@erxes/ui 4.0.0-v2.4 → 4.0.0-v2.6

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/README.md CHANGED
@@ -30,6 +30,9 @@ Only what something uses:
30
30
  - the pickers in `src/modules/pickers`: `EntityPicker`, and `SelectMember`, `MemberInline` and
31
31
  `useMembersById`, which take `memberQueries` from `@erxes/core-contract/client`. They read
32
32
  through TanStack query options, so erxes-ui imports nothing from core.
33
+ - core's records in `src/modules/records`: `ContactLink` (a customer or company by id, read
34
+ through `contactQueries` from `@erxes/core-contract/client`) and `useOpenRecord`, which open a
35
+ record in web's side panel through the `RecordOpenerProvider` web mounts.
33
36
 
34
37
  Anything else is removed, not kept "in case". Before you remove an export, check the HR plugin
35
38
  UI and `.agents/skills/plugin-contract/SKILL.md`.
@@ -2,7 +2,7 @@ import { useFormat } from "../lib/format.js";
2
2
  import { cn } from "../lib/utils.js";
3
3
  import { ChartContext, configFor, fillOf, keyOf, useChart } from "./chart-config.js";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
- import "react";
5
+ import React from "react";
6
6
  import * as RechartsPrimitive from "recharts";
7
7
  // src/components/charts.tsx
8
8
  /** The series colours as `--color-<key>` variables. */
@@ -13,8 +13,9 @@ const colorVariables = (config) => {
13
13
  };
