actual-css 0.15.1 → 0.16.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/CHANGELOG.md +31 -0
- package/README.md +10 -7
- package/components.json +44 -1
- package/dist/actual.full.css +113 -8
- package/dist/actual.full.js +1 -1
- package/dist/actual.full.min.css +1 -1
- package/docs/design-notes/enhancement-contract.md +11 -3
- package/docs/pages/components/avatar.md +10 -0
- package/docs/pages/components/bleed.md +4 -0
- package/docs/pages/components/card.md +6 -0
- package/docs/pages/components/dialog.md +26 -0
- package/docs/pages/components/rating.md +29 -5
- package/docs/pages/components/steps.md +5 -3
- package/docs/pages/forms/choice-cards.md +2 -1
- package/docs/pages/forms/overview.md +1 -0
- package/docs/pages/guides/introduction.md +1 -1
- package/docs/pages/guides/progressive-enhancement.md +22 -0
- package/docs/pages/guides/upgrading.md +2 -2
- package/docs/pages/layout/choosing.md +18 -4
- package/llms.txt +2 -1
- package/package.json +5 -3
- package/skills/actual-css/SKILL.md +5 -4
- package/skills/actual-css/references/api-and-vocabulary.md +2 -1
- package/src/css/components/avatar.css +4 -2
- package/src/css/components/card.css +1 -1
- package/src/css/components/menu.css +2 -0
- package/src/css/components/rating.css +66 -0
- package/src/css/core/theme.css +4 -1
- package/src/css/core/tokens.css +8 -2
- package/src/css/forms/form.css +15 -1
- package/src/css/forms/range.css +11 -1
- package/src/css/layout/measure.css +2 -0
- package/src/js/dialog.js +40 -9
- package/src/js/enhance.js +16 -3
- package/tokens.json +117 -0
package/src/js/dialog.js
CHANGED
|
@@ -28,12 +28,13 @@
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
import { registerCommands, targetFor } from "./command.js";
|
|
31
|
-
import enhance from "./enhance.js";
|
|
31
|
+
import enhance, { registerEnhancement } from "./enhance.js";
|
|
32
32
|
import { EVENTS } from "./events.js";
|
|
33
33
|
import { CLASSES } from "./selectors.js";
|
|
34
34
|
|
|
35
35
|
const dialogMap = new WeakMap();
|
|
36
36
|
const wiredDialogs = new Set();
|
|
37
|
+
const delegatedDialogs = new WeakSet();
|
|
37
38
|
// HTML has no non-modal dialog keyword, so non-modal opening is the custom
|
|
38
39
|
// `--show` command.
|
|
39
40
|
const DIALOG_COMMANDS = ["show-modal", "--show", "request-close", "close"];
|
|
@@ -46,6 +47,18 @@ function isDialogElement(el) {
|
|
|
46
47
|
return el?.nodeType === 1 && el.localName === "dialog";
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
function allowsDialogEnhancement(dialog) {
|
|
51
|
+
if (delegatedDialogs.has(dialog) || dialog.matches('[data-enhance~="dialog"]')) return true;
|
|
52
|
+
|
|
53
|
+
// Shadow roots and light-DOM custom elements own their dialogs, including
|
|
54
|
+
// hosts that have not upgraded yet. Avoid realm-dependent instanceof checks.
|
|
55
|
+
if (dialog.getRootNode().host) return false;
|
|
56
|
+
for (let parent = dialog.parentElement; parent; parent = parent.parentElement) {
|
|
57
|
+
if (parent.localName.includes("-")) return false;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
|
|
49
62
|
function boolData(el, name) {
|
|
50
63
|
return el.hasAttribute(name) && el.getAttribute(name) !== "false";
|
|
51
64
|
}
|
|
@@ -270,7 +283,7 @@ function finishClose(dialog, returnValue = "") {
|
|
|
270
283
|
export function closeDialog(dialog, returnValue = "") {
|
|
271
284
|
if (!isDialogElement(dialog) || !dialog.open) return;
|
|
272
285
|
|
|
273
|
-
const state =
|
|
286
|
+
const state = ensureDelegatedDialog(dialog);
|
|
274
287
|
if (state.closing) return;
|
|
275
288
|
|
|
276
289
|
const trigger = state.restoreFocusTo;
|
|
@@ -299,7 +312,7 @@ export function closeDialog(dialog, returnValue = "") {
|
|
|
299
312
|
export function requestDialogClose(dialog, returnValue = "") {
|
|
300
313
|
if (!isDialogElement(dialog) || !dialog.open) return;
|
|
301
314
|
|
|
302
|
-
const state =
|
|
315
|
+
const state = ensureDelegatedDialog(dialog);
|
|
303
316
|
state.returnValue = returnValue;
|
|
304
317
|
state.requestingClose = true;
|
|
305
318
|
try {
|
|
@@ -317,7 +330,7 @@ export function requestDialogClose(dialog, returnValue = "") {
|
|
|
317
330
|
export function openDialog(dialog, trigger = null, forcedModal = null) {
|
|
318
331
|
if (!isDialogElement(dialog) || dialog.open || !dialog.isConnected) return;
|
|
319
332
|
|
|
320
|
-
const state =
|
|
333
|
+
const state = ensureDelegatedDialog(dialog);
|
|
321
334
|
const modal = resolveModalMode(dialog, forcedModal);
|
|
322
335
|
syncDialogSemantics(dialog, state, modal);
|
|
323
336
|
|
|
@@ -497,6 +510,18 @@ function ensureDialogWired(dialog) {
|
|
|
497
510
|
|
|
498
511
|
function connectDialog(dialog) {
|
|
499
512
|
ensureDialogWired(dialog);
|
|
513
|
+
return () => disconnectDialog(dialog);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function ensureDelegatedDialog(dialog) {
|
|
517
|
+
const state = ensureDialogWired(dialog);
|
|
518
|
+
if (!allowsDialogEnhancement(dialog)) {
|
|
519
|
+
delegatedDialogs.add(dialog);
|
|
520
|
+
// Direct API calls delegate ownership too. Enroll light DOM dialogs in
|
|
521
|
+
// document cleanup; shadow-root lifecycles remain application-owned.
|
|
522
|
+
if (dialog.getRootNode() === dialog.ownerDocument) dialogRuntime.refresh(dialog);
|
|
523
|
+
}
|
|
524
|
+
return state;
|
|
500
525
|
}
|
|
501
526
|
|
|
502
527
|
function disconnectDialog(dialog) {
|
|
@@ -512,6 +537,7 @@ function disconnectDialog(dialog) {
|
|
|
512
537
|
restoreOwnedAttributes(state);
|
|
513
538
|
state.modalOpen = false;
|
|
514
539
|
dialogMap.delete(dialog);
|
|
540
|
+
delegatedDialogs.delete(dialog);
|
|
515
541
|
wiredDialogs.delete(dialog);
|
|
516
542
|
syncModalOpenClass(dialog.ownerDocument);
|
|
517
543
|
}
|
|
@@ -519,7 +545,7 @@ function disconnectDialog(dialog) {
|
|
|
519
545
|
registerCommands(DIALOG_COMMANDS, {
|
|
520
546
|
resolve: (trigger) => {
|
|
521
547
|
const dialog = targetFor(trigger);
|
|
522
|
-
return isDialogElement(dialog) ? dialog : null;
|
|
548
|
+
return isDialogElement(dialog) && allowsDialogEnhancement(dialog) ? dialog : null;
|
|
523
549
|
},
|
|
524
550
|
handle: (_event, trigger, dialog, command) => {
|
|
525
551
|
// A dialog inserted since the last enhance() pass is wired on first use.
|
|
@@ -541,9 +567,14 @@ registerCommands(DIALOG_COMMANDS, {
|
|
|
541
567
|
},
|
|
542
568
|
});
|
|
543
569
|
|
|
544
|
-
enhance(
|
|
545
|
-
|
|
546
|
-
connectDialog
|
|
547
|
-
return () => disconnectDialog(dialog);
|
|
570
|
+
const dialogRuntime = enhance(
|
|
571
|
+
{
|
|
572
|
+
[DIALOG_SELECTOR]: connectDialog,
|
|
548
573
|
},
|
|
574
|
+
undefined,
|
|
575
|
+
{ accept: allowsDialogEnhancement },
|
|
576
|
+
);
|
|
577
|
+
|
|
578
|
+
registerEnhancement("dialog", (dialog) => {
|
|
579
|
+
if (isDialogElement(dialog)) return connectDialog(dialog);
|
|
549
580
|
});
|
package/src/js/enhance.js
CHANGED
|
@@ -73,6 +73,12 @@ function createRegistry(root) {
|
|
|
73
73
|
let discovery = "";
|
|
74
74
|
|
|
75
75
|
function start(record, el) {
|
|
76
|
+
// Shared discovery also visits the scan root and other records' matches.
|
|
77
|
+
if (record.accept && !record.keys.some((key) => el.matches(key))) return;
|
|
78
|
+
if (record.accept && !record.accept(el)) {
|
|
79
|
+
stop(record, el);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
76
82
|
let active = record.instances.get(el);
|
|
77
83
|
for (const key of record.keys) {
|
|
78
84
|
if (active?.has(key) || !el.matches(key)) continue;
|
|
@@ -115,7 +121,9 @@ function createRegistry(root) {
|
|
|
115
121
|
function sweepDisconnected() {
|
|
116
122
|
for (const record of records) {
|
|
117
123
|
for (const el of Array.from(record.instances.keys())) {
|
|
118
|
-
if (!el.isConnected || !root.contains(el)
|
|
124
|
+
if (!el.isConnected || !root.contains(el) || (record.accept && !record.accept(el))) {
|
|
125
|
+
stop(record, el);
|
|
126
|
+
}
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
}
|
|
@@ -254,9 +262,14 @@ export function registerEnhancement(name, init, root) {
|
|
|
254
262
|
/**
|
|
255
263
|
* @param {Record<string, (el: Element) => (() => void) | void>} enhancers
|
|
256
264
|
* @param {Document | Element | DocumentFragment} [root]
|
|
265
|
+
* @param {object} [options]
|
|
266
|
+
* @param {(el: Element) => boolean} [options.accept] Lifecycle eligibility, rechecked on moves.
|
|
257
267
|
* @returns {{ refresh: (node: Node) => void, disconnect: () => void }}
|
|
258
268
|
*/
|
|
259
|
-
export default function enhance(enhancers, root) {
|
|
269
|
+
export default function enhance(enhancers, root, { accept } = {}) {
|
|
270
|
+
if (accept !== undefined && typeof accept !== "function") {
|
|
271
|
+
throw new TypeError("enhance() requires a function accept predicate.");
|
|
272
|
+
}
|
|
260
273
|
if (typeof document === "undefined") return noopRuntime();
|
|
261
274
|
|
|
262
275
|
root ??= document.documentElement;
|
|
@@ -272,5 +285,5 @@ export default function enhance(enhancers, root) {
|
|
|
272
285
|
});
|
|
273
286
|
if (!keys.length) return noopRuntime();
|
|
274
287
|
|
|
275
|
-
return registryFor(root).add({ keys, enhancers, query: keys.join(",") });
|
|
288
|
+
return registryFor(root).add({ keys, enhancers, query: keys.join(","), accept });
|
|
276
289
|
}
|
package/tokens.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"global": [
|
|
3
|
+
"--backdrop-color",
|
|
4
|
+
"--backdrop-fill",
|
|
5
|
+
"--backdrop-opacity",
|
|
6
|
+
"--bar-height",
|
|
7
|
+
"--border",
|
|
8
|
+
"--border-control",
|
|
9
|
+
"--border-width",
|
|
10
|
+
"--choice-control-size",
|
|
11
|
+
"--control-default-bg",
|
|
12
|
+
"--control-font-size",
|
|
13
|
+
"--control-pad-x",
|
|
14
|
+
"--control-pad-x-lg",
|
|
15
|
+
"--control-pad-x-md",
|
|
16
|
+
"--control-pad-x-sm",
|
|
17
|
+
"--control-size",
|
|
18
|
+
"--control-size-lg",
|
|
19
|
+
"--control-size-md",
|
|
20
|
+
"--control-size-sm",
|
|
21
|
+
"--control-step-lg",
|
|
22
|
+
"--control-step-md",
|
|
23
|
+
"--control-step-sm",
|
|
24
|
+
"--danger",
|
|
25
|
+
"--danger-fg",
|
|
26
|
+
"--danger-soft-fg",
|
|
27
|
+
"--duration",
|
|
28
|
+
"--duration-fast",
|
|
29
|
+
"--duration-shimmer",
|
|
30
|
+
"--duration-slow",
|
|
31
|
+
"--duration-spin",
|
|
32
|
+
"--ease-enter",
|
|
33
|
+
"--ease-exit",
|
|
34
|
+
"--focus",
|
|
35
|
+
"--focus-outline",
|
|
36
|
+
"--focus-outline-color",
|
|
37
|
+
"--focus-outline-offset",
|
|
38
|
+
"--focus-ring-width",
|
|
39
|
+
"--font-mono",
|
|
40
|
+
"--font-sans",
|
|
41
|
+
"--font-size-lg",
|
|
42
|
+
"--font-size-md",
|
|
43
|
+
"--font-size-sm",
|
|
44
|
+
"--font-size-xs",
|
|
45
|
+
"--font-weight-bold",
|
|
46
|
+
"--font-weight-medium",
|
|
47
|
+
"--font-weight-normal",
|
|
48
|
+
"--font-weight-semibold",
|
|
49
|
+
"--font-width",
|
|
50
|
+
"--gap",
|
|
51
|
+
"--heading",
|
|
52
|
+
"--hover-overlay",
|
|
53
|
+
"--hover-overlay-solid",
|
|
54
|
+
"--hr-space",
|
|
55
|
+
"--icon-check",
|
|
56
|
+
"--icon-chevron",
|
|
57
|
+
"--icon-close",
|
|
58
|
+
"--icon-plus",
|
|
59
|
+
"--line-height",
|
|
60
|
+
"--line-height-relaxed",
|
|
61
|
+
"--line-height-tight",
|
|
62
|
+
"--link",
|
|
63
|
+
"--neutral",
|
|
64
|
+
"--neutral-fg",
|
|
65
|
+
"--neutral-soft-fg",
|
|
66
|
+
"--primary",
|
|
67
|
+
"--primary-fg",
|
|
68
|
+
"--primary-soft-fg",
|
|
69
|
+
"--radius",
|
|
70
|
+
"--radius-full",
|
|
71
|
+
"--radius-lg",
|
|
72
|
+
"--radius-sm",
|
|
73
|
+
"--secondary",
|
|
74
|
+
"--secondary-fg",
|
|
75
|
+
"--secondary-soft-fg",
|
|
76
|
+
"--selection-bg",
|
|
77
|
+
"--selection-fg",
|
|
78
|
+
"--shadow",
|
|
79
|
+
"--shadow-color",
|
|
80
|
+
"--shadow-popout",
|
|
81
|
+
"--soft-bg-mix",
|
|
82
|
+
"--soft-border-mix",
|
|
83
|
+
"--soft-fg-mix",
|
|
84
|
+
"--soft-hover-alpha",
|
|
85
|
+
"--space-10",
|
|
86
|
+
"--space-20",
|
|
87
|
+
"--space-30",
|
|
88
|
+
"--space-40",
|
|
89
|
+
"--space-50",
|
|
90
|
+
"--space-60",
|
|
91
|
+
"--state-disabled",
|
|
92
|
+
"--state-selected",
|
|
93
|
+
"--state-selected-fg",
|
|
94
|
+
"--state-selected-text",
|
|
95
|
+
"--success",
|
|
96
|
+
"--success-fg",
|
|
97
|
+
"--success-soft-fg",
|
|
98
|
+
"--surface",
|
|
99
|
+
"--surface-opaque",
|
|
100
|
+
"--surface-raised",
|
|
101
|
+
"--surface-solid",
|
|
102
|
+
"--surface-solid-fg",
|
|
103
|
+
"--surface-subtle",
|
|
104
|
+
"--text",
|
|
105
|
+
"--text-muted",
|
|
106
|
+
"--text-subtle",
|
|
107
|
+
"--tone-fg",
|
|
108
|
+
"--viewport-block",
|
|
109
|
+
"--viewport-inline",
|
|
110
|
+
"--warning",
|
|
111
|
+
"--warning-fg",
|
|
112
|
+
"--warning-soft-fg",
|
|
113
|
+
"--z-menu",
|
|
114
|
+
"--z-status",
|
|
115
|
+
"--z-sticky"
|
|
116
|
+
]
|
|
117
|
+
}
|