@descope/web-components-ui 3.14.9 → 3.15.0
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.
- package/dist/cjs/index.cjs.js +26 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +68 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/DescopeDev.js.map +1 -1
- package/dist/umd/descope-modal-index-js.js +1 -1
- package/dist/umd/descope-modal-index-js.js.map +1 -1
- package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js +1 -1
- package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js.map +1 -1
- package/dist/umd/descope-passcode-index-js.js +1 -1
- package/dist/umd/descope-passcode-index-js.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/package.json +40 -40
- package/src/components/descope-modal/ModalClass.js +26 -0
- package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +42 -14
- package/stories/descope-modal.stories.js +13 -2
package/dist/index.esm.js
CHANGED
|
@@ -9383,6 +9383,13 @@ class PasscodeInternal extends BaseInputClass$d {
|
|
|
9383
9383
|
|
|
9384
9384
|
const debouncedHandleParseInput = debounce(handleParseInput, 0, { trailing: true });
|
|
9385
9385
|
|
|
9386
|
+
// Per-input flag: set in keydown, consumed in the input event.
|
|
9387
|
+
// Fallback for WebKit/Safari, where the native input event can fire
|
|
9388
|
+
// non-composed; proxyInputMixin then re-dispatches it as a plain Event
|
|
9389
|
+
// (no inputType), so the 'deleteContentBackward' check misses the
|
|
9390
|
+
// backspace and navigation is skipped.
|
|
9391
|
+
let lastKeyWasBackspace = false;
|
|
9392
|
+
|
|
9386
9393
|
// sanitize the input
|
|
9387
9394
|
input.addEventListener('input', (e) => {
|
|
9388
9395
|
input.value = sanitizeStr(input.value);
|
|
@@ -9391,29 +9398,50 @@ class PasscodeInternal extends BaseInputClass$d {
|
|
|
9391
9398
|
toggleMaskVisibility(input, input.value[0]);
|
|
9392
9399
|
}
|
|
9393
9400
|
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9401
|
+
// inputType covers iOS (unreliable keydown); the flag covers WebKit
|
|
9402
|
+
// (missing inputType). See flag declaration above.
|
|
9403
|
+
const isBackspace = e?.inputType === 'deleteContentBackward' || lastKeyWasBackspace;
|
|
9404
|
+
lastKeyWasBackspace = false;
|
|
9405
|
+
|
|
9406
|
+
if (isBackspace) {
|
|
9407
|
+
// Navigate synchronously (no setTimeout) to prevent WebKit key-event
|
|
9408
|
+
// leakage: with setTimeout(0), WebKit can dispatch the next key-repeat
|
|
9409
|
+
// backspace event to the newly focused element, deleting a second digit.
|
|
9410
|
+
// Calling focusElement here (inside the input event, not keydown) is safe
|
|
9411
|
+
// because the browser has already finished processing the deletion.
|
|
9412
|
+
focusElement(this.getPrevInput(input));
|
|
9413
|
+
}
|
|
9414
|
+
|
|
9399
9415
|
debouncedHandleParseInput(input.value);
|
|
9400
9416
|
});
|
|
9401
9417
|
|
|
9402
9418
|
// we want backspace to focus on the previous digit
|
|
9403
|
-
input.onkeydown = (
|
|
9404
|
-
|
|
9419
|
+
input.onkeydown = (e) => {
|
|
9420
|
+
const { key } = e;
|
|
9405
9421
|
if (key === 'Backspace') {
|
|
9406
|
-
// if value is empty then the input element does not fire `input` event
|
|
9407
|
-
// if this is the case, we focus the element here.
|
|
9408
|
-
// otherwise, the focusElement occurs as part of the `input` event listener
|
|
9409
9422
|
if (!input.value) {
|
|
9410
|
-
|
|
9423
|
+
// Empty field: the input event will not fire (nothing to delete),
|
|
9424
|
+
// so we must handle navigation here.
|
|
9425
|
+
// e.preventDefault() stops WebKit from leaking this keypress to
|
|
9426
|
+
// the element that receives focus (key-event leakage).
|
|
9427
|
+
e.preventDefault();
|
|
9428
|
+
lastKeyWasBackspace = false;
|
|
9429
|
+
focusElement(this.getPrevInput(input));
|
|
9411
9430
|
} else {
|
|
9431
|
+
// Non-empty field: let the browser delete normally so the input
|
|
9432
|
+
// event fires (needed on older iOS where keydown is unreliable).
|
|
9433
|
+
// Move the caret to the end first so Backspace deletes the digit
|
|
9434
|
+
// even if a direct tap left the caret before it (caret at index 0).
|
|
9412
9435
|
input.setSelectionRange(1, 1);
|
|
9436
|
+
// Fallback signal for the input handler (see flag declaration above).
|
|
9437
|
+
lastKeyWasBackspace = true;
|
|
9438
|
+
}
|
|
9439
|
+
} else {
|
|
9440
|
+
lastKeyWasBackspace = false;
|
|
9441
|
+
if (key.length === 1) {
|
|
9442
|
+
// we want only characters and not command keys
|
|
9443
|
+
input.value = ''; // we are clearing the previous value so we can override it with the new value
|
|
9413
9444
|
}
|
|
9414
|
-
} else if (key.length === 1) {
|
|
9415
|
-
// we want only characters and not command keys
|
|
9416
|
-
input.value = ''; // we are clearing the previous value so we can override it with the new value
|
|
9417
9445
|
}
|
|
9418
9446
|
};
|
|
9419
9447
|
|
|
@@ -15658,6 +15686,10 @@ const customMixin$8 = (superclass) =>
|
|
|
15658
15686
|
return this.getAttribute('opened') === 'true';
|
|
15659
15687
|
}
|
|
15660
15688
|
|
|
15689
|
+
get closeOnOutsideClick() {
|
|
15690
|
+
return this.getAttribute('close-on-outside-click') === 'true';
|
|
15691
|
+
}
|
|
15692
|
+
|
|
15661
15693
|
handleOpened() {
|
|
15662
15694
|
if (this.opened) {
|
|
15663
15695
|
this.style.display = '';
|
|
@@ -15723,6 +15755,28 @@ const customMixin$8 = (superclass) =>
|
|
|
15723
15755
|
overlay._enterModalState = () => {};
|
|
15724
15756
|
|
|
15725
15757
|
overlay.close = () => false;
|
|
15758
|
+
|
|
15759
|
+
// close the modal when the user clicks/taps the backdrop (outside the modal
|
|
15760
|
+
// box). Vaadin's own outside-click does not fire here because we keep the
|
|
15761
|
+
// overlay in the shadow DOM (see _attachOverlay above), which leaves it out
|
|
15762
|
+
// of Vaadin's overlay stack, so we detect the backdrop click ourselves.
|
|
15763
|
+
// the listener is always attached and reads `closeOnOutsideClick` at click
|
|
15764
|
+
// time, so toggling the attribute after init is respected.
|
|
15765
|
+
overlay.addEventListener('click', (event) => {
|
|
15766
|
+
if (!this.closeOnOutsideClick || !this.opened) return;
|
|
15767
|
+
|
|
15768
|
+
// the visible modal box; clicks inside it (content + its padding) keep
|
|
15769
|
+
// the modal open, only clicks on the dimmed backdrop close it. if we
|
|
15770
|
+
// can't find the box, don't close - safer than closing on an inside click
|
|
15771
|
+
const overlayPart = overlay.shadowRoot?.querySelector('[part="overlay"]');
|
|
15772
|
+
if (!overlayPart || event.composedPath().includes(overlayPart)) {
|
|
15773
|
+
return;
|
|
15774
|
+
}
|
|
15775
|
+
|
|
15776
|
+
// just close ourselves; consumers that need to react (e.g. ModalDriver
|
|
15777
|
+
// resetting the content) observe the `opened` attribute
|
|
15778
|
+
this.removeAttribute('opened');
|
|
15779
|
+
});
|
|
15726
15780
|
}
|
|
15727
15781
|
};
|
|
15728
15782
|
|