@burojs/ui-shadcn 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/{bulk-summary-2HLgz7Il.cjs → bulk-summary-Chc61Pyw.cjs} +9 -7
  2. package/dist/bulk-summary-Chc61Pyw.cjs.map +1 -0
  3. package/dist/{bulk-summary-D6A0ua21.js → bulk-summary-DpSQD2Fq.js} +9 -7
  4. package/dist/bulk-summary-DpSQD2Fq.js.map +1 -0
  5. package/dist/{candidates-relation-picker-CGXItMN0.js → candidates-relation-picker-DRsHKe6N.js} +3 -3
  6. package/dist/{candidates-relation-picker-CGXItMN0.js.map → candidates-relation-picker-DRsHKe6N.js.map} +1 -1
  7. package/dist/{candidates-relation-picker-C47mF260.cjs → candidates-relation-picker-GIxsp7D_.cjs} +3 -3
  8. package/dist/{candidates-relation-picker-C47mF260.cjs.map → candidates-relation-picker-GIxsp7D_.cjs.map} +1 -1
  9. package/dist/{check-confirm-dialog-BT04Mieo.cjs → check-confirm-dialog-BMSb7wFv.cjs} +76 -9
  10. package/dist/check-confirm-dialog-BMSb7wFv.cjs.map +1 -0
  11. package/dist/{check-confirm-dialog-CtiRzOAt.js → check-confirm-dialog-B_u3YVHS.js} +72 -11
  12. package/dist/{check-confirm-dialog-CtiRzOAt.js.map → check-confirm-dialog-B_u3YVHS.js.map} +1 -1
  13. package/dist/{filter-builder-z3Axzf9Y.js → filter-builder-DX-xC3Yd.js} +14 -6
  14. package/dist/filter-builder-DX-xC3Yd.js.map +1 -0
  15. package/dist/{filter-builder-ByGhxLf_.cjs → filter-builder-Dt5E8PSX.cjs} +14 -6
  16. package/dist/filter-builder-Dt5E8PSX.cjs.map +1 -0
  17. package/dist/{flow-runtime-BVFjMU5-.cjs → flow-runtime-CQ4wf8co.cjs} +3 -3
  18. package/dist/{flow-runtime-BVFjMU5-.cjs.map → flow-runtime-CQ4wf8co.cjs.map} +1 -1
  19. package/dist/{flow-runtime-DrUWyTS0.js → flow-runtime-Q2vD7R3c.js} +3 -3
  20. package/dist/{flow-runtime-DrUWyTS0.js.map → flow-runtime-Q2vD7R3c.js.map} +1 -1
  21. package/dist/{flow-screen-3fk6J33y.js → flow-screen-B1y2yizP.js} +68 -29
  22. package/dist/flow-screen-B1y2yizP.js.map +1 -0
  23. package/dist/{flow-screen-6y5E_HT6.cjs → flow-screen-sw2cP70t.cjs} +67 -28
  24. package/dist/flow-screen-sw2cP70t.cjs.map +1 -0
  25. package/dist/index.cjs +2304 -247
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +119 -12
  28. package/dist/index.d.ts +119 -12
  29. package/dist/index.js +2225 -172
  30. package/dist/index.js.map +1 -1
  31. package/dist/{inline-flow-host-C4KmZIYE.cjs → inline-flow-host-CkhoA69R.cjs} +3 -3
  32. package/dist/{inline-flow-host-C4KmZIYE.cjs.map → inline-flow-host-CkhoA69R.cjs.map} +1 -1
  33. package/dist/{inline-flow-host-YnnvWjdU.js → inline-flow-host-DqbXqcPS.js} +3 -3
  34. package/dist/{inline-flow-host-YnnvWjdU.js.map → inline-flow-host-DqbXqcPS.js.map} +1 -1
  35. package/dist/{lazy-relation-picker-dialog-DN4bvQfg.js → lazy-relation-picker-dialog-BaIEWLbF.js} +3 -52
  36. package/dist/lazy-relation-picker-dialog-BaIEWLbF.js.map +1 -0
  37. package/dist/{lazy-relation-picker-dialog-BAKBRn3V.cjs → lazy-relation-picker-dialog-CeRzOAi0.cjs} +3 -52
  38. package/dist/lazy-relation-picker-dialog-CeRzOAi0.cjs.map +1 -0
  39. package/dist/{page-flow-route-CtEfqAvU.js → page-flow-route-CP7cS7FY.js} +7 -7
  40. package/dist/page-flow-route-CP7cS7FY.js.map +1 -0
  41. package/dist/{page-flow-route-DEjAxHe3.cjs → page-flow-route-UDx8qvdM.cjs} +10 -10
  42. package/dist/page-flow-route-UDx8qvdM.cjs.map +1 -0
  43. package/dist/{place-node-Bhl8B3fF.cjs → place-node-C5ZmuHaN.cjs} +208 -55
  44. package/dist/place-node-C5ZmuHaN.cjs.map +1 -0
  45. package/dist/{place-node-BdxT-30h.js → place-node-DwWAigv0.js} +205 -58
  46. package/dist/place-node-DwWAigv0.js.map +1 -0
  47. package/dist/record-trail-store-Cjo9vtod.cjs +126 -0
  48. package/dist/record-trail-store-Cjo9vtod.cjs.map +1 -0
  49. package/dist/record-trail-store-Dn6bVry4.js +91 -0
  50. package/dist/record-trail-store-Dn6bVry4.js.map +1 -0
  51. package/dist/{related-list-cards-Bc_vfCE_.cjs → related-list-cards-BypKfm9t.cjs} +3 -3
  52. package/dist/{related-list-cards-Bc_vfCE_.cjs.map → related-list-cards-BypKfm9t.cjs.map} +1 -1
  53. package/dist/{related-list-cards-BvkD5OcC.js → related-list-cards-Dcmruy09.js} +3 -3
  54. package/dist/{related-list-cards-BvkD5OcC.js.map → related-list-cards-Dcmruy09.js.map} +1 -1
  55. package/dist/{related-list-timeline-k0DtnxTs.cjs → related-list-timeline-D-KClgKb.cjs} +4 -4
  56. package/dist/related-list-timeline-D-KClgKb.cjs.map +1 -0
  57. package/dist/{related-list-timeline-DCrwN9oO.js → related-list-timeline-DZON_qSc.js} +4 -4
  58. package/dist/related-list-timeline-DZON_qSc.js.map +1 -0
  59. package/dist/{related-rows-BW9Jr07T.cjs → related-rows-DgF05ssi.cjs} +4 -4
  60. package/dist/{related-rows-BW9Jr07T.cjs.map → related-rows-DgF05ssi.cjs.map} +1 -1
  61. package/dist/{related-rows-CPE-9FFr.js → related-rows-ETZl5CB9.js} +4 -4
  62. package/dist/{related-rows-CPE-9FFr.js.map → related-rows-ETZl5CB9.js.map} +1 -1
  63. package/dist/{relation-create-DDEYcKfw.cjs → relation-create-B8zngAcA.cjs} +82 -13
  64. package/dist/relation-create-B8zngAcA.cjs.map +1 -0
  65. package/dist/{relation-create-C43cdPQt.js → relation-create-CeCWyxIb.js} +79 -16
  66. package/dist/relation-create-CeCWyxIb.js.map +1 -0
  67. package/dist/{relation-many-picker-BlrGRwMV.js → relation-many-picker-CT7nKfE2.js} +12 -10
  68. package/dist/relation-many-picker-CT7nKfE2.js.map +1 -0
  69. package/dist/{relation-many-picker-Br-zBHxT.cjs → relation-many-picker-Cq0EHY5I.cjs} +12 -10
  70. package/dist/relation-many-picker-Cq0EHY5I.cjs.map +1 -0
  71. package/dist/{relation-picker-x7P5HKie.js → relation-picker-CCyuMeGq.js} +13 -10
  72. package/dist/relation-picker-CCyuMeGq.js.map +1 -0
  73. package/dist/{relation-picker-ADjxI_TI.cjs → relation-picker-DmwTzgsd.cjs} +13 -10
  74. package/dist/relation-picker-DmwTzgsd.cjs.map +1 -0
  75. package/dist/{relation-picker-dialog-CyKliBkN.js → relation-picker-dialog-CoWKjNv8.js} +5 -5
  76. package/dist/relation-picker-dialog-CoWKjNv8.js.map +1 -0
  77. package/dist/{relation-picker-dialog-DimVQF9Y.cjs → relation-picker-dialog-mbwyNK43.cjs} +5 -5
  78. package/dist/relation-picker-dialog-mbwyNK43.cjs.map +1 -0
  79. package/dist/{relation-select-Cr3CfNLy.cjs → relation-select-CguIo2M5.cjs} +2 -2
  80. package/dist/{relation-select-Cr3CfNLy.cjs.map → relation-select-CguIo2M5.cjs.map} +1 -1
  81. package/dist/{relation-select-B8Fq4o-t.js → relation-select-nAYxhopN.js} +2 -2
  82. package/dist/{relation-select-B8Fq4o-t.js.map → relation-select-nAYxhopN.js.map} +1 -1
  83. package/dist/{success-notices-Dl3M1fZP.cjs → success-notices-Cl4b6MLQ.cjs} +3 -2
  84. package/dist/success-notices-Cl4b6MLQ.cjs.map +1 -0
  85. package/dist/{success-notices-LDEgEkc4.js → success-notices-CrcWOGSo.js} +3 -2
  86. package/dist/success-notices-CrcWOGSo.js.map +1 -0
  87. package/dist/{use-dialog-filter-state-tNvqAAjh.cjs → use-dialog-filter-state-CpWblz3C.cjs} +2 -2
  88. package/dist/{use-dialog-filter-state-tNvqAAjh.cjs.map → use-dialog-filter-state-CpWblz3C.cjs.map} +1 -1
  89. package/dist/{use-dialog-filter-state-B_MqzHaT.js → use-dialog-filter-state-ZYxOp5WO.js} +2 -2
  90. package/dist/{use-dialog-filter-state-B_MqzHaT.js.map → use-dialog-filter-state-ZYxOp5WO.js.map} +1 -1
  91. package/dist/{use-record-subtitle-bfwIoUme.cjs → use-record-subtitle-B4lTR7pf.cjs} +5 -8
  92. package/dist/use-record-subtitle-B4lTR7pf.cjs.map +1 -0
  93. package/dist/{use-record-subtitle-gIaCGgbI.js → use-record-subtitle-pWMBqQx9.js} +5 -8
  94. package/dist/use-record-subtitle-pWMBqQx9.js.map +1 -0
  95. package/package.json +9 -9
  96. package/dist/bulk-summary-2HLgz7Il.cjs.map +0 -1
  97. package/dist/bulk-summary-D6A0ua21.js.map +0 -1
  98. package/dist/check-confirm-dialog-BT04Mieo.cjs.map +0 -1
  99. package/dist/filter-builder-ByGhxLf_.cjs.map +0 -1
  100. package/dist/filter-builder-z3Axzf9Y.js.map +0 -1
  101. package/dist/flow-screen-3fk6J33y.js.map +0 -1
  102. package/dist/flow-screen-6y5E_HT6.cjs.map +0 -1
  103. package/dist/lazy-relation-picker-dialog-BAKBRn3V.cjs.map +0 -1
  104. package/dist/lazy-relation-picker-dialog-DN4bvQfg.js.map +0 -1
  105. package/dist/page-flow-route-CtEfqAvU.js.map +0 -1
  106. package/dist/page-flow-route-DEjAxHe3.cjs.map +0 -1
  107. package/dist/place-node-BdxT-30h.js.map +0 -1
  108. package/dist/place-node-Bhl8B3fF.cjs.map +0 -1
  109. package/dist/related-list-timeline-DCrwN9oO.js.map +0 -1
  110. package/dist/related-list-timeline-k0DtnxTs.cjs.map +0 -1
  111. package/dist/relation-create-C43cdPQt.js.map +0 -1
  112. package/dist/relation-create-DDEYcKfw.cjs.map +0 -1
  113. package/dist/relation-many-picker-BlrGRwMV.js.map +0 -1
  114. package/dist/relation-many-picker-Br-zBHxT.cjs.map +0 -1
  115. package/dist/relation-picker-ADjxI_TI.cjs.map +0 -1
  116. package/dist/relation-picker-dialog-CyKliBkN.js.map +0 -1
  117. package/dist/relation-picker-dialog-DimVQF9Y.cjs.map +0 -1
  118. package/dist/relation-picker-x7P5HKie.js.map +0 -1
  119. package/dist/resource-page-router-BRpUnhay.js +0 -1958
  120. package/dist/resource-page-router-BRpUnhay.js.map +0 -1
  121. package/dist/resource-page-router-qEd2xb55.cjs +0 -2167
  122. package/dist/resource-page-router-qEd2xb55.cjs.map +0 -1
  123. package/dist/success-notices-Dl3M1fZP.cjs.map +0 -1
  124. package/dist/success-notices-LDEgEkc4.js.map +0 -1
  125. package/dist/use-record-subtitle-bfwIoUme.cjs.map +0 -1
  126. package/dist/use-record-subtitle-gIaCGgbI.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { a as namesHiddenField, o as narrowSearchDecl } from "./relation-create-C43cdPQt.js";
