@zazz-ui/core 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTHORING.md +158 -0
- package/CHANGELOG.md +331 -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 +53 -25
- 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 +71 -23
- 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
package/src/base/navigation.ts
CHANGED
|
@@ -3,49 +3,215 @@
|
|
|
3
3
|
import { refreshAll } from "./zazz-element.ts";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @fileoverview
|
|
7
|
-
* @description
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* @fileoverview Opt-in in-page navigation via the Navigation API.
|
|
7
|
+
* @description With `<html data-ui-navigation="swap">` on both the current and
|
|
8
|
+
* the destination page, a same-origin navigation fetches the destination and
|
|
9
|
+
* swaps the whole `<body>` in place instead of loading a new document. The
|
|
10
|
+
* browser still owns the URL and history; one `navigate` listener covers link
|
|
11
|
+
* clicks, back/forward, and programmatic navigations.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* Nothing persists implicitly. An element survives a swap only when it carries
|
|
14
|
+
* `data-ui-persist="<id>"` and the destination has an element with the same id:
|
|
15
|
+
* the live element takes the new one's place, keeping its DOM and state (a toast
|
|
16
|
+
* stack, a playing video, an open mini-cart). Everything else comes from the new
|
|
17
|
+
* page, so headers, footers and current-page links are never stale. A carried
|
|
18
|
+
* element keeps its scroll offsets, and its links take `aria-current` from the
|
|
19
|
+
* destination's copy, so a kept header still marks the current page.
|
|
18
20
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* An element whose content depends on the page (a section sidebar, a table of
|
|
22
|
+
* contents) should not persist; `data-ui-persist-scroll="<id>"` renders it from
|
|
23
|
+
* the destination and carries only its scroll offset. The window itself
|
|
24
|
+
* scrolls as the browser decides: to the top or the target for a new entry,
|
|
25
|
+
* restored on back/forward.
|
|
26
|
+
*
|
|
27
|
+
* Without the opt-in the browser navigates normally, animated by the CSS
|
|
28
|
+
* cross-document view transitions in `_view-transitions.css`. Reloads, hash
|
|
29
|
+
* changes, downloads and form posts are never intercepted.
|
|
25
30
|
*
|
|
26
31
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API
|
|
27
32
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/NavigateEvent/scroll
|
|
28
33
|
*/
|
|
29
34
|
|
|
35
|
+
/** The opt-in, on `<html>` of both pages. */
|
|
36
|
+
const SWAP = "swap";
|
|
37
|
+
|
|
38
|
+
/** True when `doc` opted in to in-page navigation. */
|
|
39
|
+
function optedIn(doc: Document): boolean {
|
|
40
|
+
return doc.documentElement.getAttribute("data-ui-navigation") === SWAP;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** `Element.moveBefore` keeps iframes, media and custom elements live; not in every browser yet. */
|
|
44
|
+
type Movable = Element & { moveBefore?: (node: Node, child: Node | null) => void };
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @description Records the scroll offsets of `root` and its scrolled
|
|
48
|
+
* descendants. A plain move (no `moveBefore()`) resets them to zero.
|
|
49
|
+
*
|
|
50
|
+
* @param root - A persisted element, still connected.
|
|
51
|
+
* @returns Each scrolled element with its `scrollTop` and `scrollLeft`.
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
function scrollOffsets(root: Element): [Element, number, number][] {
|
|
55
|
+
const offsets: [Element, number, number][] = [];
|
|
56
|
+
for (const el of [root, ...root.querySelectorAll("*")]) {
|
|
57
|
+
if (el.scrollTop || el.scrollLeft) offsets.push([el, el.scrollTop, el.scrollLeft]);
|
|
58
|
+
}
|
|
59
|
+
return offsets;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @description Gives the links in a persisted element the `aria-current` of
|
|
64
|
+
* their twins in the destination's copy, so a kept header or sidebar marks the
|
|
65
|
+
* new page. Links pair by `href`, in document order; a link with no twin is not
|
|
66
|
+
* current.
|
|
67
|
+
*
|
|
68
|
+
* @param keep - The live persisted element.
|
|
69
|
+
* @param slot - The destination's element with the same id.
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
function adoptCurrent(keep: Element, slot: Element): void {
|
|
73
|
+
const twins = new Map<string, Element[]>();
|
|
74
|
+
for (const link of slot.querySelectorAll("a[href], area[href]")) {
|
|
75
|
+
const href = link.getAttribute("href")!;
|
|
76
|
+
twins.set(href, [...(twins.get(href) ?? []), link]);
|
|
77
|
+
}
|
|
78
|
+
for (const link of keep.querySelectorAll("a[href], area[href]")) {
|
|
79
|
+
const twin = twins.get(link.getAttribute("href")!)?.shift();
|
|
80
|
+
const current = twin?.getAttribute("aria-current");
|
|
81
|
+
if (current == null) link.removeAttribute("aria-current");
|
|
82
|
+
else link.setAttribute("aria-current", current);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @description Replaces the current body with `next`, carrying over every
|
|
88
|
+
* `data-ui-persist` element whose id appears in both, scroll offsets included;
|
|
89
|
+
* links in a carried element take `aria-current` from the destination. A
|
|
90
|
+
* `data-ui-persist-scroll` element comes from `next` and takes the scroll
|
|
91
|
+
* offset of the current element with the same id. Returns the new body.
|
|
92
|
+
*
|
|
93
|
+
* @param next - The destination's parsed `<body>`.
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
function swapBody(next: HTMLElement): HTMLElement {
|
|
97
|
+
const current = document.body;
|
|
98
|
+
// Read every scroll offset now, while the layout holds one body: a read once
|
|
99
|
+
// both bodies are connected would lay out the doubled document.
|
|
100
|
+
const live = new Map<string, Element>();
|
|
101
|
+
const offsets: [Element, number, number][] = [];
|
|
102
|
+
for (const el of current.querySelectorAll("[data-ui-persist]")) {
|
|
103
|
+
const id = el.getAttribute("data-ui-persist");
|
|
104
|
+
if (id && !live.has(id)) live.set(id, el);
|
|
105
|
+
}
|
|
106
|
+
for (const keep of live.values()) offsets.push(...scrollOffsets(keep));
|
|
107
|
+
const scrolled = new Map<string, [number, number]>();
|
|
108
|
+
for (const el of current.querySelectorAll("[data-ui-persist-scroll]")) {
|
|
109
|
+
const id = el.getAttribute("data-ui-persist-scroll");
|
|
110
|
+
if (id && !scrolled.has(id)) scrolled.set(id, [el.scrollTop, el.scrollLeft]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const body = document.importNode(next, true);
|
|
114
|
+
const placeholders: [Element, Element][] = [];
|
|
115
|
+
for (const slot of body.querySelectorAll("[data-ui-persist]")) {
|
|
116
|
+
const keep = live.get(slot.getAttribute("data-ui-persist") ?? "");
|
|
117
|
+
if (keep) placeholders.push([slot, keep]);
|
|
118
|
+
}
|
|
119
|
+
for (const el of body.querySelectorAll("[data-ui-persist-scroll]")) {
|
|
120
|
+
const id = el.getAttribute("data-ui-persist-scroll") ?? "";
|
|
121
|
+
const offset = scrolled.get(id);
|
|
122
|
+
scrolled.delete(id);
|
|
123
|
+
if (offset) offsets.push([el, ...offset]);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Connect the new body beside the old one, move each live element into its
|
|
127
|
+
// slot while both are connected (moveBefore requires that, and then keeps the
|
|
128
|
+
// element's state: no disconnect, no iframe or media reset), then drop the old
|
|
129
|
+
// body. `document.body` is the first body, so it is the new one throughout.
|
|
130
|
+
// Scroll offsets are restored in the same task, before the view transition
|
|
131
|
+
// captures the new state, so a plain move never shows a jump.
|
|
132
|
+
current.before(body);
|
|
133
|
+
for (const [slot, keep] of placeholders) {
|
|
134
|
+
const parent = slot.parentNode as Movable | null;
|
|
135
|
+
if (!parent) continue;
|
|
136
|
+
adoptCurrent(keep, slot);
|
|
137
|
+
if (typeof parent.moveBefore === "function") parent.moveBefore(keep, slot);
|
|
138
|
+
else parent.insertBefore(keep, slot);
|
|
139
|
+
slot.remove();
|
|
140
|
+
}
|
|
141
|
+
current.remove();
|
|
142
|
+
for (const [el, top, left] of offsets) el.scrollTo({ top, left, behavior: "instant" });
|
|
143
|
+
return body;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @description Moves focus to the new page's primary heading so screen readers
|
|
148
|
+
* announce the navigation.
|
|
149
|
+
*
|
|
150
|
+
* @param body - The swapped-in body.
|
|
151
|
+
* @private
|
|
152
|
+
*/
|
|
153
|
+
function routeFocus(body: HTMLElement): void {
|
|
154
|
+
const main = body.querySelector("main");
|
|
155
|
+
const target = main?.querySelector("h1") ?? main ?? body;
|
|
156
|
+
if (!(target instanceof HTMLElement)) return;
|
|
157
|
+
if (!target.hasAttribute("tabindex")) target.tabIndex = -1;
|
|
158
|
+
target.focus({ preventScroll: true });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Navigations holding the instant-scroll override, and the value it replaced. */
|
|
162
|
+
let instantHolds = 0;
|
|
163
|
+
let savedScrollBehavior = "";
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @description Makes window scrolls instant until the returned release runs.
|
|
167
|
+
* Overlapping navigations share one override: the first saves `<html>`'s
|
|
168
|
+
* inline `scroll-behavior`, the last to release restores it.
|
|
169
|
+
*
|
|
170
|
+
* @returns The release; calling it again does nothing.
|
|
171
|
+
* @private
|
|
172
|
+
*/
|
|
173
|
+
function holdInstantScroll(): () => void {
|
|
174
|
+
const root = document.documentElement.style;
|
|
175
|
+
if (instantHolds++ === 0) {
|
|
176
|
+
savedScrollBehavior = root.scrollBehavior;
|
|
177
|
+
root.scrollBehavior = "auto";
|
|
178
|
+
}
|
|
179
|
+
let held = true;
|
|
180
|
+
return () => {
|
|
181
|
+
if (!held) return;
|
|
182
|
+
held = false;
|
|
183
|
+
if (--instantHolds === 0) root.scrollBehavior = savedScrollBehavior;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function isSameOrigin(url: string): boolean {
|
|
188
|
+
return new URL(url, location.href).origin === location.origin;
|
|
189
|
+
}
|
|
190
|
+
|
|
30
191
|
if ("navigation" in window) {
|
|
31
192
|
/**
|
|
32
|
-
* URL
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* inside the handler would re-enter this same listener, re-intercept, fail to
|
|
36
|
-
* find a usable `<main>` again, and loop forever. Cleared as soon as it's seen.
|
|
193
|
+
* URL handed back to the browser for a full load. The `navigate` listener
|
|
194
|
+
* skips it once, so `location.assign()` from inside the handler does not
|
|
195
|
+
* re-enter the interception and loop.
|
|
37
196
|
*/
|
|
38
197
|
let bypassUrl: string | null = null;
|
|
39
198
|
|
|
199
|
+
function fullLoad(url: string): void {
|
|
200
|
+
bypassUrl = url;
|
|
201
|
+
location.assign(url);
|
|
202
|
+
}
|
|
203
|
+
|
|
40
204
|
window.navigation.addEventListener("navigate", (e) => {
|
|
41
|
-
// A navigation we already chose to full-load: let the browser handle it.
|
|
42
205
|
if (bypassUrl !== null && e.destination.url === bypassUrl) {
|
|
43
206
|
bypassUrl = null;
|
|
44
207
|
return;
|
|
45
208
|
}
|
|
46
209
|
|
|
210
|
+
// A reload re-renders the whole document; it is never a swap.
|
|
47
211
|
if (
|
|
212
|
+
!optedIn(document) ||
|
|
48
213
|
!e.canIntercept ||
|
|
214
|
+
e.navigationType === "reload" ||
|
|
49
215
|
e.hashChange ||
|
|
50
216
|
e.downloadRequest !== null ||
|
|
51
217
|
e.formData !== null ||
|
|
@@ -58,94 +224,60 @@ if ("navigation" in window) {
|
|
|
58
224
|
async handler() {
|
|
59
225
|
let doc: Document;
|
|
60
226
|
try {
|
|
61
|
-
const res = await fetch(e.destination.url);
|
|
227
|
+
const res = await fetch(e.destination.url, { signal: e.signal });
|
|
62
228
|
if (!res.ok) throw new Error(res.statusText);
|
|
63
229
|
doc = new DOMParser().parseFromString(await res.text(), "text/html");
|
|
64
230
|
} catch {
|
|
65
|
-
|
|
231
|
+
// A newer navigation aborted this one; it must not swap in late.
|
|
232
|
+
if (e.signal.aborted) return;
|
|
233
|
+
fullLoad(e.destination.url); // network or HTTP failure
|
|
66
234
|
return;
|
|
67
235
|
}
|
|
236
|
+
if (e.signal.aborted) return;
|
|
68
237
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Bail to a full load when we can't safely swap in place:
|
|
73
|
-
// - either page lacks <main> (e.g. a legacy / non-Zazz page), or
|
|
74
|
-
// - the layout differs (retail ↔ portal ↔ utility), so the header and
|
|
75
|
-
// footer chrome — which lives outside <main> — must change too.
|
|
76
|
-
if (
|
|
77
|
-
!(newMain instanceof HTMLElement) ||
|
|
78
|
-
!(currentMain instanceof HTMLElement) ||
|
|
79
|
-
newMain.dataset.layout !== currentMain.dataset.layout
|
|
80
|
-
) {
|
|
81
|
-
fullReload(e.destination.url);
|
|
238
|
+
// The destination must opt in too; otherwise it gets a normal load.
|
|
239
|
+
if (!optedIn(doc) || !(doc.body instanceof HTMLElement)) {
|
|
240
|
+
fullLoad(e.destination.url);
|
|
82
241
|
return;
|
|
83
242
|
}
|
|
84
243
|
|
|
85
|
-
|
|
86
|
-
|
|
244
|
+
let body = document.body;
|
|
245
|
+
const update = () => {
|
|
246
|
+
body = swapBody(doc.body);
|
|
87
247
|
document.title = doc.title;
|
|
88
248
|
// Restore scroll while the new snapshot is captured so the transition
|
|
89
|
-
// animates from the
|
|
249
|
+
// animates from the right position instead of jumping afterwards.
|
|
90
250
|
e.scroll();
|
|
91
251
|
};
|
|
92
252
|
|
|
253
|
+
// The jumps are instant: under the reset's `scroll-behavior: smooth` the
|
|
254
|
+
// window would scroll in view of the live new snapshot. The browser may
|
|
255
|
+
// apply the scroll at the next layout, so the override holds until the
|
|
256
|
+
// transition is done (two frames without one).
|
|
257
|
+
const release = holdInstantScroll();
|
|
93
258
|
if (document.startViewTransition) {
|
|
94
|
-
|
|
259
|
+
try {
|
|
260
|
+
await document.startViewTransition(update).finished;
|
|
261
|
+
} finally {
|
|
262
|
+
release();
|
|
263
|
+
}
|
|
95
264
|
} else {
|
|
96
|
-
|
|
265
|
+
try {
|
|
266
|
+
update();
|
|
267
|
+
} finally {
|
|
268
|
+
requestAnimationFrame(() => requestAnimationFrame(release));
|
|
269
|
+
}
|
|
97
270
|
}
|
|
98
271
|
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
refreshAll(newMain);
|
|
104
|
-
routeFocus(newMain);
|
|
272
|
+
// Page-scoped modules (reveal, class-form carousels, …) registered
|
|
273
|
+
// refresh hooks; custom elements ride the swap on their own callbacks.
|
|
274
|
+
refreshAll(body);
|
|
275
|
+
routeFocus(body);
|
|
105
276
|
},
|
|
106
277
|
});
|
|
107
278
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
* @description Hands a navigation back to the browser for a full page load.
|
|
111
|
-
* Records the URL so the re-entrant `navigate` event skips interception
|
|
112
|
-
* instead of looping.
|
|
113
|
-
*
|
|
114
|
-
* @param url - The destination URL to load normally.
|
|
115
|
-
* @private
|
|
116
|
-
*/
|
|
117
|
-
function fullReload(url: string): void {
|
|
118
|
-
bypassUrl = url;
|
|
119
|
-
location.assign(url);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @description Routes focus to the primary heading in swapped main content.
|
|
124
|
-
*
|
|
125
|
-
* @param main - The newly inserted `<main>` element.
|
|
126
|
-
* @private
|
|
127
|
-
*/
|
|
128
|
-
function routeFocus(main: HTMLElement): void {
|
|
129
|
-
const target = main.querySelector("h1") ?? main;
|
|
130
|
-
if (!(target instanceof HTMLElement)) return;
|
|
131
|
-
|
|
132
|
-
if (!target.hasAttribute("tabindex")) {
|
|
133
|
-
target.tabIndex = -1;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
target.focus({ preventScroll: true });
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* @description Checks whether a URL shares the current document origin.
|
|
141
|
-
*
|
|
142
|
-
* @param url - The URL to compare.
|
|
143
|
-
* @returns True when the URL origin matches `location.origin`.
|
|
144
|
-
* @private
|
|
145
|
-
*/
|
|
146
|
-
function isSameOrigin(url: string): boolean {
|
|
147
|
-
return new URL(url, location.href).origin === location.origin;
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
console.warn("Navigation API not supported. That's okay, we'll just use a full page reload.");
|
|
279
|
+
} else if (optedIn(document)) {
|
|
280
|
+
console.warn("Navigation API not supported: data-ui-navigation falls back to full page loads.");
|
|
151
281
|
}
|
|
282
|
+
|
|
283
|
+
export { swapBody };
|
package/src/base/reveal.js
CHANGED
|
@@ -66,14 +66,14 @@ function parseCssTimeMs(value) {
|
|
|
66
66
|
*/
|
|
67
67
|
class Reveal {
|
|
68
68
|
/**
|
|
69
|
-
* @description Default config from `--ui-reveal-global-*` tokens in `
|
|
69
|
+
* @description Default config from `--ui-reveal-global-*` tokens in `reveal.css`.
|
|
70
70
|
*/
|
|
71
71
|
static #readDefaultConfig() {
|
|
72
72
|
return {
|
|
73
73
|
margin: "0px",
|
|
74
74
|
threshold: 0.2,
|
|
75
75
|
duration: getRootCssVar("--ui-reveal-global-duration") || "400ms",
|
|
76
|
-
ease: getRootCssVar("--ui-reveal-global-
|
|
76
|
+
ease: getRootCssVar("--ui-reveal-global-timing-function") || "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
77
77
|
wait: parseCssTimeMs(getRootCssVar("--ui-reveal-global-wait")),
|
|
78
78
|
distance: getRootCssVar("--ui-reveal-global-distance") || "1rem",
|
|
79
79
|
step: 80,
|
|
@@ -108,7 +108,7 @@ class Reveal {
|
|
|
108
108
|
observer = new IntersectionObserver((entries, obs) => {
|
|
109
109
|
entries.forEach((entry) => {
|
|
110
110
|
if (entry.isIntersecting) {
|
|
111
|
-
entry.target.
|
|
111
|
+
entry.target.setAttribute("data-reveal-state", "in-view");
|
|
112
112
|
obs.unobserve(entry.target);
|
|
113
113
|
}
|
|
114
114
|
});
|
|
@@ -172,7 +172,7 @@ class Reveal {
|
|
|
172
172
|
const dataset = groupElement.dataset;
|
|
173
173
|
const groupOptions = this.#getElementObserverOptions(groupElement);
|
|
174
174
|
const groupObserver = this.#getObserver(groupOptions);
|
|
175
|
-
const
|
|
175
|
+
const groupConfig = {
|
|
176
176
|
step: Math.max(0, parseInt(dataset.revealStep || this.config.step.toString(), 10) || 0),
|
|
177
177
|
duration: dataset.revealDuration
|
|
178
178
|
? Math.max(0, parseInt(dataset.revealDuration, 10) || 0)
|
|
@@ -183,24 +183,24 @@ class Reveal {
|
|
|
183
183
|
order: dataset.revealOrder,
|
|
184
184
|
};
|
|
185
185
|
const childrenArray = Array.from(groupElement.children);
|
|
186
|
-
const sequence =
|
|
186
|
+
const sequence = groupConfig.order === "reversed" ? childrenArray.reverse() : childrenArray;
|
|
187
187
|
if (supportsSiblingIndex) {
|
|
188
188
|
this.#setRevealProperties(groupElement, {
|
|
189
|
-
"--ui-reveal-stagger-base": `${
|
|
190
|
-
"--ui-reveal-stagger-step": `${
|
|
189
|
+
"--ui-reveal-stagger-base": `${groupConfig.baseWait}ms`,
|
|
190
|
+
"--ui-reveal-stagger-step": `${groupConfig.step}ms`,
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
sequence.forEach((child, i) => {
|
|
194
194
|
if (!(child instanceof HTMLElement))
|
|
195
195
|
return;
|
|
196
196
|
this.#setRevealProperties(child, {
|
|
197
|
-
"--ui-reveal-duration": this.#formatTime(
|
|
198
|
-
"--ui-reveal-ease":
|
|
197
|
+
"--ui-reveal-duration": this.#formatTime(groupConfig.duration),
|
|
198
|
+
"--ui-reveal-ease": groupConfig.ease,
|
|
199
199
|
// Fallback only: natively each child computes this in reveal.css.
|
|
200
200
|
"--ui-reveal-wait": supportsSiblingIndex
|
|
201
201
|
? null
|
|
202
|
-
: `${
|
|
203
|
-
"--ui-reveal-distance":
|
|
202
|
+
: `${groupConfig.baseWait + groupConfig.step * i}ms`,
|
|
203
|
+
"--ui-reveal-distance": groupConfig.distance,
|
|
204
204
|
"--ui-reveal-scale": dataset.revealScale || null,
|
|
205
205
|
});
|
|
206
206
|
groupObserver.observe(child);
|
|
@@ -239,7 +239,7 @@ class Reveal {
|
|
|
239
239
|
this.#observers.clear();
|
|
240
240
|
const rootStyle = document.documentElement.style;
|
|
241
241
|
rootStyle.setProperty("--ui-reveal-global-duration", this.#formatTime(this.config.duration));
|
|
242
|
-
rootStyle.setProperty("--ui-reveal-global-
|
|
242
|
+
rootStyle.setProperty("--ui-reveal-global-timing-function", this.config.ease);
|
|
243
243
|
rootStyle.setProperty("--ui-reveal-global-wait", this.#formatTime(this.config.wait));
|
|
244
244
|
rootStyle.setProperty("--ui-reveal-global-distance", this.config.distance);
|
|
245
245
|
rootStyle.setProperty("--ui-reveal-global-grow", this.config.grow.toString());
|
|
@@ -280,7 +280,7 @@ if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
|
280
280
|
else {
|
|
281
281
|
autoInit();
|
|
282
282
|
}
|
|
283
|
-
// After
|
|
283
|
+
// After an in-page navigation swap, re-scan the new content for [data-reveal] targets.
|
|
284
284
|
registerRefresh(() => Reveal.getAutoInstance()?.refresh());
|
|
285
285
|
/**
|
|
286
286
|
* @description Prevents automatic initialization on DOM ready.
|
|
@@ -298,7 +298,7 @@ if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
// Attach to window for the documented public API (`window.Reveal`, `new Reveal()`),
|
|
301
|
-
// and export for module consumers (navigation.js imports it via the
|
|
301
|
+
// and export for module consumers (navigation.js imports it via the index.js entry).
|
|
302
302
|
if (typeof window !== "undefined") {
|
|
303
303
|
window.Reveal = Reveal;
|
|
304
304
|
}
|
package/src/base/reveal.ts
CHANGED
|
@@ -108,14 +108,14 @@ class Reveal {
|
|
|
108
108
|
declare static getAutoInstance: () => Reveal | null;
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
* @description Default config from `--ui-reveal-global-*` tokens in `
|
|
111
|
+
* @description Default config from `--ui-reveal-global-*` tokens in `reveal.css`.
|
|
112
112
|
*/
|
|
113
113
|
static #readDefaultConfig(): RevealConfig {
|
|
114
114
|
return {
|
|
115
115
|
margin: "0px",
|
|
116
116
|
threshold: 0.2,
|
|
117
117
|
duration: getRootCssVar("--ui-reveal-global-duration") || "400ms",
|
|
118
|
-
ease: getRootCssVar("--ui-reveal-global-
|
|
118
|
+
ease: getRootCssVar("--ui-reveal-global-timing-function") || "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
119
119
|
wait: parseCssTimeMs(getRootCssVar("--ui-reveal-global-wait")),
|
|
120
120
|
distance: getRootCssVar("--ui-reveal-global-distance") || "1rem",
|
|
121
121
|
step: 80,
|
|
@@ -155,7 +155,7 @@ class Reveal {
|
|
|
155
155
|
observer = new IntersectionObserver((entries, obs) => {
|
|
156
156
|
entries.forEach((entry) => {
|
|
157
157
|
if (entry.isIntersecting) {
|
|
158
|
-
entry.target.
|
|
158
|
+
entry.target.setAttribute("data-reveal-state", "in-view");
|
|
159
159
|
obs.unobserve(entry.target);
|
|
160
160
|
}
|
|
161
161
|
});
|
|
@@ -228,7 +228,7 @@ class Reveal {
|
|
|
228
228
|
const groupOptions = this.#getElementObserverOptions(groupElement);
|
|
229
229
|
const groupObserver = this.#getObserver(groupOptions);
|
|
230
230
|
|
|
231
|
-
const
|
|
231
|
+
const groupConfig = {
|
|
232
232
|
step: Math.max(0, parseInt(dataset.revealStep || this.config.step.toString(), 10) || 0),
|
|
233
233
|
duration: dataset.revealDuration
|
|
234
234
|
? Math.max(0, parseInt(dataset.revealDuration, 10) || 0)
|
|
@@ -240,12 +240,12 @@ class Reveal {
|
|
|
240
240
|
};
|
|
241
241
|
|
|
242
242
|
const childrenArray = Array.from(groupElement.children);
|
|
243
|
-
const sequence =
|
|
243
|
+
const sequence = groupConfig.order === "reversed" ? childrenArray.reverse() : childrenArray;
|
|
244
244
|
|
|
245
245
|
if (supportsSiblingIndex) {
|
|
246
246
|
this.#setRevealProperties(groupElement, {
|
|
247
|
-
"--ui-reveal-stagger-base": `${
|
|
248
|
-
"--ui-reveal-stagger-step": `${
|
|
247
|
+
"--ui-reveal-stagger-base": `${groupConfig.baseWait}ms`,
|
|
248
|
+
"--ui-reveal-stagger-step": `${groupConfig.step}ms`,
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
|
|
@@ -253,13 +253,13 @@ class Reveal {
|
|
|
253
253
|
if (!(child instanceof HTMLElement)) return;
|
|
254
254
|
|
|
255
255
|
this.#setRevealProperties(child, {
|
|
256
|
-
"--ui-reveal-duration": this.#formatTime(
|
|
257
|
-
"--ui-reveal-ease":
|
|
256
|
+
"--ui-reveal-duration": this.#formatTime(groupConfig.duration),
|
|
257
|
+
"--ui-reveal-ease": groupConfig.ease,
|
|
258
258
|
// Fallback only: natively each child computes this in reveal.css.
|
|
259
259
|
"--ui-reveal-wait": supportsSiblingIndex
|
|
260
260
|
? null
|
|
261
|
-
: `${
|
|
262
|
-
"--ui-reveal-distance":
|
|
261
|
+
: `${groupConfig.baseWait + groupConfig.step * i}ms`,
|
|
262
|
+
"--ui-reveal-distance": groupConfig.distance,
|
|
263
263
|
"--ui-reveal-scale": dataset.revealScale || null,
|
|
264
264
|
});
|
|
265
265
|
|
|
@@ -305,7 +305,7 @@ class Reveal {
|
|
|
305
305
|
|
|
306
306
|
const rootStyle = document.documentElement.style;
|
|
307
307
|
rootStyle.setProperty("--ui-reveal-global-duration", this.#formatTime(this.config.duration));
|
|
308
|
-
rootStyle.setProperty("--ui-reveal-global-
|
|
308
|
+
rootStyle.setProperty("--ui-reveal-global-timing-function", this.config.ease);
|
|
309
309
|
rootStyle.setProperty("--ui-reveal-global-wait", this.#formatTime(this.config.wait));
|
|
310
310
|
rootStyle.setProperty("--ui-reveal-global-distance", this.config.distance);
|
|
311
311
|
rootStyle.setProperty("--ui-reveal-global-grow", this.config.grow.toString());
|
|
@@ -350,7 +350,7 @@ if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
|
350
350
|
autoInit();
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
// After
|
|
353
|
+
// After an in-page navigation swap, re-scan the new content for [data-reveal] targets.
|
|
354
354
|
registerRefresh(() => Reveal.getAutoInstance()?.refresh());
|
|
355
355
|
|
|
356
356
|
/**
|
|
@@ -371,7 +371,7 @@ if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
// Attach to window for the documented public API (`window.Reveal`, `new Reveal()`),
|
|
374
|
-
// and export for module consumers (navigation.js imports it via the
|
|
374
|
+
// and export for module consumers (navigation.js imports it via the index.js entry).
|
|
375
375
|
if (typeof window !== "undefined") {
|
|
376
376
|
window.Reveal = Reveal;
|
|
377
377
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @description (Re)collects the containers holding a reader, e.g. after a navigation swap. @private */
|
|
2
|
+
declare function scan(): void;
|
|
3
|
+
/** True where the browser evaluates container scroll-state queries itself. */
|
|
4
|
+
declare function isSupported(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* @description Starts the polyfill; idempotent, and a no-op where `scroll-state`
|
|
7
|
+
* is supported unless `force` is set (tests).
|
|
8
|
+
*/
|
|
9
|
+
declare function start({ force }?: {
|
|
10
|
+
force?: boolean;
|
|
11
|
+
}): void;
|
|
12
|
+
/** @description Stops the polyfill and clears every `data-ui-stuck` it wrote. */
|
|
13
|
+
declare function stop(): void;
|
|
14
|
+
declare const ScrollState: {
|
|
15
|
+
start: typeof start;
|
|
16
|
+
stop: typeof stop;
|
|
17
|
+
isSupported: typeof isSupported;
|
|
18
|
+
refresh: typeof scan;
|
|
19
|
+
};
|
|
20
|
+
export { ScrollState };
|
|
21
|
+
//# sourceMappingURL=scroll-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-state.d.ts","sourceRoot":"","sources":["scroll-state.ts"],"names":[],"mappings":"AAsIA,wGAAwG;AACxG,iBAAS,IAAI,IAAI,IAAI,CAOpB;AAID,8EAA8E;AAC9E,iBAAS,WAAW,IAAI,OAAO,CAE9B;AAED;;;GAGG;AACH,iBAAS,KAAK,CAAC,EAAE,KAAa,EAAE,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,IAAI,CAQhE;AAED,iFAAiF;AACjF,iBAAS,IAAI,IAAI,IAAI,CAOpB;AAED,QAAA,MAAM,WAAW;;;;;CAA8C,CAAC;AAYhE,OAAO,EAAE,WAAW,EAAE,CAAC"}
|