@cosmicdrift/kumiko-renderer 0.406.0 → 0.410.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.
Files changed (143) hide show
  1. package/dist/app/action-form-body.js +23 -8
  2. package/dist/app/action-form-support.d.ts +7 -0
  3. package/dist/app/action-form-support.js +14 -1
  4. package/dist/app/config-edit-action-row.d.ts +7 -0
  5. package/dist/app/config-edit-action-row.js +45 -0
  6. package/dist/app/config-edit-body.js +32 -4
  7. package/dist/app/entity-list-screen.js +8 -11
  8. package/dist/app/nav.js +2 -1
  9. package/dist/app/projection-detail-body.js +3 -1
  10. package/dist/app/projection-detail-header.d.ts +1 -0
  11. package/dist/app/projection-detail-header.js +1 -1
  12. package/dist/app/projection-detail-navigation.d.ts +2 -1
  13. package/dist/app/projection-detail-navigation.js +6 -3
  14. package/dist/app/projection-detail-shim.js +3 -1
  15. package/dist/app/projection-list-render-props.d.ts +1 -1
  16. package/dist/app/projection-list-render-props.js +4 -2
  17. package/dist/app/projection-list-render.js +1 -1
  18. package/dist/app/screen-access.js +4 -2
  19. package/dist/app/screen-shared.d.ts +3 -2
  20. package/dist/app/screen-shared.js +30 -2
  21. package/dist/app/use-embedded-screen.d.ts +2 -0
  22. package/dist/app/use-embedded-screen.js +7 -1
  23. package/dist/components/edit-mounts.d.ts +3 -1
  24. package/dist/components/edit-mounts.js +3 -3
  25. package/dist/components/related-list-section.d.ts +3 -1
  26. package/dist/components/related-list-section.js +2 -2
  27. package/dist/components/render-edit-field-grid.d.ts +2 -2
  28. package/dist/components/render-edit-field-grid.js +12 -4
  29. package/dist/components/render-edit-fields-section.js +6 -7
  30. package/dist/components/render-edit-helpers.d.ts +4 -0
  31. package/dist/components/render-edit-helpers.js +5 -0
  32. package/dist/components/render-edit-section-kinds.js +6 -4
  33. package/dist/components/render-edit-submit.js +18 -1
  34. package/dist/components/render-edit-titles.js +6 -6
  35. package/dist/components/render-edit-types.d.ts +6 -0
  36. package/dist/components/render-field-control.d.ts +2 -0
  37. package/dist/components/render-field-control.js +23 -1
  38. package/dist/components/render-field-write-only.d.ts +1 -1
  39. package/dist/components/render-field-write-only.js +12 -2
  40. package/dist/components/render-field.js +2 -1
  41. package/dist/components/use-render-edit-sections.js +4 -4
  42. package/dist/format-when.d.ts +1 -1
  43. package/dist/format-when.js +2 -2
  44. package/dist/headless/format/escape.js +3 -2
  45. package/dist/headless/view-model/edit.js +0 -2
  46. package/dist/headless/view-model/types.d.ts +0 -3
  47. package/dist/i18n-defaults.js +38 -0
  48. package/dist/index.d.ts +2 -1
  49. package/dist/index.js +1 -0
  50. package/dist/primitives.d.ts +30 -7
  51. package/dist/primitives.js +1 -51
  52. package/dist/status-tone.d.ts +6 -0
  53. package/dist/status-tone.js +51 -0
  54. package/dist/toggle-set-member.d.ts +1 -0
  55. package/dist/toggle-set-member.js +8 -0
  56. package/dist/web/app/dashboard-header.js +5 -1
  57. package/dist/web/app/dashboard-screen-tiles.js +19 -3
  58. package/dist/web/icons.d.ts +2 -0
  59. package/dist/web/icons.js +3 -1
  60. package/dist/web/index.d.ts +3 -2
  61. package/dist/web/index.js +2 -1
  62. package/dist/web/layout/default-app-shell.d.ts +4 -1
  63. package/dist/web/layout/default-app-shell.js +5 -2
  64. package/dist/web/layout/focus-aware-sidebar.d.ts +27 -0
  65. package/dist/web/layout/focus-aware-sidebar.js +23 -0
  66. package/dist/web/layout/focus-rail.d.ts +16 -0
  67. package/dist/web/layout/focus-rail.js +61 -0
  68. package/dist/web/layout/nav-tree.d.ts +2 -1
  69. package/dist/web/layout/nav-tree.js +3 -9
  70. package/dist/web/layout/shell-focus.d.ts +19 -0
  71. package/dist/web/layout/shell-focus.js +35 -0
  72. package/dist/web/layout/shell-header.d.ts +1 -1
  73. package/dist/web/layout/shell-header.js +12 -9
  74. package/dist/web/layout/sidebar-brand.js +1 -1
  75. package/dist/web/layout/workspace-shell.d.ts +4 -1
  76. package/dist/web/layout/workspace-shell.js +5 -2
  77. package/dist/web/primitives/banner.js +3 -1
  78. package/dist/web/primitives/data-table/toolbar.js +2 -2
  79. package/dist/web/primitives/default-form.js +12 -5
  80. package/dist/web/primitives/field.js +4 -1
  81. package/dist/web/primitives/input-text-kinds.js +8 -2
  82. package/dist/web/primitives/layout-elements.js +2 -4
  83. package/dist/web/primitives/tabs.d.ts +1 -1
  84. package/dist/web/primitives/tabs.js +21 -4
  85. package/dist/web/theme-plugin.d.ts +1 -1
  86. package/dist/web/theme-plugin.js +7 -0
  87. package/dist/web/ui/sidebar.js +5 -2
  88. package/dist/web/widgets/ai-text-end-action.d.ts +12 -0
  89. package/dist/web/widgets/ai-text-end-action.js +15 -0
  90. package/dist/web/widgets/ai-text-field.d.ts +3 -0
  91. package/dist/web/widgets/ai-text-field.js +4 -3
  92. package/dist/web/widgets/attachment-card.d.ts +6 -0
  93. package/dist/web/widgets/attachment-card.js +11 -0
  94. package/dist/web/widgets/attachment-chip.d.ts +8 -0
  95. package/dist/web/widgets/attachment-chip.js +21 -0
  96. package/dist/web/widgets/clamped-text.d.ts +11 -0
  97. package/dist/web/widgets/clamped-text.js +38 -0
  98. package/dist/web/widgets/html-mail-frame.d.ts +17 -0
  99. package/dist/web/widgets/html-mail-frame.js +56 -0
  100. package/dist/web/widgets/index.d.ts +10 -1
  101. package/dist/web/widgets/index.js +9 -1
  102. package/dist/web/widgets/infinity-list.d.ts +3 -1
  103. package/dist/web/widgets/infinity-list.js +2 -2
  104. package/dist/web/widgets/message-body-view.d.ts +10 -0
  105. package/dist/web/widgets/message-body-view.js +36 -0
  106. package/dist/web/widgets/message-reader.d.ts +4 -0
  107. package/dist/web/widgets/message-reader.js +31 -0
  108. package/dist/web/widgets/message-thread.d.ts +5 -0
  109. package/dist/web/widgets/message-thread.js +66 -0
  110. package/dist/web/widgets/message-types.d.ts +68 -0
  111. package/dist/web/widgets/message-types.js +1 -0
  112. package/dist/web/widgets/mobile-top-bar.d.ts +21 -0
  113. package/dist/web/widgets/mobile-top-bar.js +8 -0
  114. package/dist/web/widgets/pdf-document.d.ts +19 -0
  115. package/dist/web/widgets/pdf-document.js +70 -0
  116. package/dist/web/widgets/pdf-page.d.ts +35 -0
  117. package/dist/web/widgets/pdf-page.js +155 -0
  118. package/dist/web/widgets/pdf-preview.d.ts +27 -7
  119. package/dist/web/widgets/pdf-preview.js +21 -133
  120. package/dist/web/widgets/pdf-search.d.ts +43 -0
  121. package/dist/web/widgets/pdf-search.js +178 -0
  122. package/dist/web/widgets/pdf-thumbnails.d.ts +10 -0
  123. package/dist/web/widgets/pdf-thumbnails.js +35 -0
  124. package/dist/web/widgets/pdf-viewer-toolbar.d.ts +22 -0
  125. package/dist/web/widgets/pdf-viewer-toolbar.js +35 -0
  126. package/dist/web/widgets/pdf-viewer.d.ts +21 -0
  127. package/dist/web/widgets/pdf-viewer.js +176 -0
  128. package/dist/web/widgets/quoted-text.d.ts +16 -0
  129. package/dist/web/widgets/quoted-text.js +76 -0
  130. package/dist/web/widgets/status-badge.js +3 -1
  131. package/dist/web/widgets/step-list-fit.d.ts +25 -0
  132. package/dist/web/widgets/step-list-fit.js +79 -0
  133. package/dist/web/widgets/step-list-row.d.ts +50 -0
  134. package/dist/web/widgets/step-list-row.js +97 -0
  135. package/dist/web/widgets/step-list.d.ts +33 -0
  136. package/dist/web/widgets/step-list.js +36 -0
  137. package/dist/web/widgets/surfaces.d.ts +23 -0
  138. package/dist/web/widgets/surfaces.js +15 -0
  139. package/dist/web/widgets/use-in-view.d.ts +5 -0
  140. package/dist/web/widgets/use-in-view.js +18 -0
  141. package/package.json +5 -5
  142. package/src/changes.json +192 -0
  143. package/src/web/styles.css +22 -0
