@mistriwork/kit 1.0.0-rc.16 → 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 (110) hide show
  1. package/dist/client/components/AppList.js +16 -6
  2. package/dist/client/components/CardsList.js +7 -1
  3. package/dist/client/components/Chart.css +5 -0
  4. package/dist/client/components/Chart.d.ts +17 -2
  5. package/dist/client/components/Chart.js +83 -22
  6. package/dist/client/components/ChartFigure.d.ts +3 -1
  7. package/dist/client/components/ChartFigure.js +14 -8
  8. package/dist/client/components/Content.js +3 -1
  9. package/dist/client/components/DashHead.d.ts +6 -0
  10. package/dist/client/components/DashHead.js +20 -0
  11. package/dist/client/components/Editable.js +1 -1
  12. package/dist/client/components/Export.js +8 -4
  13. package/dist/client/components/Grid.js +54 -6
  14. package/dist/client/components/JsonPreview.css +29 -0
  15. package/dist/client/components/JsonPreview.js +1 -1
  16. package/dist/client/components/JsonView.css +201 -62
  17. package/dist/client/components/JsonView.d.ts +43 -1
  18. package/dist/client/components/JsonView.js +320 -55
  19. package/dist/client/components/LayoutSwitch.d.ts +9 -0
  20. package/dist/client/components/LayoutSwitch.js +61 -0
  21. package/dist/client/components/ListEmpty.css +3 -0
  22. package/dist/client/components/LiveNotices.css +3 -0
  23. package/dist/client/components/NewRecord.d.ts +0 -2
  24. package/dist/client/components/NewRecord.js +61 -17
  25. package/dist/client/components/PageFields.js +23 -4
  26. package/dist/client/components/PageHead.js +28 -7
  27. package/dist/client/components/PageRelated.d.ts +28 -0
  28. package/dist/client/components/PageRelated.js +50 -3
  29. package/dist/client/components/PageSectionBox.d.ts +5 -1
  30. package/dist/client/components/PageSectionBox.js +5 -3
  31. package/dist/client/components/PageSections.js +26 -13
  32. package/dist/client/components/PageSkeleton.css +2 -0
  33. package/dist/client/components/PageSkeleton.js +11 -3
  34. package/dist/client/components/Palette.js +108 -10
  35. package/dist/client/components/RecordPicker.d.ts +2 -0
  36. package/dist/client/components/RecordPicker.js +34 -8
  37. package/dist/client/components/RecordSummaries.js +6 -1
  38. package/dist/client/components/Rooms.js +2 -2
  39. package/dist/client/components/SecondLine.d.ts +15 -0
  40. package/dist/client/components/SecondLine.js +18 -0
  41. package/dist/client/components/TableRoom.js +15 -5
  42. package/dist/client/components/TableView.d.ts +2 -0
  43. package/dist/client/components/Value.d.ts +1 -0
  44. package/dist/client/components/Value.js +7 -9
  45. package/dist/client/components/appListModel.d.ts +4 -0
  46. package/dist/client/components/appRooms.d.ts +2 -0
  47. package/dist/client/components/appRooms.js +2 -0
  48. package/dist/client/components/dashboardModel.d.ts +5 -0
  49. package/dist/client/components/directoryModel.d.ts +25 -0
  50. package/dist/client/components/directoryModel.js +88 -0
  51. package/dist/client/components/gridSizing.d.ts +3 -0
  52. package/dist/client/components/gridSizing.js +6 -2
  53. package/dist/client/components/jsonTree.d.ts +54 -0
  54. package/dist/client/components/jsonTree.js +190 -0
  55. package/dist/client/components/listSubtitles.d.ts +1 -0
  56. package/dist/client/components/listSubtitles.js +7 -0
  57. package/dist/client/components/newMenuModel.d.ts +14 -6
  58. package/dist/client/components/newMenuModel.js +37 -5
  59. package/dist/client/components/newRecordModel.d.ts +24 -2
  60. package/dist/client/components/newRecordModel.js +47 -4
  61. package/dist/client/components/pageContext.d.ts +2 -0
  62. package/dist/client/components/pageModel.d.ts +2 -0
  63. package/dist/client/components/sidebarModel.js +7 -3
  64. package/dist/client/components/textMeasure.d.ts +2 -0
  65. package/dist/client/components/textMeasure.js +16 -2
  66. package/dist/client/composedReads.js +3 -1
  67. package/dist/client/copy/lists/components/AppList.d.ts +1 -0
  68. package/dist/client/copy/lists/components/AppList.js +1 -0
  69. package/dist/client/copy/lists/components/LayoutSwitch.d.ts +4 -0
  70. package/dist/client/copy/lists/components/LayoutSwitch.js +6 -0
  71. package/dist/client/copy/record/components/JsonView.d.ts +22 -0
  72. package/dist/client/copy/record/components/JsonView.js +19 -0
  73. package/dist/client/copy/record/components/PageHead.d.ts +1 -0
  74. package/dist/client/copy/record/components/PageHead.js +2 -0
  75. package/dist/client/copy/shell/components/Palette.d.ts +11 -0
  76. package/dist/client/copy/shell/components/Palette.js +14 -0
  77. package/dist/client/copy/shell/components/TopNav.d.ts +2 -1
  78. package/dist/client/copy/shell/components/TopNav.js +4 -2
  79. package/dist/client/copy/shell/components/directoryModel.d.ts +4 -0
  80. package/dist/client/copy/shell/components/directoryModel.js +6 -0
  81. package/dist/client/copy/shell/components/sidebarModel.d.ts +1 -0
  82. package/dist/client/copy/shell/components/sidebarModel.js +1 -0
  83. package/dist/client/copy/workbench/components/Export.d.ts +3 -2
  84. package/dist/client/copy/workbench/components/Export.js +3 -2
  85. package/dist/client/core.d.ts +3 -3
  86. package/dist/client/core.js +6 -7
  87. package/dist/client/export.d.ts +5 -4
  88. package/dist/client/export.js +40 -19
  89. package/dist/client/features.css +67 -7
  90. package/dist/client/index.html +2 -1
  91. package/dist/client/insert.js +1 -8
  92. package/dist/client/locale.d.ts +7 -0
  93. package/dist/client/locale.js +0 -0
  94. package/dist/client/lumenLook.css +9 -12
  95. package/dist/client/page.css +63 -15
  96. package/dist/client/palette.d.ts +3 -1
  97. package/dist/client/palette.js +19 -4
  98. package/dist/client/paletteRecents.d.ts +25 -0
  99. package/dist/client/paletteRecents.js +64 -0
  100. package/dist/client/partsLook.css +6 -3
  101. package/dist/client/sageLook.css +5 -3
  102. package/dist/client/shellMode.d.ts +8 -0
  103. package/dist/client/shellMode.js +1 -0
  104. package/dist/client/structure.css +201 -1
  105. package/dist/client/style.css +59 -10
  106. package/dist/client/themeFamilies.css +37 -0
  107. package/dist/client/visualThemes.css +12 -0
  108. package/dist/client/workbenchLook.css +415 -0
  109. package/dist/client/workshopLook.css +48 -25
  110. package/package.json +4 -3
