@burojs/ui-shadcn 0.4.0 → 0.6.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 (131) hide show
  1. package/README.md +22 -5
  2. package/dist/bulk-summary-CwSd6Yjb.cjs +108 -0
  3. package/dist/bulk-summary-CwSd6Yjb.cjs.map +1 -0
  4. package/dist/bulk-summary-GxMDP4bw.js +108 -0
  5. package/dist/bulk-summary-GxMDP4bw.js.map +1 -0
  6. package/dist/button-BxnnE28H.cjs +55 -0
  7. package/dist/button-BxnnE28H.cjs.map +1 -0
  8. package/dist/button-MWVeZaqj.js +44 -0
  9. package/dist/button-MWVeZaqj.js.map +1 -0
  10. package/dist/candidates-gate-Bb70LPAy.js +135 -0
  11. package/dist/candidates-gate-Bb70LPAy.js.map +1 -0
  12. package/dist/candidates-gate-D33jXLHO.cjs +153 -0
  13. package/dist/candidates-gate-D33jXLHO.cjs.map +1 -0
  14. package/dist/candidates-relation-picker-B116Bmqi.js +31 -0
  15. package/dist/candidates-relation-picker-B116Bmqi.js.map +1 -0
  16. package/dist/candidates-relation-picker-Cy0rTxvI.cjs +31 -0
  17. package/dist/candidates-relation-picker-Cy0rTxvI.cjs.map +1 -0
  18. package/dist/check-confirm-dialog--gPFnEeg.cjs +1547 -0
  19. package/dist/check-confirm-dialog--gPFnEeg.cjs.map +1 -0
  20. package/dist/check-confirm-dialog-bRT8lt0d.js +1245 -0
  21. package/dist/check-confirm-dialog-bRT8lt0d.js.map +1 -0
  22. package/dist/dialog-B_rt9S1c.js +63 -0
  23. package/dist/dialog-B_rt9S1c.js.map +1 -0
  24. package/dist/dialog-DRNUq9EA.cjs +112 -0
  25. package/dist/dialog-DRNUq9EA.cjs.map +1 -0
  26. package/dist/filter-builder-Bhn-dhZV.js +1621 -0
  27. package/dist/filter-builder-Bhn-dhZV.js.map +1 -0
  28. package/dist/filter-builder-nXqtM_h4.cjs +1789 -0
  29. package/dist/filter-builder-nXqtM_h4.cjs.map +1 -0
  30. package/dist/flow-runtime-D3avVH0I.cjs +255 -0
  31. package/dist/flow-runtime-D3avVH0I.cjs.map +1 -0
  32. package/dist/flow-runtime-s6lkRPKF.js +252 -0
  33. package/dist/flow-runtime-s6lkRPKF.js.map +1 -0
  34. package/dist/flow-screen-CCvgDI9G.js +704 -0
  35. package/dist/flow-screen-CCvgDI9G.js.map +1 -0
  36. package/dist/flow-screen-Ci_Sik4Y.cjs +708 -0
  37. package/dist/flow-screen-Ci_Sik4Y.cjs.map +1 -0
  38. package/dist/index.cjs +3420 -11986
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +1843 -2015
  41. package/dist/index.d.ts +1849 -2021
  42. package/dist/index.js +3090 -11675
  43. package/dist/index.js.map +1 -1
  44. package/dist/inline-flow-host-B6FI0ctQ.js +112 -0
  45. package/dist/inline-flow-host-B6FI0ctQ.js.map +1 -0
  46. package/dist/inline-flow-host-DV1et3c6.cjs +112 -0
  47. package/dist/inline-flow-host-DV1et3c6.cjs.map +1 -0
  48. package/dist/input-BI0czGyI.cjs +23 -0
  49. package/dist/input-BI0czGyI.cjs.map +1 -0
  50. package/dist/input-CUPStzZO.js +17 -0
  51. package/dist/input-CUPStzZO.js.map +1 -0
  52. package/dist/label-66W1qbke.js +29 -0
  53. package/dist/label-66W1qbke.js.map +1 -0
  54. package/dist/label-w6JYf2cF.cjs +36 -0
  55. package/dist/label-w6JYf2cF.cjs.map +1 -0
  56. package/dist/markdown/index.cjs +1 -1
  57. package/dist/markdown/index.d.cts +2 -3
  58. package/dist/markdown/index.d.ts +2 -3
  59. package/dist/markdown/index.js +1 -1
  60. package/dist/page-flow-route-hdnULWqd.cjs +277 -0
  61. package/dist/page-flow-route-hdnULWqd.cjs.map +1 -0
  62. package/dist/page-flow-route-i3ZfJ1sd.js +277 -0
  63. package/dist/page-flow-route-i3ZfJ1sd.js.map +1 -0
  64. package/dist/place-node-C5SmIAYU.cjs +8139 -0
  65. package/dist/place-node-C5SmIAYU.cjs.map +1 -0
  66. package/dist/place-node-NraNYKPx.js +7597 -0
  67. package/dist/place-node-NraNYKPx.js.map +1 -0
  68. package/dist/related-list-cards-BWZ9GfOG.js +42 -0
  69. package/dist/related-list-cards-BWZ9GfOG.js.map +1 -0
  70. package/dist/related-list-cards-CFq3meUn.cjs +42 -0
  71. package/dist/related-list-cards-CFq3meUn.cjs.map +1 -0
  72. package/dist/related-list-timeline-CCzl71aA.cjs +142 -0
  73. package/dist/related-list-timeline-CCzl71aA.cjs.map +1 -0
  74. package/dist/related-list-timeline-yrPsjA3F.js +142 -0
  75. package/dist/related-list-timeline-yrPsjA3F.js.map +1 -0
  76. package/dist/related-rows-ea43qhhy.cjs +208 -0
  77. package/dist/related-rows-ea43qhhy.cjs.map +1 -0
  78. package/dist/related-rows-o0_t-Yce.js +185 -0
  79. package/dist/related-rows-o0_t-Yce.js.map +1 -0
  80. package/dist/relation-create-IA40t1hi.cjs +364 -0
  81. package/dist/relation-create-IA40t1hi.cjs.map +1 -0
  82. package/dist/relation-create-h6F9B4C4.js +339 -0
  83. package/dist/relation-create-h6F9B4C4.js.map +1 -0
  84. package/dist/relation-many-picker-C8zFEjwd.cjs +467 -0
  85. package/dist/relation-many-picker-C8zFEjwd.cjs.map +1 -0
  86. package/dist/relation-many-picker-bvkjkv-k.js +466 -0
  87. package/dist/relation-many-picker-bvkjkv-k.js.map +1 -0
  88. package/dist/relation-picker-Z0ZJJ5uS.js +493 -0
  89. package/dist/relation-picker-Z0ZJJ5uS.js.map +1 -0
  90. package/dist/relation-picker-dialog-0IzkjmiA.cjs +304 -0
  91. package/dist/relation-picker-dialog-0IzkjmiA.cjs.map +1 -0
  92. package/dist/relation-picker-dialog-B6nIiJBf.js +303 -0
  93. package/dist/relation-picker-dialog-B6nIiJBf.js.map +1 -0
  94. package/dist/relation-picker-gag0qSR5.cjs +516 -0
  95. package/dist/relation-picker-gag0qSR5.cjs.map +1 -0
  96. package/dist/resource-page-router-3RUf9d1j.js +1588 -0
  97. package/dist/resource-page-router-3RUf9d1j.js.map +1 -0
  98. package/dist/resource-page-router-PXfMW9nh.cjs +1785 -0
  99. package/dist/resource-page-router-PXfMW9nh.cjs.map +1 -0
  100. package/dist/{rich-text-IDFvyvRE.js → rich-text-DFerywgz.js} +7 -4
  101. package/dist/{rich-text-IDFvyvRE.js.map → rich-text-DFerywgz.js.map} +1 -1
  102. package/dist/{rich-text-lndbYqzR.cjs → rich-text-vTyVjDoa.cjs} +25 -22
  103. package/dist/{rich-text-lndbYqzR.cjs.map → rich-text-vTyVjDoa.cjs.map} +1 -1
  104. package/dist/search-access-CPPmfuvy.js +654 -0
  105. package/dist/search-access-CPPmfuvy.js.map +1 -0
  106. package/dist/search-access-Dugvttlg.cjs +791 -0
  107. package/dist/search-access-Dugvttlg.cjs.map +1 -0
  108. package/dist/shell-BPlk8hEa.js +205 -0
  109. package/dist/shell-BPlk8hEa.js.map +1 -0
  110. package/dist/shell-DxhlsPwm.cjs +271 -0
  111. package/dist/shell-DxhlsPwm.cjs.map +1 -0
  112. package/dist/skeleton-U2noefj5.js +13 -0
  113. package/dist/skeleton-U2noefj5.js.map +1 -0
  114. package/dist/skeleton-_1gP7wan.cjs +18 -0
  115. package/dist/skeleton-_1gP7wan.cjs.map +1 -0
  116. package/dist/styles.css +241 -9
  117. package/dist/toaster-C02XbB9r.js +135 -0
  118. package/dist/toaster-C02XbB9r.js.map +1 -0
  119. package/dist/toaster-Cr51X7bz.cjs +195 -0
  120. package/dist/toaster-Cr51X7bz.cjs.map +1 -0
  121. package/dist/use-dialog-filter-state-C--oMAZG.js +87 -0
  122. package/dist/use-dialog-filter-state-C--oMAZG.js.map +1 -0
  123. package/dist/use-dialog-filter-state-Dhe8PcB5.cjs +92 -0
  124. package/dist/use-dialog-filter-state-Dhe8PcB5.cjs.map +1 -0
  125. package/dist/{use-theme-BwPWinB2.cjs → use-theme-DFlpXils.cjs} +12 -1
  126. package/dist/use-theme-DFlpXils.cjs.map +1 -0
  127. package/dist/{use-theme-IHmtrhEt.js → use-theme-dnE3Od3I.js} +7 -2
  128. package/dist/use-theme-dnE3Od3I.js.map +1 -0
  129. package/package.json +16 -14
  130. package/dist/use-theme-BwPWinB2.cjs.map +0 -1
  131. package/dist/use-theme-IHmtrhEt.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"place-node-NraNYKPx.js","names":["EMPTY_ISSUES","i18nPrefixToRef","Table","UITable","exhaustive","useNotImplemented","lazyViews"],"sources":["../src/shell/shell-context.tsx","../src/screen/tree-context.ts","../src/fields/display-value.ts","../src/fields/legacy-field.ts","../src/fields/resolved-field.tsx","../src/forms/field.tsx","../src/screen/field-leaf.tsx","../src/blocks/facts-view.tsx","../src/blocks/placement-frame.ts","../src/flows/app-flow-button.tsx","../src/flows/inline-flow-view.tsx","../src/quick/use-deep-link.ts","../src/blocks/placement-seeds.ts","../src/enum/enum-badge.tsx","../src/export/download.ts","../src/export/run-watcher.ts","../src/actions/action-overflow.tsx","../src/layout/record-targets.ts","../src/lib/typography.ts","../src/layout/document-title.tsx","../src/resource/page-header.tsx","../src/blocks/related-skeletons.tsx","../src/blocks/related-item.tsx","../src/primitives/tabs.tsx","../src/screen/node-parts.tsx","../src/frames/builtin-nodes.tsx","../src/primitives/checkbox.tsx","../src/lib/use-container-narrow.ts","../src/data-table/data-table.tsx","../src/resource/column-header-menu.tsx","../src/resource/column-accessor.ts","../src/resource/column-target.ts","../src/data-table/use-buro-data-table.ts","../src/resource/list-error-state.tsx","../src/list-kit/cursor-load-more.tsx","../src/resource/resource-list.tsx","../src/list-kit/pieces/piece.tsx","../src/list-kit/pieces/pieces-context.tsx","../src/list-kit/pieces/list-body.tsx","../src/record/route-screen-context.ts","../src/screen/use-tabs-url-state.ts","../src/frames/node-host.tsx","../src/screen/nodes.tsx","../src/screen/screen-tree.tsx","../src/forms/declarative-form.tsx","../src/export/format-option-labels.ts","../src/export/export-dialog.tsx","../src/flows/bulk-flow-button.tsx","../src/actions/bulk-action-toolbar.tsx","../src/list-kit/pieces/list-bulk-bar.tsx","../src/data-table/data-table-view-options.tsx","../src/list-kit/columns-toggle.tsx","../src/list-kit/pieces/list-columns.tsx","../src/resource/create-button.tsx","../src/list-kit/pieces/list-create.tsx","../src/export/export-button.tsx","../src/list-kit/pieces/list-export.tsx","../src/list-kit/list-search-input.tsx","../src/list-kit/filter-builder/filter-region.tsx","../src/list-kit/pieces/list-filters.tsx","../src/list-kit/pieces/list-flows.tsx","../src/list-kit/pieces/list-live.tsx","../src/saved-views/saved-views-dropdown.tsx","../src/list-kit/pieces/list-saved-views.tsx","../src/list-kit/pieces/list-controls.tsx","../src/frames/builtin-list.tsx","../src/frames/builtin-page.tsx","../src/frames/builtin-peek.tsx","../src/record/frame-context.ts","../src/record/frame-pieces.tsx","../src/frames/builtin-record.tsx","../src/frames/builtin.ts","../src/frames/resolve.ts","../src/list-kit/list-frame-host.tsx","../src/list-kit/resource-list-surface.tsx","../src/quick/peek-filter.ts","../src/blocks/related-list-unbound.tsx","../src/blocks/link-panel.tsx","../src/blocks/route-list-context.ts","../src/blocks/related-list-view.tsx","../src/blocks/related-record-view.tsx","../src/blocks/builtins.ts","../src/blocks/place-node.tsx"],"sourcesContent":["'use client';\nimport { createContext, useContext, useMemo, type ReactElement, type ReactNode } from 'react';\n\nexport interface ShellBrand {\n readonly name: string;\n readonly subtitle?: string;\n readonly logo?: ReactNode;\n /** Where the brand links to. Default `'/'`. */\n readonly homePath?: string;\n}\n\nexport interface ShellUser {\n readonly name: string;\n readonly email?: string;\n readonly avatarUrl?: string;\n readonly initials: string;\n}\n\n/** Maps the auth provider's identity to what the shell shows. `initials` is derived from `name`. */\nexport type ShellUserMapper = (identity: unknown) => Omit<ShellUser, 'initials'>;\n\nexport interface ShellContextValue {\n readonly brand?: ShellBrand;\n readonly mapUser: ShellUserMapper;\n /** Where sign-out and \"Sign in\" go. Default `'/login'`. */\n readonly loginPath: string;\n /** Set only when a command palette is mounted. */\n readonly openPalette?: () => void;\n /** The mounted palette's open state; `AppShell` sets it unless `palette={false}`. Read it with {@link usePaletteState}. */\n readonly palette?: PaletteState;\n}\n\nexport interface PaletteState {\n readonly open: boolean;\n readonly setOpen: (open: boolean) => void;\n}\n\nfunction str(value: unknown): string | undefined {\n if (typeof value === 'string') return value.length > 0 ? value : undefined;\n if (typeof value === 'number' || typeof value === 'bigint') return String(value);\n return undefined;\n}\n\n/** `name`, else `email`, else `id` for the name; `email`; `avatarUrl` else `avatar`. */\nexport function defaultUserMapper(identity: unknown): Omit<ShellUser, 'initials'> {\n const record: Record<string, unknown> =\n typeof identity === 'object' && identity !== null ? (identity as Record<string, unknown>) : {};\n const email = str(record.email);\n const avatarUrl = str(record.avatarUrl) ?? str(record.avatar);\n return {\n name: str(record.name) ?? email ?? str(record.id) ?? '',\n ...(email !== undefined ? { email } : {}),\n ...(avatarUrl !== undefined ? { avatarUrl } : {}),\n };\n}\n\nconst DEFAULT_VALUE: ShellContextValue = Object.freeze({\n mapUser: defaultUserMapper,\n loginPath: '/login',\n});\n\nconst ShellContext = createContext<ShellContextValue>(DEFAULT_VALUE);\n\nexport type ShellProviderProps = Partial<ShellContextValue> & { readonly children: ReactNode };\n\nexport function ShellProvider({\n brand,\n mapUser,\n loginPath,\n openPalette,\n palette,\n children,\n}: ShellProviderProps): ReactElement {\n // Keyed on the brand's fields, not its identity: an inline `brand={{ … }}` is a new object on\n // every render, and must not re-render every shell consumer when nothing in it changed.\n const brandName = brand?.name;\n const brandSubtitle = brand?.subtitle;\n const brandLogo = brand?.logo;\n const brandHomePath = brand?.homePath;\n const stableBrand = useMemo<ShellBrand | undefined>(\n () =>\n brandName === undefined\n ? undefined\n : {\n name: brandName,\n ...(brandSubtitle !== undefined ? { subtitle: brandSubtitle } : {}),\n ...(brandLogo !== undefined ? { logo: brandLogo } : {}),\n ...(brandHomePath !== undefined ? { homePath: brandHomePath } : {}),\n },\n [brandName, brandSubtitle, brandLogo, brandHomePath],\n );\n const setPaletteOpen = palette?.setOpen;\n const open = useMemo(\n () => openPalette ?? (setPaletteOpen !== undefined ? () => setPaletteOpen(true) : undefined),\n [openPalette, setPaletteOpen],\n );\n const value = useMemo<ShellContextValue>(\n () => ({\n ...(stableBrand !== undefined ? { brand: stableBrand } : {}),\n mapUser: mapUser ?? defaultUserMapper,\n loginPath: loginPath ?? '/login',\n ...(open !== undefined ? { openPalette: open } : {}),\n ...(palette !== undefined ? { palette } : {}),\n }),\n [stableBrand, mapUser, loginPath, open, palette],\n );\n return <ShellContext.Provider value={value}>{children}</ShellContext.Provider>;\n}\n\n/** Outside a `ShellProvider`: no brand, the default mapper, `/login`. */\nexport function useShell(): ShellContextValue {\n return useContext(ShellContext);\n}\n\n/**\n * The palette's `open` and `setOpen`, for a custom `AppShell palette={<MyPalette/>}`, which\n * receives no props. Throws outside an `AppShell` (or a `ShellProvider` given `palette`).\n */\nexport function usePaletteState(): PaletteState {\n const { palette } = useContext(ShellContext);\n if (palette === undefined) {\n throw new Error(\n '[buro] usePaletteState must be used inside <AppShell> (or <ShellProvider palette={…}>)',\n );\n }\n return palette;\n}\n","'use client';\nimport type { CompiledScreen, ScreenMode } from '@burojs/core';\nimport type { FieldBinding, FormController } from '@burojs/react';\nimport { type ReactNode, createContext, useContext, useEffect, useRef } from 'react';\n\n/**\n * Which test ids a field leaf emits: the record ids (`form-field:…`,\n * `show-field:…`), or a resource-less form's (`<prefix>:field:<name>:hint`,\n * `…:info`) and none of the record ones.\n */\nexport type LeafIdScheme =\n | 'record'\n | {\n readonly prefix: string;\n /** The input ids' prefix (`<inputIds>-<name>`), so a host can focus a field by name. */\n readonly inputIds?: string;\n };\n\n/** A per-field render override: the binding and the default leaf node. */\nexport type RenderFieldOverrides = Readonly<\n Record<string, (binding: FieldBinding, defaultNode: ReactNode) => ReactNode>\n>;\n\n/** What every node of one rendered screen tree reads. */\nexport interface ScreenTreeValue {\n /** The resource's canonical name: test ids and bundle keys use it. */\n readonly resource: string;\n readonly mode: ScreenMode;\n readonly compiled: CompiledScreen;\n readonly controller: FormController;\n readonly region: 'record' | 'form-body' | 'page-body';\n /**\n * The tree is inside the `<form>` (edit and create: a record's `body`, or a form body): a\n * panel's body is a `fieldset` (P6-17). A display slot is never in the form.\n */\n readonly form: boolean;\n readonly leafIds: LeafIdScheme;\n readonly renderField?: RenderFieldOverrides;\n /** A whole-form lock (`<DeclarativeForm disabled>`): every input renders disabled. */\n readonly disabled?: boolean;\n /** Fields whose leaves render absent: a peek's fields it may not show (P3-38, P6-66). */\n readonly hiddenFields?: ReadonlySet<string>;\n}\n\nexport const ScreenTreeContext = createContext<ScreenTreeValue | null>(null);\n\n/** The tree being rendered; a node component outside `ScreenTree` is a framework bug. */\nexport function useScreenTree(): ScreenTreeValue {\n const tree = useContext(ScreenTreeContext);\n if (tree === null) throw new Error('[burojs] A screen node rendered outside <ScreenTree>.');\n return tree;\n}\n\n/** Registers `reveal` for a node id while mounted; the latest callback is the one called. */\nexport function useReveal(nodeId: string, reveal: () => void): void {\n const { controller } = useScreenTree();\n const latest = useRef(reveal);\n latest.current = reveal;\n const { registerReveal } = controller;\n useEffect(() => registerReveal(nodeId, () => latest.current()), [registerReveal, nodeId]);\n}\n","/**\n * Render an arbitrary field value as display text.\n *\n * Exists because the same defect was fixed twice and missed once. `String(value)`\n * on an object yields the literal «[object Object]» — what a jsonb column becomes\n * on screen. The guard was added to `TextDisplay`, but `f.json` routes to\n * `TextareaDisplay`, which still had the bare `String(value)`; an acceptance\n * review found «[object Object]» on every `code_code` record, on the exact\n * resource the fix claimed to cover.\n *\n * One helper, used by both renderers, so the two cannot drift again.\n */\nexport function toDisplayText(value: unknown): { text: string; isStructured: boolean } {\n if (typeof value !== 'object' || value === null) {\n return { text: String(value), isStructured: false };\n }\n try {\n return { text: JSON.stringify(value, null, 2), isStructured: true };\n } catch {\n // Circular or otherwise unserialisable — a shape hint beats a lie.\n return {\n text: Array.isArray(value) ? `[${(value as unknown[]).length}]` : '{…}',\n isStructured: true,\n };\n }\n}\n","import { declaredText, type FieldDeclaration } from '@burojs/core';\n\n/**\n * The native builder's historical `kind` is inert declaration data. During\n * migration, lower it once to the same semantic shape that a raw config uses;\n * consumers must not each invent a renderer-specific fallback.\n */\nexport interface LegacyFieldLike {\n readonly declaration?: FieldDeclaration;\n readonly type?: string;\n readonly kind?: string;\n /**\n * `opts` and `ui` are opaque host-local bags: the lowering below reads them\n * only through own-property descriptors (`ownData`), never by index. They\n * are typed `object` rather than `Record<string, unknown>` on purpose — an\n * index signature would reject every real field type (`FileFieldOpts`,\n * `FieldUiSelection`, …), which is what forced `as LegacyFieldLike` casts\n * on callers passing the framework's own declarations.\n */\n readonly opts?: object;\n readonly format?: string;\n readonly items?: FieldDeclaration;\n readonly meta?: Readonly<Record<string, unknown>>;\n readonly ui?: object;\n readonly required?: boolean;\n readonly nullable?: boolean;\n}\n\n/**\n * A semantic declaration plus UI-only hints retained at the rendering edge.\n * `ui` remains outside `FieldDeclaration`: it participates in host renderer\n * selection/props, never in portable model compilation or runtime attachment\n * registration.\n */\nexport type LoweredLegacyFieldSource = FieldDeclaration &\n Readonly<{\n ui?: Readonly<Record<string, unknown>>;\n }>;\n\ntype LegacyMapping = Readonly<{\n type: string;\n format?: string;\n items?: FieldDeclaration;\n}>;\n\nconst STRING_ITEM: FieldDeclaration = Object.freeze({ type: 'string' });\n\nconst LEGACY_KIND_DECLARATIONS: Readonly<Record<string, LegacyMapping>> = Object.freeze({\n string: { type: 'string' },\n text: { type: 'string', format: 'text' },\n textarea: { type: 'string', format: 'textarea' },\n code: { type: 'string', format: 'code' },\n email: { type: 'string', format: 'email' },\n url: { type: 'string', format: 'url' },\n uuid: { type: 'string', format: 'uuid' },\n number: { type: 'number' },\n boolean: { type: 'boolean' },\n date: { type: 'string', format: 'date' },\n dateTime: { type: 'string', format: 'date-time' },\n enum: { type: 'string', format: 'enum' },\n json: { type: 'object', format: 'json' },\n richText: { type: 'string', format: 'rich-text' },\n file: { type: 'array', format: 'file', items: STRING_ITEM },\n relation: { type: 'relation' },\n relationMany: { type: 'array', format: 'relation', items: STRING_ITEM },\n});\n\nconst SEMANTIC_KEYS = Object.freeze([\n 'type',\n 'format',\n 'meta',\n 'required',\n 'nullable',\n 'empty',\n 'default',\n 'constraints',\n 'texts',\n 'options',\n 'items',\n 'properties',\n 'additionalProperties',\n 'variants',\n] as const);\n\ntype SemanticKey = (typeof SEMANTIC_KEYS)[number];\ntype OwnData = Readonly<{ readonly present: boolean; readonly value?: unknown }>;\n\n/** Read only own data properties: getters and inherited legacy attachments never cross the host boundary. */\nfunction ownData(value: unknown, key: PropertyKey): OwnData {\n if (value === null || (typeof value !== 'object' && typeof value !== 'function'))\n return { present: false };\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (\n descriptor === undefined ||\n !Object.prototype.propertyIsEnumerable.call(value, key) ||\n !('value' in descriptor)\n ) {\n return { present: false };\n }\n return { present: true, value: descriptor.value };\n}\n\nfunction ownString(value: unknown, key: PropertyKey): string | undefined {\n const candidate = ownData(value, key).value;\n return typeof candidate === 'string' && candidate.length > 0 ? candidate : undefined;\n}\n\n/** Keep only portable implementation-selection ids in a semantic declaration. */\nfunction projectUiSelection(input: unknown): FieldDeclaration['ui'] | undefined {\n const selection: { input?: string; display?: string } = {};\n const inputId = ownString(input, 'input');\n const displayId = ownString(input, 'display');\n if (inputId !== undefined) selection.input = inputId;\n if (displayId !== undefined) selection.display = displayId;\n return inputId === undefined && displayId === undefined ? undefined : Object.freeze(selection);\n}\n\n/**\n * Strictly project a native/legacy object into `FieldDeclaration`. This is a\n * boundary projection, not declaration validation: it intentionally drops\n * builder-only `schema`, `opts`, `kind`, codecs, and arbitrary attachments.\n */\nfunction projectFieldDeclaration(input: unknown): FieldDeclaration | undefined {\n const type = ownString(input, 'type');\n if (type === undefined) return undefined;\n const projected: Record<SemanticKey | 'ui', unknown> = { type } as Record<\n SemanticKey | 'ui',\n unknown\n >;\n for (const key of SEMANTIC_KEYS) {\n if (key === 'type' || key === 'items' || key === 'properties' || key === 'variants') continue;\n const candidate = ownData(input, key);\n if (candidate.present && candidate.value !== undefined) projected[key] = candidate.value;\n }\n const ui = projectUiSelection(ownData(input, 'ui').value);\n if (ui !== undefined) projected.ui = ui;\n if (type === 'array') {\n const item = projectFieldDeclaration(ownData(input, 'items').value);\n if (item !== undefined) projected.items = item;\n }\n if (type === 'object') {\n const properties = ownData(input, 'properties').value;\n if (properties !== null && typeof properties === 'object' && !Array.isArray(properties)) {\n const output: Record<string, FieldDeclaration> = {};\n for (const key of Object.keys(properties)) {\n const child = projectFieldDeclaration(ownData(properties, key).value);\n if (child !== undefined) output[key] = child;\n }\n projected.properties = Object.freeze(output);\n }\n }\n if (type === 'union') {\n const variants = ownData(input, 'variants').value;\n if (Array.isArray(variants)) {\n const output: FieldDeclaration[] = [];\n for (let index = 0; index < variants.length; index += 1) {\n const child = projectFieldDeclaration(ownData(variants, index).value);\n if (child !== undefined) output.push(child);\n }\n projected.variants = Object.freeze(output);\n }\n }\n return Object.freeze(projected) as FieldDeclaration;\n}\n\n/** Preserve only original, enumerable own UI hints for a host implementation. */\nfunction projectUiHints(input: unknown): Readonly<Record<string, unknown>> | undefined {\n if (input === null || typeof input !== 'object' || Array.isArray(input)) return undefined;\n const projected: Record<string, unknown> = {};\n for (const key of Object.keys(input)) {\n const candidate = ownData(input, key);\n if (candidate.present) projected[key] = candidate.value;\n }\n return Object.freeze(projected);\n}\n\n/**\n * Return an immutable semantic field declaration for either native semantic\n * data or a legacy builder kind. Unknown kinds retain their name as a format\n * on an `unknown` base, so a host catalog may still handle them without\n * implying a primitive value type.\n */\nexport function lowerLegacyField(field: LegacyFieldLike): FieldDeclaration {\n const declaration = projectFieldDeclaration(ownData(field, 'declaration').value);\n if (declaration !== undefined) return declaration;\n const direct = projectFieldDeclaration(field);\n const kind = ownString(field, 'kind');\n const mapping = kind === undefined ? undefined : LEGACY_KIND_DECLARATIONS[kind];\n // A number of native-era builders already carry their primitive shape\n // (`type`, `items`, `meta`) alongside the former routing `kind`. Keep that\n // shape, but lower the kind into the semantic format so an app-local host\n // catalog can still select its custom implementation. An explicit format\n // remains authoritative.\n if (direct !== undefined) {\n const format = direct.format ?? mapping?.format ?? kind;\n return format === undefined\n ? direct\n : (Object.freeze({ ...direct, format }) as FieldDeclaration);\n }\n\n // Legacy `f.file()` is a one-file field unless its builder option explicitly\n // says `multiple: true`. The renderer contract follows that cardinality:\n // only a semantic array selects `CollectionInput`, whose public API always\n // carries `multiple: true`. Preserve the file format for both variants so\n // they share the same host implementation and full-width layout.\n const ui = projectUiHints(ownData(field, 'ui').value);\n const legacySingleFile = kind === 'file' && ui?.multiple !== true;\n const type = legacySingleFile ? 'unknown' : (mapping?.type ?? 'unknown');\n const format = ownString(field, 'format') ?? mapping?.format ?? kind;\n const items =\n type === 'array'\n ? (projectFieldDeclaration(ownData(field, 'items').value) ?? mapping?.items ?? STRING_ITEM)\n : undefined;\n const meta = ownData(field, 'meta');\n const texts = ownData(field, 'texts');\n const required = ownData(field, 'required');\n const nullable = ownData(field, 'nullable');\n // Native builders retain their declaration-time semantics under `opts`.\n // Prefer an explicit top-level value when present, then project only the\n // portable boolean flags; functions and arbitrary builder options remain\n // host-local implementation details.\n const opts = ownData(field, 'opts').value;\n const optionRequired = ownData(opts, 'required');\n const optionNullable = ownData(opts, 'nullable');\n const requiredValue = required.present ? required.value : optionRequired.value;\n const nullableValue = nullable.present ? nullable.value : optionNullable.value;\n return Object.freeze({\n type,\n ...(format === undefined ? {} : { format }),\n ...(items === undefined ? {} : { items }),\n ...(meta.present && meta.value !== undefined ? { meta: meta.value } : {}),\n ...(texts.present && texts.value !== undefined ? { texts: texts.value } : {}),\n ...(requiredValue === true ? { required: true } : {}),\n ...(nullableValue === true ? { nullable: true } : {}),\n }) as FieldDeclaration;\n}\n\n/**\n * Build the safe source accepted by a React field surface. Use this when a\n * legacy field must be lowered before it reaches `ResolvedField*` (for\n * example action-modal fields): semantic data comes from the shared lowering,\n * while inert UI hints such as file storage/accept/cardinality stay available\n * to the host implementation.\n */\nexport function lowerLegacyFieldSource(field: LegacyFieldLike): LoweredLegacyFieldSource {\n const declaration = lowerLegacyField(field);\n const ui = projectUiHints(ownData(field, 'ui').value);\n if (ui === undefined) return declaration as LoweredLegacyFieldSource;\n return Object.freeze({ ...declaration, ui }) as LoweredLegacyFieldSource;\n}\n\n/**\n * A field's description, the hint under its input: its `texts.description` (the field's\n * `declaration` is asked first, then the field itself). It is the code default of the one slot\n * `fields.<name>.description`, which wins at render; core's collector reads the same slot.\n */\nexport function fieldDescription(field: unknown): string | undefined {\n const declaration = (field as { readonly declaration?: unknown } | undefined)?.declaration;\n return (\n declaredText('field', declaration, 'description') ?? declaredText('field', field, 'description')\n );\n}\n","'use client';\nimport {\n formatEntityRef,\n type AppContext,\n type EntityRef,\n type FieldContextSources,\n type FieldDeclaration,\n type FieldOption,\n type FixedFilterInput,\n type ScreenSources,\n type ValidationIssues,\n} from '@burojs/core';\nimport {\n useCtx,\n useFieldImplementation,\n useFieldMeta,\n useFieldMetaSources,\n useI18nCaps,\n useLocale,\n useOptionalT,\n type FieldI18n,\n type FieldMetaState,\n type FieldPresentation,\n type FieldRenderContext,\n} from '@burojs/react';\nimport {\n createElement,\n useEffect,\n useMemo,\n useRef,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { Skeleton } from '../primitives/skeleton.js';\nimport { lowerLegacyField, lowerLegacyFieldSource, type LegacyFieldLike } from './legacy-field.js';\n\ntype FieldLike = LegacyFieldLike & {\n readonly format?: string;\n readonly formatSemantics?: { readonly id?: string; readonly fallback?: string };\n readonly items?: FieldDeclaration;\n readonly meta?: Readonly<Record<string, unknown>>;\n /** See `LegacyFieldLike.ui` — an opaque bag, so a canonical `FieldDeclaration` stays assignable. */\n readonly ui?: object;\n readonly options?: FieldDeclaration['options'];\n readonly required?: boolean;\n readonly codec?: unknown;\n};\n\nconst EMPTY = Object.freeze({});\nconst EMPTY_ISSUES = Object.freeze([]);\nconst EMPTY_OPTIONS = Object.freeze([]) as readonly FieldOption[];\n\nfunction canonical(field: FieldLike): FieldDeclaration {\n return lowerLegacyField(field);\n}\n\nconst warnedObjectLabels = new Set<string>();\n\n/**\n * Canonical `options` win. During the compatibility migration, value-enum\n * builders still carry their choices in `meta.options`; normalize that trusted\n * legacy shape once here so every resolver surface sees the same contract. An\n * entry whose label is not a string (a JavaScript caller's `{ ru, en }`) is\n * kept under its raw value, with one development warning naming the fix.\n */\nfunction optionsFor(field: FieldDeclaration, name: string): readonly FieldOption[] {\n if (Array.isArray(field.options)) return field.options;\n const candidate = field.meta?.options;\n if (!Array.isArray(candidate)) return EMPTY_OPTIONS;\n const output: FieldOption[] = [];\n for (const item of candidate) {\n if (item === null || typeof item !== 'object' || Array.isArray(item)) continue;\n const raw = item as Record<string, unknown>;\n if (\n typeof raw.value !== 'string' &&\n typeof raw.value !== 'number' &&\n typeof raw.value !== 'boolean' &&\n raw.value !== null\n )\n continue;\n const { value, label, description, ...legacyMeta } = raw;\n if (\n typeof label !== 'string' &&\n process.env.NODE_ENV !== 'production' &&\n !warnedObjectLabels.has(`${name}:${value}`)\n ) {\n warnedObjectLabels.add(`${name}:${value}`);\n // eslint-disable-next-line no-console\n console.warn(\n `[buro/ui-shadcn] field '${name}': option '${value}' has a non-string label, so it renders its raw value. Declare a plain string label and put the translations under fields.${name}.options.${value} (see docs/i18n-guide.md).`,\n );\n }\n output.push(\n Object.freeze({\n value,\n label: typeof label === 'string' ? label : String(value),\n ...(typeof description === 'string' ? { description } : {}),\n ...(Object.keys(legacyMeta).length === 0 ? {} : { meta: Object.freeze(legacyMeta) }),\n }) as FieldOption,\n );\n }\n return Object.freeze(output);\n}\n\nconst readScope = (ctx: AppContext): Readonly<Record<string, unknown>> | undefined => ctx.scope;\n\nfunction useFieldRuntimeContext(\n resource: EntityRef,\n record: Readonly<Record<string, unknown>> | undefined,\n values: Readonly<Record<string, unknown>> | undefined,\n metaSources: ScreenSources | undefined,\n): Readonly<{\n readonly sources: FieldContextSources;\n readonly i18n: FieldI18n;\n readonly metaSources: ScreenSources;\n}> {\n const scope = useCtx(readScope);\n const locale = useLocale();\n // `resource.id` alone aliases `hasura:user` and `supabase:user`; field\n // implementation i18n must remain bound to the same qualified ref as the\n // record it renders.\n const caps = useI18nCaps(formatEntityRef(resource));\n // What a field's `meta` refs read (P7 3.2): the owner's projected states when it passes them,\n // else this field's own `record` and `values` props. Never anything else.\n const metaSourcesOut = useFieldMetaSources({ record, values, extra: metaSources });\n return useMemo(\n () =>\n Object.freeze({\n i18n: Object.freeze({ locale, has: caps.has, t: caps.t }),\n sources: Object.freeze({\n record: record ?? EMPTY,\n values: values ?? EMPTY,\n scope: scope ?? EMPTY,\n }),\n metaSources: metaSourcesOut,\n }),\n [caps, locale, record, scope, values, metaSourcesOut],\n );\n}\n\n/**\n * One development message per mounted field and refusal (P7 3.3): which field, which\n * implementation and why. Never in production, where the field only draws as misconfigured.\n */\nexport function useFieldMetaDiagnostic(\n state: FieldMetaState,\n resource: EntityRef,\n name: string,\n field: FieldDeclaration,\n surface: 'input' | 'display',\n): void {\n const reported = useRef<string | undefined>(undefined);\n const reason = state.status === 'failed' ? state.reason : undefined;\n useEffect(() => {\n if (\n reason === undefined ||\n reported.current === reason ||\n process.env.NODE_ENV === 'production'\n )\n return;\n reported.current = reason;\n const named = (\n field.ui as { readonly input?: unknown; readonly display?: unknown } | undefined\n )?.[surface];\n const implementation = typeof named === 'string' ? named : (field.format ?? field.type);\n // eslint-disable-next-line no-console\n console.error(\n `[burojs] field.meta-invalid: ${formatEntityRef(resource)}.${name} (${implementation}): ${reason}`,\n );\n }, [reason, resource, name, field, surface]);\n}\n\n/**\n * What a field draws while its `meta` is not ready (P7 3.2): a skeleton while a source or an\n * asynchronous schema is pending, an inert labelled control once it was refused. Never the\n * implementation, which would read a `meta` it was not given.\n */\nexport function MetaPlaceholder({ state }: { readonly state: FieldMetaState }): ReactElement {\n const t = useOptionalT();\n if (state.status === 'pending')\n return <Skeleton data-buro-skeleton=\"\" data-buro-field-meta=\"pending\" className=\"h-9 w-full\" />;\n return (\n <div\n role=\"alert\"\n data-buro-field-meta=\"failed\"\n className=\"rounded-md border border-dashed px-3 py-2 text-sm text-muted-foreground\"\n >\n {t('field.misconfigured', { defaultValue: 'This field is misconfigured' })}\n </div>\n );\n}\n\n/** Report a fail-soft resolver miss once per mounted field and diagnostic. */\nfunction useFieldImplementationDiagnostic(diagnostic: unknown): void {\n const reported = useRef<unknown>(undefined);\n useEffect(() => {\n if (\n diagnostic === undefined ||\n reported.current === diagnostic ||\n process.env.NODE_ENV === 'production'\n )\n return;\n reported.current = diagnostic;\n // eslint-disable-next-line no-console\n console.warn('[buro/ui-shadcn] missing-field-implementation; rendering fallback.', diagnostic);\n }, [diagnostic]);\n}\n\nexport interface ResolvedFieldDisplayProps {\n readonly resource: EntityRef;\n readonly name: string;\n readonly field: FieldLike;\n readonly value: unknown;\n readonly record?: Readonly<Record<string, unknown>>;\n readonly testId?: string;\n readonly fallback: ReactNode;\n readonly presentation?: FieldPresentation;\n /**\n * The owner's own source states, by name (P7 3.2): a form controller's projected `record` and\n * `values`, a flow's `with` and `args`. They replace the sources built from `record` and\n * `form`, so a field P5 withholds stays pending in a `meta` ref as it does everywhere else.\n */\n readonly metaSources?: ScreenSources;\n}\n\nexport interface ResolvedFieldInputProps extends Omit<ResolvedFieldDisplayProps, 'fallback'> {\n readonly inputId?: string;\n readonly onChange: (value: unknown) => void;\n /** Live form values, distinct from the edit record baseline. */\n readonly form?: Readonly<Record<string, unknown>>;\n readonly onBlur?: () => void;\n readonly disabled?: boolean;\n readonly required?: boolean;\n readonly placeholder?: string;\n readonly descriptionId?: string;\n readonly errorId?: string;\n readonly errorMessage?: string | null;\n /** Current lifecycle state from the enclosing form. */\n readonly pending?: boolean;\n readonly touched?: boolean;\n /** Optional canonical issues; localized errorMessage remains the fallback. */\n readonly issues?: ValidationIssues;\n /**\n * A relation select's create seeds (P6-31), from the form controller's binding. A separate\n * channel from `field.meta`: the seeds' provenance is the code registry, and `meta` can be\n * written by a layer.\n */\n readonly relationSeeds?: Readonly<Record<string, unknown>>;\n /**\n * A relation select's extra filters from the form's `filter` function (P7 3.4): code, handed\n * down by the form controller on its own channel, applied on top of the field's `candidates`.\n * Never read from `field.meta`, which a layer can write.\n */\n readonly fixedFilters?: readonly FixedFilterInput[];\n readonly fallback: ReactNode;\n}\n\n/** Render a display through the sole app-scoped canonical implementation resolver. */\nexport function ResolvedFieldDisplay({\n resource,\n name,\n field: source,\n value,\n record,\n testId,\n fallback,\n presentation,\n metaSources,\n}: ResolvedFieldDisplayProps): ReactElement {\n const sourceAtEdge = lowerLegacyFieldSource(source);\n const field = canonical(sourceAtEdge);\n const resolved = useFieldImplementation({ field, surface: 'display' });\n // Spec 6.1: in show there is no form, so `values` is the record itself.\n const runtimeContext = useFieldRuntimeContext(resource, record, record, metaSources);\n const metaState = useFieldMeta(field, resolved.implementation, runtimeContext.metaSources);\n useFieldMetaDiagnostic(metaState, resource, name, field, 'display');\n useFieldImplementationDiagnostic(resolved.diagnostic);\n if (resolved.Component === undefined) return <>{fallback}</>;\n if (metaState.status !== 'ready') return <MetaPlaceholder state={metaState} />;\n const Component = resolved.Component;\n const context: FieldRenderContext = {\n owner: resource,\n resource,\n field,\n path: Object.freeze([name]),\n surface: 'display',\n presentation: presentation ?? 'default',\n record,\n meta: metaState.meta,\n ui: sourceAtEdge.ui ?? EMPTY,\n options: optionsFor(field, name),\n i18n: runtimeContext.i18n,\n sources: runtimeContext.sources,\n pending: false,\n touched: false,\n issues: EMPTY_ISSUES,\n accessibility: EMPTY,\n testIds: testId === undefined ? EMPTY : Object.freeze({ display: testId }),\n };\n if (resolved.multiple) {\n return createElement(\n Component as never,\n { ...context, multiple: true, value: Array.isArray(value) ? value : [] } as never,\n );\n }\n return createElement(Component as never, { ...context, multiple: false, value } as never);\n}\n\n/** Render an editable field through the same app-scoped resolver as displays. */\nexport function ResolvedFieldInput({\n resource,\n name,\n field: source,\n value,\n record,\n form,\n testId,\n inputId,\n onChange,\n onBlur,\n disabled,\n required,\n placeholder,\n descriptionId,\n errorId,\n errorMessage,\n pending = false,\n touched = errorMessage != null,\n issues: suppliedIssues,\n relationSeeds,\n fixedFilters,\n metaSources,\n fallback,\n}: ResolvedFieldInputProps): ReactElement {\n const sourceAtEdge = lowerLegacyFieldSource(source);\n const base = canonical(sourceAtEdge);\n const field =\n required === undefined || required === base.required\n ? base\n : (Object.freeze({ ...base, required }) as FieldDeclaration);\n const ui = Object.freeze({\n ...(sourceAtEdge.ui ?? EMPTY),\n ...(placeholder === undefined ? {} : { placeholder }),\n });\n const resolved = useFieldImplementation({ field: { ...field, ui }, surface: 'input' });\n const runtimeContext = useFieldRuntimeContext(resource, record, form, metaSources);\n const metaState = useFieldMeta(field, resolved.implementation, runtimeContext.metaSources);\n useFieldMetaDiagnostic(metaState, resource, name, field, 'input');\n useFieldImplementationDiagnostic(resolved.diagnostic);\n if (resolved.Component === undefined) return <>{fallback}</>;\n if (metaState.status !== 'ready') return <MetaPlaceholder state={metaState} />;\n const Component = resolved.Component;\n // `errorMessage` is a bare string with no severity of its own — by\n // contract (the prop's name) it always denotes a blocking ERROR, so this\n // is the only severity this synthesis path may ever produce. A caller with\n // non-error diagnostics (severity 'warning' | 'info') must not funnel them\n // through `errorMessage`; it must supply them via `issues` (below) instead,\n // where they pass through untouched and keep their real severity — that is\n // what lets `default-renderers.ts`'s `ariaInvalid` (error-only) and any\n // consumer's non-blocking warning UI tell them apart from a real error.\n const issues =\n suppliedIssues ??\n (errorMessage == null\n ? EMPTY_ISSUES\n : Object.freeze([\n Object.freeze({\n code: 'ui.field-error',\n message: { key: 'ui.field-error', default: errorMessage },\n path: Object.freeze([]),\n source: 'field' as const,\n severity: 'error' as const,\n }),\n ]));\n const context: FieldRenderContext = {\n owner: resource,\n resource,\n field,\n path: Object.freeze([name]),\n surface: 'input',\n // Inputs always render in a surface we control; the axis exists on the\n // shared context so displays can read it, not because inputs vary yet.\n presentation: 'default',\n record,\n form,\n meta: metaState.meta,\n ui,\n options: optionsFor(field, name),\n i18n: runtimeContext.i18n,\n sources: runtimeContext.sources,\n pending,\n touched,\n issues,\n accessibility: Object.freeze({\n input: inputId ?? name,\n description: descriptionId,\n error: errorId,\n }),\n testIds: testId === undefined ? EMPTY : Object.freeze({ input: testId }),\n };\n if (resolved.multiple) {\n return createElement(\n Component as never,\n {\n ...context,\n multiple: true,\n value: Array.isArray(value) ? value : [],\n onChange,\n onBlur,\n disabled,\n relationSeeds,\n fixedFilters,\n metaSources: runtimeContext.metaSources,\n } as never,\n );\n }\n return createElement(\n Component as never,\n {\n ...context,\n multiple: false,\n value,\n onChange,\n onBlur,\n disabled,\n relationSeeds,\n fixedFilters,\n metaSources: runtimeContext.metaSources,\n } as never,\n );\n}\n","'use client';\nimport { i18nPrefixToRef, type EntityRef, type FixedFilterInput } from '@burojs/core';\nimport type { ReactElement, ReactNode } from 'react';\nimport { DocInfo } from '../doc/doc-info.js';\nimport {\n ResolvedFieldDisplay,\n ResolvedFieldInput,\n type ResolvedFieldDisplayProps,\n type ResolvedFieldInputProps,\n} from '../fields/resolved-field.js';\nimport { Input } from '../primitives/input.js';\n\nexport { i18nPrefixToRef };\n\nfunction resolveRef(resource: EntityRef | undefined, i18nPrefix: string | undefined): EntityRef {\n if (resource !== undefined) return resource;\n if (i18nPrefix !== undefined) return i18nPrefixToRef(i18nPrefix);\n return { namespace: 'default', id: 'form' };\n}\n\nexport type FieldProps = Omit<ResolvedFieldInputProps, 'resource' | 'fallback'> & {\n readonly resource?: EntityRef;\n readonly i18nPrefix?: string;\n readonly fallback?: ReactNode;\n /**\n * A relation field's `filter` function RESOLVED against the form's values (design doc §5,\n * `@burojs/react`'s `FieldBinding.fixedFilters`). It reaches the select on its own channel (a\n * prop of the input, never `field.meta`, which a layer can write) and applies on top of the\n * field's `candidates`. `<DeclarativeForm>` never sets this explicitly: it spreads the whole\n * `FieldBinding` (`{...binding}`), which already carries `fixedFilters` when the field\n * declared a `filter` function.\n *\n * `FixedFilterInput`, not the bare AST — matches `FieldBinding.fixedFilters`\n * (`@burojs/react`) and `RelationPickerProps`/`RelationPickerDialogProps`\n * downstream, so `{...binding}`'s spread onto this prop keeps typechecking.\n */\n readonly fixedFilters?: readonly FixedFilterInput[];\n /**\n * Render the contextual-doc affordance for this field. Opt-in: the brick is\n * used inside app-owned layouts that may already place their own label row,\n * so an always-on icon would appear twice. `<DeclarativeForm>` does NOT use\n * this — it owns its label row and renders `DocInfo` there directly.\n */\n readonly doc?: { readonly address: string; readonly name: string; readonly testId?: string };\n};\n\n/**\n * Public, resource-independent single-field input brick over\n * `ResolvedFieldInput`. Callers scope a field's runtime i18n either with an\n * explicit `resource` `EntityRef` or with a lighter-weight `i18nPrefix`\n * (`\"namespace:id\"` or a bare id against the default namespace) — no\n * registered resource is required. `fallback` defaults to a plain `<Input>`\n * wired to the field's value/onChange/disabled state.\n */\nexport function Field({\n resource,\n i18nPrefix,\n fallback,\n fixedFilters,\n field,\n doc,\n ...rest\n}: FieldProps): ReactElement {\n const input = (\n <ResolvedFieldInput\n {...rest}\n field={field}\n {...(fixedFilters === undefined ? {} : { fixedFilters })}\n resource={resolveRef(resource, i18nPrefix)}\n fallback={\n fallback ?? (\n // Raw HTML <input> fallback: string-oriented only. A non-primitive\n // `value` (object/array — e.g. an unresolved relation or JSON field\n // with no matching implementation) coerces via String() to\n // \"[object Object]\" rather than something editable. Callers with\n // such a field should supply their own `fallback`.\n <Input\n id={rest.inputId}\n value={String(rest.value ?? '')}\n onChange={(event) => rest.onChange(event.target.value)}\n disabled={rest.disabled}\n />\n )\n }\n />\n );\n if (doc === undefined) return input;\n return (\n <div className=\"flex flex-col gap-1.5\">\n <div className=\"flex items-center gap-2\">\n <DocInfo address={doc.address} name={doc.name} testId={doc.testId} />\n </div>\n {input}\n </div>\n );\n}\n\nexport type FieldDisplayProps = Omit<ResolvedFieldDisplayProps, 'resource' | 'fallback'> & {\n readonly resource?: EntityRef;\n readonly i18nPrefix?: string;\n readonly fallback?: ReactNode;\n};\n\n/**\n * Public, resource-independent single-field display brick over\n * `ResolvedFieldDisplay`. See {@link Field} for the `resource`/`i18nPrefix`\n * resolution rule. `fallback` defaults to a `<span>` rendering the value, or\n * an em dash when the value is empty.\n */\nexport function FieldDisplay({\n resource,\n i18nPrefix,\n fallback,\n value,\n ...rest\n}: FieldDisplayProps): ReactElement {\n return (\n <ResolvedFieldDisplay\n {...rest}\n value={value}\n resource={resolveRef(resource, i18nPrefix)}\n fallback={fallback ?? <span>{value == null || value === '' ? '—' : String(value)}</span>}\n />\n );\n}\n","'use client';\nimport {\n LAYOUT_SIZES,\n declaredText,\n type LayoutSize,\n type PlanNode,\n formatEntityRef,\n i18nPrefixToRef,\n resolveContentSlot,\n resolveFieldLabel,\n resolveFieldSlot,\n} from '@burojs/core';\nimport {\n type FieldBinding,\n resolveValidationMessage,\n useFieldImplementation,\n useFieldMeta,\n useFieldMetaSources,\n useI18nCaps,\n useOptionalT,\n useTestIds,\n} from '@burojs/react';\nimport { IconLock } from '@tabler/icons-react';\nimport { type ReactElement, type ReactNode, useId, useRef } from 'react';\nimport { DocInfo } from '../doc/doc-info.js';\nimport {\n type LegacyFieldLike,\n fieldDescription,\n lowerLegacyField,\n} from '../fields/legacy-field.js';\nimport { MetaPlaceholder, useFieldMetaDiagnostic } from '../fields/resolved-field.js';\nimport { Field, FieldDisplay } from '../forms/field.js';\nimport { Input } from '../primitives/input.js';\nimport { cn } from '../lib/cn.js';\nimport { Label } from '../primitives/label.js';\nimport { useReveal, useScreenTree } from './tree-context.js';\n\nconst SIZES: ReadonlySet<string> = new Set(LAYOUT_SIZES);\n\n/** What a reveal may focus inside a composite input. */\nconst FOCUSABLE =\n 'input:not([type=\"hidden\"]):not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [contenteditable=\"true\"], [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * A leaf's effective size (P1b+P1c decision 29): the field's `ui.size`, then\n * its input implementation's `layout.size`, then `md`.\n */\nfunction useLeafSize(field: FieldBinding['field']): LayoutSize {\n const implementation = useFieldImplementation({\n field: lowerLegacyField(field as LegacyFieldLike),\n surface: 'input',\n });\n const declared = (field as { readonly ui?: { readonly size?: unknown } }).ui?.size;\n if (typeof declared === 'string' && SIZES.has(declared)) return declared as LayoutSize;\n return implementation.layout.size ?? 'md';\n}\n\n/**\n * A field's label in show, everywhere one is drawn (field leaves, facts): one size, one weight,\n * one colour (visual-quality spec, finding 2).\n */\nexport const FIELD_LABEL_SHOW = 'text-sm font-medium text-muted-foreground';\n\n/** The attributes every leaf element carries. */\nfunction leafAttributes(size: LayoutSize, weight: number | undefined) {\n return {\n 'data-buro-node': 'field',\n 'data-buro-size': size,\n ...(weight === undefined ? {} : { 'data-buro-weight': String(weight) }),\n } as const;\n}\n\n/**\n * One field leaf of a screen tree (P1b+P1c section 9): an input when the plan\n * makes it `active`, its display with the lock reason when `readonly`, its\n * display in show. The test ids are the old engine's (`form-field:…`,\n * `form-field-input:…`, `form-field-locked:…`, `show-field:…`).\n */\nexport function FieldLeaf({ node }: { readonly node: PlanNode }): ReactElement | null {\n const { leafIds } = useScreenTree();\n // A resource-less form's leaf (`<DeclarativeForm>`, `<DeclarativeDisplay>`) keeps its own ids.\n // A field whose only failure is its own `meta` (a schema refused it, P7 3.3) draws its label\n // and the misconfigured control: the implementation is never given a meta it was refused.\n if (\n node.state === 'failed' &&\n node.failedOn.length > 0 &&\n node.failedOn.every((name) => name.startsWith('meta:'))\n )\n return <MisconfiguredLeaf node={node} />;\n if (leafIds !== 'record')\n return <DeclarativeLeaf node={node} prefix={leafIds.prefix} inputIds={leafIds.inputIds} />;\n return <RecordLeaf node={node} />;\n}\n\n/** The leaf of a field whose `meta` was refused: its label, the reason in development. */\nfunction MisconfiguredLeaf({ node }: { readonly node: PlanNode }): ReactElement {\n const { leafIds, resource, mode, controller } = useScreenTree();\n const name = node.field!;\n const binding = controller.field(name);\n const caps = useI18nCaps(resource);\n const tid = useTestIds();\n const field = lowerLegacyField(binding.field as LegacyFieldLike);\n const surface = mode === 'show' ? 'display' : 'input';\n const resolved = useFieldImplementation({ field, surface });\n const sources = useFieldMetaSources({\n record: controller.record,\n values: controller.values,\n extra: controller.sources,\n });\n const state = useFieldMeta(field, resolved.implementation, sources);\n useFieldMetaDiagnostic(state, binding.resource, name, field, surface);\n const label = resolveFieldLabel(caps, name, declaredText('field', binding.field, 'label'));\n const testId =\n leafIds === 'record' ? tid.formField(resource, mode, name) : `${leafIds.prefix}:field:${name}`;\n return (\n <div\n {...leafAttributes('md', undefined)}\n className=\"relative\"\n data-testid={testId}\n data-buro-field-meta=\"failed\"\n >\n <div data-buro-region=\"field-label\" className=\"text-sm font-medium leading-none\">\n {label}\n </div>\n <div data-buro-region=\"field-control\">\n <MetaPlaceholder state={state} />\n </div>\n </div>\n );\n}\n\n/** A record screen's leaf: the record test ids. */\nfunction RecordLeaf({ node }: { readonly node: PlanNode }): ReactElement | null {\n const { resource, mode, compiled, controller } = useScreenTree();\n const name = node.field!;\n const binding = controller.field(name);\n const size = useLeafSize(binding.field);\n const weight = compiled.nodes[node.index]?.options.weight;\n const caps = useI18nCaps(resource);\n const tid = useTestIds();\n const label = resolveFieldLabel(caps, name, declaredText('field', binding.field, 'label'));\n const attributes = leafAttributes(size, weight);\n const t = useOptionalT();\n // A restricted field (P5 spec 3.6): its label, that it is restricted and why. Never the value,\n // never an input; the same in show and in edit.\n if (node.restricted === true) {\n const rawReason = node.restrictedReason;\n const reason =\n rawReason === undefined || rawReason === ''\n ? undefined\n : resolveContentSlot(caps, [rawReason], { resource, default: rawReason });\n const restrictedId = tid.formFieldRestricted(resource, mode, name);\n return (\n <div\n {...attributes}\n className=\"relative\"\n data-testid={restrictedId}\n data-buro-restricted=\"true\"\n >\n <div data-buro-region=\"field-label\" className=\"text-sm font-medium leading-none\">\n {label}\n </div>\n <div data-buro-region=\"field-control\" className=\"space-y-1 text-sm\">\n <p className=\"flex items-center gap-1 text-[13px] leading-snug text-muted-foreground\">\n <IconLock className=\"h-3 w-3 shrink-0\" aria-hidden=\"true\" />\n <span>{t('access.restricted', { defaultValue: 'No access' })}</span>\n {reason === undefined ? null : <span>{reason}</span>}\n </p>\n </div>\n </div>\n );\n }\n const record = controller.record;\n // A field its user may not edit is not held in form state (P5 decision 23): in edit it is\n // displayed from the projected record.\n const value =\n mode === 'show'\n ? (record?.[name] ?? controller.values[name])\n : mode === 'edit' && controller.plan?.fields[name] !== 'active'\n ? (record?.[name] ?? controller.values[name])\n : controller.values[name];\n const display = (\n <FieldDisplay\n resource={binding.resource}\n name={name}\n field={binding.field as never}\n value={value}\n metaSources={controller.sources}\n {...(record === undefined ? {} : { record })}\n fallback={\n value == null || value === '' ? (\n <span className=\"text-muted-foreground\">—</span>\n ) : (\n <span>{String(value)}</span>\n )\n }\n />\n );\n\n if (mode === 'show') {\n return (\n <dl {...attributes} data-testid={`show-field:${resource}:${name}`}>\n <dt\n data-buro-region=\"field-label\"\n className={cn('flex items-center gap-0.5', FIELD_LABEL_SHOW)}\n >\n <span className=\"min-w-0\">{label}</span>\n <DocInfo address={`${resource}/fields/${name}`} name={label} />\n </dt>\n <dd data-buro-region=\"field-control\" className=\"text-sm text-foreground\">\n {display}\n </dd>\n </dl>\n );\n }\n\n if (node.editable !== true) {\n // A field the form cannot write: its display, and the deny rule's reason beside it.\n const rawReason = node.lockReason;\n const reason =\n rawReason === undefined\n ? undefined\n : resolveContentSlot(caps, [rawReason], { resource, default: rawReason });\n const locked = tid.formFieldLocked(resource, mode, name);\n return (\n <div {...attributes} className=\"relative\" data-testid={tid.formField(resource, mode, name)}>\n <div data-buro-region=\"field-label\" className=\"flex items-center gap-2\">\n {/* The editable field's label exactly: a field turning read-only changes nothing here. */}\n <Label>{label}</Label>\n <DocInfo\n address={`${resource}/fields/${name}`}\n name={label}\n testId={`${tid.formField(resource, mode, name)}:info`}\n />\n </div>\n <div data-buro-region=\"field-control\" data-testid={locked} className=\"space-y-1 text-sm\">\n {/* An input-height box where the input would be, so nothing moves when it becomes one. */}\n <div\n data-buro-readonly=\"\"\n className=\"flex min-h-9 items-center rounded-md border border-input bg-muted/40 px-3 py-1.5\"\n >\n {display}\n </div>\n {reason === undefined ? null : (\n <p className=\"flex items-center gap-1 text-[13px] leading-snug text-muted-foreground\">\n <IconLock className=\"h-3 w-3 shrink-0\" aria-hidden=\"true\" />\n {reason}\n <DocInfo address={`lock/${rawReason}`} name={reason} testId={`${locked}:info`} />\n </p>\n )}\n </div>\n </div>\n );\n }\n\n const inputId = `${mode}-${name}`;\n return (\n <ActiveLeaf\n node={node}\n binding={binding}\n label={label}\n attributes={attributes}\n inputId={inputId}\n />\n );\n}\n\n/** An editable leaf: label, input, one message slot; its reveal focuses the input. */\nfunction ActiveLeaf({\n node,\n binding,\n label,\n attributes,\n inputId,\n}: {\n readonly node: PlanNode;\n readonly binding: FieldBinding;\n readonly label: string;\n readonly attributes: ReturnType<typeof leafAttributes>;\n readonly inputId: string;\n}): ReactElement {\n const { resource, mode, controller, disabled: locked } = useScreenTree();\n const caps = useI18nCaps(resource);\n const t = useOptionalT();\n const tid = useTestIds();\n const name = binding.name;\n const record = controller.record;\n const root = useRef<HTMLDivElement>(null);\n useReveal(node.id, () => {\n const element = root.current;\n if (element === null) return;\n const byId = element.ownerDocument.getElementById(inputId);\n byId?.focus();\n if (byId !== null && element.ownerDocument.activeElement === byId) return;\n // A composite input renders a container under the id: focus the first control in it,\n // else the first in the leaf.\n const scope = byId ?? element.querySelector('[data-buro-region=\"field-control\"]') ?? element;\n scope.querySelector<HTMLElement>(FOCUSABLE)?.focus();\n });\n const messageId = `${mode}-${name}-msg`;\n const placeholder = resolveFieldSlot(caps, name, 'placeholder');\n const hint = resolveFieldSlot(caps, name, 'description', fieldDescription(binding.field));\n const fieldKey = `resources.${resource}.fields.${name}`;\n const errorText =\n binding.error === undefined\n ? null\n : resolveValidationMessage(\n {\n code: binding.error.code ?? '',\n message: binding.error.message,\n ...(binding.error.params === undefined ? {} : { params: binding.error.params }),\n },\n { t, fieldKey },\n );\n const warning = errorText === null ? binding.warnings[0] : undefined;\n const warningText =\n warning === undefined\n ? null\n : resolveValidationMessage(\n {\n code: warning.code ?? '',\n message: warning.message,\n ...(warning.params === undefined ? {} : { params: warning.params }),\n },\n { t, fieldKey },\n );\n // The tree's whole-form lock too (a flow's host while its write runs, or its unknown screen).\n const disabled = binding.disabled || controller.isSubmitting || locked === true;\n const describedBy = errorText === null && hint ? messageId : undefined;\n const errorMessageId = errorText === null ? undefined : messageId;\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: the blur bubbles from the input inside (focusout); the wrapper is not a control\n <div\n ref={root}\n {...attributes}\n // `relative`: a Radix control's hidden native element anchors here, not on the page.\n className=\"relative\"\n data-testid={tid.formField(resource, mode, name)}\n onBlur={binding.onBlur}\n >\n <div data-buro-region=\"field-label\" className=\"flex items-center gap-2\">\n <Label htmlFor={inputId} required={binding.required}>\n {label}\n </Label>\n <DocInfo\n address={`${resource}/fields/${name}`}\n name={label}\n testId={`${tid.formField(resource, mode, name)}:info`}\n />\n </div>\n <div data-buro-region=\"field-control\" className=\"space-y-1\">\n <Field\n resource={binding.resource}\n name={name}\n inputId={inputId}\n field={binding.field as never}\n value={binding.value}\n onChange={binding.onChange}\n testId={tid.formFieldInput(resource, mode, name)}\n {...(placeholder === undefined ? {} : { placeholder })}\n required={binding.required}\n disabled={disabled}\n {...(mode === 'create' || record === undefined ? {} : { record })}\n form={controller.values}\n metaSources={controller.sources}\n {...(describedBy === undefined ? {} : { descriptionId: describedBy })}\n {...(errorMessageId === undefined ? {} : { errorId: errorMessageId })}\n errorMessage={errorText}\n {...(binding.fixedFilters === undefined ? {} : { fixedFilters: binding.fixedFilters })}\n {...(binding.relationSeeds === undefined ? {} : { relationSeeds: binding.relationSeeds })}\n fallback={\n <Input\n id={inputId}\n name={inputId}\n data-testid={tid.formFieldInput(resource, mode, name)}\n value={binding.value == null ? '' : String(binding.value)}\n placeholder={placeholder}\n required={binding.required}\n disabled={disabled}\n aria-required={binding.required}\n aria-invalid={errorText !== null || undefined}\n aria-describedby={describedBy}\n {...(errorMessageId === undefined ? {} : { 'aria-errormessage': errorMessageId })}\n onChange={(event) => binding.onChange(event.target.value)}\n />\n }\n />\n {errorText !== null ? (\n <p\n id={messageId}\n aria-live=\"polite\"\n className=\"text-sm text-destructive\"\n data-testid={tid.formFieldError(resource, mode, name)}\n >\n {errorText}\n </p>\n ) : warningText !== null ? (\n <p\n id={messageId}\n aria-live=\"polite\"\n className=\"text-sm text-warning-emphasis\"\n data-testid={`form-field-warning:${resource}:${mode}:${name}`}\n >\n {warningText}\n </p>\n ) : hint ? (\n <p\n id={messageId}\n data-testid={tid.formFieldHelp(resource, mode, name)}\n className=\"text-[13px] leading-snug text-muted-foreground\"\n >\n {hint}\n </p>\n ) : null}\n </div>\n </div>\n );\n}\n\n/**\n * A resource-less form's leaf (P1b+P1c S3e): the markup `<DeclarativeForm>`\n * and `<DeclarativeDisplay>` drew per field before they ran on the controller,\n * with their ids (`<prefix>:field:<name>:hint`, `…:info`) and none of the\n * record ones. In show it is a label and the display; otherwise a label, the\n * input (or the `renderField` override wrapping it), one message slot (error\n * over warning) and the hint.\n */\nfunction DeclarativeLeaf({\n node,\n prefix,\n inputIds,\n}: {\n readonly node: PlanNode;\n readonly prefix: string;\n readonly inputIds: string | undefined;\n}): ReactElement {\n const { mode, compiled, controller, renderField, disabled } = useScreenTree();\n const name = node.field!;\n const binding = controller.field(name);\n const size = useLeafSize(binding.field);\n const weight = compiled.nodes[node.index]?.options.weight;\n const attributes = leafAttributes(size, weight);\n const docRef = i18nPrefixToRef(prefix);\n // Short key for the default namespace, qualified otherwise: a bundle authored under\n // `resources.<bare scope>` must match.\n const docScope = docRef.namespace === 'default' ? docRef.id : formatEntityRef(docRef);\n const caps = useI18nCaps(docScope);\n const t = useOptionalT();\n const uid = useId();\n const root = useRef<HTMLDivElement>(null);\n const inputId = `${inputIds ?? uid}-${name}`;\n useReveal(node.id, () => {\n const element = root.current;\n if (element === null) return;\n const byId = element.ownerDocument.getElementById(inputId);\n byId?.focus();\n if (byId !== null && element.ownerDocument.activeElement === byId) return;\n element.querySelector<HTMLElement>(FOCUSABLE)?.focus();\n });\n const label = resolveFieldLabel(caps, name, declaredText('field', binding.field, 'label'));\n const hint = resolveFieldSlot(caps, name, 'description', fieldDescription(binding.field));\n const info = (\n <DocInfo\n address={`${docScope}/fields/${name}`}\n name={label}\n testId={`${prefix}:field:${name}:info`}\n />\n );\n const hintNode =\n hint === undefined ? null : (\n <p\n data-buro-region=\"field-message\"\n className=\"text-xs text-muted-foreground\"\n data-testid={`${prefix}:field:${name}:hint`}\n >\n {hint}\n </p>\n );\n if (mode === 'show') {\n return (\n <div ref={root} {...attributes}>\n <div data-buro-region=\"field-label\" className=\"flex items-center gap-2\">\n <span className={FIELD_LABEL_SHOW}>{label}</span>\n {info}\n </div>\n <div data-buro-region=\"field-control\">\n <FieldDisplay\n name={name}\n value={binding.value}\n field={binding.field as never}\n i18nPrefix={prefix}\n metaSources={controller.sources}\n />\n </div>\n {hintNode}\n </div>\n );\n }\n const fieldKey = `resources.${prefix}.fields.${name}`;\n const text = (issue: NonNullable<FieldBinding['error']>) =>\n resolveValidationMessage(\n {\n code: issue.code ?? '',\n message: issue.message,\n ...(issue.params === undefined ? {} : { params: issue.params }),\n },\n { t, fieldKey },\n );\n const defaultNode: ReactNode = (\n <Field\n {...binding}\n field={binding.field as never}\n metaSources={controller.sources}\n inputId={inputId}\n i18nPrefix={prefix}\n disabled={disabled === true || binding.disabled}\n />\n );\n const override = renderField?.[name];\n const control = override === undefined ? defaultNode : override(binding, defaultNode);\n const warning = binding.warnings[0];\n return (\n // `relative`: a Radix control's hidden native element anchors here, not on the page.\n <div ref={root} {...attributes} className=\"relative\">\n <div data-buro-region=\"field-label\" className=\"flex items-center gap-2\">\n <Label htmlFor={inputId} required={binding.required}>\n {label}\n </Label>\n {info}\n </div>\n <div data-buro-region=\"field-control\">{control}</div>\n {binding.error ? (\n <p data-buro-region=\"field-message\" aria-live=\"polite\" className=\"text-sm text-destructive\">\n {text(binding.error)}\n </p>\n ) : warning ? (\n <p\n data-buro-region=\"field-message\"\n aria-live=\"polite\"\n className=\"text-sm text-warning-emphasis\"\n >\n {text(warning)}\n </p>\n ) : null}\n {hintNode}\n </div>\n );\n}\n","'use client';\nimport {\n type CustomQueryHandle,\n type EntityRef,\n formatEntityRef,\n humanizeKey,\n resolveContentSlot,\n declaredText,\n} from '@burojs/core';\nimport {\n type BlockViewProps,\n useApplicationSnapshot,\n useCustomQuery,\n useI18nCaps,\n useOptionalT,\n} from '@burojs/react';\nimport { type ReactElement, useMemo } from 'react';\nimport { toDisplayText } from '../fields/display-value.js';\nimport { ResolvedFieldDisplay } from '../fields/resolved-field.js';\nimport { Button } from '../primitives/button.js';\nimport { Skeleton } from '../primitives/skeleton.js';\nimport { FIELD_LABEL_SHOW } from '../screen/field-leaf.js';\n\n/** The props of `buro:facts` as its view receives them (each schema's output). */\ninterface FactsViewProps {\n readonly query: EntityRef;\n readonly input?: Readonly<Record<string, unknown>>;\n readonly rows?: readonly string[];\n readonly view?: 'grid' | 'list';\n readonly title?: string;\n readonly missing?: string;\n}\n\n/** A query field as its portable declaration holds it. */\ninterface QueryField {\n readonly name: string;\n readonly label?: unknown;\n}\n\n/** An input holding, at any depth, a value that cannot be a key (final review M5). */\nfunction holdsUnreadable(value: unknown, depth = 0): boolean {\n if (unreadable(value)) return true;\n if (depth >= 8 || value === null || typeof value !== 'object') return false;\n const entries = Array.isArray(value) ? value : Object.values(value);\n return entries.some((entry) => holdsUnreadable(entry, depth + 1));\n}\n\n/** An input value that cannot be a key: no read is sent for it (Known finding 1). */\nfunction unreadable(value: unknown): boolean {\n return (\n value === undefined ||\n value === null ||\n value === '' ||\n (typeof value === 'number' && Number.isNaN(value))\n );\n}\n\nfunction Notice({ children }: { readonly children: string }): ReactElement {\n return <p className=\"text-sm text-muted-foreground\">{children}</p>;\n}\n\n/**\n * The built-in `buro:facts` view (P7 3.8): one custom query's declared `fields` as label and value\n * pairs. It is mounted once the placement is decided (its `requires`, its `when` and its refs are\n * the planner's), so the read below is the first and only one. The query's output is not a\n * resource row, so P5's projection does not apply to it (P7-25); an `input` value the planner\n * resolved to nothing sends no read.\n */\nexport function FactsView({ props }: BlockViewProps<unknown>): ReactElement {\n const own = props as unknown as FactsViewProps;\n const t = useOptionalT();\n const snapshot = useApplicationSnapshot();\n const queryId = formatEntityRef(own.query);\n const caps = useI18nCaps();\n const fields = useMemo(() => {\n const projection = snapshot.getProjection({ kind: 'custom-query', ref: own.query });\n const declared = (projection?.value as { readonly fields?: readonly QueryField[] } | undefined)\n ?.fields;\n return Array.isArray(declared) ? declared : [];\n }, [snapshot, own.query]);\n const input = own.input ?? {};\n const blocked = Object.values(input).some((value) => holdsUnreadable(value));\n const handle = useMemo(\n () => ({ kind: 'custom-query', ref: own.query }) as CustomQueryHandle<unknown, unknown>,\n [own.query],\n );\n // A blocked input is never read, and it may not be portable (a resolved `undefined`): the hook\n // gets an empty one, disabled.\n const result = useCustomQuery(handle, (blocked ? {} : input) as never, { enabled: !blocked });\n const shown = useMemo(() => {\n const byName = new Map(fields.map((field) => [field.name, field]));\n const names = own.rows ?? fields.map((field) => field.name);\n return names.flatMap((name) => {\n const field = byName.get(name);\n return field === undefined ? [] : [field];\n });\n }, [fields, own.rows]);\n if (blocked)\n return <Notice>{own.missing ?? t('facts.empty', { defaultValue: 'No data' })}</Notice>;\n if (result.isError) {\n return (\n <div\n role=\"alert\"\n className=\"flex flex-wrap items-center gap-2 rounded-md border border-dashed px-3 py-2 text-sm text-muted-foreground\"\n >\n <span>{t('block.failed', { defaultValue: 'This section could not be loaded.' })}</span>\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => void result.refetch()}>\n {t('actions.retry', { defaultValue: 'Retry' })}\n </Button>\n </div>\n );\n }\n // One tile per fact while it loads, in the grid the facts will fill: nothing shifts on arrival.\n if (result.data === undefined)\n return own.view === 'list' ? (\n <Skeleton data-buro-skeleton=\"\" className=\"h-9 w-full\" />\n ) : (\n <div data-buro-facts=\"grid\">\n {shown.map((field) => (\n <Skeleton key={field.name} data-buro-skeleton=\"\" className=\"h-[4.25rem] rounded-lg\" />\n ))}\n </div>\n );\n const data = result.data as Readonly<Record<string, unknown>> | null;\n if (data === null || typeof data !== 'object' || shown.length === 0)\n return <Notice>{own.missing ?? t('facts.empty', { defaultValue: 'No data' })}</Notice>;\n const pairs = shown.map((field) => {\n const value = data[field.name];\n const label = resolveContentSlot(\n caps,\n [`queries.${queryId}.fields.${field.name}.label`, `queries.${queryId}.fields.${field.name}`],\n {\n ...(declaredText('field', field, 'label') === undefined\n ? {}\n : { default: declaredText('field', field, 'label') as string }),\n humanize: () => humanizeKey(field.name),\n },\n );\n const body =\n value === null || value === undefined ? (\n <span className=\"text-muted-foreground\">—</span>\n ) : (\n <ResolvedFieldDisplay\n resource={own.query}\n name={field.name}\n field={field as never}\n value={value}\n record={data}\n fallback={toDisplayText(value).text}\n />\n );\n return { name: field.name, label, body };\n });\n const heading =\n own.title === undefined ? null : <h3 className=\"text-sm font-semibold\">{own.title}</h3>;\n if (own.view === 'list')\n return (\n <div className=\"flex flex-col gap-2\">\n {heading}\n <dl data-buro-facts=\"list\" className=\"flex flex-col gap-1\">\n {pairs.map(({ name, label, body }) => (\n <div key={name} data-buro-fact={name} className=\"flex items-baseline gap-2\">\n <dt className={FIELD_LABEL_SHOW}>{label}</dt>\n <dd className=\"min-w-0 break-words text-sm\">{body}</dd>\n </div>\n ))}\n </dl>\n </div>\n );\n return (\n <div className=\"flex flex-col gap-2\">\n {heading}\n {/* The grid is the styling contract's (`[data-buro-facts=\"grid\"]`); a fact is a tile, the one\n place a tile is earned: the number is the block's whole point. */}\n <dl data-buro-facts=\"grid\">\n {pairs.map(({ name, label, body }) => (\n <div\n key={name}\n data-buro-fact={name}\n className=\"flex min-w-0 flex-col gap-1 rounded-lg border bg-card px-4 py-3 text-card-foreground\"\n >\n <dt className={FIELD_LABEL_SHOW}>{label}</dt>\n <dd className=\"min-w-0 break-words text-xl font-semibold tabular-nums\">{body}</dd>\n </div>\n ))}\n </dl>\n </div>\n );\n}\n","import { createContext, useContext } from 'react';\n\n/** The placement a block view is rendered for: its key and its `state` node option. Internal. */\nexport interface PlacementFrame {\n readonly key: string;\n readonly state?: 'memory' | 'url';\n /** Found through a host's `block()` prop: its key is derived, so its list state is memory. */\n readonly nested: boolean;\n /** The placement's declared `where` (portable, refs unresolved): what its seeds come from. */\n readonly where?: readonly unknown[];\n /** The screen's source closure: which inputs each `with` source reaches. */\n readonly closure?: Readonly<Record<string, readonly string[]>>;\n /** The resource whose screen holds the placement (a record screen's); absent on a page. */\n readonly owner?: string;\n}\n\nexport const PlacementFrameContext = createContext<PlacementFrame | null>(null);\n\n/** The placement around a view, or `null` (the route list). Internal. */\nexport function usePlacementFrame(): PlacementFrame | null {\n return useContext(PlacementFrameContext);\n}\n","'use client';\nimport { useI18nCaps } from '@burojs/react';\nimport { resolveNavLabel } from '@burojs/core';\nimport { type ReactElement, useState } from 'react';\nimport { DisabledAction } from '../actions/action-button.js';\nimport { ActionInner } from '../actions/action-inner.js';\nimport { Button, type ButtonProps } from '../primitives/button.js';\nimport { useLinkComponent } from '../layout/link-component.js';\nimport { preloadFlowRuntime, RuntimeAppFlowRunner } from './load-runtime.js';\n\nexport interface AppFlowButtonProps {\n /** The entry `useAppActions()` returned for a `kind: 'flow'` app action. */\n readonly action: {\n readonly name: string;\n readonly label?: string;\n readonly icon?: string;\n readonly disabledReason?: string;\n /** A flow hosted on a custom page (P7 3.15): the control is a link to it, not a runner. */\n readonly hostHref?: string;\n };\n readonly variant?: ButtonProps['variant'];\n readonly size?: ButtonProps['size'];\n readonly className?: string;\n}\n\n/**\n * An app flow's control (P4-D: app flows are drawn). `useAppActions()` decides whether the\n * entry exists and whether it is disabled (the flow's gate); this button draws it, loads the\n * flow runtime on intent (a hover, a focus, at the latest the click) and runs the flow — its\n * host when it has a form or a review, else the send behind the confirm dialog. Busy from the\n * click until the interaction ends. Test id: `app-action:<name>`.\n */\nexport function AppFlowButton({\n action,\n variant = 'ghost',\n size = 'sm',\n className,\n}: AppFlowButtonProps): ReactElement {\n const caps = useI18nCaps();\n const [running, setRunning] = useState(false);\n const label = resolveNavLabel(caps, `appActions.${action.name}`, action.label);\n const testid = `app-action:${action.name}`;\n const Anchor = useLinkComponent();\n if (action.disabledReason !== undefined)\n return (\n <DisabledAction\n reason={action.disabledReason === '' ? undefined : action.disabledReason}\n label={label}\n icon={action.icon}\n testid={testid}\n size={size}\n variant={variant}\n className={className}\n actionName={action.name}\n surface=\"app\"\n />\n );\n if (action.hostHref !== undefined)\n return (\n <Button\n asChild\n variant={variant}\n size={size}\n className={className}\n data-testid={testid}\n data-buro-flow-state=\"ready\"\n >\n <Anchor href={action.hostHref}>\n <ActionInner icon={action.icon} label={label} />\n </Anchor>\n </Button>\n );\n return (\n <>\n <Button\n type=\"button\"\n variant={variant}\n size={size}\n className={className}\n data-testid={testid}\n disabled={running}\n aria-busy={running ? 'true' : undefined}\n onPointerEnter={preloadFlowRuntime}\n onFocus={preloadFlowRuntime}\n onClick={() => setRunning(true)}\n >\n <ActionInner icon={action.icon} label={label} />\n </Button>\n {running ? (\n <RuntimeAppFlowRunner\n name={action.name}\n label={label}\n testid={testid}\n onClose={() => setRunning(false)}\n />\n ) : null}\n </>\n );\n}\n","'use client';\nimport {\n canonicalEntityNodeKey,\n compileFlow,\n declaredText,\n type EntityRef,\n type FlowTarget,\n resolveNavLabel,\n} from '@burojs/core';\nimport {\n type BlockViewProps,\n useApp,\n useCurrentUserId,\n useI18nCaps,\n usePageFlowGate,\n useFlowRowResolver,\n policyRecordOf,\n useOptionalRecordFrame,\n useScreenState,\n useTestIds,\n} from '@burojs/react';\nimport { type ReactElement, useEffect, useMemo, useSyncExternalStore } from 'react';\nimport { usePlacementFrame } from '../blocks/placement-frame.js';\nimport { Skeleton } from '../primitives/skeleton.js';\nimport { AppFlowButton } from './app-flow-button.js';\nimport { FlowActionButton } from './flow-action-button.js';\nimport { FlowBoundary, loadFailedText, loadInlineFlowHost, useLoaded } from './load-runtime.js';\n\nconst NO_SUBSCRIBE = () => () => undefined;\nconst ZERO = () => 0;\n\n/**\n * The built-in `buro:inline-flow` view (P6 3.12): an item flow of the screen's own resource,\n * drawn in place. The gate is the placement's own (the planner already dropped a denied one)\n * conjoined with the flow's: nothing is read or drawn before it is decided; a flow whose gate\n * hides it leaves no trace. A flow without a form or a review is its button; a slot another\n * mounted screen already holds (a sheet over the page) is the button too.\n */\nexport function InlineFlowView({ props }: BlockViewProps<unknown>): ReactElement | null {\n const name = (props as { readonly flow?: unknown }).flow;\n // On a page the flow is named by a reference, and there is no record (P7 3.15).\n if (name !== null && typeof name === 'object')\n return <PageInlineFlow flow={name as PageFlowRef} />;\n return <RecordInlineFlow name={name} />;\n}\n\ntype PageFlowRef =\n | { readonly app: EntityRef }\n | { readonly resource: EntityRef; readonly flow: string };\n\nfunction RecordInlineFlow({ name }: { readonly name: unknown }): ReactElement | null {\n const frame = useOptionalRecordFrame();\n const placement = usePlacementFrame();\n const app = useApp();\n const tid = useTestIds();\n const holder = useScreenState()?.inline;\n // A discard (or any release) of this screen's leases re-renders the placement.\n useSyncExternalStore(\n holder?.subscribe ?? NO_SUBSCRIBE,\n holder?.version ?? ZERO,\n holder?.version ?? ZERO,\n );\n const userId = useCurrentUserId();\n const resource = frame?.resource ?? '';\n const flowName = typeof name === 'string' ? name : '';\n const resolve = useFlowRowResolver(resource);\n const def = app.registry.get(resource);\n const compiled = useMemo(() => {\n try {\n return def === undefined ? null : compileFlow(def as never, flowName);\n } catch {\n return null;\n }\n }, [def, flowName]);\n const id = frame?.recordId;\n // The gate and the flow read the record as read; what the form renders projects on its own\n // (P4 4.24 C2, P5 decision 12).\n const asRead = frame === null ? undefined : policyRecordOf(frame.controller, frame.record);\n const key = placement?.key ?? flowName;\n // A flow whose `when` turned false keeps its node while the input is dirty or its attempt\n // unresolved (3.12); a denied or clean one is released at once.\n const state =\n frame === null || id === undefined || asRead === undefined\n ? null\n : resolve(flowName, { ...asRead, id } as { id: string } & Record<string, unknown>);\n const kept = holder?.get(key);\n const stale =\n state?.state === 'absent' && state.cause === 'when' && kept !== undefined && kept.dirty;\n const gone = state?.state === 'absent' && !stale;\n useEffect(() => {\n if (gone) holder?.release(key);\n }, [gone, holder, key]);\n if (frame === null || asRead === undefined || id === undefined || compiled === null) return null;\n const row = { ...asRead, id } as { id: string } & Record<string, unknown>;\n const control = resolve(flowName, row);\n switch (control.state) {\n case 'undecided':\n case 'pending':\n return (\n <Skeleton\n className=\"h-24 w-full\"\n data-testid={tid.inlineFlow(compiled.flowId, key)}\n data-buro-flow-state=\"pending\"\n />\n );\n case 'absent':\n if (!stale || kept === undefined) return null;\n return (\n <InlineHostLoader\n resource={resource}\n name={flowName}\n record={row as never}\n placementKey={key}\n lease={kept}\n stale\n onDiscard={() => holder?.release(key)}\n />\n );\n default:\n }\n const button = (\n <FlowActionButton resource={resource} actionName={flowName} record={row} scope=\"show\" />\n );\n // A pre-click check that starts blocking under unsaved input: the notice and Discard, not a\n // disabled button over a hidden form (3.12).\n if (control.state === 'disabled' && kept !== undefined && kept.dirty)\n return (\n <InlineHostLoader\n resource={resource}\n name={flowName}\n record={row as never}\n placementKey={key}\n lease={kept}\n stale\n onDiscard={() => holder?.release(key)}\n />\n );\n if (control.state === 'disabled' || !compiled.hasHost) return button;\n const lease = holder?.acquire(key, compiled.flowId, id, userId ?? '');\n if (lease === 'held-elsewhere') return button;\n return (\n <InlineHostLoader\n resource={resource}\n name={flowName}\n record={(control.record ?? row) as never}\n placementKey={key}\n {...(lease === undefined ? {} : { lease })}\n />\n );\n}\n\nfunction InlineHostLoader(\n props: Parameters<typeof import('./inline-flow-host.js').InlineFlowHost>[0],\n): ReactElement {\n const loaded = useLoaded(loadInlineFlowHost);\n if (loaded.error !== undefined)\n return (\n <p role=\"alert\" className=\"text-sm text-muted-foreground\">\n {loadFailedText((key: string) => key)}\n </p>\n );\n if (loaded.module === undefined) return <Skeleton className=\"h-24 w-full\" />;\n const Host = loaded.module.InlineFlowHost;\n return (\n <FlowBoundary\n fallback={() => (\n <p role=\"alert\" className=\"text-sm text-muted-foreground\">\n {loadFailedText((key: string) => key)}\n </p>\n )}\n >\n <Host {...props} />\n </FlowBoundary>\n );\n}\n\n/**\n * An app flow or a resource-level flow drawn in place on a custom page (P7 3.15). The gate is the\n * flow's own (`resolveFlowGate`, decided before anything is read): undecided is a skeleton,\n * absent leaves no trace. A flow without a form or a review is its button; one with a host holds\n * the page's lease for the flow, so a tab switch away and back finds the typed input.\n */\nfunction PageInlineFlow({ flow }: { readonly flow: PageFlowRef }): ReactElement | null {\n const placement = usePlacementFrame();\n const app = useApp();\n const caps = useI18nCaps();\n const tid = useTestIds();\n const holder = useScreenState()?.inline;\n useSyncExternalStore(\n holder?.subscribe ?? NO_SUBSCRIBE,\n holder?.version ?? ZERO,\n holder?.version ?? ZERO,\n );\n const userId = useCurrentUserId();\n const target = useMemo<FlowTarget>(\n () =>\n 'app' in flow\n ? { appAction: canonicalEntityNodeKey({ name: flow.app.id, ref: flow.app }) }\n : {\n resource: canonicalEntityNodeKey({ name: flow.resource.id, ref: flow.resource }),\n action: flow.flow,\n },\n [flow],\n );\n const { answer, compiled } = usePageFlowGate(target);\n const key = placement?.key ?? ('appAction' in target ? target.appAction : target.action);\n const gone = answer.state === 'absent' || answer.state === 'hidden';\n useEffect(() => {\n if (gone) holder?.release(key);\n }, [gone, holder, key]);\n if (compiled === null || gone) return null;\n if (answer.state === 'undecided')\n return (\n <Skeleton\n className=\"h-24 w-full\"\n data-testid={tid.inlineFlow(compiled.flowId, key)}\n data-buro-flow-state=\"pending\"\n />\n );\n const appAction =\n 'appAction' in target ? app.registry.appActions.get(target.appAction) : undefined;\n const label =\n appAction === undefined\n ? undefined\n : resolveNavLabel(\n caps,\n `appActions.${'appAction' in target ? target.appAction : ''}`,\n declaredText('flow', appAction, 'label'),\n );\n const button =\n 'appAction' in target ? (\n <AppFlowButton\n action={{\n name: target.appAction,\n label: declaredText('flow', appAction, 'label') ?? target.appAction,\n ...(appAction?.icon === undefined ? {} : { icon: appAction.icon }),\n ...(answer.state === 'disabled' ? { disabledReason: answer.reason ?? '' } : {}),\n }}\n variant=\"outline\"\n size=\"default\"\n />\n ) : (\n <FlowActionButton resource={target.resource} actionName={target.action} scope=\"page\" />\n );\n if (answer.state === 'disabled' || !compiled.hasHost) return button;\n const lease = holder?.acquire(key, compiled.flowId, 'page', userId ?? '');\n if (lease === 'held-elsewhere') return button;\n return (\n <InlineHostLoader\n target={target}\n placementKey={key}\n {...(label === undefined ? {} : { label })}\n {...(lease === undefined ? {} : { lease })}\n />\n );\n}\n","'use client';\nimport type { PlanNode, ScreenPlan } from '@burojs/core';\nimport {\n useEntryGate,\n useOptionalRouterAdapter,\n useQuickOpener,\n useSearchParamsWriter,\n} from '@burojs/react';\nimport {\n type Context,\n type ReactElement,\n type ReactNode,\n createContext,\n createElement,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nconst SUFFIX = '.open';\n\n/** The drawn placements of a route screen, by key: what the sweep asks before it drops a link. */\ninterface DeepLinkRegistry {\n register(key: string): () => void;\n has(key: string): boolean;\n}\n\nconst DeepLinkRegistryContext: Context<DeepLinkRegistry | null> =\n createContext<DeepLinkRegistry | null>(null);\n\nfunction notice(param: string, id: string, why: string): void {\n if (process.env.NODE_ENV === 'production') return;\n console.warn(`[burojs] ?${param}=${id} was dropped: ${why}.`);\n}\n\n/**\n * The deep link `?<key>.open=<id>` of a drawn placement (spec 4.8, P3-24/25): once the entry gate\n * has decided, an `open` answer opens the row's `quick.show` and the parameter is removed with a\n * `replace` (consumed once); any other answer removes it with one development notice; undecided\n * (the permission map loads) waits, and nothing is read meanwhile. `key` is the placement's key on\n * a route screen, or the resource's own namespace on the route list of a resource without a page.\n */\nexport function useDeepLinkOpen(key: string | null, target: string, enabled: boolean): void {\n const adapter = useOptionalRouterAdapter();\n const gate = useEntryGate();\n const open = useQuickOpener();\n const write = useSearchParamsWriter();\n const registry = useContext(DeepLinkRegistryContext);\n const param = key === null ? null : `${key}${SUFFIX}`;\n const id = param === null ? null : (adapter?.searchParams.get(param) ?? null);\n // A drawn placement says so: the sweep leaves its parameter to it.\n useEffect(() => {\n if (!enabled || key === null || registry === null) return;\n return registry.register(key);\n }, [enabled, key, registry]);\n const handled = useRef<string | null>(null);\n useEffect(() => {\n if (!enabled || param === null || id === null || adapter === null) return;\n const token = `${param}=${id}`;\n if (handled.current === token) return;\n const answer = gate(target, 'show');\n if (answer.state === 'undecided') return;\n handled.current = token;\n const drop = () => write((params) => params.delete(param), { history: 'replace' });\n if (id === '') {\n notice(param, id, 'it names no record');\n drop();\n return;\n }\n if (answer.state !== 'open') {\n notice(param, id, answer.why);\n drop();\n return;\n }\n open(target, id);\n drop();\n }, [enabled, param, id, adapter, gate, target, open, write]);\n}\n\n/** The keyed placements of a plan, by key. */\nfunction placements(plan: ScreenPlan): Map<string, PlanNode> {\n const out = new Map<string, PlanNode>();\n const walk = (nodes: readonly PlanNode[]) => {\n for (const node of nodes) {\n if (node.kind === 'place' && node.key !== undefined) out.set(node.key, node);\n walk(node.children);\n }\n };\n walk(Object.values(plan.slots).flat());\n return out;\n}\n\n/**\n * A route screen's sweep (spec 4.8): once the plan has settled for a key a `?<key>.open`\n * parameter names (its placement is not pending), a parameter whose placement is absent, not\n * drawn (its tab not chosen) or unknown is removed with one development notice. A drawn\n * placement consumes its own parameter (`useDeepLinkOpen`); a pending one keeps it.\n */\nexport function DeepLinkScope({\n plan,\n enabled,\n children,\n}: {\n readonly plan: ScreenPlan | null;\n readonly enabled: boolean;\n readonly children: ReactNode;\n}): ReactElement {\n const adapter = useOptionalRouterAdapter();\n const write = useSearchParamsWriter();\n const drawn = useRef(new Map<string, number>());\n const registry = useMemo<DeepLinkRegistry>(\n () => ({\n register(key) {\n drawn.current.set(key, (drawn.current.get(key) ?? 0) + 1);\n return () => {\n const left = (drawn.current.get(key) ?? 1) - 1;\n if (left <= 0) drawn.current.delete(key);\n else drawn.current.set(key, left);\n };\n },\n has: (key) => drawn.current.has(key),\n }),\n [],\n );\n const search = adapter?.searchParams.toString() ?? '';\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the query string, not the params object\n useEffect(() => {\n if (!enabled || plan === null || adapter === null) return;\n const named = [...adapter.searchParams.keys()].filter((name) => name.endsWith(SUFFIX));\n if (named.length === 0) return;\n const nodes = placements(plan);\n // A drawn placement registers in its own effect; give a placement that became ready in this\n // commit one task to say so before deciding that it is not drawn.\n const timer = setTimeout(() => {\n const stale: { param: string; id: string; why: string }[] = [];\n for (const param of named) {\n const key = param.slice(0, -SUFFIX.length);\n if (registry.has(key)) continue;\n const node = nodes.get(key);\n const id = adapter.searchParams.get(param) ?? '';\n if (node === undefined) {\n // The route list of a page: false resource reads its own namespace, which is no\n // placement of this screen; leave it alone.\n continue;\n }\n if (node.state === 'pending') continue;\n stale.push({\n param,\n id,\n why:\n node.state === 'absent'\n ? `the placement \"${key}\" is absent (${node.reason ?? 'not shown'})`\n : `the placement \"${key}\" is not drawn`,\n });\n }\n if (stale.length === 0) return;\n for (const entry of stale) notice(entry.param, entry.id, entry.why);\n write(\n (params) => {\n for (const entry of stale) params.delete(entry.param);\n },\n { history: 'replace' },\n );\n }, 0);\n return () => clearTimeout(timer);\n }, [enabled, plan, search, registry, write]);\n return createElement(DeepLinkRegistryContext.Provider, { value: registry }, children);\n}\n","/** A `where` entry as a placement declares it: its `value` may be a portable ref. */\nexport interface PortableWhereEntry {\n readonly field: string;\n readonly op: string;\n readonly value: unknown;\n}\n\n/**\n * Inputs a seed never comes from: `route` (a URL value, or the opener's id inside a quick entry)\n * and `values` (the form's unsaved input in edit).\n */\nconst UNTRUSTED: readonly string[] = ['route', 'values'];\n\n/** A portable ref, `{ kind: 'ref', source, path }`. */\nfunction refSource(value: unknown): string | null {\n if (value === null || typeof value !== 'object') return null;\n const ref = value as { readonly kind?: unknown; readonly source?: unknown };\n return ref.kind === 'ref' && typeof ref.source === 'string' ? ref.source : null;\n}\n\n/** A value with no ref anywhere in it: a literal. */\nfunction isLiteral(value: unknown): boolean {\n if (value === null || typeof value !== 'object') return true;\n if (refSource(value) !== null) return false;\n return Object.values(value as Record<string, unknown>).every(isLiteral);\n}\n\n/**\n * The seeds a placement's \"+ Create\" passes to `quick.create` (spec 4.5, P3-18): from each\n * `where` entry with `op: 'eq'` whose resolved value is ready (not `null` or `undefined`) and\n * whose declared value is a literal, a ref into `record` or `user`, or a ref into a `with` source\n * whose inputs never reach `route` or `values` (`closure`, the screen's source closure). A value\n * derived from `route` — a URL value on a route screen, the opener's id inside a quick entry — or\n * from `values` — the user's unsaved input — seeds nothing: the seeds land in the caller's trusted\n * defaults tier.\n */\nexport function placementSeeds(\n where: readonly PortableWhereEntry[],\n resolved: readonly { readonly field: string; readonly op: string; readonly value: unknown }[],\n closure: Readonly<Record<string, readonly string[]>>,\n): Readonly<Record<string, unknown>> {\n const seeds: Record<string, unknown> = {};\n where.forEach((entry, index) => {\n const value = resolved[index]?.value;\n if (entry.op !== 'eq' || value === null || value === undefined) return;\n if (resolved[index]?.field !== entry.field) return;\n const source = refSource(entry.value);\n const trusted =\n source === null\n ? isLiteral(entry.value)\n : source === 'record' ||\n source === 'user' ||\n (!UNTRUSTED.includes(source) &&\n Object.hasOwn(closure, source) &&\n !(closure[source] ?? []).some((input) => UNTRUSTED.includes(input)));\n if (trusted) seeds[entry.field] = value;\n });\n return Object.freeze(seeds);\n}\n","'use client';\n\nimport type * as React from 'react';\nimport {\n type EnumValue,\n enumFallbackKey,\n enumFallbackText,\n enumValueText,\n resolveContentSlot,\n resolveEnumLabel,\n} from '@burojs/core';\nimport { useApp, useEnumValues, useI18nCaps, type FieldPresentation } from '@burojs/react';\nimport { Badge } from '../primitives/badge.js';\nimport { Icon } from '../primitives/icon.js';\n\n/** Icon + localized label body shared by the resolved + fallback badges. */\nfunction BadgeBody({ icon, label }: { icon?: string; label: string }): React.ReactElement {\n return (\n <span className=\"inline-flex items-center gap-1\">\n {icon ? <Icon name={icon} className=\"size-3.5 shrink-0\" /> : null}\n {label}\n </span>\n );\n}\n\nexport interface EnumBadgeProps {\n /** Name of the enum registered via `defineEnum` + `app.use(...)`. */\n enumName: string;\n /** Raw value as stored on the record. */\n value: string | null | undefined;\n /** Test-id override. Defaults to `enum-badge:<enumName>:<value>`. */\n testid?: string;\n /** Custom class name passed through to the underlying Badge. */\n className?: string;\n /** `'plain'` drops the Badge wrapper and renders the label bare. */\n presentation?: FieldPresentation;\n}\n\n/**\n * Renders a status / type / kind badge by looking up the enum + value\n * from the app registry.\n *\n * Resolution order:\n * 1. Look up `app.registry.enums.get(enumName)`.\n * 2. Find the matching value entry inside the enum.\n * 3. Render `<Badge variant={value.color ?? 'outline'}>{value.label}</Badge>`.\n *\n * Fallbacks:\n * - Enum not registered → render plain `<span>` with the raw value.\n * No error — this is intentional so a half-shipped enum (e.g. waiting\n * for a follow-up registration) does not crash an admin page.\n * - Value is null/empty → render an em-dash placeholder.\n * - Value is unknown to the enum AND `enum.fallback` is set → render the\n * fallback label/color.\n * - Value is unknown AND no `fallback` declared → render the raw value\n * as a plain badge (variant `outline`).\n */\nexport function EnumBadge({\n enumName,\n value,\n testid,\n className,\n presentation,\n}: EnumBadgeProps): React.ReactElement {\n const app = useApp();\n const caps = useI18nCaps();\n const def = app.registry.enums.get(enumName);\n const { values, isLoading, error } = useEnumValues(enumName);\n // Enum labels resolve from the `enums.<ns>.<value>` bundle; namespace defaults\n // to the enum name (overridable via `i18nNamespace`). Falls back to the inline\n // def label until the enum is migrated to the bundle (phase 4).\n const ns = (def as { i18nNamespace?: string } | undefined)?.i18nNamespace ?? enumName;\n const id = testid ?? `enum-badge:${enumName}:${String(value ?? 'null')}`;\n\n if (value == null || value === '') {\n return (\n <span data-testid={`${id}:empty`} className=\"text-muted-foreground\">\n —\n </span>\n );\n }\n\n if (!def) {\n // Enum not registered — degrade to plain text. Adopters get a console\n // warning the first time the lookup misses (cheap to do, not throttled\n // because dev-mode only).\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(\n `[EnumBadge] enum '${enumName}' not registered — rendering raw value '${value}'`,\n );\n }\n return (\n <span data-testid={`${id}:unregistered`} className={className}>\n {value}\n </span>\n );\n }\n\n // Loader-backed enum still resolving — render a small skeleton placeholder\n // so the table cell doesn't shift once the values arrive.\n if (isLoading) {\n // plain: a filled, fixed-height pill is exactly the chrome contract\n // points 1 and 3 rule out — no background/border shape, no fixed height.\n // An inline pulsing ellipsis carries the same \"still loading\" meaning\n // without either.\n if (presentation === 'plain') {\n return (\n <span\n data-testid={`${id}:loading`}\n className={`animate-pulse text-muted-foreground ${className ?? ''}`}\n aria-busy=\"true\"\n >\n …\n </span>\n );\n }\n return (\n <span\n data-testid={`${id}:loading`}\n className={`inline-block h-5 w-12 animate-pulse rounded bg-muted ${className ?? ''}`}\n aria-busy=\"true\"\n />\n );\n }\n\n // Loader rejected — graceful degradation: show the raw value as plain\n // text (same fail-soft policy as the unregistered branch above).\n if (error) {\n return (\n <span data-testid={`${id}:error`} className={className} title={error.message}>\n {value}\n </span>\n );\n }\n\n const entry: EnumValue | undefined = values?.find((v) => v.value === value);\n\n if (entry) {\n const body = (\n <BadgeBody\n icon={entry.icon}\n label={resolveEnumLabel(caps, ns, value, enumValueText(def, value) ?? entry.label)}\n />\n );\n // plain: the label and icon carry the whole meaning here — the colour is\n // decoration on top of a word that already says «Draft». Dropping the\n // Badge wrapper therefore loses nothing (contract point 4).\n if (presentation === 'plain') {\n return (\n <span data-testid={id} data-icon={entry.icon} className={className}>\n {body}\n </span>\n );\n }\n return (\n <Badge\n variant={entry.color ?? 'outline'}\n className={className}\n data-testid={id}\n data-icon={entry.icon}\n >\n {body}\n </Badge>\n );\n }\n\n // Value not in enum — fallback path. Its label is the slot\n // `enums.<ns>._fallback` (the underscore keeps it apart from a value named\n // `fallback`), the declared label its default, then the raw value.\n const declaredFallback = enumFallbackText(def);\n if (def?.fallback !== undefined || declaredFallback !== undefined) {\n const fallbackLabel =\n resolveContentSlot(caps, [enumFallbackKey(ns)], { default: declaredFallback }) ?? value;\n if (presentation === 'plain') {\n return (\n <span data-testid={`${id}:fallback`} className={className}>\n {fallbackLabel}\n </span>\n );\n }\n return (\n <Badge\n variant={def?.fallback?.color ?? 'outline'}\n className={className}\n data-testid={`${id}:fallback`}\n >\n {fallbackLabel}\n </Badge>\n );\n }\n\n if (presentation === 'plain') {\n return (\n <span data-testid={`${id}:unknown`} className={className}>\n {value}\n </span>\n );\n }\n return (\n <Badge variant=\"outline\" className={className} data-testid={`${id}:unknown`}>\n {value}\n </Badge>\n );\n}\n","import type { ExportArtifact } from '@burojs/core';\n\n/**\n * The ONLY place in the whole export feature allowed to touch\n * `URL.createObjectURL`/`revokeObjectURL` or an anchor click — `@burojs/core`\n * and `@burojs/export` are DOM-free by constraint (they run in workers/SSR\n * too), so the browser-only delivery step lives here, at the UI edge, behind\n * one narrow function `<ExportDialog>`'s succeeded view calls.\n *\n * A `blob` artifact never had a URL to begin with — one is minted here,\n * strictly for the duration of the click, then revoked immediately after so\n * this never leaks memory across repeated downloads. A `url` artifact\n * (already hosted, e.g. by REF-15's job storage) is opened the same way, via\n * a real anchor click rather than `window.open` — a `window.open` popup is\n * blocked by most browsers unless it happens inside the ORIGINAL user\n * gesture's call stack; routing both artifact kinds through one synchronous\n * anchor-click keeps that guarantee for the `url` case, which a router-level\n * `await` between the click and this call could otherwise break.\n */\nexport function downloadArtifact(artifact: ExportArtifact): void {\n const { href, revoke } =\n artifact.kind === 'blob'\n ? { href: URL.createObjectURL(artifact.blob), revoke: true as const }\n : { href: artifact.url, revoke: false as const };\n\n const anchor = document.createElement('a');\n anchor.href = href;\n anchor.rel = 'noopener noreferrer';\n if (artifact.kind === 'blob') {\n anchor.download = artifact.filename;\n } else {\n anchor.target = '_blank';\n }\n document.body.appendChild(anchor);\n anchor.click();\n document.body.removeChild(anchor);\n\n if (revoke) URL.revokeObjectURL(href);\n}\n","'use client';\nimport type { DataRuntimeContextValue } from '@burojs/react';\nimport { useDataRuntime, useExportRuns, useOptionalDataRuntime, useOptionalT } from '@burojs/react';\nimport * as React from 'react';\nimport { toast } from '../notification/toaster.js';\nimport { downloadArtifact } from './download.js';\n\n/**\n * Per-app-runtime registry of \"which `runId` is a mounted `<ExportDialog>`\n * currently displaying\", keyed by `DataRuntimeContextValue` — the SAME\n * keying `use-export.ts`'s `getExportRunsStore` uses for `ExportRunsStore`,\n * so two apps (or two tests, each with their own `createDataRuntime()`\n * lease) never see each other's displayed runs.\n *\n * Run-scoped, NOT resource-scoped (fix round 1, Important 2): a resource can\n * have two independent dialogs open at once (the toolbar's filter-scope\n * export and the bulk bar's ids-scope export both target the same resource\n * but are two different runs) — resource-scoping made an unrelated run's\n * *own* dialog suppress the toast for a DIFFERENT, already-backgrounded run\n * of that same resource, permanently (see `useExportRunWatcher`'s ordering\n * note for why \"permanently\" was the actual bug, not merely \"late\"). Each\n * `<ExportDialog>` registers the ONE `runId` it is actually showing (see\n * `export-dialog.tsx`'s own `useTrackDisplayedRun` call), so the watcher can\n * suppress exactly that run and nothing else.\n */\nconst displayedRunCounts = new WeakMap<DataRuntimeContextValue, Map<string, number>>();\n\n/**\n * Per-app-runtime set of run ids whose OUTCOME has already been\n * communicated to the user — either by a fired toast, or by a dialog that\n * was displaying that exact run at the moment it settled. Keyed by\n * `DataRuntimeContextValue`, NOT held in component state (fix round 1,\n * Important 1): `useExportRuns()` is backed by one APP-WIDE\n * `ExportRunsStore` per runtime, and a run survives in it — by design, so\n * the dialog's own download button and a future REF-15 panel can still read\n * it — until dismissed or the lease is disposed\n * (`packages/react/src/export/runs-store.ts`). `<ExportRunWatcherMount>`\n * lives inside `<ResourceListPage>`, which unmounts on ordinary route\n * navigation; a component-local `useRef` would forget every run it had\n * already announced the moment the user navigates away and back, and the\n * eager re-check on remount would re-toast a run that finished while they\n * were gone. Keying this set by the RUNTIME instead makes \"already told the\n * user\" survive exactly as long as the run itself does.\n */\nconst announcedRuns = new WeakMap<DataRuntimeContextValue, Set<string>>();\n\nfunction displayedRunCountsFor(runtime: DataRuntimeContextValue): Map<string, number> {\n let map = displayedRunCounts.get(runtime);\n if (map === undefined) {\n map = new Map();\n displayedRunCounts.set(runtime, map);\n }\n return map;\n}\n\nfunction announcedRunsFor(runtime: DataRuntimeContextValue): Set<string> {\n let set = announcedRuns.get(runtime);\n if (set === undefined) {\n set = new Set();\n announcedRuns.set(runtime, set);\n }\n return set;\n}\n\nfunction isRunDisplayed(runtime: DataRuntimeContextValue, runId: string): boolean {\n return (displayedRunCountsFor(runtime).get(runId) ?? 0) > 0;\n}\n\n/**\n * Registers the ONE `runId` a mounted `<ExportDialog>` is currently\n * displaying against the shared per-runtime registry\n * {@link displayedRunCounts} reads from. `undefined` (no active run yet, or\n * the dialog is closed) is a no-op — nothing to register. Call from\n * `<ExportDialog>` itself (fix round 1, Important 2: moved out of\n * `ExportButton`/the bulk-bar entry, which had no way to know WHICH run\n * their own dialog was showing — only the dialog does), with\n * `open ? runEntry?.runId : undefined`.\n *\n * A `useEffect`, not a during-render write: mutating shared module state\n * while rendering is unsafe under StrictMode's double-invoked render pass\n * (it would double-increment before the matching decrement ever ran).\n *\n * Reference-counted rather than a plain \"set/unset\": two dialogs could in\n * principle end up momentarily registering the identical `runId` during a\n * remount race, and a bare overwrite would let the first one's cleanup\n * erase the second's still-live registration.\n *\n * Uses `useOptionalDataRuntime()`, not the hard `useDataRuntime()` — unlike\n * `useResourceExport`/`useExportRuns` (frozen, `packages/react/src/export/`),\n * this hook is entirely OUR code, and `<ExportDialog>` is mounted (and unit-\n * tested, e.g. `export-dialog.test.tsx`) with `useResourceExport` itself\n * MOCKED and no real `dataRuntime` at all. There is nothing to register\n * against without a runtime, so `null` is simply a no-op, exactly like\n * `<ResourceListPage>`'s own compat-mode guard for the hard export hooks.\n */\nexport function useTrackDisplayedRun(runId: string | undefined): void {\n const runtime = useOptionalDataRuntime();\n React.useEffect(() => {\n if (runId === undefined || runtime === null) return;\n const map = displayedRunCountsFor(runtime);\n map.set(runId, (map.get(runId) ?? 0) + 1);\n return () => {\n const current = map.get(runId) ?? 0;\n if (current <= 1) map.delete(runId);\n else map.set(runId, current - 1);\n };\n }, [runtime, runId]);\n}\n\n/**\n * Background-completion toasts (Task 8). Watches every export run for THIS\n * app (`useExportRuns()` — one shared `ExportRunsStore` per\n * `DataRuntimeContextValue`) and, the moment a run settles into a terminal\n * state, decides EXACTLY ONCE what the user learns about it:\n *\n * - if `<ExportDialog>` is displaying that SAME run right now, nothing —\n * the dialog's own success/download or error view already told them;\n * - otherwise, `succeeded` → a success toast with a Download action,\n * `failed` → an error toast, `canceled` → nothing (partial files are\n * never delivered, and a user-initiated cancel needs no completion\n * announcement — the dialog's own \"Stop export\" already confirmed the\n * action live).\n *\n * That decision is recorded in the shared, runtime-keyed\n * {@link announcedRuns} set — never in component state, so it survives this\n * hook unmounting and remounting with the run still un-dismissed (fix round\n * 1, Important 1) — and, critically, is recorded ONLY once one of those two\n * \"the user was told something\" branches is actually reached (fix round 1,\n * Important 2's ordering fix): a run whose dialog is showing a DIFFERENT run\n * is never marked, so it still gets its toast; nothing is ever marked on a\n * path where nobody was informed.\n */\nexport function useExportRunWatcher(): void {\n const runtime = useDataRuntime();\n const runs = useExportRuns();\n const t = useOptionalT();\n\n React.useEffect(() => {\n const announced = announcedRunsFor(runtime);\n const unsubscribes = runs.map((run) => {\n const check = (): void => {\n if (announced.has(run.runId)) return;\n const state = run.handle.getState();\n if (state.status === 'running') return; // not terminal yet — no decision to make\n\n if (isRunDisplayed(runtime, run.runId)) {\n // THIS run's own dialog is showing it right now — that IS the\n // notification. Mark it told, permanently: once marked here, a\n // later close of that same dialog must never retroactively fire a\n // toast (the guard above already prevents re-entry regardless).\n announced.add(run.runId);\n return;\n }\n\n announced.add(run.runId);\n if (state.status === 'succeeded') {\n const artifact = state.artifact;\n toast.success(t('export.toast.succeeded'), {\n action: {\n label: t('export.toast.download'),\n onClick: () => downloadArtifact(artifact),\n },\n });\n } else if (state.status === 'failed') {\n toast.error(t('export.toast.failed', { params: { message: state.error.message } }));\n }\n // 'canceled': no toast, by contract — the \"Stop export\" click that\n // caused this already told the user synchronously; still marked\n // announced immediately above so this branch is never re-entered.\n };\n // A run can already be terminal by the time this effect (re)subscribes\n // — e.g. it settled while no watcher was mounted at all (the user\n // navigated away and the page unmounted), or between one `runs`\n // snapshot and the next. Firing once eagerly on (re)subscribe is what\n // catches both cases; the guard above keeps it a no-op for every run\n // this runtime's shared set has already recorded.\n check();\n return run.handle.subscribe(check);\n });\n return () => {\n for (const unsubscribe of unsubscribes) unsubscribe();\n };\n }, [runs, runtime, t]);\n}\n","'use client';\nimport { isBuiltinItemAction, recordEntries } from '@burojs/core';\nimport { useApp, useItemActions, useOptionalT, useTestIds } from '@burojs/react';\nimport { IconDots } from '@tabler/icons-react';\nimport { createContext, Fragment, useContext, useState } from 'react';\nimport { cn } from '../lib/cn.js';\nimport { Button } from '../primitives/button.js';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../primitives/dropdown-menu.js';\nimport { FlowMenuItem, useHostedFlow } from '../flows/flow-action-button.js';\nimport { preloadFlowRuntime, RuntimeFlowRunner } from '../flows/load-runtime.js';\nimport { ActionButton } from './action-button.js';\n\nexport interface ActionOverflowProps {\n resource: string;\n record: { id: string } & Record<string, unknown>;\n /**\n * Which surface is rendering. Any string: the core's surface vocabulary is\n * an augmentable interface, so an adopter panel passes its own name and gets\n * the same resolved list.\n */\n surface: string;\n className?: string;\n /**\n * Flows this screen presents inline (P6 3.12): their own button is not drawn here, the\n * placement is their control on this screen.\n */\n hideFlows?: (name: string) => boolean;\n /**\n * A row in a narrow list: every action goes into the one menu, so the actions column is a single\n * control wide. Default: {@link RowActionsCollapseContext}.\n */\n collapse?: boolean;\n}\n\n/**\n * A row in a narrow list (`ResourceList` measures its own width): every row action goes into the\n * one menu. A context, not a cell prop, because the table's memoized rows do not re-render when a\n * column definition changes.\n */\nexport const RowActionsCollapseContext = createContext(false);\n\n/**\n * Collapses an entity's actions into an overflow menu so tables and detail\n * toolbars don't bloat with a button per action.\n *\n * Resolves its own list via `useItemActions` — hidden/denied actions are\n * already absent, order is already applied, and each entry already carries\n * its resolved `placement`/`density`. `'standalone'` entries render as their\n * own control (at their resolved density — icon-only on a row, icon+label on\n * a toolbar); everything else collapses into one menu after them, with the\n * destructive tail set off by a separator. Menu items reuse\n * `<ActionButton asMenuItem>` for a link or a modal and `<FlowMenuItem>` for a\n * flow, whose run continues outside the dropdown. Tone is NOT\n * hardcoded here (no more `variant=\"ghost\"`): it comes from each action's own\n * `variant`, exactly like the menu items already respected it — a hardcoded\n * `ghost` used to strip a destructive standalone action of its destructive\n * look.\n */\nexport function ActionOverflow({\n resource,\n record,\n surface,\n className,\n hideFlows,\n collapse,\n}: ActionOverflowProps): React.ReactElement | null {\n const t = useOptionalT();\n const tid = useTestIds();\n const collapsedRows = useContext(RowActionsCollapseContext);\n // A flow selected from the menu runs here, outside the menu (P4 spec 4.15): the menu closes\n // normally, and the run — its host, its confirm, its outcome — outlives it.\n const [flowFor, setFlowFor] = useState<{\n readonly name: string;\n readonly record: typeof record;\n } | null>(null);\n // ONE list. The container no longer partitions a caller-supplied array and\n // no longer re-filters by availability: `useItemActions` already dropped\n // everything hidden or denied, which is what stopped the old code from\n // rendering an empty menu.\n const actions = useShownItemActions(resource, record, surface, hideFlows);\n\n if (actions.length === 0) return null;\n\n const isRow = surface === 'row';\n const folded = isRow && (collapse ?? collapsedRows);\n const standalone = folded ? [] : actions.filter((a) => a.placement === 'standalone');\n const menu = folded ? actions : actions.filter((a) => a.placement === 'menu');\n const menuTestId = isRow\n ? tid.listRowActionsMenu(resource, record.id)\n : tid.formActionsMenu(resource, surface);\n // The destructive tail gets a rule above it. Computed off the RESOLVED list,\n // not off a hardcoded 'delete', so an adopter's own destructive action is\n // grouped the same way.\n const firstDestructive = menu.findIndex((a) => a.variant === 'destructive');\n\n // A flow's run is owned HERE, not by its menu item: its host, its confirm dialog and its\n // outcome are Radix layers that must not live inside the open menu (two competing focus\n // scopes), so the menu closes normally on select and this sibling takes over.\n //\n // The dropdown below is `modal={false}` for the same reason: a modal Radix menu locks\n // `pointer-events` on the body and marks everything outside itself `aria-hidden`, which would\n // swallow the flow's dialog rendered as its sibling.\n const overlays = (\n <>\n {flowFor != null ? (\n <RuntimeFlowRunner\n resource={resource}\n actionName={flowFor.name}\n record={flowFor.record}\n scope={surface}\n onClose={() => setFlowFor(null)}\n />\n ) : null}\n </>\n );\n\n const buttons = standalone.map((a) => (\n <ActionButton\n key={a.name}\n resource={resource}\n actionName={a.name}\n record={record}\n scope={surface}\n // `density` is only ever null when `placement === 'menu'`\n // (`ItemActionPlacement`'s own invariant, enforced by\n // `resolveActionDensity`) — this entry came from the `standalone`\n // filter above, so it is never null here. No `?? 'regular'`\n // fallback: that would be dead code masking a real core bug if the\n // invariant ever broke. `<ActionButton>`'s own `density ?? 'regular'`\n // default (each leaf renderer) stays — it protects a direct\n // `<ActionButton>` caller that supplies no density at all.\n density={a.density!}\n />\n ));\n\n return (\n // A record's actions wrap onto a second line where the width runs out (a quick sheet is\n // narrower than a page); a row's strip never wraps (its column is sized to it).\n <div\n className={cn(\n 'flex items-center',\n isRow ? 'justify-end gap-1' : 'flex-wrap gap-2',\n className,\n )}\n >\n {isRow && buttons.length > 0 ? (\n // Revealed on the row's hover or keyboard focus (always on a touch screen, which has no\n // hover). Opacity, not display: the strip keeps its box, so nothing shifts as it shows.\n <span\n data-buro-row-standalone=\"\"\n className=\"flex items-center gap-1 opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 [@media(hover:none)]:opacity-100\"\n >\n {buttons}\n </span>\n ) : (\n buttons\n )}\n {menu.length > 0 && (\n <DropdownMenu\n modal={false}\n // A menu opening is the sign a user may run one of its flows: their runtime loads now.\n onOpenChange={(open) => {\n if (open && menu.some((entry) => entry.flow !== undefined)) preloadFlowRuntime();\n }}\n >\n <DropdownMenuTrigger asChild>\n {isRow ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n className=\"size-7\"\n data-testid={menuTestId}\n aria-label={t('actions.more', { defaultValue: 'More' })}\n >\n <IconDots className=\"h-4 w-4\" aria-hidden=\"true\" />\n </Button>\n ) : (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"gap-1.5\"\n data-testid={menuTestId}\n >\n <IconDots className=\"h-4 w-4\" aria-hidden=\"true\" />\n {t('actions.more', { defaultValue: 'More' })}\n </Button>\n )}\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {menu.map((a, index) => (\n <Fragment key={a.name}>\n {index === firstDestructive && index > 0 && (\n <DropdownMenuSeparator\n data-testid={\n isRow\n ? `list-row-actions-separator:${resource}:${record.id}`\n : `form-actions-separator:${resource}:${surface}`\n }\n />\n )}\n {a.flow === undefined ? (\n <ActionButton\n resource={resource}\n actionName={a.name}\n record={record}\n scope={surface}\n asMenuItem\n />\n ) : (\n <FlowMenuItem\n resource={resource}\n actionName={a.name}\n record={record}\n scope={surface}\n control={a.flow}\n // A flow of this menu runs: the others are busy until it is over (M4).\n active={flowFor !== null}\n onRun={() =>\n setFlowFor({\n name: a.name,\n record: (a.flow?.record as typeof record | undefined) ?? record,\n })\n }\n />\n )}\n </Fragment>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n {overlays}\n </div>\n );\n}\n\n/**\n * The item actions `<ActionOverflow>` draws on `surface`: `useItemActions`' list, minus a\n * built-in Edit that leads nowhere (spec 4.3). Also read by a record frame's runtime check of\n * `<RecordActions/>`.\n */\nexport function useShownItemActions(\n resource: string,\n record: { id: string } & Record<string, unknown>,\n surface: string,\n hideFlows?: (name: string) => boolean,\n) {\n const resolved = useItemActions({ resource, record, surface });\n // The built-in Edit of a resource with neither an edit page nor a quick edit leads nowhere\n // (spec 4.3): it is not drawn at all, so it leaves no empty slot or menu behind.\n const def = useApp().registry.get(resource);\n const editNowhere =\n def !== undefined &&\n isBuiltinItemAction(\n (def.actions?.item as readonly { readonly name?: string }[] | undefined)?.find(\n (action) => action.name === 'edit',\n ),\n 'edit',\n ) &&\n !recordEntries(def).page.edit &&\n recordEntries(def).quick.edit === null;\n const shown = editNowhere ? resolved.filter((a) => a.name !== 'edit') : resolved;\n return hideFlows === undefined\n ? shown\n : shown.filter((a) => a.flow === undefined || !hideFlows(a.name));\n}\n","import {\n type AppRuntime,\n type RouteDescriptor,\n type ScreenMode,\n hasRecordPage,\n resolveStaticAvailability,\n} from '@burojs/core';\nimport { resolveRoute } from '@burojs/react';\n\ntype Registry = AppRuntime['registry'];\n\n/**\n * Whether the resource's record route for `action` renders a record page: the\n * one availability test behind the router's gate (`<ResourcePageRouter>`\n * renders not-found otherwise), the header's choice of the record trail\n * (`recordTrailRoute`) and `isShowAvailable`, so those three cannot disagree. The test is the\n * resource's `operations` and its page switch `views.show.page`\n * (`hasRecordPage`): a `page: false` resource has no record route at all.\n */\nexport function recordRouteAvailable(\n registry: Registry,\n resource: string,\n action: ScreenMode,\n): boolean {\n if (resolveStaticAvailability(registry, resource, action).state !== 'available') return false;\n const def = registry.get(resource);\n return def !== undefined && hasRecordPage(def, action);\n}\n\n/** Whether the resource has a show page. */\nexport function isShowAvailable(registry: Registry, resource: string): boolean {\n return recordRouteAvailable(registry, resource, 'show');\n}\n\nexport function showTarget(resource: string, id: string): RouteDescriptor {\n return { resource, action: 'show', params: { id } };\n}\n\nexport function listTarget(resource: string): RouteDescriptor {\n return { resource, action: 'list' };\n}\n\n/**\n * Where a record page returns to — after a save or a create, and from the edit\n * back-link and Cancel: the record's show page when the resource has one, else\n * the list.\n */\nexport function recordReturnTarget(\n registry: Registry,\n resource: string,\n id: string,\n): RouteDescriptor {\n return isShowAvailable(registry, resource) ? showTarget(resource, id) : listTarget(resource);\n}\n\n/**\n * The edit page's back-link: `backHref` when the caller gives one, else the\n * record page's return target — the record's show page when the resource has\n * one, else the list — resolved through the registry (nesting-aware).\n */\nexport function editBackHref(\n registry: Registry,\n resource: string,\n id: string,\n backHref?: string,\n): string {\n return backHref ?? resolveRoute(recordReturnTarget(registry, resource, id), registry);\n}\n","/**\n * Canonical typography scale for the Buro playground / framework UI.\n *\n * Pick the constant that matches the *role* of the element (page title,\n * card-in-grid title, body text) rather than picking a Tailwind size by\n * appearance. This keeps the scale consistent across components and\n * makes future global tweaks a single-file change.\n *\n * **Scale at a glance**\n *\n * role | size | weight | tracking | typical use\n * ----------------|-------|-----------|-------------------|----------------------------------\n * h1 | 2xl | semibold | tracking-tight | page title (PageHeader)\n * h2 | xl | semibold | tracking-tight | sub-page section heading\n * h3 | lg | semibold | tracking-tight | card-as-hero title; in-card section\n * h4 | base | semibold | tracking-tight | sub-section inside a card\n * cardTitleHero | 2xl | semibold | tracking-tight | shadcn Card hero variant (CardTitle)\n * cardTitleGrid | sm | medium | — | Card-in-grid (Cards 01 dashboard)\n * body | base | normal | — | default paragraph\n * small | sm | normal | — | secondary text\n * muted | sm | normal | — | secondary muted (text-muted-foreground)\n * caption | 11px | semibold | uppercase + wider | sidebar caption / popover header\n *\n * Note: the existing `<CardTitle>` primitive defaults to `cardTitleHero`\n * (canonical shadcn). When using Card in a tight grid (e.g., dashboard\n * Cards 01 layout), pass `className={typography.cardTitleGrid}` to\n * override.\n *\n * Adopters can re-export their own constants on top of this module — the\n * exports are pure strings, no runtime cost.\n */\nexport const typography = {\n h1: 'text-2xl font-semibold tracking-tight',\n h2: 'text-xl font-semibold tracking-tight',\n h3: 'text-lg font-semibold tracking-tight',\n h4: 'text-base font-semibold tracking-tight',\n cardTitleHero: 'text-2xl font-semibold leading-none tracking-tight',\n cardTitleGrid: 'text-sm font-medium',\n body: 'text-base',\n small: 'text-sm',\n muted: 'text-sm text-muted-foreground',\n caption: 'text-[11px] font-semibold uppercase tracking-wider text-muted-foreground',\n} as const;\n\nexport type TypographyKey = keyof typeof typography;\n","'use client';\nimport { createContext, useCallback, useContext, useEffect, useRef, type ReactNode } from 'react';\n\nimport { useShell } from '../shell/shell-context.js';\n\ntype SetTitle = (title: string) => void;\nconst DocumentTitleContext = createContext<SetTitle | null>(null);\n\n/**\n * Register the desired `document.title` for the current page (suffixed with ` · <brand name>` under a `ShellProvider` brand). Under a\n * `DocumentTitleProvider` the title is applied AND DEFENDED against Next's\n * metadata writes (Next re-applies the root `metadata.title` to `<title>` on\n * soft navigations — same-URL clicks, `?query` changes, post-hydration ticks —\n * which otherwise resets the tab to the app default). WITHOUT a provider it\n * falls back to a plain one-shot `document.title` write (unchanged legacy\n * behavior, so PageHeader still works standalone / in tests).\n */\nexport function useDocumentTitle(title: string | undefined): void {\n const set = useContext(DocumentTitleContext);\n const brandName = useShell().brand?.name;\n const full = title == null || brandName === undefined ? title : `${title} · ${brandName}`;\n useEffect(() => {\n if (full == null) return;\n if (set) set(full);\n else if (typeof document !== 'undefined') document.title = full;\n }, [set, full]);\n}\n\n/**\n * Owns `document.title`: applies the registered title and re-asserts it via a\n * MutationObserver whenever something (Next's metadata system) changes `<title>`\n * to anything else. Mount ONCE around the app shell. Router-agnostic — no\n * next/react-router import.\n *\n * `routeKey` (typically the pathname, WITHOUT `?search`) lets a real page\n * change release the pinned title. Without this, a route that never calls\n * `useDocumentTitle` (no `PageHeader` — e.g. an embedded-only fallback panel,\n * or an unmatched custom-page fallback) would inherit the PREVIOUS page's\n * pinned title and the MutationObserver would actively defend that stale\n * value, fighting even Next's own default write — worse than the pre-guard\n * behavior, where a titleless route was merely passively stale. When\n * `routeKey` changes, `wantRef` is cleared so the titleless route falls back\n * to `<title>`'s own value (Next's metadata default) instead. The clear\n * happens DURING RENDER (comparing against a `prevKeyRef`), not in an effect:\n * this provider sits ABOVE `PageHeader` in the tree, so a parent effect would\n * run AFTER the child's `useDocumentTitle` effect and wipe the incoming\n * page's just-set title. A render-phase compare runs before any child effect,\n * so the release lands first and the incoming page's title (if any) is set\n * after it. Same-key rerenders (e.g. a `?tab=` change, or a same-URL click)\n * leave `wantRef` untouched, so the guard keeps defending the current title.\n */\nexport function DocumentTitleProvider({\n routeKey,\n children,\n}: {\n routeKey?: string;\n children: ReactNode;\n}) {\n const wantRef = useRef<string | null>(null);\n const prevKeyRef = useRef<string | undefined>(routeKey);\n if (routeKey !== prevKeyRef.current) {\n prevKeyRef.current = routeKey;\n wantRef.current = null;\n }\n\n const setTitle = useCallback<SetTitle>((title) => {\n wantRef.current = title;\n if (typeof document !== 'undefined' && document.title !== title) {\n document.title = title;\n }\n }, []);\n\n useEffect(() => {\n if (typeof document === 'undefined' || typeof MutationObserver === 'undefined') return;\n const reassert = () => {\n const want = wantRef.current;\n if (want != null && document.title !== want) document.title = want;\n };\n const obs = new MutationObserver(reassert);\n // Observe head subtree: catches both a <title> text mutation and a full\n // <title> element replacement (Next may do either).\n obs.observe(document.head, { childList: true, subtree: true, characterData: true });\n return () => obs.disconnect();\n }, []);\n\n return <DocumentTitleContext.Provider value={setTitle}>{children}</DocumentTitleContext.Provider>;\n}\n","'use client';\nimport type { ReactNode } from 'react';\nimport { resolveResourceLabel } from '@burojs/core';\nimport { useApp, useI18nCaps, useProjectedTitle, usePublishDocVariant, useT } from '@burojs/react';\nimport { ActionOverflow } from '../actions/action-overflow.js';\nimport { editBackHref } from '../layout/record-targets.js';\nimport { cn } from '../lib/cn.js';\nimport { typography } from '../lib/typography.js';\nimport { useLinkComponent } from '../layout/link-component.js';\nimport { useDocumentTitle } from '../layout/document-title.js';\n\nexport interface PageHeaderProps {\n /** Resource name (matches the registry key). Used for back-link target + label resolution. */\n resource: string;\n /**\n * Page mode. Drives default title:\n * - 'list' → labelPlural\n * - 'show' → label + ': ' + recordName\n * - 'edit' → 'Edit ' + label + ': ' + recordName\n * - 'create' → 'Create ' + label\n */\n mode: 'list' | 'show' | 'edit' | 'create';\n /** Display name of the current record (for show/edit). */\n recordName?: string;\n /**\n * Override the back-link href. By default points to the resource's basePath\n * (or `/{resource}` fallback) for show/edit/create.\n */\n backHref?: string;\n /** Override the back-link label. Defaults to labelPlural. */\n backLabel?: string;\n /** Slot for action buttons (Edit/Delete/+Create) on the right. */\n actions?: ReactNode;\n /** Override the rendered title text. */\n title?: string;\n /**\n * Optional breadcrumb slot rendered above the title. When provided,\n * the back-link is suppressed in favour of the breadcrumb (the two\n * are functionally redundant — a breadcrumb's leading link points\n * at the same URL as the back-link, with more spatial context).\n * Pass `<Breadcrumbs resource={resource} pageLabel={recordName} />` from\n * `@burojs/ui-shadcn` for the canonical resource-rooted layout.\n */\n breadcrumbs?: ReactNode;\n /**\n * Render the textual `← Back to …` link on detail pages. Defaults to FALSE.\n *\n * An app shell that already renders breadcrumbs in its top bar (the common\n * layout, and what the playground does) makes this link a third redundant nav\n * row stacked under the crumb — the exact \"breadcrumbs twice plus a title\"\n * clutter this default removes. Opt in when a page has no breadcrumb above it.\n */\n backLink?: boolean;\n /**\n * Render the page title as a VISIBLE heading. Defaults to FALSE.\n *\n * The title almost always restates the trailing breadcrumb directly above it\n * («Documents › Order codes №53» followed by an h1 «Order codes №53»), and an\n * h1 plus its margins costs ~70px of vertical space on every screen — space a\n * dense admin table wants back.\n *\n * The heading is NOT removed: it stays in the DOM as `sr-only`, because a page\n * without an h1 breaks heading-based navigation for screen-reader users, and\n * the title moves to `document.title` so the browser tab identifies the page.\n * Same computed string, three surfaces instead of one.\n */\n visibleTitle?: boolean;\n /**\n * Replace the resource label used to BUILD the title, without replacing the\n * title template. `title` overrides the whole string; this keeps the\n * localized «Create: {{label}}» / «Edit {{label}}» phrasing and only\n * swaps in a more specific noun (e.g. the picked document type). Callers\n * therefore don't have to reimplement the i18n template to say\n * «Create: Order codes».\n */\n labelOverride?: string;\n className?: string;\n}\n\nexport function PageHeader({\n resource,\n mode,\n recordName,\n backHref,\n backLabel,\n actions,\n title,\n breadcrumbs,\n backLink = false,\n visibleTitle = false,\n labelOverride,\n className,\n}: PageHeaderProps): React.ReactElement | null {\n const app = useApp();\n const t = useT();\n const def = app.registry.get(resource);\n const caps = useI18nCaps(resource);\n const RouterLink = useLinkComponent();\n\n const resourceSingle = resolveResourceLabel(caps, resource, 'single', def);\n const labelSingle = labelOverride ?? resourceSingle;\n // Deliberately NOT derived from `labelSingle`: the plural names the\n // COLLECTION the back-link returns to («Back to Documents»), which is still\n // the resource's list even when the title is about one specific type — a\n // typed override must not turn that into «Back to Order codes».\n const labelPlural = resolveResourceLabel(caps, resource, 'plural', def);\n\n const computedTitle =\n title ??\n (mode === 'list'\n ? labelPlural\n : mode === 'show'\n ? // Just the record's own title. Prefixing it with the resource label\n // (\"Document: Order codes №53\") duplicates what the breadcrumb above\n // already says and pushes the meaningful part to the right.\n (recordName ?? labelSingle)\n : mode === 'edit'\n ? recordName\n ? t('pageHeader.editTitleNamed', { params: { label: labelSingle, name: recordName } })\n : t('pageHeader.editTitle', { params: { label: labelSingle } })\n : t('pageHeader.createTitle', { params: { label: labelSingle } }));\n\n // Back-link: list mode has no back; show/edit/create go back to the\n // list. Breadcrumbs are functionally a richer back-link, so when the\n // caller provides a breadcrumb slot we suppress the text back-link\n // to avoid two redundant nav affordances stacked on top of each\n // other.\n // The tab is now the primary place the page announces itself, so it has to\n // stay in step with the heading — one computed value, set here rather than\n // duplicated per route. Delegated to useDocumentTitle: under a\n // DocumentTitleProvider (the playground admin shell) it's applied AND\n // defended against Next's re-application of the root metadata title on\n // soft navigations; standalone it's a plain one-shot document.title write.\n const fullTitle = app?.name ? `${computedTitle} · ${app.name}` : computedTitle;\n useDocumentTitle(fullTitle);\n\n const showBack = backLink && mode !== 'list' && !breadcrumbs;\n const computedBackHref = backHref ?? def?.basePath ?? `/${resource}`;\n const computedBackLabel = backLabel ?? labelPlural;\n\n return (\n <div className={cn('space-y-2', visibleTitle || actions ? 'mb-4' : 'mb-2', className)}>\n {breadcrumbs}\n {showBack && (\n <RouterLink\n href={computedBackHref}\n className=\"text-sm text-muted-foreground hover:text-foreground inline-flex items-center gap-1 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring rounded\"\n data-testid={`page-back:${resource}`}\n >\n ← {t('pageHeader.backTo', { params: { label: computedBackLabel } })}\n </RouterLink>\n )}\n {/*\n `flex-wrap` matters on phones: a detail toolbar (pinned action + \"…\" +\n Edit + Delete) next to a long title does not fit 390px, and without\n wrapping it forced the WHOLE PAGE into horizontal scroll — the heading,\n the tabs and every field row shifted with it. Wrapping lets the actions\n drop under the title instead. `min-w-0` lets the title itself shrink so\n it truncates rather than pushing the buttons off-screen.\n */}\n {/* An sr-only heading with no actions beside it would still render a\n flex row with gaps and margins — a blank strip where the h1 used to\n be, which defeats the point of reclaiming the space. */}\n {visibleTitle || actions ? (\n <div\n className={cn(\n 'flex flex-wrap items-center gap-2',\n // An `sr-only` heading occupies no width, so `justify-between` had\n // nothing to push against and the toolbar collapsed to the LEFT\n // edge of the page — the reported \"actions are nailed to the left\".\n // With no visible title the toolbar is the row's only content and\n // belongs at the trailing edge.\n visibleTitle ? 'justify-between' : 'justify-end',\n )}\n >\n <h1 className={visibleTitle ? cn(typography.h1, 'min-w-0 break-words') : 'sr-only'}>\n {computedTitle}\n </h1>\n {actions && <div className=\"flex flex-wrap items-center gap-2\">{actions}</div>}\n </div>\n ) : (\n <h1 className=\"sr-only\">{computedTitle}</h1>\n )}\n </div>\n );\n}\n\n/**\n * The show-page `<PageHeader>`: the breadcrumb, the record's title and the resolved\n * `<ActionOverflow surface=\"show\">` item-action list, then any `extraActions`.\n */\nexport function ShowPageHeader({\n resource,\n record,\n extraActions,\n breadcrumbs,\n}: {\n resource: string;\n record: { id: string } & Record<string, unknown>;\n extraActions?: ReactNode;\n breadcrumbs?: ReactNode;\n}): React.ReactElement | null {\n const app = useApp();\n const def = app.registry.get(resource);\n // Hook must run before any early return (rules of hooks). Resolves\n // `recordTitle(record)` → `record[displayField]` → `#id`.\n const recordName = useProjectedTitle(resource, (record as { id?: unknown })?.id, record);\n // Tell the breadcrumb trail which KIND of record this is, so its help offers\n // the type's articles alongside the resource's. The trail lives in the app\n // header — a sibling, not an ancestor — hence a store rather than context.\n usePublishDocVariant(resource, record);\n if (!def) return null;\n return (\n <PageHeader\n resource={resource}\n mode=\"show\"\n recordName={recordName}\n // Breadcrumbs are OPT-IN: a default one here would duplicate the app\n // shell's own top-bar crumb.\n breadcrumbs={breadcrumbs}\n actions={\n <>\n <ActionOverflow resource={resource} record={record} surface=\"show\" />\n {extraActions}\n </>\n }\n />\n );\n}\n\n/**\n * The edit-page `<PageHeader>`: the back-link, the record's title and the resolved\n * `<ActionOverflow surface=\"edit\">` item-action list.\n */\nexport function EditPageHeader({\n resource,\n record,\n backHref,\n breadcrumbs,\n}: {\n resource: string;\n record: { id: string } & Record<string, unknown>;\n backHref?: string;\n breadcrumbs?: ReactNode;\n}): React.ReactElement {\n const app = useApp();\n const def = app.registry.get(resource);\n const caps = useI18nCaps(resource);\n // Same resolution as the show header: recordTitle → displayField → #id.\n const recordName = useProjectedTitle(resource, (record as { id?: unknown })?.id, record);\n\n return (\n <PageHeader\n resource={resource}\n mode=\"edit\"\n recordName={recordName}\n backHref={editBackHref(app.registry, resource, String(record.id), backHref)}\n breadcrumbs={breadcrumbs}\n backLabel={\n recordName\n ? `${resolveResourceLabel(caps, resource, 'single', def)}: ${recordName}`\n : undefined\n }\n // `<ActionOverflow>` resolves its own list and returns null when it's\n // empty, so no length guard is needed here.\n actions={<ActionOverflow resource={resource} record={record} surface=\"edit\" />}\n />\n );\n}\n","'use client';\nimport type { ReactElement } from 'react';\nimport { Skeleton } from '../primitives/skeleton.js';\n\n/** The cards' grid; the cards themselves draw in it. */\nexport const RELATED_GRID_CLASS = 'grid grid-cols-1 gap-3 @md:grid-cols-2 @3xl:grid-cols-3';\n\n/** The cards' loading state: the grid with placeholder cards. */\nexport function RelatedCardsSkeleton(): ReactElement {\n return (\n <div className=\"@container\" data-buro-skeleton=\"\">\n <div className={RELATED_GRID_CLASS}>\n {Array.from({ length: 3 }, (_, index) => (\n <Skeleton key={index} className=\"h-24 w-full rounded-lg\" />\n ))}\n </div>\n </div>\n );\n}\n\n/** The timeline's loading state. */\nexport function RelatedTimelineSkeleton(): ReactElement {\n return (\n <div className=\"flex flex-col gap-2\" data-buro-skeleton=\"\">\n <Skeleton className=\"h-4 w-40\" />\n {Array.from({ length: 3 }, (_, index) => (\n <Skeleton key={index} className=\"h-10 w-full\" />\n ))}\n </div>\n );\n}\n","'use client';\nimport {\n type BlockProp,\n type CompiledScreen,\n type AnyBlockHandle,\n formatEntityRef,\n type PlanNode,\n validatePlacementProps,\n} from '@burojs/core';\nimport { type BlockViewProps, usePlacement } from '@burojs/react';\nimport {\n Component,\n type ErrorInfo,\n type ReactElement,\n type ReactNode,\n Suspense,\n useMemo,\n} from 'react';\nimport { useScreenTree } from '../screen/tree-context.js';\nimport { selectImplementation, viewOf } from './place-node.js';\n\n/**\n * The item of a `related-list` placement as its view receives it (P6 3.13): the planned item\n * node, not an element. The list draws it once per row with the row bound to the `item` source,\n * so nothing here is rendered until a row is.\n */\nexport interface ItemHandle {\n readonly kind: 'item-handle';\n readonly node: PlanNode;\n}\n\nexport const itemHandle = (node: PlanNode): ItemHandle =>\n Object.freeze({ kind: 'item-handle', node });\n\nexport function isItemHandle(value: unknown): value is ItemHandle {\n return (\n value !== null && typeof value === 'object' && (value as ItemHandle).kind === 'item-handle'\n );\n}\n\ntype Row = Readonly<Record<string, unknown>>;\ntype Definitions = Readonly<Record<string, BlockProp<unknown, unknown>>>;\n\ninterface Ref {\n readonly kind: 'ref';\n readonly source: string;\n readonly path: readonly string[];\n}\n\nconst isRef = (value: unknown): value is Ref =>\n value !== null &&\n typeof value === 'object' &&\n (value as { kind?: unknown }).kind === 'ref' &&\n typeof (value as { source?: unknown }).source === 'string' &&\n Array.isArray((value as { path?: unknown }).path);\n\n/** One path of the bound row. The row is the whole value of `ref('item')`. */\nfunction readRow(row: Row, path: readonly string[]): unknown {\n let current: unknown = row;\n for (const segment of path) {\n if (current === null || typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n return current;\n}\n\n/**\n * A prop value with every ref read: `item` is the bound row, any other source is not available\n * to an item and reads nothing (the prop then fails its schema, and the list falls back to the\n * default item).\n */\nfunction bind(value: unknown, row: Row): unknown {\n if (isRef(value)) return value.source === 'item' ? readRow(row, value.path) : undefined;\n if (Array.isArray(value)) return value.map((entry) => bind(entry, row));\n if (value !== null && typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) out[key] = bind(entry, row);\n return out;\n }\n return value;\n}\n\n/** What a placement writes for a prop, else its definition's ref default (a literal is validation's). */\nfunction written(\n props: Readonly<Record<string, unknown>>,\n name: string,\n definition: BlockProp<unknown, unknown>,\n): unknown {\n if (Object.hasOwn(props, name)) return props[name];\n const fallback = definition.defaultValue;\n return fallback?.kind === 'ref'\n ? { kind: 'ref', source: fallback.source, path: fallback.path }\n : undefined;\n}\n\n/** The first `item` field a ref reads, or undefined. */\nfunction itemField(value: unknown): string | undefined {\n if (isRef(value)) return value.source === 'item' ? value.path[0] : undefined;\n if (Array.isArray(value)) {\n for (const entry of value) {\n const found = itemField(entry);\n if (found !== undefined) return found;\n }\n return undefined;\n }\n if (value !== null && typeof value === 'object')\n for (const entry of Object.values(value)) {\n const found = itemField(entry);\n if (found !== undefined) return found;\n }\n return undefined;\n}\n\n/** Item props that failed validation, warned once each: a developer's schema mismatch, not an access answer. */\nconst warned = new Set<string>();\n\nfunction warnInvalid(label: string, validation: ReturnType<typeof validatePlacementProps>): void {\n if (process.env.NODE_ENV === 'production' || validation.status !== 'failed') return;\n const key = `${label}:${validation.prop}`;\n if (warned.has(key)) return;\n warned.add(key);\n console.warn(\n `[burojs] The item block ${label} of a related list does not accept its row, so the list draws the default item: the prop \"${validation.prop}\" ${validation.reason}.`,\n );\n}\n\nconst NO_NAMES: ReadonlySet<string> = new Set();\n\n/** The `block()` props of a node: those its nested placements fill. */\nfunction nestedNames(node: PlanNode, compiled: CompiledScreen): ReadonlySet<string> {\n const names = new Set<string>();\n for (const child of node.children) {\n const host = compiled.nodes[child.index]?.placement?.host;\n if (host !== undefined) names.add(host.prop);\n }\n return names;\n}\n\n/** The validated props of an item node for one row, or why it cannot be drawn. */\nfunction itemProps(\n block: AnyBlockHandle,\n raw: Readonly<Record<string, unknown>>,\n row: Row,\n /** The props that hold nested placements: drawn by the nodes below, never validated here. */\n nested: ReadonlySet<string> = NO_NAMES,\n): ReturnType<typeof validatePlacementProps> {\n const values: Record<string, unknown> = {};\n for (const [name, definition] of Object.entries(block.props as Definitions)) {\n if (nested.has(name)) continue;\n const value = bind(written(raw, name, definition), row);\n if (value !== undefined) values[name] = value;\n }\n return validatePlacementProps(block, values);\n}\n\n/**\n * Whether the item is drawn for this list at all, decided once for every row (P6-53): drawn only\n * when the planner decided it (its state is `ready`: a denied, undecided or failed `requires`\n * draws the default item), when no required prop reads a field the viewer may not see for every\n * row (`hidden` is an every-row question, so a rule reading the record counts as hiding it),\n * and when the first projected row satisfies its props.\n */\nexport function useItemDrawn(\n handle: ItemHandle | undefined,\n hidden: (field: string) => boolean,\n probe: Row | undefined,\n): boolean {\n const { compiled, controller } = useScreenTree();\n const placed = handle === undefined ? undefined : controller.placement(handle.node.key ?? '');\n const definition = placed?.definition;\n const blockName = placed === undefined ? 'item' : formatEntityRef(placed.block);\n const raw =\n handle === undefined ? undefined : compiled.nodes[handle.node.index]?.placement?.props;\n return useMemo(() => {\n if (handle === undefined || definition === undefined || raw === undefined) return false;\n if (handle.node.state !== 'ready') return false;\n const props = definition.props as Definitions;\n for (const [name, prop] of Object.entries(props)) {\n if (prop.isOptional) continue;\n const field = itemField(written(raw, name, prop));\n if (field !== undefined && hidden(field)) return false;\n }\n if (probe === undefined) return true;\n const validation = itemProps(definition, raw, probe, nestedNames(handle.node, compiled));\n warnInvalid(blockName, validation);\n return validation.status !== 'failed';\n }, [handle, definition, blockName, raw, hidden, probe, compiled]);\n}\n\nclass ItemBoundary extends Component<\n { readonly fallback: ReactNode; readonly children: ReactNode },\n { readonly failed: boolean }\n> {\n override state = { failed: false };\n\n static getDerivedStateFromError(): { readonly failed: boolean } {\n return { failed: true };\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo): void {\n if (process.env.NODE_ENV !== 'production')\n console.error(\n '[burojs] The item of a related list threw while rendering.',\n error,\n info.componentStack,\n );\n }\n\n override render(): ReactNode {\n return this.state.failed ? this.props.fallback : this.props.children;\n }\n}\n\n/**\n * One row of the list drawn through its item block: the item placement's props resolved with\n * `item` bound to `row` (the projected row, never the raw one), validated against the block's\n * schemas, the nested placements below it drawn the same way. A row whose props do not validate\n * draws `fallback`.\n */\nexport function RelatedItem({\n handle,\n row,\n fallback,\n}: {\n readonly handle: ItemHandle;\n readonly row: Row;\n readonly fallback: ReactNode;\n}): ReactElement {\n return (\n <ItemBoundary fallback={fallback}>\n <Suspense fallback={null}>\n <ItemNode node={handle.node} row={row} fallback={fallback} />\n </Suspense>\n </ItemBoundary>\n );\n}\n\nfunction ItemNode({\n node,\n row,\n fallback,\n}: {\n readonly node: PlanNode;\n readonly row: Row;\n readonly fallback: ReactNode;\n}): ReactNode {\n const { compiled, controller } = useScreenTree();\n const placement = usePlacement(node.key ?? '', controller);\n const definition = controller.placement(node.key ?? '')?.definition;\n const raw = compiled.nodes[node.index]?.placement?.props;\n const implementation = selectImplementation(\n formatEntityRef(placement.block),\n placement.appImplementation,\n );\n const validation = useMemo(\n () =>\n definition === undefined || raw === undefined\n ? undefined\n : itemProps(definition, raw, row, nestedNames(node, compiled)),\n [definition, raw, row, node, compiled],\n );\n if (node.state === 'absent') return null;\n if (node.state !== 'ready') return fallback;\n if (validation !== undefined) warnInvalid(formatEntityRef(placement.block), validation);\n if (\n placement.state !== 'ready' ||\n implementation === undefined ||\n validation === undefined ||\n validation.status !== 'ready'\n )\n return fallback;\n const props: Record<string, unknown> = { ...validation.props };\n const lists = new Map<string, ReactElement[]>();\n for (const child of node.children) {\n const host = compiled.nodes[child.index]?.placement?.host;\n if (host === undefined) continue;\n const element = (\n <ItemNode key={`${child.index}:${child.id}`} node={child} row={row} fallback={null} />\n );\n if (host.index === undefined) props[host.prop] = element;\n else {\n const list = lists.get(host.prop) ?? [];\n list[host.index] = element as ReactElement;\n lists.set(host.prop, list);\n }\n }\n for (const [name, list] of lists) props[name] = list.filter((entry) => entry !== undefined);\n const View = viewOf(implementation);\n const viewProps: BlockViewProps<unknown> = {\n props: props as BlockViewProps<unknown>['props'],\n data: {} as BlockViewProps<unknown>['data'],\n t: placement.viewProps?.t ?? ((name: string) => name),\n };\n return <View {...viewProps} />;\n}\n","'use client';\n\nimport * as React from 'react';\nimport * as TabsPrimitive from '@radix-ui/react-tabs';\nimport { cn } from '../lib/cn.js';\n\n/**\n * Thin shadcn-ui-style wrapper around `@radix-ui/react-tabs`. Exposed as\n * a primitive so feature components (e.g. the screen tree's tabs node) can compose\n * the standard accessible Tabs pattern without re-implementing radix\n * boilerplate.\n *\n * Controlled-vs-uncontrolled: pass `value`+`onValueChange` for URL-synced\n * tabs (the playground show page does this with `?tab=` query state); pass\n * `defaultValue` for purely-local tab state.\n */\nconst Tabs = TabsPrimitive.Root;\n\nexport type TabsListProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>;\n\nconst TabsList = React.forwardRef<React.ElementRef<typeof TabsPrimitive.List>, TabsListProps>(\n ({ className, ...props }, ref) => (\n <TabsPrimitive.List\n ref={ref}\n className={cn(\n 'inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground',\n className,\n )}\n {...props}\n />\n ),\n);\nTabsList.displayName = TabsPrimitive.List.displayName;\n\nexport type TabsTriggerProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>;\n\nconst TabsTrigger = React.forwardRef<\n React.ElementRef<typeof TabsPrimitive.Trigger>,\n TabsTriggerProps\n>(({ className, ...props }, ref) => (\n <TabsPrimitive.Trigger\n ref={ref}\n className={cn(\n 'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all',\n 'focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',\n 'disabled:pointer-events-none disabled:opacity-50',\n 'data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-xs',\n className,\n )}\n {...props}\n />\n));\nTabsTrigger.displayName = TabsPrimitive.Trigger.displayName;\n\nexport type TabsContentProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>;\n\nconst TabsContent = React.forwardRef<\n React.ElementRef<typeof TabsPrimitive.Content>,\n TabsContentProps\n>(({ className, ...props }, ref) => (\n <TabsPrimitive.Content\n ref={ref}\n className={cn(\n 'mt-4 ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',\n className,\n )}\n {...props}\n />\n));\nTabsContent.displayName = TabsPrimitive.Content.displayName;\n\nexport { Tabs, TabsList, TabsTrigger, TabsContent };\n","'use client';\nimport { type PlanNode, resolveTextSlot, type TextSlot } from '@burojs/core';\nimport type { FrameNodeAttributes } from '@burojs/react';\nimport { useI18nCaps, useOptionalT } from '@burojs/react';\nimport type { ReactElement } from 'react';\nimport { DocInfo } from '../doc/doc-info.js';\nimport { Skeleton } from '../primitives/skeleton.js';\nimport { useScreenTree } from './tree-context.js';\n\n/** The attributes of the styling contract every node element carries (P1b+P1c section 9). */\nexport function nodeAttributes(\n node: PlanNode,\n kind: string = node.kind,\n tone?: string,\n): FrameNodeAttributes {\n return {\n 'data-buro-node': kind,\n ...(node.key === undefined ? {} : { 'data-buro-key': node.key }),\n ...(tone === undefined ? {} : { 'data-buro-tone': tone }),\n ...(node.state === 'pending' || node.state === 'failed'\n ? { 'data-buro-state': node.state }\n : {}),\n };\n}\n\n/**\n * A node text: its bundle key `resources.<r>.nodes.<key>.<slot>` (or the\n * entry's plain string), never a `common.*` or `resources._.*` fallback\n * (P1b+P1c decision 14), else the compiled default.\n */\nexport function useNodeText(): (slot: TextSlot | undefined) => string | undefined {\n const caps = useI18nCaps();\n return (slot) => (slot === undefined ? undefined : resolveTextSlot(caps, slot));\n}\n\n/** The «i» of a keyed panel, tabs or steps node: its doc address, no test id of its own. */\nexport function NodeInfo({ node, name }: { readonly node: PlanNode; readonly name: string }) {\n const { resource } = useScreenTree();\n if (node.key === undefined) return null;\n return (\n <span data-buro-region=\"info\" className=\"inline-flex\">\n <DocInfo address={`${resource}/nodes/${node.key}`} name={name} />\n </span>\n );\n}\n\n/** A node's «i» element, or `null` for a node without a key (it has no doc address). */\nexport function nodeInfo(node: PlanNode, name: string): ReactElement | null {\n return node.key === undefined ? null : <NodeInfo node={node} name={name} />;\n}\n\n/** What a pending node draws inside its kept box: a skeleton, visible while the box is not. */\nexport function PendingSkeleton(): ReactElement {\n return <Skeleton data-buro-skeleton=\"\" className=\"h-9 w-full\" />;\n}\n\n/** A badge with the number of errors under a keyed node; nothing when there are none. */\nexport function ErrorBadge({ count }: { readonly count: number }): ReactElement | null {\n const t = useOptionalT();\n if (count === 0) return null;\n return (\n <span\n role=\"img\"\n aria-label={t('screen.errorCount', { count, defaultValue: `${count} errors` })}\n className=\"ml-1.5 inline-flex min-w-5 items-center justify-center rounded-full bg-destructive px-1.5 text-[11px] font-semibold leading-5 text-destructive-foreground tabular-nums\"\n >\n {count}\n </span>\n );\n}\n","'use client';\nimport {\n type PanelFrameViewProps,\n type StepsFrameViewProps,\n type TabsFrameViewProps,\n useOptionalT,\n} from '@burojs/react';\nimport { IconChevronRight } from '@tabler/icons-react';\nimport { Fragment, type ReactElement, type Ref } from 'react';\nimport { Button } from '../primitives/button.js';\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '../primitives/tabs.js';\nimport { ErrorBadge } from '../screen/node-parts.js';\n\n/**\n * `buro:panel`: a `section` with the title row (the collapse toggle, the title, the error count\n * of a closed panel, the «i») and the framework's body. `stepPanel` is the kit's own extension\n * for a step of a non-wizard steps node, which always shows its count.\n */\nexport function BuroPanelFrame({\n body,\n title,\n description,\n collapsible,\n open,\n onToggle,\n errorCount,\n titleId,\n bodyId,\n info,\n nodeAttributes,\n stepPanel = false,\n}: PanelFrameViewProps & { readonly stepPanel?: boolean }): ReactElement {\n const t = useOptionalT();\n return (\n <section {...nodeAttributes}>\n {title === undefined && info === null && !collapsible ? null : (\n <div data-buro-region=\"panel-title\" className=\"flex items-center gap-1\">\n {collapsible ? (\n <button\n type=\"button\"\n aria-expanded={open}\n aria-controls={bodyId}\n aria-label={\n open\n ? t('screen.collapse', { defaultValue: 'Collapse' })\n : t('screen.expand', { defaultValue: 'Expand' })\n }\n onClick={() => onToggle(!open)}\n className=\"inline-flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-muted\"\n >\n <IconChevronRight\n className={\n open ? 'h-4 w-4 rotate-90 transition-transform' : 'h-4 w-4 transition-transform'\n }\n aria-hidden=\"true\"\n />\n </button>\n ) : null}\n {title === undefined ? null : (\n <h3 id={titleId} className=\"text-sm font-semibold\">\n {title}\n </h3>\n )}\n {collapsible && !open ? <ErrorBadge count={errorCount} /> : null}\n {stepPanel ? <ErrorBadge count={errorCount} /> : null}\n {info}\n </div>\n )}\n {description === undefined ? null : (\n <p className=\"text-sm text-muted-foreground\">{description}</p>\n )}\n {body}\n </section>\n );\n}\n\n/** `buro:tabs`: a Radix tab strip with each tab's error count; one tab draws no strip. */\nexport function BuroTabsFrame({\n tabs,\n active,\n onSelect,\n info,\n nodeAttributes,\n}: TabsFrameViewProps): ReactElement {\n if (tabs.length === 1)\n return (\n <div {...nodeAttributes}>\n <div data-buro-region=\"tab-panel\">{tabs[0]!.panel}</div>\n </div>\n );\n return (\n <Tabs {...nodeAttributes} value={active} onValueChange={onSelect}>\n <div className=\"flex items-center gap-2\">\n <TabsList data-buro-region=\"tabs-list\">\n {tabs.map((tab) => (\n <TabsTrigger key={tab.key} value={tab.key} data-buro-key={tab.key}>\n {tab.title}\n <ErrorBadge count={tab.errorCount} />\n </TabsTrigger>\n ))}\n </TabsList>\n {info}\n </div>\n {tabs.map((tab) => (\n <TabsContent\n key={tab.key}\n value={tab.key}\n forceMount\n data-buro-region=\"tab-panel\"\n data-buro-key={tab.key}\n >\n {tab.panel}\n </TabsContent>\n ))}\n </Tabs>\n );\n}\n\n/**\n * `buro:steps`: outside a wizard, every step's panel stacked; inside (a create's steps, P1b+P1c\n * decision 11), the step list, the current step under its heading, and the Back / Next rail —\n * the frame's Submit is the last step's.\n */\nexport function BuroStepsFrame({\n wizard,\n steps,\n goTo,\n back,\n next,\n headingRef,\n info,\n nodeAttributes,\n liveRegion = null,\n}: StepsFrameViewProps & {\n /** The kit's own extension: the framework's live region, drawn inside the wizard's root. */\n readonly liveRegion?: ReactElement | null;\n}): ReactElement {\n const t = useOptionalT();\n if (!wizard)\n return (\n <div {...nodeAttributes}>\n {info}\n {steps.map((step) => (\n <Fragment key={step.key}>{step.panel}</Fragment>\n ))}\n </div>\n );\n const index = steps.findIndex((step) => step.state === 'current');\n const current = steps[index];\n if (current === undefined) return <div {...nodeAttributes} />;\n const keepFocus = (event: { preventDefault(): void }) => event.preventDefault();\n return (\n <div {...nodeAttributes} className=\"flex flex-col gap-4\">\n {steps.length > 1 ? (\n <nav aria-label={t('steps.progress', { defaultValue: 'Progress' })}>\n <ol data-buro-region=\"steps-list\" className=\"flex flex-wrap items-center gap-2\">\n {steps.map((step, at) => (\n <li key={step.key}>\n <button\n type=\"button\"\n aria-current={step.state === 'current' ? 'step' : undefined}\n disabled={step.state === 'locked'}\n onClick={() => goTo(step.key)}\n className=\"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-sm aria-[current=step]:border-primary aria-[current=step]:font-semibold disabled:opacity-50\"\n >\n <span className=\"tabular-nums\">{at + 1}.</span>\n <span>{step.title}</span>\n <ErrorBadge count={step.errorCount} />\n </button>\n </li>\n ))}\n </ol>\n </nav>\n ) : null}\n {liveRegion}\n <section {...current.nodeAttributes}>\n <div data-buro-region=\"panel-title\" className=\"flex items-center gap-1\">\n <h2\n ref={headingRef as Ref<HTMLHeadingElement>}\n id={current.titleId}\n tabIndex={-1}\n className=\"text-base font-semibold outline-none\"\n >\n {current.title}\n </h2>\n {current.info}\n </div>\n {current.description === undefined ? null : (\n <p className=\"text-sm text-muted-foreground\">{current.description}</p>\n )}\n {current.panel}\n </section>\n {steps.length > 1 ? (\n <div className=\"flex gap-2\">\n {index > 0 ? (\n <Button type=\"button\" variant=\"outline\" onMouseDown={keepFocus} onClick={back}>\n {t('steps.back', { defaultValue: 'Back' })}\n </Button>\n ) : null}\n {index < steps.length - 1 ? (\n <Button type=\"button\" className=\"ml-auto\" onMouseDown={keepFocus} onClick={next}>\n {t('steps.next', { defaultValue: 'Next' })}\n </Button>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n}\n","'use client';\n\nimport * as React from 'react';\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox';\nimport { IconCheck, IconMinus } from '@tabler/icons-react';\nimport { cn } from '../lib/cn.js';\n\nexport type CheckboxProps = React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>;\n\nconst Checkbox = React.forwardRef<React.ElementRef<typeof CheckboxPrimitive.Root>, CheckboxProps>(\n ({ className, checked, ...props }, ref) => (\n <CheckboxPrimitive.Root\n ref={ref}\n className={cn(\n 'peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground',\n className,\n )}\n checked={checked}\n {...props}\n >\n <CheckboxPrimitive.Indicator className={cn('flex items-center justify-center text-current')}>\n {/* Some, not all: a dash. A check here read as \"all selected\" with one row picked. */}\n {checked === 'indeterminate' ? (\n <IconMinus data-icon=\"minus\" className=\"h-4 w-4\" />\n ) : (\n <IconCheck data-icon=\"check\" className=\"h-4 w-4\" />\n )}\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n ),\n);\nCheckbox.displayName = CheckboxPrimitive.Root.displayName;\n\nexport { Checkbox };\n","'use client';\nimport { useEffect, useState } from 'react';\n\n/**\n * Whether an element is narrower than `maxRem` root ems: its own inline size, not the viewport's,\n * so a list in a 380px sheet on a 1280px page lays out as it would on a phone. Returns a callback\n * ref (the element may mount after the first render) and the answer; `false` where there is no\n * `ResizeObserver` (SSR) and until the first measurement.\n */\nexport function useContainerNarrow(\n maxRem = 40,\n): readonly [(element: HTMLElement | null) => void, boolean] {\n const [element, setElement] = useState<HTMLElement | null>(null);\n const [narrow, setNarrow] = useState(false);\n useEffect(() => {\n if (element === null || typeof ResizeObserver === 'undefined') return;\n const rootPx = Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;\n const observer = new ResizeObserver((entries) => {\n const entry = entries[entries.length - 1];\n if (entry === undefined) return;\n const size = entry.contentBoxSize?.[0]?.inlineSize ?? entry.contentRect.width;\n setNarrow(size < maxRem * rootPx);\n });\n observer.observe(element);\n return () => observer.disconnect();\n }, [element, maxRem]);\n return [setElement, narrow] as const;\n}\n","'use client';\nimport {\n type CSSProperties,\n type ReactNode,\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n type Cell,\n type Column,\n type Row,\n type Table as TanStackTable,\n flexRender,\n} from '@tanstack/react-table';\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from '../primitives/table.js';\nimport { useOptionalT, useRouteNavigate } from '@burojs/react';\nimport { cn } from '../lib/cn.js';\nimport { useToBrowserHref } from '../lib/external-href.js';\n\n/**\n * Sticky-column styles with an edge shadow (#17), ported from the reference\n * admin table. Gated on horizontal overflow: when everything fits there is\n * no sticky positioning and no shadow. The shadow is drawn only on the EDGE\n * pinned column — the last left-pinned / first right-pinned — so a block of\n * pinned columns reads as one raised panel.\n *\n * Offset comes from a CSS variable set once on the table root\n * (`--col-{id}-left` / `--col-{id}-right`, written in `DataTable`'s\n * `columnSizeVars` alongside the width vars below) — the SAME \"commit once\n * to a var on the table root\" pattern already used for width. This matters\n * for more than consistency: a pinned column's offset is the cumulative\n * SIZE of every earlier same-side pinned column (`getStart`/`getAfter`), so\n * resizing a non-terminal pinned column shifts every LATER same-side pinned\n * cell's offset. If that offset were baked into each cell's inline style\n * (as it used to be), a LIVE resize drag (`columnResizeMode: 'onChange'`\n * commits sizing every mousemove tick) would need every later pinned cell\n * to re-render on every tick to stay aligned — reintroducing the exact\n * per-tick, all-rows re-render `DataTableBody`'s memo exists to eliminate.\n * Routing it through a var instead means the browser applies the new\n * offset directly, with ZERO cell re-renders, on every tick — identical to\n * how width already works.\n */\n/**\n * Elevation for the edge of a pinned column, as a pseudo-element.\n *\n * `box-shadow` on a table cell is not paintable under\n * `border-collapse: collapse` (Tailwind Preflight's default), so the depth cue\n * that tells the user \"the rest of the table is scrolling UNDER this column\"\n * has to be a real child box. An `::after` strip just outside the cell's edge\n * paints in every engine and in both themes.\n *\n * Returns '' for cells that are not the boundary of a pinned group, so the\n * gradient appears exactly once per side.\n */\nfunction pinEdgeClass(isLastLeft: boolean, isFirstRight: boolean): string {\n /*\n OUTSIDE the cell, and that is the whole point of this function.\n\n A shadow says which surface is raised. The pinned column is the raised one —\n the rest of the table scrolls UNDER it — so the shadow belongs ON THE\n SCROLLING CONTENT, darkest against the pinned edge and fading away from it.\n\n It used to be drawn INSIDE the pinned cell (`right-0`, transparent → dark),\n which darkened the last 12px of the pinned column itself and left the\n scrolling side untouched. That reads as a stripe painted onto the pinned\n column, not as depth: it says the pinned column is the thing being covered.\n\n Placing it outside was avoided because a resizable table put\n `overflow-hidden` on the cell, which clips a pseudo-element beyond the\n edge. That clip is no longer on the pinned edge cell — the inner\n `truncate` wrapper already clips the content, so the cell does not need to\n (see the call sites).\n */\n if (isLastLeft) {\n return 'after:pointer-events-none after:absolute after:inset-y-0 after:left-full after:z-10 after:w-1.5 after:bg-gradient-to-r after:from-overlay/[0.07] after:to-transparent dark:after:from-overlay/30';\n }\n if (isFirstRight) {\n return 'after:pointer-events-none after:absolute after:inset-y-0 after:right-full after:z-10 after:w-1.5 after:bg-gradient-to-l after:from-overlay/[0.07] after:to-transparent dark:after:from-overlay/30';\n }\n return '';\n}\n\n/** Same guards as `getPinStyles` — the edge only exists when the column is\n * pinned AND the table actually overflows. */\nfunction pinEdgeClassFor<TRow>(\n column: {\n getIsPinned: () => false | 'left' | 'right';\n getIsLastColumn: (p: 'left') => boolean;\n getIsFirstColumn: (p: 'right') => boolean;\n },\n overflowing: boolean,\n): string {\n const pinned = column.getIsPinned();\n if (!pinned || !overflowing) return '';\n return pinEdgeClass(\n pinned === 'left' && column.getIsLastColumn('left'),\n pinned === 'right' && column.getIsFirstColumn('right'),\n );\n}\n\nfunction getPinStyles<TRow>(column: Column<TRow>, overflowing: boolean): CSSProperties {\n // Width comes from a CSS variable set once on the table root (the TanStack\n // performant-resize pattern): the browser applies width changes during a drag\n // without re-rendering every cell. EVERY column carries an explicit width —\n // there is no width-less \"flex\" column any more. The table still fills the\n // container because `table-layout:fixed` + `min-width:100%` makes the browser\n // distribute any slack across the columns (and it re-flows on window /\n // sidebar resize); when the widths overflow, the wrapper scrolls. Dropping\n // the flex column is what lets the first/ID column be resized like any other.\n const explicitWidth: CSSProperties = { width: `calc(var(--col-${column.id}-size) * 1px)` };\n const pinned = column.getIsPinned();\n if (!pinned || !overflowing) {\n return explicitWidth;\n }\n const isLastLeft = pinned === 'left' && column.getIsLastColumn('left');\n const isFirstRight = pinned === 'right' && column.getIsFirstColumn('right');\n return {\n position: 'sticky',\n zIndex: 1,\n // MUST be `var(--background)`, not `hsl(var(--background))`. Since the\n // token-contract refactor, `--background` carries the FULL `hsl(...)`\n // value itself (`hsl(0 0% 100%)`, not a bare triplet) — wrapping it in\n // another `hsl(...)` here nests it invalidly (`hsl(hsl(...))`), which\n // makes `background` invalid at computed-value time and resets to its\n // initial value (transparent), so the sticky column renders TRANSPARENT\n // and the horizontally-scrolled-under columns bleed through it (the\n // \"Location/Actions\" collision an acceptance review caught, this\n // time reproduced by the style-baseline gate on the token-notation change).\n background: 'var(--background)',\n // `, 0` fallback: harmless before the table-root vars are painted, or for\n // a pinned column on a non-resizable table (the vars are only written\n // when `enableColumnResizing` is on — see `columnSizeVars` — matching\n // the pre-existing width var's same constraint).\n left: pinned === 'left' ? `calc(var(--col-${column.id}-left, 0) * 1px)` : undefined,\n right: pinned === 'right' ? `calc(var(--col-${column.id}-right, 0) * 1px)` : undefined,\n ...explicitWidth,\n /*\n ⚠️ NO `boxShadow` here — it would be dead CSS.\n\n Tailwind's Preflight sets `table { border-collapse: collapse }`, and\n under collapsed borders Blink does not paint box-shadow on `<td>`/`<th>`\n at all. A previous pass set a perfectly reasonable elevation here and it\n rendered NOTHING: screenshotting the pinned edge with the shadow on and\n then with `box-shadow: none !important` produced byte-identical PNGs,\n and even a forced `30px 0 0 0 red` changed no pixels. It looked correct\n in computed styles, which is exactly why it survived review.\n\n The elevation lives on a pseudo-element instead — see\n `pinEdgeClass()`. A child box paints regardless of border-collapse.\n */\n };\n}\n\n/**\n * Per-column presentational escape hatch: a column may carry\n * `meta: { className, noRowNav, noClip }`.\n *\n * - `className` is applied to BOTH its `<th>` and its `<td>` so the pair\n * stays aligned (width, text-align, …). Used by `ResourceList` to keep the\n * collapsed actions column at its natural kebab width instead of letting\n * it share the table's even column distribution.\n * - `noRowNav` stamps the `<td>` with `data-no-row-nav`, which `activateRow`\n * already allowlists (see its doc comment) but which, before this flag\n * existed, no column ever set. It exists because whole-row navigation\n * (`rowHref`) only excludes clicks on actual interactive elements\n * (`a, button, …`) — a click that lands on a *cell's padding* rather than\n * the control inside it (e.g. the actions column's kebab button, which is\n * 32×32 inside a wider `<td>`) still falls through and navigates. Marking\n * the whole cell, not just the control, closes that gap. Kept as a single\n * boolean rather than a general \"arbitrary props on cells\" mechanism:\n * this is the one DOM attribute `activateRow` understands, so that's all\n * `meta` needs to carry.\n * - `noClip` says the cell holds CONTROLS, not text, so it must never be\n * clipped. See {@link columnMetaNoClip}.\n */\nfunction columnMetaClassName(meta: unknown): string | undefined {\n const cls = (meta as { className?: unknown } | undefined)?.className;\n return typeof cls === 'string' ? cls : undefined;\n}\n\nfunction columnMetaNoRowNav(meta: unknown): boolean {\n return (meta as { noRowNav?: unknown } | undefined)?.noRowNav === true;\n}\n\n/**\n * \"This column's content is controls, not text — never clip it.\"\n *\n * A resizable table is `table-layout: fixed`, so every cell is exactly as wide\n * as its column says and content that does not fit has to go somewhere. For\n * TEXT the answer is the `truncate` wrapper below: hide the overflow, show an\n * ellipsis, and hand the full string back through the hover `title`. Nothing is\n * lost, because the value is still readable another way.\n *\n * For a CONTROL the same answer is a silent failure, and it produced F1 in\n * `docs/superpowers/specs/2026-08-15-marketplace-ops-follow-ups.md`. Measured,\n * at a 1280px viewport, on a row-actions column carrying three standalone\n * buttons plus an overflow kebab in a 64px column: `<ActionOverflow>` lays its\n * strip out `flex … justify-end`, so content that does not fit overflows past\n * the cell's START edge — and `truncate` (`overflow: hidden`) then clipped the\n * first button away entirely. It was still in the DOM, still `opacity: 1`,\n * still `pointer-events: auto`, and its `getBoundingClientRect()` still\n * reported a healthy 18×32 box, so Playwright judged it VISIBLE and then timed\n * out clicking it: `document.elementFromPoint` at that box's centre returned\n * the neighbouring date cell's own wrapper, because the button was clipped out\n * of hit-testing. A user's pointer lands exactly where Playwright's did.\n *\n * ⚠️ The z-index was never the problem, and raising it does not help — proven\n * in-page before this fix: with the pinned `<td>` forced to `z-index: 50` the\n * hit test still returned the date cell, while setting the wrapper to\n * `overflow: visible` (nothing else) made the button reachable at once. Pinning\n * puts the actions cell ABOVE its neighbours already; the button was simply not\n * inside its own cell any more.\n *\n * So a `noClip` column trades a cosmetic overflow for a reachable control: if\n * its width is ever too small for what it holds, the controls spill visibly\n * over the neighbouring cell (and, when pinned, paint above it) instead of\n * disappearing. `ResourceList` sizes its actions column to fit\n * (`actionsColumnSize`), so the spill is a backstop for the widths that\n * arithmetic cannot know — an adopter's `regular`-density row action, a custom\n * `renderCell`, a long translated label — not the normal case.\n */\nfunction columnMetaNoClip(meta: unknown): boolean {\n return (meta as { noClip?: unknown } | undefined)?.noClip === true;\n}\n\n/** Shared props for a single `<TableCell>`'s markup — used by both memoized\n * cell variants below (`MemoCell` and `SelectionCell`). */\ninterface CellSharedProps<TRow> {\n cell: Cell<TRow, unknown>;\n resizable: boolean;\n overflowing: boolean;\n /**\n * ⚠️ Pin side, captured at RENDER time by the row — deliberately a prop and\n * not read off `cell.column` inside the comparator.\n *\n * TanStack reuses the same `column` object across renders, so\n * `prev.cell.column.getIsPinned()` and `next.cell.column.getIsPinned()` both\n * return the CURRENT value and always compare equal. A comparator written\n * that way looks like it checks pin state and silently never does — which is\n * exactly the bug this prop exists to fix, so it must not be reintroduced.\n */\n pinned: false | 'left' | 'right';\n testId?: string;\n /**\n * Selection cell only: makes the WHOLE cell a hit area. The column is 44px\n * wide and the checkbox inside it is ~16px, so without this two thirds of\n * the cell fall through to the row's `rowHref` navigation — which unmounts\n * the list and drops the accumulated selection.\n */\n onCellClick?: (e: React.MouseEvent<HTMLTableCellElement>) => void;\n /**\n * Stamps `data-no-row-nav`, which `activateRow` already honours. Required\n * whenever `onCellClick` is set: the cell's click still bubbles to the row,\n * so without it the row would navigate on top of the cell's own handling.\n */\n noRowNav?: boolean;\n}\n\n/**\n * The `<TableCell>` markup itself — IDENTICAL to the previous inline render.\n * Pulled into a plain function (not a component) so `MemoCell` and\n * `SelectionCell` below can share it without duplicating JSX; which one\n * wraps it in `memo` (and what that memo depends on) is the whole point of\n * this file's re-render fix — see their doc comments.\n *\n * This calls `flexRender(cell.column.columnDef.cell, cell.getContext())` —\n * whatever a caller's `columnDef.cell` (or, in `ResourceList`, its\n * `renderCell` override — see that prop's doc) returns runs INSIDE\n * `MemoCell`'s frozen boundary for a data/action column. A `cell` render fn\n * that isn't a pure function of the cell's own `row`/`column`/`value` — e.g.\n * one that reads locale, a feature flag, or any other external reactive\n * state inline — will go stale exactly like the built-in\n * `DateDisplay`/`NumberDisplay` did before they were fixed to self-subscribe\n * (`useLocale()`) instead of resolving state inline.\n */\n/**\n * Give a clipped cell a native tooltip carrying its full text, so a value the\n * column is too narrow to show is still readable. «Production facility …» in a\n * Location column was otherwise unrecoverable without resizing the column.\n *\n * Three deliberate choices:\n *\n * - **On hover, not on render.** Measuring needs layout, and the row body is\n * memoized precisely so it does not re-render while the user works (see\n * `MemoRow`). A `ResizeObserver` or a state flag would defeat that; reading\n * `scrollWidth` in the pointerenter handler costs nothing until the pointer\n * actually arrives, and re-checks after a column resize for free.\n * - **Only when actually clipped.** A `title` on every cell would put a\n * tooltip under the pointer constantly, which is worse than no tooltip.\n * - **Descendants too.** The cell wrapper is not always the element that\n * clips: a `<Badge>` caps itself at `max-w-full` and truncates INSIDE, so\n * the wrapper fits perfectly while the text is still cut off.\n *\n * Writing `title` straight onto the node is intentional — it is ephemeral,\n * affects nothing React renders, and keeps this out of the render path.\n *\n * `onPointerEnter`, not `onMouseEnter`: this is a passive, non-actionable\n * enhancement (there is nothing to activate, nothing a screen reader user\n * would do with it), so it carries no interactive ARIA role — pointer events\n * cover mouse, pen, and touch alike, where `onMouseEnter` would only cover\n * mouse.\n */\nfunction annotateIfClipped(e: React.PointerEvent<HTMLDivElement>): void {\n const el = e.currentTarget;\n const clipped =\n el.scrollWidth > el.clientWidth ||\n Array.from(el.querySelectorAll<HTMLElement>('*')).some((c) => c.scrollWidth > c.clientWidth);\n const text = clipped ? (el.textContent ?? '').trim() : '';\n if (text) el.setAttribute('title', text);\n else el.removeAttribute('title');\n}\n\nfunction renderCellMarkup<TRow>({\n cell,\n resizable,\n overflowing,\n testId,\n onCellClick,\n noRowNav,\n}: CellSharedProps<TRow>): React.ReactElement {\n /*\n The LIVE column — `cell.column` can be a cached object predating the current\n pinning state (see the `pinned` prop's note at the call site). Resolved once\n here because both the pin styles and the edge shadow must read the same\n source of truth, or the header pins and the body does not.\n */\n const liveColumn = cell.getContext().table.getColumn(cell.column.id) ?? cell.column;\n const pinEdge = pinEdgeClassFor(liveColumn, overflowing);\n // Controls, not text — see `columnMetaNoClip`. Both the cell's own\n // `overflow-hidden` and the inner `truncate` wrapper are dropped for such a\n // column, because either one alone still clips.\n const noClip = columnMetaNoClip(cell.column.columnDef.meta);\n return (\n <TableCell\n data-testid={testId}\n data-no-row-nav={columnMetaNoRowNav(cell.column.columnDef.meta) || noRowNav ? '' : undefined}\n onClick={onCellClick}\n /*\n The LIVE column — `cell.column` can be a cached object predating the\n current pinning state (see the `pinned` prop's note at the call site).\n Styles must come from the same source of truth the header uses, or the\n header pins and the body does not.\n */\n style={getPinStyles(liveColumn, overflowing)}\n className={cn(\n /*\n Fixed-layout tables (resizing on) must clip overflowing cell content,\n or an unbroken value like a marking code\n (`0104820000846134215egimM…`) spills past its column and overlaps the\n next one.\n\n EXCEPT on the pinned edge, whose shadow is drawn just outside the\n cell and would be clipped away by it. Safe to drop there: the inner\n `truncate` wrapper below is itself `overflow: hidden`, so the content\n is clipped either way — the cell-level rule was belt-and-braces, and\n only on this one cell does it cost something.\n */\n resizable && !pinEdge && !noClip && 'overflow-hidden',\n // `relative` so the pinned-edge pseudo-element has a containing block.\n pinEdge && 'relative',\n pinEdge,\n columnMetaClassName(cell.column.columnDef.meta),\n onCellClick && 'cursor-pointer',\n )}\n >\n {resizable && !noClip ? (\n <div className=\"truncate\" onPointerEnter={annotateIfClipped}>\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </div>\n ) : (\n flexRender(cell.column.columnDef.cell, cell.getContext())\n )}\n </TableCell>\n );\n}\n\ninterface MemoCellProps<TRow> extends CellSharedProps<TRow> {\n /** The row's data object — see `MemoRow`'s comparator doc for why this\n * (not the TanStack `row`/`cell` wrapper objects) is the identity to key\n * skip-detection on. */\n rowOriginal: TRow;\n}\n\nfunction MemoCellInner<TRow>(props: MemoCellProps<TRow>): React.ReactElement {\n return renderCellMarkup(props);\n}\n\n/**\n * Memoized data/action cell (#1 in the render-perf plan). Deliberately does\n * NOT compare `isSelected` — that's what lets the `ActionOverflow` kebab\n * (and every other data cell) skip re-rendering when a row's selection\n * toggles. Keyed on `rowOriginal` rather than the TanStack `cell` wrapper's\n * identity: TanStack's `getCoreRowModel` rebuilds EVERY `Row`/`Cell` object\n * from scratch whenever the table's `data` array reference changes at all\n * (even for records that didn't change), so comparing wrapper identity would\n * defeat the memo for exactly the case that matters most — a query refetch\n * that only touched one record. `rowOriginal` is the actual data object,\n * which stays referentially stable across an immutable partial-array update\n * for every row except the one that changed.\n *\n * Does NOT need to know about pinned-column offsets either: those are a CSS\n * var on the table root now (see `getPinStyles`), so a pinned resize updates\n * this cell's sticky position purely via CSS, with no re-render at all —\n * an earlier version of this fix threaded a `pinnedOffset` prop through here\n * instead, which worked but meant a LIVE pinned-column drag changed\n * `columnLayoutKey` on every mousemove tick, defeating `MemoRow`'s skip for\n * that interaction. The CSS-var route avoids that entirely.\n */\nconst MemoCell = memo(\n MemoCellInner,\n (prev, next) =>\n prev.rowOriginal === next.rowOriginal &&\n prev.cell.column.id === next.cell.column.id &&\n prev.resizable === next.resizable &&\n /*\n ⚠️ `overflowing` only matters to a PINNED cell.\n\n Both `getPinStyles` and `pinEdgeClassFor` bail to the plain width when the\n column is not pinned, so for an unpinned cell this flag cannot change a\n single rendered byte. Comparing it unconditionally made every cell in the\n table re-render whenever the table crossed its overflow threshold — which\n hiding a column does routinely, because it changes the table's width.\n\n Measured on /document_document at 100 rows, hiding one column: the cell\n comparator ran 1 400 times and `overflowing` differed in 700 of them, for\n 3 300 DOM mutations — 33 per row, to remove one cell per row. Paging and\n sorting were already near-minimal (3 per row) precisely because they do\n not change the table's width.\n */\n ((!prev.pinned && !next.pinned) || prev.overflowing === next.overflowing) &&\n /*\n ⚠️ Pin state MUST be compared, and was not.\n\n `getPinStyles()` bakes `position` / `left` / `background` into the cell's\n inline style at render time, so a cell that skips re-rendering keeps the\n OLD pin styles. Pinning a column therefore moved only the `<th>`: the\n header became `position: sticky` while its `<td>`s stayed `static`, so the\n frozen header floated above a DIFFERENT column's values until the page was\n reloaded. To an operator that reads as corrupted data, not as a styling\n bug. Unpinning desynced the same way in reverse.\n\n The row above does re-render (its `columnLayoutKey` includes pin side) —\n every cell inside it was skipping.\n */\n prev.pinned === next.pinned &&\n prev.testId === next.testId,\n) as typeof MemoCellInner;\n\ninterface SelectionCellProps<TRow> extends CellSharedProps<TRow> {\n isSelected: boolean;\n}\n\nfunction SelectionCellInner<TRow>(props: SelectionCellProps<TRow>): React.ReactElement {\n const row = props.cell.row;\n const toggle = (e: React.MouseEvent<HTMLTableCellElement>): void => {\n // The checkbox handles its own click. Without this guard the cell handler\n // runs a second, redundant toggle — harmless in value, but a duplicate\n // emission to a controlled owner.\n if ((e.target as HTMLElement | null)?.closest('[role=\"checkbox\"]')) return;\n row.toggleSelected(!row.getIsSelected());\n };\n return renderCellMarkup({ ...props, onCellClick: toggle, noRowNav: true });\n}\n\n/**\n * The row-selection checkbox cell (see `DataTableProps.selectionColumnId`).\n * Its column's `cell` render fn reads `row.getIsSelected()` imperatively\n * (resource-list's `SELECT_COL_ID` columnDef), so — unlike `MemoCell` —\n * it MUST re-render whenever `isSelected` changes, even on a row whose\n * `row`/`cell` wrappers and data are otherwise unchanged (select-all leaves\n * `MemoRow`'s wrapper skip-check untouched: same `row.original`, same\n * columns; only `isSelected` flips). Uses the default shallow comparator —\n * `isSelected` is a normal prop like any other here.\n */\nconst SelectionCell = memo(SelectionCellInner) as typeof SelectionCellInner;\n\n/** Props for `MemoRow` — see its comparator doc for why `row` itself is NOT\n * the skip-detection key. */\ninterface DataRowProps<TRow> {\n row: Row<TRow>;\n isSelected: boolean;\n resizable: boolean;\n overflowing: boolean;\n /** Serialized `id:pinnedSide` of every visible leaf column, recomputed by\n * `DataTable` on every render. Column hide/show/reorder/pin don't touch\n * `row.original` or `isSelected`, so without this in the comparator a\n * column-visibility change on an otherwise-untouched row would silently\n * skip — stale DOM showing a hidden column's cell. Deliberately does NOT\n * include pinned column SIZING (offset) — that's a CSS var now (see\n * `getPinStyles`), so a pinned-column resize/drag doesn't need to\n * invalidate this at all; folding it in here used to make a live pinned\n * drag change this key on every mousemove tick, which defeated `MemoRow`'s\n * skip for that interaction (the exact per-tick, all-rows re-render the\n * body memo exists to eliminate). */\n columnLayoutKey: string;\n /** Column id of the row-selection checkbox column, if any (resource-list\n * passes its `SELECT_COL_ID`). That one cell renders via `SelectionCell`\n * (live on `isSelected`); every other cell renders via `MemoCell`\n * (frozen across selection changes). Generic `DataTable` doesn't know or\n * care what the id string means — it's just the opt-in marker. */\n selectionColumnId?: string;\n getCellTestId?: (row: TRow, columnId: string) => string | undefined;\n getRowTestId?: (row: TRow) => string | undefined;\n rowHref?: (row: TRow) => string | undefined;\n /** A row opener that may take a plain click instead of `rowHref` (see `DataTableProps`). */\n onRowOpen?: (row: TRow) => boolean;\n activateRow: (row: Row<TRow>, e: React.MouseEvent<HTMLTableRowElement>) => void;\n rowClassName?: ((row: Row<TRow>) => string | undefined) | string;\n}\n\n/**\n * A single data row, split out of `DataTableBodyInner` purely so it can be\n * wrapped in `React.memo` (see `MemoRow` below). Markup, testids, and\n * behaviour are IDENTICAL to the previous inline render — this only changes\n * WHEN each piece re-executes, not what it renders.\n */\nfunction DataRowInner<TRow>({\n row,\n isSelected,\n resizable,\n overflowing,\n selectionColumnId,\n getCellTestId,\n getRowTestId,\n rowHref,\n onRowOpen,\n activateRow,\n rowClassName,\n}: DataRowProps<TRow>): React.ReactElement {\n const clickable = rowHref !== undefined || onRowOpen !== undefined;\n return (\n <TableRow\n data-state={isSelected ? 'selected' : undefined}\n data-testid={getRowTestId?.(row.original)}\n onClick={clickable ? (e) => activateRow(row, e) : undefined}\n // Middle-click fires `auxclick`, not `click` — route it here so a\n // wheel-click opens the row in a new tab like a real link.\n onAuxClick={clickable ? (e) => (e.button === 1 ? activateRow(row, e) : undefined) : undefined}\n className={cn(typeof rowClassName === 'function' ? rowClassName(row) : rowClassName)}\n >\n {row.getVisibleCells().map((cell) =>\n selectionColumnId != null && cell.column.id === selectionColumnId ? (\n <SelectionCell\n key={cell.id}\n cell={cell}\n isSelected={isSelected}\n resizable={resizable}\n overflowing={overflowing}\n /*\n ⚠️ Resolved through the LIVE table, not `cell.column`.\n\n `row.getVisibleCells()` hands back cached cells whose `column`\n object can predate the current `columnPinning` state — measured\n directly: after pinning GTIN, the header's column reported\n 'left' while the cell's reported false, so `getPinStyles`\n early-exited and the body kept `position: static` under a frozen\n header sitting over a DIFFERENT column's values. `getColumn(id)`\n goes to the table, which is current.\n */\n pinned={cell.getContext().table.getColumn(cell.column.id)?.getIsPinned() ?? false}\n testId={getCellTestId?.(row.original, cell.column.id)}\n />\n ) : (\n <MemoCell\n key={cell.id}\n cell={cell}\n rowOriginal={row.original}\n resizable={resizable}\n overflowing={overflowing}\n // Live table, not the cached `cell.column` — see the note above.\n pinned={cell.getContext().table.getColumn(cell.column.id)?.getIsPinned() ?? false}\n testId={getCellTestId?.(row.original, cell.column.id)}\n />\n ),\n )}\n </TableRow>\n );\n}\n\n/**\n * Memoized row wrapper (#1 in the render-perf plan — the core fix). Custom\n * comparator, NOT default shallow: it keys skip-detection on `row.original`\n * (see `MemoCell`'s doc for why the `row` wrapper's own identity is the\n * wrong signal) plus every prop that can legitimately change a row's\n * output — `isSelected`, sizing/overflow flags, the column-layout\n * signature, and the callback props (which MUST be referentially stable\n * across unrelated renders — see `activateRow`'s `useCallback` in\n * `DataTable` and the `volatileRef`-backed callbacks in `resource-list` —\n * or this memo never skips).\n *\n * Composes with `DataTableBody`'s existing resize-skip memo: that one\n * short-circuits the WHOLE body during a live column-resize drag; this one\n * skips individual rows on every other kind of unrelated render (filter\n * visibility, sidebar toggle) and lets `MemoCell`/`SelectionCell` further\n * narrow which CELLS re-render when a row's own props do change (e.g.\n * select-all: the `<tr>` re-renders for `data-state`, but only\n * `SelectionCell` actually re-executes — `MemoCell`, including the\n * `ActionOverflow` kebab, stays frozen).\n */\nconst MemoRow = memo(\n DataRowInner,\n (prev, next) =>\n prev.row.original === next.row.original &&\n prev.row.id === next.row.id &&\n prev.isSelected === next.isSelected &&\n prev.resizable === next.resizable &&\n prev.overflowing === next.overflowing &&\n prev.columnLayoutKey === next.columnLayoutKey &&\n prev.selectionColumnId === next.selectionColumnId &&\n prev.getCellTestId === next.getCellTestId &&\n prev.getRowTestId === next.getRowTestId &&\n prev.rowHref === next.rowHref &&\n prev.onRowOpen === next.onRowOpen &&\n prev.activateRow === next.activateRow &&\n prev.rowClassName === next.rowClassName,\n) as typeof DataRowInner;\n\n/** Props for the memoized `<DataTableBody>` — see the comparator below for why `isResizing` is included. */\ninterface DataTableBodyProps<TRow> {\n rows: Row<TRow>[];\n isLoading: boolean;\n loadingRowCount: number;\n visibleColumnCount: number;\n emptyState?: ReactNode;\n /** Resolved `t('table.empty', ...)` string — resolved by the parent so this memoized body needs no `useT`. */\n emptyText: string;\n resizable: boolean;\n overflowing: boolean;\n /** See `DataRowProps.columnLayoutKey`. */\n columnLayoutKey: string;\n /** See `DataRowProps.selectionColumnId`. */\n selectionColumnId?: string;\n getCellTestId?: (row: TRow, columnId: string) => string | undefined;\n getRowTestId?: (row: TRow) => string | undefined;\n rowHref?: (row: TRow) => string | undefined;\n onRowOpen?: (row: TRow) => boolean;\n activateRow: (row: Row<TRow>, e: React.MouseEvent<HTMLTableRowElement>) => void;\n rowClassName?: ((row: Row<TRow>) => string | undefined) | string;\n /** Whether a column-resize drag is currently live. Read only by the memo comparator below. */\n isResizing: boolean;\n}\n\n/**\n * The `<TableBody>` content, split out of `DataTable` purely so it can be\n * wrapped in `React.memo` (see `DataTableBody` below). Markup, testids, and\n * behaviour are IDENTICAL to the previous inline render — rows now render\n * via `MemoRow` (see above) instead of inline JSX so a body re-render\n * (which still happens on every non-resize table state change, same as\n * before) can skip individual rows/cells that didn't actually change.\n */\nfunction DataTableBodyInner<TRow>({\n rows,\n isLoading,\n loadingRowCount,\n visibleColumnCount,\n emptyState,\n emptyText,\n resizable,\n overflowing,\n columnLayoutKey,\n selectionColumnId,\n getCellTestId,\n getRowTestId,\n rowHref,\n onRowOpen,\n activateRow,\n rowClassName,\n}: DataTableBodyProps<TRow>): React.ReactElement {\n return (\n <TableBody>\n {isLoading ? (\n // Skeleton rows. We render `loadingRowCount` rows with\n // `visibleColumnCount` cells each so the layout doesn't pop\n // when real rows arrive.\n Array.from({ length: loadingRowCount }).map((_, i) => (\n <TableRow key={`skeleton-${i}`} aria-busy=\"true\">\n {Array.from({ length: Math.max(1, visibleColumnCount) }).map((__, j) => (\n <TableCell key={`skeleton-${i}-${j}`}>\n <div className=\"h-4 w-3/4 animate-pulse rounded bg-muted\" />\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : rows.length === 0 ? (\n <TableRow>\n <TableCell colSpan={Math.max(1, visibleColumnCount)} className=\"h-24 text-center\">\n {emptyState ?? <span className=\"text-muted-foreground\">{emptyText}</span>}\n </TableCell>\n </TableRow>\n ) : (\n rows.map((row) => (\n <MemoRow\n key={row.id}\n row={row}\n isSelected={row.getIsSelected()}\n resizable={resizable}\n overflowing={overflowing}\n columnLayoutKey={columnLayoutKey}\n selectionColumnId={selectionColumnId}\n getCellTestId={getCellTestId}\n getRowTestId={getRowTestId}\n rowHref={rowHref}\n onRowOpen={onRowOpen}\n activateRow={activateRow}\n rowClassName={rowClassName}\n />\n ))\n )}\n </TableBody>\n );\n}\n\n/**\n * Memoized wrapper around `DataTableBodyInner`. The comparator skips\n * re-rendering the body ONLY while a column-resize drag is live — the hot\n * path where every mousemove would otherwise re-render all rows for no\n * visual change (cell widths come from the CSS vars on the table root, see\n * `getPinStyles`). Any NON-resize render behaves exactly as before (the\n * comparator returns `false`, i.e. \"props are NOT equal, re-render\").\n *\n * `React.memo` doesn't preserve generics on its own — the cast back to\n * `typeof DataTableBodyInner` recovers `<TRow>` inference at call sites\n * without resorting to `any` on the public surface.\n */\nconst DataTableBody = memo(DataTableBodyInner, (prev, next) => {\n if (!next.isResizing) return false;\n return (\n prev.rows === next.rows &&\n prev.overflowing === next.overflowing &&\n prev.isLoading === next.isLoading &&\n prev.columnLayoutKey === next.columnLayoutKey &&\n prev.selectionColumnId === next.selectionColumnId\n );\n}) as typeof DataTableBodyInner;\n\n/**\n * Presentational `<DataTable>` over a TanStack Table v8 instance.\n *\n * Unlike the shadcn-Tasks single-file orchestrator, this component is\n * intentionally kept agnostic about state ownership: callers create the\n * table via `useBuroDataTable(...)` (or vanilla `useReactTable`) and\n * pass the resulting instance in. Composition with the toolbar /\n * pagination / view-options siblings happens in the caller.\n *\n * Testids: resource-agnostic. Callers supply optional `tableTestId`,\n * `getRowTestId(row)`, and `getCellTestId(row, columnId)` callbacks.\n * The future ResourceList migration will plug in the existing\n * `list-table:<resource>` / `list-row:<resource>:<id>` /\n * `list-cell:<resource>:<id>:<col>` patterns via these hooks so the\n * 119+ e2e specs that depend on those testids stay green.\n *\n * Loading state: when `isLoading` is true, the body renders\n * `loadingRowCount` skeleton rows shaped like real rows (same column\n * count). Skeleton cells use a muted block so e2e specs can grep for\n * `[aria-busy=\"true\"]` without depending on row data.\n *\n * Empty / error states: caller-provided `<ReactNode>` slots — keeps\n * the contract simple and lets the parent decide CTA copy / illustration.\n */\nexport interface DataTableProps<TRow> {\n /** TanStack Table v8 instance (typically from `useBuroDataTable`). */\n table: TanStackTable<TRow>;\n\n /** Testid for the `<table>` element. */\n tableTestId?: string;\n\n /** Per-row testid generator. Receives the row's `original` record. */\n getRowTestId?: (row: TRow) => string | undefined;\n\n /** Per-cell testid generator. Receives the row's record and the column id. */\n getCellTestId?: (row: TRow, columnId: string) => string | undefined;\n\n /** When true, body renders a skeleton instead of real rows. */\n isLoading?: boolean;\n loadingRowCount?: number;\n\n /** Slot for the empty state when there are no rows + not loading. */\n emptyState?: ReactNode;\n\n /** Slot for an error banner replacing the body when set. */\n errorState?: ReactNode;\n\n /** Accessible label for screen readers. */\n ariaLabel?: string;\n\n /**\n * Per-row className extension. Receives the TanStack `Row<TRow>` so\n * the caller can vary styling by row state (e.g. `cursor-pointer`\n * when the row has a clickable target, archived/muted treatment for\n * soft-deleted rows). Composed with the TableRow primitive's own\n * classes via `cn`.\n */\n rowClassName?: ((row: Row<TRow>) => string | undefined) | string;\n\n /**\n * Whole-row navigation target (#4). When provided, clicking anywhere on a row\n * (except an interactive element — link, button, checkbox, kebab — or while\n * selecting text) navigates to `rowHref(row)`. Cmd/Ctrl-click and middle-click\n * open it in a NEW TAB, matching native link behaviour. Client-side nav uses\n * `useRouteNavigate()` (the `RouterAdapter`). The row's own ID cell stays a\n * real anchor for keyboard / copy-link, so this is a mouse-affordance layer on\n * top.\n */\n rowHref?: (row: TRow) => string | undefined;\n\n /**\n * A row opener asked before `rowHref` on a plain click (P3-17): `true` means it handled the\n * row (a quick entry opened) and the row does not navigate. A modified click (Cmd/Ctrl,\n * middle) still opens `rowHref` in a new tab.\n */\n onRowOpen?: (row: TRow) => boolean;\n\n /**\n * Enable drag-to-reorder on column headers (#17). When set, headers become\n * draggable and dropping one onto another calls `onColumnReorder(from, to)`.\n * Pinned columns are not draggable (they stay fixed).\n */\n onColumnReorder?: (fromColumnId: string, toColumnId: string) => void;\n\n /**\n * Column id of the row-selection checkbox column, when the caller has one\n * (resource-list passes its `SELECT_COL_ID`). See `DataRowProps` above for\n * why this needs to be threaded through explicitly: it's the one cell that\n * must keep re-rendering when a row's `isSelected` flips, while every\n * other cell (notably the actions kebab) skips. Omit it and every cell —\n * including any selection checkbox — freezes across selection-only\n * renders instead.\n */\n selectionColumnId?: string;\n\n className?: string;\n}\n\nexport function DataTable<TRow>({\n table,\n tableTestId,\n getRowTestId,\n getCellTestId,\n isLoading = false,\n loadingRowCount = 5,\n emptyState,\n errorState,\n rowClassName,\n ariaLabel,\n onColumnReorder,\n rowHref,\n onRowOpen,\n selectionColumnId,\n className,\n}: DataTableProps<TRow>): React.ReactElement {\n const t = useOptionalT();\n const navigate = useRouteNavigate();\n // A new tab is outside the router: its URL keeps the router's basename.\n const toBrowser = useToBrowserHref();\n\n // Whole-row activation (#4). Navigates to `rowHref(row)` unless the click\n // landed on something interactive, or the user was selecting text. Cmd/Ctrl or\n // middle-click open a new tab (native-link parity); a plain click navigates\n // client-side through the RouterAdapter.\n //\n // Wrapped in `useCallback` (NOT a fresh closure per render like the\n // previous inline definition) so it's referentially stable across\n // unrelated `DataTable` renders — `MemoRow`'s comparator includes it, and\n // an unstable callback here would defeat the row memo on every render\n // regardless of what else changed. Depends only on `rowHref` (stable when\n // the caller routes it through a ref — see resource-list) and `navigate`.\n const activateRow = useCallback(\n (row: Row<TRow>, e: React.MouseEvent<HTMLTableRowElement>): void => {\n const target = e.target as HTMLElement | null;\n // React dispatches synthetic events along the REACT tree, not the DOM\n // tree. Content rendered through a `Portal` (Dialog, DropdownMenu,\n // Select, Tooltip) lives under `document.body` in the DOM but is still\n // a React descendant of whatever cell renders it, so a click inside a\n // portalled dialog still bubbles here. Reject anything that isn't a DOM\n // descendant of this row FIRST — before asking whether it's on an\n // \"interactive\" element — so the whole portalled subtree is out of\n // scope, not just the specific controls the allowlist below happens to\n // name. `e.currentTarget` is the `<tr>` itself.\n if (target && !e.currentTarget.contains(target)) return;\n // Don't hijack clicks on real controls (the ID anchor, relation links, the\n // row checkbox, the actions kebab, form controls) — they handle themselves.\n if (\n target?.closest(\n 'a, button, input, label, select, textarea, [role=\"checkbox\"], [role=\"menuitem\"], [data-no-row-nav]',\n )\n ) {\n return;\n }\n // A click that ends a text selection shouldn't navigate.\n if (typeof window !== 'undefined' && (window.getSelection?.()?.toString().length ?? 0) > 0) {\n return;\n }\n const modified = e.metaKey || e.ctrlKey || e.button === 1;\n if (!modified && onRowOpen?.(row.original) === true) return;\n const href = rowHref?.(row.original);\n if (!href) return;\n if (modified) {\n e.preventDefault();\n if (typeof window !== 'undefined') window.open(toBrowser(href), '_blank', 'noopener');\n return;\n }\n navigate(href);\n },\n [rowHref, onRowOpen, navigate, toBrowser],\n );\n const rows = table.getRowModel().rows;\n const headerGroups = table.getHeaderGroups();\n const visibleColumnCount = table.getVisibleLeafColumns().length;\n // Serialized visible-column layout (id + pinned side), recomputed every\n // render — cheap (a handful of columns) and compares by VALUE, not\n // reference, so `MemoRow` only sees it as \"changed\" when a column was\n // actually hidden/shown/reordered/pinned. Without this, hiding a column\n // wouldn't touch `row.original` or `isSelected`, and an untouched row\n // would incorrectly skip re-rendering — stale DOM still showing the\n // hidden column's cell.\n //\n // Deliberately does NOT include pinned column SIZING/offset — that's a\n // CSS var now (`--col-{id}-left` / `--col-{id}-right`, see\n // `columnSizeVars` below and `getPinStyles`), so a pinned-column resize\n // updates the affected cells' sticky position purely via CSS, with zero\n // row/cell re-renders. Folding the offset in here (an earlier version of\n // this fix did) meant a LIVE pinned-column drag changed this key on every\n // mousemove tick, which defeated `MemoRow`'s skip and reintroduced the\n // exact per-tick, all-rows re-render the body memo exists to eliminate.\n const columnLayoutKey = table\n .getVisibleLeafColumns()\n .map((c) => `${c.id}:${c.getIsPinned() || ''}`)\n .join('|');\n const resizable = table.options.enableColumnResizing === true;\n const hasPinned =\n table.getState().columnPinning != null &&\n (table.getState().columnPinning.left?.length || table.getState().columnPinning.right?.length);\n\n // Per-column CSS variables, set once on the table root so a resize drag\n // updates styling without re-rendering every cell (TanStack's performant\n // pattern). Reading columnSizing + columnSizingInfo + columnPinning\n // establishes reactivity so the map recomputes on committed sizes AND live\n // during a drag, and whenever pinning changes.\n const sizingState = table.getState().columnSizing;\n const sizingInfo = table.getState().columnSizingInfo;\n const pinningState = table.getState().columnPinning;\n // The column definitions too: a definition's own `size` can change without any sizing state\n // moving (a list's actions column narrows with its container).\n const columnDefs = table.options.columns;\n const columnSizeVars = useMemo(() => {\n const vars: Record<string, string> = {};\n if (resizable) {\n for (const header of table.getFlatHeaders()) {\n vars[`--col-${header.column.id}-size`] = String(header.column.getSize());\n }\n }\n // Pinned-column sticky offsets, as CSS vars — same pattern as the width\n // vars above (see `getPinStyles`'s doc for why this matters beyond\n // consistency: it's what lets a live pinned-column drag update every\n // later same-side pinned cell with ZERO re-renders). Computed for every\n // pinned leaf regardless of `resizable`/`overflowing` — cheap (a\n // handful of columns at most), and `getPinStyles` only ever reads them\n // when the table is actually overflowing.\n for (const c of table.getVisibleLeafColumns()) {\n const pinned = c.getIsPinned();\n if (pinned === 'left') vars[`--col-${c.id}-left`] = String(c.getStart('left'));\n else if (pinned === 'right') vars[`--col-${c.id}-right`] = String(c.getAfter('right'));\n }\n return vars;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [resizable, sizingState, sizingInfo, pinningState, visibleColumnCount, columnDefs]);\n\n // Horizontal-overflow detection — sticky styling only activates when the\n // table is actually wider than its scroll container. The\n // `<Table>` primitive already provides the `overflow-auto` scroll container\n // (the table's parentElement), so we measure against that. Uses a\n // ResizeObserver on the scroller — a plain `window.resize` listener misses the\n // sidebar collapsing/expanding, which changes the container width but not the\n // window's.\n const tableRef = useRef<HTMLTableElement>(null);\n // #17 resize-vs-reorder guard. A header is HTML5-`draggable` for reorder, and\n // the resize grip lives INSIDE that header, so a mousedown on the grip also\n // arms a native column drag — the resize \"sticks\" to a drag ghost and you\n // can't size the column until you release and re-grab. Set on grip\n // mousedown/touchstart so the header's `onDragStart` can bail; cleared on\n // pointer up (the resize itself ends on the document's mouseup too).\n const resizingRef = useRef(false);\n useEffect(() => {\n const clear = () => {\n resizingRef.current = false;\n // Safety net: TanStack ends a resize on a document mouseup; if that\n // never arrives (pointer released off-page over devtools/OS chrome, or\n // the tab is hidden/blurred mid-drag), `isResizingColumn` stays truthy\n // forever — and the memoized `DataTableBody` skips re-renders while a\n // resize is \"live\", so a later selection/column change would silently\n // freeze stale until a refresh. Clear it on any drag-end SIGNAL (not\n // just mouseup/touchend) so it can never get stuck. Guarded so the\n // normal path — TanStack already cleared it on its own mouseup — is a\n // no-op and doesn't force an extra render on every plain click.\n if (table.getState().columnSizingInfo.isResizingColumn) {\n table.setColumnSizingInfo((prev) => ({ ...prev, isResizingColumn: false }));\n }\n };\n window.addEventListener('mouseup', clear);\n window.addEventListener('touchend', clear);\n window.addEventListener('blur', clear);\n document.addEventListener('visibilitychange', clear);\n return () => {\n window.removeEventListener('mouseup', clear);\n window.removeEventListener('touchend', clear);\n window.removeEventListener('blur', clear);\n document.removeEventListener('visibilitychange', clear);\n };\n }, [table]);\n const [overflowing, setOverflowing] = useState(false);\n useEffect(() => {\n if (!hasPinned) {\n setOverflowing(false);\n return;\n }\n const check = () => {\n const tbl = tableRef.current;\n const scroller = tbl?.parentElement;\n if (!tbl || !scroller) return;\n setOverflowing(tbl.offsetWidth > scroller.clientWidth);\n };\n check();\n const id = setTimeout(check, 100);\n const tbl = tableRef.current;\n const scroller = tbl?.parentElement;\n const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(check) : null;\n // Observe BOTH the scroll container AND the table itself. Watching only the\n // container misses the case that actually creates the overflow: resizing a\n // COLUMN grows the table's own width while the container's stays fixed, so\n // the container-only observer never fired and the sticky pins didn't engage\n // until some unrelated re-render (hide/show a column) re-ran this effect.\n // The table's ResizeObserver fires on every resize frame, so pins now turn\n // sticky the instant the widths overflow. (Sticky positioning doesn't change\n // offsetWidth, so this can't feed back into a loop.)\n if (scroller) ro?.observe(scroller);\n if (tbl) ro?.observe(tbl);\n window.addEventListener('resize', check);\n return () => {\n clearTimeout(id);\n ro?.disconnect();\n window.removeEventListener('resize', check);\n };\n }, [hasPinned, rows.length, visibleColumnCount]);\n\n // Error takes precedence: caller renders the error UI in place of the\n // table body. Header still renders so column structure stays visible.\n if (errorState) {\n return (\n <div className={cn('space-y-2', className)}>\n <Table data-testid={tableTestId} aria-label={ariaLabel}>\n <TableHeader>\n {headerGroups.map((hg) => (\n <TableRow key={hg.id}>\n {hg.headers.map((header) => (\n <TableHead key={header.id} colSpan={header.colSpan}>\n {header.isPlaceholder\n ? null\n : flexRender(header.column.columnDef.header, header.getContext())}\n </TableHead>\n ))}\n </TableRow>\n ))}\n </TableHeader>\n </Table>\n {errorState}\n </div>\n );\n }\n\n return (\n <Table\n ref={tableRef}\n data-testid={tableTestId}\n aria-label={ariaLabel}\n className={className}\n // `min-width:100%` (not a fixed px width) is the key to FILLING the\n // container: the table grows to the container, and the flex column absorbs\n // any slack so it's never narrower than the viewport. It still grows PAST\n // the container — triggering the wrapper's horizontal scroll — when the\n // fixed columns together exceed the width.\n style={resizable ? { ...columnSizeVars, minWidth: '100%', tableLayout: 'fixed' } : undefined}\n >\n <TableHeader>\n {headerGroups.map((hg) => (\n <TableRow key={hg.id}>\n {hg.headers.map((header) => {\n // Derive aria-sort from TanStack column state when sortable —\n // preserves the existing ResourceList accessibility contract\n // (and the preflight-sort.spec.ts assertion).\n const sorted = header.column.getCanSort() ? header.column.getIsSorted() : false;\n const ariaSort: 'ascending' | 'descending' | 'none' | undefined =\n header.column.getCanSort()\n ? sorted === 'asc'\n ? 'ascending'\n : sorted === 'desc'\n ? 'descending'\n : 'none'\n : undefined;\n // Every column with resizing enabled gets a grip — including the\n // first/ID column. Service columns opt out via enableResizing:false\n // (getCanResize()), not by being a special \"flex\" column.\n const canResize = resizable && header.column.getCanResize();\n // Reorderable only when a handler is set AND the column isn't\n // pinned (pinned columns stay put) or a service column.\n const canReorder =\n onColumnReorder != null &&\n !header.column.getIsPinned() &&\n !header.column.id.startsWith('__');\n return (\n <TableHead\n key={header.id}\n colSpan={header.colSpan}\n aria-sort={ariaSort}\n style={getPinStyles(header.column, overflowing)}\n className={cn(\n 'relative',\n /*\n Clip the header label too, so a long column title doesn't\n run into its neighbour in the fixed layout — but not on\n the pinned edge, where the clip would eat the shadow that\n now falls OUTSIDE the cell. The `truncate` on the label\n itself still does the clipping either way.\n */\n /*\n A `noClip` column is exempt on both counts, so its `<th>`\n and its `<td>` stay the same shape (see\n `columnMetaNoClip`) — a header that holds a control has\n the same reachability problem a body cell does.\n */\n resizable &&\n !columnMetaNoClip(header.column.columnDef.meta) &&\n (pinEdgeClassFor(header.column, overflowing)\n ? '[&>*:not([data-testid^=col-resize])]:truncate'\n : 'overflow-hidden [&>*:not([data-testid^=col-resize])]:truncate'),\n canReorder && 'cursor-grab',\n pinEdgeClassFor(header.column, overflowing),\n columnMetaClassName(header.column.columnDef.meta),\n )}\n draggable={canReorder || undefined}\n onDragStart={\n canReorder\n ? (e) => {\n // A resize started on the grip → cancel the drag the\n // browser is trying to begin on this draggable header.\n if (resizingRef.current) {\n e.preventDefault();\n return;\n }\n e.dataTransfer.setData('text/plain', header.column.id);\n }\n : undefined\n }\n onDragOver={canReorder ? (e) => e.preventDefault() : undefined}\n onDrop={\n canReorder\n ? (e) => {\n e.preventDefault();\n const from = e.dataTransfer.getData('text/plain');\n if (from && from !== header.column.id)\n onColumnReorder(from, header.column.id);\n }\n : undefined\n }\n >\n {header.isPlaceholder\n ? null\n : flexRender(header.column.columnDef.header, header.getContext())}\n {canResize && (\n // WAI-ARIA APG \"Resizable Grid\" pattern: a column-resize grip\n // is a `separator` between two columns, keyboard-operable via\n // the arrow keys and describing its current/min/max width so\n // it isn't a bare static `div` with only a mouse handler.\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={t('table.resizeColumn', { defaultValue: 'Resize column' })}\n aria-valuenow={Math.round(header.column.getSize())}\n aria-valuemin={header.column.columnDef.minSize ?? 20}\n aria-valuemax={header.column.columnDef.maxSize ?? Number.MAX_SAFE_INTEGER}\n tabIndex={0}\n onMouseDown={(e) => {\n resizingRef.current = true;\n header.getResizeHandler()(e);\n }}\n onTouchStart={(e) => {\n resizingRef.current = true;\n header.getResizeHandler()(e);\n }}\n onKeyDown={(e) => {\n if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;\n e.preventDefault();\n const min = header.column.columnDef.minSize ?? 20;\n const max = header.column.columnDef.maxSize ?? Number.MAX_SAFE_INTEGER;\n const step = e.key === 'ArrowRight' ? 10 : -10;\n table.setColumnSizing((prev) => ({\n ...prev,\n [header.column.id]: Math.min(\n max,\n Math.max(min, header.column.getSize() + step),\n ),\n }));\n }}\n draggable={false}\n onDragStart={(e) => e.preventDefault()}\n data-testid={`col-resize:${header.column.id}`}\n className={cn(\n 'absolute right-0 top-0 h-full w-1 cursor-col-resize touch-none select-none opacity-0 transition-opacity hover:opacity-100 focus-visible:opacity-100',\n header.column.getIsResizing() ? 'bg-primary opacity-100' : 'bg-border',\n )}\n />\n )}\n </TableHead>\n );\n })}\n </TableRow>\n ))}\n </TableHeader>\n <DataTableBody\n rows={rows}\n isLoading={isLoading}\n loadingRowCount={loadingRowCount}\n visibleColumnCount={visibleColumnCount}\n emptyState={emptyState}\n emptyText={t('table.empty', { defaultValue: 'No records' })}\n resizable={resizable}\n overflowing={overflowing}\n columnLayoutKey={columnLayoutKey}\n selectionColumnId={selectionColumnId}\n isResizing={Boolean(sizingInfo.isResizingColumn)}\n getCellTestId={getCellTestId}\n getRowTestId={getRowTestId}\n rowHref={rowHref}\n onRowOpen={onRowOpen}\n activateRow={activateRow}\n rowClassName={rowClassName}\n />\n </Table>\n );\n}\n","'use client';\nimport type * as React from 'react';\nimport {\n IconArrowDown,\n IconArrowLeft,\n IconArrowRight,\n IconArrowUp,\n IconSelector,\n IconEyeOff,\n IconPinned,\n IconPinnedOff,\n IconX,\n} from '@tabler/icons-react';\nimport { useOptionalT } from '@burojs/react';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../primitives/dropdown-menu.js';\nimport { cn } from '../lib/cn.js';\n\nexport type PinSide = 'left' | 'right' | false;\nexport type SortDirection = 'asc' | 'desc' | null;\n\n/**\n * Column header as a MENU (#17): clicking a header\n * opens a dropdown to sort (explicit asc/desc, not a blind toggle), pin the\n * column left/right, or hide it — instead of a single click cycling the sort.\n */\nexport interface ColumnHeaderMenuProps {\n label: React.ReactNode;\n /** Current sort direction for THIS column, or null when it isn't the sort key. */\n sortDirection: SortDirection;\n sortable: boolean;\n onSort?: (direction: SortDirection) => void;\n pinned: PinSide;\n onPin?: (side: PinSide) => void;\n canHide: boolean;\n onHide?: () => void;\n /** Reorder this column one slot. `canMoveLeft/Right` gate the items. */\n onMove?: (dir: 'left' | 'right') => void;\n canMoveLeft?: boolean;\n canMoveRight?: boolean;\n testid?: string;\n}\n\nexport function ColumnHeaderMenu({\n label,\n sortDirection,\n sortable,\n onSort,\n pinned,\n onPin,\n canHide,\n onHide,\n onMove,\n canMoveLeft,\n canMoveRight,\n testid,\n}: ColumnHeaderMenuProps): React.ReactElement {\n const t = useOptionalT();\n const tr = (key: string, fallback: string) => t?.(key, { defaultValue: fallback }) ?? fallback;\n\n const SortGlyph =\n sortDirection === 'asc' ? IconArrowUp : sortDirection === 'desc' ? IconArrowDown : IconSelector;\n const canMove = onMove && (canMoveLeft || canMoveRight);\n const hasActions = sortable || onPin || canMove || (canHide && onHide);\n\n // Nothing actionable → render a plain label (no menu affordance).\n if (!hasActions) return <>{label}</>;\n\n return (\n // Non-modal: a modal dropdown locks `pointer-events` on <body> during its\n // close animation, so a rapid re-open (sorting a column twice in a row)\n // could miss the next trigger click. A header menu never needs to trap the\n // page anyway.\n <DropdownMenu modal={false}>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n data-testid={testid}\n className=\"-mx-1 inline-flex items-center gap-1.5 rounded px-1 transition-colors hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:text-foreground\"\n >\n <span className=\"truncate\">{label}</span>\n <span\n className={cn(\n 'inline-flex shrink-0',\n sortDirection ? 'text-foreground' : 'text-muted-foreground/70',\n )}\n aria-hidden=\"true\"\n >\n <SortGlyph className=\"size-3.5\" />\n </span>\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"start\"\n className=\"w-48\"\n /*\n ⚠️ Restore focus to the trigger BY TESTID, not by the node reference\n Radix captured.\n\n Sorting re-renders the header, so by the time the menu closes the\n element Radix saved has been replaced and its `.focus()` is a no-op —\n focus lands on <body>. A keyboard-only acceptance pass measured the\n cost: 40 Tab presses to get back to the same header button, on an\n action an operator performs dozens of times a day. Same fall-through\n after closing the menu with Escape.\n\n The testid is stable across the remount, so re-querying finds the NEW\n node. `preventDefault` stops Radix's own restore from fighting this.\n */\n onCloseAutoFocus={(event) => {\n if (!testid) return;\n event.preventDefault();\n // One frame, so the re-render caused by the chosen action has landed. Only when focus\n // has nowhere better to be: the menu closes after its exit animation, and by then the\n // user may already have opened something else (another menu, a dialog), which a\n // restore would close by stealing its focus.\n requestAnimationFrame(() => {\n const active = document.activeElement;\n if (active !== null && active !== document.body) return;\n document.querySelector<HTMLElement>(`[data-testid=\"${CSS.escape(testid)}\"]`)?.focus();\n });\n }}\n >\n {/* Grouped into labeled sections (Sort / Pin / Move / Hide) so\n item labels can stay short — the section header carries the verb,\n avoiding long strings like \"Move left\" that forced a wide menu. */}\n {sortable && onSort && (\n <DropdownMenuGroup>\n <DropdownMenuLabel className=\"text-xs font-medium text-muted-foreground\">\n {tr('columnMenu.sortSection', 'Sort')}\n </DropdownMenuLabel>\n <DropdownMenuItem\n onClick={() => onSort('asc')}\n data-testid={testid ? `${testid}:sort-asc` : undefined}\n >\n <IconArrowUp className=\"mr-2 size-4 text-muted-foreground\" />\n {tr('columnMenu.sortAsc', 'Ascending')}\n </DropdownMenuItem>\n <DropdownMenuItem\n onClick={() => onSort('desc')}\n data-testid={testid ? `${testid}:sort-desc` : undefined}\n >\n <IconArrowDown className=\"mr-2 size-4 text-muted-foreground\" />\n {tr('columnMenu.sortDesc', 'Descending')}\n </DropdownMenuItem>\n {sortDirection && (\n <DropdownMenuItem onClick={() => onSort(null)}>\n <IconX className=\"mr-2 size-4 text-muted-foreground\" />\n {tr('columnMenu.clearSort', 'Clear')}\n </DropdownMenuItem>\n )}\n </DropdownMenuGroup>\n )}\n {onPin && (\n <>\n {sortable && onSort && <DropdownMenuSeparator />}\n <DropdownMenuGroup>\n <DropdownMenuLabel className=\"text-xs font-medium text-muted-foreground\">\n {tr('columnMenu.pinSection', 'Pin')}\n </DropdownMenuLabel>\n {pinned !== 'left' && (\n <DropdownMenuItem\n onClick={() => onPin('left')}\n data-testid={testid ? `${testid}:pin-left` : undefined}\n >\n <IconPinned className=\"mr-2 size-4 text-muted-foreground\" />\n {tr('columnMenu.pinLeft', 'Left')}\n </DropdownMenuItem>\n )}\n {pinned !== 'right' && (\n <DropdownMenuItem onClick={() => onPin('right')}>\n <IconPinned className=\"mr-2 size-4 -scale-x-100 text-muted-foreground\" />\n {tr('columnMenu.pinRight', 'Right')}\n </DropdownMenuItem>\n )}\n {pinned !== false && (\n <DropdownMenuItem\n onClick={() => onPin(false)}\n data-testid={testid ? `${testid}:unpin` : undefined}\n >\n <IconPinnedOff className=\"mr-2 size-4 text-muted-foreground\" />\n {tr('columnMenu.unpin', 'Unpin')}\n </DropdownMenuItem>\n )}\n </DropdownMenuGroup>\n </>\n )}\n {canMove && (\n <>\n <DropdownMenuSeparator />\n <DropdownMenuGroup>\n <DropdownMenuLabel className=\"text-xs font-medium text-muted-foreground\">\n {tr('columnMenu.moveSection', 'Move')}\n </DropdownMenuLabel>\n {canMoveLeft && (\n <DropdownMenuItem\n onClick={() => onMove?.('left')}\n data-testid={testid ? `${testid}:move-left` : undefined}\n >\n <IconArrowLeft className=\"mr-2 size-4 text-muted-foreground\" />\n {tr('columnMenu.moveLeft', 'Left')}\n </DropdownMenuItem>\n )}\n {canMoveRight && (\n <DropdownMenuItem\n onClick={() => onMove?.('right')}\n data-testid={testid ? `${testid}:move-right` : undefined}\n >\n <IconArrowRight className=\"mr-2 size-4 text-muted-foreground\" />\n {tr('columnMenu.moveRight', 'Right')}\n </DropdownMenuItem>\n )}\n </DropdownMenuGroup>\n </>\n )}\n {canHide && onHide && (\n <>\n <DropdownMenuSeparator />\n <DropdownMenuItem onClick={onHide} data-testid={testid ? `${testid}:hide` : undefined}>\n <IconEyeOff className=\"mr-2 size-4 text-muted-foreground\" />\n {tr('columnMenu.hide', 'Hide column')}\n </DropdownMenuItem>\n </>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n","import type { RowRecord } from '@burojs/react';\n\n/**\n * How a list column reads its value from a row. A dotted column (`code_id.gtin`) reads the flat\n * key the provider returns (`row['code_id.gtin']`) through `accessorFn`: TanStack splits a dotted\n * `accessorKey` into nested access (`row.code_id.gtin`), which finds nothing.\n */\nexport function columnAccessor(\n column: string,\n): { readonly accessorFn: (row: RowRecord) => unknown } | { readonly accessorKey: string } {\n return column.includes('.') ? { accessorFn: (row) => row[column] } : { accessorKey: column };\n}\n","import type { EntityRef, I18nCaps, Registry } from '@burojs/core';\nimport { resolveColumnField } from '@burojs/react';\n\n/** The field a dotted list column draws, read across its to-one relations. */\nexport interface ColumnTarget {\n /** The target field's declaration: its renderer, size and label. */\n readonly field: unknown;\n /** The target field's name on its own resource (the column's last segment). */\n readonly name: string;\n /** The registry name of the resource holding the field. */\n readonly resource: string;\n readonly ref: EntityRef;\n}\n\n/**\n * The target of a dotted column of `resource` (`code_id.gtin` → `code_code.gtin`), or undefined\n * for a column that names no field across declared to-one relations.\n */\nexport function columnTarget(\n registry: Pick<Registry, 'get'>,\n resource: string,\n column: string,\n): ColumnTarget | undefined {\n if (!column.includes('.')) return undefined;\n const resolved = resolveColumnField(registry, resource, column);\n if (resolved === undefined) return undefined;\n const ref = registry.get(resolved.resource as never)?.ref ?? {\n namespace: 'default',\n id: resolved.resource,\n };\n return {\n field: resolved.field,\n name: column.slice(column.lastIndexOf('.') + 1),\n resource: resolved.resource,\n ref,\n };\n}\n\n/** `caps` reading a field's content (`fields.<name>.*`) of another resource. */\nexport function capsOf(caps: I18nCaps, resource: string): I18nCaps {\n return {\n has: (key, options) => caps.has(key, { ...options, resource: options?.resource ?? resource }),\n t: (key, options) => caps.t(key, { ...options, resource: options?.resource ?? resource }),\n };\n}\n","'use client';\nimport {\n type ColumnDef,\n type ColumnFiltersState,\n type ColumnOrderState,\n type ColumnPinningState,\n type ColumnSizingState,\n type OnChangeFn,\n type PaginationState,\n type Row,\n type RowSelectionState,\n type SortingState,\n type Table,\n type Updater,\n type VisibilityState,\n getCoreRowModel,\n getFacetedRowModel,\n getFacetedUniqueValues,\n useReactTable,\n} from '@tanstack/react-table';\nimport type { ErasedResourceHandle, FilterOperator, SortExpression } from '@burojs/core';\nimport { useMemo } from 'react';\n\n/**\n * Options for `useBuroDataTable` — the bridge between a native Buro\n * list controller and TanStack Table v8.\n *\n * Architectural contract (preserved across the Stage-1 migration):\n * - The hook stays presentational. Sorting / pagination / column-visibility\n * / selection state ALL live in the parent (which feeds them to\n * `useList` for the actual fetch).\n * - Server-side mode: `manualSorting`, `manualFiltering`,\n * `manualPagination` are forced on. Row models are computed from the\n * page `useList` returned, not on the full result set.\n * - `pageCount` is derived from `total` (from `useList`) and `pagination.pageSize`.\n * When `total` is undefined the hook returns `pageCount: -1` — TanStack's\n * own convention for \"unknown page count\" — rather than guessing from\n * `data.length` (the current page's length, not the total row count).\n * Callers get a working table that can still page forward; they just\n * cannot render a last-page jump or a grand total.\n * - `getRowId` defaults to `(r) => String(r.id)`. This is mandatory for\n * stable testid generation (every list-row testid in the e2e suite is\n * `list-row:<resource>:<id>`) and for selection state to survive the\n * refetch that happens on page / sort / filter change.\n */\nexport interface UseBuroDataTableOptions<TRow> {\n /** Current page of rows from the native list controller. */\n data: TRow[];\n\n /** Column definitions. Use `meta.testid` to drive future testid generation. */\n columns: ColumnDef<TRow, unknown>[];\n\n /** Total row count from the controller — required for accurate `pageCount`. */\n total?: number;\n\n /** Defaults to `(r) => String(r.id)`. */\n getRowId?: (row: TRow, index: number, parent?: Row<TRow>) => string;\n\n /** TanStack pagination state, owned by the caller. */\n pagination: PaginationState;\n onPaginationChange: OnChangeFn<PaginationState>;\n\n /** TanStack sorting state, owned by the caller. */\n sorting: SortingState;\n onSortingChange: OnChangeFn<SortingState>;\n\n /**\n * Optional column-filters state. `useBuroDataTable` no longer ships a\n * bridge to native filter expressions (that lived in\n * `tanStackFiltersToExpression` / `filterExpressionsToTanStack`, both\n * removed — the framework's filters now live in `FilterRegion`, not\n * TanStack `ColumnFiltersState`). This passthrough stays for adopters\n * composing their OWN table out of the standalone `data-table/*`\n * filter components (`DataTableTextFilter`, `DataTableOperatorFilter`,\n * etc.), which write straight to TanStack's `column.setFilterValue`\n * and need a controlled `columnFilters` state to read that back from.\n */\n columnFilters?: ColumnFiltersState;\n onColumnFiltersChange?: OnChangeFn<ColumnFiltersState>;\n\n /** Optional column-visibility state. */\n columnVisibility?: VisibilityState;\n onColumnVisibilityChange?: OnChangeFn<VisibilityState>;\n\n /** Optional row-selection state. */\n rowSelection?: RowSelectionState;\n onRowSelectionChange?: OnChangeFn<RowSelectionState>;\n\n /** When false, the per-row checkbox column is omitted by callers. */\n enableRowSelection?: boolean;\n\n /** Optional column-pinning state (#17). Left/right sticky columns. */\n columnPinning?: ColumnPinningState;\n onColumnPinningChange?: OnChangeFn<ColumnPinningState>;\n\n /** Optional column-sizing state (#17). Pixel widths per column. */\n columnSizing?: ColumnSizingState;\n onColumnSizingChange?: OnChangeFn<ColumnSizingState>;\n\n /** Optional column-order state (#17). */\n columnOrder?: ColumnOrderState;\n onColumnOrderChange?: OnChangeFn<ColumnOrderState>;\n\n /** Turn on interactive column resizing (#17). Off by default (BC). */\n enableColumnResizing?: boolean;\n}\n\n/**\n * Builds a TanStack Table v8 instance wired to native server-side data\n * flow. The caller drives state via the callbacks; this hook does NOT\n * own state, so it is safe to compose with the existing `useList` hook\n * without an extra source of truth.\n *\n * Returns the `Table<TRow>` instance for direct consumption by the\n * data-table composition components (DataTable, DataTableViewOptions,\n * etc.).\n */\nexport function useBuroDataTable<TRow>(opts: UseBuroDataTableOptions<TRow>): Table<TRow> {\n const {\n data,\n columns,\n total,\n getRowId,\n pagination,\n onPaginationChange,\n sorting,\n onSortingChange,\n columnFilters,\n onColumnFiltersChange,\n columnVisibility,\n onColumnVisibilityChange,\n rowSelection,\n onRowSelectionChange,\n enableRowSelection,\n columnPinning,\n onColumnPinningChange,\n columnSizing,\n onColumnSizingChange,\n columnOrder,\n onColumnOrderChange,\n enableColumnResizing,\n } = opts;\n\n // Server-side `pageCount`. `pageCount: -1` is the TanStack convention\n // for \"unknown count\" — adopters that cannot supply `total` get a\n // working table with infinite-scroll-style pagination semantics.\n const pageCount = useMemo<number>(() => {\n if (total == null) return -1;\n if (pagination.pageSize <= 0) return -1;\n return Math.max(1, Math.ceil(total / pagination.pageSize));\n }, [total, pagination.pageSize]);\n\n const resolvedGetRowId = useMemo<NonNullable<UseBuroDataTableOptions<TRow>['getRowId']>>(\n () =>\n getRowId ??\n ((row) => {\n const id = (row as { id?: unknown }).id;\n return id == null ? '' : String(id);\n }),\n [getRowId],\n );\n\n // A column's declared `size` doubles as its resize FLOOR unless it declares an\n // explicit `minSize`: the base width the app chose is the smallest sensible\n // width, so the user can widen but not shrink a column below its content. (#17)\n const normalizedColumns = useMemo(\n () =>\n columns.map((c) =>\n c.size != null && (c as { minSize?: number }).minSize == null\n ? { ...c, minSize: c.size }\n : c,\n ),\n [columns],\n );\n\n return useReactTable<TRow>({\n data,\n columns: normalizedColumns,\n // Unset content columns default to a sensible base + a floor well above\n // TanStack's tiny 20px, so a column never collapses to nothing.\n defaultColumn: { size: 160, minSize: 90 },\n pageCount,\n state: {\n pagination,\n sorting,\n ...(columnFilters !== undefined ? { columnFilters } : {}),\n ...(columnVisibility !== undefined ? { columnVisibility } : {}),\n ...(rowSelection !== undefined ? { rowSelection } : {}),\n ...(columnPinning !== undefined ? { columnPinning } : {}),\n ...(columnSizing !== undefined ? { columnSizing } : {}),\n ...(columnOrder !== undefined ? { columnOrder } : {}),\n },\n enableRowSelection: enableRowSelection ?? rowSelection !== undefined,\n ...(enableColumnResizing\n ? { enableColumnResizing: true, columnResizeMode: 'onChange' as const }\n : {}),\n getRowId: resolvedGetRowId,\n onPaginationChange,\n onSortingChange,\n ...(onColumnFiltersChange ? { onColumnFiltersChange } : {}),\n ...(onColumnVisibilityChange ? { onColumnVisibilityChange } : {}),\n ...(onRowSelectionChange ? { onRowSelectionChange } : {}),\n ...(onColumnPinningChange ? { onColumnPinningChange } : {}),\n ...(onColumnSizingChange ? { onColumnSizingChange } : {}),\n ...(onColumnOrderChange ? { onColumnOrderChange } : {}),\n // Server-side: the runtime fetches one page at a time, so we must not\n // sort / filter / paginate the in-memory rows again client-side.\n manualPagination: true,\n manualSorting: true,\n manualFiltering: true,\n getCoreRowModel: getCoreRowModel(),\n // Faceted models stay client-side: they reflect the values present\n // on the CURRENT page only, which is the right scope for the\n // upcoming `<DataTableFacetedFilter>` UI on a server-driven list.\n getFacetedRowModel: getFacetedRowModel(),\n getFacetedUniqueValues: getFacetedUniqueValues(),\n });\n}\n\n/**\n * Convert a native `SortExpression` (server shape)\n * into TanStack's `SortingState`. Lossless one-to-one mapping.\n */\nexport function buroSortingToTanStack(\n sorters: SortExpression<ErasedResourceHandle> | undefined,\n): SortingState {\n if (!sorters || sorters.length === 0) return [];\n return sorters.map((s) => ({ id: s.field, desc: s.direction === 'desc' }));\n}\n\n/**\n * Convert TanStack's `SortingState` back into a native `SortExpression`.\n * Lossless inverse of `buroSortingToTanStack`.\n */\nexport function tanStackSortingToBuro(state: SortingState): SortExpression<ErasedResourceHandle> {\n return state.map((s) => ({ field: s.id, direction: s.desc ? 'desc' : 'asc' }));\n}\n\n/**\n * Practical operator vocabulary. Excludes the logical connectives `or` /\n * `and` (those belong on `ConditionalFilter`, not on a single column) and\n * the rarely-used case-sensitive `*s` variants the filter UI does not yet\n * expose. Stage-2 callers can widen this when they wire a column that\n * needs one.\n *\n * Moved to `@burojs/core` (B1.1) so the framework's list controller can\n * depend on it without importing `@burojs/ui-shadcn`. Re-exported from\n * this module path — not merely from this package's `index.ts` — because\n * several files import `FilterOperator` directly from\n * `./use-buro-data-table.js`.\n */\nexport type { FilterOperator };\n\n/**\n * Resolves a TanStack `Updater<T>` value (which can be a function or\n * a plain value) against a previous state — used by callers writing\n * onXxxChange callbacks that want to forward the update plus their\n * own derived state changes.\n *\n * @example\n * ```tsx\n * onSortingChange={(updater) => {\n * const next = resolveUpdater(updater, sorting);\n * setSorting(next);\n * setPage(1); // also reset pagination on sort change\n * }}\n * ```\n */\nexport function resolveUpdater<T>(updater: Updater<T>, prev: T): T {\n return typeof updater === 'function' ? (updater as (p: T) => T)(prev) : updater;\n}\n","'use client';\nimport { useT } from '@burojs/react';\nimport { IconAlertCircle, IconRefresh } from '@tabler/icons-react';\nimport { cn } from '../lib/cn.js';\nimport { friendlyStringsFrom, toFriendlyError } from '../lib/friendly-error.js';\nimport { Button } from '../primitives/button.js';\n\nexport interface ListErrorStateProps {\n /** Whatever the query threw. */\n error: { message?: string } | Error;\n /** When provided, a Retry button is rendered and calls this. */\n onRetry?: () => void;\n /** Resource name, used to build the retry button's test id. */\n resource?: string;\n /** Overrides the default heading (the `list.errorTitle` bundle entry). */\n title?: string;\n className?: string;\n}\n\n/**\n * The canonical \"this list failed to load\" panel: icon, heading, an\n * actionable sentence, and a Retry button.\n *\n * ⚠️ Extracted from `<ResourceList>` because it was trapped inside it. The\n * `schedules` list is rendered by a level-3 body slot, which is the whole\n * point of slots — but the slot then had to hand-roll its own error branch,\n * and hand-rolled it worse: a bare red card printing\n *\n * «Could not load schedules. Temporal GET\n * /namespaces/default/schedules?maximumPageSize=10 -> 502»\n *\n * — a raw internal HTTP trace under a Russian sentence, with NO way to retry.\n * When Temporal was briefly down, the only recovery was reloading the page.\n *\n * A slot author should not have to re-derive an error state the framework\n * already knows how to render, so this is now shared by both. `toFriendlyError`\n * keeps the technical string out of the operator's face while leaving\n * adopter-written messages verbatim; the raw text stays reachable under\n * «Details» for whoever has to file the bug.\n */\nexport function ListErrorState({\n error,\n onRetry,\n resource,\n title,\n className,\n}: ListErrorStateProps): React.ReactElement {\n const t = useT();\n // `useT()` subscribes to the locale, so a language switch re-renders this panel.\n const raw = (error as { message?: string }).message ?? '';\n const friendly = toFriendlyError(raw, '', friendlyStringsFrom(t));\n // A recognised developer-facing message is replaced by an actionable\n // sentence; anything the adopter wrote themselves survives verbatim.\n const friendlyError = friendly.replaced ? friendly.detail : raw;\n\n return (\n <div\n role=\"alert\"\n className={cn(\n 'flex flex-col items-center justify-center gap-3 px-6 py-16 rounded-lg border border-destructive/40 bg-destructive/5 text-center',\n className,\n )}\n data-testid=\"error\"\n >\n <div className=\"rounded-full bg-destructive/10 p-3 text-destructive\">\n <IconAlertCircle className=\"size-6\" aria-hidden=\"true\" />\n </div>\n <div className=\"space-y-1\">\n <h3 className=\"text-base font-semibold tracking-tight text-destructive\">\n {title ?? t('list.errorTitle')}\n </h3>\n <p className=\"max-w-md text-sm text-muted-foreground\">\n {friendlyError || t('list.errorBody')}\n </p>\n </div>\n {/*\n The raw string still matters — to whoever has to diagnose it, not to\n the operator staring at a broken page. Collapsed, and only when it\n actually differs from what is already shown.\n */}\n {raw && raw !== friendlyError ? (\n <details className=\"max-w-md text-left\">\n <summary className=\"cursor-pointer text-xs text-muted-foreground hover:text-foreground\">\n {t('list.errorDetails')}\n </summary>\n <p\n className=\"mt-1.5 break-all font-mono text-xs text-muted-foreground\"\n data-testid=\"list-error-detail\"\n >\n {raw}\n </p>\n </details>\n ) : null}\n {onRetry && (\n <div className=\"flex justify-center pt-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n data-testid={resource ? `list-error-retry:${resource}` : 'list-error-retry'}\n onClick={onRetry}\n className=\"gap-1.5\"\n >\n <IconRefresh className=\"size-3.5\" aria-hidden=\"true\" />\n {t('actions.retry')}\n </Button>\n </div>\n )}\n </div>\n );\n}\n","'use client';\nimport { useT } from '@burojs/react';\nimport { Button } from '../primitives/button.js';\n\n/**\n * Props of {@link CursorLoadMore}.\n *\n * Deliberately shaped as three scalars rather than taking the controller's\n * `cursor` group whole: the group's `next` is an opaque TOKEN (useful to a\n * consumer that wants to log or deep-link it) while this control only ever\n * needs to know whether there IS one. Spreading `cursor` in would also make\n * the component unusable by a surface that paginates a nested/embedded list\n * outside `useResourceList` — the workflows page does exactly that.\n */\nexport interface CursorLoadMoreProps {\n /** Render the button at all. `false` renders nothing (see the docblock). */\n hasMore: boolean;\n /** A load-more fetch is in flight — disables the button and swaps the label. */\n loading?: boolean;\n /** Fetch the next page. Wire to `cursor.loadMore()`. */\n onMore: () => void;\n}\n\n/**\n * The \"load more\" footer for a **cursor (opaque-token) paginated** list —\n * the counterpart of the numbered pager `<ResourceList>` renders for offset\n * providers.\n *\n * ```tsx\n * const { rows, cursor } = useResourceListContext();\n * // …the table…\n * {cursor && (\n * <CursorLoadMore\n * hasMore={cursor.next !== null}\n * loading={cursor.isLoadingMore}\n * onMore={cursor.loadMore}\n * />\n * )}\n * ```\n *\n * ⚠️ **Renders `null` when `hasMore` is false**, so an exhausted cursor\n * leaves no dead control behind — the caller does not need its own guard.\n * That is also what makes \"the button is gone\" a usable end-of-list\n * assertion in tests.\n *\n * Why it lives in the framework rather than in the app that first needed it\n * (core flexibility program, Task B5.3): it has **zero coupling to any\n * provider**. It knows nothing about Temporal, tokens, or where the next\n * page comes from — only \"is there more\" / \"is it coming\" / \"go get it\". A\n * cursor list is now a first-class declared mode\n * (`views.list.pagination: 'cursor'`), so the control that drives one\n * belongs beside the pager it replaces.\n *\n * @see ResourceListController.cursor in `@burojs/react`\n */\nexport function CursorLoadMore({\n hasMore,\n loading,\n onMore,\n}: CursorLoadMoreProps): React.ReactElement | null {\n const t = useT();\n if (!hasMore) return null;\n return (\n <div className=\"flex justify-center py-4\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={loading}\n onClick={onMore}\n data-testid=\"cursor-load-more\"\n >\n {loading ? t('pagination.loadingMore') : t('pagination.loadMore')}\n </Button>\n </div>\n );\n}\n","'use client';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type {\n ColumnDef,\n ColumnOrderState,\n ColumnPinningState,\n ColumnSizingState,\n Row,\n RowSelectionState,\n SortingState,\n Table,\n} from '@tanstack/react-table';\nimport {\n IconChevronLeft,\n IconChevronsLeft,\n IconChevronsRight,\n IconChevronRight,\n IconFilterX,\n IconInbox,\n IconLoader2,\n} from '@tabler/icons-react';\nimport {\n type CompiledFlow,\n type DtoSource,\n compileFlow,\n declaredField,\n isLinkField,\n planItemActions,\n resolveFieldLabel,\n resolveResourceLabel,\n type PlannableAction,\n declaredText,\n} from '@burojs/core';\nimport {\n FlowRowBatchContext,\n QUICK_ANCHOR_ATTRIBUTE,\n useApp,\n useFlowRowBatch,\n useI18nCaps,\n useListAccess,\n useLocale,\n usePathAccess,\n useOptionalT,\n useTestIds,\n useViewRow,\n} from '@burojs/react';\nimport { Button } from '../primitives/button.js';\nimport { Checkbox } from '../primitives/checkbox.js';\nimport {\n Table as UITable,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from '../primitives/table.js';\nimport { ActionOverflow, RowActionsCollapseContext } from '../actions/action-overflow.js';\nimport { useContainerNarrow } from '../lib/use-container-narrow.js';\nimport { useLinkComponent } from '../layout/link-component.js';\nimport { ResolvedFieldDisplay } from '../fields/resolved-field.js';\nimport { ClaimedQuickLink } from '../fields/claimed-quick-link.js';\nimport { relationLinkClassName } from '../fields/relation-display.js';\nimport { DataTable } from '../data-table/data-table.js';\nimport { ColumnHeaderMenu } from './column-header-menu.js';\nimport { columnAccessor } from './column-accessor.js';\nimport { capsOf, columnTarget } from './column-target.js';\nimport { useBuroDataTable } from '../data-table/use-buro-data-table.js';\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '../primitives/select.js';\nimport { cn } from '../lib/cn.js';\nimport { ListErrorState } from './list-error-state.js';\nimport { CursorLoadMore } from '../list-kit/cursor-load-more.js';\n\ntype RowRecord = { id: string } & Record<string, unknown>;\n\nexport interface ResourceListProps {\n resource: string;\n data?: RowRecord[];\n total?: number;\n page?: number;\n pageSize?: number;\n /**\n * Called when the user picks a different page size. The size selector is\n * rendered ONLY when this is supplied — a list whose host does not persist\n * page size should not offer a control that silently resets on navigation.\n */\n onPageSize?: (size: number) => void;\n /**\n * Ask the host for the row count of the CURRENTLY described set (Task\n * B4.3). Rendered ONLY when this is supplied and `total` is unknown — the\n * same \"no control the host cannot honour\" gate `onPageSize` above uses.\n *\n * This component is presentational by contract, so the trigger arrives as\n * a prop rather than being read from `useResourceListContext()`:\n * `useResourceListContext()` THROWS outside a provider\n * (`list-kit/context.tsx`), and `<ResourceList>` must stay usable\n * standalone — a `related-list` placement mounts one with a hand-rolled count and\n * no controller at all.\n *\n * ⚠️ Answering moves the user, on purpose. The host writes the answer into\n * `total`, which flips `knownTotal` and with it four behaviours that are\n * dead on an unknown-total list: `pagination.showing` replaces the\n * range-only readout, the first/last jump buttons appear, `hasNextPage`\n * switches from \"this page is full\" to `page < totalPages`, and the\n * out-of-range clamp navigates a stale `?page=20` to the last real page.\n * That last one is the point of offering the trigger on a wrong page at\n * all.\n */\n onRequestCount?: () => void;\n /**\n * A count request is in flight. The trigger keeps its place and its width;\n * only its label is swapped for a spinner, and it stops accepting clicks.\n */\n isCountingRows?: boolean;\n /** Page-size choices. Defaults to a standard admin ladder. */\n pageSizeOptions?: number[];\n onPage?: (n: number) => void;\n /**\n * Opaque-token pagination. When supplied, the numbered pager is replaced by\n * a load-more control: a token list has no page index to jump to. Absent →\n * the offset pager renders exactly as before.\n */\n loadMore?: { hasMore: boolean; loading: boolean; onMore: () => void };\n selectable?: boolean;\n /**\n * The row-actions column (each row's item actions). `false` draws none: a read-only list\n * offers nothing to do with a row but open it.\n */\n rowActions?: boolean;\n /**\n * Accumulating selection owned by the caller. When provided the component\n * is CONTROLLED: this is the WHOLE selected set (ids that are not on the\n * current page included), the component keeps no selection state of its\n * own, and every change — including the page-scoped header checkbox — is\n * reported through `onSelectionChange` as the new whole set.\n *\n * Omit it for the uncontrolled behaviour: the component owns the selection\n * and drops it whenever `data` changes identity.\n *\n * ⚠️ A controlled caller MUST commit every emission it receives through\n * `onSelectionChange` back into this prop: skip one and the `emittedRef`\n * bridge (below) stays armed against a base the DOM never reflected, so\n * the next toggle composes against a phantom selection instead of what's\n * actually checked.\n */\n selectedIds?: string[];\n onSelectionChange?: (ids: string[]) => void;\n className?: string;\n /** When true, show skeleton rows instead of the table. */\n isLoading?: boolean;\n /** When non-null, show an error state. */\n error?: { message: string } | Error | null;\n /**\n * Optional retry callback. When provided AND `error` is set, the\n * error-state panel renders a \"Retry\" button that invokes this\n * callback. The typical wiring is `onRetry={() => query.refetch()}`\n * when the parent uses the framework's `useList` (or an equivalent\n * `refetch()` method on the data source).\n */\n onRetry?: () => void;\n /** Render an inline \"+ Create\" button in the empty state. */\n createHref?: string;\n /** Whether the list is currently filtered (changes empty-state copy). */\n isFiltered?: boolean;\n /** Called when the user clicks the \"Clear filter\" link in the filtered-empty state. */\n onClearFilter?: () => void;\n /**\n * Replacement for the \"no rows\" rendering, forwarded to\n * `<DataTable emptyState>`.\n *\n * ⚠️ This changes the SHAPE of the empty list, not just its copy. Left\n * undefined (the default, and what every caller did before the slot work)\n * this component early-returns a standalone panel INSTEAD of the table —\n * dashed border, icon, heading, and one of three CTAs (\"Clear filter\" when\n * filtered / \"+ Create\" when genuinely empty / \"back to page 1\" on an\n * out-of-range page). Supplying a node skips that panel entirely: the\n * table renders with its header row and the node fills a single body cell\n * spanning every column, so the column headers survive but none of the\n * CTAs do — the caller owns whatever recovery affordance the state needs.\n *\n * The footer/pagination is still hidden while there are no rows.\n */\n emptyState?: React.ReactNode;\n /**\n * Another drawing of the same rows in place of the table (a `related-list` with `view: 'cards'`\n * or `'timeline'`, P6 3.13). Everything around the rows stays this component's: the loading,\n * error and empty states, the numbered pager or load-more footer, the on-demand count. The\n * table's own affordances (selection, column menu, sort headers) do not exist on it.\n */\n rowsView?: {\n readonly render: (rows: RowRecord[]) => React.ReactNode;\n /** Drawn while the first page loads, in place of the table skeleton. */\n readonly skeleton: React.ReactNode;\n };\n /**\n * If provided, each row becomes a clickable link to this href.\n * Receives the row record; returns the navigation target.\n * Default behavior: rows are not clickable. Set to `(row) => '/{resource}/{row.id}'`\n * for typical show-page navigation.\n */\n rowHref?: (row: RowRecord) => string | undefined;\n /**\n * A row's quick opener (P3-17): when it returns a function, a plain click on the row or its\n * first cell calls it instead of navigating; the first cell keeps the `rowHref` anchor (marked\n * for the opener) when there is one, and is a button when there is none. `null`: the row\n * follows `rowHref`.\n */\n rowQuick?: (row: RowRecord) => (() => void) | null;\n /**\n * Changes whenever `rowHref` or `rowQuick` would answer differently for the same row (an\n * access answer arrived): the memoized rows and cells re-render.\n */\n rowLinkKey?: unknown;\n /**\n * Per-cell custom renderer override. Returns `undefined` to fall back to\n * the default field-type-based display. Use for badges, links, or any\n * custom visual treatment that depends on column + value + row.\n *\n * MUST be a pure function of `(col, value, row)` — the cell it renders runs\n * inside `<DataTable>`'s memoized row/cell (`MemoRow`/`MemoCell` in\n * data-table.tsx), which intentionally skips re-rendering when a row's own\n * data and selection state haven't changed. If the returned output depends\n * on EXTERNAL reactive state (locale, a feature flag, anything read outside\n * `col`/`value`/`row`), it will go stale under that memo the same way the\n * built-in `DateDisplay`/`NumberDisplay` renderers did before they were\n * fixed to self-subscribe to locale. Delegate any such state-dependent\n * text to a component that subscribes to it itself (`useLocale()` /\n * `useOptionalT()` — see `EnumDisplay`/`BooleanDisplay`/`DateDisplay` for\n * the pattern) rather than resolving it inline in this callback.\n */\n renderCell?: (col: string, value: unknown, row: RowRecord) => React.ReactNode | undefined;\n /** Current native sort expression. The header exposes the first sort key. */\n sort?: readonly { field: string; direction: 'asc' | 'desc' }[];\n /**\n * Sort request from a column header. `direction` is EXPLICIT when the header\n * menu picks «ascending/descending/reset» (`'asc'`/`'desc'`/`null`); it\n * is omitted when a caller wants the legacy 3-click toggle. Consumers should\n * honour an explicit direction and fall back to toggling when it's undefined.\n */\n onSort?: (field: string, direction?: 'asc' | 'desc' | null) => void;\n /**\n * Hide a column from a column-header menu. Receives the column name; the\n * parent removes it from the visible-columns list. When omitted, the header\n * menu shows no «hide» item.\n */\n onHideColumn?: (field: string) => void;\n /**\n * Columns that may NOT be hidden — the header menu omits «hide» for these.\n * Without it every column is treated as hideable (when `onHideColumn` is set).\n */\n requiredColumns?: string[];\n /**\n * Bump to reset the persisted column layout (#17). `resetLayout.mode`:\n * - `'sizes'` — clear user-resized widths only.\n * - `'all'` — clear widths AND pinning AND order back to defaults.\n * The token is what triggers it; increment it on each reset click.\n */\n resetLayout?: { token: number; mode: 'sizes' | 'all' };\n /**\n * Override for the column list rendered in the table. When omitted,\n * the table falls back to `def.views.list.columns` (or all field\n * keys). When provided, the table renders EXACTLY this set in the\n * given order — useful for the user-toggleable Columns menu (see\n * `views.list.optionalColumns` / `requiredColumns`).\n */\n columns?: string[];\n /**\n * Optional callback that hands the parent the underlying TanStack\n * `Table` instance. Fires once after the table is mounted (and\n * again with `null` on unmount). Use this when the parent needs to\n * read selection state for components that live OUTSIDE the table\n * (e.g. `<BulkActionToolbar>` which calls\n * `table.getFilteredSelectedRowModel().rows`). The id-array\n * `onSelectionChange` callback remains the recommended way to\n * trigger a parent re-render on selection changes — `tableRef`\n * gives access to the rows, not a re-render signal.\n */\n tableRef?: (table: Table<RowRecord> | null) => void;\n}\n\n/**\n * The on-demand row-count trigger (Task B4.3) — one affordance, two homes.\n *\n * Loading is a swap IN PLACE: the label stays in the flow with\n * `visibility:hidden` so the control keeps its exact width, and the spinner is\n * centred on top of it. Nothing around the button moves — which matters most\n * in the empty-state CTA row, where a shrinking button would slide its\n * neighbour sideways for the length of a query measured in tens of seconds.\n * `visibility:hidden` also drops the label from the accessibility tree, so the\n * accessible name is pinned with `aria-label`.\n */\nfunction CountRowsTrigger({\n label,\n loading,\n onClick,\n testid,\n variant,\n className,\n}: {\n label: string;\n loading: boolean;\n onClick: () => void;\n testid: string;\n variant: 'link' | 'outline';\n className?: string;\n}): React.ReactElement {\n return (\n <Button\n type=\"button\"\n variant={variant}\n size=\"sm\"\n data-testid={testid}\n onClick={onClick}\n disabled={loading}\n aria-label={label}\n aria-busy={loading || undefined}\n className={cn('relative', className)}\n >\n <span className={loading ? 'invisible' : undefined}>{label}</span>\n {loading && (\n <IconLoader2 className=\"absolute inset-0 m-auto size-3.5 animate-spin\" aria-hidden=\"true\" />\n )}\n </Button>\n );\n}\n\nconst SELECT_COL_ID = '__select__';\nconst ACTIONS_COL_ID = '__actions__';\n\n/**\n * Geometry of the row-action strip, in px. Three constants rather than one\n * magic number, because {@link actionsColumnSize} is arithmetic over them and\n * each one mirrors a class written somewhere else — a reader has to be able to\n * check the sum against the markup.\n */\n/** `size-7` — `resolveControlChrome`'s compact size on a row, and the overflow kebab's. */\nconst ROW_ACTION_CONTROL_PX = 28;\n/** `gap-1` on `<ActionOverflow>`'s row container and on its standalone strip. */\nconst ROW_ACTION_GAP_PX = 4;\n/** `p-2` on the `<td>`, both sides. */\nconst ACTIONS_CELL_PADDING_PX = 16;\n/**\n * The width this column had unconditionally before F1, kept as a FLOOR so the\n * one-kebab table — every resource that adds no standalone row action, i.e.\n * most of them — renders byte-identically to before.\n */\nconst ACTIONS_COL_MIN_PX = 64;\n\n/**\n * How wide the row-actions column has to be to hold what this resource\n * declares.\n *\n * ⚠️ THIS USED TO BE A FLAT `size: 64`, and that is the whole of F1\n * (`docs/superpowers/specs/2026-08-15-marketplace-ops-follow-ups.md`). The\n * number came with the comment \"now that the cell is a single kebab\", which was\n * true when it was written and stopped being true the moment a resource\n * declared row-standalone actions: `order` in `examples/marketplace-ops` puts\n * `ship`, `cancel` and `refund` directly in the row and keeps `edit`/`delete`\n * in the menu, so the strip needs FOUR 32px controls and three 8px gaps — 168px\n * of a 64px column. Measured consequences, at a 1280px viewport:\n *\n * - the buttons are flex items, so they shrank from 32px to 16-18px — visibly\n * deformed even in the rows where they still worked;\n * - `justify-end` sends the remaining ~22px of overflow past the cell's START\n * edge, so the FIRST button ended up outside its own `<td>` entirely;\n * - the cell's `truncate` wrapper then clipped it out of hit-testing, so a\n * click never landed (see `columnMetaNoClip` in `data-table.tsx` for the\n * hit-test evidence and for the backstop that keeps such a control\n * reachable even when the arithmetic below cannot know the width).\n *\n * The count is record-INDEPENDENT on purpose. `planItemActions` is the same\n * pure function `useItemActions` plans each row with, minus the per-record\n * capability/visibility filtering that only ever REMOVES controls. So this is\n * the maximum any row can render: never too narrow, and at most one control too\n * wide on a table where every row happens to be denied something. A width that\n * changed per page of data would be worse than slightly generous — the column\n * would jump as the user pages.\n *\n * KNOWN LIMIT, deliberately not guessed at: a standalone row action declared\n * `regular` (icon + LABEL, e.g. `surfaces: { row: 'regular' }`), or `compact`\n * with no icon (which `resolveControlChrome` degrades to a labelled button),\n * is as wide as its translated text and this function cannot know that. Those\n * columns come out too narrow, and `noClip` below is what keeps them usable:\n * the strip spills visibly instead of vanishing. Sizing them properly needs a\n * measured auto-fit, which is a bigger mechanism than this defect justifies.\n */\nfunction actionsColumnSize(items: readonly PlannableAction[] | undefined): number {\n const plan = planItemActions(items ?? [], 'row');\n const standalone = plan.filter((p) => p.placement === 'standalone').length;\n // The overflow kebab is one more control, and exactly one however many\n // actions collapse into it.\n const controls = standalone + (plan.some((p) => p.placement === 'menu') ? 1 : 0);\n if (controls === 0) return ACTIONS_COL_MIN_PX;\n const strip =\n controls * ROW_ACTION_CONTROL_PX + (controls - 1) * ROW_ACTION_GAP_PX + ACTIONS_CELL_PADDING_PX;\n return Math.max(ACTIONS_COL_MIN_PX, strip);\n}\n\n/**\n * Initial column width, in px, derived from canonical field structure/format.\n *\n * The baseline is `defaultColumn: { size: 160, minSize: 90 }` in\n * `use-buro-data-table.ts` — one width for every column regardless of\n * content.\n *\n * ⚠️ Every data column used to render at TanStack's default 150px whatever it\n * held, so a one-character id column was as wide as a 23-character label and\n * 29% of a table could sit off-screen with no affordance. The adopter already\n * told us the value structure and semantic format; the width follows from it.\n *\n * Only kinds whose content is reliably narrow or reliably wide appear here.\n * Anything else falls through to TanStack's default, so no column can come out\n * of this worse than before. This is the INITIAL size only — a width the user\n * has dragged is held in `columnSizing` state and still wins.\n */\nconst COLUMN_SIZE_BY_TYPE: Readonly<Record<string, number>> = {\n // ⚠️ Nothing below 90 — `use-buro-data-table.ts` sets\n // `defaultColumn.minSize: 90`, so a smaller number here would be silently\n // clamped and the declared value would be a lie.\n boolean: 96,\n number: 112,\n};\n\nconst COLUMN_SIZE_BY_FORMAT: Readonly<Record<string, number>> = {\n date: 132,\n 'date-time': 132,\n};\n\nfunction columnSize(\n field: { type?: string; format?: string; kind?: string } | undefined,\n): number | undefined {\n if (field?.format !== undefined && COLUMN_SIZE_BY_FORMAT[field.format] !== undefined)\n return COLUMN_SIZE_BY_FORMAT[field.format];\n if (field?.type !== undefined && COLUMN_SIZE_BY_TYPE[field.type] !== undefined)\n return COLUMN_SIZE_BY_TYPE[field.type];\n // Native field builders can still supply their stable kind while a host is\n // migrating to semantic declarations. Layout remains presentation-only, so\n // this is an inert compatibility projection rather than a renderer lookup.\n if (field?.kind === 'date' || field?.kind === 'dateTime') {\n return COLUMN_SIZE_BY_FORMAT[field.kind === 'dateTime' ? 'date-time' : 'date'];\n }\n return field?.kind === undefined ? undefined : COLUMN_SIZE_BY_TYPE[field.kind];\n}\n\n/*\n ⚠️ NARROWING ONLY — deliberately.\n\n The first cut also widened the long-content kinds (email/url/text/json to\n 208-224px) for readability. Measured on /counterparty_counterparty that made\n things WORSE against the actual complaint: total width 1644 → 1592, still\n 418px off-screen, because the widened Email column ate most of what the\n narrowed ID and boolean columns gave back — and Email was one of the columns\n scrolled out of view in the first place. Widening a column you cannot see is\n not a readability win.\n\n Every entry above therefore only ever SHRINKS a column below the 160px\n default, so total table width moves in one direction and overflow can never\n increase. Long-content columns keep the default and stay resizable.\n*/\n\nexport function ResourceList({\n resource,\n data,\n total,\n page = 1,\n pageSize = 10,\n onPageSize,\n onRequestCount,\n isCountingRows = false,\n pageSizeOptions = [10, 25, 50, 100],\n onPage,\n loadMore,\n selectable = false,\n rowActions = true,\n selectedIds,\n onSelectionChange,\n className,\n isLoading = false,\n error = null,\n onRetry,\n createHref,\n isFiltered = false,\n onClearFilter,\n emptyState,\n rowsView,\n rowHref,\n rowQuick,\n rowLinkKey,\n renderCell,\n sort,\n onSort,\n onHideColumn,\n requiredColumns,\n resetLayout,\n columns: columnsOverride,\n tableRef,\n}: ResourceListProps): React.ReactElement {\n const app = useApp();\n const tid = useTestIds();\n const t = useOptionalT();\n const locale = useLocale();\n /**\n * Group the digits in the footer readout. Without this an on-demand count\n * on `code_code` prints «of 9841924`» — nine digits with no grouping, which\n * is the one number on the page a user actually has to READ. The docblock\n * on that readout has always described the intended output as «of 9 800 000»;\n * only the formatting was missing. Locale-aware on purpose: RU groups with a\n * non-breaking space, EN with commas, and the switch is live.\n */\n const nf = useMemo(() => new Intl.NumberFormat(locale), [locale]);\n const i18nCaps = useI18nCaps(resource);\n const def = app.registry.get(resource);\n const resourceRef = def?.ref ?? { namespace: 'default', id: resource };\n const RouterLink = useLinkComponent();\n // Uncontrolled fallback. A controlled caller (`selectedIds`) never writes here.\n const [ownSelection, setOwnSelection] = useState<RowSelectionState>({});\n const controlled = selectedIds !== undefined;\n const controlledSelection = useMemo<RowSelectionState>(() => {\n const next: RowSelectionState = {};\n for (const id of selectedIds ?? []) next[id] = true;\n return next;\n }, [selectedIds]);\n const rowSelection = controlled ? controlledSelection : ownSelection;\n // Bridges the gap between an emitted change and the owner's committed prop.\n // Two clicks in one tick (e2e does exactly this) would otherwise both\n // resolve against the same stale prop and the first would be lost. Cleared\n // as soon as a new `selectedIds` identity arrives — the prop always wins.\n const emittedRef = useRef<RowSelectionState | null>(null);\n useEffect(() => {\n emittedRef.current = null;\n }, [controlledSelection]);\n\n // #17 — column layout (sizing, pinning, order) persisted per resource so the\n // user's arrangement survives reloads. Default pinning keeps the select box,\n // the id column, and the actions column fixed while the content scrolls.\n const layoutKey = `buro:table-layout:${resource}`;\n const [columnSizing, setColumnSizing] = usePersistedState<ColumnSizingState>(\n `${layoutKey}:sizing`,\n {},\n 200,\n );\n const [columnOrder, setColumnOrder] = usePersistedState<ColumnOrderState>(\n `${layoutKey}:order`,\n [],\n );\n const DEFAULT_PINNING: ColumnPinningState = {\n left: [SELECT_COL_ID, 'id'],\n right: [ACTIONS_COL_ID],\n };\n const [columnPinning, setColumnPinning] = usePersistedState<ColumnPinningState>(\n `${layoutKey}:pinning`,\n DEFAULT_PINNING,\n );\n\n // #17 — reset the persisted layout on a token bump from the columns dropdown.\n // The setters persist the reset values, so localStorage is cleaned too.\n const resetToken = resetLayout?.token ?? 0;\n useEffect(() => {\n if (!resetToken) return;\n setColumnSizing({});\n if (resetLayout?.mode === 'all') {\n setColumnOrder([]);\n setColumnPinning(DEFAULT_PINNING);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [resetToken]);\n\n // Reset selection whenever the visible data array reference changes.\n // The `controlled` guard isn't a correctness gate — `rowSelection` never\n // reads `ownSelection` in controlled mode, so this write is invisible\n // either way — it just skips a pointless `setOwnSelection({})` + re-render\n // on every page/filter/sort change for a controlled caller.\n useEffect(() => {\n if (controlled) return;\n // No explicit onSelectionChange([]) here — clearing `ownSelection` makes the\n // notify-effect below emit [] on its own. Calling it here too would double-emit.\n setOwnSelection({});\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [data]);\n\n /*\n THE SECOND `kind: 'column'` ENFORCEMENT CALL SITE (SP5 task 2) — the table\n itself. `useResourceList`'s `isColVisibleHere` is the first; it gates what\n the Columns menu OFFERS, and it is not in this path at all when a host\n renders `<ResourceList>` directly with a `columns` prop (which is exactly\n what `columnsOverride` is, and what every test in this package does). A\n denial that only lived in the controller would therefore be bypassable by\n passing the column in explicitly.\n\n Checked BEFORE the `!field` early-return on purpose: a column that names no\n field is a legitimate host-rendered column (`renderCell`), and a rule must\n be able to gate it too.\n */\n // The one list predicate (P5 spec 3.7): field view in any-record reach plus `column` rules.\n // A pending decision renders the skeleton over the whole declared set, never a narrower one.\n const listAccess = useListAccess(resource);\n // A dotted column naming a field across relations is decided like the controller decides it:\n // its head, its full key, and the field of every hop. The row's projection keeps keys that name\n // no field of its own, so the table must not draw what this predicate hides.\n const pathAccess = usePathAccess(resource);\n const accessPending = listAccess.status === 'pending' || pathAccess.pending;\n const declaredColumnKeys = useMemo<string[]>(() => {\n if (!def) return [];\n return [...(columnsOverride ?? def.views?.list?.columns ?? Object.keys(def.fields))];\n }, [def, columnsOverride]);\n const visibleColumnKeys = useMemo<string[]>(\n () =>\n accessPending\n ? []\n : declaredColumnKeys.filter(\n (col) =>\n listAccess.columnVisible(col) &&\n (columnTarget(app.registry, resource, col) === undefined ||\n (listAccess.columnVisible(col.split('.')[0] as string) && pathAccess.visible(col))),\n ),\n [accessPending, declaredColumnKeys, listAccess, pathAccess, app, resource],\n );\n const skeletonColumnKeys = accessPending ? declaredColumnKeys : visibleColumnKeys;\n\n const rows = useMemo<RowRecord[]>(() => data ?? [], [data]);\n\n // The row flows' pre-click read (P4 spec 4.17, I8): one batched read per page, keyed by the\n // page's own ids, and only when a row flow's `when` or pre-click check reads past the list DTO.\n const rowFlows = useMemo<CompiledFlow[]>(() => {\n if (!def) return [];\n const items = (def.actions?.item ?? []) as readonly PlannableAction[];\n const out: CompiledFlow[] = [];\n for (const placement of planItemActions(items, 'row')) {\n const action = items.find((entry) => entry.name === placement.name);\n if ((action as { readonly kind?: unknown } | undefined)?.kind !== 'flow') continue;\n try {\n out.push(compileFlow(def as never, placement.name));\n } catch {\n // An uncompilable flow is absent on the row as well.\n }\n }\n return out;\n }, [def]);\n const pageIds = useMemo(() => rows.map((row) => String(row.id)), [rows]);\n const rowBatch = useFlowRowBatch(resource, pageIds, rowFlows);\n const rowBatchState = rowBatch.state;\n const flowRowBatch = useMemo(\n () => ({ resource, state: rowBatchState }),\n [resource, rowBatchState],\n );\n\n // UNKNOWN TOTAL IS NOT ONE PAGE.\n //\n // `total` is absent whenever the provider skips the count query — which is\n // exactly what the biggest tables do, because counting 28.9M rows took ~55s\n // and hung the page. The old expression fell back to `rows.length`, so a full\n // first page of 10 became \"10 / 10 = 1 page\", the pager was hidden entirely,\n // and the user could never reach row 11 of nine million. The list looked\n // complete while silently truncating.\n //\n // With no count we cannot know the last page, but we can know whether THIS\n // page is full: a full page means there is plausibly more, a short page means\n // we have reached the end. That is the standard unknown-total pagination\n // contract — range without a grand total, Next while full, no jump-to-end.\n const knownTotal = typeof total === 'number';\n const totalPages = knownTotal ? Math.max(1, Math.ceil(total / pageSize)) : undefined;\n const pageIsFull = rows.length >= pageSize;\n const hasNextPage = knownTotal ? page < (totalPages as number) : pageIsFull;\n // The footer is shown whenever the list has rows — NOT only when there's more\n // than one page. Even a single-record list benefits from it: it reports the\n // total count and, crucially, offers the page-size selector. Otherwise a list\n // of 45 rows at pageSize 50 fits on one page, hides the footer, and the user\n // has no way to shrink the page size to fit the viewport. The nav buttons\n // simply disable on a single page — that is expected, not a defect.\n // NOTE: this is deliberately `rows.length > 0` alone. An earlier version added\n // `|| page > 1` to keep a way back off an empty out-of-range page, but that\n // disjunct was never reachable — the `rows.length === 0` branch below RETURNS\n // before the footer renders. An empty page past the first is handled there\n // instead, by the `list-empty-first-page` recovery button.\n const showPager = rows.length > 0;\n\n // Auto-correct an out-of-range page when the total is known: a stale\n // `?page=20` on a 3-page list snaps to the last real page so the user sees\n // data, not a dead empty page. `total===0` clamps to page 1, where the empty\n // state (not the footer) takes over. Idempotent — once page ≤ totalPages the\n // condition is false. Unknown-total lists can't compute the last page, so\n // they instead get the one-click `list-empty-first-page` button in the\n // empty state (stepping back one page per fetch would cost 17 round-trips\n // from `?page=20`).\n useEffect(() => {\n // NOT while loading: on a cold deep-link to `?page=2`, `query.data` is\n // briefly empty and the host passes `total = rows.length = 0`, which is a\n // valid number → knownTotal, totalPages=1 → this would spuriously clamp\n // page 2 to 1 BEFORE the real count arrives. Wait for real data.\n if (isLoading || !onPage || !knownTotal) return;\n const tp = totalPages as number;\n if (page > tp) onPage(tp);\n }, [isLoading, onPage, knownTotal, totalPages, page]);\n\n const resourceLabel = resolveResourceLabel(i18nCaps, resource, 'plural', def);\n const recordSingular = resolveResourceLabel(i18nCaps, resource, 'single', def);\n const ariaLabel = resourceLabel;\n // Computed in render (not the memo) so it re-translates on locale change; the\n // resolved string is fed into the memo's dep list below.\n const actionsHeader = t('actions.column', { defaultValue: 'Actions' });\n\n // Volatile props read via a ref inside the column render functions, so the\n // `tableColumns` memo does NOT rebuild when these change identity. The\n // playground passes fresh inline callbacks (`renderCell`, `rowHref`, `onSort`,\n // …) every render; if they were memo deps, columns would rebuild on every\n // parent render — including a graphql-ws subscription tick — which rebuilds\n // TanStack's column model and UNMOUNTS an open column-header menu mid-click.\n // The header/cell renders run fresh on every table render regardless, so they\n // still see the latest values through the ref.\n // View code reads a row projected in any-record reach (P5 spec 3.6.6): `renderCell`, the cell\n // renderers and `rowHref` (an href reaches the DOM and the status bar). The quick opener and\n // the item actions keep the row as read: they are policy.\n const viewRow = useViewRow(resource);\n const volatileRef = useRef({\n onSort,\n onHideColumn,\n requiredColumns,\n renderCell,\n rowHref,\n rowQuick,\n sort,\n i18nCaps,\n viewRow,\n });\n volatileRef.current = {\n onSort,\n onHideColumn,\n requiredColumns,\n renderCell,\n rowHref,\n rowQuick,\n sort,\n i18nCaps,\n viewRow,\n };\n\n // Stable callbacks for `<DataTable>`'s row/cell memoization (table render\n // perf #1). `DataTable` wraps rows/cells in `React.memo`, keyed in part on\n // these callback props — an unstable (fresh-per-render) callback here\n // defeats that memo on every single ResourceList render, same as an\n // unstable `tableColumns` dep would defeat the column memo above. `tid` is\n // itself stable (`useTestIds()` memoizes with an empty dep array), so\n // these only need `resource` + `tid` as deps; `rowHref` is read through\n // `volatileRef` (like the column cell renderers above) so the wrapper's\n // OWN identity never changes even though the playground passes a fresh\n // `rowHref` closure every render.\n const getRowTestId = useCallback(\n (row: RowRecord) => tid.listRow(resource, row.id),\n [resource, tid],\n );\n const getCellTestId = useCallback(\n (row: RowRecord, columnId: string) => {\n if (columnId === SELECT_COL_ID || columnId === ACTIONS_COL_ID) return undefined;\n return tid.listCell(resource, row.id, columnId);\n },\n [resource, tid],\n );\n // biome-ignore lint/correctness/useExhaustiveDependencies: a new identity per rowLinkKey re-renders the memoized rows\n const stableRowHref = useCallback(\n (record: RowRecord) => volatileRef.current.rowHref?.(volatileRef.current.viewRow(record)),\n [rowLinkKey],\n );\n // biome-ignore lint/correctness/useExhaustiveDependencies: a new identity per rowLinkKey re-renders the memoized rows\n const stableRowOpen = useCallback(\n (record: RowRecord) => {\n const open = volatileRef.current.rowQuick?.(record) ?? null;\n if (open === null) return false;\n open();\n return true;\n },\n [rowLinkKey],\n );\n // A `rowHref` prop being SET does not mean every row has somewhere to go —\n // the availability gate (Task 8) can return `''` for a record whose show\n // and edit are both unavailable. `rowClassName` must therefore check the\n // PER-ROW result, not just whether the callback exists, or a row with no\n // destination would still show a pointer cursor. Stable via `volatileRef`\n // for the same row/cell-memo reason as `stableRowHref` above.\n // biome-ignore lint/correctness/useExhaustiveDependencies: a new identity per rowLinkKey re-renders the memoized rows\n const stableRowClassName = useCallback(\n (row: Row<RowRecord>) =>\n volatileRef.current.rowHref?.(volatileRef.current.viewRow(row.original)) ||\n (volatileRef.current.rowQuick?.(row.original) ?? null) !== null\n ? 'cursor-pointer'\n : undefined,\n [rowLinkKey],\n );\n\n // Build TanStack ColumnDef array. Done unconditionally (even when we\n // early-return for loading/empty) because hooks must run on every\n // render path; the columns array is cheap to recompute.\n // The list's own width decides its narrow layout (finding 8): one action menu per row, a\n // compact pager. Measured on the list root, so a list in a sheet collapses like a phone's.\n const [listRoot, narrow] = useContainerNarrow();\n const tableColumns = useMemo<ColumnDef<RowRecord, unknown>[]>(() => {\n const cols: ColumnDef<RowRecord, unknown>[] = [];\n\n if (selectable) {\n cols.push({\n id: SELECT_COL_ID,\n enableSorting: false,\n enableHiding: false,\n enableResizing: false,\n size: 44,\n header: ({ table }) => (\n <Checkbox\n checked={\n table.getIsAllPageRowsSelected()\n ? true\n : table.getIsSomePageRowsSelected()\n ? 'indeterminate'\n : false\n }\n onCheckedChange={(v) => table.toggleAllPageRowsSelected(v === true)}\n aria-label={t('table.selectAllRows')}\n />\n ),\n cell: ({ row }) => (\n <Checkbox\n checked={row.getIsSelected()}\n onCheckedChange={(v) => row.toggleSelected(v === true)}\n data-testid={tid.listRowCheckbox(resource, row.original.id)}\n aria-label={t('table.selectRow')}\n />\n ),\n });\n }\n\n for (const col of visibleColumnKeys) {\n // A dotted column draws a field across to-one relations: its renderer, size and label are the\n // target field's, and its value sits under the dotted key itself.\n const target = columnTarget(app.registry, resource, col);\n const field = (target === undefined ? def?.fields?.[col] : target.field) as\n | {\n type?: import('@burojs/core').FieldDeclaration['type'];\n format?: string;\n kind?: string;\n declaration?: import('@burojs/core').FieldDeclaration;\n meta?: Record<string, unknown>;\n ui?: Record<string, unknown>;\n }\n | undefined;\n const declaredLabel = declaredText('field', field, 'label');\n const headerLabel =\n target === undefined\n ? resolveFieldLabel(volatileRef.current.i18nCaps, col, declaredLabel)\n : resolveFieldLabel(\n capsOf(volatileRef.current.i18nCaps, target.resource),\n target.name,\n declaredLabel,\n );\n const kindSize = columnSize(field);\n // A link holds a set of keys, which has no order: its column offers no sort.\n const declared =\n target === undefined && def !== undefined\n ? declaredField(def as unknown as DtoSource, col)\n : undefined;\n const linkColumn =\n declared !== null && typeof declared === 'object' && isLinkField(declared as never);\n cols.push({\n id: col,\n ...columnAccessor(col),\n // Omitted (not `undefined`) for unrecognised kinds so TanStack applies\n // its own default rather than treating 0/undefined as a width.\n ...(kindSize !== undefined ? { size: kindSize } : {}),\n enableSorting: !linkColumn && Boolean(volatileRef.current.onSort),\n enableHiding: true,\n meta: { testid: col },\n // Header is a MENU (#17): sort asc/desc/clear, pin left/right/unpin, hide\n // — instead of a blind click-to-toggle. Pin flows through the column's\n // own TanStack API (`column.pin`), which routes to our persisted\n // columnPinning; sort + hide route to the parent callbacks.\n header: ({ column, table }) => {\n const v = volatileRef.current;\n // Reorder among this column's SECTION peers, in visual order, visible\n // only, service columns (__…) excluded. A pinned column reorders\n // WITHIN its pinned group; a center column reorders in the flow. The\n // previous build filtered out `getIsPinned()`, so pinned columns had\n // no «move» items at all — pin two columns and you couldn't swap them.\n const pinSide = column.getIsPinned(); // 'left' | 'right' | false\n const sectionCols =\n pinSide === 'left'\n ? table.getLeftLeafColumns()\n : pinSide === 'right'\n ? table.getRightLeafColumns()\n : table.getCenterLeafColumns();\n const peerIds = sectionCols\n .filter((c) => c.getIsVisible() && !c.id.startsWith('__'))\n .map((c) => c.id);\n const pos = peerIds.indexOf(col);\n const move = (dir: 'left' | 'right') => {\n const to = dir === 'left' ? pos - 1 : pos + 1;\n if (pos < 0 || to < 0 || to >= peerIds.length) return;\n if (pinSide) {\n // The pinning array's order IS the pinned group's visual order\n // (getLeft/RightLeafColumns map the array 1:1), so swap there and\n // route it through our persisted columnPinning.\n const pinning = table.getState().columnPinning;\n const side = [...(pinSide === 'left' ? (pinning.left ?? []) : (pinning.right ?? []))];\n const a = side.indexOf(peerIds[pos]!);\n const b = side.indexOf(peerIds[to]!);\n if (a < 0 || b < 0) return;\n [side[a], side[b]] = [side[b]!, side[a]!];\n table.setColumnPinning({ ...pinning, [pinSide]: side });\n } else {\n const full = table.getVisibleLeafColumns().map((c) => c.id);\n const a = full.indexOf(peerIds[pos]!);\n const b = full.indexOf(peerIds[to]!);\n const next = [...full];\n [next[a], next[b]] = [next[b]!, next[a]!];\n table.setColumnOrder(next);\n }\n };\n return (\n <ColumnHeaderMenu\n label={headerLabel}\n sortable={!linkColumn && Boolean(v.onSort)}\n sortDirection={v.sort?.[0]?.field === col ? v.sort[0].direction : null}\n onSort={!linkColumn && v.onSort ? (dir) => v.onSort?.(col, dir) : undefined}\n pinned={column.getIsPinned()}\n onPin={(side) => column.pin(side)}\n canHide={Boolean(v.onHideColumn) && !v.requiredColumns?.includes(col)}\n onHide={v.onHideColumn ? () => v.onHideColumn?.(col) : undefined}\n onMove={move}\n canMoveLeft={pos > 0}\n canMoveRight={pos >= 0 && pos < peerIds.length - 1}\n testid={`list-sort:${resource}:${col}`}\n />\n );\n },\n cell: ({ row }) => {\n const raw = row.original;\n const record = volatileRef.current.viewRow(raw);\n const value = record[col];\n // Per-cell consumer override takes precedence over default renderer.\n const customCell = volatileRef.current.renderCell?.(col, value, record);\n const cellInner =\n customCell !== undefined ? (\n customCell\n ) : (\n <ResolvedFieldDisplay\n resource={target === undefined ? resourceRef : target.ref}\n name={target === undefined ? col : target.name}\n field={field ?? { type: 'unknown' }}\n value={value}\n record={record}\n fallback={<span>{String(value ?? '')}</span>}\n />\n );\n // Make the first content cell a real link for keyboard /\n // screen-reader navigation. Route it through the injected\n // `LinkComponent` (next/link, react-router, …) so the drill-in\n // stays client-side — a raw <a> would trigger a full document\n // reload under an SPA router.\n const href = volatileRef.current.rowHref?.(record);\n const indexInVisible = visibleColumnKeys.indexOf(col);\n const isFirstContentCell = indexInVisible === 0;\n const quick = isFirstContentCell ? (volatileRef.current.rowQuick?.(raw) ?? null) : null;\n // A quick row (P3-17): the page anchor claimed for the opener, or a button without one.\n if (quick !== null)\n return href ? (\n <ClaimedQuickLink href={href} className={relationLinkClassName} onOpen={quick}>\n {cellInner}\n </ClaimedQuickLink>\n ) : (\n <button\n type=\"button\"\n {...{ [QUICK_ANCHOR_ATTRIBUTE]: '' }}\n className={`${relationLinkClassName} text-left`}\n onClick={(e) => {\n e.stopPropagation();\n quick();\n }}\n >\n {cellInner}\n </button>\n );\n return isFirstContentCell && href ? (\n <RouterLink\n href={href}\n className={relationLinkClassName}\n onClick={(e) => e.stopPropagation()}\n >\n {cellInner}\n </RouterLink>\n ) : (\n cellInner\n );\n },\n });\n }\n\n // Drawn unless the list is read-only (`rowActions: false`): every resource has at least the\n // built-in Edit and Delete, so a guard on the declared actions would only ever hide the\n // column for a resource that opted BOTH built-ins out — and `<ActionOverflow>` already\n // returns null in that case.\n if (!rowActions) return cols;\n cols.push({\n id: ACTIONS_COL_ID,\n enableSorting: false,\n enableResizing: false,\n // Wide enough for what THIS resource declares, not a flat 64 — see\n // `actionsColumnSize` for the measurements behind that (F1).\n size: narrow\n ? ROW_ACTION_CONTROL_PX + ACTIONS_CELL_PADDING_PX\n : actionsColumnSize(def?.actions?.item),\n enableHiding: false,\n // No visible header — the kebab column needs no «Actions» label; it\n // only wastes space and reads as noise. The accessible name lives on\n // each row's action trigger. Kept as an sr-only string for AT.\n header: () => <span className=\"sr-only\">{actionsHeader}</span>,\n // `w-0` + `whitespace-nowrap` collapses the column to its natural width\n // on a NON-resizable table (no `table-layout: fixed`, so no inline width\n // var to override it) and right-aligns the strip, so the data columns\n // get the freed space.\n // `noRowNav: true` stamps the whole `<td>` (not just the buttons inside\n // it) as out of bounds for whole-row navigation — the cell's padding is\n // still bigger than the 32×32 controls, and a mis-click there used to\n // navigate away instead of doing nothing.\n // `noClip: true` is the F1 fix's backstop: this cell holds CONTROLS, so\n // it must spill visibly rather than clip one out of hit-testing. See\n // `columnMetaNoClip` in `data-table.tsx`.\n // `py-0.5`: a 28px control in the cell's `p-2` made a row 45px against a text row's 39px; with\n // the vertical padding trimmed the text sets the row's height. The horizontal `p-2` stays\n // (`ACTIONS_CELL_PADDING_PX`).\n meta: { className: 'w-0 whitespace-nowrap py-0.5 text-right', noRowNav: true, noClip: true },\n // Standalone row actions render inline; everything else collapses into a\n // single kebab, so the column stays bounded regardless of action count.\n cell: ({ row }) => <ActionOverflow resource={resource} record={row.original} surface=\"row\" />,\n });\n\n return cols;\n // Volatile props (onSort/sort/renderCell/rowHref/onHideColumn/\n // requiredColumns) are intentionally NOT deps — read via volatileRef so a\n // parent re-render doesn't rebuild columns and unmount an open header menu.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n // `i18nCaps` IS a dep: its identity changes only when the active locale\n // changes (see useI18nCaps memo), so column HEADER LABELS re-resolve on a\n // live language switch. It does not churn on ordinary parent re-renders, so\n // an open header menu still survives those.\n }, [\n app,\n selectable,\n rowActions,\n resourceRef,\n visibleColumnKeys,\n def,\n resource,\n tid,\n RouterLink,\n actionsHeader,\n i18nCaps,\n rowLinkKey,\n narrow,\n ]);\n\n // Bridge external selection state to TanStack's RowSelectionState shape.\n // We keep the caller's id-string contract (Array<string>) on the\n // onSelectionChange boundary; internally TanStack uses\n // {[rowId]: true}.\n //\n // Crucial in both branches below: never resolve `next` against the\n // closure-captured `rowSelection`. On rapid back-to-back clicks (e.g. e2e\n // tests calling click() twice without a microtask flush) that loses the\n // first toggle, because the second click's handler closure still sees the\n // pre-first-click selection. Uncontrolled uses the FUNCTIONAL form of\n // `setOwnSelection`; controlled uses `emittedRef` (see its declaration\n // above) since there is no local setState to resolve against.\n const handleSelectionChange = (\n updater: RowSelectionState | ((prev: RowSelectionState) => RowSelectionState),\n ) => {\n if (controlled) {\n // Resolve against the last value we emitted when the owner has not\n // committed it yet, so back-to-back toggles compose instead of racing.\n const base = emittedRef.current ?? rowSelection;\n const next = typeof updater === 'function' ? updater(base) : updater;\n emittedRef.current = next;\n // Safe here and NOT in the setState updater below: this runs in an event\n // handler, not the render phase.\n onSelectionChange?.(Object.keys(next).filter((k) => next[k]));\n return;\n }\n // The caller is NOT notified from inside the updater. A useState updater is\n // not an event-handler callback: React runs it during the RENDER phase (and\n // twice under StrictMode), so calling the parent's setState there is a\n // setState-during-render — \"Cannot update a component (ResourceListBody)\n // while rendering a different component (ResourceList)\". Notification\n // happens in the effect below, off committed state.\n setOwnSelection((prev) => (typeof updater === 'function' ? updater(prev) : updater));\n };\n\n // Uncontrolled only. Deliberately keyed on committed `ownSelection`:\n // `onSelectionChange` is left out of the deps on purpose because callers\n // commonly pass an inline arrow, and depending on it would re-emit every\n // render and loop. A controlled caller is notified straight from the\n // handler above — emitting [] here on mount would wipe its selection.\n useEffect(() => {\n if (controlled) return;\n onSelectionChange?.(Object.keys(ownSelection).filter((k) => ownSelection[k]));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [ownSelection]);\n\n const table = useBuroDataTable<RowRecord>({\n data: rows,\n columns: tableColumns,\n total,\n pagination: { pageIndex: Math.max(0, page - 1), pageSize },\n onPaginationChange: () => {\n // Pagination is parent-driven via onPage; ignore TanStack's own\n // updaters here. The Prev/Next buttons below call onPage directly.\n },\n sorting: useMemo<SortingState>(\n () => (sort?.[0] ? [{ id: sort[0].field, desc: sort[0].direction === 'desc' }] : []),\n [sort],\n ),\n onSortingChange: () => {\n // Sort is parent-driven via onSort; the sortable header's button\n // calls onSort directly. We do NOT toggle TanStack's own sort\n // state here — preserves the existing 3-click cycle ownership.\n },\n rowSelection,\n onRowSelectionChange: handleSelectionChange,\n enableRowSelection: selectable,\n columnPinning,\n onColumnPinningChange: setColumnPinning,\n columnSizing,\n onColumnSizingChange: setColumnSizing,\n columnOrder,\n onColumnOrderChange: setColumnOrder,\n enableColumnResizing: true,\n });\n\n // Hand the table instance up to callers that need to read TanStack\n // selection / filter / sort state for components living outside the\n // table (e.g. `<BulkActionToolbar>` reading\n // `table.getFilteredSelectedRowModel().rows`). Fires once after\n // mount with the live table; fires again with `null` on unmount so\n // callers can drop their reference.\n useEffect(() => {\n tableRef?.(table);\n return () => {\n tableRef?.(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [table]);\n\n if (!def) {\n return <div data-testid={tid.listEmpty(resource)}>{t('list.notRegistered')}</div>;\n }\n\n // Loading state — skeleton rendered inside the same Table primitives\n // the real list uses, so the loading shimmer matches the rendered\n // table's geometry exactly: same row height, same cell padding,\n // same columns. Replacing the prior generic flex bars eliminates\n // the visual jump when data arrives. Each cell holds an\n // `animate-pulse rounded bg-muted/60` block sized to the column\n // role: a 4×4 square for the checkbox/actions columns; a wider\n // bar for content columns. Headers carry their own muted bars so\n // the skeleton reads as \"table loading\", not \"blank screen\".\n if ((isLoading || accessPending) && rowsView !== undefined)\n return (\n <div\n className={cn('space-y-2', className)}\n role=\"status\"\n aria-busy=\"true\"\n aria-live=\"polite\"\n data-testid=\"loading\"\n >\n <span className=\"sr-only\">{t('list.loading', { params: { items: resourceLabel } })}</span>\n {rowsView.skeleton}\n </div>\n );\n if (isLoading || accessPending) {\n const skeletonRows = 5;\n return (\n <div\n className={cn('space-y-2', className)}\n role=\"status\"\n aria-busy=\"true\"\n aria-live=\"polite\"\n data-testid=\"loading\"\n >\n <span className=\"sr-only\">{t('list.loading', { params: { items: resourceLabel } })}</span>\n <UITable>\n <TableHeader>\n <TableRow>\n {selectable && (\n <TableHead className=\"w-10\">\n <div className=\"size-4 animate-pulse rounded bg-muted/60\" />\n </TableHead>\n )}\n {skeletonColumnKeys.map((col) => (\n <TableHead key={col}>\n <div className=\"h-3.5 w-20 animate-pulse rounded bg-muted/60\" />\n </TableHead>\n ))}\n <TableHead className=\"w-16 text-right\">\n <div className=\"ml-auto h-3.5 w-12 animate-pulse rounded bg-muted/60\" />\n </TableHead>\n </TableRow>\n </TableHeader>\n <TableBody>\n {Array.from({ length: skeletonRows }, (_, i) => (\n <TableRow key={i}>\n {selectable && (\n <TableCell className=\"w-10\">\n <div className=\"size-4 animate-pulse rounded bg-muted/60\" />\n </TableCell>\n )}\n {skeletonColumnKeys.map((col) => (\n <TableCell key={col}>\n <div className=\"h-4 w-full max-w-[16rem] animate-pulse rounded bg-muted/60\" />\n </TableCell>\n ))}\n <TableCell className=\"w-16\">\n <div className=\"ml-auto size-7 animate-pulse rounded bg-muted/60\" />\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </UITable>\n </div>\n );\n }\n\n if (error) {\n // Icon + heading + friendly body + optional Retry. Extracted to\n // `<ListErrorState>` so level-3 body slots can render the SAME panel\n // instead of hand-rolling a worse one — see that file for what the\n // `schedules` slot was showing before it existed.\n return (\n <ListErrorState error={error} onRetry={onRetry} resource={resource} className={className} />\n );\n }\n\n // `emptyState === undefined` is the ONLY guard added here for the list\n // slots (B3.2), and it is deliberately a guard rather than a restructure:\n // absent the prop this branch is byte-identical to what it always was.\n // When a caller DOES supply one, skipping the early return is the whole\n // point — control falls through to `<DataTable emptyState>` below, which\n // has rendered the node in a full-width body cell since it was written\n // and which no caller had ever been able to reach.\n if (rows.length === 0 && emptyState === undefined) {\n // Empty-state polish: split the icon, heading, body, and CTA\n // into a clear vertical hierarchy. Two flavours:\n // - filtered-no-match: IconFilterX icon, \"No matching <plural>\" h3,\n // body explains the filter, \"Clear filter\" outline button.\n // - genuinely empty: IconInbox icon, \"No <plural> yet\" h3, friendly\n // body inviting creation, \"+ Create <singular>\" primary\n // button (when `createHref` is provided).\n // Both flavours are OVERRIDDEN when `page > 1`: this branch returns\n // before the `showPager`-gated footer further down (`:878`), so an\n // out-of-range page (e.g. a stale `?page=20`) would otherwise be a\n // dead end — no pager, and the unknown-total clamp can't help (it's\n // gated on `knownTotal`, `:312`). Neither \"no records yet\" nor \"no\n // matching records\" is honest here — the list may well have data,\n // just not on this page — so heading/body switch to the \"wrong page\"\n // copy and the CTA offers a single-click way back to page 1.\n const isWrongPage = page > 1;\n const EmptyIcon = isFiltered ? IconFilterX : IconInbox;\n const items = resourceLabel.toLowerCase();\n const heading = isWrongPage\n ? t('pagination.emptyPage')\n : isFiltered\n ? t('list.emptyFilteredTitle', { params: { items } })\n : t('list.emptyTitle', { params: { items } });\n // The wrong-page flavour deliberately has NO body: its heading already says\n // the whole story and the recovery button below says what to do, so a\n // paragraph would just repeat the heading verbatim.\n const body = isWrongPage\n ? null\n : isFiltered\n ? t('list.emptyFilteredBody', { params: { items } })\n : createHref\n ? t('list.emptyBody', { params: { item: recordSingular.toLowerCase() } })\n : // No create here: inviting the user to create one would be a dead end.\n t('list.emptyBodyReadOnly', { params: { items } });\n // Zero rows does not mean \"no more data\" for a cursor list: server-side\n // filtering can legitimately leave the CURRENT token's page empty while a\n // later token still has matches (`hasMore: true` has no dependency on\n // `rows.length` — see the `loadMore` docblock above). So the panel and\n // the load-more control render TOGETHER here rather than one replacing\n // the other: the panel explains this page is empty, the control offers\n // the next one. `<CursorLoadMore>` already no-ops when `hasMore` is\n // false, so this is a no-op appendage on an honestly-exhausted list.\n return (\n <>\n <div\n className={cn(\n 'flex flex-col items-center justify-center gap-3 px-6 py-16 rounded-lg border border-dashed text-center',\n className,\n )}\n data-testid={tid.listEmpty(resource)}\n >\n <div className=\"rounded-full bg-muted p-3 text-muted-foreground\">\n <EmptyIcon className=\"size-6\" aria-hidden=\"true\" />\n </div>\n <div className=\"space-y-1\">\n <h3 className=\"text-base font-semibold tracking-tight\">{heading}</h3>\n {body ? <p className=\"max-w-sm text-sm text-muted-foreground\">{body}</p> : null}\n </div>\n <div className=\"flex justify-center gap-2 pt-2\">\n {isFiltered && onClearFilter && (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n data-testid={`list-clear-filter:${resource}`}\n onClick={onClearFilter}\n >\n {t('list.clearFilter')}\n </Button>\n )}\n {/* NOT on a wrong page: \"+ Create\" implies the list is empty, but an\n out-of-range page says nothing about whether records exist — the\n list may be full. Offering it there is the same false claim the\n heading above was fixed to stop making. */}\n {!isFiltered && !isWrongPage && createHref && (\n <RouterLink href={createHref}>\n <Button type=\"button\" size=\"sm\" data-testid={`list-empty-create:${resource}`}>\n {t('list.create', { params: { item: recordSingular } })}\n </Button>\n </RouterLink>\n )}\n {isWrongPage && onPage && (\n <Button\n type=\"button\"\n size=\"sm\"\n data-testid={`list-empty-first-page:${resource}`}\n onClick={() => onPage(1)}\n >\n {t('pagination.firstPage')}\n </Button>\n )}\n {/* The count is LOAD-BEARING here and nowhere else in this panel.\n An out-of-range page is empty precisely because nothing knows\n where the list ends: the clamp at the top of this component is\n gated on `knownTotal` and is therefore dead. Answering the count\n un-gates it, and the user is snapped to the LAST real page —\n a second recovery route, and the opposite one to «Back to start».\n That makes the two co-equal choices, so this reads as the\n established secondary action of this row (the same treatment\n `list-clear-filter` above uses) rather than as the footer's\n sentence-continuation link.\n\n ⚠️ NOT offered on the page-1 empty state: with server-side\n filtering an empty first page IS the count — the answer is\n always 0, and the panel already says so.\n ⚠️ Supplying `emptyState` skips this whole branch (see the guard\n at the top of it), so a B3 list-body slot adopter gets no\n affordance at zero rows. Out of scope here; noted so the next\n reader does not think it was missed. */}\n {isWrongPage && !knownTotal && onRequestCount && (\n <CountRowsTrigger\n label={t('pagination.countRows')}\n loading={isCountingRows}\n onClick={onRequestCount}\n testid={`list-count:${resource}`}\n variant=\"outline\"\n />\n )}\n </div>\n </div>\n {loadMore && (\n <CursorLoadMore\n hasMore={loadMore.hasMore}\n loading={loadMore.loading}\n onMore={loadMore.onMore}\n />\n )}\n </>\n );\n }\n\n return (\n <FlowRowBatchContext.Provider value={flowRowBatch}>\n <RowActionsCollapseContext.Provider value={narrow}>\n {rowBatch.reader}\n <div ref={listRoot} className={cn('space-y-4', className)}>\n {rowsView !== undefined ? (\n rowsView.render(rows)\n ) : (\n <DataTable\n table={table}\n tableTestId={tid.listTable(resource)}\n ariaLabel={ariaLabel}\n // Reachable only via the `emptyState` prop above: without it this\n // component early-returns its own panel before ever rendering the\n // table, which is why `DataTable`'s prop sat unused until B3.2.\n emptyState={emptyState}\n onColumnReorder={(fromId, toId) => {\n // Seed the order from the CURRENT visible leaf order (columnOrder may\n // be empty, meaning \"natural order\"), then move `from` to `to`'s slot.\n const current = table.getState().columnOrder;\n const base =\n current.length > 0 ? current : table.getVisibleLeafColumns().map((c) => c.id);\n const next = base.filter((id) => id !== fromId);\n const at = next.indexOf(toId);\n next.splice(at < 0 ? next.length : at, 0, fromId);\n setColumnOrder(next);\n }}\n getRowTestId={getRowTestId}\n getCellTestId={getCellTestId}\n // Row click affordance: when the consumer provides a `rowHref`,\n // most rows carry a clickable first-cell anchor — surface that\n // to the rest of the row by adding `cursor-pointer` so users see\n // the row is clickable wherever they hover, not just over the\n // title cell. The actual click is still handled by the anchor\n // for proper href semantics + middle-click + copy-link support.\n // Per-row, not per-callback: `rowHref` can return `''` for a\n // record the availability gate has no destination for (Task 8),\n // and that row must NOT look clickable either.\n rowClassName={rowHref || rowQuick ? stableRowClassName : undefined}\n // #4 — whole-row click navigates (Cmd/Ctrl/middle-click → new tab). The\n // first cell stays a real anchor for keyboard/copy-link; this adds the\n // mouse affordance across the rest of the row. Routed through the\n // stable `stableRowHref` wrapper (reads `rowHref` via `volatileRef`)\n // so its identity doesn't change every render — see the row/cell\n // memoization in `DataTable`.\n rowHref={rowHref ? stableRowHref : undefined}\n onRowOpen={rowQuick ? stableRowOpen : undefined}\n // Row-selection checkbox column id (table render perf #1): tells\n // `DataTable` which cell must keep re-rendering on `isSelected`\n // changes while every other cell (the actions kebab, data cells)\n // stays memoized-frozen across selection-only renders.\n selectionColumnId={selectable ? SELECT_COL_ID : undefined}\n />\n )}\n\n {/* Cursor (opaque-token) lists have no page index to jump to, so they get\n a load-more footer instead of the numbered pager below. `loadMore`\n wins over `showPager` on purpose — it is a plain prop, not read from\n the controller, so this component stays mountable standalone (see\n the `loadMore` docblock above).\n\n ⚠️ Deliberately NOT gated on `showPager` (`rows.length > 0`):\n `hasMore` comes from the cursor token, which has no relationship to\n how many rows the CURRENT page happens to hold — server-side\n filtering can legitimately return zero rows for this token while a\n later token still has matches. Consulting row count here would\n strand that case. `<CursorLoadMore>` already no-ops on\n `hasMore: false`, so this stays correctly silent once the list is\n actually exhausted. (The zero-rows-AND-no-custom-emptyState case is\n handled earlier, at the empty-state early return, where the panel\n and this same control render together.) */}\n {loadMore && (\n <CursorLoadMore\n hasMore={loadMore.hasMore}\n loading={loadMore.loading}\n onMore={loadMore.onMore}\n />\n )}\n {showPager && !loadMore && (\n <div className=\"flex items-center justify-between border-t pt-3 text-sm\">\n {/* \"Showing X–Y of Z\" — admin-grade range readout, more\n human than the prior \"Page X of Y (Z total)\" form. The\n range uses the page index + pageSize math; clamps the\n upper bound at total when the last page is partial. */}\n {/* `aria-live` so the answer to an on-demand count is announced: the\n readout rewrites itself from «Showing 1–10» to «Showing 1–10 of\n 9 800 000» with no focus change and nothing else to notice. */}\n <div className=\"text-muted-foreground tabular-nums\" aria-live=\"polite\">\n {knownTotal\n ? t('pagination.showing', {\n params: {\n from: nf.format((page - 1) * pageSize + 1),\n to: nf.format(Math.min(page * pageSize, total as number)),\n total: nf.format(total as number),\n },\n })\n : /* Without a count, printing «of 10» would state a total that is\n off by nine million. Show the range only. */\n t('pagination.showingUnknownTotal', {\n params: {\n from: nf.format((page - 1) * pageSize + 1),\n to: nf.format((page - 1) * pageSize + rows.length),\n },\n })}\n {/* The trigger sits at the END of that sentence, in the very spot\n where «of {{total}}» prints once the count lands — so \"the\n number appears where you asked for it\" is literal, and the\n trigger disappears because the `knownTotal` branch above takes\n over. It is styled as prose, not as a control: the four pager\n buttons opposite are all boxed `outline sm`, and a fifth boxed\n control would read as a button bar. `link` is the only boxless\n variant; matching the readout's size and muted colour makes it\n a continuation of the sentence rather than a new element. */}\n {!knownTotal && onRequestCount && (\n <CountRowsTrigger\n label={t('pagination.countRows')}\n loading={isCountingRows}\n onClick={onRequestCount}\n testid={`list-count:${resource}`}\n variant=\"link\"\n className=\"ml-1.5 h-auto p-0 align-baseline text-sm font-normal text-muted-foreground underline underline-offset-4 hover:text-foreground\"\n />\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n {/* Ten rows over hundreds of pages is a daily tax for anyone\n scanning records; the size selector is the cheapest fix. Hidden\n unless the host can persist the choice (see `onPageSize`). */}\n {onPageSize && (\n <div className=\"flex items-center gap-2\">\n <span className={narrow ? 'sr-only' : 'text-muted-foreground'}>\n {t('pagination.rowsPerPage', { defaultValue: 'Rows per page' })}\n </span>\n <Select value={String(pageSize)} onValueChange={(v) => onPageSize(Number(v))}>\n <SelectTrigger\n className=\"h-8 w-[4.5rem]\"\n data-testid={`list-page-size:${resource}`}\n >\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {pageSizeOptions.map((n) => (\n <SelectItem key={n} value={String(n)}>\n {n}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n )}\n <span className={cn('text-muted-foreground tabular-nums', narrow && 'hidden')}>\n {knownTotal\n ? t('pagination.pageOf', {\n params: { page: nf.format(page), total: nf.format(totalPages as number) },\n })\n : t('pagination.pageOnly', { params: { page: nf.format(page) } })}\n </span>\n {/* First/last jumps: 270 pages reachable only by Back/Forward means\n 199 clicks to reach page 200. Rendered only when they would do\n something a neighbour button cannot. */}\n {knownTotal && (totalPages as number) > 2 && (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n data-testid={`list-pagination-first:${resource}`}\n aria-label={t('pagination.firstPage')}\n disabled={page <= 1}\n onClick={() => onPage?.(1)}\n className=\"h-8 w-8 p-0\"\n >\n <IconChevronsLeft className=\"size-4\" aria-hidden=\"true\" />\n </Button>\n )}\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n data-testid={tid.listPaginationPrev(resource)}\n disabled={page <= 1}\n onClick={() => onPage?.(page - 1)}\n // Narrow, an icon: the words made the pager wider than a phone.\n className={cn('h-8 gap-1', narrow && 'w-8 p-0')}\n >\n <IconChevronLeft className=\"size-4\" aria-hidden=\"true\" />\n <span className={narrow ? 'sr-only' : undefined}>{t('pagination.prev')}</span>\n </Button>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n data-testid={tid.listPaginationNext(resource)}\n disabled={!hasNextPage}\n onClick={() => onPage?.(page + 1)}\n className={cn('h-8 gap-1', narrow && 'w-8 p-0')}\n >\n <span className={narrow ? 'sr-only' : undefined}>{t('pagination.next')}</span>\n <IconChevronRight className=\"size-4\" aria-hidden=\"true\" />\n </Button>\n {/* No jump-to-end without a known end. */}\n {knownTotal && (totalPages as number) > 2 && (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n data-testid={`list-pagination-last:${resource}`}\n aria-label={t('pagination.lastPage')}\n disabled={page >= (totalPages as number)}\n onClick={() => onPage?.(totalPages as number)}\n className=\"h-8 w-8 p-0\"\n >\n <IconChevronsRight className=\"size-4\" aria-hidden=\"true\" />\n </Button>\n )}\n </div>\n </div>\n )}\n </div>\n </RowActionsCollapseContext.Provider>\n </FlowRowBatchContext.Provider>\n );\n}\n\n/**\n * localStorage-backed state (#17). Lazily seeds from storage, writes on change,\n * and fails silently when storage is unavailable. `Updater` support so it drops\n * straight into TanStack's `onXxxChange` callbacks.\n */\nfunction usePersistedState<T>(\n key: string,\n initial: T,\n debounceMs = 0,\n): [T, (updater: T | ((prev: T) => T)) => void] {\n const [state, setState] = useState<T>(() => {\n if (typeof window === 'undefined') return initial;\n try {\n const raw = window.localStorage.getItem(key);\n return raw ? (JSON.parse(raw) as T) : initial;\n } catch {\n return initial;\n }\n });\n // Seed the initial value into storage once so the persisted layout is\n // explicit (and a future \"reset layout\" has a known baseline to clear).\n useEffect(() => {\n try {\n if (window.localStorage.getItem(key) == null) {\n window.localStorage.setItem(key, JSON.stringify(initial));\n }\n } catch {\n // storage unavailable — in-memory default still applies\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n const writeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const write = (value: T) => {\n // Column-sizing fires this on every drag frame (columnResizeMode 'onChange').\n // Debounce the localStorage write so a drag isn't a JSON.stringify per pixel;\n // the in-memory state still updates live for a smooth resize.\n const doWrite = () => {\n try {\n window.localStorage.setItem(key, JSON.stringify(value));\n } catch {\n // storage full / disabled — keep the in-memory value\n }\n };\n if (debounceMs <= 0) {\n doWrite();\n return;\n }\n if (writeTimer.current) clearTimeout(writeTimer.current);\n writeTimer.current = setTimeout(doWrite, debounceMs);\n };\n const set = (updater: T | ((prev: T) => T)) => {\n setState((prev) => {\n const next = typeof updater === 'function' ? (updater as (p: T) => T)(prev) : updater;\n write(next);\n return next;\n });\n };\n return [state, set];\n}\n","'use client';\nimport { type FramePiece, useFramePiece } from '@burojs/react';\nimport type { ReactElement } from 'react';\n\n/**\n * A list piece as a frame places it: its view in a frame, a marker under `checkFrame` (which\n * renders a frame alone, without the list controller the pieces read).\n */\nexport function listPiece(\n name: FramePiece,\n View: () => ReactElement | null,\n): () => ReactElement | null {\n function Piece(): ReactElement | null {\n const check = useFramePiece(name);\n if (check?.stub === true) return <span data-check-piece={name} />;\n return <View />;\n }\n Piece.displayName = name;\n return Piece;\n}\n","'use client';\nimport { type ReactNode, createContext, useContext, useEffect, useMemo, useRef } from 'react';\nimport type { SearchDecl } from '@burojs/core';\nimport type { SavedViewEntry } from '@burojs/react';\nimport type { ComponentType, ReactElement } from 'react';\nimport type { ItemHandle } from '../../blocks/related-item.js';\nimport type { ResourceListProps } from '../../resource/resource-list.js';\n\n/** The names of the list pieces a frame arranges (P7-33). */\nexport type ListPieceName =\n | 'filters'\n | 'flows'\n | 'live'\n | 'saved-views'\n | 'columns'\n | 'export'\n | 'create'\n | 'body'\n | 'bulk-bar';\n\n/** What the route and placement lists share with their pieces: everything that is not the controller. */\nexport interface ListSurfaceValue {\n readonly resource: string;\n /** The route list (saved views, create, the page header) rather than a `related-list` placement. */\n readonly route: boolean;\n /** The table draws rows, columns, selection and the bulk bar; cards and timeline do not. */\n readonly tableView: boolean;\n /** The placement's own search box declaration; the route list reads `views.list.search`. */\n readonly searchDecl: SearchDecl | undefined;\n /** `list.filters.<r>`: replaces the contents of the filter region. */\n readonly FiltersSlot: ComponentType | undefined;\n readonly savedViewsUi: {\n readonly canSaveCurrent: boolean;\n readonly canFork: boolean;\n readonly onSaveCurrent: () => void;\n readonly onManage: () => void;\n readonly onRenameEntry: (entry: SavedViewEntry) => void;\n readonly onForkEntry: (entry: SavedViewEntry) => void;\n readonly onDeleteEntry: (entry: SavedViewEntry) => void;\n };\n readonly openCreate: (() => void) | undefined;\n readonly createAvailable: boolean;\n readonly createPage: boolean;\n /** What a row opens, and how the cards or timeline draw the rows: straight to `<ResourceList>`. */\n readonly rowProps: Partial<Pick<ResourceListProps, 'rowHref' | 'rowQuick' | 'rowLinkKey'>>;\n /**\n * How cards or a timeline draw the rows, given the planned item block (the route list's comes\n * from its frame's plan, `ListItemContext`; a placement's is its own prop). Absent for a table.\n */\n readonly rowsViewFor:\n | ((item: ItemHandle | undefined) => ResourceListProps['rowsView'])\n | undefined;\n readonly emptyState: ReactNode;\n /** The route's cell ladder: a typed discriminator, an enum badge, then `renderCell` / `list.cell.<r>`. */\n readonly renderCell: NonNullable<ResourceListProps['renderCell']>;\n /** A read-only list: no row actions, no selection, no bulk bar. */\n readonly readOnly: boolean;\n /** The list draws its export control. */\n readonly exportable: boolean;\n}\n\nconst SurfaceContext = createContext<ListSurfaceValue | null>(null);\n\n/**\n * The route list's planned item block, provided by the frame host that plans the list's screen\n * (P7-36); `undefined` where there is none, and the rows then draw their default item.\n * @internal\n */\nexport const ListItemContext = createContext<ItemHandle | undefined>(undefined);\n\ninterface PieceCounts {\n readonly counts: Map<ListPieceName, number>;\n readonly register: (name: ListPieceName) => () => void;\n}\n\nconst PiecesContext = createContext<PieceCounts | null>(null);\n\n/**\n * Provides the surface's shared value to the pieces and counts how many times each is mounted\n * (a frame that omits or repeats a piece is reported by the surface, P7-34). Registration is\n * effect-based and balanced, so StrictMode's simulated unmount and remount leave one count per\n * mounted instance, not two (Known finding 20).\n * @internal\n */\nexport function ListPiecesProvider(props: {\n readonly value: ListSurfaceValue;\n readonly counts?: (counts: ReadonlyMap<ListPieceName, number>) => void;\n readonly children: ReactNode;\n}): ReactElement {\n const { value, children } = props;\n const registry = useRef<PieceCounts | null>(null);\n if (registry.current === null) {\n const counts = new Map<ListPieceName, number>();\n registry.current = {\n counts,\n register: (name) => {\n counts.set(name, (counts.get(name) ?? 0) + 1);\n return () => {\n counts.set(name, (counts.get(name) ?? 1) - 1);\n };\n },\n };\n }\n const stable = useMemo(() => registry.current as PieceCounts, []);\n return (\n <PiecesContext.Provider value={stable}>\n <SurfaceContext.Provider value={value}>{children}</SurfaceContext.Provider>\n </PiecesContext.Provider>\n );\n}\n\n/** The mount counts so far, by piece (the surface reads them after its frame has mounted). @internal */\nexport function useListPieceCounts(): () => ReadonlyMap<ListPieceName, number> {\n const pieces = useContext(PiecesContext);\n return () => pieces?.counts ?? new Map();\n}\n\n/** Registers one mounted piece instance. @internal */\nexport function usePieceMount(name: ListPieceName): void {\n const pieces = useContext(PiecesContext);\n useEffect(() => pieces?.register(name), [pieces, name]);\n}\n\n/** The surface's shared value; throws outside a list. @internal */\nexport function useListSurface(): ListSurfaceValue {\n const value = useContext(SurfaceContext);\n if (value === null)\n throw new Error('A list piece (ListControls, ListBody, …) renders inside a resource list.');\n return value;\n}\n\n/**\n * Draws its children as the table, whatever `views.list.view` says: cards and a timeline read\n * their rows through the screen tree, which the built-in fallback arrangement does not have.\n * Only the surface value changes; the mount counts stay the surface's own.\n * @internal\n */\nexport function ForceTableView(props: { readonly children: ReactNode }): ReactElement {\n const value = useListSurface();\n const forced = useMemo(() => ({ ...value, tableView: true, rowsViewFor: undefined }), [value]);\n return <SurfaceContext.Provider value={forced}>{props.children}</SurfaceContext.Provider>;\n}\n","'use client';\nimport { type ReactElement, useContext, useMemo } from 'react';\nimport { policyRowsOf, useResourceListContext } from '@burojs/react';\nimport { ResourceList } from '../../resource/resource-list.js';\nimport { listPiece } from './piece.js';\nimport { ListItemContext, useListSurface, usePieceMount } from './pieces-context.js';\n\n/**\n * The rows: the table, or cards or a timeline over the same controller, with the empty state,\n * the pager (or \"load more\") and the on-demand count.\n */\nfunction ListBodyView() {\n usePieceMount('body');\n const list = useResourceListContext();\n const {\n resource,\n route,\n tableView,\n createAvailable,\n createPage,\n rowProps,\n rowsViewFor,\n emptyState,\n renderCell,\n readOnly,\n } = useListSurface();\n const item = useContext(ListItemContext);\n const rowsView = useMemo(() => rowsViewFor?.(item), [rowsViewFor, item]);\n const { query, pagination, cursor, count, columns, selection, filters, sorting, routing } = list;\n // The table keeps the rows as read: selection, the quick opener and item-action gates are\n // policy, and its cells project each row on their own (`viewRow`).\n const rows = policyRowsOf(list, list.rows);\n return (\n <ResourceList\n resource={resource}\n data={rows}\n total={pagination.total}\n page={pagination.page}\n pageSize={pagination.pageSize}\n pageSizeOptions={pagination.pageSizeOptions}\n onPage={pagination.setPage}\n // `setPageSize` anchors back to page 1 itself: row 41 of the old\n // size may not exist under the new one.\n onPageSize={pagination.setPageSize}\n // Cursor (token) pagination — `controller.cursor` is non-null exactly\n // when the resource declares `views.list.pagination: 'cursor'`; the\n // `pagination.*` props above stay wired but go inert in that mode,\n // since `<ResourceList>` prefers `loadMore` over the numbered pager\n // whenever it is present.\n loadMore={\n cursor === null\n ? undefined\n : {\n hasMore: cursor.next !== null,\n loading: cursor.isLoadingMore,\n onMore: cursor.loadMore,\n }\n }\n // On-demand count (B4.3). `undefined` — not a no-op callback — when\n // the resolved provider implements no `getCount` or has already\n // answered \"this cannot be counted here at all\": that is the prop's\n // own render gate, so an unavailable count renders nothing at all.\n // The answer itself needs no wiring; it writes through to\n // `pagination.total` above.\n onRequestCount={count.available ? count.request : undefined}\n isCountingRows={count.isLoading}\n columns={columns.visible}\n isLoading={query.isLoading}\n error={query.error}\n onRetry={query.refetch}\n createHref={route && createAvailable && createPage ? routing.createHref : undefined}\n {...rowProps}\n {...(rowsView === undefined ? {} : { rowsView })}\n selectable={tableView && !readOnly}\n rowActions={!readOnly}\n selectedIds={selection.ids}\n onSelectionChange={selection.set}\n isFiltered={filters.isFiltered}\n onClearFilter={filters.clearAll}\n // Undefined for every caller that doesn't override it, which is\n // what keeps the standard empty-state panel the default.\n emptyState={emptyState}\n sort={sorting.value ?? []}\n requiredColumns={columns.required}\n resetLayout={columns.resetLayout}\n // Header-menu «hide» — no-ops on a required column.\n onHideColumn={columns.hide}\n // The 3-click toggle (new field → asc → desc → null) plus the\n // header menu's explicit-direction path.\n onSort={sorting.toggle}\n renderCell={renderCell}\n />\n );\n}\n\nexport const ListBody: () => ReactElement | null = listPiece('ListBody', ListBodyView);\n","import { createContext, useContext } from 'react';\n\n/**\n * Set by the record route around the screen it renders: the next `<RecordScreen>` below it is a\n * route screen. That screen claims it (its descendants see `false`), so a screen nested inside\n * it — a dialog, a popover — is not one. Internal.\n */\nexport const RouteScreenClaimContext = createContext(false);\n\n/** Whether the `<RecordScreen>` around the caller is the route's own screen. Internal. */\nexport const RouteScreenContext = createContext(false);\n\n/**\n * Set by a quick entry around the screen it renders: the next `<RecordScreen>` below it is the\n * entry's own (it reads the entry's `route`, and the host draws its title). That screen claims it,\n * so a screen nested inside it is not one. Internal.\n */\nexport const QuickScreenClaimContext = createContext(false);\n\n/** Whether the screen around the caller is a route screen (`state: 'url'` is honoured there). */\nexport function useIsRouteScreen(): boolean {\n return useContext(RouteScreenContext);\n}\n","'use client';\nimport {\n type ScreenOpenState,\n useOptionalRecordFrame,\n useOptionalRouterAdapter,\n useSearchParamsWriter,\n} from '@burojs/react';\nimport { useCallback, useMemo, useState } from 'react';\nimport { useIsRouteScreen } from '../record/route-screen-context.js';\n\nconst CLOSED: ScreenOpenState = Object.freeze({\n containers: Object.freeze({}),\n collapsed: Object.freeze([]),\n});\n\n/**\n * A record screen's open panels (P1b+P1c decision 10). Called by\n * `<RecordScreen>` and the page host above their screen state, so it needs no\n * compiled screen: the state is held in memory, and on a route screen (the\n * caller's claim, `isRouteScreen`) in show and edit under a router every\n * search parameter is overlaid as `containers[param] = value`. Off a route\n * screen — a quick entry, a dialog, any screen rendered beside the page's own —\n * the page's query is not read (P3-35). A keyed tabs\n * node's compiled id is its key, and the planner ignores an entry that names\n * no container or an absent panel, so a list-state parameter, an old `?tab=`\n * or a denied `?sections=secret` falls back to the first permitted panel.\n * Because the URL is read on every render, Back and Forward re-plan.\n */\nexport function useTabsUrlState(\n mode: 'show' | 'edit' | 'create',\n isRouteScreen: boolean,\n): {\n readonly open: ScreenOpenState;\n readonly onOpenChange: (next: ScreenOpenState) => void;\n} {\n const adapter = useOptionalRouterAdapter();\n const [memory, setMemory] = useState<ScreenOpenState>(CLOSED);\n // A create's steps read `containers` as the current step: memory only.\n const params =\n adapter === null || mode === 'create' || !isRouteScreen ? null : adapter.searchParams;\n const search = params?.toString() ?? '';\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the query string, not the params object\n const open = useMemo<ScreenOpenState>(() => {\n if (params === null) return memory;\n const containers: Record<string, string> = { ...memory.containers };\n for (const [name, value] of params) containers[name] = value;\n return Object.freeze({ ...memory, containers: Object.freeze(containers) });\n }, [memory, params === null, search]);\n return { open, onOpenChange: setMemory };\n}\n\n/**\n * How a keyed tabs node writes its panel: `?<tabsKey>=<panelKey>`, pushed in\n * show and replaced in edit (a reveal always replaces), the default panel\n * never written. `null` off a route screen (a `<RecordScreen>` outside its\n * route, a quick entry), without a router adapter and in create: the tabs\n * node then keeps its panel in the screen state and the page's URL is left\n * alone (P3-35).\n */\nexport function useTabsUrlSelect():\n | ((tabsKey: string, panelKey: string, isDefault: boolean, reveal?: boolean) => void)\n | null {\n const frame = useOptionalRecordFrame();\n const adapter = useOptionalRouterAdapter();\n const write = useSearchParamsWriter();\n // A page is a route screen with no record frame (P2 4.6): it writes as a show does.\n const routeScreen = useIsRouteScreen();\n const mode = frame?.mode ?? (routeScreen ? 'show' : undefined);\n const select = useCallback(\n (tabsKey: string, panelKey: string, isDefault: boolean, reveal = false) =>\n write(\n (params) => {\n if (isDefault) params.delete(tabsKey);\n else params.set(tabsKey, panelKey);\n },\n { history: mode === 'show' && !reveal ? 'push' : 'replace' },\n ),\n [write, mode],\n );\n if (!routeScreen || adapter === null || mode === 'create') return null;\n return select;\n}\n","'use client';\nimport { formatEntityRef, type PlanNode } from '@burojs/core';\nimport {\n type FrameStep,\n type FrameTab,\n type PanelFrameViewProps,\n type StepsFrameViewProps,\n type TabsFrameViewProps,\n useFrameImplementations,\n useFrameT,\n useOptionalT,\n useScreenState,\n} from '@burojs/react';\nimport {\n type ComponentType,\n type ReactElement,\n type ReactNode,\n Suspense,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport { nodeAttributes, nodeInfo, PendingSkeleton, useNodeText } from '../screen/node-parts.js';\nimport { useReveal, useScreenTree } from '../screen/tree-context.js';\nimport { useTabsUrlSelect } from '../screen/use-tabs-url-state.js';\nimport { BuroPanelFrame, BuroStepsFrame, BuroTabsFrame } from './builtin-nodes.js';\nimport { resolveFrameView } from './resolve.js';\n\n/** How a host renders a node's children (the node dispatch lives in `screen/nodes.tsx`). */\nexport type RenderChildren = (nodes: readonly PlanNode[]) => ReactNode;\n\nconst BUILTIN_NODE_VIEWS = {\n panel: BuroPanelFrame,\n tabs: BuroTabsFrame,\n steps: BuroStepsFrame,\n} as const;\n\n/**\n * The view a node host draws and its frame id: the node's effective frame (its own ← the app's\n * ← `buro:<kind>`, resolved by the compiler) looked up like a record frame; `builtin` when the\n * view is the kit's own (it then takes the kit's extensions). A panel drawn by its steps\n * container is always the built-in one.\n */\nfunction useNodeView<K extends keyof typeof BUILTIN_NODE_VIEWS>(\n node: PlanNode,\n kind: K,\n containerDrawn = false,\n): {\n // biome-ignore lint/suspicious/noExplicitAny: a node view of the resolved kind\n readonly view: ComponentType<any>;\n readonly id: string;\n readonly builtin: boolean;\n} {\n const { compiled } = useScreenTree();\n const catalog = useFrameImplementations();\n const ref = containerDrawn ? undefined : compiled.nodes[node.index]?.frame;\n return useMemo(() => {\n if (ref === undefined)\n return { view: BUILTIN_NODE_VIEWS[kind], id: `buro:${kind}`, builtin: true };\n const resolved = resolveFrameView(ref, catalog, kind);\n return {\n view: resolved.view,\n id: formatEntityRef(ref),\n builtin: resolved.view === BUILTIN_NODE_VIEWS[kind],\n };\n }, [ref, catalog, kind]);\n}\n\n/**\n * The framework's body element of a panel or a step: in a form (edit, create, inside the\n * `<form>`) a `fieldset` labelled by the title, elsewhere a `div`; the region names are\n * unchanged (P6-17).\n */\nfunction PanelBody({\n id,\n region,\n form,\n labelledBy,\n children,\n}: {\n readonly id?: string;\n readonly region: 'panel-body' | 'step-panel';\n readonly form: boolean;\n readonly labelledBy: string | undefined;\n readonly children: ReactNode;\n}): ReactElement {\n if (form)\n return (\n <fieldset\n {...(id === undefined ? {} : { id })}\n data-buro-region={region}\n {...(labelledBy === undefined ? {} : { 'aria-labelledby': labelledBy })}\n >\n {children}\n </fieldset>\n );\n return (\n <div {...(id === undefined ? {} : { id })} data-buro-region={region}>\n {children}\n </div>\n );\n}\n\n/**\n * A panel: the framework owns `open` (the plan's, toggled through the screen state), the\n * reveal (it calls the same `onToggle` the view is given), the error count and the body\n * element; the view draws the rest.\n */\nexport function PanelHost({\n node,\n region = 'panel-body',\n renderChildren,\n}: {\n readonly node: PlanNode;\n readonly region?: 'panel-body' | 'step-panel';\n readonly renderChildren: RenderChildren;\n}): ReactElement {\n const { compiled, controller, mode, form } = useScreenTree();\n const state = useScreenState();\n const text = useNodeText();\n const options = compiled.nodes[node.index]!.options;\n // A humanized slot's default (the key, humanized) captions a tab or a step; a standalone panel\n // draws a heading for it only when the bundle has an entry, never the humanized key itself.\n const title =\n options.title?.humanized === true\n ? text({ ...options.title, default: '' }) || undefined\n : text(options.title);\n const description = text(options.description);\n const collapsible = options.collapse !== undefined;\n // A collapsible panel's `open` is the plan's; the others are always drawn.\n const open = !collapsible || node.open !== false;\n const onToggle = useCallback(\n (next: boolean) => {\n if (collapsible) state?.setCollapsed(node.id, !next);\n },\n [collapsible, state, node.id],\n );\n useReveal(node.id, () => {\n if (collapsible && node.open === false) onToggle(true);\n });\n const errorCount = node.key === undefined ? 0 : controller.errorsIn(node.key);\n const bodyId = `panel-body:${node.id}`;\n const titleId = `panel-title:${node.id}`;\n const { view: View, id, builtin } = useNodeView(node, 'panel', region === 'step-panel');\n const t = useFrameT(id);\n const body =\n node.state === 'pending' ? (\n <PendingSkeleton />\n ) : open ? (\n <PanelBody\n id={bodyId}\n region={region}\n form={form}\n labelledBy={title === undefined ? undefined : titleId}\n >\n {renderChildren(node.children)}\n </PanelBody>\n ) : null;\n const props: PanelFrameViewProps & { stepPanel?: boolean } = {\n body,\n ...(title === undefined ? {} : { title }),\n ...(description === undefined ? {} : { description }),\n ...(options.tone === undefined ? {} : { tone: options.tone }),\n ...(options.icon === undefined ? {} : { icon: options.icon }),\n collapsible,\n open,\n onToggle,\n errorCount,\n mode,\n titleId,\n bodyId,\n info: nodeInfo(node, title ?? node.key ?? ''),\n nodeAttributes: nodeAttributes(node, node.kind, options.tone),\n t,\n ...(builtin && region === 'step-panel' ? { stepPanel: true } : {}),\n };\n return (\n <Suspense fallback={<PendingSkeleton />}>\n <View {...props} />\n </Suspense>\n );\n}\n\n/** The Radix value of a tab: its panel key, or its compiled id when it has none. */\nconst panelValue = (panel: PlanNode): string => panel.key ?? panel.id;\n\n/** A tab's reveal: selects its panel when it holds the first failing field. */\nfunction TabReveal({\n panel,\n select,\n}: {\n readonly panel: PlanNode;\n readonly select: (panel: PlanNode, reveal: boolean) => void;\n}): null {\n useReveal(panel.id, () => {\n if (panel.open !== true) select(panel, true);\n });\n return null;\n}\n\n/**\n * A tabs node: the framework owns which tab is active (the URL's or the screen state's), the\n * reveal, the error counts and demand (only the active tab's panel is rendered); the view draws\n * the strip.\n */\nexport function TabsHost({\n node,\n renderChildren,\n}: {\n readonly node: PlanNode;\n readonly renderChildren: RenderChildren;\n}): ReactElement {\n const { compiled, controller } = useScreenTree();\n const state = useScreenState();\n const text = useNodeText();\n const panels = node.children.filter((child) => child.state !== 'absent');\n const open = panels.find((child) => child.open === true) ?? panels[0];\n const urlSelect = useTabsUrlSelect();\n // A keyed tabs node in a routed record keeps its panel in the URL (decision 10); the\n // others, and every tabs node without a router, in the screen state.\n const select = (panel: PlanNode, reveal: boolean) => {\n if (urlSelect !== null && node.key !== undefined && panel.key !== undefined)\n urlSelect(node.key, panel.key, panel === panels[0], reveal);\n else state?.openPanel(node.id, panelValue(panel));\n };\n const onSelect = (key: string) => {\n const panel = panels.find((candidate) => panelValue(candidate) === key);\n if (panel !== undefined) select(panel, false);\n };\n const titleOf = (panel: PlanNode) => text(compiled.nodes[panel.index]!.options.title) ?? panel.id;\n const tabs: FrameTab[] = panels.map((panel) => ({\n key: panelValue(panel),\n title: titleOf(panel),\n errorCount: panel.key === undefined ? 0 : controller.errorsIn(panel.key),\n panel:\n panels.length === 1 || panel.open === true ? (\n // biome-ignore lint/complexity/noUselessFragments: a view receives an element, not a node list\n <>{renderChildren(panel.children)}</>\n ) : null,\n }));\n const { view: View, id } = useNodeView(node, 'tabs');\n const t = useFrameT(id);\n const props: TabsFrameViewProps = {\n tabs,\n active: open === undefined ? '' : panelValue(open),\n onSelect,\n info: nodeInfo(node, node.key ?? ''),\n nodeAttributes: nodeAttributes(node),\n t,\n };\n return (\n <>\n {panels.length > 1\n ? panels.map((panel) => <TabReveal key={panel.id} panel={panel} select={select} />)\n : null}\n <Suspense fallback={<PendingSkeleton />}>\n <View {...props} />\n </Suspense>\n </>\n );\n}\n\n/**\n * A steps node. In a create wizard (a create with a steps root, P1b+P1c decision 11) the\n * framework owns the current step, the \"Step i of n\" live region and the heading focus on a\n * step change (through `headingRef`); `next()` validates the step. Outside a wizard every step is\n * a panel, drawn whole.\n */\nexport function StepsHost({\n node,\n renderChildren,\n}: {\n readonly node: PlanNode;\n readonly renderChildren: RenderChildren;\n}): ReactElement {\n const { mode, controller } = useScreenTree();\n if (mode === 'create' && controller.steps !== null)\n return <WizardHost node={node} renderChildren={renderChildren} />;\n return <StackedStepsHost node={node} renderChildren={renderChildren} />;\n}\n\nfunction StackedStepsHost({\n node,\n renderChildren,\n}: {\n readonly node: PlanNode;\n readonly renderChildren: RenderChildren;\n}): ReactElement {\n const { compiled, controller } = useScreenTree();\n const text = useNodeText();\n const { view: View, id } = useNodeView(node, 'steps');\n const t = useFrameT(id);\n const panels = node.children.filter((child) => child.state !== 'absent');\n const steps: FrameStep[] = panels.map((panel) => {\n const options = compiled.nodes[panel.index]!.options;\n const title = text(options.title) ?? panel.id;\n const description = text(options.description);\n return {\n key: panel.key ?? panel.id,\n title,\n errorCount: panel.key === undefined ? 0 : controller.errorsIn(panel.key),\n state: 'reachable',\n panel: (\n <PanelHost\n key={`${panel.index}:${panel.id}`}\n node={panel}\n region=\"step-panel\"\n renderChildren={renderChildren}\n />\n ),\n ...(description === undefined ? {} : { description }),\n titleId: `panel-title:${panel.id}`,\n info: nodeInfo(panel, title),\n nodeAttributes: nodeAttributes(panel, 'panel', options.tone),\n };\n });\n const props: StepsFrameViewProps = {\n wizard: false,\n steps,\n current: steps[0]?.key ?? '',\n goTo: NOTHING,\n back: NOTHING,\n next: NOTHING,\n headingRef: NO_HEADING,\n info: nodeInfo(node, node.key ?? ''),\n nodeAttributes: nodeAttributes(node),\n t,\n };\n return (\n <Suspense fallback={<PendingSkeleton />}>\n <View {...props} />\n </Suspense>\n );\n}\n\nconst NOTHING = () => undefined;\nconst NO_HEADING = { current: null };\n\nfunction WizardHost({\n node,\n renderChildren,\n}: {\n readonly node: PlanNode;\n readonly renderChildren: RenderChildren;\n}): ReactElement {\n const { compiled, controller, form } = useScreenTree();\n const steps = controller.steps!;\n const ft = useOptionalT();\n const text = useNodeText();\n const { view: View, id, builtin } = useNodeView(node, 'steps');\n const t = useFrameT(id);\n const panels = node.children.filter((child) => child.state !== 'absent');\n const current = panels.find((child) => child.open === true) ?? panels[0];\n const index = current === undefined ? -1 : panels.indexOf(current);\n const idOf = (panel: PlanNode) => panel.key ?? panel.id;\n const titleOf = (panel: PlanNode) => text(compiled.nodes[panel.index]!.options.title) ?? panel.id;\n const headingRef = useRef<HTMLElement | null>(null);\n const shown = useRef<string | undefined>(undefined);\n const currentId = current === undefined ? undefined : idOf(current);\n // Focus moves to the step heading when the step changes (not on the first render).\n useEffect(() => {\n if (shown.current !== undefined && shown.current !== currentId) headingRef.current?.focus();\n shown.current = currentId;\n }, [currentId]);\n const next = useCallback(() => void steps.next(), [steps]);\n const frameSteps: FrameStep[] = panels.map((panel) => {\n const options = compiled.nodes[panel.index]!.options;\n const key = idOf(panel);\n const title = titleOf(panel);\n const description = text(options.description);\n const titleId = `panel-title:${panel.id}`;\n const isCurrent = panel === current;\n return {\n key,\n title,\n errorCount: panel.key === undefined ? 0 : controller.errorsIn(panel.key),\n state: isCurrent ? 'current' : steps.completed.includes(key) ? 'complete' : 'locked',\n panel: !isCurrent ? null : panel.state === 'pending' ? (\n <PendingSkeleton />\n ) : (\n <PanelBody region=\"step-panel\" form={form} labelledBy={titleId}>\n {renderChildren(panel.children)}\n </PanelBody>\n ),\n ...(description === undefined ? {} : { description }),\n titleId,\n info: nodeInfo(panel, title),\n nodeAttributes: nodeAttributes(panel, 'panel', options.tone),\n };\n });\n if (current === undefined) return <div {...nodeAttributes(node)} />;\n const props: StepsFrameViewProps = {\n wizard: true,\n steps: frameSteps,\n current: idOf(current),\n goTo: steps.goTo,\n back: steps.back,\n next,\n headingRef,\n info: nodeInfo(node, node.key ?? ''),\n nodeAttributes: nodeAttributes(node),\n t,\n };\n const liveRegion = (\n <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {ft('steps.current', {\n params: { index: index + 1, count: panels.length },\n defaultValue: 'Step {{index}} of {{count}}',\n })}\n {`: ${titleOf(current)}`}\n </p>\n );\n // The built-in view draws the live region inside its root; a custom view gets it beside it.\n if (builtin) return <BuroStepsFrame {...props} liveRegion={liveRegion} />;\n return (\n <>\n {liveRegion}\n <Suspense fallback={<PendingSkeleton />}>\n <View {...props} />\n </Suspense>\n </>\n );\n}\n","'use client';\nimport type { PlanNode } from '@burojs/core';\nimport { useOptionalT } from '@burojs/react';\nimport type { ReactElement, ReactNode } from 'react';\nimport { PlaceNode } from '../blocks/place-node.js';\nimport { PanelHost, StepsHost, TabsHost } from '../frames/node-host.js';\nimport { Button } from '../primitives/button.js';\nimport { FieldLeaf } from './field-leaf.js';\nimport { nodeAttributes, PendingSkeleton } from './node-parts.js';\nimport { useScreenTree } from './tree-context.js';\n\n/** A failed node: the reason and a Retry that refetches only its failed sources. */\nfunction FailedNode({ node }: { readonly node: PlanNode }): ReactElement {\n const { controller } = useScreenTree();\n const t = useOptionalT();\n return (\n <div\n {...nodeAttributes(node)}\n role=\"alert\"\n className=\"flex flex-wrap items-center gap-2 rounded-md border border-dashed px-3 py-2 text-sm text-muted-foreground\"\n >\n <span>{t('screen.failed', { defaultValue: 'This section could not be loaded.' })}</span>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => controller.retry(node.failedOn)}\n >\n {t('actions.retry', { defaultValue: 'Retry' })}\n </Button>\n </div>\n );\n}\n\n/** Whether every source a node failed on is its own field's `meta:<field>` outcome. */\nfunction failedOnlyOnMeta(node: PlanNode): boolean {\n return node.failedOn.length > 0 && node.failedOn.every((name) => name.startsWith('meta:'));\n}\n\n/** The children of a container, each through {@link ScreenNodeView}. */\nfunction renderChildren(nodes: readonly PlanNode[]): ReactNode {\n return nodes.map((child) => <ScreenNodeView key={`${child.index}:${child.id}`} node={child} />);\n}\n\n/** Whether a node draws anything: not absent, and not a field the tree hides. */\nfunction drawn(node: PlanNode, hiddenFields: ReadonlySet<string> | undefined): boolean {\n if (node.state === 'absent') return false;\n return !(node.kind === 'field' && node.field !== undefined && hiddenFields?.has(node.field));\n}\n\n/**\n * A section container's children: each run of consecutive field nodes inside one implicit\n * `data-buro-group=\"fields\"` stack, every other node as itself. The group exists only in the DOM\n * (never in the screen tree), so the styling contract can space blocks apart with\n * `--buro-section-gap` while fields stay at `--buro-node-gap`.\n *\n * The runs are cut from the static node list, never from what is drawn right now: a `when` reading\n * the form's values toggles a neighbour while the user types, and a field moved to another group\n * (or a group re-keyed) would remount its input mid-keystroke. A run with no field drawn emits\n * nothing, so it leaves no gap; an absent field inside a drawn run renders nothing in its place.\n */\nfunction SectionChildren({ nodes }: { readonly nodes: readonly PlanNode[] }): ReactNode {\n const { hiddenFields } = useScreenTree();\n const out: ReactNode[] = [];\n let run: PlanNode[] = [];\n const flush = () => {\n if (run.some((node) => drawn(node, hiddenFields)))\n out.push(\n <div key={`group:${run[0]!.index}`} data-buro-node=\"stack\" data-buro-group=\"fields\">\n {renderChildren(run)}\n </div>,\n );\n run = [];\n };\n for (const node of nodes) {\n if (node.kind === 'field') {\n run.push(node);\n continue;\n }\n flush();\n out.push(<ScreenNodeView key={`${node.index}:${node.id}`} node={node} />);\n }\n flush();\n return out;\n}\n\n/**\n * The children of a section container (a slot's root, a panel, a tab, a step): fields grouped,\n * see {@link SectionChildren}. Authored `row`, `grid` and `stack` lay their children out\n * themselves and use {@link renderChildren}.\n */\nexport function renderSection(nodes: readonly PlanNode[]): ReactNode {\n return <SectionChildren nodes={nodes} />;\n}\n\nfunction Layout({ node }: { readonly node: PlanNode }): ReactElement {\n return <div {...nodeAttributes(node)}>{renderChildren(node.children)}</div>;\n}\n\n/** A field leaf, absent when the tree hides its field (a peek's filter). */\nfunction FieldNode({ node }: { readonly node: PlanNode }): ReactNode {\n const { hiddenFields } = useScreenTree();\n if (node.field !== undefined && hiddenFields?.has(node.field) === true) return null;\n return <FieldLeaf node={node} />;\n}\n\n/** One plan node: nothing when absent, its failed chrome when failed, else its kind's component. */\nexport function ScreenNodeView({ node }: { readonly node: PlanNode }): ReactNode {\n if (node.state === 'absent') return null;\n // A placement draws its own chrome, failed and pending included (spec 8.1).\n if (node.kind === 'place') return <PlaceNode node={node} />;\n // A field whose only failure is its own `meta` (a schema refused it, P7 3.3) is not a source to\n // retry: its leaf draws the labelled misconfigured control and says why in development.\n if (node.state === 'failed' && !(node.kind === 'field' && failedOnlyOnMeta(node)))\n return <FailedNode node={node} />;\n switch (node.kind) {\n case 'field':\n if (node.state === 'pending')\n return (\n <div {...nodeAttributes(node)}>\n <PendingSkeleton />\n </div>\n );\n return <FieldNode node={node} />;\n case 'panel':\n return <PanelHost node={node} renderChildren={renderSection} />;\n case 'tabs':\n return <TabsHost node={node} renderChildren={renderSection} />;\n case 'steps':\n return <StepsHost node={node} renderChildren={renderSection} />;\n case 'row':\n case 'grid':\n case 'stack':\n return <Layout node={node} />;\n default: {\n // Exhaustive: a node kind the dispatch does not know fails the typecheck here.\n const unknown: never = node.kind;\n return unknown;\n }\n }\n}\n","'use client';\nimport { type CompiledScreen, FORM_SLOT, type ScreenMode } from '@burojs/core';\nimport type { FormController, PageScreen } from '@burojs/react';\nimport { type ReactElement, type ReactNode, useMemo } from 'react';\nimport { renderSection } from './nodes.js';\nimport {\n type LeafIdScheme,\n type RenderFieldOverrides,\n ScreenTreeContext,\n type ScreenTreeValue,\n} from './tree-context.js';\n\nexport interface ScreenTreeProps {\n /**\n * Where the tree is drawn: `record` a record screen's slot (`slot`), `form-body` and\n * `page-body` the body. A record host wraps the tree in its own slot wrapper; for `form-body`\n * the tree renders the region element itself.\n */\n readonly region: 'record' | 'form-body' | 'page-body';\n /** On a record screen, the frame slot to draw (P6 3.3); `body` when omitted. */\n readonly slot?: string;\n /**\n * The resource's canonical name, or a resource-less form's\n * `i18nPrefix ?? 'form'`.\n */\n readonly resource: string;\n readonly mode: ScreenMode;\n /** The compiled screen the controller plans (`controller.screen`); nothing while `null`. */\n readonly compiled: CompiledScreen | null;\n /** The record or form controller that plans the screen; a page passes `page` instead. */\n readonly controller?: FormController;\n /**\n * A custom page's body (`usePageScreen`): its plan, Retry and placements. A page body has no\n * field leaves (refused when the page is parsed), so no field binding is ever asked of it.\n */\n readonly page?: PageScreen;\n /** Default `'record'`. */\n readonly leafIds?: LeafIdScheme;\n readonly renderField?: RenderFieldOverrides;\n /** A whole-form lock: every input renders disabled. */\n readonly disabled?: boolean;\n /** On the `form-body` region element. */\n readonly className?: string;\n /** Fields whose leaves render absent (a peek body's filter). */\n readonly hiddenFields?: ReadonlySet<string>;\n}\n\n/**\n * Draws one slot of a planned screen (P1b+P1c section 9): the slot's nodes in\n * a root stack, each node carrying the `data-buro-*` attributes the styling\n * contract keys off. Every node reads its static options from the compiled\n * screen by its plan index; nothing is compiled or planned here.\n */\nexport function ScreenTree({\n region,\n slot = FORM_SLOT,\n resource,\n mode,\n compiled,\n controller: own,\n page,\n leafIds = 'record',\n renderField,\n disabled,\n className,\n hiddenFields,\n}: ScreenTreeProps): ReactElement | null {\n const controller = useMemo(() => own ?? pageHost(page), [own, page]);\n const form =\n mode !== 'show' && (region === 'form-body' || (region === 'record' && slot === FORM_SLOT));\n const value = useMemo<ScreenTreeValue | null>(\n () =>\n compiled === null || controller === undefined\n ? null\n : {\n resource,\n mode,\n compiled,\n controller,\n region,\n form,\n leafIds,\n ...(renderField === undefined ? {} : { renderField }),\n ...(disabled === undefined ? {} : { disabled }),\n ...(hiddenFields === undefined ? {} : { hiddenFields }),\n },\n [\n resource,\n mode,\n compiled,\n controller,\n region,\n form,\n leafIds,\n renderField,\n disabled,\n hiddenFields,\n ],\n );\n const plan = controller?.plan ?? null;\n if (value === null || plan === null) return null;\n const roots = plan.slots[region === 'record' ? slot : FORM_SLOT] ?? [];\n if (roots.length === 0 && region !== 'form-body') return null;\n // A record's display slot: the stack is the slot's wrapper (`data-buro-slot`, no region, no\n // container type; P6-70). The body's wrapper is the record host's `record-body` element.\n const displaySlot = region === 'record' && slot !== FORM_SLOT;\n const stack = (\n <div data-buro-node=\"stack\" {...(displaySlot ? { 'data-buro-slot': slot } : {})}>\n {renderSection(roots)}\n </div>\n );\n return (\n <ScreenTreeContext.Provider value={value}>\n {region === 'form-body' ? (\n <div data-buro-region=\"form-body\" className={className}>\n {stack}\n </div>\n ) : (\n stack\n )}\n </ScreenTreeContext.Provider>\n );\n}\n\n/**\n * The tree context of a page's screen for what is drawn from its plan outside a slot's stack: the\n * route list's item block, which the rows draw one by one (P7-36), needs the screen its node was\n * planned in. Nothing is drawn here.\n */\nexport function ScreenTreeScope({\n resource,\n mode,\n compiled,\n page,\n children,\n}: {\n readonly resource: string;\n readonly mode: ScreenMode;\n readonly compiled: CompiledScreen;\n readonly page: PageScreen;\n readonly children: ReactNode;\n}): ReactElement {\n const controller = useMemo(() => pageHost(page), [page]);\n const value = useMemo<ScreenTreeValue>(\n () => ({\n resource,\n mode,\n compiled,\n controller: controller!,\n region: 'record',\n form: false,\n leafIds: 'record',\n }),\n [resource, mode, compiled, controller],\n );\n return <ScreenTreeContext.Provider value={value}>{children}</ScreenTreeContext.Provider>;\n}\n\n/**\n * The part of a controller the non-field nodes read, over a page's screen: its plan, Retry and\n * placements; a page has no field errors, steps or reveals.\n */\nfunction pageHost(page: PageScreen | undefined): FormController | undefined {\n if (page === undefined) return undefined;\n return {\n plan: page.plan,\n retry: page.retry,\n placement: page.placement,\n errorsIn: () => 0,\n steps: null,\n registerReveal: () => () => undefined,\n } as Partial<FormController> as FormController;\n}\n","'use client';\nimport type {\n DraftOption,\n Check,\n CheckOutcome,\n CheckSurface,\n FormBody,\n ResourceFieldMap,\n StandardSchemaV1,\n ValidationIssues,\n} from '@burojs/core';\nimport {\n ScreenStateProvider,\n resolveValidationMessage,\n useFormController,\n useOptionalT,\n type CheckGateState,\n type FieldBinding,\n type FormValues,\n type ResolvedIssue,\n type UseFormControllerFormOptions,\n} from '@burojs/react';\nimport {\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { CheckConfirmDialog } from '../checks/check-confirm-dialog.js';\nimport { Button } from '../primitives/button.js';\nimport { ScreenTree } from '../screen/screen-tree.js';\n\n/**\n * A footer slot may need the controller's submit-gate to build its own submit\n * control — see {@link DeclarativeFormSlots.footer}.\n */\nexport interface DeclarativeFormFooterCtx {\n /**\n * `form.canSubmit` already ANDed with the whole-form `disabled` lock — a\n * footer never has to re-derive that combination itself.\n */\n readonly canSubmit: boolean;\n}\n\n/**\n * Slot overrides for the managed layout. `footer` replaces the default\n * submit-button row. The index signature keeps the shape open for future\n * per-section slots (design doc §4) without a breaking change to this\n * interface later.\n */\nexport interface DeclarativeFormSlots {\n /**\n * A plain `ReactNode` replaces the default footer outright, same as\n * before this widening (e.g. a footer with no submit button at all). The\n * function form exists for the common case a plain node cannot serve: a\n * CUSTOM footer (e.g. Cancel + Submit side by side) that still needs the\n * framework's own disabled-while-invalid gate — `slots` is built by the\n * CALLER before the form controller has run, so a plain node has no way\n * to read `form.canSubmit`. Called once per render with `{ canSubmit }`\n * (already ANDed with the whole-form `disabled` lock) instead of forcing\n * every such caller to either reimplement the gate or stand up a second,\n * parallel controller just to read it.\n */\n readonly footer?: ReactNode | ((ctx: DeclarativeFormFooterCtx) => ReactNode);\n readonly [slot: string]: ReactNode | ((ctx: DeclarativeFormFooterCtx) => ReactNode) | undefined;\n}\n\nexport interface DeclarativeFormProps<F extends ResourceFieldMap = ResourceFieldMap> {\n /** The same field-def map shape `defineResource`'s `f` builder produces. */\n readonly fields: F;\n /**\n * The form's tree (`(l) => [...]`, the same builder a resource's\n * `views.<mode>.body` uses); absent, every field in one column, in\n * declaration order. A field under a `when` that does not hold is inactive:\n * it is not drawn and not submitted.\n */\n readonly body?: FormBody<F>;\n /** The draft identity; `draft` without it is a development error. */\n readonly formId?: string;\n readonly draft?: DraftOption;\n /** Controlled values: presence (not truthiness) selects controlled mode. */\n readonly value?: FormValues;\n /** Uncontrolled seed. Ignored once `value` is supplied. */\n readonly defaults?: FormValues;\n readonly onChange?: (values: FormValues) => void;\n readonly schema?: StandardSchemaV1;\n /** Cross-field validation; may return warnings as well as errors. */\n readonly validate?: UseFormControllerFormOptions['validate'];\n /**\n * Conditional checks for this form, as a plain list (a resource-less form has\n * no `app.checkSource` entry); a confirmable warning asks through the\n * mounted `<CheckConfirmDialog>`.\n */\n readonly checks?: readonly Check[];\n /** The check surface; default `'create'`. */\n readonly surface?: CheckSurface;\n /** Receives the payload: the active declared fields only. */\n readonly onSubmit?: (values: FormValues) => unknown | Promise<unknown>;\n /**\n * Text slots and the doc address key as `resources.<i18nPrefix>.…`; the\n * leaf ids are `<i18nPrefix>:field:<name>:hint` / `:info`. Default `'form'`.\n */\n readonly i18nPrefix?: string;\n /**\n * Whole-form lock: every field renders disabled, OR-ed with that field's\n * own resolved `disabled`. Distinct from a read-only VIEW\n * (`<DeclarativeDisplay>`), which renders displays instead of inputs.\n */\n readonly disabled?: boolean;\n /**\n * Per-field render override — swap ONE field's node without abandoning\n * the managed leaf (label, message slot, hint): receives the binding and\n * the default input node, so an override can wrap rather than reimplement.\n */\n readonly renderField?: Record<\n string,\n (binding: FieldBinding, defaultNode: ReactNode) => ReactNode\n >;\n readonly slots?: DeclarativeFormSlots;\n /** The submit caption; defaults to the framework bundle's `actions.save` (\"Save\"). */\n readonly submitLabel?: string;\n /**\n * Class applied to the `<form>` element itself — e.g. `flex flex-col` for a\n * dialog taller than the viewport, so the body can scroll between a fixed\n * header and footer.\n */\n readonly className?: string;\n /**\n * Class applied to the fields region (`[data-buro-region=\"form-body\"]`), the\n * scroll region of a form too tall to fit (`flex-1 overflow-y-auto min-h-0`).\n */\n readonly bodyClassName?: string;\n}\n\n/**\n * `t(key)` or `fallback` on a miss: with a provider mounted, `t()` returns the\n * raw key on a miss and never consults a `defaultValue`.\n */\nfunction translateOrFallback(\n t: ReturnType<typeof useOptionalT>,\n key: string,\n fallback: string,\n): string {\n const translated = t(key);\n return translated === key ? fallback : translated;\n}\n\n/**\n * Localize one resolved issue the same way across the field slots and the\n * form-level summary, through `resolveValidationMessage` (`@burojs/react`):\n * the per-field `resources.<i18nPrefix>.fields.<f>.validation.<code>` first,\n * then a semantic key, the issue's own `default`, the common\n * `validation.<code>`, and `errors.failed`. Resolved at render, so a locale\n * switch reaches the text.\n */\nfunction issueText(\n issue: ResolvedIssue,\n t: ReturnType<typeof useOptionalT>,\n i18nPrefix: string,\n): string {\n return resolveValidationMessage(\n {\n code: issue.code ?? '',\n message: issue.message,\n ...(issue.params === undefined ? {} : { params: issue.params }),\n },\n {\n t,\n ...(issue.field === '_form'\n ? {}\n : { fieldKey: `resources.${i18nPrefix}.fields.${issue.field}` }),\n },\n );\n}\n\nconst EMPTY_ISSUES: ValidationIssues = Object.freeze([]);\n\n/**\n * A minimal confirm gate driven by an EXPLICIT `CheckOutcome`, not a\n * `resource` string — `useCheckGate` (`@burojs/react`) re-derives its check\n * list via `app.checkSource.checks(resource)`, which has nothing to key off\n * for a resource-less declarative form whose checks arrive as a plain\n * `props.checks` array. The controller's submit already evaluates those\n * checks once; this hook only owns the DIALOG'S open/decide state, fed\n * through the controller's `onConfirmChecks` option — so checks are\n * evaluated exactly once per submit, not re-derived here.\n *\n * Renders through the SAME `<CheckConfirmDialog>` (Task 7) `<RecordScreen>`\n * uses, off a `CheckGateState`-shaped object built by hand. `blockers` is\n * always empty here: a `severity: 'error'` check already stops the submit\n * before `onConfirmChecks` is ever called (it renders inline instead), so\n * this gate only ever shows\n * `confirmable` issues, and `busy` stays `false` — unlike `useCheckGate`,\n * there is no async re-evaluation while the dialog is open, just a decision.\n */\nfunction useDeclarativeCheckGate(): {\n readonly state: CheckGateState;\n readonly confirmChecks: (outcome: CheckOutcome) => Promise<'proceed' | 'cancel'>;\n} {\n const [open, setOpen] = useState(false);\n const [confirmable, setConfirmable] = useState<ValidationIssues>(EMPTY_ISSUES);\n const decide = useRef<((decision: 'proceed' | 'cancel') => void) | null>(null);\n\n // Unmount mid-decision must resolve the pending promise rather than let it\n // dangle — same hazard `useCheckGate` itself guards against.\n useEffect(() => {\n return () => {\n decide.current?.('cancel');\n decide.current = null;\n };\n }, []);\n\n const close = useCallback((decision: 'proceed' | 'cancel') => {\n setOpen(false);\n setConfirmable(EMPTY_ISSUES);\n const resolve = decide.current;\n decide.current = null;\n resolve?.(decision);\n }, []);\n\n const confirmChecks = useCallback((outcome: CheckOutcome): Promise<'proceed' | 'cancel'> => {\n // Self-contained re-entrancy guard: a second `confirmChecks()` call while\n // one is still pending must not silently overwrite `decide.current` and\n // strand the FIRST caller's promise forever. Today the controller's own\n // submit latch makes a second call unreachable (a submit refuses to\n // re-enter while one is in flight), but\n // this hook has no business depending on another package's internal\n // guard to stay correct — resolve the superseded decision as 'cancel'\n // (same \"a broken/interrupted gate must not silently proceed\" contract\n // `useCheckGate`'s own `run()` uses) before starting the new one.\n decide.current?.('cancel');\n decide.current = null;\n setConfirmable(outcome.confirmable);\n setOpen(true);\n return new Promise<'proceed' | 'cancel'>((resolve) => {\n decide.current = resolve;\n });\n }, []);\n\n return {\n state: {\n open,\n busy: false,\n header: null,\n blockers: EMPTY_ISSUES,\n confirmable,\n proceed: () => close('proceed'),\n cancel: () => close('cancel'),\n },\n confirmChecks,\n };\n}\n\n/**\n * Batteries-included resource-less form (P1b+P1c decision 21) over\n * `useFormController` and the screen renderer: the form's `body` tree (or one\n * column of every field), each leaf with its label, input, one message slot\n * (error over warning) and hint; a form-level error / warning summary above;\n * the submit footer below. Uncontrolled by default (`defaults` seeds,\n * `onSubmit(payload)` delivers the active declared values); controlled\n * `value` / `onChange` remain available. Submit is disabled on\n * `!form.canSubmit` (errors only — warnings never block) or `disabled`.\n */\nexport function DeclarativeForm<F extends ResourceFieldMap = ResourceFieldMap>(\n props: DeclarativeFormProps<F>,\n): ReactElement {\n return (\n <ScreenStateProvider>\n <DeclarativeFormBody {...(props as DeclarativeFormProps)} />\n </ScreenStateProvider>\n );\n}\n\nfunction DeclarativeFormBody(props: DeclarativeFormProps): ReactElement {\n const gate = useDeclarativeCheckGate();\n const prefix = props.i18nPrefix ?? 'form';\n const form = useFormController({\n fields: props.fields,\n mode: 'create',\n onConfirmChecks: gate.confirmChecks,\n ...(props.body === undefined ? {} : { body: props.body }),\n ...(props.formId === undefined ? {} : { formId: props.formId }),\n ...(props.draft === undefined ? {} : { draft: props.draft }),\n ...(props.value === undefined ? {} : { value: props.value }),\n ...(props.defaults === undefined ? {} : { defaults: props.defaults }),\n ...(props.onChange === undefined ? {} : { onChange: props.onChange }),\n ...(props.i18nPrefix === undefined ? {} : { i18nPrefix: props.i18nPrefix }),\n ...(props.schema === undefined ? {} : { schema: props.schema }),\n ...(props.validate === undefined ? {} : { validate: props.validate }),\n ...(props.checks === undefined ? {} : { checks: props.checks }),\n ...(props.surface === undefined ? {} : { surface: props.surface }),\n ...(props.onSubmit === undefined ? {} : { onSubmit: props.onSubmit }),\n });\n const t = useOptionalT();\n const disabled = props.disabled === true;\n const uid = useId();\n const leafIds = useMemo(() => ({ prefix, inputIds: uid }), [prefix, uid]);\n\n const formErrors = form.errors.filter((issue) => issue.field === '_form');\n // An error check that could not run (P1b+P1c decision 28): its \"could not\n // verify\" reason above, and Retry, which re-runs the check pass.\n const retryableChecks: string[] = [];\n for (const issue of form.checkOutcome?.blockers ?? []) {\n const checkId = issue.params?.checkId;\n if (issue.params?.cause === undefined || typeof checkId !== 'string') continue;\n if (!retryableChecks.includes(checkId)) retryableChecks.push(checkId);\n }\n const formWarnings = form.warnings.filter((issue) => issue.field === '_form');\n // Base testid for the mounted `<CheckConfirmDialog>`: declarative forms are\n // resource-less, so `i18nPrefix` is the stable per-form handle.\n const checksTestId = `${prefix}:checks`;\n\n return (\n <>\n <form onSubmit={form.handleSubmit()} noValidate className={props.className}>\n {formErrors.length > 0 && (\n <div\n role=\"alert\"\n className=\"mb-4 flex flex-col gap-1 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive\"\n >\n {formErrors.map((issue, index) => (\n <p key={index}>{issueText(issue, t, prefix)}</p>\n ))}\n </div>\n )}\n {retryableChecks.length > 0 && (\n <div className=\"mb-4 flex flex-wrap gap-2\">\n {retryableChecks.map((checkId) => (\n <Button\n key={checkId}\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n data-testid={`form-check-retry:${checkId}`}\n onClick={() => void form.revalidate()}\n >\n {translateOrFallback(t, 'actions.retry', 'Retry')}\n </Button>\n ))}\n </div>\n )}\n {formWarnings.length > 0 && (\n <div\n role=\"status\"\n aria-live=\"polite\"\n className=\"mb-4 flex flex-col gap-1 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-sm text-warning-emphasis\"\n >\n {formWarnings.map((issue, index) => (\n <p key={index}>{issueText(issue, t, prefix)}</p>\n ))}\n </div>\n )}\n <ScreenTree\n region=\"form-body\"\n resource={prefix}\n mode=\"create\"\n compiled={form.screen}\n controller={form}\n leafIds={leafIds}\n {...(props.renderField === undefined ? {} : { renderField: props.renderField })}\n disabled={disabled}\n {...(props.bodyClassName === undefined ? {} : { className: props.bodyClassName })}\n />\n {props.slots?.footer === undefined ? (\n <div className=\"mt-4 flex justify-end\">\n <Button\n type=\"submit\"\n disabled={!form.canSubmit || disabled}\n // Without this, focusing out of the field a blur error just inserted moves the\n // submit button up, and the click that lands on the OLD position is swallowed.\n onMouseDown={(event) => event.preventDefault()}\n >\n {props.submitLabel ?? translateOrFallback(t, 'actions.save', 'Save')}\n </Button>\n </div>\n ) : typeof props.slots.footer === 'function' ? (\n props.slots.footer({ canSubmit: form.canSubmit && !disabled })\n ) : (\n props.slots.footer\n )}\n </form>\n {/* Rendered as a SIBLING of the `<form>`, never inside a menu, so the dialog\n survives whatever closes the triggering control. */}\n <CheckConfirmDialog\n state={gate.state}\n testid={checksTestId}\n onAnchorFocus={(field) => {\n document.getElementById(`${uid}-${field}`)?.focus();\n }}\n />\n </>\n );\n}\n","import {\n type ExportFormat,\n type FieldOption,\n declaredText,\n fieldOptionText,\n type I18nCaps,\n type ResourceFieldMap,\n exportFormatFieldKey,\n exportFormatOptionKey,\n humanizeKey,\n resolveContentSlot,\n} from '@burojs/core';\n\n/**\n * A format's option fields with every label resolved for the active locale,\n * ready for `<DeclarativeForm>`. A format declares plain English defaults and\n * no keys; a translation lives in a `common` bundle under\n * {@link exportFormatFieldKey} and {@link exportFormatOptionKey}. The option form belongs to no resource, so the\n * resource-scoped field convention (`resources.<r>.fields.<f>.label`) cannot\n * reach the framework bundle — this is where these labels resolve. `caps`\n * changes with the locale; recompute per render (`useMemo` on `caps`).\n */\nexport function localizeFormatOptions(\n caps: I18nCaps,\n format: ExportFormat,\n): ResourceFieldMap | undefined {\n const fields = format.options;\n if (fields === undefined) return undefined;\n const out: Record<string, unknown> = {};\n for (const [name, field] of Object.entries(fields)) {\n const declared = field as {\n readonly texts?: unknown;\n readonly options?: readonly FieldOption[];\n };\n const label = resolveContentSlot(caps, [exportFormatFieldKey(format.id, name)], {\n default: declaredText('field', field, 'label'),\n humanize: () => humanizeKey(name),\n });\n const options = declared.options?.map((option) => ({\n value: String(option.value),\n label: resolveContentSlot(\n caps,\n [exportFormatOptionKey(format.id, name, String(option.value))],\n {\n default: fieldOptionText(field, String(option.value)),\n humanize: () => String(option.value),\n },\n ),\n }));\n // The resolved texts replace the declared ones in `texts` too: a reader asks `texts` first,\n // and the declared English default must not shadow the bundle's translation.\n const declaredTexts: Readonly<Record<string, unknown>> =\n typeof declared.texts === 'object' && declared.texts !== null\n ? (declared.texts as Readonly<Record<string, unknown>>)\n : {};\n const declaredOptions = (declaredTexts.options ?? {}) as Readonly<Record<string, unknown>>;\n const texts = {\n ...declaredTexts,\n label,\n ...(options === undefined\n ? {}\n : {\n options: Object.fromEntries(\n options.map(({ value, label: optionLabel }) => {\n const entry = declaredOptions[value];\n return [\n value,\n typeof entry === 'object' && entry !== null\n ? { ...entry, label: optionLabel }\n : optionLabel,\n ];\n }),\n ),\n }),\n };\n out[name] = { ...field, texts };\n }\n return out as ResourceFieldMap;\n}\n","'use client';\nimport {\n declaredText,\n dtoFields,\n exportFormatLabelKey,\n resolveContentSlot,\n type ExportFormat,\n type ExportRequest,\n type ExportRunState,\n type ExportTarget,\n type ResourceFieldMap,\n type ScopeSource,\n} from '@burojs/core';\nimport {\n DismissGuardScope,\n type ExportRunEntry,\n useListAccess,\n useDismissGuard,\n useI18nCaps,\n useNavigationBlocker,\n useOptionalT,\n useResource,\n useResourceExport,\n useTestIds,\n} from '@burojs/react';\nimport * as React from 'react';\nimport { DeclarativeForm } from '../forms/declarative-form.js';\nimport { toast } from '../notification/toaster.js';\nimport { Button } from '../primitives/button.js';\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '../primitives/dialog.js';\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '../primitives/select.js';\nimport { downloadArtifact } from './download.js';\nimport { localizeFormatOptions } from './format-option-labels.js';\nimport { useTrackDisplayedRun } from './run-watcher.js';\n\nexport interface ExportDialogProps {\n readonly open: boolean;\n readonly onOpenChange: (open: boolean) => void;\n readonly resource: string;\n readonly target: ExportTarget;\n /**\n * The list's currently visible columns — what \"as in table\" (the default) sends as `request.columns`.\n * Empty means \"unknown\": the dialog then sends the same set as \"All columns\" (the resource's list\n * fields, minus any a `column` rule hides). `request.columns` is never omitted.\n */\n readonly visibleColumns: readonly string[];\n /** Known row estimate, shown in the filter-scope title and handed to the exporter as a progress total hint. */\n readonly estimatedCount?: number;\n /** How the export reads the resource: the scope of the list it exports (default `'session'`). */\n readonly scope?: ScopeSource;\n}\n\ntype Mode = 'form' | 'progress' | 'confirm-close';\n\nconst EMPTY_VALUES: Record<string, unknown> = {};\n\n/** `FieldDeclaration.default` off every entry of a `ResourceFieldMap`, for seeding a format's options form each time the selected format changes. */\nfunction fieldDefaults(fields: ResourceFieldMap | undefined): Record<string, unknown> {\n if (!fields) return EMPTY_VALUES;\n const out: Record<string, unknown> = {};\n for (const [name, def] of Object.entries(fields)) {\n const value = (def as { default?: unknown } | undefined)?.default;\n if (value !== undefined) out[name] = value;\n }\n return out;\n}\n\nfunction hasOptions(\n format: ExportFormat | undefined,\n): format is ExportFormat & { options: ResourceFieldMap } {\n return format?.options !== undefined && Object.keys(format.options).length > 0;\n}\n\n/** An empty option: absent, `null` and `''` all mean \"not set\". */\nfunction isEmptyOption(value: unknown): boolean {\n return value === undefined || value === null || value === '';\n}\n\nfunction sameOption(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (isEmptyOption(a) && isEmptyOption(b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n return JSON.stringify(a) === JSON.stringify(b);\n}\n\n/** True when any option value differs from the format's defaults (plan ruling 6). */\nexport function optionsDiffer(\n values: Readonly<Record<string, unknown>>,\n defaults: Readonly<Record<string, unknown>>,\n): boolean {\n const keys = new Set([...Object.keys(values), ...Object.keys(defaults)]);\n for (const key of keys) if (!sameOption(values[key], defaults[key])) return true;\n return false;\n}\n\n/**\n * Arms the unsaved-changes guard while the options differ from the format's defaults: in the\n * dialog's dismiss scope (Escape, an outside click and ✕ ask) and globally, like any form (a\n * route change and a reload ask too).\n */\nfunction ExportOptionsDirty({ dirty }: { readonly dirty: boolean }): null {\n useNavigationBlocker(dirty);\n return null;\n}\n\n/** Stable no-op snapshot getter for `useSyncExternalStore` before any run has started. */\nfunction getNoRunState(): ExportRunState | undefined {\n return undefined;\n}\n\n/**\n * Self-hosted export dialog — NOT presented through `useUIPresent`: an\n * unregistered `UIPresentRequest.component` registry key silently renders\n * `null`, so a framework-owned dialog would do nothing until every adopter\n * registered it (see `packages/react/src/ui/ui-presentations.tsx:74,138`).\n * The flow host draws the opposite line (it IS presented, as `buro:flow`, and\n * `shadcnPresentationHosts` registers it); this dialog stays self-hosted, built\n * on the local `<Dialog>` primitives, no registry involved.\n *\n * A `mode` state (`'form' | 'progress' | 'confirm-close'`) swaps content\n * inside ONE `<DialogContent>`/one Radix focus scope. A second, nested\n * Radix root for the close-while-running confirm was tried elsewhere in this\n * codebase and deadlocked the jsdom test runner (the old form-modal action's\n * menu-held dialog, deleted in P4) — this dialog\n * never repeats that shape.\n */\nexport function ExportDialog({\n open,\n onOpenChange,\n resource,\n target,\n visibleColumns,\n estimatedCount,\n scope,\n}: ExportDialogProps): React.ReactElement {\n const t = useOptionalT();\n const tid = useTestIds();\n const dialogTestId = tid.exportDialog(resource);\n // `{ load: open }` — this dialog is the ONE surface that actually needs the\n // exporter itself, so it is the one that invokes a deferred\n // (`ExporterLoader`) registration. The toolbar/bulk triggers call the same\n // hook with no options and answer `available` from the registration alone,\n // which is what keeps an app's exporter factories out of its initial JS.\n //\n // Keyed on `open`, not a literal `true`, for TWO reasons — both load-bearing:\n // - Both entry points keep this dialog mounted while it is closed (it is a\n // permanent sibling of their trigger; see the class comment). A constant\n // `true` would therefore ask for the exporter's chunk on every list page\n // that shows an export button, which is exactly the cost the deferred\n // registration exists to avoid.\n // - It makes a failed load RECOVERABLE. `useResourceExport`'s load effect\n // depends on this flag, so closing and reopening re-runs it and retries the\n // loader (the failed attempt is not cached). With a constant `true` the\n // effect's deps were all constant for the app's lifetime: one rejected load\n // left this dialog permanently unavailable, however many times the user\n // reopened it, while the changeset and the adopter guide both said\n // reopening retries.\n const { formats, start, exporter, available, error, loading } = useResourceExport(resource, {\n load: open,\n ...(scope === undefined ? {} : { scope }),\n });\n\n const [mode, setMode] = React.useState<Mode>('form');\n const [formatIdOverride, setFormatIdOverride] = React.useState<string | undefined>(undefined);\n const [columnsMode, setColumnsMode] = React.useState<'visible' | 'all'>('visible');\n const [formatValues, setFormatValues] = React.useState<Record<string, unknown>>(EMPTY_VALUES);\n const [runEntry, setRunEntry] = React.useState<ExportRunEntry | undefined>(undefined);\n\n // Tells `useExportRunWatcher()` (Task 8, fix round 1) exactly which run\n // THIS dialog is displaying right now — `undefined` whenever there is\n // none (no run started yet) or the dialog is closed, either of which\n // means the watcher owns the decision instead. Run-scoped, not\n // resource-scoped: a toolbar export and a bulk-bar export for the SAME\n // resource are two independent runs, and this dialog must only ever claim\n // credit for the one it is actually showing.\n useTrackDisplayedRun(open ? runEntry?.runId : undefined);\n\n // What \"All columns\" means: the resource's list fields in declaration order,\n // each gated by the same `kind: 'column'` view check `<ResourceList>` applies\n // to what it draws (`visibleColumnKeys`). `mode: 'list'` and no record, for\n // the same reason as there: a column spans every row.\n const def = useResource(resource);\n // The one list predicate (P5 spec 3.7): field view in any-record reach and `column` rules.\n const listAccess = useListAccess(resource);\n const accessPending = listAccess.status === 'pending';\n const allowedListColumns = React.useMemo<readonly string[]>(\n () =>\n def === undefined || accessPending\n ? []\n : dtoFields(def, 'list').filter((col) => listAccess.columnVisible(col)),\n [def, listAccess, accessPending],\n );\n // The table's visible columns, gated again by the same predicate: a prop a host built from a\n // stale or hand-made column set never widens what the user may export.\n const exportableVisible = React.useMemo<readonly string[]>(\n () => visibleColumns.filter((col) => !accessPending && listAccess.columnVisible(col)),\n [visibleColumns, listAccess, accessPending],\n );\n const requestColumns =\n columnsMode === 'visible' && visibleColumns.length > 0 ? exportableVisible : allowedListColumns;\n\n const selectedFormat = formats.find((f) => f.id === formatIdOverride) ?? formats[0];\n // A format's name is its `texts`; the flat `label` was removed. The type no longer allows it,\n // but an exporter's formats are adopter code at runtime: say so in development, once a format.\n const reportedLabels = React.useRef(new Set<string>());\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') return;\n for (const format of formats) {\n const flat = Object.hasOwn(format, 'label')\n ? (format as { readonly label?: unknown }).label\n : undefined;\n if (flat === undefined || reportedLabels.current.has(format.id)) continue;\n reportedLabels.current.add(format.id);\n console.error(\n `[ExportDialog] export format '${format.id}' declares label, which was removed: write texts — the text the bundle holds at common.${exportFormatLabelKey(format.id)} (see docs/i18n-guide.md).`,\n );\n }\n }, [formats]);\n const caps = useI18nCaps();\n const localizedOptions = React.useMemo(\n () => (selectedFormat === undefined ? undefined : localizeFormatOptions(caps, selectedFormat)),\n [caps, selectedFormat],\n );\n\n // A controlled dialog Task 8 may keep mounted and reopen for a DIFFERENT\n // request (a fresh `target`/`estimatedCount` on the next click) — without\n // this, reopening after a finished run would show the PREVIOUS run's\n // progress/success/failure view instead of a fresh form. Resets exactly on\n // the false→true edge, never on the initial mount (whatever `open` starts\n // at already matches this ref, so the very first render never \"edges\").\n const wasOpenRef = React.useRef(open);\n React.useEffect(() => {\n if (open && !wasOpenRef.current) {\n setMode('form');\n setRunEntry(undefined);\n setFormatIdOverride(undefined);\n setColumnsMode('visible');\n }\n wasOpenRef.current = open;\n }, [open]);\n\n // Reset the format-options snapshot to the newly selected format's own\n // field defaults — `<DeclarativeForm>` below is remounted (`key`) on the\n // same change, so its OWN internal state already restarts; this keeps what\n // `handleStart` would submit in sync even if the user never touches a\n // field of the format they just switched to.\n // Keyed on the format ID deliberately, not on `selectedFormat.options`: a\n // format's option schema is a static declaration for a given id, so the narrow\n // dep cannot go stale — while depending on the `options` OBJECT would re-run\n // this on every render for any exporter whose `formats()` rebuilds its entries.\n // biome-ignore lint/correctness/useExhaustiveDependencies: see comment above\n React.useEffect(() => {\n setFormatValues(fieldDefaults(selectedFormat?.options));\n }, [selectedFormat?.id]);\n\n const runState = React.useSyncExternalStore(\n React.useCallback(\n (cb: () => void) => (runEntry ? runEntry.handle.subscribe(cb) : () => {}),\n [runEntry],\n ),\n React.useCallback(() => (runEntry ? runEntry.handle.getState() : undefined), [runEntry]),\n getNoRunState,\n );\n\n // `supportsSort` lives on the resolved `Exporter` (`@burojs/core`), not on\n // any individual `ExportFormat` — every format of one exporter shares the\n // same answer. `exporter` is genuinely absent (not falsy-but-present) when\n // nothing resolved, so `undefined === false` correctly keeps the warning\n // hidden rather than needing a separate `available` check here.\n const showSortWarning = target.kind === 'filter' && exporter?.supportsSort === false;\n\n const titleText =\n target.kind === 'ids'\n ? t('export.dialog.titleSelected', { count: target.ids.length })\n : estimatedCount === undefined\n ? t('export.dialog.titleFilterUnknownCount')\n : t('export.dialog.titleFilter', { count: estimatedCount });\n\n function handleStart(): void {\n if (!selectedFormat) return;\n const request: Omit<ExportRequest, 'resource'> = {\n target,\n format: hasOptions(selectedFormat)\n ? { id: selectedFormat.id, options: formatValues }\n : { id: selectedFormat.id },\n // ALWAYS explicit. With no `columns`, both stock exporters fall back to\n // every key of the first row — which includes fields a `column` rule\n // hides from this user and anything extra the provider selected, so one\n // click turned a deliberately hidden column into a file. \"All columns\"\n // and an EMPTY visible set (`<BulkActionToolbar>` defaults the prop to\n // `[]` for standalone callers that cannot know the visible set) both\n // send the resource's list fields as the table itself would gate them.\n columns: [...requestColumns],\n ...(estimatedCount === undefined ? {} : { estimatedCount }),\n };\n const entry = start(request);\n setRunEntry(entry);\n setMode('progress');\n }\n\n // The dialog is a dismiss scope (P3-33): a close asks while the options differ from\n // the format's defaults. The confirm-close flow below stays the one prompt while a run is\n // in progress (the options form is not mounted then, so the scope is clean).\n const guard = useDismissGuard(() => onOpenChange(false));\n const dirtyOptions =\n mode === 'form' &&\n hasOptions(selectedFormat) &&\n optionsDiffer(formatValues, fieldDefaults(selectedFormat.options));\n\n function handleOpenChange(next: boolean): void {\n if (next) return; // this dialog is only ever closed through this handler\n // Once the confirm view is up, EVERY dismiss path Radix funnels through\n // this same callback — Escape, an overlay click, and the chrome close\n // button all call `onOpenChange(false)` exactly like a first close\n // attempt does. Without this branch, a SECOND dismiss signal while\n // `mode === 'confirm-close'` fell through to the plain `onOpenChange(false)`\n // at the bottom of this function: no `handle.cancel()`, no toast, no\n // explicit choice — a silent, unannounced \"continue in background\" that\n // defeats the whole point of asking. Swallowing the signal (never calling\n // the prop) keeps the dialog visually open, because `open` is a prop WE\n // forward from the parent unchanged — Radix has nothing else to redraw.\n if (mode === 'confirm-close') return;\n if (mode === 'progress' && runState?.status === 'running') {\n if (runEntry?.handle.cancel) {\n setMode('confirm-close');\n return;\n }\n toast(t('export.continuesInBackground'));\n guard.dismiss();\n return;\n }\n guard.dismiss();\n }\n\n function handleStop(): void {\n setMode('progress');\n // `ExportHandle.cancel` is a public seam — any adopter exporter may\n // implement it, and a rejecting one used to become an unhandled promise\n // rejection (bare `void handle.cancel?.()`). Reported loudly rather than\n // swallowed, the same stance `handle.ts` takes for a throwing listener:\n // the run itself is unaffected (the exporter owns its own termination),\n // but a cancel endpoint that is failing is worth knowing about.\n runEntry?.handle.cancel?.().catch((thrown: unknown) => {\n console.error('[buro] ExportDialog: export cancel failed', thrown);\n });\n onOpenChange(false);\n }\n\n function handleContinue(): void {\n setMode('progress');\n onOpenChange(false);\n }\n\n return (\n <Dialog open={open} onOpenChange={handleOpenChange}>\n <DialogContent data-testid={dialogTestId}>\n <DismissGuardScope value={guard.scope}>\n <ExportOptionsDirty dirty={open && dirtyOptions} />\n {mode === 'confirm-close' ? (\n <>\n <DialogHeader>\n <DialogTitle>{t('export.dialog.confirmCloseTitle')}</DialogTitle>\n <DialogDescription>{t('export.dialog.confirmCloseMessage')}</DialogDescription>\n </DialogHeader>\n <DialogFooter>\n <Button\n type=\"button\"\n variant=\"outline\"\n data-testid={`${dialogTestId}:continue`}\n onClick={handleContinue}\n >\n {t('export.dialog.continue')}\n </Button>\n <Button\n type=\"button\"\n variant=\"destructive\"\n data-testid={`${dialogTestId}:stop`}\n onClick={handleStop}\n >\n {t('export.dialog.stop')}\n </Button>\n </DialogFooter>\n </>\n ) : mode === 'progress' ? (\n <>\n <DialogHeader>\n <DialogTitle>{titleText}</DialogTitle>\n <DialogDescription className=\"sr-only\">{titleText}</DialogDescription>\n </DialogHeader>\n <ExportProgressView state={runState} dialogTestId={dialogTestId} t={t} />\n </>\n ) : (\n <>\n <DialogHeader>\n <DialogTitle>{titleText}</DialogTitle>\n <DialogDescription className=\"sr-only\">{titleText}</DialogDescription>\n </DialogHeader>\n\n {!available ? (\n // Task 8 gates the TRIGGER on `available` before ever opening\n // this dialog, so this path is a defensive fallback for a\n // direct/programmatic mount — without it, an unavailable\n // resource showed an empty form (no format selector, no\n // fields) next to a Start button that was disabled for a\n // reason nobody explained.\n <p role=\"alert\" data-testid={`${dialogTestId}:unavailable`}>\n {error?.message ?? t('export.dialog.unavailable')}\n </p>\n ) : (\n <>\n {loading ? (\n // A deferred exporter registration is still loading, so\n // there are no `formats` to choose from yet — this stands in\n // for the selector rather than rendering an empty one (and\n // Start stays disabled below). There is no semantic HTML\n // element for a status live region, so `role=\"status\"` on a\n // <p> IS the correct ARIA construction — same call the sort\n // warning below makes.\n // biome-ignore lint/a11y/useSemanticElements: see comment above\n <p\n role=\"status\"\n data-testid={`${dialogTestId}:loading`}\n className=\"text-sm text-muted-foreground\"\n >\n {t('export.dialog.loading')}\n </p>\n ) : (\n formats.length > 1 && (\n <div className=\"flex flex-col gap-1.5\">\n <span className=\"text-sm font-medium\">{t('export.dialog.format')}</span>\n <Select\n value={selectedFormat?.id}\n onValueChange={(value) => setFormatIdOverride(value)}\n >\n <SelectTrigger data-testid={`${dialogTestId}:format`}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {formats.map((format) => (\n <SelectItem\n key={format.id}\n value={format.id}\n data-testid={`${dialogTestId}:format:option:${format.id}`}\n >\n {resolveContentSlot(caps, [exportFormatLabelKey(format.id)], {\n default: declaredText('export-format', format, 'label'),\n humanize: () => format.id,\n })}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n )\n )}\n\n {hasOptions(selectedFormat) && (\n <DeclarativeForm\n key={selectedFormat.id}\n fields={localizedOptions ?? selectedFormat.options}\n defaults={fieldDefaults(selectedFormat.options)}\n onChange={setFormatValues}\n i18nPrefix=\"export\"\n slots={{ footer: <React.Fragment /> }}\n />\n )}\n\n <div className=\"flex flex-col gap-1.5\">\n <span className=\"text-sm font-medium\">{t('export.dialog.columns')}</span>\n <div className=\"flex gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant={columnsMode === 'visible' ? 'default' : 'outline'}\n aria-pressed={columnsMode === 'visible'}\n data-testid={`${dialogTestId}:columns-visible`}\n onClick={() => setColumnsMode('visible')}\n >\n {t('export.dialog.columnsVisible')}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant={columnsMode === 'all' ? 'default' : 'outline'}\n aria-pressed={columnsMode === 'all'}\n data-testid={`${dialogTestId}:columns-all`}\n onClick={() => setColumnsMode('all')}\n >\n {t('export.dialog.columnsAll')}\n </Button>\n </div>\n </div>\n\n {showSortWarning && (\n // There is no semantic HTML element for a status live region, so\n // `role=\"status\"` on a <p> IS the correct ARIA construction — the\n // same call data-table-faceted-filter.tsx makes for role=\"option\".\n // biome-ignore lint/a11y/useSemanticElements: see comment above\n <p\n role=\"status\"\n data-testid={`${dialogTestId}:sort-warning`}\n className=\"text-sm text-warning-emphasis\"\n >\n {t('export.dialog.sortWarning')}\n </p>\n )}\n\n <DialogFooter>\n <Button\n type=\"button\"\n // `loading` is stated explicitly even though an unloaded\n // exporter also has no `selectedFormat`: `start()` is\n // synchronous and THROWS while a deferred registration is\n // still loading, so the reason this control is disabled\n // should be readable at the call site rather than inferred\n // from an empty format list.\n disabled={loading || !selectedFormat || accessPending}\n data-testid={`${dialogTestId}:start`}\n onClick={handleStart}\n >\n {t('export.dialog.start')}\n </Button>\n </DialogFooter>\n </>\n )}\n </>\n )}\n </DismissGuardScope>\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction ExportProgressView({\n state,\n dialogTestId,\n t,\n}: {\n state: ExportRunState | undefined;\n dialogTestId: string;\n t: (key: string, options?: { params?: Record<string, unknown> }) => string;\n}): React.ReactElement | null {\n if (state === undefined) return null;\n if (state.status === 'running') {\n const total = state.progress?.total;\n return (\n <p data-testid={`${dialogTestId}:progress`}>\n {total === undefined\n ? t('export.dialog.progressIndeterminate')\n : t('export.dialog.progress', { params: { done: state.progress?.done ?? 0, total } })}\n </p>\n );\n }\n if (state.status === 'succeeded') {\n return (\n <Button\n type=\"button\"\n data-testid={`${dialogTestId}:download`}\n onClick={() => downloadArtifact(state.artifact)}\n >\n {t('export.dialog.download')}\n </Button>\n );\n }\n if (state.status === 'failed') {\n // Framed with `export.dialog.failed` rather than rendering a bare\n // `DataError.message`: provider messages are written for developers\n // (\"Portable value must contain only JSON-compatible data.\") and read as\n // gibberish with no statement of WHAT failed. The key existed in both\n // bundles and was unused.\n return (\n <p role=\"alert\" data-testid={`${dialogTestId}:error`}>\n {`${t('export.dialog.failed')}: ${state.error.message}`}\n </p>\n );\n }\n if (state.status === 'canceled') {\n return <p data-testid={`${dialogTestId}:canceled`}>{t('export.dialog.canceled')}</p>;\n }\n // Exhaustiveness check: `ExportRunState` (`@burojs/core`) is a closed union\n // of exactly 4 statuses. A future 5th status would fail THIS assignment at\n // compile time — `state` would no longer be assignable to `never` — rather\n // than silently falling through to whatever a trailing catch-all used to\n // render (a `canceled` message, which is exactly wrong for an unmodeled\n // status).\n const exhaustive: never = state;\n return exhaustive;\n}\n","'use client';\nimport { BULK_EACH_LIMIT, type BulkProgress, compileFlow, type FlowResult } from '@burojs/core';\nimport { useApp, useFlowRowResolver, useOptionalT, useTestIds } from '@burojs/react';\nimport { type ReactElement, useMemo, useState } from 'react';\nimport { DisabledAction } from '../actions/action-button.js';\nimport { ActionInner } from '../actions/action-inner.js';\nimport { Button } from '../primitives/button.js';\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '../primitives/dialog.js';\nimport { text, useFlowChrome } from './chrome.js';\nimport {\n FlowBoundary,\n loadBulkSummary,\n loadFailedText,\n preloadFlowRuntime,\n RuntimeBulkFlowRunner,\n useLoaded,\n} from './load-runtime.js';\nimport type { FlowBulkSummaryProps } from './bulk-summary.js';\n\n/** The summary, loaded on first use (plan ruling 8); a failed load says so, with Retry. */\nfunction BulkSummary(props: FlowBulkSummaryProps): ReactElement | null {\n const loaded = useLoaded(loadBulkSummary);\n const t = useOptionalT();\n const failed = (retry: () => void) => (\n <div role=\"alert\" className=\"flex items-center gap-2 text-sm\">\n <span>{loadFailedText(t)}</span>\n <Button type=\"button\" size=\"sm\" variant=\"outline\" onClick={retry}>\n {text(t, 'actions.retry', 'Retry')}\n </Button>\n </div>\n );\n if (loaded.error !== undefined) return failed(loaded.retry);\n if (loaded.module === undefined) return null;\n const Summary = loaded.module.FlowBulkSummary;\n return (\n <FlowBoundary fallback={(_error, reset) => failed(reset)}>\n <Summary {...props} />\n </FlowBoundary>\n );\n}\n\nexport interface BulkFlowButtonProps {\n readonly resource: string;\n readonly actionName: string;\n /** The selected ids: the run's `selection` (`{ ids, count }`). */\n readonly ids: readonly string[];\n /** Replaces the selection: after a run, the ids that succeeded leave it (4.16). */\n readonly onSelectionChange?: (ids: string[]) => void;\n}\n\n/**\n * A bulk flow in the selection bar (P4 spec 4.16): over the selection `{ ids, count }`, at most\n * `BULK_EACH_LIMIT` ids (more renders the button refused, and nothing is read). Its state comes\n * from the flow's gate without a run; the click starts the run (loading the flow runtime when a\n * hover or a focus has not already): `confirm` and the fired warnings ask, the run re-reads the\n * rows in one read and writes each under its own key. Afterwards the ids that succeeded leave\n * the selection, the others stay, and anything but a full success shows the per-outcome summary.\n */\nexport function BulkFlowButton({\n resource,\n actionName,\n ids,\n onSelectionChange,\n}: BulkFlowButtonProps): ReactElement | null {\n const app = useApp();\n const tid = useTestIds();\n const t = useOptionalT();\n const control = useFlowRowResolver(resource)(actionName, undefined);\n const chrome = useFlowChrome(resource, actionName);\n const def = app.registry.get(resource);\n const each = useMemo(() => {\n try {\n return def === undefined ? false : compileFlow(def as never, actionName).each;\n } catch {\n return false;\n }\n }, [def, actionName]);\n const [running, setRunning] = useState(false);\n const [summary, setSummary] = useState<{\n readonly progress: BulkProgress;\n readonly total: number;\n } | null>(null);\n const testid = tid.bulkAction(resource, actionName);\n if (control.state === 'absent') return null;\n const variant = chrome.destructive ? 'destructive' : 'outline';\n const overLimit = each && ids.length > BULK_EACH_LIMIT;\n if (overLimit || control.state === 'disabled')\n return (\n <DisabledAction\n reason={\n overLimit\n ? text(t, 'flow.bulkLimit', `Select at most ${BULK_EACH_LIMIT}.`, {\n count: BULK_EACH_LIMIT,\n })\n : control.reason\n }\n label={chrome.label}\n icon={chrome.icon}\n testid={testid}\n size=\"sm\"\n variant={variant}\n resource={resource}\n actionName={actionName}\n surface=\"bulk\"\n />\n );\n const busy = control.state === 'undecided' || control.state === 'pending' || running;\n const finish = (result: FlowResult, progress: BulkProgress | undefined) => {\n setRunning(false);\n if (progress === undefined) return;\n if (result.outcome !== 'success') setSummary({ progress, total: ids.length });\n // The ids that succeeded leave the selection; the others stay selected (4.16).\n onSelectionChange?.(ids.filter((id) => !progress.success.includes(id)));\n };\n return (\n <>\n <Button\n type=\"button\"\n size=\"sm\"\n variant={variant}\n data-testid={testid}\n data-buro-flow-state={running ? 'running' : control.state}\n disabled={busy}\n aria-busy={busy ? 'true' : undefined}\n onPointerEnter={preloadFlowRuntime}\n onFocus={preloadFlowRuntime}\n onClick={() => {\n if (!busy) setRunning(true);\n }}\n >\n <ActionInner icon={chrome.icon} label={chrome.label} />\n </Button>\n {running ? (\n <RuntimeBulkFlowRunner\n resource={resource}\n actionName={actionName}\n ids={ids}\n onFinish={finish}\n />\n ) : null}\n <Dialog\n open={summary !== null}\n onOpenChange={(open) => {\n if (!open) setSummary(null);\n }}\n >\n <DialogContent data-testid={`${tid.bulkSummary(resource, actionName)}:dialog`}>\n <DialogHeader>\n <DialogTitle>{chrome.label}</DialogTitle>\n <DialogDescription className=\"sr-only\">{chrome.labelText}</DialogDescription>\n </DialogHeader>\n {summary === null ? null : (\n <BulkSummary\n resource={resource}\n actionName={actionName}\n label={chrome.labelText}\n total={summary.total}\n progress={summary.progress}\n />\n )}\n <DialogFooter>\n <Button\n type=\"button\"\n variant=\"outline\"\n data-testid={`${tid.bulkSummary(resource, actionName)}:close`}\n onClick={() => setSummary(null)}\n >\n {text(t, 'flow.close', 'Close')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </>\n );\n}\n","'use client';\nimport { isFlowAction } from '@burojs/core/internal';\nimport { useState } from 'react';\nimport { IconDownload, IconX } from '@tabler/icons-react';\nimport type { ActionFlow, ExportTarget, ScopeSource } from '@burojs/core';\nimport {\n useApp,\n useCapability,\n useOptionalDataRuntime,\n useOptionalT,\n useResourceExport,\n useTestIds,\n} from '@burojs/react';\nimport type { Table } from '@tanstack/react-table';\nimport { Button } from '../primitives/button.js';\nimport { cn } from '../lib/cn.js';\nimport { ExportDialog } from '../export/export-dialog.js';\nimport { BulkFlowButton } from '../flows/bulk-flow-button.js';\n\ntype BulkRecord = { id: string } & Record<string, unknown>;\n\n/**\n * Canonical order for the bar's declared actions — `order` when it is set,\n * declaration index otherwise, stable on ties.\n *\n * The identical weighting `planItemActions` gives item actions, deliberately\n * NOT that function: it also resolves SURFACES and a density, and a bulk\n * action has neither (`ActionSurfaces` is `{ row; show; edit; list }` — there\n * is no `bulk` surface, and this bar is the one place a bulk action renders).\n * Calling it here would mean inventing a surface name for a control that has\n * exactly one home.\n *\n * Until SP5 task 6 `order` was declared on bulk actions and read by\n * nothing: a probe declared `[{ name: 'second', order: 99 }, { name: 'first',\n * order: 1 }]` and the bar drew them in declaration order.\n */\nfunction orderBulkActions(actions: readonly ActionFlow[]): ActionFlow[] {\n return actions\n .map((action, index) => ({ action, weight: action.order ?? index, seq: index }))\n .sort((a, b) => a.weight - b.weight || a.seq - b.seq)\n .map(({ action }) => action);\n}\n\nexport interface BulkActionToolbarProps<TRecord extends BulkRecord = BulkRecord> {\n resource: string;\n /**\n * TanStack table instance from the surrounding `<ResourceList>`. Used only\n * as a FALLBACK, for standalone call sites that have no accumulated set of\n * their own: `getFilteredSelectedRowModel()` can only see the rows of the\n * current page, so it under-reports a selection built across pages.\n */\n table?: Table<TRecord>;\n /**\n * The selected records — the authoritative source when present. Includes\n * records for rows the user selected on pages they have since left.\n */\n selectedRecords?: TRecord[];\n /**\n * The selected ids. Defaults to the ids of `selectedRecords`; pass it\n * explicitly when the owner's id set can be wider than the records it\n * could resolve (see `ResourceListController.selection`).\n */\n selectedIds?: string[];\n /**\n * Called when the user clicks the \"Clear\" button. When `table` is\n * provided and this prop is omitted, the toolbar clears selection\n * itself via `table.resetRowSelection()`.\n */\n onClearSelection?: () => void;\n /**\n * Replaces the selection. A bulk flow calls it after its run: the ids that succeeded leave the\n * selection and the others stay (P4 spec 4.16). Without it, a run that succeeded for every id\n * clears the selection through `onClearSelection`.\n */\n onSelectionChange?: (ids: string[]) => void;\n className?: string;\n /**\n * The list's currently visible columns (Task 8) — forwarded to the\n * built-in bulk Export entry point's `<ExportDialog visibleColumns>` as\n * what \"as shown in the table\" (the dialog's default) sends as\n * `request.columns`. Optional: this toolbar is usable standalone, with no\n * `<ResourceListPage>`/list controller in reach — a caller that omits it\n * gets the dialog's \"All columns\" set for that default: the resource's list\n * fields, minus any a `column` rule hides.\n */\n visibleColumns?: readonly string[];\n /** How the built-in bulk Export reads the resource: the scope of the list the ids came from. */\n scope?: ScopeSource;\n}\n\nexport function BulkActionToolbar<TRecord extends BulkRecord = BulkRecord>({\n resource,\n table,\n selectedRecords,\n selectedIds,\n onClearSelection,\n onSelectionChange,\n className,\n visibleColumns,\n scope,\n}: BulkActionToolbarProps<TRecord>): React.ReactElement | null {\n const app = useApp();\n const tid = useTestIds();\n const t = useOptionalT();\n const def = app.registry.get(resource);\n\n // Explicit selection wins: it is the whole accumulated set. The table only\n // knows the current page, so it is the fallback for standalone callers.\n const records: TRecord[] =\n selectedRecords ??\n (table ? table.getFilteredSelectedRowModel().rows.map((r) => r.original as TRecord) : []);\n const ids: string[] = selectedIds ?? records.map((record) => record.id);\n\n if (!def || (records.length === 0 && ids.length === 0)) return null;\n\n // Every bulk action is a flow (P4, F15): `order`, then declaration; each draws its own button.\n const bulkActions = orderBulkActions(\n ((def.actions.bulk ?? []) as readonly unknown[]).filter(isFlowAction) as ActionFlow[],\n );\n\n const handleClear = (): void => {\n if (onClearSelection) {\n onClearSelection();\n return;\n }\n table?.resetRowSelection();\n };\n\n return (\n <>\n {/*\n Floating command bar (#1). It used to sit INLINE above the table and\n shove the whole list down the moment a row was checked — jarring. It's\n now `fixed` to the bottom-centre of the viewport, so selecting rows never\n reflows the content. A matching spacer (below) extends the scroll height\n so the last rows can always be scrolled clear of the bar. Slide-up +\n fade on mount; a frosted, elevated pill on the theme's own tokens.\n */}\n <div className=\"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center px-4 pb-4 sm:pb-6\">\n <div\n data-testid={tid.listBulkBar(resource)}\n className={cn(\n // `flex-wrap` + max-width: at 390px the bar would otherwise overflow\n // the viewport (measured 715px in a 356px container); wrapping keeps\n // every action reachable without a sideways scroll.\n 'pointer-events-auto flex max-w-[calc(100vw-2rem)] flex-wrap items-center gap-1.5 rounded-full border bg-background/95 p-1.5 pl-3 shadow-lg supports-[backdrop-filter]:bg-background/80 supports-[backdrop-filter]:backdrop-blur',\n 'animate-in fade-in-0 zoom-in-95 slide-in-from-bottom-3 duration-300 ease-out',\n className,\n )}\n >\n <span className=\"flex items-center gap-2 pr-1 text-sm font-medium\">\n {/* Narrow screens: a primary count chip stands in for the full\n sentence (which is hidden below `sm`), so the count is never\n lost. */}\n <span className=\"inline-flex h-6 min-w-6 items-center justify-center rounded-full bg-primary px-1.5 text-xs font-semibold tabular-nums text-primary-foreground sm:hidden\">\n {ids.length}\n </span>\n {/*\n The count is the WHOLE selection, which can exceed the number of\n checked boxes on screen: selection accumulates across pages. The\n chip (mobile) and this sentence (sm+) never show together, so the\n count is stated exactly once.\n */}\n <span className=\"hidden text-muted-foreground sm:inline\">\n {t('table.selectedCount', { count: ids.length })}\n </span>\n </span>\n <span className=\"mx-0.5 h-6 w-px bg-border\" aria-hidden=\"true\" />\n {bulkActions.map((action) => (\n <BulkFlowButton\n key={action.name}\n resource={resource}\n actionName={action.name}\n ids={ids}\n onSelectionChange={(next) => {\n if (onSelectionChange !== undefined) onSelectionChange(next);\n else if (next.length === 0) handleClear();\n }}\n />\n ))}\n {/*\n Built-in Export entry point (Task 8) — NOT one of `def.actions\n .bulk`, so it renders unconditionally alongside them rather than\n through the per-action loop; its own gates\n (`useResourceExport().available` + the capability engine) decide\n whether it exists at all.\n */}\n <BulkExportButton\n resource={resource}\n ids={ids}\n visibleColumns={visibleColumns ?? []}\n {...(scope === undefined ? {} : { scope })}\n />\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n onClick={handleClear}\n className=\"h-8 gap-1.5 rounded-full px-2.5\"\n >\n <IconX className=\"size-4\" aria-hidden=\"true\" />\n <span className=\"hidden sm:inline\">\n {t('actions.clearSelection', { defaultValue: 'Clear' })}\n </span>\n </Button>\n </div>\n </div>\n {/* Scroll-clearance spacer: only present while the bar is (its height +\n bottom gap ≈ the bar's footprint), so the bottom rows never hide\n behind the floating bar. Rendered in-flow at the end of the content. */}\n <div aria-hidden=\"true\" className=\"h-20 sm:h-24\" />\n </>\n );\n}\n\n/**\n * Built-in bulk Export entry point (Task 8) — the `selection.ids` analogue\n * of `<ExportButton>`'s filter-scope toolbar button. Own component (like\n * `BulkFlowButton`) so its hooks (`useResourceExport`, `useCapability`,\n * `useState`) keep a stable order regardless of how many declared bulk\n * actions render around it.\n *\n * Target is `{ kind: 'ids', ids }` — exactly `selection.ids`, never derived\n * from `records` (which may be shorter: a snapshot only exists for rows the\n * list still has a record for, per `ResourceListController.selection`'s own\n * doc). `ids` is threaded in as a prop rather than read from\n * `useResourceListContext()` — this toolbar is usable with NO\n * `<ResourceListProvider>` mounted at all (see `BulkActionToolbarProps`'s\n * own doc on `table`), and every existing test in this file renders it that\n * way; calling that hook here would throw for every one of them.\n *\n * `<ExportDialog>` is mounted as a SIBLING of the floating bar's buttons —\n * never nested inside a menu's content — matching `ActionOverflow`'s\n * flow runner, mounted beside its menu: two nested Radix\n * focus scopes make typing unreliable in a browser and deadlocked this\n * repo's jsdom runner. This toolbar renders plain `<Button>`s, not a\n * dropdown menu, so the failure mode does not apply today — but the dialog\n * still lives at this level (a sibling return, not inside anything that\n * could tear it down) so the invariant holds if a future menu-mode bulk bar\n * is ever built on top of this component.\n */\nfunction BulkExportButton({\n resource,\n ids,\n visibleColumns,\n scope,\n}: {\n resource: string;\n ids: string[];\n visibleColumns: readonly string[];\n scope?: ScopeSource;\n}): React.ReactElement | null {\n // See `ExportButton`'s identical guard (`export-button.tsx`) for why:\n // `useResourceExport` hard-requires a native data runtime, and this\n // toolbar is explicitly usable standalone (no `<ResourceListProvider>`,\n // sometimes no `dataRuntime` at all — several tests in this very file\n // render it that way). `useOptionalDataRuntime()` never throws, so it is\n // safe to call unconditionally here; `BulkExportButtonActive` calls the\n // hard hooks unconditionally because it only ever mounts once a runtime\n // is confirmed present.\n const hasDataRuntime = useOptionalDataRuntime() !== null;\n if (!hasDataRuntime) return null;\n return (\n <BulkExportButtonActive\n resource={resource}\n ids={ids}\n visibleColumns={visibleColumns}\n {...(scope === undefined ? {} : { scope })}\n />\n );\n}\n\nfunction BulkExportButtonActive({\n resource,\n ids,\n visibleColumns,\n scope,\n}: {\n resource: string;\n ids: string[];\n visibleColumns: readonly string[];\n scope?: ScopeSource;\n}): React.ReactElement | null {\n const tid = useTestIds();\n const t = useOptionalT();\n // No `{ load: true }`, plus hover/focus prefetch — identical reasoning to\n // `<ExportButton>`'s, documented there.\n const { available, prefetch } = useResourceExport(resource);\n const capability = useCapability('run', {\n resource,\n target: { kind: 'action', name: 'export' },\n mode: 'list',\n });\n const [open, setOpen] = useState(false);\n\n if (!available || !capability.allowed) return null;\n\n const target: ExportTarget = { kind: 'ids', ids };\n\n return (\n <>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n data-testid={tid.exportBulkAction(resource)}\n onClick={() => setOpen(true)}\n onMouseEnter={prefetch}\n onFocus={prefetch}\n >\n <IconDownload className=\"size-4\" aria-hidden=\"true\" />\n {t('export.button.label')}\n </Button>\n <ExportDialog\n open={open}\n onOpenChange={setOpen}\n resource={resource}\n target={target}\n visibleColumns={visibleColumns}\n {...(scope === undefined ? {} : { scope })}\n />\n </>\n );\n}\n","'use client';\nimport type { ReactElement } from 'react';\nimport { useResourceListContext } from '@burojs/react';\nimport { BulkActionToolbar } from '../../actions/bulk-action-toolbar.js';\nimport { listPiece } from './piece.js';\nimport { useListSurface, usePieceMount } from './pieces-context.js';\n\n/**\n * The floating bar of a selection. The surface mounts it BELOW the list frame, so a frame cannot\n * lose it; it must render at the END of the content flow so its in-flow spacer extends the scroll\n * height and the last rows clear the bar.\n */\nfunction ListBulkBarView() {\n usePieceMount('bulk-bar');\n const { selection, columns, scope } = useResourceListContext();\n const { resource, tableView, readOnly } = useListSurface();\n if (!tableView || readOnly || selection.ids.length === 0) return null;\n return (\n <BulkActionToolbar\n resource={resource}\n selectedRecords={selection.records}\n selectedIds={selection.ids}\n onClearSelection={selection.clear}\n onSelectionChange={selection.set}\n visibleColumns={columns.visible}\n scope={scope}\n />\n );\n}\n\nexport const ListBulkBar: () => ReactElement | null = listPiece('ListBulkBar', ListBulkBarView);\n","'use client';\nimport type { ReactNode } from 'react';\nimport { useOptionalT } from '@burojs/react';\nimport type { Column, Table } from '@tanstack/react-table';\nimport { IconSettings2 } from '@tabler/icons-react';\nimport { Button } from '../primitives/button.js';\nimport { Checkbox } from '../primitives/checkbox.js';\nimport { Popover, PopoverContent, PopoverTrigger } from '../primitives/popover.js';\nimport { cn } from '../lib/cn.js';\n\n/**\n * Column visibility toggle for `<DataTable>`. Functional adaptation\n * of the canonical shadcn Tasks `data-table-view-options.tsx` using\n * existing Popover + Checkbox primitives. The shadcn version uses\n * DropdownMenu + DropdownMenuCheckboxItem; we mirror the\n * functionality without expanding our primitive surface (Popover\n * is what we already ship).\n *\n * The component lists every column for which `column.getCanHide()`\n * returns true and toggles visibility via `column.toggleVisibility()`.\n * Three features the original playground `ColumnsToggle` carried —\n * required-column locking (`data-required` attribute, disabled\n * checkbox), a \"Reset to defaults\" footer, and visual overrides for\n * trigger/menu — are all surfaced as optional props so the caller\n * keeps full control of look + behaviour.\n *\n * Testids: resource-agnostic, supplied by the caller via\n * `getTestId(role, columnId?)` callback. Roles: 'trigger', 'menu',\n * 'option' (with columnId), 'checkbox' (with columnId), 'reset'.\n */\nexport interface DataTableViewOptionsProps<TData> {\n table: Table<TData>;\n\n /**\n * Map a column to its visible label. Defaults to `column.id`.\n * The future ResourceList migration plugs in field labels (e.g.\n * `def.fields[col].label ?? humanizeKey(col)`).\n */\n getColumnLabel?: (column: Column<TData, unknown>) => string;\n\n /**\n * Mark a column as required (cannot be hidden). When true:\n * - the checkbox is disabled (and forced to checked)\n * - the option row carries `data-required=\"true\"` for\n * compatibility with the existing `column-toggle.spec.ts`.\n */\n isColumnRequired?: (column: Column<TData, unknown>) => boolean;\n\n /**\n * Resource-agnostic testid generator. Roles:\n * 'trigger' → the popover trigger button\n * 'menu' → the popover content container\n * 'option' → option row (columnId passed as second arg)\n * 'checkbox' → option checkbox input (columnId as second arg)\n * 'reset' → \"Reset to defaults\" footer button (only rendered\n * when `onReset` is provided)\n */\n getTestId?: (\n role: 'trigger' | 'menu' | 'option' | 'checkbox' | 'reset',\n columnId?: string,\n ) => string | undefined;\n\n /**\n * Optional reset callback. When provided, a footer button is\n * rendered at the bottom of the popover content. Caller controls\n * visibility by passing `undefined` when the table is already at\n * defaults — the typical pattern is `onReset={isAtDefaults ?\n * undefined : handler}`.\n */\n onReset?: () => void;\n\n /**\n * Extra footer actions (#17), rendered below the column list — e.g. «Reset\n * sizes» / «Restore defaults». Each is a full-width button. Shown\n * in addition to `onReset`.\n */\n footerActions?: Array<{ label: string; onClick: () => void; testid?: string }>;\n\n /** Label rendered inside the trigger button. Default: \"View\". */\n triggerLabel?: string;\n\n /**\n * Icon node rendered to the left of `triggerLabel`. Default:\n * `<Settings2 .../>`. Pass `null` to suppress the icon entirely\n * (the playground's \"Columns\" trigger uses no icon).\n */\n triggerIcon?: ReactNode;\n\n /**\n * className applied to the trigger Button. Default:\n * `'ml-auto hidden h-8 lg:flex'` (the canonical shadcn-tasks\n * trigger style, right-aligned, hidden on small viewports).\n * Pass an empty string to remove the default and let the Button\n * primitive's own classes drive layout.\n */\n triggerClassName?: string;\n\n /** Popover content alignment. Default: 'end'. */\n popoverAlign?: 'start' | 'center' | 'end';\n\n /** className applied to the popover content. Default: 'w-[180px] p-1'. */\n popoverContentClassName?: string;\n\n /**\n * Header rendered at the top of the popover content. Default:\n * \"Toggle columns\". Pass `null` to suppress the header (and its\n * divider).\n */\n menuTitle?: ReactNode;\n\n /** Label rendered inside the reset footer button. Defaults to `toolbar.restoreDefaults`. */\n resetLabel?: string;\n\n /**\n * Legacy alias for `triggerClassName`. Earlier callers used\n * `className` to override the trigger; we keep that behaviour for\n * backward compatibility — both compose via `cn`.\n */\n className?: string;\n\n /**\n * Render the trigger as a compact icon-only square button (no visible\n * label). `triggerLabel` becomes the `aria-label` + tooltip so the control\n * stays accessible. Pass `triggerIcon` WITHOUT a text margin in this mode.\n */\n iconOnly?: boolean;\n}\n\nconst DEFAULT_TRIGGER_ICON = <IconSettings2 className=\"mr-2 h-4 w-4\" aria-hidden=\"true\" />;\n\nexport function DataTableViewOptions<TData>({\n table,\n getColumnLabel,\n isColumnRequired,\n getTestId,\n onReset,\n footerActions,\n triggerLabel = 'View',\n triggerIcon = DEFAULT_TRIGGER_ICON,\n triggerClassName = 'ml-auto hidden h-8 lg:flex',\n popoverAlign = 'end',\n popoverContentClassName = 'w-[180px] p-1',\n menuTitle,\n resetLabel,\n className,\n iconOnly = false,\n}: DataTableViewOptionsProps<TData>): React.ReactElement {\n /*\n ⚠️ These defaulted to the English literals 'Toggle columns' and 'Reset to\n defaults'. This component is exported to adopters, so those strings were\n reachable — an app in another language that used `onReset` without also\n passing `resetLabel` got an English button. Defaults now come from the bundle;\n an explicitly-passed label still wins.\n */\n const t = useOptionalT();\n // `undefined` means \"not specified, use the default\"; an explicit `null`\n // means \"no header at all\" and is part of this component's contract, so\n // `??` would be wrong here.\n const menuTitleText =\n menuTitle === undefined ? t('toolbar.columns', { defaultValue: 'Toggle columns' }) : menuTitle;\n const resetLabelText =\n resetLabel ?? t('toolbar.restoreDefaults', { defaultValue: 'Reset to defaults' });\n const hideableColumns = table\n .getAllColumns()\n .filter((column) => typeof column.accessorFn !== 'undefined' && column.getCanHide());\n\n return (\n <Popover>\n <PopoverTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size={iconOnly ? 'icon' : 'sm'}\n aria-label={iconOnly && typeof triggerLabel === 'string' ? triggerLabel : undefined}\n title={iconOnly && typeof triggerLabel === 'string' ? triggerLabel : undefined}\n data-testid={getTestId?.('trigger')}\n className={cn(iconOnly && 'h-8 w-8', triggerClassName, className)}\n >\n {triggerIcon}\n {!iconOnly && triggerLabel}\n </Button>\n </PopoverTrigger>\n <PopoverContent\n align={popoverAlign}\n className={popoverContentClassName}\n data-testid={getTestId?.('menu')}\n >\n {menuTitleText != null && (\n <>\n <div className=\"px-2 py-1.5 text-sm font-semibold\">{menuTitleText}</div>\n <div className=\"my-1 -mx-1 border-t\" />\n </>\n )}\n <div className=\"max-h-[300px] overflow-auto\">\n {hideableColumns.map((column) => {\n const label = getColumnLabel?.(column) ?? column.id;\n const required = isColumnRequired?.(column) ?? false;\n const checked = required ? true : column.getIsVisible();\n return (\n <label\n key={column.id}\n data-testid={getTestId?.('option', column.id)}\n data-required={required ? 'true' : 'false'}\n className={cn(\n 'flex items-center gap-2 px-2 py-1.5 rounded-sm text-sm cursor-pointer',\n required\n ? 'opacity-60 cursor-not-allowed'\n : 'hover:bg-accent hover:text-accent-foreground',\n )}\n >\n <Checkbox\n data-testid={getTestId?.('checkbox', column.id)}\n checked={checked}\n disabled={required}\n onCheckedChange={(value) => {\n if (required) return;\n column.toggleVisibility(!!value);\n }}\n />\n <span className=\"flex-1 truncate\">{label}</span>\n </label>\n );\n })}\n </div>\n {(onReset || (footerActions && footerActions.length > 0)) && (\n <div className=\"mt-2 space-y-0.5 border-t pt-2\">\n {onReset && (\n <button\n type=\"button\"\n onClick={onReset}\n data-testid={getTestId?.('reset')}\n className=\"w-full rounded-sm px-2 py-1 text-left text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {resetLabelText}\n </button>\n )}\n {footerActions?.map((a) => (\n <button\n key={a.label}\n type=\"button\"\n onClick={a.onClick}\n data-testid={a.testid}\n className=\"w-full rounded-sm px-2 py-1 text-left text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {a.label}\n </button>\n ))}\n </div>\n )}\n </PopoverContent>\n </Popover>\n );\n}\n","'use client';\nimport { useMemo } from 'react';\nimport { IconColumns3 } from '@tabler/icons-react';\nimport type { ColumnDef, VisibilityState } from '@tanstack/react-table';\nimport { getCoreRowModel, useReactTable } from '@tanstack/react-table';\nimport { resolveFieldLabel, type ResourceDef, declaredText } from '@burojs/core';\nimport { type RowRecord, useApp, useI18nCaps, useT } from '@burojs/react';\nimport { DataTableViewOptions } from '../data-table/data-table-view-options.js';\nimport { capsOf, columnTarget } from '../resource/column-target.js';\n\n/**\n * Storage-shape adapter around `<DataTableViewOptions>` (the canonical\n * shadcn-Tasks-style column visibility dropdown). The primitive\n * itself reads/writes TanStack's `VisibilityState` (`Record<columnId,\n * boolean>`); the playground persists visibility as `string[]` of\n * visible column ids in the URL at `?<resource>.cols=col1,col2,col3`\n * via `useResourceUrlState`'s `setVisibleColumns` setter (A3.1-A3.3).\n * This wrapper bridges those two shapes: it spins up a tiny\n * visibility-only `useReactTable`, derives the visibility map from\n * the parent's `visibleColumns`, and projects `onColumnVisibilityChange`\n * back into the `string[]` shape the parent owns.\n *\n * Stage-1 ColumnsToggle migration completed via this adapter — the\n * primitive's contracts (testid surface, `data-required=\"true\"`,\n * disabled-when-required checkbox, footer Reset, ARIA) are preserved\n * verbatim through the `getTestId` / `isColumnRequired` / `onReset`\n * callbacks.\n *\n * Reset semantics: `onChange(undefined)` reverts to defaults. The\n * parent maps `undefined → null` for `setVisibleColumns`, which drops\n * the `?<r>.cols=` URL param. The Reset button only renders when the\n * current `visibleColumns` differs from `defaultVisible` by\n * set-equality (since the merge always materialises in\n * `allAvailable` order, set-equality is sufficient).\n *\n * Visual overrides match the rest of the toolbar chrome: trigger\n * label \"Columns\" with no icon, popover `align=\"start\" w-64 p-2`\n * with no header.\n */\nexport function ColumnsToggle({\n resource,\n def,\n allAvailable,\n required,\n visibleColumns,\n defaultVisible,\n onChange,\n onResetSizes,\n onRestoreDefaults,\n}: {\n resource: string;\n def: ResourceDef;\n allAvailable: string[];\n required: string[];\n visibleColumns: string[];\n defaultVisible: string[];\n onChange: (next: string[] | undefined) => void;\n onResetSizes?: () => void;\n onRestoreDefaults?: () => void;\n}) {\n const t = useT();\n const columnsCaps = useI18nCaps(resource);\n const app = useApp();\n const visibleSet = useMemo(() => new Set(visibleColumns), [visibleColumns]);\n const requiredSet = useMemo(() => new Set(required), [required]);\n const defaultSet = useMemo(() => new Set(defaultVisible), [defaultVisible]);\n\n // \"Differs from defaults\" means same elements (order is irrelevant —\n // the merge logic always keeps required first then optional in the\n // declared order). We compare set-equality.\n const isAtDefaults = useMemo(() => {\n if (visibleSet.size !== defaultSet.size) return false;\n for (const x of visibleSet) {\n if (!defaultSet.has(x)) return false;\n }\n return true;\n }, [visibleSet, defaultSet]);\n\n // ColumnDefs for the visibility-only TanStack table. `accessorKey`\n // is required so DataTableViewOptions' filter\n // (`typeof column.accessorFn !== 'undefined'`) accepts the column.\n const tableColumns = useMemo<ColumnDef<RowRecord>[]>(() => {\n return allAvailable.map((col) => ({\n id: col,\n accessorKey: col,\n enableHiding: true,\n }));\n }, [allAvailable]);\n\n // Project the parent's `string[]` into the TanStack VisibilityState\n // shape (`Record<columnId, boolean>`). Required columns are always\n // `true` here; non-required entries follow the parent's set.\n const visibilityState = useMemo<VisibilityState>(() => {\n const out: VisibilityState = {};\n for (const col of allAvailable) {\n out[col] = requiredSet.has(col) || visibleSet.has(col);\n }\n return out;\n }, [allAvailable, requiredSet, visibleSet]);\n\n const table = useReactTable<RowRecord>({\n data: COLUMNS_TOGGLE_EMPTY_DATA,\n columns: tableColumns,\n state: { columnVisibility: visibilityState },\n getCoreRowModel: getCoreRowModel(),\n onColumnVisibilityChange: (updater) => {\n const nextMap = typeof updater === 'function' ? updater(visibilityState) : updater;\n // Project the new visibility map back into the parent's\n // `string[]` shape, materialised in `allAvailable` order so the\n // table layout stays predictable across toggles. Required\n // columns are always included regardless of the map (the\n // primitive disables their checkbox; this is just defence in\n // depth in case TanStack ever emits a stale entry for them).\n const nextSet = new Set<string>();\n for (const col of allAvailable) {\n if (requiredSet.has(col) || nextMap[col] !== false) nextSet.add(col);\n }\n onChange(allAvailable.filter((c) => nextSet.has(c)));\n },\n });\n\n return (\n <DataTableViewOptions\n table={table}\n iconOnly\n triggerLabel={t('toolbar.columns')}\n triggerIcon={<IconColumns3 className=\"h-4 w-4\" aria-hidden=\"true\" />}\n triggerClassName=\"\"\n popoverAlign=\"end\"\n popoverContentClassName=\"w-64 p-2\"\n // Icon + title header — the trigger is icon-only, so the menu names itself\n // (consistent with the Saved-views popover).\n menuTitle={\n <span className=\"flex items-center gap-2\">\n <IconColumns3 className=\"h-4 w-4 text-muted-foreground\" aria-hidden=\"true\" />\n {t('toolbar.columns')}\n </span>\n }\n footerActions={[\n ...(onResetSizes\n ? [\n {\n label: t('toolbar.resetSizes'),\n onClick: onResetSizes,\n testid: `list-columns-reset-sizes:${resource}`,\n },\n ]\n : []),\n ...(onRestoreDefaults\n ? [\n {\n label: t('toolbar.restoreDefaults'),\n onClick: onRestoreDefaults,\n testid: `list-columns-restore-defaults:${resource}`,\n },\n ]\n : []),\n ]}\n getColumnLabel={(column) => {\n // A dotted column is labelled by the field it reads across its relations.\n const target = columnTarget(app.registry, resource, column.id);\n if (target !== undefined)\n return resolveFieldLabel(\n capsOf(columnsCaps, target.resource),\n target.name,\n declaredText('field', target.field, 'label'),\n );\n return resolveFieldLabel(\n columnsCaps,\n column.id,\n declaredText('field', def.fields?.[column.id], 'label'),\n );\n }}\n isColumnRequired={(column) => requiredSet.has(column.id)}\n getTestId={(role, columnId) => {\n switch (role) {\n case 'trigger':\n return `list-columns:${resource}`;\n case 'menu':\n return `list-columns-menu:${resource}`;\n case 'option':\n return `list-columns-option:${resource}:${columnId ?? ''}`;\n case 'checkbox':\n return `list-columns-checkbox:${resource}:${columnId ?? ''}`;\n default:\n return undefined;\n }\n }}\n />\n );\n}\n\n// Module-level constant so the `data` array reference stays stable\n// across renders — TanStack rebuilds row models when `data` identity\n// changes, and the visibility-only table never reads rows anyway.\nconst COLUMNS_TOGGLE_EMPTY_DATA: RowRecord[] = [];\n","'use client';\nimport type { ReactElement } from 'react';\nimport { useResourceListContext } from '@burojs/react';\nimport { ColumnsToggle } from '../columns-toggle.js';\nimport { listPiece } from './piece.js';\nimport { useListSurface, usePieceMount } from './pieces-context.js';\n\n/** The column picker; it renders nothing unless the list draws a table. */\nfunction ListColumnsView() {\n usePieceMount('columns');\n const { def, columns } = useResourceListContext();\n const { resource, tableView } = useListSurface();\n if (!def || !tableView) return null;\n return (\n <ColumnsToggle\n resource={resource}\n def={def}\n allAvailable={columns.all}\n required={columns.required}\n visibleColumns={columns.visible}\n defaultVisible={columns.defaultVisible}\n onChange={columns.setVisible}\n onResetSizes={() => columns.restoreDefaults('sizes')}\n // Sizes + pins + order (via the token) AND visibility + sort.\n onRestoreDefaults={() => columns.restoreDefaults()}\n />\n );\n}\n\nexport const ListColumns: () => ReactElement | null = listPiece('ListColumns', ListColumnsView);\n","'use client';\nimport { useAvailability, useEntryGate, useOptionalT } from '@burojs/react';\nimport { DisabledAction } from '../actions/action-button.js';\nimport { useLinkComponent } from '../layout/link-component.js';\nimport { Button, type ButtonProps } from '../primitives/button.js';\nimport { Icon } from '../primitives/icon.js';\n\nexport interface CreateButtonProps {\n /** Resource this creates. Required — the button gates itself. */\n resource: string;\n /** Target create route, e.g. `resourceCreateHref(def, resource)`. Ignored with `onOpen`. */\n href: string;\n /**\n * Opens the create somewhere other than a route — a resource without a create page opens its\n * `quick.create` (P3-19). The control is then a button, drawn when the entry gate answers\n * `open` (inert with its reason when `disabled`, absent otherwise, and while access loads).\n */\n onOpen?: () => void;\n /** `data-testid` for the button. */\n testid?: string;\n size?: ButtonProps['size'];\n variant?: ButtonProps['variant'];\n /** Override the label. Defaults to the localized `actions.create`. */\n label?: React.ReactNode;\n className?: string;\n}\n\n/**\n * The list-page \"create\" affordance.\n *\n * Lives in the library so its label resolves from the framework i18n bundle\n * (`actions.create`) rather than a hardcoded `+ Create` in each app's list\n * toolbar. Navigation goes through the installed `LinkComponent`, so SPA\n * routing is preserved. Falls back to English outside a `BuroProvider`.\n *\n * Gates itself against the availability gate (`useAvailability`): renders\n * nothing for `absent`/`hidden`, a focusable `aria-disabled` control with a\n * toast reason for `disabled`, and the normal link for `available`.\n */\nexport function CreateButton({\n resource,\n href,\n testid,\n size = 'sm',\n variant,\n label,\n className,\n onOpen,\n}: CreateButtonProps): React.ReactElement | null {\n const t = useOptionalT();\n const Link = useLinkComponent();\n const availability = useAvailability(resource, 'create');\n const gate = useEntryGate();\n const text = label ?? t('actions.create', { defaultValue: 'Create' });\n\n if (onOpen !== undefined) {\n const answer = gate(resource, 'create');\n if (answer.state === 'disabled')\n return (\n <DisabledAction\n reason={availability.state === 'disabled' ? availability.reason : undefined}\n label={text}\n icon=\"Plus\"\n testid={testid}\n size={size}\n variant={variant}\n className={className}\n resource={resource}\n />\n );\n if (answer.state !== 'open') return null;\n return (\n <Button\n type=\"button\"\n size={size}\n variant={variant}\n data-testid={testid}\n className={className}\n onClick={onOpen}\n >\n <Icon name=\"Plus\" className=\"mr-1 h-4 w-4\" />\n {text}\n </Button>\n );\n }\n\n // `absent` and `hidden` render identically here — see the note on the\n // `Availability` type. Nothing about this button should depend on WHY.\n if (availability.state === 'absent' || availability.state === 'hidden') return null;\n\n if (availability.state === 'disabled') {\n /*\n `DisabledAction`, not a second implementation of it. It already owns the\n whole denied-affordance contract — reason → resolved via\n `resolveContentSlot` (bundle key or literal, never a `console.warn`) →\n the localized `availability.denied` fallback, `aria-disabled` instead of\n the native `disabled` attribute (a natively disabled element takes no\n focus and fires no events, so a keyboard or screen-reader user would get\n no explanation at all), the toast on click, and the `opacity-60` dimming.\n Forked here, this branch drifted: it had every behaviour EXCEPT the\n dimming, so the one denied affordance an adopter meets first was also the\n only one that looked fully live.\n */\n return (\n <DisabledAction\n reason={availability.reason}\n label={text}\n icon=\"Plus\"\n testid={testid}\n size={size}\n variant={variant}\n className={className}\n resource={resource}\n />\n );\n }\n\n return (\n /*\n ⚠️ `asChild`, so this is ONE <a> rather than a <button> nested inside one.\n Nested interactive content is invalid HTML, gives a keyboard user two tab\n stops for a single control, and makes a screen reader announce\n «Create» twice (`link \"Create\" › button \"Create\"`).\n */\n <Button asChild size={size} variant={variant} data-testid={testid} className={className}>\n <Link href={href}>\n <Icon name=\"Plus\" className=\"mr-1 h-4 w-4\" />\n {text}\n </Link>\n </Button>\n );\n}\n","'use client';\nimport type { ReactElement } from 'react';\nimport { useResourceListContext } from '@burojs/react';\nimport { CreateButton } from '../../resource/create-button.js';\nimport { listPiece } from './piece.js';\nimport { useListSurface, usePieceMount } from './pieces-context.js';\n\n/** The route list's primary action: create, as a page link or (without a create page) its quick form. */\nfunction ListCreateView() {\n usePieceMount('create');\n const { def, routing } = useResourceListContext();\n const { resource, route, openCreate } = useListSurface();\n if (!def || !route) return null;\n return (\n <CreateButton\n resource={resource}\n href={routing.createHref}\n testid={`list-create:${resource}`}\n {...(openCreate === undefined ? {} : { onOpen: openCreate })}\n />\n );\n}\n\nexport const ListCreate: () => ReactElement | null = listPiece('ListCreate', ListCreateView);\n","'use client';\nimport { type ExportTarget, composeListFilter } from '@burojs/core';\nimport {\n useCapability,\n useOptionalDataRuntime,\n useOptionalT,\n useResourceExport,\n useResourceListContext,\n useTestIds,\n} from '@burojs/react';\nimport { IconDownload } from '@tabler/icons-react';\nimport * as React from 'react';\nimport { cn } from '../lib/cn.js';\nimport { Button } from '../primitives/button.js';\nimport { ExportDialog } from './export-dialog.js';\n\nexport interface ExportButtonProps {\n resource: string;\n className?: string;\n}\n\n/** One `providerQuery` warning per resource, not one per render — the same\n * dedup idiom `useResourceExport`'s own report sets use. */\nconst warnedProviderQueryResources = new Set<string>();\n\n/**\n * Toolbar entry point (Task 8) — mounted by `<ResourceListPage>` next to the\n * saved-views controls. Opens the self-hosted `<ExportDialog>` (Task 7 —\n * there is no `openExportDialog`; the caller drives `open` itself) with a\n * `filter`-kind target built from the LIVE list context, never from\n * `useResourceListContext` inside the dialog (Task 7's dialog is scope-blind\n * on purpose — see its own doc comment).\n *\n * Gated on TWO independent axes, both evaluated before any hook-order-unsafe\n * early return:\n * - `useResourceExport(resource).available` — whether an exporter resolves\n * at all (a resource `export: false` setting, or nothing configured).\n * Gated on `available`, never on truthiness of `exporter` — the key is\n * genuinely absent when unavailable (`useResourceExport`'s own contract).\n * - the capability engine, asked directly via `useCapability('run', {\n * target: { kind: 'action', name: 'export' } })` — the SAME axis\n * `resolveAvailability` resolves for every other action (capability\n * `'run'`, target `{ kind: 'action', name: <op> }`; see\n * `reference_capability_rule_shape` — the array-based deny trap). NOT\n * `useAvailability`/`useAvailabilityResolver`: those layer a static\n * \"is this a DECLARED operation\" existence check in front of the rule\n * engine (`resolveStaticAvailability`), and `'export'` is neither a\n * system operation nor a declared `actions.item/resource/bulk` entry —\n * every call would report `absent` (with a `console.error`) regardless\n * of any rule. `useResourceExport` already answers the existence\n * question; `useCapability` is asked ONLY about permission.\n */\nexport function ExportButton({\n resource,\n className,\n}: ExportButtonProps): React.ReactElement | null {\n // `useResourceExport` needs a native data runtime and throws without one\n // (`useDataRuntime`, not the optional variant — export genuinely cannot\n // function without one, the same stance `useAction` takes). Several\n // `<ResourceListPage>` tests mount it under \"compat mode\" (`<BuroProvider>`\n // with no `dataRuntime` prop — the established fixture for component-only\n // tests that never touch data),\n // where NOTHING in this package may call those hooks at all. Gating on\n // `useOptionalDataRuntime()` — which never throws — before rendering\n // {@link ExportButtonActive} keeps this component safe to mount\n // unconditionally in `<ResourceListPage>` regardless of which mode the\n // host is running in; `ExportButtonActive` then calls the hard hooks\n // unconditionally, because it only ever mounts once a runtime already\n // exists — no hook is ever conditionally called WITHIN one component.\n const hasDataRuntime = useOptionalDataRuntime() !== null;\n if (!hasDataRuntime) return null;\n return <ExportButtonActive resource={resource} className={className} />;\n}\n\nfunction ExportButtonActive({ resource, className }: ExportButtonProps): React.ReactElement | null {\n const list = useResourceListContext();\n // No `{ load: true }`: this trigger only needs to know whether an exporter is\n // REGISTERED, and asking for the instance here would fetch a deferred\n // exporter's chunk on every list page that shows the button. `prefetch` is\n // the deliberate exception — see `onMouseEnter`/`onFocus` below.\n const { available, prefetch } = useResourceExport(resource);\n const capability = useCapability('run', {\n resource,\n target: { kind: 'action', name: 'export' },\n // Matches the mode `useAvailabilityResolver` uses for list-surface\n // affordances (row actions, the create button) — a rule branching on\n // `ctx.mode` must see the same answer from every list-scoped gate.\n mode: 'list',\n });\n const tid = useTestIds();\n const t = useOptionalT();\n const [open, setOpen] = React.useState(false);\n\n // `useResourceList` builds its own `searchContext` as a memo on\n // `(resource, def)` (`use-resource-list.ts`), and `searchToFilter` passes\n // this object straight to a `SearchResolver`. Mirrored as a memo here for\n // the same reason it is one there: a fresh object literal per render would\n // make the target memo below recompute on every render.\n const searchContext = React.useMemo(() => ({ resource, def: list.def }), [resource, list.def]);\n\n const target = React.useMemo<ExportTarget>(() => {\n // EVERY slot the production list query folds, in the same order, through\n // the same `composeListFilter` — mirroring `use-resource-list.ts`'s own\n // call argument for argument:\n //\n // fixed (call-site narrowing, e.g. an embedded child list's FK)\n // pinned (`filters.value` — the URL-state column filters)\n // search (`filters.search` + the resource's `views.list.search` decl)\n // group (`filters.group` — the filter builder)\n //\n // ⚠️ This used to pass `{ pinned: list.filters.value }` ALONE, which is\n // only one of the four. The consequences were all reachable from the UI:\n // typing in the search box and exporting produced the WHOLE table; a\n // builder-group filter was ignored identically; and on a list narrowed by\n // a `fixed` filter the export returned rows the user's page never showed —\n // a scope leak, not merely a wrong count. It also desynchronised\n // `estimatedCount` below, which is the FULLY filtered total: a search\n // narrowing 9.8M rows to 3 gave a dialog titled \"3 rows\" whose progress\n // line read `1000/3` and whose `maxRows` pre-check was evaluated against\n // 3. Composing all four slots is what makes the filter and the count\n // describe the same set of rows again.\n //\n // `providerQuery` (the level-2 raw provider blob, merged into the list's\n // `meta`) is the ONE input the production query has that this target\n // cannot carry: `ExportTarget` has no `meta`, the controller does not\n // expose the merged `meta` at all (only `providerQuery.value` — the\n // page-supplied `opts.meta` half is private to the controller), and a raw\n // provider blob is by definition uninterpretable to an exporter that\n // bypasses the provider. A `providerQuery`-narrowed list therefore exports\n // WITHOUT that narrowing. Rather than leave that silent, the effect below\n // warns once — and the adopter guide states it.\n const filter = composeListFilter({\n fixed: list.filters.fixed,\n pinned: list.filters.value,\n group: list.filters.group,\n search: list.filters.search,\n // The list's own declaration: a placement's search box, not the target's (S5 review I2).\n // No search at all when its user has none left (P5 spec 3.7): the declared set is not a\n // fallback for a narrowed-away one.\n searchDecl: list.filters.searchEnabled\n ? (list.filters.searchDecl ?? list.def?.views?.list?.search)\n : undefined,\n searchContext,\n });\n const sort = list.sorting.value;\n return {\n kind: 'filter',\n ...(filter === undefined ? {} : { filter }),\n ...(sort.length > 0 ? { sort } : {}),\n };\n }, [\n list.filters.fixed,\n list.filters.value,\n list.filters.group,\n list.filters.search,\n list.filters.searchDecl,\n list.filters.searchEnabled,\n list.def,\n searchContext,\n list.sorting.value,\n ]);\n\n // Loud, deduped, and gated on the button actually being usable — an\n // export-less resource that uses `providerQuery` (the Temporal workflows\n // list, today's only consumer) must not warn about an export it can never\n // start. In an effect, not in the memo above, because the memo runs before\n // the gates are known.\n React.useEffect(() => {\n if (!available || !capability.allowed) return;\n if (list.providerQuery.value === undefined) return;\n if (warnedProviderQueryResources.has(resource)) return;\n warnedProviderQueryResources.add(resource);\n // One long template literal rather than a wrapped concatenation: biome's\n // `useTemplate` rejects the latter, and breaking it across source lines\n // inside the backticks would embed real newlines in the message.\n console.warn(\n `[buro] ExportButton('${resource}'): this list is narrowed by \\`providerQuery\\` (a raw provider blob), which an export target cannot carry — the exported file will NOT be narrowed by it. See docs/adopters/data-export.md.`,\n );\n }, [available, capability.allowed, list.providerQuery.value, resource]);\n\n // Both gates evaluated above, unconditionally, so hook order never\n // depends on either answer — only the RENDER branches on them.\n // A forbidden read lists nothing, so it exports nothing (the list, its count and its export\n // send the same predicates).\n if (!available || !capability.allowed || list.isForbidden) return null;\n\n return (\n <>\n <Button\n type=\"button\"\n variant=\"outline\"\n // Icon-only, matching its immediate neighbour in the toolbar row — the\n // columns toggle renders through `<DataTableViewOptions iconOnly>`,\n // which is `size=\"icon\"` narrowed to `h-8 w-8` so it lines up with the\n // `sm` controls around it. The label survives as BOTH the accessible\n // name and the hover tooltip; dropping it from the DOM without\n // `aria-label` would leave the control announced only as \"button\".\n size=\"icon\"\n aria-label={t('export.button.label')}\n title={t('export.button.label')}\n className={cn('h-8 w-8', className)}\n data-testid={tid.exportButton(resource)}\n onClick={() => setOpen(true)}\n // Prefetch the exporter chunk on the first sign of intent, so a\n // deferred registration is usually already loaded by the time the\n // dialog OPENS (it renders a \"preparing\" state otherwise). Both\n // pointer AND keyboard paths, because focus is how a keyboard user\n // reaches this button. Fire-and-forget and idempotent — `prefetch()`\n // joins the one in-flight load and is a no-op once loaded, or when the\n // app registered a ready `Exporter` and there is nothing to fetch.\n // Unreachable for a resource with no export at all: this component\n // already returned `null` above in that case.\n onMouseEnter={prefetch}\n onFocus={prefetch}\n >\n <IconDownload className=\"size-4\" aria-hidden=\"true\" />\n </Button>\n {/* Mounted unconditionally — a closed dialog asks `useResourceExport` for\n nothing (it passes `{ load: open }`), so keeping it here costs no chunk\n fetch, and it is what lets a failed load be retried by simply\n reopening. */}\n <ExportDialog\n open={open}\n onOpenChange={setOpen}\n resource={resource}\n target={target}\n visibleColumns={list.columns.visible}\n estimatedCount={list.pagination.total}\n scope={list.scope}\n />\n </>\n );\n}\n","'use client';\nimport type { ReactElement } from 'react';\nimport { useResourceListContext } from '@burojs/react';\nimport { ExportButton } from '../../export/export-button.js';\nimport { listPiece } from './piece.js';\nimport { useListSurface, usePieceMount } from './pieces-context.js';\n\n/**\n * The export trigger. It sits directly after the columns toggle: both are icon-only controls over\n * the SAME thing the page is showing, and the export dialog's default column scope is literally\n * the toggle's current selection.\n */\nfunction ListExportView() {\n usePieceMount('export');\n const { def } = useResourceListContext();\n const { resource, exportable } = useListSurface();\n if (!def || !exportable) return null;\n return <ExportButton resource={resource} />;\n}\n\nexport const ListExport: () => ReactElement | null = listPiece('ListExport', ListExportView);\n","'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { useT } from '@burojs/react';\nimport { Input } from '../primitives/input.js';\n\n/**\n * Debounced free-form search box. Keeps the typed text in LOCAL state so\n * keystrokes feel instant (only this component re-renders per key), and\n * commits to the URL-state setter (`onCommit`) after a short pause — so\n * a `router.replace` + `useList` refetch fires once per typing burst, not\n * once per character. Re-syncs from the external `value` when it changes\n * (deep-link / saved view / clear-all).\n */\nexport function ListSearchInput({\n resource,\n label,\n value,\n onCommit,\n placeholder,\n}: {\n resource: string;\n label: string;\n value: string;\n onCommit: (next: string) => void;\n /**\n * Override the placeholder. The default falls back to `toolbar.searchBy`\n * (\"Search by {name}…\") fed by `label` — a plain per-field template that\n * promises nothing about HOW the query is matched. Every host in this\n * repo passes an explicit `placeholder` instead of relying on this\n * default: `<ResourceListPage>` distinguishes a declarative\n * `views.list.search` (names its first field) from a resolver (generic\n * `list.search` label, since the framework cannot know what a resolver\n * matches), and a `related-list` placement names its own search field.\n */\n placeholder?: string;\n}) {\n const t = useT();\n const [text, setText] = useState(value);\n const lastPushedRef = useRef(value);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Adopt the external value ONLY when it changed from outside (clear-all,\n // saved view, deep link) — never when it's the echo of our own debounced\n // commit. Syncing on every external change would clobber characters the\n // user typed during the debounce window (they vanish, then reappear, and\n // the caret jumps).\n useEffect(() => {\n if (value !== lastPushedRef.current) {\n setText(value);\n lastPushedRef.current = value;\n }\n }, [value]);\n\n useEffect(\n () => () => {\n if (timerRef.current) clearTimeout(timerRef.current);\n },\n [],\n );\n\n return (\n <Input\n type=\"search\"\n placeholder={placeholder ?? t('toolbar.searchBy', { params: { name: label } })}\n value={text}\n data-testid={`list-search:${resource}`}\n // Fixed width once the row can hold search + funnel side-by-side (≥420px),\n // full-width only below that — where the RIGHT action group has already\n // wrapped to the line above, so the search fills the freed left line\n // instead of forcing the funnel onto its own row mid-band.\n className=\"h-8 w-full min-[420px]:w-72\"\n onChange={(e) => {\n const next = e.target.value;\n setText(next);\n if (timerRef.current) clearTimeout(timerRef.current);\n timerRef.current = setTimeout(() => {\n lastPushedRef.current = next;\n onCommit(next);\n }, 300);\n }}\n />\n );\n}\n","'use client';\nimport { type SearchDecl, resolveContentSlot, resolveFieldLabel, declaredText } from '@burojs/core';\nimport { useI18nCaps, useResourceListContext, useT } from '@burojs/react';\nimport { Button } from '../../primitives/button.js';\nimport { ListSearchInput } from '../list-search-input.js';\nimport { FilterBuilder } from './filter-builder.js';\n\n/**\n * The default `list.filters.<resource>` content — search box, pinned\n * controls, the builder popover trigger, applied-filter badges and a\n * \"Clear all\" action, left to right. Props-free: like every list slot, it\n * reads the live controller from `useResourceListContext()` rather than a\n * prop chain, which is the SAME contract a registered\n * `list.filters.<resource>` slot fulfils — an adopter that wants a\n * different layout composes `FilterBuilder` (or its own `FilterPanel` /\n * `FilterBadges` / `PinnedFilterControls` / `FilterValueControl`, all\n * exported) into its own region instead of forking this file.\n *\n * A THIN wrapper: everything that needs the list controller (the search\n * box, its placeholder, \"Clear all\") stays here — that's the page's\n * concern, not the builder's — and everything else (the pinned controls,\n * the panel, the badges, and the `open`/`focusPath`/`externalRemoval`\n * wiring between them) is `<FilterBuilder>`'s job, which has no controller\n * dependency at all and so can also be mounted where there isn't one (the\n * relation picker's advanced-search dialog, SP3).\n *\n * `<ResourceListPage>` owns mounting: it renders `<FilterRegion>` only when\n * no `list.filters.<resource>` slot is registered, so this component itself\n * never has to know about the override ladder.\n */\nexport function FilterRegion({\n search,\n}: {\n /**\n * The search a placement declares (`related-list`'s `search` prop), `null` for none; the route\n * list omits it and reads the resource's `views.list.search`.\n */\n readonly search?: SearchDecl | null;\n} = {}): React.ReactElement {\n const { resource, def, filters, pagination, access } = useResourceListContext();\n const t = useT();\n const listCaps = useI18nCaps(resource);\n\n const testIdBase = `list-filter:${resource}`;\n\n // The search BOX (and its placeholder) needs to know whether search is\n // declared at all — declared per resource at `views.list.search`. The\n // controller reads the same declaration to compose the actual filter.\n //\n // A declaration NAMES a field, so the placeholder can say what it searches\n // (`toolbar.searchBy`, \"Search by {name}…\" — mirrors the embedded\n // sub-resource tab's own search box). A resolver has no single field to\n // point at — the framework cannot know whether it matches an id, a GTIN,\n // several columns, or none of those — so it gets the generic `list.search`\n // label instead. Neither form ever advertises the deleted numeric-`#`/`№`\n // branch (`toolbar.searchByIdOr` doesn't exist for a reason: see\n // `SearchDecl`'s doc in `@burojs/core`).\n const searchDecl = search === undefined ? def?.views?.list?.search : (search ?? undefined);\n const searchField =\n searchDecl !== undefined && typeof searchDecl !== 'function'\n ? (() => {\n // The first field the user may view: a hidden field's label never reaches the placeholder.\n const visible = searchDecl.fields\n .map((entry) => (typeof entry === 'string' ? entry : entry.field))\n .find((name) => access.fieldVisible(name));\n return visible;\n })()\n : undefined;\n const searchGenericLabel = resolveContentSlot(listCaps, ['list.search']) ?? 'Search';\n const searchLabel = searchField\n ? resolveFieldLabel(\n listCaps,\n searchField,\n declaredText('field', def?.fields[searchField], 'label'),\n )\n : searchGenericLabel;\n const searchPlaceholder = searchField\n ? t('toolbar.searchBy', { params: { name: searchLabel } })\n : searchGenericLabel;\n\n return (\n <div className=\"flex flex-wrap items-center gap-2\">\n {searchDecl !== undefined && filters.searchEnabled && (\n <ListSearchInput\n resource={resource}\n label={searchLabel}\n placeholder={searchPlaceholder}\n value={filters.search}\n onCommit={(v) => {\n // ⚠️ `filters.setSearch` is a pure pass-through — the page reset\n // has always lived at this call site, and without it a search\n // typed on page 3 keeps the user on page 3 while showing page-1\n // results.\n pagination.setPage(1);\n filters.setSearch(v);\n }}\n />\n )}\n <FilterBuilder\n group={filters.group}\n setGroup={filters.setGroup}\n available={filters.available}\n fixed={filters.fixed}\n pinnedFields={filters.pinnedFields}\n pinnedValue={filters.value}\n setPinnedValue={filters.set}\n setPage={pagination.setPage}\n testIdBase={testIdBase}\n />\n {filters.isFiltered && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n data-testid={`${testIdBase}:clear-all`}\n onClick={filters.clearAll}\n >\n {t('filters.clearAll')}\n </Button>\n )}\n </div>\n );\n}\n","'use client';\nimport type { ReactElement } from 'react';\nimport { useResourceListContext } from '@burojs/react';\nimport { FilterRegion } from '../filter-builder/filter-region.js';\nimport { listPiece } from './piece.js';\nimport { useListSurface, usePieceMount } from './pieces-context.js';\n\n/**\n * The search box and the filter builder. `list.filters.<r>` replaces its CONTENTS, never the\n * group itself: the wrapper's `min-w-[21rem] flex-1` is the whole reason the right-hand group (and\n * not the search box) is what wraps on overflow, so the two-group geometry stays framework-owned\n * and a slot cannot break it. The test id switches with the content rather than lying:\n * `list-filters:*` names the standard region, `list-filters-slot:*` names an override.\n */\nfunction ListFiltersView() {\n usePieceMount('filters');\n const { def } = useResourceListContext();\n const { resource, route, searchDecl, FiltersSlot } = useListSurface();\n if (!def) return null;\n return (\n <div\n className=\"min-w-[21rem] flex-1\"\n data-testid={FiltersSlot ? `list-filters-slot:${resource}` : `list-filters:${resource}`}\n >\n {FiltersSlot ? (\n <FiltersSlot />\n ) : (\n <FilterRegion {...(route ? {} : { search: searchDecl ?? null })} />\n )}\n </div>\n );\n}\n\nexport const ListFilters: () => ReactElement | null = listPiece('ListFilters', ListFiltersView);\n","'use client';\nimport type { ReactElement } from 'react';\nimport { resolveActionDensity, resolveActionSurfaceMode } from '@burojs/core';\nimport {\n resourceFlowsOn,\n useFlowRowResolver,\n useOptionalT,\n useResourceListContext,\n useTestIds,\n} from '@burojs/react';\nimport { IconDots } from '@tabler/icons-react';\nimport { Fragment, useState } from 'react';\nimport { FlowActionButton, FlowMenuItem } from '../../flows/flow-action-button.js';\nimport { RuntimeFlowRunner, preloadFlowRuntime } from '../../flows/load-runtime.js';\nimport { Button } from '../../primitives/button.js';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from '../../primitives/dropdown-menu.js';\nimport { listPiece } from './piece.js';\nimport { useListSurface, usePieceMount } from './pieces-context.js';\n\n/**\n * The resource-level flows (`toolbar.resource`) of the route list: one control per flow by its\n * `surfaces.list` — a labelled button (`regular`, and `auto`), an icon button (`compact`) or an\n * entry of one \"More actions\" menu (`menu`, the default) — and nothing for `false`. Each control\n * is decided by the flow's gate without a run and without a record: denied is absent, disabled is\n * inert with its reason, and a gate still deciding draws nothing, so no control (and no request)\n * appears before access is known. A `related-list` placement draws none of it.\n */\nfunction ListFlowsView() {\n usePieceMount('flows');\n const t = useOptionalT();\n const tid = useTestIds();\n const { def } = useResourceListContext();\n const { resource, route } = useListSurface();\n const resolve = useFlowRowResolver(resource);\n // A flow chosen from the menu runs here, outside the menu: the menu closes normally and the\n // run (its host, its confirm, its outcome) outlives it.\n const [flowFor, setFlowFor] = useState<string | null>(null);\n if (!def || !route) return null;\n const entries = resourceFlowsOn(def, 'list').flatMap((flow) => {\n const control = resolve(flow.name, undefined);\n if (control.state === 'absent' || control.state === 'undecided') return [];\n const mode = resolveActionSurfaceMode(flow.surfaces, 'list');\n return [{ flow, control, density: resolveActionDensity(mode, 'list') }];\n });\n const standalone = entries.filter((entry) => entry.density !== null);\n const menu = entries.filter((entry) => entry.density === null);\n if (entries.length === 0) return null;\n return (\n <>\n {standalone.map(({ flow, density }) => (\n <FlowActionButton\n key={flow.name}\n resource={resource}\n actionName={flow.name}\n scope=\"list\"\n // `density` is only null for the menu entries filtered out above.\n density={density ?? 'regular'}\n />\n ))}\n {menu.length > 0 && (\n <DropdownMenu\n modal={false}\n onOpenChange={(open) => {\n if (open) preloadFlowRuntime();\n }}\n >\n <DropdownMenuTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"gap-1.5\"\n data-testid={tid.listFlowsMenu(resource)}\n aria-label={t('list.flowsMenu', { defaultValue: 'More actions' })}\n >\n <IconDots className=\"h-4 w-4\" aria-hidden=\"true\" />\n {t('list.flowsMenu', { defaultValue: 'More actions' })}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {menu.map(({ flow, control }) => (\n <Fragment key={flow.name}>\n <FlowMenuItem\n resource={resource}\n actionName={flow.name}\n scope=\"list\"\n control={control}\n active={flowFor !== null}\n onRun={() => setFlowFor(flow.name)}\n />\n </Fragment>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n {flowFor !== null ? (\n <RuntimeFlowRunner\n resource={resource}\n actionName={flowFor}\n scope=\"list\"\n onClose={() => setFlowFor(null)}\n />\n ) : null}\n </>\n );\n}\n\nexport const ListFlows: () => ReactElement | null = listPiece('ListFlows', ListFlowsView);\n","'use client';\nimport type { ReactElement } from 'react';\nimport { useResourceListContext, useT } from '@burojs/react';\nimport { IconRefresh } from '@tabler/icons-react';\nimport { Button } from '../../primitives/button.js';\nimport { listPiece } from './piece.js';\nimport { useListSurface, usePieceMount } from './pieces-context.js';\n\n/**\n * The live-list pause toggle (`views.list.refetchInterval`). `live` is undefined for any resource\n * that declares no interval, and its absence is exactly what hides this control — a static list's\n * toolbar is unchanged. `aria-pressed` announces the state to assistive tech; the icon spins only\n * while polling is actually running.\n */\nfunction ListLiveView() {\n usePieceMount('live');\n const t = useT();\n const { def, live } = useResourceListContext();\n const { resource } = useListSurface();\n if (!def || !live) return null;\n return (\n <Button\n type=\"button\"\n variant={live.isPaused ? 'outline' : 'default'}\n size=\"sm\"\n aria-pressed={!live.isPaused}\n data-testid={`list-live:${resource}`}\n onClick={() => (live.isPaused ? live.resume() : live.pause())}\n >\n <IconRefresh className={live.isPaused ? undefined : 'animate-spin'} aria-hidden=\"true\" />\n {live.isPaused ? t('toolbar.liveOff') : t('toolbar.liveOn')}\n </Button>\n );\n}\n\nexport const ListLive: () => ReactElement | null = listPiece('ListLive', ListLiveView);\n","'use client';\nimport { useMemo, useState } from 'react';\nimport { IconBookmark, IconCopy, IconPencil, IconTrash } from '@tabler/icons-react';\nimport {\n declaredText,\n humanizeKey,\n resolveContentSlot,\n savedViewKey,\n type I18nCaps,\n type SavedViewDef,\n type UiSettingScope,\n type UiSettingsIssue,\n} from '@burojs/core';\nimport { LOCAL_USER_SCOPE_ID, useI18nCaps, useOptionalT, type SavedViewEntry } from '@burojs/react';\nimport { Button } from '../primitives/button.js';\nimport { Popover, PopoverContent, PopoverTrigger } from '../primitives/popover.js';\nimport { cn } from '../lib/cn.js';\n\n/**\n * Saved-views dropdown for the list-page filter row.\n *\n * Renders as a popover (matching the existing `<DataTableViewOptions>`\n * pattern — `<Dropdown menu>` is not part of this package's primitive\n * surface, and the popover with role=\"menu\" carries the same UX +\n * keyboard semantics for our purposes).\n *\n * Sections (top to bottom), Task 9 — SCOPE-GROUPED, not hardcoded:\n * 1. An adapter-reported issues notice, when `issues` is non-empty —\n * rendered WITHOUT hiding any otherwise-valid group below it.\n * 2. Adopter-defined views (`adopterViews`, no scope, always read-only —\n * header rendered only when at least one OTHER section also exists,\n * otherwise the single section speaks for itself).\n * 3. One group per DISTINCT `entry.scope.id` found in `entries`, in the\n * order each scope first appears — header is the scope's OWN\n * `label`, verbatim, EXCEPT the framework's own local-user scope\n * (`LOCAL_USER_SCOPE_ID`), whose data-layer placeholder label is\n * swapped for a reactive i18n one (`toolbar.viewsMyScope`). Every\n * other (adopter-supplied) scope label is NEVER rewritten.\n * 4. \"Save current view…\" — hidden entirely when `canSaveCurrent` is\n * `false` (no writable scope, spec §5: \"empty `writeScopes` means the\n * current user cannot create … a value\").\n * 5. \"Manage views…\" — rendered only when at least one entry exists.\n *\n * Each entry row (never an adopter row — those carry no per-entry\n * permissions) offers inline Rename / Fork / Delete affordances, gated on\n * `entry.permissions.update` / `.fork` / `.remove` respectively — hidden,\n * not merely disabled, when the permission is absent (they are UI hints;\n * the adapter re-authorizes every mutation regardless, spec §4). Fork is\n * ADDITIONALLY gated on `canFork` (`writeScopes.length > 0`, spec §5):\n * forking always needs somewhere writable to land, so a fork-permitted\n * entry never renders a clickable-but-inert Fork button when there is no\n * write scope at all — the same \"hide, don't just disable\" rule\n * `canSaveCurrent` already applies to \"Save current view…\". An entry with\n * none of the (effectively available) three actions is additionally\n * marked read-only.\n *\n * The component is purely presentational — it owns no view state. The\n * caller (page integration) wires `onApply` to the URL-state replace\n * codepath, `onSaveCurrent`/`onRenameEntry`/`onForkEntry` to their own\n * dialogs, and `onDeleteEntry`/`onManage` to the delete flow / manage\n * dialog.\n */\nexport interface SavedViewsDropdownProps {\n /**\n * The resource the views belong to. Declared views (`adopterViews`) read their label from\n * `resources.<resource>.savedViews.<id>` in the bundle (that resource's own entry only, never\n * `resources._` or `common`); without it they render as declared.\n * User-saved `entries` are user data and always render as written.\n */\n resource?: string;\n /** Adopter-defined views from `def.views.list.savedViews`. Always read-only. */\n adopterViews: SavedViewDef[];\n /** Adapter-backed entries, WITH scope/permission metadata (Task 9). */\n entries: SavedViewEntry[];\n /** Adapter-reported issues for this collection (spec §13) — rendered, never hiding valid entries. */\n issues?: readonly UiSettingsIssue[];\n /** Click on a view item — apply its state. */\n onApply: (view: SavedViewDef) => void;\n /** Click on \"Save current view…\". Caller shows a label-prompt dialog. */\n onSaveCurrent: () => void;\n /** Whether saving is possible at all (`writeScopes.length > 0`, spec §5). Default `true`. */\n canSaveCurrent?: boolean;\n /** Click on \"Manage views…\". Caller shows a list dialog with delete/rename. */\n onManage: () => void;\n /** Click on an entry's Rename action. Shown only when `entry.permissions.update`. */\n onRenameEntry?: (entry: SavedViewEntry) => void;\n /** Click on an entry's Delete action. Shown only when `entry.permissions.remove`. */\n onDeleteEntry?: (entry: SavedViewEntry) => void;\n /** Click on an entry's Fork action. Shown only when `entry.permissions.fork` AND `canFork`. */\n onForkEntry?: (entry: SavedViewEntry) => void;\n /**\n * Whether forking is possible AT ALL (`writeScopes.length > 0`, spec §5) —\n * combined with each entry's own `permissions.fork`. Default `true`.\n * Mirrors `canSaveCurrent`: a fork-permitted entry with nowhere writable to\n * land must not render a clickable-but-inert Fork affordance (fork always\n * needs a writable scope regardless of the per-entry flag, spec §5's\n * \"copy into a writable scope\").\n */\n canFork?: boolean;\n /**\n * Optional testid generator. Roles:\n * 'trigger' → the popover trigger button\n * 'menu' → the popover content container\n * 'view-item' → a view row (viewId passed as second arg)\n * 'save-current' → the \"Save current view…\" action row\n * 'manage' → the \"Manage views…\" action row\n * 'separator' → between sections (no viewId)\n * 'section-header' → a group header (viewId is the section name: \"adopter\" or a scope id)\n * 'rename-entry' → an entry's inline Rename button (viewId passed)\n * 'delete-entry' → an entry's inline Delete button (viewId passed)\n * 'fork-entry' → an entry's inline Fork button (viewId passed)\n * 'issues-notice' → the adapter-issues banner (no viewId)\n */\n getTestId?: (\n role:\n | 'trigger'\n | 'menu'\n | 'view-item'\n | 'save-current'\n | 'manage'\n | 'separator'\n | 'section-header'\n | 'rename-entry'\n | 'delete-entry'\n | 'fork-entry'\n | 'issues-notice',\n viewId?: string,\n ) => string | undefined;\n /** Trigger label override. Default: \"Views\". */\n triggerLabel?: string;\n /**\n * Render the trigger as a compact icon-only square button (no visible label).\n * `triggerLabel` becomes the `aria-label` + tooltip. The bookmark icon (the\n * saved-views affordance) stays.\n */\n iconOnly?: boolean;\n /** className applied to the trigger button. */\n triggerClassName?: string;\n /** className applied to the popover content. */\n popoverContentClassName?: string;\n /** Popover content alignment. Default: 'start'. */\n popoverAlign?: 'start' | 'center' | 'end';\n}\n\nfunction ViewItem({\n view,\n caps,\n resource,\n onClick,\n testid,\n}: {\n view: SavedViewDef;\n caps: I18nCaps;\n resource?: string;\n onClick: () => void;\n testid?: string;\n}) {\n // The resource's own entry only, probed absolute: a relative `savedViews.<id>` would walk\n // `resources._` and `common` and let a shared entry replace this resource's declared label.\n const own = resource === undefined ? undefined : `resources.${resource}.${savedViewKey(view.id)}`;\n const declared = declaredText('saved-view', view, 'label');\n const label =\n own === undefined\n ? (declared ?? humanizeKey(view.id))\n : (resolveContentSlot(caps, [[`${own}.label`, own]], {\n default: declared,\n humanize: () => humanizeKey(view.id),\n }) as string);\n return (\n <button\n type=\"button\"\n onClick={onClick}\n data-testid={testid}\n className=\"w-full text-left rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {label}\n </button>\n );\n}\n\n/** One adapter-backed entry row: click-to-apply plus permission-gated inline actions (Task 9). */\nfunction EntryRow({\n entry,\n onApply,\n onRename,\n onFork,\n onDelete,\n forkAvailable,\n applyTestId,\n renameTestId,\n forkTestId,\n deleteTestId,\n tr,\n}: {\n entry: SavedViewEntry;\n onApply: () => void;\n onRename?: () => void;\n onFork?: () => void;\n onDelete?: () => void;\n /** Whether ANY write scope exists at all — see `SavedViewsDropdownProps.canFork`. */\n forkAvailable: boolean;\n applyTestId?: string;\n renameTestId?: string;\n forkTestId?: string;\n deleteTestId?: string;\n tr: (key: string, fallback: string) => string;\n}) {\n const canRename = entry.permissions.update && onRename !== undefined;\n const canFork = forkAvailable && entry.permissions.fork && onFork !== undefined;\n const canDelete = entry.permissions.remove && onDelete !== undefined;\n // Effective, not raw: an entry whose only permission is `fork` but has\n // nowhere writable to land (`forkAvailable` false) offers NO action in\n // this UI, so it reads as read-only too — matching what the user can\n // actually see/click, not the adapter's raw permission bits.\n const readOnly = !canRename && !canFork && !canDelete;\n return (\n <div className=\"flex items-center gap-0.5 rounded-sm hover:bg-accent hover:text-accent-foreground\">\n <button\n type=\"button\"\n onClick={onApply}\n data-testid={applyTestId}\n className=\"min-w-0 flex-1 truncate rounded-sm px-2 py-1.5 text-left text-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {entry.label}\n </button>\n {readOnly && (\n <span className=\"shrink-0 pr-1 text-[10px] uppercase tracking-wide text-muted-foreground\">\n {tr('toolbar.viewsReadOnly', 'Read-only')}\n </span>\n )}\n {canRename && (\n <button\n type=\"button\"\n onClick={onRename}\n aria-label={tr('toolbar.viewsRename', 'Rename')}\n title={tr('toolbar.viewsRename', 'Rename')}\n data-testid={renameTestId}\n className=\"shrink-0 rounded-sm p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <IconPencil className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n </button>\n )}\n {canFork && (\n <button\n type=\"button\"\n onClick={onFork}\n aria-label={tr('toolbar.viewsFork', 'Fork')}\n title={tr('toolbar.viewsFork', 'Fork')}\n data-testid={forkTestId}\n className=\"shrink-0 rounded-sm p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <IconCopy className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n </button>\n )}\n {canDelete && (\n <button\n type=\"button\"\n onClick={onDelete}\n aria-label={tr('actions.delete', 'Delete')}\n title={tr('actions.delete', 'Delete')}\n data-testid={deleteTestId}\n className=\"shrink-0 rounded-sm p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <IconTrash className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n </button>\n )}\n </div>\n );\n}\n\nfunction SectionHeader({ label, testid }: { label: string; testid?: string }) {\n return (\n <div\n data-testid={testid}\n className=\"px-2 py-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground\"\n >\n {label}\n </div>\n );\n}\n\nfunction Separator({ testid }: { testid?: string }) {\n return <hr data-testid={testid} className=\"my-1 -mx-1 border-t\" />;\n}\n\ninterface ScopeGroup {\n scope: UiSettingScope;\n items: SavedViewEntry[];\n}\n\n/** Groups entries by `scope.id`, preserving the order each scope FIRST appears in `entries`. */\nfunction groupByScope(entries: SavedViewEntry[]): ScopeGroup[] {\n const order: string[] = [];\n const byId = new Map<string, ScopeGroup>();\n for (const entry of entries) {\n const existing = byId.get(entry.scope.id);\n if (existing) {\n existing.items.push(entry);\n } else {\n byId.set(entry.scope.id, { scope: entry.scope, items: [entry] });\n order.push(entry.scope.id);\n }\n }\n return order.map((id) => byId.get(id) as ScopeGroup);\n}\n\nexport function SavedViewsDropdown({\n resource,\n adopterViews,\n entries,\n issues = [],\n onApply,\n onSaveCurrent,\n canSaveCurrent = true,\n onManage,\n onRenameEntry,\n onDeleteEntry,\n onForkEntry,\n canFork = true,\n getTestId,\n triggerLabel = 'Views',\n iconOnly = false,\n triggerClassName = 'h-9',\n popoverContentClassName = 'w-64 p-1',\n popoverAlign = 'start',\n}: SavedViewsDropdownProps): React.ReactElement {\n const t = useOptionalT();\n const caps = useI18nCaps(resource);\n const tr = (key: string, fallback: string) => t?.(key, { defaultValue: fallback }) ?? fallback;\n const [open, setOpen] = useState(false);\n const hasAdopter = adopterViews.length > 0;\n const hasEntries = entries.length > 0;\n const groups = useMemo(() => groupByScope(entries), [entries]);\n // A header only earns its keep when there is more than one section on\n // screen — a lone section is unambiguous without one (unchanged rule\n // from the pre-Task-9 \"Defaults\"/\"Yours\" behaviour, generalized from two\n // hardcoded sections to N scope groups).\n const showHeaders = (hasAdopter ? 1 : 0) + groups.length > 1;\n\n const scopeLabel = (scope: UiSettingScope): string =>\n scope.id === LOCAL_USER_SCOPE_ID ? tr('toolbar.viewsMyScope', 'Just me') : scope.label;\n\n // Wraps an item-click handler so the popover closes after the action.\n // Saved-view click is a single-shot navigation; leaving the popover\n // open would stack a stale state on top of the new URL.\n const closeAfter = (fn: () => void) => () => {\n fn();\n setOpen(false);\n };\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size={iconOnly ? 'icon' : 'sm'}\n aria-label={iconOnly ? triggerLabel : undefined}\n title={iconOnly ? triggerLabel : undefined}\n data-testid={getTestId?.('trigger')}\n className={cn(iconOnly && 'h-8 w-8', triggerClassName)}\n >\n <IconBookmark className={cn('h-4 w-4', !iconOnly && 'mr-2')} aria-hidden=\"true\" />\n {!iconOnly && triggerLabel}\n </Button>\n </PopoverTrigger>\n <PopoverContent\n align={popoverAlign}\n className={popoverContentClassName}\n data-testid={getTestId?.('menu')}\n >\n {/* Title header — the trigger is icon-only, so the menu names itself. */}\n <div className=\"flex items-center gap-2 border-b px-2 pb-2 pt-1 text-sm font-semibold\">\n <IconBookmark className=\"h-4 w-4 text-muted-foreground\" aria-hidden=\"true\" />\n {triggerLabel}\n </div>\n {issues.length > 0 && (\n <div\n data-testid={getTestId?.('issues-notice')}\n className=\"mx-1 mt-1 rounded-sm bg-warning/15 px-2 py-1 text-xs text-warning-emphasis\"\n >\n {tr('toolbar.viewsIssuesNotice', 'Some views could not be loaded.')}\n </div>\n )}\n {hasAdopter && (\n <>\n {showHeaders && (\n <SectionHeader\n label={tr('toolbar.viewsDefaults', 'Defaults')}\n testid={getTestId?.('section-header', 'adopter')}\n />\n )}\n <div className=\"max-h-[200px] overflow-auto\">\n {adopterViews.map((v) => (\n <ViewItem\n key={v.id}\n view={v}\n caps={caps}\n resource={resource}\n testid={getTestId?.('view-item', v.id)}\n onClick={closeAfter(() => onApply(v))}\n />\n ))}\n </div>\n </>\n )}\n {hasAdopter && groups.length > 0 && <Separator testid={getTestId?.('separator')} />}\n {groups.map((group, index) => (\n <div key={group.scope.id}>\n {index > 0 && <Separator testid={getTestId?.('separator')} />}\n {showHeaders && (\n <SectionHeader\n label={scopeLabel(group.scope)}\n testid={getTestId?.('section-header', group.scope.id)}\n />\n )}\n <div className=\"max-h-[200px] overflow-auto\">\n {group.items.map((entry) => (\n <EntryRow\n key={entry.id}\n entry={entry}\n tr={tr}\n onApply={closeAfter(() => onApply(entry))}\n onRename={onRenameEntry ? closeAfter(() => onRenameEntry(entry)) : undefined}\n onFork={onForkEntry ? closeAfter(() => onForkEntry(entry)) : undefined}\n onDelete={onDeleteEntry ? closeAfter(() => onDeleteEntry(entry)) : undefined}\n forkAvailable={canFork}\n applyTestId={getTestId?.('view-item', entry.id)}\n renameTestId={getTestId?.('rename-entry', entry.id)}\n forkTestId={getTestId?.('fork-entry', entry.id)}\n deleteTestId={getTestId?.('delete-entry', entry.id)}\n />\n ))}\n </div>\n </div>\n ))}\n {(hasAdopter || hasEntries) && <Separator testid={getTestId?.('separator')} />}\n {canSaveCurrent && (\n <button\n type=\"button\"\n onClick={closeAfter(onSaveCurrent)}\n data-testid={getTestId?.('save-current')}\n className=\"w-full text-left rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {tr('toolbar.viewsSaveCurrent', 'Save current view…')}\n </button>\n )}\n {hasEntries && (\n <button\n type=\"button\"\n onClick={closeAfter(onManage)}\n data-testid={getTestId?.('manage')}\n className=\"w-full text-left rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {tr('toolbar.viewsManage', 'Manage views…')}\n </button>\n )}\n </PopoverContent>\n </Popover>\n );\n}\n","'use client';\nimport type { ReactElement } from 'react';\nimport { useResourceListContext, useT } from '@burojs/react';\nimport { SavedViewsDropdown } from '../../saved-views/saved-views-dropdown.js';\nimport { listPiece } from './piece.js';\nimport { useListSurface, usePieceMount } from './pieces-context.js';\n\n/** The saved-views menu of the route list; a `related-list` placement has none. */\nfunction ListSavedViewsView() {\n usePieceMount('saved-views');\n const t = useT();\n const { def, savedViews } = useResourceListContext();\n const { resource, route, savedViewsUi } = useListSurface();\n if (!def || !route) return null;\n return (\n <SavedViewsDropdown\n resource={resource}\n adopterViews={savedViews.adopter}\n entries={savedViews.entries}\n issues={savedViews.issues}\n onApply={savedViews.apply}\n onSaveCurrent={savedViewsUi.onSaveCurrent}\n canSaveCurrent={savedViewsUi.canSaveCurrent}\n onManage={savedViewsUi.onManage}\n onRenameEntry={savedViewsUi.onRenameEntry}\n onForkEntry={savedViewsUi.onForkEntry}\n canFork={savedViewsUi.canFork}\n onDeleteEntry={savedViewsUi.onDeleteEntry}\n iconOnly\n popoverAlign=\"end\"\n triggerLabel={t('toolbar.views')}\n triggerClassName=\"\"\n getTestId={(role, viewId) => {\n switch (role) {\n case 'trigger':\n return `list-saved-views:${resource}`;\n case 'menu':\n return `list-saved-views-menu:${resource}`;\n case 'view-item':\n return `list-saved-view:${resource}:${viewId ?? ''}`;\n case 'save-current':\n return `list-saved-view-save:${resource}`;\n case 'manage':\n return `list-saved-view-manage:${resource}`;\n case 'section-header':\n return `list-saved-view-section:${resource}:${viewId ?? ''}`;\n case 'rename-entry':\n return `list-saved-view-rename:${resource}:${viewId ?? ''}`;\n case 'fork-entry':\n return `list-saved-view-fork:${resource}:${viewId ?? ''}`;\n case 'delete-entry':\n return `list-saved-view-delete:${resource}:${viewId ?? ''}`;\n case 'issues-notice':\n return `list-saved-view-issues:${resource}`;\n default:\n return undefined;\n }\n }}\n />\n );\n}\n\nexport const ListSavedViews: () => ReactElement | null = listPiece(\n 'ListSavedViews',\n ListSavedViewsView,\n);\n","'use client';\nimport { useFramePiece, useResourceListContext } from '@burojs/react';\nimport type { ReactElement } from 'react';\nimport { ListColumns } from './list-columns.js';\nimport { ListCreate } from './list-create.js';\nimport { ListExport } from './list-export.js';\nimport { ListFilters } from './list-filters.js';\nimport { ListFlows } from './list-flows.js';\nimport { ListLive } from './list-live.js';\nimport { ListSavedViews } from './list-saved-views.js';\n\n/**\n * The toolbar: the filter region on the left, a group of controls pinned right. Two flex groups in\n * one row that wraps ONLY when it cannot fit — on overflow `flex-wrap-reverse` drops the right\n * group onto a line above the filters, each half keeping its own alignment. The left group's\n * min-width is what forces the right group (not the search) to be the thing that wraps.\n */\nfunction ListControlsView() {\n const { def } = useResourceListContext();\n if (!def) return null;\n return (\n <div className=\"flex flex-wrap-reverse items-end justify-end gap-2\">\n <ListFilters />\n <div className=\"flex shrink-0 items-center gap-2\">\n <ListFlows />\n <ListLive />\n <ListSavedViews />\n <ListColumns />\n <ListExport />\n <ListCreate />\n </div>\n </div>\n );\n}\n\n/**\n * The toolbar as a frame places it (`<ListControls/>`): under `checkFrame` it draws the pieces it\n * is made of, so a frame that also places one of them is counted twice.\n */\nexport function ListControls(): ReactElement | null {\n const check = useFramePiece('ListControls');\n if (check?.stub === true)\n return (\n <>\n <span data-check-piece=\"ListControls\" />\n <ListFilters />\n <ListFlows />\n <ListLive />\n <ListSavedViews />\n <ListColumns />\n <ListExport />\n <ListCreate />\n </>\n );\n return <ListControlsView />;\n}\n","'use client';\nimport type { ListFrameViewProps } from '@burojs/react';\nimport type { ReactElement } from 'react';\nimport { ListBody, ListControls } from '../list-kit/pieces/index.js';\n\n/**\n * `buro:list`: the `header` slot above the toolbar and the rows. The page header, the export\n * watcher, the saved-view dialogs and the bulk bar belong to the surface, not to the frame, so a\n * frame that arranges the pieces differently cannot lose them (P7-34).\n */\nexport function BuroListFrame({ slots }: ListFrameViewProps): ReactElement {\n return (\n <>\n {slots.header ?? null}\n <ListControls />\n <ListBody />\n </>\n );\n}\n","'use client';\nimport type { PageFrameViewProps } from '@burojs/react';\nimport type { ReactElement } from 'react';\n\n/**\n * `buro:page`: the `body` slot, nothing more. The page's `<h1>`, its access gate and `NavChrome`\n * belong to the page host, so a frame that arranges the slots differently cannot lose them.\n */\nexport function BuroPageFrame({ slots }: PageFrameViewProps): ReactElement {\n return <>{slots.body}</>;\n}\n","'use client';\nimport type { PeekFrameViewProps } from '@burojs/react';\nimport type { ReactElement } from 'react';\n\n/** `buro:peek`: the `body` slot as it is. */\nexport function BuroPeekFrame({ slots }: PeekFrameViewProps): ReactElement {\n return <>{slots.body ?? null}</>;\n}\n","'use client';\nimport { createContext, type ReactNode, type RefObject, useContext } from 'react';\n\n/** What the built-in frame pieces read besides the public record frame: `<RecordScreen>`'s props. */\nexport interface FrameChrome {\n readonly onCancel?: () => void;\n readonly submitLabel?: string;\n readonly extraActions?: ReactNode;\n /** The `<form>` the body renders in edit and create; `FormActions` submits it. */\n readonly formId: string;\n /** The last failed write, shown above the form actions until the next submit. */\n readonly submitError: unknown;\n /** Runs the controller's submit, then `onSuccess` or the failure banner. */\n submit(): Promise<void>;\n /** A typed create with an accepted type: back to the type offer. */\n readonly changeType?: () => void;\n /**\n * Show and edit of a typed resource whose record names no declared type: the\n * value (`null` when the record has none). Show adds a notice; edit refuses.\n */\n readonly unsupportedType?: string | null;\n /**\n * The screen is a quick entry's: its host draws the record title as the overlay's heading\n * (spec 4.1), so the frame's `<RecordTitle/>` renders nothing.\n */\n readonly hostTitle?: true;\n /** The screen's root element (the frame's runtime checks look for an `h1` inside it). */\n readonly root?: RefObject<HTMLElement | null>;\n}\n\nexport const FrameChromeContext = createContext<FrameChrome | null>(null);\n\n/** The frame's chrome; a piece outside `<RecordScreen>` has thrown before it reads this. */\nexport function useFrameChrome(): FrameChrome {\n const chrome = useContext(FrameChromeContext);\n if (chrome === null)\n throw new Error('[burojs] useRecordFrame() must be called inside <RecordScreen>');\n return chrome;\n}\n\n/** The frame's chrome, or `null` outside `<RecordScreen>` (a view rendered alone, `checkFrame`). */\nexport function useOptionalFrameChrome(): FrameChrome | null {\n return useContext(FrameChromeContext);\n}\n","'use client';\nimport { type CompiledScreen, resolveResourceLabel, type ScreenPlan } from '@burojs/core';\nimport {\n policyRecordOf,\n resolveValidationMessage,\n useApp,\n useI18nCaps,\n useOptionalT,\n useRecordFrame,\n useRecordTitle,\n useRouteNavigate,\n useFramePiece,\n useScreenState,\n useTestIds,\n} from '@burojs/react';\nimport { IconAlertCircle, IconAlertTriangle, IconCopy, IconLoader2 } from '@tabler/icons-react';\nimport type { ReactElement } from 'react';\nimport { ActionOverflow } from '../actions/action-overflow.js';\nimport { listTarget, recordReturnTarget } from '../layout/record-targets.js';\nimport { friendlyStringsFrom, toFriendlyError } from '../lib/friendly-error.js';\nimport { Button } from '../primitives/button.js';\nimport { useFrameChrome } from './frame-context.js';\n\n/** The record's id as the frame knows it: the `recordId`, else the record's own `id`. */\nfunction useFrameId(): string | undefined {\n const { recordId, record } = useRecordFrame();\n if (recordId !== undefined) return recordId;\n const id = record?.id;\n return typeof id === 'string' || typeof id === 'number' ? String(id) : undefined;\n}\n\n/**\n * The record's title: its `recordTitle` / display field (show, edit), or\n * \"Create <label>\" in create. Inside `<RecordScreen>` only; no props.\n */\nfunction RecordTitleView(): ReactElement | null {\n const { resource, mode, record } = useRecordFrame();\n const id = useFrameId();\n const app = useApp();\n const caps = useI18nCaps(resource);\n const t = useOptionalT();\n const title = useRecordTitle(resource, mode === 'create' ? undefined : id, record);\n // A quick entry's host draws the title as its heading: drawn and announced once (spec 4.1).\n if (useFrameChrome().hostTitle === true) return null;\n const text =\n mode === 'create'\n ? t('pageHeader.createTitle', {\n params: {\n label: resolveResourceLabel(caps, resource, 'single', app.registry.get(resource)),\n },\n })\n : title;\n if (text === '') return null;\n return <h2 className=\"min-w-0 break-words text-xl font-semibold tracking-tight\">{text}</h2>;\n}\n\n/**\n * The record's item actions: the resolved `<ActionOverflow>` of the mode's\n * surface, then `<RecordScreen extraActions>`. Nothing in create or before\n * the record is read.\n */\nfunction RecordActionsView(): ReactElement | null {\n const { resource, mode, record, controller } = useRecordFrame();\n const { extraActions } = useFrameChrome();\n const id = useFrameId();\n const holder = useScreenState()?.inline;\n if (mode === 'create' || record === undefined || id === undefined) return null;\n // Item actions are policy (P5 decision 12): their gates and the flows they start read the row\n // as read, not the projected one (P4 4.24 C2) — what they render projects on its own.\n const row = { ...policyRecordOf(controller, record), id } as { id: string } & Record<\n string,\n unknown\n >;\n // A flow this screen presents inline has no button of its own here (P6 3.12): this screen\n // instance only, a screen without the placement draws it.\n holder?.declare(inlineFlowNames(controller.screen, controller.plan));\n return (\n <div className=\"flex flex-wrap items-center gap-2\">\n <ActionOverflow\n resource={resource}\n record={row}\n surface={mode}\n {...(holder === undefined ? {} : { hideFlows: (name: string) => holder.suppressed(name) })}\n />\n {mode === 'show' ? extraActions : null}\n </div>\n );\n}\n\n/** Copies the record's id to the clipboard. Nothing without an id (create). */\nfunction CopyIdView(): ReactElement | null {\n const id = useFrameId();\n const t = useOptionalT();\n if (id === undefined) return null;\n const label = t('record.copyId', { defaultValue: 'Copy ID' });\n return (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label={label}\n title={label}\n onClick={() => void navigator.clipboard?.writeText(id)}\n className=\"h-7 gap-1 px-2 font-mono text-xs text-muted-foreground\"\n >\n <IconCopy className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n <span>{id}</span>\n </Button>\n );\n}\n\n/**\n * Submit and Cancel (edit, create): Submit runs the controller's submit and\n * then `onSuccess`; Cancel calls `onCancel`, else navigates back through the\n * navigation guard. Above them, the form-level messages and a failed write.\n * Nothing in show.\n */\nfunction FormActionsView(): ReactElement | null {\n const { resource, mode, controller } = useRecordFrame();\n const chrome = useFrameChrome();\n const app = useApp();\n const navigate = useRouteNavigate();\n const t = useOptionalT();\n const tid = useTestIds();\n const id = useFrameId();\n if (mode === 'show') return null;\n const busy = controller.isSubmitting;\n const cancel = () => {\n if (chrome.onCancel !== undefined) chrome.onCancel();\n else\n navigate(\n mode === 'edit' && id !== undefined\n ? recordReturnTarget(app.registry, resource, id)\n : listTarget(resource),\n );\n };\n // Record-level: an issue with no field, or anchored to a field no leaf renders (it would\n // otherwise show nowhere). One message per banner, a validator's before a check's: a\n // check's record-level message never clobbers the form's own.\n const plan = controller.plan;\n // A field the mode does not draw (`inactive`: hidden by the tree or its `in`) has no leaf either.\n const undrawn = (field: string) =>\n plan === null || plan.fields[field] === undefined || plan.fields[field] === 'inactive';\n const recordLevel = (issue: (typeof controller.errors)[number]) =>\n issue.field === '_form' || undrawn(issue.field);\n // A blocking check anchored to a field no leaf draws never reaches `errors` (it is shown once\n // its field is touched, and nobody can touch it): it still blocks, so its message shows here\n // (P3 Known finding 16).\n const undrawnBlockers = (controller.checkOutcome?.blockers ?? []).flatMap((issue) => {\n const field = typeof issue.path?.[0] === 'string' ? issue.path[0] : '_form';\n if (field !== '_form' && !undrawn(field)) return [];\n if (controller.errors.some((own) => own.code === issue.code && own.field === field)) return [];\n return [{ ...issue, field }];\n });\n const formErrors = firstPreferred([\n ...controller.errors.filter(recordLevel),\n ...(undrawnBlockers as unknown as typeof controller.errors),\n ]);\n const formWarnings = firstPreferred(controller.warnings.filter(recordLevel));\n const text = (issue: (typeof formErrors)[number]) =>\n resolveValidationMessage(\n {\n code: issue.code ?? '',\n message: issue.message,\n ...(issue.params === undefined ? {} : { params: issue.params }),\n },\n { t },\n );\n // An error check that could not run: Retry re-runs the check pass (decision 28).\n const retryable: string[] = [];\n for (const issue of controller.checkOutcome?.blockers ?? []) {\n const checkId = issue.params?.checkId;\n if (issue.params?.cause === undefined || typeof checkId !== 'string') continue;\n if (!retryable.includes(checkId)) retryable.push(checkId);\n }\n const failure = chrome.submitError === undefined ? undefined : failureText(chrome.submitError, t);\n // A create wizard submits from its last step; before it, the steps rail's Next moves on.\n const steps = controller.steps;\n const midSteps =\n steps !== null &&\n steps.ids.length > 1 &&\n steps.current !== undefined &&\n steps.current !== steps.ids[steps.ids.length - 1];\n return (\n <div className=\"flex flex-col gap-3\">\n {failure === undefined && formErrors.length === 0 ? null : (\n <div\n role=\"alert\"\n className=\"flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive\"\n >\n <IconAlertCircle className=\"mt-0.5 h-4 w-4 shrink-0\" aria-hidden=\"true\" />\n <div className=\"leading-snug\">\n {failure === undefined ? null : <p className=\"font-medium\">{failure}</p>}\n {formErrors.map((issue) => (\n <p key={issueKey(issue)}>{text(issue)}</p>\n ))}\n </div>\n {failure !== undefined && steps !== null ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"ml-auto\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => void chrome.submit()}\n >\n {t('actions.retry', { defaultValue: 'Retry' })}\n </Button>\n ) : null}\n </div>\n )}\n {retryable.length === 0 ? null : (\n <div className=\"flex flex-wrap gap-2\">\n {retryable.map((checkId) => (\n <Button\n key={checkId}\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n data-testid={`form-check-retry:${checkId}`}\n onClick={() => void controller.revalidate()}\n >\n {t('actions.retry', { defaultValue: 'Retry' })}\n </Button>\n ))}\n </div>\n )}\n {formWarnings.length === 0 ? null : (\n <div\n role=\"status\"\n aria-live=\"polite\"\n className=\"flex items-start gap-2 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-sm text-warning-emphasis\"\n data-testid={`form-warning:${resource}:${mode}`}\n >\n <IconAlertTriangle className=\"mt-0.5 h-4 w-4 shrink-0\" aria-hidden=\"true\" />\n <div className=\"leading-snug\">\n {formWarnings.map((issue) => (\n <p key={issueKey(issue)}>{text(issue)}</p>\n ))}\n </div>\n </div>\n )}\n <div className=\"flex justify-end gap-2 border-t pt-4\">\n {controller.isValidating ? (\n <span\n className=\"mr-auto inline-flex items-center gap-2 text-sm text-muted-foreground\"\n data-testid={tid.formValidating(resource, mode)}\n aria-live=\"polite\"\n >\n <IconLoader2 className=\"h-3.5 w-3.5 animate-spin\" aria-hidden=\"true\" />\n <span>{t('actions.validating', { defaultValue: 'Validating…' })}</span>\n </span>\n ) : null}\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={cancel}\n // A button taking focus on mousedown blurs the field, whose validation shifts the\n // layout, and the click lands nowhere: keep the focus where it is.\n onMouseDown={(event) => event.preventDefault()}\n data-testid={tid.formCancel(resource, mode)}\n >\n {t('actions.cancel', { defaultValue: 'Cancel' })}\n </Button>\n {midSteps ? null : (\n <Button\n type=\"submit\"\n form={chrome.formId}\n disabled={busy || controller.failure !== null}\n aria-busy={busy}\n onMouseDown={(event) => event.preventDefault()}\n onClick={(event) => {\n event.preventDefault();\n void chrome.submit();\n }}\n data-testid={tid.formSubmit(resource, mode)}\n className=\"min-w-24\"\n >\n {busy ? <IconLoader2 className=\"mr-2 h-4 w-4 animate-spin\" aria-hidden=\"true\" /> : null}\n {busy\n ? mode === 'edit'\n ? t('actions.saving', { defaultValue: 'Saving…' })\n : t('actions.creating', { defaultValue: 'Creating…' })\n : (chrome.submitLabel ??\n (mode === 'edit'\n ? t('actions.save', { defaultValue: 'Save' })\n : t('actions.create', { defaultValue: 'Create' })))}\n </Button>\n )}\n </div>\n </div>\n );\n}\n\n/** The banner's one issue: the first that no check raised, else the first. */\nfunction firstPreferred<T extends { readonly params?: Readonly<Record<string, unknown>> }>(\n issues: readonly T[],\n): readonly T[] {\n const own = issues.find((issue) => issue.params?.checkId === undefined);\n const first = own ?? issues[0];\n return first === undefined ? [] : [first];\n}\n\n/** A form-level issue's identity in a list: its code, message and params. */\nfunction issueKey(issue: {\n readonly code?: string;\n readonly message: { readonly key: string };\n readonly params?: unknown;\n}): string {\n return JSON.stringify([issue.code ?? '', issue.message.key, issue.params ?? null]);\n}\n\n/** A failed write as the user reads it: a friendly title, never a provider's raw message. */\nfunction failureText(error: unknown, t: ReturnType<typeof useOptionalT>): string {\n const friendly = toFriendlyError(safeMessage(error), undefined, friendlyStringsFrom(t));\n return friendly.replaced ? friendly.title : t('errors.failed', { defaultValue: 'Failed' });\n}\n\n/** A provider error's own `message` data property, never a getter, and never a long one. */\nfunction safeMessage(error: unknown): string | undefined {\n if (error === null || typeof error !== 'object') return undefined;\n try {\n const descriptor = Object.getOwnPropertyDescriptor(error, 'message');\n return descriptor !== undefined &&\n 'value' in descriptor &&\n typeof descriptor.value === 'string' &&\n descriptor.value.length <= 1024\n ? descriptor.value\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The names of the flows a compiled screen places inline (`buro:inline-flow`) and actually draws:\n * a placement the plan dropped (its own `when`, `requires` or `in`) leaves the flow's button.\n */\nfunction inlineFlowNames(screen: CompiledScreen | null, plan: ScreenPlan | null): string[] {\n if (screen === null) return [];\n const names: string[] = [];\n for (const node of screen.nodes) {\n const block = node.placement?.block;\n const flow = node.placement?.props.flow;\n if (block?.namespace !== 'buro' || block.id !== 'inline-flow' || typeof flow !== 'string')\n continue;\n const planned = plan === null || node.key === undefined ? undefined : plan.byKey[node.key];\n if (plan !== null && (planned === undefined || planned.state === 'absent')) continue;\n names.push(flow);\n }\n return names;\n}\n\n/** A piece as a frame places it: recorded while mounted, a marker under `checkFrame`. */\nfunction piece(\n name: 'RecordTitle' | 'RecordActions' | 'CopyId' | 'FormActions',\n View: () => ReactElement | null,\n) {\n function Piece(): ReactElement | null {\n const check = useFramePiece(name);\n if (check?.stub === true) return <span data-check-piece={name} />;\n return <View />;\n }\n Piece.displayName = name;\n return Piece;\n}\n\n/**\n * The record's title: its `recordTitle` / display field (show, edit), or\n * \"Create <label>\" in create. Inside `<RecordScreen>` only; no props.\n */\nexport const RecordTitle: () => ReactElement | null = piece('RecordTitle', RecordTitleView);\n\n/**\n * The record's item actions: the resolved `<ActionOverflow>` of the mode's\n * surface, then `<RecordScreen extraActions>`. Nothing in create or before\n * the record is read.\n */\nexport const RecordActions: () => ReactElement | null = piece('RecordActions', RecordActionsView);\n\n/** Copies the record's id to the clipboard. Nothing without an id (create). */\nexport const CopyId: () => ReactElement | null = piece('CopyId', CopyIdView);\n\n/**\n * Submit and Cancel (edit, create): Submit runs the controller's submit and\n * then `onSuccess`; Cancel calls `onCancel`, else navigates back through the\n * navigation guard. Above them, the form-level messages and a failed write.\n * Nothing in show.\n */\nexport const FormActions: () => ReactElement | null = piece('FormActions', FormActionsView);\n","'use client';\nimport { type RecordFrameViewProps, useOptionalT, useTestIds } from '@burojs/react';\nimport { createContext, type ReactElement, useContext } from 'react';\nimport { Button } from '../primitives/button.js';\nimport { useOptionalFrameChrome } from '../record/frame-context.js';\nimport { CopyId, FormActions, RecordActions, RecordTitle } from '../record/frame-pieces.js';\n\n/**\n * The undeclared-type notice: a record whose discriminator value no type declares (or that has\n * none) reads as the base with this notice, and nothing can be written for it (P1b+P1c\n * decision 64). The strings are the framework's `create.unsupportedType` /\n * `create.unsupportedTypeHint`.\n */\nexport function UndeclaredTypeNotice({\n resource,\n typeValue,\n className,\n}: {\n readonly resource: string;\n readonly typeValue: string | null;\n readonly className?: string;\n}): ReactElement {\n const t = useOptionalT();\n const tid = useTestIds();\n return (\n <div\n data-testid={tid.unsupportedDocumentType(resource)}\n data-type-value={typeValue ?? ''}\n role=\"status\"\n className={className ?? 'rounded-md border border-dashed p-8 text-center'}\n >\n <h2 className=\"text-base font-semibold tracking-tight\">\n {t('create.unsupportedType', { defaultValue: 'Unsupported type' })}\n </h2>\n <p className=\"mx-auto max-w-sm text-sm text-muted-foreground\">\n {t('create.unsupportedTypeHint', {\n params: { type: typeValue ?? '' },\n defaultValue: 'The type “{{type}}” is not registered for this resource.',\n })}\n </p>\n </div>\n );\n}\n\n/**\n * Whether the framework already drew the type chrome above a custom frame (P6-70): the built-in\n * view's notice and Change type then render nothing (a lazily-failed custom view falls back to\n * the built-in view under the same flag).\n */\nexport const TypeChromeDrawnContext = createContext(false);\n\n/** The undeclared-type notice in a frame's header row (the framework's, P6-70). */\nexport function HeaderTypeNotice({ resource }: { readonly resource: string }): ReactElement | null {\n const chrome = useOptionalFrameChrome();\n const drawn = useContext(TypeChromeDrawnContext);\n if (drawn || chrome?.unsupportedType === undefined) return null;\n return (\n <UndeclaredTypeNotice\n resource={resource}\n typeValue={chrome.unsupportedType}\n className=\"rounded-md border border-dashed px-3 py-2 text-sm\"\n />\n );\n}\n\n/** A typed create's \"Change type\" (the framework's, P6-70). */\nexport function ChangeTypeButton(): ReactElement | null {\n const chrome = useOptionalFrameChrome();\n const drawn = useContext(TypeChromeDrawnContext);\n const t = useOptionalT();\n if (drawn || chrome?.changeType === undefined) return null;\n return (\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={chrome.changeType}>\n {t('create.typeOffer.change', { defaultValue: 'Change type' })}\n </Button>\n );\n}\n\n/**\n * `buro:record`: the header region (the undeclared-type notice, the title row, then the `header`\n * slot), the `body` slot, the form actions.\n */\nexport function BuroRecordFrame({ slots, screen }: RecordFrameViewProps): ReactElement {\n return (\n <>\n <div data-buro-region=\"record-header\" className=\"flex flex-col gap-3\">\n <HeaderTypeNotice resource={screen.resource} />\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <div className=\"flex min-w-0 items-baseline gap-2\">\n <RecordTitle />\n <CopyId />\n </div>\n <RecordActions />\n <ChangeTypeButton />\n </div>\n {slots.header ?? null}\n </div>\n {slots.body}\n <FormActions />\n </>\n );\n}\n","import { builtinFrames } from '@burojs/core';\nimport { type FrameImplementation, implementFrame } from '@burojs/react';\nimport { BuroPanelFrame, BuroStepsFrame, BuroTabsFrame } from './builtin-nodes.js';\nimport { BuroListFrame } from './builtin-list.js';\nimport { BuroPageFrame } from './builtin-page.js';\nimport { BuroPeekFrame } from './builtin-peek.js';\nimport { BuroRecordFrame } from './builtin-record.js';\n\n/** The ids of the seven built-in frames. */\nexport type BuiltinFrameId =\n | 'buro:record'\n | 'buro:peek'\n | 'buro:list'\n | 'buro:page'\n | 'buro:panel'\n | 'buro:tabs'\n | 'buro:steps';\n\n/**\n * The seven built-in frames' views, the kit's own (P6-8): the renderer looks a `buro:` id up here\n * and any other in the app's `<BuroProvider frameImplementations>`.\n */\nexport const shadcnFrameViews: Readonly<\n // biome-ignore lint/suspicious/noExplicitAny: the views of five frame kinds\n Record<BuiltinFrameId, FrameImplementation<any>>\n> = Object.freeze({\n 'buro:record': implementFrame(builtinFrames.record, { component: BuroRecordFrame }),\n 'buro:peek': implementFrame(builtinFrames.peek, { component: BuroPeekFrame }),\n 'buro:list': implementFrame(builtinFrames.list, { component: BuroListFrame }),\n 'buro:page': implementFrame(builtinFrames.page, { component: BuroPageFrame }),\n 'buro:panel': implementFrame(builtinFrames.panel, { component: BuroPanelFrame }),\n 'buro:tabs': implementFrame(builtinFrames.tabs, { component: BuroTabsFrame }),\n 'buro:steps': implementFrame(builtinFrames.steps, { component: BuroStepsFrame }),\n});\n","'use client';\nimport { type EntityRef, type FrameKind, formatEntityRef } from '@burojs/core';\nimport type { FrameImplementation, FrameImplementationCatalog } from '@burojs/react';\nimport {\n type ComponentType,\n type ReactNode,\n createElement,\n Fragment,\n lazy,\n useEffect,\n useRef,\n} from 'react';\nimport { BuroPanelFrame, BuroStepsFrame, BuroTabsFrame } from './builtin-nodes.js';\nimport { BuroListFrame } from './builtin-list.js';\nimport { BuroPageFrame } from './builtin-page.js';\nimport { BuroPeekFrame } from './builtin-peek.js';\nimport { BuroRecordFrame } from './builtin-record.js';\nimport { type BuiltinFrameId, shadcnFrameViews } from './builtin.js';\n\n// biome-ignore lint/suspicious/noExplicitAny: a frame view of any kind\ntype View = ComponentType<any>;\n\n/** A resolved frame view; `fallback` when the frame has no view and the built-in draws it. */\nexport interface ResolvedFrameView {\n readonly view: View;\n readonly fallback?: 'not-implemented';\n}\n\nconst BUILTIN_BY_KIND: Readonly<Record<FrameKind, View>> = {\n record: BuroRecordFrame,\n peek: BuroPeekFrame,\n list: BuroListFrame,\n page: BuroPageFrame,\n panel: BuroPanelFrame,\n tabs: BuroTabsFrame,\n steps: BuroStepsFrame,\n};\n\n/** Logs `frame.not-implemented` once per mounted instance (a screen or a node), in development. */\nfunction useNotImplemented(id: string): void {\n const told = useRef(false);\n useEffect(() => {\n if (told.current || process.env.NODE_ENV === 'production') return;\n told.current = true;\n console.error(\n `[burojs] frame.not-implemented: ${id} has no view; register implementFrame(<the ${id} frame>, { component }) in <BuroProvider frameImplementations>. The built-in frame draws it.`,\n );\n }, [id]);\n}\n\nconst notImplementedViews = new Map<string, View>();\n\n/**\n * The built-in view of `kind` standing in for the frame `id` (P6-10): one development error per\n * instance; a record frame's extra slots render in declaration order above `body`, so nothing\n * the frame would have shown is hidden.\n */\nfunction notImplementedView(kind: FrameKind, id: string): View {\n const key = `${kind}\\u0000${id}`;\n let view = notImplementedViews.get(key);\n if (view !== undefined) return view;\n const builtin = BUILTIN_BY_KIND[kind];\n view =\n kind === 'record' || kind === 'page'\n ? function RecordFrameNotImplemented(props: {\n readonly slots: Readonly<Record<string, ReactNode>>;\n }) {\n useNotImplemented(id);\n const extras = Object.entries(props.slots)\n .filter(([name]) => name !== 'header' && name !== 'body')\n .map(([, element]) => element);\n return createElement(builtin, {\n ...props,\n slots: {\n ...props.slots,\n body: createElement(Fragment, null, ...extras, props.slots.body),\n },\n });\n }\n : function FrameNotImplemented(props: object) {\n useNotImplemented(id);\n return createElement(builtin, props);\n };\n notImplementedViews.set(key, view);\n return view;\n}\n\nconst lazyViews = new WeakMap<FrameImplementation, View>();\n\n/** A `load` entry's view behind `React.lazy`, one per entry; a rejecting load is not-implemented. */\nfunction lazyView(entry: FrameImplementation, kind: FrameKind): View {\n let view = lazyViews.get(entry);\n if (view === undefined) {\n const load = entry.load!;\n view = lazy(async () => {\n try {\n const module = await load();\n return { default: module.default as View };\n } catch {\n return { default: notImplementedView(kind, entry.id) };\n }\n });\n lazyViews.set(entry, view);\n }\n return view;\n}\n\n/**\n * The view of a frame: a `buro:` id from the kit's own table, any other from the app's\n * catalogue (`component`, or `load` behind `React.lazy`); a frame with no view is drawn by the\n * built-in of its kind with `fallback: 'not-implemented'` (spec 3.2). Never reads a prop or an\n * attribute: only the frame reference the compiled screen holds.\n */\nexport function resolveFrameView(\n ref: EntityRef,\n catalog: FrameImplementationCatalog,\n kind: FrameKind,\n): ResolvedFrameView {\n const id = formatEntityRef(ref);\n if (ref.namespace === 'buro') {\n const builtin = Object.hasOwn(shadcnFrameViews, id)\n ? shadcnFrameViews[id as BuiltinFrameId]\n : undefined;\n if (builtin !== undefined && builtin.for === kind) return { view: builtin.component as View };\n return { view: notImplementedView(kind, id), fallback: 'not-implemented' };\n }\n const entry = Object.hasOwn(catalog, id) ? catalog[id] : undefined;\n if (entry === undefined || entry.for !== kind)\n return { view: notImplementedView(kind, id), fallback: 'not-implemented' };\n if (entry.component !== undefined) return { view: entry.component as View };\n return { view: lazyView(entry, kind) };\n}\n\n/** Whether a resolved view is the kit's built-in record view (it draws the type chrome itself). */\nexport function isBuiltinRecordView(resolved: ResolvedFrameView): boolean {\n return resolved.view === BuroRecordFrame || resolved.fallback === 'not-implemented';\n}\n","'use client';\nimport {\n type EntityRef,\n type CompiledScreen,\n compiledScreenFor,\n formatEntityRef,\n isScreenFailure,\n} from '@burojs/core';\nimport {\n RouteSourceContext,\n type ListFrameViewProps,\n useApp,\n useApplicationSnapshot,\n useFrameImplementations,\n useFrameT,\n useOptionalDataRuntime,\n usePageScreen,\n useResourceListContext,\n useTestIds,\n} from '@burojs/react';\nimport { type ReactElement, Suspense, useEffect, useMemo, useRef, useState } from 'react';\nimport { itemHandle } from '../blocks/related-item.js';\nimport { resolveFrameView } from '../frames/resolve.js';\nimport { ScreenTree, ScreenTreeScope } from '../screen/screen-tree.js';\nimport {\n ForceTableView,\n ListBody,\n ListControls,\n ListItemContext,\n type ListPieceName,\n useListPieceCounts,\n} from './pieces/index.js';\n\n/** The pieces a frame places at most once each; `bulk-bar` is the surface's own. */\nconst ONCE: readonly ListPieceName[] = [\n 'filters',\n 'flows',\n 'live',\n 'saved-views',\n 'columns',\n 'export',\n 'create',\n 'body',\n 'bulk-bar',\n];\n\n/**\n * Reports, once the frame view has mounted, a frame that places `ListBody` zero or two times\n * (development: `list.body-missing`, `list.piece-twice`) and asks the host for the built-in body\n * when there is none, so a list never vanishes. It mounts in the view's own Suspense boundary\n * and after it, so a lazy view is counted when it has loaded, not before.\n */\nfunction MountCheck(props: {\n readonly frameId: string;\n readonly onBodyMissing: (missing: boolean) => void;\n}): null {\n const { frameId, onBodyMissing } = props;\n const counts = useListPieceCounts();\n const told = useRef(new Set<string>());\n // Every commit: a frame may place its pieces after a state change, and the counts are final\n // only after the pieces' own effects, which run before this one.\n useEffect(() => {\n const seen = counts();\n const body = seen.get('body') ?? 0;\n onBodyMissing(body === 0);\n if (process.env.NODE_ENV === 'production') return;\n const tell = (code: string, message: string) => {\n if (told.current.has(code)) return;\n told.current.add(code);\n console.error(`[burojs] ${code}: ${message}`);\n };\n if (body === 0)\n tell(\n 'list.body-missing',\n `${frameId} renders no <ListBody/>; the built-in body is drawn below the frame. Place <ListBody/> where the rows go.`,\n );\n for (const name of ONCE)\n if ((seen.get(name) ?? 0) > 1)\n tell(\n 'list.piece-twice',\n `${frameId} renders the ${name} piece more than once; place each piece once.`,\n );\n });\n return null;\n}\n\n/** The compiled list screen of a resource: its failure marker is a development error. */\nfunction useCompiledListScreen(resource: string): CompiledScreen | null {\n const app = useApp();\n const snapshot = useApplicationSnapshot();\n const ref = (app.registry.get(resource) as { readonly ref?: EntityRef } | undefined)?.ref;\n const compiled = useMemo(\n () => (ref === undefined ? undefined : compiledScreenFor(snapshot, ref, 'show', 'list')),\n [snapshot, ref],\n );\n const failure = compiled !== undefined && isScreenFailure(compiled) ? compiled : null;\n useEffect(() => {\n if (failure === null || process.env.NODE_ENV === 'production') return;\n console.error(\n `[burojs] The list of \"${resource}\" cannot render its frame: ${failure.code} at ${failure.path.join('.')}: ${failure.message}. The built-in frame draws it.`,\n );\n }, [failure, resource]);\n return compiled === undefined || isScreenFailure(compiled) ? null : compiled;\n}\n\n/** The compiled screen's frame slots: the item (P7-36) is planned beside them and is no slot. */\nfunction frameSlotNames(compiled: CompiledScreen): readonly string[] {\n return Object.keys(compiled.slots).filter((name) => name !== 'item');\n}\n\n/**\n * The built-in arrangement, with no slot: what a list that cannot draw its frame falls back to.\n * It has no screen-tree scope, which cards and a timeline need to read their rows, so it draws\n * the table whatever `views.list.view` says.\n */\nfunction Arrangement(): ReactElement {\n return (\n <ForceTableView>\n <ListControls />\n <ListBody />\n </ForceTableView>\n );\n}\n\n/**\n * The frame view of a compiled list screen, given its slots' elements: resolved from the frame\n * reference (a `buro:` id from the kit's own table, any other from the app's catalogue), with the\n * mount check beside it. A view without `<ListBody/>` gets the built-in body below it.\n */\nfunction FrameView(props: {\n readonly resource: string;\n readonly compiled: CompiledScreen;\n readonly slots: Readonly<Record<string, ReactElement | null>>;\n}): ReactElement {\n const { resource, compiled, slots } = props;\n const catalog = useFrameImplementations();\n const [bodyMissing, setBodyMissing] = useState(false);\n const id = formatEntityRef(compiled.frame);\n const resolved = useMemo(\n () => resolveFrameView(compiled.frame, catalog, 'list'),\n [compiled.frame, catalog],\n );\n const t = useFrameT(id);\n const View = resolved.view;\n const viewProps: ListFrameViewProps = {\n slots: slots as ListFrameViewProps['slots'],\n resource,\n t,\n };\n return (\n <>\n <Suspense fallback={null}>\n <View {...viewProps} />\n <MountCheck frameId={id} onBodyMissing={setBodyMissing} />\n </Suspense>\n {bodyMissing ? <ListBody /> : null}\n </>\n );\n}\n\n/** A list whose slots hold nodes: planned as a page's (the sources a list reads are user and scope). */\nfunction PlannedFrame(props: {\n readonly resource: string;\n readonly compiled: CompiledScreen;\n}): ReactElement {\n const { resource, compiled } = props;\n const page = usePageScreen(compiled);\n const tid = useTestIds();\n const slots: Record<string, ReactElement | null> = {};\n for (const name of frameSlotNames(compiled)) {\n const roots = page.plan.slots[name] ?? [];\n slots[name] = roots.every((node) => node.state === 'absent') ? null : (\n <div key={name} data-testid={tid.listSlot(resource, name)}>\n <ScreenTree\n region=\"record\"\n slot={name}\n resource={resource}\n mode=\"show\"\n compiled={compiled}\n page={page}\n />\n </div>\n );\n }\n const { PlacementScope } = page;\n // The item block of a cards or timeline list is planned with the screen, beside the slots.\n const itemNode = page.plan.slots.item?.[0];\n const item = useMemo(\n () => (itemNode === undefined ? undefined : itemHandle(itemNode)),\n [itemNode],\n );\n return (\n <RouteSourceContext.Provider value={null}>\n <PlacementScope>\n <ScreenTreeScope resource={resource} mode=\"show\" compiled={compiled} page={page}>\n <ListItemContext.Provider value={item}>\n <FrameView resource={resource} compiled={compiled} slots={slots} />\n </ListItemContext.Provider>\n </ScreenTreeScope>\n </PlacementScope>\n </RouteSourceContext.Provider>\n );\n}\n\n/**\n * The route list's frame (P7-34): the effective frame of `views.list` (its own, the app's default,\n * `buro:list`) and its slots, each inside the framework's wrapper. The pieces the view places read\n * the controller the surface owns; the page header, the export watcher, the saved-view dialogs and\n * the bulk bar are drawn outside this host, so no frame can drop or fork them. A screen that\n * cannot compile draws the built-in arrangement with no slot (fail closed); a list whose slots\n * hold no node plans nothing, and one that does needs a data runtime to read its placements.\n */\nexport function ListFrameHost({ resource }: { readonly resource: string }): ReactElement {\n const compiled = useCompiledListScreen(resource);\n const hasDataRuntime = useOptionalDataRuntime() !== null;\n const { def } = useResourceListContext();\n // Cards and a timeline draw their rows from the screen's tree context, even with no node of\n // their own to plan (P7-36).\n const rowsView = (def?.views?.list as { readonly view?: string } | undefined)?.view ?? 'table';\n if (compiled === null) return <Arrangement />;\n if (compiled.nodes.length === 0 && rowsView === 'table') {\n const empty: Record<string, ReactElement | null> = {};\n for (const name of frameSlotNames(compiled)) empty[name] = null;\n return <FrameView resource={resource} compiled={compiled} slots={empty} />;\n }\n if (!hasDataRuntime) return <Arrangement />;\n return <PlannedFrame resource={resource} compiled={compiled} />;\n}\n","'use client';\nimport { lazy, Suspense, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';\nimport { IconPlus } from '@tabler/icons-react';\nimport {\n type CountPolicy,\n type FixedFilterInput,\n type ScopeSource,\n type SearchDecl,\n enumNamespaceOf,\n resolveEnumLabel,\n resolveFieldOptionLabel,\n resolveResourceLabel,\n hasRecordPage,\n resourceShowHref,\n fieldOptionText,\n} from '@burojs/core';\nimport {\n LOCAL_USER_SCOPE_ID,\n policyRowsOf,\n ResourceListProvider,\n useApp,\n useAvailability,\n useAvailabilityResolver,\n useEntryGate,\n useQuick,\n useQuickOpener,\n useComponent,\n useI18nCaps,\n useOptionalDataRuntime,\n useOptionalT,\n useResourceList,\n useT,\n useTestIds,\n type ListState,\n type SavedViewEntry,\n} from '@burojs/react';\nimport type { ResourceListPageProps } from './resource-list-page.js';\nimport { EnumBadge } from '../enum/enum-badge.js';\nimport { useExportRunWatcher } from '../export/run-watcher.js';\nimport { cn } from '../lib/cn.js';\nimport { toast } from '../notification/toaster.js';\nimport { Badge } from '../primitives/badge.js';\nimport { Button } from '../primitives/button.js';\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '../primitives/dialog.js';\nimport { Input } from '../primitives/input.js';\nimport { PageHeader } from '../resource/page-header.js';\nimport { useDeepLinkOpen } from '../quick/use-deep-link.js';\nimport type { ItemHandle } from '../blocks/related-item.js';\nimport { RelatedCardsSkeleton, RelatedTimelineSkeleton } from '../blocks/related-skeletons.js';\nimport { canonicalResourceName, useListSlot } from './list-slots.js';\nimport { ListFrameHost } from './list-frame-host.js';\nimport {\n ListBody,\n ListBulkBar,\n ListControls,\n ListPiecesProvider,\n type ListSurfaceValue,\n} from './pieces/index.js';\nimport type { ResourceListProps } from '../resource/resource-list.js';\n\n// The cards and timeline views load when a placement asks for one (P6 ruling 15).\nconst RelatedCards = lazy(async () => ({\n default: (await import('../blocks/related-list-cards.js')).RelatedCards,\n}));\nconst RelatedTimeline = lazy(async () => ({\n default: (await import('../blocks/related-list-timeline.js')).RelatedTimeline,\n}));\n\n/**\n * Props of {@link ResourceListSurface}: the route list's (`variant: 'route'`, from\n * {@link ResourceListPageProps}) or a `related-list` placement's (`variant: 'placement'`, from its\n * props).\n */\nexport interface ResourceListSurfaceProps {\n /** Registry name of the resource to list (it MUST be registered). */\n readonly resource: string;\n readonly variant: 'route' | 'placement';\n /** Where the list keeps its state; the route list passes none (`?<resource>.`). */\n readonly state?: ListState;\n /** Locked filters (a placement's `where`); the route list has none. */\n readonly fixedFilters?: readonly FixedFilterInput[];\n /** A placement's page size; else the target's `views.list.pageSize`. */\n readonly pageSize?: number;\n /** A placement's own search field (a box only when set); the route list uses `views.list.search`. */\n readonly search?: string;\n /** A placement's columns; else the target's `views.list.columns`. */\n readonly columns?: readonly string[];\n /**\n * What a row opens: its `quick.show` (`quick`, a placement's default), its show page (`page`)\n * or nothing (`none`). The route list opens the page, or `quick.show` for a resource without\n * one (`views.show.page: false`).\n */\n readonly open?: 'page' | 'none' | 'quick';\n /** A placement's heading. */\n readonly title?: string;\n /**\n * Where a placement's reads take their scope values from; the route list passes none and keeps\n * the session's scope.\n */\n readonly scope?: ScopeSource;\n /**\n * How a placement draws its rows: the table (the default), cards or a timeline over the same\n * controller. The column menu, resize, selection and the bulk bar are the table's only.\n */\n readonly view?: 'table' | 'cards' | 'timeline';\n /** The planned item block of a cards or timeline placement (else the default item). */\n readonly item?: ItemHandle;\n /** The placement's key: its cards' and entries' test ids. */\n readonly placementKey?: string;\n /** A placement's \"+ Create\" (its `quick.create`, seeded by the caller); absent: none drawn. */\n readonly onCreate?: () => void;\n /** A placement's count policy, in place of the listed resource's `views.list.count`. */\n readonly count?: CountPolicy;\n /**\n * The record a row opens is another resource's (`resource`), keyed by the row's `field`: a\n * link panel lists junction rows and opens their targets. `open` then says `page` or `none`.\n */\n readonly rowTarget?: { readonly resource: string; readonly field: string };\n /** No row actions, no selection and no bulk bar: a row can only be opened. */\n readonly readOnly?: true;\n /**\n * `false`: no export control. A link panel shows target columns over junction rows, and an\n * export would ask (and write) the junction's fields and permissions, not the shown target's.\n */\n readonly exportable?: false;\n /** Route only: see {@link ResourceListPageProps.meta}. */\n readonly meta?: Record<string, unknown>;\n /** Route only: see {@link ResourceListPageProps.renderCell}. */\n readonly renderCell?: ResourceListPageProps['renderCell'];\n /** Route only: see {@link ResourceListPageProps.emptyState}. */\n readonly emptyState?: ReactNode;\n}\n\n/**\n * The one list body (spec 8.4, decision 63): the route list page and every `related-list`\n * placement render it. The route variant is today's list page, moved here unchanged — header,\n * filter region, saved views and their dialogs, the columns toggle, export, create, the table,\n * the bulk bar, and the `list.filters.<r>` / `list.body.<r>` / `list.cell.<r>` slots. The\n * placement variant drops the page header, the saved views and the `filters` / `body` slots\n * (decisions 61, 62); `list.cell.<r>` applies in both. See `ResourceListPage` for the override\n * ladder.\n */\n\n/** The discriminator field's own label for `value` (its `options`), or the value itself. */\nfunction discriminatorOptionLabel(field: unknown, value: string): string {\n const text = fieldOptionText(field, value);\n if (text !== undefined) return text;\n const declared = field as\n | {\n readonly options?: readonly { readonly value?: unknown; readonly label?: unknown }[];\n readonly meta?: { readonly options?: unknown };\n }\n | undefined;\n const options = Array.isArray(declared?.options)\n ? declared.options\n : Array.isArray(declared?.meta?.options)\n ? (declared.meta.options as readonly { readonly value?: unknown; readonly label?: unknown }[])\n : [];\n const label = options.find((option) => option?.value === value)?.label;\n return typeof label === 'string' ? label : value;\n}\n\nexport function ResourceListSurface({\n resource,\n variant,\n state,\n fixedFilters,\n pageSize,\n search: searchField,\n columns: columnNames,\n open,\n title,\n scope,\n view,\n item,\n placementKey,\n onCreate,\n count: countPolicy,\n rowTarget,\n readOnly,\n exportable,\n meta,\n renderCell,\n emptyState,\n}: ResourceListSurfaceProps) {\n const route = variant === 'route';\n const t = useT();\n // A string that must read without the framework bundle (a host without `en` mounted).\n const optionalT = useOptionalT();\n const tid = useTestIds();\n const listCaps = useI18nCaps(resource);\n\n /**\n * The three override seams. Resolved unconditionally (Rules of Hooks) and\n * `undefined` for every resource that registers nothing — the level-0\n * path, which is byte-identical to the pre-B3.2 render (and, for\n * `CellSlot`, the pre-Task-5 render).\n *\n * `useListSlot` is overloaded on `region`: the `'cell'` call resolves to\n * {@link ListCellRenderer} — a 3-arg function — while `'filters'`/`'body'`\n * still resolve to {@link ListSlot}, a no-props component. No cast is\n * needed here; the hook's own signature carries the distinction.\n */\n const RouteFiltersSlot = useListSlot('filters', resource);\n // `list.body.<r>` was retired (P7-37): a component still registered there is told, not rendered.\n const RemovedBodySlot = useComponent<unknown>(`list.body.${canonicalResourceName(resource)}`);\n const CellSlot = useListSlot('cell', resource);\n // The route list only (decision 62): a placement renders the standard region.\n const FiltersSlot = route ? RouteFiltersSlot : undefined;\n const removedBody = route && RemovedBodySlot !== undefined;\n const bodyRemovedTold = useRef(false);\n useEffect(() => {\n if (!removedBody || bodyRemovedTold.current || process.env.NODE_ENV === 'production') return;\n bodyRemovedTold.current = true;\n console.error(\n `[burojs] list.body-removed: list.body.${canonicalResourceName(resource)} is no longer rendered; a whole-body override is a list frame (views.list.frame).`,\n );\n }, [removedBody, resource]);\n const searchDecl = useMemo<SearchDecl | undefined>(\n () => (searchField === undefined ? undefined : { fields: [searchField] }),\n [searchField],\n );\n\n /**\n * The list controller (`@burojs/react`). Owns everything that is not\n * rendering: URL-state sync, the column math, filter composition, the\n * `useList` call, row identity, selection, saved views and hrefs.\n *\n * ⚠️ No `onReset` here (Task 7). That seam existed ONLY to cross into the\n * old chip toolbar's app-owned `visibleIds` — its ephemeral \"which\n * filters are showing as chips\" set, which `filters.clearAll`/\n * `savedViews.apply` had to reach from outside (that toolbar and its hook\n * are gone — SP2 Task 8). The\n * filter-builder region (`FilterRegion`) has no equivalent state: its\n * badges render straight off the APPLIED `filters.group`/`filters.value`\n * and its panel draft reseeds from `filters.group` on every open (see\n * `FilterPanel`'s doc), so there is nothing left for a reset seam to\n * clear. `onReset` stays optional on `useResourceList` for any other\n * caller that still needs it.\n */\n // The route list's call is `{ meta }` exactly, no `state` key: its URL namespace stays the\n // resource's registry key.\n const list = useResourceList(\n resource,\n route\n ? { meta }\n : {\n ...(state === undefined ? {} : { state }),\n ...(fixedFilters === undefined ? {} : { fixedFilters }),\n ...(pageSize === undefined ? {} : { pageSize }),\n ...(searchDecl === undefined ? {} : { search: searchDecl }),\n ...(columnNames === undefined ? {} : { columns: columnNames }),\n ...(scope === undefined ? {} : { scope }),\n ...(countPolicy === undefined ? {} : { countPolicy }),\n },\n );\n // Both sides added a destructured member: `live` (l2-lists SP0's polling\n // seam) and `cursor` (cursor pagination on main). They are independent —\n // keep both.\n const {\n def,\n query,\n pagination,\n cursor,\n count,\n filters,\n sorting,\n columns,\n selection,\n savedViews,\n routing,\n live,\n droppedPredicates,\n } = list;\n // The table keeps the rows as read: selection, the quick opener and item-action gates are\n // policy, and its cells project each row on their own (`viewRow`).\n const rows = policyRowsOf(list, list.rows);\n\n /**\n * `useExportRunWatcher()`/`useResourceExport()` (and everything\n * `<ExportButton>` needs) hard-require a native data runtime and throw\n * without one — the same stance `useAction` takes, and the reason\n * `<ExportButton>` gates itself on `useOptionalDataRuntime()` internally\n * (see that file). This page, though, is also mounted in \"compat mode\"\n * (`<BuroProvider>` with no `dataRuntime` — every assembly/slot test in\n * this package's suite does this), where NOTHING may call those hooks.\n * `useOptionalDataRuntime()` itself never throws, so checking it here —\n * once, as an ordinary unconditional hook call — decides whether the\n * watcher may be mounted at all, without ever conditionally calling a\n * HARD hook from inside one component's own body.\n */\n const hasDataRuntime = useOptionalDataRuntime() !== null;\n\n /** Task 9 — scope's own label, except the framework's local scope (reactive i18n swap). */\n const scopeLabel = (scope: { id: string; label: string }): string =>\n scope.id === LOCAL_USER_SCOPE_ID ? t('toolbar.viewsMyScope') : scope.label;\n\n // The empty-state \"+ Create\" is drawn by <ResourceList>, which takes an href\n // rather than a resource — so the gate is applied here, at the only place\n // that knows both.\n //\n // ⚠️ `disabled` collapses to hidden here, unlike the toolbar's\n // `<CreateButton>`, which draws it inert and explains itself. That is the\n // LINK rule from the spec, not an oversight: `<ResourceList>`'s contract for\n // this slot is an href, so the only thing it can render is a link, and a link\n // cannot carry a toast. The toolbar button above still says why.\n const createAvailable = useAvailability(resource, 'create').state === 'available';\n // A resource without a create page (`views.show.page: false`) creates in its `quick.create`\n // (spec 4.7); the empty state's link has nowhere to go and is not drawn.\n const quick = useQuick();\n const createPage = def === undefined || hasRecordPage(def, 'create');\n const openCreate = createPage ? undefined : () => void quick.create(resource);\n\n // What a row opens (spec 4.5): a placement opens `quick.show` unless told otherwise; the route\n // list opens the page, or `quick.show` when the resource has none. A quick row asks the entry\n // gate with the row: `open` opens the overlay (the first cell keeps the page anchor when there\n // is a page); undecided draws no link and takes no click; anything else falls back to the page\n // when there is one (`routing.rowHref` is `''` otherwise).\n const gate = useEntryGate();\n const openQuick = useQuickOpener();\n const effectiveOpen =\n open ??\n (route ? (def !== undefined && !hasRecordPage(def, 'show') ? 'quick' : 'page') : 'quick');\n // A row whose record is another resource's never opens its own row's quick entry.\n const quickRows = effectiveOpen === 'quick' && rowTarget === undefined;\n // The route list of a resource without a page reads `?<resource>.open=<id>` (spec 4.8).\n useDeepLinkOpen(resource, resource, route && quickRows);\n const rowQuick = useMemo(\n () =>\n quickRows\n ? (row: { readonly id: string } & Record<string, unknown>) =>\n gate(resource, 'show', row).state === 'open'\n ? () => void openQuick(resource, String(row.id), { row })\n : null\n : undefined,\n [quickRows, gate, openQuick, resource],\n );\n // A row whose record is another resource's (`rowTarget`) links to that record's show page when\n // it has one and the user may see it; the row's own resource is never linked then.\n const registry = useApp().registry;\n const targetName = rowTarget?.resource;\n const targetField = rowTarget?.field;\n const targetGate = useAvailabilityResolver(targetName ?? resource);\n const targetHref = useMemo(() => {\n if (targetName === undefined || targetField === undefined) return undefined;\n const targetDef = registry.get(targetName);\n const delegate = targetDef?.routesTo?.show;\n const showDef = delegate === undefined ? targetDef : registry.get(delegate as never);\n const showPage =\n targetDef !== undefined && showDef !== undefined && hasRecordPage(showDef, 'show');\n return (row: { readonly id: string } & Record<string, unknown>): string | undefined => {\n const key = row[targetField];\n if (!showPage || key === null || key === undefined || key === '') return undefined;\n // Asked without the row: the junction row is not the target's record. The target's page\n // enforces its own record-level rule when it opens.\n if (targetGate('show').state !== 'available') return undefined;\n return resourceShowHref(registry, targetDef, targetName, String(key));\n };\n }, [registry, targetName, targetField, targetGate]);\n const rowHref = useMemo(\n () =>\n effectiveOpen === 'none'\n ? undefined\n : targetHref !== undefined\n ? targetHref\n : quickRows\n ? (row: { readonly id: string } & Record<string, unknown>) =>\n gate(resource, 'show', row).state === 'undecided' ? undefined : routing.rowHref(row)\n : routing.rowHref,\n [effectiveOpen, targetHref, quickRows, gate, resource, routing.rowHref],\n );\n\n // Cards and timeline draw the same rows from the same controller (P6 3.13); the route list\n // draws them too when its `views.list.view` says so (P7-36), else it is the table.\n const effectiveView: 'table' | 'cards' | 'timeline' = route\n ? ((def?.views?.list as { readonly view?: 'table' | 'cards' | 'timeline' } | undefined)?.view ??\n 'table')\n : (view ?? 'table');\n const tableView = effectiveView === 'table';\n const rowsViewFor = useMemo(\n () =>\n tableView\n ? undefined\n : (planned: ItemHandle | undefined) => ({\n skeleton:\n effectiveView === 'cards' ? <RelatedCardsSkeleton /> : <RelatedTimelineSkeleton />,\n render: (rows: readonly (typeof list.rows)[number][]) => {\n const common = {\n resource,\n placementKey: placementKey ?? resource,\n rows,\n // A placement's item is its own prop; the route list's is its frame's plan.\n item: route ? planned : item,\n // The route list draws the columns it would show as a table.\n columns: route ? columns.visible : columnNames,\n rowQuick,\n rowHref,\n };\n return (\n <Suspense\n fallback={\n effectiveView === 'cards' ? (\n <RelatedCardsSkeleton />\n ) : (\n <RelatedTimelineSkeleton />\n )\n }\n >\n {effectiveView === 'cards' ? (\n <RelatedCards {...common} />\n ) : (\n <RelatedTimeline {...common} />\n )}\n </Suspense>\n );\n },\n }),\n [\n tableView,\n effectiveView,\n route,\n resource,\n placementKey,\n item,\n columns.visible,\n columnNames,\n rowQuick,\n rowHref,\n ],\n );\n\n // Render-time so the H1 flips live on a language switch (was reading the\n // frozen `def.label`, which is baked at app-construction time).\n const pageTitle = resolveResourceLabel(listCaps, resource, 'plural', def);\n\n /**\n * Saved-view dialogs (A4.1-A4.3, extended Task 9) are page-local UI so\n * the primitive stays presentational: the save-prompt is a single-input\n * shadcn Dialog (plus a scope picker when more than one write scope\n * exists), the manage dialog lists entries with per-row delete, and\n * separate rename/fork dialogs cover the dropdown's inline actions. The\n * controller supplies the entries themselves plus `apply` / `saveCurrent`\n * / `renameUser` / `deleteUser` / `forkView` — all mutations `await`ed\n * here; every dialog stays OPEN and surfaces a toast on a rejected/\n * conflict result, closing only on success (Task 9).\n */\n const [saveOpen, setSaveOpen] = useState(false);\n const [saveLabel, setSaveLabel] = useState('');\n const [saveScopeId, setSaveScopeId] = useState<string | undefined>(undefined);\n const [manageOpen, setManageOpen] = useState(false);\n const [renameOpen, setRenameOpen] = useState(false);\n const [renameTarget, setRenameTarget] = useState<SavedViewEntry | null>(null);\n const [renameLabel, setRenameLabel] = useState('');\n const [forkOpen, setForkOpen] = useState(false);\n const [forkTarget, setForkTarget] = useState<SavedViewEntry | null>(null);\n const [forkScopeId, setForkScopeId] = useState<string | undefined>(undefined);\n\n const canSaveCurrent = savedViews.writeScopes.length > 0;\n // Fork always needs somewhere writable to land (spec §5's \"copy into a\n // writable scope\"), regardless of any one entry's own `permissions.fork`\n // — mirrors `canSaveCurrent` so a fork-permitted entry with zero write\n // scopes never renders a clickable-but-inert affordance (fix: a bare\n // `entry.permissions.fork` gate let that happen).\n const canFork = savedViews.writeScopes.length > 0;\n\n const handleSaveCurrent = () => {\n setSaveLabel('');\n setSaveScopeId(savedViews.writeScopes[0]?.id);\n setSaveOpen(true);\n };\n\n const handleSaveConfirm = async () => {\n const label = saveLabel.trim();\n if (label.length === 0) return;\n try {\n // The controller snapshots the live URL state itself; it rejects on\n // a failed store mutation (Task 8 — the settings store backing\n // saved views is async), so the toast wiring stays here. A single\n // write scope saves directly (`scopeId` omitted, spec §5); more than\n // one requires the picker's explicit answer to \"for whom?\" (Task 9).\n await savedViews.saveCurrent(\n label,\n savedViews.writeScopes.length > 1 ? saveScopeId : undefined,\n );\n setSaveOpen(false);\n toast.success(t('toolbar.viewsSaved', { params: { label } }));\n } catch {\n // Dialog stays open — the user can retry or cancel.\n toast.error(t('toolbar.viewsSaveFailed'));\n }\n };\n\n const handleManage = () => {\n setManageOpen(true);\n };\n\n /**\n * Delete a user view (Task 8 — `savedViews.deleteUser` is async now).\n * Fired fire-and-forget from either the manage dialog's row button or the\n * dropdown's inline delete action; a failed mutation surfaces the same\n * generic error toast `handleSaveConfirm` uses rather than leaving an\n * unhandled rejection.\n */\n const handleDeleteUserView = (id: string) => {\n void savedViews.deleteUser(id).catch(() => {\n toast.error(t('toolbar.viewsDeleteFailed'));\n });\n };\n\n /** Opens the rename dialog for one entry (Task 9), prefilled with its current label. */\n const handleRenameEntry = (entry: SavedViewEntry) => {\n setRenameTarget(entry);\n setRenameLabel(entry.label);\n setRenameOpen(true);\n };\n\n const handleRenameConfirm = async () => {\n if (renameTarget === null) return;\n const label = renameLabel.trim();\n if (label.length === 0) return;\n try {\n await savedViews.renameUser(renameTarget.id, label);\n setRenameOpen(false);\n setRenameTarget(null);\n } catch {\n // Dialog stays open — the user can retry or cancel.\n toast.error(t('toolbar.viewsRenameFailed'));\n }\n };\n\n /**\n * Fork an entry (Task 9, spec §5). One write scope forks directly, no\n * prompt; more than one opens the SAME shape of \"for whom?\" question the\n * save flow uses. Zero write scopes should never reach here — the\n * dropdown gates Fork's visibility on `canFork` (`writeScopes.length >\n * 0`) in addition to `entry.permissions.fork`, so there is normally no\n * button to click. The `scopeId === undefined` branch below is\n * defense-in-depth only (a caller wiring the dropdown without `canFork`,\n * or a future regression re-introducing the old bare-permission gate)\n * — it surfaces a toast rather than silently doing nothing.\n */\n const handleForkEntry = (entry: SavedViewEntry) => {\n if (savedViews.writeScopes.length > 1) {\n setForkTarget(entry);\n setForkScopeId(savedViews.writeScopes[0]?.id);\n setForkOpen(true);\n return;\n }\n const scopeId = savedViews.writeScopes[0]?.id;\n if (scopeId === undefined) {\n toast.error(t('toolbar.viewsForkFailed'));\n return;\n }\n void savedViews.forkView(entry.id, scopeId).catch(() => {\n toast.error(t('toolbar.viewsForkFailed'));\n });\n };\n\n const handleForkConfirm = async () => {\n if (forkTarget === null || forkScopeId === undefined) return;\n try {\n await savedViews.forkView(forkTarget.id, forkScopeId);\n setForkOpen(false);\n setForkTarget(null);\n } catch {\n // Dialog stays open — the user can retry or cancel.\n toast.error(t('toolbar.viewsForkFailed'));\n }\n };\n\n // The cell ladder (route and placement alike): a typed resource's discriminator badge, an enum\n // badge, then the app-level escape hatch.\n const renderCellLadder: NonNullable<ResourceListProps['renderCell']> = (col, value, row) => {\n // A typed resource's discriminator column renders the value's label as a badge:\n // a value a type declares is `list-cell-type:<r>:<v>`, labelled from the\n // discriminator's enum namespace (its `meta.enumNamespace`) or, without one, from the\n // field's own option slot (`fields.<by>.options.<value>`), the field's option label as\n // the inline default either way; any other value (an undeclared type, an empty one)\n // is the unknown badge.\n if (def?.types && col === def.types.by) {\n const raw = typeof value === 'string' ? value : '';\n const declared = raw !== '' && def.types.items.some((item) => item.name === raw);\n if (!declared) {\n return (\n <Badge variant=\"outline\" data-testid={`list-cell-template-unknown:${resource}`}>\n {t('list.templateUnknown')}\n </Badge>\n );\n }\n const fieldDef = def.fields[col];\n const inline = discriminatorOptionLabel(fieldDef, raw);\n const namespace = enumNamespaceOf(fieldDef as never);\n const label =\n namespace === undefined\n ? resolveFieldOptionLabel(listCaps, col, raw, inline)\n : resolveEnumLabel(listCaps, namespace, raw, inline);\n return (\n <Badge variant=\"secondary\" data-testid={`list-cell-type:${resource}:${raw}`}>\n {label}\n </Badge>\n );\n }\n // Enum-aware rendering: any field declaring `enum: '<name>'` in\n // its opts gets the framework's <EnumBadge> with the registered\n // color/label. Falls back to plain text when the enum is missing\n // from the registry — same fail-soft policy as the badge itself.\n const fieldDef = def?.fields[col] as\n | { opts?: { enum?: string }; ui?: { enum?: string } }\n | undefined;\n const enumName = fieldDef?.opts?.enum ?? fieldDef?.ui?.enum;\n if (enumName && typeof value === 'string') {\n return <EnumBadge enumName={enumName} value={value} />;\n }\n // App-level escape hatch, LAST: whatever the registry cannot\n // describe. Returning `undefined` (or omitting the prop) falls\n // through to `<ResourceList>`'s default field-type display. The\n // explicit prop wins over a registered `list.cell.<resource>`\n // slot (level 1) — a host that mounted this page and passed\n // its own `renderCell` knows more than the registry does.\n return (renderCell ?? CellSlot)?.(col, value, row);\n };\n\n const surface: ListSurfaceValue = {\n resource,\n route,\n tableView,\n searchDecl,\n FiltersSlot,\n savedViewsUi: {\n canSaveCurrent,\n canFork,\n onSaveCurrent: handleSaveCurrent,\n onManage: handleManage,\n onRenameEntry: handleRenameEntry,\n onForkEntry: handleForkEntry,\n onDeleteEntry: (entry) => handleDeleteUserView(entry.id),\n },\n openCreate,\n createAvailable,\n createPage,\n rowProps: {\n rowHref,\n ...(rowQuick === undefined ? {} : { rowQuick, rowLinkKey: gate }),\n },\n rowsViewFor,\n emptyState,\n renderCell: renderCellLadder,\n readOnly: readOnly === true,\n exportable: exportable !== false,\n };\n\n return (\n <ResourceListProvider value={list}>\n <ListPiecesProvider value={surface}>\n <div className=\"space-y-4\">\n {route ? (\n <PageHeader resource={resource} mode=\"list\" title={pageTitle} />\n ) : title === undefined && onCreate === undefined ? null : (\n <div className=\"flex items-center justify-between gap-2\">\n {title === undefined ? <span /> : <h3 className=\"text-sm font-semibold\">{title}</h3>}\n {onCreate === undefined ? null : (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n data-testid={`list-create:${resource}`}\n onClick={onCreate}\n >\n <IconPlus className=\"mr-1 h-4 w-4\" aria-hidden=\"true\" />\n {optionalT('actions.create', { defaultValue: 'Create' })}\n </Button>\n )}\n </div>\n )}\n {hasDataRuntime && <ExportRunWatcherMount />}\n\n {droppedPredicates > 0 && (\n // Predicates on fields the user may not view were left out (P5 spec 3.7): no field\n // name, no value.\n <p\n role=\"status\"\n className=\"text-[13px] leading-snug text-muted-foreground\"\n data-testid={tid.listPredicatesDropped(resource)}\n >\n {t('list.predicatesDropped')}\n </p>\n )}\n {route ? (\n <ListFrameHost resource={resource} />\n ) : (\n <>\n <ListControls />\n <ListBody />\n </>\n )}\n {route && (\n <>\n {/* Save-current-view prompt dialog. When more than one write scope\n is available, an inline scope picker asks \"for whom?\" (Task 9,\n spec §5) — a single scope saves directly, no prompt. */}\n <Dialog open={saveOpen} onOpenChange={setSaveOpen}>\n <DialogContent\n data-testid={`list-saved-view-save-dialog:${resource}`}\n className=\"max-w-sm\"\n >\n <DialogHeader>\n <DialogTitle>{t('toolbar.viewsSaveTitle')}</DialogTitle>\n <DialogDescription>{t('toolbar.viewsSaveDescription')}</DialogDescription>\n </DialogHeader>\n <Input\n autoFocus\n value={saveLabel}\n onChange={(e) => setSaveLabel(e.target.value)}\n placeholder={t('toolbar.viewsSavePlaceholder')}\n data-testid={`list-saved-view-save-input:${resource}`}\n onKeyDown={(e) => {\n if (e.key === 'Enter' && saveLabel.trim().length > 0) {\n handleSaveConfirm();\n }\n }}\n />\n {savedViews.writeScopes.length > 1 && (\n <div\n className=\"space-y-1\"\n data-testid={`list-saved-view-scope-picker:${resource}`}\n >\n <div className=\"text-xs font-medium text-muted-foreground\">\n {t('toolbar.viewsScopeDialogTitle')}\n </div>\n {savedViews.writeScopes.map((scope) => (\n <button\n key={scope.id}\n type=\"button\"\n onClick={() => setSaveScopeId(scope.id)}\n aria-pressed={saveScopeId === scope.id}\n data-testid={`list-saved-view-scope-option:${resource}:${scope.id}`}\n className={cn(\n 'w-full rounded-sm border px-2 py-1.5 text-left text-sm',\n saveScopeId === scope.id\n ? 'border-primary bg-accent text-accent-foreground'\n : 'border-input hover:bg-accent hover:text-accent-foreground',\n )}\n >\n {scopeLabel(scope)}\n </button>\n ))}\n </div>\n )}\n <DialogFooter>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => setSaveOpen(false)}\n data-testid={`list-saved-view-save-cancel:${resource}`}\n >\n {t('actions.cancel')}\n </Button>\n <Button\n type=\"button\"\n onClick={handleSaveConfirm}\n disabled={saveLabel.trim().length === 0}\n data-testid={`list-saved-view-save-confirm:${resource}`}\n >\n {t('actions.save')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n {/* Manage-views dialog: list entries (Task 9 — scope badge per row)\n with a delete button gated on `entry.permissions.remove`. */}\n <Dialog open={manageOpen} onOpenChange={setManageOpen}>\n <DialogContent\n data-testid={`list-saved-view-manage-dialog:${resource}`}\n className=\"max-w-md\"\n >\n <DialogHeader>\n <DialogTitle>{t('toolbar.viewsManageTitle')}</DialogTitle>\n <DialogDescription>{t('toolbar.viewsManageDescription')}</DialogDescription>\n </DialogHeader>\n {savedViews.entries.length === 0 ? (\n <p className=\"text-sm text-muted-foreground\">{t('toolbar.viewsManageEmpty')}</p>\n ) : (\n <ul className=\"space-y-1\">\n {savedViews.entries.map((entry) => (\n <li\n key={entry.id}\n className=\"flex items-center justify-between gap-2 rounded-sm px-2 py-1.5 hover:bg-accent hover:text-accent-foreground\"\n data-testid={`list-saved-view-manage-row:${resource}:${entry.id}`}\n >\n <span className=\"flex min-w-0 items-center gap-2 text-sm\">\n <span className=\"truncate\">{entry.label}</span>\n <Badge variant=\"outline\" className=\"shrink-0\">\n {scopeLabel(entry.scope)}\n </Badge>\n </span>\n {entry.permissions.remove ? (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() => handleDeleteUserView(entry.id)}\n data-testid={`list-saved-view-manage-delete:${resource}:${entry.id}`}\n >\n {t('actions.delete')}\n </Button>\n ) : (\n <span className=\"shrink-0 text-xs text-muted-foreground\">\n {t('toolbar.viewsReadOnly')}\n </span>\n )}\n </li>\n ))}\n </ul>\n )}\n <DialogFooter>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => setManageOpen(false)}\n data-testid={`list-saved-view-manage-close:${resource}`}\n >\n {t('actions.close')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n {/* Rename dialog (Task 9) — opened from the dropdown's inline\n Rename action; prefilled with the entry's current label. */}\n <Dialog\n open={renameOpen}\n onOpenChange={(next) => {\n setRenameOpen(next);\n if (!next) setRenameTarget(null);\n }}\n >\n <DialogContent\n data-testid={`list-saved-view-rename-dialog:${resource}`}\n className=\"max-w-sm\"\n >\n <DialogHeader>\n <DialogTitle>{t('toolbar.viewsRenameTitle')}</DialogTitle>\n <DialogDescription>{t('toolbar.viewsRenameDescription')}</DialogDescription>\n </DialogHeader>\n <Input\n autoFocus\n value={renameLabel}\n onChange={(e) => setRenameLabel(e.target.value)}\n data-testid={`list-saved-view-rename-input:${resource}`}\n onKeyDown={(e) => {\n if (e.key === 'Enter' && renameLabel.trim().length > 0) {\n handleRenameConfirm();\n }\n }}\n />\n <DialogFooter>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => {\n setRenameOpen(false);\n setRenameTarget(null);\n }}\n data-testid={`list-saved-view-rename-cancel:${resource}`}\n >\n {t('actions.cancel')}\n </Button>\n <Button\n type=\"button\"\n onClick={handleRenameConfirm}\n disabled={renameLabel.trim().length === 0}\n data-testid={`list-saved-view-rename-confirm:${resource}`}\n >\n {t('actions.save')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n {/* Fork \"for whom?\" dialog (Task 9, spec §5) — only reached when\n more than one write scope exists; a single scope forks directly\n with no prompt (see `handleForkEntry`). */}\n <Dialog\n open={forkOpen}\n onOpenChange={(next) => {\n setForkOpen(next);\n if (!next) setForkTarget(null);\n }}\n >\n <DialogContent\n data-testid={`list-saved-view-fork-dialog:${resource}`}\n className=\"max-w-sm\"\n >\n <DialogHeader>\n <DialogTitle>{t('toolbar.viewsScopeDialogTitle')}</DialogTitle>\n <DialogDescription>\n {t('toolbar.viewsScopeDialogDescription')}\n </DialogDescription>\n </DialogHeader>\n <div className=\"space-y-1\">\n {savedViews.writeScopes.map((scope) => (\n <button\n key={scope.id}\n type=\"button\"\n onClick={() => setForkScopeId(scope.id)}\n aria-pressed={forkScopeId === scope.id}\n data-testid={`list-saved-view-fork-scope-option:${resource}:${scope.id}`}\n className={cn(\n 'w-full rounded-sm border px-2 py-1.5 text-left text-sm',\n forkScopeId === scope.id\n ? 'border-primary bg-accent text-accent-foreground'\n : 'border-input hover:bg-accent hover:text-accent-foreground',\n )}\n >\n {scopeLabel(scope)}\n </button>\n ))}\n </div>\n <DialogFooter>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => {\n setForkOpen(false);\n setForkTarget(null);\n }}\n data-testid={`list-saved-view-fork-cancel:${resource}`}\n >\n {t('actions.cancel')}\n </Button>\n <Button\n type=\"button\"\n onClick={handleForkConfirm}\n disabled={forkScopeId === undefined}\n data-testid={`list-saved-view-fork-confirm:${resource}`}\n >\n {t('toolbar.viewsFork')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </>\n )}\n <ListBulkBar />\n </div>\n </ListPiecesProvider>\n </ResourceListProvider>\n );\n}\n\n/**\n * Renders nothing — exists solely so `useExportRunWatcher()` (a HARD hook;\n * see `run-watcher.ts`) is only ever called from a component that is itself\n * only mounted once `<ResourceListSurface>` has already confirmed (via\n * `useOptionalDataRuntime()`, which never throws) that a native data\n * runtime exists. This is what lets `<ResourceListPage>` mount the watcher\n * unconditionally on that ONE checked condition without ever conditionally\n * calling a hook from inside a single component's own body — this\n * component's own hook call sequence never varies across its lifetime,\n * because it only ever exists under a confirmed runtime.\n */\nfunction ExportRunWatcherMount(): null {\n useExportRunWatcher();\n return null;\n}\n","import { declaredField, fieldSensitivity } from '@burojs/core';\nimport type { CapabilityResolver } from '@burojs/react';\n\n/** What `peekFields` reads of a resource definition. */\nexport interface PeekFieldSource {\n readonly displayField?: string;\n readonly fields: Readonly<Record<string, unknown>>;\n readonly types?: {\n readonly items: readonly { readonly fields: readonly { readonly name: string }[] }[];\n };\n}\n\n/**\n * A field's definition by name: a base field, else a type's own field (Known finding 2: a field a\n * type declares lives in `types.items[].fields`, never in the base map).\n */\nexport function peekFieldDefinition(def: PeekFieldSource, name: string): unknown {\n return declaredField(def, name);\n}\n\n/**\n * Whether a peek may show `name` (P3-38, P6-66): the field is declared, not `sensitive`, and\n * not hidden from this viewer by the target's `column` rule — \"nothing a page would hide may\n * surface on hover\". The default body and a declared peek body both apply it. The third\n * condition is P5's field view in record reach (spec 3.6.5): `fieldVisible` is true only for a\n * `visible` field, so a hidden, restricted or still undecided field is not allowed.\n */\nexport function peekLeafAllowed(\n def: PeekFieldSource,\n name: string,\n capabilityFor: CapabilityResolver,\n fieldVisible: (name: string) => boolean,\n): boolean {\n const field = peekFieldDefinition(def, name);\n if (field === undefined || fieldSensitivity(field) !== undefined) return false;\n if (capabilityFor('view', { kind: 'column', name }).allowed === false) return false;\n return fieldVisible(name);\n}\n\n/**\n * The row a declared peek body is planned over: the id field and every field\n * {@link peekLeafAllowed} admits keep their values; every other field reads `null` — its leaf\n * renders absent, and a block prop reading it reads `null` (spec 3.9). With `drawn`, the row is\n * narrowed to the fields the body draws (P5 spec 3.6.5, for a peek frame's `record` prop): every\n * field outside it reads `null`, whatever the filter allows.\n */\nexport function peekRow(\n def: PeekFieldSource,\n row: Readonly<Record<string, unknown>>,\n idField: string,\n capabilityFor: CapabilityResolver,\n fieldVisible: (name: string) => boolean,\n drawn?: ReadonlySet<string>,\n): Readonly<Record<string, unknown>> {\n const out: Record<string, unknown> = {};\n for (const [name, value] of Object.entries(row))\n out[name] =\n name === idField ||\n ((drawn === undefined || drawn.has(name)) &&\n peekLeafAllowed(def, name, capabilityFor, fieldVisible))\n ? value\n : null;\n return Object.freeze(out);\n}\n\n/**\n * The peek's `record` (the row a declared body is planned over and a peek frame's `record` starts\n * from): {@link peekRow} over the target's definition, and the id field alone when the target has\n * no registry definition — without a definition nothing can be filtered, so nothing but the id\n * leaves (fail closed).\n */\nexport function peekRecord(\n def: PeekFieldSource | undefined,\n row: Readonly<Record<string, unknown>>,\n idField: string,\n capabilityFor: CapabilityResolver,\n fieldVisible: (name: string) => boolean,\n): Readonly<Record<string, unknown>> {\n if (def === undefined) return Object.freeze({ [idField]: row[idField] });\n return peekRow(def, row, idField, capabilityFor, fieldVisible);\n}\n","'use client';\nimport type { ScopeSource } from '@burojs/core';\nimport { useOptionalT } from '@burojs/react';\nimport type { ReactElement } from 'react';\n\n/**\n * A related list bound to no rows (a `where` value that resolved to nothing, a link panel whose\n * record is not read yet): the empty state, and no request.\n */\nexport function UnboundRelatedList(props: {\n readonly resource: string;\n readonly title?: string | undefined;\n}): ReactElement {\n const t = useOptionalT();\n return (\n <div className=\"flex flex-col gap-2\" data-testid={`list-unbound:${props.resource}`}>\n {props.title === undefined ? null : <h3 className=\"text-sm font-semibold\">{props.title}</h3>}\n <p className=\"text-sm text-muted-foreground\">\n {t('table.empty', { defaultValue: 'No records' })}\n </p>\n </div>\n );\n}\n\n/**\n * Where a placement's reads take their scope from: its own `scope`, else `'none'` on a record's\n * card (a tab lists what belongs to the record, whatever the session's scope) and `'session'` on\n * a custom page, which has no record around it.\n */\nexport function placementScope(\n scope: ScopeSource | undefined,\n owner: string | undefined,\n): ScopeSource {\n return scope ?? (owner === undefined ? 'session' : 'none');\n}\n","'use client';\nimport {\n type CountPolicy,\n type EntityRef,\n type FilterOperator,\n type FixedFilterInput,\n type DtoSource,\n type LinkDeclaration,\n dtoFields,\n fieldSensitivity,\n isRelationField,\n linkOf,\n normalizeEntityRef,\n resourceKey,\n whereEntryToFilter,\n} from '@burojs/core';\nimport { resolveColumnField, useApp, useOptionalRecordFrame } from '@burojs/react';\nimport { type ReactElement, useMemo } from 'react';\nimport { ResourceListSurface } from '../list-kit/resource-list-surface.js';\nimport { type PeekFieldSource, peekFieldDefinition } from '../quick/peek-filter.js';\nimport { useIsRouteScreen } from '../record/route-screen-context.js';\nimport { usePlacementFrame } from './placement-frame.js';\nimport { UnboundRelatedList, placementScope } from './related-list-unbound.js';\nimport type { RelatedListViewProps } from './related-list-view.js';\n\ntype Rec = Readonly<Record<string, unknown>>;\n\nconst isRecord = (value: unknown): value is Rec =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst isResourceHandle = (value: unknown): value is { readonly ref: EntityRef } =>\n isRecord(value) && value.kind === 'resource';\n\n/** `ref` (a name, an entity ref or a resource handle) as a registry key in `owner`'s namespace. */\nfunction qualify(ref: unknown, owner: string): string | undefined {\n try {\n const namespace = normalizeEntityRef(owner).namespace;\n return resourceKey(\n normalizeEntityRef((isResourceHandle(ref) ? ref.ref : ref) as EntityRef, {\n defaultNamespace: namespace,\n }),\n );\n } catch {\n return undefined;\n }\n}\n\n/** The link field `link` of `owner` (a base field or a type's), or undefined when it is none. */\nfunction linkField(\n registry: { get(name: string): unknown },\n owner: string | undefined,\n link: string,\n): { readonly field: Rec; readonly declaration: LinkDeclaration } | undefined {\n if (owner === undefined) return undefined;\n const def = registry.get(owner) as PeekFieldSource | undefined;\n const field = def === undefined ? undefined : peekFieldDefinition(def, link);\n if (!isRecord(field)) return undefined;\n const declaration = linkOf(field);\n return declaration === undefined ? undefined : { field, declaration };\n}\n\n/**\n * The registry name of the target of the link field `link` of `owner` (the resource whose screen\n * holds the placement; the field is a base field or a type's), resolved against the owner's\n * namespace; undefined without an owner or when `link` is no link field of it.\n */\nexport function linkTarget(\n registry: { get(name: string): unknown },\n owner: string | undefined,\n link: string,\n): string | undefined {\n const found = linkField(registry, owner, link);\n if (found === undefined || owner === undefined) return undefined;\n return qualify((found.field.meta as Rec | undefined)?.to, owner);\n}\n\nfunction idFieldOf(def: unknown): string {\n const declared = isRecord(def) && isRecord(def.data) ? def.data.idField : undefined;\n return typeof declared === 'string' && declared.length > 0 ? declared : 'id';\n}\n\n/** The field a relation keys its target by (`meta.by`), when it is not the target's id. */\nfunction byOf(field: unknown): string | undefined {\n const by = isRecord(field) && isRecord(field.meta) ? field.meta.by : undefined;\n return typeof by === 'string' && by.length > 0 ? by : undefined;\n}\n\n/** The most relations of the target a panel's dotted column may cross (one more reaches it). */\nconst MAX_TARGET_HOPS = 2;\n\n/**\n * The target's list columns a dotted column can end at: its `views.list.columns`, else the fields\n * a list row of it holds. A relation or a link (a hop needs a field after it), a sensitive or\n * undeclared field, and a path across more relations than a panel reads are left out silently:\n * the target's list columns are its own page's, and drawing fewer of them is no error of the panel.\n */\nfunction targetColumns(\n registry: Parameters<typeof resolveColumnField>[0],\n target: string,\n def: unknown,\n): readonly string[] {\n if (!isRecord(def) || !isRecord(def.fields)) return [];\n const source = def as unknown as DtoSource & PeekFieldSource;\n const views = isRecord(def.views) ? def.views : undefined;\n const list = views !== undefined && isRecord(views.list) ? views.list : undefined;\n const declared =\n list !== undefined && Array.isArray(list.columns)\n ? list.columns.filter((name): name is string => typeof name === 'string')\n : dtoFields(source, 'list');\n return declared.filter((name) => {\n // A dotted column of the target: declared to-one hops to a declared, non-relation,\n // non-sensitive field, within the panel's hop budget.\n if (name.includes('.'))\n return (\n name.split('.').length - 1 <= MAX_TARGET_HOPS &&\n resolveColumnField(registry, target, name) !== undefined\n );\n const field = peekFieldDefinition(source, name);\n return isRecord(field) && !isRelationField(field) && fieldSensitivity(field) === undefined;\n });\n}\n\n/** What the panel reads: the junction, its keys, and how a row reaches its target. */\ninterface PanelStorage {\n readonly junction: string;\n readonly target: string;\n readonly sourceKey: string;\n readonly targetKey: string;\n /** The owner's field the junction's `sourceKey` holds (its relation's `by`, else the id). */\n readonly ownerField: string;\n /** The junction's `targetKey` relation keys the target by a non-id field: no row opens. */\n readonly targetKeyedBy: boolean;\n readonly where: LinkDeclaration['where'];\n readonly targetDef: unknown;\n}\n\n/**\n * A link panel (`relatedList({ link })`): the record's links of one link field, shown as target\n * rows and read as junction rows. Target `columns` (else the target's list columns) are read\n * through the junction's `targetKey` hop as dotted columns, `linkColumns` are the junction's own;\n * the owner key, the link's `through.where` and the placement's `where` (on target fields,\n * through the hop) are locked filters, so paging and the count count links. Read-only: no\n * create, no row actions, no selection. A row opens the target record's page, or nothing when\n * `open` is `'none'` or the junction keys the target by a non-id field.\n */\nexport function LinkPanel(props: {\n readonly link: string;\n readonly owner: string;\n readonly own: RelatedListViewProps;\n}): ReactElement {\n const { link, owner, own } = props;\n const app = useApp();\n const frame = usePlacementFrame();\n const routeScreen = useIsRouteScreen();\n const record = useOptionalRecordFrame()?.record;\n\n const storage = useMemo<PanelStorage | undefined>(() => {\n const found = linkField(app.registry, owner, link);\n if (found === undefined) return undefined;\n const { declaration } = found;\n const junction = qualify(declaration.junction, owner);\n const target = qualify((found.field.meta as Rec | undefined)?.to, owner);\n if (junction === undefined || target === undefined) return undefined;\n const junctionDef = app.registry.get(junction);\n if (junctionDef === undefined) return undefined;\n const junctionFields = junctionDef.fields as Rec;\n return {\n junction,\n target,\n sourceKey: declaration.sourceKey,\n targetKey: declaration.targetKey,\n ownerField: byOf(junctionFields[declaration.sourceKey]) ?? idFieldOf(app.registry.get(owner)),\n targetKeyedBy: byOf(junctionFields[declaration.targetKey]) !== undefined,\n where: declaration.where,\n targetDef: app.registry.get(target),\n };\n }, [app.registry, owner, link]);\n\n const ownerKey = storage === undefined ? undefined : record?.[storage.ownerField];\n const whereKey = JSON.stringify(own.where ?? []);\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the where's value, not its identity\n const fixedFilters = useMemo<readonly FixedFilterInput[] | undefined>(() => {\n if (storage === undefined || ownerKey === null || ownerKey === undefined) return undefined;\n const { sourceKey, targetKey } = storage;\n return [\n whereEntryToFilter(sourceKey, 'eq', ownerKey),\n ...storage.where.map((entry) => whereEntryToFilter(entry.field, entry.op, entry.value)),\n ...(own.where ?? []).map((entry) =>\n whereEntryToFilter(`${targetKey}.${entry.field}`, entry.op as FilterOperator, entry.value),\n ),\n ];\n }, [storage, ownerKey, whereKey]);\n\n const columnsKey = JSON.stringify([own.columns ?? null, own.linkColumns ?? null]);\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the columns' value\n const columns = useMemo<readonly string[] | undefined>(() => {\n if (storage === undefined) return undefined;\n const shown = own.columns ?? targetColumns(app.registry, storage.target, storage.targetDef);\n return [...shown.map((name) => `${storage.targetKey}.${name}`), ...(own.linkColumns ?? [])];\n }, [storage, columnsKey, app.registry]);\n\n const rowTarget = useMemo(\n () =>\n storage === undefined || storage.targetKeyedBy\n ? undefined\n : { resource: storage.target, field: storage.targetKey },\n [storage],\n );\n\n // A record not read yet (or a create screen), a link the registry cannot resolve, or a `where`\n // value that resolved to nothing binds no links: nothing is read.\n const unbound =\n fixedFilters === undefined ||\n own.where?.some((entry) => entry.value === null || entry.value === undefined) === true;\n if (storage === undefined || unbound)\n return <UnboundRelatedList resource={storage?.target ?? ''} title={own.title} />;\n\n // URL state on the top level of a route screen only, as for any placement.\n const state =\n frame?.state === 'url' && routeScreen && !frame.nested\n ? { url: frame.key }\n : ('memory' as const);\n const count: CountPolicy | undefined = own.count === false ? 'off' : own.count;\n return (\n <ResourceListSurface\n resource={storage.junction}\n variant=\"placement\"\n state={state}\n fixedFilters={fixedFilters}\n {...(own.pageSize === undefined ? {} : { pageSize: own.pageSize })}\n {...(own.search === undefined ? {} : { search: `${storage.targetKey}.${own.search}` })}\n {...(columns === undefined ? {} : { columns })}\n open={rowTarget === undefined || own.open === 'none' ? 'none' : 'page'}\n {...(rowTarget === undefined ? {} : { rowTarget })}\n {...(frame === null ? {} : { placementKey: frame.key })}\n {...(own.title === undefined ? {} : { title: own.title })}\n scope={placementScope(own.scope, owner)}\n {...(count === undefined ? {} : { count })}\n readOnly\n exportable={false}\n />\n );\n}\n","import type { ReactNode } from 'react';\nimport { createContext, useContext } from 'react';\nimport type { ResourceListPageProps } from '../list-kit/resource-list-page.js';\n\n/**\n * What `ResourceListPage` hands the `related-list` view: its route-only props. Its presence is\n * what selects the route variant (decision 63). Internal.\n */\nexport interface RouteListValue {\n readonly meta?: Record<string, unknown>;\n readonly renderCell?: ResourceListPageProps['renderCell'];\n readonly emptyState?: ReactNode;\n}\n\nexport const RouteListContext = createContext<RouteListValue | null>(null);\n\nexport function useRouteList(): RouteListValue | null {\n return useContext(RouteListContext);\n}\n","'use client';\nimport {\n type AppContext,\n type CountPolicy,\n type EntityRef,\n type FilterOperator,\n type FixedFilterInput,\n type ScopeSource,\n grantedPlacementKeys,\n resourceKey,\n whereEntryToFilter,\n} from '@burojs/core';\nimport {\n type BlockViewProps,\n useApp,\n useCtx,\n useEntryGate,\n useQuick,\n useQuickEntry,\n} from '@burojs/react';\nimport { useDeepLinkOpen } from '../quick/use-deep-link.js';\nimport { type PortableWhereEntry, placementSeeds } from './placement-seeds.js';\nimport { type ReactElement, useEffect, useMemo, useRef } from 'react';\nimport { ResourceListSurface } from '../list-kit/resource-list-surface.js';\nimport { useIsRouteScreen } from '../record/route-screen-context.js';\nimport { LinkPanel, linkTarget } from './link-panel.js';\nimport { usePlacementFrame } from './placement-frame.js';\nimport { isItemHandle } from './related-item.js';\nimport { RelatedCardsSkeleton, RelatedTimelineSkeleton } from './related-skeletons.js';\nimport { UnboundRelatedList, placementScope } from './related-list-unbound.js';\nimport { useRouteList } from './route-list-context.js';\n\n/** The props of `buro:related-list` as its view receives them (each schema's output). */\nexport interface RelatedListViewProps {\n /** Absent on a link list: its resource is the link field's target. */\n readonly resource?: EntityRef;\n /** A link field of the record's resource: the list shows that record's links. */\n readonly link?: string;\n readonly where?: readonly {\n readonly field: string;\n readonly op: string;\n readonly value: unknown;\n }[];\n readonly columns?: readonly string[];\n readonly pageSize?: number;\n readonly search?: string;\n readonly open?: 'page' | 'none' | 'quick';\n readonly title?: string;\n /** Absent: a card tab reads `'none'`, a list on a page keeps the session's scope. */\n readonly scope?: ScopeSource;\n readonly view?: 'table' | 'cards' | 'timeline';\n /** The planned item node, drawn once per row; absent on the route list and without `item`. */\n readonly item?: unknown;\n /** A link list's junction columns, after its target columns. */\n readonly linkColumns?: readonly string[];\n /** When the list reads its total, in place of the listed resource's; `false` is `'off'`. */\n readonly count?: CountPolicy | false;\n /** A link list's attach and detach controls: none (`false`) is the only value. */\n readonly linkActions?: false;\n}\n\n/**\n * The built-in `buro:related-list` view (spec 8.4): the route list when `ResourceListPage` renders\n * it, a placement otherwise. A placement's `where` is a locked filter (user and URL filters\n * conjoin it, never replace it), its state lives in memory, or in the URL under its key when\n * the node says `state: 'url'` at the top level of a route screen (a record route or a page); a\n * `where` value that resolved to null lists nothing and sends no request.\n */\nexport function RelatedListView({ props }: BlockViewProps<unknown>): ReactElement {\n const own = props as unknown as RelatedListViewProps;\n const route = useRouteList();\n const frame = usePlacementFrame();\n const app = useApp();\n // Derived before any hook that reads it: a link list has no `resource` prop, its resource is\n // the link's target ('' when the link names no link field of the record's resource).\n const linked = own.link !== undefined;\n const resource = linked\n ? (linkTarget(app.registry, frame?.owner, own.link as string) ?? '')\n : resourceKey(own.resource as EntityRef);\n const whereKey = JSON.stringify(own.where ?? []);\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the where's value, not its identity\n const fixedFilters = useMemo<readonly FixedFilterInput[] | undefined>(\n () =>\n own.where === undefined\n ? undefined\n : own.where.map(({ field, op, value }) =>\n whereEntryToFilter(field, op as FilterOperator, value),\n ),\n [whereKey],\n );\n const columnsKey = JSON.stringify(own.columns ?? null);\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the columns' value\n const columns = useMemo(() => own.columns, [columnsKey]);\n const routeScreen = useIsRouteScreen();\n // Inside a quick entry an inherited `state: 'url'` is expected to fall back (spec 4.13 item 4).\n const inQuick = useQuickEntry() !== null;\n useMemoryNotice(frame, routeScreen || inQuick, route !== null);\n const permissions = useCtx((c: AppContext) => c.permissions);\n const gate = useEntryGate();\n const quick = useQuick();\n // A placement's \"+ Create\" (spec 4.5, P3-18): only a top-level placement on a record screen\n // whose key no granted layer placed or changed (plan rulings 1 and 21; an unknown marker is\n // untrusted), and only when the target's quick create passes the entry gate. It opens\n // `quick.create` — a new overlay, above the sheet when inside one — seeded from the trusted\n // `where` values only.\n const ownerDef = frame?.owner === undefined ? undefined : app.registry.get(frame.owner);\n const granted = ownerDef === undefined ? 'unknown' : grantedPlacementKeys(ownerDef);\n const trusted =\n frame !== null && !frame.nested && granted !== 'unknown' && !granted.has(frame.key);\n const createOpen =\n route === null && !linked && trusted && gate(resource, 'create').state === 'open';\n const onCreate =\n createOpen && frame !== null\n ? () =>\n void quick.create(resource, {\n defaults: placementSeeds(\n (frame.where ?? []) as readonly PortableWhereEntry[],\n own.where ?? [],\n frame.closure ?? {},\n ),\n })\n : undefined;\n // The deep link `?<key>.open=<id>` (spec 4.8): a drawn top-level placement on a route screen\n // whose rows open quick entries consumes it.\n useDeepLinkOpen(\n frame?.key ?? null,\n resource,\n route === null &&\n !linked &&\n frame !== null &&\n !frame.nested &&\n routeScreen &&\n (own.open ?? 'quick') === 'quick',\n );\n // A `where` value that resolved to nothing (a null relation key) binds no rows: the list is\n // empty and no list, count or export request goes out — never `field eq null`, whose meaning\n // is the backend's (spec Review Focus 2).\n const unbound =\n own.where?.some((entry) => entry.value === null || entry.value === undefined) === true;\n // A link list's rows are the record's links, read through the junction: never a list of every\n // target row, so it is no placement over `resource`.\n if (linked)\n return frame?.owner === undefined ? (\n <UnboundRelatedList resource={resource} title={own.title} />\n ) : (\n <LinkPanel link={own.link as string} owner={frame.owner} own={own} />\n );\n if (route !== null)\n return (\n <ResourceListSurface\n resource={resource}\n variant=\"route\"\n {...(route.meta === undefined ? {} : { meta: route.meta })}\n {...(route.renderCell === undefined ? {} : { renderCell: route.renderCell })}\n {...(route.emptyState === undefined ? {} : { emptyState: route.emptyState })}\n />\n );\n // Cards and timeline are new hosts of the list: while the permission map loads they draw\n // their skeleton and read nothing (P6 3.14 item 9).\n if (own.view !== undefined && own.view !== 'table' && permissions?.status === 'loading')\n return (\n <div role=\"status\" aria-busy=\"true\" data-testid={`list-undecided:${resource}`}>\n {own.view === 'cards' ? <RelatedCardsSkeleton /> : <RelatedTimelineSkeleton />}\n </div>\n );\n if (unbound) return <UnboundRelatedList resource={resource} title={own.title} />;\n // URL state is honoured on the top level of a route screen only (spec 8.4, P2 4.7); anywhere\n // else the state is local, so two screens on one page never share `?<key>.` parameters, and a\n // nested placement's derived key never becomes part of a shared link.\n const state =\n frame?.state === 'url' && routeScreen && !frame.nested\n ? { url: frame.key }\n : ('memory' as const);\n // A tab of a record's card lists what belongs to the record, whatever the session's scope; a\n // list on a custom page has no record around it and keeps the session (spec 4, table).\n const scope: ScopeSource = placementScope(own.scope, frame?.owner);\n // The placement's count policy replaces the target's `views.list.count`; `false` reads none.\n const count: CountPolicy | undefined = own.count === false ? 'off' : own.count;\n return (\n <ResourceListSurface\n resource={resource}\n variant=\"placement\"\n state={state}\n {...(fixedFilters === undefined ? {} : { fixedFilters })}\n {...(own.pageSize === undefined ? {} : { pageSize: own.pageSize })}\n {...(own.search === undefined ? {} : { search: own.search })}\n {...(columns === undefined ? {} : { columns })}\n open={own.open ?? 'quick'}\n {...(own.view === undefined ? {} : { view: own.view })}\n {...(isItemHandle(own.item) ? { item: own.item } : {})}\n {...(frame === null ? {} : { placementKey: frame.key })}\n {...(own.title === undefined ? {} : { title: own.title })}\n scope={scope}\n {...(count === undefined ? {} : { count })}\n {...(onCreate === undefined ? {} : { onCreate })}\n />\n );\n}\n\n/**\n * In development, one `console.warn` per key per mount when a placement asks for `state: 'url'`\n * and keeps its state in memory instead: the checker cannot see where a host renders a screen\n * (P2 4.7), and it warns `list.url-state-nested` only where it can see the nesting.\n */\nfunction useMemoryNotice(\n frame: ReturnType<typeof usePlacementFrame>,\n routeScreen: boolean,\n routeList: boolean,\n): void {\n const warned = useRef<string | null>(null);\n const why =\n routeList || frame === null || frame.state !== 'url'\n ? undefined\n : frame.nested\n ? 'it is nested in a block'\n : routeScreen\n ? undefined\n : 'this screen is not a route screen';\n const key = frame?.key;\n useEffect(() => {\n if (why === undefined || key === undefined || process.env.NODE_ENV === 'production') return;\n if (warned.current === key) return;\n warned.current = key;\n console.warn(`[burojs] The list \"${key}\" keeps its state in memory: ${why}.`);\n }, [key, why]);\n}\n","'use client';\nimport {\n type EntityRef,\n dtoFields,\n fieldSensitivity,\n projectDto,\n resolveFieldLabel,\n resourceKey,\n declaredText,\n} from '@burojs/core';\nimport {\n type BlockViewProps,\n useApp,\n useCapabilityResolver,\n useFieldAccess,\n useI18nCaps,\n useOne,\n useOptionalT,\n useProjectedRecord,\n} from '@burojs/react';\nimport { type ReactElement, useMemo } from 'react';\nimport { ActionOverflow } from '../actions/action-overflow.js';\nimport { ResolvedFieldDisplay } from '../fields/resolved-field.js';\nimport { toDisplayText } from '../fields/display-value.js';\nimport { Skeleton } from '../primitives/skeleton.js';\nimport { FIELD_LABEL_SHOW } from '../screen/field-leaf.js';\n\n/** The props of `buro:related-record` as its view receives them (each schema's output). */\ninterface RelatedRecordViewProps {\n readonly resource: EntityRef;\n readonly record: unknown;\n readonly title?: string;\n readonly fields?: readonly string[];\n readonly toolbar?: 'item' | 'none';\n readonly missing?: string;\n}\n\n/**\n * A field's definition by name: a base field, else a type's own field (the record DTO is the union\n * over types), so its sensitivity, label and display are read for a typed target too.\n */\nfunction fieldDefinition(\n def: {\n readonly fields: Readonly<Record<string, unknown>>;\n readonly types?: {\n readonly items: readonly { readonly fields: readonly { readonly name: string }[] }[];\n };\n },\n name: string,\n): unknown {\n if (Object.hasOwn(def.fields, name)) return def.fields[name];\n for (const type of def.types?.items ?? [])\n for (const field of type.fields ?? []) if (field.name === name) return field;\n return undefined;\n}\n\n/** A record id as a ref resolves it: `null` for none. */\nfunction recordId(value: unknown): string | null {\n if (typeof value === 'string') return value === '' ? null : value;\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n return null;\n}\n\nfunction Missing({ text }: { readonly text: string | undefined }): ReactElement {\n const t = useOptionalT();\n return (\n <p className=\"text-sm text-muted-foreground\">\n {text ?? t('table.empty', { defaultValue: 'No records' })}\n </p>\n );\n}\n\n/**\n * The built-in `buro:related-record` view (spec 8.4): one record of another resource in a panel.\n * It reads the target with the target's record DTO projection and renders each of `fields`\n * (default: the record DTO's fields, sensitive ones left out) with the field's display under its\n * label, minus the fields the target's `column` rules deny; the record is the DTO (decision 41),\n * so an undeclared column never renders. `toolbar: 'item'` shows the target's item actions under\n * its own rules; a null `record` renders `missing` and reads nothing.\n */\nexport function RelatedRecordView({ props }: BlockViewProps<unknown>): ReactElement {\n const own = props as unknown as RelatedRecordViewProps;\n const app = useApp();\n const resource = resourceKey(own.resource);\n const def = app.registry.get(resource);\n const id = recordId(own.record);\n const caps = useI18nCaps(resource);\n const capabilityFor = useCapabilityResolver(resource, undefined, 'show');\n const projection = useMemo(\n () => (def === undefined ? undefined : dtoFields(def, 'record')),\n [def],\n );\n const query = useOne(resource, {\n id: id ?? '',\n enabled: id !== null,\n ...(projection === undefined ? {} : { projection }),\n });\n // The target's rows are read with the record DTO, then decided in record reach over the row as\n // read (P5 spec 3.6): a field the viewer may not see never reaches a label, a value or a title.\n const result = query.data as { readonly data?: unknown } | undefined;\n const raw = result?.data;\n const dtoRow = useMemo(\n () =>\n raw !== null && typeof raw === 'object' && projection !== undefined\n ? projectDto(raw as Readonly<Record<string, unknown>>, projection)\n : undefined,\n [raw, projection],\n );\n const access = useFieldAccess(resource, 'record', dtoRow);\n const projected = useProjectedRecord(resource, dtoRow, {\n placeholder: query.isPlaceholderData === true,\n });\n const fieldsKey = JSON.stringify(own.fields ?? null);\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the fields' value\n const shown = useMemo(() => {\n if (def === undefined || projection === undefined) return [];\n const declared = new Set(projection);\n const wanted =\n own.fields ??\n projection.filter((name) => fieldSensitivity(fieldDefinition(def, name)) === undefined);\n // Only declared fields of the DTO, and only those the target's column rules let this viewer see.\n return wanted.filter(\n (name) =>\n declared.has(name) &&\n capabilityFor('view', { kind: 'column', name }).allowed &&\n access[name]?.view === 'visible',\n );\n }, [def, projection, fieldsKey, capabilityFor, access]);\n if (id === null) return <Missing text={own.missing} />;\n if (result === undefined) {\n if (query.error != null) return <Missing text={own.missing} />;\n return <Skeleton data-buro-skeleton=\"\" className=\"h-9 w-full\" />;\n }\n if (dtoRow === undefined) return <Missing text={own.missing} />;\n if (projected.status === 'pending' || projected.value === null)\n return <Skeleton data-buro-skeleton=\"\" className=\"h-9 w-full\" />;\n const row = projected.value;\n return (\n <div className=\"flex flex-col gap-2\">\n {own.title === undefined && own.toolbar !== 'item' ? null : (\n <div className=\"flex items-center gap-2\">\n {own.title === undefined ? null : <h3 className=\"text-sm font-semibold\">{own.title}</h3>}\n {own.toolbar === 'item' ? (\n <ActionOverflow\n resource={resource}\n record={{ ...dtoRow, id } as { id: string } & Record<string, unknown>}\n surface=\"show\"\n />\n ) : null}\n </div>\n )}\n <dl className=\"grid gap-2 sm:grid-cols-2\">\n {shown.map((name) => {\n const field = fieldDefinition(def!, name) as { readonly label?: string } | undefined;\n const value = row[name];\n return (\n <div key={name} className=\"flex min-w-0 flex-col gap-0.5\">\n <dt className={FIELD_LABEL_SHOW}>\n {resolveFieldLabel(caps, name, declaredText('field', field, 'label'))}\n </dt>\n <dd className=\"min-w-0 break-words text-sm\">\n <ResolvedFieldDisplay\n resource={own.resource}\n name={name}\n field={field as never}\n value={value}\n record={row}\n fallback={toDisplayText(value).text}\n />\n </dd>\n </div>\n );\n })}\n </dl>\n </div>\n );\n}\n","import { facts, inlineFlow, relatedList, relatedRecord } from '@burojs/core';\nimport type {\n BlockImplementation,\n BlockImplementationCatalog,\n BlockViewProps,\n} from '@burojs/react';\nimport type { ComponentType } from 'react';\nimport { FactsView } from './facts-view.js';\nimport { InlineFlowView } from '../flows/inline-flow-view.js';\nimport { RelatedListView } from './related-list-view.js';\nimport { RelatedRecordView } from './related-record-view.js';\n\n/**\n * A built-in entry whose `definition` (the block handle) is built on first read: the handles are\n * built on first use (spec decision 20), so importing the catalogue builds none.\n */\nfunction builtinEntry(\n id: string,\n component: ComponentType<BlockViewProps<unknown>>,\n definition: () => unknown,\n): BlockImplementation<unknown> {\n const [namespace, name] = id.split(':') as [string, string];\n const entry = { id, block: Object.freeze({ namespace, id: name }), component };\n Object.defineProperty(entry, 'definition', { enumerable: true, get: definition });\n return Object.freeze(entry) as BlockImplementation<unknown>;\n}\n\nfunction builtinCatalog(): BlockImplementationCatalog {\n return Object.freeze({\n 'buro:related-list': builtinEntry('buro:related-list', RelatedListView, () =>\n relatedList(undefined as never),\n ),\n 'buro:related-record': builtinEntry('buro:related-record', RelatedRecordView, () =>\n relatedRecord(undefined as never),\n ),\n 'buro:inline-flow': builtinEntry('buro:inline-flow', InlineFlowView, () => inlineFlow),\n 'buro:facts': builtinEntry('buro:facts', FactsView, () => facts),\n });\n}\n\n/**\n * The built-in block views (`buro:*`), keyed by block id. The renderer composes them first and\n * the app's `blockImplementations` over them: an app entry with a built-in id replaces that view\n * (with a development notice); a built-in cannot be dropped.\n */\nexport const shadcnBlockImplementations: BlockImplementationCatalog =\n /* @__PURE__ */ builtinCatalog();\n","'use client';\nimport { type DataError, formatEntityRef, isDataError, type PlanNode } from '@burojs/core';\nimport {\n type BlockImplementation,\n type BlockViewProps,\n type PlacementView,\n useOptionalRecordFrame,\n useOptionalT,\n usePlacement,\n} from '@burojs/react';\nimport {\n Component,\n type ComponentType,\n type ErrorInfo,\n lazy,\n type ReactElement,\n type ReactNode,\n Suspense,\n useEffect,\n useMemo,\n} from 'react';\nimport { Button } from '../primitives/button.js';\nimport { Skeleton } from '../primitives/skeleton.js';\nimport { useScreenTree } from '../screen/tree-context.js';\nimport { shadcnBlockImplementations } from './builtins.js';\nimport { PlacementFrameContext } from './placement-frame.js';\nimport { itemHandle } from './related-item.js';\nimport { RouteListContext } from './route-list-context.js';\n\n// biome-ignore lint/suspicious/noExplicitAny: a view of any block\ntype AnyImplementation = BlockImplementation<any>;\ntype View = ComponentType<BlockViewProps<unknown>>;\n\n/** The lazy view of a `load` entry, one per entry object. */\nconst lazyViews = new WeakMap<AnyImplementation, View>();\n/** Built-in ids an app entry replaced, warned once per process. */\nconst replacedWarned = new Set<string>();\n/** Placements reported as `block.not-implemented`, once per location. */\nconst notImplementedReported = new Set<string>();\n\n/** A catalogue entry's view: its component, or its `load` behind `React.lazy` (one per entry). Internal. */\nexport function viewOf(implementation: AnyImplementation): View {\n if (implementation.component !== undefined) return implementation.component as View;\n let view = lazyViews.get(implementation);\n if (view === undefined) {\n const load = implementation.load!;\n view = lazy(async () => {\n const module = await load();\n return { default: module.default as View };\n });\n lazyViews.set(implementation, view);\n }\n return view;\n}\n\n/** The app's entry over the built-in one; a replaced built-in is said once, in development. Internal. */\nexport function selectImplementation(id: string, app: AnyImplementation | undefined) {\n const builtin = Object.hasOwn(shadcnBlockImplementations, id)\n ? shadcnBlockImplementations[id]\n : undefined;\n if (app !== undefined && builtin !== undefined && !replacedWarned.has(id)) {\n replacedWarned.add(id);\n if (process.env.NODE_ENV !== 'production')\n console.warn(\n `[burojs] blockImplementations: the app's ${id} replaces the built-in ${id} view.`,\n );\n }\n return app ?? builtin;\n}\n\ninterface ChromeProps {\n readonly node: PlanNode;\n readonly size: string;\n readonly state?: 'pending' | 'failed';\n readonly children?: ReactNode;\n}\n\n/** The place node's box: the styling contract's attributes (section 9). */\nfunction Chrome({ node, size, state, children }: ChromeProps): ReactElement {\n return (\n <div\n data-buro-node=\"place\"\n {...(node.key === undefined ? {} : { 'data-buro-key': node.key })}\n data-buro-size={size}\n {...(state === undefined ? {} : { 'data-buro-state': state })}\n className=\"min-w-0\"\n >\n {children}\n </div>\n );\n}\n\nfunction isAuthError(error: unknown): error is DataError {\n return isDataError(error) && error.kind === 'auth';\n}\n\n/** A placement that failed: its reason, and Retry when a refetch can help. */\nfunction FailedPlacement({\n node,\n size,\n message,\n retry,\n}: {\n readonly node: PlanNode;\n readonly size: string;\n readonly message: 'failed' | 'sessionExpired' | 'notImplemented';\n readonly retry?: () => void;\n}): ReactElement {\n const t = useOptionalT();\n const defaults = {\n failed: 'This section could not be loaded.',\n sessionExpired: 'Your session has expired. Sign in again to continue.',\n notImplemented: 'This section is not available.',\n } as const;\n return (\n <Chrome node={node} size={size} state=\"failed\">\n <div\n role=\"alert\"\n className=\"flex flex-wrap items-center gap-2 rounded-md border border-dashed px-3 py-2 text-sm text-muted-foreground\"\n >\n <span>{t(`block.${message}`, { defaultValue: defaults[message] })}</span>\n {retry === undefined ? null : (\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={retry}>\n {t('actions.retry', { defaultValue: 'Retry' })}\n </Button>\n )}\n </div>\n </Chrome>\n );\n}\n\nfunction PendingPlacement({ node, size }: { readonly node: PlanNode; readonly size: string }) {\n return (\n <Chrome node={node} size={size} state=\"pending\">\n <Skeleton data-buro-skeleton=\"\" className=\"h-9 w-full\" />\n </Chrome>\n );\n}\n\ninterface BoundaryProps {\n readonly node: PlanNode;\n readonly size: string;\n readonly retryable: boolean;\n readonly onRetry: () => void;\n readonly children: ReactNode;\n}\n\n/**\n * One error boundary per place node: a view that throws while rendering shows the failed\n * chrome in its own box; the frame and the sibling nodes keep rendering.\n */\nclass PlacementBoundary extends Component<BoundaryProps, { readonly failed: boolean }> {\n override state = { failed: false };\n\n static getDerivedStateFromError(): { readonly failed: boolean } {\n return { failed: true };\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo): void {\n if (process.env.NODE_ENV !== 'production')\n console.error(\n `[burojs] The view of the placement ${this.props.node.key ?? this.props.node.id} threw while rendering.`,\n error,\n info.componentStack,\n );\n }\n\n override render(): ReactNode {\n if (!this.state.failed) return this.props.children;\n const { node, size, retryable, onRetry } = this.props;\n return (\n <FailedPlacement\n node={node}\n size={size}\n message=\"failed\"\n {...(retryable\n ? {\n retry: () => {\n this.setState({ failed: false });\n onRetry();\n },\n }\n : {})}\n />\n );\n }\n}\n\n/** The view props with each `block()` prop as its nested placement, rendered. */\nfunction useViewProps(node: PlanNode, placement: PlacementView): BlockViewProps<unknown> {\n const { compiled } = useScreenTree();\n const viewProps = placement.viewProps!;\n if (node.children.length === 0) return viewProps;\n const props: Record<string, unknown> = { ...(viewProps.props as Record<string, unknown>) };\n const lists = new Map<string, ReactElement[]>();\n for (const child of node.children) {\n const host = compiled.nodes[child.index]?.placement?.host;\n if (host === undefined) continue;\n // The item of a related list is drawn once per row by the list, not here (P6 3.13).\n if (host.itemOf === host.key && host.prop === 'item') {\n props.item = itemHandle(child);\n continue;\n }\n const element = <PlaceNode key={`${child.index}:${child.id}`} node={child} />;\n if (host.index === undefined) props[host.prop] = element;\n else {\n const list = lists.get(host.prop) ?? [];\n list[host.index] = element;\n lists.set(host.prop, list);\n }\n }\n for (const [name, list] of lists) props[name] = list.filter((entry) => entry !== undefined);\n return { ...viewProps, props: props as BlockViewProps<unknown>['props'] };\n}\n\nfunction ReadyPlacement({\n node,\n size,\n placement,\n implementation,\n}: {\n readonly node: PlanNode;\n readonly size: string;\n readonly placement: PlacementView;\n readonly implementation: AnyImplementation;\n}): ReactElement {\n const { compiled, controller } = useScreenTree();\n const View = viewOf(implementation);\n const viewProps = useViewProps(node, placement);\n const placementNode = compiled.nodes[node.index]?.placement;\n const hasData = placementNode?.hasData === true;\n const placementState = placementNode?.state;\n const nested = placementNode?.host !== undefined;\n const declaredWhere = placementNode?.props.where;\n const owner = useOptionalRecordFrame()?.resource;\n const frame = useMemo(\n () => ({\n key: node.key ?? node.id,\n ...(placementState === undefined ? {} : { state: placementState }),\n nested,\n ...(Array.isArray(declaredWhere) ? { where: declaredWhere as readonly unknown[] } : {}),\n closure: compiled.sourceClosure,\n ...(owner === undefined ? {} : { owner }),\n }),\n [node.key, node.id, placementState, nested, declaredWhere, compiled.sourceClosure, owner],\n );\n return (\n <PlacementBoundary\n node={node}\n size={size}\n retryable={hasData}\n onRetry={() => {\n if (node.key !== undefined) controller.retry([`block:${node.key}`]);\n }}\n >\n <Suspense fallback={<PendingPlacement node={node} size={size} />}>\n <Chrome node={node} size={size}>\n {/* A placement is never the route list, even inside one (a screen in a list cell). */}\n <RouteListContext.Provider value={null}>\n <PlacementFrameContext.Provider value={frame}>\n <View {...viewProps} />\n </PlacementFrameContext.Provider>\n </RouteListContext.Provider>\n </Chrome>\n </Suspense>\n </PlacementBoundary>\n );\n}\n\n/** Reports a placement whose block has no view, once per location (criteria 58, 75). */\nfunction useNotImplemented(node: PlanNode, id: string, missing: boolean): void {\n const { compiled } = useScreenTree();\n const path = compiled.nodes[node.index]?.path ?? [];\n const location = `${path.join('.')} (${node.key ?? node.id})`;\n useEffect(() => {\n if (!missing || process.env.NODE_ENV === 'production') return;\n if (notImplementedReported.has(location + id)) return;\n notImplementedReported.add(location + id);\n console.error(\n `[burojs] block.not-implemented: ${location} places ${id}, which has no view. Add implementBlock(${id}, { load }) to <BuroProvider blockImplementations>.`,\n );\n }, [missing, location, id]);\n}\n\n/**\n * A `place` node (spec 8.1, section 9): the framework chrome around a block view — pending,\n * failed with Retry when a refetch can help, an expired session — and the view itself, the\n * app's over the built-in one, inside its own error boundary.\n */\nexport function PlaceNode({ node }: { readonly node: PlanNode }): ReactElement | null {\n const { compiled, controller } = useScreenTree();\n const placement = usePlacement(node.key ?? '', controller);\n const size = compiled.nodes[node.index]?.options.size ?? 'full';\n const id = formatEntityRef(placement.block);\n const implementation =\n placement.state === 'ready' ? selectImplementation(id, placement.appImplementation) : undefined;\n useNotImplemented(node, id, placement.state === 'ready' && implementation === undefined);\n if (placement.state === 'absent') return null;\n if (placement.state === 'pending') return <PendingPlacement node={node} size={size} />;\n if (placement.state === 'failed')\n return (\n <FailedPlacement\n node={node}\n size={size}\n message={isAuthError(placement.error) ? 'sessionExpired' : 'failed'}\n {...(placement.retry === undefined ? {} : { retry: placement.retry })}\n />\n );\n if (implementation === undefined)\n return <FailedPlacement node={node} size={size} message=\"notImplemented\" />;\n return (\n <ReadyPlacement node={node} size={size} placement={placement} implementation={implementation} />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqCA,SAAS,IAAI,OAAoC;CAC/C,IAAI,OAAO,UAAU,UAAU,OAAO,MAAM,SAAS,IAAI,QAAQ,KAAA;CACjE,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU,OAAO,OAAO,KAAK;AAEjF;AAGA,SAAgB,kBAAkB,UAAgD;CAChF,MAAM,SACJ,OAAO,aAAa,YAAY,aAAa,OAAQ,WAAuC,CAAC;CAC/F,MAAM,QAAQ,IAAI,OAAO,KAAK;CAC9B,MAAM,YAAY,IAAI,OAAO,SAAS,KAAK,IAAI,OAAO,MAAM;CAC5D,OAAO;EACL,MAAM,IAAI,OAAO,IAAI,KAAK,SAAS,IAAI,OAAO,EAAE,KAAK;EACrD,GAAI,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