@12-apps/ui 6.12.1 → 6.13.1

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 (137) 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-6UGRH32J.js → chunk-4KSOSI3U.js} +4 -4
  36. package/dist/{chunk-IKBQ7CS2.js → chunk-56SMIHWE.js} +2 -2
  37. package/dist/{chunk-LWYXMCX6.js → chunk-5ZZPQ3MT.js} +4 -4
  38. package/dist/{chunk-ZBYWGL5G.js → chunk-6U7NA74A.js} +2 -2
  39. package/dist/{chunk-XQZOMXP3.js → chunk-AWTERXCW.js} +2 -2
  40. package/dist/{chunk-JIEEUHNS.js → chunk-AZSFIQIA.js} +8 -8
  41. package/dist/{chunk-TY6CTYCF.js → chunk-BV5XTGKB.js} +3 -3
  42. package/dist/chunk-BV5XTGKB.js.map +1 -0
  43. package/dist/{chunk-5F4NIRVF.js → chunk-CKZFYGBY.js} +10 -6
  44. package/dist/chunk-CKZFYGBY.js.map +1 -0
  45. package/dist/{chunk-T4JGNZAR.js → chunk-CZPU5TW3.js} +2 -2
  46. package/dist/{chunk-S6T722WH.js → chunk-DEOC5OI7.js} +3 -3
  47. package/dist/{chunk-KWUQZDPL.js → chunk-ECIGNYSI.js} +3 -2
  48. package/dist/chunk-ECIGNYSI.js.map +1 -0
  49. package/dist/{chunk-Q5GXVDXL.js → chunk-EICVL6GS.js} +2 -2
  50. package/dist/{chunk-USBTXEBG.js → chunk-HGBZZDP6.js} +2 -2
  51. package/dist/{chunk-6IAQGSXD.js → chunk-HR7YTBR7.js} +2 -2
  52. package/dist/{chunk-NXTKZSMT.js → chunk-IN642YHK.js} +2 -2
  53. package/dist/{chunk-QBJVRPTF.js → chunk-ISH42UC7.js} +2 -2
  54. package/dist/{chunk-AGKQBS4C.js → chunk-JKLWHENB.js} +3 -3
  55. package/dist/{chunk-SVXSBLVD.js → chunk-KEDI6IRA.js} +2 -2
  56. package/dist/{chunk-C6ATAHBX.js → chunk-LHHAYZ55.js} +1 -1
  57. package/dist/chunk-LHHAYZ55.js.map +1 -0
  58. package/dist/{chunk-Z5E2PXGN.js → chunk-LPYB4Y7C.js} +49 -16
  59. package/dist/chunk-LPYB4Y7C.js.map +1 -0
  60. package/dist/{chunk-DVTCZR3K.js → chunk-LR6MSKTT.js} +7 -5
  61. package/dist/chunk-LR6MSKTT.js.map +1 -0
  62. package/dist/{chunk-CY5X3HNQ.js → chunk-OGGHD64H.js} +2 -2
  63. package/dist/{chunk-QFHUWD3C.js → chunk-QQE2PVLO.js} +3 -3
  64. package/dist/{chunk-N7SBWD2V.js → chunk-RDYBS45D.js} +4 -4
  65. package/dist/{chunk-F6FT2LIR.js → chunk-SCGVB7DS.js} +2 -2
  66. package/dist/{chunk-TDSRBCBG.js → chunk-T4BFDZGU.js} +9 -8
  67. package/dist/chunk-T4BFDZGU.js.map +1 -0
  68. package/dist/{chunk-T6V3DKJ5.js → chunk-WLCVOQCJ.js} +2 -2
  69. package/dist/{chunk-GCC66ZSD.js → chunk-WWM2YTW4.js} +29 -13
  70. package/dist/chunk-WWM2YTW4.js.map +1 -0
  71. package/dist/{chunk-GQTBWJYK.js → chunk-WXBBWSNU.js} +2 -2
  72. package/dist/{chunk-VN6Z6F7R.js → chunk-ZAB65STX.js} +11 -6
  73. package/dist/chunk-ZAB65STX.js.map +1 -0
  74. package/dist/{chunk-HVIB6WMD.js → chunk-ZPIMPOHV.js} +2 -2
  75. package/dist/{chunk-E3IPN3KN.js → chunk-ZUIJ3N7N.js} +2 -2
  76. package/dist/data-display/DataViews.js +31 -31
  77. package/dist/form/CategorySelect.js +10 -10
  78. package/dist/form/total-form.js +12 -12
  79. package/dist/types/components/data-display/DataViews/data-views-category-pill.d.ts +6 -0
  80. package/dist/types/components/data-display/DataViews/data-views-category-pill.d.ts.map +1 -1
  81. package/dist/types/components/data-display/DataViews/data-views-grid-parts.d.ts.map +1 -1
  82. package/dist/types/components/data-display/DataViews/data-views-types.d.ts +21 -0
  83. package/dist/types/components/data-display/DataViews/data-views-types.d.ts.map +1 -1
  84. package/dist/types/components/data-display/DataViews/use-data-views-state.d.ts +10 -2
  85. package/dist/types/components/data-display/DataViews/use-data-views-state.d.ts.map +1 -1
  86. package/dist/types/components/form/CategorySelect/CategoryPanelList.d.ts.map +1 -1
  87. package/dist/types/components/form/CategorySelect/CategoryRows.d.ts +8 -2
  88. package/dist/types/components/form/CategorySelect/CategoryRows.d.ts.map +1 -1
  89. package/dist/types/components/form/CategorySelect/category-keyboard.d.ts +1 -1
  90. package/dist/types/components/form/CategorySelect/category-keyboard.d.ts.map +1 -1
  91. package/dist/types/components/form/CategorySelect/category-tree.d.ts +12 -0
  92. package/dist/types/components/form/CategorySelect/category-tree.d.ts.map +1 -1
  93. package/dist/types/components/form/CategorySelect/useCategoryCommit.d.ts.map +1 -1
  94. package/package.json +1 -1
  95. package/src/components/data-display/DataViews/data-views-category-pill.tsx +7 -0
  96. package/src/components/data-display/DataViews/data-views-grid-parts.tsx +2 -1
  97. package/src/components/data-display/DataViews/data-views-types.ts +24 -0
  98. package/src/components/data-display/DataViews/use-data-views-state.ts +13 -3
  99. package/src/components/form/CategorySelect/CategoryPanelList.tsx +9 -5
  100. package/src/components/form/CategorySelect/CategoryRows.tsx +64 -23
  101. package/src/components/form/CategorySelect/CategorySelect.md +33 -6
  102. package/src/components/form/CategorySelect/category-keyboard.ts +34 -15
  103. package/src/components/form/CategorySelect/category-tree.ts +17 -8
  104. package/src/components/form/CategorySelect/useCategoryCommit.ts +10 -6
  105. package/dist/chunk-5F4NIRVF.js.map +0 -1
  106. package/dist/chunk-C6ATAHBX.js.map +0 -1
  107. package/dist/chunk-DVTCZR3K.js.map +0 -1
  108. package/dist/chunk-GCC66ZSD.js.map +0 -1
  109. package/dist/chunk-KWUQZDPL.js.map +0 -1
  110. package/dist/chunk-TDSRBCBG.js.map +0 -1
  111. package/dist/chunk-TY6CTYCF.js.map +0 -1
  112. package/dist/chunk-VN6Z6F7R.js.map +0 -1
  113. package/dist/chunk-Z5E2PXGN.js.map +0 -1
  114. /package/dist/{chunk-HQBXB5QB.js.map → chunk-2GB5CIN6.js.map} +0 -0
  115. /package/dist/{chunk-6UGRH32J.js.map → chunk-4KSOSI3U.js.map} +0 -0
  116. /package/dist/{chunk-IKBQ7CS2.js.map → chunk-56SMIHWE.js.map} +0 -0
  117. /package/dist/{chunk-LWYXMCX6.js.map → chunk-5ZZPQ3MT.js.map} +0 -0
  118. /package/dist/{chunk-ZBYWGL5G.js.map → chunk-6U7NA74A.js.map} +0 -0
  119. /package/dist/{chunk-XQZOMXP3.js.map → chunk-AWTERXCW.js.map} +0 -0
  120. /package/dist/{chunk-JIEEUHNS.js.map → chunk-AZSFIQIA.js.map} +0 -0
  121. /package/dist/{chunk-T4JGNZAR.js.map → chunk-CZPU5TW3.js.map} +0 -0
  122. /package/dist/{chunk-S6T722WH.js.map → chunk-DEOC5OI7.js.map} +0 -0
  123. /package/dist/{chunk-Q5GXVDXL.js.map → chunk-EICVL6GS.js.map} +0 -0
  124. /package/dist/{chunk-USBTXEBG.js.map → chunk-HGBZZDP6.js.map} +0 -0
  125. /package/dist/{chunk-6IAQGSXD.js.map → chunk-HR7YTBR7.js.map} +0 -0
  126. /package/dist/{chunk-NXTKZSMT.js.map → chunk-IN642YHK.js.map} +0 -0
  127. /package/dist/{chunk-QBJVRPTF.js.map → chunk-ISH42UC7.js.map} +0 -0
  128. /package/dist/{chunk-AGKQBS4C.js.map → chunk-JKLWHENB.js.map} +0 -0
  129. /package/dist/{chunk-SVXSBLVD.js.map → chunk-KEDI6IRA.js.map} +0 -0
  130. /package/dist/{chunk-CY5X3HNQ.js.map → chunk-OGGHD64H.js.map} +0 -0
  131. /package/dist/{chunk-QFHUWD3C.js.map → chunk-QQE2PVLO.js.map} +0 -0
  132. /package/dist/{chunk-N7SBWD2V.js.map → chunk-RDYBS45D.js.map} +0 -0
  133. /package/dist/{chunk-F6FT2LIR.js.map → chunk-SCGVB7DS.js.map} +0 -0
  134. /package/dist/{chunk-T6V3DKJ5.js.map → chunk-WLCVOQCJ.js.map} +0 -0
  135. /package/dist/{chunk-GQTBWJYK.js.map → chunk-WXBBWSNU.js.map} +0 -0
  136. /package/dist/{chunk-HVIB6WMD.js.map → chunk-ZPIMPOHV.js.map} +0 -0
  137. /package/dist/{chunk-E3IPN3KN.js.map → chunk-ZUIJ3N7N.js.map} +0 -0
