@erxes/ui 4.0.0-v2.10 → 4.0.0-v2.12

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.
Files changed (42) hide show
  1. package/CATALOG.md +10 -3
  2. package/dist/components/combobox.js +4 -1
  3. package/dist/components/dialog.d.ts +5 -2
  4. package/dist/components/dialog.js +19 -10
  5. package/dist/components/field-control.d.ts +16 -0
  6. package/dist/components/field-control.js +19 -0
  7. package/dist/components/form-layout.d.ts +19 -0
  8. package/dist/components/form-layout.js +56 -0
  9. package/dist/components/form.d.ts +9 -2
  10. package/dist/components/form.js +17 -7
  11. package/dist/components/input.js +7 -2
  12. package/dist/components/multiselect.js +4 -1
  13. package/dist/components/popover.js +17 -13
  14. package/dist/components/select.js +16 -11
  15. package/dist/components/sheet.d.ts +5 -2
  16. package/dist/components/sheet.js +18 -9
  17. package/dist/components/textarea.js +4 -1
  18. package/dist/hooks/use-focus-first-field.d.ts +8 -0
  19. package/dist/hooks/use-focus-first-field.js +15 -0
  20. package/dist/hooks/use-page-hotkey.d.ts +2 -0
  21. package/dist/hooks/use-page-hotkey.js +4 -2
  22. package/dist/index.d.ts +4 -2
  23. package/dist/index.js +4 -2
  24. package/dist/lib/render-in-dom.d.ts +6 -0
  25. package/dist/lib/render-in-dom.js +26 -0
  26. package/dist/modules/list/ListFilter.d.ts +7 -1
  27. package/dist/modules/list/ListFilter.js +8 -2
  28. package/dist/modules/list/ViewBar.d.ts +36 -4
  29. package/dist/modules/list/ViewBar.js +33 -9
  30. package/dist/modules/record-field/components/TextField.js +1 -4
  31. package/dist/modules/record-panel/PanelForm.d.ts +12 -4
  32. package/dist/modules/record-panel/PanelForm.js +85 -12
  33. package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/display.BlTmubjj.js +181 -0
  34. package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/index.D0heQG4v.js +987 -0
  35. package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/pathe.M-eThtNZ.zq3TM4NT.js +176 -0
  36. package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/run.CjdgFZiW.js +1509 -0
  37. package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/source-map.DakdQc29.js +687 -0
  38. package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/tinyrainbow.Do8I1XRG.js +85 -0
  39. package/dist/node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/task-utils.js +6 -0
  40. package/dist/types/UIConfig.d.ts +5 -5
  41. package/exports.txt +7 -0
  42. package/package.json +4 -1
@@ -1,12 +1,14 @@
1
1
  import { useHotkeys } from "react-hotkeys-hook";
2
2
  // src/hooks/use-page-hotkey.ts
3
3
  const OVERLAY = "[role=\"dialog\"], [role=\"alertdialog\"], [role=\"menu\"], [role=\"listbox\"]";
4
+ /** Whether a dialog, menu or list is shown, other than one that holds `inside`. */
5
+ const isOverlayShown = (inside) => Array.from(document.querySelectorAll(OVERLAY)).some((overlay) => !(inside && overlay.contains(inside)) && overlay.getClientRects().length > 0);
4
6
  /**
5
7
  * Keys meant for something else: a repeat, an IME composition, a key a handler already took,
6
8
  * one typed into a text box, or any key while an overlay is shown. react-hotkeys-hook already
7
9
  * skips inputs, textareas, selects and contenteditable editors.
8
10
  */
