@descope/web-components-ui 1.0.358 → 1.0.360

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/cjs/index.cjs.js +55 -103
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +108 -119
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/umd/4392.js +1 -1
  6. package/dist/umd/4525.js +37 -0
  7. package/dist/umd/DescopeDev.js +1 -1
  8. package/dist/umd/descope-email-field-index-js.js +1 -1
  9. package/dist/umd/descope-enriched-text-index-js.js +1 -1
  10. package/dist/umd/descope-new-password-index-js.js +1 -1
  11. package/dist/umd/descope-number-field-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 -37
  14. package/dist/umd/descope-radio-group-index-js.js +1 -1
  15. package/dist/umd/descope-text-field-index-js.js +1 -1
  16. package/dist/umd/index.js +1 -1
  17. package/dist/umd/mapping-fields-descope-mappings-field-index-js.js +1 -1
  18. package/package.json +3 -1
  19. package/src/components/descope-enriched-text/EnrichedTextClass.js +1 -0
  20. package/src/components/descope-passcode/PasscodeClass.js +6 -1
  21. package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +23 -12
  22. package/src/components/descope-passcode/descope-passcode-internal/helpers.js +33 -5
  23. package/src/components/descope-text-field/textFieldMappings.js +6 -1
  24. package/src/helpers/themeHelpers/index.js +1 -1
  25. package/src/theme/components/enrichedText.js +14 -75
  26. package/src/theme/components/index.js +2 -2
  27. package/src/theme/components/text.js +1 -0
  28. /package/dist/umd/{descope-passcode-index-js.js.LICENSE.txt → 4525.js.LICENSE.txt} +0 -0
package/dist/index.esm.js CHANGED
@@ -4,6 +4,7 @@ import '@vaadin/checkbox';
4
4
  import '@vaadin/text-field';
5
5
  import '@vaadin/email-field';
6
6
  import '@vaadin/number-field';
7
+ import debounce from 'lodash.debounce';
7
8
  import '@vaadin/icons';
8
9
  import '@vaadin/icon';
9
10
  import '@vaadin/password-field';
