@12-apps/ui 6.12.0 → 6.13.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 (136) hide show
  1. package/dist/_internal/components/data-display/DataViews/DataViewsGrid.js +25 -25
  2. package/dist/_internal/components/data-display/DataViews/DataViewsTableBase.js +27 -27
  3. package/dist/_internal/components/data-display/DataViews/base-card.js +2 -2
  4. package/dist/_internal/components/data-display/DataViews/base-list-card-geometry.js +5 -5
  5. package/dist/_internal/components/data-display/DataViews/base-list-card-slots.js +4 -4
  6. package/dist/_internal/components/data-display/DataViews/base-list-card.js +6 -6
  7. package/dist/_internal/components/data-display/DataViews/data-views-category-pill.js +11 -11
  8. package/dist/_internal/components/data-display/DataViews/data-views-display-panel.js +4 -4
  9. package/dist/_internal/components/data-display/DataViews/data-views-display-tabs.js +3 -3
  10. package/dist/_internal/components/data-display/DataViews/data-views-filter-panel.js +12 -12
  11. package/dist/_internal/components/data-display/DataViews/data-views-grid-bodies.js +4 -4
  12. package/dist/_internal/components/data-display/DataViews/data-views-grid-parts.js +23 -23
  13. package/dist/_internal/components/data-display/DataViews/data-views-inline-bar.js +12 -12
  14. package/dist/_internal/components/data-display/DataViews/data-views-layout-context.js +2 -2
  15. package/dist/_internal/components/data-display/DataViews/data-views-scope-tabs.js +3 -3
  16. package/dist/_internal/components/data-display/DataViews/data-views-shell-toolbar.js +6 -6
  17. package/dist/_internal/components/data-display/DataViews/data-views-toolbar.js +5 -5
  18. package/dist/_internal/components/data-display/DataViews/data-views-types.js +1 -1
  19. package/dist/_internal/components/data-display/DataViews/list-card-rails.js +3 -3
  20. package/dist/_internal/components/data-display/DataViews/use-data-views-state.js +2 -2
  21. package/dist/_internal/components/data-display/DataViews/use-saved-views-controller.js +2 -2
  22. package/dist/_internal/components/form/CategorySelect/CategoryPanel.js +5 -5
  23. package/dist/_internal/components/form/CategorySelect/CategoryPanelList.js +3 -3
  24. package/dist/_internal/components/form/CategorySelect/CategoryQuickActions.js +2 -2
  25. package/dist/_internal/components/form/CategorySelect/CategoryRows.js +2 -2
  26. package/dist/_internal/components/form/CategorySelect/CategorySelect.js +10 -10
  27. package/dist/_internal/components/form/CategorySelect/category-keyboard.js +2 -1
  28. package/dist/_internal/components/form/CategorySelect/category-tree.js +3 -1
  29. package/dist/_internal/components/form/CategorySelect/useCategoryCommit.js +2 -1
  30. package/dist/_internal/components/form/CategorySelect/useCategoryKeyHandler.js +3 -2
  31. package/dist/_internal/components/form/CategorySelect/useCategorySelect.js +2 -2
  32. package/dist/_internal/components/form/total-form/Fields/CategoryField.js +11 -11
  33. package/dist/_internal/components/form/total-form/Fields/index.js +12 -12
  34. package/dist/{chunk-HQBXB5QB.js → chunk-2GB5CIN6.js} +2 -2
  35. package/dist/{chunk-IKBQ7CS2.js → chunk-56SMIHWE.js} +2 -2
  36. package/dist/{chunk-LWYXMCX6.js → chunk-5ZZPQ3MT.js} +4 -4
  37. package/dist/{chunk-JIEEUHNS.js → chunk-AZSFIQIA.js} +8 -8
  38. package/dist/{chunk-S6T722WH.js → chunk-BMAOQDVY.js} +3 -3
  39. package/dist/{chunk-5F4NIRVF.js → chunk-CKZFYGBY.js} +10 -6
  40. package/dist/chunk-CKZFYGBY.js.map +1 -0
  41. package/dist/{chunk-CY5X3HNQ.js → chunk-E2H7MBPM.js} +2 -2
  42. package/dist/{chunk-KWUQZDPL.js → chunk-ECIGNYSI.js} +3 -2
  43. package/dist/chunk-ECIGNYSI.js.map +1 -0
  44. package/dist/{chunk-XQZOMXP3.js → chunk-FZHKKLOO.js} +2 -2
  45. package/dist/{chunk-NXTKZSMT.js → chunk-IN642YHK.js} +2 -2
  46. package/dist/{chunk-QBJVRPTF.js → chunk-ISH42UC7.js} +2 -2
  47. package/dist/{chunk-AGKQBS4C.js → chunk-JHBQZZHT.js} +3 -3
  48. package/dist/{chunk-SVXSBLVD.js → chunk-KEDI6IRA.js} +2 -2
  49. package/dist/{chunk-Z5E2PXGN.js → chunk-LPYB4Y7C.js} +49 -16
  50. package/dist/chunk-LPYB4Y7C.js.map +1 -0
  51. package/dist/{chunk-DVTCZR3K.js → chunk-LR6MSKTT.js} +7 -5
  52. package/dist/chunk-LR6MSKTT.js.map +1 -0
  53. package/dist/{chunk-USBTXEBG.js → chunk-P55UFXYW.js} +2 -2
  54. package/dist/{chunk-C6ATAHBX.js → chunk-QEPGWTJT.js} +1 -1
  55. package/dist/chunk-QEPGWTJT.js.map +1 -0
  56. package/dist/{chunk-6UGRH32J.js → chunk-QRKBBOSY.js} +4 -4
  57. package/dist/{chunk-TY6CTYCF.js → chunk-TOUSE63W.js} +2 -2
  58. package/dist/{chunk-TDSRBCBG.js → chunk-W3UM2KEW.js} +7 -7
  59. package/dist/{chunk-6IAQGSXD.js → chunk-WIEXYVMU.js} +2 -2
  60. package/dist/{chunk-GQTBWJYK.js → chunk-WKRSVGT6.js} +2 -2
  61. package/dist/{chunk-T6V3DKJ5.js → chunk-WLCVOQCJ.js} +2 -2
  62. package/dist/{chunk-GCC66ZSD.js → chunk-WWM2YTW4.js} +29 -13
  63. package/dist/chunk-WWM2YTW4.js.map +1 -0
  64. package/dist/{chunk-ZBYWGL5G.js → chunk-WXHJG2UU.js} +2 -2
  65. package/dist/{chunk-QFHUWD3C.js → chunk-XIYPVNEB.js} +3 -3
  66. package/dist/{chunk-N7SBWD2V.js → chunk-XYRS4JOF.js} +4 -4
  67. package/dist/{chunk-T4JGNZAR.js → chunk-YQJMVUBG.js} +2 -2
  68. package/dist/{chunk-F6FT2LIR.js → chunk-YRFKPRV2.js} +2 -2
  69. package/dist/{chunk-VN6Z6F7R.js → chunk-ZAB65STX.js} +11 -6
  70. package/dist/chunk-ZAB65STX.js.map +1 -0
  71. package/dist/{chunk-HVIB6WMD.js → chunk-ZIPCGZA3.js} +2 -2
  72. package/dist/{chunk-Q5GXVDXL.js → chunk-ZQPG57GA.js} +2 -2
  73. package/dist/{chunk-E3IPN3KN.js → chunk-ZUIJ3N7N.js} +2 -2
  74. package/dist/data-display/DataViews.js +31 -31
  75. package/dist/form/CategorySelect.js +10 -10
  76. package/dist/form/total-form.js +12 -12
  77. package/dist/types/components/data-display/DataViews/data-views-category-pill.d.ts +6 -0
  78. package/dist/types/components/data-display/DataViews/data-views-category-pill.d.ts.map +1 -1
  79. package/dist/types/components/data-display/DataViews/data-views-types.d.ts +13 -0
  80. package/dist/types/components/data-display/DataViews/data-views-types.d.ts.map +1 -1
  81. package/dist/types/components/form/CategorySelect/CategoryPanelList.d.ts.map +1 -1
  82. package/dist/types/components/form/CategorySelect/CategoryRows.d.ts +8 -2
  83. package/dist/types/components/form/CategorySelect/CategoryRows.d.ts.map +1 -1
  84. package/dist/types/components/form/CategorySelect/category-keyboard.d.ts +1 -1
  85. package/dist/types/components/form/CategorySelect/category-keyboard.d.ts.map +1 -1
  86. package/dist/types/components/form/CategorySelect/category-tree.d.ts +12 -0
  87. package/dist/types/components/form/CategorySelect/category-tree.d.ts.map +1 -1
  88. package/dist/types/components/form/CategorySelect/useCategoryCommit.d.ts.map +1 -1
  89. package/package.json +1 -1
  90. package/src/components/data-display/DataViews/data-views-category-pill.tsx +7 -0
  91. package/src/components/data-display/DataViews/data-views-types.ts +13 -0
  92. package/src/components/feedback/Modal/Modal.md +4 -1
  93. package/src/components/form/CategorySelect/CategoryPanelList.tsx +9 -5
  94. package/src/components/form/CategorySelect/CategoryRows.tsx +64 -23
  95. package/src/components/form/CategorySelect/CategorySelect.md +33 -6
  96. package/src/components/form/CategorySelect/category-keyboard.ts +34 -15
  97. package/src/components/form/CategorySelect/category-tree.ts +17 -8
  98. package/src/components/form/CategorySelect/useCategoryCommit.ts +10 -6
  99. package/src/components/form/Menubar/Menubar.md +2 -1
  100. package/src/components/layout/Accordion/Accordion.md +3 -1
  101. package/src/components/navigation/Breadcrumbs/Breadcrumbs.md +1 -1
  102. package/src/components/navigation/DropdownMenu/DropdownMenu.md +1 -1
  103. package/src/components/utility/VirtualList/VirtualList.md +4 -1
  104. package/dist/chunk-5F4NIRVF.js.map +0 -1
  105. package/dist/chunk-C6ATAHBX.js.map +0 -1
  106. package/dist/chunk-DVTCZR3K.js.map +0 -1
  107. package/dist/chunk-GCC66ZSD.js.map +0 -1
  108. package/dist/chunk-KWUQZDPL.js.map +0 -1
  109. package/dist/chunk-VN6Z6F7R.js.map +0 -1
  110. package/dist/chunk-Z5E2PXGN.js.map +0 -1
  111. /package/dist/{chunk-HQBXB5QB.js.map → chunk-2GB5CIN6.js.map} +0 -0
  112. /package/dist/{chunk-IKBQ7CS2.js.map → chunk-56SMIHWE.js.map} +0 -0
  113. /package/dist/{chunk-LWYXMCX6.js.map → chunk-5ZZPQ3MT.js.map} +0 -0
  114. /package/dist/{chunk-JIEEUHNS.js.map → chunk-AZSFIQIA.js.map} +0 -0
  115. /package/dist/{chunk-S6T722WH.js.map → chunk-BMAOQDVY.js.map} +0 -0
  116. /package/dist/{chunk-CY5X3HNQ.js.map → chunk-E2H7MBPM.js.map} +0 -0
  117. /package/dist/{chunk-XQZOMXP3.js.map → chunk-FZHKKLOO.js.map} +0 -0
  118. /package/dist/{chunk-NXTKZSMT.js.map → chunk-IN642YHK.js.map} +0 -0
  119. /package/dist/{chunk-QBJVRPTF.js.map → chunk-ISH42UC7.js.map} +0 -0
  120. /package/dist/{chunk-AGKQBS4C.js.map → chunk-JHBQZZHT.js.map} +0 -0
  121. /package/dist/{chunk-SVXSBLVD.js.map → chunk-KEDI6IRA.js.map} +0 -0
  122. /package/dist/{chunk-USBTXEBG.js.map → chunk-P55UFXYW.js.map} +0 -0
  123. /package/dist/{chunk-6UGRH32J.js.map → chunk-QRKBBOSY.js.map} +0 -0
  124. /package/dist/{chunk-TY6CTYCF.js.map → chunk-TOUSE63W.js.map} +0 -0
  125. /package/dist/{chunk-TDSRBCBG.js.map → chunk-W3UM2KEW.js.map} +0 -0
  126. /package/dist/{chunk-6IAQGSXD.js.map → chunk-WIEXYVMU.js.map} +0 -0
  127. /package/dist/{chunk-GQTBWJYK.js.map → chunk-WKRSVGT6.js.map} +0 -0
  128. /package/dist/{chunk-T6V3DKJ5.js.map → chunk-WLCVOQCJ.js.map} +0 -0
  129. /package/dist/{chunk-ZBYWGL5G.js.map → chunk-WXHJG2UU.js.map} +0 -0
  130. /package/dist/{chunk-QFHUWD3C.js.map → chunk-XIYPVNEB.js.map} +0 -0
  131. /package/dist/{chunk-N7SBWD2V.js.map → chunk-XYRS4JOF.js.map} +0 -0
  132. /package/dist/{chunk-T4JGNZAR.js.map → chunk-YQJMVUBG.js.map} +0 -0
  133. /package/dist/{chunk-F6FT2LIR.js.map → chunk-YRFKPRV2.js.map} +0 -0
  134. /package/dist/{chunk-HVIB6WMD.js.map → chunk-ZIPCGZA3.js.map} +0 -0
  135. /package/dist/{chunk-Q5GXVDXL.js.map → chunk-ZQPG57GA.js.map} +0 -0
  136. /package/dist/{chunk-E3IPN3KN.js.map → chunk-ZUIJ3N7N.js.map} +0 -0
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  GridShell
3
- } from "./chunk-TDSRBCBG.js";
3
+ } from "./chunk-W3UM2KEW.js";
4
4
  import {
5
5
  useDataViewsState
6
- } from "./chunk-TY6CTYCF.js";
6
+ } from "./chunk-TOUSE63W.js";
7
7
 
