@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
@@ -1,91 +1,19 @@
1
- import type { Surface } from "../../foundations/types.js";
1
+ import type { Surface, Tone } from "../../foundations/types.js";
2
2
  import type { ViewStyle } from "../../foundations/viewStyle.js";
3
3
  import type { ReactNode } from "react";
4
- /** THE BAR — two rows, two questions.
5
- *
6
- * ┌──────────┬──────────────────────────────┬──────────────┐
7
- * │ crumbs │ 🔍 search… ⚙3 │ 1–8 of 187 ‹ › │
8
- * ├──────────┼──────────────────────────────┼──────────────┤
9
- * │ [New] │ Facturas · 180 · 7 · 8 │ [columns] [▤][▦] │
10
- * └──────────┴──────────────────────────────┴──────────────┘
11
- * WHERE / HOW MUCH I SEE HOW I LOOK
12
- *
13
- * Pagination answers how much of the filtered set is on screen, so it stays
14
- * with the search. Columns and the presentation switcher answer how the set
15
- * is looked at, so they sit with the actions — not next to the page range.
16
- * Putting the four of them on the search line is how the field and «1–80»
17
- * painted over each other the moment the window shrank.
18
- *
19
- * ── Why it is two lines tall ────────────────────────────────────────
20
- *
21
- * Because the three things that go on the left do not fit in one: a
22
- * comfortable button is 34 px tall, a list title may have to wrap onto two
23
- * lines, and below it goes a sentence saying what the list is made of. Forcing
24
- * it into a single line means shrinking the button —the defect we already
25
- * fixed— or truncating the title, which is worse: a list that cannot be named
26
- * in full is indistinguishable from the one next to it.
27
- *
28
- * ── The selection transforms the bar, it does not add one ───────────
29
- *
30
- * When rows get selected, the identity zone turns into «3 elegidas ✕» plus the
31
- * actions that apply. **In the same place and without pushing anything.** A
32
- * bar that appears shifts the list downwards right when somebody is ticking
33
- * checkboxes, and the row they were about to tick is no longer where it was.
34
- *
35
- * The actions on the left do NOT go away: «Nuevo» stays available with three
36
- * rows selected, because selecting is not entering a mode.
37
- *
38
- * ── The modern style: the trail is the heading ──────────────────────
39
- *
40
- * ┌──────────────────────────────────────────────────────────────────┐
41
- * │ Ventas › Andina › Pedidos ( 1–12 / 12 ‹ › ) │
42
- * │ what it is made of 🔍 search… [sort][cols] [▤▦] │
43
- * └──────────────────────────────────────────────────────────────────┘
44
- * ( Pedidos │ Importar · Exportar ▾ · + Nueva cotización ) ← floats
45
- *
46
- * As a record in the modern style, WHERE I AM is the page's heading: the trail at the
47
- * title's size (`Breadcrumb size="lg"`), its last crumb the list's name — so the title is
48
- * not said twice —, and the page range at the other end, as the record's pager pill. Its
49
- * counters are not here: beside the trail they read as more crumbs; the list draws them as
50
- * mini stats under the bar (`List.Metrics`). The second row is how I look at the set: what
51
- * it is made of (the description), the search centred, sort, columns and the faces. The
52
- * list's actions float at the bottom of the screen in a pill named by the list
53
- * (`List.Dock`), which turns into what is done to the chosen rows while some are chosen;
54
- * given `placement="bar"`, or drawn by hand, they take the start of the second row and the
55
- * description goes on demand (`Hint`) beside the heading. Without crumbs the title is the
56
- * heading. Compact keeps the one bar below.
57
- *
58
- * ── Inside a record it is ONE line (`inline`) ────────────────────────
59
- *
60
- * ┌───────────────────────────────────────────────────────────────┐
61
- * │ 🔍 search the lines… 12 records [sort][cols][▤▦] │
62
- * └───────────────────────────────────────────────────────────────┘
63
- * WHAT I LOOK FOR (fills) HOW MANY HOW I LOOK
64
- *
65
- * A collection that is a FIELD of a record — the lines of an order, the
66
- * contacts of a customer, the journal items of an invoice — is not a screen.
67
- * Everything the two rows above answer is already answered by the record
68
- * around it: where I am (the record's crumbs), what this is (the tab it sits
69
- * in), what I can do (the record's actions). Drawn with the page bar, it
70
- * spent two rows and a rule on the one question left —the search, alone and
71
- * centred on the first row; «Ordenar» and the switcher alone on the second—
72
- * and pushed the rows, which are what the tab is for, below the fold.
73
- *
74
- * So it is a single line, and the order is the order of the questions: the
75
- * search FILLS from the left (it is the only thing with variable content),
76
- * then how many there are, then how they are looked at, then what starts a
77
- * new one. No band, no padding, no hairline: it sits on the record's paper,
78
- * aligned with the fields above it, and a light band inside a white sheet is
79
- * a rectangle inside a rectangle.
80
- *
81
- * On a phone the line breaks by itself, with no threshold written anywhere:
82
- * the search asks for `--container-name` before it gives up its place, so
83
- * when the controls do not fit next to it they drop to a second line, pushed
84
- * to the right, and the search keeps the whole first one.
85
- *
86
- * The count is a live region: typing in the search changes it, and somebody
87
- * who cannot see the rows thin out hears how many are left. With
88
- * `pagination` the page range replaces it — it already says how many. */
4
+ /**
5
+ * One count of what the list is made of — «64 cotizaciones». With `onClick` it also NARROWS
6
+ * the list to them (a quick filter that already says how many it will leave), and `active`
7
+ * says it is applied: a number that leads somewhere is pressed, as a `Metric` is.
8
+ */
9
+ export type ListCounter = {
10
+ label: string;
11
+ value: number | string;
12
+ onClick?: () => void;
13
+ active?: boolean;
14
+ /** What the count means — overdue in `bad`. The figure takes it; the label stays muted. */
15
+ tone?: Tone;
16
+ };
89
17
  export declare function ListingBar({ actions, title, description, counters, selection, search, pagination, views, crumbs, surface, inline, count, look, }: {
90
18
  /** How the bar is drawn: `modern` makes the trail the heading and puts the search on the
91
19
  * row of the controls (see the header). The list passes its view style. */
@@ -98,10 +26,7 @@ export declare function ListingBar({ actions, title, description, counters, sele
98
26
  description?: string;
99
27
  /** The totals per category. The ones in the pagination say how many there
100
28
  * are; these say what they are made of, which is another question. */
101
- counters?: readonly {
102
- label: string;
103
- value: number | string;
104
- }[];
29
+ counters?: readonly ListCounter[];
105
30
  /** When there are selected rows. It replaces the identity, in the same place. */
106
31
  selection?: {
107
32
  count: number;
@@ -134,8 +59,5 @@ export declare function ListingBar({ actions, title, description, counters, sele
134
59
  export type ListIdentity = {
135
60
  title?: string;
136
61
  description?: string;
137
- counters?: readonly {
138
- label: string;
139
- value: number | string;
140
- }[];
62
+ counters?: readonly ListCounter[];
141
63
  };
@@ -91,6 +91,14 @@ import { X } from "lucide-react";
91
91
  * The count is a live region: typing in the search changes it, and somebody
92
92
  * who cannot see the rows thin out hears how many are left. With
93
93
  * `pagination` the page range replaces it — it already says how many. */
94
+ /* A count's figure in its tone — text on the canvas, so the readable ones. */
95
+ const COUNTER_TONE = {
96
+ info: "text-info",
97
+ good: "text-good",
98
+ warn: "text-warn",
99
+ bad: "text-bad",
100
+ accent: "text-ink",
101
+ };
94
102
  export function ListingBar({ actions, title, description, counters, selection, search, pagination, views, crumbs, surface, inline = false, count, look = "traditional", }) {
95
103
  const selecting = selection !== undefined && selection.count > 0;
96
104
  const d = useDensity();
@@ -109,7 +117,7 @@ export function ListingBar({ actions, title, description, counters, selection, s
109
117
  Views used to sit next to the pagination. On a narrow window the search
110
118
  field and «1–80 / 211» painted over each other; columns and the switcher
111
119
  were the extra weight on a line that only needed how MANY. */
112
- const center = selecting ? (_jsxs("div", { className: "flex min-w-0 items-center gap-x-2", children: [_jsxs("span", { className: `inline-flex h-(--size-control-md) shrink-0 items-center gap-1.5 rounded-control pr-1 pl-2.5 text-meta font-medium ${isChrome ? "bg-chrome-ink/14 text-chrome-ink" : "bg-ink/8 text-ink"}`, children: [_jsx("span", { className: "tabular-nums", children: selection?.count.toLocaleString(copy.locale) }), copy.selection.chosen, _jsx("button", { type: "button", onClick: selection?.onClear, "aria-label": copy.selection.clear, title: copy.selection.clear, className: `inline-flex size-5 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${isChrome ? "hover:bg-chrome-ink/20" : "hover:bg-primary/20"}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) })] }), selection?.matching === undefined ||
120
+ const center = selecting ? (_jsxs("div", { className: "flex min-w-0 items-center gap-x-2", children: [_jsxs("span", { className: `inline-flex h-(--size-control-md) shrink-0 items-center gap-1.5 rounded-control pr-1 pl-2.5 text-meta font-medium ${isChrome ? "bg-chrome-ink/14 text-chrome-ink" : "bg-ink/8 text-ink"}`, children: [_jsx("span", { className: "tabular-nums", children: selection?.count.toLocaleString(copy.locale) }), copy.selection.chosen, _jsx("button", { type: "button", onClick: selection?.onClear, "aria-label": copy.selection.clear, title: copy.selection.clear, className: `hit-target inline-flex size-5 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${isChrome ? "hover:bg-chrome-ink/20" : "hover:bg-primary/20"}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) })] }), selection?.matching === undefined ||
113
121
  selection.matching.total <= selection.count ? null : (_jsx("button", { type: "button", onClick: selection.matching.onSelect, className: `shrink-0 rounded-control px-1 text-meta font-medium underline-offset-4 hover:underline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${isChrome ? "text-chrome-link" : "text-primary"}`, children: fillCopy(copy.selection.allMatching, {
114
122
  count: selection.matching.total.toLocaleString(copy.locale),
115
123
  }) })), selection?.actions === undefined ? null : (_jsx("div", { className: "flex min-w-0 items-center gap-1.5", children: selection.actions }))] })) : search === undefined ? null : (
@@ -145,7 +153,21 @@ export function ListingBar({ actions, title, description, counters, selection, s
145
153
  const heading = title === undefined ? null : (_jsx("h2", { className: `text-title leading-tight font-semibold ${isChrome ? "text-chrome-ink" : "text-ink"}`, children: title }));
146
154
  /* What the list is made of: its counters and its sentence. Under the title in the
147
155
  traditional bar; at the start of the controls' row in the modern one. */
148
- const about = description === undefined && counters === undefined ? null : (_jsxs("div", { className: "flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-0.5", children: [counters?.map((c) => (_jsxs("span", { className: "flex items-baseline gap-1", children: [_jsx("span", { className: `text-meta font-medium tabular-nums ${isChrome ? "text-chrome-ink" : "text-ink"}`, children: typeof c.value === "number" ? c.value.toLocaleString(copy.locale) : c.value }), _jsx("span", { className: `text-micro ${isChrome ? "text-chrome-muted" : "text-muted"}`, children: c.label })] }, c.label))), description === undefined ? null : (_jsx("span", { className: `min-w-0 text-micro ${isChrome ? "text-chrome-muted" : "text-muted"}`, children: description }))] }));
156
+ const about = description === undefined && counters === undefined ? null : (_jsxs("div", { className: "flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-0.5", children: [counters?.map((c) => {
157
+ const inside = (_jsxs(_Fragment, { children: [_jsx("span", { className: `text-meta font-medium tabular-nums ${c.active === true
158
+ ? isChrome
159
+ ? "text-chrome-link"
160
+ : "text-primary"
161
+ : c.tone !== undefined && c.tone !== "neutral" && !isChrome
162
+ ? COUNTER_TONE[c.tone]
163
+ : isChrome
164
+ ? "text-chrome-ink"
165
+ : "text-ink"}`, children: typeof c.value === "number" ? c.value.toLocaleString(copy.locale) : c.value }), _jsx("span", { className: `text-micro ${isChrome ? "text-chrome-muted" : "text-muted"}`, children: c.label })] }));
166
+ return c.onClick === undefined ? (_jsx("span", { className: "flex items-baseline gap-1", children: inside }, c.label)) : (
167
+ /* Pressed like a link and not like a button: it sits in a sentence about the
168
+ list. Applied, it says so in the primary and with `aria-pressed`. */
169
+ _jsx("button", { type: "button", onClick: c.onClick, "aria-pressed": c.active === true, className: `hit-target flex items-baseline gap-1 rounded-control underline-offset-4 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ${c.active === true ? "underline" : ""}`, children: inside }, c.label));
170
+ }), description === undefined ? null : (_jsx("span", { className: `min-w-0 text-micro ${isChrome ? "text-chrome-muted" : "text-muted"}`, children: description }))] }));
149
171
  const bottomRow = actions === undefined && !withIdentity && views === undefined ? null : (
150
172
  /* On a narrow list (a phone, a drawer) the name and its counters take the whole first
151
173
  line and the action and the controls go below: squeezed between them, the
@@ -1,7 +1,9 @@
1
+ import type { Tone } from "../../foundations/types.js";
2
+ import { type ElapsedProps } from "../../primitives/value/Elapsed.js";
1
3
  import type { LucideIcon } from "lucide-react";
2
4
  import type { ReactNode } from "react";
3
5
  /**
4
- * One record as a card — the board presentation of a list.
6
+ * One record as a card — the board presentation of a list, a product on a till's grid.
5
7
  *
6
8
  * Context: the board drew this card inline, and a list that wanted its own card wrote its
7
9
  * own `div` — which looked the same and could not be opened: the default card was a button
@@ -11,8 +13,27 @@ import type { ReactNode } from "react";
11
13
  *
12
14
  * Its hierarchy is the row's: the state first (what it is), the name as the entry point,
13
15
  * the facts below in the quiet size.
16
+ *
17
+ * ── Three shapes, for three ways of looking ─────────────────────────
18
+ *
19
+ * card a board's card: the name in up to two lines (a figure beside it never cuts
20
+ * it), what it is about, N facts, its controls at the foot
21
+ * compact two lines, for a pipeline of sixty: name and figure, then one line of facts
22
+ * tile a product on a grid: the picture on top, the name, the price — the whole tile
23
+ * is pressed, as a till's or a shop's is
24
+ *
25
+ * It was one box of 16px padding and 12px corners inside a lane that was another box: two
26
+ * borders and two roundings around every card, and the figure on the name's line cut the
27
+ * name to «Certificación ISO 9…». The padding now follows the density, the corners are the
28
+ * control's (`--ui-record-card-radius`), and the name wraps before it is cut.
14
29
  */
15
- export declare function RecordCard({ title, subtitle, tags, meta, figure, media, footer, onOpen, }: {
30
+ export type RecordCardLayout = "card" | "compact" | "tile";
31
+ /** One fact of the record: «Cierre · 30/11», «Probabilidad · 60 %». */
32
+ export type RecordCardField = {
33
+ label: string;
34
+ value: ReactNode;
35
+ };
36
+ export declare function RecordCard({ title, subtitle, tags, meta, figure, media, footer, onOpen, layout, fields, badge, selected, disabled, tone, elapsed, }: {
16
37
  title: ReactNode;
17
38
  /** Who or what it is about, under the title: the customer of an opportunity. */
18
39
  subtitle?: ReactNode;
@@ -21,7 +42,7 @@ export declare function RecordCard({ title, subtitle, tags, meta, figure, media,
21
42
  figure?: ReactNode;
22
43
  /** The picture of the record. A product's is a square (`Thumb`); a PERSON's is round, with
23
44
  * the initials when there is no photo — `person`, like `RelationCard`'s. `alt` names the
24
- * person when the title is not plain text. */
45
+ * person when the title is not plain text. In a `tile` it is the cover. */
25
46
  media?: {
26
47
  src?: string;
27
48
  alt?: string;
@@ -32,4 +53,21 @@ export declare function RecordCard({ title, subtitle, tags, meta, figure, media,
32
53
  * avatar — each its own button, pressable without opening the card. */
33
54
  footer?: ReactNode;
34
55
  onOpen?: () => void;
56
+ layout?: RecordCardLayout;
57
+ /** N facts as label and value — as many as the record needs to be told apart on a board.
58
+ * More than four and it is a form: open the record. */
59
+ fields?: readonly RecordCardField[];
60
+ /** A count on the corner: how many of this product are already in the ticket. */
61
+ badge?: ReactNode;
62
+ /** It is chosen — the ticket's line being edited, the order being bumped. */
63
+ selected?: boolean;
64
+ /** It cannot be chosen now — out of stock. Shown (it exists) but quiet and not pressed; say
65
+ * why in `meta` («Sin stock»). */
66
+ disabled?: boolean;
67
+ /** What the record's state says before it is read: a stripe on its edge in that tone —
68
+ * blocked, overdue. `elapsed` with thresholds paints it by itself. */
69
+ tone?: Tone;
70
+ /** How long it has been waiting, live — a kitchen's ticket, a case under an SLA. With
71
+ * `warnAfter` / `badAfter` (minutes) the time and the card's edge turn amber, then red. */
72
+ elapsed?: Omit<ElapsedProps, "now">;
35
73
  }): import("react").JSX.Element;
@@ -1,31 +1,72 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useNow } from "../../foundations/clock.js";
4
+ import { byDensity, useDensity } from "../../foundations/density.js";
3
5
  import { Thumb } from "../../primitives/cell/CellStack.js";
4
6
  import { Avatar } from "../../primitives/value/Avatar.js";
5
- /**
6
- * One record as a card — the board presentation of a list.
7
- *
8
- * Context: the board drew this card inline, and a list that wanted its own card wrote its
9
- * own `div` — which looked the same and could not be opened: the default card was a button
10
- * with `onOpen`, the custom one was not. A card is the record's door in the board the way a
11
- * row is in the table, so it is a component and it is always pressable when there is
12
- * somewhere to go.
13
- *
14
- * Its hierarchy is the row's: the state first (what it is), the name as the entry point,
15
- * the facts below in the quiet size.
16
- */
17
- export function RecordCard({ title, subtitle, tags, meta, figure, media, footer, onOpen, }) {
7
+ import { Elapsed } from "../../primitives/value/Elapsed.js";
8
+ import { elapsedMillis, elapsedTone } from "../../primitives/value/elapsedTime.js";
9
+ /* The stripe on a card's edge in its tone: what it says about the record, before reading it. */
10
+ const STRIPE = {
11
+ info: "bg-info",
12
+ good: "bg-good",
13
+ warn: "bg-warn",
14
+ bad: "bg-bad",
15
+ accent: "bg-accent",
16
+ };
17
+ function Stripe({ tone }) {
18
+ if (tone === undefined || tone === "neutral")
19
+ return null;
20
+ return (_jsx("span", { "aria-hidden": true, "data-ui": "record-card.stripe", "data-tone": tone, className: `pointer-events-none absolute inset-y-0 left-0 w-1 rounded-l-ui-record-card ${STRIPE[tone]}` }));
21
+ }
22
+ /* The live stripe of a waiting record — its own component so only the card that waits
23
+ re-renders with the clock, not every card of the board. */
24
+ function WaitingStripe({ elapsed }) {
25
+ const now = useNow();
26
+ if (now === null)
27
+ return null;
28
+ return _jsx(Stripe, { tone: elapsedTone(elapsedMillis(elapsed.since, now), elapsed) });
29
+ }
30
+ export function RecordCard({ title, subtitle, tags, meta, figure, media, footer, onOpen, layout = "card", fields, badge, selected = false, disabled = false, tone, elapsed, }) {
31
+ const density = useDensity();
32
+ const pressable = onOpen !== undefined && !disabled;
18
33
  /* The card is a box, and the TITLE is the button that opens it, stretched over the whole
19
34
  card (`after:inset-0`). It used to be a `<button>` around everything: a priority star or a
20
35
  kanban state inside it would be a control inside a control, which is invalid and which a
21
36
  screen reader announces as one thing. The footer's controls sit above the stretch. */
22
- const titleText = _jsx("span", { className: "min-w-0 truncate", children: title });
23
- return (_jsxs("div", { "data-ui": "record-card", className: `relative flex w-full min-w-0 flex-col gap-2 rounded-ui-card border border-ui-card-border bg-ui-card p-4 text-left ${onOpen === undefined
24
- ? ""
25
- : "transition-colors duration-(--duration-instant) focus-within:border-line-strong hover:border-line-strong"}`, children: [media === undefined ? null : media.person === true ? (
26
- /* The name is written right below it: the photo's `alt` would say it twice. */
27
- _jsx("span", { "aria-hidden": true, className: "flex shrink-0", children: _jsx(Avatar, { name: media.alt ?? (typeof title === "string" ? title : ""), size: "xl", ...(media.src === undefined ? {} : { src: media.src }) }) })) : (_jsx(Thumb, { size: "lg", ...(media.src === undefined ? {} : { src: media.src }), ...(media.alt === undefined ? {} : { alt: media.alt }), ...(media.icon === undefined ? {} : { icon: media.icon }) })), tags === undefined ? null : _jsx("div", { className: "flex flex-wrap gap-1.5", children: tags }), _jsxs("div", { className: "flex min-w-0 items-baseline justify-between gap-3", children: [onOpen === undefined ? (_jsx("p", { className: "flex min-w-0 text-lead font-medium text-ink", children: titleText })) : (_jsx("button", { type: "button", onClick: onOpen, className: "flex min-w-0 text-left text-lead font-medium text-ink outline-none after:absolute after:inset-0 after:rounded-box focus-visible:after:outline-2 focus-visible:after:outline-primary", children: titleText })), figure === undefined ? null : (_jsx("p", { className: "shrink-0 text-lead font-semibold tabular-nums text-ink", children: figure }))] }), subtitle === undefined ? null : (
28
- /* Above the stretched title, at its own width: the subtitle may be a link to ANOTHER
29
- record (the customer), which must open that one and not the card. */
30
- _jsx("p", { className: "relative z-10 -mt-1.5 w-fit max-w-full min-w-0 truncate text-meta text-muted", children: subtitle })), meta === undefined ? null : (_jsx("p", { className: "text-micro tabular-nums text-muted", children: meta })), footer === undefined ? null : (_jsx("div", { className: "relative z-10 flex min-w-0 items-center gap-1.5", children: footer }))] }));
37
+ const titleText = (_jsx("span", { "data-ui": "record-card.title", className: `min-w-0 ${layout === "compact" ? "truncate" : "line-clamp-2"}`, children: title }));
38
+ const titleSize = layout === "card" ? "text-lead" : "text-body";
39
+ const name = pressable ? (_jsx("button", { type: "button", onClick: onOpen, ...(selected ? { "aria-current": true } : {}), className: `flex min-w-0 flex-1 text-left ${titleSize} font-medium text-ink outline-none after:absolute after:inset-0 after:rounded-ui-record-card focus-visible:after:outline-2 focus-visible:after:outline-primary`, children: titleText })) : (_jsx("p", { className: `flex min-w-0 flex-1 ${titleSize} font-medium text-ink`, children: titleText }));
40
+ const shell = `relative flex w-full min-w-0 flex-col rounded-ui-record-card border bg-ui-card text-left ${selected
41
+ ? "border-primary ring-1 ring-primary"
42
+ : `border-ui-card-border ${pressable
43
+ ? "transition-colors duration-(--duration-instant) focus-within:border-line-strong hover:border-line-strong"
44
+ : ""}`}`;
45
+ const stripe = tone !== undefined ? (_jsx(Stripe, { tone: tone })) : elapsed === undefined ? null : (_jsx(WaitingStripe, { elapsed: elapsed }));
46
+ const corner = badge === undefined ? null : (_jsx("span", { "data-ui": "record-card.badge", className: "pointer-events-none absolute -top-2 -right-2 z-20 inline-flex h-6 min-w-6 items-center justify-center rounded-pill bg-primary px-1.5 text-meta font-semibold text-surface tabular-nums shadow-raised", children: badge }));
47
+ const timer = elapsed === undefined ? null : (_jsx(Elapsed, { since: elapsed.since, ...(elapsed.warnAfter === undefined ? {} : { warnAfter: elapsed.warnAfter }), ...(elapsed.badAfter === undefined ? {} : { badAfter: elapsed.badAfter }) }));
48
+ const factList = fields === undefined || fields.length === 0 ? null : (_jsx("dl", { "data-ui": "record-card.fields", className: "flex min-w-0 flex-col gap-0.5 text-meta", children: fields.map((one) => (_jsxs("div", { className: "flex min-w-0 items-baseline justify-between gap-3", children: [_jsx("dt", { className: "shrink-0 text-muted", children: one.label }), _jsx("dd", { className: "min-w-0 truncate text-right text-ink tabular-nums", children: one.value })] }, one.label))) }));
49
+ const sub = subtitle === undefined ? null : (
50
+ /* Above the stretched title, at its own width: the subtitle may be a link to ANOTHER
51
+ record (the customer), which must open that one and not the card. */
52
+ _jsx("p", { className: "relative z-10 w-fit max-w-full min-w-0 truncate text-meta text-muted", children: subtitle }));
53
+ const quiet = meta === undefined ? null : (_jsx("p", { className: "min-w-0 truncate text-micro tabular-nums text-muted", children: meta }));
54
+ const foot = footer === undefined ? null : (_jsx("div", { "data-ui": "record-card.footer", className: "relative z-10 flex min-w-0 items-center gap-1.5", children: footer }));
55
+ if (layout === "tile") {
56
+ /* The tile is pressed whole and its picture is the first thing read: on a till the hand
57
+ goes to the photo, not to the name. Without a picture, the icon on a tinted square
58
+ keeps the grid even. */
59
+ const Icon = media?.icon;
60
+ return (_jsxs("div", { "data-ui": "record-card", "data-layout": "tile", ...(selected ? { "data-selected": "" } : {}), ...(disabled ? { "data-disabled": "" } : {}), className: shell, children: [stripe, corner, _jsx("div", { "data-ui": "record-card.media", className: `flex aspect-tile w-full items-center justify-center overflow-hidden rounded-t-ui-record-card bg-ink/5 text-muted ${disabled ? "opacity-40 grayscale" : ""}`, children: media?.src !== undefined ? (_jsx("img", { src: media.src, alt: media.alt ?? "", loading: "lazy", className: "size-full object-cover" })) : Icon === undefined ? null : (_jsx(Icon, { "aria-hidden": true, className: "size-8", strokeWidth: 1.5 })) }), _jsxs("div", { className: `flex min-w-0 flex-1 flex-col ${byDensity(density, "gap-1 p-3", "gap-0.5 p-2")}`, children: [tags === undefined ? null : _jsx("div", { className: "flex flex-wrap gap-1", children: tags }), name, sub, _jsxs("div", { className: "mt-auto flex min-w-0 items-baseline justify-between gap-2 pt-1", children: [figure === undefined ? null : (_jsx("p", { "data-ui": "record-card.figure", className: "shrink-0 text-lead font-semibold tabular-nums text-ink", children: figure })), quiet] }), timer, foot] })] }));
61
+ }
62
+ const picture = media === undefined ? null : media.person === true ? (
63
+ /* The name is written right beside it: the photo's `alt` would say it twice. */
64
+ _jsx("span", { "aria-hidden": true, className: "flex shrink-0", children: _jsx(Avatar, { name: media.alt ?? (typeof title === "string" ? title : ""), size: layout === "compact" ? "md" : "lg", ...(media.src === undefined ? {} : { src: media.src }) }) })) : (_jsx(Thumb, { size: layout === "compact" ? "md" : "lg", ...(media.src === undefined ? {} : { src: media.src }), ...(media.alt === undefined ? {} : { alt: media.alt }), ...(media.icon === undefined ? {} : { icon: media.icon }) }));
65
+ const head = (_jsxs("div", { className: "flex min-w-0 items-start justify-between gap-3", children: [name, figure === undefined && timer === null ? null : (_jsxs("div", { className: "flex shrink-0 flex-col items-end gap-0.5", children: [timer, figure === undefined ? null : (_jsx("p", { "data-ui": "record-card.figure", className: `font-semibold tabular-nums text-ink ${layout === "compact" ? "text-body" : "text-lead"}`, children: figure }))] }))] }));
66
+ return (_jsxs("div", { "data-ui": "record-card", "data-layout": layout, ...(selected ? { "data-selected": "" } : {}), ...(disabled ? { "data-disabled": "" } : {}), className: `${shell} ${layout === "compact"
67
+ ? byDensity(density, "gap-0.5 px-3 py-2", "gap-0.5 px-2 py-1.5")
68
+ : byDensity(density, "gap-1.5 p-3", "gap-1 p-2.5")}`, children: [stripe, corner, layout === "compact" || tags === undefined ? null : (
69
+ /* In a row of their own and at their own width: as a flex child of the card a tag
70
+ stretched to the card's width. */
71
+ _jsx("div", { className: "flex flex-wrap gap-1", children: tags })), _jsxs("div", { className: "flex min-w-0 items-start gap-3", children: [picture, _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [head, sub] })] }), layout === "compact" ? null : factList, quiet, foot] }));
31
72
  }
@@ -68,13 +68,16 @@ export function Row({ icon: Icon, avatar, name, onOpen, onPeek, click = "peek",
68
68
  just the same by clicking anywhere on the row, not only on the
69
69
  name. With the preview turned off (`PeekLayer.tsx`) this is today the
70
70
  case for everyone: a click on the row opens, plain and simple. */
71
- onClick: click === "open" ? (onOpen ?? onPeek) : (onPeek ?? onOpen), role: "presentation", children: [onSelectedChange === undefined ? null : (_jsx("input", { type: "checkbox", checked: selected ?? false, "aria-label": fillCopy(copy.selection.named, { name }), onChange: (e) => onSelectedChange(e.target.checked), onClick: (e) => e.stopPropagation(), className: "size-3.5 shrink-0 cursor-pointer accent-primary" })), avatar !== undefined ? (_jsx(Avatar, { name: avatar.name, size: "sm", ...(avatar.src === undefined ? {} : { src: avatar.src }) })) : Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 1.75, "aria-hidden": true })), _jsx("div", { className: "@container/row min-w-0 grow", children: _jsxs("div", { className: `flex min-w-0 items-center gap-y-1 @max-row-split/row:flex-wrap ${byDensity(d, "gap-x-3", "gap-x-2")}`, children: [_jsxs("span", { "data-slot": "row-text", className: "flex min-w-0 shrink grow basis-(--container-name) flex-col @row-split/row:max-w-(--container-row-text)", children: [_jsx(RecordLink, { ...((onOpen ?? onPeek) === undefined
71
+ onClick: click === "open" ? (onOpen ?? onPeek) : (onPeek ?? onOpen), role: "presentation", children: [onSelectedChange === undefined ? null : (
72
+ /* Drawn small, answering to `--size-target` (44px under a finger) — and a tap on
73
+ the target chooses the row, it never opens it. */
74
+ _jsx("label", { className: "hit-target inline-flex shrink-0 cursor-pointer", onClick: (e) => e.stopPropagation(), children: _jsx("input", { type: "checkbox", checked: selected ?? false, "aria-label": fillCopy(copy.selection.named, { name }), onChange: (e) => onSelectedChange(e.target.checked), onClick: (e) => e.stopPropagation(), className: "size-3.5 shrink-0 cursor-pointer accent-primary touch:size-5" }) })), avatar !== undefined ? (_jsx(Avatar, { name: avatar.name, size: "sm", ...(avatar.src === undefined ? {} : { src: avatar.src }) })) : Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 1.75, "aria-hidden": true })), _jsx("div", { className: "@container/row min-w-0 grow", children: _jsxs("div", { className: `flex min-w-0 items-center gap-y-1 @max-row-split/row:flex-wrap ${byDensity(d, "gap-x-3", "gap-x-2")}`, children: [_jsxs("span", { "data-slot": "row-text", className: "flex min-w-0 shrink grow basis-(--container-name) flex-col @row-split/row:max-w-(--container-row-text)", children: [_jsx(RecordLink, { ...((onOpen ?? onPeek) === undefined
72
75
  ? {}
73
76
  : { onClick: (onOpen ?? onPeek) }), title: name, children: name }), meta === undefined ? null : (
74
77
  /* It truncates instead of wrapping into itself: three lines per row in a
75
78
  480 px drawer means three rows fit on screen. In mono figures: under the
76
79
  name, row after row, the dates and amounts line up. */
77
- _jsx("span", { className: "min-w-0 truncate text-micro tabular-nums text-muted", children: meta }))] }), tags === undefined ? null : (_jsx("span", { "data-slot": "row-tags", className: "flex min-w-fit shrink-0 basis-(--container-tags) flex-wrap items-center gap-1.5 @max-row-split/row:basis-full", children: tags }))] }) }), _jsx("span", { className: "flex shrink-0 items-center gap-1 opacity-0 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100", children: _jsx(Trail, { name: name, openAs: openAs, ...(actions === undefined ? {} : { actions }), copy: copyAs, ...(onPeek === undefined || !openers ? {} : { onPeek }), ...(onOpen === undefined || !openers ? {} : { onOpen }), ...(more === undefined ? {} : { more }), ...(onMoreSelect === undefined ? {} : { onMoreSelect }) }) })] }) }));
80
+ _jsx("span", { className: "min-w-0 truncate text-micro tabular-nums text-muted", children: meta }))] }), tags === undefined ? null : (_jsx("span", { "data-slot": "row-tags", className: "flex min-w-fit shrink-0 basis-(--container-tags) flex-wrap items-center gap-1.5 @max-row-split/row:basis-full", children: tags }))] }) }), _jsx("span", { className: "flex shrink-0 items-center gap-1 opacity-0 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 focus-within:opacity-100 touch:opacity-100", children: _jsx(Trail, { name: name, openAs: openAs, ...(actions === undefined ? {} : { actions }), copy: copyAs, ...(onPeek === undefined || !openers ? {} : { onPeek }), ...(onOpen === undefined || !openers ? {} : { onOpen }), ...(more === undefined ? {} : { more }), ...(onMoreSelect === undefined ? {} : { onMoreSelect }) }) })] }) }));
78
81
  if (children === undefined)
79
82
  return row;
80
83
  /* What the resource produced, hanging below. The indent reaches up to where
@@ -0,0 +1,2 @@
1
+ /** `key` opened if it was closed, closed if it was open. */
2
+ export declare function toggleCollapsed(collapsed: readonly string[], key: string): string[];
@@ -0,0 +1,8 @@
1
+ /* Without `"use client"`, apart from `useTreeControl` (`tree.ts`): the closed branches of a set
2
+ are a list of pile paths, and opening or closing one is a plain function. */
3
+ /** `key` opened if it was closed, closed if it was open. */
4
+ export function toggleCollapsed(collapsed, key) {
5
+ return collapsed.includes(key)
6
+ ? collapsed.filter((one) => one !== key)
7
+ : [...collapsed, key];
8
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Which columns of a set are on screen, as plain rules: the spec (required or optional,
3
+ * hidden at first), the default set, a toggle, the set reconciled. `useColumnControl`
4
+ * (`columns.ts`) keeps them in state; these live apart and without `"use client"`, so a server
5
+ * component — the page that reads the person's columns from a cookie — computes the same set.
6
+ */
7
+ export type ColumnSpec = {
8
+ id: string;
9
+ label: string;
10
+ /** When true, the column may leave the view. Required columns stay, and
11
+ * the submenu shows them checked and disabled so the split is visible. */
12
+ optional?: boolean;
13
+ /** Odoo `optional="hide"`: start off. Only for optional columns. */
14
+ defaultHidden?: boolean;
15
+ };
16
+ export declare function isRequiredColumn(column: ColumnSpec): boolean;
17
+ export declare function defaultVisibleIds(columns: readonly ColumnSpec[]): string[];
18
+ /**
19
+ * Required columns always stay. Unknown ids drop out. If everything optional
20
+ * was unchecked, the first column remains — a table with zero columns is not
21
+ * a table.
22
+ */
23
+ export declare function reconcileVisible(columns: readonly ColumnSpec[], visibleIds: readonly string[]): string[];
24
+ export declare function toggleColumn(columns: readonly ColumnSpec[], visibleIds: readonly string[], id: string): string[];
25
+ export declare function visibleColumns<T extends {
26
+ id: string;
27
+ }>(columns: readonly T[], visibleIds: readonly string[]): T[];
28
+ /** A table's columns as specs: `header` is the label, `optional` falls back to the table's. */
29
+ export declare function specsFromColumns(columns: readonly {
30
+ id: string;
31
+ header: string;
32
+ optional?: boolean;
33
+ defaultHidden?: boolean;
34
+ }[], fallbackOptional: boolean): ColumnSpec[];
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Which columns of a set are on screen, as plain rules: the spec (required or optional,
3
+ * hidden at first), the default set, a toggle, the set reconciled. `useColumnControl`
4
+ * (`columns.ts`) keeps them in state; these live apart and without `"use client"`, so a server
5
+ * component — the page that reads the person's columns from a cookie — computes the same set.
6
+ */
7
+ export function isRequiredColumn(column) {
8
+ return column.optional !== true;
9
+ }
10
+ export function defaultVisibleIds(columns) {
11
+ return columns
12
+ .filter((column) => isRequiredColumn(column) || column.defaultHidden !== true)
13
+ .map((column) => column.id);
14
+ }
15
+ /**
16
+ * Required columns always stay. Unknown ids drop out. If everything optional
17
+ * was unchecked, the first column remains — a table with zero columns is not
18
+ * a table.
19
+ */
20
+ export function reconcileVisible(columns, visibleIds) {
21
+ if (columns.length === 0)
22
+ return [];
23
+ const known = new Set(columns.map((column) => column.id));
24
+ const visible = new Set(visibleIds.filter((id) => known.has(id)));
25
+ for (const column of columns) {
26
+ if (isRequiredColumn(column))
27
+ visible.add(column.id);
28
+ }
29
+ if (visible.size === 0)
30
+ visible.add(columns[0].id);
31
+ return columns.filter((column) => visible.has(column.id)).map((column) => column.id);
32
+ }
33
+ export function toggleColumn(columns, visibleIds, id) {
34
+ const column = columns.find((one) => one.id === id);
35
+ if (column === undefined || isRequiredColumn(column)) {
36
+ return reconcileVisible(columns, visibleIds);
37
+ }
38
+ const current = reconcileVisible(columns, visibleIds);
39
+ const next = current.includes(id) ? current.filter((one) => one !== id) : [...current, id];
40
+ return reconcileVisible(columns, next);
41
+ }
42
+ export function visibleColumns(columns, visibleIds) {
43
+ const wanted = new Set(visibleIds);
44
+ return columns.filter((column) => wanted.has(column.id));
45
+ }
46
+ /** A table's columns as specs: `header` is the label, `optional` falls back to the table's. */
47
+ export function specsFromColumns(columns, fallbackOptional) {
48
+ return columns.map((column) => ({
49
+ id: column.id,
50
+ label: column.header,
51
+ optional: column.optional ?? fallbackOptional,
52
+ ...(column.defaultHidden === true ? { defaultHidden: true } : {}),
53
+ }));
54
+ }
@@ -1,3 +1,4 @@
1
+ import { type ColumnSpec, defaultVisibleIds, isRequiredColumn, reconcileVisible, toggleColumn, visibleColumns } from "./columnSpecs.js";
1
2
  /**
2
3
  * Which FIELDS of a set are on screen.
3
4
  *
@@ -11,15 +12,6 @@
11
12
  * and `useSelection` (which rows). Presentation can change; the visible
12
13
  * field set stays.
13
14
  */
14
- export type ColumnSpec = {
15
- id: string;
16
- label: string;
17
- /** When true, the column may leave the view. Required columns stay, and
18
- * the submenu shows them checked and disabled so the split is visible. */
19
- optional?: boolean;
20
- /** Odoo `optional="hide"`: start off. Only for optional columns. */
21
- defaultHidden?: boolean;
22
- };
23
15
  export type ColumnControl = {
24
16
  visibleIds: readonly string[];
25
17
  isVisible: (id: string) => boolean;
@@ -29,18 +21,8 @@ export type ColumnControl = {
29
21
  required: readonly ColumnSpec[];
30
22
  hasOptional: boolean;
31
23
  };
32
- export declare function isRequiredColumn(column: ColumnSpec): boolean;
33
- export declare function defaultVisibleIds(columns: readonly ColumnSpec[]): string[];
34
- /**
35
- * Required columns always stay. Unknown ids drop out. If everything optional
36
- * was unchecked, the first column remains — a table with zero columns is not
37
- * a table.
38
- */
39
- export declare function reconcileVisible(columns: readonly ColumnSpec[], visibleIds: readonly string[]): string[];
40
- export declare function toggleColumn(columns: readonly ColumnSpec[], visibleIds: readonly string[], id: string): string[];
41
- export declare function visibleColumns<T extends {
42
- id: string;
43
- }>(columns: readonly T[], visibleIds: readonly string[]): T[];
24
+ export type { ColumnSpec };
25
+ export { defaultVisibleIds, isRequiredColumn, reconcileVisible, toggleColumn, visibleColumns, };
44
26
  export declare function useColumnControl(columns: readonly ColumnSpec[], options?: {
45
27
  visibleIds?: readonly string[];
46
28
  onVisibleIdsChange?: (ids: readonly string[]) => void;
@@ -1,44 +1,7 @@
1
1
  "use client";
2
+ import { defaultVisibleIds, isRequiredColumn, reconcileVisible, toggleColumn, visibleColumns, } from "./columnSpecs.js";
2
3
  import { useCallback, useState } from "react";
3
- export function isRequiredColumn(column) {
4
- return column.optional !== true;
5
- }
6
- export function defaultVisibleIds(columns) {
7
- return columns
8
- .filter((column) => isRequiredColumn(column) || column.defaultHidden !== true)
9
- .map((column) => column.id);
10
- }
11
- /**
12
- * Required columns always stay. Unknown ids drop out. If everything optional
13
- * was unchecked, the first column remains — a table with zero columns is not
14
- * a table.
15
- */
16
- export function reconcileVisible(columns, visibleIds) {
17
- if (columns.length === 0)
18
- return [];
19
- const known = new Set(columns.map((column) => column.id));
20
- const visible = new Set(visibleIds.filter((id) => known.has(id)));
21
- for (const column of columns) {
22
- if (isRequiredColumn(column))
23
- visible.add(column.id);
24
- }
25
- if (visible.size === 0)
26
- visible.add(columns[0].id);
27
- return columns.filter((column) => visible.has(column.id)).map((column) => column.id);
28
- }
29
- export function toggleColumn(columns, visibleIds, id) {
30
- const column = columns.find((one) => one.id === id);
31
- if (column === undefined || isRequiredColumn(column)) {
32
- return reconcileVisible(columns, visibleIds);
33
- }
34
- const current = reconcileVisible(columns, visibleIds);
35
- const next = current.includes(id) ? current.filter((one) => one !== id) : [...current, id];
36
- return reconcileVisible(columns, next);
37
- }
38
- export function visibleColumns(columns, visibleIds) {
39
- const wanted = new Set(visibleIds);
40
- return columns.filter((column) => wanted.has(column.id));
41
- }
4
+ export { defaultVisibleIds, isRequiredColumn, reconcileVisible, toggleColumn, visibleColumns, };
42
5
  export function useColumnControl(columns, options = {}) {
43
6
  const signature = columns.map((column) => column.id).join("\0");
44
7
  const [owned, setOwned] = useState(() => defaultVisibleIds(columns));
@@ -1,22 +1,26 @@
1
- export { type ColumnControl, type ColumnSpec, defaultVisibleIds, reconcileVisible, toggleColumn, useColumnControl, visibleColumns, } from "./columns.js";
2
- export { ColumnsMenu, specsFromColumns, } from "./ColumnsMenu.js";
1
+ export { toggleCollapsed } from "./collapsed.js";
2
+ export { type ColumnControl, useColumnControl, } from "./columns.js";
3
+ export { ColumnsMenu } from "./ColumnsMenu.js";
4
+ export { type ColumnSpec, defaultVisibleIds, reconcileVisible, specsFromColumns, toggleColumn, visibleColumns, } from "./columnSpecs.js";
3
5
  export { Listing } from "./Listing.js";
4
- export { type ListIdentity, ListingBar } from "./ListingBar.js";
6
+ export { type ListCounter, type ListIdentity, ListingBar, } from "./ListingBar.js";
5
7
  export { type ModelCellKind } from "./modelCells.js";
6
8
  export { type ClaimedField, claimedFields, columnsFromModel, modelCellKind, readModelValue, } from "./modelColumns.js";
7
- export { type CursorSource, DEFAULT_PAGE_SIZE, PAGE_SIZES, type Pages, type PaginationBridge, type ServerPage, useCursorPagination, usePagination, } from "./pages.js";
9
+ export { type CursorSource, type Pages, type PaginationBridge, type ServerPage, useCursorPagination, usePagination, } from "./pages.js";
10
+ export { DEFAULT_PAGE_SIZE, PAGE_SIZES } from "./pageSizes.js";
8
11
  export { Pagination } from "./Pagination.js";
9
12
  export { RecordLink } from "./RecordLink.js";
10
13
  export { GroupHeader, Row } from "./Row.js";
11
14
  export { type Selection, useSelection } from "./selection.js";
12
15
  export { type SetControl, useSetControl } from "./set.js";
13
- export { toggleCollapsed, type TreeControl, useTreeControl, } from "./tree.js";
16
+ export { type TreeControl, useTreeControl } from "./tree.js";
14
17
  export { type ViewIcon, type ViewOption, ViewSwitcher, } from "./ViewSwitcher.js";
15
- export { AxisLevels, levelId, levelLabeler, } from "./AxisLevels.js";
18
+ export { AxisLevels } from "./AxisLevels.js";
16
19
  export { type BoardColumn, BoardColumns, type BoardStages, } from "./BoardColumns.js";
17
20
  export { type ChartComparison, ChartExplorer, type ChartExplorerProps, } from "./ChartExplorer.js";
18
21
  export { type GroupingControl, useGroupingControl, } from "./grouping.js";
19
22
  export { GroupingLevels, type GroupingLevelsProps, } from "./GroupingLevels.js";
23
+ export { levelId, levelLabeler } from "./levels.js";
20
24
  export { PivotExplorer, type PivotExplorerProps, } from "./PivotExplorer.js";
21
- export { RecordCard } from "./RecordCard.js";
25
+ export { RecordCard, type RecordCardField, type RecordCardLayout, } from "./RecordCard.js";
22
26
  export { type SortField, SortMenu, type SortMenuProps, } from "./SortMenu.js";