@erxes/ui 4.0.0-v2.13 → 4.0.0-v2.15

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 (78) hide show
  1. package/CATALOG.md +15 -8
  2. package/README.md +1 -1
  3. package/dist/index.d.ts +6 -6
  4. package/dist/index.js +4 -3
  5. package/dist/modules/conditions/ConditionsEditor.d.ts +5 -3
  6. package/dist/modules/conditions/ConditionsEditor.js +139 -177
  7. package/dist/modules/conditions/DateEditors.d.ts +8 -0
  8. package/dist/modules/conditions/DateEditors.js +188 -0
  9. package/dist/modules/conditions/FieldPicker.d.ts +17 -0
  10. package/dist/modules/conditions/FieldPicker.js +99 -0
  11. package/dist/modules/conditions/RuleParts.d.ts +30 -0
  12. package/dist/modules/conditions/RuleParts.js +78 -0
  13. package/dist/modules/conditions/RuleRow.d.ts +27 -0
  14. package/dist/modules/conditions/RuleRow.js +156 -0
  15. package/dist/modules/conditions/TypedInput.d.ts +13 -0
  16. package/dist/modules/conditions/TypedInput.js +36 -0
  17. package/dist/modules/conditions/ValueEditor.d.ts +18 -0
  18. package/dist/modules/conditions/ValueEditor.js +169 -0
  19. package/dist/modules/conditions/conditions.d.ts +21 -12
  20. package/dist/modules/conditions/conditions.js +8 -75
  21. package/dist/modules/conditions/fieldIcons.d.ts +6 -0
  22. package/dist/modules/conditions/fieldIcons.js +21 -0
  23. package/dist/modules/conditions/fieldOptions.d.ts +15 -0
  24. package/dist/modules/conditions/fieldOptions.js +38 -0
  25. package/dist/modules/conditions/filterRule.d.ts +45 -0
  26. package/dist/modules/conditions/filterRule.js +171 -0
  27. package/dist/modules/conditions/filterText.d.ts +16 -0
  28. package/dist/modules/conditions/filterText.js +156 -0
  29. package/dist/modules/filter/components/Filter.d.ts +1 -1
  30. package/dist/modules/filter/components/Filter.js +1 -1
  31. package/dist/modules/list/ListFilter.d.ts +22 -10
  32. package/dist/modules/list/ListFilter.js +53 -20
  33. package/dist/modules/list/ViewBar.d.ts +2 -0
  34. package/dist/modules/list/ViewBar.js +21 -10
  35. package/dist/modules/list/filter/AddFilter.d.ts +10 -0
  36. package/dist/modules/list/filter/AddFilter.js +140 -0
  37. package/dist/modules/list/filter/AdvancedPopover.d.ts +8 -0
  38. package/dist/modules/list/filter/AdvancedPopover.js +103 -0
  39. package/dist/modules/list/filter/ListFilterBar.d.ts +3 -3
  40. package/dist/modules/list/filter/ListFilterBar.js +109 -205
  41. package/dist/modules/list/filter/RuleChips.d.ts +12 -2
  42. package/dist/modules/list/filter/RuleChips.js +132 -134
  43. package/dist/modules/list/filter/SearchChip.d.ts +6 -0
  44. package/dist/modules/list/filter/SearchChip.js +69 -0
  45. package/dist/modules/list/filter/filterRules.d.ts +15 -40
  46. package/dist/modules/list/filter/filterRules.js +27 -156
  47. package/dist/modules/list/filter/listFilterContext.d.ts +25 -18
  48. package/dist/modules/list/filter/listFilterContext.js +8 -24
  49. package/dist/modules/list/filter/listFilterQuery.d.ts +4 -0
  50. package/dist/modules/list/filter/listFilterQuery.js +10 -2
  51. package/dist/modules/pickers/LookupPicker.d.ts +6 -0
  52. package/dist/modules/pickers/LookupPicker.js +32 -1
  53. package/dist/modules/record-list/RecordList.d.ts +2 -1
  54. package/dist/modules/record-list/RecordList.js +2 -1
  55. package/dist/modules/record-list/RecordListRoot.d.ts +3 -1
  56. package/dist/modules/record-list/RecordListRoot.js +53 -37
  57. package/dist/modules/record-table/components/RecordTableHead.d.ts +7 -2
  58. package/dist/modules/record-table/components/RecordTableHead.js +73 -6
  59. package/dist/modules/record-table/components/RecordTableProvider.d.ts +22 -1
  60. package/dist/modules/record-table/components/RecordTableProvider.js +12 -1
  61. package/dist/modules/records/contacts.d.ts +18 -0
  62. package/dist/modules/records/openRecord.d.ts +35 -1
  63. package/dist/modules/records/openRecord.js +27 -4
  64. package/dist/theme.css +3 -2
  65. package/dist/types/UIConfig.d.ts +47 -100
  66. package/dist/types/UIConfig.js +14 -0
  67. package/exports.txt +10 -3
  68. package/package.json +1 -1
  69. package/dist/modules/conditions/ConditionValueInput.d.ts +0 -10
  70. package/dist/modules/conditions/ConditionValueInput.js +0 -166
  71. package/dist/modules/conditions/PathPicker.d.ts +0 -8
  72. package/dist/modules/conditions/PathPicker.js +0 -56
  73. package/dist/modules/list/filter/AdvancedFilterDialog.d.ts +0 -5
  74. package/dist/modules/list/filter/AdvancedFilterDialog.js +0 -52
  75. package/dist/modules/list/filter/FieldMenus.d.ts +0 -5
  76. package/dist/modules/list/filter/FieldMenus.js +0 -184
  77. package/dist/modules/list/filter/fieldIcons.d.ts +0 -7
  78. package/dist/modules/list/filter/fieldIcons.js +0 -16
