@mistriwork/kit 1.0.0-rc.17 → 1.0.0-rc.18

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 (99) hide show
  1. package/dist/client/components/AppList.js +16 -6
  2. package/dist/client/components/Chart.css +5 -0
  3. package/dist/client/components/Chart.d.ts +17 -2
  4. package/dist/client/components/Chart.js +83 -22
  5. package/dist/client/components/ChartFigure.d.ts +3 -1
  6. package/dist/client/components/ChartFigure.js +14 -8
  7. package/dist/client/components/Content.js +3 -1
  8. package/dist/client/components/DashHead.d.ts +6 -0
  9. package/dist/client/components/DashHead.js +20 -0
  10. package/dist/client/components/Editable.js +1 -1
  11. package/dist/client/components/Grid.js +33 -4
  12. package/dist/client/components/JsonPreview.css +29 -0
  13. package/dist/client/components/JsonPreview.js +1 -1
  14. package/dist/client/components/JsonView.css +201 -62
  15. package/dist/client/components/JsonView.d.ts +43 -1
  16. package/dist/client/components/JsonView.js +320 -55
  17. package/dist/client/components/LayoutSwitch.d.ts +9 -0
  18. package/dist/client/components/LayoutSwitch.js +61 -0
  19. package/dist/client/components/ListEmpty.css +3 -0
  20. package/dist/client/components/LiveNotices.css +3 -0
  21. package/dist/client/components/NewRecord.d.ts +0 -2
  22. package/dist/client/components/NewRecord.js +61 -17
  23. package/dist/client/components/PageFields.js +22 -3
  24. package/dist/client/components/PageHead.js +26 -6
  25. package/dist/client/components/PageRelated.d.ts +28 -0
  26. package/dist/client/components/PageRelated.js +50 -3
  27. package/dist/client/components/PageSectionBox.d.ts +5 -1
  28. package/dist/client/components/PageSectionBox.js +5 -3
  29. package/dist/client/components/PageSections.js +26 -13
  30. package/dist/client/components/PageSkeleton.css +2 -0
  31. package/dist/client/components/PageSkeleton.js +11 -3
  32. package/dist/client/components/Palette.js +108 -10
  33. package/dist/client/components/RecordPicker.d.ts +2 -0
  34. package/dist/client/components/RecordPicker.js +34 -8
  35. package/dist/client/components/RecordSummaries.js +6 -1
  36. package/dist/client/components/Rooms.js +2 -2
  37. package/dist/client/components/TableRoom.js +15 -5
  38. package/dist/client/components/TableView.d.ts +2 -0
  39. package/dist/client/components/Value.js +1 -1
  40. package/dist/client/components/appListModel.d.ts +4 -0
  41. package/dist/client/components/appRooms.d.ts +2 -0
  42. package/dist/client/components/appRooms.js +2 -0
  43. package/dist/client/components/dashboardModel.d.ts +5 -0
  44. package/dist/client/components/directoryModel.d.ts +25 -0
  45. package/dist/client/components/directoryModel.js +88 -0
  46. package/dist/client/components/gridSizing.d.ts +3 -0
  47. package/dist/client/components/gridSizing.js +6 -2
  48. package/dist/client/components/jsonTree.d.ts +54 -0
  49. package/dist/client/components/jsonTree.js +190 -0
  50. package/dist/client/components/listSubtitles.d.ts +1 -0
  51. package/dist/client/components/listSubtitles.js +7 -0
  52. package/dist/client/components/newMenuModel.d.ts +14 -6
  53. package/dist/client/components/newMenuModel.js +37 -5
  54. package/dist/client/components/newRecordModel.d.ts +24 -2
  55. package/dist/client/components/newRecordModel.js +47 -4
  56. package/dist/client/components/pageContext.d.ts +2 -0
  57. package/dist/client/components/pageModel.d.ts +2 -0
  58. package/dist/client/components/sidebarModel.js +7 -3
  59. package/dist/client/composedReads.js +3 -1
  60. package/dist/client/copy/lists/components/AppList.d.ts +1 -0
  61. package/dist/client/copy/lists/components/AppList.js +1 -0
  62. package/dist/client/copy/lists/components/LayoutSwitch.d.ts +4 -0
  63. package/dist/client/copy/lists/components/LayoutSwitch.js +6 -0
  64. package/dist/client/copy/record/components/JsonView.d.ts +22 -0
  65. package/dist/client/copy/record/components/JsonView.js +19 -0
  66. package/dist/client/copy/record/components/PageHead.d.ts +1 -0
  67. package/dist/client/copy/record/components/PageHead.js +2 -0
  68. package/dist/client/copy/shell/components/Palette.d.ts +11 -0
  69. package/dist/client/copy/shell/components/Palette.js +14 -0
  70. package/dist/client/copy/shell/components/TopNav.d.ts +2 -1
  71. package/dist/client/copy/shell/components/TopNav.js +4 -2
  72. package/dist/client/copy/shell/components/directoryModel.d.ts +4 -0
  73. package/dist/client/copy/shell/components/directoryModel.js +6 -0
  74. package/dist/client/copy/shell/components/sidebarModel.d.ts +1 -0
  75. package/dist/client/copy/shell/components/sidebarModel.js +1 -0
  76. package/dist/client/core.d.ts +3 -3
  77. package/dist/client/core.js +6 -7
  78. package/dist/client/features.css +67 -7
  79. package/dist/client/index.html +2 -1
  80. package/dist/client/insert.js +1 -8
  81. package/dist/client/locale.d.ts +7 -0
  82. package/dist/client/locale.js +0 -0
  83. package/dist/client/lumenLook.css +9 -12
  84. package/dist/client/page.css +56 -15
  85. package/dist/client/palette.d.ts +3 -1
  86. package/dist/client/palette.js +19 -4
  87. package/dist/client/paletteRecents.d.ts +25 -0
  88. package/dist/client/paletteRecents.js +64 -0
  89. package/dist/client/partsLook.css +6 -3
  90. package/dist/client/sageLook.css +5 -3
  91. package/dist/client/shellMode.d.ts +2 -0
  92. package/dist/client/shellMode.js +1 -0
  93. package/dist/client/structure.css +201 -1
  94. package/dist/client/style.css +59 -10
  95. package/dist/client/themeFamilies.css +37 -0
  96. package/dist/client/visualThemes.css +12 -0
  97. package/dist/client/workbenchLook.css +415 -0
  98. package/dist/client/workshopLook.css +48 -25
  99. package/package.json +4 -3
