@erxes/ui 4.0.0-v2.7 → 4.0.0-v2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +10 -3
  2. package/dist/hooks/use-item-keys.d.ts +10 -0
  3. package/dist/hooks/use-item-keys.js +23 -0
  4. package/dist/index.d.ts +11 -2
  5. package/dist/index.js +10 -2
  6. package/dist/lib/format.d.ts +2 -0
  7. package/dist/lib/format.js +6 -1
  8. package/dist/lib/money.d.ts +10 -0
  9. package/dist/lib/money.js +18 -0
  10. package/dist/lib/text.d.ts +7 -0
  11. package/dist/lib/text.js +14 -0
  12. package/dist/modules/conditions/ConditionValueInput.d.ts +10 -0
  13. package/dist/modules/conditions/ConditionValueInput.js +166 -0
  14. package/dist/modules/conditions/ConditionsEditor.d.ts +11 -0
  15. package/dist/modules/conditions/ConditionsEditor.js +209 -0
  16. package/dist/modules/conditions/LazyConditionsEditor.d.ts +9 -0
  17. package/dist/modules/conditions/LazyConditionsEditor.js +10 -0
  18. package/dist/modules/conditions/PathPicker.d.ts +8 -0
  19. package/dist/modules/conditions/PathPicker.js +51 -0
  20. package/dist/modules/conditions/conditions.d.ts +64 -0
  21. package/dist/modules/conditions/conditions.js +135 -0
  22. package/dist/modules/list/DisplayMenu.d.ts +14 -7
  23. package/dist/modules/list/DisplayMenu.js +48 -28
  24. package/dist/modules/list/ListFilter.d.ts +25 -11
  25. package/dist/modules/list/ListFilter.js +30 -26
  26. package/dist/modules/list/filter/AdvancedFilterDialog.d.ts +5 -0
  27. package/dist/modules/list/filter/AdvancedFilterDialog.js +52 -0
  28. package/dist/modules/list/filter/FieldMenus.d.ts +5 -0
  29. package/dist/modules/list/filter/FieldMenus.js +184 -0
  30. package/dist/modules/list/filter/ListFilterBar.d.ts +6 -0
  31. package/dist/modules/list/filter/ListFilterBar.js +246 -0
  32. package/dist/modules/list/filter/RecordCount.d.ts +7 -0
  33. package/dist/modules/list/filter/RecordCount.js +22 -0
  34. package/dist/modules/list/filter/RuleChips.d.ts +2 -0
  35. package/dist/modules/list/filter/RuleChips.js +157 -0
  36. package/dist/modules/list/filter/fieldIcons.d.ts +7 -0
  37. package/dist/modules/list/filter/fieldIcons.js +16 -0
  38. package/dist/modules/list/filter/filterRules.d.ts +46 -0
  39. package/dist/modules/list/filter/filterRules.js +166 -0
  40. package/dist/modules/list/filter/listFilterContext.d.ts +29 -0
  41. package/dist/modules/list/filter/listFilterContext.js +34 -0
  42. package/dist/modules/list/filter/listFilterQuery.d.ts +15 -0
  43. package/dist/modules/list/filter/listFilterQuery.js +21 -0
  44. package/dist/modules/pickers/LookupPicker.d.ts +50 -0
  45. package/dist/modules/pickers/LookupPicker.js +83 -0
  46. package/dist/modules/record-list/RecordList.d.ts +12 -0
  47. package/dist/modules/record-list/RecordList.js +17 -0
  48. package/dist/modules/record-list/RecordListProvider.d.ts +30 -0
  49. package/dist/modules/record-list/RecordListProvider.js +57 -0
  50. package/dist/modules/record-list/RecordListRoot.d.ts +28 -0
  51. package/dist/modules/record-list/RecordListRoot.js +124 -0
  52. package/dist/modules/record-list/selection.d.ts +22 -0
  53. package/dist/modules/record-list/selection.js +54 -0
  54. package/dist/theme.css +2 -0
  55. package/package.json +2 -1
package/README.md CHANGED
@@ -27,6 +27,8 @@ Only what something uses:
27
27
  `useLiveSignal`, `RecordTimeline`, `getPluginAssetsUrl`, `addPluginStyles` and the `IUIConfig` types,
