@descope/web-components-ui 1.0.59 → 1.0.61

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. package/dist/index.esm.js +39 -10
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/umd/832.js +1 -1
  4. package/dist/umd/942.js +1 -1
  5. package/dist/umd/descope-combo-index-js.js +1 -1
  6. package/dist/umd/descope-container-index-js.js +1 -1
  7. package/dist/umd/descope-divider-index-js.js +1 -1
  8. package/dist/umd/descope-link-index-js.js +1 -1
  9. package/dist/umd/descope-loader-linear-index-js.js +1 -1
  10. package/dist/umd/descope-loader-radial-index-js.js +1 -1
  11. package/dist/umd/descope-logo-index-js.js +1 -1
  12. package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js +1 -1
  13. package/dist/umd/descope-passcode-index-js.js +1 -1
  14. package/dist/umd/descope-text-index-js.js +1 -1
  15. package/package.json +1 -1
  16. package/src/components/descope-combo/index.js +1 -1
  17. package/src/components/descope-container/Container.js +1 -1
  18. package/src/components/descope-divider/Divider.js +1 -1
  19. package/src/components/descope-link/Link.js +1 -1
  20. package/src/components/descope-loader-linear/LoaderLinear.js +1 -1
  21. package/src/components/descope-loader-radial/LoaderRadial.js +1 -1
  22. package/src/components/descope-logo/Logo.js +1 -1
  23. package/src/components/descope-passcode/Passcode.js +4 -4
  24. package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +12 -4
  25. package/src/components/descope-text/Text.js +1 -1
  26. package/src/componentsHelpers/createProxy/helpers.js +15 -0
  27. package/src/componentsHelpers/createProxy/index.js +11 -4
  28. /package/src/{components → baseClasses}/DescopeBaseClass.js +0 -0
package/dist/index.esm.js CHANGED
@@ -342,12 +342,29 @@ const forwardAttrs = (source, dest, options = {}) => {
342
342
  );
343
343
  };
344
344
 
345
+ const forwardProps = (src, target, props = []) => {
346
+ if(!props.length) return;
347
+
348
+ const config = props.reduce((acc, prop) => Object.assign(acc, {[prop] : {
349
+ get () {
350
+ return target[prop]
351
+ },
352
+ set (v) {
353
+ target[prop] = v;
354
+ }
355
+ }}), {});
356
+
357
+ Object.defineProperties(src, config);
358
+ };
359
+
345
360
  const createProxy = ({
346
361
  componentName,
347
362
  wrappedEleName,
348
363
  slots = [],
349
364
  style,
350
- excludeAttrsSync = []
365
+ excludeAttrsSync = [],
366
+ includeAttrsSync = [],
367
+ includeForwardProps = []
351
368
  }) => {
352
369
  const template = `
353
370
  <style id="create-proxy"></style>
@@ -373,6 +390,10 @@ const createProxy = ({
373
390
  connectedCallback() {
374
391
  if (this.shadowRoot.isConnected) {
375
392
  this.proxyElement = this.shadowRoot.querySelector(wrappedEleName);
393
+
394
+ // this is needed for components that uses props, such as combo box
395
+ forwardProps(this.hostElement, this.proxyElement, includeForwardProps);
396
+
376
397
  this.setAttribute('tabindex', '0');
377
398
 
378
399
  // we want to focus on the proxy element when focusing our WC
@@ -397,7 +418,8 @@ const createProxy = ({
397
418
  this.proxyElement.addEventListener(...args);
398
419
 
399
420
  syncAttrs(this.proxyElement, this.hostElement, {
400
- excludeAttrs: excludeAttrsSync
421
+ excludeAttrs: excludeAttrsSync,
422
+ includeAttrs: includeAttrsSync
401
423
  });
402
424
  }
403
425
  }
@@ -1475,7 +1497,9 @@ class PasscodeInternal extends HTMLElement {
1475
1497
  return [
1476
1498
  'disabled',
1477
1499
  'bordered',
1478
- 'size'
1500
+ 'size',
1501
+ 'required',
1502
+ 'pattern'
1479
1503
  ];
1480
1504
  }
1481
1505
 
@@ -1669,9 +1693,15 @@ class PasscodeInternal extends HTMLElement {
1669
1693
  oldValue,
1670
1694
  newValue
1671
1695
  ) {
1672
- if (oldValue !== newValue &&
1673
- PasscodeInternal.observedAttributes.includes(attrName)) {
1674
- this.inputs.forEach((input) => input.setAttribute(attrName, newValue));
1696
+ const validationRelatedAttributes = ['required', 'pattern'];
1697
+
1698
+ if (oldValue !== newValue) {
1699
+ if (validationRelatedAttributes.includes(attrName)) {
1700
+ this.setValidity();
1701
+ }
1702
+ else if (PasscodeInternal.observedAttributes.includes(attrName)) {
1703
+ this.inputs.forEach((input) => input.setAttribute(attrName, newValue));
1704
+ }
1675
1705
  }
1676
1706
  }
1677
1707
  }
@@ -1692,15 +1722,12 @@ const customMixin = (superclass) =>
1692
1722
  super.connectedCallback?.();
1693
1723
  const template = document.createElement('template');
1694
1724
 
1695
- //forward required & pattern TODO use forwardAttrs
1696
1725
  template.innerHTML = `
1697
1726
  <${componentName$4}
1698
1727
  bordered="true"
1699
1728
  name="code"
1700
1729
  tabindex="0"
1701
1730
  slot="input"
1702
- required="${this.shadowRoot.host.getAttribute('required')}"
1703
- pattern="${this.shadowRoot.host.getAttribute('pattern')}"
1704
1731
  ></${componentName$4}>
1705
1732
  `;
1706
1733
 
@@ -1714,11 +1741,13 @@ const customMixin = (superclass) =>
1714
1741
 
1715
1742
  // we want to control when the element is out of focus
1716
1743
  // so the validations will be triggered blur event is dispatched from descope-passcode internal (and not every time focusing a digit)
1717
- this.proxyElement._setFocused = () => {};
1744
+ this.proxyElement._setFocused = () => { };
1718
1745
 
1719
1746
  this.shadowRoot.host.appendChild(template.content.cloneNode(true));
1720
1747
  this.inputElement = this.querySelector(componentName$4);
1721
1748
 
1749
+ forwardAttrs(this.shadowRoot.host, this.inputElement, { includeAttrs: ['required', 'pattern'] });
1750
+
1722
1751
  // we want to trigger validation only when dispatching a blur event from the descope-passcode-internal
1723
1752
  this.inputElement.addEventListener('blur', () => {
1724
1753
  this.proxyElement.validate();