@rafal.lemieszewski/tide-ui 0.83.0 → 0.84.3

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 (256) hide show
  1. package/README.md +20 -8
  2. package/dist/cjs/components/core-index.cjs +1 -0
  3. package/dist/cjs/components/fundamental/accordion.cjs +1 -0
  4. package/dist/cjs/components/fundamental/alert-dialog.cjs +1 -0
  5. package/dist/cjs/components/fundamental/alert.cjs +1 -0
  6. package/dist/cjs/components/fundamental/autocomplete-search.cjs +1 -0
  7. package/dist/cjs/components/fundamental/avatar-group.cjs +1 -0
  8. package/dist/cjs/components/fundamental/avatar.cjs +1 -0
  9. package/dist/cjs/components/fundamental/badge.cjs +1 -0
  10. package/dist/cjs/components/fundamental/breadcrumb.cjs +1 -0
  11. package/dist/cjs/components/fundamental/button-group.cjs +1 -0
  12. package/dist/cjs/components/fundamental/button.cjs +1 -0
  13. package/dist/cjs/components/fundamental/calendar.cjs +1 -0
  14. package/dist/cjs/components/fundamental/card.cjs +1 -0
  15. package/dist/cjs/components/fundamental/chart.cjs +1 -0
  16. package/dist/cjs/components/fundamental/checkbox.cjs +1 -0
  17. package/dist/cjs/components/fundamental/collapsible.cjs +1 -0
  18. package/dist/cjs/components/fundamental/combobox.cjs +1 -0
  19. package/dist/cjs/components/fundamental/command.cjs +1 -0
  20. package/dist/cjs/components/fundamental/country-dropdown.cjs +1 -0
  21. package/dist/cjs/components/fundamental/custom-icons.cjs +1 -0
  22. package/dist/cjs/components/fundamental/date-picker.cjs +1 -0
  23. package/dist/cjs/components/fundamental/dialog.cjs +1 -0
  24. package/dist/cjs/components/fundamental/drawer.cjs +1 -0
  25. package/dist/cjs/components/fundamental/dropdown-menu.cjs +1 -0
  26. package/dist/cjs/components/fundamental/editable.cjs +1 -0
  27. package/dist/cjs/components/fundamental/empty.cjs +1 -0
  28. package/dist/cjs/components/fundamental/file-upload.cjs +1 -0
  29. package/dist/cjs/components/fundamental/flag.cjs +1 -0
  30. package/dist/cjs/components/fundamental/form-field.cjs +1 -0
  31. package/dist/cjs/components/fundamental/hover-card.cjs +1 -0
  32. package/dist/cjs/components/fundamental/icon.cjs +1 -0
  33. package/dist/cjs/components/fundamental/input-group.cjs +1 -0
  34. package/dist/cjs/components/fundamental/input.cjs +1 -0
  35. package/dist/cjs/components/fundamental/kbd.cjs +1 -0
  36. package/dist/cjs/components/fundamental/label.cjs +1 -0
  37. package/dist/cjs/components/fundamental/month-picker.cjs +1 -0
  38. package/dist/cjs/components/fundamental/pagination.cjs +1 -0
  39. package/dist/cjs/components/fundamental/popover.cjs +1 -0
  40. package/dist/cjs/components/fundamental/progress.cjs +1 -0
  41. package/dist/cjs/components/fundamental/radio-group.cjs +1 -0
  42. package/dist/cjs/components/fundamental/resizable.cjs +1 -0
  43. package/dist/cjs/components/fundamental/scroll-area.cjs +1 -0
  44. package/dist/cjs/components/fundamental/select.cjs +1 -0
  45. package/dist/cjs/components/fundamental/separator.cjs +1 -0
  46. package/dist/cjs/components/fundamental/sheet.cjs +1 -0
  47. package/dist/cjs/components/fundamental/sidebar.cjs +1 -0
  48. package/dist/cjs/components/fundamental/skeleton.cjs +1 -0
  49. package/dist/cjs/components/fundamental/slider.cjs +1 -0
  50. package/dist/cjs/components/fundamental/spinner.cjs +1 -0
  51. package/dist/cjs/components/fundamental/switch.cjs +1 -0
  52. package/dist/cjs/components/fundamental/table.cjs +1 -0
  53. package/dist/cjs/components/fundamental/tabs.cjs +1 -0
  54. package/dist/cjs/components/fundamental/tag.cjs +27 -0
  55. package/dist/cjs/components/fundamental/text-link.cjs +1 -0
  56. package/dist/cjs/components/fundamental/textarea.cjs +1 -0
  57. package/dist/cjs/components/fundamental/toast.cjs +1 -0
  58. package/dist/cjs/components/fundamental/toggle-group.cjs +1 -0
  59. package/dist/cjs/components/fundamental/toggle.cjs +1 -0
  60. package/dist/cjs/components/fundamental/tooltip.cjs +1 -0
  61. package/dist/cjs/components/fundamental/tree.cjs +1 -0
  62. package/dist/cjs/components/product/activity-log.cjs +1 -0
  63. package/dist/cjs/components/product/app-frame.cjs +1 -0
  64. package/dist/cjs/components/product/attributes-list.cjs +1 -0
  65. package/dist/cjs/components/product/bookmarks.cjs +1 -0
  66. package/dist/cjs/components/product/data-table-settings-menu.cjs +1 -0
  67. package/dist/cjs/components/product/data-table.cjs +1 -0
  68. package/dist/cjs/components/product/filters.cjs +1 -0
  69. package/dist/cjs/components/product/fixture-status.cjs +1 -0
  70. package/dist/cjs/components/product/linked-chart.cjs +1 -0
  71. package/dist/cjs/components/product/view-mode-menu.cjs +1 -0
  72. package/dist/cjs/lib/date-utils.cjs +1 -0
  73. package/dist/cjs/lib/hooks.cjs +1 -0
  74. package/dist/cjs/lib/index.cjs +1 -0
  75. package/dist/cjs/lib/utils.cjs +1 -0
  76. package/dist/es/components/core-index.js +37 -0
  77. package/dist/es/components/fundamental/accordion.js +60 -0
  78. package/dist/es/components/fundamental/alert-dialog.js +116 -0
  79. package/dist/es/components/fundamental/alert.js +65 -0
  80. package/dist/es/components/fundamental/autocomplete-search.js +139 -0
  81. package/dist/es/components/fundamental/avatar-group.js +51 -0
  82. package/dist/es/components/fundamental/avatar.js +165 -0
  83. package/dist/es/components/fundamental/badge.js +157 -0
  84. package/dist/es/components/fundamental/breadcrumb.js +142 -0
  85. package/dist/es/components/fundamental/button-group.js +86 -0
  86. package/dist/es/components/fundamental/button.js +186 -0
  87. package/dist/es/components/fundamental/calendar.js +130 -0
  88. package/dist/es/components/fundamental/card.js +68 -0
  89. package/dist/es/components/fundamental/chart.js +1006 -0
  90. package/dist/es/components/fundamental/checkbox.js +51 -0
  91. package/dist/es/components/fundamental/collapsible.js +55 -0
  92. package/dist/es/components/fundamental/combobox.js +229 -0
  93. package/dist/es/components/fundamental/command.js +155 -0
  94. package/dist/es/components/fundamental/country-dropdown.js +215 -0
  95. package/dist/es/components/fundamental/custom-icons.js +876 -0
  96. package/dist/es/components/fundamental/date-picker.js +119 -0
  97. package/dist/es/components/fundamental/dialog.js +106 -0
  98. package/dist/es/components/fundamental/drawer.js +93 -0
  99. package/dist/es/components/fundamental/dropdown-menu.js +600 -0
  100. package/dist/es/components/fundamental/editable.js +123 -0
  101. package/dist/es/components/fundamental/empty.js +152 -0
  102. package/dist/es/components/fundamental/file-upload.js +289 -0
  103. package/dist/es/components/fundamental/flag.js +60 -0
  104. package/dist/es/components/fundamental/form-field.js +352 -0
  105. package/dist/es/components/fundamental/hover-card.js +23 -0
  106. package/dist/es/components/fundamental/icon.js +200 -0
  107. package/dist/es/components/fundamental/input-group.js +135 -0
  108. package/dist/es/components/fundamental/input.js +78 -0
  109. package/dist/es/components/fundamental/kbd.js +57 -0
  110. package/dist/es/components/fundamental/label.js +54 -0
  111. package/dist/es/components/fundamental/month-picker.js +161 -0
  112. package/dist/es/components/fundamental/pagination.js +109 -0
  113. package/dist/es/components/fundamental/popover.js +24 -0
  114. package/dist/es/components/fundamental/progress.js +66 -0
  115. package/dist/es/components/fundamental/radio-group.js +64 -0
  116. package/dist/es/components/fundamental/resizable.js +43 -0
  117. package/dist/es/components/fundamental/scroll-area.js +38 -0
  118. package/dist/es/components/fundamental/select.js +136 -0
  119. package/dist/es/components/fundamental/separator.js +47 -0
  120. package/dist/es/components/fundamental/sheet.js +134 -0
  121. package/dist/es/components/fundamental/sidebar.js +709 -0
  122. package/dist/es/components/fundamental/skeleton.js +158 -0
  123. package/dist/es/components/fundamental/slider.js +35 -0
  124. package/dist/es/components/fundamental/spinner.js +225 -0
  125. package/dist/es/components/fundamental/switch.js +27 -0
  126. package/dist/es/components/fundamental/table.js +263 -0
  127. package/dist/es/components/fundamental/tabs.js +170 -0
  128. package/dist/es/components/fundamental/tag.js +295 -0
  129. package/dist/es/components/fundamental/text-link.js +105 -0
  130. package/dist/es/components/fundamental/textarea.js +47 -0
  131. package/dist/es/components/fundamental/toast.js +108 -0
  132. package/dist/es/components/fundamental/toggle-group.js +37 -0
  133. package/dist/es/components/fundamental/toggle.js +51 -0
  134. package/dist/es/components/fundamental/tooltip.js +26 -0
  135. package/dist/es/components/fundamental/tree.js +161 -0
  136. package/dist/es/components/product/activity-log.js +231 -0
  137. package/dist/es/components/product/app-frame.js +985 -0
  138. package/dist/es/components/product/attributes-list.js +351 -0
  139. package/dist/es/components/product/bookmarks.js +833 -0
  140. package/dist/es/components/product/data-table-settings-menu.js +169 -0
  141. package/dist/es/components/product/data-table.js +2473 -0
  142. package/dist/es/components/product/filters.js +1041 -0
  143. package/dist/es/components/product/fixture-status.js +178 -0
  144. package/dist/es/components/product/linked-chart.js +179 -0
  145. package/dist/es/components/product/view-mode-menu.js +353 -0
  146. package/dist/es/lib/date-utils.js +151 -0
  147. package/dist/es/lib/hooks.js +29 -0
  148. package/dist/es/lib/index.js +348 -0
  149. package/dist/es/lib/utils.js +8 -0
  150. package/dist/es/style.css +1 -0
  151. package/dist/types/bookmarks.d.ts +2 -0
  152. package/dist/types/calendar.d.ts +2 -0
  153. package/dist/types/chart.d.ts +2 -0
  154. package/dist/types/components/core-index.d.cts +135 -0
  155. package/dist/types/components/core-index.d.ts +135 -0
  156. package/dist/{components → types/components}/fundamental/avatar.d.ts +3 -3
  157. package/dist/{components → types/components}/fundamental/badge.d.ts +2 -2
  158. package/dist/{components → types/components}/fundamental/button-group.d.ts +2 -2
  159. package/dist/{components → types/components}/fundamental/button.d.ts +1 -1
  160. package/dist/types/components/fundamental/calendar.d.ts +7 -0
  161. package/dist/types/components/fundamental/chart.d.ts +95 -0
  162. package/dist/{components → types/components}/fundamental/command.d.ts +2 -2
  163. package/dist/types/components/fundamental/country-dropdown.d.ts +34 -0
  164. package/dist/types/components/fundamental/date-picker.d.ts +30 -0
  165. package/dist/{components → types/components}/fundamental/file-upload.d.ts +1 -1
  166. package/dist/{components → types/components}/fundamental/form-field.d.ts +2 -2
  167. package/dist/{components → types/components}/fundamental/form.d.ts +2 -2
  168. package/dist/{components → types/components}/fundamental/icon.d.ts +1 -1
  169. package/dist/{components → types/components}/fundamental/input-group.d.ts +1 -1
  170. package/dist/types/components/fundamental/resizable.d.cts +23 -0
  171. package/dist/{components → types/components}/fundamental/resizable.d.ts +1 -1
  172. package/dist/{components → types/components}/fundamental/sidebar.d.ts +3 -3
  173. package/dist/{components → types/components}/fundamental/spinner.d.ts +1 -1
  174. package/dist/{components → types/components}/fundamental/table.d.ts +3 -3
  175. package/dist/{components → types/components}/fundamental/text-link.d.ts +1 -1
  176. package/dist/{components → types/components}/index.d.ts +118 -118
  177. package/dist/{components → types/components}/product/activity-log.d.ts +1 -1
  178. package/dist/{components → types/components}/product/attributes-list.d.ts +1 -1
  179. package/dist/types/components/product/bookmarks.d.cts +90 -0
  180. package/dist/{components → types/components}/product/bookmarks.d.ts +1 -1
  181. package/dist/types/components/product/data-table.d.ts +802 -0
  182. package/dist/types/components/product/filters.d.ts +124 -0
  183. package/dist/{components → types/components}/product/fixture-status.d.ts +1 -1
  184. package/dist/types/components/product/linked-chart.d.cts +22 -0
  185. package/dist/{components → types/components}/product/linked-chart.d.ts +1 -1
  186. package/dist/types/country-dropdown.d.ts +2 -0
  187. package/dist/types/data-table.d.ts +2 -0
  188. package/dist/types/date-picker.d.ts +2 -0
  189. package/dist/types/filters.d.ts +2 -0
  190. package/dist/types/index.d.ts +2 -0
  191. package/dist/types/lib/index.d.cts +104 -0
  192. package/dist/types/lib/index.d.ts +104 -0
  193. package/dist/types/linked-chart.d.ts +2 -0
  194. package/dist/types/resizable.d.ts +2 -0
  195. package/package.json +191 -31
  196. package/dist/index.cjs.js +0 -144
  197. package/dist/index.cjs.js.map +0 -1
  198. package/dist/index.d.ts +0 -2
  199. package/dist/index.es.js +0 -87768
  200. package/dist/index.es.js.map +0 -1
  201. package/dist/lib/index.d.ts +0 -3
  202. package/dist/style.css +0 -1
  203. /package/dist/{components → types/components}/fundamental/accordion.d.ts +0 -0
  204. /package/dist/{components → types/components}/fundamental/alert-dialog.d.ts +0 -0
  205. /package/dist/{components → types/components}/fundamental/alert.d.ts +0 -0
  206. /package/dist/{components → types/components}/fundamental/autocomplete-search.d.ts +0 -0
  207. /package/dist/{components → types/components}/fundamental/avatar-group.d.ts +0 -0
  208. /package/dist/{components → types/components}/fundamental/breadcrumb.d.ts +0 -0
  209. /package/dist/{components → types/components}/fundamental/button.test.d.ts +0 -0
  210. /package/dist/{components/fundamental/calendar.d.ts → types/components/fundamental/calendar.d.cts} +0 -0
  211. /package/dist/{components → types/components}/fundamental/card.d.ts +0 -0
  212. /package/dist/{components/fundamental/chart.d.ts → types/components/fundamental/chart.d.cts} +0 -0
  213. /package/dist/{components → types/components}/fundamental/checkbox.d.ts +0 -0
  214. /package/dist/{components → types/components}/fundamental/collapsible.d.ts +0 -0
  215. /package/dist/{components → types/components}/fundamental/combobox.d.ts +0 -0
  216. /package/dist/{components/fundamental/country-dropdown.d.ts → types/components/fundamental/country-dropdown.d.cts} +0 -0
  217. /package/dist/{components → types/components}/fundamental/custom-icons.d.ts +0 -0
  218. /package/dist/{components/fundamental/date-picker.d.ts → types/components/fundamental/date-picker.d.cts} +0 -0
  219. /package/dist/{components → types/components}/fundamental/dialog.d.ts +0 -0
  220. /package/dist/{components → types/components}/fundamental/drawer.d.ts +0 -0
  221. /package/dist/{components → types/components}/fundamental/dropdown-menu.d.ts +0 -0
  222. /package/dist/{components → types/components}/fundamental/editable.d.ts +0 -0
  223. /package/dist/{components → types/components}/fundamental/empty.d.ts +0 -0
  224. /package/dist/{components → types/components}/fundamental/flag.d.ts +0 -0
  225. /package/dist/{components → types/components}/fundamental/hover-card.d.ts +0 -0
  226. /package/dist/{components → types/components}/fundamental/input.d.ts +0 -0
  227. /package/dist/{components → types/components}/fundamental/kbd.d.ts +0 -0
  228. /package/dist/{components → types/components}/fundamental/label.d.ts +0 -0
  229. /package/dist/{components → types/components}/fundamental/month-picker.d.ts +0 -0
  230. /package/dist/{components → types/components}/fundamental/pagination.d.ts +0 -0
  231. /package/dist/{components → types/components}/fundamental/popover.d.ts +0 -0
  232. /package/dist/{components → types/components}/fundamental/progress.d.ts +0 -0
  233. /package/dist/{components → types/components}/fundamental/radio-group.d.ts +0 -0
  234. /package/dist/{components → types/components}/fundamental/scroll-area.d.ts +0 -0
  235. /package/dist/{components → types/components}/fundamental/select.d.ts +0 -0
  236. /package/dist/{components → types/components}/fundamental/separator.d.ts +0 -0
  237. /package/dist/{components → types/components}/fundamental/sheet.d.ts +0 -0
  238. /package/dist/{components → types/components}/fundamental/skeleton.d.ts +0 -0
  239. /package/dist/{components → types/components}/fundamental/slider.d.ts +0 -0
  240. /package/dist/{components → types/components}/fundamental/switch.d.ts +0 -0
  241. /package/dist/{components → types/components}/fundamental/tabs.d.ts +0 -0
  242. /package/dist/{components → types/components}/fundamental/tag.d.ts +0 -0
  243. /package/dist/{components → types/components}/fundamental/textarea.d.ts +0 -0
  244. /package/dist/{components → types/components}/fundamental/toast.d.ts +0 -0
  245. /package/dist/{components → types/components}/fundamental/toggle-group.d.ts +0 -0
  246. /package/dist/{components → types/components}/fundamental/toggle.d.ts +0 -0
  247. /package/dist/{components → types/components}/fundamental/tooltip.d.ts +0 -0
  248. /package/dist/{components → types/components}/fundamental/tree.d.ts +0 -0
  249. /package/dist/{components → types/components}/product/app-frame.d.ts +0 -0
  250. /package/dist/{components → types/components}/product/data-table-settings-menu.d.ts +0 -0
  251. /package/dist/{components/product/data-table.d.ts → types/components/product/data-table.d.cts} +0 -0
  252. /package/dist/{components/product/filters.d.ts → types/components/product/filters.d.cts} +0 -0
  253. /package/dist/{components → types/components}/product/view-mode-menu.d.ts +0 -0
  254. /package/dist/{lib → types/lib}/date-utils.d.ts +0 -0
  255. /package/dist/{lib → types/lib}/hooks.d.ts +0 -0
  256. /package/dist/{lib → types/lib}/utils.d.ts +0 -0
