@mistriwork/kit 1.0.0-rc.40 → 1.0.0-rc.41

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.
@@ -8,7 +8,7 @@ export function DashboardNote({ title, text, icon, action, row, variant, eyebrow
8
8
  const navigate = useListNavigation();
9
9
  /* A call to action into another App of the suite is the App framework's (shellMode.ts): none where the shell has none. */
10
10
  const { TargetAction } = shell().slots;
11
- const link = action && 'view' in action ? navigate?.(action.view) : undefined;
11
+ const link = action && 'view' in action ? navigate?.(action.view, 'push', { tab: action.tab }) : undefined;
12
12
  const paragraphs = text
13
13
  .split(/\n\s*\n/)
14
14
  .map((paragraph) => paragraph.trim())
@@ -55,7 +55,7 @@ import { fontLoaded, textMeasure } from './textMeasure.js';
55
55
  import { presentationColumns } from './columnPresentation.js';
56
56
  import { usePins } from './usePins.js';
57
57
  import { useStickyHead } from './useStickyHead.js';
58
- import { fitGridColumns, keepFitting, tagsThatFit, twoLineWidth, GRID_EXPANDER_WIDTH, GRID_HEAD_CHAR, GRID_SIZE_SAMPLE, GRID_TRAIL_WIDTH, } from './gridSizing.js';
58
+ import { fitGridColumns, keepFitting, tagsThatFit, twoLineWidth, GRID_EXPANDER_WIDTH, GRID_HEAD_CHAR, GRID_SIZE_SAMPLE, holdFold, GRID_TRAIL_WIDTH, } from './gridSizing.js';
59
59
  import { applyColumnOrder, applyColumnWidths, clampColumnWidth, columnResizeStep, MIN_COLUMN_WIDTH, moveColumn } from './gridArrange.js';
60
60
  import { VISUAL_THEME_EVENT } from '../visualTheme.js';
61
61
  import { JsonPreview } from './JsonPreview.js';
@@ -79,6 +79,11 @@ const HEAD_CONTROL = 24;
79
79
  /** A device that cannot hover keeps a head's caret and moves in the head's flow, beside its label (style.css). */
80
80
  const touchHeads = () => typeof matchMedia === 'function' && matchMedia('(hover: none)').matches;
81
81
  /** A group's value as the folded set and the head's identity hold it: the rows with no value are one group. */
82
+ /** Two measured records alike, so a measure that found nothing new sets no state and draws nothing again. */
83
+ const sameRecord = (a, b) => {
84
+ const keys = Object.keys(a);
85
+ return keys.length === Object.keys(b).length && keys.every((key) => key in b && a[key] === b[key]);
86
+ };
82
87
  const groupKey = (value) => (value === null || value === undefined ? '\u0000' : String(value));
83
88
  /** Beyond a few hundred rows the DOM, not the database, is the bottleneck. */
84
89
  const VIRTUAL_THRESHOLD = 300;
@@ -510,12 +515,14 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
510
515
  /* The fonts the first row's cells set in, one per cell, so a column is sized
511
516
  by what its words measure there rather than a count of their characters
512
517
  (gridSizing.ts). Per cell: a look sets the first column heavier, and
513
- measured in the others' weight its names ran past the width they got. */
514
- const [cellFonts, setCellFonts] = useState([]);
518
+ measured in the others' weight its names ran past the width they got. By column name, read off the head above
519
+ each cell: the cells drawn are the columns kept and in the reader's order, and read by position against the
520
+ asked columns a fold moved every later column's font and chip onto its neighbour (a field report). */
521
+ const [cellFonts, setCellFonts] = useState({});
515
522
  /* What a tone chip in the first row draws beyond its words, per cell (its dot, gap, padding): a look that says a
516
523
  status as a pill spends 41px there, one that says it as a dot and a word 12, and sizing every column for the
517
524
  wider kept 30px of every table's room in a status that never used it. -1: the cell holds no chip. */
518
- const [cellChips, setCellChips] = useState([]);
525
+ const [cellChips, setCellChips] = useState({});
519
526
  /* Counts the times a face arrived after the columns were sized in its fallback: the sizes are read again, once for
520
527
  each, so a table's columns never stay as the fallback face set them (textMeasure.ts). */
521
528
  const [faceEpoch, setFaceEpoch] = useState(0);
@@ -550,7 +557,9 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
550
557
  setHeadFace((was) => (was && was.font === next.font && was.upper === next.upper && was.tracking === next.tracking ? was : next));
551
558
  }
552
559
  /* A group's head is not a row of values: the first row that is one is sampled. */
553
- const first = element.querySelector('tbody tr:not(.grid-group-head)');
560
+ const valueRowSelector = 'tbody tr:not(.grid-group-head):not(.virtual-spacer):not(.grid-totals)';
561
+ const first = element.querySelector(valueRowSelector);
562
+ const heads = [...(element.querySelector('thead tr')?.children ?? [])].map((th) => th.getAttribute('data-col'));
554
563
  const cells = first ? [...first.querySelectorAll(':scope > td')] : [];
555
564
  if (cells.length) {
556
565
  const fonts = cells.map((cell) => {
@@ -558,10 +567,12 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
558
567
  return `${font.fontStyle} ${font.fontWeight} ${font.fontSize} ${font.fontFamily}`;
559
568
  });
560
569
  sizedInFallback = sizedInFallback || !fonts.every(fontLoaded);
561
- setCellFonts((was) => (was.join('|') === fonts.join('|') ? was : fonts));
570
+ const byColumn = (values) => Object.fromEntries(heads.flatMap((name, index) => (name && values[index] !== undefined ? [[name, values[index]]] : [])));
571
+ const named = byColumn(fonts);
572
+ setCellFonts((was) => (sameRecord(was, named) ? was : named));
562
573
  /* The widest chip of the sampled rows, not the first row's: a look may draw a neutral state as a bare word
563
574
  and the rest as pills, and sized by a first-row "Ready" Sage cut every "In review" pill to "In rev…". */
564
- const rows = [...element.querySelectorAll('tbody tr:not(.grid-group-head)')].slice(0, GRID_SIZE_SAMPLE);
575
+ const rows = [...element.querySelectorAll(valueRowSelector)].slice(0, GRID_SIZE_SAMPLE);
565
576
  const chips = cells.map((_, index) => {
566
577
  let extra = -1;
567
578
  for (const row of rows) {
@@ -576,8 +587,12 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
576
587
  /* A row with no chip in the cell (a sort moved the empty ones to the top) keeps what was known: the
577
588
  columns must not move because of which row happens to be first. */
578
589
  setCellChips((was) => {
579
- const next = chips.map((extra, index) => (extra >= 0 ? extra : (was[index] ?? -1)));
580
- return was.join('|') === next.join('|') ? was : next;
590
+ const next = { ...was };
591
+ heads.forEach((name, index) => {
592
+ if (name && (chips[index] ?? -1) >= 0)
593
+ next[name] = chips[index];
594
+ });
595
+ return sameRecord(was, next) ? was : next;
581
596
  });
582
597
  }
583
598
  };
@@ -630,7 +645,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
630
645
  label: byName.get(name)?.primaryKey && !shell().inApp() ? `${label} ${say('common.key')}` : label,
631
646
  title: name === titleName,
632
647
  avatar: Boolean(display?.avatar),
633
- chipExtra: (cellChips[asked.indexOf(name) + shift] ?? -1) >= 0 ? cellChips[asked.indexOf(name) + shift] : undefined,
648
+ chipExtra: cellChips[name],
634
649
  kind: labelColumn ? 'text' : plan.kind,
635
650
  controls: language || Boolean(byName.get(name)?.primaryKey || byName.get(name)?.references),
636
651
  /* A reference's arrow stands beside its label in the sort (the head, below), after the sort's 4px gap:
@@ -701,19 +716,36 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
701
716
  titleName,
702
717
  headFace,
703
718
  cellChips,
704
- shift,
705
719
  faceEpoch,
706
720
  ownLines,
707
721
  ]);
708
- /* Column i's cell follows the expander's when there is one. */
709
- const measureText = useMemo(() => cellFonts.length
710
- ? (text, column) => textMeasure(cellFonts[Math.min(column + (slotted ? 1 : 0), cellFonts.length - 1)])?.(text) ?? text.length * 8
711
- : undefined, [cellFonts, slotted, faceEpoch]);
722
+ /* A column's words in its own cell's font. The sizing reads a column by its place in the list it was handed: the
723
+ asked columns when it decides what folds, the drawn ones in the reader's order when it fits them. A column not
724
+ yet drawn (folded) measures in the first one's font. */
725
+ const measureIn = useCallback((names) => {
726
+ const fallback = Object.values(cellFonts)[0];
727
+ return fallback === undefined
728
+ ? undefined
729
+ : (text, column) => textMeasure(cellFonts[names[column] ?? ''] ?? fallback)?.(text) ?? text.length * 8;
730
+ },
731
+ /* faceEpoch: a face that arrived measures again under the same font string. */
732
+ [cellFonts, faceEpoch]);
733
+ const measureAsked = useMemo(() => measureIn(asked), [measureIn, asked]);
712
734
  /* An App's own list folds the columns its room cannot hold under the row's name, as a detail line, once its heads
713
735
  and words have wrapped (gridSizing.ts): they are moved, not lost, and the list does not scroll sideways. An
714
736
  embedded grid leaves them out, as it did. */
715
737
  const folds = !dropColumns && sizing === 'fit' && shell().inApp();
716
- const kept = useMemo(() => (dropColumns || folds) && sizing === 'fit' ? keepFitting(sizeHints, availableWidth, slotted, trailing, headChar, measureText) : null, [dropColumns, folds, sizing, sizeHints, availableWidth, slotted, trailing, headChar, measureText]);
738
+ /* What folded, and the width it folded at (gridSizing.ts holdFold): a fold changes the rows' height, and the
739
+ scrollbar that brings or takes away must not unfold it again. */
740
+ const foldHeld = useRef(null);
741
+ const kept = useMemo(() => {
742
+ if (!((dropColumns || folds) && sizing === 'fit'))
743
+ return null;
744
+ const next = keepFitting(sizeHints, availableWidth, slotted, trailing, headChar, measureAsked);
745
+ const decided = holdFold(foldHeld.current, next, availableWidth, [asked.join('\u0000'), rows]);
746
+ foldHeld.current = decided.held;
747
+ return decided.kept;
748
+ }, [dropColumns, folds, sizing, sizeHints, availableWidth, slotted, trailing, headChar, measureAsked, asked, rows]);
717
749
  const drawn = useMemo(() => (kept ? asked.filter((_, index) => kept[index]) : asked), [asked, kept]);
718
750
  const drawnHints = useMemo(() => (kept ? sizeHints.filter((_, index) => kept[index]) : sizeHints), [sizeHints, kept]);
719
751
  /* The reader's arrangement, over the drawn columns (gridArrange.ts): an
@@ -724,7 +756,8 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
724
756
  const [columnWidths, setColumnWidths] = useState({});
725
757
  const ordered = useMemo(() => applyColumnOrder(drawn, columnOrder), [drawn, columnOrder]);
726
758
  const orderedHints = useMemo(() => ordered.map((name) => drawnHints[drawn.indexOf(name)]), [ordered, drawn, drawnHints]);
727
- const fit = useMemo(() => fitGridColumns(orderedHints, availableWidth, slotted, trailing, headChar, measureText, dropColumns), [orderedHints, availableWidth, slotted, trailing, headChar, measureText, dropColumns]);
759
+ const measureOrdered = useMemo(() => measureIn(ordered), [measureIn, ordered]);
760
+ const fit = useMemo(() => fitGridColumns(orderedHints, availableWidth, slotted, trailing, headChar, measureOrdered, dropColumns), [orderedHints, availableWidth, slotted, trailing, headChar, measureOrdered, dropColumns]);
728
761
  /* A dragged width stands in place of its fitted one. A scrolled grid has
729
762
  no colgroup until a width is dragged: then it takes one, and the fixed
730
763
  layout that makes a dragged width hold, with the fitted widths for the
@@ -22,7 +22,9 @@
22
22
  --json-punct: var(--ink-subtle);
23
23
  /* The caret's gutter: every key at a level starts on one line, folding or not. */
24
24
  --json-caret: 1.15em;
25
- min-width: 0; max-width: 70rem; font: var(--text-base)/1.55 var(--sans); color: var(--ink);
25
+ /* The field's whole width: a document's tables and long values are cut short by a measure, and a field report
26
+ read a 1120px cap as the viewer being broken on a wide screen. */
27
+ min-width: 0; font: var(--text-base)/1.55 var(--sans); color: var(--ink);
26
28
  }
27
29
 
28
30
  /* ---------- the bar ---------- */
@@ -229,7 +231,6 @@
229
231
  dialog's head (the title, the filter, the tools, Close) and stays put while
230
232
  a long document scrolls under it. */
231
233
  .json-overlay { width: min(72rem, calc(100vw - 2rem)); max-width: none; max-height: 85vh; overflow: auto; padding-top: 0; }
232
- .json-overlay .json-view { max-width: none; }
233
234
  .json-overlay .json-bar {
234
235
  position: sticky; top: 0; z-index: 2; margin-bottom: var(--space-3h);
235
236
  padding: var(--space-5) 0 var(--space-3); background: var(--surface); border-bottom: 1px solid var(--line);
@@ -3,6 +3,6 @@ import { useListNavigation } from './listNavigation.js';
3
3
  import { Empty } from './Notes.js';
4
4
  export function ListEmpty({ spec }) {
5
5
  const navigate = useListNavigation();
6
- const link = spec.action ? navigate?.(spec.action.view, 'reset') : undefined;
6
+ const link = spec.action ? navigate?.(spec.action.view, 'reset', { tab: spec.action.tab }) : undefined;
7
7
  return (_jsx(Empty, { className: "list-empty", text: _jsx("span", { className: "empty-note-title", children: spec.title }), detail: spec.description, action: spec.action && link ? _jsx("a", { ...link, children: spec.action.label }) : undefined }));
8
8
  }
@@ -66,7 +66,7 @@ export function PageHeadline({ tableId, row, paths, column, actions, subfigure,
66
66
  /* A call to action into another App of the suite, and a public form over the record, are the App framework's:
67
67
  the shell's to draw (shellMode.ts), and not drawn where it has none. */
68
68
  const { TargetAction, FormDialog } = shell().slots;
69
- const rooms = actions.map((action) => ('view' in action ? viewLink(action.view) : undefined));
69
+ const rooms = actions.map((action) => ('view' in action ? viewLink(action.view, 'push', { tab: action.tab }) : undefined));
70
70
  const signedIn = sessionIdentity().mode === 'authenticated';
71
71
  const forms = useQuery({
72
72
  queryKey: ['public-forms', state.activeConnection ?? ''],
@@ -5,6 +5,8 @@ interface Tab {
5
5
  key: string | number;
6
6
  token: string;
7
7
  label: ReactNode;
8
+ /** Folds under More before the others (useTabFold.ts): a list with no rows, kept for its Add. */
9
+ yields?: true;
8
10
  }
9
11
  /** Names across the top, one panel under them, each panel drawn the first time it is opened (or at once, where `eager`). */
10
12
  export declare function TabStrip({ tabs, name, entry, onTab, draw, scoped, eager, className, }: {
@@ -176,7 +176,8 @@ export function TabStrip({ tabs, name, entry, onTab, draw, scoped, eager = [], c
176
176
  const [drawn, setDrawn] = useState(() => new Set([asked === -1 ? 0 : asked, ...eager]));
177
177
  const buttons = useRef([]);
178
178
  /* The tabs that do not fit go under More (useTabFold.ts); the chosen one is never among them. */
179
- const { strip, folded } = useTabFold(tabs.length, active);
179
+ const yields = new Set(tabs.flatMap((tab, i) => (tab.yields ? [i] : [])));
180
+ const { strip, folded } = useTabFold(tabs.length, active, yields);
180
181
  /* A tab reached by the keyboard may have been under More: it is focused once the fold has made room for it. */
181
182
  const focusing = useRef(undefined);
182
183
  useEffect(() => {
@@ -216,14 +217,19 @@ function ListTabs({ items: run, plans, base, recordKey, entry, onTab, draw, scop
216
217
  asking about is left out until it is known, so a tab arrives rather than goes. */
217
218
  const hiding = (item) => item.section.kind === 'list' && item.section.emptyMode === 'hide';
218
219
  const standing = useStandings(run, plans, base, recordKey, hiding);
220
+ /* One kept only for its Add is the first to wait under More, so a list with rows keeps its place in the row. */
221
+ const forTheDoor = new Set();
219
222
  const items = run.filter((item, i) => {
220
223
  const hides = hiding(item);
221
224
  if (standing[i] === 'gone')
222
225
  return false;
223
226
  if (standing[i] === 'wait')
224
227
  return !item.section.when && !hides;
225
- if (standing[i] === 'empty' && hides)
226
- return Boolean(relatedDoor(item.section, base, recordKey, { preview: context.preview, actions: context.actions }).door);
228
+ if (standing[i] === 'empty' && hides) {
229
+ if (!relatedDoor(item.section, base, recordKey, { preview: context.preview, actions: context.actions }).door)
230
+ return false;
231
+ forTheDoor.add(item);
232
+ }
227
233
  return true;
228
234
  });
229
235
  /* The token is the source's words (apps.ts keepAddresses), so an address names one tab in every language. */
@@ -242,6 +248,7 @@ function ListTabs({ items: run, plans, base, recordKey, entry, onTab, draw, scop
242
248
  // Read as the strip renders: the run is still being gathered when the strip is created.
243
249
  const tabs = items.map((item) => ({
244
250
  key: item.index,
251
+ ...(forTheDoor.has(item) ? { yields: true } : {}),
245
252
  token: scoped ? `section:${item.index}` : named(item),
246
253
  label: (_jsxs(_Fragment, { children: [word(item), counted(item)] })),
247
254
  }));
@@ -82,6 +82,23 @@ export declare function columnSizeHint(column: GridColumnSize, headChar?: number
82
82
  * the room is measured.
83
83
  */
84
84
  export declare function keepFitting(columns: GridColumnSize[], available: number, expandable?: boolean, trailing?: boolean, headChar?: number, measure?: (text: string, column: number) => number): boolean[] | null;
85
+ /** A fold decided: what it kept, at what width, for which columns and rows (`of`, compared by identity). */
86
+ export interface FoldHeld {
87
+ kept: boolean[];
88
+ width: number;
89
+ of: readonly unknown[];
90
+ }
91
+ /**
92
+ * The columns an App's list keeps, held against its own scrollbar. A fold changes the rows' height, and with it the
93
+ * page's scrollbar: the room a scrollbar gave back unfolded the columns, whose taller rows took the scrollbar again,
94
+ * and the list re-laid itself out without end (a field report). A folded column comes back only once the room grows
95
+ * past a scrollbar's width from where it folded; a narrower room folds at once, and other columns or other rows are
96
+ * sized afresh.
97
+ */
98
+ export declare function holdFold(held: FoldHeld | null, next: boolean[] | null, width: number, of: readonly unknown[]): {
99
+ kept: boolean[] | null;
100
+ held: FoldHeld | null;
101
+ };
85
102
  export declare function fitGridColumns(columns: GridColumnSize[], available: number, expandable?: boolean, trailing?: boolean, headChar?: number, measure?: (text: string, column: number) => number, squeezeName?: boolean): {
86
103
  width: number;
87
104
  columns: number[];
@@ -230,6 +230,25 @@ export function keepFitting(columns, available, expandable = false, trailing = f
230
230
  });
231
231
  return kept;
232
232
  }
233
+ /* Wider than any scrollbar a browser draws, so the one a fold brings or takes away never unfolds what it folded. */
234
+ const FOLD_SLACK = 24;
235
+ /**
236
+ * The columns an App's list keeps, held against its own scrollbar. A fold changes the rows' height, and with it the
237
+ * page's scrollbar: the room a scrollbar gave back unfolded the columns, whose taller rows took the scrollbar again,
238
+ * and the list re-laid itself out without end (a field report). A folded column comes back only once the room grows
239
+ * past a scrollbar's width from where it folded; a narrower room folds at once, and other columns or other rows are
240
+ * sized afresh.
241
+ */
242
+ export function holdFold(held, next, width, of) {
243
+ const same = held !== null && held.of.length === of.length && held.of.every((part, index) => part === of[index]);
244
+ if (same && width >= held.width && width < held.width + FOLD_SLACK) {
245
+ const unfolds = next === null || next.some((keep, index) => keep && !held.kept[index]);
246
+ const foldsMore = next !== null && next.some((keep, index) => !keep && held.kept[index]);
247
+ if (unfolds && !foldsMore)
248
+ return { kept: held.kept, held };
249
+ }
250
+ return { kept: next, held: next ? { kept: next, width, of } : null };
251
+ }
233
252
  /* Room past the minima goes first to the columns still cut short — an issue
234
253
  title at "Preserve filters when op…" beside a "Cycle 18" column holding
235
254
  twice its text's width — and only then, evenly, to everyone. Long text
@@ -5,7 +5,9 @@ interface ListNavigationLink {
5
5
  href: string;
6
6
  onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
7
7
  }
8
- type ListNavigation = (view: string, mode?: 'push' | 'reset') => ListNavigationLink | undefined;
8
+ type ListNavigation = (view: string, mode?: 'push' | 'reset', opened?: {
9
+ tab?: string;
10
+ }) => ListNavigationLink | undefined;
9
11
  /** The client shell supplies routing once; isolated hosts can pass it directly. */
10
12
  export declare function setListNavigation(navigate: ListNavigation): void;
11
13
  export declare function ListNavigationProvider({ navigate, children }: {
@@ -12,9 +12,11 @@
12
12
  import { type RefObject } from 'react';
13
13
  /**
14
14
  * Which items are shown: as many as fit in order, with room left for More where any do not, and the chosen one always
15
- * among them (the last that fit give way to it). `widths` are each item's own, `gap` the space between two.
15
+ * among them (the last that fit give way to it). `widths` are each item's own, `gap` the space between two. Those in
16
+ * `yields` give way first, whatever their place: an empty list kept only for its Add folds before one that has rows (a
17
+ * field report's Attachments waited under More behind four empty tabs).
16
18
  */
17
- export declare function foldTabs(widths: readonly number[], room: number, more: number, gap: number, active: number): number[];
19
+ export declare function foldTabs(widths: readonly number[], room: number, more: number, gap: number, active: number, yields?: ReadonlySet<number>): number[];
18
20
  /**
19
21
  * The least a strip can be drawn at and still hold what it never folds: the chosen tab and, beside it, More, the gap
20
22
  * between them (no more than every tab takes). Narrower, the chosen tab ran under More: Compass's contacts at 320px drew
@@ -26,7 +28,7 @@ export declare function leastStrip(widths: readonly number[], more: number, gap:
26
28
  * whose gap is the strip's, and its More wears `data-fold-more`; `active` is the chosen tab's index, `count` how many.
27
29
  * Returns the ref for the strip and the indices folded under More.
28
30
  */
29
- export declare function useTabFold(count: number, active: number): {
31
+ export declare function useTabFold(count: number, active: number, yields?: ReadonlySet<number>): {
30
32
  strip: RefObject<HTMLDivElement | null>;
31
33
  folded: ReadonlySet<number>;
32
34
  };
@@ -14,9 +14,11 @@ import { flushSync } from 'react-dom';
14
14
  import { viewportBox } from '../core.js';
15
15
  /**
16
16
  * Which items are shown: as many as fit in order, with room left for More where any do not, and the chosen one always
17
- * among them (the last that fit give way to it). `widths` are each item's own, `gap` the space between two.
17
+ * among them (the last that fit give way to it). `widths` are each item's own, `gap` the space between two. Those in
18
+ * `yields` give way first, whatever their place: an empty list kept only for its Add folds before one that has rows (a
19
+ * field report's Attachments waited under More behind four empty tabs).
18
20
  */
19
- export function foldTabs(widths, room, more, gap, active) {
21
+ export function foldTabs(widths, room, more, gap, active, yields = NONE) {
20
22
  const all = widths.map((_, i) => i);
21
23
  const span = (items) => items.reduce((sum, i) => sum + widths[i], 0) + gap * Math.max(0, items.length - 1);
22
24
  if (span(all) <= room)
@@ -24,7 +26,7 @@ export function foldTabs(widths, room, more, gap, active) {
24
26
  /* More stands after the shown ones, a gap before it. */
25
27
  const budget = room - more - gap;
26
28
  const shown = [];
27
- for (const i of all) {
29
+ for (const i of [...all.filter((i) => !yields.has(i)), ...all.filter((i) => yields.has(i))]) {
28
30
  if (span([...shown, i]) > budget)
29
31
  break;
30
32
  shown.push(i);
@@ -34,7 +36,7 @@ export function foldTabs(widths, room, more, gap, active) {
34
36
  shown.pop();
35
37
  shown.push(active);
36
38
  }
37
- return shown;
39
+ return shown.sort((a, b) => a - b);
38
40
  }
39
41
  /**
40
42
  * The least a strip can be drawn at and still hold what it never folds: the chosen tab and, beside it, More, the gap
@@ -53,11 +55,12 @@ const SLACK = 0.5;
53
55
  * whose gap is the strip's, and its More wears `data-fold-more`; `active` is the chosen tab's index, `count` how many.
54
56
  * Returns the ref for the strip and the indices folded under More.
55
57
  */
56
- export function useTabFold(count, active) {
58
+ export function useTabFold(count, active, yields = NONE) {
57
59
  const strip = useRef(null);
58
60
  const [folded, setFolded] = useState(NONE);
59
- const latest = useRef({ active, folded });
60
- latest.current = { active, folded };
61
+ const latest = useRef({ active, folded, yields });
62
+ latest.current = { active, folded, yields };
63
+ const yielding = [...yields].join();
61
64
  useLayoutEffect(() => {
62
65
  const box = strip.current;
63
66
  if (!box)
@@ -82,7 +85,7 @@ export function useTabFold(count, active) {
82
85
  if (room <= 0)
83
86
  return;
84
87
  const moreWidth = more ? viewportBox(more).width : 0;
85
- const shown = new Set(foldTabs(widths, room + SLACK, moreWidth, gap, latest.current.active));
88
+ const shown = new Set(foldTabs(widths, room + SLACK, moreWidth, gap, latest.current.active, latest.current.yields));
86
89
  const next = new Set(widths.map((_, i) => i).filter((i) => !shown.has(i)));
87
90
  /* For a row that sizes the strip by its content (a list's controls): with nothing folded the strip is its tabs'
88
91
  width on its own; with some folded it goes on asking for every tab's, so it gives way only where the row
@@ -139,7 +142,7 @@ export function useTabFold(count, active) {
139
142
  cancelAnimationFrame(frame);
140
143
  watch.disconnect();
141
144
  };
142
- }, [count, active]);
145
+ }, [count, active, yielding]);
143
146
  return { strip, folded };
144
147
  }
145
148
  const NONE = new Set();
@@ -14,8 +14,14 @@ export interface ViewLink {
14
14
  href: string;
15
15
  onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
16
16
  }
17
- /** A list, dashboard or signed-in form this reader is served, by key. `adding` opens a list with its New form over it (`…!new`). */
18
- export declare function viewLink(key: string, mode?: 'push' | 'reset', adding?: boolean): ViewLink | undefined;
17
+ /**
18
+ * A list, dashboard or signed-in form this reader is served, by key. `adding` opens a list with its New form over it
19
+ * (`…!new`); `tab` opens it on one of its tabs (`?tab=`), the list that address opens, as `to: { view, tab }` says.
20
+ */
21
+ export declare function viewLink(key: string, mode?: 'push' | 'reset', opened?: {
22
+ adding?: boolean;
23
+ tab?: string;
24
+ }): ViewLink | undefined;
19
25
  /**
20
26
  * One of the App's lists on a refinement of its rows, as a dashboard group opens it: the list's own parameter where
21
27
  * it offers the column as a filter (`?status=approved`), `q=` for what those cannot say. Undefined for a key this
@@ -24,16 +24,21 @@ function linkTo(entry, mode) {
24
24
  },
25
25
  };
26
26
  }
27
- /** A list, dashboard or signed-in form this reader is served, by key. `adding` opens a list with its New form over it (`…!new`). */
28
- export function viewLink(key, mode = 'push', adding = false) {
27
+ /**
28
+ * A list, dashboard or signed-in form this reader is served, by key. `adding` opens a list with its New form over it
29
+ * (`…!new`); `tab` opens it on one of its tabs (`?tab=`), the list that address opens, as `to: { view, tab }` says.
30
+ */
31
+ export function viewLink(key, mode = 'push', opened = {}) {
29
32
  const app = shell().app();
30
33
  const room = app ? viewRoom(app, key) : undefined;
31
34
  if (!room)
32
35
  return undefined;
33
- const entry = isListRoom(room)
34
- ? { ...tableView(room.table, appListQuery(room, 0), adding ? 'new' : undefined), view: key }
35
- : pageView(roomPageId(room) ?? dashPageId(key));
36
- return linkTo(entry, mode);
36
+ if (!isListRoom(room))
37
+ return linkTo(pageView(roomPageId(room) ?? dashPageId(key)), mode);
38
+ const asked = opened.tab && !opened.adding
39
+ ? shell().addresses?.viewEntry(key, new URLSearchParams({ tab: tabSlug(opened.tab) }).toString())
40
+ : null;
41
+ return linkTo(asked ?? { ...tableView(room.table, appListQuery(room, 0), opened.adding ? 'new' : undefined), view: key }, mode);
37
42
  }
38
43
  /**
39
44
  * One of the App's lists on a refinement of its rows, as a dashboard group opens it: the list's own parameter where
@@ -43,7 +48,15 @@ export function viewLink(key, mode = 'push', adding = false) {
43
48
  export function listEntry(key, query) {
44
49
  const app = shell().app();
45
50
  const room = app ? viewRoom(app, key) : undefined;
46
- return room && isListRoom(room) && !room.error ? { ...tableView(room.table, query), view: key } : undefined;
51
+ if (!room || !isListRoom(room) || room.error)
52
+ return undefined;
53
+ /* The list its address opens, not the bare question: a drill walked in on its own text drew every column in key
54
+ order, and the address it wrote read back as another list (a field report). Said as the view's parameters — the
55
+ tab's order adopted, as a drill has none of its own — and read back, it has the view's show, order and page size. */
56
+ const addresses = shell().addresses;
57
+ const search = addresses?.listParams({ table: room.table, query, view: key }, { adoptOrder: true });
58
+ const asked = search === undefined ? null : addresses.viewEntry(key, search);
59
+ return asked ?? { ...tableView(room.table, query), view: key };
47
60
  }
48
61
  export function listLink(key, query) {
49
62
  const entry = listEntry(key, query);
@@ -91,9 +91,10 @@ export declare function formatDate(value: string | number | Date, options?: Intl
91
91
  * A moment, in the reader's words: a stored timestamp keeps the wall clock
92
92
  * it was written with, seconds only when it has some; a stored date alone
93
93
  * is a day and a time alone is a time. A Date or an epoch is an instant,
94
- * said in the reader's own zone.
94
+ * said in the reader's own zone. `'short'` says it in the fewest characters
95
+ * ("3/5/26, 2:30 PM"), for a cell or a line of a card, never with seconds.
95
96
  */
96
- export declare function formatDateTime(value: string | number | Date, options?: Intl.DateTimeFormatOptions): string;
97
+ export declare function formatDateTime(value: string | number | Date, options?: Intl.DateTimeFormatOptions | 'short'): string;
97
98
  /**
98
99
  * Two stored moments as one range, the end saying only what the start did not: "Sep 13, 2026, 2:00 – 4:00 PM" on
99
100
  * one day, "Sep 13, 2026, 2:00 PM – Sep 14, 2026, 9:00 AM" across two, "Mar 4 – 6, 2026" for days. Each is read as
@@ -108,11 +109,12 @@ export declare function formatSpan(start: string, end: string): string | null;
108
109
  * the App's clock zone (appPayload.ts servedUi). It is said in `zone`, else the App's `ui.timezone`, else that clock
109
110
  * zone, never the reader's own; with `time` its clock and the zone's short name follow the day ("Sep 4, 2026,
110
111
  * 2:30 PM PDT"), without, it is the day it falls on there. A Date or an epoch is an instant. A time alone is a time;
111
- * text that is no date comes back as it was.
112
+ * text that is no date comes back as it was. `short` says it in the fewest characters ("9/4/26, 2:30 PM PDT").
112
113
  */
113
- export declare function formatAbsolute(value: string | number | Date, { time, zone }?: {
114
+ export declare function formatAbsolute(value: string | number | Date, { time, zone, short }?: {
114
115
  time?: boolean;
115
116
  zone?: string;
117
+ short?: boolean;
116
118
  }): string;
117
119
  /**
118
120
  * A date said from today: "today", "yesterday", "in 3 days", "7 weeks
Binary file
@@ -1,4 +1,9 @@
1
1
  /** Every token a component may name, theme roles first, then faces, corners and the sheets' own steps. */
2
2
  export declare const UI_TOKENS: readonly string[];
3
- /** The token a name was most likely meant to be: the word another system uses for it, else the nearest spelling. */
3
+ /**
4
+ * The tokens renamed before 1.0, each to the one that says it now. Read before spelling: by spelling `--text-dim` is
5
+ * nearest `--text-sm` and `--ok` nearest `--ink` (a field report). `mistri upgrade` rewrites them from this table.
6
+ */
7
+ export declare const RENAMED_TOKENS: Readonly<Record<string, string>>;
8
+ /** The token a name was most likely meant to be: the one it was renamed to, the word another system uses for it, else the nearest spelling. */
4
9
  export declare function nearestToken(name: string): string | undefined;
@@ -115,8 +115,25 @@ function distance(a, b) {
115
115
  }
116
116
  return row[b.length];
117
117
  }
118
- /** The token a name was most likely meant to be: the word another system uses for it, else the nearest spelling. */
118
+ /**
119
+ * The tokens renamed before 1.0, each to the one that says it now. Read before spelling: by spelling `--text-dim` is
120
+ * nearest `--text-sm` and `--ok` nearest `--ink` (a field report). `mistri upgrade` rewrites them from this table.
121
+ */
122
+ export const RENAMED_TOKENS = {
123
+ '--text': '--ink',
124
+ '--text-dim': '--ink-muted',
125
+ '--border': '--line',
126
+ '--border-strong': '--line-strong',
127
+ '--danger': '--status-critical',
128
+ '--warn': '--status-warning',
129
+ '--ok': '--status-good',
130
+ '--surface-2': '--raised',
131
+ '--bg': '--ground',
132
+ };
133
+ /** The token a name was most likely meant to be: the one it was renamed to, the word another system uses for it, else the nearest spelling. */
119
134
  export function nearestToken(name) {
135
+ if (Object.hasOwn(RENAMED_TOKENS, name))
136
+ return RENAMED_TOKENS[name];
120
137
  const bare = name.replace(/^--/, '').toLowerCase();
121
138
  const said = WORDS[bare];
122
139
  if (said)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/kit",
3
- "version": "1.0.0-rc.40",
3
+ "version": "1.0.0-rc.41",
4
4
  "description": "The shared React client both shells are drawn with: the walk and the address, Grid, Value, the record page, lists, filters and charts.",
5
5
  "homepage": "https://mistriwork.dev",
6
6
  "bugs": {
@@ -83,8 +83,8 @@
83
83
  "./package.json": "./package.json"
84
84
  },
85
85
  "dependencies": {
86
- "@mistriwork/engine": "1.0.0-rc.40",
87
- "@mistriwork/ui": "1.0.0-rc.40",
86
+ "@mistriwork/engine": "1.0.0-rc.41",
87
+ "@mistriwork/ui": "1.0.0-rc.41",
88
88
  "intl-messageformat": "12.1.2",
89
89
  "qrcode-generator": "^2.0.4"
90
90
  },