@descope/web-components-ui 3.2.2 → 3.3.1

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.
Files changed (26) hide show
  1. package/dist/cjs/index.cjs.js +87 -10
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +106 -12
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/umd/DescopeDev.js +1 -1
  6. package/dist/umd/DescopeDev.js.map +1 -1
  7. package/dist/umd/descope-hybrid-field-index-js.js +2 -2
  8. package/dist/umd/descope-hybrid-field-index-js.js.map +1 -1
  9. package/dist/umd/descope-recaptcha-index-js.js +1 -1
  10. package/dist/umd/descope-recaptcha-index-js.js.map +1 -1
  11. package/dist/umd/index.js +1 -1
  12. package/dist/umd/phone-fields-descope-phone-field-descope-phone-field-internal-index-js.js +1 -1
  13. package/dist/umd/phone-fields-descope-phone-field-descope-phone-field-internal-index-js.js.map +1 -1
  14. package/dist/umd/phone-fields-descope-phone-field-index-js.js +1 -1
  15. package/dist/umd/phone-fields-descope-phone-field-index-js.js.map +1 -1
  16. package/dist/umd/phone-fields-descope-phone-input-box-field-descope-phone-input-box-internal-index-js.js +1 -1
  17. package/dist/umd/phone-fields-descope-phone-input-box-field-descope-phone-input-box-internal-index-js.js.map +1 -1
  18. package/dist/umd/phone-fields-descope-phone-input-box-field-index-js.js +1 -1
  19. package/dist/umd/phone-fields-descope-phone-input-box-field-index-js.js.map +1 -1
  20. package/package.json +32 -32
  21. package/src/components/descope-hybrid-field/HybridFieldClass.js +4 -2
  22. package/src/components/descope-recaptcha/RecaptchaClass.js +81 -8
  23. package/src/components/phone-fields/descope-phone-field/PhoneFieldClass.js +1 -0
  24. package/src/components/phone-fields/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js +12 -2
  25. package/src/components/phone-fields/descope-phone-input-box-field/PhoneFieldInputBoxClass.js +1 -0
  26. package/src/components/phone-fields/descope-phone-input-box-field/descope-phone-input-box-internal/PhoneFieldInternalInputBox.js +7 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/web-components-ui",
3
- "version": "3.2.2",
3
+ "version": "3.3.1",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -51,10 +51,10 @@
51
51
  "webpack-cli": "^7.0.0",
52
52
  "webpack-dev-server": "^5.0.0",
53
53
  "webpack-subresource-integrity": "5.2.0-rc.1",
54
- "rollup-replace-plugin": "3.2.2",
55
- "webpack-extract-font-loader": "3.2.2",
56
- "webpack-replace-plugin": "3.2.2",
57
- "test-drivers": "3.2.2"
54
+ "rollup-replace-plugin": "3.3.1",
55
+ "test-drivers": "3.3.1",
56
+ "webpack-extract-font-loader": "3.3.1",
57
+ "webpack-replace-plugin": "3.3.1"
58
58
  },
