@erxes/ui 4.0.0-v2.12 → 4.0.0-v2.14

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 (70) hide show
  1. package/CATALOG.md +3 -2
  2. package/README.md +1 -1
  3. package/dist/components/color-picker.js +2 -2
  4. package/dist/components/command-bar.js +3 -0
  5. package/dist/components/input.d.ts +1 -1
  6. package/dist/components/input.js +2 -2
  7. package/dist/components/on-demand.d.ts +9 -2
  8. package/dist/components/on-demand.js +15 -1
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +2 -2
  11. package/dist/modules/conditions/ConditionsEditor.d.ts +5 -3
  12. package/dist/modules/conditions/ConditionsEditor.js +139 -177
  13. package/dist/modules/conditions/DateEditors.d.ts +8 -0
  14. package/dist/modules/conditions/DateEditors.js +188 -0
  15. package/dist/modules/conditions/FieldPicker.d.ts +17 -0
  16. package/dist/modules/conditions/FieldPicker.js +99 -0
  17. package/dist/modules/conditions/RuleParts.d.ts +30 -0
  18. package/dist/modules/conditions/RuleParts.js +78 -0
  19. package/dist/modules/conditions/RuleRow.d.ts +27 -0
  20. package/dist/modules/conditions/RuleRow.js +156 -0
  21. package/dist/modules/conditions/TypedInput.d.ts +13 -0
  22. package/dist/modules/conditions/TypedInput.js +36 -0
  23. package/dist/modules/conditions/ValueEditor.d.ts +18 -0
  24. package/dist/modules/conditions/ValueEditor.js +164 -0
  25. package/dist/modules/conditions/conditions.d.ts +15 -8
  26. package/dist/modules/conditions/conditions.js +1 -75
  27. package/dist/modules/conditions/fieldIcons.d.ts +6 -0
  28. package/dist/modules/conditions/fieldIcons.js +19 -0
  29. package/dist/modules/conditions/fieldOptions.d.ts +13 -0
  30. package/dist/modules/conditions/fieldOptions.js +26 -0
  31. package/dist/modules/conditions/filterRule.d.ts +45 -0
  32. package/dist/modules/conditions/filterRule.js +169 -0
  33. package/dist/modules/conditions/filterText.d.ts +16 -0
  34. package/dist/modules/conditions/filterText.js +156 -0
  35. package/dist/modules/filter/components/Filter.d.ts +1 -1
  36. package/dist/modules/filter/components/Filter.js +1 -1
  37. package/dist/modules/filter/components/FilterBar.js +3 -0
  38. package/dist/modules/list/ListFilter.d.ts +20 -7
  39. package/dist/modules/list/ListFilter.js +50 -17
  40. package/dist/modules/list/ViewBar.d.ts +2 -0
  41. package/dist/modules/list/ViewBar.js +21 -10
  42. package/dist/modules/list/filter/AddFilter.d.ts +10 -0
  43. package/dist/modules/list/filter/AddFilter.js +140 -0
  44. package/dist/modules/list/filter/AdvancedPopover.d.ts +8 -0
  45. package/dist/modules/list/filter/AdvancedPopover.js +103 -0
  46. package/dist/modules/list/filter/ListFilterBar.d.ts +3 -3
  47. package/dist/modules/list/filter/ListFilterBar.js +104 -198
  48. package/dist/modules/list/filter/RuleChips.d.ts +12 -2
  49. package/dist/modules/list/filter/RuleChips.js +132 -138
  50. package/dist/modules/list/filter/SearchChip.d.ts +6 -0
  51. package/dist/modules/list/filter/SearchChip.js +69 -0
  52. package/dist/modules/list/filter/filterRules.d.ts +15 -40
  53. package/dist/modules/list/filter/filterRules.js +27 -156
  54. package/dist/modules/list/filter/listFilterContext.d.ts +25 -18
  55. package/dist/modules/list/filter/listFilterContext.js +8 -24
  56. package/dist/modules/list/filter/listFilterQuery.d.ts +4 -0
  57. package/dist/modules/list/filter/listFilterQuery.js +10 -2
  58. package/dist/theme.css +3 -2
  59. package/exports.txt +1 -0
  60. package/package.json +1 -1
  61. package/dist/modules/conditions/ConditionValueInput.d.ts +0 -10
  62. package/dist/modules/conditions/ConditionValueInput.js +0 -166
  63. package/dist/modules/conditions/PathPicker.d.ts +0 -8
  64. package/dist/modules/conditions/PathPicker.js +0 -51
  65. package/dist/modules/list/filter/AdvancedFilterDialog.d.ts +0 -5
  66. package/dist/modules/list/filter/AdvancedFilterDialog.js +0 -52
  67. package/dist/modules/list/filter/FieldMenus.d.ts +0 -5
  68. package/dist/modules/list/filter/FieldMenus.js +0 -184
  69. package/dist/modules/list/filter/fieldIcons.d.ts +0 -7
  70. package/dist/modules/list/filter/fieldIcons.js +0 -16
