@erxes/ui 4.0.0-v2.16 → 4.0.0-v2.18

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/AGENTS.md CHANGED
@@ -30,6 +30,11 @@ points here. `CATALOG.md` lists every export with the first sentence of its doc
30
30
  - Motion goes through the theme too. An entrance is `animate-appear` with its offset and timing
31
31
  in `--appear-x`, `--appear-y`, `--appear-scale`, `--appear-duration`, `--appear-easing` and
32
32
  `--appear-delay`. Styles for the collapsed sidebar use the `navigation-collapsed:` variant.
33
+ - A chart is `ChartContainer` around a recharts chart with `responsive`, which fills the frame
34
+ and follows its size, with `ChartTooltipContent` and `ChartLegendContent` as its `Tooltip` and
35
+ `Legend` content and series colours as `var(--color-<key>)` from the config. These parts import
36
+ only recharts' types: the chart and its elements come from the caller's own recharts, which
37
+ for a plugin is a copy of its own, since web doesn't share recharts.
33
38
  - Class names are written out in full, never built (`` `bg-${tone}` ``): a variant map such as
34
39
  `{ success: 'bg-success', warning: 'bg-warning' }[tone]`, or a cva variant.
35
40
 
package/CATALOG.md CHANGED
@@ -13,11 +13,13 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
13
13
  | List | `PageHeader`, `ViewBar`, `ListFilter`, `RecordTable` | `ui/src/modules/items/ItemsPage.tsx` |
14
14
  | Grouped list (by status) | `RecordList`, `DisplayMenu`, `useListDisplay` | none in core yet |
15
15
  | Board | `DisplayMenu`, `useListDisplay` | `apps/web/src/modules/leads/LeadsBoard.tsx` |
16
+ | Cards or chart | `DisplayMenu`, `useListDisplay`, `TListDisplayOption` | none in core yet |
16
17
  | Record detail | `PanelSection`, `PanelField`, `RecordTableInlineCell`, `RecordPage` | `ui/src/modules/items/ItemPanel.tsx` |
17
18
  | Create/edit form | `PanelFormLayout`, `PanelFormRow` | `ui/src/modules/items/ItemPanel.tsx` |
18
19
  | Settings list | `PageHeader`, `RecordTable` | `apps/web/src/modules/settings/tags/TagsSettingsPage.tsx` |
19
20
  | Settings form | `Form`, `Switch`, `ScrollArea` | `apps/web/src/modules/settings/profile/ProfileSettingsPage.tsx` |
20
21
  | Filters | `ListFilter`, `useListFilterParams` | `ui/src/modules/items/ItemsPage.tsx` |
22
+ | Chart | `ChartContainer`, `ChartTooltipContent`, `ChartLegendContent` | none in core yet |
21
23
 
22
24
  ## Page
23
25
 
@@ -30,7 +32,7 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
30
32
 
31
33
  ## Lists
32
34
 
33
- - `<DisplayMenu list displays>` The Display menu in a list's filter bar: table, board or grouped list.
35
+ - `<DisplayMenu list displays>` The Display menu in a list's filter bar: table, board, list or its own.
34
36
  - `EnumCursorDirection` Which way a cursor-paged table loads more rows: forward or backward.
35
37
  - `Filter.{Trigger, Popover, Item, CommandItem, View, …}` Parts of a filter popover and bar, for a page without saved views.
36
38
  - `<ListFilter recordType>` A list's filter: a view bar button, and a chip row while it filters.
@@ -43,6 +45,7 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
43
45
  - `type RecordTableColumnDef` A record table column for rows of `TData`.
44
46
  - `RecordTableInlineCell.{LabelledBy, Trigger, Content, Anchor}` A table cell value, and the trigger and popover that edit it in place.
45
47
  - `type TListDisplay` How a list shows its records: grouped rows, a table or a board.
48
+ - `type TListDisplayOption { key, label, icon }` A list's own display, such as a cards grid or a chart.
46
49
  - `type TListFilterField { path, label, type, options, icon, … }` A field a list can filter by, for `ListFilter`'s `fields`.
47
50
  - `type TListFilterProps` The props of `ListFilter`: its `id`, `fields`, lookups and record count.
48
51
  - `type TListViews { Tabs, Changes }` The host's saved views for a list.
