@cosmicdrift/kumiko-renderer 0.410.0 → 0.411.0
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/dist/app/projection-detail-body.js +1 -0
- package/dist/app/projection-detail-header.js +4 -1
- package/dist/app/use-projection-detail-actions.d.ts +1 -0
- package/dist/app/use-projection-detail-actions.js +7 -2
- package/dist/components/render-edit-fields-section.js +2 -1
- package/dist/components/render-edit-form-actions.d.ts +1 -0
- package/dist/components/render-edit-form-actions.js +10 -5
- package/dist/components/render-edit-layout.js +7 -11
- package/dist/components/render-edit-logic.d.ts +3 -0
- package/dist/components/render-edit-logic.js +10 -0
- package/dist/components/render-edit-submit-result.d.ts +1 -1
- package/dist/components/render-edit-submit-result.js +2 -2
- package/dist/components/render-edit-submit.js +6 -3
- package/dist/components/render-edit-titles.d.ts +1 -2
- package/dist/components/render-edit-titles.js +1 -2
- package/dist/components/render-edit-wizard-navigation.d.ts +1 -1
- package/dist/components/render-edit-wizard-navigation.js +8 -4
- package/dist/components/render-edit-wizard-rail.d.ts +12 -0
- package/dist/components/render-edit-wizard-rail.js +74 -0
- package/dist/components/render-field.js +4 -4
- package/dist/components/use-render-edit-state.d.ts +1 -0
- package/dist/components/use-render-edit-state.js +3 -1
- package/dist/data-table-view-types.d.ts +2 -0
- package/dist/headless/view-model/edit.js +17 -6
- package/dist/headless/view-model/types.d.ts +12 -0
- package/dist/hooks/use-list-table.d.ts +1 -0
- package/dist/hooks/use-list-table.js +2 -1
- package/dist/i18n-defaults.js +18 -0
- package/dist/primitives.d.ts +23 -6
- package/dist/required-marker-context.d.ts +2 -0
- package/dist/required-marker-context.js +3 -0
- package/dist/web/index.d.ts +5 -3
- package/dist/web/index.js +2 -1
- package/dist/web/layout/avatar.d.ts +5 -2
- package/dist/web/layout/avatar.js +3 -2
- package/dist/web/presence/index.d.ts +8 -0
- package/dist/web/presence/index.js +4 -0
- package/dist/web/presence/presence-avatars.d.ts +9 -0
- package/dist/web/presence/presence-avatars.js +16 -0
- package/dist/web/presence/presence-notice.d.ts +13 -0
- package/dist/web/presence/presence-notice.js +32 -0
- package/dist/web/presence/presence-signal.d.ts +3 -0
- package/dist/web/presence/presence-signal.js +20 -0
- package/dist/web/presence/use-presence-list.d.ts +12 -0
- package/dist/web/presence/use-presence-list.js +34 -0
- package/dist/web/presence/use-presence.d.ts +16 -0
- package/dist/web/presence/use-presence.js +77 -0
- package/dist/web/primitives/banner.d.ts +1 -1
- package/dist/web/primitives/banner.js +51 -16
- package/dist/web/primitives/data-table/sortable-header.d.ts +3 -1
- package/dist/web/primitives/data-table/sortable-header.js +4 -3
- package/dist/web/primitives/data-table/table-header-row.js +1 -1
- package/dist/web/primitives/field.js +3 -1
- package/dist/web/primitives/form.d.ts +3 -1
- package/dist/web/primitives/form.js +4 -2
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +5 -2
- package/dist/web/primitives/layout.d.ts +1 -0
- package/dist/web/primitives/layout.js +4 -0
- package/dist/web/primitives/metric.js +4 -2
- package/dist/web/widgets/choice-cards.d.ts +7 -1
- package/dist/web/widgets/choice-cards.js +16 -3
- package/dist/web/widgets/composer.d.ts +16 -0
- package/dist/web/widgets/composer.js +9 -0
- package/dist/web/widgets/detail-list.d.ts +6 -2
- package/dist/web/widgets/detail-list.js +7 -3
- package/dist/web/widgets/floating-panel.d.ts +16 -1
- package/dist/web/widgets/floating-panel.js +23 -7
- package/dist/web/widgets/form-fields.d.ts +2 -1
- package/dist/web/widgets/form-fields.js +2 -2
- package/dist/web/widgets/index.d.ts +4 -2
- package/dist/web/widgets/index.js +2 -0
- package/dist/web/widgets/mode-switch.d.ts +7 -1
- package/dist/web/widgets/mode-switch.js +12 -5
- package/dist/web/widgets/result-panel.d.ts +3 -1
- package/dist/web/widgets/result-panel.js +3 -2
- package/dist/web/widgets/section-nav-layout.d.ts +14 -0
- package/dist/web/widgets/section-nav-layout.js +9 -0
- package/dist/web/widgets/side-by-side-table.d.ts +3 -1
- package/dist/web/widgets/side-by-side-table.js +2 -2
- package/dist/web/widgets/step-bar.js +1 -1
- package/dist/web/widgets/step-list-row.d.ts +15 -4
- package/dist/web/widgets/step-list-row.js +47 -5
- package/dist/web/widgets/step-list-selection.d.ts +42 -0
- package/dist/web/widgets/step-list-selection.js +134 -0
- package/dist/web/widgets/step-list.d.ts +21 -2
- package/dist/web/widgets/step-list.js +99 -14
- package/package.json +5 -5
- package/src/changes.json +84 -0
|
@@ -198,7 +198,7 @@ export const SECTION_NAV_MIN_ITEMS = 3;
|
|
|
198
198
|
// "On this page" navigation next to a screen form. The active entry follows
|
|
199
199
|
// the section nearest the top of the scroll surface; without IntersectionObserver
|
|
200
200
|
// (happy-dom, old engines) the first entry stays active until one is clicked.
|
|
201
|
-
export function FormSectionNav({ items, }) {
|
|
201
|
+
export function FormSectionNav({ items, activeTone = "primary", }) {
|
|
202
202
|
const t = useTranslation();
|
|
203
203
|
const [activeId, setActiveId] = useState(items[0]?.id);
|
|
204
204
|
useEffect(() => {
|
|
@@ -231,7 +231,9 @@ export function FormSectionNav({ items, }) {
|
|
|
231
231
|
.getElementById(item.id)
|
|
232
232
|
?.scrollIntoView?.({ behavior: "smooth", block: "start" });
|
|
233
233
|
}, className: cn("border-l-2 px-3 py-[5px] text-left text-sm", active
|
|
234
|
-
?
|
|
234
|
+
? activeTone === "foreground"
|
|
235
|
+
? "border-foreground font-semibold text-foreground"
|
|
236
|
+
: "border-primary font-semibold text-primary"
|
|
235
237
|
: "border-border text-foreground-secondary hover:text-foreground"), children: item.title }, item.id));
|
|
236
238
|
})] }));
|
|
237
239
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type MouseEvent, type ReactNode } from "react";
|
|
2
2
|
import type { FillContainerProps, GridCellProps, GridProps, HeadingProps, LinkProps, ProgressProps, SectionProps, StepBarProps, TextProps, WizardStepGroupProps } from "../../index.ts";
|
|
3
3
|
import "../react-css-custom-properties.ts";
|
|
4
|
-
export declare function DefaultSection({ id, title, subtitle, children, actions, variant, layout, testId, icon, }: SectionProps): ReactNode;
|
|
4
|
+
export declare function DefaultSection({ id, title, subtitle, subtitleBelowLgOnly, children, actions, variant, layout, testId, icon, }: SectionProps): ReactNode;
|
|
5
5
|
export declare function DefaultFillContainer({ children, testId, grow }: FillContainerProps): ReactNode;
|
|
6
6
|
export declare function DefaultGrid({ columns, children, testId, maxRows, flow, list, ariaLabelledBy, }: GridProps): ReactNode;
|
|
7
7
|
export declare function DefaultGridCell({ span, width, children }: GridCellProps): ReactNode;
|
|
@@ -9,7 +9,7 @@ import { StepBar } from "../widgets/step-bar.js";
|
|
|
9
9
|
import "../react-css-custom-properties.js";
|
|
10
10
|
import { cardSurface } from "./card-styles.js";
|
|
11
11
|
import { DrawerBodyContext, InsideFormContext, ScreenFormContext } from "./contexts.js";
|
|
12
|
-
export function DefaultSection({ id, title, subtitle, children, actions, variant = "default", layout = "stacked", testId, icon, }) {
|
|
12
|
+
export function DefaultSection({ id, title, subtitle, subtitleBelowLgOnly, children, actions, variant = "default", layout = "stacked", testId, icon, }) {
|
|
13
13
|
const insideForm = useContext(InsideFormContext);
|
|
14
14
|
const insideScreenForm = useContext(ScreenFormContext);
|
|
15
15
|
// h3 instead of CardTitle (= div): keeps the heading semantics for
|
|
@@ -21,7 +21,7 @@ export function DefaultSection({ id, title, subtitle, children, actions, variant
|
|
|
21
21
|
// footer — a title-less section still draws the row when actions are
|
|
22
22
|
// present, so a hideTitle tabs-Section with `actions` isn't stranded.
|
|
23
23
|
const TitleTag = insideScreenForm ? "h2" : "h3";
|
|
24
|
-
const titleBlock = title !== undefined || subtitle !== undefined ? (_jsxs("div", { className: "flex min-w-48 flex-1 flex-col gap-1", children: [title !== undefined && (_jsxs(TitleTag, { "data-testid": testId !== undefined ? `${testId}-title` : undefined, className: "flex items-center gap-2 text-base font-semibold leading-none tracking-tight", children: [icon !== undefined && _jsx(Icon, { name: icon, className: "size-4 text-muted-foreground" }), title] })), subtitle !== undefined && (_jsx("div", { "data-testid": testId !== undefined ? `${testId}-subtitle` : undefined, className: cn("text-sm text-muted-foreground", insideScreenForm && "text-[13px] text-foreground-secondary"), children: subtitle }))] })) : null;
|
|
24
|
+
const titleBlock = title !== undefined || subtitle !== undefined ? (_jsxs("div", { className: "flex min-w-48 flex-1 flex-col gap-1", children: [title !== undefined && (_jsxs(TitleTag, { "data-testid": testId !== undefined ? `${testId}-title` : undefined, className: "flex items-center gap-2 text-base font-semibold leading-none tracking-tight", children: [icon !== undefined && _jsx(Icon, { name: icon, className: "size-4 text-muted-foreground" }), title] })), subtitle !== undefined && (_jsx("div", { "data-testid": testId !== undefined ? `${testId}-subtitle` : undefined, className: cn("text-sm text-muted-foreground", insideScreenForm && "text-[13px] text-foreground-secondary", subtitleBelowLgOnly === true && "lg:hidden"), children: subtitle }))] })) : null;
|
|
25
25
|
const header = titleBlock !== null || actions !== undefined ? (_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-x-4 gap-y-3", children: [titleBlock, actions !== undefined && (_jsx("div", { "data-testid": testId !== undefined ? `${testId}-actions` : undefined, className: "ml-auto flex shrink-0 items-center gap-2", children: actions }))] })) : null;
|
|
26
26
|
// Inside a form: divider-less section WITHOUT a card surface of its own.
|
|
27
27
|
// The separator lines BETWEEN sections come from the divide-y wrapper in
|
|
@@ -190,5 +190,8 @@ export function DefaultHeading({ variant = "page", children, testId }) {
|
|
|
190
190
|
if (variant === "section") {
|
|
191
191
|
return (_jsx("h2", { "data-testid": testId, className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: children }));
|
|
192
192
|
}
|
|
193
|
+
if (variant === "group") {
|
|
194
|
+
return (_jsx("h2", { "data-testid": testId, className: "text-base font-semibold text-foreground", children: children }));
|
|
195
|
+
}
|
|
193
196
|
return (_jsx("h1", { "data-testid": testId, className: "text-2xl font-semibold tracking-tight", children: children }));
|
|
194
197
|
}
|
|
@@ -4,6 +4,7 @@ export type ScreenWidth = FormWidth;
|
|
|
4
4
|
export declare const screenWidthClassName: Record<ScreenWidth, string>;
|
|
5
5
|
export declare const screenFormColumnWidthClassName: Record<ScreenWidth, string>;
|
|
6
6
|
export declare const screenPaddingClassName = "px-4 pb-6 pt-5 md:px-10 md:pb-10 md:pt-7";
|
|
7
|
+
export declare const screenDockedBottomClassName = "sticky -bottom-6 -mb-6 mt-auto bg-card pb-6 md:-bottom-10 md:-mb-10 md:pb-10";
|
|
7
8
|
declare const STACK_GAP: {
|
|
8
9
|
readonly sm: "gap-2";
|
|
9
10
|
readonly md: "gap-4";
|
|
@@ -21,6 +21,10 @@ export const screenFormColumnWidthClassName = {
|
|
|
21
21
|
// at the same edge. The bottom inset keeps the last field or table row off the
|
|
22
22
|
// viewport edge.
|
|
23
23
|
export const screenPaddingClassName = "px-4 pb-6 pt-5 md:px-10 md:pb-10 md:pt-7";
|
|
24
|
+
// Sticky element at the bottom of a screen scroll that covers the bottom padding of
|
|
25
|
+
// screenPaddingClassName (sticky stops at the content box) and overlaps it at rest (negative margin).
|
|
26
|
+
// Keep offsets, margin and padding in step with it; bg-card is the surface of the main content area.
|
|
27
|
+
export const screenDockedBottomClassName = "sticky -bottom-6 -mb-6 mt-auto bg-card pb-6 md:-bottom-10 md:-mb-10 md:pb-10";
|
|
24
28
|
const STACK_GAP = { sm: "gap-2", md: "gap-4", lg: "gap-6" };
|
|
25
29
|
export function Stack({ gap = "md", className, children, testId }) {
|
|
26
30
|
return (_jsx("div", { "data-testid": testId, className: cn("flex flex-col", STACK_GAP[gap], className), children: children }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
2
|
+
import { Children, createContext, useContext } from "react";
|
|
3
3
|
import { Icon } from "../icons.js";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
import { STAT_CARD_GRID_CLASSES, StatCard } from "../widgets/stat.js";
|
|
@@ -11,7 +11,9 @@ export const InsideScreenFormColumnContext = createContext(false);
|
|
|
11
11
|
// Band column counts follow the board: 2 below md, 3 below lg, 5 from lg.
|
|
12
12
|
export function DefaultMetricBand({ lead, subtitle, children, testId, tiles, }) {
|
|
13
13
|
const insideScreenFormColumn = useContext(InsideScreenFormColumnContext);
|
|
14
|
-
|
|
14
|
+
const hasMetrics = Children.toArray(children).length > 0;
|
|
15
|
+
return (_jsxs("div", { className: cn("flex shrink-0 flex-col gap-3", !insideScreenFormColumn && "px-6 pb-4 pt-3.5"), "data-testid": testId, children: [lead !== undefined && _jsx("div", { "data-kumiko-layout": "metric-band-lead", children: lead }), subtitle !== undefined && (_jsx("div", { className: "flex flex-wrap items-center gap-x-2 text-[13px] text-foreground-secondary [&_a]:text-primary", children: subtitle })), hasMetrics &&
|
|
16
|
+
(tiles === true ? (_jsx("div", { className: STAT_CARD_GRID_CLASSES, children: children })) : (_jsx(InsideMetricBandContext.Provider, { value: true, children: _jsx("dl", { className: "m-0 grid grid-cols-2 gap-6 md:grid-cols-3 lg:grid-cols-5", children: children }) })))] }));
|
|
15
17
|
}
|
|
16
18
|
function MetricTile({ label, value, testId, onPress, tone, icon }) {
|
|
17
19
|
const card = (_jsx(StatCard, { label: label, value: value, ...(icon !== undefined && { icon: _jsx(Icon, { name: icon, className: "size-4" }) }), ...(tone !== undefined && { tone }), ...(testId !== undefined && { testId }) }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
/** Card-styled radio group for mutually exclusive choices that need a description or price line. */
|
|
3
|
-
export declare function ChoiceCards<T extends string>({ value, options, onChange, ariaLabel, testId, }: {
|
|
3
|
+
export declare function ChoiceCards<T extends string>({ value, options, onChange, ariaLabel, label, columns, variant, testId, }: {
|
|
4
4
|
/** `null`: nothing selected. */
|
|
5
5
|
readonly value: T | null;
|
|
6
6
|
readonly options: readonly {
|
|
@@ -13,5 +13,11 @@ export declare function ChoiceCards<T extends string>({ value, options, onChange
|
|
|
13
13
|
}[];
|
|
14
14
|
readonly onChange: (value: T) => void;
|
|
15
15
|
readonly ariaLabel?: string;
|
|
16
|
+
/** Visible group label in the field-label style (13px medium, foreground); names the group instead of `ariaLabel`. */
|
|
17
|
+
readonly label?: string;
|
|
18
|
+
/** Columns from the `sm` breakpoint, default 2. */
|
|
19
|
+
readonly columns?: 1 | 2 | 3 | 4;
|
|
20
|
+
/** `check` (default): check indicator top right. `radio`: radio indicator before the title. */
|
|
21
|
+
readonly variant?: "check" | "radio";
|
|
16
22
|
readonly testId?: string;
|
|
17
23
|
}): ReactNode;
|
|
@@ -2,11 +2,24 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Check } from "lucide-react";
|
|
3
3
|
import { useId } from "react";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
|
+
const CHOICE_COLUMNS_CLASS = {
|
|
6
|
+
1: "sm:grid-cols-1",
|
|
7
|
+
2: "sm:grid-cols-2",
|
|
8
|
+
3: "sm:grid-cols-3",
|
|
9
|
+
4: "sm:grid-cols-4",
|
|
10
|
+
};
|
|
5
11
|
/** Card-styled radio group for mutually exclusive choices that need a description or price line. */
|
|
6
|
-
export function ChoiceCards({ value, options, onChange, ariaLabel, testId, }) {
|
|
12
|
+
export function ChoiceCards({ value, options, onChange, ariaLabel, label, columns = 2, variant = "check", testId, }) {
|
|
7
13
|
const groupName = useId();
|
|
8
|
-
|
|
14
|
+
const labelId = `${groupName}-label`;
|
|
15
|
+
const group = (_jsx("div", { role: "radiogroup", "aria-label": label === undefined ? ariaLabel : undefined, "aria-labelledby": label !== undefined ? labelId : undefined, "data-testid": testId, className: cn("grid grid-cols-1 gap-2", CHOICE_COLUMNS_CLASS[columns]), children: options.map((option) => {
|
|
9
16
|
const selected = option.value === value;
|
|
10
|
-
|
|
17
|
+
const indicator = variant === "radio" ? (_jsx("span", { "aria-hidden": "true", className: cn("flex size-4 shrink-0 items-center justify-center rounded-full border", selected ? "border-primary" : "border-input"), children: selected && _jsx("span", { className: "size-2 rounded-full bg-primary" }) })) : (_jsx("span", { "aria-hidden": "true", className: cn("flex size-5 shrink-0 items-center justify-center rounded-full border", selected ? "border-primary bg-primary text-primary-foreground" : "border-input"), children: selected && _jsx(Check, { className: "size-3" }) }));
|
|
18
|
+
return (_jsxs("label", { "data-testid": testId !== undefined ? `${testId}-${option.value}` : undefined, className: cn("relative flex cursor-pointer flex-col gap-1 rounded-lg border bg-card p-4 transition-colors", "hover:bg-muted/50 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring", selected ? "border-primary ring-1 ring-primary" : "border-border", option.disabled && "cursor-not-allowed opacity-50"), children: [_jsx("input", { type: "radio", className: "sr-only", name: groupName, value: option.value, checked: selected, disabled: option.disabled, onChange: () => onChange(option.value) }), _jsxs("span", { className: "flex items-start justify-between gap-2", children: [_jsxs("span", { className: "flex items-center gap-2", children: [variant === "radio" && indicator, _jsx("span", { className: "font-semibold", children: option.title })] }), _jsxs("span", { className: "flex items-center gap-2", children: [option.aside !== undefined && (_jsx("span", { className: "font-semibold tabular-nums", children: option.aside })), variant === "check" && indicator] })] }), option.description !== undefined && (_jsx("span", { className: cn("text-sm text-muted-foreground",
|
|
19
|
+
// Aligns with the title: radio indicator size-4 plus gap-2.
|
|
20
|
+
variant === "radio" && "pl-6"), children: option.description }))] }, option.value));
|
|
11
21
|
}) }));
|
|
22
|
+
if (label === undefined)
|
|
23
|
+
return group;
|
|
24
|
+
return (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { id: labelId, className: "text-[13px] leading-none font-medium text-foreground", children: label }), group] }));
|
|
12
25
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type ComposerProps = {
|
|
3
|
+
readonly value: string;
|
|
4
|
+
readonly onChange: (value: string) => void;
|
|
5
|
+
readonly onSubmit: () => void;
|
|
6
|
+
readonly placeholder?: string;
|
|
7
|
+
readonly disabled?: boolean;
|
|
8
|
+
/** Text of the send button. */
|
|
9
|
+
readonly submitLabel: string;
|
|
10
|
+
/** Sticks to the bottom of a full-height flex-column parent so it stays visible while the thread scrolls; it also covers the bottom padding of the screen scroll. */
|
|
11
|
+
readonly docked?: boolean;
|
|
12
|
+
readonly rows?: number;
|
|
13
|
+
readonly testId?: string;
|
|
14
|
+
};
|
|
15
|
+
/** Chat input: a label-less textarea with a text send button inside the field frame, bottom right. */
|
|
16
|
+
export declare function Composer({ value, onChange, onSubmit, placeholder, disabled, submitLabel, docked, rows, testId, }: ComposerProps): ReactNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { usePrimitives } from "../../index.js";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { screenDockedBottomClassName } from "../primitives/layout.js";
|
|
5
|
+
/** Chat input: a label-less textarea with a text send button inside the field frame, bottom right. */
|
|
6
|
+
export function Composer({ value, onChange, onSubmit, placeholder, disabled, submitLabel, docked, rows = 2, testId, }) {
|
|
7
|
+
const { Button } = usePrimitives();
|
|
8
|
+
return (_jsx("div", { "data-testid": testId, className: cn(docked === true && screenDockedBottomClassName), children: _jsxs("div", { className: "flex flex-col rounded-md border border-input bg-card shadow-xs focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 dark:bg-input/30", children: [_jsx("textarea", { value: value, rows: rows, disabled: disabled, "aria-label": placeholder ?? submitLabel, onChange: (event) => onChange(event.target.value), className: "w-full resize-none bg-transparent px-3 pt-2 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50", ...(placeholder !== undefined && { placeholder }) }), _jsx("div", { className: "flex justify-end p-1.5", children: _jsx(Button, { size: "sm", disabled: disabled === true || value.trim() === "", onClick: onSubmit, ...(testId !== undefined && { testId: `${testId}-submit` }), children: submitLabel }) })] }) }));
|
|
9
|
+
}
|
|
@@ -2,9 +2,13 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* Read-only key-value list for detail views (dimmed label on the left, value on the right). The
|
|
4
4
|
* value is a ReactNode, so badges and chips are supported. `emphasize` highlights a row, such as
|
|
5
|
-
* the final result in a calculator.
|
|
5
|
+
* the final result in a calculator. `valueWeight="normal"` drops the value emphasis;
|
|
6
|
+
* `layout="sidebar"` keeps label (narrow column) and left-aligned value on one row, for narrow
|
|
7
|
+
* side columns.
|
|
6
8
|
*/
|
|
7
|
-
export declare function DetailList({ rows, testId, }: {
|
|
9
|
+
export declare function DetailList({ rows, testId, valueWeight, layout, }: {
|
|
10
|
+
readonly valueWeight?: "medium" | "normal";
|
|
11
|
+
readonly layout?: "default" | "sidebar";
|
|
8
12
|
readonly rows: readonly {
|
|
9
13
|
/** Optional stable key -- falls back to the label when omitted (fine as
|
|
10
14
|
* long as labels are unique; set id when they can repeat). */
|
|
@@ -3,8 +3,12 @@ import { cn } from "../lib/cn.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Read-only key-value list for detail views (dimmed label on the left, value on the right). The
|
|
5
5
|
* value is a ReactNode, so badges and chips are supported. `emphasize` highlights a row, such as
|
|
6
|
-
* the final result in a calculator.
|
|
6
|
+
* the final result in a calculator. `valueWeight="normal"` drops the value emphasis;
|
|
7
|
+
* `layout="sidebar"` keeps label (narrow column) and left-aligned value on one row, for narrow
|
|
8
|
+
* side columns.
|
|
7
9
|
*/
|
|
8
|
-
export function DetailList({ rows, testId, }) {
|
|
9
|
-
return (_jsx("dl", { "data-testid": testId, className: "@container flex flex-col divide-y", children: rows.map((row) => (_jsxs("div", { className:
|
|
10
|
+
export function DetailList({ rows, testId, valueWeight = "medium", layout = "default", }) {
|
|
11
|
+
return (_jsx("dl", { "data-testid": testId, className: "@container flex flex-col divide-y", children: rows.map((row) => (_jsxs("div", { className: layout === "sidebar"
|
|
12
|
+
? "grid grid-cols-[minmax(0,96px)_1fr] gap-3 py-2.5"
|
|
13
|
+
: "grid grid-cols-1 gap-0.5 py-2.5 @md:grid-cols-[200px_1fr] @md:gap-4", children: [_jsx("dt", { className: cn("text-sm text-muted-foreground", row.emphasize === true && "font-semibold text-foreground"), children: row.label }), _jsx("dd", { className: cn("text-sm", valueWeight === "medium" && "font-medium", row.emphasize === true && "font-semibold"), children: row.value })] }, row.id ?? row.label))) }));
|
|
10
14
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type FloatingPanelGeometry } from "./floating-panel-geometry.ts";
|
|
3
3
|
export type { FloatingPanelGeometry } from "./floating-panel-geometry.ts";
|
|
4
|
+
export type FloatingPanelPlacement = {
|
|
5
|
+
readonly mode: "free";
|
|
6
|
+
} | {
|
|
7
|
+
readonly mode: "fixed";
|
|
8
|
+
readonly rightPx: number;
|
|
9
|
+
readonly bottomPx: number;
|
|
10
|
+
readonly widthPx: number;
|
|
11
|
+
readonly heightPx: number;
|
|
12
|
+
};
|
|
4
13
|
export type FloatingPanelProps = {
|
|
5
14
|
/** Header content; the header is the move handle. */
|
|
6
15
|
readonly title: ReactNode;
|
|
@@ -18,9 +27,15 @@ export type FloatingPanelProps = {
|
|
|
18
27
|
readonly maxWidthPx?: number;
|
|
19
28
|
/** Default: viewport height minus twice the margin. */
|
|
20
29
|
readonly maxHeightPx?: number;
|
|
30
|
+
/** "fixed" anchors the panel to the bottom right: no drag, no resize, nothing persisted. Default: free. */
|
|
31
|
+
readonly placement?: FloatingPanelPlacement;
|
|
32
|
+
/** "scroll" (default) pads and scrolls the body; "fill" gives children the whole body to pad and scroll themselves. */
|
|
33
|
+
readonly bodyLayout?: "scroll" | "fill";
|
|
34
|
+
/** "ai" paints header and body with the AI surface. */
|
|
35
|
+
readonly surface?: "default" | "ai";
|
|
21
36
|
readonly testId?: string;
|
|
22
37
|
};
|
|
23
38
|
/** Non-modal panel floating above the page: draggable by its header,
|
|
24
39
|
* resizable from all edges and corners, clamped to the viewport, geometry
|
|
25
40
|
* optionally remembered. On narrow viewports it becomes a full-screen sheet. */
|
|
26
|
-
export declare function FloatingPanel({ title, headerActions, children, storageKey, defaultGeometry, minWidthPx, minHeightPx, maxWidthPx, maxHeightPx, testId, }: FloatingPanelProps): ReactNode;
|
|
41
|
+
export declare function FloatingPanel({ title, headerActions, children, storageKey, defaultGeometry, minWidthPx, minHeightPx, maxWidthPx, maxHeightPx, placement, bodyLayout, surface, testId, }: FloatingPanelProps): ReactNode;
|
|
@@ -7,6 +7,11 @@ import { cn } from "../lib/cn.js";
|
|
|
7
7
|
import { useIsNarrowViewport } from "../primitives/use-narrow-viewport.js";
|
|
8
8
|
import { FLOATING_PANEL_MARGIN_PX, fitGeometry, readLimits, refitToViewport, resizeGeometry, } from "./floating-panel-geometry.js";
|
|
9
9
|
import { arrowKeyDelta, usePointerDrag } from "./use-pointer-drag.js";
|
|
10
|
+
const BODY_LAYOUT_CLASS = {
|
|
11
|
+
scroll: "min-h-0 flex-1 overflow-auto p-4",
|
|
12
|
+
fill: "flex min-h-0 flex-1 flex-col overflow-hidden",
|
|
13
|
+
};
|
|
14
|
+
const FREE_PLACEMENT = { mode: "free" };
|
|
10
15
|
const DEFAULT_WIDTH_PX = 400;
|
|
11
16
|
const DEFAULT_HEIGHT_PX = 560;
|
|
12
17
|
const EDGES = ["top", "right", "bottom", "left"];
|
|
@@ -97,14 +102,17 @@ function initialGeometry(storageKey, defaults, limits) {
|
|
|
97
102
|
/** Non-modal panel floating above the page: draggable by its header,
|
|
98
103
|
* resizable from all edges and corners, clamped to the viewport, geometry
|
|
99
104
|
* optionally remembered. On narrow viewports it becomes a full-screen sheet. */
|
|
100
|
-
export function FloatingPanel({ title, headerActions, children, storageKey, defaultGeometry, minWidthPx, minHeightPx, maxWidthPx, maxHeightPx, testId, }) {
|
|
105
|
+
export function FloatingPanel({ title, headerActions, children, storageKey, defaultGeometry, minWidthPx, minHeightPx, maxWidthPx, maxHeightPx, placement = FREE_PLACEMENT, bodyLayout = "scroll", surface = "default", testId, }) {
|
|
101
106
|
const t = useTranslation();
|
|
102
107
|
const narrow = useIsNarrowViewport();
|
|
108
|
+
const fixedPlacement = placement.mode === "fixed" ? placement : undefined;
|
|
109
|
+
const bodyClass = BODY_LAYOUT_CLASS[bodyLayout];
|
|
110
|
+
const aiSurface = surface === "ai";
|
|
103
111
|
const titleId = useId();
|
|
104
112
|
const getLimits = () => readLimits({ minWidthPx, minHeightPx, maxWidthPx, maxHeightPx });
|
|
105
113
|
const getLimitsRef = useRef(getLimits);
|
|
106
114
|
getLimitsRef.current = getLimits;
|
|
107
|
-
const [geometry, setGeometry] = useState(() => initialGeometry(storageKey, defaultGeometry, getLimits()));
|
|
115
|
+
const [geometry, setGeometry] = useState(() => initialGeometry(fixedPlacement === undefined ? storageKey : undefined, defaultGeometry, getLimits()));
|
|
108
116
|
const geometryRef = useRef(geometry);
|
|
109
117
|
geometryRef.current = geometry;
|
|
110
118
|
// The viewport the current geometry was last fitted to; null until the first fit.
|
|
@@ -115,7 +123,7 @@ export function FloatingPanel({ title, headerActions, children, storageKey, defa
|
|
|
115
123
|
}, []);
|
|
116
124
|
const persistGeometry = () => writeStoredGeometry(storageKey, geometryRef.current);
|
|
117
125
|
useEffect(() => {
|
|
118
|
-
if (narrow)
|
|
126
|
+
if (narrow || fixedPlacement !== undefined)
|
|
119
127
|
return;
|
|
120
128
|
const onWindowResize = () => {
|
|
121
129
|
const limits = getLimitsRef.current();
|
|
@@ -129,7 +137,7 @@ export function FloatingPanel({ title, headerActions, children, storageKey, defa
|
|
|
129
137
|
onWindowResize();
|
|
130
138
|
window.addEventListener("resize", onWindowResize);
|
|
131
139
|
return () => window.removeEventListener("resize", onWindowResize);
|
|
132
|
-
}, [narrow, applyGeometry]);
|
|
140
|
+
}, [narrow, fixedPlacement, applyGeometry]);
|
|
133
141
|
const moveDrag = usePointerDrag({
|
|
134
142
|
onStart: () => geometryRef.current,
|
|
135
143
|
onMove: (start, { dx, dy }) => applyGeometry(fitGeometry({ ...start, x: start.x + dx, y: start.y + dy }, getLimits())),
|
|
@@ -158,7 +166,15 @@ export function FloatingPanel({ title, headerActions, children, storageKey, defa
|
|
|
158
166
|
if (typeof document === "undefined")
|
|
159
167
|
return null;
|
|
160
168
|
if (narrow) {
|
|
161
|
-
return createPortal(_jsxs("div", { role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, "data-testid": testId, className: "fixed inset-0 z-50 flex flex-col bg-
|
|
169
|
+
return createPortal(_jsxs("div", { role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, "data-testid": testId, className: cn("fixed inset-0 z-50 flex flex-col text-foreground", aiSurface ? "bg-ai-surface" : "bg-background"), children: [_jsxs("div", { className: "flex shrink-0 items-center gap-2 border-b px-3 py-2", children: [_jsx("div", { id: titleId, className: "min-w-0 flex-1 truncate font-medium", children: title }), headerActions] }), _jsx("div", { className: bodyClass, children: children })] }), document.body);
|
|
170
|
+
}
|
|
171
|
+
if (fixedPlacement !== undefined) {
|
|
172
|
+
return createPortal(_jsxs("div", { role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, "data-testid": testId, className: cn("fixed z-50 flex flex-col overflow-hidden rounded-lg border text-foreground shadow-2xl", aiSurface ? "bg-ai-surface" : "bg-background"), style: {
|
|
173
|
+
right: fixedPlacement.rightPx,
|
|
174
|
+
bottom: fixedPlacement.bottomPx,
|
|
175
|
+
width: `min(${fixedPlacement.widthPx}px, calc(100vw - ${2 * FLOATING_PANEL_MARGIN_PX}px))`,
|
|
176
|
+
height: `min(${fixedPlacement.heightPx}px, calc(100vh - ${fixedPlacement.bottomPx + FLOATING_PANEL_MARGIN_PX}px))`,
|
|
177
|
+
}, children: [_jsxs("div", { className: cn("flex shrink-0 items-center gap-2 border-b px-3 py-2", aiSurface ? "bg-ai-surface" : "bg-muted"), children: [_jsx("div", { id: titleId, className: "min-w-0 flex-1 truncate font-medium", children: title }), headerActions] }), _jsx("div", { className: bodyClass, children: children })] }), document.body);
|
|
162
178
|
}
|
|
163
179
|
const limits = getLimits();
|
|
164
180
|
const handleContext = {
|
|
@@ -167,12 +183,12 @@ export function FloatingPanel({ title, headerActions, children, storageKey, defa
|
|
|
167
183
|
applyGeometry,
|
|
168
184
|
persistGeometry,
|
|
169
185
|
};
|
|
170
|
-
return createPortal(_jsxs("div", { role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, "data-testid": testId, className: "fixed z-50 flex flex-col overflow-hidden rounded-lg border
|
|
186
|
+
return createPortal(_jsxs("div", { role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, "data-testid": testId, className: cn("fixed z-50 flex flex-col overflow-hidden rounded-lg border text-foreground shadow-2xl", aiSurface ? "bg-ai-surface" : "bg-background"), style: {
|
|
171
187
|
left: geometry.x,
|
|
172
188
|
top: geometry.y,
|
|
173
189
|
width: geometry.width,
|
|
174
190
|
height: geometry.height,
|
|
175
|
-
}, children: [_jsxs("div", { ...moveDrag, onPointerDown: onHeaderPointerDown, className: "flex shrink-0 cursor-grab touch-none select-none items-center gap-2 border-b
|
|
191
|
+
}, children: [_jsxs("div", { ...moveDrag, onPointerDown: onHeaderPointerDown, className: cn("flex shrink-0 cursor-grab touch-none select-none items-center gap-2 border-b px-3 py-2 active:cursor-grabbing", aiSurface ? "bg-ai-surface" : "bg-muted"), children: [_jsx("button", { type: "button", "data-drag-handle": "", "aria-label": t("kumiko.widget.floatingPanel.move"), onKeyDown: onGripKeyDown, className: "rounded-xs p-1 text-muted-foreground hover:bg-secondary focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-hidden", children: _jsx(GripVerticalIcon, { className: "size-4" }) }), _jsx("div", { id: titleId, className: "min-w-0 flex-1 truncate font-medium", children: title }), headerActions] }), _jsx("div", { className: bodyClass, children: children }), EDGES.map((edge) => (_jsx(PanelResizeHandle, { edges: [edge], className: EDGE_HANDLE_CLASS[edge], context: handleContext, separator: { label: t(EDGE_LABEL_KEYS[edge]), geometry, limits } }, edge))), CORNER_HANDLES.map((corner) => (_jsx(PanelResizeHandle, { edges: corner.edges, className: corner.className, context: handleContext }, corner.edges.join("-"))))] }), document.body);
|
|
176
192
|
}
|
|
177
193
|
function PanelResizeHandle({ edges, className, context, separator, }) {
|
|
178
194
|
const drag = usePointerDrag({
|
|
@@ -64,9 +64,10 @@ export interface TextareaFieldProps extends FieldBase {
|
|
|
64
64
|
readonly value: string;
|
|
65
65
|
readonly onChange: (v: string) => void;
|
|
66
66
|
readonly rows?: number;
|
|
67
|
+
readonly placeholder?: string;
|
|
67
68
|
}
|
|
68
69
|
/** Multi-line text field = Field + Input(kind:"textarea"). */
|
|
69
|
-
export declare function TextareaField({ label, id, name, value, onChange, rows, required, disabled, hideLabel, testId, }: TextareaFieldProps): ReactNode;
|
|
70
|
+
export declare function TextareaField({ label, id, name, value, onChange, rows, placeholder, required, disabled, hideLabel, testId, }: TextareaFieldProps): ReactNode;
|
|
70
71
|
export interface RangeFieldProps extends FieldBase {
|
|
71
72
|
readonly value: number;
|
|
72
73
|
readonly onChange: (v: number) => void;
|
|
@@ -35,9 +35,9 @@ export function BooleanField({ label, id, name, value, onChange, required, disab
|
|
|
35
35
|
return (_jsx(Field, { id: id, label: label, required: required, layout: "inline", hideLabel: hideLabel, testId: testId, children: _jsx(Input, { kind: "boolean", id: id, name: name, value: value, onChange: onChange, required: required, disabled: disabled }) }));
|
|
36
36
|
}
|
|
37
37
|
/** Multi-line text field = Field + Input(kind:"textarea"). */
|
|
38
|
-
export function TextareaField({ label, id, name, value, onChange, rows, required, disabled, hideLabel, testId, }) {
|
|
38
|
+
export function TextareaField({ label, id, name, value, onChange, rows, placeholder, required, disabled, hideLabel, testId, }) {
|
|
39
39
|
const { Field, Input } = usePrimitives();
|
|
40
|
-
return (_jsx(Field, { id: id, label: label, required: required, hideLabel: hideLabel, testId: testId, children: _jsx(Input, { kind: "textarea", id: id, name: name, value: value, onChange: onChange, required: required, disabled: disabled, ...(rows !== undefined && { rows }) }) }));
|
|
40
|
+
return (_jsx(Field, { id: id, label: label, required: required, hideLabel: hideLabel, testId: testId, children: _jsx(Input, { kind: "textarea", id: id, name: name, value: value, onChange: onChange, required: required, disabled: disabled, ...(rows !== undefined && { rows }), ...(placeholder !== undefined && { placeholder }) }) }));
|
|
41
41
|
}
|
|
42
42
|
/** Slider = Field + Input(kind:"range"). */
|
|
43
43
|
export function RangeField({ label, id, name, value, onChange, min, max, step, required, disabled, hideLabel, testId, }) {
|
|
@@ -7,11 +7,12 @@ export { type ChartMarker, type ChartSeries, type ChartTone, SegmentBarChart, ty
|
|
|
7
7
|
export { ChoiceCards } from "./choice-cards.tsx";
|
|
8
8
|
export { ClampedText } from "./clamped-text.tsx";
|
|
9
9
|
export { CollapsibleSection } from "./collapsible-section.tsx";
|
|
10
|
+
export { Composer, type ComposerProps } from "./composer.tsx";
|
|
10
11
|
export { type DashboardListColumn, DashboardListTable } from "./dashboard-list.tsx";
|
|
11
12
|
export { DetailList } from "./detail-list.tsx";
|
|
12
13
|
export { Drawer, type DrawerProps } from "./drawer.tsx";
|
|
13
14
|
export { FeedList, type FeedRow } from "./feed-list.tsx";
|
|
14
|
-
export { FloatingPanel, type FloatingPanelGeometry, type FloatingPanelProps, } from "./floating-panel.tsx";
|
|
15
|
+
export { FloatingPanel, type FloatingPanelGeometry, type FloatingPanelPlacement, type FloatingPanelProps, } from "./floating-panel.tsx";
|
|
15
16
|
export { BooleanField, type BooleanFieldProps, DateField, type DateFieldProps, FileField, type FileFieldProps, MoneyField, NumberField, type NumberFieldProps, PercentField, RangeField, type RangeFieldProps, SelectField, type SelectFieldProps, TextareaField, type TextareaFieldProps, TextField, type TextFieldProps, } from "./form-fields.tsx";
|
|
16
17
|
export { InfinityList, type InfinityListProps, type InfinityListSelection, } from "./infinity-list.tsx";
|
|
17
18
|
export { MessageReader } from "./message-reader.tsx";
|
|
@@ -27,12 +28,13 @@ export { PublicShell, type PublicShellProps, type PublicShellVariant } from "./p
|
|
|
27
28
|
export { QueryTable, type QueryTableColumn, type QueryTableProps } from "./query-table.tsx";
|
|
28
29
|
export { type ComparisonMetric, ComparisonTable, type ResultColumn, ResultPanel, ResultTable, } from "./result-panel.tsx";
|
|
29
30
|
export { SectionCard } from "./section-card.tsx";
|
|
31
|
+
export { SectionNavLayout, type SectionNavLayoutProps } from "./section-nav-layout.tsx";
|
|
30
32
|
export { SideBySideTable, type SideBySideTableCell, type SideBySideTableColumn, type SideBySideTableRow, } from "./side-by-side-table.tsx";
|
|
31
33
|
export { MiniStat, Sparkline, StatCard, type StatDelta, StatStripCell, type StatTone, } from "./stat.tsx";
|
|
32
34
|
export { EmptyState, ErrorState, LoadingState } from "./states.tsx";
|
|
33
35
|
export { STATUS_TONE_TEXT, StatusBadge, type StatusBadgeTone, type StatusTone, } from "./status-badge.tsx";
|
|
34
36
|
export { StepBar } from "./step-bar.tsx";
|
|
35
|
-
export { type StepAction, StepList, type StepListItem, type StepListProps, type StepSource, type StepStatus, type StepTag, } from "./step-list.tsx";
|
|
37
|
+
export { type StepAction, StepList, type StepListItem, type StepListProps, type StepListSelection, type StepSelectability, type StepSelectionAction, type StepSource, type StepStatus, type StepTag, } from "./step-list.tsx";
|
|
36
38
|
export { AiSurface, SenderFrame, SenderSheet } from "./surfaces.tsx";
|
|
37
39
|
export { UploadZone, type UploadZoneProps } from "./upload-zone.tsx";
|
|
38
40
|
export { useDraft } from "./use-draft.ts";
|
|
@@ -9,6 +9,7 @@ export { SegmentBarChart, StackedAreaChart, StackedBarChart, StatusBarChart, smo
|
|
|
9
9
|
export { ChoiceCards } from "./choice-cards.js";
|
|
10
10
|
export { ClampedText } from "./clamped-text.js";
|
|
11
11
|
export { CollapsibleSection } from "./collapsible-section.js";
|
|
12
|
+
export { Composer } from "./composer.js";
|
|
12
13
|
export { DashboardListTable } from "./dashboard-list.js";
|
|
13
14
|
export { DetailList } from "./detail-list.js";
|
|
14
15
|
export { Drawer } from "./drawer.js";
|
|
@@ -29,6 +30,7 @@ export { PublicShell } from "./public-shell.js";
|
|
|
29
30
|
export { QueryTable } from "./query-table.js";
|
|
30
31
|
export { ComparisonTable, ResultPanel, ResultTable, } from "./result-panel.js";
|
|
31
32
|
export { SectionCard } from "./section-card.js";
|
|
33
|
+
export { SectionNavLayout } from "./section-nav-layout.js";
|
|
32
34
|
export { SideBySideTable, } from "./side-by-side-table.js";
|
|
33
35
|
export { MiniStat, Sparkline, StatCard, StatStripCell, } from "./stat.js";
|
|
34
36
|
export { EmptyState, ErrorState, LoadingState } from "./states.js";
|
|
@@ -2,7 +2,7 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
export type ModeSwitchVariant = "outline" | "pill";
|
|
3
3
|
/** Segmented control for mutually exclusive modes—the prominent
|
|
4
4
|
* alternative to the buried <select>. */
|
|
5
|
-
export declare function ModeSwitch<T extends string>({ value, options, onChange, ariaLabel, variant, className, testId, }: {
|
|
5
|
+
export declare function ModeSwitch<T extends string>({ value, options, onChange, ariaLabel, variant, segmentWidth, className, testId, }: {
|
|
6
6
|
/** `null`: no option active. */
|
|
7
7
|
readonly value: T | null;
|
|
8
8
|
readonly options: readonly {
|
|
@@ -10,12 +10,18 @@ export declare function ModeSwitch<T extends string>({ value, options, onChange,
|
|
|
10
10
|
readonly label: string;
|
|
11
11
|
/** Muted tabular counter after the label. */
|
|
12
12
|
readonly count?: number;
|
|
13
|
+
/** Not selectable: aria-disabled, muted, no click. */
|
|
14
|
+
readonly disabled?: boolean;
|
|
15
|
+
/** `warning` frames the whole switch to flag an open question. */
|
|
16
|
+
readonly tone?: "warning";
|
|
13
17
|
}[];
|
|
14
18
|
readonly onChange: (value: T) => void;
|
|
15
19
|
readonly ariaLabel?: string;
|
|
16
20
|
/** `outline` (default): bordered segments, active tinted. `pill`: grey
|
|
17
21
|
* track with a raised active segment. */
|
|
18
22
|
readonly variant?: ModeSwitchVariant;
|
|
23
|
+
/** `wide` gives every segment a minimum width of 80px. */
|
|
24
|
+
readonly segmentWidth?: "auto" | "wide";
|
|
19
25
|
readonly className?: string;
|
|
20
26
|
readonly testId?: string;
|
|
21
27
|
}): ReactNode;
|
|
@@ -2,24 +2,31 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
/** Segmented control for mutually exclusive modes—the prominent
|
|
4
4
|
* alternative to the buried <select>. */
|
|
5
|
-
export function ModeSwitch({ value, options, onChange, ariaLabel, variant = "outline", className, testId, }) {
|
|
5
|
+
export function ModeSwitch({ value, options, onChange, ariaLabel, variant = "outline", segmentWidth = "auto", className, testId, }) {
|
|
6
6
|
const pill = variant === "pill";
|
|
7
|
+
const warning = options.some((o) => o.tone === "warning");
|
|
7
8
|
return (_jsx("div", { "data-testid": testId, role: "group", "aria-label": ariaLabel, className: cn("flex min-h-8", pill
|
|
8
9
|
? "gap-0.5 rounded-lg bg-muted p-0.5"
|
|
9
|
-
: "overflow-hidden rounded-md border border-input bg-
|
|
10
|
+
: "overflow-hidden rounded-md border border-input bg-transparent dark:bg-input/30", warning && "ring-1 ring-inset ring-status-warn", className), children: options.map((o) => {
|
|
10
11
|
const active = o.value === value;
|
|
11
|
-
|
|
12
|
+
const disabled = o.disabled === true;
|
|
13
|
+
return (_jsxs("button", { type: "button", "aria-pressed": active, "aria-disabled": disabled || undefined, onClick: () => {
|
|
14
|
+
if (!disabled)
|
|
15
|
+
onChange(o.value);
|
|
16
|
+
}, className: cn("grow px-3 text-sm transition-colors", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", disabled && "cursor-not-allowed opacity-50", segmentWidth === "wide" && "min-w-20", pill
|
|
12
17
|
? [
|
|
13
18
|
"rounded-md",
|
|
14
19
|
active
|
|
15
20
|
? "bg-card font-semibold text-foreground shadow-sm dark:bg-foreground/10"
|
|
16
|
-
: "text-muted-foreground hover:text-foreground",
|
|
21
|
+
: cn("text-muted-foreground", !disabled && "hover:text-foreground"),
|
|
17
22
|
]
|
|
18
23
|
: [
|
|
19
24
|
"border-l border-input first:border-l-0",
|
|
20
25
|
active
|
|
21
26
|
? "bg-primary/10 font-semibold text-primary"
|
|
22
|
-
:
|
|
27
|
+
: disabled
|
|
28
|
+
? "text-muted-foreground"
|
|
29
|
+
: "text-foreground hover:bg-muted",
|
|
23
30
|
]), children: [o.label, o.count !== undefined && (_jsx("span", { "data-testid": testId !== undefined ? `${testId}-count-${o.value}` : undefined, className: cn("ml-1.5 font-normal tabular-nums", !active && "text-muted-foreground"), children: o.count }))] }, o.value));
|
|
24
31
|
}) }));
|
|
25
32
|
}
|
|
@@ -31,7 +31,7 @@ export interface ResultTableFooterRow {
|
|
|
31
31
|
* Avoids repeating the `<table>`+tabular-nums pattern in each screen.
|
|
32
32
|
* ponytail: intentionally minimal and read-only—for sorting, paging, or facets,
|
|
33
33
|
* use usePrimitives().DataTable or QueryTable instead. */
|
|
34
|
-
export declare function ResultTable<Row>({ columns, rows, rowKey, testId, className, card, footer, }: {
|
|
34
|
+
export declare function ResultTable<Row>({ columns, rows, rowKey, testId, className, card, footer, compactHeader, }: {
|
|
35
35
|
readonly columns: readonly ResultColumn<Row>[];
|
|
36
36
|
readonly rows: readonly Row[];
|
|
37
37
|
readonly rowKey: (row: Row, index: number) => string;
|
|
@@ -45,6 +45,8 @@ export declare function ResultTable<Row>({ columns, rows, rowKey, testId, classN
|
|
|
45
45
|
* column-alignment to the last (typically "Amount") column instead of
|
|
46
46
|
* approximating it with an independent layout. */
|
|
47
47
|
readonly footer?: readonly ResultTableFooterRow[];
|
|
48
|
+
/** Renders the header row in 12px semibold, like the DataTable option of the same name. Default off. */
|
|
49
|
+
readonly compactHeader?: boolean;
|
|
48
50
|
}): ReactNode;
|
|
49
51
|
export interface ComparisonMetric<Col> {
|
|
50
52
|
readonly label: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { usePrimitives } from "../../index.js";
|
|
3
3
|
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { COMPACT_HEADER_CLASS } from "../primitives/data-table/sortable-header.js";
|
|
4
5
|
import { DetailList } from "./detail-list.js";
|
|
5
6
|
import { SectionCard } from "./section-card.js";
|
|
6
7
|
/** Result section for a calculator: SectionCard with an empty state (Banner)
|
|
@@ -14,8 +15,8 @@ export function ResultPanel({ title, subtitle, empty, emptyText, rows, footer, c
|
|
|
14
15
|
* Avoids repeating the `<table>`+tabular-nums pattern in each screen.
|
|
15
16
|
* ponytail: intentionally minimal and read-only—for sorting, paging, or facets,
|
|
16
17
|
* use usePrimitives().DataTable or QueryTable instead. */
|
|
17
|
-
export function ResultTable({ columns, rows, rowKey, testId, className, card, footer, }) {
|
|
18
|
-
const table = (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { "data-testid": testId, className: cn("w-full text-sm", className), children: [_jsx("thead", { className: cn(card === true && "bg-muted"), children: _jsx("tr", { className: "border-b text-left text-muted-foreground", children: columns.map((col) => (_jsx("th", { className: cn("py-1.5 font-medium", card === true && "px-3", col.align === "right" && "text-right"), children: col.header }, col.header))) }) }), _jsxs("tbody", { children: [rows.map((row, i) => (_jsx("tr", { className: "border-b last:border-0", children: columns.map((col) => (_jsx("td", { className: cn("py-1.5", card === true && "px-3", col.align === "right" && "text-right tabular-nums"), children: col.cell(row) }, col.header))) }, rowKey(row, i)))), footer?.map((row, i) => (_jsxs("tr", { className: cn(i === 0 && "border-t", row.emphasize === true && "font-semibold"), children: [_jsxs("td", { colSpan: columns.length > 1 ? Math.max(columns.length - 1, 1) : undefined, className: cn("py-1.5 text-muted-foreground", card === true && "px-3", row.emphasize === true && "text-foreground", columns.length === 1 && "flex items-center justify-between gap-4"), children: [row.label, columns.length === 1 && (_jsx("span", { className: cn("text-right tabular-nums", row.emphasize === true && "text-foreground"), children: row.value }))] }), columns.length > 1 && (_jsx("td", { className: cn("py-1.5 text-right tabular-nums", card === true && "px-3"), children: row.value }))] }, row.label)))] })] }) }));
|
|
18
|
+
export function ResultTable({ columns, rows, rowKey, testId, className, card, footer, compactHeader, }) {
|
|
19
|
+
const table = (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { "data-testid": testId, className: cn("w-full text-sm", className), children: [_jsx("thead", { className: cn(card === true && "bg-muted"), children: _jsx("tr", { className: "border-b text-left text-muted-foreground", children: columns.map((col) => (_jsx("th", { className: cn("py-1.5 font-medium", card === true && "px-3", compactHeader === true && COMPACT_HEADER_CLASS, col.align === "right" && "text-right"), children: col.header }, col.header))) }) }), _jsxs("tbody", { children: [rows.map((row, i) => (_jsx("tr", { className: "border-b last:border-0", children: columns.map((col) => (_jsx("td", { className: cn("py-1.5", card === true && "px-3", col.align === "right" && "text-right tabular-nums"), children: col.cell(row) }, col.header))) }, rowKey(row, i)))), footer?.map((row, i) => (_jsxs("tr", { className: cn(i === 0 && "border-t", row.emphasize === true && "font-semibold"), children: [_jsxs("td", { colSpan: columns.length > 1 ? Math.max(columns.length - 1, 1) : undefined, className: cn("py-1.5 text-muted-foreground", card === true && "px-3", row.emphasize === true && "text-foreground", columns.length === 1 && "flex items-center justify-between gap-4"), children: [row.label, columns.length === 1 && (_jsx("span", { className: cn("text-right tabular-nums", row.emphasize === true && "text-foreground"), children: row.value }))] }), columns.length > 1 && (_jsx("td", { className: cn("py-1.5 text-right tabular-nums", card === true && "px-3"), children: row.value }))] }, row.label)))] })] }) }));
|
|
19
20
|
return card === true ? (_jsx("div", { className: "overflow-hidden rounded-lg border bg-card", children: table })) : (table);
|
|
20
21
|
}
|
|
21
22
|
/** Transposed comparison table: row = metric, column = variant, with the best
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { FormSectionNavItem } from "../../primitives.tsx";
|
|
3
|
+
import { screenFormColumnWidthClassName } from "../primitives/layout.tsx";
|
|
4
|
+
export type SectionNavLayoutProps = {
|
|
5
|
+
/** One entry per section; `id` must equal the DOM `id` of the section element in `children`. */
|
|
6
|
+
readonly items: readonly FormSectionNavItem[];
|
|
7
|
+
readonly children: ReactNode;
|
|
8
|
+
/** Content column width, default "4xl". */
|
|
9
|
+
readonly width?: keyof typeof screenFormColumnWidthClassName;
|
|
10
|
+
readonly testId?: string;
|
|
11
|
+
};
|
|
12
|
+
/** Content column plus an "On this page" navigation in a right column (from xl), for custom
|
|
13
|
+
* screens. The same navigation the screen forms use; the active entry follows the scroll position. */
|
|
14
|
+
export declare function SectionNavLayout({ items, children, width, testId, }: SectionNavLayoutProps): ReactNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { FormSectionNav } from "../primitives/form.js";
|
|
4
|
+
import { screenFormColumnWidthClassName } from "../primitives/layout.js";
|
|
5
|
+
/** Content column plus an "On this page" navigation in a right column (from xl), for custom
|
|
6
|
+
* screens. The same navigation the screen forms use; the active entry follows the scroll position. */
|
|
7
|
+
export function SectionNavLayout({ items, children, width = "4xl", testId, }) {
|
|
8
|
+
return (_jsxs("div", { "data-testid": testId, className: "flex gap-18", children: [_jsx("div", { className: cn("flex w-full min-w-0 flex-col gap-9", screenFormColumnWidthClassName[width]), children: children }), items.length > 0 && _jsx(FormSectionNav, { items: items, activeTone: "foreground" })] }));
|
|
9
|
+
}
|
|
@@ -20,12 +20,14 @@ export type SideBySideTableRow = {
|
|
|
20
20
|
* are arbitrary React nodes — for side-by-side comparisons like "from the
|
|
21
21
|
* document" vs. "in stock". Not a `DataTable`: no sorting, paging, or
|
|
22
22
|
* view-model columns. */
|
|
23
|
-
export declare function SideBySideTable({ caption, rowHeaderLabel, columns, rows, rowHeaderWidth, testId, }: {
|
|
23
|
+
export declare function SideBySideTable({ caption, rowHeaderLabel, columns, rows, rowHeaderWidth, rowHeaderTone, testId, }: {
|
|
24
24
|
/** Accessible name of the table, not rendered visibly. */
|
|
25
25
|
readonly caption: string;
|
|
26
26
|
readonly rowHeaderLabel: string;
|
|
27
27
|
readonly columns: readonly SideBySideTableColumn[];
|
|
28
28
|
readonly rows: readonly SideBySideTableRow[];
|
|
29
29
|
readonly rowHeaderWidth?: number;
|
|
30
|
+
/** `foreground` renders the row headers in the normal text colour instead of muted. */
|
|
31
|
+
readonly rowHeaderTone?: "muted" | "foreground";
|
|
30
32
|
readonly testId?: string;
|
|
31
33
|
}): ReactNode;
|
|
@@ -4,8 +4,8 @@ import { cn } from "../lib/cn.js";
|
|
|
4
4
|
* are arbitrary React nodes — for side-by-side comparisons like "from the
|
|
5
5
|
* document" vs. "in stock". Not a `DataTable`: no sorting, paging, or
|
|
6
6
|
* view-model columns. */
|
|
7
|
-
export function SideBySideTable({ caption, rowHeaderLabel, columns, rows, rowHeaderWidth = 120, testId, }) {
|
|
7
|
+
export function SideBySideTable({ caption, rowHeaderLabel, columns, rows, rowHeaderWidth = 120, rowHeaderTone = "muted", testId, }) {
|
|
8
8
|
return (_jsxs("table", { "data-testid": testId, className: "w-full table-fixed border-collapse border border-border text-sm", children: [_jsx("caption", { className: "sr-only", children: caption }), _jsx("thead", { children: _jsxs("tr", { className: "bg-muted text-[13px] text-muted-foreground", children: [_jsx("th", { scope: "col", style: { width: rowHeaderWidth }, className: "border-b border-border px-3 py-2 text-left font-medium", children: rowHeaderLabel }), columns.map((column) => (_jsx("th", { scope: "col", className: "border-b border-border px-3 py-2 text-left font-medium", children: column.label }, column.id)))] }) }), _jsx("tbody", { children: rows.map((row) => (_jsxs("tr", { className: cn(row.tone === "warn" && "bg-status-warn-surface"), children: [_jsx("th", { scope: "row", className: cn("border-b border-border-row px-3 py-2 text-left align-top", row.tone === "warn"
|
|
9
9
|
? "font-semibold text-status-warn"
|
|
10
|
-
: "font-normal text-muted-foreground"), children: row.header }), row.cells.map((cell, index) => (_jsx("td", { colSpan: cell.colSpan, className: "border-b border-border-row px-3 py-2 align-top", children: cell.content }, index)))] }, row.id))) })] }));
|
|
10
|
+
: cn("font-normal", rowHeaderTone === "muted" && "text-muted-foreground")), children: row.header }), row.cells.map((cell, index) => (_jsx("td", { colSpan: cell.colSpan, className: "border-b border-border-row px-3 py-2 align-top", children: cell.content }, index)))] }, row.id))) })] }));
|
|
11
11
|
}
|