@@ -1,6 +1,6 @@
1
1
  import { TListFilterProps } from "../ListFilter.js";
2
2
  /**
3
- * Inside `<Filter>`: its chips, the list's status and the count, then the list's controls
4
- * and the menu (`F`).
3
+ * In the view bar: the count, the list's own controls and the filter button (`F`). Under it,
4
+ * while the list is filtered, the filter row: in the view bar's slot, else right after the bar.
5
5
  */
6
- export declare const ListFilterBar: ({ id, fields, loading, error, status, totalCount, totalCapped, children, members, tags }: TListFilterProps) => import("react").JSX.Element;
6
+ export declare const ListFilterBar: (props: TListFilterProps) => import("react").JSX.Element;
@@ -1,217 +1,145 @@
1
1
  import { Button } from "../../../components/button.js";
2
- import { Combobox } from "../../../components/combobox.js";
3
- import { Command } from "../../../components/command.js";
4
2
  import { IconTip } from "../../../components/icon-tip.js";
5
- import { Popover } from "../../../components/popover.js";
6
3
  import { usePageHotkey } from "../../../hooks/use-page-hotkey.js";
7
- import { isRule } from "../../conditions/conditions.js";
8
- import { Filter } from "../../filter/components/Filter.js";
9
- import { useFilterContext } from "../../filter/hooks/useFilterContext.js";
10
- import { AdvancedFilterDialog } from "./AdvancedFilterDialog.js";
11
- import { FieldMenu } from "./FieldMenus.js";
12
- import { FIELD_ICONS } from "./fieldIcons.js";
13
- import { groupOf, inMenu, partsOf, withPart } from "./filterRules.js";
14
- import { ListFilterContext, useListFilter } from "./listFilterContext.js";
4
+ import { ruleCount } from "../../conditions/filterRule.js";
5
+ import { useFilterRowSlot } from "../ViewBar.js";
6
+ import { AddFilter } from "./AddFilter.js";
7
+ import { AdvancedPopover } from "./AdvancedPopover.js";
8
+ import { chipsOf, groupOf, partsOf, withPart } from "./filterRules.js";
9
+ import { ListFilterContext } from "./listFilterContext.js";
15
10
  import { useListConditions } from "./listFilterQuery.js";
16
11
  import { RecordCount } from "./RecordCount.js";
17
12
  import { RuleChips } from "./RuleChips.js";
