@cosmicdrift/kumiko-renderer 0.416.0 → 0.417.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/action-form-body.d.ts +1 -4
- package/dist/app/action-form-body.js +9 -8
- package/dist/app/config-edit-body.js +71 -79
- package/dist/app/entity-list-screen.js +1 -1
- package/dist/app/header-actions-bar.d.ts +3 -1
- package/dist/app/header-actions-bar.js +12 -4
- package/dist/app/locked-screen-header.d.ts +2 -0
- package/dist/app/locked-screen-header.js +8 -1
- package/dist/app/projection-detail-body.js +24 -5
- package/dist/app/projection-detail-guidance.d.ts +1 -0
- package/dist/app/projection-detail-guidance.js +7 -4
- package/dist/app/projection-detail-header-model.js +4 -1
- package/dist/app/projection-detail-header-region.js +25 -9
- package/dist/app/projection-detail-header.d.ts +2 -0
- package/dist/app/projection-detail-header.js +30 -3
- package/dist/app/projection-list-shim.js +1 -0
- package/dist/app/row-actions.d.ts +4 -0
- package/dist/app/row-actions.js +19 -3
- package/dist/app/use-projection-detail-actions.d.ts +3 -1
- package/dist/app/use-projection-detail-actions.js +9 -1
- package/dist/app/use-projection-detail-data.js +17 -1
- package/dist/app/use-projection-list-data.js +1 -1
- package/dist/card-options.d.ts +2 -0
- package/dist/components/choice-chip-class.d.ts +1 -0
- package/dist/components/choice-chip-class.js +9 -0
- package/dist/components/edit-mounts.d.ts +1 -1
- package/dist/components/grid-cell-for-field.js +1 -1
- package/dist/components/multi-select-chips.js +2 -1
- package/dist/components/narrow-description.d.ts +3 -0
- package/dist/components/narrow-description.js +12 -0
- package/dist/components/related-list-section.d.ts +5 -3
- package/dist/components/related-list-section.js +9 -4
- package/dist/components/related-photo-grid.js +17 -3
- package/dist/components/render-edit-field-grid.d.ts +12 -3
- package/dist/components/render-edit-field-grid.js +60 -18
- package/dist/components/render-edit-fields-section.js +45 -11
- package/dist/components/render-edit-header-actions.js +1 -1
- package/dist/components/render-edit-layout.js +4 -2
- package/dist/components/render-edit-section-kinds.js +50 -12
- package/dist/components/render-edit-titles.js +1 -1
- package/dist/components/render-edit-types.d.ts +11 -0
- package/dist/components/render-field-ai-assist.js +3 -2
- package/dist/components/render-field-control.js +1 -1
- package/dist/components/render-field-value-chips.js +4 -2
- package/dist/components/render-list-hint-columns.d.ts +1 -0
- package/dist/components/render-list-hint-columns.js +30 -5
- package/dist/components/render-list-reference-columns.js +2 -4
- package/dist/components/render-list-row-tone.d.ts +2 -0
- package/dist/components/render-list-row-tone.js +6 -0
- package/dist/components/render-list-table-props.d.ts +13 -2
- package/dist/components/render-list-table-props.js +9 -3
- package/dist/components/render-list-types.d.ts +4 -0
- package/dist/components/render-list.js +12 -4
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/components/write-form-registry.d.ts +13 -0
- package/dist/components/write-form-registry.js +6 -0
- package/dist/components/write-form-section.d.ts +5 -1
- package/dist/components/write-form-section.js +55 -16
- package/dist/headless/form/form-controller.d.ts +1 -0
- package/dist/headless/form/form-controller.js +1 -1
- package/dist/headless/format/index.js +5 -4
- package/dist/headless/format/relative-time.d.ts +2 -0
- package/dist/headless/format/relative-time.js +4 -1
- package/dist/headless/view-model/edit.js +87 -37
- package/dist/headless/view-model/list.js +6 -0
- package/dist/headless/view-model/types.d.ts +49 -4
- package/dist/hooks/use-list-table.js +11 -6
- package/dist/i18n-defaults.js +7 -2
- package/dist/primitives-record-guidance.d.ts +4 -0
- package/dist/primitives-share-types.d.ts +82 -0
- package/dist/primitives-share-types.js +1 -0
- package/dist/primitives.d.ts +34 -83
- package/dist/web/app/bold-markup.d.ts +3 -0
- package/dist/web/app/bold-markup.js +14 -0
- package/dist/web/app/dashboard-body.js +5 -1
- package/dist/web/app/dashboard-list-panel.js +7 -4
- package/dist/web/app/dashboard-panels.js +31 -3
- package/dist/web/app/dashboard-shared.d.ts +3 -1
- package/dist/web/app/dashboard-shared.js +3 -3
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +16 -2
- package/dist/web/app/dashboard-text-panel.js +11 -6
- package/dist/web/app/relative-time.js +10 -1
- package/dist/web/components/config-cascade.d.ts +2 -1
- package/dist/web/components/config-cascade.js +16 -4
- package/dist/web/drawn-icons.js +2 -1
- package/dist/web/layout/header-action-pinned.d.ts +4 -2
- package/dist/web/layout/header-action-pinned.js +13 -4
- package/dist/web/layout/header-overflow-menu.d.ts +2 -0
- package/dist/web/layout/header-overflow-menu.js +2 -0
- package/dist/web/layout/notification-bell.js +12 -3
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.js +4 -1
- package/dist/web/layout/shell-header.js +13 -5
- package/dist/web/primitives/banner.js +14 -3
- package/dist/web/primitives/card.js +5 -3
- package/dist/web/primitives/combobox.js +2 -2
- package/dist/web/primitives/data-table/actions-column.js +1 -1
- package/dist/web/primitives/data-table/card-body.d.ts +1 -1
- package/dist/web/primitives/data-table/card-body.js +37 -14
- package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
- package/dist/web/primitives/data-table/card-frame.js +3 -0
- package/dist/web/primitives/data-table/card-row.js +28 -9
- package/dist/web/primitives/data-table/card-sort-select.js +1 -1
- package/dist/web/primitives/data-table/card-view.js +1 -1
- package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -1
- package/dist/web/primitives/data-table/data-cell-props.js +1 -0
- package/dist/web/primitives/data-table/density.d.ts +3 -1
- package/dist/web/primitives/data-table/density.js +11 -4
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -5
- package/dist/web/primitives/data-table/sort-options-select.js +2 -2
- package/dist/web/primitives/data-table/sortable-header.js +4 -4
- package/dist/web/primitives/data-table/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-chrome.js +1 -3
- package/dist/web/primitives/data-table/table-content.js +7 -11
- package/dist/web/primitives/data-table/table-data-cell.js +31 -17
- package/dist/web/primitives/data-table/table-header-row.js +1 -1
- package/dist/web/primitives/data-table/table-view.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +6 -7
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
- package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
- package/dist/web/primitives/data-table-cell.d.ts +13 -2
- package/dist/web/primitives/data-table-cell.js +123 -43
- package/dist/web/primitives/data-table.js +1 -1
- package/dist/web/primitives/default-form.d.ts +1 -1
- package/dist/web/primitives/default-form.js +11 -10
- package/dist/web/primitives/drawer.js +2 -7
- package/dist/web/primitives/facet-filter.d.ts +1 -1
- package/dist/web/primitives/facet-filter.js +2 -5
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
- package/dist/web/primitives/facet-trigger-label.js +4 -7
- package/dist/web/primitives/field.js +15 -8
- package/dist/web/primitives/form-footer-parts.js +2 -2
- package/dist/web/primitives/inline-suffix.d.ts +2 -0
- package/dist/web/primitives/inline-suffix.js +5 -0
- package/dist/web/primitives/input-choice-kinds.js +12 -2
- package/dist/web/primitives/input-number-kinds.js +2 -2
- package/dist/web/primitives/input-text-kinds.js +1 -1
- package/dist/web/primitives/layout-elements.d.ts +4 -4
- package/dist/web/primitives/layout-elements.js +49 -12
- package/dist/web/primitives/layout.d.ts +1 -1
- package/dist/web/primitives/layout.js +1 -1
- package/dist/web/primitives/money-input.js +8 -7
- package/dist/web/primitives/number-input.d.ts +2 -1
- package/dist/web/primitives/number-input.js +9 -4
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +8 -1
- package/dist/web/primitives/pager.js +12 -21
- package/dist/web/primitives/photo-grid.js +2 -1
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +6 -15
- package/dist/web/primitives/row-actions.js +38 -24
- package/dist/web/primitives/use-container-narrow.d.ts +12 -0
- package/dist/web/primitives/use-container-narrow.js +42 -0
- package/dist/web/ui/input.js +1 -1
- package/dist/web/ui/textarea.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.js +6 -3
- package/dist/web/widgets/dashboard-list.d.ts +4 -1
- package/dist/web/widgets/dashboard-list.js +10 -5
- package/dist/web/widgets/progress-list.js +1 -1
- package/dist/web/widgets/stat-box-cell.js +1 -1
- package/package.json +5 -5
- package/src/changes.json +51 -0
- package/src/web/styles.css +3 -2
|
@@ -39,12 +39,19 @@ export function DefaultField(props) {
|
|
|
39
39
|
.join(" ");
|
|
40
40
|
return (_jsx(FieldLabelledContext.Provider, { value: props.label !== "", children: _jsx(FieldDescriptionContext.Provider, { value: describedBy === "" ? undefined : describedBy, children: _jsx(DefaultFieldBody, { ...props }) }) }));
|
|
41
41
|
}
|
|
42
|
+
function FieldLabelElement({ id, label, required, layout, hideLabel, hasError, }) {
|
|
43
|
+
const hideRequiredMarker = useContext(HideRequiredMarkerContext);
|
|
44
|
+
return (_jsxs(UiLabel, { id: fieldLabelId(id), htmlFor: id, className: cn("min-w-0 gap-0 text-[13px]", hasError ? "text-destructive" : "text-foreground", hideLabel === true && "sr-only"), children: [_jsx("span", { className: layout === "inline" || layout === "row" ? undefined : "truncate", title: typeof label === "string" ? label : undefined, children: label }), required === true && !hideRequiredMarker && (_jsx("span", { "data-required": true, className: "ml-0.5 shrink-0 text-destructive", children: "*" }))] }));
|
|
45
|
+
}
|
|
46
|
+
function FieldErrors({ id, testId, issues, }) {
|
|
47
|
+
const t = useTranslation();
|
|
48
|
+
return (_jsx("div", { id: fieldErrorId(id), role: "alert", "data-testid": testId !== undefined ? `${testId}-errors` : undefined, className: "order-1 text-xs text-destructive", children: issues.map((issue) => (_jsx("div", { children: fieldIssueText(t, issue) }, `${issue.path}:${issue.code}`))) }));
|
|
49
|
+
}
|
|
42
50
|
function DefaultFieldBody({ id, label, required, issues, labelAppendix, fieldAppendix, appendixPlacement, description, status, children, layout, accent, hideLabel, testId, changed, }) {
|
|
43
51
|
const t = useTranslation();
|
|
44
|
-
const hideRequiredMarker = useContext(HideRequiredMarkerContext);
|
|
45
52
|
const hasError = issues !== undefined && issues.length > 0;
|
|
46
|
-
const labelEl = (
|
|
47
|
-
const errorsEl = hasError ?
|
|
53
|
+
const labelEl = (_jsx(FieldLabelElement, { id: id, label: label, required: required, layout: layout, hideLabel: hideLabel, hasError: hasError }));
|
|
54
|
+
const errorsEl = hasError ? _jsx(FieldErrors, { id: id, testId: testId, issues: issues }) : null;
|
|
48
55
|
// Inline (boolean/checkbox): Control links, Label rechts — shadcn-Muster.
|
|
49
56
|
if (layout === "inline") {
|
|
50
57
|
return (_jsxs("div", { "data-testid": testId, className: "flex flex-col gap-1.5", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(FieldLayoutContext.Provider, { value: "inline", children: children }), labelEl, labelAppendix !== undefined && labelAppendix] }), errorsEl] }));
|
|
@@ -55,14 +62,14 @@ function DefaultFieldBody({ id, label, required, issues, labelAppendix, fieldApp
|
|
|
55
62
|
// Settings row: label/help/origin on the left, control on the right. The
|
|
56
63
|
// hairlines between rows come from the list Grid, not from the row itself.
|
|
57
64
|
if (layout === "row") {
|
|
58
|
-
return (_jsxs("div", { "data-testid": testId, className: cn("group/row relative grid gap-x-6 gap-y-2 py-4 @
|
|
65
|
+
return (_jsxs("div", { "data-testid": testId, className: cn("group/row relative grid gap-x-6 gap-y-2 py-4 @sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)] @sm:grid-rows-[auto_auto_auto_1fr] @sm:gap-y-0",
|
|
59
66
|
// Switch rows keep label left / switch right when stacked.
|
|
60
|
-
"@max-
|
|
67
|
+
"@max-sm:has-[[data-slot=switch]]:grid-cols-[minmax(0,1fr)_auto]", accent === true && "@max-sm:pl-3"), children: [accent === true && (_jsx("span", { "aria-hidden": "true", "data-testid": testId !== undefined ? `${testId}-accent` : undefined, className: "absolute inset-y-3 w-0.5 bg-status-active @max-sm:left-0 @sm:-left-4" })), _jsxs("div", { className: "flex min-w-0 items-center gap-2 @sm:col-start-1 @sm:row-start-1", children: [labelEl, changedMarker, labelAppendix !== undefined && labelAppendix, statusEl !== null && _jsx("span", { className: "ml-auto", children: statusEl })] }), description !== undefined && (_jsx("div", { id: fieldDescriptionId(id), "data-testid": testId !== undefined ? `${testId}-description` : undefined, className: "min-w-0 text-sm text-muted-foreground @sm:col-start-1 @sm:row-start-2 @sm:mt-1 @max-sm:group-has-[[data-slot=switch]]/row:col-span-2", children: description })), _jsxs("div", { className: "flex min-w-0 flex-col gap-1.5 has-[[data-slot=switch]]:items-end @sm:col-start-2 @sm:row-span-4 @sm:row-start-1 @max-sm:group-has-[[data-slot=switch]]/row:col-start-2 @max-sm:group-has-[[data-slot=switch]]/row:row-start-1", children: [_jsx(FieldLayoutContext.Provider, { value: "row", children: children }), errorsEl] }), fieldAppendix !== undefined && (_jsx("div", { className: "min-w-0 @sm:col-start-1 @sm:row-start-3 @sm:mt-1 @max-sm:group-has-[[data-slot=switch]]/row:col-span-2", children: fieldAppendix }))] }));
|
|
61
68
|
}
|
|
62
69
|
return (_jsxs("div", { "data-testid": testId, ...(belowControl && fieldAppendix !== undefined && { "data-appendix-below": "" }), className: "flex flex-col gap-1.5", children: [hideLabel === true &&
|
|
63
70
|
changedMarker === null &&
|
|
64
71
|
labelAppendix === undefined &&
|
|
65
|
-
statusEl === null ? (labelEl) : (_jsxs("div", { className: "flex items-center
|
|
72
|
+
statusEl === null ? (labelEl) : (_jsxs("div", { className: "flex items-center gap-2", children: [changedMarker !== null ? (_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [labelEl, changedMarker] })) : (labelEl), labelAppendix !== undefined && labelAppendix, statusEl] })), !belowControl && fieldAppendix !== undefined && fieldAppendix, children, description !== undefined && (_jsx("div", { id: fieldDescriptionId(id), "data-testid": testId !== undefined ? `${testId}-description` : undefined, className: "order-1 text-[13px] text-muted-foreground", children: description })), errorsEl, belowControl && fieldAppendix !== undefined && (_jsx("div", { className: "order-1", children: fieldAppendix }))] }));
|
|
66
73
|
}
|
|
67
74
|
// ---- Input ----
|
|
68
75
|
// Field-icon registry: `EditFieldSpec.icon`/`InputProps.icon` sets a
|
|
@@ -171,9 +178,9 @@ export function RadioListSelect({ id, name, value, onChange, options, variant =
|
|
|
171
178
|
// the box height from the content and makes the `rows` attribute inert.
|
|
172
179
|
// A declared row count therefore only survives as a min-height floor: the field
|
|
173
180
|
// starts at `rows` lines tall and still grows with its content. The addend is
|
|
174
|
-
// the textarea frame
|
|
181
|
+
// the textarea frame: py-2 top+bottom plus the 1.5px borders.
|
|
175
182
|
export function textareaMinHeight(rows) {
|
|
176
|
-
return { minHeight: `calc(${rows} * 1lh + 1rem +
|
|
183
|
+
return { minHeight: `calc(${rows} * 1lh + 1rem + 3px)` };
|
|
177
184
|
}
|
|
178
185
|
export function withInlineDisabledHint(option) {
|
|
179
186
|
if (option.disabled !== true || option.description === undefined)
|
|
@@ -19,9 +19,9 @@ export function renderNarrowPinnedFooter(model, nodes, keyboardInset) {
|
|
|
19
19
|
: undefined, testId: testId, keyboardInset: keyboardInset }));
|
|
20
20
|
}
|
|
21
21
|
export function footerRowClassName(model) {
|
|
22
|
-
const { pinned, chromeless, fillHeight
|
|
22
|
+
const { pinned, chromeless, fillHeight } = model;
|
|
23
23
|
return cn(pinned
|
|
24
|
-
?
|
|
24
|
+
? "flex h-14 shrink-0 items-center justify-end gap-2 border-t border-border bg-card px-6"
|
|
25
25
|
: "flex flex-col-reverse gap-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:py-4", !pinned && !chromeless && "px-[var(--card-padding)]", !pinned && !chromeless && cardFooterBorder, !pinned && fillHeight === true && "shrink-0");
|
|
26
26
|
}
|
|
27
27
|
export function renderUnsavedStatus(model, unsavedCount) {
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from "../../index.js";
|
|
2
3
|
import { Checkbox } from "../ui/checkbox.js";
|
|
3
4
|
import { Switch } from "../ui/switch.js";
|
|
4
5
|
import { ComboboxInput } from "./combobox.js";
|
|
5
|
-
import { RadioListSelect, SegmentedSelect, withInlineDisabledHint, withoutSegmentedSelectPlaceholder, } from "./field.js";
|
|
6
|
+
import { fieldLabelId, RadioListSelect, SegmentedSelect, withInlineDisabledHint, withoutSegmentedSelectPlaceholder, } from "./field.js";
|
|
6
7
|
import { stateProps } from "./input-optional-props.js";
|
|
7
8
|
import { resolveSelectPresentation } from "./input-select-presentation.js";
|
|
9
|
+
import { SegmentedControl } from "./segmented-select.js";
|
|
8
10
|
// layout="inline" (checkbox lists like MultiSelectCheckboxes, the
|
|
9
11
|
// BooleanField widget) keeps the checkbox optics; the standard form
|
|
10
12
|
// field (render-field.tsx, layout="stacked") gets the switch.
|
|
11
|
-
|
|
13
|
+
// A settings row (layout="row") shows the flag as an Off/On segment, not a switch.
|
|
14
|
+
function BooleanSegment(props) {
|
|
15
|
+
const t = useTranslation();
|
|
16
|
+
return (_jsx(SegmentedControl, { id: props.id, name: props.name, value: props.value ? "on" : "off", onChange: (next) => props.onChange(next === "on"), options: [
|
|
17
|
+
{ value: "off", label: t("kumiko.config.cascade.off") },
|
|
18
|
+
{ value: "on", label: t("kumiko.config.cascade.on") },
|
|
19
|
+
], disabled: props.disabled, required: props.required, hasError: props.hasError, labelProps: { "aria-labelledby": fieldLabelId(props.id) } }));
|
|
20
|
+
}
|
|
21
|
+
export const renderBooleanKind = (props, { booleanLayout }) => booleanLayout === "row" ? (_jsx(BooleanSegment, { ...props })) : booleanLayout === "inline" ? (_jsx(Checkbox, { id: props.id, name: props.name, disabled: props.disabled, "aria-required": props.required, "aria-invalid": props.hasError === true ? true : undefined, checked: props.value, onCheckedChange: (checked) => props.onChange(checked === true) })) : (_jsx(Switch, { id: props.id, name: props.name, disabled: props.disabled, "aria-required": props.required, "aria-invalid": props.hasError === true ? true : undefined, checked: props.value, onCheckedChange: (checked) => props.onChange(checked === true), className: "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40" }));
|
|
12
22
|
function normalizeSelectOptions(options) {
|
|
13
23
|
return options.map((o) => (typeof o === "string" ? { value: o, label: o } : o));
|
|
14
24
|
}
|
|
@@ -9,8 +9,8 @@ export const renderNumberKind = (props) => {
|
|
|
9
9
|
// Icon, input and unit share this one box, and the grid cell sizes the
|
|
10
10
|
// box rather than the bare input: anchored to a wider wrapper, the unit
|
|
11
11
|
// would sit next to a narrower input instead of inside it.
|
|
12
|
-
const numberField = (_jsxs("div", { "data-slot": "number-field", className: "relative", children: [NumberIcon !== undefined && _jsx(NumberIcon, { "aria-hidden": "true", className: FIELD_ICON_CLASS }), _jsx(NumberInput, { id: props.id, name: props.name, value: props.value, onChange: props.onChange, disabled: props.disabled, required: props.required, hasError: props.hasError, testId: props.testId, ...(props.unit !== undefined && { ariaDescribedBy: unitSuffixId(props.id) }), ...(props.locale !== undefined && { locale: props.locale }), ...(props.grouping !== undefined && { grouping: props.grouping }), ...(props.integer !== undefined && { integer: props.integer }), ...(props.placeholder !== undefined && { placeholder: props.placeholder }), className: cn(NumberIcon !== undefined ? "pl-8" : undefined, props.unit !== undefined ? "pr-8" : undefined) }), props.unit !== undefined && (_jsx("span", { id: unitSuffixId(props.id), className: "pointer-events-none absolute right-2.5 top-1/2 max-w-[40%] -translate-y-1/2 truncate text-sm text-muted-foreground", children: props.unit }))] }));
|
|
13
|
-
return withInputAddons(props, numberField);
|
|
12
|
+
const numberField = (_jsxs("div", { "data-slot": "number-field", className: "relative", children: [NumberIcon !== undefined && _jsx(NumberIcon, { "aria-hidden": "true", className: FIELD_ICON_CLASS }), _jsx(NumberInput, { id: props.id, name: props.name, value: props.value, onChange: props.onChange, disabled: props.disabled, required: props.required, hasError: props.hasError, testId: props.testId, ...(props.unit !== undefined && { ariaDescribedBy: unitSuffixId(props.id) }), ...(props.locale !== undefined && { locale: props.locale }), ...(props.grouping !== undefined && { grouping: props.grouping }), ...(props.integer !== undefined && { integer: props.integer }), ...(props.suffix !== undefined && { suffix: props.suffix }), ...(props.placeholder !== undefined && { placeholder: props.placeholder }), className: cn(NumberIcon !== undefined ? "pl-8" : undefined, props.unit !== undefined ? "pr-8" : undefined) }), props.unit !== undefined && (_jsx("span", { id: unitSuffixId(props.id), className: "pointer-events-none absolute right-2.5 top-1/2 max-w-[40%] -translate-y-1/2 truncate text-sm text-muted-foreground", children: props.unit }))] }));
|
|
13
|
+
return withInputAddons({ ...props, suffix: undefined }, numberField);
|
|
14
14
|
};
|
|
15
15
|
export const renderRangeKind = (props, { common }) => (_jsx("input", { type: "range", ...common, min: props.min, max: props.max, step: props.step ?? 1, value: props.value, onChange: (e) => props.onChange(Number(e.target.value)), className: "w-full accent-primary" }));
|
|
16
16
|
export const renderMoneyKind = (props) => (_jsx(MoneyInput, { id: props.id, name: props.name, value: props.value, onChange: props.onChange, currency: props.currency ?? "EUR", ...(props.locale !== undefined && { locale: props.locale }), ...stateProps(props) }));
|
|
@@ -36,4 +36,4 @@ function textareaShortcutProps({ onKeyDown, onSubmitShortcut }) {
|
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
export const renderTextareaKind = (props, { common }) => (_jsx(Textarea, { ...common, ...props.dataAttributes, readOnly: props.readOnly, value: props.value, onChange: (e) => props.onChange(e.target.value), rows: props.rows ?? 4, className: "resize-y", ...(props.placeholder !== undefined && { placeholder: props.placeholder }),
|
|
39
|
+
export const renderTextareaKind = (props, { common }) => (_jsx(Textarea, { ...common, ...props.dataAttributes, readOnly: props.readOnly, value: props.value, onChange: (e) => props.onChange(e.target.value), rows: props.rows ?? 4, className: "resize-y", ...(props.placeholder !== undefined && { placeholder: props.placeholder }), style: textareaMinHeight(props.rows ?? 4), ...textareaShortcutProps(props) }));
|
|
@@ -1,11 +1,11 @@
|
|
|
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, subtitleBelowLgOnly, children, actions, variant, layout, testId, icon, }: SectionProps): ReactNode;
|
|
4
|
+
export declare function DefaultSection({ id, title, subtitle, subtitleBelowLgOnly, children, actions, variant, layout, titleStyle, hint, testId, icon, }: SectionProps): ReactNode;
|
|
5
5
|
export declare function DefaultFillContainer({ children, testId, grow, className, }: FillContainerProps): ReactNode;
|
|
6
|
-
export declare function DefaultGrid({ columns, children, testId, maxRows, flow, list, ariaLabelledBy, tight, }: GridProps): ReactNode;
|
|
7
|
-
export declare function DefaultGridCell({ span, width, children }: GridCellProps): ReactNode;
|
|
8
|
-
export declare function DefaultText({ variant, decorative, children, testId, }: TextProps): ReactNode;
|
|
6
|
+
export declare function DefaultGrid({ columns, children, testId, maxRows, flow, list, ariaLabelledBy, tight, facts, }: GridProps): ReactNode;
|
|
7
|
+
export declare function DefaultGridCell({ span, width, hideOnNarrow, children }: GridCellProps): ReactNode;
|
|
8
|
+
export declare function DefaultText({ variant, decorative, concealed, narrow, children, testId, }: TextProps): ReactNode;
|
|
9
9
|
export declare function isPlainPrimaryClick(event: MouseEvent): boolean;
|
|
10
10
|
export declare function DefaultLink({ href, variant, target, rel, onPress, className, children, testId, dataAttributes, }: LinkProps): ReactNode;
|
|
11
11
|
export declare function DefaultProgress({ value, tone, ariaLabel, testId }: ProgressProps): ReactNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Children, useContext } from "react";
|
|
3
3
|
import { isSafeHref } from "../../headless/index.js";
|
|
4
4
|
import { Icon } from "../icons.js";
|
|
@@ -9,7 +9,28 @@ 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
|
-
|
|
12
|
+
// Desktop boards print the hint under the data, phone boards above it.
|
|
13
|
+
const SECTION_HINT_CLASS = "m-0 mt-3 text-[12.5px] text-muted-foreground max-sm:order-first max-sm:mb-3 max-sm:mt-0";
|
|
14
|
+
function SectionHint({ text, textNarrow, testId }) {
|
|
15
|
+
if (textNarrow !== undefined) {
|
|
16
|
+
return (_jsx("p", { "data-testid": testId, className: SECTION_HINT_CLASS, children: _jsx(NarrowText, { text: text, narrow: textNarrow }) }));
|
|
17
|
+
}
|
|
18
|
+
const end = text.indexOf(". ");
|
|
19
|
+
const first = end === -1 ? text : text.slice(0, end + 1);
|
|
20
|
+
const rest = end === -1 ? "" : text.slice(end + 1);
|
|
21
|
+
return (_jsxs("p", { "data-testid": testId, className: SECTION_HINT_CLASS, children: [_jsx("strong", { className: "font-semibold", children: first }), rest] }));
|
|
22
|
+
}
|
|
23
|
+
// The flex column lets the phone hint jump above the content via `order-first`.
|
|
24
|
+
function withSectionHint(children, hint) {
|
|
25
|
+
if (hint === undefined)
|
|
26
|
+
return children;
|
|
27
|
+
return (_jsxs("div", { className: "flex flex-col", children: [children, _jsx(SectionHint, { ...hint })] }));
|
|
28
|
+
}
|
|
29
|
+
function NarrowText({ text, narrow }) {
|
|
30
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "max-sm:hidden", children: text }), _jsx("span", { className: "sm:hidden", children: narrow })] }));
|
|
31
|
+
}
|
|
32
|
+
export function DefaultSection({ id, title, subtitle, subtitleBelowLgOnly, children, actions, variant = "default", layout = "stacked", titleStyle = "heading", hint, testId, icon, }) {
|
|
33
|
+
const labelTitle = titleStyle === "label";
|
|
13
34
|
const insideForm = useContext(InsideFormContext);
|
|
14
35
|
const insideScreenForm = useContext(ScreenFormContext);
|
|
15
36
|
// h3 instead of CardTitle (= div): keeps the heading semantics for
|
|
@@ -21,7 +42,9 @@ export function DefaultSection({ id, title, subtitle, subtitleBelowLgOnly, child
|
|
|
21
42
|
// footer — a title-less section still draws the row when actions are
|
|
22
43
|
// present, so a hideTitle tabs-Section with `actions` isn't stranded.
|
|
23
44
|
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-
|
|
45
|
+
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-section-title": "", "data-testid": testId !== undefined ? `${testId}-title` : undefined, className: cn("flex items-center gap-2", labelTitle
|
|
46
|
+
? "text-[12.5px] font-semibold uppercase leading-none tracking-[0.06em] text-muted-foreground"
|
|
47
|
+
: "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
48
|
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
49
|
// Inside a form: divider-less section WITHOUT a card surface of its own.
|
|
27
50
|
// The separator lines BETWEEN sections come from the divide-y wrapper in
|
|
@@ -33,8 +56,10 @@ export function DefaultSection({ id, title, subtitle, subtitleBelowLgOnly, child
|
|
|
33
56
|
// gap only needs to read as roughly double the gap-4 field row
|
|
34
57
|
// spacing, not triple it.
|
|
35
58
|
insideScreenForm
|
|
36
|
-
?
|
|
37
|
-
|
|
59
|
+
? labelTitle
|
|
60
|
+
? "flex scroll-mt-4 flex-col gap-2 [&:not(:first-of-type)]:pt-6"
|
|
61
|
+
: "flex scroll-mt-4 flex-col gap-4 [&:not(:first-of-type)]:border-t [&:not(:first-of-type)]:border-border [&:not(:first-of-type)]:pt-7"
|
|
62
|
+
: "flex flex-col gap-4 px-6 py-4", variant === "destructive" && "border-l-2 border-destructive/40", layout === "settings-list" && "@container max-w-[944px]"), children: [header, withSectionHint(children, hint)] }));
|
|
38
63
|
}
|
|
39
64
|
// Standalone: own card, header flows into the body (no divider).
|
|
40
65
|
// overflow-hidden clips the card's own corner radius correctly for
|
|
@@ -43,7 +68,7 @@ export function DefaultSection({ id, title, subtitle, subtitleBelowLgOnly, child
|
|
|
43
68
|
// directly into `children`) WOULD get silently clipped — verify this
|
|
44
69
|
// against any new standalone-section content that renders its own
|
|
45
70
|
// non-portaled overlay.
|
|
46
|
-
return (_jsx("div", { "data-slot": "card", "data-testid": testId, className: cn(cardSurface(), "overflow-hidden", variant === "destructive" && "border-destructive/40"), children: _jsxs("div", { className: "flex flex-col gap-4 px-6 py-6", children: [header, children] }) }));
|
|
71
|
+
return (_jsx("div", { "data-slot": "card", "data-testid": testId, className: cn(cardSurface(), "overflow-hidden", variant === "destructive" && "border-destructive/40"), children: _jsxs("div", { className: "flex flex-col gap-4 px-6 py-6", children: [header, withSectionHint(children, hint)] }) }));
|
|
47
72
|
}
|
|
48
73
|
export function DefaultFillContainer({ children, testId, grow, className, }) {
|
|
49
74
|
// flex-1 only on request (`grow`, set under fillScreenHeight): without it the
|
|
@@ -52,7 +77,7 @@ export function DefaultFillContainer({ children, testId, grow, className, }) {
|
|
|
52
77
|
return (_jsx("div", { "data-testid": testId, className: cn("flex min-h-0 flex-col", grow === true && "flex-1", className), children: children }));
|
|
53
78
|
}
|
|
54
79
|
const DRAWER_FIELD_CELL_WIDTH_CLASS = {
|
|
55
|
-
money: "w-full
|
|
80
|
+
money: "w-full [&_label]:whitespace-nowrap",
|
|
56
81
|
select: "w-full",
|
|
57
82
|
};
|
|
58
83
|
const FIELD_CELL_WIDTH_CLASS = {
|
|
@@ -67,7 +92,7 @@ const FIELD_CELL_WIDTH_CLASS = {
|
|
|
67
92
|
// switch (1.15rem) gets (h-9 input − switch) / 2 margin to sit on the input line.
|
|
68
93
|
toggle: "w-auto min-w-40 shrink-0 self-start [&_[data-slot=switch]]:my-[0.55rem]",
|
|
69
94
|
};
|
|
70
|
-
export function DefaultGrid({ columns, children, testId, maxRows, flow, list, ariaLabelledBy, tight, }) {
|
|
95
|
+
export function DefaultGrid({ columns, children, testId, maxRows, flow, list, ariaLabelledBy, tight, facts, }) {
|
|
71
96
|
const insideDrawerBody = useContext(DrawerBodyContext);
|
|
72
97
|
const groupProps = ariaLabelledBy !== undefined
|
|
73
98
|
? { role: "group", "aria-labelledby": ariaLabelledBy }
|
|
@@ -75,6 +100,13 @@ export function DefaultGrid({ columns, children, testId, maxRows, flow, list, ar
|
|
|
75
100
|
if (list === true) {
|
|
76
101
|
return (_jsx("div", { ...groupProps, "data-testid": testId, className: "flex flex-col divide-y divide-border", children: children }));
|
|
77
102
|
}
|
|
103
|
+
if (facts === true && typeof columns === "number") {
|
|
104
|
+
const factStyle = {
|
|
105
|
+
"--grid-cols": `repeat(${columns}, minmax(0, 1fr))`,
|
|
106
|
+
"--grid-cols-narrow": `repeat(${Math.min(columns, 2)}, minmax(0, 1fr))`,
|
|
107
|
+
};
|
|
108
|
+
return (_jsx("div", { ...groupProps, "data-testid": testId, "data-facts": "", className: "grid gap-x-6 gap-y-3 [grid-template-columns:var(--grid-cols-narrow)] sm:[grid-template-columns:var(--grid-cols)] [&_label]:text-[12.5px] [&_label]:font-normal [&_label]:text-muted-foreground [&_[data-testid^=field-value-]]:text-sm [&_[data-testid^=field-value-]:not([data-concealed])]:font-medium [&_[data-testid^=field-value-]:not([data-concealed])]:text-foreground", style: factStyle, children: children }));
|
|
109
|
+
}
|
|
78
110
|
if (flow === true) {
|
|
79
111
|
return (_jsx("div", { ...groupProps, "data-testid": testId, className: cn("flex gap-4", insideDrawerBody
|
|
80
112
|
? "flex-col items-start"
|
|
@@ -118,10 +150,10 @@ export function DefaultGrid({ columns, children, testId, maxRows, flow, list, ar
|
|
|
118
150
|
};
|
|
119
151
|
return (_jsx("div", { ...groupProps, "data-testid": testId, className: "grid gap-[var(--kumiko-grid-gap,1rem)] grid-cols-1 sm:[grid-template-columns:var(--grid-cols)]", style: style, children: children }));
|
|
120
152
|
}
|
|
121
|
-
export function DefaultGridCell({ span, width, children }) {
|
|
153
|
+
export function DefaultGridCell({ span, width, hideOnNarrow, children }) {
|
|
122
154
|
const insideDrawerBody = useContext(DrawerBodyContext);
|
|
123
155
|
if (width !== undefined) {
|
|
124
|
-
return (_jsx("div", { className: cn("min-w-0 max-w-full", width === "full" && "sm:[grid-column:1/-1]", insideDrawerBody
|
|
156
|
+
return (_jsx("div", { className: cn("min-w-0 max-w-full", hideOnNarrow === true && "max-sm:hidden", width === "full" && "sm:[grid-column:1/-1]", insideDrawerBody
|
|
125
157
|
? (DRAWER_FIELD_CELL_WIDTH_CLASS[width] ?? FIELD_CELL_WIDTH_CLASS[width])
|
|
126
158
|
: FIELD_CELL_WIDTH_CLASS[width]), children: children }));
|
|
127
159
|
}
|
|
@@ -129,9 +161,14 @@ export function DefaultGridCell({ span, width, children }) {
|
|
|
129
161
|
// Below `sm` the grid has one explicit column (see DefaultGrid); an unconditional
|
|
130
162
|
// `span N` there would add implicit auto columns that squeeze the fr column.
|
|
131
163
|
const style = { "--grid-span": s };
|
|
132
|
-
return (_jsx("div", { className: "min-w-0 sm:[grid-column:span_var(--grid-span)]", style: style, children: children }));
|
|
164
|
+
return (_jsx("div", { className: cn("min-w-0 sm:[grid-column:span_var(--grid-span)]", hideOnNarrow === true && "max-sm:hidden"), style: style, children: children }));
|
|
133
165
|
}
|
|
134
|
-
export function DefaultText({ variant = "body", decorative, children, testId, }) {
|
|
166
|
+
export function DefaultText({ variant = "body", decorative, concealed, narrow, children, testId, }) {
|
|
167
|
+
if (narrow !== undefined)
|
|
168
|
+
return _jsx(NarrowText, { text: children, narrow: narrow });
|
|
169
|
+
if (concealed === true) {
|
|
170
|
+
return (_jsxs("span", { "data-testid": testId, "data-concealed": "", className: "inline-flex items-center gap-1.5 text-muted-foreground", children: [_jsx(Icon, { name: "lock", className: "size-3.5 shrink-0" }), children] }));
|
|
171
|
+
}
|
|
135
172
|
switch (variant) {
|
|
136
173
|
case "code":
|
|
137
174
|
return (_jsx("code", { "data-testid": testId, className: "relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm", children: children }));
|
|
@@ -3,7 +3,7 @@ import type { FormWidth } from "../../index.ts";
|
|
|
3
3
|
export type ScreenWidth = FormWidth;
|
|
4
4
|
export declare const screenWidthClassName: Record<ScreenWidth, string>;
|
|
5
5
|
export declare const screenFormColumnWidthClassName: Record<ScreenWidth, string>;
|
|
6
|
-
export declare const screenPaddingClassName = "px-4 pb-6 pt-5 md:px-
|
|
6
|
+
export declare const screenPaddingClassName = "px-4 pb-6 pt-5 md:px-6 md:pb-10 md:pt-7";
|
|
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";
|
|
8
8
|
declare const STACK_GAP: {
|
|
9
9
|
readonly sm: "gap-2";
|
|
@@ -20,7 +20,7 @@ export const screenFormColumnWidthClassName = {
|
|
|
20
20
|
// is the one the settings screens use, so a list, a dashboard and a form start
|
|
21
21
|
// at the same edge. The bottom inset keeps the last field or table row off the
|
|
22
22
|
// viewport edge.
|
|
23
|
-
export const screenPaddingClassName = "px-4 pb-6 pt-5 md:px-
|
|
23
|
+
export const screenPaddingClassName = "px-4 pb-6 pt-5 md:px-6 md:pb-10 md:pt-7";
|
|
24
24
|
// Sticky element at the bottom of a screen scroll that covers the bottom padding of
|
|
25
25
|
// screenPaddingClassName (sticky stops at the content box) and overlaps it at rest (negative margin).
|
|
26
26
|
// Keep offsets, margin and padding in step with it; bg-card is the surface of the main content area.
|
|
@@ -11,6 +11,7 @@ import { useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
|
11
11
|
import { resolveSafeLocale } from "../../headless/format/safe-locale.js";
|
|
12
12
|
import { currencyDecimals, formatMoney as formatMoneyForLocale } from "../../headless/index.js";
|
|
13
13
|
import { cn } from "../lib/cn.js";
|
|
14
|
+
import { inlineSuffixStyle } from "./inline-suffix.js";
|
|
14
15
|
import { parseLocaleNumber } from "./locale-number.js";
|
|
15
16
|
// Re-exported for backward compat — callers used to import this from here
|
|
16
17
|
// before it moved to headless (shared with RenderField).
|
|
@@ -18,13 +19,10 @@ export { currencyDecimals, parseLocaleNumber };
|
|
|
18
19
|
// The border and focus ring live on the wrapper so the currency symbol can be
|
|
19
20
|
// a flex sibling of the input: a symbol of any width ("€", "CHF", "R$") takes
|
|
20
21
|
// its own space instead of overlapping the digits.
|
|
21
|
-
const wrapperClass = "flex h-
|
|
22
|
+
const wrapperClass = "flex min-h-[38px] w-full items-center rounded-[7px] border-[1.5px] border-input bg-transparent text-sm shadow-sm " +
|
|
22
23
|
"transition-colors focus-within:ring-1 focus-within:ring-ring";
|
|
23
24
|
const inputClass = "h-full min-w-0 flex-1 bg-transparent px-3 placeholder:text-muted-foreground " +
|
|
24
|
-
"focus-visible:outline-none disabled:cursor-not-allowed "
|
|
25
|
-
// Right-aligns the value like a native type=number input so amounts align at the thousands
|
|
26
|
-
// separators in list columns.
|
|
27
|
-
"text-right tabular-nums";
|
|
25
|
+
"focus-visible:outline-none disabled:cursor-not-allowed text-left tabular-nums";
|
|
28
26
|
export function MoneyInput({ id, name, value, onChange, currency, locale, disabled, required, hasError, ariaLabel, }) {
|
|
29
27
|
const decimals = currencyDecimals(currency);
|
|
30
28
|
const factor = 10 ** decimals;
|
|
@@ -75,8 +73,11 @@ export function MoneyInput({ id, name, value, onChange, currency, locale, disabl
|
|
|
75
73
|
return;
|
|
76
74
|
onChange(Math.round(parsed * factor));
|
|
77
75
|
};
|
|
78
|
-
const
|
|
79
|
-
|
|
76
|
+
const shownText = focused ? draft : formatted;
|
|
77
|
+
const symbolEl = symbol !== "" ? (_jsx("span", { id: `${id}-currency`, "data-testid": `${id}-currency`, ...(symbolPosition === "suffix" && { style: inlineSuffixStyle(shownText) }), className: cn("select-none text-muted-foreground", symbolPosition === "prefix"
|
|
78
|
+
? "shrink-0 pl-3"
|
|
79
|
+
: "pointer-events-none absolute top-1/2 -translate-y-1/2"), children: symbol })) : null;
|
|
80
|
+
return (_jsxs("div", { className: cn(wrapperClass, "relative", hasError === true && "border-destructive focus-within:ring-destructive", disabled === true && "cursor-not-allowed opacity-50"), children: [symbolPosition === "prefix" && symbolEl, _jsx("input", { ref: inputRef, id: id, name: name, type: "text", inputMode: "decimal", autoComplete: "off", disabled: disabled, "aria-required": required, "aria-invalid": hasError === true ? true : undefined, "aria-label": ariaLabel, "aria-describedby": symbol !== "" ? `${id}-currency` : undefined, value: shownText, onFocus: handleFocus, onBlur: handleBlur, onChange: (e) => setDraft(e.target.value), className: cn(inputClass, symbolPosition === "prefix" ? "pl-2" : "pr-8") }), symbolPosition === "suffix" && symbolEl] }));
|
|
80
81
|
}
|
|
81
82
|
// Shared with defaultCellRender (index.tsx) so both formatting paths stay
|
|
82
83
|
// identical. Resolves the browser locale here; headless stays navigator-free.
|
|
@@ -7,6 +7,7 @@ export type NumberInputProps = {
|
|
|
7
7
|
readonly locale?: string;
|
|
8
8
|
readonly grouping?: boolean;
|
|
9
9
|
readonly integer?: boolean;
|
|
10
|
+
readonly suffix?: string;
|
|
10
11
|
readonly disabled?: boolean;
|
|
11
12
|
readonly required?: boolean;
|
|
12
13
|
readonly hasError?: boolean;
|
|
@@ -16,4 +17,4 @@ export type NumberInputProps = {
|
|
|
16
17
|
readonly ariaDescribedBy?: string;
|
|
17
18
|
readonly ariaLabel?: string;
|
|
18
19
|
};
|
|
19
|
-
export declare function NumberInput({ id, name, value, onChange, locale, grouping, integer, disabled, required, hasError, placeholder, testId, className, ariaDescribedBy, ariaLabel, }: NumberInputProps): ReactNode;
|
|
20
|
+
export declare function NumberInput({ id, name, value, onChange, locale, grouping, integer, suffix, disabled, required, hasError, placeholder, testId, className, ariaDescribedBy, ariaLabel, }: NumberInputProps): ReactNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// NumberInput — type=text with a focus-aware locale format, so a blurred
|
|
3
3
|
// value shows thousands separators ("28.000") while editing shows the raw
|
|
4
4
|
// locale string ("28000"). Not type=number: browsers reject formatted
|
|
@@ -10,8 +10,9 @@ import { useLayoutEffect, useRef, useState } from "react";
|
|
|
10
10
|
import { resolveSafeLocale } from "../../headless/format/safe-locale.js";
|
|
11
11
|
import { cn } from "../lib/cn.js";
|
|
12
12
|
import { Input as UiInput } from "../ui/input.js";
|
|
13
|
+
import { inlineSuffixStyle } from "./inline-suffix.js";
|
|
13
14
|
import { formatLocaleNumber, parseLocaleNumber } from "./locale-number.js";
|
|
14
|
-
export function NumberInput({ id, name, value, onChange, locale, grouping = true, integer = false, disabled, required, hasError, placeholder, testId, className, ariaDescribedBy, ariaLabel, }) {
|
|
15
|
+
export function NumberInput({ id, name, value, onChange, locale, grouping = true, integer = false, suffix, disabled, required, hasError, placeholder, testId, className, ariaDescribedBy, ariaLabel, }) {
|
|
15
16
|
const resolvedLocale = resolveSafeLocale(locale);
|
|
16
17
|
const [focused, setFocused] = useState(false);
|
|
17
18
|
const [draft, setDraft] = useState("");
|
|
@@ -40,8 +41,12 @@ export function NumberInput({ id, name, value, onChange, locale, grouping = true
|
|
|
40
41
|
}
|
|
41
42
|
onChange(parsed);
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
+
const shownText = focused ? draft : format(grouping);
|
|
45
|
+
const input = (_jsx(UiInput, { ref: inputRef, type: "text", inputMode: integer ? "numeric" : "decimal", autoComplete: "off", id: id, name: name, disabled: disabled, "aria-required": required, "aria-invalid": hasError === true ? true : undefined, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "data-testid": testId, value: shownText, onFocus: () => {
|
|
44
46
|
setDraft(format(false));
|
|
45
47
|
setFocused(true);
|
|
46
|
-
}, onBlur: () => setFocused(false), onChange: (e) => handleChange(e.target.value), ...(placeholder !== undefined && { placeholder }), className: cn("text-left tabular-nums", className) }));
|
|
48
|
+
}, onBlur: () => setFocused(false), onChange: (e) => handleChange(e.target.value), ...(placeholder !== undefined && { placeholder }), className: cn("text-left tabular-nums", suffix !== undefined && "pr-8", className) }));
|
|
49
|
+
if (suffix === undefined)
|
|
50
|
+
return input;
|
|
51
|
+
return (_jsxs("div", { className: "relative", children: [input, _jsx("span", { style: inlineSuffixStyle(shownText), className: "pointer-events-none absolute top-1/2 -translate-y-1/2 select-none text-sm text-muted-foreground", children: suffix })] }));
|
|
47
52
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { PageHeaderProps } from "../../index.ts";
|
|
3
|
-
export declare function DefaultPageHeader({ title, recordTitle, status, actions, bodyTitle, overflowItems, hideBreadcrumb, breadcrumbScreenId, }: PageHeaderProps): ReactNode;
|
|
3
|
+
export declare function DefaultPageHeader({ title, recordTitle, narrowRecordTitle, status, actions, bodyTitle, overflowItems, hideBreadcrumb, breadcrumbScreenId, }: PageHeaderProps): ReactNode;
|
|
@@ -4,11 +4,12 @@ import { createPortal } from "react-dom";
|
|
|
4
4
|
import { usePageHeaderSlot } from "../layout/page-header-slot.js";
|
|
5
5
|
import { UNIFORM_BAR_CONTROLS_CLASSES } from "../layout/uniform-bar-controls.js";
|
|
6
6
|
import { cn } from "../lib/cn.js";
|
|
7
|
-
export function DefaultPageHeader({ title, recordTitle, status, actions, bodyTitle, overflowItems, hideBreadcrumb, breadcrumbScreenId, }) {
|
|
7
|
+
export function DefaultPageHeader({ title, recordTitle, narrowRecordTitle, status, actions, bodyTitle, overflowItems, hideBreadcrumb, breadcrumbScreenId, }) {
|
|
8
8
|
const slot = usePageHeaderSlot();
|
|
9
9
|
const setOverflowItems = slot?.setOverflowItems;
|
|
10
10
|
const setTitle = slot?.setTitle;
|
|
11
11
|
const setRecordTitle = slot?.setRecordTitle;
|
|
12
|
+
const setNarrowRecordTitle = slot?.setNarrowRecordTitle;
|
|
12
13
|
const setBodyTitle = slot?.setBodyTitle;
|
|
13
14
|
const setBreadcrumbHidden = slot?.setBreadcrumbHidden;
|
|
14
15
|
const setBreadcrumbScreenId = slot?.setBreadcrumbScreenId;
|
|
@@ -37,6 +38,12 @@ export function DefaultPageHeader({ title, recordTitle, status, actions, bodyTit
|
|
|
37
38
|
setRecordTitle(recordTitle);
|
|
38
39
|
return () => setRecordTitle(undefined);
|
|
39
40
|
}, [setRecordTitle, recordTitle]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (setNarrowRecordTitle === undefined || narrowRecordTitle === undefined)
|
|
43
|
+
return;
|
|
44
|
+
setNarrowRecordTitle(narrowRecordTitle);
|
|
45
|
+
return () => setNarrowRecordTitle(undefined);
|
|
46
|
+
}, [setNarrowRecordTitle, narrowRecordTitle]);
|
|
40
47
|
useEffect(() => {
|
|
41
48
|
if (setTitle === undefined || title === undefined)
|
|
42
49
|
return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronLeft, ChevronRight, Loader2 } from "lucide-react";
|
|
2
|
+
import { ChevronDown, ChevronLeft, ChevronRight, Loader2 } from "lucide-react";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
4
|
import { useOptionalLocale, useTranslation } from "../../index.js";
|
|
5
5
|
import { cn } from "../lib/cn.js";
|
|
@@ -52,8 +52,8 @@ export function InfiniteSentinel({ onReachEnd, loadingMore, hasMore, rowsCount,
|
|
|
52
52
|
const showEndLabel = !hasMore && rowsCount >= END_LABEL_MIN_ROWS;
|
|
53
53
|
return (_jsx("div", { ref: ref, "data-testid": testId, className: cn("flex items-center justify-center text-sm text-muted-foreground", showEndLabel || loadingMore ? "py-4" : ""), children: showEndLabel ? (_jsx("span", { "data-testid": testId !== undefined ? `${testId}-end` : undefined, children: t("kumiko.list.end-of-list") })) : loadingMore ? (_jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" })) : hasMore ? (_jsx("span", { "aria-hidden": "true", children: "\u00A0" })) : null }));
|
|
54
54
|
}
|
|
55
|
-
// Pager — left "X – Y of Z
|
|
56
|
-
//
|
|
55
|
+
// Pager — left "X – Y of Z", right the page size select in text style and "‹ Page 1 of 3 ›" from sm; below sm
|
|
56
|
+
// only the arrows.
|
|
57
57
|
// `pinned` renders the footer bar of a scrollBody table (fixed height, top
|
|
58
58
|
// border); unpinned it sits as a plain row below the table.
|
|
59
59
|
//
|
|
@@ -65,32 +65,23 @@ export function Pager({ page, limit, total, onPageChange, pageSizeOptions, onPag
|
|
|
65
65
|
const locale = useOptionalLocale();
|
|
66
66
|
const totalPages = Math.max(1, Math.ceil(total / limit));
|
|
67
67
|
const safePage = Math.max(1, Math.min(page, totalPages));
|
|
68
|
-
const from = (safePage - 1) * limit + 1;
|
|
68
|
+
const from = total === 0 ? 0 : (safePage - 1) * limit + 1;
|
|
69
69
|
const to = Math.min(safePage * limit, total);
|
|
70
70
|
return (_jsxs("div", { "data-testid": testId, className: plain === true
|
|
71
71
|
? "flex items-center justify-between px-4 pb-3 pt-1 text-[12.5px] tabular-nums text-muted-foreground"
|
|
72
72
|
: pinned === true
|
|
73
73
|
? TABLE_FOOTER_BAR_CLASS
|
|
74
|
-
: "mt-3 flex items-center gap-4 text-[12.5px] tabular-nums text-muted-foreground", children: [
|
|
74
|
+
: "mt-3 flex items-center gap-4 text-[12.5px] tabular-nums text-muted-foreground", children: [_jsx("div", { className: "flex min-w-0 flex-1 items-center gap-1", children: _jsx("div", { "data-testid": testId !== undefined ? `${testId}-status` : undefined, children: total === 0
|
|
75
|
+
? t("kumiko.pager.statusEmpty")
|
|
76
|
+
: t("kumiko.pager.status", {
|
|
75
77
|
from: from.toLocaleString(locale),
|
|
76
78
|
to: to.toLocaleString(locale),
|
|
77
79
|
total: total.toLocaleString(locale),
|
|
78
|
-
}) }), pageSizeOptions !== undefined && onPageSizeChange !== undefined && (_jsxs("div", { className: "hidden items-center sm:flex", children: [_jsx("
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (totalPages <= 7)
|
|
83
|
-
return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
84
|
-
const wanted = new Set([1, current - 1, current, current + 1, totalPages]);
|
|
85
|
-
const pages = [...wanted].filter((page) => page >= 1 && page <= totalPages).sort((a, b) => a - b);
|
|
86
|
-
return pages.flatMap((page, index) => {
|
|
87
|
-
const previous = pages[index - 1];
|
|
88
|
-
return previous !== undefined && page - previous > 1 ? [{ gapBefore: page }, page] : [page];
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function PageNumberButton({ page, current, label, onClick, testId, }) {
|
|
92
|
-
return (_jsx("button", { type: "button", onClick: onClick, "aria-label": label, "aria-current": current ? "page" : undefined, "data-testid": testId, className: cn("inline-flex h-6 min-w-6 items-center justify-center rounded px-1.5", "hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", current && "bg-primary text-primary-foreground hover:bg-primary"), children: page.toLocaleString() }));
|
|
80
|
+
}) }) }), _jsxs("div", { className: "flex items-center gap-1", children: [pageSizeOptions !== undefined && onPageSizeChange !== undefined && (_jsxs("div", { className: "relative mr-2 hidden items-center sm:flex", children: [_jsx("select", { "aria-label": t("kumiko.pager.pageSizeLabel"), "data-testid": testId !== undefined ? `${testId}-page-size` : undefined, value: limit, onChange: (e) => onPageSizeChange(Number(e.target.value)), className: "h-8 cursor-pointer appearance-none rounded-md border border-border-strong bg-card py-0 pl-2.5 pr-7 text-[12.5px] text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", children: pageSizeOptions.map((size) => (_jsx("option", { value: size, children: t("kumiko.pager.pageSize", { size: size.toLocaleString(locale) }) }, size))) }), _jsx(ChevronDown, { className: "pointer-events-none absolute right-2 size-3.5 text-muted-foreground", "aria-hidden": "true" })] })), _jsx(PagerButton, { ariaLabel: t("kumiko.pager.previousPage"), disabled: safePage <= 1, onClick: () => onPageChange(safePage - 1), testId: testId !== undefined ? `${testId}-prev` : undefined, children: _jsx(ChevronLeft, { className: "size-3.5", "aria-hidden": "true" }) }), _jsx("span", { "data-testid": testId !== undefined ? `${testId}-page-label` : undefined, className: "hidden px-1 sm:inline", children: t("kumiko.pager.pageOf", {
|
|
81
|
+
page: safePage.toLocaleString(locale),
|
|
82
|
+
total: totalPages.toLocaleString(locale),
|
|
83
|
+
}) }), _jsx(PagerButton, { ariaLabel: t("kumiko.pager.nextPage"), disabled: safePage >= totalPages, onClick: () => onPageChange(safePage + 1), testId: testId !== undefined ? `${testId}-next` : undefined, children: _jsx(ChevronRight, { className: "size-3.5", "aria-hidden": "true" }) })] })] }));
|
|
93
84
|
}
|
|
94
85
|
function PagerButton({ children, onClick, ariaLabel, disabled, testId, }) {
|
|
95
|
-
return (_jsx("button", { type: "button", onClick: onClick, disabled: disabled, "aria-label": ariaLabel, "data-testid": testId, className: cn("inline-flex size-
|
|
86
|
+
return (_jsx("button", { type: "button", onClick: onClick, disabled: disabled, "aria-label": ariaLabel, "data-testid": testId, className: cn("inline-flex size-8 items-center justify-center rounded-md border border-border-strong bg-card", "hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", "disabled:pointer-events-none disabled:text-foreground-disabled"), children: children }));
|
|
96
87
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
2
3
|
import { FileThumbnail } from "./file-thumbnail.js";
|
|
3
4
|
export function DefaultPhotoGrid({ tiles, testId }) {
|
|
4
|
-
return (_jsx("ul", { "data-testid": testId, className: "m-0 grid list-none
|
|
5
|
+
return (_jsx("ul", { "data-testid": testId, className: "m-0 grid list-none gap-3.5 p-0 [grid-template-columns:repeat(2,minmax(0,1fr))] md:[grid-template-columns:repeat(3,minmax(0,1fr))]", children: tiles.map((tile) => (_jsxs("li", { "data-testid": testId !== undefined ? `${testId}-tile-${tile.id}` : undefined, className: cn("flex flex-col overflow-hidden rounded-lg border border-border bg-card", tile.leadsOnNarrow === true && "max-sm:-order-1"), children: [_jsxs("div", { className: "relative", children: [_jsx(FileThumbnail, { fileId: tile.imageId ?? "", className: "aspect-[3/2] w-full object-cover md:aspect-[2/1]" }), tile.badge !== undefined && (_jsx("span", { "data-slot": "photo-badge", className: "absolute top-2 left-2 rounded-full bg-status-warn-surface px-2 py-0.5 text-xs font-medium text-status-warn", children: tile.badge }))] }), _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-3 gap-y-2 p-3", children: [tile.caption !== undefined && (_jsx("span", { className: "min-w-0 truncate text-[13px] text-foreground", children: tile.caption })), tile.actions !== undefined && (_jsx("div", { className: "ml-auto flex flex-wrap items-center gap-x-3 gap-y-1", children: tile.actions }))] })] }, tile.id))) }));
|
|
5
6
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { RecordStepsProps } from "../../index.ts";
|
|
3
|
-
export declare function DefaultRecordSteps({ title, subtitle, emptyLabel, reasonLabel, narrowLimit, moreLabel, lessLabel, moreActionsLabel, items,
|
|
3
|
+
export declare function DefaultRecordSteps({ title, subtitle, emptyLabel, reasonLabel, narrowLimit, moreLabel, lessLabel, moreActionsLabel, items, testId, }: RecordStepsProps): ReactNode;
|