@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
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/component/jsx-runtime";
|
|
2
|
-
import { flex, flexCol, gap } from "@sdxc/u/layout";
|
|
2
|
+
import { flex, flexCol, gap, vstack } from "@sdxc/u/layout";
|
|
3
|
+
import { clientEntry } from "remix/component";
|
|
4
|
+
import { confirmPhrase } from "../mixins/confirm-phrase.js";
|
|
3
5
|
import { AlertDialog } from "./alert-dialog.js";
|
|
6
|
+
import { Input } from "./input.js";
|
|
7
|
+
import { Label } from "./label.js";
|
|
4
8
|
/** Semantic color role {@link Confirm} falls back to when `color` is omitted. */
|
|
5
9
|
const DEFAULT_COLOR = "danger";
|
|
6
10
|
/** HTTP method a submitting {@link Confirm} falls back to when `form.method` is omitted. */
|
|
@@ -11,10 +15,12 @@ const DEFAULT_METHOD = "post";
|
|
|
11
15
|
* without this the header and footer would lose their spacing.
|
|
12
16
|
*/
|
|
13
17
|
const PANEL_GAP = 6;
|
|
18
|
+
/** Characters a `pattern` (compiled with the `v` flag) reads as syntax, escaped to match literally. */
|
|
19
|
+
const PATTERN_SYNTAX = /[\\^$.*+?()[\]{}|/]/g;
|
|
14
20
|
/**
|
|
15
21
|
* Composes {@link AlertDialog} into a confirmation prompt, wiring title and
|
|
16
|
-
* description ids to `aria-labelledby`/`aria-describedby`.
|
|
17
|
-
*
|
|
22
|
+
* description ids to `aria-labelledby`/`aria-describedby`. Focus opens on Cancel, or
|
|
23
|
+
* on the phrase field with `typeToConfirm`; pass `form` to submit a real `<form>`.
|
|
18
24
|
*
|
|
19
25
|
* @param handle Runtime handle carrying the panel's props and this instance's stable identifier.
|
|
20
26
|
* @returns The render function producing the confirmation prompt's markup.
|
|
@@ -43,14 +49,47 @@ const PANEL_GAP = 6;
|
|
|
43
49
|
* cancelLabel={t("actions.cancel")}
|
|
44
50
|
* form={{ action: revokeUrl, fields: <input type="hidden" name="csrf" value={token} /> }}
|
|
45
51
|
* />
|
|
52
|
+
* @example
|
|
53
|
+
* <Confirm
|
|
54
|
+
* id="delete-team"
|
|
55
|
+
* title="Delete team?"
|
|
56
|
+
* description="Acme, its 12 monitors and their history are deleted."
|
|
57
|
+
* confirmLabel="Delete team"
|
|
58
|
+
* cancelLabel="Cancel"
|
|
59
|
+
* typeToConfirm={{ value: "acme", label: 'Type "acme" to confirm', name: "confirmation" }}
|
|
60
|
+
* form={{ action: "/teams/acme/delete" }}
|
|
61
|
+
* />
|
|
46
62
|
*/
|
|
47
63
|
export function Confirm(handle) {
|
|
48
64
|
return () => {
|
|
49
|
-
let { id, title, description, confirmLabel, cancelLabel, color, form, "aria-labelledby": ariaLabelledByProp, "aria-describedby": ariaDescribedByProp, parts, mix, ...rest } = handle.props;
|
|
65
|
+
let { id, title, description, confirmLabel, cancelLabel, color, form, typeToConfirm, "aria-labelledby": ariaLabelledByProp, "aria-describedby": ariaDescribedByProp, parts, mix, ...rest } = handle.props;
|
|
50
66
|
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
51
67
|
let titleId = `${handle.id}-title`;
|
|
52
68
|
let descriptionId = description ? `${handle.id}-description` : undefined;
|
|
53
|
-
let content = (_jsxs(_Fragment, { children: [_jsxs(AlertDialog.Header, { mix: parts?.header, children: [_jsx(AlertDialog.Title, { id: titleId, mix: parts?.title, children: title }), description ? (_jsx(AlertDialog.Description, { id: descriptionId, mix: parts?.description, children: description })) : null] }), _jsxs(AlertDialog.Footer, { mix: parts?.footer, children: [_jsx(AlertDialog.Cancel, { commandfor: id, mix: parts?.cancel, children: cancelLabel }), _jsx(AlertDialog.Action, { type: form ? "submit" : undefined, commandfor: form ? undefined : id, color: resolvedColor, mix: parts?.action, children: confirmLabel })] })] }));
|
|
69
|
+
let content = (_jsxs(_Fragment, { children: [_jsxs(AlertDialog.Header, { mix: parts?.header, children: [_jsx(AlertDialog.Title, { id: titleId, mix: parts?.title, children: title }), description ? (_jsx(AlertDialog.Description, { id: descriptionId, mix: parts?.description, children: description })) : null] }), typeToConfirm ? (_jsx(ConfirmPhrase, { id: `${handle.id}-phrase`, value: typeToConfirm.value, label: typeToConfirm.label, name: typeToConfirm.name })) : null, _jsxs(AlertDialog.Footer, { mix: parts?.footer, children: [_jsx(AlertDialog.Cancel, { commandfor: id, autofocus: typeToConfirm ? undefined : true, mix: parts?.cancel, children: cancelLabel }), _jsx(AlertDialog.Action, { "data-confirm-action": "", type: form ? "submit" : undefined, commandfor: form ? undefined : id, color: resolvedColor, mix: parts?.action, children: confirmLabel })] })] }));
|
|
54
70
|
return (_jsx(AlertDialog, { ...rest, id: id, "aria-labelledby": ariaLabelledByProp ?? titleId, "aria-describedby": ariaDescribedByProp ?? descriptionId, mix: mix, children: form ? (_jsxs("form", { action: form.action, method: form.method ?? DEFAULT_METHOD, mix: [flex(), flexCol(), gap(PANEL_GAP), parts?.form], children: [form.fields, content] })) : (content) }));
|
|
55
71
|
};
|
|
56
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Turns a phrase into a `pattern` that matches only that phrase.
|
|
75
|
+
*
|
|
76
|
+
* @param value The phrase to match literally.
|
|
77
|
+
* @returns The phrase with every pattern syntax character escaped.
|
|
78
|
+
*/
|
|
79
|
+
function escapePattern(value) {
|
|
80
|
+
return value.replace(PATTERN_SYNTAX, "\\$&");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Client island: the field a type-to-confirm prompt holds. It disables the dialog's
|
|
84
|
+
* confirming control until the typed text matches and clears itself when the dialog
|
|
85
|
+
* closes, so every opening starts locked; without script, `pattern` blocks the submit.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* <ConfirmPhrase id="delete-team-phrase" value="acme" label='Type "acme" to confirm' />
|
|
89
|
+
*/
|
|
90
|
+
export const ConfirmPhrase = clientEntry("@sdxc/ui/confirm#ConfirmPhrase", function ConfirmPhrase(handle) {
|
|
91
|
+
return () => {
|
|
92
|
+
let { id, label, name, value } = handle.props;
|
|
93
|
+
return (_jsxs("div", { "data-slot": "confirm-phrase", mix: [vstack({ gap: 1.5, align: "stretch" })], children: [_jsx(Label, { htmlFor: id, children: label }), _jsx(Input, { id: id, name: name, required: true, autofocus: true, autocomplete: "off", spellcheck: false, pattern: escapePattern(value), mix: [confirmPhrase(value)] })] }));
|
|
94
|
+
};
|
|
95
|
+
});
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @copyright Sergio Xalambrí 2026
|
|
11
11
|
*/
|
|
12
12
|
import type { Handle, Props as TagProps } from "remix/component";
|
|
13
|
+
import type { RemixNode } from "remix/component";
|
|
13
14
|
/**
|
|
14
15
|
* Prop types for {@link Group}.
|
|
15
16
|
*/
|
|
@@ -21,6 +22,16 @@ export declare namespace Group {
|
|
|
21
22
|
*/
|
|
22
23
|
interface Props extends TagProps<"div"> {
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Native `<label>` attributes plus `mix`. Set `htmlFor` to the control's `id` so a
|
|
27
|
+
* click on the addon focuses it, and `id` to list the addon in the control's
|
|
28
|
+
* `aria-describedby`; give the control its name through `aria-label` or
|
|
29
|
+
* `aria-labelledby`, which keeps the addon's text out of that name.
|
|
30
|
+
*/
|
|
31
|
+
interface TextProps extends TagProps<"label"> {
|
|
32
|
+
/** The addon's static text: a currency, a unit, a domain. */
|
|
33
|
+
children: RemixNode;
|
|
34
|
+
}
|
|
24
35
|
}
|
|
25
36
|
/**
|
|
26
37
|
* Lays children out in a centered flex row with no border, background, or gap, joining
|
|
@@ -43,3 +54,6 @@ export declare namespace Group {
|
|
|
43
54
|
* </Group>
|
|
44
55
|
*/
|
|
45
56
|
export declare function Group(handle: Handle<Group.Props>): () => import("remix/component").RemixElement;
|
|
57
|
+
export declare namespace Group {
|
|
58
|
+
var Text: (handle: Handle<Group.TextProps>) => () => import("remix/component").RemixElement;
|
|
59
|
+
}
|
package/dist/components/group.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "remix/component/jsx-runtime";
|
|
2
|
-
import { outlineColor } from "@sdxc/u/color";
|
|
3
|
-
import {
|
|
4
|
-
import { mergeMix } from "@sdxc/u/general";
|
|
5
|
-
import { flex, items } from "@sdxc/u/layout";
|
|
6
|
-
import { mis } from "@sdxc/u/size";
|
|
2
|
+
import { bg, border, fg, outline, outlineColor } from "@sdxc/u/color";
|
|
3
|
+
import { opacity, rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, mergeMix, raw } from "@sdxc/u/general";
|
|
5
|
+
import { flex, grow, items, shrink } from "@sdxc/u/layout";
|
|
6
|
+
import { bs, minIs, mis, pi } from "@sdxc/u/size";
|
|
7
7
|
import { z } from "@sdxc/u/stacking";
|
|
8
8
|
import { when } from "@sdxc/u/state";
|
|
9
|
+
import { nowrap, text } from "@sdxc/u/typography";
|
|
9
10
|
import { attrs } from "remix/component";
|
|
10
11
|
/**
|
|
11
12
|
* Default ARIA role applied through {@link attrs} unless a consumer
|
|
@@ -13,6 +14,10 @@ import { attrs } from "remix/component";
|
|
|
13
14
|
* `"presentation"` for purely visual grouping.
|
|
14
15
|
*/
|
|
15
16
|
const DEFAULT_ROLE = "group";
|
|
17
|
+
/** A group holding a {@link Group.Text} addon, which makes it one field drawing its own rings. */
|
|
18
|
+
const WITH_ADDON = '&:has(> [data-slot="group-text"])';
|
|
19
|
+
/** A control whose value fails validation, by the platform's own check or the field's `aria-invalid`. */
|
|
20
|
+
const INVALID_CONTROL = ':is(:user-invalid, [aria-invalid="true"])';
|
|
16
21
|
/**
|
|
17
22
|
* Lays children out in a centered flex row with no border, background, or gap, joining
|
|
18
23
|
* their edges into one shape: only the cluster's outer corners stay round, and the seam
|
|
@@ -44,16 +49,20 @@ export function Group(handle) {
|
|
|
44
49
|
* The controls compose into one shape, so the cluster keeps the rounding on
|
|
45
50
|
* its own outer corners and the seam where two of them meet is drawn once; the
|
|
46
51
|
* last control before a trailing `<link rel="prefetch">` hint keeps its corners.
|
|
52
|
+
* The square corners are `!important` so they hold over every child's own
|
|
53
|
+
* rounding, whichever reached the page first.
|
|
47
54
|
*/
|
|
48
55
|
when("& > *:not(:first-child)", [
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
raw({
|
|
57
|
+
borderStartStartRadius: "0 !important",
|
|
58
|
+
borderEndStartRadius: "0 !important",
|
|
59
|
+
}),
|
|
51
60
|
mis("-1px"),
|
|
52
61
|
]),
|
|
53
|
-
when("& > *:has(~ :not(link))",
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
when("& > *:has(~ :not(link))", raw({
|
|
63
|
+
borderStartEndRadius: "0 !important",
|
|
64
|
+
borderEndEndRadius: "0 !important",
|
|
65
|
+
})),
|
|
57
66
|
/**
|
|
58
67
|
* Focus shows on the control holding it, naming which control has it where a ring
|
|
59
68
|
* around the cluster names only the group. That control is raised so its ring
|
|
@@ -61,6 +70,52 @@ export function Group(handle) {
|
|
|
61
70
|
*/
|
|
62
71
|
when("& > *:focus-visible", z(1)),
|
|
63
72
|
when('&[aria-invalid="true"] > *:focus-visible', outlineColor("danger")),
|
|
73
|
+
/**
|
|
74
|
+
* With an addon the cluster is one field, so it carries the field's rounding and
|
|
75
|
+
* rings, and the control takes the width the addons leave, down to nothing.
|
|
76
|
+
*/
|
|
77
|
+
when(WITH_ADDON, rounded("md")),
|
|
78
|
+
when(`${WITH_ADDON} > :not([data-slot="group-text"])`, [grow(), minIs(0)]),
|
|
79
|
+
when(`${WITH_ADDON}:has(> :focus-visible)`, outline({ color: "brand.ring", offset: 2 })),
|
|
80
|
+
when(`${WITH_ADDON}:has(> [data-color="success"]:focus-visible)`, outlineColor("success.ring")),
|
|
81
|
+
when(`${WITH_ADDON}:has(> [data-color="warning"]:focus-visible)`, outlineColor("warning.ring")),
|
|
82
|
+
when(`${WITH_ADDON}:has(> [data-color="danger"]:focus-visible)`, outlineColor("danger.ring")),
|
|
83
|
+
when(`${WITH_ADDON}:has(> ${INVALID_CONTROL})`, outline({ color: "danger.ring", offset: 2 })),
|
|
64
84
|
], mix) }));
|
|
65
85
|
};
|
|
66
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Renders a static addon joined to the control beside it — a currency, a unit, a domain —
|
|
89
|
+
* as a muted, bordered `<label>` that keeps its text on one line. The `<label>` makes a
|
|
90
|
+
* click on the addon focus the control; it dims with a disabled control and takes the
|
|
91
|
+
* danger border with an invalid one, and its group draws the field's focus and invalid rings.
|
|
92
|
+
*
|
|
93
|
+
* @param handle Runtime handle carrying the host `<label>`'s props.
|
|
94
|
+
* @returns The render function producing the addon's markup.
|
|
95
|
+
* @example
|
|
96
|
+
* <Group>
|
|
97
|
+
* <Group.Text id="slug-prefix" htmlFor="slug">pulse.dev/</Group.Text>
|
|
98
|
+
* <Input id="slug" aria-labelledby="slug-label" aria-describedby="slug-prefix" />
|
|
99
|
+
* </Group>
|
|
100
|
+
*/
|
|
101
|
+
Group.Text = function GroupText(handle) {
|
|
102
|
+
return () => {
|
|
103
|
+
let { mix, ...rest } = handle.props;
|
|
104
|
+
return (_jsx("label", { ...rest, "data-slot": "group-text", mix: mergeMix([
|
|
105
|
+
flex(),
|
|
106
|
+
items("center"),
|
|
107
|
+
shrink(0),
|
|
108
|
+
nowrap(),
|
|
109
|
+
bs(10),
|
|
110
|
+
pi(3),
|
|
111
|
+
rounded("md"),
|
|
112
|
+
border({ color: "neutral", width: 1 }),
|
|
113
|
+
bg("neutral.tint"),
|
|
114
|
+
fg("neutral.muted"),
|
|
115
|
+
text("sm"),
|
|
116
|
+
cursor("text"),
|
|
117
|
+
when(`${INVALID_CONTROL} ~ &, &:has(~ ${INVALID_CONTROL})`, border("danger")),
|
|
118
|
+
when(":disabled ~ &, &:has(~ :disabled)", [opacity(50), cursor("not-allowed")]),
|
|
119
|
+
], mix) }));
|
|
120
|
+
};
|
|
121
|
+
};
|
|
@@ -85,3 +85,8 @@ export * from "./toggle-button.js";
|
|
|
85
85
|
export * from "./tooltip.js";
|
|
86
86
|
export * from "./typeset.js";
|
|
87
87
|
export * from "./youtube-embed.js";
|
|
88
|
+
export * from "./banner.js";
|
|
89
|
+
export * from "./property-list.js";
|
|
90
|
+
export * from "./relative-time.js";
|
|
91
|
+
export * from "./status-dot.js";
|
|
92
|
+
export * from "./timeline.js";
|
package/dist/components/index.js
CHANGED
|
@@ -85,3 +85,8 @@ export * from "./toggle-button.js";
|
|
|
85
85
|
export * from "./tooltip.js";
|
|
86
86
|
export * from "./typeset.js";
|
|
87
87
|
export * from "./youtube-embed.js";
|
|
88
|
+
export * from "./banner.js";
|
|
89
|
+
export * from "./property-list.js";
|
|
90
|
+
export * from "./relative-time.js";
|
|
91
|
+
export * from "./status-dot.js";
|
|
92
|
+
export * from "./timeline.js";
|
package/dist/components/input.js
CHANGED
|
@@ -9,6 +9,10 @@ import { text } from "@sdxc/u/typography";
|
|
|
9
9
|
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
10
10
|
/** Semantic color role {@link Input} falls back to when `color` is omitted. */
|
|
11
11
|
const DEFAULT_COLOR = "neutral";
|
|
12
|
+
/** An input joined to a `Group.Text` addon, whose group draws the field's focus and invalid rings. */
|
|
13
|
+
const BESIDE_ADDON = ':is([data-slot="group-text"] ~ *, :has(~ [data-slot="group-text"]))';
|
|
14
|
+
/** An input standing on its own, drawing its focus and invalid rings itself. */
|
|
15
|
+
const STANDALONE = `:not(${BESIDE_ADDON})`;
|
|
12
16
|
/**
|
|
13
17
|
* Renders a native `<input>` host colored via `data-color`, with hover,
|
|
14
18
|
* focus, and disabled states driven by native pseudo-classes; `[aria-invalid="true"]`
|
|
@@ -58,14 +62,16 @@ export function Input(handle) {
|
|
|
58
62
|
* cascade layer it resets the ring's color, width and style at once.
|
|
59
63
|
*/
|
|
60
64
|
when("&:focus:not(:focus-visible)", outline("none")),
|
|
61
|
-
focusVisible(
|
|
62
|
-
|
|
65
|
+
focusVisible(border("neutral.border-hover")),
|
|
66
|
+
when(`&:focus-visible${STANDALONE}`, [
|
|
63
67
|
outline({ color: "brand.ring", offset: 2 }),
|
|
64
68
|
when('&[data-color="success"]', outline("success.ring")),
|
|
65
69
|
when('&[data-color="warning"]', outline("warning.ring")),
|
|
66
70
|
when('&[data-color="danger"]', outline("danger.ring")),
|
|
67
71
|
]),
|
|
68
|
-
|
|
72
|
+
when(`&:focus${BESIDE_ADDON}`, outline("none")),
|
|
73
|
+
invalid(border("danger")),
|
|
74
|
+
when(`&:is(:user-invalid, [aria-invalid="true"])${STANDALONE}`, outline({ color: "danger.ring", offset: 2 })),
|
|
69
75
|
when("&:disabled", [opacity(50), bg("neutral.bg-tint-hover"), cursor("not-allowed")]),
|
|
70
76
|
text("sm"),
|
|
71
77
|
], mix) }));
|
|
@@ -142,7 +142,13 @@ export function LinkButton(handle) {
|
|
|
142
142
|
active([bg("danger.bg-solid-pressed"), border("danger.bg-solid-pressed")]),
|
|
143
143
|
]),
|
|
144
144
|
]),
|
|
145
|
+
/**
|
|
146
|
+
* Each variant's resting fill sits in the same block as its hover and active
|
|
147
|
+
* fills, so the state rules win on specificity and keep winning whatever order
|
|
148
|
+
* a page first uses the classes in.
|
|
149
|
+
*/
|
|
145
150
|
data("variant", "outline", [
|
|
151
|
+
bg("transparent"),
|
|
146
152
|
data("color", "brand", [
|
|
147
153
|
border("brand"),
|
|
148
154
|
fg("brand"),
|
|
@@ -174,8 +180,9 @@ export function LinkButton(handle) {
|
|
|
174
180
|
active(bg("danger.bg-tint-hover")),
|
|
175
181
|
]),
|
|
176
182
|
]),
|
|
177
|
-
data("variant", "outline", bg("transparent")),
|
|
178
183
|
data("variant", "ghost", [
|
|
184
|
+
bg("transparent"),
|
|
185
|
+
border("transparent"),
|
|
179
186
|
data("color", "brand", [
|
|
180
187
|
fg("brand"),
|
|
181
188
|
hover(bg("brand.tint")),
|
|
@@ -202,7 +209,6 @@ export function LinkButton(handle) {
|
|
|
202
209
|
active(bg("danger.bg-tint-hover")),
|
|
203
210
|
]),
|
|
204
211
|
]),
|
|
205
|
-
data("variant", "ghost", [bg("transparent"), border("transparent")]),
|
|
206
212
|
data("variant", "surface", surfaceControl()),
|
|
207
213
|
when('&[aria-disabled="true"]', opacity(50)),
|
|
208
214
|
when('&[aria-disabled="true"]', [cursor("not-allowed"), pointerEvents()]),
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Label/value rows for one record's properties, as a `<dl>`: a fixed label column beside
|
|
3
|
+
* each value that stacks once its container narrows, empty values named in words, and an
|
|
4
|
+
* editable row whose value opens an anchored native popover holding the app's own form.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Prop types for {@link PropertyList} and its compound parts.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace PropertyList {
|
|
14
|
+
/**
|
|
15
|
+
* `"rows"` sets each label beside its value in a ruled-free column; `"tiles"` sets each
|
|
16
|
+
* property in its own bordered tile, two to a row, for a record's headline figures.
|
|
17
|
+
*/
|
|
18
|
+
type Variant = "rows" | "tiles";
|
|
19
|
+
/** What {@link PropertyList} shares with its items. */
|
|
20
|
+
interface Context {
|
|
21
|
+
variant: Variant;
|
|
22
|
+
}
|
|
23
|
+
/** Every native `<dl>` attribute, plus the layout variant. */
|
|
24
|
+
interface Props extends TagProps<"dl"> {
|
|
25
|
+
/** @default {@link DEFAULT_VARIANT} */
|
|
26
|
+
variant?: Variant;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Makes a row editable in place: its value becomes a button that opens a popover
|
|
30
|
+
* anchored under it, holding whatever form the app renders as `content`.
|
|
31
|
+
*/
|
|
32
|
+
interface Edit {
|
|
33
|
+
/** Id of the popover, which the value button targets. */
|
|
34
|
+
id: string;
|
|
35
|
+
/** What the button does, read before the current value, such as "Edit assignee". */
|
|
36
|
+
label: string;
|
|
37
|
+
/** The popover's content: the app's form, its described options and its submit. */
|
|
38
|
+
content: RemixNode;
|
|
39
|
+
}
|
|
40
|
+
/** Every native `<div>` attribute the row's group accepts, plus its label and value. */
|
|
41
|
+
interface ItemProps extends Omit<TagProps<"div">, "children"> {
|
|
42
|
+
/** The property's name, rendered in the `<dt>`. */
|
|
43
|
+
label: RemixNode;
|
|
44
|
+
/**
|
|
45
|
+
* What the row says when `children` is empty, such as "None" or "No reviews".
|
|
46
|
+
*
|
|
47
|
+
* @default "—"
|
|
48
|
+
*/
|
|
49
|
+
empty?: RemixNode;
|
|
50
|
+
/** Turns the value into a button opening an anchored edit popover. */
|
|
51
|
+
edit?: Edit;
|
|
52
|
+
/** The value: text, a link, a badge, an avatar with a name. */
|
|
53
|
+
children?: RemixNode;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Renders the `<dl>`. Each item is a `<div>` grouping one `<dt>` and one `<dd>`, which
|
|
58
|
+
* keeps the label/value pairing in the accessibility tree; the list measures itself as a
|
|
59
|
+
* container, so rows stack in a narrow side pane at any viewport width.
|
|
60
|
+
*
|
|
61
|
+
* @param handle Runtime handle carrying the `<dl>`'s props and providing the variant.
|
|
62
|
+
* @returns The render function producing the list's markup.
|
|
63
|
+
* @example
|
|
64
|
+
* <PropertyList>
|
|
65
|
+
* <PropertyList.Item label="Status"><Badge color="success">Up</Badge></PropertyList.Item>
|
|
66
|
+
* <PropertyList.Item label="Reviewers" empty="No reviews" />
|
|
67
|
+
* </PropertyList>
|
|
68
|
+
* @example
|
|
69
|
+
* <PropertyList variant="tiles">
|
|
70
|
+
* <PropertyList.Item label="Uptime">99.98%</PropertyList.Item>
|
|
71
|
+
* </PropertyList>
|
|
72
|
+
*/
|
|
73
|
+
export declare function PropertyList(handle: Handle<PropertyList.Props, PropertyList.Context>): () => import("remix/component").RemixElement;
|
|
74
|
+
export declare namespace PropertyList {
|
|
75
|
+
var Item: (handle: Handle<PropertyList.ItemProps>) => () => import("remix/component").RemixElement;
|
|
76
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/component/jsx-runtime";
|
|
2
|
+
import { ChevronDownIcon } from "@sdxc/icons";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { bg, border, fg, outline } from "@sdxc/u/color";
|
|
5
|
+
import { rounded, transition } from "@sdxc/u/effects";
|
|
6
|
+
import { cursor, raw, mergeMix } from "@sdxc/u/general";
|
|
7
|
+
import { container, flex, gap, grid, items, justify, shrink, vstack } from "@sdxc/u/layout";
|
|
8
|
+
import { is, m, minBs, minIs, p, pb, pi } from "@sdxc/u/size";
|
|
9
|
+
import { focusVisible, hover } from "@sdxc/u/state";
|
|
10
|
+
import { leading, tabularNums, text, textAlign, weight } from "@sdxc/u/typography";
|
|
11
|
+
import { Popover } from "./popover.js";
|
|
12
|
+
/** Container the list names, so its rows stack against the list's own width. */
|
|
13
|
+
const PROPERTY_LIST_CONTAINER = "ui-property-list";
|
|
14
|
+
/** Layout a list takes when `variant` is left unset. */
|
|
15
|
+
const DEFAULT_VARIANT = "rows";
|
|
16
|
+
/** Shown for a value the caller leaves empty and names no empty text for. */
|
|
17
|
+
const DEFAULT_EMPTY = "—";
|
|
18
|
+
/**
|
|
19
|
+
* Whether `node` renders nothing a reader would see, which is when the row shows its
|
|
20
|
+
* named empty value instead.
|
|
21
|
+
*
|
|
22
|
+
* @param node The value a row was given.
|
|
23
|
+
* @returns `true` for `null`, `undefined`, `false`, `""` and a list of those.
|
|
24
|
+
*/
|
|
25
|
+
function isEmptyValue(node) {
|
|
26
|
+
if (node === null || node === undefined || node === false || node === "")
|
|
27
|
+
return true;
|
|
28
|
+
if (Array.isArray(node))
|
|
29
|
+
return node.every((child) => isEmptyValue(child));
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders the `<dl>`. Each item is a `<div>` grouping one `<dt>` and one `<dd>`, which
|
|
34
|
+
* keeps the label/value pairing in the accessibility tree; the list measures itself as a
|
|
35
|
+
* container, so rows stack in a narrow side pane at any viewport width.
|
|
36
|
+
*
|
|
37
|
+
* @param handle Runtime handle carrying the `<dl>`'s props and providing the variant.
|
|
38
|
+
* @returns The render function producing the list's markup.
|
|
39
|
+
* @example
|
|
40
|
+
* <PropertyList>
|
|
41
|
+
* <PropertyList.Item label="Status"><Badge color="success">Up</Badge></PropertyList.Item>
|
|
42
|
+
* <PropertyList.Item label="Reviewers" empty="No reviews" />
|
|
43
|
+
* </PropertyList>
|
|
44
|
+
* @example
|
|
45
|
+
* <PropertyList variant="tiles">
|
|
46
|
+
* <PropertyList.Item label="Uptime">99.98%</PropertyList.Item>
|
|
47
|
+
* </PropertyList>
|
|
48
|
+
*/
|
|
49
|
+
export function PropertyList(handle) {
|
|
50
|
+
return () => {
|
|
51
|
+
let { variant, mix, ...rest } = handle.props;
|
|
52
|
+
let resolved = variant ?? DEFAULT_VARIANT;
|
|
53
|
+
handle.context.set({ variant: resolved });
|
|
54
|
+
return (_jsx("dl", { "data-slot": "property-list", "data-variant": resolved, ...rest, mix: mergeMix([
|
|
55
|
+
m(0),
|
|
56
|
+
is("100%"),
|
|
57
|
+
container(PROPERTY_LIST_CONTAINER),
|
|
58
|
+
text("sm"),
|
|
59
|
+
resolved === "tiles"
|
|
60
|
+
? [
|
|
61
|
+
grid(),
|
|
62
|
+
gap(2),
|
|
63
|
+
/**
|
|
64
|
+
* Each tile claims at least half the row, so two fit side by side once
|
|
65
|
+
* both reach 9rem and a narrower list falls back to one column.
|
|
66
|
+
*/
|
|
67
|
+
raw({
|
|
68
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(max(9rem, calc(50% - 0.25rem)), 1fr))",
|
|
69
|
+
}),
|
|
70
|
+
]
|
|
71
|
+
: vstack({ gap: 0 }),
|
|
72
|
+
], mix) }));
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Renders one property. In the rows variant the label column holds
|
|
77
|
+
* `--ui-property-list-label-width` (9rem) from a 22rem container up and stacks above the
|
|
78
|
+
* value below it; a value-less row names its emptiness in muted text.
|
|
79
|
+
*
|
|
80
|
+
* @param handle Runtime handle carrying the group `<div>`'s props.
|
|
81
|
+
* @returns The render function producing the row's markup.
|
|
82
|
+
* @example
|
|
83
|
+
* <PropertyList.Item label="Owner"><a href="/people/ana">Ana Souza</a></PropertyList.Item>
|
|
84
|
+
* @example
|
|
85
|
+
* <PropertyList.Item
|
|
86
|
+
* label="Assignee"
|
|
87
|
+
* empty="No one"
|
|
88
|
+
* edit={{ id: "edit-assignee", label: "Edit assignee", content: <AssigneeForm /> }}
|
|
89
|
+
* >
|
|
90
|
+
* {assignee?.name}
|
|
91
|
+
* </PropertyList.Item>
|
|
92
|
+
*/
|
|
93
|
+
PropertyList.Item = function PropertyListItem(handle) {
|
|
94
|
+
return () => {
|
|
95
|
+
let { label, empty, edit, children, mix, ...rest } = handle.props;
|
|
96
|
+
let { variant } = handle.context.get(PropertyList);
|
|
97
|
+
let tiles = variant === "tiles";
|
|
98
|
+
let isEmpty = isEmptyValue(children);
|
|
99
|
+
let value = isEmpty ? (_jsx("span", { "data-slot": "property-empty", mix: [fg("neutral.muted")], children: empty ?? DEFAULT_EMPTY })) : (children);
|
|
100
|
+
return (_jsxs("div", { "data-slot": "property", ...rest, mix: mergeMix(tiles
|
|
101
|
+
? [
|
|
102
|
+
vstack({ gap: 1 }),
|
|
103
|
+
p(3),
|
|
104
|
+
rounded("md"),
|
|
105
|
+
border({ color: "neutral.border", width: 1 }),
|
|
106
|
+
]
|
|
107
|
+
: [
|
|
108
|
+
grid(),
|
|
109
|
+
pb(1),
|
|
110
|
+
items("baseline"),
|
|
111
|
+
/**
|
|
112
|
+
* The stacked and side-by-side tracks live in one rule, so the label column
|
|
113
|
+
* holds at its width whatever order the stylesheet layers land in.
|
|
114
|
+
*/
|
|
115
|
+
raw({
|
|
116
|
+
gridTemplateColumns: "minmax(0, 1fr)",
|
|
117
|
+
rowGap: "0.125rem",
|
|
118
|
+
[`@container ${PROPERTY_LIST_CONTAINER} (min-width: 22rem)`]: {
|
|
119
|
+
gridTemplateColumns: "var(--ui-property-list-label-width, 9rem) minmax(0, 1fr)",
|
|
120
|
+
columnGap: "1rem",
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
], mix), children: [_jsx("dt", { "data-slot": "property-label", mix: [
|
|
124
|
+
m(0),
|
|
125
|
+
minIs(0),
|
|
126
|
+
fg("neutral.muted"),
|
|
127
|
+
tiles ? text("xs") : text("sm"),
|
|
128
|
+
leading("1.25rem"),
|
|
129
|
+
pb(tiles ? 0 : 1.5),
|
|
130
|
+
], children: label }), _jsx("dd", { "data-slot": "property-value", mix: [
|
|
131
|
+
m(0),
|
|
132
|
+
minIs(0),
|
|
133
|
+
flex(),
|
|
134
|
+
items("center"),
|
|
135
|
+
gap(1.5),
|
|
136
|
+
raw({ flexWrap: "wrap" }),
|
|
137
|
+
minBs("2rem"),
|
|
138
|
+
tabularNums(),
|
|
139
|
+
tiles ? [text("lg"), weight("semibold")] : null,
|
|
140
|
+
], children: edit ? (_jsx(PropertyEdit, { edit: edit, empty: isEmpty, children: value })) : (value) })] }));
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* The editable value: a full-width button naming its action before the current value,
|
|
145
|
+
* and the popover it opens. The button is the popover's invoker, which makes it the
|
|
146
|
+
* popover's implicit anchor, so the form opens directly under its row.
|
|
147
|
+
*
|
|
148
|
+
* @param handle Runtime handle carrying the edit description and the rendered value.
|
|
149
|
+
* @returns The render function producing the button and its popover.
|
|
150
|
+
*/
|
|
151
|
+
function PropertyEdit(handle) {
|
|
152
|
+
return () => {
|
|
153
|
+
let { edit, children } = handle.props;
|
|
154
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", "data-slot": "property-edit", popovertarget: edit.id, "aria-haspopup": "dialog", mix: [
|
|
155
|
+
flex(),
|
|
156
|
+
items("center"),
|
|
157
|
+
justify("between"),
|
|
158
|
+
gap(1.5),
|
|
159
|
+
is("full"),
|
|
160
|
+
minBs("2rem"),
|
|
161
|
+
pi(2),
|
|
162
|
+
raw({ marginInline: "-0.5rem", inlineSize: "calc(100% + 1rem)" }),
|
|
163
|
+
rounded("md"),
|
|
164
|
+
border({ color: "transparent", width: 0 }),
|
|
165
|
+
bg("transparent"),
|
|
166
|
+
fg(),
|
|
167
|
+
text("sm"),
|
|
168
|
+
textAlign("start"),
|
|
169
|
+
cursor("pointer"),
|
|
170
|
+
transition("background-color"),
|
|
171
|
+
hover(bg("neutral.tint")),
|
|
172
|
+
focusVisible(outline({ color: "brand.ring", width: 2, offset: -2 })),
|
|
173
|
+
], children: [_jsxs("span", { mix: [flex(), items("center"), gap(1.5), raw({ flexWrap: "wrap" }), minIs(0)], children: [_jsx("span", { mix: [visuallyHidden()], children: `${edit.label}: ` }), children] }), _jsx(ChevronDownIcon, { size: 14, "aria-hidden": "true", mix: [shrink(0), fg("neutral.muted")] })] }), _jsx(Popover, { id: edit.id, placement: "bottom-start", role: "dialog", "aria-label": edit.label, "data-slot": "property-popover", mix: [p(3), is("min(20rem, calc(100vw - 2rem))"), text("sm")], children: edit.content })] }));
|
|
174
|
+
};
|
|
175
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `<time>` that reads "2m ago" for the last week and a date after it, with the absolute local
|
|
3
|
+
* time and UTC in its title. The server renders it from an explicit `now` and zone, and an
|
|
4
|
+
* optional island rewrites it in the viewer's own zone, the one thing a server cannot know.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { EntryComponent, Handle, Props as TagProps } from "remix/component";
|
|
10
|
+
import type { RelativeTimeFormat } from "../utils/relative-time.js";
|
|
11
|
+
export { formatRelativeTime } from "../utils/relative-time.js";
|
|
12
|
+
/**
|
|
13
|
+
* Prop types for {@link RelativeTime} and its island.
|
|
14
|
+
*/
|
|
15
|
+
export declare namespace RelativeTime {
|
|
16
|
+
/** A moment as a `Date`, an ISO 8601 string or epoch milliseconds. */
|
|
17
|
+
type DateInput = RelativeTimeFormat.DateInput;
|
|
18
|
+
/**
|
|
19
|
+
* Every native `<time>` attribute but `dateTime`, which the component writes, plus the
|
|
20
|
+
* moment and how to format it.
|
|
21
|
+
*/
|
|
22
|
+
interface Props extends Omit<TagProps<"time">, "dateTime" | "children"> {
|
|
23
|
+
/** The moment to show. */
|
|
24
|
+
date: DateInput;
|
|
25
|
+
/** The reference moment; pass the request's time so server and tests render the same text. */
|
|
26
|
+
now?: DateInput;
|
|
27
|
+
/** BCP 47 locale for the text and the title. */
|
|
28
|
+
locale?: string;
|
|
29
|
+
/** IANA zone the server formats in. Defaults to UTC. */
|
|
30
|
+
timeZone?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Hydrates the {@link RelativeTimeLocal} island, which rewrites the date and title in the
|
|
33
|
+
* viewer's zone and locale, counting from `now` when given and their clock otherwise.
|
|
34
|
+
* Needs `@sdxc/ui/relative-time#RelativeTimeLocal` in the app's browser entry.
|
|
35
|
+
*/
|
|
36
|
+
local?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Props {@link RelativeTimeLocal} serializes for hydration, so they stay plain JSON. */
|
|
39
|
+
type LocalProps = {
|
|
40
|
+
/** The moment, as an ISO 8601 string or epoch milliseconds. */
|
|
41
|
+
date: string | number;
|
|
42
|
+
/** The reference moment the text counts from; unset counts from the viewer's clock. */
|
|
43
|
+
now?: string | number;
|
|
44
|
+
/** BCP 47 locale for the text and the title. */
|
|
45
|
+
locale?: string;
|
|
46
|
+
/** IANA zone the server rendered in. */
|
|
47
|
+
timeZone?: string;
|
|
48
|
+
/** Accessible description, passed through to the `<time>`. */
|
|
49
|
+
"aria-label"?: string;
|
|
50
|
+
/** Element id, passed through to the `<time>`. */
|
|
51
|
+
id?: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Renders the moment as `<time datetime>` with its text and absolute title. With `local` it
|
|
56
|
+
* hands the same props to {@link RelativeTimeLocal}, so the server HTML is identical and the
|
|
57
|
+
* viewer's zone replaces the server's once the island hydrates.
|
|
58
|
+
*
|
|
59
|
+
* @param handle Runtime handle carrying the `<time>`'s props.
|
|
60
|
+
* @returns The render function producing the element.
|
|
61
|
+
* @example <RelativeTime date={check.at} now={ctx.requestTime} locale={locale} />
|
|
62
|
+
* @example <RelativeTime date={deploy.createdAt} now={now} locale={locale} local />
|
|
63
|
+
*/
|
|
64
|
+
export declare function RelativeTime(handle: Handle<RelativeTime.Props>): () => import("remix/component").RemixElement;
|
|
65
|
+
/**
|
|
66
|
+
* Client island behind {@link RelativeTime}'s `local` prop: the same `<time>` the server renders,
|
|
67
|
+
* rewritten in the viewer's zone on hydration, still counting from `now` when one is given.
|
|
68
|
+
* Until the island loads the server's text stands, so the moment is always readable.
|
|
69
|
+
*
|
|
70
|
+
* @example <RelativeTimeLocal date="2026-10-30T14:00:00Z" locale="en" />
|
|
71
|
+
*/
|
|
72
|
+
export declare const RelativeTimeLocal: EntryComponent<RelativeTime.LocalProps>;
|