@@ -65,6 +68,8 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
65
68
  - `type ContactSearchQueries { customers, companies }` Where a filter's `customer` and `company` fields search contacts.
66
69
  - `type CustomerContact { id, firstName, middleName, lastName, primaryEmail, … }` What a customer reads as: core's `Customer` has these fields and more.
67
70
  - `customerTitle(customer)` A customer's name, else its email or phone.
71
+ - `MEMBER_CONTENT_TYPE` The content type core's side panel opens team members as.
72
+ - `<MemberLink memberId members>` A team member as a chip: their avatar and name.
68
73
  - `<PanelDescriptionEditor value scope readonly isHTML onSave>` A record's description as a full-size tab.
69
74
  - `<PanelDescriptionField label value scope readonly isHTML>` A rich-text description row in the side panel, across its width.
70
75
  - `PanelExpansionContext` Provided by the host's record panel; erxes-ui's panel parts read it.
@@ -113,7 +118,7 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
113
118
  - `<PhoneField recordId onValueChange onValidationStatusChange primaryPhone phones>` An editable list of a record's phones, each with its own menu.
114
119
  - `<PhoneInput value onChange defaultCountry placeholder onEnter>` A phone input with a country flag picker that formats as you type.
115
120
  - `RelativeDateDisplay.{Value}` A date as how long ago it was, with the date and time on hover.
116
- - `SelectMember` The member picker as a table cell and as a field.
121
+ - `SelectMember` The member picker: a table cell, a field, or a row opening the member.
117
122
  - `<SexDisplay value>` A sex code as its label, or nothing when it is not known.
118
123
  - `<SexField value onValueChange>` A searchable list to pick a sex code, for a popover or cell editor.
119
124
  - `type Tag { id, name }` A tag as the pickers show one: core's `Tag` has these fields and more.
@@ -146,7 +151,7 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
146
151
  - `type CalendarProps` react-day-picker's `DayPicker` props.
147
152
  - `Card.{Header, Footer, Title, Description, Content}` A raised panel with header, title, description, content and footer.
148
153
  - `type ChartConfig` Each series' label, icon and colour by data key, for `ChartContainer`.
149
- - `<ChartContainer config style>` The frame for a recharts chart: size, theme and series colours.
154
+ - `<ChartContainer config style>` The frame for a `responsive` recharts chart: size, theme and colours.
150
155
  - `<ChartLegendContent hideIcon payload verticalAlign nameKey>` The themed body for a recharts `Legend`: each series' icon and label.
151
156
  - `<ChartTooltipContent>` The themed body for a recharts `Tooltip`, labelled from the config.
152
157
  - `<Checkbox>` A themed checkbox; pass `indeterminate` for a partial selection.
@@ -4,12 +4,13 @@ import * as RechartsPrimitive from "recharts";
4
4
  import { LegendPayload } from "recharts/types/component/DefaultLegendContent";
5
5
  import { Payload } from "recharts/types/component/DefaultTooltipContent";
6
6
  /**
7
- * The frame for a recharts chart: size, theme and series colours.
8
- * Each `config` colour becomes a `--color-<key>` variable the chart's parts can use.
7
+ * The frame for a `responsive` recharts chart: size, theme and colours.
8
+ * The chart (`<BarChart responsive …>`) fills the frame and follows its size. Each `config`
9
+ * colour becomes a `--color-<key>` variable the chart's parts can use. The frame needs nothing
10
+ * from recharts, so a plugin's chart from its own recharts sizes the same.
9
11
  */
10
12
  declare const ChartContainer: ({ ref, className, children, config, style, ...props }: React.ComponentProps<'div'> & {
11
13
  config: ChartConfig;
12
- children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
13
14
  }) => React.JSX.Element;
14
15
  type TooltipItem = Payload;
