@cosmicdrift/kumiko-renderer 0.415.0 → 0.416.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 -1
- package/dist/app/action-form-body.js +43 -16
- package/dist/app/action-form-support.d.ts +4 -1
- package/dist/app/action-form-support.js +8 -4
- package/dist/app/client-actions.js +6 -4
- package/dist/app/config-edit-body.js +13 -4
- package/dist/app/extension-sections.d.ts +2 -0
- package/dist/app/projection-detail-body.js +8 -6
- package/dist/app/projection-detail-guidance.d.ts +1 -1
- package/dist/app/projection-detail-guidance.js +38 -26
- package/dist/app/projection-detail-header-model.d.ts +1 -1
- package/dist/app/projection-detail-header-model.js +10 -5
- package/dist/app/projection-detail-header.js +1 -1
- package/dist/app/projection-detail-navigation.d.ts +4 -0
- package/dist/app/projection-detail-navigation.js +5 -1
- package/dist/app/screen-shared.d.ts +1 -0
- package/dist/app/screen-shared.js +23 -3
- package/dist/app/use-projection-detail-actions.d.ts +13 -0
- package/dist/app/use-projection-detail-actions.js +14 -2
- package/dist/app/use-projection-detail-data.d.ts +2 -0
- package/dist/app/use-projection-detail-data.js +37 -10
- package/dist/components/ai-assist-payload.d.ts +2 -0
- package/dist/components/ai-assist-payload.js +8 -0
- package/dist/components/edit-mounts.d.ts +3 -2
- package/dist/components/edit-mounts.js +2 -2
- package/dist/components/multi-select-chips.d.ts +10 -0
- package/dist/components/multi-select-chips.js +18 -0
- package/dist/components/related-list-section.js +44 -32
- package/dist/components/related-photo-grid.d.ts +11 -0
- package/dist/components/related-photo-grid.js +40 -0
- package/dist/components/render-edit-action-button.d.ts +2 -2
- package/dist/components/render-edit-field-grid.js +3 -3
- package/dist/components/render-edit-header-actions.d.ts +2 -1
- package/dist/components/render-edit-header-actions.js +18 -1
- package/dist/components/render-edit-layout.js +2 -2
- package/dist/components/render-edit-logic.js +1 -0
- package/dist/components/render-edit-section-kinds.js +11 -0
- package/dist/components/render-edit-types.d.ts +11 -1
- package/dist/components/render-field-ai-assist.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +89 -0
- package/dist/components/render-field-choice-inputs.js +4 -0
- package/dist/components/render-field-control.d.ts +1 -1
- package/dist/components/render-field-control.js +18 -8
- package/dist/components/render-field-value-chips.d.ts +9 -0
- package/dist/components/render-field-value-chips.js +45 -0
- package/dist/components/render-field-write-only.js +12 -4
- package/dist/components/render-list-hint-columns.d.ts +1 -0
- package/dist/components/render-list-hint-columns.js +13 -0
- package/dist/components/use-render-edit-sections.js +5 -1
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/headless/format/index.d.ts +1 -0
- package/dist/headless/format/index.js +20 -0
- package/dist/headless/format/phone.d.ts +1 -0
- package/dist/headless/format/phone.js +8 -0
- package/dist/headless/format/relative-time.d.ts +13 -0
- package/dist/headless/format/relative-time.js +60 -0
- package/dist/headless/format/safe-locale.d.ts +1 -0
- package/dist/headless/format/safe-locale.js +13 -0
- package/dist/headless/index.d.ts +2 -2
- package/dist/headless/index.js +2 -2
- package/dist/headless/view-model/edit.d.ts +3 -2
- package/dist/headless/view-model/edit.js +78 -2
- package/dist/headless/view-model/field-text.d.ts +9 -0
- package/dist/headless/view-model/field-text.js +19 -0
- package/dist/headless/view-model/index.d.ts +1 -0
- package/dist/headless/view-model/index.js +1 -0
- package/dist/headless/view-model/types.d.ts +29 -3
- package/dist/i18n-defaults.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/primitives-record-guidance.d.ts +28 -1
- package/dist/primitives.d.ts +10 -3
- package/dist/web/app/dashboard-body.js +3 -2
- package/dist/web/app/dashboard-list-panel.js +1 -0
- package/dist/web/app/dashboard-panel-columns.d.ts +9 -0
- package/dist/web/app/dashboard-panel-columns.js +14 -0
- package/dist/web/app/dashboard-shared.js +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +9 -2
- package/dist/web/app/dashboard-text-panel.d.ts +1 -0
- package/dist/web/app/dashboard-text-panel.js +11 -9
- package/dist/web/app/relative-time.d.ts +0 -5
- package/dist/web/app/relative-time.js +1 -20
- package/dist/web/primitives/banner.js +11 -6
- package/dist/web/primitives/data-table/card-body.js +2 -2
- package/dist/web/primitives/data-table/card-row.js +7 -2
- package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -0
- package/dist/web/primitives/data-table/data-cell-props.js +2 -0
- package/dist/web/primitives/data-table/row-click-guard.d.ts +2 -0
- package/dist/web/primitives/data-table/row-click-guard.js +19 -0
- package/dist/web/primitives/data-table/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-content.js +6 -2
- package/dist/web/primitives/data-table-cell.d.ts +4 -1
- package/dist/web/primitives/data-table-cell.js +16 -2
- package/dist/web/primitives/default-form.js +6 -3
- package/dist/web/primitives/drawer.js +5 -1
- package/dist/web/primitives/form-footer-parts.js +4 -1
- package/dist/web/primitives/form.js +6 -8
- package/dist/web/primitives/index.js +4 -0
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +2 -2
- package/dist/web/primitives/locale-number.d.ts +0 -1
- package/dist/web/primitives/locale-number.js +1 -13
- package/dist/web/primitives/money-input.js +2 -1
- package/dist/web/primitives/narrow-pinned-footer.js +7 -3
- package/dist/web/primitives/number-input.js +2 -1
- package/dist/web/primitives/photo-grid.d.ts +3 -0
- package/dist/web/primitives/photo-grid.js +5 -0
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +4 -4
- package/dist/web/primitives/record-summary.d.ts +1 -1
- package/dist/web/primitives/record-summary.js +8 -3
- package/dist/web/primitives/step-list.d.ts +3 -0
- package/dist/web/primitives/step-list.js +11 -0
- package/dist/web/widgets/dashboard-list.d.ts +2 -0
- package/dist/web/widgets/dashboard-list.js +2 -2
- package/dist/web/widgets/drawer-panel-class.js +1 -1
- package/package.json +5 -5
- package/src/changes.json +54 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { useOptionalDispatcher } from "../context/dispatcher-context.js";
|
|
5
|
+
import { useTranslation } from "../i18n.js";
|
|
6
|
+
import { usePrimitives } from "../primitives.js";
|
|
7
|
+
import { useAiAssistPayload } from "./ai-assist-payload.js";
|
|
8
|
+
// Mounted only with a dispatcher; without one the field stays a plain input.
|
|
9
|
+
export function AiAssistControl(props) {
|
|
10
|
+
const dispatcher = useOptionalDispatcher();
|
|
11
|
+
return dispatcher === undefined ? props.input : _jsx(AiAssistChips, { ...props });
|
|
12
|
+
}
|
|
13
|
+
// Chips stack: every active chip contributes its params, so "shorter" and "mention warranty"
|
|
14
|
+
// can be combined. A click toggles the chip and re-runs the query with the new set.
|
|
15
|
+
function AiAssistChips({ field, aiAssist, onChange, input, row }) {
|
|
16
|
+
const { Button, Input, Banner } = usePrimitives();
|
|
17
|
+
const t = useTranslation();
|
|
18
|
+
const dispatcher = useOptionalDispatcher();
|
|
19
|
+
const contextPayload = useAiAssistPayload();
|
|
20
|
+
const [active, setActive] = useState(new Set());
|
|
21
|
+
const [instruction, setInstruction] = useState("");
|
|
22
|
+
const [busy, setBusy] = useState(false);
|
|
23
|
+
const [failed, setFailed] = useState(false);
|
|
24
|
+
const [note, setNote] = useState(undefined);
|
|
25
|
+
const activeRun = useRef(null);
|
|
26
|
+
const contextValues = Object.fromEntries((aiAssist.contextFields ?? []).map((name) => [name, row?.[name]]));
|
|
27
|
+
// Changed context (e.g. another selection) replaces the text; the first render never fetches.
|
|
28
|
+
const contextKey = JSON.stringify(contextValues);
|
|
29
|
+
const seenContextKey = useRef(contextKey);
|
|
30
|
+
const run = async (chips, typed) => {
|
|
31
|
+
if (dispatcher === undefined)
|
|
32
|
+
return;
|
|
33
|
+
activeRun.current?.abort();
|
|
34
|
+
const ctrl = new AbortController();
|
|
35
|
+
activeRun.current = ctrl;
|
|
36
|
+
const chipParams = Object.assign({}, ...[...chips].map((index) => aiAssist.chips?.[index]?.params));
|
|
37
|
+
const payload = {
|
|
38
|
+
...contextPayload,
|
|
39
|
+
...contextValues,
|
|
40
|
+
...chipParams,
|
|
41
|
+
...(typed !== undefined &&
|
|
42
|
+
aiAssist.prompt !== undefined && { [aiAssist.prompt.param]: typed }),
|
|
43
|
+
};
|
|
44
|
+
setBusy(true);
|
|
45
|
+
setFailed(false);
|
|
46
|
+
const result = await dispatcher.query(aiAssist.query, payload, {
|
|
47
|
+
signal: ctrl.signal,
|
|
48
|
+
});
|
|
49
|
+
if (ctrl.signal.aborted)
|
|
50
|
+
return;
|
|
51
|
+
setBusy(false);
|
|
52
|
+
const noteText = result.isSuccess && aiAssist.noteField !== undefined
|
|
53
|
+
? propertyOf(result.data, aiAssist.noteField)
|
|
54
|
+
: undefined;
|
|
55
|
+
setNote(typeof noteText === "string" && noteText !== "" ? noteText : undefined);
|
|
56
|
+
const text = result.isSuccess ? propertyOf(result.data, aiAssist.resultField) : undefined;
|
|
57
|
+
if (typeof text !== "string") {
|
|
58
|
+
setFailed(true);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
onChange(text);
|
|
62
|
+
};
|
|
63
|
+
// The effect reads the latest run/active through a ref so it only fires when the context changes.
|
|
64
|
+
const rerunWithCurrentChips = useRef(() => { });
|
|
65
|
+
rerunWithCurrentChips.current = () => void run(active, undefined);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
// skip: nothing changed since the last run (or since mount).
|
|
68
|
+
if (seenContextKey.current === contextKey)
|
|
69
|
+
return;
|
|
70
|
+
seenContextKey.current = contextKey;
|
|
71
|
+
rerunWithCurrentChips.current();
|
|
72
|
+
}, [contextKey]);
|
|
73
|
+
const toggle = (index) => {
|
|
74
|
+
const next = new Set(active);
|
|
75
|
+
if (!next.delete(index))
|
|
76
|
+
next.add(index);
|
|
77
|
+
setActive(next);
|
|
78
|
+
void run(next, undefined);
|
|
79
|
+
};
|
|
80
|
+
return (_jsxs(_Fragment, { children: [input, _jsxs("div", { className: "flex flex-wrap items-center gap-2", "data-testid": `field-ai-assist-${field.field}`, children: [aiAssist.chips?.map((chip, index) => (_jsx(Button, { variant: "secondary", size: "sm", pressed: active.has(index), disabled: busy || field.readOnly, testId: `field-ai-chip-${field.field}-${index}`, onClick: () => toggle(index), children: chip.label }, chip.label))), aiAssist.prompt !== undefined && (_jsx(Input, { kind: "text", id: `${field.field}-ai-instruction`, name: `${field.field}-ai-instruction`, value: instruction, onChange: setInstruction, onKeyDown: (event) => {
|
|
81
|
+
if (event.key !== "Enter")
|
|
82
|
+
return;
|
|
83
|
+
// Enter must not submit the host form.
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
if (busy || field.readOnly || instruction.trim() === "")
|
|
86
|
+
return;
|
|
87
|
+
void run(active, instruction.trim());
|
|
88
|
+
}, disabled: busy || field.readOnly, placeholder: aiAssist.prompt.placeholder ?? t("kumiko.field.aiAssist.prompt"), testId: `field-ai-prompt-${field.field}` }))] }), note !== undefined && (_jsx("span", { className: "text-xs text-muted-foreground", "data-testid": `field-ai-note-${field.field}`, children: note })), failed && (_jsx(Banner, { variant: "error", testId: `field-ai-error-${field.field}`, children: t("kumiko.field.aiAssist.failed") }))] }));
|
|
89
|
+
}
|
|
@@ -2,8 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { AvailabilityOptionsMultiSelect, staticSelectOptions, } from "./availability-options-select.js";
|
|
3
3
|
import { FileListField } from "./file-list-field.js";
|
|
4
4
|
import { MultiSelectCheckboxes } from "./multi-select-checkboxes.js";
|
|
5
|
+
import { MultiSelectChips } from "./multi-select-chips.js";
|
|
5
6
|
import { stringArrayOf, stringValue, withPinnedValues } from "./render-field-values.js";
|
|
6
7
|
function renderMultiSelectControl({ field, id, Input, onChange }, { common }, options, arrayValue) {
|
|
8
|
+
if (field.display === "chips") {
|
|
9
|
+
return (_jsx(MultiSelectChips, { field: field, id: id, options: options, value: arrayValue, onChange: (v) => onChange(v) }));
|
|
10
|
+
}
|
|
7
11
|
return field.display === "checkboxes" ? (_jsx(MultiSelectCheckboxes, { field: field, id: id, options: options, value: arrayValue, onChange: (v) => onChange(v) })) : (_jsx(Input, { kind: "combobox", ...common, multiple: true, value: arrayValue, onChange: (v) => onChange(withPinnedValues(v, options, arrayValue)), options: options }));
|
|
8
12
|
}
|
|
9
13
|
export function renderMultiSelectInput(args, shared) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type
|
|
2
|
+
import { type EditFieldViewModel, type FieldIssue } from "../headless/index.ts";
|
|
3
3
|
import type { usePrimitives } from "../primitives.tsx";
|
|
4
4
|
import type { RenderInputArgs } from "./render-field-input-shared.ts";
|
|
5
5
|
export type ControlContext = RenderInputArgs & {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { telHref } from "../headless/index.js";
|
|
2
3
|
import { AvailabilityOptionsSelect } from "./availability-options-select.js";
|
|
3
4
|
import { EmbeddedListField } from "./embedded-list-field.js";
|
|
4
5
|
import { QueryOptionsSelect } from "./query-options-select.js";
|
|
6
|
+
import { AiAssistControl } from "./render-field-ai-assist.js";
|
|
5
7
|
import { FillActionControl } from "./render-field-fill-action.js";
|
|
6
8
|
import { renderInput } from "./render-field-input.js";
|
|
7
9
|
import { isComplexFieldType, isFileFieldType } from "./render-field-meta.js";
|
|
8
10
|
import { FieldRendererOutput, readOnlyDisplayText } from "./render-field-read-only.js";
|
|
9
11
|
import { ReadOnlyReferenceValue, ReferenceInput } from "./render-field-reference.js";
|
|
12
|
+
import { ValueChipsControl } from "./render-field-value-chips.js";
|
|
10
13
|
import { WriteOnlyTextInput } from "./render-field-write-only.js";
|
|
11
14
|
function rowOf({ field, row }) {
|
|
12
15
|
return row ?? { [field.field]: field.value };
|
|
@@ -55,12 +58,6 @@ const selectAvailabilityRule = (ctx) => {
|
|
|
55
58
|
return undefined;
|
|
56
59
|
return (_jsx(AvailabilityOptionsSelect, { field: field, query: source.query, payload: source.payload, row: rowOf(ctx), id: id, hasError: hasError, onChange: onChange }));
|
|
57
60
|
};
|
|
58
|
-
// Only digits and a leading "+" survive into the tel: href, so a stored
|
|
59
|
-
// "+49 (30) 123-45" dials but can never smuggle other URI parts.
|
|
60
|
-
function telHrefDigits(value) {
|
|
61
|
-
const digits = value.replace(/[^\d]/g, "");
|
|
62
|
-
return value.trim().startsWith("+") ? `+${digits}` : digits;
|
|
63
|
-
}
|
|
64
61
|
function contactHref(field) {
|
|
65
62
|
if (field.type !== "text" || typeof field.value !== "string" || field.value.trim() === "") {
|
|
66
63
|
return undefined;
|
|
@@ -68,8 +65,7 @@ function contactHref(field) {
|
|
|
68
65
|
if (field.format === "email")
|
|
69
66
|
return `mailto:${field.value.trim()}`;
|
|
70
67
|
if (field.format === "phone") {
|
|
71
|
-
|
|
72
|
-
return digits.replace("+", "") === "" ? undefined : `tel:${digits}`;
|
|
68
|
+
return telHref(field.value);
|
|
73
69
|
}
|
|
74
70
|
return undefined;
|
|
75
71
|
}
|
|
@@ -95,6 +91,18 @@ const fillActionRule = (ctx) => {
|
|
|
95
91
|
return undefined;
|
|
96
92
|
return (_jsx(FillActionControl, { field: field, fillAction: fillAction, row: rowOf(ctx), onChange: onChange, disabled: fillDisabled === true, Banner: Banner, renderControl: (fill) => renderInput({ ...ctx, fill }) }));
|
|
97
93
|
};
|
|
94
|
+
const aiAssistRule = (ctx) => {
|
|
95
|
+
const { field, onChange } = ctx;
|
|
96
|
+
if (field.aiAssist === undefined || field.readOnly)
|
|
97
|
+
return undefined;
|
|
98
|
+
return (_jsx(AiAssistControl, { field: field, row: rowOf(ctx), aiAssist: field.aiAssist, onChange: onChange, input: renderInput(ctx) }));
|
|
99
|
+
};
|
|
100
|
+
const valueChipsRule = (ctx) => {
|
|
101
|
+
const { field, onChange } = ctx;
|
|
102
|
+
if (field.valueChips === undefined || field.readOnly)
|
|
103
|
+
return undefined;
|
|
104
|
+
return (_jsx(ValueChipsControl, { field: field, from: field.valueChips.from, row: rowOf(ctx), onChange: onChange, input: renderInput(ctx) }));
|
|
105
|
+
};
|
|
98
106
|
const CONTROL_RULES = [
|
|
99
107
|
fieldRendererRule,
|
|
100
108
|
embeddedListRule,
|
|
@@ -104,6 +112,8 @@ const CONTROL_RULES = [
|
|
|
104
112
|
readOnlyTextRule,
|
|
105
113
|
writeOnlyRule,
|
|
106
114
|
fillActionRule,
|
|
115
|
+
aiAssistRule,
|
|
116
|
+
valueChipsRule,
|
|
107
117
|
];
|
|
108
118
|
export function renderControl(ctx) {
|
|
109
119
|
for (const rule of CONTROL_RULES) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type EditFieldViewModel } from "../headless/index.ts";
|
|
3
|
+
export declare function ValueChipsControl({ field, from, row, onChange, input, }: {
|
|
4
|
+
readonly field: EditFieldViewModel;
|
|
5
|
+
readonly from: string;
|
|
6
|
+
readonly row: Readonly<Record<string, unknown>>;
|
|
7
|
+
readonly onChange: (value: unknown) => void;
|
|
8
|
+
readonly input: ReactNode;
|
|
9
|
+
}): ReactNode;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { currencyDecimals, formatMoney, resolveSafeMoneyLocale, } from "../headless/index.js";
|
|
3
|
+
import { useOptionalLocale } from "../i18n.js";
|
|
4
|
+
import { usePrimitives } from "../primitives.js";
|
|
5
|
+
import { moneyPayload, resolveMoneyCurrency } from "./render-field-values.js";
|
|
6
|
+
function chipValues(row, from) {
|
|
7
|
+
const raw = row[from];
|
|
8
|
+
return Array.isArray(raw) ? raw.filter((v) => typeof v === "number") : [];
|
|
9
|
+
}
|
|
10
|
+
// Chip values are major units, like the text on the chip.
|
|
11
|
+
function chipText(field, value, currency, locale) {
|
|
12
|
+
if (field.type === "money") {
|
|
13
|
+
const decimals = currencyDecimals(currency);
|
|
14
|
+
return formatMoney(Math.round(value * 10 ** decimals), currency, locale, Number.isInteger(value) ? 0 : decimals);
|
|
15
|
+
}
|
|
16
|
+
return new Intl.NumberFormat(resolveSafeMoneyLocale(locale)).format(value);
|
|
17
|
+
}
|
|
18
|
+
// The form holds a money value as { amount (major units), currency }.
|
|
19
|
+
function currentMajorValue(field) {
|
|
20
|
+
const { value } = field;
|
|
21
|
+
if (field.type !== "money")
|
|
22
|
+
return typeof value === "number" ? value : undefined;
|
|
23
|
+
if (typeof value !== "object" || value === null || !("amount" in value))
|
|
24
|
+
return undefined;
|
|
25
|
+
return typeof value.amount === "number" ? value.amount : undefined;
|
|
26
|
+
}
|
|
27
|
+
// A money field stores {amount, currency}, a number field the bare number.
|
|
28
|
+
export function ValueChipsControl({ field, from, row, onChange, input, }) {
|
|
29
|
+
const { Button, Grid } = usePrimitives();
|
|
30
|
+
const locale = useOptionalLocale();
|
|
31
|
+
const values = chipValues(row, from);
|
|
32
|
+
const currency = resolveMoneyCurrency(field.value, field.currency);
|
|
33
|
+
const current = currentMajorValue(field);
|
|
34
|
+
const pick = (value) => {
|
|
35
|
+
if (field.type !== "money") {
|
|
36
|
+
onChange(value);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
onChange(moneyPayload(Math.round(value * 10 ** currencyDecimals(currency)), currency));
|
|
40
|
+
};
|
|
41
|
+
return (_jsxs(_Fragment, { children: [input, values.length > 0 && (_jsx(Grid, { columns: "auto", tight: true, testId: `field-value-chips-${field.field}`, children: values.map((value) => {
|
|
42
|
+
const selected = value === current;
|
|
43
|
+
return (_jsxs(Button, { variant: "secondary", size: "sm", pressed: selected, disabled: field.readOnly, testId: `field-value-chip-${field.field}-${value}`, onClick: () => pick(value), children: [selected ? "✓ " : "", chipText(field, value, currency, locale)] }, value));
|
|
44
|
+
}) }))] }));
|
|
45
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { useTranslation } from "../i18n.js";
|
|
4
4
|
import { usePrimitives } from "../primitives.js";
|
|
5
5
|
// Wire value of a writeOnly field is `true` (set) / `null` (empty), never the
|
|
@@ -12,11 +12,19 @@ export function WriteOnlyTextInput({ field, id, hasError, onChange, changed, })
|
|
|
12
12
|
const isSet = field.value === true;
|
|
13
13
|
const isMarkedForRemoval = field.value === null && changed;
|
|
14
14
|
const [replacing, setReplacing] = useState(false);
|
|
15
|
-
//
|
|
15
|
+
// The masked row returns when a value the user produced (typed text, a pending removal) turns
|
|
16
|
+
// back into `true` (save or Undo). A plain false -> true flip, e.g. the record arriving or
|
|
17
|
+
// reloading, must not close an open Replace, so only a user-produced value arms the reset.
|
|
18
|
+
const userEdited = useRef(false);
|
|
19
|
+
const userValue = typeof field.value === "string" || isMarkedForRemoval;
|
|
16
20
|
useEffect(() => {
|
|
17
|
-
if (
|
|
21
|
+
if (userValue)
|
|
22
|
+
userEdited.current = true;
|
|
23
|
+
else if (isSet && userEdited.current) {
|
|
24
|
+
userEdited.current = false;
|
|
18
25
|
setReplacing(false);
|
|
19
|
-
|
|
26
|
+
}
|
|
27
|
+
}, [isSet, userValue]);
|
|
20
28
|
if (isSet && !replacing && !field.readOnly) {
|
|
21
29
|
return (_jsxs(Grid, { columns: "auto", children: [_jsx(Text, { testId: `field-write-only-set-${field.field}`, children: t("kumiko.field.writeOnly.maskedSet") }), _jsx(Button, { type: "button", variant: "secondary", onClick: () => setReplacing(true), testId: `field-write-only-replace-${field.field}`, children: t("kumiko.field.writeOnly.replace") })] }));
|
|
22
30
|
}
|
|
@@ -3,6 +3,7 @@ import type { ListColumnHintViewModel, ListColumnViewModel, Translate } from "..
|
|
|
3
3
|
/** The hint's tone falls back to the list's `rowToneField`. */
|
|
4
4
|
export declare function hintViewModel(hint: ListColumnHint, rowToneField: string | undefined, translate: Translate): ListColumnHintViewModel;
|
|
5
5
|
export declare function withDisplayColumns(columns: readonly ListColumnViewModel[], screen: EntityListScreenDefinition): readonly ListColumnViewModel[];
|
|
6
|
+
export declare function withPillColumns(columns: readonly ListColumnViewModel[], screen: EntityListScreenDefinition): readonly ListColumnViewModel[];
|
|
6
7
|
export declare function withEmptyPlaceholderColumns(columns: readonly ListColumnViewModel[], screen: EntityListScreenDefinition): readonly ListColumnViewModel[];
|
|
7
8
|
export declare function withNarrowOnlyColumns(columns: readonly ListColumnViewModel[], screen: EntityListScreenDefinition): readonly ListColumnViewModel[];
|
|
8
9
|
export declare function withNarrowInlineColumns(columns: readonly ListColumnViewModel[], screen: EntityListScreenDefinition): readonly ListColumnViewModel[];
|
|
@@ -32,6 +32,19 @@ export function withDisplayColumns(columns, screen) {
|
|
|
32
32
|
};
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
+
export function withPillColumns(columns, screen) {
|
|
36
|
+
const specs = new Map(screen.columns.map((spec) => [normalizeListColumn(spec).field, normalizeListColumn(spec)]));
|
|
37
|
+
return columns.map((col) => {
|
|
38
|
+
const spec = specs.get(col.field);
|
|
39
|
+
if (spec?.pillField === undefined)
|
|
40
|
+
return col;
|
|
41
|
+
return {
|
|
42
|
+
...col,
|
|
43
|
+
pillField: spec.pillField,
|
|
44
|
+
...(spec.pillToneField !== undefined && { pillToneField: spec.pillToneField }),
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
35
48
|
export function withEmptyPlaceholderColumns(columns, screen) {
|
|
36
49
|
const blank = new Set(screen.columns.flatMap((spec) => {
|
|
37
50
|
const column = normalizeListColumn(spec);
|
|
@@ -43,6 +43,7 @@ function useFilteredSections(vm, fieldsFilter) {
|
|
|
43
43
|
// exclusion emptied it: that would leave an empty wizard step / tab.
|
|
44
44
|
() => filterEditSections(vm.sections, fieldsFilter).filter((section) => section.kind === "extension" ||
|
|
45
45
|
section.kind === "relatedList" ||
|
|
46
|
+
section.kind === "stepList" ||
|
|
46
47
|
section.kind === "writeForm" ||
|
|
47
48
|
(section.fields.length === 0 && section.emptiedByWriteExclusion !== true) ||
|
|
48
49
|
section.visible), [vm.sections, fieldsFilter]);
|
|
@@ -61,7 +62,10 @@ export function useRenderEditSections(core) {
|
|
|
61
62
|
const vm = useEditViewModel(core);
|
|
62
63
|
const filteredSections = useFilteredSections(vm, props.fields);
|
|
63
64
|
const allFieldsRequired = useAllFieldsRequired(filteredSections);
|
|
64
|
-
const showsAllRequiredHint = allFieldsRequired &&
|
|
65
|
+
const showsAllRequiredHint = allFieldsRequired &&
|
|
66
|
+
hideSectionTitles !== true &&
|
|
67
|
+
!state.isWizard &&
|
|
68
|
+
props.screen.layout.allRequiredHint !== false;
|
|
65
69
|
// true when editable fields exist or an extension opted into composed submit.
|
|
66
70
|
const isFormEditable = hasEditableSection(filteredSections);
|
|
67
71
|
// A fieldless form (input-less secretMint mint — the secret is
|
|
@@ -2,7 +2,7 @@ import { normalizeListColumn } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { useReferenceLinkResolver, useScreenLinkResolver, } from "../app/reference-link.js";
|
|
4
4
|
import { computeListViewModel } from "../headless/index.js";
|
|
5
|
-
import { withDisplayColumns, withEmptyPlaceholderColumns, withHintColumns, withNarrowInlineColumns, withNarrowOnlyColumns, } from "./render-list-hint-columns.js";
|
|
5
|
+
import { withDisplayColumns, withEmptyPlaceholderColumns, withHintColumns, withNarrowInlineColumns, withNarrowOnlyColumns, withPillColumns, } from "./render-list-hint-columns.js";
|
|
6
6
|
import { enrichReferenceColumns, selectReferenceColumns } from "./render-list-reference-columns.js";
|
|
7
7
|
import { useReferenceColumnLookups } from "./use-reference-column-lookups.js";
|
|
8
8
|
/** Cell link to the screen a row names in `screenField`, parametrized by the row's `paramsField` object. */
|
|
@@ -52,7 +52,7 @@ export function useRenderListColumns(input) {
|
|
|
52
52
|
const { referenceRequests, handleLookupMap, referenceLookups } = useReferenceColumnLookups(rows, referenceColumns);
|
|
53
53
|
const resolveReferenceLink = useReferenceLinkResolver();
|
|
54
54
|
const resolveScreenLink = useScreenLinkResolver();
|
|
55
|
-
const enrichedColumns = useMemo(() => withNarrowOnlyColumns(withNarrowInlineColumns(withDisplayColumns(withHintColumns(withScreenLinks(enrichReferenceColumns({
|
|
55
|
+
const enrichedColumns = useMemo(() => withNarrowOnlyColumns(withNarrowInlineColumns(withPillColumns(withDisplayColumns(withHintColumns(withScreenLinks(enrichReferenceColumns({
|
|
56
56
|
// Flag first: the reference renderer reads it while it is built.
|
|
57
57
|
columns: withEmptyPlaceholderColumns(vm.columns, screen),
|
|
58
58
|
referenceColumns,
|
|
@@ -60,7 +60,7 @@ export function useRenderListColumns(input) {
|
|
|
60
60
|
resolveReferenceLink,
|
|
61
61
|
featureName,
|
|
62
62
|
translate,
|
|
63
|
-
}), screen, resolveScreenLink), screen, translate), screen), screen), screen), [
|
|
63
|
+
}), screen, resolveScreenLink), screen, translate), screen), screen), screen), screen), [
|
|
64
64
|
vm.columns,
|
|
65
65
|
referenceColumns,
|
|
66
66
|
referenceLookups,
|
|
@@ -7,6 +7,7 @@ export { DOCUMENT_FALLBACK_CURRENCY, type DocumentDateOptions, formatDocumentDat
|
|
|
7
7
|
export { escapeHtml, escapeHtmlAttr, escapeXml, isSafeHref, stripControlChars } from "./escape.ts";
|
|
8
8
|
export { type HtmlValue, html, RawHtml, raw } from "./html-template.ts";
|
|
9
9
|
export { currencyDecimals, formatMoney, resolveSafeMoneyLocale } from "./money.ts";
|
|
10
|
+
export { telHref } from "./phone.ts";
|
|
10
11
|
export declare function applyFormatSpec(spec: {
|
|
11
12
|
format: string;
|
|
12
13
|
} & Record<string, unknown>, value: unknown, translate?: (key: string, params?: Readonly<Record<string, string | number>>) => string): string;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
|
|
4
4
|
import { isOneOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
5
5
|
import { rendererWarn } from "../../dev-console.js";
|
|
6
|
+
import { serverNowMs } from "../../server-clock.js";
|
|
7
|
+
import { formatRelativeTime } from "./relative-time.js";
|
|
6
8
|
export const EMPTY_VALUE_PLACEHOLDER = "—";
|
|
7
9
|
function toPlainDate(raw) {
|
|
8
10
|
try {
|
|
@@ -133,6 +135,7 @@ export { DOCUMENT_FALLBACK_CURRENCY, formatDocumentDate, formatDocumentMoney, fo
|
|
|
133
135
|
export { escapeHtml, escapeHtmlAttr, escapeXml, isSafeHref, stripControlChars } from "./escape.js";
|
|
134
136
|
export { html, RawHtml, raw } from "./html-template.js";
|
|
135
137
|
export { currencyDecimals, formatMoney, resolveSafeMoneyLocale } from "./money.js";
|
|
138
|
+
export { telHref } from "./phone.js";
|
|
136
139
|
// JSON.stringify throws on BigInt and circular values; a cell must degrade to text instead of crashing the screen.
|
|
137
140
|
function stringifyJsonOrString(value, indent) {
|
|
138
141
|
try {
|
|
@@ -276,6 +279,21 @@ function formatFileCell(_spec, value) {
|
|
|
276
279
|
function formatJsonCell(spec, value) {
|
|
277
280
|
return stringifyJsonOrString(value, typeof spec["indent"] === "number" ? spec["indent"] : 2);
|
|
278
281
|
}
|
|
282
|
+
const RELATIVE_TIME_STYLES = ["long", "short", "narrow"];
|
|
283
|
+
function formatRelativeTimeCell(spec, value) {
|
|
284
|
+
const atMs = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
285
|
+
if (!Number.isFinite(atMs))
|
|
286
|
+
return String(value);
|
|
287
|
+
const style = spec["style"];
|
|
288
|
+
const absoluteAfterDays = spec["absoluteAfterDays"];
|
|
289
|
+
const timeZone = stringSpec(spec, "timeZone");
|
|
290
|
+
return formatRelativeTime(atMs, serverNowMs(), stringSpec(spec, "locale"), {
|
|
291
|
+
...(isOneOf(RELATIVE_TIME_STYLES, style) && { style }),
|
|
292
|
+
...(typeof absoluteAfterDays === "number" && { absoluteAfterDays }),
|
|
293
|
+
...(spec["withTime"] === true && { withTime: true }),
|
|
294
|
+
...(timeZone !== undefined && { timeZone }),
|
|
295
|
+
});
|
|
296
|
+
}
|
|
279
297
|
const CELL_FORMATTERS = {
|
|
280
298
|
timestamp: formatTemporalCell,
|
|
281
299
|
date: formatTemporalCell,
|
|
@@ -287,7 +305,9 @@ const CELL_FORMATTERS = {
|
|
|
287
305
|
unit: formatUnitSpecCell,
|
|
288
306
|
priority: formatPriorityCell,
|
|
289
307
|
enumOption: formatEnumOptionCell,
|
|
308
|
+
relativeTime: formatRelativeTimeCell,
|
|
290
309
|
i18nText: formatI18nTextCell,
|
|
310
|
+
phone: (_spec, value) => String(value).trim(),
|
|
291
311
|
image: formatFileCell,
|
|
292
312
|
file: formatFileCell,
|
|
293
313
|
json: formatJsonCell,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function telHref(value: string): string | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Only digits and a leading "+" survive into the tel: href, so a stored
|
|
2
|
+
// "+49 (30) 123-45" dials but can never smuggle other URI parts.
|
|
3
|
+
export function telHref(value) {
|
|
4
|
+
const digits = value.replace(/[^\d]/g, "");
|
|
5
|
+
if (digits === "")
|
|
6
|
+
return undefined;
|
|
7
|
+
return `tel:${value.trim().startsWith("+") ? "+" : ""}${digits}`;
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type RelativeTimeOptions = {
|
|
2
|
+
readonly style?: Intl.RelativeTimeFormatStyle;
|
|
3
|
+
readonly absoluteAfterDays?: number;
|
|
4
|
+
readonly withTime?: boolean;
|
|
5
|
+
readonly timeZone?: string;
|
|
6
|
+
};
|
|
7
|
+
/** "5 minutes ago" / "in 30 seconds" in the given locale. The unit grows with the
|
|
8
|
+
* distance (seconds below a minute, minutes below an hour, hours below a day);
|
|
9
|
+
* each step is chosen on the already rounded value so 59.6 minutes reads "1 hour"
|
|
10
|
+
* instead of "60 minutes". From a day on, the distance counts calendar days in
|
|
11
|
+
* `options.timeZone` (default: the runtime's zone), so "yesterday" means the day
|
|
12
|
+
* before today and not 24 hours ago. `numeric: "auto"` yields "now" and "yesterday". */
|
|
13
|
+
export declare function formatRelativeTime(atMs: number, nowMs: number, locale: string | undefined, options?: RelativeTimeOptions): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { resolveSafeLocale } from "./safe-locale.js";
|
|
2
|
+
const SECONDS_PER_MINUTE = 60;
|
|
3
|
+
const MINUTES_PER_HOUR = 60;
|
|
4
|
+
const HOURS_PER_DAY = 24;
|
|
5
|
+
const MS_PER_DAY = 86_400_000;
|
|
6
|
+
function formatAbsolute(atMs, locale, options) {
|
|
7
|
+
return new Intl.DateTimeFormat(locale, {
|
|
8
|
+
day: "numeric",
|
|
9
|
+
month: "short",
|
|
10
|
+
year: "numeric",
|
|
11
|
+
...(options.withTime === true && { hour: "2-digit", minute: "2-digit" }),
|
|
12
|
+
timeZone: options.timeZone,
|
|
13
|
+
}).format(atMs);
|
|
14
|
+
}
|
|
15
|
+
function formatClock(atMs, locale, timeZone) {
|
|
16
|
+
return new Intl.DateTimeFormat(locale, { timeStyle: "short", timeZone }).format(atMs);
|
|
17
|
+
}
|
|
18
|
+
function calendarDayNumber(ms, timeZone) {
|
|
19
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
20
|
+
year: "numeric",
|
|
21
|
+
month: "numeric",
|
|
22
|
+
day: "numeric",
|
|
23
|
+
timeZone,
|
|
24
|
+
}).formatToParts(ms);
|
|
25
|
+
const part = (type) => Number(parts.find((p) => p.type === type)?.value);
|
|
26
|
+
return Date.UTC(part("year"), part("month") - 1, part("day")) / MS_PER_DAY;
|
|
27
|
+
}
|
|
28
|
+
/** "5 minutes ago" / "in 30 seconds" in the given locale. The unit grows with the
|
|
29
|
+
* distance (seconds below a minute, minutes below an hour, hours below a day);
|
|
30
|
+
* each step is chosen on the already rounded value so 59.6 minutes reads "1 hour"
|
|
31
|
+
* instead of "60 minutes". From a day on, the distance counts calendar days in
|
|
32
|
+
* `options.timeZone` (default: the runtime's zone), so "yesterday" means the day
|
|
33
|
+
* before today and not 24 hours ago. `numeric: "auto"` yields "now" and "yesterday". */
|
|
34
|
+
export function formatRelativeTime(atMs, nowMs, locale, options = {}) {
|
|
35
|
+
const safeLocale = resolveSafeLocale(locale);
|
|
36
|
+
const formatter = new Intl.RelativeTimeFormat(safeLocale, {
|
|
37
|
+
numeric: "auto",
|
|
38
|
+
style: options.style ?? "long",
|
|
39
|
+
});
|
|
40
|
+
const seconds = Math.round((atMs - nowMs) / 1000);
|
|
41
|
+
if (Math.abs(seconds) < SECONDS_PER_MINUTE)
|
|
42
|
+
return formatter.format(seconds, "second");
|
|
43
|
+
const minutes = Math.round(seconds / SECONDS_PER_MINUTE);
|
|
44
|
+
if (Math.abs(minutes) < MINUTES_PER_HOUR)
|
|
45
|
+
return formatter.format(minutes, "minute");
|
|
46
|
+
const hours = Math.round(minutes / MINUTES_PER_HOUR);
|
|
47
|
+
if (Math.abs(hours) < HOURS_PER_DAY)
|
|
48
|
+
return formatter.format(hours, "hour");
|
|
49
|
+
const days = calendarDayNumber(atMs, options.timeZone) - calendarDayNumber(nowMs, options.timeZone);
|
|
50
|
+
// 23.5+ hours inside one calendar day still reads as hours, never as "today".
|
|
51
|
+
if (days === 0)
|
|
52
|
+
return formatter.format(hours, "hour");
|
|
53
|
+
if (options.absoluteAfterDays !== undefined && Math.abs(days) >= options.absoluteAfterDays) {
|
|
54
|
+
return formatAbsolute(atMs, safeLocale, options);
|
|
55
|
+
}
|
|
56
|
+
const relative = formatter.format(days, "day");
|
|
57
|
+
return days === -1 && options.withTime === true
|
|
58
|
+
? `${relative}, ${formatClock(atMs, safeLocale, options.timeZone)}`
|
|
59
|
+
: relative;
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveSafeLocale(locale: string | undefined): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const FALLBACK_LOCALE = "en-US";
|
|
2
|
+
// An invalid tag makes every Intl constructor and toLocaleString throw a
|
|
3
|
+
// RangeError; without an ErrorBoundary that would take down the page on
|
|
4
|
+
// focus/blur. Canonicalizing once up front keeps all call sites safe.
|
|
5
|
+
export function resolveSafeLocale(locale) {
|
|
6
|
+
const candidate = locale ?? (typeof navigator !== "undefined" ? navigator.language : undefined) ?? "";
|
|
7
|
+
try {
|
|
8
|
+
return Intl.getCanonicalLocales(candidate)[0] ?? FALLBACK_LOCALE;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return FALLBACK_LOCALE;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/headless/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type { BatchResult, Command, Dispatcher, DispatcherError, DispatcherStatu
|
|
|
5
5
|
export { generateRequestId, StreamFrame, type StreamFrameEvent } from "./dispatcher/index.ts";
|
|
6
6
|
export type { FieldConditionPredicate, FieldConditions, FieldConditionValue, FieldState, FormController, FormControllerOptions, FormSnapshot, FormValues, SubmitConfig, SubmitPayloadMode, SubmitResult, } from "./form/index.ts";
|
|
7
7
|
export { createFormController, groupIssuesByPath, I18N_KEY_PARAM, relevantFieldIssues, zodErrorToFieldIssues, } from "./form/index.ts";
|
|
8
|
-
export { applyFormatSpec, currencyDecimals, DOCUMENT_FALLBACK_CURRENCY, EMPTY_VALUE_PLACEHOLDER, escapeHtml, escapeHtmlAttr, escapeXml, formatDocumentDate, formatDocumentMoney, formatDocumentPercent, formatMoney, type HtmlValue, html, isSafeHref, RawHtml, raw, resolveSafeMoneyLocale, stripControlChars, toInstant, } from "./format/index.ts";
|
|
8
|
+
export { applyFormatSpec, currencyDecimals, DOCUMENT_FALLBACK_CURRENCY, EMPTY_VALUE_PLACEHOLDER, escapeHtml, escapeHtmlAttr, escapeXml, formatDocumentDate, formatDocumentMoney, formatDocumentPercent, formatMoney, type HtmlValue, html, isSafeHref, RawHtml, raw, resolveSafeMoneyLocale, stripControlChars, telHref, toInstant, } from "./format/index.ts";
|
|
9
9
|
export type { NavDefinition, NavNode, NavRegistrySlice, NavTree, ResolveNavigationOptions, } from "./nav/index.ts";
|
|
10
10
|
export { resolveNavigation } from "./nav/index.ts";
|
|
11
11
|
export { pluralKey } from "./plural-key.ts";
|
|
@@ -13,4 +13,4 @@ export { PWA_CACHE_NAME_PREFIX, PWA_CACHE_SCOPE_HASH_LENGTH, PWA_SERVICE_WORKER_
|
|
|
13
13
|
export type { Store, WritableStore } from "./store/index.ts";
|
|
14
14
|
export { createStore, shallowEqual } from "./store/index.ts";
|
|
15
15
|
export type { CellLink, CellLinkItem, ComputeEditViewModelInput, ComputeListViewModelInput, DerivedCellRoundingTarget, EditExtensionSectionViewModel, EditFieldSpec, EditFieldsSectionViewModel, EditFieldViewModel, EditFormMode, EditRelatedListSectionViewModel, EditSectionSpec, EditSectionViewModel, EditViewModel, EditWriteFormSectionViewModel, EmbeddedDerivedOp, EmbeddedListCellViewModel, EmbeddedListIssueGroups, FieldConditionCtx, FieldRenderer, ListColumnCellDisplay, ListColumnFileDisplay, ListColumnHintViewModel, ListColumnSpec, ListColumnViewModel, ListRowViewModel, ListViewModel, RuntimeCellLink, RuntimeCellLinkItems, RuntimeRenderer, ScreenSlots, Translate, } from "./view-model/index.ts";
|
|
16
|
-
export { buildOptionLabels, computeDerivedCellValue, computeEditViewModel, computeListViewModel, computeRelatedListSectionViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, groupEmbeddedListIssues, roundDerivedCellValue, sumEmbeddedListColumn, withDerivedCells, } from "./view-model/index.ts";
|
|
16
|
+
export { buildOptionLabels, computeDerivedCellValue, computeEditViewModel, computeListViewModel, computeRelatedListSectionViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, fieldTextKey, groupEmbeddedListIssues, resolveFieldText, roundDerivedCellValue, sumEmbeddedListColumn, withDerivedCells, } from "./view-model/index.ts";
|
package/dist/headless/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
export { parseRefTarget } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
4
4
|
export { generateRequestId, StreamFrame } from "./dispatcher/index.js";
|
|
5
5
|
export { createFormController, groupIssuesByPath, I18N_KEY_PARAM, relevantFieldIssues, zodErrorToFieldIssues, } from "./form/index.js";
|
|
6
|
-
export { applyFormatSpec, currencyDecimals, DOCUMENT_FALLBACK_CURRENCY, EMPTY_VALUE_PLACEHOLDER, escapeHtml, escapeHtmlAttr, escapeXml, formatDocumentDate, formatDocumentMoney, formatDocumentPercent, formatMoney, html, isSafeHref, RawHtml, raw, resolveSafeMoneyLocale, stripControlChars, toInstant, } from "./format/index.js";
|
|
6
|
+
export { applyFormatSpec, currencyDecimals, DOCUMENT_FALLBACK_CURRENCY, EMPTY_VALUE_PLACEHOLDER, escapeHtml, escapeHtmlAttr, escapeXml, formatDocumentDate, formatDocumentMoney, formatDocumentPercent, formatMoney, html, isSafeHref, RawHtml, raw, resolveSafeMoneyLocale, stripControlChars, telHref, toInstant, } from "./format/index.js";
|
|
7
7
|
export { resolveNavigation } from "./nav/index.js";
|
|
8
8
|
export { pluralKey } from "./plural-key.js";
|
|
9
9
|
export { PWA_CACHE_NAME_PREFIX, PWA_CACHE_SCOPE_HASH_LENGTH, PWA_SERVICE_WORKER_META_NAME, pwaCacheScopePrefixOf, } from "./pwa-service-worker-meta.js";
|
|
10
10
|
export { createStore, shallowEqual } from "./store/index.js";
|
|
11
|
-
export { buildOptionLabels, computeDerivedCellValue, computeEditViewModel, computeListViewModel, computeRelatedListSectionViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, groupEmbeddedListIssues, roundDerivedCellValue, sumEmbeddedListColumn, withDerivedCells, } from "./view-model/index.js";
|
|
11
|
+
export { buildOptionLabels, computeDerivedCellValue, computeEditViewModel, computeListViewModel, computeRelatedListSectionViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, fieldTextKey, groupEmbeddedListIssues, resolveFieldText, roundDerivedCellValue, sumEmbeddedListColumn, withDerivedCells, } from "./view-model/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EditRelatedListSection, EntityDefinition, EntityEditScreenDefinition, FormDerivationScreen } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
-
import type { EditRelatedListSectionViewModel, EditViewModel, Translate } from "./types.ts";
|
|
1
|
+
import type { EditRelatedListSection, EditStepListSection, EntityDefinition, EntityEditScreenDefinition, FormDerivationScreen } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { EditRelatedListSectionViewModel, EditStepListSectionViewModel, EditViewModel, Translate } from "./types.ts";
|
|
3
3
|
export type ComputeEditViewModelInput<TValues extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>> = {
|
|
4
4
|
readonly screen: EntityEditScreenDefinition;
|
|
5
5
|
readonly entity: Pick<EntityDefinition, "fields" | "defaultCurrency">;
|
|
@@ -21,5 +21,6 @@ export type ComputeEditViewModelInput<TValues extends Readonly<Record<string, un
|
|
|
21
21
|
readonly actionFormScreenQn?: string;
|
|
22
22
|
};
|
|
23
23
|
export type EditFormMode = "create" | "update";
|
|
24
|
+
export declare function computeStepListSectionViewModel(sectionSpec: EditStepListSection, values: Readonly<Record<string, unknown>>, translate: Translate): EditStepListSectionViewModel;
|
|
24
25
|
export declare function computeRelatedListSectionViewModel(sectionSpec: EditRelatedListSection, translate: Translate): EditRelatedListSectionViewModel;
|
|
25
26
|
export declare function computeEditViewModel<TValues extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>>(input: ComputeEditViewModelInput<TValues>): EditViewModel;
|