@mistriwork/kit 1.0.0-rc.14 → 1.0.0-rc.15
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/app.js +2 -1
- package/dist/client/components/AppList.js +12 -1
- package/dist/client/components/Dressed.js +3 -0
- package/dist/client/components/Editable.js +3 -2
- package/dist/client/components/ErrorBoundary.js +1 -1
- package/dist/client/components/Grid.d.ts +15 -1
- package/dist/client/components/Grid.js +44 -7
- package/dist/client/components/NewRecord.d.ts +3 -1
- package/dist/client/components/NewRecord.js +16 -5
- package/dist/client/components/PageFlowDiagram.css +1 -1
- package/dist/client/components/PageTimeline.js +18 -4
- package/dist/client/components/RecordSummaries.d.ts +5 -3
- package/dist/client/components/RecordSummaries.js +11 -2
- package/dist/client/components/TableRoom.d.ts +4 -1
- package/dist/client/components/TableRoom.js +10 -5
- package/dist/client/components/TableView.d.ts +4 -2
- package/dist/client/components/TableView.js +3 -3
- package/dist/client/components/TimelineReactions.css +49 -0
- package/dist/client/components/TimelineReactions.d.ts +18 -0
- package/dist/client/components/TimelineReactions.js +58 -0
- package/dist/client/components/TreePicker.css +25 -0
- package/dist/client/components/TreePicker.d.ts +59 -0
- package/dist/client/components/TreePicker.js +407 -0
- package/dist/client/components/Value.js +33 -2
- package/dist/client/components/appListModel.d.ts +2 -0
- package/dist/client/components/chromeIcons.d.ts +1 -0
- package/dist/client/components/chromeIcons.js +1 -0
- package/dist/client/components/inputRenderers.d.ts +7 -1
- package/dist/client/components/inputRenderers.js +2 -0
- package/dist/client/components/pageModel.d.ts +4 -0
- package/dist/client/components/reactionTally.d.ts +20 -0
- package/dist/client/components/reactionTally.js +46 -0
- package/dist/client/components/useGridGroups.d.ts +11 -0
- package/dist/client/components/useGridGroups.js +70 -0
- package/dist/client/components/useGridKeyboard.d.ts +2 -0
- package/dist/client/components/useGridKeyboard.js +18 -1
- package/dist/client/components/valueModel.d.ts +10 -3
- package/dist/client/components/valueModel.js +21 -1
- package/dist/client/copy/forms/components/TreePicker.d.ts +9 -0
- package/dist/client/copy/forms/components/TreePicker.js +11 -0
- package/dist/client/copy/lists/components/Grid.d.ts +1 -1
- package/dist/client/copy/lists/components/Grid.js +1 -1
- package/dist/client/copy/lists/components/useGridGroups.d.ts +3 -0
- package/dist/client/copy/lists/components/useGridGroups.js +5 -0
- package/dist/client/copy/record/components/TimelineReactions.d.ts +7 -0
- package/dist/client/copy/record/components/TimelineReactions.js +6 -0
- package/dist/client/copy/record/components/Value.d.ts +3 -0
- package/dist/client/copy/record/components/Value.js +3 -0
- package/dist/client/copy/shell/components/ErrorBoundary.d.ts +1 -1
- package/dist/client/copy/shell/components/ErrorBoundary.js +1 -1
- package/dist/client/features.css +35 -1
- package/dist/client/index.html +1 -1
- package/dist/client/page.css +3 -2
- package/dist/client/shellHost.d.ts +1 -1
- package/dist/client/shellHost.js +1 -1
- package/dist/client/structure.css +11 -3
- package/dist/client/style.css +11 -2
- package/package.json +3 -3
|
@@ -20,7 +20,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
20
20
|
* is a grid embedded in someone else's surface — an app list, a dashboard
|
|
21
21
|
* section, a page's chooser — and touches nothing but its own box.
|
|
22
22
|
*/
|
|
23
|
-
import { useEffect } from 'react';
|
|
23
|
+
import { useEffect, useMemo } from 'react';
|
|
24
24
|
import { useQuery } from '@tanstack/react-query';
|
|
25
25
|
import { $, api, columnLabel, findTable, go, pageSize, setExplain, showErrors, state, tableView } from '../core.js';
|
|
26
26
|
import { explicitLimit } from '../clauses.js';
|
|
@@ -35,6 +35,7 @@ import { onDemand, useArrived } from './onDemand.js';
|
|
|
35
35
|
import { FilterBar } from './FilterBoxes.js';
|
|
36
36
|
import { Delayed, GridSkeleton } from './Skeleton.js';
|
|
37
37
|
import { Problem, Refused } from './Notes.js';
|
|
38
|
+
import { groupedQuestion } from '@mistriwork/engine/shared/listQuestion.js';
|
|
38
39
|
import { GridCellEdit, isApiConnection, TableView, ViewTabs } from './TableView.js';
|
|
39
40
|
import { pageStepFor, stepList } from './pageStep.js';
|
|
40
41
|
import { ExportHold } from './ExportHold.js';
|
|
@@ -73,7 +74,7 @@ const thingOf = (entry, table) => {
|
|
|
73
74
|
return kind === 'row' || (kind === 'page' && named) ? say('thingRecord') : table ? say('thingList') : say('thingPage');
|
|
74
75
|
};
|
|
75
76
|
const connection = () => state.activeConnection ?? '';
|
|
76
|
-
export function TableRoom({ entry, chrome = true, inset = chrome, interactive = true, hide, labels, referenceLabels, totals, density, rowActions, editable, inCrumbs, sizing, export: exportOn = true, summaries = false, embedded = false, version = 0, onResult, presentation, present, actions, listLabel, order, recordNavigation = false, empty, }) {
|
|
77
|
+
export function TableRoom({ entry, chrome = true, inset = chrome, interactive = true, hide, labels, referenceLabels, totals, group, density, rowActions, editable, inCrumbs, sizing, export: exportOn = true, summaries = false, embedded = false, version = 0, onResult, presentation, present, actions, listLabel, order, recordNavigation = false, empty, }) {
|
|
77
78
|
/* A tab this reader cannot have here falls back to Rows: Definition and API
|
|
78
79
|
are the operator's, API only over an API, and an API's definition is its
|
|
79
80
|
description, so it has no Definition tab. */
|
|
@@ -94,7 +95,7 @@ export function TableRoom({ entry, chrome = true, inset = chrome, interactive =
|
|
|
94
95
|
if (bar)
|
|
95
96
|
bar.value = entry.query;
|
|
96
97
|
}, [chrome, entry.query]);
|
|
97
|
-
return (_jsxs(_Fragment, { children: [chrome && (_jsx("div", { className: "grid-host", children: _jsx(ViewTabs, { entry: entry }) })), chrome && tab === 'rows' && _jsx(FilterSection, { entry: entry }, entry.query), _jsx("div", { className: inset ? 'grid-inset' : undefined, children: tab === 'diagram' ? (_jsx("div", { className: "panel-pad", children: _jsx("div", { className: "diagram", children: _jsx(NeighbourhoodDiagram, { tableId: entry.table }) }) })) : tab === 'api' ? (_jsx(ApiOperations, { table: entry.table })) : tab === 'ddl' ? (_jsx(DdlPane, { table: entry.table })) : (_jsx(Rows, { entry: entry, chrome: chrome, interactive: interactive, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, density: density, rowActions: rowActions, editable: editable, inCrumbs: inCrumbs, sizing: sizing, exportOn: exportOn, summaries: summaries, embedded: embedded, version: version, onResult: onResult, presentation: presentation, present: present, actions: actions, listLabel: listLabel, order: order, recordNavigation: recordNavigation, empty: empty })) })] }));
|
|
98
|
+
return (_jsxs(_Fragment, { children: [chrome && (_jsx("div", { className: "grid-host", children: _jsx(ViewTabs, { entry: entry }) })), chrome && tab === 'rows' && _jsx(FilterSection, { entry: entry }, entry.query), _jsx("div", { className: inset ? 'grid-inset' : undefined, children: tab === 'diagram' ? (_jsx("div", { className: "panel-pad", children: _jsx("div", { className: "diagram", children: _jsx(NeighbourhoodDiagram, { tableId: entry.table }) }) })) : tab === 'api' ? (_jsx(ApiOperations, { table: entry.table })) : tab === 'ddl' ? (_jsx(DdlPane, { table: entry.table })) : (_jsx(Rows, { entry: entry, chrome: chrome, interactive: interactive, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, group: group, density: density, rowActions: rowActions, editable: editable, inCrumbs: inCrumbs, sizing: sizing, exportOn: exportOn, summaries: summaries, embedded: embedded, version: version, onResult: onResult, presentation: presentation, present: present, actions: actions, listLabel: listLabel, order: order, recordNavigation: recordNavigation, empty: empty })) })] }));
|
|
98
99
|
}
|
|
99
100
|
const escaped = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
100
101
|
/**
|
|
@@ -146,7 +147,11 @@ function keepTotal(key, reply) {
|
|
|
146
147
|
listTotals.delete(listTotals.keys().next().value);
|
|
147
148
|
listTotals.set(key, { total, ...(exactTotal !== undefined ? { exactTotal } : {}), ...(cappedTotal ? { cappedTotal } : {}) });
|
|
148
149
|
}
|
|
149
|
-
function Rows({ entry, chrome, interactive, hide, labels, referenceLabels, totals, density, rowActions, editable, inCrumbs, sizing, exportOn, summaries, embedded, version, onResult, presentation, present, actions, listLabel, order, recordNavigation, empty, }) {
|
|
150
|
+
function Rows({ entry: given, chrome, interactive, hide, labels, referenceLabels, totals, group, density, rowActions, editable, inCrumbs, sizing, exportOn, summaries, embedded, version, onResult, presentation, present, actions, listLabel, order, recordNavigation, empty, }) {
|
|
151
|
+
/* A grouped list's rows are read in the group's order, each group's together under its head: said to the read and
|
|
152
|
+
the pager that steps it, while the walk keeps the reader's own question (a header's sort writes that). */
|
|
153
|
+
const groupedQuery = group ? groupedQuestion(given.query, group.column) : given.query;
|
|
154
|
+
const entry = useMemo(() => (groupedQuery === given.query ? given : { ...given, query: groupedQuery }), [given, groupedQuery]);
|
|
150
155
|
const table = findTable(entry.table);
|
|
151
156
|
/* An explicit `limit` in the query is a deliberate statement and beats the page size. */
|
|
152
157
|
const asked = explicitLimit(entry.query);
|
|
@@ -230,7 +235,7 @@ function Rows({ entry, chrome, interactive, hide, labels, referenceLabels, total
|
|
|
230
235
|
/* Not over a question that failed: its error says why there are no rows. */
|
|
231
236
|
if (empty && !run.isPlaceholderData && data.rows.length === 0 && page === 0 && !data.errors?.length)
|
|
232
237
|
return _jsx(_Fragment, { children: empty });
|
|
233
|
-
return (_jsxs(_Fragment, { children: [held.held ? _jsx(LivePill, { held: held.held, show: held.show }) : null, _jsx(TableView, { entry: entry, data: data, chrome: chrome, interactive: interactive, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, density: density, rowActions: rowActions, editable: editable, inCrumbs: inCrumbs, sizing: sizing, export: exportOn, summaries: summaries, embedded: embedded, presentation: presentation, present: present, actions: actions, listLabel: listLabel, order: order, recordNavigation: recordNavigation, at: askedFor.get(data) ?? { page, size }, busy: run.isPlaceholderData })] }));
|
|
238
|
+
return (_jsxs(_Fragment, { children: [held.held ? _jsx(LivePill, { held: held.held, show: held.show }) : null, _jsx(TableView, { entry: entry, data: data, chrome: chrome, interactive: interactive, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, group: group, density: density, rowActions: rowActions, editable: editable, inCrumbs: inCrumbs, sizing: sizing, export: exportOn, summaries: summaries, embedded: embedded, presentation: presentation, present: present, actions: actions, listLabel: listLabel, order: order, recordNavigation: recordNavigation, at: askedFor.get(data) ?? { page, size }, busy: run.isPlaceholderData })] }));
|
|
234
239
|
}
|
|
235
240
|
/** The table's definition: the statement the database keeps, or one rebuilt from its catalog. */
|
|
236
241
|
function DdlPane({ table }) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TableMeta } from '@mistriwork/engine/shared/schema.js';
|
|
2
|
-
import { type GridData } from './Grid.js';
|
|
2
|
+
import { type GridData, type GridGroup } from './Grid.js';
|
|
3
3
|
import { trailListFor } from '../recordTrail.js';
|
|
4
4
|
import { type ReactNode } from 'react';
|
|
5
5
|
import { type ListOrder } from './useListOrder.js';
|
|
@@ -79,6 +79,8 @@ export interface TableViewProps {
|
|
|
79
79
|
referenceLabels?: Record<string, string>;
|
|
80
80
|
/** Column → its total over the whole query, for the grid's footer. */
|
|
81
81
|
totals?: Record<string, unknown>;
|
|
82
|
+
/** The rows' groups, each run of one value under its head (Grid.tsx `group`). */
|
|
83
|
+
group?: GridGroup;
|
|
82
84
|
density?: 'comfortable' | 'compact';
|
|
83
85
|
/** A ⋯ menu at the end of each row with the record's own actions. */
|
|
84
86
|
rowActions?: boolean;
|
|
@@ -108,4 +110,4 @@ export interface PageAt {
|
|
|
108
110
|
export declare function ViewTabs({ entry }: {
|
|
109
111
|
entry: TableEntry;
|
|
110
112
|
}): import("react").JSX.Element;
|
|
111
|
-
export declare function TableView({ entry, data, chrome, interactive, hide, labels, referenceLabels, totals, density, rowActions, editable, inCrumbs, sizing, export: exportOn, summaries, embedded, presentation, present, actions, listLabel, order, recordNavigation, at: given, busy, }: TableViewProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal>;
|
|
113
|
+
export declare function TableView({ entry, data, chrome, interactive, hide, labels, referenceLabels, totals, group, density, rowActions, editable, inCrumbs, sizing, export: exportOn, summaries, embedded, presentation, present, actions, listLabel, order, recordNavigation, at: given, busy, }: TableViewProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal>;
|
|
@@ -203,7 +203,7 @@ function PageBox({ page, last, onGo }) {
|
|
|
203
203
|
onGo(Math.round(asked) - 1);
|
|
204
204
|
} }));
|
|
205
205
|
}
|
|
206
|
-
export function TableView({ entry, data, chrome, interactive, hide, labels, referenceLabels, totals, density, rowActions, editable, inCrumbs, sizing, export: exportOn = true, summaries = false, embedded = false, presentation, present, actions, listLabel, order, recordNavigation = false, at: given, busy = false, }) {
|
|
206
|
+
export function TableView({ entry, data, chrome, interactive, hide, labels, referenceLabels, totals, group, density, rowActions, editable, inCrumbs, sizing, export: exportOn = true, summaries = false, embedded = false, presentation, present, actions, listLabel, order, recordNavigation = false, at: given, busy = false, }) {
|
|
207
207
|
/* Records or table: how a narrow screen shows the rows, the reader's pick. The page's own list draws the switch at
|
|
208
208
|
the end of its control strip (AppList), beside the tabs; anywhere else, over the rows. */
|
|
209
209
|
const [layout, setLayout] = useState('records');
|
|
@@ -312,7 +312,7 @@ export function TableView({ entry, data, chrome, interactive, hide, labels, refe
|
|
|
312
312
|
leading cell for a reader offered bulk actions, a grip there for a view
|
|
313
313
|
kept in hand order, a ⋯ at the end of each row when the view asks for
|
|
314
314
|
row menus. */
|
|
315
|
-
const gridOf = (rows) => (_jsx(Grid, { table: table, data: rows === data.rows ? data : { ...data, rows }, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, density: density, sizing: sizing, interactive: interactive, firstRow: firstRow, list: list, current: current, dropColumns: embedded || beside, editCell: editCell, ...(adornCell ? { adornCell } : {}) }));
|
|
315
|
+
const gridOf = (rows) => (_jsx(Grid, { table: table, data: rows === data.rows ? data : { ...data, rows }, hide: hide, labels: labels, referenceLabels: referenceLabels, totals: totals, ...(group ? { group } : {}), density: density, sizing: sizing, interactive: interactive, firstRow: firstRow, list: list, current: current, dropColumns: embedded || beside, editCell: editCell, ...(adornCell ? { adornCell } : {}) }));
|
|
316
316
|
const hasOrder = Boolean(listOrder && table);
|
|
317
317
|
const ordered = hasOrder && listOrder && table ? (_jsx(GridOrder, { table: table, rows: data.rows, order: listOrder, interactive: interactive, children: gridOf })) : (gridOf(data.rows));
|
|
318
318
|
const selected = table && selectableGrid(table, actions ?? [], interactive, editing) ? (_jsxs(RowHosts, { children: [_jsx(GridSelection, { table: table, rows: data.rows, actions: actions ?? [], interactive: interactive, editable: editing }), ordered] })) : !hasOrder ? (ordered) : (_jsx(RowHosts, { children: ordered }));
|
|
@@ -320,5 +320,5 @@ export function TableView({ entry, data, chrome, interactive, hide, labels, refe
|
|
|
320
320
|
const tableGrid = rowActions && (interactive || embedded) && table && actions?.some((action) => action.header !== false) && primaryKey(table).length ? (_jsxs(RowTrailHosts, { children: [_jsx(RowActions, { table: table, rows: data.rows, actions: actions, onDone: () => render() }), selected] })) : (selected);
|
|
321
321
|
return (_jsxs(_Fragment, { children: [_jsx(ResultHead, { entry: entry, data: data, chrome: chrome, interactive: interactive, exportOn: exportOn, at: at, headRef: head, inCrumbs: inCrumbs }), _jsxs("div", { className: hasSummaries ? `responsive-results show-${embedded || !choice ? 'records' : layout}` : undefined, children: [hasSummaries && (_jsxs(_Fragment, { children: [!embedded &&
|
|
322
322
|
choice &&
|
|
323
|
-
presentationSwitch(_jsx(PresentationSwitch, { layout: layout, onChange: setLayout, label: say('common.listPresentation'), records: say('common.records'), table: say('common.table') })), _jsx(RecordSummaries, { table: table, data: data, columns: (data.columns ?? []).filter((name) => !hide?.includes(name)), labels: labels, referenceLabels: referenceLabels, list: list, query: entry.query, ...(adornCell ? { adornFact: (row, column) => adornCell(row, column, 'summary') } : {}) })] })), _jsx("div", { className: "result-table", "aria-busy": busy || undefined, children: tableGrid })] }), _jsx(Pager, { entry: entry, data: data, at: at, range: inCrumbs })] }));
|
|
323
|
+
presentationSwitch(_jsx(PresentationSwitch, { layout: layout, onChange: setLayout, label: say('common.listPresentation'), records: say('common.records'), table: say('common.table') })), _jsx(RecordSummaries, { table: table, data: data, columns: (data.columns ?? []).filter((name) => !hide?.includes(name)), labels: labels, referenceLabels: referenceLabels, list: list, query: entry.query, ...(group ? { group } : {}), ...(adornCell ? { adornFact: (row, column) => adornCell(row, column, 'summary') } : {}) })] })), _jsx("div", { className: "result-table", "aria-busy": busy || undefined, children: tableGrid })] }), _jsx(Pager, { entry: entry, data: data, at: at, range: inCrumbs })] }));
|
|
324
324
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* A timeline's reactions (its `reactions`), fetched with TimelineReactions.tsx the first time a section with reactions
|
|
2
|
+
draws, so a first page carries none of it. In the base layer, beside the rest of the timeline in page.css. */
|
|
3
|
+
@layer base {
|
|
4
|
+
/* Reactions under a message: a quiet row of outlined kinds in the column of its words, the reader's own on the accent's
|
|
5
|
+
wash. A press changes the count and the ground, and nothing moves or springs (docs/design.md, motion). */
|
|
6
|
+
.timeline-reactions {
|
|
7
|
+
grid-column: 2;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-wrap: wrap;
|
|
10
|
+
gap: var(--space-2);
|
|
11
|
+
margin-top: var(--space-1);
|
|
12
|
+
}
|
|
13
|
+
.timeline-reaction {
|
|
14
|
+
position: relative;
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: var(--space-2);
|
|
18
|
+
min-height: 24px;
|
|
19
|
+
padding: 0 var(--space-3);
|
|
20
|
+
border: 1px solid var(--line);
|
|
21
|
+
border-radius: var(--radius);
|
|
22
|
+
background: none;
|
|
23
|
+
font-size: var(--text-sm);
|
|
24
|
+
color: var(--ink-muted);
|
|
25
|
+
}
|
|
26
|
+
.timeline-reaction:is([aria-pressed='true'], [data-pressed='true']) {
|
|
27
|
+
border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
|
|
28
|
+
background: color-mix(in srgb, var(--accent) 8%, transparent);
|
|
29
|
+
color: var(--ink);
|
|
30
|
+
}
|
|
31
|
+
.timeline-reaction-count {
|
|
32
|
+
font-variant-numeric: tabular-nums;
|
|
33
|
+
color: var(--ink-subtle);
|
|
34
|
+
}
|
|
35
|
+
@media (hover: hover) and (pointer: fine) {
|
|
36
|
+
button.timeline-reaction:hover:not(:disabled) {
|
|
37
|
+
border-color: var(--line-strong);
|
|
38
|
+
color: var(--ink);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/* On a touch screen a kind's 24px takes a 44px hit area, as the chrome's small controls do (structure.css). */
|
|
42
|
+
@media (pointer: coarse) {
|
|
43
|
+
button.timeline-reaction::after {
|
|
44
|
+
content: '';
|
|
45
|
+
position: absolute;
|
|
46
|
+
inset: -10px 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A timeline entry's reactions: a quiet row of the kinds the section offers, each said through the column's display
|
|
3
|
+
* rule with its count, the reader's own pressed. The counts of every entry on the page are one breakdown, and the
|
|
4
|
+
* reader's own one more read beside it (`<by> = me`), asked together; pressing a kind runs the App's own command on
|
|
5
|
+
* the entry — found through the action of the entry's resource that offers it, as a composer's is — with the kind as
|
|
6
|
+
* its input, so the command decides what a press means (give one, or take it back) under the reader's grants. A reader
|
|
7
|
+
* not granted it reads the counts and presses nothing; a kind no one gave is not drawn for them. A part of its own,
|
|
8
|
+
* with its stylesheet: a page whose timelines carry no reactions never fetches it (PageTimeline.tsx).
|
|
9
|
+
*/
|
|
10
|
+
import './TimelineReactions.css';
|
|
11
|
+
import type { TimelineReactions as Reactions } from '@mistriwork/engine/shared/pageModel.js';
|
|
12
|
+
import { type ReactionEntry, type ReactionTally } from './reactionTally.js';
|
|
13
|
+
/** One entry's row of reactions. */
|
|
14
|
+
export declare function ReactionRow({ reactions, entry, tally }: {
|
|
15
|
+
reactions: Reactions;
|
|
16
|
+
entry: ReactionEntry;
|
|
17
|
+
tally: ReactionTally;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A timeline entry's reactions: a quiet row of the kinds the section offers, each said through the column's display
|
|
4
|
+
* rule with its count, the reader's own pressed. The counts of every entry on the page are one breakdown, and the
|
|
5
|
+
* reader's own one more read beside it (`<by> = me`), asked together; pressing a kind runs the App's own command on
|
|
6
|
+
* the entry — found through the action of the entry's resource that offers it, as a composer's is — with the kind as
|
|
7
|
+
* its input, so the command decides what a press means (give one, or take it back) under the reader's grants. A reader
|
|
8
|
+
* not granted it reads the counts and presses nothing; a kind no one gave is not drawn for them. A part of its own,
|
|
9
|
+
* with its stylesheet: a page whose timelines carry no reactions never fetches it (PageTimeline.tsx).
|
|
10
|
+
*/
|
|
11
|
+
import './TimelineReactions.css';
|
|
12
|
+
import { useState } from 'react';
|
|
13
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
14
|
+
import { columnDisplay, findTable } from '../core.js';
|
|
15
|
+
import { pageBridge } from '../uiBridge.js';
|
|
16
|
+
import { entryKey } from './reactionTally.js';
|
|
17
|
+
import { choiceWord } from './valueModel.js';
|
|
18
|
+
import { Icon } from './Icon.js';
|
|
19
|
+
import { say } from '../copy/record/components/TimelineReactions.js';
|
|
20
|
+
/** One entry's row of reactions. */
|
|
21
|
+
export function ReactionRow({ reactions, entry, tally }) {
|
|
22
|
+
const queries = useQueryClient();
|
|
23
|
+
const [busy, setBusy] = useState(false);
|
|
24
|
+
const handle = pageBridge.commands?.command(reactions.command);
|
|
25
|
+
const pressable = Boolean(handle?.granted);
|
|
26
|
+
const table = findTable(reactions.from);
|
|
27
|
+
const rule = columnDisplay(table?.id ?? reactions.from, reactions.column);
|
|
28
|
+
const kinds = reactions.kinds.map((kind) => {
|
|
29
|
+
const icon = rule?.icons && Object.hasOwn(rule.icons, kind) ? rule.icons[kind] : undefined;
|
|
30
|
+
return {
|
|
31
|
+
kind,
|
|
32
|
+
word: choiceWord(rule, kind),
|
|
33
|
+
icon,
|
|
34
|
+
count: tally.counts.get(entryKey(entry.value, kind)) ?? 0,
|
|
35
|
+
pressed: tally.mine.has(entryKey(entry.value, kind)),
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
const shown = pressable ? kinds : kinds.filter((each) => each.count > 0);
|
|
39
|
+
if (!shown.length)
|
|
40
|
+
return null;
|
|
41
|
+
const press = async (kind, word) => {
|
|
42
|
+
if (!handle || busy)
|
|
43
|
+
return;
|
|
44
|
+
setBusy(true);
|
|
45
|
+
try {
|
|
46
|
+
const outcome = await handle.run({ [entry.column]: entry.value }, { [reactions.column]: kind }, { label: word });
|
|
47
|
+
if (outcome.status === 'applied')
|
|
48
|
+
await queries.invalidateQueries({ queryKey: ['page-reactions'] });
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
setBusy(false);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return (_jsx("div", { className: "timeline-reactions", role: "group", "aria-label": say('reactions'), children: shown.map(({ kind, word, icon, count, pressed }) => {
|
|
55
|
+
const said = (_jsxs(_Fragment, { children: [icon && _jsx(Icon, { name: icon, size: 14, className: "timeline-reaction-icon" }), _jsx("span", { children: word }), count > 0 && _jsx("span", { className: "timeline-reaction-count", children: count })] }));
|
|
56
|
+
return pressable ? (_jsx("button", { type: "button", className: "timeline-reaction", "aria-pressed": pressed, "aria-label": say('reactionCount', { kind: word, count }), disabled: busy, onClick: () => void press(kind, word), children: said }, kind)) : (_jsx("span", { className: "timeline-reaction", "data-pressed": pressed ? 'true' : undefined, children: said }, kind));
|
|
57
|
+
}) }));
|
|
58
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* Brought by a tree picker (TreePicker.tsx), loaded only where a reference is drawn as one. Tokens only. The box,
|
|
2
|
+
the popup and its rows are the record picker's own (features.css); this is what a tree adds to them. */
|
|
3
|
+
@layer components {
|
|
4
|
+
.tree-picker { display: grid; gap: var(--space-1h); min-width: 0; }
|
|
5
|
+
/* The record picker's list measures its room from Base UI's --available-height, as this one does. */
|
|
6
|
+
.tree-picker-popup { width: 100%; }
|
|
7
|
+
.tree-picker-option { justify-content: flex-start; align-items: center; gap: var(--space-2); }
|
|
8
|
+
.tree-picker-option .picker-option-label { flex: 0 1 auto; }
|
|
9
|
+
.tree-picker-caret {
|
|
10
|
+
display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px;
|
|
11
|
+
color: var(--ink-muted); border-radius: min(4px, var(--radius));
|
|
12
|
+
}
|
|
13
|
+
.tree-picker-caret.is-leaf { cursor: inherit; }
|
|
14
|
+
@media (hover: hover) {
|
|
15
|
+
.tree-picker-caret:not(.is-leaf):hover { color: var(--ink); }
|
|
16
|
+
}
|
|
17
|
+
/* A match's path, after its name and pushed to the row's end, as a choice's second line is said. */
|
|
18
|
+
.tree-picker-path { margin-inline-start: auto; text-align: end; }
|
|
19
|
+
/* The chosen record's path under the box: quiet, one line, its separators lighter than its names. */
|
|
20
|
+
.tree-picker-trail {
|
|
21
|
+
display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-1h); margin: 0;
|
|
22
|
+
font: var(--text-xs) var(--sans); color: var(--ink-muted);
|
|
23
|
+
}
|
|
24
|
+
.tree-picker-sep { color: var(--ink-subtle); }
|
|
25
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A reference picker over a hierarchy: a reference whose records hang from one another by a parent column
|
|
3
|
+
* (`tree: 'parent_id'`, on a command's reference and on a New form's field). A category three levels down is found
|
|
4
|
+
* by walking to it, not by remembering its exact name, and once chosen it is said with its path — Hardware ›
|
|
5
|
+
* Laptops › Batteries — so two records of one name under different parents are told apart.
|
|
6
|
+
*
|
|
7
|
+
* The box is a combobox (APG) whose popup is the tree: focus stays in the box, the lit row is its active
|
|
8
|
+
* descendant. Up and Down move through what is open, Right opens a branch or steps into it, Left folds it or steps
|
|
9
|
+
* out to its parent, Home and End go to the ends, Enter chooses, Escape closes. Typing searches every level at once,
|
|
10
|
+
* the popup a list of matches each said with its path; clearing the box goes back to the tree.
|
|
11
|
+
*
|
|
12
|
+
* Read lazily, a level at a time: the records with no parent when the box opens, a branch's children when it is
|
|
13
|
+
* opened, and for each level one breakdown says which of its records have children, so a leaf draws no caret and
|
|
14
|
+
* nothing is read per record. A record whose parent the field's own filter leaves out is not under any branch; a
|
|
15
|
+
* search finds it. A path is read upward a level per request, bounded, and a loop in the data ends it.
|
|
16
|
+
*
|
|
17
|
+
* Every read is the reader's own (`ask`): the reader's connection, or a public form's visitor read, so the tree
|
|
18
|
+
* offers only the records its reader may read, as a flat picker does. Nothing slides open (motion rule 8).
|
|
19
|
+
*/
|
|
20
|
+
import './TreePicker.css';
|
|
21
|
+
import { type Ref } from 'react';
|
|
22
|
+
export type TreeValue = string | number;
|
|
23
|
+
/** One read, as the reader may make it: `/api/run` for rows, `/api/breakdown` for which rows have children. */
|
|
24
|
+
export type TreeAsk = (path: '/api/run' | '/api/breakdown', body: Record<string, unknown>) => Promise<{
|
|
25
|
+
rows?: unknown;
|
|
26
|
+
errors?: unknown[];
|
|
27
|
+
}>;
|
|
28
|
+
interface TreePickerProps {
|
|
29
|
+
/** The table (or resource) the records are read from, as query text starts. */
|
|
30
|
+
from: string;
|
|
31
|
+
/** Its key column: the value kept. */
|
|
32
|
+
by: string;
|
|
33
|
+
/** The column each record is said by. */
|
|
34
|
+
labelColumn: string;
|
|
35
|
+
/** The column naming each record's parent, by `by`. */
|
|
36
|
+
parent: string;
|
|
37
|
+
/** Only the records this condition admits (the field's own filter). */
|
|
38
|
+
where?: string;
|
|
39
|
+
ask: TreeAsk;
|
|
40
|
+
/** Who reads, for the answers kept between opens: a reader's answers are never another's. */
|
|
41
|
+
scope: string;
|
|
42
|
+
value: TreeValue | '' | undefined;
|
|
43
|
+
onChange: (value: TreeValue | '', label?: string) => void;
|
|
44
|
+
/** The chosen record's name where the caller has it already. */
|
|
45
|
+
known?: string;
|
|
46
|
+
id?: string;
|
|
47
|
+
/** The box's name where no `<label for>` gives it one. */
|
|
48
|
+
ariaLabel?: string;
|
|
49
|
+
/** What the popup is called where the box is named by its `<label>`: the field's caption. */
|
|
50
|
+
listLabel?: string;
|
|
51
|
+
describedBy?: string;
|
|
52
|
+
invalid?: boolean;
|
|
53
|
+
required?: boolean;
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
placeholder?: string;
|
|
56
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
57
|
+
}
|
|
58
|
+
export declare function TreePicker({ from, by, labelColumn, parent, where, ask, scope, value, onChange, known, id, ariaLabel, listLabel, describedBy, invalid, required, disabled, placeholder, inputRef, }: TreePickerProps): import("react").JSX.Element;
|
|
59
|
+
export {};
|