@burojs/ui-shadcn 0.8.0 → 0.10.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 (126) hide show
  1. package/dist/{bulk-summary-2HLgz7Il.cjs → bulk-summary-Chc61Pyw.cjs} +9 -7
  2. package/dist/bulk-summary-Chc61Pyw.cjs.map +1 -0
  3. package/dist/{bulk-summary-D6A0ua21.js → bulk-summary-DpSQD2Fq.js} +9 -7
  4. package/dist/bulk-summary-DpSQD2Fq.js.map +1 -0
  5. package/dist/{candidates-relation-picker-CGXItMN0.js → candidates-relation-picker-DRsHKe6N.js} +3 -3
  6. package/dist/{candidates-relation-picker-CGXItMN0.js.map → candidates-relation-picker-DRsHKe6N.js.map} +1 -1
  7. package/dist/{candidates-relation-picker-C47mF260.cjs → candidates-relation-picker-GIxsp7D_.cjs} +3 -3
  8. package/dist/{candidates-relation-picker-C47mF260.cjs.map → candidates-relation-picker-GIxsp7D_.cjs.map} +1 -1
  9. package/dist/{check-confirm-dialog-BT04Mieo.cjs → check-confirm-dialog-BMSb7wFv.cjs} +76 -9
  10. package/dist/check-confirm-dialog-BMSb7wFv.cjs.map +1 -0
  11. package/dist/{check-confirm-dialog-CtiRzOAt.js → check-confirm-dialog-B_u3YVHS.js} +72 -11
  12. package/dist/{check-confirm-dialog-CtiRzOAt.js.map → check-confirm-dialog-B_u3YVHS.js.map} +1 -1
  13. package/dist/{filter-builder-z3Axzf9Y.js → filter-builder-DX-xC3Yd.js} +14 -6
  14. package/dist/filter-builder-DX-xC3Yd.js.map +1 -0
  15. package/dist/{filter-builder-ByGhxLf_.cjs → filter-builder-Dt5E8PSX.cjs} +14 -6
  16. package/dist/filter-builder-Dt5E8PSX.cjs.map +1 -0
  17. package/dist/{flow-runtime-BVFjMU5-.cjs → flow-runtime-CQ4wf8co.cjs} +3 -3
  18. package/dist/{flow-runtime-BVFjMU5-.cjs.map → flow-runtime-CQ4wf8co.cjs.map} +1 -1
  19. package/dist/{flow-runtime-DrUWyTS0.js → flow-runtime-Q2vD7R3c.js} +3 -3
  20. package/dist/{flow-runtime-DrUWyTS0.js.map → flow-runtime-Q2vD7R3c.js.map} +1 -1
  21. package/dist/{flow-screen-3fk6J33y.js → flow-screen-B1y2yizP.js} +68 -29
  22. package/dist/flow-screen-B1y2yizP.js.map +1 -0
  23. package/dist/{flow-screen-6y5E_HT6.cjs → flow-screen-sw2cP70t.cjs} +67 -28
  24. package/dist/flow-screen-sw2cP70t.cjs.map +1 -0
  25. package/dist/index.cjs +2304 -247
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +119 -12
  28. package/dist/index.d.ts +119 -12
  29. package/dist/index.js +2225 -172
  30. package/dist/index.js.map +1 -1
  31. package/dist/{inline-flow-host-C4KmZIYE.cjs → inline-flow-host-CkhoA69R.cjs} +3 -3
  32. package/dist/{inline-flow-host-C4KmZIYE.cjs.map → inline-flow-host-CkhoA69R.cjs.map} +1 -1
  33. package/dist/{inline-flow-host-YnnvWjdU.js → inline-flow-host-DqbXqcPS.js} +3 -3
  34. package/dist/{inline-flow-host-YnnvWjdU.js.map → inline-flow-host-DqbXqcPS.js.map} +1 -1
  35. package/dist/{lazy-relation-picker-dialog-DN4bvQfg.js → lazy-relation-picker-dialog-BaIEWLbF.js} +3 -52
  36. package/dist/lazy-relation-picker-dialog-BaIEWLbF.js.map +1 -0
  37. package/dist/{lazy-relation-picker-dialog-BAKBRn3V.cjs → lazy-relation-picker-dialog-CeRzOAi0.cjs} +3 -52
  38. package/dist/lazy-relation-picker-dialog-CeRzOAi0.cjs.map +1 -0
  39. package/dist/{page-flow-route-CtEfqAvU.js → page-flow-route-CP7cS7FY.js} +7 -7
  40. package/dist/page-flow-route-CP7cS7FY.js.map +1 -0
  41. package/dist/{page-flow-route-DEjAxHe3.cjs → page-flow-route-UDx8qvdM.cjs} +10 -10
  42. package/dist/page-flow-route-UDx8qvdM.cjs.map +1 -0
  43. package/dist/{place-node-Bhl8B3fF.cjs → place-node-C5ZmuHaN.cjs} +208 -55
  44. package/dist/place-node-C5ZmuHaN.cjs.map +1 -0
  45. package/dist/{place-node-BdxT-30h.js → place-node-DwWAigv0.js} +205 -58
  46. package/dist/place-node-DwWAigv0.js.map +1 -0
  47. package/dist/record-trail-store-Cjo9vtod.cjs +126 -0
  48. package/dist/record-trail-store-Cjo9vtod.cjs.map +1 -0
  49. package/dist/record-trail-store-Dn6bVry4.js +91 -0
  50. package/dist/record-trail-store-Dn6bVry4.js.map +1 -0
  51. package/dist/{related-list-cards-Bc_vfCE_.cjs → related-list-cards-BypKfm9t.cjs} +3 -3
  52. package/dist/{related-list-cards-Bc_vfCE_.cjs.map → related-list-cards-BypKfm9t.cjs.map} +1 -1
  53. package/dist/{related-list-cards-BvkD5OcC.js → related-list-cards-Dcmruy09.js} +3 -3
  54. package/dist/{related-list-cards-BvkD5OcC.js.map → related-list-cards-Dcmruy09.js.map} +1 -1
  55. package/dist/{related-list-timeline-k0DtnxTs.cjs → related-list-timeline-D-KClgKb.cjs} +4 -4
  56. package/dist/related-list-timeline-D-KClgKb.cjs.map +1 -0
  57. package/dist/{related-list-timeline-DCrwN9oO.js → related-list-timeline-DZON_qSc.js} +4 -4
  58. package/dist/related-list-timeline-DZON_qSc.js.map +1 -0
  59. package/dist/{related-rows-BW9Jr07T.cjs → related-rows-DgF05ssi.cjs} +4 -4
  60. package/dist/{related-rows-BW9Jr07T.cjs.map → related-rows-DgF05ssi.cjs.map} +1 -1
  61. package/dist/{related-rows-CPE-9FFr.js → related-rows-ETZl5CB9.js} +4 -4
  62. package/dist/{related-rows-CPE-9FFr.js.map → related-rows-ETZl5CB9.js.map} +1 -1
  63. package/dist/{relation-create-DDEYcKfw.cjs → relation-create-B8zngAcA.cjs} +82 -13
  64. package/dist/relation-create-B8zngAcA.cjs.map +1 -0
  65. package/dist/{relation-create-C43cdPQt.js → relation-create-CeCWyxIb.js} +79 -16
  66. package/dist/relation-create-CeCWyxIb.js.map +1 -0
  67. package/dist/{relation-many-picker-BlrGRwMV.js → relation-many-picker-CT7nKfE2.js} +12 -10
  68. package/dist/relation-many-picker-CT7nKfE2.js.map +1 -0
  69. package/dist/{relation-many-picker-Br-zBHxT.cjs → relation-many-picker-Cq0EHY5I.cjs} +12 -10
  70. package/dist/relation-many-picker-Cq0EHY5I.cjs.map +1 -0
  71. package/dist/{relation-picker-x7P5HKie.js → relation-picker-CCyuMeGq.js} +13 -10
  72. package/dist/relation-picker-CCyuMeGq.js.map +1 -0
  73. package/dist/{relation-picker-ADjxI_TI.cjs → relation-picker-DmwTzgsd.cjs} +13 -10
  74. package/dist/relation-picker-DmwTzgsd.cjs.map +1 -0
  75. package/dist/{relation-picker-dialog-CyKliBkN.js → relation-picker-dialog-CoWKjNv8.js} +5 -5
  76. package/dist/relation-picker-dialog-CoWKjNv8.js.map +1 -0
  77. package/dist/{relation-picker-dialog-DimVQF9Y.cjs → relation-picker-dialog-mbwyNK43.cjs} +5 -5
  78. package/dist/relation-picker-dialog-mbwyNK43.cjs.map +1 -0
  79. package/dist/{relation-select-Cr3CfNLy.cjs → relation-select-CguIo2M5.cjs} +2 -2
  80. package/dist/{relation-select-Cr3CfNLy.cjs.map → relation-select-CguIo2M5.cjs.map} +1 -1
  81. package/dist/{relation-select-B8Fq4o-t.js → relation-select-nAYxhopN.js} +2 -2
  82. package/dist/{relation-select-B8Fq4o-t.js.map → relation-select-nAYxhopN.js.map} +1 -1
  83. package/dist/{success-notices-Dl3M1fZP.cjs → success-notices-Cl4b6MLQ.cjs} +3 -2
  84. package/dist/success-notices-Cl4b6MLQ.cjs.map +1 -0
  85. package/dist/{success-notices-LDEgEkc4.js → success-notices-CrcWOGSo.js} +3 -2
  86. package/dist/success-notices-CrcWOGSo.js.map +1 -0
  87. package/dist/{use-dialog-filter-state-tNvqAAjh.cjs → use-dialog-filter-state-CpWblz3C.cjs} +2 -2
  88. package/dist/{use-dialog-filter-state-tNvqAAjh.cjs.map → use-dialog-filter-state-CpWblz3C.cjs.map} +1 -1
  89. package/dist/{use-dialog-filter-state-B_MqzHaT.js → use-dialog-filter-state-ZYxOp5WO.js} +2 -2
  90. package/dist/{use-dialog-filter-state-B_MqzHaT.js.map → use-dialog-filter-state-ZYxOp5WO.js.map} +1 -1
  91. package/dist/{use-record-subtitle-bfwIoUme.cjs → use-record-subtitle-B4lTR7pf.cjs} +5 -8
  92. package/dist/use-record-subtitle-B4lTR7pf.cjs.map +1 -0
  93. package/dist/{use-record-subtitle-gIaCGgbI.js → use-record-subtitle-pWMBqQx9.js} +5 -8
  94. package/dist/use-record-subtitle-pWMBqQx9.js.map +1 -0
  95. package/package.json +9 -9
  96. package/dist/bulk-summary-2HLgz7Il.cjs.map +0 -1
  97. package/dist/bulk-summary-D6A0ua21.js.map +0 -1
  98. package/dist/check-confirm-dialog-BT04Mieo.cjs.map +0 -1
  99. package/dist/filter-builder-ByGhxLf_.cjs.map +0 -1
  100. package/dist/filter-builder-z3Axzf9Y.js.map +0 -1
  101. package/dist/flow-screen-3fk6J33y.js.map +0 -1
  102. package/dist/flow-screen-6y5E_HT6.cjs.map +0 -1
  103. package/dist/lazy-relation-picker-dialog-BAKBRn3V.cjs.map +0 -1
  104. package/dist/lazy-relation-picker-dialog-DN4bvQfg.js.map +0 -1
  105. package/dist/page-flow-route-CtEfqAvU.js.map +0 -1
  106. package/dist/page-flow-route-DEjAxHe3.cjs.map +0 -1
  107. package/dist/place-node-BdxT-30h.js.map +0 -1
  108. package/dist/place-node-Bhl8B3fF.cjs.map +0 -1
  109. package/dist/related-list-timeline-DCrwN9oO.js.map +0 -1
  110. package/dist/related-list-timeline-k0DtnxTs.cjs.map +0 -1
  111. package/dist/relation-create-C43cdPQt.js.map +0 -1
  112. package/dist/relation-create-DDEYcKfw.cjs.map +0 -1
  113. package/dist/relation-many-picker-BlrGRwMV.js.map +0 -1
  114. package/dist/relation-many-picker-Br-zBHxT.cjs.map +0 -1
  115. package/dist/relation-picker-ADjxI_TI.cjs.map +0 -1
  116. package/dist/relation-picker-dialog-CyKliBkN.js.map +0 -1
  117. package/dist/relation-picker-dialog-DimVQF9Y.cjs.map +0 -1
  118. package/dist/relation-picker-x7P5HKie.js.map +0 -1
  119. package/dist/resource-page-router-BRpUnhay.js +0 -1958
  120. package/dist/resource-page-router-BRpUnhay.js.map +0 -1
  121. package/dist/resource-page-router-qEd2xb55.cjs +0 -2167
  122. package/dist/resource-page-router-qEd2xb55.cjs.map +0 -1
  123. package/dist/success-notices-Dl3M1fZP.cjs.map +0 -1
  124. package/dist/success-notices-LDEgEkc4.js.map +0 -1
  125. package/dist/use-record-subtitle-bfwIoUme.cjs.map +0 -1
  126. package/dist/use-record-subtitle-gIaCGgbI.js.map +0 -1
