@sincpro/web-ui 2.0.0 → 2.2.0

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 (143) hide show
  1. package/README.md +45 -0
  2. package/dist/components/activity/Activity.d.ts +13 -14
  3. package/dist/components/activity/Activity.js +1 -1
  4. package/dist/components/activity/Messages.d.ts +5 -5
  5. package/dist/components/activity/Messages.js +8 -8
  6. package/dist/components/attachments/Attachments.d.ts +7 -1
  7. package/dist/components/attachments/Attachments.js +8 -2
  8. package/dist/components/board/Board.d.ts +32 -2
  9. package/dist/components/board/Board.js +27 -4
  10. package/dist/components/board/index.d.ts +1 -1
  11. package/dist/components/board/index.js +2 -1
  12. package/dist/components/form/Form.js +6 -6
  13. package/dist/components/form/index.js +2 -2
  14. package/dist/components/frame/FrameView.d.ts +5 -5
  15. package/dist/components/frame/FrameView.js +4 -4
  16. package/dist/components/listing/GroupingLevels.d.ts +22 -22
  17. package/dist/components/listing/GroupingLevels.js +9 -9
  18. package/dist/components/listing/Listing.d.ts +11 -11
  19. package/dist/components/listing/Listing.js +11 -11
  20. package/dist/components/listing/ListingBar.js +11 -11
  21. package/dist/components/listing/Row.d.ts +19 -19
  22. package/dist/components/listing/Row.js +27 -27
  23. package/dist/components/listing/SortMenu.d.ts +36 -36
  24. package/dist/components/listing/SortMenu.js +6 -6
  25. package/dist/components/listing/grouping.d.ts +16 -16
  26. package/dist/components/listing/grouping.js +6 -6
  27. package/dist/components/listing/index.js +1 -1
  28. package/dist/components/listing/modelColumns.d.ts +25 -25
  29. package/dist/components/listing/modelColumns.js +24 -24
  30. package/dist/components/listing/pages.js +4 -4
  31. package/dist/components/listing/set.d.ts +18 -18
  32. package/dist/components/navigation/NavigationTree.js +2 -2
  33. package/dist/components/navigation/index.js +2 -2
  34. package/dist/components/record/RecordSkeleton.js +7 -7
  35. package/dist/components/search/CriteriaBuilder.d.ts +22 -22
  36. package/dist/components/search/CriteriaBuilder.js +31 -31
  37. package/dist/components/search/CriteriaChips.d.ts +9 -9
  38. package/dist/components/search/CriteriaChips.js +12 -12
  39. package/dist/components/search/FilterBuilder.d.ts +67 -67
  40. package/dist/components/search/FilterBuilder.js +104 -104
  41. package/dist/components/search/JoinWord.d.ts +1 -1
  42. package/dist/components/search/JoinWord.js +14 -14
  43. package/dist/components/search/JsonEditor.d.ts +8 -8
  44. package/dist/components/search/JsonEditor.js +16 -16
  45. package/dist/components/search/SearchBar.d.ts +34 -34
  46. package/dist/components/search/SearchBar.js +140 -117
  47. package/dist/components/search/criteria.d.ts +61 -61
  48. package/dist/components/search/criteria.js +39 -39
  49. package/dist/components/search/datePeriods.d.ts +47 -48
  50. package/dist/components/search/datePeriods.js +29 -29
  51. package/dist/components/search/dateRanges.d.ts +27 -27
  52. package/dist/components/search/dateRanges.js +16 -16
  53. package/dist/components/search/index.js +13 -13
  54. package/dist/components/search/model.d.ts +28 -28
  55. package/dist/components/search/model.js +21 -21
  56. package/dist/components/search/query.d.ts +71 -71
  57. package/dist/components/search/query.js +119 -119
  58. package/dist/components/shell/AppFrame.d.ts +9 -2
  59. package/dist/components/shell/AppFrame.js +102 -14
  60. package/dist/components/shell/Sidebar.d.ts +34 -0
  61. package/dist/components/shell/Sidebar.js +32 -0
  62. package/dist/components/shell/TopBar.d.ts +2 -0
  63. package/dist/components/shell/TopBar.js +13 -9
  64. package/dist/components/shell/index.d.ts +2 -0
  65. package/dist/components/shell/index.js +5 -1
  66. package/dist/components/shell/sidebarDrawer.d.ts +26 -0
  67. package/dist/components/shell/sidebarDrawer.js +22 -0
  68. package/dist/foundations/calendar.d.ts +27 -27
  69. package/dist/foundations/calendar.js +72 -72
  70. package/dist/foundations/chart.d.ts +57 -57
  71. package/dist/foundations/chart.js +27 -27
  72. package/dist/foundations/copy.d.ts +109 -94
  73. package/dist/foundations/copy.es.js +10 -2
  74. package/dist/foundations/copy.js +10 -2
  75. package/dist/foundations/grouping.d.ts +175 -175
  76. package/dist/foundations/grouping.js +0 -0
  77. package/dist/foundations/index.d.ts +1 -1
  78. package/dist/foundations/index.js +21 -21
  79. package/dist/foundations/pivot.d.ts +133 -131
  80. package/dist/foundations/pivot.js +54 -54
  81. package/dist/foundations/pivotSheet.d.ts +36 -36
  82. package/dist/foundations/pivotSheet.js +0 -0
  83. package/dist/foundations/slots.d.ts +38 -38
  84. package/dist/foundations/slots.js +18 -18
  85. package/dist/foundations/sticky.d.ts +28 -28
  86. package/dist/foundations/sticky.js +59 -59
  87. package/dist/foundations/xlsx.d.ts +47 -47
  88. package/dist/foundations/xlsx.js +0 -0
  89. package/dist/primitives/block/Line.d.ts +4 -4
  90. package/dist/primitives/block/Line.js +28 -28
  91. package/dist/primitives/block/index.js +2 -2
  92. package/dist/primitives/cell/index.js +2 -2
  93. package/dist/primitives/choice/index.js +3 -3
  94. package/dist/primitives/date/Calendar.d.ts +7 -1
  95. package/dist/primitives/date/Calendar.js +13 -3
  96. package/dist/primitives/date/DatePicker.d.ts +4 -1
  97. package/dist/primitives/date/DatePicker.js +2 -2
  98. package/dist/primitives/date/index.js +3 -3
  99. package/dist/primitives/disclosure/index.js +1 -1
  100. package/dist/primitives/field/DropZone.d.ts +22 -3
  101. package/dist/primitives/field/DropZone.js +33 -12
  102. package/dist/primitives/menu/Menu.d.ts +10 -6
  103. package/dist/primitives/menu/Menu.js +4 -3
  104. package/dist/primitives/notice/Callout.d.ts +30 -30
  105. package/dist/primitives/notice/Callout.js +6 -6
  106. package/dist/primitives/overlay/index.js +3 -3
  107. package/dist/primitives/picker/Picker.d.ts +6 -0
  108. package/dist/primitives/picker/Picker.js +27 -4
  109. package/dist/primitives/picker/index.js +2 -2
  110. package/dist/primitives/table/DataTable.d.ts +32 -32
  111. package/dist/primitives/table/DataTable.js +24 -24
  112. package/dist/primitives/table/EditableTable.d.ts +10 -10
  113. package/dist/primitives/table/EditableTable.js +9 -9
  114. package/dist/primitives/table/ReportTable.js +7 -7
  115. package/dist/primitives/table/SheetTable.d.ts +13 -13
  116. package/dist/primitives/table/SheetTable.js +14 -14
  117. package/dist/primitives/table/Table.js +8 -8
  118. package/dist/primitives/tabs/Tabs.d.ts +46 -46
  119. package/dist/primitives/tabs/Tabs.js +4 -30
  120. package/dist/primitives/tag/Count.d.ts +23 -0
  121. package/dist/primitives/tag/Count.js +59 -0
  122. package/dist/primitives/tag/index.d.ts +1 -0
  123. package/dist/primitives/tag/index.js +5 -2
  124. package/dist/primitives/toolbar/index.js +1 -1
  125. package/dist/primitives/value/Copyable.d.ts +22 -22
  126. package/dist/primitives/value/Copyable.js +9 -9
  127. package/dist/primitives/value/Metric.d.ts +7 -2
  128. package/dist/primitives/value/Metric.js +12 -4
  129. package/dist/tokens.css +164 -57
  130. package/dist/views/list/List.d.ts +36 -36
  131. package/dist/views/list/List.js +19 -19
  132. package/dist/views/list/ListView.js +74 -74
  133. package/dist/views/list/columns.d.ts +10 -10
  134. package/dist/views/list/columns.js +10 -10
  135. package/dist/views/list/derive.d.ts +30 -30
  136. package/dist/views/list/derive.js +49 -49
  137. package/dist/views/list/index.js +2 -2
  138. package/dist/views/list/presentations.js +3 -3
  139. package/dist/views/list/types.d.ts +109 -109
  140. package/dist/views/record/Record.d.ts +14 -14
  141. package/dist/views/record/Record.js +24 -24
  142. package/dist/views/record/index.js +1 -1
  143. package/package.json +1 -1