18
- import { IconAdjustmentsHorizontal, IconFilter2, IconSearch } from "@tabler/icons-react";
13
+ import { SearchChip } from "./SearchChip.js";
14
+ import { IconFilter2, IconPlus } from "@tabler/icons-react";
19
15
  import { jsx, jsxs } from "react/jsx-runtime";
20
- import { useCallback, useMemo, useState } from "react";
16
+ import { useMemo, useRef, useState } from "react";
21
17
  import { useTranslation } from "react-i18next";
22
- import { useQueryState } from "nuqs";
18
+ import { createPortal } from "react-dom";
23
19
  import { useAutoAnimate } from "@formkit/auto-animate/react";
24
20
  // src/modules/list/filter/ListFilterBar.tsx
25
- /** Built-in fields first, the record's properties last; each with its heading's English. */
26
- const GROUPS = [
27
- {
28
- group: "fields",
29
- label: "Fields"
30
- },
31
- {
32
- group: "lead",
33
- label: "Lead"
34
- },
35
- {
36
- group: "company",
37
- label: "Company"
38
- },
39
- {
40
- group: "activity",
41
- label: "Activity"
42
- },
43
- {
44
- group: "custom",
45
- label: "Properties"
46
- }
47
- ];
48
- /** Every field, grouped; each opens its submenu. The search box filters them by name. */
49
- const FieldItems = () => {
50
- const { t } = useTranslation("views", { keyPrefix: "filter" });
51
- const { fields } = useListFilter();
52
- return [...GROUPS.map(({ group, label }) => ({
53
- key: group,
54
- heading: t(`group.${group}`, label),
55
- fields: fields.filter((field) => !field.groupLabel && (field.group ?? "fields") === group)
56
- })), ...[...new Set(fields.flatMap((field) => field.groupLabel ?? []))].map((heading) => ({
57
- key: `label:${heading}`,
58
- heading,
59
- fields: fields.filter((field) => field.groupLabel === heading)
60
- }))].map(({ key, heading, fields: inGroup }) => {
61
- if (!inGroup.length) return null;
62
- return /* @__PURE__ */ jsx(Command.Group, {
63
- heading,
64
- children: inGroup.map((field) => {
65
- const Icon = field.icon ?? FIELD_ICONS[field.type];
66
- return /* @__PURE__ */ jsxs(Filter.Item, {
67
- value: field.path,
68
- keywords: [field.label],
69
- children: [/* @__PURE__ */ jsx(Icon, {}), /* @__PURE__ */ jsx("span", {
70
- className: "truncate",
71
- children: field.label
72
- })]
73
- }, field.path);
74
- })
75
- }, key);
76
- });
77
- };
78
- /** The menu's first page: "Add filter…", search, the advanced filter, then the fields. */
79
- const RootMenu = ({ loading, error }) => {
80
- const { t } = useTranslation("views", { keyPrefix: "filter" });
81
- const { openAdvanced } = useListFilter();
82
- const search = t("search", "Search");
83
- const advanced = t("advanced", "Advanced filter");
84
- return /* @__PURE__ */ jsxs(Command, { children: [/* @__PURE__ */ jsx(Filter.CommandInput, {
85
- placeholder: t("add", "Add filter…"),
86
- variant: "secondary",
87
- focusOnMount: true
88
- }), /* @__PURE__ */ jsxs(Command.List, {
89
- className: "max-h-popup",
90
- children: [
91
- /* @__PURE__ */ jsx(Command.Empty, { children: t("no-match", "No field matches") }),
92
- /* @__PURE__ */ jsxs(Filter.Item, {
93
- value: "searchValue",
94
- keywords: [search],
95
- inDialog: true,
96
- children: [/* @__PURE__ */ jsx(IconSearch, {}), search]
97
- }),
98
- /* @__PURE__ */ jsxs(Filter.CommandItem, {
99
- value: "advanced",
100
- keywords: [advanced],
101
- onSelect: openAdvanced,
102
- children: [/* @__PURE__ */ jsx(IconAdjustmentsHorizontal, {}), advanced]
103
- }),
104
- loading && /* @__PURE__ */ jsx("p", {
105
- className: "px-2 py-1.5 text-xs text-muted-foreground",
106
- children: t("loading", "Loading fields…")
107
- }),
108
- error && /* @__PURE__ */ jsx("p", {
109
- role: "alert",
110
- className: "px-2 py-1.5 text-xs text-destructive",
111
- children: error.message
112
- }),
113
- /* @__PURE__ */ jsx(FieldItems, {})
114
- ]
115
- })] });
116
- };
117
- /** The search, as a chip (it opens the search box). */
118
- const SearchChip = () => {
119
- const { t } = useTranslation("views", { keyPrefix: "filter" });
120
- const [searchValue] = useQueryState("searchValue");
121
- return /* @__PURE__ */ jsxs(Filter.BarItem, {
122
- queryKey: "searchValue",
123
- children: [/* @__PURE__ */ jsxs(Filter.BarName, { children: [/* @__PURE__ */ jsx(IconSearch, {}), t("search", "Search")] }), /* @__PURE__ */ jsx(Filter.BarButton, {
124
- filterKey: "searchValue",
125
- inDialog: true,
126
- children: searchValue
127
- })]
128
- });
129
- };
130
- /** Opens the filter menu; it shows how many conditions apply. */
131
- const FilterButton = ({ count, onClick }) => {
21
+ /** The view bar's filter button: it opens the field picker and shows how many conditions apply. */
22
+ const FilterButton = ({ count }) => {
132
23
  const { t } = useTranslation("views", { keyPrefix: "filter" });
133
24
  const label = t("label", "Filter");
134
25
  return /* @__PURE__ */ jsx(IconTip, {
135
26
  label,
136
27
  hotkey: "F",
137
- children: /* @__PURE__ */ jsxs(Popover.Trigger, {
138
- render: /* @__PURE__ */ jsx(Button, {
28
+ children: /* @__PURE__ */ jsx(AddFilter, {
29
+ from: "bar",
30
+ trigger: /* @__PURE__ */ jsxs(Button, {
139
31
  size: "sm",
140
- "aria-label": label,
32
+ "aria-label": count > 0 ? `${label} ${count}` : label,
141
33
  "aria-keyshortcuts": "F",
142
34
  variant: count > 0 ? "secondary" : "ghost",
143
35
  tone: count > 0 ? "default" : "muted",
144
36
  className: "h-7 min-w-7",
145
- onClick
146
- }),
147
- children: [/* @__PURE__ */ jsx(IconFilter2, { className: "size-4" }), count > 0 && /* @__PURE__ */ jsx("span", {
148
- className: "text-xs tabular-nums",
149
- children: count
150
- })]
37
+ children: [/* @__PURE__ */ jsx(IconFilter2, { className: "size-4" }), count > 0 && /* @__PURE__ */ jsx("span", {
38
+ className: "text-xs tabular-nums",
39
+ children: count
40
+ })]
41
+ })
151
42
  })
152
43
  });
153
44
  };
154
- /** The bar's context: the list's conditions as parts, and the one the menu is editing. */
155
- const useListFilterState = (fields, lookups) => {
45
+ /**
46
+ * Under the view bar while the list is filtered: the conditions as chips that wrap, "+ Filter",
47
+ * Clear, and what the open view changed. The advanced filter opens anchored to it.
48
+ */
49
+ const FilterRow = ({ status }) => {
50
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
51
+ const { clear } = useListConditions();
52
+ const [chipsRef] = useAutoAnimate({ duration: 150 });
53
+ const rowRef = useRef(null);
54
+ return /* @__PURE__ */ jsxs("div", {
55
+ ref: rowRef,
56
+ role: "toolbar",
57
+ "aria-label": t("row", "Filters"),
58
+ className: "flex min-h-10 shrink-0 items-start gap-2 border-b bg-background px-3 py-1.5",
59
+ children: [
60
+ /* @__PURE__ */ jsxs("div", {
61
+ ref: chipsRef,
62
+ className: "flex min-w-0 flex-1 flex-wrap items-center gap-1.5",
63
+ children: [
64
+ /* @__PURE__ */ jsx(SearchChip, {}),
65
+ /* @__PURE__ */ jsx(RuleChips, {}),
66
+ /* @__PURE__ */ jsx(AddFilter, {
67
+ from: "row",
68
+ trigger: /* @__PURE__ */ jsxs(Button, {
69
+ size: "sm",
70
+ variant: "ghost",
71
+ tone: "muted",
72
+ className: "h-7",
73
+ children: [/* @__PURE__ */ jsx(IconPlus, {}), t("label", "Filter")]
74
+ })
75
+ })
76
+ ]
77
+ }),
78
+ /* @__PURE__ */ jsxs("div", {
79
+ className: "flex h-7 shrink-0 items-center gap-1",
80
+ children: [/* @__PURE__ */ jsx(Button, {
81
+ size: "sm",
82
+ variant: "ghost",
83
+ tone: "muted",
84
+ className: "h-7",
85
+ onClick: clear,
86
+ children: t("clear", "Clear")
87
+ }), status]
88
+ }),
89
+ /* @__PURE__ */ jsx(AdvancedPopover, { anchor: rowRef })
90
+ ]
91
+ });
92
+ };
93
+ /** The filter's shared state: the conditions from the address, the open pickers. */
94
+ const useListFilterState = ({ fields, members, tags, contacts, totalCount, totalCapped, loading, error }) => {
156
95
  const { advanced, setAdvanced } = useListConditions();
157
- const { setOpen, setView } = useFilterContext();
158
- const [editing, setEditing] = useState(null);
96
+ const [adding, setAdding] = useState(null);
159
97
  const [advancedOpen, setAdvancedOpen] = useState(false);
98
+ const lookups = useMemo(() => ({
99
+ members,
100
+ tags,
101
+ contacts
102
+ }), [
103
+ members,
104
+ tags,
105
+ contacts
106
+ ]);
160
107
  const parts = useMemo(() => partsOf(advanced), [advanced]);
161
- const openMenu = useCallback((view, part) => {
162
- setEditing(part);
163
- setView(view);
164
- setOpen(true);
165
- }, [setOpen, setView]);
166
- usePageHotkey("f", () => openMenu("root", null));
167
108
  return {
168
- state: useMemo(() => ({
169
- fields,
170
- lookups,
171
- parts,
172
- editing,
173
- setPart: (index, next) => setAdvanced(groupOf(withPart(parts, index, next))),
174
- edit: (index) => {
175
- const part = parts[index];
176
- const field = part && isRule(part) && fields.find((one) => one.path === part.path);
177
- if (part && isRule(part) && field && inMenu(part, field)) openMenu(field.path, index);
178
- else setAdvancedOpen(true);
179
- },
180
- openAdvanced: () => setAdvancedOpen(true)
181
- }), [
182
- fields,
183
- lookups,
184
- parts,
185
- editing,
186
- setAdvanced,
187
- openMenu
188
- ]),
189
- setEditing,
109
+ fields,
110
+ lookups,
111
+ advanced,
112
+ chips: chipsOf(advanced),
113
+ parts,
114
+ setPart: (index, next) => setAdvanced(groupOf(withPart(parts, index, next))),
115
+ setAdvanced,
116
+ adding,
117
+ setAdding,
190
118
  advancedOpen,
191
- setAdvancedOpen
119
+ setAdvancedOpen,
120
+ totalCount,
121
+ totalCapped,
122
+ loading,
123
+ error
192
124
  };
193
125
  };
194
126
  /**
195
- * Inside `<Filter>`: its chips, the list's status and the count, then the list's controls
196
- * and the menu (`F`).
127
+ * In the view bar: the count, the list's own controls and the filter button (`F`). Under it,
128
+ * while the list is filtered, the filter row: in the view bar's slot, else right after the bar.
197
129
  */
198
- const ListFilterBar = ({ id, fields, loading, error, status, totalCount, totalCapped, children, members, tags }) => {
199
- const [chipsRef] = useAutoAnimate({ duration: 150 });
200
- const { search } = useListConditions();
201
- const lookups = useMemo(() => ({
202
- members,
203
- tags
204
- }), [members, tags]);
205
- const { state, setEditing, advancedOpen, setAdvancedOpen } = useListFilterState(fields, lookups);
130
+ const ListFilterBar = (props) => {
131
+ const { status, totalCount, totalCapped, children } = props;
132
+ const state = useListFilterState(props);
133
+ const { advanced, search, active } = useListConditions();
134
+ const slot = useFilterRowSlot();
135
+ const count = (advanced ? ruleCount(advanced) : 0) + (search ? 1 : 0);
136
+ const rowShown = active || state.advancedOpen;
137
+ usePageHotkey("f", () => state.setAdding(rowShown ? "row" : "bar"));
138
+ const row = rowShown && /* @__PURE__ */ jsx(FilterRow, { status });
206
139
  return /* @__PURE__ */ jsxs(ListFilterContext.Provider, {
207
140
  value: state,
208
141
  children: [
209
- /* @__PURE__ */ jsxs("div", {
210
- ref: chipsRef,
211
- className: "flex min-w-0 items-center gap-1 overflow-x-auto py-1 hide-scroll",
212
- children: [/* @__PURE__ */ jsx(SearchChip, {}), /* @__PURE__ */ jsx(RuleChips, {})]
213
- }),
214
- status,
142
+ !rowShown && status,
215
143
  /* @__PURE__ */ jsx(RecordCount, {
216
144
  totalCount,
217
145
  totalCapped
@@ -221,32 +149,8 @@ const ListFilterBar = ({ id, fields, loading, error, status, totalCount, totalCa
221
149
  className: "mx-1 h-4 w-px shrink-0 bg-border"
222
150
  }),
223
151
  children,
224
- /* @__PURE__ */ jsxs(Filter.Popover, {
225
- scope: `${id}-list`,
226
- children: [/* @__PURE__ */ jsx(FilterButton, {
227
- count: state.parts.length + (search ? 1 : 0),
228
- onClick: () => setEditing(null)
229
- }), /* @__PURE__ */ jsxs(Combobox.Content, {
230
- align: "end",
231
- className: "w-80",
232
- children: [/* @__PURE__ */ jsx(Filter.View, { children: /* @__PURE__ */ jsx(RootMenu, {
233
- loading,
234
- error
235
- }) }), fields.map((field) => /* @__PURE__ */ jsx(Filter.View, {
236
- filterKey: field.path,
237
- children: /* @__PURE__ */ jsx(FieldMenu, { field }, `${state.editing}`)
238
- }, field.path))]
239
- })]
240
- }),
241
- /* @__PURE__ */ jsx(Filter.Dialog, { children: /* @__PURE__ */ jsx(Filter.View, {
242
- filterKey: "searchValue",
243
- inDialog: true,
244
- children: /* @__PURE__ */ jsx(Filter.DialogStringView, { filterKey: "searchValue" })
245
- }) }),
246
- /* @__PURE__ */ jsx(AdvancedFilterDialog, {
247
- open: advancedOpen,
248
- onOpenChange: setAdvancedOpen
249
- })
152
+ /* @__PURE__ */ jsx(FilterButton, { count }),
153
+ row && (slot ? createPortal(row, slot) : row)
250
154
  ]
251
155
  });
252
156
  };
@@ -1,2 +1,12 @@
1
- /** Each part of the list's filter as a chip (parts are distinct, so a part is its own key). */
2
- export declare const RuleChips: () => import("react").JSX.Element[];
1
+ import { ReactNode } from "react";
2
+ /** A chip: joined segments on a muted ground, the last one a remove button. */
3
+ export declare const Chip: ({ children, removeLabel, onRemove }: {
4
+ children: ReactNode;
5
+ removeLabel: string;
6
+ onRemove: () => void;
7
+ }) => import("react").JSX.Element;
8
+ /**
9
+ * The list's conditions as chips, one per rule (keyed by place, so an open editor stays open as
10
+ * its rule changes), or the advanced filter's chip.
11
+ */
12
+ export declare const RuleChips: () => import("react").JSX.Element[] | import("react").JSX.Element;