@erxes/ui 4.0.0-v2.2 → 4.0.0-v2.4

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 (65) hide show
  1. package/dist/components/charts.js +3 -1
  2. package/dist/components/combobox.d.ts +1 -1
  3. package/dist/components/combobox.js +4 -1
  4. package/dist/components/date-picker-value.d.ts +5 -9
  5. package/dist/components/date-picker-value.js +15 -34
  6. package/dist/components/date-picker.d.ts +0 -4
  7. package/dist/components/date-picker.js +5 -7
  8. package/dist/components/date-text-input.d.ts +2 -4
  9. package/dist/components/date-text-input.js +11 -9
  10. package/dist/components/dialog.js +1 -1
  11. package/dist/components/empty.d.ts +5 -1
  12. package/dist/components/empty.js +24 -2
  13. package/dist/components/form.d.ts +2 -2
  14. package/dist/components/select.d.ts +1 -1
  15. package/dist/components/select.js +3 -1
  16. package/dist/components/sheet.js +1 -1
  17. package/dist/components/sidebar/panel.js +1 -1
  18. package/dist/federation.d.ts +4 -0
  19. package/dist/federation.js +7 -1
  20. package/dist/index.d.ts +4 -5
  21. package/dist/index.js +4 -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/blocks/hooks/useBarcodeSizeForm.d.ts +1 -1
  28. package/dist/modules/display/components/RelativeDateDisplay.d.ts +4 -5
  29. package/dist/modules/display/components/RelativeDateDisplay.js +7 -8
  30. package/dist/modules/filter/components/FilterBar.js +5 -7
  31. package/dist/modules/filter/components/FilterDialog.js +4 -5
  32. package/dist/modules/filter/components/FilterPopover.js +1 -1
  33. package/dist/modules/filter/components/FilterProvider.d.ts +1 -2
  34. package/dist/modules/filter/components/FilterProvider.js +1 -2
  35. package/dist/modules/filter/types/filter.d.ts +0 -1
  36. package/dist/modules/layout/components/AppLayout.d.ts +2 -2
  37. package/dist/modules/layout/components/AppLayout.js +8 -9
  38. package/dist/modules/layout/components/AppLayoutResizeHandle.d.ts +5 -12
  39. package/dist/modules/layout/components/AppLayoutResizeHandle.js +15 -18
  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/record-field/components/NumberField.js +4 -2
  43. package/dist/modules/record-field/components/TextField.js +9 -2
  44. package/dist/modules/record-table/components/RecordTableCell.d.ts +9 -0
  45. package/dist/modules/record-table/components/RecordTableCell.js +16 -2
  46. package/dist/modules/record-table/components/RecordTableCellInline.js +3 -7
  47. package/dist/modules/record-table/components/RecordTableCursor.js +15 -20
  48. package/dist/modules/record-table/hooks/useTablePreferences.d.ts +1 -1
  49. package/dist/modules/record-table/hooks/useTablePreferences.js +18 -31
  50. package/dist/modules/record-table/states/RecordTableCursorState.d.ts +21 -1
  51. package/dist/modules/record-table/states/RecordTableCursorState.js +21 -3
  52. package/dist/state/sidebarPanelState.js +7 -2
  53. package/dist/state/themeState.d.ts +8 -2
  54. package/dist/state/themeState.js +13 -4
  55. package/package.json +5 -2
  56. package/dist/constants/IntlLanguages.d.ts +0 -74
  57. package/dist/constants/IntlLanguages.js +0 -76
  58. package/dist/hooks/use-query-state.d.ts +0 -16
  59. package/dist/hooks/use-query-state.js +0 -122
  60. package/dist/modules/filter/hooks/useFilterQueryState.d.ts +0 -4
  61. package/dist/modules/filter/hooks/useFilterQueryState.js +0 -14
  62. package/dist/types/Theme.d.ts +0 -1
  63. package/dist/types/Theme.js +0 -0
  64. package/dist/utils/localization/formatDateISOStringToRelativeDate.d.ts +0 -2
  65. package/dist/utils/localization/formatDateISOStringToRelativeDate.js +0 -16
@@ -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,
@@ -18,7 +18,7 @@ export declare const useBarcodeSizeForm: ({ size, onResize }: {
18
18
  height: number;
19
19
  }> | undefined;
20
20
  settingsOpen: boolean;
21
- applySize: (e?: React.BaseSyntheticEvent) => Promise<void>;
21
+ applySize: (e?: React.BaseSyntheticEvent) => Promise<void | undefined>;
22
22
  handleSettingsOpenChange: (open: boolean) => void;
23
23
  handlePresetChange: (value: string) => void;
24
24
  handleInputKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
@@ -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 };
@@ -1,9 +1,9 @@
1
1
  import { Sidebar } from "../../../components/sidebar.js";