8
8
  // src/components/data-display/DataViews/DataViewsGrid.tsx
9
9
  import { useEffect, useRef } from "react";
@@ -27,4 +27,4 @@ function DataViewsGrid(props) {
27
27
  export {
28
28
  DataViewsGrid
29
29
  };
30
- //# sourceMappingURL=chunk-AGKQBS4C.js.map
30
+ //# sourceMappingURL=chunk-JHBQZZHT.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-4XK6JQ4D.js";
4
4
  import {
5
5
  CategorySelect
6
- } from "./chunk-JIEEUHNS.js";
6
+ } from "./chunk-AZSFIQIA.js";
7
7
 
8
8
  // src/components/form/total-form/Fields/CategoryField.tsx
9
9
  import { jsx } from "react/jsx-runtime";
@@ -38,4 +38,4 @@ function CategoryField({
38
38
  export {
39
39
  CategoryField
40
40
  };
41
- //# sourceMappingURL=chunk-SVXSBLVD.js.map
41
+ //# sourceMappingURL=chunk-KEDI6IRA.js.map
@@ -16,7 +16,7 @@ import {
16
16
  } from "./chunk-XCT2ZLA6.js";
17
17
  import {
18
18
  highlightSegments
19
- } from "./chunk-DVTCZR3K.js";
19
+ } from "./chunk-LR6MSKTT.js";
20
20
 
21
21
  // src/components/form/CategorySelect/CategoryRows.tsx
22
22
  import Box from "@mui/material/Box/index.js";
@@ -44,6 +44,42 @@ function rowMeta(selectedCount, showCounts, count) {
44
44
  if (showCounts && count !== void 0) return { text: String(count), selected: false };
45
45
  return null;
46
46
  }
47
+ function HeadRowDisclosure({
48
+ option,
49
+ expanded,
50
+ expandable,
51
+ onToggleExpanded,
52
+ dataTestId,
53
+ copy
54
+ }) {
55
+ if (!expandable) {
56
+ return /* @__PURE__ */ jsx(Box, { sx: { width: METRICS.chevronButton, flex: "0 0 auto" } });
57
+ }
58
+ return /* @__PURE__ */ jsx(
59
+ Box,
60
+ {
61
+ component: "button",
62
+ type: "button",
63
+ tabIndex: -1,
64
+ "aria-label": expanded ? copy.collapseCategory(option.name) : copy.expandCategory(option.name),
65
+ "data-testid": `${dataTestId}-expand-${option.id}`,
66
+ sx: (theme) => chevronButtonSx(theme, expanded),
67
+ onClick: (event) => {
68
+ event.stopPropagation();
69
+ onToggleExpanded();
70
+ },
71
+ children: /* @__PURE__ */ jsx(DisclosureGlyph, {})
72
+ }
73
+ );
74
+ }
75
+ function HeadRowControl({
76
+ checkState,
77
+ single
78
+ }) {
79
+ if (!checkState) return /* @__PURE__ */ jsx(Box, { sx: { width: METRICS.boxSize, flex: "0 0 auto" } });
80
+ if (single) return /* @__PURE__ */ jsx(CategoryRadio, { on: checkState === "on" });
81
+ return /* @__PURE__ */ jsx(CategoryCheckbox, { state: checkState });
82
+ }
47
83
  function CategoryHeadRow({
48
84
  option,
49
85
  query,
@@ -51,6 +87,8 @@ function CategoryHeadRow({
51
87
  active,
52
88
  sheet,
53
89
  checkState,
90
+ single,
91
+ expandable,
54
92
  selectedCount,
55
93
  showCounts,
56
94
  onToggleExpanded,
@@ -65,28 +103,23 @@ function CategoryHeadRow({
65
103
  component: "div",
66
104
  role: checkState ? "option" : "button",
67
105
  "aria-selected": checkState ? checkState === "on" : void 0,
68
- "aria-expanded": expanded,
106
+ "aria-expanded": expandable ? expanded : void 0,
69
107
  "data-testid": `${dataTestId}-category-${option.id}`,
70
108
  sx: (theme) => rowSx(theme, active, sheet),
71
109
  onClick: onActivate,
72
110
  children: [
73
111
  /* @__PURE__ */ jsx(
74
- Box,
112
+ HeadRowDisclosure,
75
113
  {
76
- component: "button",
77
- type: "button",
78
- tabIndex: -1,
79
- "aria-label": expanded ? copy.collapseCategory(option.name) : copy.expandCategory(option.name),
80
- "data-testid": `${dataTestId}-expand-${option.id}`,
81
- sx: (theme) => chevronButtonSx(theme, expanded),
82
- onClick: (event) => {
83
- event.stopPropagation();
84
- onToggleExpanded();
85
- },
86
- children: /* @__PURE__ */ jsx(DisclosureGlyph, {})
114
+ option,
115
+ expanded,
116
+ expandable,
117
+ onToggleExpanded,
118
+ dataTestId,
119
+ copy
87
120
  }
88
121
  ),
89
- checkState ? /* @__PURE__ */ jsx(CategoryCheckbox, { state: checkState }) : /* @__PURE__ */ jsx(Box, { sx: { width: METRICS.boxSize, flex: "0 0 auto" } }),
122
+ /* @__PURE__ */ jsx(HeadRowControl, { checkState, single }),
90
123
  /* @__PURE__ */ jsx(Box, { component: "span", sx: (theme) => rowNameSx(theme, true), children: /* @__PURE__ */ jsx(HighlightedName, { text: option.name, query }) }),
91
124
  meta && /* @__PURE__ */ jsx(Box, { component: "span", sx: (theme) => rowMetaSx(theme, meta.selected), children: meta.text })
92
125
  ]
@@ -137,4 +170,4 @@ export {
137
170
  SubcategoryRow,
138
171
  CategorySectionHeading
139
172
  };
140
- //# sourceMappingURL=chunk-Z5E2PXGN.js.map
173
+ //# sourceMappingURL=chunk-LPYB4Y7C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/form/CategorySelect/CategoryRows.tsx"],"sourcesContent":["'use client';\n\nimport Box from '@mui/material/Box/index.js';\n\nimport type { CategorySelectCopy } from '../../../copy';\nimport { CheckGlyph, DisclosureGlyph } from './CategoryIcons';\nimport { highlightSegments, type CategoryCheckState } from './category-tree';\nimport {\n checkboxBarSx,\n checkboxSx,\n chevronButtonSx,\n markSx,\n METRICS,\n radioSx,\n rowMetaSx,\n rowNameSx,\n rowSx,\n sectionHeadSx,\n} from './CategorySelect.styles';\nimport type { CategorySelectOption } from './CategorySelect.types';\n\n/** A label with the search hit marked. */\nexport function HighlightedName({\n text,\n query,\n}: {\n text: string;\n query: string;\n}): React.JSX.Element {\n const segments = highlightSegments(text, query);\n return (\n <>\n {segments.map((segment, index) =>\n segment.match ? (\n <Box component=\"mark\" key={`${segment.text}-${index}`} sx={markSx}>\n {segment.text}\n </Box>\n ) : (\n <span key={`${segment.text}-${index}`}>{segment.text}</span>\n ),\n )}\n </>\n );\n}\n\n/** Tri-state checkbox. `partial` draws the bar the prototype uses for \"some\". */\nexport function CategoryCheckbox({ state }: { state: CategoryCheckState }): React.JSX.Element {\n return (\n <Box sx={(theme) => checkboxSx(theme, state)} aria-hidden=\"true\">\n {state === 'on' && <CheckGlyph />}\n {state === 'partial' && <Box sx={checkboxBarSx} />}\n </Box>\n );\n}\n\nexport function CategoryRadio({ on }: { on: boolean }): React.JSX.Element {\n return <Box sx={(theme) => radioSx(theme, on)} aria-hidden=\"true\" />;\n}\n\ninterface CategoryHeadRowProps {\n option: CategorySelectOption;\n query: string;\n expanded: boolean;\n active: boolean;\n sheet: boolean;\n /** Absent in leaf-only mode, where the category is a heading with no checkbox. */\n checkState?: CategoryCheckState;\n /** Single-select draws a radio for the control: choosing a row is exclusive. */\n single: boolean;\n /** False for a childless category — there is nothing under it to disclose. */\n expandable: boolean;\n selectedCount: number;\n showCounts: boolean;\n onToggleExpanded: () => void;\n onActivate: () => void;\n dataTestId: string;\n copy: CategorySelectCopy;\n}\n\n/** The trailing number: how many children are picked, else the item count. */\nfunction rowMeta(\n selectedCount: number,\n showCounts: boolean,\n count: number | undefined,\n): { text: string; selected: boolean } | null {\n if (selectedCount > 0) return { text: String(selectedCount), selected: true };\n if (showCounts && count !== undefined) return { text: String(count), selected: false };\n return null;\n}\n\n/** The disclosure chevron, or the space it would have taken on a childless row. */\nfunction HeadRowDisclosure({\n option,\n expanded,\n expandable,\n onToggleExpanded,\n dataTestId,\n copy,\n}: Pick<\n CategoryHeadRowProps,\n 'option' | 'expanded' | 'expandable' | 'onToggleExpanded' | 'dataTestId' | 'copy'\n>): React.JSX.Element {\n if (!expandable) {\n return <Box sx={{ width: METRICS.chevronButton, flex: '0 0 auto' }} />;\n }\n return (\n <Box\n component=\"button\"\n type=\"button\"\n tabIndex={-1}\n aria-label={expanded ? copy.collapseCategory(option.name) : copy.expandCategory(option.name)}\n data-testid={`${dataTestId}-expand-${option.id}`}\n sx={(theme) => chevronButtonSx(theme, expanded)}\n onClick={(event: React.MouseEvent) => {\n event.stopPropagation();\n onToggleExpanded();\n }}\n >\n <DisclosureGlyph />\n </Box>\n );\n}\n\n/** The row's selection control, or the space it would have taken on a heading. */\nfunction HeadRowControl({\n checkState,\n single,\n}: Pick<CategoryHeadRowProps, 'checkState' | 'single'>): React.JSX.Element {\n if (!checkState) return <Box sx={{ width: METRICS.boxSize, flex: '0 0 auto' }} />;\n // Single-select commits the moment a row is chosen, so the control is a radio\n // there: a checkbox would promise the accumulation this mode does not do.\n if (single) return <CategoryRadio on={checkState === 'on'} />;\n return <CategoryCheckbox state={checkState} />;\n}\n\n/**\n * A top-level category row: disclosure chevron, optional checkbox, name, meta.\n *\n * The chevron is its OWN button inside the row button — clicking it only folds,\n * while clicking the row does the row's job (expand as a heading, or tick when\n * the category is selectable). A CHILDLESS category has neither a fold nor a\n * heading to be: it draws no chevron, and it carries the control, because it is\n * itself the leaf.\n */\nexport function CategoryHeadRow({\n option,\n query,\n expanded,\n active,\n sheet,\n checkState,\n single,\n expandable,\n selectedCount,\n showCounts,\n onToggleExpanded,\n onActivate,\n dataTestId,\n copy,\n}: CategoryHeadRowProps): React.JSX.Element {\n const meta = rowMeta(selectedCount, showCounts, option.count);\n return (\n <Box\n component=\"div\"\n role={checkState ? 'option' : 'button'}\n aria-selected={checkState ? checkState === 'on' : undefined}\n aria-expanded={expandable ? expanded : undefined}\n data-testid={`${dataTestId}-category-${option.id}`}\n sx={(theme) => rowSx(theme, active, sheet)}\n onClick={onActivate}\n >\n <HeadRowDisclosure\n option={option}\n expanded={expanded}\n expandable={expandable}\n onToggleExpanded={onToggleExpanded}\n dataTestId={dataTestId}\n copy={copy}\n />\n <HeadRowControl checkState={checkState} single={single} />\n <Box component=\"span\" sx={(theme) => rowNameSx(theme, true)}>\n <HighlightedName text={option.name} query={query} />\n </Box>\n {meta && (\n <Box component=\"span\" sx={(theme) => rowMetaSx(theme, meta.selected)}>\n {meta.text}\n </Box>\n )}\n </Box>\n );\n}\n\ninterface SubcategoryRowProps {\n option: CategorySelectOption;\n query: string;\n selected: boolean;\n active: boolean;\n sheet: boolean;\n /** Single-select mode draws a radio; multi-select draws a checkbox. */\n single: boolean;\n showCounts: boolean;\n onActivate: () => void;\n dataTestId: string;\n}\n\nexport function SubcategoryRow({\n option,\n query,\n selected,\n active,\n sheet,\n single,\n showCounts,\n onActivate,\n dataTestId,\n}: SubcategoryRowProps): React.JSX.Element {\n return (\n <Box\n component=\"div\"\n role=\"option\"\n aria-selected={selected}\n data-testid={`${dataTestId}-option-${option.id}`}\n sx={(theme) => ({ ...rowSx(theme, active, sheet), paddingLeft: '14px' })}\n onClick={onActivate}\n >\n <Box sx={{ width: METRICS.chevronButton, flex: '0 0 auto' }} />\n {single ? (\n <CategoryRadio on={selected} />\n ) : (\n <CategoryCheckbox state={selected ? 'on' : 'off'} />\n )}\n <Box component=\"span\" sx={(theme) => rowNameSx(theme, false)}>\n <HighlightedName text={option.name} query={query} />\n </Box>\n {showCounts && option.count !== undefined && (\n <Box component=\"span\" sx={(theme) => rowMetaSx(theme, false)}>\n {option.count}\n </Box>\n )}\n </Box>\n );\n}\n\n/** The category as a non-interactive heading (single-select, leaf-only). */\nexport function CategorySectionHeading({\n option,\n query,\n}: {\n option: CategorySelectOption;\n query: string;\n}): React.JSX.Element {\n return (\n <Box sx={sectionHeadSx}>\n <HighlightedName text={option.name} query={query} />\n </Box>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,SAAS;AA6BZ,mBAGM,KAcN,YAjBA;AATG,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AACF,GAGsB;AACpB,QAAM,WAAW,kBAAkB,MAAM,KAAK;AAC9C,SACE,gCACG,mBAAS;AAAA,IAAI,CAAC,SAAS,UACtB,QAAQ,QACN,oBAAC,OAAI,WAAU,QAAwC,IAAI,QACxD,kBAAQ,QADgB,GAAG,QAAQ,IAAI,IAAI,KAAK,EAEnD,IAEA,oBAAC,UAAuC,kBAAQ,QAArC,GAAG,QAAQ,IAAI,IAAI,KAAK,EAAkB;AAAA,EAEzD,GACF;AAEJ;AAGO,SAAS,iBAAiB,EAAE,MAAM,GAAqD;AAC5F,SACE,qBAAC,OAAI,IAAI,CAAC,UAAU,WAAW,OAAO,KAAK,GAAG,eAAY,QACvD;AAAA,cAAU,QAAQ,oBAAC,cAAW;AAAA,IAC9B,UAAU,aAAa,oBAAC,OAAI,IAAI,eAAe;AAAA,KAClD;AAEJ;AAEO,SAAS,cAAc,EAAE,GAAG,GAAuC;AACxE,SAAO,oBAAC,OAAI,IAAI,CAAC,UAAU,QAAQ,OAAO,EAAE,GAAG,eAAY,QAAO;AACpE;AAuBA,SAAS,QACP,eACA,YACA,OAC4C;AAC5C,MAAI,gBAAgB,EAAG,QAAO,EAAE,MAAM,OAAO,aAAa,GAAG,UAAU,KAAK;AAC5E,MAAI,cAAc,UAAU,OAAW,QAAO,EAAE,MAAM,OAAO,KAAK,GAAG,UAAU,MAAM;A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OAAO,UAAU,UAC9B,oBAAC,OAAI,WAAU,QAAO,IAAI,CAAC,UAAU,UAAU,OAAO,KAAK,GACxD,iBAAO,OACV;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAGO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AACF,GAGsB;AACpB,SACE,oBAAC,OAAI,IAAI,eACP,8BAAC,mBAAgB,MAAM,OAAO,MAAM,OAAc,GACpD;AAEJ;","names":[]}
@@ -20,13 +20,14 @@ function buildCategoryGroups(options) {
20
20
  });
21
21
  return [...groups.values(), ...orphans];
22
22
  }
23
+ function isLeafCategory(group) {
24
+ return group.subcategories.length === 0;
25
+ }
23
26
  function collectLeafIds(groups) {
24
- return groups.flatMap(
25
- (group) => group.subcategories.length > 0 ? group.subcategories.map((sub) => sub.id) : [group.category.id]
26
- );
27
+ return groups.flatMap((group) => leavesOf(group));
27
28
  }
28
29
  function leavesOf(group) {
29
- return group.subcategories.length > 0 ? group.subcategories.map((sub) => sub.id) : [group.category.id];
30
+ return isLeafCategory(group) ? [group.category.id] : group.subcategories.map((sub) => sub.id);
30
31
  }
31
32
  function categoryCheckState(group, selected) {
32
33
  const leaves = leavesOf(group);
@@ -108,6 +109,7 @@ function flattenRows(groups, isExpanded) {
108
109
  export {
109
110
  foldText,
110
111
  buildCategoryGroups,
112
+ isLeafCategory,
111
113
  collectLeafIds,
112
114
  leavesOf,
113
115
  categoryCheckState,
@@ -119,4 +121,4 @@ export {
119
121
  highlightSegments,
120
122
  flattenRows
121
123
  };
122
- //# sourceMappingURL=chunk-DVTCZR3K.js.map
124
+ //# sourceMappingURL=chunk-LR6MSKTT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/form/CategorySelect/category-tree.ts"],"sourcesContent":["import type {\n CategoryGroup,\n CategorySelectionChip,\n CategorySelectOption,\n} from './CategorySelect.types';\n\n/**\n * Fold a string to its comparison form: no diacritics, lower case.\n *\n * Portuguese category names are full of them (\"Águas\", \"Cápsulas\", \"Grãos\"), and\n * an admin typing \"agua\" or \"graos\" on a hurried phone keyboard means the same\n * thing. Comparing folded forms on both sides makes the search accent-blind in\n * both directions.\n */\nexport function foldText(text: string): string {\n return text\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase();\n}\n\n/**\n * Group a flat `parentId` list into top level + children, preserving input order.\n *\n * An option whose `parentId` names no top-level row is promoted to top level\n * rather than dropped — a category is never invisible just because its parent\n * was filtered out of the payload, or because the tree is deeper than two levels.\n */\nexport function buildCategoryGroups(options: CategorySelectOption[]): CategoryGroup[] {\n const roots = options.filter((option) => !option.parentId);\n const rootIds = new Set(roots.map((root) => root.id));\n const groups = new Map<string, CategoryGroup>(\n roots.map((root) => [root.id, { category: root, subcategories: [] }]),\n );\n const orphans: CategoryGroup[] = [];\n\n options.forEach((option) => {\n if (!option.parentId) return;\n const parent = groups.get(option.parentId);\n if (parent) {\n parent.subcategories.push(option);\n return;\n }\n if (!rootIds.has(option.id)) orphans.push({ category: option, subcategories: [] });\n });\n\n return [...groups.values(), ...orphans];\n}\n\n/**\n * Whether this category IS the leaf, because nothing sits under it.\n *\n * The leaf-only default makes a category a heading and the subcategory the thing\n * you pick — but a childless category has no subcategory to offer instead, so\n * that reading leaves it unpickable and the row does nothing at all. It is the\n * leaf, so it is selectable in its own right, whatever `allowParentSelection`\n * says. Everything below already agreed; only the rows and the activation did\n * not, which is what made a childless category unselectable on the estoque\n * filter while `Marcar tudo` could still select it.\n */\nexport function isLeafCategory(group: CategoryGroup): boolean {\n return group.subcategories.length === 0;\n}\n\n/** Every selectable leaf id across all groups, in display order. */\nexport function collectLeafIds(groups: CategoryGroup[]): string[] {\n return groups.flatMap((group) => leavesOf(group));\n}\n\n/** The leaves a category stands for — its subcategories, or itself when childless. */\nexport function leavesOf(group: CategoryGroup): string[] {\n return isLeafCategory(group) ? [group.category.id] : group.subcategories.map((sub) => sub.id);\n}\n\nexport type CategoryCheckState = 'off' | 'partial' | 'on';\n\n/** Whether none, some, or all of a category's leaves are selected. */\nexport function categoryCheckState(\n group: CategoryGroup,\n selected: ReadonlySet<string>,\n): CategoryCheckState {\n const leaves = leavesOf(group);\n const hits = leaves.filter((id) => selected.has(id)).length;\n if (hits === 0) return 'off';\n return hits === leaves.length ? 'on' : 'partial';\n}\n\n/** Select every leaf of a category, or clear them all when already complete. */\nexport function toggleCategoryLeaves(\n group: CategoryGroup,\n selected: ReadonlySet<string>,\n): Set<string> {\n const next = new Set(selected);\n const leaves = leavesOf(group);\n const turningOff = categoryCheckState(group, selected) === 'on';\n leaves.forEach((id) => (turningOff ? next.delete(id) : next.add(id)));\n return next;\n}\n\n/** Add an id when absent, remove it when present. */\nexport function toggleLeaf(id: string, selected: ReadonlySet<string>): Set<string> {\n const next = new Set(selected);\n if (!next.delete(id)) next.add(id);\n return next;\n}\n\n/**\n * Collapse a raw id set into the chips a human reads: a category that is fully\n * selected becomes ONE chip bearing the category's name, rather than one chip\n * per subcategory — \"Bebidas\" instead of six drinks.\n */\nexport function summarizeSelection(\n groups: CategoryGroup[],\n selected: ReadonlySet<string>,\n): CategorySelectionChip[] {\n return groups.flatMap((group): CategorySelectionChip[] => {\n const state = categoryCheckState(group, selected);\n if (state === 'off') return [];\n if (state === 'on') {\n return [{ id: group.category.id, label: group.category.name, whole: true }];\n }\n return group.subcategories\n .filter((sub) => selected.has(sub.id))\n .map((sub) => ({ id: sub.id, label: sub.name, whole: false }));\n });\n}\n\n/**\n * Drop the leaves a chip stands for. A `whole` chip removes the whole category;\n * any other chip removes just that leaf.\n */\nexport function removeChip(\n groups: CategoryGroup[],\n chipId: string,\n selected: ReadonlySet<string>,\n): Set<string> {\n const next = new Set(selected);\n const group = groups.find((candidate) => candidate.category.id === chipId);\n if (group) {\n leavesOf(group).forEach((id) => next.delete(id));\n return next;\n }\n next.delete(chipId);\n return next;\n}\n\n/**\n * Search across BOTH levels, keeping every hit under its parent.\n *\n * A category that matches keeps all of its subcategories, so \"Bebidas\" shows the\n * whole group. A category that does not match keeps only the subcategories that\n * do — the hit still arrives with its parent visible above it, which is the\n * context that tells \"Massas\" (mercearia) from \"Massas\" (pratos principais).\n */\nexport function filterCategoryGroups(groups: CategoryGroup[], query: string): CategoryGroup[] {\n const needle = foldText(query.trim());\n if (!needle) return groups;\n return groups.flatMap((group) => {\n if (foldText(group.category.name).includes(needle)) return [group];\n const subcategories = group.subcategories.filter((sub) =>\n foldText(sub.name).includes(needle),\n );\n return subcategories.length > 0 ? [{ category: group.category, subcategories }] : [];\n });\n}\n\n/** A run of text, flagged when it is the part that matched the query. */\ninterface HighlightSegment {\n text: string;\n match: boolean;\n}\n\n/**\n * Split a label around the query hit so the view can mark it.\n *\n * Slicing uses indices from the FOLDED text but cuts the ORIGINAL, which is safe\n * because folding is per-character here: NFD-stripping combining marks and\n * lower-casing both preserve offsets for the scripts these names use.\n */\nexport function highlightSegments(text: string, query: string): HighlightSegment[] {\n const needle = foldText(query.trim());\n if (!needle) return [{ text, match: false }];\n const at = foldText(text).indexOf(needle);\n if (at < 0) return [{ text, match: false }];\n return [\n { text: text.slice(0, at), match: false },\n { text: text.slice(at, at + needle.length), match: true },\n { text: text.slice(at + needle.length), match: false },\n ].filter((segment) => segment.text.length > 0);\n}\n\n/** A flattened row, so keyboard navigation can walk what is actually on screen. */\nexport interface CategoryRowRef {\n kind: 'category' | 'subcategory';\n id: string;\n /** Owning category id — lets ← jump from a subcategory back to its parent. */\n parentId?: string;\n}\n\n/** The visible rows, in order, honouring which categories are expanded. */\nexport function flattenRows(\n groups: CategoryGroup[],\n isExpanded: (categoryId: string) => boolean,\n): CategoryRowRef[] {\n return groups.flatMap((group) => {\n const head: CategoryRowRef = { kind: 'category', id: group.category.id };\n if (!isExpanded(group.category.id)) return [head];\n return [\n head,\n ...group.subcategories.map(\n (sub): CategoryRowRef => ({\n kind: 'subcategory',\n id: sub.id,\n parentId: group.category.id,\n }),\n ),\n ];\n });\n}\n"],"mappings":";AAcO,SAAS,SAAS,MAAsB;AAC7C,SAA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;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  DisplayTab,
6
6
  SortTab
7
- } from "./chunk-F6FT2LIR.js";
7
+ } from "./chunk-YRFKPRV2.js";
8
8
  import {
9
9
  ViewActions,
10
10
  ViewFooter,
@@ -261,4 +261,4 @@ function DataViewsDisplayPanel({
261
261
  export {
262
262
  DataViewsDisplayPanel
263
263
  };
264
- //# sourceMappingURL=chunk-USBTXEBG.js.map
264
+ //# sourceMappingURL=chunk-P55UFXYW.js.map
@@ -53,4 +53,4 @@ export {
53
53
  DATA_VIEWS_LAYOUTS,
54
54
  toSavedViewSummary
55
55
  };
56
- //# sourceMappingURL=chunk-C6ATAHBX.js.map
56
+ //# sourceMappingURL=chunk-QEPGWTJT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/data-display/DataViews/data-views-types.ts"],"sourcesContent":["import type { GridColumn, GridSort } from \"../DataGrid\";\nimport type { DropdownMenuItem } from \"../../navigation/DropdownMenu\";\n// A re-export does not bring the name into local scope, and the state/query\n// types below are written in terms of it.\nimport type { RangeValue } from \"./data-views-range-types\";\n\n/**\n * Shared types for the reusable admin \"DataViews\" table (FUT-88): a filter bar\n * (search-across-all + typed multi-select pills + column visibility) whose full\n * state — filters + sort + visible columns — a saved view (FUT-89) can capture\n * and restore. Each table declares its own columns + filter fields.\n */\n\n/**\n * A single, reusable row action. ONE definition drives BOTH the per-row \"⋮\"\n * kebab menu and the bulk-actions menu (tabwoah model): `onSelect` receives the\n * affected rows — `[row]` from a kebab, the whole selection from the bulk menu.\n * Single-item-only actions (e.g. \"Editar\") set `bulk: false` so they never\n * appear in the bulk menu.\n */\nexport interface RowAction<T extends Record<string, unknown>> {\n /** Stable id (also the `data-testid` suffix). */\n id: string;\n /** Menu label. In the kebab, `rowLabel` overrides it per row when provided. */\n label: string;\n /** Menu-item colour (e.g. `\"error\"` for destructive). */\n color?: DropdownMenuItem[\"color\"];\n /**\n * Runs on the affected rows: `[row]` from the kebab, all selected from bulk.\n * May be async — the bulk menu awaits it and only clears the selection once it\n * settles (keeping the selection on failure so the user can retry).\n */\n onSelect: (rows: T[]) => void | Promise<void>;\n /** Include in the bulk menu (2+ selected). Defaults to `true`. */\n bulk?: boolean;\n /** Include in the per-row kebab. Defaults to `true`. */\n row?: boolean;\n /** Per-row kebab label (e.g. `row.active ? \"Inativar\" : \"Ativar\"`). */\n rowLabel?: (row: T) => string;\n /**\n * Per-row applicability (e.g. state-machine guards). `false` hides the\n * kebab item for that row; in bulk the action runs only on the passing\n * rows and is dropped when none pass. Defaults to applicable.\n */\n isVisible?: (row: T) => boolean;\n}\n\n/** Selection state handed to a card renderer so it can drive its own checkbox. */\nexport interface DataViewCardSelection {\n selected: boolean;\n onToggleSelect: () => void;\n /**\n * Card SIZE multiplier from the toolbar zoom slider. The grid sizes the card's\n * width to `base × scale`; a card passes this to {@link BaseCard} `scale` so its\n * padding + typography grow by the same factor — the whole card scales together\n * (scale 2 → ~2× size). The proportion (aspect ratio) stays constant.\n */\n scale: number;\n}\n\n/**\n * The fixed proportions a {@link BaseCard} tile can take. The tile keeps this\n * ratio and grows in BOTH width and height as the zoom slider widens its grid\n * track, so a grid of cards stays visually uniform.\n */\nexport type CardAspectRatio = \"1:1\" | \"4:3\" | \"16:9\" | \"9:16\" | \"3:4\" | \"3:1\";\n\n/** Numeric width/height factor for each {@link CardAspectRatio} (CSS `aspect-ratio`). */\nexport const CARD_ASPECT_RATIOS: Record<CardAspectRatio, number> = {\n \"1:1\": 1,\n \"4:3\": 4 / 3,\n \"16:9\": 16 / 9,\n \"9:16\": 9 / 16,\n \"3:4\": 3 / 4,\n /**\n * The BANNER tile: too short for media, sized for two lines of text.\n *\n * Every other ratio here is picture-shaped, because they were added for cards\n * built around a thumbnail. A card whose subject is a NAME and a NUMBER — a\n * cart, an order, anything triaged rather than browsed — spends most of a 4:3\n * tile on an icon that repeats down the whole grid and says nothing.\n */\n \"3:1\": 3,\n};\n\n/** One selectable value inside a filter pill. */\nexport interface FilterOption {\n value: string;\n label: string;\n /**\n * Parent option's `value`, for a hierarchical field (`control: \"category\"`).\n * Ignored by the flat controls, so one option list serves both.\n */\n parentId?: string | null;\n}\n\n/** A typed, multi-select filter pill's configuration for a table. */\nexport interface FilterFieldConfig<T extends Record<string, unknown>> {\n /** Stable id; also the default row key when no `accessor` is given. */\n id: string;\n label: string;\n options: FilterOption[];\n /**\n * How the field renders in the filter panel. `checkboxes` (default) is best for\n * a few fixed options; `multiselect` is a compact dropdown for long option\n * lists; `category` is the hierarchical picker, for an option set that nests\n * via {@link FilterOption.parentId} — it renders parents as headings and\n * their children as the selectable rows, rather than flattening the tree into\n * one indistinguishable list.\n */\n control?: \"checkboxes\" | \"multiselect\" | \"category\";\n /**\n * Lets a `control: \"category\"` pill select a PARENT category, not just its\n * children. Off by default, which keeps the leaf-only reading: the parent is\n * a heading and its subcategories are the rows you tick.\n *\n * Turn it on where \"the whole category\" is a filter a user would reach for —\n * selecting a parent then selects every subcategory under it, and the chip\n * tray collapses that back to one chip bearing the category's name.\n *\n * A category with NO children is selectable either way: it is itself the\n * leaf, so the flag has nothing to gate there.\n */\n allowParentSelection?: boolean;\n /**\n * Forces this filter to render as a searchable multi-select dropdown with the\n * search box always shown, regardless of how many options are currently\n * loaded. Use it when the option set can grow unbounded (e.g. a filter backed\n * by a relation such as Roles or Categories). Omit it for a closed value set\n * (an enum), which keeps the plain checkbox / \"search only when long\"\n * behavior.\n */\n searchEnabled?: boolean;\n /**\n * Reads the row's value(s) for this field. A row matches the pill when any of\n * its values is selected. Defaults to `String(row[id])`.\n */\n accessor?: (row: T) => string | string[];\n}\n\n/**\n * The range types live in `data-views-range-types` (this file outgrew the\n * size gate); they are re-exported here so `data-views-types` stays the one\n * name every consumer imports the model from.\n */\nexport type {\n DayRangeFieldConfig,\n NumberRangeFieldConfig,\n RangeFieldConfig,\n RangeFieldKind,\n RangePreset,\n RangeValue,\n} from \"./data-views-range-types\";\n\n/** A grid column that can join the search scan and the column-visibility menu. */\nexport interface DataViewColumn<T extends Record<string, unknown>> extends GridColumn<T> {\n /** Included in \"search across all columns\" (needs a resolvable value). */\n searchable?: boolean;\n /** Toggleable in the column-visibility menu. Defaults to true; set false for\n * structural columns (image thumbnail, actions kebab) that must always show. */\n hideable?: boolean;\n}\n\n/**\n * The DataViews layout (view type): the dense \"Tabela\" grid, the \"Grade\" of\n * cards, the \"Lista\" of full-width rows, or the \"Quadro\" board of state columns.\n * Lives with the state types rather than with the toggle because a saved view\n * CAPTURES it — see {@link DataViewState.layout}.\n */\nexport type DataViewsLayout = \"cards\" | \"list\" | \"board\" | \"table\";\n\n/** The full, serializable state a view captures. */\nexport interface DataViewState {\n /** Free text matched across every `searchable` column. */\n search: string;\n /** fieldId → selected option values (empty/absent = no constraint). */\n pills: Record<string, string[]>;\n /** fieldId → selected numeric range (min/max). Absent/empty = no constraint. */\n ranges?: Record<string, RangeValue>;\n sortBy: GridSort[];\n /** Column ids kept visible; a hideable column not listed here is hidden. */\n visibleColumns: string[];\n /**\n * Column ids in READING ORDER. Absent ⇒ the order the table declared them in.\n *\n * Order is view state for the same reason visibility is: reordering columns is\n * an operator deciding what to read FIRST, and a saved view that restored the\n * columns but not their order would restore half a decision. Ids the table no\n * longer declares are ignored at render, and ids missing from a stale list\n * fall in after it — so a column added since the view was saved appears rather\n * than disappearing.\n */\n order?: string[];\n /**\n * The active SCOPE id — the page-level partition the scope tabs select (see\n * `ScopeConfig`). Optional, so a table that declares no scopes is untouched\n * and no view persisted before scopes existed breaks.\n *\n * Stored raw and RESOLVED at read time: the declared scopes change underneath\n * a saved view, and a view naming a scope that has since been removed must\n * fall back at render rather than break.\n */\n scope?: string;\n /**\n * The layout the view was saved in. Optional — absent means \"whatever the user\n * is currently using\", which is the pre-existing behaviour.\n *\n * A LAYOUT FALLBACK IS NOT A LAYOUT CHANGE: a table rendered as stacked rows\n * on a phone still has `\"table\"` stored here, so the view round-trips the\n * stored layout regardless of the device that opened it.\n */\n layout?: DataViewsLayout;\n}\n\n/** A pristine view state showing every given column and no filters/sort. */\nexport function emptyViewState(visibleColumns: string[]): DataViewState {\n return { search: \"\", pills: {}, ranges: {}, sortBy: [], visibleColumns };\n}\n\n/**\n * The URL-driven slice of {@link DataViewState} — the controls a server-mode host\n * mirrors from the address bar (search / pills / ranges / sort), WITHOUT\n * `visibleColumns`. Supplying it re-applies those controls when its reference\n * changes (e.g. browser back/forward or a deep-link on the same route), merging\n * over the current state so a user's show/hide column choices are preserved —\n * unlike `appliedState`, which fully replaces the state to apply a saved view.\n */\nexport type DataViewSyncState = Pick<\n DataViewState,\n \"search\" | \"pills\" | \"ranges\" | \"sortBy\" | \"scope\"\n>;\n\n/**\n * The query a SERVER-mode table emits whenever its filter/sort/page changes\n * (FUT-180). The host translates this into a backend request (see\n * `@12-apps/shared-helpers/search`) — in server mode the grid never filters,\n * sorts, or paginates in the browser; it renders exactly the page the server\n * returned. `page` is 1-based to match the backend contract.\n */\nexport interface DataViewQuery {\n search: string;\n pills: Record<string, string[]>;\n ranges: Record<string, RangeValue>;\n sortBy: GridSort[];\n /**\n * The RESOLVED active scope (see `resolveScope`), when the table declares\n * scopes. The KEY IS ABSENT for a table that declares none — not present-and-\n * undefined — so a host that never opted in sees a byte-identical query.\n *\n * It carries the resolved id, never the stored one: a deep link or a saved\n * view naming a scope the table no longer declares must not put that id on the\n * wire, where the backend would reject it and replace the page with an error.\n */\n scope?: string;\n page: number;\n pageSize: number;\n}\n\n/**\n * Server-mode wiring for a DataViews table. Its PRESENCE flips the table from\n * in-browser filtering/sorting/pagination to backend-driven: the rows handed in\n * are already the current page, `totalCount` is the unpaginated total, and\n * `onQueryChange` fires (search debounced by the host) whenever the user changes\n * a filter, the sort, or the page. This is the ONLY way an admin list should run\n * (see the app-side `DataViewsTable` wrapper, which requires it).\n */\nexport interface DataViewServer {\n /** Total matched rows across all pages (drives the counter + page count). */\n totalCount: number;\n /** Current 1-based page. */\n page: number;\n /** Rows per page. */\n pageSize: number;\n /** Fired when the effective query changes; the host re-fetches the page. */\n onQueryChange: (query: DataViewQuery) => void;\n /**\n * Per-scope totals for the scope tabs: `scopeId → count`. THE ONLY PIECE OF\n * THIS CONTRACT THAT CANNOT BE DONE CLIENT-SIDE — a count computed from the\n * loaded page is wrong the moment there is a second page, which is the\n * concrete bug scopes exist to fix.\n *\n * Compute it over search + pills + ranges while IGNORING the active scope.\n * Computed WITH the scope applied, every inactive tab reads zero, which is\n * worse than no counts at all.\n *\n * Omit it and the tabs render with no numbers. Nothing is ever invented from\n * the loaded rows to fill the gap.\n */\n scopeCounts?: Record<string, number>;\n}\n\n/**\n * Coerce an opaque persisted state (a saved view's JSON) into a valid\n * DataViewState, filling any missing part with a sane default. Guards against\n * legacy/older shapes so applying a saved view never renders an empty grid.\n */\nexport function coerceViewState(raw: unknown, allColumnIds: string[]): DataViewState {\n const value = (raw ?? {}) as Partial<DataViewState>;\n return {\n search: typeof value.search === \"string\" ? value.search : \"\",\n pills: asRecord<string[]>(value.pills),\n ranges: asRecord<RangeValue>(value.ranges),\n sortBy: Array.isArray(value.sortBy) ? value.sortBy : [],\n visibleColumns: Array.isArray(value.visibleColumns) ? value.visibleColumns : allColumnIds,\n order: Array.isArray(value.order) ? value.order : undefined,\n // Carried through UNVALIDATED against the declared scopes on purpose: a view\n // written before scopes existed has none (⇒ undefined ⇒ the first declared\n // scope at render), and one naming a since-removed scope keeps its stored id\n // here and falls back at READ time. Resolving here would rewrite the view.\n scope: typeof value.scope === \"string\" ? value.scope : undefined,\n layout: isLayout(value.layout) ? value.layout : undefined,\n };\n}\n\n/** Every layout this build knows how to render — the guard's single source. */\nexport const DATA_VIEWS_LAYOUTS: readonly DataViewsLayout[] = [\"cards\", \"list\", \"board\", \"table\"];\n\n/** Is this a layout this build knows how to render? Guards persisted JSON. */\nfunction isLayout(value: unknown): value is DataViewsLayout {\n return DATA_VIEWS_LAYOUTS.includes(value as DataViewsLayout);\n}\n\n/** A persisted map, or an empty one — persisted JSON can hold anything. */\nfunction asRecord<V>(value: unknown): Record<string, V> {\n return value !== null && typeof value === \"object\" ? (value as Record<string, V>) : {};\n}\n\n/** A saved view as consumed by the DataViews UI (FUT-89), with ownership flag. */\nexport interface SavedViewSummary {\n id: string;\n name: string;\n description: string | null;\n state: DataViewState;\n shared: boolean;\n pinned: boolean;\n isDefault: boolean;\n /** True when the current user owns the view (may edit/delete/pin/share it). */\n isOwner: boolean;\n}\n\n/** A saved-view repository record (opaque `state`), as returned to server pages. */\ninterface SavedViewRecordLike {\n id: string;\n name: string;\n description: string | null;\n state: unknown;\n shared: boolean;\n pinned: boolean;\n isDefault: boolean;\n isOwner: boolean;\n}\n\n/** Map a repository record to the client summary (opaque state → DataViewState). */\nexport function toSavedViewSummary(record: SavedViewRecordLike): SavedViewSummary {\n return { ...record, state: (record.state ?? {}) as DataViewState };\n}\n\n/**\n * Dependency-injection contracts for the framework-agnostic DataViewsTableBase:\n * the host app supplies saved-view persistence + router side-effects so the ui\n * component imports neither a backend (server actions) nor a framework router.\n */\n\n/** A saved view's editable fields, as the host persists them. */\nexport interface DataViewSaveInput {\n name: string;\n description: string;\n state: DataViewState;\n shared: boolean;\n pinned: boolean;\n isDefault: boolean;\n}\n\n/** Result of a persistence call — mirrors the app's `Result` without importing it. */\nexport type DataViewMutationResult = { ok: true } | { ok: false; error: string };\n\n/** Injected saved-view persistence (create/update/delete), wired by the host. */\nexport interface DataViewPersistence {\n create: (input: DataViewSaveInput) => Promise<DataViewMutationResult>;\n update: (id: string, input: DataViewSaveInput) => Promise<DataViewMutationResult>;\n remove: (id: string) => Promise<DataViewMutationResult>;\n}\n\n/** Injected router side-effects: sync the `?view=` param and re-fetch on change. */\nexport interface DataViewRouter {\n syncViewParam: (viewId: string | null) => void;\n refresh: () => void;\n}\n"],"mappings":";AAoEO,IAAM,qBAAsD;AAAA,EACjE,OAAO;AAAA,EACP,OAAO,IAAI;AAAA,EACX,QAAQ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4
4
  import {
5
5
  CARD_RADIUS,
6
6
  cardSurfaceStyles,
@@ -16,10 +16,10 @@ import {
16
16
  RAIL_GAP,
17
17
  railsTemplateFor,
18
18
  useListRails
19
- } from "./chunk-T4JGNZAR.js";
19
+ } from "./chunk-YQJMVUBG.js";
20
20
  import {
21
21
  DENSITY_ROW_PADDING
22
- } from "./chunk-HVIB6WMD.js";
22
+ } from "./chunk-ZIPCGZA3.js";
23
23
 
24
24
  // src/components/data-display/DataViews/base-list-card-geometry.tsx
25
25
  import { useTheme } from "@mui/material/styles/index.js";
@@ -181,4 +181,4 @@ export {
181
181
  actionProps,
182
182
  rowStyles
183
183
  };
184
- //# sourceMappingURL=chunk-6UGRH32J.js.map
184
+ //# sourceMappingURL=chunk-QRKBBOSY.js.map
@@ -22,7 +22,7 @@ import {
22
22
  } from "./chunk-5VZPVDUF.js";
23
23
  import {
24
24
  emptyViewState
25
- } from "./chunk-C6ATAHBX.js";
25
+ } from "./chunk-QEPGWTJT.js";
26
26
 
27
27
  // src/components/data-display/DataViews/use-data-views-state.ts
28
28
  import { useEffect, useMemo, useRef, useState } from "react";
@@ -174,4 +174,4 @@ function useDataViewsState({
174
174
  export {
175
175
  useDataViewsState
176
176
  };
177
- //# sourceMappingURL=chunk-TY6CTYCF.js.map
177
+ //# sourceMappingURL=chunk-TOUSE63W.js.map
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  FilterDialog,
3
3
  GridFilterPanel
4
- } from "./chunk-NXTKZSMT.js";
4
+ } from "./chunk-IN642YHK.js";
5
5
  import {
6
6
  DataViewsEmpty
7
7
  } from "./chunk-S7CAXRRP.js";
8
8
  import {
9
9
  InlineFilterControls
10
- } from "./chunk-T6V3DKJ5.js";
10
+ } from "./chunk-WLCVOQCJ.js";
11
11
  import {
12
12
  GridMain
13
- } from "./chunk-QFHUWD3C.js";
13
+ } from "./chunk-XIYPVNEB.js";
14
14
  import {
15
15
  DataViewsPagination
16
16
  } from "./chunk-VR5HDUBK.js";
@@ -20,14 +20,14 @@ import {
20
20
  } from "./chunk-TQ6FPOPD.js";
21
21
  import {
22
22
  ScopeTabsSlot
23
- } from "./chunk-CY5X3HNQ.js";
23
+ } from "./chunk-E2H7MBPM.js";
24
24
  import {
25
25
  ShellToolbar
26
- } from "./chunk-XQZOMXP3.js";
26
+ } from "./chunk-FZHKKLOO.js";
27
27
  import {
28
28
  DataViewsLayoutProvider,
29
29
  useDataViewsLayout
30
- } from "./chunk-HVIB6WMD.js";
30
+ } from "./chunk-ZIPCGZA3.js";
31
31
  import {
32
32
  togglePillValues
33
33
  } from "./chunk-5VZPVDUF.js";
@@ -260,4 +260,4 @@ function GridShell(props) {
260
260
  export {
261
261
  GridShell
262
262
  };
263
- //# sourceMappingURL=chunk-TDSRBCBG.js.map
263
+ //# sourceMappingURL=chunk-W3UM2KEW.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  coerceViewState,
6
6
  emptyViewState
7
- } from "./chunk-C6ATAHBX.js";
7
+ } from "./chunk-QEPGWTJT.js";
8
8
  import {
9
9
  useDataViewsCopy
10
10
  } from "./chunk-KHG57NAE.js";
@@ -96,4 +96,4 @@ function useSavedViewsController(persistence, router, columnIds, views, initialV
96
96
  export {
97
97
  useSavedViewsController
98
98
  };
99
- //# sourceMappingURL=chunk-6IAQGSXD.js.map
99
+ //# sourceMappingURL=chunk-WIEXYVMU.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-NQCYVYP3.js";
4
4
  import {
5
5
  DataViewsDisplayPanel
6
- } from "./chunk-USBTXEBG.js";
6
+ } from "./chunk-P55UFXYW.js";
7
7
  import {
8
8
  renderBulkActions
9
9
  } from "./chunk-5VZPVDUF.js";
@@ -132,4 +132,4 @@ function GridToolbar(props) {
132
132
  export {
133
133
  GridToolbar
134
134
  };
135
- //# sourceMappingURL=chunk-GQTBWJYK.js.map
135
+ //# sourceMappingURL=chunk-WKRSVGT6.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-5WNQJ5KS.js";
5
5
  import {
6
6
  PillControl
7
- } from "./chunk-KWUQZDPL.js";
7
+ } from "./chunk-ECIGNYSI.js";
8
8
  import {
9
9
  MoreFilters
10
10
  } from "./chunk-ZHPKFV7Y.js";
@@ -220,4 +220,4 @@ function FilterSlots({
220
220
  export {
221
221
  InlineFilterControls
222
222
  };
223
- //# sourceMappingURL=chunk-T6V3DKJ5.js.map
223
+ //# sourceMappingURL=chunk-WLCVOQCJ.js.map
@@ -1,3 +1,7 @@
1
+ import {
2
+ isLeafCategory
3
+ } from "./chunk-LR6MSKTT.js";
4
+
1
5
  // src/components/form/CategorySelect/category-keyboard.ts
2
6
  function activeRow(context) {
3
7
  return context.activeIndex >= 0 ? context.rows[context.activeIndex] : void 0;
@@ -29,29 +33,41 @@ function handleLeft(context) {
29
33
  );
30
34
  if (parentIndex >= 0) context.setActiveIndex(parentIndex);
31
35
  }
32
- function handleSpace(context) {
33
- const row = activeRow(context);
34
- if (!row) return;
36
+ function activateCategoryRow(context, categoryId) {
37
+ const group = groupOf(context, categoryId);
38
+ if (!group) return;
39
+ if (!context.allowParentSelection && !isLeafCategory(group)) {
40
+ context.toggleExpanded(categoryId);
41
+ return;
42
+ }
35
43
  if (context.single) {
36
- context.pick(row.id);
44
+ context.pick(categoryId);
37
45
  return;
38
46
  }
47
+ context.toggleCategory(group);
48
+ }
49
+ function handleSpace(context) {
50
+ const row = activeRow(context);
51
+ if (!row) return;
39
52
  if (row.kind === "subcategory") {
40
- context.toggleSubcategory(row.id);
53
+ if (context.single) context.pick(row.id);
54
+ else context.toggleSubcategory(row.id);
41
55
  return;
42
56
  }
43
- const group = groupOf(context, row.id);
44
- if (!group) return;
45
- if (context.allowParentSelection) context.toggleCategory(group);
46
- else context.toggleExpanded(row.id);
57
+ activateCategoryRow(context, row.id);
47
58
  }
48
59
  function handleEnter(context) {
49
60
  const row = activeRow(context);
50
- if (context.single) {
51
- if (row) context.pick(row.id);
61
+ if (!context.single) {
62
+ context.commit();
63
+ return;
64
+ }
65
+ if (!row) return;
66
+ if (row.kind === "subcategory") {
67
+ context.pick(row.id);
52
68
  return;
53
69
  }
54
- context.commit();
70
+ activateCategoryRow(context, row.id);
55
71
  }
56
72
  var HANDLERS = {
57
73
  ArrowDown: (context) => moveCursor(context, 1),
@@ -74,4 +90,4 @@ function handleCategoryKeyDown(key, editingSearchText, context) {
74
90
  export {
75
91
  handleCategoryKeyDown
76
92
  };
77
- //# sourceMappingURL=chunk-GCC66ZSD.js.map
93
+ //# sourceMappingURL=chunk-WWM2YTW4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/form/CategorySelect/category-keyboard.ts"],"sourcesContent":["import { isLeafCategory, type CategoryRowRef } from './category-tree';\nimport type { CategoryGroup } from './CategorySelect.types';\n\n/** What a key handler is allowed to do to the panel. */\nexport interface CategoryKeyContext {\n rows: CategoryRowRef[];\n activeIndex: number;\n groups: CategoryGroup[];\n /** Single-select mode picks on Enter/Space instead of toggling a draft. */\n single: boolean;\n /** Categories are headings, not checkboxes, unless parents are selectable. */\n allowParentSelection: boolean;\n setActiveIndex: (next: number) => void;\n toggleExpanded: (categoryId: string) => void;\n expand: (categoryId: string) => void;\n collapse: (categoryId: string) => void;\n toggleCategory: (group: CategoryGroup) => void;\n toggleSubcategory: (id: string) => void;\n commit: () => void;\n cancel: () => void;\n pick: (id: string) => void;\n}\n\n/** The row under the keyboard cursor, if the cursor is on one. */\nfunction activeRow(context: CategoryKeyContext): CategoryRowRef | undefined {\n return context.activeIndex >= 0 ? context.rows[context.activeIndex] : undefined;\n}\n\nfunction groupOf(context: CategoryKeyContext, id: string): CategoryGroup | undefined {\n return context.groups.find((group) => group.category.id === id);\n}\n\nfunction moveCursor(context: CategoryKeyContext, delta: number): void {\n const { rows, activeIndex } = context;\n if (rows.length === 0) return;\n const next =\n delta > 0\n ? Math.min(rows.length - 1, activeIndex + 1)\n : Math.max(0, activeIndex - 1);\n context.setActiveIndex(next);\n}\n\n/** → opens a category. On a subcategory it is a no-op: there is nothing deeper. */\nfunction handleRight(context: CategoryKeyContext): void {\n const row = activeRow(context);\n if (row?.kind === 'category') context.expand(row.id);\n}\n\n/** ← collapses a category, or walks a subcategory back up to its parent. */\nfunction handleLeft(context: CategoryKeyContext): void {\n const row = activeRow(context);\n if (!row) return;\n if (row.kind === 'category') {\n context.collapse(row.id);\n return;\n }\n if (!row.parentId) return;\n context.collapse(row.parentId);\n const parentIndex = context.rows.findIndex(\n (candidate) => candidate.kind === 'category' && candidate.id === row.parentId,\n );\n if (parentIndex >= 0) context.setActiveIndex(parentIndex);\n}\n\n/**\n * What a category row does when it is activated — the one answer the click, the\n * Space key and (in single-select) Enter all take, so the three cannot disagree\n * about a row the way they did over a childless category.\n *\n * A category that is only a HEADING expands instead of marking: the row has no\n * control, so \"mark\" has nothing to mean there. A childless category is not a\n * heading — it is the leaf — so it marks.\n */\nfunction activateCategoryRow(context: CategoryKeyContext, categoryId: string): void {\n const group = groupOf(context, categoryId);\n if (!group) return;\n if (!context.allowParentSelection && !isLeafCategory(group)) {\n context.toggleExpanded(categoryId);\n return;\n }\n if (context.single) {\n context.pick(categoryId);\n return;\n }\n context.toggleCategory(group);\n}\n\n/** Space marks the row under the cursor. */\nfunction handleSpace(context: CategoryKeyContext): void {\n const row = activeRow(context);\n if (!row) return;\n if (row.kind === 'subcategory') {\n if (context.single) context.pick(row.id);\n else context.toggleSubcategory(row.id);\n return;\n }\n activateCategoryRow(context, row.id);\n}\n\nfunction handleEnter(context: CategoryKeyContext): void {\n const row = activeRow(context);\n if (!context.single) {\n context.commit();\n return;\n }\n if (!row) return;\n if (row.kind === 'subcategory') {\n context.pick(row.id);\n return;\n }\n activateCategoryRow(context, row.id);\n}\n\n/** Key → behaviour. A map keeps this dispatch flat instead of a long if-chain. */\nconst HANDLERS: Record<string, (context: CategoryKeyContext) => void> = {\n ArrowDown: (context) => moveCursor(context, 1),\n ArrowUp: (context) => moveCursor(context, -1),\n ArrowRight: handleRight,\n ArrowLeft: handleLeft,\n ' ': handleSpace,\n Enter: handleEnter,\n Escape: (context) => context.cancel(),\n};\n\n/**\n * Keys the SEARCH BOX has a claim on: Space types a space, and the horizontal\n * arrows move the caret.\n *\n * They are only yielded while the field actually holds text. The panel opens\n * with focus in an EMPTY search box, so yielding unconditionally — as the\n * prototype does — would make Space and ←/→ dead on arrival for anyone driving\n * the tree from the keyboard, which is most of the point of having it. With no\n * text there is no caret to move and no word to space, so the tree takes them;\n * type one character and they revert to the field.\n */\nconst TEXT_ENTRY_KEYS = new Set([' ', 'ArrowLeft', 'ArrowRight']);\n\n/**\n * Drive the tree from the keyboard.\n *\n * Returns `true` when the key was consumed, so the caller can `preventDefault`\n * only for keys this actually handled — an unhandled key must still reach the\n * search input untouched.\n */\nexport function handleCategoryKeyDown(\n key: string,\n editingSearchText: boolean,\n context: CategoryKeyContext,\n): boolean {\n if (editingSearchText && TEXT_ENTRY_KEYS.has(key)) return false;\n const handler = HANDLERS[key];\n if (!handler) return false;\n handler(context);\n return true;\n}\n"],"mappings":";;;;;AAwBA,SAAS,UAAU,SAAyD;AAC1E,SAAO,QAAQ,eAAe,IAAI,QAAQ,KAAK,QAAQ,WAAW,IAAI;AACxE;AAEA,SAAS,QAAQ,SAA6B,IAAuC;AACnF,SAAO,QAAQ,OAAO,KAAK,CAAC,UAAU,MAAM,SAAS,OAAO,EAAE;AAChE;AAEA,SAAS,WAAW,SAA6B,OAAqB;AACpE,QAAM,EAAE,MAAM,YAAY,IAAI;AAC9B,MAAI,KAAK,WAAW,EAAG;AACvB,QAAM,OACJ,QAAQ,IACJ,KAAK,IAAI,KAAK,SAAS,GAAG,cAAc,CAAC,IACzC,KAAK,IAAI,GAAG,cAAc,CAAC;AACjC,UAAQ,eAAe,IAAI;AAC7B;AAGA,SAAS,YAAY,SAAmC;AACtD,QAAM,MAAM,UAAU,OAAO;AAC7B,MAAI,KAAK,SAAS,WAAY,SAAQ,OAAO,IAAI,EAAE;AACrD;AAGA,SAAS,WAAW,SAAmC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C;AAAA,EAC7C,SAAS,CAAC,YAAY,WAAW,SAAS,EAAE;AAAA,EAC5C,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ,CAAC,YAAY,QAAQ,OAAO;AACtC;AAaA,IAAM,kBAAkB,oBAAI,IAAI,CAAC,KAAK,aAAa,YAAY,CAAC;AASzD,SAAS,sBACd,KACA,mBACA,SACS;AACT,MAAI,qBAAqB,gBAAgB,IAAI,GAAG,EAAG,QAAO;AAC1D,QAAM,UAAU,SAAS,GAAG;AAC5B,MAAI,CAAC,QAAS,QAAO;AACrB,UAAQ,OAAO;AACf,SAAO;AACT;","names":[]}
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-JCJGJX7V.js";
12
12
  import {
13
13
  CARD_ASPECT_RATIOS
14
- } from "./chunk-C6ATAHBX.js";
14
+ } from "./chunk-QEPGWTJT.js";
15
15
  import {
16
16
  useDataViewsCopy
17
17
  } from "./chunk-KHG57NAE.js";
@@ -263,4 +263,4 @@ function BaseCard(props) {
263
263
  export {
264
264
  BaseCard
265
265
  };
266
- //# sourceMappingURL=chunk-ZBYWGL5G.js.map
266
+ //# sourceMappingURL=chunk-WXHJG2UU.js.map
@@ -6,14 +6,14 @@ import {
6
6
  } from "./chunk-2I5B5NNT.js";
7
7
  import {
8
8
  ListCardGroup
9
- } from "./chunk-T4JGNZAR.js";
9
+ } from "./chunk-YQJMVUBG.js";
10
10
  import {
11
11
  DENSITY_BOARD_SCALE,
12
12
  DENSITY_ROW_PADDING,
13
13
  cardScaleForZoom,
14
14
  cardTargetWidthFor,
15
15
  useDataViewsLayout
16
- } from "./chunk-HVIB6WMD.js";
16
+ } from "./chunk-ZIPCGZA3.js";
17
17
  import {
18
18
  cardGridTracks
19
19
  } from "./chunk-5VZPVDUF.js";
@@ -264,4 +264,4 @@ function GridMain(props) {
264
264
  export {
265
265
  GridMain
266
266
  };
267
- //# sourceMappingURL=chunk-QFHUWD3C.js.map
267
+ //# sourceMappingURL=chunk-XIYPVNEB.js.map
@@ -8,13 +8,13 @@ import {
8
8
  metaShape,
9
9
  rowStyles,
10
10
  useRowShell
11
- } from "./chunk-6UGRH32J.js";
11
+ } from "./chunk-QRKBBOSY.js";
12
12
  import {
13
13
  ListCardActions,
14
14
  ListCardCaption,
15
15
  ListCardMeta,
16
16
  ListCardTail
17
- } from "./chunk-Q5GXVDXL.js";
17
+ } from "./chunk-ZQPG57GA.js";
18
18
  import {
19
19
  useDisclosure
20
20
  } from "./chunk-2JCRNWHE.js";
@@ -23,7 +23,7 @@ import {
23
23
  } from "./chunk-JCJGJX7V.js";
24
24
  import {
25
25
  cellRailsTemplate
26
- } from "./chunk-T4JGNZAR.js";
26
+ } from "./chunk-YQJMVUBG.js";
27
27
  import {
28
28
  ListCardCells,
29
29
  cellTracks,
@@ -179,4 +179,4 @@ function BaseListCard(props) {
179
179
  export {
180
180
  BaseListCard
181
181
  };
182
- //# sourceMappingURL=chunk-N7SBWD2V.js.map
182
+ //# sourceMappingURL=chunk-XYRS4JOF.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-6VP2L3DJ.js";
5
5
  import {
6
6
  DENSITY_ROW_PADDING
7
- } from "./chunk-HVIB6WMD.js";
7
+ } from "./chunk-ZIPCGZA3.js";
8
8
  import {
9
9
  default as default2
10
10
  } from "./chunk-6DPAWXZ3.js";
@@ -129,4 +129,4 @@ export {
129
129
  cellRailCount,
130
130
  ListCardGroup
131
131
  };
132
- //# sourceMappingURL=chunk-T4JGNZAR.js.map
132
+ //# sourceMappingURL=chunk-YQJMVUBG.js.map
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-SNR537TI.js";
9
9
  import {
10
10
  useDataViewsLayout
11
- } from "./chunk-HVIB6WMD.js";
11
+ } from "./chunk-ZIPCGZA3.js";
12
12
  import {
13
13
  useDataViewsCopy
14
14
  } from "./chunk-KHG57NAE.js";
@@ -243,4 +243,4 @@ export {
243
243
  SortTab,
244
244
  DisplayTab
245
245
  };
246
- //# sourceMappingURL=chunk-F6FT2LIR.js.map
246
+ //# sourceMappingURL=chunk-YRFKPRV2.js.map