@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.
- package/CATALOG.md +15 -8
- package/README.md +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +4 -3
- package/dist/modules/conditions/ConditionsEditor.d.ts +5 -3
- package/dist/modules/conditions/ConditionsEditor.js +139 -177
- package/dist/modules/conditions/DateEditors.d.ts +8 -0
- package/dist/modules/conditions/DateEditors.js +188 -0
- package/dist/modules/conditions/FieldPicker.d.ts +17 -0
- package/dist/modules/conditions/FieldPicker.js +99 -0
- package/dist/modules/conditions/RuleParts.d.ts +30 -0
- package/dist/modules/conditions/RuleParts.js +78 -0
- package/dist/modules/conditions/RuleRow.d.ts +27 -0
- package/dist/modules/conditions/RuleRow.js +156 -0
- package/dist/modules/conditions/TypedInput.d.ts +13 -0
- package/dist/modules/conditions/TypedInput.js +36 -0
- package/dist/modules/conditions/ValueEditor.d.ts +18 -0
- package/dist/modules/conditions/ValueEditor.js +169 -0
- package/dist/modules/conditions/conditions.d.ts +21 -12
- package/dist/modules/conditions/conditions.js +8 -75
- package/dist/modules/conditions/fieldIcons.d.ts +6 -0
- package/dist/modules/conditions/fieldIcons.js +21 -0
- package/dist/modules/conditions/fieldOptions.d.ts +15 -0
- package/dist/modules/conditions/fieldOptions.js +38 -0
- package/dist/modules/conditions/filterRule.d.ts +45 -0
- package/dist/modules/conditions/filterRule.js +171 -0
- package/dist/modules/conditions/filterText.d.ts +16 -0
- package/dist/modules/conditions/filterText.js +156 -0
- package/dist/modules/filter/components/Filter.d.ts +1 -1
- package/dist/modules/filter/components/Filter.js +1 -1
- package/dist/modules/list/ListFilter.d.ts +22 -10
- package/dist/modules/list/ListFilter.js +53 -20
- package/dist/modules/list/ViewBar.d.ts +2 -0
- package/dist/modules/list/ViewBar.js +21 -10
- package/dist/modules/list/filter/AddFilter.d.ts +10 -0
- package/dist/modules/list/filter/AddFilter.js +140 -0
- package/dist/modules/list/filter/AdvancedPopover.d.ts +8 -0
- package/dist/modules/list/filter/AdvancedPopover.js +103 -0
- package/dist/modules/list/filter/ListFilterBar.d.ts +3 -3
- package/dist/modules/list/filter/ListFilterBar.js +109 -205
- package/dist/modules/list/filter/RuleChips.d.ts +12 -2
- package/dist/modules/list/filter/RuleChips.js +132 -134
- package/dist/modules/list/filter/SearchChip.d.ts +6 -0
- package/dist/modules/list/filter/SearchChip.js +69 -0
- package/dist/modules/list/filter/filterRules.d.ts +15 -40
- package/dist/modules/list/filter/filterRules.js +27 -156
- package/dist/modules/list/filter/listFilterContext.d.ts +25 -18
- package/dist/modules/list/filter/listFilterContext.js +8 -24
- package/dist/modules/list/filter/listFilterQuery.d.ts +4 -0
- package/dist/modules/list/filter/listFilterQuery.js +10 -2
- package/dist/modules/pickers/LookupPicker.d.ts +6 -0
- package/dist/modules/pickers/LookupPicker.js +32 -1
- package/dist/modules/record-list/RecordList.d.ts +2 -1
- package/dist/modules/record-list/RecordList.js +2 -1
- package/dist/modules/record-list/RecordListRoot.d.ts +3 -1
- package/dist/modules/record-list/RecordListRoot.js +53 -37
- package/dist/modules/record-table/components/RecordTableHead.d.ts +7 -2
- package/dist/modules/record-table/components/RecordTableHead.js +73 -6
- package/dist/modules/record-table/components/RecordTableProvider.d.ts +22 -1
- package/dist/modules/record-table/components/RecordTableProvider.js +12 -1
- package/dist/modules/records/contacts.d.ts +18 -0
- package/dist/modules/records/openRecord.d.ts +35 -1
- package/dist/modules/records/openRecord.js +27 -4
- package/dist/theme.css +3 -2
- package/dist/types/UIConfig.d.ts +47 -100
- package/dist/types/UIConfig.js +14 -0
- package/exports.txt +10 -3
- package/package.json +1 -1
- package/dist/modules/conditions/ConditionValueInput.d.ts +0 -10
- package/dist/modules/conditions/ConditionValueInput.js +0 -166
- package/dist/modules/conditions/PathPicker.d.ts +0 -8
- package/dist/modules/conditions/PathPicker.js +0 -56
- package/dist/modules/list/filter/AdvancedFilterDialog.d.ts +0 -5
- package/dist/modules/list/filter/AdvancedFilterDialog.js +0 -52
- package/dist/modules/list/filter/FieldMenus.d.ts +0 -5
- package/dist/modules/list/filter/FieldMenus.js +0 -184
- package/dist/modules/list/filter/fieldIcons.d.ts +0 -7
- package/dist/modules/list/filter/fieldIcons.js +0 -16
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { Button } from "../../../components/button.js";
|
|
2
|
-
import { Combobox } from "../../../components/combobox.js";
|
|
3
|
-
import { Command } from "../../../components/command.js";
|
|
4
|
-
import { Input } from "../../../components/input.js";
|
|
5
|
-
import { Select } from "../../../components/select.js";
|
|
6
|
-
import { amountStep, fromAmountInput, toAmountInput } from "../../../lib/money.js";
|
|
7
|
-
import { oneOf, textOf } from "../../../lib/text.js";
|
|
8
|
-
import { isRule } from "../../conditions/conditions.js";
|
|
9
|
-
import { useFilterContext } from "../../filter/hooks/useFilterContext.js";
|
|
10
|
-
import { EntityPicker } from "../../pickers/EntityPicker.js";
|
|
11
|
-
import { DATE_PRESETS, NUMBER_OPS, NUMBER_SYMBOLS, anyOf, presetOf, targetOf, valuesOf } from "./filterRules.js";
|
|
12
|
-
import { useFieldOptions, useListFilter } from "./listFilterContext.js";
|
|
13
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { useEffect, useRef, useState } from "react";
|
|
15
|
-
import { useTranslation } from "react-i18next";
|
|
16
|
-
// src/modules/list/filter/FieldMenus.tsx
|
|
17
|
-
/** The part this field's menu changes, and that part when it is a rule of the field. */
|
|
18
|
-
const useTarget = (field) => {
|
|
19
|
-
const { parts, setPart, editing } = useListFilter();
|
|
20
|
-
const { resetFilterState } = useFilterContext();
|
|
21
|
-
const index = targetOf(parts, field, editing);
|
|
22
|
-
const part = index === null ? void 0 : parts[index];
|
|
23
|
-
return {
|
|
24
|
-
rule: part && isRule(part) && part.path === field.path ? part : void 0,
|
|
25
|
-
set: (next) => setPart(index, next),
|
|
26
|
-
/** Sets the rule and closes the menu. */
|
|
27
|
-
apply: (next) => {
|
|
28
|
-
setPart(index, next);
|
|
29
|
-
resetFilterState();
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
/** A submenu's box takes the keyboard as the submenu opens. */
|
|
34
|
-
const useFocusOnMount = () => {
|
|
35
|
-
const input = useRef(null);
|
|
36
|
-
useEffect(() => input.current?.focus(), []);
|
|
37
|
-
return input;
|
|
38
|
-
};
|
|
39
|
-
/** Options (a choice, members, tags): each pick adds to or takes from one "is any of" rule; the menu stays open. */
|
|
40
|
-
const OptionsMenu = ({ field }) => {
|
|
41
|
-
const { options, loading, error } = useFieldOptions(field);
|
|
42
|
-
const { rule, set } = useTarget(field);
|
|
43
|
-
return /* @__PURE__ */ jsx(EntityPicker, {
|
|
44
|
-
multiple: true,
|
|
45
|
-
items: options,
|
|
46
|
-
itemKey: (option) => ({
|
|
47
|
-
id: option.value,
|
|
48
|
-
label: option.label
|
|
49
|
-
}),
|
|
50
|
-
value: valuesOf(rule),
|
|
51
|
-
onValueChange: (values) => set(anyOf(field.path, values)),
|
|
52
|
-
loading,
|
|
53
|
-
error,
|
|
54
|
-
searchPlaceholder: field.label
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const DateMenu = ({ field }) => {
|
|
58
|
-
const { t } = useTranslation("views", { keyPrefix: "filter.date" });
|
|
59
|
-
const { rule, apply } = useTarget(field);
|
|
60
|
-
const current = presetOf(rule);
|
|
61
|
-
return /* @__PURE__ */ jsx(Command, { children: /* @__PURE__ */ jsx(Command.List, { children: DATE_PRESETS.map((preset) => /* @__PURE__ */ jsxs(Command.Item, {
|
|
62
|
-
value: preset.key,
|
|
63
|
-
onSelect: () => apply({
|
|
64
|
-
path: field.path,
|
|
65
|
-
op: preset.op,
|
|
66
|
-
value: preset.value
|
|
67
|
-
}),
|
|
68
|
-
children: [t(preset.key, preset.label), /* @__PURE__ */ jsx(Combobox.Check, { checked: current?.key === preset.key })]
|
|
69
|
-
}, preset.key)) }) });
|
|
70
|
-
};
|
|
71
|
-
const BooleanMenu = ({ field }) => {
|
|
72
|
-
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
73
|
-
const { rule, apply } = useTarget(field);
|
|
74
|
-
const value = rule ? textOf(rule.value) : null;
|
|
75
|
-
return /* @__PURE__ */ jsx(Command, { children: /* @__PURE__ */ jsx(Command.List, { children: ["true", "false"].map((option) => /* @__PURE__ */ jsxs(Command.Item, {
|
|
76
|
-
value: option,
|
|
77
|
-
onSelect: () => apply({
|
|
78
|
-
path: field.path,
|
|
79
|
-
op: "eq",
|
|
80
|
-
value: option === "true"
|
|
81
|
-
}),
|
|
82
|
-
children: [option === "true" ? t("yes", "Yes") : t("no", "No"), /* @__PURE__ */ jsx(Combobox.Check, { checked: value === option })]
|
|
83
|
-
}, option)) }) });
|
|
84
|
-
};
|
|
85
|
-
/** A number as typed: money in the currency's major unit. */
|
|
86
|
-
const numberText = (value, currency) => {
|
|
87
|
-
const n = Number(value);
|
|
88
|
-
if (value === void 0 || value === null || !Number.isFinite(n)) return "";
|
|
89
|
-
return currency ? toAmountInput(n, currency) : String(n);
|
|
90
|
-
};
|
|
91
|
-
/** An operator and a value; Enter or Apply adds the rule (or changes the one being edited). */
|
|
92
|
-
const NumberMenu = ({ field }) => {
|
|
93
|
-
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
94
|
-
const { rule, apply } = useTarget(field);
|
|
95
|
-
const [op, setOp] = useState(() => oneOf(NUMBER_OPS, rule?.op ?? null) ?? "gte");
|
|
96
|
-
const [text, setText] = useState(() => numberText(rule?.value, field.currency));
|
|
97
|
-
const valid = text.trim() !== "" && Number.isFinite(Number(text));
|
|
98
|
-
const input = useFocusOnMount();
|
|
99
|
-
return /* @__PURE__ */ jsxs("form", {
|
|
100
|
-
className: "flex items-center gap-1.5 p-2",
|
|
101
|
-
onSubmit: (event) => {
|
|
102
|
-
event.preventDefault();
|
|
103
|
-
if (!valid) return;
|
|
104
|
-
const value = field.currency ? fromAmountInput(text, field.currency) : Number(text);
|
|
105
|
-
apply({
|
|
106
|
-
path: field.path,
|
|
107
|
-
op,
|
|
108
|
-
value
|
|
109
|
-
});
|
|
110
|
-
},
|
|
111
|
-
children: [
|
|
112
|
-
/* @__PURE__ */ jsxs(Select, {
|
|
113
|
-
value: op,
|
|
114
|
-
onValueChange: (next) => setOp(oneOf(NUMBER_OPS, next) ?? op),
|
|
115
|
-
children: [/* @__PURE__ */ jsx(Select.Trigger, {
|
|
116
|
-
className: "h-8 w-16 shrink-0",
|
|
117
|
-
children: /* @__PURE__ */ jsx(Select.Value, {})
|
|
118
|
-
}), /* @__PURE__ */ jsx(Select.Content, { children: NUMBER_OPS.map((option) => /* @__PURE__ */ jsx(Select.Item, {
|
|
119
|
-
value: option,
|
|
120
|
-
children: NUMBER_SYMBOLS[option]
|
|
121
|
-
}, option)) })]
|
|
122
|
-
}),
|
|
123
|
-
/* @__PURE__ */ jsx(Input, {
|
|
124
|
-
ref: input,
|
|
125
|
-
type: "number",
|
|
126
|
-
className: "h-8 min-w-0 flex-1",
|
|
127
|
-
step: field.currency ? amountStep(field.currency) : "any",
|
|
128
|
-
placeholder: field.currency ?? t("value", "Value"),
|
|
129
|
-
value: text,
|
|
130
|
-
onChange: (event) => setText(event.target.value)
|
|
131
|
-
}),
|
|
132
|
-
/* @__PURE__ */ jsx(Button, {
|
|
133
|
-
type: "submit",
|
|
134
|
-
size: "sm",
|
|
135
|
-
className: "h-8",
|
|
136
|
-
disabled: !valid,
|
|
137
|
-
children: t("apply", "Apply")
|
|
138
|
-
})
|
|
139
|
-
]
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
/** "Contains" text; an empty box removes the rule being edited. */
|
|
143
|
-
const TextMenu = ({ field }) => {
|
|
144
|
-
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
145
|
-
const { rule, apply } = useTarget(field);
|
|
146
|
-
const [text, setText] = useState(() => textOf(rule?.value));
|
|
147
|
-
const input = useFocusOnMount();
|
|
148
|
-
return /* @__PURE__ */ jsxs("form", {
|
|
149
|
-
className: "flex items-center gap-1.5 p-2",
|
|
150
|
-
onSubmit: (event) => {
|
|
151
|
-
event.preventDefault();
|
|
152
|
-
apply(text.trim() ? {
|
|
153
|
-
path: field.path,
|
|
154
|
-
op: "contains",
|
|
155
|
-
value: text.trim()
|
|
156
|
-
} : null);
|
|
157
|
-
},
|
|
158
|
-
children: [/* @__PURE__ */ jsx(Input, {
|
|
159
|
-
ref: input,
|
|
160
|
-
className: "h-8 min-w-0 flex-1",
|
|
161
|
-
placeholder: t("contains", "Contains…"),
|
|
162
|
-
value: text,
|
|
163
|
-
onChange: (event) => setText(event.target.value)
|
|
164
|
-
}), /* @__PURE__ */ jsx(Button, {
|
|
165
|
-
type: "submit",
|
|
166
|
-
size: "sm",
|
|
167
|
-
className: "h-8",
|
|
168
|
-
children: t("apply", "Apply")
|
|
169
|
-
})]
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
/** A field's submenu, by its type. */
|
|
173
|
-
const FieldMenu = ({ field }) => {
|
|
174
|
-
switch (field.type) {
|
|
175
|
-
case "select":
|
|
176
|
-
case "member":
|
|
177
|
-
case "tags": return /* @__PURE__ */ jsx(OptionsMenu, { field });
|
|
178
|
-
case "date": return /* @__PURE__ */ jsx(DateMenu, { field });
|
|
179
|
-
case "boolean": return /* @__PURE__ */ jsx(BooleanMenu, { field });
|
|
180
|
-
case "number": return /* @__PURE__ */ jsx(NumberMenu, { field });
|
|
181
|
-
case "text": return /* @__PURE__ */ jsx(TextMenu, { field });
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
export { FieldMenu };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { TListFilterField } from "../ListFilter.js";
|
|
2
|
-
import { IconHash } from "@tabler/icons-react";
|
|
3
|
-
/**
|
|
4
|
-
* A field's icon in the filter menu and on its chips, by type, unless it brings its own:
|
|
5
|
-
* `field.icon ?? FIELD_ICONS[field.type]`.
|
|
6
|
-
*/
|
|
7
|
-
export declare const FIELD_ICONS: Record<TListFilterField['type'], typeof IconHash>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IconCalendar, IconHash, IconLetterCase, IconSelector, IconTags, IconToggleLeft, IconUser } from "@tabler/icons-react";
|
|
2
|
-
// src/modules/list/filter/fieldIcons.ts
|
|
3
|
-
/**
|
|
4
|
-
* A field's icon in the filter menu and on its chips, by type, unless it brings its own:
|
|
5
|
-
* `field.icon ?? FIELD_ICONS[field.type]`.
|
|
6
|
-
*/
|
|
7
|
-
const FIELD_ICONS = {
|
|
8
|
-
text: IconLetterCase,
|
|
9
|
-
number: IconHash,
|
|
10
|
-
date: IconCalendar,
|
|
11
|
-
boolean: IconToggleLeft,
|
|
12
|
-
select: IconSelector,
|
|
13
|
-
member: IconUser,
|
|
14
|
-
tags: IconTags
|
|
15
|
-
};
|
|
16
|
-
export { FIELD_ICONS };
|