1
+ import { a as namesHiddenField, o as narrowSearchDecl } from "./relation-create-CeCWyxIb.js";
2
2
  import { EMPTY_FILTER_GROUP, composeListFilter, routeResourceKey } from "@burojs/core";
3
3
  import { useApp, useFilterFields, useListAccess } from "@burojs/react";
4
4
  import { useCallback, useMemo, useState } from "react";
@@ -85,4 +85,4 @@ function useDialogFilterState(resourceInput, options) {
85
85
  //#endregion
86
86
  export { useDialogFilterState as t };
87
87
 
88
- //# sourceMappingURL=use-dialog-filter-state-B_MqzHaT.js.map
88
+ //# sourceMappingURL=use-dialog-filter-state-ZYxOp5WO.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-dialog-filter-state-B_MqzHaT.js","names":[],"sources":["../src/fields/use-dialog-filter-state.ts"],"sourcesContent":["import {\n EMPTY_FILTER_GROUP,\n composeListFilter,\n type ErasedResourceHandle,\n type FilterExpression,\n type FilterGroup,\n type FixedFilterInput,\n type ResolvedFixedFilter,\n type SearchDecl,\n routeResourceKey,\n type ResourceNameOrRef,\n} from '@burojs/core';\nimport { useApp, useFilterFields, useListAccess, type FilterFieldSpec } from '@burojs/react';\nimport { namesHiddenField, narrowSearchDecl } from './search-access.js';\nimport { useCallback, useMemo, useState } from 'react';\n\n/** The portable erased AST — the only shape this module deals in. */\ntype ErasedExpression = FilterExpression<ErasedResourceHandle>;\n\n/** Options for {@link useDialogFilterState}. */\nexport interface UseDialogFilterStateOptions {\n /** Call-site narrowing (e.g. scope the target list to a product group). */\n readonly fixedFilters?: readonly FixedFilterInput[];\n /**\n * Fallback search field, used ONLY when the target resource declares no\n * `views.list.search`. Wrapped into a single-field `SearchFieldsDecl`\n * (`{ fields: [searchField] }`, implicit `contains` — same degenerate form\n * `searchToFilter` already gives a bare field-name string) so the override\n * goes through the exact same `composeListFilter` → `searchToFilter` path\n * as a real declaration, rather than a second hand-built predicate at the\n * call site. The target's own declaration always wins when present — this\n * is a fallback, not an override of a declared search.\n */\n readonly searchField?: string;\n /**\n * Gates the field-derivation walk (`useFilterFields`'s `categorizeField`\n * pass over every field of the resource). Defaults to `true`. A caller\n * whose UI isn't visible yet (e.g. `RelationPickerDialog` before it's\n * opened) should pass `false` to skip that work on every mount /\n * `fixedFilters`-identity change; the derivation recomputes in full the\n * next render where this flips back to `true`.\n */\n readonly enabled?: boolean;\n}\n\n/** Return shape of {@link useDialogFilterState}. */\nexport interface DialogFilterState {\n readonly group: FilterGroup;\n readonly setGroup: (next: FilterGroup) => void;\n readonly search: string;\n readonly setSearch: (next: string) => void;\n readonly page: number;\n readonly setPage: (page: number) => void;\n readonly available: readonly FilterFieldSpec[];\n readonly fixed: readonly ResolvedFixedFilter[];\n /** The single expression to hand the data provider. */\n readonly filter: ErasedExpression | undefined;\n /** Whether the target has a search for this user (no field left means no search box). */\n readonly searchEnabled: boolean;\n /** The read must not be sent: undecided access, or a filter naming a field the user may not view. */\n readonly blocked: boolean;\n readonly reset: () => void;\n}\n\n/**\n * Local (non-URL) filter state for the relation-picker's advanced-search\n * dialog.\n *\n * `useResourceList` cannot serve this: it unconditionally calls\n * `useResourceUrlState`, which throws without a `RouterAdapterProvider` and,\n * when one IS present, writes to `?<resource>.*`. A picker dialog mounted\n * inside a form for resource A, searching TARGET resource B, would then\n * write B's list state into the URL — clobbering a real B list page open on\n * another tab of the same app, and reading back whatever that page last\n * wrote on open. So this hook keeps `group`/`search`/`page` in plain\n * `useState` and reuses the SAME composition core's list controller uses\n * (`composeListFilter`) so the two never drift on what a filter means.\n *\n * No `pinned` slot: pinned controls are a list-PAGE affordance (permanent\n * screen real estate for a couple of always-visible facets); a modal has no\n * spare real estate to spend on them.\n */\nexport function useDialogFilterState<const N extends string = string>(\n resourceInput: ResourceNameOrRef<N>,\n options: UseDialogFilterStateOptions,\n): DialogFilterState {\n const resource = routeResourceKey(resourceInput);\n const app = useApp();\n const def = app.registry.get(resource);\n const { available, fixed } = useFilterFields(resource, {\n fixedFilters: options.fixedFilters,\n enabled: options.enabled,\n });\n\n const [group, setGroupState] = useState<FilterGroup>(EMPTY_FILTER_GROUP);\n const [search, setSearchState] = useState('');\n const [page, setPage] = useState(1);\n\n // Any change to WHAT is filtered invalidates the current page — the same\n // rule `useResourceList`'s URL-state controller applies to its own\n // group/search setters.\n const setGroup = useCallback((next: FilterGroup) => {\n setGroupState(next);\n setPage(1);\n }, []);\n\n const setSearch = useCallback((next: string) => {\n setSearchState(next);\n setPage(1);\n }, []);\n\n const reset = useCallback(() => {\n setGroupState(EMPTY_FILTER_GROUP);\n setSearchState('');\n setPage(1);\n }, []);\n\n // The target's own declaration always wins; `options.searchField` only\n // fills in when the target declares no search at all. Memoized so an\n // omitted declaration doesn't hand `composeListFilter`'s `filter` memo a\n // fresh `{ fields: [...] }` literal (and therefore a spurious recompute)\n // on every render — see `UseDialogFilterStateOptions.searchField`'s doc.\n const { searchField } = options;\n const access = useListAccess(resource);\n const accessReady = access.status === 'ready';\n const searchDecl = useMemo<SearchDecl | undefined>(() => {\n const declared = def?.views?.list?.search;\n const base =\n declared !== undefined\n ? declared\n : searchField === undefined\n ? undefined\n : { fields: [searchField] };\n return narrowSearchDecl(base, (field) => access.fieldVisible(field));\n }, [def, searchField, access]);\n const searchContext = useMemo(() => ({ resource, def }), [resource, def]);\n\n const filter = useMemo<ErasedExpression | undefined>(\n () => composeListFilter({ fixed, group, search, searchDecl, searchContext }),\n [fixed, group, search, searchDecl, searchContext],\n );\n\n // A read whose composed filter names a field the user may not view is forbidden (an author\n // predicate, or a function search's output); an undecided access sends nothing yet.\n const blocked = !accessReady || namesHiddenField(filter, (field) => access.fieldVisible(field));\n\n return useMemo<DialogFilterState>(\n () => ({\n searchEnabled: searchDecl !== undefined,\n blocked,\n group,\n setGroup,\n search,\n setSearch,\n page,\n setPage,\n available,\n fixed,\n filter,\n reset,\n }),\n [\n group,\n setGroup,\n search,\n setSearch,\n page,\n available,\n fixed,\n filter,\n reset,\n searchDecl,\n blocked,\n ],\n );\n}\n"],"mappings":";;;;;AAkFA,SAAgB,qBACd,eACA,SACmB;CACnB,MAAM,WAAW,iBAAiB,aAAa;CAE/C,MAAM,MADM,OACE,CAAC,CAAC,SAAS,IAAI,QAAQ;CACrC,MAAM,EAAE,WAAW,UAAU,gBAAgB,UAAU;EACrD,cAAc,QAAQ;EACtB,SAAS,QAAQ;CACnB,CAAC;CAED,MAAM,CAAC,OAAO,iBAAiB,SAAsB,kBAAkB;CACvE,MAAM,CAAC,QAAQ,kBAAkB,SAAS,EAAE;CAC5C,MAAM,CAAC,MAAM,WAAW,SAAS,CAAC;CAKlC,MAAM,WAAW,aAAa,SAAsB;EAClD,cAAc,IAAI;EAClB,QAAQ,CAAC;CACX,GAAG,CAAC,CAAC;CAEL,MAAM,YAAY,aAAa,SAAiB;EAC9C,eAAe,IAAI;EACnB,QAAQ,CAAC;CACX,GAAG,CAAC,CAAC;CAEL,MAAM,QAAQ,kBAAkB;EAC9B,cAAc,kBAAkB;EAChC,eAAe,EAAE;EACjB,QAAQ,CAAC;CACX,GAAG,CAAC,CAAC;CAOL,MAAM,EAAE,gBAAgB;CACxB,MAAM,SAAS,cAAc,QAAQ;CACrC,MAAM,cAAc,OAAO,WAAW;CACtC,MAAM,aAAa,cAAsC;EACvD,MAAM,WAAW,KAAK,OAAO,MAAM;EAOnC,OAAO,iBALL,aAAa,KAAA,IACT,WACA,gBAAgB,KAAA,IACd,KAAA,IACA,EAAE,QAAQ,CAAC,WAAW,EAAE,IACD,UAAU,OAAO,aAAa,KAAK,CAAC;CACrE,GAAG;EAAC;EAAK;EAAa;CAAM,CAAC;CAC7B,MAAM,gBAAgB,eAAe;EAAE;EAAU;CAAI,IAAI,CAAC,UAAU,GAAG,CAAC;CAExE,MAAM,SAAS,cACP,kBAAkB;EAAE;EAAO;EAAO;EAAQ;EAAY;CAAc,CAAC,GAC3E;EAAC;EAAO;EAAO;EAAQ;EAAY;CAAa,CAClD;CAIA,MAAM,UAAU,CAAC,eAAe,iBAAiB,SAAS,UAAU,OAAO,aAAa,KAAK,CAAC;CAE9F,OAAO,eACE;EACL,eAAe,eAAe,KAAA;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;AACF"}
1
+ {"version":3,"file":"use-dialog-filter-state-ZYxOp5WO.js","names":[],"sources":["../src/fields/use-dialog-filter-state.ts"],"sourcesContent":["import {\n EMPTY_FILTER_GROUP,\n composeListFilter,\n type ErasedResourceHandle,\n type FilterExpression,\n type FilterGroup,\n type FixedFilterInput,\n type ResolvedFixedFilter,\n type SearchDecl,\n routeResourceKey,\n type ResourceNameOrRef,\n} from '@burojs/core';\nimport { useApp, useFilterFields, useListAccess, type FilterFieldSpec } from '@burojs/react';\nimport { namesHiddenField, narrowSearchDecl } from './search-access.js';\nimport { useCallback, useMemo, useState } from 'react';\n\n/** The portable erased AST — the only shape this module deals in. */\ntype ErasedExpression = FilterExpression<ErasedResourceHandle>;\n\n/** Options for {@link useDialogFilterState}. */\nexport interface UseDialogFilterStateOptions {\n /** Call-site narrowing (e.g. scope the target list to a product group). */\n readonly fixedFilters?: readonly FixedFilterInput[];\n /**\n * Fallback search field, used ONLY when the target resource declares no\n * `views.list.search`. Wrapped into a single-field `SearchFieldsDecl`\n * (`{ fields: [searchField] }`, implicit `contains` — same degenerate form\n * `searchToFilter` already gives a bare field-name string) so the override\n * goes through the exact same `composeListFilter` → `searchToFilter` path\n * as a real declaration, rather than a second hand-built predicate at the\n * call site. The target's own declaration always wins when present — this\n * is a fallback, not an override of a declared search.\n */\n readonly searchField?: string;\n /**\n * Gates the field-derivation walk (`useFilterFields`'s `categorizeField`\n * pass over every field of the resource). Defaults to `true`. A caller\n * whose UI isn't visible yet (e.g. `RelationPickerDialog` before it's\n * opened) should pass `false` to skip that work on every mount /\n * `fixedFilters`-identity change; the derivation recomputes in full the\n * next render where this flips back to `true`.\n */\n readonly enabled?: boolean;\n}\n\n/** Return shape of {@link useDialogFilterState}. */\nexport interface DialogFilterState {\n readonly group: FilterGroup;\n readonly setGroup: (next: FilterGroup) => void;\n readonly search: string;\n readonly setSearch: (next: string) => void;\n readonly page: number;\n readonly setPage: (page: number) => void;\n readonly available: readonly FilterFieldSpec[];\n readonly fixed: readonly ResolvedFixedFilter[];\n /** The single expression to hand the data provider. */\n readonly filter: ErasedExpression | undefined;\n /** Whether the target has a search for this user (no field left means no search box). */\n readonly searchEnabled: boolean;\n /** The read must not be sent: undecided access, or a filter naming a field the user may not view. */\n readonly blocked: boolean;\n readonly reset: () => void;\n}\n\n/**\n * Local (non-URL) filter state for the relation-picker's advanced-search\n * dialog.\n *\n * `useResourceList` cannot serve this: it unconditionally calls\n * `useResourceUrlState`, which throws without a `RouterAdapterProvider` and,\n * when one IS present, writes to `?<resource>.*`. A picker dialog mounted\n * inside a form for resource A, searching TARGET resource B, would then\n * write B's list state into the URL — clobbering a real B list page open on\n * another tab of the same app, and reading back whatever that page last\n * wrote on open. So this hook keeps `group`/`search`/`page` in plain\n * `useState` and reuses the SAME composition core's list controller uses\n * (`composeListFilter`) so the two never drift on what a filter means.\n *\n * No `pinned` slot: pinned controls are a list-PAGE affordance (permanent\n * screen real estate for a couple of always-visible facets); a modal has no\n * spare real estate to spend on them.\n */\nexport function useDialogFilterState<const N extends string = string>(\n resourceInput: ResourceNameOrRef<N>,\n options: UseDialogFilterStateOptions,\n): DialogFilterState {\n const resource = routeResourceKey(resourceInput);\n const app = useApp();\n const def = app.registry.get(resource);\n const { available, fixed } = useFilterFields(resource, {\n fixedFilters: options.fixedFilters,\n enabled: options.enabled,\n });\n\n const [group, setGroupState] = useState<FilterGroup>(EMPTY_FILTER_GROUP);\n const [search, setSearchState] = useState('');\n const [page, setPage] = useState(1);\n\n // Any change to WHAT is filtered invalidates the current page — the same\n // rule `useResourceList`'s URL-state controller applies to its own\n // group/search setters.\n const setGroup = useCallback((next: FilterGroup) => {\n setGroupState(next);\n setPage(1);\n }, []);\n\n const setSearch = useCallback((next: string) => {\n setSearchState(next);\n setPage(1);\n }, []);\n\n const reset = useCallback(() => {\n setGroupState(EMPTY_FILTER_GROUP);\n setSearchState('');\n setPage(1);\n }, []);\n\n // The target's own declaration always wins; `options.searchField` only\n // fills in when the target declares no search at all. Memoized so an\n // omitted declaration doesn't hand `composeListFilter`'s `filter` memo a\n // fresh `{ fields: [...] }` literal (and therefore a spurious recompute)\n // on every render — see `UseDialogFilterStateOptions.searchField`'s doc.\n const { searchField } = options;\n const access = useListAccess(resource);\n const accessReady = access.status === 'ready';\n const searchDecl = useMemo<SearchDecl | undefined>(() => {\n const declared = def?.views?.list?.search;\n const base =\n declared !== undefined\n ? declared\n : searchField === undefined\n ? undefined\n : { fields: [searchField] };\n return narrowSearchDecl(base, (field) => access.fieldVisible(field));\n }, [def, searchField, access]);\n const searchContext = useMemo(() => ({ resource, def }), [resource, def]);\n\n const filter = useMemo<ErasedExpression | undefined>(\n () => composeListFilter({ fixed, group, search, searchDecl, searchContext }),\n [fixed, group, search, searchDecl, searchContext],\n );\n\n // A read whose composed filter names a field the user may not view is forbidden (an author\n // predicate, or a function search's output); an undecided access sends nothing yet.\n const blocked = !accessReady || namesHiddenField(filter, (field) => access.fieldVisible(field));\n\n return useMemo<DialogFilterState>(\n () => ({\n searchEnabled: searchDecl !== undefined,\n blocked,\n group,\n setGroup,\n search,\n setSearch,\n page,\n setPage,\n available,\n fixed,\n filter,\n reset,\n }),\n [\n group,\n setGroup,\n search,\n setSearch,\n page,\n available,\n fixed,\n filter,\n reset,\n searchDecl,\n blocked,\n ],\n );\n}\n"],"mappings":";;;;;AAkFA,SAAgB,qBACd,eACA,SACmB;CACnB,MAAM,WAAW,iBAAiB,aAAa;CAE/C,MAAM,MADM,OACE,CAAC,CAAC,SAAS,IAAI,QAAQ;CACrC,MAAM,EAAE,WAAW,UAAU,gBAAgB,UAAU;EACrD,cAAc,QAAQ;EACtB,SAAS,QAAQ;CACnB,CAAC;CAED,MAAM,CAAC,OAAO,iBAAiB,SAAsB,kBAAkB;CACvE,MAAM,CAAC,QAAQ,kBAAkB,SAAS,EAAE;CAC5C,MAAM,CAAC,MAAM,WAAW,SAAS,CAAC;CAKlC,MAAM,WAAW,aAAa,SAAsB;EAClD,cAAc,IAAI;EAClB,QAAQ,CAAC;CACX,GAAG,CAAC,CAAC;CAEL,MAAM,YAAY,aAAa,SAAiB;EAC9C,eAAe,IAAI;EACnB,QAAQ,CAAC;CACX,GAAG,CAAC,CAAC;CAEL,MAAM,QAAQ,kBAAkB;EAC9B,cAAc,kBAAkB;EAChC,eAAe,EAAE;EACjB,QAAQ,CAAC;CACX,GAAG,CAAC,CAAC;CAOL,MAAM,EAAE,gBAAgB;CACxB,MAAM,SAAS,cAAc,QAAQ;CACrC,MAAM,cAAc,OAAO,WAAW;CACtC,MAAM,aAAa,cAAsC;EACvD,MAAM,WAAW,KAAK,OAAO,MAAM;EAOnC,OAAO,iBALL,aAAa,KAAA,IACT,WACA,gBAAgB,KAAA,IACd,KAAA,IACA,EAAE,QAAQ,CAAC,WAAW,EAAE,IACD,UAAU,OAAO,aAAa,KAAK,CAAC;CACrE,GAAG;EAAC;EAAK;EAAa;CAAM,CAAC;CAC7B,MAAM,gBAAgB,eAAe;EAAE;EAAU;CAAI,IAAI,CAAC,UAAU,GAAG,CAAC;CAExE,MAAM,SAAS,cACP,kBAAkB;EAAE;EAAO;EAAO;EAAQ;EAAY;CAAc,CAAC,GAC3E;EAAC;EAAO;EAAO;EAAQ;EAAY;CAAa,CAClD;CAIA,MAAM,UAAU,CAAC,eAAe,iBAAiB,SAAS,UAAU,OAAO,aAAa,KAAK,CAAC;CAE9F,OAAO,eACE;EACL,eAAe,eAAe,KAAA;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;AACF"}
@@ -1,3 +1,4 @@
1
+ const require_relation_create = require("./relation-create-B8zngAcA.cjs");
1
2
  let _burojs_core = require("@burojs/core");
2
3
  let _burojs_react = require("@burojs/react");
3
4
  let react = require("react");
@@ -29,13 +30,9 @@ function useRowSubtitle(target, override) {
29
30
  const resolve = useRecordSubtitle(target, override);
30
31
  const declares = override !== void 0 || def?.recordSubtitle !== void 0;
31
32
  return (0, react.useCallback)((row) => {
32
- if (!declares || access.status !== "ready") return void 0;
33
- const declaredId = (def?.data)?.idField;
34
- const idField = typeof declaredId === "string" && declaredId !== "" ? declaredId : "id";
35
- const visible = {};
36
- for (const name of Object.keys(def?.fields ?? {})) if (Object.hasOwn(row, name) && access.fieldVisible(name)) visible[name] = row[name];
37
- if (Object.hasOwn(row, idField)) visible[idField] = row[idField];
38
- return resolve(visible);
33
+ if (!declares) return void 0;
34
+ const visible = require_relation_create.visibleRow(def, access, row);
35
+ return visible === void 0 ? void 0 : resolve(visible);
39
36
  }, [
40
37
  declares,
41
38
  access,
@@ -67,4 +64,4 @@ Object.defineProperty(exports, "useRowSubtitle", {
67
64
  }
68
65
  });
69
66
 
70
- //# sourceMappingURL=use-record-subtitle-bfwIoUme.cjs.map
67
+ //# sourceMappingURL=use-record-subtitle-B4lTR7pf.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-record-subtitle-B4lTR7pf.cjs","names":["useApp","useI18nCaps","useCallback","resolveEnumLabel","useListAccess","visibleRow"],"sources":["../src/resource/use-record-subtitle.ts"],"sourcesContent":["'use client';\nimport { type RecordTitleContext, resolveEnumLabel } from '@burojs/core';\nimport { useApp, useI18nCaps, useListAccess } from '@burojs/react';\nimport { useCallback } from 'react';\nimport { visibleRow } from './visible-row.js';\n\n/**\n * A record's second line as code declares it (REF-136): the resource's `recordSubtitle`, or a\n * relation field's `optionSubtitle` for that field's options. A string is the line, `null` says\n * there is none, `undefined` (or a blank string) leaves it to the surface.\n */\nexport type RecordSubtitleFn = (\n record: Readonly<Record<string, unknown>>,\n ctx?: RecordTitleContext,\n) => string | null | undefined;\n\n/** The first of `fns` that decides: a non-blank string, or `null`; else `undefined`. */\nfunction declaredSubtitle(\n fns: readonly (RecordSubtitleFn | undefined)[],\n record: Readonly<Record<string, unknown>>,\n ctx: RecordTitleContext,\n): string | null | undefined {\n for (const fn of fns) {\n const out = fn?.(record, ctx);\n if (out === null) return null;\n if (typeof out === 'string' && out.trim() !== '') return out;\n }\n return undefined;\n}\n\n/**\n * The declared subtitle of one of `resource`'s records: `override` first, then the resource's\n * `recordSubtitle`. Hand it a record as its viewer may read it (projected in record reach); a row of\n * a list goes through {@link useRowSubtitle}. Like `recordTitle`, the hooks are called with an i18n\n * context bound to the resource, so an enum label in the line follows the active locale.\n */\nexport function useRecordSubtitle(\n resource: string,\n override?: RecordSubtitleFn,\n): (record: Readonly<Record<string, unknown>>) => string | null | undefined {\n const app = useApp();\n const caps = useI18nCaps(resource);\n const own: RecordSubtitleFn | undefined = app.registry.get(resource)?.recordSubtitle;\n return useCallback(\n (record) => {\n if (override === undefined && own === undefined) return undefined;\n return declaredSubtitle([override, own], record, {\n resolveEnum: (namespace, value, inlineDefault) =>\n resolveEnumLabel(caps, namespace, value, inlineDefault),\n });\n },\n [override, own, caps],\n );\n}\n\n/**\n * The declared subtitle of a row a list surface shows (picker options, palette results): the hooks\n * see only the row's declared fields its user may view in any-record reach, and its id (P5 spec\n * 3.6, as a list title reads only a visible display field). Undecided access declares nothing.\n */\nexport function useRowSubtitle(\n target: string,\n override?: RecordSubtitleFn,\n): (row: Readonly<Record<string, unknown>>) => string | null | undefined {\n const app = useApp();\n const access = useListAccess(target);\n const def = app.registry.get(target);\n const resolve = useRecordSubtitle(target, override);\n const declares = override !== undefined || def?.recordSubtitle !== undefined;\n return useCallback(\n (row) => {\n if (!declares) return undefined;\n const visible = visibleRow(def, access, row);\n return visible === undefined ? undefined : resolve(visible);\n },\n [declares, access, def, resolve],\n );\n}\n\n/**\n * A picker option's second line: the declared subtitle, else the option's `#<id>` — not drawn when\n * the label already is the id, which would print it twice (REF-40). `null`: none.\n */\nexport function optionSubtitle(\n declared: string | null | undefined,\n label: string,\n id: string,\n): string | null {\n if (declared !== undefined) return declared;\n return label === id ? null : `#${id}`;\n}\n"],"mappings":";;;;;AAiBA,SAAS,iBACP,KACA,QACA,KAC2B;CAC3B,KAAK,MAAM,MAAM,KAAK;EACpB,MAAM,MAAM,KAAK,QAAQ,GAAG;EAC5B,IAAI,QAAQ,MAAM,OAAO;EACzB,IAAI,OAAO,QAAQ,YAAY,IAAI,KAAK,MAAM,IAAI,OAAO;CAC3D;AAEF;AAQA,SAAgB,kBACd,UACA,UAC0E;CAC1E,MAAM,OAAA,GAAMA,cAAAA,OAAAA,CAAO;CACnB,MAAM,QAAA,GAAOC,cAAAA,YAAAA,CAAY,QAAQ;CACjC,MAAM,MAAoC,IAAI,SAAS,IAAI,QAAQ,CAAC,EAAE;CACtE,QAAA,GAAOC,MAAAA,YAAAA,EACJ,WAAW;EACV,IAAI,aAAa,KAAA,KAAa,QAAQ,KAAA,GAAW,OAAO,KAAA;EACxD,OAAO,iBAAiB,CAAC,UAAU,GAAG,GAAG,QAAQ,EAC/C,cAAc,WAAW,OAAO,mBAAA,GAC9BC,aAAAA,iBAAAA,CAAiB,MAAM,WAAW,OAAO,aAAa,EAC1D,CAAC;CACH,GACA;EAAC;EAAU;EAAK;CAAI,CACtB;AACF;AAOA,SAAgB,eACd,QACA,UACuE;CACvE,MAAM,OAAA,GAAMH,cAAAA,OAAAA,CAAO;CACnB,MAAM,UAAA,GAASI,cAAAA,cAAAA,CAAc,MAAM;CACnC,MAAM,MAAM,IAAI,SAAS,IAAI,MAAM;CACnC,MAAM,UAAU,kBAAkB,QAAQ,QAAQ;CAClD,MAAM,WAAW,aAAa,KAAA,KAAa,KAAK,mBAAmB,KAAA;CACnE,QAAA,GAAOF,MAAAA,YAAAA,EACJ,QAAQ;EACP,IAAI,CAAC,UAAU,OAAO,KAAA;EACtB,MAAM,UAAUG,wBAAAA,WAAW,KAAK,QAAQ,GAAG;EAC3C,OAAO,YAAY,KAAA,IAAY,KAAA,IAAY,QAAQ,OAAO;CAC5D,GACA;EAAC;EAAU;EAAQ;EAAK;CAAO,CACjC;AACF;AAMA,SAAgB,eACd,UACA,OACA,IACe;CACf,IAAI,aAAa,KAAA,GAAW,OAAO;CACnC,OAAO,UAAU,KAAK,OAAO,IAAI;AACnC"}
@@ -1,3 +1,4 @@
1
+ import { h as visibleRow } from "./relation-create-CeCWyxIb.js";
1
2
  import { resolveEnumLabel } from "@burojs/core";
2
3
  import { useApp, useI18nCaps, useListAccess } from "@burojs/react";
3
4
  import { useCallback } from "react";
@@ -29,13 +30,9 @@ function useRowSubtitle(target, override) {
29
30
  const resolve = useRecordSubtitle(target, override);
30
31
  const declares = override !== void 0 || def?.recordSubtitle !== void 0;
31
32
  return useCallback((row) => {
32
- if (!declares || access.status !== "ready") return void 0;
33
- const declaredId = (def?.data)?.idField;
34
- const idField = typeof declaredId === "string" && declaredId !== "" ? declaredId : "id";
35
- const visible = {};
36
- for (const name of Object.keys(def?.fields ?? {})) if (Object.hasOwn(row, name) && access.fieldVisible(name)) visible[name] = row[name];
37
- if (Object.hasOwn(row, idField)) visible[idField] = row[idField];
38
- return resolve(visible);
33
+ if (!declares) return void 0;
34
+ const visible = visibleRow(def, access, row);
35
+ return visible === void 0 ? void 0 : resolve(visible);
39
36
  }, [
40
37
  declares,
41
38
  access,
@@ -50,4 +47,4 @@ function optionSubtitle(declared, label, id) {
50
47
  //#endregion
51
48
  export { useRecordSubtitle as n, useRowSubtitle as r, optionSubtitle as t };
52
49
 
53
- //# sourceMappingURL=use-record-subtitle-gIaCGgbI.js.map
50
+ //# sourceMappingURL=use-record-subtitle-pWMBqQx9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-record-subtitle-pWMBqQx9.js","names":[],"sources":["../src/resource/use-record-subtitle.ts"],"sourcesContent":["'use client';\nimport { type RecordTitleContext, resolveEnumLabel } from '@burojs/core';\nimport { useApp, useI18nCaps, useListAccess } from '@burojs/react';\nimport { useCallback } from 'react';\nimport { visibleRow } from './visible-row.js';\n\n/**\n * A record's second line as code declares it (REF-136): the resource's `recordSubtitle`, or a\n * relation field's `optionSubtitle` for that field's options. A string is the line, `null` says\n * there is none, `undefined` (or a blank string) leaves it to the surface.\n */\nexport type RecordSubtitleFn = (\n record: Readonly<Record<string, unknown>>,\n ctx?: RecordTitleContext,\n) => string | null | undefined;\n\n/** The first of `fns` that decides: a non-blank string, or `null`; else `undefined`. */\nfunction declaredSubtitle(\n fns: readonly (RecordSubtitleFn | undefined)[],\n record: Readonly<Record<string, unknown>>,\n ctx: RecordTitleContext,\n): string | null | undefined {\n for (const fn of fns) {\n const out = fn?.(record, ctx);\n if (out === null) return null;\n if (typeof out === 'string' && out.trim() !== '') return out;\n }\n return undefined;\n}\n\n/**\n * The declared subtitle of one of `resource`'s records: `override` first, then the resource's\n * `recordSubtitle`. Hand it a record as its viewer may read it (projected in record reach); a row of\n * a list goes through {@link useRowSubtitle}. Like `recordTitle`, the hooks are called with an i18n\n * context bound to the resource, so an enum label in the line follows the active locale.\n */\nexport function useRecordSubtitle(\n resource: string,\n override?: RecordSubtitleFn,\n): (record: Readonly<Record<string, unknown>>) => string | null | undefined {\n const app = useApp();\n const caps = useI18nCaps(resource);\n const own: RecordSubtitleFn | undefined = app.registry.get(resource)?.recordSubtitle;\n return useCallback(\n (record) => {\n if (override === undefined && own === undefined) return undefined;\n return declaredSubtitle([override, own], record, {\n resolveEnum: (namespace, value, inlineDefault) =>\n resolveEnumLabel(caps, namespace, value, inlineDefault),\n });\n },\n [override, own, caps],\n );\n}\n\n/**\n * The declared subtitle of a row a list surface shows (picker options, palette results): the hooks\n * see only the row's declared fields its user may view in any-record reach, and its id (P5 spec\n * 3.6, as a list title reads only a visible display field). Undecided access declares nothing.\n */\nexport function useRowSubtitle(\n target: string,\n override?: RecordSubtitleFn,\n): (row: Readonly<Record<string, unknown>>) => string | null | undefined {\n const app = useApp();\n const access = useListAccess(target);\n const def = app.registry.get(target);\n const resolve = useRecordSubtitle(target, override);\n const declares = override !== undefined || def?.recordSubtitle !== undefined;\n return useCallback(\n (row) => {\n if (!declares) return undefined;\n const visible = visibleRow(def, access, row);\n return visible === undefined ? undefined : resolve(visible);\n },\n [declares, access, def, resolve],\n );\n}\n\n/**\n * A picker option's second line: the declared subtitle, else the option's `#<id>` — not drawn when\n * the label already is the id, which would print it twice (REF-40). `null`: none.\n */\nexport function optionSubtitle(\n declared: string | null | undefined,\n label: string,\n id: string,\n): string | null {\n if (declared !== undefined) return declared;\n return label === id ? null : `#${id}`;\n}\n"],"mappings":";;;;;AAiBA,SAAS,iBACP,KACA,QACA,KAC2B;CAC3B,KAAK,MAAM,MAAM,KAAK;EACpB,MAAM,MAAM,KAAK,QAAQ,GAAG;EAC5B,IAAI,QAAQ,MAAM,OAAO;EACzB,IAAI,OAAO,QAAQ,YAAY,IAAI,KAAK,MAAM,IAAI,OAAO;CAC3D;AAEF;AAQA,SAAgB,kBACd,UACA,UAC0E;CAC1E,MAAM,MAAM,OAAO;CACnB,MAAM,OAAO,YAAY,QAAQ;CACjC,MAAM,MAAoC,IAAI,SAAS,IAAI,QAAQ,CAAC,EAAE;CACtE,OAAO,aACJ,WAAW;EACV,IAAI,aAAa,KAAA,KAAa,QAAQ,KAAA,GAAW,OAAO,KAAA;EACxD,OAAO,iBAAiB,CAAC,UAAU,GAAG,GAAG,QAAQ,EAC/C,cAAc,WAAW,OAAO,kBAC9B,iBAAiB,MAAM,WAAW,OAAO,aAAa,EAC1D,CAAC;CACH,GACA;EAAC;EAAU;EAAK;CAAI,CACtB;AACF;AAOA,SAAgB,eACd,QACA,UACuE;CACvE,MAAM,MAAM,OAAO;CACnB,MAAM,SAAS,cAAc,MAAM;CACnC,MAAM,MAAM,IAAI,SAAS,IAAI,MAAM;CACnC,MAAM,UAAU,kBAAkB,QAAQ,QAAQ;CAClD,MAAM,WAAW,aAAa,KAAA,KAAa,KAAK,mBAAmB,KAAA;CACnE,OAAO,aACJ,QAAQ;EACP,IAAI,CAAC,UAAU,OAAO,KAAA;EACtB,MAAM,UAAU,WAAW,KAAK,QAAQ,GAAG;EAC3C,OAAO,YAAY,KAAA,IAAY,KAAA,IAAY,QAAQ,OAAO;CAC5D,GACA;EAAC;EAAU;EAAQ;EAAK;CAAO,CACjC;AACF;AAMA,SAAgB,eACd,UACA,OACA,IACe;CACf,IAAI,aAAa,KAAA,GAAW,OAAO;CACnC,OAAO,UAAU,KAAK,OAAO,IAAI;AACnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burojs/ui-shadcn",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "license": "MIT",
5
5
  "description": "Buro: default shadcn+Tailwind UI kit with required testid attributes",
6
6
  "type": "module",
@@ -120,11 +120,11 @@
120
120
  "tw-animate-css": "^1.4.0",
121
121
  "unist-util-visit": "^5",
122
122
  "zod": "^3.24.0",
123
- "@burojs/core": "0.8.0",
124
- "@burojs/field-types": "0.8.0",
125
- "@burojs/file-storage": "0.8.0",
126
- "@burojs/i18n-core": "0.8.0",
127
- "@burojs/react": "0.8.0"
123
+ "@burojs/core": "0.10.0",
124
+ "@burojs/field-types": "0.10.0",
125
+ "@burojs/file-storage": "0.10.0",
126
+ "@burojs/i18n-core": "0.10.0",
127
+ "@burojs/react": "0.10.0"
128
128
  },
129
129
  "peerDependencies": {
130
130
  "react": "^19.0.0",
@@ -147,9 +147,9 @@
147
147
  "react-dom": "^19.0.0",
148
148
  "typescript": "^5.5.0",
149
149
  "vitest": "^4.0.0",
150
- "@burojs/context": "0.8.0",
151
- "@burojs/export": "0.8.0",
152
- "@burojs/testing": "0.8.0",
150
+ "@burojs/context": "0.10.0",
151
+ "@burojs/export": "0.10.0",
152
+ "@burojs/testing": "0.10.0",
153
153
  "@burojs/tooling-eslint": "0.0.0",
154
154
  "@burojs/tooling-globals": "0.0.0",
155
155
  "@burojs/tooling-tsconfig": "0.0.0"
@@ -1 +0,0 @@
1
- {"version":3,"file":"bulk-summary-2HLgz7Il.cjs","names":["useOptionalT","useI18nCaps","useForgetEachAttempt","useState","useTestIds","specificErrorText","kindErrorText","declaredText","BULK_SUMMARY_IDS","Button"],"sources":["../src/flows/bulk-summary.tsx"],"sourcesContent":["'use client';\nimport { BULK_SUMMARY_IDS, type BulkProgress, type DataError, declaredText } from '@burojs/core';\nimport {\n type ErrorTextPlace,\n kindErrorText,\n specificErrorText,\n useI18nCaps,\n useOptionalT,\n useTestIds,\n} from '@burojs/react';\nimport { useForgetEachAttempt } from '@burojs/react/flows';\nimport { type ReactElement, useState } from 'react';\nimport { Button } from '../primitives/button.js';\n\nexport interface FlowBulkSummaryProps {\n readonly resource: string;\n readonly actionName: string;\n /** The action's label. */\n readonly label: string;\n /** How many ids the run was given. */\n readonly total: number;\n readonly progress: BulkProgress;\n /** The action's declared texts (`texts.validation`, `texts.rejected`): the resolver's action place. */\n readonly texts?: unknown;\n}\n\n/** One line of a group: the ids that read the same text; `text` absent for a group without lines. */\ninterface SummaryLine {\n readonly text?: string;\n readonly ids: readonly string[];\n}\n\ninterface SummaryGroup {\n readonly key: string;\n readonly title: string;\n readonly lines: readonly SummaryLine[];\n}\n\n/** The ids by their text, in the order each text first appears. */\nfunction linesByText(entries: readonly { readonly id: string; readonly text: string }[]) {\n const lines = new Map<string, string[]>();\n for (const { id, text } of entries) {\n const ids = lines.get(text);\n if (ids === undefined) lines.set(text, [id]);\n else ids.push(id);\n }\n return [...lines].map(([text, ids]): SummaryLine => ({ text, ids }));\n}\n\n/**\n * A bulk flow's summary (P4 spec 4.16, T1 spec 4.17): the count that succeeded of the ids given\n * (the flow's own `resources.<r>.actions.<name>.summary`, `{{count}}` of `{{total}}`, else the\n * framework's count text), then one group per other outcome with its count and up to\n * `BULK_SUMMARY_IDS` ids per line. The ids the server answered for are grouped first by\n * `applied` — not applied (refused or failed) and may have been applied (unknown) — and then by\n * the text each one's error resolves to (spec 4.15, with the action as the place), so\n * \"3 records: Already linked\" and \"2 records: Not allowed\" are separate lines. A row a check\n * rejected is grouped under that check's resolved text (`checks.<id>`), a row that was gone under\n * the flow's `texts.rereadGone` else \"No longer available\", and a row sent without a re-read\n * (`rereadSkipped` under `warn`, even when every row succeeded) under its own group (REF-135 §2.3).\n * Unresolved from an earlier run and not attempted keep their own groups.\n * Every text resolves at render, so a language switch re-renders it.\n */\nexport function FlowBulkSummary({\n resource,\n actionName,\n label,\n total,\n progress,\n texts,\n}: FlowBulkSummaryProps): ReactElement {\n const t = useOptionalT();\n const caps = useI18nCaps(resource);\n // An id the run left unknown, or found unresolved, has its exit here (P4-C review I3): the user\n // checked the record, and the id's attempt is forgotten — the next run sends it again.\n const forget = useForgetEachAttempt({ resource, action: actionName });\n const [forgotten, setForgotten] = useState<ReadonlySet<string>>(() => new Set());\n const forgetText = t('flow.forget', { defaultValue: \"I've checked — forget it\" });\n const tid = useTestIds();\n const testid = tid.bulkSummary(resource, actionName);\n const own = `resources.${resource}.actions.${actionName}.summary`;\n const count = progress.success.length;\n const heading = caps.has(own, { count })\n ? caps.t(own, { params: { total }, count })\n : `${label}: ${t('flow.bulkSummary', { defaultValue: `${count} processed`, params: { total }, count })} / ${total}`;\n // A bulk flow is a resource's action: its texts live under `resources.<r>.actions.<name>`.\n const place: ErrorTextPlace = {\n action: { prefix: `resources.${resource}.actions.${actionName}`, texts },\n };\n const textCaps = { has: (key: string) => caps.has(key), t: caps.t };\n // Steps 1 to 5 of spec 4.15; the fallback is the outcome's own sentence.\n const textOf = (error: DataError | undefined, fallback: () => string): string =>\n (error === undefined\n ? undefined\n : (specificErrorText(error, textCaps, place) ??\n kindErrorText(error.kind, textCaps, place))) ?? fallback();\n const neutral = () =>\n t('flow.rejected.validation', { defaultValue: 'Not accepted. Nothing was saved.' });\n const gone = progress.rejected.filter((entry) => entry.reason === 'gone');\n // One group per check, in the order each first appears, headed by the first entry's text. The machine resolved the\n // text (bundle entry, the check's declared `texts`, the framework's sentence); an entry without\n // it reads the check's `checks.<id>` bundle entry, else names the check.\n const byCheck = new Map<string, { check: string; title: string; ids: string[] }>();\n for (const entry of progress.rejected) {\n if (entry.reason !== 'check' || entry.check === undefined) continue;\n const own = `checks.${entry.check}`;\n const title = entry.message ?? (caps.has(own) ? caps.t(own) : entry.check);\n const group = byCheck.get(entry.check);\n if (group === undefined)\n byCheck.set(entry.check, { check: entry.check, title, ids: [entry.id] });\n else group.ids.push(entry.id);\n }\n const checkGroups = [...byCheck.values()].map(\n ({ check, title, ids }): SummaryGroup => ({ key: `check:${check}`, title, lines: [{ ids }] }),\n );\n const ownGone = `resources.${resource}.actions.${actionName}.rereadGone`;\n const goneTitle = caps.has(ownGone)\n ? caps.t(ownGone)\n : (declaredText('flow', { texts }, 'rereadGone') ??\n t('flow.bulkGone', { defaultValue: 'No longer available' }));\n const notApplied = [\n ...progress.rejected\n .filter((entry) => entry.reason === 'server')\n .map((entry) => ({ id: entry.id, text: textOf(entry.error, neutral) })),\n ...progress.failed.map((entry) => ({\n id: entry.id,\n text: textOf(entry.error, () =>\n entry.reason === 'reread'\n ? t('flow.couldNotReread', {\n defaultValue: \"Couldn't re-read the record. Nothing was sent.\",\n })\n : t('flow.failed', {\n defaultValue: 'The request could not be sent. Nothing was saved.',\n }),\n ),\n })),\n ];\n const unknown = progress.unknown\n .filter((entry) => !forgotten.has(entry.id))\n .map((entry) => ({\n id: entry.id,\n text: textOf(entry.error, () =>\n entry.error?.applied === 'partial'\n ? t('flow.unknownPartial', {\n defaultValue: 'Part of this may have been applied. Nothing was resent.',\n })\n : t('flow.unknown', { defaultValue: 'It may have been applied. Nothing was resent.' }),\n ),\n }));\n const groups: readonly SummaryGroup[] = [\n ...checkGroups,\n { key: 'gone', title: goneTitle, lines: [{ ids: gone.map((entry) => entry.id) }] },\n {\n key: 'reread-skipped',\n title: t('flow.bulkSentWithoutReread', { defaultValue: 'Sent without a current record' }),\n lines: [\n {\n ids: progress.rereadSkipped\n .filter((entry) => entry.policy === 'warn')\n .map((entry) => entry.id),\n },\n ],\n },\n {\n key: 'not-applied',\n title: t('flow.bulkNotApplied', { defaultValue: 'Not applied' }),\n lines: linesByText(notApplied),\n },\n {\n key: 'unknown',\n title: t('flow.bulkMayHaveBeenApplied', { defaultValue: 'May have been applied' }),\n lines: linesByText(unknown),\n },\n {\n key: 'unresolved',\n title: t('flow.bulkUnresolved', {\n defaultValue: 'Skipped: an earlier request for it may have been applied.',\n }),\n lines: [{ ids: progress.unresolved.filter((id) => !forgotten.has(id)) }],\n },\n {\n key: 'not-attempted',\n title: t('flow.bulkNotAttempted', { defaultValue: 'Not attempted.' }),\n lines: [{ ids: progress.notAttempted }],\n },\n ];\n const sizeOf = (group: SummaryGroup) =>\n group.lines.reduce((sum, line) => sum + line.ids.length, 0);\n return (\n <div data-testid={testid} className=\"flex flex-col gap-3 text-sm\">\n <p data-testid={`${testid}:heading`} className=\"font-medium\">\n {heading}\n </p>\n {groups\n .filter((group) => sizeOf(group) > 0)\n .map((group) => (\n <section key={group.key} data-testid={`${testid}:${group.key}`}>\n <h3 className=\"font-medium\">\n {group.title}{' '}\n <span data-testid={`${testid}:${group.key}:count`} className=\"tabular-nums\">\n ({sizeOf(group)})\n </span>\n </h3>\n {group.lines.map((line, index) => (\n <div\n key={line.text ?? index}\n data-testid={line.text === undefined ? undefined : `${testid}:${group.key}:line`}\n >\n {line.text === undefined ? null : (\n <p>\n {t('flow.bulkLine', {\n defaultValue: `${line.ids.length}: ${line.text}`,\n params: { message: line.text },\n count: line.ids.length,\n })}\n </p>\n )}\n <ul className=\"flex flex-wrap gap-1 text-muted-foreground\">\n {line.ids.slice(0, BULK_SUMMARY_IDS).map((id) => (\n <li\n key={id}\n data-testid={`${testid}:${group.key}:${id}`}\n className=\"flex items-center gap-1\"\n >\n {id}\n {group.key === 'unknown' || group.key === 'unresolved' ? (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n className=\"h-6 px-1.5 text-xs\"\n data-testid={`${testid}:forget:${id}`}\n onClick={() =>\n void forget(id).then(() =>\n setForgotten((previous) => new Set([...previous, id])),\n )\n }\n >\n {forgetText}\n </Button>\n ) : null}\n </li>\n ))}\n {line.ids.length > BULK_SUMMARY_IDS ? (\n <li>+{line.ids.length - BULK_SUMMARY_IDS}</li>\n ) : null}\n </ul>\n </div>\n ))}\n </section>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAuCA,SAAS,YAAY,SAAoE;CACvF,MAAM,QAAQ,IAAI,IAAsB;CACxC,KAAK,MAAM,EAAE,IAAI,UAAU,SAAS;EAClC,MAAM,MAAM,MAAM,IAAI,IAAI;EAC1B,IAAI,QAAQ,KAAA,GAAW,MAAM,IAAI,MAAM,CAAC,EAAE,CAAC;OACtC,IAAI,KAAK,EAAE;CAClB;CACA,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,UAAuB;EAAE;EAAM;CAAI,EAAE;AACrE;AAgBA,SAAgB,gBAAgB,EAC9B,UACA,YACA,OACA,OACA,UACA,SACqC;CACrC,MAAM,KAAA,GAAIA,cAAAA,aAAAA,CAAa;CACvB,MAAM,QAAA,GAAOC,cAAAA,YAAAA,CAAY,QAAQ;CAGjC,MAAM,UAAA,GAASC,oBAAAA,qBA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,CACL,GACA,KAAK,IAAI,SAASD,aAAAA,oBACjB,GAAA,kBAAA,KAAA,CAAC,MAAD,EAAA,UAAA,CAAI,KAAE,KAAK,IAAI,SAASA,aAAAA,gBAAqB,EAAA,CAAA,IAC3C,IACF;IACD,CAAA,CAAA;GA1CE,GAAA,KAAK,QAAQ,KA0Cf,CACN,CACM;EArDK,GAAA,MAAM,GAqDX,CACV,CACA;;AAET"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"bulk-summary-D6A0ua21.js","names":[],"sources":["../src/flows/bulk-summary.tsx"],"sourcesContent":["'use client';\nimport { BULK_SUMMARY_IDS, type BulkProgress, type DataError, declaredText } from '@burojs/core';\nimport {\n type ErrorTextPlace,\n kindErrorText,\n specificErrorText,\n useI18nCaps,\n useOptionalT,\n useTestIds,\n} from '@burojs/react';\nimport { useForgetEachAttempt } from '@burojs/react/flows';\nimport { type ReactElement, useState } from 'react';\nimport { Button } from '../primitives/button.js';\n\nexport interface FlowBulkSummaryProps {\n readonly resource: string;\n readonly actionName: string;\n /** The action's label. */\n readonly label: string;\n /** How many ids the run was given. */\n readonly total: number;\n readonly progress: BulkProgress;\n /** The action's declared texts (`texts.validation`, `texts.rejected`): the resolver's action place. */\n readonly texts?: unknown;\n}\n\n/** One line of a group: the ids that read the same text; `text` absent for a group without lines. */\ninterface SummaryLine {\n readonly text?: string;\n readonly ids: readonly string[];\n}\n\ninterface SummaryGroup {\n readonly key: string;\n readonly title: string;\n readonly lines: readonly SummaryLine[];\n}\n\n/** The ids by their text, in the order each text first appears. */\nfunction linesByText(entries: readonly { readonly id: string; readonly text: string }[]) {\n const lines = new Map<string, string[]>();\n for (const { id, text } of entries) {\n const ids = lines.get(text);\n if (ids === undefined) lines.set(text, [id]);\n else ids.push(id);\n }\n return [...lines].map(([text, ids]): SummaryLine => ({ text, ids }));\n}\n\n/**\n * A bulk flow's summary (P4 spec 4.16, T1 spec 4.17): the count that succeeded of the ids given\n * (the flow's own `resources.<r>.actions.<name>.summary`, `{{count}}` of `{{total}}`, else the\n * framework's count text), then one group per other outcome with its count and up to\n * `BULK_SUMMARY_IDS` ids per line. The ids the server answered for are grouped first by\n * `applied` — not applied (refused or failed) and may have been applied (unknown) — and then by\n * the text each one's error resolves to (spec 4.15, with the action as the place), so\n * \"3 records: Already linked\" and \"2 records: Not allowed\" are separate lines. A row a check\n * rejected is grouped under that check's resolved text (`checks.<id>`), a row that was gone under\n * the flow's `texts.rereadGone` else \"No longer available\", and a row sent without a re-read\n * (`rereadSkipped` under `warn`, even when every row succeeded) under its own group (REF-135 §2.3).\n * Unresolved from an earlier run and not attempted keep their own groups.\n * Every text resolves at render, so a language switch re-renders it.\n */\nexport function FlowBulkSummary({\n resource,\n actionName,\n label,\n total,\n progress,\n texts,\n}: FlowBulkSummaryProps): ReactElement {\n const t = useOptionalT();\n const caps = useI18nCaps(resource);\n // An id the run left unknown, or found unresolved, has its exit here (P4-C review I3): the user\n // checked the record, and the id's attempt is forgotten — the next run sends it again.\n const forget = useForgetEachAttempt({ resource, action: actionName });\n const [forgotten, setForgotten] = useState<ReadonlySet<string>>(() => new Set());\n const forgetText = t('flow.forget', { defaultValue: \"I've checked — forget it\" });\n const tid = useTestIds();\n const testid = tid.bulkSummary(resource, actionName);\n const own = `resources.${resource}.actions.${actionName}.summary`;\n const count = progress.success.length;\n const heading = caps.has(own, { count })\n ? caps.t(own, { params: { total }, count })\n : `${label}: ${t('flow.bulkSummary', { defaultValue: `${count} processed`, params: { total }, count })} / ${total}`;\n // A bulk flow is a resource's action: its texts live under `resources.<r>.actions.<name>`.\n const place: ErrorTextPlace = {\n action: { prefix: `resources.${resource}.actions.${actionName}`, texts },\n };\n const textCaps = { has: (key: string) => caps.has(key), t: caps.t };\n // Steps 1 to 5 of spec 4.15; the fallback is the outcome's own sentence.\n const textOf = (error: DataError | undefined, fallback: () => string): string =>\n (error === undefined\n ? undefined\n : (specificErrorText(error, textCaps, place) ??\n kindErrorText(error.kind, textCaps, place))) ?? fallback();\n const neutral = () =>\n t('flow.rejected.validation', { defaultValue: 'Not accepted. Nothing was saved.' });\n const gone = progress.rejected.filter((entry) => entry.reason === 'gone');\n // One group per check, in the order each first appears, headed by the first entry's text. The machine resolved the\n // text (bundle entry, the check's declared `texts`, the framework's sentence); an entry without\n // it reads the check's `checks.<id>` bundle entry, else names the check.\n const byCheck = new Map<string, { check: string; title: string; ids: string[] }>();\n for (const entry of progress.rejected) {\n if (entry.reason !== 'check' || entry.check === undefined) continue;\n const own = `checks.${entry.check}`;\n const title = entry.message ?? (caps.has(own) ? caps.t(own) : entry.check);\n const group = byCheck.get(entry.check);\n if (group === undefined)\n byCheck.set(entry.check, { check: entry.check, title, ids: [entry.id] });\n else group.ids.push(entry.id);\n }\n const checkGroups = [...byCheck.values()].map(\n ({ check, title, ids }): SummaryGroup => ({ key: `check:${check}`, title, lines: [{ ids }] }),\n );\n const ownGone = `resources.${resource}.actions.${actionName}.rereadGone`;\n const goneTitle = caps.has(ownGone)\n ? caps.t(ownGone)\n : (declaredText('flow', { texts }, 'rereadGone') ??\n t('flow.bulkGone', { defaultValue: 'No longer available' }));\n const notApplied = [\n ...progress.rejected\n .filter((entry) => entry.reason === 'server')\n .map((entry) => ({ id: entry.id, text: textOf(entry.error, neutral) })),\n ...progress.failed.map((entry) => ({\n id: entry.id,\n text: textOf(entry.error, () =>\n entry.reason === 'reread'\n ? t('flow.couldNotReread', {\n defaultValue: \"Couldn't re-read the record. Nothing was sent.\",\n })\n : t('flow.failed', {\n defaultValue: 'The request could not be sent. Nothing was saved.',\n }),\n ),\n })),\n ];\n const unknown = progress.unknown\n .filter((entry) => !forgotten.has(entry.id))\n .map((entry) => ({\n id: entry.id,\n text: textOf(entry.error, () =>\n entry.error?.applied === 'partial'\n ? t('flow.unknownPartial', {\n defaultValue: 'Part of this may have been applied. Nothing was resent.',\n })\n : t('flow.unknown', { defaultValue: 'It may have been applied. Nothing was resent.' }),\n ),\n }));\n const groups: readonly SummaryGroup[] = [\n ...checkGroups,\n { key: 'gone', title: goneTitle, lines: [{ ids: gone.map((entry) => entry.id) }] },\n {\n key: 'reread-skipped',\n title: t('flow.bulkSentWithoutReread', { defaultValue: 'Sent without a current record' }),\n lines: [\n {\n ids: progress.rereadSkipped\n .filter((entry) => entry.policy === 'warn')\n .map((entry) => entry.id),\n },\n ],\n },\n {\n key: 'not-applied',\n title: t('flow.bulkNotApplied', { defaultValue: 'Not applied' }),\n lines: linesByText(notApplied),\n },\n {\n key: 'unknown',\n title: t('flow.bulkMayHaveBeenApplied', { defaultValue: 'May have been applied' }),\n lines: linesByText(unknown),\n },\n {\n key: 'unresolved',\n title: t('flow.bulkUnresolved', {\n defaultValue: 'Skipped: an earlier request for it may have been applied.',\n }),\n lines: [{ ids: progress.unresolved.filter((id) => !forgotten.has(id)) }],\n },\n {\n key: 'not-attempted',\n title: t('flow.bulkNotAttempted', { defaultValue: 'Not attempted.' }),\n lines: [{ ids: progress.notAttempted }],\n },\n ];\n const sizeOf = (group: SummaryGroup) =>\n group.lines.reduce((sum, line) => sum + line.ids.length, 0);\n return (\n <div data-testid={testid} className=\"flex flex-col gap-3 text-sm\">\n <p data-testid={`${testid}:heading`} className=\"font-medium\">\n {heading}\n </p>\n {groups\n .filter((group) => sizeOf(group) > 0)\n .map((group) => (\n <section key={group.key} data-testid={`${testid}:${group.key}`}>\n <h3 className=\"font-medium\">\n {group.title}{' '}\n <span data-testid={`${testid}:${group.key}:count`} className=\"tabular-nums\">\n ({sizeOf(group)})\n </span>\n </h3>\n {group.lines.map((line, index) => (\n <div\n key={line.text ?? index}\n data-testid={line.text === undefined ? undefined : `${testid}:${group.key}:line`}\n >\n {line.text === undefined ? null : (\n <p>\n {t('flow.bulkLine', {\n defaultValue: `${line.ids.length}: ${line.text}`,\n params: { message: line.text },\n count: line.ids.length,\n })}\n </p>\n )}\n <ul className=\"flex flex-wrap gap-1 text-muted-foreground\">\n {line.ids.slice(0, BULK_SUMMARY_IDS).map((id) => (\n <li\n key={id}\n data-testid={`${testid}:${group.key}:${id}`}\n className=\"flex items-center gap-1\"\n >\n {id}\n {group.key === 'unknown' || group.key === 'unresolved' ? (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n className=\"h-6 px-1.5 text-xs\"\n data-testid={`${testid}:forget:${id}`}\n onClick={() =>\n void forget(id).then(() =>\n setForgotten((previous) => new Set([...previous, id])),\n )\n }\n >\n {forgetText}\n </Button>\n ) : null}\n </li>\n ))}\n {line.ids.length > BULK_SUMMARY_IDS ? (\n <li>+{line.ids.length - BULK_SUMMARY_IDS}</li>\n ) : null}\n </ul>\n </div>\n ))}\n </section>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAuCA,SAAS,YAAY,SAAoE;CACvF,MAAM,QAAQ,IAAI,IAAsB;CACxC,KAAK,MAAM,EAAE,IAAI,UAAU,SAAS;EAClC,MAAM,MAAM,MAAM,IAAI,IAAI;EAC1B,IAAI,QAAQ,KAAA,GAAW,MAAM,IAAI,MAAM,CAAC,EAAE,CAAC;OACtC,IAAI,KAAK,EAAE;CAClB;CACA,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,UAAuB;EAAE;EAAM;CAAI,EAAE;AACrE;AAgBA,SAAgB,gBAAgB,EAC9B,UACA,YACA,OACA,OACA,UACA,SACqC;CACrC,MAAM,IAAI,aAAa;CACvB,MAAM,OAAO,YAAY,QAAQ;CAGjC,MAAM,SAAS,qBAAqB;EAAE;EAAU,QAAQ;CAAW,CAAC;CACpE,MAAM,CAAC,WAAW,gBAAgB,eAAoC,IAAI,IAAI,CAAC;CAC/E,MAAM,aAAa,EAAE,eAAe,EAAE,cAAc,2BAA2B,CAAC;CAEhF,MAAM,SADM,WACK,CAAC,CAAC,YAAY,UAAU,UAAU;CACnD,MAAM,MAAM,aAAa,SAAS,WAAW,WAAW;CACxD,MAAM,QAAQ,SAAS,QAAQ;CAC/B,MAAM,UAAU,KAAK,IAAI,KAAK,EAAE,MAAM,CAAC,IACnC,KAA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