@sincpro/web-ui 2.11.0 → 2.13.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 (207) hide show
  1. package/README.md +77 -20
  2. package/dist/components/activity/Messages.d.ts +3 -23
  3. package/dist/components/activity/Messages.js +3 -17
  4. package/dist/components/activity/index.d.ts +2 -1
  5. package/dist/components/activity/index.js +2 -1
  6. package/dist/components/activity/messageKind.d.ts +23 -0
  7. package/dist/components/activity/messageKind.js +17 -0
  8. package/dist/components/assist/assist.d.ts +1 -1
  9. package/dist/components/assist/assist.js +1 -1
  10. package/dist/components/frame/model.js +1 -1
  11. package/dist/components/guide/index.d.ts +2 -1
  12. package/dist/components/guide/index.js +2 -1
  13. package/dist/components/guide/selector.d.ts +25 -0
  14. package/dist/components/guide/selector.js +14 -0
  15. package/dist/components/guide/target.d.ts +3 -25
  16. package/dist/components/guide/target.js +2 -14
  17. package/dist/components/index.d.ts +1 -0
  18. package/dist/components/index.js +1 -0
  19. package/dist/components/listing/AxisLevels.d.ts +2 -5
  20. package/dist/components/listing/AxisLevels.js +5 -22
  21. package/dist/components/listing/BoardColumns.js +10 -6
  22. package/dist/components/listing/ColumnsMenu.d.ts +3 -7
  23. package/dist/components/listing/ColumnsMenu.js +4 -8
  24. package/dist/components/listing/Listing.js +3 -1
  25. package/dist/components/listing/ListingBar.d.ts +16 -94
  26. package/dist/components/listing/ListingBar.js +24 -2
  27. package/dist/components/listing/RecordCard.d.ts +41 -3
  28. package/dist/components/listing/RecordCard.js +63 -22
  29. package/dist/components/listing/Row.js +5 -2
  30. package/dist/components/listing/collapsed.d.ts +2 -0
  31. package/dist/components/listing/collapsed.js +8 -0
  32. package/dist/components/listing/columnSpecs.d.ts +34 -0
  33. package/dist/components/listing/columnSpecs.js +54 -0
  34. package/dist/components/listing/columns.d.ts +3 -21
  35. package/dist/components/listing/columns.js +2 -39
  36. package/dist/components/listing/index.d.ts +11 -7
  37. package/dist/components/listing/index.js +15 -8
  38. package/dist/components/listing/levels.d.ts +9 -0
  39. package/dist/components/listing/levels.js +27 -0
  40. package/dist/components/listing/pageSizes.d.ts +9 -0
  41. package/dist/components/listing/pageSizes.js +11 -0
  42. package/dist/components/listing/pages.d.ts +2 -9
  43. package/dist/components/listing/pages.js +5 -9
  44. package/dist/components/listing/set.d.ts +1 -1
  45. package/dist/components/listing/tree.d.ts +2 -1
  46. package/dist/components/listing/tree.js +4 -5
  47. package/dist/components/preview/FilePreview.d.ts +3 -3
  48. package/dist/components/preview/FilePreview.js +3 -15
  49. package/dist/components/preview/index.d.ts +2 -1
  50. package/dist/components/preview/index.js +2 -1
  51. package/dist/components/preview/previewKind.d.ts +3 -0
  52. package/dist/components/preview/previewKind.js +17 -0
  53. package/dist/components/receipt/Receipt.d.ts +51 -0
  54. package/dist/components/receipt/Receipt.js +23 -0
  55. package/dist/components/receipt/index.d.ts +1 -0
  56. package/dist/components/receipt/index.js +3 -0
  57. package/dist/components/search/CriteriaChips.js +5 -3
  58. package/dist/components/search/FilterBuilder.d.ts +5 -139
  59. package/dist/components/search/FilterBuilder.js +5 -579
  60. package/dist/components/search/JsonEditor.d.ts +2 -8
  61. package/dist/components/search/JsonEditor.js +5 -15
  62. package/dist/components/search/RuleValue.d.ts +2 -2
  63. package/dist/components/search/RuleValue.js +5 -4
  64. package/dist/components/search/datePeriods.js +1 -1
  65. package/dist/components/search/filterTree.d.ts +183 -0
  66. package/dist/components/search/filterTree.js +570 -0
  67. package/dist/components/search/formatJson.d.ts +8 -0
  68. package/dist/components/search/formatJson.js +17 -0
  69. package/dist/components/search/index.d.ts +5 -3
  70. package/dist/components/search/index.js +7 -3
  71. package/dist/components/search/query.js +1 -1
  72. package/dist/components/shell/KioskFrame.d.ts +35 -0
  73. package/dist/components/shell/KioskFrame.js +39 -0
  74. package/dist/components/shell/SearchEntry.js +1 -1
  75. package/dist/components/shell/index.d.ts +1 -0
  76. package/dist/components/shell/index.js +1 -0
  77. package/dist/foundations/calendar.js +1 -1
  78. package/dist/foundations/catalog.d.ts +7 -8
  79. package/dist/foundations/catalog.js +10 -35
  80. package/dist/foundations/chart.js +1 -1
  81. package/dist/foundations/clock.d.ts +3 -0
  82. package/dist/foundations/clock.js +41 -0
  83. package/dist/foundations/controlName.d.ts +12 -0
  84. package/dist/foundations/controlName.js +14 -0
  85. package/dist/foundations/copy.d.ts +3 -1130
  86. package/dist/foundations/copy.es.d.ts +1 -1
  87. package/dist/foundations/copy.es.js +26 -0
  88. package/dist/foundations/copy.js +13 -747
  89. package/dist/foundations/copyStore.d.ts +21 -0
  90. package/dist/foundations/copyStore.js +47 -0
  91. package/dist/foundations/density.d.ts +4 -8
  92. package/dist/foundations/density.js +2 -9
  93. package/dist/foundations/form.d.ts +2 -12
  94. package/dist/foundations/form.js +4 -14
  95. package/dist/foundations/idle.d.ts +1 -0
  96. package/dist/foundations/idle.js +34 -0
  97. package/dist/foundations/index.d.ts +21 -11
  98. package/dist/foundations/index.js +28 -11
  99. package/dist/foundations/keys.d.ts +8 -0
  100. package/dist/foundations/keys.js +6 -0
  101. package/dist/foundations/pickBy.d.ts +16 -0
  102. package/dist/foundations/pickBy.js +17 -0
  103. package/dist/foundations/pivotSheet.js +0 -0
  104. package/dist/foundations/pointer.d.ts +25 -0
  105. package/dist/foundations/pointer.js +28 -0
  106. package/dist/foundations/shortcut.d.ts +3 -9
  107. package/dist/foundations/shortcut.js +2 -7
  108. package/dist/foundations/sticky.d.ts +2 -6
  109. package/dist/foundations/sticky.js +5 -8
  110. package/dist/foundations/stickyStyle.d.ts +12 -0
  111. package/dist/foundations/stickyStyle.js +13 -0
  112. package/dist/foundations/surface.d.ts +2 -2
  113. package/dist/foundations/surface.js +4 -2
  114. package/dist/foundations/theme.d.ts +3 -13
  115. package/dist/foundations/theme.js +2 -15
  116. package/dist/foundations/themeChoice.d.ts +19 -0
  117. package/dist/foundations/themeChoice.js +22 -0
  118. package/dist/foundations/types.d.ts +3 -0
  119. package/dist/foundations/uiCopy.d.ts +1173 -0
  120. package/dist/foundations/uiCopy.js +775 -0
  121. package/dist/foundations/xlsx.d.ts +4 -10
  122. package/dist/foundations/xlsx.js +0 -0
  123. package/dist/foundations/xlsxDownload.d.ts +8 -0
  124. package/dist/foundations/xlsxDownload.js +28 -0
  125. package/dist/primitives/button/Button.d.ts +3 -15
  126. package/dist/primitives/button/Button.js +2 -65
  127. package/dist/primitives/button/classes.d.ts +21 -0
  128. package/dist/primitives/button/classes.js +65 -0
  129. package/dist/primitives/button/index.d.ts +2 -1
  130. package/dist/primitives/button/index.js +3 -1
  131. package/dist/primitives/choice/RadioGroup.d.ts +8 -1
  132. package/dist/primitives/choice/RadioGroup.js +9 -1
  133. package/dist/primitives/choice/options.d.ts +3 -0
  134. package/dist/primitives/field/Field.d.ts +2 -6
  135. package/dist/primitives/field/Field.js +4 -10
  136. package/dist/primitives/field/Keypad.d.ts +43 -0
  137. package/dist/primitives/field/Keypad.js +62 -0
  138. package/dist/primitives/field/Stepper.d.ts +28 -0
  139. package/dist/primitives/field/Stepper.js +52 -0
  140. package/dist/primitives/field/classes.d.ts +6 -0
  141. package/dist/primitives/field/classes.js +13 -0
  142. package/dist/primitives/field/clipboard.js +1 -1
  143. package/dist/primitives/field/index.d.ts +5 -1
  144. package/dist/primitives/field/index.js +9 -1
  145. package/dist/primitives/field/keypadKeys.d.ts +24 -0
  146. package/dist/primitives/field/keypadKeys.js +80 -0
  147. package/dist/primitives/hint/Hint.js +1 -1
  148. package/dist/primitives/menu/Menu.d.ts +2 -19
  149. package/dist/primitives/menu/Menu.js +4 -30
  150. package/dist/primitives/menu/classes.d.ts +18 -0
  151. package/dist/primitives/menu/classes.js +33 -0
  152. package/dist/primitives/menu/index.d.ts +2 -1
  153. package/dist/primitives/menu/index.js +3 -1
  154. package/dist/primitives/notice/Flag.js +1 -1
  155. package/dist/primitives/notice/Outcome.d.ts +28 -0
  156. package/dist/primitives/notice/Outcome.js +28 -0
  157. package/dist/primitives/notice/index.d.ts +1 -0
  158. package/dist/primitives/notice/index.js +2 -0
  159. package/dist/primitives/table/CellCopy.js +1 -1
  160. package/dist/primitives/table/EditableTable.d.ts +3 -37
  161. package/dist/primitives/table/EditableTable.js +2 -47
  162. package/dist/primitives/table/ReportTable.js +1 -1
  163. package/dist/primitives/table/RowActions.js +1 -1
  164. package/dist/primitives/table/Table.d.ts +2 -4
  165. package/dist/primitives/table/Table.js +13 -16
  166. package/dist/primitives/table/cellTone.d.ts +5 -0
  167. package/dist/primitives/table/cellTone.js +13 -0
  168. package/dist/primitives/table/editRules.d.ts +43 -0
  169. package/dist/primitives/table/editRules.js +53 -0
  170. package/dist/primitives/table/index.d.ts +4 -2
  171. package/dist/primitives/table/index.js +4 -2
  172. package/dist/primitives/tag/Count.d.ts +2 -3
  173. package/dist/primitives/tag/Count.js +4 -5
  174. package/dist/primitives/tag/Tags.d.ts +22 -1
  175. package/dist/primitives/tag/Tags.js +57 -14
  176. package/dist/primitives/tag/countText.d.ts +3 -0
  177. package/dist/primitives/tag/countText.js +7 -0
  178. package/dist/primitives/tag/index.d.ts +3 -2
  179. package/dist/primitives/tag/index.js +2 -1
  180. package/dist/primitives/value/DateValue.d.ts +2 -5
  181. package/dist/primitives/value/DateValue.js +6 -44
  182. package/dist/primitives/value/Elapsed.d.ts +16 -0
  183. package/dist/primitives/value/Elapsed.js +37 -0
  184. package/dist/primitives/value/Meter.d.ts +3 -8
  185. package/dist/primitives/value/Meter.js +2 -9
  186. package/dist/primitives/value/RichText.d.ts +2 -4
  187. package/dist/primitives/value/RichText.js +5 -20
  188. package/dist/primitives/value/Value.d.ts +10 -7
  189. package/dist/primitives/value/Value.js +7 -24
  190. package/dist/primitives/value/elapsedTime.d.ts +26 -0
  191. package/dist/primitives/value/elapsedTime.js +32 -0
  192. package/dist/primitives/value/format.d.ts +16 -0
  193. package/dist/primitives/value/format.js +81 -0
  194. package/dist/primitives/value/index.d.ts +9 -4
  195. package/dist/primitives/value/index.js +13 -4
  196. package/dist/primitives/value/meterLevel.d.ts +10 -0
  197. package/dist/primitives/value/meterLevel.js +12 -0
  198. package/dist/primitives/value/richTextPlain.d.ts +4 -0
  199. package/dist/primitives/value/richTextPlain.js +23 -0
  200. package/dist/tokens.css +87 -1
  201. package/dist/views/list/List.d.ts +11 -0
  202. package/dist/views/list/List.js +14 -3
  203. package/dist/views/list/ListView.d.ts +1 -1
  204. package/dist/views/list/ListView.js +26 -6
  205. package/dist/views/list/types.d.ts +7 -0
  206. package/dist/views/record/Record.js +1 -1
  207. package/package.json +1 -1