9
- const meantElsewhere = (event) => event.repeat || event.isComposing || event.defaultPrevented || event.target instanceof Element && event.target.closest("[role=\"textbox\"]") !== null || Array.from(document.querySelectorAll(OVERLAY)).some((overlay) => overlay.getClientRects().length > 0);
11
+ const meantElsewhere = (event) => event.repeat || event.isComposing || event.defaultPrevented || event.target instanceof Element && event.target.closest("[role=\"textbox\"]") !== null || isOverlayShown();
10
12
  /**
11
13
  * A page shortcut, skipped while typing or while a dialog or menu is open.
12
14
  * Examples: `c` adds, `f` filters, `/` focuses the description, `mod+shift+enter` expands the
@@ -19,4 +21,4 @@ const usePageHotkey = (keys, action, { when, useKey } = {}) => useHotkeys(keys,
19
21
  preventDefault: true,
20
22
  ignoreEventWhen: (event) => meantElsewhere(event) || when?.() === false
21
23
  });
22
- export { usePageHotkey };
24
+ export { isOverlayShown, usePageHotkey };
package/dist/index.d.ts CHANGED
@@ -25,6 +25,7 @@ import { Dialog } from "./components/dialog.js";
25
25
  import { DragHandle } from "./components/drag-handle.js";
26
26
  import { DropdownMenu } from "./components/dropdown-menu.js";
27
27
  import { Empty } from "./components/empty.js";
28
+ import { useFieldControl } from "./components/field-control.js";
28
29
  import { Form } from "./components/form.js";
29
30
  import { HoverCard } from "./components/hover-card.js";
30
31
  import { IconTip } from "./components/icon-tip.js";
@@ -58,6 +59,7 @@ import { Upload } from "./components/upload.js";
58
59
  import { useConfirm } from "./hooks/use-confirm.js";
59
60
  import { useItemKeys } from "./hooks/use-item-keys.js";
60
61
  import { usePageHotkey } from "./hooks/use-page-hotkey.js";
62
+ import { useFocusFirstField } from "./hooks/use-focus-first-field.js";
61
63
  import { toast, useToast } from "./hooks/use-toast.js";
62
64
  import { useUpload } from "./hooks/use-upload.js";
63
65
  import { cn } from "./lib/utils.js";
@@ -105,7 +107,7 @@ import { ListFilter, TListFilterField, TListFilterProps, useListFilterParams } f
105
107
  import { listFilterQuery } from "./modules/list/filter/listFilterQuery.js";
106
108
  import { TConditionField, TConditionGroup, TConditionLookups, TConditionRule, isRule } from "./modules/conditions/conditions.js";
107
109
  import { ConditionsEditor } from "./modules/conditions/LazyConditionsEditor.js";
108
- import { ViewBar } from "./modules/list/ViewBar.js";
110
+ import { ListViewsProvider, TListViews, TPluginListType, TViewTabsProps, ViewBar, useListViews } from "./modules/list/ViewBar.js";
109
111
  import { PanelDescriptionEditor } from "./modules/record-panel/PanelDescriptionEditor.js";
110
112
  import { PanelDescriptionField } from "./modules/record-panel/PanelDescriptionField.js";
111
113
  import { PanelField, PanelFieldTrigger } from "./modules/record-panel/PanelField.js";
@@ -128,4 +130,4 @@ import { jsonOf } from "./utils/json.js";
128
130
  import { PluginLiveMessage, PluginRuntime, PluginSession, getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
129
131
  import { addPluginStyles } from "./utils/plugin-styles.js";
130
132
  import { RecordTimeline, RecordTimelineProps, setRecordTimeline } from "./utils/record-timeline.js";
131
- 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, ContextMenu, CopyText, type CustomerContact, 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, 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 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 TActivityRowProps, type TConditionField, type TConditionGroup, type TConditionLookups, type TConditionRule, type TContactContentType, type TDashboardWidgetPreview, type TListDisplay, type TListFilterField, type TListFilterProps, type TPanelRecordType, type TPropertyInputMeta, type TPropertyInputProps, type TRecordContacts, type TRecordDraftProps, type TRecordSection, type TRecordSectionProps, type TRecordSlotProps, type TRecordTab, type TRelationTab, type TRelationTabProps, 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, useFilterContext, useFormat, useItemKeys, useListDisplay, useListFilterParams, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, 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, ContextMenu, CopyText, type CustomerContact, 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, 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 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 TActivityRowProps, type TConditionField, type TConditionGroup, type TConditionLookups, type TConditionRule, type TContactContentType, type TDashboardWidgetPreview, type TListDisplay, type TListFilterField, type TListFilterProps, type TListViews, type TPanelRecordType, type TPluginListType, type TPropertyInputMeta, type TPropertyInputProps, type TRecordContacts, type TRecordDraftProps, type TRecordSection, type TRecordSectionProps, type TRecordSlotProps, type TRecordTab, 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, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ import { Dialog } from "./components/dialog.js";
24
24
  import { DragHandle } from "./components/drag-handle.js";
25
25
  import { DropdownMenu } from "./components/dropdown-menu.js";
26
26
  import { Empty } from "./components/empty.js";
27
+ import { useFieldControl } from "./components/field-control.js";
27
28
  import { Form } from "./components/form.js";
28
29
  import { HoverCard } from "./components/hover-card.js";
29
30
  import { IconTip } from "./components/icon-tip.js";
@@ -56,6 +57,7 @@ import { Upload } from "./components/upload.js";
56
57
  import { useConfirm } from "./hooks/use-confirm.js";
57
58
  import { useItemKeys } from "./hooks/use-item-keys.js";
58
59
  import { usePageHotkey } from "./hooks/use-page-hotkey.js";
60
+ import { useFocusFirstField } from "./hooks/use-focus-first-field.js";
59
61
  import { toast, useToast } from "./hooks/use-toast.js";
60
62
  import { useUpload } from "./hooks/use-upload.js";
61
63
  import { cn } from "./lib/utils.js";
@@ -101,7 +103,7 @@ import { ListFilter, useListFilterParams } from "./modules/list/ListFilter.js";
101
103
  import { listFilterQuery } from "./modules/list/filter/listFilterQuery.js";
102
104
  import { isRule } from "./modules/conditions/conditions.js";
103
105
  import { ConditionsEditor } from "./modules/conditions/LazyConditionsEditor.js";
104
- import { ViewBar } from "./modules/list/ViewBar.js";
106
+ import { ListViewsProvider, ViewBar, useListViews } from "./modules/list/ViewBar.js";
105
107
  import { PanelDescriptionEditor } from "./modules/record-panel/PanelDescriptionEditor.js";
106
108
  import { PanelDescriptionField } from "./modules/record-panel/PanelDescriptionField.js";
107
109
  import { PanelField, PanelFieldTrigger } from "./modules/record-panel/PanelField.js";
@@ -123,4 +125,4 @@ import { jsonOf } from "./utils/json.js";
123
125
  import { getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
124
126
  import { addPluginStyles } from "./utils/plugin-styles.js";
125
127
  import { RecordTimeline, setRecordTimeline } from "./utils/record-timeline.js";
126
- export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, BackgroundGradientAnimation, Badge, Breadcrumb, Button, Calendar, Card, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, ConditionsEditor, ContactLink, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DisplayMenu, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, Filter, Form, FullNameField, FullNameValue, HoverCard, IconComponent, IconPicker, IconTip, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, ListFilter, LookupPicker, MemberInline, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PanelDescriptionEditor, PanelDescriptionField, PanelExpansionContext, PanelField, PanelFieldTrigger, PanelFormLayout, PanelFormRow, PanelLabel, PanelSection, PhoneDisplay, PhoneField, PhoneInput, Popover, PopoverScoped, RadioGroup, RecordList, RecordOpenerProvider, RecordPage, RecordTable, RecordTableInlineCell, RecordTimeline, RelativeDateDisplay, Resizable, ScrollArea, Select, SelectMember, Separator, SexCode, SexDisplay, SexField, Sheet, Sidebar, Skeleton, Slider, Spinner, StringArrayInput, Switch, TabButton, Table, Tabs, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, ViewBar, addPluginStyles, amountStep, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatMoney, formatPhoneNumber, formatter, fromAmountInput, getPluginAssetsUrl, getPluginRuntime, isRule, isUndefinedOrNull, jsonOf, listFilterQuery, localTimeZone, memberName, oneOf, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordPage, setRecordTimeline, stored, storedFamily, textOf, themeState, toAmountInput, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useItemKeys, useListDisplay, useListFilterParams, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
128
+ export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, BackgroundGradientAnimation, Badge, Breadcrumb, Button, Calendar, Card, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, ConditionsEditor, ContactLink, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DisplayMenu, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, Filter, Form, FullNameField, FullNameValue, HoverCard, IconComponent, IconPicker, IconTip, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, ListFilter, ListViewsProvider, LookupPicker, MemberInline, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PanelDescriptionEditor, PanelDescriptionField, PanelExpansionContext, PanelField, PanelFieldTrigger, PanelFormLayout, PanelFormRow, PanelLabel, PanelSection, PhoneDisplay, PhoneField, PhoneInput, Popover, PopoverScoped, RadioGroup, RecordList, RecordOpenerProvider, RecordPage, RecordTable, RecordTableInlineCell, RecordTimeline, RelativeDateDisplay, Resizable, ScrollArea, Select, SelectMember, Separator, SexCode, SexDisplay, SexField, Sheet, Sidebar, Skeleton, Slider, Spinner, StringArrayInput, Switch, TabButton, Table, Tabs, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, ViewBar, addPluginStyles, amountStep, badgeVariants, buttonVariants, cn, companyTitle, customerTitle, editorText, formatMoney, formatPhoneNumber, formatter, fromAmountInput, getPluginAssetsUrl, getPluginRuntime, isRule, isUndefinedOrNull, jsonOf, listFilterQuery, localTimeZone, memberName, oneOf, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordPage, setRecordTimeline, stored, storedFamily, textOf, themeState, toAmountInput, toIsoDay, toast, useConfirm, useFieldControl, useFilterContext, useFocusFirstField, useFormat, useItemKeys, useListDisplay, useListFilterParams, useListViews, useLiveSignal, useMemberOptions, useMembersById, useMoney, useOpenRecord, usePageHotkey, usePanelExpanded, usePreviousHotkeyScope, useScopedHotkeys, useTagOptions, useToast, useUpload, zoneOffset };
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ /**
3
+ * Renders a component into the test's document and returns its container; call it in a
4
+ * `.test.tsx` under happy-dom. Each test starts with an empty document.
5
+ */
6
+ export declare const setupDomRender: () => (node: ReactNode) => HTMLDivElement;
@@ -0,0 +1,26 @@
1
+ import { l as afterEach, q as beforeAll } from "../node_modules/.pnpm/vitest@5.1.0_@opentelemetry_api@1.10.0_@types_node@26.6.6_@vitest_browser-preview@5.1.0_d78d0f63d2a6b1c4a51a56547b330411/node_modules/vitest/dist/chunks/run.CjdgFZiW.js";
2
+ import { act } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ // src/lib/render-in-dom.tsx
5
+ let root;
6
+ /**
7
+ * Renders a component into the test's document and returns its container; call it in a
8
+ * `.test.tsx` under happy-dom. Each test starts with an empty document.
9
+ */
10
+ const setupDomRender = () => {
11
+ beforeAll(() => {
12
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
13
+ });
14
+ afterEach(() => {
15
+ act(() => root?.unmount());
16
+ document.body.innerHTML = "";
17
+ });
18
+ return (node) => {
19
+ const container = document.createElement("div");
20
+ document.body.append(container);
21
+ root = createRoot(container);
22
+ act(() => root?.render(node));
23
+ return container;
24
+ };
25
+ };
26
+ export { setupDomRender };
@@ -1,4 +1,5 @@
1
1
  import { TConditionLookups } from "../conditions/conditions.js";