@@ -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';
@@ -50,7 +51,7 @@ import { Icon } from './Icon.js';
50
51
  import { createRowHosts, RowDecoration, RowHostScope, RowTrailScope, rowKeyString, useRowHostScope, useRowTrailScope, } from './RowHost.js';
51
52
  import { useGridKeyboard } from './useGridKeyboard.js';
52
53
  import { useChangedRows } from '../liveState.js';
53
- import { textMeasure } from './textMeasure.js';
54
+ import { fontLoaded, textMeasure } from './textMeasure.js';
54
55
  import { presentationColumns } from './columnPresentation.js';
55
56
  import { usePins } from './usePins.js';
56
57
  import { useStickyHead } from './useStickyHead.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) => [
@@ -484,13 +509,18 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
484
509
  status as a pill spends 41px there, one that says it as a dot and a word 12, and sizing every column for the
485
510
  wider kept 30px of every table's room in a status that never used it. -1: the cell holds no chip. */
486
511
  const [cellChips, setCellChips] = useState([]);
512
+ /* Counts the times a face arrived after the columns were sized in its fallback: the sizes are read again, once for
513
+ each, so a table's columns never stay as the fallback face set them (textMeasure.ts). */
514
+ const [faceEpoch, setFaceEpoch] = useState(0);
487
515
  useLayoutEffect(() => {
488
516
  if (sizing !== 'fit' || !wrap.current)
489
517
  return;
490
518
  const element = wrap.current;
491
519
  /* The look says how wide its heads' characters set (gridSizing.ts); read
492
520
  again when the reader picks another look, which moves no width. */
521
+ let sizedInFallback = false;
493
522
  const measure = (contentWidth) => {
523
+ sizedInFallback = false;
494
524
  const style = getComputedStyle(element);
495
525
  /* clientWidth rounds up fractional layout widths. At density zoom that
496
526
  can create a one-screen-pixel scroll range even when scrollWidth and
@@ -509,6 +539,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
509
539
  upper: face.textTransform === 'uppercase',
510
540
  tracking: parseFloat(face.letterSpacing) || 0,
511
541
  };
542
+ sizedInFallback = sizedInFallback || !fontLoaded(next.font);
512
543
  setHeadFace((was) => (was && was.font === next.font && was.upper === next.upper && was.tracking === next.tracking ? was : next));
513
544
  }
514
545
  /* A group's head is not a row of values: the first row that is one is sampled. */
@@ -519,6 +550,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
519
550
  const font = getComputedStyle(cell);
520
551
  return `${font.fontStyle} ${font.fontWeight} ${font.fontSize} ${font.fontFamily}`;
521
552
  });
553
+ sizedInFallback = sizedInFallback || !fonts.every(fontLoaded);
522
554
  setCellFonts((was) => (was.join('|') === fonts.join('|') ? was : fonts));
523
555
  /* The widest chip of the sampled rows, not the first row's: a look may draw a neutral state as a bare word
524
556
  and the rest as pills, and sized by a first-row "Ready" Sage cut every "In review" pill to "In rev…". */
@@ -547,7 +579,18 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
547
579
  observer.observe(element);
548
580
  const themeChanged = () => measure();
549
581
  addHostListener(window, VISUAL_THEME_EVENT, themeChanged);
582
+ /* A face that arrives after the first measure: sized again with it, once, and only if the last measure was made
583
+ without it (a face already here moves nothing). */
584
+ const faces = globalThis.document?.fonts;
585
+ const arrived = () => {
586
+ if (!sizedInFallback)
587
+ return;
588
+ measure();
589
+ setFaceEpoch((was) => was + 1);
590
+ };
591
+ faces?.addEventListener?.('loadingdone', arrived);
550
592
  return () => {
593
+ faces?.removeEventListener?.('loadingdone', arrived);
551
594
  observer.disconnect();
552
595
  removeHostListener(window, VISUAL_THEME_EVENT, themeChanged);
553
596
  };
@@ -563,7 +606,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
563
606
  const sizeHints = useMemo(() => asked.map((name) => {
564
607
  const plan = plans.get(name);
565
608
  const labelColumn = referenceLabels?.[name];
566
- const display = datesAmong(columnDisplay(table?.id, name), rows.map((row) => row[name]));
609
+ const display = datesAmong(displayOf(name), rows.map((row) => row[name]));
567
610
  const label = String(labels?.[name] ?? columnLabel(table?.id, name) ?? name);
568
611
  const headText = byName.get(name)?.primaryKey && !shell().inApp() ? `${label} ${say('common.key')}` : label;
569
612
  const headMeasure = headFace ? textMeasure(headFace.font) : undefined;
@@ -610,6 +653,8 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
610
653
  return drawnWords(display, plan, row[name]);
611
654
  }),
612
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,
613
658
  chip: byName.get(name)?.type === TAGS_TYPE ||
614
659
  (!labelColumn &&
615
660
  rows.slice(0, GRID_SIZE_SAMPLE).some((row) => {
@@ -643,15 +688,18 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
643
688
  captionLanguage,
644
689
  byName,
645
690
  rows,
691
+ totals,
646
692
  titleName,
647
693
  headFace,
648
694
  cellChips,
649
695
  shift,
696
+ faceEpoch,
697
+ ownLines,
650
698
  ]);
651
699
  /* Column i's cell follows the expander's when there is one. */
652
700
  const measureText = useMemo(() => cellFonts.length
653
701
  ? (text, column) => textMeasure(cellFonts[Math.min(column + (slotted ? 1 : 0), cellFonts.length - 1)])?.(text) ?? text.length * 8
654
- : undefined, [cellFonts, slotted]);
702
+ : undefined, [cellFonts, slotted, faceEpoch]);
655
703
  /* An App's own list folds the columns its room cannot hold under the row's name, as a detail line, once its heads
656
704
  and words have wrapped (gridSizing.ts): they are moved, not lost, and the list does not scroll sideways. An
657
705
  embedded grid leaves them out, as it did. */
@@ -888,7 +936,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
888
936
  })();
