@erxes/ui 4.0.0-v2.15 → 4.0.0-v2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CATALOG.md +3 -0
- package/dist/components/form-layout.d.ts +3 -1
- package/dist/components/form-layout.js +4 -3
- package/dist/components/input-group.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/modules/blocks/components/Editor.d.ts +1 -1
- package/dist/modules/blocks/components/Editor.js +5 -2
- package/dist/modules/blocks/hooks/useBlockEditor.d.ts +3 -0
- package/dist/modules/blocks/hooks/useBlockEditor.js +21 -2
- package/dist/modules/blocks/types/TextEditor.d.ts +3 -1
- package/dist/modules/records/openRecord.d.ts +11 -3
- package/dist/modules/records/openRecord.js +1 -1
- package/dist/types/UIConfig.d.ts +22 -1
- package/exports.txt +3 -0
- package/package.json +1 -1
package/CATALOG.md
CHANGED
|
@@ -76,6 +76,7 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
|
|
|
76
76
|
- `<PanelSection title icon nested>` A plain heading that groups the side panel's rows.
|
|
77
77
|
- `<RecordOpenerProvider open openNew current dismiss>` The host app's way to open records, which `useOpenRecord` calls.
|
|
78
78
|
- `RecordPage` A record on its own page, as core draws a customer's.
|
|
79
|
+
- `type RecordPageProps { listPath }` A `RecordPage`'s record, and the list it goes back to.
|
|
79
80
|
- `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
81
|
- `RecordPanelProvider` Web gives each record it shows its controls.
|
|
81
82
|
- `type RecordRef { contentType, contentId }` A record the host can open, by `contentType` and `contentId`.
|
|
@@ -218,8 +219,10 @@ core's, in the erxes repo on branch `postgre`. The `ui-patterns` skill has the r
|
|
|
218
219
|
- `type TDashboardWidgetPreview` The schematic a dashboard widget shows in the widget catalog.
|
|
219
220
|
- `type TPanelRecordType { contentType, title, icon, detailPath, Title, … }` A record type a plugin shows in core's side panel.
|
|
220
221
|
- `type TPluginSettingsPage { path, label, icon }` A plugin's settings page, linked from core's settings sidebar.
|
|
222
|
+
- `type TPropertyValue` A custom field's value: text, number, date, yes/no or options.
|
|
221
223
|
- `type TRecordContacts { customerIds, companyIds }` The customers and companies a record is about.
|
|
222
224
|
- `type TRecordDraftProps { defaults, onCreated, onCancel }` Props of a plugin record type's `New` slot, the draft form.
|
|
225
|
+
- `type TRecordProperties { type, values, save }` Custom fields on a plugin record type, whose values the plugin keeps.
|
|
223
226
|
- `type TRecordSection { contentType, title, icon, component }` A plugin's section on a customer's or company's detail in core's panel.
|
|
224
227
|
- `type TRecordSectionProps { contentType, contentId }` What a record section is given: the customer or company it shows on.
|
|
225
228
|
- `type TRecordSlotProps` What each slot of a plugin record is given: the record.
|
|
@@ -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
|
@@ -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 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;
|
|
@@ -67,12 +67,20 @@ export declare const RecordPanelProvider: import("react").Context<RecordPanelCon
|
|
|
67
67
|
* Null outside a record (a plugin page on its own).
|
|
68
68
|
*/
|
|
69
69
|
export declare const useRecordPanel: () => RecordPanelControls | null;
|
|
70
|
+
/** A `RecordPage`'s record, and the list it goes back to. */
|
|
71
|
+
export interface RecordPageProps extends RecordRef {
|
|
72
|
+
/**
|
|
73
|
+
* The list closing or deleting the record goes back to, e.g. its team's tasks; without it, the
|
|
74
|
+
* plugin's first page. Pass it once the record is known.
|
|
75
|
+
*/
|
|
76
|
+
listPath?: string;
|
|
77
|
+
}
|
|
70
78
|
/** Web registers how a record draws on its own page. */
|
|
71
|
-
export declare const setRecordPage: (component: import("react").ComponentType<
|
|
79
|
+
export declare const setRecordPage: (component: import("react").ComponentType<RecordPageProps> | null) => void;
|
|
72
80
|
/**
|
|
73
81
|
* A record on its own page, as core draws a customer's.
|
|
74
82
|
* The record's View at full size, under the page header, with Back to its list. A plugin
|
|
75
|
-
* routes its record type's `
|
|
83
|
+
* routes its record type's `detailPath` to `<RecordPage contentType="sales:deal" contentId={id} listPath="/sales/deals" />`.
|
|
76
84
|
*/
|
|
77
|
-
export declare const RecordPage: (props:
|
|
85
|
+
export declare const RecordPage: (props: RecordPageProps) => import("react").JSX.Element | null;
|
|
78
86
|
export {};
|
|
@@ -65,7 +65,7 @@ const setRecordPage = page.set;
|
|
|
65
65
|
/**
|
|
66
66
|
* A record on its own page, as core draws a customer's.
|
|
67
67
|
* The record's View at full size, under the page header, with Back to its list. A plugin
|
|
68
|
-
* routes its record type's `
|
|
68
|
+
* routes its record type's `detailPath` to `<RecordPage contentType="sales:deal" contentId={id} listPath="/sales/deals" />`.
|
|
69
69
|
*/
|
|
70
70
|
const RecordPage = page.Host;
|
|
71
71
|
export { RecordOpenerProvider, RecordPage, RecordPanelProvider, setRecordPage, useOpenRecord, useRecordPanel };
|
package/dist/types/UIConfig.d.ts
CHANGED
|
@@ -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;
|
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
|
|
@@ -51,8 +52,10 @@ type TListViews
|
|
|
51
52
|
type TPanelRecordType
|
|
52
53
|
type TPluginListType
|
|
53
54
|
type TPluginSettingsPage
|
|
55
|
+
type TPropertyValue
|
|
54
56
|
type TRecordContacts
|
|
55
57
|
type TRecordDraftProps
|
|
58
|
+
type TRecordProperties
|
|
56
59
|
type TRecordSection
|
|
57
60
|
type TRecordSectionProps
|
|
58
61
|
type TRecordSlotProps
|