@@ -2518,6 +2519,7 @@ const {
2518
2519
  requiredIndicator: requiredIndicator$9,
2519
2520
  inputField: inputField$6,
2520
2521
  input,
2522
+ inputMask,
2521
2523
  helperText: helperText$8,
2522
2524
  errorMessage: errorMessage$a,
2523
2525
  disabledPlaceholder,
@@ -2534,6 +2536,7 @@ const {
2534
2536
  disabledPlaceholder: { selector: '> input:disabled::placeholder' },
2535
2537
  inputField: { selector: '::part(input-field)' },
2536
2538
  input: { selector: 'input' },
2539
+ inputMask: { selector: '::part(input-field)::before' },
2537
2540
  inputDisabled: { selector: 'input:disabled' },
2538
2541
  helperText: { selector: '::part(helper-text)' },
2539
2542
  errorMessage: { selector: '::part(error-message)' },
@@ -2559,7 +2562,10 @@ var textFieldMappings = {
2559
2562
  hostMinWidth: { ...host$i, property: 'min-width' },
2560
2563
  hostDirection: { ...host$i, property: 'direction' },
2561
2564
 
2562
- inputBackgroundColor: { ...inputField$6, property: 'background-color' },
2565
+ inputBackgroundColor: [
2566
+ { ...inputField$6, property: 'background-color' },
2567
+ { ...inputMask, property: 'background-color' },
2568
+ ],
2563
2569
 
2564
2570
  errorMessageTextColor: { ...errorMessage$a, property: 'color' },
2565
2571
  helperTextColor: { ...helperText$8, property: '-webkit-text-fill-color' },
@@ -2870,18 +2876,46 @@ const NumberFieldClass = compose(
2870
2876
 
2871
2877
  customElements.define(componentName$I, NumberFieldClass);
2872
2878
 
2879
+ const INPUT_MASK_TEXT_PROP = '--descope-input-mask-content';
2880
+ const INPUT_MASK_DISPLAY_PROP = '--descope-input-mask-display';
2881
+ const INPUT_MASK_FALLBACK_PROP = '--descope-input-mask-fallback';
2882
+
2873
2883
  const focusElement = (ele) => {
2874
2884
  ele?.focus();
2875
2885
  ele?.setSelectionRange?.(1, 1);
2876
2886
  };
2877
2887
 
2878
- const getSanitizedCharacters = (str) => {
2879
- const pin = str.replace(/\s/g, ''); // sanitize string
2888
+ const sanitizeStr = (str) => {
2889
+ return str.replace(/\D/g, '') || '';
2890
+ };
2880
2891
 
2881
- // accept only numbers
2882
- if (!pin.match(/^\d+$/)) return [];
2892
+ // During debounced input we hide the value with a mask.
2893
+ // This allows us to hide the multiple population of the first input
2894
+ // in case of an automated input (e.g. Safari OTP Autofill or paste).
2895
+ const createInputMaskStyle = () => {
2896
+ const ele = document.createElement('style');
2897
+ ele.id = 'input-mask';
2898
+ ele.innerHTML = `vaadin-text-field::part(input-field)::before {
2899
+ ${INPUT_MASK_FALLBACK_PROP}: '';
2900
+ content: var(${INPUT_MASK_TEXT_PROP}, var(${INPUT_MASK_FALLBACK_PROP}));
2901
+ position: absolute;
2902
+ width: 100%;
2903
+ height: 100%;
2904
+ display: var(${INPUT_MASK_DISPLAY_PROP}, none);
2905
+ align-items: center;
2906
+ justify-content: center;
2907
+ }`;
2908
+ return ele;
2909
+ };
2883
2910
 
2884
- return [...pin]; // creating array of chars
2911
+ const toggleMaskVisibility = (input, value) => {
2912
+ if (value) {
2913
+ input.style.setProperty(INPUT_MASK_TEXT_PROP, `"${value}"`);
2914
+ input.style.setProperty(INPUT_MASK_DISPLAY_PROP, 'flex');
2915
+ } else {
2916
+ input.style.removeProperty(INPUT_MASK_TEXT_PROP);
2917
+ input.style.removeProperty(INPUT_MASK_DISPLAY_PROP);
2918
+ }
2885
2919
  };
2886
2920
 
2887
2921
  /* eslint-disable no-param-reassign */
@@ -2972,11 +3006,7 @@ class PasscodeInternal extends BaseInputClass$7 {
2972
3006
  set value(val) {
2973
3007
  if (val === this.value) return;
2974
3008
 
2975
- const charArr = getSanitizedCharacters(val);
2976
-
2977
- if (charArr.length) {
2978
- this.fillDigits(charArr, this.inputs[0]);
2979
- }
3009
+ this.parseInputValue(this.inputs[0], sanitizeStr(val));
2980
3010
  }
2981
3011
 
2982
3012
  getValidity() {
@@ -3032,8 +3062,8 @@ class PasscodeInternal extends BaseInputClass$7 {
3032
3062
  focusElement(currentInput);
3033
3063
  }
3034
3064
 
3035
- parseInputValue(input) {
3036
- const charArr = getSanitizedCharacters(input.value);
3065
+ parseInputValue(input, value = '') {
3066
+ const charArr = value.split('');
3037
3067
 
3038
3068
  if (!charArr.length) {
3039
3069
  // if we got an invalid value we want to clear the input
@@ -3045,15 +3075,30 @@ class PasscodeInternal extends BaseInputClass$7 {
3045
3075
  let currentInput;
3046
3076
 
3047
3077
  this.inputs.forEach((input) => {
3078
+ input.shadowRoot.appendChild(createInputMaskStyle());
3079
+
3048
3080
  input.addEventListener('change', (e) => {
3049
3081
  if (currentInput !== e.target) {
3050
- this.parseInputValue(input);
3082
+ this.parseInputValue(input, input.value);
3051
3083
  this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
3052
3084
  }
3053
3085
  });
3054
3086
 
3087
+ const handleParseInput = (val) => {
3088
+ this.parseInputValue(input, val);
3089
+ toggleMaskVisibility(input);
3090
+ };
3091
+
3092
+ const debouncedHandleParseInput = debounce(handleParseInput, 20, { trailing: true });
3093
+
3055
3094
  // sanitize the input
3056
3095
  input.addEventListener('input', (e) => {
3096
+ input.value = sanitizeStr(input.value);
3097
+
3098
+ if (input.value) {
3099
+ toggleMaskVisibility(input, input.value[0]);
3100
+ }
3101
+
3057
3102
  // when using iPhone's code autofill we get only `change` events.
3058
3103
  // In other scenarios we get `input` AND `change` events.
3059
3104
  // In order to be parse the digits properly in iPhone, we need to listen to `change` event
@@ -3064,12 +3109,11 @@ class PasscodeInternal extends BaseInputClass$7 {
3064
3109
  currentInput = e.target;
3065
3110
  setTimeout(() => {
3066
3111
  currentInput = null;
3067
- if (e.inputType === 'deleteContentBackward') {
3112
+ if (e?.inputType === 'deleteContentBackward') {
3068
3113
  focusElement(this.getPrevInput(input));
3069
3114
  }
3070
3115
  });
3071
-
3072
- this.parseInputValue(input);
3116
+ debouncedHandleParseInput(input.value);
3073
3117
  });
3074
3118
 
3075
3119
  // we want backspace to focus on the previous digit
@@ -3394,10 +3438,15 @@ const PasscodeClass = compose(
3394
3438
  -webkit-mask-image: none;
3395
3439
  }
3396
3440
 
3441
+ /* safari */
3442
+ vaadin-text-field::part(input-field)::after {
3443
+ opacity: 0;
3444
+ }
3445
+
3397
3446
  vaadin-text-field {
3398
3447
  margin: 0;
3399
3448
  padding: 0;
3400
- width: 100%
3449
+ width: 100%;
3401
3450
  }
3402
3451
 
3403
3452
  vaadin-text-field::before {
@@ -3718,7 +3767,7 @@ const decodeHTML = (html) => {
3718
3767
 
3719
3768
  const componentName$D = getComponentName('enriched-text');
3720
3769
 
3721
- let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName: componentName$D, baseSelector: ':host > div' }) {
3770
+ class EnrichedText extends createBaseClass({ componentName: componentName$D, baseSelector: ':host > div' }) {
3722
3771
  #origLinkRenderer;
3723
3772
 
3724
3773
  #origEmRenderer;
@@ -3878,7 +3927,7 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
3878
3927
  this.contentNode.removeAttribute('inert');
3879
3928
  }
3880
3929
  }
3881
- };
3930
+ }
3882
3931
 
3883
3932
  const EnrichedTextClass = compose(
3884
3933
  createStyleMixin({
@@ -3903,9 +3952,10 @@ const EnrichedTextClass = compose(
3903
3952
  },
3904
3953
  }),
3905
3954
  createStyleMixin({ componentNameOverride: getComponentName('link') }),
3955
+ createStyleMixin({ componentNameOverride: getComponentName('text') }),
3906
3956
  draggableMixin,
3907
3957
  componentNameValidationMixin
3908
- )(EnrichedText$2);
3958
+ )(EnrichedText);
3909
3959
 
3910
3960
  customElements.define(componentName$D, EnrichedTextClass);
3911
3961
 
@@ -12941,6 +12991,7 @@ const text = {
12941
12991
  [vars$v.textLineHeight]: '1.35em',
12942
12992
  [vars$v.textAlign]: 'left',
12943
12993
  [vars$v.textColor]: globalRefs$m.colors.surface.dark,
12994
+
12944
12995
  variant: {
12945
12996
  h1: {
12946
12997
  [vars$v.fontSize]: globalRefs$m.typography.h1.size,
@@ -13024,33 +13075,31 @@ var text$1 = /*#__PURE__*/Object.freeze({
13024
13075
  });
13025
13076
 
13026
13077
  const globalRefs$l = getThemeRefs(globals);
13027
- const vars$u = EnrichedTextClass.cssVarList;
13078
+ const vars$u = LinkClass.cssVarList;
13028
13079
 
13029
- const EnrichedText = {
13080
+ const link = {
13030
13081
  [vars$u.hostDirection]: globalRefs$l.direction,
13082
+ [vars$u.cursor]: 'pointer',
13031
13083
 
13032
- [vars$u.fontSize]: globalRefs$l.typography.body1.size,
13033
- [vars$u.fontWeight]: globalRefs$l.typography.body1.weight,
13034
- [vars$u.fontWeightBold]: '900',
13035
- [vars$u.fontFamily]: globalRefs$l.typography.body1.font,
13084
+ [vars$u.textColor]: globalRefs$l.colors.primary.main,
13036
13085
 
13037
- [vars$u.textLineHeight]: '1.35em',
13038
- [vars$u.textAlign]: 'left',
13039
- [vars$u.textColor]: globalRefs$l.colors.surface.dark,
13086
+ textAlign: {
13087
+ right: { [vars$u.textAlign]: 'right' },
13088
+ left: { [vars$u.textAlign]: 'left' },
13089
+ center: { [vars$u.textAlign]: 'center' },
13090
+ },
13040
13091
 
13041
- [vars$u.linkColor]: `var(${LinkClass.cssVarList.textColor})`,
13042
- [vars$u.linkTextDecoration]: 'none',
13043
- [vars$u.linkHoverTextDecoration]: 'underline',
13092
+ _fullWidth: {
13093
+ [vars$u.hostWidth]: '100%',
13094
+ },
13044
13095
 
13045
- [vars$u.minWidth]: '0.25em',
13046
- [vars$u.minHeight]: '1.35em',
13096
+ _hover: {
13097
+ [vars$u.textDecoration]: 'underline',
13098
+ },
13047
13099
 
13048
13100
  mode: {
13049
- primary: {
13050
- [vars$u.textColor]: globalRefs$l.colors.surface.contrast,
13051
- },
13052
13101
  secondary: {
13053
- [vars$u.textColor]: globalRefs$l.colors.surface.dark,
13102
+ [vars$u.textColor]: globalRefs$l.colors.secondary.main,
13054
13103
  },
13055
13104
  error: {
13056
13105
  [vars$u.textColor]: globalRefs$l.colors.error.main,
@@ -13059,101 +13108,41 @@ const EnrichedText = {
13059
13108
  [vars$u.textColor]: globalRefs$l.colors.success.main,
13060
13109
  },
13061
13110
  },
13062
-
13063
- variant: {
13064
- h1: {
13065
- [vars$u.fontSize]: globalRefs$l.typography.h1.size,
13066
- [vars$u.fontWeight]: globalRefs$l.typography.h1.weight,
13067
- [vars$u.fontFamily]: globalRefs$l.typography.h1.font,
13068
- },
13069
- h2: {
13070
- [vars$u.fontSize]: globalRefs$l.typography.h2.size,
13071
- [vars$u.fontWeight]: globalRefs$l.typography.h2.weight,
13072
- [vars$u.fontFamily]: globalRefs$l.typography.h2.font,
13073
- },
13074
- h3: {
13075
- [vars$u.fontSize]: globalRefs$l.typography.h3.size,
13076
- [vars$u.fontWeight]: globalRefs$l.typography.h3.weight,
13077
- [vars$u.fontFamily]: globalRefs$l.typography.h3.font,
13078
- },
13079
- subtitle1: {
13080
- [vars$u.fontSize]: globalRefs$l.typography.subtitle1.size,
13081
- [vars$u.fontWeight]: globalRefs$l.typography.subtitle1.weight,
13082
- [vars$u.fontFamily]: globalRefs$l.typography.subtitle1.font,
13083
- },
13084
- subtitle2: {
13085
- [vars$u.fontSize]: globalRefs$l.typography.subtitle2.size,
13086
- [vars$u.fontWeight]: globalRefs$l.typography.subtitle2.weight,
13087
- [vars$u.fontFamily]: globalRefs$l.typography.subtitle2.font,
13088
- },
13089
- body1: {
13090
- [vars$u.fontSize]: globalRefs$l.typography.body1.size,
13091
- [vars$u.fontWeight]: globalRefs$l.typography.body1.weight,
13092
- [vars$u.fontFamily]: globalRefs$l.typography.body1.font,
13093
- },
13094
- body2: {
13095
- [vars$u.fontSize]: globalRefs$l.typography.body2.size,
13096
- [vars$u.fontWeight]: globalRefs$l.typography.body2.weight,
13097
- [vars$u.fontFamily]: globalRefs$l.typography.body2.font,
13098
- },
13099
- },
13100
-
13101
- textAlign: {
13102
- right: { [vars$u.textAlign]: 'right' },
13103
- left: { [vars$u.textAlign]: 'left' },
13104
- center: { [vars$u.textAlign]: 'center' },
13105
- },
13106
-
13107
- _fullWidth: {
13108
- [vars$u.hostWidth]: '100%',
13109
- },
13110
13111
  };
13111
13112
 
13112
- var EnrichedText$1 = /*#__PURE__*/Object.freeze({
13113
+ var link$1 = /*#__PURE__*/Object.freeze({
13113
13114
  __proto__: null,
13114
- default: EnrichedText,
13115
+ default: link,
13115
13116
  vars: vars$u
13116
13117
  });
13117
13118
 
13118
13119
  const globalRefs$k = getThemeRefs(globals);
13119
- const vars$t = LinkClass.cssVarList;
13120
+ const vars$t = EnrichedTextClass.cssVarList;
13120
13121
 
13121
- const link = {
13122
+ const enrichedText = {
13122
13123
  [vars$t.hostDirection]: globalRefs$k.direction,
13123
- [vars$t.cursor]: 'pointer',
13124
+ [vars$t.hostWidth]: useVar(vars$v.hostWidth),
13124
13125
 
13125
- [vars$t.textColor]: globalRefs$k.colors.primary.main,
13126
+ [vars$t.textLineHeight]: useVar(vars$v.textLineHeight),
13127
+ [vars$t.textColor]: useVar(vars$v.textColor),
13128
+ [vars$t.textAlign]: useVar(vars$v.textAlign),
13126
13129
 
13127
- textAlign: {
13128
- right: { [vars$t.textAlign]: 'right' },
13129
- left: { [vars$t.textAlign]: 'left' },
13130
- center: { [vars$t.textAlign]: 'center' },
13131
- },
13130
+ [vars$t.fontSize]: useVar(vars$v.fontSize),
13131
+ [vars$t.fontWeight]: useVar(vars$v.fontWeight),
13132
+ [vars$t.fontFamily]: useVar(vars$v.fontFamily),
13132
13133
 
13133
- _fullWidth: {
13134
- [vars$t.hostWidth]: '100%',
13135
- },
13136
-
13137
- _hover: {
13138
- [vars$t.textDecoration]: 'underline',
13139
- },
13134
+ [vars$t.linkColor]: useVar(vars$u.textColor),
13135
+ [vars$t.linkTextDecoration]: 'none',
13136
+ [vars$t.linkHoverTextDecoration]: 'underline',
13140
13137
 
13141
- mode: {
13142
- secondary: {
13143
- [vars$t.textColor]: globalRefs$k.colors.secondary.main,
13144
- },
13145
- error: {
13146
- [vars$t.textColor]: globalRefs$k.colors.error.main,
13147
- },
13148
- success: {
13149
- [vars$t.textColor]: globalRefs$k.colors.success.main,
13150
- },
13151
- },
13138
+ [vars$t.fontWeightBold]: '900',
13139
+ [vars$t.minWidth]: '0.25em',
13140
+ [vars$t.minHeight]: '1.35em',
13152
13141
  };
13153
13142
 
13154
- var link$1 = /*#__PURE__*/Object.freeze({
13143
+ var enrichedText$1 = /*#__PURE__*/Object.freeze({
13155
13144
  __proto__: null,
13156
- default: link,
13145
+ default: enrichedText,
13157
13146
  vars: vars$t
13158
13147
  });
13159
13148
 
@@ -14363,7 +14352,7 @@ const components = {
14363
14352
  totpImage,
14364
14353
  notpImage,
14365
14354
  text: text$1,
14366
- EnrichedText: EnrichedText$1,
14355
+ enrichedText: enrichedText$1,
14367
14356
  link: link$1,
14368
14357
  divider: divider$1,
14369
14358
  passcode: passcode$1,