@hellotext/hellotext 2.0.2 → 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.
@@ -96,18 +96,21 @@ let _default = /*#__PURE__*/function (_Controller) {
96
96
  }, {
97
97
  key: "showErrorMessages",
98
98
  value: function showErrorMessages() {
99
- this.element.querySelectorAll('input:invalid').forEach(input => {
100
- const parent = input.closest('article');
101
- parent.querySelector('[data-error-container]').innerText = input.validationMessage;
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.element.querySelectorAll('input').forEach(input => {
111
+ this.inputTargets.forEach(input => {
108
112
  input.setCustomValidity('');
109
- const parent = input.closest('article');
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.element.querySelectorAll('input:invalid').forEach(input => {
101
- var parent = input.closest('article');
102
- parent.querySelector('[data-error-container]').innerText = input.validationMessage;
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.element.querySelectorAll('input').forEach(input => {
112
+ this.inputTargets.forEach(input => {
109
113
  input.setCustomValidity('');
110
- var parent = input.closest('article');
111
- parent.querySelector('[data-error-container]').innerText = '';
114
+ input.closest('article').querySelector('[data-error-container]').innerText = '';
112
115
  });
113
116
  }
114
117
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellotext/hellotext",
3
- "version": "2.0.2",
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": ">=14.0.0"
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.element.querySelectorAll('input:invalid').forEach(input => {
90
- const parent = input.closest('article')
91
- parent.querySelector('[data-error-container]').innerText = input.validationMessage
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.element.querySelectorAll('input').forEach(input => {
101
+ this.inputTargets.forEach(input => {
97
102
  input.setCustomValidity('')
98
- const parent = input.closest('article')
99
- parent.querySelector('[data-error-container]').innerText = ''
103
+ input.closest('article').querySelector('[data-error-container]').innerText = ''
100
104
  })
101
105
  }
102
106