@@ -0,0 +1,34 @@
1
+ import type { LucideIcon } from "lucide-react";
2
+ import type { ReactNode } from "react";
3
+ export type SidebarAction = {
4
+ id: string;
5
+ label: string;
6
+ icon?: LucideIcon;
7
+ /** A link instead of an action — «Ver el sitio». It is followed, not reported. */
8
+ href?: string;
9
+ /** The link opens in another tab; a screen reader is told so. */
10
+ external?: boolean;
11
+ };
12
+ export type SidebarProps = {
13
+ /** The product, at the top: its name and its mark — an icon, or the logo's image. */
14
+ brand?: {
15
+ label: string;
16
+ icon?: LucideIcon;
17
+ logo?: string;
18
+ };
19
+ /** Who is signed in. */
20
+ user?: {
21
+ name: string;
22
+ detail?: string;
23
+ avatar?: string;
24
+ };
25
+ /** The navigation: a `NavigationTree`. It scrolls; the top and the bottom stay. */
26
+ children: ReactNode;
27
+ /** The account, pinned to the bottom: change the password, view the site, sign out. */
28
+ actions?: readonly SidebarAction[];
29
+ /** An action without `href` was chosen. */
30
+ onAction?: (id: string) => void;
31
+ /** Anything else at the very bottom: a `ThemeSwitcher`, the version. */
32
+ footer?: ReactNode;
33
+ };
34
+ export declare function Sidebar({ brand, user, children, actions, onAction, footer }: SidebarProps): import("react").JSX.Element;
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useSidebarDrawer } from "./sidebarDrawer.js";
4
+ import { useUiCopy } from "../../foundations/copy.js";
5
+ import { Avatar } from "../../primitives/value/Person.js";
6
+ const ROW = "flex h-(--size-control-sm) w-full min-w-0 cursor-pointer items-center gap-2 rounded-control px-2 text-meta text-ink no-underline transition-colors duration-(--duration-instant) hover:bg-ink/6 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary";
7
+ function Brand({ brand }) {
8
+ const Icon = brand.icon;
9
+ return (_jsxs("div", { className: "flex min-w-0 items-center gap-2 px-4 pt-4 pb-2", children: [brand.logo === undefined ? (Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-lg) shrink-0 text-primary", strokeWidth: 1.75, "aria-hidden": true }))) : (_jsx("img", { src: brand.logo, alt: "", className: "size-(--size-control-md) shrink-0 object-contain" })), _jsx("span", { className: "min-w-0 truncate text-lead font-semibold text-ink", children: brand.label })] }));
10
+ }
11
+ function User({ user }) {
12
+ return (_jsxs("div", { className: "flex min-w-0 items-center gap-2 px-4 py-2", children: [_jsx(Avatar, { name: user.name, size: "md", ...(user.avatar === undefined ? {} : { src: user.avatar }) }), _jsxs("span", { className: "flex min-w-0 flex-col leading-tight", children: [_jsx("span", { className: "truncate text-meta text-ink", children: user.name }), user.detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-muted", children: user.detail }))] })] }));
13
+ }
14
+ function Action({ action, onAction, }) {
15
+ const copy = useUiCopy();
16
+ const drawer = useSidebarDrawer();
17
+ const Icon = action.icon;
18
+ const content = (_jsxs(_Fragment, { children: [Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "min-w-0 truncate", children: action.label })] }));
19
+ if (action.href !== undefined) {
20
+ return (_jsxs("a", { href: action.href, className: ROW, ...(action.external === true ? { target: "_blank", rel: "noreferrer" } : {}), children: [content, action.external === true ? (_jsx("span", { className: "sr-only", children: ` (${copy.field.newTab})` })) : null] }));
21
+ }
22
+ return (_jsx("button", { type: "button", className: ROW, onClick: () => {
23
+ onAction?.(action.id);
24
+ drawer?.close();
25
+ }, children: content }));
26
+ }
27
+ export function Sidebar({ brand, user, children, actions, onAction, footer }) {
28
+ const copy = useUiCopy();
29
+ const head = brand !== undefined || user !== undefined;
30
+ const foot = (actions !== undefined && actions.length > 0) || footer !== undefined;
31
+ return (_jsxs("div", { className: "flex h-full min-h-0 min-w-0 flex-col", children: [head ? (_jsxs("div", { className: "shrink-0 border-b border-line pb-2", children: [brand === undefined ? null : _jsx(Brand, { brand: brand }), user === undefined ? null : _jsx(User, { user: user })] })) : null, _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: children }), foot ? (_jsxs("div", { className: "flex shrink-0 flex-col gap-2 border-t border-line p-2", children: [actions === undefined || actions.length === 0 ? null : (_jsx("ul", { "aria-label": copy.shell.account, className: "flex flex-col gap-px", children: actions.map((action) => (_jsx("li", { children: _jsx(Action, { action: action, ...(onAction === undefined ? {} : { onAction }) }) }, action.id))) })), footer] })) : null] }));
32
+ }
@@ -12,6 +12,8 @@ export interface TopMenu {
12
12
  id: string;
13
13
  label: string;
14
14
  groups: readonly MenuGroup[];
15
+ /** What is waiting inside — «Pagos 5» — seen without opening the menu. Zero is not drawn. */
16
+ count?: number;
15
17
  }
16
18
  export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, onMenuSelect, systray, user, onUserSelect, userGroups, }: {
17
19
  /** The product's name, when there is ONE product. It is drawn like the
@@ -1,16 +1,18 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { SidebarToggle } from "./sidebarDrawer.js";
3
4
  import { useUiCopy } from "../../foundations/copy.js";
4
5
  import { SurfaceProvider } from "../../foundations/surface.js";
5
6
  import { Menu } from "../../primitives/menu/Menu.js";
7
+ import { Count, countText } from "../../primitives/tag/Count.js";
6
8
  import { Avatar } from "../../primitives/value/Person.js";
7
9
  import { Grid3x3 } from "lucide-react";
8
- import { useState } from "react";
10
+ import { useMemo, useState } from "react";
9
11
  export function TopBar({ app, apps, currentApp, onAppSelect, menus, onMenuSelect, systray, user, onUserSelect, userGroups, }) {
10
12
  const copy = useUiCopy();
11
13
  const actual = apps?.find((a) => a.id === currentApp);
12
14
  const brand = app ?? actual;
13
- return (_jsx(SurfaceProvider, { value: "chrome", children: _jsxs("header", { className: "flex h-(--size-appbar) min-w-0 items-center gap-1 border-b border-chrome-edge bg-chrome px-2", children: [apps === undefined || apps.length === 0 ? null : (_jsx(AppSwitcher, { apps: apps, current: currentApp, ...(onAppSelect === undefined ? {} : { onSelect: onAppSelect }) })), brand === undefined ? null : (_jsxs("span", { className: "flex shrink-0 items-center gap-2 pr-2 pl-1", children: [brand.icon === undefined ? null : (_jsx(brand.icon, { className: "size-(--size-icon-md) text-chrome-link", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "text-lead font-medium text-chrome-ink", children: brand.label })] })), menus === undefined ? null : (_jsx("nav", { className: "scroll-quiet flex min-w-0 items-center gap-0.5", "aria-label": copy.shell.menus, children: menus.map((m) => (_jsx(Menu, { label: m.label, groups: m.groups, surface: "chrome", variant: "text", chevron: false, onSelect: (id) => onMenuSelect?.(m.id, id) }, m.id))) })), _jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-1 pl-2", children: [systray, user === undefined ? null : (_jsx(UserMenu, { name: user.name, ...(user.detail === undefined ? {} : { detail: user.detail }), groups: userGroups ?? [], ...(onUserSelect === undefined ? {} : { onSelect: onUserSelect }) }))] })] }) }));
15
+ return (_jsx(SurfaceProvider, { value: "chrome", children: _jsxs("header", { className: "flex h-(--size-appbar) min-w-0 items-center gap-1 border-b border-chrome-edge bg-chrome px-2", children: [_jsx(SidebarToggle, {}), apps === undefined || apps.length === 0 ? null : (_jsx(AppSwitcher, { apps: apps, current: currentApp, ...(onAppSelect === undefined ? {} : { onSelect: onAppSelect }) })), brand === undefined ? null : (_jsxs("span", { className: "flex shrink-0 items-center gap-2 pr-2 pl-1", children: [brand.icon === undefined ? null : (_jsx(brand.icon, { className: "size-(--size-icon-md) text-chrome-link", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "text-lead font-medium text-chrome-ink", children: brand.label })] })), menus === undefined ? null : (_jsx("nav", { className: "scroll-quiet flex min-w-0 items-center gap-0.5", "aria-label": copy.shell.menus, children: menus.map((m) => (_jsx(Menu, { label: m.label, groups: m.groups, surface: "chrome", variant: "text", chevron: false, ...(m.count === undefined ? {} : { count: m.count }), onSelect: (id) => onMenuSelect?.(m.id, id) }, m.id))) })), _jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-1 pl-2", children: [systray, user === undefined ? null : (_jsx(UserMenu, { name: user.name, ...(user.detail === undefined ? {} : { detail: user.detail }), groups: userGroups ?? [], ...(onUserSelect === undefined ? {} : { onSelect: onUserSelect }) }))] })] }) }));
14
16
  }
15
17
  /** The app switcher: a grid, not a list.
16
18
  *
@@ -31,20 +33,22 @@ export function AppSwitcher({ apps, current, onSelect, }) {
31
33
  }, className: `flex flex-col items-center gap-1.5 rounded-box px-2 py-3 text-center transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${here ? "bg-primary/8 text-primary" : "text-ink hover:bg-ink/5"}`, children: [_jsx(a.icon, { className: "size-(--size-icon-lg)", strokeWidth: 1.75, "aria-hidden": true }), _jsx("span", { className: "text-micro leading-tight", children: a.label })] }, a.id));
32
34
  }) })] }))] }));
33
35
  }
36
+ /** A badge over an icon is read in a glance: past two digits it says «a lot». */
37
+ const SYSTRAY_MAX = 99;
34
38
  /** A systray icon with its count.
35
39
  *
36
40
  * Zero is NOT drawn: a bell with a «0» next to it forces you to read a number
37
41
  * to discover there is nothing. With no count you can already see there is
38
42
  * nothing. */
39
43
  export function SystrayButton({ icon: Icon, label, count = 0, tone = "info", onClick, active = false, }) {
40
- const PUNTO = {
41
- info: "bg-chrome-link text-chrome",
42
- warn: "bg-chrome-warn text-chrome",
43
- bad: "bg-chrome-bad text-chrome",
44
- };
45
- return (_jsxs("button", { type: "button", onClick: onClick, title: count > 0 ? `${label} (${count})` : label, "aria-label": count > 0 ? `${label}: ${count}` : label, className: `relative inline-flex size-(--size-control-md) items-center justify-center rounded-pill transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-chrome-link ${active
44
+ const copy = useUiCopy();
45
+ const number = useMemo(() => new Intl.NumberFormat(copy.locale), [copy.locale]);
46
+ /* The button says the number in its name, so the badge is only seen — and both say the
47
+ same «99+», not a badge that is cut and a name that is not. */
48
+ const said = countText(count, number.format, SYSTRAY_MAX);
49
+ return (_jsxs("button", { type: "button", onClick: onClick, title: count > 0 ? `${label} (${said})` : label, "aria-label": count > 0 ? `${label}: ${said}` : label, className: `relative inline-flex size-(--size-control-md) items-center justify-center rounded-pill transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-chrome-link ${active
46
50
  ? "bg-chrome-ink/12 text-chrome-ink"
47
- : "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink"}`, children: [_jsx(Icon, { className: "size-(--size-icon-md)", strokeWidth: 2, "aria-hidden": true }), count <= 0 ? null : (_jsx("span", { "aria-hidden": true, className: `absolute -top-0.5 -right-0.5 inline-flex min-w-4 items-center justify-center rounded-pill px-1 text-micro leading-none font-semibold tabular-nums ${PUNTO[tone]}`, children: count > 99 ? "99+" : count }))] }));
51
+ : "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink"}`, children: [_jsx(Icon, { className: "size-(--size-icon-md)", strokeWidth: 2, "aria-hidden": true }), count <= 0 ? null : (_jsx("span", { className: "absolute -top-0.5 -right-0.5 flex", children: _jsx(Count, { value: count, tone: tone, solid: true, max: SYSTRAY_MAX, surface: "chrome", "aria-hidden": true }) }))] }));
48
52
  }
49
53
  /** Who I am and how I leave. The name is drawn when there is width; when narrow
50
54
  * only the avatar stays, which is what gets recognised without reading. */
@@ -1,3 +1,5 @@
1
1
  export { AppFrame } from "./AppFrame.js";
2
+ export { Sidebar, type SidebarAction, type SidebarProps, } from "./Sidebar.js";
3
+ export { type SidebarDrawer, SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
2
4
  export { type AppEntry, SystrayButton, TopBar, type TopMenu, } from "./TopBar.js";
3
5
  export { Pane, Panes } from "./Panes.js";
@@ -1,5 +1,9 @@
1
- /* EL MARCO DE LA APLICACIÓN — lo que está arriba de toda vista. */
1
+ /* THE APPLICATION FRAME — what sits above every view. */
2
2
  export { AppFrame } from "./AppFrame.js";
3
+ /* The whole chrome in one column, for a back office with no bar on top. */
4
+ export { Sidebar, } from "./Sidebar.js";
5
+ /* The sidebar's phone drawer, for a bar an application writes itself. */
6
+ export { SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
3
7
  export { SystrayButton, TopBar, } from "./TopBar.js";
4
8
  /* A screen of N sets side by side — the reconciliation: each pane scrolls on its own. */
5
9
  export { Pane, Panes } from "./Panes.js";
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Context: **the sidebar on a phone.** Below `sm` (`--container-handheld`) a 15 rem column
3
+ * beside the view is two thirds of a 390 px screen, so `AppFrame` hides it and offers the
4
+ * SAME sidebar as a drawer from the start edge. What opens the drawer lives in the bar on
5
+ * top — the application's `TopBar`, or the bar the frame draws when the sidebar is the
6
+ * only chrome — and the frame is the one that knows there is a drawer. This is that
7
+ * contract: `null` outside a frame with a sidebar, so a `TopBar` without one draws no
8
+ * button that opens nothing.
9
+ */
10
+ export type SidebarDrawer = {
11
+ isOpen: boolean;
12
+ open: () => void;
13
+ close: () => void;
14
+ /** The drawer's id, for `aria-controls`. */
15
+ id: string;
16
+ };
17
+ export declare const SidebarDrawerContext: import("react").Context<SidebarDrawer | null>;
18
+ /** The phone drawer of the frame's sidebar, for a bar or a control an application writes
19
+ * itself. `null` when the frame has no sidebar. */
20
+ export declare function useSidebarDrawer(): SidebarDrawer | null;
21
+ /** The button that opens the sidebar on a phone. It draws nothing on a wider screen — the
22
+ * sidebar is in view there — nor outside a frame with a sidebar. `TopBar` draws it first
23
+ * on its own; write it only in a bar of your own. */
24
+ export declare function SidebarToggle({ surface }: {
25
+ surface?: "canvas" | "chrome";
26
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useUiCopy } from "../../foundations/copy.js";
4
+ import { IconButton } from "../../primitives/button/Button.js";
5
+ import { Menu as Hamburger } from "lucide-react";
6
+ import { createContext, useContext } from "react";
7
+ export const SidebarDrawerContext = createContext(null);
8
+ /** The phone drawer of the frame's sidebar, for a bar or a control an application writes
9
+ * itself. `null` when the frame has no sidebar. */
10
+ export function useSidebarDrawer() {
11
+ return useContext(SidebarDrawerContext);
12
+ }
13
+ /** The button that opens the sidebar on a phone. It draws nothing on a wider screen — the
14
+ * sidebar is in view there — nor outside a frame with a sidebar. `TopBar` draws it first
15
+ * on its own; write it only in a bar of your own. */
16
+ export function SidebarToggle({ surface = "chrome" }) {
17
+ const copy = useUiCopy();
18
+ const drawer = useSidebarDrawer();
19
+ if (drawer === null)
20
+ return null;
21
+ return (_jsx("span", { className: "flex shrink-0 sm:hidden", children: _jsx(IconButton, { icon: Hamburger, label: copy.shell.openNavigation, size: "md", surface: surface, expanded: drawer.isOpen, haspopup: "dialog", ...(drawer.isOpen ? { "aria-controls": drawer.id } : {}), onClick: drawer.open }) }));
22
+ }
@@ -1,45 +1,45 @@
1
- /** El grano de un nivel de fecha. Sin grano, un campo de fecha parte por
2
- * instante y cada fila termina en su propio montón, que es no agrupar. */
1
+ /** The grain of a date level. Without a grain, a date field splits by
2
+ * instant and every row ends up in its own bucket, which is not grouping. */
3
3
  export type GroupGrain = "day" | "week" | "month" | "quarter" | "year";
4
4
  /**
5
- * Una fecha recortada a la CLAVE de su grano.
5
+ * A date cut down to the KEY of its grain.
6
6
  *
7
- * El texto es el que produce el motor —«2026», «2026-Q3», «2026-09», «2026-W38»,
8
- * «2026-09-15»—, y que los dos lados lo escriban igual es lo que deja comparar
9
- * un agrupado hecho en el navegador con uno contado a mil kilómetros. Sin fecha
10
- * la clave es vacía: un montón que existe —el de los que no tienen— y que se
11
- * dibuja con las palabras de la copia.
7
+ * The text is the one the engine produces —«2026», «2026-Q3», «2026-09», «2026-W38»,
8
+ * «2026-09-15»—, and both sides writing it the same is what lets a grouping
9
+ * made in the browser be compared with one counted a thousand kilometres away. Without a date
10
+ * the key is empty: a bucket that exists —the one for those that have none— and that is
11
+ * drawn with the words of the copy.
12
12
  */
13
13
  export declare function dateKey(when: Date | string | number | null | undefined, grain: GroupGrain): string;
14
14
  /**
15
- * El RÓTULO de una clave de fecha, en el idioma activo.
15
+ * The LABEL of a date key, in the active language.
16
16
  *
17
- * `within` son los granos que los montones de arriba ya dijeron: con el año
18
- * arriba, un mes es «Septiembre» y no «Septiembre de 2026». Una clave que no
19
- * tiene la forma de su grano se dibuja TAL CUAL —es lo que hace que un montón
20
- * contado afuera, con una clave que esta capa no escribió, siga siendo legible
21
- * en vez de desaparecer detrás de una fecha inventada.
17
+ * `within` are the grains the buckets above already said: with the year
18
+ * above, a month is «Septiembre» and not «Septiembre de 2026». A key that does not
19
+ * have the shape of its grain is drawn AS IS —that is what keeps a bucket
20
+ * counted elsewhere, with a key this layer did not write, readable
21
+ * instead of vanishing behind an invented date.
22
22
  */
23
23
  export declare function dateLabel(key: string, grain: GroupGrain, within?: readonly GroupGrain[]): string;
24
24
  /**
25
- * La clave SIGUIENTE en el mismo grano: «2026-09» → «2026-10», «2026-Q4» → «2027-Q1»,
26
- * «2026-W52» → la semana ISO que sigue. `null` si la clave no tiene la forma de su grano —
27
- * una contada afuera, que esta capa no escribió y entonces no puede continuar.
25
+ * The NEXT key in the same grain: «2026-09» → «2026-10», «2026-Q4» → «2027-Q1»,
26
+ * «2026-W52» → the ISO week that follows. `null` if the key does not have the shape of its grain —
27
+ * one counted elsewhere, which this layer did not write and so cannot continue.
28
28
  */
29
29
  export declare function nextDateKey(key: string, grain: GroupGrain): string | null;
30
30
  /**
31
- * Todas las claves de un grano entre dos, las dos incluidas: el EJE de tiempo entero.
31
+ * All the keys of a grain between two, both included: the whole time AXIS.
32
32
  *
33
- * Un eje que salta el mes en que no pasó nada miente sobre el tiempo —agosto pegado a
34
- * octubre se lee como un mes— y ese hueco suele ser justo lo que alguien busca. `null` si
35
- * alguna clave no se puede continuar o si serían más de `max`: un eje por día de diez años
36
- * no es un gráfico.
33
+ * An axis that skips the month where nothing happened lies about time —August stuck to
34
+ * October reads as one month— and that gap is often exactly what someone is looking for. `null` if
35
+ * some key cannot be continued or if there would be more than `max`: an axis by day over ten years
36
+ * is not a chart.
37
37
  */
38
38
  export declare function dateKeysBetween(first: string, last: string, grain: GroupGrain, max?: number): string[] | null;
39
- /** El nombre de un mes —1 a 12— en el idioma activo. Lo usa el que ofrece meses
40
- * sin tener ninguna fecha en la mano, como el recorte por período. */
39
+ /** The name of a month —1 to 12— in the active language. Used by whoever offers months
40
+ * without holding any date, like the cut by period. */
41
41
  export declare function monthName(month: number): string;
42
- /** Cómo se llama un GRANO —«día», «semana»—, que es distinto de cómo se llama un
43
- * montón suyo: el grano nombra el corte y el rótulo nombra lo cortado. Sale de
44
- * la copia, que es donde ya viven las unidades de tiempo en singular. */
42
+ /** What a GRAIN is called —«día», «semana»—, which is different from what a bucket
43
+ * of it is called: the grain names the cut and the label names what was cut. It comes from
44
+ * the copy, which is where the time units in the singular already live. */
45
45
  export declare function grainName(grain: GroupGrain): string;
@@ -1,49 +1,49 @@
1
1
  import { currentCopy, currentCopyLocale, fillCopy } from "./copy.js";
2
2
  /**
3
- * EL CALENDARIO: de una fecha a una CLAVE, y de una clave a un RÓTULO.
3
+ * THE CALENDAR: from a date to a KEY, and from a key to a LABEL.
4
4
  *
5
- * Context: un montón de fecha tiene dos textos y no son el mismo. «2026-09» es
6
- * lo que el motor escribe —lo que identifica al montón, lo que se compara con lo
7
- * que contó el servidor, lo que se guarda plegado— y «Septiembre» es lo que se
8
- * lee. Escribir uno solo obliga a elegir cuál se pierde: con la clave a la vista
9
- * la interfaz habla en máquina, y con el rótulo por identidad dos septiembres de
10
- * años distintos se funden en un montón que no existe.
5
+ * Context: a date bucket has two texts and they are not the same. «2026-09» is
6
+ * what the engine writes —what identifies the bucket, what is compared with what
7
+ * the server counted, what is stored folded— and «Septiembre» is what is
8
+ * read. Writing only one forces a choice of which one is lost: with the key in view
9
+ * the interface speaks machine, and with the label as identity two Septembers of
10
+ * different years melt into a bucket that does not exist.
11
11
  *
12
- * Por eso son dos funciones y no una:
12
+ * That is why there are two functions and not one:
13
13
  *
14
- * dateKey(when, "month") → «2026-09» la identidad, en un solo idioma
15
- * dateLabel("2026-09", …) → «Septiembre» el rótulo, en el idioma activo
14
+ * dateKey(when, "month") → «2026-09» the identity, in a single language
15
+ * dateLabel("2026-09", …) → «Septiembre» the label, in the active language
16
16
  *
17
- * ── El idioma no se traduce: se PIDE ────────────────────────────────
17
+ * ── The language is not translated: it is ASKED for ─────────────────
18
18
  *
19
- * Los meses y los días de la semana los dice `Intl` con el `locale` que la copia
20
- * tiene puesto, así que no hay acá ninguna tabla de doce meses en español ni en
21
- * inglés — ni la habría que escribir para un tercer idioma. Lo único que sí es
22
- * copia son la semana y el trimestre, porque ningún calendario los nombra: «W38»
23
- * no es una palabra y `Intl` no la tiene.
19
+ * The months and the days of the week are said by `Intl` with the `locale` the copy
20
+ * has set, so there is no table of twelve months here, in Spanish or in
21
+ * English — nor would one have to be written for a third language. The only things that
22
+ * are copy are the week and the quarter, because no calendar names them: «W38»
23
+ * is not a word and `Intl` does not have it.
24
24
  *
25
- * ── Un rótulo dice lo que el de arriba NO dijo ──────────────────────
25
+ * ── A label says what the one above did NOT say ─────────────────────
26
26
  *
27
- * Un árbol de fechas se lee de arriba hacia abajo, y repetir el año en cada mes
28
- * y el mes en cada día llena la sangría de texto que ya está dos renglones más
29
- * arriba:
27
+ * A tree of dates is read from top to bottom, and repeating the year in every month
28
+ * and the month in every day fills the indentation with text that is already two lines
29
+ * above:
30
30
  *
31
- * 2026 ← el año lo dice una vez
32
- * Septiembre ← no «Septiembre de 2026»
33
- * Semana 38 ← no «Semana 38 de 2026»
34
- * Martes ← no «martes, 15 sept 2026»
31
+ * 2026 ← the year is said once
32
+ * Septiembre ← not «Septiembre de 2026»
33
+ * Semana 38 ← not «Semana 38 de 2026»
34
+ * Martes ← not «martes, 15 sept 2026»
35
35
  *
36
- * De eso se ocupa `within`: los granos que los montones de arriba —del mismo
37
- * campo— ya dijeron. Sin nadie arriba, el rótulo se planta solo y dice la fecha
38
- * entera, porque un «Martes» suelto no es ningún día.
36
+ * `within` takes care of that: the grains that the buckets above —of the same
37
+ * field— already said. With nobody above, the label stands alone and says the whole
38
+ * date, because a bare «Martes» is not a day.
39
39
  */
40
40
  /**
41
- * La forma de la clave de cada grano. Es `GroupGrain` entero: un grano que el
42
- * calendario no supiera cortar sería un nivel que no parte nada.
41
+ * The shape of each grain's key. It is the whole `GroupGrain`: a grain the
42
+ * calendar could not cut would be a level that splits nothing.
43
43
  *
44
- * Los rangos van en la expresión y no en un `if` porque `new Date(2026, 12, 1)`
45
- * no falla: se corre a enero de 2027. Una clave «2026-13» dibujada como «Enero»
46
- * es un mes que nadie contó, y eso es peor que un rótulo ilegible.
44
+ * The ranges go in the expression and not in an `if` because `new Date(2026, 12, 1)`
45
+ * does not fail: it rolls over to January 2027. A key «2026-13» drawn as «Enero»
46
+ * is a month nobody counted, and that is worse than an unreadable label.
47
47
  */
48
48
  const KEY_SHAPES = {
49
49
  year: /^(\d{4})$/,
@@ -53,13 +53,13 @@ const KEY_SHAPES = {
53
53
  day: /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,
54
54
  };
55
55
  /**
56
- * Una fecha recortada a la CLAVE de su grano.
56
+ * A date cut down to the KEY of its grain.
57
57
  *
58
- * El texto es el que produce el motor —«2026», «2026-Q3», «2026-09», «2026-W38»,
59
- * «2026-09-15»—, y que los dos lados lo escriban igual es lo que deja comparar
60
- * un agrupado hecho en el navegador con uno contado a mil kilómetros. Sin fecha
61
- * la clave es vacía: un montón que existe —el de los que no tienen— y que se
62
- * dibuja con las palabras de la copia.
58
+ * The text is the one the engine produces —«2026», «2026-Q3», «2026-09», «2026-W38»,
59
+ * «2026-09-15»—, and both sides writing it the same is what lets a grouping
60
+ * made in the browser be compared with one counted a thousand kilometres away. Without a date
61
+ * the key is empty: a bucket that exists —the one for those that have none— and that is
62
+ * drawn with the words of the copy.
63
63
  */
64
64
  export function dateKey(when, grain) {
65
65
  if (when === null || when === undefined || when === "")
@@ -90,13 +90,13 @@ export function dateKey(when, grain) {
90
90
  return `${year}-${pad(month)}-${pad(date.getDate())}`;
91
91
  }
92
92
  /**
93
- * El RÓTULO de una clave de fecha, en el idioma activo.
93
+ * The LABEL of a date key, in the active language.
94
94
  *
95
- * `within` son los granos que los montones de arriba ya dijeron: con el año
96
- * arriba, un mes es «Septiembre» y no «Septiembre de 2026». Una clave que no
97
- * tiene la forma de su grano se dibuja TAL CUAL —es lo que hace que un montón
98
- * contado afuera, con una clave que esta capa no escribió, siga siendo legible
99
- * en vez de desaparecer detrás de una fecha inventada.
95
+ * `within` are the grains the buckets above already said: with the year
96
+ * above, a month is «Septiembre» and not «Septiembre de 2026». A key that does not
97
+ * have the shape of its grain is drawn AS IS —that is what keeps a bucket
98
+ * counted elsewhere, with a key this layer did not write, readable
99
+ * instead of vanishing behind an invented date.
100
100
  */
101
101
  export function dateLabel(key, grain, within = []) {
102
102
  const copy = currentCopy();
@@ -118,8 +118,8 @@ export function dateLabel(key, grain, within = []) {
118
118
  }
119
119
  if (grain === "week") {
120
120
  const week = Number(parts[2]);
121
- /* El mes también alcanza: una semana adentro de septiembre ya sabe de qué
122
- año es, porque el mes lo dijo. */
121
+ /* The month is enough too: a week inside September already knows which
122
+ year it is, because the month said so. */
123
123
  return said("year") || said("quarter") || said("month")
124
124
  ? fillCopy(copy.calendar.week, { n: week })
125
125
  : fillCopy(copy.calendar.weekOfYear, { n: week, year });
@@ -132,13 +132,13 @@ export function dateLabel(key, grain, within = []) {
132
132
  }
133
133
  const day = Number(parts[3]);
134
134
  const when = new Date(year, Number(parts[2]) - 1, day);
135
- /* El 31 de febrero tiene la forma de un día y no es ninguno: `Date` lo corre
136
- al 3 de marzo en vez de quejarse, así que se pregunta si volvió el mismo. */
135
+ /* 31 February has the shape of a day and is none: `Date` rolls it over
136
+ to 3 March instead of complaining, so we ask whether the same day came back. */
137
137
  if (when.getDate() !== day)
138
138
  return key;
139
- /* Adentro de una semana, el día es su NOMBRE: son siete y ninguno se repite,
140
- así que «Martes» alcanza y el número de día sería ruido. Afuera no: un
141
- «Martes» suelto no dice cuál de los cincuenta y dos. */
139
+ /* Inside a week, the day is its NAME: there are seven and none repeats,
140
+ so «Martes» is enough and the day number would be noise. Outside it is not: a bare
141
+ «Martes» does not say which of the fifty-two. */
142
142
  if (said("week"))
143
143
  return capitalized(format(locale, { weekday: "long" }).format(when));
144
144
  return capitalized(format(locale, {
@@ -149,9 +149,9 @@ export function dateLabel(key, grain, within = []) {
149
149
  }).format(when));
150
150
  }
151
151
  /**
152
- * La clave SIGUIENTE en el mismo grano: «2026-09» → «2026-10», «2026-Q4» → «2027-Q1»,
153
- * «2026-W52» → la semana ISO que sigue. `null` si la clave no tiene la forma de su grano —
154
- * una contada afuera, que esta capa no escribió y entonces no puede continuar.
152
+ * The NEXT key in the same grain: «2026-09» → «2026-10», «2026-Q4» → «2027-Q1»,
153
+ * «2026-W52» → the ISO week that follows. `null` if the key does not have the shape of its grain —
154
+ * one counted elsewhere, which this layer did not write and so cannot continue.
155
155
  */
156
156
  export function nextDateKey(key, grain) {
157
157
  const parts = KEY_SHAPES[grain].exec(key);
@@ -179,12 +179,12 @@ export function nextDateKey(key, grain) {
179
179
  return dateKey(date, "day");
180
180
  }
181
181
  /**
182
- * Todas las claves de un grano entre dos, las dos incluidas: el EJE de tiempo entero.
182
+ * All the keys of a grain between two, both included: the whole time AXIS.
183
183
  *
184
- * Un eje que salta el mes en que no pasó nada miente sobre el tiempo —agosto pegado a
185
- * octubre se lee como un mes— y ese hueco suele ser justo lo que alguien busca. `null` si
186
- * alguna clave no se puede continuar o si serían más de `max`: un eje por día de diez años
187
- * no es un gráfico.
184
+ * An axis that skips the month where nothing happened lies about time —August stuck to
185
+ * October reads as one month— and that gap is often exactly what someone is looking for. `null` if
186
+ * some key cannot be continued or if there would be more than `max`: an axis by day over ten years
187
+ * is not a chart.
188
188
  */
189
189
  export function dateKeysBetween(first, last, grain, max = 1000) {
190
190
  const out = [first];
@@ -198,24 +198,24 @@ export function dateKeysBetween(first, last, grain, max = 1000) {
198
198
  }
199
199
  return key === last ? out : null;
200
200
  }
201
- /** El nombre de un mes —1 a 12— en el idioma activo. Lo usa el que ofrece meses
202
- * sin tener ninguna fecha en la mano, como el recorte por período. */
201
+ /** The name of a month —1 to 12— in the active language. Used by whoever offers months
202
+ * without holding any date, like the cut by period. */
203
203
  export function monthName(month) {
204
204
  return capitalized(format(currentCopyLocale(), { month: "long" }).format(new Date(2000, month - 1, 1)));
205
205
  }
206
- /** Cómo se llama un GRANO —«día», «semana»—, que es distinto de cómo se llama un
207
- * montón suyo: el grano nombra el corte y el rótulo nombra lo cortado. Sale de
208
- * la copia, que es donde ya viven las unidades de tiempo en singular. */
206
+ /** What a GRAIN is called —«día», «semana»—, which is different from what a bucket
207
+ * of it is called: the grain names the cut and the label names what was cut. It comes from
208
+ * the copy, which is where the time units in the singular already live. */
209
209
  export function grainName(grain) {
210
210
  return capitalized(currentCopy().dates[grain]);
211
211
  }
212
212
  /**
213
- * El año y la semana ISO de una fecha.
213
+ * The ISO year and week of a date.
214
214
  *
215
- * La semana 1 es la que tiene el primer jueves del año, así que se calcula con
216
- * el jueves de la semana del dato: es él quien decide a qué año pertenece, y por
217
- * eso una semana de fin de diciembre puede ser la 1 del año siguiente. El año
218
- * que sale de acá es el de ESA semana y no el de la fecha.
215
+ * Week 1 is the one holding the first Thursday of the year, so it is computed with
216
+ * the Thursday of the datum's week: it decides which year it belongs to, and that is
217
+ * why a week at the end of December can be week 1 of the next year. The year
218
+ * that comes out of here is that of THAT week and not that of the date.
219
219
  */
220
220
  function isoWeek(date) {
221
221
  const thursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
@@ -229,9 +229,9 @@ function isoWeek(date) {
229
229
  function format(locale, options) {
230
230
  return new Intl.DateTimeFormat(locale, options);
231
231
  }
232
- /** Un rótulo encabeza un montón, y en español `Intl` devuelve «septiembre» con
233
- * minúscula. Se sube la primera letra con el idioma activo, que es el que sabe
234
- * cuál es la mayúscula de esa letra. */
232
+ /** A label heads a bucket, and in Spanish `Intl` returns «septiembre» in
233
+ * lowercase. The first letter is raised with the active language, which is the one that knows
234
+ * what the capital of that letter is. */
235
235
  function capitalized(text) {
236
236
  const first = text.charAt(0);
237
237
  return first === "" ? text : first.toLocaleUpperCase(currentCopyLocale()) + text.slice(1);