@kumix/ui 0.3.7 → 0.3.9

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 (186) hide show
  1. package/README.md +26 -25
  2. package/dist/cascader-types-BnH6wYD-.d.ts +183 -0
  3. package/dist/cascader-types-BnH6wYD-.d.ts.map +1 -0
  4. package/dist/components/agents/ai-sidebar.js +3 -5
  5. package/dist/components/agents/ai-sidebar.js.map +1 -1
  6. package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
  7. package/dist/components/motion/animated-sidebar.js +12 -3
  8. package/dist/components/motion/animated-sidebar.js.map +1 -1
  9. package/dist/components/motion/attachment-upload.d.ts.map +1 -1
  10. package/dist/components/motion/attachment-upload.js +9 -5
  11. package/dist/components/motion/attachment-upload.js.map +1 -1
  12. package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
  13. package/dist/components/motion/bottom-sheet.js +77 -74
  14. package/dist/components/motion/bottom-sheet.js.map +1 -1
  15. package/dist/components/motion/center-morph-modal.d.ts.map +1 -1
  16. package/dist/components/motion/center-morph-modal.js +82 -88
  17. package/dist/components/motion/center-morph-modal.js.map +1 -1
  18. package/dist/components/motion/combobox/content.js +1 -1
  19. package/dist/components/motion/combobox/context.d.ts +6 -0
  20. package/dist/components/motion/combobox/context.d.ts.map +1 -1
  21. package/dist/components/motion/combobox/context.js +1 -233
  22. package/dist/components/motion/combobox/list.js +1 -1
  23. package/dist/components/motion/combobox/trigger.js +7 -8
  24. package/dist/components/motion/combobox/trigger.js.map +1 -1
  25. package/dist/components/motion/combobox.js +1 -1
  26. package/dist/components/motion/command-palette.d.ts.map +1 -1
  27. package/dist/components/motion/command-palette.js +62 -45
  28. package/dist/components/motion/command-palette.js.map +1 -1
  29. package/dist/components/motion/drawer.d.ts.map +1 -1
  30. package/dist/components/motion/drawer.js +30 -30
  31. package/dist/components/motion/drawer.js.map +1 -1
  32. package/dist/components/motion/loader.js +20 -22
  33. package/dist/components/motion/loader.js.map +1 -1
  34. package/dist/components/motion/morphing-modal.d.ts.map +1 -1
  35. package/dist/components/motion/morphing-modal.js +83 -83
  36. package/dist/components/motion/morphing-modal.js.map +1 -1
  37. package/dist/components/motion/morphing-search.d.ts +28 -0
  38. package/dist/components/motion/morphing-search.d.ts.map +1 -0
  39. package/dist/components/motion/morphing-search.js +422 -0
  40. package/dist/components/motion/morphing-search.js.map +1 -0
  41. package/dist/components/motion/project-folder.js +20 -20
  42. package/dist/components/motion/project-folder.js.map +1 -1
  43. package/dist/components/reui/alert.d.ts +1 -1
  44. package/dist/components/reui/badge.d.ts +1 -1
  45. package/dist/components/reui/cascader/cascader-async.d.ts +90 -0
  46. package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -0
  47. package/dist/components/reui/cascader/cascader-async.js +549 -0
  48. package/dist/components/reui/cascader/cascader-async.js.map +1 -0
  49. package/dist/components/reui/cascader/cascader-columns.d.ts +29 -0
  50. package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -0
  51. package/dist/components/reui/cascader/cascader-columns.js +135 -0
  52. package/dist/components/reui/cascader/cascader-columns.js.map +1 -0
  53. package/dist/components/reui/cascader/cascader-context.d.ts +193 -0
  54. package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -0
  55. package/dist/components/reui/cascader/cascader-context.js +59 -0
  56. package/dist/components/reui/cascader/cascader-context.js.map +1 -0
  57. package/dist/components/reui/cascader/cascader-footer.d.ts +85 -0
  58. package/dist/components/reui/cascader/cascader-footer.d.ts.map +1 -0
  59. package/dist/components/reui/cascader/cascader-footer.js +456 -0
  60. package/dist/components/reui/cascader/cascader-footer.js.map +1 -0
  61. package/dist/components/reui/cascader/cascader-i18n.d.ts +17 -0
  62. package/dist/components/reui/cascader/cascader-i18n.d.ts.map +1 -0
  63. package/dist/components/reui/cascader/cascader-i18n.js +68 -0
  64. package/dist/components/reui/cascader/cascader-i18n.js.map +1 -0
  65. package/dist/components/reui/cascader/cascader-item.d.ts +115 -0
  66. package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -0
  67. package/dist/components/reui/cascader/cascader-item.js +530 -0
  68. package/dist/components/reui/cascader/cascader-item.js.map +1 -0
  69. package/dist/components/reui/cascader/cascader-lib.d.ts +141 -0
  70. package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -0
  71. package/dist/components/reui/cascader/cascader-lib.js +576 -0
  72. package/dist/components/reui/cascader/cascader-lib.js.map +1 -0
  73. package/dist/components/reui/cascader/cascader-nav.d.ts +59 -0
  74. package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -0
  75. package/dist/components/reui/cascader/cascader-nav.js +312 -0
  76. package/dist/components/reui/cascader/cascader-nav.js.map +1 -0
  77. package/dist/components/reui/cascader/cascader-types.d.ts +2 -0
  78. package/dist/components/reui/cascader/cascader-types.js +2 -0
  79. package/dist/components/reui/cascader/cascader-virtual.d.ts +65 -0
  80. package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -0
  81. package/dist/components/reui/cascader/cascader-virtual.js +240 -0
  82. package/dist/components/reui/cascader/cascader-virtual.js.map +1 -0
  83. package/dist/components/reui/cascader/cascader.d.ts +322 -0
  84. package/dist/components/reui/cascader/cascader.d.ts.map +1 -0
  85. package/dist/components/reui/cascader/cascader.js +1459 -0
  86. package/dist/components/reui/cascader/cascader.js.map +1 -0
  87. package/dist/components/reui/event-calendar/event-calendar-event.d.ts +28 -47
  88. package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -1
  89. package/dist/components/reui/event-calendar/event-calendar-event.js +26 -44
  90. package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
  91. package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
  92. package/dist/components/reui/event-calendar/event-calendar-types.d.ts +19 -57
  93. package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -1
  94. package/dist/components/reui/filters/filters-advanced.d.ts +52 -0
  95. package/dist/components/reui/filters/filters-advanced.d.ts.map +1 -0
  96. package/dist/components/reui/filters/filters-advanced.js +1191 -0
  97. package/dist/components/reui/filters/filters-advanced.js.map +1 -0
  98. package/dist/components/reui/filters/filters-builder.d.ts +43 -0
  99. package/dist/components/reui/filters/filters-builder.d.ts.map +1 -0
  100. package/dist/components/reui/filters/filters-builder.js +152 -0
  101. package/dist/components/reui/filters/filters-builder.js.map +1 -0
  102. package/dist/components/reui/filters/filters-chip.d.ts +79 -0
  103. package/dist/components/reui/filters/filters-chip.d.ts.map +1 -0
  104. package/dist/components/reui/filters/filters-chip.js +553 -0
  105. package/dist/components/reui/filters/filters-chip.js.map +1 -0
  106. package/dist/components/reui/filters/filters-context.d.ts +290 -0
  107. package/dist/components/reui/filters/filters-context.d.ts.map +1 -0
  108. package/dist/components/reui/filters/filters-context.js +277 -0
  109. package/dist/components/reui/filters/filters-context.js.map +1 -0
  110. package/dist/components/reui/filters/filters-date.d.ts +43 -0
  111. package/dist/components/reui/filters/filters-date.d.ts.map +1 -0
  112. package/dist/components/reui/filters/filters-date.js +143 -0
  113. package/dist/components/reui/filters/filters-date.js.map +1 -0
  114. package/dist/components/reui/filters/filters-dnd.d.ts +101 -0
  115. package/dist/components/reui/filters/filters-dnd.d.ts.map +1 -0
  116. package/dist/components/reui/filters/filters-dnd.js +454 -0
  117. package/dist/components/reui/filters/filters-dnd.js.map +1 -0
  118. package/dist/components/reui/filters/filters-draft.d.ts +2 -0
  119. package/dist/components/reui/filters/filters-draft.js +128 -0
  120. package/dist/components/reui/filters/filters-draft.js.map +1 -0
  121. package/dist/components/reui/filters/filters-editors.d.ts +91 -0
  122. package/dist/components/reui/filters/filters-editors.d.ts.map +1 -0
  123. package/dist/components/reui/filters/filters-editors.js +773 -0
  124. package/dist/components/reui/filters/filters-editors.js.map +1 -0
  125. package/dist/components/reui/filters/filters-i18n.d.ts +24 -0
  126. package/dist/components/reui/filters/filters-i18n.d.ts.map +1 -0
  127. package/dist/components/reui/filters/filters-i18n.js +127 -0
  128. package/dist/components/reui/filters/filters-i18n.js.map +1 -0
  129. package/dist/components/reui/filters/filters-lib.d.ts +171 -0
  130. package/dist/components/reui/filters/filters-lib.d.ts.map +1 -0
  131. package/dist/components/reui/filters/filters-lib.js +336 -0
  132. package/dist/components/reui/filters/filters-lib.js.map +1 -0
  133. package/dist/components/reui/filters/filters-operators.d.ts +49 -0
  134. package/dist/components/reui/filters/filters-operators.d.ts.map +1 -0
  135. package/dist/components/reui/filters/filters-operators.js +300 -0
  136. package/dist/components/reui/filters/filters-operators.js.map +1 -0
  137. package/dist/components/reui/filters/filters-query.d.ts +132 -0
  138. package/dist/components/reui/filters/filters-query.d.ts.map +1 -0
  139. package/dist/components/reui/filters/filters-query.js +476 -0
  140. package/dist/components/reui/filters/filters-query.js.map +1 -0
  141. package/dist/components/reui/filters/filters-types.d.ts +452 -0
  142. package/dist/components/reui/filters/filters-types.d.ts.map +1 -0
  143. package/dist/components/reui/filters/filters-types.js +2 -0
  144. package/dist/components/reui/filters/filters.d.ts +114 -0
  145. package/dist/components/reui/filters/filters.d.ts.map +1 -0
  146. package/dist/components/reui/filters/filters.js +638 -0
  147. package/dist/components/reui/filters/filters.js.map +1 -0
  148. package/dist/components/reui/gantt/gantt-bar.js +1 -1
  149. package/dist/components/reui/gantt/gantt-nav.js +1 -1
  150. package/dist/components/reui/gantt/gantt-types.d.ts +25 -71
  151. package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
  152. package/dist/components/reui/gantt/gantt-view.js +1 -1
  153. package/dist/components/ui/button.d.ts +1 -1
  154. package/dist/components/ui/checkbox.js +1 -1
  155. package/dist/components/ui/checkbox.js.map +1 -1
  156. package/dist/components/ui/field.js +2 -2
  157. package/dist/components/ui/field.js.map +1 -1
  158. package/dist/components/ui/radio-group.js +1 -1
  159. package/dist/components/ui/radio-group.js.map +1 -1
  160. package/dist/components/ui/sidebar.js +1 -1
  161. package/dist/components/ui/switch.js +1 -1
  162. package/dist/components/ui/switch.js.map +1 -1
  163. package/dist/context-BizvUNZv.js +298 -0
  164. package/dist/context-BizvUNZv.js.map +1 -0
  165. package/dist/filters-draft-DEAl3TO-.d.ts +70 -0
  166. package/dist/filters-draft-DEAl3TO-.d.ts.map +1 -0
  167. package/dist/hooks/use-on-open.d.ts +18 -0
  168. package/dist/hooks/use-on-open.d.ts.map +1 -0
  169. package/dist/hooks/use-on-open.js +27 -0
  170. package/dist/hooks/use-on-open.js.map +1 -0
  171. package/dist/hooks/use-row-cursor.d.ts +39 -0
  172. package/dist/hooks/use-row-cursor.d.ts.map +1 -0
  173. package/dist/hooks/use-row-cursor.js +77 -0
  174. package/dist/hooks/use-row-cursor.js.map +1 -0
  175. package/dist/lib/text-shimmer.d.ts +2 -2
  176. package/dist/lib/text-shimmer.d.ts.map +1 -1
  177. package/dist/lib/text-shimmer.js +2 -2
  178. package/dist/lib/text-shimmer.js.map +1 -1
  179. package/dist/presence-gate-BekdC4Bo.js +24 -0
  180. package/dist/presence-gate-BekdC4Bo.js.map +1 -0
  181. package/package.json +11 -11
  182. package/dist/components/motion/combobox/context.js.map +0 -1
  183. package/dist/components/reui/filters.d.ts +0 -176
  184. package/dist/components/reui/filters.d.ts.map +0 -1
  185. package/dist/components/reui/filters.js +0 -1223
  186. package/dist/components/reui/filters.js.map +0 -1
