@descope/web-components-ui 1.0.312 → 1.0.314

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 (27) hide show
  1. package/dist/cjs/index.cjs.js +209 -29
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +231 -63
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/umd/4978.js +1 -1
  6. package/dist/umd/DescopeDev.js +1 -1
  7. package/dist/umd/descope-divider-index-js.js +1 -1
  8. package/dist/umd/descope-enriched-text-index-js.js +1 -1
  9. package/dist/umd/descope-link-index-js.js +1 -1
  10. package/dist/umd/descope-new-password-descope-new-password-internal-index-js.js +1 -1
  11. package/dist/umd/descope-new-password-index-js.js +1 -1
  12. package/dist/umd/descope-password-index-js.js +1 -1
  13. package/dist/umd/descope-text-index-js.js +1 -1
  14. package/dist/umd/descope-user-attribute-index-js.js +1 -1
  15. package/dist/umd/descope-user-auth-method-index-js.js +1 -1
  16. package/dist/umd/mapping-fields-descope-mappings-field-index-js.js +1 -1
  17. package/dist/umd/mapping-fields-descope-saml-group-mappings-index-js.js +1 -1
  18. package/package.json +1 -1
  19. package/src/components/descope-enriched-text/EnrichedTextClass.js +1 -0
  20. package/src/components/descope-link/LinkClass.js +1 -0
  21. package/src/components/descope-new-password/NewPasswordClass.js +27 -1
  22. package/src/components/descope-new-password/descope-new-password-internal/NewPasswordInternal.js +18 -30
  23. package/src/components/descope-password/PasswordClass.js +92 -15
  24. package/src/components/descope-password/helpers.js +62 -0
  25. package/src/components/descope-password/passwordDraggableMixin.js +16 -11
  26. package/src/components/descope-text/TextClass.js +1 -0
  27. package/src/mixins/inputValidationMixin.js +12 -1
@@ -1985,8 +1985,13 @@ const errorAttributes = {
1985
1985
  tooShort: 'data-errormessage-pattern-mismatch-too-short',
1986
1986
  tooLong: 'data-errormessage-pattern-mismatch-too-long',
1987
1987
  };
1988
+
1989
+ const validationTargetSymbol = Symbol('validationTarget');
1990
+
1988
1991
  const inputValidationMixin = (superclass) =>
1989
1992
  class InputValidationMixinClass extends superclass {
1993
+ #validationTarget = validationTargetSymbol;
1994
+
1990
1995
  static get observedAttributes() {
1991
1996
  return [...(superclass.observedAttributes || []), ...observedAttributes$4];
1992
1997
  }
@@ -2103,7 +2108,13 @@ const inputValidationMixin = (superclass) =>
2103
2108
  }
2104
2109
 
2105
2110
  get validationTarget() {
2106
- return this.inputElement;
2111
+ return this.#validationTarget === validationTargetSymbol
2112
+ ? this.inputElement
2113
+ : this.#validationTarget;
2114
+ }
2115
+
2116
+ set validationTarget(val) {
2117
+ this.#validationTarget = val;
2107
2118
  }
2108
2119
 
