@mistriwork/kit 1.0.0-rc.75 → 1.0.0-rc.78
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/brandLook.css +6 -1
- package/dist/client/choiceEntries.d.ts +21 -0
- package/dist/client/choiceEntries.js +18 -0
- package/dist/client/components/AppList.js +36 -26
- package/dist/client/components/CardsList.js +2 -1
- package/dist/client/components/FilterTabs.d.ts +53 -0
- package/dist/client/components/FilterTabs.js +23 -0
- package/dist/client/components/ListFilterBar.css +3 -0
- package/dist/client/components/ListFilterBar.d.ts +26 -0
- package/dist/client/components/ListFilterBar.js +2 -2
- package/dist/client/components/NewRecord.js +5 -1
- package/dist/client/components/PageFields.js +4 -1
- package/dist/client/components/dashboardModel.d.ts +4 -0
- package/dist/client/components/newRecordModel.d.ts +8 -1
- package/dist/client/components/newRecordModel.js +23 -1
- package/dist/client/copy/lists/components/AppList.d.ts +3 -0
- package/dist/client/copy/lists/components/AppList.js +3 -0
- package/dist/client/core.js +7 -0
- package/dist/client/features.css +1 -1
- package/dist/client/firstPaint.js +9 -0
- package/dist/client/lumenLook.css +2 -2
- package/dist/client/rowEditing.js +10 -5
- package/dist/client/sageLook.css +1 -1
- package/dist/client/shellMode.d.ts +3 -0
- package/dist/client/shellMode.js +2 -0
- package/dist/client/structure.css +7 -0
- package/dist/client/style.css +1 -1
- package/dist/client/themeFamilies.css +3 -3
- package/dist/client/tilesLook.css +2 -2
- package/dist/client/visualThemes.css +1 -1
- package/package.json +3 -3
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
like, on a bar with 4px to spare. */
|
|
41
41
|
padding-block: var(--space-2);
|
|
42
42
|
}
|
|
43
|
+
/* The App-wide choice's trigger is a tenant-control trigger; its word and pick take the bar's ink, not the page's
|
|
44
|
+
muted and body ink, which are dark on a dark ground. */
|
|
45
|
+
:root[data-look-bar='dark'] .app-mode .topbar .choice-control-trigger :is(bdi, .choice-control-word) {
|
|
46
|
+
color: inherit;
|
|
47
|
+
}
|
|
43
48
|
:root[data-look-bar='dark'] .app-mode .topbar :is(.new-menu, .tenant-control-host) {
|
|
44
49
|
align-self: center;
|
|
45
50
|
}
|
|
@@ -135,7 +140,7 @@
|
|
|
135
140
|
:root[data-look-table='banded'] .table-wrap tbody tr:nth-child(even):hover td {
|
|
136
141
|
background: color-mix(in srgb, var(--ink) 6%, var(--band, var(--raised)));
|
|
137
142
|
}
|
|
138
|
-
:root[data-look-tabs='rule'] :is(.tab, :where(body.app-mode) .page-tab)[aria-selected='true'] {
|
|
143
|
+
:root[data-look-tabs='rule'] :is(.tab, :where(body.app-mode) .page-tab):is([aria-selected='true'], [aria-pressed='true']) {
|
|
139
144
|
background: none;
|
|
140
145
|
color: var(--ink);
|
|
141
146
|
border-radius: 0;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The App's choosers, as a list can reach them. Below the width the bar holds one, a chooser leaves the bar and is an
|
|
3
|
+
* item of the account menu, which opens the same dialog; a list narrowed by a choice (`chosen.site`) opens it from a chip.
|
|
4
|
+
* Each mounted chooser says here what it shows and how to open it. Kept in the kit, which draws the chip, and read by
|
|
5
|
+
* the shell's account menu; the chooser itself is the shell's (ChoiceControl.tsx).
|
|
6
|
+
*/
|
|
7
|
+
export interface ChoiceEntry {
|
|
8
|
+
/** The choice's name in `choose` (`site`), so a chip on a list it filters can open this chooser. */
|
|
9
|
+
readonly choice: string;
|
|
10
|
+
/** "Site:", the choice's name as the menu says it. */
|
|
11
|
+
readonly word: string;
|
|
12
|
+
/** The picked row's label, or the chooser's "Choose site" where nothing is picked. */
|
|
13
|
+
readonly name: string;
|
|
14
|
+
/** The picked row's label; absent where nothing is picked (or the pick is not yet read). */
|
|
15
|
+
readonly picked?: string;
|
|
16
|
+
readonly open: () => void;
|
|
17
|
+
}
|
|
18
|
+
/** Said by a chooser while it is mounted; undefined takes back the one it replaces, and only that one. */
|
|
19
|
+
export declare function setChoiceEntry(next: ChoiceEntry | undefined, replacing?: ChoiceEntry): void;
|
|
20
|
+
export declare const choiceEntries: () => readonly ChoiceEntry[];
|
|
21
|
+
export declare function subscribeChoiceEntries(listener: () => void): () => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
let entries = [];
|
|
2
|
+
const entryListeners = new Set();
|
|
3
|
+
/** Said by a chooser while it is mounted; undefined takes back the one it replaces, and only that one. */
|
|
4
|
+
export function setChoiceEntry(next, replacing) {
|
|
5
|
+
const kept = replacing ? entries.filter((entry) => entry !== replacing) : entries;
|
|
6
|
+
if (next === undefined && kept.length === entries.length)
|
|
7
|
+
return;
|
|
8
|
+
entries = next ? [...kept, next] : kept;
|
|
9
|
+
for (const listener of [...entryListeners])
|
|
10
|
+
listener();
|
|
11
|
+
}
|
|
12
|
+
export const choiceEntries = () => entries;
|
|
13
|
+
export function subscribeChoiceEntries(listener) {
|
|
14
|
+
entryListeners.add(listener);
|
|
15
|
+
return () => {
|
|
16
|
+
entryListeners.delete(listener);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -25,10 +25,13 @@ import { useMessageLanguage } from './useMessageLanguage.js';
|
|
|
25
25
|
import { createPortal } from 'react-dom';
|
|
26
26
|
import { listControlsRef, listHeadRef, useCrumbSlots } from './crumbSlot.js';
|
|
27
27
|
import { FavoriteStar } from './FavoriteStar.js';
|
|
28
|
-
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
28
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
29
29
|
import { useMutation, useQueries, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
30
30
|
import { api, columnLabel, labelPath, pageSize, recordLabel, state as walk, toast } from '../core.js';
|
|
31
31
|
import { say } from '../copy/lists/components/AppList.js';
|
|
32
|
+
import { choiceEntries, subscribeChoiceEntries } from '../choiceEntries.js';
|
|
33
|
+
import { choicesNamed } from '@mistriwork/engine/shared/queryOperands.js';
|
|
34
|
+
import { humanName } from '@mistriwork/engine/shared/model.js';
|
|
32
35
|
import { LABEL_SEGMENT } from '@mistriwork/engine/shared/recordLabel.js';
|
|
33
36
|
/* The walk's state, with the field core.js's JSDoc does not declare. */
|
|
34
37
|
const state = walk;
|
|
@@ -38,7 +41,6 @@ import { splitConditions, splitQuery } from '../clauses.js';
|
|
|
38
41
|
import { promptFor } from '../prompt.js';
|
|
39
42
|
import { canonicalize, conditionTail, deriveFilterNames, mentionsColumn, ownedTails, squeeze, withCondition } from '../filterbar.js';
|
|
40
43
|
import { exportOffered } from '@mistriwork/engine/shared/listPresentations.js';
|
|
41
|
-
import { humanName } from '@mistriwork/engine/shared/model.js';
|
|
42
44
|
import { pluralOf, recordNoun } from '@mistriwork/engine/shared/appNoun.js';
|
|
43
45
|
import { primaryKey } from '@mistriwork/engine/shared/schema.js';
|
|
44
46
|
import { findTable } from '../core.js';
|
|
@@ -59,7 +61,7 @@ function oneValue(tail) {
|
|
|
59
61
|
}
|
|
60
62
|
import { useConditionWords } from './useConditionWords.js';
|
|
61
63
|
import { message } from '../messages.js';
|
|
62
|
-
import {
|
|
64
|
+
import { FilterTabs, TabCount } from './FilterTabs.js';
|
|
63
65
|
import { DropGroup, DropItem, DropMenu } from '@mistriwork/ui/DropMenu.js';
|
|
64
66
|
import { FilterRail, FilterSheet } from './FilterRail.js';
|
|
65
67
|
import { clearFacets, facetActive } from './filterRailModel.js';
|
|
@@ -148,13 +150,6 @@ function knownCounts(client) {
|
|
|
148
150
|
lastKnown = known;
|
|
149
151
|
return known;
|
|
150
152
|
}
|
|
151
|
-
/** A tab's badge: its count from the batch, or the grid's own total when the tab is the one on screen. */
|
|
152
|
-
function TabCount({ counted }) {
|
|
153
|
-
// null is a current result with no count, not permission to show an older one.
|
|
154
|
-
const said = counted == null ? '' : `${formatNumber(counted.total)}${counted.capped ? '+' : ''}`;
|
|
155
|
-
/* The number in a box of its own, over the room a tab keeps for it (features.css). */
|
|
156
|
-
return _jsx("span", { className: "tab-count", children: said && _jsx("span", { children: said }) });
|
|
157
|
-
}
|
|
158
153
|
/* The switch's width where a list has drawn one, by the list's table: a list is made again on a change of tab, and
|
|
159
154
|
the room it held would be forgotten with it. */
|
|
160
155
|
const switchRoom = new Map();
|
|
@@ -282,15 +277,6 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
|
|
|
282
277
|
const store = saved.store;
|
|
283
278
|
const savable = !inDashboard && (store === 'shared' || store === 'account');
|
|
284
279
|
const yourLit = yours.findIndex((f) => canonicalize(f.query) === canonicalize(refinement));
|
|
285
|
-
/* The strip fits its row (useTabFold.ts): the list's tabs by their place, then the saved views' heading, then each
|
|
286
|
-
saved view; what does not fit is under More, and the lit one never is. */
|
|
287
|
-
const savedAt = tabs.length + 1;
|
|
288
|
-
const { strip: tabStrip, folded } = useTabFold(tabs.length + (yours.length ? yours.length + 1 : 0), yourLit === -1 ? litTab : savedAt + yourLit);
|
|
289
|
-
const foldMark = (at) => ({
|
|
290
|
-
'data-fold': at,
|
|
291
|
-
'data-folded': folded.has(at) ? '' : undefined,
|
|
292
|
-
'aria-hidden': folded.has(at) || undefined,
|
|
293
|
-
});
|
|
294
280
|
const writeViews = useMutation({
|
|
295
281
|
mutationFn: (change) => writeSavedViews(client, viewKey, change),
|
|
296
282
|
onError: (err) => toast(err.message, 'error'),
|
|
@@ -349,7 +335,26 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
|
|
|
349
335
|
}
|
|
350
336
|
if (residueChip)
|
|
351
337
|
chips.push(residueChip);
|
|
352
|
-
|
|
338
|
+
/* A choice that narrows this list (`chosen.site` in its query) is said beside what the reader applied, so a link
|
|
339
|
+
shared with someone who has picked another site reads as different. It has no x: the way out is another pick,
|
|
340
|
+
which the chip opens. Drawn from the App's declaration, so the row does not wait on the chooser mounting. */
|
|
341
|
+
const choosers = useSyncExternalStore(subscribeChoiceEntries, choiceEntries, () => []);
|
|
342
|
+
const declaredChoices = shell().app()?.choose;
|
|
343
|
+
const chosenChips = declaredChoices
|
|
344
|
+
? choicesNamed(entry.query, appListQuery(spec, 0), ...tabs.map((_, i) => appListQuery(spec, i)))
|
|
345
|
+
.filter((name) => declaredChoices[name])
|
|
346
|
+
.map((name) => {
|
|
347
|
+
const chooser = choosers.find((c) => c.choice === name);
|
|
348
|
+
const thing = humanName(name);
|
|
349
|
+
const value = chooser?.picked ?? (chooser ? say('chosenNone') : '');
|
|
350
|
+
const text = say('chosen', { thing, value });
|
|
351
|
+
return (_jsx("span", { className: "applist-chip applist-chip-chosen", "data-choice": name, title: text, children: _jsxs("button", { type: "button", className: "applist-chip-text applist-chip-open", "aria-haspopup": "dialog", "aria-label": `${text}. ${say('chosenChange', { thing: thing.toLowerCase() })}`, disabled: !chooser, onClick: chooser?.open, children: [_jsx("span", { className: "applist-chip-label", children: `${thing}: ` }), _jsx("span", { className: "applist-chip-value", children: value })] }) }, `chosen-${name}`));
|
|
352
|
+
})
|
|
353
|
+
: [];
|
|
354
|
+
const chipList = [
|
|
355
|
+
...chosenChips,
|
|
356
|
+
...chips.map((c) => (_jsxs("span", { className: "applist-chip", title: c.text, children: [_jsx("span", { className: "applist-chip-text", children: c.text }), _jsx("button", { type: "button", className: "applist-chip-x", "aria-label": say('common.remove2', { text: c.text }), onClick: c.remove, children: "\u00D7" })] }, c.text))),
|
|
357
|
+
];
|
|
353
358
|
const isDefault = canonicalize(entry.query) === canonicalize(appListQuery(spec, 0));
|
|
354
359
|
const exactTab = litTab >= 0 && canonicalize(refinement) === canonicalize(tabs[litTab].query ?? '');
|
|
355
360
|
const offerSave = savable && !(isDefault || exactTab || yourLit >= 0 || !refinement);
|
|
@@ -753,15 +758,20 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
|
|
|
753
758
|
const headTo = ownList && spec.link ? openLink?.(spec.link.view, 'reset', { tab: spec.link.tab }) : undefined;
|
|
754
759
|
const headLink = headTo && spec.link ? (_jsx("a", { className: "applist-link", ...headTo, children: spec.link.label })) : null;
|
|
755
760
|
return (_jsxs(_Fragment, { children: [boundNames.map((name) => (_jsx(DefinedBoxes, { column: name, binding: bound[name], per: bound[name].per ? oneValue(conditionTail(refinement, bound[name].per)) : undefined, onBoxes: onDefinedBoxes }, name))), inBar && createPortal(title, crumbs.note), inBar &&
|
|
756
|
-
createPortal(_jsxs(_Fragment, { children: [headLink, viewsMenu, pageVerbs] }), crumbs.tools), _jsxs("div", { className: `applist-head${inBar ? ' in-crumbs' : ''}`, children: [!inBar && !inDashboard && (_jsxs("div", { className: "applist-head-row", ref: head, children: [title, ownList ? (_jsxs("div", { className: "applist-head-tools", children: [headLink, viewsMenu, _jsx("span", { className: "applist-head-slot", ref: listHeadRef }), pageVerbs] })) : (pageVerbs)] })), !beside && !chipsInBar && _jsx("div", { className: "applist-chips", children: chipList })] }), summary, _jsxs("div", { className: "applist-controls", role: "group", "aria-label": say('listControls', { caption }), children: [(tabs.length > 1 || yours.length > 0) && (
|
|
761
|
+
createPortal(_jsxs(_Fragment, { children: [headLink, viewsMenu, pageVerbs] }), crumbs.tools), _jsxs("div", { className: `applist-head${inBar ? ' in-crumbs' : ''}`, children: [!inBar && !inDashboard && (_jsxs("div", { className: "applist-head-row", ref: head, children: [title, ownList ? (_jsxs("div", { className: "applist-head-tools", children: [headLink, viewsMenu, _jsx("span", { className: "applist-head-slot", ref: listHeadRef }), pageVerbs] })) : (pageVerbs)] })), !beside && !chipsInBar && _jsx("div", { className: "applist-chips", children: chipList })] }), summary, _jsxs("div", { className: "applist-controls", role: "group", "aria-label": say('listControls', { caption }), children: [(tabs.length > 1 || yours.length > 0) && (_jsx(FilterTabs, { tabs: tabs.map((tab, i) => ({ key: tab.label, label: tab.label, count: countOf(i) })), lit: yourLit === -1 ? litTab : -1, onPick: pickTab, extra: {
|
|
762
|
+
count: yours.length ? yours.length + 1 : 0,
|
|
763
|
+
lit: yourLit === -1 ? -1 : 1 + yourLit,
|
|
764
|
+
row: (foldMark) => (_jsxs(_Fragment, { children: [yours.length > 0 && (_jsxs("span", { className: "tab-group", ...foldMark(0), "aria-hidden": "true", children: [tabs.length > 1 && _jsx("span", { className: "tab-divider" }), _jsx("span", { className: "tab-group-label", children: store === 'account' ? say('myViews') : say('savedViews') })] })), yours.map((f, i) => (_jsxs("span", { className: "tab-wrap", role: "presentation", ...foldMark(1 + i), children: [_jsxs("button", { type: "button", role: "tab", className: "tab tab-yours", "aria-selected": i === yourLit, title: `${viewWords(f.query) || say('everything')} — ${store === 'account' ? say('yourView') : say('aSavedView')}`, onClick: () => {
|
|
757
765
|
if (i !== yourLit) {
|
|
758
766
|
state.page = 0;
|
|
759
767
|
apply(f.query);
|
|
760
768
|
}
|
|
761
|
-
}, children: [_jsx("span", { children: f.name }), _jsx(TabCount, { counted: tabCounts?.get(squeeze(`${entry.table} ${f.query}`)) })] }), savable && (_jsx("button", { type: "button", className: "tab-x", title: say('common.removeName', { name: f.name }), "aria-label": say('removeTheView', { name: f.name }), onClick: () => writeViews.mutate((views) => withoutView(views, f.name)), children: "\u00D7" }))] }, f.name)))] })
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
769
|
+
}, children: [_jsx("span", { children: f.name }), _jsx(TabCount, { counted: tabCounts?.get(squeeze(`${entry.table} ${f.query}`)) })] }), savable && (_jsx("button", { type: "button", className: "tab-x", title: say('common.removeName', { name: f.name }), "aria-label": say('removeTheView', { name: f.name }), onClick: () => writeViews.mutate((views) => withoutView(views, f.name)), children: "\u00D7" }))] }, f.name)))] })),
|
|
770
|
+
more: (folded) => yours.some((_, i) => folded(1 + i)) && (_jsx(DropGroup, { labelClassName: "more-group-label", label: store === 'account' ? say('myViews') : say('savedViews'), children: yours.map((f, i) => folded(1 + i) ? (_jsx(DropItem, { className: "page-actions-item", onClick: () => {
|
|
771
|
+
state.page = 0;
|
|
772
|
+
apply(f.query);
|
|
773
|
+
}, children: f.name }, f.name)) : null) })),
|
|
774
|
+
} })), spec.filterBar !== 'none' && (_jsxs("form", { className: "applist-filterbar", ref: form, onSubmit: submit, children: [_jsxs("div", { className: "applist-fields", children: [chipsInBar && table && (_jsx(ListFilterBar, { table: table, boxes: boxes, search: searchBox, refinement: refinement, tabQuery: tabQuery, standing: spec.query ?? '', unitOf: unitOf, typed: searchBox ? edits[searchBox.column]?.raw : undefined, onType: (raw) => {
|
|
765
775
|
if (!searchBox)
|
|
766
776
|
return;
|
|
767
777
|
/* Now, not on the next paint: the search field's own × asks in the same event. */
|
|
@@ -770,7 +780,7 @@ export function AppList({ entry, spec, navigate, embedded = false, newButton, in
|
|
|
770
780
|
[searchBox.column]: { raw },
|
|
771
781
|
};
|
|
772
782
|
setEdits(editsNow.current);
|
|
773
|
-
}, onSearch: () => form.current?.requestSubmit(), apply: apply, current: currentText, residue: residueChip, listLabel: caption, phone: phone, onSheet: () => setSheet(true) })), spec.sorts?.length && !beside ? (_jsx(SortMenu, { sorts: spec.sorts, sort: spec.sort, query: entry.query, onPick: (query) => {
|
|
783
|
+
}, onSearch: () => form.current?.requestSubmit(), apply: apply, current: currentText, residue: residueChip, chosen: chosenChips, listLabel: caption, phone: phone, onSheet: () => setSheet(true) })), spec.sorts?.length && !beside ? (_jsx(SortMenu, { sorts: spec.sorts, sort: spec.sort, query: entry.query, onPick: (query) => {
|
|
774
784
|
walk.page = 0;
|
|
775
785
|
navigate(query);
|
|
776
786
|
} })) : null, _jsxs("div", { className: "applist-actions", children: [boardable && _jsx(LayoutSwitch, { layout: layout, onChange: setLayout, label: say('layout', { caption }) }), railed && railNarrow && railProps && boxes.length > 0 && (_jsx("button", { type: "button", className: "applist-toggle", "aria-haspopup": "dialog", onClick: () => setSheet(true), children: narrowed ? say('common.filters', { narrowed }) : say('common.filtersButton') })), spec.advancedFilters === true && boxes.length > 0 && (_jsx("button", { type: "button", className: "applist-toggle", "aria-expanded": showAdvanced, onClick: () => {
|
|
@@ -201,7 +201,8 @@ export function CardsList({ table, rows, spec, interactive = true, recordNavigat
|
|
|
201
201
|
const mark = (dressed?.kind === 'tone' || dressed?.kind === 'mark') && dressed.icon
|
|
202
202
|
? { name: dressed.icon, label: dressed.label, tone: dressed.kind === 'tone' ? dressed.tone : undefined }
|
|
203
203
|
: null;
|
|
204
|
-
|
|
204
|
+
/* A badge on the title's own column (a vocabulary word titling the card) would say the title twice. */
|
|
205
|
+
const badge = spec.badge && spec.badge !== spec.primary && row[spec.badge] != null && row[spec.badge] !== '' ? (_jsx("span", { className: "cards-badge", children: said(row, spec.badge) })) : null;
|
|
205
206
|
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 && spec.value !== spec.primary && row[spec.value] != null && (_jsx("p", { className: "cards-value", children: saidWithSecond(row, spec.value) })), summary?.some((name) => present(row, name)) ? (_jsx("p", { className: "cards-summary", children: summary.filter((name) => present(row, name)).map((name) => fact(row, name, 'cards-summary-item')) })) : null, lines?.length ? (_jsx("dl", { className: "cards-facts", children: lines.map((name) => (_jsxs("div", { className: "cards-fact", children: [_jsx("dt", { children: caption(name) }), _jsx("dd", { children: saidWithSecond(row, name) })] }, name))) })) : null] }), footer?.length ? (_jsx("p", { className: "cards-foot", children: footer.some((name) => present(row, name))
|
|
206
207
|
? footer.filter((name) => present(row, name)).map((name) => fact(row, name, 'cards-foot-item'))
|
|
207
208
|
: '\u00a0' })) : null, hasMedia && !avatar && badge] }) }, key ? JSON.stringify(key) : index));
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A row of filter tabs with counts, folding what does not fit under More (useTabFold.ts): the generated list's tabs
|
|
3
|
+
* (AppList.tsx) and a page's counted `<Choose>` (sdk/paramControls.tsx) are this one row, so a look that dresses one
|
|
4
|
+
* dresses both.
|
|
5
|
+
*
|
|
6
|
+
* Two semantics over one markup. The list's tabs are a `tablist` that switches what the list below shows; a page's
|
|
7
|
+
* Choose is a group of toggle buttons (`aria-pressed`) that set a param, named by the page, each named with its count
|
|
8
|
+
* ("Working, 12") so a screen reader hears the number it sees. The lit dress keys on either state (style.css).
|
|
9
|
+
*/
|
|
10
|
+
import type { ReactNode } from 'react';
|
|
11
|
+
/** A tab's count: the total, and whether it is a floor ("10,000+"). */
|
|
12
|
+
export interface Counted {
|
|
13
|
+
total: number;
|
|
14
|
+
capped: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare const sayCount: (counted: Counted) => string;
|
|
17
|
+
/** A tab's badge. `null` is a current result with no count, not permission to show an older one. */
|
|
18
|
+
export declare function TabCount({ counted }: {
|
|
19
|
+
counted?: Counted | null;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
interface FilterTab {
|
|
22
|
+
key: string;
|
|
23
|
+
label: string;
|
|
24
|
+
count?: Counted | null;
|
|
25
|
+
}
|
|
26
|
+
/** What the fold marks an item with: its place in the strip, and whether it is folded under More. */
|
|
27
|
+
type FoldMark = (at: number) => {
|
|
28
|
+
'data-fold': number;
|
|
29
|
+
'data-folded': '' | undefined;
|
|
30
|
+
'aria-hidden': true | undefined;
|
|
31
|
+
};
|
|
32
|
+
interface FilterTabsProps {
|
|
33
|
+
tabs: readonly FilterTab[];
|
|
34
|
+
/** The lit tab's index, -1 for none (a saved view may be the lit one). */
|
|
35
|
+
lit: number;
|
|
36
|
+
onPick(index: number): void;
|
|
37
|
+
/** `tablist` for tabs that switch a view; `group` for a control's toggle buttons, which `name` names. */
|
|
38
|
+
semantics?: 'tablist' | 'group';
|
|
39
|
+
name?: string;
|
|
40
|
+
/**
|
|
41
|
+
* More items after the tabs, in the same fold (a list's saved views): how many, which of them is lit (-1 for none),
|
|
42
|
+
* what the row draws for them with their fold marks (counted from 0 after the tabs), and what More lists for the
|
|
43
|
+
* folded ones.
|
|
44
|
+
*/
|
|
45
|
+
extra?: {
|
|
46
|
+
count: number;
|
|
47
|
+
lit: number;
|
|
48
|
+
row(mark: FoldMark): ReactNode;
|
|
49
|
+
more(folded: (at: number) => boolean): ReactNode;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export declare function FilterTabs({ tabs, lit, onPick, semantics, name, extra }: FilterTabsProps): import("react").JSX.Element;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DropItem, DropMenu } from '@mistriwork/ui/DropMenu.js';
|
|
3
|
+
import { formatNumber } from '../locale.js';
|
|
4
|
+
import { message } from '../messages.js';
|
|
5
|
+
import { useTabFold } from './useTabFold.js';
|
|
6
|
+
export const sayCount = (counted) => `${formatNumber(counted.total)}${counted.capped ? '+' : ''}`;
|
|
7
|
+
/** A tab's badge. `null` is a current result with no count, not permission to show an older one. */
|
|
8
|
+
export function TabCount({ counted }) {
|
|
9
|
+
const said = counted == null ? '' : sayCount(counted);
|
|
10
|
+
/* The number in a box of its own, over the room a tab keeps for it (features.css). */
|
|
11
|
+
return _jsx("span", { className: "tab-count", children: said && _jsx("span", { children: said }) });
|
|
12
|
+
}
|
|
13
|
+
export function FilterTabs({ tabs, lit, onPick, semantics = 'tablist', name, extra }) {
|
|
14
|
+
const after = tabs.length;
|
|
15
|
+
const { strip, folded } = useTabFold(after + (extra?.count ?? 0), extra && extra.lit !== -1 ? after + extra.lit : lit);
|
|
16
|
+
const foldMark = (at) => ({
|
|
17
|
+
'data-fold': at,
|
|
18
|
+
'data-folded': folded.has(at) ? '' : undefined,
|
|
19
|
+
'aria-hidden': folded.has(at) || undefined,
|
|
20
|
+
});
|
|
21
|
+
const group = semantics === 'group';
|
|
22
|
+
return (_jsxs("div", { className: "tabs folds", ref: strip, children: [_jsxs("div", { className: "tabs-row", ...(group ? { role: 'group', 'aria-label': name } : { role: 'tablist' }), children: [tabs.map((tab, i) => (_jsxs("button", { type: "button", role: group ? undefined : 'tab', className: "tab", "aria-selected": group ? undefined : i === lit, "aria-pressed": group ? i === lit : undefined, "aria-label": group && tab.count != null ? `${tab.label}, ${sayCount(tab.count)}` : undefined, onClick: () => onPick(i), ...foldMark(i), children: [_jsx("span", { children: tab.label }), _jsx(TabCount, { counted: tab.count })] }, tab.key))), extra?.row((at) => foldMark(after + at))] }), _jsx("div", { className: "tab-more", "data-fold-more": "", "data-folded": folded.size ? undefined : '', "aria-hidden": !folded.size || undefined, children: _jsxs(DropMenu, { className: "tab-more-menu", triggerClassName: "tab", label: message('common.more'), popupClassName: "page-actions-popup", align: "end", children: [tabs.map((tab, i) => folded.has(i) ? (_jsxs(DropItem, { className: "page-actions-item", onClick: () => onPick(i), children: [_jsx("span", { children: tab.label }), _jsx(TabCount, { counted: tab.count })] }, tab.key)) : null), extra?.more((at) => folded.has(after + at))] }) })] }));
|
|
23
|
+
}
|
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
border: 0; border-radius: var(--radius); background: none; color: inherit; font: inherit; cursor: pointer;
|
|
68
68
|
}
|
|
69
69
|
.applist-chip-open:hover { color: var(--accent-ink); }
|
|
70
|
+
/* A choice's chip has no x: its words are the whole of it, and open the chooser. */
|
|
71
|
+
.applist-fields .applist-chip-chosen { padding-right: 0; }
|
|
72
|
+
.applist-chip-chosen .applist-chip-open:disabled { cursor: default; }
|
|
70
73
|
.applist-fields .applist-chip-x { min-width: 24px; min-height: 24px; font-size: var(--text-md); }
|
|
71
74
|
.applist-bar-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2h); flex-basis: 100%; }
|
|
72
75
|
.applist-bar-chips:empty { display: none; }
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An App list's filters as controls, not a form: the bar a list draws above
|
|
3
|
+
* its rows unless its view says `filterBar: 'rail'` or `'none'`.
|
|
4
|
+
*
|
|
5
|
+
* The bar was a form — an empty box or Select per filter, then Filter, then
|
|
6
|
+
* Advanced — the heaviest thing above a quiet table, and on a phone more than
|
|
7
|
+
* half the first screen. So the list's name column keeps one search box, a
|
|
8
|
+
* real field with the 3:1 edge; every other filter the view declares is a
|
|
9
|
+
* quiet "Status ▾" that opens, in a popover, the picker the rail draws for it
|
|
10
|
+
* (a checklist, Min/Max, date presets; a reference is the typeahead its box
|
|
11
|
+
* was); and what is applied is said in the same row as chips, each in its
|
|
12
|
+
* filter's place and under its filter's label ("Status: Open +1"): a chip
|
|
13
|
+
* opens its picker again, its × (or Backspace) takes it out, and two or more
|
|
14
|
+
* earn one Clear all. On a phone the pickers are the
|
|
15
|
+
* rail's sheet, behind one Filters button that says how many apply.
|
|
16
|
+
*
|
|
17
|
+
* No picker writes a new kind of question. Each hands a condition tail to
|
|
18
|
+
* withCondition, as the boxes and the rail do, so a chip, the address
|
|
19
|
+
* (publicAddress.ts), a saved view and the crumb read it as they always did.
|
|
20
|
+
* A picker edits a draft and applies it with one button: every navigation
|
|
21
|
+
* redraws the list, and a popover that applied each tick would close under
|
|
22
|
+
* the reader's second one.
|
|
23
|
+
*/
|
|
24
|
+
import { type ReactNode } from 'react';
|
|
1
25
|
import { type TableMeta } from '@mistriwork/engine/shared/schema.js';
|
|
2
26
|
import { type Box } from './FilterBoxes.js';
|
|
3
27
|
import { type FacetUnit } from './FilterRail.js';
|
|
@@ -28,6 +52,8 @@ interface ListFilterBarProps {
|
|
|
28
52
|
text: string;
|
|
29
53
|
remove: () => void;
|
|
30
54
|
};
|
|
55
|
+
/** The choices that narrow the list (`chosen.site`): standing chips with no x, which open the chooser. */
|
|
56
|
+
chosen?: ReactNode;
|
|
31
57
|
/** The list's own name, for the search box's words: "Search issues…". */
|
|
32
58
|
listLabel: string;
|
|
33
59
|
phone: boolean;
|
|
@@ -117,13 +117,13 @@ export function ListFilterBar(props) {
|
|
|
117
117
|
if (phone) {
|
|
118
118
|
/* The search stays in reach; the pickers are one button, and the chips
|
|
119
119
|
wrap under the box rather than pushing it off the row. */
|
|
120
|
-
return (_jsxs(_Fragment, { children: [searchBox, pickers.length > 0 && (_jsx("button", { type: "button", className: "applist-add applist-sheet-open", "aria-haspopup": "dialog", onClick: onSheet, children: narrowed ? say('common.filters', { narrowed }) : say('common.filtersButton') })), _jsxs("div", { className: "applist-bar-chips", children: [search && _jsx(FilterSlot, { ...props, box: search, chipOnly: true }), pickers.map((box) => (_jsx(FilterSlot, { ...props, box: box, chipOnly: true }, box.column))), residueChip, clearAll] })] }));
|
|
120
|
+
return (_jsxs(_Fragment, { children: [searchBox, pickers.length > 0 && (_jsx("button", { type: "button", className: "applist-add applist-sheet-open", "aria-haspopup": "dialog", onClick: onSheet, children: narrowed ? say('common.filters', { narrowed }) : say('common.filtersButton') })), _jsxs("div", { className: "applist-bar-chips", children: [search && _jsx(FilterSlot, { ...props, box: search, chipOnly: true }), pickers.map((box) => (_jsx(FilterSlot, { ...props, box: box, chipOnly: true }, box.column))), props.chosen, residueChip, clearAll] })] }));
|
|
121
121
|
}
|
|
122
122
|
const rest = idle.filter((box) => hidden.has(box.column));
|
|
123
123
|
const heldSet = rest.filter((box) => facetActive(refinement, box.column, tabQuery)).length;
|
|
124
124
|
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: mark, hidden: true }), searchBox, search && _jsx(FilterSlot, { ...props, box: search }), pickers
|
|
125
125
|
.filter((box) => !hidden.has(box.column))
|
|
126
|
-
.map((box) => (_jsx(FilterSlot, { ...props, box: box }, box.column))), rest.length > 0 && (_jsx("span", { className: "applist-slot applist-slot-more", children: _jsxs("button", { type: "button", className: "applist-add", "aria-haspopup": "dialog", "aria-label": say('moreFilters', { filter: say('moreFiltersButton'), map: rest.map((box) => box.label).join(', ') }), onClick: onSheet, children: [say('moreFiltersButton'), heldSet > 0 && _jsx("span", { className: "applist-add-count", children: heldSet }), _jsx("span", { className: "applist-add-mark", "aria-hidden": "true", children: "\u25BE" })] }) })), residueChip, clearAll] }));
|
|
126
|
+
.map((box) => (_jsx(FilterSlot, { ...props, box: box }, box.column))), rest.length > 0 && (_jsx("span", { className: "applist-slot applist-slot-more", children: _jsxs("button", { type: "button", className: "applist-add", "aria-haspopup": "dialog", "aria-label": say('moreFilters', { filter: say('moreFiltersButton'), map: rest.map((box) => box.label).join(', ') }), onClick: onSheet, children: [say('moreFiltersButton'), heldSet > 0 && _jsx("span", { className: "applist-add-count", children: heldSet }), _jsx("span", { className: "applist-add-mark", "aria-hidden": "true", children: "\u25BE" })] }) })), props.chosen, residueChip, clearAll] }));
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* One declared filter in its place in the row: its chip when it narrows the
|
|
@@ -55,7 +55,7 @@ import { defaultCurrency } from '../locale.js';
|
|
|
55
55
|
import { wordFor } from './valueModel.js';
|
|
56
56
|
import { majorText, minorToMajor, rowCurrency } from '@mistriwork/engine/shared/money.js';
|
|
57
57
|
import { MinorMoneyInput, minorProblem } from './MinorMoneyInput.js';
|
|
58
|
-
import { clockDefault, fieldInput, inferredNarrowing, flagStart, formColumns, formFrame, formGroups, hasFormChanges, insertValues, isFormFieldVisible, missingFields, narrowingCondition, presetValue, SEGMENTED_WORDS, withDisplayChoices, } from './newRecordModel.js';
|
|
58
|
+
import { clockDefault, fieldInput, inferredNarrowing, flagStart, formColumns, formFrame, formGroups, hasFormChanges, insertValues, isFormFieldVisible, missingFields, narrowingCondition, presetValue, chosenDefaults, SEGMENTED_WORDS, withDisplayChoices, } from './newRecordModel.js';
|
|
59
59
|
import { derivedValue, formWords, resolvedForm, useMeDefaults } from './formDefaults.js';
|
|
60
60
|
import { useRecordInsert } from './useRecordInsert.js';
|
|
61
61
|
import { say } from '../copy/forms/components/NewRecord.js';
|
|
@@ -122,6 +122,9 @@ function NewRecordFormBody({ table, form, app, label: columnLabel, target, inser
|
|
|
122
122
|
return start === undefined ? [] : [[column.name, start]];
|
|
123
123
|
})
|
|
124
124
|
: [];
|
|
125
|
+
/* A reference to the App's chosen row (`choose`: the site the person works at) starts at it, read once as the form
|
|
126
|
+
opens: a pick changed while it is open never replaces what the form holds (newRecordModel.ts chosenDefaults). */
|
|
127
|
+
const [chosen] = useState(() => (app ? chosenDefaults(columns, shell().app()?.choose, shell().chosen(), target) : {}));
|
|
125
128
|
/* A vocabulary opens on the choice the database would write (`default 'booked'`), unless the form says another. */
|
|
126
129
|
const defaults = {
|
|
127
130
|
...Object.fromEntries(flags),
|
|
@@ -133,6 +136,7 @@ function NewRecordFormBody({ table, form, app, label: columnLabel, target, inser
|
|
|
133
136
|
clockDefault('now', column, new Date(), formatClockZone()),
|
|
134
137
|
]))
|
|
135
138
|
: {}),
|
|
139
|
+
...chosen,
|
|
136
140
|
...(form?.defaults ?? {}),
|
|
137
141
|
};
|
|
138
142
|
const switches = new Set(flags.map(([name]) => name));
|
|
@@ -338,6 +338,9 @@ export function FieldsSection({ page, section, index, base, recordKey: key, fold
|
|
|
338
338
|
in a <div> had no list for assistive technology to announce. */
|
|
339
339
|
/* An inferred page's form is the classic one (structure.css); a rail an author placed keeps its own dress. */
|
|
340
340
|
const classic = inferredForm;
|
|
341
|
-
const grid = rail ? (_jsx("dl", { className: classic ? 'page-properties page-classic' : 'page-properties', style: columns ? { '--page-properties-columns': String(columns) } : undefined, children: fields })) : (_jsx("dl", {
|
|
341
|
+
const grid = rail ? (_jsx("dl", { className: classic ? 'page-properties page-classic' : 'page-properties', style: columns ? { '--page-properties-columns': String(columns) } : undefined, children: fields })) : (_jsx("dl", {
|
|
342
|
+
/* Read-only, it is the kit's `Details` (sdk/kit.tsx) and shares its class, so a look dresses both; a grid with
|
|
343
|
+
fields open for editing is the form's alone. */
|
|
344
|
+
className: `page-field-grid${presentation === 'summary' ? ' page-field-summary' : ''}${editing ? '' : ' kit-details'}`, "data-columns": columns, style: columns ? { '--page-field-columns': `repeat(${columns}, minmax(0, 1fr))` } : undefined, children: fields }));
|
|
342
345
|
return (_jsx(SectionBox, { section: section, foldable: foldable, body: _jsxs(_Fragment, { children: [section.workflow && _jsx(WorkflowStatus, { definition: section.workflow, value: row[section.workflow.field], reachable: reachable }), grid] }) }));
|
|
343
346
|
}
|
|
@@ -63,6 +63,10 @@ export interface Section {
|
|
|
63
63
|
x?: string;
|
|
64
64
|
/** breakdown, steps: a line under a step, by its value. */
|
|
65
65
|
notes?: Record<string, string>;
|
|
66
|
+
/** breakdown drawn as bars: a second measure said beside each bar ("4 deals"), asked in the same request. */
|
|
67
|
+
also?: string;
|
|
68
|
+
/** chart: whether buckets with no rows stand at zero across the window, across what was observed, or not at all. */
|
|
69
|
+
fill?: 'window' | 'observed' | false;
|
|
66
70
|
/** chart: a line's curve, and a donut's words for its middle figure. */
|
|
67
71
|
curve?: 'smooth' | 'straight';
|
|
68
72
|
total?: string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* and what is missing or changed before the values are written.
|
|
6
6
|
*/
|
|
7
7
|
import { type ColumnMeta, type TableMeta } from '@mistriwork/engine/shared/schema.js';
|
|
8
|
-
import type { AppForm } from '@mistriwork/engine/shared/servedApp.js';
|
|
8
|
+
import type { AppForm, ServedChoice } from '@mistriwork/engine/shared/servedApp.js';
|
|
9
9
|
import { type FormScalar } from '@mistriwork/engine/shared/formValues.js';
|
|
10
10
|
/** The client-side presentation subset of an authored App form. */
|
|
11
11
|
export type FormCuration = Omit<AppForm<string>, 'defaults'> & {
|
|
@@ -74,6 +74,13 @@ export declare function fieldInput(column: ColumnMeta, options: {
|
|
|
74
74
|
export declare function clockDefault(word: 'today' | 'now', column: ColumnMeta, now: Date, timeZone?: string): string;
|
|
75
75
|
/** The choices a narrowed reference offers, in the query language: `project_id = 4`; undefined while a field it reads is empty. */
|
|
76
76
|
export declare function narrowingCondition(where: Readonly<Record<string, string>> | undefined, values: Readonly<Record<string, unknown>>): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Where a New form's references start from the App's choices (`choose`): a reference to the chosen table, by its key,
|
|
79
|
+
* starts at the pick, so a visit booked at a site the person works at names that site without being asked. It is a
|
|
80
|
+
* start like any default, below the form's own (a parent's key, a declared default): the field is the person's to
|
|
81
|
+
* change, and the form reads this once, so a pick changed while the form is open never replaces what it holds.
|
|
82
|
+
*/
|
|
83
|
+
export declare function chosenDefaults(columns: readonly ColumnMeta[], choose: Readonly<Record<string, ServedChoice>> | undefined, chosen: Readonly<Record<string, string>>, target: (tableId: string) => TableMeta | undefined): Record<string, string>;
|
|
77
84
|
/**
|
|
78
85
|
* The pickers a form narrows by an earlier pick where the App's form says nothing (`fields.<column>.where`): a
|
|
79
86
|
* reference whose table points at the table of a required reference asked before it, by exactly one column, offers
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* start), the control each field gets, how an earlier pick narrows a later one, whether it opens as a drawer or a page,
|
|
5
5
|
* and what is missing or changed before the values are written.
|
|
6
6
|
*/
|
|
7
|
-
import { coerceForColumn, columnKind, isFlagColumn } from '@mistriwork/engine/shared/schema.js';
|
|
7
|
+
import { coerceForColumn, columnKind, isFlagColumn, primaryKey, } from '@mistriwork/engine/shared/schema.js';
|
|
8
8
|
import { appNow } from '../locale.js';
|
|
9
9
|
import { autoKey, formShownFields, isRequired } from '@mistriwork/engine/shared/form.js';
|
|
10
10
|
import { evaluateFormCondition, typedValue } from '@mistriwork/engine/shared/formValues.js';
|
|
@@ -244,6 +244,28 @@ export function narrowingCondition(where, values) {
|
|
|
244
244
|
}
|
|
245
245
|
return clauses.join(' and ');
|
|
246
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Where a New form's references start from the App's choices (`choose`): a reference to the chosen table, by its key,
|
|
249
|
+
* starts at the pick, so a visit booked at a site the person works at names that site without being asked. It is a
|
|
250
|
+
* start like any default, below the form's own (a parent's key, a declared default): the field is the person's to
|
|
251
|
+
* change, and the form reads this once, so a pick changed while the form is open never replaces what it holds.
|
|
252
|
+
*/
|
|
253
|
+
export function chosenDefaults(columns, choose, chosen, target) {
|
|
254
|
+
const out = {};
|
|
255
|
+
for (const [name, choice] of Object.entries(choose ?? {})) {
|
|
256
|
+
const value = chosen[name];
|
|
257
|
+
const into = value ? target(choice.table) : undefined;
|
|
258
|
+
const keys = into ? primaryKey(into) : [];
|
|
259
|
+
if (keys.length !== 1)
|
|
260
|
+
continue;
|
|
261
|
+
for (const column of columns) {
|
|
262
|
+
const ref = column.references;
|
|
263
|
+
if (ref?.table === choice.table && ref.column === keys[0] && !Object.hasOwn(out, column.name))
|
|
264
|
+
out[column.name] = value;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return out;
|
|
268
|
+
}
|
|
247
269
|
/**
|
|
248
270
|
* The pickers a form narrows by an earlier pick where the App's form says nothing (`fields.<column>.where`): a
|
|
249
271
|
* reference whose table points at the table of a required reference asked before it, by exactly one column, offers
|
|
@@ -28,4 +28,7 @@ export declare const say: import("../../../messages.js").RoomMessage<{
|
|
|
28
28
|
readonly captionFilters: "{caption} filters";
|
|
29
29
|
readonly everything: "Everything";
|
|
30
30
|
readonly layout: "Show {caption} as";
|
|
31
|
+
readonly chosen: "{thing}: {value}";
|
|
32
|
+
readonly chosenNone: "none";
|
|
33
|
+
readonly chosenChange: "Change {thing}";
|
|
31
34
|
}>;
|
package/dist/client/core.js
CHANGED
|
@@ -202,6 +202,8 @@ async function sent(path, body, headers) {
|
|
|
202
202
|
composedReads()?.forget();
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
+
/* The header an App's picks are sent in (server/app/appChoices.ts). */
|
|
206
|
+
const CHOSEN_HEADER = 'x-mistri-chosen';
|
|
205
207
|
/**
|
|
206
208
|
* @param {string} path
|
|
207
209
|
* @param {Record<string, unknown> | undefined} body
|
|
@@ -209,6 +211,11 @@ async function sent(path, body, headers) {
|
|
|
209
211
|
* @returns {Promise<any>}
|
|
210
212
|
*/
|
|
211
213
|
async function request(path, body, headers) {
|
|
214
|
+
/* The App-wide picks ride every request (an App's `choose`): the server reads each row again under the reader, so
|
|
215
|
+
the header is a wish and never a grant. A caller's own header of the same name wins. */
|
|
216
|
+
const chosen = new URLSearchParams(shell().chosen()).toString();
|
|
217
|
+
if (chosen)
|
|
218
|
+
headers = { [CHOSEN_HEADER]: chosen, ...headers };
|
|
212
219
|
const parsedPath = new URL(path, window.location.href);
|
|
213
220
|
if (!path.startsWith('/api/') || parsedPath.hash || parsedPath.pathname !== path.split('?')[0]) {
|
|
214
221
|
throw Object.assign(new Error(say('useACanonicalApi')), { outcome: 'not_applied' });
|
package/dist/client/features.css
CHANGED
|
@@ -455,7 +455,7 @@ body.app-mode .page-edit { font-family: var(--sans); }
|
|
|
455
455
|
:is(.page-tab, .page-section-head) .tab-count::before { content: '00' / ''; visibility: hidden; }
|
|
456
456
|
.page-tab[aria-selected="true"] .tab-count { color: inherit; }
|
|
457
457
|
/* The count takes the tab's ink whole: faded, it was 3.3:1 on a filled tab. */
|
|
458
|
-
.tab[aria-selected="true"] .tab-count { color: inherit; }
|
|
458
|
+
.tab:is([aria-selected="true"], [aria-pressed="true"]) .tab-count { color: inherit; }
|
|
459
459
|
/* Quick filters: the list's key vocabularies as one-click conditions. */
|
|
460
460
|
.applist-quick {
|
|
461
461
|
padding: var(--space-2h) var(--space-3);
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { FIRST_PAINT_ELEMENT, itemKey, readKey, } from '@mistriwork/engine/shared/firstPaint.js';
|
|
12
12
|
import { sessionIdentity } from './sessionIdentity.js';
|
|
13
13
|
import { shellById } from './shellHost.js';
|
|
14
|
+
import { shell } from './shellMode.js';
|
|
14
15
|
/* Long enough for the first room and what it asks as it draws, and no
|
|
15
16
|
longer: past it every read is the reader's own again. */
|
|
16
17
|
const LIFETIME = 15_000;
|
|
@@ -48,6 +49,14 @@ function held() {
|
|
|
48
49
|
}
|
|
49
50
|
if (!owner && identity.mode !== 'unknown')
|
|
50
51
|
owner = identity;
|
|
52
|
+
/* The page was drawn for the pick the server holds for this person (an App's `choose`, read from their store as the
|
|
53
|
+
page's reads were asked), so a person with a stored pick keeps first paint: nothing waits on one. Only a tab that
|
|
54
|
+
differs from it, or one with no store to hold it, sends a pick of its own (`chosen()` is that difference), and
|
|
55
|
+
none of the page's answers is that tab's: every one is asked again. */
|
|
56
|
+
if (Object.keys(shell().chosen()).length) {
|
|
57
|
+
data = null;
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
51
60
|
return data;
|
|
52
61
|
}
|
|
53
62
|
/** The answer the page carries for this request, once, or undefined. */
|
|
@@ -592,12 +592,12 @@
|
|
|
592
592
|
background: transparent;
|
|
593
593
|
color: var(--ink);
|
|
594
594
|
}
|
|
595
|
-
:root[data-look-tabs='underline'] :is(.tab, :where(body.app-mode) .page-tab)[aria-selected='true'] {
|
|
595
|
+
:root[data-look-tabs='underline'] :is(.tab, :where(body.app-mode) .page-tab):is([aria-selected='true'], [aria-pressed='true']) {
|
|
596
596
|
background: transparent;
|
|
597
597
|
color: var(--ink);
|
|
598
598
|
font-weight: 600;
|
|
599
599
|
}
|
|
600
|
-
:root[data-look-tabs='underline'] :is(.tab, :where(body.app-mode) .page-tab)[aria-selected='true']::after {
|
|
600
|
+
:root[data-look-tabs='underline'] :is(.tab, :where(body.app-mode) .page-tab):is([aria-selected='true'], [aria-pressed='true'])::after {
|
|
601
601
|
content: '';
|
|
602
602
|
position: absolute;
|
|
603
603
|
left: 0;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* write.js re-exports both; the rules are these, once.
|
|
7
7
|
*/
|
|
8
8
|
import { isAppendOnly } from '@mistriwork/engine/shared/schema.js';
|
|
9
|
+
import { rowMeetsCondition } from '@mistriwork/engine/shared/rowCondition.js';
|
|
9
10
|
import { prefersPages, state, writeAllowed } from './core.js';
|
|
10
11
|
import { planColumn } from './columns.js';
|
|
11
12
|
import { pageBridge } from './uiBridge.js';
|
|
@@ -26,17 +27,21 @@ export function booleanChoices(column, row) {
|
|
|
26
27
|
return /bool/i.test(column?.type ?? '') ? { yes: 'true', no: 'false' } : { yes: '1', no: '0' };
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
|
-
* Whether the row is in a state its machine freezes (`final: { freeze: true }`)
|
|
30
|
-
* so no editor is offered. Judged from the row's own
|
|
30
|
+
* Whether the row is frozen: in a state its machine freezes (`final: { freeze: true }`), or matching its resource's
|
|
31
|
+
* `frozen` condition. The server refuses every write to it, so no editor is offered. Judged from the row's own values,
|
|
32
|
+
* which a row that does not carry a column cannot say (the server's refusal then stands, a 409 `frozen`).
|
|
31
33
|
*/
|
|
32
34
|
function frozenRow(tableId, row) {
|
|
33
35
|
if (!row)
|
|
34
36
|
return false;
|
|
35
37
|
const app =
|
|
36
|
-
/** @type {{ resources?: Record<string, { machine?: import('@mistriwork/engine/shared/servedApp.js').ServedMachine }> } | null} */ (pageBridge.activeApp());
|
|
37
|
-
const
|
|
38
|
+
/** @type {{ resources?: Record<string, { frozen?: string, machine?: import('@mistriwork/engine/shared/servedApp.js').ServedMachine }> } | null} */ (pageBridge.activeApp());
|
|
39
|
+
const resource = app?.resources?.[tableId];
|
|
40
|
+
const machine = resource?.machine;
|
|
38
41
|
const value = machine ? row[machine.column] : undefined;
|
|
39
|
-
|
|
42
|
+
if (machine !== undefined && value !== undefined && value !== null && machine.states.some((s) => s.freeze && s.value === String(value)))
|
|
43
|
+
return true;
|
|
44
|
+
return typeof resource?.frozen === 'string' && rowMeetsCondition(state.schema, tableId, resource.frozen, row);
|
|
40
45
|
}
|
|
41
46
|
/** True when this row can be edited at all: write mode on, and a full key; a frozen row (`row`, where the caller has it) is not. */
|
|
42
47
|
export function canEditRow(table, key, row) {
|
package/dist/client/sageLook.css
CHANGED
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
}
|
|
281
281
|
/* What is chosen: a tint of the accent and the text's ink, never a fill in the accent. A record's tabs are the
|
|
282
282
|
list's: one soft pill for the group that is open, on a page and on a list alike. */
|
|
283
|
-
:root[data-look-tabs='tint'] :is(.tab, body.app-mode .page-tab)[aria-selected='true'] {
|
|
283
|
+
:root[data-look-tabs='tint'] :is(.tab, body.app-mode .page-tab):is([aria-selected='true'], [aria-pressed='true']) {
|
|
284
284
|
background: var(--chosen);
|
|
285
285
|
color: var(--ink);
|
|
286
286
|
}
|
|
@@ -153,6 +153,9 @@ export interface ShellMode {
|
|
|
153
153
|
unauthorized(info: unknown): void;
|
|
154
154
|
/** Draw the App's sign-in in place, so a signed-out visitor comes back to this address (publicSurface.js); a no-op where none signs in. */
|
|
155
155
|
signInHere(appId: string): void;
|
|
156
|
+
/** The App-wide rows this tab has picked (an App's `choose`), each name's key as text: sent with every request as
|
|
157
|
+
`x-mistri-chosen`, and believed only once the server has read the row again. None in the Workbench. */
|
|
158
|
+
chosen(): Readonly<Record<string, string>>;
|
|
156
159
|
/** A tenant session's requests, or null where there is no tenant. */
|
|
157
160
|
tenant: TenantRequests | null;
|
|
158
161
|
tenantLinks: TenantLinks | null;
|
package/dist/client/shellMode.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const none = () => false;
|
|
2
2
|
const NOTHING_REACHABLE = new Set();
|
|
3
|
+
const NOTHING_CHOSEN = Object.freeze({});
|
|
3
4
|
const WORKBENCH = Object.freeze({
|
|
4
5
|
app: () => null,
|
|
5
6
|
inApp: none,
|
|
@@ -20,6 +21,7 @@ const WORKBENCH = Object.freeze({
|
|
|
20
21
|
peekRecord: null,
|
|
21
22
|
unauthorized: () => { },
|
|
22
23
|
signInHere: () => { },
|
|
24
|
+
chosen: () => NOTHING_CHOSEN,
|
|
23
25
|
tenant: null,
|
|
24
26
|
tenantLinks: null,
|
|
25
27
|
mutations: Object.freeze({ start: () => undefined, unknown: none, settle: none, hasUnresolved: none }),
|
|
@@ -1202,6 +1202,13 @@
|
|
|
1202
1202
|
.free-page-body.is-own > .page-section {
|
|
1203
1203
|
padding-top: 0;
|
|
1204
1204
|
}
|
|
1205
|
+
/* ...but a page that draws the kit's own head (PageHeader) keeps the pane's top space, the one a head's row leaves
|
|
1206
|
+
above its title (--page-top): without it that head stood flush under the pane's bar, a step higher than every page
|
|
1207
|
+
whose head the shell draws. A page whose first part is its own (a hero) still starts at the pane's top, and a bare
|
|
1208
|
+
page owns the window and keeps none. */
|
|
1209
|
+
.free-page-body.is-own:not(.is-bare):has(.applist-head) {
|
|
1210
|
+
padding-top: var(--page-top);
|
|
1211
|
+
}
|
|
1205
1212
|
/* The first part of a free-form page that has a head stands one gap under it (--page-head-gap), as a list's controls
|
|
1206
1213
|
do. It was the head's own margin, the body's (the sidebar shell's rule below) and the section's, three spaces said
|
|
1207
1214
|
one on another: 62px under the head against a list's 27. */
|
package/dist/client/style.css
CHANGED
|
@@ -463,7 +463,7 @@ html[data-starting] .content.nav-holding.nav-holding-focusable > :not(.nav-held)
|
|
|
463
463
|
white-space: nowrap; flex-shrink: 0;
|
|
464
464
|
}
|
|
465
465
|
.tab:hover { color: var(--ink); }
|
|
466
|
-
.tab[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); }
|
|
466
|
+
.tab:is([aria-selected="true"], [aria-pressed="true"]) { color: var(--accent-ink); border-bottom-color: var(--accent); }
|
|
467
467
|
|
|
468
468
|
/* Wider than it was: with the sidebar on the left, 14px of gutter on the
|
|
469
469
|
right reads as none at all beside a panel edge. */
|
|
@@ -224,14 +224,14 @@
|
|
|
224
224
|
`font` shorthand resets neither, so four looks named their record tabs in capitals. Mono
|
|
225
225
|
sets its own label below. */
|
|
226
226
|
:root[data-theme-style] :is(.tab, :where(body.app-mode) .page-tab) { border: 0; border-radius: var(--radius); padding: var(--space-2) var(--space-4); font: 500 var(--text-base) var(--sans); text-transform: none; letter-spacing: normal; color: var(--ink-muted); }
|
|
227
|
-
:root[data-theme-style] :is(.tab, :where(body.app-mode) .page-tab)[aria-selected="true"] { background: var(--accent); color: var(--on-accent); border-bottom-width: 0; }
|
|
227
|
+
:root[data-theme-style] :is(.tab, :where(body.app-mode) .page-tab):is([aria-selected="true"], [aria-pressed="true"]) { background: var(--accent); color: var(--on-accent); border-bottom-width: 0; }
|
|
228
228
|
/* A tab drawn as a box is a control in the list's toolbar: the toolbar's height, so it stands level with the filters
|
|
229
229
|
beside it (a 24px pill stood beside 30px filters), and the control's corner, so a look whose buttons are pills has
|
|
230
230
|
pill tabs. The height is the line's, not a box's, so a count beside the name keeps its baseline. */
|
|
231
231
|
:root[data-theme-style]:is([data-look-tabs='pill'], [data-look-tabs='tint'], [data-look-tabs='inverted']) :is(.tab, :where(body.app-mode) .page-tab) { line-height: calc(var(--control-h-sm) - 2 * var(--space-2)); border-radius: var(--control-radius, var(--radius)); }
|
|
232
232
|
/* The chosen pill is a soft one in the ink with an edge of its own: filled in the accent, as the primary button
|
|
233
233
|
is, it read as a second primary over every list and on every record. */
|
|
234
|
-
html:root[data-theme-style][data-look-tabs='pill'] :is(.tab, :where(body.app-mode) .page-tab)[aria-selected='true'] { background: var(--raised); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
|
|
234
|
+
html:root[data-theme-style][data-look-tabs='pill'] :is(.tab, :where(body.app-mode) .page-tab):is([aria-selected='true'], [aria-pressed='true']) { background: var(--raised); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
|
|
235
235
|
:root[data-theme-style] .tab .tab-count { font-size: var(--text-sm); line-height: 1; }
|
|
236
236
|
/* A two-or-three-way switch (a Segmented, a list's Rows/Board, the phone's Records/Table, Tree/Raw) is one drawing in every
|
|
237
237
|
look: a tray on the raised ground with a hairline, and the chosen one inside it. The tray's corner is the item's plus
|
|
@@ -516,7 +516,7 @@ html:root[data-theme-style] .record-presentation { margin-inline-start: auto; }
|
|
|
516
516
|
:root[data-look-nav='inverted'] .app-mode .topbar :is(.tn-group.active > .tn-group-button, .tn-item[aria-current='true']) :is(.tn-caret, .nav-icon) {
|
|
517
517
|
color: inherit;
|
|
518
518
|
}
|
|
519
|
-
:root[data-look-tabs='inverted'] :is(.tab, :where(body.app-mode) .page-tab)[aria-selected='true'] {
|
|
519
|
+
:root[data-look-tabs='inverted'] :is(.tab, :where(body.app-mode) .page-tab):is([aria-selected='true'], [aria-pressed='true']) {
|
|
520
520
|
background: var(--ink);
|
|
521
521
|
color: var(--ground);
|
|
522
522
|
border-radius: var(--radius);
|
|
@@ -164,12 +164,12 @@
|
|
|
164
164
|
text-transform: none;
|
|
165
165
|
}
|
|
166
166
|
@media (hover: hover) {
|
|
167
|
-
:root[data-look-tabs='lifted'] :is(.tab, :where(body.app-mode) .page-tab):hover:not([aria-selected='true']) {
|
|
167
|
+
:root[data-look-tabs='lifted'] :is(.tab, :where(body.app-mode) .page-tab):hover:not([aria-selected='true'], [aria-pressed='true']) {
|
|
168
168
|
background: color-mix(in srgb, var(--ink) 5%, transparent);
|
|
169
169
|
color: var(--ink);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
:root[data-look-tabs='lifted'] :is(.tab, :where(body.app-mode) .page-tab)[aria-selected='true'] {
|
|
172
|
+
:root[data-look-tabs='lifted'] :is(.tab, :where(body.app-mode) .page-tab):is([aria-selected='true'], [aria-pressed='true']) {
|
|
173
173
|
background: var(--surface);
|
|
174
174
|
color: var(--ink);
|
|
175
175
|
font-weight: 600;
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
:root[data-visual-theme] .applist-quick-text { min-height: 32px; background: var(--surface); }
|
|
191
191
|
:root[data-visual-theme] .tabs { gap: var(--space-4h); padding-top: var(--space-4); }
|
|
192
192
|
:root[data-visual-theme] .tab { padding: var(--space-3) 0 var(--space-4); font-weight: 550; }
|
|
193
|
-
:root[data-visual-theme] .tab[aria-selected="true"] { border-bottom-width: 3px; }
|
|
193
|
+
:root[data-visual-theme] .tab:is([aria-selected="true"], [aria-pressed="true"]) { border-bottom-width: 3px; }
|
|
194
194
|
:root[data-visual-theme] .app-mode .result-head { padding-top: var(--space-4); padding-bottom: var(--space-4); }
|
|
195
195
|
:root[data-visual-theme] .app-mode table { font-family: var(--mono); font-variant-numeric: tabular-nums; }
|
|
196
196
|
:root[data-visual-theme] .app-mode th { font-family: var(--sans); color: var(--ink-muted); font-weight: 600; }
|
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.78",
|
|
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": {
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"./package.json": "./package.json"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@mistriwork/engine": "1.0.0-rc.
|
|
89
|
-
"@mistriwork/ui": "1.0.0-rc.
|
|
88
|
+
"@mistriwork/engine": "1.0.0-rc.78",
|
|
89
|
+
"@mistriwork/ui": "1.0.0-rc.78",
|
|
90
90
|
"intl-messageformat": "12.1.2",
|
|
91
91
|
"qrcode-generator": "^2.0.4"
|
|
92
92
|
},
|