package/CATALOG.md CHANGED
@@ -32,8 +32,9 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
32
32
 
33
33
  - `<DisplayMenu list displays>` The Display menu in a list's filter bar: table, board or grouped list.
34
34
  - `EnumCursorDirection` Which way a cursor-paged table loads more rows: forward or backward.
35
- - `Filter.{Trigger, Popover, Item, CommandItem, View, …}` Parts of a filter popover and bar, which `ListFilter` is built from.
36
- - `<ListFilter recordType>` A list's filter bar, with a field menu, search and conditions as chips.
35
+ - `Filter.{Trigger, Popover, Item, CommandItem, View, …}` Parts of a filter popover and bar, for a page without saved views.
36
+ - `<ListFilter recordType>` A list's filter: a view bar button, and a chip row while it filters.
37
+ - `<ListFilterEmpty records fallback>` A list's empty state while `ListFilter` filters it, with Clear filters.
37
38
  - `listFilterQuery` The URL params holding a list's filter, as nuqs parsers.
38
39
  - `<ListViewsProvider views>` Gives every list with a `recordType` saved views, as core's lists have.
39
40
  - `RecordList.{Provider, Skeleton, useSelection}` Rows grouped under headers that fold away, such as tasks by status.
package/README.md CHANGED
@@ -41,7 +41,7 @@ Only what something uses:
41
41
  `PanelField`, `PanelFormRow`, `PanelFormLayout`, `PanelLabel`, the description field and
42
42
  editor, and `usePanelExpanded`. The panel itself (header, tabs, resize) is web's.
43
43
  - a list's bar in `src/modules/list`: `ViewBar`, `DisplayMenu` with `useListDisplay`, and
44
- `ListFilter` with `useListFilterParams`. `ListFilter` draws core's filter bar itself, with or
44
+ `ListFilter` with `useListFilterParams` and its empty state `ListFilterEmpty`. `ListFilter` draws core's filter bar itself, with or
45
45
  without web: its `member` fields pick from `members` (`memberQueries` from
46
46
  `@erxes/core-contract/client`) and its `tags` fields from `tags` (a tags query of the record
47
47
  type); a plugin outside erxes passes its own. Web's lists and the automation builder use the
@@ -3,10 +3,10 @@ import { Popover } from "./popover.js";
3
3
  import { inputVariants } from "./input.js";
4
4
  import { cn } from "../lib/utils.js";
5
5
  import { PopoverScoped } from "../modules/hotkey/components/PopoverScoped.js";
6
+ import { MaskInput } from "./on-demand.js";
6
7
  import { IconCheck, IconChevronDown } from "@tabler/icons-react";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
8
9
  import { createContext, useContext, useMemo, useState } from "react";
9
- import { IMaskInput } from "react-imask";
10
10
  // src/components/color-picker.tsx
11
11
  const DEFAULT_COLORS = {
12
12
  red: "#dc2626",
@@ -93,7 +93,7 @@ const ColorPickerContent = ({ setOpen }) => {
93
93
  className: "absolute inset-0 w-full h-full opacity-0 cursor-pointer",
94
94
  onChange: (e) => onValueChange?.(e.target.value)
95
95
  }), "#"]
