@mistriwork/kit 1.0.0-rc.13 → 1.0.0-rc.14
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/Composer.js +2 -2
- package/dist/client/components/Diagram.js +1 -1
- package/dist/client/components/Grid.js +27 -1
- package/dist/client/components/Summary.js +1 -1
- package/dist/client/components/gridSizing.d.ts +3 -0
- package/dist/client/components/gridSizing.js +1 -1
- package/dist/client/copy/shell/visualTheme.d.ts +2 -0
- package/dist/client/copy/shell/visualTheme.js +2 -0
- package/dist/client/copy/workbench/components/Composer.d.ts +2 -2
- package/dist/client/copy/workbench/components/Composer.js +2 -2
- package/dist/client/copy/workbench/components/Diagram.d.ts +1 -1
- package/dist/client/copy/workbench/components/Diagram.js +1 -1
- package/dist/client/copy/workbench/components/Summary.d.ts +3 -3
- package/dist/client/copy/workbench/components/Summary.js +3 -3
- package/dist/client/features.css +6 -3
- package/dist/client/fonts/faces.css +53 -0
- package/dist/client/visualTheme.d.ts +29 -0
- package/dist/client/visualTheme.js +94 -17
- package/dist/client/visualThemes.css +2 -1
- package/package.json +10 -3
|
@@ -115,7 +115,7 @@ function summaryLabel(fn, column, isDate) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
function SummariseMenu({ fk, child }) {
|
|
118
|
-
const items = [{ value: '', label: say('
|
|
118
|
+
const items = [{ value: '', label: say('summarize'), detail: say('aTotalAnAverage') }];
|
|
119
119
|
for (const column of child.columns) {
|
|
120
120
|
if (column.primaryKey || column.references)
|
|
121
121
|
continue;
|
|
@@ -133,7 +133,7 @@ function SummariseMenu({ fk, child }) {
|
|
|
133
133
|
}
|
|
134
134
|
if (items.length === 1)
|
|
135
135
|
return null;
|
|
136
|
-
return (_jsx("span", { className: "composer-menu", children: _jsx(Dropdown, { items: items, value: "", ariaLabel: say('
|
|
136
|
+
return (_jsx("span", { className: "composer-menu", children: _jsx(Dropdown, { items: items, value: "", ariaLabel: say('summarizeName', { name: child.name }), onChange: (value) => {
|
|
137
137
|
if (!value)
|
|
138
138
|
return;
|
|
139
139
|
const [fn, column] = value.split(':');
|
|
@@ -225,7 +225,7 @@ export function NeighbourhoodDiagram({ tableId, expandable = true }) {
|
|
|
225
225
|
return _jsx("p", { className: "note", children: say('hasNoForeignKeys', { tableId }) });
|
|
226
226
|
const { left, right, self, width, height, leftX, midX, rightX, focusTop, focusAnchor, drawn } = layout;
|
|
227
227
|
const drawing = (_jsxs(_Fragment, { children: [_jsx(Arrow, { id: "arrow", size: 7 }), left.map((node) => (_jsxs("g", { children: [_jsx(Edge, { x1: leftX + NODE_W, y1: node.top + HEAD_H / 2, x2: midX, y2: focusAnchor, label: node.columns.join(' · '), marker: "arrow" }), _jsx(Node, { tableId: node.table, x: leftX, y: node.top, role: "out", repaint: repaint })] }, node.table))), right.map((node) => (_jsxs("g", { children: [_jsx(Edge, { x1: rightX, y1: node.top + HEAD_H / 2, x2: midX + NODE_W, y2: focusAnchor, label: node.columns.join(' · '), marker: "arrow" }), _jsx(Node, { tableId: node.table, x: rightX, y: node.top, role: "in", repaint: repaint })] }, node.table))), self.length ? (_jsxs(_Fragment, { children: [_jsx("path", { className: "edge", markerEnd: "url(#arrow)", d: `M${midX + NODE_W * 0.3},${focusTop} C${midX + NODE_W * 0.1},${focusTop - 34} ${midX + NODE_W * 0.9},${focusTop - 34} ${midX + NODE_W * 0.7},${focusTop}` }), _jsx("text", { x: midX + NODE_W / 2, y: focusTop - 22, className: "edge-label", textAnchor: "middle", children: self.map((fk) => fk.from.columns.join(', ')).join(' · ') })] })) : null, _jsx(Node, { tableId: tableId, x: midX, y: focusTop, role: "focus", repaint: repaint })] }));
|
|
228
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "diagram-head", children: [_jsx("h2", { className: "diagram-title", children: say('andWhatItTouches', { name: focus.name }) }), _jsx(SchemaExportControl, { schema: schemaOf(), only: drawn, picture: () => ({ svg: svg.current ?? undefined, size: { width, height } }) })] }), _jsx(PanZoom, { size: { width, height }, focus: { x: midX + NODE_W / 2, y: focusAnchor }, svgRef: svg, label: say('
|
|
228
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "diagram-head", children: [_jsx("h2", { className: "diagram-title", children: say('andWhatItTouches', { name: focus.name }) }), _jsx(SchemaExportControl, { schema: schemaOf(), only: drawn, picture: () => ({ svg: svg.current ?? undefined, size: { width, height } }) })] }), _jsx(PanZoom, { size: { width, height }, focus: { x: midX + NODE_W / 2, y: focusAnchor }, svgRef: svg, label: say('foreignKeyNeighborhood', { tableId }), expand: expandable ? () => setFull(true) : undefined, children: drawing }), _jsxs("p", { className: "diagram-legend", children: [_jsx("span", { className: "legend-out", children: say('points') }), _jsx("span", { children: ` ${focus.name} ` }), _jsx("span", { className: "legend-in", children: say('pointed') })] }), full ? (_jsx(Fullscreen, { onClose: () => setFull(false), children: _jsx("div", { className: "diagram", children: _jsx(NeighbourhoodDiagram, { tableId: tableId, expandable: false }) }) })) : null] }));
|
|
229
229
|
}
|
|
230
230
|
/* ---------- the whole schema ---------- */
|
|
231
231
|
export function SchemaDiagram({ expandable = true }) {
|
|
@@ -72,6 +72,10 @@ const FOLD_ROOM = 150;
|
|
|
72
72
|
const TAGS_SHOWN = 3;
|
|
73
73
|
/* The mark a reference's head draws after its label, and its sizing counts. */
|
|
74
74
|
const REFERENCE_MARK = '→';
|
|
75
|
+
/** A head's caret and each of its move buttons: 24px (style.css, `.th-filter`, `.th-move`). */
|
|
76
|
+
const HEAD_CONTROL = 24;
|
|
77
|
+
/** A device that cannot hover keeps a head's caret and moves in the head's flow, beside its label (style.css). */
|
|
78
|
+
const touchHeads = () => typeof matchMedia === 'function' && matchMedia('(hover: none)').matches;
|
|
75
79
|
/** Beyond a few hundred rows the DOM, not the database, is the bottleneck. */
|
|
76
80
|
const VIRTUAL_THRESHOLD = 300;
|
|
77
81
|
const OVERSCAN = 12;
|
|
@@ -571,6 +575,12 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
571
575
|
/* A reference's arrow stands beside its label in the sort (the head, below), after the sort's 4px gap:
|
|
572
576
|
uncounted, it took the room past the label that the resizer's strip is (style.css). */
|
|
573
577
|
mark: byName.get(name)?.references ? 4 + (headMeasure ? headSet(REFERENCE_MARK) : GRID_HEAD_CHAR) : undefined,
|
|
578
|
+
/* On touch the head's caret and moves stand beside its label, which gives way to them. The key's label is the
|
|
579
|
+
shortest and gave way whole: a phone drew the Workbench's "id KEY ↓" as "KEY ↓". Its column keeps their
|
|
580
|
+
room; any other head's label may still give way, as it was designed to. */
|
|
581
|
+
touchControls: byName.get(name)?.primaryKey && !shell().inApp() && touchHeads()
|
|
582
|
+
? HEAD_CONTROL * ((interactive ? 2 : 0) + (language && (!table?.filterable || table.filterable.includes(name)) ? 1 : 0))
|
|
583
|
+
: undefined,
|
|
574
584
|
showTime: plan.showTime,
|
|
575
585
|
values: rows.slice(0, GRID_SIZE_SAMPLE).map((row) => {
|
|
576
586
|
if (labelColumn && row[labelColumn] != null)
|
|
@@ -610,7 +620,23 @@ export function Grid({ table, data, hide, labels, totals, totalsLabel = say('tot
|
|
|
610
620
|
(Boolean(display?.tone && !display.format && !display.bar) ||
|
|
611
621
|
(Boolean(byName.get(name)?.allowed?.length) && STATUS_NAME.test(name))),
|
|
612
622
|
};
|
|
613
|
-
}), [
|
|
623
|
+
}), [
|
|
624
|
+
asked,
|
|
625
|
+
plans,
|
|
626
|
+
referenceLabels,
|
|
627
|
+
table?.id,
|
|
628
|
+
table?.filterable,
|
|
629
|
+
labels,
|
|
630
|
+
interactive,
|
|
631
|
+
language,
|
|
632
|
+
captionLanguage,
|
|
633
|
+
byName,
|
|
634
|
+
rows,
|
|
635
|
+
titleName,
|
|
636
|
+
headFace,
|
|
637
|
+
cellChips,
|
|
638
|
+
shift,
|
|
639
|
+
]);
|
|
614
640
|
/* Column i's cell follows the expander's when there is one. */
|
|
615
641
|
const measureText = useMemo(() => cellFonts.length
|
|
616
642
|
? (text, column) => textMeasure(cellFonts[Math.min(column + (slotted ? 1 : 0), cellFonts.length - 1)])?.(text) ?? text.length * 8
|
|
@@ -89,5 +89,5 @@ export function SchemaSummary({ shape, label, id }) {
|
|
|
89
89
|
setOpen(id, !open);
|
|
90
90
|
};
|
|
91
91
|
const start = shape.start;
|
|
92
|
-
return (_jsxs("section", { className: open ? 'shape' : 'shape shape-closed', children: [_jsxs("div", { className: "shape-head", children: [_jsx("button", { type: "button", className: "shape-toggle", "aria-expanded": open, title: say('showOrHideTheSummary'), onClick: toggle, children: label }), _jsx("span", { className: "shape-counts", children: say('common.tables', { count: counts.tables }) + (counts.views ? `, ${say('views', { count: counts.views })}` : '') }), shape.hubs.length ? _jsx("span", { className: "shape-gist", children: say('
|
|
92
|
+
return (_jsxs("section", { className: open ? 'shape' : 'shape shape-closed', children: [_jsxs("div", { className: "shape-head", children: [_jsx("button", { type: "button", className: "shape-toggle", "aria-expanded": open, title: say('showOrHideTheSummary'), onClick: toggle, children: label }), _jsx("span", { className: "shape-counts", children: say('common.tables', { count: counts.tables }) + (counts.views ? `, ${say('views', { count: counts.views })}` : '') }), shape.hubs.length ? _jsx("span", { className: "shape-gist", children: say('centers', { name: shape.hubs[0].table.name }) }) : null, start ? (_jsx("button", { type: "button", className: "ghost shape-start", title: say('theTableThatConnects'), onClick: () => go(tableView(start.id), 'reset'), children: say('start', { name: start.name }) })) : null] }), _jsxs("div", { className: "shape-body", children: [_jsxs("ul", { className: "shape-lines", children: [shape.hubs.length ? (_jsxs(Line, { label: say('centersOnLabel'), children: [_jsx(Link, { table: shape.hubs[0].table }), say('referencedByOtherTables', { incoming: shape.hubs[0].incoming }), shape.hubs.length > 1 ? (_jsxs(_Fragment, { children: ['. Then ', _jsx(TableList, { tables: shape.hubs.slice(1).map((h) => h.table) })] })) : null] })) : null, shape.leaves.length ? (_jsx(Line, { label: say('recordsEvents'), children: _jsx(TableList, { tables: shape.leaves }) })) : null, shape.joins.length ? (_jsxs(Line, { label: say('connectedThrough'), children: [_jsx(TableList, { tables: shape.joins.map((j) => j.table) }), shape.joins.length === 1 ? say('aJoinTable') : say('whichAreJoinTables')] })) : null, shape.chain.length > 2 ? (_jsx(Line, { label: say('deepestWalk'), children: shape.chain.map((t, i) => (_jsxs(Fragment, { children: [i ? _jsx("span", { className: "shape-arrow", children: " \u2192 " }) : null, _jsx(Link, { table: t })] }, t.id))) })) : null, shape.islands.length ? (_jsxs(Line, { label: say('standingAlone'), children: [_jsx(TableList, { tables: shape.islands }), shape.islands.length === 1 ? say('noForeignKeys') : say('noForeignKeysAtAll')] })) : null] }), _jsx(StartingPoints, { shape: shape })] })] }));
|
|
93
93
|
}
|
|
@@ -26,6 +26,9 @@ interface GridColumnSize {
|
|
|
26
26
|
/** What the sort draws beside the label on its line, the gap before it included: a reference's arrow. A head that
|
|
27
27
|
wraps keeps it beside the label's line, so it is room on both floors. */
|
|
28
28
|
mark?: number;
|
|
29
|
+
/** What stands in the head's flow beside the sort on a device that cannot hover (its caret and move buttons,
|
|
30
|
+
style.css): room on both floors, as `mark` is. */
|
|
31
|
+
touchControls?: number;
|
|
29
32
|
showTime?: boolean;
|
|
30
33
|
/** The column that names the row: it is read whole before the others are. */
|
|
31
34
|
title?: boolean;
|
|
@@ -39,7 +39,7 @@ export function columnSizeHint(column, headChar = GRID_HEAD_CHAR, measure, squee
|
|
|
39
39
|
edge, which the sort never reaches under (style.css); a reference's arrow beside the label is room too (`mark`).
|
|
40
40
|
Its menu caret and its move buttons stand past the label's end where a pointer hovers, so they are not reserved. */
|
|
41
41
|
const counted = Math.min(column.label.length, 22) * headChar;
|
|
42
|
-
const around = (column.controls ? 34 : 28) + (column.mark ?? 0);
|
|
42
|
+
const around = (column.controls ? 34 : 28) + (column.mark ?? 0) + (column.touchControls ?? 0);
|
|
43
43
|
const header = Math.ceil(column.headWidth === undefined ? counted : Math.min(column.headWidth, counted * 1.15)) + around;
|
|
44
44
|
/* An App's head wraps before it widens its column: the floor is its two-line width, and the whole label stays
|
|
45
45
|
what the column wants, so a table with room for it still draws every head on one line. */
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const say: import("../../messages.js").RoomMessage<{
|
|
2
2
|
readonly default: "Default";
|
|
3
3
|
readonly workbenchDefault: "Workbench default";
|
|
4
|
+
readonly hostLookId: "A host look's id is lowercase letters, digits and dashes: \"{id}\".";
|
|
5
|
+
readonly hostLookTaken: "The host look \"{id}\" has a name the picker already offers.";
|
|
4
6
|
}>;
|
|
@@ -3,4 +3,6 @@ import { defineMessages } from '../../messages.js';
|
|
|
3
3
|
export const say = defineMessages({
|
|
4
4
|
default: 'Default',
|
|
5
5
|
workbenchDefault: 'Workbench default',
|
|
6
|
+
hostLookId: 'A host look\'s id is lowercase letters, digits and dashes: "{id}".',
|
|
7
|
+
hostLookTaken: 'The host look "{id}" has a name the picker already offers.',
|
|
6
8
|
});
|
|
@@ -54,9 +54,9 @@ export declare const say: import("../../../messages.js").RoomMessage<{
|
|
|
54
54
|
readonly smallest: "Smallest {column}";
|
|
55
55
|
readonly latest: "Latest {column}";
|
|
56
56
|
readonly largest: "Largest {column}";
|
|
57
|
-
readonly
|
|
57
|
+
readonly summarize: "Summarize…";
|
|
58
58
|
readonly aTotalAnAverage: "a total, an average, a range";
|
|
59
|
-
readonly
|
|
59
|
+
readonly summarizeName: "Summarize {name}";
|
|
60
60
|
readonly aViewIsOne: "A view is one row per {name}, ";
|
|
61
61
|
readonly withAnyFieldFromAny: "with any field from any table it points at. Tick fields here; press “Add” beside a related table on the left to bring its fields into this list too.";
|
|
62
62
|
readonly baseTableGroup: "base table";
|
|
@@ -50,9 +50,9 @@ export const say = defineMessages({
|
|
|
50
50
|
smallest: 'Smallest {column}',
|
|
51
51
|
latest: 'Latest {column}',
|
|
52
52
|
largest: 'Largest {column}',
|
|
53
|
-
|
|
53
|
+
summarize: 'Summarize…',
|
|
54
54
|
aTotalAnAverage: 'a total, an average, a range',
|
|
55
|
-
|
|
55
|
+
summarizeName: 'Summarize {name}',
|
|
56
56
|
aViewIsOne: 'A view is one row per {name}, ',
|
|
57
57
|
withAnyFieldFromAny: 'with any field from any table it points at. Tick fields here; press “Add” beside a related table on the left to bring its fields into this list too.',
|
|
58
58
|
baseTableGroup: 'base table',
|
|
@@ -17,7 +17,7 @@ export declare const say: import("../../../messages.js").RoomMessage<{
|
|
|
17
17
|
readonly unknownTable: "Unknown table.";
|
|
18
18
|
readonly hasNoForeignKeys: "{tableId} has no foreign keys in either direction.";
|
|
19
19
|
readonly andWhatItTouches: "{name} and what it touches";
|
|
20
|
-
readonly
|
|
20
|
+
readonly foreignKeyNeighborhood: "Foreign key neighborhood of {tableId}";
|
|
21
21
|
readonly points: "points at →";
|
|
22
22
|
readonly pointed: "← pointed at by";
|
|
23
23
|
readonly thisDatabaseHasNoTables: "This database has no tables.";
|
|
@@ -16,7 +16,7 @@ export const say = defineMessages({
|
|
|
16
16
|
unknownTable: 'Unknown table.',
|
|
17
17
|
hasNoForeignKeys: '{tableId} has no foreign keys in either direction.',
|
|
18
18
|
andWhatItTouches: '{name} and what it touches',
|
|
19
|
-
|
|
19
|
+
foreignKeyNeighborhood: 'Foreign key neighborhood of {tableId}',
|
|
20
20
|
points: 'points at →',
|
|
21
21
|
pointed: '← pointed at by',
|
|
22
22
|
thisDatabaseHasNoTables: 'This database has no tables.',
|
|
@@ -4,10 +4,10 @@ export declare const say: import("../../../messages.js").RoomMessage<{
|
|
|
4
4
|
readonly queryLanguageParenQuestion: "Query language (?)";
|
|
5
5
|
readonly open: "Open {id}";
|
|
6
6
|
readonly showOrHideTheSummary: "Show or hide the summary";
|
|
7
|
-
readonly
|
|
8
|
-
readonly theTableThatConnects: "The table that connects to the most, with names you can
|
|
7
|
+
readonly centers: "centers on {name}";
|
|
8
|
+
readonly theTableThatConnects: "The table that connects to the most, with names you can recognize rows by";
|
|
9
9
|
readonly start: "Start at {name} →";
|
|
10
|
-
readonly
|
|
10
|
+
readonly centersOnLabel: "Centers on";
|
|
11
11
|
readonly referencedByOtherTables: ", referenced by {incoming} other tables";
|
|
12
12
|
readonly recordsEvents: "Records events in";
|
|
13
13
|
readonly connectedThrough: "Connected through";
|
|
@@ -6,10 +6,10 @@ export const say = defineMessages({
|
|
|
6
6
|
queryLanguageParenQuestion: 'Query language (?)',
|
|
7
7
|
open: 'Open {id}',
|
|
8
8
|
showOrHideTheSummary: 'Show or hide the summary',
|
|
9
|
-
|
|
10
|
-
theTableThatConnects: 'The table that connects to the most, with names you can
|
|
9
|
+
centers: 'centers on {name}',
|
|
10
|
+
theTableThatConnects: 'The table that connects to the most, with names you can recognize rows by',
|
|
11
11
|
start: 'Start at {name} →',
|
|
12
|
-
|
|
12
|
+
centersOnLabel: 'Centers on',
|
|
13
13
|
referencedByOtherTables: ', referenced by {incoming} other tables',
|
|
14
14
|
recordsEvents: 'Records events in',
|
|
15
15
|
connectedThrough: 'Connected through',
|
package/dist/client/features.css
CHANGED
|
@@ -1088,14 +1088,17 @@ body.type-sans {
|
|
|
1088
1088
|
Tabular numerals keep columns of figures aligned, which is what makes
|
|
1089
1089
|
a non-mono face survivable in a data tool. */
|
|
1090
1090
|
--mono: "Inter", "IBM Plex Sans", "Segoe UI Variable Text", ui-sans-serif, system-ui, sans-serif;
|
|
1091
|
+
/* The reader's pick wins over a host look's data face (tokens.css). */
|
|
1092
|
+
--data-face: var(--mono);
|
|
1091
1093
|
font-variant-numeric: tabular-nums;
|
|
1092
1094
|
}
|
|
1093
1095
|
/* The interface is sans everywhere (appnav points --mono at it). Code keeps
|
|
1094
1096
|
the code face; in the database browser so do the short values a grid sets
|
|
1095
|
-
apart — ids, dates, codes — as a data tool reads them
|
|
1096
|
-
|
|
1097
|
+
apart — ids, dates, codes — as a data tool reads them, unless a host look
|
|
1098
|
+
names its data face (--data-face, tokens.css), which the reader's own pick
|
|
1099
|
+
overrides. An App's lists read as its theme dresses them. */
|
|
1097
1100
|
body :is(.ddl, .explain, #query, .applist-filter, pre, code, kbd) { font-family: var(--code); }
|
|
1098
|
-
body:not(.app-mode):not(.type-sans) td.mono { font-family: var(--code); font-size: var(--text-sm); }
|
|
1101
|
+
body:not(.app-mode):not(.type-sans) td.mono { font-family: var(--data-face, var(--code)); font-size: var(--text-sm); }
|
|
1099
1102
|
body.type-sans .ddl,
|
|
1100
1103
|
body.type-sans .explain,
|
|
1101
1104
|
body.type-sans #query,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* The kit's own faces, for a host product's look (`@mistriwork/kit/client/fonts/faces.css`): every font file the kit
|
|
2
|
+
ships, declared once each under the family names its looks use, so a look of the host's own can name Barlow, Barlow
|
|
3
|
+
Semi Condensed, IBM Plex Mono or Inter in a stack, as Workshop, Ledger and Lumen do. Each is under the SIL Open Font
|
|
4
|
+
License, whose text travels beside it (the *-OFL.txt files here; the kit's Vite preset copies them into the build).
|
|
5
|
+
A rule costs nothing until a line is drawn in its family, so importing this sheet fetches no font a page does not
|
|
6
|
+
set. The looks' own sheets (workshopLook.css, ledgerLook.css, lumenLook.css) keep their own rules and their cut
|
|
7
|
+
fallbacks, so a page wearing a kit look never loads this one. `swap`, as theirs: a host holds its page until its
|
|
8
|
+
look's sheet is in (visualTheme.ts registerHostLooks), so the face is mostly there by the first paint. */
|
|
9
|
+
@font-face {
|
|
10
|
+
font-family: Barlow;
|
|
11
|
+
font-style: normal;
|
|
12
|
+
font-weight: 400;
|
|
13
|
+
font-display: swap;
|
|
14
|
+
src: url('./barlow-400.woff2') format('woff2');
|
|
15
|
+
}
|
|
16
|
+
@font-face {
|
|
17
|
+
font-family: Barlow;
|
|
18
|
+
font-style: normal;
|
|
19
|
+
font-weight: 600;
|
|
20
|
+
font-display: swap;
|
|
21
|
+
src: url('./barlow-600.woff2') format('woff2');
|
|
22
|
+
}
|
|
23
|
+
@font-face {
|
|
24
|
+
font-family: 'Barlow Semi Condensed';
|
|
25
|
+
font-style: normal;
|
|
26
|
+
font-weight: 700;
|
|
27
|
+
font-display: swap;
|
|
28
|
+
src: url('./barlow-semi-condensed-700.woff2') format('woff2');
|
|
29
|
+
}
|
|
30
|
+
@font-face {
|
|
31
|
+
font-family: 'IBM Plex Mono';
|
|
32
|
+
font-style: normal;
|
|
33
|
+
font-weight: 400;
|
|
34
|
+
font-display: swap;
|
|
35
|
+
src: url('./ibm-plex-mono-400.woff2') format('woff2');
|
|
36
|
+
}
|
|
37
|
+
@font-face {
|
|
38
|
+
font-family: 'IBM Plex Mono';
|
|
39
|
+
font-style: normal;
|
|
40
|
+
font-weight: 500;
|
|
41
|
+
font-display: swap;
|
|
42
|
+
src: url('./ibm-plex-mono-500.woff2') format('woff2');
|
|
43
|
+
}
|
|
44
|
+
/* Latin, variable from 100 to 900, its `tnum` cut to the ten figures (lumenLook.css says why). */
|
|
45
|
+
@font-face {
|
|
46
|
+
font-family: Inter;
|
|
47
|
+
font-style: normal;
|
|
48
|
+
font-weight: 100 900;
|
|
49
|
+
font-display: swap;
|
|
50
|
+
src: url('./inter-latin.woff2') format('woff2');
|
|
51
|
+
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
|
|
52
|
+
U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
53
|
+
}
|
|
@@ -7,12 +7,41 @@ export declare const VISUAL_THEME_REGISTRY_EVENT = "mistri:visual-theme-registry
|
|
|
7
7
|
/** The look inside an App when neither the reader nor the App names one.
|
|
8
8
|
Workbench instead defaults to its native tokens in style.css. */
|
|
9
9
|
export declare const DEFAULT_VISUAL_THEME = "workshop";
|
|
10
|
+
/**
|
|
11
|
+
* A look a host product declares for its own screens (the database browser's Workbench): its own stylesheet, worn
|
|
12
|
+
* over the native tokens rather than over a kit look. The reader picks it in Preferences beside the native default and
|
|
13
|
+
* the built-in looks; it persists as the Workbench's other picks do (`WORKBENCH_VISUAL_THEME_KEY`, which the startup
|
|
14
|
+
* veil's signature already reads, so its first paint is cached apart from every other look's), and while it is worn
|
|
15
|
+
* the root carries `data-host-look="<id>"` and no kit look attribute. Every rule in its sheet keys on that attribute,
|
|
16
|
+
* so a sheet left on the page after the reader picks another look draws nothing. An App's screens never offer one: an
|
|
17
|
+
* App is dressed by its own theme.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export interface HostLook {
|
|
21
|
+
/** Lowercase letters, digits and dashes, starting with a letter: the attribute's value and what is stored. */
|
|
22
|
+
id: string;
|
|
23
|
+
/** What Preferences calls it, in the host's words. */
|
|
24
|
+
label: string;
|
|
25
|
+
/** Its stylesheet: an address the page links, or a module that loads it (`() => import('./looks/blueprint.css')`). */
|
|
26
|
+
sheet: string | (() => Promise<unknown>);
|
|
27
|
+
/** Up to three colors the picker shows beside its name. */
|
|
28
|
+
swatches?: readonly string[];
|
|
29
|
+
}
|
|
10
30
|
/** The built-in looks, then the App's own themes. */
|
|
11
31
|
export declare function visualThemeOptions(): Array<{
|
|
12
32
|
value: string;
|
|
13
33
|
label: string;
|
|
14
34
|
swatches: readonly string[];
|
|
15
35
|
}>;
|
|
36
|
+
/** The host look worn, or undefined: the native default, a kit look, or an App's screen. @public */
|
|
37
|
+
export declare function hostLookChoice(): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The looks a host product offers on its own screens (`HostLook`), called once from its main before its shell boots:
|
|
40
|
+
* the stored pick is read again, since the page's look was worn before the main ran (shellStart.js), and a pick of a
|
|
41
|
+
* look the host no longer declares falls back to the native default for this page and stays stored.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function registerHostLooks(looks: readonly HostLook[]): void;
|
|
16
45
|
/** The look in force: the reader's pick, else the App's preset, else Workshop. */
|
|
17
46
|
export declare function visualThemeChoice(): string;
|
|
18
47
|
/** The theme the App itself wears, where this screen is an App's and the reader may pick another: what the picker marks and what a reset returns to. */
|
|
@@ -31,6 +31,10 @@ let palettePreferences = new Map();
|
|
|
31
31
|
let inApp = false;
|
|
32
32
|
let locked = false;
|
|
33
33
|
let isolated = false;
|
|
34
|
+
/** The attribute a worn host look sets on the root. */
|
|
35
|
+
const HOST_LOOK_ATTRIBUTE = 'data-host-look';
|
|
36
|
+
const LOOK_ID = /^[a-z][a-z0-9-]{0,47}$/;
|
|
37
|
+
let hostLooks = [];
|
|
34
38
|
const swatches = (theme) => [theme.light.navGround ?? theme.light.surface, theme.light.accent, theme.light.chart2 ?? theme.light.ink];
|
|
35
39
|
/** The built-in looks, then the App's own themes. */
|
|
36
40
|
export function visualThemeOptions() {
|
|
@@ -41,7 +45,52 @@ export function visualThemeOptions() {
|
|
|
41
45
|
label: theme.label,
|
|
42
46
|
swatches: swatches(effectiveThemeDefinition(theme, paletteChoiceFor(theme))),
|
|
43
47
|
}));
|
|
44
|
-
|
|
48
|
+
if (inApp)
|
|
49
|
+
return themes;
|
|
50
|
+
return [
|
|
51
|
+
{ value: 'default', label: say('workbenchDefault'), swatches: [] },
|
|
52
|
+
...hostLooks.map((look) => ({ value: look.id, label: look.label, swatches: look.swatches?.slice(0, 3) ?? [] })),
|
|
53
|
+
...themes,
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
/** The host look this screen wears, where it wears one. */
|
|
57
|
+
const wornHostLook = () => (inApp ? undefined : hostLooks.find((look) => look.id === workbenchPreferred));
|
|
58
|
+
/** Whether a kit look dresses this screen: always in an App; outside one, only the built-in look its reader picked, never
|
|
59
|
+
the native default or a host look, which are worn over the native tokens. */
|
|
60
|
+
const kitLookWorn = () => inApp || Boolean(workbenchPreferred && themePreset(workbenchPreferred));
|
|
61
|
+
/** The host look worn, or undefined: the native default, a kit look, or an App's screen. @public */
|
|
62
|
+
export function hostLookChoice() {
|
|
63
|
+
return wornHostLook()?.id;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The looks a host product offers on its own screens (`HostLook`), called once from its main before its shell boots:
|
|
67
|
+
* the stored pick is read again, since the page's look was worn before the main ran (shellStart.js), and a pick of a
|
|
68
|
+
* look the host no longer declares falls back to the native default for this page and stays stored.
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export function registerHostLooks(looks) {
|
|
72
|
+
const ids = new Set();
|
|
73
|
+
for (const look of looks) {
|
|
74
|
+
if (!LOOK_ID.test(look.id))
|
|
75
|
+
throw new Error(say('hostLookId', { id: look.id }));
|
|
76
|
+
if (look.id === 'default' || themePreset(look.id) || ids.has(look.id))
|
|
77
|
+
throw new Error(say('hostLookTaken', { id: look.id }));
|
|
78
|
+
ids.add(look.id);
|
|
79
|
+
}
|
|
80
|
+
hostLooks = [...looks];
|
|
81
|
+
workbenchPreferred = storedWorkbenchLook();
|
|
82
|
+
apply();
|
|
83
|
+
window.dispatchEvent(new Event(VISUAL_THEME_REGISTRY_EVENT));
|
|
84
|
+
}
|
|
85
|
+
/** The Workbench's stored pick, while it names a built-in look or a host look this page declares. */
|
|
86
|
+
function storedWorkbenchLook() {
|
|
87
|
+
try {
|
|
88
|
+
const value = window.localStorage.getItem(WORKBENCH_VISUAL_THEME_KEY);
|
|
89
|
+
return value && (themePreset(value) || hostLooks.some((look) => look.id === value)) ? value : undefined;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return undefined; /* Native Workbench needs no storage. */
|
|
93
|
+
}
|
|
45
94
|
}
|
|
46
95
|
const offered = (value) => typeof value === 'string' && visualThemeOptions().some((theme) => theme.value === value);
|
|
47
96
|
/** The look in force: the reader's pick, else the App's preset, else Workshop. */
|
|
@@ -101,7 +150,7 @@ export function resetVisualTheme() {
|
|
|
101
150
|
const ownColorsArePalette = (theme) => themePreset(theme.id) === theme && Boolean(theme.palettes?.some((palette) => palette.id === theme.defaultPalette));
|
|
102
151
|
/** Palette choices belong to their theme, not to an unrelated App using the same slug. */
|
|
103
152
|
export function visualPaletteOptions() {
|
|
104
|
-
if (!
|
|
153
|
+
if (!kitLookWorn())
|
|
105
154
|
return [];
|
|
106
155
|
const theme = selectedThemeBase();
|
|
107
156
|
return [
|
|
@@ -127,7 +176,7 @@ function paletteChoiceFor(theme) {
|
|
|
127
176
|
return offered(fallback) ? fallback : 'default';
|
|
128
177
|
}
|
|
129
178
|
export function visualPaletteChoice() {
|
|
130
|
-
if (!
|
|
179
|
+
if (!kitLookWorn())
|
|
131
180
|
return 'default';
|
|
132
181
|
return paletteChoiceFor(selectedThemeBase());
|
|
133
182
|
}
|
|
@@ -252,6 +301,33 @@ function themeSheet(href) {
|
|
|
252
301
|
}
|
|
253
302
|
return arriving;
|
|
254
303
|
}
|
|
304
|
+
/* A host look's sheet, fetched once: linked where it is an address, imported where it is a module. Like a kit look's,
|
|
305
|
+
one that cannot come leaves the native tokens, which read; it is not worth a failed boot. */
|
|
306
|
+
const hostSheets = new Map();
|
|
307
|
+
function hostSheet(look) {
|
|
308
|
+
let arriving = hostSheets.get(look.id);
|
|
309
|
+
if (!arriving) {
|
|
310
|
+
const failed = (error) => console.error(`The ${look.id} look's sheet did not load.`, error ?? '');
|
|
311
|
+
if (typeof look.sheet === 'function')
|
|
312
|
+
arriving = look.sheet().then(() => undefined, failed);
|
|
313
|
+
else {
|
|
314
|
+
const link = document.createElement('link');
|
|
315
|
+
link.rel = 'stylesheet';
|
|
316
|
+
link.href = look.sheet;
|
|
317
|
+
link.dataset.hostLook = look.id;
|
|
318
|
+
arriving = new Promise((settle) => {
|
|
319
|
+
link.addEventListener('load', () => settle(), { once: true });
|
|
320
|
+
link.addEventListener('error', () => {
|
|
321
|
+
failed();
|
|
322
|
+
settle();
|
|
323
|
+
}, { once: true });
|
|
324
|
+
});
|
|
325
|
+
document.head.append(link);
|
|
326
|
+
}
|
|
327
|
+
hostSheets.set(look.id, arriving);
|
|
328
|
+
}
|
|
329
|
+
return arriving;
|
|
330
|
+
}
|
|
255
331
|
function wearSheets(styles, ...also) {
|
|
256
332
|
const arriving = [...styles.map(sheet), ...also].filter((value) => value !== undefined);
|
|
257
333
|
lookSheet = arriving.length ? Promise.all(arriving).then(() => undefined) : Promise.resolve();
|
|
@@ -281,11 +357,17 @@ const LOOK_ATTRIBUTES = [
|
|
|
281
357
|
];
|
|
282
358
|
function apply() {
|
|
283
359
|
const root = shellRoot();
|
|
284
|
-
/* Native Workbench has no look attributes. Explicit picks use the
|
|
285
|
-
definitions, token owner and sheets as the App looks. */
|
|
286
|
-
|
|
360
|
+
/* Native Workbench has no look attributes, and a host look only its own. Explicit picks of a built-in look use the
|
|
361
|
+
same definitions, token owner and sheets as the App looks. */
|
|
362
|
+
const host = wornHostLook();
|
|
363
|
+
if (host)
|
|
364
|
+
root.setAttribute(HOST_LOOK_ATTRIBUTE, host.id);
|
|
365
|
+
else
|
|
366
|
+
root.removeAttribute(HOST_LOOK_ATTRIBUTE);
|
|
367
|
+
if (!kitLookWorn()) {
|
|
287
368
|
for (const name of LOOK_ATTRIBUTES)
|
|
288
369
|
root.removeAttribute(name);
|
|
370
|
+
wearSheets([], host && hostSheet(host));
|
|
289
371
|
void wearIconWeight(undefined);
|
|
290
372
|
facesStyle?.remove();
|
|
291
373
|
facesStyle = undefined;
|
|
@@ -340,13 +422,7 @@ export function initVisualTheme() {
|
|
|
340
422
|
catch {
|
|
341
423
|
preferred = null; /* The default needs no storage. */
|
|
342
424
|
}
|
|
343
|
-
|
|
344
|
-
const value = window.localStorage.getItem(WORKBENCH_VISUAL_THEME_KEY);
|
|
345
|
-
workbenchPreferred = value && themePreset(value) ? value : undefined;
|
|
346
|
-
}
|
|
347
|
-
catch {
|
|
348
|
-
workbenchPreferred = undefined; /* Native Workbench needs no storage. */
|
|
349
|
-
}
|
|
425
|
+
workbenchPreferred = storedWorkbenchLook();
|
|
350
426
|
customPreferences = new Map();
|
|
351
427
|
try {
|
|
352
428
|
const entries = JSON.parse(window.localStorage.getItem(CUSTOM_THEME_KEY) ?? '[]');
|
|
@@ -456,8 +532,9 @@ export function setVisualTheme(value) {
|
|
|
456
532
|
}
|
|
457
533
|
/** The look's own radius and data face; an App's authored values win over them in appnav. */
|
|
458
534
|
export function visualThemeOverrides() {
|
|
459
|
-
|
|
460
|
-
|
|
535
|
+
/* The native data face: a host look's `--data-face` where it sets one, else the code face (tokens.css). */
|
|
536
|
+
if (!kitLookWorn())
|
|
537
|
+
return { font: 'var(--data-face, var(--code))', square: false };
|
|
461
538
|
const definition = selectedThemeDefinition();
|
|
462
539
|
return {
|
|
463
540
|
...(definition.density ? { density: definition.density } : {}),
|
|
@@ -477,13 +554,13 @@ export function visualThemePalette(dark) {
|
|
|
477
554
|
/** The worn theme's part styles as custom properties, written where the App's accent is (appTheme.js) so a part in
|
|
478
555
|
`accent` is the App's own accent; none outside an App or for a theme without parts. */
|
|
479
556
|
export function customThemePartTokens() {
|
|
480
|
-
if (!
|
|
557
|
+
if (!kitLookWorn())
|
|
481
558
|
return {};
|
|
482
559
|
return partTokens(selectedThemeDefinition().parts);
|
|
483
560
|
}
|
|
484
561
|
/** Values only; appnav remains the sole writer of inline theme tokens. */
|
|
485
562
|
export function customThemeTokens(dark) {
|
|
486
|
-
if (!
|
|
563
|
+
if (!kitLookWorn())
|
|
487
564
|
return {};
|
|
488
565
|
const definition = selectedThemeDefinition();
|
|
489
566
|
const tokens = {};
|
|
@@ -373,7 +373,8 @@
|
|
|
373
373
|
/* Only new preference controls and explicit Mono use unscoped rules. */
|
|
374
374
|
.dd-swatches { display: inline-flex; flex: none; gap: var(--space-1h); margin-right: var(--space-2); }
|
|
375
375
|
.dd-swatches > span { display: block; width: 9px; height: 14px; border: 1px solid #80808050; border-radius: min(2px, var(--radius)); }
|
|
376
|
-
|
|
376
|
+
/* The reader's Mono wins over a host look's data face (tokens.css). */
|
|
377
|
+
body.type-mono { --mono: var(--code); --data-face: var(--code); }
|
|
377
378
|
/* Code surfaces keep the code face; a textarea of prose (a description, a reason) keeps the interface's. */
|
|
378
379
|
:root[data-visual-theme] .app-mode :is(.ddl, .explain, #query, .applist-filter, pre, .sql-input, .composer-text, .agent-json) { font-family: var(--code); }
|
|
379
380
|
/* A list's search box, in the kit with every other field (moved from ListFilterBar.css, which stands in the base). */
|
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.14",
|
|
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": {
|
|
@@ -42,6 +42,13 @@
|
|
|
42
42
|
"./client/delete.js": "./dist/client/delete.js",
|
|
43
43
|
"./client/density.js": "./dist/client/density.js",
|
|
44
44
|
"./client/draftRecovery.js": "./dist/client/draftRecovery.js",
|
|
45
|
+
"./client/fonts/barlow-400.woff2": "./dist/client/fonts/barlow-400.woff2",
|
|
46
|
+
"./client/fonts/barlow-600.woff2": "./dist/client/fonts/barlow-600.woff2",
|
|
47
|
+
"./client/fonts/barlow-semi-condensed-700.woff2": "./dist/client/fonts/barlow-semi-condensed-700.woff2",
|
|
48
|
+
"./client/fonts/faces.css": "./dist/client/fonts/faces.css",
|
|
49
|
+
"./client/fonts/ibm-plex-mono-400.woff2": "./dist/client/fonts/ibm-plex-mono-400.woff2",
|
|
50
|
+
"./client/fonts/ibm-plex-mono-500.woff2": "./dist/client/fonts/ibm-plex-mono-500.woff2",
|
|
51
|
+
"./client/fonts/inter-latin.woff2": "./dist/client/fonts/inter-latin.woff2",
|
|
45
52
|
"./client/help.js": "./dist/client/help.js",
|
|
46
53
|
"./client/historyToken.js": "./dist/client/historyToken.js",
|
|
47
54
|
"./client/insert.js": "./dist/client/insert.js",
|
|
@@ -75,8 +82,8 @@
|
|
|
75
82
|
"./package.json": "./package.json"
|
|
76
83
|
},
|
|
77
84
|
"dependencies": {
|
|
78
|
-
"@mistriwork/engine": "1.0.0-rc.
|
|
79
|
-
"@mistriwork/ui": "1.0.0-rc.
|
|
85
|
+
"@mistriwork/engine": "1.0.0-rc.14",
|
|
86
|
+
"@mistriwork/ui": "1.0.0-rc.14",
|
|
80
87
|
"intl-messageformat": "12.1.2",
|
|
81
88
|
"qrcode-generator": "^2.0.4"
|
|
82
89
|
},
|