889
937
  const cellColumns = useKeptColumns(ordered.map((name) => {
890
938
  /* A column of relative dates is said one way down its length (datesAmong). */
891
- const display = datesAmong(columnDisplay(table?.id, name), rows.map((row) => row[name]));
939
+ const display = datesAmong(displayOf(name), rows.map((row) => row[name]));
892
940
  return {
893
941
  name,
894
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
+ }
@@ -21,5 +21,5 @@ export function JsonPreview({ value, name, type }) {
21
21
  return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "json-preview", "data-cell-opens": "", tabIndex: -1, "aria-haspopup": "dialog", title: say('openName', { name }), onClick: (e) => {
22
22
  e.stopPropagation();
23
23
  setOpen(true);
24
- }, children: previewOf(value) }), open && here && (_jsxs(Modal, { ref: modal, className: "confirm json-overlay", ariaLabel: `${name} (JSON)`, onClose: () => setOpen(false), children: [_jsxs("header", { className: "json-overlay-head", children: [_jsx("h2", { children: name }), type && _jsx("span", { className: "json-overlay-type", children: type.toLowerCase() }), _jsx("button", { type: "button", className: "ghost json-overlay-close", onClick: () => modal.current?.close(), children: say('common.close') })] }), _jsx(JsonView, { value: value })] }))] }));
24
+ }, children: previewOf(value) }), open && here && (_jsx(Modal, { ref: modal, className: "confirm json-overlay", ariaLabel: `${name} (JSON)`, onClose: () => setOpen(false), children: _jsx(JsonView, { value: value, label: name, head: _jsxs("header", { className: "json-overlay-title", children: [_jsx("h2", { children: name }), type && _jsx("span", { className: "json-overlay-type", children: type.toLowerCase() })] }), tail: _jsx("button", { type: "button", className: "ghost json-overlay-close", onClick: () => modal.current?.close(), children: say('common.close') }) }) }))] }));
25
25
  }