@@ -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-ZPIMPOHV.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-CZPU5TW3.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-LS42VJAI.js";
4
4
  import {
5
5
  DataViewsGrid
6
- } from "./chunk-AGKQBS4C.js";
6
+ } from "./chunk-JKLWHENB.js";
7
7
  import {
8
8
  viewStateKey
9
9
  } from "./chunk-ZOLAYP2D.js";
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-XPS7FWZS.js";
14
14
  import {
15
15
  useSavedViewsController
16
- } from "./chunk-6IAQGSXD.js";
16
+ } from "./chunk-HR7YTBR7.js";
17
17
 
18
18
  // src/components/data-display/DataViews/DataViewsTableBase.tsx
19
19
  import { useEffect, useMemo, useRef, useState } from "react";
@@ -178,4 +178,4 @@ function renderViewDialogs(ctl, fields, columns, views, testIdPrefix, onSaved) {
178
178
  export {
179
179
  DataViewsTableBase
180
180
  };
181
- //# sourceMappingURL=chunk-S6T722WH.js.map
181
+ //# sourceMappingURL=chunk-DEOC5OI7.js.map
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-4T6W43TO.js";
7
7
  import {
8
8
  CategorySelect
9
- } from "./chunk-JIEEUHNS.js";
9
+ } from "./chunk-AZSFIQIA.js";
10
10
 
11
11
  // src/components/data-display/DataViews/data-views-category-pill.tsx
12
12
  import { jsx } from "react/jsx-runtime";