28
28
  - the design-system primitives in `src/components` (Accordion, Card, Slider …), even unused,
29
29
  because plugins build on them,
30
+ - the record views plugins build lists from: `RecordTable` and `RecordList` (rows grouped under
31
+ headers that fold away, such as tasks by status; the Operation plugin is the first consumer),
30
32
  - the pickers in `src/modules/pickers`: `EntityPicker`, and `SelectMember`, `MemberInline` and
31
33
  `useMembersById`, which take `memberQueries` from `@erxes/core-contract/client`. They read
32
34
  through TanStack query options, so erxes-ui imports nothing from core.
@@ -39,10 +41,15 @@ Only what something uses:
39
41
  `PanelField`, `PanelFormRow`, `PanelFormLayout`, `PanelLabel`, the description field and
40
42
  editor, and `usePanelExpanded`. The panel itself (header, tabs, resize) is web's.
41
43
  - a list's bar in `src/modules/list`: `ViewBar`, `DisplayMenu` with `useListDisplay`, and
42
- `ListFilter` with `useListFilterParams`.
44
+ `ListFilter` with `useListFilterParams`. `ListFilter` draws core's filter bar itself, with or
45
+ without web: its `member` fields pick from `members` (`memberQueries` from
46
+ `@erxes/core-contract/client`) and its `tags` fields from `tags` (a tags query of the record
47
+ type); a plugin outside erxes passes its own. Web's lists and the automation builder use the
48
+ same bar and the condition editor under its advanced filter (`ConditionsEditor`,
49
+ `src/modules/conditions`).
43
50
  - what the host app provides at startup, rendered through `hostComponent`
44
- (`src/utils/host-component.tsx`): `setRecordTimeline`, `setRecordPage` and `setListFilter`.
45
- Outside erxes they render nothing.
51
+ (`src/utils/host-component.tsx`): `setRecordTimeline` and `setRecordPage`. Outside erxes they
52
+ render nothing.
46
53
 
47
54
  Anything else is removed, not kept "in case". Before you remove an export, check the HR plugin
48
55
  UI and `.agents/skills/plugin-contract/SKILL.md`.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Stable React keys for an editable list whose items have no id (condition rules, switch
3
+ * cases). Call `added` and `removed` next to the change, so a row keeps its key when an
4
+ * earlier one goes. A list replaced from outside keeps its first keys and gains or drops the rest.
5
+ */
6
+ export declare const useItemKeys: (length: number) => {
7
+ keyAt: (index: number) => string;
8
+ added: () => void;
9
+ removed: (index: number) => void;
10
+ };
@@ -0,0 +1,23 @@
1
+ import { useState } from "react";
2
+ // src/hooks/use-item-keys.ts
3
+ let counter = 0;
4
+ const newKey = () => {
5
+ counter += 1;
6
+ return `item-${counter}`;
7
+ };
8
+ /**
9
+ * Stable React keys for an editable list whose items have no id (condition rules, switch
10
+ * cases). Call `added` and `removed` next to the change, so a row keeps its key when an
11
+ * earlier one goes. A list replaced from outside keeps its first keys and gains or drops the rest.
12
+ */
13
+ const useItemKeys = (length) => {
14
+ const [keys, setKeys] = useState(() => Array.from({ length }, newKey));
15
+ const synced = keys.length === length ? keys : Array.from({ length }, (_, at) => keys[at] ?? newKey());
16
+ if (synced !== keys) setKeys(synced);
17
+ return {
18
+ keyAt: (index) => synced[index] ?? String(index),
19
+ added: () => setKeys((current) => [...current, newKey()]),
20
+ removed: (index) => setKeys((current) => current.filter((_, at) => at !== index))
21
+ };
22
+ };
23
+ export { useItemKeys };
package/dist/index.d.ts CHANGED
@@ -56,12 +56,15 @@ import { Toggle } from "./components/toggle.js";
56
56
  import { Tooltip } from "./components/tooltip.js";
57
57
  import { Upload } from "./components/upload.js";
58
58
  import { useConfirm } from "./hooks/use-confirm.js";
