@descope/web-components-ui 1.0.158 → 1.0.160

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/dist/cjs/index.cjs.js +310 -129
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.esm.js +337 -155
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/umd/1000.js +1 -0
  7. package/dist/umd/2481.js +1 -1
  8. package/dist/umd/3585.js +1 -1
  9. package/dist/umd/3878.js +1 -1
  10. package/dist/umd/boolean-fields-descope-checkbox-index-js.js +1 -1
  11. package/dist/umd/boolean-fields-descope-switch-toggle-index-js.js +1 -1
  12. package/dist/umd/descope-button-index-js.js +1 -1
  13. package/dist/umd/descope-combo-box-index-js.js +1 -1
  14. package/dist/umd/descope-container-index-js.js +1 -1
  15. package/dist/umd/descope-date-picker-index-js.js +1 -1
  16. package/dist/umd/descope-divider-index-js.js +1 -1
  17. package/dist/umd/descope-email-field-index-js.js +1 -1
  18. package/dist/umd/descope-image-index-js.js +1 -1
  19. package/dist/umd/descope-link-index-js.js +1 -1
  20. package/dist/umd/descope-loader-linear-index-js.js +1 -1
  21. package/dist/umd/descope-loader-radial-index-js.js +1 -1
  22. package/dist/umd/descope-new-password-descope-new-password-internal-index-js.js +1 -1
  23. package/dist/umd/descope-number-field-index-js.js +1 -1
  24. package/dist/umd/descope-passcode-index-js.js +1 -1
  25. package/dist/umd/descope-phone-field-descope-phone-field-internal-index-js.js +1 -1
  26. package/dist/umd/descope-phone-field-index-js.js +1 -1
  27. package/dist/umd/descope-recaptcha-index-js.js +1 -0
  28. package/dist/umd/descope-text-area-index-js.js +1 -1
  29. package/dist/umd/descope-text-field-index-js.js +1 -1
  30. package/dist/umd/descope-text-index-js.js +1 -1
  31. package/dist/umd/descope-upload-file-index-js.js +1 -1
  32. package/dist/umd/index.js +1 -1
  33. package/package.json +1 -1
  34. package/src/baseClasses/createBaseClass.js +3 -1
  35. package/src/components/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js +1 -1
  36. package/src/components/descope-recaptcha/RecaptchaClass.js +161 -0
  37. package/src/components/descope-recaptcha/index.js +5 -0
  38. package/src/index.cjs.js +1 -0
  39. package/src/index.d.ts +1 -0
  40. package/src/index.js +1 -0
  41. package/src/mixins/componentsContextMixin.js +16 -0
  42. package/src/mixins/proxyInputMixin.js +46 -39
  43. package/dist/umd/9241.js +0 -1
package/dist/index.esm.js CHANGED
@@ -498,6 +498,32 @@ const componentNameValidationMixin = (superclass) =>
498
498
  }
499
499
  };
500
500
 
501
+ // create a dispatch event function that also calls to the onevent function in case it's set
502
+ // usage example:
503
+ // #dispatchSomething = createDispatchEvent.bind(this, 'something' { ...options })
504
+ // this will dispatch a new event when called, but also call to "onsomething"
505
+ function createDispatchEvent(eventName, options = {}) {
506
+ const event = new Event(eventName, options);
507
+
508
+ this[`on${eventName}`]?.(event); // in case we got an event callback as property
509
+ this.dispatchEvent(event);
510
+ }
511
+
512
+ const componentsContextMixin = (superclass) =>
513
+ class ComponentsContextMixinClass extends superclass {
514
+ #dispatchComponentsContext = createDispatchEvent.bind(this, 'components-context');
515
+
516
+ updateComponentsContext(componentsContext) {
517
+ this.dispatchEvent(
518
+ new CustomEvent('components-context', {
519
+ bubbles: true,
520
+ composed: true,
521
+ detail: componentsContext,
522
+ })
523
+ );
524
+ }
525
+ };
526
+
501
527
  const hoverableMixin = (superclass) =>