@@ -46,6 +46,7 @@ function PillControl({
46
46
  label: layout === "stacked" ? pill.label : void 0,
47
47
  fullWidth: layout === "stacked",
48
48
  options: pill.options.map(toCategoryOption),
49
+ allowParentSelection: pill.allowParentSelection ?? false,
49
50
  value: selected,
50
51
  onChange: (next) => emitPillDiff(fieldId, selected, next, onTogglePill),
51
52
  dataTestId: testId
@@ -78,4 +79,4 @@ export {
78
79
  emitPillDiff,
79
80
  PillControl
80
81
  };
81
- //# sourceMappingURL=chunk-KWUQZDPL.js.map
82
+ //# sourceMappingURL=chunk-ECIGNYSI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/data-display/DataViews/data-views-category-pill.tsx"],"sourcesContent":["\"use client\";\n\nimport { useDataViewsCopy } from \"./data-views-copy-context\";\nimport { CategorySelect } from \"../../form/CategorySelect\";\nimport { MultiSelectDropdown } from \"../../layout/ContentToolbar\";\n\nimport type { FilterFieldConfig, FilterOption } from \"./data-views-types\";\n\n/**\n * Diff a whole-array selection back into per-value toggles.\n *\n * The filter state's only channel is `onTogglePill(field, value, checked)`, but\n * a tree hands back the entire selection at once. Diffing here keeps that one\n * channel the single way a pill ever changes, rather than giving the\n * hierarchical control a private path into the state.\n */\nexport function emitPillDiff(\n fieldId: string,\n before: readonly string[],\n after: readonly string[],\n onTogglePill: (fieldId: string, value: string, checked: boolean) => void,\n): void {\n const had = new Set(before);\n const wants = new Set(after);\n after.forEach((value) => {\n if (!had.has(value)) onTogglePill(fieldId, value, true);\n });\n before.forEach((value) => {\n if (!wants.has(value)) onTogglePill(fieldId, value, false);\n });\n}\n\n/** A filter option as the category tree wants it. */\nconst toCategoryOption = (option: FilterOption) => ({\n id: option.value,\n name: option.label,\n parentId: option.parentId ?? null,\n});\n\ninterface PillControlProps<T extends Record<string, unknown>> {\n fieldId: string;\n pill: FilterFieldConfig<T>;\n selected: string[];\n onTogglePill: (fieldId: string, value: string, checked: boolean) => void;\n onClearField: (fieldId: string) => void;\n onOpenChange?: (open: boolean) => void;\n testIdPrefix: string;\n /** `stacked` in the filter panel, `pill` on the inline bar. */\n layout?: \"stacked\" | \"pill\";\n}\n\n/**\n * One filter pill: the hierarchical category tree, or the flat multi-select.\n *\n * A category set nests, and flattening it into one list is what made \"Massas\"\n * (mercearia) indistinguishable from \"Massas\" (pratos principais). `control:\n * \"category\"` opts a field into the tree, which shows each hit under its parent.\n *\n * {@link FilterFieldConfig.allowParentSelection} decides whether a parent row is\n * itself tickable. It is forwarded rather than fixed here because it is a\n * per-SCREEN question: a filter over a catalogue where products sit on leaves\n * wants \"the whole category\" as one click, while one whose parents are pure\n * grouping would only offer a tick that means nothing.\n */\nexport function PillControl<T extends Record<string, unknown>>({\n fieldId,\n pill,\n selected,\n onTogglePill,\n onClearField,\n onOpenChange,\n testIdPrefix,\n layout = \"pill\",\n}: PillControlProps<T>): React.JSX.Element {\n const copy = useDataViewsCopy();\n const testId = `${testIdPrefix}-filter-${fieldId}`;\n if (pill.control === \"category\") {\n return (\n <CategorySelect\n copy={copy.categorySelect}\n placeholder={pill.label}\n label={layout === \"stacked\" ? pill.label : undefined}\n fullWidth={layout === \"stacked\"}\n options={pill.options.map(toCategoryOption)}\n allowParentSelection={pill.allowParentSelection ?? false}\n value={selected}\n onChange={(next) => emitPillDiff(fieldId, selected, next, onTogglePill)}\n dataTestId={testId}\n />\n );\n }\n return (\n <MultiSelectDropdown\n extraOptionsHeading={copy.filters.optionsHeading}\n clearText={copy.filters.clear}\n clearLabel={copy.filters.clearRange(pill.label)}\n label={pill.label}\n options={pill.options}\n selected={new Set(selected)}\n onToggle={(value, checked) => onTogglePill(fieldId, value, checked)}\n onClear={() => onClearField(fieldId)}\n allLabel={copy.filters.allOption}\n searchable={pill.searchEnabled ? true : undefined}\n searchPlaceholder={copy.filters.optionSearchPlaceholder}\n noResultsLabel={copy.filters.optionsEmpty}\n layout={layout}\n onOpenChange={onOpenChange}\n data-testid={testId}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AA8EM;AA9DC,SAAS,aACd,SACA,QACA,OACA,cACM;AACN,QAAM,MAAM,IAAI,IAAI,MAAM;AAC1B,QAAM,QAAQ,IAAI,IAAI,KAAK;AAC3B,QAAM,QAAQ,CAAC,UAAU;AACvB,QAAI,CAAC,IAAI,IAAI,KAAK,EAAG,cAAa,SAAS,OAAO,IAAI;AAAA,EACxD,CAAC;AACD,SAAO,QAAQ,CAAC,UAAU;AACxB,QAAI,CAAC,MAAM,IAAI,KAAK,EAAG,cAAa,SAAS,OAAO,KAAK;AAAA,EAC3D,CAAC;AACH;AAGA,IAAM,mBAAmB,CAAC,YAA0B;AAAA,EAClD,IAAI,OAAO;AAAA,EACX,MAAM,OAAO;AAAA,EACb,UAAU,OAAO,YAAY;AAC/B;AA2BO,SAAS,YAA+C;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AACX,GAA2C;AACzC,QAAM,OAAO,iBAAiB;AAC9B,QAAM,SAAS,GAAG,YAAY,WAAW,OAAO;AAChD,MAAI,KAAK,YAAY,YAAY;AAC/B,WACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,KAAK;AAAA,QACX,aAAa,KAAK;AAAA,QAClB,OAAO,WAAW,YAAY,KAAK,QAAQ;AAAA,QAC3C,WAAW,WAAW;AAAA,QACtB,SAAS,KAAK,QAAQ,IAAI,gBAAgB;AAAA,QAC1C,sBAAsB,KAAK,wBAAwB;AAAA,QACnD,OAAO;AAAA,QACP,UAAU,CAAC,SAAS,aAAa,SAAS,UAAU,MAAM,YAAY;AAAA,QACtE,YAAY;AAAA;AAAA,IACd;AAAA,EAEJ;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,qBAAqB,KAAK,QAAQ;AAAA,MAClC,WAAW,KAAK,QAAQ;AAAA,MACxB,YAAY,KAAK,QAAQ,WAAW,KAAK,KAAK;AAAA,MAC9C,OAAO,KAAK;AAAA,MACZ,SAAS,KAAK;AAAA,MACd,UAAU,IAAI,IAAI,QAAQ;AAAA,MAC1B,UAAU,CAAC,OAAO,YAAY,aAAa,SAAS,OAAO,OAAO;AAAA,MAClE,SAAS,MAAM,aAAa,OAAO;AAAA,MACnC,UAAU,KAAK,QAAQ;AAAA,MACvB,YAAY,KAAK,gBAAgB,OAAO;AAAA,MACxC,mBAAmB,KAAK,QAAQ;AAAA,MAChC,gBAAgB,KAAK,QAAQ;AAAA,MAC7B;AAAA,MACA;AAAA,MACA,eAAa;AAAA;AAAA,EACf;AAEJ;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RAIL_GAP_PX
3
- } from "./chunk-T4JGNZAR.js";
3
+ } from "./chunk-CZPU5TW3.js";
4
4
  import {
5
5
  DescriptionItem
6
6
  } from "./chunk-TCAB2ERD.js";
