@erxes/ui 4.0.0-v2.11 → 4.0.0-v2.13
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 +9 -2
- package/dist/components/color-picker.js +2 -2
- package/dist/components/combobox.js +4 -1
- package/dist/components/command-bar.js +3 -0
- package/dist/components/dialog.d.ts +5 -2
- package/dist/components/dialog.js +19 -10
- package/dist/components/field-control.d.ts +16 -0
- package/dist/components/field-control.js +19 -0
- package/dist/components/form-layout.d.ts +19 -0
- package/dist/components/form-layout.js +56 -0
- package/dist/components/form.d.ts +9 -2
- package/dist/components/form.js +17 -7
- package/dist/components/input.d.ts +1 -1
- package/dist/components/input.js +9 -4
- package/dist/components/multiselect.js +4 -1
- package/dist/components/on-demand.d.ts +9 -2
- package/dist/components/on-demand.js +15 -1
- package/dist/components/popover.js +17 -13
- package/dist/components/select.js +16 -11
- package/dist/components/sheet.d.ts +5 -2
- package/dist/components/sheet.js +18 -9
- package/dist/components/textarea.js +4 -1
- package/dist/hooks/use-focus-first-field.d.ts +8 -0
- package/dist/hooks/use-focus-first-field.js +15 -0
- package/dist/hooks/use-page-hotkey.d.ts +2 -0
- package/dist/hooks/use-page-hotkey.js +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/lib/render-in-dom.d.ts +6 -0
- package/dist/lib/render-in-dom.js +26 -0
- package/dist/modules/conditions/PathPicker.js +7 -2
- package/dist/modules/conditions/conditions.d.ts +2 -0
- package/dist/modules/filter/components/FilterBar.js +3 -0
- package/dist/modules/list/ListFilter.d.ts +11 -3
- package/dist/modules/list/ListFilter.js +8 -2
- package/dist/modules/list/ViewBar.d.ts +36 -4
- package/dist/modules/list/ViewBar.js +33 -9
- package/dist/modules/list/filter/ListFilterBar.js +11 -4
- package/dist/modules/list/filter/RuleChips.js +1 -5
- package/dist/modules/record-field/components/TextField.js +1 -4
- package/dist/modules/record-panel/PanelForm.d.ts +4 -2
- package/dist/modules/record-panel/PanelForm.js +73 -7
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/exports.txt +7 -0
- package/package.json +4 -1
package/dist/components/sheet.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Button } from "./button.js";
|
|
2
|
-
import {
|
|
2
|
+
import { findFirstField } from "../hooks/use-focus-first-field.js";
|
|
3
|
+
import { cn, mergeRefs } from "../lib/utils.js";
|
|
3
4
|
import { IconX } from "@tabler/icons-react";
|
|
4
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import React from "react";
|
|
@@ -54,14 +55,22 @@ const SheetBackdrop = ({ className, ...props }) => /* @__PURE__ */ jsx(Dialog.Ba
|
|
|
54
55
|
className: cn("fixed inset-0 z-50 bg-black/25 data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-open:duration-200 data-closed:duration-200 data-closed:animation-forwards", className),
|
|
55
56
|
...props
|
|
56
57
|
});
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
/**
|
|
59
|
+
* The backdrop fades in under the panel, which slides in from its side and fades with it.
|
|
60
|
+
* It opens with the cursor in its first field, when it has one.
|
|
61
|
+
*/
|
|
62
|
+
const SheetView = ({ ref, side = "right", size, className, initialFocus, ...props }) => {
|
|
63
|
+
const popupRef = React.useRef(null);
|
|
64
|
+
return /* @__PURE__ */ jsxs(Dialog.Portal, { children: [/* @__PURE__ */ jsx(SheetBackdrop, {}), /* @__PURE__ */ jsx(Dialog.Popup, {
|
|
65
|
+
ref: mergeRefs(popupRef, ref),
|
|
66
|
+
initialFocus: initialFocus ?? (() => findFirstField(popupRef.current) ?? true),
|
|
67
|
+
className: cn(sheetVariants({
|
|
68
|
+
side,
|
|
69
|
+
size
|
|
70
|
+
}), className),
|
|
71
|
+
...props
|
|
72
|
+
})] });
|
|
73
|
+
};
|
|
65
74
|
/** The close icon button in a sheet header. */
|
|
66
75
|
const SheetClose = ({ className }) => {
|
|
67
76
|
const { t } = useTranslation();
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { useFieldControl } from "./field-control.js";
|
|
1
2
|
import { fieldTextVariants } from "./input.js";
|
|
2
3
|
import { cn } from "../lib/utils.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import "react";
|
|
5
6
|
import { cva } from "class-variance-authority";
|
|
6
7
|
// src/components/textarea.tsx
|
|
7
|
-
const textareaVariants = cva("flex min-h-15 w-full rounded bg-transparent px-3 py-1.5 text-sm shadow-xs transition placeholder:text-accent-foreground focus-visible:outline-hidden focus-visible:shadow-focus disabled:cursor-not-allowed disabled:opacity-50", {
|
|
8
|
+
const textareaVariants = cva("flex min-h-15 w-full rounded bg-transparent px-3 py-1.5 text-sm shadow-xs transition placeholder:text-accent-foreground focus-visible:outline-hidden focus-visible:shadow-focus disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:shadow-destructive aria-invalid:focus-visible:shadow-focus-destructive", {
|
|
8
9
|
variants: {
|
|
9
10
|
variant: {
|
|
10
11
|
default: "",
|
|
@@ -21,7 +22,9 @@ const textareaVariants = cva("flex min-h-15 w-full rounded bg-transparent px-3 p
|
|
|
21
22
|
});
|
|
22
23
|
/** A themed multi-line text box; `flat` and `ghost` drop the border. */
|
|
23
24
|
const Textarea = ({ ref, className, variant, text, truncate, ...props }) => {
|
|
25
|
+
const field = useFieldControl();
|
|
24
26
|
return /* @__PURE__ */ jsx("textarea", {
|
|
27
|
+
...field,
|
|
25
28
|
className: cn(textareaVariants({
|
|
26
29
|
variant,
|
|
27
30
|
text,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
/** The first field to type into under `root`, if it has one. */
|
|
3
|
+
export declare const findFirstField: (root: Element | null | undefined) => HTMLElement | null;
|
|
4
|
+
/**
|
|
5
|
+
* Puts the cursor in the first field under `ref` when the form opens. For a page or panel whose
|
|
6
|
+
* one job is that form; it doesn't scroll the field into view.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useFocusFirstField: (ref: RefObject<HTMLElement | null>) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
// src/hooks/use-focus-first-field.ts
|
|
3
|
+
const FIRST_FIELD = "input:not([type=hidden],[type=file],[type=checkbox],[type=radio],:disabled), textarea:not(:disabled)";
|
|
4
|
+
/** The first field to type into under `root`, if it has one. */
|
|
5
|
+
const findFirstField = (root) => root?.querySelector(FIRST_FIELD) ?? null;
|
|
6
|
+
/**
|
|
7
|
+
* Puts the cursor in the first field under `ref` when the form opens. For a page or panel whose
|
|
8
|
+
* one job is that form; it doesn't scroll the field into view.
|
|
9
|
+
*/
|
|
10
|
+
const useFocusFirstField = (ref) => {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
findFirstField(ref.current)?.focus({ preventScroll: true });
|
|
13
|
+
}, [ref]);
|
|
14
|
+
};
|
|
15
|
+
export { findFirstField, useFocusFirstField };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Keys } from "react-hotkeys-hook";
|
|
2
|
+
/** Whether a dialog, menu or list is shown, other than one that holds `inside`. */
|
|
3
|
+
export declare const isOverlayShown: (inside?: Element | null) => boolean;
|
|
2
4
|
/**
|
|
3
5
|
* A page shortcut, skipped while typing or while a dialog or menu is open.
|
|
4
6
|
* Examples: `c` adds, `f` filters, `/` focuses the description, `mod+shift+enter` expands the
|
|
@@ -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 ||
|
|
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 };
|
|
@@ -11,14 +11,19 @@ const GROUP_LABELS = {
|
|
|
11
11
|
activity: "Activity"
|
|
12
12
|
};
|
|
13
13
|
const CUSTOM_PATH = "__custom__";
|
|
14
|
-
|
|
14
|
+
/** A heading per group, and one per `groupLabel` (a plugin's fields under its title). */
|
|
15
|
+
const groupOf = (field) => field.groupLabel ? `label:${field.groupLabel}` : field.group ?? "fields";
|
|
15
16
|
const FieldItems = ({ fields }) => fields.map((field) => /* @__PURE__ */ jsx(Select.Item, {
|
|
16
17
|
value: field.path,
|
|
17
18
|
children: field.label
|
|
18
19
|
}, field.path));
|
|
19
20
|
const GroupedFieldItems = ({ fields }) => {
|
|
20
21
|
const { t } = useTranslation("automations");
|
|
21
|
-
return [...new Set(fields.map(groupOf))].map((group) =>
|
|
22
|
+
return [...new Set(fields.map(groupOf))].map((group) => {
|
|
23
|
+
const inGroup = fields.filter((field) => groupOf(field) === group);
|
|
24
|
+
const label = inGroup[0]?.groupLabel;
|
|
25
|
+
return /* @__PURE__ */ jsxs(Select.Group, { children: [/* @__PURE__ */ jsx(Select.Label, { children: label ?? t(`field-group.${group}`, GROUP_LABELS[group] ?? group) }), /* @__PURE__ */ jsx(FieldItems, { fields: inGroup })] }, group);
|
|
26
|
+
});
|
|
22
27
|
};
|
|
23
28
|
/** A field from the catalog, or any path typed by hand (`event.payload.amount`, `steps.x.output.y`). */
|
|
24
29
|
const PathPicker = ({ value, fields, onChange, disabled }) => {
|
|
@@ -41,6 +41,8 @@ export type TConditionField = {
|
|
|
41
41
|
type: string;
|
|
42
42
|
options?: string[];
|
|
43
43
|
group?: string;
|
|
44
|
+
/** The heading to list it under instead of the group's own (a plugin's title). */
|
|
45
|
+
groupLabel?: string;
|
|
44
46
|
/** A money amount, stored in this currency's smallest unit and typed in its major unit. */
|
|
45
47
|
currency?: string;
|
|
46
48
|
};
|
|
@@ -4,6 +4,7 @@ import { useFilterContext } from "../hooks/useFilterContext.js";
|
|
|
4
4
|
import { IconSearch, IconX } from "@tabler/icons-react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import "react";
|
|
7
|
+
import { useTranslation } from "react-i18next";
|
|
7
8
|
import { useQueryState } from "nuqs";
|
|
8
9
|
// src/modules/filter/components/FilterBar.tsx
|
|
9
10
|
const FilterBar = ({ ref, className, ...props }) => {
|
|
@@ -15,11 +16,13 @@ const FilterBar = ({ ref, className, ...props }) => {
|
|
|
15
16
|
};
|
|
16
17
|
const FilterBarCloseButton = ({ ref, className, filterKey, ...props }) => {
|
|
17
18
|
const [, setQuery] = useQueryState(filterKey ?? "");
|
|
19
|
+
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
18
20
|
return /* @__PURE__ */ jsx(Button, {
|
|
19
21
|
ref,
|
|
20
22
|
variant: "segment",
|
|
21
23
|
size: "icon",
|
|
22
24
|
className,
|
|
25
|
+
"aria-label": t("remove", "Remove filter"),
|
|
23
26
|
onClick: () => void setQuery(null),
|
|
24
27
|
...props,
|
|
25
28
|
children: /* @__PURE__ */ jsx(IconX, {})
|
|
@@ -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`.
|
|
@@ -20,8 +21,10 @@ export type TListFilterField = {
|
|
|
20
21
|
}[];
|
|
21
22
|
/** Instead of the type's icon. */
|
|
22
23
|
icon?: ElementType;
|
|
23
|
-
/** The menu's heading it lists under; `fields` by default. */
|
|
24
|
-
group?: 'fields' | 'lead' | 'company' | 'activity' | 'custom';
|
|
24
|
+
/** The menu's heading it lists under; `fields` by default. `plugin`: under `groupLabel`. */
|
|
25
|
+
group?: 'fields' | 'lead' | 'company' | 'activity' | 'custom' | 'plugin';
|
|
26
|
+
/** The heading instead of the group's own: a plugin's title, for the fields it keeps. */
|
|
27
|
+
groupLabel?: string;
|
|
25
28
|
/** A `number` that is money: stored in this currency's smallest unit, typed in its major one. */
|
|
26
29
|
currency?: string;
|
|
27
30
|
};
|
|
@@ -41,6 +44,11 @@ export type TListFilterProps = TConditionLookups & {
|
|
|
41
44
|
error?: Error | null;
|
|
42
45
|
/** Beside the chips, before the count: what a saved view changed. */
|
|
43
46
|
status?: ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* The list's record type, `<plugin>:<record>`, as its `ViewBar` has it: while the list differs
|
|
49
|
+
* from its saved view, the bar offers to reset it or save it as a view.
|
|
50
|
+
*/
|
|
51
|
+
recordType?: TPluginListType;
|
|
44
52
|
};
|
|
45
53
|
/**
|
|
46
54
|
* A list's filter bar, with a field menu, search and conditions as chips.
|
|
@@ -51,7 +59,7 @@ export type TListFilterProps = TConditionLookups & {
|
|
|
51
59
|
* `@erxes/core-contract/client` and the tags query of the record type; outside erxes, the
|
|
52
60
|
* plugin's own.
|
|
53
61
|
*/
|
|
54
|
-
export declare const ListFilter: (props: TListFilterProps) => import("react").JSX.Element;
|
|
62
|
+
export declare const ListFilter: ({ recordType, ...props }: TListFilterProps) => import("react").JSX.Element;
|
|
55
63
|
/**
|
|
56
64
|
* `ListFilter`'s conditions and search, as params for the list's query.
|
|
57
65
|
* `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, {
|
|
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.
|
|
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
|
-
/**
|
|
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.
|
|
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 ??
|
|
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 };
|
|
@@ -49,11 +49,18 @@ const GROUPS = [
|
|
|
49
49
|
const FieldItems = () => {
|
|
50
50
|
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
51
51
|
const { fields } = useListFilter();
|
|
52
|
-
return GROUPS.map(({ group, label }) => {
|
|
53
|
-
|
|
52
|
+
return [...GROUPS.map(({ group, label }) => ({
|
|
53
|
+
key: group,
|
|
54
|
+
heading: t(`group.${group}`, label),
|
|
55
|
+
fields: fields.filter((field) => !field.groupLabel && (field.group ?? "fields") === group)
|
|
56
|
+
})), ...[...new Set(fields.flatMap((field) => field.groupLabel ?? []))].map((heading) => ({
|
|
57
|
+
key: `label:${heading}`,
|
|
58
|
+
heading,
|
|
59
|
+
fields: fields.filter((field) => field.groupLabel === heading)
|
|
60
|
+
}))].map(({ key, heading, fields: inGroup }) => {
|
|
54
61
|
if (!inGroup.length) return null;
|
|
55
62
|
return /* @__PURE__ */ jsx(Command.Group, {
|
|
56
|
-
heading
|
|
63
|
+
heading,
|
|
57
64
|
children: inGroup.map((field) => {
|
|
58
65
|
const Icon = field.icon ?? FIELD_ICONS[field.type];
|
|
59
66
|
return /* @__PURE__ */ jsxs(Filter.Item, {
|
|
@@ -65,7 +72,7 @@ const FieldItems = () => {
|
|
|
65
72
|
})]
|
|
66
73
|
}, field.path);
|
|
67
74
|
})
|
|
68
|
-
},
|
|
75
|
+
}, key);
|
|
69
76
|
});
|
|
70
77
|
};
|
|
71
78
|
/** The menu's first page: "Add filter…", search, the advanced filter, then the fields. */
|
|
@@ -12,7 +12,6 @@ import { useTranslation } from "react-i18next";
|
|
|
12
12
|
// src/modules/list/filter/RuleChips.tsx
|
|
13
13
|
/** A filter bar chip: what it filters, the condition (opens it), remove. */
|
|
14
14
|
const Chip = ({ name, children, onOpen, onRemove }) => {
|
|
15
|
-
const { t } = useTranslation("views", { keyPrefix: "filter" });
|
|
16
15
|
return /* @__PURE__ */ jsxs("div", {
|
|
17
16
|
className: "flex h-7 items-stretch gap-px rounded bg-muted text-sm font-medium shadow-xs",
|
|
18
17
|
children: [
|
|
@@ -21,10 +20,7 @@ const Chip = ({ name, children, onOpen, onRemove }) => {
|
|
|
21
20
|
onClick: onOpen,
|
|
22
21
|
children
|
|
23
22
|
}),
|
|
24
|
-
/* @__PURE__ */ jsx(Filter.BarClose, {
|
|
25
|
-
"aria-label": t("remove", "Remove filter"),
|
|
26
|
-
onClick: onRemove
|
|
27
|
-
})
|
|
23
|
+
/* @__PURE__ */ jsx(Filter.BarClose, { onClick: onRemove })
|
|
28
24
|
]
|
|
29
25
|
});
|
|
30
26
|
};
|
|
@@ -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 {
|
|
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
|
})]
|
|
@@ -3,7 +3,8 @@ import { Icon } from "@tabler/icons-react";
|
|
|
3
3
|
* One field of a form in the side panel, laid out like `PanelField`.
|
|
4
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
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.
|
|
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.
|
|
7
8
|
*/
|
|
8
9
|
export declare const PanelFormRow: ({ label, icon: Icon, required, error, hint, htmlFor, children }: {
|
|
9
10
|
label: React.ReactNode;
|
|
@@ -18,7 +19,8 @@ export declare const PanelFormRow: ({ label, icon: Icon, required, error, hint,
|
|
|
18
19
|
}) => import("react").JSX.Element;
|
|
19
20
|
/**
|
|
20
21
|
* A new record's form in the side panel: its rows, then Cancel and Save.
|
|
21
|
-
* 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).
|
|
22
24
|
*/
|
|
23
25
|
export declare const PanelFormLayout: ({ children, onCancel, saving, saveLabel }: {
|
|
24
26
|
children: React.ReactNode;
|