@mistriwork/kit 1.0.0-rc.16 → 1.0.0-rc.17
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.
- package/dist/client/components/CardsList.js +7 -1
- package/dist/client/components/Export.js +8 -4
- package/dist/client/components/Grid.js +21 -2
- package/dist/client/components/PageFields.js +1 -1
- package/dist/client/components/PageHead.js +2 -1
- package/dist/client/components/SecondLine.d.ts +15 -0
- package/dist/client/components/SecondLine.js +18 -0
- package/dist/client/components/Value.d.ts +1 -0
- package/dist/client/components/Value.js +6 -8
- package/dist/client/components/textMeasure.d.ts +2 -0
- package/dist/client/components/textMeasure.js +16 -2
- package/dist/client/copy/workbench/components/Export.d.ts +3 -2
- package/dist/client/copy/workbench/components/Export.js +3 -2
- package/dist/client/export.d.ts +5 -4
- package/dist/client/export.js +40 -19
- package/dist/client/page.css +7 -0
- package/dist/client/shellMode.d.ts +6 -0
- package/package.json +3 -3
|
@@ -24,6 +24,7 @@ import { primaryKey } from '@mistriwork/engine/shared/schema.js';
|
|
|
24
24
|
import { humanName } from '@mistriwork/engine/shared/model.js';
|
|
25
25
|
import { cardsImageSort, factWord } from '@mistriwork/engine/shared/appCards.js';
|
|
26
26
|
import { Value } from './Value.js';
|
|
27
|
+
import { Subtitled, secondLine } from './SecondLine.js';
|
|
27
28
|
import { dressFor, hueOf, initialsOf, maskedText } from './valueModel.js';
|
|
28
29
|
import { Icon } from './Icon.js';
|
|
29
30
|
import { useListOrder } from './useListOrder.js';
|
|
@@ -136,6 +137,10 @@ export function CardsList({ table, rows, spec, interactive = true, recordNavigat
|
|
|
136
137
|
const { column, value } = namedCell(table, name, row, referenceLabels);
|
|
137
138
|
return _jsx(Value, { col: column, value: value, tableId: table.id, compact: true });
|
|
138
139
|
};
|
|
140
|
+
/* The figure and a captioned line have room for their column's second line (`subtitle`), quiet under the value; a
|
|
141
|
+
summary, a foot and a badge are one line each (appListColumns.ts listSecondLineColumns). A label path's rule is
|
|
142
|
+
its own table's, so only the row's own columns are asked. */
|
|
143
|
+
const saidWithSecond = (row, name) => (_jsx(Subtitled, { tableId: table.id, column: name.includes('.') ? undefined : name, row: row, children: said(row, name) }));
|
|
139
144
|
// A line or a fact may be a label path ("dealer_id.name"): its caption is the App's, else its last step's.
|
|
140
145
|
const caption = (name) => columnLabel(table.id, name) ?? humanName(name.split('.').pop() ?? name);
|
|
141
146
|
const present = (row, name) => row[name] !== null && row[name] !== undefined && row[name] !== '';
|
|
@@ -161,6 +166,7 @@ export function CardsList({ table, rows, spec, interactive = true, recordNavigat
|
|
|
161
166
|
const key = keyOf(table, row);
|
|
162
167
|
const id = ordering.id(row);
|
|
163
168
|
const title = titleOf(row);
|
|
169
|
+
const titleSecond = spec.primary.includes('.') ? undefined : secondLine(table.id, spec.primary, row);
|
|
164
170
|
const src = typeof image === 'string' ? cardImageAddress(row[image]) : leadOf(row);
|
|
165
171
|
const avatar = spec.media === 'avatar';
|
|
166
172
|
/* An icon tile leads the card in a picture's place: it is no picture, so the card keeps its text layout. */
|
|
@@ -177,7 +183,7 @@ export function CardsList({ table, rows, spec, interactive = true, recordNavigat
|
|
|
177
183
|
? { name: dressed.icon, label: dressed.label, tone: dressed.kind === 'tone' ? dressed.tone : undefined }
|
|
178
184
|
: null;
|
|
179
185
|
const badge = spec.badge && row[spec.badge] != null && row[spec.badge] !== '' ? (_jsx("span", { className: "cards-badge", children: said(row, spec.badge) })) : null;
|
|
180
|
-
return (_jsx("li", { className: "cards-item", ...(win.windowed ? { 'data-index': win.lineOf(index), ref: win.measure } : {}), ...(id ? ordering.item(id) : {}), onKeyDown: id ? (event) => ordering.keyDown(event, id) : undefined, children: _jsxs("article", { className: `cards-card${hasMedia ? ' has-media' : ''}${avatar ? ' cards-profile' : ''}${changedRows.has(row) ? ` row-changed-${changedRows.get(row)}` : ''}`, children: [hasMedia && _jsx(CardPicture, { src: src, avatar: avatar, title: title, first: index < FIRST_ROW }), id && ordering.menu(id), _jsxs("div", { className: "cards-body", children: [tile && (_jsx("span", { className: `cards-tile${mark?.tone ? ` tone-${mark.tone}` : ''}`, children: mark && _jsx(Icon, { name: mark.name, label: mark.label, size: 22 }) })), _jsxs("h3", { className: "cards-title", children: [mark && !tile && _jsx(Icon, { name: mark.name, label: mark.label, className: "cards-icon" }), canOpen && key ? (_jsx("button", { type: "button", className: "cards-open", "data-order-focus": "", "aria-keyshortcuts": ordering.shortcuts, "data-opens": opensRecord(table.id, key), onClick: () => void openRecord(table.id, key, title, 'push', { records, list }), children: title })) : (_jsx("span", { children: title }))] }), description !== undefined && (_jsx("p", { className: "cards-description", title: description, children: description })), (!hasMedia || avatar) && badge, spec.value && row[spec.value] != null && _jsx("p", { className: "cards-value", children:
|
|
186
|
+
return (_jsx("li", { className: "cards-item", ...(win.windowed ? { 'data-index': win.lineOf(index), ref: win.measure } : {}), ...(id ? ordering.item(id) : {}), onKeyDown: id ? (event) => ordering.keyDown(event, id) : undefined, children: _jsxs("article", { className: `cards-card${hasMedia ? ' has-media' : ''}${avatar ? ' cards-profile' : ''}${changedRows.has(row) ? ` row-changed-${changedRows.get(row)}` : ''}`, children: [hasMedia && _jsx(CardPicture, { src: src, avatar: avatar, title: title, first: index < FIRST_ROW }), id && ordering.menu(id), _jsxs("div", { className: "cards-body", children: [tile && (_jsx("span", { className: `cards-tile${mark?.tone ? ` tone-${mark.tone}` : ''}`, children: mark && _jsx(Icon, { name: mark.name, label: mark.label, size: 22 }) })), _jsxs("h3", { className: "cards-title", children: [mark && !tile && _jsx(Icon, { name: mark.name, label: mark.label, className: "cards-icon" }), canOpen && key ? (_jsx("button", { type: "button", className: "cards-open", "data-order-focus": "", "aria-keyshortcuts": ordering.shortcuts, "data-opens": opensRecord(table.id, key), onClick: () => void openRecord(table.id, key, title, 'push', { records, list }), children: title })) : (_jsx("span", { children: title }))] }), titleSecond !== undefined && _jsx("p", { className: "cards-subtitle", children: titleSecond }), description !== undefined && (_jsx("p", { className: "cards-description", title: description, children: description })), (!hasMedia || avatar) && badge, spec.value && row[spec.value] != null && _jsx("p", { className: "cards-value", children: saidWithSecond(row, spec.value) }), spec.facts?.some((name) => present(row, name)) ? (_jsx("p", { className: "cards-summary", children: spec.facts.filter((name) => present(row, name)).map((name) => fact(row, name, 'cards-summary-item')) })) : null, spec.lines?.length ? (_jsx("dl", { className: "cards-facts", children: spec.lines.map((name) => (_jsxs("div", { className: "cards-fact", children: [_jsx("dt", { children: caption(name) }), _jsx("dd", { children: saidWithSecond(row, name) })] }, name))) })) : null] }), spec.footer?.length ? (_jsx("p", { className: "cards-foot", children: spec.footer.some((name) => present(row, name))
|
|
181
187
|
? spec.footer.filter((name) => present(row, name)).map((name) => fact(row, name, 'cards-foot-item'))
|
|
182
188
|
: '\u00a0' })) : null, hasMedia && !avatar && badge] }) }, key ? JSON.stringify(key) : index));
|
|
183
189
|
}), win.after > 0 && _jsx("li", { className: "cards-spacer", "aria-hidden": "true", style: { height: `${win.after}px` } })] }), ordering.live] }));
|
|
@@ -82,13 +82,17 @@ export function ExportControl({ entry, data }) {
|
|
|
82
82
|
setOpen(false);
|
|
83
83
|
// `selected` rather than what came back, so the file follows the declared order.
|
|
84
84
|
saveExport(kind, data.table, selected, kind === 'csv' ? sheetAmounts(data.table, selected, rows) : rows);
|
|
85
|
+
/* Not streamed (a support visit): the one bounded read held whole, and the file says where it stopped. */
|
|
86
|
+
if (all && total > EXPORT_MAX_ROWS)
|
|
87
|
+
toast(say('stoppedAtTheCap', { max: formatNumber(EXPORT_MAX_ROWS) }));
|
|
85
88
|
};
|
|
86
89
|
/* JSON and the agent hand-off are Workbench tools; an App's list offers the columns and the CSV. */
|
|
87
90
|
const workbench = !shell().inApp();
|
|
88
91
|
const kinds = workbench ? ['csv', 'json'] : ['csv'];
|
|
89
92
|
const pageLabel = say('thisPageRows', { count: pageRows.length });
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
/* Every row: the server streams the file with no ceiling (exportRoute.ts); only its fallback stops at the cap. */
|
|
94
|
+
const allLabel = say('allMatchingRows', { count: formatNumber(total) });
|
|
95
|
+
return (_jsxs(_Fragment, { children: [_jsxs(DropMenu, { className: "export", triggerClassName: "export-summary", triggerTitle: say('downloadThisResult'), label: _jsxs(_Fragment, { children: [_jsx("span", { className: "export-word", children: say('export') }), _jsx("span", { className: "export-more", "aria-hidden": "true", children: "\u22EF" })] }), popupClassName: "export-menu", open: open, onOpenChange: setOpen, children: [_jsx("div", { className: "export-group", children: _jsxs(DropItem, { className: "export-item export-columns-item", onClick: () => setChoosing(true), children: [_jsx("span", { children: say('chooseColumns') }), _jsx("span", { className: "export-count", children: declared.length ? say('selectedOfDeclared', { selected: selected.length, declared: declared.length }) : `${selected.length}` })] }) }), kinds.map((kind) => (_jsxs("div", { className: "export-group", children: [_jsx("span", { className: "export-kind", children: kind.toUpperCase() }), _jsx(DropItem, { className: "export-item", disabled: busy === `${kind}:false`, closeOnClick: false, onClick: () => void deliver(kind, false), children: busy === `${kind}:false` ? say('fetching') : pageLabel }), total > pageRows.length && (_jsx(DropItem, { className: "export-item", disabled: busy === `${kind}:true`, closeOnClick: false, onClick: () => void deliver(kind, true), children: busy === `${kind}:true` ? say('fetching') : allLabel }))] }, kind))), workbench && (_jsxs("div", { className: "export-group", children: [_jsx("span", { className: "export-kind", children: say('agent') }), _jsx(DropItem, { className: "export-item", title: say('theQueryTheShape'), onClick: () => void copyPosition(positionOf(state, entry, { columns: displayed, shown: pageRows.length, total }), toast), children: say('copyThisPosition') })] })), total > EXPORT_MAX_ROWS && _jsx("p", { className: "export-note", children: say('streamedPastTheCap') })] }), choosing && (_jsx(ColumnChooser, { tableId: data.table, displayed: displayed, declared: declared, selected: selected, onClose: () => setChoosing(false), onDone: (picked) => {
|
|
92
96
|
rememberColumns(data.table, picked);
|
|
93
97
|
tick((n) => n + 1);
|
|
94
98
|
} }))] }));
|
|
@@ -130,8 +134,8 @@ function ColumnChooser({ tableId, displayed, declared, selected, onClose, onDone
|
|
|
130
134
|
}
|
|
131
135
|
/**
|
|
132
136
|
* A CSV says money as the figure a sheet reads, as the server's streamed file
|
|
133
|
-
* does (
|
|
134
|
-
*
|
|
137
|
+
* does (appExport.ts csvAmounts), and here where it does not stream — a
|
|
138
|
+
* support visit, this page: a column kept in minor units, 1999, is
|
|
135
139
|
* written 19.99 in its row's own currency.
|
|
136
140
|
*/
|
|
137
141
|
function sheetAmounts(tableId, columns, rows) {
|
|
@@ -50,7 +50,7 @@ import { Icon } from './Icon.js';
|
|
|
50
50
|
import { createRowHosts, RowDecoration, RowHostScope, RowTrailScope, rowKeyString, useRowHostScope, useRowTrailScope, } from './RowHost.js';
|
|
51
51
|
import { useGridKeyboard } from './useGridKeyboard.js';
|
|
52
52
|
import { useChangedRows } from '../liveState.js';
|
|
53
|
-
import { textMeasure } from './textMeasure.js';
|
|
53
|
+
import { fontLoaded, textMeasure } from './textMeasure.js';
|
|
54
54
|
import { presentationColumns } from './columnPresentation.js';
|
|
55
55
|
import { usePins } from './usePins.js';
|
|
56
56
|
import { useStickyHead } from './useStickyHead.js';
|
|
@@ -484,13 +484,18 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
484
484
|
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
485
|
wider kept 30px of every table's room in a status that never used it. -1: the cell holds no chip. */
|
|
486
486
|
const [cellChips, setCellChips] = useState([]);
|
|
487
|
+
/* Counts the times a face arrived after the columns were sized in its fallback: the sizes are read again, once for
|
|
488
|
+
each, so a table's columns never stay as the fallback face set them (textMeasure.ts). */
|
|
489
|
+
const [faceEpoch, setFaceEpoch] = useState(0);
|
|
487
490
|
useLayoutEffect(() => {
|
|
488
491
|
if (sizing !== 'fit' || !wrap.current)
|
|
489
492
|
return;
|
|
490
493
|
const element = wrap.current;
|
|
491
494
|
/* The look says how wide its heads' characters set (gridSizing.ts); read
|
|
492
495
|
again when the reader picks another look, which moves no width. */
|
|
496
|
+
let sizedInFallback = false;
|
|
493
497
|
const measure = (contentWidth) => {
|
|
498
|
+
sizedInFallback = false;
|
|
494
499
|
const style = getComputedStyle(element);
|
|
495
500
|
/* clientWidth rounds up fractional layout widths. At density zoom that
|
|
496
501
|
can create a one-screen-pixel scroll range even when scrollWidth and
|
|
@@ -509,6 +514,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
509
514
|
upper: face.textTransform === 'uppercase',
|
|
510
515
|
tracking: parseFloat(face.letterSpacing) || 0,
|
|
511
516
|
};
|
|
517
|
+
sizedInFallback = sizedInFallback || !fontLoaded(next.font);
|
|
512
518
|
setHeadFace((was) => (was && was.font === next.font && was.upper === next.upper && was.tracking === next.tracking ? was : next));
|
|
513
519
|
}
|
|
514
520
|
/* A group's head is not a row of values: the first row that is one is sampled. */
|
|
@@ -519,6 +525,7 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
519
525
|
const font = getComputedStyle(cell);
|
|
520
526
|
return `${font.fontStyle} ${font.fontWeight} ${font.fontSize} ${font.fontFamily}`;
|
|
521
527
|
});
|
|
528
|
+
sizedInFallback = sizedInFallback || !fonts.every(fontLoaded);
|
|
522
529
|
setCellFonts((was) => (was.join('|') === fonts.join('|') ? was : fonts));
|
|
523
530
|
/* The widest chip of the sampled rows, not the first row's: a look may draw a neutral state as a bare word
|
|
524
531
|
and the rest as pills, and sized by a first-row "Ready" Sage cut every "In review" pill to "In rev…". */
|
|
@@ -547,7 +554,18 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
547
554
|
observer.observe(element);
|
|
548
555
|
const themeChanged = () => measure();
|
|
549
556
|
addHostListener(window, VISUAL_THEME_EVENT, themeChanged);
|
|
557
|
+
/* A face that arrives after the first measure: sized again with it, once, and only if the last measure was made
|
|
558
|
+
without it (a face already here moves nothing). */
|
|
559
|
+
const faces = globalThis.document?.fonts;
|
|
560
|
+
const arrived = () => {
|
|
561
|
+
if (!sizedInFallback)
|
|
562
|
+
return;
|
|
563
|
+
measure();
|
|
564
|
+
setFaceEpoch((was) => was + 1);
|
|
565
|
+
};
|
|
566
|
+
faces?.addEventListener?.('loadingdone', arrived);
|
|
550
567
|
return () => {
|
|
568
|
+
faces?.removeEventListener?.('loadingdone', arrived);
|
|
551
569
|
observer.disconnect();
|
|
552
570
|
removeHostListener(window, VISUAL_THEME_EVENT, themeChanged);
|
|
553
571
|
};
|
|
@@ -647,11 +665,12 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
647
665
|
headFace,
|
|
648
666
|
cellChips,
|
|
649
667
|
shift,
|
|
668
|
+
faceEpoch,
|
|
650
669
|
]);
|
|
651
670
|
/* Column i's cell follows the expander's when there is one. */
|
|
652
671
|
const measureText = useMemo(() => cellFonts.length
|
|
653
672
|
? (text, column) => textMeasure(cellFonts[Math.min(column + (slotted ? 1 : 0), cellFonts.length - 1)])?.(text) ?? text.length * 8
|
|
654
|
-
: undefined, [cellFonts, slotted]);
|
|
673
|
+
: undefined, [cellFonts, slotted, faceEpoch]);
|
|
655
674
|
/* 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
675
|
and words have wrapped (gridSizing.ts): they are moved, not lost, and the list does not scroll sideways. An
|
|
657
676
|
embedded grid leaves them out, as it did. */
|
|
@@ -208,7 +208,7 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
|
|
|
208
208
|
? recordNoun(resourceOf(shell().app(), reference.table)?.noun, findTable(reference.table)?.name ?? reference.table)
|
|
209
209
|
: '';
|
|
210
210
|
const jump = (className, text) => (_jsx(RefJump, { references: reference, value: row[titlePath], label: titleLabel ? row[titleLabel] : undefined, table: base, column: titlePath, row: row, className: className, text: text }));
|
|
211
|
-
return (_jsx("section", { className: `${sectionClass(section)} page-card-section page-reference-card`, children: _jsxs("div", { className: "page-card", children: [section.title && _jsx("h2", { className: "page-card-caption", children: section.title }), _jsx("p", { className: "page-card-title", children: reference ? (jump('page-card-name')) : filled(titlePath) ? (_jsx(Value, { col: titleColumn, value: row[titlePath], tableId: base.id })) : (emptyWord()) }), rest.some(filled) && (_jsx("dl", { className: "page-card-facts", children: rest.filter(filled).map((path) => (_jsxs("div", { className: "page-card-fact", children: [_jsx("dt", { children: columnLabel(base.id, path, factsStem) ?? captionOf(path) }), _jsx("dd", { children: said(path) })] }, path))) })), reference && _jsx("p", { className: "page-card-foot", children: jump('page-card-more', say('common.view', { noun })) })] }) }));
|
|
211
|
+
return (_jsx("section", { className: `${sectionClass(section)} page-card-section page-reference-card`, children: _jsxs("div", { className: "page-card", children: [section.title && _jsx("h2", { className: "page-card-caption", children: section.title }), _jsx("p", { className: "page-card-title", children: reference ? (jump('page-card-name')) : filled(titlePath) ? (_jsx(Value, { col: titleColumn, value: row[titlePath], tableId: base.id, row: row, subtitled: !titlePath.includes('.') })) : (emptyWord()) }), rest.some(filled) && (_jsx("dl", { className: "page-card-facts", children: rest.filter(filled).map((path) => (_jsxs("div", { className: "page-card-fact", children: [_jsx("dt", { children: columnLabel(base.id, path, factsStem) ?? captionOf(path) }), _jsx("dd", { children: said(path) })] }, path))) })), reference && _jsx("p", { className: "page-card-foot", children: jump('page-card-more', say('common.view', { noun })) })] }) }));
|
|
212
212
|
}
|
|
213
213
|
/* A group of fields that all follow the same reference is that record
|
|
214
214
|
shown inline; its labels drop the hop they all share. */
|
|
@@ -21,6 +21,7 @@ import { shell } from '../shellMode.js';
|
|
|
21
21
|
import { isPinned, togglePinned } from '../pagemarks.js';
|
|
22
22
|
import { Editable, PendingBar } from './Editable.js';
|
|
23
23
|
import { RefJump, Value } from './Value.js';
|
|
24
|
+
import { Subtitled } from './SecondLine.js';
|
|
24
25
|
import { headerColumns } from '@mistriwork/engine/shared/recordReads.js';
|
|
25
26
|
import { presentationColumns } from './columnPresentation.js';
|
|
26
27
|
import { useDelete } from './DeleteButton.js';
|
|
@@ -270,7 +271,7 @@ function useRecordHeader({ page, base, recordKey: key, header, onSectionLabel, o
|
|
|
270
271
|
? factWord(labels[path], row[path], columnDisplay(base.id, path))
|
|
271
272
|
: undefined;
|
|
272
273
|
const before = word !== undefined && labels[path].position === 'before';
|
|
273
|
-
return (_jsxs("li", { className: "page-fact", children: [word === undefined && (_jsxs("span", { className: "page-fact-caption", children: [captionOf(path), _jsx("span", { className: "visually-hidden", children: ": " })] })), before && _jsxs("span", { className: "page-fact-word", children: [word, " "] }), filled(path) && said(path), word !== undefined && !before && _jsxs("span", { className: "page-fact-word", children: [" ", word] }), adornments.get(path)] }, path));
|
|
274
|
+
return (_jsxs("li", { className: "page-fact", children: [word === undefined && (_jsxs("span", { className: "page-fact-caption", children: [captionOf(path), _jsx("span", { className: "visually-hidden", children: ": " })] })), before && _jsxs("span", { className: "page-fact-word", children: [word, " "] }), filled(path) && (_jsx(Subtitled, { tableId: base.id, column: path.includes('.') ? undefined : path, row: row, children: said(path) })), word !== undefined && !before && _jsxs("span", { className: "page-fact-word", children: [" ", word] }), adornments.get(path)] }, path));
|
|
274
275
|
};
|
|
275
276
|
return {
|
|
276
277
|
/* Its caption is heard, not seen: beside the name a chip is its own word. */
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A column's second line: the column its display rule names (`subtitle`, another column of the same record), drawn
|
|
3
|
+
* quietly under the value wherever there is room for one (docs/design.md). Its own module so a test that stands a
|
|
4
|
+
* value in for Value.tsx still draws the second line it is about.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
/** The second line of `column` on `row`, as the record or the list read it with the row; none where it has no value. */
|
|
8
|
+
export declare function secondLine(tableId: string | undefined, column: string | undefined, row: Readonly<Record<string, unknown>> | undefined): string | undefined;
|
|
9
|
+
/** Something drawn with its column's second line quietly under it, as a list's cell does. */
|
|
10
|
+
export declare function Subtitled({ tableId, column, row, children, }: {
|
|
11
|
+
tableId: string | undefined;
|
|
12
|
+
column: string | undefined;
|
|
13
|
+
row: Readonly<Record<string, unknown>> | undefined;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { columnDisplay } from '../core.js';
|
|
3
|
+
import { subtitlePath } from './valueModel.js';
|
|
4
|
+
/** The second line of `column` on `row`, as the record or the list read it with the row; none where it has no value. */
|
|
5
|
+
export function secondLine(tableId, column, row) {
|
|
6
|
+
if (tableId === undefined || !column || !row)
|
|
7
|
+
return undefined;
|
|
8
|
+
const path = subtitlePath(columnDisplay(tableId, column), column);
|
|
9
|
+
const second = path !== undefined && Object.hasOwn(row, path) ? row[path] : undefined;
|
|
10
|
+
return second === null || second === undefined || second === '' ? undefined : String(second);
|
|
11
|
+
}
|
|
12
|
+
/** Something drawn with its column's second line quietly under it, as a list's cell does. */
|
|
13
|
+
export function Subtitled({ tableId, column, row, children, }) {
|
|
14
|
+
const second = secondLine(tableId, column, row);
|
|
15
|
+
if (second === undefined)
|
|
16
|
+
return children;
|
|
17
|
+
return (_jsxs("span", { className: "value-subtitled", children: [children, _jsx("span", { className: "value-sub", children: second })] }));
|
|
18
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ColumnMeta, TableMeta } from '@mistriwork/engine/shared/schema.js';
|
|
2
2
|
import { AvatarText, Dressed } from './Dressed.js';
|
|
3
|
+
export { secondLine } from './SecondLine.js';
|
|
3
4
|
export { AvatarText, Dressed };
|
|
4
5
|
interface ValueProps {
|
|
5
6
|
col: ColumnMeta | undefined;
|
|
@@ -11,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
import { Fragment } from 'react';
|
|
12
12
|
import { api, columnDisplay, columnLabel, emptyWord, findTable, humanName, openRecord, refsFrom, state, toast } from '../core.js';
|
|
13
13
|
import { opensRecord } from '../recordIntent.js';
|
|
14
|
-
import { dressFor, linkFor, maskedText, ruleSays,
|
|
14
|
+
import { dressFor, linkFor, maskedText, ruleSays, wordFor } from './valueModel.js';
|
|
15
15
|
import { rowCurrency } from '@mistriwork/engine/shared/money.js';
|
|
16
16
|
import { dueOpen } from './dueOpen.js';
|
|
17
17
|
import { JsonValue } from './JsonValue.js';
|
|
@@ -22,6 +22,9 @@ import { ValueSlot } from './valueRenderers.js';
|
|
|
22
22
|
import { Icon } from './Icon.js';
|
|
23
23
|
import { say } from '../copy/record/components/Value.js';
|
|
24
24
|
import { shellBody } from '../shellHost.js';
|
|
25
|
+
import { Subtitled } from './SecondLine.js';
|
|
26
|
+
/* The second line is a value's too: the board reads it from here, as it reads every value's words. */
|
|
27
|
+
export { secondLine } from './SecondLine.js';
|
|
25
28
|
/* Drawn here and in the grid; the rules that draw them read no global (Dressed.tsx). */
|
|
26
29
|
export { AvatarText, Dressed };
|
|
27
30
|
/** A value that is a link: mail, a call, or a web page, which opens beside the App rather than in place of it. */
|
|
@@ -46,14 +49,9 @@ function breakable(text) {
|
|
|
46
49
|
}
|
|
47
50
|
/** A value as the record and the page show it: dressed when the app says, plain otherwise. */
|
|
48
51
|
export function Value(props) {
|
|
49
|
-
const { subtitled, row, col } = props;
|
|
52
|
+
const { subtitled, row, col, tableId } = props;
|
|
50
53
|
const body = _jsx(BareValue, { ...props });
|
|
51
|
-
|
|
52
|
-
const path = subtitlePath(rule, col?.name ?? '');
|
|
53
|
-
const second = path !== undefined && row && Object.hasOwn(row, path) ? row[path] : undefined;
|
|
54
|
-
if (second === null || second === undefined || second === '')
|
|
55
|
-
return body;
|
|
56
|
-
return (_jsxs("span", { className: "value-subtitled", children: [body, _jsx("span", { className: "value-sub", children: String(second) })] }));
|
|
54
|
+
return subtitled ? (_jsx(Subtitled, { tableId: tableId, column: col?.name, row: row, children: body })) : (body);
|
|
57
55
|
}
|
|
58
56
|
function BareValue(props) {
|
|
59
57
|
const { col, value, tableId, compact = false, links = !compact } = props;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { TextMeasure } from './gridSizing.js';
|
|
2
|
+
/** Whether `font` is set in faces that are loaded (or that no `@font-face` declares: a system face). */
|
|
3
|
+
export declare function fontLoaded(font: string): boolean;
|
|
2
4
|
export declare function textMeasure(font: string): TextMeasure | undefined;
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
/** Text widths in one font, from a shared canvas; `undefined` where there is
|
|
2
2
|
no 2D context (the component tests), which falls back to counting. */
|
|
3
3
|
let measuringContext;
|
|
4
|
+
/* Only measures of a face that is here: a canvas measures a face still on its way in the fallback's metrics, and that
|
|
5
|
+
number kept for the page's life sized every column from the wrong font, so a table's columns came out differently
|
|
6
|
+
from one load to the next, by whether the webfont beat the first measure. */
|
|
4
7
|
const measures = new Map();
|
|
8
|
+
/** Whether `font` is set in faces that are loaded (or that no `@font-face` declares: a system face). */
|
|
9
|
+
export function fontLoaded(font) {
|
|
10
|
+
try {
|
|
11
|
+
return globalThis.document?.fonts?.check(font) ?? true;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
5
17
|
export function textMeasure(font) {
|
|
6
18
|
if (measuringContext === undefined) {
|
|
7
19
|
try {
|
|
@@ -14,7 +26,8 @@ export function textMeasure(font) {
|
|
|
14
26
|
const context = measuringContext;
|
|
15
27
|
if (!context)
|
|
16
28
|
return undefined;
|
|
17
|
-
const
|
|
29
|
+
const loaded = fontLoaded(font);
|
|
30
|
+
const known = loaded ? measures.get(font) : undefined;
|
|
18
31
|
if (known)
|
|
19
32
|
return known;
|
|
20
33
|
const cache = new Map();
|
|
@@ -30,6 +43,7 @@ export function textMeasure(font) {
|
|
|
30
43
|
cache.set(text, width);
|
|
31
44
|
return width;
|
|
32
45
|
};
|
|
33
|
-
|
|
46
|
+
if (loaded)
|
|
47
|
+
measures.set(font, measure);
|
|
34
48
|
return measure;
|
|
35
49
|
}
|
|
@@ -5,7 +5,7 @@ export declare const say: import("../../../messages.js").RoomMessage<{
|
|
|
5
5
|
readonly one: "this page ({count} row)";
|
|
6
6
|
readonly other: "this page ({count} rows)";
|
|
7
7
|
};
|
|
8
|
-
readonly allMatchingRows: "all matching rows ({
|
|
8
|
+
readonly allMatchingRows: "all matching rows ({count})";
|
|
9
9
|
readonly downloadThisResult: "Download this result";
|
|
10
10
|
readonly export: "Export";
|
|
11
11
|
readonly chooseColumns: "Choose columns…";
|
|
@@ -13,7 +13,8 @@ export declare const say: import("../../../messages.js").RoomMessage<{
|
|
|
13
13
|
readonly agent: "Agent";
|
|
14
14
|
readonly theQueryTheShape: "The query, the shape and how to run it over MCP — not the rows";
|
|
15
15
|
readonly copyThisPosition: "Copy this position";
|
|
16
|
-
readonly
|
|
16
|
+
readonly streamedPastTheCap: "Every matching row is written, read in batches as it downloads.";
|
|
17
|
+
readonly stoppedAtTheCap: "This file stops at {max} rows: a support visit records each read whole, so its export is one read, not a stream.";
|
|
17
18
|
readonly pickAtLeastOne: "Pick at least one column to export.";
|
|
18
19
|
readonly columnsToExport: "Columns to export";
|
|
19
20
|
readonly tickedColumnsAreWritten: "Ticked columns are written in the order the table declares them. Choosing a column that is not on screen re-runs the query to fetch it.";
|
|
@@ -4,7 +4,7 @@ export const say = defineMessages({
|
|
|
4
4
|
none: 'None',
|
|
5
5
|
thatQueryNoLonger: 'That query no longer returns rows.',
|
|
6
6
|
thisPageRows: { one: 'this page ({count} row)', other: 'this page ({count} rows)' },
|
|
7
|
-
allMatchingRows: 'all matching rows ({
|
|
7
|
+
allMatchingRows: 'all matching rows ({count})',
|
|
8
8
|
downloadThisResult: 'Download this result',
|
|
9
9
|
export: 'Export',
|
|
10
10
|
chooseColumns: 'Choose columns…',
|
|
@@ -12,7 +12,8 @@ export const say = defineMessages({
|
|
|
12
12
|
agent: 'Agent',
|
|
13
13
|
theQueryTheShape: 'The query, the shape and how to run it over MCP — not the rows',
|
|
14
14
|
copyThisPosition: 'Copy this position',
|
|
15
|
-
|
|
15
|
+
streamedPastTheCap: 'Every matching row is written, read in batches as it downloads.',
|
|
16
|
+
stoppedAtTheCap: 'This file stops at {max} rows: a support visit records each read whole, so its export is one read, not a stream.',
|
|
16
17
|
pickAtLeastOne: 'Pick at least one column to export.',
|
|
17
18
|
columnsToExport: 'Columns to export',
|
|
18
19
|
tickedColumnsAreWritten: 'Ticked columns are written in the order the table declares them. Choosing a column that is not on screen re-runs the query to fetch it.',
|
package/dist/client/export.d.ts
CHANGED
|
@@ -45,10 +45,11 @@ export declare function saveExport(kind: any, table: any, columns: any, rows: an
|
|
|
45
45
|
/**
|
|
46
46
|
* All matching rows, as a file the server streams (`POST /api/export`):
|
|
47
47
|
* read in batches and written as each arrives, so neither side holds the
|
|
48
|
-
* whole result as objects and nothing is counted.
|
|
49
|
-
*
|
|
50
|
-
* the policy
|
|
51
|
-
*
|
|
48
|
+
* whole result as objects and nothing is counted. A tenant's file is asked
|
|
49
|
+
* on its lease (the shell's `tenant.exportFile`); a row-policy App's is read
|
|
50
|
+
* through the policy like its list. False where the server does not offer
|
|
51
|
+
* it — a support visit, whose every read is ledgered whole — and the caller
|
|
52
|
+
* exports through `/api/run` as before.
|
|
52
53
|
*
|
|
53
54
|
* @param {'csv' | 'json'} kind
|
|
54
55
|
* @param {string} table
|
package/dist/client/export.js
CHANGED
|
@@ -22,11 +22,11 @@ import { scopeApiRequest } from './requestIdentity.js';
|
|
|
22
22
|
import { captureSessionIdentity } from './sessionIdentity.js';
|
|
23
23
|
import { say } from './copy/workbench/export.js';
|
|
24
24
|
import { portalRoot } from './shellHost.js';
|
|
25
|
+
import { shell } from './shellMode.js';
|
|
25
26
|
import { fetchServer } from './transport.js';
|
|
26
27
|
export { csvField };
|
|
27
|
-
/* Mirrors MAX_LIMIT in packages/engine/src/shared/reads.ts
|
|
28
|
-
|
|
29
|
-
rows "all matching" can actually mean. */
|
|
28
|
+
/* Mirrors MAX_LIMIT in packages/engine/src/shared/reads.ts: the most one `/api/run` reads, which is all an export
|
|
29
|
+
holds only where the server cannot stream the file (streamExport below); a streamed file has no ceiling. */
|
|
30
30
|
export const EXPORT_MAX_ROWS = MAX_LIMIT;
|
|
31
31
|
/** A CSV document: a header row of column names, then one row per record. */
|
|
32
32
|
export function toCsv(columns, rows) {
|
|
@@ -172,10 +172,11 @@ export function saveExport(kind, table, columns, rows) {
|
|
|
172
172
|
/**
|
|
173
173
|
* All matching rows, as a file the server streams (`POST /api/export`):
|
|
174
174
|
* read in batches and written as each arrives, so neither side holds the
|
|
175
|
-
* whole result as objects and nothing is counted.
|
|
176
|
-
*
|
|
177
|
-
* the policy
|
|
178
|
-
*
|
|
175
|
+
* whole result as objects and nothing is counted. A tenant's file is asked
|
|
176
|
+
* on its lease (the shell's `tenant.exportFile`); a row-policy App's is read
|
|
177
|
+
* through the policy like its list. False where the server does not offer
|
|
178
|
+
* it — a support visit, whose every read is ledgered whole — and the caller
|
|
179
|
+
* exports through `/api/run` as before.
|
|
179
180
|
*
|
|
180
181
|
* @param {'csv' | 'json'} kind
|
|
181
182
|
* @param {string} table
|
|
@@ -185,19 +186,9 @@ export function saveExport(kind, table, columns, rows) {
|
|
|
185
186
|
*/
|
|
186
187
|
export async function streamExport(kind, table, q, columns) {
|
|
187
188
|
const identity = captureSessionIdentity();
|
|
188
|
-
|
|
189
|
+
const res = identity.tenantRequired ? await onLease(kind, q, columns) : await ordinary(identity, kind, q, columns);
|
|
190
|
+
if (!res)
|
|
189
191
|
return false;
|
|
190
|
-
const { url, payload } = scopeApiRequest('/api/export', { q, format: kind, columns }, state.activeConnection);
|
|
191
|
-
const res = await fetchServer(url, {
|
|
192
|
-
method: 'POST',
|
|
193
|
-
credentials: 'same-origin',
|
|
194
|
-
cache: 'no-store',
|
|
195
|
-
headers: {
|
|
196
|
-
'content-type': 'application/json',
|
|
197
|
-
...(identity.mode === 'authenticated' ? { 'x-mistri-account': identity.accountId } : {}),
|
|
198
|
-
},
|
|
199
|
-
body: JSON.stringify(payload),
|
|
200
|
-
});
|
|
201
192
|
/* The file is the one answer with a disposition; anything else is JSON
|
|
202
193
|
saying why not — a refusal to fall back from, or the query's error. */
|
|
203
194
|
if (res.ok && res.headers.get('content-disposition')) {
|
|
@@ -215,3 +206,33 @@ export async function streamExport(kind, table, q, columns) {
|
|
|
215
206
|
const said = await res.json().catch(() => null);
|
|
216
207
|
throw new Error(said?.errors?.[0]?.message ?? said?.error ?? say('theExportCouldNotBeRead'));
|
|
217
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* @param {ReturnType<typeof captureSessionIdentity>} identity
|
|
211
|
+
* @param {'csv' | 'json'} kind
|
|
212
|
+
* @param {string} q
|
|
213
|
+
* @param {string[]} columns
|
|
214
|
+
*/
|
|
215
|
+
function ordinary(identity, kind, q, columns) {
|
|
216
|
+
const { url, payload } = scopeApiRequest('/api/export', { q, format: kind, columns }, state.activeConnection);
|
|
217
|
+
return fetchServer(url, {
|
|
218
|
+
method: 'POST',
|
|
219
|
+
credentials: 'same-origin',
|
|
220
|
+
cache: 'no-store',
|
|
221
|
+
headers: {
|
|
222
|
+
'content-type': 'application/json',
|
|
223
|
+
...(identity.mode === 'authenticated' ? { 'x-mistri-account': identity.accountId } : {}),
|
|
224
|
+
},
|
|
225
|
+
body: JSON.stringify(payload),
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The file on the tenant's lease, or undefined where the shell sends none (tenantTransport.ts `tenantExport`).
|
|
230
|
+
*
|
|
231
|
+
* @param {'csv' | 'json'} kind
|
|
232
|
+
* @param {string} q
|
|
233
|
+
* @param {string[]} columns
|
|
234
|
+
*/
|
|
235
|
+
async function onLease(kind, q, columns) {
|
|
236
|
+
const exportFile = shell().tenant?.exportFile;
|
|
237
|
+
return exportFile ? await exportFile({ q, format: kind, columns }) : undefined;
|
|
238
|
+
}
|
package/dist/client/page.css
CHANGED
|
@@ -3038,6 +3038,13 @@
|
|
|
3038
3038
|
outline: var(--focus-width) solid var(--focus);
|
|
3039
3039
|
outline-offset: -2px;
|
|
3040
3040
|
}
|
|
3041
|
+
/* The title's second line (its column's `subtitle`): another column of the record, said quietly and close under it. */
|
|
3042
|
+
.cards-subtitle {
|
|
3043
|
+
margin: calc(var(--space-1) - var(--space-2h)) 0 0;
|
|
3044
|
+
font: 400 var(--text-sm)/1.35 var(--sans);
|
|
3045
|
+
color: var(--ink-muted);
|
|
3046
|
+
overflow-wrap: anywhere;
|
|
3047
|
+
}
|
|
3041
3048
|
.cards-description {
|
|
3042
3049
|
margin: 0;
|
|
3043
3050
|
color: var(--ink-muted);
|
|
@@ -50,6 +50,12 @@ interface TenantRequests {
|
|
|
50
50
|
read(path: string, body: Record<string, unknown> | undefined, connection: string | null | undefined): Promise<unknown>;
|
|
51
51
|
mutate(path: string, body: unknown, connection: string | null | undefined): Promise<unknown>;
|
|
52
52
|
isMutation(path: string): boolean;
|
|
53
|
+
/** The streamed export on the lease: the file, or the server's answer where it is not one. */
|
|
54
|
+
exportFile?(body: {
|
|
55
|
+
q: string;
|
|
56
|
+
format: string;
|
|
57
|
+
columns: readonly string[];
|
|
58
|
+
}): Promise<Response>;
|
|
53
59
|
}
|
|
54
60
|
/** How a tenant's links are read and written (tenantLink.ts). */
|
|
55
61
|
interface TenantLinks {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistriwork/kit",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.17",
|
|
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": {
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"./package.json": "./package.json"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@mistriwork/engine": "1.0.0-rc.
|
|
86
|
-
"@mistriwork/ui": "1.0.0-rc.
|
|
85
|
+
"@mistriwork/engine": "1.0.0-rc.17",
|
|
86
|
+
"@mistriwork/ui": "1.0.0-rc.17",
|
|
87
87
|
"intl-messageformat": "12.1.2",
|
|
88
88
|
"qrcode-generator": "^2.0.4"
|
|
89
89
|
},
|