@sdxc/ui 2026.10.21 → 2026.10.24

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.
Files changed (41) hide show
  1. package/README.md +4 -0
  2. package/dist/behaviors/filter-model.js +6 -5
  3. package/dist/components/attachment.js +9 -1
  4. package/dist/components/breadcrumbs.d.ts +17 -3
  5. package/dist/components/breadcrumbs.js +5 -3
  6. package/dist/components/group.js +3 -2
  7. package/dist/components/link-button.d.ts +14 -1
  8. package/dist/components/link-button.js +173 -169
  9. package/dist/components/link.d.ts +14 -1
  10. package/dist/components/link.js +63 -59
  11. package/dist/components/nav-link.d.ts +14 -1
  12. package/dist/components/nav-link.js +61 -57
  13. package/dist/components/navigation-menu.d.ts +12 -0
  14. package/dist/components/navigation-menu.js +15 -6
  15. package/dist/components/pagination.d.ts +17 -4
  16. package/dist/components/pagination.js +14 -7
  17. package/dist/components/sidebar.d.ts +18 -0
  18. package/dist/components/sidebar.js +22 -9
  19. package/dist/mixins/active-descendant-keys.d.ts +33 -3
  20. package/dist/mixins/active-descendant-keys.js +101 -13
  21. package/dist/mixins/calendar-keys.js +0 -1
  22. package/dist/mixins/carousel-controls.js +0 -1
  23. package/dist/mixins/context-menu.js +4 -6
  24. package/dist/mixins/dismiss.js +3 -5
  25. package/dist/mixins/frame-refresh.d.ts +30 -0
  26. package/dist/mixins/frame-refresh.js +85 -0
  27. package/dist/mixins/frame-submit.d.ts +65 -0
  28. package/dist/mixins/frame-submit.js +104 -0
  29. package/dist/mixins/grid-list-keys.js +0 -1
  30. package/dist/mixins/index.d.ts +2 -0
  31. package/dist/mixins/index.js +2 -0
  32. package/dist/mixins/long-press.js +2 -4
  33. package/dist/mixins/menu-keys.js +2 -3
  34. package/dist/mixins/menubar-keys.js +3 -4
  35. package/dist/mixins/message-follow.js +0 -1
  36. package/dist/mixins/theme-toggle.js +2 -4
  37. package/dist/utils/index.d.ts +1 -0
  38. package/dist/utils/index.js +1 -0
  39. package/dist/utils/link-prefetch.d.ts +33 -0
  40. package/dist/utils/link-prefetch.js +31 -0
  41. package/package.json +6 -5
package/README.md CHANGED
@@ -273,6 +273,8 @@ Each mixin module documents why it needs JavaScript and what still works without
273
273
  | `dragReorder(session)` | `GridList` / `Tree` | Pointer reordering through a `DragSession`. |
274
274
  | `dropZone(session)` | `DropZone` | File drag-and-drop through a `DragSession`. |
275
275
  | `dualRange()` | a two-thumb `Slider` | Thumbs that cannot cross. |
276
+ | `frameRefresh(options)` | any host in a frame | Its frame reloaded on a schedule or an event, resting while hidden. |
277
+ | `frameSubmit(options?)` | a `<form>` in a frame | The form posted through its frame, answered in place in one request. |
276
278
  | `gridListKeys(model)` | `GridList` | The ARIA grid keyboard pattern over a `SelectionModel`. |
277
279
  | `headingLevelFallback(options)` | an island's `HeadingScope` | Reports the page's heading depth to `onLevel` once on attach. |
278
280
  | `hotkey(combo)` | a `<dialog>`/`[popover]` | A document-wide shortcut toggling its host. |
@@ -306,6 +308,8 @@ Helpers for writing your own:
306
308
  stand-down rules as `isClaimedKeystroke(event, scope?)`.
307
309
  - `chooseOption(combobox, index)` and `chosenOption(combobox)` — set and read the option
308
310
  `activeDescendantKeys` has chosen, after a reload replaces the options.
311
+ - `prefetchOption(combobox, index, strategy)` — loads an option's link ahead, as
312
+ `activeDescendantKeys({ prefetch })` does for a resting choice, e.g. the top result once it settles.
309
313
  - `syncAriaChecked(control)` — refreshes `ariaChecked` after a programmatic checked write or reset.