2109
2120
  setCustomValidity(errorMessage) {
@@ -3139,7 +3150,7 @@ const componentName$O = getComponentName('text-field');
3139
3150
 
3140
3151
  const observedAttrs = ['type'];
3141
3152
 
3142
- const customMixin$8 = (superclass) =>
3153
+ const customMixin$9 = (superclass) =>
3143
3154
  class TextFieldClass extends superclass {
3144
3155
  static get observedAttributes() {
3145
3156
  return observedAttrs.concat(superclass.observedAttributes || []);
@@ -3191,7 +3202,7 @@ const TextFieldClass = compose(
3191
3202
  draggableMixin,
3192
3203
  composedProxyInputMixin({ proxyProps: ['value', 'selectionStart'] }),
3193
3204
  componentNameValidationMixin,
3194
- customMixin$8
3205
+ customMixin$9
3195
3206
  )(
3196
3207
  createProxy({
3197
3208
  slots: ['prefix', 'suffix'],
@@ -3346,32 +3357,165 @@ const passwordDraggableMixin = (superclass) =>
3346
3357
  // there is an issue in Chrome that input field with type password cannot be D&D
3347
3358
  // so in case the input is draggable & readonly, we are changing the input type to "text" before dragging
3348
3359
  // and return the original type when done
3349
- this.addEventListener('mousedown', (e) => {
3360
+ super.init?.();
3361
+
3362
+ const ele = this.querySelector('input');
3363
+
3364
+ ele?.addEventListener('mousedown', (e) => {
3350
3365
  if (this.isDraggable && this.isReadOnly) {
3351
- const inputEle = this.baseElement.querySelector('input');
3352
- const prevType = inputEle.getAttribute('type');
3366
+ ele.setAttribute('inert', 'true');
3353
3367
 
3368
+ const inputEle = e.target;
3369
+ const prevType = inputEle.getAttribute('type');
3354
3370
  inputEle.setAttribute('type', 'text');
3355
- setTimeout(() => inputEle.focus());
3371
+ setTimeout(() => {
3372
+ inputEle.focus();
3373
+ });
3356
3374
 
3357
3375
  const onComplete = (_) => {
3358
3376
  inputEle.setAttribute('type', prevType);
3359
-
3360
- e.target.removeEventListener('mouseup', onComplete);
3361
- e.target.removeEventListener('dragend', onComplete);
3377
+ ele.removeAttribute('inert');
3378
+ this.removeEventListener('mouseup', onComplete);
3379
+ this.removeEventListener('dragend', onComplete);
3362
3380
  };
3363
3381
 
3364
- e.target.addEventListener('mouseup', onComplete, { once: true });
3365
- e.target.addEventListener('dragend', onComplete, { once: true });
3382
+ this.addEventListener('dragend', onComplete, { once: true });
3383
+ this.addEventListener('mouseup', onComplete, { once: true });
3366
3384
  }
3367
3385
  });
3368
-
3369
- super.init?.();
3370
3386
  }
3371
3387
  };
3372
3388
 
3389
+ // since on load we can only sample the color of the placeholder,
3390
+ // we need to temporarily populate the input in order to sample the value color
3391
+ const getValueColor = (ele, computedStyle) => {
3392
+ // eslint-disable-next-line no-param-reassign
3393
+ ele.value = '_';
3394
+
3395
+ const valueColor = computedStyle.getPropertyValue('color');
3396
+
3397
+ // eslint-disable-next-line no-param-reassign
3398
+ ele.value = '';
3399
+
3400
+ return valueColor;
3401
+ };
3402
+
3403
+ const createExternalInputSlot = (slotName, targetSlotName) => {
3404
+ const slotEle = document.createElement('slot');
3405
+
3406
+ slotEle.setAttribute('name', slotName);
3407
+ slotEle.setAttribute('slot', targetSlotName);
3408
+
3409
+ return slotEle;
3410
+ };
3411
+
3412
+ const createExternalInputEle = (targetSlotName, autocompleteType) => {
3413
+ const inputEle = document.createElement('input');
3414
+
3415
+ inputEle.setAttribute('slot', targetSlotName);
3416
+ inputEle.setAttribute('type', 'password');
3417
+ inputEle.setAttribute('data-hidden-input', 'true');
3418
+ inputEle.setAttribute('autocomplete', autocompleteType);
3419
+
3420
+ return inputEle;
3421
+ };
3422
+
3423
+ const applyExternalInputStyles = (sourceInputEle, targetInputEle) => {
3424
+ const computedStyle = getComputedStyle(sourceInputEle);
3425
+ const height = computedStyle.getPropertyValue('height');
3426
+ const paddingLeft = computedStyle.getPropertyValue('padding-left');
3427
+ const paddingRight = computedStyle.getPropertyValue('padding-right');
3428
+ const fontSize = computedStyle.getPropertyValue('font-size');
3429
+ const fontFamily = computedStyle.getPropertyValue('font-family');
3430
+ const letterSpacing = computedStyle.getPropertyValue('letter-spacing');
3431
+ const caretColor = computedStyle.getPropertyValue('caret-color');
3432
+ const valueColor = getValueColor(sourceInputEle, computedStyle);
3433
+
3434
+ // set external input style (and lock it with `all: unset` and `!important` all around)
3435
+ // eslint-disable-next-line no-param-reassign
3436
+ targetInputEle.style = `
3437
+ all: unset !important;
3438
+ position: absolute !important;
3439
+ width: calc(100% - 3em) !important;
3440
+ background-color: transparent !important;
3441
+ color: ${valueColor} !important;
3442
+ height: ${height} !important;
3443
+ left: ${paddingLeft} !important;
3444
+ right: ${paddingRight} !important;
3445
+ font-size: ${fontSize} !important;
3446
+ font-family: ${fontFamily} !important;
3447
+ letter-spacing: ${letterSpacing} !important;
3448
+ caret-color: ${caretColor} !important;
3449
+ `;
3450
+ };
3451
+
3373
3452
  const componentName$M = getComponentName('password');
3374
3453
 
3454
+ const customMixin$8 = (superclass) =>
3455
+ class PasswordFieldMixinClass extends superclass {
3456
+ init() {
3457
+ super.init?.();
3458
+
3459
+ // reset vaadin's checkValidity
3460
+ this.baseElement.checkValidity = () => {};
3461
+ // set safety attribute `external-input`
3462
+ this.setAttribute('external-input', 'true');
3463
+
3464
+ // use original input element as reference
3465
+ const origInput = this.baseElement.querySelector('input');
3466
+
3467
+ // create external slot
3468
+ const externalInputSlot = createExternalInputSlot('external-input', 'suffix');
3469
+ // append external slot to base element
3470
+ this.baseElement.appendChild(externalInputSlot);
3471
+
3472
+ // create external input
3473
+ const externalInput = createExternalInputEle('external-input', this.getAutocompleteType());
3474
+
3475
+ // apply original input's styles to external input
3476
+ setTimeout(() => {
3477
+ applyExternalInputStyles(origInput, externalInput);
3478
+ });
3479
+
3480
+ // set external input events
3481
+ this.handleExternalInputEvents(externalInput);
3482
+
3483
+ // sync input stateful attributes: `type` (for visibility state change) and `readonly`
3484
+ syncAttrs(origInput, externalInput, { includeAttrs: ['type', 'readonly'] });
3485
+
3486
+ origInput.addEventListener('focus', (e) => {
3487
+ e.preventDefault();
3488
+ if (e.isTrusted) {
3489
+ externalInput.focus();
3490
+ }
3491
+ });
3492
+
3493
+ this.addEventListener('focus', (e) => {
3494
+ e.preventDefault();
3495
+ this.focus();
3496
+ });
3497
+
3498
+ // append external input to component's DOM
3499
+ this.appendChild(externalInput);
3500
+ }
3501
+
3502
+ getAutocompleteType() {
3503
+ return this.getAttribute('autocomplete') || 'current-password';
3504
+ }
3505
+
3506
+ handleExternalInputEvents(inputEle) {
3507
+ // sync value of insible input back to original input
3508
+ inputEle.addEventListener('input', (e) => {
3509
+ this.value = e.target.value;
3510
+ });
3511
+
3512
+ // sync `focused` attribute on host when focusing on external input
3513
+ inputEle.addEventListener('focus', () => {
3514
+ this.setAttribute('focused', 'true');
3515
+ });
3516
+ }
3517
+ };
3518
+
3375
3519
  const {
3376
3520
  host: host$l,
3377
3521
  inputField: inputField$5,
@@ -3387,9 +3531,9 @@ const {
3387
3531
  host: { selector: () => ':host' },
3388
3532
  inputField: { selector: '::part(input-field)' },
3389
3533
  inputElement: { selector: '> input' },
3390
- inputElementPlaceholder: { selector: '> input:placeholder-shown' },
3391
- revealButtonContainer: { selector: () => '::part(reveal-button)' },
3392
- revealButtonIcon: { selector: () => '::part(reveal-button)::before' },
3534
+ inputElementPlaceholder: { selector: () => ':host input:placeholder-shown' },
3535
+ revealButtonContainer: { selector: '::part(reveal-button)' },
3536
+ revealButtonIcon: { selector: '::part(reveal-button)::before' },
3393
3537
  label: { selector: '::part(label)' },
3394
3538
  requiredIndicator: { selector: '[required]::part(required-indicator)::after' },
3395
3539
  helperText: { selector: '::part(helper-text)' },
@@ -3428,8 +3572,14 @@ const PasswordClass = compose(
3428
3572
  labelRequiredIndicator: { ...requiredIndicator$a, property: 'content' },
3429
3573
  errorMessageTextColor: { ...errorMessage$b, property: 'color' },
3430
3574
 
3431
- inputValueTextColor: { ...inputElement$2, property: 'color' },
3432
- inputPlaceholderTextColor: { ...inputElementPlaceholder, property: 'color' },
3575
+ inputPlaceholderTextColor: [
3576
+ { ...inputElementPlaceholder, property: 'color' },
3577
+ { selector: () => ':host ::slotted(input:placeholder-shown)', property: 'color' },
3578
+ ],
3579
+ inputValueTextColor: [
3580
+ { ...inputElement$2, property: 'color' },
3581
+ { selector: () => ':host ::slotted(input)', property: 'color' },
3582
+ ],
3433
3583
 
3434
3584
  revealButtonOffset: [
3435
3585
  { ...revealButtonContainer, property: 'margin-right' },
@@ -3442,7 +3592,8 @@ const PasswordClass = compose(
3442
3592
  draggableMixin,
3443
3593
  composedProxyInputMixin({ proxyProps: ['value', 'selectionStart'] }),
3444
3594
  componentNameValidationMixin,
3445
- passwordDraggableMixin
3595
+ passwordDraggableMixin,
3596
+ customMixin$8
3446
3597
  )(
3447
3598
  createProxy({
3448
3599
  slots: ['', 'suffix'],
@@ -3453,6 +3604,7 @@ const PasswordClass = compose(
3453
3604
  max-width: 100%;
3454
3605
  min-width: 10em;
3455
3606
  box-sizing: border-box;
3607
+ position: relative;
3456
3608
  }
3457
3609
  ${useHostExternalPadding(PasswordClass.cssVarList)}
3458
3610
  ${resetInputCursor('vaadin-password-field')}
@@ -3464,7 +3616,9 @@ const PasswordClass = compose(
3464
3616
  padding: 0;
3465
3617
  }
3466
3618
  vaadin-password-field > input {
3619
+ -webkit-mask-image: none;
3467
3620
  box-sizing: border-box;
3621
+ opacity: 1;
3468
3622
  }
3469
3623
  vaadin-password-field::part(input-field) {
3470
3624
  box-sizing: border-box;
@@ -3473,12 +3627,11 @@ const PasswordClass = compose(
3473
3627
  vaadin-password-field[focus-ring]::part(input-field) {
3474
3628
  box-shadow: none;
3475
3629
  }
3476
- vaadin-password-field > input {
3630
+ :host ::slotted(input) {
3477
3631
  min-height: 0;
3478
- -webkit-mask-image: none;
3479
- }
3480
- vaadin-password-field[readonly] > input:placeholder-shown {
3481
- opacity: 1;
3632
+ }
3633
+ :host([readonly]) ::slotted(input:placeholder-shown) {
3634
+ opacity: 0;
3482
3635
  }
3483
3636
  vaadin-password-field::before {
3484
3637
  height: initial;
@@ -3489,11 +3642,9 @@ const PasswordClass = compose(
3489
3642
  vaadin-password-field-button {
3490
3643
  cursor: pointer;
3491
3644
  }
3492
-
3493
- [readonly] vaadin-password-field-button {
3645
+ :host([readonly]) vaadin-password-field-button {
3494
3646
  pointer-events: none;
3495
3647
  }
3496
-
3497
3648
  vaadin-password-field-button[focus-ring] {
3498
3649
  box-shadow: 0 0 0 2px var(${PasswordClass.cssVarList.inputOutlineColor});
3499
3650
  }
@@ -4537,6 +4688,7 @@ class RawText extends createBaseClass({ componentName: componentName$B, baseSele
4537
4688
  <style>
4538
4689
  :host {
4539
4690
  display: inline-block;
4691
+ line-height: 1em;
4540
4692
  }
4541
4693
  :host > slot {
4542
4694
  width: 100%;
@@ -4701,6 +4853,7 @@ let EnrichedText$2 = class EnrichedText extends createBaseClass({ componentName:
4701
4853
  <style>
4702
4854
  :host {
4703
4855
  display: inline-block;
4856
+ line-height: 1em;
4704
4857
  }
4705
4858
  :host > slot {
4706
4859
  width: 100%;
@@ -4861,6 +5014,7 @@ class RawLink extends createBaseClass({ componentName: componentName$z, baseSele
4861
5014
  <style>
4862
5015
  :host {
4863
5016
  display: inline-block;
5017
+ line-height: 1em;
4864
5018
  }
4865
5019
  :host a {
4866
5020
  display: inline;
@@ -8044,13 +8198,24 @@ const customMixin$3 = (superclass) =>
8044
8198
  name="new-password"
8045
8199
  tabindex="-1"
8046
8200
  slot="input"
8047
- ></${componentName$n}>
8201
+ >
8202
+ </${componentName$n}>
8048
8203
  `;
8049
8204
 
8205
+ this.setAttribute('external-input', 'true');
8206
+
8050
8207
  this.baseElement.appendChild(template.content.cloneNode(true));
8051
8208
 
8052
8209
  this.inputElement = this.shadowRoot.querySelector(componentName$n);
8053
8210
 
8211
+ // get descope input components
8212
+ this.passwordInput = this.inputElement.querySelector('[data-id="password"]');
8213
+ this.confirmInput = this.inputElement.querySelector('[data-id="confirm"]');
8214
+
8215
+ // create slots for external password input
8216
+ this.createExternalInput(this.passwordInput, 'external-password-input');
8217
+ this.createExternalInput(this.confirmInput, 'external-confirm-input');
8218
+
8054
8219
  forwardAttrs(this, this.inputElement, {
8055
8220
  includeAttrs: [
8056
8221
  'password-label',
@@ -8073,6 +8238,20 @@ const customMixin$3 = (superclass) =>
8073
8238
  ],
8074
8239
  });
8075
8240
  }
8241
+
8242
+ createExternalInput(node, slotName) {
8243
+ const externalInput = node.querySelector('input');
8244
+ const slotEle = document.createElement('slot');
8245
+ const targetSlot = externalInput.getAttribute('slot');
8246
+ slotEle.setAttribute('name', slotName);
8247
+ slotEle.setAttribute('slot', targetSlot);
8248
+ node.appendChild(slotEle);
8249
+
8250
+ // move external input
8251
+ externalInput.setAttribute('slot', slotName);
8252
+ externalInput.setAttribute('data-hidden-input', 'true');
8253
+ this.appendChild(externalInput);
8254
+ }
8076
8255
  };
8077
8256
 
8078
8257
  const {
@@ -8160,6 +8339,7 @@ const NewPasswordClass = compose(
8160
8339
  padding: 0;
8161
8340
  }
8162
8341
  descope-new-password-internal > .wrapper {
8342
+ -webkit-mask-image: none;
8163
8343
  width: 100%;
8164
8344
  height: 100%;
8165
8345
  display: flex;