@@ -1,108 +1,247 @@
1
- /* Imported by features.css: part of the tool's own rules (style.css names the order). */
1
+ /* A JSON document, laid out (components/JsonView.tsx), and the overlay that
2
+ shows one from a grid cell (JsonPreview.tsx). Its own sheet, fetched with
3
+ the viewer, so no first page carries the rules of a part most visits never
4
+ draw; what a first page needs (the cell's line, the field's width) is in
5
+ JsonPreview.css. Every value is a token from style.css, so light, dark and
6
+ an App's theme dress it the same way. In the tool's own layer, as it was
7
+ when features.css took it: a look's rules still come after. */
2
8
  @layer base {
3
- /* A JSON document, laid out (components/JsonView.tsx), its one-line grid
4
- preview and its overlay (JsonPreview.tsx). Every value is a token from
5
- style.css, so light, dark and an App's theme dress it the same way. */
6
9
 
7
- .json-view { min-width: 0; max-width: 70rem; font: var(--text-base)/1.55 var(--sans); color: var(--ink); }
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
- .field:has(.json-view), .page-field:has(.json-view) { grid-column: 1 / -1; }
10
+ .json-view {
11
+ /* The type tints, shared by the tree and the raw text: each a status ink
12
+ drawn back toward the text's own, so a payload's kinds are told apart at a
13
+ glance and none of them shouts (docs/design.md: bold by type and
14
+ contrast, never by saturation). Mixed toward the ink, never the ground,
15
+ so each keeps at least its status ink's contrast, light and dark. Keys
16
+ and punctuation stay the quiet greys: they are the frame, not the data. */
17
+ --json-key: var(--ink-muted);
18
+ --json-string: color-mix(in srgb, var(--status-good) 64%, var(--ink));
19
+ --json-number: color-mix(in srgb, var(--status-info) 70%, var(--ink));
20
+ --json-literal: color-mix(in srgb, var(--status-warning) 70%, var(--ink));
21
+ --json-null: var(--ink-subtle);
22
+ --json-punct: var(--ink-subtle);
23
+ /* The caret's gutter: every key at a level starts on one line, folding or not. */
24
+ --json-caret: 1.15em;
25
+ min-width: 0; max-width: 70rem; font: var(--text-base)/1.55 var(--sans); color: var(--ink);
26
+ }
27
+
28
+ /* ---------- the bar ---------- */
11
29
 
12
- .json-bar { display: flex; justify-content: flex-end; gap: var(--space-2); margin-bottom: var(--space-1); }
30
+ .json-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); margin-bottom: var(--space-3); }
31
+ .json-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-left: auto; }
13
32
  .json-tool {
14
- background: transparent; color: var(--ink-muted); border: 1px solid transparent;
15
- padding: 1px var(--space-3); font-size: var(--text-sm); line-height: 1.6;
33
+ background: transparent; color: var(--ink-muted); border: 1px solid transparent; border-radius: var(--radius);
34
+ padding: var(--space-1) var(--space-3); font-size: var(--text-sm); line-height: 1.6;
16
35
  }
17
- .json-tool:hover { color: var(--ink); background: var(--raised); }
18
36
  .json-tool[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-soft); }
37
+ /* Tree | Raw: a segmented pair, the chosen one filled, as a list's Records | Table is. */
38
+ .json-modes { display: inline-flex; gap: var(--space-1); padding: var(--space-1); border: 1px solid var(--line); border-radius: var(--radius); }
39
+ .json-mode {
40
+ background: transparent; color: var(--ink-muted); border: 0; border-radius: var(--radius);
41
+ padding: 0 var(--space-3); font-size: var(--text-sm); line-height: 1.6;
42
+ }
43
+ .json-mode[aria-pressed="true"] { background: var(--raised); color: var(--ink); }
44
+
45
+ .json-filter { display: flex; align-items: center; gap: var(--space-3); flex: 1 1 14rem; max-width: 24rem; min-width: 0; }
46
+ .json-filter-input {
47
+ flex: 1; min-width: 0; padding: var(--space-1h) var(--space-3);
48
+ border: 1px solid var(--line-control); border-radius: var(--radius); background: var(--field-fill); color: var(--ink);
49
+ font: var(--text-sm)/1.5 var(--sans);
50
+ }
51
+ .json-filter-input::placeholder { color: var(--ink-subtle); }
52
+ .json-filter-input:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: -1px; border-color: transparent; }
53
+ .json-count { flex: none; color: var(--ink-subtle); font-size: var(--text-xs); font-variant-numeric: tabular-nums; white-space: nowrap; }
54
+
55
+ /* ---------- the tree ---------- */
19
56
 
