wj-elements 0.7.0 → 0.7.1

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.
@@ -23,7 +23,7 @@ import Option from "./wje-option.js";
23
23
  import Options from "./wje-options.js";
24
24
  import Checkbox from "./wje-checkbox.js";
25
25
  import { P as Popup } from "./popup.element-CwXvVFK7.js";
26
- const styles = "/*\n[ WJ Select ]\n*/\n\n:host {\n margin-bottom: var(--wje-select-margin-bottom);\n width: 100%;\n display: block;\n [slot='arrow'] {\n transform: rotate(0deg);\n transition: all 0.2s ease-in;\n }\n label {\n margin: var(--wje-select-label-margin);\n padding: var(--wje-select-label-padding);\n display: var(--wje-select-label-display);\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-select-label-line-height);\n font-size: var(--wje-select-label-font-size);\n }\n}\n\n.native-select {\n position: relative;\n &.default {\n .wrapper {\n display: block;\n background-color: var(--wje-select-background);\n border-width: var(--wje-select-border-width);\n border-style: var(--wje-select-border-style);\n border-color: var(--wje-select-border-color);\n border-radius: var(--wje-select-border-radius);\n padding-inline: 0.5rem;\n padding-top: 0.125rem;\n padding-bottom: 0.125rem;\n }\n .input-wrapper {\n padding: 0;\n min-height: 28px;\n margin-top: -4px;\n }\n &.focused {\n wje-label {\n opacity: 0.67;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n label {\n &.fade {\n opacity: 0.5;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n }\n &.standard {\n .wrapper {\n height: var(--wje-select-height);\n box-sizing: border-box;\n background-color: var(--wje-select-background);\n border-width: var(--wje-select-border-width);\n border-style: var(--wje-select-border-style);\n border-color: var(--wje-select-border-color);\n border-radius: var(--wje-select-border-radius);\n }\n .input-wrapper {\n background: transparent;\n width: 100%;\n }\n slot[name='error'] {\n position: static;\n\n background: transparent;\n padding: 0.25rem 0;\n left: auto;\n transform: none;\n color: var(--wje-input-color-invalid);\n font-size: 12px;\n line-height: normal;\n }\n }\n}\n\n.wrapper {\n display: flex;\n width: 100%;\n}\n\n.input-wrapper {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr) auto auto auto;\n align-items: center;\n background-color: var(--wje-select-background);\n /*min-height: 28px;*/\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n appearance: none;\n padding: 2px 0.5rem;\n font-size: 14px !important;\n font-weight: normal;\n vertical-align: middle;\n input[readonly] {\n pointer-events: none;\n caret-color: transparent;\n }\n}\n\ninput {\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n font-size: 14px !important;\n font-weight: 400;\n letter-spacing: 0.01em;\n border: medium;\n height: 25px;\n min-height: 25px;\n padding: 0;\n background: none;\n box-shadow: none;\n width: 100%;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n outline: 0;\n font-size: 14px !important;\n}\n\n.display-wrapper {\n display: block;\n min-width: 0;\n width: 100%;\n position: relative;\n}\n\n.display-input {\n position: absolute;\n inset: 0;\n opacity: 0;\n pointer-events: none;\n}\n\n.display-text {\n display: block;\n min-width: 0;\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n font-size: 14px !important;\n font-weight: 400;\n letter-spacing: 0.01em;\n}\n\n.display-text[data-placeholder-visible]::before {\n content: attr(data-placeholder);\n}\n\n::placeholder {\n opacity: 1;\n}\n\n:host [active] {\n .wrapper {\n border-radius: var(--wje-select-border-radius);\n }\n [slot='arrow'] {\n transform: rotate(180deg);\n transition: all 0.2s ease-in;\n }\n}\n\n.options-wrapper {\n box-sizing: border-box;\n min-width: 100%;\n border-width: var(--wje-select-options-border-width);\n border-style: var(--wje-select-options-border-style);\n border-color: var(--wje-select-options-border-color);\n border-radius: var(--wje-select-options-border-radius);\n margin-top: calc(0px - var(--wje-select-border-width));\n background-color: var(--wje-select-options-background-color);\n overflow: hidden;\n}\n\n.find {\n margin-block: var(--wje-select-find-margin-block);\n margin-inline: var(--wje-select-find-margin-inline);\n width: var(--wje-select-find-width);\n}\n\n.list {\n overflow: auto;\n height: 100%;\n position: relative;\n}\n\n.list:has(.empty:not([hidden])) {\n min-height: 44px;\n}\n\n.empty {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--wje-spacing-small);\n color: var(--wje-select-color);\n text-align: center;\n background-color: var(--wje-select-options-background-color);\n pointer-events: none;\n}\n\n.empty[hidden] {\n display: none;\n}\n\n.options-wrapper:has(.find) .list {\n height: calc(100% - 32px - 2 * var(--wje-select-find-margin-block));\n}\n\n:host([multiple]) input {\n position: absolute;\n z-index: -1;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n opacity: 0;\n}\n\n:host([multiple]) .display-wrapper {\n display: none;\n}\n\n:host([multiple]) .chips {\n display: flex;\n flex: 1;\n align-items: center;\n flex-wrap: wrap;\n gap: var(--wje-spacing-3x-small);\n}\n\n:host([disabled]) .input-wrapper {\n opacity: 0.5;\n pointer-events: none;\n cursor: not-allowed;\n}\n\n.counter {\n padding-inline: 0.5rem;\n}\n\nwje-chip {\n --wje-chip-margin: 0 0.25rem 0 0;\n}\n\nwje-button {\n --wje-padding-top: 0.25rem;\n --wje-padding-start: 0.25rem;\n --wje-padding-end: 0.25rem;\n --wje-padding-bottom: 0.25rem;\n --wje-button-margin-inline: 0 0.25rem;\n}\n\n.slot-start,\n.slot-end {\n &:not(:empty) {\n margin-right: 0.5rem;\n }\n}\n\nslot[name='error'] {\n display: none;\n}\n\n:host([invalid]) slot[name='error'] {\n display: block;\n}\n\nslot[name='error'] {\n display: none;\n position: absolute;\n max-width: 100%;\n min-width: auto;\n border-radius: 50px;\n background-color: var(--wje-select-error-background-color, var(--wje-tooltip-background));\n padding: 0.25rem 0.5rem;\n top: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n color: var(--wje-select-error-color, var(--wje-tooltip-color));\n font-size: var(--wje-font-size-small);\n width: max-content;\n line-height: normal;\n}\n\n.input-hidden{\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n opacity: 0;\n z-index: -1;\n}\n\n:host([required]) .wrapper::after {\n color: var(--wje-input-color-invalid);\n content: var(--wje-input-required-symbol);\n font-size: 24px;\n position: absolute;\n right: 12px;\n top: 0;\n}\n\n:host([required]) .standard .input-wrapper::after {\n right: 13px;\n top: -20px;\n}\n";
26
+ const styles = "/*\n[ WJ Select ]\n*/\n\n:host {\n margin-bottom: var(--wje-select-margin-bottom);\n width: 100%;\n display: block;\n [slot='arrow'] {\n transform: rotate(0deg);\n transition: all 0.2s ease-in;\n }\n label {\n margin: var(--wje-select-label-margin);\n padding: var(--wje-select-label-padding);\n display: var(--wje-select-label-display);\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-select-label-line-height);\n font-size: var(--wje-select-label-font-size);\n }\n}\n\n.native-select {\n position: relative;\n &.default {\n .wrapper {\n display: block;\n background-color: var(--wje-select-background);\n border-width: var(--wje-select-border-width);\n border-style: var(--wje-select-border-style);\n border-color: var(--wje-select-border-color);\n border-radius: var(--wje-select-border-radius);\n padding-inline: 0.5rem;\n padding-top: 0.125rem;\n padding-bottom: 0.125rem;\n }\n .input-wrapper {\n padding: 0;\n min-height: 28px;\n margin-top: -4px;\n }\n &.focused {\n wje-label {\n opacity: 0.67;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n label {\n &.fade {\n opacity: 0.5;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n }\n &.standard {\n .wrapper {\n height: var(--wje-select-height);\n box-sizing: border-box;\n background-color: var(--wje-select-background);\n border-width: var(--wje-select-border-width);\n border-style: var(--wje-select-border-style);\n border-color: var(--wje-select-border-color);\n border-radius: var(--wje-select-border-radius);\n }\n .input-wrapper {\n background: transparent;\n width: 100%;\n }\n slot[name='error'] {\n position: static;\n\n background: transparent;\n padding: 0.25rem 0;\n left: auto;\n transform: none;\n color: var(--wje-input-color-invalid);\n font-size: 12px;\n line-height: normal;\n }\n }\n}\n\n.wrapper {\n display: flex;\n width: 100%;\n}\n\n.input-wrapper {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr) auto auto auto;\n align-items: center;\n background-color: var(--wje-select-background);\n /*min-height: 28px;*/\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n appearance: none;\n padding: 2px 0.5rem;\n font-size: 14px !important;\n font-weight: normal;\n vertical-align: middle;\n input[readonly] {\n pointer-events: none;\n caret-color: transparent;\n }\n}\n\ninput {\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n font-size: 14px !important;\n font-weight: 400;\n letter-spacing: 0.01em;\n border: medium;\n height: 25px;\n min-height: 25px;\n padding: 0;\n background: none;\n box-shadow: none;\n width: 100%;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n outline: 0;\n font-size: 14px !important;\n}\n\n.display-wrapper {\n display: block;\n min-width: 0;\n width: 100%;\n position: relative;\n}\n\n.display-input {\n position: absolute;\n inset: 0;\n opacity: 0;\n pointer-events: none;\n}\n\n.display-text {\n display: block;\n min-width: 0;\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--wje-select-color);\n line-height: var(--wje-select-line-height);\n font-size: 14px !important;\n font-weight: 400;\n letter-spacing: 0.01em;\n}\n\n.display-text[data-placeholder-visible]::before {\n content: attr(data-placeholder);\n}\n\n::placeholder {\n opacity: 1;\n}\n\n:host [active] {\n .wrapper {\n border-radius: var(--wje-select-border-radius);\n }\n [slot='arrow'] {\n transform: rotate(180deg);\n transition: all 0.2s ease-in;\n }\n}\n\n.options-wrapper {\n box-sizing: border-box;\n min-width: 100%;\n border-width: var(--wje-select-options-border-width);\n border-style: var(--wje-select-options-border-style);\n border-color: var(--wje-select-options-border-color);\n border-radius: var(--wje-select-options-border-radius);\n margin-top: calc(0px - var(--wje-select-border-width));\n background-color: var(--wje-select-options-background-color);\n overflow: hidden;\n}\n\n.find {\n margin-block: var(--wje-select-find-margin-block);\n margin-inline: var(--wje-select-find-margin-inline);\n width: var(--wje-select-find-width);\n}\n\n.list {\n overflow: auto;\n height: 100%;\n position: relative;\n}\n\n.list:has(.empty:not([hidden])) {\n min-height: 44px;\n}\n\n.empty {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--wje-spacing-small);\n color: var(--wje-select-color);\n text-align: center;\n background-color: var(--wje-select-options-background-color);\n pointer-events: none;\n}\n\n.empty[hidden] {\n display: none;\n}\n\n.options-wrapper:has(.find) .list {\n height: calc(100% - 32px - 2 * var(--wje-select-find-margin-block));\n}\n\n:host([multiple]) input {\n position: absolute;\n z-index: -1;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n opacity: 0;\n}\n\n:host([multiple]) .display-wrapper {\n display: none;\n}\n\n:host([multiple]) .chips {\n display: flex;\n grid-column: 2;\n grid-row: 1;\n flex: 1 1 auto;\n min-width: 0;\n max-width: 100%;\n align-items: center;\n flex-wrap: nowrap;\n gap: var(--wje-spacing-3x-small);\n overflow: hidden;\n white-space: nowrap;\n}\n\n:host([disabled]) .input-wrapper {\n opacity: 0.5;\n pointer-events: none;\n cursor: not-allowed;\n}\n\n.counter {\n flex: 0 0 auto;\n padding-inline: 0.5rem;\n}\n\nwje-chip {\n --wje-chip-margin: 0 0.25rem 0 0;\n}\n\n:host([multiple]) wje-chip {\n flex: 0 1 auto;\n min-width: var(--wje-select-chip-min-width, 2.5rem);\n max-width: 100%;\n}\n\n:host([multiple]) wje-chip:first-of-type {\n flex-shrink: 10;\n}\n\n:host([multiple]) wje-button[part='clear'] {\n grid-column: 3;\n grid-row: 1;\n}\n\n:host([multiple]) .slot-end {\n grid-column: 4;\n grid-row: 1;\n}\n\n:host([multiple]) [slot='arrow'] {\n grid-column: 5;\n grid-row: 1;\n}\n\nwje-button {\n --wje-padding-top: 0.25rem;\n --wje-padding-start: 0.25rem;\n --wje-padding-end: 0.25rem;\n --wje-padding-bottom: 0.25rem;\n --wje-button-margin-inline: 0 0.25rem;\n}\n\n.slot-start,\n.slot-end {\n &:not(:empty) {\n margin-right: 0.5rem;\n }\n}\n\nslot[name='error'] {\n display: none;\n}\n\n:host([invalid]) slot[name='error'] {\n display: block;\n}\n\nslot[name='error'] {\n display: none;\n position: absolute;\n max-width: 100%;\n min-width: auto;\n border-radius: 50px;\n background-color: var(--wje-select-error-background-color, var(--wje-tooltip-background));\n padding: 0.25rem 0.5rem;\n top: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n color: var(--wje-select-error-color, var(--wje-tooltip-color));\n font-size: var(--wje-font-size-small);\n width: max-content;\n line-height: normal;\n}\n\n.input-hidden{\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n opacity: 0;\n z-index: -1;\n}\n\n:host([required]) .wrapper::after {\n color: var(--wje-input-color-invalid);\n content: var(--wje-input-required-symbol);\n font-size: 24px;\n position: absolute;\n right: 12px;\n top: 0;\n}\n\n:host([required]) .standard .input-wrapper::after {\n right: 13px;\n top: -20px;\n}\n";
27
27
  const _Select = class _Select extends FormAssociatedElement {
28
28
  constructor() {
29
29
  super();
@@ -3,9 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import WJElement from "./wje-element.js";
5
5
  import { event } from "./event.js";
6
- const styles = ":host {\n display: block;\n z-index: 9999;\n position: relative;\n height: 100%;\n right: unset;\n left: unset;\n .close-button {\n position: absolute;\n top: 0;\n right: 0;\n z-index: 1000;\n }\n}\n\n:host([hide-button]) {\n .close-button {\n display: none;\n }\n}\n\n.sliding-container-backdrop {\n display: none;\n}\n\n.sliding-container-wrapper {\n height: 100%;\n position: relative;\n overflow: hidden;\n}\n\n.native-sliding-container {\n\n position: absolute;\n width: 0;\n height: 100%;\n}\n\n.native-sliding-container-inner {\n height: 100%;\n position: absolute;\n}\n\n.sliding-container-sheet-handle-area {\n display: none;\n}\n\n:host(.bottom-sheet) {\n inset: 0;\n pointer-events: none;\n}\n\n:host(.bottom-sheet.open) {\n pointer-events: auto;\n overscroll-behavior: contain;\n}\n\n:host(.bottom-sheet) .sliding-container-backdrop {\n display: block;\n position: fixed;\n inset: 0;\n z-index: 0;\n opacity: 0;\n pointer-events: none;\n touch-action: none;\n overscroll-behavior: none;\n background: var(--wje-sliding-container-backdrop-background, var(--wje-backdrop, rgba(0, 0, 0, .35)));\n}\n\n:host(.bottom-sheet.open) .sliding-container-backdrop {\n pointer-events: auto;\n}\n\n:host(.bottom-sheet) .sliding-container-wrapper {\n position: fixed;\n inset: 0;\n overflow: visible;\n pointer-events: none;\n z-index: 1;\n}\n\n:host(.bottom-sheet) .sliding-container-transparent {\n display: none;\n}\n\n:host(.bottom-sheet) .native-sliding-container {\n position: fixed;\n top: auto;\n height: fit-content;\n overflow: hidden;\n pointer-events: auto;\n display: flex;\n flex-direction: column;\n overscroll-behavior: contain;\n background: var(--wje-sliding-container-background);\n box-shadow: var(--wje-sliding-container-box-shadow, var(--wje-sliding-container-shadow));\n border-radius: var(--wje-sliding-container-sheet-border-radius, var(--wje-sliding-container-border-radius) var(--wje-sliding-container-border-radius) 0 0);\n}\n\n:host(.bottom-sheet) .native-sliding-container-inner {\n position: relative;\n flex: 1 1 auto;\n min-height: 0;\n height: auto;\n max-height: inherit;\n overflow: auto;\n overscroll-behavior: contain;\n}\n\n:host(.bottom-sheet) .sliding-container-sheet-handle-area {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 var(--wje-sliding-container-sheet-handle-area-height, 24px);\n height: var(--wje-sliding-container-sheet-handle-area-height, 24px);\n cursor: ns-resize;\n pointer-events: auto;\n touch-action: none;\n user-select: none;\n -webkit-user-select: none;\n}\n\n:host(.bottom-sheet) .sliding-container-sheet-handle {\n width: var(--wje-sliding-container-sheet-handle-width, 36px);\n height: var(--wje-sliding-container-sheet-handle-height, 2px);\n background: var(--wje-sliding-container-sheet-handle-background, var(--wje-border-color));\n border-radius: var(--wje-sliding-container-sheet-handle-radius, 999px);\n}\n";
7
- let documentScrollLocks = 0;
8
- let documentScrollState = null;
6
+ const styles = ":host {\n display: block;\n z-index: var(--wje-sliding-container-z-index, 1000);\n position: relative;\n height: 100%;\n right: unset;\n left: unset;\n .close-button {\n position: absolute;\n top: 0;\n right: 0;\n z-index: 2;\n }\n}\n\n:host([hide-button]) {\n .close-button {\n display: none;\n }\n}\n\n.sliding-container-backdrop {\n display: none;\n}\n\n.sliding-container-wrapper {\n height: 100%;\n position: relative;\n overflow: hidden;\n}\n\n.native-sliding-container {\n\n position: absolute;\n width: 0;\n height: 100%;\n}\n\n.native-sliding-container-inner {\n height: 100%;\n position: absolute;\n}\n\n.sliding-container-sheet-handle-area {\n display: none;\n}\n\n:host(.bottom-sheet) {\n inset: 0;\n pointer-events: none;\n z-index: var(--wje-sliding-container-bottom-sheet-z-index, var(--wje-sliding-container-z-index, 1000));\n}\n\n:host(.bottom-sheet.open) {\n overscroll-behavior: contain;\n}\n\n:host(.bottom-sheet) .sliding-container-backdrop {\n display: none;\n position: fixed;\n inset: 0;\n z-index: var(--wje-sliding-container-bottom-sheet-backdrop-z-index, 0);\n opacity: 0;\n pointer-events: none;\n touch-action: none;\n overscroll-behavior: none;\n background: var(--wje-sliding-container-backdrop-background, var(--wje-backdrop, rgba(0, 0, 0, .35)));\n}\n\n:host(.bottom-sheet.open) .sliding-container-backdrop {\n pointer-events: auto;\n}\n\n:host(.bottom-sheet) .sliding-container-wrapper {\n position: fixed;\n inset: 0;\n overflow: visible;\n pointer-events: none;\n z-index: var(--wje-sliding-container-bottom-sheet-panel-z-index, 1);\n}\n\n:host(.bottom-sheet) .sliding-container-transparent {\n display: none;\n}\n\n:host(.bottom-sheet) .native-sliding-container {\n position: fixed;\n top: auto;\n height: fit-content;\n overflow: hidden;\n pointer-events: auto;\n display: flex;\n flex-direction: column;\n overscroll-behavior: contain;\n background: var(--wje-sliding-container-background);\n box-shadow: var(--wje-sliding-container-box-shadow, var(--wje-sliding-container-shadow));\n border-radius: var(--wje-sliding-container-sheet-border-radius, var(--wje-sliding-container-border-radius) var(--wje-sliding-container-border-radius) 0 0);\n}\n\n:host(.bottom-sheet) .native-sliding-container-inner {\n position: relative;\n flex: 1 1 auto;\n min-height: 0;\n height: auto;\n max-height: inherit;\n overflow: auto;\n overscroll-behavior: contain;\n}\n\n:host(.bottom-sheet) .sliding-container-sheet-handle-area {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 var(--wje-sliding-container-sheet-handle-area-height, 24px);\n height: var(--wje-sliding-container-sheet-handle-area-height, 24px);\n cursor: grab;\n pointer-events: auto;\n touch-action: none;\n user-select: none;\n -webkit-user-select: none;\n}\n\n:host(.bottom-sheet) .sliding-container-sheet-handle-area:active {\n cursor: grabbing;\n}\n\n:host(.bottom-sheet) .sliding-container-sheet-handle {\n width: var(--wje-sliding-container-sheet-handle-width, 36px);\n height: var(--wje-sliding-container-sheet-handle-height, 2px);\n background: var(--wje-sliding-container-sheet-handle-background, var(--wje-border-color));\n border-radius: var(--wje-sliding-container-sheet-handle-radius, 999px);\n}\n";
9
7
  class SlidingContainer extends WJElement {
10
8
  /**
11
9
  * Creates an instance of SlidingContainer.
@@ -14,6 +12,20 @@ class SlidingContainer extends WJElement {
14
12
  constructor() {
15
13
  super();
16
14
  __publicField(this, "className", "SlidingContainer");
15
+ /**
16
+ * Handles backdrop click dismissal.
17
+ * @param {MouseEvent} e The click event.
18
+ */
19
+ __publicField(this, "handleBackdropClick", (e) => {
20
+ if (this.isEventInsideSheet(e) || Date.now() < this._sheetIgnoreDismissUntil || Date.now() < this._sheetBackdropHandledUntil) {
21
+ e.preventDefault();
22
+ e.stopPropagation();
23
+ return;
24
+ }
25
+ if (this.isBackdropElement(e.target)) {
26
+ this.close(e);
27
+ }
28
+ });
17
29
  /**
18
30
  * Stops a handle interaction from dismissing the bottom sheet.
19
31
  * @param {Event} e The interaction emitted by the resize handle.
@@ -79,7 +91,7 @@ class SlidingContainer extends WJElement {
79
91
  * @param {PointerEvent} e The pointer event.
80
92
  */
81
93
  __publicField(this, "handleBackdropPointerStart", (e) => {
82
- if (!this.isBottomSheet() || e.target !== this.backdropElement || this.isEventInsideSheet(e) || Date.now() < this._sheetIgnoreDismissUntil) {
94
+ if (!this.isBottomSheet() || !this.isBackdropElement(e.target) || this.isEventInsideSheet(e) || Date.now() < this._sheetIgnoreDismissUntil) {
83
95
  this._sheetBackdropGesture = null;
84
96
  return;
85
97
  }
@@ -108,7 +120,7 @@ class SlidingContainer extends WJElement {
108
120
  */
109
121
  __publicField(this, "handleBackdropPointerEnd", (e) => {
110
122
  if (!this._sheetBackdropGesture || e.pointerId !== this._sheetBackdropGesture.pointerId) return;
111
- const shouldClose = !this._sheetBackdropGesture.hasMoved && e.target === this.backdropElement && !this.isEventInsideSheet(e) && Date.now() >= this._sheetIgnoreDismissUntil;
123
+ const shouldClose = !this._sheetBackdropGesture.hasMoved && this.isBackdropElement(e.target) && !this.isEventInsideSheet(e) && Date.now() >= this._sheetIgnoreDismissUntil;
112
124
  this._sheetBackdropGesture = null;
113
125
  this._sheetBackdropHandledUntil = Date.now() + 350;
114
126
  if (shouldClose) {
@@ -211,7 +223,6 @@ class SlidingContainer extends WJElement {
211
223
  this._sheetIgnoreDismissUntil = 0;
212
224
  this._sheetBackdropGesture = null;
213
225
  this._sheetBackdropHandledUntil = 0;
214
- this._hasLockedDocumentScroll = false;
215
226
  this._bottomSheetScopeFrame = null;
216
227
  this._resizeObserver = new ResizeObserver((entries) => {
217
228
  for (let entry of entries) {
@@ -429,28 +440,28 @@ class SlidingContainer extends WJElement {
429
440
  this.setAttribute("sheet-resizable", value);
430
441
  }
431
442
  /**
432
- * Gets the mobile bottom sheet scope.
443
+ * Gets the mobile bottom sheet panel scope. The backdrop always covers the viewport.
433
444
  * @returns {string} Either 'viewport', 'container', or 'parent'.
434
445
  */
435
446
  get sheetScope() {
436
447
  return this.getAttribute("sheet-scope") || "viewport";
437
448
  }
438
449
  /**
439
- * Sets the mobile bottom sheet scope.
450
+ * Sets the mobile bottom sheet panel scope.
440
451
  * @param {string} value The new boundary mode for the mobile sheet.
441
452
  */
442
453
  set sheetScope(value) {
443
454
  this.setAttribute("sheet-scope", value);
444
455
  }
445
456
  /**
446
- * Gets the selector used for container-scoped mobile bottom sheets.
457
+ * Gets the selector used for container-scoped mobile bottom sheet panels.
447
458
  * @returns {string|null} A CSS selector used to find the composed boundary ancestor.
448
459
  */
449
460
  get sheetBoundary() {
450
461
  return this.getAttribute("sheet-boundary");
451
462
  }
452
463
  /**
453
- * Sets the selector used for container-scoped mobile bottom sheets.
464
+ * Sets the selector used for container-scoped mobile bottom sheet panels.
454
465
  * @param {string} value Selector for the boundary element.
455
466
  */
456
467
  set sheetBoundary(value) {
@@ -551,6 +562,19 @@ class SlidingContainer extends WJElement {
551
562
  (_a = this.animation) == null ? void 0 : _a.cancel();
552
563
  (_b = this.nativeAnimation) == null ? void 0 : _b.cancel();
553
564
  this.endSheetDrag();
565
+ this.removePortalBackdrop();
566
+ document.removeEventListener(this.trigger, this.triggerEvent);
567
+ }
568
+ /**
569
+ * Cleans up global listeners and portaled layers.
570
+ */
571
+ afterDisconnect() {
572
+ var _a, _b, _c;
573
+ (_a = this.animation) == null ? void 0 : _a.cancel();
574
+ (_b = this.nativeAnimation) == null ? void 0 : _b.cancel();
575
+ this.endSheetDrag();
576
+ this.removePortalBackdrop();
577
+ (_c = this._resizeObserver) == null ? void 0 : _c.disconnect();
554
578
  document.removeEventListener(this.trigger, this.triggerEvent);
555
579
  }
556
580
  /**
@@ -569,24 +593,7 @@ class SlidingContainer extends WJElement {
569
593
  if (this._isOpen && isBottomSheet) {
570
594
  backdrop.style.opacity = "var(--wje-sliding-container-backdrop-opacity, 1)";
571
595
  }
572
- backdrop.addEventListener("wheel", this.preventBottomSheetScroll, { passive: false });
573
- backdrop.addEventListener("touchmove", this.preventBottomSheetScroll, { passive: false });
574
- if (this.backdropDismiss) {
575
- backdrop.addEventListener("pointerdown", this.handleBackdropPointerStart);
576
- backdrop.addEventListener("pointermove", this.handleBackdropPointerMove);
577
- backdrop.addEventListener("pointerup", this.handleBackdropPointerEnd);
578
- backdrop.addEventListener("pointercancel", this.handleBackdropPointerCancel);
579
- backdrop.addEventListener("click", (e) => {
580
- if (this.isEventInsideSheet(e) || Date.now() < this._sheetIgnoreDismissUntil || Date.now() < this._sheetBackdropHandledUntil) {
581
- e.preventDefault();
582
- e.stopPropagation();
583
- return;
584
- }
585
- if (e.target === backdrop) {
586
- this.close(e);
587
- }
588
- });
589
- }
596
+ this.addBackdropListeners(backdrop);
590
597
  let wrapperDiv = document.createElement("div");
591
598
  wrapperDiv.classList.add("sliding-container-wrapper");
592
599
  let transparentDiv = document.createElement("div");
@@ -668,6 +675,111 @@ class SlidingContainer extends WJElement {
668
675
  isBottomSheet() {
669
676
  return this.mobilePresentation === "bottom-sheet" && window.innerWidth <= +this.mobileBreakPoint;
670
677
  }
678
+ /**
679
+ * Adds interaction listeners to a backdrop element.
680
+ * @param {HTMLElement} backdrop The backdrop element.
681
+ */
682
+ addBackdropListeners(backdrop) {
683
+ backdrop.addEventListener("wheel", this.preventBottomSheetScroll, { passive: false });
684
+ backdrop.addEventListener("touchmove", this.preventBottomSheetScroll, { passive: false });
685
+ if (!this.backdropDismiss) return;
686
+ backdrop.addEventListener("pointerdown", this.handleBackdropPointerStart);
687
+ backdrop.addEventListener("pointermove", this.handleBackdropPointerMove);
688
+ backdrop.addEventListener("pointerup", this.handleBackdropPointerEnd);
689
+ backdrop.addEventListener("pointercancel", this.handleBackdropPointerCancel);
690
+ backdrop.addEventListener("click", this.handleBackdropClick);
691
+ }
692
+ /**
693
+ * Removes interaction listeners from a backdrop element.
694
+ * @param {HTMLElement} backdrop The backdrop element.
695
+ */
696
+ removeBackdropListeners(backdrop) {
697
+ backdrop.removeEventListener("wheel", this.preventBottomSheetScroll);
698
+ backdrop.removeEventListener("touchmove", this.preventBottomSheetScroll);
699
+ backdrop.removeEventListener("pointerdown", this.handleBackdropPointerStart);
700
+ backdrop.removeEventListener("pointermove", this.handleBackdropPointerMove);
701
+ backdrop.removeEventListener("pointerup", this.handleBackdropPointerEnd);
702
+ backdrop.removeEventListener("pointercancel", this.handleBackdropPointerCancel);
703
+ backdrop.removeEventListener("click", this.handleBackdropClick);
704
+ }
705
+ /**
706
+ * Checks whether an element is one of this component's backdrop layers.
707
+ * @param {EventTarget|null} element The event target.
708
+ * @returns {boolean}
709
+ */
710
+ isBackdropElement(element) {
711
+ return element === this.backdropElement || element === this._portalBackdropElement;
712
+ }
713
+ /**
714
+ * Gets the backdrop element that is active for the current presentation.
715
+ * @param {object} options Options for resolving the backdrop.
716
+ * @param {boolean} options.createPortal Creates the body-level mobile backdrop when needed.
717
+ * @returns {HTMLElement|null}
718
+ */
719
+ getBackdropElement({ createPortal = false } = {}) {
720
+ if (!this.isBottomSheet()) return this.backdropElement;
721
+ if (createPortal) return this.ensurePortalBackdrop();
722
+ return this._portalBackdropElement || this.backdropElement;
723
+ }
724
+ /**
725
+ * Creates the body-level backdrop used by mobile bottom sheets.
726
+ * @returns {HTMLElement} Element appended to document.body for page-level dimming.
727
+ */
728
+ ensurePortalBackdrop() {
729
+ if (!this._portalBackdropElement) {
730
+ this._portalBackdropElement = document.createElement("div");
731
+ this._portalBackdropElement.setAttribute("data-wje-sliding-container-backdrop", "");
732
+ this._portalBackdropElement.classList.add("sliding-container-backdrop", "sliding-container-backdrop-portal");
733
+ this.addBackdropListeners(this._portalBackdropElement);
734
+ document.body.append(this._portalBackdropElement);
735
+ }
736
+ this.syncPortalBackdropStyles();
737
+ return this._portalBackdropElement;
738
+ }
739
+ /**
740
+ * Removes the body-level mobile backdrop.
741
+ */
742
+ removePortalBackdrop() {
743
+ if (!this._portalBackdropElement) return;
744
+ this.removeBackdropListeners(this._portalBackdropElement);
745
+ this._portalBackdropElement.remove();
746
+ this._portalBackdropElement = null;
747
+ }
748
+ /**
749
+ * Gets the full-page z-index for the body-level mobile backdrop.
750
+ * @returns {string}
751
+ */
752
+ getPortalBackdropZIndex() {
753
+ const hostStyle = getComputedStyle(this);
754
+ const configuredZIndex = hostStyle.getPropertyValue("--wje-sliding-container-portal-backdrop-z-index").trim();
755
+ if (configuredZIndex) return configuredZIndex;
756
+ const hostZIndex = Number.parseInt(hostStyle.zIndex, 10);
757
+ if (Number.isFinite(hostZIndex)) return String(hostZIndex - 1);
758
+ return "999";
759
+ }
760
+ /**
761
+ * Gets the target opacity for the active mobile backdrop.
762
+ * @returns {string}
763
+ */
764
+ getBackdropOpenOpacity() {
765
+ return getComputedStyle(this).getPropertyValue("--wje-sliding-container-backdrop-opacity").trim() || "1";
766
+ }
767
+ /**
768
+ * Syncs visual styles from the component to the body-level backdrop.
769
+ */
770
+ syncPortalBackdropStyles() {
771
+ if (!this._portalBackdropElement) return;
772
+ const backdropStyle = this.backdropElement ? getComputedStyle(this.backdropElement) : null;
773
+ this._portalBackdropElement.style.position = "fixed";
774
+ this._portalBackdropElement.style.inset = "0";
775
+ this._portalBackdropElement.style.display = "block";
776
+ this._portalBackdropElement.style.opacity = this.classList.contains("open") ? this.getBackdropOpenOpacity() : "0";
777
+ this._portalBackdropElement.style.pointerEvents = this.classList.contains("open") ? "auto" : "none";
778
+ this._portalBackdropElement.style.touchAction = "none";
779
+ this._portalBackdropElement.style.overscrollBehavior = "none";
780
+ this._portalBackdropElement.style.background = (backdropStyle == null ? void 0 : backdropStyle.background) || "rgba(0, 0, 0, .35)";
781
+ this._portalBackdropElement.style.zIndex = this.getPortalBackdropZIndex();
782
+ }
671
783
  /**
672
784
  * Sync ARIA attributes on host.
673
785
  */
@@ -776,7 +888,7 @@ class SlidingContainer extends WJElement {
776
888
  };
777
889
  }
778
890
  /**
779
- * Returns the element that bounds the mobile bottom sheet.
891
+ * Returns the element that bounds the mobile bottom sheet panel.
780
892
  * @returns {Element|null} The scope element, or null for viewport scope.
781
893
  */
782
894
  getBottomSheetScopeElement() {
@@ -786,7 +898,7 @@ class SlidingContainer extends WJElement {
786
898
  return this.getParentElement();
787
899
  }
788
900
  /**
789
- * Returns the frame used by the mobile bottom sheet.
901
+ * Returns the frame used by the mobile bottom sheet panel.
790
902
  * @returns {{top: number, left: number, right: number, bottom: number, width: number, height: number}}
791
903
  */
792
904
  getBottomSheetScopeFrame() {
@@ -883,12 +995,17 @@ class SlidingContainer extends WJElement {
883
995
  */
884
996
  setBottomSheetVariant() {
885
997
  const scopeFrame = this.getBottomSheetScopeFrame();
998
+ const backdropFrame = this.getViewportFrame();
999
+ const backdrop = this.getBackdropElement({
1000
+ createPortal: this.classList.contains("open") || this._isOpen
1001
+ });
886
1002
  this._bottomSheetScopeFrame = scopeFrame;
887
1003
  this.classList.add("bottom-sheet");
888
1004
  this.style.position = "fixed";
889
1005
  this.setBottomSheetLayerFrame(this, scopeFrame);
890
- this.setBottomSheetLayerFrame(this.backdropElement, scopeFrame);
1006
+ this.setBottomSheetLayerFrame(backdrop, backdropFrame);
891
1007
  this.setBottomSheetLayerFrame(this.wrapperDiv, scopeFrame);
1008
+ this.syncPortalBackdropStyles();
892
1009
  this.wrapperDiv.style.height = "100%";
893
1010
  this.transparentDiv.style.width = 0;
894
1011
  this.nativeElement.style.left = scopeFrame.left + "px";
@@ -915,6 +1032,7 @@ class SlidingContainer extends WJElement {
915
1032
  this.style.removeProperty("position");
916
1033
  this.resetBottomSheetLayerFrame(this);
917
1034
  this.resetBottomSheetLayerFrame(this.backdropElement);
1035
+ this.removePortalBackdrop();
918
1036
  this.resetBottomSheetLayerFrame(this.wrapperDiv);
919
1037
  if (this.transparentDiv) {
920
1038
  this.transparentDiv.style.width = this._isOpen ? this.maxWidth : 0;
@@ -941,7 +1059,6 @@ class SlidingContainer extends WJElement {
941
1059
  (_i = this.backdropElement) == null ? void 0 : _i.style.removeProperty("opacity");
942
1060
  this._bottomSheetScopeFrame = null;
943
1061
  this.endSheetDrag();
944
- this.unlockDocumentScroll();
945
1062
  }
946
1063
  /**
947
1064
  * Applies the current visual open or closed state to the mobile bottom sheet.
@@ -949,10 +1066,17 @@ class SlidingContainer extends WJElement {
949
1066
  */
950
1067
  setBottomSheetVisualState(isOpen) {
951
1068
  this.nativeElement.style.transform = isOpen ? "translateY(0)" : "translateY(100%)";
1069
+ const backdrop = this.getBackdropElement({ createPortal: isOpen || Boolean(this._portalBackdropElement) });
952
1070
  if (this.hasOpacity) {
953
1071
  this.nativeElement.style.opacity = isOpen ? 1 : 0;
954
1072
  }
955
- this.backdropElement.style.opacity = isOpen ? "var(--wje-sliding-container-backdrop-opacity, 1)" : 0;
1073
+ if (backdrop) {
1074
+ backdrop.style.opacity = isOpen ? this.getBackdropOpenOpacity() : "0";
1075
+ backdrop.style.pointerEvents = isOpen ? "auto" : "none";
1076
+ }
1077
+ if (!isOpen) {
1078
+ this.removePortalBackdrop();
1079
+ }
956
1080
  }
957
1081
  /**
958
1082
  * Gets the CSS height limit used for the mobile bottom sheet.
@@ -1053,58 +1177,6 @@ class SlidingContainer extends WJElement {
1053
1177
  const rect = this.nativeElement.getBoundingClientRect();
1054
1178
  return e.clientX >= rect.left && e.clientX <= rect.right && e.clientY >= rect.top && e.clientY <= rect.bottom;
1055
1179
  }
1056
- /**
1057
- * Prevents the page behind the mobile bottom sheet from scrolling.
1058
- */
1059
- lockDocumentScroll() {
1060
- if (!this.isBottomSheet() || this.sheetScope !== "viewport" || this._hasLockedDocumentScroll) return;
1061
- if (documentScrollLocks === 0) {
1062
- documentScrollState = {
1063
- bodyOverflow: document.body.style.overflow,
1064
- documentOverflow: document.documentElement.style.overflow,
1065
- bodyOverscrollBehavior: document.body.style.overscrollBehavior,
1066
- documentOverscrollBehavior: document.documentElement.style.overscrollBehavior,
1067
- bodyPosition: document.body.style.position,
1068
- bodyTop: document.body.style.top,
1069
- bodyLeft: document.body.style.left,
1070
- bodyRight: document.body.style.right,
1071
- bodyWidth: document.body.style.width,
1072
- scrollX: window.scrollX,
1073
- scrollY: window.scrollY
1074
- };
1075
- document.body.style.overflow = "hidden";
1076
- document.documentElement.style.overflow = "hidden";
1077
- document.body.style.overscrollBehavior = "none";
1078
- document.documentElement.style.overscrollBehavior = "none";
1079
- document.body.style.position = "fixed";
1080
- document.body.style.top = `-${documentScrollState.scrollY}px`;
1081
- document.body.style.left = `-${documentScrollState.scrollX}px`;
1082
- document.body.style.right = "0";
1083
- document.body.style.width = "100%";
1084
- }
1085
- documentScrollLocks++;
1086
- this._hasLockedDocumentScroll = true;
1087
- }
1088
- /**
1089
- * Restores page scrolling after the mobile bottom sheet is closed.
1090
- */
1091
- unlockDocumentScroll() {
1092
- if (!this._hasLockedDocumentScroll) return;
1093
- documentScrollLocks = Math.max(documentScrollLocks - 1, 0);
1094
- this._hasLockedDocumentScroll = false;
1095
- if (documentScrollLocks > 0 || !documentScrollState) return;
1096
- document.body.style.overflow = documentScrollState.bodyOverflow;
1097
- document.documentElement.style.overflow = documentScrollState.documentOverflow;
1098
- document.body.style.overscrollBehavior = documentScrollState.bodyOverscrollBehavior;
1099
- document.documentElement.style.overscrollBehavior = documentScrollState.documentOverscrollBehavior;
1100
- document.body.style.position = documentScrollState.bodyPosition;
1101
- document.body.style.top = documentScrollState.bodyTop;
1102
- document.body.style.left = documentScrollState.bodyLeft;
1103
- document.body.style.right = documentScrollState.bodyRight;
1104
- document.body.style.width = documentScrollState.bodyWidth;
1105
- window.scrollTo(documentScrollState.scrollX, documentScrollState.scrollY);
1106
- documentScrollState = null;
1107
- }
1108
1180
  /**
1109
1181
  * Stores the initial drag state for the mobile bottom sheet.
1110
1182
  * @param {number|string} pointerId The pointer identifier.
@@ -1286,11 +1358,12 @@ class SlidingContainer extends WJElement {
1286
1358
  doAnimateBottomSheetTransition(options) {
1287
1359
  var _a, _b, _c, _d;
1288
1360
  const shouldOpen = !this._isOpen;
1361
+ const backdropElement = this.getBackdropElement({ createPortal: true });
1289
1362
  const closedBackdrop = {
1290
1363
  opacity: 0
1291
1364
  };
1292
1365
  const openBackdrop = {
1293
- opacity: "var(--wje-sliding-container-backdrop-opacity, 1)"
1366
+ opacity: this.getBackdropOpenOpacity()
1294
1367
  };
1295
1368
  const closedSheet = {
1296
1369
  ...this.hasOpacity ? { opacity: 0 } : {},
@@ -1300,7 +1373,7 @@ class SlidingContainer extends WJElement {
1300
1373
  ...this.hasOpacity ? { opacity: 1 } : {},
1301
1374
  transform: "translateY(0)"
1302
1375
  };
1303
- if (this.animation && ((_b = (_a = this.animation) == null ? void 0 : _a.effect) == null ? void 0 : _b.target) !== this.backdropElement) {
1376
+ if (this.animation && ((_b = (_a = this.animation) == null ? void 0 : _a.effect) == null ? void 0 : _b.target) !== backdropElement) {
1304
1377
  this.animation.cancel();
1305
1378
  this.animation = null;
1306
1379
  }
@@ -1313,7 +1386,7 @@ class SlidingContainer extends WJElement {
1313
1386
  this.animation.reverse();
1314
1387
  this.nativeAnimation.reverse();
1315
1388
  } else {
1316
- this.animation = this.backdropElement.animate([closedBackdrop, openBackdrop], options);
1389
+ this.animation = backdropElement.animate([closedBackdrop, openBackdrop], options);
1317
1390
  this.nativeAnimation = this.nativeElement.animate([closedSheet, openSheet], options);
1318
1391
  }
1319
1392
  } else {
@@ -1321,7 +1394,7 @@ class SlidingContainer extends WJElement {
1321
1394
  this.animation.reverse();
1322
1395
  this.nativeAnimation.reverse();
1323
1396
  } else {
1324
- this.animation = this.backdropElement.animate([openBackdrop, closedBackdrop], options);
1397
+ this.animation = backdropElement.animate([openBackdrop, closedBackdrop], options);
1325
1398
  this.nativeAnimation = this.nativeElement.animate([openSheet, closedSheet], options);
1326
1399
  }
1327
1400
  }
@@ -1350,7 +1423,6 @@ class SlidingContainer extends WJElement {
1350
1423
  this.classList.add("open");
1351
1424
  event.dispatchCustomEvent(this, "wje-sliding-container:beforeOpen");
1352
1425
  this.checkForVariant(this.variant);
1353
- this.lockDocumentScroll();
1354
1426
  await this.doAnimateTransition();
1355
1427
  this.syncAria();
1356
1428
  await Promise.resolve(this.afterOpen(e)).then(() => {
@@ -1365,7 +1437,7 @@ class SlidingContainer extends WJElement {
1365
1437
  * @returns {Promise<void>} A promise that resolves when the closing operation, including animations and child element removal, is completed.
1366
1438
  */
1367
1439
  async close(e) {
1368
- if (this.isBottomSheet() && e instanceof Event && (this.isSheetHandleEvent(e) || e.target === this.backdropElement && Date.now() < this._sheetIgnoreDismissUntil)) {
1440
+ if (this.isBottomSheet() && e instanceof Event && (this.isSheetHandleEvent(e) || this.isBackdropElement(e.target) && Date.now() < this._sheetIgnoreDismissUntil)) {
1369
1441
  return;
1370
1442
  }
1371
1443
  await Promise.resolve(this.beforeClose(e)).then(async () => {
@@ -1378,7 +1450,6 @@ class SlidingContainer extends WJElement {
1378
1450
  }
1379
1451
  });
1380
1452
  this.syncAria();
1381
- this.unlockDocumentScroll();
1382
1453
  await Promise.resolve(this.afterClose(e)).then(() => {
1383
1454
  if (this.removeChildAfterClose) {
1384
1455
  this.childNodes.forEach((child) => {
@@ -1418,7 +1489,7 @@ class SlidingContainer extends WJElement {
1418
1489
  componentCleanup() {
1419
1490
  var _a;
1420
1491
  this.endSheetDrag();
1421
- this.unlockDocumentScroll();
1492
+ this.removePortalBackdrop();
1422
1493
  (_a = this._resizeObserver) == null ? void 0 : _a.disconnect();
1423
1494
  this._resizeObserver = null;
1424
1495
  }