59
+ import { useItemKeys } from "./hooks/use-item-keys.js";
59
60
  import { usePageHotkey } from "./hooks/use-page-hotkey.js";
60
61
  import { toast, useToast } from "./hooks/use-toast.js";
61
62
  import { useUpload } from "./hooks/use-upload.js";
62
63
  import { cn } from "./lib/utils.js";
63
64
  import { LANGUAGES, formatter, localTimeZone, toIsoDay, useFormat, zoneOffset } from "./lib/format.js";
65
+ import { amountStep, formatMoney, fromAmountInput, toAmountInput, useMoney } from "./lib/money.js";
64
66
  import { stored, storedFamily } from "./lib/stored.js";
67
+ import { oneOf, textOf } from "./lib/text.js";
65
68
  import { Editor } from "./modules/blocks/components/LazyEditor.js";
66
69
  import { editorText } from "./modules/blocks/utils/parseBlocks.js";
67
70
  import { EmailDisplay } from "./modules/display/components/EmailDisplay.js";
@@ -87,15 +90,21 @@ import { NavigationMenuLinkItem } from "./modules/navigation-menu/components/Nav
87
90
  import { EntityPicker } from "./modules/pickers/EntityPicker.js";
88
91
  import { Member, MemberQueries, memberName, useMembersById } from "./modules/pickers/members.js";
89
92
  import { MemberInline, SelectMember } from "./modules/pickers/SelectMember.js";
93
+ import { LookupPicker, Tag, TagsQuery, useMemberOptions, useTagOptions } from "./modules/pickers/LookupPicker.js";
90
94
  import { NumberField } from "./modules/record-field/components/NumberField.js";
91
95
  import { TextField } from "./modules/record-field/components/TextField.js";
92
96
  import { PhoneInput } from "./modules/record-field/meta-inputs/components/PhoneInput.js";
97
+ import { RecordList } from "./modules/record-list/RecordList.js";
98
+ import { RecordListGroup } from "./modules/record-list/RecordListRoot.js";
93
99
  import { RecordTable } from "./modules/record-table/components/RecordTable.js";
94
100
  import { RecordTableColumnDef } from "./modules/record-table/components/RecordTableProvider.js";
95
101
  import { RecordTableInlineCell } from "./modules/record-table/components/RecordTableCellInline.js";
96
102
  import { EnumCursorDirection } from "./modules/record-table/types/RecordTableCursorTypes.js";
97
103
  import { DisplayMenu, TListDisplay, useListDisplay } from "./modules/list/DisplayMenu.js";
98
- import { ListFilter, TListFilterField, TListFilterProps, setListFilter, useListFilterParams } from "./modules/list/ListFilter.js";
104
+ import { ListFilter, TListFilterField, TListFilterProps, useListFilterParams } from "./modules/list/ListFilter.js";
105
+ import { listFilterQuery } from "./modules/list/filter/listFilterQuery.js";
106
+ import { TConditionField, TConditionGroup, TConditionLookups, TConditionRule, isRule } from "./modules/conditions/conditions.js";
107
+ import { ConditionsEditor } from "./modules/conditions/LazyConditionsEditor.js";
99
108
  import { ViewBar } from "./modules/list/ViewBar.js";
100
109
  import { PanelDescriptionEditor } from "./modules/record-panel/PanelDescriptionEditor.js";
101
110
  import { PanelDescriptionField } from "./modules/record-panel/PanelDescriptionField.js";