20
- /* Labels beside values. The label column is as wide as its longest key up to
21
- a cap, so a short document is not stretched across the room and a long key
22
- wraps rather than pushing its value off the edge. */
23
- .json-fields {
24
- display: grid; grid-template-columns: fit-content(14rem) minmax(0, 1fr);
25
- gap: var(--space-2) var(--space-5); margin: 0;
57
+ /* Labels beside values. The caret has a gutter of its own, so keys line up
58
+ whether they fold or not; the label column is as wide as its longest key up
59
+ to a cap, so a short document is not stretched across the room and a long
60
+ key wraps rather than pushing its value off the edge. Each node is a row
61
+ of the one grid (subgrid), so a row can be hovered, focused and ringed as
62
+ one line while every key at its level still shares a column. The value
63
+ column is as wide as its widest value and no wider, so a line's band and
64
+ its copies end near what it says, not at the far side of the room. The
65
+ copies have a column of their own past the widest value, held while they
66
+ are hidden, so a short value is never under them. */
67
+ .json-fields { display: grid; grid-template-columns: var(--json-caret) fit-content(14rem) minmax(0, max-content) max-content; justify-content: start; row-gap: var(--space-2); }
68
+ .json-entry { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; row-gap: var(--space-2); min-width: 0; }
69
+ .json-row {
70
+ grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: baseline;
71
+ position: relative; border-radius: min(3px, var(--radius));
72
+ }
73
+ .json-caret { color: var(--ink-subtle); font-size: var(--text-xs); text-align: center; user-select: none; }
74
+ .json-row .json-caret { grid-column: 1; }
75
+ .json-key {
76
+ grid-column: 2; padding-right: var(--space-5);
77
+ color: var(--json-key); font: var(--text-sm)/1.65 var(--code); overflow-wrap: anywhere;
26
78
  }
27
- .json-field { display: contents; }
28
- .json-key { color: var(--ink-muted); font: var(--text-sm)/1.65 var(--code); overflow-wrap: anywhere; }
29
79
  .json-index { color: var(--ink-subtle); font-variant-numeric: tabular-nums; }
30
- .json-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
31
- /* A nested object is indented under its count by a hairline, not boxed:
32
- one box, hairlines inside. */
33
- .json-group { margin: var(--space-1) 0 var(--space-2h); padding-left: var(--space-4); border-left: 1px solid var(--line); }
80
+ .json-value { grid-column: 3; min-width: 0; overflow-wrap: anywhere; }
81
+ .is-fold > .json-caret, .is-fold > .json-key, .json-summary, .json-fold-row > .json-caret { cursor: pointer; }
82
+ /* A nested level is indented under its count by a hairline, not boxed: one
83
+ box, hairlines inside, and the hairline is the guide that says which level
84
+ a line is on. */
85
+ .json-group { grid-column: 3 / -1; min-width: 0; margin-bottom: var(--space-2); padding-left: var(--space-3); border-left: 1px solid var(--line); }
86
+ /* On a phone the value column is a third of the screen: a level indents under its key instead, the value column
87
+ takes the rest of the line, and a key never takes more than two fifths of it. Size containment keeps a nested
88
+ level (a wide table, say) out of the sizing of the keys it sits under; it fills the width they leave and scrolls
89
+ inside itself past that. */
90
+ @media (max-width: 600px) {
91
+ .json-fields { grid-template-columns: var(--json-caret) fit-content(40%) minmax(0, 1fr); }
92
+ .json-group { grid-column: 2 / -1; contain: inline-size; }
93
+ }
94
+ .json-summary { color: var(--ink-muted); font: var(--text-sm)/1.65 var(--code); }
95
+
96
+ /* The node the keyboard is on, and the one under the pointer: a tint across the line, and the house ring for the keyboard. */
97
+ .json-entry:focus, .json-fold:focus, .json-tr:focus, .json-chip:focus, .json-item:focus { outline: none; }
98
+ .json-entry:focus > .json-row, .json-fold:focus > .json-fold-row, .json-tr:focus > td, .json-item:focus { background: var(--raised); }
99
+ .json-entry:focus-visible > .json-row, .json-fold:focus-visible > .json-fold-row, .json-chip:focus-visible, .json-item:focus-visible {
100
+ outline: var(--focus-width) solid var(--focus); outline-offset: 1px;
101
+ }
102
+ .json-tr:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: -1px; }
103
+
104
+ .json-fold { min-width: 0; }
105
+ .json-fold-row { display: flex; align-items: baseline; position: relative; border-radius: min(3px, var(--radius)); }
106
+ .json-fold-row > .json-caret { flex: none; width: var(--json-caret); }
107
+ .json-fold > .json-group { margin-left: calc(var(--json-caret) / 2); }
108
+
109
+ /* A node's copies: hidden, not dimmed, until its line is hovered or it is the
110
+ node the keyboard is on (docs/design.md: a row's own menu). A field's sit in
111
+ its own column; elsewhere, and on a phone where that column would cost a
112
+ third of the line, they sit over the end of the line on its own tint. Either
113
+ way showing them moves nothing. */
114
+ .json-actions {
115
+ position: absolute; top: 0; bottom: 0; right: 0; z-index: 1;
116
+ display: flex; align-items: flex-start; gap: var(--space-1); padding-left: var(--space-3);
117
+ background: var(--raised); border-radius: min(3px, var(--radius)); visibility: hidden;
118
+ }
119
+ /* Shorter than 24px, so the line's band holds them; the pair sits apart, and only one line's pair shows at a time
120
+ (WCAG 2.5.8's spacing). */
121
+ .json-row > .json-actions { position: static; grid-column: 4; align-self: start; }
122
+ @media (max-width: 600px) { .json-row > .json-actions { position: absolute; } }
123
+ .json-act {
124
+ padding: var(--space-1) var(--space-2h); border: 0; border-radius: min(3px, var(--radius));
125
+ background: transparent; color: var(--link); font: var(--text-xs)/1.4 var(--sans); white-space: nowrap; cursor: pointer;
126
+ }
127
+ .json-act:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: -1px; }
128
+ .json-entry:focus > .json-row > .json-actions,
129
+ .json-fold:focus > .json-fold-row > .json-actions,
130
+ .json-tr:focus > .json-act-cell > .json-actions,
131
+ .json-chip:focus > .json-actions,
132
+ .json-item:focus > .json-actions,
133
+ .json-actions:focus-within { visibility: visible; }
134
+ @media (hover: hover) and (pointer: fine) {
135
+ .json-row:hover, .json-fold-row:hover, .json-tr:hover > td, .json-item:hover { background: var(--raised); }
136
+ .json-row:hover > .json-actions,
137
+ .json-fold-row:hover > .json-actions,
138
+ .json-tr:hover > .json-act-cell > .json-actions,
139
+ .json-chip:hover > .json-actions,
140
+ .json-item:hover > .json-actions { visibility: visible; }
141
+ .json-tool:hover, .json-mode:hover { color: var(--ink); }
142
+ .json-tool:not([aria-pressed="true"]):hover { background: var(--raised); }
143
+ .json-act:hover { background: var(--accent-soft); }
144
+ .json-fold-row:hover > .json-summary, .is-fold:hover > .json-key { color: var(--ink); }
145
+ .json-more:hover { text-decoration: underline; }
146
+ }
34
147
 