@@ -46,6 +46,8 @@ import { appListQuery, litTabFor, residueOf, searchColumn, shownTabs, visibleQue
46
46
  import { boxTail, boxesFor } from './FilterBoxes.js';
47
47
  import { onDemand } from './onDemand.js';
48
48
  import { useGridGroups } from './useGridGroups.js';
49
+ import { ListSubtitles } from './listSubtitles.js';
50
+ import { LayoutSwitch, useListLayout } from './LayoutSwitch.js';
49
51
  const DefinedBoxes = onDemand(() => import('./DefinedFields.js'), 'DefinedBoxes', { quiet: true });
50
52
  /* A list's single `per` value (`category_id = 3`), which picks the fields a row-defined column's boxes are. */
51
53
  function oneValue(tail) {
@@ -151,6 +153,11 @@ function TabCount({ counted }) {
151
153
  export function AppList({ entry, spec, navigate, embedded = false, newButton, inDashboard = false, onTotal }) {
152
154
  useMessageLanguage();
153
155
  const caption = spec.label;
156
+ /* A list whose machine has a handful of open states may be read as a board too (listInference.ts): the reader's
157
+ choice, kept in their browser per view, as a board's folds are. */
158
+ const boardable = Boolean(spec.asBoard && !spec.presentation && !embedded && !inDashboard);
159
+ const [layout, setLayout] = useListLayout(spec.id, boardable);
160
+ const presented = boardable && layout === 'board' ? spec.asBoard : spec.presentation;
154
161
  const client = useQueryClient();
155
162
  const table = findTable(entry.table);
156
163
  const tabs = shownTabs(spec);
@@ -289,7 +296,8 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
289
296
  const isDefault = canonicalize(entry.query) === canonicalize(appListQuery(spec, 0));
290
297
  const exactTab = litTab >= 0 && canonicalize(refinement) === canonicalize(tabs[litTab].query ?? '');
291
298
  const offerSave = savable && !(isDefault || exactTab || yourLit >= 0 || !refinement);
292
- const gridTab = tabs.findIndex((_, i) => squeeze(appListQuery(spec, i)) === squeeze(entry.query));
299
+ /* A board reads no total (TableRoom.tsx): its tab's badge is counted with the others. */
300
+ const gridTab = presented?.kind === 'board' ? -1 : tabs.findIndex((_, i) => squeeze(appListQuery(spec, i)) === squeeze(entry.query));
293
301
  /* The badges not already on screen: the grid's own total answers the tab
294
302
  it shows, so that one is never asked twice (and a list whose grid is
295
303
  still loading does not ask again once it lands). */
@@ -422,6 +430,7 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
422
430
  ...(recordLabel(table) && labelPath(table) ? [labelPath(table)] : []),
423
431
  ...(spec.order ? [spec.order] : []),
424
432
  ...subtitleColumns(entry.table, [...chosen]),
433
+ ...[...chosen].flatMap((name) => (spec.subtitles && Object.hasOwn(spec.subtitles, name) ? [spec.subtitles[name]] : [])),
425
434
  ...editedReferences(spec),
426
435
  ...(spec.opens ? [spec.opens] : []),
427
436
  ...(spec.group ? [spec.group] : []),
@@ -461,7 +470,7 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
461
470
  : undefined;
462
471
  /* A grouped grid's heads: one breakdown over what the conditions match, never a read per group (useGridGroups.ts). */
463
472
  const gridGroup = useGridGroups({
464
- column: spec.presentation ? undefined : spec.group,
473
+ column: presented ? undefined : spec.group,
465
474
  table,
466
475
  query: entry.query,
467
476
  totals: spec.totals,
@@ -631,14 +640,15 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
631
640
  void client.invalidateQueries({
632
641
  queryKey: ['count', connection ?? ''],
633
642
  });
634
- } }) })), _jsx(BoardNewForm.Provider, { value: offersNew ? (spec.form ?? {}) : null, children: _jsx(RowOpensContext.Provider, { value: rowOpens, children: _jsx(TableRoom, { entry: gridEntry, sizing: spec.sizing, chrome: false, summaries: true, inset: !inDashboard, embedded: inDashboard, hide: keptHide, referenceLabels: referenceLabels, totals: keptTotals, ...(gridGroup ? { group: gridGroup } : {}), density: spec.density,
635
- /* A ⋯ with nothing a reader may run is a dead control and a reserved column; the App payload already says what they may run. */
636
- rowActions: Boolean(spec.rowActions && !spec.presentation && !embedded && mayRunAny(shell().app(), entry.table, spec.actions ?? [])), editable: spec.presentation || embedded ? undefined : spec.editable, inCrumbs: inCrumbs, onResult: keptOnGrid, presentation: embedded ? undefined : spec.presentation, present: shell().present ?? undefined, empty: embedded ? undefined : narrowedPast ? (noMatches) : authoredEmpty ? (_jsx(ListEmpty, { spec: authoredEmpty })) : ((nothingYet ?? tabEmpty)), actions: embedded ? undefined : spec.actions, listLabel: caption, order: embedded ? undefined : spec.order, export: exportOff ? false : undefined, interactive: embedded ? false : undefined }) }) })] })), [
643
+ } }) })), _jsx(BoardNewForm.Provider, { value: offersNew ? (spec.form ?? {}) : null, children: _jsx(RowOpensContext.Provider, { value: rowOpens, children: _jsx(ListSubtitles.Provider, { value: spec.subtitles, children: _jsx(TableRoom, { entry: gridEntry, sizing: spec.sizing, chrome: false, summaries: true, inset: !inDashboard, embedded: inDashboard, hide: keptHide, referenceLabels: referenceLabels, totals: keptTotals, ...(gridGroup ? { group: gridGroup } : {}), density: spec.density,
644
+ /* A ⋯ with nothing a reader may run is a dead control and a reserved column; the App payload already says what they may run. */
645
+ rowActions: Boolean(spec.rowActions && !presented && !embedded && mayRunAny(shell().app(), entry.table, spec.actions ?? [])), editable: presented || embedded ? undefined : spec.editable, inCrumbs: inCrumbs, onResult: keptOnGrid, presentation: embedded ? undefined : presented, present: shell().present ?? undefined, empty: embedded ? undefined : narrowedPast ? (noMatches) : authoredEmpty ? (_jsx(ListEmpty, { spec: authoredEmpty })) : ((nothingYet ?? tabEmpty)), actions: embedded ? undefined : spec.actions, listLabel: caption, order: embedded ? undefined : spec.order, export: exportOff ? false : undefined, interactive: embedded ? false : undefined }) }) }) })] })), [
637
646
  gridPage,
638
647
  gridSize,
639
648
  embedded,
640
649
  inDashboard,
641
650
  spec,
651
+ presented,
642
652
  table,
643
653
  client,
644
654
  connection,
@@ -683,7 +693,7 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
683
693
  }, onSearch: () => form.current?.requestSubmit(), apply: apply, current: currentText, residue: residueChip, listLabel: caption, phone: phone, onSheet: () => setSheet(true) })), spec.sorts?.length && !beside ? (_jsx(SortMenu, { sorts: spec.sorts, sort: spec.sort, query: entry.query, onPick: (query) => {
684
694
  walk.page = 0;
685
695
  navigate(query);
686
- } })) : null, _jsxs("div", { className: "applist-actions", children: [railed && railNarrow && railProps && boxes.length > 0 && (_jsx("button", { type: "button", className: "applist-toggle", "aria-haspopup": "dialog", onClick: () => setSheet(true), children: narrowed ? say('common.filters', { narrowed }) : say('common.filtersButton') })), spec.advancedFilters === true && boxes.length > 0 && (_jsx("button", { type: "button", className: "applist-toggle", "aria-expanded": showAdvanced, onClick: () => {
696
+ } })) : null, _jsxs("div", { className: "applist-actions", children: [boardable && _jsx(LayoutSwitch, { layout: layout, onChange: setLayout, label: say('layout', { caption }) }), railed && railNarrow && railProps && boxes.length > 0 && (_jsx("button", { type: "button", className: "applist-toggle", "aria-haspopup": "dialog", onClick: () => setSheet(true), children: narrowed ? say('common.filters', { narrowed }) : say('common.filtersButton') })), spec.advancedFilters === true && boxes.length > 0 && (_jsx("button", { type: "button", className: "applist-toggle", "aria-expanded": showAdvanced, onClick: () => {
687
697
  setAdvanced(!showAdvanced);
688
698
  // Opening an inline editor must not scroll its toggle beneath
689
699
  // the sticky trail, leaving the same control impossible to close.
@@ -16,6 +16,11 @@
16
16
  /* Stacked columns: each series its token in every column; the current column is named by its tick and its pill, not by a tint. */
17
17
  .chart-columns { display: grid; gap: var(--space-3h); min-width: 0; }
18
18
  .chart-column-part { rx: 0; }
19
+ /* A column that drills: a door over its whole band (the hit rect is clear), the pointer saying it goes somewhere, and
20
+ while it holds the keyboard the house ring round the band, as a line's point widens its stroke. */
21
+ .chart-column-door { cursor: pointer; outline: none; }
22
+ .chart-column-hit { fill: transparent; }
23
+ .chart-column-door:focus-visible .chart-column-hit { stroke: var(--focus); stroke-width: 2px; vector-effect: non-scaling-stroke; }
19
24
  .chart-columns-legend { display: flex; flex-wrap: wrap; gap: var(--space-2h) 20px; max-width: none; }
20
25
  /* A trend is its change's news where the metric says which way is good: the
21
26
  green or red its delta is said in, never a colour by position. The wash
@@ -107,10 +107,12 @@ export declare function BarChart({ rows, say, label, wide, high, target, tone, }
107
107
  * legend, which says each series' total. Every column is also a row of a
108
108
  * table assistive technology reads. Nothing moves (motion rule 8).
109
109
  */
110
- export declare function StackedColumns({ rows, series, say, wide, high, }: {
110
+ export declare function StackedColumns({ rows, series, say, wide, high, paint, legend, target, onPick, }: {
111
+ /** `raw` is the key a column goes to when it drills; a gap-filled bucket (a period nothing happened in) holds none and is no door. */
111
112
  rows: Array<{
112
113
  key: string;
113
114
  values: Record<string, number>;
115
+ raw?: unknown;
114
116
  }>;
115
117
  series: Array<{
116
118
  key: string;
@@ -119,6 +121,13 @@ export declare function StackedColumns({ rows, series, say, wide, high, }: {
119
121
  say?: Say;
120
122
  wide?: number;
121
123
  high?: number;
124
+ /** A series' own paint where it is not the palette in order (a tone, a ramp step, a lighter share): its parts' style. */
125
+ paint?: (k: number) => React.CSSProperties;
126
+ /** The legend and its totals under the figure; off where the caller draws one over it. */
127
+ legend?: boolean;
128
+ target?: number;
129
+ /** A column as a way into its rows, by its raw key. */
130
+ onPick?: ((value: unknown) => void) | null;
122
131
  }): import("react").JSX.Element;
123
132
  /**
124
133
  * The house ring round a donut's slice (design.md, Access): a shape takes no outline, so the ring is the outline of
@@ -151,6 +160,8 @@ interface StackedRow {
151
160
  series: unknown;
152
161
  value: unknown;
153
162
  }
163
+ /** A stacked chart over periods is drawn at this height, as a bar chart's figure is: a fixed figure, so its room is held before its answer. */
164
+ export declare const TIMED_HEIGHT = 180;
154
165
  /**
155
166
  * Stacked bars: each group of the first key a bar, divided by the second —
156
167
  * how each of several wholes divides, where a donut says how one does. The
@@ -185,7 +196,11 @@ export declare function StackedBars({ rows, say, label, seriesLabel, target, lim
185
196
  * corner; the stroke and the last point's dot keep their own size however
186
197
  * far it stretches (`non-scaling-stroke`, and the dot is a round cap on a
187
198
  * zero-length stroke). Under four points there is no shape to read, so
188
- * there is no spark.
199
+ * there is no spark. Four points with fewer than four of them above zero are a
200
+ * line that is flat but for a spike or two, which reads as a fall to nothing
201
+ * and a climb back: those are thin bars (one per period, the empty ones left
202
+ * bare over a baseline), kept to a short width, and an all-zero run draws none.
203
+ * The card's change, said beside the figure, is the trend's news either way.
189
204
  */
190
205
  export declare function Sparkline({ rows, say }: {
191
206
  rows: ChartRow[];
@@ -507,10 +507,15 @@ export function BarChart({ rows, say = String, label = String, wide = 600, high,
507
507
  * legend, which says each series' total. Every column is also a row of a
508
508
  * table assistive technology reads. Nothing moves (motion rule 8).
509
509
  */
510
- export function StackedColumns({ rows, series, say = String, wide = 600, high, }) {
510
+ export function StackedColumns({ rows, series, say = String, wide = 600, high, paint, legend = true, target, onPick, }) {
511
511
  const columns = rows
512
- .map((r) => ({ key: r.key, parts: series.map((s) => Math.max(0, Number(r.values[s.key]) || 0)) }))
512
+ .map((r) => ({ key: r.key, raw: r.raw, parts: series.map((s) => Math.max(0, Number(r.values[s.key]) || 0)) }))
513
513
  .map((c) => ({ ...c, total: c.parts.reduce((n, v) => n + v, 0) }));
514
+ /* Roving tabindex for the columns that drill, as a line's points have: one tab stop for the figure, the arrows
515
+ between its doors, Home and End to its ends. */
516
+ const doors = columns.map((c, i) => (onPick && c.raw != null ? i : -1)).filter((i) => i >= 0);
517
+ const [roved, setRoved] = useState(null);
518
+ const tabbable = roved !== null && doors.includes(roved) ? roved : doors[0];
514
519
  const svg = useRef(null);
515
520
  const [near, setNear] = useState(null);
516
521
  const [pointer, setPointer] = useState(null);
@@ -531,8 +536,9 @@ export function StackedColumns({ rows, series, say = String, wide = 600, high, }
531
536
  const named = columns.map((c) => (periods ? periodTick(c.key) : c.key));
532
537
  const W = measured > 0 ? measured : wide;
533
538
  const H = high ? Math.max(120, Math.round(high)) : Math.max(160, Math.min(Math.round(W / 3.5), 220));
539
+ const goal = target !== undefined && Number.isFinite(target) && target > 0 ? target : undefined;
534
540
  const max = Math.max(...columns.map((c) => c.total), 1);
535
- const scale = niceScale(0, max, 2, say.tick?.steps);
541
+ const scale = niceScale(0, Math.max(max, goal ?? 0), 2, say.tick?.steps);
536
542
  const levels = scale.levels;
537
543
  const gutter = Math.max(...levels.map((v) => tickWidth(tickSay(say)(v)))) + 6;
538
544
  const PAD = { top: 30, right: 6, bottom: 24, left: gutter };
@@ -553,6 +559,10 @@ export function StackedColumns({ rows, series, say = String, wide = 600, high, }
553
559
  const top = y(columns[active].total);
554
560
  const tipTop = pointer ? Math.min(Math.max(2, pointer.y - 30), H - PAD.bottom - 22) : Math.max(2, top - 26);
555
561
  const color = (k) => `var(--chart-${k + 1}, var(--accent))`;
562
+ const moveRoving = (to) => {
563
+ setRoved(to);
564
+ svg.current?.querySelectorAll('.chart-column-door')[doors.indexOf(to)]?.focus?.();
565
+ };
556
566
  const at = (e) => {
557
567
  // screen-px: clientX is a screen-pixel ruler too; the ratio maps it into viewBox units.
558
568
  const box = svg.current.getBoundingClientRect();
@@ -563,24 +573,52 @@ export function StackedColumns({ rows, series, say = String, wide = 600, high, }
563
573
  setNear(Math.min(columns.length - 1, Math.max(0, Math.floor((px - PAD.left) / band))));
564
574
  };
565
575
  const totals = series.map((_, k) => columns.reduce((n, c) => n + c.parts[k], 0));
566
- return (_jsxs("div", { className: "chart-columns", children: [_jsxs("svg", { ref: svg, className: "chart-bars", viewBox: `0 0 ${W} ${H}`, role: "img", "aria-label": sayCopy('barsSummary', {
576
+ return (_jsxs("div", { className: "chart-columns", children: [_jsxs("svg", { ref: svg, className: "chart-bars", viewBox: `0 0 ${W} ${H}`,
577
+ /* A picture must not hold buttons (a line's points say why): where a column drills, the figure is a group. */
578
+ role: doors.length ? 'group' : 'img', "aria-label": `${sayCopy('barsSummary', {
567
579
  count: columns.length,
568
580
  highest: say(max),
569
581
  last: named[columns.length - 1],
570
582
  value: say(columns[columns.length - 1].total),
571
- }), onPointerMove: at, onPointerLeave: () => {
583
+ })}${goal === undefined ? '' : sayCopy('targetAfter', { goal: say(goal) })}`, onPointerMove: at, onPointerLeave: () => {
572
584
  setNear(null);
573
585
  setPointer(null);
574
586
  }, children: [levels.map((v) => (_jsx("line", { className: "chart-grid", x1: PAD.left, x2: W - PAD.right, y1: f1(y(v)), y2: f1(y(v)) }, `g${v}`))), levels.map((v) => (_jsx("text", { className: "chart-tick chart-y-tick", x: f1(PAD.left - 6), y: f1(y(v) + 4), textAnchor: "end", children: tickSay(say)(v) }, `t${v}`))), _jsx("line", { className: "chart-bar-guide", x1: PAD.left, x2: W - PAD.right, y1: f1(top), y2: f1(top) }), columns.map((c, i) => {
575
587
  let base = 0;
576
- return (_jsxs("g", { className: `chart-column${i === active ? ' is-active' : ''}`, children: [_jsx("title", { children: `${named[i]}: ${parts(i)}` }), c.parts.map((v, k) => {
588
+ const column = (_jsxs(_Fragment, { children: [_jsx("title", { children: `${named[i]}: ${parts(i)}` }), c.parts.map((v, k) => {
577
589
  const from = base;
578
590
  base += v;
579
591
  if (!v)
580
592
  return null;
581
- return (_jsx("rect", { className: "chart-column-part", x: f1(x(i)), y: f1(y(base)), width: f1(colWide), height: f1(Math.max(1, y(from) - y(base))), style: { fill: color(k) } }, k));
582
- })] }, c.key));
583
- }), marks.map(({ index, text }) => (_jsx("text", { className: `chart-tick chart-x-tick${index === active ? ' is-active' : ''}`, x: f1(markAt(index, text)), y: H - 6, textAnchor: "middle", children: text }, `m${index}`))), _jsxs("g", { className: "chart-bar-tip", "aria-hidden": "true", children: [_jsx("rect", { x: f1(tipLeft), y: f1(tipTop), width: f1(tipWide), height: 20 }), _jsx("text", { x: f1(tipLeft + tipWide / 2), y: f1(tipTop + 14), textAnchor: "middle", children: tip })] })] }), _jsx("ul", { className: "chart-legend chart-columns-legend", children: series.map((s, k) => (_jsxs("li", { children: [_jsx("span", { className: "chart-swatch", style: { background: color(k) } }), _jsx("span", { className: "chart-legend-key", children: s.label }), _jsx("span", { className: "chart-legend-value", children: say(totals[k]) })] }, s.key))) }), _jsx("div", { className: "visually-hidden", children: _jsx("table", { className: "chart-data", children: _jsx("tbody", { children: columns.map((c, i) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", children: named[i] }), _jsx("td", { children: parts(i) })] }, c.key))) }) }) })] }));
593
+ return (_jsx("rect", { className: "chart-column-part", x: f1(x(i)), y: f1(y(base)), width: f1(colWide), height: f1(Math.max(1, y(from) - y(base))), style: paint ? paint(k) : { fill: color(k) } }, k));
594
+ })] }));
595
+ const className = `chart-column${i === active ? ' is-active' : ''}`;
596
+ if (!(onPick && c.raw != null))
597
+ return (_jsx("g", { className: className, children: column }, c.key));
598
+ /* A column that goes somewhere is a door over its whole band, so a short column is as easy to find as a tall
599
+ one; its focus is the house ring round the band. */
600
+ return (_jsxs("g", { className: `${className} chart-column-door`, role: "button", tabIndex: i === tabbable ? 0 : -1, "aria-label": `${named[i]}: ${parts(i)}`, onClick: () => onPick(c.raw), onKeyDown: (event) => {
601
+ const key = event.key;
602
+ if (key === 'Enter' || key === ' ') {
603
+ event.preventDefault();
604
+ onPick(c.raw);
605
+ return;
606
+ }
607
+ const to = key === 'ArrowRight'
608
+ ? doors[doors.indexOf(i) + 1]
609
+ : key === 'ArrowLeft'
610
+ ? doors[doors.indexOf(i) - 1]
611
+ : key === 'Home'
612
+ ? doors[0]
613
+ : key === 'End'
614
+ ? doors[doors.length - 1]
615
+ : undefined;
616
+ if (to !== undefined) {
617
+ event.preventDefault();
618
+ moveRoving(to);
619
+ }
620
+ }, children: [column, _jsx("rect", { className: "chart-column-hit", x: f1(PAD.left + band * i), y: PAD.top, width: f1(band), height: f1(H - PAD.top - PAD.bottom) })] }, c.key));
621
+ }), goal !== undefined && (_jsxs("g", { className: "chart-target", children: [_jsx("line", { className: "chart-target-line", x1: PAD.left, x2: W - PAD.right, y1: f1(y(goal)), y2: f1(y(goal)) }), _jsx("text", { className: "chart-target-label", x: PAD.left + 4, y: f1(y(goal) - 4), children: sayCopy('target', { goal: say(goal) }) })] })), marks.map(({ index, text }) => (_jsx("text", { className: `chart-tick chart-x-tick${index === active ? ' is-active' : ''}`, x: f1(markAt(index, text)), y: H - 6, textAnchor: "middle", children: text }, `m${index}`))), _jsxs("g", { className: "chart-bar-tip", "aria-hidden": "true", children: [_jsx("rect", { x: f1(tipLeft), y: f1(tipTop), width: f1(tipWide), height: 20 }), _jsx("text", { x: f1(tipLeft + tipWide / 2), y: f1(tipTop + 14), textAnchor: "middle", children: tip })] })] }), legend && (_jsx("ul", { className: "chart-legend chart-columns-legend", children: series.map((s, k) => (_jsxs("li", { children: [_jsx("span", { className: "chart-swatch", style: { background: color(k) } }), _jsx("span", { className: "chart-legend-key", children: s.label }), _jsx("span", { className: "chart-legend-value", children: say(totals[k]) })] }, s.key))) })), _jsx("div", { className: "visually-hidden", children: _jsx("table", { className: "chart-data", children: _jsx("tbody", { children: columns.map((c, i) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", children: named[i] }), _jsx("td", { children: parts(i) })] }, c.key))) }) }) })] }));
584
622
  }
585
623
  /**
586
624
  * The house ring round a donut's slice (design.md, Access): a shape takes no outline, so the ring is the outline of
@@ -686,6 +724,8 @@ export const TONE_INK = {
686
724
  info: 'var(--status-info)',
687
725
  neutral: 'var(--ink-subtle)',
688
726
  };
727
+ /** A stacked chart over periods is drawn at this height, as a bar chart's figure is: a fixed figure, so its room is held before its answer. */
728
+ export const TIMED_HEIGHT = 180;
689
729
  /**
690
730
  * Stacked bars: each group of the first key a bar, divided by the second —
691
731
  * how each of several wholes divides, where a donut says how one does. The
@@ -755,24 +795,34 @@ export function StackedBars({ rows, say = String, label = String, seriesLabel =
755
795
  const sayTotal = sayLegend
756
796
  ? sayLegend([...series.map((s) => s.total), ...shown.map((bar) => bar.total), ...(goal === undefined ? [] : [goal])])
757
797
  : say;
758
- return (_jsxs("div", { className: "chart-stacked", children: [_jsxs("ul", { className: "chart-legend chart-stacked-legend", children: [series.map((s, i) => (_jsxs("li", { children: [_jsx("span", { className: "chart-swatch", style: { ...ramp(i), background: color(i), opacity: opacity(i) } }), _jsx("span", { className: "chart-legend-key", children: s.label }), _jsx("span", { className: "chart-legend-value", children: sayTotal(s.total) })] }, s.key))), goal !== undefined && (_jsxs("li", { className: "chart-stacked-goal", children: [_jsx("span", { className: "chart-target-swatch", "aria-hidden": "true" }), _jsx("span", { className: "chart-legend-key", children: sayCopy('targetLabel') }), _jsx("span", { className: "chart-legend-value", children: sayTotal(goal) })] }))] }), _jsx("ul", { className: "chart-stacked-rows", "aria-label": `${sayCopy('barsBySeries', { count: shown.length, series: series.map((s) => s.label).join(', ') })}${goal === undefined ? '' : sayCopy('targetAfter', { goal: say(goal) })}`, children: shown.map((bar, at) => {
798
+ /* A bar's share of one series, the tail's folded into "others". */
799
+ const partOf = (bar, s) => s.key === 'others'
800
+ ? [...bar.parts.entries()]
801
+ .filter(([key]) => slot(key) === series.length - 1 && !kept.some((k) => k.key === key))
802
+ .reduce((n, [, v]) => n + v, 0)
803
+ : (bar.parts.get(s.key) ?? 0);
804
+ const legend = (_jsxs("ul", { className: "chart-legend chart-stacked-legend", children: [series.map((s, i) => (_jsxs("li", { children: [_jsx("span", { className: "chart-swatch", style: { ...ramp(i), background: color(i), opacity: opacity(i) } }), _jsx("span", { className: "chart-legend-key", children: s.label }), _jsx("span", { className: "chart-legend-value", children: sayTotal(s.total) })] }, s.key))), goal !== undefined && (_jsxs("li", { className: "chart-stacked-goal", children: [_jsx("span", { className: "chart-target-swatch", "aria-hidden": "true" }), _jsx("span", { className: "chart-legend-key", children: sayCopy('targetLabel') }), _jsx("span", { className: "chart-legend-value", children: sayTotal(goal) })] }))] }));
805
+ /* Time runs across the page, as it does in every other chart of a period: a column a period, at the bars' own height
806
+ and axis, its empty periods at zero, under the legend the rows have. Rows are for categories, whose order is the
807
+ reader's to scan down. */
808
+ if (timed) {
809
+ const filled = fillGaps(shown.map((bar) => ({ key: String(bar.raw), value: bar.total, bar })));
810
+ return (_jsxs("div", { className: "chart-stacked chart-stacked-timed", children: [legend, _jsx(StackedColumns, { rows: filled.map(({ key, bar }) => ({
811
+ key,
812
+ raw: bar?.raw,
813
+ values: bar ? Object.fromEntries(series.map((s) => [s.key, partOf(bar, s)])) : {},
814
+ })), series: series, say: say, high: TIMED_HEIGHT, paint: (i) => ({ ...ramp(i), fill: color(i), opacity: opacity(i) }), legend: false, target: goal, onPick: onPick })] }));
815
+ }
816
+ return (_jsxs("div", { className: "chart-stacked", children: [legend, _jsx("ul", { className: "chart-stacked-rows", "aria-label": `${sayCopy('barsBySeries', { count: shown.length, series: series.map((s) => s.label).join(', ') })}${goal === undefined ? '' : sayCopy('targetAfter', { goal: say(goal) })}`, children: shown.map((bar, at) => {
759
817
  /* Each series in legend order, so a colour sits in the same place in every bar. */
760
- const parts = series
761
- .map((s, i) => ({
762
- s,
763
- i,
764
- value: s.key === 'others'
765
- ? [...bar.parts.entries()]
766
- .filter(([key]) => slot(key) === series.length - 1 && !kept.some((k) => k.key === key))
767
- .reduce((n, [, v]) => n + v, 0)
768
- : (bar.parts.get(s.key) ?? 0),
769
- }))
770
- .filter((part) => part.value > 0);
818
+ const parts = series.map((s, i) => ({ s, i, value: partOf(bar, s) })).filter((part) => part.value > 0);
771
819
  const words = (_jsxs(_Fragment, { children: [_jsx("span", { className: "chart-stacked-label", children: barLabel(bar, at) }), _jsxs("span", { className: "chart-stacked-track", children: [_jsx("span", { className: "chart-stacked-fill", style: { width: share(bar.total) }, children: parts.map(({ s, i, value }) => (_jsx("span", { className: "chart-stacked-part", title: `${s.label}: ${say(value)}`, style: { ...ramp(i), flexGrow: value, background: color(i), opacity: opacity(i) } }, s.key))) }), goal !== undefined && _jsx("span", { className: "chart-stacked-target", style: { left: share(goal) }, "aria-hidden": "true" })] }), _jsx("span", { className: "chart-stacked-total", children: sayTotal(bar.total) }), _jsx("span", { className: "visually-hidden", children: `: ${parts.map(({ s, value }) => `${s.label} ${say(value)}`).join(', ')}` })] }));
772
820
  /* A bar that goes somewhere is a button; a null group, or no drill, stays text. */
773
821
  return (_jsx("li", { children: onPick && bar.raw != null ? (_jsx("button", { type: "button", className: "chart-stacked-row chart-stacked-drill", onClick: () => onPick(bar.raw), children: words })) : (_jsx("div", { className: "chart-stacked-row", children: words })) }, name(bar.raw)));
774
822
  }) })] }));
775
823
  }
824
+ /** A spark needs this many periods above zero to be a line; fewer are bars (Sparkline). */
825
+ const SPARK_LEAST = 4;
776
826
  /**
777
827
  * A spark: the measure's shape inside a KPI card. No axes; the card's own
778
828
  * number is the label. It spans the card's width, stretched rather than
@@ -780,7 +830,11 @@ export function StackedBars({ rows, say = String, label = String, seriesLabel =
780
830
  * corner; the stroke and the last point's dot keep their own size however
781
831
  * far it stretches (`non-scaling-stroke`, and the dot is a round cap on a
782
832
  * zero-length stroke). Under four points there is no shape to read, so
783
- * there is no spark.
833
+ * there is no spark. Four points with fewer than four of them above zero are a
834
+ * line that is flat but for a spike or two, which reads as a fall to nothing
835
+ * and a climb back: those are thin bars (one per period, the empty ones left
836
+ * bare over a baseline), kept to a short width, and an all-zero run draws none.
837
+ * The card's change, said beside the figure, is the trend's news either way.
784
838
  */
785
839
  export function Sparkline({ rows, say = String }) {
786
840
  const points = rows
@@ -795,6 +849,13 @@ export function Sparkline({ rows, say = String }) {
795
849
  const span = max - min || 1;
796
850
  const x = (i) => 1 + (i * (W - 2)) / (points.length - 1);
797
851
  const y = (v) => 3 + (1 - (v - min) / span) * (H - 6);
852
+ const filled = points.filter((p) => p.value !== 0).length;
853
+ if (filled === 0)
854
+ return null;
855
+ if (filled < SPARK_LEAST) {
856
+ const base = y(0);
857
+ return (_jsxs("svg", { className: "spark spark-sparse", viewBox: `0 0 ${W} ${H}`, preserveAspectRatio: "none", role: "img", "aria-label": `trend: ${points.map((p) => say(p.value)).join(', ')}`, children: [_jsx("title", { children: `${points[0].key} → ${points[points.length - 1].key}` }), _jsx("path", { className: "spark-base", d: `M1,${f1(base)} H${W - 1}`, vectorEffect: "non-scaling-stroke" }), points.map((p, i) => p.value ? (_jsx("path", { className: "spark-bar", d: `M${f1(x(i))},${f1(base)} V${f1(y(p.value))}`, vectorEffect: "non-scaling-stroke" }, i)) : null)] }));
858
+ }
798
859
  const d = points.map((p, i) => `${i ? 'L' : 'M'}${f1(x(i))},${f1(y(p.value))}`).join(' ');
799
860
  const last = points[points.length - 1];
800
861
  return (_jsxs("svg", { className: "spark", viewBox: `0 0 ${W} ${H}`, preserveAspectRatio: "none", role: "img", "aria-label": `trend: ${points.map((p) => say(p.value)).join(', ')}`, children: [_jsx("title", { children: `${points[0].key} → ${last.key}` }), _jsx("path", { className: "spark-area", d: `${d} L${f1(x(points.length - 1))},${H} L${f1(x(0))},${H} Z` }), _jsx("path", { className: "spark-stroke", d: d, vectorEffect: "non-scaling-stroke" }), _jsx("path", { className: "spark-dot", d: `M${f1(x(points.length - 1))},${f1(y(last.value))} h0`, vectorEffect: "non-scaling-stroke" })] }));
@@ -56,8 +56,10 @@ interface ChartFigureProps {
56
56
  arrange?: 'answer' | 'value' | 'category';
57
57
  /** A line with too few filled buckets to draw a line through keeps its shape and stands its points alone. */
58
58
  dots?: boolean;
59
+ /** Stacked bars over periods stand as columns at a fixed height (Chart.tsx), which the room is held at before the answer. */
60
+ timed?: boolean;
59
61
  }
60
- export declare function ChartFigure({ answer, shape, limit, target, height, say, label, seriesLabel, vocabulary, seriesVocabulary, scale, seriesScale, seriesTone, tone, sayLegend, onPick, empty, emptyDetail, emptyAction, curve, total, dots, arrange, }: ChartFigureProps): import("react").JSX.Element;
62
+ export declare function ChartFigure({ answer, shape, limit, target, height, say, label, seriesLabel, vocabulary, seriesVocabulary, scale, seriesScale, seriesTone, tone, sayLegend, onPick, empty, emptyDetail, emptyAction, curve, total, dots, arrange, timed, }: ChartFigureProps): import("react").JSX.Element;
61
63
  interface ChartShapeFigureProps {
62
64
  shape: ExtraShape;
63
65
  answer: Answer | undefined;
@@ -7,14 +7,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
7
7
  */
8
8
  import { useLayoutEffect, useRef, useState } from 'react';
9
9
  import { viewportBox } from '../core.js';
10
- import { BarChart, DonutChart, LineChart, StackedBars } from './Chart.js';
10
+ import { BarChart, DonutChart, LineChart, StackedBars, TIMED_HEIGHT } from './Chart.js';
11
11
  import { Empty } from './Notes.js';
12
12
  import { orderDeclared } from './groupOrder.js';
13
13
  import { onDemand } from './onDemand.js';
14
14
  /* The shapes drawn by the part on demand: said beside the dashboard's preload (dashboardModel.ts), which asks for it early. */
15
15
  export { EXTRA_SHAPES } from './dashboardModel.js';
16
16
  const ChartShape = onDemand(() => import('./ChartShapes.js'), 'ChartShape');
17
- export function ChartFigure({ answer, shape, limit, target, height, say, label, seriesLabel, vocabulary, seriesVocabulary, scale, seriesScale, seriesTone, tone, sayLegend, onPick, empty, emptyDetail, emptyAction, curve, total, dots, arrange, }) {
17
+ export function ChartFigure({ answer, shape, limit, target, height, say, label, seriesLabel, vocabulary, seriesVocabulary, scale, seriesScale, seriesTone, tone, sayLegend, onPick, empty, emptyDetail, emptyAction, curve, total, dots, arrange, timed, }) {
18
18
  const stacked = shape === 'stacked';
19
19
  const donut = shape === 'donut';
20
20
  const bars = shape === 'bar';
@@ -61,7 +61,7 @@ export function ChartFigure({ answer, shape, limit, target, height, say, label,
61
61
  /* Before the answer, the chart's room at about the height it will draw at, ruled as its gridlines will be: an empty
62
62
  host was nothing tall, and the chart arriving pushed every section under it down. */
63
63
  if (!answer)
64
- return _jsx(ChartWait, { shape: stacked ? 'rows' : donut ? 'donut' : 'plot', height: height, rows: limit });
64
+ return _jsx(ChartWait, { shape: stacked ? (timed ? 'columns' : 'rows') : donut ? 'donut' : 'plot', height: height, rows: limit });
65
65
  return (_jsx("div", { className: "chart-host", ref: host, children: answer &&
66
66
  wide > 0 &&
67
67
  (donut ? (_jsx(DonutChart, { rows: rows, say: say, label: label, onPick: onPick, total: total, ordered: scale, tone: tone })) : bars ? (_jsx(BarChart, { rows: rows, say: say, label: label, wide: wide, high: height, target: target, tone: tone })) : stacked ? (_jsx(StackedBars, { rows: rows, say: say, target: target, limit: limit, label: label, seriesLabel: seriesLabel, onPick: onPick, seriesVocabulary: seriesVocabulary, seriesOrdered: seriesScale, seriesTone: seriesTone, sayLegend: sayLegend })) : (_jsx(LineChart, { rows: rows, say: say, wide: wide, high: height, target: target, smooth: curve === 'smooth', dots: dots, seriesLabel: seriesLabel, seriesVocabulary: seriesVocabulary, onPick: onPick }))) }));
@@ -87,6 +87,9 @@ export function ChartShapeFigure({ answer, empty, emptyDetail, emptyAction, heig
87
87
  return _jsx(ChartWait, { shape: "plot", height: height });
88
88
  return (_jsx("div", { className: "chart-host", ref: host, children: answer && wide > 0 && _jsx(ChartShape, { ...rest, answer: answer, wide: wide, high: height }) }));
89
89
  }
90
+ /** The legend's line (24px) and the gap under it (10px) over stacked columns, as .chart-stacked-legend draws them:
91
+ measured, so the room held while the answer is read is the height of the chart that replaces it. */
92
+ const TIMED_LEGEND = 34;
90
93
  /**
91
94
  * A chart's room while it is read: a plot at the line's own measure (a third of its width, 160px to 240px, or the
92
95
  * section's `height`), a stack at a row a group, a donut at its disc. Quiet gridlines and no sweep: a chart is a
@@ -95,10 +98,13 @@ export function ChartShapeFigure({ answer, empty, emptyDetail, emptyAction, heig
95
98
  function ChartWait({ shape, height, rows }) {
96
99
  const style = shape === 'rows'
97
100
  ? { height: `${Math.min(Math.max(rows ?? 4, 2), 8) * 30 + 32}px` }
98
- : shape === 'donut'
99
- ? { height: '200px' }
100
- : height
101
- ? { height: `${Math.max(120, Math.round(height))}px` }
102
- : undefined;
101
+ : shape === 'columns'
102
+ ? /* The legend's line over the columns' fixed figure (Chart.tsx, StackedBars). */
103
+ { height: `${TIMED_HEIGHT + TIMED_LEGEND}px` }
104
+ : shape === 'donut'
105
+ ? { height: '200px' }
106
+ : height
107
+ ? { height: `${Math.max(120, Math.round(height))}px` }
108
+ : undefined;
103
109
  return _jsx("div", { className: `chart-host chart-wait chart-wait-${shape}`, style: style, role: "status", "aria-busy": "true" });
104
110
  }
@@ -25,7 +25,7 @@ import { currentEntry, paintVersion, renderCrumbs, roomVersion } from '../core.j
25
25
  import { shell } from '../shellMode.js';
26
26
  import { syncHash } from '../url.js';
27
27
  import { appListFor } from './appListModel.js';
28
- import { ASSISTANT_PAGE, INBOX_PAGE, dashPageId, dashViewKey, formViewKey, homeRoom } from './appRooms.js';
28
+ import { ASSISTANT_PAGE, DIRECTORY_PAGE, INBOX_PAGE, dashPageId, dashViewKey, formViewKey, homeRoom } from './appRooms.js';
29
29
  import { onDemand } from './onDemand.js';
30
30
  import { crumbBarShown, Crumbs } from './Crumbs.js';
31
31
  import { LoadErrorNote, NothingGranted, WorkbenchLanding } from './Landing.js';
@@ -164,6 +164,8 @@ function Room({ entry }) {
164
164
  return rooms.Inbox ? _jsx(rooms.Inbox, {}) : null;
165
165
  if (shell().inApp() && page.pageId === ASSISTANT_PAGE)
166
166
  return rooms.Assistant ? _jsx(rooms.Assistant, { conversation: page.tab }) : null;
167
+ if (shell().inApp() && page.pageId === DIRECTORY_PAGE)
168
+ return rooms.Directory ? _jsx(rooms.Directory, {}) : null;
167
169
  return _jsx(PageRoom, { entry: page });
168
170
  }
169
171
  return _jsx(RowRoom, { entry: entry });
@@ -0,0 +1,6 @@
1
+ import type { DashboardDef } from './dashboardModel.js';
2
+ export declare function DashHead({ dashboard, star, }: {
3
+ dashboard: Pick<DashboardDef, 'id' | 'label' | 'heading' | 'headingHidden' | 'head' | 'description' | 'favorite'>;
4
+ /** The landing draws no star: its page is the App's front door, not a place one keeps. */
5
+ star?: boolean;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * A dashboard's or a free-form page's head (Rooms.tsx, the App's FreePage and
4
+ * landing): its one h1, its star, its intro — in the form the page asks for.
5
+ *
6
+ * `head: 'compact'` is the title alone on one line with its verbs, at a list's
7
+ * size and with no intro: a working page whose body starts at once. `head:
8
+ * false` is a page that draws its own head; its title is kept for a screen
9
+ * reader, so the room still has the one h1 that names it, while the document
10
+ * title, the crumbs and the palette read the label as they always do.
11
+ */
12
+ import { FavoriteStar } from './FavoriteStar.js';
13
+ export function DashHead({ dashboard, star = true, }) {
14
+ const hidden = dashboard.headingHidden === true || dashboard.head === 'own';
15
+ const title = dashboard.heading ?? dashboard.label;
16
+ const favorite = star && dashboard.favorite && dashboard.head !== 'own' && (_jsx(FavoriteStar, { favorite: { kind: 'view', view: dashboard.id, label: dashboard.label }, name: dashboard.label }));
17
+ if (dashboard.head === 'compact' && !hidden)
18
+ return (_jsxs("div", { className: "applist-head applist-head-row dash-head-compact", children: [_jsx("h1", { className: "applist-title", children: title }), favorite] }));
19
+ return (_jsxs("div", { className: "applist-head dash-head", children: [_jsx("h1", { className: `applist-title${hidden ? ' visually-hidden' : ''}`, children: title }), favorite, dashboard.description && dashboard.head !== 'own' && _jsx("p", { className: "note dash-description", children: dashboard.description })] }));
20
+ }
@@ -220,7 +220,7 @@ export function Editable({ table, row, column, recordKey, onSaved, app = false,
220
220
  and stage it back over the value. JSON is read here, never edited. */
221
221
  const json = jsonValueOf(column, value);
222
222
  if (json)
223
- return _jsx(JsonView, { value: json.value });
223
+ return _jsx(JsonView, { value: json.value, label: column.name });
224
224
  const onEdit = (next) => {
225
225
  if (applying || column.writable === false || column.changesBy === 'actions' || !editorCurrent(isCurrent))
226
226
  return;
@@ -32,6 +32,7 @@ import { useVirtualizer } from '@tanstack/react-virtual';
32
32
  import { columnDisplay, columnLabel, currentEntry, emptyWord, keyOf, openRecord, peekRecord, prefersPages, primaryKey, rowLabel, state, viewportBox, viewportScale, } from '../core.js';
33
33
  import { opensRecord } from '../recordIntent.js';
34
34
  import { labelColumn as namingColumn } from '@mistriwork/engine/shared/schema.js';
35
+ import { ListSubtitles } from './listSubtitles.js';
35
36
  import { datesAmong, dressFor, leadTonePath, maskedText, ruleSays, subtitlePath } from './valueModel.js';
36
37
  import { currencyPath } from '@mistriwork/engine/shared/money.js';
37
38
  import { dueOpen } from './dueOpen.js';
@@ -120,6 +121,18 @@ function TotalValue({ value, display }) {
120
121
  return _jsx(Dressed, { dress: dress, compact: dress.kind === 'richText' });
121
122
  return _jsx("span", { className: "num-value", children: formatNumber(value) });
122
123
  }
124
+ /** The words the totals row draws for a column's sum, which its column is sized by (TotalValue's words); none while the
125
+ sum is on its way, absent, or drawn by a meter. */
126
+ function totalWords(display, value) {
127
+ if (value === undefined || value === null)
128
+ return undefined;
129
+ const dress = dressFor(display, value);
130
+ if (!dress)
131
+ return formatNumber(value);
132
+ if (dress.kind === 'meter')
133
+ return undefined;
134
+ return String((dress.kind === 'tone' || dress.kind === 'word' || dress.kind === 'mark' ? dress.label : dress.text) ?? value);
135
+ }
123
136
  /** The words a plain cell draws for a value, which the grid sizes a column by and a folded detail line tests its head
124
137
  against: a reference's label, a display rule's own words, a number as formatted, else the raw value. */
125
138
  function drawnWords(display, plan, value, label) {
@@ -284,6 +297,7 @@ function TagsCellList({ chips }) {
284
297
  more.style.display = count > 0 ? '' : 'none';
285
298
  };
286
299
  const fit = () => {
300
+ list.removeAttribute('data-lone');
287
301
  tags.forEach((tag) => (tag.style.display = ''));
288
302
  sayMore(chips.length - tags.length);
289
303
  const box = getComputedStyle(cell);
@@ -298,6 +312,10 @@ function TagsCellList({ chips }) {
298
312
  });
299
313
  sayMore(chips.length - count);
300
314
  tags.forEach((tag, index) => (tag.style.display = index < count ? '' : 'none'));
315
+ /* The one chip that is left is kept even where it is wider than the cell, and is then the one thing that may be
316
+ cut: a chip is a word, but a cell narrower than its only word cannot show it whole. */
317
+ if (count === 1 && widths[0] + (chips.length > 1 ? gap + more.offsetWidth : 0) > room)
318
+ list.setAttribute('data-lone', '');
301
319
  };
302
320
  fit();
303
321
  const observer = new ResizeObserver(() => fit());
@@ -372,7 +390,7 @@ function PlatformCell({ meta, plan, value, label, display, pin, edge, photo, wra
372
390
  classes.push('mono');
373
391
  if (plan.kind === 'boolean') {
374
392
  const on = value === true || value === 1 || value === '1' || value === 't';
375
- return (_jsx("td", { className: `${classes.join(' ')} bool${pinClass}`, title: raw, ...peek, ...pinAttrs, children: _jsx("span", { className: on ? 'yes' : 'no', children: on ? '✓' : '✗' }) }));
393
+ return (_jsx("td", { className: `${classes.join(' ')} bool${pinClass}`, title: raw, ...peek, ...pinAttrs, children: on ? (_jsx("span", { className: "yes", children: "\u2713" })) : app ? (_jsx("span", { className: "no visually-hidden", children: say('common.no') })) : (_jsx("span", { className: "no", children: "\u2717" })) }));
376
394
  }
377
395
  if (plan.kind === 'number') {
378
396
  const shown = numberShown(value, plan) ?? raw;
@@ -408,8 +426,15 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
408
426
  /* A second line is read from the row only where the row carries it: a
409
427
  subtitle the list did not fetch is left out rather than read from a
410
428
  column of the same name on another table. */
429
+ /* A list whose columns were inferred says a second line of its own where the column's rule names none. */
430
+ const ownLines = useContext(ListSubtitles);
431
+ const displayOf = (name) => {
432
+ const rule = columnDisplay(table?.id, name);
433
+ const line = ownLines && Object.hasOwn(ownLines, name) ? ownLines[name] : undefined;
434
+ return line && !rule?.subtitle ? { ...rule, subtitle: line } : rule;
435
+ };
411
436
  const subtitleOf = (name, row) => {
412
- const path = subtitlePath(columnDisplay(table?.id, name), name);
437
+ const path = subtitlePath(displayOf(name), name);
413
438
  return path && Object.hasOwn(row, path) ? row[path] : undefined;
414
439
  };
415
440
  const plans = useMemo(() => new Map(asked.map((name) => [
@@ -581,7 +606,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
581
606
  const sizeHints = useMemo(() => asked.map((name) => {
582
607
  const plan = plans.get(name);
583
608
  const labelColumn = referenceLabels?.[name];
584
- const display = datesAmong(columnDisplay(table?.id, name), rows.map((row) => row[name]));
609
+ const display = datesAmong(displayOf(name), rows.map((row) => row[name]));
585
610
  const label = String(labels?.[name] ?? columnLabel(table?.id, name) ?? name);
586
611
  const headText = byName.get(name)?.primaryKey && !shell().inApp() ? `${label} ${say('common.key')}` : label;
587
612
  const headMeasure = headFace ? textMeasure(headFace.font) : undefined;
@@ -628,6 +653,8 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
628
653
  return drawnWords(display, plan, row[name]);
629
654
  }),
630
655
  subValues: display?.subtitle ? rows.slice(0, GRID_SIZE_SAMPLE).map((row) => subtitleOf(name, row)) : undefined,
656
+ /* The totals row is a figure no row is as wide as: sized by its rows alone, a sum was cut to "$102,795....". */
657
+ total: totals && rows.length > 0 && Object.hasOwn(totals, name) ? totalWords(display, totals[name]) : undefined,
631
658
  chip: byName.get(name)?.type === TAGS_TYPE ||
632
659
  (!labelColumn &&
633
660
  rows.slice(0, GRID_SIZE_SAMPLE).some((row) => {
@@ -661,11 +688,13 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
661
688
  captionLanguage,
662
689
  byName,
663
690
  rows,
691
+ totals,
664
692
  titleName,
665
693
  headFace,
666
694
  cellChips,
667
695
  shift,
668
696
  faceEpoch,
697
+ ownLines,
669
698
  ]);
670
699
  /* Column i's cell follows the expander's when there is one. */
671
700
  const measureText = useMemo(() => cellFonts.length
@@ -907,7 +936,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
907
936
  })();
908
937
  const cellColumns = useKeptColumns(ordered.map((name) => {
909
938
  /* A column of relative dates is said one way down its length (datesAmong). */
910
- const display = datesAmong(columnDisplay(table?.id, name), rows.map((row) => row[name]));
939
+ const display = datesAmong(displayOf(name), rows.map((row) => row[name]));
911
940
  return {
912
941
  name,
913
942
  meta: byName.get(name),
@@ -0,0 +1,29 @@
1
+ /* Imported by features.css: part of the tool's own rules (style.css names the order). */
2
+ @layer base {
3
+ /* What a first page needs of a JSON document: its one-line preview in a grid
4
+ cell (JsonPreview.tsx) and in a compact field, and the full width a field
5
+ holding a document takes. The document itself is drawn by JsonView.tsx,
6
+ whose sheet (JsonView.css) arrives with it, on demand. */
7
+
8
+ /* A document is a block: in a record's or a page's field grid it takes the
9
+ full width, as long text does, rather than being squeezed into a column.
10
+ Here, not in the viewer's sheet, so the field is full width from the first
11
+ paint and nothing moves when the viewer arrives. */
12
+ .field:has(.json-view), .page-field:has(.json-view) { grid-column: 1 / -1; }
13
+
14
+ /* In a grid cell: the shape in one quiet line, the whole cell a button. */
15
+ .json-preview {
16
+ display: block; width: 100%; padding: 0; border: 0; border-radius: 0; background: none;
17
+ text-align: left; font: var(--text-sm)/inherit var(--code); color: var(--ink-muted);
18
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
19
+ }
20
+ @media (hover: hover) and (pointer: fine) {
21
+ .json-preview:hover { color: var(--link); }
22
+ }
23
+ .json-preview:focus-visible { outline-offset: -2px; }
24
+ .json-preview-text { font: var(--text-sm) var(--code); color: var(--ink-muted); }
25
+
26
+ @media (prefers-reduced-motion: no-preference) {
27
+ .json-preview { transition: color var(--t-hover) var(--ease-out); }
28
+ }
29
+ }