@erxes/ui 4.0.0-v2.17 → 4.0.0-v2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CATALOG.md +6 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/modules/blocks/components/BlockEditor.js +2 -2
- package/dist/modules/pickers/SelectMember.d.ts +16 -1
- package/dist/modules/pickers/SelectMember.js +56 -2
- package/dist/modules/records/ContactLink.js +9 -37
- package/dist/modules/records/ContactPicker.d.ts +36 -0
- package/dist/modules/records/ContactPicker.js +173 -0
- package/dist/modules/records/MemberLink.d.ts +12 -0
- package/dist/modules/records/MemberLink.js +25 -0
- package/dist/modules/records/RecordChip.d.ts +13 -0
- package/dist/modules/records/RecordChip.js +46 -0
- package/exports.txt +5 -0
- package/package.json +1 -1
package/CATALOG.md
CHANGED
|
@@ -64,10 +64,13 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
|
|
|
64
64
|
- `companyTitle(company)` A company's name, else its email or phone.
|
|
65
65
|
- `<ContactLink contentType contentId contacts placeholder>` A customer or company as a chip: its avatar and name.
|
|
66
66
|
- `type ContactQueries { customer, company }` Where customers and companies come from, as TanStack query options.
|
|
67
|
+
- `<ContactRelationInput {...RelationProps}>` A record's customers or companies in a side panel field.
|
|
67
68
|
- `type ContactSearch { search, ids }` What a contact search asks for: matches, or the contacts with these ids.
|
|
68
69
|
- `type ContactSearchQueries { customers, companies }` Where a filter's `customer` and `company` fields search contacts.
|
|
69
70
|
- `type CustomerContact { id, firstName, middleName, lastName, primaryEmail, … }` What a customer reads as: core's `Customer` has these fields and more.
|
|
70
71
|
- `customerTitle(customer)` A customer's name, else its email or phone.
|
|
72
|
+
- `MEMBER_CONTENT_TYPE` The content type core's side panel opens team members as.
|
|
73
|
+
- `<MemberLink memberId members>` A team member as a chip: their avatar and name.
|
|
71
74
|
- `<PanelDescriptionEditor value scope readonly isHTML onSave>` A record's description as a full-size tab.
|
|
72
75
|
- `<PanelDescriptionField label value scope readonly isHTML>` A rich-text description row in the side panel, across its width.
|
|
73
76
|
- `PanelExpansionContext` Provided by the host's record panel; erxes-ui's panel parts read it.
|
|
@@ -85,9 +88,11 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
|
|
|
85
88
|
- `type RecordRef { contentType, contentId }` A record the host can open, by `contentType` and `contentId`.
|
|
86
89
|
- `RecordTimeline` Core's timeline of notes, calls and events for a plugin's record.
|
|
87
90
|
- `type RecordTimelineProps { type, id }` Which record `RecordTimeline` shows: its timeline type and id.
|
|
91
|
+
- `<SelectContactContent kind value onValueChange contacts multiple>` A picker's searchable list of customers or companies, the picked first.
|
|
88
92
|
- `setRecordPage` Web registers how a record draws on its own page.
|
|
89
93
|
- `setRecordTimeline` Registers core's timeline; web calls it at startup and plugins don't.
|
|
90
94
|
- `type TContactContentType` The customer or company types `ContactLink` shows.
|
|
95
|
+
- `type TContactKind` Which contacts a picker lists: core's customers or its companies.
|
|
91
96
|
- `useOpenRecord()` Opens a record, or a new draft, in core's side panel.
|
|
92
97
|
- `usePanelExpanded()` Whether the record shows at full size on its own page.
|
|
93
98
|
- `useRecordPanel()` The record a slot is in, and what the slot can do to it.
|
|
@@ -116,7 +121,7 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
|
|
|
116
121
|
- `<PhoneField recordId onValueChange onValidationStatusChange primaryPhone phones>` An editable list of a record's phones, each with its own menu.
|
|
117
122
|
- `<PhoneInput value onChange defaultCountry placeholder onEnter>` A phone input with a country flag picker that formats as you type.
|
|
118
123
|
- `RelativeDateDisplay.{Value}` A date as how long ago it was, with the date and time on hover.
|
|
119
|
-
- `SelectMember` The member picker
|
|
124
|
+
- `SelectMember` The member picker: a table cell, a field, or a row opening the member.
|
|
120
125
|
- `<SexDisplay value>` A sex code as its label, or nothing when it is not known.
|
|
121
126
|
- `<SexField value onValueChange>` A searchable list to pick a sex code, for a popover or cell editor.
|
|
122
127
|
- `type Tag { id, name }` A tag as the pickers show one: core's `Tag` has these fields and more.
|
package/dist/index.d.ts
CHANGED
|
@@ -116,6 +116,8 @@ import { PanelLabel } from "./modules/record-panel/PanelLabel.js";
|
|
|
116
116
|
import { PanelSection } from "./modules/record-panel/PanelSection.js";
|
|
117
117
|
import { PanelExpansionContext, usePanelExpanded } from "./modules/record-panel/panelExpansion.js";
|
|
118
118
|
import { ContactLink } from "./modules/records/ContactLink.js";
|
|
119
|
+
import { ContactRelationInput, SelectContactContent, TContactKind } from "./modules/records/ContactPicker.js";
|
|
120
|
+
import { MEMBER_CONTENT_TYPE, MemberLink } from "./modules/records/MemberLink.js";
|
|
119
121
|
import { CompanyContact, ContactQueries, ContactSearch, ContactSearchQueries, CustomerContact, TContactContentType, companyTitle, customerTitle } from "./modules/records/contacts.js";
|
|
120
122
|
import { RecordOpenerProvider, RecordPage, RecordPageProps, RecordPanelControls, RecordPanelProvider, RecordRef, setRecordPage, useOpenRecord, useRecordPanel } from "./modules/records/openRecord.js";
|
|
121
123
|
import { ThemeOption, themeState } from "./state/themeState.js";
|
|
@@ -130,4 +132,4 @@ import { jsonOf } from "./utils/json.js";
|
|
|
130
132
|
import { PluginLiveMessage, PluginRuntime, PluginSession, getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
|
|
131
133
|
import { addPluginStyles } from "./utils/plugin-styles.js";
|
|
132
134
|
import { RecordTimeline, RecordTimelineProps, setRecordTimeline } from "./utils/record-timeline.js";
|
|
133
|
-
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, ConditionsEditor, ContactLink, type ContactQueries, type ContactSearch, type ContactSearchQueries, ContextMenu, CopyText, type CustomerContact, DASHBOARD_WIDGET_PREVIEWS, DateInput, DatePicker, Dialog, DisplayMenu, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, type FileStorageAdapter, Filter, Form, FullNameField, FullNameValue, HoverCard, type IUIConfig, IconComponent, IconPicker, IconTip, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, ListFilter, ListFilterEmpty, ListViewsProvider, LookupPicker, type Member, MemberInline, type MemberQueries, type MultiSelectOption, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PanelDescriptionEditor, PanelDescriptionField, PanelExpansionContext, PanelField, PanelFieldTrigger, PanelFormLayout, PanelFormRow, PanelLabel, PanelSection, PhoneDisplay, PhoneField, PhoneInput, type PluginLiveMessage, type PluginRuntime, type PluginSession, Popover, PopoverScoped, RadioGroup, RecordList, type RecordListGroup, RecordOpenerProvider, RecordPage, type RecordPageProps, type RecordPanelControls, RecordPanelProvider, 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 TConditionField, type TConditionGroup, type TConditionLookups, type TConditionRule, type TContactContentType, type TDashboardWidget, type TDashboardWidgetPreview, type TListDisplay, type TListDisplayOption, type TListFilterField, type TListFilterProps, type TListViews, type TPanelRecordType, type TPluginListType, type TPluginSettingsPage, type TPropertyValue, type TRecordContacts, type TRecordDraftProps, type TRecordProperties, type TRecordSection, type TRecordSectionProps, type TRecordSlotProps, type TRecordTab, type TRecordTableSort, type TRelationTab, type TRelationTabProps, type TViewTabsProps, TabButton, Table, Tabs, type Tag, type TagsQuery, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, ViewBar, addPluginStyles, amountStep, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatMoney, formatPhoneNumber, formatter, fromAmountInput, getPluginAssetsUrl, getPluginRuntime, isRule, isUndefinedOrNull, jsonOf, listFilterQuery, localTimeZone, memberName, oneOf, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordPage, setRecordTimeline, stored, storedFamily, textOf, themeState, toAmountInput, toIsoDay, toast, useConfirm, useFieldControl, useFilterContext, useFocusFirstField, useFormat, useItemKeys, useListDisplay, useListFilterParams, useListViews, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useRecordPanel, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
|
|
135
|
+
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, ConditionsEditor, ContactLink, type ContactQueries, ContactRelationInput, type ContactSearch, type ContactSearchQueries, ContextMenu, CopyText, type CustomerContact, DASHBOARD_WIDGET_PREVIEWS, DateInput, DatePicker, Dialog, DisplayMenu, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, type FileStorageAdapter, Filter, Form, FullNameField, FullNameValue, HoverCard, type IUIConfig, IconComponent, IconPicker, IconTip, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, ListFilter, ListFilterEmpty, ListViewsProvider, LookupPicker, MEMBER_CONTENT_TYPE, type Member, MemberInline, MemberLink, type MemberQueries, type MultiSelectOption, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PanelDescriptionEditor, PanelDescriptionField, PanelExpansionContext, PanelField, PanelFieldTrigger, PanelFormLayout, PanelFormRow, PanelLabel, PanelSection, PhoneDisplay, PhoneField, PhoneInput, type PluginLiveMessage, type PluginRuntime, type PluginSession, Popover, PopoverScoped, RadioGroup, RecordList, type RecordListGroup, RecordOpenerProvider, RecordPage, type RecordPageProps, type RecordPanelControls, RecordPanelProvider, type RecordRef, RecordTable, type RecordTableColumnDef, RecordTableInlineCell, RecordTimeline, type RecordTimelineProps, RelativeDateDisplay, Resizable, ScrollArea, Select, SelectContactContent, SelectMember, Separator, SexCode, SexDisplay, SexField, Sheet, Sidebar, Skeleton, Slider, Spinner, StringArrayInput, Switch, type TConditionField, type TConditionGroup, type TConditionLookups, type TConditionRule, type TContactContentType, type TContactKind, type TDashboardWidget, type TDashboardWidgetPreview, type TListDisplay, type TListDisplayOption, type TListFilterField, type TListFilterProps, type TListViews, type TPanelRecordType, type TPluginListType, type TPluginSettingsPage, type TPropertyValue, type TRecordContacts, type TRecordDraftProps, type TRecordProperties, type TRecordSection, type TRecordSectionProps, type TRecordSlotProps, type TRecordTab, type TRecordTableSort, type TRelationTab, type TRelationTabProps, type TViewTabsProps, TabButton, Table, Tabs, type Tag, type TagsQuery, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, ViewBar, addPluginStyles, amountStep, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatMoney, formatPhoneNumber, formatter, fromAmountInput, getPluginAssetsUrl, getPluginRuntime, isRule, isUndefinedOrNull, jsonOf, listFilterQuery, localTimeZone, memberName, oneOf, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordPage, setRecordTimeline, stored, storedFamily, textOf, themeState, toAmountInput, toIsoDay, toast, useConfirm, useFieldControl, useFilterContext, useFocusFirstField, useFormat, useItemKeys, useListDisplay, useListFilterParams, useListViews, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useRecordPanel, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
|
package/dist/index.js
CHANGED
|
@@ -112,6 +112,8 @@ import { PanelLabel } from "./modules/record-panel/PanelLabel.js";
|
|
|
112
112
|
import { PanelSection } from "./modules/record-panel/PanelSection.js";
|
|
113
113
|
import { PanelExpansionContext, usePanelExpanded } from "./modules/record-panel/panelExpansion.js";
|
|
114
114
|
import { ContactLink } from "./modules/records/ContactLink.js";
|
|
115
|
+
import { ContactRelationInput, SelectContactContent } from "./modules/records/ContactPicker.js";
|
|
116
|
+
import { MEMBER_CONTENT_TYPE, MemberLink } from "./modules/records/MemberLink.js";
|
|
115
117
|
import { companyTitle, customerTitle } from "./modules/records/contacts.js";
|
|
116
118
|
import { RecordOpenerProvider, RecordPage, RecordPanelProvider, setRecordPage, useOpenRecord, useRecordPanel } from "./modules/records/openRecord.js";
|
|
117
119
|
import { ThemeOption, themeState } from "./state/themeState.js";
|
|
@@ -126,4 +128,4 @@ import { jsonOf } from "./utils/json.js";
|
|
|
126
128
|
import { getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
|
|
127
129
|
import { addPluginStyles } from "./utils/plugin-styles.js";
|
|
128
130
|
import { RecordTimeline, setRecordTimeline } from "./utils/record-timeline.js";
|
|
129
|
-
export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, BackgroundGradientAnimation, Badge, Breadcrumb, Button, Calendar, Card, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, ConditionsEditor, ContactLink, ContextMenu, CopyText, DASHBOARD_WIDGET_PREVIEWS, DateInput, DatePicker, Dialog, DisplayMenu, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, Filter, Form, FullNameField, FullNameValue, HoverCard, IconComponent, IconPicker, IconTip, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, ListFilter, ListFilterEmpty, ListViewsProvider, LookupPicker, MemberInline, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PanelDescriptionEditor, PanelDescriptionField, PanelExpansionContext, PanelField, PanelFieldTrigger, PanelFormLayout, PanelFormRow, PanelLabel, PanelSection, PhoneDisplay, PhoneField, PhoneInput, Popover, PopoverScoped, RadioGroup, RecordList, RecordOpenerProvider, RecordPage, RecordPanelProvider, 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, ViewBar, addPluginStyles, amountStep, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatMoney, formatPhoneNumber, formatter, fromAmountInput, getPluginAssetsUrl, getPluginRuntime, isRule, isUndefinedOrNull, jsonOf, listFilterQuery, localTimeZone, memberName, oneOf, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordPage, setRecordTimeline, stored, storedFamily, textOf, themeState, toAmountInput, toIsoDay, toast, useConfirm, useFieldControl, useFilterContext, useFocusFirstField, useFormat, useItemKeys, useListDisplay, useListFilterParams, useListViews, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useRecordPanel, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
|
|
131
|
+
export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, BackgroundGradientAnimation, Badge, Breadcrumb, Button, Calendar, Card, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, ConditionsEditor, ContactLink, ContactRelationInput, ContextMenu, CopyText, DASHBOARD_WIDGET_PREVIEWS, DateInput, DatePicker, Dialog, DisplayMenu, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, Filter, Form, FullNameField, FullNameValue, HoverCard, IconComponent, IconPicker, IconTip, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, ListFilter, ListFilterEmpty, ListViewsProvider, LookupPicker, MEMBER_CONTENT_TYPE, MemberInline, MemberLink, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PanelDescriptionEditor, PanelDescriptionField, PanelExpansionContext, PanelField, PanelFieldTrigger, PanelFormLayout, PanelFormRow, PanelLabel, PanelSection, PhoneDisplay, PhoneField, PhoneInput, Popover, PopoverScoped, RadioGroup, RecordList, RecordOpenerProvider, RecordPage, RecordPanelProvider, RecordTable, RecordTableInlineCell, RecordTimeline, RelativeDateDisplay, Resizable, ScrollArea, Select, SelectContactContent, 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, ViewBar, addPluginStyles, amountStep, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatMoney, formatPhoneNumber, formatter, fromAmountInput, getPluginAssetsUrl, getPluginRuntime, isRule, isUndefinedOrNull, jsonOf, listFilterQuery, localTimeZone, memberName, oneOf, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordPage, setRecordTimeline, stored, storedFamily, textOf, themeState, toAmountInput, toIsoDay, toast, useConfirm, useFieldControl, useFilterContext, useFocusFirstField, useFormat, useItemKeys, useListDisplay, useListFilterParams, useListViews, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useRecordPanel, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
|
|
@@ -17,8 +17,8 @@ import { BlockNoteView } from "@blocknote/shadcn";
|
|
|
17
17
|
const blockEditorVariants = cva("erxes-blocknote transition", {
|
|
18
18
|
variants: { variant: {
|
|
19
19
|
default: "",
|
|
20
|
-
outline: "rounded-md pt-1 styled-scroll shadow-xs data-focused:shadow-focus",
|
|
21
|
-
ghost: "rounded-sm pt-1 styled-scroll hover:bg-accent focus-within:bg-background focus-within:shadow-focus"
|
|
20
|
+
outline: "rounded-md pt-1 text-sm styled-scroll shadow-xs data-focused:shadow-focus",
|
|
21
|
+
ghost: "rounded-sm pt-1 text-sm styled-scroll hover:bg-accent focus-within:bg-background focus-within:shadow-focus"
|
|
22
22
|
} },
|
|
23
23
|
defaultVariants: { variant: "default" }
|
|
24
24
|
});
|
|
@@ -33,9 +33,24 @@ declare const SelectMemberInlineCell: ({ ref, value, onValueChange, members, non
|
|
|
33
33
|
} & RefAttributes<ComponentRef<typeof RecordTableInlineCell.Trigger>>) => import("react").JSX.Element;
|
|
34
34
|
/** A member picker button; its other props (an id, `Form.Control`'s aria wiring) go to the button. */
|
|
35
35
|
declare const SelectMemberField: ({ value, onValueChange, members, noneLabel, placeholder, className, ...trigger }: SelectMemberProps & Omit<ComponentProps<typeof Combobox.Trigger>, 'value' | 'children' | 'placeholder'>) => import("react").JSX.Element;
|
|
36
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* A record panel's member row: the member as a chip that opens them in core's side panel, and a
|
|
38
|
+
* button, shown on hover, to pick another; with none, "+ Add". Read-only without `onValueChange`.
|
|
39
|
+
*/
|
|
40
|
+
declare const SelectMemberLinked: ({ value, onValueChange, members, noneLabel, scope, addLabel, changeLabel, emptyLabel }: Omit<SelectMemberProps, 'onValueChange' | 'placeholder'> & {
|
|
41
|
+
onValueChange?: (id: string | null) => void;
|
|
42
|
+
scope?: string;
|
|
43
|
+
/** The button's words while no member is picked. */
|
|
44
|
+
addLabel?: string;
|
|
45
|
+
/** The hover button's name for screen readers once one is. */
|
|
46
|
+
changeLabel?: string;
|
|
47
|
+
/** Read-only and empty. */
|
|
48
|
+
emptyLabel?: string;
|
|
49
|
+
}) => import("react").JSX.Element;
|
|
50
|
+
/** The member picker: a table cell, a field, or a row opening the member. */
|
|
37
51
|
export declare const SelectMember: {
|
|
38
52
|
InlineCell: typeof SelectMemberInlineCell;
|
|
39
53
|
Field: typeof SelectMemberField;
|
|
54
|
+
Linked: typeof SelectMemberLinked;
|
|
40
55
|
};
|
|
41
56
|
export {};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Avatar } from "../../components/avatar.js";
|
|
2
2
|
import { Badge } from "../../components/badge.js";
|
|
3
|
+
import { Button } from "../../components/button.js";
|
|
3
4
|
import { Combobox } from "../../components/combobox.js";
|
|
4
5
|
import { Popover } from "../../components/popover.js";
|
|
5
6
|
import { cn } from "../../lib/utils.js";
|
|
6
7
|
import { readImage } from "../../utils/core.js";
|
|
7
8
|
import { PopoverScoped } from "../hotkey/components/PopoverScoped.js";
|
|
8
9
|
import { RecordTableInlineCell } from "../record-table/components/RecordTableCellInline.js";
|
|
10
|
+
import { MemberLink } from "../records/MemberLink.js";
|
|
9
11
|
import { EntityPicker } from "./EntityPicker.js";
|
|
10
12
|
import { memberName, useMembersById } from "./members.js";
|
|
13
|
+
import { IconPlus } from "@tabler/icons-react";
|
|
11
14
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
15
|
import { useState } from "react";
|
|
13
16
|
import { useQuery } from "@tanstack/react-query";
|
|
@@ -114,9 +117,60 @@ const SelectMemberField = ({ value, onValueChange, members, noneLabel, placehold
|
|
|
114
117
|
}) })]
|
|
115
118
|
});
|
|
116
119
|
};
|
|
117
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* A record panel's member row: the member as a chip that opens them in core's side panel, and a
|
|
122
|
+
* button, shown on hover, to pick another; with none, "+ Add". Read-only without `onValueChange`.
|
|
123
|
+
*/
|
|
124
|
+
const SelectMemberLinked = ({ value, onValueChange, members, noneLabel, scope, addLabel = "Add", changeLabel = "Change", emptyLabel = "Not specified" }) => {
|
|
125
|
+
const [open, setOpen] = useState(false);
|
|
126
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
127
|
+
className: "group/relations flex min-h-7 min-w-0 items-center gap-1 px-1",
|
|
128
|
+
children: [
|
|
129
|
+
value && /* @__PURE__ */ jsx("div", {
|
|
130
|
+
className: "flex min-w-0 overflow-hidden",
|
|
131
|
+
children: /* @__PURE__ */ jsx(MemberLink, {
|
|
132
|
+
memberId: value,
|
|
133
|
+
members
|
|
134
|
+
})
|
|
135
|
+
}),
|
|
136
|
+
!value && !onValueChange && /* @__PURE__ */ jsx("span", {
|
|
137
|
+
className: "px-1 text-xs text-muted-foreground",
|
|
138
|
+
children: emptyLabel
|
|
139
|
+
}),
|
|
140
|
+
onValueChange && /* @__PURE__ */ jsxs(PopoverScoped, {
|
|
141
|
+
scope,
|
|
142
|
+
open,
|
|
143
|
+
onOpenChange: setOpen,
|
|
144
|
+
children: [/* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
145
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
146
|
+
variant: "ghost",
|
|
147
|
+
size: "xs",
|
|
148
|
+
tone: "muted",
|
|
149
|
+
"data-panel-inline": "",
|
|
150
|
+
"aria-label": value ? changeLabel : addLabel,
|
|
151
|
+
className: cn("shrink-0 [&>svg]:size-3.5", value && "opacity-0 group-hover/relations:opacity-100 focus-visible:opacity-100 data-popup-open:opacity-100")
|
|
152
|
+
}),
|
|
153
|
+
children: [/* @__PURE__ */ jsx(IconPlus, { "aria-hidden": "true" }), !value && /* @__PURE__ */ jsx("span", {
|
|
154
|
+
className: "font-normal",
|
|
155
|
+
children: addLabel
|
|
156
|
+
})]
|
|
157
|
+
}), /* @__PURE__ */ jsx(Combobox.Content, { children: /* @__PURE__ */ jsx(MemberList, {
|
|
158
|
+
value,
|
|
159
|
+
members,
|
|
160
|
+
noneLabel,
|
|
161
|
+
onPick: (next) => {
|
|
162
|
+
onValueChange(next);
|
|
163
|
+
setOpen(false);
|
|
164
|
+
}
|
|
165
|
+
}) })]
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
/** The member picker: a table cell, a field, or a row opening the member. */
|
|
118
171
|
const SelectMember = {
|
|
119
172
|
InlineCell: SelectMemberInlineCell,
|
|
120
|
-
Field: SelectMemberField
|
|
173
|
+
Field: SelectMemberField,
|
|
174
|
+
Linked: SelectMemberLinked
|
|
121
175
|
};
|
|
122
176
|
export { MemberInline, SelectMember };
|
|
@@ -1,11 +1,6 @@
|
|
|
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
1
|
import { companyTitle, customerTitle } from "./contacts.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RecordChip } from "./RecordChip.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
4
|
import { useQuery } from "@tanstack/react-query";
|
|
10
5
|
// src/modules/records/ContactLink.tsx
|
|
11
6
|
/** The customer's or company's title and avatar. */
|
|
@@ -32,46 +27,23 @@ const useContact = (contentType, contentId, contacts) => {
|
|
|
32
27
|
error: company.error
|
|
33
28
|
};
|
|
34
29
|
};
|
|
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
30
|
/**
|
|
37
31
|
* A customer or company as a chip: its avatar and name. Inside erxes, clicking it opens the
|
|
38
32
|
* record in core's side panel beside the page; elsewhere it is only the name.
|
|
39
33
|
* `contacts` is `contactQueries` from `@erxes/core-contract/client`.
|
|
40
34
|
*/
|
|
41
35
|
const ContactLink = ({ contentType, contentId, contacts, placeholder }) => {
|
|
42
|
-
const { open, canOpen } = useOpenRecord();
|
|
43
36
|
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
37
|
const name = contact.error?.message || contact.title || placeholder || (contentType === "core:customer" ? "Unnamed customer" : "Unnamed company");
|
|
49
|
-
|
|
50
|
-
|
|
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({
|
|
38
|
+
return /* @__PURE__ */ jsx(RecordChip, {
|
|
39
|
+
record: {
|
|
65
40
|
contentType,
|
|
66
41
|
contentId
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
})]
|
|
42
|
+
},
|
|
43
|
+
name,
|
|
44
|
+
avatarUrl: contact.avatarUrl,
|
|
45
|
+
loading: contact.isPending,
|
|
46
|
+
failed: Boolean(contact.error)
|
|
75
47
|
});
|
|
76
48
|
};
|
|
77
49
|
export { ContactLink };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ContactQueries, ContactSearchQueries } from "./contacts.js";
|
|
2
|
+
/** Which contacts a picker lists: core's customers or its companies. */
|
|
3
|
+
export type TContactKind = 'customer' | 'company';
|
|
4
|
+
/**
|
|
5
|
+
* A picker's searchable list of customers or companies, the picked first.
|
|
6
|
+
* Searched on the server; `contacts` is `contactSearchQueries` from
|
|
7
|
+
* `@erxes/core-contract/client`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SelectContactContent: ({ kind, value, onValueChange, contacts, multiple, noneLabel }: {
|
|
10
|
+
kind: TContactKind;
|
|
11
|
+
value: string[];
|
|
12
|
+
onValueChange: (ids: string[]) => void;
|
|
13
|
+
contacts: ContactSearchQueries;
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
noneLabel?: string;
|
|
16
|
+
}) => import("react").JSX.Element;
|
|
17
|
+
type RelationProps = {
|
|
18
|
+
kind: TContactKind;
|
|
19
|
+
value: string[];
|
|
20
|
+
/** Picks several unless `multiple` is false; then a pick replaces the one linked. */
|
|
21
|
+
onValueChange?: (ids: string[]) => void;
|
|
22
|
+
/** `contactQueries` and `contactSearchQueries` from `@erxes/core-contract/client`. */
|
|
23
|
+
contacts: ContactQueries;
|
|
24
|
+
contactSearch: ContactSearchQueries;
|
|
25
|
+
multiple?: boolean;
|
|
26
|
+
scope: string;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* A record's customers or companies in a side panel field.
|
|
31
|
+
* Put it in a `cell={false}` field. The first shows as a chip, then a muted button adds, changes, or shows the rest
|
|
32
|
+
* (`+N`). Without `onValueChange` it only shows them. Core's panels and plugin
|
|
33
|
+
* records draw contacts with it.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ContactRelationInput: (props: RelationProps) => import("react").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Avatar } from "../../components/avatar.js";
|
|
2
|
+
import { Button } from "../../components/button.js";
|
|
3
|
+
import { Combobox } from "../../components/combobox.js";
|
|
4
|
+
import { Popover } from "../../components/popover.js";
|
|
5
|
+
import { Spinner } from "../../components/spinner.js";
|
|
6
|
+
import { cn } from "../../lib/utils.js";
|
|
7
|
+
import { readImage } from "../../utils/core.js";
|
|
8
|
+
import { PopoverScoped } from "../hotkey/components/PopoverScoped.js";
|
|
9
|
+
import { EntityPicker } from "../pickers/EntityPicker.js";
|
|
10
|
+
import { ContactLink } from "./ContactLink.js";
|
|
11
|
+
import { companyTitle, customerTitle } from "./contacts.js";
|
|
12
|
+
import { IconPlus } from "@tabler/icons-react";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { useTranslation } from "react-i18next";
|
|
16
|
+
import { useQuery } from "@tanstack/react-query";
|
|
17
|
+
import { useDebounce } from "use-debounce";
|
|
18
|
+
// src/modules/records/ContactPicker.tsx
|
|
19
|
+
/** Up to 20 customers or companies: those matching `search`, or the ones with `ids`. */
|
|
20
|
+
const useContactRows = (contacts, kind, { search, ids }) => {
|
|
21
|
+
const input = {
|
|
22
|
+
search: search || void 0,
|
|
23
|
+
ids
|
|
24
|
+
};
|
|
25
|
+
const enabled = !ids || ids.length > 0;
|
|
26
|
+
const customers = useQuery({
|
|
27
|
+
...contacts.customers(input),
|
|
28
|
+
enabled: enabled && kind === "customer",
|
|
29
|
+
placeholderData: (previous) => previous
|
|
30
|
+
});
|
|
31
|
+
const companies = useQuery({
|
|
32
|
+
...contacts.companies(input),
|
|
33
|
+
enabled: enabled && kind === "company",
|
|
34
|
+
placeholderData: (previous) => previous
|
|
35
|
+
});
|
|
36
|
+
if (kind === "customer") return {
|
|
37
|
+
data: customers.data?.data.map((customer) => ({
|
|
38
|
+
id: customer.id,
|
|
39
|
+
name: customerTitle(customer),
|
|
40
|
+
avatarUrl: customer.avatarUrl
|
|
41
|
+
})),
|
|
42
|
+
isPending: customers.isPending,
|
|
43
|
+
error: customers.error
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
data: companies.data?.data.map((company) => ({
|
|
47
|
+
id: company.id,
|
|
48
|
+
name: companyTitle(company),
|
|
49
|
+
avatarUrl: company.avatarUrl
|
|
50
|
+
})),
|
|
51
|
+
isPending: companies.isPending,
|
|
52
|
+
error: companies.error
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* A picker's searchable list of customers or companies, the picked first.
|
|
57
|
+
* Searched on the server; `contacts` is `contactSearchQueries` from
|
|
58
|
+
* `@erxes/core-contract/client`.
|
|
59
|
+
*/
|
|
60
|
+
const SelectContactContent = ({ kind, value, onValueChange, contacts, multiple = true, noneLabel }) => {
|
|
61
|
+
const [search, setSearch] = useState("");
|
|
62
|
+
const [debounced] = useDebounce(search.trim(), 500);
|
|
63
|
+
const placeholder = kind === "customer" ? "Unnamed customer" : "Unnamed company";
|
|
64
|
+
const selected = useContactRows(contacts, kind, { ids: value });
|
|
65
|
+
const matches = useContactRows(contacts, kind, { search: debounced });
|
|
66
|
+
const found = matches.data ?? [];
|
|
67
|
+
const items = [...(selected.data ?? []).filter((option) => value.includes(option.id) && !found.some((match) => match.id === option.id)), ...found];
|
|
68
|
+
return /* @__PURE__ */ jsx(EntityPicker, {
|
|
69
|
+
multiple,
|
|
70
|
+
noneLabel,
|
|
71
|
+
items,
|
|
72
|
+
itemKey: (option) => ({
|
|
73
|
+
id: option.id,
|
|
74
|
+
label: option.name
|
|
75
|
+
}),
|
|
76
|
+
renderItem: (option) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Avatar, { children: [/* @__PURE__ */ jsx(Avatar.Image, { src: readImage(option.avatarUrl ?? void 0) }), /* @__PURE__ */ jsx(Avatar.Fallback, { children: option.name.charAt(0) })] }), /* @__PURE__ */ jsx(Combobox.Value, {
|
|
77
|
+
value: option.name,
|
|
78
|
+
placeholder
|
|
79
|
+
})] }),
|
|
80
|
+
value,
|
|
81
|
+
onValueChange,
|
|
82
|
+
onSearchChange: setSearch,
|
|
83
|
+
loading: matches.isPending,
|
|
84
|
+
error: matches.error ?? selected.error
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const ContactRelationTriggerLabel = ({ saving, moreCount, hasLinks, addLabel }) => {
|
|
88
|
+
if (saving) return /* @__PURE__ */ jsx(Spinner, { size: "sm" });
|
|
89
|
+
if (moreCount > 0) return /* @__PURE__ */ jsxs("span", {
|
|
90
|
+
className: "font-normal",
|
|
91
|
+
children: ["+", moreCount]
|
|
92
|
+
});
|
|
93
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(IconPlus, { "aria-hidden": "true" }), !hasLinks && /* @__PURE__ */ jsx("span", {
|
|
94
|
+
className: "font-normal",
|
|
95
|
+
children: addLabel
|
|
96
|
+
})] });
|
|
97
|
+
};
|
|
98
|
+
/** The button after the first chip: `+N` more, or add, opening the picker. */
|
|
99
|
+
const ContactRelationPopover = ({ kind, value, contacts, contactSearch, multiple = true, scope, disabled = false, onValueChange }) => {
|
|
100
|
+
const { t } = useTranslation("common", { keyPrefix: "side-panel" });
|
|
101
|
+
const [open, setOpen] = useState(false);
|
|
102
|
+
const hasLinks = value.length > 0;
|
|
103
|
+
const moreCount = Math.max(0, value.length - 1);
|
|
104
|
+
const addLabel = kind === "company" ? t("add-company", "Add company") : t("add-customer", "Add customer");
|
|
105
|
+
const editLabel = kind === "company" ? t("edit-companies", "Edit companies") : t("edit-customers", "Edit customers");
|
|
106
|
+
return /* @__PURE__ */ jsxs(PopoverScoped, {
|
|
107
|
+
scope,
|
|
108
|
+
open,
|
|
109
|
+
onOpenChange: setOpen,
|
|
110
|
+
children: [/* @__PURE__ */ jsx(Popover.Trigger, {
|
|
111
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
112
|
+
variant: moreCount > 0 ? "secondary" : "ghost",
|
|
113
|
+
size: "xs",
|
|
114
|
+
tone: "muted",
|
|
115
|
+
"data-panel-inline": "",
|
|
116
|
+
disabled,
|
|
117
|
+
"aria-label": hasLinks ? editLabel : addLabel,
|
|
118
|
+
className: cn("shrink-0 [&>svg]:size-3.5", hasLinks && !moreCount && "opacity-0 group-hover/relations:opacity-100 focus-visible:opacity-100 data-popup-open:opacity-100")
|
|
119
|
+
}),
|
|
120
|
+
children: /* @__PURE__ */ jsx(ContactRelationTriggerLabel, {
|
|
121
|
+
saving: disabled,
|
|
122
|
+
moreCount,
|
|
123
|
+
hasLinks,
|
|
124
|
+
addLabel
|
|
125
|
+
})
|
|
126
|
+
}), /* @__PURE__ */ jsx(Combobox.Content, { children: onValueChange ? /* @__PURE__ */ jsx(SelectContactContent, {
|
|
127
|
+
kind,
|
|
128
|
+
value,
|
|
129
|
+
contacts: contactSearch,
|
|
130
|
+
multiple,
|
|
131
|
+
onValueChange: (ids) => {
|
|
132
|
+
if (disabled) return;
|
|
133
|
+
onValueChange(ids);
|
|
134
|
+
if (!multiple) setOpen(false);
|
|
135
|
+
}
|
|
136
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: "flex flex-col items-start gap-1 p-2",
|
|
138
|
+
children: value.map((id) => /* @__PURE__ */ jsx(ContactLink, {
|
|
139
|
+
contentType: kind === "company" ? "core:company" : "core:customer",
|
|
140
|
+
contentId: id,
|
|
141
|
+
contacts
|
|
142
|
+
}, id))
|
|
143
|
+
}) })]
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* A record's customers or companies in a side panel field.
|
|
148
|
+
* Put it in a `cell={false}` field. The first shows as a chip, then a muted button adds, changes, or shows the rest
|
|
149
|
+
* (`+N`). Without `onValueChange` it only shows them. Core's panels and plugin
|
|
150
|
+
* records draw contacts with it.
|
|
151
|
+
*/
|
|
152
|
+
const ContactRelationInput = (props) => {
|
|
153
|
+
const { kind, value, contacts, onValueChange } = props;
|
|
154
|
+
const { t } = useTranslation("common", { keyPrefix: "side-panel" });
|
|
155
|
+
let control = null;
|
|
156
|
+
if (onValueChange || value.length > 1) control = /* @__PURE__ */ jsx(ContactRelationPopover, { ...props });
|
|
157
|
+
else if (!value.length) control = /* @__PURE__ */ jsx("span", {
|
|
158
|
+
className: "px-1 text-xs text-muted-foreground",
|
|
159
|
+
children: t("not-specified", "Not specified")
|
|
160
|
+
});
|
|
161
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
162
|
+
className: "group/relations flex min-h-7 min-w-0 items-center gap-1 px-1",
|
|
163
|
+
children: [value.slice(0, 1).map((id) => /* @__PURE__ */ jsx("div", {
|
|
164
|
+
className: "flex min-w-0 overflow-hidden",
|
|
165
|
+
children: /* @__PURE__ */ jsx(ContactLink, {
|
|
166
|
+
contentType: kind === "company" ? "core:company" : "core:customer",
|
|
167
|
+
contentId: id,
|
|
168
|
+
contacts
|
|
169
|
+
})
|
|
170
|
+
}, id)), control]
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
export { ContactRelationInput, SelectContactContent };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MemberQueries } from "../pickers/members.js";
|
|
2
|
+
/** The content type core's side panel opens team members as. */
|
|
3
|
+
export declare const MEMBER_CONTENT_TYPE = "core:user";
|
|
4
|
+
/**
|
|
5
|
+
* A team member as a chip: their avatar and name. Inside erxes, clicking it opens the member in
|
|
6
|
+
* core's side panel beside the page (their detail and what they did); elsewhere it is only
|
|
7
|
+
* the name. `members` is `memberQueries` from `@erxes/core-contract/client`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MemberLink: ({ memberId, members }: {
|
|
10
|
+
memberId: string;
|
|
11
|
+
members: MemberQueries;
|
|
12
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { memberName, useMembersById } from "../pickers/members.js";
|
|
2
|
+
import { RecordChip } from "./RecordChip.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/modules/records/MemberLink.tsx
|
|
5
|
+
/** The content type core's side panel opens team members as. */
|
|
6
|
+
const MEMBER_CONTENT_TYPE = "core:user";
|
|
7
|
+
/**
|
|
8
|
+
* A team member as a chip: their avatar and name. Inside erxes, clicking it opens the member in
|
|
9
|
+
* core's side panel beside the page (their detail and what they did); elsewhere it is only
|
|
10
|
+
* the name. `members` is `memberQueries` from `@erxes/core-contract/client`.
|
|
11
|
+
*/
|
|
12
|
+
const MemberLink = ({ memberId, members }) => {
|
|
13
|
+
const member = useMembersById([memberId], members).get(memberId);
|
|
14
|
+
return /* @__PURE__ */ jsx(RecordChip, {
|
|
15
|
+
record: {
|
|
16
|
+
contentType: MEMBER_CONTENT_TYPE,
|
|
17
|
+
contentId: memberId
|
|
18
|
+
},
|
|
19
|
+
name: member ? memberName(member) : "",
|
|
20
|
+
avatarUrl: member?.avatarUrl,
|
|
21
|
+
loading: !member,
|
|
22
|
+
failed: false
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export { MEMBER_CONTENT_TYPE, MemberLink };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RecordRef } from "./openRecord.js";
|
|
2
|
+
/**
|
|
3
|
+
* A record as a chip: its avatar and name. Inside erxes, clicking it opens the record in core's
|
|
4
|
+
* side panel beside the page; elsewhere it is only the name. A record that can't be read says
|
|
5
|
+
* why, and still opens to show it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RecordChip: ({ record, name, avatarUrl, loading, failed }: {
|
|
8
|
+
record: RecordRef;
|
|
9
|
+
name: string;
|
|
10
|
+
avatarUrl: string | null | undefined;
|
|
11
|
+
loading: boolean;
|
|
12
|
+
failed: boolean;
|
|
13
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { useOpenRecord } from "./openRecord.js";
|
|
6
|
+
import { IconArrowUpRight } from "@tabler/icons-react";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/modules/records/RecordChip.tsx
|
|
9
|
+
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";
|
|
10
|
+
/**
|
|
11
|
+
* A record as a chip: its avatar and name. Inside erxes, clicking it opens the record in core's
|
|
12
|
+
* side panel beside the page; elsewhere it is only the name. A record that can't be read says
|
|
13
|
+
* why, and still opens to show it.
|
|
14
|
+
*/
|
|
15
|
+
const RecordChip = ({ record, name, avatarUrl, loading, failed }) => {
|
|
16
|
+
const { open, canOpen } = useOpenRecord();
|
|
17
|
+
if (loading) return /* @__PURE__ */ jsx(Skeleton, {
|
|
18
|
+
radius: "sm",
|
|
19
|
+
className: "h-5 w-20"
|
|
20
|
+
});
|
|
21
|
+
const face = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Avatar, {
|
|
22
|
+
size: "sm",
|
|
23
|
+
className: "size-4 flex-none",
|
|
24
|
+
children: [/* @__PURE__ */ jsx(Avatar.Image, { src: readImage(avatarUrl ?? void 0) }), /* @__PURE__ */ jsx(Avatar.Fallback, { children: name.charAt(0) })]
|
|
25
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
26
|
+
className: cn("truncate", failed && "text-destructive"),
|
|
27
|
+
children: name
|
|
28
|
+
})] });
|
|
29
|
+
if (!canOpen) return /* @__PURE__ */ jsx("span", {
|
|
30
|
+
title: name,
|
|
31
|
+
className: CHIP,
|
|
32
|
+
children: face
|
|
33
|
+
});
|
|
34
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
35
|
+
type: "button",
|
|
36
|
+
onClick: () => open(record),
|
|
37
|
+
title: name,
|
|
38
|
+
"data-panel-inline": "",
|
|
39
|
+
className: cn(CHIP, "hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),
|
|
40
|
+
children: [face, /* @__PURE__ */ jsx(IconArrowUpRight, {
|
|
41
|
+
className: "size-3 flex-none text-muted-foreground opacity-0 transition-opacity group-hover/chip:opacity-100 group-focus-visible/chip:opacity-100",
|
|
42
|
+
"aria-hidden": "true"
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export { RecordChip };
|
package/exports.txt
CHANGED
|
@@ -43,6 +43,7 @@ type TConditionGroup
|
|
|
43
43
|
type TConditionLookups
|
|
44
44
|
type TConditionRule
|
|
45
45
|
type TContactContentType
|
|
46
|
+
type TContactKind
|
|
46
47
|
type TDashboardWidget
|
|
47
48
|
type TDashboardWidgetPreview
|
|
48
49
|
type TListDisplay
|
|
@@ -91,6 +92,7 @@ value Command
|
|
|
91
92
|
value CommandBar
|
|
92
93
|
value ConditionsEditor
|
|
93
94
|
value ContactLink
|
|
95
|
+
value ContactRelationInput
|
|
94
96
|
value ContextMenu
|
|
95
97
|
value CopyText
|
|
96
98
|
value DASHBOARD_WIDGET_PREVIEWS
|
|
@@ -125,7 +127,9 @@ value ListFilter
|
|
|
125
127
|
value ListFilterEmpty
|
|
126
128
|
value ListViewsProvider
|
|
127
129
|
value LookupPicker
|
|
130
|
+
value MEMBER_CONTENT_TYPE
|
|
128
131
|
value MemberInline
|
|
132
|
+
value MemberLink
|
|
129
133
|
value MultipleSelector
|
|
130
134
|
value NavigationMenuLinkItem
|
|
131
135
|
value NumberField
|
|
@@ -158,6 +162,7 @@ value RelativeDateDisplay
|
|
|
158
162
|
value Resizable
|
|
159
163
|
value ScrollArea
|
|
160
164
|
value Select
|
|
165
|
+
value SelectContactContent
|
|
161
166
|
value SelectMember
|
|
162
167
|
value Separator
|
|
163
168
|
value SexCode
|