35
- .json-fold, .json-more {
36
- background: none; border: 0; padding: 0; border-radius: min(3px, var(--radius));
37
- font: var(--text-sm)/1.65 var(--sans); cursor: pointer;
148
+ .json-more {
149
+ display: block; margin-top: var(--space-2); padding: 0; border: 0; border-radius: min(3px, var(--radius)); background: none;
150
+ color: var(--link); font: var(--text-sm)/1.65 var(--sans); cursor: pointer;
38
151
  }
39
- .json-fold { color: var(--ink-muted); }
40
- .json-fold:hover { color: var(--ink); }
41
- .json-caret { display: inline-block; width: 1.1em; color: var(--ink-subtle); }
42
- .json-more { display: block; margin-top: var(--space-2); color: var(--link); }
43
- .json-more:hover { text-decoration: underline; }
44
152
 
45
153
  /* Like records, lined up. Wide ones scroll inside themselves; the page never does. */
46
154
  .json-table-wrap { overflow-x: auto; max-width: 100%; }
47
155
  .json-table { border-collapse: collapse; font-size: var(--text-sm); }
48
156
  .json-table th {
49
- text-align: left; font: var(--text-xs)/1.5 var(--code); font-weight: normal; color: var(--ink-muted);
157
+ text-align: left; font: var(--text-xs)/1.5 var(--code); font-weight: normal; color: var(--json-key);
50
158
  padding: var(--space-1h) var(--space-4h) var(--space-1h) 0; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
51
159
  }
52
160
  .json-table td {
53
161
  padding: var(--space-2) var(--space-4h) var(--space-2) 0; border-bottom: 1px solid var(--line);
54
162
  vertical-align: top; max-width: 24rem; overflow-wrap: anywhere;
55
163
  }
164
+ .json-table :is(th, td).json-figures { text-align: right; }
165
+ /* The row's copies hang from a column of no width at its end, over the row's last cells. */
166
+ .json-table :is(th, td).json-act-cell { position: relative; width: 0; padding: 0; }
167
+ .json-act-cell > .json-actions { top: var(--space-1); bottom: auto; }
56
168
 
57
169
  .json-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
58
170
  .json-chip {
59
- border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised);
171
+ position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised);
60
172
  padding: 0 var(--space-3); font-size: var(--text-sm); line-height: 1.65;
61
173
  }