59
59
  "dependencies": {
60
60
  "@vaadin/checkbox": "24.3.4",
@@ -78,33 +78,33 @@
78
78
  "libphonenumber-js": "^1.11.12",
79
79
  "lodash.debounce": "4.0.8",
80
80
  "lodash.merge": "4.6.2",
81
- "@descope-ui/descope-address-field": "3.2.2",
82
- "@descope-ui/descope-country-subdivision-city-field": "3.2.2",
83
- "@descope-ui/common": "3.2.2",
84
- "@descope-ui/descope-apps-list": "3.2.2",
85
- "@descope-ui/descope-autocomplete-field": "3.2.2",
86
- "@descope-ui/descope-avatar": "3.2.2",
87
- "@descope-ui/descope-badge": "3.2.2",
88
- "@descope-ui/descope-button": "3.2.2",
89
- "@descope-ui/descope-collapsible-container": "3.2.2",
90
- "@descope-ui/descope-combo-box": "3.2.2",
91
- "@descope-ui/descope-icon": "3.2.2",
92
- "@descope-ui/descope-link": "3.2.2",
93
- "@descope-ui/descope-list": "3.2.2",
94
- "@descope-ui/descope-list-item": "3.2.2",
95
- "@descope-ui/descope-outbound-app-button": "3.2.2",
96
- "@descope-ui/descope-outbound-apps": "3.2.2",
97
- "@descope-ui/descope-enriched-text": "3.2.2",
98
- "@descope-ui/descope-password-strength": "3.2.2",
99
- "@descope-ui/descope-ponyhot": "3.2.2",
100
- "@descope-ui/descope-recovery-codes": "3.2.2",
101
- "@descope-ui/descope-text": "3.2.2",
102
- "@descope-ui/descope-timer": "3.2.2",
103
- "@descope-ui/descope-image": "3.2.2",
104
- "@descope-ui/descope-tooltip": "3.2.2",
105
- "@descope-ui/descope-trusted-devices": "3.2.2",
106
- "@descope-ui/descope-attachment": "3.2.2",
107
- "@descope-ui/descope-timer-button": "3.2.2"
81
+ "@descope-ui/common": "3.3.1",
82
+ "@descope-ui/descope-address-field": "3.3.1",
83
+ "@descope-ui/descope-country-subdivision-city-field": "3.3.1",
84
+ "@descope-ui/descope-avatar": "3.3.1",
85
+ "@descope-ui/descope-badge": "3.3.1",
86
+ "@descope-ui/descope-button": "3.3.1",
87
+ "@descope-ui/descope-autocomplete-field": "3.3.1",
88
+ "@descope-ui/descope-apps-list": "3.3.1",
89
+ "@descope-ui/descope-combo-box": "3.3.1",
90
+ "@descope-ui/descope-collapsible-container": "3.3.1",
91
+ "@descope-ui/descope-enriched-text": "3.3.1",
92
+ "@descope-ui/descope-image": "3.3.1",
93
+ "@descope-ui/descope-link": "3.3.1",
94
+ "@descope-ui/descope-icon": "3.3.1",
95
+ "@descope-ui/descope-list": "3.3.1",
96
+ "@descope-ui/descope-list-item": "3.3.1",
97
+ "@descope-ui/descope-outbound-app-button": "3.3.1",
98
+ "@descope-ui/descope-outbound-apps": "3.3.1",
99
+ "@descope-ui/descope-password-strength": "3.3.1",
100
+ "@descope-ui/descope-ponyhot": "3.3.1",
101
+ "@descope-ui/descope-recovery-codes": "3.3.1",
102
+ "@descope-ui/descope-text": "3.3.1",
103
+ "@descope-ui/descope-timer": "3.3.1",
104
+ "@descope-ui/descope-timer-button": "3.3.1",
105
+ "@descope-ui/descope-tooltip": "3.3.1",
106
+ "@descope-ui/descope-trusted-devices": "3.3.1",
107
+ "@descope-ui/descope-attachment": "3.3.1"
108
108
  },
