@sdxc/ui 2026.10.23 → 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.
- package/README.md +4 -0
- package/dist/components/breadcrumbs.d.ts +17 -3
- package/dist/components/breadcrumbs.js +5 -3
- package/dist/components/group.js +3 -2
- package/dist/components/link-button.d.ts +14 -1
- package/dist/components/link-button.js +173 -169
- package/dist/components/link.d.ts +14 -1
- package/dist/components/link.js +63 -59
- package/dist/components/nav-link.d.ts +14 -1
- package/dist/components/nav-link.js +61 -57
- package/dist/components/navigation-menu.d.ts +12 -0
- package/dist/components/navigation-menu.js +15 -6
- package/dist/components/pagination.d.ts +17 -4
- package/dist/components/pagination.js +14 -7
- package/dist/components/sidebar.d.ts +18 -0
- package/dist/components/sidebar.js +22 -9
- package/dist/mixins/active-descendant-keys.d.ts +33 -3
- package/dist/mixins/active-descendant-keys.js +101 -13
- package/dist/mixins/frame-refresh.d.ts +30 -0
- package/dist/mixins/frame-refresh.js +85 -0
- package/dist/mixins/frame-submit.d.ts +65 -0
- package/dist/mixins/frame-submit.js +104 -0
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.js +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/link-prefetch.d.ts +33 -0
- package/dist/utils/link-prefetch.js +31 -0
- package/package.json +5 -5
package/dist/components/link.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
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 { colorMix, fg, outline } from "@sdxc/u/color";
|
|
3
3
|
import { opacity, rounded } from "@sdxc/u/effects";
|
|
4
4
|
import { cursor, raw, var as varUtility } from "@sdxc/u/general";
|
|
5
5
|
import { data, when } from "@sdxc/u/state";
|
|
6
6
|
import { textDecoration } from "@sdxc/u/typography";
|
|
7
7
|
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
8
|
+
import { prefetchAttribute, rendersPrefetchHint } from "../utils/link-prefetch.js";
|
|
8
9
|
/** Semantic color role {@link Link} falls back to when `color` is omitted. */
|
|
9
10
|
const DEFAULT_COLOR = "brand";
|
|
11
|
+
/** Prefetch mode {@link Link} falls back to when `prefetch` is omitted. */
|
|
12
|
+
const DEFAULT_PREFETCH = "none";
|
|
10
13
|
/**
|
|
11
14
|
* Renders a native `<a>` host, colored through the `data-color` attribute
|
|
12
15
|
* contract and underlined unconditionally. `aria-disabled="true"` mutes the
|
|
@@ -17,69 +20,70 @@ const DEFAULT_COLOR = "brand";
|
|
|
17
20
|
* @example
|
|
18
21
|
* <Link href="/about">{t("nav.about")}</Link>
|
|
19
22
|
* @example
|
|
20
|
-
* <Link href="/
|
|
23
|
+
* <Link href="/products/shirt" prefetch="render">{t("products.shirt")}</Link>
|
|
21
24
|
* @example
|
|
22
25
|
* <Link href="/settings" aria-disabled="true">{t("nav.settings")}</Link>
|
|
23
26
|
*/
|
|
24
27
|
export function Link(handle) {
|
|
25
28
|
return () => {
|
|
26
|
-
let { color, mix, ...rest } = handle.props;
|
|
29
|
+
let { color, prefetch, mix, ...rest } = handle.props;
|
|
27
30
|
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
31
|
+
let resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsx("a", { "data-color": resolvedColor, "data-rmx-prefetch": prefetchAttribute(resolvedPrefetch), ...rest, mix: [
|
|
33
|
+
when("&:focus-visible", [
|
|
34
|
+
outline({ color: "brand.ring", offset: 2 }),
|
|
35
|
+
data("color", "neutral", outline("neutral.ring")),
|
|
36
|
+
data("color", "success", outline("success.ring")),
|
|
37
|
+
data("color", "warning", outline("warning.ring")),
|
|
38
|
+
data("color", "danger", outline("danger.ring")),
|
|
39
|
+
]),
|
|
40
|
+
interactiveTransition(),
|
|
41
|
+
rounded("sm"),
|
|
42
|
+
data("color", "brand", fg("brand")),
|
|
43
|
+
data("color", "neutral", fg("neutral")),
|
|
44
|
+
data("color", "success", fg("success")),
|
|
45
|
+
data("color", "danger", fg("danger")),
|
|
46
|
+
data("color", "warning", fg("warning")),
|
|
47
|
+
when('&[aria-disabled="true"]', opacity(50)),
|
|
48
|
+
textDecoration("underline"),
|
|
49
|
+
cursor("pointer"),
|
|
50
|
+
data("color", "brand", [
|
|
51
|
+
/**
|
|
52
|
+
* `color-mix()`'s color argument needs the raw CSS variable
|
|
53
|
+
* (`var(--ui-brand-fg)`), so the property stays `raw()` while
|
|
54
|
+
* the literal string becomes a builder call.
|
|
55
|
+
*/
|
|
56
|
+
raw({
|
|
57
|
+
textDecorationColor: colorMix("srgb", { color: varUtility("ui-brand-fg"), weight: 60 }, "transparent"),
|
|
58
|
+
}),
|
|
59
|
+
when("&:hover", raw({ textDecorationColor: varUtility("ui-brand-fg") })),
|
|
60
|
+
]),
|
|
61
|
+
data("color", "neutral", [
|
|
62
|
+
raw({
|
|
63
|
+
textDecorationColor: colorMix("srgb", { color: varUtility("ui-neutral-fg"), weight: 50 }, "transparent"),
|
|
64
|
+
}),
|
|
65
|
+
when("&:hover", raw({ textDecorationColor: varUtility("ui-neutral-fg") })),
|
|
66
|
+
]),
|
|
67
|
+
data("color", "success", [
|
|
68
|
+
raw({
|
|
69
|
+
textDecorationColor: colorMix("srgb", { color: varUtility("ui-success-fg"), weight: 60 }, "transparent"),
|
|
70
|
+
}),
|
|
71
|
+
when("&:hover", raw({ textDecorationColor: varUtility("ui-success-fg") })),
|
|
72
|
+
]),
|
|
73
|
+
data("color", "danger", [
|
|
74
|
+
raw({
|
|
75
|
+
textDecorationColor: colorMix("srgb", { color: varUtility("ui-danger-fg"), weight: 60 }, "transparent"),
|
|
76
|
+
}),
|
|
77
|
+
when("&:hover", raw({ textDecorationColor: varUtility("ui-danger-fg") })),
|
|
78
|
+
]),
|
|
79
|
+
data("color", "warning", [
|
|
80
|
+
raw({
|
|
81
|
+
textDecorationColor: colorMix("srgb", { color: varUtility("ui-warning-fg"), weight: 60 }, "transparent"),
|
|
82
|
+
}),
|
|
83
|
+
when("&:hover", raw({ textDecorationColor: varUtility("ui-warning-fg") })),
|
|
84
|
+
]),
|
|
85
|
+
when('&[aria-disabled="true"]', [cursor("not-allowed"), textDecoration("none")]),
|
|
86
|
+
mix,
|
|
87
|
+
] }), rendersPrefetchHint(resolvedPrefetch, rest.href) && (_jsx("link", { rel: "prefetch", href: rest.href }))] }));
|
|
84
88
|
};
|
|
85
89
|
}
|
|
@@ -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 NavLink}.
|
|
@@ -18,6 +19,12 @@ export declare namespace NavLink {
|
|
|
18
19
|
* Semantic color role, each mapped to its matching `--ui-*` variables.
|
|
19
20
|
*/
|
|
20
21
|
type Color = SemanticColor;
|
|
22
|
+
/**
|
|
23
|
+
* When the destination starts loading: on intent, once in the viewport, on
|
|
24
|
+
* render through a `<link rel="prefetch">` that also serves full-document
|
|
25
|
+
* navigations, or only on navigation (`"none"`).
|
|
26
|
+
*/
|
|
27
|
+
type Prefetch = LinkPrefetch;
|
|
21
28
|
/**
|
|
22
29
|
* Props accepted by {@link NavLink}, built as an intersection: the
|
|
23
30
|
* underlying anchor prop type is a union keyed on `href`, since the
|
|
@@ -34,6 +41,12 @@ export declare namespace NavLink {
|
|
|
34
41
|
* from surrounding text.
|
|
35
42
|
*/
|
|
36
43
|
hasBackground?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Prefetch mode, for links whose GET is safe to repeat. `"render"` suits
|
|
46
|
+
* multi-page navigations; a menu keeps it to its first few items, since each
|
|
47
|
+
* hint is a request on page load. Defaults to {@link DEFAULT_PREFETCH}.
|
|
48
|
+
*/
|
|
49
|
+
prefetch?: Prefetch;
|
|
37
50
|
};
|
|
38
51
|
}
|
|
39
52
|
/**
|
|
@@ -44,7 +57,7 @@ export declare namespace NavLink {
|
|
|
44
57
|
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
45
58
|
* @returns The render function producing the link's markup.
|
|
46
59
|
* @example
|
|
47
|
-
* <NavLink href="/dashboard" color="brand">{t("nav.dashboard")}</NavLink>
|
|
60
|
+
* <NavLink href="/dashboard" color="brand" prefetch="render">{t("nav.dashboard")}</NavLink>
|
|
48
61
|
* @example
|
|
49
62
|
* <NavLink href="/settings" aria-current={pathname === "/settings" ? "page" : undefined}>{t("nav.settings")}</NavLink>
|
|
50
63
|
* @example
|
|
@@ -1,12 +1,15 @@
|
|
|
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 { colorMix, fg, outline } from "@sdxc/u/color";
|
|
3
3
|
import { rounded } from "@sdxc/u/effects";
|
|
4
4
|
import { cursor, raw } from "@sdxc/u/general";
|
|
5
5
|
import { data, hover, when } from "@sdxc/u/state";
|
|
6
6
|
import { textDecoration, weight } from "@sdxc/u/typography";
|
|
7
7
|
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
8
|
+
import { prefetchAttribute, rendersPrefetchHint } from "../utils/link-prefetch.js";
|
|
8
9
|
/** Semantic color role {@link NavLink} falls back to when `color` is omitted. */
|
|
9
10
|
const DEFAULT_COLOR = "neutral";
|
|
11
|
+
/** Prefetch mode {@link NavLink} falls back to when `prefetch` is omitted. */
|
|
12
|
+
const DEFAULT_PREFETCH = "none";
|
|
10
13
|
/**
|
|
11
14
|
* Renders a native `<a>`, colored via `data-color` and underlined with a
|
|
12
15
|
* translucent decoration that solidifies on hover. Setting `aria-current`
|
|
@@ -15,7 +18,7 @@ const DEFAULT_COLOR = "neutral";
|
|
|
15
18
|
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
16
19
|
* @returns The render function producing the link's markup.
|
|
17
20
|
* @example
|
|
18
|
-
* <NavLink href="/dashboard" color="brand">{t("nav.dashboard")}</NavLink>
|
|
21
|
+
* <NavLink href="/dashboard" color="brand" prefetch="render">{t("nav.dashboard")}</NavLink>
|
|
19
22
|
* @example
|
|
20
23
|
* <NavLink href="/settings" aria-current={pathname === "/settings" ? "page" : undefined}>{t("nav.settings")}</NavLink>
|
|
21
24
|
* @example
|
|
@@ -23,61 +26,62 @@ const DEFAULT_COLOR = "neutral";
|
|
|
23
26
|
*/
|
|
24
27
|
export function NavLink(handle) {
|
|
25
28
|
return () => {
|
|
26
|
-
let { color, hasBackground, mix, ...rest } = handle.props;
|
|
29
|
+
let { color, hasBackground, prefetch, mix, ...rest } = handle.props;
|
|
27
30
|
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
31
|
+
let resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsx("a", { ...rest, "data-color": resolvedColor, "data-has-background": hasBackground || undefined, "data-rmx-prefetch": prefetchAttribute(resolvedPrefetch), mix: [
|
|
33
|
+
interactiveTransition(),
|
|
34
|
+
rounded("sm"),
|
|
35
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
36
|
+
cursor("pointer"),
|
|
37
|
+
textDecoration("underline"),
|
|
38
|
+
raw({
|
|
39
|
+
textDecorationColor: colorMix("oklab", { color: "currentcolor", weight: 60 }, "transparent"),
|
|
40
|
+
textUnderlineOffset: "4px",
|
|
41
|
+
}),
|
|
42
|
+
hover(raw({ textDecorationColor: "currentcolor" })),
|
|
43
|
+
data("color", "brand", [
|
|
44
|
+
fg("brand"),
|
|
45
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
46
|
+
weight(500),
|
|
47
|
+
fg("brand.emphasis"),
|
|
48
|
+
]),
|
|
49
|
+
]),
|
|
50
|
+
data("color", "neutral", [
|
|
51
|
+
fg("neutral"),
|
|
52
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
53
|
+
weight(500),
|
|
54
|
+
fg("neutral.emphasis"),
|
|
55
|
+
]),
|
|
56
|
+
]),
|
|
57
|
+
data("color", "success", [
|
|
58
|
+
fg("success"),
|
|
59
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
60
|
+
weight(500),
|
|
61
|
+
fg("success.emphasis"),
|
|
62
|
+
]),
|
|
63
|
+
]),
|
|
64
|
+
data("color", "warning", [
|
|
65
|
+
fg("warning"),
|
|
66
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
67
|
+
weight(500),
|
|
68
|
+
fg("warning.emphasis"),
|
|
69
|
+
]),
|
|
70
|
+
]),
|
|
71
|
+
data("color", "danger", [
|
|
72
|
+
fg("danger"),
|
|
73
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
74
|
+
weight(500),
|
|
75
|
+
fg("danger.emphasis"),
|
|
76
|
+
]),
|
|
77
|
+
]),
|
|
78
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
79
|
+
weight(500),
|
|
80
|
+
raw({ textDecorationThickness: "2px", textDecorationColor: "currentcolor" }),
|
|
81
|
+
]),
|
|
82
|
+
data("has-background", textDecoration("none")),
|
|
83
|
+
when('&[data-has-background]:hover, &[data-has-background][aria-current]:not([aria-current="false"])', textDecoration("none")),
|
|
84
|
+
mix,
|
|
85
|
+
] }), rendersPrefetchHint(resolvedPrefetch, rest.href) && (_jsx("link", { rel: "prefetch", href: rest.href }))] }));
|
|
82
86
|
};
|
|
83
87
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @copyright Sergio Xalambrí 2026
|
|
11
11
|
*/
|
|
12
12
|
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
13
|
+
import type { LinkPrefetch } from "../utils/link-prefetch.js";
|
|
13
14
|
import { Popover } from "./popover.js";
|
|
14
15
|
/**
|
|
15
16
|
* Prop types for {@link NavigationMenu} and its compound parts.
|
|
@@ -90,7 +91,18 @@ export declare namespace NavigationMenu {
|
|
|
90
91
|
type LinkProps = TagProps<"a"> & {
|
|
91
92
|
/** Destination the link navigates to. */
|
|
92
93
|
href: string;
|
|
94
|
+
/**
|
|
95
|
+
* `"intent"`/`"viewport"` write `data-rmx-prefetch`; `"render"` adds a `<link rel="prefetch">`
|
|
96
|
+
* that also serves full-document navigations, so keep it to the first few links, since each
|
|
97
|
+
* hint is a request on page load. Defaults to {@link DEFAULT_PREFETCH}.
|
|
98
|
+
*/
|
|
99
|
+
prefetch?: Prefetch;
|
|
93
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* When a {@link NavigationMenu.Link}'s destination starts loading, the same
|
|
103
|
+
* modes every link component in this library accepts.
|
|
104
|
+
*/
|
|
105
|
+
type Prefetch = LinkPrefetch;
|
|
94
106
|
/**
|
|
95
107
|
* Every native `<div>` attribute, plus the `mix` passthrough.
|
|
96
108
|
*/
|
|
@@ -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, fg, outline, outlineStyle } from "@sdxc/u/color";
|
|
3
3
|
import { opacity, rounded, transition, transitionBehavior, transitionProperty, } from "@sdxc/u/effects";
|
|
4
4
|
import { cursor, raw, userSelect } from "@sdxc/u/general";
|
|
@@ -14,6 +14,7 @@ import { attrs } from "remix/component";
|
|
|
14
14
|
import { durations, easings } from "../animations/tokens.js";
|
|
15
15
|
import { concentricRadius, floatingSurface, surfaceInset, surfacePadding, } from "../styles/floating-surface.js";
|
|
16
16
|
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
17
|
+
import { prefetchAttribute, rendersPrefetchHint } from "../utils/link-prefetch.js";
|
|
17
18
|
import { Popover } from "./popover.js";
|
|
18
19
|
/**
|
|
19
20
|
* Named container {@link NavigationMenu.Content} declares on its own host, so
|
|
@@ -55,6 +56,8 @@ const DEFAULT_CONTENT_PLACEMENT = "bottom-start";
|
|
|
55
56
|
* sizing the panel to its own content instead of a fixed wide measure.
|
|
56
57
|
*/
|
|
57
58
|
const DEFAULT_CONTENT_SIZE = "default";
|
|
59
|
+
/** Prefetch mode {@link NavigationMenu.Link} falls back to when `prefetch` is omitted. */
|
|
60
|
+
const DEFAULT_PREFETCH = "none";
|
|
58
61
|
/**
|
|
59
62
|
* Renders the menu's root host: a native `<nav>` landmark establishing a
|
|
60
63
|
* positioning context for whatever floating panels its
|
|
@@ -235,23 +238,26 @@ NavigationMenu.Content = function NavigationMenuContent(handle) {
|
|
|
235
238
|
};
|
|
236
239
|
};
|
|
237
240
|
/**
|
|
238
|
-
* Renders {@link NavigationMenu.LinkProps.children} as a native `<a
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
+
* Renders {@link NavigationMenu.LinkProps.children} as a native `<a>`, followed
|
|
242
|
+
* by its `<link rel="prefetch">` when `prefetch="render"`. `aria-current` marks
|
|
243
|
+
* the active page; `aria-disabled="true"` only mutes it visually.
|
|
241
244
|
*
|
|
242
245
|
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
243
246
|
* @returns The render function producing the link's markup.
|
|
244
247
|
* @example
|
|
245
248
|
* <NavigationMenu.Link href="/pricing">{t("nav.pricing")}</NavigationMenu.Link>
|
|
246
249
|
* @example
|
|
250
|
+
* <NavigationMenu.Link href="/docs" prefetch="intent">{t("nav.docs")}</NavigationMenu.Link>
|
|
251
|
+
* @example
|
|
247
252
|
* <NavigationMenu.Link href="/dashboard" aria-current={pathname === "/dashboard" ? "page" : undefined}>
|
|
248
253
|
* {t("nav.dashboard")}
|
|
249
254
|
* </NavigationMenu.Link>
|
|
250
255
|
*/
|
|
251
256
|
NavigationMenu.Link = function NavigationMenuLink(handle) {
|
|
252
257
|
return () => {
|
|
253
|
-
let { mix, ...rest } = handle.props;
|
|
254
|
-
|
|
258
|
+
let { prefetch, mix, ...rest } = handle.props;
|
|
259
|
+
let resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;
|
|
260
|
+
let anchor = (_jsx("a", { "data-slot": "link", "data-rmx-prefetch": prefetchAttribute(resolvedPrefetch), ...rest, mix: [
|
|
255
261
|
interactiveTransition(),
|
|
256
262
|
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
257
263
|
inlineFlex(),
|
|
@@ -274,6 +280,9 @@ NavigationMenu.Link = function NavigationMenuLink(handle) {
|
|
|
274
280
|
fontSize("sm"),
|
|
275
281
|
mix,
|
|
276
282
|
] }));
|
|
283
|
+
if (!rendersPrefetchHint(resolvedPrefetch, rest.href))
|
|
284
|
+
return anchor;
|
|
285
|
+
return (_jsxs(_Fragment, { children: [anchor, _jsx("link", { rel: "prefetch", href: rest.href })] }));
|
|
277
286
|
};
|
|
278
287
|
};
|
|
279
288
|
/**
|
|
@@ -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
|
/**
|
|
15
16
|
* Prop types for {@link Pagination} and its compound parts.
|
|
16
17
|
*/
|
|
@@ -31,11 +32,23 @@ export declare namespace Pagination {
|
|
|
31
32
|
interface ItemProps extends TagProps<"li"> {
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* conditional type an `interface extends` clause can't statically extend.
|
|
35
|
+
* When a {@link Pagination.Link}'s destination starts loading, the same
|
|
36
|
+
* modes every link component in this library accepts.
|
|
37
37
|
*/
|
|
38
|
-
type
|
|
38
|
+
type Prefetch = LinkPrefetch;
|
|
39
|
+
/**
|
|
40
|
+
* Every native `<a>` attribute, plus `prefetch` and the `mix` passthrough. A
|
|
41
|
+
* type alias rather than an interface, since native anchor props resolve
|
|
42
|
+
* through a conditional type an `interface extends` clause can't extend.
|
|
43
|
+
*/
|
|
44
|
+
type LinkProps = TagProps<"a"> & {
|
|
45
|
+
/**
|
|
46
|
+
* `"intent"`/`"viewport"` write `data-rmx-prefetch`; `"render"` adds a `<link rel="prefetch">`
|
|
47
|
+
* that also serves full-document navigations. The next-page link suits `"render"` or
|
|
48
|
+
* `"intent"`. Defaults to {@link DEFAULT_PREFETCH}.
|
|
49
|
+
*/
|
|
50
|
+
prefetch?: Prefetch;
|
|
51
|
+
};
|
|
39
52
|
/**
|
|
40
53
|
* Every native `<button>` attribute, unchanged, plus the `mix` passthrough.
|
|
41
54
|
*/
|
|
@@ -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, fg, outline } from "@sdxc/u/color";
|
|
3
3
|
import { opacity, rounded } from "@sdxc/u/effects";
|
|
4
4
|
import { cursor, listStyle, pointerEvents } from "@sdxc/u/general";
|
|
@@ -7,12 +7,15 @@ import { bs, m, minIs, p, pi } from "@sdxc/u/size";
|
|
|
7
7
|
import { active, hover, when } from "@sdxc/u/state";
|
|
8
8
|
import { tabularNums, text, textDecoration, weight } from "@sdxc/u/typography";
|
|
9
9
|
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
10
|
+
import { prefetchAttribute, rendersPrefetchHint } from "../utils/link-prefetch.js";
|
|
10
11
|
import { warnIfNoAccessibleLabel, warnIfNoAccessibleName, } from "../utils/warn-if-no-accessible-name.js";
|
|
11
12
|
/**
|
|
12
13
|
* `type` given to a {@link Pagination.Button} carrying an Invoker Command, for
|
|
13
14
|
* which the platform accepts no other value.
|
|
14
15
|
*/
|
|
15
16
|
const INVOKER_TYPE = "button";
|
|
17
|
+
/** Prefetch mode {@link Pagination.Link} falls back to when `prefetch` is omitted. */
|
|
18
|
+
const DEFAULT_PREFETCH = "none";
|
|
16
19
|
/**
|
|
17
20
|
* Renders the pagination's `<nav>` root, laying its single {@link
|
|
18
21
|
* Pagination.List} child out as a centered row. In dev mode, a root missing
|
|
@@ -78,14 +81,14 @@ Pagination.Item = function PaginationItem(handle) {
|
|
|
78
81
|
};
|
|
79
82
|
};
|
|
80
83
|
/**
|
|
81
|
-
* Renders a page-number destination as a native `<a
|
|
82
|
-
* `aria-current="page"` fills
|
|
83
|
-
* `aria-disabled="true"` mutes it
|
|
84
|
+
* Renders a page-number destination as a native `<a>`, followed by its
|
|
85
|
+
* `<link rel="prefetch">` when `prefetch="render"`. `aria-current="page"` fills
|
|
86
|
+
* it with the active-page treatment; `aria-disabled="true"` mutes it.
|
|
84
87
|
*
|
|
85
88
|
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
86
89
|
* @returns The render function producing the link's markup.
|
|
87
90
|
* @example
|
|
88
|
-
* <Pagination.Link href="?page=
|
|
91
|
+
* <Pagination.Link href="?page=6" prefetch="render">6</Pagination.Link>
|
|
89
92
|
* @example
|
|
90
93
|
* <Pagination.Link href="?page=5" aria-current="page">5</Pagination.Link>
|
|
91
94
|
* @example
|
|
@@ -93,8 +96,9 @@ Pagination.Item = function PaginationItem(handle) {
|
|
|
93
96
|
*/
|
|
94
97
|
Pagination.Link = function PaginationLink(handle) {
|
|
95
98
|
return () => {
|
|
96
|
-
let { mix, ...rest } = handle.props;
|
|
97
|
-
|
|
99
|
+
let { prefetch, mix, ...rest } = handle.props;
|
|
100
|
+
let resolvedPrefetch = prefetch ?? DEFAULT_PREFETCH;
|
|
101
|
+
let anchor = (_jsx("a", { "data-rmx-prefetch": prefetchAttribute(resolvedPrefetch), ...rest, "data-slot": "link", mix: [
|
|
98
102
|
interactiveTransition(),
|
|
99
103
|
inlineFlex(),
|
|
100
104
|
items("center"),
|
|
@@ -118,6 +122,9 @@ Pagination.Link = function PaginationLink(handle) {
|
|
|
118
122
|
when('&[aria-disabled="true"]', [cursor("not-allowed"), pointerEvents()]),
|
|
119
123
|
mix,
|
|
120
124
|
] }));
|
|
125
|
+
if (!rendersPrefetchHint(resolvedPrefetch, rest.href))
|
|
126
|
+
return anchor;
|
|
127
|
+
return (_jsxs(_Fragment, { children: [anchor, _jsx("link", { rel: "prefetch", href: rest.href })] }));
|
|
121
128
|
};
|
|
122
129
|
};
|
|
123
130
|
/**
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @copyright Sergio Xalambrí 2026
|
|
10
10
|
*/
|
|
11
11
|
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
12
|
+
import type { LinkPrefetch } from "../utils/link-prefetch.js";
|
|
12
13
|
import { Dialog } from "./dialog.js";
|
|
13
14
|
import { ScrollArea } from "./scroll-area.js";
|
|
14
15
|
import { Separator } from "./separator.js";
|
|
@@ -158,7 +159,18 @@ export declare namespace Sidebar {
|
|
|
158
159
|
size?: MenuButtonSize;
|
|
159
160
|
/** Shorthand setting `aria-current="page"` when true and `aria-current` is otherwise unset. */
|
|
160
161
|
active?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* `"intent"`/`"viewport"` write `data-rmx-prefetch`; `"render"` adds a `<link rel="prefetch">`
|
|
164
|
+
* that also serves full-document navigations, so keep it to the first few links, since each
|
|
165
|
+
* hint is a request on page load. Defaults to {@link DEFAULT_PREFETCH}.
|
|
166
|
+
*/
|
|
167
|
+
prefetch?: Prefetch;
|
|
161
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* When a {@link Sidebar.MenuLink} or {@link Sidebar.MenuSubLink} destination
|
|
171
|
+
* starts loading, the same modes every link component in this library accepts.
|
|
172
|
+
*/
|
|
173
|
+
type Prefetch = LinkPrefetch;
|
|
162
174
|
/**
|
|
163
175
|
* Props accepted by {@link Sidebar.MenuAction}.
|
|
164
176
|
*/
|
|
@@ -208,6 +220,12 @@ export declare namespace Sidebar {
|
|
|
208
220
|
href: string;
|
|
209
221
|
/** Shorthand setting `aria-current="page"` when true and `aria-current` is otherwise unset. */
|
|
210
222
|
active?: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* `"intent"`/`"viewport"` write `data-rmx-prefetch`; `"render"` adds a `<link rel="prefetch">`
|
|
225
|
+
* that also serves full-document navigations, so keep it to the first few links, since each
|
|
226
|
+
* hint is a request on page load. Defaults to {@link DEFAULT_PREFETCH}.
|
|
227
|
+
*/
|
|
228
|
+
prefetch?: Prefetch;
|
|
211
229
|
};
|
|
212
230
|
/**
|
|
213
231
|
* Props accepted by {@link Sidebar.Rail}: every native `<label>` attribute
|