@erxes/ui 4.0.0-v2.15 → 4.0.0-v2.17

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.
@@ -76,6 +79,7 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
76
79
  - `<PanelSection title icon nested>` A plain heading that groups the side panel's rows.
77
80
  - `<RecordOpenerProvider open openNew current dismiss>` The host app's way to open records, which `useOpenRecord` calls.
78
81
  - `RecordPage` A record on its own page, as core draws a customer's.
82
+ - `type RecordPageProps { listPath }` A `RecordPage`'s record, and the list it goes back to.
79
83
  - `type RecordPanelControls { record, tab, setTab, close, dismiss, … }` What a record shown in core's panel, or on its own page, can do to it.
80
84
  - `RecordPanelProvider` Web gives each record it shows its controls.
81
85
  - `type RecordRef { contentType, contentId }` A record the host can open, by `contentType` and `contentId`.
@@ -145,7 +149,7 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
145
149
  - `type CalendarProps` react-day-picker's `DayPicker` props.
146
150
  - `Card.{Header, Footer, Title, Description, Content}` A raised panel with header, title, description, content and footer.
147
151
  - `type ChartConfig` Each series' label, icon and colour by data key, for `ChartContainer`.
148
- - `<ChartContainer config style>` The frame for a recharts chart: size, theme and series colours.
152
+ - `<ChartContainer config style>` The frame for a `responsive` recharts chart: size, theme and colours.
149
153
  - `<ChartLegendContent hideIcon payload verticalAlign nameKey>` The themed body for a recharts `Legend`: each series' icon and label.
150
154
  - `<ChartTooltipContent>` The themed body for a recharts `Tooltip`, labelled from the config.
151
155
  - `<Checkbox>` A themed checkbox; pass `indeterminate` for a partial selection.
@@ -218,8 +222,10 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
218
222
  - `type TDashboardWidgetPreview` The schematic a dashboard widget shows in the widget catalog.
219
223
  - `type TPanelRecordType { contentType, title, icon, detailPath, Title, … }` A record type a plugin shows in core's side panel.
220
224
  - `type TPluginSettingsPage { path, label, icon }` A plugin's settings page, linked from core's settings sidebar.
225
+ - `type TPropertyValue` A custom field's value: text, number, date, yes/no or options.
221
226
  - `type TRecordContacts { customerIds, companyIds }` The customers and companies a record is about.
222
227
  - `type TRecordDraftProps { defaults, onCreated, onCancel }` Props of a plugin record type's `New` slot, the draft form.
228
+ - `type TRecordProperties { type, values, save }` Custom fields on a plugin record type, whose values the plugin keeps.
223
229
  - `type TRecordSection { contentType, title, icon, component }` A plugin's section on a customer's or company's detail in core's panel.
224
230
  - `type TRecordSectionProps { contentType, contentId }` What a record section is given: the customer or company it shows on.
225
231
  - `type TRecordSlotProps` What each slot of a plugin record is given: the record.
@@ -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
  };
@@ -1,10 +1,12 @@
1
1
  import { ReactNode } from "react";
2
2
  /** A card of a settings page or a record's own page: a title, a line about it, then its fields. */
