@erxes/ui 4.0.0-v2.1 → 4.0.0-v2.3

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 (75) hide show
  1. package/README.md +5 -2
  2. package/dist/components/charts.js +3 -1
  3. package/dist/components/combobox.d.ts +1 -1
  4. package/dist/components/combobox.js +4 -1
  5. package/dist/components/date-picker-value.d.ts +5 -9
  6. package/dist/components/date-picker-value.js +15 -34
  7. package/dist/components/date-picker.d.ts +0 -4
  8. package/dist/components/date-picker.js +5 -7
  9. package/dist/components/date-text-input.d.ts +2 -4
  10. package/dist/components/date-text-input.js +11 -9
  11. package/dist/components/dialog.js +1 -1
  12. package/dist/components/empty.d.ts +5 -1
  13. package/dist/components/empty.js +24 -2
  14. package/dist/components/select.d.ts +1 -1
  15. package/dist/components/select.js +3 -1
  16. package/dist/components/sheet.js +4 -4
  17. package/dist/components/sidebar/panel.js +29 -7
  18. package/dist/federation.d.ts +4 -1
  19. package/dist/federation.js +6 -2
  20. package/dist/index.d.ts +8 -5
  21. package/dist/index.js +8 -4
  22. package/dist/lib/format.d.ts +52 -0
  23. package/dist/lib/format.js +75 -0
  24. package/dist/lib/stored.d.ts +13 -0
  25. package/dist/lib/stored.js +41 -0
  26. package/dist/modules/attachments/use-carousel.js +5 -10
  27. package/dist/modules/display/components/RelativeDateDisplay.d.ts +4 -5
  28. package/dist/modules/display/components/RelativeDateDisplay.js +7 -8
  29. package/dist/modules/filter/components/FilterBar.js +5 -7
  30. package/dist/modules/filter/components/FilterDialog.js +4 -5
  31. package/dist/modules/filter/components/FilterPopover.js +1 -1
  32. package/dist/modules/filter/components/FilterProvider.d.ts +1 -2
  33. package/dist/modules/filter/components/FilterProvider.js +1 -2
  34. package/dist/modules/filter/types/filter.d.ts +0 -1
  35. package/dist/modules/layout/components/AppLayout.d.ts +2 -2
  36. package/dist/modules/layout/components/AppLayout.js +8 -9
  37. package/dist/modules/layout/components/AppLayoutResizeHandle.d.ts +5 -12
  38. package/dist/modules/layout/components/AppLayoutResizeHandle.js +15 -18
  39. package/dist/modules/layout/components/PageHeader.js +5 -2
  40. package/dist/modules/navigation-menu/components/NavigationMenu.d.ts +3 -3
  41. package/dist/modules/navigation-menu/components/NavigationMenu.js +6 -7
  42. package/dist/modules/pickers/EntityPicker.d.ts +30 -0
  43. package/dist/modules/pickers/EntityPicker.js +60 -0
  44. package/dist/modules/pickers/SelectMember.d.ts +41 -0
  45. package/dist/modules/pickers/SelectMember.js +122 -0
  46. package/dist/modules/pickers/members.d.ts +30 -0
  47. package/dist/modules/pickers/members.js +18 -0
  48. package/dist/modules/record-field/components/NumberField.js +4 -2
  49. package/dist/modules/record-field/components/TextField.js +9 -2
  50. package/dist/modules/record-table/components/RecordTableCell.d.ts +9 -0
  51. package/dist/modules/record-table/components/RecordTableCell.js +16 -2
  52. package/dist/modules/record-table/components/RecordTableCellInline.js +3 -7
  53. package/dist/modules/record-table/components/RecordTableCursor.js +15 -20
  54. package/dist/modules/record-table/hooks/useTablePreferences.d.ts +1 -1
  55. package/dist/modules/record-table/hooks/useTablePreferences.js +18 -31
  56. package/dist/modules/record-table/states/RecordTableCursorState.d.ts +21 -1
  57. package/dist/modules/record-table/states/RecordTableCursorState.js +21 -3
  58. package/dist/state/sidebarPanelState.d.ts +5 -1
  59. package/dist/state/sidebarPanelState.js +11 -3
  60. package/dist/state/themeState.d.ts +8 -2
  61. package/dist/state/themeState.js +13 -4
  62. package/dist/theme.css +3 -2
  63. package/dist/utils/plugin-styles.d.ts +6 -0
  64. package/dist/utils/plugin-styles.js +53 -0
  65. package/package.json +4 -1
  66. package/dist/constants/IntlLanguages.d.ts +0 -74
  67. package/dist/constants/IntlLanguages.js +0 -76
  68. package/dist/hooks/use-query-state.d.ts +0 -16
  69. package/dist/hooks/use-query-state.js +0 -122
  70. package/dist/modules/filter/hooks/useFilterQueryState.d.ts +0 -4
  71. package/dist/modules/filter/hooks/useFilterQueryState.js +0 -14
  72. package/dist/types/Theme.d.ts +0 -1
  73. package/dist/types/Theme.js +0 -0
  74. package/dist/utils/localization/formatDateISOStringToRelativeDate.d.ts +0 -2
  75. package/dist/utils/localization/formatDateISOStringToRelativeDate.js +0 -16
package/dist/index.d.ts CHANGED
@@ -55,10 +55,11 @@ import { Toggle } from "./components/toggle.js";
55
55
  import { Tooltip } from "./components/tooltip.js";
56
56
  import { Upload } from "./components/upload.js";
57
57
  import { useConfirm } from "./hooks/use-confirm.js";
58
- import { useMultiQueryState, useQueryState } from "./hooks/use-query-state.js";
59
58
  import { toast, useToast } from "./hooks/use-toast.js";
60
59
  import { useUpload } from "./hooks/use-upload.js";
61
60
  import { cn } from "./lib/utils.js";
61
+ import { LANGUAGES, formatter, localTimeZone, toIsoDay, useFormat, zoneOffset } from "./lib/format.js";
62
+ import { stored, storedFamily } from "./lib/stored.js";
62
63
  import { Editor } from "./modules/blocks/components/LazyEditor.js";
63
64
  import { editorText } from "./modules/blocks/utils/parseBlocks.js";