174
+ /* A chip is too short to cover: its copies drop below it, a popover's box. */
175
+ .json-chip > .json-actions {
176
+ top: calc(100% + var(--space-1)); bottom: auto; left: 0; right: auto; padding: var(--space-1);
177
+ background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop);
178
+ }
62
179
  .json-lines { margin: 0; padding-left: 2em; }
180
+ .json-item { position: relative; border-radius: min(3px, var(--radius)); }
63
181
  .json-lines li::marker { color: var(--ink-subtle); font: var(--text-xs) var(--code); }
64
182
 
65
- .json-number, .json-date { font-variant-numeric: tabular-nums; }
66
- .json-table :is(th, td).json-figures { text-align: right; }
67
- .json-number { font-family: var(--mono); }
68
- .json-null, .json-empty { color: var(--ink-subtle); }
69
- .json-empty { font-family: var(--code); }
70
- .json-bool {
71
- display: inline-block; padding: 0 var(--space-3); border-radius: 999px;
72
- font-size: var(--text-xs); line-height: 1.65; background: var(--raised); color: var(--ink-muted);
73
- }
74
- .json-bool.yes { background: var(--accent-soft); color: var(--accent-ink); }
183
+ /* ---------- values, by type ---------- */
184
+
185
+ .json-text { color: var(--json-string); }
186
+ /* Prose is read, not scanned: a paragraph stays in the text's own ink. */
187
+ .json-long { display: block; white-space: pre-wrap; color: var(--ink); }
188
+ .json-code { font: var(--text-sm) var(--code); }
189
+ .json-number { color: var(--json-number); font-family: var(--mono); font-variant-numeric: tabular-nums; }
190
+ .json-date { font-variant-numeric: tabular-nums; }
191
+ .json-bool { color: var(--json-literal); font: var(--text-sm) var(--code); }
192
+ .json-null { color: var(--json-null); font: var(--text-sm) var(--code); }
193
+ .json-empty { color: var(--ink-subtle); font-family: var(--code); }
75
194
  .json-link { color: var(--link); overflow-wrap: anywhere; }
76
- .json-long { display: block; white-space: pre-wrap; }
195
+ /* A hex color carries a swatch of itself, edged so white on white and black on black still show. */
196
+ .json-swatch {
197
+ display: inline-block; width: 0.8em; height: 0.8em; margin-right: var(--space-2); vertical-align: -0.05em;
198
+ border: 1px solid var(--line-strong); border-radius: min(2px, var(--radius));
199
+ }
200
+ /* A match: the warm hue a change from elsewhere is said in (--changed-hue), lightly, under the text's own ink. */
201
+ .json-mark { background: color-mix(in srgb, var(--changed-hue) 32%, transparent); color: inherit; border-radius: min(2px, var(--radius)); }
202
+
203
+ /* ---------- raw ---------- */
77
204
 
78
205
  .json-raw {
79
206
  margin: 0; padding: var(--space-3) var(--space-3h); max-height: 24rem; overflow: auto;
80
- font: var(--text-sm)/1.55 var(--code); white-space: pre; tab-size: 2;
207
+ font: var(--text-sm)/1.55 var(--code); white-space: pre; tab-size: 2; color: var(--ink);
81
208
  background: var(--ground); border: 1px solid var(--line); border-radius: var(--radius);
82
209
  }
210
+ .json-raw.is-wrapped { white-space: pre-wrap; overflow-wrap: anywhere; }
83
211
  .json-raw:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: -1px; }