15
16
  type ChartTooltipContentProps = React.ComponentProps<typeof RechartsPrimitive.Tooltip> & React.ComponentProps<'div'> & {
@@ -3,7 +3,6 @@ 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
5
  import React from "react";
6
- import * as RechartsPrimitive from "recharts";
7
6
  // src/components/charts.tsx
8
7
  /** The series colours as `--color-<key>` variables. */
9
8
  const colorVariables = (config) => {
@@ -12,8 +11,10 @@ const colorVariables = (config) => {
12
11
  return variables;
13
12
  };
14
13
  /**
15
- * The frame for a recharts chart: size, theme and series colours.
16
- * Each `config` colour becomes a `--color-<key>` variable the chart's parts can use.
14
+ * The frame for a `responsive` recharts chart: size, theme and colours.
15
+ * The chart (`<BarChart responsive …>`) fills the frame and follows its size. Each `config`
16
+ * colour becomes a `--color-<key>` variable the chart's parts can use. The frame needs nothing
17
+ * from recharts, so a plugin's chart from its own recharts sizes the same.
17
18
  */
18
19
  const ChartContainer = ({ ref, className, children, config, style, ...props }) => {
19
20
  const cssVariables = colorVariables(config);
@@ -26,9 +27,9 @@ const ChartContainer = ({ ref, className, children, config, style, ...props }) =
26
27
  ...cssVariables,
27
28
  ...style
28
29
  },
29
- className: cn("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-hidden [&_.recharts-surface]:outline-hidden", className),
30
+ className: cn("flex aspect-video justify-center text-xs [&>.recharts-wrapper]:size-full [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-hidden [&_.recharts-surface]:outline-hidden", className),
30
31
  ...props,
31
- children: /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { children })
32
+ children
32
33
  })
33
34
  });
34
35
  };
package/dist/index.d.ts CHANGED
@@ -102,7 +102,7 @@ import { RecordTable } from "./modules/record-table/components/RecordTable.js";
102
102
  import { RecordTableColumnDef, TRecordTableSort } from "./modules/record-table/components/RecordTableProvider.js";
103
103
  import { RecordTableInlineCell } from "./modules/record-table/components/RecordTableCellInline.js";
104
104
  import { EnumCursorDirection } from "./modules/record-table/types/RecordTableCursorTypes.js";
105
- import { DisplayMenu, TListDisplay, useListDisplay } from "./modules/list/DisplayMenu.js";
105
+ import { DisplayMenu, TListDisplay, TListDisplayOption, useListDisplay } from "./modules/list/DisplayMenu.js";
106
106
  import { ListFilter, ListFilterEmpty, TListFilterField, TListFilterProps, useListFilterParams } from "./modules/list/ListFilter.js";
107
107
  import { listFilterQuery } from "./modules/list/filter/listFilterQuery.js";
108
108
  import { TConditionField, TConditionGroup, TConditionLookups, TConditionRule, isRule } from "./modules/conditions/conditions.js";
@@ -116,6 +116,7 @@ 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 { MEMBER_CONTENT_TYPE, MemberLink } from "./modules/records/MemberLink.js";
119
120
  import { CompanyContact, ContactQueries, ContactSearch, ContactSearchQueries, CustomerContact, TContactContentType, companyTitle, customerTitle } from "./modules/records/contacts.js";
120
121
  import { RecordOpenerProvider, RecordPage, RecordPageProps, RecordPanelControls, RecordPanelProvider, RecordRef, setRecordPage, useOpenRecord, useRecordPanel } from "./modules/records/openRecord.js";
121
122
  import { ThemeOption, themeState } from "./state/themeState.js";
@@ -130,4 +131,4 @@ import { jsonOf } from "./utils/json.js";
130
131
  import { PluginLiveMessage, PluginRuntime, PluginSession, getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
131
132
  import { addPluginStyles } from "./utils/plugin-styles.js";
132
133
  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 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 };
134
+ 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, 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, 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 };
package/dist/index.js CHANGED
@@ -112,6 +112,7 @@ 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 { MEMBER_CONTENT_TYPE, MemberLink } from "./modules/records/MemberLink.js";
115
116
  import { companyTitle, customerTitle } from "./modules/records/contacts.js";
116
117
  import { RecordOpenerProvider, RecordPage, RecordPanelProvider, setRecordPage, useOpenRecord, useRecordPanel } from "./modules/records/openRecord.js";
117
118
  import { ThemeOption, themeState } from "./state/themeState.js";
@@ -126,4 +127,4 @@ import { jsonOf } from "./utils/json.js";
126
127
  import { getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
127
128
  import { addPluginStyles } from "./utils/plugin-styles.js";
128
129
  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 };
130
+ 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, 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, 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 };
@@ -1,24 +1,37 @@
1
- declare const LIST_DISPLAYS: readonly ['list', 'table', 'board'];
1
+ import { Icon } from "@tabler/icons-react";
2
2
  /**
3
3
  * How a list shows its records: grouped rows, a table or a board.
4
4
  * Grouped rows are `RecordList`; a board shows cards.
5
5
  */