64
65
  import { EmailDisplay } from "./modules/display/components/EmailDisplay.js";
@@ -67,7 +68,6 @@ import { RelativeDateDisplay } from "./modules/display/components/RelativeDateDi
67
68
  import { SexDisplay } from "./modules/display/components/SexDisplay.js";
68
69
  import { Filter } from "./modules/filter/components/Filter.js";
69
70
  import { useFilterContext } from "./modules/filter/hooks/useFilterContext.js";
70
- import { useFilterQueryState } from "./modules/filter/hooks/useFilterQueryState.js";
71
71
  import { PopoverScoped } from "./modules/hotkey/components/PopoverScoped.js";
72
72
  import { usePreviousHotkeyScope } from "./modules/hotkey/hooks/usePreviousHotkeyScope.js";
73
73
  import { useScopedHotkeys } from "./modules/hotkey/hooks/useScopedHotkeys.js";
@@ -82,6 +82,9 @@ import { AppLayout, AppLayoutFooterLink } from "./modules/layout/components/AppL
82
82
  import { PageContainer, PageSubHeader } from "./modules/layout/components/Page.js";
83
83
  import { PageHeader } from "./modules/layout/components/PageHeader.js";
84
84
  import { NavigationMenuLinkItem } from "./modules/navigation-menu/components/NavigationMenu.js";
85
+ import { EntityPicker } from "./modules/pickers/EntityPicker.js";
86
+ import { Member, MemberQueries, memberName, useMembersById } from "./modules/pickers/members.js";
87
+ import { MemberInline, SelectMember } from "./modules/pickers/SelectMember.js";
85
88
  import { NumberField } from "./modules/record-field/components/NumberField.js";
86
89
  import { TextField } from "./modules/record-field/components/TextField.js";
87
90
  import { PhoneInput } from "./modules/record-field/meta-inputs/components/PhoneInput.js";
@@ -89,9 +92,8 @@ import { RecordTable } from "./modules/record-table/components/RecordTable.js";
89
92
  import { RecordTableColumnDef } from "./modules/record-table/components/RecordTableProvider.js";
90
93
  import { RecordTableInlineCell } from "./modules/record-table/components/RecordTableCellInline.js";
91
94
  import { EnumCursorDirection } from "./modules/record-table/types/RecordTableCursorTypes.js";
92
- import { themeState } from "./state/themeState.js";
95
+ import { ThemeOption, themeState } from "./state/themeState.js";
93
96
  import { SexCode } from "./types/SexCode.js";
94
- import { ThemeOption } from "./types/Theme.js";
95
97
  import { IUIConfig, TActivityRowProps, TDashboardWidgetPreview, TPropertyInputMeta, TPropertyInputProps } from "./types/UIConfig.js";
96
98
  import { isUndefinedOrNull } from "./utils/IsUndefinedOrNull.js";
97
99
  import { readImage } from "./utils/core.js";
@@ -100,5 +102,6 @@ import { formatPhoneNumber } from "./utils/format/formatPhoneNumber.js";
100
102
  import { getPluginAssetsUrl } from "./utils/getPluginAssetsUrl.js";
101
103
  import { jsonOf } from "./utils/json.js";
102
104
  import { PluginLiveMessage, PluginRuntime, PluginSession, getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
105
+ import { addPluginStyles } from "./utils/plugin-styles.js";
103
106
  import { RecordTimeline, RecordTimelineProps, setRecordTimeline } from "./utils/record-timeline.js";
104
- 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, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EnumCursorDirection, type FileStorageAdapter, Filter, Form, FullNameField, FullNameValue, HoverCard, type IUIConfig, IconComponent, IconPicker, IconsProvider, InfoCard, Input, InputGroup, Kbd, Label, type MultiSelectOption, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PhoneDisplay, PhoneField, PhoneInput, type PluginLiveMessage, type PluginRuntime, type PluginSession, Popover, PopoverScoped, RadioGroup, RecordTable, type RecordTableColumnDef, RecordTableInlineCell, RecordTimeline, type RecordTimelineProps, RelativeDateDisplay, Resizable, ScrollArea, Select, Separator, SexCode, SexDisplay, SexField, Sheet, Sidebar, Skeleton, Slider, Spinner, StringArrayInput, Switch, type TActivityRowProps, type TDashboardWidgetPreview, type TPropertyInputMeta, type TPropertyInputProps, TabButton, Table, Tabs, TextField, TextOverflowTooltip, Textarea, type ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, badgeVariants, buttonVariants, cn, editorText, formatPhoneNumber, getPluginAssetsUrl, getPluginRuntime, isUndefinedOrNull, jsonOf, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordTimeline, themeState, toast, useConfirm, useFilterContext, useFilterQueryState, useLiveSignal, useMultiQueryState, usePreviousHotkeyScope, useQueryState, useScopedHotkeys, useToast, useUpload };
107
+ 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, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, type FileStorageAdapter, Filter, Form, FullNameField, FullNameValue, HoverCard, type IUIConfig, IconComponent, IconPicker, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, type Member, MemberInline, type MemberQueries, type MultiSelectOption, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PhoneDisplay, PhoneField, PhoneInput, type PluginLiveMessage, type PluginRuntime, type PluginSession, Popover, PopoverScoped, RadioGroup, 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 TDashboardWidgetPreview, type TPropertyInputMeta, type TPropertyInputProps, TabButton, Table, Tabs, TextField, TextOverflowTooltip, Textarea, ThemeOption, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, addPluginStyles, badgeVariants, buttonVariants, cn, editorText, formatPhoneNumber, formatter, getPluginAssetsUrl, getPluginRuntime, isUndefinedOrNull, jsonOf, localTimeZone, memberName, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordTimeline, stored, storedFamily, themeState, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useLiveSignal, useMembersById, usePreviousHotkeyScope, useScopedHotkeys, useToast, useUpload, zoneOffset };
package/dist/index.js CHANGED
@@ -53,10 +53,11 @@ import { Toggle } from "./components/toggle.js";
53
53
  import { Tooltip } from "./components/tooltip.js";
54
54
  import { Upload } from "./components/upload.js";
