@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
@@ -25,11 +25,14 @@ const pageHeaderStartVariants = cva("flex flex-none items-center gap-2", {
25
25
  } },
26
26
  defaultVariants: { variant: "default" }
27
27
  });
28
- const PageHeaderStart = ({ ref, children, className, variant, ...props }) => /* @__PURE__ */ jsx("div", {
28
+ const PageHeaderStart = ({ ref, children, className, variant, ...props }) => /* @__PURE__ */ jsxs("div", {
29
29
  ref,
30
30
  className: cn(pageHeaderStartVariants({ variant }), className),
31
31
  ...props,
32
- children
32
+ children: [/* @__PURE__ */ jsx("span", {
33
+ "data-sidebar-panel-slot": "",
34
+ className: "contents"
35
+ }), children]
33
36
  });
34
37
  const PageHeaderEnd = ({ ref, children, className, ...props }) => /* @__PURE__ */ jsx("div", {
35
38
  ref,
@@ -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
  ]
@@ -0,0 +1,30 @@
1
+ import { ReactNode } from "react";
2
+ interface EntityPickerProps<T, K extends string> {
3
+ items: T[];
4
+ /** The id and the text a search matches. */
5
+ itemKey: (item: T) => {
6
+ id: K;
7
+ label: string;
8
+ };
9
+ /** How an item reads in the list; its label by default. */
10
+ renderItem?: (item: T) => ReactNode;
11
+ value: K[];
12
+ /** The picked ids. One pick replaces the value unless `multiple`, where it toggles. */
13
+ onValueChange: (ids: K[]) => void;
14
+ multiple?: boolean;
15
+ /** Items keep their order (a tree reads top down); otherwise the picked ones come first. */
16
+ keepOrder?: boolean;
17
+ loading?: boolean;
18
+ error?: Error | null;
19
+ /** Searching on the server: `items` are already the matches, so they are not filtered here. */
20
+ onSearchChange?: (search: string) => void;
21
+ searchPlaceholder?: string;
22
+ /** A first row that picks nothing. */
23
+ noneLabel?: string;
24
+ /** Above the list, e.g. the picked tags as badges. */
25
+ header?: ReactNode;
26
+ /** A row for what was searched, e.g. "Add tag: VIP"; `clear` empties the search. */
27
+ renderCreate?: (search: string, clear: () => void) => ReactNode;
28
+ }
29
+ export declare const EntityPicker: <T, K extends string = string>({ items, itemKey, renderItem, value, onValueChange, multiple, keepOrder, loading, error, onSearchChange, searchPlaceholder, noneLabel, header, renderCreate }: EntityPickerProps<T, K>) => import("react").JSX.Element;
30
+ export {};
@@ -0,0 +1,60 @@
1
+ import { Combobox } from "../../components/combobox.js";
2
+ import { Command } from "../../components/command.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { useState } from "react";
5
+ // src/modules/pickers/EntityPicker.tsx
6
+ const EntityPicker = ({ items, itemKey, renderItem, value, onValueChange, multiple, keepOrder, loading, error, onSearchChange, searchPlaceholder, noneLabel, header, renderCreate }) => {
7
+ const [search, setSearch] = useState("");
8
+ const [pickedAtOpen] = useState(value);
9
+ const term = search.trim().toLowerCase();
10
+ const matches = items.map((item) => ({
11
+ item,
12
+ ...itemKey(item)
13
+ })).filter((row) => onSearchChange !== void 0 || row.label.toLowerCase().includes(term));
14
+ const rows = keepOrder ? matches : matches.toSorted((a, b) => Number(pickedAtOpen.includes(b.id)) - Number(pickedAtOpen.includes(a.id)));
15
+ const pick = (id) => onValueChange(!multiple ? [id] : value.includes(id) ? value.filter((item) => item !== id) : [...value, id]);
16
+ const changeSearch = (next) => {
17
+ setSearch(next);
18
+ onSearchChange?.(next);
19
+ };
20
+ return /* @__PURE__ */ jsxs(Command, {
21
+ shouldFilter: false,
22
+ children: [
23
+ /* @__PURE__ */ jsx(Command.Input, {
24
+ value: search,
25
+ onValueChange: changeSearch,
26
+ placeholder: searchPlaceholder,
27
+ variant: "secondary",
28
+ wrapperClassName: "flex-auto",
29
+ focusOnMount: true
30
+ }),
31
+ header,
32
+ error && /* @__PURE__ */ jsx("p", {
33
+ role: "alert",
34
+ className: "text-destructive px-3 py-2 text-sm",
35
+ children: error.message
36
+ }),
37
+ /* @__PURE__ */ jsxs(Command.List, {
38
+ className: "max-h-75 overflow-y-auto",
39
+ children: [
40
+ noneLabel && !term && /* @__PURE__ */ jsxs(Command.Item, {
41
+ value: "__none__",
42
+ onSelect: () => onValueChange([]),
43
+ children: [/* @__PURE__ */ jsx("span", {
44
+ className: "text-muted-foreground",
45
+ children: noneLabel
46
+ }), /* @__PURE__ */ jsx(Combobox.Check, { checked: value.length === 0 })]
47
+ }),
48
+ renderCreate?.(search.trim(), () => changeSearch("")),
49
+ !error && /* @__PURE__ */ jsx(Combobox.Empty, { loading }),
50
+ rows.map(({ item, id, label }) => /* @__PURE__ */ jsxs(Command.Item, {
51
+ value: id,
52
+ onSelect: () => pick(id),
53
+ children: [renderItem ? renderItem(item) : label, /* @__PURE__ */ jsx(Combobox.Check, { checked: value.includes(id) })]
54
+ }, id))
55
+ ]
56
+ })
57
+ ]
58
+ });
59
+ };
60
+ export { EntityPicker };
@@ -0,0 +1,41 @@
1
+ import { AvatarProps } from "../../components/avatar.js";
2
+ import { Combobox } from "../../components/combobox.js";
3
+ import { RecordTableInlineCell } from "../record-table/components/RecordTableCellInline.js";
4
+ import { MemberQueries } from "./members.js";
5
+ import { ComponentProps, ComponentRef, RefAttributes } from "react";
6
+ /** One member by id: avatar and name, or the placeholder when there is none. */
7
+ export declare const MemberInline: ({ memberId, members, placeholder, size, className }: {
8
+ memberId: string | null | undefined;
9
+ members: MemberQueries;
10
+ placeholder?: string;
11
+ size?: AvatarProps['size'];
12
+ className?: string;
13
+ }) => import("react").JSX.Element;
14
+ interface SelectMemberProps {
15
+ value: string | null | undefined;
16
+ onValueChange: (id: string | null) => void;
17
+ /** Where the members come from: `memberQueries` from `@erxes/core-contract/client`. */
18
+ members: MemberQueries;
19
+ placeholder?: string;
20
+ /** A first row that picks no member, e.g. "Anyone" on a filter. */
21
+ noneLabel?: string;
22
+ }
23
+ /** The member as a record table cell; click to pick another. */
24
+ declare const SelectMemberInlineCell: ({ ref, value, onValueChange, members, noneLabel, scope, placeholder, size, className, variant, id, 'aria-label': ariaLabel }: SelectMemberProps & {
25
+ scope?: string;
26
+ size?: AvatarProps['size'];
27
+ className?: string;
28
+ /** `field` beside its label in a side panel; a table cell by default. */
29
+ variant?: ComponentProps<typeof RecordTableInlineCell.Trigger>['variant'];
30
+ id?: string;
31
+ /** Names the picker while it shows no member. */
32
+ 'aria-label'?: string;
33
+ } & RefAttributes<ComponentRef<typeof RecordTableInlineCell.Trigger>>) => import("react").JSX.Element;
34
+ /** A member picker button; its other props (an id, `Form.Control`'s aria wiring) go to the button. */
35
+ declare const SelectMemberField: ({ value, onValueChange, members, noneLabel, placeholder, className, ...trigger }: SelectMemberProps & Omit<ComponentProps<typeof Combobox.Trigger>, 'value' | 'children' | 'placeholder'>) => import("react").JSX.Element;
36
+ /** The member picker as a table cell and as a field. */
37
+ export declare const SelectMember: {
38
+ InlineCell: typeof SelectMemberInlineCell;
39
+ Field: typeof SelectMemberField;
40
+ };
41
+ export {};
@@ -0,0 +1,122 @@
1
+ import { Avatar } from "../../components/avatar.js";
2
+ import { Badge } from "../../components/badge.js";
3
+ import { Combobox } from "../../components/combobox.js";
4
+ import { Popover } from "../../components/popover.js";
5
+ import { cn } from "../../lib/utils.js";
6
+ import { readImage } from "../../utils/core.js";
7
+ import { PopoverScoped } from "../hotkey/components/PopoverScoped.js";
8
+ import { RecordTableInlineCell } from "../record-table/components/RecordTableCellInline.js";
9
+ import { EntityPicker } from "./EntityPicker.js";
10
+ import { memberName, useMembersById } from "./members.js";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ import { useState } from "react";
13
+ import { useQuery } from "@tanstack/react-query";
14
+ // src/modules/pickers/SelectMember.tsx
15
+ /** A member's name, with an "Inactive" badge for disabled ones. */
16
+ const MemberLabel = ({ member }) => member.status === "active" ? /* @__PURE__ */ jsx(Fragment, { children: memberName(member) }) : /* @__PURE__ */ jsxs("span", {
17
+ className: "inline-flex items-center gap-1",
18
+ children: [/* @__PURE__ */ jsx("span", { children: memberName(member) }), /* @__PURE__ */ jsx(Badge, {
19
+ variant: "destructive",
20
+ size: "sm",
21
+ className: "h-5 shrink-0",
22
+ children: "Inactive"
23
+ })]
24
+ });
25
+ /** One member by id: avatar and name, or the placeholder when there is none. */
26
+ const MemberInline = ({ memberId, members, placeholder, size = "lg", className }) => {
27
+ const member = useMembersById([memberId], members).get(memberId ?? "");
28
+ return /* @__PURE__ */ jsxs(Fragment, { children: [member && /* @__PURE__ */ jsxs(Avatar, {
29
+ size,
30
+ children: [/* @__PURE__ */ jsx(Avatar.Image, { src: readImage(member.avatarUrl) }), /* @__PURE__ */ jsx(Avatar.Fallback, { children: memberName(member).charAt(0) })]
31
+ }), /* @__PURE__ */ jsx(Combobox.Value, {
32
+ value: member && /* @__PURE__ */ jsx(MemberLabel, { member }),
33
+ loading: Boolean(memberId) && !member,
34
+ placeholder: placeholder ?? "Select a member",
35
+ className
36
+ })] });
37
+ };
38
+ /** Active members, searched on their name and email; picking one reports its id. */
39
+ const MemberList = ({ value, members, noneLabel, onPick }) => {
40
+ const team = useQuery(members.team);
41
+ return /* @__PURE__ */ jsx(EntityPicker, {
42
+ items: team.data?.data ?? [],
43
+ itemKey: (member) => ({
44
+ id: member.id,
45
+ label: `${memberName(member)} ${member.email}`
46
+ }),
47
+ renderItem: (member) => /* @__PURE__ */ jsx(MemberInline, {
48
+ memberId: member.id,
49
+ members,
50
+ placeholder: "Unnamed user"
51
+ }),
52
+ value: value ? [value] : [],
53
+ onValueChange: ([id]) => onPick(id ?? null),
54
+ noneLabel,
55
+ loading: team.isPending,
56
+ error: team.error
57
+ });
58
+ };
59
+ /** The member as a record table cell; click to pick another. */
60
+ const SelectMemberInlineCell = ({ ref, value, onValueChange, members, noneLabel, scope, placeholder, size = "lg", className, variant, id, "aria-label": ariaLabel }) => {
61
+ const [open, setOpen] = useState(false);
62
+ return /* @__PURE__ */ jsxs(PopoverScoped, {
63
+ scope,
64
+ open,
65
+ onOpenChange: setOpen,
66
+ children: [/* @__PURE__ */ jsx(RecordTableInlineCell.Trigger, {
67
+ ref,
68
+ id,
69
+ "aria-label": ariaLabel,
70
+ variant,
71
+ className,
72
+ children: /* @__PURE__ */ jsx("span", {
73
+ className: "contents text-xs",
74
+ children: /* @__PURE__ */ jsx(MemberInline, {
75
+ memberId: value,
76
+ members,
77
+ placeholder: placeholder ?? "",
78
+ size
79
+ })
80
+ })
81
+ }), /* @__PURE__ */ jsx(RecordTableInlineCell.Content, { children: /* @__PURE__ */ jsx(MemberList, {
82
+ value,
83
+ members,
84
+ noneLabel,
85
+ onPick: (next) => {
86
+ onValueChange(next);
87
+ setOpen(false);
88
+ }
89
+ }) })]
90
+ });
91
+ };
92
+ /** A member picker button; its other props (an id, `Form.Control`'s aria wiring) go to the button. */
93
+ const SelectMemberField = ({ value, onValueChange, members, noneLabel, placeholder, className, ...trigger }) => {
94
+ const [open, setOpen] = useState(false);
95
+ return /* @__PURE__ */ jsxs(Popover, {
96
+ open,
97
+ onOpenChange: setOpen,
98
+ children: [/* @__PURE__ */ jsx(Combobox.Trigger, {
99
+ ...trigger,
100
+ className: cn("w-full", className),
101
+ children: /* @__PURE__ */ jsx(MemberInline, {
102
+ memberId: value,
103
+ members,
104
+ placeholder
105
+ })
106
+ }), /* @__PURE__ */ jsx(Combobox.Content, { children: /* @__PURE__ */ jsx(MemberList, {
107
+ value,
108
+ members,
109
+ noneLabel,
110
+ onPick: (next) => {
111
+ onValueChange(next);
112
+ setOpen(false);
113
+ }
114
+ }) })]
115
+ });
116
+ };
117
+ /** The member picker as a table cell and as a field. */
118
+ const SelectMember = {
119
+ InlineCell: SelectMemberInlineCell,
120
+ Field: SelectMemberField
121
+ };
122
+ export { MemberInline, SelectMember };
@@ -0,0 +1,30 @@
1
+ import { UseQueryOptions } from "@tanstack/react-query";
2
+ /** A team member as the pickers show one: core's `User` has these fields and more. */
3
+ export interface Member {
4
+ id: string;
5
+ email: string;
6
+ fullName: string | null;
7
+ username: string | null;
8
+ avatarUrl: string | null;
9
+ status: string;
10
+ }
11
+ type MemberQuery = UseQueryOptions<{
12
+ data: Member[];
13
+ }, Error, {
14
+ data: Member[];
15
+ }>;
16
+ /**
17
+ * Where members come from, as TanStack query options. erxes-ui knows nothing of core: web and
18
+ * plugin UIs pass `memberQueries` from `@erxes/core-contract/client`.
19
+ */
20
+ export interface MemberQueries {
21
+ /** The active team: every picker's list, and the names most screens show. */
22
+ team: MemberQuery;
23
+ /** Members by id, for those outside the active team (disabled ones). */
24
+ byIds: (ids: string[]) => MemberQuery;
25
+ }
26
+ /** How a member reads: the display name, else the username, else the email. */
27
+ export declare const memberName: (member: Pick<Member, 'fullName' | 'username' | 'email'>) => string;
28
+ /** Members by id, any status. The active team answers most; only the rest are fetched. */
29
+ export declare const useMembersById: (ids: (string | null | undefined)[], members: MemberQueries) => Map<string, Member>;
30
+ export {};
@@ -0,0 +1,18 @@
1
+ import { useMemo } from "react";
2
+ import { keepPreviousData, useQuery } from "@tanstack/react-query";
3
+ // src/modules/pickers/members.ts
4
+ /** How a member reads: the display name, else the username, else the email. */
5
+ const memberName = (member) => member.fullName || member.username || member.email;
6
+ /** Members by id, any status. The active team answers most; only the rest are fetched. */
7
+ const useMembersById = (ids, members) => {
8
+ const team = useQuery(members.team);
9
+ const known = useMemo(() => new Set((team.data?.data ?? []).map((user) => user.id)), [team.data]);
10
+ const wanted = useMemo(() => [...new Set(ids.filter((id) => Boolean(id) && !known.has(id ?? "")))].toSorted((a, b) => a.localeCompare(b)), [ids, known]);
11
+ const others = useQuery({
12
+ ...members.byIds(wanted),
13
+ enabled: team.isFetched && wanted.length > 0,
14
+ placeholderData: keepPreviousData
15
+ });
16
+ return useMemo(() => new Map([...team.data?.data ?? [], ...others.data?.data ?? []].map((user) => [user.id, user])), [team.data, others.data]);
17
+ };
18
+ export { memberName, useMembersById };
@@ -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 };
@@ -2,9 +2,8 @@ import { Badge } from "../../../components/badge.js";
2
2
  import { Button, buttonVariants } from "../../../components/button.js";
3
3
  import { Popover } from "../../../components/popover.js";
4
4
  import { cn } from "../../../lib/utils.js";
5
- import { CellColumnHead } from "./RecordTableCell.js";
5
+ import { CellColumnHead, useCellLabel } from "./RecordTableCell.js";
6
6
  import { jsx } from "react/jsx-runtime";
7
- import { use, useId } from "react";
8
7
  import { cva } from "class-variance-authority";
9
8
  // src/modules/record-table/components/RecordTableCellInline.tsx
10
9
  const cellTriggerVariants = cva("h-8 px-2 w-full justify-start text-left focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:shadow-subtle overflow-hidden", {
@@ -20,13 +19,10 @@ const cellTriggerVariants = cva("h-8 px-2 w-full justify-start text-left focus-v
20
19
  defaultVariants: { variant: "cell" }
21
20
  });
22
21
  const RecordTableCellTrigger = ({ ref, children, className, id, variant, empty, ...props }) => {
23
- const ownId = useId();
24
- const triggerId = id ?? ownId;
25
- const columnHead = use(CellColumnHead);
22
+ const label = useCellLabel(id);
26
23
  return /* @__PURE__ */ jsx(Popover.Trigger, {
27
24
  render: /* @__PURE__ */ jsx(Button, {
28
- id: triggerId,
29
- "aria-labelledby": columnHead ? `${columnHead} ${triggerId}` : void 0,
25
+ ...label,
30
26
  variant: "ghost",
31
27
  className: cn(cellTriggerVariants({
32
28
  variant,
@@ -1,10 +1,12 @@
1
1
  import { ScrollArea } from "../../../components/scroll-area.js";
2
2
  import { mergeRefs } from "../../../lib/utils.js";
3
3
  import { useCursorScroll } from "../hooks/useCursorScroll.js";
4
+ import { tablePositionState } from "../states/RecordTableCursorState.js";
4
5
  import "../types/RecordTableCursorTypes.js";
5
6
  import { RecordTableRowSkeleton } from "./RecordTableRowSkeleton.js";
6
7
  import { jsx, jsxs } from "react/jsx-runtime";
7
8
  import { createContext, useContext, useEffect, useState } from "react";
9
+ import { useStore } from "jotai";
8
10
  import { useDebouncedCallback } from "use-debounce";
9
11
  // src/modules/record-table/components/RecordTableCursor.tsx
10
12
  const RecordTableCursorContext = createContext(null);
@@ -13,19 +15,6 @@ const useRecordTableCursorContext = () => {
13
15
  if (!context) throw new Error("Cursor skeletons must be used within a RecordTableCursorProvider");
14
16
  return context;
15
17
  };
16
- /** Session storage is best effort: when it is blocked the position is simply not restored. */
17
- const remember = (key, value) => {
18
- try {
19
- sessionStorage.setItem(key, value);
20
- } catch {}
21
- };
22
- const recall = (key) => {
23
- try {
24
- return sessionStorage.getItem(key);
25
- } catch {
26
- return null;
27
- }
28
- };
29
18
  /**
30
19
  * Scrolls a cursor-paged table. With a `sessionKey` it remembers the first visible row and the
31
20
  * scroll position for the session, and restores the position when the rows come back.
@@ -37,25 +26,31 @@ const RecordTableCursorProvider = ({ children, hasPreviousPage, loading, dataLen
37
26
  offset
38
27
  });
39
28
  const [viewport, setViewport] = useState(null);
40
- const rememberScrollTop = useDebouncedCallback((scrollTop) => {
41
- if (sessionKey) remember(`${sessionKey}_scroll`, String(scrollTop));
42
- }, 150);
29
+ const store = useStore();
30
+ const remember = (part) => {
31
+ if (sessionKey) store.set(tablePositionState(sessionKey), (saved) => ({
32
+ ...saved,
33
+ ...part
34
+ }));
35
+ };
36
+ const rememberScrollTop = useDebouncedCallback((scroll) => remember({ scroll }), 150);
43
37
  const handleScroll = (event) => {
44
38
  const scroll = event.currentTarget;
45
39
  const firstVisibleRow = scroll.querySelector(".in-view");
46
- if (sessionKey && firstVisibleRow) remember(sessionKey, firstVisibleRow.id);
40
+ if (firstVisibleRow) remember({ row: firstVisibleRow.id });
47
41
  rememberScrollTop(scroll.scrollTop);
48
42
  };
49
43
  useEffect(() => {
50
44
  const scroll = scrollRef.current;
51
45
  if (!dataLength || loading || !scroll || !sessionKey) return;
52
- const saved = recall(`${sessionKey}_scroll`);
53
- if (saved) scroll.scrollTop = Number.parseInt(saved, 10);
46
+ const saved = store.get(tablePositionState(sessionKey)).scroll;
47
+ if (saved) scroll.scrollTop = saved;
54
48
  }, [
55
49
  loading,
56
50
  dataLength,
57
51
  scrollRef,
58
- sessionKey
52
+ sessionKey,
53
+ store
59
54
  ]);
60
55
  return /* @__PURE__ */ jsx(RecordTableCursorContext.Provider, {
61
56
  value: {
@@ -10,7 +10,7 @@ declare const tablePrefsSchema: z.ZodObject<{
10
10
  stickyColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
11
11
  }, z.core.$strip>;
12
12
  type TablePrefs = z.infer<typeof tablePrefsSchema>;
13
- /** A table's column layout, kept in localStorage per `tableId`; without one nothing is kept. */
13
+ /** A table's column layout, kept in this browser per `tableId`; without one nothing is kept. */
14
14
  export declare const useTablePreferences: (tableId: string | undefined) => {
15
15
  prefs: {
16
16
  columnOrder?: string[] | undefined;