6
- export type TListDisplay = (typeof LIST_DISPLAYS)[number];
6
+ export type TListDisplay = 'list' | 'table' | 'board';
7
+ /**
8
+ * A list's own display, such as a cards grid or a chart.
9
+ * It shows in `DisplayMenu` beside the built-in ones:
10
+ * `{ key: 'cards', label: t('cards', 'Cards'), icon: IconLayoutGrid }`. The list renders it
11
+ * when `useListDisplay` returns its `key`.
12
+ */
13
+ export interface TListDisplayOption<K extends string = string> {
14
+ key: K;
15
+ label: string;
16
+ icon: Icon;
17
+ }
7
18
  /** The displays a list offers, in the menu's order; the first shows until one is chosen. */
8
- type ListDisplays = readonly [TListDisplay, ...TListDisplay[]];
19
+ type ListDisplays<K extends string> = readonly [TListDisplay | TListDisplayOption<K>, ...(TListDisplay | TListDisplayOption<K>)[]];
9
20
  /**
10
21
  * The display a list shows, as picked in its Display menu.
11
22
  * `const [display] = useListDisplay('sales-deals')`. The choice is remembered in this browser,
12
- * one per list. Give it the same `displays` as the list's `DisplayMenu`.
23
+ * one per list. Give it the same `displays` as the list's `DisplayMenu`; a list's own display
24
+ * comes back as its `key`.
13
25
  */
14
- export declare const useListDisplay: (list: string, displays?: ListDisplays) => readonly ["board" | "list" | "table", (args_0: "board" | "list" | "table" | typeof import("jotai/utils").RESET | ((prev: "board" | "list" | "table" | null) => "board" | "list" | "table" | typeof import("jotai/utils").RESET | null) | null) => void];
26
+ export declare const useListDisplay: <const K extends string = never>(list: string, displays?: ListDisplays<K>) => readonly [K | TListDisplay, (args_0: string | typeof import("jotai/utils").RESET | ((prev: string | null) => string | typeof import("jotai/utils").RESET | null) | null) => void];
15
27
  /**
16
- * The Display menu in a list's filter bar: table, board or grouped list.
28
+ * The Display menu in a list's filter bar: table, board, list or its own.
17
29
  * It offers table or board, or the `displays` the list offers, such as
18
- * `['list', 'board', 'table']`; `useListDisplay(list, displays)` reads the choice.
30
+ * `['list', 'board', 'table']`, or the list's own (`TListDisplayOption`) among them:
31
+ * `[{ key: 'cards', label, icon }, 'table']`. `useListDisplay(list, displays)` reads the choice.
19
32
  */