55
55
  import { useConfirm } from "./hooks/use-confirm.js";
56
- import { useMultiQueryState, useQueryState } from "./hooks/use-query-state.js";
57
56
  import { toast, useToast } from "./hooks/use-toast.js";
58
57
  import { useUpload } from "./hooks/use-upload.js";
59
58
  import { cn } from "./lib/utils.js";
59
+ import { LANGUAGES, formatter, localTimeZone, toIsoDay, useFormat, zoneOffset } from "./lib/format.js";
60
+ import { stored, storedFamily } from "./lib/stored.js";
60
61
  import { Editor } from "./modules/blocks/components/LazyEditor.js";
61
62
  import { editorText } from "./modules/blocks/utils/parseBlocks.js";
62
63
  import { EmailDisplay } from "./modules/display/components/EmailDisplay.js";
@@ -65,7 +66,6 @@ import { RelativeDateDisplay } from "./modules/display/components/RelativeDateDi
65
66
  import { SexDisplay } from "./modules/display/components/SexDisplay.js";
66
67
  import { Filter } from "./modules/filter/components/Filter.js";
67
68
  import { useFilterContext } from "./modules/filter/hooks/useFilterContext.js";
68
- import { useFilterQueryState } from "./modules/filter/hooks/useFilterQueryState.js";
69
69
  import { PopoverScoped } from "./modules/hotkey/components/PopoverScoped.js";
70
70
  import { usePreviousHotkeyScope } from "./modules/hotkey/hooks/usePreviousHotkeyScope.js";
71
71
  import { useScopedHotkeys } from "./modules/hotkey/hooks/useScopedHotkeys.js";
@@ -80,13 +80,16 @@ import { AppLayout, AppLayoutFooterLink } from "./modules/layout/components/AppL
80
80
  import { PageContainer, PageSubHeader } from "./modules/layout/components/Page.js";
81
81
  import { PageHeader } from "./modules/layout/components/PageHeader.js";
82
82
  import { NavigationMenuLinkItem } from "./modules/navigation-menu/components/NavigationMenu.js";
83
+ import { EntityPicker } from "./modules/pickers/EntityPicker.js";
84
+ import { memberName, useMembersById } from "./modules/pickers/members.js";
85
+ import { MemberInline, SelectMember } from "./modules/pickers/SelectMember.js";
83
86
  import { NumberField } from "./modules/record-field/components/NumberField.js";
84
87
  import { TextField } from "./modules/record-field/components/TextField.js";
85
88
  import { PhoneInput } from "./modules/record-field/meta-inputs/components/PhoneInput.js";
86
89
  import { RecordTable } from "./modules/record-table/components/RecordTable.js";
87
90
  import { RecordTableInlineCell } from "./modules/record-table/components/RecordTableCellInline.js";
88
91
  import { EnumCursorDirection } from "./modules/record-table/types/RecordTableCursorTypes.js";
89
- import { themeState } from "./state/themeState.js";
92
+ import { ThemeOption, themeState } from "./state/themeState.js";
90
93
  import { SexCode } from "./types/SexCode.js";
91
94
  import { isUndefinedOrNull } from "./utils/IsUndefinedOrNull.js";
92
95
  import { readImage } from "./utils/core.js";
@@ -95,5 +98,6 @@ import { formatPhoneNumber } from "./utils/format/formatPhoneNumber.js";
95
98
  import { getPluginAssetsUrl } from "./utils/getPluginAssetsUrl.js";
96
99
  import { jsonOf } from "./utils/json.js";
97
100
  import { getPluginRuntime, pluginFetch, pluginJson, setPluginRuntime, useLiveSignal } from "./utils/plugin-runtime.js";
101
+ import { addPluginStyles } from "./utils/plugin-styles.js";
98
102
  import { RecordTimeline, setRecordTimeline } from "./utils/record-timeline.js";
