@erxes/ui 4.0.0-v2.13 → 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 (63) hide show
  1. package/CATALOG.md +3 -2
  2. package/README.md +1 -1
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +2 -2
  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 +164 -0
  19. package/dist/modules/conditions/conditions.d.ts +14 -9
  20. package/dist/modules/conditions/conditions.js +1 -75
  21. package/dist/modules/conditions/fieldIcons.d.ts +6 -0
  22. package/dist/modules/conditions/fieldIcons.js +19 -0
  23. package/dist/modules/conditions/fieldOptions.d.ts +13 -0
  24. package/dist/modules/conditions/fieldOptions.js +26 -0
  25. package/dist/modules/conditions/filterRule.d.ts +45 -0
  26. package/dist/modules/conditions/filterRule.js +169 -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 +16 -5
  32. package/dist/modules/list/ListFilter.js +50 -17
  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 +104 -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/theme.css +3 -2
  52. package/exports.txt +1 -0
  53. package/package.json +1 -1
  54. package/dist/modules/conditions/ConditionValueInput.d.ts +0 -10
  55. package/dist/modules/conditions/ConditionValueInput.js +0 -166
  56. package/dist/modules/conditions/PathPicker.d.ts +0 -8
  57. package/dist/modules/conditions/PathPicker.js +0 -56
  58. package/dist/modules/list/filter/AdvancedFilterDialog.d.ts +0 -5
  59. package/dist/modules/list/filter/AdvancedFilterDialog.js +0 -52
  60. package/dist/modules/list/filter/FieldMenus.d.ts +0 -5
  61. package/dist/modules/list/filter/FieldMenus.js +0 -184
  62. package/dist/modules/list/filter/fieldIcons.d.ts +0 -7
  63. package/dist/modules/list/filter/fieldIcons.js +0 -16