@@ -18,57 +18,7 @@ export const NARROW_LABEL_PROP = "kumikoNarrowLabel";
18
18
  export function shouldRenderActionsIconOnly(actions) {
19
19
  return actions.length > 2 && actions.every((a) => a.icon !== undefined);
20
20
  }
21
- // Status value -> StatusTone heuristic, shared by every surface that shows a
22
- // raw status value without a tone of its own (projectionDetail header badge,
23
- // list cells). Covers the common status vocabularies; unknown values stay
24
- // undefined so the caller keeps its own neutral default.
25
- const STATUS_TONE_BY_VALUE = {
26
- ok: "ok",
27
- active: "ok",
28
- done: "ok",
29
- complete: "ok",
30
- completed: "ok",
31
- paid: "ok",
32
- approved: "ok",
33
- published: "ok",
34
- success: "ok",
35
- pending: "warn",
36
- processing: "warn",
37
- review: "warn",
38
- "in-review": "warn",
39
- waiting: "warn",
40
- open: "warn",
41
- draft: "warn",
42
- failed: "bad",
43
- error: "bad",
44
- overdue: "bad",
45
- rejected: "bad",
46
- blocked: "bad",
47
- critical: "bad",
48
- };
49
- const STATUS_TONE_BY_OPTION_TONE = {
50
- ok: "ok",
51
- warn: "warn",
52
- bad: "bad",
53
- critical: "critical",
54
- accent: "accent",
55
- neutral: "muted",
56
- };
57
- // Own-key check: an unknown tone from an untyped definition must yield undefined so callers fall back to the value heuristic.
58
- export function statusToneForOptionTone(tone) {
59
- return Object.hasOwn(STATUS_TONE_BY_OPTION_TONE, tone)
60
- ? STATUS_TONE_BY_OPTION_TONE[tone]
61
- : undefined;
62
- }
63
- export function statusToneForValue(value) {
64
- const slug = value
65
- .trim()
66
- .toLowerCase()
67
- .replace(/[\s_]+/g, "-");
68
- // Own-key check: the value comes from row data, and a plain object lookup
69
- // would hand back `Object.prototype.constructor` & friends as a "tone".
70
- return Object.hasOwn(STATUS_TONE_BY_VALUE, slug) ? STATUS_TONE_BY_VALUE[slug] : undefined;
71
- }
21
+ export { statusToneForOptionTone, statusToneForValue, } from "./status-tone.js";
72
22
  // ---- Context + Provider + Hook ----
73
23
  const PrimitivesContext = createContext(undefined);