@@ -222,4 +222,4 @@ export {
222
222
  ListCardActions,
223
223
  ListCardTail
224
224
  };
225
- //# sourceMappingURL=chunk-Q5GXVDXL.js.map
225
+ //# sourceMappingURL=chunk-EICVL6GS.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  DisplayTab,
6
6
  SortTab
7
- } from "./chunk-F6FT2LIR.js";
7
+ } from "./chunk-SCGVB7DS.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-HGBZZDP6.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  coerceViewState,
6
6
  emptyViewState
7
- } from "./chunk-C6ATAHBX.js";
7
+ } from "./chunk-LHHAYZ55.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-HR7YTBR7.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PillControl
3
- } from "./chunk-KWUQZDPL.js";
3
+ } from "./chunk-ECIGNYSI.js";
4
4
  import {
5
5
  PanelRangeField
6
6
  } from "./chunk-BZTFPSWT.js";
@@ -154,4 +154,4 @@ export {
154
154
  GridFilterPanel,
155
155
  FilterDialog
156
156
  };
157
- //# sourceMappingURL=chunk-NXTKZSMT.js.map
157
+ //# sourceMappingURL=chunk-IN642YHK.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  handleCategoryKeyDown
3
- } from "./chunk-GCC66ZSD.js";
3
+ } from "./chunk-WWM2YTW4.js";
4
4
 
5
5
  // src/components/form/CategorySelect/useCategoryKeyHandler.ts
6
6
  import { useCallback } from "react";
@@ -52,4 +52,4 @@ function useCategoryKeyHandler({
52
52
  export {
53
53
  useCategoryKeyHandler
54
54
  };
55
- //# sourceMappingURL=chunk-QBJVRPTF.js.map
55
+ //# sourceMappingURL=chunk-ISH42UC7.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  GridShell
3
- } from "./chunk-TDSRBCBG.js";
3
+ } from "./chunk-T4BFDZGU.js";
4
4
  import {
5
5
  useDataViewsState
6
- } from "./chunk-TY6CTYCF.js";
6
+ } from "./chunk-BV5XTGKB.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-JKLWHENB.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
@@ -53,4 +53,4 @@ export {
53
53
  DATA_VIEWS_LAYOUTS,
54
54
  toSavedViewSummary
55
55
  };
