@erxes/ui 4.0.0-v2.5 → 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 +3 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +4 -1
- package/dist/modules/records/ContactLink.d.ts +13 -0
- package/dist/modules/records/ContactLink.js +77 -0
- package/dist/modules/records/contacts.d.ts +35 -0
- package/dist/modules/records/contacts.js +10 -0
- package/dist/modules/records/openRecord.d.ts +25 -0
- package/dist/modules/records/openRecord.js +27 -0
- package/dist/types/UIConfig.d.ts +19 -0
- package/package.json +2 -1
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`.
|
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 };
|
|
@@ -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 };
|
package/dist/types/UIConfig.d.ts
CHANGED
|
@@ -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.
|
|
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",
|