@@ -119,4 +128,4 @@ import { jsonOf } from "./utils/json.js";
119
128
  import { PluginLiveMessage, PluginRuntime, PluginSession, getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
120
129
  import { addPluginStyles } from "./utils/plugin-styles.js";
121
130
  import { RecordTimeline, RecordTimelineProps, setRecordTimeline } from "./utils/record-timeline.js";
122
- export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, type AvatarProps, BackgroundGradientAnimation, Badge, type BadgeProps, Breadcrumb, Button, type ButtonProps, Calendar, type CalendarProps, Card, type ChartConfig, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, type CompanyContact, ContactLink, type ContactQueries, ContextMenu, CopyText, type CustomerContact, DateInput, DatePicker, Dialog, DisplayMenu, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, type FileStorageAdapter, Filter, Form, FullNameField, FullNameValue, HoverCard, type IUIConfig, IconComponent, IconPicker, IconTip, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, ListFilter, type Member, MemberInline, type MemberQueries, type MultiSelectOption, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PanelDescriptionEditor, PanelDescriptionField, PanelExpansionContext, PanelField, PanelFieldTrigger, PanelFormLayout, PanelFormRow, PanelLabel, PanelSection, PhoneDisplay, PhoneField, PhoneInput, type PluginLiveMessage, type PluginRuntime, type PluginSession, Popover, PopoverScoped, RadioGroup, RecordOpenerProvider, RecordPage, type RecordRef, RecordTable, type RecordTableColumnDef, RecordTableInlineCell, RecordTimeline, type RecordTimelineProps, RelativeDateDisplay, Resizable, ScrollArea, Select, SelectMember, Separator, SexCode, SexDisplay, SexField, Sheet, Sidebar, Skeleton, Slider, Spinner, StringArrayInput, Switch, type TActivityRowProps, type TContactContentType, type TDashboardWidgetPreview, type TListDisplay, type TListFilterField, type TListFilterProps, type TPanelRecordType, type TPropertyInputMeta, type TPropertyInputProps, type TRecordContacts, type TRecordDraftProps, type TRecordSection, type TRecordSectionProps, type TRecordSlotProps, type TRecordTab, type TRelationTab, type TRelationTabProps, TabButton, Table, Tabs, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, ViewBar, addPluginStyles, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatPhoneNumber, formatter, getPluginAssetsUrl, getPluginRuntime, isUndefinedOrNull, jsonOf, localTimeZone, memberName, pluginFetch, pluginJson, readImage, setFileStorage, setListFilter, setPluginRuntime, setRecordPage, setRecordTimeline, stored, storedFamily, themeState, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useListDisplay, useListFilterParams, useLiveSignal, useMembersById, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useScopedHotkeys, useToast, useUpload, zoneOffset };
131
+ export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, type AvatarProps, BackgroundGradientAnimation, Badge, type BadgeProps, Breadcrumb, Button, type ButtonProps, Calendar, type CalendarProps, Card, type ChartConfig, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, type CompanyContact, ConditionsEditor, ContactLink, type ContactQueries, ContextMenu, CopyText, type CustomerContact, DateInput, DatePicker, Dialog, DisplayMenu, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, type FileStorageAdapter, Filter, Form, FullNameField, FullNameValue, HoverCard, type IUIConfig, IconComponent, IconPicker, IconTip, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, ListFilter, LookupPicker, type Member, MemberInline, type MemberQueries, type MultiSelectOption, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PanelDescriptionEditor, PanelDescriptionField, PanelExpansionContext, PanelField, PanelFieldTrigger, PanelFormLayout, PanelFormRow, PanelLabel, PanelSection, PhoneDisplay, PhoneField, PhoneInput, type PluginLiveMessage, type PluginRuntime, type PluginSession, Popover, PopoverScoped, RadioGroup, RecordList, type RecordListGroup, RecordOpenerProvider, RecordPage, type RecordRef, RecordTable, type RecordTableColumnDef, RecordTableInlineCell, RecordTimeline, type RecordTimelineProps, RelativeDateDisplay, Resizable, ScrollArea, Select, SelectMember, Separator, SexCode, SexDisplay, SexField, Sheet, Sidebar, Skeleton, Slider, Spinner, StringArrayInput, Switch, type TActivityRowProps, type TConditionField, type TConditionGroup, type TConditionLookups, type TConditionRule, type TContactContentType, type TDashboardWidgetPreview, type TListDisplay, type TListFilterField, type TListFilterProps, type TPanelRecordType, type TPropertyInputMeta, type TPropertyInputProps, type TRecordContacts, type TRecordDraftProps, type TRecordSection, type TRecordSectionProps, type TRecordSlotProps, type TRecordTab, type TRelationTab, type TRelationTabProps, TabButton, Table, Tabs, type Tag, type TagsQuery, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, ViewBar, addPluginStyles, amountStep, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatMoney, formatPhoneNumber, formatter, fromAmountInput, getPluginAssetsUrl, getPluginRuntime, isRule, isUndefinedOrNull, jsonOf, listFilterQuery, localTimeZone, memberName, oneOf, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordPage, setRecordTimeline, stored, storedFamily, textOf, themeState, toAmountInput, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useItemKeys, useListDisplay, useListFilterParams, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
package/dist/index.js CHANGED
@@ -54,12 +54,15 @@ import { Toggle } from "./components/toggle.js";
54
54
  import { Tooltip } from "./components/tooltip.js";
