@erxes/ui 4.0.0-v2.16 → 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 +5 -0
- package/CATALOG.md +5 -2
- package/dist/components/charts.d.ts +4 -3
- package/dist/components/charts.js +6 -5
- package/dist/index.d.ts +2 -2
- package/dist/modules/list/DisplayMenu.d.ts +22 -9
- package/dist/modules/list/DisplayMenu.js +20 -15
- package/dist/modules/records/openRecord.d.ts +12 -4
- package/dist/modules/records/openRecord.js +2 -1
- package/dist/utils/plugin-styles.d.ts +6 -0
- package/dist/utils/plugin-styles.js +40 -9
- package/exports.txt +1 -0
- package/package.json +1 -1
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
|
|
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.
|
|
@@ -146,7 +149,7 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
|
|
|
146
149
|
- `type CalendarProps` react-day-picker's `DayPicker` props.
|
|
147
150
|
- `Card.{Header, Footer, Title, Description, Content}` A raised panel with header, title, description, content and footer.
|
|
148
151
|
- `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
|
|
152
|
+
- `<ChartContainer config style>` The frame for a `responsive` recharts chart: size, theme and colours.
|
|
150
153
|
- `<ChartLegendContent hideIcon payload verticalAlign nameKey>` The themed body for a recharts `Legend`: each series' icon and label.
|
|
151
154
|
- `<ChartTooltipContent>` The themed body for a recharts `Tooltip`, labelled from the config.
|
|
152
155
|
- `<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
|
|
8
|
-
*
|
|
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
|
|
16
|
-
*
|
|
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
|
|
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";
|
|
@@ -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 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 };
|
|
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,24 +1,37 @@
|
|
|
1
|
-
|
|
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 =
|
|
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
|
|
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 [
|
|
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
|
|
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']
|
|
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.
|
|
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 [
|
|
28
|
+
return [displays.map(keyOf).find((key) => key === chosen) ?? keyOf(displays[0]), setDisplay];
|
|
32
29
|
};
|
|
33
|
-
const
|
|
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
|
|
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']
|
|
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((
|
|
75
|
-
const
|
|
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(
|
|
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
|
-
|
|
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?:
|
|
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,
|
|
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:
|
|
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,
|
|
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
|
|
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 = (
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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