@sdxc/ui 2026.11.1 → 2026.11.4
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 +1 -1
- package/dist/app/app-shell-toggle.d.ts +31 -0
- package/dist/app/app-shell-toggle.js +43 -0
- package/dist/app/app-shell.d.ts +131 -0
- package/dist/app/app-shell.js +542 -0
- package/dist/app/auto-refresh.d.ts +104 -0
- package/dist/app/auto-refresh.js +126 -0
- package/dist/app/behaviors/refresh-schedule.d.ts +53 -0
- package/dist/app/behaviors/refresh-schedule.js +95 -0
- package/dist/app/behaviors/shortcuts.d.ts +175 -0
- package/dist/app/behaviors/shortcuts.js +401 -0
- package/dist/app/behaviors/toaster.d.ts +31 -2
- package/dist/app/behaviors/toaster.js +62 -5
- package/dist/app/chart.d.ts +62 -8
- package/dist/app/chart.js +207 -9
- package/dist/app/command-palette.d.ts +132 -0
- package/dist/app/command-palette.js +181 -0
- package/dist/app/danger-zone.d.ts +66 -0
- package/dist/app/danger-zone.js +66 -0
- package/dist/app/detail-sheet.d.ts +119 -0
- package/dist/app/detail-sheet.js +173 -0
- package/dist/app/drop-zone.d.ts +2 -1
- package/dist/app/drop-zone.js +6 -3
- package/dist/app/editor-layout.d.ts +69 -0
- package/dist/app/editor-layout.js +143 -0
- package/dist/app/empty.d.ts +56 -19
- package/dist/app/empty.js +129 -22
- package/dist/app/filter-bar.d.ts +169 -0
- package/dist/app/filter-bar.js +346 -0
- package/dist/app/index.d.ts +51 -0
- package/dist/app/index.js +51 -0
- package/dist/app/keyboard-help.d.ts +66 -0
- package/dist/app/keyboard-help.js +56 -0
- package/dist/app/mixins/app-shell-controls.d.ts +46 -0
- package/dist/app/mixins/app-shell-controls.js +131 -0
- package/dist/app/mixins/auto-refresh.d.ts +29 -0
- package/dist/app/mixins/auto-refresh.js +66 -0
- package/dist/app/mixins/command-palette.d.ts +56 -0
- package/dist/app/mixins/command-palette.js +297 -0
- package/dist/app/mixins/copy-permalink.d.ts +26 -0
- package/dist/app/mixins/copy-permalink.js +54 -0
- package/dist/app/mixins/detail-sheet-keys.d.ts +28 -0
- package/dist/app/mixins/detail-sheet-keys.js +88 -0
- package/dist/app/mixins/escape-link.d.ts +17 -0
- package/dist/app/mixins/escape-link.js +35 -0
- package/dist/app/mixins/keyboard-help.d.ts +38 -0
- package/dist/app/mixins/keyboard-help.js +51 -0
- package/dist/app/mixins/optimistic-toggle-sync.d.ts +80 -0
- package/dist/app/mixins/optimistic-toggle-sync.js +153 -0
- package/dist/app/mixins/range-picker-keys.d.ts +18 -0
- package/dist/app/mixins/range-picker-keys.js +94 -0
- package/dist/app/mixins/row-navigation.d.ts +85 -0
- package/dist/app/mixins/row-navigation.js +208 -0
- package/dist/app/mixins/save-bar-sync.d.ts +27 -0
- package/dist/app/mixins/save-bar-sync.js +106 -0
- package/dist/app/mixins/save-shortcut.d.ts +47 -0
- package/dist/app/mixins/save-shortcut.js +101 -0
- package/dist/app/mixins/save-status-sync.d.ts +77 -0
- package/dist/app/mixins/save-status-sync.js +159 -0
- package/dist/app/mixins/selection-bar-sync.d.ts +32 -0
- package/dist/app/mixins/selection-bar-sync.js +151 -0
- package/dist/app/mixins/split-view.d.ts +66 -0
- package/dist/app/mixins/split-view.js +319 -0
- package/dist/app/mixins/status-strip-keys.d.ts +17 -0
- package/dist/app/mixins/status-strip-keys.js +79 -0
- package/dist/app/mixins/submit-on-change.d.ts +16 -0
- package/dist/app/mixins/submit-on-change.js +28 -0
- package/dist/app/mixins/table-selection.d.ts +39 -0
- package/dist/app/mixins/table-selection.js +272 -0
- package/dist/app/mixins/toast-queue.d.ts +36 -0
- package/dist/app/mixins/toast-queue.js +77 -0
- package/dist/app/mixins/toast-stack.d.ts +20 -0
- package/dist/app/mixins/toast-stack.js +55 -0
- package/dist/app/optimistic-toggle.d.ts +48 -0
- package/dist/app/optimistic-toggle.js +38 -0
- package/dist/app/page-header.d.ts +71 -0
- package/dist/app/page-header.js +249 -0
- package/dist/app/range-picker.d.ts +102 -0
- package/dist/app/range-picker.js +118 -0
- package/dist/app/save-bar.d.ts +54 -0
- package/dist/app/save-bar.js +64 -0
- package/dist/app/save-status.d.ts +50 -0
- package/dist/app/save-status.js +54 -0
- package/dist/app/selection-bar.d.ts +101 -0
- package/dist/app/selection-bar.js +157 -0
- package/dist/app/settings-layout.d.ts +70 -0
- package/dist/app/settings-layout.js +112 -0
- package/dist/app/settings-section.d.ts +140 -0
- package/dist/app/settings-section.js +182 -0
- package/dist/app/skeleton.d.ts +47 -4
- package/dist/app/skeleton.js +149 -2
- package/dist/app/sparkline.d.ts +61 -0
- package/dist/app/sparkline.js +145 -0
- package/dist/app/split-view.d.ts +154 -0
- package/dist/app/split-view.js +272 -0
- package/dist/app/stat-card.d.ts +109 -0
- package/dist/app/stat-card.js +379 -0
- package/dist/app/status-strip.d.ts +70 -0
- package/dist/app/status-strip.js +155 -0
- package/dist/app/styles/action-row.d.ts +41 -0
- package/dist/app/styles/action-row.js +59 -0
- package/dist/app/styles/stat-delta.d.ts +29 -0
- package/dist/app/styles/stat-delta.js +36 -0
- package/dist/app/styles/toast-stack.d.ts +21 -0
- package/dist/app/styles/toast-stack.js +54 -0
- package/dist/app/table.d.ts +199 -24
- package/dist/app/table.js +640 -36
- package/dist/app/toast.d.ts +105 -5
- package/dist/app/toast.js +89 -17
- package/dist/app/toasts.d.ts +49 -0
- package/dist/app/toasts.js +103 -0
- package/dist/app/utils/app-shell-cookie.d.ts +21 -0
- package/dist/app/utils/app-shell-cookie.js +33 -0
- package/dist/app/utils/chart-marker-indices.d.ts +9 -5
- package/dist/app/utils/chart-marker-indices.js +9 -8
- package/dist/app/utils/chart-path.d.ts +14 -10
- package/dist/app/utils/chart-path.js +46 -18
- package/dist/app/utils/edited-time.d.ts +19 -0
- package/dist/app/utils/edited-time.js +35 -0
- package/dist/app/utils/key-target.d.ts +23 -0
- package/dist/app/utils/key-target.js +48 -0
- package/dist/app/utils/search-params.d.ts +69 -0
- package/dist/app/utils/search-params.js +132 -0
- package/dist/app/utils/shortcut-groups.d.ts +21 -0
- package/dist/app/utils/shortcut-groups.js +53 -0
- package/dist/app/utils/split-view-layout.d.ts +48 -0
- package/dist/app/utils/split-view-layout.js +71 -0
- package/dist/app/view-options.d.ts +99 -0
- package/dist/app/view-options.js +182 -0
- package/dist/components/banner.d.ts +61 -0
- package/dist/components/banner.js +101 -0
- package/dist/components/confirm.d.ts +54 -5
- package/dist/components/confirm.js +44 -5
- package/dist/components/group.d.ts +14 -0
- package/dist/components/group.js +66 -11
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/input.js +9 -3
- package/dist/components/link-button.js +8 -2
- package/dist/components/property-list.d.ts +76 -0
- package/dist/components/property-list.js +175 -0
- package/dist/components/relative-time.d.ts +72 -0
- package/dist/components/relative-time.js +45 -0
- package/dist/components/status-dot.d.ts +62 -0
- package/dist/components/status-dot.js +99 -0
- package/dist/components/text-field.d.ts +17 -2
- package/dist/components/text-field.js +13 -4
- package/dist/components/timeline.d.ts +67 -0
- package/dist/components/timeline.js +159 -0
- package/dist/components/typeset.d.ts +2 -1
- package/dist/components/typeset.js +4 -1
- package/dist/docs/code-tabs-sync.d.ts +1 -1
- package/dist/docs/code-tabs-sync.js +2 -2
- package/dist/docs/copy-button.d.ts +1 -1
- package/dist/docs/copy-button.js +2 -2
- package/dist/docs/docs-feedback.d.ts +12 -0
- package/dist/docs/docs-feedback.js +4 -2
- package/dist/docs/docs-hub.js +4 -4
- package/dist/docs/docs-layout.d.ts +1 -1
- package/dist/docs/docs-layout.js +1 -1
- package/dist/docs/docs-nav-tools.d.ts +11 -5
- package/dist/docs/docs-nav-tools.js +5 -4
- package/dist/docs/docs-nav.d.ts +12 -5
- package/dist/docs/docs-nav.js +20 -8
- package/dist/docs/docs-pager.d.ts +5 -1
- package/dist/docs/docs-pager.js +7 -6
- package/dist/docs/mixins/docs-nav-tools.d.ts +3 -3
- package/dist/docs/mixins/docs-nav-tools.js +42 -17
- package/dist/docs/next-steps.js +3 -2
- package/dist/docs/page-actions.d.ts +1 -1
- package/dist/docs/page-actions.js +2 -2
- package/dist/docs/table-of-contents.d.ts +1 -1
- package/dist/docs/table-of-contents.js +2 -2
- package/dist/docs/utils/docs-filter.d.ts +26 -0
- package/dist/docs/utils/docs-filter.js +53 -0
- package/dist/mixins/confirm-phrase.d.ts +19 -0
- package/dist/mixins/confirm-phrase.js +56 -0
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.js +2 -0
- package/dist/mixins/viewer-time.d.ts +20 -0
- package/dist/mixins/viewer-time.js +40 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/segmented-control.d.ts +49 -0
- package/dist/styles/segmented-control.js +71 -0
- package/dist/test/table.d.ts +65 -0
- package/dist/test/table.js +108 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/relative-time.d.ts +44 -0
- package/dist/utils/relative-time.js +69 -0
- package/package.json +6 -6
|
@@ -28,13 +28,15 @@ const VOTED = `input[name="${DOCS_FEEDBACK_VOTE_FIELD}"]:checked`;
|
|
|
28
28
|
* @returns The render function producing the block's markup.
|
|
29
29
|
* @example
|
|
30
30
|
* <DocsFeedback action="/docs/feedback" page="/docs/alerts" state={sent ? "sent" : "idle"} labels={labels} />
|
|
31
|
+
* @example
|
|
32
|
+
* <DocsFeedback frame="feedback" resetScroll="manual" action="/docs/feedback" page="/docs/alerts" labels={labels} />
|
|
31
33
|
*/
|
|
32
34
|
export function DocsFeedback(handle) {
|
|
33
35
|
return () => {
|
|
34
|
-
let { action, page, labels, state, mix, ...rest } = handle.props;
|
|
36
|
+
let { action, page, labels, state, frame, resetScroll, mix, ...rest } = handle.props;
|
|
35
37
|
let isSent = state === "sent";
|
|
36
38
|
let questionId = `${handle.id}-question`;
|
|
37
|
-
return (_jsxs("div", { ...rest, "data-slot": "docs-feedback", "data-state": isSent ? "sent" : "idle", mix: mergeMix([minIs(0), text("sm"), fg("neutral")], mix), children: [_jsx("p", { role: "status", "data-slot": "docs-feedback-thanks", mix: [m(0), isSent ? [] : visuallyHidden()], children: isSent ? labels.thanks : "" }), isSent ? null : (_jsxs("form", { method: "post", action: action, "data-slot": "docs-feedback-form", mix: [vstack({ gap: 3, align: "stretch" })], children: [_jsx("input", { type: "hidden", name: DOCS_FEEDBACK_PAGE_FIELD, value: page }), _jsxs("div", { role: "radiogroup", "aria-labelledby": questionId, "data-slot": "docs-feedback-vote", mix: [flex(), items("center"), gap(4, 3), raw({ flexWrap: "wrap" }), minIs(0)], children: [_jsx("span", { id: questionId, "data-slot": "docs-feedback-question", mix: [weight("medium"), fg("neutral.emphasis")], children: labels.question }), _jsxs("span", { mix: [hstack({ gap: 2, align: "center" })], children: [_jsx(DocsFeedbackChoice, { value: "yes", label: labels.yes }), _jsx(DocsFeedbackChoice, { value: "no", label: labels.no })] })] }), _jsxs("div", { "data-slot": "docs-feedback-note", mix: [
|
|
39
|
+
return (_jsxs("div", { ...rest, "data-slot": "docs-feedback", "data-state": isSent ? "sent" : "idle", mix: mergeMix([minIs(0), text("sm"), fg("neutral")], mix), children: [_jsx("p", { role: "status", "data-slot": "docs-feedback-thanks", mix: [m(0), isSent ? [] : visuallyHidden()], children: isSent ? labels.thanks : "" }), isSent ? null : (_jsxs("form", { method: "post", action: action, "data-rmx-target": frame, "data-rmx-reset-scroll": resetScroll, "data-slot": "docs-feedback-form", mix: [vstack({ gap: 3, align: "stretch" })], children: [_jsx("input", { type: "hidden", name: DOCS_FEEDBACK_PAGE_FIELD, value: page }), _jsxs("div", { role: "radiogroup", "aria-labelledby": questionId, "data-slot": "docs-feedback-vote", mix: [flex(), items("center"), gap(4, 3), raw({ flexWrap: "wrap" }), minIs(0)], children: [_jsx("span", { id: questionId, "data-slot": "docs-feedback-question", mix: [weight("medium"), fg("neutral.emphasis")], children: labels.question }), _jsxs("span", { mix: [hstack({ gap: 2, align: "center" })], children: [_jsx(DocsFeedbackChoice, { value: "yes", label: labels.yes }), _jsx(DocsFeedbackChoice, { value: "no", label: labels.no })] })] }), _jsxs("div", { "data-slot": "docs-feedback-note", mix: [
|
|
38
40
|
/**
|
|
39
41
|
* One rule holds both displays, so the revealed state always outranks the
|
|
40
42
|
* hidden one whatever order the stylesheet layers land in.
|
package/dist/docs/docs-hub.js
CHANGED
|
@@ -85,7 +85,7 @@ export function DocsHub(handle) {
|
|
|
85
85
|
balance(),
|
|
86
86
|
fg("neutral.emphasis"),
|
|
87
87
|
raw({ fontWeight: 650, letterSpacing: "-0.02em", lineHeight: 1.1 }),
|
|
88
|
-
], children: title }), lead ? (_jsx("p", { "data-slot": "docs-hub-lead", mix: [m(0), text("lg"), pretty(), fg("neutral"), raw({ maxInlineSize: "65ch" })], children: lead })) : null] }), search ? (_jsx("div", { "data-slot": "docs-hub-search", mix: [raw({ maxInlineSize: "36rem" })], children: search })) : null, topics && topics.length > 0 ? (_jsx("nav", { "data-slot": "docs-hub-topics", "aria-label": labels.topics, children: _jsx("ul", { mix: [hstack({ gap: 2 }), flexWrap("wrap"), m(0), p(0), listStyle("none")], children: topics.map((topic) => (_jsx("li", { children: _jsx("a", { href: topic.href, "data-rmx-prefetch": "intent", "data-slot": "docs-hub-topic", mix: [
|
|
88
|
+
], children: title }), lead ? (_jsx("p", { "data-slot": "docs-hub-lead", mix: [m(0), text("lg"), pretty(), fg("neutral"), raw({ maxInlineSize: "65ch" })], children: lead })) : null] }), search ? (_jsx("div", { "data-slot": "docs-hub-search", mix: [raw({ maxInlineSize: "36rem" })], children: search })) : null, topics && topics.length > 0 ? (_jsx("nav", { "data-slot": "docs-hub-topics", "aria-label": labels.topics, children: _jsx("ul", { "data-slot": "docs-hub-topic-list", "data-not-typeset": "", mix: [hstack({ gap: 2 }), flexWrap("wrap"), m(0), p(0), listStyle("none")], children: topics.map((topic) => (_jsx("li", { children: _jsx("a", { href: topic.href, "data-rmx-prefetch": "intent", "data-slot": "docs-hub-topic", mix: [
|
|
89
89
|
hstack({ align: "center" }),
|
|
90
90
|
raw({
|
|
91
91
|
minBlockSize: "2.25rem",
|
|
@@ -100,7 +100,7 @@ export function DocsHub(handle) {
|
|
|
100
100
|
hover(border("brand.border")),
|
|
101
101
|
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
102
102
|
motionSafe(raw({ transition: `border-color 150ms ${EASE_OUT}` })),
|
|
103
|
-
], children: topic.title }) }, topic.href))) }) })) : null] }), start.length > 0 ? (_jsxs("section", { "data-slot": "docs-hub-start", mix: [vstack({ gap: 4, align: "stretch" })], children: [_jsx(BlockTag, { mix: blockHeading, children: labels.start }), _jsx("ul", { mix: [fillGrid("20rem"), m(0), p(0), listStyle("none")], children: start.map((item) => (_jsx("li", { mix: [grid()], children: _jsxs("a", { href: item.href, "data-rmx-prefetch": "intent", "data-slot": "docs-hub-start-card", mix: [cardLink(), p(6), bg("neutral.bg-tint"), raw({ minBlockSize: "11rem" })], children: [item.eyebrow ? (_jsx("span", { mix: [text("xs"), font("mono"), fg("neutral.muted")], children: item.eyebrow })) : null, _jsx(CardTag, { "data-slot": "docs-hub-start-title", mix: [
|
|
103
|
+
], children: topic.title }) }, topic.href))) }) })) : null] }), start.length > 0 ? (_jsxs("section", { "data-slot": "docs-hub-start", mix: [vstack({ gap: 4, align: "stretch" })], children: [_jsx(BlockTag, { mix: blockHeading, children: labels.start }), _jsx("ul", { "data-slot": "docs-hub-start-list", "data-not-typeset": "", mix: [fillGrid("20rem"), m(0), p(0), listStyle("none")], children: start.map((item) => (_jsx("li", { mix: [grid()], children: _jsxs("a", { href: item.href, "data-rmx-prefetch": "intent", "data-slot": "docs-hub-start-card", mix: [cardLink(), p(6), bg("neutral.bg-tint"), raw({ minBlockSize: "11rem" })], children: [item.eyebrow ? (_jsx("span", { mix: [text("xs"), font("mono"), fg("neutral.muted")], children: item.eyebrow })) : null, _jsx(CardTag, { "data-slot": "docs-hub-start-title", mix: [
|
|
104
104
|
m(0),
|
|
105
105
|
text("xl"),
|
|
106
106
|
weight("semibold"),
|
|
@@ -112,7 +112,7 @@ export function DocsHub(handle) {
|
|
|
112
112
|
text("sm"),
|
|
113
113
|
weight("medium"),
|
|
114
114
|
fg("brand"),
|
|
115
|
-
], children: [item.cta, _jsx(ArrowRightIcon, { size: 14, "aria-hidden": "true" })] })) : null] }) }, item.href))) })] })) : null, sections.length > 0 ? (_jsxs("section", { "data-slot": "docs-hub-sections", mix: [vstack({ gap: 4, align: "stretch" })], children: [_jsx(BlockTag, { mix: blockHeading, children: labels.sections }), _jsx("ul", { mix: [fillGrid("15rem"), m(0), p(0), listStyle("none")], children: sections.map((section) => {
|
|
115
|
+
], children: [item.cta, _jsx(ArrowRightIcon, { size: 14, "aria-hidden": "true" })] })) : null] }) }, item.href))) })] })) : null, sections.length > 0 ? (_jsxs("section", { "data-slot": "docs-hub-sections", mix: [vstack({ gap: 4, align: "stretch" })], children: [_jsx(BlockTag, { mix: blockHeading, children: labels.sections }), _jsx("ul", { "data-slot": "docs-hub-section-list", "data-not-typeset": "", mix: [fillGrid("15rem"), m(0), p(0), listStyle("none")], children: sections.map((section) => {
|
|
116
116
|
let countText = section.countLabel ??
|
|
117
117
|
(section.count === undefined
|
|
118
118
|
? undefined
|
|
@@ -129,7 +129,7 @@ export function DocsHub(handle) {
|
|
|
129
129
|
font("mono"),
|
|
130
130
|
fg("neutral.muted"),
|
|
131
131
|
], children: countText })) : null] }) }, section.href));
|
|
132
|
-
}) })] })) : null, popular && popular.length > 0 ? (_jsxs("section", { "data-slot": "docs-hub-popular", mix: [vstack({ gap: 4, align: "stretch" })], children: [labels.popular ? _jsx(BlockTag, { mix: blockHeading, children: labels.popular }) : null, _jsx("ul", { mix: [fillGrid("15rem", "fill"), m(0), p(0), listStyle("none")], children: popular.map((item) => (_jsx("li", { mix: [grid()], children: _jsxs("a", { href: item.href, "data-rmx-prefetch": "intent", "data-slot": "docs-hub-popular-card", mix: [cardLink(), raw({ overflow: "hidden" })], children: [item.image ? (_jsx("span", { "data-slot": "docs-hub-popular-image", mix: [
|
|
132
|
+
}) })] })) : null, popular && popular.length > 0 ? (_jsxs("section", { "data-slot": "docs-hub-popular", mix: [vstack({ gap: 4, align: "stretch" })], children: [labels.popular ? _jsx(BlockTag, { mix: blockHeading, children: labels.popular }) : null, _jsx("ul", { "data-slot": "docs-hub-popular-list", "data-not-typeset": "", mix: [fillGrid("15rem", "fill"), m(0), p(0), listStyle("none")], children: popular.map((item) => (_jsx("li", { mix: [grid()], children: _jsxs("a", { href: item.href, "data-rmx-prefetch": "intent", "data-slot": "docs-hub-popular-card", mix: [cardLink(), raw({ overflow: "hidden" })], children: [item.image ? (_jsx("span", { "data-slot": "docs-hub-popular-image", mix: [
|
|
133
133
|
raw({
|
|
134
134
|
display: "block",
|
|
135
135
|
aspectRatio: "16 / 9",
|
|
@@ -77,7 +77,7 @@ export declare namespace DocsLayout {
|
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Renders the three columns and their narrow-screen fallbacks. Load
|
|
80
|
-
* `@sdxc/ui/table-of-contents` and `@sdxc/ui/dialog-dismiss` in the browser entry. Headings
|
|
80
|
+
* `@sdxc/ui/docs/table-of-contents` and `@sdxc/ui/dialog-dismiss` in the browser entry. Headings
|
|
81
81
|
* with an `id` in the article get a `scroll-margin-top` that clears the sticky chrome, and
|
|
82
82
|
* `--ui-docs-scroll-margin` carries the same offset for anything else jumped to.
|
|
83
83
|
*
|
package/dist/docs/docs-layout.js
CHANGED
|
@@ -31,7 +31,7 @@ const BAR_HEIGHT = "2.75rem";
|
|
|
31
31
|
const RING_CLEARANCE = "0.375rem";
|
|
32
32
|
/**
|
|
33
33
|
* Renders the three columns and their narrow-screen fallbacks. Load
|
|
34
|
-
* `@sdxc/ui/table-of-contents` and `@sdxc/ui/dialog-dismiss` in the browser entry. Headings
|
|
34
|
+
* `@sdxc/ui/docs/table-of-contents` and `@sdxc/ui/dialog-dismiss` in the browser entry. Headings
|
|
35
35
|
* with an `id` in the article get a `scroll-margin-top` that clears the sticky chrome, and
|
|
36
36
|
* `--ui-docs-scroll-margin` carries the same offset for anything else jumped to.
|
|
37
37
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Island that finishes a {@link DocsNav} in the browser: the sidebar opens scrolled to the
|
|
3
|
-
* current page, and an optional field filters its pages by title. It renders
|
|
4
|
-
* so the tree it acts on stays server HTML however many pages it holds.
|
|
3
|
+
* current page, and an optional field filters its pages by title as the reader types. It renders
|
|
4
|
+
* only the field, so the tree it acts on stays server HTML however many pages it holds.
|
|
5
5
|
*
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
@@ -11,15 +11,21 @@ import type { EntryComponent } from "remix/component";
|
|
|
11
11
|
export declare namespace DocsNavTools {
|
|
12
12
|
/** Plain data only, since the props cross into the browser with the island. */
|
|
13
13
|
type Props = {
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The title filter's accessible name, placeholder, the query parameter it submits as
|
|
16
|
+
* and the query the page was rendered for; unset draws no field.
|
|
17
|
+
*/
|
|
15
18
|
filter?: {
|
|
16
19
|
label: string;
|
|
17
20
|
placeholder: string;
|
|
21
|
+
name: string;
|
|
22
|
+
query: string;
|
|
18
23
|
};
|
|
19
24
|
};
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
|
-
* Renders the filter field
|
|
23
|
-
*
|
|
27
|
+
* Renders the filter field inside a `GET` form on the current address, so before or without
|
|
28
|
+
* script, Enter reloads the page filtered by the server. `DocsNav` places it; load
|
|
29
|
+
* `@sdxc/ui/docs/docs-nav-tools` in the browser entry to filter as the reader types.
|
|
24
30
|
*/
|
|
25
31
|
export declare const DocsNavTools: EntryComponent<DocsNavTools.Props>;
|
|
@@ -3,12 +3,13 @@ import { clientEntry } from "remix/component";
|
|
|
3
3
|
import { SearchField } from "../components/search-field.js";
|
|
4
4
|
import { docsNavTools } from "./mixins/docs-nav-tools.js";
|
|
5
5
|
/**
|
|
6
|
-
* Renders the filter field
|
|
7
|
-
*
|
|
6
|
+
* Renders the filter field inside a `GET` form on the current address, so before or without
|
|
7
|
+
* script, Enter reloads the page filtered by the server. `DocsNav` places it; load
|
|
8
|
+
* `@sdxc/ui/docs/docs-nav-tools` in the browser entry to filter as the reader types.
|
|
8
9
|
*/
|
|
9
|
-
export const DocsNavTools = clientEntry("@sdxc/ui/docs-nav-tools#DocsNavTools", function DocsNavTools(handle) {
|
|
10
|
+
export const DocsNavTools = clientEntry("@sdxc/ui/docs/docs-nav-tools#DocsNavTools", function DocsNavTools(handle) {
|
|
10
11
|
return () => {
|
|
11
12
|
let { filter } = handle.props;
|
|
12
|
-
return (_jsx("
|
|
13
|
+
return (_jsx("form", { method: "get", mix: [docsNavTools()], children: filter ? (_jsx(SearchField, { "aria-label": filter.label, children: _jsx(SearchField.Input, { name: filter.name, defaultValue: filter.query, placeholder: filter.placeholder, autocomplete: "off" }) })) : null }));
|
|
13
14
|
};
|
|
14
15
|
});
|
package/dist/docs/docs-nav.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A docs sidebar drawn from a {@link DocsTree}: sections under plain labels, pages and
|
|
3
3
|
* titled groups of pages, the current page marked and scrolled into view, an optional
|
|
4
|
-
* title filter, and a footer for support links.
|
|
4
|
+
* title filter that works with or without script, and a footer for support links.
|
|
5
5
|
*
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
@@ -17,15 +17,22 @@ export declare namespace DocsNav {
|
|
|
17
17
|
/** The path being read, which marks one link `aria-current="page"`. */
|
|
18
18
|
activePath: string;
|
|
19
19
|
/**
|
|
20
|
-
* A field that filters pages by title, with the line shown when nothing matches.
|
|
21
|
-
*
|
|
20
|
+
* A field that filters pages by title, with the line shown when nothing matches. Without
|
|
21
|
+
* script it submits `name` (default `"filter"`) to the page; pass that parameter back as
|
|
22
|
+
* `query` and the tree renders filtered.
|
|
22
23
|
*/
|
|
23
24
|
filter?: {
|
|
24
25
|
label: string;
|
|
25
26
|
placeholder: string;
|
|
26
27
|
noResults: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
query?: string;
|
|
27
30
|
};
|
|
28
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Drawn under the tree, such as "Contact support" or a status link, flush with the
|
|
33
|
+
* nav's edge; give its links the rows' inline padding (or render them as
|
|
34
|
+
* `Sidebar.MenuLink`s) to line their text up with the pages above.
|
|
35
|
+
*/
|
|
29
36
|
footer?: RemixNode;
|
|
30
37
|
/**
|
|
31
38
|
* Folds every group except the ones holding the current page, for a tree whose
|
|
@@ -43,7 +50,7 @@ export declare namespace DocsNav {
|
|
|
43
50
|
/**
|
|
44
51
|
* Renders the tree in reading order. A group whose `href` is set links its own page from
|
|
45
52
|
* its summary, and every group is a native `<details>`, so folding needs no script. Load
|
|
46
|
-
* `@sdxc/ui/docs-nav-tools` in the browser entry for the scroll-to-current and the filter.
|
|
53
|
+
* `@sdxc/ui/docs/docs-nav-tools` in the browser entry for the scroll-to-current and the filter.
|
|
47
54
|
*
|
|
48
55
|
* @example
|
|
49
56
|
* <DocsNav tree={tree} activePath={url.pathname} />
|
package/dist/docs/docs-nav.js
CHANGED
|
@@ -11,10 +11,11 @@ import { rotate } from "@sdxc/u/transform";
|
|
|
11
11
|
import { text, weight } from "@sdxc/u/typography";
|
|
12
12
|
import { Sidebar } from "../components/sidebar.js";
|
|
13
13
|
import { DocsNavTools } from "./docs-nav-tools.js";
|
|
14
|
+
import { matchDocsTree } from "./utils/docs-filter.js";
|
|
14
15
|
/**
|
|
15
16
|
* Renders the tree in reading order. A group whose `href` is set links its own page from
|
|
16
17
|
* its summary, and every group is a native `<details>`, so folding needs no script. Load
|
|
17
|
-
* `@sdxc/ui/docs-nav-tools` in the browser entry for the scroll-to-current and the filter.
|
|
18
|
+
* `@sdxc/ui/docs/docs-nav-tools` in the browser entry for the scroll-to-current and the filter.
|
|
18
19
|
*
|
|
19
20
|
* @example
|
|
20
21
|
* <DocsNav tree={tree} activePath={url.pathname} />
|
|
@@ -24,12 +25,21 @@ import { DocsNavTools } from "./docs-nav-tools.js";
|
|
|
24
25
|
export function DocsNav(handle) {
|
|
25
26
|
return () => {
|
|
26
27
|
let { tree, activePath, filter, footer, collapseGroups = false, prefetch = "intent", } = handle.props;
|
|
27
|
-
let
|
|
28
|
+
let query = filter?.query ?? "";
|
|
29
|
+
let matches = filter ? matchDocsTree(tree, query) : null;
|
|
30
|
+
let context = { activePath, collapseGroups, prefetch, matches };
|
|
28
31
|
return (_jsxs("div", { "data-docs-nav": "", mix: [
|
|
29
32
|
vstack({ gap: 4 }),
|
|
30
33
|
minIs(0),
|
|
31
34
|
when("& [hidden]", raw({ display: "none !important" })),
|
|
32
|
-
], children: [_jsx(DocsNavTools, { filter: filter
|
|
35
|
+
], children: [_jsx(DocsNavTools, { filter: filter
|
|
36
|
+
? {
|
|
37
|
+
label: filter.label,
|
|
38
|
+
placeholder: filter.placeholder,
|
|
39
|
+
name: filter.name ?? "filter",
|
|
40
|
+
query,
|
|
41
|
+
}
|
|
42
|
+
: undefined }), _jsxs(Sidebar.Nav, { "aria-label": tree.label, mix: [raw({ gap: "1.25rem" })], children: [tree.sections.map((section) => (_jsxs("div", { "data-docs-nav-section": "", hidden: matches ? !section.items.some((item) => matches.shown.has(item)) : undefined, mix: [vstack({ gap: 1 })], children: [_jsx("p", { mix: [m(0), p(1, 2.5), text("sm"), weight("semibold"), fg("neutral.emphasis")], children: section.title }), _jsx(Sidebar.Menu, { "data-docs-nav-list": "", mix: [m(0), p(0), listStyle("none")], children: section.items.map((item) => (_jsx(NavItem, { item: item, context: context, depth: 0 }, item.href ?? item.title))) })] }, section.title))), filter ? (_jsx("p", { "data-docs-nav-empty": "", hidden: !matches || matches.shown.size > 0, mix: [m(0), p(2, 2.5), text("sm"), fg("neutral.muted")], children: filter.noResults })) : null] }), footer ? _jsx("div", { "data-docs-nav-footer": "", children: footer }) : null] }));
|
|
33
43
|
};
|
|
34
44
|
}
|
|
35
45
|
/** Whether `item` is, or holds, the page at `path`. */
|
|
@@ -40,18 +50,20 @@ function holds(item, path) {
|
|
|
40
50
|
function NavItem(handle) {
|
|
41
51
|
return () => {
|
|
42
52
|
let { item, context, depth } = handle.props;
|
|
43
|
-
let { activePath, collapseGroups, prefetch } = context;
|
|
53
|
+
let { activePath, collapseGroups, prefetch, matches } = context;
|
|
54
|
+
let filteredOut = matches ? !matches.shown.has(item) : undefined;
|
|
44
55
|
let Row = depth === 0 ? Sidebar.MenuItem : Sidebar.MenuSubItem;
|
|
45
56
|
let badge = item.badge ? _jsx(Sidebar.MenuBadge, { children: item.badge }) : null;
|
|
46
57
|
if (!item.items || item.items.length === 0) {
|
|
47
58
|
if (item.href === undefined)
|
|
48
59
|
return null;
|
|
49
60
|
let Link = depth === 0 ? Sidebar.MenuLink : Sidebar.MenuSubLink;
|
|
50
|
-
return (_jsx(Row, { children: _jsxs(Link, { href: item.href, prefetch: prefetch, active: item.href === activePath, children: [_jsx("span", { children: item.title }), badge] }) }));
|
|
61
|
+
return (_jsx(Row, { hidden: filteredOut, children: _jsxs(Link, { href: item.href, prefetch: prefetch, active: item.href === activePath, children: [_jsx("span", { "data-docs-nav-title": "", children: item.title }), badge] }) }));
|
|
51
62
|
}
|
|
52
|
-
let
|
|
63
|
+
let own = !collapseGroups || holds(item, activePath);
|
|
64
|
+
let opened = !own && (matches?.opened.has(item) ?? false);
|
|
53
65
|
let current = item.href !== undefined && item.href === activePath;
|
|
54
|
-
return (_jsx(Row, { children: _jsxs("details", { open:
|
|
66
|
+
return (_jsx(Row, { hidden: filteredOut, children: _jsxs("details", { open: own || opened, "data-docs-nav-opened": opened ? "" : undefined, children: [_jsxs("summary", { mix: [
|
|
55
67
|
hstack({ gap: 2, align: "center" }),
|
|
56
68
|
minBs("2.25rem"),
|
|
57
69
|
pi("0.625rem"),
|
|
@@ -65,7 +77,7 @@ function NavItem(handle) {
|
|
|
65
77
|
fg("inherit"),
|
|
66
78
|
raw({ textDecoration: "none" }),
|
|
67
79
|
when('&[aria-current="page"]', [fg("neutral.emphasis"), weight("medium")]),
|
|
68
|
-
], children: item.title })) : (_jsx("span", { children: item.title })), badge, _jsx(ChevronRightIcon, { size: 14, "aria-hidden": "true", mix: [
|
|
80
|
+
], children: _jsx("span", { "data-docs-nav-title": "", children: item.title }) })) : (_jsx("span", { "data-docs-nav-title": "", children: item.title })), badge, _jsx(ChevronRightIcon, { size: 14, "aria-hidden": "true", mix: [
|
|
69
81
|
shrink(0),
|
|
70
82
|
mis("auto"),
|
|
71
83
|
transition("transform"),
|
|
@@ -25,8 +25,12 @@ export declare namespace DocsPager {
|
|
|
25
25
|
previous: string;
|
|
26
26
|
next: string;
|
|
27
27
|
}
|
|
28
|
+
/** When the pager's links prefetch their page, as `LinkButton` does. */
|
|
29
|
+
type Prefetch = "intent" | "viewport";
|
|
28
30
|
/** Props accepted by {@link DocsPager}. */
|
|
29
31
|
interface Props extends Omit<TagProps<"nav">, "children"> {
|
|
32
|
+
/** Prefetches each neighbour's page; unset prefetches none. */
|
|
33
|
+
prefetch?: Prefetch;
|
|
30
34
|
previous?: Entry | null;
|
|
31
35
|
next?: Entry | null;
|
|
32
36
|
/** Section of the page being read; a destination in another section names its own. */
|
|
@@ -41,6 +45,6 @@ export declare namespace DocsPager {
|
|
|
41
45
|
* @param handle Runtime handle carrying the pager's props.
|
|
42
46
|
* @returns The render function producing the pager's markup.
|
|
43
47
|
* @example
|
|
44
|
-
* <DocsPager {...findNeighbours(tree, path)} section="Guides" labels={{ nav: "Pagination", previous: "Previous", next: "Next" }} />
|
|
48
|
+
* <DocsPager {...findNeighbours(tree, path)} section="Guides" prefetch="intent" labels={{ nav: "Pagination", previous: "Previous", next: "Next" }} />
|
|
45
49
|
*/
|
|
46
50
|
export declare function DocsPager(handle: Handle<DocsPager.Props>): () => import("remix/component").RemixElement | null;
|
package/dist/docs/docs-pager.js
CHANGED
|
@@ -9,7 +9,7 @@ import { motionSafe } from "@sdxc/u/responsive";
|
|
|
9
9
|
import { is, minIs, p } from "@sdxc/u/size";
|
|
10
10
|
import { hover, when } from "@sdxc/u/state";
|
|
11
11
|
import { translateProperty } from "@sdxc/u/transform";
|
|
12
|
-
import { overflowWrap, text, textAlign, weight } from "@sdxc/u/typography";
|
|
12
|
+
import { overflowWrap, text, textAlign, textDecoration, weight } from "@sdxc/u/typography";
|
|
13
13
|
/** Container the pager measures; at 36rem of its own width a pair of cards sits side by side. */
|
|
14
14
|
const PAGER_CONTAINER = "ui-docs-pager";
|
|
15
15
|
/** Selector for a card's arrow, which hover and focus nudge toward the destination. */
|
|
@@ -21,11 +21,11 @@ const ARROW = '& [data-slot="docs-pager-arrow"]';
|
|
|
21
21
|
* @param handle Runtime handle carrying the pager's props.
|
|
22
22
|
* @returns The render function producing the pager's markup.
|
|
23
23
|
* @example
|
|
24
|
-
* <DocsPager {...findNeighbours(tree, path)} section="Guides" labels={{ nav: "Pagination", previous: "Previous", next: "Next" }} />
|
|
24
|
+
* <DocsPager {...findNeighbours(tree, path)} section="Guides" prefetch="intent" labels={{ nav: "Pagination", previous: "Previous", next: "Next" }} />
|
|
25
25
|
*/
|
|
26
26
|
export function DocsPager(handle) {
|
|
27
27
|
return () => {
|
|
28
|
-
let { previous, next, section, labels, mix, ...rest } = handle.props;
|
|
28
|
+
let { previous, next, section, labels, prefetch, mix, ...rest } = handle.props;
|
|
29
29
|
if (!previous && !next)
|
|
30
30
|
return null;
|
|
31
31
|
let paired = Boolean(previous && next);
|
|
@@ -42,7 +42,7 @@ export function DocsPager(handle) {
|
|
|
42
42
|
gridTemplateColumns: paired ? "repeat(2, minmax(0, 1fr))" : "minmax(0, 1fr)",
|
|
43
43
|
},
|
|
44
44
|
}),
|
|
45
|
-
], children: [previous ? (_jsx(DocsPagerCard, { entry: previous, label: labels.previous, direction: "previous", section: section })) : null, next ? (_jsx(DocsPagerCard, { entry: next, label: labels.next, direction: "next", section: section })) : null] }) }));
|
|
45
|
+
], children: [previous ? (_jsx(DocsPagerCard, { entry: previous, prefetch: prefetch, label: labels.previous, direction: "previous", section: section })) : null, next ? (_jsx(DocsPagerCard, { entry: next, label: labels.next, direction: "next", section: section, prefetch: prefetch })) : null] }) }));
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
@@ -52,12 +52,12 @@ export function DocsPager(handle) {
|
|
|
52
52
|
*/
|
|
53
53
|
function DocsPagerCard(handle) {
|
|
54
54
|
return () => {
|
|
55
|
-
let { direction, entry, label, section } = handle.props;
|
|
55
|
+
let { direction, entry, label, section, prefetch } = handle.props;
|
|
56
56
|
let isNext = direction === "next";
|
|
57
57
|
let Arrow = isNext ? ArrowRightIcon : ArrowLeftIcon;
|
|
58
58
|
let showSection = entry.section !== undefined && entry.section !== section;
|
|
59
59
|
let arrow = (_jsx(Arrow, { size: 14, "aria-hidden": "true", "data-slot": "docs-pager-arrow", mix: [transition("translate")] }));
|
|
60
|
-
return (_jsxs("a", { href: entry.href, rel: isNext ? "next" : "prev", "data-slot": "docs-pager-card", "data-direction": direction, mix: [
|
|
60
|
+
return (_jsxs("a", { href: entry.href, "data-rmx-prefetch": prefetch, rel: isNext ? "next" : "prev", "data-slot": "docs-pager-card", "data-direction": direction, mix: [
|
|
61
61
|
vstack({ gap: 1, align: isNext ? "end" : "start" }),
|
|
62
62
|
minIs(0),
|
|
63
63
|
p(4, 5),
|
|
@@ -65,6 +65,7 @@ function DocsPagerCard(handle) {
|
|
|
65
65
|
border({ color: "neutral.border", width: 1, style: "solid" }),
|
|
66
66
|
textAlign(isNext ? "end" : "start"),
|
|
67
67
|
overflowWrap("anywhere"),
|
|
68
|
+
textDecoration("none"),
|
|
68
69
|
transition("border-color, background-color"),
|
|
69
70
|
hover([border("brand.border"), bg("neutral.bg-tint")]),
|
|
70
71
|
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
@@ -12,11 +12,11 @@ import type { ElementProps, MixinFactory } from "remix/component";
|
|
|
12
12
|
* `aria-current="page"`. When the host holds an `<input>`, typing hides every `li` whose
|
|
13
13
|
* title misses the query, hides sections left empty, opens `<details>` groups holding a
|
|
14
14
|
* match, and shows `[data-docs-nav-empty]` when nothing matches; clearing the field restores
|
|
15
|
-
* every group's own open state.
|
|
16
|
-
* script
|
|
15
|
+
* every group's own open state. A page reload that resets the tree keeps the query applied,
|
|
16
|
+
* and the field's form stays on the page, which without script submits to the server instead.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
|
-
* <div data-docs-nav><
|
|
19
|
+
* <div data-docs-nav><form mix={[docsNavTools()]}><input type="search" /></form><nav>…</nav></div>
|
|
20
20
|
*/
|
|
21
21
|
export declare const docsNavTools: MixinFactory<HTMLElement, [], ElementProps>;
|
|
22
22
|
/**
|
|
@@ -7,17 +7,18 @@
|
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
8
8
|
*/
|
|
9
9
|
import { createMixin } from "remix/component";
|
|
10
|
+
import { filterWords, titleMatches } from "../utils/docs-filter.js";
|
|
10
11
|
import { revealInScroller } from "../utils/reveal-in-scroller.js";
|
|
11
12
|
/**
|
|
12
13
|
* Works on the closest `[data-docs-nav]` around its host. The current link is the one with
|
|
13
14
|
* `aria-current="page"`. When the host holds an `<input>`, typing hides every `li` whose
|
|
14
15
|
* title misses the query, hides sections left empty, opens `<details>` groups holding a
|
|
15
16
|
* match, and shows `[data-docs-nav-empty]` when nothing matches; clearing the field restores
|
|
16
|
-
* every group's own open state.
|
|
17
|
-
* script
|
|
17
|
+
* every group's own open state. A page reload that resets the tree keeps the query applied,
|
|
18
|
+
* and the field's form stays on the page, which without script submits to the server instead.
|
|
18
19
|
*
|
|
19
20
|
* @example
|
|
20
|
-
* <div data-docs-nav><
|
|
21
|
+
* <div data-docs-nav><form mix={[docsNavTools()]}><input type="search" /></form><nav>…</nav></div>
|
|
21
22
|
*/
|
|
22
23
|
export const docsNavTools = createMixin((handle) => {
|
|
23
24
|
let controller;
|
|
@@ -46,10 +47,41 @@ function enhance(host, signal) {
|
|
|
46
47
|
let input = host.querySelector("input");
|
|
47
48
|
if (!input)
|
|
48
49
|
return;
|
|
49
|
-
host.
|
|
50
|
-
let
|
|
51
|
-
let
|
|
52
|
-
|
|
50
|
+
host.addEventListener("submit", (event) => event.preventDefault(), { signal });
|
|
51
|
+
let ownState = new Map();
|
|
52
|
+
let snapshot = () => {
|
|
53
|
+
ownState = new Map([...nav.querySelectorAll("details")].map((group) => [group, ownOpen(group)]));
|
|
54
|
+
};
|
|
55
|
+
snapshot();
|
|
56
|
+
let observer = new MutationObserver((records) => {
|
|
57
|
+
if (!input.value || !records.some(isReset))
|
|
58
|
+
return;
|
|
59
|
+
snapshot();
|
|
60
|
+
filterDocsNav(nav, input.value, ownState);
|
|
61
|
+
observer.takeRecords();
|
|
62
|
+
});
|
|
63
|
+
let apply = () => {
|
|
64
|
+
filterDocsNav(nav, input.value, ownState);
|
|
65
|
+
observer.takeRecords();
|
|
66
|
+
};
|
|
67
|
+
observer.observe(nav, { subtree: true, childList: true, attributeFilter: ["hidden"] });
|
|
68
|
+
signal.addEventListener("abort", () => observer.disconnect());
|
|
69
|
+
input.addEventListener("input", apply, { signal });
|
|
70
|
+
if (input.value)
|
|
71
|
+
apply();
|
|
72
|
+
}
|
|
73
|
+
/** Whether `group` is open on its own, discounting a server render that opened it for a match. */
|
|
74
|
+
function ownOpen(group) {
|
|
75
|
+
return group.open && !group.hasAttribute("data-docs-nav-opened");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Whether `record` is a page reload putting the server's markup back: pages added or
|
|
79
|
+
* replaced, or a page the filter hid shown again. The filter's own writes only hide.
|
|
80
|
+
*/
|
|
81
|
+
function isReset(record) {
|
|
82
|
+
if (record.type === "childList")
|
|
83
|
+
return true;
|
|
84
|
+
return record.target instanceof HTMLElement && !record.target.hidden;
|
|
53
85
|
}
|
|
54
86
|
/**
|
|
55
87
|
* Shows the pages whose title holds every word of `query`, case- and accent-insensitive,
|
|
@@ -57,7 +89,7 @@ function enhance(host, signal) {
|
|
|
57
89
|
* its pages. An empty query restores the full tree and each group's own open state.
|
|
58
90
|
*/
|
|
59
91
|
export function filterDocsNav(nav, query, ownState) {
|
|
60
|
-
let words =
|
|
92
|
+
let words = filterWords(query);
|
|
61
93
|
let empty = nav.querySelector("[data-docs-nav-empty]");
|
|
62
94
|
let anyMatch = false;
|
|
63
95
|
for (let section of nav.querySelectorAll("[data-docs-nav-section]")) {
|
|
@@ -76,8 +108,8 @@ export function filterDocsNav(nav, query, ownState) {
|
|
|
76
108
|
}
|
|
77
109
|
/** Shows or hides `item` and its nested pages for `words`; reports whether it stays shown. */
|
|
78
110
|
function applyFilter(item, words) {
|
|
79
|
-
let title = item.querySelector(":scope > a, :scope > details > summary");
|
|
80
|
-
let own =
|
|
111
|
+
let title = item.querySelector(":scope > a [data-docs-nav-title], :scope > details > summary [data-docs-nav-title]");
|
|
112
|
+
let own = titleMatches(title?.textContent ?? "", words);
|
|
81
113
|
let children = item.querySelectorAll(":scope > details > ul > li, :scope > ul > li");
|
|
82
114
|
let childShown = false;
|
|
83
115
|
for (let child of children)
|
|
@@ -88,10 +120,3 @@ function applyFilter(item, words) {
|
|
|
88
120
|
item.hidden = !(own || childShown);
|
|
89
121
|
return !item.hidden;
|
|
90
122
|
}
|
|
91
|
-
/** Lower-cases `value` and strips diacritics, so "Configuracion" finds "Configuración". */
|
|
92
|
-
function normalize(value) {
|
|
93
|
-
return value
|
|
94
|
-
.normalize("NFD")
|
|
95
|
-
.replaceAll(/\p{Diacritic}/gu, "")
|
|
96
|
-
.toLowerCase();
|
|
97
|
-
}
|
package/dist/docs/next-steps.js
CHANGED
|
@@ -8,7 +8,7 @@ import { motionSafe } from "@sdxc/u/responsive";
|
|
|
8
8
|
import { m, minIs, p, pb } from "@sdxc/u/size";
|
|
9
9
|
import { hover, when } from "@sdxc/u/state";
|
|
10
10
|
import { translateProperty } from "@sdxc/u/transform";
|
|
11
|
-
import { leading, overflowWrap, pretty, text, weight } from "@sdxc/u/typography";
|
|
11
|
+
import { leading, overflowWrap, pretty, text, textDecoration, weight } from "@sdxc/u/typography";
|
|
12
12
|
import { readAmbientLevel, TAG_BY_LEVEL } from "../components/heading-scope.js";
|
|
13
13
|
/** Look {@link NextSteps} draws when `variant` is omitted. */
|
|
14
14
|
const DEFAULT_VARIANT = "cards";
|
|
@@ -31,7 +31,7 @@ export function NextSteps(handle) {
|
|
|
31
31
|
let resolvedVariant = variant ?? DEFAULT_VARIANT;
|
|
32
32
|
let Tag = TAG_BY_LEVEL[level ?? readAmbientLevel(handle) ?? DEFAULT_LEVEL];
|
|
33
33
|
let isCards = resolvedVariant === "cards";
|
|
34
|
-
return (_jsxs("section", { ...rest, "aria-labelledby": id, "aria-label": id ? undefined : title, "data-slot": "next-steps", "data-variant": resolvedVariant, mix: mergeMix([vstack({ gap: 4, align: "stretch" }), minIs(0)], mix), children: [_jsx(Tag, { id: id, "data-slot": "next-steps-title", mix: [m(0), text("lg"), weight("semibold"), fg("neutral.emphasis"), leading("snug")], children: title }), _jsx("ul", { "data-slot": "next-steps-list", mix: [
|
|
34
|
+
return (_jsxs("section", { ...rest, "aria-labelledby": id, "aria-label": id ? undefined : title, "data-slot": "next-steps", "data-variant": resolvedVariant, mix: mergeMix([vstack({ gap: 4, align: "stretch" }), minIs(0)], mix), children: [_jsx(Tag, { id: id, "data-slot": "next-steps-title", mix: [m(0), text("lg"), weight("semibold"), fg("neutral.emphasis"), leading("snug")], children: title }), _jsx("ul", { "data-slot": "next-steps-list", "data-not-typeset": "", mix: [
|
|
35
35
|
m(0),
|
|
36
36
|
p(0),
|
|
37
37
|
listStyle(),
|
|
@@ -63,6 +63,7 @@ function NextStepsLink(handle) {
|
|
|
63
63
|
return (_jsxs("a", { href: item.href, "data-slot": "next-steps-link", mix: [
|
|
64
64
|
vstack({ gap: 1, align: "stretch" }),
|
|
65
65
|
overflowWrap("anywhere"),
|
|
66
|
+
textDecoration("none"),
|
|
66
67
|
cards
|
|
67
68
|
? [
|
|
68
69
|
p(4),
|
|
@@ -68,7 +68,7 @@ export declare namespace PageActions {
|
|
|
68
68
|
export declare function PageActions(handle: Handle<PageActions.Props>): () => import("remix/component").RemixElement;
|
|
69
69
|
/**
|
|
70
70
|
* Client island: the main half of {@link PageActions}, loaded from the bare
|
|
71
|
-
* `@sdxc/ui/page-actions` specifier. It copies `href`'s body, swaps its glyph and label to
|
|
71
|
+
* `@sdxc/ui/docs/page-actions` specifier. It copies `href`'s body, swaps its glyph and label to
|
|
72
72
|
* the copied state for two seconds and announces it; before hydration it is inert.
|
|
73
73
|
*
|
|
74
74
|
* @example
|
|
@@ -34,13 +34,13 @@ export function PageActions(handle) {
|
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Client island: the main half of {@link PageActions}, loaded from the bare
|
|
37
|
-
* `@sdxc/ui/page-actions` specifier. It copies `href`'s body, swaps its glyph and label to
|
|
37
|
+
* `@sdxc/ui/docs/page-actions` specifier. It copies `href`'s body, swaps its glyph and label to
|
|
38
38
|
* the copied state for two seconds and announces it; before hydration it is inert.
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
41
|
* <PageActionsCopy href="/docs/install.md" copy="Copy page" copied="Copied" failed="Could not copy" />
|
|
42
42
|
*/
|
|
43
|
-
export const PageActionsCopy = clientEntry("@sdxc/ui/page-actions#PageActionsCopy", function PageActionsCopy(handle) {
|
|
43
|
+
export const PageActionsCopy = clientEntry("@sdxc/ui/docs/page-actions#PageActionsCopy", function PageActionsCopy(handle) {
|
|
44
44
|
return () => {
|
|
45
45
|
let { copied, copy, failed, href, joined = false } = handle.props;
|
|
46
46
|
return (_jsxs(Button, { type: "button", size: "sm", variant: "surface", color: "neutral", "data-slot": "page-actions-copy", mix: [
|
|
@@ -36,7 +36,7 @@ export declare namespace TableOfContents {
|
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Renders the in-page navigation, or nothing when the page has fewer than `minItems`
|
|
39
|
-
* headings. Load `@sdxc/ui/table-of-contents` in the browser entry. Headings that the
|
|
39
|
+
* headings. Load `@sdxc/ui/docs/table-of-contents` in the browser entry. Headings that the
|
|
40
40
|
* page's layout gives a `scroll-margin-top` set the line a section is read from.
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
@@ -27,7 +27,7 @@ const RING = 43.98;
|
|
|
27
27
|
const SETTLE = "cubic-bezier(0.32, 0.72, 0, 1)";
|
|
28
28
|
/**
|
|
29
29
|
* Renders the in-page navigation, or nothing when the page has fewer than `minItems`
|
|
30
|
-
* headings. Load `@sdxc/ui/table-of-contents` in the browser entry. Headings that the
|
|
30
|
+
* headings. Load `@sdxc/ui/docs/table-of-contents` in the browser entry. Headings that the
|
|
31
31
|
* page's layout gives a `scroll-margin-top` set the line a section is read from.
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
@@ -35,7 +35,7 @@ const SETTLE = "cubic-bezier(0.32, 0.72, 0, 1)";
|
|
|
35
35
|
* @example
|
|
36
36
|
* <TableOfContents items={anchors} label="On this page" layout="bar" />
|
|
37
37
|
*/
|
|
38
|
-
export const TableOfContents = clientEntry("@sdxc/ui/table-of-contents#TableOfContents", function TableOfContents(handle) {
|
|
38
|
+
export const TableOfContents = clientEntry("@sdxc/ui/docs/table-of-contents#TableOfContents", function TableOfContents(handle) {
|
|
39
39
|
return () => {
|
|
40
40
|
let { items, label, layout = "rail", minItems = TOC_MIN_ITEMS } = handle.props;
|
|
41
41
|
if (items.length < minItems)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a docs sidebar's title filter matches pages, shared by the server, which draws a
|
|
3
|
+
* filtered tree for a reader without script, and the browser, which filters as they type,
|
|
4
|
+
* so both keep exactly the same pages for the same query.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { DocsTree } from "./docs-tree.js";
|
|
10
|
+
/** What a query keeps of a tree: the items left shown and the groups opened around a match. */
|
|
11
|
+
export interface DocsTreeMatches {
|
|
12
|
+
shown: Set<DocsTree.Item>;
|
|
13
|
+
opened: Set<DocsTree.Item>;
|
|
14
|
+
}
|
|
15
|
+
/** Lower-cases `value` and strips diacritics, so "Configuracion" finds "Configuración". */
|
|
16
|
+
export declare function normalizeFilterText(value: string): string;
|
|
17
|
+
/** The normalized words of `query`; an empty list keeps every page. */
|
|
18
|
+
export declare function filterWords(query: string): string[];
|
|
19
|
+
/** Whether `title` holds every word, case- and accent-insensitive. */
|
|
20
|
+
export declare function titleMatches(title: string, words: string[]): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The items of `tree` whose title holds every word of `query`, with the groups that contain
|
|
23
|
+
* them; a group whose own title matches keeps all its pages. Returns `null` for a query with
|
|
24
|
+
* no words, which keeps the whole tree as drawn.
|
|
25
|
+
*/
|
|
26
|
+
export declare function matchDocsTree(tree: DocsTree, query: string): DocsTreeMatches | null;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a docs sidebar's title filter matches pages, shared by the server, which draws a
|
|
3
|
+
* filtered tree for a reader without script, and the browser, which filters as they type,
|
|
4
|
+
* so both keep exactly the same pages for the same query.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** Lower-cases `value` and strips diacritics, so "Configuracion" finds "Configuración". */
|
|
10
|
+
export function normalizeFilterText(value) {
|
|
11
|
+
return value
|
|
12
|
+
.normalize("NFD")
|
|
13
|
+
.replaceAll(/\p{Diacritic}/gu, "")
|
|
14
|
+
.toLowerCase();
|
|
15
|
+
}
|
|
16
|
+
/** The normalized words of `query`; an empty list keeps every page. */
|
|
17
|
+
export function filterWords(query) {
|
|
18
|
+
return normalizeFilterText(query).split(/\s+/).filter(Boolean);
|
|
19
|
+
}
|
|
20
|
+
/** Whether `title` holds every word, case- and accent-insensitive. */
|
|
21
|
+
export function titleMatches(title, words) {
|
|
22
|
+
let normalized = normalizeFilterText(title);
|
|
23
|
+
return words.every((word) => normalized.includes(word));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The items of `tree` whose title holds every word of `query`, with the groups that contain
|
|
27
|
+
* them; a group whose own title matches keeps all its pages. Returns `null` for a query with
|
|
28
|
+
* no words, which keeps the whole tree as drawn.
|
|
29
|
+
*/
|
|
30
|
+
export function matchDocsTree(tree, query) {
|
|
31
|
+
let words = filterWords(query);
|
|
32
|
+
if (words.length === 0)
|
|
33
|
+
return null;
|
|
34
|
+
let matches = { shown: new Set(), opened: new Set() };
|
|
35
|
+
for (let section of tree.sections) {
|
|
36
|
+
for (let item of section.items)
|
|
37
|
+
collect(item, words, matches);
|
|
38
|
+
}
|
|
39
|
+
return matches;
|
|
40
|
+
}
|
|
41
|
+
/** Adds `item` and its matching pages to `matches`; reports whether it stays shown. */
|
|
42
|
+
function collect(item, words, matches) {
|
|
43
|
+
let own = titleMatches(item.title, words);
|
|
44
|
+
let childShown = false;
|
|
45
|
+
for (let child of item.items ?? []) {
|
|
46
|
+
childShown = collect(child, own ? [] : words, matches) || childShown;
|
|
47
|
+
}
|
|
48
|
+
if (childShown && words.length > 0)
|
|
49
|
+
matches.opened.add(item);
|
|
50
|
+
if (own || childShown)
|
|
51
|
+
matches.shown.add(item);
|
|
52
|
+
return own || childShown;
|
|
53
|
+
}
|