@@ -0,0 +1,35 @@
1
+ import { type LucideIcon } from "lucide-react";
2
+ import { type ReactNode } from "react";
3
+ export type KioskFrameProps = {
4
+ /** The self-service flow: the menu, the steps, the payment. */
5
+ children: ReactNode;
6
+ /** The screen that waits for someone: a title that invites, a line under it, and the call
7
+ * — «Tocá para pedir». Pressing anywhere on it starts. */
8
+ attract: {
9
+ title: string;
10
+ subtitle?: string;
11
+ call?: string;
12
+ icon?: LucideIcon;
13
+ };
14
+ /** Seconds without a touch before the kiosk goes back to `attract` and calls `onIdle` (to
15
+ * drop the abandoned order). 0 never. */
16
+ idleAfter?: number;
17
+ onIdle?: () => void;
18
+ /** Controlled: whether the attract screen is showing. Uncontrolled it starts on it. */
19
+ waiting?: boolean;
20
+ onWaitingChange?: (waiting: boolean) => void;
21
+ /** Who runs the kiosk, in its corner: the brand. */
22
+ brand?: ReactNode;
23
+ };
24
+ /**
25
+ * The frame of a self-service screen — a kiosk at a café, a check-in totem, a pickup point.
26
+ *
27
+ * Context: a kiosk is not an application someone opens: it waits for a stranger, is used once
28
+ * standing up, and is left half-way. So the frame does three things no screen inside should
29
+ * have to: it WAITS (an attract screen, pressed anywhere to start), it FORGETS (after
30
+ * `idleAfter` seconds without a touch it goes back and tells the application to drop the
31
+ * order), and it REACHES (a button in the corner brings the content down to the lower half
32
+ * for someone seated, the way the big chains' kiosks do). It says «touch» for its whole area
33
+ * (`data-pointer`): a kiosk's screen may report a mouse.
34
+ */
35
+ export declare function KioskFrame({ children, attract, idleAfter, onIdle, waiting: controlled, onWaitingChange, brand, }: KioskFrameProps): import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useUiCopy } from "../../foundations/copy.js";
4
+ import { useIdle } from "../../foundations/idle.js";
5
+ import { POINTER_ATTRIBUTE } from "../../foundations/pointer.js";
6
+ import { buttonClasses } from "../../primitives/button/classes.js";
7
+ import { Accessibility, Hand } from "lucide-react";
8
+ import { useState } from "react";
9
+ /**
10
+ * The frame of a self-service screen — a kiosk at a café, a check-in totem, a pickup point.
11
+ *
12
+ * Context: a kiosk is not an application someone opens: it waits for a stranger, is used once
13
+ * standing up, and is left half-way. So the frame does three things no screen inside should
14
+ * have to: it WAITS (an attract screen, pressed anywhere to start), it FORGETS (after
15
+ * `idleAfter` seconds without a touch it goes back and tells the application to drop the
16
+ * order), and it REACHES (a button in the corner brings the content down to the lower half
17
+ * for someone seated, the way the big chains' kiosks do). It says «touch» for its whole area
18
+ * (`data-pointer`): a kiosk's screen may report a mouse.
19
+ */
20
+ export function KioskFrame({ children, attract, idleAfter = 90, onIdle, waiting: controlled, onWaitingChange, brand, }) {
21
+ const copy = useUiCopy();
22
+ const [own, setOwn] = useState(true);
23
+ const waiting = controlled ?? own;
24
+ const [low, setLow] = useState(false);
25
+ const setWaiting = (next) => {
26
+ if (controlled === undefined)
27
+ setOwn(next);
28
+ onWaitingChange?.(next);
29
+ };
30
+ useIdle(idleAfter, () => {
31
+ setWaiting(true);
32
+ setLow(false);
33
+ onIdle?.();
34
+ }, !waiting);
35
+ const Icon = attract.icon ?? Hand;
36
+ return (_jsx("div", { "data-ui": "kiosk", [POINTER_ATTRIBUTE]: "touch", className: "relative flex h-dvh min-h-0 min-w-0 flex-col bg-ground", children: waiting ? (
37
+ /* The whole screen is the button: a stranger does not look for a target. */
38
+ _jsxs("button", { type: "button", "data-ui": "kiosk.attract", onClick: () => setWaiting(false), className: "flex min-h-0 flex-1 cursor-pointer flex-col items-center justify-center gap-4 px-6 text-center outline-none focus-visible:outline-4 focus-visible:-outline-offset-8 focus-visible:outline-primary", children: [brand === undefined ? null : _jsx("span", { className: "text-meta text-muted", children: brand }), _jsx("span", { className: "text-hero leading-tight font-semibold text-ink", children: attract.title }), attract.subtitle === undefined ? null : (_jsx("span", { className: "max-w-short text-lead text-muted", children: attract.subtitle })), _jsxs("span", { className: `${buttonClasses("primary", "lg")} mt-6 gap-3`, children: [_jsx(Icon, { "aria-hidden": true, className: "size-(--size-icon-lg)" }), attract.call ?? copy.kiosk.start] })] })) : (_jsxs(_Fragment, { children: [low ? _jsx("div", { "aria-hidden": true, className: "h-(--size-kiosk-reach) shrink-0" }) : null, _jsx("div", { "data-ui": "kiosk.content", className: "flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto", children: children }), _jsx("button", { type: "button", "data-ui": "kiosk.reach", "aria-pressed": low, onClick: () => setLow((now) => !now), title: low ? copy.kiosk.reachOff : copy.kiosk.reach, "aria-label": low ? copy.kiosk.reachOff : copy.kiosk.reach, className: `${buttonClasses("secondary", "lg")} absolute bottom-4 left-4 z-30 aspect-square rounded-pill px-0 shadow-float`, children: _jsx(Accessibility, { "aria-hidden": true, className: "size-(--size-icon-lg)" }) })] })) }));
39
+ }
@@ -30,5 +30,5 @@ export function SearchEntry({ onSearch, label, shortcut = "K", layout = "row", s
30
30
  }, ...(keys === null ? {} : { "aria-keyshortcuts": keys.aria }), className: `flex h-(--size-control-sm) min-w-0 cursor-pointer items-center gap-2 rounded-ui-control border px-2 text-meta transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 ${bar ? "shrink-0 max-sm:w-(--size-control-sm) max-sm:justify-center" : "w-full"} ${skin.box}`, "data-ui": "search-entry", "data-surface": sup, children: [_jsx(Search, { className: "size-(--size-icon-md) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: `min-w-0 flex-1 truncate text-left ${bar ? "max-sm:sr-only" : ""}`, children: label ?? copy.shell.search }), keys === null ? null : (
31
31
  /* Seen, not heard: `aria-keyshortcuts` already tells a screen reader, and «⌘K» read
32
32
  aloud is noise after the name. Not drawn for a finger: a phone has no ⌘. */
33
- _jsx("kbd", { "aria-hidden": true, className: `shrink-0 rounded-control border px-1.5 font-mono text-micro pointer-coarse:hidden ${bar ? "max-sm:hidden" : ""} ${skin.keys}`, "data-ui": "search-entry.keys", children: keys.label }))] }));
33
+ _jsx("kbd", { "aria-hidden": true, className: `shrink-0 rounded-control border px-1.5 font-mono text-micro touch:hidden ${bar ? "max-sm:hidden" : ""} ${skin.keys}`, "data-ui": "search-entry.keys", children: keys.label }))] }));
34
34
  }