3
- export declare const FormSection: ({ title, description, action, children }: {
3
+ export declare const FormSection: ({ title, description, action, variant, children }: {
4
4
  title: ReactNode;
5
5
  description?: ReactNode;
6
6
  /** A control beside the title, such as a status badge. */
7
7
  action?: ReactNode;
8
+ /** `destructive`: a red card for what can't be undone, such as deleting a team. */
9
+ variant?: 'default' | 'destructive';
8
10
  children: ReactNode;
9
11
  }) => import("react").JSX.Element;
10
12
  /**
@@ -1,3 +1,4 @@
1
+ import { cn } from "../lib/utils.js";
1
2
  import { Button } from "./button.js";
2
3
  import { Spinner } from "./spinner.js";
3
4
  import { IconDeviceFloppy } from "@tabler/icons-react";
@@ -6,14 +7,14 @@ import { useTranslation } from "react-i18next";
6
7
  import { useFormContext, useFormState } from "react-hook-form";
7
8
  // src/components/form-layout.tsx
8
9
  /** A card of a settings page or a record's own page: a title, a line about it, then its fields. */
9
- const FormSection = ({ title, description, action, children }) => /* @__PURE__ */ jsxs("section", {
10
- className: "space-y-4 rounded-lg border bg-background p-5",
10
+ const FormSection = ({ title, description, action, variant = "default", children }) => /* @__PURE__ */ jsxs("section", {
11
+ className: cn("space-y-4 rounded-lg border bg-background p-5", variant === "destructive" && "border-destructive/40"),
11
12
  children: [/* @__PURE__ */ jsxs("div", {
12
13
  className: "flex items-start justify-between gap-4",
13
14
  children: [/* @__PURE__ */ jsxs("div", {
14
15
  className: "min-w-0 space-y-0.5",
15
16
  children: [/* @__PURE__ */ jsx("h2", {
16
- className: "text-base font-semibold",
17
+ className: cn("text-base font-semibold", variant === "destructive" && "text-(--destructive-text)"),
17
18
  children: title
18
19
  }), description && /* @__PURE__ */ jsx("p", {
19
20
  className: "text-sm text-muted-foreground",
@@ -9,7 +9,7 @@ const InputGroupRoot = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
9
9
  className: cn("group/input-group relative flex h-7 w-full min-w-0 items-center rounded-sm bg-background shadow-xs transition has-[>textarea]:h-auto has-[>:is(input,textarea):focus-visible]:shadow-focus has-[>:is(input,textarea):disabled]:opacity-50", "has-[>[data-align=start]]:[&>:is(input,textarea)]:pl-1.5 has-[>[data-align=end]]:[&>:is(input,textarea)]:pr-1.5", className),
10
10
  ...props
11
11
  });
12
- const addonVariants = cva("flex h-full shrink-0 items-center text-muted-foreground group-has-[>textarea]/input-group:h-auto group-has-[>textarea]/input-group:self-start group-has-[>textarea]/input-group:pt-1.5", {
12
+ const addonVariants = cva("flex h-full shrink-0 items-center text-sm text-muted-foreground group-has-[>textarea]/input-group:h-auto group-has-[>textarea]/input-group:self-start group-has-[>textarea]/input-group:pt-1.5", {
13
13
  variants: { align: {
14
14
  start: "order-first pl-2.5",
15
15
  end: "order-last pr-1.5"
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";
@@ -117,10 +117,10 @@ 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
119
  import { CompanyContact, ContactQueries, ContactSearch, ContactSearchQueries, CustomerContact, TContactContentType, companyTitle, customerTitle } from "./modules/records/contacts.js";
120
- import { RecordOpenerProvider, RecordPage, RecordPanelControls, RecordPanelProvider, RecordRef, setRecordPage, useOpenRecord, useRecordPanel } from "./modules/records/openRecord.js";
120
+ import { RecordOpenerProvider, RecordPage, RecordPageProps, RecordPanelControls, RecordPanelProvider, RecordRef, setRecordPage, useOpenRecord, useRecordPanel } from "./modules/records/openRecord.js";
121
121
  import { ThemeOption, themeState } from "./state/themeState.js";
122
122
  import { SexCode } from "./types/SexCode.js";
123
- import { DASHBOARD_WIDGET_PREVIEWS, IUIConfig, TDashboardWidget, TDashboardWidgetPreview, TPanelRecordType, TPluginSettingsPage, TRecordContacts, TRecordDraftProps, TRecordSection, TRecordSectionProps, TRecordSlotProps, TRecordTab, TRelationTab, TRelationTabProps } from "./types/UIConfig.js";
123
+ import { DASHBOARD_WIDGET_PREVIEWS, IUIConfig, TDashboardWidget, TDashboardWidgetPreview, TPanelRecordType, TPluginSettingsPage, TPropertyValue, TRecordContacts, TRecordDraftProps, TRecordProperties, TRecordSection, TRecordSectionProps, TRecordSlotProps, TRecordTab, TRelationTab, TRelationTabProps } from "./types/UIConfig.js";
124
124
  import { isUndefinedOrNull } from "./utils/IsUndefinedOrNull.js";
125
125
  import { readImage } from "./utils/core.js";
126
126
  import { FileStorageAdapter, setFileStorage } from "./utils/file-storage.js";
@@ -130,4 +130,4 @@ import { jsonOf } from "./utils/json.js";
130
130
  import { PluginLiveMessage, PluginRuntime, PluginSession, getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
131
131
  import { addPluginStyles } from "./utils/plugin-styles.js";
132
132
  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 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 TRecordContacts, type TRecordDraftProps, 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 };
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 };
@@ -1,2 +1,2 @@
1
1
  import { BlockEditorProps, IEditorProps } from "../types/TextEditor.js";
2
- export declare const Editor: ({ onChange, initialContent, scope, className, isHTML, uploadFile, label, variant, ...props }: Omit<BlockEditorProps, 'editor' | 'onChange'> & IEditorProps) => import("react").JSX.Element;
2
+ export declare const Editor: ({ onChange, initialContent, scope, className, isHTML, uploadFile, label, placeholder, variant, ...props }: Omit<BlockEditorProps, 'editor' | 'onChange'> & IEditorProps) => import("react").JSX.Element;
@@ -1,15 +1,18 @@
1
1
  import { useBlockEditor } from "../hooks/useBlockEditor.js";
2
2
  import { useEditorValue } from "../hooks/useEditorValue.js";
3
3
  import { BlockEditor } from "./BlockEditor.js";
4
+ import { useFieldControl } from "../../../components/field-control.js";
4
5
  import { cn } from "../../../lib/utils.js";
5
6
  import { parseBlocks } from "../utils/parseBlocks.js";
6
7
  import { jsx } from "react/jsx-runtime";
7
8
  // src/modules/blocks/components/Editor.tsx
8
- const Editor = ({ onChange, initialContent, scope, className, isHTML = false, uploadFile, label, variant = "outline", ...props }) => {
9
+ const Editor = ({ onChange, initialContent, scope, className, isHTML = false, uploadFile, label, placeholder, variant = "outline", ...props }) => {
9
10
  const editor = useBlockEditor({
10
11
  initialContent: parseBlocks(initialContent ?? "") || void 0,
11
12
  uploadFile,
12
- label
13
+ label,
14
+ placeholder,
15
+ field: useFieldControl()
13
16
  });
14
17
  const handleChange = useEditorValue({
15
18
  editor,
@@ -1,3 +1,4 @@
1
+ import { FieldControlProps } from "../../../components/field-control.js";
1
2
  import { IBlockEditor } from "../types/TextEditor.js";
2
3
  import { Block } from "@blocknote/core";
3
4
  export declare const useBlockEditor: (args?: {
@@ -6,4 +7,6 @@ export declare const useBlockEditor: (args?: {
6
7
  /** What screen readers call the editor; the placeholder when not given. */
7
8
  label?: string;
8
9
  uploadFile?: (file: File) => Promise<string>;
10
+ /** The form row it's in (`useFieldControl()`): its label names the editor. */
11
+ field?: FieldControlProps;
9
12
  }) => IBlockEditor;
@@ -7,7 +7,7 @@ import { useEffect } from "react";
7
7
  import { useCreateBlockNote } from "@blocknote/react";
8
8
  // src/modules/blocks/hooks/useBlockEditor.tsx
9
9
  const useBlockEditor = (args) => {
10
- const { initialContent, placeholder, label, uploadFile } = args ?? {};
10
+ const { initialContent, placeholder, label, uploadFile, field = {} } = args ?? {};
11
11
  const { toast } = useToast();
12
12
  const defaultUploadFile = async (file) => {
13
13
  try {
@@ -29,12 +29,31 @@ const useBlockEditor = (args) => {
29
29
  domAttributes: { editor: {
30
30
  role: "textbox",
31
31
  "aria-multiline": "true",
32
- "aria-label": label || defaultPlaceholder
32
+ ...field["aria-labelledby"] && !label ? { "aria-labelledby": field["aria-labelledby"] } : { "aria-label": label || defaultPlaceholder }
33
33
  } },
34
34
  uploadFile: uploadFile ?? defaultUploadFile,
35
35
  resolveFileUrl: (url) => Promise.resolve(readImage(url)),
36
36
  initialContent
37
37
  });
38
+ const describedBy = field["aria-describedby"];
39
+ const invalid = field["aria-invalid"];
40
+ const required = field["aria-required"];
41
+ useEffect(() => {
42
+ const element = editor.domElement;
43
+ if (!element) return;
44
+ const state = {
45
+ "aria-describedby": describedBy,
46
+ "aria-invalid": invalid ? "true" : void 0,
47
+ "aria-required": required ? "true" : void 0
48
+ };
49
+ for (const [name, value] of Object.entries(state)) if (value) element.setAttribute(name, value);
50
+ else element.removeAttribute(name);
51
+ }, [
52
+ editor,
53
+ describedBy,
54
+ invalid,
55
+ required
56
+ ]);
38
57
  useEffect(() => {
39
58
  const exportHTML = editor.blocksToHTMLLossy.bind(editor);
40
59
  editor.blocksToHTMLLossy = (blocks) => removeCodeFormattingFromHTML(exportHTML(blocks));
@@ -23,8 +23,10 @@ export interface IEditorProps {
23
23
  initialContent?: string;
24
24
  scope?: string;
25
25
  isHTML?: boolean;
26
- /** What screen readers call the editor. */
26
+ /** What screen readers call the editor; in a `PanelFormRow`, its label does. */
27
27
  label?: string;
28
+ /** Shown while it's empty, e.g. "Leave a comment…"; "Type '/' for commands..." without it. */
29
+ placeholder?: string;
28
30
  uploadFile?: (file: File) => Promise<string>;
29
31
  }
30
32
  export type IBlockEditor = typeof BLOCK_SCHEMA.BlockNoteEditor;
@@ -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
  })]
@@ -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
  /**
@@ -67,12 +75,20 @@ export declare const RecordPanelProvider: import("react").Context<RecordPanelCon
67
75
  * Null outside a record (a plugin page on its own).
68
76
  */
69
77
  export declare const useRecordPanel: () => RecordPanelControls | null;
78
+ /** A `RecordPage`'s record, and the list it goes back to. */
79
+ export interface RecordPageProps extends RecordRef {
80
+ /**
81
+ * The list closing or deleting the record goes back to, e.g. its team's tasks; without it, the
82
+ * plugin's first page. Pass it once the record is known.
83
+ */
84
+ listPath?: string;
85
+ }
70
86
  /** Web registers how a record draws on its own page. */
71
- export declare const setRecordPage: (component: import("react").ComponentType<RecordRef> | null) => void;
87
+ export declare const setRecordPage: (component: import("react").ComponentType<RecordPageProps> | null) => void;
72
88
  /**
73
89
  * A record on its own page, as core draws a customer's.
74
90
  * The record's View at full size, under the page header, with Back to its list. A plugin
75
- * routes its record type's `listPath/:id` to `<RecordPage contentType="sales:deal" contentId={id} />`.
91
+ * routes its record type's `detailPath` to `<RecordPage contentType="sales:deal" contentId={id} listPath="/sales/deals" />`.
76
92
  */
77
- export declare const RecordPage: (props: RecordRef) => import("react").JSX.Element | null;
93
+ export declare const RecordPage: (props: RecordPageProps) => import("react").JSX.Element | null;
78
94
  export {};
@@ -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.
@@ -65,7 +66,7 @@ const setRecordPage = page.set;
65
66
  /**
66
67
  * A record on its own page, as core draws a customer's.
67
68
  * The record's View at full size, under the page header, with Back to its list. A plugin
68
- * routes its record type's `listPath/:id` to `<RecordPage contentType="sales:deal" contentId={id} />`.
69
+ * routes its record type's `detailPath` to `<RecordPage contentType="sales:deal" contentId={id} listPath="/sales/deals" />`.
69
70
  */
70
71
  const RecordPage = page.Host;
71
72
  export { RecordOpenerProvider, RecordPage, RecordPanelProvider, setRecordPage, useOpenRecord, useRecordPanel };
@@ -77,10 +77,29 @@ export type TRecordDraftProps = {
77
77
  /** Leaves the draft: back to the record it came from, else closes the panel. */
78
78
  onCancel: () => void;
79
79
  };
80
+ /**
81
+ * A custom field's value: text, number, date, yes/no or options.
82
+ * A date is `YYYY-MM-DD`; several options are a list.
83
+ */
84
+ export type TPropertyValue = string | number | boolean | string[];
85
+ /**
86
+ * Custom fields on a plugin record type, whose values the plugin keeps.
87
+ * Core keeps the fields of `type` (Settings › Properties, under the plugin) and draws the
88
+ * record's Properties tab; the plugin keeps each record's values by field id, checks a patch
89
+ * with core's `fields.check` and saves the values it answers.
90
+ */
91
+ export type TRecordProperties = {
92
+ /** The record type the fields are defined on, `<plugin>.<type>`, e.g. `operation.task`. */
93
+ type: string;
94
+ /** The record's values by field id, as query options; core refetches them after a save. */
95
+ values: (contentId: string) => UseQueryOptions<Record<string, TPropertyValue>>;
96
+ /** Saves a patch of values by field id; `null` clears one. */
97
+ save: (contentId: string, patch: Record<string, TPropertyValue | null>) => Promise<unknown>;
98
+ };
80
99
  /**
81
100
  * A record type a plugin shows in core's side panel. Core draws the panel as it draws a
82
101
  * customer's: header with Back, expand and close, the tabs (Detail, the type's own `tabs`,
83
- * every allowed plugin's relation tabs for it, Activity), resizing, the address
102
+ * Properties, every allowed plugin's relation tabs for it, Activity), resizing, the address
84
103
  * `?panel=/detail/<contentType>/<id>`, drafts. The plugin fills the slots. Open one with
85
104
  * `useOpenRecord().open({ contentType, contentId })`, a draft with `openNew(contentType)`.
86
105
  */
@@ -111,6 +130,8 @@ export type TPanelRecordType = {
111
130
  contacts?: (contentId: string) => UseQueryOptions<TRecordContacts, Error, TRecordContacts>;
112
131
  /** A timeline type of the plugin's manifest (`timelines`): core's Activity tab shows it. */
113
132
  activity?: string;
133
+ /** Custom fields: core adds a Properties tab and a settings page for them. */
134
+ properties?: TRecordProperties;
114
135
  };
115
136
  /** Props of a relation tab: the record it shows on, and its contacts. */
116
137
  export type TRelationTabProps = TRecordSlotProps & TRecordContacts;
@@ -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
@@ -33,6 +33,7 @@ type PluginLiveMessage
33
33
  type PluginRuntime
34
34
  type PluginSession
35
35
  type RecordListGroup
36
+ type RecordPageProps
36
37
  type RecordPanelControls
37
38
  type RecordRef
38
39
  type RecordTableColumnDef
@@ -45,14 +46,17 @@ type TContactContentType
45
46
  type TDashboardWidget
46
47
  type TDashboardWidgetPreview
47
48
  type TListDisplay
49
+ type TListDisplayOption
48
50
  type TListFilterField
49
51
  type TListFilterProps
50
52
  type TListViews
51
53
  type TPanelRecordType
52
54
  type TPluginListType
53
55
  type TPluginSettingsPage
56
+ type TPropertyValue
54
57
  type TRecordContacts
55
58
  type TRecordDraftProps
59
+ type TRecordProperties
56
60
  type TRecordSection
57
61
  type TRecordSectionProps
58
62
  type TRecordSlotProps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erxes/ui",
3
- "version": "4.0.0-v2.15",
3
+ "version": "4.0.0-v2.17",
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",