74
24
  export function PrimitivesProvider({ children, value }) {
@@ -0,0 +1,6 @@
1
+ import type { SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
2
+ export type StatusTone = "ok" | "warn" | "bad" | "critical" | "muted";
3
+ /** Tones a select option can request: the status tones plus the brand `accent`. */
4
+ export type StatusBadgeOptionTone = StatusTone | "accent";
5
+ export declare function statusToneForOptionTone(tone: SelectOptionTone): StatusBadgeOptionTone | undefined;
6
+ export declare function statusToneForValue(value: string): StatusTone | undefined;
@@ -0,0 +1,51 @@
1
+ // Status value -> StatusTone heuristic, shared by every surface that shows a
2
+ // raw status value without a tone of its own (projectionDetail header badge,
3
+ // list cells). Covers the common status vocabularies; unknown values stay
4
+ // undefined so the caller keeps its own neutral default.
5
+ const STATUS_TONE_BY_VALUE = {
6
+ ok: "ok",
7
+ active: "ok",
8
+ done: "ok",
9
+ complete: "ok",
10
+ completed: "ok",
11
+ paid: "ok",
12
+ approved: "ok",
13
+ published: "ok",
14
+ success: "ok",
15
+ pending: "warn",
16
+ processing: "warn",
17
+ review: "warn",
18
+ "in-review": "warn",
19
+ waiting: "warn",
20
+ open: "warn",
21
+ draft: "warn",
22
+ failed: "bad",
23
+ error: "bad",
24
+ overdue: "bad",
25
+ rejected: "bad",
26
+ blocked: "bad",
27
+ critical: "bad",
28
+ };
29
+ const STATUS_TONE_BY_OPTION_TONE = {
30
+ ok: "ok",
31
+ warn: "warn",
32
+ bad: "bad",
33
+ critical: "critical",
34
+ accent: "accent",
35
+ neutral: "muted",
36
+ };
37
+ // Own-key check: an unknown tone from an untyped definition must yield undefined so callers fall back to the value heuristic.
38
+ export function statusToneForOptionTone(tone) {
39
+ return Object.hasOwn(STATUS_TONE_BY_OPTION_TONE, tone)
40
+ ? STATUS_TONE_BY_OPTION_TONE[tone]
41
+ : undefined;
42
+ }
43
+ export function statusToneForValue(value) {
44
+ const slug = value
45
+ .trim()
46
+ .toLowerCase()
47
+ .replace(/[\s_]+/g, "-");
48
+ // Own-key check: the value comes from row data, and a plain object lookup
49
+ // would hand back `Object.prototype.constructor` & friends as a "tone".
50
+ return Object.hasOwn(STATUS_TONE_BY_VALUE, slug) ? STATUS_TONE_BY_VALUE[slug] : undefined;
51
+ }
@@ -0,0 +1 @@
1
+ export declare function toggleSetMember<T>(set: ReadonlySet<T>, value: T): Set<T>;
@@ -0,0 +1,8 @@
1
+ export function toggleSetMember(set, value) {
2
+ const next = new Set(set);
3
+ if (next.has(value))
4
+ next.delete(value);
5
+ else
6
+ next.add(value);
7
+ return next;
8
+ }
@@ -38,7 +38,7 @@ export function renderPageHeaderSlot(model, headerActionsBar, badgeInHeader) {
38
38
  export function renderTitleRow(model, headerActionsBar, badgeInHeader) {
39
39
  const { Heading } = model.primitives;
40
40
  const { screen, usesPageHeaderSlot, recordTitle, scopeBadge, picker, rangeControl } = model;
41
- return (_jsxs("div", { className: "flex flex-wrap items-end justify-between gap-3", children: [_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [!usesPageHeaderSlot && recordTitle !== undefined && (_jsx(Heading, { variant: "page", testId: `dashboard-${screen.id}-record-title`, children: recordTitle })), !badgeInHeader && scopeBadge, picker] }), _jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [!usesPageHeaderSlot && headerActionsBar, screen.showUpdatedAt !== false && (_jsx("span", { "data-testid": `dashboard-${screen.id}-updated-at`, className: "text-xs tabular-nums text-muted-foreground", children: model.t("kumiko.dashboard.updated-at", {
41
+ return (_jsxs("div", { className: "flex flex-wrap items-end justify-between gap-3", children: [_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [!usesPageHeaderSlot && recordTitle !== undefined && (_jsx(Heading, { variant: "page", testId: `dashboard-${screen.id}-record-title`, children: recordTitle })), !badgeInHeader && scopeBadge, picker] }), _jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [!usesPageHeaderSlot && headerActionsBar, screen.showUpdatedAt !== false && hasDataPanel(screen.panels) && (_jsx("span", { "data-testid": `dashboard-${screen.id}-updated-at`, className: "text-xs tabular-nums text-muted-foreground", children: model.t("kumiko.dashboard.updated-at", {
42
42
  time: model.formatDateTime(model.loadedAtMs),
43
43
  }) })), rangeControl] })] }));
44
44
  }
@@ -51,6 +51,10 @@ export function renderRecordError(model, error, recordRow, refetchRecord) {
51
51
  return (error !== null &&
52
52
  recordRow === null && (_jsxs("div", { role: "alert", "data-testid": `dashboard-${model.screen.id}-record-error`, className: "flex flex-col items-start gap-2 text-sm", children: [_jsx("span", { className: "text-status-bad", children: dispatcherErrorText(error, model.t) }), _jsx(Button, { variant: "secondary", onClick: () => void refetchRecord(), children: model.t("kumiko.dashboard.panel.error.retry") })] })));
53
53
  }
54
+ // A dashboard that only embeds screens loads no data of its own, so "Stand" would say nothing.
55
+ function hasDataPanel(panels) {
56
+ return panels.some((panel) => panel.kind !== "screen" && panel.kind !== "text" && panel.kind !== "custom");
57
+ }
54
58
  export function renderDescriptionAndNotice(model, description) {
55
59
  const { Text, Banner } = model.primitives;
56
60
  const { screen } = model;
@@ -1,17 +1,33 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
3
  import { EmbeddedScreenProvider, evalVisibleWhen, KumikoScreen, useEmbeddedScreen, } from "../../index.js";
4
+ import { screenTitleKey } from "../layout/shell-breadcrumb.js";
4
5
  import { cn } from "../lib/cn.js";
5
6
  import { EmbeddedFormProvider } from "../primitives/index.js";
6
7
  import { SectionCard } from "../widgets/section-card.js";
7
8
  import { PanelError, WIDE_PANEL } from "./dashboard-shared.js";
8
9
  import { NO_GATE_PAYLOAD, VisibilityQueryContext, visibilityGate, } from "./dashboard-visibility.js";
10
+ // A raw description is agent-facing prose; only an i18n key is user-facing copy.
11
+ function embeddedDescription(raw, translate) {
12
+ if (raw === undefined)
13
+ return undefined;
14
+ const translated = translate(raw);
15
+ return translated !== raw ? translated : undefined;
16
+ }
9
17
  function EmbeddedScreenPanelTile({ recordId, panel, target, translate, }) {
10
18
  // Only a record screen takes the dashboard's bound record; other screens have no id to read.
11
19
  const entityId = target.screenType === "projectionDetail" ? recordId : undefined;
12
20
  const screenBody = (_jsx(KumikoScreen, { schema: target.schema, qn: target.qn, translate: translate, ...(entityId !== undefined && { entityId }) }));
13
- const embedded = panel.chromeless === true ? (_jsx(EmbeddedFormProvider, { children: _jsx(EmbeddedScreenProvider, { children: screenBody }) })) : (screenBody);
14
- return (_jsx("div", { className: cn("min-w-0", WIDE_PANEL), "data-testid": `dashboard-panel-${panel.id}`, children: panel.label !== undefined && panel.chromeless !== true ? (_jsx(SectionCard, { title: translate(panel.label), children: embedded })) : (_jsxs(_Fragment, { children: [panel.label !== undefined && (_jsx("h3", { className: "mb-3 text-sm font-semibold text-foreground", children: translate(panel.label) })), embedded] })) }));
21
+ const label = panel.label !== undefined ? translate(panel.label) : undefined;
22
+ if (panel.chromeless !== true) {
23
+ return (_jsx("div", { className: cn("min-w-0", WIDE_PANEL), "data-testid": `dashboard-panel-${panel.id}`, children: label !== undefined ? _jsx(SectionCard, { title: label, children: screenBody }) : screenBody }));
24
+ }
25
+ // The tile owns the section head, so the embedded form drops its own title block.
26
+ const titleKey = screenTitleKey(target.screenId);
27
+ const translatedTitle = translate(titleKey);
28
+ const title = label ?? (translatedTitle === titleKey ? target.screenId : translatedTitle);
29
+ const description = embeddedDescription(target.description, translate);
30
+ return (_jsxs("div", { className: cn("min-w-0 border-t border-border pt-6 first:border-t-0 first:pt-0", WIDE_PANEL), "data-testid": `dashboard-panel-${panel.id}`, children: [_jsx("h3", { "data-testid": `dashboard-panel-${panel.id}-title`, className: "text-sm font-semibold text-foreground", children: title }), description !== undefined && (_jsx("p", { "data-testid": `dashboard-panel-${panel.id}-description`, className: "mt-1 text-sm text-muted-foreground", children: description })), _jsx("div", { className: "mt-3", children: _jsx(EmbeddedFormProvider, { children: _jsx(EmbeddedScreenProvider, { children: screenBody }) }) })] }));
15
31
  }
16
32
  // Own component so the target lookup (a hook) only runs for panels that actually fall back.
17
33
  function FallbackScreenPanelTile({ panel, fallback, featureName, recordId, translate, }) {
@@ -12,8 +12,10 @@ export declare const NAV_ICONS: {
12
12
  readonly table: import("lucide-react").LucideIcon;
13
13
  readonly layers: import("lucide-react").LucideIcon;
14
14
  readonly building: import("lucide-react").LucideIcon;
15
+ readonly warehouse: import("lucide-react").LucideIcon;
15
16
  readonly calculator: import("lucide-react").LucideIcon;
16
17
  readonly wallet: import("lucide-react").LucideIcon;
18
+ readonly euro: import("lucide-react").LucideIcon;
17
19
  readonly coins: import("lucide-react").LucideIcon;
18
20
  readonly "credit-card": import("lucide-react").LucideIcon;
19
21
  readonly "piggy-bank": import("lucide-react").LucideIcon;
package/dist/web/icons.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { AlertTriangle, Archive, ArrowLeft, ArrowRight, BarChart3, Bell, BookOpen, Building, Calculator, CalendarDays, Camera, Check, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, CircleStop, ClipboardList, Clock, Coins, Copy, CreditCard, Download, ExternalLink, Eye, EyeOff, FileText, Filter, Flag, Folder, FolderOpen, Gauge, Hash, Headphones, Home, ImageIcon, Info, KeyRound, Languages, Layers, LayoutDashboard, LayoutGrid, LineChart, Link, List, Loader2, Lock, Mail, MapPin, Mic, MoreHorizontal, MoreVertical, Package, Palette, Pencil, Phone, PiggyBank, Plus, Printer, Receipt, RefreshCw, Rocket, Save, Search, Send, Server, Settings, Share2, Shield, ShieldCheck, Sparkles, Star, Table, Tag, Trash2, TrendingUp, Undo2, Upload, User, Users, Wallet, Wand2, X, XCircle, } from "lucide-react";
2
+ import { AlertTriangle, Archive, ArrowLeft, ArrowRight, BarChart3, Bell, BookOpen, Building, Calculator, CalendarDays, Camera, Check, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, CircleStop, ClipboardList, Clock, Coins, Copy, CreditCard, Download, Euro, ExternalLink, Eye, EyeOff, FileText, Filter, Flag, Folder, FolderOpen, Gauge, Hash, Headphones, Home, ImageIcon, Info, KeyRound, Languages, Layers, LayoutDashboard, LayoutGrid, LineChart, Link, List, Loader2, Lock, Mail, MapPin, Mic, MoreHorizontal, MoreVertical, Package, Palette, Pencil, Phone, PiggyBank, Plus, Printer, Receipt, RefreshCw, Rocket, Save, Search, Send, Server, Settings, Share2, Shield, ShieldCheck, Sparkles, Star, Table, Tag, Trash2, TrendingUp, Undo2, Upload, User, Users, Wallet, Wand2, Warehouse, X, XCircle, } from "lucide-react";
3
3
  import { cn } from "./lib/cn.js";
4
4
  export const NAV_ICONS = {
5
5
  dashboard: LayoutDashboard,
@@ -12,8 +12,10 @@ export const NAV_ICONS = {
12
12
  table: Table,
13
13
  layers: Layers,
14
14
  building: Building,
15
+ warehouse: Warehouse,
15
16
  calculator: Calculator,
16
17
  wallet: Wallet,
18
+ euro: Euro,
17
19
  coins: Coins,
18
20
  "credit-card": CreditCard,
19
21
  "piggy-bank": PiggyBank,
@@ -35,6 +35,7 @@ export type { NavTreeProps } from "./layout/nav-tree.tsx";
35
35
  export { buildNavRegistrySlice, buildNavRegistrySliceForApp, NavTree } from "./layout/nav-tree.tsx";
36
36
  export type { ProfileMenuItem, ProfileMenuProps } from "./layout/profile-menu.tsx";
37
37
  export { ProfileMenu } from "./layout/profile-menu.tsx";
38
+ export { useShellFocusMode } from "./layout/shell-focus.tsx";
38
39
  export type { SidebarProps } from "./layout/sidebar.tsx";
39
40
  export { Sidebar } from "./layout/sidebar.tsx";
40
41
  export type { SidebarBrandProps } from "./layout/sidebar-brand.tsx";
@@ -75,5 +76,5 @@ export { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "./ui/resiz
75
76
  export { SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider } from "./ui/sidebar.tsx";
76
77
  export type { KumikoBuild } from "./version/update-checker.tsx";
77
78
  export { readLoadedBuild } from "./version/update-checker.tsx";
78
- export type { AiTextAreaProps, AiTextFieldProps, BooleanFieldProps, ComparisonMetric, DateFieldProps, DrawerProps, FeedRow, FileFieldProps, FloatingPanelGeometry, FloatingPanelProps, InfinityListProps, InfinityListSelection, ModeSwitchVariant, NumberFieldProps, PdfPreviewSource, PhotoSlotSpec, PhotoSlotsProps, PlanCardActionSlot, PlanCardLinkSlot, PlanCardPrice, PlanCardProps, PlanGridProps, ProgressListRow, PublicShellProps, PublicShellVariant, QueryTableColumn, QueryTableProps, RangeFieldProps, ResultColumn, SelectFieldProps, SideBySideTableCell, SideBySideTableColumn, SideBySideTableRow, StatDelta, StatTone, StatusBadgeTone, StatusBarEntry, StatusTone, TextareaFieldProps, TextFieldProps, TimeseriesHeight, TimeseriesPoint, TimeseriesReferenceLine, TimeseriesXAxis, TimeseriesYAxis, UploadZoneProps, } from "./widgets/index.ts";
79
- export { AiTextArea, AiTextField, BooleanField, ChoiceCards, CollapsibleSection, ComparisonTable, DateField, DetailList, Drawer, EmptyState, ErrorState, FeedList, FileField, FloatingPanel, InfinityList, LoadingState, MiniStat, ModeSwitch, MoneyField, NumberField, PdfPreview, PercentField, PhotoSlots, PlanCard, PlanGrid, ProgressBar, ProgressList, PublicShell, QueryTable, RangeField, ResultPanel, ResultTable, SectionCard, SelectField, SideBySideTable, Sparkline, STATUS_TONE_TEXT, StatCard, StatusBadge, StatusBarChart, StepBar, smoothPath, TextareaField, TextField, TimeseriesChart, UploadZone, useDraft, } from "./widgets/index.ts";
79
+ export type { AiTextAreaProps, AiTextEndAction, AiTextFieldProps, BooleanFieldProps, ComparisonMetric, DateFieldProps, DrawerProps, FeedRow, FileFieldProps, FloatingPanelGeometry, FloatingPanelProps, InfinityListProps, InfinityListSelection, MessageAttachment, MessageBody, MessageReaderProps, MessageReaderTab, MessageThreadProps, MobileTopBarProps, ModeSwitchVariant, NumberFieldProps, PdfMatchInfo, PdfPreviewProps, PdfPreviewSource, PhotoSlotSpec, PhotoSlotsProps, PlanCardActionSlot, PlanCardLinkSlot, PlanCardPrice, PlanCardProps, PlanGridProps, ProgressListRow, PublicShellProps, PublicShellVariant, QueryTableColumn, QueryTableProps, RangeFieldProps, ResultColumn, SelectFieldProps, SideBySideTableCell, SideBySideTableColumn, SideBySideTableRow, StatDelta, StatTone, StatusBadgeTone, StatusBarEntry, StatusTone, StepAction, StepListItem, StepListProps, StepSource, StepStatus, StepTag, TextareaFieldProps, TextFieldProps, ThreadMessage, TimeseriesHeight, TimeseriesPoint, TimeseriesReferenceLine, TimeseriesXAxis, TimeseriesYAxis, UploadZoneProps, } from "./widgets/index.ts";
80
+ export { AiSurface, AiTextArea, AiTextField, AttachmentCard, AttachmentChip, BooleanField, ChoiceCards, ClampedText, CollapsibleSection, ComparisonTable, DateField, DetailList, Drawer, EmptyState, ErrorState, FeedList, FileField, FloatingPanel, InfinityList, LoadingState, MessageReader, MessageThread, MiniStat, MobileTopBar, ModeSwitch, MoneyField, NumberField, PdfPreview, PercentField, PhotoSlots, PlanCard, PlanGrid, ProgressBar, ProgressList, PublicShell, QueryTable, RangeField, ResultPanel, ResultTable, SectionCard, SelectField, SenderFrame, SenderSheet, SideBySideTable, Sparkline, STATUS_TONE_TEXT, StatCard, StatusBadge, StatusBarChart, StepBar, StepList, smoothPath, TextareaField, TextField, TimeseriesChart, UploadZone, useDraft, } from "./widgets/index.ts";
package/dist/web/index.js CHANGED
@@ -23,6 +23,7 @@ export { LanguageMenuItems } from "./layout/language-menu-items.js";
23
23
  export { LanguageSwitcher } from "./layout/language-switcher.js";
24
24
  export { buildNavRegistrySlice, buildNavRegistrySliceForApp, NavTree } from "./layout/nav-tree.js";
25
25
  export { ProfileMenu } from "./layout/profile-menu.js";
26
+ export { useShellFocusMode } from "./layout/shell-focus.js";
26
27
  export { Sidebar } from "./layout/sidebar.js";
27
28
  export { SidebarBrand } from "./layout/sidebar-brand.js";
28
29
  export { SidebarPanel } from "./layout/sidebar-panel.js";
@@ -51,4 +52,4 @@ export { applyTokensToCssVars, defaultTokens, lightTokens, useBrowserTokensApi,
51
52
  export { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "./ui/resizable.js";
52
53
  export { SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider } from "./ui/sidebar.js";
53
54
  export { readLoadedBuild } from "./version/update-checker.js";
54
- export { AiTextArea, AiTextField, BooleanField, ChoiceCards, CollapsibleSection, ComparisonTable, DateField, DetailList, Drawer, EmptyState, ErrorState, FeedList, FileField, FloatingPanel, InfinityList, LoadingState, MiniStat, ModeSwitch, MoneyField, NumberField, PdfPreview, PercentField, PhotoSlots, PlanCard, PlanGrid, ProgressBar, ProgressList, PublicShell, QueryTable, RangeField, ResultPanel, ResultTable, SectionCard, SelectField, SideBySideTable, Sparkline, STATUS_TONE_TEXT, StatCard, StatusBadge, StatusBarChart, StepBar, smoothPath, TextareaField, TextField, TimeseriesChart, UploadZone, useDraft, } from "./widgets/index.js";
55
+ export { AiSurface, AiTextArea, AiTextField, AttachmentCard, AttachmentChip, BooleanField, ChoiceCards, ClampedText, CollapsibleSection, ComparisonTable, DateField, DetailList, Drawer, EmptyState, ErrorState, FeedList, FileField, FloatingPanel, InfinityList, LoadingState, MessageReader, MessageThread, MiniStat, MobileTopBar, ModeSwitch, MoneyField, NumberField, PdfPreview, PercentField, PhotoSlots, PlanCard, PlanGrid, ProgressBar, ProgressList, PublicShell, QueryTable, RangeField, ResultPanel, ResultTable, SectionCard, SelectField, SenderFrame, SenderSheet, SideBySideTable, Sparkline, STATUS_TONE_TEXT, StatCard, StatusBadge, StatusBarChart, StepBar, StepList, smoothPath, TextareaField, TextField, TimeseriesChart, UploadZone, useDraft, } from "./widgets/index.js";
@@ -30,6 +30,9 @@ export type DefaultAppShellProps = {
30
30
  /** Footer slot at the bottom of the sidebar — profile row, help link,
31
31
  * or plan banner. */
32
32
  readonly sidebarFooter?: ReactNode;
33
+ /** Top-level nav QNs the focus rail shows as tiles; the others sit behind a
34
+ * "More" tile that opens the full sidebar. Unset: every top-level entry. */
35
+ readonly focusRailNavQns?: readonly string[];
33
36
  /** Viewport-fit shell. true → fixed viewport height (`h-svh`); content
34
37
  * scrolls inside instead of the whole page. Defaults to true — `fill={false}`
35
38
  * switches back to page scrolling. */
@@ -37,4 +40,4 @@ export type DefaultAppShellProps = {
37
40
  /** Screen content rendered inside SidebarInset. */
38
41
  readonly children: ReactNode;
39
42
  };
40
- export declare function DefaultAppShell({ brand, schema, user, sidebarActions, headerActions, navBadges, sidebarFooter, fill, children, }: DefaultAppShellProps): ReactNode;
43
+ export declare function DefaultAppShell({ brand, schema, user, sidebarActions, headerActions, navBadges, sidebarFooter, focusRailNavQns, fill, children, }: DefaultAppShellProps): ReactNode;
@@ -2,15 +2,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { UserRolesProvider, useTranslation, } from "../../index.js";
3
3
  import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarHeader, SidebarInset, SidebarProvider, SidebarRail, } from "../ui/sidebar.js";
4
4
  import { fillClasses } from "./fill-classes.js";
5
+ import { FocusAwareSidebarBody, focusSidebarProviderProps } from "./focus-aware-sidebar.js";
5
6
  import { NavTree } from "./nav-tree.js";
6
7
  import { PageHeaderSlotProvider } from "./page-header-slot.js";
8
+ import { ShellFocusProvider, useShellFocusHost } from "./shell-focus.js";
7
9
  import { ShellHeader } from "./shell-header.js";
8
10
  import { SidebarPanelProvider, useSidebarPanelHost } from "./sidebar-panel.js";
9
- export function DefaultAppShell({ brand, schema, user, sidebarActions, headerActions, navBadges, sidebarFooter, fill = true, children, }) {
11
+ export function DefaultAppShell({ brand, schema, user, sidebarActions, headerActions, navBadges, sidebarFooter, focusRailNavQns, fill = true, children, }) {
10
12
  const fillCls = fillClasses(fill);
11
13
  const t = useTranslation();
12
14
  // Second column only when a screen fills it (sidebar-09 pattern) — otherwise
13
15
  // every other screen would carry an empty strip next to the navigation.
14
16
  const panel = useSidebarPanelHost();
15
- return (_jsx(SidebarProvider, { ...fillCls.provider, children: _jsxs(SidebarPanelProvider, { value: panel.value, children: [_jsxs(Sidebar, { collapsible: "icon", mobileTitle: t("kumiko.sidebar.title"), mobileDescription: t("kumiko.sidebar.description"), children: [_jsx(SidebarHeader, { "data-kumiko-layout": "sidebar-header", children: brand }), sidebarActions !== undefined && (_jsx(SidebarGroup, { "data-kumiko-layout": "sidebar-actions", className: "flex-row flex-wrap items-center gap-1 py-0", children: sidebarActions })), _jsx(SidebarContent, { "data-kumiko-layout": "sidebar-nav", children: _jsx(NavTree, { schema: schema, ...(user !== undefined && { user }), ...(navBadges !== undefined && { navBadges }) }) }), 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: schema, ...(user !== undefined && { user }), ...(headerActions !== undefined && { headerActions }) }), _jsx("main", { className: fillCls.main, children: _jsx(UserRolesProvider, { roles: user?.roles, children: children }) })] }) })] }) }));
17
+ const focus = useShellFocusHost();
18
+ return (_jsx(SidebarProvider, { ...fillCls.provider, ...focusSidebarProviderProps(focus), 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: schema, user: user, railNavQns: focusRailNavQns, footer: sidebarFooter, children: [_jsx(SidebarHeader, { "data-kumiko-layout": "sidebar-header", children: brand }), sidebarActions !== undefined && (_jsx(SidebarGroup, { "data-kumiko-layout": "sidebar-actions", className: "flex-row flex-wrap items-center gap-1 py-0", children: sidebarActions })), _jsx(SidebarContent, { "data-kumiko-layout": "sidebar-nav", children: _jsx(NavTree, { schema: schema, ...(user !== undefined && { user }), ...(navBadges !== undefined && { navBadges }) }) }), 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: schema, ...(user !== undefined && { user }), ...(headerActions !== undefined && { headerActions }) }), _jsx("main", { className: fillCls.main, children: _jsx(UserRolesProvider, { roles: user?.roles, children: children }) })] }) })] }) }) }));
16
19
  }
@@ -0,0 +1,27 @@
1
+ import type { CSSProperties, ReactNode } from "react";
2
+ import type { AppSchema, FeatureSchema } from "../../index.ts";
3
+ import type { ShellFocusHost } from "./shell-focus.tsx";
4
+ /** SidebarProvider props that hand the rail state to the focus host while a screen holds focus mode. */
5
+ export declare function focusSidebarProviderProps(focus: ShellFocusHost): {
6
+ open?: undefined;
7
+ onOpenChange?: undefined;
8
+ style?: undefined;
9
+ } | {
10
+ open: boolean;
11
+ onOpenChange: (open: boolean) => void;
12
+ style: CSSProperties;
13
+ };
14
+ /** Swaps the whole sidebar content for the focus rail while focused and collapsed on desktop. */
15
+ export declare function FocusAwareSidebarBody({ focused, brand, schema, user, allowedNavQns, railNavQns, footer, children, }: {
16
+ readonly focused: boolean;
17
+ readonly brand: ReactNode;
18
+ readonly schema: AppSchema | FeatureSchema;
19
+ readonly user: {
20
+ readonly id: string;
21
+ readonly roles: readonly string[];
22
+ } | undefined;
23
+ readonly allowedNavQns?: ReadonlySet<string> | undefined;
24
+ readonly railNavQns?: readonly string[] | undefined;
25
+ readonly footer?: ReactNode;
26
+ readonly children: ReactNode;
27
+ }): ReactNode;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useSidebar } from "../ui/sidebar.js";
3
+ import { FocusRail } from "./focus-rail.js";
4
+ // 3.5rem = the 56px rail of the focused screen; the default icon width stays 3rem.
5
+ const FOCUS_RAIL_WIDTH_STYLE = { "--sidebar-width-icon": "3.5rem" };
6
+ /** SidebarProvider props that hand the rail state to the focus host while a screen holds focus mode. */
7
+ export function focusSidebarProviderProps(focus) {
8
+ if (!focus.focused)
9
+ return {};
10
+ return {
11
+ open: focus.railOpen,
12
+ onOpenChange: focus.setRailOpen,
13
+ style: FOCUS_RAIL_WIDTH_STYLE,
14
+ };
15
+ }
16
+ /** Swaps the whole sidebar content for the focus rail while focused and collapsed on desktop. */
17
+ export function FocusAwareSidebarBody({ focused, brand, schema, user, allowedNavQns, railNavQns, footer, children, }) {
18
+ const { state, isMobile } = useSidebar();
19
+ if (focused && state === "collapsed" && !isMobile) {
20
+ return (_jsx(FocusRail, { brand: brand, schema: schema, ...(user !== undefined && { user }), ...(allowedNavQns !== undefined && { allowedNavQns }), ...(railNavQns !== undefined && { railNavQns }), ...(footer !== undefined && { footer }) }));
21
+ }
22
+ return children;
23
+ }
@@ -0,0 +1,16 @@
1
+ import { type ReactNode } from "react";
2
+ import type { AppSchema, FeatureSchema } from "../../index.ts";
3
+ export type FocusRailProps = {
4
+ readonly brand: ReactNode;
5
+ readonly schema: AppSchema | FeatureSchema;
6
+ readonly user?: {
7
+ readonly id: string;
8
+ readonly roles: readonly string[];
9
+ };
10
+ readonly allowedNavQns?: ReadonlySet<string>;
11
+ /** Top-level nav QNs that get a rail tile; the rest sit behind a "More" tile. Unset: all of them. */
12
+ readonly railNavQns?: readonly string[];
13
+ /** The sidebar footer (e.g. the sidebar UserMenu), pinned to the bottom of the rail. */
14
+ readonly footer?: ReactNode;
15
+ };
16
+ export declare function FocusRail({ brand, schema, user, allowedNavQns, railNavQns, footer, }: FocusRailProps): ReactNode;
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The collapsed rail of a focused screen: brand tile plus one icon per top-level nav node.
3
+ // Sections have no screen of their own, so their icon expands the sidebar instead of navigating.
4
+ import { MoreHorizontal } from "lucide-react";
5
+ import { useMemo } from "react";
6
+ import { resolveNavigation } from "../../headless/index.js";
7
+ import { lastSegment, toAppSchema, useNav, useTranslation } from "../../index.js";
8
+ import { KumikoLink } from "../app/nav.js";
9
+ import { NAV_ICONS } from "../icons.js";
10
+ import { useSidebar } from "../ui/sidebar.js";
11
+ import { buildNavRegistrySliceForApp, treeContainsScreen } from "./nav-tree.js";
12
+ import { resolveParentScreenId } from "./shell-breadcrumb.js";
13
+ import { useDispatchTarget } from "./target-resolver-stub.js";
14
+ const NAV_ICON_LOOKUP = NAV_ICONS;
15
+ const RAIL_TILE_CLASS = "flex size-10 shrink-0 items-center justify-center rounded-md border-0 bg-transparent p-0 text-sidebar-muted outline-hidden transition-colors hover:bg-sidebar-accent/60 hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground";
16
+ function RailGlyph({ node, label }) {
17
+ const Icon = node.icon !== undefined && Object.hasOwn(NAV_ICONS, node.icon)
18
+ ? NAV_ICON_LOOKUP[node.icon]
19
+ : undefined;
20
+ if (Icon !== undefined)
21
+ return _jsx(Icon, { "aria-hidden": "true", className: "size-[18px]" });
22
+ return (_jsx("span", { "aria-hidden": "true", className: "text-sm font-semibold", children: label.trim().charAt(0).toUpperCase() }));
23
+ }
24
+ function useActiveScreenId(tree, schema) {
25
+ const nav = useNav();
26
+ const routedScreenId = nav.route?.screenId;
27
+ return useMemo(() => {
28
+ if (routedScreenId === undefined)
29
+ return undefined;
30
+ if (treeContainsScreen(tree, routedScreenId))
31
+ return routedScreenId;
32
+ const screens = toAppSchema(schema).features.flatMap((feature) => feature.screens);
33
+ return resolveParentScreenId(screens, routedScreenId);
34
+ }, [tree, schema, routedScreenId]);
35
+ }
36
+ function RailTile({ node, active, }) {
37
+ const t = useTranslation();
38
+ const dispatchTarget = useDispatchTarget();
39
+ const { setOpen } = useSidebar();
40
+ const label = node.label.includes(".") ? t(node.label) : node.label;
41
+ const glyph = _jsx(RailGlyph, { node: node, label: label });
42
+ if (node.screen !== undefined) {
43
+ return (_jsx(KumikoLink, { to: { screenId: lastSegment(node.screen) }, title: label, "aria-label": label, "data-active": active, ...(active && { "aria-current": "page" }), className: RAIL_TILE_CLASS, children: glyph }));
44
+ }
45
+ const target = node.target;
46
+ return (_jsx("button", { type: "button", title: label, "aria-label": label, "data-active": active, className: RAIL_TILE_CLASS, onClick: () => (target !== undefined ? dispatchTarget(target) : setOpen(true)), children: glyph }));
47
+ }
48
+ export function FocusRail({ brand, schema, user, allowedNavQns, railNavQns, footer, }) {
49
+ const t = useTranslation();
50
+ const { setOpen } = useSidebar();
51
+ const tree = useMemo(() => {
52
+ const source = buildNavRegistrySliceForApp(toAppSchema(schema), allowedNavQns);
53
+ return resolveNavigation({ source, ...(user !== undefined && { user }) });
54
+ }, [schema, user, allowedNavQns]);
55
+ const activeScreenId = useActiveScreenId(tree, schema);
56
+ const isActive = (node) => activeScreenId !== undefined && treeContainsScreen([node], activeScreenId);
57
+ const shown = railNavQns === undefined ? tree : tree.filter((n) => railNavQns.includes(n.qualifiedName));
58
+ const hidden = tree.filter((node) => !shown.includes(node));
59
+ const moreLabel = t("kumiko.focusRail.more");
60
+ return (_jsxs("div", { "data-kumiko-layout": "focus-rail", "data-focus-rail": "", className: "group/focus-rail flex h-full flex-col items-center px-2 py-3", children: [brand, _jsx("nav", { className: "flex flex-col items-center gap-1", children: shown.map((node) => (_jsx(RailTile, { node: node, active: isActive(node) }, node.qualifiedName))) }), _jsxs("div", { className: "mt-auto flex w-full flex-col items-center gap-1", children: [hidden.length > 0 && (_jsx("button", { type: "button", title: moreLabel, "aria-label": moreLabel, "data-active": hidden.some(isActive), className: RAIL_TILE_CLASS, onClick: () => setOpen(true), children: _jsx(MoreHorizontal, { "aria-hidden": "true", className: "size-[18px]" }) })), footer !== undefined && (_jsx("div", { "data-kumiko-layout": "focus-rail-footer", className: "w-full", children: footer }))] })] }));
61
+ }
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode } from "react";
2
- import type { NavRegistrySlice } from "../../headless/index.ts";
2
+ import type { NavNode, NavRegistrySlice } from "../../headless/index.ts";
3
3
  import type { AppSchema, FeatureSchema } from "../../index.ts";
