@cosmicdrift/kumiko-renderer 0.416.0 → 0.418.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/action-form-body.d.ts +1 -4
- package/dist/app/action-form-body.js +14 -9
- package/dist/app/action-form-preview.d.ts +13 -0
- package/dist/app/action-form-preview.js +66 -0
- package/dist/app/action-form-support.d.ts +6 -1
- package/dist/app/action-form-support.js +26 -9
- package/dist/app/config-edit-body.js +71 -79
- package/dist/app/entity-list-screen.js +1 -1
- package/dist/app/header-actions-bar.d.ts +3 -1
- package/dist/app/header-actions-bar.js +12 -4
- package/dist/app/list-bulk-actions.d.ts +8 -1
- package/dist/app/list-bulk-actions.js +28 -4
- package/dist/app/locked-screen-header.d.ts +2 -0
- package/dist/app/locked-screen-header.js +8 -1
- package/dist/app/projection-detail-body.js +24 -5
- package/dist/app/projection-detail-guidance.d.ts +1 -0
- package/dist/app/projection-detail-guidance.js +7 -4
- package/dist/app/projection-detail-header-model.js +4 -1
- package/dist/app/projection-detail-header-region.js +25 -9
- package/dist/app/projection-detail-header.d.ts +2 -0
- package/dist/app/projection-detail-header.js +30 -3
- package/dist/app/projection-list-shim.js +1 -0
- package/dist/app/row-actions.d.ts +4 -0
- package/dist/app/row-actions.js +19 -3
- package/dist/app/use-projection-detail-actions.d.ts +3 -1
- package/dist/app/use-projection-detail-actions.js +9 -1
- package/dist/app/use-projection-detail-data.js +17 -1
- package/dist/app/use-projection-list-data.js +1 -1
- package/dist/card-options.d.ts +2 -0
- package/dist/components/choice-chip-class.d.ts +1 -0
- package/dist/components/choice-chip-class.js +9 -0
- package/dist/components/edit-mounts.d.ts +1 -1
- package/dist/components/embedded-list-paste.js +2 -2
- package/dist/components/grid-cell-for-field.js +1 -1
- package/dist/components/multi-select-chips.js +7 -2
- package/dist/components/multi-select-count.d.ts +5 -0
- package/dist/components/multi-select-count.js +10 -0
- package/dist/components/narrow-description.d.ts +3 -0
- package/dist/components/narrow-description.js +12 -0
- package/dist/components/related-list-section.d.ts +5 -3
- package/dist/components/related-list-section.js +9 -4
- package/dist/components/related-photo-grid.js +17 -3
- package/dist/components/render-edit-field-grid.d.ts +12 -3
- package/dist/components/render-edit-field-grid.js +60 -18
- package/dist/components/render-edit-fields-section.js +45 -11
- package/dist/components/render-edit-header-actions.js +1 -1
- package/dist/components/render-edit-layout.js +5 -3
- package/dist/components/render-edit-section-kinds.js +50 -12
- package/dist/components/render-edit-titles.js +1 -1
- package/dist/components/render-edit-types.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +26 -7
- package/dist/components/render-field-choice-inputs.js +3 -0
- package/dist/components/render-field-control.js +1 -1
- package/dist/components/render-field-value-chips.js +6 -4
- package/dist/components/render-field-values.js +3 -3
- package/dist/components/render-list-hint-columns.d.ts +1 -0
- package/dist/components/render-list-hint-columns.js +30 -5
- package/dist/components/render-list-reference-columns.js +2 -4
- package/dist/components/render-list-row-tone.d.ts +2 -0
- package/dist/components/render-list-row-tone.js +6 -0
- package/dist/components/render-list-table-props.d.ts +13 -2
- package/dist/components/render-list-table-props.js +9 -3
- package/dist/components/render-list-types.d.ts +4 -0
- package/dist/components/render-list.js +12 -4
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/components/write-form-registry.d.ts +13 -0
- package/dist/components/write-form-registry.js +6 -0
- package/dist/components/write-form-section.d.ts +5 -1
- package/dist/components/write-form-section.js +55 -16
- package/dist/data-table-bulk-types.d.ts +11 -2
- package/dist/data-table-bulk-types.js +3 -1
- package/dist/headless/form/form-controller.d.ts +2 -0
- package/dist/headless/form/form-controller.js +2 -2
- package/dist/headless/format/index.d.ts +1 -1
- package/dist/headless/format/index.js +6 -5
- package/dist/headless/format/money.d.ts +5 -0
- package/dist/headless/format/money.js +10 -0
- package/dist/headless/format/relative-time.d.ts +2 -0
- package/dist/headless/format/relative-time.js +4 -1
- package/dist/headless/index.d.ts +1 -1
- package/dist/headless/index.js +1 -1
- package/dist/headless/view-model/edit.js +87 -37
- package/dist/headless/view-model/list.js +6 -0
- package/dist/headless/view-model/types.d.ts +50 -5
- package/dist/hooks/use-bulk-run.d.ts +2 -2
- package/dist/hooks/use-list-table.js +11 -6
- package/dist/i18n-defaults.js +8 -2
- package/dist/primitives-record-guidance.d.ts +4 -0
- package/dist/primitives-share-types.d.ts +82 -0
- package/dist/primitives-share-types.js +1 -0
- package/dist/primitives.d.ts +34 -83
- package/dist/web/app/bold-markup.d.ts +3 -0
- package/dist/web/app/bold-markup.js +14 -0
- package/dist/web/app/dashboard-body.js +5 -1
- package/dist/web/app/dashboard-list-panel.js +7 -4
- package/dist/web/app/dashboard-panels.js +31 -3
- package/dist/web/app/dashboard-shared.d.ts +3 -1
- package/dist/web/app/dashboard-shared.js +3 -3
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +16 -2
- package/dist/web/app/dashboard-text-panel.js +11 -6
- package/dist/web/app/relative-time.js +10 -1
- package/dist/web/components/config-cascade.d.ts +2 -1
- package/dist/web/components/config-cascade.js +16 -4
- package/dist/web/drawn-icons.js +2 -1
- package/dist/web/layout/header-action-pinned.d.ts +4 -2
- package/dist/web/layout/header-action-pinned.js +13 -4
- package/dist/web/layout/header-overflow-menu.d.ts +2 -0
- package/dist/web/layout/header-overflow-menu.js +2 -0
- package/dist/web/layout/nav-tree.js +1 -1
- package/dist/web/layout/notification-bell.js +13 -4
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.js +4 -1
- package/dist/web/layout/shell-header.js +15 -7
- package/dist/web/primitives/banner.js +14 -3
- package/dist/web/primitives/card.js +5 -3
- package/dist/web/primitives/combobox.js +2 -2
- package/dist/web/primitives/data-table/actions-column.js +1 -1
- package/dist/web/primitives/data-table/card-body.d.ts +1 -1
- package/dist/web/primitives/data-table/card-body.js +37 -14
- package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
- package/dist/web/primitives/data-table/card-frame.js +3 -0
- package/dist/web/primitives/data-table/card-row.js +28 -9
- package/dist/web/primitives/data-table/card-sort-select.js +1 -1
- package/dist/web/primitives/data-table/card-view.js +1 -1
- package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -1
- package/dist/web/primitives/data-table/data-cell-props.js +1 -0
- package/dist/web/primitives/data-table/density.d.ts +3 -1
- package/dist/web/primitives/data-table/density.js +11 -4
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -5
- package/dist/web/primitives/data-table/sort-options-select.js +2 -2
- package/dist/web/primitives/data-table/sortable-header.js +4 -4
- package/dist/web/primitives/data-table/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-chrome.js +1 -3
- package/dist/web/primitives/data-table/table-content.js +7 -11
- package/dist/web/primitives/data-table/table-data-cell.js +31 -17
- package/dist/web/primitives/data-table/table-header-row.js +1 -1
- package/dist/web/primitives/data-table/table-view.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +6 -7
- package/dist/web/primitives/data-table/use-bulk-selection.d.ts +1 -1
- package/dist/web/primitives/data-table/use-bulk-selection.js +5 -0
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
- package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
- package/dist/web/primitives/data-table-cell.d.ts +13 -2
- package/dist/web/primitives/data-table-cell.js +125 -53
- package/dist/web/primitives/data-table.js +1 -1
- package/dist/web/primitives/default-form.d.ts +1 -1
- package/dist/web/primitives/default-form.js +11 -10
- package/dist/web/primitives/drawer.js +2 -7
- package/dist/web/primitives/facet-filter.d.ts +1 -1
- package/dist/web/primitives/facet-filter.js +2 -5
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
- package/dist/web/primitives/facet-trigger-label.js +4 -7
- package/dist/web/primitives/field.js +15 -8
- package/dist/web/primitives/form-footer-parts.js +2 -2
- package/dist/web/primitives/inline-suffix.d.ts +2 -0
- package/dist/web/primitives/inline-suffix.js +5 -0
- package/dist/web/primitives/input-choice-kinds.js +12 -2
- package/dist/web/primitives/input-number-kinds.js +2 -2
- package/dist/web/primitives/input-text-kinds.js +1 -1
- package/dist/web/primitives/layout-elements.d.ts +4 -4
- package/dist/web/primitives/layout-elements.js +49 -12
- package/dist/web/primitives/layout.d.ts +1 -1
- package/dist/web/primitives/layout.js +1 -1
- package/dist/web/primitives/metric.js +4 -5
- package/dist/web/primitives/money-input.js +8 -7
- package/dist/web/primitives/number-input.d.ts +2 -1
- package/dist/web/primitives/number-input.js +9 -4
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +8 -1
- package/dist/web/primitives/pager.js +12 -21
- package/dist/web/primitives/photo-grid.js +2 -1
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +6 -15
- package/dist/web/primitives/row-actions.js +38 -24
- package/dist/web/primitives/use-container-narrow.d.ts +12 -0
- package/dist/web/primitives/use-container-narrow.js +42 -0
- package/dist/web/pwa/pwa-support.js +13 -7
- package/dist/web/ui/input.js +1 -1
- package/dist/web/ui/textarea.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.js +6 -3
- package/dist/web/widgets/dashboard-list.d.ts +4 -1
- package/dist/web/widgets/dashboard-list.js +10 -5
- package/dist/web/widgets/progress-list.js +1 -1
- package/dist/web/widgets/stat-box-cell.js +1 -1
- package/package.json +5 -5
- package/src/changes.json +51 -0
- package/src/web/styles.css +3 -2
|
@@ -6,6 +6,7 @@ import { namedFilterNavigateAllows, navigateTargetAllows } from "../../app/scree
|
|
|
6
6
|
import { rendererWarn } from "../../dev-console.js";
|
|
7
7
|
import { EMPTY_VALUE_PLACEHOLDER } from "../../headless/index.js";
|
|
8
8
|
import { extensionSectionName, useAppFeatures, useExtensionSectionComponent, useNav, useTranslation, useUserRoles, } from "../../index.js";
|
|
9
|
+
import { useIsBelowSmViewport } from "../primitives/use-narrow-viewport.js";
|
|
9
10
|
import { initialWindowSelection, } from "../widgets/chart-window.js";
|
|
10
11
|
import { chartToneColor, SegmentBarChart, StackedAreaChart, StackedBarChart, TimeseriesChart, } from "../widgets/charts.js";
|
|
11
12
|
import { FeedList } from "../widgets/feed-list.js";
|
|
@@ -55,6 +56,7 @@ export function StatPanelBody(props) {
|
|
|
55
56
|
}
|
|
56
57
|
function StatPanelContent({ panel, label, screenId, screenParams, translate, variant, }) {
|
|
57
58
|
const formats = useDashboardFormats();
|
|
59
|
+
const belowSm = useIsBelowSmViewport();
|
|
58
60
|
const nav = useNav();
|
|
59
61
|
const link = optionalDashboardNavigationLink(nav, panel.navigate);
|
|
60
62
|
// Resolved HERE (not in a separate always-rendered child) so `icon` on
|
|
@@ -86,7 +88,10 @@ function StatPanelContent({ panel, label, screenId, screenParams, translate, var
|
|
|
86
88
|
(rawValue === 0 ? undefined : panel.tone);
|
|
87
89
|
const sub = panel.subField !== undefined ? record[panel.subField] : undefined;
|
|
88
90
|
const dynamicLabel = panel.labelField !== undefined ? record[panel.labelField] : undefined;
|
|
89
|
-
const
|
|
91
|
+
const staticLabel = belowSm && panel.labelNarrow !== undefined
|
|
92
|
+
? translate(panel.labelNarrow, typeof rawValue === "number" ? { count: rawValue } : {})
|
|
93
|
+
: label;
|
|
94
|
+
const shownLabel = typeof dynamicLabel === "string" && dynamicLabel !== "" ? dynamicLabel : staticLabel;
|
|
90
95
|
const delta = readDelta(panel, record);
|
|
91
96
|
const value = statValueText(rawValue, panel.valueFormat, translate, formats);
|
|
92
97
|
const spark = readSparkline(panel, record);
|
|
@@ -250,8 +255,16 @@ export function ChartPanelBody({ panel, label, screenParams, translate, }) {
|
|
|
250
255
|
}), ariaLabel: label, testId: testId }));
|
|
251
256
|
} }));
|
|
252
257
|
}
|
|
258
|
+
function feedTotalText(showTotal, data, translate) {
|
|
259
|
+
const shown = (data.rows ?? []).length;
|
|
260
|
+
const total = typeof data.total === "number" && Number.isFinite(data.total) ? data.total : shown;
|
|
261
|
+
const key = showTotal === true ? undefined : showTotal.text;
|
|
262
|
+
return translate(key ?? "kumiko.dashboard.list.shown-of-total", { shown, total });
|
|
263
|
+
}
|
|
253
264
|
export function FeedPanelBody({ panel, label, screenParams, translate, }) {
|
|
254
|
-
return (_jsx(QueryPanel, { panel: panel, label: label, screenParams: screenParams, translate: translate, skeleton: "rows", isEmpty: (data) => (data.rows ?? []).length === 0,
|
|
265
|
+
return (_jsx(QueryPanel, { panel: panel, label: label, screenParams: screenParams, translate: translate, skeleton: "rows", isEmpty: (data) => (data.rows ?? []).length === 0, ...(panel.showTotal !== undefined && {
|
|
266
|
+
subtitle: (data) => feedTotalText(panel.showTotal ?? true, data, translate),
|
|
267
|
+
}), children: (data, formats) => {
|
|
255
268
|
const rows = (data.rows ?? []).map((row, i) => {
|
|
256
269
|
const trailing = resolveDashboardText(row.trailing, translate, formats);
|
|
257
270
|
return {
|
|
@@ -263,6 +276,12 @@ export function FeedPanelBody({ panel, label, screenParams, translate, }) {
|
|
|
263
276
|
return _jsx(FeedList, { rows: rows });
|
|
264
277
|
} }));
|
|
265
278
|
}
|
|
279
|
+
function labelParamsFrom(labelParams, data) {
|
|
280
|
+
return Object.fromEntries(Object.entries(labelParams).map(([param, field]) => {
|
|
281
|
+
const value = data[field];
|
|
282
|
+
return [param, typeof value === "string" || typeof value === "number" ? String(value) : ""];
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
266
285
|
function isFiniteNumber(value) {
|
|
267
286
|
return typeof value === "number" && Number.isFinite(value);
|
|
268
287
|
}
|
|
@@ -310,7 +329,16 @@ function toProgressListRow(row, index, translate, formats) {
|
|
|
310
329
|
};
|
|
311
330
|
}
|
|
312
331
|
export function ProgressListPanelBody({ panel, label, screenParams, translate, }) {
|
|
313
|
-
return (_jsx(QueryPanel, { panel: panel, label: label,
|
|
332
|
+
return (_jsx(QueryPanel, { panel: panel, label: label, ...(panel.labelParams !== undefined && {
|
|
333
|
+
titleFrom: (data) => panel.labelParams === undefined
|
|
334
|
+
? undefined
|
|
335
|
+
: translate(panel.label, labelParamsFrom(panel.labelParams, data)),
|
|
336
|
+
}), ...(panel.subtitleField !== undefined && {
|
|
337
|
+
subtitle: (data) => {
|
|
338
|
+
const value = panel.subtitleField === undefined ? undefined : data[panel.subtitleField];
|
|
339
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
340
|
+
},
|
|
341
|
+
}), screenParams: screenParams, translate: translate, skeleton: "rows", isEmpty: (data) => (data.rows ?? []).length === 0, children: (data, formats) => {
|
|
314
342
|
const rows = (data.rows ?? []).map((row, i) => toProgressListRow(row, i, translate, formats));
|
|
315
343
|
return _jsx(ProgressList, { rows: rows });
|
|
316
344
|
} }));
|
|
@@ -82,6 +82,8 @@ type QueryPanelProps<TData> = {
|
|
|
82
82
|
readonly query: string;
|
|
83
83
|
};
|
|
84
84
|
readonly label: string;
|
|
85
|
+
/** Title derived from the loaded data; `label` stands in until then. */
|
|
86
|
+
readonly titleFrom?: (data: TData) => string | undefined;
|
|
85
87
|
/** A function derives the line from the loaded data (e.g. "n of m"); `staticSubtitle` stands in until then. */
|
|
86
88
|
readonly subtitle?: string | ((data: TData) => string | undefined);
|
|
87
89
|
readonly staticSubtitle?: string;
|
|
@@ -98,7 +100,7 @@ type QueryPanelProps<TData> = {
|
|
|
98
100
|
* redraws this panel and nothing else. */
|
|
99
101
|
readonly children: (data: TData, formats: DashboardFormats) => ReactNode;
|
|
100
102
|
};
|
|
101
|
-
export declare function QueryPanel<TData>({ panel, label, subtitle, staticSubtitle, action, footer, replaceShell, screenParams, translate, skeleton, isEmpty, children, }: QueryPanelProps<TData>): ReactNode;
|
|
103
|
+
export declare function QueryPanel<TData>({ panel, label, titleFrom, subtitle, staticSubtitle, action, footer, replaceShell, screenParams, translate, skeleton, isEmpty, children, }: QueryPanelProps<TData>): ReactNode;
|
|
102
104
|
export declare function useLoadedAt(screenParams: ScreenParams): {
|
|
103
105
|
readonly loadedAtMs: number;
|
|
104
106
|
readonly reportLoaded: (atMs: number) => void;
|
|
@@ -119,7 +119,7 @@ export function useDashboardFormats() {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
export function PanelShell({ testId, title, subtitle, action, footer, children, }) {
|
|
122
|
-
return (_jsxs("section", { "data-testid": testId, className: "flex h-full flex-col rounded-lg border border-border bg-card text-card-foreground shadow-[var(--card-shadow)]", children: [(title !== undefined || action !== undefined) && (_jsxs("header", { className: "flex shrink-0 flex-wrap items-baseline justify-between gap-x-3 gap-y-2 px-4 pt-3.5", children: [
|
|
122
|
+
return (_jsxs("section", { "data-testid": testId, className: "flex h-full flex-col rounded-lg border border-border bg-card text-card-foreground shadow-[var(--card-shadow)]", children: [(title !== undefined || action !== undefined) && (_jsxs("header", { className: "flex shrink-0 flex-wrap items-baseline justify-between gap-x-3 gap-y-2 px-4 pt-3.5", children: [_jsx("div", { className: "flex min-w-0 flex-col gap-0.5", children: title !== undefined && _jsx("h2", { className: "text-sm font-semibold break-words", children: title }) }), (subtitle !== undefined || action !== undefined) && (_jsxs("div", { className: "ml-auto flex min-w-0 items-baseline gap-3 max-sm:ml-0 max-sm:w-full max-sm:flex-col max-sm:items-start max-sm:gap-2", children: [subtitle !== undefined && (_jsx("p", { "data-slot": "panel-subtitle", className: "text-[12.5px] tabular-nums text-muted-foreground", children: subtitle })), action] }))] })), _jsx("div", { className: cn("grow px-4 pt-3", footer === undefined && "pb-4"), children: children }), footer !== undefined && (_jsx("footer", { className: "mx-4 mb-4 mt-2.5 flex shrink-0 flex-wrap items-center gap-x-1 border-t border-border-row pt-2.5 text-[12.5px] text-muted-foreground", children: footer }))] }));
|
|
123
123
|
}
|
|
124
124
|
export function PanelError({ label, error, onRetry, testId, }) {
|
|
125
125
|
const { Button } = usePrimitives();
|
|
@@ -142,7 +142,7 @@ function resolveSubtitle(subtitle, fallback, data) {
|
|
|
142
142
|
return subtitle;
|
|
143
143
|
return data === undefined ? fallback : subtitle(data);
|
|
144
144
|
}
|
|
145
|
-
export function QueryPanel({ panel, label, subtitle, staticSubtitle, action, footer, replaceShell, screenParams, translate, skeleton, isEmpty, children, }) {
|
|
145
|
+
export function QueryPanel({ panel, label, titleFrom, subtitle, staticSubtitle, action, footer, replaceShell, screenParams, translate, skeleton, isEmpty, children, }) {
|
|
146
146
|
const formats = useDashboardFormats();
|
|
147
147
|
const { data, error, loading, refetch } = useDashboardQuery(panel.query, panelPayload(panel, screenParams));
|
|
148
148
|
useReportPanelLoaded(data, loading);
|
|
@@ -163,7 +163,7 @@ export function QueryPanel({ panel, label, subtitle, staticSubtitle, action, foo
|
|
|
163
163
|
}
|
|
164
164
|
if (shown !== undefined && replaceShell !== undefined)
|
|
165
165
|
return replaceShell(shown);
|
|
166
|
-
return (_jsx(PanelShell, { testId: `dashboard-panel-${panel.id}`, title: label, subtitle: resolveSubtitle(subtitle, staticSubtitle, shown), action: action, footer: shown !== undefined ? footer?.(shown) : undefined, children: body }));
|
|
166
|
+
return (_jsx(PanelShell, { testId: `dashboard-panel-${panel.id}`, title: (shown !== undefined ? titleFrom?.(shown) : undefined) ?? label, subtitle: resolveSubtitle(subtitle, staticSubtitle, shown), action: action, footer: shown !== undefined ? footer?.(shown) : undefined, children: body }));
|
|
167
167
|
}
|
|
168
168
|
// Starts at render time and restarts whenever the merged query params change;
|
|
169
169
|
// panels additionally report each successful (re)load, so live refetches and
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DashboardStatGroupPanel } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
-
import type
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
3
|
import type { Translate } from "../../headless/index.ts";
|
|
4
4
|
import "../react-css-custom-properties.ts";
|
|
5
5
|
import { type ScreenParams } from "./dashboard-shared.tsx";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronRight } from "lucide-react";
|
|
3
|
+
import { Fragment } from "react";
|
|
3
4
|
import { useNav } from "../../app/nav.js";
|
|
4
5
|
import { navigateTargetAllows } from "../../app/screen-access.js";
|
|
5
6
|
import { extensionSectionName, useAppFeatures, useExtensionSectionComponent, usePrimitives, useUserRoles, } from "../../index.js";
|
|
@@ -43,11 +44,24 @@ function statsForViewport(stats, belowSm) {
|
|
|
43
44
|
}
|
|
44
45
|
function StatCells({ panel, screenId, screenParams, translate, variant, }) {
|
|
45
46
|
const belowSm = useIsBelowSmViewport();
|
|
46
|
-
return statsForViewport(panel.stats, belowSm).map((stat) =>
|
|
47
|
+
return statsForViewport(panel.stats, belowSm).map((stat) => {
|
|
48
|
+
const body = (_jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: screenId, screenParams: screenParams, translate: translate, variant: variant }, stat.id));
|
|
49
|
+
return variant === "strip" ? (_jsx("div", { "data-stat-card": "true", className: "min-w-0 rounded-lg border border-border bg-card empty:hidden", children: body }, stat.id)) : (_jsx(Fragment, { children: body }, stat.id));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Phone: the untitled strip is one text line ("2 Interessenten 2 Vorschläge 1 Antwort"), not tiles.
|
|
53
|
+
function PhoneStatLine(props) {
|
|
54
|
+
const { panel, translate } = props;
|
|
55
|
+
const navigateAllowed = useStatNavigateAllowed();
|
|
56
|
+
const stats = statsForViewport(panel.stats, true).filter(navigateAllowed);
|
|
57
|
+
return (_jsx("div", { "data-testid": `dashboard-panel-${panel.id}`, "data-stat-line": "true", className: "flex flex-wrap justify-between gap-x-3 gap-y-1 rounded-lg border border-border bg-card px-3 py-2 text-sm", children: stats.map((stat) => (_jsx("span", { className: "[&_a]:inline", children: _jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: props.screenId, screenParams: props.screenParams, translate: translate, variant: "strip-compact" }) }, stat.id))) }));
|
|
47
58
|
}
|
|
48
59
|
function FlatStatStrip(props) {
|
|
49
60
|
const { panel, translate } = props;
|
|
50
|
-
|
|
61
|
+
const belowSm = useIsBelowSmViewport();
|
|
62
|
+
if (belowSm)
|
|
63
|
+
return _jsx(PhoneStatLine, { ...props });
|
|
64
|
+
return (_jsxs("div", { "data-testid": `dashboard-panel-${panel.id}`, className: "lg:flex lg:items-center lg:gap-3", children: [_jsx("div", { className: "grid grow grid-cols-2 gap-3 lg:auto-cols-fr lg:grid-flow-col", children: _jsx(StatCells, { ...props, variant: "strip" }) }), panel.link !== undefined && (_jsx("div", { className: "flex px-4 max-lg:pt-1 lg:shrink-0", children: _jsx(StatGroupLink, { link: panel.link, translate: translate, stretchOnNarrow: false }) }))] }));
|
|
51
65
|
}
|
|
52
66
|
function PhoneStripIcon({ panel, screenId, screenParams, }) {
|
|
53
67
|
const Icon = useExtensionSectionComponent(panel.icon !== undefined ? extensionSectionName(panel.icon) : undefined);
|
|
@@ -3,6 +3,7 @@ import { navigateTargetAllows } from "../../app/screen-access.js";
|
|
|
3
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
|
+
import { renderBoldMarkup } from "./bold-markup.js";
|
|
6
7
|
import { PanelError, PanelShell, PanelSkeleton, panelPayload, useDashboardFormats, useDashboardQuery, useReportPanelLoaded, } from "./dashboard-shared.js";
|
|
7
8
|
import { isDashboardI18nText, isRecord, resolveDashboardText } from "./dashboard-text.js";
|
|
8
9
|
function isDashboardText(value) {
|
|
@@ -62,7 +63,7 @@ function resolveBlockText(text, translate, formats) {
|
|
|
62
63
|
const PARAGRAPH_CLASS_NAMES = {
|
|
63
64
|
muted: "text-sm text-muted-foreground",
|
|
64
65
|
strong: "text-sm font-medium text-foreground",
|
|
65
|
-
lead: "font-heading text-
|
|
66
|
+
lead: "font-heading text-sm leading-5 sm:text-[17px] sm:leading-relaxed text-foreground",
|
|
66
67
|
};
|
|
67
68
|
function isLeadParagraph(block) {
|
|
68
69
|
return block?.kind === "paragraph" && block.emphasis === "lead";
|
|
@@ -74,7 +75,7 @@ function TextBlockView({ block, translate, followsLead = false, }) {
|
|
|
74
75
|
case "heading":
|
|
75
76
|
return (_jsx("h3", { "data-block": "heading", className: "text-sm font-semibold text-foreground", children: resolve(block.text) }));
|
|
76
77
|
case "paragraph":
|
|
77
|
-
return (_jsx("p", { "data-block": "paragraph", className: PARAGRAPH_CLASS_NAMES[block.emphasis ?? "muted"], children: resolve(block.text) }));
|
|
78
|
+
return (_jsx("p", { "data-block": "paragraph", className: PARAGRAPH_CLASS_NAMES[block.emphasis ?? "muted"], children: renderBoldMarkup(resolve(block.text)) }));
|
|
78
79
|
case "list":
|
|
79
80
|
return (_jsx("ul", { "data-block": "list", className: "list-disc space-y-1 pl-5 text-sm text-muted-foreground", children: withOccurrenceKeys(block.items, textKey).map(({ entry, key }) => (_jsx("li", { children: resolve(entry) }, key))) }));
|
|
80
81
|
case "code":
|
|
@@ -121,14 +122,17 @@ function textBlockKey(block) {
|
|
|
121
122
|
return `${block.kind}:${textKey(block.text)}`;
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
+
function startsWithLead(blocks) {
|
|
126
|
+
return isLeadParagraph(blocks[0]);
|
|
127
|
+
}
|
|
128
|
+
function TextPanelFrame({ panel, label, screenId, screenParams, accented = false, children, }) {
|
|
125
129
|
const testId = `dashboard-panel-${panel.id}`;
|
|
126
130
|
const Icon = useExtensionSectionComponent(panel.icon !== undefined ? extensionSectionName(panel.icon) : undefined);
|
|
127
131
|
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 })] }));
|
|
128
132
|
if (label !== undefined) {
|
|
129
133
|
return (_jsx(PanelShell, { testId: testId, title: label, children: content }));
|
|
130
134
|
}
|
|
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
|
|
135
|
+
return (_jsx("section", { "data-testid": testId, className: cn("h-full rounded-lg border border-border bg-card p-4 text-card-foreground max-sm:px-3 max-sm:py-2.5", accented && "border-l-[3px] border-l-primary"), children: content }));
|
|
132
136
|
}
|
|
133
137
|
function TextBlockList({ blocks, translate, }) {
|
|
134
138
|
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))) }));
|
|
@@ -136,8 +140,9 @@ function TextBlockList({ blocks, translate, }) {
|
|
|
136
140
|
export function TextPanelBody(props) {
|
|
137
141
|
const { panel, label, translate, screenId, screenParams } = props;
|
|
138
142
|
const narrow = useIsBelowSmViewport();
|
|
143
|
+
const staticBlocks = (narrow ? panel.narrowBlocks : undefined) ?? panel.blocks ?? [];
|
|
139
144
|
if (panel.query === undefined) {
|
|
140
|
-
return (_jsx(TextPanelFrame, { panel: panel, label: label, screenId: screenId, screenParams: screenParams, children: _jsx(TextBlockList, { blocks:
|
|
145
|
+
return (_jsx(TextPanelFrame, { panel: panel, label: label, screenId: screenId, screenParams: screenParams, accented: startsWithLead(staticBlocks), children: _jsx(TextBlockList, { blocks: staticBlocks, translate: translate }) }));
|
|
141
146
|
}
|
|
142
147
|
return _jsx(QueryTextPanelBody, { ...props, query: panel.query });
|
|
143
148
|
}
|
|
@@ -165,5 +170,5 @@ function QueryTextPanelBody({ panel, query, label, screenId, screenParams, trans
|
|
|
165
170
|
else {
|
|
166
171
|
body = null;
|
|
167
172
|
}
|
|
168
|
-
return (_jsx(TextPanelFrame, { panel: panel, label: label, screenId: screenId, screenParams: screenParams, children: body }));
|
|
173
|
+
return (_jsx(TextPanelFrame, { panel: panel, label: label, screenId: screenId, screenParams: screenParams, accented: startsWithLead(blocks), children: body }));
|
|
169
174
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
2
|
import { formatRelativeTime } from "../../headless/format/relative-time.js";
|
|
3
|
+
import { useTranslation } from "../../i18n.js";
|
|
3
4
|
import { serverNowMs } from "../../server-clock.js";
|
|
4
5
|
const SECONDS_PER_MINUTE = 60;
|
|
6
|
+
// One look for relative times everywhere: short units, yesterday with clock, absolute after a week.
|
|
7
|
+
const LIST_RELATIVE_OPTIONS = {
|
|
8
|
+
style: "short",
|
|
9
|
+
withTime: true,
|
|
10
|
+
absoluteAfterDays: 7,
|
|
11
|
+
};
|
|
5
12
|
const SECOND_TICK_MS = 1000;
|
|
6
13
|
// Above a minute the text changes at most once per minute; half a minute keeps it
|
|
7
14
|
// at most 30 s late without waking the page every second for a "5 minutes ago".
|
|
@@ -14,6 +21,8 @@ export function relativeTickIntervalMs(distanceMs) {
|
|
|
14
21
|
/** Returns a formatter for relative times that redraws its component on a timer, but
|
|
15
22
|
* only while a render actually called it: no relative output on screen, no timer. */
|
|
16
23
|
export function useRelativeTimeFormatter(locale) {
|
|
24
|
+
const t = useTranslation();
|
|
25
|
+
const justNow = t("kumiko.time.justNow");
|
|
17
26
|
const [, setTick] = useState(0);
|
|
18
27
|
const [intervalMs, setIntervalMs] = useState(null);
|
|
19
28
|
const nearestDistanceMs = useRef(Number.POSITIVE_INFINITY);
|
|
@@ -33,6 +42,6 @@ export function useRelativeTimeFormatter(locale) {
|
|
|
33
42
|
return (atMs) => {
|
|
34
43
|
const nowMs = serverNowMs();
|
|
35
44
|
nearestDistanceMs.current = Math.min(nearestDistanceMs.current, Math.abs(atMs - nowMs));
|
|
36
|
-
return formatRelativeTime(atMs, nowMs, locale);
|
|
45
|
+
return formatRelativeTime(atMs, nowMs, locale, { ...LIST_RELATIVE_OPTIONS, justNow });
|
|
37
46
|
};
|
|
38
47
|
}
|
|
@@ -8,6 +8,7 @@ type ConfigCascadeViewProps = {
|
|
|
8
8
|
readonly qualifiedKey?: string;
|
|
9
9
|
readonly required?: boolean;
|
|
10
10
|
readonly renderValue?: CascadeValueRenderer;
|
|
11
|
+
readonly compact?: boolean;
|
|
11
12
|
};
|
|
12
|
-
export declare function ConfigCascadeView({ cascade, screenScope, onReset, qualifiedKey, required, renderValue, }: ConfigCascadeViewProps): ReactNode;
|
|
13
|
+
export declare function ConfigCascadeView({ cascade, screenScope, onReset, qualifiedKey, required, renderValue, compact, }: ConfigCascadeViewProps): ReactNode;
|
|
13
14
|
export {};
|
|
@@ -3,6 +3,7 @@ import { useId, useState } from "react";
|
|
|
3
3
|
import { usePrimitives, useTranslation } from "../../index.js";
|
|
4
4
|
import { Icon } from "../icons.js";
|
|
5
5
|
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip.js";
|
|
6
7
|
const SOURCE_I18N_KEY = {
|
|
7
8
|
"user-row": "kumiko.config.source.user",
|
|
8
9
|
"tenant-row": "kumiko.config.source.tenant",
|
|
@@ -91,7 +92,7 @@ const OWN_LEVEL_ORIGIN_NO_DEFAULT_KEY = {
|
|
|
91
92
|
user: "kumiko.config.cascade.originNoDefault.user",
|
|
92
93
|
system: "kumiko.config.cascade.originNoDefault.system",
|
|
93
94
|
};
|
|
94
|
-
export function ConfigCascadeView({ cascade, screenScope, onReset, qualifiedKey, required = false, renderValue, }) {
|
|
95
|
+
export function ConfigCascadeView({ cascade, screenScope, onReset, qualifiedKey, required = false, renderValue, compact = false, }) {
|
|
95
96
|
const t = useTranslation();
|
|
96
97
|
const { Button } = usePrimitives();
|
|
97
98
|
const [expanded, setExpanded] = useState(false);
|
|
@@ -143,9 +144,20 @@ export function ConfigCascadeView({ cascade, screenScope, onReset, qualifiedKey,
|
|
|
143
144
|
: t("kumiko.config.cascade.origin.default"),
|
|
144
145
|
className: "text-muted-foreground",
|
|
145
146
|
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
const resetButton = hasOverride && onReset !== undefined && qualifiedKey !== undefined ? (_jsx(Button, { variant: "ghost", size: "sm", onClick: () => onReset(qualifiedKey, screenScope), testId: "config-cascade-reset", className: "h-auto px-1.5 py-0.5 text-xs text-muted-foreground hover:bg-transparent hover:text-foreground", children: t(screenScope === "system"
|
|
148
|
+
? "kumiko.config.cascade.resetToApp"
|
|
149
|
+
: "kumiko.config.cascade.resetTo") })) : null;
|
|
150
|
+
const showsLevels = expandable && (cascade.levels.length > 2 || screenScope === "system");
|
|
151
|
+
const levelsPanel = expanded && showsLevels ? (_jsx("ul", { id: panelId, className: "flex flex-col gap-0.5 border-l border-border pl-3", children: displayLevels.map((display) => (_jsx(CascadeLevelRow, { display: display, ...(renderValue !== undefined && { renderValue }) }, display.level.source))) })) : null;
|
|
152
|
+
if (compact) {
|
|
153
|
+
return (_jsxs("div", { className: "flex flex-col gap-1 text-xs", "data-testid": "config-cascade", children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(TooltipProvider, { children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("button", { type: "button", "data-testid": "config-cascade-origin", onClick: showsLevels ? () => setExpanded((v) => !v) : undefined, ...(showsLevels && {
|
|
154
|
+
"aria-expanded": expanded,
|
|
155
|
+
...(expanded && { "aria-controls": panelId }),
|
|
156
|
+
}), className: cn("inline-flex size-5 items-center justify-center rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring", showsLevels ? "cursor-pointer" : "cursor-help", origin.className), children: [_jsx(Icon, { name: "info", className: "size-3.5" }), showsLevels && (_jsx("span", { className: "sr-only", children: t(expanded
|
|
157
|
+
? "kumiko.config.cascade.hideLevels"
|
|
158
|
+
: "kumiko.config.cascade.showLevels") }))] }) }), _jsx(TooltipContent, { children: origin.text })] }) }), _jsx("span", { className: "sr-only", children: origin.text }), resetButton] }), levelsPanel] }));
|
|
159
|
+
}
|
|
160
|
+
return (_jsxs("div", { className: "flex flex-col gap-1 text-xs", "data-testid": "config-cascade", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-1 gap-y-1", children: [_jsx("span", { className: cn("inline-flex items-center gap-1.5", origin.className), children: origin.text }), resetButton] }), showsLevels ? (_jsxs("button", { type: "button", onClick: () => setExpanded((v) => !v), "aria-expanded": expanded, ...(expanded && { "aria-controls": panelId }), className: "inline-flex cursor-pointer items-center gap-1 self-start rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring", children: [_jsx(Icon, { name: "chevron-right", className: cn("size-3.5 transition-transform motion-reduce:transition-none", expanded && "rotate-90") }), t(expanded ? "kumiko.config.cascade.hideLevels" : "kumiko.config.cascade.showLevels")] })) : null, levelsPanel] }));
|
|
149
161
|
}
|
|
150
162
|
function CascadeLevelRow({ display, renderValue, }) {
|
|
151
163
|
const t = useTranslation();
|
package/dist/web/drawn-icons.js
CHANGED
|
@@ -13,7 +13,8 @@ export const DrawnPencil = createLucideIcon("drawn-pencil", [
|
|
|
13
13
|
["path", { d: "m13 7 4 4", key: "tip" }],
|
|
14
14
|
]);
|
|
15
15
|
export const DrawnFilter = createLucideIcon("drawn-filter", [
|
|
16
|
-
["path", { d: "
|
|
16
|
+
["path", { d: "M21 4h-7M10 4H3M21 12h-9M8 12H3M21 20h-5M12 20H3", key: "lines" }],
|
|
17
|
+
["path", { d: "M14 2v4M8 10v4M16 18v4", key: "knobs" }],
|
|
17
18
|
]);
|
|
18
19
|
export const DrawnWand = createLucideIcon("drawn-wand", [
|
|
19
20
|
[
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
/** Marks an app header action (e.g. the assistant trigger) that stays in the bar on a phone, next to the
|
|
3
|
-
* bell; the rest of `headerActions` folds into the "…" menu. Inside the menu it renders nothing.
|
|
4
|
-
|
|
3
|
+
* bell; the rest of `headerActions` folds into the "…" menu. Inside the menu it renders nothing.
|
|
4
|
+
* `hideOnListScreens` drops it on phone entityList/projectionList screens, whose rows carry their own AI action. */
|
|
5
|
+
export declare function HeaderActionPinned({ children, hideOnListScreens, }: {
|
|
5
6
|
readonly children: ReactNode;
|
|
7
|
+
readonly hideOnListScreens?: boolean;
|
|
6
8
|
}): ReactNode;
|
|
7
9
|
export declare function collectPinnedHeaderActions(node: ReactNode): readonly ReactNode[];
|
|
8
10
|
export declare function isOnlyPinnedHeaderActions(node: ReactNode): boolean;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { Children, Fragment, isValidElement, useContext } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { usePageHeaderCompact } from "../../index.js";
|
|
3
|
+
import { HeaderOverflowMenuContext, HeaderScreenTypeContext } from "./header-overflow-menu.js";
|
|
4
|
+
const LIST_SCREEN_TYPES = new Set([
|
|
5
|
+
"entityList",
|
|
6
|
+
"projectionList",
|
|
7
|
+
]);
|
|
3
8
|
/** Marks an app header action (e.g. the assistant trigger) that stays in the bar on a phone, next to the
|
|
4
|
-
* bell; the rest of `headerActions` folds into the "…" menu. Inside the menu it renders nothing.
|
|
5
|
-
|
|
9
|
+
* bell; the rest of `headerActions` folds into the "…" menu. Inside the menu it renders nothing.
|
|
10
|
+
* `hideOnListScreens` drops it on phone entityList/projectionList screens, whose rows carry their own AI action. */
|
|
11
|
+
export function HeaderActionPinned({ children, hideOnListScreens = false, }) {
|
|
6
12
|
const inMenu = useContext(HeaderOverflowMenuContext);
|
|
7
|
-
|
|
13
|
+
const screenType = useContext(HeaderScreenTypeContext);
|
|
14
|
+
const compact = usePageHeaderCompact();
|
|
15
|
+
const onListScreen = screenType !== undefined && LIST_SCREEN_TYPES.has(screenType);
|
|
16
|
+
return inMenu || (hideOnListScreens && compact && onListScreen) ? null : children;
|
|
8
17
|
}
|
|
9
18
|
function isPinnedElement(node) {
|
|
10
19
|
return isValidElement(node) && node.type === HeaderActionPinned;
|
|
@@ -2,3 +2,5 @@
|
|
|
2
2
|
* like ThemeToggle can draw a labelled menu row instead of an icon button. */
|
|
3
3
|
export declare const HeaderOverflowMenuContext: import("react").Context<boolean>;
|
|
4
4
|
export declare const headerOverflowMenuItemClass: string;
|
|
5
|
+
/** The type of the screen the shell header currently sits above; read by HeaderActionPinned. */
|
|
6
|
+
export declare const HeaderScreenTypeContext: import("react").Context<"actionForm" | "configEdit" | "custom" | "dashboard" | "entityEdit" | "entityList" | "projectionDetail" | "projectionList" | "secretMint" | "secretsEdit" | undefined>;
|
|
@@ -6,3 +6,5 @@ export const HeaderOverflowMenuContext = createContext(false);
|
|
|
6
6
|
export const headerOverflowMenuItemClass = "relative flex min-h-10 w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm " +
|
|
7
7
|
"outline-none transition-colors hover:bg-accent focus:bg-accent focus:text-accent-foreground " +
|
|
8
8
|
"disabled:pointer-events-none disabled:opacity-50";
|
|
9
|
+
/** The type of the screen the shell header currently sits above; read by HeaderActionPinned. */
|
|
10
|
+
export const HeaderScreenTypeContext = createContext(undefined);
|
|
@@ -440,7 +440,7 @@ function NavSection({ node, collapsed, onToggle }) {
|
|
|
440
440
|
!node.children.some((c) => c.provider === true || subtreeMatches(c, matches))) {
|
|
441
441
|
return null;
|
|
442
442
|
}
|
|
443
|
-
return (_jsxs(SidebarGroup, { children: [_jsxs(SidebarGroupLabel, { className: plain ? PLAIN_GROUP_LABEL_CLASS : undefined, children: [displayLabel, plain && create !== undefined && (_jsx(TreeActionControl, { action: create, ariaLabel: navLabel(t, create.label), className: `${PLUS_BUTTON_CLASS} hover:bg-sidebar-foreground/10 hover:text-sidebar-foreground`, dispatch: dispatch, workspaceId: nav.route?.workspaceId, children: _jsx(Plus, { className: "size-3.5" }) }))] }), _jsx(SidebarGroupContent, { children: _jsx(SidebarMenu, { children: node.children.map((child) => (_jsx(NavMenuNode, { node: child, collapsed: collapsed, onToggle: onToggle }, child.qualifiedName))) }) })] }));
|
|
443
|
+
return (_jsxs(SidebarGroup, { children: [_jsxs(SidebarGroupLabel, { className: plain ? PLAIN_GROUP_LABEL_CLASS : undefined, children: [displayLabel, plain && create !== undefined && (_jsx(TreeActionControl, { action: create, ariaLabel: navLabel(t, create.label), className: `${PLUS_BUTTON_CLASS} hover:bg-sidebar-foreground/10 hover:text-sidebar-foreground group-data-[collapsible=icon]:hidden`, dispatch: dispatch, workspaceId: nav.route?.workspaceId, children: _jsx(Plus, { className: "size-3.5" }) }))] }), _jsx(SidebarGroupContent, { children: _jsx(SidebarMenu, { children: node.children.map((child) => (_jsx(NavMenuNode, { node: child, collapsed: collapsed, onToggle: onToggle }, child.qualifiedName))) }) })] }));
|
|
444
444
|
}
|
|
445
445
|
// A menu entry (top-level item or section child) supports three click modes:
|
|
446
446
|
// `screen` is a route link (KumikoLink), `target` dispatches to EditorPanel
|
|
@@ -13,6 +13,13 @@ const triggerClass = "relative inline-flex size-8 shrink-0 items-center justify-
|
|
|
13
13
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
|
|
14
14
|
const panelClass = "z-50 flex max-h-[28rem] w-[min(22rem,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-md border " +
|
|
15
15
|
"bg-popover text-popover-foreground shadow-md";
|
|
16
|
+
function NotificationRowItem({ row, createdLabel, onOpen, }) {
|
|
17
|
+
const t = useTranslation();
|
|
18
|
+
return (_jsx("li", { children: _jsxs("button", { type: "button", "data-unread": row.isRead ? undefined : "true", className: "flex w-full items-start gap-2 border-b border-border px-3 py-2 text-left hover:bg-accent focus-visible:bg-accent focus-visible:outline-none", onClick: onOpen, children: [_jsx("span", { "aria-hidden": "true", className: cn("mt-1.5 size-2 shrink-0 rounded-full", row.isRead ? "bg-transparent" : "bg-primary") }), !row.isRead && _jsx("span", { className: "sr-only", children: t("kumiko.notifications.unread") }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: cn("block truncate text-sm", !row.isRead && "font-semibold"), children: row.title }), row.body !== null && (_jsx("span", { className: "block truncate text-xs text-muted-foreground", children: row.body })), _jsx("span", { className: "block text-xs text-muted-foreground", children: createdLabel })] })] }) }));
|
|
19
|
+
}
|
|
20
|
+
function unreadBadgeText(unreadCount) {
|
|
21
|
+
return unreadCount > MAX_BADGE_COUNT ? `${MAX_BADGE_COUNT}+` : String(unreadCount);
|
|
22
|
+
}
|
|
16
23
|
export function NotificationBell({ screens, menuEntry, }) {
|
|
17
24
|
const t = useTranslation();
|
|
18
25
|
const nav = useNav();
|
|
@@ -20,7 +27,7 @@ export function NotificationBell({ screens, menuEntry, }) {
|
|
|
20
27
|
const formatRelative = useRelativeTimeFormatter(locale);
|
|
21
28
|
const [open, setOpen] = useState(false);
|
|
22
29
|
const inbox = useInAppInbox(open);
|
|
23
|
-
const badge =
|
|
30
|
+
const badge = unreadBadgeText(inbox.unreadCount);
|
|
24
31
|
const label = inbox.unreadCount > 0
|
|
25
32
|
? t("kumiko.notifications.labelUnread", { count: badge })
|
|
26
33
|
: t("kumiko.notifications.label");
|
|
@@ -42,9 +49,11 @@ export function NotificationBell({ screens, menuEntry, }) {
|
|
|
42
49
|
event.preventDefault();
|
|
43
50
|
menuEntry.anchorRef.current?.focus();
|
|
44
51
|
},
|
|
45
|
-
}), children: [_jsxs("div", { className: "flex items-center justify-between gap-2 border-b border-border px-3 py-2", children: [_jsx("h2", { className: "text-sm font-semibold", children: t("kumiko.notifications.title") }), inbox.unreadCount > 0 && (_jsx("button", { type: "button", className: "text-xs text-primary hover:underline", onClick: () => void inbox.markAllRead(), children: t("kumiko.notifications.markAllRead") }))] }), _jsxs("div", { className: "min-h-0 flex-1 overflow-y-auto", children: [inbox.failed && (_jsx("p", { role: "alert", className: "px-3 py-4 text-sm text-destructive", children: t("kumiko.notifications.loadFailed") })), !inbox.failed && !inbox.loading && inbox.rows.length === 0 && (_jsx("p", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: t("kumiko.notifications.empty") })), _jsx("ul", { children: inbox.rows.map((row) => (_jsx(
|
|
46
|
-
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [menuEntry === undefined ? (
|
|
52
|
+
}), children: [_jsxs("div", { className: "flex items-center justify-between gap-2 border-b border-border px-3 py-2", children: [_jsx("h2", { className: "text-sm font-semibold", children: t("kumiko.notifications.title") }), inbox.unreadCount > 0 && (_jsx("button", { type: "button", className: "text-xs text-primary hover:underline", onClick: () => void inbox.markAllRead(), children: t("kumiko.notifications.markAllRead") }))] }), _jsxs("div", { className: "min-h-0 flex-1 overflow-y-auto", children: [inbox.failed && (_jsx("p", { role: "alert", className: "px-3 py-4 text-sm text-destructive", children: t("kumiko.notifications.loadFailed") })), !inbox.failed && !inbox.loading && inbox.rows.length === 0 && (_jsx("p", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: t("kumiko.notifications.empty") })), _jsx("ul", { children: inbox.rows.map((row) => (_jsx(NotificationRowItem, { row: row, createdLabel: formatRelative(Date.parse(row.createdAt)), onOpen: () => void openRow(row) }, row.id))) }), inbox.hasMore && (_jsx("button", { type: "button", className: "w-full px-3 py-2 text-sm text-primary hover:bg-accent", onClick: () => void inbox.loadMore(), children: t("kumiko.notifications.loadMore") }))] })] }) }));
|
|
53
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [menuEntry === undefined ? (
|
|
54
|
+
// Stays mounted while the list is open, else "mark all read" would pull the anchor away.
|
|
55
|
+
inbox.unreadCount > 0 || open ? (_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs("button", { type: "button", "aria-label": label, "data-kumiko-layout": "notification-bell", className: triggerClass, children: [_jsx(Bell, { className: "size-4", "aria-hidden": "true" }), inbox.unreadCount > 0 && (_jsx("span", { "data-kumiko-layout": "notification-bell-badge", className: "absolute right-[3px] top-[3px] rounded-full bg-destructive px-1 py-0.5 text-[9.5px] font-semibold leading-none text-destructive-foreground", children: badge }))] }) })) : null) : (_jsxs(_Fragment, { children: [_jsx(PopoverPrimitive.Anchor, { virtualRef: menuEntry.anchorRef }), _jsxs("button", { type: "button", role: "menuitem", "aria-label": label, "data-testid": "notification-bell-menu-item", className: headerOverflowMenuItemClass, onClick: () => {
|
|
47
56
|
setOpen(true);
|
|
48
57
|
menuEntry.onSelect();
|
|
49
|
-
}, children: [_jsx(Bell, { className: "size-4", "aria-hidden": "true" }), _jsx("span", { className: "flex-1", children: t("kumiko.notifications.label") }), inbox.unreadCount > 0 && (_jsx("span", { "data-kumiko-layout": "notification-bell-badge", className: "rounded-full bg-destructive px-1.5 py-0.5 text-[9.5px] font-semibold leading-none text-destructive-foreground", children: badge }))] })] })), panel] }));
|
|
58
|
+
}, children: [_jsx(Bell, { className: "size-4", "aria-hidden": "true" }), _jsx("span", { className: "flex-1", children: t("kumiko.notifications.label") }), inbox.unreadCount > 0 && (_jsx("span", { "data-kumiko-layout": "notification-bell-badge", "aria-hidden": "true", className: "rounded-full bg-destructive px-1.5 py-0.5 text-[9.5px] font-semibold leading-none text-destructive-foreground", children: badge }))] })] })), panel] }));
|
|
50
59
|
}
|
|
@@ -10,6 +10,8 @@ export type PageHeaderSlot = {
|
|
|
10
10
|
readonly setTitle: (title: string | undefined) => void;
|
|
11
11
|
readonly recordTitle: string | undefined;
|
|
12
12
|
readonly setRecordTitle: (recordTitle: string | undefined) => void;
|
|
13
|
+
readonly narrowRecordTitle: string | undefined;
|
|
14
|
+
readonly setNarrowRecordTitle: (title: string | undefined) => void;
|
|
13
15
|
readonly bodyTitle: boolean;
|
|
14
16
|
readonly setBodyTitle: (bodyTitle: boolean) => void;
|
|
15
17
|
readonly breadcrumbHidden: boolean;
|
|
@@ -18,6 +18,7 @@ export function PageHeaderSlotProvider({ children }) {
|
|
|
18
18
|
const [actionsElement, setActionsElement] = useState(null);
|
|
19
19
|
const [title, setTitle] = useState(undefined);
|
|
20
20
|
const [recordTitle, setRecordTitle] = useState(undefined);
|
|
21
|
+
const [narrowRecordTitle, setNarrowRecordTitle] = useState(undefined);
|
|
21
22
|
const [bodyTitle, setBodyTitle] = useState(false);
|
|
22
23
|
const [breadcrumbHidden, setBreadcrumbHidden] = useState(false);
|
|
23
24
|
const [breadcrumbScreenId, setBreadcrumbScreenId] = useState(undefined);
|
|
@@ -32,6 +33,8 @@ export function PageHeaderSlotProvider({ children }) {
|
|
|
32
33
|
setTitle,
|
|
33
34
|
recordTitle,
|
|
34
35
|
setRecordTitle,
|
|
36
|
+
narrowRecordTitle,
|
|
37
|
+
setNarrowRecordTitle,
|
|
35
38
|
bodyTitle,
|
|
36
39
|
setBodyTitle,
|
|
37
40
|
breadcrumbHidden,
|
|
@@ -45,6 +48,7 @@ export function PageHeaderSlotProvider({ children }) {
|
|
|
45
48
|
actionsElement,
|
|
46
49
|
title,
|
|
47
50
|
recordTitle,
|
|
51
|
+
narrowRecordTitle,
|
|
48
52
|
bodyTitle,
|
|
49
53
|
breadcrumbHidden,
|
|
50
54
|
breadcrumbScreenId,
|
|
@@ -25,7 +25,10 @@ function FocusedScreenFrame({ screen, screens, children, }) {
|
|
|
25
25
|
const hasActions = topbarActions !== undefined || overflowItems.length > 0;
|
|
26
26
|
return (_jsxs(_Fragment, { children: [focused && (_jsx(MobileTopBar, { label: parentScreenId !== undefined
|
|
27
27
|
? t(screenTitleKey(parentScreenId))
|
|
28
|
-
: (slot?.
|
|
28
|
+
: (slot?.narrowRecordTitle ??
|
|
29
|
+
slot?.recordTitle ??
|
|
30
|
+
slot?.title ??
|
|
31
|
+
t(screenTitleKey(shortId))), back: {
|
|
29
32
|
label: t("kumiko.actions.back"),
|
|
30
33
|
onClick: () => parentScreenId !== undefined
|
|
31
34
|
? nav.navigate({ screenId: parentScreenId })
|
|
@@ -3,13 +3,13 @@ import { IN_APP_NOTIFICATION_FEATURE } from "@cosmicdrift/kumiko-types/in-app-no
|
|
|
3
3
|
import { ChevronLeft, MoreHorizontal } from "lucide-react";
|
|
4
4
|
import { Fragment, useEffect, useId, useMemo, useRef, useState, } from "react";
|
|
5
5
|
import { resolveNavigation } from "../../headless/index.js";
|
|
6
|
-
import { toAppSchema, useNav, usePageHeaderCompact, useTranslation, } from "../../index.js";
|
|
6
|
+
import { lastSegment, toAppSchema, useNav, usePageHeaderCompact, useTranslation, } from "../../index.js";
|
|
7
7
|
import { Icon, NAV_ICONS } from "../icons.js";
|
|
8
8
|
import { cn } from "../lib/cn.js";
|
|
9
9
|
import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "../ui/breadcrumb.js";
|
|
10
10
|
import { SidebarTrigger } from "../ui/sidebar.js";
|
|
11
11
|
import { collectPinnedHeaderActions, isOnlyPinnedHeaderActions } from "./header-action-pinned.js";
|
|
12
|
-
import { HeaderOverflowMenuContext, headerOverflowMenuItemClass } from "./header-overflow-menu.js";
|
|
12
|
+
import { HeaderOverflowMenuContext, HeaderScreenTypeContext, headerOverflowMenuItemClass, } from "./header-overflow-menu.js";
|
|
13
13
|
import { buildNavRegistrySliceForApp } from "./nav-tree.js";
|
|
14
14
|
import { NotificationBell } from "./notification-bell.js";
|
|
15
15
|
import { usePageHeaderSlot } from "./page-header-slot.js";
|
|
@@ -43,6 +43,9 @@ export function ShellHeader({ schema, user, headerActions: appHeaderActions, all
|
|
|
43
43
|
const slot = usePageHeaderSlot();
|
|
44
44
|
const standInScreenId = slot?.breadcrumbScreenId;
|
|
45
45
|
const screenId = standInScreenId ?? nav.route?.screenId;
|
|
46
|
+
// The qualified id wins: two features can share a short screen id.
|
|
47
|
+
const screenType = (allScreens.find((s) => s.id === screenId) ??
|
|
48
|
+
allScreens.find((s) => lastSegment(s.id) === screenId))?.type;
|
|
46
49
|
const entityId = standInScreenId !== undefined ? undefined : nav.route?.entityId;
|
|
47
50
|
const crumbs = useMemo(() => {
|
|
48
51
|
if (screenId === undefined)
|
|
@@ -85,8 +88,13 @@ export function ShellHeader({ schema, user, headerActions: appHeaderActions, all
|
|
|
85
88
|
// A screen that draws its own breadcrumb hides the bar's crumbs, but its parent link stays.
|
|
86
89
|
const titleCrumbs = standInUntitled ? undefined : crumbs;
|
|
87
90
|
const parentCrumb = titleCrumbs !== undefined && titleCrumbs.length > 1 ? titleCrumbs.at(-2) : undefined;
|
|
88
|
-
|
|
91
|
+
// A record's short title replaces the "‹ parent" link on the phone; going back is the gesture or menu.
|
|
92
|
+
const phoneRecordTitle = slot?.narrowRecordTitle ?? recordTitle;
|
|
93
|
+
const phoneShowsRecordTitle = bodyTitle && compact && phoneRecordTitle !== undefined;
|
|
94
|
+
const parentOnly = bodyTitle && compact && parentCrumb !== undefined && !phoneShowsRecordTitle;
|
|
89
95
|
const bodyTitleCrumbs = () => {
|
|
96
|
+
if (phoneShowsRecordTitle)
|
|
97
|
+
return [{ label: phoneRecordTitle }];
|
|
90
98
|
if (compact)
|
|
91
99
|
return parentCrumb === undefined ? [] : [parentCrumb];
|
|
92
100
|
const ownTitle = recordTitle ?? titleCrumbs?.at(-1)?.label;
|
|
@@ -96,7 +104,7 @@ export function ShellHeader({ schema, user, headerActions: appHeaderActions, all
|
|
|
96
104
|
];
|
|
97
105
|
};
|
|
98
106
|
const shownCrumbs = bodyTitle ? bodyTitleCrumbs() : visibleCrumbs;
|
|
99
|
-
return (_jsxs("header", { "data-kumiko-layout": "shell-header", ...(plainNav && { "data-nav-style": "plain" }), className: cn("flex h-14 shrink-0 items-center gap-3 border-b border-border pl-1.5 pr-3 md:pl-4 md:pr-6", plainNav && "h-[58px] md:gap-2.5 md:px-5", (compact || bellInOverflow) && "relative", focused && "max-md:hidden"), children: [_jsxs("div", { className: "@container flex min-w-0 flex-1 items-center gap-3", children: [_jsx(ShellSidebarTrigger, { focused: focused, plainNav: plainNav }), _jsxs("div", { className: cn("flex min-w-0", compact ? "flex-col justify-center" : "items-center gap-3"), children: [_jsx(ShellBreadcrumb, { crumbs: shownCrumbs, parentOnly: parentOnly, bodyTitle: bodyTitle, titleOverride: titleOverride }), _jsx("div", { ref: setStatusElement, "data-kumiko-layout": "page-header-status", className: cn("flex items-center gap-2 empty:hidden", compact ? "min-w-0 max-w-full overflow-hidden whitespace-nowrap text-xs" : "shrink-0") })] })] }), _jsx(ShellHeaderEnd, { compact: compact, actionsRef: setActionsElement, headerActions: headerActions, overflowItems: slot?.overflowItems ?? [], bellScreens: showsBell ? allScreens : undefined, bellInOverflow: bellInOverflow })] }));
|
|
107
|
+
return (_jsxs("header", { "data-kumiko-layout": "shell-header", ...(plainNav && { "data-nav-style": "plain" }), className: cn("flex h-14 shrink-0 items-center gap-3 border-b border-border pl-1.5 pr-3 md:pl-4 md:pr-6", plainNav && "h-[58px] md:gap-2.5 md:px-5", (compact || bellInOverflow) && "relative", focused && "max-md:hidden"), children: [_jsxs("div", { className: "@container flex min-w-0 flex-1 items-center gap-3", children: [_jsx(ShellSidebarTrigger, { focused: focused, plainNav: plainNav }), _jsxs("div", { className: cn("flex min-w-0", compact ? "flex-col justify-center" : "items-center gap-3"), children: [_jsx(ShellBreadcrumb, { crumbs: shownCrumbs, parentOnly: parentOnly, bodyTitle: bodyTitle, titleOverride: titleOverride }), _jsx("div", { ref: setStatusElement, "data-kumiko-layout": "page-header-status", className: cn("flex items-center gap-2 empty:hidden", compact ? "min-w-0 max-w-full overflow-hidden whitespace-nowrap text-xs" : "shrink-0") })] })] }), _jsx(HeaderScreenTypeContext.Provider, { value: screenType, children: _jsx(ShellHeaderEnd, { compact: compact, actionsRef: setActionsElement, headerActions: headerActions, overflowItems: slot?.overflowItems ?? [], bellScreens: showsBell ? allScreens : undefined, bellInOverflow: bellInOverflow }) })] }));
|
|
100
108
|
}
|
|
101
109
|
function foldsIntoOverflow(overflowItems, headerActions) {
|
|
102
110
|
if (overflowItems.length > 0)
|
|
@@ -117,7 +125,7 @@ function VisibleHeaderActions({ compact, headerActions, }) {
|
|
|
117
125
|
}
|
|
118
126
|
function ShellHeaderEnd({ compact, actionsRef, headerActions, overflowItems, bellScreens, bellInOverflow, }) {
|
|
119
127
|
const hasOverflow = bellInOverflow || (compact && foldsIntoOverflow(overflowItems, headerActions));
|
|
120
|
-
return (_jsxs("div", { className: cn("ml-auto flex items-center gap-2", compact ? "min-w-0 max-w-[60%]" : "min-w-0 max-w-[50%] shrink-0 sm:max-w-none"), children: [_jsx("div", { ref: actionsRef, "data-kumiko-layout": "page-header-actions", className: cn(SHELL_HEADER_CONTROLS_CLASSES, "flex min-w-0 items-center gap-2 empty:hidden [&_*]:min-w-0 [&_*]:max-w-full [&_button]:overflow-hidden [&_button]:whitespace-nowrap", compact && "overflow-hidden") }), bellScreens !== undefined && !bellInOverflow && _jsx(NotificationBell, { screens: bellScreens }), _jsx(VisibleHeaderActions, { compact: compact, headerActions: headerActions }), hasOverflow && (_jsx(HeaderOverflow, { items: compact ? overflowItems : [], headerActions: compact ? headerActions : undefined, ...(bellInOverflow && bellScreens !== undefined && { bellScreens }) }))] }));
|
|
128
|
+
return (_jsxs("div", { className: cn("ml-auto flex items-center gap-2", compact ? "min-w-0 max-w-[60%]" : "min-w-0 max-w-[50%] shrink-0 sm:max-w-none"), children: [!compact && _jsx(VisibleHeaderActions, { compact: compact, headerActions: headerActions }), _jsx("div", { ref: actionsRef, "data-kumiko-layout": "page-header-actions", className: cn(SHELL_HEADER_CONTROLS_CLASSES, "flex min-w-0 items-center gap-2 empty:hidden [&_*]:min-w-0 [&_*]:max-w-full [&_button]:overflow-hidden [&_button]:whitespace-nowrap", compact && "overflow-hidden") }), bellScreens !== undefined && !bellInOverflow && _jsx(NotificationBell, { screens: bellScreens }), compact && _jsx(VisibleHeaderActions, { compact: compact, headerActions: headerActions }), hasOverflow && (_jsx(HeaderOverflow, { items: compact ? overflowItems : [], headerActions: compact ? headerActions : undefined, ...(bellInOverflow && bellScreens !== undefined && { bellScreens }) }))] }));
|
|
121
129
|
}
|
|
122
130
|
function ShellSidebarTrigger({ focused, plainNav, }) {
|
|
123
131
|
const t = useTranslation();
|
|
@@ -196,10 +204,10 @@ function HeaderOverflow({ items, headerActions, bellScreens, }) {
|
|
|
196
204
|
event.preventDefault();
|
|
197
205
|
menuItems[next]?.focus();
|
|
198
206
|
};
|
|
199
|
-
return (_jsxs(_Fragment, { children: [_jsx("button", { ref: triggerRef, type: "button", "aria-label": t("kumiko.page-header.actions"), "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": panelId, "data-testid": "shell-header-overflow-trigger", onClick: () => setOpen((wasOpen) => !wasOpen), className: "inline-flex size-10 shrink-0 items-center justify-center rounded-md border border-input bg-background text-foreground shadow-xs hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", children: _jsx(MoreHorizontal, { className: "size-4", "aria-hidden": "true" }) }), _jsxs("div", { ref: panelRef, id: panelId, role: "menu", "aria-label": t("kumiko.page-header.actions"), hidden: !open, onKeyDown: onPanelKeyDown, "data-testid": "shell-header-overflow", className: "absolute right-2 top-full z-30 mt-1 w-max min-w-[8rem] max-w-[calc(100vw-1rem)] rounded-md border bg-popover p-1 text-popover-foreground shadow-md", children: [bellScreens !== undefined && (_jsx(OverflowBellEntry, { screens: bellScreens, anchorRef: triggerRef, onSelect: () => setOpen(false), separated: items
|
|
207
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { ref: triggerRef, type: "button", "aria-label": t("kumiko.page-header.actions"), "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": panelId, "data-testid": "shell-header-overflow-trigger", onClick: () => setOpen((wasOpen) => !wasOpen), className: "inline-flex size-10 shrink-0 items-center justify-center rounded-md border border-input bg-background text-foreground shadow-xs hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", children: _jsx(MoreHorizontal, { className: "size-4", "aria-hidden": "true" }) }), _jsxs("div", { ref: panelRef, id: panelId, role: "menu", "aria-label": t("kumiko.page-header.actions"), hidden: !open, onKeyDown: onPanelKeyDown, "data-testid": "shell-header-overflow", className: "absolute right-2 top-full z-30 mt-1 w-max min-w-[8rem] max-w-[calc(100vw-1rem)] rounded-md border bg-popover p-1 text-popover-foreground shadow-md", children: [bellScreens !== undefined && (_jsx(OverflowBellEntry, { screens: bellScreens, anchorRef: triggerRef, onSelect: () => setOpen(false), separated: foldsIntoOverflow(items, headerActions) })), items.length > 0 && (_jsx("div", { className: "flex flex-col", children: items.map((item) => (_jsxs("button", { type: "button", role: "menuitem", disabled: item.disabled === true, "data-testid": item.testId ?? `shell-header-overflow-item-${item.id}`, onClick: () => {
|
|
200
208
|
setOpen(false);
|
|
201
209
|
item.onSelect();
|
|
202
|
-
}, className: cn(headerOverflowMenuItemClass, item.variant === "danger" && "text-destructive"), children: [item.icon !== undefined && Object.hasOwn(NAV_ICONS, item.icon) && (_jsx(Icon, { name: item.icon, className: "size-4 shrink-0" })), item.label] }, item.id))) })), items.length > 0 && headerActions
|
|
210
|
+
}, className: cn(headerOverflowMenuItemClass, item.variant === "danger" && "text-destructive"), children: [item.icon !== undefined && Object.hasOwn(NAV_ICONS, item.icon) && (_jsx(Icon, { name: item.icon, className: "size-4 shrink-0" })), item.label] }, item.id))) })), items.length > 0 && foldsIntoOverflow([], headerActions) && (_jsx("hr", { className: "-mx-1 my-1 border-t border-border" })), headerActions !== undefined && (_jsx("div", { "data-kumiko-layout": "header-actions",
|
|
203
211
|
// Stacks direct children only; app wrappers opt in via HeaderActionGroup instead of
|
|
204
212
|
// being restyled through a child selector that reaches into their markup.
|
|
205
213
|
className: "flex flex-col items-stretch gap-1", onClick: () => setOpen(false), children: _jsx(HeaderOverflowMenuContext.Provider, { value: true, children: headerActions }) }))] })] }));
|