@cosmicdrift/kumiko-renderer 0.414.0 → 0.415.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/entity-list-screen.js +12 -9
- package/dist/app/list-facets.d.ts +1 -0
- package/dist/app/list-facets.js +10 -1
- package/dist/app/named-filter-facet.d.ts +0 -1
- package/dist/app/named-filter-facet.js +19 -10
- package/dist/app/projection-detail-guidance-data.js +3 -1
- package/dist/app/projection-detail-guidance.js +9 -9
- package/dist/app/projection-detail-header.js +4 -3
- package/dist/app/projection-detail-navigation.d.ts +2 -0
- package/dist/app/projection-detail-navigation.js +13 -3
- package/dist/app/screen-access.js +1 -2
- package/dist/app/use-entity-list-payload.d.ts +2 -1
- package/dist/app/use-entity-list-payload.js +4 -2
- package/dist/app/use-projection-detail-actions.d.ts +1 -0
- package/dist/app/use-projection-detail-actions.js +26 -14
- package/dist/app/use-row-decoration.d.ts +6 -4
- package/dist/app/use-row-decoration.js +67 -19
- package/dist/app/use-screen-list-rows.js +1 -1
- package/dist/card-options.d.ts +25 -0
- package/dist/card-options.js +1 -0
- package/dist/components/list-empty-state.d.ts +5 -0
- package/dist/components/list-empty-state.js +17 -1
- package/dist/components/render-list-hint-columns.d.ts +1 -0
- package/dist/components/render-list-hint-columns.js +10 -0
- package/dist/components/render-list-toolbar-model.d.ts +2 -2
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/context/screen-focus-context.d.ts +1 -1
- package/dist/context/screen-focus-context.js +3 -3
- package/dist/data-table-facet-types.d.ts +4 -0
- package/dist/headless/index.d.ts +1 -1
- package/dist/headless/index.js +1 -1
- package/dist/headless/pwa-service-worker-meta.d.ts +3 -0
- package/dist/headless/pwa-service-worker-meta.js +10 -0
- package/dist/headless/view-model/types.d.ts +4 -0
- package/dist/i18n-defaults.js +2 -1
- package/dist/metric-types.d.ts +2 -0
- package/dist/primitives-record-guidance.d.ts +2 -0
- package/dist/primitives.d.ts +7 -24
- package/dist/web/app/dashboard-header.js +1 -1
- package/dist/web/app/dashboard-list-panel.js +8 -13
- package/dist/web/app/dashboard-panels.d.ts +1 -0
- package/dist/web/app/dashboard-panels.js +9 -7
- package/dist/web/app/dashboard-reference-list-table.js +1 -0
- package/dist/web/app/dashboard-shared.js +2 -1
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -0
- package/dist/web/app/dashboard-stat-group-panel.js +14 -7
- package/dist/web/app/dashboard-text-panel.js +8 -4
- package/dist/web/drawn-icons.d.ts +6 -0
- package/dist/web/drawn-icons.js +30 -0
- package/dist/web/icons.js +6 -5
- package/dist/web/index.d.ts +2 -0
- package/dist/web/index.js +2 -0
- package/dist/web/layout/default-app-shell.js +3 -3
- package/dist/web/layout/nav-collapse-state.d.ts +2 -0
- package/dist/web/layout/nav-collapse-state.js +10 -0
- package/dist/web/layout/nav-tree.js +46 -23
- package/dist/web/layout/notification-bell.d.ts +7 -2
- package/dist/web/layout/notification-bell.js +16 -5
- package/dist/web/layout/shell-focus.d.ts +2 -2
- package/dist/web/layout/shell-focus.js +7 -3
- package/dist/web/layout/shell-header.d.ts +2 -1
- package/dist/web/layout/shell-header.js +56 -27
- package/dist/web/layout/shell-style.d.ts +3 -0
- package/dist/web/layout/shell-style.js +6 -0
- package/dist/web/layout/workspace-shell.d.ts +11 -1
- package/dist/web/layout/workspace-shell.js +6 -4
- package/dist/web/primitives/banner.d.ts +1 -1
- package/dist/web/primitives/banner.js +12 -7
- package/dist/web/primitives/card.js +18 -8
- package/dist/web/primitives/data-table/actions-column.d.ts +1 -1
- package/dist/web/primitives/data-table/actions-column.js +3 -1
- package/dist/web/primitives/data-table/card-body.d.ts +1 -1
- package/dist/web/primitives/data-table/card-body.js +11 -6
- package/dist/web/primitives/data-table/card-row.js +21 -17
- package/dist/web/primitives/data-table/hint-cell.d.ts +1 -3
- package/dist/web/primitives/data-table/hint-cell.js +4 -10
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -2
- package/dist/web/primitives/data-table/sort-options-select.js +3 -3
- package/dist/web/primitives/data-table/table-content.js +4 -4
- package/dist/web/primitives/data-table/table-view.js +8 -3
- package/dist/web/primitives/data-table/toolbar.d.ts +2 -0
- package/dist/web/primitives/data-table/toolbar.js +44 -9
- package/dist/web/primitives/data-table/totals-footer.js +4 -3
- package/dist/web/primitives/data-table-cell.js +44 -18
- package/dist/web/primitives/facet-filter.d.ts +1 -1
- package/dist/web/primitives/facet-filter.js +16 -8
- package/dist/web/primitives/facet-search-filter.d.ts +2 -1
- package/dist/web/primitives/facet-search-filter.js +3 -2
- package/dist/web/primitives/facet-trigger-label.d.ts +8 -0
- package/dist/web/primitives/facet-trigger-label.js +9 -0
- package/dist/web/primitives/file-view-action.js +4 -1
- package/dist/web/primitives/layout-elements.js +1 -1
- package/dist/web/primitives/metric.js +17 -5
- package/dist/web/primitives/page-header.js +3 -2
- package/dist/web/primitives/pager.d.ts +3 -2
- package/dist/web/primitives/pager.js +16 -20
- package/dist/web/primitives/record-breadcrumb.js +1 -1
- package/dist/web/primitives/record-steps.js +9 -4
- package/dist/web/primitives/record-summary.js +1 -1
- package/dist/web/primitives/segmented-select.js +6 -3
- package/dist/web/primitives/tabs.js +6 -1
- package/dist/web/pwa/pwa-support.js +19 -1
- package/dist/web/ui/sidebar.d.ts +2 -1
- package/dist/web/ui/sidebar.js +4 -3
- package/dist/web/widgets/ai-text-field.js +3 -2
- package/dist/web/widgets/dashboard-list-cards.js +6 -14
- package/dist/web/widgets/dashboard-list.d.ts +8 -0
- package/dist/web/widgets/dashboard-list.js +34 -8
- package/dist/web/widgets/drawer-panel-class.d.ts +1 -0
- package/dist/web/widgets/drawer-panel-class.js +9 -1
- package/dist/web/widgets/drawer.js +2 -2
- package/dist/web/widgets/pdf-viewer-toolbar.js +3 -2
- package/dist/web/widgets/sheet-parts.js +3 -1
- package/dist/web/widgets/stat-box-cell.js +1 -1
- package/dist/web/widgets/stat.d.ts +7 -1
- package/dist/web/widgets/stat.js +12 -4
- package/dist/web/widgets/step-list-row.d.ts +4 -0
- package/dist/web/widgets/step-list-row.js +22 -14
- package/dist/web/widgets/step-list.d.ts +12 -4
- package/dist/web/widgets/step-list.js +38 -20
- package/package.json +5 -5
- package/src/changes.json +72 -0
- package/src/web/styles.css +6 -0
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// ShellHeader — inset header bar for sidebar-based shells: SidebarTrigger
|
|
3
|
-
// (rail/mobile-sheet toggle), breadcrumb of the active screen, optional
|
|
4
|
-
// right-aligned headerActions. Shared by DefaultAppShell and WorkspaceShell so
|
|
5
|
-
// both carry the same header (h-14, also with a collapsed icon rail).
|
|
6
|
-
//
|
|
7
|
-
// The `data-kumiko-layout="shell-header"` marker drives `--shell-header-height`
|
|
8
|
-
// in styles.css (:has() selector) — the single source for the header height
|
|
9
|
-
// that Drawer's `belowHeader` prop also reads.
|
|
10
2
|
import { IN_APP_NOTIFICATION_FEATURE } from "@cosmicdrift/kumiko-types/in-app-notification-types";
|
|
11
3
|
import { ChevronLeft, MoreHorizontal } from "lucide-react";
|
|
12
4
|
import { Fragment, useEffect, useId, useMemo, useRef, useState, } from "react";
|
|
@@ -23,14 +15,17 @@ import { NotificationBell } from "./notification-bell.js";
|
|
|
23
15
|
import { usePageHeaderSlot } from "./page-header-slot.js";
|
|
24
16
|
import { activeNavLabel, resolveDetailBreadcrumb, screenTitleKey, } from "./shell-breadcrumb.js";
|
|
25
17
|
import { useShellFocused } from "./shell-focus.js";
|
|
18
|
+
import { useShellNavStyle } from "./shell-style.js";
|
|
26
19
|
import { SHELL_HEADER_CONTROLS_CLASSES } from "./uniform-bar-controls.js";
|
|
27
|
-
export function ShellHeader({ schema, user, headerActions: appHeaderActions, allowedNavQns, }) {
|
|
20
|
+
export function ShellHeader({ schema, user, headerActions: appHeaderActions, allowedNavQns, notificationBellPlacement = "header", }) {
|
|
28
21
|
const nav = useNav();
|
|
29
22
|
const t = useTranslation();
|
|
30
23
|
const focused = useShellFocused();
|
|
24
|
+
const plainNav = useShellNavStyle() === "plain";
|
|
31
25
|
// The app's headerActions (the assistant button) stay in focus mode: they are not navigation,
|
|
32
|
-
// and a focused screen must not cut the user off from them. The
|
|
33
|
-
//
|
|
26
|
+
// and a focused screen must not cut the user off from them. The notification bell is rendered
|
|
27
|
+
// by this header itself, not passed in, and stays hidden; so does the sidebar trigger, except
|
|
28
|
+
// with the plain nav style, whose panel symbol stays visible in focus mode.
|
|
34
29
|
const headerActions = appHeaderActions;
|
|
35
30
|
const appSchema = toAppSchema(schema);
|
|
36
31
|
const tree = useMemo(() => {
|
|
@@ -72,12 +67,8 @@ export function ShellHeader({ schema, user, headerActions: appHeaderActions, all
|
|
|
72
67
|
const titleOverride = slot?.title;
|
|
73
68
|
const recordTitle = slot?.recordTitle;
|
|
74
69
|
const compact = usePageHeaderCompact();
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
const pinnedActions = compact ? collectPinnedHeaderActions(headerActions) : [];
|
|
78
|
-
const hasOverflow = compact &&
|
|
79
|
-
(overflowItems.length > 0 ||
|
|
80
|
-
(headerActions !== undefined && !isOnlyPinnedHeaderActions(headerActions)));
|
|
70
|
+
const showsBell = !focused && user !== undefined && hasInAppChannel;
|
|
71
|
+
const bellInOverflow = showsBell && notificationBellPlacement === "overflow";
|
|
81
72
|
// A stand-in without a translated title must not surface the raw i18n key.
|
|
82
73
|
const standInUntitled = standInScreenId !== undefined && crumbs?.at(-1)?.label === screenTitleKey(standInScreenId);
|
|
83
74
|
const bodyTitle = slot?.bodyTitle === true;
|
|
@@ -105,20 +96,43 @@ export function ShellHeader({ schema, user, headerActions: appHeaderActions, all
|
|
|
105
96
|
];
|
|
106
97
|
};
|
|
107
98
|
const shownCrumbs = bodyTitle ? bodyTitleCrumbs() : visibleCrumbs;
|
|
108
|
-
return (_jsxs("header", { "data-kumiko-layout": "shell-header", 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", compact && "relative", focused && "max-md:hidden"), children: [_jsxs("div", { className: "@container flex min-w-0 flex-1 items-center gap-3", children: [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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 })] }));
|
|
100
|
+
}
|
|
101
|
+
function foldsIntoOverflow(overflowItems, headerActions) {
|
|
102
|
+
if (overflowItems.length > 0)
|
|
103
|
+
return true;
|
|
104
|
+
return headerActions !== undefined && !isOnlyPinnedHeaderActions(headerActions);
|
|
105
|
+
}
|
|
106
|
+
// On a phone the app's headerActions fold into the menu, except the ones wrapped in HeaderActionPinned.
|
|
107
|
+
function VisibleHeaderActions({ compact, headerActions, }) {
|
|
108
|
+
if (!compact) {
|
|
109
|
+
if (headerActions === undefined)
|
|
110
|
+
return null;
|
|
111
|
+
return (_jsx("div", { "data-kumiko-layout": "header-actions", className: "flex items-center gap-2", children: headerActions }));
|
|
112
|
+
}
|
|
113
|
+
const pinnedActions = collectPinnedHeaderActions(headerActions);
|
|
114
|
+
if (pinnedActions.length === 0)
|
|
115
|
+
return null;
|
|
116
|
+
return (_jsx("div", { "data-kumiko-layout": "header-actions-pinned", className: "flex items-center gap-2", children: pinnedActions }));
|
|
117
|
+
}
|
|
118
|
+
function ShellHeaderEnd({ compact, actionsRef, headerActions, overflowItems, bellScreens, bellInOverflow, }) {
|
|
119
|
+
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 }) }))] }));
|
|
121
|
+
}
|
|
122
|
+
function ShellSidebarTrigger({ focused, plainNav, }) {
|
|
123
|
+
const t = useTranslation();
|
|
124
|
+
if (focused && !plainNav)
|
|
125
|
+
return null;
|
|
126
|
+
return (_jsx(SidebarTrigger, { label: t("kumiko.sidebar.toggle"), ...(plainNav && { icon: "panel-all-widths" }) }));
|
|
116
127
|
}
|
|
117
128
|
// A hand-rolled menu instead of Radix DropdownMenu: app headerActions are opaque
|
|
118
129
|
// nodes with their own popovers, and the panel stays mounted while closed so their
|
|
119
130
|
// effects (shortcut listeners) keep running.
|
|
120
131
|
const MENU_ITEM_SELECTOR = '[role="menuitem"]:not(:disabled)';
|
|
121
|
-
function
|
|
132
|
+
function OverflowBellEntry({ screens, anchorRef, onSelect, separated, }) {
|
|
133
|
+
return (_jsxs(_Fragment, { children: [_jsx(NotificationBell, { screens: screens, menuEntry: { anchorRef, onSelect } }), separated && _jsx("hr", { className: "-mx-1 my-1 border-t border-border" })] }));
|
|
134
|
+
}
|
|
135
|
+
function HeaderOverflow({ items, headerActions, bellScreens, }) {
|
|
122
136
|
const t = useTranslation();
|
|
123
137
|
const [open, setOpen] = useState(false);
|
|
124
138
|
const panelId = useId();
|
|
@@ -182,7 +196,7 @@ function HeaderOverflow({ items, headerActions, }) {
|
|
|
182
196
|
event.preventDefault();
|
|
183
197
|
menuItems[next]?.focus();
|
|
184
198
|
};
|
|
185
|
-
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: [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: () => {
|
|
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.length > 0 || headerActions !== undefined })), 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: () => {
|
|
186
200
|
setOpen(false);
|
|
187
201
|
item.onSelect();
|
|
188
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 !== undefined && (_jsx("hr", { className: "-mx-1 my-1 border-t border-border" })), headerActions !== undefined && (_jsx("div", { "data-kumiko-layout": "header-actions",
|
|
@@ -190,3 +204,18 @@ function HeaderOverflow({ items, headerActions, }) {
|
|
|
190
204
|
// being restyled through a child selector that reaches into their markup.
|
|
191
205
|
className: "flex flex-col items-stretch gap-1", onClick: () => setOpen(false), children: _jsx(HeaderOverflowMenuContext.Provider, { value: true, children: headerActions }) }))] })] }));
|
|
192
206
|
}
|
|
207
|
+
// The bar's breadcrumb: only the page title truncates, parents stay whole and leave when the space is too narrow.
|
|
208
|
+
function ShellBreadcrumb({ crumbs, parentOnly, bodyTitle, titleOverride, }) {
|
|
209
|
+
const nav = useNav();
|
|
210
|
+
const t = useTranslation();
|
|
211
|
+
if (crumbs === undefined || crumbs.length === 0)
|
|
212
|
+
return null;
|
|
213
|
+
return (_jsx(Breadcrumb, { className: "min-w-0", "aria-label": t("kumiko.breadcrumb.label"), children: _jsx(BreadcrumbList, { className: "flex-nowrap gap-1.5 sm:gap-1.5", children: crumbs.map((crumb, index) => {
|
|
214
|
+
const screenId = crumb.screenId;
|
|
215
|
+
const isLast = index === crumbs.length - 1;
|
|
216
|
+
return (_jsxs(Fragment, { children: [index > 0 && (_jsx(BreadcrumbSeparator, { className: "hidden text-muted-foreground @xs:inline-flex [&>svg]:size-3.5" })), _jsx(BreadcrumbItem, { className: cn(isLast ? "min-w-0" : "hidden shrink-0 @xs:inline-flex"), children: screenId !== undefined && (!isLast || parentOnly) ? (_jsxs(BreadcrumbLink, { href: "#", className: cn("whitespace-nowrap text-foreground-secondary", parentOnly && "text-[17px] font-semibold text-foreground"), onClick: (e) => {
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
nav.navigate({ screenId });
|
|
219
|
+
}, children: [parentOnly && (_jsx(ChevronLeft, { className: "me-0.5 inline size-4 align-text-bottom", "aria-hidden": "true" })), crumb.label] })) : isLast && bodyTitle ? (_jsx("span", { className: "truncate text-lg font-semibold text-foreground", children: crumb.label })) : isLast ? (_jsx("h1", { "aria-current": "page", title: titleOverride ?? crumb.label, className: "truncate text-lg font-semibold text-foreground", children: titleOverride ?? crumb.label })) : (_jsx(BreadcrumbPage, { className: "whitespace-nowrap text-foreground-secondary", children: crumb.label })) })] }, screenId ?? crumb.label));
|
|
220
|
+
}) }) }));
|
|
221
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { AppSchema, FeatureSchema, WorkspaceSchema } from "../../index.ts";
|
|
3
|
+
import { type ShellNavStyle } from "./shell-style.tsx";
|
|
3
4
|
export type WorkspaceShellUser = {
|
|
4
5
|
readonly id: string;
|
|
5
6
|
readonly roles: readonly string[];
|
|
@@ -34,10 +35,19 @@ export type WorkspaceShellProps = {
|
|
|
34
35
|
* scrolls INSIDE instead of the whole page. Default true — set
|
|
35
36
|
* `fill={false}` to opt back into page scroll. */
|
|
36
37
|
readonly fill?: boolean;
|
|
38
|
+
/** Surface behind the screen content. `"card"` (default) keeps the inset on `bg-card`;
|
|
39
|
+
* `"background"` lets the page background show through so cards stand out from it. */
|
|
40
|
+
readonly contentSurface?: "card" | "background";
|
|
41
|
+
/** `"plain"` renders the sidebar without leading icons while expanded (the focus rail and the
|
|
42
|
+
* collapsed rail keep them), with uppercase group labels, quiet active entries, a panel-symbol
|
|
43
|
+
* sidebar trigger and a 58px title bar. `"default"` keeps the icon navigation. */
|
|
44
|
+
readonly navStyle?: ShellNavStyle;
|
|
45
|
+
/** `"header"` (default) draws the notification bell in the title bar; `"overflow"` moves it into the "…" menu, which then shows on every width. */
|
|
46
|
+
readonly notificationBellPlacement?: "header" | "overflow";
|
|
37
47
|
/** Screen content. */
|
|
38
48
|
readonly children: ReactNode;
|
|
39
49
|
};
|
|
40
|
-
export declare function WorkspaceShell({ brand, schema, topbarActions, user, initialWorkspaceId, sidebarFooter, focusRailNavQns, navBadges, fill, children, }: WorkspaceShellProps): ReactNode;
|
|
50
|
+
export declare function WorkspaceShell({ brand, schema, topbarActions, user, initialWorkspaceId, sidebarFooter, focusRailNavQns, navBadges, fill, contentSurface, navStyle, notificationBellPlacement, children, }: WorkspaceShellProps): ReactNode;
|
|
41
51
|
export declare function filterByAccess(workspaces: readonly WorkspaceSchema[], userRoles: readonly string[] | undefined): readonly WorkspaceSchema[];
|
|
42
52
|
/** Returns the short screen-id of the first nav-member that points at
|
|
43
53
|
* a screen. Walks the workspace's nav-list in order and skips section
|
|
@@ -33,19 +33,21 @@ import { isUiAccessGranted } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
|
33
33
|
import { useCallback, useLayoutEffect, useMemo } from "react";
|
|
34
34
|
import { qualifyNavId, ScreenFocusProvider, toAppSchema, UserRolesProvider, useNav, useTranslation, } from "../../index.js";
|
|
35
35
|
import { useResolvers } from "../app/resolvers-context.js";
|
|
36
|
+
import { cn } from "../lib/cn.js";
|
|
36
37
|
import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarInset, SidebarProvider, SidebarRail, } from "../ui/sidebar.js";
|
|
37
38
|
import { EditorPanel } from "./editor-panel.js";
|
|
38
39
|
import { fillClasses } from "./fill-classes.js";
|
|
39
40
|
import { FocusAwareSidebarBody, sidebarProviderProps } from "./focus-aware-sidebar.js";
|
|
40
41
|
import { lastSegment, NavTree } from "./nav-tree.js";
|
|
41
42
|
import { PageHeaderSlotProvider } from "./page-header-slot.js";
|
|
42
|
-
import { ShellFocusProvider, useShellFocusHost } from "./shell-focus.js";
|
|
43
|
+
import { ShellFocusProvider, ShellTopbarActionsProvider, useShellFocusHost, } from "./shell-focus.js";
|
|
43
44
|
import { ShellHeader } from "./shell-header.js";
|
|
45
|
+
import { ShellNavStyleProvider } from "./shell-style.js";
|
|
44
46
|
import { usePersistedSidebarOpen } from "./sidebar-open-state.js";
|
|
45
47
|
import { SidebarPanelProvider, useSidebarPanelHost } from "./sidebar-panel.js";
|
|
46
48
|
import { parseTargetFromSearchParams } from "./target-url.js";
|
|
47
49
|
import { WorkspaceSwitcher } from "./workspace-switcher.js";
|
|
48
|
-
export function WorkspaceShell({ brand, schema, topbarActions, user, initialWorkspaceId, sidebarFooter, focusRailNavQns, navBadges, fill = true, children, }) {
|
|
50
|
+
export function WorkspaceShell({ brand, schema, topbarActions, user, initialWorkspaceId, sidebarFooter, focusRailNavQns, navBadges, fill = true, contentSurface = "card", navStyle = "default", notificationBellPlacement = "header", children, }) {
|
|
49
51
|
const app = useMemo(() => toAppSchema(schema), [schema]);
|
|
50
52
|
const visible = useMemo(() => filterByAccess(app.workspaces ?? [], user?.roles), [app.workspaces, user?.roles]);
|
|
51
53
|
const nav = useNav();
|
|
@@ -153,9 +155,9 @@ export function WorkspaceShell({ brand, schema, topbarActions, user, initialWork
|
|
|
153
155
|
// The second column appears only when a screen fills it (sidebar-09 pattern);
|
|
154
156
|
// otherwise every other screen would have an empty strip beside the navigation.
|
|
155
157
|
const panel = useSidebarPanelHost();
|
|
156
|
-
const focus = useShellFocusHost(
|
|
158
|
+
const focus = useShellFocusHost();
|
|
157
159
|
const sidebarOpen = usePersistedSidebarOpen();
|
|
158
|
-
return (_jsx(ScreenFocusProvider, { children: _jsx(SidebarProvider, { ...fillCls.provider, ...sidebarProviderProps(focus, sidebarOpen), children: _jsx(ShellFocusProvider, { value: focus.value, children: _jsxs(SidebarPanelProvider, { value: panel.value, children: [_jsxs(Sidebar, { collapsible: "icon", mobileTitle: t("kumiko.sidebar.title"), mobileDescription: t("kumiko.sidebar.description"), children: [_jsxs(FocusAwareSidebarBody, { focused: focus.focused, brand: brand, schema: app, user: user, allowedNavQns: allowedNavQns, railNavQns: focusRailNavQns, footer: sidebarFooter, children: [_jsxs(SidebarHeader, { "data-kumiko-layout": "sidebar-header", children: [brand, switcher] }), _jsx(SidebarContent, { "data-kumiko-layout": "sidebar-nav", children: sidebarContent }), sidebarFooter !== undefined && (_jsx(SidebarFooter, { "data-kumiko-layout": "sidebar-footer", className: "border-t border-sidebar-border", children: sidebarFooter }))] }), _jsx(SidebarRail, { "aria-label": t("kumiko.sidebar.toggle"), title: t("kumiko.sidebar.toggle") })] }), _jsx("div", { ref: panel.ref, "data-kumiko-layout": "sidebar-panel", className: panel.occupied ? "flex h-svh shrink-0 flex-col" : "hidden" }), _jsx(SidebarInset, { className: fillCls.inset, children: _jsxs(PageHeaderSlotProvider, { children: [_jsx(ShellHeader, { schema: app, ...(user !== undefined && { user }), ...(allowedNavQns !== undefined && { allowedNavQns }), ...(topbarActions !== undefined && { headerActions: topbarActions }) }), _jsx("main", { className: fillCls.main, children: activeTarget !== undefined ? (_jsx(EditorPanel, { resolvers: resolvers })) : (_jsx(UserRolesProvider, { roles: user?.roles, children: children })) })] }) })] }) }) }) }));
|
|
160
|
+
return (_jsx(ShellNavStyleProvider, { value: navStyle, children: _jsx(ScreenFocusProvider, { children: _jsx(SidebarProvider, { ...fillCls.provider, ...sidebarProviderProps(focus, sidebarOpen), children: _jsx(ShellFocusProvider, { value: focus.value, children: _jsx(ShellTopbarActionsProvider, { value: topbarActions, children: _jsxs(SidebarPanelProvider, { value: panel.value, children: [_jsxs(Sidebar, { collapsible: "icon", mobileTitle: t("kumiko.sidebar.title"), mobileDescription: t("kumiko.sidebar.description"), children: [_jsxs(FocusAwareSidebarBody, { focused: focus.focused, brand: brand, schema: app, user: user, allowedNavQns: allowedNavQns, railNavQns: focusRailNavQns, footer: sidebarFooter, children: [_jsxs(SidebarHeader, { "data-kumiko-layout": "sidebar-header", children: [brand, switcher] }), _jsx(SidebarContent, { "data-kumiko-layout": "sidebar-nav", children: sidebarContent }), sidebarFooter !== undefined && (_jsx(SidebarFooter, { "data-kumiko-layout": "sidebar-footer", className: "border-t border-sidebar-border", children: sidebarFooter }))] }), _jsx(SidebarRail, { "aria-label": t("kumiko.sidebar.toggle"), title: t("kumiko.sidebar.toggle") })] }), _jsx("div", { ref: panel.ref, "data-kumiko-layout": "sidebar-panel", className: panel.occupied ? "flex h-svh shrink-0 flex-col" : "hidden" }), _jsx(SidebarInset, { className: cn(fillCls.inset, contentSurface === "background" && "bg-background"), children: _jsxs(PageHeaderSlotProvider, { children: [_jsx(ShellHeader, { schema: app, ...(user !== undefined && { user }), ...(allowedNavQns !== undefined && { allowedNavQns }), ...(topbarActions !== undefined && { headerActions: topbarActions }), notificationBellPlacement: notificationBellPlacement }), _jsx("main", { className: fillCls.main, children: activeTarget !== undefined ? (_jsx(EditorPanel, { resolvers: resolvers })) : (_jsx(UserRolesProvider, { roles: user?.roles, children: children })) })] }) })] }) }) }) }) }) }));
|
|
159
161
|
}
|
|
160
162
|
// --- helpers (exported for tests) ---
|
|
161
163
|
export function filterByAccess(workspaces, userRoles) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { BannerProps } from "../../index.ts";
|
|
3
3
|
import "../react-css-custom-properties.ts";
|
|
4
|
-
export declare function DefaultBanner({ variant, density, icon, title, titleTestId, children, parts, actions, actionsPlacement, padded, inline, testId, id, }: BannerProps): ReactNode;
|
|
4
|
+
export declare function DefaultBanner({ variant, density, icon, title, narrowTitle, narrowText, titleTestId, children, parts, actions, actionsPlacement, padded, inline, testId, id, }: BannerProps): ReactNode;
|
|
@@ -3,6 +3,7 @@ import { Icon } from "../icons.js";
|
|
|
3
3
|
import { cn } from "../lib/cn.js";
|
|
4
4
|
import "../react-css-custom-properties.js";
|
|
5
5
|
import { fieldLabelId } from "./field.js";
|
|
6
|
+
import { useIsBelowSmViewport } from "./use-narrow-viewport.js";
|
|
6
7
|
const ICON_COLOR_CLASS = {
|
|
7
8
|
hint: "text-primary",
|
|
8
9
|
info: "text-primary",
|
|
@@ -17,7 +18,7 @@ function variantClass(variant, compact) {
|
|
|
17
18
|
case "error":
|
|
18
19
|
return "border-destructive/50 text-destructive bg-destructive/10 dark:border-destructive";
|
|
19
20
|
case "warning":
|
|
20
|
-
return "border-status-warn/30 bg-status-warn
|
|
21
|
+
return "border-status-warn/30 bg-status-warn-surface text-status-warn";
|
|
21
22
|
case "ok":
|
|
22
23
|
return "border-status-ok/30 bg-status-ok-surface text-foreground";
|
|
23
24
|
case "primary":
|
|
@@ -41,21 +42,25 @@ function BannerParts({ parts }) {
|
|
|
41
42
|
return part.strong === true ? (_jsx("strong", { className: "font-semibold", children: part.text }, key)) : (_jsx("span", { children: part.text }, key));
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
|
-
function BannerText({ compact, title, titleTestId, children, parts, actionsBelow, inline, }) {
|
|
45
|
+
function BannerText({ compact, title: fullTitle, narrowTitle, narrowText, titleTestId, children: fullText, parts, actionsBelow, inline, }) {
|
|
46
|
+
const narrow = useIsBelowSmViewport();
|
|
47
|
+
const title = narrow && narrowTitle !== undefined ? narrowTitle : fullTitle;
|
|
48
|
+
const showsNarrowText = narrow && narrowText !== undefined;
|
|
49
|
+
const children = showsNarrowText ? narrowText : fullText;
|
|
45
50
|
if (compact || inline) {
|
|
46
|
-
return (_jsxs("div", { className: "min-w-0 grow", children: [title !== undefined && (_jsxs(_Fragment, { children: [_jsx("strong", { "data-testid": titleTestId, className: "font-semibold", children: title }), " "] })), _jsxs("span", { className: cn(inline && "max-sm:hidden"), children: [children, _jsx(BannerParts, { parts: parts })] })] }));
|
|
51
|
+
return (_jsxs("div", { className: "min-w-0 grow", children: [title !== undefined && (_jsxs(_Fragment, { children: [_jsx("strong", { "data-testid": titleTestId, className: "font-semibold", children: title }), " "] })), _jsxs("span", { className: cn(inline && !showsNarrowText && "max-sm:hidden"), children: [children, !showsNarrowText && _jsx(BannerParts, { parts: parts })] })] }));
|
|
47
52
|
}
|
|
48
|
-
return (_jsxs("div", { className: "flex-1", children: [title !== undefined && (_jsx("div", { "data-testid": titleTestId, className: "font-semibold", children: title })), children, _jsx(BannerParts, { parts: parts }), actionsBelow] }));
|
|
53
|
+
return (_jsxs("div", { className: "flex-1", children: [title !== undefined && (_jsx("div", { "data-testid": titleTestId, className: "font-semibold", children: title })), children, !showsNarrowText && _jsx(BannerParts, { parts: parts }), actionsBelow] }));
|
|
49
54
|
}
|
|
50
55
|
function bannerLayoutClass(variant, compact, actionsBelow) {
|
|
51
|
-
return cn("relative flex w-full items-center border", compact ? "gap-2 rounded-md px-2.5 py-2 text-[13px]" : "gap-3 rounded-lg px-
|
|
56
|
+
return cn("relative flex w-full items-center border", compact ? "gap-2 rounded-md px-2.5 py-2 text-[13px]" : "gap-3 rounded-lg px-3.5 py-2.5 text-sm",
|
|
52
57
|
// Viewport breakpoint like the form footer bar; actions drop below the text on phones.
|
|
53
58
|
!compact &&
|
|
54
59
|
!actionsBelow &&
|
|
55
60
|
variant === "primary" &&
|
|
56
61
|
"flex-col items-start sm:flex-row sm:items-center", actionsBelow && "items-start", variantClass(variant, compact));
|
|
57
62
|
}
|
|
58
|
-
export function DefaultBanner({ variant = "info", density = "default", icon, title, titleTestId, children, parts, actions, actionsPlacement = "end", padded, inline = false, testId, id, }) {
|
|
63
|
+
export function DefaultBanner({ variant = "info", density = "default", icon, title, narrowTitle, narrowText, titleTestId, children, parts, actions, actionsPlacement = "end", padded, inline = false, testId, id, }) {
|
|
59
64
|
const isError = variant === "error";
|
|
60
65
|
const compact = density === "compact";
|
|
61
66
|
// A compact banner is one line, so its actions always stay at the end.
|
|
@@ -65,7 +70,7 @@ export function DefaultBanner({ variant = "info", density = "default", icon, tit
|
|
|
65
70
|
// at it is inert for screen readers — role="group" + aria-labelledby is
|
|
66
71
|
// the actual mechanism, pointed at the label id Field emits (fieldLabelId).
|
|
67
72
|
const bannerRole = id !== undefined ? "group" : isError ? "alert" : undefined;
|
|
68
|
-
const banner = (_jsxs("div", { role: bannerRole, ...(id !== undefined && { "aria-labelledby": fieldLabelId(id) }), "data-testid": testId, "data-variant": variant, "data-density": density, className: bannerLayoutClass(variant, compact, actionsBelow), children: [icon !== undefined && (_jsx(Icon, { name: icon, className: cn("size-3.5 shrink-0", ICON_COLOR_CLASS[variant]) })), _jsx(BannerText, { compact: compact, inline: inline, title: title, titleTestId: titleTestId, parts: parts, actionsBelow: actionsBelow ? (_jsx("div", { "data-slot": "actions", className: "mt-3 flex flex-wrap gap-2", children: actions })) : undefined, children: children }), !actionsBelow && actions !== undefined && (_jsx("div", { "data-slot": "actions", className: cn(compact && "shrink-0"), children: actions }))] }));
|
|
73
|
+
const banner = (_jsxs("div", { role: bannerRole, ...(id !== undefined && { "aria-labelledby": fieldLabelId(id) }), "data-testid": testId, "data-variant": variant, "data-density": density, className: bannerLayoutClass(variant, compact, actionsBelow), children: [icon !== undefined && (_jsx(Icon, { name: icon, className: cn("size-3.5 shrink-0", ICON_COLOR_CLASS[variant]) })), _jsx(BannerText, { compact: compact, inline: inline, title: title, narrowTitle: narrowTitle, narrowText: narrowText, titleTestId: titleTestId, parts: parts, actionsBelow: actionsBelow ? (_jsx("div", { "data-slot": "actions", className: "mt-3 flex flex-wrap gap-2", children: actions })) : undefined, children: children }), !actionsBelow && actions !== undefined && (_jsx("div", { "data-slot": "actions", className: cn(compact && "shrink-0"), children: actions }))] }));
|
|
69
74
|
// Page state: the banner sits alone in main (which no longer has padding).
|
|
70
75
|
// The wrapper adds 24px outer spacing so the banner does not stick
|
|
71
76
|
// edge-to-edge to the sidebar/browser.
|
|
@@ -4,6 +4,20 @@ import { InsideScreenFormColumnContext } from "./metric.js";
|
|
|
4
4
|
import "../react-css-custom-properties.js";
|
|
5
5
|
import { cardFooter, cardFooterBorder, cardFooterInset, cardSurface } from "./card-styles.js";
|
|
6
6
|
import { FormScreenShell } from "./form.js";
|
|
7
|
+
function cardBodyPadding(inline, hasHeader) {
|
|
8
|
+
if (inline)
|
|
9
|
+
return "px-4 pb-4 pt-3";
|
|
10
|
+
return hasHeader
|
|
11
|
+
? "px-[var(--card-padding)] pb-[var(--card-padding)]"
|
|
12
|
+
: "p-[var(--card-padding)]";
|
|
13
|
+
}
|
|
14
|
+
function CardTitleRow({ slots, inline, }) {
|
|
15
|
+
const { title, subtitle, headerActions } = slots;
|
|
16
|
+
if (inline) {
|
|
17
|
+
return (_jsxs("div", { className: "flex flex-wrap items-baseline gap-x-2.5 gap-y-1", children: [title !== undefined && _jsx("h3", { className: "m-0 text-sm font-semibold", children: title }), subtitle !== undefined && (_jsx("div", { className: "text-[12.5px] text-muted-foreground", children: subtitle })), headerActions !== undefined && _jsx("div", { className: "ml-auto", children: headerActions })] }));
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [title !== undefined && (_jsx("h3", { className: "text-base font-semibold leading-none tracking-tight", children: title })), subtitle !== undefined && _jsx("div", { className: "text-sm text-muted-foreground", children: subtitle })] }), headerActions] }));
|
|
20
|
+
}
|
|
7
21
|
// Generic card chrome (rounded-xl like the entity card), slot- and
|
|
8
22
|
// options-based so the contract grows additively and consumers never have
|
|
9
23
|
// to migrate.
|
|
@@ -16,10 +30,9 @@ export function DefaultCard({ slots, options, className, testId, dataAttributes,
|
|
|
16
30
|
const fillHeight = options?.fillHeight ?? false;
|
|
17
31
|
const framed = screenBody ? false : (options?.framed ?? true);
|
|
18
32
|
const s = slots ?? {};
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
s.headerActions !== undefined ? (_jsxs("div", { className: cn("flex flex-col gap-3 px-[var(--card-padding)] pt-6 pb-4", fillHeight && "shrink-0"), children: [(s.title !== undefined || s.subtitle !== undefined || s.headerActions !== undefined) && (_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [s.title !== undefined && (_jsx("h3", { className: "text-base font-semibold leading-none tracking-tight", children: s.title })), s.subtitle !== undefined && (_jsx("div", { className: "text-sm text-muted-foreground", children: s.subtitle }))] }), s.headerActions] })), s.headerContent] })) : null;
|
|
33
|
+
const inlineHeader = options?.headerLayout === "inline";
|
|
34
|
+
const hasTitleRow = s.title !== undefined || s.subtitle !== undefined || s.headerActions !== undefined;
|
|
35
|
+
const defaultHeader = hasTitleRow || s.headerContent !== undefined ? (_jsxs("div", { className: cn("flex flex-col gap-3", inlineHeader ? "px-4 pt-3.5" : "px-[var(--card-padding)] pt-6 pb-4", fillHeight && "shrink-0"), children: [hasTitleRow && _jsx(CardTitleRow, { slots: s, inline: inlineHeader }), s.headerContent] })) : null;
|
|
23
36
|
const header = s.header ?? defaultHeader;
|
|
24
37
|
const hasHeader = header !== null && header !== undefined;
|
|
25
38
|
const card = (_jsxs("div", { ...dataAttributes, "data-slot": "card", "data-testid": testId, className: cn(framed ? cardSurface({ radius }) : "flex flex-col",
|
|
@@ -29,10 +42,7 @@ export function DefaultCard({ slots, options, className, testId, dataAttributes,
|
|
|
29
42
|
// Same "no flex-1" reasoning as DefaultForm's own fillHeight card:
|
|
30
43
|
// sizes to content and only shrinks (min-h-0) once
|
|
31
44
|
// an ancestor is itself height-constrained.
|
|
32
|
-
fillHeight && "min-h-0 flex flex-col", className), children: [header, children != null && (_jsx("div", { className: cn("grow", screenBody && "flex flex-col gap-6", padded &&
|
|
33
|
-
(hasHeader
|
|
34
|
-
? "px-[var(--card-padding)] pb-[var(--card-padding)]"
|
|
35
|
-
: "p-[var(--card-padding)]"),
|
|
45
|
+
fillHeight && "min-h-0 flex flex-col", className), children: [header, children != null && (_jsx("div", { className: cn("grow", screenBody && "flex flex-col gap-6", padded && cardBodyPadding(inlineHeader, hasHeader),
|
|
36
46
|
// The one region allowed to shrink and scroll internally — mirrors
|
|
37
47
|
// FormSections' fillHeight === true && "min-h-0" treatment of the
|
|
38
48
|
// section it wraps.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
2
|
import "../../react-css-custom-properties.ts";
|
|
3
3
|
export declare const ACTIONS_CONTENT_ATTRIBUTE = "data-actions-content";
|
|
4
|
-
export declare function stickyActionsCellClass(fillsHeight: boolean): string;
|
|
4
|
+
export declare function stickyActionsCellClass(fillsHeight: boolean, inFooter?: boolean): string;
|
|
5
5
|
export declare function ActionsHeaderCell({ label, style, absorbsLeftover, }: {
|
|
6
6
|
readonly label: string;
|
|
7
7
|
readonly style?: CSSProperties | undefined;
|
|
@@ -5,7 +5,9 @@ import { COLUMN_ROLE_ATTRIBUTE } from "./column-role.js";
|
|
|
5
5
|
import { ROW_FOCUS_RING_CELL_CLASS } from "./use-row-keyboard-navigation.js";
|
|
6
6
|
import "../../react-css-custom-properties.js";
|
|
7
7
|
export const ACTIONS_CONTENT_ATTRIBUTE = "data-actions-content";
|
|
8
|
-
export function stickyActionsCellClass(fillsHeight) {
|
|
8
|
+
export function stickyActionsCellClass(fillsHeight, inFooter = false) {
|
|
9
|
+
if (inFooter)
|
|
10
|
+
return "md:sticky md:right-0 md:z-10 md:bg-muted";
|
|
9
11
|
return cn("md:sticky md:right-0 md:z-10", fillsHeight ? "md:bg-card" : "md:bg-background");
|
|
10
12
|
}
|
|
11
13
|
export function ActionsHeaderCell({ label, style, absorbsLeftover, }) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type cardColumnRoles } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import type { ListColumnViewModel, ListRowViewModel } from "../../../headless/index.ts";
|
|
4
4
|
import type { DataTableModel } from "./use-data-table-state.ts";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cardMetaLines } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
3
|
import { ChevronRight } from "lucide-react";
|
|
3
4
|
import { cellLinkProp, DataTableCell, isBadgeColumn, isEmptyCellValue, isUnlabeledFalse, showsBareCheckMark, } from "../data-table-cell.js";
|
|
4
5
|
import { CardLeadingImage } from "../file-thumbnail.js";
|
|
@@ -6,7 +7,7 @@ import { columnCellPresentationProps } from "./data-cell-props.js";
|
|
|
6
7
|
import { showFullTextOnHover } from "./table-footer.js";
|
|
7
8
|
// The phone card shows the sentence and its (narrow) detail; the reason toggle stays a table feature.
|
|
8
9
|
function cardHint(hint) {
|
|
9
|
-
const { reasonField: _reason, reasonOpenField: _reasonOpen, reasonTitleField: _reasonTitle, detailField: _detail, narrowDetailField, ...rest } = hint;
|
|
10
|
+
const { reasonField: _reason, reasonOpenField: _reasonOpen, reasonTitleField: _reasonTitle, detailField: _detail, narrowDetailField, narrowField: _narrowField, ...rest } = hint;
|
|
10
11
|
const detailField = narrowDetailField ?? _detail;
|
|
11
12
|
return { ...rest, ...(detailField !== undefined && { detailField }) };
|
|
12
13
|
}
|
|
@@ -16,7 +17,8 @@ function cardCell(m, row, col, { linksAllowed } = { linksAllowed: false }) {
|
|
|
16
17
|
// A bare check mark in the subtitle line says nothing without its column.
|
|
17
18
|
if (showsBareCheckMark(col.type, row.values[col.field], col.renderer))
|
|
18
19
|
return col.label;
|
|
19
|
-
|
|
20
|
+
const shortSentence = col.hint?.narrowField === undefined ? undefined : row.values[col.hint.narrowField];
|
|
21
|
+
return (_jsx(DataTableCell, { value: isEmptyCellValue(shortSentence) ? row.values[col.field] : shortSentence, row: row.values, field: col.field, type: col.type, renderer: col.renderer, translate: m.tableTranslate, locale: m.tableLocale, ...columnCellPresentationProps(col), ...(col.hint !== undefined && { hint: cardHint(col.hint) }), ...(col.fileDisplay !== undefined && { fileDisplay: col.fileDisplay, compactFile: true }), ...(onCellChange !== undefined && {
|
|
20
22
|
onChange: (value) => onCellChange(row.id, col.field, value),
|
|
21
23
|
}), ...(col.rowActionLink === true &&
|
|
22
24
|
col.display === undefined && { display: "button" }), ...cellLinkProp(col, row, linksAllowed || !opensRow) }));
|
|
@@ -53,22 +55,25 @@ export function splitLinkColumns(m, row, roles) {
|
|
|
53
55
|
export function renderCardLinks(m, row, linkColumns) {
|
|
54
56
|
return (_jsx("div", { "data-testid": `card-links-${row.id}`, className: "flex flex-wrap items-center gap-x-3 text-[13px] leading-5", children: linkColumns.map((col) => (_jsx("span", { "data-testid": cellTestIdOf(m, row, col.field), children: cardCell(m, row, col, { linksAllowed: true }) }, col.field))) }));
|
|
55
57
|
}
|
|
58
|
+
function renderMetaCell(m, row, col) {
|
|
59
|
+
return (_jsx("div", { "data-testid": cellTestIdOf(m, row, col.field), className: "min-w-0 truncate leading-5", onPointerEnter: showFullTextOnHover, children: isBadgeColumn(col) ? (_jsx("span", { className: "inline-flex align-middle", children: cardCell(m, row, col) })) : (cardCell(m, row, col)) }, col.field));
|
|
60
|
+
}
|
|
56
61
|
function renderCardMeta(m, row, metaColumns) {
|
|
57
|
-
return (_jsx("div", { className: "min-w-0", children: _jsx("div", { "data-testid": `card-meta-${row.id}`, className: "flex min-w-0 flex-col text-[13px] leading-5 tabular-nums text-foreground-secondary", children: metaColumns.map((
|
|
62
|
+
return (_jsx("div", { className: "min-w-0", children: _jsx("div", { "data-testid": `card-meta-${row.id}`, className: "flex min-w-0 flex-col text-[13px] leading-5 tabular-nums text-foreground-secondary", children: cardMetaLines(metaColumns).map((line) => line[0]?.narrowInline === true ? (_jsx("div", { "data-testid": `card-vals-${row.id}-${line[0].field}`, className: "mt-1 flex h-5 min-w-0 max-w-full items-center gap-3 text-[12.5px]", children: line.map((col) => renderMetaCell(m, row, col)) }, line.map((col) => col.field).join("|"))) : (_jsx("div", { className: "flex h-5 min-w-0 max-w-full items-center", children: line.map((col) => renderMetaCell(m, row, col)) }, line.map((col) => col.field).join("|")))) }) }));
|
|
58
63
|
}
|
|
59
64
|
function renderCardLead(m, row, lead) {
|
|
60
65
|
if (lead === undefined || isEmptyCellValue(row.values[lead.field]))
|
|
61
66
|
return null;
|
|
62
|
-
return (_jsx("div", { "data-testid": cellTestIdOf(m, row, lead.field), className: "min-w-0 text-
|
|
67
|
+
return (_jsx("div", { "data-testid": cellTestIdOf(m, row, lead.field), className: "min-w-0 text-xs font-medium leading-5", children: cardCell(m, row, lead) }));
|
|
63
68
|
}
|
|
64
69
|
function renderCardHeading(m, row, roles) {
|
|
65
70
|
const { title: cardTitleColumn, status: cardStatusColumn } = roles;
|
|
66
71
|
const showStatus = cardStatusColumn !== undefined && !isEmptyCellValue(row.values[cardStatusColumn.field]);
|
|
67
|
-
return (_jsxs("div", { className: "flex min-w-0 items-start justify-between gap-2", children: [cardTitleColumn !== undefined && (_jsx("span", { "data-testid": cellTestIdOf(m, row, cardTitleColumn.field), className: "min-w-0 truncate text-
|
|
72
|
+
return (_jsxs("div", { className: "flex min-w-0 items-start justify-between gap-2", children: [cardTitleColumn !== undefined && (_jsx("span", { "data-testid": cellTestIdOf(m, row, cardTitleColumn.field), className: "min-w-0 truncate text-[14.5px] font-semibold text-foreground", onPointerEnter: showFullTextOnHover, children: cardCell(m, row, cardTitleColumn) })), showStatus && (_jsx("span", { "data-testid": cellTestIdOf(m, row, cardStatusColumn.field), className: "shrink-0", children: cardCell(m, row, cardStatusColumn) }))] }));
|
|
68
73
|
}
|
|
69
74
|
export function renderCardBody(m, row, roles) {
|
|
70
75
|
const { image: cardImageColumn, meta: cardMetaColumns } = roles;
|
|
71
76
|
const metaColumns = cardMetaColumns.filter((col) => !isEmptyCellValue(row.values[col.field]) &&
|
|
72
77
|
!isUnlabeledFalse(col.type, row.values[col.field], col.renderer));
|
|
73
|
-
return (_jsxs(_Fragment, { children: [cardImageColumn?.fileDisplay !== undefined && (_jsx("div", { "data-testid": `card-image-${row.id}`, className: "shrink-0", children: _jsx(CardLeadingImage, { value: row.values[cardImageColumn.field], display: cardImageColumn.fileDisplay }) })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [renderCardLead(m, row, roles.lead), renderCardHeading(m, row, roles), metaColumns.length > 0 && renderCardMeta(m, row, metaColumns)] }), m.rowOpener(row) !== undefined && (_jsx(ChevronRight, { className: "size-4 shrink-0 text-
|
|
78
|
+
return (_jsxs(_Fragment, { children: [cardImageColumn?.fileDisplay !== undefined && (_jsx("div", { "data-testid": `card-image-${row.id}`, className: "shrink-0", children: _jsx(CardLeadingImage, { value: row.values[cardImageColumn.field], display: cardImageColumn.fileDisplay }) })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [renderCardLead(m, row, roles.lead), renderCardHeading(m, row, roles), metaColumns.length > 0 && renderCardMeta(m, row, metaColumns)] }), m.rowOpener(row) !== undefined && (_jsx(ChevronRight, { className: "size-4 shrink-0 text-border-strong", "aria-hidden": "true" }))] }));
|
|
74
79
|
}
|
|
@@ -25,37 +25,41 @@ function renderCardOpenButton(openRow, body) {
|
|
|
25
25
|
function renderCardButtons(m, row, buttonActions) {
|
|
26
26
|
return renderStopPropagation("flex justify-start", `row-${row.id}-card-buttons`, _jsx(RowActionsCell, { row: row, actions: buttonActions, mode: m.rowActionMode, compact: true, small: true }));
|
|
27
27
|
}
|
|
28
|
-
function cardLeftPadding(compact
|
|
29
|
-
|
|
30
|
-
return toned ? "pl-[5px]" : "pl-2";
|
|
31
|
-
return toned ? "pl-[13px]" : "pl-4";
|
|
28
|
+
function cardLeftPadding(compact) {
|
|
29
|
+
return compact ? "pl-2" : "pl-4";
|
|
32
30
|
}
|
|
33
31
|
function cardRowBaseClass(m) {
|
|
34
32
|
return hasSeparateCardRows(m)
|
|
35
33
|
? `flex min-h-[72px] items-center gap-2 py-3 ${CARD_SURFACE_CLASS}`
|
|
36
34
|
: "flex min-h-[72px] items-center gap-2 border-b border-border-row py-3";
|
|
37
35
|
}
|
|
36
|
+
function splitCardActions(m, row, opensRow) {
|
|
37
|
+
const menuMode = m.rowActionMode === "menu";
|
|
38
|
+
// "menu" mode keeps every action in the table's kebab; a phone card opens the row instead,
|
|
39
|
+
// unless the row cannot be opened, then the actions would be unreachable.
|
|
40
|
+
const cardActions = menuMode && opensRow ? [] : (m.menuActions ?? []);
|
|
41
|
+
return {
|
|
42
|
+
buttonActions: cardActions.filter((a) => !menuMode &&
|
|
43
|
+
(a.display === "button" || a.display === "link") &&
|
|
44
|
+
(a.isVisible === undefined || a.isVisible(row))),
|
|
45
|
+
menuActions: cardActions.filter((a) => menuMode || (a.display !== "button" && a.display !== "link")),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
38
48
|
export function renderCard(m, row, roles) {
|
|
39
49
|
const { rowTone } = m;
|
|
40
|
-
const allActions = m.menuActions ?? [];
|
|
41
50
|
const openRow = m.rowOpener(row);
|
|
42
|
-
|
|
43
|
-
// unless the row cannot be opened, then the actions would be unreachable.
|
|
44
|
-
const cardActions = m.rowActionMode === "menu" && openRow !== undefined ? [] : allActions;
|
|
45
|
-
const menuMode = m.rowActionMode === "menu";
|
|
46
|
-
const buttonActions = cardActions.filter((a) => !menuMode &&
|
|
47
|
-
(a.display === "button" || a.display === "link") &&
|
|
48
|
-
(a.isVisible === undefined || a.isVisible(row)));
|
|
49
|
-
const menuActions = cardActions.filter((a) => menuMode || (a.display !== "button" && a.display !== "link"));
|
|
51
|
+
const { buttonActions, menuActions } = splitCardActions(m, row, openRow !== undefined);
|
|
50
52
|
const hasMenu = menuActions.length > 0;
|
|
51
53
|
const hasButtons = buttonActions.length > 0;
|
|
52
54
|
const { bodyRoles, linkColumns } = splitLinkColumns(m, row, roles);
|
|
53
55
|
const body = renderCardBody(m, row, bodyRoles);
|
|
54
56
|
const main = openRow !== undefined ? renderCardOpenButton(openRow, body) : body;
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
// In a list with row tones every card carries a stripe (neutral = grey) so the cards align.
|
|
58
|
+
const toneClass = cardToneClass(rowTone === undefined ? undefined : (rowTone(row) ?? "neutral"));
|
|
59
|
+
const toned = toneClass !== "";
|
|
60
|
+
const rowItem = (_jsxs("li", { "data-testid": m.rowTestId(row), "data-tone": rowTone?.(row), className: cn(cardRowBaseClass(m), toneClass,
|
|
61
|
+
// A toned card already pads past its inner 4px stripe (see cardToneClass); a later pl-* would override it.
|
|
62
|
+
!toned && cardLeftPadding(m.expansion !== undefined || m.selection.active), hasMenu ? "pr-2" : "pr-4", m.density.card), ...(openRow !== undefined && { onClick: openRow }), children: [m.selection.cardCheckbox(row), renderExpandToggle(m, row), linkColumns.length > 0 || hasButtons ? (_jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [main, linkColumns.length > 0 && renderCardLinks(m, row, linkColumns), hasButtons && renderCardButtons(m, row, buttonActions)] })) : (main), hasMenu && renderCardMenu(m, row, menuActions)] }, row.id));
|
|
59
63
|
if (m.expansion === undefined)
|
|
60
64
|
return rowItem;
|
|
61
65
|
// The expansion is a sibling <li>, outside the row's click target, so
|
|
@@ -2,9 +2,7 @@ import type { SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { ListColumnHintViewModel } from "../../../headless/index.ts";
|
|
4
4
|
export declare const HINT_TONE_TEXT_CLASS: Readonly<Record<SelectOptionTone, string>>;
|
|
5
|
-
|
|
6
|
-
export declare function isDimmedHintSentence(tone: SelectOptionTone | undefined, plainSentence: boolean | undefined): boolean;
|
|
7
|
-
export declare const DIMMED_HINT_SENTENCE_CLASS = "font-normal text-muted-foreground";
|
|
5
|
+
export declare function hintSentenceClass(tone: SelectOptionTone | undefined, plainSentence: boolean | undefined, weight?: "font-medium" | "font-semibold"): string;
|
|
8
6
|
/** "To do" cell: an emphasized sentence in the row tone with an optional muted second line. */
|
|
9
7
|
export declare function HintCell({ value, row, hint, onOpen, leading, }: {
|
|
10
8
|
readonly value: unknown;
|
|
@@ -13,10 +13,10 @@ export const HINT_TONE_TEXT_CLASS = {
|
|
|
13
13
|
neutral: "",
|
|
14
14
|
};
|
|
15
15
|
/** Tone `neutral` dims the sentence like an empty label (muted, not bold); `plainSentence` opts out. */
|
|
16
|
-
|
|
16
|
+
function isDimmedHintSentence(tone, plainSentence) {
|
|
17
17
|
return tone === "neutral" && plainSentence !== true;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
const DIMMED_HINT_SENTENCE_CLASS = "font-normal text-muted-foreground";
|
|
20
20
|
const OPEN_SENTENCE_CLASS = "min-w-0 cursor-pointer bg-transparent p-0 text-left font-medium hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring";
|
|
21
21
|
function SentenceText({ text, className, onOpen, }) {
|
|
22
22
|
if (onOpen === undefined)
|
|
@@ -24,12 +24,6 @@ function SentenceText({ text, className, onOpen, }) {
|
|
|
24
24
|
return (_jsx("button", { type: "button", className: cn(OPEN_SENTENCE_CLASS, className), onClick: (event) => {
|
|
25
25
|
event.stopPropagation();
|
|
26
26
|
onOpen();
|
|
27
|
-
}, onKeyDown: (event) => {
|
|
28
|
-
if (event.key !== "Enter")
|
|
29
|
-
return;
|
|
30
|
-
event.preventDefault();
|
|
31
|
-
event.stopPropagation();
|
|
32
|
-
onOpen();
|
|
33
27
|
}, children: text }));
|
|
34
28
|
}
|
|
35
29
|
// Without a sentence the empty label is the only element of the first cell, so it must stay
|
|
@@ -55,10 +49,10 @@ function useHintReason(hint, row) {
|
|
|
55
49
|
boxId: rowReason?.boxId ?? ownBoxId,
|
|
56
50
|
};
|
|
57
51
|
}
|
|
58
|
-
function hintSentenceClass(tone, plainSentence) {
|
|
52
|
+
export function hintSentenceClass(tone, plainSentence, weight = "font-medium") {
|
|
59
53
|
if (isDimmedHintSentence(tone, plainSentence))
|
|
60
54
|
return DIMMED_HINT_SENTENCE_CLASS;
|
|
61
|
-
return cn(
|
|
55
|
+
return cn(weight, plainSentence !== true && tone !== undefined && HINT_TONE_TEXT_CLASS[tone]);
|
|
62
56
|
}
|
|
63
57
|
/** "To do" cell: an emphasized sentence in the row tone with an optional muted second line. */
|
|
64
58
|
export function HintCell({ value, row, hint, onOpen, leading, }) {
|
|
@@ -5,4 +5,4 @@ import type { DataTableModel } from "./use-data-table-state.ts";
|
|
|
5
5
|
export declare function renderExpandToggle(m: DataTableModel, row: ListRowViewModel): ReactNode;
|
|
6
6
|
export declare function renderExpansion(m: DataTableModel, row: ListRowViewModel, as: "row" | "item", colSpan: number): ReactNode;
|
|
7
7
|
export declare function renderBand(m: DataTableModel, item: DataTableBandItem): ReactNode;
|
|
8
|
-
export declare function renderEmptyBlock(m: DataTableModel): ReactNode;
|
|
8
|
+
export declare function renderEmptyBlock(m: DataTableModel, embedded?: boolean): ReactNode;
|
|
@@ -29,7 +29,8 @@ export function renderExpansion(m, row, as, colSpan) {
|
|
|
29
29
|
export function renderBand(m, item) {
|
|
30
30
|
return _jsx(GroupBand, { item: item, columnOf: m.columnOf });
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
// `embedded`: the block sits inside the framed table's body, which already draws the border.
|
|
33
|
+
export function renderEmptyBlock(m, embedded = false) {
|
|
33
34
|
const { testId, chromeless, fillsHeight, emptyState, tableTranslate } = m;
|
|
34
|
-
return (_jsx("div", { "data-testid": testId !== undefined ? `${testId}-empty` : "render-list-empty", className: cn("flex flex-col items-center justify-center
|
|
35
|
+
return (_jsx("div", { "data-testid": testId !== undefined ? `${testId}-empty` : "render-list-empty", className: cn("flex flex-col items-center justify-center gap-3 px-6 py-10 text-[13px] text-muted-foreground", !embedded && chromeless !== true && !fillsHeight && "rounded-md border border-border-row"), children: emptyState ?? _jsx("span", { children: tableTranslate?.("kumiko.list.no-entries") ?? "No entries." }) }));
|
|
35
36
|
}
|