2
+ import { TPluginListType } from "./ViewBar.js";
2
3
  import { ElementType, ReactNode } from "react";
3
4
  /**
4
5
  * A field a list can filter by, for `ListFilter`'s `fields`.
@@ -41,6 +42,11 @@ export type TListFilterProps = TConditionLookups & {
41
42
  error?: Error | null;
42
43
  /** Beside the chips, before the count: what a saved view changed. */
43
44
  status?: ReactNode;
45
+ /**
46
+ * The list's record type, `<plugin>:<record>`, as its `ViewBar` has it: while the list differs
47
+ * from its saved view, the bar offers to reset it or save it as a view.
48
+ */
49
+ recordType?: TPluginListType;
44
50
  };
45
51
  /**
46
52
  * A list's filter bar, with a field menu, search and conditions as chips.
@@ -51,7 +57,7 @@ export type TListFilterProps = TConditionLookups & {
51
57
  * `@erxes/core-contract/client` and the tags query of the record type; outside erxes, the
52
58
  * plugin's own.
53
59
  */
54
- export declare const ListFilter: (props: TListFilterProps) => import("react").JSX.Element;
60
+ export declare const ListFilter: ({ recordType, ...props }: TListFilterProps) => import("react").JSX.Element;
55
61
  /**
56
62
  * `ListFilter`'s conditions and search, as params for the list's query.
57
63
  * `filter` is core's condition group (`ConditionGroup` from `@erxes/core-contract`) as JSON,
@@ -1,5 +1,6 @@
1
1
  import { Filter } from "../filter/components/Filter.js";
2
2
  import { useListConditions } from "./filter/listFilterQuery.js";
3
+ import { useListViews } from "./ViewBar.js";
3
4
  import { jsx } from "react/jsx-runtime";
4
5
  import { Suspense, lazy } from "react";
5
6
  import { useAutoAnimate } from "@formkit/auto-animate/react";
@@ -18,14 +19,19 @@ const ListFilterBar = lazy(async () => ({ default: (await import("./filter/ListF
18
19
  * `@erxes/core-contract/client` and the tags query of the record type; outside erxes, the
19
20
  * plugin's own.
20
21
  */