@@ -1,1958 +0,0 @@
1
- import { l as cn } from "./use-theme-dnE3Od3I.js";
2
- import { l as useLinkComponent } from "./toaster-Ct_YHGs6.js";
3
- import { D as loadPageFlowRoute, k as useLoaded, o as canonicalResourceName, t as CheckConfirmDialog, v as FlowBoundary, w as loadFailedText } from "./check-confirm-dialog-CtiRzOAt.js";
4
- import { t as Button } from "./button-MWVeZaqj.js";
5
- import { b as RecordState, m as useRowTitle, v as InvalidRouteId, y as LoadError } from "./relation-create-C43cdPQt.js";
6
- import { t as Skeleton } from "./skeleton-U2noefj5.js";
7
- import { Ct as useShownItemActions, G as RouteScreenClaimContext, H as ScreenTree, J as FormControlProvider, K as RouteScreenContext, Mt as FieldDisplay, S as useFrameChrome, U as useTabsUrlState, W as QuickScreenClaimContext, X as useFormControlOf, d as resolveFrameView, g as UndeclaredTypeNotice, gt as PageHeader, h as TypeChromeDrawnContext, i as RouteListContext, kt as DeepLinkScope, m as HeaderTypeNotice, n as viewOf, p as ChangeTypeButton, q as useIsRouteScreen, t as selectImplementation, u as isBuiltinRecordView, v as FormActions, x as FrameChromeContext } from "./place-node-BdxT-30h.js";
8
- import { t as useNoticeSink } from "./success-notices-LDEgEkc4.js";
9
- import { FORM_SLOT, addressesCapability, builtinFrames, canonicalEntityNodeKey, compilePageScreen, declaredText, dtoFields, evaluateVisible, fieldSensitivity, formatEntityRef, hasListPage, hrefFor, humanizeKey, isCustomPageDef, isScreenFailure, issueOfInput, matchPath, navHrefFor, normalizeEntityRef, normalizeIssueInputs, pageParamNames, parsePageParams, resolveNavLabel, resolveResourceLabel, resourceKey, routeResourceKey, routeServerIssues, scopeColumnOf, snapshotAppFrames, snapshotBlockLookup, snapshotFrameLookup, successNoticesOf } from "@burojs/core";
10
- import { ActionRouteContext, ComponentsContext, FrameCheckContext, ORIGIN_DEPTH, RecordFrameContext, RecordScopeProvider, ResourceContext, RouteSourceContext, ScreenStateProvider, maybeThen, pageAccessFor, policyRecordOf, recordKeyOf, recordRouteAvailable, resolveRoute, retryRecordRead, settle, useApp, useApplicationSnapshot, useAvailabilityResolver, useChromeT, useComponent, useCtx, useCurrentUserId, useFieldAccess, useFormController, useFrameImplementations, useFrameT, useI18nCaps, useList, useNavigationGuardText, useOne, useOptionalDataRuntime, useOptionalRouterAdapter, useOptionalT, usePageAccess, usePageScreen, usePermissions, usePlatformStorage, useProjectedRecord, usePublishDocVariant, useQuickEntry, useRecordFrame, useRecordTitle, useReturnTarget, useRouteListImplementation, useRouteNavigate, useRouteRecordId, useScope, useT, useTestIds, useTranslate, useVisibilityCtx } from "@burojs/react";
11
- import { Suspense, createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
12
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
- //#region src/resource-key.ts
14
- function canonicalNavKey(node) {
15
- return canonicalEntityNodeKey(node);
16
- }
17
- function canonicalResourceKey$1(def) {
18
- return canonicalNavKey(def);
19
- }
20
- //#endregion
21
- //#region src/layout/layouts/secondary-sidebar-layout.tsx
22
- function Row({ it }) {
23
- const RouterLink = useLinkComponent();
24
- return jsx("li", { children: jsxs(RouterLink, {
25
- href: it.href,
26
- "data-testid": `nav-secondary-item:${it.name}`,
27
- "aria-current": it.active ? "page" : void 0,
28
- className: cn("flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium outline-hidden ring-offset-background transition-colors", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", it.active ? "bg-secondary text-secondary-foreground" : "text-muted-foreground hover:bg-secondary/50 hover:text-foreground"),
29
- children: [it.icon != null && jsx("span", {
30
- className: "inline-flex h-4 w-4 shrink-0 items-center justify-center",
31
- "aria-hidden": "true",
32
- children: it.icon
33
- }), jsx("span", {
34
- className: "truncate",
35
- title: it.label,
36
- children: it.label
37
- })]
38
- }) });
39
- }
40
- function SecondarySidebarLayout({ group, groupKey, items, children }) {
41
- const RouterLink = useLinkComponent();
42
- const caps = useI18nCaps();
43
- const id = groupKey ?? group.name;
44
- const label = resolveNavLabel(caps, `groups.${id}`, declaredText("chrome", group, "label"));
45
- return jsxs("div", {
46
- className: "md:-m-6 md:flex md:min-h-[calc(100%+3rem)]",
47
- "data-testid": `nav-secondary:${id}`,
48
- children: [
49
- jsx("aside", {
50
- className: "hidden w-64 shrink-0 border-r bg-background text-foreground md:block",
51
- children: jsxs("div", {
52
- className: "space-y-4 p-4",
53
- children: [jsx("p", {
54
- className: "px-3 text-base font-semibold tracking-tight",
55
- children: label
56
- }), jsx("nav", {
57
- "aria-label": label,
58
- children: jsx("ul", {
59
- className: "space-y-0.5",
60
- children: items.map((it) => jsx(Row, { it }, it.name))
61
- })
62
- })]
63
- })
64
- }),
65
- jsx("nav", {
66
- "aria-label": label,
67
- "data-testid": `nav-secondary-select:${id}`,
68
- className: "-mx-1 mb-4 flex snap-x snap-proximity gap-1.5 overflow-x-auto scroll-smooth px-1 pb-1 [-ms-overflow-style:none] [mask-image:linear-gradient(to_right,transparent,black_8px,black_calc(100%-8px),transparent)] [scrollbar-width:none] md:hidden [&::-webkit-scrollbar]:hidden",
69
- children: items.map((it) => jsx(RouterLink, {
70
- href: it.href,
71
- "aria-current": it.active ? "page" : void 0,
72
- className: cn("snap-start whitespace-nowrap rounded-full border px-3 py-1.5 text-sm outline-hidden ring-offset-background transition-colors duration-150", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", it.active ? "border-primary/40 bg-primary/10 font-medium text-foreground" : "border-border text-muted-foreground hover:bg-accent/60 hover:text-accent-foreground"),
73
- children: it.label
74
- }, it.name))
75
- }),
76
- jsx("div", {
77
- className: "min-w-0 flex-1 md:overflow-x-hidden md:p-6",
78
- children
79
- })
80
- ]
81
- });
82
- }
83
- //#endregion
84
- //#region src/layout/layouts/tabs-layout.tsx
85
- function TabsLayout({ group, groupKey, items, children }) {
86
- const RouterLink = useLinkComponent();
87
- const caps = useI18nCaps();
88
- const id = groupKey ?? group.name;
89
- const label = resolveNavLabel(caps, `groups.${id}`, declaredText("chrome", group, "label"));
90
- return jsxs("div", {
91
- className: "flex flex-col gap-4",
92
- "data-testid": `nav-tabs:${id}`,
93
- children: [jsx("nav", {
94
- "aria-label": label,
95
- className: "flex gap-1 overflow-x-auto scroll-smooth border-b border-border [-ms-overflow-style:none] [mask-image:linear-gradient(to_right,transparent,black_8px,black_calc(100%-8px),transparent)] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
96
- children: items.map((it) => jsxs(RouterLink, {
97
- href: it.href,
98
- "aria-current": it.active ? "page" : void 0,
99
- "data-testid": `nav-tab:${it.name}`,
100
- className: cn("group/tab relative flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-t-sm px-3 py-2.5 text-sm outline-hidden ring-offset-background transition-colors duration-150", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", it.active ? "font-medium text-foreground" : "text-muted-foreground hover:text-foreground"),
101
- children: [
102
- it.icon != null && jsx("span", {
103
- className: "inline-flex h-4 w-4 shrink-0 items-center justify-center",
104
- "aria-hidden": "true",
105
- children: it.icon
106
- }),
107
- it.label,
108
- jsx("span", {
109
- "aria-hidden": "true",
110
- className: cn("pointer-events-none absolute inset-x-2 -bottom-px h-0.5 origin-center scale-x-0 rounded-full bg-primary opacity-0 transition-all duration-300 ease-out", it.active ? "scale-x-100 opacity-100" : "group-hover/tab:scale-x-100 group-hover/tab:opacity-30")
111
- })
112
- ]
113
- }, it.name))
114
- }), jsx("div", {
115
- className: "min-w-0",
116
- children
117
- })]
118
- });
119
- }
120
- //#endregion
121
- //#region src/layout/nav-slots.ts
122
- function layoutSlot(key) {
123
- return `layout.${key}`;
124
- }
125
- function useLayout(key) {
126
- return useComponent(layoutSlot(key));
127
- }
128
- const BUILTIN_LAYOUTS = {
129
- [layoutSlot("secondary-sidebar")]: SecondarySidebarLayout,
130
- [layoutSlot("tabs")]: TabsLayout
131
- };
132
- function useLayoutResolver() {
133
- const components = useContext(ComponentsContext);
134
- return (key) => components[layoutSlot(key)] ?? BUILTIN_LAYOUTS[layoutSlot(key)];
135
- }
136
- const unresolvedLayoutReported = new WeakMap();
137
- function useReportUnresolvedLayouts(groups, resolve) {
138
- const app = useApp();
139
- useEffect(() => {
140
- if (process.env.NODE_ENV === "production") return;
141
- for (const group of groups) {
142
- const layout = group.layout;
143
- if (layout === "flat" || layout === "collapsible" || resolve(layout)) continue;
144
- const key = canonicalNavKey(group);
145
- let seen = unresolvedLayoutReported.get(app);
146
- if (!seen) {
147
- seen = new Set();
148
- unresolvedLayoutReported.set(app, seen);
149
- }
150
- if (seen.has(key)) continue;
151
- seen.add(key);
152
- console.error(`[burojs] Nav group "${key}" declares layout "${layout}", and no renderer is registered for it. Register one as components["layout.${layout}"] on <BuroProvider>, or use a built-in layout: "secondary-sidebar", "tabs", "flat", "collapsible".`);
153
- }
154
- });
155
- }
156
- //#endregion
157
- //#region src/layout/use-nav-routing.ts
158
- function useNavVisible() {
159
- const ctx = useVisibilityCtx();
160
- const allowed = usePageAllowed();
161
- return useCallback((node) => evaluateVisible(node.visible, ctx) && (!isCustomPageDef(node) || allowed(node)), [ctx, allowed]);
162
- }
163
- function useResourceVisible() {
164
- const ctx = useVisibilityCtx();
165
- return useCallback((def) => evaluateVisible(def.visible, ctx), [ctx]);
166
- }
167
- function usePageAllowed() {
168
- const permissions = usePermissions();
169
- return useCallback((page) => pageAccessFor(page, permissions) === "allowed", [permissions]);
170
- }
171
- function useHref(name, opts) {
172
- const app = useApp();
173
- const isVisible = useNavVisible();
174
- return hrefFor(app.registry, name, {
175
- ...opts,
176
- isVisible
177
- });
178
- }
179
- function useMatch() {
180
- const app = useApp();
181
- const isVisible = useNavVisible();
182
- const path = useOptionalRouterAdapter()?.pathname;
183
- return path === void 0 ? null : matchPath(app.registry, path, { isVisible });
184
- }
185
- //#endregion
186
- //#region src/layout/nav-chrome-mounted.ts
187
- const NavChromeMountedContext = createContext(false);
188
- const NavChromeMountedProvider = NavChromeMountedContext.Provider;
189
- function useNavChromeMounted() {
190
- return useContext(NavChromeMountedContext);
191
- }
192
- //#endregion
193
- //#region src/flows/page-flow-loader.tsx
194
- function PageFlowRouteLoader({ match }) {
195
- const t = useOptionalT();
196
- const chromeT = useChromeT();
197
- const loaded = useLoaded(loadPageFlowRoute);
198
- const failed = (retry) => jsxs("div", {
199
- role: "alert",
200
- "data-buro-flow-load": "failed",
201
- className: "flex flex-col gap-3 p-6 text-sm",
202
- children: [jsx("p", { children: loadFailedText(t) }), jsx("div", { children: jsx(Button, {
203
- type: "button",
204
- onClick: retry,
205
- children: chromeT("actions.retry", { defaultValue: "Retry" })
206
- }) })]
207
- });
208
- if (loaded.error !== void 0) return failed(loaded.retry);
209
- if (loaded.module === void 0) return jsx(RecordState, { state: "loading" });
210
- const Route = loaded.module.PageFlowRoute;
211
- return jsx(FlowBoundary, {
212
- fallback: (_error, reset) => failed(reset),
213
- children: jsx(Route, { match })
214
- });
215
- }
216
- //#endregion
217
- //#region src/list-kit/resource-list-page.tsx
218
- function ResourceListPage({ resource: resourceInput, meta, renderCell, emptyState }) {
219
- const resource = routeResourceKey(resourceInput);
220
- const app = useRouteListImplementation();
221
- const implementation = selectImplementation("buro:related-list", app);
222
- const View = implementation === void 0 ? void 0 : viewOf(implementation);
223
- const translate = useTranslate();
224
- const route = useMemo(() => ({
225
- meta,
226
- renderCell,
227
- emptyState
228
- }), [
229
- meta,
230
- renderCell,
231
- emptyState
232
- ]);
233
- const viewProps = useMemo(() => ({
234
- props: { resource: normalizeEntityRef(resource) },
235
- data: {},
236
- t: (key, options) => translate(`blocks.buro:related-list.${key}`, options)
237
- }), [resource, translate]);
238
- return jsx("div", {
239
- "data-buro-node": "place",
240
- "data-buro-size": "full",
241
- className: "min-w-0",
242
- children: jsx(RouteListContext.Provider, {
243
- value: route,
244
- children: jsx(Suspense, {
245
- fallback: null,
246
- children: View === void 0 ? null : jsx(View, { ...viewProps })
247
- })
248
- })
249
- });
250
- }
251
- //#endregion
252
- //#region src/layout/page-host.tsx
253
- function PageHost({ page, match, notFound }) {
254
- const isVisible = useNavVisible();
255
- const ctx = useVisibilityCtx();
256
- const access = usePageAccess(page);
257
- if (!(evaluateVisible(page.visible, ctx) && match.groupChain.every((group) => isVisible(group)))) return notFound;
258
- if (access === "pending") return jsx(RecordState, { state: "loading" });
259
- if (access === "denied") return notFound;
260
- return jsx(PageParams, {
261
- page,
262
- notFound
263
- });
264
- }
265
- const NO_SEARCH = new URLSearchParams();
266
- function PageParams({ page, notFound }) {
267
- const search = useOptionalRouterAdapter()?.searchParams ?? (typeof window === "undefined" ? NO_SEARCH : new URLSearchParams(window.location.search));
268
- const raw = JSON.stringify(pageParamNames(page.params).map((name) => search.get(name)));
269
- const parsed = useMemo(() => parsePageParams(page, search), [page, raw]);
270
- if (!parsed.ok) return notFound;
271
- return jsx(RouteSourceContext.Provider, {
272
- value: parsed.route,
273
- children: jsx(PageBody, { page })
274
- });
275
- }
276
- function PageBody({ page }) {
277
- const snapshot = useApplicationSnapshot();
278
- const compiled = useMemo(() => compilePageScreen(page, {
279
- blocks: snapshotBlockLookup(snapshot),
280
- frames: snapshotFrameLookup(snapshot),
281
- appFrames: snapshotAppFrames(snapshot)
282
- }), [page, snapshot]);
283
- const failure = isScreenFailure(compiled) ? compiled : null;
284
- const screen = failure === null && !isScreenFailure(compiled) ? compiled : null;
285
- const caps = useI18nCaps();
286
- const name = canonicalNavKey(page);
287
- const label = resolveNavLabel(caps, `pages.${name}`, declaredText("chrome", page, "label"));
288
- useEffect(() => {
289
- if (failure === null || process.env.NODE_ENV === "production") return;
290
- console.error(`[burojs] The page "${name}" cannot render its body: ${failure.code} at ${failure.path.join(".")}: ${failure.message}.`);
291
- }, [failure, name]);
292
- return jsxs("div", {
293
- className: "flex flex-col gap-4",
294
- children: [jsx("h1", {
295
- className: "text-2xl font-semibold tracking-tight",
296
- children: label
297
- }), screen === null ? jsx(RecordState, { state: "error" }) : jsx(PageRouteScreen, { children: jsx(PlannedBody, {
298
- screen,
299
- name,
300
- label
301
- }) })]
302
- });
303
- }
304
- function PageRouteScreen({ children }) {
305
- const tabs = useTabsUrlState("show", true);
306
- return jsx(RouteScreenClaimContext.Provider, {
307
- value: false,
308
- children: jsx(RouteScreenContext.Provider, {
309
- value: true,
310
- children: jsx(ScreenStateProvider, {
311
- open: tabs.open,
312
- onOpenChange: tabs.onOpenChange,
313
- children
314
- })
315
- })
316
- });
317
- }
318
- function PlannedBody({ screen, name, label, record }) {
319
- const pageOptions = useMemo(() => record === void 0 ? {} : { record }, [record]);
320
- const page = usePageScreen(screen, pageOptions);
321
- const { PlacementScope } = page;
322
- const route = useContext(RouteSourceContext);
323
- const catalog = useFrameImplementations();
324
- const id = formatEntityRef(screen.frame);
325
- const resolved = useMemo(() => resolveFrameView(screen.frame, catalog, "page"), [screen.frame, catalog]);
326
- const t = useFrameT(id);
327
- const slots = {};
328
- for (const slot of Object.keys(screen.slots)) slots[slot] = (page.plan.slots[slot] ?? []).every((node) => node.state === "absent") ? null : jsx(ScreenTree, {
329
- region: slot === "body" ? "page-body" : "record",
330
- slot,
331
- resource: name,
332
- mode: "show",
333
- compiled: screen,
334
- page
335
- }, slot);
336
- const View = resolved.view;
337
- const viewProps = {
338
- slots,
339
- label,
340
- params: route ?? {},
341
- t
342
- };
343
- return jsx(RouteSourceContext.Provider, {
344
- value: null,
345
- children: jsx(ActionRouteContext.Provider, {
346
- value: route,
347
- children: jsx(PlacementScope, { children: jsx(DeepLinkScope, {
348
- plan: page.plan,
349
- enabled: true,
350
- children: jsx("div", {
351
- "data-buro-region": "page-body",
352
- children: jsx(Suspense, {
353
- fallback: null,
354
- children: jsx(View, { ...viewProps })
355
- })
356
- })
357
- }) })
358
- })
359
- });
360
- }
361
- //#endregion
362
- //#region src/frames/obligations.tsx
363
- const SlotMountsContext = createContext(null);
364
- function useSlotOnce(slot) {
365
- const mounts = useContext(SlotMountsContext);
366
- const token = useId();
367
- const first = mounts === null || mounts.claim(slot, token);
368
- useEffect(() => {
369
- if (mounts === null) return;
370
- mounts.claim(slot, token);
371
- return () => mounts.release(slot, token);
372
- }, [
373
- mounts,
374
- slot,
375
- token
376
- ]);
377
- useEffect(() => {
378
- if (!first) mounts?.twice(slot);
379
- }, [
380
- first,
381
- mounts,
382
- slot
383
- ]);
384
- return first;
385
- }
386
- function FrameObligations({ id, mode, showActions, root, children }) {
387
- const told = useRef(new Set());
388
- const counts = useRef(new Map());
389
- const owners = useRef(new Map());
390
- const tell = (key, write) => {
391
- if (told.current.has(key) || process.env.NODE_ENV === "production") return;
392
- told.current.add(key);
393
- write();
394
- };
395
- const latestId = useRef(id);
396
- latestId.current = id;
397
- const slotMounts = useMemo(() => ({
398
- claim(slot, token) {
399
- const owner = owners.current.get(slot);
400
- if (owner === void 0) {
401
- owners.current.set(slot, token);
402
- return true;
403
- }
404
- return owner === token;
405
- },
406
- release(slot, token) {
407
- if (owners.current.get(slot) === token) owners.current.delete(slot);
408
- },
409
- twice(slot) {
410
- tell(`slot-twice:${slot}`, () => console.error(`[burojs] frame.slot-twice: ${latestId.current} renders slots.${slot} twice; a slot renders at most once (body twice would mount every field twice under one form).`));
411
- }
412
- }), []);
413
- const pieces = useMemo(() => ({
414
- stub: false,
415
- mount(piece) {
416
- counts.current.set(piece, (counts.current.get(piece) ?? 0) + 1);
417
- return () => counts.current.set(piece, (counts.current.get(piece) ?? 1) - 1);
418
- }
419
- }), []);
420
- return jsx(SlotMountsContext.Provider, {
421
- value: slotMounts,
422
- children: jsxs(FrameCheckContext.Provider, {
423
- value: pieces,
424
- children: [children, jsx(ObligationCheck, { check: () => {
425
- const mounted = (piece) => (counts.current.get(piece) ?? 0) > 0;
426
- if (mode !== "show" && !mounted("FormActions")) tell("no-form-actions", () => console.error(`[burojs] frame.no-form-actions: ${id} renders no <FormActions/> in ${mode}; nothing can submit or cancel the form.`));
427
- if (mode === "show" && showActions && !mounted("RecordActions")) tell("no-actions", () => console.warn(`[burojs] screen.no-actions: ${id} renders no <RecordActions/> in show, and the resource has item actions there.`));
428
- if (root.current?.querySelector("h1") != null) tell("h1", () => console.error(`[burojs] ${id} renders an h1; the route draws the screen's one h1.`));
429
- } })]
430
- })
431
- });
432
- }
433
- function ObligationCheck({ check }) {
434
- useEffect(() => {
435
- check();
436
- });
437
- return null;
438
- }
439
- //#endregion
440
- //#region src/frames/slot-wrapper.tsx
441
- function DraftBanner() {
442
- const { resource, mode, controller } = useRecordFrame();
443
- const t = useOptionalT();
444
- const tid = useTestIds();
445
- const { draft } = controller;
446
- if (mode === "show" || draft.pending === null) return null;
447
- return jsxs("div", {
448
- "data-testid": tid.formDraftBanner(resource, mode),
449
- role: "status",
450
- "aria-live": "polite",
451
- className: "flex flex-wrap items-center gap-2 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-sm",
452
- children: [
453
- jsx("span", {
454
- className: "font-medium",
455
- children: draft.recordChanged ? t("draft.recordChanged") : t("draft.found", { params: { time: timeAgo(draft.pending.savedAt, t) } })
456
- }),
457
- draft.recordChanged ? null : jsx("span", {
458
- className: "text-muted-foreground",
459
- children: t("draft.restorePrompt")
460
- }),
461
- jsxs("div", {
462
- className: "ml-auto flex gap-2",
463
- children: [draft.recordChanged ? null : jsx(Button, {
464
- type: "button",
465
- size: "sm",
466
- variant: "outline",
467
- "data-testid": tid.formDraftRestore(resource, mode),
468
- onClick: draft.restore,
469
- children: t("draft.restore")
470
- }), jsx(Button, {
471
- type: "button",
472
- size: "sm",
473
- variant: "ghost",
474
- "data-testid": tid.formDraftDiscard(resource, mode),
475
- onClick: draft.discard,
476
- children: t("draft.discard")
477
- })]
478
- })
479
- ]
480
- });
481
- }
482
- function timeAgo(savedAt, t) {
483
- const then = new Date(savedAt).getTime();
484
- if (!Number.isFinite(then)) return t("draft.timeAgoRecently");
485
- const diff = Date.now() - then;
486
- if (diff < 6e4) return t("draft.timeAgoMoment");
487
- if (diff < 36e5) return t("draft.timeAgoMinutes", { count: Math.round(diff / 6e4) });
488
- if (diff < 864e5) return t("draft.timeAgoHours", { count: Math.round(diff / 36e5) });
489
- return t("draft.timeAgoDays", { count: Math.round(diff / 864e5) });
490
- }
491
- function frameRecordId(frame, def) {
492
- if (frame.recordId !== void 0) return frame.recordId;
493
- const id = recordKeyOf(def, frame.record);
494
- return typeof id === "string" || typeof id === "number" ? String(id) : void 0;
495
- }
496
- function BodySlot() {
497
- const frame = useRecordFrame();
498
- const { resource, mode, controller } = frame;
499
- const chrome = useFrameChrome();
500
- const tid = useTestIds();
501
- const id = frameRecordId(frame, useApp().registry.get(resource));
502
- const tree = jsx("div", {
503
- "data-buro-region": "record-body",
504
- "data-buro-slot": FORM_SLOT,
505
- children: jsx(ScreenTree, {
506
- region: "record",
507
- slot: FORM_SLOT,
508
- resource,
509
- mode,
510
- compiled: controller.screen,
511
- controller
512
- })
513
- });
514
- if (mode === "show") return tree;
515
- return jsxs("form", {
516
- id: chrome.formId,
517
- noValidate: true,
518
- "data-testid": tid.form(resource, mode, id),
519
- onSubmit: (event) => {
520
- event.preventDefault();
521
- const steps = controller.steps;
522
- if (steps !== null && steps.current !== void 0 && steps.current !== steps.ids[steps.ids.length - 1]) steps.next();
523
- else chrome.submit();
524
- },
525
- className: "flex flex-col gap-4",
526
- children: [jsx(DraftBanner, {}), tree]
527
- });
528
- }
529
- function DisplaySlot({ name }) {
530
- const { resource, mode, controller } = useRecordFrame();
531
- return jsx(ScreenTree, {
532
- region: "record",
533
- slot: name,
534
- resource,
535
- mode,
536
- compiled: controller.screen,
537
- controller
538
- });
539
- }
540
- function SlotWrapper({ name }) {
541
- if (!useSlotOnce(name)) return null;
542
- return name === FORM_SLOT ? jsx(BodySlot, {}) : jsx(DisplaySlot, { name });
543
- }
544
- //#endregion
545
- //#region src/frames/record-frame-host.tsx
546
- const NO_ROOT = { current: null };
547
- function drawnFields(roots, compiled, out) {
548
- for (const node of roots) {
549
- if (node.state === "absent") continue;
550
- const field = node.field ?? compiled.nodes[node.index]?.field;
551
- if (node.kind === "field" && field !== void 0 && node.state === "ready") out.add(field);
552
- drawnFields(node.children, compiled, out);
553
- }
554
- }
555
- function frameRecord(record, compiled, slots, idField, visible = () => true) {
556
- if (record === void 0 || compiled === null || slots === void 0) return void 0;
557
- const drawn = new Set();
558
- for (const roots of Object.values(slots)) drawnFields(roots, compiled, drawn);
559
- const declarations = new Map(compiled.fields.map((entry) => [entry.name, entry.declaration]));
560
- const out = {};
561
- if (Object.hasOwn(record, idField)) out[idField] = record[idField];
562
- for (const name of drawn) {
563
- if (!Object.hasOwn(record, name) || !visible(name)) continue;
564
- if (fieldSensitivity(declarations.get(name)) !== void 0) continue;
565
- out[name] = record[name];
566
- }
567
- return Object.freeze(out);
568
- }
569
- function declaredSlots(compiled) {
570
- if (compiled === null) return [];
571
- return Object.entries(compiled.slots).filter(([, nodes]) => nodes.length > 0).map(([name]) => name);
572
- }
573
- function useEffectiveFrame(instance) {
574
- const { resource, mode, controller } = useRecordFrame();
575
- const compiled = controller.screen;
576
- const missing = useMemo(() => {
577
- if (instance === void 0 || instance.for !== "record") return void 0;
578
- const own = new Set(Object.keys(instance.slots));
579
- return declaredSlots(compiled).find((slot) => !own.has(slot));
580
- }, [instance, compiled]);
581
- const told = useRef(false);
582
- const instanceId = instance === void 0 ? void 0 : formatEntityRef(instance.ref);
583
- useEffect(() => {
584
- if (missing === void 0 || told.current || process.env.NODE_ENV === "production") return;
585
- told.current = true;
586
- console.error(`[burojs] <RecordScreen frame={${instanceId}}> lacks the slot ${missing} that ${resource}'s ${mode} screen fills; the screen's own frame draws it.`);
587
- }, [
588
- missing,
589
- instanceId,
590
- resource,
591
- mode
592
- ]);
593
- if (instance !== void 0 && instance.for === "record" && missing === void 0 && compiled !== null) return {
594
- ref: instance.ref,
595
- slotNames: Object.keys(instance.slots)
596
- };
597
- return {
598
- ref: compiled?.frame ?? builtinFrames.record.ref,
599
- slotNames: compiled === null ? ["header", FORM_SLOT] : Object.keys(compiled.slots)
600
- };
601
- }
602
- function RecordFrameView({ frame: instance }) {
603
- const { resource, mode, controller, record } = useRecordFrame();
604
- const chrome = useFrameChrome();
605
- const quick = useQuickEntry();
606
- const app = useApp();
607
- const catalog = useFrameImplementations();
608
- const { ref, slotNames } = useEffectiveFrame(instance);
609
- const id = formatEntityRef(ref);
610
- const resolved = useMemo(() => resolveFrameView(ref, catalog, "record"), [ref, catalog]);
611
- const t = useFrameT(id);
612
- const compiled = controller.screen;
613
- const plan = controller.plan;
614
- const slots = {};
615
- for (const name of slotNames) {
616
- if (name === FORM_SLOT) {
617
- slots[name] = jsx(SlotWrapper, { name }, name);
618
- continue;
619
- }
620
- slots[name] = (plan?.slots[name] ?? []).every((node) => node.state === "absent") ? null : jsx(SlotWrapper, { name }, name);
621
- }
622
- slots[FORM_SLOT] ??= jsx(SlotWrapper, { name: FORM_SLOT });
623
- const idField = app.registry.get(resource)?.data?.idField ?? "id";
624
- const access = useFieldAccess(resource, "record", record === void 0 ? void 0 : policyRecordOf(controller, record));
625
- const projected = useMemo(() => frameRecord(record, compiled, plan?.slots, idField, (name) => access[name]?.view === "visible"), [
626
- record,
627
- compiled,
628
- plan,
629
- idField,
630
- access
631
- ]);
632
- const quickHost = chrome.hostTitle === true && quick !== null;
633
- const props = {
634
- slots,
635
- host: quickHost ? quick.host : "page",
636
- mode,
637
- screen: {
638
- resource,
639
- entry: quickHost ? "quick" : "route"
640
- },
641
- record: mode === "create" ? void 0 : projected,
642
- t
643
- };
644
- const policyRecord = policyRecordOf(controller, record);
645
- const rowId = record?.[idField];
646
- const actionRow = useMemo(() => ({
647
- ...policyRecord ?? {},
648
- id: typeof rowId === "string" || typeof rowId === "number" ? String(rowId) : ""
649
- }), [policyRecord, rowId]);
650
- const showItemActions = useShownItemActions(resource, actionRow, "show", void 0, controller.sources);
651
- const showActions = mode === "show" && record !== void 0 && showItemActions.length > 0;
652
- const View = resolved.view;
653
- const builtin = isBuiltinRecordView(resolved);
654
- return jsxs(Fragment$1, { children: [builtin ? null : jsxs(Fragment$1, { children: [jsx(HeaderTypeNotice, { resource }), jsx(ChangeTypeButton, {})] }), jsx(TypeChromeDrawnContext.Provider, {
655
- value: !builtin,
656
- children: jsx(Suspense, {
657
- fallback: jsx(RecordState, { state: "loading" }),
658
- children: jsx(FrameObligations, {
659
- id,
660
- mode,
661
- showActions,
662
- root: chrome.root ?? NO_ROOT,
663
- children: jsx(View, { ...props })
664
- })
665
- })
666
- })] });
667
- }
668
- function useResourceDimensionOptions(dimension, resource, labelField) {
669
- const def = useApp().registry.get(resource);
670
- const rowTitle = useRowTitle(resource, labelField ?? def?.displayField);
671
- const rows = useList(resource, {
672
- pagination: {
673
- kind: "offset",
674
- page: 1,
675
- pageSize: 100
676
- },
677
- total: false,
678
- scope: {
679
- default: "session",
680
- dimensions: { [dimension]: "none" }
681
- }
682
- }).data?.data;
683
- return useMemo(() => (rows ?? []).flatMap((row) => {
684
- const key = recordKeyOf(def, row);
685
- return key === null || key === void 0 ? [] : [{
686
- value: key,
687
- label: rowTitle(row)
688
- }];
689
- }), [
690
- rows,
691
- def,
692
- rowTitle
693
- ]);
694
- }
695
- //#endregion
696
- //#region src/record/scope-mismatch-banner.tsx
697
- const asList = (value) => value === null ? [] : Array.isArray(value) ? value : [value];
698
- const isScalar = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean";
699
- function ScopeMismatchBanner(props) {
700
- const app = useApp();
701
- const mapping = app.registry.get(props.resource)?.data?.scope;
702
- if (app.scope === void 0 || mapping === void 0 || props.record === void 0) return null;
703
- return jsx(Banner, {
704
- ...props,
705
- record: props.record,
706
- mapping
707
- });
708
- }
709
- function Banner({ record, mapping, kind = "record" }) {
710
- const scope = useScope();
711
- const chromeT = useChromeT();
712
- const differences = useMemo(() => {
713
- const out = [];
714
- for (const [dimension, target] of Object.entries(mapping)) {
715
- const definition = scope.definition?.dimensions[dimension];
716
- if (definition === void 0 || definition.select === "none") continue;
717
- const selected = asList(scope.selection[dimension] ?? null);
718
- if (selected.length === 0) continue;
719
- const column = scopeColumnOf(target);
720
- if (!Object.hasOwn(record, column)) continue;
721
- const held = record[column];
722
- if (held === null || held === void 0 || held === "") {
723
- if (kind === "created" || "field" in target && target.empty === "shared") continue;
724
- out.push({
725
- dimension,
726
- value: null,
727
- selected,
728
- select: definition.select
729
- });
730
- continue;
731
- }
732
- if (!isScalar(held)) continue;
733
- if (selected.some((value) => String(value) === String(held))) continue;
734
- out.push({
735
- dimension,
736
- value: held,
737
- selected,
738
- select: definition.select
739
- });
740
- }
741
- return out;
742
- }, [
743
- mapping,
744
- record,
745
- scope.definition,
746
- scope.selection,
747
- kind
748
- ]);
749
- if (differences.length === 0) return null;
750
- const apply = () => {
751
- for (const difference of differences) scope.select(difference.dimension, difference.value === null ? null : difference.select === "multiple" ? [difference.value] : difference.value);
752
- };
753
- return jsxs("div", {
754
- role: "status",
755
- "data-testid": "scope-mismatch:banner",
756
- className: "flex flex-wrap items-center justify-between gap-3 rounded-md border bg-muted/50 px-3 py-2 text-sm",
757
- children: [jsxs("div", {
758
- className: "space-y-1",
759
- children: [jsx("p", {
760
- className: "font-medium",
761
- children: kind === "created" ? chromeT("scope.mismatch.createdOutside", { defaultValue: "Created outside the current scope" }) : chromeT("scope.mismatch.title", { defaultValue: "This record is outside the current scope" })
762
- }), jsx("ul", {
763
- className: "text-muted-foreground",
764
- children: differences.map((difference) => jsx(DifferenceLine, {
765
- difference,
766
- definition: scope.definition.dimensions[difference.dimension]
767
- }, difference.dimension))
768
- })]
769
- }), jsx(Button, {
770
- type: "button",
771
- size: "sm",
772
- "data-testid": "scope-mismatch:switch",
773
- onClick: apply,
774
- children: chromeT("scope.mismatch.switch", { defaultValue: "Switch" })
775
- })]
776
- });
777
- }
778
- function DifferenceLine(props) {
779
- const source = props.definition.values;
780
- if (source !== void 0 && !Array.isArray(source)) {
781
- const { resource, label } = source;
782
- return jsx(ResourceLine, {
783
- ...props,
784
- resource,
785
- ...label ? { labelField: label } : {}
786
- });
787
- }
788
- return jsx(LineText, {
789
- difference: props.difference,
790
- options: source ?? []
791
- });
792
- }
793
- function ResourceLine({ difference, resource, labelField }) {
794
- const options = useResourceDimensionOptions(difference.dimension, resource, labelField);
795
- return jsx(LineText, {
796
- difference,
797
- options
798
- });
799
- }
800
- function LineText({ difference, options }) {
801
- const chromeT = useChromeT();
802
- const labelOf = (value) => options.find((option) => String(option.value) === String(value))?.label ?? String(value);
803
- const field = humanizeKey(difference.dimension);
804
- const item = difference.value === null ? chromeT("scope.mismatch.empty", { defaultValue: "not set" }) : labelOf(difference.value);
805
- const items = difference.selected.map(labelOf).join(", ");
806
- return jsx("li", {
807
- "data-testid": `scope-mismatch:line:${difference.dimension}`,
808
- children: chromeT("scope.mismatch.line", {
809
- params: {
810
- field,
811
- item,
812
- items
813
- },
814
- defaultValue: `${field}: ${item} (selected: ${items})`
815
- })
816
- });
817
- }
818
- //#endregion
819
- //#region src/record/type-offer.tsx
820
- function TypeOffer({ resource, offer, onChoose }) {
821
- const app = useApp();
822
- const t = useOptionalT();
823
- const tid = useTestIds();
824
- const def = app.registry.get(resource);
825
- const by = def?.types?.by;
826
- const field = by === void 0 ? void 0 : def?.fields[by];
827
- const ref = def?.ref ?? {
828
- namespace: "default",
829
- id: resource
830
- };
831
- return jsxs("section", {
832
- "aria-labelledby": "type-offer-title",
833
- className: "flex flex-col gap-3",
834
- children: [jsxs("div", {
835
- className: "flex flex-col gap-1",
836
- children: [jsx("h2", {
837
- id: "type-offer-title",
838
- className: "text-base font-semibold",
839
- children: t("create.typeOffer.title", { defaultValue: "Choose a type" })
840
- }), jsx("p", {
841
- className: "text-sm text-muted-foreground",
842
- children: t("create.typeOffer.hint", { defaultValue: "The type decides which fields the record has." })
843
- })]
844
- }), offer.status === "pending" ? jsxs("div", {
845
- "aria-busy": "true",
846
- className: "flex flex-col gap-2",
847
- children: [jsx(Skeleton, { className: "h-10 w-full" }), jsx(Skeleton, { className: "h-10 w-full" })]
848
- }) : offer.types.length === 0 ? jsx("p", {
849
- role: "status",
850
- className: "text-sm text-muted-foreground",
851
- children: t("create.typeOffer.empty", { defaultValue: "No type can be created here." })
852
- }) : jsx("ul", {
853
- className: "grid grid-cols-1 gap-2 sm:grid-cols-2",
854
- children: offer.types.map((type) => jsx("li", { children: jsx("button", {
855
- type: "button",
856
- "data-testid": tid.typeOffer(resource, type),
857
- onClick: () => onChoose(type),
858
- className: "flex w-full items-center gap-2 rounded-md border px-3 py-2 text-left text-sm hover:bg-muted focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
859
- children: by === void 0 || field === void 0 ? type : jsx(FieldDisplay, {
860
- resource: ref,
861
- name: by,
862
- field,
863
- value: type,
864
- fallback: jsx("span", { children: type })
865
- })
866
- }) }, type))
867
- })]
868
- });
869
- }
870
- //#endregion
871
- //#region src/record/record-screen.tsx
872
- function isAbort(error) {
873
- if (error === null || typeof error !== "object" && typeof error !== "function") return false;
874
- try {
875
- return error.name === "AbortError";
876
- } catch {
877
- return false;
878
- }
879
- }
880
- const NO_ISSUES = Object.freeze([]);
881
- const APPLIED_UNREADABLE = Object.freeze({
882
- code: "applied-unreadable",
883
- message: Object.freeze({
884
- key: "errors.appliedUnreadable",
885
- default: "Saved. The server's answer could not be read, so the screen may not show the latest values."
886
- }),
887
- path: Object.freeze([]),
888
- source: "server",
889
- severity: "info"
890
- });
891
- function issuesOf(error) {
892
- if (error === null || typeof error !== "object") return void 0;
893
- try {
894
- const descriptor = Object.getOwnPropertyDescriptor(error, "issues");
895
- return descriptor !== void 0 && "value" in descriptor ? descriptor.value : void 0;
896
- } catch {
897
- return;
898
- }
899
- }
900
- const NO_EDITED = new Set();
901
- function sameValue(a, b) {
902
- if (Object.is(a, b)) return true;
903
- try {
904
- return JSON.stringify(a) === JSON.stringify(b);
905
- } catch {
906
- return false;
907
- }
908
- }
909
- function RecordFrameHost(props) {
910
- const { resource, mode } = props;
911
- const [failed, setFailed] = useState(NO_ISSUES);
912
- const named = useMemo(() => failed.length === 0 ? NO_ISSUES : routeServerIssues({ issues: failed }, (segment) => segment, (field) => field !== "_form").fields, [failed]);
913
- const atFailure = useRef({});
914
- const [edited, setEdited] = useState(NO_EDITED);
915
- const controller = useFormController({
916
- resource,
917
- mode,
918
- ...props.recordId === void 0 ? {} : { recordId: props.recordId },
919
- ...props.type === void 0 ? {} : { type: props.type },
920
- ...props.record === void 0 ? {} : { record: props.record },
921
- ...props.defaults === void 0 ? {} : { defaults: props.defaults },
922
- ...props.onSubmit === void 0 ? {} : { onSubmit: props.onSubmit },
923
- ...props.hostTitle ? { entry: "quick" } : {},
924
- serverIssues: named
925
- });
926
- const inputApplied = useRef(false);
927
- const { input } = props;
928
- const plan = controller.plan;
929
- useEffect(() => {
930
- if (inputApplied.current || input === void 0 || mode !== "create" || plan === null) return;
931
- inputApplied.current = true;
932
- for (const [key, value] of Object.entries(input)) if (plan.fields[key] === "active") controller.setValue(key, value);
933
- }, [
934
- input,
935
- mode,
936
- plan,
937
- controller
938
- ]);
939
- const tid = useTestIds();
940
- const formId = `record-form-${useId()}`;
941
- const root = useRef(null);
942
- const [submitError, setSubmitError] = useState(void 0);
943
- const [submitApplied, setSubmitApplied] = useState(void 0);
944
- useEffect(() => {
945
- if (plan === null) return;
946
- const now = Object.keys(atFailure.current).filter((name) => !edited.has(name) && plan.fields[name] === "active" && !sameValue(controller.field(name).value, atFailure.current[name]));
947
- if (now.length > 0) setEdited((previous) => new Set([...previous, ...now]));
948
- }, [
949
- plan,
950
- controller,
951
- edited
952
- ]);
953
- const notify = useNoticeSink(resource);
954
- const routeScreen = useIsRouteScreen();
955
- const leavesOnCreate = mode === "create" && routeScreen;
956
- const [created, setCreated] = useState(false);
957
- const createdRef = useRef(false);
958
- const latest = useRef({
959
- controller,
960
- onSuccess: props.onSuccess,
961
- notify,
962
- leavesOnCreate
963
- });
964
- latest.current = {
965
- controller,
966
- onSuccess: props.onSuccess,
967
- notify,
968
- leavesOnCreate
969
- };
970
- const mounted = useRef(true);
971
- useEffect(() => {
972
- mounted.current = true;
973
- return () => {
974
- mounted.current = false;
975
- };
976
- }, []);
977
- const submit = useCallback(async () => {
978
- if (createdRef.current) return;
979
- setSubmitError(void 0);
980
- setSubmitApplied(void 0);
981
- setFailed(NO_ISSUES);
982
- setEdited(NO_EDITED);
983
- atFailure.current = {};
984
- const outcome = await latest.current.controller.submit();
985
- if (!mounted.current) return;
986
- if (latest.current.leavesOnCreate && (outcome.status === "submitted" || outcome.status === "failed" && outcome.applied === "yes")) {
987
- createdRef.current = true;
988
- setCreated(true);
989
- }
990
- if (outcome.status === "submitted") {
991
- const notices = successNoticesOf(outcome.result);
992
- if (notices.length > 0) latest.current.notify(notices);
993
- latest.current.onSuccess?.(outcome.result);
994
- } else if (outcome.status === "failed" && outcome.applied === "yes") {
995
- latest.current.notify([APPLIED_UNREADABLE]);
996
- latest.current.onSuccess?.(void 0);
997
- } else if (outcome.status === "failed" && !isAbort(outcome.error)) {
998
- setSubmitError(outcome.error ?? null);
999
- setSubmitApplied(outcome.applied);
1000
- const issues = normalizeIssueInputs(issuesOf(outcome.error)).issues;
1001
- const next = issues.length === 0 ? NO_ISSUES : Object.freeze(issues.map(issueOfInput));
1002
- const held = {};
1003
- const now = latest.current.controller;
1004
- for (const issue of next) {
1005
- const head = issue.path[0];
1006
- if (typeof head === "string" && head !== "_form" && now.plan?.fields[head] === "active") held[head] = now.field(head).value;
1007
- }
1008
- atFailure.current = held;
1009
- setFailed(next);
1010
- }
1011
- }, []);
1012
- const record = controller.record;
1013
- const recordText = props.recordId === void 0 ? void 0 : String(props.recordId);
1014
- const frame = useMemo(() => ({
1015
- resource,
1016
- recordId: recordText,
1017
- mode,
1018
- record,
1019
- controller
1020
- }), [
1021
- resource,
1022
- recordText,
1023
- mode,
1024
- record,
1025
- controller
1026
- ]);
1027
- const { chooseType } = props;
1028
- const typedAndAccepted = mode === "create" && controller.typeOffer !== null && controller.failure === null;
1029
- const adapter = useOptionalRouterAdapter();
1030
- const hostRouter = routeScreen ? adapter : null;
1031
- const guardText = useNavigationGuardText();
1032
- const changeType = useMemo(() => typedAndAccepted ? () => {
1033
- if (hostRouter === null && latest.current.controller.isDirty && !window.confirm(`${guardText.title}\n\n${guardText.body}`)) return;
1034
- chooseType(void 0);
1035
- } : void 0, [
1036
- typedAndAccepted,
1037
- chooseType,
1038
- hostRouter,
1039
- guardText.title,
1040
- guardText.body
1041
- ]);
1042
- const app = useApp();
1043
- const typesDecl = app.registry.get(resource)?.types;
1044
- const loaded = controller.record;
1045
- const unsupportedType = useMemo(() => {
1046
- if (mode === "create" || typesDecl === void 0 || loaded === void 0) return void 0;
1047
- const value = loaded[typesDecl.by];
1048
- const name = typeof value === "string" && value !== "" ? value : null;
1049
- return name !== null && typesDecl.items.some((item) => item.name === name) ? void 0 : name;
1050
- }, [
1051
- mode,
1052
- typesDecl,
1053
- loaded
1054
- ]);
1055
- const shownFailed = useMemo(() => edited.size === 0 ? failed : Object.freeze(failed.filter((issue) => {
1056
- const head = issue.path[0];
1057
- return typeof head !== "string" || !edited.has(head);
1058
- })), [failed, edited]);
1059
- const chrome = useMemo(() => ({
1060
- ...props.onCancel === void 0 ? {} : { onCancel: props.onCancel },
1061
- ...props.submitLabel === void 0 ? {} : { submitLabel: props.submitLabel },
1062
- ...props.extraActions === void 0 ? {} : { extraActions: props.extraActions },
1063
- ...changeType === void 0 ? {} : { changeType },
1064
- ...unsupportedType === void 0 ? {} : { unsupportedType },
1065
- ...props.hostTitle ? { hostTitle: true } : {},
1066
- formId,
1067
- submitError,
1068
- ...submitApplied === void 0 ? {} : { submitApplied },
1069
- serverIssues: shownFailed,
1070
- ...created ? { created: true } : {},
1071
- submit,
1072
- root
1073
- }), [
1074
- props.onCancel,
1075
- props.submitLabel,
1076
- props.extraActions,
1077
- changeType,
1078
- unsupportedType,
1079
- props.hostTitle,
1080
- formId,
1081
- submitError,
1082
- submitApplied,
1083
- shownFailed,
1084
- created,
1085
- submit
1086
- ]);
1087
- usePublishDocVariant(mode === "show" ? resource : void 0, record);
1088
- const failure = controller.failure;
1089
- const offering = failure?.kind === "type-required" && controller.typeOffer !== null;
1090
- useEffect(() => {
1091
- if (failure === null || offering || process.env.NODE_ENV === "production") return;
1092
- console.error(`[burojs] <RecordScreen resource="${resource}" mode="${mode}"> cannot render its screen: ${failure.kind === "screen" ? `${failure.failure.code} at ${failure.failure.path.join(".")}: ${failure.failure.message}` : "a typed create needs an accepted type"}.`);
1093
- }, [
1094
- failure,
1095
- offering,
1096
- resource,
1097
- mode
1098
- ]);
1099
- const formControl = useFormControlOf(controller);
1100
- const id = frameRecordId(frame, app.registry.get(frame.resource));
1101
- const rootId = mode === "show" ? tid.pageShow(resource, id ?? "") : mode === "edit" ? tid.pageEdit(resource, id ?? "") : tid.pageCreate(resource);
1102
- const claimedRoute = useContext(RouteSourceContext);
1103
- const scopeValues = mode === "show" ? controller.record : controller.values;
1104
- return jsx(RecordScopeProvider, {
1105
- resource,
1106
- ...recordText === void 0 ? {} : { recordId: recordText },
1107
- values: scopeValues,
1108
- create: mode === "create",
1109
- children: jsx(RouteSourceContext.Provider, {
1110
- value: null,
1111
- children: jsx(ActionRouteContext.Provider, {
1112
- value: claimedRoute,
1113
- children: jsx(RecordFrameContext.Provider, {
1114
- value: frame,
1115
- children: jsx(FrameChromeContext.Provider, {
1116
- value: chrome,
1117
- children: jsxs(FormControlProvider, {
1118
- value: formControl,
1119
- children: [jsx(DeepLinkScope, {
1120
- plan: controller.plan,
1121
- enabled: routeScreen && mode !== "create",
1122
- children: jsx("div", {
1123
- ref: root,
1124
- "data-testid": rootId,
1125
- className: "flex flex-col gap-[var(--buro-section-gap)]",
1126
- children: offering && controller.typeOffer !== null ? jsx(TypeOffer, {
1127
- resource,
1128
- offer: controller.typeOffer,
1129
- onChoose: (type) => chooseType(type)
1130
- }) : failure !== null ? jsxs(Fragment$1, { children: [jsx(RecordState, { state: "error" }), jsx(FormActions, {})] }) : mode === "edit" && unsupportedType !== void 0 ? jsx(UndeclaredTypeNotice, {
1131
- resource,
1132
- typeValue: unsupportedType
1133
- }) : jsxs(Fragment$1, { children: [jsx(ScopeMismatchBanner, {
1134
- resource,
1135
- record: mode === "create" ? controller.trustedSeeds : controller.record,
1136
- kind: mode === "create" ? "created" : "record"
1137
- }), jsx(RecordFrameView, { ...props.frame === void 0 ? {} : { frame: props.frame } })] })
1138
- })
1139
- }), controller.checkGate === null ? null : jsx(CheckConfirmDialog, {
1140
- state: controller.checkGate,
1141
- testid: `${tid.form(resource, mode, id)}:checks`
1142
- })]
1143
- })
1144
- })
1145
- })
1146
- })
1147
- })
1148
- });
1149
- }
1150
- function RecordScreen(props) {
1151
- const app = useApp();
1152
- const routeScreen = useContext(RouteScreenClaimContext);
1153
- const quickScreen = useContext(QuickScreenClaimContext);
1154
- const route = useContext(RouteSourceContext);
1155
- const resourceInput = props.resource;
1156
- const resource = resourceKey(resourceInput);
1157
- const tabs = useTabsUrlState(props.mode, routeScreen);
1158
- const adapter = useOptionalRouterAdapter();
1159
- const router = routeScreen ? adapter : null;
1160
- const navigate = useRouteNavigate();
1161
- const [local, setLocal] = useState(props.type);
1162
- const [typeProp, setTypeProp] = useState(props.type);
1163
- if (props.type !== typeProp) {
1164
- setTypeProp(props.type);
1165
- setLocal(props.type);
1166
- }
1167
- const [chose, setChose] = useState(false);
1168
- const fromUrl = router?.searchParams.get("type") ?? void 0;
1169
- const type = props.mode !== "create" ? props.type : router === null ? local : chose ? fromUrl : props.type ?? fromUrl;
1170
- const chooseType = useCallback((next) => {
1171
- if (router === null) {
1172
- setLocal(next);
1173
- return;
1174
- }
1175
- setChose(true);
1176
- const params = new URLSearchParams(router.searchParams);
1177
- if (next === void 0) params.delete("type");
1178
- else params.set("type", next);
1179
- const query = params.toString();
1180
- navigate(query === "" ? router.pathname : `${router.pathname}?${query}`);
1181
- }, [router, navigate]);
1182
- if (app.registry.get(resource) === void 0) return jsx(RecordState, { state: "not-found" });
1183
- const { type: _declared, ...rest } = props;
1184
- return jsx(RouteScreenClaimContext.Provider, {
1185
- value: false,
1186
- children: jsx(QuickScreenClaimContext.Provider, {
1187
- value: false,
1188
- children: jsx(RouteSourceContext.Provider, {
1189
- value: routeScreen || quickScreen ? route : null,
1190
- children: jsx(RouteScreenContext.Provider, {
1191
- value: routeScreen,
1192
- children: jsx(ResourceContext.Provider, {
1193
- value: { resource },
1194
- children: jsx(ScreenStateProvider, {
1195
- open: tabs.open,
1196
- onOpenChange: tabs.onOpenChange,
1197
- children: jsx(RecordFrameHost, {
1198
- ...rest,
1199
- ...type === void 0 ? {} : { type },
1200
- resource,
1201
- chooseType,
1202
- hostTitle: quickScreen
1203
- }, type ?? "")
1204
- })
1205
- })
1206
- })
1207
- })
1208
- })
1209
- });
1210
- }
1211
- //#endregion
1212
- //#region src/layout/record-trail-store.ts
1213
- const stores = new WeakMap();
1214
- function storeOf(app) {
1215
- let store = stores.get(app);
1216
- if (store === void 0) {
1217
- store = {
1218
- current: null,
1219
- listeners: new Set()
1220
- };
1221
- stores.set(app, store);
1222
- }
1223
- return store;
1224
- }
1225
- function set(store, value) {
1226
- store.current = value;
1227
- for (const listener of store.listeners) listener();
1228
- }
1229
- function recordTrailKey(resource, id, route) {
1230
- return JSON.stringify([
1231
- resource,
1232
- id,
1233
- route
1234
- ]);
1235
- }
1236
- function usePublishRecordTrail(entry) {
1237
- const app = useApp();
1238
- const key = entry?.key;
1239
- const title = entry?.title;
1240
- const flowLabel = entry?.flowLabel;
1241
- useEffect(() => {
1242
- if (key === void 0 || title === void 0) return;
1243
- const store = storeOf(app);
1244
- const value = {
1245
- key,
1246
- title,
1247
- ...flowLabel === void 0 ? {} : { flowLabel }
1248
- };
1249
- set(store, value);
1250
- return () => {
1251
- if (store.current === value) set(store, null);
1252
- };
1253
- }, [
1254
- app,
1255
- key,
1256
- title,
1257
- flowLabel
1258
- ]);
1259
- }
1260
- function usePublishedRecordTrail(key) {
1261
- const store = storeOf(useApp());
1262
- const subscribe = useCallback((listener) => {
1263
- store.listeners.add(listener);
1264
- return () => {
1265
- store.listeners.delete(listener);
1266
- };
1267
- }, [store]);
1268
- const current = useSyncExternalStore(subscribe, () => store.current, () => null);
1269
- return current !== null && current.key === key ? current : null;
1270
- }
1271
- //#endregion
1272
- //#region src/layout/record-targets.ts
1273
- function isShowAvailable(registry, resource) {
1274
- return recordRouteAvailable(registry, resource, "show");
1275
- }
1276
- function showTarget(resource, id) {
1277
- return {
1278
- resource,
1279
- action: "show",
1280
- params: { id }
1281
- };
1282
- }
1283
- function listTarget(resource) {
1284
- return {
1285
- resource,
1286
- action: "list"
1287
- };
1288
- }
1289
- //#endregion
1290
- //#region src/layout/route-trail.ts
1291
- function useTrailContext() {
1292
- const app = useApp();
1293
- const caps = useI18nCaps();
1294
- const isVisible = useNavVisible();
1295
- const t = useT();
1296
- return {
1297
- registry: app.registry,
1298
- caps,
1299
- isVisible,
1300
- t
1301
- };
1302
- }
1303
- function groupCrumbHref(registry, group, isVisible) {
1304
- let href;
1305
- try {
1306
- href = navHrefFor(registry, group, { isVisible });
1307
- } catch {
1308
- return;
1309
- }
1310
- return matchPath(registry, href, { isVisible }) === null ? void 0 : href;
1311
- }
1312
- function groupCrumbs(ctx, chain) {
1313
- return chain.map((group) => {
1314
- const key = canonicalNavKey(group);
1315
- return {
1316
- label: resolveNavLabel(ctx.caps, `groups.${key}`, declaredText("chrome", group, "label")),
1317
- href: groupCrumbHref(ctx.registry, key, ctx.isVisible),
1318
- jump: true
1319
- };
1320
- });
1321
- }
1322
- function nonEmpty(crumbs) {
1323
- return crumbs.length > 0 ? crumbs : void 0;
1324
- }
1325
- function recordActionOf(match) {
1326
- if (match === null || match.kind !== "resource") return void 0;
1327
- switch (match.action) {
1328
- case "show":
1329
- case "edit":
1330
- case "create": return match.action;
1331
- default: return;
1332
- }
1333
- }
1334
- function pathOf(href) {
1335
- const path = href.split(/[?#]/, 1)[0] ?? "";
1336
- return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
1337
- }
1338
- function originTrail(ctx, origin, depth = ORIGIN_DEPTH) {
1339
- const match = matchPath(ctx.registry, pathOf(origin.href), { isVisible: ctx.isVisible });
1340
- if (match === null) return void 0;
1341
- switch (match.kind) {
1342
- case "resource": {
1343
- const key = canonicalNavKey(match);
1344
- if (match.action === "list") return {
1345
- leading: groupCrumbs(ctx, match.groupChain),
1346
- resource: key,
1347
- resourceHref: origin.href,
1348
- segments: []
1349
- };
1350
- const def = ctx.registry.get(key);
1351
- const crumb = {
1352
- label: match.action === "create" ? ctx.t("breadcrumbs.create") : origin.title || (match.id === void 0 ? "" : `#${match.id}`),
1353
- href: origin.href
1354
- };
1355
- const parent = depth > 1 && origin.origin !== void 0 ? originTrail(ctx, origin.origin, depth - 1) : void 0;
1356
- if (parent !== void 0) return {
1357
- ...parent,
1358
- segments: [...parent.segments, crumb]
1359
- };
1360
- return {
1361
- leading: groupCrumbs(ctx, match.groupChain),
1362
- resource: key,
1363
- ...def !== void 0 && hasListPage(def) ? { resourceHref: hrefFor(ctx.registry, key) } : {},
1364
- segments: [crumb]
1365
- };
1366
- }
1367
- case "custom-page": {
1368
- const trail = headerTrail(ctx, match);
1369
- if (trail === null || trail.pageLabel === void 0) return void 0;
1370
- return {
1371
- leading: trail.leadingSegments ?? [],
1372
- segments: [{
1373
- label: trail.pageLabel,
1374
- href: origin.href
1375
- }]
1376
- };
1377
- }
1378
- case "group-index": {
1379
- const crumbs = groupCrumbs(ctx, match.groupChain);
1380
- const own = crumbs[crumbs.length - 1];
1381
- if (own === void 0) return void 0;
1382
- return {
1383
- leading: crumbs.slice(0, -1),
1384
- segments: [{
1385
- label: own.label,
1386
- href: origin.href
1387
- }]
1388
- };
1389
- }
1390
- default: return;
1391
- }
1392
- }
1393
- function recordTrail(ctx, input) {
1394
- const { resource, action, id, origin } = input;
1395
- if (origin !== void 0 && (action === "create" || id !== "")) return originRooted(ctx, input, origin);
1396
- const leadingSegments = nonEmpty(groupCrumbs(ctx, input.groupChain));
1397
- if (action !== "create" && id === "") return {
1398
- resource,
1399
- leadingSegments
1400
- };
1401
- const recordLabel = input.title || id;
1402
- const middleSegments = action === "edit" ? [isShowAvailable(ctx.registry, resource) ? {
1403
- label: recordLabel,
1404
- href: resolveRoute(showTarget(resource, id), ctx.registry)
1405
- } : { label: recordLabel }] : void 0;
1406
- const pageLabel = action === "create" ? ctx.t("breadcrumbs.create") : action === "edit" ? ctx.t("breadcrumbs.edit") : recordLabel;
1407
- return {
1408
- resource,
1409
- recordId: action === "create" ? void 0 : id,
1410
- pageLabel,
1411
- leadingSegments,
1412
- middleSegments
1413
- };
1414
- }
1415
- function originRooted(ctx, input, origin) {
1416
- const { resource, action, id } = input;
1417
- const recordLabel = input.title || id;
1418
- const drawn = new Set(origin.segments.flatMap((crumb) => crumb.href === void 0 ? [] : [pathOf(crumb.href)]));
1419
- const own = action === "edit" ? [isShowAvailable(ctx.registry, resource) ? {
1420
- label: recordLabel,
1421
- href: resolveRoute(showTarget(resource, id), ctx.registry)
1422
- } : { label: recordLabel }].filter((crumb) => crumb.href === void 0 || !drawn.has(pathOf(crumb.href))) : [];
1423
- const pageLabel = action === "create" ? ctx.t("breadcrumbs.create") : action === "edit" ? ctx.t("breadcrumbs.edit") : recordLabel;
1424
- const recordId = action === "create" ? void 0 : id;
1425
- const middleSegments = nonEmpty([...origin.segments, ...own]);
1426
- if (origin.resource !== void 0 && ctx.registry.get(origin.resource) === ctx.registry.get(resource)) return {
1427
- resource,
1428
- recordId,
1429
- pageLabel,
1430
- leadingSegments: nonEmpty([...origin.leading]),
1431
- ...origin.resourceHref === void 0 ? {} : { resourceHref: origin.resourceHref },
1432
- middleSegments
1433
- };
1434
- const def = origin.resource === void 0 ? void 0 : ctx.registry.get(origin.resource);
1435
- const resourceCrumb = origin.resource === void 0 ? [] : [{
1436
- label: resolveResourceLabel(ctx.caps, origin.resource, "plural", def),
1437
- ...origin.resourceHref === void 0 ? {} : { href: origin.resourceHref }
1438
- }];
1439
- return {
1440
- resource,
1441
- recordId,
1442
- pageLabel,
1443
- rootSegments: [
1444
- ...origin.leading,
1445
- ...resourceCrumb,
1446
- ...origin.segments,
1447
- ...own
1448
- ]
1449
- };
1450
- }
1451
- function recordTrailRoute(registry, match) {
1452
- if (match === null || match.kind !== "resource") return null;
1453
- const resource = canonicalNavKey(match);
1454
- const { groupChain } = match;
1455
- if (match.action === "flow") return {
1456
- resource,
1457
- action: "show",
1458
- id: match.id ?? "",
1459
- flow: match.flow ?? "",
1460
- groupChain
1461
- };
1462
- const action = recordActionOf(match);
1463
- if (action === void 0 || !recordRouteAvailable(registry, resource, action)) return null;
1464
- return {
1465
- resource,
1466
- action,
1467
- id: action === "create" ? "" : match.id ?? "",
1468
- groupChain
1469
- };
1470
- }
1471
- function headerTrail(ctx, match) {
1472
- if (match === null) return null;
1473
- const key = canonicalNavKey(match);
1474
- switch (match.kind) {
1475
- case "resource": {
1476
- const leadingSegments = nonEmpty(groupCrumbs(ctx, match.groupChain));
1477
- const action = recordActionOf(match);
1478
- if (recordTrailRoute(ctx.registry, match) !== null) return null;
1479
- if (action === void 0) return {
1480
- resource: key,
1481
- leadingSegments
1482
- };
1483
- return {
1484
- resource: key,
1485
- recordId: match.id,
1486
- pageLabel: ctx.t("router.notFoundTitle"),
1487
- leadingSegments
1488
- };
1489
- }
1490
- case "custom-page": {
1491
- const page = ctx.registry.customPages.get(match.name);
1492
- if (page === void 0 || !ctx.isVisible(page)) return null;
1493
- return {
1494
- name: key,
1495
- pageLabel: resolveNavLabel(ctx.caps, `pages.${key}`, declaredText("chrome", page, "label")),
1496
- leadingSegments: nonEmpty(groupCrumbs(ctx, match.groupChain))
1497
- };
1498
- }
1499
- case "group-index": {
1500
- const own = match.groupChain[match.groupChain.length - 1];
1501
- if (own === void 0) return null;
1502
- const crumbs = groupCrumbs(ctx, match.groupChain);
1503
- const current = crumbs[crumbs.length - 1];
1504
- return {
1505
- name: canonicalNavKey(own),
1506
- pageLabel: current.label,
1507
- leadingSegments: nonEmpty(crumbs.slice(0, -1))
1508
- };
1509
- }
1510
- default: return null;
1511
- }
1512
- }
1513
- function recentStorageKey(userId) {
1514
- return `buro:recent:v2:${userId}`;
1515
- }
1516
- function isRecent(value) {
1517
- if (typeof value !== "object" || value === null) return false;
1518
- const entry = value;
1519
- return typeof entry.canonicalRef === "string" && typeof entry.id === "string" && typeof entry.label === "string" && (entry.labelField === void 0 || typeof entry.labelField === "string") && typeof entry.at === "string";
1520
- }
1521
- function parse(raw) {
1522
- if (raw === null) return [];
1523
- try {
1524
- const parsed = JSON.parse(raw);
1525
- if (typeof parsed !== "object" || parsed === null) return [];
1526
- const envelope = parsed;
1527
- if (envelope.version !== 2 || !Array.isArray(envelope.items)) return [];
1528
- return envelope.items.filter(isRecent);
1529
- } catch {
1530
- return [];
1531
- }
1532
- }
1533
- function readRecentRecords(store, userId) {
1534
- return maybeThen(settle(() => store.get(recentStorageKey(userId)), null), parse);
1535
- }
1536
- function writeRecentRecord(store, userId, entry) {
1537
- const key = recentStorageKey(userId);
1538
- return maybeThen(settle(() => store.get(key), null), (raw) => {
1539
- const envelope = {
1540
- version: 2,
1541
- items: [entry, ...parse(raw).filter((item) => !(item.canonicalRef === entry.canonicalRef && item.id === entry.id))].slice(0, 5)
1542
- };
1543
- return settle(() => store.set(key, JSON.stringify(envelope)), void 0);
1544
- });
1545
- }
1546
- function text(value) {
1547
- return typeof value === "string" && value.length > 0 ? value : void 0;
1548
- }
1549
- const RECENT_LABEL_KEYS = [
1550
- "alias",
1551
- "name",
1552
- "title",
1553
- "label"
1554
- ];
1555
- function recentLabel(record, id, isGuarded = () => false) {
1556
- for (const key of RECENT_LABEL_KEYS) {
1557
- if (isGuarded(key)) continue;
1558
- const value = text(record[key]);
1559
- if (value !== void 0) return {
1560
- label: value,
1561
- field: key
1562
- };
1563
- }
1564
- return { label: id };
1565
- }
1566
- //#endregion
1567
- //#region src/layout/use-record-visit.ts
1568
- function useRecordVisit(resource, record, opts) {
1569
- const userId = useCurrentUserId();
1570
- const store = usePlatformStorage().local;
1571
- const app = useApp();
1572
- const def = app.registry.get(resource);
1573
- const raw = recordKeyOf(def, record);
1574
- const id = typeof raw === "string" || typeof raw === "number" ? String(raw) : void 0;
1575
- const fields = def?.fields;
1576
- const rules = app.ruleSource?.rules(resource) ?? [];
1577
- const isGuarded = (field) => fields !== void 0 && Object.hasOwn(fields, field) && fieldSensitivity(fields[field]) !== void 0 || addressesCapability(rules, "view", {
1578
- kind: "field",
1579
- name: field
1580
- });
1581
- const picked = record != null && id !== void 0 ? recentLabel(record, id, isGuarded) : void 0;
1582
- const label = picked?.label;
1583
- const labelField = picked?.field;
1584
- const canonicalRef = canonicalResourceName(resource);
1585
- const { isCurrentData } = opts;
1586
- useEffect(() => {
1587
- if (userId === null || !isCurrentData || id === void 0 || id === "") return;
1588
- if (label === void 0) return;
1589
- writeRecentRecord(store, userId, {
1590
- canonicalRef,
1591
- id,
1592
- label,
1593
- ...labelField === void 0 ? {} : { labelField },
1594
- at: new Date().toISOString()
1595
- });
1596
- }, [
1597
- store,
1598
- userId,
1599
- isCurrentData,
1600
- canonicalRef,
1601
- id,
1602
- label,
1603
- labelField
1604
- ]);
1605
- }
1606
- //#endregion
1607
- //#region src/layout/record-page.tsx
1608
- function useMountedRef() {
1609
- const mounted = useRef(true);
1610
- useEffect(() => {
1611
- mounted.current = true;
1612
- return () => {
1613
- mounted.current = false;
1614
- };
1615
- }, []);
1616
- return mounted;
1617
- }
1618
- function RecordRouteHeader({ resource, action, id, record }) {
1619
- const recordName = useRecordTitle(resource, action === "create" ? void 0 : id, record);
1620
- usePublishRecordTrail(action === "create" ? null : {
1621
- key: recordTrailKey(resource, id, action),
1622
- title: recordName
1623
- });
1624
- return jsx(PageHeader, {
1625
- resource,
1626
- mode: action,
1627
- ...action === "create" ? {} : { recordName }
1628
- });
1629
- }
1630
- function RecordShow({ resource, id, recordId, record, shown }) {
1631
- return jsxs("div", { children: [jsx(RecordRouteHeader, {
1632
- resource,
1633
- action: "show",
1634
- id,
1635
- record: shown
1636
- }), jsx(RecordScreen, {
1637
- resource,
1638
- mode: "show",
1639
- recordId,
1640
- record
1641
- })] });
1642
- }
1643
- function RecordEdit({ resource, id, recordId, record, shown }) {
1644
- const navigate = useRouteNavigate();
1645
- const mounted = useMountedRef();
1646
- const back = useReturnTarget(resource, "edit", id);
1647
- return jsxs("div", { children: [jsx(RecordRouteHeader, {
1648
- resource,
1649
- action: "edit",
1650
- id,
1651
- record: shown
1652
- }), jsx(RecordScreen, {
1653
- resource,
1654
- mode: "edit",
1655
- recordId,
1656
- record,
1657
- onCancel: () => navigate(back, { origin: "inherit" }),
1658
- onSuccess: () => {
1659
- if (mounted.current) navigate(back, { origin: "inherit" });
1660
- }
1661
- })] });
1662
- }
1663
- function createdId(result) {
1664
- const id = result?.id;
1665
- return typeof id === "string" || typeof id === "number" ? String(id) : void 0;
1666
- }
1667
- function RecordCreate({ resource, defaults }) {
1668
- const app = useApp();
1669
- const navigate = useRouteNavigate();
1670
- const mounted = useMountedRef();
1671
- const adapter = useOptionalRouterAdapter();
1672
- const list = listTarget(resource);
1673
- const back = useReturnTarget(resource, "create");
1674
- const type = adapter?.searchParams.get("type") ?? void 0;
1675
- return jsxs("div", { children: [jsx(RecordRouteHeader, {
1676
- resource,
1677
- action: "create",
1678
- id: ""
1679
- }), jsx(RouteScreenClaimContext.Provider, {
1680
- value: true,
1681
- children: jsx(RecordScreen, {
1682
- resource,
1683
- mode: "create",
1684
- ...type === void 0 ? {} : { type },
1685
- ...defaults === void 0 ? {} : { defaults },
1686
- onCancel: () => navigate(back, { origin: "inherit" }),
1687
- onSuccess: (result) => {
1688
- if (!mounted.current) return;
1689
- const id = createdId(result);
1690
- navigate(id !== void 0 && isShowAvailable(app.registry, resource) ? showTarget(resource, id) : list, { origin: "inherit" });
1691
- }
1692
- })
1693
- })] });
1694
- }
1695
- function RecordRead({ resource, action, id, recordId }) {
1696
- const app = useApp();
1697
- const def = app.registry.get(resource);
1698
- const projection = useMemo(() => def === void 0 ? void 0 : dtoFields(def, "record"), [def]);
1699
- const query = useOne(resource, {
1700
- id: recordId,
1701
- retry: retryRecordRead,
1702
- ...projection === void 0 ? {} : { projection }
1703
- });
1704
- const result = query.data;
1705
- const read = result?.data;
1706
- const projected = useProjectedRecord(resource, read, { placeholder: query.isPlaceholderData });
1707
- const showAvailability = useAvailabilityResolver(resource, "show");
1708
- const permissions = useCtx((c) => c.permissions);
1709
- const showRuled = addressesCapability(app.ruleSource.rules(resource), "run", {
1710
- kind: "action",
1711
- name: "show"
1712
- });
1713
- const showHidden = showRuled && read !== null && typeof read === "object" && showAvailability("show", read).state !== "available";
1714
- const showSettled = !showRuled || !query.isPlaceholderData && permissions?.status !== "loading" && permissions?.status !== "error";
1715
- useRecordVisit(resource, projected.status === "ready" && showSettled && !showHidden ? projected.value : null, { isCurrentData: !query.isPlaceholderData });
1716
- const route = useMemo(() => Object.freeze({ id }), [id]);
1717
- const availability = useAvailabilityResolver(resource, "edit");
1718
- if (result !== void 0) {
1719
- const record = result.data;
1720
- if (record === null || typeof record !== "object") return jsx(RecordState, { state: "not-found" });
1721
- const loaded = record;
1722
- if (showRuled) {
1723
- if (query.isPlaceholderData || permissions?.status === "loading") return jsx(RecordState, { state: "loading" });
1724
- if (permissions?.status === "error") return jsx(RecordState, { state: "not-found" });
1725
- if (showHidden) return jsx(RecordState, { state: "not-found" });
1726
- }
1727
- if (projected.status === "pending" || projected.value === null) return jsx(RecordState, { state: "loading" });
1728
- const shown = projected.value;
1729
- if (action === "edit") {
1730
- const edit = availability("edit", loaded).state;
1731
- if (edit === "hidden" || edit === "absent") return jsx(RecordState, { state: "not-found" });
1732
- }
1733
- return jsx(RouteSourceContext.Provider, {
1734
- value: route,
1735
- children: jsx(RouteScreenClaimContext.Provider, {
1736
- value: true,
1737
- children: action === "edit" ? jsx(RecordEdit, {
1738
- resource,
1739
- id,
1740
- recordId,
1741
- record: loaded,
1742
- shown
1743
- }) : jsx(RecordShow, {
1744
- resource,
1745
- id,
1746
- recordId,
1747
- record: loaded,
1748
- shown
1749
- })
1750
- })
1751
- });
1752
- }
1753
- if (query.error != null) return jsx(LoadError, {
1754
- surface: "record",
1755
- resource,
1756
- error: query.error,
1757
- retry: () => void query.refetch()
1758
- });
1759
- return jsx(RecordState, { state: "loading" });
1760
- }
1761
- function RecordRouteBody(props) {
1762
- if (props.action === "create") return jsx(RecordCreate, { ...props });
1763
- if (props.id === "") return jsx(RecordState, { state: "not-found" });
1764
- return jsx(RecordReadRoute, { ...props });
1765
- }
1766
- function RecordReadRoute(props) {
1767
- const recordId = useRouteRecordId(props.resource, props.id);
1768
- if (recordId === void 0) return jsx(InvalidRouteId, { resource: props.resource });
1769
- return jsx(RecordRead, {
1770
- ...props,
1771
- recordId
1772
- });
1773
- }
1774
- function RecordRoute(props) {
1775
- const missingRuntime = useOptionalDataRuntime() === null;
1776
- useEffect(() => {
1777
- if (!missingRuntime || process.env.NODE_ENV === "production") return;
1778
- console.error(`[burojs] The '${props.resource}' record page has no data runtime to read or write with: BuroProvider.dataRuntime is not set. Pass <BuroProvider dataRuntime={…}> (createDataRuntime from @burojs/react); until then record routes render the error state.`);
1779
- }, [missingRuntime, props.resource]);
1780
- if (missingRuntime) return jsx(RecordState, { state: "error" });
1781
- return jsx(RecordRouteBody, { ...props }, `${props.resource}:${props.id}`);
1782
- }
1783
- function recordPageProblem(input) {
1784
- const { props, resource, action } = input;
1785
- if (resource === void 0 || action === void 0) return "[burojs] <RecordPage> needs both `resource` and `action`. Pass them; until then it renders not-found.";
1786
- if (!input.onRecordRoute) return `[burojs] <RecordPage resource="${resource}" action="${action}"> is not on a record route (show, edit or create), so it has no record to read: render it on one, under a RouterAdapterProvider. Until then it renders not-found.`;
1787
- if (props.defaults !== void 0 && action !== "create") return `[burojs] <RecordPage defaults> applies to create only; on this '${action}' route it is ignored.`;
1788
- return null;
1789
- }
1790
- const recordPageProblemsLogged = new WeakMap();
1791
- function RecordPage(props) {
1792
- const app = useApp();
1793
- const match = useMatch();
1794
- const id = match === null ? null : match.id ?? "";
1795
- const { action } = props;
1796
- const resource = props.resource === void 0 ? void 0 : routeResourceKey(props.resource);
1797
- const onRecordRoute = recordActionOf(match) !== void 0;
1798
- const problem = recordPageProblem({
1799
- props,
1800
- resource,
1801
- action,
1802
- onRecordRoute
1803
- });
1804
- useEffect(() => {
1805
- if (problem === null || process.env.NODE_ENV === "production") return;
1806
- let logged = recordPageProblemsLogged.get(app);
1807
- if (logged === void 0) {
1808
- logged = new Set();
1809
- recordPageProblemsLogged.set(app, logged);
1810
- }
1811
- if (logged.has(problem)) return;
1812
- logged.add(problem);
1813
- console.error(problem);
1814
- }, [app, problem]);
1815
- if (resource === void 0 || action === void 0 || id === null || !onRecordRoute) return jsx(RecordState, { state: "not-found" });
1816
- const route = action === "create" ? {
1817
- resource,
1818
- action,
1819
- defaults: props.defaults
1820
- } : {
1821
- resource,
1822
- action
1823
- };
1824
- return jsx(RecordRoute, {
1825
- ...route,
1826
- id
1827
- });
1828
- }
1829
- //#endregion
1830
- //#region src/layout/resource-page-router.tsx
1831
- function ResourcePageRouterEmpty() {
1832
- const t = useT();
1833
- return jsxs("div", {
1834
- "data-testid": "resource-page-router-empty",
1835
- className: "flex flex-col items-center justify-center gap-1 px-6 py-24 text-center",
1836
- children: [jsx("h2", {
1837
- className: "text-base font-semibold tracking-tight",
1838
- children: t("router.emptyTitle")
1839
- }), jsx("p", {
1840
- className: "max-w-sm text-sm text-muted-foreground",
1841
- children: t("router.emptyBody")
1842
- })]
1843
- });
1844
- }
1845
- function ResourcePageRouter({ match }) {
1846
- const app = useApp();
1847
- const qualifiedMatch = match;
1848
- const resource = canonicalNavKey(qualifiedMatch);
1849
- const target = canonicalNavKey({
1850
- name: match.target ?? match.name,
1851
- ref: qualifiedMatch.targetRef
1852
- });
1853
- const recordAction = recordActionOf(match);
1854
- switch (match.kind) {
1855
- case "resource":
1856
- if (match.action === "list") {
1857
- const def = app.registry.get(resource);
1858
- return def !== void 0 && !hasListPage(def) ? jsx(NavAreaNotFound, {}) : jsx(ResourceListPage, { resource });
1859
- }
1860
- if (match.action === "flow") return jsx(PageFlowRouteLoader, { match });
1861
- if (recordAction === void 0) return jsx(ResourcePageRouterEmpty, {});
1862
- if (!recordRouteAvailable(app.registry, resource, recordAction)) return jsx(NavAreaNotFound, {});
1863
- return jsx(RecordRoute, {
1864
- resource,
1865
- action: recordAction,
1866
- id: match.id ?? ""
1867
- });
1868
- case "custom-page": {
1869
- const page = app.registry.customPages.get(resource);
1870
- if (page === void 0) return jsx(ResourcePageRouterEmpty, {});
1871
- if (!page.body?.length) return jsx(NavAreaNotFound, {});
1872
- return jsx(PageHost, {
1873
- page,
1874
- match,
1875
- notFound: jsx(NavAreaNotFound, {})
1876
- }, resource);
1877
- }
1878
- case "group-index": {
1879
- const indexPage = app.registry.customPages.get(target);
1880
- if (indexPage?.body?.length) return jsx(PageHost, {
1881
- page: indexPage,
1882
- match,
1883
- notFound: jsx(NavAreaNotFound, {})
1884
- }, target);
1885
- const targetDef = app.registry.get(target);
1886
- if (targetDef !== void 0) return hasListPage(targetDef) ? jsx(ResourceListPage, { resource: target }) : jsx(NavAreaNotFound, {});
1887
- return jsx(ResourcePageRouterEmpty, {});
1888
- }
1889
- default: return jsx(ResourcePageRouterEmpty, {});
1890
- }
1891
- }
1892
- function NavAreaPageSkeleton() {
1893
- return jsxs("div", {
1894
- className: "space-y-3 p-6",
1895
- role: "status",
1896
- "aria-busy": "true",
1897
- "aria-live": "polite",
1898
- "data-testid": "nav-area-skeleton",
1899
- children: [
1900
- jsx("span", {
1901
- className: "sr-only",
1902
- children: "Loading…"
1903
- }),
1904
- jsx("div", { className: "h-6 w-48 animate-pulse rounded bg-muted/60" }),
1905
- jsx("div", { className: "h-4 w-full animate-pulse rounded bg-muted/40" }),
1906
- jsx("div", { className: "h-4 w-5/6 animate-pulse rounded bg-muted/40" }),
1907
- jsx("div", { className: "h-4 w-2/3 animate-pulse rounded bg-muted/40" })
1908
- ]
1909
- });
1910
- }
1911
- function NavAreaNotFound() {
1912
- const t = useT();
1913
- return jsxs("div", {
1914
- "data-testid": "nav-area-not-found",
1915
- className: "flex flex-col items-center justify-center gap-1 px-6 py-24 text-center",
1916
- children: [jsx("h2", {
1917
- className: "text-base font-semibold tracking-tight",
1918
- children: t("router.notFoundTitle")
1919
- }), jsx("p", {
1920
- className: "max-w-sm text-sm text-muted-foreground",
1921
- children: t("router.notFoundBody")
1922
- })]
1923
- });
1924
- }
1925
- const adapterNoticeGiven = new WeakSet();
1926
- const chromeNoticeGiven = new WeakSet();
1927
- function NavAreaPage() {
1928
- const match = useMatch();
1929
- const app = useApp();
1930
- const noAdapter = useOptionalRouterAdapter() === null;
1931
- const chromeMounted = useNavChromeMounted();
1932
- const resolveLayout = useLayoutResolver();
1933
- const chromeGroup = match?.groupChain.find((g) => resolveLayout(g.layout)) ?? null;
1934
- useEffect(() => {
1935
- if (process.env.NODE_ENV === "production") return;
1936
- if (chromeMounted || !chromeGroup || chromeNoticeGiven.has(app)) return;
1937
- chromeNoticeGiven.add(app);
1938
- console.error(`[burojs] <NavAreaPage> is inside the nav group "${canonicalNavKey(chromeGroup)}" whose layout "${chromeGroup.layout}" draws area chrome, and no <NavChrome> is mounted above it. <AppShell> mounts one by default; with your own frame, wrap your routes in <NavChrome>.`);
1939
- }, [
1940
- app,
1941
- chromeMounted,
1942
- chromeGroup
1943
- ]);
1944
- useEffect(() => {
1945
- if (!noAdapter || process.env.NODE_ENV === "production") return;
1946
- if (adapterNoticeGiven.has(app)) return;
1947
- adapterNoticeGiven.add(app);
1948
- console.error("[burojs] <NavAreaPage> has no location to match: no RouterAdapterProvider is mounted. Mount your router’s adapter (RouterAdapterProvider from @burojs/react) above <BuroProvider>; until then every route renders not-found.");
1949
- }, [app, noAdapter]);
1950
- return jsx(Suspense, {
1951
- fallback: jsx(NavAreaPageSkeleton, {}),
1952
- children: match ? jsx(ResourcePageRouter, { match }) : jsx(NavAreaNotFound, {})
1953
- });
1954
- }
1955
- //#endregion
1956
- export { useLayoutResolver as A, useMatch as C, BUILTIN_LAYOUTS as D, useResourceVisible as E, canonicalResourceKey$1 as F, TabsLayout as M, SecondarySidebarLayout as N, layoutSlot as O, canonicalNavKey as P, useHref as S, usePageAllowed as T, RecordScreen as _, useRecordVisit as a, ResourceListPage as b, headerTrail as c, recordTrailRoute as d, useTrailContext as f, usePublishedRecordTrail as g, usePublishRecordTrail as h, RecordPage as i, useReportUnresolvedLayouts as j, useLayout as k, originTrail as l, recordTrailKey as m, NavAreaPage as n, RECENT_LABEL_KEYS as o, isShowAvailable as p, ResourcePageRouter as r, readRecentRecords as s, NavAreaNotFound as t, recordTrail as u, useResourceDimensionOptions as v, useNavVisible as w, NavChromeMountedProvider as x, PlannedBody as y };
1957
-
1958
- //# sourceMappingURL=resource-page-router-BRpUnhay.js.map