@hellotext/hellotext 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hellotext.js +1 -1
- package/lib/controllers/form_controller.cjs +9 -6
- package/lib/controllers/form_controller.js +9 -6
- package/lib/hellotext.cjs +2 -2
- package/lib/hellotext.js +2 -2
- package/package.json +16 -4
- package/src/controllers/form_controller.js +12 -8
- package/src/hellotext.js +3 -3
|
@@ -96,18 +96,21 @@ let _default = /*#__PURE__*/function (_Controller) {
|
|
|
96
96
|
}, {
|
|
97
97
|
key: "showErrorMessages",
|
|
98
98
|
value: function showErrorMessages() {
|
|
99
|
-
this.
|
|
100
|
-
const
|
|
101
|
-
|
|
99
|
+
this.inputTargets.forEach(input => {
|
|
100
|
+
const errorsContainer = input.closest('article').querySelector('[data-error-container]');
|
|
101
|
+
if (input.validity.valid) {
|
|
102
|
+
errorsContainer.innerText = '';
|
|
103
|
+
} else {
|
|
104
|
+
errorsContainer.innerText = input.validationMessage;
|
|
105
|
+
}
|
|
102
106
|
});
|
|
103
107
|
}
|
|
104
108
|
}, {
|
|
105
109
|
key: "clearErrorMessages",
|
|
106
110
|
value: function clearErrorMessages() {
|
|
107
|
-
this.
|
|
111
|
+
this.inputTargets.forEach(input => {
|
|
108
112
|
input.setCustomValidity('');
|
|
109
|
-
|
|
110
|
-
parent.querySelector('[data-error-container]').innerText = '';
|
|
113
|
+
input.closest('article').querySelector('[data-error-container]').innerText = '';
|
|
111
114
|
});
|
|
112
115
|
}
|
|
113
116
|
}, {
|
|
@@ -97,18 +97,21 @@ var _default = /*#__PURE__*/function (_Controller) {
|
|
|
97
97
|
}, {
|
|
98
98
|
key: "showErrorMessages",
|
|
99
99
|
value: function showErrorMessages() {
|
|
100
|
-
this.
|
|
101
|
-
var
|
|
102
|
-
|
|
100
|
+
this.inputTargets.forEach(input => {
|
|
101
|
+
var errorsContainer = input.closest('article').querySelector('[data-error-container]');
|
|
102
|
+
if (input.validity.valid) {
|
|
103
|
+
errorsContainer.innerText = '';
|
|
104
|
+
} else {
|
|
105
|
+
errorsContainer.innerText = input.validationMessage;
|
|
106
|
+
}
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
}, {
|
|
106
110
|
key: "clearErrorMessages",
|
|
107
111
|
value: function clearErrorMessages() {
|
|
108
|
-
this.
|
|
112
|
+
this.inputTargets.forEach(input => {
|
|
109
113
|
input.setCustomValidity('');
|
|
110
|
-
|
|
111
|
-
parent.querySelector('[data-error-container]').innerText = '';
|
|
114
|
+
input.closest('article').querySelector('[data-error-container]').innerText = '';
|
|
112
115
|
});
|
|
113
116
|
}
|
|
114
117
|
}, {
|
package/lib/hellotext.cjs
CHANGED
|
@@ -33,15 +33,15 @@ let Hellotext = /*#__PURE__*/function () {
|
|
|
33
33
|
* @param { Configuration } config
|
|
34
34
|
*/
|
|
35
35
|
async function initialize(business, config) {
|
|
36
|
+
this.forms = new _models.FormCollection();
|
|
36
37
|
this.business = new _models.Business(business);
|
|
37
38
|
_core.Configuration.assign(config);
|
|
38
39
|
_models.Session.initialize();
|
|
40
|
+
this.business.fetchPublicData().then(() => this.forms.collect());
|
|
39
41
|
_classPrivateFieldLooseBase(this, _query)[_query] = new _models.Query();
|
|
40
|
-
this.forms = new _models.FormCollection();
|
|
41
42
|
if (_core.Configuration.webchat.id) {
|
|
42
43
|
this.webchat = await _models.Webchat.load(_core.Configuration.webchat.id);
|
|
43
44
|
}
|
|
44
|
-
this.forms.collect();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
package/lib/hellotext.js
CHANGED
|
@@ -31,15 +31,15 @@ var Hellotext = /*#__PURE__*/function () {
|
|
|
31
31
|
*/
|
|
32
32
|
function () {
|
|
33
33
|
var _initialize = _asyncToGenerator(function* (business, config) {
|
|
34
|
+
this.forms = new FormCollection();
|
|
34
35
|
this.business = new Business(business);
|
|
35
36
|
Configuration.assign(config);
|
|
36
37
|
Session.initialize();
|
|
38
|
+
this.business.fetchPublicData().then(() => this.forms.collect());
|
|
37
39
|
_classPrivateFieldLooseBase(this, _query)[_query] = new Query();
|
|
38
|
-
this.forms = new FormCollection();
|
|
39
40
|
if (Configuration.webchat.id) {
|
|
40
41
|
this.webchat = yield Webchat.load(Configuration.webchat.id);
|
|
41
42
|
}
|
|
42
|
-
this.forms.collect();
|
|
43
43
|
});
|
|
44
44
|
function initialize(_x, _x2) {
|
|
45
45
|
return _initialize.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hellotext/hellotext",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Hellotext JavaScript Client",
|
|
5
5
|
"source": "src/index.js",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"./lib/index.cjs"
|
|
41
41
|
],
|
|
42
42
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
43
|
+
"node": ">=20.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@babel/cli": "^7.20.7",
|
|
@@ -65,7 +65,18 @@
|
|
|
65
65
|
},
|
|
66
66
|
"keywords": [
|
|
67
67
|
"hellotext",
|
|
68
|
-
"javascript"
|
|
68
|
+
"javascript",
|
|
69
|
+
"sms",
|
|
70
|
+
"whatsapp",
|
|
71
|
+
"messaging",
|
|
72
|
+
"chat",
|
|
73
|
+
"webchat",
|
|
74
|
+
"customer-engagement",
|
|
75
|
+
"sdk",
|
|
76
|
+
"client-library",
|
|
77
|
+
"typescript",
|
|
78
|
+
"browser",
|
|
79
|
+
"node"
|
|
69
80
|
],
|
|
70
81
|
"scripts": {
|
|
71
82
|
"test": "NODE_ENV=test jest",
|
|
@@ -83,5 +94,6 @@
|
|
|
83
94
|
"@floating-ui/dom": "^1.6.12",
|
|
84
95
|
"@hotwired/stimulus": "^3.0.0",
|
|
85
96
|
"emoji-mart": "^5.6.0"
|
|
86
|
-
}
|
|
97
|
+
},
|
|
98
|
+
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
|
87
99
|
}
|
|
@@ -72,11 +72,11 @@ export default class extends Controller {
|
|
|
72
72
|
completed() {
|
|
73
73
|
this.form.markAsCompleted(this.formData)
|
|
74
74
|
|
|
75
|
-
if(!Configuration.forms.shouldShowSuccessMessage) {
|
|
75
|
+
if (!Configuration.forms.shouldShowSuccessMessage) {
|
|
76
76
|
return this.element.remove()
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
if(typeof Configuration.forms.successMessage === 'string') {
|
|
79
|
+
if (typeof Configuration.forms.successMessage === 'string') {
|
|
80
80
|
this.element.innerHTML = Configuration.forms.successMessage
|
|
81
81
|
} else {
|
|
82
82
|
this.element.innerHTML = Hellotext.business.locale.forms[this.form.localeAuthKey]
|
|
@@ -86,17 +86,21 @@ export default class extends Controller {
|
|
|
86
86
|
// private
|
|
87
87
|
|
|
88
88
|
showErrorMessages() {
|
|
89
|
-
this.
|
|
90
|
-
const
|
|
91
|
-
|
|
89
|
+
this.inputTargets.forEach(input => {
|
|
90
|
+
const errorsContainer = input.closest('article').querySelector('[data-error-container]')
|
|
91
|
+
|
|
92
|
+
if (input.validity.valid) {
|
|
93
|
+
errorsContainer.innerText = ''
|
|
94
|
+
} else {
|
|
95
|
+
errorsContainer.innerText = input.validationMessage
|
|
96
|
+
}
|
|
92
97
|
})
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
clearErrorMessages() {
|
|
96
|
-
this.
|
|
101
|
+
this.inputTargets.forEach(input => {
|
|
97
102
|
input.setCustomValidity('')
|
|
98
|
-
|
|
99
|
-
parent.querySelector('[data-error-container]').innerText = ''
|
|
103
|
+
input.closest('article').querySelector('[data-error-container]').innerText = ''
|
|
100
104
|
})
|
|
101
105
|
}
|
|
102
106
|
|
package/src/hellotext.js
CHANGED
|
@@ -20,19 +20,19 @@ class Hellotext {
|
|
|
20
20
|
* @param { Configuration } config
|
|
21
21
|
*/
|
|
22
22
|
static async initialize(business, config) {
|
|
23
|
+
this.forms = new FormCollection()
|
|
23
24
|
this.business = new Business(business)
|
|
24
25
|
|
|
25
26
|
Configuration.assign(config)
|
|
26
27
|
Session.initialize()
|
|
27
28
|
|
|
29
|
+
this.business.fetchPublicData().then(() => this.forms.collect())
|
|
30
|
+
|
|
28
31
|
this.#query = new Query()
|
|
29
|
-
this.forms = new FormCollection()
|
|
30
32
|
|
|
31
33
|
if (Configuration.webchat.id) {
|
|
32
34
|
this.webchat = await Webchat.load(Configuration.webchat.id)
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
this.forms.collect()
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|