@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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { availableSelectOptions, evalFieldCondition, isExtensionEditSection, isFieldRequired, isFieldsEditSection, isFieldVisible, isFormDerivationInputMode, isUnusedFallbackOperand, isWriteFormEditSection, normalizeEditField, parseRefTarget, sectionFieldSpecs, WRITE_FORM_SECTION_ENTITY, } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import { SELECT_OPTION_TONES } from "@cosmicdrift/kumiko-types/fields";
|
|
3
|
+
import { isOneOf, propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
2
4
|
import { buildEmbeddedListCell } from "./embedded-list-cells.js";
|
|
5
|
+
import { resolveFieldText } from "./field-text.js";
|
|
3
6
|
import { buildOptionLabels, fieldLabelKey, fieldOptionLabelKey } from "./list.js";
|
|
4
7
|
// Resolves a writeForm section's own fieldDefs/fields through the same
|
|
5
8
|
// per-field pipeline as a plain fields section, by reusing the pipeline
|
|
@@ -61,6 +64,48 @@ function translateSectionTexts(section, translate) {
|
|
|
61
64
|
function wasEmptiedByWriteExclusion(declaredFieldSpecs, remainingFields) {
|
|
62
65
|
return declaredFieldSpecs.length > 0 && remainingFields.length === 0;
|
|
63
66
|
}
|
|
67
|
+
function readOptionalString(entry, key) {
|
|
68
|
+
const value = propertyOf(entry, key);
|
|
69
|
+
return typeof value === "string" ? value : undefined;
|
|
70
|
+
}
|
|
71
|
+
function readStepListItem(entry) {
|
|
72
|
+
const title = readOptionalString(entry, "title");
|
|
73
|
+
if (title === undefined)
|
|
74
|
+
return undefined;
|
|
75
|
+
const status = readOptionalString(entry, "status");
|
|
76
|
+
const statusTone = propertyOf(entry, "statusTone");
|
|
77
|
+
const description = readOptionalString(entry, "description");
|
|
78
|
+
return {
|
|
79
|
+
title,
|
|
80
|
+
...(status !== undefined && { status }),
|
|
81
|
+
...(isOneOf(SELECT_OPTION_TONES, statusTone) && { statusTone }),
|
|
82
|
+
...(description !== undefined && { description }),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Malformed entries of the record's array are skipped: the screen must not crash on a bad row.
|
|
86
|
+
export function computeStepListSectionViewModel(sectionSpec, values, translate) {
|
|
87
|
+
const raw = values[sectionSpec.field];
|
|
88
|
+
const items = Array.isArray(raw) ? raw : [];
|
|
89
|
+
return {
|
|
90
|
+
kind: "stepList",
|
|
91
|
+
...(sectionSpec.id !== undefined && { id: sectionSpec.id }),
|
|
92
|
+
...(sectionSpec.title !== undefined && { title: translate(sectionSpec.title) }),
|
|
93
|
+
items: items.flatMap((entry) => {
|
|
94
|
+
const item = readStepListItem(entry);
|
|
95
|
+
if (item === undefined)
|
|
96
|
+
return [];
|
|
97
|
+
const { title, status, statusTone, description } = item;
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
100
|
+
title: translate(title),
|
|
101
|
+
...(status !== undefined && { status: translate(status) }),
|
|
102
|
+
...(statusTone !== undefined && { statusTone }),
|
|
103
|
+
...(description !== undefined && { description: translate(description) }),
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
}),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
64
109
|
// relatedList runs its own query — nothing here to resolve against
|
|
65
110
|
// entity/values, the spec passes through verbatim.
|
|
66
111
|
export function computeRelatedListSectionViewModel(sectionSpec, translate) {
|
|
@@ -89,6 +134,7 @@ export function computeRelatedListSectionViewModel(sectionSpec, translate) {
|
|
|
89
134
|
...(sectionSpec.rowTone !== undefined && { rowTone: sectionSpec.rowTone }),
|
|
90
135
|
...(sectionSpec.toolbarActions !== undefined && { toolbarActions: sectionSpec.toolbarActions }),
|
|
91
136
|
...(sectionSpec.actions !== undefined && { actions: sectionSpec.actions }),
|
|
137
|
+
...(sectionSpec.photoGrid !== undefined && { photoGrid: sectionSpec.photoGrid }),
|
|
92
138
|
...(sectionSpec.emptyState !== undefined && {
|
|
93
139
|
emptyState: {
|
|
94
140
|
title: translate(sectionSpec.emptyState.title),
|
|
@@ -129,6 +175,33 @@ function deriveFieldAffixHints(normalized, translate) {
|
|
|
129
175
|
...(normalized.fillAction !== undefined && {
|
|
130
176
|
fillAction: { ...normalized.fillAction, label: translate(normalized.fillAction.label) },
|
|
131
177
|
}),
|
|
178
|
+
...(normalized.aiAssist !== undefined && {
|
|
179
|
+
aiAssist: {
|
|
180
|
+
query: normalized.aiAssist.query,
|
|
181
|
+
resultField: normalized.aiAssist.resultField,
|
|
182
|
+
...(normalized.aiAssist.noteField !== undefined && {
|
|
183
|
+
noteField: normalized.aiAssist.noteField,
|
|
184
|
+
}),
|
|
185
|
+
...(normalized.aiAssist.contextFields !== undefined && {
|
|
186
|
+
contextFields: normalized.aiAssist.contextFields,
|
|
187
|
+
}),
|
|
188
|
+
...(normalized.aiAssist.chips !== undefined && {
|
|
189
|
+
chips: normalized.aiAssist.chips.map((chip) => ({
|
|
190
|
+
...chip,
|
|
191
|
+
label: translate(chip.label),
|
|
192
|
+
})),
|
|
193
|
+
}),
|
|
194
|
+
...(normalized.aiAssist.prompt !== undefined && {
|
|
195
|
+
prompt: {
|
|
196
|
+
param: normalized.aiAssist.prompt.param,
|
|
197
|
+
...(normalized.aiAssist.prompt.placeholder !== undefined && {
|
|
198
|
+
placeholder: translate(normalized.aiAssist.prompt.placeholder),
|
|
199
|
+
}),
|
|
200
|
+
},
|
|
201
|
+
}),
|
|
202
|
+
},
|
|
203
|
+
}),
|
|
204
|
+
...(normalized.valueChips !== undefined && { valueChips: normalized.valueChips }),
|
|
132
205
|
};
|
|
133
206
|
}
|
|
134
207
|
function deriveSelectOptionsQuery(fieldDef) {
|
|
@@ -395,6 +468,9 @@ export function computeEditViewModel(input) {
|
|
|
395
468
|
if (isWriteFormEditSection(sectionSpec)) {
|
|
396
469
|
return computeWriteFormSectionViewModel(sectionSpec, screen.id, values, translate, featureName);
|
|
397
470
|
}
|
|
471
|
+
if (sectionSpec.kind === "stepList") {
|
|
472
|
+
return computeStepListSectionViewModel(sectionSpec, values, translate);
|
|
473
|
+
}
|
|
398
474
|
if (!isFieldsEditSection(sectionSpec)) {
|
|
399
475
|
return computeRelatedListSectionViewModel(sectionSpec, translate);
|
|
400
476
|
}
|
|
@@ -423,8 +499,8 @@ export function computeEditViewModel(input) {
|
|
|
423
499
|
? parseRefTarget(normalized.refEntity, featureName)
|
|
424
500
|
: undefined;
|
|
425
501
|
const effectiveType = declaredRefTarget !== undefined ? "reference" : fieldDef.type;
|
|
426
|
-
const label =
|
|
427
|
-
fieldLabelKey(featureName, screen.entity, normalized.field));
|
|
502
|
+
const label = resolveFieldText(screen.fieldLabels?.[normalized.field] ??
|
|
503
|
+
fieldLabelKey(featureName, screen.entity, normalized.field), values, translate).text;
|
|
428
504
|
const visible = isEditFieldVisible(normalized, fieldDef, values);
|
|
429
505
|
// `readOnly` (camelCase) is the name on both sides: EditFieldSpec
|
|
430
506
|
// in the engine, and the view-model emitted here. One convention
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FieldTextRef } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { Translate } from "./types.ts";
|
|
3
|
+
export declare function fieldTextKey(ref: FieldTextRef): string;
|
|
4
|
+
/** Translates a label or help text, filling `{placeholder}`s from the form values (hidden
|
|
5
|
+
* fields included). `complete` is false while any referenced value is empty. */
|
|
6
|
+
export declare function resolveFieldText(ref: FieldTextRef, values: Readonly<Record<string, unknown>>, translate: Translate): {
|
|
7
|
+
readonly text: string;
|
|
8
|
+
readonly complete: boolean;
|
|
9
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function fieldTextKey(ref) {
|
|
2
|
+
return typeof ref === "string" ? ref : ref.key;
|
|
3
|
+
}
|
|
4
|
+
/** Translates a label or help text, filling `{placeholder}`s from the form values (hidden
|
|
5
|
+
* fields included). `complete` is false while any referenced value is empty. */
|
|
6
|
+
export function resolveFieldText(ref, values, translate) {
|
|
7
|
+
if (typeof ref === "string")
|
|
8
|
+
return { text: translate(ref), complete: true };
|
|
9
|
+
const params = {};
|
|
10
|
+
let complete = true;
|
|
11
|
+
for (const [placeholder, fieldName] of Object.entries(ref.params)) {
|
|
12
|
+
const value = values[fieldName];
|
|
13
|
+
const text = value === undefined || value === null ? "" : String(value);
|
|
14
|
+
if (text === "")
|
|
15
|
+
complete = false;
|
|
16
|
+
params[placeholder] = text;
|
|
17
|
+
}
|
|
18
|
+
return { text: translate(ref.key, params), complete };
|
|
19
|
+
}
|
|
@@ -2,6 +2,7 @@ export type { ComputeEditViewModelInput, EditFormMode } from "./edit.ts";
|
|
|
2
2
|
export { computeEditViewModel, computeRelatedListSectionViewModel } from "./edit.ts";
|
|
3
3
|
export type { DerivedCellRoundingTarget, EmbeddedDerivedOp, EmbeddedListIssueGroups, } from "./embedded-list.ts";
|
|
4
4
|
export { computeDerivedCellValue, groupEmbeddedListIssues, roundDerivedCellValue, sumEmbeddedListColumn, withDerivedCells, } from "./embedded-list.ts";
|
|
5
|
+
export { fieldTextKey, resolveFieldText } from "./field-text.ts";
|
|
5
6
|
export type { ComputeListViewModelInput } from "./list.ts";
|
|
6
7
|
export { buildOptionLabels, computeListViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, } from "./list.ts";
|
|
7
8
|
export type { CellLink, CellLinkItem, EditExtensionSectionViewModel, EditFieldSpec, EditFieldsSectionViewModel, EditFieldViewModel, EditRelatedListSectionViewModel, EditSectionSpec, EditSectionViewModel, EditViewModel, EditWriteFormSectionViewModel, EmbeddedListCellViewModel, FieldConditionCtx, FieldRenderer, ListColumnCellDisplay, ListColumnFileDisplay, ListColumnHintViewModel, ListColumnSpec, ListColumnViewModel, ListRowViewModel, ListViewModel, RuntimeCellLink, RuntimeCellLinkItems, RuntimeRenderer, ScreenSlots, Translate, } from "./types.ts";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { computeEditViewModel, computeRelatedListSectionViewModel } from "./edit.js";
|
|
2
2
|
export { computeDerivedCellValue, groupEmbeddedListIssues, roundDerivedCellValue, sumEmbeddedListColumn, withDerivedCells, } from "./embedded-list.js";
|
|
3
|
+
export { fieldTextKey, resolveFieldText } from "./field-text.js";
|
|
3
4
|
export { buildOptionLabels, computeListViewModel, embeddedCellLabelKey, embeddedCellOptionLabelKey, fieldLabelKey, fieldOptionLabelKey, fieldOptionLabelKeyPrefix, } from "./list.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EditFieldSpec, EditSectionSpec, EmbeddedDerivedCellDef, FieldAffix, FieldCondition, FieldFillAction, FieldIconKey, FieldRenderer, IconKey, ListBulkAction, ListColumnSpec, ListFacetSpec, ListSortSpec, ListTableOptions, OptionsQueryPayload, PlatformComponent, RelatedListEmptyStateVariant, RelatedListRowTone, RelatedListToolbarAction, RowAction, RowActionMode, ScreenSlots, SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
1
|
+
import type { EditFieldSpec, EditSectionSpec, EmbeddedDerivedCellDef, FieldAffix, FieldAiAssist, FieldCondition, FieldFillAction, FieldIconKey, FieldRenderer, FieldValueChips, IconKey, ListBulkAction, ListColumnSpec, ListFacetSpec, ListSortSpec, ListTableOptions, OptionsQueryPayload, PlatformComponent, RelatedListEmptyStateVariant, RelatedListRowTone, RelatedListToolbarAction, RowAction, RowActionMode, ScreenSlots, SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
export type RuntimeRenderer = (value: unknown, row?: Readonly<Record<string, unknown>>) => string;
|
|
3
3
|
/** Where a cell's text links to. `href` comes from NavApi.hrefFor (new-tab and
|
|
4
4
|
* copy-link work); `onPress` is the in-app navigation for a plain click. */
|
|
@@ -81,6 +81,10 @@ export type ListColumnViewModel = {
|
|
|
81
81
|
readonly badgeToneField?: string;
|
|
82
82
|
/** `false`: the pill has no leading dot. */
|
|
83
83
|
readonly badgeDot?: false;
|
|
84
|
+
/** Row field with the label of a pill drawn beside the cell value (`ListColumnSpec.pillField`). */
|
|
85
|
+
readonly pillField?: string;
|
|
86
|
+
/** Row field naming the pill tone. */
|
|
87
|
+
readonly pillToneField?: string;
|
|
84
88
|
/** `false`: an empty cell stays blank instead of showing "—". */
|
|
85
89
|
readonly emptyPlaceholder?: false;
|
|
86
90
|
};
|
|
@@ -187,7 +191,7 @@ export type EditFieldViewModel = {
|
|
|
187
191
|
* toggle instead of the default combobox dropdown. Set for
|
|
188
192
|
* `type: "select"` when SelectFieldDef.display is "radio" or "dropdown" —
|
|
189
193
|
* the renderer then skips its own radio-vs-dropdown heuristic. */
|
|
190
|
-
readonly display?: "checkboxes" | "dropdown" | "radio";
|
|
194
|
+
readonly display?: "checkboxes" | "chips" | "dropdown" | "radio";
|
|
191
195
|
/** `type: "select"` only: tone per option, shown on the selected radio segment. */
|
|
192
196
|
readonly optionTones?: Readonly<Partial<Record<string, SelectOptionTone>>>;
|
|
193
197
|
/** Set for `type: "multiSelect"` when MultiSelectFieldDef.columns is
|
|
@@ -289,6 +293,10 @@ export type EditFieldViewModel = {
|
|
|
289
293
|
readonly suffix?: FieldAffix;
|
|
290
294
|
/** From EditFieldSpec.fillAction, `label` already translated. */
|
|
291
295
|
readonly fillAction?: FieldFillAction;
|
|
296
|
+
/** From EditFieldSpec.aiAssist, chip labels and the prompt placeholder already translated. */
|
|
297
|
+
readonly aiAssist?: FieldAiAssist;
|
|
298
|
+
/** From EditFieldSpec.valueChips. */
|
|
299
|
+
readonly valueChips?: FieldValueChips;
|
|
292
300
|
/** Only set for an embedded-LIST field (`multiple: true`) — the per-cell
|
|
293
301
|
* metadata the renderer needs to draw each column/cell. Absent for a
|
|
294
302
|
* plain (non-list) embedded field. */
|
|
@@ -331,7 +339,7 @@ export type EditFieldViewModel = {
|
|
|
331
339
|
readonly field: string;
|
|
332
340
|
};
|
|
333
341
|
};
|
|
334
|
-
export type EditSectionViewModel = EditFieldsSectionViewModel | EditExtensionSectionViewModel | EditRelatedListSectionViewModel | EditWriteFormSectionViewModel;
|
|
342
|
+
export type EditSectionViewModel = EditFieldsSectionViewModel | EditExtensionSectionViewModel | EditRelatedListSectionViewModel | EditWriteFormSectionViewModel | EditStepListSectionViewModel;
|
|
335
343
|
export type EditFieldsSectionViewModel = {
|
|
336
344
|
readonly kind: "fields";
|
|
337
345
|
/** From `EditFieldsSection.id`. The boot-validator makes it mandatory under
|
|
@@ -394,6 +402,19 @@ export type EditExtensionSectionViewModel = {
|
|
|
394
402
|
/** From `EditExtensionSection.actions`. */
|
|
395
403
|
readonly actions?: readonly RowAction[];
|
|
396
404
|
};
|
|
405
|
+
export type EditStepListSectionViewModel = {
|
|
406
|
+
readonly kind: "stepList";
|
|
407
|
+
readonly id?: string;
|
|
408
|
+
readonly title?: string;
|
|
409
|
+
/** Read from the record at view-model time; texts are already translated. */
|
|
410
|
+
readonly items: readonly {
|
|
411
|
+
readonly title: string;
|
|
412
|
+
readonly status?: string;
|
|
413
|
+
readonly statusTone?: SelectOptionTone;
|
|
414
|
+
readonly description?: string;
|
|
415
|
+
}[];
|
|
416
|
+
readonly actions?: undefined;
|
|
417
|
+
};
|
|
397
418
|
export type EditRelatedListSectionViewModel = {
|
|
398
419
|
readonly kind: "relatedList";
|
|
399
420
|
readonly id?: string;
|
|
@@ -426,6 +447,11 @@ export type EditRelatedListSectionViewModel = {
|
|
|
426
447
|
* Section's title row, distinct from `toolbarActions` (which render
|
|
427
448
|
* above the table itself). */
|
|
428
449
|
readonly actions?: readonly RowAction[];
|
|
450
|
+
/** From `EditRelatedListSection.photoGrid` — draws the rows as image tiles. */
|
|
451
|
+
readonly photoGrid?: {
|
|
452
|
+
readonly imageField: string;
|
|
453
|
+
readonly captionField?: string;
|
|
454
|
+
};
|
|
429
455
|
/** From `EditRelatedListSection.emptyState` — forwarded to the
|
|
430
456
|
* DataTable's `emptyState` prop when the section has zero rows. */
|
|
431
457
|
readonly emptyState?: {
|
package/dist/i18n-defaults.js
CHANGED
|
@@ -48,6 +48,8 @@ export const kumikoDefaultTranslations = {
|
|
|
48
48
|
"kumiko.field.file-list.preview": "Preview",
|
|
49
49
|
"kumiko.field.file-list.view": "View",
|
|
50
50
|
"kumiko.field.fillAction.failed": "Could not fetch a suggestion.",
|
|
51
|
+
"kumiko.field.aiAssist.prompt": "Tell the AI what to change",
|
|
52
|
+
"kumiko.field.aiAssist.failed": "The AI could not rewrite the text.",
|
|
51
53
|
"kumiko.field.writeOnly.remove": "Remove stored value",
|
|
52
54
|
"kumiko.field.writeOnly.set": "Set",
|
|
53
55
|
"kumiko.field.writeOnly.maskedSet": "•••••••••• set",
|
package/dist/index.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export { InsideDrawerProvider, useInsideDrawer } from "./inside-drawer.ts";
|
|
|
94
94
|
export { hasUnsavedInput, registerUnsavedInputSource, requestLeave, setLeaveConfirmer, useUnsavedInputSource, } from "./leave-guard.ts";
|
|
95
95
|
export { LeaveGuardDialog } from "./leave-guard-dialog.tsx";
|
|
96
96
|
export { PageHeaderCompactProvider, PageHeaderSlotAvailableProvider, usePageHeaderCompact, usePageHeaderSlotAvailable, } from "./page-header-slot.ts";
|
|
97
|
-
export type { ActionMenuItemSpec, ActionOverflowMenuProps, AppPrimitives, BannerProps, BulkRowOutcome, ButtonProps, CardOptions, CardProps, CardSlots, CopyButtonProps, CorePrimitives, DataTableBulk, DataTableBulkAction, DataTableDateRangeFacet, DataTableFacet, DataTableFacetChip, DataTableProps, DataTableRowAction, DataTableRowActionMode, DataTableSort, DataTableSortDir, DialogProps, DrawerProps, EmbeddedListCellType, EmbeddedListColumn, EmbeddedListInputProps, EmbeddedListTotal, FieldCellWidth, FieldProps, FileValueListProps, FillContainerProps, FooterActionMarker, FooterActionRole, FormProps, FormSectionNavItem, FormWidth, GridCellProps, GridProps, HeadingProps, InputEndAction, InputFillAction, InputProps, JsonViewProps, LightboxImage, LightboxProps, LinkProps, MetricBandProps, MetricProps, ModalProps, PageHeaderProps, PickedFile, PrimitivesProviderProps, PrimitivesRegistry, ProgressProps, ProgressTone, PromoPanelAction, PromoPanelProps, RecordBreadcrumbProps, RecordStepsProps, RecordSummaryProps, RuntimeRenderer, SecretRevealProps, SecretRevealValue, SectionProps, ShareButtonProps, StatusBadgeProps, StatusTone, StepBarProps, StickyActionBarProps, StickyPrimaryActionMarker, TabsProps, TextProps, TrailingInputAction, WizardStepGroupProps, } from "./primitives.tsx";
|
|
97
|
+
export type { ActionMenuItemSpec, ActionOverflowMenuProps, AppPrimitives, BannerProps, BulkRowOutcome, ButtonProps, CardOptions, CardProps, CardSlots, CopyButtonProps, CorePrimitives, DataTableBulk, DataTableBulkAction, DataTableDateRangeFacet, DataTableFacet, DataTableFacetChip, DataTableProps, DataTableRowAction, DataTableRowActionMode, DataTableSort, DataTableSortDir, DialogProps, DrawerProps, EmbeddedListCellType, EmbeddedListColumn, EmbeddedListInputProps, EmbeddedListTotal, FieldCellWidth, FieldProps, FileValueListProps, FillContainerProps, FooterActionMarker, FooterActionRole, FormProps, FormSectionNavItem, FormWidth, GridCellProps, GridProps, HeadingProps, InputEndAction, InputFillAction, InputProps, JsonViewProps, LightboxImage, LightboxProps, LinkProps, MetricBandProps, MetricProps, ModalProps, PageHeaderProps, PhotoGridProps, PickedFile, PrimitivesProviderProps, PrimitivesRegistry, ProgressProps, ProgressTone, PromoPanelAction, PromoPanelProps, RecordBreadcrumbProps, RecordStepsProps, RecordSummaryProps, RuntimeRenderer, SecretRevealProps, SecretRevealValue, SectionProps, ShareButtonProps, StatusBadgeProps, StatusTone, StepBarProps, StepListProps, StickyActionBarProps, StickyPrimaryActionMarker, TabsProps, TextProps, TrailingInputAction, WizardStepGroupProps, } from "./primitives.tsx";
|
|
98
98
|
export { FOOTER_ACTION_ROLE_PROP, NARROW_LABEL_PROP, PrimitivesProvider, STICKY_PRIMARY_ACTION_PROP, shouldRenderActionsIconOnly, statusToneForOptionTone, statusToneForValue, useOptionalPrimitives, usePrimitives, } from "./primitives.tsx";
|
|
99
99
|
export type { SessionEndedSignal, SessionEndedSignalProviderProps, } from "./session/session-ended.tsx";
|
|
100
100
|
export { createSessionEndedSignal, isSessionEndedError, SESSION_ENDED_ERROR_CODES, SessionEndedSignalProvider, useSessionEndedSignal, withSessionEndedDetection, } from "./session/session-ended.tsx";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
1
|
+
import type { NavIconKey, SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import type { CellLink } from "./headless/index.ts";
|
|
4
4
|
/** Path above a record header; an item with a `link` is a link, the last item without one names the current record. */
|
|
@@ -16,6 +16,31 @@ export type RecordSummaryProps = {
|
|
|
16
16
|
/** Shown instead of `text` below the sm breakpoint. */
|
|
17
17
|
readonly narrowText?: string;
|
|
18
18
|
readonly tone?: SelectOptionTone;
|
|
19
|
+
/** Leads the sentence; the sentence then has no bordered box. */
|
|
20
|
+
readonly icon?: NavIconKey;
|
|
21
|
+
readonly testId?: string;
|
|
22
|
+
};
|
|
23
|
+
/** Grid of image tiles; each tile shows a stored file and its own action buttons underneath. */
|
|
24
|
+
export type PhotoGridProps = {
|
|
25
|
+
readonly tiles: readonly {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
/** FileRef id of the image; a tile without one shows a placeholder. */
|
|
28
|
+
readonly imageId?: string;
|
|
29
|
+
readonly caption?: string;
|
|
30
|
+
readonly actions?: ReactNode;
|
|
31
|
+
}[];
|
|
32
|
+
readonly testId?: string;
|
|
33
|
+
};
|
|
34
|
+
/** Vertical numbered steps joined by a line; each step has a title, an optional status pill and
|
|
35
|
+
* a description line. */
|
|
36
|
+
export type StepListProps = {
|
|
37
|
+
readonly items: readonly {
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly title: string;
|
|
40
|
+
readonly status?: string;
|
|
41
|
+
readonly statusTone?: SelectOptionTone;
|
|
42
|
+
readonly description?: string;
|
|
43
|
+
}[];
|
|
19
44
|
readonly testId?: string;
|
|
20
45
|
};
|
|
21
46
|
/** "Next steps" panel; an item's `reason` sits behind a toggle labelled `reasonLabel`. */
|
|
@@ -30,6 +55,8 @@ export type RecordStepsProps = {
|
|
|
30
55
|
/** Toggle label for the hidden steps; receives their count. */
|
|
31
56
|
readonly moreLabel?: (hiddenCount: number) => string;
|
|
32
57
|
readonly lessLabel?: string;
|
|
58
|
+
/** Label before the further actions of each item. */
|
|
59
|
+
readonly moreActionsLabel?: string;
|
|
33
60
|
readonly items: readonly {
|
|
34
61
|
readonly id: string;
|
|
35
62
|
readonly title: string;
|
package/dist/primitives.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { DataTableTableBlock } from "./data-table-view-types.ts";
|
|
|
8
8
|
import type { EmbeddedListInputProps } from "./embedded-list-types.ts";
|
|
9
9
|
import type { FieldIssue, ListColumnViewModel, ListRowViewModel, RuntimeRenderer } from "./headless/index.ts";
|
|
10
10
|
import type { MetricBandProps, MetricProps } from "./metric-types.ts";
|
|
11
|
-
import type { RecordBreadcrumbProps, RecordStepsProps, RecordSummaryProps } from "./primitives-record-guidance.ts";
|
|
11
|
+
import type { PhotoGridProps, RecordBreadcrumbProps, RecordStepsProps, RecordSummaryProps, StepListProps } from "./primitives-record-guidance.ts";
|
|
12
12
|
import type { StatusBadgeOptionTone, StatusTone } from "./status-tone.ts";
|
|
13
13
|
export type { EmbeddedListCellType, EmbeddedListColumn, EmbeddedListInputProps, EmbeddedListTotal, } from "./embedded-list-types.ts";
|
|
14
14
|
export type { RuntimeRenderer };
|
|
@@ -23,7 +23,8 @@ export type DataAttributes = Readonly<Record<`data-${string}`, string>>;
|
|
|
23
23
|
* split can't inspect (see `ScreenSlots.footerPrimary`). */
|
|
24
24
|
export declare const STICKY_PRIMARY_ACTION_PROP: "kumikoStickyPrimaryAction";
|
|
25
25
|
export type StickyPrimaryActionMarker = Partial<Record<typeof STICKY_PRIMARY_ACTION_PROP, boolean>>;
|
|
26
|
-
|
|
26
|
+
/** "inline" keeps a non-primary action as a visible button in the phone footer instead of the "…" menu. */
|
|
27
|
+
export type FooterActionRole = "back" | "primary" | "inline";
|
|
27
28
|
/** Tells the pinned phone footer which node is Back and which is the primary
|
|
28
29
|
* action, for buttons that are not `type="submit"` (e.g. the wizard Back). */
|
|
29
30
|
export declare const FOOTER_ACTION_ROLE_PROP: "kumikoFooterActionRole";
|
|
@@ -696,7 +697,7 @@ export declare function shouldRenderActionsIconOnly(actions: readonly {
|
|
|
696
697
|
export type { BulkRowOutcome, DataTableBulk, DataTableBulkAction, } from "./data-table-bulk-types.ts";
|
|
697
698
|
export type { DataTableDateRangeFacet, DataTableFacet, DataTableFacetChip, } from "./data-table-facet-types.ts";
|
|
698
699
|
export type { MetricBandProps, MetricProps } from "./metric-types.ts";
|
|
699
|
-
export type { RecordBreadcrumbProps, RecordStepsProps, RecordSummaryProps, } from "./primitives-record-guidance.ts";
|
|
700
|
+
export type { PhotoGridProps, RecordBreadcrumbProps, RecordStepsProps, RecordSummaryProps, StepListProps, } from "./primitives-record-guidance.ts";
|
|
700
701
|
export type DataTableProps = {
|
|
701
702
|
readonly columns: readonly ListColumnViewModel[];
|
|
702
703
|
readonly rows: readonly ListRowViewModel[];
|
|
@@ -1006,6 +1007,8 @@ export type GridProps = {
|
|
|
1006
1007
|
* a `role="group"` so a Field whose control is a set of inputs (checkbox
|
|
1007
1008
|
* group) still gives screen readers a group name. */
|
|
1008
1009
|
readonly ariaLabelledBy?: string;
|
|
1010
|
+
/** With `columns: "auto"`: the small gap of a chip row instead of the tile gap. */
|
|
1011
|
+
readonly tight?: boolean;
|
|
1009
1012
|
};
|
|
1010
1013
|
/** Width class of a field cell inside a `flow` grid: sized by what the field holds. */
|
|
1011
1014
|
export type FieldCellWidth = "text" | "number" | "money" | "date" | "timestamp" | "select" | "full" | "toggle";
|
|
@@ -1495,6 +1498,10 @@ export type CorePrimitives = {
|
|
|
1495
1498
|
readonly RecordBreadcrumb?: ComponentType<RecordBreadcrumbProps>;
|
|
1496
1499
|
/** Optional — without it the summary renders as plain text. */
|
|
1497
1500
|
readonly RecordSummary?: ComponentType<RecordSummaryProps>;
|
|
1501
|
+
/** Optional — without it a relatedList with `photoGrid` falls back to its table. */
|
|
1502
|
+
readonly PhotoGrid?: ComponentType<PhotoGridProps>;
|
|
1503
|
+
/** Optional — without it a stepList section renders nothing. */
|
|
1504
|
+
readonly StepList?: ComponentType<StepListProps>;
|
|
1498
1505
|
/** Optional — without it the steps render as a plain card. */
|
|
1499
1506
|
readonly RecordSteps?: ComponentType<RecordStepsProps>;
|
|
1500
1507
|
/** Optional: without an implementation, callers with >2 header/row
|
|
@@ -6,6 +6,7 @@ import { buildScopeBadge, dashboardDescription, recordTitleText, renderActionErr
|
|
|
6
6
|
import { ListPanelBody } from "./dashboard-list-panel.js";
|
|
7
7
|
import { HiddenOnNarrow } from "./dashboard-narrow-gate.js";
|
|
8
8
|
import { panelsInNarrowOrder } from "./dashboard-narrow-order.js";
|
|
9
|
+
import { DashboardPanelGrid } from "./dashboard-panel-columns.js";
|
|
9
10
|
import { ChartPanelBody, CustomPanelBody, FeedPanelBody, ProgressListPanelBody, StatPanelBody, } from "./dashboard-panels.js";
|
|
10
11
|
import { ScreenPanelTile } from "./dashboard-screen-tiles.js";
|
|
11
12
|
import { DashboardQueryContext, HALF_PANEL, PanelLoadedContext, STAT_PANEL, THIRD_PANEL, TWO_THIRDS_PANEL, useDashboardFormats, WIDE_PANEL, } from "./dashboard-shared.js";
|
|
@@ -54,7 +55,7 @@ function PanelBody({ panel, label, featureName, screenId, screenParams, translat
|
|
|
54
55
|
return (_jsx(FeedPanelBody, { panel: panel, label: text, screenParams: screenParams, translate: translate }));
|
|
55
56
|
}
|
|
56
57
|
if (panel.kind === "text") {
|
|
57
|
-
return (_jsx(TextPanelBody, { panel: panel, label: label, screenParams: screenParams, translate: translate }));
|
|
58
|
+
return (_jsx(TextPanelBody, { screenId: screenId, panel: panel, label: label, screenParams: screenParams, translate: translate }));
|
|
58
59
|
}
|
|
59
60
|
return (_jsx(ProgressListPanelBody, { panel: panel, label: text, screenParams: screenParams, translate: translate }));
|
|
60
61
|
}
|
|
@@ -106,5 +107,5 @@ export function WebDashboardBody({ featureName, screen, translate, }) {
|
|
|
106
107
|
const headerActionsBar = renderHeaderActionsBar(model);
|
|
107
108
|
// The shell header owns the title; the badge and the actions sit in it there.
|
|
108
109
|
const badgeInHeader = scopeBadge !== null && usesPageHeaderSlot;
|
|
109
|
-
return (_jsx(PanelLoadedContext.Provider, { value: params.reportLoaded, children: _jsx(DashboardQueryContext.Provider, { value: record.queryRuntime, children: _jsxs(PageSection, { className: "flex flex-col gap-4", testId: `dashboard-${screen.id}`, children: [renderPageHeaderSlot(model, headerActionsBar, badgeInHeader), renderTitleRow(model, headerActionsBar, badgeInHeader), renderActionErrorBanner(primitives, actionError), renderRecordError(model, recordQuery.error, recordRow, refetchRecord), renderDescriptionAndNotice(model, description), _jsxs(VisibilityQueryContext.Provider, { value: visibility.gateResultsWithPending, children: [_jsx(VisibilityGateQueries, { gates: visibility.visibilityGates, onResult: visibility.gateResults.report, onForget: visibility.gateResults.forget }), _jsx(
|
|
110
|
+
return (_jsx(PanelLoadedContext.Provider, { value: params.reportLoaded, children: _jsx(DashboardQueryContext.Provider, { value: record.queryRuntime, children: _jsxs(PageSection, { className: "flex flex-col gap-4", testId: `dashboard-${screen.id}`, children: [renderPageHeaderSlot(model, headerActionsBar, badgeInHeader), renderTitleRow(model, headerActionsBar, badgeInHeader), renderActionErrorBanner(primitives, actionError), renderRecordError(model, recordQuery.error, recordRow, refetchRecord), renderDescriptionAndNotice(model, description), _jsxs(VisibilityQueryContext.Provider, { value: visibility.gateResultsWithPending, children: [_jsx(VisibilityGateQueries, { gates: visibility.visibilityGates, onResult: visibility.gateResults.report, onForget: visibility.gateResults.forget }), _jsx(DashboardPanelGrid, { layout: screen.layout, panels: panelsInNarrowOrder(screen.panels, belowSm), belowSm: belowSm, renderPanel: (panel) => renderDashboardPanel(panel, featureName, screen.id, screenParams, effectiveTranslate) })] })] }) }) }));
|
|
110
111
|
}
|
|
@@ -103,6 +103,7 @@ export function ListPanelBody({ panel, label, featureName, screenId, screenParam
|
|
|
103
103
|
field: normalized.field,
|
|
104
104
|
label: translate(normalized.label ?? normalized.field),
|
|
105
105
|
...(normalized.display !== undefined && { display: normalized.display }),
|
|
106
|
+
...(normalized.variant !== undefined && { buttonVariant: normalized.variant }),
|
|
106
107
|
...(normalized.badgeToneField !== undefined && {
|
|
107
108
|
badgeToneField: normalized.badgeToneField,
|
|
108
109
|
}),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DashboardPanelDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
/** Panel grid, or the main/side columns of `layout: "main-side"`; below sm everything is one list in `narrowOrder`. */
|
|
4
|
+
export declare function DashboardPanelGrid({ layout, panels, belowSm, renderPanel, }: {
|
|
5
|
+
readonly layout: "main-side" | undefined;
|
|
6
|
+
readonly panels: readonly DashboardPanelDefinition[];
|
|
7
|
+
readonly belowSm: boolean;
|
|
8
|
+
readonly renderPanel: (panel: DashboardPanelDefinition) => ReactNode;
|
|
9
|
+
}): ReactNode;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
const GRID_CLASS = "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-12";
|
|
3
|
+
const COLUMNS_CLASS = "grid grid-cols-1 gap-4 lg:grid-cols-3";
|
|
4
|
+
const COLUMN_CLASS = "flex min-w-0 flex-col gap-4";
|
|
5
|
+
/** Panel grid, or the main/side columns of `layout: "main-side"`; below sm everything is one list in `narrowOrder`. */
|
|
6
|
+
export function DashboardPanelGrid({ layout, panels, belowSm, renderPanel, }) {
|
|
7
|
+
if (layout !== "main-side" || belowSm) {
|
|
8
|
+
return (_jsx("div", { className: layout === "main-side" ? COLUMN_CLASS : GRID_CLASS, children: panels.map(renderPanel) }));
|
|
9
|
+
}
|
|
10
|
+
const topPanels = panels.filter((panel) => panel.column === "top");
|
|
11
|
+
return (_jsxs("div", { className: COLUMN_CLASS, children: [topPanels.length > 0 && (_jsx("div", { className: COLUMN_CLASS, "data-testid": "dashboard-column-top", children: topPanels.map(renderPanel) })), _jsxs("div", { className: COLUMNS_CLASS, "data-testid": "dashboard-columns", children: [_jsx("div", { className: `${COLUMN_CLASS} lg:col-span-2`, "data-testid": "dashboard-column-main", children: panels
|
|
12
|
+
.filter((panel) => panel.column !== "side" && panel.column !== "top")
|
|
13
|
+
.map(renderPanel) }), _jsx("div", { className: COLUMN_CLASS, "data-testid": "dashboard-column-side", children: panels.filter((panel) => panel.column === "side").map(renderPanel) })] })] }));
|
|
14
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useCallback, useContext, useEffect, useRef, useState, } from "react";
|
|
3
|
+
import { resolveSafeLocale } from "../../headless/format/safe-locale.js";
|
|
3
4
|
import { currencyDecimals } from "../../headless/index.js";
|
|
4
5
|
import { dispatcherErrorText, useLocale, usePrimitives, useQuery, useTranslation, } from "../../index.js";
|
|
5
6
|
import { serverNowMs } from "../../server-clock.js";
|
|
6
7
|
import { cn } from "../lib/cn.js";
|
|
7
|
-
import { resolveSafeLocale } from "../primitives/locale-number.js";
|
|
8
8
|
import { formatMoney } from "../primitives/money-input.js";
|
|
9
9
|
import { Skeleton } from "../ui/skeleton.js";
|
|
10
10
|
import { EmptyState, LoadingState } from "../widgets/states.js";
|
|
@@ -4,6 +4,7 @@ import { useNav } from "../../app/nav.js";
|
|
|
4
4
|
import { navigateTargetAllows } from "../../app/screen-access.js";
|
|
5
5
|
import { extensionSectionName, useAppFeatures, useExtensionSectionComponent, usePrimitives, useUserRoles, } from "../../index.js";
|
|
6
6
|
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { useIsBelowSmViewport } from "../primitives/use-narrow-viewport.js";
|
|
7
8
|
import "../react-css-custom-properties.js";
|
|
8
9
|
import { STAT_CARD_GRID_CLASSES } from "../widgets/stat.js";
|
|
9
10
|
import { dashboardNavigationLink } from "./dashboard-navigation-link.js";
|
|
@@ -36,8 +37,13 @@ function StatGroupLink({ link, translate, stretchOnNarrow, }) {
|
|
|
36
37
|
? "ml-auto flex shrink-0 items-center gap-1 text-sm font-medium max-sm:after:absolute max-sm:after:inset-0"
|
|
37
38
|
: "ml-auto flex shrink-0 items-center gap-1 text-sm font-medium", children: [_jsx("span", { className: stretchOnNarrow ? "max-sm:sr-only" : undefined, children: translate(link.label) }), _jsx(ChevronRight, { className: "size-4", "aria-hidden": "true" })] }));
|
|
38
39
|
}
|
|
40
|
+
/** A child with `hideOnNarrow` is not mounted on a phone, so it runs no query and leaves no gap. */
|
|
41
|
+
function statsForViewport(stats, belowSm) {
|
|
42
|
+
return belowSm ? stats.filter((stat) => stat.hideOnNarrow !== true) : stats;
|
|
43
|
+
}
|
|
39
44
|
function StatCells({ panel, screenId, screenParams, translate, variant, }) {
|
|
40
|
-
|
|
45
|
+
const belowSm = useIsBelowSmViewport();
|
|
46
|
+
return statsForViewport(panel.stats, belowSm).map((stat) => (_jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: screenId, screenParams: screenParams, translate: translate, variant: variant }, stat.id)));
|
|
41
47
|
}
|
|
42
48
|
function FlatStatStrip(props) {
|
|
43
49
|
const { panel, translate } = props;
|
|
@@ -52,7 +58,8 @@ function PhoneStripIcon({ panel, screenId, screenParams, }) {
|
|
|
52
58
|
function TitledStatStrip(props) {
|
|
53
59
|
const { panel, label, translate } = props;
|
|
54
60
|
const navigateAllowed = useStatNavigateAllowed();
|
|
55
|
-
const
|
|
61
|
+
const belowSm = useIsBelowSmViewport();
|
|
62
|
+
const stats = statsForViewport(panel.stats, belowSm).filter(navigateAllowed);
|
|
56
63
|
return (_jsxs("div", { "data-testid": `dashboard-panel-${panel.id}`, "data-narrow-tone": panel.narrow?.tone, style: { "--stat-count": stats.length }, className: cn(
|
|
57
64
|
// Board grid: title column, one equal column per stat, link column.
|
|
58
65
|
panel.link === undefined
|
|
@@ -5,6 +5,7 @@ import { type ScreenParams } from "./dashboard-shared.tsx";
|
|
|
5
5
|
type TextPanelBodyProps = {
|
|
6
6
|
readonly panel: DashboardTextPanel;
|
|
7
7
|
readonly label: string | undefined;
|
|
8
|
+
readonly screenId: string;
|
|
8
9
|
readonly screenParams: ScreenParams;
|
|
9
10
|
readonly translate: Translate;
|
|
10
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { navigateTargetAllows } from "../../app/screen-access.js";
|
|
3
|
-
import { lastSegment, useAppFeatures, useNav, usePrimitives, useUserRoles } from "../../index.js";
|
|
3
|
+
import { extensionSectionName, lastSegment, useAppFeatures, useExtensionSectionComponent, useNav, usePrimitives, useUserRoles, } from "../../index.js";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
import { useIsBelowSmViewport } from "../primitives/use-narrow-viewport.js";
|
|
6
6
|
import { PanelError, PanelShell, PanelSkeleton, panelPayload, useDashboardFormats, useDashboardQuery, useReportPanelLoaded, } from "./dashboard-shared.js";
|
|
@@ -121,27 +121,29 @@ function textBlockKey(block) {
|
|
|
121
121
|
return `${block.kind}:${textKey(block.text)}`;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
function TextPanelFrame({ panel, label, children, }) {
|
|
124
|
+
function TextPanelFrame({ panel, label, screenId, screenParams, children, }) {
|
|
125
125
|
const testId = `dashboard-panel-${panel.id}`;
|
|
126
|
+
const Icon = useExtensionSectionComponent(panel.icon !== undefined ? extensionSectionName(panel.icon) : undefined);
|
|
127
|
+
const content = Icon === undefined ? (children) : (_jsxs("div", { className: "flex items-start gap-3", children: [_jsx("span", { "data-testid": `${testId}-icon`, className: "flex shrink-0 items-center pt-0.5", children: _jsx(Icon, { entityName: screenId, entityId: null, screenId: screenId, filterParams: screenParams.filterParams }) }), _jsx("div", { className: "min-w-0 grow", children: children })] }));
|
|
126
128
|
if (label !== undefined) {
|
|
127
|
-
return (_jsx(PanelShell, { testId: testId, title: label, children:
|
|
129
|
+
return (_jsx(PanelShell, { testId: testId, title: label, children: content }));
|
|
128
130
|
}
|
|
129
|
-
return (_jsx("section", { "data-testid": testId, className: "h-full rounded-lg border border-border bg-card p-4 text-card-foreground max-sm:px-3.5 max-sm:py-3", children:
|
|
131
|
+
return (_jsx("section", { "data-testid": testId, className: "h-full rounded-lg border border-border bg-card p-4 text-card-foreground max-sm:px-3.5 max-sm:py-3", children: content }));
|
|
130
132
|
}
|
|
131
133
|
function TextBlockList({ blocks, translate, }) {
|
|
132
134
|
return (_jsx("div", { className: "flex flex-col gap-3", children: withOccurrenceKeys(blocks, textBlockKey).map(({ entry, key }, index) => (_jsx(TextBlockView, { block: entry, translate: translate, followsLead: isLeadParagraph(blocks[index - 1]) }, key))) }));
|
|
133
135
|
}
|
|
134
136
|
export function TextPanelBody(props) {
|
|
135
|
-
const { panel, label, translate } = props;
|
|
137
|
+
const { panel, label, translate, screenId, screenParams } = props;
|
|
136
138
|
const narrow = useIsBelowSmViewport();
|
|
137
139
|
if (panel.query === undefined) {
|
|
138
|
-
return (_jsx(TextPanelFrame, { panel: panel, label: label, children: _jsx(TextBlockList, { blocks: (narrow ? panel.narrowBlocks : undefined) ?? panel.blocks ?? [], translate: translate }) }));
|
|
140
|
+
return (_jsx(TextPanelFrame, { panel: panel, label: label, screenId: screenId, screenParams: screenParams, children: _jsx(TextBlockList, { blocks: (narrow ? panel.narrowBlocks : undefined) ?? panel.blocks ?? [], translate: translate }) }));
|
|
139
141
|
}
|
|
140
142
|
return _jsx(QueryTextPanelBody, { ...props, query: panel.query });
|
|
141
143
|
}
|
|
142
144
|
// Not QueryPanel: that shell shows a skeleton/error/empty state instead of content, but the
|
|
143
145
|
// static blocks are the fallback here and must stay visible while the query loads, fails or is empty.
|
|
144
|
-
function QueryTextPanelBody({ panel, query, label, screenParams, translate, }) {
|
|
146
|
+
function QueryTextPanelBody({ panel, query, label, screenId, screenParams, translate, }) {
|
|
145
147
|
const { data, error, loading, refetch } = useDashboardQuery(query, panelPayload(panel, screenParams));
|
|
146
148
|
useReportPanelLoaded(data, loading);
|
|
147
149
|
const narrow = useIsBelowSmViewport();
|
|
@@ -163,5 +165,5 @@ function QueryTextPanelBody({ panel, query, label, screenParams, translate, }) {
|
|
|
163
165
|
else {
|
|
164
166
|
body = null;
|
|
165
167
|
}
|
|
166
|
-
return (_jsx(TextPanelFrame, { panel: panel, label: label, children: body }));
|
|
168
|
+
return (_jsx(TextPanelFrame, { panel: panel, label: label, screenId: screenId, screenParams: screenParams, children: body }));
|
|
167
169
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/** "5 minutes ago" / "in 30 seconds" in the given locale. The unit grows with the
|
|
2
|
-
* distance (seconds below a minute, minutes below an hour, hours below a day,
|
|
3
|
-
* days beyond); each step is chosen on the already rounded value so 59.6 minutes
|
|
4
|
-
* reads "1 hour" instead of "60 minutes". `numeric: "auto"` yields "now" and "yesterday". */
|
|
5
|
-
export declare function formatRelativeTime(atMs: number, nowMs: number, locale: string): string;
|
|
6
1
|
/** Interval at which a relative text at `distanceMs` from now needs a redraw. */
|
|
7
2
|
export declare function relativeTickIntervalMs(distanceMs: number): number;
|
|
8
3
|
/** Returns a formatter for relative times that redraws its component on a timer, but
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { formatRelativeTime } from "../../headless/format/relative-time.js";
|
|
2
3
|
import { serverNowMs } from "../../server-clock.js";
|
|
3
|
-
import { resolveSafeLocale } from "../primitives/locale-number.js";
|
|
4
4
|
const SECONDS_PER_MINUTE = 60;
|
|
5
|
-
const MINUTES_PER_HOUR = 60;
|
|
6
|
-
const HOURS_PER_DAY = 24;
|
|
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
|
-
* days beyond); each step is chosen on the already rounded value so 59.6 minutes
|
|
10
|
-
* reads "1 hour" instead of "60 minutes". `numeric: "auto"` yields "now" and "yesterday". */
|
|
11
|
-
export function formatRelativeTime(atMs, nowMs, locale) {
|
|
12
|
-
const formatter = new Intl.RelativeTimeFormat(resolveSafeLocale(locale), { numeric: "auto" });
|
|
13
|
-
const seconds = Math.round((atMs - nowMs) / 1000);
|
|
14
|
-
if (Math.abs(seconds) < SECONDS_PER_MINUTE)
|
|
15
|
-
return formatter.format(seconds, "second");
|
|
16
|
-
const minutes = Math.round(seconds / SECONDS_PER_MINUTE);
|
|
17
|
-
if (Math.abs(minutes) < MINUTES_PER_HOUR)
|
|
18
|
-
return formatter.format(minutes, "minute");
|
|
19
|
-
const hours = Math.round(minutes / MINUTES_PER_HOUR);
|
|
20
|
-
if (Math.abs(hours) < HOURS_PER_DAY)
|
|
21
|
-
return formatter.format(hours, "hour");
|
|
22
|
-
return formatter.format(Math.round(hours / HOURS_PER_DAY), "day");
|
|
23
|
-
}
|
|
24
5
|
const SECOND_TICK_MS = 1000;
|
|
25
6
|
// Above a minute the text changes at most once per minute; half a minute keeps it
|
|
26
7
|
// at most 30 s late without waking the page every second for a "5 minutes ago".
|