@@ -4,4 +4,5 @@ export { Sidebar, type SidebarAction, type SidebarProps, } from "./Sidebar.js";
4
4
  export { SearchEntry, type SearchEntryProps, } from "./SearchEntry.js";
5
5
  export { type SidebarDrawer, SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
6
6
  export { type AppEntry, SystrayButton, TopBar, type TopMenu, } from "./TopBar.js";
7
+ export { KioskFrame, type KioskFrameProps, } from "./KioskFrame.js";
7
8
  export { Pane, Panes } from "./Panes.js";
@@ -11,4 +11,5 @@ export { SearchEntry, } from "./SearchEntry.js";
11
11
  export { SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
12
12
  export { SystrayButton, TopBar, } from "./TopBar.js";
13
13
  /* A screen of N sets side by side — the reconciliation: each pane scrolls on its own. */
14
+ export { KioskFrame, } from "./KioskFrame.js";
14
15
  export { Pane, Panes } from "./Panes.js";
@@ -1,4 +1,4 @@
1
- import { currentCopy, currentCopyLocale, fillCopy } from "./copy.js";
1
+ import { currentCopy, currentCopyLocale, fillCopy } from "./uiCopy.js";
2
2
  /**
3
3
  * THE CALENDAR: from a date to a KEY, and from a key to a LABEL.
4
4
  *
@@ -1,10 +1,7 @@
1
+ import { type CopyOverride, type CopyStore, fillCopy, mergeCopyOver } from "./copyStore.js";
1
2
  import { type ReactNode } from "react";
2
- /** What changes, at any depth. A word is replaced; a section is merged. */
3
- export type CopyOverride<C> = {
4
- [K in keyof C]?: C[K] extends string ? string : C[K] extends readonly unknown[] ? C[K] : C[K] extends object ? CopyOverride<C[K]> : C[K];
5
- };
6
- /** `base` with `over` on top: sections merge, everything else is replaced. */
7
- export declare function mergeCopyOver<C extends object>(base: C, over: CopyOverride<C> | undefined): C;
3
+ export type { CopyOverride };
4
+ export { fillCopy, mergeCopyOver };
8
5
  export type CopyCatalog<C extends object> = {
9
6
  /** The factory words: what is there before anything is installed. */
10
7
  english: C;
@@ -23,5 +20,7 @@ export type CopyCatalog<C extends object> = {
23
20
  useCopy: () => C;
24
21
  };
25
22
  export declare function createCopy<C extends object>(english: C): CopyCatalog<C>;
26
- /** `{name}` → value. A missing key stays visible in the template. */
27
- export declare function fillCopy(template: string, params: Record<string, string | number>): string;
23
+ /** The React half over a store that already exists: web-ui's own words are built in a module
24
+ * without the directive (`uiCopy.ts`), and their `Provider` reads the same installed ones.
25
+ * Not public. */
26
+ export declare function catalogOver<C extends object>(store: CopyStore<C>): CopyCatalog<C>;
@@ -1,48 +1,23 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { copyStore, fillCopy, mergeCopyOver, } from "./copyStore.js";
3
4
  import { createContext, useContext, useMemo } from "react";
4
- const isSection = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5
- /** `base` with `over` on top: sections merge, everything else is replaced. */
6
- export function mergeCopyOver(base, over) {
7
- if (over === undefined)
8
- return base;
9
- const out = { ...base };
10
- for (const [key, value] of Object.entries(over)) {
11
- if (value === undefined)
12
- continue;
13
- const under = out[key];
14
- out[key] = isSection(under) && isSection(value) ? mergeCopyOver(under, value) : value;
15
- }
16
- return out;
17
- }
5
+ export { fillCopy, mergeCopyOver };
18
6
  export function createCopy(english) {
19
- let installed = english;
7
+ return catalogOver(copyStore(english));
8
+ }
9
+ /** The React half over a store that already exists: web-ui's own words are built in a module
10
+ * without the directive (`uiCopy.ts`), and their `Provider` reads the same installed ones.
11
+ * Not public. */
12
+ export function catalogOver(store) {
20
13
  /* `null` and not English: a context keeps the value it was created with, so with the
21
14
  factory words inside it a component without a provider would ignore `install`. */
22
15
  const Context = createContext(null);
23
- const current = () => installed;
24
- const useCopy = () => useContext(Context) ?? installed;
16
+ const useCopy = () => useContext(Context) ?? store.current();
25
17
  function Provider({ copy, children }) {
26
18
  const enclosing = useCopy();
27
19
  const merged = useMemo(() => mergeCopyOver(enclosing, copy), [enclosing, copy]);
28
20
  return _jsx(Context.Provider, { value: merged, children: children });
29
21
  }
30
- return {
31
- english,
32
- install: (over) => {
33
- installed = mergeCopyOver(english, over);
34
- return installed;
35
- },
36
- current,
37
- merge: (over) => mergeCopyOver(english, over),
38
- Provider,
39
- useCopy,
40
- };
41
- }
42
- /** `{name}` → value. A missing key stays visible in the template. */
43
- export function fillCopy(template, params) {
44
- return template.replace(/\{(\w+)\}/g, (whole, name) => {
45
- const value = params[name];
46
- return value === undefined ? whole : String(value);
47
- });
22
+ return { ...store, Provider, useCopy };
48
23
  }
@@ -1,7 +1,7 @@
1
1
  import { dateKeysBetween, dateKeyYear, dateTick } from "./calendar.js";
2
- import { currentCopy, fillCopy } from "./copy.js";
3
2
  import { pathKey } from "./grouping.js";
4
3
  import { axisLabels, } from "./pivot.js";
4
+ import { currentCopy, fillCopy } from "./uiCopy.js";
5
5
  /** The row count of each crossing, offered as one more measure: it is the only one that
6
6
  * can always be answered. */
7
7
  export const COUNT_MEASURE = "__count";
@@ -0,0 +1,3 @@
1
+ /** The time now, in epoch milliseconds, refreshed every `every` ms (a second by default) — or
2
+ * `null` on the server and while hydrating. */
3
+ export declare function useNow(every?: number): number | null;
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { useCallback, useSyncExternalStore } from "react";
3
+ const tickers = new Map();
4
+ function tickerOf(every) {
5
+ let ticker = tickers.get(every);
6
+ if (ticker === undefined) {
7
+ ticker = { now: Date.now(), listeners: new Set() };
8
+ tickers.set(every, ticker);
9
+ }
10
+ return ticker;
11
+ }
12
+ function subscribe(every, listener) {
13
+ const ticker = tickerOf(every);
14
+ ticker.listeners.add(listener);
15
+ if (ticker.timer === undefined) {
16
+ /* «now» moves only on a tick: changing it while subscribing would change the snapshot
17
+ React just read, and it would render, resubscribe and change it again, forever. */
18
+ ticker.timer = setInterval(() => {
19
+ ticker.now = Date.now();
20
+ for (const one of ticker.listeners)
21
+ one();
22
+ }, every);
23
+ }
24
+ return () => {
25
+ ticker.listeners.delete(listener);
26
+ if (ticker.listeners.size === 0 && ticker.timer !== undefined) {
27
+ clearInterval(ticker.timer);
28
+ ticker.timer = undefined;
29
+ }
30
+ };
31
+ }
32
+ /** The time now, in epoch milliseconds, refreshed every `every` ms (a second by default) — or
33
+ * `null` on the server and while hydrating. */
34
+ export function useNow(every = 1000) {
35
+ /* Stable per interval: a new `subscribe` on every render makes React unsubscribe and
36
+ subscribe again on each one. */
37
+ const listen = useCallback((listener) => subscribe(every, listener), [every]);
38
+ const read = useCallback(() => tickerOf(every).now, [every]);
39
+ return useSyncExternalStore(listen, read, serverNow);
40
+ }
41
+ const serverNow = () => null;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The `aria-label` a control puts on itself: none inside a `Field` — the field's label names
3
+ * it — and outside one the control's own, or as a last resort its placeholder (what a browser
4
+ * reads for a bare `<input placeholder>` anyway, so a control outside a form is never
5
+ * nameless).
6
+ *
7
+ * Context: a control inside a `Field` used to keep its `aria-label` too. With both, React Aria
8
+ * names the control by the label AND itself («Cliente Cliente», «Cantidad cantidad»), so the
9
+ * name was read twice. The field wins: an `aria-label` is for a control that has no label
10
+ * on screen — a table cell, a search box — and inside a field it is ignored.
11
+ */
12
+ export declare function controlName(labelledBy: string | undefined, ariaLabel: string | undefined, fallback?: string): string | undefined;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The `aria-label` a control puts on itself: none inside a `Field` — the field's label names
3
+ * it — and outside one the control's own, or as a last resort its placeholder (what a browser
4
+ * reads for a bare `<input placeholder>` anyway, so a control outside a form is never
5
+ * nameless).
6
+ *
7
+ * Context: a control inside a `Field` used to keep its `aria-label` too. With both, React Aria
8
+ * names the control by the label AND itself («Cliente Cliente», «Cantidad cantidad»), so the
9
+ * name was read twice. The field wins: an `aria-label` is for a control that has no label
10
+ * on screen — a table cell, a search box — and inside a field it is ignored.
11
+ */
12
+ export function controlName(labelledBy, ariaLabel, fallback) {
13
+ return labelledBy === undefined ? (ariaLabel ?? fallback) : undefined;
14
+ }