96
- }), /* @__PURE__ */ jsx(IMaskInput, {
96
+ }), /* @__PURE__ */ jsx(MaskInput, {
97
97
  mask: /^[0-9A-Fa-f]+$/,
98
98
  className: cn(inputVariants(), "pl-9"),
99
99
  value: (value || "").replace("#", ""),
@@ -3,6 +3,7 @@ import { Button, buttonVariants } from "./button.js";
3
3
  import { IconX } from "@tabler/icons-react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { useRef } from "react";
6
+ import { useTranslation } from "react-i18next";
6
7
  import { Popover } from "@base-ui/react/popover";
7
8
  // src/components/command-bar.tsx
8
9
  const Root = ({ open = false, onOpenChange, defaultOpen = false, disableAutoFocus = true, children }) => {
@@ -29,6 +30,7 @@ const Root = ({ open = false, onOpenChange, defaultOpen = false, disableAutoFocu
29
30
  });
30
31
  };
31
32
  const Value = ({ ref, className, onClose, children, ...props }) => {
33
+ const { t } = useTranslation();
32
34
  return /* @__PURE__ */ jsxs("div", {
33
35
  className: "flex items-center -space-x-px",
34
36
  children: [/* @__PURE__ */ jsx("div", {
@@ -40,6 +42,7 @@ const Value = ({ ref, className, onClose, children, ...props }) => {
40
42
  variant: "outline",
41
43
  className: "shadow-none border-dashed border rounded-l-none",
42
44
  size: "icon",
45
+ "aria-label": t("close", "Close"),
43
46
  onClick: onClose,
44
47
  children: /* @__PURE__ */ jsx(IconX, {})
45
48
  })]
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { VariantProps } from "class-variance-authority";
3
- import { ReactElementProps } from "react-imask";
4
3
  import { Except } from "type-fest";
4
+ import { ReactElementProps } from "react-imask";
5
5
  /** The text of an input or textarea: its size and, for codes, a monospace face. */
6
6
  export declare const fieldTextVariants: {
7
7
  default: string;
@@ -1,9 +1,9 @@
1
1
  import { cn } from "../lib/utils.js";
2
2
  import { useFieldControl } from "./field-control.js";
3
+ import { MaskInput } from "./on-demand.js";
3
4
  import { jsx } from "react/jsx-runtime";
4
5
  import "react";
5
6
  import { cva } from "class-variance-authority";
6
- import { IMaskInput } from "react-imask";
7
7
  // src/components/input.tsx
8
8
  /** The text of an input or textarea: its size and, for codes, a monospace face. */
9
9
  const fieldTextVariants = {
@@ -53,7 +53,7 @@ const InputMain = ({ ref, className, type, variant, text, ...props }) => {
53
53
  /** A number with thousands separators; `onChange` gets the number, or '' when cleared. */
54
54
  const InputNumber = ({ value, onChange, className, ...props }) => {
55
55
  const field = useFieldControl();
56
- return /* @__PURE__ */ jsx(IMaskInput, {
56
+ return /* @__PURE__ */ jsx(MaskInput, {
57
57
  ...field,
58
58
  mask: Number,
59
59
  onAccept: (accepted) => {
@@ -1,8 +1,15 @@
1
1
  import { MultipleSelector as MultipleSelector$1 } from "./multiselect.js";
2
2
  import { Resizable as Resizable$1 } from "./resizable.js";
3
3
  import { SliderProps } from "./slider.js";
4
- import { ComponentProps } from "react";
5
- declare const Selector: import("react").LazyExoticComponent<typeof MultipleSelector$1>;
4
+ import { ComponentProps, LazyExoticComponent } from "react";
5
+ import { IMaskInput } from "react-imask";
6
+ type MaskInputProps = ComponentProps<typeof IMaskInput>;
7
+ /**
8
+ * imask's input (numbers with separators, hex colours). Until its code loads, a read-only input
9
+ * with the same value and classes holds its place.
10
+ */
11
+ export declare const MaskInput: (props: MaskInputProps) => import("react").JSX.Element;
12
+ declare const Selector: LazyExoticComponent<typeof MultipleSelector$1>;
6
13
  /**
7
14
  * Picks several options from a list, shown as removable badges.
8
15
  * Picked options leave the list. The code loads the first time one renders.
@@ -2,6 +2,20 @@ import { cn } from "../lib/utils.js";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { Suspense, lazy, use } from "react";
4
4
  // src/components/on-demand.tsx
5
+ const LoadedMaskInput = lazy(async () => ({ default: (await import("react-imask")).IMaskInput }));
6
+ /**
7
+ * imask's input (numbers with separators, hex colours). Until its code loads, a read-only input
8
+ * with the same value and classes holds its place.
9
+ */
10
+ const MaskInput = (props) => /* @__PURE__ */ jsx(Suspense, {
11
+ fallback: /* @__PURE__ */ jsx("input", {
12
+ readOnly: true,
13
+ "aria-label": props["aria-label"],
14
+ className: props.className,
15
+ value: props.value ?? ""
16
+ }),
17
+ children: /* @__PURE__ */ jsx(LoadedMaskInput, { ...props })
18
+ });
5
19
  const Selector = lazy(async () => ({ default: (await import("./multiselect.js")).MultipleSelector }));
6
20
  /**
7
21
  * Picks several options from a list, shown as removable badges.
@@ -45,4 +59,4 @@ const Resizable = {
45
59
  Panel: ResizablePanel,
46
60
  Handle: ResizableHandle
47
61
  };
48
- export { MultipleSelector, Resizable, Slider };
62
+ export { MaskInput, MultipleSelector, Resizable, Slider };
package/dist/index.d.ts CHANGED
@@ -103,7 +103,7 @@ import { RecordTableColumnDef } from "./modules/record-table/components/RecordTa
103
103
  import { RecordTableInlineCell } from "./modules/record-table/components/RecordTableCellInline.js";
104
104
  import { EnumCursorDirection } from "./modules/record-table/types/RecordTableCursorTypes.js";
105
105
  import { DisplayMenu, TListDisplay, useListDisplay } from "./modules/list/DisplayMenu.js";
106
- import { ListFilter, TListFilterField, TListFilterProps, useListFilterParams } from "./modules/list/ListFilter.js";
106
+ import { ListFilter, ListFilterEmpty, TListFilterField, TListFilterProps, useListFilterParams } from "./modules/list/ListFilter.js";
107
107
  import { listFilterQuery } from "./modules/list/filter/listFilterQuery.js";
108
108
  import { TConditionField, TConditionGroup, TConditionLookups, TConditionRule, isRule } from "./modules/conditions/conditions.js";
109
109
  import { ConditionsEditor } from "./modules/conditions/LazyConditionsEditor.js";
@@ -130,4 +130,4 @@ import { jsonOf } from "./utils/json.js";
130
130
  import { PluginLiveMessage, PluginRuntime, PluginSession, getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
131
131
  import { addPluginStyles } from "./utils/plugin-styles.js";
132
132
  import { RecordTimeline, RecordTimelineProps, setRecordTimeline } from "./utils/record-timeline.js";
133
- 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, ListViewsProvider, 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 TListViews, type TPanelRecordType, type TPluginListType, type TPropertyInputMeta, type TPropertyInputProps, type TRecordContacts, type TRecordDraftProps, type TRecordSection, type TRecordSectionProps, type TRecordSlotProps, type TRecordTab, type TRelationTab, type TRelationTabProps, type TViewTabsProps, 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, useFieldControl, useFilterContext, useFocusFirstField, useFormat, useItemKeys, useListDisplay, useListFilterParams, useListViews, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
133
+ 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, ListFilterEmpty, ListViewsProvider, 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 TListViews, type TPanelRecordType, type TPluginListType, type TPropertyInputMeta, type TPropertyInputProps, type TRecordContacts, type TRecordDraftProps, type TRecordSection, type TRecordSectionProps, type TRecordSlotProps, type TRecordTab, type TRelationTab, type TRelationTabProps, type TViewTabsProps, 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, useFieldControl, useFilterContext, useFocusFirstField, useFormat, useItemKeys, useListDisplay, useListFilterParams, useListViews, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
package/dist/index.js CHANGED
@@ -99,7 +99,7 @@ import { RecordTable } from "./modules/record-table/components/RecordTable.js";
99
99
  import { RecordTableInlineCell } from "./modules/record-table/components/RecordTableCellInline.js";
100
100
  import { EnumCursorDirection } from "./modules/record-table/types/RecordTableCursorTypes.js";
101
101
  import { DisplayMenu, useListDisplay } from "./modules/list/DisplayMenu.js";
102
- import { ListFilter, useListFilterParams } from "./modules/list/ListFilter.js";
102
+ import { ListFilter, ListFilterEmpty, useListFilterParams } from "./modules/list/ListFilter.js";
103
103
  import { listFilterQuery } from "./modules/list/filter/listFilterQuery.js";
104
104
  import { isRule } from "./modules/conditions/conditions.js";
105
105
  import { ConditionsEditor } from "./modules/conditions/LazyConditionsEditor.js";
@@ -125,4 +125,4 @@ import { jsonOf } from "./utils/json.js";
125
125
  import { getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
126
126
  import { addPluginStyles } from "./utils/plugin-styles.js";
127
127
  import { RecordTimeline, setRecordTimeline } from "./utils/record-timeline.js";
128
- 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, ListViewsProvider, 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, useFieldControl, useFilterContext, useFocusFirstField, useFormat, useItemKeys, useListDisplay, useListFilterParams, useListViews, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
128
+ 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, ListFilterEmpty, ListViewsProvider, 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, useFieldControl, useFilterContext, useFocusFirstField, useFormat, useItemKeys, useListDisplay, useListFilterParams, useListViews, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
@@ -1,11 +1,13 @@
1
1
  import { TConditionField, TConditionGroup, TConditionLookups } from "./conditions.js";
2
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.
3
+ * Conditions as rows "Where <field> <operator> <value>", joined by "and" or "or", with nested
4
+ * groups, on `fields`; `members` and `tags` feed their pickers. Fields and values pick from the
5
+ * same menus as a list's filter chips. With `customPath`, a typed path is a field too.
5
6
  */
6
- export declare const ConditionsEditor: ({ value, onChange, disabled, fields, ...lookups }: TConditionLookups & {
7
+ export declare const ConditionsEditor: ({ value, onChange, disabled, fields, customPath, ...lookups }: TConditionLookups & {
7
8
  value: TConditionGroup | undefined;
8
9
  onChange: (next: TConditionGroup | undefined) => void;
9
10
  disabled?: boolean;
10
11
  fields: TConditionField[];
12
+ customPath?: boolean;
11
13
  }) => import("react").JSX.Element;
@@ -1,139 +1,98 @@
1
1
  import { Button } from "../../components/button.js";
2
+ import { Popover } from "../../components/popover.js";
2
3
  import { Select } from "../../components/select.js";
3
4
  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";
5
+ import { NO_VALUE, isRule } from "./conditions.js";
6
+ import { isFilterRule, ruleFor } from "./filterRule.js";
7
+ import { FieldPicker } from "./FieldPicker.js";
8
+ import { RemoveButton, RuleRow } from "./RuleRow.js";
9
+ import { IconBraces, IconPlus } from "@tabler/icons-react";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
+ import { useState } from "react";
11
12
  import { useTranslation } from "react-i18next";
12
13
  // 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
- ]
14
+ /** "Where" first; the second row picks "and" or "or" for the group; the rest repeat it. */
15
+ const Conjunction = ({ index, group, disabled, onChange }) => {
16
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
17
+ const word = group.match === "all" ? t("and", "And") : t("or", "Or");
18
+ if (index === 0) return /* @__PURE__ */ jsx("span", {
19
+ className: "px-2 text-sm text-muted-foreground",
20
+ children: t("where", "Where")
73
21
  });
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
- ]
22
+ if (index > 1 || disabled) return /* @__PURE__ */ jsx("span", {
23
+ className: "px-2 text-sm text-muted-foreground",
24
+ children: word
25
+ });
26
+ return /* @__PURE__ */ jsxs(Select, {
27
+ value: group.match,
28
+ onValueChange: (match) => onChange({
29
+ ...group,
30
+ match: match === "any" ? "any" : "all"
31
+ }),
32
+ children: [/* @__PURE__ */ jsx(Select.Trigger, {
33
+ className: "h-8 w-full",
34
+ "aria-label": t("conjunction", "And or or"),
35
+ children: /* @__PURE__ */ jsx(Select.Value, { children: word })
36
+ }), /* @__PURE__ */ jsxs(Select.Content, { children: [/* @__PURE__ */ jsx(Select.Item, {
37
+ value: "all",
38
+ children: t("and", "And")
39
+ }), /* @__PURE__ */ jsx(Select.Item, {
40
+ value: "any",
41
+ children: t("or", "Or")
42
+ })] })]
110
43
  });
111
44
  };
112
- const AddButtons = ({ newRule, newGroup, disabled, onAdd }) => {
113
- const { t } = useTranslation("automations");
45
+ /** "Add filter rule" opens the field picker; "Add filter group", while groups may still nest. */
46
+ const AddButtons = ({ fields, disabled, customPath, canGroup, onAdd }) => {
47
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
48
+ const [open, setOpen] = useState(false);
114
49
  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, {
50
+ className: "flex gap-1",
51
+ children: [/* @__PURE__ */ jsxs(Popover, {
52
+ open,
53
+ onOpenChange: setOpen,
54
+ children: [/* @__PURE__ */ jsxs(Popover.Trigger, {
55
+ render: /* @__PURE__ */ jsx(Button, {
56
+ size: "sm",
57
+ variant: "ghost",
58
+ tone: "muted",
59
+ disabled
60
+ }),
61
+ children: [/* @__PURE__ */ jsx(IconPlus, {}), t("add-rule", "Add filter rule")]
62
+ }), /* @__PURE__ */ jsx(Popover.Content, {
63
+ variant: "flush",
64
+ align: "start",
65
+ className: "w-72",
66
+ children: /* @__PURE__ */ jsx(FieldPicker, {
67
+ fields,
68
+ customPath,
69
+ onSelect: (field) => {
70
+ setOpen(false);
71
+ onAdd(ruleFor(field));
72
+ }
73
+ })
74
+ })]
75
+ }), canGroup && /* @__PURE__ */ jsxs(Button, {
123
76
  size: "sm",
124
77
  variant: "ghost",
78
+ tone: "muted",
125
79
  disabled,
126
- onClick: () => onAdd(newGroup),
127
- children: [/* @__PURE__ */ jsx(IconBraces, {}), t("add-group", "Add group")]
80
+ onClick: () => onAdd({
81
+ match: "all",
82
+ rules: []
83
+ }),
84
+ children: [/* @__PURE__ */ jsx(IconBraces, {}), t("add-group", "Add filter group")]
128
85
  })]
129
86
  });
130
87
  };
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 }) => {
88
+ /** One group: its rows and nested groups (three levels in all), then the add buttons. */
89
+ const GroupEditor = ({ group, onChange, depth, ...shared }) => {
90
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
133
91
  const keys = useItemKeys(group.rules.length);
134
- const update = (index, rule) => onChange({
92
+ const [fresh, setFresh] = useState(null);
93
+ const update = (index, node) => onChange({
135
94
  ...group,
136
- rules: group.rules.map((item, at) => at === index ? rule : item)
95
+ rules: group.rules.map((item, at) => at === index ? node : item)
137
96
  });
138
97
  const remove = (index) => {
139
98
  keys.removed(index);
@@ -142,68 +101,71 @@ const GroupEditor = ({ group, onChange, onRemove, fields, disabled, depth, looku
142
101
  rules: group.rules.filter((_, at) => at !== index)
143
102
  });
144
103
  };
145
- const add = (rule) => {
146
- keys.added();
147
- onChange({
148
- ...group,
149
- rules: [...group.rules, rule]
150
- });
151
- };
104
+ const lead = (index) => /* @__PURE__ */ jsx(Conjunction, {
105
+ index,
106
+ group,
107
+ disabled: shared.disabled,
108
+ onChange
109
+ });
152
110
  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
- ]
111
+ className: "flex flex-col gap-1.5",
112
+ children: [group.rules.map((node, index) => isFilterRule(node) ? /* @__PURE__ */ jsx(RuleRow, {
113
+ ...shared,
114
+ rule: node,
115
+ lead: lead(index),
116
+ fresh: fresh === index,
117
+ onChange: (next) => update(index, next),
118
+ onRemove: () => remove(index)
119
+ }, keys.keyAt(index)) : /* @__PURE__ */ jsxs("div", {
120
+ className: "grid grid-cols-condition items-start gap-1.5",
121
+ children: [
122
+ lead(index),
123
+ /* @__PURE__ */ jsx("div", {
124
+ className: "col-span-3 rounded-md border bg-muted/40 p-2",
125
+ children: /* @__PURE__ */ jsx(GroupEditor, {
126
+ ...shared,
127
+ group: node,
128
+ depth: depth + 1,
129
+ onChange: (next) => update(index, next)
130
+ })
131
+ }),
132
+ /* @__PURE__ */ jsx(RemoveButton, {
133
+ label: t("remove-group", "Remove group"),
134
+ disabled: shared.disabled,
135
+ onRemove: () => remove(index)
136
+ })
137
+ ]
138
+ }, keys.keyAt(index))), /* @__PURE__ */ jsx(AddButtons, {
139
+ fields: shared.fields,
140
+ disabled: shared.disabled,
141
+ customPath: shared.customPath,
142
+ canGroup: depth < 2,
143
+ onAdd: (node) => {
144
+ keys.added();
145
+ setFresh(isRule(node) && !NO_VALUE.has(node.op) ? group.rules.length : null);
146
+ onChange({
147
+ ...group,
148
+ rules: [...group.rules, node]
149
+ });
150
+ }
151
+ })]
190
152
  });
191
153
  };
192
154
  /**
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.
155
+ * Conditions as rows "Where <field> <operator> <value>", joined by "and" or "or", with nested
156
+ * groups, on `fields`; `members` and `tags` feed their pickers. Fields and values pick from the
157
+ * same menus as a list's filter chips. With `customPath`, a typed path is a field too.
195
158
  */
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
- };
159
+ const ConditionsEditor = ({ value, onChange, disabled, fields, customPath, ...lookups }) => /* @__PURE__ */ jsx(GroupEditor, {
160
+ group: value ?? {
161
+ match: "all",
162
+ rules: []
163
+ },
164
+ fields,
165
+ lookups,
166
+ disabled,
167
+ customPath,
168
+ depth: 0,
169
+ onChange: (next) => onChange(next.rules.length ? next : void 0)
170
+ });
209
171
  export { ConditionsEditor };
@@ -0,0 +1,8 @@
1
+ import { TConditionRule } from "./conditions.js";
2
+ import { ValueEditorProps } from "./ValueEditor.js";
3
+ /** "In the last 30 days": the usual spans in one pick, or any amount and unit. */
4
+ export declare const RelativeEditor: (props: Omit<ValueEditorProps, 'rule' | 'field' | 'lookups'> & {
5
+ rule: TConditionRule;
6
+ }) => import("react").JSX.Element;
7
+ /** A day (before, on, after) or a range of days, on erxes-ui's date picker. */
8
+ export declare const DayEditor: ({ rule, onChange, onDone }: ValueEditorProps) => import("react").JSX.Element;