foldkit-mixins-data-grid 0.1.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/LICENSE +21 -0
- package/README.md +275 -0
- package/dist/index.d.mts +375 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1846 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +62 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { Attr, Capability, Event, Slot, SlotView, Slots } from "foldkit-mixins";
|
|
2
|
+
import { Option } from "effect";
|
|
3
|
+
import { CellAddress, ColumnSpec, ColumnState, DataGridOf, Direction, RowModel, RowSelection, RowStatus, Viewport } from "foldkit-data-grid";
|
|
4
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/slots.d.ts
|
|
7
|
+
export declare const GridSlots: Slots.Contract<{
|
|
8
|
+
/** The scroll container: `role="grid"`, the one tab stop, and the keyboard. */
|
|
9
|
+
readonly root: Slot.UnnamedSlot<Capability.Capability<"Focusable", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly [Event.EventToken<"keydown">], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"aria-label">, Attr.AttrToken<"aria-rowcount">, Attr.AttrToken<"aria-colcount">, Attr.AttrToken<"aria-activedescendant">], readonly Slot.RequirementName[], boolean>;
|
|
10
|
+
/** The header row's group; it stays at the top while the body scrolls. */
|
|
11
|
+
readonly header: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
12
|
+
readonly headerRow: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* One per drawn column. `data-pinned` is `start` or `end` on a pinned
|
|
15
|
+
* column; while a header is dragged it has `data-dragging` and follows the
|
|
16
|
+
* pointer by a `transform`, and the shown neighbour it would land beside
|
|
17
|
+
* has `data-drop`, `before` or `after`.
|
|
18
|
+
*/
|
|
19
|
+
readonly headerCell: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* A column's resize handle at its end edge: a `role="separator"` with its
|
|
22
|
+
* width as `aria-valuenow`, dragged with the pointer, or stepped with the
|
|
23
|
+
* arrow keys once focused. It is out of the tab order, so the grid stays
|
|
24
|
+
* one tab stop. Only resizable columns have one.
|
|
25
|
+
*/
|
|
26
|
+
readonly resizeHandle: Slot.UnnamedSlot<Capability.Capability<"Focusable", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly [Event.EventToken<"keydown">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
27
|
+
readonly body: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
28
|
+
/** One per drawn row; `aria-rowindex` is its place among every row, drawn or not. */
|
|
29
|
+
readonly row: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
30
|
+
/** One per drawn cell; `data-focused` marks the current one, `data-pinned` a pinned one. */
|
|
31
|
+
readonly cell: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly [Event.EventToken<"mousedown">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
32
|
+
/** A row counted but not loaded yet, drawn at its height for a skeleton to style. */
|
|
33
|
+
readonly placeholder: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* The text field a cell is edited in, drawn in place of its content while
|
|
36
|
+
* the edit lasts; `aria-invalid` when the column refused the draft.
|
|
37
|
+
*/
|
|
38
|
+
readonly editor: Slot.UnnamedSlot<Capability.Capability<"TextInput", readonly [Capability.Capability<"Focusable", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>]>, readonly [Event.EventToken<"input">, Event.EventToken<"keydown">, Event.EventToken<"blur">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Why the column refused a draft, shown below the field while the edit
|
|
41
|
+
* lasts; the field names it with `aria-describedby`.
|
|
42
|
+
*/
|
|
43
|
+
readonly editorError: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* The editor of a column whose schema's text is one of a few literals,
|
|
46
|
+
* drawn in place of the cell's content while the edit lasts, like
|
|
47
|
+
* `editor`: a `role="combobox"` showing the draft, its options in
|
|
48
|
+
* `choiceList` (or, with `choiceEditor: 'native'`, a `select`).
|
|
49
|
+
*/
|
|
50
|
+
readonly choice: Slot.UnnamedSlot<Capability.Capability<"Focusable", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly [Event.EventToken<"change">, Event.EventToken<"keydown">, Event.EventToken<"blur">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* A choice's options, `role="listbox"`, below the cell, or above it when
|
|
53
|
+
* the cell is low in the view (`data-place="above"`).
|
|
54
|
+
*/
|
|
55
|
+
readonly choiceList: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
56
|
+
/** One literal a `choice` offers: `role="option"`, `aria-selected` on the draft. */
|
|
57
|
+
readonly choiceOption: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly [Event.EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
58
|
+
/** Said in place of rows when there are none: empty, loading, or failed. */
|
|
59
|
+
readonly status: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* The button on a column's header that opens its menu, when the view is
|
|
62
|
+
* given `columnMenu`: `aria-haspopup="menu"` and `aria-expanded`, out of
|
|
63
|
+
* the tab order like the grid's other controls.
|
|
64
|
+
*/
|
|
65
|
+
readonly menuButton: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly [Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* A column's open menu, below its header: a `role="menu"` that takes focus
|
|
68
|
+
* and points at its active item with `aria-activedescendant`, as the grid
|
|
69
|
+
* points at its cell. Focus leaving it closes it.
|
|
70
|
+
*/
|
|
71
|
+
readonly menu: Slot.UnnamedSlot<Capability.Capability<"Focusable", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly [Event.EventToken<"keydown">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
72
|
+
/** One of a menu's items; `data-active` marks the one the keyboard is on. */
|
|
73
|
+
readonly menuItem: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly [Event.EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
74
|
+
/**
|
|
75
|
+
* The button on a sortable column's header: a click sends its sort Message.
|
|
76
|
+
* `data-sort` is `asc` or `desc` while the column is sorted.
|
|
77
|
+
*/
|
|
78
|
+
readonly sort: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
79
|
+
/**
|
|
80
|
+
* The square at the end corner of the range, or of the focused cell, in a
|
|
81
|
+
* grid that edits: dragged, it fills the cells it is drawn over. Pointer
|
|
82
|
+
* only and hidden from assistive technology; Ctrl+D and Ctrl+R fill by key.
|
|
83
|
+
*/
|
|
84
|
+
readonly fillHandle: Slot.UnnamedSlot<Capability.Capability<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
85
|
+
/** Below the rows: a failure that left them on screen, and the More button. */
|
|
86
|
+
readonly footer: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
87
|
+
readonly retry: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
88
|
+
readonly more: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
89
|
+
}>;
|
|
90
|
+
declare namespace metadataToken_d_exports {
|
|
91
|
+
export { Any, KindOf, MetadataToken, MetadataTokenTypeId, NameOf, NamesOf, is, make, nameOf };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Ported from `effect-atom-jsx/src/MetadataToken.ts`. Kinded name tokens so
|
|
95
|
+
* Event, Attr, Requirement, and Capability share one witness instead of four
|
|
96
|
+
* ad-hoc brands.
|
|
97
|
+
*/
|
|
98
|
+
declare const MetadataTokenTypeId: unique symbol;
|
|
99
|
+
interface MetadataToken<Kind extends string, Name extends string> {
|
|
100
|
+
readonly [MetadataTokenTypeId]: {
|
|
101
|
+
readonly Kind: Kind;
|
|
102
|
+
readonly Name: Name;
|
|
103
|
+
};
|
|
104
|
+
readonly kind: Kind;
|
|
105
|
+
readonly name: Name;
|
|
106
|
+
}
|
|
107
|
+
type Any = MetadataToken<string, string>;
|
|
108
|
+
type NameOf<T> = T extends MetadataToken<any, infer Name> ? Name : T extends string ? T : never;
|
|
109
|
+
type KindOf<T> = T extends MetadataToken<infer Kind, any> ? Kind : never;
|
|
110
|
+
type NamesOf<T extends readonly unknown[]> = NameOf<T[number]>;
|
|
111
|
+
declare const make: <const Kind extends string, const Name extends string>(kind: Kind, name: Name) => MetadataToken<Kind, Name>;
|
|
112
|
+
declare const is: (value: unknown) => value is Any;
|
|
113
|
+
declare const nameOf: (value: string | Any) => string;
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region ../mixins/src/capability.d.ts
|
|
116
|
+
type CapabilityParent = string | MetadataToken<'element.capability', string>;
|
|
117
|
+
interface Capability$1<Name extends string = string, Extends extends readonly CapabilityParent[] = readonly []> extends MetadataToken<'element.capability', Name> {
|
|
118
|
+
readonly extends: Extends;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region ../mixins/src/attr.d.ts
|
|
122
|
+
type AttrToken<Name extends string = string> = MetadataToken<'view.attribute', Name>;
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region ../mixins/src/event.d.ts
|
|
125
|
+
type EventToken<Name extends string = string> = MetadataToken<'view.event', Name>;
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region ../mixins/src/requirement.d.ts
|
|
128
|
+
type RequirementToken<Name extends string = string> = MetadataToken<'view.requirement', Name>;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region ../mixins/src/slot.d.ts
|
|
131
|
+
type EventName = string | EventToken;
|
|
132
|
+
type AttributeName = string | AttrToken;
|
|
133
|
+
type RequirementName = string | RequirementToken;
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/style.d.ts
|
|
136
|
+
/** Every piece is in the `components` layer, so an application's own layer wins. */
|
|
137
|
+
export declare const GridStyle: import("foldkit-mixins").NamedStyle<import("foldkit-mixins").SlotsContract<{
|
|
138
|
+
readonly root: import("foldkit-mixins").UnnamedSlot<Capability$1<"Focusable", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly [import("foldkit-mixins").EventToken<"keydown">], readonly [import("foldkit-mixins").AttrToken<"role">, import("foldkit-mixins").AttrToken<"aria-label">, import("foldkit-mixins").AttrToken<"aria-rowcount">, import("foldkit-mixins").AttrToken<"aria-colcount">, import("foldkit-mixins").AttrToken<"aria-activedescendant">], readonly RequirementName[], boolean>;
|
|
139
|
+
readonly header: import("foldkit-mixins").UnnamedSlot<Capability$1<"Container", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
140
|
+
readonly headerRow: import("foldkit-mixins").UnnamedSlot<Capability$1<"Container", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
141
|
+
readonly headerCell: import("foldkit-mixins").UnnamedSlot<Capability$1<"Base", readonly []>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
142
|
+
readonly resizeHandle: import("foldkit-mixins").UnnamedSlot<Capability$1<"Focusable", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly [import("foldkit-mixins").EventToken<"keydown">], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
143
|
+
readonly body: import("foldkit-mixins").UnnamedSlot<Capability$1<"Container", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
144
|
+
readonly row: import("foldkit-mixins").UnnamedSlot<Capability$1<"Container", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
145
|
+
readonly cell: import("foldkit-mixins").UnnamedSlot<Capability$1<"Base", readonly []>, readonly [import("foldkit-mixins").EventToken<"mousedown">], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
146
|
+
readonly placeholder: import("foldkit-mixins").UnnamedSlot<Capability$1<"Base", readonly []>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
147
|
+
readonly editor: import("foldkit-mixins").UnnamedSlot<Capability$1<"TextInput", readonly [Capability$1<"Focusable", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>]>, readonly [import("foldkit-mixins").EventToken<"input">, import("foldkit-mixins").EventToken<"keydown">, import("foldkit-mixins").EventToken<"blur">], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
148
|
+
readonly editorError: import("foldkit-mixins").UnnamedSlot<Capability$1<"Base", readonly []>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
149
|
+
readonly choice: import("foldkit-mixins").UnnamedSlot<Capability$1<"Focusable", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly [import("foldkit-mixins").EventToken<"change">, import("foldkit-mixins").EventToken<"keydown">, import("foldkit-mixins").EventToken<"blur">], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
150
|
+
readonly choiceList: import("foldkit-mixins").UnnamedSlot<Capability$1<"Base", readonly []>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
151
|
+
readonly choiceOption: import("foldkit-mixins").UnnamedSlot<Capability$1<"Base", readonly []>, readonly [import("foldkit-mixins").EventToken<"click">], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
152
|
+
readonly status: import("foldkit-mixins").UnnamedSlot<Capability$1<"Base", readonly []>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
153
|
+
readonly menuButton: import("foldkit-mixins").UnnamedSlot<Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly [import("foldkit-mixins").AttrToken<"aria-label">], readonly RequirementName[], boolean>;
|
|
154
|
+
readonly menu: import("foldkit-mixins").UnnamedSlot<Capability$1<"Focusable", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly [import("foldkit-mixins").EventToken<"keydown">], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
155
|
+
readonly menuItem: import("foldkit-mixins").UnnamedSlot<Capability$1<"Base", readonly []>, readonly [import("foldkit-mixins").EventToken<"click">], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
156
|
+
readonly sort: import("foldkit-mixins").UnnamedSlot<Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
157
|
+
readonly fillHandle: import("foldkit-mixins").UnnamedSlot<Capability$1<"Base", readonly []>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
158
|
+
readonly footer: import("foldkit-mixins").UnnamedSlot<Capability$1<"Container", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly EventName[], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
159
|
+
readonly retry: import("foldkit-mixins").UnnamedSlot<Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
160
|
+
readonly more: import("foldkit-mixins").UnnamedSlot<Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly AttributeName[], readonly RequirementName[], boolean>;
|
|
161
|
+
}>>;
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/view.d.ts
|
|
164
|
+
interface GridWords {
|
|
165
|
+
/** In place of rows when there are none. Default `No rows.` */
|
|
166
|
+
readonly empty?: string;
|
|
167
|
+
/** While the first rows are awaited. Default `Loading…`. */
|
|
168
|
+
readonly loading?: string;
|
|
169
|
+
/** When the read failed. `{message}` is the failure's. Default `{message}`. */
|
|
170
|
+
readonly failed?: string;
|
|
171
|
+
/** On the button that asks again after a failure. Default `Try again`. */
|
|
172
|
+
readonly retry?: string;
|
|
173
|
+
/** On the button that loads more rows. Default `More`. */
|
|
174
|
+
readonly more?: string;
|
|
175
|
+
/** The name of a column's menu button. `{column}` is its header. Default `{column} menu`. */
|
|
176
|
+
readonly menu?: string;
|
|
177
|
+
/** Menu items. `{column}` in `show` is the hidden column's header. */
|
|
178
|
+
readonly pinStart?: string;
|
|
179
|
+
readonly pinEnd?: string;
|
|
180
|
+
readonly unpin?: string;
|
|
181
|
+
readonly hide?: string;
|
|
182
|
+
readonly show?: string;
|
|
183
|
+
}
|
|
184
|
+
/** How a column is sorted, and the Message that sorts it next: `foldkit-crud`'s `Sort` gives these. */
|
|
185
|
+
interface ColumnSort<Message> {
|
|
186
|
+
readonly direction?: 'asc' | 'desc' | undefined;
|
|
187
|
+
readonly message: Message;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* A state the application gives one cell, such as an edit not yet saved. The
|
|
191
|
+
* grid draws its `name` as `data-mark` on the cell's Slot, for a style, and
|
|
192
|
+
* its `description` as the cell's `aria-description`, for a screen reader,
|
|
193
|
+
* and its `title`, shown on hover.
|
|
194
|
+
*/
|
|
195
|
+
interface CellMark {
|
|
196
|
+
readonly name: string;
|
|
197
|
+
readonly description: string;
|
|
198
|
+
}
|
|
199
|
+
/** What the grid's view reads, and what the application gives it. */
|
|
200
|
+
interface GridInput<Row, Id extends string, GridMessage, Message> {
|
|
201
|
+
/** The `DataGrid` Model as placed in the parent. */
|
|
202
|
+
readonly state: {
|
|
203
|
+
readonly focus: {
|
|
204
|
+
readonly current: Option.Option<CellAddress<Id>>;
|
|
205
|
+
readonly header: Option.Option<Id>;
|
|
206
|
+
};
|
|
207
|
+
readonly viewport: Viewport;
|
|
208
|
+
readonly columns: ColumnState<Id>;
|
|
209
|
+
readonly selection: {
|
|
210
|
+
readonly rows: RowSelection;
|
|
211
|
+
readonly anchor: Option.Option<string>;
|
|
212
|
+
readonly cells: Option.Option<{
|
|
213
|
+
readonly anchor: CellAddress<Id>;
|
|
214
|
+
readonly focus: CellAddress<Id>;
|
|
215
|
+
}>;
|
|
216
|
+
};
|
|
217
|
+
readonly editing: Option.Option<{
|
|
218
|
+
readonly address: CellAddress<Id>;
|
|
219
|
+
readonly draft: string;
|
|
220
|
+
readonly error: Option.Option<string>;
|
|
221
|
+
}>;
|
|
222
|
+
readonly dragging: Option.Option<{
|
|
223
|
+
readonly column: Id;
|
|
224
|
+
readonly delta: number;
|
|
225
|
+
}>;
|
|
226
|
+
readonly menu: Option.Option<{
|
|
227
|
+
readonly column: Id;
|
|
228
|
+
readonly active: number;
|
|
229
|
+
}>;
|
|
230
|
+
readonly filling: Option.Option<{
|
|
231
|
+
readonly source: {
|
|
232
|
+
readonly anchor: CellAddress<Id>;
|
|
233
|
+
readonly focus: CellAddress<Id>;
|
|
234
|
+
};
|
|
235
|
+
readonly to: CellAddress<Id>;
|
|
236
|
+
}>;
|
|
237
|
+
};
|
|
238
|
+
/** The application's rows, in its order; the view draws them through `state.columns`. */
|
|
239
|
+
readonly rows: RowModel<Row>;
|
|
240
|
+
/** Lifts the grid's own Messages into the parent's: the placement's wrapper. */
|
|
241
|
+
readonly wrap: (message: GridMessage) => Message;
|
|
242
|
+
/** The grid's accessible name. */
|
|
243
|
+
readonly label: string;
|
|
244
|
+
readonly rowHeight: number;
|
|
245
|
+
readonly headerHeight: number;
|
|
246
|
+
readonly overscan?: {
|
|
247
|
+
readonly rows?: number;
|
|
248
|
+
readonly columns?: number;
|
|
249
|
+
};
|
|
250
|
+
readonly direction?: Direction;
|
|
251
|
+
/** Draws one cell; by default the column's value, as text. */
|
|
252
|
+
readonly cell?: (column: Id, row: Row, h: HtmlBuilder<Message>) => Html | string;
|
|
253
|
+
/** A cell's mark, if it has one; asked only for the cells drawn. */
|
|
254
|
+
readonly marks?: (address: CellAddress<Id>) => Option.Option<CellMark>;
|
|
255
|
+
/**
|
|
256
|
+
* How a choice column is edited: a list the grid draws, styled with the
|
|
257
|
+
* page (`list`, the default), or the platform's own `select` (`native`),
|
|
258
|
+
* whose picker suits a touch screen better. Pass `native` from a media
|
|
259
|
+
* fact in the Model, such as a coarse pointer; the view reads no media.
|
|
260
|
+
*/
|
|
261
|
+
readonly choiceEditor?: 'list' | 'native';
|
|
262
|
+
readonly words?: GridWords;
|
|
263
|
+
/**
|
|
264
|
+
* Where the rows' source stands (`GridCrud.status` for a Remote page).
|
|
265
|
+
* Default `Ready`. The grid holds no loading state: the source's owner does.
|
|
266
|
+
*/
|
|
267
|
+
readonly status?: RowStatus;
|
|
268
|
+
/** Asks again after a failure; given, a failed grid shows a button that sends it. */
|
|
269
|
+
readonly onRetry?: Message;
|
|
270
|
+
/**
|
|
271
|
+
* Loads more rows; given, a grid whose count is not known yet shows a button
|
|
272
|
+
* that sends it. Attach `MoreOnScroll` to send it as the end comes into view.
|
|
273
|
+
*/
|
|
274
|
+
readonly onMore?: Message;
|
|
275
|
+
/**
|
|
276
|
+
* A menu button on each header, opening the column's menu: pin it to the
|
|
277
|
+
* start or the end or unpin it, hide it, or show a hidden column. On a
|
|
278
|
+
* focused header Alt+ArrowDown, Shift+F10 or the menu key opens it.
|
|
279
|
+
*/
|
|
280
|
+
readonly columnMenu?: boolean;
|
|
281
|
+
/** The columns that sort, each with its direction and its Message. */
|
|
282
|
+
readonly sort?: { readonly [K in Id]?: ColumnSort<Message>; };
|
|
283
|
+
}
|
|
284
|
+
export declare const DataGridView: <Message>() => {
|
|
285
|
+
/**
|
|
286
|
+
* The view of one `DataGrid`. It draws the grid's columns' headers and the
|
|
287
|
+
* window of cells `VirtualGrid.window` picks for the placed viewport, and
|
|
288
|
+
* sends the grid's Messages through `wrap`: `Moved` for a key, with the
|
|
289
|
+
* scroll that reveals the cell, `Focused` for the pointer, `Measured` from
|
|
290
|
+
* the scroll container. Attach Style and Behavior to the result.
|
|
291
|
+
*/
|
|
292
|
+
define: <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>>(grid: DataGridOf<Row, Specs>) => SlotView.SlotView<typeof GridSlots, GridInput<Row, keyof Specs & string, typeof grid.Message.Type, Message>, Message>;
|
|
293
|
+
};
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/moreOnScroll.d.ts
|
|
296
|
+
/**
|
|
297
|
+
* Sends the grid's `onMore` as its More button comes within 200px of the
|
|
298
|
+
* grid's visible box, and again after each load while the button stays
|
|
299
|
+
* there; the button stays for the keyboard. Nothing is asked while the rows'
|
|
300
|
+
* source is busy. Attach it to a grid's view:
|
|
301
|
+
* `DataGridView<Message>().define(Grid).pipe(MoreOnScroll)`.
|
|
302
|
+
*/
|
|
303
|
+
export declare const MoreOnScroll: <Row, Id extends string, GridMessage, Message>(view: SlotView.SlotView<typeof GridSlots, GridInput<Row, Id, GridMessage, Message>, Message>) => SlotView.SlotView<typeof GridSlots, GridInput<Row, Id, GridMessage, Message>, Message>;
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/marks.d.ts
|
|
306
|
+
export declare const GridMarks: readonly ["pending", "saved", "refused", "replaced", "peer"];
|
|
307
|
+
type GridMark = (typeof GridMarks)[number];
|
|
308
|
+
export declare const GridLegendSlots: Slots.Contract<{
|
|
309
|
+
/** The list: labelled, so a screen reader names what the marks are. */
|
|
310
|
+
readonly legend: Slot.UnnamedSlot<Slot.SlotCapability, readonly Slot.EventName[], readonly [Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>;
|
|
311
|
+
/** One mark and its words. */
|
|
312
|
+
readonly legendItem: Slot.UnnamedSlot<Slot.SlotCapability, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
313
|
+
/** The mark drawn small, as the cells draw it (`data-mark`), hidden from screen readers. */
|
|
314
|
+
readonly legendSwatch: Slot.UnnamedSlot<Slot.SlotCapability, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
315
|
+
}>;
|
|
316
|
+
/** The words for each mark, and the legend's own label. */
|
|
317
|
+
interface GridLegendWords {
|
|
318
|
+
readonly label: string;
|
|
319
|
+
readonly marks: Readonly<Record<GridMark, string>>;
|
|
320
|
+
}
|
|
321
|
+
interface GridLegendInput {
|
|
322
|
+
/** The marks to explain, in order; all five when omitted. */
|
|
323
|
+
readonly marks?: ReadonlyArray<GridMark>;
|
|
324
|
+
readonly words?: GridLegendWords;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* A legend of the marks, each beside a swatch drawn by the same rules as the
|
|
328
|
+
* cells (`GridMarkStyle` styles both), so the two cannot drift apart.
|
|
329
|
+
*/
|
|
330
|
+
export declare const GridLegend: <Message>() => SlotView.SlotView<Slots.Contract<{
|
|
331
|
+
/** The list: labelled, so a screen reader names what the marks are. */
|
|
332
|
+
readonly legend: Slot.UnnamedSlot<Slot.SlotCapability, readonly Slot.EventName[], readonly [Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>;
|
|
333
|
+
/** One mark and its words. */
|
|
334
|
+
readonly legendItem: Slot.UnnamedSlot<Slot.SlotCapability, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
335
|
+
/** The mark drawn small, as the cells draw it (`data-mark`), hidden from screen readers. */
|
|
336
|
+
readonly legendSwatch: Slot.UnnamedSlot<Slot.SlotCapability, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
337
|
+
}>, GridLegendInput, Message>;
|
|
338
|
+
/** The marks on the grid's cells. Attach after `GridStyle`, whose plain dot it replaces by name. */
|
|
339
|
+
export declare const GridMarkStyle: import("foldkit-mixins").NamedStyle<Slots.Contract<{
|
|
340
|
+
readonly root: Slot.UnnamedSlot<Capability$1<"Focusable", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly [import("foldkit-mixins").EventToken<"keydown">], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"aria-label">, Attr.AttrToken<"aria-rowcount">, Attr.AttrToken<"aria-colcount">, Attr.AttrToken<"aria-activedescendant">], readonly Slot.RequirementName[], boolean>;
|
|
341
|
+
readonly header: Slot.UnnamedSlot<Capability$1<"Container", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
342
|
+
readonly headerRow: Slot.UnnamedSlot<Capability$1<"Container", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
343
|
+
readonly headerCell: Slot.UnnamedSlot<Capability$1<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
344
|
+
readonly resizeHandle: Slot.UnnamedSlot<Capability$1<"Focusable", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly [import("foldkit-mixins").EventToken<"keydown">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
345
|
+
readonly body: Slot.UnnamedSlot<Capability$1<"Container", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
346
|
+
readonly row: Slot.UnnamedSlot<Capability$1<"Container", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
347
|
+
readonly cell: Slot.UnnamedSlot<Capability$1<"Base", readonly []>, readonly [import("foldkit-mixins").EventToken<"mousedown">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
348
|
+
readonly placeholder: Slot.UnnamedSlot<Capability$1<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
349
|
+
readonly editor: Slot.UnnamedSlot<Capability$1<"TextInput", readonly [Capability$1<"Focusable", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>]>, readonly [import("foldkit-mixins").EventToken<"input">, import("foldkit-mixins").EventToken<"keydown">, import("foldkit-mixins").EventToken<"blur">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
350
|
+
readonly editorError: Slot.UnnamedSlot<Capability$1<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
351
|
+
readonly choice: Slot.UnnamedSlot<Capability$1<"Focusable", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly [import("foldkit-mixins").EventToken<"change">, import("foldkit-mixins").EventToken<"keydown">, import("foldkit-mixins").EventToken<"blur">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
352
|
+
readonly choiceList: Slot.UnnamedSlot<Capability$1<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
353
|
+
readonly choiceOption: Slot.UnnamedSlot<Capability$1<"Base", readonly []>, readonly [import("foldkit-mixins").EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
354
|
+
readonly status: Slot.UnnamedSlot<Capability$1<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
355
|
+
readonly menuButton: Slot.UnnamedSlot<Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly [Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>;
|
|
356
|
+
readonly menu: Slot.UnnamedSlot<Capability$1<"Focusable", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly [import("foldkit-mixins").EventToken<"keydown">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
357
|
+
readonly menuItem: Slot.UnnamedSlot<Capability$1<"Base", readonly []>, readonly [import("foldkit-mixins").EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
358
|
+
readonly sort: Slot.UnnamedSlot<Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
359
|
+
readonly fillHandle: Slot.UnnamedSlot<Capability$1<"Base", readonly []>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
360
|
+
readonly footer: Slot.UnnamedSlot<Capability$1<"Container", readonly [Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
361
|
+
readonly retry: Slot.UnnamedSlot<Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
362
|
+
readonly more: Slot.UnnamedSlot<Capability$1<"Interactive", readonly [Capability$1<"Base", readonly []>]>, readonly [import("foldkit-mixins").EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
363
|
+
}>>;
|
|
364
|
+
/** The legend's look, its swatches drawn by the cells' own rules. */
|
|
365
|
+
export declare const GridLegendStyle: import("foldkit-mixins").NamedStyle<Slots.Contract<{
|
|
366
|
+
/** The list: labelled, so a screen reader names what the marks are. */
|
|
367
|
+
readonly legend: Slot.UnnamedSlot<Slot.SlotCapability, readonly Slot.EventName[], readonly [Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>;
|
|
368
|
+
/** One mark and its words. */
|
|
369
|
+
readonly legendItem: Slot.UnnamedSlot<Slot.SlotCapability, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
370
|
+
/** The mark drawn small, as the cells draw it (`data-mark`), hidden from screen readers. */
|
|
371
|
+
readonly legendSwatch: Slot.UnnamedSlot<Slot.SlotCapability, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>;
|
|
372
|
+
}>>;
|
|
373
|
+
//#endregion
|
|
374
|
+
export type { CellMark, ColumnSort, GridInput, GridLegendInput, GridLegendWords, GridMark, GridWords };
|
|
375
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/slots.ts","../../mixins/src/metadataToken.d.ts","../../mixins/src/capability.d.ts","../../mixins/src/attr.d.ts","../../mixins/src/event.d.ts","../../mixins/src/requirement.d.ts","../../mixins/src/slot.d.ts","../src/style.ts","../src/view.ts","../src/moreOnScroll.ts","../src/marks.ts"],"mappings":";;;;;;qBA8Ba,WAAS,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCzBD;UACJ,cAAc,qBAAqB;YACtC;aACG,MAAM;aACN,MAAM;;WAEV,MAAM;WACN,MAAM;;KAEP,MAAM;KACN,OAAO,KAAK,UAAU,yBAAyB,QAAQ,OAAO,mBAAmB;KACjF,OAAO,KAAK,UAAU,oBAAoB,aAAa;KACvD,QAAQ,gCAAgC,OAAO;cACtC,aAAa,2BAA2B,qBAAqB,MAAM,MAAM,MAAM,SAAS,cAAc,MAAM;cAC5G,KAAK,mBAAmB,SAAS;cACjC,SAAS,gBAAgB;;;KCdlC,4BAA4B;UACvB,aAAW,8BAA8B,yBAAyB,0CAA0C,oCAAkD;WAClK,SAAS;;;;KCHV,UAAU,gCAAgC,gCAA8C;;;KCAxF,WAAW,gCAAgC,4BAA0C;;;KCArF,iBAAiB,gCAAgC,kCAAgD;;;KCSjG,qBAAqB;KACrB,yBAAyB;KACzB,2BAA2B;;;;qBCiC1B,oCAAS,oCAAA;gIAAT;;;;;;;;;;;;;;;;;;;;;;;;;;UCfI;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;;;UAIM,WAAW;WACjB;WACA,SAAS;;;;;;;;UASH;WACN;WACA;;;UAIM,UAAU,KAAK,mBAAmB,aAAa;;WAErD;aACE;eACE,SAAS,OAAO,OAAO,YAAY;eACnC,QAAQ,OAAO,OAAO;;aAExB,UAAU;aACV,SAAS,YAAY;aACrB;eACE,MAAM;eACN,QAAQ,OAAO;eACf,OAAO,OAAO;iBACZ,QAAQ,YAAY;iBACpB,OAAO,YAAY;;;aAGvB,SAAS,OAAO;eACd,SAAS,YAAY;eACrB;eACA,OAAO,OAAO;;aAEhB,UAAU,OAAO;eAAkB,QAAQ;eAAa;;aACxD,MAAM,OAAO;eAAkB,QAAQ;eAAa;;aACpD,SAAS,OAAO;eACd;iBAAmB,QAAQ,YAAY;iBAAc,OAAO,YAAY;;eACxE,IAAI,YAAY;;;;WAIpB,MAAM,SAAS;;WAEf,OAAO,SAAS,gBAAgB;;WAEhC;WACA;WACA;WACA;aAAsB;aAAwB;;WAC9C,YAAY;;WAEZ,QAAQ,QAAQ,IAAI,KAAK,KAAK,GAAG,YAAY,aAAa;;WAE1D,SAAS,SAAS,YAAY,QAAQ,OAAO,OAAO;;;;;;;WAOpD;WACA,QAAQ;;;;;WAKR,SAAS;;WAET,UAAU;;;;;WAKV,SAAS;;;;;;WAMT;;WAEA,mBAAmB,KAAK,MAAM,WAAW;;qBAixCvC,eA7tCC;;;;;;;;EAQH,SAAA,KAAK,cAAc,eAAe,WAAW,gBAAc,MAC5D,WAAW,KAAK,WACrB,SAAS,gBACH,WACP,UAAU,WAAW,uBAAuB,KAAK,QAAQ,MAAM,UAC/D;;;;;;;;;;;qBCnMS,eAAgB,KAAK,mBAAmB,aAAa,SAChE,MAAM,SAAS,gBAAgB,WAAW,UAAU,KAAK,IAAI,aAAa,UAAU,aACnF,SAAS,gBAAgB,WAAW,UAAU,KAAK,IAAI,aAAa,UAAU;;;qBCHpE;KACD,mBAAmB;qBAmClB,iBAAe,MAAA;;;;;;;;;UAUX;WACN;WACA,OAAO,SAAS,OAAO;;UAcjB;;WAEN,QAAQ,cAAc;WACtB,QAAQ;;;;;;qBAON,aAAc,cAAO,SAAA,SAAA,MAAA;;;;;;;IAkB/B,iBAAA;;qBAGU,wCAAa,WAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;qBAMb,0CAAe,WAAA,MAAA"}
|