@sdxc/ui 2026.10.12 → 2026.10.14
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/README.md +524 -668
- package/dist/animations/transitions.d.ts +45 -20
- package/dist/animations/transitions.js +108 -35
- package/dist/behaviors/announcer.js +2 -1
- package/dist/behaviors/toaster.js +2 -1
- package/dist/components/accordion.js +5 -9
- package/dist/components/alert-dialog.js +3 -3
- package/dist/components/alert.js +11 -2
- package/dist/components/attachment.js +1 -1
- package/dist/components/badge.js +2 -1
- package/dist/components/breadcrumbs.js +17 -9
- package/dist/components/bubble.js +6 -5
- package/dist/components/button.d.ts +14 -0
- package/dist/components/button.js +61 -20
- package/dist/components/calendar.js +12 -8
- package/dist/components/card.d.ts +5 -3
- package/dist/components/card.js +32 -14
- package/dist/components/carousel.js +4 -6
- package/dist/components/chart.js +5 -4
- package/dist/components/checkbox.js +2 -2
- package/dist/components/color-picker.js +8 -11
- package/dist/components/color-slider.js +16 -5
- package/dist/components/color-swatch-picker.js +7 -4
- package/dist/components/color-wheel.js +7 -9
- package/dist/components/combobox.js +5 -1
- package/dist/components/command.d.ts +3 -3
- package/dist/components/command.js +25 -28
- package/dist/components/context-menu.js +4 -4
- package/dist/components/date-field.js +2 -1
- package/dist/components/date-picker.js +12 -16
- package/dist/components/description.js +2 -2
- package/dist/components/dialog.js +19 -15
- package/dist/components/disclosure.js +15 -17
- package/dist/components/drawer.d.ts +5 -5
- package/dist/components/drawer.js +38 -33
- package/dist/components/drop-indicator.js +4 -10
- package/dist/components/empty.js +13 -6
- package/dist/components/field-error.js +2 -1
- package/dist/components/file-trigger.js +7 -10
- package/dist/components/grid-list.js +15 -16
- package/dist/components/group.js +5 -6
- package/dist/components/heading.js +2 -1
- package/dist/components/hover-card.js +4 -5
- package/dist/components/image-placeholder.js +17 -12
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/input.js +8 -11
- package/dist/components/item.js +4 -7
- package/dist/components/keyboard.js +9 -9
- package/dist/components/link-button.js +26 -8
- package/dist/components/listbox.d.ts +3 -2
- package/dist/components/listbox.js +9 -8
- package/dist/components/menu.js +6 -6
- package/dist/components/menubar.js +6 -5
- package/dist/components/message-scroller.js +4 -6
- package/dist/components/message.js +2 -2
- package/dist/components/meter.js +2 -2
- package/dist/components/modal.d.ts +2 -2
- package/dist/components/modal.js +12 -24
- package/dist/components/navigation-menu.js +5 -4
- package/dist/components/number-field.js +6 -6
- package/dist/components/overlay-arrow.js +2 -2
- package/dist/components/pagination.js +3 -1
- package/dist/components/popover.js +7 -19
- package/dist/components/progress-bar.js +2 -2
- package/dist/components/range-calendar.js +5 -3
- package/dist/components/resizable.js +8 -3
- package/dist/components/search-field.js +7 -7
- package/dist/components/select.js +26 -39
- package/dist/components/sheet.js +30 -22
- package/dist/components/shortcut-list.js +2 -2
- package/dist/components/sidebar.js +24 -22
- package/dist/components/slider.d.ts +3 -3
- package/dist/components/slider.js +18 -6
- package/dist/components/switch.js +2 -2
- package/dist/components/table.d.ts +15 -2
- package/dist/components/table.js +36 -14
- package/dist/components/tag-group.js +10 -5
- package/dist/components/text.js +2 -2
- package/dist/components/time-field.js +2 -1
- package/dist/components/toast.js +5 -2
- package/dist/components/toggle-button.js +28 -12
- package/dist/components/tree.js +9 -5
- package/dist/components/typeset.js +5 -2
- package/dist/components/youtube-embed.d.ts +35 -0
- package/dist/components/youtube-embed.js +29 -0
- package/dist/mixins/carousel-controls.js +11 -15
- package/dist/mixins/clear-field.js +4 -5
- package/dist/mixins/context-menu.js +5 -8
- package/dist/mixins/grid-list-keys.js +5 -2
- package/dist/mixins/listbox-keys.js +1 -1
- package/dist/mixins/message-follow.js +7 -13
- package/dist/mixins/treeKeys.js +5 -3
- package/dist/styles/floating-surface.d.ts +62 -14
- package/dist/styles/floating-surface.js +67 -10
- package/dist/styles/hit-area.d.ts +36 -0
- package/dist/styles/hit-area.js +48 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/output-caption-text.d.ts +3 -2
- package/dist/styles/output-caption-text.js +4 -3
- package/dist/styles/range-thumb-appearance.js +17 -18
- package/dist/utils/glyph-edges.d.ts +24 -0
- package/dist/utils/glyph-edges.js +46 -0
- package/package.json +5 -4
- package/src/reset.css +4 -1
- package/src/theme.css +49 -2
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A YouTube player sized to its container: a 16:9 `<iframe>` served from YouTube's
|
|
3
|
+
* privacy-enhanced host, so a visitor receives no YouTube cookies until they press play,
|
|
4
|
+
* and lazy-loaded so a video below the fold costs nothing until it scrolls into view.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Prop types for {@link YouTubeEmbed}.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace YouTubeEmbed {
|
|
14
|
+
/**
|
|
15
|
+
* Props accepted by {@link YouTubeEmbed}.
|
|
16
|
+
*/
|
|
17
|
+
interface Props extends Omit<TagProps<"iframe">, "src" | "title" | "allow" | "referrerpolicy" | "referrerPolicy"> {
|
|
18
|
+
/** The eleven-character id from the video's `watch?v=` or `youtu.be/` URL. */
|
|
19
|
+
videoId: string;
|
|
20
|
+
/** Seconds into the video the player starts at; zero or less starts at the beginning. */
|
|
21
|
+
start?: number;
|
|
22
|
+
/** The frame's accessible name, announced before a reader enters the player. */
|
|
23
|
+
title: string;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Renders the player filling its container's inline axis at 16:9. The frame always sends
|
|
28
|
+
* the embedding page's origin as referrer, without which YouTube refuses to play.
|
|
29
|
+
*
|
|
30
|
+
* @param handle Runtime handle carrying the host `<iframe>`'s props.
|
|
31
|
+
* @returns The render function producing the player's markup.
|
|
32
|
+
* @example <YouTubeEmbed videoId="dQw4w9WgXcQ" title={t("video.title")} />
|
|
33
|
+
* @example <YouTubeEmbed videoId="dQw4w9WgXcQ" start={90} title={t("video.title")} />
|
|
34
|
+
*/
|
|
35
|
+
export declare function YouTubeEmbed(handle: Handle<YouTubeEmbed.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/component/jsx-runtime";
|
|
2
|
+
import { border } from "@sdxc/u/color";
|
|
3
|
+
import { rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { block } from "@sdxc/u/layout";
|
|
5
|
+
import { aspect, is } from "@sdxc/u/size";
|
|
6
|
+
/** The host every player loads from; a page's `frame-src` has to allow it. */
|
|
7
|
+
const EMBED_ORIGIN = "https://www.youtube-nocookie.com";
|
|
8
|
+
/** Loading strategy {@link YouTubeEmbed} falls back to when `loading` is omitted. */
|
|
9
|
+
const DEFAULT_LOADING = "lazy";
|
|
10
|
+
/** The player features YouTube asks an embedding page to delegate. */
|
|
11
|
+
const ALLOWED_FEATURES = "accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";
|
|
12
|
+
/**
|
|
13
|
+
* Renders the player filling its container's inline axis at 16:9. The frame always sends
|
|
14
|
+
* the embedding page's origin as referrer, without which YouTube refuses to play.
|
|
15
|
+
*
|
|
16
|
+
* @param handle Runtime handle carrying the host `<iframe>`'s props.
|
|
17
|
+
* @returns The render function producing the player's markup.
|
|
18
|
+
* @example <YouTubeEmbed videoId="dQw4w9WgXcQ" title={t("video.title")} />
|
|
19
|
+
* @example <YouTubeEmbed videoId="dQw4w9WgXcQ" start={90} title={t("video.title")} />
|
|
20
|
+
*/
|
|
21
|
+
export function YouTubeEmbed(handle) {
|
|
22
|
+
return () => {
|
|
23
|
+
let { videoId, start, title, loading, mix, ...rest } = handle.props;
|
|
24
|
+
let src = new URL(`/embed/${encodeURIComponent(videoId)}`, EMBED_ORIGIN);
|
|
25
|
+
if (start !== undefined && start >= 1)
|
|
26
|
+
src.searchParams.set("start", String(Math.floor(start)));
|
|
27
|
+
return (_jsx("iframe", { ...rest, "data-slot": "youtube-embed", src: src.href, title: title, loading: loading ?? DEFAULT_LOADING, referrerpolicy: "strict-origin-when-cross-origin", allow: ALLOWED_FEATURES, allowFullScreen: true, mix: [block(), is("full"), aspect("video"), border("none"), rounded("lg"), mix] }));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -89,25 +89,21 @@ function scrollToSlide(node, index) {
|
|
|
89
89
|
let slide = slides[index];
|
|
90
90
|
if (slide === undefined)
|
|
91
91
|
return;
|
|
92
|
-
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* page — and so scrolls the carousel by however far it sits from that ancestor.
|
|
92
|
+
/**
|
|
93
|
+
* Read from the viewport's own box, so the target holds wherever the carousel sits;
|
|
94
|
+
* `offsetLeft` counts from the nearest positioned ancestor, usually the page.
|
|
96
95
|
*/
|
|
97
96
|
let viewportEdges = node.getBoundingClientRect();
|
|
98
97
|
let slideEdges = slide.getBoundingClientRect();
|
|
99
|
-
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* first is still animating moves by an amount that is already stale; a position is the
|
|
103
|
-
* same answer however many times it is asked, and the scroller simply retargets.
|
|
98
|
+
/**
|
|
99
|
+
* A position, so a command arriving mid-animation asks for the same answer and the
|
|
100
|
+
* scroller retargets; a distance would be measured from wherever the viewport stood then.
|
|
104
101
|
*/
|
|
105
|
-
node.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
102
|
+
let left = node.scrollLeft +
|
|
103
|
+
(isRightToLeft(node)
|
|
104
|
+
? slideEdges.right - viewportEdges.right
|
|
105
|
+
: slideEdges.left - viewportEdges.left);
|
|
106
|
+
node.scrollTo({ left });
|
|
111
107
|
}
|
|
112
108
|
/**
|
|
113
109
|
* Reads which slide the viewport has settled on: the one whose start edge sits nearest
|
|
@@ -76,12 +76,11 @@ function resolveClearTarget(button) {
|
|
|
76
76
|
export const clearField = createMixin((handle) => {
|
|
77
77
|
handle.addEventListener("insert", (event) => {
|
|
78
78
|
let button = event.node;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
* or a `commandfor` the consumer rewrites — shows from the moment script runs, so
|
|
83
|
-
* its press stays reachable while the pairing settles.
|
|
79
|
+
/**
|
|
80
|
+
* Unresolved while the input renders after the button or a rewritten `commandfor`
|
|
81
|
+
* settles; the button then shows from the moment script runs, so its press stays reachable.
|
|
84
82
|
*/
|
|
83
|
+
let input = resolveClearTarget(button);
|
|
85
84
|
if (!input) {
|
|
86
85
|
button.hidden = false;
|
|
87
86
|
return;
|
|
@@ -56,17 +56,14 @@ export const contextMenu = createMixin((handle) => {
|
|
|
56
56
|
return createElement(handle.element, {
|
|
57
57
|
mix: [
|
|
58
58
|
attrs({ "aria-controls": id, "aria-haspopup": "menu" }),
|
|
59
|
+
/**
|
|
60
|
+
* A pointer request opens once its button is released: a `popover="auto"` surface reads
|
|
61
|
+
* the summoning press's pointerdown and pointerup as a click away. A keyboard request
|
|
62
|
+
* reports no button and has no release to wait for, so it opens where it stands.
|
|
63
|
+
*/
|
|
59
64
|
on("contextmenu", (event) => {
|
|
60
65
|
event.preventDefault();
|
|
61
66
|
let point = { x: event.clientX, y: event.clientY };
|
|
62
|
-
/*
|
|
63
|
-
* A `popover="auto"` surface is dismissed by a press that begins outside it, and
|
|
64
|
-
* the press asking for the menu began before the menu existed: the browser pairs
|
|
65
|
-
* that pointerdown with the pointerup still to come and reads the pair as a click
|
|
66
|
-
* away. Opening once the button is released leaves the surface to the next press
|
|
67
|
-
* instead of the one that summoned it. A menu asked for from the keyboard reports
|
|
68
|
-
* no button and has no release to wait for, so it opens where it stands.
|
|
69
|
-
*/
|
|
70
67
|
if (event.button !== SECONDARY_BUTTON) {
|
|
71
68
|
openSurfaceAt(id, point, options);
|
|
72
69
|
return;
|
|
@@ -180,11 +180,15 @@ export const gridListKeys = createMixin((handle) => {
|
|
|
180
180
|
return;
|
|
181
181
|
setRovingTabindex(rows, stopAt(rows, position));
|
|
182
182
|
}),
|
|
183
|
+
/** A shift-click spans rows, so the grid keeps that gesture for selection. */
|
|
183
184
|
on("pointerdown", (event) => {
|
|
184
|
-
/* A shift-click spans rows, so the grid keeps that gesture for selection. */
|
|
185
185
|
if (event.shiftKey)
|
|
186
186
|
event.preventDefault();
|
|
187
187
|
}),
|
|
188
|
+
/**
|
|
189
|
+
* Selection belongs to the row: a click inside an action cell moves focus there and
|
|
190
|
+
* leaves the rest to that cell's own action.
|
|
191
|
+
*/
|
|
188
192
|
on("click", (event) => {
|
|
189
193
|
if (hostNode === undefined)
|
|
190
194
|
return;
|
|
@@ -193,7 +197,6 @@ export const gridListKeys = createMixin((handle) => {
|
|
|
193
197
|
if (position === null)
|
|
194
198
|
return;
|
|
195
199
|
focusElement(rows, stopAt(rows, position));
|
|
196
|
-
/* Selection belongs to the row, leaving an action cell's click to its own action. */
|
|
197
200
|
if (position.cellIndex !== null)
|
|
198
201
|
return;
|
|
199
202
|
let key = resolveKey(model, rowKeyOf(rows[position.rowIndex]));
|
|
@@ -59,7 +59,7 @@ export const listboxKeys = createMixin((handle) => {
|
|
|
59
59
|
getHostNode()?.dispatchEvent(new ListboxChangeEvent({ value, activeValue }));
|
|
60
60
|
}
|
|
61
61
|
return [
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
63
|
* Moving past the first option carries on to the last, matching the wrap the
|
|
64
64
|
* forward direction already makes. The primitive's own handler runs on this same
|
|
65
65
|
* host, so the press is settled here before it reaches that one.
|
|
@@ -126,11 +126,6 @@ function precedes(node, reference) {
|
|
|
126
126
|
* @param model Model whose pinned state gates the jump.
|
|
127
127
|
*/
|
|
128
128
|
function stickToEndIfPinned(host, model) {
|
|
129
|
-
/*
|
|
130
|
-
* Following lands at once, so a viewport that scrolls smoothly still keeps up with a
|
|
131
|
-
* reply arriving a word at a time: an eased scroll would restart on every word and
|
|
132
|
-
* spend the whole answer travelling.
|
|
133
|
-
*/
|
|
134
129
|
if (model.pinned)
|
|
135
130
|
host.scrollTo({ top: host.scrollHeight, behavior: "instant" });
|
|
136
131
|
}
|
|
@@ -335,10 +330,9 @@ export const messageFollow = createMixin((handle) => {
|
|
|
335
330
|
}
|
|
336
331
|
handle.addEventListener("insert", (event) => {
|
|
337
332
|
hostNode = event.node;
|
|
338
|
-
|
|
339
|
-
* The
|
|
340
|
-
*
|
|
341
|
-
* rendered inside it does.
|
|
333
|
+
/**
|
|
334
|
+
* The frame around the scroller answers the press, so a control floating over the
|
|
335
|
+
* log reaches the behavior the same way one rendered inside it does.
|
|
342
336
|
*/
|
|
343
337
|
let pressScope = event.node.parentElement ?? event.node;
|
|
344
338
|
pressScope.addEventListener("click", (pressEvent) => {
|
|
@@ -354,14 +348,14 @@ export const messageFollow = createMixin((handle) => {
|
|
|
354
348
|
ensureItemsObserved(hostNode, boundModel);
|
|
355
349
|
resync(hostNode, boundModel, false);
|
|
356
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Watches text as well as nodes: a reply arriving a word at a time grows by rewriting
|
|
353
|
+
* the row it is already in, and following keeps up with that.
|
|
354
|
+
*/
|
|
357
355
|
let mutationObserver = new MutationObserver((records) => {
|
|
358
356
|
if (hostNode && boundModel)
|
|
359
357
|
handleMutations(hostNode, boundModel, records);
|
|
360
358
|
});
|
|
361
|
-
/*
|
|
362
|
-
* Text counts as growth, not just nodes: a reply that arrives a word at a time grows
|
|
363
|
-
* by rewriting the row it is already in, and following has to keep up with that.
|
|
364
|
-
*/
|
|
365
359
|
mutationObserver.observe(event.node, {
|
|
366
360
|
childList: true,
|
|
367
361
|
subtree: true,
|
package/dist/mixins/treeKeys.js
CHANGED
|
@@ -197,6 +197,10 @@ export const treeKeys = createMixin((handle) => {
|
|
|
197
197
|
setRovingTabindex(rows.map((candidate) => candidate.element), row.element);
|
|
198
198
|
}
|
|
199
199
|
}),
|
|
200
|
+
/**
|
|
201
|
+
* Listens in the capture phase: a `toggle` event stays on the `<details>` it fires at,
|
|
202
|
+
* so the host hears it on the way down.
|
|
203
|
+
*/
|
|
200
204
|
on("toggle", (event) => {
|
|
201
205
|
if (!hostNode)
|
|
202
206
|
return;
|
|
@@ -208,9 +212,7 @@ export const treeKeys = createMixin((handle) => {
|
|
|
208
212
|
return;
|
|
209
213
|
row.setAttribute("aria-expanded", disclosure.open ? "true" : "false");
|
|
210
214
|
refreshKeys(hostNode, model);
|
|
211
|
-
},
|
|
212
|
-
/* A `toggle` event stays on the `<details>` it fires at, so the host hears it on the way down. */
|
|
213
|
-
true),
|
|
215
|
+
}, true),
|
|
214
216
|
on("keydown", (event) => {
|
|
215
217
|
if (!hostNode)
|
|
216
218
|
return;
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* top.
|
|
2
|
+
* The edge, rounding, tint, and elevation a floating surface — an anchored
|
|
3
|
+
* popover, a hover-revealed card, a navigation panel, a command list — draws
|
|
4
|
+
* on its own host, plus the inset and concentric radius a surface padding a
|
|
5
|
+
* stack of rounded rows shares with them.
|
|
7
6
|
*
|
|
8
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
8
|
* @copyright Sergio Xalambrí 2026
|
|
10
9
|
*/
|
|
11
|
-
import type {
|
|
12
|
-
import type { CSSStyles } from "../utils/css-styles.js";
|
|
10
|
+
import type { UtilityMixin } from "@sdxc/u";
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
12
|
+
* The hairline ring plus soft lift an elevated surface draws its edge with,
|
|
13
|
+
* read from the theme's `--ui-shadow-ring`; the fallback is its light value.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SHADOW_RING = "var(--ui-shadow-ring, 0 0 0 1px rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.06), 0 2px 4px 0 rgb(0 0 0 / 0.04))";
|
|
16
|
+
/**
|
|
17
|
+
* The gap between a floating surface's edge and the rounded rows it stacks,
|
|
18
|
+
* one source for both the padding and the radius derived from it.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SURFACE_PADDING = "var(--ui-surface-padding, 0.25rem)";
|
|
21
|
+
/**
|
|
22
|
+
* Composes the shared floating-surface edge, tint, and elevation as a mixin.
|
|
23
|
+
* The edge is a ring shadow in the composite `box-shadow`'s ring slot over a
|
|
24
|
+
* transparent 1px border, which forced-colors mode still paints as a line.
|
|
17
25
|
*
|
|
18
|
-
* @returns A
|
|
26
|
+
* @returns A mixin ready for a host element's `mix` prop.
|
|
19
27
|
* @example
|
|
20
28
|
* <div
|
|
21
29
|
* popover="auto"
|
|
@@ -27,6 +35,46 @@ import type { CSSStyles } from "../utils/css-styles.js";
|
|
|
27
35
|
* {content}
|
|
28
36
|
* </div>;
|
|
29
37
|
*/
|
|
30
|
-
export declare function floatingSurface<Node extends Element = Element>():
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
export declare function floatingSurface<Node extends Element = Element>(): UtilityMixin<Node>;
|
|
39
|
+
/**
|
|
40
|
+
* Options accepted by {@link surfaceInset}.
|
|
41
|
+
*/
|
|
42
|
+
export declare namespace SurfaceInset {
|
|
43
|
+
interface Options {
|
|
44
|
+
/** Multiple of `--ui-surface-padding` the surface pads its rows by. Defaults to `1`. */
|
|
45
|
+
scale?: number;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Pads a surface around its rounded rows and rounds the surface concentric
|
|
50
|
+
* with them: its radius is the rows' `--ui-radius-md` plus that padding and
|
|
51
|
+
* the surface's edge, so the gap between the curves stays even under any tokens.
|
|
52
|
+
*
|
|
53
|
+
* @param options How many `--ui-surface-padding` steps the surface pads by.
|
|
54
|
+
* @returns A mixin ready for a host element's `mix` prop, after {@link floatingSurface}.
|
|
55
|
+
* @example
|
|
56
|
+
* <Popover id="actions" mix={[surfaceInset()]}>{rows}</Popover>;
|
|
57
|
+
* @example
|
|
58
|
+
* <Popover id="products" mix={[surfaceInset({ scale: 2 })]}>{links}</Popover>;
|
|
59
|
+
*/
|
|
60
|
+
export declare function surfaceInset<Node extends Element = Element>(options?: SurfaceInset.Options): UtilityMixin<Node>;
|
|
61
|
+
/**
|
|
62
|
+
* The padding {@link surfaceInset} applies for a given number of
|
|
63
|
+
* `--ui-surface-padding` steps, for a part that pads along one axis only.
|
|
64
|
+
*
|
|
65
|
+
* @param scale Multiple of `--ui-surface-padding`.
|
|
66
|
+
* @returns A CSS length.
|
|
67
|
+
* @example surfacePadding(1) // "var(--ui-surface-padding, 0.25rem)"
|
|
68
|
+
*/
|
|
69
|
+
export declare function surfacePadding(scale: number): string;
|
|
70
|
+
/**
|
|
71
|
+
* The radius a surface takes to stay concentric with rows set `padding` in
|
|
72
|
+
* from its 1px edge: the rows' own radius plus the padding and that edge.
|
|
73
|
+
*
|
|
74
|
+
* @param padding The gap between the surface edge and its rows.
|
|
75
|
+
* @param rowRadius The radius the rows round their corners with. Defaults to `--ui-radius-md`.
|
|
76
|
+
* @returns A CSS length.
|
|
77
|
+
* @example concentricRadius(surfacePadding(1))
|
|
78
|
+
* @example concentricRadius(surfacePadding(1), "var(--ui-radius-sm, 0.25rem)")
|
|
79
|
+
*/
|
|
80
|
+
export declare function concentricRadius(padding: string, rowRadius?: string): string;
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import { bg, border } from "@sdxc/u/color";
|
|
2
|
-
import { rounded } from "@sdxc/u/effects";
|
|
3
|
-
import { combine, raw } from "@sdxc/u/general";
|
|
2
|
+
import { rounded, shadow } from "@sdxc/u/effects";
|
|
3
|
+
import { combine, raw, vars } from "@sdxc/u/general";
|
|
4
|
+
import { p } from "@sdxc/u/size";
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
6
|
+
* The hairline ring plus soft lift an elevated surface draws its edge with,
|
|
7
|
+
* read from the theme's `--ui-shadow-ring`; the fallback is its light value.
|
|
8
|
+
*/
|
|
9
|
+
export const SHADOW_RING = "var(--ui-shadow-ring, 0 0 0 1px rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.06), 0 2px 4px 0 rgb(0 0 0 / 0.04))";
|
|
10
|
+
/**
|
|
11
|
+
* The gap between a floating surface's edge and the rounded rows it stacks,
|
|
12
|
+
* one source for both the padding and the radius derived from it.
|
|
13
|
+
*/
|
|
14
|
+
export const SURFACE_PADDING = "var(--ui-surface-padding, 0.25rem)";
|
|
15
|
+
/** The radius every row inside a padded surface rounds its own corners with. */
|
|
16
|
+
const ROW_RADIUS = "var(--ui-radius-md, 0.375rem)";
|
|
17
|
+
/**
|
|
18
|
+
* The edge every floating surface draws, in pixels; it sits between the
|
|
19
|
+
* surface's outer curve and its rows, so the concentric radius counts it.
|
|
20
|
+
*/
|
|
21
|
+
const SURFACE_BORDER_WIDTH = 1;
|
|
22
|
+
/**
|
|
23
|
+
* Composes the shared floating-surface edge, tint, and elevation as a mixin.
|
|
24
|
+
* The edge is a ring shadow in the composite `box-shadow`'s ring slot over a
|
|
25
|
+
* transparent 1px border, which forced-colors mode still paints as a line.
|
|
8
26
|
*
|
|
9
|
-
* @returns A
|
|
27
|
+
* @returns A mixin ready for a host element's `mix` prop.
|
|
10
28
|
* @example
|
|
11
29
|
* <div
|
|
12
30
|
* popover="auto"
|
|
@@ -21,10 +39,49 @@ import { combine, raw } from "@sdxc/u/general";
|
|
|
21
39
|
export function floatingSurface() {
|
|
22
40
|
return combine([
|
|
23
41
|
rounded("lg"),
|
|
24
|
-
border({ color: "
|
|
42
|
+
border({ color: "transparent", width: SURFACE_BORDER_WIDTH }),
|
|
25
43
|
bg("neutral.tint"),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}),
|
|
44
|
+
shadow("lg"),
|
|
45
|
+
vars({ "ui-box-shadow-ring": SHADOW_RING }),
|
|
29
46
|
]);
|
|
30
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Pads a surface around its rounded rows and rounds the surface concentric
|
|
50
|
+
* with them: its radius is the rows' `--ui-radius-md` plus that padding and
|
|
51
|
+
* the surface's edge, so the gap between the curves stays even under any tokens.
|
|
52
|
+
*
|
|
53
|
+
* @param options How many `--ui-surface-padding` steps the surface pads by.
|
|
54
|
+
* @returns A mixin ready for a host element's `mix` prop, after {@link floatingSurface}.
|
|
55
|
+
* @example
|
|
56
|
+
* <Popover id="actions" mix={[surfaceInset()]}>{rows}</Popover>;
|
|
57
|
+
* @example
|
|
58
|
+
* <Popover id="products" mix={[surfaceInset({ scale: 2 })]}>{links}</Popover>;
|
|
59
|
+
*/
|
|
60
|
+
export function surfaceInset(options = {}) {
|
|
61
|
+
let padding = surfacePadding(options.scale ?? 1);
|
|
62
|
+
return combine([p(padding), raw({ borderRadius: concentricRadius(padding) })]);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The padding {@link surfaceInset} applies for a given number of
|
|
66
|
+
* `--ui-surface-padding` steps, for a part that pads along one axis only.
|
|
67
|
+
*
|
|
68
|
+
* @param scale Multiple of `--ui-surface-padding`.
|
|
69
|
+
* @returns A CSS length.
|
|
70
|
+
* @example surfacePadding(1) // "var(--ui-surface-padding, 0.25rem)"
|
|
71
|
+
*/
|
|
72
|
+
export function surfacePadding(scale) {
|
|
73
|
+
return scale === 1 ? SURFACE_PADDING : `calc(${SURFACE_PADDING} * ${scale})`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The radius a surface takes to stay concentric with rows set `padding` in
|
|
77
|
+
* from its 1px edge: the rows' own radius plus the padding and that edge.
|
|
78
|
+
*
|
|
79
|
+
* @param padding The gap between the surface edge and its rows.
|
|
80
|
+
* @param rowRadius The radius the rows round their corners with. Defaults to `--ui-radius-md`.
|
|
81
|
+
* @returns A CSS length.
|
|
82
|
+
* @example concentricRadius(surfacePadding(1))
|
|
83
|
+
* @example concentricRadius(surfacePadding(1), "var(--ui-radius-sm, 0.25rem)")
|
|
84
|
+
*/
|
|
85
|
+
export function concentricRadius(padding, rowRadius = ROW_RADIUS) {
|
|
86
|
+
return `calc(${rowRadius} + ${padding} + ${SURFACE_BORDER_WIDTH}px)`;
|
|
87
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `hitArea()` style-mixin factory: an invisible `::after` box that grows
|
|
3
|
+
* a small control's pointer target to `--ui-target-size` on every side it
|
|
4
|
+
* falls short, keeping the visible control at its designed size.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { ElementProps, MixinDescriptor } from "remix/component";
|
|
10
|
+
import type { CSSStyles } from "../utils/css-styles.js";
|
|
11
|
+
/**
|
|
12
|
+
* Options accepted by {@link hitArea}.
|
|
13
|
+
*/
|
|
14
|
+
export interface HitAreaOptions {
|
|
15
|
+
/**
|
|
16
|
+
* How the box finds its host. `"inset"` stretches it from the host's edges and needs a
|
|
17
|
+
* positioned host; `"flex-center"` draws a fixed target-size box that a flex host
|
|
18
|
+
* centres on its content, so it works however a consumer positions the host.
|
|
19
|
+
*
|
|
20
|
+
* @default "inset"
|
|
21
|
+
*/
|
|
22
|
+
anchor?: "inset" | "flex-center";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Extends the host's pointer target to at least `--ui-target-size` in both axes, centred
|
|
26
|
+
* on the host. With the default `"inset"` anchor each inset is clamped at zero, so a host
|
|
27
|
+
* larger than the target keeps its own box, and the host must be `relative()`/`absolute()`.
|
|
28
|
+
*
|
|
29
|
+
* @param options How the box anchors to its host.
|
|
30
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
31
|
+
* @example
|
|
32
|
+
* <button mix={[relative(), hitArea()]} aria-label={t("actions.remove")}><XIcon /></button>
|
|
33
|
+
* @example
|
|
34
|
+
* <button mix={[inlineFlex(), items("center"), justify("center"), hitArea({ anchor: "flex-center" })]} />
|
|
35
|
+
*/
|
|
36
|
+
export declare function hitArea<Node extends Element = Element>(options?: HitAreaOptions): MixinDescriptor<Node, [styles: CSSStyles], ElementProps>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `hitArea()` style-mixin factory: an invisible `::after` box that grows
|
|
3
|
+
* a small control's pointer target to `--ui-target-size` on every side it
|
|
4
|
+
* falls short, keeping the visible control at its designed size.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { combine, pseudoContent } from "@sdxc/u/general";
|
|
10
|
+
import { absolute, inset } from "@sdxc/u/layout";
|
|
11
|
+
import { bs, is } from "@sdxc/u/size";
|
|
12
|
+
import { after } from "@sdxc/u/state";
|
|
13
|
+
/**
|
|
14
|
+
* Minimum pointer target edge: WCAG 2.5.8's 24px by default, raised to 44px
|
|
15
|
+
* for coarse pointers by the theme, and overridable per app or per subtree.
|
|
16
|
+
*/
|
|
17
|
+
const TARGET_SIZE = "var(--ui-target-size, 1.5rem)";
|
|
18
|
+
/**
|
|
19
|
+
* Extends the host's pointer target to at least `--ui-target-size` in both axes, centred
|
|
20
|
+
* on the host. With the default `"inset"` anchor each inset is clamped at zero, so a host
|
|
21
|
+
* larger than the target keeps its own box, and the host must be `relative()`/`absolute()`.
|
|
22
|
+
*
|
|
23
|
+
* @param options How the box anchors to its host.
|
|
24
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
25
|
+
* @example
|
|
26
|
+
* <button mix={[relative(), hitArea()]} aria-label={t("actions.remove")}><XIcon /></button>
|
|
27
|
+
* @example
|
|
28
|
+
* <button mix={[inlineFlex(), items("center"), justify("center"), hitArea({ anchor: "flex-center" })]} />
|
|
29
|
+
*/
|
|
30
|
+
export function hitArea(options = {}) {
|
|
31
|
+
if (options.anchor === "flex-center") {
|
|
32
|
+
return combine([
|
|
33
|
+
after([
|
|
34
|
+
pseudoContent('""'),
|
|
35
|
+
absolute(),
|
|
36
|
+
is(TARGET_SIZE),
|
|
37
|
+
bs(TARGET_SIZE),
|
|
38
|
+
]),
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
return combine([
|
|
42
|
+
after([
|
|
43
|
+
pseudoContent('""'),
|
|
44
|
+
absolute(),
|
|
45
|
+
inset(`min(0px, calc((100% - ${TARGET_SIZE}) / 2))`),
|
|
46
|
+
]),
|
|
47
|
+
]);
|
|
48
|
+
}
|
package/dist/styles/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./chart-palette.js";
|
|
|
11
11
|
export * from "./field-stack-layout.js";
|
|
12
12
|
export * from "./floating-surface.js";
|
|
13
13
|
export * from "./graphic-host.js";
|
|
14
|
+
export * from "./hit-area.js";
|
|
14
15
|
export * from "./interactive-transition.js";
|
|
15
16
|
export * from "./legend-toggle.js";
|
|
16
17
|
export * from "./output-caption-text.js";
|
package/dist/styles/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./chart-palette.js";
|
|
|
11
11
|
export * from "./field-stack-layout.js";
|
|
12
12
|
export * from "./floating-surface.js";
|
|
13
13
|
export * from "./graphic-host.js";
|
|
14
|
+
export * from "./hit-area.js";
|
|
14
15
|
export * from "./interactive-transition.js";
|
|
15
16
|
export * from "./legend-toggle.js";
|
|
16
17
|
export * from "./output-caption-text.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The muted caption typography shared by every live readout rendered through
|
|
3
3
|
* a native `<output>` element: a small point size, a matching line height,
|
|
4
|
-
*
|
|
4
|
+
* the neutral muted foreground color, and tabular digits.
|
|
5
5
|
*
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
@@ -11,7 +11,8 @@ import type { CSSStyles } from "../utils/css-styles.js";
|
|
|
11
11
|
/**
|
|
12
12
|
* `text("sm")`'s font-size/line-height fallback pair matches the
|
|
13
13
|
* `0.875rem`/`calc(1.25 / 0.875)` caption spec exactly, so composing it
|
|
14
|
-
* directly keeps every `<output>` readout visually identical.
|
|
14
|
+
* directly keeps every `<output>` readout visually identical. Tabular digits
|
|
15
|
+
* hold the readout's width steady while its value changes under a drag.
|
|
15
16
|
*
|
|
16
17
|
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
17
18
|
* @example
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { fg } from "@sdxc/u/color";
|
|
2
2
|
import { combine } from "@sdxc/u/general";
|
|
3
|
-
import { text } from "@sdxc/u/typography";
|
|
3
|
+
import { tabularNums, text } from "@sdxc/u/typography";
|
|
4
4
|
/**
|
|
5
5
|
* `text("sm")`'s font-size/line-height fallback pair matches the
|
|
6
6
|
* `0.875rem`/`calc(1.25 / 0.875)` caption spec exactly, so composing it
|
|
7
|
-
* directly keeps every `<output>` readout visually identical.
|
|
7
|
+
* directly keeps every `<output>` readout visually identical. Tabular digits
|
|
8
|
+
* hold the readout's width steady while its value changes under a drag.
|
|
8
9
|
*
|
|
9
10
|
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
10
11
|
* @example
|
|
11
12
|
* <output mix={[outputCaptionText(), mix]}>{value}</output>;
|
|
12
13
|
*/
|
|
13
14
|
export function outputCaptionText() {
|
|
14
|
-
return combine([text("sm"), fg("neutral")]);
|
|
15
|
+
return combine([text("sm"), fg("neutral"), tabularNums()]);
|
|
15
16
|
}
|