You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add new form configuration object
* add new localization
* display tailored success messages based on the form auth state
* return none when the form does not require auth
* remove method
* yarn build
* access new property
* add logs
* update code
* update jsdocs
* remove autoMountForms from configuration
* 1.8.0
| session | A valid Hellotext session which was stored previously. When not set, Hellotext attempts to retrieve the stored value from `document.cookie` when available, otherwise it creates a new session. | String | null |
129
-
| autoGenerateSession | Whether the library should automatically generate a session when no session is found in the query or the cookies | Boolean | true |
130
-
|autoMountForms | Whether the library should automatically mount forms collected or not| Boolean | true|
| session | A valid Hellotext session which was stored previously. When not set, Hellotext attempts to retrieve the stored value from `document.cookie` when available, otherwise it creates a new session. | String | null |
129
+
| autoGenerateSession | Whether the library should automatically generate a session when no session is found in the query or the cookies | Boolean | true |
130
+
| forms | An object that controls how Hellotext should control the forms on the page. See [Forms](/docs/forms.md) documentation for more information.| Object | { autoMount: true, successMessage: true }|
Copy file name to clipboardexpand all lines: docs/forms.md
+17
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,23 @@ Then let Hellotext handle building the form, collecting, validating and authenti
5
5
6
6
For more information on how to create a form from the dashboard, view this [guide](https://help.hellotext.com/forms).
7
7
8
+
### Configuration
9
+
10
+
Hellotext forms have a default configuration that can be overridden by passing an object when initializing the library. It has the following attributes by default:
11
+
12
+
-`autoMount`: Automatically mount forms to the DOM when a `form` element with the `data-hello-form` attribute is found. Default is `true`.
13
+
-`successMessage`: Display a contextual success message when a form is submitted successfully. Default is `true`.
14
+
You can turn this off by setting it to `false`, or provide your custom success message by setting it to a string.
15
+
16
+
```javascript
17
+
Hellotext.initialize('HELLOTEXT_BUSINESS_ID', {
18
+
forms: {
19
+
autoMount:true,
20
+
successMessage:'Thank you for submitting the form'
21
+
}
22
+
})
23
+
```
24
+
8
25
### Collection Phase
9
26
10
27
Hellotext uses the `MutationObserver` API to listen for changes in the DOM, specifically new form elements being added that have the `data-hello-form` attribute.
function_toPrimitive(input,hint){if(typeofinput!=="object"||input===null)returninput;varprim=input[Symbol.toPrimitive];if(prim!==undefined){varres=prim.call(input,hint||"default");if(typeofres!=="object")returnres;thrownewTypeError("@@toPrimitive must return a primitive value.");}return(hint==="string" ? String : Number)(input);}
13
+
/**
14
+
* @class Configuration
15
+
* @classdesc
16
+
* Configuration for Hellotext
17
+
* @property {Boolean} [autoGenerateSession=true] - whether to auto generate session or not
18
+
* @property {String} [session] - session id
19
+
* @property {Forms} [forms] - form configuration
20
+
*/
12
21
varConfiguration=/*#__PURE__*/function(){
13
22
functionConfiguration(){
14
23
_classCallCheck(this,Configuration);
15
24
}
16
25
_createClass(Configuration,null,[{
17
26
key: "assign",
18
-
value: functionassign(props){
27
+
value:
28
+
/**
29
+
*
30
+
* @param props
31
+
* @param {Boolean} [props.autoGenerateSession=true] - whether to auto generate session or not
32
+
* @param {String} [props.session] - session id
33
+
* @param {Object} [props.forms] - form configuration
34
+
* @returns {Configuration}
35
+
*/
36
+
functionassign(props){
19
37
if(props){
20
38
Object.entries(props).forEach(_ref=>{
21
39
var[key,value]=_ref;
22
-
this[key]=value;
40
+
if(key==='forms'){
41
+
this.forms=_forms.Forms.assign(value);
42
+
}else{
43
+
this[key]=value;
44
+
}
23
45
});
24
46
}
25
47
returnthis;
@@ -35,5 +57,5 @@ var Configuration = /*#__PURE__*/function () {
function_toPrimitive(input,hint){if(typeofinput!=="object"||input===null)returninput;varprim=input[Symbol.toPrimitive];if(prim!==undefined){varres=prim.call(input,hint||"default");if(typeofres!=="object")returnres;thrownewTypeError("@@toPrimitive must return a primitive value.");}return(hint==="string" ? String : Number)(input);}
12
+
/**
13
+
* @class Forms
14
+
* @classdesc
15
+
* Configuration for forms
16
+
* @property {Boolean} autoMount - whether to auto mount forms
17
+
* @property {Boolean|String} successMessage - whether to show success message after form completion or not
18
+
*/
19
+
varForms=/*#__PURE__*/function(){
20
+
functionForms(){
21
+
_classCallCheck(this,Forms);
22
+
}
23
+
_createClass(Forms,null,[{
24
+
key: "assign",
25
+
value:
26
+
/**
27
+
* @param {Object} props
28
+
* @param {Boolean} [props.autoMount=true] - whether to auto mount forms
29
+
* @param {Boolean|String} [props.successMessage=true] - whether to show success message after form completion or not
0 commit comments