@@ -1,166 +0,0 @@
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 };
@@ -1,8 +0,0 @@
1
- import { TConditionField } from "./conditions.js";
2
- /** A field from the catalog, or any path typed by hand (`event.payload.amount`, `steps.x.output.y`). */
3
- export declare const PathPicker: ({ value, fields, onChange, disabled }: {
4
- value: string;
5
- fields: TConditionField[];
6
- onChange: (path: string) => void;
7
- disabled?: boolean;
8
- }) => import("react").JSX.Element;
@@ -1,56 +0,0 @@
1
- import { Input } from "../../components/input.js";
2
- import { Select } from "../../components/select.js";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import { useTranslation } from "react-i18next";
5
- // src/modules/conditions/PathPicker.tsx
6
- const GROUP_LABELS = {
7
- fields: "Fields",
8
- lead: "Lead",
9
- custom: "Properties",
10
- company: "Company",
11
- activity: "Activity"
12
- };
13
- const CUSTOM_PATH = "__custom__";
14
- /** A heading per group, and one per `groupLabel` (a plugin's fields under its title). */
15
- const groupOf = (field) => field.groupLabel ? `label:${field.groupLabel}` : field.group ?? "fields";
16
- const FieldItems = ({ fields }) => fields.map((field) => /* @__PURE__ */ jsx(Select.Item, {
17
- value: field.path,
18
- children: field.label
19
- }, field.path));
20
- const GroupedFieldItems = ({ fields }) => {
21
- const { t } = useTranslation("automations");
22
- return [...new Set(fields.map(groupOf))].map((group) => {
23
- const inGroup = fields.filter((field) => groupOf(field) === group);
24
- const label = inGroup[0]?.groupLabel;
25
- return /* @__PURE__ */ jsxs(Select.Group, { children: [/* @__PURE__ */ jsx(Select.Label, { children: label ?? t(`field-group.${group}`, GROUP_LABELS[group] ?? group) }), /* @__PURE__ */ jsx(FieldItems, { fields: inGroup })] }, group);
26
- });
27
- };
28
- /** A field from the catalog, or any path typed by hand (`event.payload.amount`, `steps.x.output.y`). */
29
- const PathPicker = ({ value, fields, onChange, disabled }) => {
30
- const { t } = useTranslation("automations");
31
- const known = fields.some((field) => field.path === value);
32
- const grouped = fields.some((field) => field.group);
33
- return /* @__PURE__ */ jsxs("div", {
34
- className: "flex min-w-0 gap-1",
35
- children: [/* @__PURE__ */ jsxs(Select, {
36
- value: known ? value : CUSTOM_PATH,
37
- onValueChange: (path) => onChange(path === CUSTOM_PATH ? "" : path),
38
- disabled,
39
- children: [/* @__PURE__ */ jsx(Select.Trigger, {
40
- className: "h-8 w-full min-w-0",
41
- children: /* @__PURE__ */ jsx(Select.Value, {})
42
- }), /* @__PURE__ */ jsxs(Select.Content, { children: [grouped ? /* @__PURE__ */ jsx(GroupedFieldItems, { fields }) : /* @__PURE__ */ jsx(FieldItems, { fields }), !grouped && /* @__PURE__ */ jsx(Select.Item, {
43
- value: CUSTOM_PATH,
44
- children: t("custom-path", "Another value…")
45
- })] })]
46
- }), !known && /* @__PURE__ */ jsx(Input, {
47
- text: "code",
48
- className: "h-8 w-full min-w-0",
49
- placeholder: "event.payload.amount",
50
- value,
51
- disabled,
52
- onChange: (event) => onChange(event.target.value)
53
- })]
54
- });
55
- };
56
- export { PathPicker };
@@ -1,5 +0,0 @@
1
- /** The full builder (every field, and/or groups), for what the filter menu can't say. */
2
- export declare const AdvancedFilterDialog: ({ open, onOpenChange }: {
3
- open: boolean;
4
- onOpenChange: (open: boolean) => void;
5
- }) => import("react").JSX.Element;
@@ -1,52 +0,0 @@
1
- import { Button } from "../../../components/button.js";
2
- import { Dialog } from "../../../components/dialog.js";
3
- import { ConditionsEditor } from "../../conditions/ConditionsEditor.js";
4
- import { useListFilter } from "./listFilterContext.js";
5
- import { useListConditions } from "./listFilterQuery.js";
6
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- import { useState } from "react";
8
- import { useTranslation } from "react-i18next";
9
- // src/modules/list/filter/AdvancedFilterDialog.tsx
10
- /** Mounted each time the dialog opens, so the draft starts from the list's filter. */
11
- const AdvancedFilterForm = ({ onDone }) => {
12
- const { t } = useTranslation("views", { keyPrefix: "filter" });
13
- const { fields, lookups } = useListFilter();
14
- const { advanced, setAdvanced } = useListConditions();
15
- const [draft, setDraft] = useState(advanced);
16
- const apply = (next) => {
17
- setAdvanced(next);
18
- onDone();
19
- };
20
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ConditionsEditor, {
21
- fields: fields.map(({ options, ...field }) => ({
22
- ...field,
23
- options: options?.map((option) => option.value)
24
- })),
25
- ...lookups,
26
- value: draft ?? void 0,
27
- onChange: (next) => setDraft(next ?? null)
28
- }), /* @__PURE__ */ jsxs(Dialog.Footer, { children: [/* @__PURE__ */ jsx(Button, {
29
- variant: "ghost",
30
- onClick: () => apply(null),
31
- children: t("clear", "Clear")
32
- }), /* @__PURE__ */ jsx(Button, {
33
- onClick: () => apply(draft),
34
- children: t("apply", "Apply")
35
- })] })] });
36
- };
37
- /** The full builder (every field, and/or groups), for what the filter menu can't say. */
38
- const AdvancedFilterDialog = ({ open, onOpenChange }) => {
39
- const { t } = useTranslation("views", { keyPrefix: "filter" });
40
- return /* @__PURE__ */ jsx(Dialog, {
41
- open,
42
- onOpenChange,
43
- children: /* @__PURE__ */ jsxs(Dialog.Content, {
44
- className: "sm:max-w-3xl",
45
- children: [/* @__PURE__ */ jsx(Dialog.HeaderCombined, {
46
- title: t("advanced", "Advanced filter"),
47
- description: t("advanced-title", "Show records where")
48
- }), /* @__PURE__ */ jsx(AdvancedFilterForm, { onDone: () => onOpenChange(false) })]
49
- })
50
- });
51
- };
52
- export { AdvancedFilterDialog };
@@ -1,5 +0,0 @@
1
- import { TListFilterField } from "../ListFilter.js";
2
- /** A field's submenu, by its type. */
3
- export declare const FieldMenu: ({ field }: {
4
- field: TListFilterField;
5
- }) => import("react").JSX.Element;
@@ -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 };