@sdxc/ui 2026.11.1 → 2026.11.3
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 +1 -1
- package/dist/docs/docs-nav-tools.js +2 -2
- package/dist/docs/docs-nav.d.ts +6 -2
- package/dist/docs/docs-nav.js +2 -2
- 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 +2 -2
- package/dist/docs/mixins/docs-nav-tools.js +32 -5
- 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/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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The split view's remembered layout: each resizable pane's share of the screen and
|
|
3
|
+
* which panes are collapsed, written to one cookie so the next server render draws the
|
|
4
|
+
* screen the way the reader left it, ahead of any script.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** Cookie a split view stores its layout in unless it names its own. */
|
|
10
|
+
export const SPLIT_VIEW_COOKIE = "ui-split-view";
|
|
11
|
+
/** Every pane name, which a cookie value is checked against. */
|
|
12
|
+
const PANES = ["sidebar", "list", "detail"];
|
|
13
|
+
/**
|
|
14
|
+
* Reads a size field: a percentage between 0 and 100, or nothing.
|
|
15
|
+
*
|
|
16
|
+
* @param raw The field as stored.
|
|
17
|
+
* @returns The percentage, or `undefined` for an empty or out-of-range field.
|
|
18
|
+
*/
|
|
19
|
+
function parseSize(raw) {
|
|
20
|
+
if (raw === undefined || raw === "")
|
|
21
|
+
return undefined;
|
|
22
|
+
let value = Number(raw);
|
|
23
|
+
return Number.isFinite(value) && value > 0 && value < 100 ? value : undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Writes a layout as the cookie's value: `sidebar:list:collapsed,panes`, sizes rounded to
|
|
27
|
+
* two decimals.
|
|
28
|
+
*
|
|
29
|
+
* @param layout The layout to store.
|
|
30
|
+
* @returns The cookie value.
|
|
31
|
+
* @example serializeSplitViewLayout({ sidebar: 18, list: 30, collapsed: ["sidebar"] }) // "18:30:sidebar"
|
|
32
|
+
*/
|
|
33
|
+
export function serializeSplitViewLayout(layout) {
|
|
34
|
+
let size = (value) => value === undefined ? "" : String(Math.round(value * 100) / 100);
|
|
35
|
+
return `${size(layout.sidebar)}:${size(layout.list)}:${layout.collapsed.join(",")}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Reads a cookie value back into a layout, dropping any field that does not parse, so a
|
|
39
|
+
* tampered or stale cookie falls back to the default layout field by field.
|
|
40
|
+
*
|
|
41
|
+
* @param value The cookie's value.
|
|
42
|
+
* @returns The layout it stores.
|
|
43
|
+
*/
|
|
44
|
+
export function parseSplitViewLayout(value) {
|
|
45
|
+
let [sidebar, list, collapsed = ""] = decodeURIComponent(value).split(":");
|
|
46
|
+
return {
|
|
47
|
+
sidebar: parseSize(sidebar),
|
|
48
|
+
list: parseSize(list),
|
|
49
|
+
collapsed: PANES.filter((pane) => collapsed.split(",").includes(pane)),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Reads a split view's layout from a request's `Cookie` header, for the server render
|
|
54
|
+
* that passes it to `SplitView` as `layout`.
|
|
55
|
+
*
|
|
56
|
+
* @param cookieHeader The request's `Cookie` header.
|
|
57
|
+
* @param name The cookie the view stores its layout in.
|
|
58
|
+
* @returns The stored layout, or `undefined` when the reader has none yet.
|
|
59
|
+
* @example <SplitView layout={readSplitViewLayout(request.headers.get("Cookie"))} … />
|
|
60
|
+
*/
|
|
61
|
+
export function readSplitViewLayout(cookieHeader, name = SPLIT_VIEW_COOKIE) {
|
|
62
|
+
if (!cookieHeader)
|
|
63
|
+
return undefined;
|
|
64
|
+
for (let pair of cookieHeader.split(";")) {
|
|
65
|
+
let separator = pair.indexOf("=");
|
|
66
|
+
if (separator === -1 || pair.slice(0, separator).trim() !== name)
|
|
67
|
+
continue;
|
|
68
|
+
return parseSplitViewLayout(pair.slice(separator + 1).trim());
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The "Display" popover beside a list: layout, grouping, ordering, density and the visible
|
|
3
|
+
* properties, each a field of one GET form, so the URL holds the view and a link shares it.
|
|
4
|
+
* "Set as default" posts the same fields to an endpoint that stores them for the reader.
|
|
5
|
+
* Inline, it draws the fields alone, for a menu that already has a trigger.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
11
|
+
/** Prop types for {@link ViewOptions}. */
|
|
12
|
+
export declare namespace ViewOptions {
|
|
13
|
+
/** One choice of a field. */
|
|
14
|
+
interface Choice {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
/** A glyph drawn with the label in a segmented control, decorative. */
|
|
18
|
+
icon?: RemixNode;
|
|
19
|
+
}
|
|
20
|
+
/** A single-choice field: a segmented control (layout, density) or a select (grouping, ordering). */
|
|
21
|
+
interface Field {
|
|
22
|
+
/** The search parameter it writes. */
|
|
23
|
+
name?: string;
|
|
24
|
+
options: Choice[];
|
|
25
|
+
/** The choice the list uses while the URL names none. */
|
|
26
|
+
defaultValue: string;
|
|
27
|
+
}
|
|
28
|
+
/** The visible-properties field: one toggle chip per property, written as a repeated parameter. */
|
|
29
|
+
interface Properties {
|
|
30
|
+
/** The search parameter it writes. @default "props" */
|
|
31
|
+
name?: string;
|
|
32
|
+
options: Choice[];
|
|
33
|
+
/** The properties shown while the URL names none. */
|
|
34
|
+
defaultValue: string[];
|
|
35
|
+
}
|
|
36
|
+
/** Every string the popover shows. */
|
|
37
|
+
interface Labels {
|
|
38
|
+
/** The trigger's text and the popover's accessible name, such as "Display". */
|
|
39
|
+
trigger: string;
|
|
40
|
+
layout: string;
|
|
41
|
+
grouping: string;
|
|
42
|
+
ordering: string;
|
|
43
|
+
density: string;
|
|
44
|
+
properties: string;
|
|
45
|
+
apply: string;
|
|
46
|
+
/** The button that stores this view as the reader's default, such as "Set as default". */
|
|
47
|
+
setDefault: string;
|
|
48
|
+
}
|
|
49
|
+
/** Props accepted by {@link ViewOptions}; the host is a `<div>`. */
|
|
50
|
+
interface Props extends Omit<TagProps<"div">, "children" | "id"> {
|
|
51
|
+
/** Prefix for the popover and form ids; unique on the page. */
|
|
52
|
+
id: string;
|
|
53
|
+
/**
|
|
54
|
+
* The page's current URL, where every applied value is read from.
|
|
55
|
+
*
|
|
56
|
+
* @default "/", a page with no parameters
|
|
57
|
+
*/
|
|
58
|
+
url?: URL | string;
|
|
59
|
+
/** Where Apply submits. Defaults to the current path. */
|
|
60
|
+
action?: string;
|
|
61
|
+
/** @default name "layout" */
|
|
62
|
+
layout?: Field;
|
|
63
|
+
/** @default name "group" */
|
|
64
|
+
grouping?: Field;
|
|
65
|
+
/** @default name "order" */
|
|
66
|
+
ordering?: Field;
|
|
67
|
+
/** @default name "density" */
|
|
68
|
+
density?: Field;
|
|
69
|
+
properties?: Properties;
|
|
70
|
+
/** Where "Set as default" posts the fields; omitted hides the button. */
|
|
71
|
+
setDefault?: {
|
|
72
|
+
action: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Draws the form in place, without its own trigger and popover, for a menu that holds
|
|
76
|
+
* it among other view controls, such as a filter bar's `options`.
|
|
77
|
+
*/
|
|
78
|
+
inline?: boolean;
|
|
79
|
+
labels: Labels;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Renders the trigger and its popover. Every field reads its value from `url`, falling back to
|
|
84
|
+
* the field's default, and Apply submits them with every other parameter carried as hidden
|
|
85
|
+
* fields, so the filters and tab the page shows survive a view change.
|
|
86
|
+
*
|
|
87
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
88
|
+
* @returns The render function producing the trigger and popover.
|
|
89
|
+
* @example
|
|
90
|
+
* <ViewOptions
|
|
91
|
+
* id="monitors-view"
|
|
92
|
+
* url={request.url}
|
|
93
|
+
* layout={{ defaultValue: "table", options: [{ value: "table", label: "Table", icon: <TableIcon /> }, { value: "grid", label: "Grid", icon: <LayoutGridIcon /> }] }}
|
|
94
|
+
* density={{ defaultValue: "compact", options: [{ value: "compact", label: "Compact" }, { value: "comfortable", label: "Comfortable" }] }}
|
|
95
|
+
* setDefault={{ action: "/settings/views/monitors" }}
|
|
96
|
+
* labels={labels}
|
|
97
|
+
* />
|
|
98
|
+
*/
|
|
99
|
+
export declare function ViewOptions(handle: Handle<ViewOptions.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { SlidersHorizontalIcon } from "@sdxc/icons";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { bg, border, fg, outline } from "@sdxc/u/color";
|
|
5
|
+
import { rounded } from "@sdxc/u/effects";
|
|
6
|
+
import { cursor, mergeMix } from "@sdxc/u/general";
|
|
7
|
+
import { flex, flexWrap, gap, inlineBlock, inlineFlex, items, justify, shrink, vstack, } from "@sdxc/u/layout";
|
|
8
|
+
import { bs, is, m, maxIs, minIs, p, pb, pi } from "@sdxc/u/size";
|
|
9
|
+
import { has, hover, when } from "@sdxc/u/state";
|
|
10
|
+
import { nowrap, text, weight } from "@sdxc/u/typography";
|
|
11
|
+
import { Button } from "../components/button.js";
|
|
12
|
+
import { Popover } from "../components/popover.js";
|
|
13
|
+
import { Select } from "../components/select.js";
|
|
14
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
15
|
+
import { segmentedItem, segmentedTrack } from "../styles/segmented-control.js";
|
|
16
|
+
import { carriedParams, paramValues } from "./utils/search-params.js";
|
|
17
|
+
/** The URL read when `url` is unset: a page with nothing applied. */
|
|
18
|
+
const DEFAULT_URL = "/";
|
|
19
|
+
/** The parameter each field writes when its `name` is unset. */
|
|
20
|
+
const DEFAULT_NAMES = {
|
|
21
|
+
layout: "layout",
|
|
22
|
+
grouping: "group",
|
|
23
|
+
ordering: "order",
|
|
24
|
+
density: "density",
|
|
25
|
+
properties: "props",
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Renders the trigger and its popover. Every field reads its value from `url`, falling back to
|
|
29
|
+
* the field's default, and Apply submits them with every other parameter carried as hidden
|
|
30
|
+
* fields, so the filters and tab the page shows survive a view change.
|
|
31
|
+
*
|
|
32
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
33
|
+
* @returns The render function producing the trigger and popover.
|
|
34
|
+
* @example
|
|
35
|
+
* <ViewOptions
|
|
36
|
+
* id="monitors-view"
|
|
37
|
+
* url={request.url}
|
|
38
|
+
* layout={{ defaultValue: "table", options: [{ value: "table", label: "Table", icon: <TableIcon /> }, { value: "grid", label: "Grid", icon: <LayoutGridIcon /> }] }}
|
|
39
|
+
* density={{ defaultValue: "compact", options: [{ value: "compact", label: "Compact" }, { value: "comfortable", label: "Comfortable" }] }}
|
|
40
|
+
* setDefault={{ action: "/settings/views/monitors" }}
|
|
41
|
+
* labels={labels}
|
|
42
|
+
* />
|
|
43
|
+
*/
|
|
44
|
+
export function ViewOptions(handle) {
|
|
45
|
+
return () => {
|
|
46
|
+
let { id, url = DEFAULT_URL, action, layout, grouping, ordering, density, properties, setDefault, inline, labels, mix, ...rest } = handle.props;
|
|
47
|
+
let popoverId = `${id}-popover`;
|
|
48
|
+
let names = {
|
|
49
|
+
layout: layout?.name ?? DEFAULT_NAMES.layout,
|
|
50
|
+
grouping: grouping?.name ?? DEFAULT_NAMES.grouping,
|
|
51
|
+
ordering: ordering?.name ?? DEFAULT_NAMES.ordering,
|
|
52
|
+
density: density?.name ?? DEFAULT_NAMES.density,
|
|
53
|
+
properties: properties?.name ?? DEFAULT_NAMES.properties,
|
|
54
|
+
};
|
|
55
|
+
let owned = [
|
|
56
|
+
layout ? names.layout : null,
|
|
57
|
+
grouping ? names.grouping : null,
|
|
58
|
+
ordering ? names.ordering : null,
|
|
59
|
+
density ? names.density : null,
|
|
60
|
+
properties ? names.properties : null,
|
|
61
|
+
].filter((name) => name !== null);
|
|
62
|
+
let form = (_jsxs("form", { method: "get", action: action, "aria-label": inline ? labels.trigger : undefined, mix: [vstack({ gap: 3 })], children: [carriedParams(url, owned).map(([name, value]) => (_jsx("input", { type: "hidden", name: name, value: value }))), layout ? (_jsx(Segmented, { name: names.layout, label: labels.layout, field: layout, value: chosen(url, names.layout, layout) })) : null, grouping ? (_jsx(SelectRow, { id: `${id}-grouping`, name: names.grouping, label: labels.grouping, field: grouping, value: chosen(url, names.grouping, grouping) })) : null, ordering ? (_jsx(SelectRow, { id: `${id}-ordering`, name: names.ordering, label: labels.ordering, field: ordering, value: chosen(url, names.ordering, ordering) })) : null, density ? (_jsx(Segmented, { name: names.density, label: labels.density, field: density, value: chosen(url, names.density, density) })) : null, properties ? (_jsx(PropertyChips, { name: names.properties, label: labels.properties, field: properties, selected: shownProperties(url, names.properties, properties) })) : null, _jsxs("div", { mix: [flex(), items("center"), justify("end"), gap(2)], children: [setDefault ? (_jsx(Button, { type: "submit", variant: "ghost", size: "sm", formMethod: "post", formAction: setDefault.action, "data-slot": "view-options-default", children: labels.setDefault })) : null, _jsx(Button, { type: "submit", size: "sm", color: "brand", "data-slot": "view-options-apply", children: labels.apply })] })] }));
|
|
63
|
+
if (inline) {
|
|
64
|
+
return (_jsx("div", { ...rest, "data-slot": "view-options", "data-inline": "", mix: mergeMix([minIs(0)], mix), children: form }));
|
|
65
|
+
}
|
|
66
|
+
return (_jsxs("div", { ...rest, "data-slot": "view-options", mix: mergeMix([inlineBlock()], mix), children: [_jsxs(Button, { variant: "ghost", size: "sm", commandfor: popoverId, command: "toggle-popover", "data-slot": "view-options-trigger", mix: [fg("neutral"), weight(400), when("& > svg", fg("neutral.muted"))], children: [_jsx(SlidersHorizontalIcon, { size: 16, "aria-hidden": "true" }), labels.trigger] }), _jsx(Popover, { id: popoverId, placement: "bottom-end", role: "dialog", "aria-label": labels.trigger, mix: [p(3), is("18rem"), maxIs("calc(100vw - 2rem)")], children: form })] }));
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The value a single-choice field shows: the URL's, when it names one of the field's options,
|
|
71
|
+
* else the field's default, so a stale or hand-typed value never leaves the control blank.
|
|
72
|
+
*
|
|
73
|
+
* @param url The page's current URL.
|
|
74
|
+
* @param name The field's parameter.
|
|
75
|
+
* @param field The field.
|
|
76
|
+
* @returns The value to mark chosen.
|
|
77
|
+
*/
|
|
78
|
+
function chosen(url, name, field) {
|
|
79
|
+
let value = paramValues(url, name)[0];
|
|
80
|
+
return field.options.some((option) => option.value === value) && value !== undefined
|
|
81
|
+
? value
|
|
82
|
+
: field.defaultValue;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The properties shown: the URL's list once the parameter is present, even empty (every chip
|
|
86
|
+
* off), else the default list. The form always sends an empty value first, which is what
|
|
87
|
+
* marks the parameter present after the reader turns every chip off.
|
|
88
|
+
*
|
|
89
|
+
* @param url The page's current URL.
|
|
90
|
+
* @param name The parameter.
|
|
91
|
+
* @param field The properties field.
|
|
92
|
+
* @returns The property values to mark on.
|
|
93
|
+
*/
|
|
94
|
+
function shownProperties(url, name, field) {
|
|
95
|
+
let present = new URL(url.toString(), "http://localhost").searchParams.has(name);
|
|
96
|
+
return present ? paramValues(url, name) : field.defaultValue;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Renders a single-choice field as a segmented control of native radios, so arrow keys move
|
|
100
|
+
* between choices and the chosen one submits under `name`.
|
|
101
|
+
*
|
|
102
|
+
* @param handle Runtime handle carrying the field.
|
|
103
|
+
* @returns The render function producing the fieldset.
|
|
104
|
+
*/
|
|
105
|
+
function Segmented(handle) {
|
|
106
|
+
return () => {
|
|
107
|
+
let { name, label, field, value } = handle.props;
|
|
108
|
+
return (_jsxs("fieldset", { "data-slot": "view-options-segmented", "data-name": name, mix: [
|
|
109
|
+
m(0),
|
|
110
|
+
p(0),
|
|
111
|
+
border({ width: 0 }),
|
|
112
|
+
flex(),
|
|
113
|
+
items("center"),
|
|
114
|
+
justify("between"),
|
|
115
|
+
gap(3),
|
|
116
|
+
minIs(0),
|
|
117
|
+
], children: [_jsx("legend", { mix: [visuallyHidden()], children: label }), _jsx("span", { "aria-hidden": "true", mix: [text("sm"), fg("neutral"), nowrap()], children: label }), _jsx("span", { mix: [segmentedTrack(), minIs(0)], children: field.options.map((option) => (_jsxs("label", { title: option.label, mix: [
|
|
118
|
+
interactiveTransition(),
|
|
119
|
+
inlineFlex(),
|
|
120
|
+
items("center"),
|
|
121
|
+
justify("center"),
|
|
122
|
+
gap(1.5),
|
|
123
|
+
bs(7),
|
|
124
|
+
pi(2),
|
|
125
|
+
text("sm"),
|
|
126
|
+
cursor("pointer"),
|
|
127
|
+
nowrap(),
|
|
128
|
+
segmentedItem({
|
|
129
|
+
selected: "&:has(input:checked)",
|
|
130
|
+
focused: "&:has(input:focus-visible)",
|
|
131
|
+
}),
|
|
132
|
+
when("& > svg", shrink(0)),
|
|
133
|
+
], children: [_jsx("input", { type: "radio", name: name, value: option.value, defaultChecked: option.value === value, mix: [visuallyHidden()] }), option.icon, option.icon ? _jsx("span", { mix: [visuallyHidden()], children: option.label }) : option.label] }))) })] }));
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Renders a single-choice field with many options (grouping, ordering) as a labelled select
|
|
138
|
+
* on the same row as its label.
|
|
139
|
+
*
|
|
140
|
+
* @param handle Runtime handle carrying the field.
|
|
141
|
+
* @returns The render function producing the row.
|
|
142
|
+
*/
|
|
143
|
+
function SelectRow(handle) {
|
|
144
|
+
return () => {
|
|
145
|
+
let { id, name, label, field, value } = handle.props;
|
|
146
|
+
return (_jsxs("div", { mix: [flex(), items("center"), justify("between"), gap(3)], children: [_jsx("label", { for: id, mix: [text("sm"), fg("neutral"), nowrap()], children: label }), _jsx(Select, { id: id, name: name, mix: [is("10rem"), bs(8), minIs(0)], children: field.options.map((option) => (_jsx("option", { value: option.value, selected: option.value === value, children: option.label }))) })] }));
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Renders the visible properties as toggle chips: native checkboxes under one repeated name,
|
|
151
|
+
* behind an empty value that keeps the parameter present when every chip is off.
|
|
152
|
+
*
|
|
153
|
+
* @param handle Runtime handle carrying the field.
|
|
154
|
+
* @returns The render function producing the fieldset.
|
|
155
|
+
*/
|
|
156
|
+
function PropertyChips(handle) {
|
|
157
|
+
return () => {
|
|
158
|
+
let { name, label, field, selected } = handle.props;
|
|
159
|
+
return (_jsxs("fieldset", { "data-slot": "view-options-properties", mix: [m(0), p(0), border({ width: 0 }), vstack({ gap: 2 }), minIs(0)], children: [_jsx("legend", { mix: [pb(2), text("sm"), fg("neutral")], children: label }), _jsx("input", { type: "hidden", name: name, value: "" }), _jsx("div", { mix: [flex(), flexWrap(), gap(1.5)], children: field.options.map((option) => (_jsxs("label", { mix: [
|
|
160
|
+
interactiveTransition(),
|
|
161
|
+
inlineFlex(),
|
|
162
|
+
items("center"),
|
|
163
|
+
gap(1),
|
|
164
|
+
bs(7),
|
|
165
|
+
pi(2.5),
|
|
166
|
+
rounded("full"),
|
|
167
|
+
border({ width: 1, color: "neutral.border" }),
|
|
168
|
+
text("xs"),
|
|
169
|
+
weight(500),
|
|
170
|
+
fg("neutral"),
|
|
171
|
+
cursor("pointer"),
|
|
172
|
+
nowrap(),
|
|
173
|
+
hover(bg("neutral.bg-tint-hover")),
|
|
174
|
+
has("input:checked", [
|
|
175
|
+
bg("brand.tint"),
|
|
176
|
+
border("brand.border"),
|
|
177
|
+
fg("brand.emphasis"),
|
|
178
|
+
]),
|
|
179
|
+
has("input:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
180
|
+
], children: [_jsx("input", { type: "checkbox", name: name, value: option.value, defaultChecked: selected.includes(option.value), mix: [visuallyHidden()] }), option.icon, option.label] }))) })] }));
|
|
181
|
+
};
|
|
182
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A full-width strip above a page or the whole app for state that outlives one
|
|
3
|
+
* action: an overdue invoice, a failing integration, a maintenance window. It
|
|
4
|
+
* sits in the flow and pushes the frame down, so it never covers what it warns about.
|
|
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
|
+
import type { SemanticColor } from "../utils/semantic-color.js";
|
|
11
|
+
/** Prop types for {@link Banner}. */
|
|
12
|
+
export declare namespace Banner {
|
|
13
|
+
/** Semantic tone of the strip: warning for billing, danger for a failing integration. */
|
|
14
|
+
type Color = SemanticColor;
|
|
15
|
+
/** Props accepted by {@link Banner}. */
|
|
16
|
+
interface Props extends Omit<TagProps<"section">, "children"> {
|
|
17
|
+
/** Accessible name of the strip's region landmark, such as "Billing". */
|
|
18
|
+
label: string;
|
|
19
|
+
/** Default: `"brand"`. */
|
|
20
|
+
color?: Color;
|
|
21
|
+
/** Leading icon in place of the tone's own, or `null` for none. */
|
|
22
|
+
icon?: RemixNode;
|
|
23
|
+
/** The one fixing action, such as an "Update Payment Method" button or link. */
|
|
24
|
+
action?: RemixNode;
|
|
25
|
+
/**
|
|
26
|
+
* Lets the reader close the strip through a form, so the server records it
|
|
27
|
+
* and stops rendering the banner. Leave it out for state that needs resolving.
|
|
28
|
+
*/
|
|
29
|
+
dismiss?: Dismiss;
|
|
30
|
+
/** The message: what is wrong and what fixing it changes, in a sentence or two. */
|
|
31
|
+
children: RemixNode;
|
|
32
|
+
}
|
|
33
|
+
/** How a dismissible {@link Banner} closes. */
|
|
34
|
+
interface Dismiss {
|
|
35
|
+
/** Accessible name of the close button, such as "Dismiss". */
|
|
36
|
+
label: string;
|
|
37
|
+
/** URL the dismissal submits to. */
|
|
38
|
+
action: string;
|
|
39
|
+
/** Default: `"post"`. */
|
|
40
|
+
method?: "get" | "post";
|
|
41
|
+
/** Hidden fields sent with it, such as the banner's id. */
|
|
42
|
+
fields?: Record<string, string>;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Renders the strip as a named region: tone icon, message, one action, and a
|
|
47
|
+
* close form only when `dismiss` is given. One banner at a time; it wraps on a
|
|
48
|
+
* phone and flows above the app frame, pushing it down.
|
|
49
|
+
*
|
|
50
|
+
* @param handle Runtime handle carrying the host `<section>`'s props.
|
|
51
|
+
* @returns The render function producing the strip's markup.
|
|
52
|
+
* @example
|
|
53
|
+
* <Banner color="warning" label={t("billing.region")} action={<Button href="/billing">{t("billing.update")}</Button>}>
|
|
54
|
+
* {t("billing.declined")}
|
|
55
|
+
* </Banner>
|
|
56
|
+
* @example
|
|
57
|
+
* <Banner label={t("maintenance.region")} dismiss={{ label: t("actions.dismiss"), action: "/banners/dismiss", fields: { id: "maintenance" } }}>
|
|
58
|
+
* {t("maintenance.message")}
|
|
59
|
+
* </Banner>
|
|
60
|
+
*/
|
|
61
|
+
export declare function Banner(handle: Handle<Banner.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { CircleAlertIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, XIcon } from "@sdxc/icons";
|
|
3
|
+
import { bg, border, fg, outline } from "@sdxc/u/color";
|
|
4
|
+
import { rounded, transition } from "@sdxc/u/effects";
|
|
5
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
6
|
+
import { flex, flexWrap, gap, grow, inlineFlex, items, justify, shrink } from "@sdxc/u/layout";
|
|
7
|
+
import { bs, is, minIs, pb, pi } from "@sdxc/u/size";
|
|
8
|
+
import { hover, when } from "@sdxc/u/state";
|
|
9
|
+
import { fontSize, leading, overflowWrap, pretty, weight } from "@sdxc/u/typography";
|
|
10
|
+
import { semanticColorPanel } from "../styles/semantic-color-panel.js";
|
|
11
|
+
/** Default {@link Banner.Props.color}: an informational strip. */
|
|
12
|
+
const DEFAULT_COLOR = "brand";
|
|
13
|
+
/**
|
|
14
|
+
* Renders the strip as a named region: tone icon, message, one action, and a
|
|
15
|
+
* close form only when `dismiss` is given. One banner at a time; it wraps on a
|
|
16
|
+
* phone and flows above the app frame, pushing it down.
|
|
17
|
+
*
|
|
18
|
+
* @param handle Runtime handle carrying the host `<section>`'s props.
|
|
19
|
+
* @returns The render function producing the strip's markup.
|
|
20
|
+
* @example
|
|
21
|
+
* <Banner color="warning" label={t("billing.region")} action={<Button href="/billing">{t("billing.update")}</Button>}>
|
|
22
|
+
* {t("billing.declined")}
|
|
23
|
+
* </Banner>
|
|
24
|
+
* @example
|
|
25
|
+
* <Banner label={t("maintenance.region")} dismiss={{ label: t("actions.dismiss"), action: "/banners/dismiss", fields: { id: "maintenance" } }}>
|
|
26
|
+
* {t("maintenance.message")}
|
|
27
|
+
* </Banner>
|
|
28
|
+
*/
|
|
29
|
+
export function Banner(handle) {
|
|
30
|
+
return () => {
|
|
31
|
+
let { label, color = DEFAULT_COLOR, icon, action, dismiss, children, mix, ...rest } = handle.props;
|
|
32
|
+
let toneIcon = icon === null ? null : (icon ?? _jsx(BannerToneIcon, { color: color }));
|
|
33
|
+
return (_jsxs("section", { "aria-label": label, ...rest, "data-color": color, "data-slot": "banner", mix: mergeMix([
|
|
34
|
+
semanticColorPanel(),
|
|
35
|
+
flex(),
|
|
36
|
+
flexWrap(),
|
|
37
|
+
items("center"),
|
|
38
|
+
gap(3),
|
|
39
|
+
is("full"),
|
|
40
|
+
minIs(0),
|
|
41
|
+
pb("0.5rem"),
|
|
42
|
+
pi("1rem"),
|
|
43
|
+
raw({ borderWidth: "0", borderBlockEndWidth: "1px", borderStyle: "solid" }),
|
|
44
|
+
fontSize("sm"),
|
|
45
|
+
], mix), children: [toneIcon ? (_jsx("span", { "aria-hidden": "true", "data-slot": "banner-icon", mix: [inlineFlex(), shrink(0), fg("currentcolor")], children: toneIcon })) : null, _jsx("p", { "data-slot": "banner-message", mix: [
|
|
46
|
+
grow(),
|
|
47
|
+
raw({ flexBasis: "16rem" }),
|
|
48
|
+
minIs(0),
|
|
49
|
+
leading("snug"),
|
|
50
|
+
weight("medium"),
|
|
51
|
+
pretty(),
|
|
52
|
+
overflowWrap("anywhere"),
|
|
53
|
+
], children: children }), action ? (_jsx("div", { "data-slot": "banner-action", mix: [flex(), items("center"), shrink(0)], children: action })) : null, dismiss ? _jsx(BannerDismiss, { dismiss: dismiss }) : null] }));
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Picks the icon a tone carries, so a warning and a failure read apart before
|
|
58
|
+
* the message does.
|
|
59
|
+
*
|
|
60
|
+
* @param handle Runtime handle carrying the banner's tone.
|
|
61
|
+
* @returns The render function producing the icon.
|
|
62
|
+
*/
|
|
63
|
+
function BannerToneIcon(handle) {
|
|
64
|
+
return () => {
|
|
65
|
+
let { color } = handle.props;
|
|
66
|
+
if (color === "success")
|
|
67
|
+
return _jsx(CircleCheckIcon, { size: 16 });
|
|
68
|
+
if (color === "danger")
|
|
69
|
+
return _jsx(CircleAlertIcon, { size: 16 });
|
|
70
|
+
if (color === "warning")
|
|
71
|
+
return _jsx(TriangleAlertIcon, { size: 16 });
|
|
72
|
+
return _jsx(InfoIcon, { size: 16 });
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The close control of a dismissible {@link Banner}: an icon button that
|
|
77
|
+
* submits its form, so the dismissal reaches the server with or without
|
|
78
|
+
* JavaScript and the banner stays gone on the next page.
|
|
79
|
+
*
|
|
80
|
+
* @param handle Runtime handle carrying the dismissal form.
|
|
81
|
+
* @returns The render function producing the form's markup.
|
|
82
|
+
*/
|
|
83
|
+
function BannerDismiss(handle) {
|
|
84
|
+
return () => {
|
|
85
|
+
let { dismiss } = handle.props;
|
|
86
|
+
return (_jsxs("form", { method: dismiss.method ?? "post", action: dismiss.action, "data-slot": "banner-dismiss", mix: [flex(), shrink(0), raw({ marginInlineStart: "auto" })], children: [Object.entries(dismiss.fields ?? {}).map(([name, value]) => (_jsx("input", { type: "hidden", name: name, value: value }, name))), _jsx("button", { type: "submit", "aria-label": dismiss.label, title: dismiss.label, mix: [
|
|
87
|
+
inlineFlex(),
|
|
88
|
+
items("center"),
|
|
89
|
+
justify("center"),
|
|
90
|
+
is("2rem"),
|
|
91
|
+
bs("2rem"),
|
|
92
|
+
rounded("md"),
|
|
93
|
+
border({ width: 0 }),
|
|
94
|
+
bg("transparent"),
|
|
95
|
+
fg("currentcolor"),
|
|
96
|
+
transition("background-color"),
|
|
97
|
+
hover(bg("neutral.bg-tint-hover")),
|
|
98
|
+
when("&:focus-visible", outline({ color: "brand.ring", width: 2 })),
|
|
99
|
+
], children: _jsx(XIcon, { size: 16 }) })] }));
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* call: an {@link AlertDialog} panel prefilled with a heading, an optional
|
|
4
4
|
* supporting passage, and a cancel/confirm control pair, so a single
|
|
5
5
|
* consequential decision needs no compound assembly of its own. The
|
|
6
|
-
* confirming control defaults to the semantic danger tone,
|
|
7
|
-
*
|
|
6
|
+
* confirming control defaults to the semantic danger tone, and a
|
|
7
|
+
* type-to-confirm variant holds a big irreversible action until its name is typed.
|
|
8
8
|
*
|
|
9
9
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
10
10
|
* @copyright Sergio Xalambrí 2026
|
|
11
11
|
*/
|
|
12
|
-
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
12
|
+
import type { EntryComponent, Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
13
13
|
import type { Button } from "./button.js";
|
|
14
14
|
import { AlertDialog } from "./alert-dialog.js";
|
|
15
15
|
/**
|
|
@@ -53,6 +53,19 @@ export declare namespace Confirm {
|
|
|
53
53
|
*/
|
|
54
54
|
fields?: RemixNode;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The phrase a person types before a big irreversible action unlocks, such as
|
|
58
|
+
* the team's name. Reserve it for deleting something large; on routine
|
|
59
|
+
* confirms it reads as melodrama.
|
|
60
|
+
*/
|
|
61
|
+
interface TypeToConfirm {
|
|
62
|
+
/** The exact text that unlocks the confirming control, compared case-sensitively. */
|
|
63
|
+
value: string;
|
|
64
|
+
/** The field's label, such as `Type "acme" to confirm`. */
|
|
65
|
+
label: RemixNode;
|
|
66
|
+
/** Name the typed text submits under in submit mode, so the server can check it again. */
|
|
67
|
+
name?: string;
|
|
68
|
+
}
|
|
56
69
|
/**
|
|
57
70
|
* Props accepted by {@link Confirm}. `mix` styles the underlying
|
|
58
71
|
* {@link AlertDialog} host directly; style the composed header, title,
|
|
@@ -84,14 +97,19 @@ export declare namespace Confirm {
|
|
|
84
97
|
* submits a real form instead.
|
|
85
98
|
*/
|
|
86
99
|
form?: FormProps;
|
|
100
|
+
/**
|
|
101
|
+
* Holds the confirming control disabled until this phrase is typed. Without
|
|
102
|
+
* script the field's `pattern` blocks the submission instead.
|
|
103
|
+
*/
|
|
104
|
+
typeToConfirm?: TypeToConfirm;
|
|
87
105
|
/** Per-part styling for this wrapper's internally composed elements. */
|
|
88
106
|
parts?: PartsProps;
|
|
89
107
|
}
|
|
90
108
|
}
|
|
91
109
|
/**
|
|
92
110
|
* Composes {@link AlertDialog} into a confirmation prompt, wiring title and
|
|
93
|
-
* description ids to `aria-labelledby`/`aria-describedby`.
|
|
94
|
-
*
|
|
111
|
+
* description ids to `aria-labelledby`/`aria-describedby`. Focus opens on Cancel, or
|
|
112
|
+
* on the phrase field with `typeToConfirm`; pass `form` to submit a real `<form>`.
|
|
95
113
|
*
|
|
96
114
|
* @param handle Runtime handle carrying the panel's props and this instance's stable identifier.
|
|
97
115
|
* @returns The render function producing the confirmation prompt's markup.
|
|
@@ -120,5 +138,36 @@ export declare namespace Confirm {
|
|
|
120
138
|
* cancelLabel={t("actions.cancel")}
|
|
121
139
|
* form={{ action: revokeUrl, fields: <input type="hidden" name="csrf" value={token} /> }}
|
|
122
140
|
* />
|
|
141
|
+
* @example
|
|
142
|
+
* <Confirm
|
|
143
|
+
* id="delete-team"
|
|
144
|
+
* title="Delete team?"
|
|
145
|
+
* description="Acme, its 12 monitors and their history are deleted."
|
|
146
|
+
* confirmLabel="Delete team"
|
|
147
|
+
* cancelLabel="Cancel"
|
|
148
|
+
* typeToConfirm={{ value: "acme", label: 'Type "acme" to confirm', name: "confirmation" }}
|
|
149
|
+
* form={{ action: "/teams/acme/delete" }}
|
|
150
|
+
* />
|
|
123
151
|
*/
|
|
124
152
|
export declare function Confirm(handle: Handle<Confirm.Props>): () => import("remix/component").RemixElement;
|
|
153
|
+
/**
|
|
154
|
+
* Props {@link ConfirmPhrase} serializes into the page for hydration, which is why they are
|
|
155
|
+
* a `type`: `SerializableProps` rejects an interface.
|
|
156
|
+
*/
|
|
157
|
+
export type ConfirmPhraseProps = {
|
|
158
|
+
/** The input's `id`, which its label points at. */
|
|
159
|
+
id: string;
|
|
160
|
+
/** The exact text that unlocks the confirming control. */
|
|
161
|
+
value: string;
|
|
162
|
+
label: RemixNode;
|
|
163
|
+
name?: string;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Client island: the field a type-to-confirm prompt holds. It disables the dialog's
|
|
167
|
+
* confirming control until the typed text matches and clears itself when the dialog
|
|
168
|
+
* closes, so every opening starts locked; without script, `pattern` blocks the submit.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* <ConfirmPhrase id="delete-team-phrase" value="acme" label='Type "acme" to confirm' />
|
|
172
|
+
*/
|
|
173
|
+
export declare const ConfirmPhrase: EntryComponent<ConfirmPhraseProps>;
|