55
55
  import { Upload } from "./components/upload.js";
56
56
  import { useConfirm } from "./hooks/use-confirm.js";
57
+ import { useItemKeys } from "./hooks/use-item-keys.js";
57
58
  import { usePageHotkey } from "./hooks/use-page-hotkey.js";
58
59
  import { toast, useToast } from "./hooks/use-toast.js";
59
60
  import { useUpload } from "./hooks/use-upload.js";
60
61
  import { cn } from "./lib/utils.js";
61
62
  import { LANGUAGES, formatter, localTimeZone, toIsoDay, useFormat, zoneOffset } from "./lib/format.js";
63
+ import { amountStep, formatMoney, fromAmountInput, toAmountInput, useMoney } from "./lib/money.js";
62
64
  import { stored, storedFamily } from "./lib/stored.js";
65
+ import { oneOf, textOf } from "./lib/text.js";
63
66
  import { Editor } from "./modules/blocks/components/LazyEditor.js";
64
67
  import { editorText } from "./modules/blocks/utils/parseBlocks.js";
65
68
  import { EmailDisplay } from "./modules/display/components/EmailDisplay.js";
@@ -85,14 +88,19 @@ import { NavigationMenuLinkItem } from "./modules/navigation-menu/components/Nav
85
88
  import { EntityPicker } from "./modules/pickers/EntityPicker.js";
86
89
  import { memberName, useMembersById } from "./modules/pickers/members.js";
87
90
  import { MemberInline, SelectMember } from "./modules/pickers/SelectMember.js";
91
+ import { LookupPicker, useMemberOptions, useTagOptions } from "./modules/pickers/LookupPicker.js";
88
92
  import { NumberField } from "./modules/record-field/components/NumberField.js";
89
93
  import { TextField } from "./modules/record-field/components/TextField.js";
90
94
  import { PhoneInput } from "./modules/record-field/meta-inputs/components/PhoneInput.js";
95
+ import { RecordList } from "./modules/record-list/RecordList.js";
91
96
  import { RecordTable } from "./modules/record-table/components/RecordTable.js";
92
97
  import { RecordTableInlineCell } from "./modules/record-table/components/RecordTableCellInline.js";
93
98
  import { EnumCursorDirection } from "./modules/record-table/types/RecordTableCursorTypes.js";
94
99
  import { DisplayMenu, useListDisplay } from "./modules/list/DisplayMenu.js";
95
- import { ListFilter, setListFilter, useListFilterParams } from "./modules/list/ListFilter.js";
100
+ import { ListFilter, useListFilterParams } from "./modules/list/ListFilter.js";
101
+ import { listFilterQuery } from "./modules/list/filter/listFilterQuery.js";
102
+ import { isRule } from "./modules/conditions/conditions.js";
103
+ import { ConditionsEditor } from "./modules/conditions/LazyConditionsEditor.js";
96
104
  import { ViewBar } from "./modules/list/ViewBar.js";
97
105
  import { PanelDescriptionEditor } from "./modules/record-panel/PanelDescriptionEditor.js";
98
106
  import { PanelDescriptionField } from "./modules/record-panel/PanelDescriptionField.js";