502
528
  class HoverableMixinClass extends superclass {
503
529
  init() {
@@ -621,21 +647,11 @@ const createBaseClass = ({ componentName, baseSelector = '' }) => {
621
647
  return compose(
622
648
  componentNameValidationMixin,
623
649
  hoverableMixin,
624
- normalizeBooleanAttributesMixin
650
+ normalizeBooleanAttributesMixin,
651
+ componentsContextMixin
625
652
  )(DescopeBaseClass);
626
653
  };
627
654
 
628
- // create a dispatch event function that also calls to the onevent function in case it's set
629
- // usage example:
630
- // #dispatchSomething = createDispatchEvent.bind(this, 'something' { ...options })
631
- // this will dispatch a new event when called, but also call to "onsomething"
632
- function createDispatchEvent(eventName, options = {}) {
633
- const event = new Event(eventName, options);
634
-
635
- this[`on${eventName}`]?.(event); // in case we got an event callback as property
636
- this.dispatchEvent(event);
637
- }
638
-
639
655
  const createProxy = ({
640
656
  componentName,
641
657
  wrappedEleName,
@@ -684,7 +700,7 @@ const createProxy = ({
684
700
  return ProxyClass;
685
701
  };
686
702
 
687
- const observedAttributes$4 = ['required', 'pattern'];
703
+ const observedAttributes$5 = ['required', 'pattern'];
688
704
 
689
705
  const errorAttributes = {
690
706
  valueMissing: 'data-errormessage-value-missing',
@@ -695,7 +711,7 @@ const errorAttributes = {
695
711
  const inputValidationMixin = (superclass) =>
696
712
  class InputValidationMixinClass extends superclass {
697
713
  static get observedAttributes() {
698
- return [...(superclass.observedAttributes || []), ...observedAttributes$4];
714
+ return [...(superclass.observedAttributes || []), ...observedAttributes$5];
699
715
  }
700
716
 
701
717
  static get formAssociated() {
@@ -826,7 +842,7 @@ const inputValidationMixin = (superclass) =>
826
842
  attributeChangedCallback(attrName, oldValue, newValue) {
827
843
  super.attributeChangedCallback?.(attrName, oldValue, newValue);
828
844
 
829
- if (observedAttributes$4.includes(attrName)) {
845
+ if (observedAttributes$5.includes(attrName)) {
830
846
  this.#setValidity();
831
847
  }
832
848
  }
@@ -903,12 +919,14 @@ const proxyInputMixin = (superclass) =>
903
919
  }
904
920
 
905
921
  get inputElement() {
922
+ if (this.#inputElement) return this.#inputElement
923
+
906
924
  this.warnIfInputElementIsMissing();
907
925
 
908
926
  const inputSlot = this.baseElement.shadowRoot?.querySelector('slot[name="input"]');
909
927
  const textAreaSlot = this.baseElement.shadowRoot?.querySelector('slot[name="textarea"]');
910
928
 
911
- this.#inputElement ??= getNestedInput(inputSlot) || getNestedInput(textAreaSlot);
929
+ this.#inputElement = getNestedInput(inputSlot) || getNestedInput(textAreaSlot);
912
930
 
913
931
  return this.#inputElement;
914
932
  }
@@ -935,49 +953,54 @@ const proxyInputMixin = (superclass) =>
935
953
  init() {
936
954
  super.init?.();
937
955
 
938
- this.inputElement.addEventListener('input', (e) => {
939
- if (!this.inputElement.checkValidity()) {
940
- this.inputElement.setCustomValidity('');
941
- // after updating the input validity we want to trigger set validity on the wrapping element
942
- // so we will get the updated validity
943
- this.setCustomValidity('');
944
-
945
- // Vaadin is getting the input event before us,
946
- // so in order to make sure they use the updated validity
947
- // we calling their fn after updating the input validity
948
- this.baseElement.__onInput(e);
956
+ // on some cases the base element is not ready so the inputElement is empty
957
+ // we are deferring this section to make sure the base element is ready
958
+ setTimeout(() => {
959
+ this.inputElement.addEventListener('input', (e) => {
960
+ if (!this.inputElement.checkValidity()) {
961
+ this.inputElement.setCustomValidity('');
962
+ // after updating the input validity we want to trigger set validity on the wrapping element
963
+ // so we will get the updated validity
964
+ this.setCustomValidity('');
965
+
966
+ // Vaadin is getting the input event before us,
967
+ // so in order to make sure they use the updated validity
968
+ // we calling their fn after updating the input validity
969
+ this.baseElement.__onInput(e);
970
+
971
+ this.#handleErrorMessage();
972
+ }
973
+ });
949
974
 
950
- this.#handleErrorMessage();
951
- }
952
- });
975
+ this.baseElement.addEventListener('change', () => {
976
+ this.#dispatchChange();
977
+ });
953
978
 
954
- this.baseElement.addEventListener('change', () => {
955
- this.#dispatchChange();
956
- });
979
+ this.#inputElement.addEventListener('blur', () => {
980
+ if (!this.checkValidity()) {
981
+ this.setAttribute('invalid', 'true');
982
+ this.#handleErrorMessage();
983
+ }
984
+ });
957
985
 
958
- this.#inputElement.addEventListener('blur', () => {
959
- if (!this.checkValidity()) {
960
- this.setAttribute('invalid', 'true');
986
+ this.addEventListener('invalid', () => {
987
+ if (!this.checkValidity()) {
988
+ this.setAttribute('invalid', 'true');
989
+ }
961
990
  this.#handleErrorMessage();
962
- }
963
- });
964
-
965
- this.addEventListener('invalid', () => {
966
- if (!this.checkValidity()) {
967
- this.setAttribute('invalid', 'true');
968
- }
969
- this.#handleErrorMessage();
970
- });
991
+ });
971
992
 
972
- this.handleInternalInputErrorMessage();
993
+ this.handleInternalInputErrorMessage();
973
994
 
974
- // sync properties
975
- propertyObserver(this, this.inputElement, 'value');
976
- propertyObserver(this, this.inputElement, 'selectionStart');
977
- this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
995
+ // sync properties
996
+ propertyObserver(this, this.inputElement, 'value');
997
+ propertyObserver(this, this.inputElement, 'selectionStart');
998
+ this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
978
999
 
979
- forwardAttrs(this, this.inputElement, { includeAttrs: ['inputmode'] });
1000
+ forwardAttrs(this, this.inputElement, { includeAttrs: ['inputmode'] });
1001
+ });
980
1002
  }
1003
+
981
1004
  };
982
1005
 
983
1006
  const composedProxyInputMixin = compose(
@@ -1163,7 +1186,7 @@ const clickableMixin = (superclass) =>
1163
1186
  }
1164
1187
  };
1165
1188
 
1166
- const componentName$q = getComponentName('button');
1189
+ const componentName$r = getComponentName('button');
1167
1190
 
1168
1191
  const resetStyles = `
1169
1192
  :host {
@@ -1257,7 +1280,7 @@ const ButtonClass = compose(
1257
1280
  }
1258
1281
  `,
1259
1282
  excludeAttrsSync: ['tabindex'],
1260
- componentName: componentName$q,
1283
+ componentName: componentName$r,
1261
1284
  })
1262
1285
  );
1263
1286
 
@@ -1294,7 +1317,7 @@ loadingIndicatorStyles = `
1294
1317
  }
1295
1318
  `;
1296
1319
 
1297
- customElements.define(componentName$q, ButtonClass);
1320
+ customElements.define(componentName$r, ButtonClass);
1298
1321
 
1299
1322
  const createBaseInputClass = (...args) =>
1300
1323
  compose(
@@ -1304,11 +1327,11 @@ const createBaseInputClass = (...args) =>
1304
1327
  inputEventsDispatchingMixin
1305
1328
  )(createBaseClass(...args));
1306
1329
 
1307
- const componentName$p = getComponentName('boolean-field-internal');
1330
+ const componentName$q = getComponentName('boolean-field-internal');
1308
1331
 
1309
1332
  const forwardAttributes$1 = ['disabled', 'label', 'invalid', 'readonly'];
1310
1333
 
1311
- const BaseInputClass$4 = createBaseInputClass({ componentName: componentName$p, baseSelector: 'div' });
1334
+ const BaseInputClass$4 = createBaseInputClass({ componentName: componentName$q, baseSelector: 'div' });
1312
1335
 
1313
1336
  class BooleanInputInternal extends BaseInputClass$4 {
1314
1337
  constructor() {
@@ -1368,14 +1391,14 @@ const booleanFieldMixin = (superclass) =>
1368
1391
 
1369
1392
  const template = document.createElement('template');
1370
1393
  template.innerHTML = `
1371
- <${componentName$p}
1394
+ <${componentName$q}
1372
1395
  tabindex="-1"
1373
1396
  slot="input"
1374
- ></${componentName$p}>
1397
+ ></${componentName$q}>
1375
1398
  `;
1376
1399
 
1377
1400
  this.baseElement.appendChild(template.content.cloneNode(true));
1378
- this.inputElement = this.shadowRoot.querySelector(componentName$p);
1401
+ this.inputElement = this.shadowRoot.querySelector(componentName$q);
1379
1402
  this.checkbox = this.inputElement.querySelector('vaadin-checkbox');
1380
1403
 
1381
1404
  forwardAttrs(this, this.inputElement, {
@@ -1555,7 +1578,7 @@ vaadin-checkbox::part(checkbox) {
1555
1578
  }
1556
1579
  `;
1557
1580
 
1558
- const componentName$o = getComponentName('checkbox');
1581
+ const componentName$p = getComponentName('checkbox');
1559
1582
 
1560
1583
  const {
1561
1584
  host: host$c,
@@ -1645,15 +1668,15 @@ const CheckboxClass = compose(
1645
1668
  ${useHostExternalPadding(CheckboxClass.cssVarList)}
1646
1669
  `,
1647
1670
  excludeAttrsSync: ['tabindex'],
1648
- componentName: componentName$o,
1671
+ componentName: componentName$p,
1649
1672
  })
1650
1673
  );
1651
1674
 
1652
- customElements.define(componentName$p, BooleanInputInternal);
1675
+ customElements.define(componentName$q, BooleanInputInternal);
1653
1676
 
1654
- customElements.define(componentName$o, CheckboxClass);
1677
+ customElements.define(componentName$p, CheckboxClass);
1655
1678
 
1656
- const componentName$n = getComponentName('switch-toggle');
1679
+ const componentName$o = getComponentName('switch-toggle');
1657
1680
 
1658
1681
  const {
1659
1682
  host: host$b,
@@ -1756,17 +1779,17 @@ const SwitchToggleClass = compose(
1756
1779
  }
1757
1780
  `,
1758
1781
  excludeAttrsSync: ['tabindex'],
1759
- componentName: componentName$n,
1782
+ componentName: componentName$o,
1760
1783
  })
1761
1784
  );
1762
1785
 
1763
- customElements.define(componentName$n, SwitchToggleClass);
1786
+ customElements.define(componentName$o, SwitchToggleClass);
1764
1787
 
1765
- const componentName$m = getComponentName('loader-linear');
1788
+ const componentName$n = getComponentName('loader-linear');
1766
1789
 
1767
- class RawLoaderLinear extends createBaseClass({ componentName: componentName$m, baseSelector: ':host > div' }) {
1790
+ class RawLoaderLinear extends createBaseClass({ componentName: componentName$n, baseSelector: ':host > div' }) {
1768
1791
  static get componentName() {
1769
- return componentName$m;
1792
+ return componentName$n;
1770
1793
  }
1771
1794
 
1772
1795
  constructor() {
@@ -1827,11 +1850,11 @@ const LoaderLinearClass = compose(
1827
1850
  componentNameValidationMixin
1828
1851
  )(RawLoaderLinear);
1829
1852
 
1830
- customElements.define(componentName$m, LoaderLinearClass);
1853
+ customElements.define(componentName$n, LoaderLinearClass);
1831
1854
 
1832
- const componentName$l = getComponentName('loader-radial');
1855
+ const componentName$m = getComponentName('loader-radial');
1833
1856
 
1834
- class RawLoaderRadial extends createBaseClass({ componentName: componentName$l, baseSelector: ':host > div' }) {
1857
+ class RawLoaderRadial extends createBaseClass({ componentName: componentName$m, baseSelector: ':host > div' }) {
1835
1858
  constructor() {
1836
1859
  super();
1837
1860
 
@@ -1875,11 +1898,11 @@ const LoaderRadialClass = compose(
1875
1898
  componentNameValidationMixin
1876
1899
  )(RawLoaderRadial);
1877
1900
 
1878
- customElements.define(componentName$l, LoaderRadialClass);
1901
+ customElements.define(componentName$m, LoaderRadialClass);
1879
1902
 
1880
- const componentName$k = getComponentName('container');
1903
+ const componentName$l = getComponentName('container');
1881
1904
 
1882
- class RawContainer extends createBaseClass({ componentName: componentName$k, baseSelector: ':host > slot' }) {
1905
+ class RawContainer extends createBaseClass({ componentName: componentName$l, baseSelector: ':host > slot' }) {
1883
1906
  constructor() {
1884
1907
  super();
1885
1908
 
@@ -1931,10 +1954,10 @@ const ContainerClass = compose(
1931
1954
  componentNameValidationMixin
1932
1955
  )(RawContainer);
1933
1956
 
1934
- customElements.define(componentName$k, ContainerClass);
1957
+ customElements.define(componentName$l, ContainerClass);
1935
1958
 
1936
- const componentName$j = getComponentName('divider');
1937
- class RawDivider extends createBaseClass({ componentName: componentName$j, baseSelector: ':host > div' }) {
1959
+ const componentName$k = getComponentName('divider');
1960
+ class RawDivider extends createBaseClass({ componentName: componentName$k, baseSelector: ':host > div' }) {
1938
1961
  constructor() {
1939
1962
  super();
1940
1963
 
@@ -2030,9 +2053,9 @@ const DividerClass = compose(
2030
2053
  componentNameValidationMixin
2031
2054
  )(RawDivider);
2032
2055
 
2033
- const componentName$i = getComponentName('text');
2056
+ const componentName$j = getComponentName('text');
2034
2057
 
2035
- class RawText extends createBaseClass({ componentName: componentName$i, baseSelector: ':host > slot' }) {
2058
+ class RawText extends createBaseClass({ componentName: componentName$j, baseSelector: ':host > slot' }) {
2036
2059
  constructor() {
2037
2060
  super();
2038
2061
 
@@ -2074,9 +2097,9 @@ const TextClass = compose(
2074
2097
  componentNameValidationMixin
2075
2098
  )(RawText);
2076
2099
 
2077
- customElements.define(componentName$i, TextClass);
2100
+ customElements.define(componentName$j, TextClass);
2078
2101
 
2079
- customElements.define(componentName$j, DividerClass);
2102
+ customElements.define(componentName$k, DividerClass);
2080
2103
 
2081
2104
  const { host: host$8, label: label$6, placeholder: placeholder$2, requiredIndicator: requiredIndicator$6, inputField: inputField$4, input, helperText: helperText$5, errorMessage: errorMessage$6 } =
2082
2105
  {
@@ -2132,7 +2155,7 @@ var textFieldMappings = {
2132
2155
  inputPlaceholderColor: { ...placeholder$2, property: 'color' },
2133
2156
  };
2134
2157
 
2135
- const componentName$h = getComponentName('email-field');
2158
+ const componentName$i = getComponentName('email-field');
2136
2159
 
2137
2160
  const EmailFieldClass = compose(
2138
2161
  createStyleMixin({
@@ -2157,15 +2180,15 @@ const EmailFieldClass = compose(
2157
2180
  ${resetInputOverrides('vaadin-email-field', EmailFieldClass.cssVarList)}
2158
2181
  `,
2159
2182
  excludeAttrsSync: ['tabindex'],
2160
- componentName: componentName$h,
2183
+ componentName: componentName$i,
2161
2184
  })
2162
2185
  );