56
- //# sourceMappingURL=chunk-C6ATAHBX.js.map
56
+ //# sourceMappingURL=chunk-LHHAYZ55.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. */\n/**\n * A view-state patch: the fields to merge, or an updater given the CURRENT\n * state. Use the updater whenever the patch derives from state it also changes\n * — a render-scoped snapshot would let two calls in one tick read the same\n * `prev` and the second overwrite the first, which is exactly what a control\n * emitting one call per changed value does.\n */\nexport type DataViewStatePatch =\n | Partial<DataViewState>\n | ((prev: DataViewState) => Partial<DataViewState>);\n\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,KAAK;AAAA,EACb,QAAQ,IAAI;AAAA,EACZ,OAAO,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASX,OAAO;AACT;AA+IO,SAAS,eAAe,gBAAyC;AACtE,SAAO,EAAE,QAAQ,IAAI,OAAO,CAAC,GAAG,QAAQ,CAAC,GAAG,QAAQ,CAAC,GAAG,eAAe;AACzE;AA+EO,SAAS,gBAAgB,KAAc,cAAuC;AACnF,QAAM,QAAS,OAAO,CAAC;AACvB,SAAO;AAAA,IACL,QAAQ,OAAO,MAAM,WAAW,WAAW,MAAM,SAAS;AAAA,IAC1D,OAAO,SAAmB,MAAM,KAAK;AAAA,IACrC,QAAQ,SAAqB,MAAM,MAAM;AAAA,IACzC,QAAQ,MAAM,QAAQ,MAAM,MAAM,IAAI,MAAM,SAAS,CAAC;AAAA,IACtD,gBAAgB,MAAM,QAAQ,MAAM,cAAc,IAAI,MAAM,iBAAiB;AAAA,IAC7E,OAAO,MAAM,QAAQ,MAAM,KAAK,IAAI,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,IAKlD,OAAO,OAAO,MAAM,UAAU,WAAW,MAAM,QAAQ;AAAA,IACvD,QAAQ,SAAS,MAAM,MAAM,IAAI,MAAM,SAAS;AAAA,EAClD;AACF;AAGO,IAAM,qBAAiD,CAAC,SAAS,QAAQ,SAAS,OAAO;AAGhG,SAAS,SAAS,OAA0C;AAC1D,SAAO,mBAAmB,SAAS,KAAwB;AAC7D;AAGA,SAAS,SAAY,OAAmC;AACtD,SAAO,UAAU,QAAQ,OAAO,UAAU,WAAY,QAA8B,CAAC;AACvF;AA4BO,SAAS,mBAAmB,QAA+C;AAChF,SAAO,EAAE,GAAG,QAAQ,OAAQ,OAAO,SAAS,CAAC,EAAoB;AACnE;","names":[]}
@@ -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;A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AAAA,MAET;AAAA,4BAAC,OAAI,IAAI,EAAE,OAAO,QAAQ,eAAe,MAAM,WAAW,GAAG;AAAA,QAC5D,SACC,oBAAC,iBAAc,IAAI,UAAU,IAE7B,oBAAC,oBAAiB,OAAO,WAAW,OAAO,OAAO;AAAA,QAEpD,oBAAC,OAAI,WAAU,QAAO,IAAI,CAAC,UAAU,UAAU,OAAO,KAAK,GACzD,8BAAC,mBAAgB,MAAM,OAAO,MAAM,OAAc,GACpD;AAAA,QACC,cAAc,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,SAAO,KACJ,UAAU,KAAK,EACf,QAAQ,oBAAoB,EAAE,EAC9B,YAAY;AACjB;AASO,SAAS,oBAAoB,SAAkD;AACpF,QAAM,QAAQ,QAAQ,OAAO,CAAC,WAAW,CAAC,OAAO,QAAQ;AACzD,QAAM,UAAU,IAAI,IAAI,MAAM,IAAI,CAAC,SAAS,KAAK,EAAE,CAAC;AACpD,QAAM,SAAS,IAAI;AAAA,IACjB,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,UAAU,MAAM,eAAe,CAAC,EAAE,CAAC,CAAC;AAAA,EACtE;AACA,QAAM,UAA2B,CAAC;AAElC,UAAQ,QAAQ,CAAC,WAAW;AAC1B,QAAI,CAAC,OAAO,SAAU;AACtB,UAAM,SAAS,OAAO,IAAI,OAAO,QAAQ;AACzC,QAAI,QAAQ;AACV,aAAO,cAAc,KAAK,MAAM;AAChC;AAAA,IACF;AACA,QAAI,CAAC,QAAQ,IAAI,OAAO,EAAE,EAAG,SAAQ,KAAK,EAAE,UAAU,QAAQ,eAAe,CAAC,EAAE,CAAC;AAAA,EACnF,CAAC;AAED,SAAO,CAAC,GAAG,OAAO,OAAO,GAAG,GAAG,OAAO;AACxC;AAaO,SAAS,eAAe,OAA+B;AAC5D,SAAO,MAAM,cAAc,WAAW;AACxC;AAGO,SAAS,eAAe,QAAmC;AAChE,SAAO,OAAO,QAAQ,CAAC,UAAU,SAAS,KAAK,CAAC;AAClD;AAGO,SAAS,SAAS,OAAgC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B;AAClB,SAAO,OAAO,QAAQ,CAAC,UAAU;AAC/B,UAAM,OAAuB,EAAE,MAAM,YAAY,IAAI,MAAM,SAAS,GAAG;AACvE,QAAI,CAAC,WAAW,MAAM,SAAS,EAAE,EAAG,QAAO,CAAC,IAAI;AAChD,WAAO;AAAA,MACL;AAAA,MACA,GAAG,MAAM,cAAc;AAAA,QACrB,CAAC,SAAyB;AAAA,UACxB,MAAM;AAAA,UACN,IAAI,IAAI;AAAA,UACR,UAAU,MAAM,SAAS;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useDataViewsLayout
3
- } from "./chunk-HVIB6WMD.js";
3
+ } from "./chunk-ZPIMPOHV.js";
4
4
  import {
5
5
  DataViewsScopeTabs
6
6
  } from "./chunk-LYKV3C7B.js";
@@ -34,4 +34,4 @@ function ScopeTabsSlot({
34
34
  export {
35
35
  ScopeTabsSlot
36
36
  };
37
- //# sourceMappingURL=chunk-CY5X3HNQ.js.map
37
+ //# sourceMappingURL=chunk-OGGHD64H.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-CZPU5TW3.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-ZPIMPOHV.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-QQE2PVLO.js.map
@@ -8,13 +8,13 @@ import {
8
8
  metaShape,
9
9
  rowStyles,
10
10
  useRowShell
11
- } from "./chunk-6UGRH32J.js";
11
+ } from "./chunk-4KSOSI3U.js";
12
12
  import {
13
13
  ListCardActions,
14
14
  ListCardCaption,
15
15
  ListCardMeta,
16
16
  ListCardTail
17
- } from "./chunk-Q5GXVDXL.js";
17
+ } from "./chunk-EICVL6GS.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-CZPU5TW3.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-RDYBS45D.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-ZPIMPOHV.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-SCGVB7DS.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-QQE2PVLO.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-OGGHD64H.js";
24
24
  import {
25
25
  ShellToolbar
26
- } from "./chunk-XQZOMXP3.js";
26
+ } from "./chunk-AWTERXCW.js";
27
27
  import {
28
28
  DataViewsLayoutProvider,
29
29
  useDataViewsLayout
30
- } from "./chunk-HVIB6WMD.js";
30
+ } from "./chunk-ZPIMPOHV.js";
31
31
  import {
32
32
  togglePillValues
33
33
  } from "./chunk-5VZPVDUF.js";