84
-
85
- /* In a grid cell: the shape in one quiet line, the whole cell a button. */
86
- .json-preview {
87
- display: block; width: 100%; padding: 0; border: 0; border-radius: 0; background: none;
88
- text-align: left; font: var(--text-sm)/inherit var(--code); color: var(--ink-muted);
89
- white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
212
+ /* Each line's number in a gutter as wide as the last one's: generated
213
+ content, so a selection and a copy never take it. */
214
+ .json-line { display: block; position: relative; padding-left: calc((var(--json-digits, 2) + 2) * 1ch); }
215
+ .json-line::before {
216
+ content: attr(data-n); position: absolute; left: 0; width: calc(var(--json-digits, 2) * 1ch);
217
+ text-align: right; color: var(--ink-subtle); opacity: 0.85; user-select: none;
90
218
  }
91
- .json-preview:hover { color: var(--link); }
92
- .json-preview:focus-visible { outline-offset: -2px; }
93
- .json-preview-text { font: var(--text-sm) var(--code); color: var(--ink-muted); }
219
+ /* In the text, the keys are its frame: the ink, with the punctuation receding behind them. */
220
+ .json-t-key { color: var(--ink); }
221
+ .json-t-string { color: var(--json-string); }
222
+ .json-t-number { color: var(--json-number); }
223
+ .json-t-boolean { color: var(--json-literal); }
224
+ .json-t-null, .json-t-punct { color: var(--json-null); }
225
+
226
+ /* ---------- the overlay ---------- */
94
227
 
95
- /* The overlay is the confirm dialog's box and scrim, at a document's width. */
96
- .json-overlay { width: min(60rem, calc(100vw - 2rem)); max-width: none; max-height: 85vh; }
228
+ /* The confirm dialog's box and scrim, at a document's width; its bar is the
229
+ dialog's head (the title, the filter, the tools, Close) and stays put while
230
+ a long document scrolls under it. */
231
+ .json-overlay { width: min(72rem, calc(100vw - 2rem)); max-width: none; max-height: 85vh; overflow: auto; padding-top: 0; }
97
232
  .json-overlay .json-view { max-width: none; }
98
- .json-overlay .json-raw { max-height: 60vh; }
99
- .json-overlay-head { display: flex; align-items: baseline; gap: var(--space-3h); margin-bottom: var(--space-3h); }
100
- .json-overlay-head h2 { margin: 0; font: 600 calc(15px * var(--type-k))/1.4 var(--sans); overflow-wrap: anywhere; }
233
+ .json-overlay .json-bar {
234
+ position: sticky; top: 0; z-index: 2; margin-bottom: var(--space-3h);
235
+ padding: var(--space-5) 0 var(--space-3); background: var(--surface); border-bottom: 1px solid var(--line);
236
+ }
237
+ .json-overlay .json-raw { max-height: none; }
238
+ .json-overlay-title { display: flex; align-items: baseline; gap: var(--space-3h); min-width: 0; }
239
+ .json-overlay-title h2 { margin: 0; font: 600 calc(15px * var(--type-k))/1.4 var(--sans); overflow-wrap: anywhere; }
101
240
  .json-overlay-type { color: var(--ink-subtle); font: var(--text-xs) var(--code); }
102
- .json-overlay-close { margin-left: auto; padding: var(--space-1h) var(--space-3h); font-size: var(--text-sm); }
241
+ .json-overlay-close { padding: var(--space-1h) var(--space-3h); font-size: var(--text-sm); }
103
242
 
104
243
  @media (prefers-reduced-motion: no-preference) {
105
- .json-tool, .json-fold, .json-preview {
244
+ .json-tool, .json-mode, .json-act, .json-row, .json-fold-row {
106
245
  transition: color var(--t-hover) var(--ease-out), background-color var(--t-hover) var(--ease-out);
107
246
  }
108
247
  }
@@ -1,4 +1,46 @@
1
- export declare function JsonView({ value, bar }: {
1
+ /**
2
+ * A JSON document, laid out by its shape.
3
+ *
4
+ * jsonModel.ts decides what each part is best shown as; this draws it: an
5
+ * object as quiet labels beside their values, like records as a table,
6
+ * words as chips. Two levels open and deeper ones folded behind a count,
7
+ * long arrays a page at a time — so a document of any size reads top-down
8
+ * instead of as one line of braces. Raw is the text itself, pretty-printed
9
+ * and tinted, for the reader who wants the braces; Copy takes that text.
10
+ *
11
+ * What a developer's viewer gives, it gives too, without giving up the
12
+ * layout: a filter over keys and values that marks each match and opens
13
+ * whatever holds one; Expand all and Collapse all; each node's value and
14
+ * path (`data.lines[2].sku`) a click or a key away; values tinted by type,
15
+ * quietly, from the tokens (a hex color with its swatch, an id in the code
16
+ * face).
17
+ *
18
+ * The keyboard's tree pattern (APG), as TreeList.tsx has it: the document is
19
+ * one `role="tree"` and one Tab stop, the node last visited. Up and Down move
20
+ * through what is open, Right opens a node or steps into it, Left folds it or
21
+ * steps out to its parent, Home and End go to the ends, Enter and Space fold.
22
+ * Every key, value, row and item is a `treeitem` with its level, its place
23
+ * among its siblings and, when it holds something, `aria-expanded`; its name
24
+ * is said for it (`city: London`), so a folded branch is never read out
25
+ * whole. The tree rather than the description list and table it draws:
26
+ * those name a pair or a cell, but not where it is, whether it opens, or
27
+ * how to get back out — and a reader moving by key needs all three. A table
28
+ * row's name carries its column names, so nothing the header said is lost.
29
+ * The current node's own controls (Copy value, Copy path, a link) are the
30
+ * Tab stops after it; every other node's wait until it is current.
31
+ *
32
+ * Read-only on purpose: a document is changed by the statement that owns
33
+ * it, not by a box pretending a tree is a line of text.
34
+ */
35
+ import './JsonView.css';
36
+ import { type ReactNode } from 'react';
37
+ export declare function JsonView({ value, bar, label, head, tail, }: {
2
38
  value: object;
39
+ /** False for a list of plain values (Value.tsx): its words with neither the bar nor a node's copies over them. */
3
40
  bar?: boolean;
41
+ /** The tree's name: the field's or the column's, where there is one. */
42
+ label?: string;
43
+ /** Drawn at the start of the bar, and at its end: the overlay's title and its Close. */
44
+ head?: ReactNode;
45
+ tail?: ReactNode;
4
46
  }): import("react").JSX.Element;