2163
2186
 
2164
- customElements.define(componentName$h, EmailFieldClass);
2187
+ customElements.define(componentName$i, EmailFieldClass);
2165
2188
 
2166
- const componentName$g = getComponentName('link');
2189
+ const componentName$h = getComponentName('link');
2167
2190
 
2168
- class RawLink extends createBaseClass({ componentName: componentName$g, baseSelector: ':host a' }) {
2191
+ class RawLink extends createBaseClass({ componentName: componentName$h, baseSelector: ':host a' }) {
2169
2192
  constructor() {
2170
2193
  super();
2171
2194
 
@@ -2229,7 +2252,7 @@ const LinkClass = compose(
2229
2252
  componentNameValidationMixin
2230
2253
  )(RawLink);
2231
2254
 
2232
- customElements.define(componentName$g, LinkClass);
2255
+ customElements.define(componentName$h, LinkClass);
2233
2256
 
2234
2257
  const createCssVarImageClass = ({ componentName, varName, fallbackVarName }) => {
2235
2258
  let style;
@@ -2281,27 +2304,27 @@ const createCssVarImageClass = ({ componentName, varName, fallbackVarName }) =>
2281
2304
  return CssVarImageClass;
2282
2305
  };
2283
2306
 
2284
- const componentName$f = getComponentName('logo');
2307
+ const componentName$g = getComponentName('logo');
2285
2308
 
2286
2309
  const LogoClass = createCssVarImageClass({
2287
- componentName: componentName$f,
2310
+ componentName: componentName$g,
2288
2311
  varName: 'url',
2289
2312
  fallbackVarName: 'fallbackUrl',
2290
2313
  });
2291
2314
 
2292
- customElements.define(componentName$f, LogoClass);
2315
+ customElements.define(componentName$g, LogoClass);
2293
2316
 
2294
- const componentName$e = getComponentName('totp-image');
2317
+ const componentName$f = getComponentName('totp-image');
2295
2318
 
2296
2319
  const TotpImageClass = createCssVarImageClass({
2297
- componentName: componentName$e,
2320
+ componentName: componentName$f,
2298
2321
  varName: 'url',
2299
2322
  fallbackVarName: 'fallbackUrl',
2300
2323
  });
2301
2324
 
2302
- customElements.define(componentName$e, TotpImageClass);
2325
+ customElements.define(componentName$f, TotpImageClass);
2303
2326
 
2304
- const componentName$d = getComponentName('number-field');
2327
+ const componentName$e = getComponentName('number-field');
2305
2328
 
2306
2329
  const NumberFieldClass = compose(
2307
2330
  createStyleMixin({
@@ -2326,11 +2349,11 @@ const NumberFieldClass = compose(
2326
2349
  ${resetInputOverrides('vaadin-number-field', NumberFieldClass.cssVarList)}
2327
2350
  `,
2328
2351
  excludeAttrsSync: ['tabindex'],
2329
- componentName: componentName$d,
2352
+ componentName: componentName$e,
2330
2353
  })
2331
2354
  );
2332
2355
 
2333
- customElements.define(componentName$d, NumberFieldClass);
2356
+ customElements.define(componentName$e, NumberFieldClass);
2334
2357
 
2335
2358
  const focusElement = (ele) => {
2336
2359
  ele?.focus();
@@ -2348,21 +2371,21 @@ const getSanitizedCharacters = (str) => {
2348
2371
 
2349
2372
  /* eslint-disable no-param-reassign */
2350
2373
 
2351
- const componentName$c = getComponentName('passcode-internal');
2374
+ const componentName$d = getComponentName('passcode-internal');
2352
2375
 
2353
- const observedAttributes$3 = ['digits'];
2376
+ const observedAttributes$4 = ['digits'];
2354
2377
 
2355
2378
  const forwardAttributes = ['disabled', 'bordered', 'size', 'invalid', 'readonly'];
2356
2379
 
2357
- const BaseInputClass$3 = createBaseInputClass({ componentName: componentName$c, baseSelector: 'div' });
2380
+ const BaseInputClass$3 = createBaseInputClass({ componentName: componentName$d, baseSelector: 'div' });
2358
2381
 
2359
2382
  class PasscodeInternal extends BaseInputClass$3 {
2360
2383
  static get observedAttributes() {
2361
- return observedAttributes$3.concat(BaseInputClass$3.observedAttributes || []);
2384
+ return observedAttributes$4.concat(BaseInputClass$3.observedAttributes || []);
2362
2385
  }
2363
2386
 
2364
2387
  static get componentName() {
2365
- return componentName$c;
2388
+ return componentName$d;
2366
2389
  }
2367
2390
 
2368
2391
  constructor() {
@@ -2534,7 +2557,7 @@ class PasscodeInternal extends BaseInputClass$3 {
2534
2557
 
2535
2558
  // sync attributes to inputs
2536
2559
  if (oldValue !== newValue) {
2537
- if (observedAttributes$3.includes(attrName)) {
2560
+ if (observedAttributes$4.includes(attrName)) {
2538
2561
  if (attrName === 'digits') {
2539
2562
  this.renderInputs();
2540
2563
  }
@@ -2547,7 +2570,7 @@ class PasscodeInternal extends BaseInputClass$3 {
2547
2570
  }
2548
2571
  }
2549
2572
 
2550
- const componentName$b = getComponentName('text-field');
2573
+ const componentName$c = getComponentName('text-field');
2551
2574
 
2552
2575
  const observedAttrs = ['type'];
2553
2576
 
@@ -2595,18 +2618,18 @@ const TextFieldClass = compose(
2595
2618
  ${resetInputOverrides('vaadin-text-field', TextFieldClass.cssVarList)}
2596
2619
  `,
2597
2620
  excludeAttrsSync: ['tabindex'],
2598
- componentName: componentName$b,
2621
+ componentName: componentName$c,
2599
2622
  })
2600
2623
  );
2601
2624
 
2602
- const componentName$a = getComponentName('passcode');
2625
+ const componentName$b = getComponentName('passcode');
2603
2626
 
2604
- const observedAttributes$2 = ['digits'];
2627
+ const observedAttributes$3 = ['digits'];
2605
2628
 
2606
2629
  const customMixin$2 = (superclass) =>
2607
2630
  class PasscodeMixinClass extends superclass {
2608
2631
  static get observedAttributes() {
2609
- return observedAttributes$2.concat(superclass.observedAttributes || []);
2632
+ return observedAttributes$3.concat(superclass.observedAttributes || []);
2610
2633
  }
2611
2634
 
2612
2635
  get digits() {
@@ -2618,17 +2641,17 @@ const customMixin$2 = (superclass) =>
2618
2641
  const template = document.createElement('template');
2619
2642
 
2620
2643
  template.innerHTML = `
2621
- <${componentName$c}
2644
+ <${componentName$d}
2622
2645
  bordered="true"
2623
2646
  name="code"
2624
2647
  tabindex="-1"
2625
2648
  slot="input"
2626
- ></${componentName$c}>
2649
+ ></${componentName$d}>
2627
2650
  `;
2628
2651
 
2629
2652
  this.baseElement.appendChild(template.content.cloneNode(true));
2630
2653
 
2631
- this.inputElement = this.shadowRoot.querySelector(componentName$c);
2654
+ this.inputElement = this.shadowRoot.querySelector(componentName$d);
2632
2655
 
2633
2656
  forwardAttrs(this, this.inputElement, { includeAttrs: ['digits', 'size'] });
2634
2657
  }
@@ -2766,15 +2789,15 @@ const PasscodeClass = compose(
2766
2789
  ${resetInputCursor('vaadin-text-field')}
2767
2790
  `,
2768
2791
  excludeAttrsSync: ['tabindex'],
2769
- componentName: componentName$a,
2792
+ componentName: componentName$b,
2770
2793
  })
2771
2794
  );
2772
2795
 
2773
- customElements.define(componentName$b, TextFieldClass);
2796
+ customElements.define(componentName$c, TextFieldClass);
2774
2797
 
2775
- customElements.define(componentName$c, PasscodeInternal);
2798
+ customElements.define(componentName$d, PasscodeInternal);
2776
2799
 
2777
- customElements.define(componentName$a, PasscodeClass);
2800
+ customElements.define(componentName$b, PasscodeClass);
2778
2801
 
2779
2802
  const passwordDraggableMixin = (superclass) =>
2780
2803
  class PasswordDraggableMixinClass extends superclass {
@@ -2810,7 +2833,7 @@ const passwordDraggableMixin = (superclass) =>
2810
2833
  }
2811
2834
  };
2812
2835
 
2813
- const componentName$9 = getComponentName('password');
2836
+ const componentName$a = getComponentName('password');
2814
2837
 
2815
2838
  const {
2816
2839
  host: host$5,
@@ -2938,13 +2961,13 @@ const PasswordClass = compose(
2938
2961
  }
2939
2962
  `,
2940
2963
  excludeAttrsSync: ['tabindex'],
2941
- componentName: componentName$9,
2964
+ componentName: componentName$a,
2942
2965
  })
2943
2966
  );
2944
2967
 
2945
- customElements.define(componentName$9, PasswordClass);
2968
+ customElements.define(componentName$a, PasswordClass);
2946
2969
 
2947
- const componentName$8 = getComponentName('text-area');
2970
+ const componentName$9 = getComponentName('text-area');
2948
2971
 
2949
2972
  const {
2950
2973
  host: host$4,
@@ -3016,20 +3039,20 @@ const TextAreaClass = compose(
3016
3039
  ${resetInputCursor('vaadin-text-area')}
3017
3040
  `,
3018
3041
  excludeAttrsSync: ['tabindex'],
3019
- componentName: componentName$8,
3042
+ componentName: componentName$9,
3020
3043
  })
3021
3044
  );
3022
3045
 
3023
- customElements.define(componentName$8, TextAreaClass);
3046
+ customElements.define(componentName$9, TextAreaClass);
3024
3047
 
3025
- const observedAttributes$1 = ['src', 'alt'];
3048
+ const observedAttributes$2 = ['src', 'alt'];
3026
3049
 
3027
- const componentName$7 = getComponentName('image');
3050
+ const componentName$8 = getComponentName('image');
3028
3051
 
3029
- const BaseClass = createBaseClass({ componentName: componentName$7, baseSelector: ':host > img' });
3030
- class RawImage extends BaseClass {
3052
+ const BaseClass$1 = createBaseClass({ componentName: componentName$8, baseSelector: ':host > img' });
3053
+ class RawImage extends BaseClass$1 {
3031
3054
  static get observedAttributes() {
3032
- return observedAttributes$1.concat(BaseClass.observedAttributes || []);
3055
+ return observedAttributes$2.concat(BaseClass$1.observedAttributes || []);
3033
3056
  }
3034
3057
 
3035
3058
  constructor() {
@@ -3052,7 +3075,7 @@ class RawImage extends BaseClass {
3052
3075
  connectedCallback() {
3053
3076
  super.connectedCallback?.();
3054
3077
 
3055
- forwardAttrs(this, this.baseElement, { includeAttrs: observedAttributes$1 });
3078
+ forwardAttrs(this, this.baseElement, { includeAttrs: observedAttributes$2 });
3056
3079
  }
3057
3080
  }
3058
3081
 
@@ -3066,9 +3089,9 @@ const ImageClass = compose(
3066
3089
  draggableMixin
3067
3090
  )(RawImage);
3068
3091
 
3069
- customElements.define(componentName$7, ImageClass);
3092
+ customElements.define(componentName$8, ImageClass);
3070
3093
 
3071
- const componentName$6 = getComponentName('combo-box');
3094
+ const componentName$7 = getComponentName('combo-box');
3072
3095
 
3073
3096
  const ComboBoxMixin = (superclass) =>
3074
3097
  class ComboBoxMixinClass extends superclass {
@@ -3249,12 +3272,12 @@ const ComboBoxClass = compose(
3249
3272
  // and reset items to an empty array, and opening the list box with no items
3250
3273
  // to display.
3251
3274
  excludeAttrsSync: ['tabindex', 'size'],
3252
- componentName: componentName$6,
3275
+ componentName: componentName$7,
3253
3276
  includeForwardProps: ['items', 'renderer', 'selectedItem'],
3254
3277
  })
3255
3278
  );
3256
3279
 
3257
- customElements.define(componentName$6, ComboBoxClass);
3280
+ customElements.define(componentName$7, ComboBoxClass);
3258
3281
 
3259
3282
  var CountryCodes = [
3260
3283
  {
@@ -4494,7 +4517,7 @@ const comboBoxItem = ({ code, dialCode, name: country }) => `
4494
4517
  </div>
4495
4518
  `;
4496
4519
 
4497
- const componentName$5 = getComponentName('phone-field-internal');
4520
+ const componentName$6 = getComponentName('phone-field-internal');
4498
4521
 
4499
4522
  const commonAttrs$1 = ['disabled', 'size', 'bordered', 'invalid', 'readonly'];
4500
4523
  const countryAttrs = ['country-input-placeholder', 'default-code'];
@@ -4506,7 +4529,7 @@ const mapAttrs = {
4506
4529
 
4507
4530
  const inputRelatedAttrs$1 = [].concat(commonAttrs$1, countryAttrs, phoneAttrs);
4508
4531
 
4509
- const BaseInputClass$2 = createBaseInputClass({ componentName: componentName$5, baseSelector: 'div' });
4532
+ const BaseInputClass$2 = createBaseInputClass({ componentName: componentName$6, baseSelector: 'div' });
4510
4533
 
4511
4534
  class PhoneFieldInternal extends BaseInputClass$2 {
4512
4535
  static get observedAttributes() {
@@ -4566,7 +4589,7 @@ class PhoneFieldInternal extends BaseInputClass$2 {
4566
4589
  const hasPhone = this.phoneNumberInput.value;
4567
4590
  const emptyValue = !hasCode || !hasPhone;
4568
4591
  const hasMinPhoneLength =
4569
- this.phoneNumberInput.value.length && this.phoneNumberInput.value.length < this.minLength;
4592
+ this.phoneNumberInput.value?.length && this.phoneNumberInput.value.length < this.minLength;
4570
4593
 
4571
4594
  if (this.isRequired && emptyValue) {
4572
4595
  return { valueMissing: true };
@@ -4679,12 +4702,12 @@ class PhoneFieldInternal extends BaseInputClass$2 {
4679
4702
  }
4680
4703
  }
4681
4704
 
4682
- customElements.define(componentName$5, PhoneFieldInternal);
4705
+ customElements.define(componentName$6, PhoneFieldInternal);
4683
4706
 
4684
4707
  const textVars = TextFieldClass.cssVarList;
4685
4708
  const comboVars = ComboBoxClass.cssVarList;
4686
4709
 
4687
- const componentName$4 = getComponentName('phone-field');
4710
+ const componentName$5 = getComponentName('phone-field');
4688
4711
 
4689
4712
  const customMixin$1 = (superclass) =>
4690
4713
  class PhoneFieldMixinClass extends superclass {
@@ -4698,15 +4721,15 @@ const customMixin$1 = (superclass) =>
4698
4721
  const template = document.createElement('template');
4699
4722
 
4700
4723
  template.innerHTML = `
4701
- <${componentName$5}
4724
+ <${componentName$6}
4702
4725
  tabindex="-1"
4703
4726
  slot="input"
4704
- ></${componentName$5}>
4727
+ ></${componentName$6}>
4705
4728
  `;
4706
4729
 
4707
4730
  this.baseElement.appendChild(template.content.cloneNode(true));
4708
4731
 
4709
- this.inputElement = this.shadowRoot.querySelector(componentName$5);
4732
+ this.inputElement = this.shadowRoot.querySelector(componentName$6);
4710
4733
 
4711
4734
  forwardAttrs(this.shadowRoot.host, this.inputElement, {
4712
4735
  includeAttrs: [
@@ -4899,15 +4922,15 @@ const PhoneFieldClass = compose(
4899
4922
  }
4900
4923
  `,
4901
4924
  excludeAttrsSync: ['tabindex'],
4902
- componentName: componentName$4,
4925
+ componentName: componentName$5,
4903
4926
  })
4904
4927
  );
4905
4928
 
4906
- customElements.define(componentName$4, PhoneFieldClass);
4929
+ customElements.define(componentName$5, PhoneFieldClass);
4907
4930
 
4908
- const componentName$3 = getComponentName('new-password-internal');
4931
+ const componentName$4 = getComponentName('new-password-internal');
4909
4932
 
4910
- const componentName$2 = getComponentName('new-password');
4933
+ const componentName$3 = getComponentName('new-password');
4911
4934
 
4912
4935
  const customMixin = (superclass) =>
4913
4936
  class NewPasswordMixinClass extends superclass {
@@ -4917,16 +4940,16 @@ const customMixin = (superclass) =>
4917
4940
  const template = document.createElement('template');
4918
4941
 
4919
4942
  template.innerHTML = `
4920
- <${componentName$3}
4943
+ <${componentName$4}
4921
4944
  name="new-password"
4922
4945
  tabindex="-1"
4923
4946
  slot="input"
4924
- ></${componentName$3}>
4947
+ ></${componentName$4}>
4925
4948
  `;
4926
4949
 
4927
4950
  this.baseElement.appendChild(template.content.cloneNode(true));
4928
4951
 
4929
- this.inputElement = this.shadowRoot.querySelector(componentName$3);
4952
+ this.inputElement = this.shadowRoot.querySelector(componentName$4);
4930
4953
 
4931
4954
  forwardAttrs(this, this.inputElement, {
4932
4955
  includeAttrs: [
@@ -5025,7 +5048,7 @@ const NewPasswordClass = compose(
5025
5048
  },
5026
5049
  `,
5027
5050
  excludeAttrsSync: ['tabindex'],
5028
- componentName: componentName$2,
5051
+ componentName: componentName$3,
5029
5052
  })
5030
5053
  );
5031
5054
 
@@ -5049,7 +5072,7 @@ const commonAttrs = [
5049
5072
 
5050
5073
  const inputRelatedAttrs = [].concat(commonAttrs, passwordInputAttrs, confirmInputAttrs);
5051
5074
 
5052
- const BaseInputClass$1 = createBaseInputClass({ componentName: componentName$3, baseSelector: 'div' });
5075
+ const BaseInputClass$1 = createBaseInputClass({ componentName: componentName$4, baseSelector: 'div' });
5053
5076
 
5054
5077
  class NewPasswordInternal extends BaseInputClass$1 {
5055
5078
  static get observedAttributes() {
@@ -5209,9 +5232,168 @@ class NewPasswordInternal extends BaseInputClass$1 {
5209
5232
  }
5210
5233
  }
5211
5234
 
5212
- customElements.define(componentName$3, NewPasswordInternal);
5235
+ customElements.define(componentName$4, NewPasswordInternal);
5236
+
5237
+ customElements.define(componentName$3, NewPasswordClass);
5238
+
5239
+ const componentName$2 = getComponentName('recaptcha');
5240
+
5241
+ const observedAttributes$1 = ['disabled', 'site-key', 'action', 'enterprise'];
5213
5242
 
5214
- customElements.define(componentName$2, NewPasswordClass);
5243
+ const BaseClass = createBaseClass({
5244
+ componentName: componentName$2,
5245
+ baseSelector: ':host > div',
5246
+ });
5247
+ class RawRecaptcha extends BaseClass {
5248
+ static get observedAttributes() {
5249
+ return observedAttributes$1.concat(BaseClass.observedAttributes || []);
5250
+ }
5251
+
5252
+ attributeChangedCallback(attrName, oldValue, newValue) {
5253
+ super.attributeChangedCallback?.(attrName, oldValue, newValue);
5254
+ if (attrName === 'disabled') {
5255
+ this.#toggleRecaptcha(newValue === 'true');
5256
+ }
5257
+ }
5258
+
5259
+ renderRecaptcha(disabled) {
5260
+ if (disabled) {
5261
+ this.recaptchaEle.style.display = 'none';
5262
+ this.mockRecaptchaEle.style.display = '';
5263
+ } else {
5264
+ this.recaptchaEle.style.display = '';
5265
+ this.mockRecaptchaEle.style.display = 'none';
5266
+ }
5267
+ }
5268
+
5269
+ constructor() {
5270
+ super();
5271
+
5272
+ this.attachShadow({ mode: 'open' }).innerHTML = `
5273
+ <style>
5274
+ :host #recaptcha {
5275
+ width: 100%;
5276
+ height: 100%
5277
+ }
5278
+ :host img {
5279
+ width: 256px;
5280
+ }
5281
+ :host {
5282
+ display: inline-flex;
5283
+ }
5284
+ </style>
5285
+ <div>
5286
+ <span id="recaptcha"></span>
5287
+ <img src="https://imgs.descope.com/connectors/templates/recaptcha/recaptcha-big.png" alt="recaptcha"/>
5288
+ </div>
5289
+ `;
5290
+
5291
+ this.recaptchaEle = this.baseElement.querySelector('#recaptcha');
5292
+ this.mockRecaptchaEle = this.baseElement.querySelector('img');
5293
+ }
5294
+
5295
+ get enterprise() {
5296
+ return this.getAttribute('enterprise') === 'true';
5297
+ }
5298
+
5299
+ get siteKey() {
5300
+ return this.getAttribute('site-key');
5301
+ }
5302
+
5303
+ get action() {
5304
+ return this.getAttribute('action') || 'load';
5305
+ }
5306
+
5307
+ get disabled() {
5308
+ return this.getAttribute('disabled') === 'true';
5309
+ }
5310
+
5311
+ get scriptURL() {
5312
+ const url = new URL('https://www.google.com/recaptcha/');
5313
+ url.pathname += `${this.enterprise ? 'enterprise' : 'api'}.js`;
5314
+ url.searchParams.append('onload', 'onRecaptchaLoadCallback');
5315
+ url.searchParams.append('render', 'explicit');
5316
+ return url.toString();
5317
+ }
5318
+
5319
+ #toggleRecaptcha(disabled) {
5320
+ this.renderRecaptcha(disabled);
5321
+ if (!disabled) {
5322
+ this.#loadRecaptchaScript();
5323
+ this.#createOnLoadScript();
5324
+ }
5325
+ }
5326
+
5327
+ #loadRecaptchaScript() {
5328
+ if (!document.getElementById('recaptcha-script')) {
5329
+ const script = document.createElement('script');
5330
+ script.src = this.scriptURL;
5331
+ script.async = true;
5332
+ script.id = 'recaptcha-script';
5333
+ script.defer = true;
5334
+ document.body.appendChild(script);
5335
+ } else {
5336
+ window.onRecaptchaLoadCallback();
5337
+ }
5338
+ }
5339
+
5340
+ #createOnLoadScript() {
5341
+ if (window.onRecaptchaLoadCallback) {
5342
+ return;
5343
+ }
5344
+
5345
+ window.onRecaptchaLoadCallback = () => {
5346
+ const currentNode = this.recaptchaEle;
5347
+ // if there are child nodes, it means that the recaptcha was already rendered
5348
+ if (currentNode.hasChildNodes()) {
5349
+ return;
5350
+ }
5351
+ const grecaptchaInstance = this.enterprise
5352
+ ? window.grecaptcha?.enterprise
5353
+ : window.grecaptcha;
5354
+
5355
+ if (!grecaptchaInstance) {
5356
+ return;
5357
+ }
5358
+
5359
+ setTimeout(() => {
5360
+ const view = grecaptchaInstance.render(currentNode, {
5361
+ sitekey: this.siteKey,
5362
+ badge: 'inline',
5363
+ size: 'invisible',
5364
+ });
5365
+ grecaptchaInstance.ready(() => {
5366
+ // clone the node and append it to the body so that it can be used by the grepcaptcha script
5367
+ const cloneNode = currentNode.querySelector('#g-recaptcha-response')?.cloneNode();
5368
+ if (cloneNode) {
5369
+ cloneNode.style.display = 'none';
5370
+ document.body.appendChild(cloneNode);
5371
+ }
5372
+ if (this.siteKey) {
5373
+ grecaptchaInstance?.execute(view, { action: this.action }).then((token) => {
5374
+ this.updateComponentsContext({
5375
+ risktoken: token,
5376
+ riskaction: this.action,
5377
+ });
5378
+ });
5379
+ }
5380
+ });
5381
+ }, 0);
5382
+ };
5383
+ }
5384
+
5385
+ connectedCallback() {
5386
+ super.connectedCallback?.();
5387
+
5388
+ this.#toggleRecaptcha(this.disabled);
5389
+ }
5390
+ }
5391
+
5392
+ const RecaptchaClass = compose(
5393
+ draggableMixin
5394
+ )(RawRecaptcha);
5395
+
5396
+ customElements.define(componentName$2, RecaptchaClass);
5215
5397
 
5216
5398
  const getFileBase64 = (fileObj) => {
5217
5399
  return new Promise((resolve) => {
@@ -5763,7 +5945,7 @@ const mode = {
5763
5945
  surface: globalRefs$b.colors.surface,
5764
5946
  };
5765
5947
 
5766
- const [helperTheme$3, helperRefs$3, helperVars$2] = createHelperVars({ mode }, componentName$q);
5948
+ const [helperTheme$3, helperRefs$3, helperVars$2] = createHelperVars({ mode }, componentName$r);
5767
5949
 
5768
5950
  const verticalPaddingRatio = 3;
5769
5951
  const horizontalPaddingRatio = 2;
@@ -6233,7 +6415,7 @@ const [helperTheme$2, helperRefs$2, helperVars$1] = createHelperVars(
6233
6415
  horizontalAlignment,
6234
6416
  shadowColor: '#00000020', // if we want to support transparency vars, we should use different color format
6235
6417
  },
6236
- componentName$k
6418
+ componentName$l
6237
6419
  );
6238
6420
 
6239
6421
  const { shadowColor } = helperRefs$2;
@@ -6489,7 +6671,7 @@ const [helperTheme$1, helperRefs$1, helperVars] = createHelperVars(
6489
6671
  thickness: '2px',
6490
6672
  spacing: '10px',
6491
6673
  },
6492
- componentName$j
6674
+ componentName$k
6493
6675
  );
6494
6676
 
6495
6677
  const divider = {
@@ -6618,7 +6800,7 @@ const [helperTheme, helperRefs] = createHelperVars(
6618
6800
  },
6619
6801
  },
6620
6802
  },
6621
- componentName$l
6803
+ componentName$m
6622
6804
  );
6623
6805
 
6624
6806
  const loaderRadial = {
@@ -6867,5 +7049,5 @@ const vars = Object.keys(components).reduce(
6867
7049
  const defaultTheme = { globals, components: theme };
6868
7050
  const themeVars = { globals: vars$o, components: vars };
6869
7051
 
6870
- export { ButtonClass, CheckboxClass, ContainerClass, DividerClass, EmailFieldClass, ImageClass, LinkClass, LoaderLinearClass, LoaderRadialClass, LogoClass, NewPasswordClass, NumberFieldClass, PasscodeClass, PasswordClass, PhoneFieldClass, SwitchToggleClass, TextAreaClass, TextClass, TextFieldClass, TotpImageClass, UploadFileClass, componentsThemeManager, createComponentsTheme, defaultTheme, genColor, globalsThemeToStyle, themeToStyle, themeVars };
7052
+ export { ButtonClass, CheckboxClass, ContainerClass, DividerClass, EmailFieldClass, ImageClass, LinkClass, LoaderLinearClass, LoaderRadialClass, LogoClass, NewPasswordClass, NumberFieldClass, PasscodeClass, PasswordClass, PhoneFieldClass, RecaptchaClass, SwitchToggleClass, TextAreaClass, TextClass, TextFieldClass, TotpImageClass, UploadFileClass, componentsThemeManager, createComponentsTheme, defaultTheme, genColor, globalsThemeToStyle, themeToStyle, themeVars };
6871
7053
  //# sourceMappingURL=index.esm.js.map