4
4
  import { lastSegment } from "../../index.ts";
5
5
  export type NavTreeProps = {
@@ -12,6 +12,7 @@ export type NavTreeProps = {
12
12
  readonly allowedNavQns?: ReadonlySet<string>;
13
13
  readonly navBadges?: ReadonlyMap<string, ReactNode>;
14
14
  };
15
+ export declare function treeContainsScreen(nodes: readonly NavNode[], screenId: string): boolean;
15
16
  export declare function NavTree({ schema, user, testId, allowedNavQns, navBadges, }: NavTreeProps): ReactNode;
16
17
  export declare function buildNavRegistrySlice(schema: FeatureSchema, allowedNavQns?: ReadonlySet<string>): NavRegistrySlice;
17
18
  export declare function buildNavRegistrySliceForApp(app: AppSchema, allowedNavQns?: ReadonlySet<string>): NavRegistrySlice;
@@ -5,6 +5,7 @@ import { rendererWarn } from "../../dev-console.js";
5
5
  import { resolveNavigation } from "../../headless/index.js";
6
6
  import { createLiveRefetchScheduler } from "../../hooks/live-refetch-scheduler.js";
7
7
  import { lastSegment, toAppSchema, useLiveEvents, useNav, useTranslation } from "../../index.js";
8
+ import { toggleSetMember } from "../../toggle-set-member.js";
8
9
  import { KumikoLink } from "../app/nav.js";
9
10
  import { useNavEntities, useNavProviders } from "../app/nav-providers-context.js";
10
11
  import { NAV_ICONS } from "../icons.js";
@@ -23,7 +24,7 @@ const NavFilterContext = createContext({ q: "", matches: () => true });
23
24
  const ActiveScreenMarkerContext = createContext(undefined);
24
25
  // Walks only the static `children` — provider-emitted nodes (treeNodeToNavNode
25
26
  // below) never set `screen`, so they can't hide a match this walk would miss.
26
- function treeContainsScreen(nodes, screenId) {
27
+ export function treeContainsScreen(nodes, screenId) {
27
28
  return nodes.some((n) => (n.screen !== undefined && lastSegment(n.screen) === screenId) ||
28
29
  treeContainsScreen(n.children, screenId));
29
30
  }
@@ -69,14 +70,7 @@ export function NavTree({ schema, user, testId, allowedNavQns, navBadges, }) {
69
70
  // without requiring the user to click first.
70
71
  const [collapsed, setCollapsed] = useState(() => new Set());
71
72
  const onToggle = useCallback((qn) => {
72
- setCollapsed((prev) => {
73
- const next = new Set(prev);
74
- if (next.has(qn))
75
- next.delete(qn);
76
- else
77
- next.add(qn);
78
- return next;
79
- });
73
+ setCollapsed((prev) => toggleSetMember(prev, qn));
80
74
  }, []);
81
75
  const t = useTranslation();
82
76
  const { state: sidebarState } = useSidebar();
@@ -0,0 +1,19 @@
1
+ type ShellFocusContextValue = {
2
+ readonly focused: boolean;
3
+ readonly register: () => () => void;
4
+ };
5
+ export declare const ShellFocusProvider: import("react").Provider<ShellFocusContextValue | null>;
6
+ export type ShellFocusHost = {
7
+ readonly focused: boolean;
8
+ /** Rail expansion while focused; kept apart from the user's own sidebar state so leaving restores it. */
9
+ readonly railOpen: boolean;
10
+ readonly setRailOpen: (open: boolean) => void;
11
+ readonly value: ShellFocusContextValue;
12
+ };
13
+ /** Shell side: holds the focus counter and the temporary rail state. */
14
+ export declare function useShellFocusHost(): ShellFocusHost;
15
+ /** True while any mounted screen holds focus mode (always false outside DefaultAppShell). */
16
+ export declare function useShellFocused(): boolean;
17
+ /** Screen side: call while the screen is mounted to get the focused shell. No-op without a DefaultAppShell. */
18
+ export declare function useShellFocusMode(): void;
19
+ export {};
@@ -0,0 +1,35 @@
1
+ // Per-screen focused shell: while a screen holds focus mode, DefaultAppShell shows the
2
+ // collapsed icon rail and ShellHeader reduces itself to the screen's own PageHeader content.
3
+ //
4
+ // Why register/unregister instead of a prop: the shell sits above every screen and cannot
5
+ // know which one wants the focused chrome; the screen opts in by mounting the hook.
6
+ import { createContext, useCallback, useContext, useLayoutEffect, useMemo, useState } from "react";
7
+ const ShellFocusContext = createContext(null);
8
+ export const ShellFocusProvider = ShellFocusContext.Provider;
9
+ /** Shell side: holds the focus counter and the temporary rail state. */
10
+ export function useShellFocusHost() {
11
+ const [holders, setHolders] = useState(0);
12
+ const [railOpen, setRailOpen] = useState(false);
13
+ const register = useCallback(() => {
14
+ setRailOpen(false);
15
+ setHolders((count) => count + 1);
16
+ return () => setHolders((count) => count - 1);
17
+ }, []);
18
+ const focused = holders > 0;
19
+ const value = useMemo(() => ({ focused, register }), [focused, register]);
20
+ return { focused, railOpen, setRailOpen, value };
21
+ }
22
+ /** True while any mounted screen holds focus mode (always false outside DefaultAppShell). */
23
+ export function useShellFocused() {
24
+ return useContext(ShellFocusContext)?.focused ?? false;
25
+ }
26
+ /** Screen side: call while the screen is mounted to get the focused shell. No-op without a DefaultAppShell. */
27
+ export function useShellFocusMode() {
28
+ const register = useContext(ShellFocusContext)?.register;
29
+ // Layout effect so the first paint already shows the rail instead of flashing the full sidebar.
30
+ useLayoutEffect(() => {
31
+ if (register === undefined)
32
+ return;
33
+ return register();
34
+ }, [register]);
35
+ }
@@ -4,7 +4,7 @@ type ShellHeaderUser = {
4
4
  readonly id: string;
5
5
  readonly roles: readonly string[];
6
6
  };
7
- export declare function ShellHeader({ schema, user, headerActions, allowedNavQns, }: {
7
+ export declare function ShellHeader({ schema, user, headerActions: appHeaderActions, allowedNavQns, }: {
8
8
  readonly schema: AppSchema | FeatureSchema;
9
9
  readonly user?: ShellHeaderUser;
10
10
  readonly headerActions?: ReactNode;
@@ -21,10 +21,13 @@ import { buildNavRegistrySliceForApp } from "./nav-tree.js";
21
21
  import { NotificationBell } from "./notification-bell.js";
22
22
  import { usePageHeaderSlot } from "./page-header-slot.js";
23
23
  import { activeNavLabel, resolveDetailBreadcrumb, screenTitleKey, } from "./shell-breadcrumb.js";
24
+ import { useShellFocused } from "./shell-focus.js";
24
25
  import { SHELL_HEADER_CONTROLS_CLASSES } from "./uniform-bar-controls.js";
25
- export function ShellHeader({ schema, user, headerActions, allowedNavQns, }) {
26
+ export function ShellHeader({ schema, user, headerActions: appHeaderActions, allowedNavQns, }) {
26
27
  const nav = useNav();
27
28
  const t = useTranslation();
29
+ const focused = useShellFocused();
30
+ const headerActions = focused ? undefined : appHeaderActions;
28
31
  const appSchema = toAppSchema(schema);
29
32
  const tree = useMemo(() => {
30
33
  const source = buildNavRegistrySliceForApp(appSchema);
@@ -74,14 +77,14 @@ export function ShellHeader({ schema, user, headerActions, allowedNavQns, }) {
74
77
  : crumbs !== undefined && recordTitle !== undefined && crumbs.length > 0
75
78
  ? [...crumbs.slice(0, -1), { label: recordTitle }, ...crumbs.slice(-1)]
76
79
  : crumbs;
77
- 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"), children: [_jsxs("div", { className: "@container flex min-w-0 flex-1 items-center gap-3", children: [_jsx(SidebarTrigger, { label: t("kumiko.sidebar.toggle") }), shownCrumbs !== undefined && shownCrumbs.length > 0 && (_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: shownCrumbs.map((crumb, index) => {
78
- const screenId = crumb.screenId;
79
- const isLast = index === shownCrumbs.length - 1;
80
- 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 ? (_jsx(BreadcrumbLink, { href: "#", className: "whitespace-nowrap text-foreground-secondary", onClick: (e) => {
81
- e.preventDefault();
82
- nav.navigate({ screenId });
83
- }, 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));
84
- }) }) })), _jsx("div", { ref: setStatusElement, "data-kumiko-layout": "page-header-status", className: cn("flex items-center gap-2 empty:hidden", compact ? "min-w-0 overflow-hidden" : "shrink-0") })] }), _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: setActionsElement, "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") }), user !== undefined && hasInAppChannel && _jsx(NotificationBell, { screens: allScreens }), !compact && headerActions !== undefined && (_jsx("div", { "data-kumiko-layout": "header-actions", className: "flex items-center gap-2", children: headerActions })), hasOverflow && _jsx(HeaderOverflow, { items: overflowItems, headerActions: headerActions })] })] }));
80
+ 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: [!focused && _jsx(SidebarTrigger, { label: t("kumiko.sidebar.toggle") }), _jsxs("div", { className: cn("flex min-w-0", compact ? "flex-col justify-center" : "items-center gap-3"), children: [shownCrumbs !== undefined && shownCrumbs.length > 0 && (_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: shownCrumbs.map((crumb, index) => {
81
+ const screenId = crumb.screenId;
82
+ const isLast = index === shownCrumbs.length - 1;
83
+ 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 ? (_jsx(BreadcrumbLink, { href: "#", className: "whitespace-nowrap text-foreground-secondary", onClick: (e) => {
84
+ e.preventDefault();
85
+ nav.navigate({ screenId });
86
+ }, 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));
87
+ }) }) })), _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") })] })] }), _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: setActionsElement, "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") }), !focused && user !== undefined && hasInAppChannel && (_jsx(NotificationBell, { screens: allScreens })), !compact && headerActions !== undefined && (_jsx("div", { "data-kumiko-layout": "header-actions", className: "flex items-center gap-2", children: headerActions })), hasOverflow && _jsx(HeaderOverflow, { items: overflowItems, headerActions: headerActions })] })] }));
85
88
  }
86
89
  // A hand-rolled menu instead of Radix DropdownMenu: app headerActions are opaque
87
90
  // nodes with their own popovers, and the panel stays mounted while closed so their