21
- const ListFilter = (props) => {
22
+ const ListFilter = ({ recordType, ...props }) => {
22
23
  const [barRef] = useAutoAnimate({ duration: 150 });
24
+ const host = useListViews();
25
+ const status = props.status ?? (recordType && host && /* @__PURE__ */ jsx(host.Changes, { recordType }));
23
26
  return /* @__PURE__ */ jsx(Filter, {
24
27
  id: `${props.id}-list-filter`,
25
28
  children: /* @__PURE__ */ jsx(Filter.Bar, {
26
29
  ref: barRef,
27
30
  className: "min-w-0 flex-nowrap justify-end",
28
- children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ListFilterBar, { ...props }) })
31
+ children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ListFilterBar, {
32
+ ...props,
33
+ status
34
+ }) })
29
35
  })
30
36
  });
31
37
  };
@@ -1,12 +1,44 @@
1
- import { ReactNode } from "react";
1
+ import { ComponentType, ReactNode } from "react";
2
+ /** A plugin's list: its record type, `<plugin>:<record>` (`sales:deal`). */
3
+ export type TPluginListType = `${string}:${string}`;
4
+ /** The props of the host's saved-view tabs: the list and its "All …" label. */
5
+ export type TViewTabsProps = {
6
+ recordType: TPluginListType;
7
+ allLabel: string;
8
+ };
9
+ /**
10
+ * The host's saved views for a list.
11
+ * Their tabs, and the filter's reset and save while the list differs.
12
+ */
13
+ export type TListViews = {
14
+ Tabs: ComponentType<TViewTabsProps>;
15
+ Changes: ComponentType<{
16
+ recordType: TPluginListType;
17
+ }>;
18
+ };
19
+ /** The host's saved views, for `ViewBar` and `ListFilter`. Null outside erxes. */
20
+ export declare const useListViews: () => TListViews | null;
21
+ /**
22
+ * Gives every list with a `recordType` saved views, as core's lists have.
23
+ * Web provides its tabs (save, rename, share, copy a link) and the filter's save, once, around
24
+ * the app.
25
+ */
26
+ export declare const ListViewsProvider: ({ views, children }: {
27
+ views: TListViews;
28
+ children: ReactNode;
29
+ }) => import("react").JSX.Element;
2
30
  /**
3
31
  * A list's one bar under its page header: views left, filter right.
4
32
  * The filter is `ListFilter`, with `DisplayMenu` inside it. The first tab's icon lines up with
5
- * the page header's first crumb. Without `tabs` the list has one view, "All …" (`allLabel`).
33
+ * the page header's first crumb. With `recordType` (`sales:deal`), the member's saved views of
34
+ * that list show as tabs, as on core's lists; without it the list has one view, "All …"
35
+ * (`allLabel`).
6
36
  */