@@ -114,7 +114,8 @@ function useGridShellFilters({
114
114
  pills: state.pills,
115
115
  ranges: c.ranges,
116
116
  onSearchChange: (value) => c.patch({ search: value }),
117
- onTogglePill: (fieldId, value, checked) => c.patch({ pills: { ...state.pills, [fieldId]: togglePillValues(state.pills[fieldId], value, checked) } }),
117
+ // Updater, never the render's `state` — see {@link DataViewStatePatch}.
118
+ onTogglePill: (fieldId, value, checked) => c.patch(({ pills }) => ({ pills: { ...pills, [fieldId]: togglePillValues(pills[fieldId], value, checked) } })),
118
119
  onChangeRange: (fieldId, range) => c.patch({ ranges: { ...c.ranges, [fieldId]: range } }),
119
120
  onClearField: (fieldId) => c.patch({ pills: { ...state.pills, [fieldId]: [] } }),
120
121
  onClearAll: () => c.patch({ search: "", pills: {}, ranges: {} })
@@ -260,4 +261,4 @@ function GridShell(props) {
260
261
  export {
261
262
  GridShell
262
263
  };
263
- //# sourceMappingURL=chunk-TDSRBCBG.js.map
264
+ //# sourceMappingURL=chunk-T4BFDZGU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/data-display/DataViews/data-views-grid-parts.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nimport { TableFilter } from \"../../layout/TableFilter\";\nimport { Text } from \"../../typography/Text\";\nimport { Box } from \"../../../mui/Box\";\nimport { Stack } from \"../../../mui/Stack\";\n\nimport {\n DataViewsLayoutProvider,\n useDataViewsLayout,\n type DataViewsLayout,\n} from \"./data-views-layout-context\";\nimport { FilterDialog, GridFilterPanel } from \"./data-views-filter-panel\";\nimport { GridMain } from \"./data-views-grid-bodies\";\nimport type { ListGroupConfig } from \"./list-card-rails\";\nimport { InlineFilterControls } from \"./data-views-inline-bar\";\nimport { toOverflowFields, useFilterOverflow, type OverflowSplit } from \"./data-views-overflow\";\nimport { ShellToolbar } from \"./data-views-shell-toolbar\";\nimport type { DisplayPanelView } from \"./data-views-display-panel\";\nimport type { DataViewExport } from \"./data-views-export\";\nimport { useDataViewsCopy } from \"./data-views-copy-context\";\nimport { DataViewsEmpty } from \"./data-views-empty\";\nimport { DataViewsPagination } from \"./data-views-pagination\";\nimport type { BoardConfig } from \"./DataViewsBoard\";\nimport { type ScopeConfig } from \"./data-views-scopes\";\nimport { ScopeTabsSlot } from \"./data-views-scope-tabs\";\nimport { togglePillValues } from \"./data-views-grid-helpers\";\nimport type {\n DataViewCardSelection,\n FilterFieldConfig,\n RangeFieldConfig,\n RangeValue,\n RowAction,\n} from \"./data-views-types\";\nimport type { DataViewsController } from \"./use-data-views-state\";\n\n/* ── Header row ──────────────────────────────────────────────────────────── */\n\n/**\n * The grid's own header row: the page title on the left, the primary page\n * actions on the right.\n *\n * `title` and `headerActions` were DECLARED on `DataViewsGridProps` and\n * `DataViewsTableBaseProps` but never destructured or forwarded — dead props\n * whose types lied to every caller that set them. Wired here rather than\n * deleted: a table that carries its own title keeps the title, the scope tabs\n * and the toolbar as one block, instead of the page having to space them.\n *\n * Renders NOTHING when neither is supplied, so no existing table gains a row.\n */\nfunction GridHeaderRow({\n title,\n headerActions,\n testIdPrefix,\n}: {\n title?: string;\n headerActions?: React.ReactNode;\n testIdPrefix: string;\n}): React.JSX.Element | null {\n if (!title && !headerActions) return null;\n return (\n <Box\n data-testid={`${testIdPrefix}-header`}\n sx={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n gap: 2,\n flexWrap: \"wrap\",\n pb: 1.5,\n }}\n >\n {title ? (\n <Text variant=\"heading\" size=\"lg\" as=\"h2\">\n {title}\n </Text>\n ) : (\n <Box />\n )}\n {headerActions && <Box sx={{ display: \"flex\", alignItems: \"center\", gap: 1 }}>{headerActions}</Box>}\n </Box>\n );\n}\n\n/* ── Layout ⇄ view-state mirror ──────────────────────────────────────────── */\n\n/**\n * Mirrors the LIVE layout back into the view state, so saving a view captures\n * the layout the user is actually looking at.\n *\n * A component rather than a callback prop because only something INSIDE the\n * provider can read the layout, and only the controller can write the state.\n * The `stored !== layout` guard is what makes it idempotent: `c` is rebuilt on\n * every render, so an unguarded effect here would patch → re-render → patch.\n *\n * It re-fires when `stored` changes too, which is the case that matters after\n * applying a saved view: `appliedState` REPLACES the state, so a view saved\n * before layouts were captured clears `state.layout`, and the mirror puts the\n * current one back rather than leaving the next save with nothing to store.\n */\nfunction LayoutStateSync<T extends Record<string, unknown>>({\n c,\n}: {\n c: DataViewsController<T>;\n}): null {\n const { layout } = useDataViewsLayout();\n const stored = c.state.layout;\n useEffect(() => {\n if (stored !== layout) c.patch({ layout });\n // `c` is intentionally out of the deps — see the guard above.\n }, [layout, stored]);\n return null;\n}\n\n/* ── Shell (composes toolbar + body + panel) ─────────────────────────────── */\n\n/** The shared filter-surface props consumed by the inline bar, panel, and modal. */\ninterface FilterSurfaceProps<T extends Record<string, unknown>> {\n testIdPrefix: string;\n search: string;\n fields: FilterFieldConfig<T>[];\n rangeFields: RangeFieldConfig<T>[];\n pills: Record<string, string[]>;\n ranges: Record<string, RangeValue>;\n onSearchChange: (value: string) => void;\n onTogglePill: (fieldId: string, value: string, checked: boolean) => void;\n onChangeRange: (fieldId: string, range: RangeValue) => void;\n onClearField: (fieldId: string) => void;\n onClearAll: () => void;\n}\n\n/**\n * Derives the responsive filter state (which surface to show at this width) and\n * the filter-mutation handlers from the controller — pulled out of `GridShell`\n * so the component body stays under the size/complexity budget.\n */\n/** Grouped rather than positional: the list had grown past readability. */\ninterface GridShellFiltersArgs<T extends Record<string, unknown>> {\n c: DataViewsController<T>;\n inlineFilters: boolean;\n fields: FilterFieldConfig<T>[];\n rangeFields: RangeFieldConfig<T>[];\n testIdPrefix: string;\n alwaysShowSearch: boolean;\n /** Is \"Exportar\" on the bar? Half the right cluster's cost when it is not. */\n hasExport: boolean;\n}\n\nfunction useGridShellFilters<T extends Record<string, unknown>>({\n c,\n inlineFilters,\n fields,\n rangeFields,\n testIdPrefix,\n alwaysShowSearch,\n hasExport,\n}: GridShellFiltersArgs<T>): {\n showInline: boolean;\n useModal: boolean;\n inlineVisible: boolean;\n filterProps: FilterSurfaceProps<T>;\n split: OverflowSplit<T>;\n onControlOpenChange: (open: boolean) => void;\n} {\n const { state } = c;\n // How many filter controls are open. A COUNT, not a flag: closing one popover\n // by opening another overlaps, and a boolean would unfreeze mid-handover.\n const [openControls, setOpenControls] = useState(0);\n // ONE measurement for the whole shell: the filter row decides which controls\n // it can keep, and the TOOLBAR needs the same answer to drop its labels.\n // Measuring twice would let the two disagree at the crossover width.\n const split = useFilterOverflow(\n toOverflowFields(fields, rangeFields),\n state.pills,\n c.ranges,\n openControls > 0,\n hasExport,\n );\n // THE BAR RENDERS AT EVERY WIDTH. It used to be swapped for a full-screen\n // filter MODAL below `lg`, which was the responsive strategy before the\n // measured ladder existed — and the two now do the same job, badly together:\n // the modal took the bar away at 1199px, and with it the very degradation\n // (labels off, search collapsed, filters into \"Mais\") that exists to make a\n // narrow bar work. So a 900px window got no bar and no ladder, and the\n // operator lost the search entirely rather than gaining a compact one.\n //\n // The ladder is measured, so it already covers every width the modal did.\n const showInline = inlineFilters;\n const useModal = false;\n const inlineVisible =\n showInline &&\n (alwaysShowSearch || fields.length > 0 || rangeFields.length > 0 || state.search !== \"\");\n const filterProps: FilterSurfaceProps<T> = {\n testIdPrefix,\n search: state.search,\n fields,\n rangeFields,\n pills: state.pills,\n ranges: c.ranges,\n onSearchChange: (value) => c.patch({ search: value }),\n // Updater, never the render's `state` — see {@link DataViewStatePatch}.\n onTogglePill: (fieldId, value, checked) =>\n c.patch(({ pills }) => ({ pills: { ...pills, [fieldId]: togglePillValues(pills[fieldId], value, checked) } })),\n onChangeRange: (fieldId, range) => c.patch({ ranges: { ...c.ranges, [fieldId]: range } }),\n onClearField: (fieldId) => c.patch({ pills: { ...state.pills, [fieldId]: [] } }),\n onClearAll: () => c.patch({ search: \"\", pills: {}, ranges: {} }),\n };\n return {\n showInline,\n useModal,\n inlineVisible,\n filterProps,\n split,\n onControlOpenChange: (open) =>\n setOpenControls((count) => Math.max(0, count + (open ? 1 : -1))),\n };\n}\n\ninterface GridShellProps<T extends Record<string, unknown>> {\n c: DataViewsController<T>;\n rows: T[];\n fields: FilterFieldConfig<T>[];\n rangeFields: RangeFieldConfig<T>[];\n getRowId: (row: T) => string | number;\n testIdPrefix: string;\n dataTestId?: string;\n emptyState?: React.ReactNode;\n toolbarRightSlot?: React.ReactNode;\n rowActions?: RowAction<T>[];\n bulkActions?: (selectedRows: T[], clearSelection: () => void) => React.ReactNode;\n /** Opt-in \"Grade\" (cards) layout: renders each row as an entity-supplied card.\n * Omit ⇒ table only (no layout toggle). */\n renderCard?: (row: T, selection: DataViewCardSelection) => React.ReactNode;\n /**\n * Opt-in \"Quadro\" (board) layout. Needs `renderCard` too — the board reuses\n * the entity's card, so a board config without one simply offers no board\n * rather than failing: that is a config gap, not a runtime error.\n */\n board?: BoardConfig<T>;\n /** Opt-in \"Lista\" layout: one full-width, entity-rendered row per record. */\n renderListRow?: (row: T, selection: DataViewCardSelection) => React.ReactNode;\n /** The Lista's shared columns, so its rows line up by construction. */\n listGroup?: ListGroupConfig<T>;\n /** The page-level partition rendered as tabs under the toolbar. */\n scopes?: ScopeConfig[];\n /**\n * The row field the scopes partition by. Compared against the board's\n * `groupBy` so the two are not shown as the same partition twice.\n */\n scopeFieldId?: string;\n /** Per-sort-field value kind, so directions read in the column's own terms. */\n sortKinds?: Record<string, string>;\n /** The saved-view chrome bracketing the Exibir panel. */\n displayView?: DisplayPanelView;\n /** Injected export — the host re-queries; the grid never fetches. */\n exportConfig?: DataViewExport;\n /** Page title in the grid's own header row, above the scopes + toolbar. */\n title?: string;\n /** Primary page actions rendered at the header row's right. */\n headerActions?: React.ReactNode;\n /** Which layout to show first when the user has expressed no preference (default \"table\"). */\n defaultLayout?: DataViewsLayout;\n /** Pin to `defaultLayout`, ignoring the remembered preference (stories/docs). */\n ignoreStoredLayout?: boolean;\n /**\n * Opt into the responsive inline filter UX: a collapsible filter row below the\n * toolbar on wide screens and a modal on narrow ones. When false (default),\n * keep the classic slide-in filter panel opened by the \"Filtros\" button.\n */\n inlineFilters?: boolean;\n /**\n * Keep the inline search box on screen even with no filter fields and no\n * active search. Without it a grid whose only filter IS the search (`fields`\n * empty) can never OFFER one: the row renders only once a search exists, so\n * the operator would have to hand-edit the URL to start one. Default false —\n * every grid that ships filter fields already shows the row.\n */\n alwaysShowSearch?: boolean;\n}\n\n/** The scrollable content region: scope tabs, toolbar, filter bar, body, pager. */\nfunction ShellStack<T extends Record<string, unknown>>({\n props,\n filters,\n}: {\n props: GridShellProps<T>;\n filters: ReturnType<typeof useGridShellFilters<T>>;\n}): React.JSX.Element {\n const copy = useDataViewsCopy();\n const { c, testIdPrefix, dataTestId, scopes = [], emptyState, inlineFilters = false } = props;\n const { showInline, useModal, inlineVisible, filterProps, split, onControlOpenChange } = filters;\n // The grid renders the FILTERED empty state itself — it is the only party\n // that knows a filter is applied. See {@link DataViewsEmpty}.\n const body = (\n <DataViewsEmpty\n filtered={c.activeFilterCount > 0 || c.state.search !== \"\"}\n onClearFilters={() => c.patch({ search: \"\", pills: {}, ranges: {} })}\n emptyState={emptyState}\n testIdPrefix={testIdPrefix}\n />\n );\n return (\n <TableFilter\n copy={copy.tableFilter} open={c.filterOpen} onOpenChange={c.setFilterOpen}\n hasActiveFilters={c.activeFilterCount > 0}\n >\n <Stack spacing={0} data-testid={dataTestId ? `${dataTestId}-container` : undefined}>\n <GridHeaderRow title={props.title} headerActions={props.headerActions} testIdPrefix={testIdPrefix} />\n <ShellToolbar\n c={c}\n rows={props.rows}\n sortKinds={props.sortKinds}\n displayView={props.displayView}\n exportConfig={props.exportConfig}\n filterControls={\n inlineVisible ? (\n <InlineFilterControls\n {...filterProps} split={split} activeFilterCount={c.activeFilterCount}\n onControlOpenChange={onControlOpenChange}\n />\n ) : undefined\n }\n barRef={split.barRef}\n testIdPrefix={testIdPrefix}\n rowActions={props.rowActions}\n bulkActions={props.bulkActions}\n toolbarRightSlot={props.toolbarRightSlot}\n compactControls={showInline && split.compactControls}\n counterHidden={showInline && split.counterHidden}\n showInline={showInline}\n />\n <ScopeTabsSlot\n scopes={scopes} scopeFieldId={props.scopeFieldId} board={props.board}\n value={c.scope} onChange={c.setScope} counts={c.scopeCounts}\n testIdPrefix={testIdPrefix}\n />\n <TableFilter.Layout>\n <TableFilter.Main>\n <GridMain\n c={c}\n getRowId={props.getRowId}\n renderCard={props.renderCard}\n renderListRow={props.renderListRow}\n listGroup={props.listGroup}\n board={props.board}\n dataTestId={dataTestId}\n testIdPrefix={testIdPrefix}\n emptyState={body}\n />\n <DataViewsPagination c={c} testIdPrefix={testIdPrefix} />\n </TableFilter.Main>\n {inlineFilters ? null : <GridFilterPanel {...filterProps} />}\n </TableFilter.Layout>\n {useModal && <FilterDialog open={c.filterOpen} onClose={() => c.setFilterOpen(false)} {...filterProps} />}\n </Stack>\n </TableFilter>\n );\n}\n\nexport function GridShell<T extends Record<string, unknown>>(props: GridShellProps<T>): React.JSX.Element {\n const {\n c,\n fields,\n rangeFields,\n testIdPrefix,\n renderCard,\n renderListRow,\n board,\n defaultLayout,\n ignoreStoredLayout,\n inlineFilters = false,\n alwaysShowSearch = false,\n } = props;\n const filters = useGridShellFilters({\n c,\n inlineFilters,\n fields,\n rangeFields,\n testIdPrefix,\n alwaysShowSearch,\n hasExport: props.exportConfig !== undefined,\n });\n return (\n <DataViewsLayoutProvider\n canUseCards={Boolean(renderCard)}\n canUseList={Boolean(renderListRow)}\n // The board reuses the entity's card, so it needs BOTH — a `board` with no\n // `renderCard` offers no board rather than throwing.\n canUseBoard={Boolean(board && renderCard)}\n defaultLayout={defaultLayout}\n ignoreStoredLayout={ignoreStoredLayout}\n viewLayout={c.state.layout}\n >\n <LayoutStateSync c={c} />\n <ShellStack props={props} filters={filters} />\n </DataViewsLayoutProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,WAAW,gBAAgB;AA6DhC,SAYI,KAZJ;AAXJ,SAAS,cAAc;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AACF,GAI6B;AAC3B,MAAI,CAAC,SAAS,CAAC,cAAe,QAAO;AACrC,SACE;AAAA,IAACA;AAAA,IAAA;AAAA,MACC,eAAa,GAAG,YAAY;AAAA,MAC5B,IAAI;AAAA,QACF,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,KAAK;AAAA,QACL,UAAU;AAAA,QACV,IAAI;AAAA,MACN;AAAA,MAEC;AAAA,gBACC,oBAAC,QAAK,SAAQ,WAAU,MAAK,MAAK,IAAG,MAClC,iBACH,IAEA,oBAACA,UAAA,EAAI;AAAA,QAEN,iBAAiB,oBAACA,UAAA,EAAI,IAAI,EAAE,SAAS,QAAQ,YAAY,UAAU,KAAK,EAAE,GAAI,yBAAc;AAAA;AAAA;AAAA,EAC/F;AAEJ;AAkBA,SAAS,gBAAmD;AAAA,EAC1D;AACF,GAES;AACP,QAAM,EAAE,OAAO,IAAI,mBAAmB;AACtC,QAAM,SAAS,EAAE,MAAM;AACvB,YAAU,MAAM;AACd,QAAI,WAAW,OAAQ,GAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EAE3C,GAAG,CAAC,QAAQ,MAAM,CAAC;AACnB,SAAO;AACT;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