99
- export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, BackgroundGradientAnimation, Badge, Breadcrumb, Button, Calendar, Card, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EnumCursorDirection, Filter, Form, FullNameField, FullNameValue, HoverCard, IconComponent, IconPicker, IconsProvider, InfoCard, Input, InputGroup, Kbd, Label, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PhoneDisplay, PhoneField, PhoneInput, Popover, PopoverScoped, RadioGroup, RecordTable, RecordTableInlineCell, RecordTimeline, RelativeDateDisplay, Resizable, ScrollArea, Select, Separator, SexCode, SexDisplay, SexField, Sheet, Sidebar, Skeleton, Slider, Spinner, StringArrayInput, Switch, TabButton, Table, Tabs, TextField, TextOverflowTooltip, Textarea, TimeField, Toaster, Toggle, ToggleGroup, Tooltip, Upload, badgeVariants, buttonVariants, cn, editorText, formatPhoneNumber, getPluginAssetsUrl, getPluginRuntime, isUndefinedOrNull, jsonOf, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordTimeline, themeState, toast, useConfirm, useFilterContext, useFilterQueryState, useLiveSignal, useMultiQueryState, usePreviousHotkeyScope, useQueryState, useScopedHotkeys, useToast, useUpload };
103
+ export { Accordion, Alert, AlertDialog, AppLayout, AppLayoutFooterLink, Avatar, BackgroundGradientAnimation, Badge, Breadcrumb, Button, Calendar, Card, ChartContainer, ChartLegendContent, ChartTooltipContent, Checkbox, ChoiceboxGroup, Collapsible, ColorPicker, Combobox, Command, CommandBar, ContextMenu, CopyText, DateInput, DatePicker, Dialog, DragHandle, DropdownMenu, Editor, EmailDisplay, EmailListField, Empty, EntityPicker, EnumCursorDirection, Filter, Form, FullNameField, FullNameValue, HoverCard, IconComponent, IconPicker, IconsProvider, InfoCard, Input, InputGroup, Kbd, LANGUAGES, Label, MemberInline, MultipleSelector, NavigationMenuLinkItem, NumberField, PageContainer, PageHeader, PageSubHeader, PhoneDisplay, PhoneField, PhoneInput, Popover, PopoverScoped, RadioGroup, 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, addPluginStyles, badgeVariants, buttonVariants, cn, editorText, formatPhoneNumber, formatter, getPluginAssetsUrl, getPluginRuntime, isUndefinedOrNull, jsonOf, localTimeZone, memberName, pluginFetch, pluginJson, readImage, setFileStorage, setPluginRuntime, setRecordTimeline, stored, storedFamily, themeState, toIsoDay, toast, useConfirm, useFilterContext, useFormat, useLiveSignal, useMembersById, usePreviousHotkeyScope, useScopedHotkeys, useToast, useUpload, zoneOffset };
@@ -0,0 +1,52 @@
1
+ /** The languages the UI speaks, each with its own name and its date-fns locale. */
2
+ export declare const LANGUAGES: readonly [{
3
+ readonly code: 'en';
4
+ readonly label: 'English';
5
+ readonly dates: import("date-fns").Locale;
6
+ }, {
7
+ readonly code: 'mn';
8
+ readonly label: 'Монгол';
9
+ readonly dates: import("date-fns").Locale;
10
+ }];
11
+ type DateInput = Date | string | number;
12
+ /** The formatters for `language` (an i18next code), for code outside React. */
13
+ export declare const formatter: (language: string) => {
14
+ /** A date in a date-fns pattern; `PP` by default ("Nov 14, 2026"). */
15
+ date: (value: DateInput, pattern?: string) => string;
16
+ /** A date and time: "Nov 14, 2026, 2:30 PM". */
17
+ dateTime: (value: DateInput) => string;
18
+ /** A time of day: "2:30 PM", or "14:30" in a 24-hour language. */
19
+ time: (value: DateInput) => string;
20
+ /** How long ago or ahead: "5 minutes ago", "in 2 days", "less than a minute ago". */
21
+ relative: (value: DateInput, now?: DateInput) => string;
22
+ /** A count or measure: "1,234". */
23
+ number: (value: number) => string;
24
+ /** A list's total; when counting stopped there (`capped`), there are more: "10,000+". */
25
+ count: (value: number, capped?: boolean) => string;
26
+ /** An amount in the currency's main unit: 1500 MNT → "MNT 1,500.00". */
27
+ currency: (value: number, currency: string) => string;
28
+ };
29
+ /** The formatters in the UI's language; a component using them re-renders when it changes. */
30
+ export declare const useFormat: () => {
31
+ /** A date in a date-fns pattern; `PP` by default ("Nov 14, 2026"). */
32
+ date: (value: DateInput, pattern?: string) => string;
33
+ /** A date and time: "Nov 14, 2026, 2:30 PM". */
34
+ dateTime: (value: DateInput) => string;
35
+ /** A time of day: "2:30 PM", or "14:30" in a 24-hour language. */
36
+ time: (value: DateInput) => string;
37
+ /** How long ago or ahead: "5 minutes ago", "in 2 days", "less than a minute ago". */
38
+ relative: (value: DateInput, now?: DateInput) => string;
39
+ /** A count or measure: "1,234". */
40
+ number: (value: number) => string;
41
+ /** A list's total; when counting stopped there (`capped`), there are more: "10,000+". */
42
+ count: (value: number, capped?: boolean) => string;
43
+ /** An amount in the currency's main unit: 1500 MNT → "MNT 1,500.00". */
44
+ currency: (value: number, currency: string) => string;
45
+ };
46
+ /** A local day as stored and typed, `yyyy-MM-dd`, the same in every language. */
47
+ export declare const toIsoDay: (date: Date) => string;
48
+ /** The browser's time zone ("Asia/Ulaanbaatar"), when it says. */
49
+ export declare const localTimeZone: () => string | undefined;
50
+ /** A zone's offset today, "UTC+8"; empty for a zone the browser doesn't know. */
51
+ export declare const zoneOffset: (zone: string) => string;
52
+ export {};
@@ -0,0 +1,75 @@
1
+ import { format, formatDistance, formatDistanceStrict, parseISO } from "date-fns";
2
+ import { enUS } from "date-fns/locale/en-US";
3
+ import { mn } from "date-fns/locale/mn";
4
+ import { useTranslation } from "react-i18next";
5
+ // src/lib/format.ts
6
+ /** The languages the UI speaks, each with its own name and its date-fns locale. */
7
+ const LANGUAGES = [{
8
+ code: "en",
9
+ label: "English",
10
+ dates: enUS
11
+ }, {
12
+ code: "mn",
13
+ label: "Монгол",
14
+ dates: mn
15
+ }];
16
+ /** ISO strings read as written: `2026-11-14` is that day here, not UTC midnight. */
17
+ const toDate = (value) => typeof value === "string" ? parseISO(value) : value;
18
+ /** The formatters for `language` (an i18next code), for code outside React. */
19
+ const formatter = (language) => {
20
+ const locale = LANGUAGES.find((entry) => language.startsWith(entry.code))?.dates ?? LANGUAGES[0].dates;
21
+ return {
22
+ /** A date in a date-fns pattern; `PP` by default ("Nov 14, 2026"). */
23
+ date: (value, pattern = "PP") => format(toDate(value), pattern, { locale }),
24
+ /** A date and time: "Nov 14, 2026, 2:30 PM". */
25
+ dateTime: (value) => format(toDate(value), "PPp", { locale }),
26
+ /** A time of day: "2:30 PM", or "14:30" in a 24-hour language. */
27
+ time: (value) => format(toDate(value), "p", { locale }),
28
+ /** How long ago or ahead: "5 minutes ago", "in 2 days", "less than a minute ago". */
29
+ relative: (value, now = Date.now()) => {
30
+ const date = toDate(value);
31
+ const base = toDate(now);
32
+ return Math.abs(Number(date) - Number(base)) < 6e4 ? formatDistance(date, base, {
33
+ addSuffix: true,
34
+ locale
35
+ }) : formatDistanceStrict(date, base, {
36
+ addSuffix: true,
37
+ locale,
38
+ roundingMethod: "floor"
39
+ });
40
+ },
41
+ /** A count or measure: "1,234". */
42
+ number: (value) => new Intl.NumberFormat(language).format(value),
43
+ /** A list's total; when counting stopped there (`capped`), there are more: "10,000+". */
44
+ count: (value, capped) => `${new Intl.NumberFormat(language).format(value)}${capped ? "+" : ""}`,
45
+ /** An amount in the currency's main unit: 1500 MNT → "MNT 1,500.00". */
46
+ currency: (value, currency) => new Intl.NumberFormat(language, {
47
+ style: "currency",
48
+ currency
49
+ }).format(value)
50
+ };
51
+ };
52
+ /** The formatters in the UI's language; a component using them re-renders when it changes. */
53
+ const useFormat = () => formatter(useTranslation().i18n.language);
54
+ /** A local day as stored and typed, `yyyy-MM-dd`, the same in every language. */
55
+ const toIsoDay = (date) => format(date, "yyyy-MM-dd");
56
+ /** The browser's time zone ("Asia/Ulaanbaatar"), when it says. */
57
+ const localTimeZone = () => {
58
+ try {
59
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
60
+ } catch {
61
+ return;
62
+ }
63
+ };
64
+ /** A zone's offset today, "UTC+8"; empty for a zone the browser doesn't know. */
65
+ const zoneOffset = (zone) => {
66
+ try {
67
+ return new Intl.DateTimeFormat("en-US", {
68
+ timeZone: zone,
69
+ timeZoneName: "shortOffset"
70
+ }).formatToParts(/* @__PURE__ */ new Date()).find((part) => part.type === "timeZoneName")?.value.replace("GMT", "UTC") ?? "";
71
+ } catch {
72
+ return "";
73
+ }
74
+ };
75
+ export { LANGUAGES, formatter, localTimeZone, toIsoDay, useFormat, zoneOffset };
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ interface StoredOptions<T> {
3
+ key: string;
4
+ schema: z.ZodType<T>;
5
+ initial: NoInfer<T>;
6
+ /** sessionStorage: kept for this tab until it closes. */
7
+ session?: boolean;
8
+ }
9
+ /** An atom kept in browser storage under `key`. */
10
+ export declare const stored: <T>({ key, schema, initial, session }: StoredOptions<T>) => import("jotai").WritableAtom<T, [typeof import("jotai/utils").RESET | T | ((prev: T) => typeof import("jotai/utils").RESET | T)], void>;
11
+ /** One stored atom per id (a table, a user, a list), under `<key>:<id>`. */
12
+ export declare const storedFamily: <T>({ key, ...options }: StoredOptions<T>) => import("jotai-family").AtomFamily<string, import("jotai").WritableAtom<T, [typeof import("jotai/utils").RESET | T | ((prev: T) => typeof import("jotai/utils").RESET | T)], void>>;
13
+ export {};
@@ -0,0 +1,41 @@
1
+ import { atomFamily } from "jotai-family";
2
+ import { atomWithStorage, createJSONStorage } from "jotai/utils";
3
+ // src/lib/stored.ts
4
+ /** Reading the storage itself throws where it is blocked; then nothing is kept. */
5
+ const nothingKept = {
6
+ getItem: () => null,
7
+ setItem: () => {},
8
+ removeItem: () => {}
9
+ };
10
+ const browserStorage = (session) => () => {
11
+ try {
12
+ return session ? window.sessionStorage : window.localStorage;
13
+ } catch {
14
+ return nothingKept;
15
+ }
16
+ };
17
+ /** An atom kept in browser storage under `key`. */
18
+ const stored = ({ key, schema, initial, session }) => {
19
+ const json = createJSONStorage(browserStorage(session));
20
+ const subscribe = json.subscribe;
21
+ const valid = (value) => {
22
+ const parsed = schema.safeParse(value);
23
+ return parsed.success ? parsed.data : initial;
24
+ };
25
+ return atomWithStorage(key, initial, {
26
+ getItem: (name) => valid(json.getItem(name, initial)),
27
+ setItem: (name, value) => {
28
+ try {
29
+ json.setItem(name, value);
30
+ } catch {}
31
+ },
32
+ removeItem: json.removeItem,
33
+ subscribe: subscribe && ((name, callback) => subscribe(name, (value) => callback(valid(value)), initial))
34
+ }, { getOnInit: true });
35
+ };
36
+ /** One stored atom per id (a table, a user, a list), under `<key>:<id>`. */
37
+ const storedFamily = ({ key, ...options }) => atomFamily((id) => stored({
38
+ key: `${key}:${id}`,
39
+ ...options
40
+ }));
41
+ export { stored, storedFamily };
@@ -1,4 +1,5 @@
1
- import { useEffect, useState } from "react";
1
+ import { useState } from "react";
2
+ import { useHotkeys } from "react-hotkeys-hook";
2
3
  // src/modules/attachments/use-carousel.ts