109
109
  "overrides": {
110
110
  "@vaadin/avatar": "24.3.4",
@@ -40,6 +40,7 @@ const attrs = {
40
40
  'phone-minlength',
41
41
  'phone-format-value',
42
42
  'phone-strict-validation',
43
+ 'phone-input-type',
43
44
  'data-errormessage-value-missing-phone',
44
45
  ],
45
46
  inputBox: [
@@ -48,6 +49,7 @@ const attrs = {
48
49
  'phone-minlength',
49
50
  'phone-format-value',
50
51
  'phone-strict-validation',
52
+ 'phone-input-type',
51
53
  'data-errormessage-value-missing-phone',
52
54
  ],
53
55
  },
@@ -87,8 +89,8 @@ class RawHybridField extends BaseClass {
87
89
  this.attachShadow({ mode: 'open' }).innerHTML = `
88
90
  <div class="wrapper">
89
91
  <descope-email-field external-input="${this.isExternalInput}"></descope-email-field>
90
- <descope-phone-field allow-alphanumeric-input="true"></descope-phone-field>
91
- <descope-phone-input-box-field allow-alphanumeric-input="true"></descope-phone-input-box-field>
92
+ <descope-phone-field allow-alphanumeric-input="true" phone-input-type="text"></descope-phone-field>
93
+ <descope-phone-input-box-field allow-alphanumeric-input="true" phone-input-type="text"></descope-phone-input-box-field>
92
94
  </div>
93
95
  `;
94
96
 
@@ -6,7 +6,7 @@ import { getComponentName, observeChildren } from '../../helpers/componentHelper
6
6
 
7
7
  export const componentName = getComponentName('recaptcha');
8
8
 
9
- const observedAttributes = ['enabled', 'site-key', 'action', 'enterprise'];
9
+ const observedAttributes = ['enabled', 'site-key', 'action', 'enterprise', 'variant'];
10
10
 
11
11
  const BaseClass = createBaseClass({
12
12
  componentName,
@@ -23,6 +23,10 @@ class RawRecaptcha extends BaseClass {
23
23
  if (attrName === 'enabled') {
24
24
  this.#toggleRecaptcha(newValue === 'true');
25
25
  }
26
+
27
+ if (attrName === 'variant') {
28
+ this.updatePreview();
29
+ }
26
30
  }
27
31
  }
28
32
 
@@ -35,13 +39,37 @@ class RawRecaptcha extends BaseClass {
35
39
  this.toggleRecaptchaEles(enabled);
36
40
  }
37
41
 
42
+ displayRecaptcha() {
43
+ if (this.isWidget) {
44
+ this.displayWidget();
45
+ } else {
46
+ this.displayDeprecated();
47
+ }
48
+ }
49
+
50
+ displayWidget() {
51
+ this.mockRecaptchaEle.style.display = 'none';
52
+ this.recaptchaWidgetEle.style.display = '';
53
+ this.depercatedRecaptchaEle.style.display = 'none';
54
+ }
55
+
56
+ hideRecaptcha() {
57
+ this.recaptchaWidgetEle.style.display = 'none';
58
+ this.depercatedRecaptchaEle.style.display = 'none';
59
+ this.mockRecaptchaEle.style.display = '';
60
+ }
61
+
62
+ displayDeprecated() {
63
+ this.mockRecaptchaEle.style.display = 'none';
64
+ this.recaptchaWidgetEle.style.display = 'none';
65
+ this.depercatedRecaptchaEle.style.display = '';
66
+ }
67
+
38
68
  toggleRecaptchaEles(enabled) {
39
69
  if (enabled) {
40
- this.recaptchaEle.style.display = '';
41
- this.mockRecaptchaEle.style.display = 'none';
70
+ this.displayRecaptcha();
42
71
  } else {
43
- this.recaptchaEle.style.display = 'none';
44
- this.mockRecaptchaEle.style.display = '';
72
+ this.hideRecaptcha();
45
73
  }
46
74
  }
47
75
 
@@ -51,6 +79,8 @@ class RawRecaptcha extends BaseClass {
51
79
  this.attachShadow({ mode: 'open' }).innerHTML = `
52
80
  <div class="badge">
53
81
  <span id="recaptcha"></span>
82
+ <span id="recaptcha-widget"></span>
83
+ <input id="recaptcha-widget-input" type="hidden" name="recaptcha-widget" required />
54
84
  <img src="https://imgs.descope.com/connectors/templates/recaptcha/recaptcha-big.png" alt="recaptcha"/>
55
85
  </div>
56
86
  <slot></slot>
@@ -74,6 +104,13 @@ class RawRecaptcha extends BaseClass {
74
104
  width: 100%;
75
105
  height: 100%;
76
106
  }
107
+ :host #recaptcha-widget {
108
+ width: 100%;
109
+ height: 100%;
110
+ }
111
+ :host #recaptcha-widget-input {
112
+ display: none;
113
+ }
77
114
  :host img {
78
115
  width: 256px;
79
116
  }
@@ -87,7 +124,9 @@ class RawRecaptcha extends BaseClass {
87
124
  this
88
125
  );
89
126
 
90
- this.recaptchaEle = this.baseElement.querySelector('#recaptcha');
127
+ this.depercatedRecaptchaEle = this.baseElement.querySelector('#recaptcha');
128
+ this.recaptchaWidgetEle = this.baseElement.querySelector('#recaptcha-widget');
129
+ this.recaptchaWidgetInputEle = this.baseElement.querySelector('#recaptcha-widget-input');
91
130
  this.mockRecaptchaEle = this.baseElement.querySelector('img');
92
131
  this.badge = this.shadowRoot.querySelector('.badge');
93
132
  }
@@ -100,7 +139,8 @@ class RawRecaptcha extends BaseClass {
100
139
 
101
140
  updatePreview() {
102
141
  if (this.children.length) {
103
- this.recaptchaEle.style.display = 'none';
142
+ this.depercatedRecaptchaEle.style.display = 'none';
143
+ this.recaptchaWidgetEle.style.display = 'none';
104
144
  this.mockRecaptchaEle.style.display = 'none';
105
145
  this.badge.classList.add('hidden');
106
146
  } else {
@@ -109,6 +149,26 @@ class RawRecaptcha extends BaseClass {
109
149
  }
110
150
  }
111
151
 
152
+ getValidity() {
153
+ if (!this.isWidget) {
154
+ return {};
155
+ }
156
+
157
+ if (!this.recaptchaWidgetInputEle.value) {
158
+ return { valueMissing: true };
159
+ }
160
+
161
+ return {};
162
+ }
163
+
164
+ checkValidity() {
165
+ if (!this.isWidget) {
166
+ return true;
167
+ }
168
+
169
+ return !!this.recaptchaWidgetInputEle.value;
170
+ }
171
+
112
172
  get enterprise() {
113
173
  return this.getAttribute('enterprise') === 'true';
114
174
  }
@@ -125,6 +185,14 @@ class RawRecaptcha extends BaseClass {
125
185
  return this.getAttribute('enabled') === 'true';
126
186
  }
127
187
 
188
+ get variant() {
189
+ return this.getAttribute('variant') || 'text';
190
+ }
191
+
192
+ get isWidget() {
193
+ return this.variant === 'widget';
194
+ }
195
+
128
196
  get scriptURL() {
129
197
  const url = new URL('https://www.google.com/recaptcha/');
130
198
  url.pathname += `${this.enterprise ? 'enterprise' : 'api'}.js`;
@@ -135,6 +203,11 @@ class RawRecaptcha extends BaseClass {
135
203
 
136
204
  #toggleRecaptcha(enabled) {
137
205
  this.renderRecaptcha(enabled);
206
+ if (this.isWidget) {
207
+ // For the v2 checkbox flow, scripts are loaded/executed by the runtime (grecaptcha-v2).
208
+ // This legacy v3/invisible path must be fully skipped.
209
+ return;
210
+ }
138
211
  if (enabled) {
139
212
  this.#createOnLoadScript();
140
213
  if (!document.getElementById('recaptcha-script')) {
@@ -207,7 +280,7 @@ class RawRecaptcha extends BaseClass {
207
280
 
208
281
  #createOnLoadScript() {
209
282
  window.onRecaptchaLoadCallback = () => {
210
- const currentNode = this.recaptchaEle;
283
+ const currentNode = this.depercatedRecaptchaEle;
211
284
 
212
285
  // if there are child nodes, it means that the recaptcha was already rendered
213
286
  if (currentNode.hasChildNodes()) {
@@ -64,6 +64,7 @@ const customMixin = (superclass) =>
64
64
  'allow-alphanumeric-input',
65
65
  'format-value',
66
66
  'strict-validation',
67
+ 'phone-input-type',
67
68
  ],
68
69
  });
69
70
  }
@@ -8,12 +8,19 @@ export const componentName = getComponentName('phone-field-internal');
8
8
 
9
9
  const commonAttrs = ['disabled', 'size', 'bordered', 'readonly'];
10
10
  const countryAttrs = ['country-input-placeholder', 'default-code', 'restrict-countries'];
11
- const phoneAttrs = ['phone-input-placeholder', 'maxlength', 'autocomplete', 'name'];
11
+ const phoneAttrs = [
12
+ 'phone-input-placeholder',
13
+ 'maxlength',
14
+ 'autocomplete',
15
+ 'name',
16
+ 'phone-input-type',
17
+ ];
12
18
  const labelTypeAttrs = ['label-type', 'country-input-label', 'label'];
13
19
  const mapAttrs = {
14
20
  'country-input-label': 'label',
15
21
  'country-input-placeholder': 'placeholder',
16
22
  'phone-input-placeholder': 'placeholder',
23
+ 'phone-input-type': 'type',
17
24
  };
18
25
 
19
26
  const inputRelatedAttrs = [].concat(commonAttrs, countryAttrs, phoneAttrs, labelTypeAttrs);
@@ -49,7 +56,10 @@ class PhoneFieldInternal extends BaseInputClass {
49
56
  this.inputs = [this.comboBox, this.textField];
50
57
 
51
58
  forwardAttrs(this, this.comboBox, { includeAttrs: ['label-type'] });
52
- forwardAttrs(this, this.textField, { includeAttrs: ['label-type', 'required'] });
59
+ forwardAttrs(this, this.textField, {
60
+ includeAttrs: ['label-type', 'required', 'phone-input-type'],
61
+ mapAttrs: { 'phone-input-type': 'type' },
62
+ });
53
63
 
54
64
  // override combo box setter to display dialCode value in input
55
65
  this.comboBox.customValueTransformFn = (val) => {
@@ -63,6 +63,7 @@ const customMixin = (superclass) =>
63
63
  'format-value',
64
64
  'strict-validation',
65
65
  'data-errormessage-type-mismatch',
66
+ 'phone-input-type',
66
67
  ],
67
68
  });
68
69
  }
@@ -15,9 +15,11 @@ const observedAttributes = [
15
15
  'maxlength',
16
16
  'autocomplete',
17
17
  'label-type',
18
+ 'phone-input-type',
18
19
  ];
19
20
  const mapAttrs = {
20
21
  'phone-input-placeholder': 'placeholder',
22
+ 'phone-input-type': 'type',
21
23
  };
22
24
 
23
25
  const BaseInputClass = createBaseInputClass({ componentName, baseSelector: 'div' });
@@ -111,6 +113,11 @@ class PhoneFieldInternal extends BaseInputClass {
111
113
  this.handleFocusEventsDispatching([this.textField]);
112
114
 
113
115
  forwardAttrs(this.textField, this, { includeAttrs: ['has-value'] });
116
+
117
+ forwardAttrs(this, this.textField, {
118
+ includeAttrs: ['phone-input-type'],
119
+ mapAttrs: { 'phone-input-type': 'type' },
120
+ });
114
121
  }
115
122
 
116
123
  getValidity() {