@adobe/spectrum-wc-core 0.0.0-snapshot.20260922095923
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/README.md +39 -0
- package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js +9 -0
- package/dist/components/accordion/Accordion.base.d.ts +59 -0
- package/dist/components/accordion/Accordion.base.js +69 -0
- package/dist/components/accordion/Accordion.base.js.map +1 -0
- package/dist/components/accordion/Accordion.types.d.ts +22 -0
- package/dist/components/accordion/Accordion.types.js +21 -0
- package/dist/components/accordion/Accordion.types.js.map +1 -0
- package/dist/components/accordion/AccordionItem.base.d.ts +96 -0
- package/dist/components/accordion/AccordionItem.base.js +93 -0
- package/dist/components/accordion/AccordionItem.base.js.map +1 -0
- package/dist/components/accordion/index.d.ts +14 -0
- package/dist/components/accordion/index.js +4 -0
- package/dist/components/action-button/ActionButton.types.d.ts +15 -0
- package/dist/components/action-button/ActionButton.types.js +12 -0
- package/dist/components/action-button/ActionButton.types.js.map +1 -0
- package/dist/components/action-button/index.d.ts +12 -0
- package/dist/components/action-button/index.js +2 -0
- package/dist/components/action-group/ActionGroup.base.d.ts +108 -0
- package/dist/components/action-group/ActionGroup.base.js +53 -0
- package/dist/components/action-group/ActionGroup.base.js.map +1 -0
- package/dist/components/action-group/ActionGroup.types.d.ts +17 -0
- package/dist/components/action-group/ActionGroup.types.js +12 -0
- package/dist/components/action-group/ActionGroup.types.js.map +1 -0
- package/dist/components/action-group/index.d.ts +13 -0
- package/dist/components/action-group/index.js +3 -0
- package/dist/components/alert-banner/AlertBanner.base.d.ts +36 -0
- package/dist/components/alert-banner/AlertBanner.base.js +57 -0
- package/dist/components/alert-banner/AlertBanner.base.js.map +1 -0
- package/dist/components/alert-banner/AlertBanner.types.d.ts +13 -0
- package/dist/components/alert-banner/AlertBanner.types.js +10 -0
- package/dist/components/alert-banner/AlertBanner.types.js.map +1 -0
- package/dist/components/alert-banner/index.d.ts +13 -0
- package/dist/components/alert-banner/index.js +3 -0
- package/dist/components/asset/Asset.base.d.ts +101 -0
- package/dist/components/asset/Asset.base.js +130 -0
- package/dist/components/asset/Asset.base.js.map +1 -0
- package/dist/components/asset/Asset.types.d.ts +31 -0
- package/dist/components/asset/Asset.types.js +14 -0
- package/dist/components/asset/Asset.types.js.map +1 -0
- package/dist/components/asset/index.d.ts +13 -0
- package/dist/components/asset/index.js +3 -0
- package/dist/components/avatar/Avatar.base.d.ts +53 -0
- package/dist/components/avatar/Avatar.base.js +52 -0
- package/dist/components/avatar/Avatar.base.js.map +1 -0
- package/dist/components/avatar/Avatar.types.d.ts +19 -0
- package/dist/components/avatar/Avatar.types.js +24 -0
- package/dist/components/avatar/Avatar.types.js.map +1 -0
- package/dist/components/avatar/index.d.ts +13 -0
- package/dist/components/avatar/index.js +3 -0
- package/dist/components/badge/Badge.base.d.ts +114 -0
- package/dist/components/badge/Badge.base.js +49 -0
- package/dist/components/badge/Badge.base.js.map +1 -0
- package/dist/components/badge/Badge.types.d.ts +21 -0
- package/dist/components/badge/Badge.types.js +43 -0
- package/dist/components/badge/Badge.types.js.map +1 -0
- package/dist/components/badge/index.d.ts +13 -0
- package/dist/components/badge/index.js +3 -0
- package/dist/components/button/Button.base.d.ts +78 -0
- package/dist/components/button/Button.base.js +51 -0
- package/dist/components/button/Button.base.js.map +1 -0
- package/dist/components/button/Button.types.d.ts +19 -0
- package/dist/components/button/Button.types.js +16 -0
- package/dist/components/button/Button.types.js.map +1 -0
- package/dist/components/button/index.d.ts +13 -0
- package/dist/components/button/index.js +3 -0
- package/dist/components/button-group/ButtonGroup.base.d.ts +89 -0
- package/dist/components/button-group/ButtonGroup.base.js +60 -0
- package/dist/components/button-group/ButtonGroup.base.js.map +1 -0
- package/dist/components/button-group/ButtonGroup.types.d.ts +17 -0
- package/dist/components/button-group/ButtonGroup.types.js +15 -0
- package/dist/components/button-group/ButtonGroup.types.js.map +1 -0
- package/dist/components/button-group/index.d.ts +13 -0
- package/dist/components/button-group/index.js +3 -0
- package/dist/components/card/Card.base.d.ts +172 -0
- package/dist/components/card/Card.base.js +123 -0
- package/dist/components/card/Card.base.js.map +1 -0
- package/dist/components/card/Card.types.d.ts +18 -0
- package/dist/components/card/Card.types.js +21 -0
- package/dist/components/card/Card.types.js.map +1 -0
- package/dist/components/card/index.d.ts +13 -0
- package/dist/components/card/index.js +3 -0
- package/dist/components/color-handle/ColorHandle.base.d.ts +51 -0
- package/dist/components/color-handle/ColorHandle.base.js +39 -0
- package/dist/components/color-handle/ColorHandle.base.js.map +1 -0
- package/dist/components/color-handle/ColorHandle.types.d.ts +30 -0
- package/dist/components/color-handle/color-contrast.d.ts +55 -0
- package/dist/components/color-handle/color-contrast.js +49 -0
- package/dist/components/color-handle/color-contrast.js.map +1 -0
- package/dist/components/color-handle/index.d.ts +14 -0
- package/dist/components/color-handle/index.js +3 -0
- package/dist/components/color-loupe/ColorLoupe.base.d.ts +41 -0
- package/dist/components/color-loupe/ColorLoupe.base.js +21 -0
- package/dist/components/color-loupe/ColorLoupe.base.js.map +1 -0
- package/dist/components/color-loupe/index.d.ts +12 -0
- package/dist/components/color-loupe/index.js +2 -0
- package/dist/components/divider/Divider.base.d.ts +43 -0
- package/dist/components/divider/Divider.base.js +42 -0
- package/dist/components/divider/Divider.base.js.map +1 -0
- package/dist/components/divider/Divider.types.d.ts +15 -0
- package/dist/components/divider/Divider.types.js +10 -0
- package/dist/components/divider/Divider.types.js.map +1 -0
- package/dist/components/divider/index.d.ts +13 -0
- package/dist/components/divider/index.js +3 -0
- package/dist/components/dropzone/Dropzone.base.d.ts +74 -0
- package/dist/components/dropzone/Dropzone.base.js +82 -0
- package/dist/components/dropzone/Dropzone.base.js.map +1 -0
- package/dist/components/dropzone/Dropzone.types.d.ts +43 -0
- package/dist/components/dropzone/Dropzone.types.js +15 -0
- package/dist/components/dropzone/Dropzone.types.js.map +1 -0
- package/dist/components/dropzone/index.d.ts +13 -0
- package/dist/components/dropzone/index.js +3 -0
- package/dist/components/icon/Icon.base.d.ts +36 -0
- package/dist/components/icon/Icon.base.js +28 -0
- package/dist/components/icon/Icon.base.js.map +1 -0
- package/dist/components/icon/Icon.types.d.ts +13 -0
- package/dist/components/icon/Icon.types.js +12 -0
- package/dist/components/icon/Icon.types.js.map +1 -0
- package/dist/components/icon/index.d.ts +13 -0
- package/dist/components/icon/index.js +3 -0
- package/dist/components/illustrated-message/IllustratedMessage.base.d.ts +60 -0
- package/dist/components/illustrated-message/IllustratedMessage.base.js +59 -0
- package/dist/components/illustrated-message/IllustratedMessage.base.js.map +1 -0
- package/dist/components/illustrated-message/IllustratedMessage.types.d.ts +15 -0
- package/dist/components/illustrated-message/IllustratedMessage.types.js +10 -0
- package/dist/components/illustrated-message/IllustratedMessage.types.js.map +1 -0
- package/dist/components/illustrated-message/index.d.ts +13 -0
- package/dist/components/illustrated-message/index.js +3 -0
- package/dist/components/infield-button/InfieldButton.base.d.ts +28 -0
- package/dist/components/infield-button/InfieldButton.base.js +22 -0
- package/dist/components/infield-button/InfieldButton.base.js.map +1 -0
- package/dist/components/infield-button/InfieldButton.types.d.ts +13 -0
- package/dist/components/infield-button/InfieldButton.types.js +11 -0
- package/dist/components/infield-button/InfieldButton.types.js.map +1 -0
- package/dist/components/infield-button/index.d.ts +13 -0
- package/dist/components/infield-button/index.js +3 -0
- package/dist/components/meter/Meter.base.d.ts +40 -0
- package/dist/components/meter/Meter.base.js +32 -0
- package/dist/components/meter/Meter.base.js.map +1 -0
- package/dist/components/meter/Meter.types.d.ts +13 -0
- package/dist/components/meter/Meter.types.js +11 -0
- package/dist/components/meter/Meter.types.js.map +1 -0
- package/dist/components/meter/index.d.ts +13 -0
- package/dist/components/meter/index.js +3 -0
- package/dist/components/popover/Popover.base.d.ts +226 -0
- package/dist/components/popover/Popover.base.js +287 -0
- package/dist/components/popover/Popover.base.js.map +1 -0
- package/dist/components/popover/Popover.types.d.ts +39 -0
- package/dist/components/popover/Popover.types.js +24 -0
- package/dist/components/popover/Popover.types.js.map +1 -0
- package/dist/components/popover/index.d.ts +13 -0
- package/dist/components/popover/index.js +3 -0
- package/dist/components/progress-bar/ProgressBar.base.d.ts +34 -0
- package/dist/components/progress-bar/ProgressBar.base.js +21 -0
- package/dist/components/progress-bar/ProgressBar.base.js.map +1 -0
- package/dist/components/progress-bar/ProgressBar.types.d.ts +12 -0
- package/dist/components/progress-bar/index.d.ts +13 -0
- package/dist/components/progress-bar/index.js +2 -0
- package/dist/components/progress-circle/ProgressCircle.base.d.ts +83 -0
- package/dist/components/progress-circle/ProgressCircle.base.js +77 -0
- package/dist/components/progress-circle/ProgressCircle.base.js.map +1 -0
- package/dist/components/progress-circle/ProgressCircle.types.d.ts +15 -0
- package/dist/components/progress-circle/ProgressCircle.types.js +10 -0
- package/dist/components/progress-circle/ProgressCircle.types.js.map +1 -0
- package/dist/components/progress-circle/index.d.ts +13 -0
- package/dist/components/progress-circle/index.js +3 -0
- package/dist/components/status-light/StatusLight.base.d.ts +69 -0
- package/dist/components/status-light/StatusLight.base.js +32 -0
- package/dist/components/status-light/StatusLight.base.js.map +1 -0
- package/dist/components/status-light/StatusLight.types.d.ts +19 -0
- package/dist/components/status-light/StatusLight.types.js +32 -0
- package/dist/components/status-light/StatusLight.types.js.map +1 -0
- package/dist/components/status-light/index.d.ts +13 -0
- package/dist/components/status-light/index.js +3 -0
- package/dist/components/tabs/Tab.base.d.ts +49 -0
- package/dist/components/tabs/Tab.base.js +39 -0
- package/dist/components/tabs/Tab.base.js.map +1 -0
- package/dist/components/tabs/Tab.types.d.ts +17 -0
- package/dist/components/tabs/TabPanel.base.d.ts +49 -0
- package/dist/components/tabs/TabPanel.base.js +36 -0
- package/dist/components/tabs/TabPanel.base.js.map +1 -0
- package/dist/components/tabs/TabPanel.types.d.ts +17 -0
- package/dist/components/tabs/Tabs.base.d.ts +221 -0
- package/dist/components/tabs/Tabs.base.js +213 -0
- package/dist/components/tabs/Tabs.base.js.map +1 -0
- package/dist/components/tabs/Tabs.types.d.ts +55 -0
- package/dist/components/tabs/Tabs.types.js +6 -0
- package/dist/components/tabs/Tabs.types.js.map +1 -0
- package/dist/components/tabs/index.d.ts +17 -0
- package/dist/components/tabs/index.js +5 -0
- package/dist/components/tooltip/Tooltip.base.d.ts +159 -0
- package/dist/components/tooltip/Tooltip.base.js +198 -0
- package/dist/components/tooltip/Tooltip.base.js.map +1 -0
- package/dist/components/tooltip/Tooltip.types.d.ts +18 -0
- package/dist/components/tooltip/Tooltip.types.js +15 -0
- package/dist/components/tooltip/Tooltip.types.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +13 -0
- package/dist/components/tooltip/index.js +3 -0
- package/dist/controllers/color-controller/index.d.ts +12 -0
- package/dist/controllers/color-controller/index.js +2 -0
- package/dist/controllers/color-controller/src/color-controller.d.ts +226 -0
- package/dist/controllers/color-controller/src/color-controller.js +253 -0
- package/dist/controllers/color-controller/src/color-controller.js.map +1 -0
- package/dist/controllers/drag-and-drop-controller/index.d.ts +12 -0
- package/dist/controllers/drag-and-drop-controller/index.js +2 -0
- package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.d.ts +68 -0
- package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.js +56 -0
- package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.js.map +1 -0
- package/dist/controllers/focusgroup-navigation-controller/index.d.ts +12 -0
- package/dist/controllers/focusgroup-navigation-controller/index.js +2 -0
- package/dist/controllers/focusgroup-navigation-controller/src/focusgroup-navigation-controller.d.ts +496 -0
- package/dist/controllers/focusgroup-navigation-controller/src/focusgroup-navigation-controller.js +345 -0
- package/dist/controllers/focusgroup-navigation-controller/src/focusgroup-navigation-controller.js.map +1 -0
- package/dist/controllers/hover-controller/index.d.ts +12 -0
- package/dist/controllers/hover-controller/index.js +2 -0
- package/dist/controllers/hover-controller/src/hover-controller.d.ts +118 -0
- package/dist/controllers/hover-controller/src/hover-controller.js +90 -0
- package/dist/controllers/hover-controller/src/hover-controller.js.map +1 -0
- package/dist/controllers/index.d.ts +26 -0
- package/dist/controllers/index.js +18 -0
- package/dist/controllers/language-resolution.d.ts +87 -0
- package/dist/controllers/language-resolution.js +56 -0
- package/dist/controllers/language-resolution.js.map +1 -0
- package/dist/controllers/live-selection-controller/index.d.ts +12 -0
- package/dist/controllers/live-selection-controller/index.js +2 -0
- package/dist/controllers/live-selection-controller/src/live-selection-controller.d.ts +144 -0
- package/dist/controllers/live-selection-controller/src/live-selection-controller.js +36 -0
- package/dist/controllers/live-selection-controller/src/live-selection-controller.js.map +1 -0
- package/dist/controllers/page-scroll-lock-controller/index.d.ts +12 -0
- package/dist/controllers/page-scroll-lock-controller/index.js +2 -0
- package/dist/controllers/page-scroll-lock-controller/src/page-scroll-lock.d.ts +20 -0
- package/dist/controllers/page-scroll-lock-controller/src/page-scroll-lock.js +30 -0
- package/dist/controllers/page-scroll-lock-controller/src/page-scroll-lock.js.map +1 -0
- package/dist/controllers/pending-controller/index.d.ts +12 -0
- package/dist/controllers/pending-controller/index.js +2 -0
- package/dist/controllers/pending-controller/src/pending-controller.d.ts +95 -0
- package/dist/controllers/pending-controller/src/pending-controller.js +55 -0
- package/dist/controllers/pending-controller/src/pending-controller.js.map +1 -0
- package/dist/controllers/placement-controller/index.d.ts +12 -0
- package/dist/controllers/placement-controller/index.js +4 -0
- package/dist/controllers/placement-controller/src/fallback-placements.d.ts +9 -0
- package/dist/controllers/placement-controller/src/fallback-placements.js +71 -0
- package/dist/controllers/placement-controller/src/fallback-placements.js.map +1 -0
- package/dist/controllers/placement-controller/src/placement-controller.d.ts +152 -0
- package/dist/controllers/placement-controller/src/placement-controller.js +129 -0
- package/dist/controllers/placement-controller/src/placement-controller.js.map +1 -0
- package/dist/controllers/placement-controller/src/placement-conversion.d.ts +35 -0
- package/dist/controllers/placement-controller/src/placement-conversion.js +54 -0
- package/dist/controllers/placement-controller/src/placement-conversion.js.map +1 -0
- package/dist/controllers/placement-controller/src/types.d.ts +128 -0
- package/dist/controllers/placement-controller/src/types.js +29 -0
- package/dist/controllers/placement-controller/src/types.js.map +1 -0
- package/dist/controllers/slot-attribute-propagation-controller/index.d.ts +12 -0
- package/dist/controllers/slot-attribute-propagation-controller/index.js +2 -0
- package/dist/controllers/slot-attribute-propagation-controller/src/slot-attribute-propagation-controller.d.ts +65 -0
- package/dist/controllers/slot-attribute-propagation-controller/src/slot-attribute-propagation-controller.js +33 -0
- package/dist/controllers/slot-attribute-propagation-controller/src/slot-attribute-propagation-controller.js.map +1 -0
- package/dist/controllers/slot-presence-controller/index.d.ts +12 -0
- package/dist/controllers/slot-presence-controller/index.js +2 -0
- package/dist/controllers/slot-presence-controller/src/slot-presence-controller.d.ts +57 -0
- package/dist/controllers/slot-presence-controller/src/slot-presence-controller.js +44 -0
- package/dist/controllers/slot-presence-controller/src/slot-presence-controller.js.map +1 -0
- package/dist/controllers/slot-text-controller/index.d.ts +12 -0
- package/dist/controllers/slot-text-controller/index.js +2 -0
- package/dist/controllers/slot-text-controller/src/slot-text-controller.d.ts +92 -0
- package/dist/controllers/slot-text-controller/src/slot-text-controller.js +53 -0
- package/dist/controllers/slot-text-controller/src/slot-text-controller.js.map +1 -0
- package/dist/directives/index.d.ts +15 -0
- package/dist/directives/index.js +3 -0
- package/dist/directives/pending-spinner/index.d.ts +12 -0
- package/dist/directives/pending-spinner/index.js +1 -0
- package/dist/directives/pending-spinner/src/pending-spinner.d.ts +22 -0
- package/dist/directives/pending-spinner/src/pending-spinner.js +39 -0
- package/dist/directives/pending-spinner/src/pending-spinner.js.map +1 -0
- package/dist/element/define-element.d.ts +16 -0
- package/dist/element/define-element.js +8 -0
- package/dist/element/define-element.js.map +1 -0
- package/dist/element/index.d.ts +14 -0
- package/dist/element/index.js +4 -0
- package/dist/element/spectrum-element.d.ts +69 -0
- package/dist/element/spectrum-element.js +85 -0
- package/dist/element/spectrum-element.js.map +1 -0
- package/dist/element/version.d.ts +19 -0
- package/dist/element/version.js +6 -0
- package/dist/element/version.js.map +1 -0
- package/dist/mixins/disabled-mixin.d.ts +30 -0
- package/dist/mixins/disabled-mixin.js +27 -0
- package/dist/mixins/disabled-mixin.js.map +1 -0
- package/dist/mixins/index.d.ts +16 -0
- package/dist/mixins/index.js +5 -0
- package/dist/mixins/linear-progress-mixin.d.ts +41 -0
- package/dist/mixins/linear-progress-mixin.js +115 -0
- package/dist/mixins/linear-progress-mixin.js.map +1 -0
- package/dist/mixins/pending-mixin.d.ts +45 -0
- package/dist/mixins/pending-mixin.js +50 -0
- package/dist/mixins/pending-mixin.js.map +1 -0
- package/dist/mixins/sized-mixin.d.ts +49 -0
- package/dist/mixins/sized-mixin.js +42 -0
- package/dist/mixins/sized-mixin.js.map +1 -0
- package/dist/utils/actual-placement.d.ts +10 -0
- package/dist/utils/actual-placement.js +8 -0
- package/dist/utils/actual-placement.js.map +1 -0
- package/dist/utils/capitalize.d.ts +26 -0
- package/dist/utils/capitalize.js +8 -0
- package/dist/utils/capitalize.js.map +1 -0
- package/dist/utils/deep-contains.d.ts +26 -0
- package/dist/utils/deep-contains.js +14 -0
- package/dist/utils/deep-contains.js.map +1 -0
- package/dist/utils/dev-validation.d.ts +88 -0
- package/dist/utils/dev-validation.js +33 -0
- package/dist/utils/dev-validation.js.map +1 -0
- package/dist/utils/dismissible-stack.d.ts +26 -0
- package/dist/utils/dismissible-stack.js +16 -0
- package/dist/utils/dismissible-stack.js.map +1 -0
- package/dist/utils/focusable-selectors.d.ts +43 -0
- package/dist/utils/focusable-selectors.js +18 -0
- package/dist/utils/focusable-selectors.js.map +1 -0
- package/dist/utils/get-active-element.d.ts +31 -0
- package/dist/utils/get-active-element.js +11 -0
- package/dist/utils/get-active-element.js.map +1 -0
- package/dist/utils/get-label-from-slot.d.ts +12 -0
- package/dist/utils/get-label-from-slot.js +10 -0
- package/dist/utils/get-label-from-slot.js.map +1 -0
- package/dist/utils/index.d.ts +22 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/is-focus-visible-in-tree.d.ts +33 -0
- package/dist/utils/is-focus-visible-in-tree.js +11 -0
- package/dist/utils/is-focus-visible-in-tree.js.map +1 -0
- package/dist/utils/resolve-trigger.d.ts +42 -0
- package/dist/utils/resolve-trigger.js +23 -0
- package/dist/utils/resolve-trigger.js.map +1 -0
- package/dist/utils/transition.d.ts +53 -0
- package/dist/utils/transition.js +26 -0
- package/dist/utils/transition.js.map +1 -0
- package/package.json +644 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region utils/dev-validation.ts
|
|
2
|
+
function e(e, t, n, r) {
|
|
3
|
+
var i;
|
|
4
|
+
(i = window.__swc) != null && i.DEBUG && window.__swc.warn(e, t, n, r);
|
|
5
|
+
}
|
|
6
|
+
function t() {
|
|
7
|
+
var e;
|
|
8
|
+
return process.env.NODE_ENV === "production" || typeof window > "u" ? !1 : !!((e = window.__swc) != null && e.DEBUG);
|
|
9
|
+
}
|
|
10
|
+
function n(t, { prop: n, value: r, valid: i, url: a, options: o }) {
|
|
11
|
+
process.env.NODE_ENV !== "production" && (i.includes(r) || e(t, `<${t.localName}> expects "${n}" to be one of: ${i.join(", ")}. Received "${r}".`, a, {
|
|
12
|
+
issues: [`${n}="${r}"`],
|
|
13
|
+
...o
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
function r(t, n, r, i, a) {
|
|
17
|
+
process.env.NODE_ENV !== "production" && n && e(t, r, i, a);
|
|
18
|
+
}
|
|
19
|
+
function i(t, n, r, i, a) {
|
|
20
|
+
process.env.NODE_ENV !== "production" && (!n || n.assignedNodes({ flatten: !0 }).length === 0) && e(t, `<${t.localName}> requires content in the "${r}" slot.`, i, a);
|
|
21
|
+
}
|
|
22
|
+
function a(t, n, r, i, a, o) {
|
|
23
|
+
if (process.env.NODE_ENV === "production" || !n) return;
|
|
24
|
+
let s = r.map((e) => e.toUpperCase()), c = r.map((e) => `<${e}>`).join(", ");
|
|
25
|
+
for (let r of n.assignedElements()) s.includes(r.tagName) || e(t, `<${t.localName}> "${i}" slot received a <${r.tagName.toLowerCase()}> element. Only ${c} elements are allowed.`, a, {
|
|
26
|
+
issues: [`${i} slot: <${r.tagName.toLowerCase()}>`],
|
|
27
|
+
...o
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { t as isDebug, a as validateAllowedChildren, n as validateEnum, i as validateRequiredSlot, r as warnIf };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=dev-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-validation.js","names":[],"sources":["../../utils/dev-validation.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * The single place \"warn in development\" lives: the `DEBUG` gate plus the\n * `window.__swc.warn` call. Every public helper below computes its own\n * predicate and message, then defers the actual emit to this primitive, so\n * there is one source of truth for how a warning is gated and dispatched.\n *\n * Note: this deliberately does **not** include the\n * `process.env.NODE_ENV === 'production'` guard. That guard must stay in each\n * public helper so a bundler can dead-code-eliminate the message construction\n * inside that function for production builds; centralizing it here would leave\n * each caller's message-building in the production bundle.\n *\n * @param element - The component instance the warning is attributed to.\n * @param message - The warning message.\n * @param url - Documentation URL for the component.\n * @param options - Passed through to `window.__swc.warn`.\n */\nfunction emitWarning(\n element: HTMLElement,\n message: string,\n url: string,\n options?: SWCWarningOptions\n): void {\n if (!window.__swc?.DEBUG) {\n return;\n }\n window.__swc.warn(element, message, url, options);\n}\n\n/**\n * Whether dev-mode validation is active: `false` in production builds and in\n * non-browser (SSR) environments, otherwise mirrors `window.__swc.DEBUG`.\n *\n * Use this to guard the *call site* of a warning whose condition or message is\n * expensive to compute (for example a DOM traversal), so that work is skipped\n * entirely when validation is off:\n *\n * ```ts\n * if (isDebug()) {\n * this.warnAboutExpensiveThing(); // only traverses the DOM when validation runs\n * }\n * ```\n *\n * For cheap conditions, call `warnIf`/`validateEnum` directly; they already\n * gate internally. This helper exists only to avoid paying call-site argument\n * cost in the expensive cases. It checks `process.env.NODE_ENV` first so a\n * bundler can dead-code-eliminate the guarded block in production, matching the\n * other helpers in this file, and short-circuits when `window` is undefined so\n * it is safe to call during server-side rendering.\n */\nexport function isDebug(): boolean {\n if (process.env.NODE_ENV === 'production') {\n return false;\n }\n if (typeof window === 'undefined') {\n return false;\n }\n return Boolean(window.__swc?.DEBUG);\n}\n\n/**\n * Warns when `value` is not one of `valid`. Covers union-type/enum property\n * validation (e.g. `variant`, `size`).\n *\n * @param element - The component instance the warning is attributed to.\n * @param check - The enum check to perform.\n * @param check.prop - The property name, for the warning message.\n * @param check.value - The value received.\n * @param check.valid - The allowed values.\n * @param check.url - Documentation URL for the component.\n * @param check.options - Passed through to `window.__swc.warn`.\n */\nexport function validateEnum<T extends string>(\n element: HTMLElement,\n {\n prop,\n value,\n valid,\n url,\n options,\n }: {\n prop: string;\n value: string;\n valid: readonly T[];\n url: string;\n options?: SWCWarningOptions;\n }\n): void {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n if ((valid as readonly string[]).includes(value)) {\n return;\n }\n emitWarning(\n element,\n `<${element.localName}> expects \"${prop}\" to be one of: ${valid.join(', ')}. Received \"${value}\".`,\n url,\n { issues: [`${prop}=\"${value}\"`], ...options }\n );\n}\n\n/**\n * Warns when `condition` is true. The general-purpose validation primitive:\n * covers required properties, conditionally required properties, mutually\n * exclusive/no-effect property combinations, and any component-specific\n * quirk that doesn't fit the other helpers here.\n *\n * @param element - The component instance the warning is attributed to.\n * @param condition - Warn when this is true.\n * @param message - The warning message.\n * @param url - Documentation URL for the component.\n * @param options - Passed through to `window.__swc.warn`.\n */\nexport function warnIf(\n element: HTMLElement,\n condition: boolean,\n message: string,\n url: string,\n options?: SWCWarningOptions\n): void {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n if (!condition) {\n return;\n }\n emitWarning(element, message, url, options);\n}\n\n/**\n * Warns when a slot has no assigned nodes. Covers required-slot validation.\n *\n * @param element - The component instance the warning is attributed to.\n * @param slot - The slot element to check (`null`/`undefined` counts as empty).\n * @param slotName - The slot's `name` attribute (or `\"default\"`), for the message.\n * @param url - Documentation URL for the component.\n * @param options - Passed through to `window.__swc.warn`.\n */\nexport function validateRequiredSlot(\n element: HTMLElement,\n slot: HTMLSlotElement | null | undefined,\n slotName: string,\n url: string,\n options?: SWCWarningOptions\n): void {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n const isEmpty = !slot || slot.assignedNodes({ flatten: true }).length === 0;\n if (!isEmpty) {\n return;\n }\n emitWarning(\n element,\n `<${element.localName}> requires content in the \"${slotName}\" slot.`,\n url,\n options\n );\n}\n\n/**\n * Warns for each assigned element in `slot` whose tag name is not in\n * `allowedTagNames`. Covers allowed-children slot validation (e.g. a heading\n * slot that only accepts `<h2>`-`<h6>`).\n *\n * @param element - The component instance the warning is attributed to.\n * @param slot - The slot element to check.\n * @param allowedTagNames - Allowed tag names (case-insensitive, e.g. `['h2', 'h3']`).\n * @param slotName - The slot's `name` attribute (or `\"default\"`), for the message.\n * @param url - Documentation URL for the component.\n * @param options - Passed through to `window.__swc.warn`.\n */\nexport function validateAllowedChildren(\n element: HTMLElement,\n slot: HTMLSlotElement | null | undefined,\n allowedTagNames: readonly string[],\n slotName: string,\n url: string,\n options?: SWCWarningOptions\n): void {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n if (!slot) {\n return;\n }\n const allowed = allowedTagNames.map((tag) => tag.toUpperCase());\n const allowedList = allowedTagNames.map((tag) => `<${tag}>`).join(', ');\n for (const el of slot.assignedElements()) {\n if (!allowed.includes(el.tagName)) {\n emitWarning(\n element,\n `<${element.localName}> \"${slotName}\" slot received a <${el.tagName.toLowerCase()}> element. Only ${allowedList} elements are allowed.`,\n url,\n {\n issues: [`${slotName} slot: <${el.tagName.toLowerCase()}>`],\n ...options,\n }\n );\n }\n }\n}\n"],"mappings":";AA6BA,SAAS,EACP,GACA,GACA,GACA,GACM;;AACF,EAAA,IAAC,OAAO,UAAA,QAAA,EAAO,SAGnB,OAAO,MAAM,KAAK,GAAS,GAAS,GAAK,EAAQ;;AAwBnD,SAAgB,IAAmB;;AAOjC,QANA,QAAA,IAAA,aAA6B,gBAGzB,OAAO,SAAW,MACb,KAEF,IAAA,IAAQ,OAAO,UAAA,QAAA,EAAO;;AAe/B,SAAgB,EACd,GACA,EACE,SACA,UACA,UACA,QACA,cAQI;AACN,SAAA,IAAA,aAA6B,iBAGxB,EAA4B,SAAS,EAAM,IAGhD,EACE,GACA,IAAI,EAAQ,UAAU,aAAa,EAAK,kBAAkB,EAAM,KAAK,KAAK,CAAC,cAAc,EAAM,KAC/F,GACA;EAAE,QAAQ,CAAC,GAAG,EAAK,IAAI,EAAM,GAAG;EAAE,GAAG;EAAS,CAC/C;;AAeH,SAAgB,EACd,GACA,GACA,GACA,GACA,GACM;AACN,SAAA,IAAA,aAA6B,gBAGxB,KAGL,EAAY,GAAS,GAAS,GAAK,EAAQ;;AAY7C,SAAgB,EACd,GACA,GACA,GACA,GACA,GACM;AACN,SAAA,IAAA,aAA6B,iBAGb,CAAC,KAAQ,EAAK,cAAc,EAAE,SAAS,IAAM,CAAC,CAAC,WAAW,MAI1E,EACE,GACA,IAAI,EAAQ,UAAU,6BAA6B,EAAS,UAC5D,GACA,EACD;;AAeH,SAAgB,EACd,GACA,GACA,GACA,GACA,GACA,GACM;AAIN,KAHA,QAAA,IAAA,aAA6B,gBAGzB,CAAC,EACH;CAEF,IAAM,IAAU,EAAgB,KAAK,MAAQ,EAAI,aAAa,CAAC,EACzD,IAAc,EAAgB,KAAK,MAAQ,IAAI,EAAI,GAAG,CAAC,KAAK,KAAK;AACvE,MAAK,IAAM,KAAM,EAAK,kBAAkB,CACtC,CAAK,EAAQ,SAAS,EAAG,QAAQ,IAC/B,EACE,GACA,IAAI,EAAQ,UAAU,KAAK,EAAS,qBAAqB,EAAG,QAAQ,aAAa,CAAC,kBAAkB,EAAY,yBAChH,GACA;EACE,QAAQ,CAAC,GAAG,EAAS,UAAU,EAAG,QAAQ,aAAa,CAAC,GAAG;EAC3D,GAAG;EACJ,CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Register a dismissible as the topmost entry when it opens. Any existing entry
|
|
14
|
+
* for the same key is removed first, so re-registering moves the key to the top
|
|
15
|
+
* and the stack never holds duplicates.
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerDismissible(key: object): void;
|
|
18
|
+
/**
|
|
19
|
+
* Remove the most-recent entry matching the key when it closes. Idempotent: a
|
|
20
|
+
* key that is not present is a no-op (safe to call from `disconnectedCallback`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function unregisterDismissible(key: object): void;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the key is the topmost (most-recently-registered) dismissible.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isTopDismissible(key: object): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region utils/dismissible-stack.ts
|
|
2
|
+
var e = [];
|
|
3
|
+
function t(t) {
|
|
4
|
+
n(t), e.push(t);
|
|
5
|
+
}
|
|
6
|
+
function n(t) {
|
|
7
|
+
let n = e.lastIndexOf(t);
|
|
8
|
+
n !== -1 && e.splice(n, 1);
|
|
9
|
+
}
|
|
10
|
+
function r(t) {
|
|
11
|
+
return e[e.length - 1] === t;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { r as isTopDismissible, t as registerDismissible, n as unregisterDismissible };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=dismissible-stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dismissible-stack.js","names":[],"sources":["../../utils/dismissible-stack.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * A LIFO stack of currently-open dismissible top-layer components, used to\n * coordinate Escape handling across mechanisms that don't natively order with\n * each other (e.g. an `popover=\"auto\"` element open while a `<dialog>` is also\n * open).\n *\n * Usage convention for consumers:\n *\n * - `registerDismissible(this)` on open.\n * - `unregisterDismissible(this)` on close and in `disconnectedCallback`.\n * - Check `isTopDismissible(this)` before processing any custom Escape handling.\n *\n * State is module-level and in-memory only; it resets on page reload, which is\n * correct for this coordination use case.\n *\n */\nconst dismissibleStack: object[] = [];\n\n/**\n * Register a dismissible as the topmost entry when it opens. Any existing entry\n * for the same key is removed first, so re-registering moves the key to the top\n * and the stack never holds duplicates.\n */\nexport function registerDismissible(key: object): void {\n unregisterDismissible(key);\n dismissibleStack.push(key);\n}\n\n/**\n * Remove the most-recent entry matching the key when it closes. Idempotent: a\n * key that is not present is a no-op (safe to call from `disconnectedCallback`).\n */\nexport function unregisterDismissible(key: object): void {\n const index = dismissibleStack.lastIndexOf(key);\n if (index !== -1) {\n dismissibleStack.splice(index, 1);\n }\n}\n\n/**\n * Whether the key is the topmost (most-recently-registered) dismissible.\n */\nexport function isTopDismissible(key: object): boolean {\n // Index access rather than `Array.prototype.at()`: core's TS lib target does\n // not include `at`. On an empty stack `length - 1` is `-1`, which reads as\n // `undefined` and never equals a (non-null) key.\n return dismissibleStack[dismissibleStack.length - 1] === key;\n}\n"],"mappings":";AA4BA,IAAM,IAA6B,EAAE;AAOrC,SAAgB,EAAoB,GAAmB;AAErD,CADA,EAAsB,EAAI,EAC1B,EAAiB,KAAK,EAAI;;AAO5B,SAAgB,EAAsB,GAAmB;CACvD,IAAM,IAAQ,EAAiB,YAAY,EAAI;AAC/C,CAAI,MAAU,MACZ,EAAiB,OAAO,GAAO,EAAE;;AAOrC,SAAgB,EAAiB,GAAsB;AAIrD,QAAO,EAAiB,EAAiB,SAAS,OAAO"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* CSS selector strings for matching focusable and tabbable DOM elements
|
|
14
|
+
* per the HTML specification.
|
|
15
|
+
*
|
|
16
|
+
* These selectors use standard HTML focusability rules only — the 1st-gen
|
|
17
|
+
* custom `[focusable]` attribute selector is intentionally not included,
|
|
18
|
+
* as native `delegatesFocus` replaces that workaround.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Matches elements that can receive focus programmatically (via `.focus()`).
|
|
22
|
+
*
|
|
23
|
+
* Includes elements with `tabindex="-1"` which are focusable via script
|
|
24
|
+
* but not reachable via the Tab key.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const firstFocusable = shadowRoot.querySelector(focusableSelector);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const focusableSelector: string;
|
|
32
|
+
/**
|
|
33
|
+
* Matches elements reachable via the Tab key.
|
|
34
|
+
*
|
|
35
|
+
* This is a subset of {@link focusableSelector} that excludes elements
|
|
36
|
+
* with `tabindex="-1"` (which are focusable via script but not tabbable).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const tabbableElements = [...container.querySelectorAll(tabbableSelector)];
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const tabbableSelector: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region utils/focusable-selectors.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"input:not([inert]):not([disabled])",
|
|
4
|
+
"select:not([inert]):not([disabled])",
|
|
5
|
+
"textarea:not([inert]):not([disabled])",
|
|
6
|
+
"a[href]:not([inert])",
|
|
7
|
+
"button:not([inert]):not([disabled])",
|
|
8
|
+
"[tabindex]:not([inert])",
|
|
9
|
+
"audio[controls]:not([inert])",
|
|
10
|
+
"video[controls]:not([inert])",
|
|
11
|
+
"[contenteditable]:not([contenteditable=\"false\"]):not([inert])",
|
|
12
|
+
"details>summary:first-of-type:not([inert])",
|
|
13
|
+
"details:not([inert])"
|
|
14
|
+
].join(","), t = e.split(",").map((e) => e + ":not([tabindex=\"-1\"])").join(",");
|
|
15
|
+
//#endregion
|
|
16
|
+
export { e as focusableSelector, t as tabbableSelector };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=focusable-selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focusable-selectors.js","names":[],"sources":["../../utils/focusable-selectors.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * CSS selector strings for matching focusable and tabbable DOM elements\n * per the HTML specification.\n *\n * These selectors use standard HTML focusability rules only — the 1st-gen\n * custom `[focusable]` attribute selector is intentionally not included,\n * as native `delegatesFocus` replaces that workaround.\n */\n\n/**\n * Matches elements that can receive focus programmatically (via `.focus()`).\n *\n * Includes elements with `tabindex=\"-1\"` which are focusable via script\n * but not reachable via the Tab key.\n *\n * @example\n * ```typescript\n * const firstFocusable = shadowRoot.querySelector(focusableSelector);\n * ```\n */\nexport const focusableSelector = [\n 'input:not([inert]):not([disabled])',\n 'select:not([inert]):not([disabled])',\n 'textarea:not([inert]):not([disabled])',\n 'a[href]:not([inert])',\n 'button:not([inert]):not([disabled])',\n '[tabindex]:not([inert])',\n 'audio[controls]:not([inert])',\n 'video[controls]:not([inert])',\n '[contenteditable]:not([contenteditable=\"false\"]):not([inert])',\n 'details>summary:first-of-type:not([inert])',\n 'details:not([inert])',\n].join(',');\n\n/**\n * Matches elements reachable via the Tab key.\n *\n * This is a subset of {@link focusableSelector} that excludes elements\n * with `tabindex=\"-1\"` (which are focusable via script but not tabbable).\n *\n * @example\n * ```typescript\n * const tabbableElements = [...container.querySelectorAll(tabbableSelector)];\n * ```\n */\nexport const tabbableSelector = focusableSelector\n .split(',')\n .map((s) => s + ':not([tabindex=\"-1\"])')\n .join(',');\n"],"mappings":";AAgCA,IAAa,IAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,KAAK,IAAI,EAaE,IAAmB,EAC7B,MAAM,IAAI,CACV,KAAK,MAAM,IAAI,0BAAwB,CACvC,KAAK,IAAI"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Returns the deepest focused element by traversing shadow DOM boundaries.
|
|
14
|
+
*
|
|
15
|
+
* `document.activeElement` stops at shadow hosts — this utility follows
|
|
16
|
+
* `shadowRoot.activeElement` chains to find the leaf-level focused element.
|
|
17
|
+
*
|
|
18
|
+
* @param root - The document or shadow root to start traversal from.
|
|
19
|
+
* Defaults to `document`.
|
|
20
|
+
* @returns The deepest focused element, or `null` if nothing is focused.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // Get the truly focused element across all shadow boundaries
|
|
25
|
+
* const active = getActiveElement();
|
|
26
|
+
*
|
|
27
|
+
* // Start traversal from a specific root
|
|
28
|
+
* const active = getActiveElement(el.getRootNode() as Document);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getActiveElement(root?: Document | ShadowRoot): HTMLElement | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region utils/get-active-element.ts
|
|
2
|
+
function e(e = document) {
|
|
3
|
+
var t;
|
|
4
|
+
let n = e.activeElement;
|
|
5
|
+
for (; !(n == null || (t = n.shadowRoot) == null) && t.activeElement;) n = n.shadowRoot.activeElement;
|
|
6
|
+
return n;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { e as getActiveElement };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=get-active-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-active-element.js","names":[],"sources":["../../utils/get-active-element.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Returns the deepest focused element by traversing shadow DOM boundaries.\n *\n * `document.activeElement` stops at shadow hosts — this utility follows\n * `shadowRoot.activeElement` chains to find the leaf-level focused element.\n *\n * @param root - The document or shadow root to start traversal from.\n * Defaults to `document`.\n * @returns The deepest focused element, or `null` if nothing is focused.\n *\n * @example\n * ```typescript\n * // Get the truly focused element across all shadow boundaries\n * const active = getActiveElement();\n *\n * // Start traversal from a specific root\n * const active = getActiveElement(el.getRootNode() as Document);\n * ```\n */\nexport function getActiveElement(\n root: Document | ShadowRoot = document\n): HTMLElement | null {\n let current = root.activeElement as HTMLElement | null;\n while (current?.shadowRoot?.activeElement) {\n current = current.shadowRoot.activeElement as HTMLElement;\n }\n return current;\n}\n"],"mappings":";AA+BA,SAAgB,EACd,IAA8B,UACV;;CACpB,IAAI,IAAU,EAAK;AACnB,QAAA,OAAA,SAAA,IAAO,EAAS,eAAA,SAAA,EAAY,eAC1B,KAAU,EAAQ,WAAW;AAE/B,QAAO"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getLabelFromSlot: (label: string, slotEl: HTMLSlotElement) => string | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region utils/get-label-from-slot.ts
|
|
2
|
+
var e = (e, t) => {
|
|
3
|
+
if (e) return null;
|
|
4
|
+
let n = t.assignedNodes().reduce((e, t) => t.textContent ? e + t.textContent : e, "");
|
|
5
|
+
return n ? n.trim() : null;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as getLabelFromSlot };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=get-label-from-slot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-label-from-slot.js","names":[],"sources":["../../utils/get-label-from-slot.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport const getLabelFromSlot = (\n label: string,\n slotEl: HTMLSlotElement\n): string | null => {\n if (label) {\n return null;\n }\n const textContent = slotEl\n .assignedNodes()\n .reduce((accumulator: string, node: Node) => {\n if (node.textContent) {\n return accumulator + node.textContent;\n } else {\n return accumulator;\n }\n }, '');\n if (textContent) {\n return textContent.trim();\n } else {\n return null;\n }\n};\n"],"mappings":";AAYA,IAAa,KACX,GACA,MACkB;AAClB,KAAI,EACF,QAAO;CAET,IAAM,IAAc,EACjB,eAAe,CACf,QAAQ,GAAqB,MACxB,EAAK,cACA,IAAc,EAAK,cAEnB,GAER,GAAG;AAIN,QAHE,IACK,EAAY,MAAM,GAElB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export { physicalSide } from './actual-placement.js';
|
|
13
|
+
export { capitalize } from './capitalize.js';
|
|
14
|
+
export { deepContains } from './deep-contains.js';
|
|
15
|
+
export { isDebug, validateAllowedChildren, validateEnum, validateRequiredSlot, warnIf, } from './dev-validation.js';
|
|
16
|
+
export { isTopDismissible, registerDismissible, unregisterDismissible, } from './dismissible-stack.js';
|
|
17
|
+
export { getActiveElement } from './get-active-element.js';
|
|
18
|
+
export { focusableSelector, tabbableSelector } from './focusable-selectors.js';
|
|
19
|
+
export { getLabelFromSlot } from './get-label-from-slot.js';
|
|
20
|
+
export { isFocusVisibleInTree } from './is-focus-visible-in-tree.js';
|
|
21
|
+
export { resolveTrigger, type ResolvedTrigger, type ResolveTriggerOptions, } from './resolve-trigger.js';
|
|
22
|
+
export { hasActiveTransition, maxTransitionDurationMs, runAfterTransition, } from './transition.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { physicalSide as e } from "./actual-placement.js";
|
|
2
|
+
import { capitalize as t } from "./capitalize.js";
|
|
3
|
+
import { deepContains as n } from "./deep-contains.js";
|
|
4
|
+
import { isDebug as r, validateAllowedChildren as i, validateEnum as a, validateRequiredSlot as o, warnIf as s } from "./dev-validation.js";
|
|
5
|
+
import { isTopDismissible as c, registerDismissible as l, unregisterDismissible as u } from "./dismissible-stack.js";
|
|
6
|
+
import { getActiveElement as d } from "./get-active-element.js";
|
|
7
|
+
import { focusableSelector as f, tabbableSelector as p } from "./focusable-selectors.js";
|
|
8
|
+
import { getLabelFromSlot as m } from "./get-label-from-slot.js";
|
|
9
|
+
import { isFocusVisibleInTree as h } from "./is-focus-visible-in-tree.js";
|
|
10
|
+
import { resolveTrigger as g } from "./resolve-trigger.js";
|
|
11
|
+
import { hasActiveTransition as _, maxTransitionDurationMs as v, runAfterTransition as y } from "./transition.js";
|
|
12
|
+
export { t as capitalize, n as deepContains, f as focusableSelector, d as getActiveElement, m as getLabelFromSlot, _ as hasActiveTransition, r as isDebug, h as isFocusVisibleInTree, c as isTopDismissible, v as maxTransitionDurationMs, e as physicalSide, l as registerDismissible, g as resolveTrigger, y as runAfterTransition, p as tabbableSelector, u as unregisterDismissible, i as validateAllowedChildren, a as validateEnum, o as validateRequiredSlot, s as warnIf };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Returns whether the deepest focused element in a tree is matched by
|
|
14
|
+
* `:focus-visible` (i.e. the platform would show a focus ring).
|
|
15
|
+
*
|
|
16
|
+
* Traverses shadow DOM boundaries via {@link getActiveElement} before testing
|
|
17
|
+
* the pseudo-class, so it reports the truly focused element rather than stopping
|
|
18
|
+
* at a shadow host.
|
|
19
|
+
*
|
|
20
|
+
* @param root - The document or shadow root to start traversal from. Pass a
|
|
21
|
+
* component's root node (`el.getRootNode()`) to scope the check to
|
|
22
|
+
* that tree. Defaults to `document`.
|
|
23
|
+
* @returns `true` if the active element matches `:focus-visible`, otherwise `false`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* // Inside a component, mirror focus-visible state to a reactive property.
|
|
28
|
+
* this.focused = isFocusVisibleInTree(
|
|
29
|
+
* this.getRootNode() as Document | ShadowRoot
|
|
30
|
+
* );
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function isFocusVisibleInTree(root?: Document | ShadowRoot): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getActiveElement as e } from "./get-active-element.js";
|
|
2
|
+
//#region utils/is-focus-visible-in-tree.ts
|
|
3
|
+
function t(t = document) {
|
|
4
|
+
var n;
|
|
5
|
+
let r = e(t);
|
|
6
|
+
return (n = r == null ? void 0 : r.matches(":focus-visible")) == null ? !1 : n;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as isFocusVisibleInTree };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=is-focus-visible-in-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-focus-visible-in-tree.js","names":[],"sources":["../../utils/is-focus-visible-in-tree.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { getActiveElement } from './get-active-element.js';\n\n/**\n * Returns whether the deepest focused element in a tree is matched by\n * `:focus-visible` (i.e. the platform would show a focus ring).\n *\n * Traverses shadow DOM boundaries via {@link getActiveElement} before testing\n * the pseudo-class, so it reports the truly focused element rather than stopping\n * at a shadow host.\n *\n * @param root - The document or shadow root to start traversal from. Pass a\n * component's root node (`el.getRootNode()`) to scope the check to\n * that tree. Defaults to `document`.\n * @returns `true` if the active element matches `:focus-visible`, otherwise `false`.\n *\n * @example\n * ```typescript\n * // Inside a component, mirror focus-visible state to a reactive property.\n * this.focused = isFocusVisibleInTree(\n * this.getRootNode() as Document | ShadowRoot\n * );\n * ```\n */\nexport function isFocusVisibleInTree(\n root: Document | ShadowRoot = document\n): boolean {\n const active = getActiveElement(root);\n return active?.matches(':focus-visible') ?? false;\n}\n"],"mappings":";;AAmCA,SAAgB,EACd,IAA8B,UACrB;;CACT,IAAM,IAAS,EAAiB,EAAK;AACrC,SAAA,IAAA,KAAA,OAAA,KAAA,IAAO,EAAQ,QAAQ,iBAAiB,KAAA,OAAI,KAAJ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Options for {@link resolveTrigger}.
|
|
14
|
+
*/
|
|
15
|
+
export interface ResolveTriggerOptions {
|
|
16
|
+
/** ID of the trigger element in the host's tree root. */
|
|
17
|
+
for?: string;
|
|
18
|
+
/** Direct trigger reference; overrides `for` when set. */
|
|
19
|
+
triggerElement?: HTMLElement | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The resolved trigger and the element that should receive ARIA wiring.
|
|
23
|
+
*
|
|
24
|
+
* `trigger` is the element used for positioning. `interactiveElement` is the
|
|
25
|
+
* AT-facing focusable element: the inner `<button>` of an open-shadow SWC
|
|
26
|
+
* component when present, otherwise the trigger itself.
|
|
27
|
+
*/
|
|
28
|
+
export interface ResolvedTrigger {
|
|
29
|
+
trigger: HTMLElement | null;
|
|
30
|
+
interactiveElement: HTMLElement | null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve the trigger for a popover-like host and discover the AT-facing inner
|
|
34
|
+
* button across shadow boundaries.
|
|
35
|
+
*
|
|
36
|
+
* Resolution order: a direct `triggerElement` reference wins; otherwise `for`
|
|
37
|
+
* is resolved by ID within the host's tree root (`getRootNode().getElementById`,
|
|
38
|
+
* strictly same-root). When the resolved trigger exposes an open shadow root,
|
|
39
|
+
* its inner `<button>` becomes the `interactiveElement` that receives ARIA;
|
|
40
|
+
* otherwise ARIA is wired on the trigger itself.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveTrigger(host: HTMLElement, options: ResolveTriggerOptions): ResolvedTrigger;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region utils/resolve-trigger.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
var n, r, i;
|
|
4
|
+
let a = (n = t.triggerElement) == null ? null : n;
|
|
5
|
+
if (!a && t.for) {
|
|
6
|
+
var o, s;
|
|
7
|
+
let n = e.getRootNode();
|
|
8
|
+
a = (o = (s = n.getElementById) == null ? void 0 : s.call(n, t.for)) == null ? null : o;
|
|
9
|
+
}
|
|
10
|
+
if (!a) return {
|
|
11
|
+
trigger: null,
|
|
12
|
+
interactiveElement: null
|
|
13
|
+
};
|
|
14
|
+
let c = (r = (i = a.shadowRoot) == null ? void 0 : i.querySelector("button")) == null ? null : r;
|
|
15
|
+
return {
|
|
16
|
+
trigger: a,
|
|
17
|
+
interactiveElement: c == null ? a : c
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { e as resolveTrigger };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=resolve-trigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-trigger.js","names":[],"sources":["../../utils/resolve-trigger.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Options for {@link resolveTrigger}.\n */\nexport interface ResolveTriggerOptions {\n /** ID of the trigger element in the host's tree root. */\n for?: string;\n /** Direct trigger reference; overrides `for` when set. */\n triggerElement?: HTMLElement | null;\n}\n\n/**\n * The resolved trigger and the element that should receive ARIA wiring.\n *\n * `trigger` is the element used for positioning. `interactiveElement` is the\n * AT-facing focusable element: the inner `<button>` of an open-shadow SWC\n * component when present, otherwise the trigger itself.\n */\nexport interface ResolvedTrigger {\n trigger: HTMLElement | null;\n interactiveElement: HTMLElement | null;\n}\n\n/**\n * Resolve the trigger for a popover-like host and discover the AT-facing inner\n * button across shadow boundaries.\n *\n * Resolution order: a direct `triggerElement` reference wins; otherwise `for`\n * is resolved by ID within the host's tree root (`getRootNode().getElementById`,\n * strictly same-root). When the resolved trigger exposes an open shadow root,\n * its inner `<button>` becomes the `interactiveElement` that receives ARIA;\n * otherwise ARIA is wired on the trigger itself.\n */\nexport function resolveTrigger(\n host: HTMLElement,\n options: ResolveTriggerOptions\n): ResolvedTrigger {\n let trigger: HTMLElement | null = options.triggerElement ?? null;\n\n if (!trigger && options.for) {\n // `getRootNode()` returns the Document or the host's ShadowRoot; both expose\n // `getElementById`, keeping resolution strictly within the same tree root.\n const root = host.getRootNode() as Document | ShadowRoot;\n trigger = root.getElementById?.(options.for) ?? null;\n }\n\n if (!trigger) {\n return { trigger: null, interactiveElement: null };\n }\n\n // Inner-button discovery: for a gen2 component trigger with an open shadow\n // root, wire ARIA on the AT-facing inner <button>. Closed-shadow or native\n // triggers fall back to the trigger host itself.\n const innerButton = trigger.shadowRoot?.querySelector('button') ?? null;\n\n return { trigger, interactiveElement: innerButton ?? trigger };\n}\n"],"mappings":";AA4CA,SAAgB,EACd,GACA,GACiB;;CACjB,IAAI,KAAA,IAA8B,EAAQ,mBAAA,OAAkB,OAAlB;AAE1C,KAAI,CAAC,KAAW,EAAQ,KAAK;;EAG3B,IAAM,IAAO,EAAK,aAAa;AAC/B,OAAA,KAAA,IAAU,EAAK,mBAAA,OAAA,KAAA,IAAA,EAAA,KAAA,GAAiB,EAAQ,IAAI,KAAA,OAAI,OAAJ;;AAG9C,KAAI,CAAC,EACH,QAAO;EAAE,SAAS;EAAM,oBAAoB;EAAM;CAMpD,IAAM,KAAA,KAAA,IAAc,EAAQ,eAAA,OAAA,KAAA,IAAA,EAAY,cAAc,SAAS,KAAA,OAAI,OAAJ;AAE/D,QAAO;EAAE;EAAS,oBAAoB,KAAA,OAAe,IAAf;EAAwB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Whether the element has an active CSS transition: at least one
|
|
14
|
+
* `transition-duration` entry is non-zero. Returns `false` when no transition
|
|
15
|
+
* will run (none declared, or reduced motion has zeroed it out), in which case
|
|
16
|
+
* `transitionend` will not fire and callers should run their completion logic
|
|
17
|
+
* immediately instead of waiting for it.
|
|
18
|
+
*
|
|
19
|
+
* @param element - The element whose computed `transition-duration` is read.
|
|
20
|
+
*/
|
|
21
|
+
export declare function hasActiveTransition(element: Element): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The longest `transition-duration` on the element, in milliseconds. Useful as a
|
|
24
|
+
* fallback timeout for browsers that do not fire `transitionend` for
|
|
25
|
+
* `transition-behavior: allow-discrete` discrete properties.
|
|
26
|
+
*
|
|
27
|
+
* @param element - The element whose computed `transition-duration` is read.
|
|
28
|
+
*/
|
|
29
|
+
export declare function maxTransitionDurationMs(element: Element): number;
|
|
30
|
+
/**
|
|
31
|
+
* Run `callback` once `element`'s CSS transition settles, or synchronously when
|
|
32
|
+
* no transition will run (none declared, or reduced motion) since neither
|
|
33
|
+
* `transitionend` nor `transitioncancel` will fire in that case. A
|
|
34
|
+
* `transitioncancel` (interrupted transition) settles the callback as promptly
|
|
35
|
+
* as a normal `transitionend`.
|
|
36
|
+
*
|
|
37
|
+
* When `fallback` is `true` (the default) a timer (the longest declared duration
|
|
38
|
+
* plus a small buffer) also settles the callback, covering browsers that skip
|
|
39
|
+
* both transition events for `transition-behavior: allow-discrete` properties
|
|
40
|
+
* (e.g. Firefox). Pass `fallback: false` when no completion-gated work depends on
|
|
41
|
+
* the callback (e.g. an open transition, where a delayed `transitionend` should
|
|
42
|
+
* not be pre-empted by the timer). The listeners and the timer are mutually
|
|
43
|
+
* cancelling, so the callback runs exactly once.
|
|
44
|
+
*
|
|
45
|
+
* @param element - The element whose transition completion is awaited.
|
|
46
|
+
* @param callback - Invoked once when the transition settles.
|
|
47
|
+
* @returns A cancel function that removes the listeners and clears the timer
|
|
48
|
+
* **without** running the callback. Call it to supersede a pending run (for
|
|
49
|
+
* example a new open/close cycle) or to clean up on disconnect.
|
|
50
|
+
*/
|
|
51
|
+
export declare function runAfterTransition(element: Element, callback: () => void, { fallback }?: {
|
|
52
|
+
fallback?: boolean;
|
|
53
|
+
}): () => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region utils/transition.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return getComputedStyle(e).transitionDuration.split(",").map((e) => {
|
|
4
|
+
let t = e.trim(), n = parseFloat(t);
|
|
5
|
+
return Number.isNaN(n) ? 0 : t.endsWith("ms") ? n : n * 1e3;
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
function t(t) {
|
|
9
|
+
return e(t).some((e) => e > 0);
|
|
10
|
+
}
|
|
11
|
+
function n(t) {
|
|
12
|
+
return Math.max(0, ...e(t));
|
|
13
|
+
}
|
|
14
|
+
function r(e, r, { fallback: i = !0 } = {}) {
|
|
15
|
+
if (!t(e)) return r(), () => {};
|
|
16
|
+
let a = (t) => {
|
|
17
|
+
t && t.target !== e || (o(), r());
|
|
18
|
+
}, o = () => {
|
|
19
|
+
s !== void 0 && clearTimeout(s), e.removeEventListener("transitionend", a), e.removeEventListener("transitioncancel", a);
|
|
20
|
+
}, s = i ? setTimeout(a, n(e) + 100) : void 0;
|
|
21
|
+
return e.addEventListener("transitionend", a), e.addEventListener("transitioncancel", a), o;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { t as hasActiveTransition, n as maxTransitionDurationMs, r as runAfterTransition };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=transition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transition.js","names":[],"sources":["../../utils/transition.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Parse an element's computed `transition-duration` into milliseconds per entry.\n * The value is comma-separated when multiple properties transition (for example\n * `\"0.2s, 0.2s, 0s\"`), so each entry is parsed independently rather than reading\n * only the first (which `parseFloat` of the whole string would do).\n */\nfunction transitionDurationsMs(element: Element): number[] {\n return getComputedStyle(element)\n .transitionDuration.split(',')\n .map((entry) => {\n const trimmed = entry.trim();\n const value = parseFloat(trimmed);\n if (Number.isNaN(value)) {\n return 0;\n }\n return trimmed.endsWith('ms') ? value : value * 1000;\n });\n}\n\n/**\n * Whether the element has an active CSS transition: at least one\n * `transition-duration` entry is non-zero. Returns `false` when no transition\n * will run (none declared, or reduced motion has zeroed it out), in which case\n * `transitionend` will not fire and callers should run their completion logic\n * immediately instead of waiting for it.\n *\n * @param element - The element whose computed `transition-duration` is read.\n */\nexport function hasActiveTransition(element: Element): boolean {\n return transitionDurationsMs(element).some((ms) => ms > 0);\n}\n\n/**\n * The longest `transition-duration` on the element, in milliseconds. Useful as a\n * fallback timeout for browsers that do not fire `transitionend` for\n * `transition-behavior: allow-discrete` discrete properties.\n *\n * @param element - The element whose computed `transition-duration` is read.\n */\nexport function maxTransitionDurationMs(element: Element): number {\n return Math.max(0, ...transitionDurationsMs(element));\n}\n\n/**\n * Run `callback` once `element`'s CSS transition settles, or synchronously when\n * no transition will run (none declared, or reduced motion) since neither\n * `transitionend` nor `transitioncancel` will fire in that case. A\n * `transitioncancel` (interrupted transition) settles the callback as promptly\n * as a normal `transitionend`.\n *\n * When `fallback` is `true` (the default) a timer (the longest declared duration\n * plus a small buffer) also settles the callback, covering browsers that skip\n * both transition events for `transition-behavior: allow-discrete` properties\n * (e.g. Firefox). Pass `fallback: false` when no completion-gated work depends on\n * the callback (e.g. an open transition, where a delayed `transitionend` should\n * not be pre-empted by the timer). The listeners and the timer are mutually\n * cancelling, so the callback runs exactly once.\n *\n * @param element - The element whose transition completion is awaited.\n * @param callback - Invoked once when the transition settles.\n * @returns A cancel function that removes the listeners and clears the timer\n * **without** running the callback. Call it to supersede a pending run (for\n * example a new open/close cycle) or to clean up on disconnect.\n */\nexport function runAfterTransition(\n element: Element,\n callback: () => void,\n { fallback = true }: { fallback?: boolean } = {}\n): () => void {\n if (!hasActiveTransition(element)) {\n callback();\n return () => {};\n }\n\n // `event` is present for the transition events and absent for the fallback\n // timer. Ignore transitions bubbling up from descendants (e.g. slotted\n // content) so only the element's own transition settles the callback.\n const settle = (event?: TransitionEvent): void => {\n if (event && event.target !== element) {\n return;\n }\n cancel();\n callback();\n };\n const cancel = (): void => {\n if (timer !== undefined) {\n clearTimeout(timer);\n }\n element.removeEventListener('transitionend', settle as EventListener);\n element.removeEventListener('transitioncancel', settle as EventListener);\n };\n\n const timer = fallback\n ? setTimeout(settle, maxTransitionDurationMs(element) + 100)\n : undefined;\n element.addEventListener('transitionend', settle as EventListener);\n element.addEventListener('transitioncancel', settle as EventListener);\n\n return cancel;\n}\n"],"mappings":";AAkBA,SAAS,EAAsB,GAA4B;AACzD,QAAO,iBAAiB,EAAQ,CAC7B,mBAAmB,MAAM,IAAI,CAC7B,KAAK,MAAU;EACd,IAAM,IAAU,EAAM,MAAM,EACtB,IAAQ,WAAW,EAAQ;AAIjC,SAHI,OAAO,MAAM,EAAM,GACd,IAEF,EAAQ,SAAS,KAAK,GAAG,IAAQ,IAAQ;GAChD;;AAYN,SAAgB,EAAoB,GAA2B;AAC7D,QAAO,EAAsB,EAAQ,CAAC,MAAM,MAAO,IAAK,EAAE;;AAU5D,SAAgB,EAAwB,GAA0B;AAChE,QAAO,KAAK,IAAI,GAAG,GAAG,EAAsB,EAAQ,CAAC;;AAwBvD,SAAgB,EACd,GACA,GACA,EAAE,cAAW,OAAiC,EAAE,EACpC;AACZ,KAAI,CAAC,EAAoB,EAAQ,CAE/B,QADA,GAAU,QACG;CAMf,IAAM,KAAU,MAAkC;AAC5C,OAAS,EAAM,WAAW,MAG9B,GAAQ,EACR,GAAU;IAEN,UAAqB;AAKzB,EAJI,MAAU,KAAA,KACZ,aAAa,EAAM,EAErB,EAAQ,oBAAoB,iBAAiB,EAAwB,EACrE,EAAQ,oBAAoB,oBAAoB,EAAwB;IAGpE,IAAQ,IACV,WAAW,GAAQ,EAAwB,EAAQ,GAAG,IAAI,GAC1D,KAAA;AAIJ,QAHA,EAAQ,iBAAiB,iBAAiB,EAAwB,EAClE,EAAQ,iBAAiB,oBAAoB,EAAwB,EAE9D"}
|