@@ -115,4 +123,4 @@ import { jsonOf } from "./utils/json.js";
115
123
  import { getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
116
124
  import { addPluginStyles } from "./utils/plugin-styles.js";
117
125
  import { RecordTimeline, setRecordTimeline } from "./utils/record-timeline.js";
118
- export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, BackgroundGradientAnimation, Badge, Breadcrumb, Button, Calendar, Card, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, ContactLink, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DisplayMenu, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, Filter, Form, FullNameField, FullNameValue, HoverCard, IconComponent, IconPicker, IconTip, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, ListFilter, MemberInline, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PanelDescriptionEditor, PanelDescriptionField, PanelExpansionContext, PanelField, PanelFieldTrigger, PanelFormLayout, PanelFormRow, PanelLabel, PanelSection, PhoneDisplay, PhoneField, PhoneInput, Popover, PopoverScoped, RadioGroup, RecordOpenerProvider, RecordPage, RecordTable, RecordTableInlineCell, RecordTimeline, RelativeDateDisplay, Resizable, ScrollArea, Select, SelectMember, Separator, SexCode, SexDisplay, SexField, Sheet, Sidebar, Skeleton, Slider, Spinner, StringArrayInput, Switch, TabButton, Table, Tabs, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, ViewBar, addPluginStyles, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatPhoneNumber, formatter, getPluginAssetsUrl, getPluginRuntime, isUndefinedOrNull, jsonOf, localTimeZone, memberName, pluginFetch, pluginJson, readImage, setFileStorage, setListFilter, setPluginRuntime, setRecordPage, setRecordTimeline, stored, storedFamily, themeState, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useListDisplay, useListFilterParams, useLiveSignal, useMembersById, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useScopedHotkeys, useToast, useUpload, zoneOffset };
126
+ export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, BackgroundGradientAnimation, Badge, Breadcrumb, Button, Calendar, Card, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, ConditionsEditor, ContactLink, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DisplayMenu, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, Filter, Form, FullNameField, FullNameValue, HoverCard, IconComponent, IconPicker, IconTip, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, ListFilter, LookupPicker, MemberInline, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PanelDescriptionEditor, PanelDescriptionField, PanelExpansionContext, PanelField, PanelFieldTrigger, PanelFormLayout, PanelFormRow, PanelLabel, PanelSection, PhoneDisplay, PhoneField, PhoneInput, Popover, PopoverScoped, RadioGroup, RecordList, RecordOpenerProvider, RecordPage, RecordTable, RecordTableInlineCell, RecordTimeline, RelativeDateDisplay, Resizable, ScrollArea, Select, SelectMember, Separator, SexCode, SexDisplay, SexField, Sheet, Sidebar, Skeleton, Slider, Spinner, StringArrayInput, Switch, TabButton, Table, Tabs, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, ViewBar, addPluginStyles, amountStep, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatMoney, formatPhoneNumber, formatter, fromAmountInput, getPluginAssetsUrl, getPluginRuntime, isRule, isUndefinedOrNull, jsonOf, listFilterQuery, localTimeZone, memberName, oneOf, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordPage, setRecordTimeline, stored, storedFamily, textOf, themeState, toAmountInput, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useItemKeys, useListDisplay, useListFilterParams, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
@@ -26,6 +26,8 @@ export declare const formatter: (language: string) => {
26
26
  /** An amount in the currency's main unit: 1500 MNT → "MNT 1,500.00". */
27
27
  currency: (value: number, currency: string) => string;
28
28
  };
29
+ /** How many decimals a currency has (USD and MNT 2, JPY 0, KWD 3). */
30
+ export declare const currencyDigits: (currency: string) => number;
29
31
  /** The formatters in the UI's language; a component using them re-renders when it changes. */
30
32
  export declare const useFormat: () => {
31
33
  /** A date in a date-fns pattern; `PP` by default ("Nov 14, 2026"). */
@@ -49,6 +49,11 @@ const formatter = (language) => {
49
49
  }).format(value)
50
50
  };
51
51
  };
52
+ /** How many decimals a currency has (USD and MNT 2, JPY 0, KWD 3). */
53
+ const currencyDigits = (currency) => new Intl.NumberFormat("en", {
54
+ style: "currency",
55
+ currency
56
+ }).resolvedOptions().maximumFractionDigits ?? 2;
52
57
  /** The formatters in the UI's language; a component using them re-renders when it changes. */
53
58
  const useFormat = () => formatter(useTranslation().i18n.language);
54
59
  /** A local day as stored and typed, `yyyy-MM-dd`, the same in every language. */
@@ -72,4 +77,4 @@ const zoneOffset = (zone) => {
72
77
  return "";
73
78
  }
74
79
  };
