@erxes/ui 4.0.0-v2.1 → 4.0.0-v2.11

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 (318) hide show
  1. package/AGENTS.md +58 -0
  2. package/CATALOG.md +251 -0
  3. package/README.md +25 -2
  4. package/dist/components/accordion.d.ts +1 -0
  5. package/dist/components/accordion.js +1 -0
  6. package/dist/components/alert-dialog.d.ts +4 -0
  7. package/dist/components/alert-dialog.js +4 -0
  8. package/dist/components/alert.d.ts +1 -0
  9. package/dist/components/alert.js +1 -0
  10. package/dist/components/avatar.d.ts +2 -0
  11. package/dist/components/avatar.js +1 -0
  12. package/dist/components/background-gradient-animation.d.ts +4 -1
  13. package/dist/components/background-gradient-animation.js +4 -1
  14. package/dist/components/badge.d.ts +3 -0
  15. package/dist/components/badge.js +2 -0
  16. package/dist/components/breadcrumb.d.ts +1 -0
  17. package/dist/components/breadcrumb.js +1 -0
  18. package/dist/components/button.d.ts +6 -1
  19. package/dist/components/button.js +5 -1
  20. package/dist/components/calendar.d.ts +5 -0
  21. package/dist/components/calendar.js +4 -0
  22. package/dist/components/card.d.ts +1 -0
  23. package/dist/components/card.js +1 -0
  24. package/dist/components/chart-config.d.ts +4 -1
  25. package/dist/components/charts.d.ts +6 -0
  26. package/dist/components/charts.js +12 -3
  27. package/dist/components/checkbox.d.ts +1 -0
  28. package/dist/components/checkbox.js +1 -0
  29. package/dist/components/choicebox-group.d.ts +1 -0
  30. package/dist/components/choicebox-group.js +1 -0
  31. package/dist/components/collapsible.d.ts +1 -0
  32. package/dist/components/collapsible.js +1 -0
  33. package/dist/components/color-picker.d.ts +1 -0
  34. package/dist/components/color-picker.js +13 -6
  35. package/dist/components/combobox.d.ts +6 -1
  36. package/dist/components/combobox.js +9 -1
  37. package/dist/components/command-bar.d.ts +4 -0
  38. package/dist/components/command-bar.js +4 -0
  39. package/dist/components/command.d.ts +4 -0
  40. package/dist/components/command.js +4 -0
  41. package/dist/components/context-menu.d.ts +1 -0
  42. package/dist/components/context-menu.js +1 -0
  43. package/dist/components/copy-text.d.ts +1 -0
  44. package/dist/components/copy-text.js +1 -0
  45. package/dist/components/date-picker-value.d.ts +5 -9
  46. package/dist/components/date-picker-value.js +15 -34
  47. package/dist/components/date-picker.d.ts +4 -4
  48. package/dist/components/date-picker.js +9 -7
  49. package/dist/components/date-text-input.d.ts +2 -4
  50. package/dist/components/date-text-input.js +11 -9
  51. package/dist/components/dialog.d.ts +4 -0
  52. package/dist/components/dialog.js +5 -1
  53. package/dist/components/drag-handle.d.ts +1 -0
  54. package/dist/components/drag-handle.js +1 -0
  55. package/dist/components/dropdown-menu.d.ts +1 -0
  56. package/dist/components/dropdown-menu.js +1 -0
  57. package/dist/components/empty.d.ts +6 -1
  58. package/dist/components/empty.js +25 -2
  59. package/dist/components/form.d.ts +6 -2
  60. package/dist/components/form.js +8 -2
  61. package/dist/components/hover-card.d.ts +1 -0
  62. package/dist/components/hover-card.js +1 -0
  63. package/dist/components/icon-tip.d.ts +7 -0
  64. package/dist/components/icon-tip.js +16 -0
  65. package/dist/components/info-card.d.ts +4 -0
  66. package/dist/components/info-card.js +4 -0
  67. package/dist/components/input-group.d.ts +5 -4
  68. package/dist/components/input-group.js +5 -4
  69. package/dist/components/input.d.ts +1 -0
  70. package/dist/components/input.js +1 -0
  71. package/dist/components/kbd.d.ts +2 -1
  72. package/dist/components/kbd.js +2 -1
  73. package/dist/components/label.d.ts +1 -1
  74. package/dist/components/label.js +1 -1
  75. package/dist/components/multiselect.d.ts +1 -0
  76. package/dist/components/multiselect.js +3 -2
  77. package/dist/components/on-demand.d.ts +6 -0
  78. package/dist/components/on-demand.js +6 -0
  79. package/dist/components/popover.d.ts +4 -0
  80. package/dist/components/popover.js +4 -0
  81. package/dist/components/radio-group.d.ts +1 -0
  82. package/dist/components/radio-group.js +1 -0
  83. package/dist/components/scroll-area.d.ts +1 -0
  84. package/dist/components/scroll-area.js +1 -0
  85. package/dist/components/select.d.ts +5 -1
  86. package/dist/components/select.js +7 -1
  87. package/dist/components/separator.d.ts +4 -0
  88. package/dist/components/separator.js +4 -0
  89. package/dist/components/sheet.d.ts +4 -0
  90. package/dist/components/sheet.js +8 -4
  91. package/dist/components/sidebar/panel.js +29 -7
  92. package/dist/components/sidebar.d.ts +1 -0
  93. package/dist/components/sidebar.js +1 -0
  94. package/dist/components/skeleton.d.ts +1 -0
  95. package/dist/components/skeleton.js +1 -0
  96. package/dist/components/spinner.d.ts +1 -0
  97. package/dist/components/spinner.js +1 -0
  98. package/dist/components/string-array.js +1 -0
  99. package/dist/components/switch.d.ts +1 -0
  100. package/dist/components/switch.js +1 -0
  101. package/dist/components/table.d.ts +4 -0
  102. package/dist/components/table.js +4 -0
  103. package/dist/components/tabs.d.ts +8 -1
  104. package/dist/components/tabs.js +8 -1
  105. package/dist/components/text-overflow.d.ts +4 -1
  106. package/dist/components/text-overflow.js +4 -1
  107. package/dist/components/textarea.d.ts +1 -0
  108. package/dist/components/textarea.js +1 -0
  109. package/dist/components/toaster.d.ts +4 -1
  110. package/dist/components/toaster.js +5 -2
  111. package/dist/components/toggle-group.d.ts +5 -0
  112. package/dist/components/toggle-group.js +19 -11
  113. package/dist/components/toggle.d.ts +1 -0
  114. package/dist/components/toggle.js +1 -0
  115. package/dist/components/tooltip.d.ts +4 -0
  116. package/dist/components/tooltip.js +4 -0
  117. package/dist/components/upload.d.ts +4 -0
  118. package/dist/components/upload.js +20 -11
  119. package/dist/federation.d.ts +8 -1
  120. package/dist/federation.js +12 -2
  121. package/dist/hooks/use-item-keys.d.ts +11 -0
  122. package/dist/hooks/use-item-keys.js +24 -0
  123. package/dist/hooks/use-page-hotkey.d.ts +12 -0
  124. package/dist/hooks/use-page-hotkey.js +22 -0
  125. package/dist/hooks/use-toast.d.ts +5 -0
  126. package/dist/hooks/use-toast.js +5 -0
  127. package/dist/index.d.ts +33 -6
  128. package/dist/index.js +31 -4
  129. package/dist/lib/format.d.ts +60 -0
  130. package/dist/lib/format.js +86 -0
  131. package/dist/lib/money.d.ts +13 -0
  132. package/dist/lib/money.js +21 -0
  133. package/dist/lib/stored.d.ts +13 -0
  134. package/dist/lib/stored.js +41 -0
  135. package/dist/lib/text.d.ts +11 -0
  136. package/dist/lib/text.js +18 -0
  137. package/dist/modules/attachments/use-carousel.js +5 -10
  138. package/dist/modules/blocks/hooks/useBarcodeSizeForm.d.ts +1 -1
  139. package/dist/modules/blocks/utils/parseBlocks.d.ts +1 -1
  140. package/dist/modules/blocks/utils/parseBlocks.js +1 -1
  141. package/dist/modules/conditions/ConditionValueInput.d.ts +10 -0
  142. package/dist/modules/conditions/ConditionValueInput.js +166 -0
  143. package/dist/modules/conditions/ConditionsEditor.d.ts +11 -0
  144. package/dist/modules/conditions/ConditionsEditor.js +209 -0
  145. package/dist/modules/conditions/LazyConditionsEditor.d.ts +10 -0
  146. package/dist/modules/conditions/LazyConditionsEditor.js +11 -0
  147. package/dist/modules/conditions/PathPicker.d.ts +8 -0
  148. package/dist/modules/conditions/PathPicker.js +51 -0
  149. package/dist/modules/conditions/conditions.d.ts +66 -0
  150. package/dist/modules/conditions/conditions.js +136 -0
  151. package/dist/modules/display/components/EmailDisplay.d.ts +4 -0
  152. package/dist/modules/display/components/EmailDisplay.js +6 -3
  153. package/dist/modules/display/components/PhoneDisplay.d.ts +4 -0
  154. package/dist/modules/display/components/PhoneDisplay.js +4 -0
  155. package/dist/modules/display/components/RelativeDateDisplay.d.ts +7 -5
  156. package/dist/modules/display/components/RelativeDateDisplay.js +10 -8
  157. package/dist/modules/display/components/SexDisplay.d.ts +1 -0
  158. package/dist/modules/display/components/SexDisplay.js +1 -0
  159. package/dist/modules/filter/components/Filter.d.ts +4 -0
  160. package/dist/modules/filter/components/Filter.js +4 -0
  161. package/dist/modules/filter/components/FilterBar.js +5 -7
  162. package/dist/modules/filter/components/FilterDialog.js +4 -5
  163. package/dist/modules/filter/components/FilterPopover.js +1 -1
  164. package/dist/modules/filter/components/FilterProvider.d.ts +1 -2
  165. package/dist/modules/filter/components/FilterProvider.js +22 -16
  166. package/dist/modules/filter/hooks/useFilterContext.d.ts +1 -0
  167. package/dist/modules/filter/hooks/useFilterContext.js +1 -0
  168. package/dist/modules/filter/types/filter.d.ts +0 -1
  169. package/dist/modules/hotkey/components/PopoverScoped.d.ts +5 -0
  170. package/dist/modules/hotkey/components/PopoverScoped.js +5 -0
  171. package/dist/modules/hotkey/hooks/usePreviousHotkeyScope.d.ts +1 -0
  172. package/dist/modules/hotkey/hooks/usePreviousHotkeyScope.js +1 -0
  173. package/dist/modules/hotkey/hooks/useScopedHotkeys.d.ts +5 -1
  174. package/dist/modules/hotkey/hooks/useScopedHotkeys.js +5 -1
  175. package/dist/modules/icons/components/IconComponent.d.ts +4 -0
  176. package/dist/modules/icons/components/IconComponent.js +4 -0
  177. package/dist/modules/icons/components/IconPicker.d.ts +4 -0
  178. package/dist/modules/icons/components/IconPicker.js +7 -5
  179. package/dist/modules/icons/providers/IconsProvider.d.ts +1 -0
  180. package/dist/modules/icons/providers/IconsProvider.js +1 -0
  181. package/dist/modules/inputs/components/EmailField.d.ts +4 -1
  182. package/dist/modules/inputs/components/EmailField.js +4 -1
  183. package/dist/modules/inputs/components/FullNameField.d.ts +6 -0
  184. package/dist/modules/inputs/components/FullNameField.js +20 -8
  185. package/dist/modules/inputs/components/PhoneField.d.ts +4 -1
  186. package/dist/modules/inputs/components/PhoneField.js +4 -1
  187. package/dist/modules/inputs/components/SexField.d.ts +1 -0
  188. package/dist/modules/inputs/components/SexField.js +1 -0
  189. package/dist/modules/layout/components/AppLayout.d.ts +6 -6
  190. package/dist/modules/layout/components/AppLayout.js +12 -13
  191. package/dist/modules/layout/components/AppLayoutResizeHandle.d.ts +5 -12
  192. package/dist/modules/layout/components/AppLayoutResizeHandle.js +15 -18
  193. package/dist/modules/layout/components/Page.d.ts +5 -0
  194. package/dist/modules/layout/components/Page.js +5 -0
  195. package/dist/modules/layout/components/PageHeader.d.ts +4 -1
  196. package/dist/modules/layout/components/PageHeader.js +9 -3
  197. package/dist/modules/list/DisplayMenu.d.ts +24 -0
  198. package/dist/modules/list/DisplayMenu.js +87 -0
  199. package/dist/modules/list/ListFilter.d.ts +63 -0
  200. package/dist/modules/list/ListFilter.js +44 -0
  201. package/dist/modules/list/ViewBar.d.ts +13 -0
  202. package/dist/modules/list/ViewBar.js +30 -0
  203. package/dist/modules/list/filter/AdvancedFilterDialog.d.ts +5 -0
  204. package/dist/modules/list/filter/AdvancedFilterDialog.js +52 -0
  205. package/dist/modules/list/filter/FieldMenus.d.ts +5 -0
  206. package/dist/modules/list/filter/FieldMenus.js +184 -0
  207. package/dist/modules/list/filter/ListFilterBar.d.ts +6 -0
  208. package/dist/modules/list/filter/ListFilterBar.js +246 -0
  209. package/dist/modules/list/filter/RecordCount.d.ts +7 -0
  210. package/dist/modules/list/filter/RecordCount.js +22 -0
  211. package/dist/modules/list/filter/RuleChips.d.ts +2 -0
  212. package/dist/modules/list/filter/RuleChips.js +157 -0
  213. package/dist/modules/list/filter/fieldIcons.d.ts +7 -0
  214. package/dist/modules/list/filter/fieldIcons.js +16 -0
  215. package/dist/modules/list/filter/filterRules.d.ts +46 -0
  216. package/dist/modules/list/filter/filterRules.js +166 -0
  217. package/dist/modules/list/filter/listFilterContext.d.ts +29 -0
  218. package/dist/modules/list/filter/listFilterContext.js +34 -0
  219. package/dist/modules/list/filter/listFilterQuery.d.ts +16 -0
  220. package/dist/modules/list/filter/listFilterQuery.js +22 -0
  221. package/dist/modules/navigation-menu/components/NavigationMenu.d.ts +4 -3
  222. package/dist/modules/navigation-menu/components/NavigationMenu.js +7 -7
  223. package/dist/modules/pickers/EntityPicker.d.ts +37 -0
  224. package/dist/modules/pickers/EntityPicker.js +67 -0
  225. package/dist/modules/pickers/LookupPicker.d.ts +51 -0
  226. package/dist/modules/pickers/LookupPicker.js +84 -0
  227. package/dist/modules/pickers/SelectMember.d.ts +41 -0
  228. package/dist/modules/pickers/SelectMember.js +122 -0
  229. package/dist/modules/pickers/members.d.ts +30 -0
  230. package/dist/modules/pickers/members.js +18 -0
  231. package/dist/modules/record-field/components/NumberField.d.ts +5 -0
  232. package/dist/modules/record-field/components/NumberField.js +14 -7
  233. package/dist/modules/record-field/components/TextField.d.ts +4 -0
  234. package/dist/modules/record-field/components/TextField.js +14 -3
  235. package/dist/modules/record-field/meta-inputs/components/PhoneInput.d.ts +5 -0
  236. package/dist/modules/record-field/meta-inputs/components/PhoneInput.js +5 -0
  237. package/dist/modules/record-list/RecordList.d.ts +18 -0
  238. package/dist/modules/record-list/RecordList.js +23 -0
  239. package/dist/modules/record-list/RecordListProvider.d.ts +30 -0
  240. package/dist/modules/record-list/RecordListProvider.js +57 -0
  241. package/dist/modules/record-list/RecordListRoot.d.ts +28 -0
  242. package/dist/modules/record-list/RecordListRoot.js +124 -0
  243. package/dist/modules/record-list/selection.d.ts +22 -0
  244. package/dist/modules/record-list/selection.js +54 -0
  245. package/dist/modules/record-panel/PanelDescriptionEditor.d.ts +9 -0
  246. package/dist/modules/record-panel/PanelDescriptionEditor.js +39 -0
  247. package/dist/modules/record-panel/PanelDescriptionField.d.ts +13 -0
  248. package/dist/modules/record-panel/PanelDescriptionField.js +39 -0
  249. package/dist/modules/record-panel/PanelField.d.ts +17 -0
  250. package/dist/modules/record-panel/PanelField.js +47 -0
  251. package/dist/modules/record-panel/PanelForm.d.ts +28 -0
  252. package/dist/modules/record-panel/PanelForm.js +88 -0
  253. package/dist/modules/record-panel/PanelLabel.d.ts +10 -0
  254. package/dist/modules/record-panel/PanelLabel.js +55 -0
  255. package/dist/modules/record-panel/PanelSection.d.ts +12 -0
  256. package/dist/modules/record-panel/PanelSection.js +24 -0
  257. package/dist/modules/record-panel/panelExpansion.d.ts +10 -0
  258. package/dist/modules/record-panel/panelExpansion.js +7 -0
  259. package/dist/modules/record-panel/useSaveOnLeave.d.ts +14 -0
  260. package/dist/modules/record-panel/useSaveOnLeave.js +42 -0
  261. package/dist/modules/record-table/components/RecordTable.d.ts +6 -0
  262. package/dist/modules/record-table/components/RecordTable.js +6 -0
  263. package/dist/modules/record-table/components/RecordTableCell.d.ts +9 -0
  264. package/dist/modules/record-table/components/RecordTableCell.js +16 -2
  265. package/dist/modules/record-table/components/RecordTableCellInline.d.ts +5 -0
  266. package/dist/modules/record-table/components/RecordTableCellInline.js +8 -7
  267. package/dist/modules/record-table/components/RecordTableCursor.js +30 -28
  268. package/dist/modules/record-table/components/RecordTableProvider.js +12 -7
  269. package/dist/modules/record-table/hooks/useTablePreferences.d.ts +1 -1
  270. package/dist/modules/record-table/hooks/useTablePreferences.js +18 -31
  271. package/dist/modules/record-table/states/RecordTableCursorState.d.ts +21 -1
  272. package/dist/modules/record-table/states/RecordTableCursorState.js +21 -3
  273. package/dist/modules/record-table/types/RecordTableCursorTypes.d.ts +1 -0
  274. package/dist/modules/record-table/types/RecordTableCursorTypes.js +1 -0
  275. package/dist/modules/records/ContactLink.d.ts +13 -0
  276. package/dist/modules/records/ContactLink.js +77 -0
  277. package/dist/modules/records/contacts.d.ts +35 -0
  278. package/dist/modules/records/contacts.js +10 -0
  279. package/dist/modules/records/openRecord.d.ts +44 -0
  280. package/dist/modules/records/openRecord.js +48 -0
  281. package/dist/state/sidebarPanelState.d.ts +5 -1
  282. package/dist/state/sidebarPanelState.js +11 -3
  283. package/dist/state/themeState.d.ts +13 -2
  284. package/dist/state/themeState.js +18 -4
  285. package/dist/theme.css +5 -2
  286. package/dist/types/SexCode.d.ts +1 -0
  287. package/dist/types/SexCode.js +1 -0
  288. package/dist/types/UIConfig.d.ts +131 -3
  289. package/dist/utils/IsUndefinedOrNull.d.ts +1 -0
  290. package/dist/utils/IsUndefinedOrNull.js +1 -0
  291. package/dist/utils/file-storage.d.ts +1 -0
  292. package/dist/utils/file-storage.js +1 -0
  293. package/dist/utils/format/formatPhoneNumber.d.ts +4 -0
  294. package/dist/utils/format/formatPhoneNumber.js +4 -0
  295. package/dist/utils/getPluginAssetsUrl.d.ts +5 -0
  296. package/dist/utils/getPluginAssetsUrl.js +5 -0
  297. package/dist/utils/host-component.d.ts +10 -0
  298. package/dist/utils/host-component.js +34 -0
  299. package/dist/utils/json.d.ts +3 -2
  300. package/dist/utils/json.js +3 -2
  301. package/dist/utils/plugin-runtime.d.ts +21 -17
  302. package/dist/utils/plugin-runtime.js +59 -12
  303. package/dist/utils/plugin-styles.d.ts +7 -0
  304. package/dist/utils/plugin-styles.js +54 -0
  305. package/dist/utils/record-timeline.d.ts +10 -9
  306. package/dist/utils/record-timeline.js +12 -17
  307. package/exports.txt +226 -0
  308. package/package.json +13 -3
  309. package/dist/constants/IntlLanguages.d.ts +0 -74
  310. package/dist/constants/IntlLanguages.js +0 -76
  311. package/dist/hooks/use-query-state.d.ts +0 -16
  312. package/dist/hooks/use-query-state.js +0 -122
  313. package/dist/modules/filter/hooks/useFilterQueryState.d.ts +0 -4
  314. package/dist/modules/filter/hooks/useFilterQueryState.js +0 -14
  315. package/dist/types/Theme.d.ts +0 -1
  316. package/dist/types/Theme.js +0 -0
  317. package/dist/utils/localization/formatDateISOStringToRelativeDate.d.ts +0 -2
  318. package/dist/utils/localization/formatDateISOStringToRelativeDate.js +0 -16