20
- export declare const DisplayMenu: ({ list, displays }: {
33
+ export declare const DisplayMenu: <const K extends string = never>({ list, displays }: {
21
34
  list: string;
22
- displays?: ListDisplays;
35
+ displays?: ListDisplays<K>;
23
36
  }) => import("react").JSX.Element;
24
37
  export {};
@@ -9,28 +9,25 @@ import { useAtom } from "jotai";
9
9
  import { z } from "zod";
10
10
  import { useTranslation } from "react-i18next";
11
11
  // src/modules/list/DisplayMenu.tsx
12
- const LIST_DISPLAYS = [
13
- "list",
14
- "table",
15
- "board"
16
- ];
17
12
  const TABLE_AND_BOARD = ["table", "board"];
13
+ const keyOf = (display) => typeof display === "string" ? display : display.key;
18
14
  /** Null until the member picks one. */
19
15
  const listDisplayFamily = storedFamily({
20
16
  key: "erxes:list-display",
21
- schema: z.enum(LIST_DISPLAYS).nullable(),
17
+ schema: z.string().nullable(),
22
18
  initial: null
23
19
  });
24
20
  /**
25
21
  * The display a list shows, as picked in its Display menu.
26
22
  * `const [display] = useListDisplay('sales-deals')`. The choice is remembered in this browser,
27
- * one per list. Give it the same `displays` as the list's `DisplayMenu`.
23
+ * one per list. Give it the same `displays` as the list's `DisplayMenu`; a list's own display
24
+ * comes back as its `key`.
28
25
  */
29
26
  const useListDisplay = (list, displays = TABLE_AND_BOARD) => {
30
27
  const [chosen, setDisplay] = useAtom(listDisplayFamily(list));
31
- return [chosen && displays.includes(chosen) ? chosen : displays[0], setDisplay];
28
+ return [displays.map(keyOf).find((key) => key === chosen) ?? keyOf(displays[0]), setDisplay];
32
29
  };
33
- const DISPLAYS = {
30
+ const BUILT_IN = {
34
31
  list: {
35
32
  fallback: "List",
36
33
  icon: IconList
@@ -45,9 +42,10 @@ const DISPLAYS = {
45
42
  }
46
43
  };
47
44
  /**
48
- * The Display menu in a list's filter bar: table, board or grouped list.
45
+ * The Display menu in a list's filter bar: table, board, list or its own.
49
46
  * It offers table or board, or the `displays` the list offers, such as
50
- * `['list', 'board', 'table']`; `useListDisplay(list, displays)` reads the choice.
47
+ * `['list', 'board', 'table']`, or the list's own (`TListDisplayOption`) among them:
48
+ * `[{ key: 'cards', label, icon }, 'table']`. `useListDisplay(list, displays)` reads the choice.
51
49
  */
52
50
  const DisplayMenu = ({ list, displays = TABLE_AND_BOARD }) => {
53
51
  const [current, setDisplay] = useListDisplay(list, displays);
@@ -65,20 +63,27 @@ const DisplayMenu = ({ list, displays = TABLE_AND_BOARD }) => {
65
63
  })
66
64
  }), /* @__PURE__ */ jsxs(Popover.Content, {
67
65
  align: "end",
68
- className: "w-64",
66
+ className: displays.length > 2 ? "w-80" : "w-64",
69
67
  children: [/* @__PURE__ */ jsx("p", {
70
68
  className: "mb-2 text-xs font-medium text-muted-foreground",
71
69
  children: t("view", "View")
72
70
  }), /* @__PURE__ */ jsx("div", {
73
71
  className: cn("grid gap-2", displays.length > 2 ? "grid-cols-3" : "grid-cols-2"),
74
- children: displays.map((value) => {
75
- const { fallback, icon: Icon } = DISPLAYS[value];
72
+ children: displays.map((display) => {
73
+ const value = keyOf(display);
74
+ const { label, icon: DisplayIcon } = typeof display === "string" ? {
75
+ label: t(display, BUILT_IN[display].fallback),
76
+ icon: BUILT_IN[display].icon
77
+ } : display;
76
78
  return /* @__PURE__ */ jsxs("button", {
77
79
  type: "button",
78
80
  "aria-pressed": current === value,
79
81
  onClick: () => setDisplay(value),
80
82
  className: cn("flex flex-col items-center gap-1.5 rounded-lg border p-3 text-sm text-muted-foreground transition-colors hover:bg-accent", current === value && "border-primary bg-primary/5 font-medium text-foreground"),
81
- children: [/* @__PURE__ */ jsx(Icon, { className: "size-5" }), t(value, fallback)]
83
+ children: [/* @__PURE__ */ jsx(DisplayIcon, { className: "size-5" }), /* @__PURE__ */ jsx("span", {
84
+ className: "text-center",
85
+ children: label
86
+ })]
82
87
  }, value);
83
88
  })
84
89
  })]
@@ -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
- /** The member picker as a table cell and as a field. */
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
- /** The member picker as a table cell and as a field. */
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 { useOpenRecord } from "./openRecord.js";
7
- import { IconArrowUpRight } from "@tabler/icons-react";
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
- 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({
38
+ return /* @__PURE__ */ jsx(RecordChip, {
39
+ record: {
65
40
  contentType,
66
41
  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
- })]
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,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 };
@@ -7,9 +7,16 @@ export interface RecordRef {
7
7
  contentType: string;
8
8
  contentId: string;
9
9
  }
10
- type OpenRecord = (record: RecordRef) => void;
10
+ /**
11
+ * Opens a record; `tab` picks the tab it opens on: `detail`, `activity` or one of its type's
12
+ * `tabs` by `value`. A tab the record lacks opens its default.
13
+ */
14
+ type OpenRecord = (record: RecordRef & {
15
+ tab?: string;
16
+ }) => void;
11
17
  /** Opens a draft of a record type, starting with `defaults` (e.g. the stage it was added in). */
12
18
  type OpenNewRecord = (contentType: string, defaults?: Record<string, unknown>) => void;
19
+ type DismissRecord = (record: RecordRef) => void;
13
20
  /**
14
21
  * The host app's way to open records, which `useOpenRecord` calls.
15
22
  * Web provides it: beside the page in its side panel, or, inside a record, on top of that
@@ -20,12 +27,13 @@ export declare const RecordOpenerProvider: ({ open, openNew, current, dismiss, c
20
27
  open: OpenRecord;
21
28
  openNew?: OpenNewRecord;
22
29
  current?: RecordRef | null;
23
- dismiss?: OpenRecord;
30
+ dismiss?: DismissRecord;
24
31
  }>) => import("react").JSX.Element;
25
32
  /**
26
33
  * Opens a record, or a new draft, in core's side panel.
27
34
  * `const { open, openNew } = useOpenRecord()`: `open({ contentType: 'sales:deal', contentId })`
28
- * opens a record in core's side panel, the page staying under it, and
35
+ * opens a record in core's side panel, the page staying under it, on its default tab, or on
36
+ * the one `tab` names (`open({ contentType: 'hr:employee', contentId, tab: 'leave' })`), and
29
37
  * `openNew('sales:deal', { stageId })` opens a draft that becomes the record on Save. Any
30
38
  * type core or an installed plugin registers opens (`IUIConfig.recordTypes`). `canOpen` is
31
39
  * false outside erxes (a plugin page rendered on its own), where both do nothing.
@@ -38,7 +46,7 @@ export declare const useOpenRecord: () => {
38
46
  open: OpenRecord;
39
47
  openNew: OpenNewRecord;
40
48
  current: RecordRef | null;
41
- dismiss: OpenRecord;
49
+ dismiss: DismissRecord;
42
50
  canOpen: boolean;
43
51
  };
44
52
  /**
@@ -30,7 +30,8 @@ const RecordOpenerProvider = ({ open, openNew = ignore, current = null, dismiss
30
30
  /**
31
31
  * Opens a record, or a new draft, in core's side panel.
32
32
  * `const { open, openNew } = useOpenRecord()`: `open({ contentType: 'sales:deal', contentId })`
33
- * opens a record in core's side panel, the page staying under it, and
33
+ * opens a record in core's side panel, the page staying under it, on its default tab, or on
34
+ * the one `tab` names (`open({ contentType: 'hr:employee', contentId, tab: 'leave' })`), and
34
35
  * `openNew('sales:deal', { stageId })` opens a draft that becomes the record on Save. Any
35
36
  * type core or an installed plugin registers opens (`IUIConfig.recordTypes`). `canOpen` is
36
37
  * false outside erxes (a plugin page rendered on its own), where both do nothing.
@@ -1,3 +1,9 @@
1
+ /**
2
+ * The selectors of a list whose class the page lacks, and those with no class. Minified Tailwind
3
+ * merges rules with the same body into one list (`.bg-info,.bg-info\/10{…}`), so each selector
4
+ * is judged on its own.
5
+ */
6
+ export declare const unknownSelectors: (selectorText: string, known: Set<string>) => string[];
1
7
  /**
2
8
  * Adds a plugin UI's compiled Tailwind to the page, minus what web has.
3
9
  * Pass `css` from `import css from './styles.css?inline'`. It keeps the utilities layer without
@@ -1,12 +1,38 @@
1
1
  // src/utils/plugin-styles.ts
2
2
  const sheets = /* @__PURE__ */ new Map();
3
- /** The class a rule is for: `md\:flex` in `.md\:flex`, `space-y-2` in `:where(.space-y-2 > …)`. */
3
+ /** The class a selector is for: `md\:flex` in `.md\:flex`, `space-y-2` in `:where(.space-y-2 > …)`. */
4
4
  const CLASS = /\.((?:\\[\da-f]{1,6} ?|\\.|[\w-])+)/i;
5
- const classOf = (rule) => rule instanceof CSSStyleRule ? CLASS.exec(rule.selectorText)?.[1] : void 0;
5
+ const classOf = (selector) => CLASS.exec(selector)?.[1];
6
+ /** The selectors of a list, split at the commas outside brackets: `:is(.a, .b)` stays one. */
7
+ const selectorList = (selectorText) => {
8
+ const selectors = [];
9
+ let depth = 0;
10
+ let start = 0;
11
+ for (let index = 0; index < selectorText.length; index++) {
12
+ const char = selectorText[index];
13
+ if (char === "\\") index++;
14
+ else if (char === "(" || char === "[") depth++;
15
+ else if (char === ")" || char === "]") depth--;
16
+ else if (char === "," && depth === 0) {
17
+ selectors.push(selectorText.slice(start, index).trim());
18
+ start = index + 1;
19
+ }
20
+ }
21
+ return [...selectors, selectorText.slice(start).trim()];
22
+ };
23
+ /**
24
+ * The selectors of a list whose class the page lacks, and those with no class. Minified Tailwind
25
+ * merges rules with the same body into one list (`.bg-info,.bg-info\/10{…}`), so each selector
26
+ * is judged on its own.
27
+ */
28
+ const unknownSelectors = (selectorText, known) => selectorList(selectorText).filter((selector) => {
29
+ const name = classOf(selector);
30
+ return name === void 0 || !known.has(name);
31
+ });
6
32
  const collectClasses = (rules, into) => {
7
33
  for (const rule of rules) {
8
- const name = classOf(rule);
9
- if (name) into.add(name);
34
+ const names = rule instanceof CSSStyleRule ? selectorList(rule.selectorText).flatMap((selector) => classOf(selector) ?? []) : [];
35
+ if (names.length > 0) for (const name of names) into.add(name);
10
36
  else if (rule instanceof CSSGroupingRule) collectClasses(rule.cssRules, into);
11
37
  }
12
38
  };
@@ -18,13 +44,18 @@ const pageClasses = (except) => {
18
44
  for (const sheet of [...document.styleSheets, ...document.adoptedStyleSheets]) if (sheet !== except && sameOrigin(sheet)) collectClasses(sheet.cssRules, classes);
19
45
  return classes;
20
46
  };
21
- /** Deletes the rules for classes the page has, and the groups that leave empty. */
47
+ /**
48
+ * Deletes the selectors for classes the page has, the rules that leave with none, and the groups
49
+ * that leave empty.
50
+ */
22
51
  const dropKnown = (group, known) => {
23
52
  for (let index = group.cssRules.length - 1; index >= 0; index--) {
24
53
  const rule = group.cssRules[index];
25
- const name = rule && classOf(rule);
26
- if (name !== void 0 && known.has(name)) group.deleteRule(index);
27
- else if (rule instanceof CSSGroupingRule && !(rule instanceof CSSStyleRule)) {
54
+ if (rule instanceof CSSStyleRule) {
55
+ const kept = unknownSelectors(rule.selectorText, known);
56
+ if (kept.length === 0) group.deleteRule(index);
57
+ else rule.selectorText = kept.join(", ");
58
+ } else if (rule instanceof CSSGroupingRule) {
28
59
  dropKnown(rule, known);
29
60
  if (rule.cssRules.length === 0) group.deleteRule(index);
30
61
  }
@@ -51,4 +82,4 @@ const addPluginStyles = (plugin, css) => {
51
82
  sheets.set(plugin, sheet);
52
83
  document.adoptedStyleSheets = [...document.adoptedStyleSheets.filter((adopted) => adopted !== previous), sheet];
53
84
  };
54
- export { addPluginStyles };
85
+ export { addPluginStyles, unknownSelectors };
package/exports.txt CHANGED
@@ -46,6 +46,7 @@ type TContactContentType
46
46
  type TDashboardWidget
47
47
  type TDashboardWidgetPreview
48
48
  type TListDisplay
49
+ type TListDisplayOption
49
50
  type TListFilterField
50
51
  type TListFilterProps
51
52
  type TListViews
@@ -124,7 +125,9 @@ value ListFilter
124
125
  value ListFilterEmpty
125
126
  value ListViewsProvider
126
127
  value LookupPicker
128
+ value MEMBER_CONTENT_TYPE
127
129
  value MemberInline
130
+ value MemberLink
128
131
  value MultipleSelector
129
132
  value NavigationMenuLinkItem
130
133
  value NumberField
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erxes/ui",
3
- "version": "4.0.0-v2.16",
3
+ "version": "4.0.0-v2.18",
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",