310
314
  - `colorChannelProperty(channel)` and `getCommandItemId(item, index)` — the custom property and the
311
315
  item id `channelSync` and `commandFilter` read.
@@ -7,6 +7,7 @@
7
7
  * @author [Sergio Xalambrí](https://sergiodxa.com)
8
8
  * @copyright Sergio Xalambrí 2026
9
9
  */
10
+ import { iife } from "@sdxc/iife";
10
11
  import { TypedEventTarget } from "remix/component";
11
12
  import { dispatchChange } from "../utils/dispatch-change.js";
12
13
  const DEFAULT_QUERY = "";
@@ -166,11 +167,11 @@ export class FilterModel extends TypedEventTarget {
166
167
  return;
167
168
  }
168
169
  let index = this.#matches.findIndex((option) => option.id === this.#activeId);
169
- let nextIndex = index === -1
170
- ? delta > 0
171
- ? 0
172
- : this.#matches.length - 1
173
- : (index + delta + this.#matches.length) % this.#matches.length;
170
+ let nextIndex = iife(() => {
171
+ if (index === -1)
172
+ return delta > 0 ? 0 : this.#matches.length - 1;
173
+ return (index + delta + this.#matches.length) % this.#matches.length;
174
+ });
174
175
  let nextOption = this.#matches[nextIndex];
175
176
  if (nextOption === undefined)
176
177
  return;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "remix/component/jsx-runtime";
2
+ import { iife } from "@sdxc/iife";
2
3
  import { bg, border, fg, outline } from "@sdxc/u/color";
3
4
  import { rounded, transition } from "@sdxc/u/effects";
4
5
  import { raw } from "@sdxc/u/general";
@@ -272,7 +273,14 @@ Attachment.Trigger = function AttachmentTrigger(handle) {
272
273
  return () => {
273
274
  let { href, commandfor, command, target, role, tabIndex, children, mix, ...rest } = handle.props;
274
275
  let isConfigured = href !== undefined || commandfor !== undefined;
275
- let resolvedRole = role ?? (href !== undefined ? "link" : isConfigured ? "button" : undefined);
276
+ let inferredRole = iife(() => {
277
+ if (href !== undefined)
278
+ return "link";
279
+ if (isConfigured)
280
+ return "button";
281
+ return undefined;
282
+ });
283
+ let resolvedRole = role ?? inferredRole;
276
284
  let resolvedTabIndex = tabIndex ?? (isConfigured ? 0 : undefined);
277
285
  if (import.meta.env?.DEV && !isConfigured) {
278
286
  console.warn('Attachment.Trigger: rendered with neither "href" nor "commandfor" — nothing will happen once `attachmentTrigger()` handles an activation.');
@@ -11,6 +11,7 @@
11
11
  * @copyright Sergio Xalambrí 2026
12
12
  */
13
13
  import type { Handle, Props as TagProps } from "remix/component";
14
+ import type { LinkPrefetch } from "../utils/link-prefetch.js";
14
15
  import { Link } from "./link.js";
15
16
  /**
16
17
  * Prop types for {@link Breadcrumbs} and its compound parts.
@@ -32,11 +33,24 @@ export declare namespace Breadcrumbs {
32
33
  interface ItemProps extends TagProps<"li"> {
33
34
  }
34
35
  /**
35
- * Every prop {@link Link.Props} accepts, unchanged. A type alias rather than
36
- * an interface, since {@link Link.Props} resolves through a conditional type
36
+ * When a segment's destination starts loading: on intent, once in the
37
+ * viewport, on render through a `<link rel="prefetch">` that also serves
38
+ * full-document navigations, or only on navigation (`"none"`).
39
+ */
40
+ type Prefetch = LinkPrefetch;
41
+ /**
42
+ * Every prop {@link Link.Props} accepts. A type alias rather than an
43
+ * interface, since {@link Link.Props} resolves through a conditional type
37
44
  * that an `interface extends` clause can't statically extend.
38
45
  */
39
- type LinkProps = Link.Props;
46
+ type LinkProps = Link.Props & {
47
+ /**
48
+ * Prefetch mode, for segments whose GET is safe to repeat. `"render"` suits
49
+ * multi-page navigations; a long trail keeps it to its nearest parents, since
50
+ * each hint is a request on page load. Defaults to {@link DEFAULT_PREFETCH}.
51
+ */
52
+ prefetch?: Prefetch;
53
+ };
40
54
  }
41
55
  /**
42
56
  * Renders the trail's `<nav>` root, laying {@link Breadcrumbs.List} as a row.
@@ -9,6 +9,8 @@ import { warnIfNoAccessibleLabel } from "../utils/warn-if-no-accessible-name.js"
9
9
  import { Link } from "./link.js";
10
10
  /** Semantic color role {@link Breadcrumbs.Link} falls back to when `color` is omitted. */
11
11
  const DEFAULT_COLOR = "neutral";
12
+ /** Prefetch mode {@link Breadcrumbs.Link} falls back to when `prefetch` is omitted. */
13
+ const DEFAULT_PREFETCH = "none";
12
14
  /**
13
15
  * Renders the trail's `<nav>` root, laying {@link Breadcrumbs.List} as a row.
14
16
  * A root missing `aria-label` or `aria-labelledby` logs a dev-mode
@@ -92,7 +94,7 @@ Breadcrumbs.Item = function BreadcrumbsItem(handle) {
92
94
  * @param handle Runtime handle carrying the host `<a>`'s props.
93
95
  * @returns The render function producing the segment's markup.
94
96
  * @example
95
- * <Breadcrumbs.Link href="/settings">{t("nav.settings")}</Breadcrumbs.Link>
97
+ * <Breadcrumbs.Link href="/settings" prefetch="render">{t("nav.settings")}</Breadcrumbs.Link>
96
98
  * @example
97
99
  * <Breadcrumbs.Link href="/settings/profile" aria-current="page">
98
100
  * {t("nav.profile")}
@@ -102,9 +104,9 @@ Breadcrumbs.Item = function BreadcrumbsItem(handle) {
102
104
  */
103
105
  Breadcrumbs.Link = function BreadcrumbsLink(handle) {
104
106
  return () => {
105
- let { color, mix, ...rest } = handle.props;
107
+ let { color, prefetch, mix, ...rest } = handle.props;
106
108
  let resolvedColor = color ?? DEFAULT_COLOR;
107
- return (_jsx(Link, { color: resolvedColor, ...rest, "data-slot": "link", mix: [
109
+ return (_jsx(Link, { color: resolvedColor, prefetch: prefetch ?? DEFAULT_PREFETCH, ...rest, "data-slot": "link", mix: [
108
110
  fontSize("sm"),
109
111
  /**
110
112
  * The space around each separator lives in the link's own padding, so the
@@ -41,14 +41,15 @@ export function Group(handle) {
41
41
  items("center"),
42
42
  /**
43
43
  * The controls compose into one shape, so the cluster keeps the rounding on
44
- * its own outer corners and the seam where two of them meet is drawn once.
44
+ * its own outer corners and the seam where two of them meet is drawn once; the
45
+ * last control before a trailing `<link rel="prefetch">` hint keeps its corners.
45
46
  */
46
47
  when("& > *:not(:first-child)", [
47
48
  roundedCorner("start-start", "none"),
48
49
  roundedCorner("end-start", "none"),
49
50
  mis("-1px"),
50
51
  ]),
51
- when("& > *:not(:last-child)", [
52
+ when("& > *:has(~ :not(link))", [
52
53
  roundedCorner("start-end", "none"),
53
54
  roundedCorner("end-end", "none"),
54
55
  ]),
@@ -9,6 +9,7 @@
9
9
  * @copyright Sergio Xalambrí 2026
10
10
  */
11
11
  import type { Handle, Props as TagProps } from "remix/component";
12
+ import type { LinkPrefetch } from "../utils/link-prefetch.js";
12
13
  import type { SemanticColor } from "../utils/semantic-color.js";
13
14
  /**
14
15
  * Prop types for {@link LinkButton}.
@@ -28,6 +29,12 @@ export declare namespace LinkButton {
28
29
  * Size variant controlling the link's padding and font size.
29
30
  */
30
31
  type Size = "sm" | "md" | "lg";
32
+ /**
33
+ * When the destination starts loading: on intent, once in the viewport, on
34
+ * render through a `<link rel="prefetch">` that also serves full-document
35
+ * navigations, or only on navigation (`"none"`).
36
+ */
37
+ type Prefetch = LinkPrefetch;
31
38
  /**
32
39
  * Props accepted by {@link LinkButton}. A type alias rather than an
33
40
  * interface, since the native anchor props resolve to an intersection
@@ -40,6 +47,12 @@ export declare namespace LinkButton {
40
47
  variant?: Variant;
41
48
  /** Size variant. Defaults to {@link DEFAULT_SIZE}. */
42
49
  size?: Size;
50
+ /**
51
+ * Prefetch mode, for links whose GET is safe to repeat. `"render"` suits
52
+ * multi-page navigations; a list keeps it to its first few items, since each
53
+ * hint is a request on page load. Defaults to {@link DEFAULT_PREFETCH}.
54
+ */
55
+ prefetch?: Prefetch;
43
56
  };
44
57
  }
45
58
  /**
@@ -50,7 +63,7 @@ export declare namespace LinkButton {
50
63
  * @param handle Runtime handle carrying the host `<a>`'s props.
51
64
  * @returns The render function producing the link's markup.
52
65
  * @example
53
- * <LinkButton href="/projects/new">{t("actions.createProject")}</LinkButton>
66
+ * <LinkButton href="/projects/new" prefetch="intent">{t("actions.createProject")}</LinkButton>
54
67
  * @example
55
68
  * <LinkButton href="/projects" color="neutral" variant="outline" size="sm">{t("actions.cancel")}</LinkButton>
56
69
  * @example
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "remix/component/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "remix/component/jsx-runtime";
2
2
  import { bg, border, fg, outline } from "@sdxc/u/color";
3
3
  import { opacity, rounded } from "@sdxc/u/effects";
4
4
  import { cursor, pointerEvents, userSelect } from "@sdxc/u/general";
@@ -9,12 +9,15 @@ import { text, weight } from "@sdxc/u/typography";
9
9
  import { hitArea } from "../styles/hit-area.js";
10
10
  import { interactiveTransition } from "../styles/interactive-transition.js";
11
11
  import { glyphEdges } from "../utils/glyph-edges.js";
12
+ import { prefetchAttribute, rendersPrefetchHint } from "../utils/link-prefetch.js";
12
13
  /** Semantic color role {@link LinkButton} falls back to when `color` is omitted. */
13
14
  const DEFAULT_COLOR = "neutral";
14
15
  /** Visual weight {@link LinkButton} falls back to when `variant` is omitted. */
15
16
  const DEFAULT_VARIANT = "solid";
16
17
  /** Size variant {@link LinkButton} falls back to when `size` is omitted. */
17
18
  const DEFAULT_SIZE = "md";
19
+ /** Prefetch mode {@link LinkButton} falls back to when `prefetch` is omitted. */
20
+ const DEFAULT_PREFETCH = "none";
18
21
  /**
19
22
  * Renders a native `<a>` host, colored and shaped through the same color,
20
23
  * variant, and size data attributes as {@link Button}. `aria-disabled="true"`
@@ -23,7 +26,7 @@ const DEFAULT_SIZE = "md";
23
26
  * @param handle Runtime handle carrying the host `<a>`'s props.
24
27
  * @returns The render function producing the link's markup.
25
28
  * @example
26
- * <LinkButton href="/projects/new">{t("actions.createProject")}</LinkButton>
29
+ * <LinkButton href="/projects/new" prefetch="intent">{t("actions.createProject")}</LinkButton>
27
30
  * @example
28
31
  * <LinkButton href="/projects" color="neutral" variant="outline" size="sm">{t("actions.cancel")}</LinkButton>
29
32
  * @example
@@ -31,176 +34,177 @@ const DEFAULT_SIZE = "md";
31
34
  */
32
35
  export function LinkButton(handle) {
33
36
  return () => {
34
- let { color, variant, size, children, mix, ...rest } = handle.props;
37
+ let { color, variant, size, prefetch, children, mix, ...rest } = handle.props;
35
38
  let resolvedColor = color ?? DEFAULT_COLOR;
36
39
  let resolvedVariant = variant ?? DEFAULT_VARIANT;
37
40
  let resolvedSize = size ?? DEFAULT_SIZE;
41
+ let resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;
38
42
  let edges = glyphEdges(children);
39
- return (_jsx("a", { ...rest, "data-color": resolvedColor, "data-variant": resolvedVariant, "data-size": resolvedSize, "data-glyph-start": edges.start || undefined, "data-glyph-end": edges.end || undefined, mix: [
40
- when("&:focus-visible", [
41
- outline({ color: "brand.ring", offset: 2 }),
42
- data("color", "neutral", outline("neutral.ring")),
43
- data("color", "success", outline("success.ring")),
44
- data("color", "warning", outline("warning.ring")),
45
- data("color", "danger", outline("danger.ring")),
46
- ]),
47
- interactiveTransition(),
48
- inlineFlex(),
49
- items("center"),
50
- justify("center"),
51
- gap(2),
52
- /**
53
- * A glyph inside a link button is measured and held at size by the same rules
54
- * `Button` states, for the same reasons: it is sized against the label beside
55
- * it so the row keeps the height its text and padding ask for, and it never
56
- * shrinks, since the default `flex-shrink: 1` would compress the glyph rather
57
- * than the words and a squashed icon reads as a rendering fault.
58
- */
59
- when("& > svg", [shrink(), is(4), bs(4)]),
60
- rounded("md"),
61
- weight("medium"),
62
- /** A small control reaches `--ui-target-size` however a consumer positions it. */
63
- hitArea({ anchor: "flex-center" }),
64
- pi(4),
65
- pb(2),
66
- /**
67
- * Every variant carries the same border width, colored to match its
68
- * own fill (transparent for ghost), so solid, outline, and ghost
69
- * render at the same footprint.
70
- */
71
- border({ width: 1 }),
72
- /**
73
- * The row measure is stated, so the control lines up with a field of the same size when
74
- * a Group fuses the two, and still grows when a long label wraps.
75
- */
76
- minBs("2.5rem"),
77
- data("size", "sm", [pi(3), pb(1.5), minBs("2rem"), when("& > svg", [is(3), bs(3)])]),
78
- data("size", "lg", [
79
- pi(5),
80
- pb(2.5),
81
- text("base"),
82
- minBs("3rem"),
83
- when("& > svg", [is(5), bs(5)]),
84
- ]),
85
- /**
86
- * A glyph beside a label carries its own side bearing, so the padding on that
87
- * side drops one step and the glyph and the words read as evenly inset.
88
- */
89
- when("&[data-glyph-start]:has(> svg:first-child)", [
90
- pis(3),
91
- data("size", "sm", pis(2)),
92
- data("size", "lg", pis(4)),
93
- ]),
94
- when("&[data-glyph-end]:has(> svg:last-child)", [
95
- pie(3),
96
- data("size", "sm", pie(2)),
97
- data("size", "lg", pie(4)),
98
- ]),
99
- data("variant", "solid", [
100
- data("color", "brand", [
101
- bg("brand.solid"),
102
- border("brand.solid"),
103
- fg("brand.onSolid"),
104
- hover([bg("brand.bg-solid-hover"), border("brand.bg-solid-hover")]),
105
- active([bg("brand.bg-solid-pressed"), border("brand.bg-solid-pressed")]),
106
- ]),
107
- data("color", "neutral", [
108
- bg("neutral.solid"),
109
- border("neutral.solid"),
110
- fg("neutral.onSolid"),
111
- hover([bg("neutral.bg-solid-hover"), border("neutral.bg-solid-hover")]),
112
- active([bg("neutral.bg-solid-pressed"), border("neutral.bg-solid-pressed")]),
113
- ]),
114
- data("color", "success", [
115
- bg("success.solid"),
116
- border("success.solid"),
117
- fg("success.onSolid"),
118
- hover([bg("success.bg-solid-hover"), border("success.bg-solid-hover")]),
119
- active([bg("success.bg-solid-pressed"), border("success.bg-solid-pressed")]),
120
- ]),
121
- data("color", "warning", [
122
- bg("warning.solid"),
123
- border("warning.solid"),
124
- fg("warning.onSolid"),
125
- hover([bg("warning.bg-solid-hover"), border("warning.bg-solid-hover")]),
126
- active([bg("warning.bg-solid-pressed"), border("warning.bg-solid-pressed")]),
127
- ]),
128
- data("color", "danger", [
129
- bg("danger.solid"),
130
- border("danger.solid"),
131
- fg("danger.onSolid"),
132
- hover([bg("danger.bg-solid-hover"), border("danger.bg-solid-hover")]),
133
- active([bg("danger.bg-solid-pressed"), border("danger.bg-solid-pressed")]),
134
- ]),
135
- ]),
136
- data("variant", "outline", [
137
- data("color", "brand", [
138
- border("brand"),
139
- fg("brand"),
140
- hover([bg("brand.tint"), border("brand.border-hover")]),
141
- active(bg("brand.bg-tint-hover")),
142
- ]),
143
- data("color", "neutral", [
144
- border("neutral"),
145
- fg("neutral"),
146
- hover([bg("neutral.tint"), border("neutral.border-hover")]),
147
- active(bg("neutral.bg-tint-hover")),
148
- ]),
149
- data("color", "success", [
150
- border("success"),
151
- fg("success"),
152
- hover([bg("success.tint"), border("success.border-hover")]),
153
- active(bg("success.bg-tint-hover")),
154
- ]),
155
- data("color", "warning", [
156
- border("warning"),
157
- fg("warning"),
158
- hover([bg("warning.tint"), border("warning.border-hover")]),
159
- active(bg("warning.bg-tint-hover")),
160
- ]),
161
- data("color", "danger", [
162
- border("danger"),
163
- fg("danger"),
164
- hover([bg("danger.tint"), border("danger.border-hover")]),
165
- active(bg("danger.bg-tint-hover")),
166
- ]),
167
- ]),
168
- data("variant", "outline", bg("transparent")),
169
- data("variant", "ghost", [
170
- data("color", "brand", [
171
- fg("brand"),
172
- hover(bg("brand.tint")),
173
- active(bg("brand.bg-tint-hover")),
174
- ]),
175
- data("color", "neutral", [
176
- fg("neutral"),
177
- hover(bg("neutral.bg-tint-hover")),
178
- active(bg("neutral.bg-tint-pressed")),
179
- ]),
180
- data("color", "success", [
181
- fg("success"),
182
- hover(bg("success.tint")),
183
- active(bg("success.bg-tint-hover")),
184
- ]),
185
- data("color", "warning", [
186
- fg("warning"),
187
- hover(bg("warning.tint")),
188
- active(bg("warning.bg-tint-hover")),
189
- ]),
190
- data("color", "danger", [
191
- fg("danger"),
192
- hover(bg("danger.tint")),
193
- active(bg("danger.bg-tint-hover")),
194
- ]),
195
- ]),
196
- data("variant", "ghost", [bg("transparent"), border("transparent")]),
197
- when('&[aria-disabled="true"]', opacity(50)),
198
- when('&[aria-disabled="true"]', [cursor("not-allowed"), pointerEvents()]),
199
- cursor("default"),
200
- userSelect(),
201
- text("sm"),
202
- data("size", "sm", text("xs")),
203
- mix,
204
- ], children: children }));
43
+ return (_jsxs(_Fragment, { children: [_jsx("a", { ...rest, "data-color": resolvedColor, "data-variant": resolvedVariant, "data-size": resolvedSize, "data-rmx-prefetch": prefetchAttribute(resolvedPrefetch), "data-glyph-start": edges.start || undefined, "data-glyph-end": edges.end || undefined, mix: [
44
+ when("&:focus-visible", [
45
+ outline({ color: "brand.ring", offset: 2 }),
46
+ data("color", "neutral", outline("neutral.ring")),
47
+ data("color", "success", outline("success.ring")),
48
+ data("color", "warning", outline("warning.ring")),
49
+ data("color", "danger", outline("danger.ring")),
50
+ ]),
51
+ interactiveTransition(),
52
+ inlineFlex(),
53
+ items("center"),
54
+ justify("center"),
55
+ gap(2),
56
+ /**
57
+ * A glyph inside a link button is measured and held at size by the same rules
58
+ * `Button` states, for the same reasons: it is sized against the label beside
59
+ * it so the row keeps the height its text and padding ask for, and it never
60
+ * shrinks, since the default `flex-shrink: 1` would compress the glyph rather
61
+ * than the words and a squashed icon reads as a rendering fault.
62
+ */
63
+ when("& > svg", [shrink(), is(4), bs(4)]),
64
+ rounded("md"),
65
+ weight("medium"),
66
+ /** A small control reaches `--ui-target-size` however a consumer positions it. */
67
+ hitArea({ anchor: "flex-center" }),
68
+ pi(4),
69
+ pb(2),
70
+ /**
71
+ * Every variant carries the same border width, colored to match its
72
+ * own fill (transparent for ghost), so solid, outline, and ghost
73
+ * render at the same footprint.
74
+ */
75
+ border({ width: 1 }),
76
+ /**
77
+ * The row measure is stated, so the control lines up with a field of the same size when
78
+ * a Group fuses the two, and still grows when a long label wraps.
79
+ */
80
+ minBs("2.5rem"),
81
+ data("size", "sm", [pi(3), pb(1.5), minBs("2rem"), when("& > svg", [is(3), bs(3)])]),
82
+ data("size", "lg", [
83
+ pi(5),
84
+ pb(2.5),
85
+ text("base"),
86
+ minBs("3rem"),
87
+ when("& > svg", [is(5), bs(5)]),
88
+ ]),
89
+ /**
90
+ * A glyph beside a label carries its own side bearing, so the padding on that
91
+ * side drops one step and the glyph and the words read as evenly inset.
92
+ */
93
+ when("&[data-glyph-start]:has(> svg:first-child)", [
94
+ pis(3),
95
+ data("size", "sm", pis(2)),
96
+ data("size", "lg", pis(4)),
97
+ ]),
98
+ when("&[data-glyph-end]:has(> svg:last-child)", [
99
+ pie(3),
100
+ data("size", "sm", pie(2)),
101
+ data("size", "lg", pie(4)),
102
+ ]),
103
+ data("variant", "solid", [
104
+ data("color", "brand", [
105
+ bg("brand.solid"),
106
+ border("brand.solid"),
107
+ fg("brand.onSolid"),
108
+ hover([bg("brand.bg-solid-hover"), border("brand.bg-solid-hover")]),
109
+ active([bg("brand.bg-solid-pressed"), border("brand.bg-solid-pressed")]),
110
+ ]),
111
+ data("color", "neutral", [
112
+ bg("neutral.solid"),
113
+ border("neutral.solid"),
114
+ fg("neutral.onSolid"),
115
+ hover([bg("neutral.bg-solid-hover"), border("neutral.bg-solid-hover")]),
116
+ active([bg("neutral.bg-solid-pressed"), border("neutral.bg-solid-pressed")]),
117
+ ]),
118
+ data("color", "success", [
119
+ bg("success.solid"),
120
+ border("success.solid"),
121
+ fg("success.onSolid"),
122
+ hover([bg("success.bg-solid-hover"), border("success.bg-solid-hover")]),
123
+ active([bg("success.bg-solid-pressed"), border("success.bg-solid-pressed")]),
124
+ ]),
125
+ data("color", "warning", [
126
+ bg("warning.solid"),
127
+ border("warning.solid"),
128
+ fg("warning.onSolid"),
129
+ hover([bg("warning.bg-solid-hover"), border("warning.bg-solid-hover")]),
130
+ active([bg("warning.bg-solid-pressed"), border("warning.bg-solid-pressed")]),
131
+ ]),
132
+ data("color", "danger", [
133
+ bg("danger.solid"),
134
+ border("danger.solid"),
135
+ fg("danger.onSolid"),
136
+ hover([bg("danger.bg-solid-hover"), border("danger.bg-solid-hover")]),
137
+ active([bg("danger.bg-solid-pressed"), border("danger.bg-solid-pressed")]),
138
+ ]),
139
+ ]),
140
+ data("variant", "outline", [
141
+ data("color", "brand", [
142
+ border("brand"),
143
+ fg("brand"),
144
+ hover([bg("brand.tint"), border("brand.border-hover")]),
145
+ active(bg("brand.bg-tint-hover")),
146
+ ]),
147
+ data("color", "neutral", [
148
+ border("neutral"),
149
+ fg("neutral"),
150
+ hover([bg("neutral.tint"), border("neutral.border-hover")]),
151
+ active(bg("neutral.bg-tint-hover")),
152
+ ]),
153
+ data("color", "success", [
154
+ border("success"),
155
+ fg("success"),
156
+ hover([bg("success.tint"), border("success.border-hover")]),
157
+ active(bg("success.bg-tint-hover")),
158
+ ]),
159
+ data("color", "warning", [
160
+ border("warning"),
161
+ fg("warning"),
162
+ hover([bg("warning.tint"), border("warning.border-hover")]),
163
+ active(bg("warning.bg-tint-hover")),
164
+ ]),
165
+ data("color", "danger", [
166
+ border("danger"),
167
+ fg("danger"),
168
+ hover([bg("danger.tint"), border("danger.border-hover")]),
169
+ active(bg("danger.bg-tint-hover")),
170
+ ]),
171
+ ]),
172
+ data("variant", "outline", bg("transparent")),
173
+ data("variant", "ghost", [
174
+ data("color", "brand", [
175
+ fg("brand"),
176
+ hover(bg("brand.tint")),
177
+ active(bg("brand.bg-tint-hover")),
178
+ ]),
179
+ data("color", "neutral", [
180
+ fg("neutral"),
181
+ hover(bg("neutral.bg-tint-hover")),
182
+ active(bg("neutral.bg-tint-pressed")),
183
+ ]),
184
+ data("color", "success", [
185
+ fg("success"),
186
+ hover(bg("success.tint")),
187
+ active(bg("success.bg-tint-hover")),
188
+ ]),
189
+ data("color", "warning", [
190
+ fg("warning"),
191
+ hover(bg("warning.tint")),
192
+ active(bg("warning.bg-tint-hover")),
193
+ ]),
194
+ data("color", "danger", [
195
+ fg("danger"),
196
+ hover(bg("danger.tint")),
197
+ active(bg("danger.bg-tint-hover")),
198
+ ]),
199
+ ]),
200
+ data("variant", "ghost", [bg("transparent"), border("transparent")]),
201
+ when('&[aria-disabled="true"]', opacity(50)),
202
+ when('&[aria-disabled="true"]', [cursor("not-allowed"), pointerEvents()]),
203
+ cursor("default"),
204
+ userSelect(),
205
+ text("sm"),
206
+ data("size", "sm", text("xs")),
207
+ mix,
208
+ ], children: children }), rendersPrefetchHint(resolvedPrefetch, rest.href) && (_jsx("link", { rel: "prefetch", href: rest.href }))] }));
205
209
  };
206
210
  }
@@ -7,6 +7,7 @@
7
7
  * @copyright Sergio Xalambrí 2026
8
8
  */
9
9
  import type { Handle, Props as TagProps } from "remix/component";
10
+ import type { LinkPrefetch } from "../utils/link-prefetch.js";
10
11
  import type { SemanticColor } from "../utils/semantic-color.js";
11
12
  /**
12
13
  * Prop types for {@link Link}.
@@ -16,6 +17,12 @@ export declare namespace Link {
16
17
  * Semantic color role, each mapped to its matching `--ui-*` variables.
17
18
  */
18
19
  type Color = SemanticColor;
20
+ /**
21
+ * When the destination starts loading: on intent, once in the viewport, on
22
+ * render through a `<link rel="prefetch">` that also serves full-document
23
+ * navigations, or only on navigation (`"none"`).
24
+ */
25
+ type Prefetch = LinkPrefetch;
19
26
  /**
20
27
  * Props accepted by {@link Link}. A type alias rather than an interface,
21
28
  * since the native anchor props resolve through a conditional type that an
@@ -24,6 +31,12 @@ export declare namespace Link {
24
31
  type Props = TagProps<"a"> & {
25
32
  /** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */
26
33
  color?: Color;
34
+ /**
35
+ * Prefetch mode, for links whose GET is safe to repeat. `"render"` suits
36
+ * multi-page navigations; a list keeps it to its first few items, since each
37
+ * hint is a request on page load. Defaults to {@link DEFAULT_PREFETCH}.
38
+ */
39
+ prefetch?: Prefetch;
27
40
  };
28
41
  }
29
42
  /**
@@ -36,7 +49,7 @@ export declare namespace Link {
36
49
  * @example
37
50
  * <Link href="/about">{t("nav.about")}</Link>
38
51
  * @example
39
- * <Link href="/delete" color="danger">{t("actions.delete")}</Link>
52
+ * <Link href="/products/shirt" prefetch="render">{t("products.shirt")}</Link>
40
53
  * @example
41
54
  * <Link href="/settings" aria-disabled="true">{t("nav.settings")}</Link>
42
55
  */