@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,166 @@
1
+ import { Input } from "../../components/input.js";
2
+ import { Select } from "../../components/select.js";
3
+ import { amountStep, fromAmountInput, toAmountInput } from "../../lib/money.js";
4
+ import { oneOf, textOf } from "../../lib/text.js";
5
+ import { LookupPicker, useMemberOptions, useTagOptions } from "../pickers/LookupPicker.js";
6
+ import { LIST_VALUE, RELATIVE, RELATIVE_UNITS } from "./conditions.js";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { useState } from "react";
9
+ import { z } from "zod";
10
+ import { useTranslation } from "react-i18next";
11
+ // src/modules/conditions/ConditionValueInput.tsx
12
+ /** What the rule holds so far: a half-typed amount is still shown. */
13
+ const RelativeValue = z.object({
14
+ amount: z.number().optional(),
15
+ unit: z.enum(RELATIVE_UNITS).optional()
16
+ });
17
+ const RelativeInput = ({ rule, onChange, disabled }) => {
18
+ const { t } = useTranslation("automations");
19
+ const current = RelativeValue.safeParse(rule.value).data ?? {};
20
+ return /* @__PURE__ */ jsxs("div", {
21
+ className: "flex w-full items-center gap-1",
22
+ children: [/* @__PURE__ */ jsx(Input, {
23
+ className: "h-8 w-20",
24
+ type: "number",
25
+ min: 0,
26
+ disabled,
27
+ value: current.amount ?? "",
28
+ onChange: (event) => onChange({
29
+ unit: "days",
30
+ ...current,
31
+ amount: Math.max(0, Number(event.target.value) || 0)
32
+ })
33
+ }), rule.op === "anniversary_within" ? /* @__PURE__ */ jsx("span", {
34
+ className: "text-sm text-muted-foreground",
35
+ children: t("days", "days")
36
+ }) : /* @__PURE__ */ jsxs(Select, {
37
+ value: current.unit ?? "days",
38
+ disabled,
39
+ onValueChange: (next) => {
40
+ const unit = oneOf(RELATIVE_UNITS, next);
41
+ if (unit) onChange({
42
+ amount: 0,
43
+ ...current,
44
+ unit
45
+ });
46
+ },
47
+ children: [/* @__PURE__ */ jsx(Select.Trigger, {
48
+ className: "h-8 w-28 shrink-0",
49
+ children: /* @__PURE__ */ jsx(Select.Value, {})
50
+ }), /* @__PURE__ */ jsx(Select.Content, { children: RELATIVE_UNITS.map((unit) => /* @__PURE__ */ jsx(Select.Item, {
51
+ value: unit,
52
+ children: t(unit, unit)
53
+ }, unit)) })]
54
+ })]
55
+ });
56
+ };
57
+ /** A team member ("me" first) or a tag of the subject. */
58
+ const LookupInput = ({ rule, field, onChange, disabled, ...lookups }) => {
59
+ const { t } = useTranslation("automations");
60
+ const isMember = field?.type === "member";
61
+ const value = textOf(rule.value);
62
+ const members = useMemberOptions(lookups.members, isMember, value ? [value] : []);
63
+ const tags = useTagOptions(lookups.tags, !isMember);
64
+ const lookup = isMember ? members : tags;
65
+ return /* @__PURE__ */ jsx(LookupPicker, {
66
+ lookup: isMember ? {
67
+ ...lookup,
68
+ options: [{
69
+ value: "me",
70
+ label: t("me", "Me")
71
+ }, ...lookup.options]
72
+ } : lookup,
73
+ value: value ? [value] : [],
74
+ onValueChange: ([next]) => onChange(next ?? ""),
75
+ disabled,
76
+ placeholder: t("choose", "Choose…"),
77
+ className: "h-8 w-full min-w-0"
78
+ });
79
+ };
80
+ const ListInput = ({ rule, onChange, disabled }) => {
81
+ const { t } = useTranslation("automations");
82
+ return /* @__PURE__ */ jsx(Input, {
83
+ className: "h-8 w-full min-w-0",
84
+ disabled,
85
+ placeholder: t("list-placeholder", "a, b, c"),
86
+ value: Array.isArray(rule.value) ? rule.value.join(", ") : textOf(rule.value),
87
+ onChange: (event) => onChange(event.target.value.split(",").map((item) => item.trim()).filter(Boolean))
88
+ });
89
+ };
90
+ const BooleanInput = ({ rule, onChange, disabled }) => {
91
+ const { t } = useTranslation("automations");
92
+ return /* @__PURE__ */ jsxs(Select, {
93
+ value: textOf(rule.value ?? "true"),
94
+ onValueChange: (value) => onChange(value === "true"),
95
+ disabled,
96
+ children: [/* @__PURE__ */ jsx(Select.Trigger, {
97
+ className: "h-8 w-28 shrink-0",
98
+ children: /* @__PURE__ */ jsx(Select.Value, {})
99
+ }), /* @__PURE__ */ jsxs(Select.Content, { children: [/* @__PURE__ */ jsx(Select.Item, {
100
+ value: "true",
101
+ children: t("yes", "yes")
102
+ }), /* @__PURE__ */ jsx(Select.Item, {
103
+ value: "false",
104
+ children: t("no", "no")
105
+ })] })]
106
+ });
107
+ };
108
+ const OptionInput = ({ rule, options, onChange, disabled }) => /* @__PURE__ */ jsxs(Select, {
109
+ value: textOf(rule.value),
110
+ onValueChange: onChange,
111
+ disabled,
112
+ children: [/* @__PURE__ */ jsx(Select.Trigger, {
113
+ className: "h-8 w-full min-w-0",
114
+ children: /* @__PURE__ */ jsx(Select.Value, {})
115
+ }), /* @__PURE__ */ jsx(Select.Content, { children: options.map((option) => /* @__PURE__ */ jsx(Select.Item, {
116
+ value: option,
117
+ children: option
118
+ }, option)) })]
119
+ });
120
+ const TextInput = ({ rule, field, onChange, disabled }) => {
121
+ const { t } = useTranslation("automations");
122
+ return /* @__PURE__ */ jsx(Input, {
123
+ className: "h-8 w-full min-w-0",
124
+ type: field?.type === "date" ? "date" : field?.type === "number" ? "number" : "text",
125
+ disabled,
126
+ placeholder: t("value-placeholder", "value"),
127
+ value: textOf(rule.value),
128
+ onChange: (event) => onChange(field?.type === "number" ? Number(event.target.value) : event.target.value)
129
+ });
130
+ };
131
+ /** An amount typed in the currency's major unit (12.50), kept in its smallest (1250); the text is kept while typing. */
132
+ const MoneyInput = ({ rule, onChange, disabled, currency }) => {
133
+ const { t } = useTranslation("automations");
134
+ const stored = Number(rule.value);
135
+ const [text, setText] = useState(rule.value === void 0 || !Number.isFinite(stored) ? "" : toAmountInput(stored, currency));
136
+ return /* @__PURE__ */ jsx(Input, {
137
+ className: "h-8 w-full min-w-0",
138
+ type: "number",
139
+ step: amountStep(currency),
140
+ disabled,
141
+ placeholder: t("value-placeholder", "value"),
142
+ value: text,
143
+ onChange: (event) => {
144
+ setText(event.target.value);
145
+ onChange(fromAmountInput(event.target.value, currency));
146
+ }
147
+ });
148
+ };
149
+ /** The value side of a rule, shaped by the operator and the field's type. */
150
+ const ConditionValueInput = (props) => {
151
+ const { rule, field } = props;
152
+ if (RELATIVE.has(rule.op)) return /* @__PURE__ */ jsx(RelativeInput, { ...props });
153
+ if (field?.currency && field.type === "number" && !LIST_VALUE.has(rule.op)) return /* @__PURE__ */ jsx(MoneyInput, {
154
+ ...props,
155
+ currency: field.currency
156
+ });
157
+ if (LIST_VALUE.has(rule.op)) return /* @__PURE__ */ jsx(ListInput, { ...props });
158
+ if (field?.type === "member" || field?.type === "tags") return /* @__PURE__ */ jsx(LookupInput, { ...props });
159
+ if (field?.type === "boolean") return /* @__PURE__ */ jsx(BooleanInput, { ...props });
160
+ if (field?.options?.length) return /* @__PURE__ */ jsx(OptionInput, {
161
+ ...props,
162
+ options: field.options
163
+ });
164
+ return /* @__PURE__ */ jsx(TextInput, { ...props });
165
+ };
166
+ export { ConditionValueInput };
@@ -0,0 +1,11 @@
1
+ import { TConditionField, TConditionGroup, TConditionLookups } from "./conditions.js";
2
+ /**
3
+ * Conditions: rows "<field> <operator> <value>", all or any, with nested groups, on `fields`
4
+ * (grouped in the picker when they have a `group`); `members` and `tags` feed their pickers.
5
+ */
6
+ export declare const ConditionsEditor: ({ value, onChange, disabled, fields, ...lookups }: TConditionLookups & {
7
+ value: TConditionGroup | undefined;
8
+ onChange: (next: TConditionGroup | undefined) => void;
9
+ disabled?: boolean;
10
+ fields: TConditionField[];
11
+ }) => import("react").JSX.Element;
@@ -0,0 +1,209 @@
1
+ import { Button } from "../../components/button.js";
2
+ import { Select } from "../../components/select.js";
3
+ import { useItemKeys } from "../../hooks/use-item-keys.js";
4
+ import { oneOf } from "../../lib/text.js";
5
+ import { cn } from "../../lib/utils.js";
6
+ import { CONDITION_OPERATORS, NO_VALUE, OPERATOR_LABELS, isRule, operatorsFor, withOperator } from "./conditions.js";
7
+ import { ConditionValueInput } from "./ConditionValueInput.js";
8
+ import { PathPicker } from "./PathPicker.js";
9
+ import { IconBraces, IconPlus, IconX } from "@tabler/icons-react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ import { useTranslation } from "react-i18next";
12
+ // src/modules/conditions/ConditionsEditor.tsx
13
+ /** Field and operator side by side, remove at the end; the value takes its own full line. */
14
+ const RuleRow = ({ rule, fields, disabled, lookups, onChange, onRemove }) => {
15
+ const { t } = useTranslation("automations");
16
+ const field = fields.find((one) => one.path === rule.path);
17
+ return /* @__PURE__ */ jsxs("div", {
18
+ className: "grid grid-cols-condition items-center gap-2",
19
+ children: [
20
+ /* @__PURE__ */ jsx(PathPicker, {
21
+ value: rule.path,
22
+ fields,
23
+ disabled,
24
+ onChange: (path) => onChange(fields.find((one) => one.path === path)?.type === field?.type ? {
25
+ ...rule,
26
+ path
27
+ } : {
28
+ ...rule,
29
+ path,
30
+ value: void 0
31
+ })
32
+ }),
33
+ /* @__PURE__ */ jsxs(Select, {
34
+ value: rule.op,
35
+ onValueChange: (next) => {
36
+ const op = oneOf(CONDITION_OPERATORS, next);
37
+ if (op) onChange(withOperator(rule, op));
38
+ },
39
+ disabled,
40
+ children: [/* @__PURE__ */ jsx(Select.Trigger, {
41
+ className: "h-8 w-full min-w-0",
42
+ "aria-label": t("operator", "Operator"),
43
+ children: /* @__PURE__ */ jsx(Select.Value, {})
44
+ }), /* @__PURE__ */ jsx(Select.Content, { children: operatorsFor(field?.type).map((op) => /* @__PURE__ */ jsx(Select.Item, {
45
+ value: op,
46
+ children: t(`op.${op}`, OPERATOR_LABELS[op])
47
+ }, op)) })]
48
+ }),
49
+ /* @__PURE__ */ jsx(Button, {
50
+ size: "icon",
51
+ variant: "ghost",
52
+ tone: "muted",
53
+ className: "size-8",
54
+ disabled,
55
+ onClick: onRemove,
56
+ "aria-label": t("remove", "Remove"),
57
+ children: /* @__PURE__ */ jsx(IconX, { className: "size-4" })
58
+ }),
59
+ !NO_VALUE.has(rule.op) && /* @__PURE__ */ jsx("div", {
60
+ className: "col-span-2 flex min-w-0",
61
+ children: /* @__PURE__ */ jsx(ConditionValueInput, {
62
+ rule,
63
+ field,
64
+ disabled,
65
+ ...lookups,
66
+ onChange: (value) => onChange({
67
+ ...rule,
68
+ value
69
+ })
70
+ })
71
+ })
72
+ ]
73
+ });
74
+ };
75
+ const MatchSelect = ({ group, onChange, onRemove, disabled }) => {
76
+ const { t } = useTranslation("automations");
77
+ return /* @__PURE__ */ jsxs("div", {
78
+ className: "flex items-center gap-2 text-sm",
79
+ children: [
80
+ /* @__PURE__ */ jsx("span", { children: t("match-prefix", "Match") }),
81
+ /* @__PURE__ */ jsxs(Select, {
82
+ value: group.match,
83
+ onValueChange: (match) => onChange({
84
+ ...group,
85
+ match: match === "any" ? "any" : "all"
86
+ }),
87
+ disabled,
88
+ children: [/* @__PURE__ */ jsx(Select.Trigger, {
89
+ className: "h-8 w-24",
90
+ "aria-label": t("match-prefix", "Match"),
91
+ children: /* @__PURE__ */ jsx(Select.Value, {})
92
+ }), /* @__PURE__ */ jsxs(Select.Content, { children: [/* @__PURE__ */ jsx(Select.Item, {
93
+ value: "all",
94
+ children: t("match-all", "all")
95
+ }), /* @__PURE__ */ jsx(Select.Item, {
96
+ value: "any",
97
+ children: t("match-any", "any")
98
+ })] })]
99
+ }),
100
+ /* @__PURE__ */ jsx("span", { children: t("match-suffix", "of these") }),
101
+ onRemove && /* @__PURE__ */ jsx(Button, {
102
+ size: "sm",
103
+ variant: "ghost",
104
+ className: "ml-auto",
105
+ disabled,
106
+ onClick: onRemove,
107
+ children: /* @__PURE__ */ jsx(IconX, {})
108
+ })
109
+ ]
110
+ });
111
+ };
112
+ const AddButtons = ({ newRule, newGroup, disabled, onAdd }) => {
113
+ const { t } = useTranslation("automations");
114
+ return /* @__PURE__ */ jsxs("div", {
115
+ className: "flex gap-2",
116
+ children: [/* @__PURE__ */ jsxs(Button, {
117
+ size: "sm",
118
+ variant: "outline",
119
+ disabled,
120
+ onClick: () => onAdd(newRule),
121
+ children: [/* @__PURE__ */ jsx(IconPlus, {}), t("add-condition", "Add condition")]
122
+ }), newGroup && /* @__PURE__ */ jsxs(Button, {
123
+ size: "sm",
124
+ variant: "ghost",
125
+ disabled,
126
+ onClick: () => onAdd(newGroup),
127
+ children: [/* @__PURE__ */ jsx(IconBraces, {}), t("add-group", "Add group")]
128
+ })]
129
+ });
130
+ };
131
+ /** One group: "all"/"any" of its rules and nested groups (up to three levels). */
132
+ const GroupEditor = ({ group, onChange, onRemove, fields, disabled, depth, lookups }) => {
133
+ const keys = useItemKeys(group.rules.length);
134
+ const update = (index, rule) => onChange({
135
+ ...group,
136
+ rules: group.rules.map((item, at) => at === index ? rule : item)
137
+ });
138
+ const remove = (index) => {
139
+ keys.removed(index);
140
+ onChange({
141
+ ...group,
142
+ rules: group.rules.filter((_, at) => at !== index)
143
+ });
144
+ };
145
+ const add = (rule) => {
146
+ keys.added();
147
+ onChange({
148
+ ...group,
149
+ rules: [...group.rules, rule]
150
+ });
151
+ };
152
+ return /* @__PURE__ */ jsxs("div", {
153
+ className: cn("space-y-2", depth > 0 && "rounded-md border border-dashed p-2"),
154
+ children: [
155
+ /* @__PURE__ */ jsx(MatchSelect, {
156
+ group,
157
+ onChange,
158
+ onRemove,
159
+ disabled
160
+ }),
161
+ group.rules.map((rule, index) => isRule(rule) ? /* @__PURE__ */ jsx(RuleRow, {
162
+ rule,
163
+ fields,
164
+ disabled,
165
+ lookups,
166
+ onChange: (next) => update(index, next),
167
+ onRemove: () => remove(index)
168
+ }, keys.keyAt(index)) : /* @__PURE__ */ jsx(GroupEditor, {
169
+ group: rule,
170
+ fields,
171
+ disabled,
172
+ lookups,
173
+ depth: depth + 1,
174
+ onChange: (next) => update(index, next),
175
+ onRemove: () => remove(index)
176
+ }, keys.keyAt(index))),
177
+ /* @__PURE__ */ jsx(AddButtons, {
178
+ newRule: {
179
+ path: fields[3]?.path ?? "subject.primaryEmail",
180
+ op: "exists"
181
+ },
182
+ newGroup: depth < 2 ? {
183
+ match: group.match === "all" ? "any" : "all",
184
+ rules: []
185
+ } : null,
186
+ disabled,
187
+ onAdd: add
188
+ })
189
+ ]
190
+ });
191
+ };
192
+ /**
193
+ * Conditions: rows "<field> <operator> <value>", all or any, with nested groups, on `fields`
194
+ * (grouped in the picker when they have a `group`); `members` and `tags` feed their pickers.
195
+ */
196
+ const ConditionsEditor = ({ value, onChange, disabled, fields, ...lookups }) => {
197
+ return /* @__PURE__ */ jsx(GroupEditor, {
198
+ group: value ?? {
199
+ match: "all",
200
+ rules: []
201
+ },
202
+ fields,
203
+ disabled,
204
+ lookups,
205
+ depth: 0,
206
+ onChange: (next) => onChange(next.rules.length ? next : void 0)
207
+ });
208
+ };
209
+ export { ConditionsEditor };
@@ -0,0 +1,10 @@
1
+ import { ConditionsEditor as ConditionsEditor$1 } from "./ConditionsEditor.js";
2
+ import { ComponentProps } from "react";
3
+ declare const Editor: import("react").LazyExoticComponent<typeof ConditionsEditor$1>;
4
+ /**
5
+ * Edits a condition group of rules, for automations and advanced filters.
6
+ * It is fetched the first time one renders: erxes-ui is one shared chunk every route loads,
7
+ * and only automations and a list's advanced filter edit conditions.
8
+ */
9
+ export declare const ConditionsEditor: (props: ComponentProps<typeof Editor>) => import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,11 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Suspense, lazy } from "react";
3
+ // src/modules/conditions/LazyConditionsEditor.tsx
4
+ const Editor = lazy(async () => ({ default: (await import("./ConditionsEditor.js")).ConditionsEditor }));
5
+ /**
6
+ * Edits a condition group of rules, for automations and advanced filters.
7
+ * It is fetched the first time one renders: erxes-ui is one shared chunk every route loads,
8
+ * and only automations and a list's advanced filter edit conditions.
9
+ */
10
+ const ConditionsEditor = (props) => /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(Editor, { ...props }) });
11
+ export { ConditionsEditor };
@@ -0,0 +1,8 @@
1
+ import { TConditionField } from "./conditions.js";
2
+ /** A field from the catalog, or any path typed by hand (`event.payload.amount`, `steps.x.output.y`). */
3
+ export declare const PathPicker: ({ value, fields, onChange, disabled }: {
4
+ value: string;
5
+ fields: TConditionField[];
6
+ onChange: (path: string) => void;
7
+ disabled?: boolean;
8
+ }) => import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ import { Input } from "../../components/input.js";
2
+ import { Select } from "../../components/select.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { useTranslation } from "react-i18next";
5
+ // src/modules/conditions/PathPicker.tsx
6
+ const GROUP_LABELS = {
7
+ fields: "Fields",
8
+ lead: "Lead",
9
+ custom: "Properties",
10
+ company: "Company",
11
+ activity: "Activity"
12
+ };
13
+ const CUSTOM_PATH = "__custom__";
14
+ const groupOf = (field) => field.group ?? "fields";
15
+ const FieldItems = ({ fields }) => fields.map((field) => /* @__PURE__ */ jsx(Select.Item, {
16
+ value: field.path,
17
+ children: field.label
18
+ }, field.path));
19
+ const GroupedFieldItems = ({ fields }) => {
20
+ const { t } = useTranslation("automations");
21
+ return [...new Set(fields.map(groupOf))].map((group) => /* @__PURE__ */ jsxs(Select.Group, { children: [/* @__PURE__ */ jsx(Select.Label, { children: t(`field-group.${group}`, GROUP_LABELS[group] ?? group) }), /* @__PURE__ */ jsx(FieldItems, { fields: fields.filter((field) => groupOf(field) === group) })] }, group));
22
+ };
23
+ /** A field from the catalog, or any path typed by hand (`event.payload.amount`, `steps.x.output.y`). */
24
+ const PathPicker = ({ value, fields, onChange, disabled }) => {
25
+ const { t } = useTranslation("automations");
26
+ const known = fields.some((field) => field.path === value);
27
+ const grouped = fields.some((field) => field.group);
28
+ return /* @__PURE__ */ jsxs("div", {
29
+ className: "flex min-w-0 gap-1",
30
+ children: [/* @__PURE__ */ jsxs(Select, {
31
+ value: known ? value : CUSTOM_PATH,
32
+ onValueChange: (path) => onChange(path === CUSTOM_PATH ? "" : path),
33
+ disabled,
34
+ children: [/* @__PURE__ */ jsx(Select.Trigger, {
35
+ className: "h-8 w-full min-w-0",
36
+ children: /* @__PURE__ */ jsx(Select.Value, {})
37
+ }), /* @__PURE__ */ jsxs(Select.Content, { children: [grouped ? /* @__PURE__ */ jsx(GroupedFieldItems, { fields }) : /* @__PURE__ */ jsx(FieldItems, { fields }), !grouped && /* @__PURE__ */ jsx(Select.Item, {
38
+ value: CUSTOM_PATH,
39
+ children: t("custom-path", "Another value…")
40
+ })] })]
41
+ }), !known && /* @__PURE__ */ jsx(Input, {
42
+ text: "code",
43
+ className: "h-8 w-full min-w-0",
44
+ placeholder: "event.payload.amount",
45
+ value,
46
+ disabled,
47
+ onChange: (event) => onChange(event.target.value)
48
+ })]
49
+ });
50
+ };
51
+ export { PathPicker };
@@ -0,0 +1,66 @@
1
+ import { TagsQuery } from "../pickers/LookupPicker.js";
2
+ import { MemberQueries } from "../pickers/members.js";
3
+ import { z } from "zod";
4
+ export declare const CONDITION_OPERATORS: readonly ['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'contains', 'not_contains', 'starts_with', 'in', 'not_in', 'exists', 'not_exists', 'within_last', 'more_than_ago', 'within_next', 'anniversary_within'];
5
+ export type TConditionOperator = (typeof CONDITION_OPERATORS)[number];
6
+ /** `all`: every condition holds; `any`: one does. */
7
+ declare const CONDITION_MATCHES: readonly ['all', 'any'];
8
+ /** The units of a relative date's `{ amount, unit }`. */
9
+ export declare const RELATIVE_UNITS: readonly ['days', 'weeks', 'months'];
10
+ /** One rule of a condition: a `path`, an operator and maybe a value. */
11
+ export type TConditionRule = {
12
+ /** `subject.primaryEmail`, `event.payload.amount`, `steps.s2.output.id`. */
13
+ path: string;
14
+ op: TConditionOperator;
15
+ value?: unknown;
16
+ };
17
+ /** Rules (or nested groups) that must all, or any, hold. */
18
+ export type TConditionGroup = {
19
+ match: (typeof CONDITION_MATCHES)[number];
20
+ rules: (TConditionRule | TConditionGroup)[];
21
+ };
22
+ /** Parses a condition group from outside (the address); core checks the rest. */
23
+ export declare const ConditionGroup: z.ZodType<TConditionGroup, unknown, z.core.$ZodTypeInternals<TConditionGroup, unknown>>;
24
+ /** The value of a relative-date rule: "within the last 30 days". */
25
+ export declare const RelativeAmount: z.ZodObject<{
26
+ amount: z.ZodInt;
27
+ unit: z.ZodDefault<z.ZodEnum<{
28
+ days: "days";
29
+ months: "months";
30
+ weeks: "weeks";
31
+ }>>;
32
+ }, z.core.$strip>;
33
+ export type RelativeAmount = z.infer<typeof RelativeAmount>;
34
+ /**
35
+ * A field conditions can use: a record's, or an earlier step's output. `group`: where it comes
36
+ * from, for grouping in the picker (a list's advanced filter).
37
+ */
38
+ export type TConditionField = {
39
+ path: string;
40
+ label: string;
41
+ type: string;
42
+ options?: string[];
43
+ group?: string;
44
+ /** A money amount, stored in this currency's smallest unit and typed in its major unit. */
45
+ currency?: string;
46
+ };
47
+ /**
48
+ * Where `member` and `tags` values pick from. In erxes: `memberQueries` from
49
+ * `@erxes/core-contract/client`, and web's tags query for the record type. Without one, the
50
+ * picker has nothing to offer.
51
+ */
52
+ export type TConditionLookups = {
53
+ members?: MemberQueries;
54
+ tags?: TagsQuery;
55
+ };
56
+ export declare const OPERATOR_LABELS: Record<TConditionOperator, string>;
57
+ /** Operators that make sense for a field's type. */
58
+ export declare const operatorsFor: (type: string | undefined) => readonly ["eq", "neq"] | readonly ["contains", "not_contains", "exists", "not_exists"] | readonly ["eq", "neq", "in", "not_in", "exists", "not_exists"] | readonly ["eq", "neq", "gt", "gte", "lt", "lte", "exists", "not_exists"] | readonly ["within_last", "more_than_ago", "within_next", "anniversary_within", "eq", "gt", "lt", "exists", "not_exists"] | readonly ["eq", "neq", "gt", "gte", "lt", "lte", "contains", "not_contains", "starts_with", "in", "not_in", "exists", "not_exists", "within_last", "more_than_ago", "within_next", "anniversary_within"];
59
+ export declare const NO_VALUE: Set<string>;
60
+ export declare const RELATIVE: Set<string>;
61
+ export declare const LIST_VALUE: Set<string>;
62
+ /** Whether a condition entry is a rule rather than a nested group. */
63
+ export declare const isRule: (rule: TConditionRule | TConditionGroup) => rule is TConditionRule;
64
+ /** A relative date takes `{ amount, unit }`; switching to or from one resets the value. */
65
+ export declare const withOperator: (rule: TConditionRule, op: TConditionOperator) => TConditionRule;
66
+ export {};
@@ -0,0 +1,136 @@
1
+ import { z } from "zod";
2
+ // src/modules/conditions/conditions.ts
3
+ const CONDITION_OPERATORS = [
4
+ "eq",
5
+ "neq",
6
+ "gt",
7
+ "gte",
8
+ "lt",
9
+ "lte",
10
+ "contains",
11
+ "not_contains",
12
+ "starts_with",
13
+ "in",
14
+ "not_in",
15
+ "exists",
16
+ "not_exists",
17
+ "within_last",
18
+ "more_than_ago",
19
+ "within_next",
20
+ "anniversary_within"
21
+ ];
22
+ /** `all`: every condition holds; `any`: one does. */
23
+ const CONDITION_MATCHES = ["all", "any"];
24
+ /** The units of a relative date's `{ amount, unit }`. */
25
+ const RELATIVE_UNITS = [
26
+ "days",
27
+ "weeks",
28
+ "months"
29
+ ];
30
+ /** Core's limits, so a filter the UI accepts is one core's API accepts too. */
31
+ const MAX_RULES = 50;
32
+ const MAX_AMOUNT = 3650;
33
+ /** Groups nest as deep as the editor builds them: a group, and two levels inside it. */
34
+ const MAX_DEPTH = 3;
35
+ const ConditionRule = z.object({
36
+ path: z.string().trim().regex(/^(event|subject|steps|run)(\.[A-Za-z0-9_-]+)*$/),
37
+ op: z.enum(CONDITION_OPERATORS),
38
+ value: z.unknown().optional()
39
+ });
40
+ /** A group whose groups nest at most `depth` levels, so a crafted address can't recurse on. */
41
+ const groupOf = (depth) => z.object({
42
+ match: z.enum(CONDITION_MATCHES),
43
+ rules: z.array(depth > 1 ? z.union([ConditionRule, groupOf(depth - 1)]) : ConditionRule).max(MAX_RULES)
44
+ });
45
+ /** Parses a condition group from outside (the address); core checks the rest. */
46
+ const ConditionGroup = groupOf(MAX_DEPTH);
47
+ /** The value of a relative-date rule: "within the last 30 days". */
48
+ const RelativeAmount = z.object({
49
+ amount: z.int().min(0).max(MAX_AMOUNT),
50
+ unit: z.enum(RELATIVE_UNITS).default("days")
51
+ });
52
+ const OPERATOR_LABELS = {
53
+ eq: "is",
54
+ neq: "is not",
55
+ gt: "is greater than",
56
+ gte: "is at least",
57
+ lt: "is less than",
58
+ lte: "is at most",
59
+ contains: "contains",
60
+ not_contains: "doesn't contain",
61
+ starts_with: "starts with",
62
+ in: "is one of",
63
+ not_in: "is none of",
64
+ exists: "is set",
65
+ not_exists: "is empty",
66
+ within_last: "in the last",
67
+ more_than_ago: "more than … ago",
68
+ within_next: "in the next",
69
+ anniversary_within: "anniversary in the next"
70
+ };
71
+ /** Operators that make sense for a field's type. */
72
+ const operatorsFor = (type) => {
73
+ if (type === "date") return [
74
+ "within_last",
75
+ "more_than_ago",
76
+ "within_next",
77
+ "anniversary_within",
78
+ "eq",
79
+ "gt",
80
+ "lt",
81
+ "exists",
82
+ "not_exists"
83
+ ];
84
+ if (type === "number") return [
85
+ "eq",
86
+ "neq",
87
+ "gt",
88
+ "gte",
89
+ "lt",
90
+ "lte",
91
+ "exists",
92
+ "not_exists"
93
+ ];
94
+ if (type === "tags" || type === "list") return [
95
+ "contains",
96
+ "not_contains",
97
+ "exists",
98
+ "not_exists"
99
+ ];
100
+ if (type === "boolean") return ["eq", "neq"];
101
+ if (type === "select" || type === "member") return [
102
+ "eq",
103
+ "neq",
104
+ "in",
105
+ "not_in",
106
+ "exists",
107
+ "not_exists"
108
+ ];
109
+ return CONDITION_OPERATORS;
110
+ };
111
+ const NO_VALUE = /* @__PURE__ */ new Set(["exists", "not_exists"]);
112
+ const RELATIVE = /* @__PURE__ */ new Set([
113
+ "within_last",
114
+ "more_than_ago",
115
+ "within_next",
116
+ "anniversary_within"
117
+ ]);
118
+ const LIST_VALUE = /* @__PURE__ */ new Set(["in", "not_in"]);
119
+ /** Whether a condition entry is a rule rather than a nested group. */
120
+ const isRule = (rule) => !("match" in rule);
121
+ /** A relative date takes `{ amount, unit }`; switching to or from one resets the value. */
122
+ const withOperator = (rule, op) => {
123
+ if (RELATIVE.has(op) === RELATIVE.has(rule.op)) return {
124
+ ...rule,
125
+ op
126
+ };
127
+ return {
128
+ ...rule,
129
+ op,
130
+ value: RELATIVE.has(op) ? {
131
+ amount: 30,
132
+ unit: "days"
133
+ } : void 0
134
+ };
135
+ };
136
+ export { CONDITION_OPERATORS, ConditionGroup, LIST_VALUE, NO_VALUE, OPERATOR_LABELS, RELATIVE, RELATIVE_UNITS, RelativeAmount, isRule, operatorsFor, withOperator };
@@ -1,2 +1,6 @@
1
1
  import { EmailDisplayProps } from "../types/emailDisplay.js";
2
+ /**
3
+ * A record's emails as chips, the primary one with its validation mark.
4
+ * `maxVisible` shows that many and a +N badge for the rest; `onEmailClick` makes each a button.
5
+ */
2
6
  export declare const EmailDisplay: ({ maxVisible, primaryEmail, emails, emailValidationStatus, ...handlers }: EmailDisplayProps) => import("react").JSX.Element;