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

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.
@@ -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 };
@@ -11,14 +11,19 @@ const GROUP_LABELS = {
11
11
  activity: "Activity"
12
12
  };
13
13
  const CUSTOM_PATH = "__custom__";
14
- const groupOf = (field) => field.group ?? "fields";
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";
15
16
  const FieldItems = ({ fields }) => fields.map((field) => /* @__PURE__ */ jsx(Select.Item, {
16
17
  value: field.path,
17
18
  children: field.label
18
19
  }, field.path));
19
20
  const GroupedFieldItems = ({ fields }) => {
20
21
  const { t } = useTranslation("automations");
21
- return [...new Set(fields.map(groupOf))].map((group) => /* @__PURE__ */ jsxs(Select.Group, { children: [/* @__PURE__ */ jsx(Select.Label, { children: t(`field-group.${group}`, GROUP_LABELS[group] ?? group) }), /* @__PURE__ */ jsx(FieldItems, { fields: fields.filter((field) => groupOf(field) === group) })] }, group));
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
+ });
22
27
  };
23
28
  /** A field from the catalog, or any path typed by hand (`event.payload.amount`, `steps.x.output.y`). */
24
29
  const PathPicker = ({ value, fields, onChange, disabled }) => {
@@ -41,6 +41,8 @@ export type TConditionField = {
41
41
  type: string;
42
42
  options?: string[];
43
43
  group?: string;
44
+ /** The heading to list it under instead of the group's own (a plugin's title). */
45
+ groupLabel?: string;
44
46
  /** A money amount, stored in this currency's smallest unit and typed in its major unit. */
45
47
  currency?: string;
46
48
  };
@@ -4,6 +4,7 @@ import { useFilterContext } from "../hooks/useFilterContext.js";
4
4
  import { IconSearch, IconX } from "@tabler/icons-react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import "react";
7
+ import { useTranslation } from "react-i18next";
7
8
  import { useQueryState } from "nuqs";
8
9
  // src/modules/filter/components/FilterBar.tsx
9
10
  const FilterBar = ({ ref, className, ...props }) => {
@@ -15,11 +16,13 @@ const FilterBar = ({ ref, className, ...props }) => {
15
16
  };
16
17
  const FilterBarCloseButton = ({ ref, className, filterKey, ...props }) => {
17
18
  const [, setQuery] = useQueryState(filterKey ?? "");
19
+ const { t } = useTranslation("views", { keyPrefix: "filter" });
18
20
  return /* @__PURE__ */ jsx(Button, {
19
21
  ref,
20
22
  variant: "segment",
21
23
  size: "icon",
22
24
  className,
25
+ "aria-label": t("remove", "Remove filter"),
23
26
  onClick: () => void setQuery(null),
24
27
  ...props,
25
28
  children: /* @__PURE__ */ jsx(IconX, {})
@@ -21,8 +21,10 @@ export type TListFilterField = {
21
21
  }[];
22
22
  /** Instead of the type's icon. */
23
23
  icon?: ElementType;
24
- /** The menu's heading it lists under; `fields` by default. */
25
- group?: 'fields' | 'lead' | 'company' | 'activity' | 'custom';
24
+ /** The menu's heading it lists under; `fields` by default. `plugin`: under `groupLabel`. */
25
+ group?: 'fields' | 'lead' | 'company' | 'activity' | 'custom' | 'plugin';
26
+ /** The heading instead of the group's own: a plugin's title, for the fields it keeps. */
27
+ groupLabel?: string;
26
28
  /** A `number` that is money: stored in this currency's smallest unit, typed in its major one. */
27
29
  currency?: string;
28
30
  };
@@ -49,11 +49,18 @@ const GROUPS = [
49
49
  const FieldItems = () => {
50
50
  const { t } = useTranslation("views", { keyPrefix: "filter" });
51
51
  const { fields } = useListFilter();
52
- return GROUPS.map(({ group, label }) => {
53
- const inGroup = fields.filter((field) => (field.group ?? "fields") === group);
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 }) => {
54
61
  if (!inGroup.length) return null;
55
62
  return /* @__PURE__ */ jsx(Command.Group, {
56
- heading: t(`group.${group}`, label),
63
+ heading,
57
64
  children: inGroup.map((field) => {
58
65
  const Icon = field.icon ?? FIELD_ICONS[field.type];
59
66
  return /* @__PURE__ */ jsxs(Filter.Item, {
@@ -65,7 +72,7 @@ const FieldItems = () => {
65
72
  })]
66
73
  }, field.path);
67
74
  })
68
- }, group);
75
+ }, key);
69
76
  });
70
77
  };
71
78
  /** The menu's first page: "Add filter…", search, the advanced filter, then the fields. */
@@ -12,7 +12,6 @@ import { useTranslation } from "react-i18next";
12
12
  // src/modules/list/filter/RuleChips.tsx
13
13
  /** A filter bar chip: what it filters, the condition (opens it), remove. */
14
14
  const Chip = ({ name, children, onOpen, onRemove }) => {
15
- const { t } = useTranslation("views", { keyPrefix: "filter" });
16
15
  return /* @__PURE__ */ jsxs("div", {
17
16
  className: "flex h-7 items-stretch gap-px rounded bg-muted text-sm font-medium shadow-xs",
18
17
  children: [
@@ -21,10 +20,7 @@ const Chip = ({ name, children, onOpen, onRemove }) => {
21
20
  onClick: onOpen,
22
21
  children
23
22
  }),
24
- /* @__PURE__ */ jsx(Filter.BarClose, {
25
- "aria-label": t("remove", "Remove filter"),
26
- onClick: onRemove
27
- })
23
+ /* @__PURE__ */ jsx(Filter.BarClose, { onClick: onRemove })
28
24
  ]
29
25
  });
30
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erxes/ui",
3
- "version": "4.0.0-v2.12",
3
+ "version": "4.0.0-v2.13",
4
4
  "private": false,
5
5
  "description": "erxes design system: UI primitives, layout, hooks and shared frontend state",
6
6
  "license": "AGPL-3.0-only",