@zazz-ui/core 0.4.1 → 0.5.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.
- package/AUTHORING.md +158 -0
- package/CHANGELOG.md +345 -0
- package/README.md +55 -23
- package/dist/scroll-state-C8mA5gq6.js +1 -0
- package/dist/sri.json +124 -72
- package/dist/zazz.css +1 -1
- package/dist/zazz.js +1 -1
- package/editor/zazz.css-data.json +116794 -0
- package/editor/zazz.html-data.json +1683 -0
- package/editor/zazz.language-data.json +5001 -0
- package/editor/zazz.lint-data.json +152 -0
- package/package.json +12 -5
- package/src/base/_breakpoints.css +12 -0
- package/src/base/_layers.css +8 -9
- package/src/base/_properties-2xl.css +171 -0
- package/src/base/_properties-active.css +107 -0
- package/src/base/_properties-checked.css +107 -0
- package/src/base/_properties-current.css +107 -0
- package/src/base/_properties-disabled.css +107 -0
- package/src/base/_properties-focus-visible.css +107 -0
- package/src/base/_properties-focus-within.css +107 -0
- package/src/base/_properties-hover.css +107 -0
- package/src/base/_properties-lg.css +171 -0
- package/src/base/_properties-md.css +171 -0
- package/src/base/_properties-open.css +107 -0
- package/src/base/_properties-sm.css +171 -0
- package/src/base/_properties-starting.css +55 -0
- package/src/base/_properties-stuck.css +55 -0
- package/src/base/_properties-xl.css +171 -0
- package/src/base/_properties.css +555 -0
- package/src/base/_reset.css +67 -75
- package/src/base/_switches.css +145 -0
- package/src/base/_typography.css +437 -370
- package/src/base/_utilities-box.css +142 -0
- package/src/base/_utilities-color.css +290 -0
- package/src/base/_utilities-effects.css +235 -0
- package/src/base/_utilities-flow.css +312 -0
- package/src/base/_utilities-grid.css +143 -0
- package/src/base/_utilities-margin.css +376 -0
- package/src/base/_utilities-pseudo.css +426 -0
- package/src/base/_utilities-sizing.css +259 -0
- package/src/base/_utilities-spacing.css +190 -0
- package/src/base/_utilities-tier-2xl.css +93 -0
- package/src/base/_utilities-tier-active.css +61 -0
- package/src/base/_utilities-tier-checked.css +61 -0
- package/src/base/_utilities-tier-current.css +61 -0
- package/src/base/_utilities-tier-disabled.css +61 -0
- package/src/base/_utilities-tier-focus-visible.css +61 -0
- package/src/base/_utilities-tier-focus-within.css +61 -0
- package/src/base/_utilities-tier-hover.css +63 -0
- package/src/base/_utilities-tier-lg.css +93 -0
- package/src/base/_utilities-tier-md.css +93 -0
- package/src/base/_utilities-tier-open.css +61 -0
- package/src/base/_utilities-tier-sm.css +93 -0
- package/src/base/_utilities-tier-starting.css +35 -0
- package/src/base/_utilities-tier-stuck.css +114 -0
- package/src/base/_utilities-tier-xl.css +93 -0
- package/src/base/_utilities-typography.css +141 -0
- package/src/base/_variables.css +323 -372
- package/src/base/_view-transitions.css +10 -12
- package/src/base/command-score.d.ts.map +1 -1
- package/src/base/command-score.js +1 -2
- package/src/base/command-score.ts +1 -2
- package/src/base/dialog-lifecycle.js +1 -1
- package/src/base/dialog-lifecycle.ts +1 -1
- package/src/base/embla.d.ts +6 -7
- package/src/base/embla.d.ts.map +1 -1
- package/src/base/embla.js +89 -55
- package/src/base/embla.ts +89 -55
- package/src/base/hotkeys.d.ts +0 -5
- package/src/base/hotkeys.d.ts.map +1 -1
- package/src/base/hotkeys.ts +0 -5
- package/src/base/navigation.d.ts +12 -1
- package/src/base/navigation.d.ts.map +1 -1
- package/src/base/navigation.js +229 -86
- package/src/base/navigation.ts +224 -92
- package/src/base/reveal.js +14 -14
- package/src/base/reveal.ts +14 -14
- package/src/base/scroll-state.d.ts +21 -0
- package/src/base/scroll-state.d.ts.map +1 -0
- package/src/base/scroll-state.js +177 -0
- package/src/base/scroll-state.ts +188 -0
- package/src/base/signals.d.ts +1 -2
- package/src/base/signals.d.ts.map +1 -1
- package/src/base/signals.js +4 -6
- package/src/base/signals.ts +4 -6
- package/src/base/style-format.d.ts +33 -0
- package/src/base/style-format.d.ts.map +1 -0
- package/src/base/style-format.js +160 -0
- package/src/base/style-format.ts +180 -0
- package/src/base/typeahead.d.ts +19 -4
- package/src/base/typeahead.d.ts.map +1 -1
- package/src/base/typeahead.js +68 -21
- package/src/base/typeahead.ts +73 -23
- package/src/base/utilities.d.ts +188 -0
- package/src/base/utilities.d.ts.map +1 -0
- package/src/base/utilities.js +750 -0
- package/src/base/utilities.ts +865 -0
- package/src/base/utils.d.ts +3 -7
- package/src/base/utils.d.ts.map +1 -1
- package/src/base/utils.js +4 -8
- package/src/base/utils.ts +4 -8
- package/src/base/zazz-element.d.ts +14 -8
- package/src/base/zazz-element.d.ts.map +1 -1
- package/src/base/zazz-element.js +14 -8
- package/src/base/zazz-element.ts +15 -8
- package/src/globals.d.ts +1 -1
- package/src/head.d.ts +50 -4
- package/src/head.d.ts.map +1 -1
- package/src/head.js +119 -38
- package/src/head.ts +172 -41
- package/src/index.css +57 -14
- package/src/index.js +5 -0
- package/src/index.ts +6 -0
- package/src/manifest.d.ts +36 -5
- package/src/manifest.d.ts.map +1 -1
- package/src/manifest.js +150 -6
- package/src/manifest.ts +167 -9
- package/src/primitives/accordion/accordion.css +18 -17
- package/src/primitives/accordion/accordion.html +42 -9
- package/src/primitives/alert-dialog/alert-dialog.css +13 -13
- package/src/primitives/alert-dialog/alert-dialog.html +26 -12
- package/src/primitives/autocomplete/autocomplete-groups.html +64 -33
- package/src/primitives/autocomplete/autocomplete.css +43 -39
- package/src/primitives/autocomplete/autocomplete.d.ts +6 -5
- package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -1
- package/src/primitives/autocomplete/autocomplete.html +38 -26
- package/src/primitives/autocomplete/autocomplete.js +6 -5
- package/src/primitives/autocomplete/autocomplete.ts +6 -5
- package/src/primitives/avatar/avatar.html +110 -15
- package/src/primitives/badge/badge-icon.html +22 -8
- package/src/primitives/badge/badge.css +401 -128
- package/src/primitives/badge/badge.html +12 -6
- package/src/primitives/breadcrumbs/breadcrumbs.html +25 -5
- package/src/primitives/button/button-icon-only.html +17 -11
- package/src/primitives/button/button-icon.html +9 -3
- package/src/primitives/button/button.css +408 -164
- package/src/primitives/button/button.html +14 -7
- package/src/primitives/button-group/button-group-vertical.html +5 -5
- package/src/primitives/button-group/button-group.css +61 -31
- package/src/primitives/button-group/button-group.html +18 -12
- package/src/primitives/callout/callout.css +114 -0
- package/src/primitives/callout/callout.html +188 -0
- package/src/primitives/card/card-subgrid.html +249 -34
- package/src/primitives/card/card.css +125 -0
- package/src/primitives/card/card.html +141 -20
- package/src/primitives/carousel/carousel.css +30 -20
- package/src/primitives/carousel/carousel.d.ts +7 -10
- package/src/primitives/carousel/carousel.d.ts.map +1 -1
- package/src/primitives/carousel/carousel.html +420 -84
- package/src/primitives/carousel/carousel.js +1 -1
- package/src/primitives/carousel/carousel.ts +8 -11
- package/src/primitives/checkbox/checkbox-tasklist.html +6 -6
- package/src/primitives/checkbox/checkbox.css +98 -40
- package/src/primitives/checkbox/checkbox.d.ts.map +1 -1
- package/src/primitives/checkbox/checkbox.html +13 -8
- package/src/primitives/checkbox/checkbox.js +7 -9
- package/src/primitives/checkbox/checkbox.ts +7 -15
- package/src/primitives/combobox/combobox-multiselect.html +53 -33
- package/src/primitives/combobox/combobox.css +145 -122
- package/src/primitives/combobox/combobox.d.ts +12 -11
- package/src/primitives/combobox/combobox.d.ts.map +1 -1
- package/src/primitives/combobox/combobox.html +48 -28
- package/src/primitives/combobox/combobox.js +46 -51
- package/src/primitives/combobox/combobox.ts +48 -55
- package/src/primitives/command/command-actions.d.ts +2 -3
- package/src/primitives/command/command-actions.d.ts.map +1 -1
- package/src/primitives/command/command-actions.html +48 -33
- package/src/primitives/command/command-actions.js +12 -10
- package/src/primitives/command/command-actions.ts +12 -13
- package/src/primitives/command/command-dialog.html +49 -25
- package/src/primitives/command/command.css +52 -42
- package/src/primitives/command/command.d.ts +10 -7
- package/src/primitives/command/command.d.ts.map +1 -1
- package/src/primitives/command/command.html +95 -46
- package/src/primitives/command/command.js +30 -13
- package/src/primitives/command/command.ts +30 -12
- package/src/primitives/debug/audit-core.d.ts +64 -0
- package/src/primitives/debug/audit-core.d.ts.map +1 -0
- package/src/primitives/debug/audit-core.js +356 -0
- package/src/primitives/debug/audit-core.ts +535 -0
- package/src/primitives/debug/debug.d.ts +50 -0
- package/src/primitives/debug/debug.d.ts.map +1 -0
- package/src/primitives/debug/debug.js +168 -0
- package/src/primitives/debug/debug.ts +211 -0
- package/src/primitives/dialog/dialog-with-form.html +67 -45
- package/src/primitives/dialog/dialog.css +87 -61
- package/src/primitives/dialog/dialog.html +25 -17
- package/src/primitives/fields/fields.css +108 -134
- package/src/primitives/fields/fields.html +39 -0
- package/src/primitives/input/input-icon-leading.html +3 -3
- package/src/primitives/input/input-icon-trailing.html +3 -3
- package/src/primitives/input/input.css +87 -49
- package/src/primitives/input/input.html +15 -15
- package/src/primitives/input-group/input-group-password-group.html +15 -15
- package/src/primitives/input-group/input-group.css +118 -75
- package/src/primitives/input-group/input-group.html +42 -30
- package/src/primitives/kbd/kbd-group.html +15 -2
- package/src/primitives/kbd/kbd.css +44 -31
- package/src/primitives/kbd/kbd.html +7 -1
- package/src/primitives/layout/layout.css +159 -0
- package/src/primitives/layout/layout.html +35 -0
- package/src/primitives/lightbox/lightbox.css +178 -105
- package/src/primitives/lightbox/lightbox.d.ts.map +1 -1
- package/src/primitives/lightbox/lightbox.html +138 -166
- package/src/primitives/lightbox/lightbox.js +10 -13
- package/src/primitives/lightbox/lightbox.ts +12 -13
- package/src/primitives/menu/menu-interest.html +60 -18
- package/src/primitives/menu/menu.css +22 -17
- package/src/primitives/menu/menu.d.ts +5 -5
- package/src/primitives/menu/menu.html +195 -40
- package/src/primitives/menu/menu.js +8 -8
- package/src/primitives/menu/menu.ts +8 -8
- package/src/primitives/menubar/menubar-help-search.html +78 -32
- package/src/primitives/menubar/menubar.html +166 -38
- package/src/primitives/meter/meter.css +41 -38
- package/src/primitives/meter/meter.html +44 -9
- package/src/primitives/mobile-menu/mobile-menu.css +47 -40
- package/src/primitives/mobile-menu/mobile-menu.html +1460 -179
- package/src/primitives/navigation-menu/navigation-menu-featured.html +155 -33
- package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +222 -47
- package/src/primitives/navigation-menu/navigation-menu-interest.html +130 -38
- package/src/primitives/navigation-menu/navigation-menu-megamenu.html +402 -72
- package/src/primitives/navigation-menu/navigation-menu-simple.html +90 -40
- package/src/primitives/navigation-menu/navigation-menu.css +104 -106
- package/src/primitives/navigation-menu/navigation-menu.html +554 -158
- package/src/primitives/otp/otp.css +43 -44
- package/src/primitives/otp/otp.d.ts +4 -5
- package/src/primitives/otp/otp.d.ts.map +1 -1
- package/src/primitives/otp/otp.html +7 -6
- package/src/primitives/otp/otp.js +13 -18
- package/src/primitives/otp/otp.ts +12 -19
- package/src/primitives/password-group/password-group.css +132 -107
- package/src/primitives/password-group/password-group.d.ts.map +1 -1
- package/src/primitives/password-group/password-group.html +23 -16
- package/src/primitives/password-group/password-group.js +11 -12
- package/src/primitives/password-group/password-group.ts +11 -12
- package/src/primitives/popover/popover.css +88 -95
- package/src/primitives/popover/popover.html +18 -0
- package/src/primitives/progress/progress-indeterminate.html +1 -1
- package/src/primitives/progress/progress.css +34 -35
- package/src/primitives/progress/progress.html +18 -4
- package/src/primitives/prose/prose.html +19 -12
- package/src/primitives/radio/radio.css +83 -46
- package/src/primitives/radio/radio.html +16 -11
- package/src/primitives/reveal/reveal.css +37 -46
- package/src/primitives/reveal/reveal.html +15 -0
- package/src/primitives/scroll-fade/scroll-fade.css +115 -0
- package/src/primitives/scroll-fade/scroll-fade.html +69 -0
- package/src/primitives/select/multiselect.d.ts +8 -10
- package/src/primitives/select/multiselect.d.ts.map +1 -1
- package/src/primitives/select/multiselect.js +23 -27
- package/src/primitives/select/multiselect.ts +23 -29
- package/src/primitives/select/select-align.html +79 -16
- package/src/primitives/select/select-multiple.html +8 -4
- package/src/primitives/select/select-sides.html +104 -21
- package/src/primitives/select/select.css +297 -186
- package/src/primitives/select/select.html +24 -5
- package/src/primitives/separator/separator.css +15 -18
- package/src/primitives/separator/separator.html +37 -10
- package/src/primitives/slider/slider.css +48 -38
- package/src/primitives/slider/slider.html +9 -1
- package/src/primitives/style-guard/style-guard.d.ts +19 -0
- package/src/primitives/style-guard/style-guard.d.ts.map +1 -0
- package/src/primitives/style-guard/style-guard.js +125 -0
- package/src/primitives/style-guard/style-guard.ts +153 -0
- package/src/primitives/switch/switch.css +42 -33
- package/src/primitives/switch/switch.html +11 -6
- package/src/primitives/table/table-alternating.html +1 -1
- package/src/primitives/table/table-grid.html +5 -5
- package/src/primitives/table/table-size-sm.html +1 -1
- package/src/primitives/table/table.css +64 -61
- package/src/primitives/table/table.html +7 -7
- package/src/primitives/tabs/tabs.css +167 -166
- package/src/primitives/tabs/tabs.d.ts +10 -11
- package/src/primitives/tabs/tabs.d.ts.map +1 -1
- package/src/primitives/tabs/tabs.html +192 -36
- package/src/primitives/tabs/tabs.js +14 -15
- package/src/primitives/tabs/tabs.ts +14 -15
- package/src/primitives/textarea/textarea.css +69 -44
- package/src/primitives/textarea/textarea.html +3 -3
- package/src/primitives/toaster/toaster.css +90 -92
- package/src/primitives/toaster/toaster.d.ts +0 -6
- package/src/primitives/toaster/toaster.d.ts.map +1 -1
- package/src/primitives/toaster/toaster.html +22 -18
- package/src/primitives/toaster/toaster.js +64 -72
- package/src/primitives/toaster/toaster.ts +71 -87
- package/src/primitives/toggle/toggle.css +368 -153
- package/src/primitives/toggle/toggle.html +27 -9
- package/src/primitives/toggle-group/toggle-group-multiple.html +3 -3
- package/src/primitives/toggle-group/toggle-group-vertical.html +4 -4
- package/src/primitives/toggle-group/toggle-group.css +76 -26
- package/src/primitives/toggle-group/toggle-group.html +3 -3
- package/src/primitives/toolbar/toolbar.html +35 -13
- package/src/primitives/tooltip/tooltip-disabled.html +3 -3
- package/src/primitives/tooltip/tooltip-sides.html +36 -14
- package/src/primitives/tooltip/tooltip-with-kbd.html +5 -5
- package/src/primitives/tooltip/tooltip.css +111 -80
- package/src/primitives/tooltip/tooltip.html +3 -3
- package/src/primitives/utilities/aspect-ratio.html +51 -7
- package/src/primitives/utilities/basis.html +64 -11
- package/src/primitives/utilities/col-span.html +65 -9
- package/src/primitives/utilities/compose.html +48 -10
- package/src/primitives/utilities/flex-align.html +89 -19
- package/src/primitives/utilities/flex-direction.html +111 -13
- package/src/primitives/utilities/flex-grow.html +41 -7
- package/src/primitives/utilities/gap.html +158 -19
- package/src/primitives/utilities/grid-cols.html +75 -7
- package/src/primitives/utilities/grid-responsive.html +111 -12
- package/src/primitives/utilities/margin-auto.html +38 -7
- package/src/primitives/utilities/object-fit.html +75 -13
- package/src/primitives/utilities/order.html +40 -4
- package/src/primitives/utilities/overflow.html +74 -20
- package/src/primitives/utilities/padding-compose.html +67 -10
- package/src/primitives/utilities/padding.html +84 -13
- package/src/primitives/utilities/pile.html +29 -0
- package/src/primitives/utilities/position.html +65 -8
- package/src/primitives/utilities/responsive-flex.html +54 -7
- package/src/primitives/utilities/responsive-grid.html +115 -12
- package/src/primitives/utilities/size.html +120 -16
- package/src/primitives/utilities/width.html +123 -16
- package/examples/about.html +0 -583
- package/examples/components.html +0 -1028
- package/examples/forms.html +0 -504
- package/examples/index.html +0 -261
- package/examples/layout.html +0 -313
- package/examples/products.html +0 -839
- package/examples/responsive.html +0 -332
- package/src/base/_layout.css +0 -571
- package/src/base/_utilities.css +0 -6758
- package/src/primitives/utilities/grid-pile.html +0 -5
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* _view-transitions.css — Cross-document view transitions
|
|
3
3
|
*
|
|
4
4
|
* @layer variables, utilities
|
|
5
|
-
* @requires
|
|
5
|
+
* @requires _layers.css, _variables.css, _reset.css ([data-transition-layer] names)
|
|
6
6
|
* @uses ::view-transition-old/new — cross-document page transitions
|
|
7
7
|
* @uses @view-transition { navigation: auto } — enabled here, behind @supports
|
|
8
8
|
* @uses ::view-transition-group(toaster) — frozen group; excludes the toast
|
|
9
|
-
* stack (named in
|
|
9
|
+
* stack (named in toaster.css) from transition repaints
|
|
10
10
|
* @tokens --view-transition-* (@layer variables)
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
@layer
|
|
35
|
-
/*
|
|
34
|
+
@layer ui.utilities {
|
|
35
|
+
/* main is isolated from header/footer (see _reset.css view-transition-name) */
|
|
36
36
|
@media screen and (prefers-reduced-motion: no-preference) {
|
|
37
37
|
::view-transition-old(main-content) {
|
|
38
38
|
animation: global-view-transition--old var(--view-transition-duration)
|
|
@@ -53,20 +53,18 @@
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
/*
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
/* Keep header/footer snapshots above main so a taller main snapshot can't
|
|
57
|
+
paint over the chrome during the crossfade. Applies regardless of motion
|
|
58
|
+
preference. */
|
|
59
59
|
::view-transition-group(main-content) {
|
|
60
60
|
z-index: 1;
|
|
61
61
|
overflow: clip;
|
|
62
62
|
transform-origin: var(--view-transition-origin);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/* Toasts are
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
cross-document navigations can't cross-fade or repaint an active stack.
|
|
69
|
-
Applies regardless of motion preference. */
|
|
65
|
+
/* Toasts are chrome, not page content: pin the toaster's snapshot group
|
|
66
|
+
(named in toaster.css) above everything and never animate it, so
|
|
67
|
+
navigations can't cross-fade an active stack. */
|
|
70
68
|
::view-transition-group(toaster) {
|
|
71
69
|
z-index: 3;
|
|
72
70
|
animation: none;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-score.d.ts","sourceRoot":"","sources":["command-score.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-score.d.ts","sourceRoot":"","sources":["command-score.ts"],"names":[],"mappings":"AAgLA;;;;;;;;GAQG;AACH,iBAAS,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAG5F;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Vendored from cmdk's `command-score.ts` by @pacocoursey (MIT), itself
|
|
11
11
|
* adapted from Superhuman's `command-score` (MIT), which builds on Joshaven
|
|
12
|
-
* Potter's `string_score`.
|
|
13
|
-
* results match cmdk's ranking; only the module shape is Zazz's.
|
|
12
|
+
* Potter's `string_score`. Constants and recursion are kept verbatim.
|
|
14
13
|
*
|
|
15
14
|
* @see https://github.com/pacocoursey/cmdk
|
|
16
15
|
* @see https://github.com/superhuman/command-score
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Vendored from cmdk's `command-score.ts` by @pacocoursey (MIT), itself
|
|
12
12
|
* adapted from Superhuman's `command-score` (MIT), which builds on Joshaven
|
|
13
|
-
* Potter's `string_score`.
|
|
14
|
-
* results match cmdk's ranking; only the module shape is Zazz's.
|
|
13
|
+
* Potter's `string_score`. Constants and recursion are kept verbatim.
|
|
15
14
|
*
|
|
16
15
|
* @see https://github.com/pacocoursey/cmdk
|
|
17
16
|
* @see https://github.com/superhuman/command-score
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @fileoverview Single owner of `<dialog>` visibility for the kit.
|
|
4
4
|
* @description Watches every dialog on the page and re-emits its lifecycle as
|
|
5
|
-
* two **bubbling** events dispatched on the dialog itself
|
|
5
|
+
* two **bubbling** events dispatched on the dialog itself:
|
|
6
6
|
*
|
|
7
7
|
* - `zazz:dialog-open`: the `open` attribute was added (works for both
|
|
8
8
|
* `showModal()` and `show()`, and for invoker commands).
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview Single owner of `<dialog>` visibility for the kit.
|
|
5
5
|
* @description Watches every dialog on the page and re-emits its lifecycle as
|
|
6
|
-
* two **bubbling** events dispatched on the dialog itself
|
|
6
|
+
* two **bubbling** events dispatched on the dialog itself:
|
|
7
7
|
*
|
|
8
8
|
* - `zazz:dialog-open`: the `open` attribute was added (works for both
|
|
9
9
|
* `showModal()` and `show()`, and for invoker commands).
|
package/src/base/embla.d.ts
CHANGED
|
@@ -8,15 +8,14 @@ import type { EmblaCarouselType } from "embla-carousel";
|
|
|
8
8
|
*/
|
|
9
9
|
declare function parseCarouselPlugins(value: string | null): string[];
|
|
10
10
|
/**
|
|
11
|
-
* @description
|
|
11
|
+
* @description Sets `data-carousel-state="active"` on the node at `selected` and clears it
|
|
12
12
|
* from every other node: the shared "which one is current" marker used by
|
|
13
13
|
* both dot pagination and thumb navigation.
|
|
14
14
|
*
|
|
15
15
|
* @param nodes - Candidate nodes, in slide order.
|
|
16
16
|
* @param selected - The active index.
|
|
17
|
-
* @param options - Set `ariaCurrent` to also toggle `aria-current` (
|
|
18
|
-
*
|
|
19
|
-
* as their `.is-active` state is purely visual pagination).
|
|
17
|
+
* @param options - Set `ariaCurrent` to also toggle `aria-current` (thumbs only;
|
|
18
|
+
* dot pagination is purely visual).
|
|
20
19
|
* @private
|
|
21
20
|
*/
|
|
22
21
|
declare function setActiveIndex(nodes: readonly HTMLElement[], selected: number, options?: {
|
|
@@ -54,8 +53,8 @@ declare const addTogglethumbsActive: (emblaApiMain: EmblaCarouselType, emblaApiT
|
|
|
54
53
|
* skips roots that are already initialized or inside a closed dialog (no
|
|
55
54
|
* measurable viewport until open).
|
|
56
55
|
*
|
|
57
|
-
* Called by `initEmblaCarousels()` for
|
|
58
|
-
* the `<ui-carousel>` web component
|
|
56
|
+
* Called by `initEmblaCarousels()` for attribute-form (`[data-ui~="carousel"]`) markup and by
|
|
57
|
+
* the `<ui-carousel>` web component on connect.
|
|
59
58
|
*
|
|
60
59
|
* @param emblaNode - The carousel root element.
|
|
61
60
|
*/
|
|
@@ -63,7 +62,7 @@ declare function initEmblaRoot(emblaNode: Element): void;
|
|
|
63
62
|
/**
|
|
64
63
|
* @description Initializes all Embla carousels within a scope.
|
|
65
64
|
*
|
|
66
|
-
* Discovers carousel elements via `:is(ui-carousel,
|
|
65
|
+
* Discovers carousel elements via `:is(ui-carousel, [data-ui~="carousel"])` and configures them
|
|
67
66
|
* based on their data attributes. Roots managed by the `<ui-carousel>` web
|
|
68
67
|
* component are skipped: they initialize themselves via `connectedCallback()`.
|
|
69
68
|
*
|
package/src/base/embla.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embla.d.ts","sourceRoot":"","sources":["embla.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"embla.d.ts","sourceRoot":"","sources":["embla.ts"],"names":[],"mappings":"AA6EA,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,gBAAgB,CAAC;AAa3F;;;;;;GAMG;AACH,iBAAS,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,EAAE,CAG5D;AAwED;;;;;;;;;;GAUG;AACH,iBAAS,cAAc,CACrB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,IAAI,CAWN;AAID;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,aACpB,iBAAiB,YACjB,OAAO,WACR,WAAW,KACnB,CAAC,MAAM,IAAI,CAAC,GAAG,SAqDjB,CAAC;AAIF;;;;;;GAMG;AACH,QAAA,MAAM,qBAAqB,iBACX,iBAAiB,iBAChB,iBAAiB,WACvB,WAAW,SAOrB,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,qBAAqB,iBACX,iBAAiB,iBAChB,iBAAiB,SAiBjC,CAAC;AAmJF;;;;;;;;;;;;GAYG;AACH,iBAAS,aAAa,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAqI/C;AAED;;;;;;;;GAQG;AACH,iBAAS,kBAAkB,CAAC,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAW5D;AAuGD;;;;;;;;;GASG;AACH,QAAA,MAAM,SAAS;;;;;;CAMd,CAAC;AA2EF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,oBAAoB,EAAE,CAAC"}
|
package/src/base/embla.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @fileoverview Embla Carousel initialization and controls.
|
|
4
|
-
* @description Discovers carousel roots (`<ui-carousel>` or
|
|
4
|
+
* @description Discovers carousel roots (`<ui-carousel>` or `[data-ui~="carousel"]`),
|
|
5
5
|
* initializes Embla instances with optional plugins, and wires navigation,
|
|
6
6
|
* keyboard, and dialog-open behaviors (subscribing to `zazz:dialog-open`
|
|
7
7
|
* from base/dialog-lifecycle.ts; lightbox choreography lives in lightbox.ts).
|
|
8
8
|
*
|
|
9
|
-
* Structure: root is the element
|
|
10
|
-
* - root (`<ui-carousel>` |
|
|
9
|
+
* Structure: root is the element itself; parts are slots (`data-carousel-slot="<part>"`):
|
|
10
|
+
* - root (`<ui-carousel>` | `[data-ui~="carousel"]`): Carousel container; holds all config attributes
|
|
11
11
|
* - `carousel-viewport`: Visible window (required)
|
|
12
12
|
* - `carousel-container`: Slides flex track
|
|
13
13
|
* - `carousel-slide`: Individual slide
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - `carousel-dots` / `carousel-dot`: Dot pagination container and template dot (optional)
|
|
16
16
|
* - `carousel-thumbs`: Linked thumb carousel container (optional)
|
|
17
17
|
*
|
|
18
|
-
* thumb navigation (on `data-slot="
|
|
18
|
+
* thumb navigation (on `data-carousel-slot="thumbs"`):
|
|
19
19
|
* - `data-carousel-thumbs-*`: thumb carousel options (defaults: containScroll keepSnaps, dragFree true)
|
|
20
20
|
* - Syncs with the main carousel in the same root
|
|
21
21
|
*
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* - `data-carousel-start-index`: Set on root by script; consumed when dialog opens
|
|
26
26
|
* - `data-carousel-keyboard`: Set to `"false"` to disable ArrowLeft/ArrowRight navigation
|
|
27
27
|
*
|
|
28
|
-
* Configuration (on the carousel root: `<ui-carousel>` or
|
|
28
|
+
* Configuration (on the carousel root: `<ui-carousel>` or `[data-ui~="carousel"]`):
|
|
29
29
|
* - `data-carousel-*`: Core Embla options
|
|
30
30
|
* - `data-carousel-plugins`: Space-separated plugin slugs (`autoplay`, `auto-scroll`, `class-names`)
|
|
31
31
|
* - `data-carousel-autoplay-*`: Autoplay plugin options (requires `autoplay` in plugins)
|
|
@@ -54,24 +54,23 @@
|
|
|
54
54
|
* data-carousel-plugins="class-names" data-carousel-class-names-snapped="is-snapped"
|
|
55
55
|
*
|
|
56
56
|
* @example Barebones carousel (4 text slides; auto-inits on DOMContentLoaded):
|
|
57
|
-
* <div
|
|
58
|
-
* <div data-slot="
|
|
59
|
-
* <div data-slot="
|
|
60
|
-
* <div data-slot="
|
|
61
|
-
* <div data-slot="
|
|
62
|
-
* <div data-slot="
|
|
63
|
-
* <div data-slot="
|
|
57
|
+
* <div data-ui="carousel">
|
|
58
|
+
* <div data-carousel-slot="viewport">
|
|
59
|
+
* <div data-carousel-slot="container">
|
|
60
|
+
* <div data-carousel-slot="slide">Slide 1</div>
|
|
61
|
+
* <div data-carousel-slot="slide">Slide 2</div>
|
|
62
|
+
* <div data-carousel-slot="slide">Slide 3</div>
|
|
63
|
+
* <div data-carousel-slot="slide">Slide 4</div>
|
|
64
64
|
* </div>
|
|
65
65
|
* </div>
|
|
66
|
-
* <button type="button" data-slot="
|
|
67
|
-
* <button type="button" data-slot="
|
|
66
|
+
* <button type="button" data-carousel-slot="prev">Prev</button>
|
|
67
|
+
* <button type="button" data-carousel-slot="next">Next</button>
|
|
68
68
|
* </div>
|
|
69
69
|
*/
|
|
70
70
|
import { Utils } from "./utils.js";
|
|
71
71
|
import { registerRefresh } from "./zazz-element.js";
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
// node_modules in tests/bundlers. No more UMD globals, no tag-order contract.
|
|
72
|
+
// Bare specifiers resolve through the page's import map in browsers (pinned
|
|
73
|
+
// jsDelivr URLs; see `head.ts`) and through node_modules in tests/bundlers.
|
|
75
74
|
import EmblaCarousel from "embla-carousel";
|
|
76
75
|
import EmblaCarouselAutoplay from "embla-carousel-autoplay";
|
|
77
76
|
import EmblaCarouselAutoScroll from "embla-carousel-auto-scroll";
|
|
@@ -101,10 +100,8 @@ const PLUGIN_BY_SLUG = {
|
|
|
101
100
|
* @description Reads a node's prefixed `data-carousel-*` attributes as an
|
|
102
101
|
* options object of the shape Embla (or one of its plugins) expects.
|
|
103
102
|
*
|
|
104
|
-
* Attributes are strings, so the
|
|
105
|
-
*
|
|
106
|
-
* here with its justification (Embla validates its own options at runtime)
|
|
107
|
-
* instead of being repeated at every call site.
|
|
103
|
+
* Attributes are strings, so the single type assertion into Embla's option
|
|
104
|
+
* types lives here (Embla validates its own options at runtime).
|
|
108
105
|
*
|
|
109
106
|
* @param node - Element carrying the configuration attributes.
|
|
110
107
|
* @param prefix - Attribute prefix, e.g. `"data-carousel-autoplay-"`.
|
|
@@ -116,21 +113,51 @@ function readCarouselOptions(node, prefix) {
|
|
|
116
113
|
}
|
|
117
114
|
// --- Active-index sync ---
|
|
118
115
|
/**
|
|
119
|
-
* @description
|
|
116
|
+
* @description Adds or removes one token of an element's `data-carousel-state`
|
|
117
|
+
* list, leaving the other tokens in place.
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
function setCarouselState(node, token, on) {
|
|
121
|
+
const tokens = (node.getAttribute("data-carousel-state") ?? "").split(/\s+/).filter(Boolean);
|
|
122
|
+
const next = on ? [...new Set([...tokens, token])] : tokens.filter((t) => t !== token);
|
|
123
|
+
if (next.length)
|
|
124
|
+
node.setAttribute("data-carousel-state", next.join(" "));
|
|
125
|
+
else
|
|
126
|
+
node.removeAttribute("data-carousel-state");
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @description Mirrors Embla's view state onto the slides as `data-carousel-state`
|
|
130
|
+
* tokens: `in-view` for slides inside the viewport and `snapped` for the slides
|
|
131
|
+
* of the selected snap (what the ClassNames plugin exposes as classes).
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
function bindSlideStates(emblaApi) {
|
|
135
|
+
const update = () => {
|
|
136
|
+
const slides = emblaApi.slideNodes();
|
|
137
|
+
const inView = new Set(emblaApi.slidesInView());
|
|
138
|
+
const snapped = new Set(emblaApi.internalEngine().slideRegistry[emblaApi.selectedScrollSnap()] ?? []);
|
|
139
|
+
slides.forEach((slide, index) => {
|
|
140
|
+
setCarouselState(slide, "in-view", inView.has(index));
|
|
141
|
+
setCarouselState(slide, "snapped", snapped.has(index));
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
emblaApi.on("init", update).on("reInit", update).on("select", update).on("slidesInView", update);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @description Sets `data-carousel-state="active"` on the node at `selected` and clears it
|
|
120
148
|
* from every other node: the shared "which one is current" marker used by
|
|
121
149
|
* both dot pagination and thumb navigation.
|
|
122
150
|
*
|
|
123
151
|
* @param nodes - Candidate nodes, in slide order.
|
|
124
152
|
* @param selected - The active index.
|
|
125
|
-
* @param options - Set `ariaCurrent` to also toggle `aria-current` (
|
|
126
|
-
*
|
|
127
|
-
* as their `.is-active` state is purely visual pagination).
|
|
153
|
+
* @param options - Set `ariaCurrent` to also toggle `aria-current` (thumbs only;
|
|
154
|
+
* dot pagination is purely visual).
|
|
128
155
|
* @private
|
|
129
156
|
*/
|
|
130
157
|
function setActiveIndex(nodes, selected, options = {}) {
|
|
131
158
|
nodes.forEach((node, idx) => {
|
|
132
159
|
const active = idx === selected;
|
|
133
|
-
node
|
|
160
|
+
setCarouselState(node, "active", active);
|
|
134
161
|
if (!options.ariaCurrent)
|
|
135
162
|
return;
|
|
136
163
|
if (active) {
|
|
@@ -153,7 +180,7 @@ function setActiveIndex(nodes, selected, options = {}) {
|
|
|
153
180
|
const addDotBtnsAndClickHandlers = (emblaApi, dotsNode, signal) => {
|
|
154
181
|
if (!dotsNode)
|
|
155
182
|
return;
|
|
156
|
-
const templateDot = dotsNode.querySelector('[data-slot~="
|
|
183
|
+
const templateDot = dotsNode.querySelector('[data-carousel-slot~="dot"]');
|
|
157
184
|
if (!templateDot)
|
|
158
185
|
return;
|
|
159
186
|
let dotNodes = [];
|
|
@@ -353,8 +380,8 @@ function initCommandDragGuard() {
|
|
|
353
380
|
* skips roots that are already initialized or inside a closed dialog (no
|
|
354
381
|
* measurable viewport until open).
|
|
355
382
|
*
|
|
356
|
-
* Called by `initEmblaCarousels()` for
|
|
357
|
-
* the `<ui-carousel>` web component
|
|
383
|
+
* Called by `initEmblaCarousels()` for attribute-form (`[data-ui~="carousel"]`) markup and by
|
|
384
|
+
* the `<ui-carousel>` web component on connect.
|
|
358
385
|
*
|
|
359
386
|
* @param emblaNode - The carousel root element.
|
|
360
387
|
*/
|
|
@@ -365,13 +392,13 @@ function initEmblaRoot(emblaNode) {
|
|
|
365
392
|
if (emblaNode.closest("dialog:not([open])"))
|
|
366
393
|
return;
|
|
367
394
|
emblaNode.setAttribute("data-carousel-init", "");
|
|
368
|
-
const emblathumbsNode = emblaNode.querySelector('[data-slot~="
|
|
395
|
+
const emblathumbsNode = emblaNode.querySelector('[data-carousel-slot~="thumbs"]');
|
|
369
396
|
const emblaViewportNode = emblathumbsNode
|
|
370
|
-
? emblaNode.querySelector('[data-slot~="
|
|
371
|
-
: emblaNode.querySelector('[data-slot~="
|
|
372
|
-
const emblaPrevButtonNode = emblaNode.querySelector('[data-slot~="
|
|
373
|
-
const emblaNextButtonNode = emblaNode.querySelector('[data-slot~="
|
|
374
|
-
const emblaDotsNode = emblaNode.querySelector('[data-slot~="
|
|
397
|
+
? emblaNode.querySelector('[data-carousel-slot~="viewport"]:not([data-carousel-slot~="thumbs"] *)')
|
|
398
|
+
: emblaNode.querySelector('[data-carousel-slot~="viewport"]');
|
|
399
|
+
const emblaPrevButtonNode = emblaNode.querySelector('[data-carousel-slot~="prev"]');
|
|
400
|
+
const emblaNextButtonNode = emblaNode.querySelector('[data-carousel-slot~="next"]');
|
|
401
|
+
const emblaDotsNode = emblaNode.querySelector('[data-carousel-slot~="dots"]');
|
|
375
402
|
if (!emblaViewportNode)
|
|
376
403
|
return;
|
|
377
404
|
if (!emblaViewportNode.hasAttribute("tabindex")) {
|
|
@@ -393,7 +420,6 @@ function initEmblaRoot(emblaNode) {
|
|
|
393
420
|
// single snap Embla still rubber-bands on drag, which feels broken. The
|
|
394
421
|
// callback re-evaluates on every pointer down, so it stays correct across
|
|
395
422
|
// resizes/reInit. Respect an explicit data-carousel-watch-drag override.
|
|
396
|
-
// @see https://github.com/davidjerleke/embla-carousel/issues/416
|
|
397
423
|
if (!("watchDrag" in apiOptions)) {
|
|
398
424
|
apiOptions.watchDrag = (api) => api.canScrollPrev() || api.canScrollNext();
|
|
399
425
|
}
|
|
@@ -408,6 +434,16 @@ function initEmblaRoot(emblaNode) {
|
|
|
408
434
|
}
|
|
409
435
|
// The options come from untyped data attributes; Embla validates at runtime.
|
|
410
436
|
const emblaApi = EmblaCarousel(emblaViewportNode, apiOptions, plugins);
|
|
437
|
+
// Drag state is a data-carousel-state token on the viewport.
|
|
438
|
+
emblaApi.on("pointerDown", () => {
|
|
439
|
+
if (emblaViewportNode)
|
|
440
|
+
setCarouselState(emblaViewportNode, "dragging", true);
|
|
441
|
+
});
|
|
442
|
+
emblaApi.on("pointerUp", () => {
|
|
443
|
+
if (emblaViewportNode)
|
|
444
|
+
setCarouselState(emblaViewportNode, "dragging", false);
|
|
445
|
+
});
|
|
446
|
+
bindSlideStates(emblaApi);
|
|
411
447
|
emblaNode._emblaApi = emblaApi;
|
|
412
448
|
// One controller per root scopes every carousel listener below; the owner
|
|
413
449
|
// (`<ui-carousel>` disconnectedCallback) aborts it on teardown so the DOM
|
|
@@ -426,11 +462,11 @@ function initEmblaRoot(emblaNode) {
|
|
|
426
462
|
}
|
|
427
463
|
// Any command-bearing slide (e.g. a lightbox stage slide that opens the
|
|
428
464
|
// dialog) needs its click suppressed when it was really a drag.
|
|
429
|
-
if (emblaNode.querySelector('[data-slot~="
|
|
430
|
-
bindDragClickSuppression(emblaNode, emblaApi, '[data-slot~="
|
|
465
|
+
if (emblaNode.querySelector('[data-carousel-slot~="slide"][commandfor]')) {
|
|
466
|
+
bindDragClickSuppression(emblaNode, emblaApi, '[data-carousel-slot~="slide"][commandfor]', { dragThresholdPx: 14 }, signal);
|
|
431
467
|
}
|
|
432
468
|
if (emblathumbsNode) {
|
|
433
|
-
const emblathumbsViewportNode = emblathumbsNode.querySelector('[data-slot~="
|
|
469
|
+
const emblathumbsViewportNode = emblathumbsNode.querySelector('[data-carousel-slot~="viewport"]');
|
|
434
470
|
if (emblathumbsViewportNode) {
|
|
435
471
|
const thumbDefaults = { containScroll: "keepSnaps", dragFree: true };
|
|
436
472
|
const thumbOptions = readCarouselOptions(emblathumbsNode, "data-carousel-thumbs-");
|
|
@@ -441,14 +477,14 @@ function initEmblaRoot(emblaNode) {
|
|
|
441
477
|
emblaNode._emblaApiThumb = emblaApiThumb;
|
|
442
478
|
addThumbClickHandlers(emblaApi, emblaApiThumb, signal);
|
|
443
479
|
addTogglethumbsActive(emblaApi, emblaApiThumb);
|
|
444
|
-
bindDragClickSuppression(emblathumbsNode, emblaApiThumb, '[data-slot~="
|
|
480
|
+
bindDragClickSuppression(emblathumbsNode, emblaApiThumb, '[data-carousel-slot~="slide"]', {}, signal);
|
|
445
481
|
}
|
|
446
482
|
}
|
|
447
483
|
}
|
|
448
484
|
/**
|
|
449
485
|
* @description Initializes all Embla carousels within a scope.
|
|
450
486
|
*
|
|
451
|
-
* Discovers carousel elements via `:is(ui-carousel,
|
|
487
|
+
* Discovers carousel elements via `:is(ui-carousel, [data-ui~="carousel"])` and configures them
|
|
452
488
|
* based on their data attributes. Roots managed by the `<ui-carousel>` web
|
|
453
489
|
* component are skipped: they initialize themselves via `connectedCallback()`.
|
|
454
490
|
*
|
|
@@ -456,7 +492,7 @@ function initEmblaRoot(emblaNode) {
|
|
|
456
492
|
*/
|
|
457
493
|
function initEmblaCarousels(scope) {
|
|
458
494
|
const root = scope || document;
|
|
459
|
-
const emblaRoots = root.querySelectorAll(
|
|
495
|
+
const emblaRoots = root.querySelectorAll(':is(ui-carousel, [data-ui~="carousel"])');
|
|
460
496
|
emblaRoots.forEach(function (emblaNode) {
|
|
461
497
|
// <ui-carousel> elements own their lifecycle (init on connect, destroy
|
|
462
498
|
// on disconnect); double-initializing would leak a second Embla instance.
|
|
@@ -468,7 +504,7 @@ function initEmblaCarousels(scope) {
|
|
|
468
504
|
// --- Dialog open subscription ---
|
|
469
505
|
/**
|
|
470
506
|
* @description Reacts to dialogs opening (via `zazz:dialog-open` from
|
|
471
|
-
* base/dialog-lifecycle.ts
|
|
507
|
+
* base/dialog-lifecycle.ts) with the carousel-domain work:
|
|
472
508
|
* initializes class-form roots that deferred while the dialog was
|
|
473
509
|
* `display: none`, applies a stored `data-carousel-start-index`, and focuses
|
|
474
510
|
* the viewport for keyboard navigation.
|
|
@@ -482,14 +518,14 @@ function initDialogOpenSubscription() {
|
|
|
482
518
|
return;
|
|
483
519
|
const dialog = e.target;
|
|
484
520
|
initEmblaCarousels(dialog);
|
|
485
|
-
const roots = dialog.querySelectorAll(
|
|
521
|
+
const roots = dialog.querySelectorAll(':is(ui-carousel, [data-ui~="carousel"])');
|
|
486
522
|
roots.forEach(function (root) {
|
|
487
523
|
const startIndex = root.getAttribute("data-carousel-start-index");
|
|
488
524
|
if (startIndex != null && root._emblaApi) {
|
|
489
525
|
root._emblaApi.scrollTo(Number(startIndex), true);
|
|
490
526
|
root.removeAttribute("data-carousel-start-index");
|
|
491
527
|
}
|
|
492
|
-
const viewport = root.querySelector('[data-slot~="
|
|
528
|
+
const viewport = root.querySelector('[data-carousel-slot~="viewport"]');
|
|
493
529
|
if (viewport instanceof HTMLElement) {
|
|
494
530
|
viewport.focus({ preventScroll: true });
|
|
495
531
|
}
|
|
@@ -509,12 +545,12 @@ function initDialogOpenSubscription() {
|
|
|
509
545
|
function getActiveEmblaRoot() {
|
|
510
546
|
const openDialog = document.querySelector("dialog[open]");
|
|
511
547
|
if (openDialog) {
|
|
512
|
-
const dialogRoot = openDialog.querySelector(
|
|
548
|
+
const dialogRoot = openDialog.querySelector(':is(ui-carousel, [data-ui~="carousel"])[data-carousel-init]');
|
|
513
549
|
if (dialogRoot?._emblaApi && dialogRoot.getAttribute("data-carousel-keyboard") !== "false") {
|
|
514
550
|
return dialogRoot;
|
|
515
551
|
}
|
|
516
552
|
}
|
|
517
|
-
const focusedRoot = document.activeElement?.closest(
|
|
553
|
+
const focusedRoot = document.activeElement?.closest(':is(ui-carousel, [data-ui~="carousel"])[data-carousel-init]');
|
|
518
554
|
if (focusedRoot?._emblaApi && focusedRoot.getAttribute("data-carousel-keyboard") !== "false") {
|
|
519
555
|
return focusedRoot;
|
|
520
556
|
}
|
|
@@ -576,19 +612,19 @@ const EmblaInit = {
|
|
|
576
612
|
* @description Stores or applies a start slide index from `[data-carousel-start]` triggers.
|
|
577
613
|
*
|
|
578
614
|
* Clicking an element with `data-carousel-start="N"` stores that index on the target
|
|
579
|
-
* carousel (found via `commandfor` → dialog → `:is(ui-carousel,
|
|
615
|
+
* carousel (found via `commandfor` → dialog → `:is(ui-carousel, [data-ui~="carousel"])`). The dialog
|
|
580
616
|
* open observer scrolls to it on open.
|
|
581
617
|
*/
|
|
582
618
|
function initEmblaStartLinks() {
|
|
583
619
|
document.addEventListener("click", function (e) {
|
|
584
620
|
if (!(e.target instanceof HTMLElement))
|
|
585
621
|
return;
|
|
586
|
-
const trigger = e.target.closest("[data-carousel-start], [data-slot~='
|
|
622
|
+
const trigger = e.target.closest("[data-carousel-start], [data-carousel-slot~='slide'][commandfor]");
|
|
587
623
|
if (!trigger)
|
|
588
624
|
return;
|
|
589
625
|
let index = trigger.getAttribute("data-carousel-start");
|
|
590
626
|
if (index == null && trigger.hasAttribute("commandfor")) {
|
|
591
|
-
const emblaRoot = trigger.closest(
|
|
627
|
+
const emblaRoot = trigger.closest(':is(ui-carousel, [data-ui~="carousel"])');
|
|
592
628
|
if (emblaRoot?._emblaApi) {
|
|
593
629
|
index = String(emblaRoot._emblaApi.selectedScrollSnap());
|
|
594
630
|
}
|
|
@@ -599,7 +635,7 @@ function initEmblaStartLinks() {
|
|
|
599
635
|
const dialog = document.getElementById(dialogId);
|
|
600
636
|
if (!dialog)
|
|
601
637
|
return;
|
|
602
|
-
const root = dialog.querySelector(
|
|
638
|
+
const root = dialog.querySelector(':is(ui-carousel, [data-ui~="carousel"])');
|
|
603
639
|
if (!root)
|
|
604
640
|
return;
|
|
605
641
|
if (root._emblaApi) {
|
|
@@ -612,7 +648,7 @@ function initEmblaStartLinks() {
|
|
|
612
648
|
}
|
|
613
649
|
// Auto-initialize when DOM is ready (only in browser environment)
|
|
614
650
|
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
615
|
-
// After
|
|
651
|
+
// After an in-page navigation swap, initialize class-form carousels in the new content
|
|
616
652
|
// (<ui-carousel> elements ride the swap via their own lifecycle; init() skips
|
|
617
653
|
// already-initialized roots and closed dialogs).
|
|
618
654
|
registerRefresh((scope) => initEmblaCarousels(scope));
|
|
@@ -634,10 +670,8 @@ if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
|
634
670
|
}
|
|
635
671
|
}
|
|
636
672
|
// Attach to window for the documented public API (`window.EmblaInit`), and export
|
|
637
|
-
// for module consumers (carousel.js / navigation.js import it via the
|
|
673
|
+
// for module consumers (carousel.js / navigation.js import it via the index.js entry).
|
|
638
674
|
if (typeof window !== "undefined") {
|
|
639
675
|
window.EmblaInit = EmblaInit;
|
|
640
676
|
}
|
|
641
|
-
// setActiveIndex and parseCarouselPlugins are exported for unit tests only;
|
|
642
|
-
// not part of the public API.
|
|
643
677
|
export { EmblaInit, setActiveIndex, parseCarouselPlugins };
|