@@ -0,0 +1,1191 @@
1
+ "use client";
2
+ import { Button } from "../../ui/button.js";
3
+ import { Input } from "../../ui/input.js";
4
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "../../ui/dropdown-menu.js";
5
+ import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
6
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../ui/tooltip.js";
7
+ import { FilterReorderProvider, filterControlSizes, filterReadOnlyProps, isFilterLocked, useFilterActions, useFilterChipAutoOpen, useFilterChipFocused, useFilterFocusEmpty, useFilterFocusStore, useFilterRender, useFilterReorderable, useFilterRowPending, useFilterRowStateStore, useFilterSegmentFocus, useFilterState } from "./filters-context.js";
8
+ import { FILTER_FIELD_PICKER_CLASS, FILTER_MENU_CLASS, FILTER_MENU_LABEL_CLASS, filterCombinatorSlot, getFilterField, isFilterFieldPickable, joinFilterPath } from "./filters-lib.js";
9
+ import { getFilterArity, getFilterOperator, operatorTakesValue } from "./filters-operators.js";
10
+ import { FilterFieldPicker } from "./filters-builder.js";
11
+ import { collectFilterIssues, createFilterRule, isFilterRule } from "./filters-query.js";
12
+ import { FilterMoveToMenuItems, FilterOperatorPopover, FilterRuleMenuItems, FilterValuePopover, useFilterRuleDisplay } from "./filters-chip.js";
13
+ import { FILTER_ROW_SELECTOR, useFilterRowDrag } from "./filters-dnd.js";
14
+ import { filterIssueLabel } from "./filters-i18n.js";
15
+ import * as React$1 from "react";
16
+ import { cn } from "@kumix/utils";
17
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
18
+ import { ChevronDownIcon, CircleAlertIcon, CopyIcon, EllipsisVerticalIcon, FolderPlusIcon, GripVerticalIcon, ListFilterIcon, PlusIcon, RefreshCwIcon, Trash2Icon, UngroupIcon, XIcon } from "lucide-react";
19
+ //#region src/components/reui/filters/filters-advanced.tsx
20
+ const CONTENT_COLUMNS = [
21
+ "combinator",
22
+ "field",
23
+ "operator",
24
+ "value"
25
+ ];
26
+ const ACTION_COLUMNS = [
27
+ "drag",
28
+ "menu",
29
+ "add",
30
+ "remove"
31
+ ];
32
+ /** The nearest column in `band` that `available` has; backward wins a tie. */
33
+ function nearestColumn(band, from, available) {
34
+ const at = band.indexOf(from);
35
+ if (at === -1) return void 0;
36
+ for (let step = 0; step < band.length; step++) {
37
+ const before = step === 0 ? void 0 : available.get(band[at - step] ?? "");
38
+ if (before) return before;
39
+ const after = available.get(band[at + step] ?? "");
40
+ if (after) return after;
41
+ }
42
+ }
43
+ /** Marks a focusable cell control, read by the keyboard walker. Not
44
+ * `data-slot`: a cell control is handed to a Base UI trigger through `render`,
45
+ * which stamps its own, so a slot here would be two owners on one attribute. */
46
+ const CELL_ATTRIBUTE = "data-filter-cell";
47
+ /** Marks a cell the user TYPES into: the builder claims the arrows, Home, End
48
+ * and Delete, and each means something else in a text box. */
49
+ const CELL_INPUT_ATTRIBUTE = "data-filter-cell-input";
50
+ const ROW_SELECTOR = FILTER_ROW_SELECTOR;
51
+ /** Hands every row's handle its pointer wiring: only the panel, which owns the
52
+ * body element, can measure a drop. */
53
+ const FilterDragContext = React$1.createContext(null);
54
+ /** What each node is missing, by id. An empty map by default, so a row mounted
55
+ * outside the shipped panel gets "nothing is wrong" instead of a throw. */
56
+ const FilterIssueContext = React$1.createContext(/* @__PURE__ */ new Map());
57
+ function cellProps(column, active) {
58
+ return {
59
+ "data-filter-cell": column,
60
+ tabIndex: active === column ? 0 : -1
61
+ };
62
+ }
63
+ /** What an INVALID cell wears: `aria-invalid` to announce it, `data-invalid`
64
+ * to style it, `aria-description` for the sentence. */
65
+ function issueProps(issue, column, message) {
66
+ if (!issue || issue.column !== column) return null;
67
+ return {
68
+ "aria-invalid": true,
69
+ "data-invalid": "",
70
+ "aria-description": message
71
+ };
72
+ }
73
+ /** Sera's uppercase and wide tracking cost about a third of a cell, so where
74
+ * every other style drew "migration" sera drew "MIGRATI...". */
75
+ const SERA_TEXT_CLASS = "";
76
+ const CELL_CLASS = cn("w-full min-w-0 justify-between gap-1.5 font-normal", "[&>svg]:text-muted-foreground", "@max-[7rem]/cell:gap-0 @max-[7rem]/cell:[&>svg]:hidden", "@max-[5rem]/cell:[&_span>svg]:hidden", SERA_TEXT_CLASS);
77
+ /** What an invalid cell looks like. A ring, not a border: a border changes the
78
+ * box, so a cell turning invalid would nudge every cell beside it. */
79
+ const CELL_INVALID_CLASS = "data-invalid:ring-destructive/40 data-invalid:ring-1";
80
+ /** Width of the leading combinator column. The 58.72px pill put this track at
81
+ * 4rem and it does not shrink now the pill has: it is sized for the longest of
82
+ * the three things in it, "Where", 51.44px in every style. */
83
+ const COMBINATOR_CLASS = cn("w-16 shrink-0 items-center justify-center", "me-1.5");
84
+ /** The two static words in that column, CENTRED because the pill's own
85
+ * `justify-center` centres its word. `w-full`, or `truncate` has no box. */
86
+ const COMBINATOR_TEXT_CLASS = cn("w-full truncate px-1 text-center text-muted-foreground text-sm", SERA_TEXT_CLASS);
87
+ /** A row is TWO BANDS. The trailing pair of every row at every depth shares one
88
+ * vertical axis - 0.00px of spread from 1104px to 240px, eight styles, depth
89
+ * three - and only because the content band may shrink to nothing. */
90
+ const ROW_BAND_CLASS = "flex min-w-0 items-center gap-1.5";
91
+ const CONTENT_BAND_CLASS = "flex min-w-0 flex-1 items-center gap-1.5";
92
+ /** FLEX and not a block: a `Button` is `inline-flex`, so a block wrapper builds
93
+ * a line box as tall as its font's strut - 28px buttons in 28.141px wrappers. */
94
+ const CELL_BOX_CLASS = "@container/cell flex min-w-0 shrink grow-0";
95
+ /** THE DEFAULT WIDTH OF EACH CONTENT CELL. An INLINE FALLBACK and not a
96
+ * declaration on the panel: declared, the panel would beat anything an ANCESTOR
97
+ * set, which is where a consumer sets it in popover mode. So all four work:
98
+ *
99
+ * <Filters variant="advanced" className="[--filter-field-width:14rem]" />
100
+ * <FiltersAdvancedPanel className="[--filter-operator-width:7rem]" />
101
+ * <Card className="[--filter-value-width:16rem]"><Filters … /></Card>
102
+ * [data-slot="filters-advanced"] { --filter-field-width: 14rem } */
103
+ const FIELD_CELL_CLASS = "basis-[var(--filter-field-width,11rem)]";
104
+ const OPERATOR_CELL_CLASS = "basis-[var(--filter-operator-width,9rem)]";
105
+ const VALUE_CELL_CLASS = "basis-[var(--filter-value-width,12rem)]";
106
+ /** The trailing band. `pe-1` is on the BAND and not the gutter, since a group
107
+ * card is `pe-0`; the footer and `DROP_SLOT_INDICATOR` restate the same four. */
108
+ const ACTION_BAND_CLASS = cn("flex shrink-0 items-center gap-0.5 pe-1 text-muted-foreground");
109
+ /** What the grip and the kebab wear while open. TWO ATTRIBUTES, because Radix
110
+ * sets `data-state="open"` and Base UI `data-popup-open`, so one selector alone
111
+ * would be dead in one twin, silently, in a byte-locked file. */
112
+ const ACTION_CONTROL_CLASS = cn("hover:inset-ring hover:inset-ring-border", "data-popup-open:inset-ring data-popup-open:inset-ring-border", "data-[state=open]:inset-ring data-[state=open]:inset-ring-border");
113
+ /** The gap between sibling rows, one third of one measurement:
114
+ * `FILTER_ROW_SEAM_PX` is HALF of it and the footer's `-mt-*` cancels it. */
115
+ const FILTER_ROW_GAP_CLASS = "gap-3";
116
+ const FILTER_ROW_GAP_CANCEL_CLASS = "-mt-3";
117
+ const FILTER_ROW_HALF_GAP_CLASS = {
118
+ before: "data-[drop-edge=before]:after:mb-[5px]",
119
+ after: "data-[drop-edge=after]:after:mt-[5px]"
120
+ };
121
+ /** POPOVER: the popover content is `p-0`, so this IS the popup's own inner
122
+ * padding. INLINE there is no popup, and a panel that pads itself as well is a
123
+ * second inset the page did not ask for. */
124
+ const PANEL_PAD_VAR = "--filter-panel-pad";
125
+ const PANEL_PAD_POPOVER = "0.75rem";
126
+ const PANEL_PAD_INLINE = "0px";
127
+ /** The panel's ONE horizontal rhythm: a row's trailing controls sit at the
128
+ * content edge, which IS this padding, so a footer that disagrees breaks it. */
129
+ const PANEL_GUTTER_CLASS = "px-(--filter-panel-pad)";
130
+ const PANEL_CLASS = "flex w-full min-w-0 flex-col gap-2 py-(--filter-panel-pad)";
131
+ /** A RING and not a border, the whole answer to the staggered trailing
132
+ * controls: a border pushes the content edge inward a pixel per level. */
133
+ const GROUP_CARD_CLASS = cn("min-w-0 flex-1 rounded-md bg-muted/40", "inset-ring inset-ring-border", "ps-2 pe-0", "data-invalid:inset-ring-destructive/50", "data-drop-into:bg-muted/60", "data-drop-into:outline-1 data-drop-into:outline-solid", "data-drop-into:outline-border data-drop-into:-outline-offset-2");
134
+ /** THE CONTAINER a row measures its own room against, on the panel body and on
135
+ * every group's list, so a row asks how wide the list it is IN is. */
136
+ const TRACK_CONTAINER_CLASS = "@container/track";
137
+ /** When a group stops putting its combinator BESIDE the card. A DEPTH budget
138
+ * was wrong both ways: at 380px the depth-three row painted zero pixels of
139
+ * field, operator and value and fanned the kebab column out by up to 119px.
140
+ * 26rem is what a row MEASURES: 134px of fixed cost plus about 200px of cells. */
141
+ const GROUP_COMBINATOR_WRAP_CLASS = "@max-[26rem]/track:w-full";
142
+ /** The combinator itself, once its wrapper has a whole line. Pinned to the
143
+ * same 4rem the gutter track is, so it is the same control at every width. */
144
+ const GROUP_COMBINATOR_WRAPPED_CLASS = "@max-[26rem]/track:w-16";
145
+ /** How a row shows where a dragged node would land. `data-drop-edge` is an
146
+ * insertion BETWEEN rows, drawn here; `data-drop-into` is painted on the CARD,
147
+ * so "inside this group" and "after this group" are not one picture. */
148
+ const DROP_SLOT_INDICATOR = cn("relative rounded-md", "data-dragging:opacity-60", "data-drop-edge:after:absolute", "data-drop-edge:after:start-0 data-drop-edge:after:end-1", "data-drop-edge:after:h-0.5 data-drop-edge:after:rounded-full", "data-drop-edge:after:bg-primary", "data-drop-edge:after:z-10", "data-[drop-edge=before]:after:bottom-full", FILTER_ROW_HALF_GAP_CLASS.before, "data-[drop-edge=after]:after:top-full", FILTER_ROW_HALF_GAP_CLASS.after);
149
+ /** What a CONDITION row draws, which is what a group's row draws: the slot and
150
+ * nothing else. It used to add a faint dashed outline of its own, a second
151
+ * dashed rectangle a few pixels from the first saying what it already said. */
152
+ const DROP_INDICATOR = DROP_SLOT_INDICATOR;
153
+ /** How the footer says "append to the top level": the same RULE the rows draw.
154
+ * `data-drop-into` and not `data-drop-edge`, because an explicit zone is a
155
+ * DESTINATION. Both ends restate the padding VARIABLE, since `inset` resolves
156
+ * against the PADDING box and `inset-x-0` overran every rule above it. */
157
+ const FOOTER_DROP_CLASS = cn("data-drop-into:after:absolute", "data-drop-into:after:start-(--filter-panel-pad)", "data-drop-into:after:end-[calc(var(--filter-panel-pad)+4px)]", "data-drop-into:after:top-0 data-drop-into:after:h-0.5", "data-drop-into:after:rounded-full data-drop-into:after:bg-primary");
158
+ /** The cells a row owns ITSELF: a group's row contains its children's rows, so
159
+ * a bare `querySelectorAll` would let ArrowRight walk into the first of them. */
160
+ function ownCells(row) {
161
+ return Array.from(row.querySelectorAll(`[${CELL_ATTRIBUTE}]`)).filter((cell) => cell.closest(ROW_SELECTOR) === row);
162
+ }
163
+ /** The leading and/or slot: one group is joined by ONE operator, and mixing is
164
+ * what a nested group is FOR. */
165
+ function CombinatorCell({ index, parentId, combinator, active, onFocus, className }) {
166
+ const actions = useFilterActions();
167
+ const sizes = filterControlSizes(actions);
168
+ const slot = filterCombinatorSlot(index);
169
+ const word = combinator === "and" ? actions.labels.and : actions.labels.or;
170
+ if (slot === "where") return /* @__PURE__ */ jsx("span", {
171
+ className: cn(COMBINATOR_TEXT_CLASS, className),
172
+ children: actions.labels.where
173
+ });
174
+ if (slot === "echo") return /* @__PURE__ */ jsx("span", {
175
+ className: cn(COMBINATOR_TEXT_CLASS, className),
176
+ children: word
177
+ });
178
+ const name = actions.labels.combinatorLabel(word);
179
+ return /* @__PURE__ */ jsxs(Button, {
180
+ variant: "outline",
181
+ size: sizes.button,
182
+ "aria-label": name,
183
+ title: name,
184
+ disabled: actions.disabled,
185
+ ...filterReadOnlyProps(actions),
186
+ className: cn("group/combinator relative w-full min-w-0 justify-center px-1.5 font-normal", SERA_TEXT_CLASS, className),
187
+ ...cellProps("combinator", active),
188
+ onFocus: onFocus("combinator"),
189
+ onClick: () => actions.toggleCombinator(parentId),
190
+ children: [/* @__PURE__ */ jsx("span", {
191
+ className: "truncate",
192
+ children: word
193
+ }), /* @__PURE__ */ jsx("span", {
194
+ "aria-hidden": "true",
195
+ className: cn("pointer-events-none absolute end-1 opacity-0 transition-opacity", "group-hover/combinator:opacity-60", "group-focus-visible/combinator:opacity-60", "[&_svg]:size-3"),
196
+ children: /* @__PURE__ */ jsx(RefreshCwIcon, {})
197
+ })]
198
+ });
199
+ }
200
+ /** Whether dragging this node could change the tree at all; the grip is drawn
201
+ * only when it could. Every destination outside the footer zone lives inside
202
+ * some row and the drop layer discards any inside the dragged one, so the sole
203
+ * child of the root is the one case with nowhere to go. A pure function of the
204
+ * QUERY, deliberately blind to `disabled` and `readOnly`: a locked bar keeps
205
+ * its grip, because "you may not move this" and "there is nowhere to move it"
206
+ * are different sentences. */
207
+ function canFilterNodeMove(query, position) {
208
+ if (position.parentId !== query.id) return true;
209
+ return query.rules.length > 1;
210
+ }
211
+ /** The error, as a QUIET mark the pointer can ask about: ONE per ROW, and
212
+ * `aria-hidden`, since the cell carries it as `aria-description`. */
213
+ function RowIssueHint({ message, className }) {
214
+ if (!message) return null;
215
+ return /* @__PURE__ */ jsx(TooltipProvider, {
216
+ delay: 200,
217
+ children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: /* @__PURE__ */ jsx("span", {
218
+ "data-slot": "filter-row-issue",
219
+ tabIndex: -1,
220
+ "aria-hidden": "true",
221
+ className: cn("flex shrink-0 items-center justify-center text-destructive [&_svg]:size-3.5", className),
222
+ children: /* @__PURE__ */ jsx(CircleAlertIcon, {})
223
+ }) }), /* @__PURE__ */ jsx(TooltipContent, {
224
+ side: "top",
225
+ children: message
226
+ })] })
227
+ });
228
+ }
229
+ /** The drag handle: what ARMS the gesture, since arming the row would turn
230
+ * every text selection into a drag, and the only thing a screen reader can be
231
+ * told about, which is why Alt+arrow hangs off it. */
232
+ function RowHandle({ nodeId, active, onFocus }) {
233
+ const actions = useFilterActions();
234
+ const sizes = filterControlSizes(actions);
235
+ const dragProps = React$1.useContext(FilterDragContext);
236
+ const locked = isFilterLocked(actions);
237
+ return /* @__PURE__ */ jsx(Button, {
238
+ variant: "ghost",
239
+ size: sizes.icon,
240
+ "aria-label": actions.labels.reorder,
241
+ "aria-keyshortcuts": "Alt+ArrowUp Alt+ArrowDown",
242
+ "aria-description": actions.labels.reorderHint,
243
+ disabled: actions.disabled,
244
+ ...filterReadOnlyProps(actions),
245
+ className: cn("cursor-grab touch-none focus-visible:text-foreground", "active:cursor-grabbing", ACTION_CONTROL_CLASS),
246
+ ...cellProps("drag", active),
247
+ onFocus: onFocus("drag"),
248
+ ...locked ? null : dragProps?.(nodeId),
249
+ children: /* @__PURE__ */ jsx(GripVerticalIcon, {})
250
+ });
251
+ }
252
+ /** Which cell of a row owns the builder's single tab stop. An operator change
253
+ * can take the value column out from under the focus pointing at it. */
254
+ function useActiveColumn(nodeId, columns, isFirstRow) {
255
+ const focused = useFilterChipFocused(nodeId);
256
+ const segment = useFilterSegmentFocus(nodeId);
257
+ const noFocus = useFilterFocusEmpty();
258
+ if (focused) return segment && columns.includes(segment) ? segment : columns[0];
259
+ return noFocus && isFirstRow ? columns[0] : null;
260
+ }
261
+ function useFilterIssue(nodeId) {
262
+ return React$1.useContext(FilterIssueContext).get(nodeId);
263
+ }
264
+ /** Whether a value is FREE TEXT, and therefore typed in the row itself. The
265
+ * CHIP row keeps its popover for every value, deliberately, which is why this
266
+ * lives here and not in the shared display hook. NUMBER is in: empty clears,
267
+ * and anything unparseable snaps back to the last committed number. */
268
+ function usesInlineTextEditor(field, operator, hasCustomDisplay) {
269
+ if (field.editor) return false;
270
+ if (field.options || field.loadOptions) return false;
271
+ if (field.renderValue || field.valueText || hasCustomDisplay) return false;
272
+ const type = field.type ?? "text";
273
+ if (type !== "text" && type !== "number") return false;
274
+ return getFilterArity(operator) === "one";
275
+ }
276
+ /** The value cell as a real text box. COMMIT IS BLUR AND ENTER: per keystroke
277
+ * makes the ROOT the source of truth for every character, and debouncing only
278
+ * adds a window where the cell and the query disagree with no event. */
279
+ function FilterInlineValueCell({ rule, field, issue, issueText, active, onFocus }) {
280
+ const actions = useFilterActions();
281
+ const focusStore = useFilterFocusStore();
282
+ const locked = isFilterLocked(actions);
283
+ const numeric = (field.type ?? "text") === "number";
284
+ const autoOpen = useFilterChipAutoOpen(rule.id) === "value";
285
+ const inputRef = React$1.useRef(null);
286
+ const committed = rule.value === void 0 || rule.value === null ? "" : String(rule.value);
287
+ const [draft, setDraft] = React$1.useState(committed);
288
+ const [seed, setSeed] = React$1.useState(committed);
289
+ if (seed !== committed) {
290
+ setSeed(committed);
291
+ setDraft(committed);
292
+ }
293
+ React$1.useEffect(() => {
294
+ if (!autoOpen) return;
295
+ if (!locked) {
296
+ const input = inputRef.current;
297
+ input?.focus();
298
+ input?.select();
299
+ }
300
+ focusStore.set({
301
+ id: rule.id,
302
+ segment: "value",
303
+ autoOpen: false
304
+ });
305
+ }, [
306
+ autoOpen,
307
+ locked,
308
+ focusStore,
309
+ rule.id
310
+ ]);
311
+ const commit = () => {
312
+ if (draft === seed) return;
313
+ if (numeric) {
314
+ const text = draft.trim();
315
+ if (text === "") {
316
+ actions.updateRule(rule.id, { value: void 0 });
317
+ return;
318
+ }
319
+ const parsed = Number(text);
320
+ if (!Number.isFinite(parsed)) {
321
+ setDraft(seed);
322
+ return;
323
+ }
324
+ actions.updateRule(rule.id, { value: parsed });
325
+ return;
326
+ }
327
+ actions.updateRule(rule.id, { value: draft });
328
+ };
329
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Input, {
330
+ ref: inputRef,
331
+ "aria-label": field.label,
332
+ placeholder: field.placeholder ?? actions.labels.valuePlaceholder,
333
+ inputMode: numeric ? "decimal" : void 0,
334
+ value: draft,
335
+ className: cn("h-full", issueText && "pe-7", CELL_INVALID_CLASS),
336
+ readOnly: locked,
337
+ disabled: actions.disabled,
338
+ ...filterReadOnlyProps(actions),
339
+ ...cellProps("value", active),
340
+ [CELL_INPUT_ATTRIBUTE]: "",
341
+ ...issueProps(issue, "value", issueText),
342
+ onFocus: onFocus("value"),
343
+ onChange: (event) => setDraft(event.target.value),
344
+ onBlur: commit,
345
+ onKeyDown: (event) => {
346
+ if (event.key === "Enter" && !event.nativeEvent.isComposing) {
347
+ event.preventDefault();
348
+ commit();
349
+ return;
350
+ }
351
+ if (event.key === "Escape") {
352
+ if (draft === seed) return;
353
+ event.preventDefault();
354
+ event.stopPropagation();
355
+ setDraft(seed);
356
+ }
357
+ }
358
+ }), /* @__PURE__ */ jsx(RowIssueHint, {
359
+ message: issueText,
360
+ className: "pointer-events-none absolute end-2 top-1/2 -translate-y-1/2 *:pointer-events-auto"
361
+ })] });
362
+ }
363
+ function FilterAdvancedRowImpl({ rule, position }) {
364
+ const actions = useFilterActions();
365
+ const render = useFilterRender();
366
+ const sizes = filterControlSizes(actions);
367
+ const focusStore = useFilterFocusStore();
368
+ const locked = isFilterLocked(actions);
369
+ const { query } = useFilterState();
370
+ const field = getFilterField(actions.index, rule.path);
371
+ const operators = field ? actions.resolveOperators(field) : [];
372
+ const operator = getFilterOperator(operators, rule.operator);
373
+ const takesValue = Boolean(rule.operator) && operatorTakesValue(operator);
374
+ const inlineValue = takesValue && field ? usesInlineTextEditor(field, operator, Boolean(render.renderValue)) : false;
375
+ const issue = useFilterIssue(rule.id);
376
+ const issueText = issue ? filterIssueLabel(issue, actions.labels) : "";
377
+ const { pathText, pathLabel, pathCollapsed, operatorLabel, valueLabel, valueText, valueFullText, valueEmpty } = useFilterRuleDisplay(rule, field, operator);
378
+ const fieldAutoOpen = useFilterChipAutoOpen(rule.id) === "field";
379
+ const [pickerOpen, setPickerOpen] = React$1.useState(false);
380
+ const [menuOpen, setMenuOpen] = React$1.useState(false);
381
+ const [pickerPath, setPickerPath] = React$1.useState(() => rule.path.slice(0, -1));
382
+ const [pickerQuery, setPickerQuery] = React$1.useState("");
383
+ React$1.useEffect(() => {
384
+ if (!fieldAutoOpen || pickerOpen) return;
385
+ if (!locked) setPickerOpen(true);
386
+ focusStore.set({
387
+ id: rule.id,
388
+ segment: "field",
389
+ autoOpen: false
390
+ });
391
+ }, [
392
+ fieldAutoOpen,
393
+ pickerOpen,
394
+ locked,
395
+ focusStore,
396
+ rule.id
397
+ ]);
398
+ React$1.useEffect(() => {
399
+ if (!pickerOpen) return;
400
+ setPickerPath(rule.path.slice(0, -1));
401
+ setPickerQuery("");
402
+ }, [pickerOpen, rule.path]);
403
+ const slot = filterCombinatorSlot(position.index);
404
+ const canMove = useFilterReorderable() && canFilterNodeMove(query, position);
405
+ const rowStateStore = useFilterRowStateStore();
406
+ const pending = useFilterRowPending(rule.id);
407
+ const columns = React$1.useMemo(() => {
408
+ const list = [];
409
+ if (slot === "toggle") list.push("combinator");
410
+ list.push("field");
411
+ if (!pending) {
412
+ list.push("operator");
413
+ if (takesValue) list.push("value");
414
+ }
415
+ if (canMove) list.push("drag");
416
+ list.push("menu");
417
+ return list;
418
+ }, [
419
+ slot,
420
+ takesValue,
421
+ canMove,
422
+ pending
423
+ ]);
424
+ const active = useActiveColumn(rule.id, columns, position.depth === 1 && position.index === 0);
425
+ const onCellFocus = React$1.useCallback((column) => () => focusStore.set({
426
+ id: rule.id,
427
+ segment: column,
428
+ autoOpen: false
429
+ }), [focusStore, rule.id]);
430
+ if (!field) return null;
431
+ return /* @__PURE__ */ jsxs("div", {
432
+ role: "group",
433
+ "aria-label": actions.labels.rowLabel(`${pathText} ${operatorLabel}`, position.depth),
434
+ "data-slot": "filter-row",
435
+ "data-node-id": rule.id,
436
+ "data-parent-id": position.parentId,
437
+ "data-index": position.index,
438
+ "data-depth": position.depth,
439
+ className: cn("group/row", ROW_BAND_CLASS, DROP_INDICATOR),
440
+ children: [
441
+ /* @__PURE__ */ jsx("div", {
442
+ className: cn(COMBINATOR_CLASS, CELL_BOX_CLASS),
443
+ children: /* @__PURE__ */ jsx(CombinatorCell, {
444
+ index: position.index,
445
+ parentId: position.parentId,
446
+ combinator: position.combinator,
447
+ active,
448
+ onFocus: onCellFocus
449
+ })
450
+ }),
451
+ /* @__PURE__ */ jsxs("div", {
452
+ className: CONTENT_BAND_CLASS,
453
+ children: [
454
+ /* @__PURE__ */ jsx("div", {
455
+ className: cn(CELL_BOX_CLASS, FIELD_CELL_CLASS),
456
+ children: /* @__PURE__ */ jsxs(Popover, {
457
+ open: pickerOpen,
458
+ onOpenChange: (next) => {
459
+ if (next && locked) return;
460
+ setPickerOpen(next);
461
+ },
462
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
463
+ disabled: actions.disabled,
464
+ ...filterReadOnlyProps(actions),
465
+ render: /* @__PURE__ */ jsxs(Button, {
466
+ variant: "outline",
467
+ size: sizes.button,
468
+ "aria-label": pathText,
469
+ title: pathCollapsed ? void 0 : pathText,
470
+ className: CELL_CLASS,
471
+ ...cellProps("field", active),
472
+ onFocus: onCellFocus("field"),
473
+ children: [/* @__PURE__ */ jsxs("span", {
474
+ className: "flex min-w-0 items-center gap-1.5 truncate",
475
+ children: [field.icon, /* @__PURE__ */ jsx("span", {
476
+ className: "truncate",
477
+ children: pathLabel
478
+ })]
479
+ }), /* @__PURE__ */ jsx(ChevronDownIcon, {})]
480
+ })
481
+ }), /* @__PURE__ */ jsx(PopoverContent, {
482
+ align: "start",
483
+ className: cn(FILTER_FIELD_PICKER_CLASS, actions.fieldPickerClassName),
484
+ children: /* @__PURE__ */ jsx(FilterFieldPicker, {
485
+ path: pickerPath,
486
+ onPathChange: setPickerPath,
487
+ query: pickerQuery,
488
+ onQueryChange: setPickerQuery,
489
+ onSelect: (path, defaultOperator) => {
490
+ setPickerOpen(false);
491
+ focusStore.set({
492
+ id: rule.id,
493
+ segment: pending ? "operator" : "field",
494
+ autoOpen: pending
495
+ });
496
+ rowStateStore.resolvePending(rule.id);
497
+ if (joinFilterPath(path) === joinFilterPath(rule.path)) return;
498
+ actions.updateRule(rule.id, {
499
+ path,
500
+ operator: pending ? "" : defaultOperator ?? "",
501
+ value: void 0
502
+ });
503
+ }
504
+ })
505
+ })]
506
+ })
507
+ }),
508
+ pending ? null : /* @__PURE__ */ jsx("div", {
509
+ className: cn(CELL_BOX_CLASS, OPERATOR_CELL_CLASS),
510
+ children: /* @__PURE__ */ jsx(FilterOperatorPopover, {
511
+ rule,
512
+ field,
513
+ trigger: /* @__PURE__ */ jsxs(Button, {
514
+ variant: "outline",
515
+ size: sizes.button,
516
+ title: operatorLabel,
517
+ className: cn(CELL_CLASS, CELL_INVALID_CLASS, "text-muted-foreground"),
518
+ ...cellProps("operator", active),
519
+ ...issueProps(issue, "operator", issueText),
520
+ onFocus: onCellFocus("operator"),
521
+ children: [/* @__PURE__ */ jsx("span", {
522
+ className: "truncate",
523
+ children: operatorLabel
524
+ }), /* @__PURE__ */ jsx(ChevronDownIcon, {})]
525
+ })
526
+ })
527
+ }),
528
+ pending ? null : /* @__PURE__ */ jsx("div", {
529
+ className: cn(CELL_BOX_CLASS, VALUE_CELL_CLASS, "relative", "self-stretch"),
530
+ children: takesValue ? inlineValue ? /* @__PURE__ */ jsx(FilterInlineValueCell, {
531
+ rule,
532
+ field,
533
+ issue,
534
+ issueText,
535
+ active,
536
+ onFocus: onCellFocus
537
+ }) : /* @__PURE__ */ jsx(FilterValuePopover, {
538
+ rule,
539
+ field,
540
+ operator,
541
+ trigger: /* @__PURE__ */ jsxs(Button, {
542
+ variant: "outline",
543
+ size: sizes.button,
544
+ "aria-label": locked ? valueFullText : valueText,
545
+ title: valueFullText,
546
+ className: cn(CELL_CLASS, CELL_INVALID_CLASS, "h-full", valueEmpty && "text-muted-foreground"),
547
+ ...cellProps("value", active),
548
+ ...issueProps(issue, "value", issueText),
549
+ onFocus: onCellFocus("value"),
550
+ children: [/* @__PURE__ */ jsx("span", {
551
+ className: "min-w-0 flex-1 truncate text-start",
552
+ children: valueLabel
553
+ }), /* @__PURE__ */ jsx(RowIssueHint, { message: issueText })]
554
+ })
555
+ }) : null
556
+ })
557
+ ]
558
+ }),
559
+ /* @__PURE__ */ jsxs("div", {
560
+ className: ACTION_BAND_CLASS,
561
+ children: [canMove ? /* @__PURE__ */ jsx(RowHandle, {
562
+ nodeId: rule.id,
563
+ active,
564
+ onFocus: onCellFocus
565
+ }) : null, /* @__PURE__ */ jsxs(DropdownMenu, {
566
+ open: menuOpen,
567
+ onOpenChange: (next) => {
568
+ if (next && locked) return;
569
+ setMenuOpen(next);
570
+ },
571
+ children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
572
+ disabled: actions.disabled,
573
+ ...filterReadOnlyProps(actions),
574
+ render: /* @__PURE__ */ jsx(Button, {
575
+ variant: "ghost",
576
+ size: sizes.icon,
577
+ "aria-label": actions.labels.chipMenu(field.label),
578
+ className: ACTION_CONTROL_CLASS,
579
+ ...cellProps("menu", active),
580
+ onFocus: onCellFocus("menu")
581
+ }),
582
+ children: /* @__PURE__ */ jsx(EllipsisVerticalIcon, {})
583
+ }), /* @__PURE__ */ jsx(DropdownMenuContent, {
584
+ align: "end",
585
+ className: cn(FILTER_MENU_CLASS, actions.menuClassName),
586
+ children: /* @__PURE__ */ jsx(FilterRuleMenuItems, {
587
+ ruleId: rule.id,
588
+ allowGrouping: true
589
+ })
590
+ })]
591
+ })]
592
+ })
593
+ ]
594
+ });
595
+ }
596
+ /** One rule, as a row, memoized: the query tree shares structure, so editing
597
+ * one row of twenty re-renders one. */
598
+ const FilterAdvancedRow = React$1.memo(FilterAdvancedRowImpl);
599
+ /** A rule whose field the schema no longer has: dropping it would lose a saved
600
+ * view's data, rendering nothing would leave it filtering invisibly. */
601
+ function FilterUnknownRow({ rule, position }) {
602
+ const actions = useFilterActions();
603
+ const sizes = filterControlSizes(actions);
604
+ return /* @__PURE__ */ jsxs("div", {
605
+ role: "group",
606
+ "aria-label": actions.labels.rowLabel(rule.path.join(actions.labels.pathSeparator), position.depth),
607
+ "data-slot": "filter-row",
608
+ "data-node-id": rule.id,
609
+ "data-parent-id": position.parentId,
610
+ "data-index": position.index,
611
+ "data-depth": position.depth,
612
+ "data-unknown": "",
613
+ className: cn(ROW_BAND_CLASS, DROP_INDICATOR),
614
+ children: [/* @__PURE__ */ jsx("span", {
615
+ className: "min-w-0 flex-1 truncate text-muted-foreground text-sm",
616
+ children: rule.path.join(actions.labels.pathSeparator)
617
+ }), /* @__PURE__ */ jsx("div", {
618
+ className: ACTION_BAND_CLASS,
619
+ children: /* @__PURE__ */ jsx(Button, {
620
+ variant: "ghost",
621
+ size: sizes.icon,
622
+ "aria-label": actions.labels.remove,
623
+ className: ACTION_CONTROL_CLASS,
624
+ "data-filter-cell": "remove",
625
+ disabled: actions.disabled,
626
+ ...filterReadOnlyProps(actions),
627
+ onClick: () => actions.removeNode(rule.id),
628
+ children: /* @__PURE__ */ jsx(XIcon, {})
629
+ })
630
+ })]
631
+ });
632
+ }
633
+ /** A nested group: an indented card, its conditions, and one way to add
634
+ * another. The HEADLINE went; the pill outside already says "or". */
635
+ function FilterAdvancedGroup({ group, position }) {
636
+ const actions = useFilterActions();
637
+ const sizes = filterControlSizes(actions);
638
+ const focusStore = useFilterFocusStore();
639
+ const { query } = useFilterState();
640
+ const issue = useFilterIssue(group.id);
641
+ const issueText = issue ? filterIssueLabel(issue, actions.labels) : "";
642
+ const canMove = useFilterReorderable() && canFilterNodeMove(query, position);
643
+ const rowStateStore = useFilterRowStateStore();
644
+ const slot = filterCombinatorSlot(position.index);
645
+ const columns = React$1.useMemo(() => {
646
+ const list = [];
647
+ if (slot === "toggle") list.push("combinator");
648
+ list.push("add");
649
+ if (canMove) list.push("drag");
650
+ list.push("menu");
651
+ return list;
652
+ }, [slot, canMove]);
653
+ const active = useActiveColumn(group.id, columns, position.depth === 1 && position.index === 0);
654
+ const onCellFocus = React$1.useCallback((column) => () => focusStore.set({
655
+ id: group.id,
656
+ segment: column,
657
+ autoOpen: false
658
+ }), [focusStore, group.id]);
659
+ const description = group.combinator === "and" ? actions.labels.groupAll : actions.labels.groupAny;
660
+ const addInto = () => {
661
+ const id = addFilterRow(actions, group.id);
662
+ if (!id) return;
663
+ rowStateStore.markPending(id);
664
+ focusStore.set({
665
+ id,
666
+ segment: "field",
667
+ autoOpen: true
668
+ });
669
+ };
670
+ return /* @__PURE__ */ jsxs("div", {
671
+ role: "group",
672
+ "aria-label": actions.labels.groupLabel(description, position.depth),
673
+ "data-slot": "filter-row",
674
+ "data-node-id": group.id,
675
+ "data-parent-id": position.parentId,
676
+ "data-index": position.index,
677
+ "data-depth": position.depth,
678
+ className: cn("flex flex-wrap items-center gap-1.5", DROP_SLOT_INDICATOR),
679
+ children: [/* @__PURE__ */ jsx("div", {
680
+ className: cn(COMBINATOR_CLASS, CELL_BOX_CLASS, GROUP_COMBINATOR_WRAP_CLASS),
681
+ children: /* @__PURE__ */ jsx(CombinatorCell, {
682
+ index: position.index,
683
+ parentId: position.parentId,
684
+ combinator: position.combinator,
685
+ active,
686
+ onFocus: onCellFocus,
687
+ className: GROUP_COMBINATOR_WRAPPED_CLASS
688
+ })
689
+ }), /* @__PURE__ */ jsxs("div", {
690
+ "data-slot": "filter-group",
691
+ "data-invalid": issue ? "" : void 0,
692
+ className: GROUP_CARD_CLASS,
693
+ children: [
694
+ /* @__PURE__ */ jsx("div", {
695
+ "data-slot": "filter-group-header",
696
+ className: "flex h-2 items-center",
697
+ "data-drop-parent": group.id,
698
+ "data-drop-index": 0
699
+ }),
700
+ /* @__PURE__ */ jsx("div", {
701
+ className: cn(TRACK_CONTAINER_CLASS, "flex flex-col", FILTER_ROW_GAP_CLASS),
702
+ children: group.rules.length === 0 ? /* @__PURE__ */ jsx("p", {
703
+ className: cn("rounded-md border border-dashed px-2 py-3 text-foreground/70", "text-center text-xs", "data-drop-into:border-primary/60 data-drop-into:bg-primary/5", "data-drop-into:text-primary"),
704
+ "data-slot": "filter-group-empty",
705
+ "data-drop-parent": group.id,
706
+ "data-drop-index": 0,
707
+ children: actions.labels.groupPlaceholder
708
+ }) : group.rules.map((node, index) => /* @__PURE__ */ jsx(FilterAdvancedNode, {
709
+ node,
710
+ position: {
711
+ index,
712
+ parentId: group.id,
713
+ combinator: group.combinator,
714
+ depth: position.depth + 1
715
+ }
716
+ }, node.id))
717
+ }),
718
+ /* @__PURE__ */ jsxs("div", {
719
+ "data-slot": "filter-group-footer",
720
+ className: "flex flex-nowrap items-center gap-2 pt-2 pb-2 text-muted-foreground",
721
+ "data-drop-parent": group.id,
722
+ "data-drop-index": group.rules.length,
723
+ children: [/* @__PURE__ */ jsxs(Button, {
724
+ variant: "outline",
725
+ size: sizes.button,
726
+ "aria-label": actions.labels.addToGroup,
727
+ className: cn("min-w-0 shrink font-normal", "overflow-hidden", CELL_INVALID_CLASS),
728
+ disabled: actions.disabled,
729
+ ...filterReadOnlyProps(actions),
730
+ ...cellProps("add", active),
731
+ ...issueProps(issue, "group", issueText),
732
+ onFocus: onCellFocus("add"),
733
+ onClick: addInto,
734
+ children: [/* @__PURE__ */ jsx(PlusIcon, {}), actions.labels.addCondition]
735
+ }), /* @__PURE__ */ jsxs("div", {
736
+ className: cn("ms-auto", ACTION_BAND_CLASS),
737
+ children: [canMove ? /* @__PURE__ */ jsx(RowHandle, {
738
+ nodeId: group.id,
739
+ active,
740
+ onFocus: onCellFocus
741
+ }) : null, /* @__PURE__ */ jsx(FilterGroupMenu, {
742
+ group,
743
+ active,
744
+ onFocus: onCellFocus
745
+ })]
746
+ })]
747
+ })
748
+ ]
749
+ })]
750
+ });
751
+ }
752
+ /** A group's kebab. A menu row affords six words, where two icons said none. */
753
+ function FilterGroupMenu({ group, active, onFocus }) {
754
+ const actions = useFilterActions();
755
+ const sizes = filterControlSizes(actions);
756
+ const locked = isFilterLocked(actions);
757
+ const [open, setOpen] = React$1.useState(false);
758
+ return /* @__PURE__ */ jsxs(DropdownMenu, {
759
+ open,
760
+ onOpenChange: (next) => {
761
+ if (next && locked) return;
762
+ setOpen(next);
763
+ },
764
+ children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
765
+ disabled: actions.disabled,
766
+ ...filterReadOnlyProps(actions),
767
+ render: /* @__PURE__ */ jsx(Button, {
768
+ variant: "ghost",
769
+ size: sizes.icon,
770
+ "aria-label": actions.labels.groupMenu,
771
+ className: ACTION_CONTROL_CLASS,
772
+ ...cellProps("menu", active),
773
+ onFocus: onFocus("menu")
774
+ }),
775
+ children: /* @__PURE__ */ jsx(EllipsisVerticalIcon, {})
776
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
777
+ align: "end",
778
+ className: cn(FILTER_MENU_CLASS, actions.menuClassName),
779
+ children: [
780
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
781
+ disabled: locked,
782
+ onClick: () => actions.duplicateNode(group.id),
783
+ children: [/* @__PURE__ */ jsx(CopyIcon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", {
784
+ className: FILTER_MENU_LABEL_CLASS,
785
+ children: actions.labels.duplicate
786
+ })]
787
+ }),
788
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
789
+ disabled: locked,
790
+ onClick: () => actions.unwrapGroup(group.id),
791
+ children: [/* @__PURE__ */ jsx(UngroupIcon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", {
792
+ className: FILTER_MENU_LABEL_CLASS,
793
+ children: actions.labels.ungroup
794
+ })]
795
+ }),
796
+ /* @__PURE__ */ jsx(FilterMoveToMenuItems, { nodeId: group.id }),
797
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
798
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
799
+ variant: "destructive",
800
+ disabled: locked,
801
+ onClick: () => actions.removeNode(group.id),
802
+ children: [/* @__PURE__ */ jsx(Trash2Icon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", {
803
+ className: FILTER_MENU_LABEL_CLASS,
804
+ children: actions.labels.removeGroup
805
+ })]
806
+ })
807
+ ]
808
+ })]
809
+ });
810
+ }
811
+ function FilterAdvancedNode({ node, position }) {
812
+ const actions = useFilterActions();
813
+ if (!isFilterRule(node)) return /* @__PURE__ */ jsx(FilterAdvancedGroup, {
814
+ group: node,
815
+ position
816
+ });
817
+ if (!getFilterField(actions.index, node.path)) return /* @__PURE__ */ jsx(FilterUnknownRow, {
818
+ rule: node,
819
+ position
820
+ });
821
+ return /* @__PURE__ */ jsx(FilterAdvancedRow, {
822
+ rule: node,
823
+ position
824
+ });
825
+ }
826
+ /** Appends a condition on the first attribute anyone may filter on, at any
827
+ * depth. `isFilterFieldPickable` is the picker's own rule. */
828
+ function addFilterRow(actions, parentId) {
829
+ if (isFilterLocked(actions)) return null;
830
+ const entry = actions.index.all.find((candidate) => isFilterFieldPickable(candidate.field));
831
+ if (!entry) return null;
832
+ const id = actions.nextId();
833
+ actions.addRule(createFilterRule({
834
+ id,
835
+ path: entry.path,
836
+ operator: ""
837
+ }), parentId);
838
+ return id;
839
+ }
840
+ /** The builder itself: nested groups over the query tree the chips read. A
841
+ * group is a parenthesised list joined by ONE operator, so nesting is a real
842
+ * tree: a flat model cannot represent `a AND (b OR c)` without inventing
843
+ * precedence, and invented precedence returns the wrong rows. */
844
+ function FiltersAdvancedPanel({ mode = "popover", renderEmpty, reorderable = false, className }) {
845
+ const actions = useFilterActions();
846
+ const panelRender = useFilterRender();
847
+ const sizes = filterControlSizes(actions);
848
+ const { query, ruleCount, announcement, announcementSeq } = useFilterState();
849
+ const focusStore = useFilterFocusStore();
850
+ const rowStateStore = useFilterRowStateStore();
851
+ const bodyRef = React$1.useRef(null);
852
+ const locked = isFilterLocked(actions);
853
+ /** What is unfinished, computed ONCE: an empty group is a fact about a
854
+ * group, not about any row inside it. */
855
+ const issues = React$1.useMemo(() => collectFilterIssues(query, (rule) => {
856
+ const field = getFilterField(actions.index, rule.path);
857
+ if (!field) return null;
858
+ return getFilterArity(getFilterOperator(actions.resolveOperators(field), rule.operator));
859
+ }, (rule) => {
860
+ const field = getFilterField(actions.index, rule.path);
861
+ if (!field?.validate) return null;
862
+ const operator = getFilterOperator(actions.resolveOperators(field), rule.operator);
863
+ if (!operator) return null;
864
+ return field.validate({
865
+ value: rule.value,
866
+ values: rule.value === void 0 || rule.value === null ? [] : Array.isArray(rule.value) ? rule.value : [rule.value],
867
+ field,
868
+ operator,
869
+ arity: getFilterArity(operator) ?? "one",
870
+ rule,
871
+ labels: actions.labels
872
+ });
873
+ }), [query, actions]);
874
+ /** The issues a row may DRAW: the ones on a value committed once. */
875
+ const visibleIssueMap = React$1.useMemo(() => {
876
+ const visible = /* @__PURE__ */ new Map();
877
+ for (const issue of issues) {
878
+ if (issue.reason !== "custom") continue;
879
+ if (rowStateStore.has(issue.nodeId)) visible.set(issue.nodeId, issue);
880
+ }
881
+ return visible;
882
+ }, [issues, rowStateStore]);
883
+ /** Says out loud that a VISIBLE error has appeared, which would
884
+ * otherwise happen in silence. The DRAWN issues, on a RISE only. */
885
+ const announcedIssues = React$1.useRef({
886
+ count: visibleIssueMap.size,
887
+ seq: announcementSeq
888
+ });
889
+ React$1.useEffect(() => {
890
+ const before = announcedIssues.current;
891
+ announcedIssues.current = {
892
+ count: visibleIssueMap.size,
893
+ seq: announcementSeq
894
+ };
895
+ if (announcementSeq !== before.seq) return;
896
+ if (visibleIssueMap.size <= before.count) return;
897
+ actions.announce(actions.labels.issueSummary(visibleIssueMap.size));
898
+ }, [
899
+ visibleIssueMap,
900
+ announcementSeq,
901
+ actions
902
+ ]);
903
+ /** Whether the panel, or a menu of its own, held focus a moment ago. A
904
+ * blur WITH a `relatedTarget` is focus arriving somewhere real; a blur
905
+ * with none, or none at all when the element is simply removed, is what
906
+ * this exists to repair. */
907
+ const heldFocus = React$1.useRef(false);
908
+ const addRowRef = React$1.useRef(null);
909
+ /** Puts focus back after a mutation that destroyed the thing holding it:
910
+ * measured at 50, 200, 600 and 1200ms after Convert to group, Remove,
911
+ * Ungroup and Move to group, `document.activeElement` was the BODY,
912
+ * because a menu restores focus to a trigger the action unmounted. */
913
+ const restoreFocus = React$1.useCallback(() => {
914
+ if (focusStore.getSnapshot().autoOpen) return;
915
+ if (!heldFocus.current) return;
916
+ const active = document.activeElement;
917
+ if (active && active !== document.body) return;
918
+ const rows = Array.from(bodyRef.current?.querySelectorAll(ROW_SELECTOR) ?? []);
919
+ const { id, segment } = focusStore.getSnapshot();
920
+ const row = id ? rows.find((candidate) => candidate.dataset.nodeId === id) : void 0;
921
+ const cells = row ? ownCells(row) : [];
922
+ (cells.find((entry) => entry.getAttribute(CELL_ATTRIBUTE) === segment) ?? cells[0] ?? (rows[0] ? ownCells(rows[0])[0] : void 0) ?? addRowRef.current ?? void 0)?.focus();
923
+ }, [focusStore]);
924
+ React$1.useEffect(() => {
925
+ restoreFocus();
926
+ }, [restoreFocus]);
927
+ const addRow = React$1.useCallback(() => {
928
+ const id = addFilterRow(actions);
929
+ if (!id) return;
930
+ rowStateStore.markPending(id);
931
+ focusStore.set({
932
+ id,
933
+ segment: "field",
934
+ autoOpen: true
935
+ });
936
+ }, [
937
+ actions,
938
+ focusStore,
939
+ rowStateStore
940
+ ]);
941
+ const addGroup = React$1.useCallback(() => {
942
+ const id = actions.addGroup();
943
+ if (!id) return;
944
+ focusStore.set({
945
+ id,
946
+ segment: "add",
947
+ autoOpen: false
948
+ });
949
+ }, [actions, focusStore]);
950
+ const onKeyDown = (event) => {
951
+ const cell = event.target.closest(`[${CELL_ATTRIBUTE}]`);
952
+ if (!cell || event.target !== cell) return;
953
+ const body = bodyRef.current;
954
+ const row = cell.closest(ROW_SELECTOR);
955
+ if (!body || !row) return;
956
+ const editing = cell.hasAttribute(CELL_INPUT_ATTRIBUTE);
957
+ const rows = Array.from(body.querySelectorAll(ROW_SELECTOR));
958
+ const cells = ownCells(row);
959
+ const rowIndex = rows.indexOf(row);
960
+ const cellIndex = cells.indexOf(cell);
961
+ const rtl = getComputedStyle(cell).direction === "rtl";
962
+ const forward = rtl ? "ArrowLeft" : "ArrowRight";
963
+ const backward = rtl ? "ArrowRight" : "ArrowLeft";
964
+ const focus = (target) => {
965
+ if (!target) return;
966
+ event.preventDefault();
967
+ target.focus();
968
+ };
969
+ const from = cell.getAttribute(CELL_ATTRIBUTE);
970
+ const band = CONTENT_COLUMNS.includes(from) ? CONTENT_COLUMNS : ACTION_COLUMNS;
971
+ const bandRows = [];
972
+ const seen = /* @__PURE__ */ new Set();
973
+ for (const entry of body.querySelectorAll(`[${CELL_ATTRIBUTE}]`)) {
974
+ const column = entry.getAttribute(CELL_ATTRIBUTE);
975
+ if (!band.includes(column)) continue;
976
+ const owner = entry.closest(ROW_SELECTOR);
977
+ if (!owner || seen.has(owner)) continue;
978
+ seen.add(owner);
979
+ bandRows.push(owner);
980
+ }
981
+ const bandIndex = bandRows.indexOf(row);
982
+ const focusRow = (step) => {
983
+ const nextRow = bandRows[bandIndex + step];
984
+ if (!nextRow) return;
985
+ const cellsThere = ownCells(nextRow);
986
+ const byColumn = new Map(cellsThere.map((entry) => [entry.getAttribute(CELL_ATTRIBUTE), entry]));
987
+ focus(nearestColumn(band, from, byColumn) ?? cellsThere[0]);
988
+ };
989
+ const nodeId = row.dataset.nodeId;
990
+ if (!nodeId) return;
991
+ if (event.altKey && (event.key === "ArrowUp" || event.key === "ArrowDown")) {
992
+ if (locked || !reorderable) return;
993
+ event.preventDefault();
994
+ actions.moveNode(nodeId, event.key === "ArrowDown" ? 1 : -1);
995
+ return;
996
+ }
997
+ if (event.key === "ArrowDown") return focusRow(1);
998
+ if (event.key === "ArrowUp") return focusRow(-1);
999
+ if (editing) return;
1000
+ if (event.key === forward) return focus(cells[cellIndex + 1]);
1001
+ if (event.key === backward) return focus(cells[cellIndex - 1]);
1002
+ if (event.key === "Home") return focus(event.ctrlKey ? ownCells(rows[0])[0] : cells[0]);
1003
+ if (event.key === "End") {
1004
+ const scope = event.ctrlKey ? ownCells(rows[rows.length - 1]) : cells;
1005
+ return focus(scope[scope.length - 1]);
1006
+ }
1007
+ if (event.key === "Backspace" || event.key === "Delete") {
1008
+ if (locked) return;
1009
+ event.preventDefault();
1010
+ actions.removeNode(nodeId);
1011
+ requestAnimationFrame(() => {
1012
+ const remaining = Array.from(bodyRef.current?.querySelectorAll(ROW_SELECTOR) ?? []);
1013
+ const target = remaining[Math.min(rowIndex, remaining.length - 1)];
1014
+ if (target) ownCells(target)[0]?.focus();
1015
+ });
1016
+ }
1017
+ };
1018
+ /** Pointer drag, not HTML5 drag and drop: its drag image is a
1019
+ * browser-owned snapshot no copy badge can be drawn on, and a nested
1020
+ * drop would mean hit-testing on every `dragover`. */
1021
+ const dragProps = useFilterRowDrag({
1022
+ root: () => bodyRef.current?.parentElement ?? null,
1023
+ disabled: locked,
1024
+ onDrop: (nodeId, drop) => {
1025
+ if (drop.copy) actions.copyNodeTo(nodeId, drop.parentId, drop.index);
1026
+ else actions.moveNodeTo(nodeId, drop.parentId, drop.index);
1027
+ }
1028
+ });
1029
+ const panelProps = {
1030
+ role: "group",
1031
+ "aria-label": actions.labels.advancedFilter,
1032
+ "aria-description": actions.readOnly ? `${actions.labels.countAnnouncement(ruleCount)} ${actions.labels.readOnly}` : actions.labels.countAnnouncement(ruleCount),
1033
+ "data-slot": "filters-advanced",
1034
+ "data-readonly": actions.readOnly || void 0,
1035
+ onFocusCapture: () => {
1036
+ heldFocus.current = true;
1037
+ },
1038
+ onBlurCapture: (event) => {
1039
+ if (event.relatedTarget) heldFocus.current = false;
1040
+ }
1041
+ };
1042
+ /** The empty state, resolved once: the panel's own prop, else the root's.
1043
+ * Assembled here so a replacement gets the SAME two actions the footer
1044
+ * calls, focus handoff included. */
1045
+ const renderEmptyState = renderEmpty ?? panelRender.renderEmpty;
1046
+ const emptyState = renderEmptyState ? renderEmptyState({
1047
+ labels: actions.labels,
1048
+ readOnly: Boolean(actions.readOnly),
1049
+ mode,
1050
+ addFilter: addRow,
1051
+ addGroup
1052
+ }) : null;
1053
+ const body = /* @__PURE__ */ jsxs(Fragment$1, { children: [
1054
+ actions.readOnly ? /* @__PURE__ */ jsx("p", {
1055
+ "data-slot": "filters-readonly",
1056
+ className: cn("text-muted-foreground text-xs", PANEL_GUTTER_CLASS),
1057
+ children: actions.labels.readOnly
1058
+ }) : null,
1059
+ query.rules.length > 0 ? /* @__PURE__ */ jsx("div", {
1060
+ ref: bodyRef,
1061
+ "data-slot": "filters-advanced-body",
1062
+ className: cn(TRACK_CONTAINER_CLASS, "flex min-w-0 flex-col", FILTER_ROW_GAP_CLASS, PANEL_GUTTER_CLASS),
1063
+ onKeyDown,
1064
+ children: /* @__PURE__ */ jsx(FilterReorderProvider, {
1065
+ value: reorderable,
1066
+ children: /* @__PURE__ */ jsx(FilterDragContext.Provider, {
1067
+ value: reorderable ? dragProps : null,
1068
+ children: /* @__PURE__ */ jsx(FilterIssueContext.Provider, {
1069
+ value: visibleIssueMap,
1070
+ children: query.rules.map((node, index) => /* @__PURE__ */ jsx(FilterAdvancedNode, {
1071
+ node,
1072
+ position: {
1073
+ index,
1074
+ parentId: query.id,
1075
+ combinator: query.combinator,
1076
+ depth: 1
1077
+ }
1078
+ }, node.id))
1079
+ })
1080
+ })
1081
+ })
1082
+ }) : renderEmptyState ? emptyState : /* @__PURE__ */ jsxs("div", {
1083
+ "data-slot": "filters-advanced-empty",
1084
+ className: cn("flex flex-col items-center justify-center gap-1 py-8 text-center", PANEL_GUTTER_CLASS),
1085
+ children: [
1086
+ /* @__PURE__ */ jsx("span", {
1087
+ "aria-hidden": "true",
1088
+ className: "mb-1 flex size-9 items-center justify-center rounded-full bg-muted text-muted-foreground [&_svg]:size-4",
1089
+ children: /* @__PURE__ */ jsx(ListFilterIcon, {})
1090
+ }),
1091
+ /* @__PURE__ */ jsx("p", {
1092
+ className: "font-medium text-sm",
1093
+ children: actions.labels.builderEmpty
1094
+ }),
1095
+ actions.readOnly ? null : /* @__PURE__ */ jsx("p", {
1096
+ className: "text-muted-foreground text-xs",
1097
+ children: actions.labels.builderEmptyHint
1098
+ })
1099
+ ]
1100
+ }),
1101
+ /* @__PURE__ */ jsxs("div", {
1102
+ "data-slot": "filters-advanced-footer",
1103
+ "data-drop-parent": query.id,
1104
+ "data-drop-index": query.rules.length,
1105
+ className: cn("relative flex flex-wrap items-center gap-2", PANEL_GUTTER_CLASS, "pe-[calc(var(--filter-panel-pad)+4px)]", FOOTER_DROP_CLASS, query.rules.length > 0 && cn(FILTER_ROW_GAP_CANCEL_CLASS, "pt-5")),
1106
+ children: [
1107
+ /* @__PURE__ */ jsxs(Button, {
1108
+ ref: addRowRef,
1109
+ variant: "outline",
1110
+ size: sizes.button,
1111
+ className: "shrink-0 font-normal",
1112
+ disabled: actions.disabled,
1113
+ ...filterReadOnlyProps(actions),
1114
+ onClick: addRow,
1115
+ children: [/* @__PURE__ */ jsx(PlusIcon, {}), actions.labels.addCondition]
1116
+ }),
1117
+ /* @__PURE__ */ jsxs(Button, {
1118
+ variant: "outline",
1119
+ size: sizes.button,
1120
+ className: "shrink-0 font-normal",
1121
+ disabled: actions.disabled,
1122
+ ...filterReadOnlyProps(actions),
1123
+ onClick: addGroup,
1124
+ children: [/* @__PURE__ */ jsx(FolderPlusIcon, {}), actions.labels.addConditionGroup]
1125
+ }),
1126
+ ruleCount > 0 ? /* @__PURE__ */ jsx(Button, {
1127
+ variant: "ghost",
1128
+ size: sizes.button,
1129
+ className: "ms-auto shrink-0 text-muted-foreground hover:text-foreground",
1130
+ disabled: actions.disabled,
1131
+ ...filterReadOnlyProps(actions),
1132
+ onClick: () => actions.clearQuery(),
1133
+ children: actions.labels.clearAll
1134
+ }) : null
1135
+ ]
1136
+ }),
1137
+ /* @__PURE__ */ jsx("div", {
1138
+ "aria-live": "polite",
1139
+ role: "status",
1140
+ className: "sr-only",
1141
+ children: /* @__PURE__ */ jsx("span", { children: announcement }, announcementSeq)
1142
+ })
1143
+ ] });
1144
+ return /* @__PURE__ */ jsx("div", {
1145
+ ...panelProps,
1146
+ style: { [PANEL_PAD_VAR]: mode === "inline" ? PANEL_PAD_INLINE : PANEL_PAD_POPOVER },
1147
+ className: cn(PANEL_CLASS, className),
1148
+ children: body
1149
+ });
1150
+ }
1151
+ function FiltersAdvanced({ mode = "popover", trigger, reorderable = false, align = "start", className }) {
1152
+ const actions = useFilterActions();
1153
+ const sizes = filterControlSizes(actions);
1154
+ const { ruleCount } = useFilterState();
1155
+ const [open, setOpen] = React$1.useState(false);
1156
+ if (mode === "inline") return /* @__PURE__ */ jsx(FiltersAdvancedPanel, {
1157
+ mode: "inline",
1158
+ reorderable,
1159
+ className
1160
+ });
1161
+ return /* @__PURE__ */ jsxs(Popover, {
1162
+ open,
1163
+ onOpenChange: setOpen,
1164
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
1165
+ disabled: actions.disabled,
1166
+ render: trigger ? trigger : /* @__PURE__ */ jsxs(Button, {
1167
+ variant: "outline",
1168
+ size: sizes.button,
1169
+ "aria-label": ruleCount > 0 ? `${actions.labels.advancedFilter}, ${actions.labels.countAnnouncement(ruleCount)}` : void 0,
1170
+ children: [
1171
+ /* @__PURE__ */ jsx(ListFilterIcon, {}),
1172
+ actions.labels.advancedFilter,
1173
+ ruleCount > 0 ? /* @__PURE__ */ jsx("span", {
1174
+ "aria-hidden": "true",
1175
+ className: "rounded-sm bg-muted px-1.5 text-muted-foreground text-xs tabular-nums",
1176
+ children: ruleCount
1177
+ }) : null
1178
+ ]
1179
+ })
1180
+ }), /* @__PURE__ */ jsx(PopoverContent, {
1181
+ align,
1182
+ "aria-label": actions.labels.advancedFilter,
1183
+ className: cn("w-[42rem] max-w-[95vw] p-0", className),
1184
+ children: /* @__PURE__ */ jsx(FiltersAdvancedPanel, { reorderable })
1185
+ })]
1186
+ });
1187
+ }
1188
+ //#endregion
1189
+ export { FilterAdvancedRow, FiltersAdvanced, FiltersAdvancedPanel };
1190
+
1191
+ //# sourceMappingURL=filters-advanced.js.map