@@ -0,0 +1,1041 @@
1
+ import { jsxs as v, jsx as e, Fragment as ne } from "react/jsx-runtime";
2
+ import * as u from "react";
3
+ import { cn as D } from "../../lib/utils.js";
4
+ import { Button as Q } from "../fundamental/button.js";
5
+ import { Input as ee } from "../fundamental/input.js";
6
+ import { AutocompleteSearch as me } from "../fundamental/autocomplete-search.js";
7
+ import { Icon as H } from "../fundamental/icon.js";
8
+ import { Checkbox as oe } from "../fundamental/checkbox.js";
9
+ import { RadioGroup as ve, RadioGroupItem as se } from "../fundamental/radio-group.js";
10
+ import { Select as he, SelectTrigger as xe, SelectValue as be, SelectContent as fe, SelectItem as ge } from "../fundamental/select.js";
11
+ import { MonthPicker as ye } from "../fundamental/month-picker.js";
12
+ import { Calendar as Ne } from "../fundamental/calendar.js";
13
+ import { Popover as le, PopoverTrigger as ie, PopoverContent as ce } from "../fundamental/popover.js";
14
+ import { Separator as re } from "../fundamental/separator.js";
15
+ import { Badge as te } from "../fundamental/badge.js";
16
+ import { getPresetLabel as we, calculatePresetRange as de, formatDateRange as Ce } from "../../lib/date-utils.js";
17
+ const Se = [
18
+ "this-month",
19
+ "last-month",
20
+ "this-quarter",
21
+ "last-quarter",
22
+ "this-year",
23
+ "last-year",
24
+ "custom"
25
+ ], ke = [
26
+ "this-week",
27
+ "last-week",
28
+ "last-30-days",
29
+ "last-90-days",
30
+ "this-month",
31
+ "last-month",
32
+ "custom"
33
+ ];
34
+ function $e(x) {
35
+ let r = 0;
36
+ if (x.groups)
37
+ for (const s of x.groups)
38
+ for (const b of s.options)
39
+ r++, b.children && (r += b.children.length);
40
+ return x.options && (r = x.options.length), r;
41
+ }
42
+ const pe = /* @__PURE__ */ u.memo(function({ filter: r, value: s, onChange: b, onReset: g, autoFocusSearch: y = !0 }) {
43
+ const [k, A] = u.useState(""), f = u.useDeferredValue(k), [$, M] = u.useState(""), [w, R] = u.useState(""), [I, O] = u.useState(null), [T, L] = u.useState(null), [K, c] = u.useState(!1), [C, S] = u.useState((/* @__PURE__ */ new Date()).getFullYear()), h = u.useMemo(() => s ? Array.isArray(s) ? s.map(String) : [String(s)] : [], [s]);
44
+ u.useEffect(() => {
45
+ if (r.type === "number" && r.rangeMode) {
46
+ const n = s;
47
+ if (Array.isArray(n)) {
48
+ const [d, p] = n;
49
+ M(d === -1 / 0 ? "" : d?.toString() || ""), R(p === 1 / 0 ? "" : p?.toString() || "");
50
+ } else typeof n == "number" ? (M(n.toString()), R("")) : (M(""), R(""));
51
+ O(null), L(null);
52
+ }
53
+ }, [s, r.type, r.rangeMode]);
54
+ const F = u.useMemo(() => {
55
+ const n = r.showSearch ?? "auto";
56
+ if (n === !0) return !0;
57
+ if (n === !1) return !1;
58
+ const d = $e(r), p = r.searchThreshold ?? 8;
59
+ return d >= p;
60
+ }, [r]), B = u.useMemo(() => {
61
+ if (r.groups) {
62
+ if (!f) return r.groups;
63
+ const n = f.toLowerCase();
64
+ return r.groups.map((d) => ({
65
+ ...d,
66
+ options: d.options.filter(
67
+ (p) => p.label.toLowerCase().includes(n) || p.children?.some(
68
+ (m) => m.label.toLowerCase().includes(n)
69
+ )
70
+ )
71
+ })).filter((d) => d.options.length > 0);
72
+ }
73
+ if (r.options) {
74
+ const n = f ? r.options.filter(
75
+ (d) => d.label.toLowerCase().includes(f.toLowerCase())
76
+ ) : r.options;
77
+ return n.length > 0 ? [{ label: r.label, options: n }] : [];
78
+ }
79
+ return [];
80
+ }, [r.groups, r.options, r.label, f]), Y = (n) => {
81
+ if (r.type === "multiselect") {
82
+ const d = h.includes(n) ? h.filter((p) => p !== n) : [...h, n];
83
+ b(d.length > 0 ? d : void 0);
84
+ } else
85
+ b(n === h[0] ? void 0 : n);
86
+ }, J = (n) => {
87
+ if (r.type !== "multiselect") return;
88
+ const d = n.options.flatMap(
89
+ (m) => [m.value, ...m.children?.map((N) => N.value) || []]
90
+ ), p = h.filter((m) => !d.includes(m));
91
+ b(p.length > 0 ? p : void 0);
92
+ }, q = (n) => {
93
+ if (r.type !== "multiselect") return;
94
+ const d = n.options.flatMap(
95
+ (m) => [m.value, ...m.children?.map((N) => N.value) || []]
96
+ ), p = Array.from(/* @__PURE__ */ new Set([...h, ...d]));
97
+ b(p.length > 0 ? p : void 0);
98
+ }, X = (n) => {
99
+ if (r.type !== "multiselect") return;
100
+ const p = n.options.filter((P) => !k || P.label.toLowerCase().includes(k.toLowerCase())).flatMap((P) => {
101
+ const W = P.value, t = P.children?.filter(
102
+ (a) => !k || a.label.toLowerCase().includes(k.toLowerCase())
103
+ ).map((a) => a.value) || [];
104
+ return [W, ...t];
105
+ }), m = h.filter((P) => !p.includes(P)), N = p.filter((P) => !h.includes(P)), G = [...m, ...N];
106
+ b(G.length > 0 ? G : void 0);
107
+ }, _ = () => {
108
+ const n = $.trim(), d = w.trim();
109
+ if (O(null), L(null), n === "" && d === "") {
110
+ b(void 0);
111
+ return;
112
+ }
113
+ const p = n === "" ? -1 / 0 : parseFloat(n), m = d === "" ? 1 / 0 : parseFloat(d);
114
+ if (n !== "" && isNaN(p)) {
115
+ O("Invalid minimum value");
116
+ return;
117
+ }
118
+ if (d !== "" && isNaN(m)) {
119
+ L("Invalid maximum value");
120
+ return;
121
+ }
122
+ if (p !== -1 / 0 && m !== 1 / 0 && p > m) {
123
+ O("Minimum must be less than maximum"), L("Maximum must be more than minimum");
124
+ return;
125
+ }
126
+ b([p, m]);
127
+ }, j = r.dateConfig?.granularity || "month", U = () => r.dateConfig?.presets ? r.dateConfig.presets : j === "day" ? ke : Se, Z = () => {
128
+ if (K)
129
+ return "custom";
130
+ const n = s;
131
+ if (!n || !Array.isArray(n))
132
+ return U().includes("all-time") ? "all-time" : "";
133
+ for (const d of U()) {
134
+ if (d === "custom") continue;
135
+ const p = de(d);
136
+ if (p && p[0].getTime() === n[0].getTime() && p[1].getTime() === n[1].getTime())
137
+ return d;
138
+ }
139
+ return "custom";
140
+ }, ae = (n) => {
141
+ if (n === "custom") {
142
+ c(!0);
143
+ return;
144
+ }
145
+ c(!1);
146
+ const d = de(n);
147
+ b(d);
148
+ };
149
+ return /* @__PURE__ */ v("div", { className: "flex flex-col gap-[var(--space-3xl)]", children: [
150
+ F && /* @__PURE__ */ v("div", { className: "relative", children: [
151
+ /* @__PURE__ */ e(
152
+ H,
153
+ {
154
+ name: "search",
155
+ className: "absolute left-[var(--space-m)] top-1/2 -translate-y-1/2 h-[var(--size-xs)] w-[var(--size-xs)] text-[var(--color-text-tertiary)] pointer-events-none"
156
+ }
157
+ ),
158
+ /* @__PURE__ */ e(
159
+ ee,
160
+ {
161
+ type: "text",
162
+ size: "l",
163
+ placeholder: r.searchPlaceholder || `Search for a ${r.label.toLowerCase()}`,
164
+ value: k,
165
+ onChange: (n) => A(n.target.value),
166
+ className: "pl-[calc(var(--space-m)+var(--size-xs)+var(--space-s))]",
167
+ autoFocus: y
168
+ }
169
+ )
170
+ ] }),
171
+ r.type === "number" && r.rangeMode && /* @__PURE__ */ v("div", { className: "flex flex-col gap-[var(--space-s)]", children: [
172
+ /* @__PURE__ */ e("div", { className: "text-body-medium-sm text-[var(--color-text-tertiary)]", children: r.label }),
173
+ /* @__PURE__ */ e("div", { className: "h-px w-full mb-[var(--space-s)]", children: /* @__PURE__ */ e("div", { "aria-hidden": "true", className: "border-[var(--color-border-primary-subtle)] border-[0px_0px_1px] border-solid h-px" }) }),
174
+ /* @__PURE__ */ v("div", { className: "flex flex-col gap-[var(--space-s)]", children: [
175
+ /* @__PURE__ */ e("label", { className: "text-label-md text-[var(--color-text-primary)]", children: "At least..." }),
176
+ /* @__PURE__ */ v("div", { className: "relative", children: [
177
+ r.numberConfig?.prefix && /* @__PURE__ */ e("span", { className: "absolute left-[var(--space-m)] top-1/2 -translate-y-1/2 text-body-md text-[var(--color-text-tertiary)] pointer-events-none", children: r.numberConfig.prefix }),
178
+ /* @__PURE__ */ e(
179
+ ee,
180
+ {
181
+ type: "text",
182
+ inputMode: "numeric",
183
+ size: "l",
184
+ variant: I ? "error" : "default",
185
+ value: $,
186
+ onChange: (n) => {
187
+ M(n.target.value), O(null);
188
+ },
189
+ onBlur: _,
190
+ onKeyDown: (n) => {
191
+ n.key === "Enter" && _();
192
+ },
193
+ placeholder: r.numberConfig?.min?.toString() || "0.00",
194
+ className: D(
195
+ r.numberConfig?.prefix && "pl-[calc(var(--space-l)+var(--space-m))]",
196
+ r.numberConfig?.suffix && "pr-[calc(var(--space-l)+var(--space-m))]"
197
+ )
198
+ }
199
+ ),
200
+ r.numberConfig?.suffix && /* @__PURE__ */ e("span", { className: "absolute right-[var(--space-m)] top-1/2 -translate-y-1/2 text-body-md text-[var(--color-text-tertiary)] pointer-events-none", children: r.numberConfig.suffix })
201
+ ] }),
202
+ I && /* @__PURE__ */ e("span", { className: "text-caption-sm text-[var(--color-text-error-bold)]", children: I })
203
+ ] }),
204
+ /* @__PURE__ */ v("div", { className: "flex flex-col gap-[var(--space-s)]", children: [
205
+ /* @__PURE__ */ e("label", { className: "text-label-md text-[var(--color-text-primary)]", children: "No more than..." }),
206
+ /* @__PURE__ */ v("div", { className: "relative", children: [
207
+ r.numberConfig?.prefix && /* @__PURE__ */ e("span", { className: "absolute left-[var(--space-m)] top-1/2 -translate-y-1/2 text-body-md text-[var(--color-text-tertiary)] pointer-events-none", children: r.numberConfig.prefix }),
208
+ /* @__PURE__ */ e(
209
+ ee,
210
+ {
211
+ type: "text",
212
+ inputMode: "numeric",
213
+ size: "l",
214
+ variant: T ? "error" : "default",
215
+ value: w,
216
+ onChange: (n) => {
217
+ R(n.target.value), L(null);
218
+ },
219
+ onBlur: _,
220
+ onKeyDown: (n) => {
221
+ n.key === "Enter" && _();
222
+ },
223
+ placeholder: r.numberConfig?.max?.toString() || "0.00",
224
+ className: D(
225
+ r.numberConfig?.prefix && "pl-[calc(var(--space-l)+var(--space-m))]",
226
+ r.numberConfig?.suffix && "pr-[calc(var(--space-l)+var(--space-m))]"
227
+ )
228
+ }
229
+ ),
230
+ r.numberConfig?.suffix && /* @__PURE__ */ e("span", { className: "absolute right-[var(--space-m)] top-1/2 -translate-y-1/2 text-body-md text-[var(--color-text-tertiary)] pointer-events-none", children: r.numberConfig.suffix })
231
+ ] }),
232
+ T && /* @__PURE__ */ e("span", { className: "text-caption-sm text-[var(--color-text-error-bold)]", children: T })
233
+ ] }),
234
+ g && ($ !== "" || w !== "") && /* @__PURE__ */ e(
235
+ Q,
236
+ {
237
+ variant: "default",
238
+ onClick: () => {
239
+ M(""), R(""), O(null), L(null), g();
240
+ },
241
+ className: "self-start",
242
+ children: /* @__PURE__ */ e("span", { className: "text-body-medium-sm", children: "Reset" })
243
+ }
244
+ )
245
+ ] }),
246
+ r.type === "date" && r.rangeMode && /* @__PURE__ */ v("div", { className: "flex flex-col gap-[var(--space-s)]", children: [
247
+ /* @__PURE__ */ e("div", { className: "text-body-medium-sm text-[var(--color-text-tertiary)]", children: r.label }),
248
+ /* @__PURE__ */ e("div", { className: "h-px w-full mb-[var(--space-s)]", children: /* @__PURE__ */ e("div", { "aria-hidden": "true", className: "border-[var(--color-border-primary-subtle)] border-[0px_0px_1px] border-solid h-px" }) }),
249
+ /* @__PURE__ */ v("div", { className: "flex flex-col gap-[var(--space-s)]", children: [
250
+ /* @__PURE__ */ e("label", { className: "text-label-md text-[var(--color-text-primary)]", children: "Date range" }),
251
+ /* @__PURE__ */ v(he, { value: Z(), onValueChange: ae, children: [
252
+ /* @__PURE__ */ e(xe, { size: "l", children: /* @__PURE__ */ e(be, { placeholder: "Select date range..." }) }),
253
+ /* @__PURE__ */ e(fe, { children: U().map((n) => /* @__PURE__ */ e(ge, { value: n, children: we(n) }, n)) })
254
+ ] })
255
+ ] }),
256
+ Z() === "custom" && /* @__PURE__ */ v(ne, { children: [
257
+ /* @__PURE__ */ e("p", { className: "text-body-sm text-[var(--color-text-secondary)]", children: j === "day" ? "Select start and end dates for custom range" : "Select start and end months for custom range" }),
258
+ j === "day" && /* @__PURE__ */ e(
259
+ Ne,
260
+ {
261
+ mode: "range",
262
+ selected: s && Array.isArray(s) && s.length === 2 ? { from: s[0], to: s[1] } : void 0,
263
+ onSelect: (n) => {
264
+ if (n?.from && n?.to) {
265
+ const d = new Date(n.from);
266
+ d.setHours(0, 0, 0, 0);
267
+ const p = new Date(n.to);
268
+ p.setHours(23, 59, 59, 999), b([d, p]), c(!1);
269
+ }
270
+ },
271
+ numberOfMonths: 2,
272
+ disabled: r.dateConfig?.minDate || r.dateConfig?.maxDate ? (n) => !!(r.dateConfig?.minDate && n < r.dateConfig.minDate || r.dateConfig?.maxDate && n > r.dateConfig.maxDate) : void 0
273
+ }
274
+ ),
275
+ j === "month" && /* @__PURE__ */ e(
276
+ ye,
277
+ {
278
+ value: s,
279
+ onChange: (n) => {
280
+ b(n), c(!1);
281
+ },
282
+ mode: "range",
283
+ yearCount: 2,
284
+ size: "small",
285
+ enableNavigation: !0,
286
+ onYearNavigate: (n) => S(n),
287
+ minDate: r.dateConfig?.minDate,
288
+ maxDate: r.dateConfig?.maxDate
289
+ }
290
+ )
291
+ ] })
292
+ ] }),
293
+ B.map((n, d) => {
294
+ const p = `filter-group-${d}-${n.label.replace(/\s+/g, "-").toLowerCase()}`;
295
+ return /* @__PURE__ */ v(
296
+ "div",
297
+ {
298
+ role: "group",
299
+ "aria-labelledby": p,
300
+ className: "flex flex-col gap-[var(--space-s)]",
301
+ children: [
302
+ /* @__PURE__ */ v("div", { className: "flex gap-[var(--space-s)] items-start justify-start w-full", children: [
303
+ /* @__PURE__ */ e(
304
+ "div",
305
+ {
306
+ id: p,
307
+ className: "flex-1 text-body-medium-sm text-[var(--color-text-tertiary)]",
308
+ children: n.label
309
+ }
310
+ ),
311
+ g && r.type === "multiselect" && /* @__PURE__ */ v("div", { className: "flex gap-[var(--space-xs)] items-center text-body-medium-sm text-[var(--color-text-brand-bold)]", children: [
312
+ /* @__PURE__ */ e(
313
+ "button",
314
+ {
315
+ onClick: () => q(n),
316
+ "aria-label": `Select all ${n.label} options`,
317
+ className: "hover:text-[var(--color-text-brand-bold-hovered)] hover:underline",
318
+ children: "All"
319
+ }
320
+ ),
321
+ /* @__PURE__ */ e("span", { className: "text-[var(--color-text-tertiary)]", "aria-hidden": "true", children: "•" }),
322
+ /* @__PURE__ */ e(
323
+ "button",
324
+ {
325
+ onClick: () => X(n),
326
+ "aria-label": `Inverse selection in ${n.label}`,
327
+ className: "hover:text-[var(--color-text-brand-bold-hovered)] hover:underline",
328
+ children: "Inverse"
329
+ }
330
+ ),
331
+ /* @__PURE__ */ e("span", { className: "text-[var(--color-text-tertiary)]", "aria-hidden": "true", children: "•" }),
332
+ /* @__PURE__ */ e(
333
+ "button",
334
+ {
335
+ onClick: () => J(n),
336
+ "aria-label": `Clear all ${n.label} selections`,
337
+ className: "hover:text-[var(--color-text-brand-bold-hovered)] hover:underline",
338
+ children: "None"
339
+ }
340
+ )
341
+ ] })
342
+ ] }),
343
+ /* @__PURE__ */ e("div", { className: "h-px w-full", children: /* @__PURE__ */ e("div", { "aria-hidden": "true", className: "border-[var(--color-border-primary-subtle)] border-[0px_0px_1px] border-solid h-px" }) }),
344
+ r.type === "multiselect" ? /* @__PURE__ */ e("div", { className: "flex flex-col gap-[var(--space-s)]", children: n.options.map((m) => /* @__PURE__ */ v(u.Fragment, { children: [
345
+ /* @__PURE__ */ v("div", { className: "flex gap-[var(--space-s)] h-[20px] items-center", children: [
346
+ /* @__PURE__ */ e(
347
+ oe,
348
+ {
349
+ id: `checkbox-${r.id}-${m.value}`,
350
+ checked: h.includes(m.value),
351
+ onCheckedChange: () => Y(m.value)
352
+ }
353
+ ),
354
+ /* @__PURE__ */ e(
355
+ "label",
356
+ {
357
+ htmlFor: `checkbox-${r.id}-${m.value}`,
358
+ className: "flex-1 text-body-md text-[var(--color-text-primary)] cursor-pointer",
359
+ children: m.label
360
+ }
361
+ )
362
+ ] }),
363
+ m.children && m.children.map((N) => /* @__PURE__ */ v("div", { className: "flex gap-[var(--space-s)] h-[20px] items-center pl-[var(--space-3xl)]", children: [
364
+ /* @__PURE__ */ e(
365
+ oe,
366
+ {
367
+ id: `checkbox-${r.id}-${N.value}`,
368
+ checked: h.includes(N.value),
369
+ onCheckedChange: () => Y(N.value)
370
+ }
371
+ ),
372
+ /* @__PURE__ */ e(
373
+ "label",
374
+ {
375
+ htmlFor: `checkbox-${r.id}-${N.value}`,
376
+ className: "flex-1 text-body-md text-[var(--color-text-primary)] cursor-pointer",
377
+ children: N.label
378
+ }
379
+ )
380
+ ] }, N.value))
381
+ ] }, m.value)) }) : /* @__PURE__ */ e(ve, { value: h[0] || "", onValueChange: Y, "aria-label": n.label, children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-[var(--space-s)]", children: n.options.map((m) => /* @__PURE__ */ v(u.Fragment, { children: [
382
+ /* @__PURE__ */ v("div", { className: "flex gap-[var(--space-s)] h-[20px] items-center", children: [
383
+ /* @__PURE__ */ e(se, { id: `radio-${r.id}-${m.value}`, value: m.value }),
384
+ /* @__PURE__ */ e(
385
+ "label",
386
+ {
387
+ htmlFor: `radio-${r.id}-${m.value}`,
388
+ className: "flex-1 text-body-md text-[var(--color-text-primary)] cursor-pointer",
389
+ children: m.label
390
+ }
391
+ )
392
+ ] }),
393
+ m.children && m.children.map((N) => /* @__PURE__ */ v("div", { className: "flex gap-[var(--space-s)] h-[20px] items-center pl-[var(--space-3xl)]", children: [
394
+ /* @__PURE__ */ e(se, { id: `radio-${r.id}-${N.value}`, value: N.value }),
395
+ /* @__PURE__ */ e(
396
+ "label",
397
+ {
398
+ htmlFor: `radio-${r.id}-${N.value}`,
399
+ className: "flex-1 text-body-md text-[var(--color-text-primary)] cursor-pointer",
400
+ children: N.label
401
+ }
402
+ )
403
+ ] }, N.value))
404
+ ] }, m.value)) }) })
405
+ ]
406
+ },
407
+ n.label
408
+ );
409
+ })
410
+ ] });
411
+ }), ue = /* @__PURE__ */ u.memo(function({ filter: r, isSelected: s, isPinned: b, valueCount: g, onSelect: y, onTogglePin: k, onPrefetch: A }) {
412
+ const f = r.icon, [$, M] = u.useState(!1);
413
+ return /* @__PURE__ */ v(
414
+ "div",
415
+ {
416
+ id: `filter-option-${r.id}`,
417
+ role: "option",
418
+ "aria-selected": s,
419
+ "aria-label": `${r.label}${g ? `, ${g} selected` : ""}`,
420
+ tabIndex: -1,
421
+ onKeyDown: (w) => {
422
+ (w.key === "Enter" || w.key === " ") && (w.preventDefault(), y());
423
+ },
424
+ onMouseEnter: () => {
425
+ M(!0), A?.();
426
+ },
427
+ onMouseLeave: () => M(!1),
428
+ className: D(
429
+ "group/item box-border flex gap-[var(--space-m)] h-[var(--size-m)] items-center justify-start px-[var(--space-l)] py-[var(--space-s)] relative rounded-m shrink-0 w-full cursor-pointer transition-colors",
430
+ "hover:bg-[var(--color-background-neutral-hovered)]",
431
+ s && "bg-[var(--color-background-blue-subtle-selected)] hover:bg-[var(--color-background-blue-subtle-selected-hovered)] group-focus-visible/listbox:ring-2 group-focus-visible/listbox:ring-[var(--ring-color)] group-focus-visible/listbox:ring-inset"
432
+ ),
433
+ onClick: y,
434
+ children: [
435
+ /* @__PURE__ */ v("div", { className: "flex-1 flex gap-[var(--space-s)] items-center justify-start min-w-0", children: [
436
+ /* @__PURE__ */ e(f, { className: D(
437
+ "h-[var(--size-2xs)] w-[var(--size-2xs)] shrink-0",
438
+ s ? "text-[var(--color-text-brand-bold)]" : "text-[var(--color-text-primary)]"
439
+ ) }),
440
+ /* @__PURE__ */ e("div", { className: D(
441
+ "truncate [&]:text-label-md",
442
+ s ? "text-[var(--color-text-brand-bold)]" : "text-[var(--color-text-primary)]"
443
+ ), children: r.label }),
444
+ g !== void 0 && g > 0 && /* @__PURE__ */ e(
445
+ te,
446
+ {
447
+ size: "s",
448
+ intent: s ? "brand" : "neutral",
449
+ appearance: s || $ ? "bold" : "subtle",
450
+ children: g
451
+ }
452
+ )
453
+ ] }),
454
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-[var(--space-s)] shrink-0", children: /* @__PURE__ */ e(
455
+ Q,
456
+ {
457
+ variant: "ghost",
458
+ size: "s",
459
+ tabIndex: -1,
460
+ "aria-label": b ? `Unpin ${r.label} filter` : `Pin ${r.label} filter`,
461
+ "aria-pressed": b,
462
+ onClick: (w) => {
463
+ w.stopPropagation(), k();
464
+ },
465
+ className: D(
466
+ "group/pin h-auto w-auto p-[var(--space-xs)] transition-opacity",
467
+ b ? "opacity-100" : "opacity-0 group-hover/item:opacity-100"
468
+ ),
469
+ children: b ? /* @__PURE__ */ v(ne, { children: [
470
+ /* @__PURE__ */ e(
471
+ H,
472
+ {
473
+ name: "pin",
474
+ "aria-hidden": "true",
475
+ className: D(
476
+ "h-[12px] w-[12px] group-hover/pin:hidden",
477
+ s ? "text-[var(--color-text-brand-bold)]" : "text-[var(--color-text-primary)]"
478
+ )
479
+ }
480
+ ),
481
+ /* @__PURE__ */ e(
482
+ H,
483
+ {
484
+ name: "pin-off",
485
+ "aria-hidden": "true",
486
+ className: D(
487
+ "h-[12px] w-[12px] hidden group-hover/pin:block",
488
+ s ? "text-[var(--color-text-brand-bold)]" : "text-[var(--color-text-primary)]"
489
+ )
490
+ }
491
+ )
492
+ ] }) : /* @__PURE__ */ e(
493
+ H,
494
+ {
495
+ name: "pin",
496
+ "aria-hidden": "true",
497
+ className: D(
498
+ "h-[12px] w-[12px]",
499
+ s ? "text-[var(--color-text-brand-bold)]" : "text-[var(--color-text-primary)]"
500
+ )
501
+ }
502
+ )
503
+ }
504
+ ) })
505
+ ]
506
+ }
507
+ );
508
+ });
509
+ function Ie({ placeholder: x = "Search for keyword...", onAddSearchTerm: r }) {
510
+ const [s, b] = u.useState("");
511
+ return /* @__PURE__ */ e("div", { className: "min-w-[200px] w-[280px]", children: /* @__PURE__ */ e(
512
+ ee,
513
+ {
514
+ type: "search",
515
+ "aria-label": "Search filters by keyword",
516
+ placeholder: x,
517
+ value: s,
518
+ onChange: (y) => b(y.target.value),
519
+ onKeyDown: (y) => {
520
+ y.key === "Enter" && s.trim() && (y.preventDefault(), r(s.trim()), b(""));
521
+ },
522
+ size: "m"
523
+ }
524
+ ) });
525
+ }
526
+ function Ae({
527
+ placeholder: x = "Search for keyword...",
528
+ onAddSearchTerm: r,
529
+ suggestions: s,
530
+ minCharacters: b
531
+ }) {
532
+ const [g, y] = u.useState("");
533
+ return /* @__PURE__ */ e("div", { className: "min-w-[200px] w-[280px]", children: /* @__PURE__ */ e(
534
+ me,
535
+ {
536
+ value: g,
537
+ onValueChange: y,
538
+ onSelect: (A, f) => {
539
+ r(A, f), y("");
540
+ },
541
+ suggestions: s,
542
+ placeholder: x,
543
+ minCharacters: b
544
+ }
545
+ ) });
546
+ }
547
+ function ze({
548
+ filters: x,
549
+ pinnedFilters: r,
550
+ activeFilters: s,
551
+ onPinnedFiltersChange: b,
552
+ onFilterChange: g,
553
+ sidebarWidth: y = 240
554
+ }) {
555
+ const [k, A] = u.useState(x[0]?.id), [f, $] = u.useState("mouse"), M = u.useRef(null), w = u.useMemo(() => x.map((c) => c.id), [x]), R = (c) => {
556
+ const C = w.indexOf(k);
557
+ let S = C;
558
+ switch (c.key) {
559
+ case "ArrowDown":
560
+ c.preventDefault(), S = Math.min(C + 1, w.length - 1);
561
+ break;
562
+ case "ArrowUp":
563
+ c.preventDefault(), S = Math.max(C - 1, 0);
564
+ break;
565
+ case "Home":
566
+ c.preventDefault(), S = 0;
567
+ break;
568
+ case "End":
569
+ c.preventDefault(), S = w.length - 1;
570
+ break;
571
+ default:
572
+ return;
573
+ }
574
+ S !== C && ($("keyboard"), A(w[S]));
575
+ }, I = x.find((c) => c.id === k), O = u.useCallback((c) => {
576
+ I && g(I.id, c);
577
+ }, [I?.id, g]), T = u.useCallback(() => {
578
+ I && g(I.id, void 0);
579
+ }, [I?.id, g]), L = (c) => {
580
+ const C = r.includes(c) ? r.filter((S) => S !== c) : [...r, c];
581
+ b(C);
582
+ }, K = u.useMemo(() => {
583
+ const c = {}, C = [], S = [];
584
+ return x.forEach((h) => {
585
+ h.group ? (c[h.group] || (c[h.group] = [], S.push(h.group)), c[h.group].push(h)) : C.push(h);
586
+ }), { grouped: c, ungrouped: C, groupOrder: S };
587
+ }, [x]);
588
+ return /* @__PURE__ */ e("div", { className: "bg-[var(--color-surface-primary)] relative rounded-m max-h-[480px] flex flex-col", children: /* @__PURE__ */ v("div", { className: "flex items-stretch justify-start min-h-0 overflow-hidden rounded-m flex-1", children: [
589
+ /* @__PURE__ */ e(
590
+ "div",
591
+ {
592
+ className: "bg-[var(--color-background-neutral-default)] relative shrink-0 border-r border-[var(--color-border-primary-subtle)] flex flex-col",
593
+ style: { width: typeof y == "number" ? `${y}px` : y },
594
+ children: /* @__PURE__ */ v(
595
+ "div",
596
+ {
597
+ ref: M,
598
+ role: "listbox",
599
+ "aria-label": "Filter categories",
600
+ "aria-orientation": "vertical",
601
+ "aria-activedescendant": k ? `filter-option-${k}` : void 0,
602
+ tabIndex: 0,
603
+ onKeyDown: R,
604
+ className: "group/listbox box-border flex flex-col gap-[var(--space-s)] p-[var(--space-s)] overflow-y-auto focus-visible:outline-none",
605
+ children: [
606
+ K.ungrouped.map((c) => {
607
+ const C = s[c.id], S = Array.isArray(C) ? C.length : C != null ? 1 : 0;
608
+ return /* @__PURE__ */ e(
609
+ ue,
610
+ {
611
+ filter: c,
612
+ isSelected: c.id === k,
613
+ isPinned: r.includes(c.id),
614
+ valueCount: S,
615
+ onSelect: () => {
616
+ $("mouse"), A(c.id);
617
+ },
618
+ onTogglePin: () => L(c.id)
619
+ },
620
+ c.id
621
+ );
622
+ }),
623
+ K.groupOrder.map((c, C) => {
624
+ const S = K.grouped[c];
625
+ return /* @__PURE__ */ v("div", { className: "flex flex-col gap-[var(--space-s)]", children: [
626
+ /* @__PURE__ */ e("div", { className: D(
627
+ "px-[var(--space-m)] pb-[var(--space-xs)]",
628
+ C === 0 && K.ungrouped.length === 0 ? "pt-0" : "pt-[var(--space-m)]"
629
+ ), children: /* @__PURE__ */ e("div", { className: "text-caption-sm text-[var(--color-text-tertiary)] tracking-[0.1px]", children: c }) }),
630
+ S.map((h) => {
631
+ const F = s[h.id], B = Array.isArray(F) ? F.length : F != null ? 1 : 0;
632
+ return /* @__PURE__ */ e(
633
+ ue,
634
+ {
635
+ filter: h,
636
+ isSelected: h.id === k,
637
+ isPinned: r.includes(h.id),
638
+ valueCount: B,
639
+ onSelect: () => {
640
+ $("mouse"), A(h.id);
641
+ },
642
+ onTogglePin: () => L(h.id)
643
+ },
644
+ h.id
645
+ );
646
+ })
647
+ ] }, c);
648
+ })
649
+ ]
650
+ }
651
+ )
652
+ }
653
+ ),
654
+ /* @__PURE__ */ e("div", { className: "flex-1 box-border p-[var(--space-l)] overflow-y-auto", children: I && /* @__PURE__ */ e(
655
+ pe,
656
+ {
657
+ filter: I,
658
+ value: s[I.id],
659
+ onChange: O,
660
+ onReset: T,
661
+ autoFocusSearch: f === "mouse"
662
+ }
663
+ ) })
664
+ ] }) });
665
+ }
666
+ function Ye({
667
+ filters: x,
668
+ pinnedFilters: r,
669
+ activeFilters: s,
670
+ onPinnedFiltersChange: b,
671
+ onFilterChange: g,
672
+ onFilterClear: y,
673
+ onFilterReset: k,
674
+ enableGlobalSearch: A = !1,
675
+ globalSearchTerms: f = [],
676
+ onGlobalSearchChange: $,
677
+ globalSearchPlaceholder: M,
678
+ enableAutocomplete: w = !1,
679
+ autocompleteMinCharacters: R = 2,
680
+ hideReset: I = !1,
681
+ hideFiltersButton: O = !1,
682
+ actionButtons: T
683
+ }) {
684
+ const [L, K] = u.useState(!1), [c, C] = u.useState(null), [S, h] = u.useState(""), F = u.useRef(s), B = u.useRef(f), Y = u.useRef({}), J = u.useCallback((t, a) => {
685
+ const o = c;
686
+ C(t ? a : null), !t && o === a && setTimeout(() => {
687
+ Y.current[a]?.focus();
688
+ }, 0);
689
+ }, [c]);
690
+ u.useEffect(() => {
691
+ const t = F.current, a = B.current, o = Object.keys(s).filter(
692
+ (E) => s[E] !== void 0 && s[E] !== null && (!Array.isArray(s[E]) || s[E].length > 0)
693
+ ).length, i = Object.keys(t).filter(
694
+ (E) => t[E] !== void 0 && t[E] !== null && (!Array.isArray(t[E]) || t[E].length > 0)
695
+ ).length, l = f.length, V = a.length;
696
+ let z = "";
697
+ if (o !== i && (o > i ? z = "Filter applied." : o < i && (z = "Filter removed.")), l !== V && (l > V ? z = z ? `${z} Search term added.` : "Search term added." : l < V && (z = z ? `${z} Search term removed.` : "Search term removed.")), z) {
698
+ const E = o + l;
699
+ E === 0 ? z = "All filters cleared." : z = `${z} ${E} active filter${E !== 1 ? "s" : ""}.`, h(z);
700
+ }
701
+ F.current = s, B.current = f;
702
+ }, [s, f]);
703
+ const q = !O && x.length > 0, X = Object.keys(s).some(
704
+ (t) => s[t] !== void 0 && s[t] !== null
705
+ ), _ = f.length > 0, j = Object.keys(s).filter(
706
+ (t) => {
707
+ const a = s[t];
708
+ return a != null && (!Array.isArray(a) || a.length > 0);
709
+ }
710
+ ).length, U = (t, a) => {
711
+ if (!t.groups) return a;
712
+ for (const o of t.groups)
713
+ for (const i of o.options) {
714
+ if (i.value === a) return i.label;
715
+ if (i.children) {
716
+ const l = i.children.find((V) => V.value === a);
717
+ if (l) return l.label;
718
+ }
719
+ }
720
+ return a;
721
+ }, Z = (t, a, o) => {
722
+ const i = o?.prefix || "", l = o?.suffix || "";
723
+ return t === -1 / 0 ? `≤ ${i}${a}${l}` : a === 1 / 0 ? `≥ ${i}${t}${l}` : `${i}${t}${l} - ${i}${a}${l}`;
724
+ }, ae = (t) => {
725
+ const a = s[t.id];
726
+ if (!a || Array.isArray(a) && a.length === 0)
727
+ return { type: "empty", icon: t.icon, content: t.label };
728
+ if (t.type === "number" && t.rangeMode && Array.isArray(a) && a.length === 2) {
729
+ const [o, i] = a, l = t.formatValue?.(
730
+ [o.toString(), i.toString()],
731
+ 2
732
+ ) ?? Z(o, i, t.numberConfig);
733
+ return { type: "values", icon: t.icon, content: l };
734
+ }
735
+ if (t.type === "date" && t.rangeMode && Array.isArray(a) && a.length === 2) {
736
+ const [o, i] = a, l = t.formatValue?.(
737
+ [o.toISOString(), i.toISOString()],
738
+ 2
739
+ ) ?? Ce(o, i);
740
+ return { type: "values", icon: t.icon, content: l };
741
+ }
742
+ if (Array.isArray(a))
743
+ if (a.length <= 3) {
744
+ const o = a.map(String), i = t.formatValue?.(o, o.length) ?? o.map((l) => U(t, l)).join(", ");
745
+ return { type: "values", icon: t.icon, content: i };
746
+ } else
747
+ return {
748
+ type: "count",
749
+ icon: t.icon,
750
+ label: t.label,
751
+ count: a.length
752
+ };
753
+ return { type: "values", icon: t.icon, content: U(t, String(a)) };
754
+ }, n = x.filter((t) => r.includes(t.id)), d = u.useMemo(() => {
755
+ const t = [];
756
+ for (const a of x) {
757
+ const o = (i) => {
758
+ t.push({
759
+ normalizedLabel: i.toLowerCase(),
760
+ filterId: a.id,
761
+ icon: a.icon
762
+ });
763
+ };
764
+ if (a.groups)
765
+ for (const i of a.groups)
766
+ for (const l of i.options)
767
+ o(l.label), l.children?.forEach((V) => o(V.label));
768
+ a.options && a.options.forEach((i) => {
769
+ o(i.label), i.children?.forEach((l) => o(l.label));
770
+ });
771
+ }
772
+ return t;
773
+ }, [x]), p = u.useCallback((t) => {
774
+ if (!t) return null;
775
+ const a = t.toLowerCase();
776
+ for (const o of d)
777
+ if (o.normalizedLabel.includes(a))
778
+ return { filterId: o.filterId, icon: o.icon };
779
+ return null;
780
+ }, [d]), m = u.useMemo(() => f.filter((a) => a && typeof a == "string").map((a) => {
781
+ if (a.includes("|")) {
782
+ const [i, l] = a.split("|"), V = x.find((z) => z.label === l);
783
+ return {
784
+ value: a,
785
+ // Keep encoded term for removal
786
+ matchedFilter: V ? {
787
+ filterId: V.id,
788
+ icon: V.icon
789
+ } : void 0
790
+ };
791
+ }
792
+ const o = p(a);
793
+ return {
794
+ value: a,
795
+ matchedFilter: o ? {
796
+ filterId: o.filterId,
797
+ icon: o.icon
798
+ } : void 0
799
+ };
800
+ }), [f, x, p]), N = u.useMemo(() => {
801
+ if (!w || !A)
802
+ return [];
803
+ const t = [];
804
+ return x.forEach((a) => {
805
+ a.groups ? a.groups.forEach((o) => {
806
+ o.options.forEach((i) => {
807
+ i.label && i.value && t.push({
808
+ label: i.label,
809
+ value: i.value,
810
+ filterLabel: a.label,
811
+ filterIcon: a.icon
812
+ }), i.children && i.children.forEach((l) => {
813
+ l.label && l.value && t.push({
814
+ label: l.label,
815
+ value: l.value,
816
+ filterLabel: a.label,
817
+ filterIcon: a.icon
818
+ });
819
+ });
820
+ });
821
+ }) : a.options && a.options.forEach((o) => {
822
+ o.label && o.value && t.push({
823
+ label: o.label,
824
+ value: o.value,
825
+ filterLabel: a.label,
826
+ filterIcon: a.icon
827
+ }), o.children && o.children.forEach((i) => {
828
+ i.label && i.value && t.push({
829
+ label: i.label,
830
+ value: i.value,
831
+ filterLabel: a.label,
832
+ filterIcon: a.icon
833
+ });
834
+ });
835
+ });
836
+ }), t.sort((a, o) => {
837
+ const i = a.label.localeCompare(o.label);
838
+ return i !== 0 ? i : a.filterLabel.localeCompare(o.filterLabel);
839
+ });
840
+ }, [x, w, A]), G = (t, a) => {
841
+ if (!$) return;
842
+ const o = a ? `${t}|${a}` : t;
843
+ f.includes(o) || $([...f, o]);
844
+ }, P = (t) => {
845
+ $ && $(f.filter((a) => a !== t));
846
+ }, W = () => {
847
+ k(), $ && _ && $([]);
848
+ };
849
+ return /* @__PURE__ */ v("div", { className: "flex gap-[3px] items-center min-w-0", children: [
850
+ /* @__PURE__ */ e(
851
+ "div",
852
+ {
853
+ role: "status",
854
+ "aria-live": "polite",
855
+ "aria-atomic": "true",
856
+ className: "sr-only",
857
+ children: S
858
+ }
859
+ ),
860
+ q && /* @__PURE__ */ v(le, { open: L, onOpenChange: K, children: [
861
+ /* @__PURE__ */ e(ie, { asChild: !0, children: /* @__PURE__ */ v(
862
+ Q,
863
+ {
864
+ className: "h-[var(--size-m)] gap-[var(--space-xs)]",
865
+ "aria-label": `Filters${j > 0 ? `, ${j} active` : ""}`,
866
+ "aria-expanded": L,
867
+ "aria-haspopup": "dialog",
868
+ children: [
869
+ /* @__PURE__ */ e(H, { name: "list-filter", className: "h-[var(--size-2xs)] w-[var(--size-2xs)]", "aria-hidden": "true" }),
870
+ /* @__PURE__ */ e("span", { className: "text-label-md", children: "Filters" }),
871
+ j > 0 && /* @__PURE__ */ e(te, { size: "s", intent: "neutral", appearance: "subtle", "aria-hidden": "true", children: j })
872
+ ]
873
+ }
874
+ ) }),
875
+ /* @__PURE__ */ e(
876
+ ce,
877
+ {
878
+ className: "w-[660px] p-0",
879
+ align: "start",
880
+ children: /* @__PURE__ */ e(
881
+ ze,
882
+ {
883
+ filters: x,
884
+ pinnedFilters: r,
885
+ activeFilters: s,
886
+ onPinnedFiltersChange: b,
887
+ onFilterChange: g
888
+ }
889
+ )
890
+ }
891
+ )
892
+ ] }),
893
+ q && n.length > 0 && /* @__PURE__ */ e(re, { type: "dot", layout: "horizontal" }),
894
+ n.length > 0 && /* @__PURE__ */ e("div", { className: "min-w-0 flex gap-[7px] overflow-x-auto scrollbar-hide p-1", children: n.map((t) => {
895
+ const a = ae(t), o = a.type !== "empty", i = a.icon;
896
+ return /* @__PURE__ */ v(
897
+ le,
898
+ {
899
+ open: c === t.id,
900
+ onOpenChange: (l) => J(l, t.id),
901
+ children: [
902
+ /* @__PURE__ */ e(ie, { asChild: !0, children: /* @__PURE__ */ v(
903
+ "div",
904
+ {
905
+ ref: (l) => {
906
+ Y.current[t.id] = l;
907
+ },
908
+ role: "button",
909
+ tabIndex: 0,
910
+ "aria-label": `${t.label}: ${a.type === "empty" ? "not set, click to add filter" : a.type === "count" ? `${a.count} selected, click to edit` : `${a.content}, click to edit`}`,
911
+ "aria-expanded": c === t.id,
912
+ "aria-haspopup": "dialog",
913
+ onKeyDown: (l) => {
914
+ (l.key === "Enter" || l.key === " ") && (l.preventDefault(), J(c !== t.id, t.id));
915
+ },
916
+ className: D(
917
+ "group/slot h-[var(--size-m)] rounded-l flex items-center justify-center gap-[var(--space-s)] transition-colors cursor-pointer flex-shrink-0",
918
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring-color)] focus-visible:ring-offset-2",
919
+ o ? "bg-[var(--color-background-neutral-selected)] hover:bg-[var(--color-background-neutral-hovered)] px-[var(--space-m)] pr-[4px]" : "border border-dashed border-[var(--color-border-primary-strong)] px-[var(--space-m)] pr-[var(--space-s)] hover:border-[var(--grey-400)] active:bg-[var(--grey-25)]"
920
+ ),
921
+ children: [
922
+ /* @__PURE__ */ e(i, { className: D(
923
+ "h-[var(--size-2xs)] w-[var(--size-2xs)]",
924
+ o ? "text-[var(--color-icon-primary)]" : "text-[var(--grey-400)] group-hover/slot:text-[var(--grey-500)]"
925
+ ) }),
926
+ a.type === "count" ? /* @__PURE__ */ v(ne, { children: [
927
+ /* @__PURE__ */ e("span", { className: "whitespace-nowrap [&]:text-label-md text-[var(--color-text-primary)]", children: a.label }),
928
+ /* @__PURE__ */ e(te, { size: "s", intent: "neutral", appearance: "bold", children: a.count })
929
+ ] }) : /* @__PURE__ */ e("span", { className: D(
930
+ "whitespace-nowrap [&]:text-label-md",
931
+ o ? "text-[var(--color-text-primary)]" : "text-[var(--color-text-tertiary)] group-hover/slot:text-[var(--grey-500)]"
932
+ ), children: a.content }),
933
+ o && /* @__PURE__ */ e(
934
+ Q,
935
+ {
936
+ variant: "ghost",
937
+ size: "s",
938
+ "aria-label": `Clear ${t.label} filter`,
939
+ onClick: (l) => {
940
+ l.stopPropagation(), y(t.id);
941
+ },
942
+ onKeyDown: (l) => {
943
+ (l.key === "Enter" || l.key === " ") && (l.preventDefault(), l.stopPropagation(), y(t.id));
944
+ },
945
+ className: "h-auto w-auto p-[var(--space-xs)]",
946
+ children: /* @__PURE__ */ e(H, { name: "x", className: "h-[var(--size-2xs)] w-[var(--size-2xs)]", "aria-hidden": "true" })
947
+ }
948
+ )
949
+ ]
950
+ }
951
+ ) }),
952
+ /* @__PURE__ */ e(
953
+ ce,
954
+ {
955
+ className: D(
956
+ "p-[var(--space-l)]",
957
+ t.type === "date" ? "w-[600px]" : "w-[320px]",
958
+ "max-h-[var(--radix-popover-content-available-height)] overflow-y-auto"
959
+ ),
960
+ align: "start",
961
+ collisionPadding: 8,
962
+ children: /* @__PURE__ */ e(
963
+ pe,
964
+ {
965
+ filter: t,
966
+ value: s[t.id],
967
+ onChange: (l) => g(t.id, l),
968
+ onReset: () => y(t.id)
969
+ }
970
+ )
971
+ }
972
+ )
973
+ ]
974
+ },
975
+ t.id
976
+ );
977
+ }) }),
978
+ A && (q || n.length > 0) && /* @__PURE__ */ e(re, { type: "line", layout: "horizontal", className: "mx-[var(--space-s)]" }),
979
+ A && !w && /* @__PURE__ */ e(
980
+ Ie,
981
+ {
982
+ placeholder: M,
983
+ onAddSearchTerm: G
984
+ }
985
+ ),
986
+ A && w && /* @__PURE__ */ e(
987
+ Ae,
988
+ {
989
+ placeholder: M,
990
+ onAddSearchTerm: G,
991
+ suggestions: N,
992
+ minCharacters: R
993
+ }
994
+ ),
995
+ m.map((t) => {
996
+ const a = t.matchedFilter?.icon, o = t.value.includes("|") ? t.value.split("|")[0] : t.value;
997
+ return /* @__PURE__ */ v(
998
+ "div",
999
+ {
1000
+ className: "h-[var(--size-m)] rounded-l bg-[var(--color-background-neutral-selected)] hover:bg-[var(--color-background-neutral-hovered)] px-[var(--space-m)] pr-[4px] flex items-center gap-[var(--space-s)] transition-colors",
1001
+ children: [
1002
+ a && /* @__PURE__ */ e(a, { className: "h-[var(--size-2xs)] w-[var(--size-2xs)] text-[var(--color-icon-primary)]" }),
1003
+ /* @__PURE__ */ e("span", { className: "whitespace-nowrap [&]:text-label-md text-[var(--color-text-primary)]", children: o }),
1004
+ /* @__PURE__ */ e(
1005
+ Q,
1006
+ {
1007
+ variant: "ghost",
1008
+ size: "s",
1009
+ "aria-label": `Remove search term: ${o}`,
1010
+ onClick: () => P(t.value),
1011
+ className: "h-auto w-auto p-[var(--space-xs)]",
1012
+ children: /* @__PURE__ */ e(H, { name: "x", className: "h-[var(--size-2xs)] w-[var(--size-2xs)]", "aria-hidden": "true" })
1013
+ }
1014
+ )
1015
+ ]
1016
+ },
1017
+ t.value
1018
+ );
1019
+ }),
1020
+ !I && (X || _) && /* @__PURE__ */ e(re, { type: "dot", layout: "horizontal" }),
1021
+ !I && (X || _) && /* @__PURE__ */ e(
1022
+ Q,
1023
+ {
1024
+ variant: "ghost",
1025
+ onClick: W,
1026
+ "aria-label": "Reset all filters and search terms",
1027
+ className: "h-[var(--size-m)] rounded-s px-[var(--space-m)]",
1028
+ children: /* @__PURE__ */ e("span", { className: "text-label-md", children: "Clear all" })
1029
+ }
1030
+ ),
1031
+ T && /* @__PURE__ */ e("div", { className: "flex-1" }),
1032
+ T
1033
+ ] });
1034
+ }
1035
+ export {
1036
+ ke as DEFAULT_DAY_PRESETS,
1037
+ Se as DEFAULT_MONTH_PRESETS,
1038
+ ze as FilterDropdownMenu,
1039
+ pe as FilterPanelContent,
1040
+ Ye as Filters
1041
+ };