@zazz-ui/core 0.5.3 → 0.6.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 +17 -14
- package/CHANGELOG.md +51 -0
- package/README.md +3 -3
- package/dist/sri.json +74 -74
- package/dist/zazz.css +1 -1
- package/dist/zazz.js +1 -1
- package/editor/zazz.css-data.json +3604 -116
- package/editor/zazz.html-data.json +18 -12
- package/editor/zazz.language-data.json +103 -54
- package/editor/zazz.lint-data.json +2 -0
- package/package.json +1 -1
- package/src/base/_properties-2xl.css +16 -0
- package/src/base/_properties-active.css +12 -0
- package/src/base/_properties-checked.css +12 -0
- package/src/base/_properties-current.css +12 -0
- package/src/base/_properties-disabled.css +12 -0
- package/src/base/_properties-focus-visible.css +12 -0
- package/src/base/_properties-focus-within.css +12 -0
- package/src/base/_properties-hover.css +12 -0
- package/src/base/_properties-lg.css +16 -0
- package/src/base/_properties-md.css +16 -0
- package/src/base/_properties-open.css +12 -0
- package/src/base/_properties-sm.css +16 -0
- package/src/base/_properties-starting.css +6 -0
- package/src/base/_properties-stuck.css +6 -0
- package/src/base/_properties-xl.css +16 -0
- package/src/base/_properties.css +22 -1
- package/src/base/_reset.css +8 -2
- package/src/base/_switches.css +3 -0
- package/src/base/_typography.css +3 -4
- package/src/base/_utilities-color.css +5 -5
- package/src/base/_utilities-effects.css +45 -6
- package/src/base/_utilities-flow.css +5 -5
- package/src/base/_utilities-grid.css +10 -10
- package/src/base/_utilities-margin.css +35 -35
- package/src/base/_utilities-pseudo.css +16 -0
- package/src/base/_utilities-sizing.css +20 -20
- package/src/base/_utilities-tier-2xl.css +9 -1
- package/src/base/_utilities-tier-active.css +6 -0
- package/src/base/_utilities-tier-checked.css +6 -0
- package/src/base/_utilities-tier-current.css +6 -0
- package/src/base/_utilities-tier-disabled.css +6 -0
- package/src/base/_utilities-tier-focus-visible.css +6 -0
- package/src/base/_utilities-tier-focus-within.css +6 -0
- package/src/base/_utilities-tier-hover.css +6 -0
- package/src/base/_utilities-tier-lg.css +9 -1
- package/src/base/_utilities-tier-md.css +9 -1
- package/src/base/_utilities-tier-open.css +6 -0
- package/src/base/_utilities-tier-sm.css +9 -1
- package/src/base/_utilities-tier-starting.css +3 -0
- package/src/base/_utilities-tier-stuck.css +3 -0
- package/src/base/_utilities-tier-xl.css +9 -1
- package/src/base/_utilities-typography.css +5 -5
- package/src/base/_variables.css +116 -55
- package/src/base/_view-transitions.css +7 -9
- package/src/base/dialog-lifecycle.d.ts +18 -1
- package/src/base/dialog-lifecycle.d.ts.map +1 -1
- package/src/base/dialog-lifecycle.js +72 -1
- package/src/base/dialog-lifecycle.ts +79 -1
- package/src/base/navigation.d.ts.map +1 -1
- package/src/base/navigation.js +19 -8
- package/src/base/navigation.ts +19 -8
- package/src/base/utilities.d.ts +19 -13
- package/src/base/utilities.d.ts.map +1 -1
- package/src/base/utilities.js +72 -21
- package/src/base/utilities.ts +84 -24
- package/src/head.d.ts +4 -1
- package/src/head.d.ts.map +1 -1
- package/src/head.js +9 -5
- package/src/head.ts +9 -5
- package/src/primitives/accordion/accordion.css +23 -12
- package/src/primitives/accordion/accordion.html +3 -3
- package/src/primitives/badge/badge.css +16 -9
- package/src/primitives/button/button.css +18 -11
- package/src/primitives/checkbox/checkbox-tasklist.html +6 -1
- package/src/primitives/checkbox/checkbox.css +16 -9
- package/src/primitives/checkbox/checkbox.html +1 -1
- package/src/primitives/checkbox/checkbox.js +1 -1
- package/src/primitives/checkbox/checkbox.ts +1 -1
- package/src/primitives/combobox/combobox.css +15 -8
- package/src/primitives/command/command-actions.d.ts.map +1 -1
- package/src/primitives/command/command-actions.html +1 -0
- package/src/primitives/command/command-actions.js +9 -4
- package/src/primitives/command/command-actions.ts +9 -4
- package/src/primitives/command/command-dialog.html +36 -0
- package/src/primitives/command/command.css +12 -1
- package/src/primitives/command/command.html +1 -0
- package/src/primitives/debug/audit-core.d.ts +3 -1
- package/src/primitives/debug/audit-core.d.ts.map +1 -1
- package/src/primitives/debug/audit-core.js +19 -1
- package/src/primitives/debug/audit-core.ts +25 -1
- package/src/primitives/debug/debug.d.ts.map +1 -1
- package/src/primitives/debug/debug.js +1 -0
- package/src/primitives/debug/debug.ts +1 -0
- package/src/primitives/dialog/dialog.css +2 -2
- package/src/primitives/fields/fields.css +15 -2
- package/src/primitives/input/input-icon-leading.html +1 -1
- package/src/primitives/input/input-icon-trailing.html +1 -1
- package/src/primitives/input/input.css +16 -9
- package/src/primitives/input-group/input-group.css +15 -8
- package/src/primitives/lightbox/lightbox.html +1 -2
- package/src/primitives/mobile-menu/mobile-menu.html +50 -10
- package/src/primitives/navigation-menu/navigation-menu-featured.html +5 -1
- package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +5 -1
- package/src/primitives/navigation-menu/navigation-menu-interest.html +10 -2
- package/src/primitives/navigation-menu/navigation-menu-megamenu.html +5 -1
- package/src/primitives/navigation-menu/navigation-menu-simple.html +6 -1
- package/src/primitives/navigation-menu/navigation-menu.css +6 -3
- package/src/primitives/navigation-menu/navigation-menu.html +15 -3
- package/src/primitives/password-group/password-group.css +14 -7
- package/src/primitives/password-group/password-group.js +1 -1
- package/src/primitives/password-group/password-group.ts +1 -1
- package/src/primitives/radio/radio.css +15 -8
- package/src/primitives/select/multiselect.d.ts.map +1 -1
- package/src/primitives/select/multiselect.js +3 -1
- package/src/primitives/select/multiselect.ts +3 -1
- package/src/primitives/select/select.css +14 -7
- package/src/primitives/slider/slider.html +1 -0
- package/src/primitives/switch/switch.css +15 -8
- package/src/primitives/tabs/tabs.css +21 -9
- package/src/primitives/textarea/textarea.css +16 -9
- package/src/primitives/toggle/toggle.css +16 -9
- package/src/primitives/toggle/toggle.html +6 -6
- package/src/primitives/toolbar/toolbar.html +2 -1
|
@@ -18,11 +18,80 @@
|
|
|
18
18
|
* choreography (ancestor and document level).
|
|
19
19
|
*
|
|
20
20
|
* No `detail` payload: the dialog is the event target.
|
|
21
|
+
*
|
|
22
|
+
* It also fills in light dismiss where the browser lacks it. `closedby="any"`
|
|
23
|
+
* (Chrome 134, Firefox 141) lets a tap on the backdrop close a modal dialog;
|
|
24
|
+
* Safari 26 knows `closedby` but only its `none` and `closerequest` values, so
|
|
25
|
+
* `any` falls back to `closerequest` and the backdrop does nothing there. Where
|
|
26
|
+
* `any` is not supported, a backdrop tap on a `closedby="any"` dialog closes it
|
|
27
|
+
* here, with native semantics: the press and the release both land on the
|
|
28
|
+
* backdrop, and the dialog gets a `cancel` through `requestClose()` where that
|
|
29
|
+
* exists.
|
|
21
30
|
*/
|
|
22
31
|
/** Dispatches a bubbling lifecycle event on a dialog. */
|
|
23
32
|
function emit(dialog, type) {
|
|
24
33
|
dialog.dispatchEvent(new Event(type, { bubbles: true }));
|
|
25
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @description True when the browser dismisses `closedby="any"` dialogs itself.
|
|
37
|
+
* The property alone is not proof: Safari 26 has `closedBy` with `none` and
|
|
38
|
+
* `closerequest` but not `any`, so `any` must round-trip through the reflected
|
|
39
|
+
* property, which keeps only the keywords the engine knows.
|
|
40
|
+
*/
|
|
41
|
+
function hasNativeLightDismiss() {
|
|
42
|
+
if (typeof HTMLDialogElement === "undefined" || !("closedBy" in HTMLDialogElement.prototype)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const probe = document.createElement("dialog");
|
|
46
|
+
probe.setAttribute("closedby", "any");
|
|
47
|
+
return probe.closedBy === "any";
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @description The open `closedby="any"` dialog whose backdrop `event` hit, or
|
|
51
|
+
* null. A backdrop hit targets the dialog element itself at a point outside
|
|
52
|
+
* its box; a hit inside the box targets a descendant, or the dialog's own
|
|
53
|
+
* padding, which must not dismiss.
|
|
54
|
+
*
|
|
55
|
+
* @param event - A pointer or mouse event, read for its target and position.
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
function backdropHit(event) {
|
|
59
|
+
const dialog = event.target;
|
|
60
|
+
if (!(dialog instanceof HTMLDialogElement) || !dialog.open)
|
|
61
|
+
return null;
|
|
62
|
+
if (dialog.getAttribute("closedby") !== "any")
|
|
63
|
+
return null;
|
|
64
|
+
const { clientX: x, clientY: y } = event;
|
|
65
|
+
const box = dialog.getBoundingClientRect();
|
|
66
|
+
const outside = x < box.left || x > box.right || y < box.top || y > box.bottom;
|
|
67
|
+
return outside ? dialog : null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @description Binds the backdrop-tap fallback for browsers without
|
|
71
|
+
* `closedby="any"`. The press and the release must both land on the backdrop,
|
|
72
|
+
* as in the native algorithm, so a drag from inside the dialog out to the
|
|
73
|
+
* backdrop does not dismiss. Pointer events, not `click`: iOS Safari does not
|
|
74
|
+
* deliver a delegated `click` from a non-interactive element such as a dialog's
|
|
75
|
+
* backdrop, but it does deliver `pointerup`.
|
|
76
|
+
*
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
function bindLightDismissFallback() {
|
|
80
|
+
let pressed = null;
|
|
81
|
+
document.addEventListener("pointerdown", (event) => {
|
|
82
|
+
pressed = backdropHit(event);
|
|
83
|
+
}, true);
|
|
84
|
+
document.addEventListener("pointerup", (event) => {
|
|
85
|
+
const dialog = backdropHit(event);
|
|
86
|
+
if (dialog && dialog === pressed) {
|
|
87
|
+
if (typeof dialog.requestClose === "function")
|
|
88
|
+
dialog.requestClose();
|
|
89
|
+
else
|
|
90
|
+
dialog.close();
|
|
91
|
+
}
|
|
92
|
+
pressed = null;
|
|
93
|
+
}, true);
|
|
94
|
+
}
|
|
26
95
|
/**
|
|
27
96
|
* @description Starts the page-wide dialog watcher. Idempotent and safe to call
|
|
28
97
|
* from double script loads.
|
|
@@ -51,6 +120,8 @@ const initDialogLifecycle = function () {
|
|
|
51
120
|
if (e.target instanceof HTMLDialogElement)
|
|
52
121
|
emit(e.target, "zazz:dialog-close");
|
|
53
122
|
}, true);
|
|
123
|
+
if (!hasNativeLightDismiss())
|
|
124
|
+
bindLightDismissFallback();
|
|
54
125
|
};
|
|
55
126
|
// Auto-initialize when DOM is ready (only in browser environment)
|
|
56
127
|
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
@@ -62,4 +133,4 @@ if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
|
62
133
|
}
|
|
63
134
|
}
|
|
64
135
|
// Exported for tests and manual bootstrapping; the events are the public API.
|
|
65
|
-
export { initDialogLifecycle };
|
|
136
|
+
export { backdropHit, hasNativeLightDismiss, initDialogLifecycle };
|
|
@@ -19,6 +19,15 @@
|
|
|
19
19
|
* choreography (ancestor and document level).
|
|
20
20
|
*
|
|
21
21
|
* No `detail` payload: the dialog is the event target.
|
|
22
|
+
*
|
|
23
|
+
* It also fills in light dismiss where the browser lacks it. `closedby="any"`
|
|
24
|
+
* (Chrome 134, Firefox 141) lets a tap on the backdrop close a modal dialog;
|
|
25
|
+
* Safari 26 knows `closedby` but only its `none` and `closerequest` values, so
|
|
26
|
+
* `any` falls back to `closerequest` and the backdrop does nothing there. Where
|
|
27
|
+
* `any` is not supported, a backdrop tap on a `closedby="any"` dialog closes it
|
|
28
|
+
* here, with native semantics: the press and the release both land on the
|
|
29
|
+
* backdrop, and the dialog gets a `cancel` through `requestClose()` where that
|
|
30
|
+
* exists.
|
|
22
31
|
*/
|
|
23
32
|
|
|
24
33
|
/** Dispatches a bubbling lifecycle event on a dialog. */
|
|
@@ -26,6 +35,73 @@ function emit(dialog: HTMLDialogElement, type: "zazz:dialog-open" | "zazz:dialog
|
|
|
26
35
|
dialog.dispatchEvent(new Event(type, { bubbles: true }));
|
|
27
36
|
}
|
|
28
37
|
|
|
38
|
+
/**
|
|
39
|
+
* @description True when the browser dismisses `closedby="any"` dialogs itself.
|
|
40
|
+
* The property alone is not proof: Safari 26 has `closedBy` with `none` and
|
|
41
|
+
* `closerequest` but not `any`, so `any` must round-trip through the reflected
|
|
42
|
+
* property, which keeps only the keywords the engine knows.
|
|
43
|
+
*/
|
|
44
|
+
function hasNativeLightDismiss(): boolean {
|
|
45
|
+
if (typeof HTMLDialogElement === "undefined" || !("closedBy" in HTMLDialogElement.prototype)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const probe = document.createElement("dialog");
|
|
49
|
+
probe.setAttribute("closedby", "any");
|
|
50
|
+
return probe.closedBy === "any";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @description The open `closedby="any"` dialog whose backdrop `event` hit, or
|
|
55
|
+
* null. A backdrop hit targets the dialog element itself at a point outside
|
|
56
|
+
* its box; a hit inside the box targets a descendant, or the dialog's own
|
|
57
|
+
* padding, which must not dismiss.
|
|
58
|
+
*
|
|
59
|
+
* @param event - A pointer or mouse event, read for its target and position.
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
function backdropHit(event: Event): HTMLDialogElement | null {
|
|
63
|
+
const dialog = event.target;
|
|
64
|
+
if (!(dialog instanceof HTMLDialogElement) || !dialog.open) return null;
|
|
65
|
+
if (dialog.getAttribute("closedby") !== "any") return null;
|
|
66
|
+
const { clientX: x, clientY: y } = event as MouseEvent;
|
|
67
|
+
const box = dialog.getBoundingClientRect();
|
|
68
|
+
const outside = x < box.left || x > box.right || y < box.top || y > box.bottom;
|
|
69
|
+
return outside ? dialog : null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @description Binds the backdrop-tap fallback for browsers without
|
|
74
|
+
* `closedby="any"`. The press and the release must both land on the backdrop,
|
|
75
|
+
* as in the native algorithm, so a drag from inside the dialog out to the
|
|
76
|
+
* backdrop does not dismiss. Pointer events, not `click`: iOS Safari does not
|
|
77
|
+
* deliver a delegated `click` from a non-interactive element such as a dialog's
|
|
78
|
+
* backdrop, but it does deliver `pointerup`.
|
|
79
|
+
*
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
function bindLightDismissFallback(): void {
|
|
83
|
+
let pressed: HTMLDialogElement | null = null;
|
|
84
|
+
document.addEventListener(
|
|
85
|
+
"pointerdown",
|
|
86
|
+
(event) => {
|
|
87
|
+
pressed = backdropHit(event);
|
|
88
|
+
},
|
|
89
|
+
true,
|
|
90
|
+
);
|
|
91
|
+
document.addEventListener(
|
|
92
|
+
"pointerup",
|
|
93
|
+
(event) => {
|
|
94
|
+
const dialog = backdropHit(event);
|
|
95
|
+
if (dialog && dialog === pressed) {
|
|
96
|
+
if (typeof dialog.requestClose === "function") dialog.requestClose();
|
|
97
|
+
else dialog.close();
|
|
98
|
+
}
|
|
99
|
+
pressed = null;
|
|
100
|
+
},
|
|
101
|
+
true,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
29
105
|
interface InitDialogLifecycleFn {
|
|
30
106
|
(): void;
|
|
31
107
|
_bound?: boolean;
|
|
@@ -65,6 +141,8 @@ const initDialogLifecycle: InitDialogLifecycleFn = function () {
|
|
|
65
141
|
},
|
|
66
142
|
true,
|
|
67
143
|
);
|
|
144
|
+
|
|
145
|
+
if (!hasNativeLightDismiss()) bindLightDismissFallback();
|
|
68
146
|
};
|
|
69
147
|
|
|
70
148
|
// Auto-initialize when DOM is ready (only in browser environment)
|
|
@@ -77,4 +155,4 @@ if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
|
77
155
|
}
|
|
78
156
|
|
|
79
157
|
// Exported for tests and manual bootstrapping; the events are the public API.
|
|
80
|
-
export { initDialogLifecycle };
|
|
158
|
+
export { backdropHit, hasNativeLightDismiss, initDialogLifecycle };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["navigation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["navigation.ts"],"names":[],"mappings":"AAsFA;;;;;;;;;GASG;AACH,iBAAS,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,CAgDhD;AAqJD,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/src/base/navigation.js
CHANGED
|
@@ -22,9 +22,10 @@ import { refreshAll } from "./zazz-element.js";
|
|
|
22
22
|
* scrolls as the browser decides: to the top or the target for a new entry,
|
|
23
23
|
* restored on back/forward.
|
|
24
24
|
*
|
|
25
|
-
* Without the opt-in the browser navigates normally
|
|
26
|
-
* cross-document view transitions in
|
|
27
|
-
*
|
|
25
|
+
* Without the opt-in the browser navigates normally; a site animates those
|
|
26
|
+
* loads by enabling cross-document view transitions in its own CSS, which
|
|
27
|
+
* `_view-transitions.css` then styles. Reloads, hash changes, downloads and
|
|
28
|
+
* form posts are never intercepted.
|
|
28
29
|
*
|
|
29
30
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API
|
|
30
31
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/NavigateEvent/scroll
|
|
@@ -187,16 +188,23 @@ function holdInstantScroll() {
|
|
|
187
188
|
function isSameOrigin(url) {
|
|
188
189
|
return new URL(url, location.href).origin === location.origin;
|
|
189
190
|
}
|
|
191
|
+
/** A path ending in a file extension other than `.html` (`/llms.txt`, `/a.md`, `/b.pdf`) is not a page. */
|
|
192
|
+
function isPagePath(url) {
|
|
193
|
+
const ext = /\.([a-z0-9]+)$/i.exec(new URL(url, location.href).pathname)?.[1];
|
|
194
|
+
return !ext || /^x?html?$/i.test(ext);
|
|
195
|
+
}
|
|
190
196
|
if ("navigation" in window) {
|
|
191
197
|
/**
|
|
192
198
|
* URL handed back to the browser for a full load. The `navigate` listener
|
|
193
|
-
* skips it once, so `location.
|
|
194
|
-
* re-enter the interception and loop.
|
|
199
|
+
* skips it once, so `location.replace()` from inside the handler does not
|
|
200
|
+
* re-enter the interception and loop. Replace, not assign: the intercepted
|
|
201
|
+
* navigation already committed an entry for this URL, and a second one would
|
|
202
|
+
* leave Back pointing at a page that no longer exists.
|
|
195
203
|
*/
|
|
196
204
|
let bypassUrl = null;
|
|
197
205
|
function fullLoad(url) {
|
|
198
206
|
bypassUrl = url;
|
|
199
|
-
location.
|
|
207
|
+
location.replace(url);
|
|
200
208
|
}
|
|
201
209
|
window.navigation.addEventListener("navigate", (e) => {
|
|
202
210
|
if (bypassUrl !== null && e.destination.url === bypassUrl) {
|
|
@@ -210,7 +218,8 @@ if ("navigation" in window) {
|
|
|
210
218
|
e.hashChange ||
|
|
211
219
|
e.downloadRequest !== null ||
|
|
212
220
|
e.formData !== null ||
|
|
213
|
-
!isSameOrigin(e.destination.url)
|
|
221
|
+
!isSameOrigin(e.destination.url) ||
|
|
222
|
+
!isPagePath(e.destination.url)) {
|
|
214
223
|
return;
|
|
215
224
|
}
|
|
216
225
|
e.intercept({
|
|
@@ -220,13 +229,15 @@ if ("navigation" in window) {
|
|
|
220
229
|
const res = await fetch(e.destination.url, { signal: e.signal });
|
|
221
230
|
if (!res.ok)
|
|
222
231
|
throw new Error(res.statusText);
|
|
232
|
+
if (!res.headers.get("content-type")?.includes("html"))
|
|
233
|
+
throw new Error("not a page");
|
|
223
234
|
doc = new DOMParser().parseFromString(await res.text(), "text/html");
|
|
224
235
|
}
|
|
225
236
|
catch {
|
|
226
237
|
// A newer navigation aborted this one; it must not swap in late.
|
|
227
238
|
if (e.signal.aborted)
|
|
228
239
|
return;
|
|
229
|
-
fullLoad(e.destination.url); // network or HTTP failure
|
|
240
|
+
fullLoad(e.destination.url); // network or HTTP failure, or not HTML
|
|
230
241
|
return;
|
|
231
242
|
}
|
|
232
243
|
if (e.signal.aborted)
|
package/src/base/navigation.ts
CHANGED
|
@@ -24,9 +24,10 @@ import { refreshAll } from "./zazz-element.ts";
|
|
|
24
24
|
* scrolls as the browser decides: to the top or the target for a new entry,
|
|
25
25
|
* restored on back/forward.
|
|
26
26
|
*
|
|
27
|
-
* Without the opt-in the browser navigates normally
|
|
28
|
-
* cross-document view transitions in
|
|
29
|
-
*
|
|
27
|
+
* Without the opt-in the browser navigates normally; a site animates those
|
|
28
|
+
* loads by enabling cross-document view transitions in its own CSS, which
|
|
29
|
+
* `_view-transitions.css` then styles. Reloads, hash changes, downloads and
|
|
30
|
+
* form posts are never intercepted.
|
|
30
31
|
*
|
|
31
32
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API
|
|
32
33
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/NavigateEvent/scroll
|
|
@@ -188,17 +189,25 @@ function isSameOrigin(url: string): boolean {
|
|
|
188
189
|
return new URL(url, location.href).origin === location.origin;
|
|
189
190
|
}
|
|
190
191
|
|
|
192
|
+
/** A path ending in a file extension other than `.html` (`/llms.txt`, `/a.md`, `/b.pdf`) is not a page. */
|
|
193
|
+
function isPagePath(url: string): boolean {
|
|
194
|
+
const ext = /\.([a-z0-9]+)$/i.exec(new URL(url, location.href).pathname)?.[1];
|
|
195
|
+
return !ext || /^x?html?$/i.test(ext);
|
|
196
|
+
}
|
|
197
|
+
|
|
191
198
|
if ("navigation" in window) {
|
|
192
199
|
/**
|
|
193
200
|
* URL handed back to the browser for a full load. The `navigate` listener
|
|
194
|
-
* skips it once, so `location.
|
|
195
|
-
* re-enter the interception and loop.
|
|
201
|
+
* skips it once, so `location.replace()` from inside the handler does not
|
|
202
|
+
* re-enter the interception and loop. Replace, not assign: the intercepted
|
|
203
|
+
* navigation already committed an entry for this URL, and a second one would
|
|
204
|
+
* leave Back pointing at a page that no longer exists.
|
|
196
205
|
*/
|
|
197
206
|
let bypassUrl: string | null = null;
|
|
198
207
|
|
|
199
208
|
function fullLoad(url: string): void {
|
|
200
209
|
bypassUrl = url;
|
|
201
|
-
location.
|
|
210
|
+
location.replace(url);
|
|
202
211
|
}
|
|
203
212
|
|
|
204
213
|
window.navigation.addEventListener("navigate", (e) => {
|
|
@@ -215,7 +224,8 @@ if ("navigation" in window) {
|
|
|
215
224
|
e.hashChange ||
|
|
216
225
|
e.downloadRequest !== null ||
|
|
217
226
|
e.formData !== null ||
|
|
218
|
-
!isSameOrigin(e.destination.url)
|
|
227
|
+
!isSameOrigin(e.destination.url) ||
|
|
228
|
+
!isPagePath(e.destination.url)
|
|
219
229
|
) {
|
|
220
230
|
return;
|
|
221
231
|
}
|
|
@@ -226,11 +236,12 @@ if ("navigation" in window) {
|
|
|
226
236
|
try {
|
|
227
237
|
const res = await fetch(e.destination.url, { signal: e.signal });
|
|
228
238
|
if (!res.ok) throw new Error(res.statusText);
|
|
239
|
+
if (!res.headers.get("content-type")?.includes("html")) throw new Error("not a page");
|
|
229
240
|
doc = new DOMParser().parseFromString(await res.text(), "text/html");
|
|
230
241
|
} catch {
|
|
231
242
|
// A newer navigation aborted this one; it must not swap in late.
|
|
232
243
|
if (e.signal.aborted) return;
|
|
233
|
-
fullLoad(e.destination.url); // network or HTTP failure
|
|
244
|
+
fullLoad(e.destination.url); // network or HTTP failure, or not HTML
|
|
234
245
|
return;
|
|
235
246
|
}
|
|
236
247
|
if (e.signal.aborted) return;
|
package/src/base/utilities.d.ts
CHANGED
|
@@ -7,18 +7,14 @@
|
|
|
7
7
|
export declare const BREAKPOINTS: readonly ["sm", "md", "lg", "xl", "2xl"];
|
|
8
8
|
export type Breakpoint = (typeof BREAKPOINTS)[number];
|
|
9
9
|
/**
|
|
10
|
-
* Breakpoint thresholds
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* Breakpoint thresholds and layout widths, in rem: Tailwind's scale. A tier
|
|
11
|
+
* applies when the nearest inline-size container is at least this wide, and
|
|
12
|
+
* `--layout-<breakpoint>` is the same width, so `@md` means "an md band fits".
|
|
13
|
+
* rem resolves against the root in every container, so siblings in different
|
|
14
|
+
* fonts flip together; it still follows the reader's font size and zoom.
|
|
15
|
+
* 640 / 768 / 1024 / 1280 / 1536px at 16px.
|
|
15
16
|
*/
|
|
16
|
-
export declare const
|
|
17
|
-
/**
|
|
18
|
-
* Layout band and component widths (`--layout-*`), in rem for predictable
|
|
19
|
-
* geometry: Tailwind's scale. Decoupled from the query thresholds above.
|
|
20
|
-
*/
|
|
21
|
-
export declare const LAYOUT_REM: Record<Breakpoint, number>;
|
|
17
|
+
export declare const BREAKPOINT_REM: Record<Breakpoint, number>;
|
|
22
18
|
/** Interaction states, highest precedence first. */
|
|
23
19
|
export declare const STATES: readonly ["starting", "disabled", "active", "focus-visible", "focus-within", "hover", "checked", "current", "open", "stuck"];
|
|
24
20
|
export type State = (typeof STATES)[number];
|
|
@@ -81,9 +77,19 @@ export interface Utility {
|
|
|
81
77
|
* `line-clamp` adds the -webkit-box companions; `bg` is a relative oklch
|
|
82
78
|
* with `--bg-alpha`; `none` feeds a composite (`box-shadow`) and emits nothing itself;
|
|
83
79
|
* `border` is a border shorthand: it sorts a color, number, or length into
|
|
84
|
-
* width and color channels, and the side rules emit them.
|
|
80
|
+
* width and color channels, and the side rules emit them. `px` feeds a
|
|
81
|
+
* composite too, as one signed length `--_<name>-w`: a number is that many
|
|
82
|
+
* pixels, a length passes through, and the sign carries meaning (a negative
|
|
83
|
+
* ring is inset).
|
|
84
|
+
*/
|
|
85
|
+
emit?: "plain" | "repeat" | "span" | "grid-fit" | "line-clamp" | "bg" | "none" | "border" | "px";
|
|
86
|
+
/**
|
|
87
|
+
* What the precedence chain ends in when neither the base nor an active tier
|
|
88
|
+
* sets the utility: a `px` utility that stands in for a token (`--focus-ring`
|
|
89
|
+
* falls back to `--ring-width`, so `--focus-ring--md: -2` alone keeps the
|
|
90
|
+
* default ring below md).
|
|
85
91
|
*/
|
|
86
|
-
|
|
92
|
+
chainEnd?: string;
|
|
87
93
|
/** Overrides the family's tier kind (`none` for a utility that is base-only). */
|
|
88
94
|
tiers?: Tiers;
|
|
89
95
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["utilities.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,qDAAqD;AACrD,eAAO,MAAM,WAAW,YAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAU,CAAC;AACpE,MAAM,MAAM,UAAU,GAAG,CAAC,O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,eAAe,YAAI,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,CAAU,CAAC;AAC9F,eAAO,MAAM,eAAe,YAAI,MAAM,CAAU,CAAC;AAIjD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,YAAI,SAAS,CAAU,CAAC;AAE3D,qFAAqF;AACrF,eAAO,MAAM,SAAS,EAAE,SAAS,OAAO,EA6jBvC,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,WAAW,EAAE,SAAS,OAAO,EAEzC,CAAC;AAEF,eAAO,MAAM,YAAY,YAAI,QAAQ,EAAE,OAAO,CAAU,CAAC;AACzD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,6DAA6D;AAC7D,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAM3D;AAED,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,IAAI,CAAC;CACd;AAID,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAyBzD"}
|
package/src/base/utilities.js
CHANGED
|
@@ -7,24 +7,14 @@
|
|
|
7
7
|
/** Breakpoints, ascending: Tailwind's five names. */
|
|
8
8
|
export const BREAKPOINTS = ["sm", "md", "lg", "xl", "2xl"];
|
|
9
9
|
/**
|
|
10
|
-
* Breakpoint thresholds
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* Breakpoint thresholds and layout widths, in rem: Tailwind's scale. A tier
|
|
11
|
+
* applies when the nearest inline-size container is at least this wide, and
|
|
12
|
+
* `--layout-<breakpoint>` is the same width, so `@md` means "an md band fits".
|
|
13
|
+
* rem resolves against the root in every container, so siblings in different
|
|
14
|
+
* fonts flip together; it still follows the reader's font size and zoom.
|
|
15
|
+
* 640 / 768 / 1024 / 1280 / 1536px at 16px.
|
|
15
16
|
*/
|
|
16
|
-
export const
|
|
17
|
-
sm: 40,
|
|
18
|
-
md: 65,
|
|
19
|
-
lg: 90,
|
|
20
|
-
xl: 120,
|
|
21
|
-
"2xl": 150,
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Layout band and component widths (`--layout-*`), in rem for predictable
|
|
25
|
-
* geometry: Tailwind's scale. Decoupled from the query thresholds above.
|
|
26
|
-
*/
|
|
27
|
-
export const LAYOUT_REM = {
|
|
17
|
+
export const BREAKPOINT_REM = {
|
|
28
18
|
sm: 40,
|
|
29
19
|
md: 48,
|
|
30
20
|
lg: 64,
|
|
@@ -635,10 +625,53 @@ export const UTILITIES = [
|
|
|
635
625
|
// the shadow color for an element and its subtree: _variables.css re-declares the
|
|
636
626
|
// --shadow-* tokens wherever this is set, so keyword, var(), and primitive shadows follow
|
|
637
627
|
{ name: "shadow-hue", properties: [], mode: "raw", family: "box", emit: "none" },
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
{
|
|
641
|
-
|
|
628
|
+
// the shadow's cast direction: the --shadow-* tokens rotate their offsets by it
|
|
629
|
+
// (0deg casts down, clockwise), re-declared where it is set (_variables.css)
|
|
630
|
+
{
|
|
631
|
+
name: "shadow-angle",
|
|
632
|
+
properties: [],
|
|
633
|
+
mode: "raw",
|
|
634
|
+
family: "effects",
|
|
635
|
+
emit: "none",
|
|
636
|
+
tiers: "both",
|
|
637
|
+
},
|
|
638
|
+
// ring widths are signed: a number is pixels, and a negative ring is inset
|
|
639
|
+
{ name: "ring", properties: [], mode: "raw", family: "effects", emit: "px", tiers: "both" },
|
|
640
|
+
{
|
|
641
|
+
name: "ring-color",
|
|
642
|
+
properties: [],
|
|
643
|
+
mode: "raw",
|
|
644
|
+
family: "effects",
|
|
645
|
+
emit: "none",
|
|
646
|
+
tiers: "both",
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
name: "ring-offset",
|
|
650
|
+
properties: [],
|
|
651
|
+
mode: "raw",
|
|
652
|
+
family: "effects",
|
|
653
|
+
emit: "px",
|
|
654
|
+
tiers: "both",
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
name: "ring-offset-color",
|
|
658
|
+
properties: [],
|
|
659
|
+
mode: "raw",
|
|
660
|
+
family: "effects",
|
|
661
|
+
emit: "none",
|
|
662
|
+
tiers: "both",
|
|
663
|
+
},
|
|
664
|
+
// a primitive's focus ring (and the reset's focus outline): signed like --ring,
|
|
665
|
+
// the --ring-width token when unset
|
|
666
|
+
{
|
|
667
|
+
name: "focus-ring",
|
|
668
|
+
properties: [],
|
|
669
|
+
mode: "raw",
|
|
670
|
+
family: "effects",
|
|
671
|
+
emit: "px",
|
|
672
|
+
tiers: "breakpoints",
|
|
673
|
+
chainEnd: "var(--ring-width)",
|
|
674
|
+
},
|
|
642
675
|
{
|
|
643
676
|
name: "scale",
|
|
644
677
|
pseudo: true,
|
|
@@ -664,6 +697,24 @@ export const UTILITIES = [
|
|
|
664
697
|
noBase: "none",
|
|
665
698
|
},
|
|
666
699
|
{ name: "transition", pseudo: true, properties: ["transition"], mode: "raw", family: "effects" },
|
|
700
|
+
// longhands after the shorthand, so they win over --transition and over a
|
|
701
|
+
// primitive's transition: retime one element without restating its property list
|
|
702
|
+
{
|
|
703
|
+
name: "transition-duration",
|
|
704
|
+
pseudo: true,
|
|
705
|
+
properties: ["transition-duration"],
|
|
706
|
+
mode: "raw",
|
|
707
|
+
family: "effects",
|
|
708
|
+
tiers: "both",
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
name: "transition-delay",
|
|
712
|
+
pseudo: true,
|
|
713
|
+
properties: ["transition-delay"],
|
|
714
|
+
mode: "raw",
|
|
715
|
+
family: "effects",
|
|
716
|
+
tiers: "both",
|
|
717
|
+
},
|
|
667
718
|
// box: no tiers
|
|
668
719
|
{
|
|
669
720
|
name: "rounded",
|