@@ -0,0 +1,184 @@
1
+ import { Button } from "../../../components/button.js";
2
+ import { Combobox } from "../../../components/combobox.js";
3
+ import { Command } from "../../../components/command.js";
4
+ import { Input } from "../../../components/input.js";
5
+ import { Select } from "../../../components/select.js";
6
+ import { amountStep, fromAmountInput, toAmountInput } from "../../../lib/money.js";
7
+ import { oneOf, textOf } from "../../../lib/text.js";
8
+ import { isRule } from "../../conditions/conditions.js";
9
+ import { useFilterContext } from "../../filter/hooks/useFilterContext.js";
10
+ import { EntityPicker } from "../../pickers/EntityPicker.js";
11
+ import { DATE_PRESETS, NUMBER_OPS, NUMBER_SYMBOLS, anyOf, presetOf, targetOf, valuesOf } from "./filterRules.js";
12
+ import { useFieldOptions, useListFilter } from "./listFilterContext.js";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ import { useEffect, useRef, useState } from "react";
15
+ import { useTranslation } from "react-i18next";
16
+ // src/modules/list/filter/FieldMenus.tsx
17
+ /** The part this field's menu changes, and that part when it is a rule of the field. */
18
+ const useTarget = (field) => {
19
+ const { parts, setPart, editing } = useListFilter();
20
+ const { resetFilterState } = useFilterContext();
21
+ const index = targetOf(parts, field, editing);
22
+ const part = index === null ? void 0 : parts[index];
23
+ return {
24
+ rule: part && isRule(part) && part.path === field.path ? part : void 0,
25
+ set: (next) => setPart(index, next),
26
+ /** Sets the rule and closes the menu. */
27
+ apply: (next) => {
28
+ setPart(index, next);
29
+ resetFilterState();
30
+ }
31
+ };
32
+ };
33
+ /** A submenu's box takes the keyboard as the submenu opens. */
34
+ const useFocusOnMount = () => {
35
+ const input = useRef(null);
36
+ useEffect(() => input.current?.focus(), []);
37
+ return input;
38
+ };
39
+ /** Options (a choice, members, tags): each pick adds to or takes from one "is any of" rule; the menu stays open. */
40
+ const OptionsMenu = ({ field }) => {
41
+ const { options, loading, error } = useFieldOptions(field);
42
+ const { rule, set } = useTarget(field);
43
+ return /* @__PURE__ */ jsx(EntityPicker, {
44
+ multiple: true,
45
+ items: options,
46
+ itemKey: (option) => ({
47
+ id: option.value,
48
+ label: option.label
49
+ }),
50
+ value: valuesOf(rule),
51
+ onValueChange: (values) => set(anyOf(field.path, values)),
52
+ loading,
53
+ error,
54
+ searchPlaceholder: field.label
55
+ });
56
+ };
57
+ const DateMenu = ({ field }) => {
58
+ const { t } = useTranslation("views", { keyPrefix: "filter.date" });
59
+ const { rule, apply } = useTarget(field);
60
+ const current = presetOf(rule);
61
+ return /* @__PURE__ */ jsx(Command, { children: /* @__PURE__ */ jsx(Command.List, { children: DATE_PRESETS.map((preset) => /* @__PURE__ */ jsxs(Command.Item, {
62
+ value: preset.key,
63
+ onSelect: () => apply({
64
+ path: field.path,
65
+ op: preset.op,
66
+ value: preset.value
67
+ }),
68
+ children: [t(preset.key, preset.label), /* @__PURE__ */ jsx(Combobox.Check, { checked: current?.key === preset.key })]
69
+ }, preset.key)) }) });
70
+ };
71
+ const BooleanMenu = ({ field }) => {
72
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
73
+ const { rule, apply } = useTarget(field);
74
+ const value = rule ? textOf(rule.value) : null;
75
+ return /* @__PURE__ */ jsx(Command, { children: /* @__PURE__ */ jsx(Command.List, { children: ["true", "false"].map((option) => /* @__PURE__ */ jsxs(Command.Item, {
76
+ value: option,
77
+ onSelect: () => apply({
78
+ path: field.path,
79
+ op: "eq",
80
+ value: option === "true"
81
+ }),
82
+ children: [option === "true" ? t("yes", "Yes") : t("no", "No"), /* @__PURE__ */ jsx(Combobox.Check, { checked: value === option })]
83
+ }, option)) }) });
84
+ };
85
+ /** A number as typed: money in the currency's major unit. */
86
+ const numberText = (value, currency) => {
87
+ const n = Number(value);
88
+ if (value === void 0 || value === null || !Number.isFinite(n)) return "";
89
+ return currency ? toAmountInput(n, currency) : String(n);
90
+ };
91
+ /** An operator and a value; Enter or Apply adds the rule (or changes the one being edited). */
92
+ const NumberMenu = ({ field }) => {
93
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
94
+ const { rule, apply } = useTarget(field);
95
+ const [op, setOp] = useState(() => oneOf(NUMBER_OPS, rule?.op ?? null) ?? "gte");
96
+ const [text, setText] = useState(() => numberText(rule?.value, field.currency));
97
+ const valid = text.trim() !== "" && Number.isFinite(Number(text));
98
+ const input = useFocusOnMount();
99
+ return /* @__PURE__ */ jsxs("form", {
100
+ className: "flex items-center gap-1.5 p-2",
101
+ onSubmit: (event) => {
102
+ event.preventDefault();
103
+ if (!valid) return;
104
+ const value = field.currency ? fromAmountInput(text, field.currency) : Number(text);
105
+ apply({
106
+ path: field.path,
107
+ op,
108
+ value
109
+ });
110
+ },
111
+ children: [
112
+ /* @__PURE__ */ jsxs(Select, {
113
+ value: op,
114
+ onValueChange: (next) => setOp(oneOf(NUMBER_OPS, next) ?? op),
115
+ children: [/* @__PURE__ */ jsx(Select.Trigger, {
116
+ className: "h-8 w-16 shrink-0",
117
+ children: /* @__PURE__ */ jsx(Select.Value, {})
118
+ }), /* @__PURE__ */ jsx(Select.Content, { children: NUMBER_OPS.map((option) => /* @__PURE__ */ jsx(Select.Item, {
119
+ value: option,
120
+ children: NUMBER_SYMBOLS[option]
121
+ }, option)) })]
122
+ }),
123
+ /* @__PURE__ */ jsx(Input, {
124
+ ref: input,
125
+ type: "number",
126
+ className: "h-8 min-w-0 flex-1",
127
+ step: field.currency ? amountStep(field.currency) : "any",
128
+ placeholder: field.currency ?? t("value", "Value"),
129
+ value: text,
130
+ onChange: (event) => setText(event.target.value)
131
+ }),
132
+ /* @__PURE__ */ jsx(Button, {
133
+ type: "submit",
134
+ size: "sm",
135
+ className: "h-8",
136
+ disabled: !valid,
137
+ children: t("apply", "Apply")
138
+ })
139
+ ]
140
+ });
141
+ };
142
+ /** "Contains" text; an empty box removes the rule being edited. */
143
+ const TextMenu = ({ field }) => {
144
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
145
+ const { rule, apply } = useTarget(field);
146
+ const [text, setText] = useState(() => textOf(rule?.value));
147
+ const input = useFocusOnMount();
148
+ return /* @__PURE__ */ jsxs("form", {
149
+ className: "flex items-center gap-1.5 p-2",
150
+ onSubmit: (event) => {
151
+ event.preventDefault();
152
+ apply(text.trim() ? {
153
+ path: field.path,
154
+ op: "contains",
155
+ value: text.trim()
156
+ } : null);
157
+ },
158
+ children: [/* @__PURE__ */ jsx(Input, {
159
+ ref: input,
160
+ className: "h-8 min-w-0 flex-1",
161
+ placeholder: t("contains", "Contains…"),
162
+ value: text,
163
+ onChange: (event) => setText(event.target.value)
164
+ }), /* @__PURE__ */ jsx(Button, {
165
+ type: "submit",
166
+ size: "sm",
167
+ className: "h-8",
168
+ children: t("apply", "Apply")
169
+ })]
170
+ });
171
+ };
172
+ /** A field's submenu, by its type. */
173
+ const FieldMenu = ({ field }) => {
174
+ switch (field.type) {
175
+ case "select":
176
+ case "member":
177
+ case "tags": return /* @__PURE__ */ jsx(OptionsMenu, { field });
178
+ case "date": return /* @__PURE__ */ jsx(DateMenu, { field });
179
+ case "boolean": return /* @__PURE__ */ jsx(BooleanMenu, { field });
180
+ case "number": return /* @__PURE__ */ jsx(NumberMenu, { field });
181
+ case "text": return /* @__PURE__ */ jsx(TextMenu, { field });
182
+ }
183
+ };
184
+ export { FieldMenu };
@@ -0,0 +1,6 @@
1
+ import { TListFilterProps } from "../ListFilter.js";
2
+ /**
3
+ * Inside `<Filter>`: its chips, the list's status and the count, then the list's controls
4
+ * and the menu (`F`).
5
+ */
6
+ export declare const ListFilterBar: ({ id, fields, loading, error, status, totalCount, totalCapped, children, members, tags }: TListFilterProps) => import("react").JSX.Element;
@@ -0,0 +1,246 @@
1
+ import { Button } from "../../../components/button.js";
2
+ import { Combobox } from "../../../components/combobox.js";
3
+ import { Command } from "../../../components/command.js";
4
+ import { IconTip } from "../../../components/icon-tip.js";
5
+ import { Popover } from "../../../components/popover.js";
6
+ import { usePageHotkey } from "../../../hooks/use-page-hotkey.js";
7
+ import { isRule } from "../../conditions/conditions.js";
8
+ import { Filter } from "../../filter/components/Filter.js";
9
+ import { useFilterContext } from "../../filter/hooks/useFilterContext.js";
10
+ import { AdvancedFilterDialog } from "./AdvancedFilterDialog.js";
11
+ import { FieldMenu } from "./FieldMenus.js";
12
+ import { FIELD_ICONS } from "./fieldIcons.js";
13
+ import { groupOf, inMenu, partsOf, withPart } from "./filterRules.js";
14
+ import { ListFilterContext, useListFilter } from "./listFilterContext.js";
15
+ import { useListConditions } from "./listFilterQuery.js";
16
+ import { RecordCount } from "./RecordCount.js";
17
+ import { RuleChips } from "./RuleChips.js";
18
+ import { IconAdjustmentsHorizontal, IconFilter2, IconSearch } from "@tabler/icons-react";
19
+ import { jsx, jsxs } from "react/jsx-runtime";
20
+ import { useCallback, useMemo, useState } from "react";
21
+ import { useTranslation } from "react-i18next";
22
+ import { useQueryState } from "nuqs";
23
+ import { useAutoAnimate } from "@formkit/auto-animate/react";
24
+ // src/modules/list/filter/ListFilterBar.tsx
25
+ /** Built-in fields first, the record's properties last; each with its heading's English. */
26
+ const GROUPS = [
27
+ {
28
+ group: "fields",
29
+ label: "Fields"
30
+ },
31
+ {
32
+ group: "lead",
33
+ label: "Lead"
34
+ },
35
+ {
36
+ group: "company",
37
+ label: "Company"
38
+ },
39
+ {
40
+ group: "activity",
41
+ label: "Activity"
42
+ },
43
+ {
44
+ group: "custom",
45
+ label: "Properties"
46
+ }
47
+ ];
48
+ /** Every field, grouped; each opens its submenu. The search box filters them by name. */
49
+ const FieldItems = () => {
50
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
51
+ const { fields } = useListFilter();
52
+ return GROUPS.map(({ group, label }) => {
53
+ const inGroup = fields.filter((field) => (field.group ?? "fields") === group);
54
+ if (!inGroup.length) return null;
55
+ return /* @__PURE__ */ jsx(Command.Group, {
56
+ heading: t(`group.${group}`, label),
57
+ children: inGroup.map((field) => {
58
+ const Icon = field.icon ?? FIELD_ICONS[field.type];
59
+ return /* @__PURE__ */ jsxs(Filter.Item, {
60
+ value: field.path,
61
+ keywords: [field.label],
62
+ children: [/* @__PURE__ */ jsx(Icon, {}), /* @__PURE__ */ jsx("span", {
63
+ className: "truncate",
64
+ children: field.label
65
+ })]
66
+ }, field.path);
67
+ })
68
+ }, group);
69
+ });
70
+ };
71
+ /** The menu's first page: "Add filter…", search, the advanced filter, then the fields. */
72
+ const RootMenu = ({ loading, error }) => {
73
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
74
+ const { openAdvanced } = useListFilter();
75
+ const search = t("search", "Search");
76
+ const advanced = t("advanced", "Advanced filter");
77
+ return /* @__PURE__ */ jsxs(Command, { children: [/* @__PURE__ */ jsx(Filter.CommandInput, {
78
+ placeholder: t("add", "Add filter…"),
79
+ variant: "secondary",
80
+ focusOnMount: true
81
+ }), /* @__PURE__ */ jsxs(Command.List, {
82
+ className: "max-h-popup",
83
+ children: [
84
+ /* @__PURE__ */ jsx(Command.Empty, { children: t("no-match", "No field matches") }),
85
+ /* @__PURE__ */ jsxs(Filter.Item, {
86
+ value: "searchValue",
87
+ keywords: [search],
88
+ inDialog: true,
89
+ children: [/* @__PURE__ */ jsx(IconSearch, {}), search]
90
+ }),
91
+ /* @__PURE__ */ jsxs(Filter.CommandItem, {
92
+ value: "advanced",
93
+ keywords: [advanced],
94
+ onSelect: openAdvanced,
95
+ children: [/* @__PURE__ */ jsx(IconAdjustmentsHorizontal, {}), advanced]
96
+ }),
97
+ loading && /* @__PURE__ */ jsx("p", {
98
+ className: "px-2 py-1.5 text-xs text-muted-foreground",
99
+ children: t("loading", "Loading fields…")
100
+ }),
101
+ error && /* @__PURE__ */ jsx("p", {
102
+ role: "alert",
103
+ className: "px-2 py-1.5 text-xs text-destructive",
104
+ children: error.message
105
+ }),
106
+ /* @__PURE__ */ jsx(FieldItems, {})
107
+ ]
108
+ })] });
109
+ };
110
+ /** The search, as a chip (it opens the search box). */
111
+ const SearchChip = () => {
112
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
113
+ const [searchValue] = useQueryState("searchValue");
114
+ return /* @__PURE__ */ jsxs(Filter.BarItem, {
115
+ queryKey: "searchValue",
116
+ children: [/* @__PURE__ */ jsxs(Filter.BarName, { children: [/* @__PURE__ */ jsx(IconSearch, {}), t("search", "Search")] }), /* @__PURE__ */ jsx(Filter.BarButton, {
117
+ filterKey: "searchValue",
118
+ inDialog: true,
119
+ children: searchValue
120
+ })]
121
+ });
122
+ };
123
+ /** Opens the filter menu; it shows how many conditions apply. */
124
+ const FilterButton = ({ count, onClick }) => {
125
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
126
+ const label = t("label", "Filter");
127
+ return /* @__PURE__ */ jsx(IconTip, {
128
+ label,
129
+ hotkey: "F",
130
+ children: /* @__PURE__ */ jsxs(Popover.Trigger, {
131
+ render: /* @__PURE__ */ jsx(Button, {
132
+ size: "sm",
133
+ "aria-label": label,
134
+ "aria-keyshortcuts": "F",
135
+ variant: count > 0 ? "secondary" : "ghost",
136
+ tone: count > 0 ? "default" : "muted",
137
+ className: "h-7 min-w-7",
138
+ onClick
139
+ }),
140
+ children: [/* @__PURE__ */ jsx(IconFilter2, { className: "size-4" }), count > 0 && /* @__PURE__ */ jsx("span", {
141
+ className: "text-xs tabular-nums",
142
+ children: count
143
+ })]
144
+ })
145
+ });
146
+ };
147
+ /** The bar's context: the list's conditions as parts, and the one the menu is editing. */
148
+ const useListFilterState = (fields, lookups) => {
149
+ const { advanced, setAdvanced } = useListConditions();
150
+ const { setOpen, setView } = useFilterContext();
151
+ const [editing, setEditing] = useState(null);
152
+ const [advancedOpen, setAdvancedOpen] = useState(false);
153
+ const parts = useMemo(() => partsOf(advanced), [advanced]);
154
+ const openMenu = useCallback((view, part) => {
155
+ setEditing(part);
156
+ setView(view);
157
+ setOpen(true);
158
+ }, [setOpen, setView]);
159
+ usePageHotkey("f", () => openMenu("root", null));
160
+ return {
161
+ state: useMemo(() => ({
162
+ fields,
163
+ lookups,
164
+ parts,
165
+ editing,
166
+ setPart: (index, next) => setAdvanced(groupOf(withPart(parts, index, next))),
167
+ edit: (index) => {
168
+ const part = parts[index];
169
+ const field = part && isRule(part) && fields.find((one) => one.path === part.path);
170
+ if (part && isRule(part) && field && inMenu(part, field)) openMenu(field.path, index);
171
+ else setAdvancedOpen(true);
172
+ },
173
+ openAdvanced: () => setAdvancedOpen(true)
174
+ }), [
175
+ fields,
176
+ lookups,
177
+ parts,
178
+ editing,
179
+ setAdvanced,
180
+ openMenu
181
+ ]),
182
+ setEditing,
183
+ advancedOpen,
184
+ setAdvancedOpen
185
+ };
186
+ };
187
+ /**
188
+ * Inside `<Filter>`: its chips, the list's status and the count, then the list's controls
189
+ * and the menu (`F`).
190
+ */
191
+ const ListFilterBar = ({ id, fields, loading, error, status, totalCount, totalCapped, children, members, tags }) => {
192
+ const [chipsRef] = useAutoAnimate({ duration: 150 });
193
+ const { search } = useListConditions();
194
+ const lookups = useMemo(() => ({
195
+ members,
196
+ tags
197
+ }), [members, tags]);
198
+ const { state, setEditing, advancedOpen, setAdvancedOpen } = useListFilterState(fields, lookups);
199
+ return /* @__PURE__ */ jsxs(ListFilterContext.Provider, {
200
+ value: state,
201
+ children: [
202
+ /* @__PURE__ */ jsxs("div", {
203
+ ref: chipsRef,
204
+ className: "flex min-w-0 items-center gap-1 overflow-x-auto py-1 hide-scroll",
205
+ children: [/* @__PURE__ */ jsx(SearchChip, {}), /* @__PURE__ */ jsx(RuleChips, {})]
206
+ }),
207
+ status,
208
+ /* @__PURE__ */ jsx(RecordCount, {
209
+ totalCount,
210
+ totalCapped
211
+ }),
212
+ /* @__PURE__ */ jsx("div", {
213
+ "aria-hidden": true,
214
+ className: "mx-1 h-4 w-px shrink-0 bg-border"
215
+ }),
216
+ children,
217
+ /* @__PURE__ */ jsxs(Filter.Popover, {
218
+ scope: `${id}-list`,
219
+ children: [/* @__PURE__ */ jsx(FilterButton, {
220
+ count: state.parts.length + (search ? 1 : 0),
221
+ onClick: () => setEditing(null)
222
+ }), /* @__PURE__ */ jsxs(Combobox.Content, {
223
+ align: "end",
224
+ className: "w-80",
225
+ children: [/* @__PURE__ */ jsx(Filter.View, { children: /* @__PURE__ */ jsx(RootMenu, {
226
+ loading,
227
+ error
228
+ }) }), fields.map((field) => /* @__PURE__ */ jsx(Filter.View, {
229
+ filterKey: field.path,
230
+ children: /* @__PURE__ */ jsx(FieldMenu, { field }, `${state.editing}`)
231
+ }, field.path))]
232
+ })]
233
+ }),
234
+ /* @__PURE__ */ jsx(Filter.Dialog, { children: /* @__PURE__ */ jsx(Filter.View, {
235
+ filterKey: "searchValue",
236
+ inDialog: true,
237
+ children: /* @__PURE__ */ jsx(Filter.DialogStringView, { filterKey: "searchValue" })
238
+ }) }),
239
+ /* @__PURE__ */ jsx(AdvancedFilterDialog, {
240
+ open: advancedOpen,
241
+ onOpenChange: setAdvancedOpen
242
+ })
243
+ ]
244
+ });
245
+ };
246
+ export { ListFilterBar };
@@ -0,0 +1,7 @@
1
+ /** How many records a list matches, as its list hook gives them. */
2
+ export interface Total {
3
+ totalCount?: number | null;
4
+ totalCapped?: boolean;
5
+ }
6
+ /** The list's count, quietly, after its filter; hidden on narrow screens. */
7
+ export declare const RecordCount: ({ totalCount, totalCapped }: Total) => import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { Skeleton } from "../../../components/skeleton.js";
2
+ import { useFormat } from "../../../lib/format.js";
3
+ import { isUndefinedOrNull } from "../../../utils/IsUndefinedOrNull.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { useTranslation } from "react-i18next";
6
+ // src/modules/list/filter/RecordCount.tsx
7
+ /** The list's count, quietly, after its filter; hidden on narrow screens. */
8
+ const RecordCount = ({ totalCount, totalCapped }) => {
9
+ const { t } = useTranslation("views");
10
+ const fmt = useFormat();
11
+ if (isUndefinedOrNull(totalCount)) return /* @__PURE__ */ jsx(Skeleton, { className: "hidden h-3.5 w-14 md:block" });
12
+ return /* @__PURE__ */ jsx("span", {
13
+ className: "hidden shrink-0 whitespace-nowrap px-1 text-xs tabular-nums text-muted-foreground md:inline",
14
+ children: t("count", {
15
+ count: totalCapped ? 2 : totalCount,
16
+ formatted: fmt.count(totalCount, totalCapped),
17
+ defaultValue_one: "{{formatted}} record",
18
+ defaultValue_other: "{{formatted}} records"
19
+ })
20
+ });
21
+ };
22
+ export { RecordCount };
@@ -0,0 +1,2 @@
1
+ /** Each part of the list's filter as a chip (parts are distinct, so a part is its own key). */
2
+ export declare const RuleChips: () => import("react").JSX.Element[];
@@ -0,0 +1,157 @@
1
+ import { useFormat } from "../../../lib/format.js";
2
+ import { useMoney } from "../../../lib/money.js";
3
+ import { oneOf, textOf } from "../../../lib/text.js";
4
+ import { OPERATOR_LABELS, RelativeAmount, isRule } from "../../conditions/conditions.js";
5
+ import { Filter } from "../../filter/components/Filter.js";
6
+ import { FIELD_ICONS } from "./fieldIcons.js";
7
+ import { NUMBER_OPS, NUMBER_SYMBOLS, presetOf, valuesOf } from "./filterRules.js";
8
+ import { useFieldOptions, useListFilter } from "./listFilterContext.js";
9
+ import { IconAdjustmentsHorizontal } from "@tabler/icons-react";
10
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
+ import { useTranslation } from "react-i18next";
12
+ // src/modules/list/filter/RuleChips.tsx
13
+ /** A filter bar chip: what it filters, the condition (opens it), remove. */
14
+ const Chip = ({ name, children, onOpen, onRemove }) => {
15
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
16
+ return /* @__PURE__ */ jsxs("div", {
17
+ className: "flex h-7 items-stretch gap-px rounded bg-muted text-sm font-medium shadow-xs",
18
+ children: [
19
+ /* @__PURE__ */ jsx(Filter.BarName, { children: name }),
20
+ /* @__PURE__ */ jsx(Filter.BarButton, {
21
+ onClick: onOpen,
22
+ children
23
+ }),
24
+ /* @__PURE__ */ jsx(Filter.BarClose, {
25
+ "aria-label": t("remove", "Remove filter"),
26
+ onClick: onRemove
27
+ })
28
+ ]
29
+ });
30
+ };
31
+ /** Unknown paths (a removed property) read as text. */
32
+ const textField = (path) => ({
33
+ path,
34
+ label: path,
35
+ type: "text"
36
+ });
37
+ /** English for the `views` namespace's `filter.unit.<unit>`, by plural form. */
38
+ const UNIT_LABELS = {
39
+ days: {
40
+ defaultValue_one: "{{count}} day",
41
+ defaultValue_other: "{{count}} days"
42
+ },
43
+ weeks: {
44
+ defaultValue_one: "{{count}} week",
45
+ defaultValue_other: "{{count}} weeks"
46
+ },
47
+ months: {
48
+ defaultValue_one: "{{count}} month",
49
+ defaultValue_other: "{{count}} months"
50
+ }
51
+ };
52
+ /** A rule as words: the operator and the value. */
53
+ const useRuleText = (rule, field) => {
54
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
55
+ const { t: opT } = useTranslation("automations");
56
+ const { options } = useFieldOptions(field);
57
+ const money = useMoney();
58
+ const fmt = useFormat();
59
+ const op = opT(`op.${rule.op}`, OPERATOR_LABELS[rule.op]);
60
+ const labelOf = (value) => options.find((option) => option.value === value)?.label ?? value;
61
+ const preset = field.type === "date" ? presetOf(rule) : void 0;
62
+ const span = RelativeAmount.safeParse(rule.value);
63
+ const numberOp = field.type === "number" ? oneOf(NUMBER_OPS, rule.op) : void 0;
64
+ const is = t("is", "is");
65
+ if (preset) return {
66
+ op: "",
67
+ value: t(`date.${preset.key}`, preset.label)
68
+ };
69
+ if (rule.op === "exists" || rule.op === "not_exists") return {
70
+ op,
71
+ value: ""
72
+ };
73
+ if (span.success) {
74
+ const { amount, unit } = span.data;
75
+ return {
76
+ op,
77
+ value: t(`unit.${unit}`, {
78
+ count: amount,
79
+ ...UNIT_LABELS[unit]
80
+ })
81
+ };
82
+ }
83
+ if (field.type === "boolean") return {
84
+ op: is,
85
+ value: textOf(rule.value) === "true" ? t("yes", "Yes") : t("no", "No")
86
+ };
87
+ if (numberOp) {
88
+ const n = Number(rule.value);
89
+ return {
90
+ op: NUMBER_SYMBOLS[numberOp],
91
+ value: field.currency ? money(n, field.currency) : fmt.number(n)
92
+ };
93
+ }
94
+ if (rule.op === "contains" && field.type === "text") return {
95
+ op,
96
+ value: `“${textOf(rule.value)}”`
97
+ };
98
+ const values = valuesOf(rule).map(labelOf);
99
+ if (rule.op === "in" || rule.op === "eq") return {
100
+ op: values.length > 1 ? t("is-any-of", "is any of") : is,
101
+ value: values.join(", ")
102
+ };
103
+ return {
104
+ op,
105
+ value: values.join(", ")
106
+ };
107
+ };
108
+ const RuleChip = ({ rule, index }) => {
109
+ const { fields, edit, setPart } = useListFilter();
110
+ const field = fields.find((one) => one.path === rule.path) ?? textField(rule.path);
111
+ const text = useRuleText(rule, field);
112
+ const Icon = field.icon ?? FIELD_ICONS[field.type];
113
+ return /* @__PURE__ */ jsxs(Chip, {
114
+ name: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Icon, {}), field.label] }),
115
+ onOpen: () => edit(index),
116
+ onRemove: () => setPart(index, null),
117
+ children: [text.op && /* @__PURE__ */ jsx("span", {
118
+ className: "font-normal text-muted-foreground",
119
+ children: text.op
120
+ }), /* @__PURE__ */ jsx("span", {
121
+ className: "truncate",
122
+ children: text.value
123
+ })]
124
+ });
125
+ };
126
+ /** A group from the advanced filter: how many conditions; it opens the advanced filter. */
127
+ const GroupChip = ({ group, index }) => {
128
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
129
+ const { openAdvanced, setPart } = useListFilter();
130
+ const count = group.rules.length;
131
+ return /* @__PURE__ */ jsx(Chip, {
132
+ name: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(IconAdjustmentsHorizontal, {}), t("advanced", "Advanced filter")] }),
133
+ onOpen: openAdvanced,
134
+ onRemove: () => setPart(index, null),
135
+ children: group.match === "any" ? t("any-of", {
136
+ count,
137
+ defaultValue_one: "any of {{count}} condition",
138
+ defaultValue_other: "any of {{count}} conditions"
139
+ }) : t("conditions", {
140
+ count,
141
+ defaultValue_one: "{{count}} condition",
142
+ defaultValue_other: "{{count}} conditions"
143
+ })
144
+ });
145
+ };
146
+ /** Each part of the list's filter as a chip (parts are distinct, so a part is its own key). */
147
+ const RuleChips = () => {
148
+ const { parts } = useListFilter();
149
+ return parts.map((part, index) => isRule(part) ? /* @__PURE__ */ jsx(RuleChip, {
150
+ rule: part,
151
+ index
152
+ }, JSON.stringify(part)) : /* @__PURE__ */ jsx(GroupChip, {
153
+ group: part,
154
+ index
155
+ }, JSON.stringify(part)));
156
+ };
157
+ export { RuleChips };
@@ -0,0 +1,7 @@
1
+ import { TListFilterField } from "../ListFilter.js";
2
+ import { IconHash } from "@tabler/icons-react";
3
+ /**
4
+ * A field's icon in the filter menu and on its chips, by type, unless it brings its own:
5
+ * `field.icon ?? FIELD_ICONS[field.type]`.
6
+ */
7
+ export declare const FIELD_ICONS: Record<TListFilterField['type'], typeof IconHash>;
@@ -0,0 +1,16 @@
1
+ import { IconCalendar, IconHash, IconLetterCase, IconSelector, IconTags, IconToggleLeft, IconUser } from "@tabler/icons-react";
2
+ // src/modules/list/filter/fieldIcons.ts
3
+ /**
4
+ * A field's icon in the filter menu and on its chips, by type, unless it brings its own:
5
+ * `field.icon ?? FIELD_ICONS[field.type]`.
6
+ */
7
+ const FIELD_ICONS = {
8
+ text: IconLetterCase,
9
+ number: IconHash,
10
+ date: IconCalendar,
11
+ boolean: IconToggleLeft,
12
+ select: IconSelector,
13
+ member: IconUser,
14
+ tags: IconTags
15
+ };
16
+ export { FIELD_ICONS };