actual-css 0.19.5 → 0.20.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 +59 -0
- package/README.md +4 -4
- package/components.json +6 -3
- package/dist/actual.full.css +249 -54
- package/dist/actual.full.js +2 -2
- package/dist/actual.full.min.css +1 -1
- package/dist/types/menu.d.ts +2 -5
- package/docs/pages/components/accordion.md +11 -6
- package/docs/pages/components/alert.md +64 -62
- package/docs/pages/components/avatar.md +12 -12
- package/docs/pages/components/badge.md +15 -15
- package/docs/pages/components/breadcrumb.md +10 -8
- package/docs/pages/components/button.md +56 -7
- package/docs/pages/components/card.md +21 -21
- package/docs/pages/components/dialog.md +97 -69
- package/docs/pages/components/drawer.md +33 -33
- package/docs/pages/components/indicator.md +12 -12
- package/docs/pages/components/navbar.md +41 -9
- package/docs/pages/components/pagination.md +7 -7
- package/docs/pages/components/progress.md +18 -13
- package/docs/pages/components/rating.md +19 -19
- package/docs/pages/components/reveal.md +2 -0
- package/docs/pages/components/segmented.md +35 -31
- package/docs/pages/components/skeleton.md +10 -8
- package/docs/pages/components/spinner.md +21 -15
- package/docs/pages/components/table.md +26 -28
- package/docs/pages/enhancements/flyout.md +94 -43
- package/docs/pages/enhancements/in-view.md +3 -1
- package/docs/pages/enhancements/scrollspy.md +51 -18
- package/docs/pages/enhancements/tabs.md +43 -37
- package/docs/pages/enhancements/tooltip.md +4 -2
- package/docs/pages/forms/ajax.md +66 -0
- package/docs/pages/forms/choice-cards.md +8 -8
- package/docs/pages/forms/color-swatches.md +12 -12
- package/docs/pages/forms/form-actions.md +23 -0
- package/docs/pages/forms/joined-controls.md +7 -7
- package/docs/pages/forms/labels.md +11 -11
- package/docs/pages/forms/overview.md +35 -29
- package/docs/pages/forms/states-and-sizes.md +9 -9
- package/docs/pages/forms/switch.md +35 -4
- package/docs/pages/forms/validation.md +16 -16
- package/docs/pages/foundations/theming.md +32 -2
- package/docs/pages/foundations/tokens.md +7 -5
- package/docs/pages/guides/coding-agents.md +18 -0
- package/docs/pages/guides/introduction.md +1 -1
- package/package.json +2 -1
- package/reserved-classes.json +1 -0
- package/skills/actual-css/SKILL.md +7 -0
- package/src/cli/actual-css.js +1 -1
- package/src/css/components/badge.css +10 -6
- package/src/css/components/button.css +20 -7
- package/src/css/components/join.css +14 -4
- package/src/css/components/navbar.css +83 -1
- package/src/css/components/pagination.css +3 -1
- package/src/css/components/segmented.css +27 -7
- package/src/css/core/theme.css +11 -9
- package/src/css/core/tokens.css +7 -1
- package/src/css/core/variants.css +2 -0
- package/src/css/effects/reveal.css +15 -6
- package/src/css/forms/control.css +11 -1
- package/src/css/forms/form.css +14 -4
- package/src/css/forms/switch.css +32 -7
- package/src/js/ajax.js +18 -1
- package/src/js/context-menu.js +1 -3
- package/src/js/flyout.js +14 -5
- package/src/js/in-view.js +41 -30
- package/src/js/menu.js +9 -21
- package/src/js/surface.js +38 -0
- package/src/tooling/design-tokens.js +1 -0
- package/src/tooling/theme-contrast.js +22 -11
- package/tokens.json +1 -0
package/src/js/in-view.js
CHANGED
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
*
|
|
18
18
|
* A pending element keeps its text in the accessibility tree and in the tab
|
|
19
19
|
* order; effects hide it with opacity alone. `focusin` releases it at once and
|
|
20
|
-
* finishes
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* finishes its entrance, also when the element was already released and the
|
|
21
|
+
* entrance is still running or waiting out a delay, so keyboard focus never
|
|
22
|
+
* lands on invisible or fading content. In-page find still matches the text,
|
|
23
|
+
* because nothing is removed from the layer.
|
|
23
24
|
*
|
|
24
25
|
* One initial IntersectionObserver per document protects content already in
|
|
25
26
|
* view. Optional data-in-view-margin values share additional observers for
|
|
@@ -82,31 +83,42 @@ function triggerFor(connection, margin) {
|
|
|
82
83
|
return observer;
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
// Releasing the state also records the entrance it leaves running, so focus
|
|
87
|
+
// can finish it later. The entrance is what the release started, found by
|
|
88
|
+
// difference, plus what already runs on the element and its direct children:
|
|
89
|
+
// an element visible at load never goes pending and plays its first-render
|
|
90
|
+
// entrance instead. The runtime still names no effect, and a deeper component's
|
|
91
|
+
// own motion is left alone.
|
|
85
92
|
function reveal(record) {
|
|
86
93
|
if (record.done) return;
|
|
87
94
|
record.done = true;
|
|
88
|
-
record.element.classList.remove(CLASSES.pending);
|
|
89
|
-
record.initialObserver.unobserve(record.element);
|
|
90
|
-
record.observer.unobserve(record.element);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Focus reached a pending element: the content must be usable on this frame,
|
|
94
|
-
// not after an entrance. Only the animations that releasing the state started
|
|
95
|
-
// are finished, found by difference, so the runtime still names no effect and
|
|
96
|
-
// leaves a nested component's own motion alone. A CSS :focus-within override
|
|
97
|
-
// cannot do this: it lapses on blur and the entrance replays from the start.
|
|
98
|
-
function revealNow(record) {
|
|
99
|
-
if (record.done) return;
|
|
100
95
|
const { element } = record;
|
|
101
96
|
const running = new Set(element.getAnimations({ subtree: true }));
|
|
102
|
-
|
|
97
|
+
element.classList.remove(CLASSES.pending);
|
|
98
|
+
record.initialObserver.unobserve(element);
|
|
99
|
+
record.observer.unobserve(element);
|
|
103
100
|
// getAnimations() flushes style, so the entrance released above is listed.
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
record.entrance = element.getAnimations({ subtree: true }).filter((animation) => {
|
|
102
|
+
const target = animation.effect?.target;
|
|
103
|
+
const owned = target === element || target?.parentElement === element;
|
|
106
104
|
// finish() throws on an animation that never ends.
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
return (
|
|
106
|
+
(owned || !running.has(animation)) &&
|
|
107
|
+
animation.effect?.getComputedTiming().endTime !== Infinity
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Focus entered the element: the content must be usable on this frame, not at
|
|
113
|
+
// the end of an entrance, whether the element was pending, just released or
|
|
114
|
+
// still playing its first-render entrance. A CSS :focus-within override cannot
|
|
115
|
+
// do this: on blur the entrance resumes from its timeline, or replays.
|
|
116
|
+
function revealNow(record) {
|
|
117
|
+
reveal(record);
|
|
118
|
+
for (const animation of record.entrance) {
|
|
119
|
+
if (animation.playState !== "finished") animation.finish();
|
|
109
120
|
}
|
|
121
|
+
record.entrance = [];
|
|
110
122
|
}
|
|
111
123
|
|
|
112
124
|
function cleanup(record, records) {
|
|
@@ -127,24 +139,23 @@ function connect(element) {
|
|
|
127
139
|
initialObserver: observer,
|
|
128
140
|
observer: triggerFor(connection, element.getAttribute("data-in-view-margin")),
|
|
129
141
|
done: false,
|
|
142
|
+
entrance: [],
|
|
130
143
|
controller: new AbortController(),
|
|
131
144
|
};
|
|
132
145
|
records.set(element, record);
|
|
133
146
|
|
|
134
|
-
// Focus may already sit inside the element before this registration (an
|
|
135
|
-
// autofocused control, a second runtime copy attaching late). Hiding it then
|
|
136
|
-
// would leave focus invisible until the observer's first callback.
|
|
137
|
-
if (element.contains(element.ownerDocument.activeElement)) {
|
|
138
|
-
reveal(record);
|
|
139
|
-
return () => cleanup(record, records);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
147
|
// Focus moves the page first, so this is the guarantee, not the observer:
|
|
143
|
-
// the element is visible by the time its descendant takes focus.
|
|
148
|
+
// the element is visible by the time its descendant takes focus. It stays
|
|
149
|
+
// after the release, while the entrance may still run.
|
|
144
150
|
element.addEventListener("focusin", () => revealNow(record), {
|
|
145
151
|
signal: record.controller.signal,
|
|
146
152
|
});
|
|
147
|
-
|
|
153
|
+
|
|
154
|
+
// Focus may already sit inside the element before this registration (an
|
|
155
|
+
// autofocused control, a second runtime copy attaching late). Hiding it then
|
|
156
|
+
// would leave focus invisible until the observer's first callback.
|
|
157
|
+
if (element.contains(element.ownerDocument.activeElement)) revealNow(record);
|
|
158
|
+
else observer.observe(element);
|
|
148
159
|
|
|
149
160
|
return () => cleanup(record, records);
|
|
150
161
|
}
|
package/src/js/menu.js
CHANGED
|
@@ -61,7 +61,7 @@ export function focusLastMenuItem(menu) {
|
|
|
61
61
|
lastItem(getMenuItems(menu))?.focus();
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export function onMenuKeydown(e, {
|
|
64
|
+
export function onMenuKeydown(e, { navigate = true } = {}) {
|
|
65
65
|
if (shouldIgnoreKey(e)) return;
|
|
66
66
|
const menu = e.currentTarget;
|
|
67
67
|
if (navigate) {
|
|
@@ -77,16 +77,10 @@ export function onMenuKeydown(e, { close, navigate = true }) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
case "Enter":
|
|
85
|
-
case " ":
|
|
86
|
-
if (activateCurrentItem(menu)) {
|
|
87
|
-
e.preventDefault();
|
|
88
|
-
}
|
|
89
|
-
break;
|
|
80
|
+
// No Tab case: the browser moves focus, and surface.js closes the menu once
|
|
81
|
+
// focus lands outside it, without bouncing focus through the trigger first.
|
|
82
|
+
if ((e.key === "Enter" || e.key === " ") && activateCurrentItem(menu)) {
|
|
83
|
+
e.preventDefault();
|
|
90
84
|
}
|
|
91
85
|
}
|
|
92
86
|
|
|
@@ -96,7 +90,7 @@ export function onMenuKeydown(e, { close, navigate = true }) {
|
|
|
96
90
|
// Each retain returns a release(); the wiring is torn down on the last one.
|
|
97
91
|
const menuConnections = new WeakMap();
|
|
98
92
|
|
|
99
|
-
export function connectMenu(menu
|
|
93
|
+
export function connectMenu(menu) {
|
|
100
94
|
let entry = menuConnections.get(menu);
|
|
101
95
|
|
|
102
96
|
if (!entry) {
|
|
@@ -109,15 +103,9 @@ export function connectMenu(menu, { close }) {
|
|
|
109
103
|
signal: controller.signal,
|
|
110
104
|
})
|
|
111
105
|
: null;
|
|
112
|
-
menu.addEventListener(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
onMenuKeydown(event, {
|
|
116
|
-
close: () => close(menu),
|
|
117
|
-
navigate: !focusGroup,
|
|
118
|
-
}),
|
|
119
|
-
{ signal: controller.signal },
|
|
120
|
-
);
|
|
106
|
+
menu.addEventListener("keydown", (event) => onMenuKeydown(event, { navigate: !focusGroup }), {
|
|
107
|
+
signal: controller.signal,
|
|
108
|
+
});
|
|
121
109
|
menu.addEventListener(
|
|
122
110
|
"click",
|
|
123
111
|
(event) => {
|
package/src/js/surface.js
CHANGED
|
@@ -428,9 +428,47 @@ function onDocumentClick(e) {
|
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
430
|
|
|
431
|
+
/*
|
|
432
|
+
* Focus that lands outside an open surface closes it, without moving focus:
|
|
433
|
+
* Tab, Shift+Tab or a script took it somewhere on purpose. Left open, the
|
|
434
|
+
* panel could cover the very control that just received focus (WCAG 2.4.11).
|
|
435
|
+
* Listening to where focus arrives, not to the Tab key, covers every route
|
|
436
|
+
* and leaves the browser's own sequential navigation untouched.
|
|
437
|
+
*
|
|
438
|
+
* What keeps a surface open: focus inside it, or on what opened it — any
|
|
439
|
+
* trigger naming it through aria-controls, the anchor, the source region of a
|
|
440
|
+
* context menu, or the element focus returns to. A context menu's trigger may
|
|
441
|
+
* be a point, so each one is checked as a Node. autoClose "false" is the
|
|
442
|
+
* application's explicit claim on closing, so focus leaves it alone too.
|
|
443
|
+
*/
|
|
444
|
+
function keepsSurfaceOpen(menu, state, target) {
|
|
445
|
+
if (menu.contains(target)) return true;
|
|
446
|
+
const owners = [
|
|
447
|
+
state.trigger,
|
|
448
|
+
state.source,
|
|
449
|
+
surfaceFocusReturns.get(menu),
|
|
450
|
+
...linkedTriggers(menu),
|
|
451
|
+
];
|
|
452
|
+
return owners.some((owner) => owner instanceof Node && owner.contains(target));
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function onDocumentFocusIn(e) {
|
|
456
|
+
// composedPath() reaches past a shadow host to the element that took focus.
|
|
457
|
+
const target = e.composedPath()[0] ?? e.target;
|
|
458
|
+
if (!(target instanceof Node)) return;
|
|
459
|
+
|
|
460
|
+
for (const menu of [...openSurfaces]) {
|
|
461
|
+
if (menu.ownerDocument !== e.currentTarget) continue;
|
|
462
|
+
const state = surfaceMap.get(menu);
|
|
463
|
+
if (!state || state.autoClose === "false") continue;
|
|
464
|
+
if (!keepsSurfaceOpen(menu, state, target)) closeSurface(menu, { restoreFocus: false });
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
431
468
|
function ensureDocumentClick(menu) {
|
|
432
469
|
const doc = menu.ownerDocument;
|
|
433
470
|
if (!doc || clickBoundDocuments.has(doc)) return;
|
|
434
471
|
clickBoundDocuments.add(doc);
|
|
435
472
|
doc.addEventListener("click", onDocumentClick);
|
|
473
|
+
doc.addEventListener("focusin", onDocumentFocusIn);
|
|
436
474
|
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* (`bun run report:theme-contrast`).
|
|
6
6
|
*
|
|
7
7
|
* Measured per island (one per color scheme the theme declares):
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
8
|
+
* - what identifies a resting control against --surface (3:1): the edge of a
|
|
9
|
+
* field, checkbox and radio, the track edge or knob of an unchecked switch
|
|
10
10
|
* - soft ink against the resting and the hovered soft fill (4.5:1), on each
|
|
11
11
|
* surface a soft element sits on
|
|
12
12
|
* - the solid pairs, -fg on the intent fill (4.5:1); a fill painted by a
|
|
@@ -75,8 +75,9 @@ function islandMarkup(id, scheme) {
|
|
|
75
75
|
/* Controls whose resting edge is all that identifies them (WCAG 1.4.11): the
|
|
76
76
|
edge against the surface around them needs 3:1. The field is read on its
|
|
77
77
|
block-end side, the one an underline-only theme (material) keeps. An
|
|
78
|
-
unchecked switch is
|
|
79
|
-
|
|
78
|
+
unchecked switch is read on its track edge or its knob, whichever is
|
|
79
|
+
stronger: the core track is the --border-control edge, and a theme may move
|
|
80
|
+
the cue to a dark knob on a quiet track (docs/pages/forms/switch.md). */
|
|
80
81
|
export const CONTROLS = [
|
|
81
82
|
["field", '<input class="input">'],
|
|
82
83
|
["checkbox", '<input class="check" type="checkbox">'],
|
|
@@ -144,7 +145,7 @@ export async function measureContrast({ css, themes, label = "default" }) {
|
|
|
144
145
|
const colors = await view.evaluate(`(() => {
|
|
145
146
|
const rgba = ${RASTERIZE};
|
|
146
147
|
return [...document.querySelectorAll("[id^=island-]")].map((island) => {
|
|
147
|
-
const cs = (el) => getComputedStyle(el);
|
|
148
|
+
const cs = (el, pseudo = null) => getComputedStyle(el, pseudo);
|
|
148
149
|
const pairs = {};
|
|
149
150
|
for (const el of island.querySelectorAll("[data-pair]")) {
|
|
150
151
|
// The invalid field's block-end border carries --form-invalid-border,
|
|
@@ -205,11 +206,17 @@ export async function measureContrast({ css, themes, label = "default" }) {
|
|
|
205
206
|
}
|
|
206
207
|
const box = island.querySelector("[data-controls]");
|
|
207
208
|
const controls = { backdrop: rgba(cs(box).backgroundColor), edges: {} };
|
|
209
|
+
// The cues that can identify each control; the best one counts. A field
|
|
210
|
+
// shows its lower edge, a switch its track edge or its knob (the core
|
|
211
|
+
// pill, or a theme's dark knob on a quiet track), any other control its
|
|
212
|
+
// edge.
|
|
213
|
+
const cues = {
|
|
214
|
+
field: (s) => [s.borderBlockEndColor],
|
|
215
|
+
switch: (s, el) => [cs(el, "::before").backgroundColor, s.borderTopColor],
|
|
216
|
+
};
|
|
208
217
|
for (const el of box.querySelectorAll("[data-control]")) {
|
|
209
|
-
const
|
|
210
|
-
controls.edges[el.dataset.control] = rgba
|
|
211
|
-
el.dataset.control === "field" ? s.borderBlockEndColor : s.borderTopColor,
|
|
212
|
-
);
|
|
218
|
+
const read = cues[el.dataset.control] ?? ((s) => [s.borderTopColor]);
|
|
219
|
+
controls.edges[el.dataset.control] = read(cs(el), el).map(rgba);
|
|
213
220
|
}
|
|
214
221
|
return { pairs, soft, solid, controls };
|
|
215
222
|
});
|
|
@@ -264,7 +271,11 @@ export async function measureContrast({ css, themes, label = "default" }) {
|
|
|
264
271
|
value:
|
|
265
272
|
controls.backdrop[3] < 255
|
|
266
273
|
? null
|
|
267
|
-
:
|
|
274
|
+
: Math.max(
|
|
275
|
+
...controls.edges[kind].map((cue) =>
|
|
276
|
+
ratio(composite(cue, controls.backdrop), controls.backdrop),
|
|
277
|
+
),
|
|
278
|
+
),
|
|
268
279
|
})),
|
|
269
280
|
focusSurface: pair("focus-surface"),
|
|
270
281
|
focusSolid: pair("focus-solid"),
|
|
@@ -362,7 +373,7 @@ export function formatContrast(rows) {
|
|
|
362
373
|
);
|
|
363
374
|
}
|
|
364
375
|
|
|
365
|
-
lines.push("", "Control
|
|
376
|
+
lines.push("", "Control cue at rest (edge, or a switch's knob, vs --surface), needs 3:1.", "");
|
|
366
377
|
lines.push(`${"theme".padEnd(width)} scheme control ratio`);
|
|
367
378
|
for (const row of rows) {
|
|
368
379
|
for (const { kind, value } of row.controls ?? []) {
|