3
4
  /** The index `delta` steps from `index`, wrapping around a list of `length`. */
4
5
  const step = (index, length, delta) => ((Math.min(index, length - 1) + delta) % length + length) % length;
@@ -8,15 +9,9 @@ const step = (index, length, delta) => ((Math.min(index, length - 1) + delta) %
8
9
  */
9
10
  const useCarousel = (length, open) => {
10
11
  const [index, setIndex] = useState(0);
11
- useEffect(() => {
12
- if (!open || length === 0) return;
13
- const onKey = (event) => {
14
- if (event.key === "ArrowRight") setIndex((i) => step(i, length, 1));
15
- if (event.key === "ArrowLeft") setIndex((i) => step(i, length, -1));
16
- };
17
- document.addEventListener("keydown", onKey);
18
- return () => document.removeEventListener("keydown", onKey);
19
- }, [open, length]);
12
+ const enabled = open && length > 0;
13
+ useHotkeys("right", () => setIndex((i) => step(i, length, 1)), { enabled });
14
+ useHotkeys("left", () => setIndex((i) => step(i, length, -1)), { enabled });
20
15
  return {
21
16
  index: Math.max(0, Math.min(index, length - 1)),
22
17
  show: setIndex,
@@ -1,14 +1,13 @@
1
1
  import { Tooltip } from "../../../components/tooltip.js";
2
2
  import React from "react";
3
3
  import { Except } from "type-fest";
4
- type RelativeDateDisplayProps = {
5
- value: string;
6
- isShort?: boolean;
7
- };
4
+ /** A date as how long ago it was, with the date and time on hover. */
8
5
  declare const RelativeDateDisplayTooltip: ({ value, ...props }: Except<React.ComponentProps<typeof Tooltip.Trigger>, 'value'> & {
9
6
  value: string;
10
7
  }) => React.JSX.Element | null;
11
- declare const RelativeDateDisplayValue: ({ value, isShort }: RelativeDateDisplayProps) => string | null;
8
+ declare const RelativeDateDisplayValue: ({ value }: {
9
+ value: string;
10
+ }) => string | null;
12
11
  export declare const RelativeDateDisplay: typeof RelativeDateDisplayTooltip & {
13
12
  Value: typeof RelativeDateDisplayValue;
14
13
  };
@@ -1,23 +1,22 @@
1
1
  import { Tooltip } from "../../../components/tooltip.js";
2
+ import { useFormat } from "../../../lib/format.js";
2
3
  import { isUndefinedOrNull } from "../../../utils/IsUndefinedOrNull.js";
3
- import { formatDateISOStringToRelativeDate, formatDateISOStringToRelativeDateShort } from "../../../utils/localization/formatDateISOStringToRelativeDate.js";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import "react";
6
- import { format } from "date-fns";
7
6
  // src/modules/display/components/RelativeDateDisplay.tsx
7
+ /** A date as how long ago it was, with the date and time on hover. */
8
8
  const RelativeDateDisplayTooltip = ({ value, ...props }) => {
9
+ const fmt = useFormat();
9
10
  if (isUndefinedOrNull(value)) return null;
10
11
  return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(Tooltip.Trigger, {
11
12
  delay: 100,
12
13
  className: "truncate",
13
14
  ...props
14
- }), /* @__PURE__ */ jsx(Tooltip.Content, { children: format(value, "MMM dd, yyyy HH:mm") })] });
15
+ }), /* @__PURE__ */ jsx(Tooltip.Content, { children: fmt.dateTime(value) })] });
15
16
  };
