gridsmith-ui 0.32.0 → 0.33.0
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/CHANGELOG.md +33 -1
- package/README.md +4 -2
- package/dist/charts.d.ts +10 -1
- package/dist/charts.js +113 -48
- package/dist/charts.js.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/{chunk-NGZJK57C.js → chunk-6NRLTG5W.js} +8 -7
- package/dist/chunk-6NRLTG5W.js.map +1 -0
- package/dist/{chunk-OVHM55JF.js → chunk-6XCWKLJZ.js} +40 -5
- package/dist/chunk-6XCWKLJZ.js.map +1 -0
- package/dist/{chunk-JHZ22HQP.js → chunk-AB4UQ4G5.js} +58 -219
- package/dist/chunk-AB4UQ4G5.js.map +1 -0
- package/dist/{chunk-SIEU4H3H.js → chunk-AVSP6NDX.js} +5 -5
- package/dist/{chunk-SIEU4H3H.js.map → chunk-AVSP6NDX.js.map} +1 -1
- package/dist/chunk-F2XMZOUP.js +81 -0
- package/dist/chunk-F2XMZOUP.js.map +1 -0
- package/dist/{chunk-XBVZIN26.js → chunk-FF57N3P7.js} +8 -6
- package/dist/chunk-FF57N3P7.js.map +1 -0
- package/dist/chunk-GIA4BMGI.js +18 -0
- package/dist/chunk-GIA4BMGI.js.map +1 -0
- package/dist/{chunk-DO6DLTFK.js → chunk-OWGF362U.js} +4 -4
- package/dist/{chunk-DO6DLTFK.js.map → chunk-OWGF362U.js.map} +1 -1
- package/dist/chunk-P3NUUIL6.js +9 -0
- package/dist/chunk-P3NUUIL6.js.map +1 -0
- package/dist/chunk-R7FG4ZQ5.js +16 -0
- package/dist/chunk-R7FG4ZQ5.js.map +1 -0
- package/dist/{chunk-QY2RA2HO.js → chunk-UBLBVCQN.js} +3 -3
- package/dist/{chunk-QY2RA2HO.js.map → chunk-UBLBVCQN.js.map} +1 -1
- package/dist/{chunk-HUVZQOU4.js → chunk-WD6T57ZJ.js} +3 -3
- package/dist/{chunk-HUVZQOU4.js.map → chunk-WD6T57ZJ.js.map} +1 -1
- package/dist/chunk-ZQV26NND.js +213 -0
- package/dist/chunk-ZQV26NND.js.map +1 -0
- package/dist/dashboard.d.ts +207 -0
- package/dist/dashboard.js +1210 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/data-grid.js +8 -7
- package/dist/data-grid.js.map +1 -1
- package/dist/index.d.ts +50 -6
- package/dist/index.js +190 -128
- package/dist/index.js.map +1 -1
- package/dist/kanban.js +6 -6
- package/dist/resizable.js +7 -6
- package/dist/resizable.js.map +1 -1
- package/dist/utils.d.ts +51 -1
- package/dist/utils.js +55 -4
- package/dist/utils.js.map +1 -1
- package/dist/virtualized.js +6 -6
- package/package.json +6 -1
- package/dist/chunk-H732QL56.js +0 -71
- package/dist/chunk-H732QL56.js.map +0 -1
- package/dist/chunk-JHZ22HQP.js.map +0 -1
- package/dist/chunk-LJYSVZMI.js +0 -25
- package/dist/chunk-LJYSVZMI.js.map +0 -1
- package/dist/chunk-NGZJK57C.js.map +0 -1
- package/dist/chunk-OVHM55JF.js.map +0 -1
- package/dist/chunk-XBVZIN26.js.map +0 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { IconName } from './icons.js';
|
|
4
|
+
import { a as DropdownMenuEntry } from './DropdownMenu-DqT7ZQ0D.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sprint 32 (A2) — a dashboard's layout, as plain data: its widgets in reading order, each with a width in columns of 12
|
|
8
|
+
* and a height in rows of a fixed height. The grid lays them out as text is laid out: left to right, then the next row,
|
|
9
|
+
* each taking the first space after the one before that fits it (CSS grid's sparse auto-placement, never `dense`), so
|
|
10
|
+
* what's on screen, what a screen reader reads and where Tab goes are one order by construction.
|
|
11
|
+
*
|
|
12
|
+
* Server-safe: no React and no browser, so `gridsmith-ui/utils` exports the helpers (normaliseLayout, moveItem,
|
|
13
|
+
* resizeItem, addItem, removeItem) and a page that only adds a widget, or a test that checks a layout, needs no drag
|
|
14
|
+
* code. The rest is the grid's own: where widgets land (`placeLayout`, a copy of the browser's placement rule, held equal
|
|
15
|
+
* to Chrome's by a Chrome test), where a key or a pointer would take one (`stepTarget`, `nearestIndex`) and the words a
|
|
16
|
+
* screen reader hears for a size. Where things land is worked out here, from the layout, never measured from the
|
|
17
|
+
* screen: measuring a preview feeds back into it, the flicker sortable grids are known for.
|
|
18
|
+
*/
|
|
19
|
+
interface DashboardLayoutItem {
|
|
20
|
+
id: string;
|
|
21
|
+
/** Its width, in columns of 12. */
|
|
22
|
+
w: number;
|
|
23
|
+
/** Its height, in rows. */
|
|
24
|
+
h: number;
|
|
25
|
+
/** The narrowest it may be made, in columns (default 3, a quarter of the width; a widget is never narrower). */
|
|
26
|
+
minW?: number;
|
|
27
|
+
/** The shortest it may be made, in rows (default 2). */
|
|
28
|
+
minH?: number;
|
|
29
|
+
/** The widest it may be made, in columns (default 12). */
|
|
30
|
+
maxW?: number;
|
|
31
|
+
/** The tallest it may be made, in rows. */
|
|
32
|
+
maxH?: number;
|
|
33
|
+
}
|
|
34
|
+
type DashboardLayout = DashboardLayoutItem[];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Sprint 32 (A1–A13) — the dashboard grid: a dashboard the people using the app arrange themselves. Its widgets sit in a
|
|
38
|
+
* reading order on 12 columns (lib/dashboard-layout.ts), each one of the library's titled frames, which the grid only
|
|
39
|
+
* places: no frame of its own, so never a card in a card (A3). In the view it is an ordinary page (custom_interaction#20):
|
|
40
|
+
* nothing drags, and a widget's own links and clicks work as anywhere else. In its edit mode, entered on purpose, each
|
|
41
|
+
* widget gets three controls beside its frame, never inside it (A4): a move handle, a ⋯ menu (Set up, Move, Size and the
|
|
42
|
+
* page's own actions) and a resize grip. Every drag has a keyboard way and a plain click way (accessibility#26), and
|
|
43
|
+
* everything is said in the grid's own polite live region, with the widget's name, never its id (A7).
|
|
44
|
+
*
|
|
45
|
+
* The pointer and touch go through dnd-kit 6.3.1, the Kanban's: the mouse sensor after 5 px and the touch sensor after a
|
|
46
|
+
* hold (never the pointer sensor, which also answers touch and would start on a 5 px swipe), its auto-scroll for the page,
|
|
47
|
+
* and nothing of its own said. The keyboard's moves are the grid's own state, never dnd-kit's keyboard sensor (A5).
|
|
48
|
+
*/
|
|
49
|
+
/** A kind of widget the palette offers (A8): its name, an optional description and icon, and the size it starts at. */
|
|
50
|
+
interface DashboardWidgetKind {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
icon?: IconName;
|
|
55
|
+
/** Its starting width, in columns of 12. A chart's kind starts tall enough to hold the chart's floor (5 rows). */
|
|
56
|
+
w: number;
|
|
57
|
+
/** Its starting height, in rows. */
|
|
58
|
+
h: number;
|
|
59
|
+
}
|
|
60
|
+
interface DashboardItemProps {
|
|
61
|
+
/** The widget's id, as its layout entry has it. */
|
|
62
|
+
id: string;
|
|
63
|
+
/**
|
|
64
|
+
* The widget's name, its frame's title on screen ("Cash balance"): what a screen reader hears on the grid's controls
|
|
65
|
+
* ("Move Cash balance") and in what the grid says ("Cash balance, position 3 of 8"). In development a label that
|
|
66
|
+
* differs from the frame's title is warned about.
|
|
67
|
+
*/
|
|
68
|
+
label: string;
|
|
69
|
+
/** The widget: one of the library's titled frames (a ChartContainer, a StatsCard, a titled Table, a Card with a CardHeader). */
|
|
70
|
+
children: ReactNode;
|
|
71
|
+
}
|
|
72
|
+
interface DashboardGridProps {
|
|
73
|
+
/**
|
|
74
|
+
* The widgets in reading order, each with a width in columns of 12 and a height in rows: plain data the page saves as it
|
|
75
|
+
* likes. Authoritative: the grid draws what it's given, normalised (normaliseLayout), each widget once, in this order.
|
|
76
|
+
*/
|
|
77
|
+
layout: readonly DashboardLayoutItem[];
|
|
78
|
+
/** The layout after a change the person made: once per change kept (a drop, a menu choice, a keyboard drop, a resize kept). */
|
|
79
|
+
onLayoutChange?: (layout: DashboardLayout) => void;
|
|
80
|
+
/**
|
|
81
|
+
* The edit mode, entered on purpose (custom_interaction#20): handles, grips and the column guides, and each widget's
|
|
82
|
+
* content inert, so a press on a chart never opens its report mid-edit. Off, the dashboard is an ordinary page.
|
|
83
|
+
*/
|
|
84
|
+
editing?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Edit mode only: the person chose a widget to set up, from its ⋯ menu's Set up or by a click on the widget (one that
|
|
87
|
+
* began on it, never the end of a drag or a resize). Show its settings in the page's side panel.
|
|
88
|
+
*/
|
|
89
|
+
onSelect?: (id: string) => void;
|
|
90
|
+
/**
|
|
91
|
+
* A widget's own entries for its ⋯ menu (Duplicate, Remove…), after the grid's Set up, Move and Size, as a Kanban card's
|
|
92
|
+
* cardActions. A Remove that takes the widget out puts focus on the same control in the widget before, else after.
|
|
93
|
+
*/
|
|
94
|
+
itemActions?: (id: string) => DropdownMenuEntry[];
|
|
95
|
+
/**
|
|
96
|
+
* A widget of this kind added from the palette, by a click on its row (at the end) or a drop (where it lands): add the
|
|
97
|
+
* page's widget and its layout entry (addItem), and return the new widget's id, or a promise of it for an id the server
|
|
98
|
+
* makes. Focus goes to the new widget's move handle (its ⋯ on a stacked grid).
|
|
99
|
+
*/
|
|
100
|
+
onAdd?: (kind: DashboardWidgetKind, index: number) => string | PromiseLike<string>;
|
|
101
|
+
/** The widgets, each a DashboardItem: an array or a fragment of them. */
|
|
102
|
+
children?: ReactNode;
|
|
103
|
+
/**
|
|
104
|
+
* The name of the widgets' group while editing, as a screen reader hears it, and where focus goes when the last widget
|
|
105
|
+
* is removed. Default "Dashboard widgets".
|
|
106
|
+
*/
|
|
107
|
+
"aria-label"?: string;
|
|
108
|
+
className?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Sprint 32 (A8): the palette and the grid share one drag, so a widget library's kind can be dragged onto the grid. A
|
|
112
|
+
* page that uses both wraps them in a DashboardEditor (anywhere above both: the side panel and the page's content); a
|
|
113
|
+
* grid alone needs none. One grid to an editor: each tab's grid in turn, as only the open tab's is drawn.
|
|
114
|
+
*/
|
|
115
|
+
declare function DashboardEditor({ children }: {
|
|
116
|
+
children: ReactNode;
|
|
117
|
+
}): react_jsx_runtime.JSX.Element;
|
|
118
|
+
/**
|
|
119
|
+
* One widget on a DashboardGrid (A3). The grid reads its props and draws it in a cell of its own, in the layout's order;
|
|
120
|
+
* on its own it draws its children.
|
|
121
|
+
*/
|
|
122
|
+
declare function DashboardItem({ children }: DashboardItemProps): react_jsx_runtime.JSX.Element;
|
|
123
|
+
/** The grid drawn in a drag arena: an editor's, else one of its own (a grid alone needs no editor). */
|
|
124
|
+
declare function DashboardGrid(props: DashboardGridProps): react_jsx_runtime.JSX.Element;
|
|
125
|
+
|
|
126
|
+
interface DashboardPaletteProps {
|
|
127
|
+
/** The kinds of widget the page offers (headline number, line chart, table, text note, image…), in the order listed. */
|
|
128
|
+
kinds: DashboardWidgetKind[];
|
|
129
|
+
/** The list's name, as a screen reader hears it. Default "Widget library". */
|
|
130
|
+
label?: string;
|
|
131
|
+
/**
|
|
132
|
+
* The line above the list that says what a row does: by default "Select or drag to add" while the rows drag,
|
|
133
|
+
* and "Select a widget to add it" where they don't (a grid stacked at a narrow width); none while the grid isn't
|
|
134
|
+
* editing. A function gives other words for each case (it's told whether the rows drag); false draws none.
|
|
135
|
+
*/
|
|
136
|
+
hint?: false | ((rowsDrag: boolean) => string);
|
|
137
|
+
className?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Sprint 32 (A8): the widget library the briefs ask for, a list of the kinds of widget a page offers, each with its name,
|
|
141
|
+
* an optional description and icon. Each kind is one control, a button named "Add {kind}" (the look fixes, D5): a click,
|
|
142
|
+
* Enter or Space adds the widget at the end (the plain click way, accessibility#26), and a pointer's drag of the row
|
|
143
|
+
* places it where it's dropped (the grid's sensors tell the two apart: 5 px of movement for a mouse, a 250 ms press for a
|
|
144
|
+
* finger). The grid asks the page for the widget (its onAdd), focus goes to the new widget's move handle, and the grid's
|
|
145
|
+
* live region says where it went. It reaches the grid through the DashboardEditor round them both.
|
|
146
|
+
*
|
|
147
|
+
* Where it sits, so the grid keeps its width (the guidance's composition): in an AsidePanel with `width="312px"
|
|
148
|
+
* collapseBelow="xl" resizable={false}`, docked beside the grid from 1280 px and a drawer over the page below, its body
|
|
149
|
+
* padded as the panel's heading is (each row's hover tint and focus outline reach 8 px into that padding). An Add closes
|
|
150
|
+
* the overlay the panel has become, wherever it opens over the page (the drawer, or the phone's sheet), so the new widget
|
|
151
|
+
* isn't left under it; docked beside the grid, the panel stays open. Wherever the grid is stacked (narrower than 40rem)
|
|
152
|
+
* nothing drags, and focus goes to the new widget's ⋯, since a stacked grid has no handle. Adding and dragging are off
|
|
153
|
+
* while the grid isn't editing.
|
|
154
|
+
*
|
|
155
|
+
* A line above the list says what a row does (the owner's look at the second sheet: the rows drag, so say so), as visible
|
|
156
|
+
* text before the list rather than its description, which screen readers read unreliably: its words follow whether the
|
|
157
|
+
* rows drag (`hint`), and there are none while the grid isn't editing, outside a DashboardEditor, or with no kinds. The
|
|
158
|
+
* list keeps its name, its data attribute and the className, so the line is the list's sibling, not its wrapper.
|
|
159
|
+
*/
|
|
160
|
+
declare function DashboardPalette({ kinds, label, hint, className }: DashboardPaletteProps): react_jsx_runtime.JSX.Element;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Sprint 32 (A10): a draft the person edits and then saves or cancels as a whole: a dashboard's tabs (added, renamed,
|
|
164
|
+
* reordered, removed), each tab's layout and each widget's settings, in whatever shape the page gives it. Every change can be
|
|
165
|
+
* undone and redone (custom_interaction#26), from the page's visible Undo and Redo buttons and from the keyboard:
|
|
166
|
+
* Ctrl+Z or ⌘Z undoes, with Shift it redoes, outside text fields only, so a field's own undo keeps working.
|
|
167
|
+
*/
|
|
168
|
+
interface DraftHistory<T> {
|
|
169
|
+
/** The draft now. */
|
|
170
|
+
value: T;
|
|
171
|
+
/**
|
|
172
|
+
* Changes the draft: a new value, or a function of the one before. Each change is a step that Undo takes back, and a
|
|
173
|
+
* change after an Undo drops what Redo had. Pass `merge` (a field's name, say) for a run of changes that is one step:
|
|
174
|
+
* each keystroke in a widget's title field, so Undo takes back the edit, not a letter. A change to the same value
|
|
175
|
+
* adds no step.
|
|
176
|
+
*/
|
|
177
|
+
set: (next: T | ((prev: T) => T), merge?: string) => void;
|
|
178
|
+
undo: () => void;
|
|
179
|
+
redo: () => void;
|
|
180
|
+
canUndo: boolean;
|
|
181
|
+
canRedo: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* The draft differs from what was last saved (the first value, or the last `reset`): `dirty` enables Save. Cancel always
|
|
184
|
+
* goes back to the view, calling `reset(saved)` first, so it's never disabled.
|
|
185
|
+
*/
|
|
186
|
+
dirty: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Starts again from a saved value, with no steps to undo: after Save, `reset()` takes the draft as saved; Cancel
|
|
189
|
+
* passes the saved value back, `reset(saved)`, and the draft is that. A value loaded after the first render is passed
|
|
190
|
+
* here too.
|
|
191
|
+
*/
|
|
192
|
+
reset: (next?: T) => void;
|
|
193
|
+
}
|
|
194
|
+
interface DraftHistoryOptions {
|
|
195
|
+
/** Ctrl+Z, ⌘Z and their Shift forms on the page. Default true; off where two drafts share a page, or a dialog has its own. */
|
|
196
|
+
shortcuts?: boolean;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* A draft held whole until it's saved, with undo and redo: a dashboard's tabs, each tab's layout and each widget's
|
|
200
|
+
* settings in one value, or anything else a page edits before Save. `set` changes it, one step Undo takes back; `dirty`
|
|
201
|
+
* says it differs from what was last saved, and enables Save; Cancel always goes back to the view, calling
|
|
202
|
+
* `reset(saved)` first; `reset()` after Save. Ctrl+Z or ⌘Z undoes and with Shift redoes, outside text fields, unless
|
|
203
|
+
* `shortcuts` is false.
|
|
204
|
+
*/
|
|
205
|
+
declare function useDraftHistory<T>(initial: T | (() => T), { shortcuts }?: DraftHistoryOptions): DraftHistory<T>;
|
|
206
|
+
|
|
207
|
+
export { DashboardEditor, DashboardGrid, type DashboardGridProps, DashboardItem, type DashboardItemProps, type DashboardLayout, type DashboardLayoutItem, DashboardPalette, type DashboardPaletteProps, type DashboardWidgetKind, type DraftHistory, type DraftHistoryOptions, useDraftHistory };
|