2
- export declare const NavigationMenuLinkItem: ({ ref, name, icon: IconComponent, path, pathPrefix, children, className, isActive: isActiveProp, label, action, itemClassName, ...props }: React.ComponentProps<typeof Sidebar.MenuButton> & {
2
+ export declare const NavigationMenuLinkItem: ({ ref, name, icon: IconComponent, to, children, className, isActive: isActiveProp, label, action, itemClassName, ...props }: React.ComponentProps<typeof Sidebar.MenuButton> & {
3
3
  name: string;
4
4
  icon?: React.ElementType;
5
- path: string;
6
- pathPrefix?: string;
5
+ /** The address, from the app's paths. */
6
+ to: string;
7
7
  isActive?: boolean;
8
8
  label?: React.ReactNode;
9
9
  action?: React.ReactNode;
@@ -4,15 +4,14 @@ import { useNavigationMenuItemControls } from "./NavigationMenuItemControls.js";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { Link, useLocation } from "react-router-dom";
6
6
  // src/modules/navigation-menu/components/NavigationMenu.tsx
7
- const NavigationMenuLinkItem = ({ ref, name, icon: IconComponent, path, pathPrefix, children, className, isActive: isActiveProp, label, action, itemClassName, ...props }) => {
7
+ const NavigationMenuLinkItem = ({ ref, name, icon: IconComponent, to, children, className, isActive: isActiveProp, label, action, itemClassName, ...props }) => {
8
8
  const { pathname } = useLocation();
9
- const fullPath = `/${pathPrefix ? `${pathPrefix.replace(/\/$/, "")}/` : ""}${path.replace(/^\//, "")}`.replace(/\/$/, "") || "/";
10
- const isActive = pathname.startsWith(fullPath);
9
+ const isActive = pathname.startsWith(to);
11
10
  const controls = useNavigationMenuItemControls();
12
- const order = controls?.getOrder(fullPath);
11
+ const order = controls?.getOrder(to);
13
12
  return /* @__PURE__ */ jsxs(Sidebar.MenuItem, {
14
13
  className: cn(itemClassName, order !== void 0 && "order-(--order)"),
15
- "data-nav-path": controls ? fullPath : void 0,
14
+ "data-nav-path": controls ? to : void 0,
16
15
  style: { "--order": order },
17
16
  children: [
18
17
  /* @__PURE__ */ jsxs(Sidebar.MenuButton, {
@@ -20,7 +19,7 @@ const NavigationMenuLinkItem = ({ ref, name, icon: IconComponent, path, pathPref
20
19
  ref,
21
20
  className,
22
21
  ...props,
23
- render: /* @__PURE__ */ jsx(Link, { to: fullPath }),
22
+ render: /* @__PURE__ */ jsx(Link, { to }),
24
23
  children: [
25
24
  IconComponent && /* @__PURE__ */ jsx(IconComponent, { className: cn("text-accent-foreground", isActive && "text-primary-text") }),
26
25
  label || /* @__PURE__ */ jsx("span", {
@@ -33,7 +32,7 @@ const NavigationMenuLinkItem = ({ ref, name, icon: IconComponent, path, pathPref
33
32
  action,
34
33
  controls?.renderActions({
35
34
  name,
36
- path: fullPath,
35
+ path: to,
37
36
  icon: IconComponent
38
37
  })
39
38
  ]
@@ -1,4 +1,5 @@
1
1
  import { Input } from "../../../components/input.js";
2
+ import { useFormat } from "../../../lib/format.js";
2
3
  import { TextOverflowTooltip } from "../../../components/text-overflow.js";
3
4
  import { PopoverScoped } from "../../hotkey/components/PopoverScoped.js";
4
5
  import { RecordTableInlineCell } from "../../record-table/components/RecordTableCellInline.js";
@@ -6,10 +7,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
6
7
  import { useState } from "react";
7
8
  // src/modules/record-field/components/NumberField.tsx
8
9
  const NumberField = ({ placeholder, value, scope, onSave, onValueChange, formatValue, children, ...props }) => {
10
+ const fmt = useFormat();
9
11
  const [isOpen, setIsOpen] = useState(false);
10
12
  const [editingValue, setEditingValue] = useState(String(value));
11
13
  const [isEdited, setIsEdited] = useState(false);
12
- const shown = isOpen ? editingValue : formatValue ? formatValue(value) : value.toLocaleString();
14
+ const shown = isOpen ? editingValue : formatValue ? formatValue(value) : fmt.number(value);
13
15
  const resetEditing = () => {
14
16
  setEditingValue(String(value));
15
17
  setIsEdited(false);
@@ -42,7 +44,7 @@ const NumberField = ({ placeholder, value, scope, onSave, onValueChange, formatV
42
44
  render: /* @__PURE__ */ jsx("form", { onSubmit: handleAction }),
43
45
  children: [/* @__PURE__ */ jsx(Input, {
44
46
  type: "text",
45
- value: editingValue.toLocaleString(),
47
+ value: editingValue,
46
48
  onChange: (e) => {
47
49
  const rawValue = e.target.value.replace(/,/g, "");
48
50
  if (/^-?\d*\.?\d*$/.test(rawValue)) {
@@ -1,13 +1,16 @@
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";
4
5
  import { RecordTableInlineCell } from "../../record-table/components/RecordTableCellInline.js";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { useState } from "react";
7
+ import { use, useState } from "react";
7
8
  // src/modules/record-field/components/TextField.tsx
8
9
  const TextField = ({ ref, placeholder, value, scope, onSave, onValueChange, defaultOpen = false, variant = "input", children, ...props }) => {
9
10
  const [isOpen, setIsOpen] = useState(defaultOpen);
10
11
  const [editingValue, setEditingValue] = useState(value);
12
+ const shown = isOpen ? editingValue : value;
13
+ const labelled = use(CellColumnHead) !== void 0;
11
14
  /** Saves a changed text value and closes the inline editor. */
12
15
  const handleAction = (e) => {
13
16
  e?.preventDefault();
@@ -40,7 +43,11 @@ const TextField = ({ ref, placeholder, value, scope, onSave, onValueChange, defa
40
43
  empty: !value,
41
44
  ...props,
42
45
  ref,
43
- children: [children, /* @__PURE__ */ jsx(TextOverflowTooltip, { value: (isOpen ? editingValue : value) || placeholder })]
46
+ children: [children, shown ? /* @__PURE__ */ jsx(TextOverflowTooltip, { value: shown }) : /* @__PURE__ */ jsx("span", {
47
+ "aria-hidden": labelled,
48
+ className: "truncate",
49
+ children: placeholder
50
+ })]
44
51
  }), /* @__PURE__ */ jsxs(RecordTableInlineCell.Content, {
45
52
  render: /* @__PURE__ */ jsx("form", { onSubmit: handleAction }),
46
53
  children: [/* @__PURE__ */ jsx(Input, {
@@ -1,6 +1,15 @@
1
1
  import React from "react";
2
2
  /** The header cell id of the column a cell sits in, so its control is named by the column. */
3
3
  export declare const CellColumnHead: React.Context<string | undefined>;
4
+ /**
5
+ * A cell control's id and name: the column head (or a side panel field's label), then the
6
+ * control's own text ("Emails ada@…"), so an empty value is still named. Spread it before the
7
+ * caller's props, which win.
8
+ */
9
+ export declare const useCellLabel: (id?: string) => {
10
+ id: string;
11
+ 'aria-labelledby': string | undefined;
12
+ };
4
13
  /** A body cell. Its width and pinned offset are CSS variables the table container sets. */
5
14
  export declare const RecordTableCell: ({ ref, children, className, columnId, pinned, style, ...props }: React.HTMLAttributes<HTMLTableCellElement> & {
6
15
  columnId: string;
@@ -2,10 +2,24 @@ import { Table } from "../../../components/table.js";
2
2
  import { cn } from "../../../lib/utils.js";
3
3
  import { useRecordTable } from "./RecordTableProvider.js";
4
4
  import { jsx } from "react/jsx-runtime";
5
- import { createContext } from "react";
5
+ import { createContext, use, useId } from "react";
6
6
  // src/modules/record-table/components/RecordTableCell.tsx
7
7
  /** The header cell id of the column a cell sits in, so its control is named by the column. */
8
8
  const CellColumnHead = createContext(void 0);
9
+ /**
10
+ * A cell control's id and name: the column head (or a side panel field's label), then the
11
+ * control's own text ("Emails ada@…"), so an empty value is still named. Spread it before the
12
+ * caller's props, which win.
13
+ */
14
+ const useCellLabel = (id) => {
15
+ const ownId = useId();
16
+ const controlId = id ?? ownId;
17
+ const head = use(CellColumnHead);
18
+ return {
19
+ id: controlId,
20
+ "aria-labelledby": head ? `${head} ${controlId}` : void 0
21
+ };
22
+ };
9
23
  /** A body cell. Its width and pinned offset are CSS variables the table container sets. */
10
24
  const RecordTableCell = ({ ref, children, className, columnId, pinned, style, ...props }) => {
11
25
  const { headId } = useRecordTable();
@@ -32,4 +46,4 @@ const RecordTableCell = ({ ref, children, className, columnId, pinned, style, ..
32
46
  })
33
47
  });
34
48
  };
35
- export { CellColumnHead, RecordTableCell };
49
+ export { CellColumnHead, RecordTableCell, useCellLabel };