16
- const RelativeDateDisplayValue = ({ value, isShort }) => {
17
- if (isUndefinedOrNull(value)) return null;
18
- const relativeDate = formatDateISOStringToRelativeDate(value);
19
- const relativeDateShort = formatDateISOStringToRelativeDateShort(value);
20
- return isShort ? relativeDateShort : relativeDate;
17
+ const RelativeDateDisplayValue = ({ value }) => {
18
+ const fmt = useFormat();
19
+ return isUndefinedOrNull(value) ? null : fmt.relative(value);
21
20
  };
22
21
  const RelativeDateDisplay = Object.assign(RelativeDateDisplayTooltip, { Value: RelativeDateDisplayValue });
23
22
  export { RelativeDateDisplay };
@@ -1,12 +1,10 @@
1
1
  import { Button } from "../../../components/button.js";
2
- import { useRemoveQueryStateByKey } from "../../../hooks/use-query-state.js";
3
2
  import { cn } from "../../../lib/utils.js";
4
3
  import { useFilterContext } from "../hooks/useFilterContext.js";
5
- import { useFilterQueryState } from "../hooks/useFilterQueryState.js";
6
4
  import { IconSearch, IconX } from "@tabler/icons-react";
7
5
  import { jsx, jsxs } from "react/jsx-runtime";
8
6
  import "react";
9
- import { z } from "zod";
7
+ import { useQueryState } from "nuqs";
10
8
  // src/modules/filter/components/FilterBar.tsx
11
9
  const FilterBar = ({ ref, className, ...props }) => {
12
10
  return /* @__PURE__ */ jsx("div", {
@@ -16,19 +14,19 @@ const FilterBar = ({ ref, className, ...props }) => {
16
14
  });
17
15
  };
18
16
  const FilterBarCloseButton = ({ ref, className, filterKey, ...props }) => {
19
- const removeQuery = useRemoveQueryStateByKey();
17
+ const [, setQuery] = useQueryState(filterKey ?? "");
20
18
  return /* @__PURE__ */ jsx(Button, {
21
19
  ref,
22
20
  variant: "segment",
23
21
  size: "icon",
24
22
  className,
25
- onClick: () => removeQuery(filterKey ?? ""),
23
+ onClick: () => void setQuery(null),
26
24
  ...props,
27
25
  children: /* @__PURE__ */ jsx(IconX, {})
28
26
  });
29
27
  };
30
28
  const FilterBarItem = ({ ref, className, queryKey, children, ...props }) => {
31
- const [query] = useFilterQueryState(queryKey || "root", z.string());
29
+ const [query] = useQueryState(queryKey || "root");
32
30
  if (queryKey && !query) return null;
33
31
  return /* @__PURE__ */ jsxs("div", {
34
32
  ref,
@@ -60,7 +58,7 @@ const FilterBarButton = ({ ref, className, inDialog, filterKey, ...props }) => {
60
58
  });
61
59
  };
62
60
  const FilterSearchValueBarItem = () => {
63
- const [searchValue] = useFilterQueryState("searchValue", z.string());
61
+ const [searchValue] = useQueryState("searchValue");
64
62
  return /* @__PURE__ */ jsxs(FilterBarItem, {
65
63
  queryKey: "searchValue",
66
64
  children: [/* @__PURE__ */ jsxs(FilterBarName, { children: [/* @__PURE__ */ jsx(IconSearch, {}), "Search"] }), /* @__PURE__ */ jsx(FilterBarButton, {
@@ -2,13 +2,12 @@ import { Button } from "../../../components/button.js";
2
2
  import { Dialog } from "../../../components/dialog.js";
3
3
  import { Input } from "../../../components/input.js";
4
4
  import { useFilterContext } from "../hooks/useFilterContext.js";
5
- import { useFilterQueryState } from "../hooks/useFilterQueryState.js";
6
5
  import { openDialogState } from "../states/filterStates.js";
7
6
  import { jsx, jsxs } from "react/jsx-runtime";
8
7
  import { useState } from "react";
9
- import { z } from "zod";
10
- import { useTranslation } from "react-i18next";
11
8
  import { useAtomValue } from "jotai";
9
+ import { useTranslation } from "react-i18next";
10
+ import { useQueryState } from "nuqs";
12
11
  // src/modules/filter/components/FilterDialog.tsx
13
12
  const FilterDialog = (props) => {
14
13
  const { id, setOpenDialog, resetFilterState } = useFilterContext();
@@ -24,8 +23,8 @@ const FilterDialog = (props) => {
24
23
  };
25
24
  const FilterDialogStringView = ({ filterKey, label }) => {
26
25
  const { t } = useTranslation();
27
- const { setDialogView, setOpenDialog, sessionKey } = useFilterContext();
28
- const [query, setQuery] = useFilterQueryState(filterKey, z.string(), sessionKey ?? "");
26
+ const { setDialogView, setOpenDialog } = useFilterContext();
27
+ const [query, setQuery] = useQueryState(filterKey);
29
28
  const [dialogSearch, setDialogSearch] = useState(query ?? "");
30
29
  const onSubmit = (e) => {
31
30
  e.preventDefault();
@@ -10,8 +10,8 @@ import { filterDialogViewState, filterPopoverViewState, openDialogState, openPop
10
10
  import { IconChevronLeft, IconChevronRight, IconFilter2, IconSearch } from "@tabler/icons-react";
11
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
12
  import React, { useEffect } from "react";
13
- import { useTranslation } from "react-i18next";
14
13
  import { useAtom, useAtomValue, useSetAtom } from "jotai";
14
+ import { useTranslation } from "react-i18next";
15
15
  // src/modules/filter/components/FilterPopover.tsx
16
16
  const FilterTrigger = ({ ref, isFiltered, className, ...props }) => {
17
17
  const { t } = useTranslation();
@@ -1,5 +1,4 @@
1
- export declare const FilterProvider: ({ children, id, sessionKey }: {
1
+ export declare const FilterProvider: ({ children, id }: {
2
2
  children: React.ReactNode;
3
3
  id: string;
4
- sessionKey?: string;
5
4
  }) => import("react").JSX.Element;
@@ -3,7 +3,7 @@ import { filterDialogViewState, filterPopoverViewState, openDialogState, openPop
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { useSetAtom } from "jotai";
5
5
  // src/modules/filter/components/FilterProvider.tsx
6
- const FilterProvider = ({ children, id, sessionKey }) => {
6
+ const FilterProvider = ({ children, id }) => {
7
7
  const setOpen = useSetAtom(openPopoverState(id));
8
8
  const setView = useSetAtom(filterPopoverViewState(id));
9
9
  const setDialogView = useSetAtom(filterDialogViewState(id));
@@ -17,7 +17,6 @@ const FilterProvider = ({ children, id, sessionKey }) => {
17
17
  return /* @__PURE__ */ jsx(FilterContext.Provider, {
18
18
  value: {
19
19
  id,
20
- sessionKey,
21
20
  resetFilterState,
22
21
  setOpen,
23
22
  setView,
@@ -1,6 +1,5 @@
1
1
  export interface IFilterContext {
2
2
  id: string;
3
- sessionKey?: string;
4
3
  resetFilterState: () => void;
5
4
  setOpen: (open: boolean) => void;
6
5
  setView: (view: string) => void;
@@ -3,8 +3,8 @@ import { ElementType, ReactNode } from "react";
3
3
  * A link pinned to the bottom of an app sidebar (`AppLayout` `footer`), e.g.
4
4
  * the plugin's own settings or the way back from them.
5
5
  */
6
- export declare const AppLayoutFooterLink: ({ path, name, icon: Icon }: {
7
- path: string;
6
+ export declare const AppLayoutFooterLink: ({ to, name, icon: Icon }: {
7
+ to: string;
8
8
  name: string;
9
9
  icon?: ElementType;
10
10
  }) => import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { AppLayoutPageSlot } from "./AppLayoutPageSlot.js";
2
- import { AppLayoutResizeHandle, getAppLayoutAtoms } from "./AppLayoutResizeHandle.js";
2
+ import { AppLayoutResizeHandle, appLayoutOpenState, appLayoutWidthState } from "./AppLayoutResizeHandle.js";
3
3
  import { Button } from "../../../components/button.js";
4
4
  import { Separator } from "../../../components/separator.js";
5
5
  import { Sidebar } from "../../../components/sidebar.js";
@@ -33,13 +33,12 @@ const AppLayoutFooter = ({ children }) => children ? /* @__PURE__ */ jsx("div",
33
33
  * A link pinned to the bottom of an app sidebar (`AppLayout` `footer`), e.g.
34
34
  * the plugin's own settings or the way back from them.
35
35
  */
36
- const AppLayoutFooterLink = ({ path, name, icon: Icon }) => {
36
+ const AppLayoutFooterLink = ({ to, name, icon: Icon }) => {
37
37
  const { pathname } = useLocation();
38
- const fullPath = `/${path.replace(/^\/+/, "")}`;
39
- const isActive = pathname === fullPath || pathname.startsWith(`${fullPath}/`);
38
+ const isActive = pathname === to || pathname.startsWith(`${to}/`);
40
39
  return /* @__PURE__ */ jsx(Sidebar.MenuItem, { children: /* @__PURE__ */ jsxs(Sidebar.MenuButton, {
41
40
  isActive,
42
- render: /* @__PURE__ */ jsx(Link, { to: fullPath }),
41
+ render: /* @__PURE__ */ jsx(Link, { to }),
43
42
  children: [Icon && /* @__PURE__ */ jsx(Icon, {}), /* @__PURE__ */ jsx("span", {
44
43
  className: "min-w-0 flex-1 truncate",
45
44
  children: name
@@ -91,9 +90,9 @@ const AppLayoutSidebarHeader = ({ title, onCollapse }) => /* @__PURE__ */ jsxs("
91
90
  })]
92
91
  });
93
92
  /** Renders the persisted desktop sidebar beside the application page slot. */
94
- const AppLayoutDesktop = ({ atoms, children, footer, sidebar, title }) => {
95
- const [open, setOpen] = useAtom(atoms.open);
96
- const [width, setWidth] = useAtom(atoms.width);
93
+ const AppLayoutDesktop = ({ id, children, footer, sidebar, title }) => {
94
+ const [open, setOpen] = useAtom(appLayoutOpenState(id));
95
+ const [width, setWidth] = useAtom(appLayoutWidthState(id));
97
96
  const [resizing, setResizing] = useState(false);
98
97
  const asideRef = useRef(null);
99
98
  const currentWidth = width ?? 240;
@@ -180,7 +179,7 @@ const AppLayout = ({ id, sidebar, footer, title, children }) => /* @__PURE__ */
180
179
  className: "min-h-0 flex-1",
181
180
  sidebarKeyboardShortcut: false,
182
181
  children: /* @__PURE__ */ jsx(AppLayoutBody, {
183
- atoms: getAppLayoutAtoms(id),
182
+ id,
184
183
  sidebar,
185
184
  footer,
186
185
  title,
@@ -1,20 +1,13 @@
1
1
  import { RefObject } from "react";
2
2
  export declare const APP_LAYOUT_DEFAULT_WIDTH = 240;
3
- /** Persists the sidebar visibility separately for each application layout. */
4
- declare const createOpenAtom: (id: string) => import("jotai").WritableAtom<boolean, [boolean | typeof import("jotai/utils").RESET | ((prev: boolean) => boolean | typeof import("jotai/utils").RESET)], void>;
5
- /** Persists a custom sidebar width, with null selecting the default width. */
6
- declare const createWidthAtom: (id: string) => import("jotai").WritableAtom<number | null, [number | typeof import("jotai/utils").RESET | ((prev: number | null) => number | typeof import("jotai/utils").RESET | null) | null], void>;
7
- export type TAppLayoutAtoms = {
8
- open: ReturnType<typeof createOpenAtom>;
9
- width: ReturnType<typeof createWidthAtom>;
10
- };
11
- /** Reuses the same persisted atoms for every instance of an application layout. */
12
- export declare const getAppLayoutAtoms: (id: string) => TAppLayoutAtoms;
3
+ /** Whether each app layout's sidebar is open, per layout id. */
4
+ export declare const appLayoutOpenState: import("jotai-family").AtomFamily<string, import("jotai").WritableAtom<boolean, [boolean | typeof import("jotai/utils").RESET | ((prev: boolean) => boolean | typeof import("jotai/utils").RESET)], void>>;
5
+ /** Each app layout's dragged sidebar width; null is the default width. */
6
+ export declare const appLayoutWidthState: import("jotai-family").AtomFamily<string, import("jotai").WritableAtom<number | null, [number | typeof import("jotai/utils").RESET | ((prev: number | null) => number | typeof import("jotai/utils").RESET | null) | null], void>>;
13
7
  /** Resizes the application sidebar with pointer capture or keyboard steps. */
14
8
  export declare const AppLayoutResizeHandle: ({ panelRef, onResize, onReset, onResizingChange }: {
15
9
  panelRef: RefObject<HTMLElement | null>;
16
10
  onResize: (width: number) => void;
17
11
  onReset: () => void;
18
12
  onResizingChange: (resizing: boolean) => void;
19
- }) => import("react").JSX.Element;
20
- export {};
13
+ }) => import("react").JSX.Element;
@@ -1,27 +1,24 @@
1
+ import { storedFamily } from "../../../lib/stored.js";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import { useRef } from "react";
3
- import { atomWithStorage } from "jotai/utils";
4
+ import { z } from "zod";
4
5
  // src/modules/layout/components/AppLayoutResizeHandle.tsx
5
6
  const APP_LAYOUT_DEFAULT_WIDTH = 240;
6
7
  const APP_LAYOUT_MIN_WIDTH = 180;
7
8
  const APP_LAYOUT_MAX_WIDTH = 480;
8
9
  const APP_LAYOUT_KEYBOARD_STEP = 16;
9
- /** Persists the sidebar visibility separately for each application layout. */
10
- const createOpenAtom = (id) => atomWithStorage(`app-layout:${id}:open`, true, void 0, { getOnInit: true });
11
- /** Persists a custom sidebar width, with null selecting the default width. */
12
- const createWidthAtom = (id) => atomWithStorage(`app-layout:${id}:width`, null, void 0, { getOnInit: true });
13
- const appLayoutAtoms = /* @__PURE__ */ new Map();
14
- /** Reuses the same persisted atoms for every instance of an application layout. */
15
- const getAppLayoutAtoms = (id) => {
16
- const existing = appLayoutAtoms.get(id);
17
- if (existing) return existing;
18
- const atoms = {
19
- open: createOpenAtom(id),
20
- width: createWidthAtom(id)
21
- };
22
- appLayoutAtoms.set(id, atoms);
23
- return atoms;
24
- };
10
+ /** Whether each app layout's sidebar is open, per layout id. */
11
+ const appLayoutOpenState = storedFamily({
12
+ key: "erxes:layout:open",
13
+ schema: z.boolean(),
14
+ initial: true
15
+ });
16
+ /** Each app layout's dragged sidebar width; null is the default width. */
17
+ const appLayoutWidthState = storedFamily({
18
+ key: "erxes:layout:width",
19
+ schema: z.number().min(APP_LAYOUT_MIN_WIDTH).max(APP_LAYOUT_MAX_WIDTH).nullable(),
20
+ initial: null
21
+ });
25
22
  /** Keeps a resized pane within its configured width limits. */
26
23
  const clampWidth = (value) => Math.round(Math.min(APP_LAYOUT_MAX_WIDTH, Math.max(APP_LAYOUT_MIN_WIDTH, value)));
27
24
  /** Resizes the application sidebar with pointer capture or keyboard steps. */
@@ -67,4 +64,4 @@ const AppLayoutResizeHandle = ({ panelRef, onResize, onReset, onResizingChange }
67
64
  children: /* @__PURE__ */ jsx("span", { className: "absolute inset-y-0 right-0 w-0.5 bg-transparent transition-colors duration-150 group-hover/resize:bg-primary/40 group-focus-visible/resize:bg-primary group-active/resize:bg-primary" })
68
65
  });
69
66
  };
70
- export { APP_LAYOUT_DEFAULT_WIDTH, AppLayoutResizeHandle, getAppLayoutAtoms };
67
+ export { APP_LAYOUT_DEFAULT_WIDTH, AppLayoutResizeHandle, appLayoutOpenState, appLayoutWidthState };