7
- export declare const ViewBar: ({ allLabel, tabs, children }: {
37
+ export declare const ViewBar: ({ allLabel, recordType, tabs, children }: {
8
38
  allLabel: string;
9
- /** Saved views as tabs; core's own lists pass theirs. */
39
+ /** The list's record type, `<plugin>:<record>`: its saved views show as tabs. */
40
+ recordType?: TPluginListType;
41
+ /** Tabs of the list's own instead. */
10
42
  tabs?: ReactNode;
11
43
  /** The list's filter. */
12
44
  children?: ReactNode;
@@ -1,30 +1,54 @@
1
1
  import { TabButton } from "../../components/tabs.js";
2
2
  import { IconLayoutList } from "@tabler/icons-react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { Suspense, createContext, use } from "react";
4
5
  import { useAutoAnimate } from "@formkit/auto-animate/react";
5
6
  // src/modules/list/ViewBar.tsx
7
+ const ListViewsContext = createContext(null);
8
+ /** The host's saved views, for `ViewBar` and `ListFilter`. Null outside erxes. */
9
+ const useListViews = () => use(ListViewsContext);
10
+ /**
11
+ * Gives every list with a `recordType` saved views, as core's lists have.
12
+ * Web provides its tabs (save, rename, share, copy a link) and the filter's save, once, around
13
+ * the app.
14
+ */
15
+ const ListViewsProvider = ({ views, children }) => /* @__PURE__ */ jsx(ListViewsContext, {
16
+ value: views,
17
+ children
18
+ });
6
19
  /**
7
20
  * A list's one bar under its page header: views left, filter right.
8
21
  * The filter is `ListFilter`, with `DisplayMenu` inside it. The first tab's icon lines up with
9
- * the page header's first crumb. Without `tabs` the list has one view, "All …" (`allLabel`).
22
+ * the page header's first crumb. With `recordType` (`sales:deal`), the member's saved views of
23
+ * that list show as tabs, as on core's lists; without it the list has one view, "All …"
24
+ * (`allLabel`).
10
25
  */
11
- const ViewBar = ({ allLabel, tabs, children }) => {
26
+ const ViewBar = ({ allLabel, recordType, tabs, children }) => {
12
27
  const [tabsRef] = useAutoAnimate({ duration: 150 });
28
+ const host = useListViews();
29
+ const all = /* @__PURE__ */ jsxs(TabButton, {
30
+ type: "button",
31
+ "aria-current": "page",
32
+ active: true,
33
+ children: [/* @__PURE__ */ jsx(IconLayoutList, {}), allLabel]
34
+ });
35
+ const saved = recordType && host && /* @__PURE__ */ jsx(Suspense, {
36
+ fallback: all,
37
+ children: /* @__PURE__ */ jsx(host.Tabs, {
38
+ recordType,
39
+ allLabel
40
+ })
41
+ });
13
42
  return /* @__PURE__ */ jsxs("div", {
14
43
  className: "flex h-10 shrink-0 items-center gap-3 border-b bg-background pr-3",
15
44
  children: [/* @__PURE__ */ jsx("div", {
16
45
  ref: tabsRef,
17
46
  className: "flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto p-1 hide-scroll",
18
- children: tabs ?? /* @__PURE__ */ jsxs(TabButton, {
19
- type: "button",
20
- "aria-current": "page",
21
- active: true,
22
- children: [/* @__PURE__ */ jsx(IconLayoutList, {}), allLabel]
23
- })
47
+ children: tabs ?? saved ?? all
24
48
  }), /* @__PURE__ */ jsx("div", {
25
49
  className: "flex min-w-0 max-w-13/20 shrink-0 items-center justify-end",
26
50
  children
27
51
  })]
28
52
  });
29
53
  };
30
- export { ViewBar };
54
+ export { ListViewsProvider, ViewBar, useListViews };
@@ -1,10 +1,9 @@
1
1
  import { Input } from "../../../components/input.js";
2
2
  import { TextOverflowTooltip } from "../../../components/text-overflow.js";
3
3
  import { PopoverScoped } from "../../hotkey/components/PopoverScoped.js";
4
- import { CellColumnHead } from "../../record-table/components/RecordTableCell.js";
5
4
  import { RecordTableInlineCell } from "../../record-table/components/RecordTableCellInline.js";
6
5
  import { jsx, jsxs } from "react/jsx-runtime";
7
- import { use, useState } from "react";
6
+ import { useState } from "react";
8
7
  // src/modules/record-field/components/TextField.tsx
9
8
  /**
10
9
  * A text value in a table cell or panel row that edits in a popover.
@@ -14,7 +13,6 @@ const TextField = ({ ref, placeholder, value, scope, onSave, onValueChange, defa
14
13
  const [isOpen, setIsOpen] = useState(defaultOpen);
15
14
  const [editingValue, setEditingValue] = useState(value);
16
15
  const shown = isOpen ? editingValue : value;
17
- const labelled = use(CellColumnHead) !== void 0;
18
16
  /** Saves a changed text value and closes the inline editor. */
19
17
  const handleAction = (e) => {
20
18
  e?.preventDefault();
@@ -48,7 +46,6 @@ const TextField = ({ ref, placeholder, value, scope, onSave, onValueChange, defa
48
46
  ...props,
49
47
  ref,
50
48
  children: [children, shown ? /* @__PURE__ */ jsx(TextOverflowTooltip, { value: shown }) : /* @__PURE__ */ jsx("span", {
51
- "aria-hidden": labelled,
52
49
  className: "truncate",
53
50
  children: placeholder
54
51
  })]
@@ -1,18 +1,26 @@
1
1
  import { Icon } from "@tabler/icons-react";
2
2
  /**
3
- * One field of a new record's form, laid out like `PanelField`.
4
- * Its label, then the input, with the field's error under it.
3
+ * One field of a form in the side panel, laid out like `PanelField`.
4
+ * Icon and label, then the control, with its error, or else its hint, under it. A long label wraps to two lines (the
5
+ * full text on hover) instead of being cut. `htmlFor` names the control by its id, so a click
6
+ * on the label focuses it and a switch toggles. The input, select or picker in the row is named
7
+ * by the label and described by the error or hint, and marked invalid and required with it.
5
8
  */
6
- export declare const PanelFormRow: ({ label, icon: Icon, required, error, children }: {
9
+ export declare const PanelFormRow: ({ label, icon: Icon, required, error, hint, htmlFor, children }: {
7
10
  label: React.ReactNode;
8
11
  icon?: Icon;
9
12
  required?: boolean;
10
13
  error?: string;
14
+ /** What the field takes or does, under the control while it has no error. */
15
+ hint?: React.ReactNode;
16
+ /** The control's id. */
17
+ htmlFor?: string;
11
18
  children: React.ReactNode;
12
19
  }) => import("react").JSX.Element;
13
20
  /**
14
21
  * A new record's form in the side panel: its rows, then Cancel and Save.
15
- * Nothing is saved until Save.
22
+ * Nothing is saved until Save. The first field takes focus when it opens; Enter in a field
23
+ * saves, and Escape cancels (asking first once something was typed).
16
24
  */
17
25
  export declare const PanelFormLayout: ({ children, onCancel, saving, saveLabel }: {
18
26
  children: React.ReactNode;
@@ -1,61 +1,133 @@
1
1
  import { Button } from "../../components/button.js";
2
+ import { FieldControlContext } from "../../components/field-control.js";
2
3
  import { Spinner } from "../../components/spinner.js";
4
+ import { useConfirm } from "../../hooks/use-confirm.js";
5
+ import { useFocusFirstField } from "../../hooks/use-focus-first-field.js";
6
+ import { isOverlayShown } from "../../hooks/use-page-hotkey.js";
3
7
  import { RecordTableInlineCell } from "../record-table/components/RecordTableCellInline.js";
4
8
  import { PanelLabel } from "./PanelLabel.js";
5
9
  import { IconForms } from "@tabler/icons-react";
6
10
  import { jsx, jsxs } from "react/jsx-runtime";
7
- import { useId } from "react";
11
+ import { useEffect, useId, useRef } from "react";
8
12
  import { useTranslation } from "react-i18next";
13
+ import { useHotkeys } from "react-hotkeys-hook";
9
14
  // src/modules/record-panel/PanelForm.tsx
10
15
  /**
11
- * One field of a new record's form, laid out like `PanelField`.
12
- * Its label, then the input, with the field's error under it.
16
+ * One field of a form in the side panel, laid out like `PanelField`.
17
+ * Icon and label, then the control, with its error, or else its hint, under it. A long label wraps to two lines (the
18
+ * full text on hover) instead of being cut. `htmlFor` names the control by its id, so a click
19
+ * on the label focuses it and a switch toggles. The input, select or picker in the row is named
20
+ * by the label and described by the error or hint, and marked invalid and required with it.
13
21
  */
14
- const PanelFormRow = ({ label, icon: Icon = IconForms, required, error, children }) => {
22
+ const PanelFormRow = ({ label, icon: Icon = IconForms, required, error, hint, htmlFor, children }) => {
15
23
  const labelId = useId();
24
+ const messageId = useId();
25
+ const LabelTag = htmlFor ? "label" : "span";
26
+ const field = {
27
+ "aria-labelledby": labelId,
28
+ "aria-describedby": error || hint ? messageId : void 0,
29
+ "aria-invalid": error ? true : void 0,
30
+ "aria-required": required ? true : void 0
31
+ };
16
32
  return /* @__PURE__ */ jsxs("div", {
17
- className: "grid grid-cols-field items-center gap-x-2 gap-y-0.5 min-h-7",
33
+ className: "grid grid-cols-field items-start gap-x-2 gap-y-0.5",
18
34
  children: [
19
- /* @__PURE__ */ jsxs("span", {
35
+ /* @__PURE__ */ jsxs(LabelTag, {
20
36
  id: labelId,
21
- className: "flex min-w-0 items-center gap-1.5 text-xs font-medium text-accent-foreground",
37
+ htmlFor,
38
+ className: "flex min-h-7 min-w-0 items-center gap-1.5 text-xs font-medium text-accent-foreground",
22
39
  children: [/* @__PURE__ */ jsx(Icon, {
23
- className: "size-3.5 shrink-0",
40
+ className: "mt-1.75 size-3.5 shrink-0 self-start",
24
41
  "aria-hidden": "true"
25
42
  }), /* @__PURE__ */ jsxs(PanelLabel, {
26
43
  tooltip: label,
27
44
  children: [label, required && /* @__PURE__ */ jsx("span", {
45
+ "aria-hidden": "true",
28
46
  className: "text-destructive",
29
47
  children: " *"
30
48
  })]
31
49
  })]
32
50
  }),
33
51
  /* @__PURE__ */ jsxs("div", {
34
- className: "group/panel-value relative min-w-0 text-xs [&_button:not([role=switch])]:text-xs [&_input:placeholder-shown]:pl-7",
52
+ className: "group/panel-value relative flex min-h-7 min-w-0 flex-col justify-center text-xs [&_button:not([role=switch])]:text-xs [&_input]:text-xs [&_input:placeholder-shown]:pl-7",
35
53
  children: [/* @__PURE__ */ jsx(Icon, {
36
54
  className: "pointer-events-none absolute left-2 top-1/2 z-1 hidden size-3.5 -translate-y-1/2 text-muted-foreground group-has-[input:placeholder-shown]/panel-value:block",
37
55
  "aria-hidden": "true"
38
56
  }), /* @__PURE__ */ jsx(RecordTableInlineCell.LabelledBy, {
39
57
  value: labelId,
40
- children
58
+ children: /* @__PURE__ */ jsx(FieldControlContext, {
59
+ value: field,
60
+ children
61
+ })
41
62
  })]
42
63
  }),
43
- error && /* @__PURE__ */ jsx("span", {
64
+ error ? /* @__PURE__ */ jsx("span", {
65
+ id: messageId,
66
+ role: "alert",
44
67
  className: "col-start-2 text-xs text-destructive",
45
68
  children: error
69
+ }) : hint && /* @__PURE__ */ jsx("span", {
70
+ id: messageId,
71
+ className: "col-start-2 text-xs text-muted-foreground",
72
+ children: hint
46
73
  })
47
74
  ]
48
75
  });
49
76
  };
50
77
  /**
78
+ * Escape while focus is in the form leaves it, once the member agrees to drop what they typed.
79
+ * Returns the ref for the form's root; `bodyRef` holds its fields. A picker, menu or dialog keeps
80
+ * its own Escape: focus is in its popup then, outside the form.
81
+ */
82
+ const useEscapeToCancel = (bodyRef, onCancel, saving) => {
83
+ const { t } = useTranslation("common", { keyPrefix: "form" });
84
+ const { confirm } = useConfirm();
85
+ const touched = useRef(false);
86
+ useEffect(() => {
87
+ const body = bodyRef.current;
88
+ const onInput = () => {
89
+ touched.current = true;
90
+ };
91
+ body?.addEventListener("input", onInput);
92
+ return () => body?.removeEventListener("input", onInput);
93
+ }, [bodyRef]);
94
+ return useHotkeys("esc", () => {
95
+ if (!touched.current) {
96
+ onCancel();
97
+ return;
98
+ }
99
+ confirm({
100
+ message: t("discard-title", "Discard this draft?"),
101
+ options: {
102
+ description: t("discard-description", "What you typed here is not saved."),
103
+ okLabel: t("discard", "Discard"),
104
+ cancelLabel: t("keep-editing", "Keep editing"),
105
+ variants: { ok: "destructive" }
106
+ }
107
+ }).then(onCancel);
108
+ }, {
109
+ enableOnFormTags: true,
110
+ enableOnContentEditable: true,
111
+ preventDefault: true,
112
+ ignoreEventWhen: (event) => Boolean(saving) || event.defaultPrevented || isOverlayShown(bodyRef.current)
113
+ });
114
+ };
115
+ /**
51
116
  * A new record's form in the side panel: its rows, then Cancel and Save.
52
- * Nothing is saved until Save.
117
+ * Nothing is saved until Save. The first field takes focus when it opens; Enter in a field
118
+ * saves, and Escape cancels (asking first once something was typed).
53
119
  */
54
120
  const PanelFormLayout = ({ children, onCancel, saving, saveLabel }) => {
55
121
  const { t } = useTranslation("common", { keyPrefix: "side-panel" });
122
+ const bodyRef = useRef(null);
123
+ const rootRef = useEscapeToCancel(bodyRef, onCancel, saving);
124
+ useFocusFirstField(bodyRef);
56
125
  return /* @__PURE__ */ jsxs("div", {
126
+ ref: rootRef,
57
127
  className: "flex flex-1 min-h-0 flex-col",
128
+ "aria-busy": saving ? true : void 0,
58
129
  children: [/* @__PURE__ */ jsx("div", {
130
+ ref: bodyRef,
59
131
  className: "flex-1 min-h-0 overflow-y-auto",
60
132
  children: /* @__PURE__ */ jsx("div", {
61
133
  className: "flex flex-col gap-1 p-3",
@@ -67,6 +139,7 @@ const PanelFormLayout = ({ children, onCancel, saving, saveLabel }) => {
67
139
  type: "button",
68
140
  variant: "ghost",
69
141
  size: "sm",
142
+ disabled: saving,
70
143
  onClick: onCancel,
71
144
  children: t("cancel", "Cancel")
72
145
  }), /* @__PURE__ */ jsxs(Button, {