14
14
  const ChartContainer = ({ ref, className, children, config, style, ...props }) => {
15
15
  const cssVariables = colorVariables(config);
16
+ const chart = React.useMemo(() => ({ config }), [config]);
16
17
  return /* @__PURE__ */ jsx(ChartContext.Provider, {
17
- value: { config },
18
+ value: chart,
18
19
  children: /* @__PURE__ */ jsx("div", {
19
20
  ref,
20
21
  style: {
@@ -5,7 +5,7 @@ import { cn } from "../lib/utils.js";
5
5
  import { PopoverScoped } from "../modules/hotkey/components/PopoverScoped.js";
6
6
  import { IconCheck, IconChevronDown } from "@tabler/icons-react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
- import { createContext, useContext, useState } from "react";
8
+ import { createContext, useContext, useMemo, useState } from "react";
9
9
  import { IMaskInput } from "react-imask";
10
10
  // src/components/color-picker.tsx
11
11
  const DEFAULT_COLORS = {
@@ -33,12 +33,17 @@ const useColorPickerContext = () => {
33
33
  return context;
34
34
  };
35
35
  const ColorPickerProvider = ({ children, value, onValueChange, colors = DEFAULT_COLORS, open, onOpenChange, scope }) => {
36
+ const picker = useMemo(() => ({
37
+ value,
38
+ onValueChange,
39
+ colors
40
+ }), [
41
+ value,
42
+ onValueChange,
43
+ colors
44
+ ]);
36
45
  return /* @__PURE__ */ jsx(ColorPickerContext.Provider, {
37
- value: {
38
- value,
39
- onValueChange,
40
- colors
41
- },
46
+ value: picker,
42
47
  children: /* @__PURE__ */ jsx(PopoverScoped, {
43
48
  scope,
44
49
  open,
@@ -83,6 +88,7 @@ const ColorPickerContent = ({ setOpen }) => {
83
88
  style: { "--swatch": value },
84
89
  children: [/* @__PURE__ */ jsx("input", {
85
90
  type: "color",
91
+ "aria-label": "Custom color",
86
92
  value: value || "#000000",
87
93
  className: "absolute inset-0 w-full h-full opacity-0 cursor-pointer",
88
94
  onChange: (e) => onValueChange?.(e.target.value)
@@ -8,8 +8,9 @@ import { useRender } from "@base-ui/react/use-render";
8
8
  // src/components/form.tsx
9
9
  const FormFieldContext = React.createContext(null);
10
10
  const FormField = ({ ...props }) => {
11
+ const field = React.useMemo(() => ({ name: props.name }), [props.name]);
11
12
  return /* @__PURE__ */ jsx(FormFieldContext.Provider, {
12
- value: { name: props.name },
13
+ value: field,
13
14
  children: /* @__PURE__ */ jsx(Controller, { ...props })
14
15
  });
15
16
  };
@@ -39,8 +40,9 @@ const formItemVariants = cva("", {
39
40
  });
40
41
  const FormItem = ({ ref, className, orientation, ...props }) => {
41
42
  const id = React.useId();
43
+ const item = React.useMemo(() => ({ id }), [id]);
42
44
  return /* @__PURE__ */ jsx(FormItemContext.Provider, {
43
- value: { id },
45
+ value: item,
44
46
  children: /* @__PURE__ */ jsx("div", {
45
47
  ref,
46
48
  className: cn(formItemVariants({ orientation }), className),
@@ -14,7 +14,7 @@ const SelectorField = ({ fieldRef, value, placeholder, hidePlaceholderWhenSelect
14
14
  className: "flex flex-wrap gap-1 w-full",
15
15
  children: [
16
16
  value.map((option) => /* @__PURE__ */ jsxs(Combobox.Chip, {
17
- className: "relative inline-flex h-7 cursor-default items-center rounded-md border border-solid bg-background pe-7 pl-2 ps-2 text-xs font-medium text-secondary-foreground transition-all hover:bg-background data-disabled:cursor-not-allowed data-disabled:opacity-50",
17
+ className: "relative inline-flex h-7 cursor-default items-center rounded-md border border-solid bg-background pe-7 pl-2 ps-2 text-xs font-medium text-secondary-foreground transition-colors hover:bg-background data-disabled:cursor-not-allowed data-disabled:opacity-50",
18
18
  children: [option.label, /* @__PURE__ */ jsx(Combobox.ChipRemove, {
19
19
  "aria-label": "Remove",
20
20
  className: "absolute -inset-y-px -end-px flex size-7 items-center justify-center rounded-e-lg border border-transparent p-0 text-muted-foreground/80 outline-0 transition-colors hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-ring/70",
@@ -68,8 +68,9 @@ const SelectorPopup = ({ fieldRef, emptyIndicator }) => /* @__PURE__ */ jsx(Comb
68
68
  })
69
69
  }) });
70
70
  const has = (list, key) => list.some((item) => item.value === key);
71
+ const NONE = [];
71
72
  /** Picks several options from a list, shown as removable badges; picked options leave the list. */
72
- const MultipleSelector = ({ value = [], onChange, options = [], placeholder = "Search", creatable, emptyIndicator, disabled, ...fieldProps }) => {
73
+ const MultipleSelector = ({ value = NONE, onChange, options = NONE, placeholder = "Search", creatable, emptyIndicator, disabled, ...fieldProps }) => {
73
74
  const fieldRef = useRef(null);
74
75
  const [query, setQuery] = useState("");
75
76
  const typed = query.trim();
@@ -14,6 +14,7 @@ function StringArrayInput({ value, onValueChange, placeholder = "Add a tag" }) {
14
14
  setDraft("");
15
15
  };
16
16
  const onKeyDown = (event) => {
17
+ if (event.nativeEvent.isComposing) return;
17
18
  if (event.key === "Enter" || event.key === ",") {
18
19
  event.preventDefault();
19
20
  add([draft]);
@@ -13,7 +13,7 @@ const ToastList = () => {
13
13
  return toasts.map((item) => /* @__PURE__ */ jsxs(Toast.Root, {
14
14
  toast: item,
15
15
  swipeDirection: "right",
16
- className: "group pointer-events-auto relative flex w-full items-center space-x-2 overflow-hidden rounded-md p-4 pr-6 shadow-lg transition-all bg-background text-foreground translate-x-(--toast-swipe-movement-x) animate-in slide-in-from-top-full sm:slide-in-from-bottom-full data-limited:hidden data-swiping:transition-none data-ending-style:animate-out data-ending-style:fade-out-80 data-ending-style:slide-out-to-right-full",
16
+ className: "group pointer-events-auto relative flex w-full items-center space-x-2 overflow-hidden rounded-md p-4 pr-6 shadow-lg transition-transform bg-background text-foreground translate-x-(--toast-swipe-movement-x) animate-in slide-in-from-top-full sm:slide-in-from-bottom-full data-limited:hidden data-swiping:transition-none data-ending-style:animate-out data-ending-style:fade-out-80 data-ending-style:slide-out-to-right-full",
17
17
  children: [
18
18
  /* @__PURE__ */ jsx("div", {
19
19
  className: "[&>svg]:size-4.5 mt-0.5 flex-none mb-auto",
@@ -10,17 +10,20 @@ const ToggleGroupContext = React.createContext({
10
10
  variant: "default"
11
11
  });
12
12
  /** The value is an array: one item for a single choice, empty when nothing is pressed. */
13
- const ToggleGroupRoot = ({ className, variant, size, children, ...props }) => /* @__PURE__ */ jsx(ToggleGroup$1, {
14
- className: cn("flex items-center justify-center gap-1 isolate", variant === "outline" && "gap-0 bg-muted rounded", className),
15
- ...props,
16
- children: /* @__PURE__ */ jsx(ToggleGroupContext, {
17
- value: {
18
- variant,
19
- size
20
- },
21
- children
22
- })
23
- });
13
+ const ToggleGroupRoot = ({ className, variant, size, children, ...props }) => {
14
+ const look = React.useMemo(() => ({
15
+ variant,
16
+ size
17
+ }), [variant, size]);
18
+ return /* @__PURE__ */ jsx(ToggleGroup$1, {
19
+ className: cn("flex items-center justify-center gap-1 isolate", variant === "outline" && "gap-0 bg-muted rounded", className),
20
+ ...props,
21
+ children: /* @__PURE__ */ jsx(ToggleGroupContext, {
22
+ value: look,
23
+ children
24
+ })
25
+ });
26
+ };
24
27
  const ToggleGroupItem = ({ className, variant, size, ...props }) => {
25
28
  const context = React.use(ToggleGroupContext);
26
29
  return /* @__PURE__ */ jsx(Toggle, {
@@ -7,7 +7,7 @@ import { cn } from "../lib/utils.js";
7
7
  import { readImage } from "../utils/core.js";
8
8
  import { IconTrash, IconUpload, IconUserCircle } from "@tabler/icons-react";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
- import { createContext, useContext, useRef, useState } from "react";
10
+ import { createContext, useContext, useMemo, useRef, useState } from "react";
11
11
  import { cva } from "class-variance-authority";
12
12
  import { useTranslation } from "react-i18next";
13
13
  // src/components/upload.tsx
@@ -23,17 +23,22 @@ const UploadRoot = ({ ref, className, value, onChange, multiple, ...rest }) => {
23
23
  const [previewUrl, setPreviewUrl] = useState();
24
24
  const [isImageFocused, setIsImageFocused] = useState(false);
25
25
  const url = previewUrl ?? value;
26
+ const upload = useMemo(() => ({
27
+ url,
28
+ multiple,
29
+ onChange,
30
+ fileInputRef,
31
+ previewRef,
32
+ setPreviewUrl,
33
+ chooseFile: () => fileInputRef.current?.click(),
34
+ setIsImageFocused
35
+ }), [
36
+ url,
37
+ multiple,
38
+ onChange
39
+ ]);
26
40
  return /* @__PURE__ */ jsxs(UploadContext.Provider, {
27
- value: {
28
- url,
29
- multiple,
30
- onChange,
31
- fileInputRef,
32
- previewRef,
33
- setPreviewUrl,
34
- chooseFile: () => fileInputRef.current?.click(),
35
- setIsImageFocused
36
- },
41
+ value: upload,
37
42
  children: [/* @__PURE__ */ jsx(Dialog, {
38
43
  open: isImageFocused,
39
44
  onOpenChange: setIsImageFocused,
package/dist/index.d.ts CHANGED
@@ -92,9 +92,12 @@ import { RecordTable } from "./modules/record-table/components/RecordTable.js";
92
92
  import { RecordTableColumnDef } from "./modules/record-table/components/RecordTableProvider.js";
93
93
  import { RecordTableInlineCell } from "./modules/record-table/components/RecordTableCellInline.js";
94
94
  import { EnumCursorDirection } from "./modules/record-table/types/RecordTableCursorTypes.js";
95
+ import { ContactLink } from "./modules/records/ContactLink.js";
96
+ import { CompanyContact, ContactQueries, CustomerContact, TContactContentType, companyTitle, customerTitle } from "./modules/records/contacts.js";
97
+ import { RecordOpenerProvider, RecordRef, useOpenRecord } from "./modules/records/openRecord.js";
95
98
  import { ThemeOption, themeState } from "./state/themeState.js";
96
99
  import { SexCode } from "./types/SexCode.js";
97
- import { IUIConfig, TActivityRowProps, TDashboardWidgetPreview, TPropertyInputMeta, TPropertyInputProps } from "./types/UIConfig.js";
100
+ import { IUIConfig, TActivityRowProps, TDashboardWidgetPreview, TPropertyInputMeta, TPropertyInputProps, TRecordSection, TRecordSectionProps } from "./types/UIConfig.js";
98
101
  import { isUndefinedOrNull } from "./utils/IsUndefinedOrNull.js";
99
102
  import { readImage } from "./utils/core.js";
100
103
  import { FileStorageAdapter, setFileStorage } from "./utils/file-storage.js";
@@ -104,4 +107,4 @@ import { jsonOf } from "./utils/json.js";
104
107
  import { PluginLiveMessage, PluginRuntime, PluginSession, getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
105
108
  import { addPluginStyles } from "./utils/plugin-styles.js";
106
109
  import { RecordTimeline, RecordTimelineProps, setRecordTimeline } from "./utils/record-timeline.js";
107
- 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, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, type FileStorageAdapter, Filter, Form, FullNameField, FullNameValue, HoverCard, type IUIConfig, IconComponent, IconPicker, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, type Member, MemberInline, type MemberQueries, type MultiSelectOption, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PhoneDisplay, PhoneField, PhoneInput, type PluginLiveMessage, type PluginRuntime, type PluginSession, Popover, PopoverScoped, RadioGroup, 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 TDashboardWidgetPreview, type TPropertyInputMeta, type TPropertyInputProps, TabButton, Table, Tabs, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, addPluginStyles, badgeVariants, buttonVariants, cn, editorText, formatPhoneNumber, formatter, getPluginAssetsUrl, getPluginRuntime, isUndefinedOrNull, jsonOf, localTimeZone, memberName, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordTimeline, stored, storedFamily, themeState, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useLiveSignal, useMembersById, usePreviousHotkeyScope, useScopedHotkeys, useToast, useUpload, zoneOffset };
110
+ 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, ContactLink, type ContactQueries, ContextMenu, CopyText, type CustomerContact, DateInput, DatePicker, Dialog, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, type FileStorageAdapter, Filter, Form, FullNameField, FullNameValue, HoverCard, type IUIConfig, IconComponent, IconPicker, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, type Member, MemberInline, type MemberQueries, type MultiSelectOption, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PhoneDisplay, PhoneField, PhoneInput, type PluginLiveMessage, type PluginRuntime, type PluginSession, Popover, PopoverScoped, RadioGroup, RecordOpenerProvider, 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 TContactContentType, type TDashboardWidgetPreview, type TPropertyInputMeta, type TPropertyInputProps, type TRecordSection, type TRecordSectionProps, TabButton, Table, Tabs, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, addPluginStyles, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatPhoneNumber, formatter, getPluginAssetsUrl, getPluginRuntime, isUndefinedOrNull, jsonOf, localTimeZone, memberName, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordTimeline, stored, storedFamily, themeState, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useLiveSignal, useMembersById, useOpenRecord, usePreviousHotkeyScope, useScopedHotkeys, useToast, useUpload, zoneOffset };
package/dist/index.js CHANGED
@@ -89,6 +89,9 @@ import { PhoneInput } from "./modules/record-field/meta-inputs/components/PhoneI
89
89
  import { RecordTable } from "./modules/record-table/components/RecordTable.js";
90
90
  import { RecordTableInlineCell } from "./modules/record-table/components/RecordTableCellInline.js";
91
91
  import { EnumCursorDirection } from "./modules/record-table/types/RecordTableCursorTypes.js";
92
+ import { ContactLink } from "./modules/records/ContactLink.js";
93
+ import { companyTitle, customerTitle } from "./modules/records/contacts.js";
94
+ import { RecordOpenerProvider, useOpenRecord } from "./modules/records/openRecord.js";
92
95
  import { ThemeOption, themeState } from "./state/themeState.js";
93
96
  import { SexCode } from "./types/SexCode.js";
94
97
  import { isUndefinedOrNull } from "./utils/IsUndefinedOrNull.js";
@@ -100,4 +103,4 @@ import { jsonOf } from "./utils/json.js";
100
103
  import { getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
101
104
  import { addPluginStyles } from "./utils/plugin-styles.js";
102
105
  import { RecordTimeline, setRecordTimeline } from "./utils/record-timeline.js";
103
- export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, BackgroundGradientAnimation, Badge, Breadcrumb, Button, Calendar, Card, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, Filter, Form, FullNameField, FullNameValue, HoverCard, IconComponent, IconPicker, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, MemberInline, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PhoneDisplay, PhoneField, PhoneInput, Popover, PopoverScoped, RadioGroup, 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, addPluginStyles, badgeVariants, buttonVariants, cn, editorText, formatPhoneNumber, formatter, getPluginAssetsUrl, getPluginRuntime, isUndefinedOrNull, jsonOf, localTimeZone, memberName, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordTimeline, stored, storedFamily, themeState, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useLiveSignal, useMembersById, usePreviousHotkeyScope, useScopedHotkeys, useToast, useUpload, zoneOffset };
106
+ export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, BackgroundGradientAnimation, Badge, Breadcrumb, Button, Calendar, Card, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, ContactLink, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, Filter, Form, FullNameField, FullNameValue, HoverCard, IconComponent, IconPicker, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, MemberInline, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PhoneDisplay, PhoneField, PhoneInput, Popover, PopoverScoped, RadioGroup, RecordOpenerProvider, 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, addPluginStyles, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatPhoneNumber, formatter, getPluginAssetsUrl, getPluginRuntime, isUndefinedOrNull, jsonOf, localTimeZone, memberName, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordTimeline, stored, storedFamily, themeState, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useLiveSignal, useMembersById, useOpenRecord, usePreviousHotkeyScope, useScopedHotkeys, useToast, useUpload, zoneOffset };
@@ -16,13 +16,12 @@ const EmailChip = ({ item, email, onEmailClick, onEmailDoubleClick, onEmailKeyAc
16
16
  className: "min-w-0",
17
17
  children: /* @__PURE__ */ jsx(EmailText, { ...item })
18
18
  });
19
- return /* @__PURE__ */ jsx("span", {
19
+ return /* @__PURE__ */ jsx("button", {
20
+ type: "button",
20
21
  className: cn(buttonVariants({
21
22
  size: "sm",
22
23
  variant: "secondary"
23
24
  }), "min-w-0 max-w-full h-6 w-fit rounded-sm border gap-1 cursor-pointer hover:bg-primary/10 hover:text-primary-text focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"),
24
- role: "button",
25
- tabIndex: 0,
26
25
  onClick: (event) => {
27
26
  event.stopPropagation();
28
27
  onEmailClick(email);
@@ -1,6 +1,7 @@
1
1
  import { FilterContext } from "../context/FilterContext.js";
2
2
  import { filterDialogViewState, filterPopoverViewState, openDialogState, openPopoverState } from "../states/filterStates.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
+ import { useMemo } from "react";
4
5
  import { useSetAtom } from "jotai";
5
6
  // src/modules/filter/components/FilterProvider.tsx
6
7
  const FilterProvider = ({ children, id }) => {
@@ -8,21 +9,27 @@ const FilterProvider = ({ children, id }) => {
8
9
  const setView = useSetAtom(filterPopoverViewState(id));
9
10
  const setDialogView = useSetAtom(filterDialogViewState(id));
10
11
  const setOpenDialog = useSetAtom(openDialogState(id));
11
- const resetFilterState = () => {
12
- setOpen(false);
13
- setView("root");
14
- setDialogView("root");
15
- setOpenDialog(false);
16
- };
17
- return /* @__PURE__ */ jsx(FilterContext.Provider, {
18
- value: {
19
- id,
20
- resetFilterState,
21
- setOpen,
22
- setView,
23
- setDialogView,
24
- setOpenDialog
12
+ const filter = useMemo(() => ({
13
+ id,
14
+ resetFilterState: () => {
15
+ setOpen(false);
16
+ setView("root");
17
+ setDialogView("root");
18
+ setOpenDialog(false);
25
19
  },
20
+ setOpen,
21
+ setView,
22
+ setDialogView,
23
+ setOpenDialog
24
+ }), [
25
+ id,
26
+ setOpen,
27
+ setView,
28
+ setDialogView,
29
+ setOpenDialog
30
+ ]);
31
+ return /* @__PURE__ */ jsx(FilterContext.Provider, {
32
+ value: filter,
26
33
  children
27
34
  });
28
35
  };
@@ -1,4 +1,5 @@
1
1
  import { Combobox } from "../../../components/combobox.js";
2
+ /** Controlled: shows `value`, and reports a pick through `onValueChange`. */
2
3
  export declare const IconPicker: ({ ref, value, onValueChange, ...props }: React.ComponentProps<typeof Combobox.TriggerBase> & {
3
4
  value?: string;
4
5
  onValueChange?: (value: string | null) => void;
@@ -6,12 +6,12 @@ import { IconComponent } from "./IconComponent.js";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { useState } from "react";
8
8
  // src/modules/icons/components/IconPicker.tsx
9
+ /** Controlled: shows `value`, and reports a pick through `onValueChange`. */
9
10
  const IconPicker = ({ ref, value, onValueChange, ...props }) => {
10
11
  const { getIcons } = useIcons();
11
- const [_value, setValue] = useState(value);
12
12
  const [open, setOpen] = useState(false);
13
13
  const icons = Object.entries(getIcons());
14
- const selectedFirst = [...icons.filter(([key]) => key === _value), ...icons.filter(([key]) => key !== _value)];
14
+ const selectedFirst = [...icons.filter(([key]) => key === value), ...icons.filter(([key]) => key !== value)];
15
15
  return /* @__PURE__ */ jsxs(Popover, {
16
16
  open,
17
17
  onOpenChange: setOpen,
@@ -20,7 +20,7 @@ const IconPicker = ({ ref, value, onValueChange, ...props }) => {
20
20
  size: "icon",
21
21
  ref,
22
22
  ...props,
23
- children: /* @__PURE__ */ jsx(IconComponent, { name: _value })
23
+ children: /* @__PURE__ */ jsx(IconComponent, { name: value })
24
24
  }), /* @__PURE__ */ jsx(Combobox.Content, {
25
25
  className: "w-60 min-w-60",
26
26
  children: /* @__PURE__ */ jsxs(Command, { children: [/* @__PURE__ */ jsx(Command.Input, { placeholder: "Search icon..." }), /* @__PURE__ */ jsx(Command.List, {
@@ -29,12 +29,11 @@ const IconPicker = ({ ref, value, onValueChange, ...props }) => {
29
29
  className: "flex flex-wrap gap-2",
30
30
  children: selectedFirst.map(([key, Icon]) => /* @__PURE__ */ jsx(Command.Item, {
31
31
  onSelect: () => {
32
- setValue(key);
33
32
  onValueChange?.(key);
34
33
  setOpen(false);
35
34
  },
36
35
  value: key,
37
- checked: _value === key,
36
+ checked: value === key,
38
37
  children: /* @__PURE__ */ jsx(Icon, {})
39
38
  }, key))
40
39
  })
@@ -4,17 +4,23 @@ import { useFullNameField } from "../hooks/useFullNameField.js";
4
4
  import { PopoverScoped } from "../../hotkey/components/PopoverScoped.js";
5
5
  import { RecordTableInlineCell } from "../../record-table/components/RecordTableCellInline.js";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
- import { useState } from "react";
7
+ import { useMemo, useState } from "react";
8
8
  // src/modules/inputs/components/FullNameField.tsx
9
9
  const FullNameFieldProvider = ({ children, firstName, lastName, setFirstName, setLastName }) => {
10
+ const name = useMemo(() => ({
11
+ firstName,
12
+ lastName,
13
+ setFirstName,
14
+ setLastName,
15
+ fullName: `${firstName || ""}${firstName ? " " : ""}${lastName || ""}`
16
+ }), [
17
+ firstName,
18
+ lastName,
19
+ setFirstName,
20
+ setLastName
21
+ ]);
10
22
  return /* @__PURE__ */ jsx(FullNameFieldContext.Provider, {
11
- value: {
12
- firstName,
13
- lastName,
14
- setFirstName,
15
- setLastName,
16
- fullName: `${firstName || ""}${firstName ? " " : ""}${lastName || ""}`
17
- },
23
+ value: name,
18
24
  children
19
25
  });
20
26
  };
@@ -4,17 +4,17 @@ import { TextOverflowTooltip } from "../../../components/text-overflow.js";
4
4
  import { PopoverScoped } from "../../hotkey/components/PopoverScoped.js";
5
5
  import { RecordTableInlineCell } from "../../record-table/components/RecordTableCellInline.js";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
- import { useState } from "react";
7
+ import { useRef, useState } from "react";
8
8
  // src/modules/record-field/components/NumberField.tsx
9
9
  const NumberField = ({ placeholder, value, scope, onSave, onValueChange, formatValue, children, ...props }) => {
10
10
  const fmt = useFormat();
11
11
  const [isOpen, setIsOpen] = useState(false);
12
12
  const [editingValue, setEditingValue] = useState(String(value));
13
- const [isEdited, setIsEdited] = useState(false);
13
+ const edited = useRef(false);
14
14
  const shown = isOpen ? editingValue : formatValue ? formatValue(value) : fmt.number(value);
15
15
  const resetEditing = () => {
16
16
  setEditingValue(String(value));
17
- setIsEdited(false);
17
+ edited.current = false;
18
18
  };
19
19
  const handleAction = (e) => {
20
20
  e?.preventDefault();
@@ -35,7 +35,7 @@ const NumberField = ({ placeholder, value, scope, onSave, onValueChange, formatV
35
35
  onOpenChange: (open) => {
36
36
  setIsOpen(open);
37
37
  if (open) resetEditing();
38
- else if (isEdited) handleAction();
38
+ else if (edited.current) handleAction();
39
39
  },
40
40
  children: [/* @__PURE__ */ jsxs(RecordTableInlineCell.Trigger, {
41
41
  ...props,
@@ -49,7 +49,7 @@ const NumberField = ({ placeholder, value, scope, onSave, onValueChange, formatV
49
49
  const rawValue = e.target.value.replace(/,/g, "");
50
50
  if (/^-?\d*\.?\d*$/.test(rawValue)) {
51
51
  setEditingValue(rawValue);
52
- setIsEdited(true);
52
+ edited.current = true;
53
53
  const numValue = Number(rawValue);
54
54
  if (!isNaN(numValue)) onValueChange?.(numValue);
55
55
  }
@@ -19,7 +19,7 @@ const TextField = ({ ref, placeholder, value, scope, onSave, onValueChange, defa
19
19
  };
20
20
  /** Submits on Enter; Escape is handled by the popover before dismissal. */
21
21
  const handleKeyDown = (e) => {
22
- if (e.key === "Enter") {
22
+ if (e.key === "Enter" && !e.nativeEvent.isComposing) {
23
23
  e.preventDefault();
24
24
  handleAction();
25
25
  }
@@ -5,7 +5,7 @@ import { tablePositionState } from "../states/RecordTableCursorState.js";
5
5
  import "../types/RecordTableCursorTypes.js";
6
6
  import { RecordTableRowSkeleton } from "./RecordTableRowSkeleton.js";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
- import { createContext, useContext, useEffect, useState } from "react";
8
+ import { createContext, useContext, useEffect, useMemo, useState } from "react";
9
9
  import { useStore } from "jotai";
10
10
  import { useDebouncedCallback } from "use-debounce";
11
11
  // src/modules/record-table/components/RecordTableCursor.tsx
@@ -52,14 +52,21 @@ const RecordTableCursorProvider = ({ children, hasPreviousPage, loading, dataLen
52
52
  sessionKey,
53
53
  store
54
54
  ]);
55
+ const cursor = useMemo(() => ({
56
+ viewport,
57
+ startBackwardFetch,
58
+ hasNextPage,
59
+ hasPreviousPage,
60
+ loading
61
+ }), [
62
+ viewport,
63
+ startBackwardFetch,
64
+ hasNextPage,
65
+ hasPreviousPage,
66
+ loading
67
+ ]);
55
68
  return /* @__PURE__ */ jsx(RecordTableCursorContext.Provider, {
56
- value: {
57
- viewport,
58
- startBackwardFetch,
59
- hasNextPage,
60
- hasPreviousPage,
61
- loading
62
- },
69
+ value: cursor,
63
70
  children: /* @__PURE__ */ jsxs(ScrollArea.Root, {
64
71
  className: "h-full w-full pb-2 pr-2 relative",
65
72
  children: [
@@ -3,7 +3,7 @@ import { readRow } from "../utils/rowFields.js";
3
3
  import { RecordTableContainer } from "./RecordTableContainer.js";
4
4
  import { RecordTableDnDProvider } from "./RecordTableDnDProvider.js";
5
5
  import { jsx } from "react/jsx-runtime";
6
- import { createContext, useContext, useId, useState } from "react";
6
+ import { createContext, useContext, useId, useMemo, useState } from "react";
7
7
  import { shallow, useSelector } from "@tanstack/react-store";
8
8
  import { columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnSizingFeature, columnVisibilityFeature, rowSelectionFeature, tableFeatures, useTable } from "@tanstack/react-table";
9
9
  // src/modules/record-table/components/RecordTableProvider.tsx
@@ -53,13 +53,18 @@ const RecordTableProvider = ({ children, columns, data, stickyColumns, tableId,
53
53
  getRowId
54
54
  }, () => null);
55
55
  const headPrefix = useId();
56
+ const context = useMemo(() => ({
57
+ table: shared,
58
+ columnSelectorOpen,
59
+ setColumnSelectorOpen,
60
+ headId: (columnId) => `${headPrefix}-head-${columnId}`
61
+ }), [
62
+ shared,
63
+ columnSelectorOpen,
64
+ headPrefix
65
+ ]);
56
66
  return /* @__PURE__ */ jsx(RecordTableContext.Provider, {
57
- value: {
58
- table: shared,
59
- columnSelectorOpen,
60
- setColumnSelectorOpen,
61
- headId: (columnId) => `${headPrefix}-head-${columnId}`
62
- },
67
+ value: context,
63
68
  children: /* @__PURE__ */ jsx(RecordTableDnDProvider, {
64
69
  setColumnOrder,
65
70
  children: /* @__PURE__ */ jsx(RecordTableContainer, {
@@ -0,0 +1,13 @@
1
+ import { ContactQueries, TContactContentType } from "./contacts.js";
2
+ /**
3
+ * A customer or company as a chip: its avatar and name. Inside erxes, clicking it opens the
4
+ * record in core's side panel beside the page; elsewhere it is only the name.
5
+ * `contacts` is `contactQueries` from `@erxes/core-contract/client`.
6
+ */
7
+ export declare const ContactLink: ({ contentType, contentId, contacts, placeholder }: {
8
+ contentType: TContactContentType;
9
+ contentId: string;
10
+ contacts: ContactQueries;
11
+ /** Shown when the record has no name, email or phone. */
12
+ placeholder?: string;
13
+ }) => import("react").JSX.Element;
@@ -0,0 +1,77 @@
1
+ import { Avatar } from "../../components/avatar.js";
2
+ import { Skeleton } from "../../components/skeleton.js";
3
+ import { cn } from "../../lib/utils.js";
4
+ import { readImage } from "../../utils/core.js";
5
+ import { companyTitle, customerTitle } from "./contacts.js";
6
+ import { useOpenRecord } from "./openRecord.js";
7
+ import { IconArrowUpRight } from "@tabler/icons-react";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { useQuery } from "@tanstack/react-query";
10
+ // src/modules/records/ContactLink.tsx
11
+ /** The customer's or company's title and avatar. */
12
+ const useContact = (contentType, contentId, contacts) => {
13
+ const isCustomer = contentType === "core:customer";
14
+ const customer = useQuery({
15
+ ...contacts.customer(contentId),
16
+ enabled: isCustomer
17
+ });
18
+ const company = useQuery({
19
+ ...contacts.company(contentId),
20
+ enabled: !isCustomer
21
+ });
22
+ if (isCustomer) return {
23
+ title: customer.data ? customerTitle(customer.data) : "",
24
+ avatarUrl: customer.data?.avatarUrl,
25
+ isPending: customer.isPending,
26
+ error: customer.error
27
+ };
28
+ return {
29
+ title: company.data ? companyTitle(company.data) : "",
30
+ avatarUrl: company.data?.avatarUrl,
31
+ isPending: company.isPending,
32
+ error: company.error
33
+ };
34
+ };
35
+ const CHIP = "group/chip inline-flex h-6 max-w-full items-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium";
36
+ /**
37
+ * A customer or company as a chip: its avatar and name. Inside erxes, clicking it opens the
38
+ * record in core's side panel beside the page; elsewhere it is only the name.
39
+ * `contacts` is `contactQueries` from `@erxes/core-contract/client`.
40
+ */
41
+ const ContactLink = ({ contentType, contentId, contacts, placeholder }) => {
42
+ const { open, canOpen } = useOpenRecord();
43
+ const contact = useContact(contentType, contentId, contacts);
44
+ if (contact.isPending) return /* @__PURE__ */ jsx(Skeleton, {
45
+ radius: "sm",
46
+ className: "h-5 w-20"
47
+ });
48
+ const name = contact.error?.message || contact.title || placeholder || (contentType === "core:customer" ? "Unnamed customer" : "Unnamed company");
49
+ const face = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Avatar, {
50
+ size: "sm",
51
+ className: "size-4 flex-none",
52
+ children: [/* @__PURE__ */ jsx(Avatar.Image, { src: readImage(contact.avatarUrl ?? void 0) }), /* @__PURE__ */ jsx(Avatar.Fallback, { children: name.charAt(0) })]
53
+ }), /* @__PURE__ */ jsx("span", {
54
+ className: cn("truncate", contact.error && "text-destructive"),
55
+ children: name
56
+ })] });
57
+ if (!canOpen) return /* @__PURE__ */ jsx("span", {
58
+ title: name,
59
+ className: CHIP,
60
+ children: face
61
+ });
62
+ return /* @__PURE__ */ jsxs("button", {
63
+ type: "button",
64
+ onClick: () => open({
65
+ contentType,
66
+ contentId
67
+ }),
68
+ title: name,
69
+ "data-panel-inline": "",
70
+ className: cn(CHIP, "hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),
71
+ children: [face, /* @__PURE__ */ jsx(IconArrowUpRight, {
72
+ className: "size-3 flex-none text-muted-foreground opacity-0 transition-opacity group-hover/chip:opacity-100 group-focus-visible/chip:opacity-100",
73
+ "aria-hidden": "true"
74
+ })]
75
+ });
76
+ };
77
+ export { ContactLink };
@@ -0,0 +1,35 @@
1
+ import { UseQueryOptions } from "@tanstack/react-query";
2
+ /** What a customer reads as: core's `Customer` has these fields and more. */
3
+ export interface CustomerContact {
4
+ id: string;
5
+ firstName: string | null;
6
+ middleName: string | null;
7
+ lastName: string | null;
8
+ primaryEmail: string | null;
9
+ primaryPhone: string | null;
10
+ avatarUrl: string | null;
11
+ }
12
+ /** What a company reads as: core's `Company` has these fields and more. */
13
+ export interface CompanyContact {
14
+ id: string;
15
+ primaryName: string | null;
16
+ primaryEmail: string | null;
17
+ primaryPhone: string | null;
18
+ avatarUrl: string | null;
19
+ }
20
+ type ContactQuery<T> = UseQueryOptions<T, Error, T>;
21
+ /**
22
+ * Where customers and companies come from, as TanStack query options. erxes-ui knows nothing
23
+ * of core: web and plugin UIs pass `contactQueries` from `@erxes/core-contract/client`.
24
+ */
25
+ export interface ContactQueries {
26
+ customer: (id: string) => ContactQuery<CustomerContact>;
27
+ company: (id: string) => ContactQuery<CompanyContact>;
28
+ }
29
+ /** The customer or company types `ContactLink` shows. */
30
+ export type TContactContentType = 'core:customer' | 'core:company';
31
+ /** A customer's name, else its email or phone. */
32
+ export declare const customerTitle: (customer: Pick<CustomerContact, 'firstName' | 'middleName' | 'lastName' | 'primaryEmail' | 'primaryPhone'>) => string;
33
+ /** A company's name, else its email or phone. */
34
+ export declare const companyTitle: (company: Pick<CompanyContact, 'primaryName' | 'primaryEmail' | 'primaryPhone'>) => string;
35
+ export {};
@@ -0,0 +1,10 @@
1
+ // src/modules/records/contacts.ts
2
+ /** A customer's name, else its email or phone. */
3
+ const customerTitle = (customer) => [
4
+ customer.firstName,
5
+ customer.middleName,
6
+ customer.lastName
7
+ ].filter(Boolean).join(" ") || customer.primaryEmail || customer.primaryPhone || "";
8
+ /** A company's name, else its email or phone. */
9
+ const companyTitle = (company) => company.primaryName || company.primaryEmail || company.primaryPhone || "";
10
+ export { companyTitle, customerTitle };
@@ -0,0 +1,25 @@
1
+ import { PropsWithChildren } from "react";
2
+ /** A record the host can open: `core:customer`, `core:company`, or a plugin's own type. */
3
+ export interface RecordRef {
4
+ contentType: string;
5
+ contentId: string;
6
+ }
7
+ type OpenRecord = (record: RecordRef) => void;
8
+ /**
9
+ * How records open, provided by the host app (web): beside the page in its side panel, or,
10
+ * inside a record, on top of that record so Back returns to it. erxes-ui is a Module
11
+ * Federation singleton, so every plugin reads the host's.
12
+ */
13
+ export declare const RecordOpenerProvider: ({ open, children }: PropsWithChildren<{
14
+ open: OpenRecord;
15
+ }>) => import("react").JSX.Element;
16
+ /**
17
+ * `const { open } = useOpenRecord(); open({ contentType: 'core:customer', contentId })` opens
18
+ * the record in core's side panel, the plugin page staying under it. `canOpen` is false
19
+ * outside erxes (a plugin page rendered on its own), where `open` does nothing.
20
+ */
21
+ export declare const useOpenRecord: () => {
22
+ open: OpenRecord;
23
+ canOpen: boolean;
24
+ };
25
+ export {};
@@ -0,0 +1,27 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createContext, use } from "react";
3
+ // src/modules/records/openRecord.tsx
4
+ const RecordOpenerContext = createContext(null);
5
+ /**
6
+ * How records open, provided by the host app (web): beside the page in its side panel, or,
7
+ * inside a record, on top of that record so Back returns to it. erxes-ui is a Module
8
+ * Federation singleton, so every plugin reads the host's.
9
+ */
10
+ const RecordOpenerProvider = ({ open, children }) => /* @__PURE__ */ jsx(RecordOpenerContext, {
11
+ value: open,
12
+ children
13
+ });
14
+ const ignore = () => void 0;
15
+ /**
16
+ * `const { open } = useOpenRecord(); open({ contentType: 'core:customer', contentId })` opens
17
+ * the record in core's side panel, the plugin page staying under it. `canOpen` is false
18
+ * outside erxes (a plugin page rendered on its own), where `open` does nothing.
19
+ */
20
+ const useOpenRecord = () => {
21
+ const open = use(RecordOpenerContext);
22
+ return {
23
+ open: open ?? ignore,
24
+ canOpen: open !== null
25
+ };
26
+ };
27
+ export { RecordOpenerProvider, useOpenRecord };
@@ -1,3 +1,4 @@
1
+ import { TContactContentType } from "../modules/records/contacts.js";
1
2
  import { Icon } from "@tabler/icons-react";
2
3
  /** A property input's own settings, stored with the custom field; each input defines its keys. */
3
4
  export type TPropertyInputMeta = Record<string, unknown>;
@@ -19,10 +20,28 @@ export type TPropertyInputProps = {
19
20
  disabled?: boolean;
20
21
  };
21
22
  export type TDashboardWidgetPreview = 'bar' | 'line' | 'area' | 'pie' | 'table' | 'list' | 'kpi' | 'heatmap' | 'progress';
23
+ /** What a record section is given: the customer or company it shows on. */
24
+ export type TRecordSectionProps = {
25
+ contentType: TContactContentType;
26
+ contentId: string;
27
+ };
28
+ /**
29
+ * A section a plugin adds to a customer's or company's detail in core's panel, under core's
30
+ * own sections: e.g. the customer's deals. One that crashes shows its error, not the panel's.
31
+ */
32
+ export type TRecordSection = {
33
+ contentType: TContactContentType;
34
+ /** The section's heading. */
35
+ title: string;
36
+ icon: React.ElementType;
37
+ component: React.ComponentType<TRecordSectionProps>;
38
+ };
22
39
  export type IUIConfig = {
23
40
  name: string;
24
41
  path: string;
25
42
  icon?: React.ElementType;
43
+ /** Sections on core's customer and company detail, shown to members who may use the plugin. */
44
+ recordSections?: TRecordSection[];
26
45
  i18n?: boolean;
27
46
  i18nNamespace?: string;
28
47
  hasFloatingWidget?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erxes/ui",
3
- "version": "4.0.0-v2.4",
3
+ "version": "4.0.0-v2.6",
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",
@@ -73,6 +73,7 @@
73
73
  "@types/node": "^26.6.6",
74
74
  "@types/react": "19.3.0",
75
75
  "@types/react-dom": "19.3.0",
76
+ "happy-dom": "21.0.4",
76
77
  "jotai": "^3.0.2",
77
78
  "nuqs": "^2.10.3",
78
79
  "react": "^19.3.1",