75
- export { LANGUAGES, formatter, localTimeZone, toIsoDay, useFormat, zoneOffset };
80
+ export { LANGUAGES, currencyDigits, formatter, localTimeZone, toIsoDay, useFormat, zoneOffset };
@@ -0,0 +1,10 @@
1
+ /** An amount as people read it in `language`: 150000 MNT → "MNT 1,500.00". */
2
+ export declare const formatMoney: (amount: number, currency: string, language: string) => string;
3
+ /** An amount for a number input, with all of the currency's decimals: 1250 USD → "12.50", 500 JPY → "500". */
4
+ export declare const toAmountInput: (amount: number, currency: string) => string;
5
+ /** What was typed in a number input, in the smallest unit: "12.5" USD → 1250. */
6
+ export declare const fromAmountInput: (text: string, currency: string) => number;
7
+ /** The smallest step a number input takes for a currency: 0.01 for USD, 1 for JPY. */
8
+ export declare const amountStep: (currency: string) => number;
9
+ /** `formatMoney` in the UI's language. */
10
+ export declare const useMoney: () => (amount: number, currency: string) => string;
@@ -0,0 +1,18 @@
1
+ import { currencyDigits, formatter } from "./format.js";
2
+ import { useTranslation } from "react-i18next";
3
+ // src/lib/money.ts
4
+ const unit = (currency) => 10 ** currencyDigits(currency);
5
+ /** An amount as people read it in `language`: 150000 MNT → "MNT 1,500.00". */
6
+ const formatMoney = (amount, currency, language) => formatter(language).currency(amount / unit(currency), currency);
7
+ /** An amount for a number input, with all of the currency's decimals: 1250 USD → "12.50", 500 JPY → "500". */
8
+ const toAmountInput = (amount, currency) => (amount / unit(currency)).toFixed(currencyDigits(currency));
9
+ /** What was typed in a number input, in the smallest unit: "12.5" USD → 1250. */
10
+ const fromAmountInput = (text, currency) => Math.round(Number(text) * unit(currency));
11
+ /** The smallest step a number input takes for a currency: 0.01 for USD, 1 for JPY. */
12
+ const amountStep = (currency) => 1 / unit(currency);
13
+ /** `formatMoney` in the UI's language. */
14
+ const useMoney = () => {
15
+ const { i18n } = useTranslation();
16
+ return (amount, currency) => formatMoney(amount, currency, i18n.language);
17
+ };
18
+ export { amountStep, formatMoney, fromAmountInput, toAmountInput, useMoney };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A stored value of any JSON shape as text: strings as they are, numbers and
3
+ * booleans printed, objects and arrays as JSON, nothing as ''.
4
+ */
5
+ export declare const textOf: (value: unknown) => string;
6
+ /** `value` when it is one of `options` (a select's string as its union type), else undefined. */
7
+ export declare const oneOf: <T extends string>(options: readonly T[], value: string | null) => T | undefined;
@@ -0,0 +1,14 @@
1
+ // src/lib/text.ts
2
+ /**
3
+ * A stored value of any JSON shape as text: strings as they are, numbers and
4
+ * booleans printed, objects and arrays as JSON, nothing as ''.
5
+ */
6
+ const textOf = (value) => {
7
+ if (value === null || value === void 0) return "";
8
+ if (typeof value === "string") return value;
9
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return value.toString();
10
+ return JSON.stringify(value) ?? "";
11
+ };
12
+ /** `value` when it is one of `options` (a select's string as its union type), else undefined. */
13
+ const oneOf = (options, value) => options.find((option) => option === value);
14
+ export { oneOf, textOf };
@@ -0,0 +1,10 @@
1
+ import { TConditionField, TConditionLookups, TConditionRule } from "./conditions.js";
2
+ type ValueProps = TConditionLookups & {
3
+ rule: TConditionRule;
4
+ field?: TConditionField;
5
+ onChange: (value: unknown) => void;
6
+ disabled?: boolean;
7
+ };
8
+ /** The value side of a rule, shaped by the operator and the field's type. */
9
+ export declare const ConditionValueInput: (props: ValueProps) => import("react").JSX.Element;
10
+ export {};
@@ -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;