tinybase 6.5.2 → 6.6.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/@types/ui-react-dom/index.d.ts +153 -20
- package/@types/ui-react-dom/with-schemas/index.d.ts +72 -20
- package/@types/ui-react-inspector/index.d.ts +7 -0
- package/@types/ui-react-inspector/with-schemas/index.d.ts +26 -1925
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/ui-react/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom/index.js +1 -1
- package/min/ui-react-dom/index.js.gz +0 -0
- package/min/ui-react-dom/with-schemas/index.js +1 -1
- package/min/ui-react-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/omni/index.js +2003 -1156
- package/omni/with-schemas/index.js +2003 -1156
- package/package.json +4 -4
- package/readme.md +2 -2
- package/ui-react/index.js +397 -368
- package/ui-react/with-schemas/index.js +397 -368
- package/ui-react-dom/index.js +873 -436
- package/ui-react-dom/with-schemas/index.js +873 -436
- package/ui-react-inspector/index.js +1717 -544
- package/ui-react-inspector/with-schemas/index.js +1717 -544
|
@@ -9,1936 +9,38 @@
|
|
|
9
9
|
* @module ui-react-inspector
|
|
10
10
|
* @since v5.0.0
|
|
11
11
|
*/
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
CellIdFromSchema,
|
|
15
|
-
TableIdFromSchema,
|
|
16
|
-
} from '../../_internal/store/with-schemas/index.d.ts';
|
|
17
|
-
import type {
|
|
18
|
-
CellProps,
|
|
19
|
-
CellPropsForTableIdAndCellId,
|
|
20
|
-
ComponentReturnType,
|
|
21
|
-
ExtraProps,
|
|
22
|
-
IndexesOrIndexesId,
|
|
23
|
-
QueriesOrQueriesId,
|
|
24
|
-
RelationshipsOrRelationshipsId,
|
|
25
|
-
ResultCellProps,
|
|
26
|
-
StoreOrStoreId,
|
|
27
|
-
ValueProps,
|
|
28
|
-
} from '../../_internal/ui-react/with-schemas/index.d.ts';
|
|
29
|
-
import type {Id, Ids} from '../../common/with-schemas/index.d.ts';
|
|
30
|
-
import type {NoSchemas} from '../../store/index.d.ts';
|
|
31
|
-
import type {OptionalSchemas} from '../../store/with-schemas/index.d.ts';
|
|
12
|
+
import type {ComponentReturnType} from '../../_internal/ui-react/with-schemas/index.d.ts';
|
|
32
13
|
|
|
33
14
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
37
|
-
* @since v4.1.0
|
|
38
|
-
*/
|
|
39
|
-
export type CustomCell<
|
|
40
|
-
Schemas extends OptionalSchemas,
|
|
41
|
-
TableId extends TableIdFromSchema<Schemas[0]>,
|
|
42
|
-
CellId extends CellIdFromSchema<Schemas[0], TableId>,
|
|
43
|
-
> = {
|
|
44
|
-
/**
|
|
45
|
-
* An optional string that will be used as the label at the top of the table
|
|
46
|
-
* column for this Cell.
|
|
47
|
-
* @category Prop
|
|
48
|
-
* @since v4.1.0
|
|
49
|
-
*/
|
|
50
|
-
label?: string;
|
|
51
|
-
/**
|
|
52
|
-
* An optional custom component for rendering each Cell in the Table (to
|
|
53
|
-
* override the default CellView component).
|
|
54
|
-
* @category Prop
|
|
55
|
-
* @since v4.1.0
|
|
56
|
-
*/
|
|
57
|
-
component?: ComponentType<
|
|
58
|
-
CellPropsForTableIdAndCellId<Schemas, TableId, CellId>
|
|
59
|
-
>;
|
|
60
|
-
/**
|
|
61
|
-
* An optional function for generating extra props for each custom Cell
|
|
62
|
-
* component based on Row and Cell Id.
|
|
63
|
-
* @category Prop
|
|
64
|
-
* @since v4.1.0
|
|
65
|
-
*/
|
|
66
|
-
getComponentProps?: (rowId: Id, cellId: CellId) => ExtraProps;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The CustomResultCell object is used to configure custom cell rendering for
|
|
71
|
-
* query results in an HTML table.
|
|
72
|
-
* @category Configuration
|
|
73
|
-
* @since v4.1.0
|
|
74
|
-
*/
|
|
75
|
-
export type CustomResultCell<Schemas extends OptionalSchemas> = {
|
|
76
|
-
/**
|
|
77
|
-
* An optional string that will be used as the label at the top of the table
|
|
78
|
-
* column for this Cell.
|
|
79
|
-
* @category Prop
|
|
80
|
-
* @since v4.1.0
|
|
81
|
-
*/
|
|
82
|
-
label?: string;
|
|
83
|
-
/**
|
|
84
|
-
* An optional custom component for rendering each Cell in the ResultTable (to
|
|
85
|
-
* override the default ResultCellView component).
|
|
86
|
-
* @category Prop
|
|
87
|
-
* @since v4.1.0
|
|
88
|
-
*/
|
|
89
|
-
component?: ComponentType<ResultCellProps<Schemas>>;
|
|
90
|
-
/**
|
|
91
|
-
* An optional function for generating extra props for each custom Cell
|
|
92
|
-
* component based on Row and Cell Id.
|
|
93
|
-
* @category Prop
|
|
94
|
-
* @since v4.1.0
|
|
95
|
-
*/
|
|
96
|
-
getComponentProps?: (rowId: Id, cellId: Id) => ExtraProps;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* HtmlTableProps props are used for components that will render in an HTML
|
|
101
|
-
* table, such as the TableInHtmlTable component or SortedTableInHtmlTable
|
|
102
|
-
* component.
|
|
103
|
-
* @category Props
|
|
104
|
-
* @since v4.1.0
|
|
105
|
-
*/
|
|
106
|
-
export type HtmlTableProps = {
|
|
107
|
-
/**
|
|
108
|
-
* A string className to use on the root of the resulting element.
|
|
109
|
-
* @category Prop
|
|
110
|
-
* @since v4.1.0
|
|
111
|
-
*/
|
|
112
|
-
readonly className?: string;
|
|
113
|
-
/**
|
|
114
|
-
* Whether a header row should be rendered at the top of the table, defaulting
|
|
115
|
-
* to `true`.
|
|
116
|
-
* @category Prop
|
|
117
|
-
* @since v4.1.0
|
|
118
|
-
*/
|
|
119
|
-
readonly headerRow?: boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Whether an Id column should be rendered on the left of the table,
|
|
122
|
-
* defaulting to `true`.
|
|
123
|
-
* @category Prop
|
|
124
|
-
* @since v4.1.0
|
|
125
|
-
*/
|
|
126
|
-
readonly idColumn?: boolean;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* TableInHtmlTableProps props are used for components that will render a Table
|
|
131
|
-
* in an HTML table, such as the TableInHtmlTable component.
|
|
132
|
-
* @category Props
|
|
133
|
-
* @since v4.1.0
|
|
134
|
-
*/
|
|
135
|
-
export type TableInHtmlTableProps<
|
|
136
|
-
Schemas extends OptionalSchemas,
|
|
137
|
-
TableIds extends TableIdFromSchema<Schemas[0]> = TableIdFromSchema<
|
|
138
|
-
Schemas[0]
|
|
139
|
-
>,
|
|
140
|
-
> = TableIds extends infer TableId
|
|
141
|
-
? TableId extends TableIdFromSchema<Schemas[0]>
|
|
142
|
-
? {
|
|
143
|
-
/**
|
|
144
|
-
* The Id of the Table in the Store to be rendered.
|
|
145
|
-
* @category Prop
|
|
146
|
-
* @since v4.1.0
|
|
147
|
-
*/
|
|
148
|
-
readonly tableId: TableId;
|
|
149
|
-
/**
|
|
150
|
-
* The Store to be accessed: omit for the default context Store, provide an Id
|
|
151
|
-
* for a named context Store, or provide an explicit reference.
|
|
152
|
-
* @category Prop
|
|
153
|
-
* @since v4.1.0
|
|
154
|
-
*/
|
|
155
|
-
readonly store?: StoreOrStoreId<Schemas>;
|
|
156
|
-
/**
|
|
157
|
-
* Whether the Cells should be editable. This affects the default CellView
|
|
158
|
-
* component (to use the EditableCellView component instead) but of course
|
|
159
|
-
* will not affect custom Cell components if you have set them.
|
|
160
|
-
* @category Prop
|
|
161
|
-
* @since v4.1.0
|
|
162
|
-
*/
|
|
163
|
-
readonly editable?: boolean;
|
|
164
|
-
/**
|
|
165
|
-
* An optional list of Cell Ids to use for rendering a prescribed set of the
|
|
166
|
-
* Table's Cells in a given order. This can also be an object with the desired
|
|
167
|
-
* Cell Ids as keys, and with a value that can either be a string label to
|
|
168
|
-
* show in the column header, or a CustomCell object to further configure the
|
|
169
|
-
* column.
|
|
170
|
-
* @category Prop
|
|
171
|
-
* @since v4.1.0
|
|
172
|
-
*/
|
|
173
|
-
readonly customCells?:
|
|
174
|
-
| CellIdFromSchema<Schemas[0], TableId>[]
|
|
175
|
-
| {
|
|
176
|
-
[CellId in CellIdFromSchema<Schemas[0], TableId>]?:
|
|
177
|
-
| string
|
|
178
|
-
| CustomCell<Schemas, TableId, CellId>;
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
: never
|
|
182
|
-
: never;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* SortedTableInHtmlTableProps props are used for components that will render a
|
|
186
|
-
* sorted Table in an HTML table, such as the SortedTableInHtmlTable component.
|
|
187
|
-
* @category Props
|
|
188
|
-
* @since v4.1.0
|
|
189
|
-
*/
|
|
190
|
-
export type SortedTableInHtmlTableProps<
|
|
191
|
-
Schemas extends OptionalSchemas,
|
|
192
|
-
TableIds extends TableIdFromSchema<Schemas[0]> = TableIdFromSchema<
|
|
193
|
-
Schemas[0]
|
|
194
|
-
>,
|
|
195
|
-
> = TableIds extends infer TableId
|
|
196
|
-
? TableId extends TableIdFromSchema<Schemas[0]>
|
|
197
|
-
? {
|
|
198
|
-
/**
|
|
199
|
-
* The Id of the Table in the Store to be rendered.
|
|
200
|
-
* @category Prop
|
|
201
|
-
* @since v4.1.0
|
|
202
|
-
*/
|
|
203
|
-
readonly tableId: TableId;
|
|
204
|
-
/**
|
|
205
|
-
* The Id of the Cell whose values are used for the sorting. If omitted, the
|
|
206
|
-
* view will sort the Row Id itself.
|
|
207
|
-
* @category Prop
|
|
208
|
-
* @since v4.1.0
|
|
209
|
-
*/
|
|
210
|
-
readonly cellId?: CellIdFromSchema<Schemas[0], TableId>;
|
|
211
|
-
/**
|
|
212
|
-
* Whether the sorting should be in descending order.
|
|
213
|
-
* @category Prop
|
|
214
|
-
* @since v4.1.0
|
|
215
|
-
*/
|
|
216
|
-
readonly descending?: boolean;
|
|
217
|
-
/**
|
|
218
|
-
* The number of Row Ids to skip for pagination purposes.
|
|
219
|
-
* @category Prop
|
|
220
|
-
* @since v4.1.0
|
|
221
|
-
*/
|
|
222
|
-
readonly offset?: number;
|
|
223
|
-
/**
|
|
224
|
-
* The maximum number of Row Ids to return.
|
|
225
|
-
* @category Prop
|
|
226
|
-
* @since v4.1.0
|
|
227
|
-
*/
|
|
228
|
-
readonly limit?: number;
|
|
229
|
-
/**
|
|
230
|
-
* The Store to be accessed: omit for the default context Store, provide an Id
|
|
231
|
-
* for a named context Store, or provide an explicit reference.
|
|
232
|
-
* @category Prop
|
|
233
|
-
* @since v4.1.0
|
|
234
|
-
*/
|
|
235
|
-
readonly store?: StoreOrStoreId<Schemas>;
|
|
236
|
-
/**
|
|
237
|
-
* Whether the Cells should be editable. This affects the default CellView
|
|
238
|
-
* component (to use the EditableCellView component instead) but of course
|
|
239
|
-
* will not affect custom Cell components if you have set them.
|
|
240
|
-
* @category Prop
|
|
241
|
-
* @since v4.1.0
|
|
242
|
-
*/
|
|
243
|
-
readonly editable?: boolean;
|
|
244
|
-
/**
|
|
245
|
-
* An optional list of Cell Ids to use for rendering a prescribed set of the
|
|
246
|
-
* Table's Cells in a given order. This can also be an object with the desired
|
|
247
|
-
* Cell Ids as keys, and with a value that can either be a string label to
|
|
248
|
-
* show in the column header, or a CustomCell object to further configure the
|
|
249
|
-
* column.
|
|
250
|
-
* @category Prop
|
|
251
|
-
* @since v4.1.0
|
|
252
|
-
*/
|
|
253
|
-
readonly customCells?:
|
|
254
|
-
| CellIdFromSchema<Schemas[0], TableId>[]
|
|
255
|
-
| {
|
|
256
|
-
[CellId in CellIdFromSchema<Schemas[0], TableId>]?:
|
|
257
|
-
| string
|
|
258
|
-
| CustomCell<Schemas, TableId, CellId>;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* Whether the table should be interactive such that clicking a header changes
|
|
262
|
-
* the sorting and/or direction.
|
|
263
|
-
* @category Prop
|
|
264
|
-
* @since v4.1.0
|
|
265
|
-
*/
|
|
266
|
-
readonly sortOnClick?: boolean;
|
|
267
|
-
/**
|
|
268
|
-
* Either `true` to show the default SortedTablePaginator for the Table, or
|
|
269
|
-
* provide your own paginator component that takes SortedTablePaginatorProps.
|
|
270
|
-
* @category Prop
|
|
271
|
-
* @since v4.1.0
|
|
272
|
-
*/
|
|
273
|
-
readonly paginator?: boolean | ComponentType<SortedTablePaginatorProps>;
|
|
274
|
-
/**
|
|
275
|
-
* A function that is called whenever the sorting or pagination of the Table
|
|
276
|
-
* is changed by the user, invoked with the sorted Cell Id, whether descending
|
|
277
|
-
* or not, and the offset of the pagination.
|
|
278
|
-
* @category Prop
|
|
279
|
-
* @since v4.1.0
|
|
280
|
-
*/
|
|
281
|
-
readonly onChange?: (
|
|
282
|
-
sortAndOffset: [
|
|
283
|
-
cellId: CellIdFromSchema<Schemas[0], TableId> | undefined,
|
|
284
|
-
descending: boolean,
|
|
285
|
-
offset: number,
|
|
286
|
-
],
|
|
287
|
-
) => void;
|
|
288
|
-
}
|
|
289
|
-
: never
|
|
290
|
-
: never;
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* ValuesInHtmlTableProps props are used for components that will render Values
|
|
294
|
-
* in an HTML table, such as the ValuesInHtmlTable component.
|
|
295
|
-
* @category Props
|
|
296
|
-
* @since v4.1.0
|
|
297
|
-
*/
|
|
298
|
-
export type ValuesInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
299
|
-
/**
|
|
300
|
-
* The Store to be accessed: omit for the default context Store, provide an Id
|
|
301
|
-
* for a named context Store, or provide an explicit reference.
|
|
302
|
-
* @category Prop
|
|
303
|
-
* @since v4.1.0
|
|
304
|
-
*/
|
|
305
|
-
readonly store?: StoreOrStoreId<Schemas>;
|
|
306
|
-
/**
|
|
307
|
-
* Whether the Values should be editable. This affects the default ValueView
|
|
308
|
-
* component (to use the EditableValueView component instead) but of course
|
|
309
|
-
* will not affect a custom valueComponent if you have set one.
|
|
310
|
-
* @category Prop
|
|
311
|
-
* @since v4.1.0
|
|
312
|
-
*/
|
|
313
|
-
readonly editable?: boolean;
|
|
314
|
-
/**
|
|
315
|
-
* A custom component for rendering each Value in the Store (to override the
|
|
316
|
-
* default ValueView component).
|
|
317
|
-
* @category Prop
|
|
318
|
-
* @since v4.1.0
|
|
319
|
-
*/
|
|
320
|
-
readonly valueComponent?: ComponentType<ValueProps<Schemas>>;
|
|
321
|
-
/**
|
|
322
|
-
* A function for generating extra props for each custom Value component based
|
|
323
|
-
* on its Id.
|
|
324
|
-
* @category Prop
|
|
325
|
-
* @since v4.1.0
|
|
326
|
-
*/
|
|
327
|
-
readonly getValueComponentProps?: (valueId: Id) => ExtraProps;
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* SliceInHtmlTableProps props are used for components that will render an Index
|
|
332
|
-
* Slice in an HTML table, such as the SliceInHtmlTable component.
|
|
333
|
-
* @category Props
|
|
334
|
-
* @since v4.1.0
|
|
335
|
-
*/
|
|
336
|
-
export type SliceInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
337
|
-
/**
|
|
338
|
-
* The Id of the Index in the Indexes object.
|
|
339
|
-
* @category Prop
|
|
340
|
-
* @since v4.1.0
|
|
341
|
-
*/
|
|
342
|
-
readonly indexId: Id;
|
|
343
|
-
/**
|
|
344
|
-
* The Id of the Slice in the Index to be rendered.
|
|
345
|
-
* @category Prop
|
|
346
|
-
* @since v4.1.0
|
|
347
|
-
*/
|
|
348
|
-
readonly sliceId: Id;
|
|
349
|
-
/**
|
|
350
|
-
* The Indexes object to be accessed: omit for the default context Indexes
|
|
351
|
-
* object, provide an Id for a named context Indexes object, or provide an
|
|
352
|
-
* explicit reference.
|
|
353
|
-
* @category Prop
|
|
354
|
-
* @since v4.1.0
|
|
355
|
-
*/
|
|
356
|
-
readonly indexes?: IndexesOrIndexesId<Schemas>;
|
|
357
|
-
/**
|
|
358
|
-
* Whether the Cells should be editable. This affects the default CellView
|
|
359
|
-
* component (to use the EditableCellView component instead) but of course
|
|
360
|
-
* will not affect custom Cell components if you have set them.
|
|
361
|
-
* @category Prop
|
|
362
|
-
* @since v4.1.0
|
|
363
|
-
*/
|
|
364
|
-
readonly editable?: boolean;
|
|
365
|
-
/**
|
|
366
|
-
* An optional list of Cell Ids to use for rendering a prescribed set of the
|
|
367
|
-
* Slice's Cells in a given order. This can also be an object with the desired
|
|
368
|
-
* Cell Ids as keys, and with a value that can either be a string label to
|
|
369
|
-
* show in the column header, or a CustomCell object to further configure the
|
|
370
|
-
* column.
|
|
371
|
-
* @category Prop
|
|
372
|
-
* @since v4.1.0
|
|
373
|
-
*/
|
|
374
|
-
readonly customCells?:
|
|
375
|
-
| Ids
|
|
376
|
-
| {[cellId: Id]: string | CustomCell<NoSchemas, Id, Id>};
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* RelationshipInHtmlTableProps props are used for components that will render
|
|
381
|
-
* the contents of the two Tables linked by a Relationship as an HTML table,
|
|
382
|
-
* such as the RelationshipInHtmlTable component.
|
|
383
|
-
*
|
|
384
|
-
* Note the use of dotted 'tableId.cellId' string pairs when specifying custom
|
|
385
|
-
* rendering for the cells in this table, since Cells from both the
|
|
386
|
-
* relationship's 'local' and 'remote' Table objects can be rendered and need to
|
|
387
|
-
* be distinguished.
|
|
388
|
-
* @category Props
|
|
389
|
-
* @since v4.1.0
|
|
390
|
-
*/
|
|
391
|
-
export type RelationshipInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
392
|
-
/**
|
|
393
|
-
* The Id of the relationship in the Relationships object for which the
|
|
394
|
-
* relationship Table Rows will be rendered.
|
|
395
|
-
* @category Prop
|
|
396
|
-
* @since v4.1.0
|
|
397
|
-
*/
|
|
398
|
-
readonly relationshipId: Id;
|
|
399
|
-
/**
|
|
400
|
-
* The Relationships object to be accessed: omit for the default context
|
|
401
|
-
* Relationships object, provide an Id for a named context Relationships
|
|
402
|
-
* object, or provide an explicit reference.
|
|
403
|
-
* @category Prop
|
|
404
|
-
* @since v4.1.0
|
|
405
|
-
*/
|
|
406
|
-
readonly relationships?: RelationshipsOrRelationshipsId<Schemas>;
|
|
407
|
-
/**
|
|
408
|
-
* Whether the Cells should be editable. This affects the default CellView
|
|
409
|
-
* component (to use the EditableCellView component instead) but of course
|
|
410
|
-
* will not affect custom Cell components if you have set them.
|
|
411
|
-
* @category Prop
|
|
412
|
-
* @since v4.1.0
|
|
413
|
-
*/
|
|
414
|
-
readonly editable?: boolean;
|
|
415
|
-
/**
|
|
416
|
-
* An optional list of dotted 'tableId.cellId' string pairs to use for
|
|
417
|
-
* rendering a prescribed set of the relationship Tables' Cells in a given
|
|
418
|
-
* order. This can also be an object with the desired 'tableId.cellId' string
|
|
419
|
-
* pairs as keys, and with a value that can either be a string label to show
|
|
420
|
-
* in the column header, or a CustomCell object to further configure the
|
|
421
|
-
* column.
|
|
422
|
-
* @category Prop
|
|
423
|
-
* @since v4.1.0
|
|
424
|
-
*/
|
|
425
|
-
readonly customCells?:
|
|
426
|
-
| Ids
|
|
427
|
-
| {[cellId: Id]: string | CustomCell<NoSchemas, Id, Id>};
|
|
428
|
-
};
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* ResultTableInHtmlTableProps props are used for components that will render a
|
|
432
|
-
* ResultTable in an HTML table, such as the ResultTableInHtmlTable component.
|
|
433
|
-
* @category Props
|
|
434
|
-
* @since v4.1.0
|
|
435
|
-
*/
|
|
436
|
-
export type ResultTableInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
437
|
-
/**
|
|
438
|
-
* The Id of the query in the Queries object for which the ResultTable will be
|
|
439
|
-
* rendered.
|
|
440
|
-
* @category Prop
|
|
441
|
-
* @since v4.1.0
|
|
442
|
-
*/
|
|
443
|
-
readonly queryId: Id;
|
|
444
|
-
/**
|
|
445
|
-
* The Queries object to be accessed: omit for the default context Queries
|
|
446
|
-
* object, provide an Id for a named context Queries object, or provide an
|
|
447
|
-
* explicit reference.
|
|
448
|
-
* @category Prop
|
|
449
|
-
* @since v4.1.0
|
|
450
|
-
*/
|
|
451
|
-
readonly queries?: QueriesOrQueriesId<Schemas>;
|
|
452
|
-
/**
|
|
453
|
-
* An optional list of Cell Ids to use for rendering a prescribed set of the
|
|
454
|
-
* ResultTable's Cells in a given order. This can also be an object with the
|
|
455
|
-
* desired Cell Ids as keys, and with a value that can either be a string
|
|
456
|
-
* label to show in the column header, or a ResultCustomCell object to further
|
|
457
|
-
* configure the column.
|
|
458
|
-
* @category Prop
|
|
459
|
-
* @since v4.1.0
|
|
460
|
-
*/
|
|
461
|
-
readonly customCells?:
|
|
462
|
-
| Ids
|
|
463
|
-
| {[cellId: Id]: string | CustomResultCell<Schemas>};
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* ResultSortedTableInHtmlTableProps props are used for components that will
|
|
468
|
-
* render a sorted Table in an HTML table, such as the SortedTableInHtmlTable
|
|
469
|
-
* component.
|
|
470
|
-
* @category Props
|
|
471
|
-
* @since v4.1.0
|
|
472
|
-
*/
|
|
473
|
-
export type ResultSortedTableInHtmlTableProps<Schemas extends OptionalSchemas> =
|
|
474
|
-
{
|
|
475
|
-
/**
|
|
476
|
-
* The Id of the query in the Queries object for which the ResultTable will be
|
|
477
|
-
* rendered.
|
|
478
|
-
* @category Prop
|
|
479
|
-
* @since v4.1.0
|
|
480
|
-
*/
|
|
481
|
-
readonly queryId: Id;
|
|
482
|
-
/**
|
|
483
|
-
* The Id of the Cell whose values are used for the sorting. If omitted, the
|
|
484
|
-
* view will sort the Row Id itself.
|
|
485
|
-
* @category Prop
|
|
486
|
-
* @since v4.1.0
|
|
487
|
-
*/
|
|
488
|
-
readonly cellId?: Id;
|
|
489
|
-
/**
|
|
490
|
-
* Whether the sorting should be in descending order.
|
|
491
|
-
* @category Prop
|
|
492
|
-
* @since v4.1.0
|
|
493
|
-
*/
|
|
494
|
-
readonly descending?: boolean;
|
|
495
|
-
/**
|
|
496
|
-
* The number of Row Ids to skip for pagination purposes.
|
|
497
|
-
* @category Prop
|
|
498
|
-
* @since v4.1.0
|
|
499
|
-
*/
|
|
500
|
-
readonly offset?: number;
|
|
501
|
-
/**
|
|
502
|
-
* The maximum number of Row Ids to return.
|
|
503
|
-
* @category Prop
|
|
504
|
-
* @since v4.1.0
|
|
505
|
-
*/
|
|
506
|
-
readonly limit?: number;
|
|
507
|
-
/**
|
|
508
|
-
* The Queries object to be accessed: omit for the default context Queries
|
|
509
|
-
* object, provide an Id for a named context Queries object, or provide an
|
|
510
|
-
* explicit reference.
|
|
511
|
-
* @category Prop
|
|
512
|
-
* @since v4.1.0
|
|
513
|
-
*/
|
|
514
|
-
readonly queries?: QueriesOrQueriesId<Schemas>;
|
|
515
|
-
/**
|
|
516
|
-
* An optional list of Cell Ids to use for rendering a prescribed set of the
|
|
517
|
-
* ResultTable's Cells in a given order. This can also be an object with the
|
|
518
|
-
* desired Cell Ids as keys, and with a value that can either be a string
|
|
519
|
-
* label to show in the column header, or a ResultCustomCell object to further
|
|
520
|
-
* configure the column.
|
|
521
|
-
* @category Prop
|
|
522
|
-
* @since v4.1.0
|
|
523
|
-
*/
|
|
524
|
-
readonly customCells?:
|
|
525
|
-
| Ids
|
|
526
|
-
| {[cellId: Id]: string | CustomResultCell<Schemas>};
|
|
527
|
-
/**
|
|
528
|
-
* Whether the table should be interactive such that clicking a header changes
|
|
529
|
-
* the sorting and/or direction.
|
|
530
|
-
* @category Prop
|
|
531
|
-
* @since v4.1.0
|
|
532
|
-
*/
|
|
533
|
-
readonly sortOnClick?: boolean;
|
|
534
|
-
/**
|
|
535
|
-
* Either `true` to show the default SortedTablePaginator for the ResultTable,
|
|
536
|
-
* or provide your own paginator component that takes
|
|
537
|
-
* SortedTablePaginatorProps.
|
|
538
|
-
* @category Prop
|
|
539
|
-
* @since v4.1.0
|
|
540
|
-
*/
|
|
541
|
-
readonly paginator?: boolean | ComponentType<SortedTablePaginatorProps>;
|
|
542
|
-
/**
|
|
543
|
-
* A function that is called whenever the sorting or pagination of the
|
|
544
|
-
* ResultTable is changed by the user, invoked with the sorted Cell Id,
|
|
545
|
-
* whether descending or not, and the offset of the pagination.
|
|
546
|
-
* @category Prop
|
|
547
|
-
* @since v4.1.0
|
|
548
|
-
*/
|
|
549
|
-
readonly onChange?: (
|
|
550
|
-
sortAndOffset: [
|
|
551
|
-
cellId: Id | undefined,
|
|
552
|
-
descending: boolean,
|
|
553
|
-
offset: number,
|
|
554
|
-
],
|
|
555
|
-
) => void;
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* SortedTablePaginatorProps props are used for components that will be used as
|
|
560
|
-
* a table paginator, such as the SortedTablePaginator component.
|
|
561
|
-
* @category Props
|
|
562
|
-
* @since v4.1.0
|
|
563
|
-
*/
|
|
564
|
-
export type SortedTablePaginatorProps = {
|
|
565
|
-
/**
|
|
566
|
-
* An event that will fire when the offset is updated, called with the new
|
|
567
|
-
* offset.
|
|
568
|
-
* @category Prop
|
|
569
|
-
* @since v4.1.0
|
|
570
|
-
*/
|
|
571
|
-
readonly onChange: (offset: number) => void;
|
|
572
|
-
/**
|
|
573
|
-
* The number of Row Ids to skip for pagination.
|
|
574
|
-
* @category Prop
|
|
575
|
-
* @since v4.1.0
|
|
576
|
-
*/
|
|
577
|
-
readonly offset?: number;
|
|
578
|
-
/**
|
|
579
|
-
* The maximum number of Row Ids being returned.
|
|
580
|
-
* @category Prop
|
|
581
|
-
* @since v4.1.0
|
|
582
|
-
*/
|
|
583
|
-
readonly limit?: number;
|
|
584
|
-
/**
|
|
585
|
-
* The total number of Row Ids in the paginated table.
|
|
586
|
-
* @category Prop
|
|
587
|
-
* @since v4.1.0
|
|
588
|
-
*/
|
|
589
|
-
readonly total: number;
|
|
590
|
-
/**
|
|
591
|
-
* A noun to use in the pagination label for a single row, defaulting to
|
|
592
|
-
* 'row'.
|
|
593
|
-
* @category Prop
|
|
594
|
-
* @since v4.1.0
|
|
595
|
-
*/
|
|
596
|
-
readonly singular?: string;
|
|
597
|
-
/**
|
|
598
|
-
* A noun to use in the pagination label for multiple rows, defaulting to the
|
|
599
|
-
* value of the singular noun suffixed with the letter 's'.
|
|
600
|
-
* @category Prop
|
|
601
|
-
* @since v4.1.0
|
|
602
|
-
*/
|
|
603
|
-
readonly plural?: string;
|
|
604
|
-
};
|
|
605
|
-
|
|
606
|
-
/**
|
|
607
|
-
* InspectorProps props are used to configure the Inspector component.
|
|
608
|
-
* @category Props
|
|
609
|
-
* @since v5.0.0
|
|
610
|
-
*/
|
|
611
|
-
export type InspectorProps = {
|
|
612
|
-
/**
|
|
613
|
-
* An optional string to indicate where you want the inspector to first
|
|
614
|
-
* appear.
|
|
615
|
-
* @category Prop
|
|
616
|
-
* @since v5.0.0
|
|
617
|
-
*/
|
|
618
|
-
readonly position?: 'top' | 'right' | 'bottom' | 'left' | 'full';
|
|
619
|
-
/**
|
|
620
|
-
* An optional boolean to indicate whether the inspector should start in the
|
|
621
|
-
* opened state.
|
|
622
|
-
* @category Prop
|
|
623
|
-
* @since v5.0.0
|
|
624
|
-
*/
|
|
625
|
-
readonly open?: boolean;
|
|
626
|
-
};
|
|
627
|
-
|
|
628
|
-
export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
629
|
-
/**
|
|
630
|
-
* The TableInHtmlTable component renders the contents of a single Table in a
|
|
631
|
-
* Store as an HTML <table> element, and registers a listener so that any
|
|
632
|
-
* changes to that result will cause a re-render.
|
|
633
|
-
*
|
|
634
|
-
* See the <TableInHtmlTable /> demo for this component in action.
|
|
635
|
-
*
|
|
636
|
-
* The component's props identify which Table to render based on Table Id, and
|
|
637
|
-
* Store (which is either the default context Store, a named context Store, or
|
|
638
|
-
* by explicit reference).
|
|
639
|
-
*
|
|
640
|
-
* This component renders a Table by iterating over its Row objects. By default
|
|
641
|
-
* the Cells are in turn rendered with the CellView component, but you can
|
|
642
|
-
* override this behavior by providing a `component` for each Cell in the
|
|
643
|
-
* `customCells` prop. You can pass additional props to that custom component
|
|
644
|
-
* with the `getComponentProps` callback. See the CustomCell type for more
|
|
645
|
-
* details.
|
|
646
|
-
*
|
|
647
|
-
* This component uses the useRowIds hook under the covers, which means that any
|
|
648
|
-
* changes to the structure of the Table will cause a re-render.
|
|
649
|
-
*
|
|
650
|
-
* You can use the `headerRow` and `idColumn` props to control whether the Ids
|
|
651
|
-
* appear in a <th> element at the top of the table, and the start of each row.
|
|
652
|
-
* @param props The props for this component.
|
|
653
|
-
* @returns A rendering of the Table in a <table> element.
|
|
654
|
-
* @example
|
|
655
|
-
* This example creates a Provider context into which a default Store is
|
|
656
|
-
* provided. The TableInHtmlTable component within it then renders the Table in
|
|
657
|
-
* a <table> element with a CSS class.
|
|
658
|
-
*
|
|
659
|
-
* ```jsx
|
|
660
|
-
* import React from 'react';
|
|
661
|
-
* import {createRoot} from 'react-dom/client';
|
|
662
|
-
* import {createStore} from 'tinybase';
|
|
663
|
-
* import {Provider} from 'tinybase/ui-react';
|
|
664
|
-
* import {TableInHtmlTable} from 'tinybase/ui-react-dom';
|
|
665
|
-
*
|
|
666
|
-
* const App = ({store}) => (
|
|
667
|
-
* <Provider store={store}>
|
|
668
|
-
* <Pane />
|
|
669
|
-
* </Provider>
|
|
670
|
-
* );
|
|
671
|
-
* const Pane = () => <TableInHtmlTable tableId="pets" className="table" />;
|
|
672
|
-
*
|
|
673
|
-
* const store = createStore().setTable('pets', {
|
|
674
|
-
* fido: {species: 'dog'},
|
|
675
|
-
* felix: {species: 'cat'},
|
|
676
|
-
* });
|
|
677
|
-
* const app = document.createElement('div');
|
|
678
|
-
* createRoot(app).render(<App store={store} />); // !act
|
|
679
|
-
* console.log(app.innerHTML);
|
|
680
|
-
* // ->
|
|
681
|
-
* `
|
|
682
|
-
* <table class="table">
|
|
683
|
-
* <thead>
|
|
684
|
-
* <tr>
|
|
685
|
-
* <th>Id</th>
|
|
686
|
-
* <th>species</th>
|
|
687
|
-
* </tr>
|
|
688
|
-
* </thead>
|
|
689
|
-
* <tbody>
|
|
690
|
-
* <tr>
|
|
691
|
-
* <th>fido</th>
|
|
692
|
-
* <td>dog</td>
|
|
693
|
-
* </tr>
|
|
694
|
-
* <tr>
|
|
695
|
-
* <th>felix</th>
|
|
696
|
-
* <td>cat</td>
|
|
697
|
-
* </tr>
|
|
698
|
-
* </tbody>
|
|
699
|
-
* </table>
|
|
700
|
-
* `;
|
|
701
|
-
* ```
|
|
702
|
-
* @example
|
|
703
|
-
* This example creates a Provider context into which a default Store is
|
|
704
|
-
* provided. The TableInHtmlTable component within it then renders the Table
|
|
705
|
-
* with a custom component and a custom props callback for the `species` Cell.
|
|
706
|
-
* The header row at the top of the table and the Id column at the start of each
|
|
707
|
-
* row is removed.
|
|
708
|
-
*
|
|
709
|
-
* ```jsx
|
|
710
|
-
* import React from 'react';
|
|
711
|
-
* import {createRoot} from 'react-dom/client';
|
|
712
|
-
* import {createStore} from 'tinybase';
|
|
713
|
-
* import {CellView, Provider} from 'tinybase/ui-react';
|
|
714
|
-
* import {TableInHtmlTable} from 'tinybase/ui-react-dom';
|
|
715
|
-
*
|
|
716
|
-
* const App = ({store}) => (
|
|
717
|
-
* <Provider store={store}>
|
|
718
|
-
* <Pane />
|
|
719
|
-
* </Provider>
|
|
720
|
-
* );
|
|
721
|
-
* const Pane = () => (
|
|
722
|
-
* <TableInHtmlTable
|
|
723
|
-
* tableId="pets"
|
|
724
|
-
* customCells={customCells}
|
|
725
|
-
* headerRow={false}
|
|
726
|
-
* idColumn={false}
|
|
727
|
-
* />
|
|
728
|
-
* );
|
|
729
|
-
*
|
|
730
|
-
* const FormattedCellView = ({tableId, rowId, cellId, bold}) => (
|
|
731
|
-
* <>
|
|
732
|
-
* {bold ? <b>{rowId}</b> : rowId}:
|
|
733
|
-
* <CellView tableId={tableId} rowId={rowId} cellId={cellId} />
|
|
734
|
-
* </>
|
|
735
|
-
* );
|
|
736
|
-
* const customCells = {
|
|
737
|
-
* species: {
|
|
738
|
-
* component: FormattedCellView,
|
|
739
|
-
* getComponentProps: (rowId) => ({bold: rowId == 'fido'}),
|
|
740
|
-
* },
|
|
741
|
-
* };
|
|
742
|
-
*
|
|
743
|
-
* const store = createStore().setTable('pets', {
|
|
744
|
-
* fido: {species: 'dog'},
|
|
745
|
-
* felix: {species: 'cat'},
|
|
746
|
-
* });
|
|
747
|
-
* const app = document.createElement('div');
|
|
748
|
-
* createRoot(app).render(<App store={store} />); // !act
|
|
749
|
-
* console.log(app.innerHTML);
|
|
750
|
-
* // ->
|
|
751
|
-
* `
|
|
752
|
-
* <table>
|
|
753
|
-
* <tbody>
|
|
754
|
-
* <tr>
|
|
755
|
-
* <td><b>fido</b>:dog</td>
|
|
756
|
-
* </tr>
|
|
757
|
-
* <tr>
|
|
758
|
-
* <td>felix:cat</td>
|
|
759
|
-
* </tr>
|
|
760
|
-
* </tbody>
|
|
761
|
-
* </table>
|
|
762
|
-
* `;
|
|
763
|
-
* ```
|
|
764
|
-
* @category Store components
|
|
765
|
-
* @since v4.1.0
|
|
766
|
-
*/
|
|
767
|
-
TableInHtmlTable: (
|
|
768
|
-
props: TableInHtmlTableProps<Schemas> & HtmlTableProps,
|
|
769
|
-
) => ComponentReturnType;
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
* The SortedTableInHtmlTable component renders the contents of a single sorted
|
|
773
|
-
* Table in a Store, as an HTML <table> element, and registers a listener so
|
|
774
|
-
* that any changes to that result will cause a re-render.
|
|
775
|
-
*
|
|
776
|
-
* See the <SortedTableInHtmlTable /> demo for this component in action.
|
|
777
|
-
*
|
|
778
|
-
* The component's props identify which Table to render based on Table Id, and
|
|
779
|
-
* Store (which is either the default context Store, a named context Store, or
|
|
780
|
-
* by explicit reference). It also takes a Cell Id to sort by and a boolean to
|
|
781
|
-
* indicate that the sorting should be in descending order. The `offset` and
|
|
782
|
-
* `limit` props are used to paginate results, but default to `0` and
|
|
783
|
-
* `undefined` to return all available Row Ids if not specified.
|
|
784
|
-
*
|
|
785
|
-
* This component renders a ResultTable by iterating over its Row objects, in
|
|
786
|
-
* the order dictated by the sort parameters. By default the Cells are in turn
|
|
787
|
-
* rendered with the CellView component, but you can override this behavior by
|
|
788
|
-
* providing a `component` for each Cell in the `customCells` prop. You can pass
|
|
789
|
-
* additional props to that custom component with the `getComponentProps`
|
|
790
|
-
* callback. See the CustomCell type for more details.
|
|
791
|
-
*
|
|
792
|
-
* This component uses the useSortedRowIds hook under the covers, which means
|
|
793
|
-
* that any changes to the structure or sorting of the Table will cause a
|
|
794
|
-
* re-render.
|
|
795
|
-
*
|
|
796
|
-
* You can use the `headerRow` and `idColumn` props to control whether the Ids
|
|
797
|
-
* appear in a <th> element at the top of the table, and the start of each row.
|
|
798
|
-
*
|
|
799
|
-
* The `sortOnClick` prop makes the table's sorting interactive such that the
|
|
800
|
-
* user can click on a column heading to sort by that column. The style classes
|
|
801
|
-
* `sorted` and `ascending` (or `descending`) are added so that you can provide
|
|
802
|
-
* hints to the user how the sorting is being applied.
|
|
803
|
-
*
|
|
804
|
-
* Provide a paginator component for the Table with the `paginator` prop. Set to
|
|
805
|
-
* `true` to use the default SortedTablePaginator, or provide your own component
|
|
806
|
-
* that accepts SortedTablePaginatorProps.
|
|
807
|
-
*
|
|
808
|
-
* Finally, the `onChange` prop lets you listen to a user's changes to the
|
|
809
|
-
* Table's sorting or pagination.
|
|
810
|
-
* @param props The props for this component.
|
|
811
|
-
* @returns A rendering of the Table in a <table> element.
|
|
812
|
-
* @example
|
|
813
|
-
* This example creates a Provider context into which a default Store is
|
|
814
|
-
* provided. The SortedTableInHtmlTable component within it then renders the
|
|
815
|
-
* Table in a <table> element with a CSS class.
|
|
816
|
-
*
|
|
817
|
-
* ```jsx
|
|
818
|
-
* import React from 'react';
|
|
819
|
-
* import {createRoot} from 'react-dom/client';
|
|
820
|
-
* import {createStore} from 'tinybase';
|
|
821
|
-
* import {Provider} from 'tinybase/ui-react';
|
|
822
|
-
* import {SortedTableInHtmlTable} from 'tinybase/ui-react-dom';
|
|
823
|
-
*
|
|
824
|
-
* const App = ({store}) => (
|
|
825
|
-
* <Provider store={store}>
|
|
826
|
-
* <Pane />
|
|
827
|
-
* </Provider>
|
|
828
|
-
* );
|
|
829
|
-
* const Pane = () => (
|
|
830
|
-
* <SortedTableInHtmlTable
|
|
831
|
-
* tableId="pets"
|
|
832
|
-
* cellId="species"
|
|
833
|
-
* className="table"
|
|
834
|
-
* />
|
|
835
|
-
* );
|
|
836
|
-
*
|
|
837
|
-
* const store = createStore().setTables({
|
|
838
|
-
* pets: {
|
|
839
|
-
* fido: {species: 'dog'},
|
|
840
|
-
* felix: {species: 'cat'},
|
|
841
|
-
* },
|
|
842
|
-
* });
|
|
843
|
-
* const app = document.createElement('div');
|
|
844
|
-
* createRoot(app).render(<App store={store} />); // !act
|
|
845
|
-
* console.log(app.innerHTML);
|
|
846
|
-
* // ->
|
|
847
|
-
* `
|
|
848
|
-
* <table class="table">
|
|
849
|
-
* <thead>
|
|
850
|
-
* <tr>
|
|
851
|
-
* <th>Id</th>
|
|
852
|
-
* <th class="sorted ascending">↑ species</th>
|
|
853
|
-
* </tr>
|
|
854
|
-
* </thead>
|
|
855
|
-
* <tbody>
|
|
856
|
-
* <tr>
|
|
857
|
-
* <th>felix</th>
|
|
858
|
-
* <td>cat</td>
|
|
859
|
-
* </tr>
|
|
860
|
-
* <tr>
|
|
861
|
-
* <th>fido</th>
|
|
862
|
-
* <td>dog</td>
|
|
863
|
-
* </tr>
|
|
864
|
-
* </tbody>
|
|
865
|
-
* </table>
|
|
866
|
-
* `;
|
|
867
|
-
* ```
|
|
868
|
-
* @example
|
|
869
|
-
* This example creates a Provider context into which a default Store is
|
|
870
|
-
* provided. The SortedTableInHtmlTable component within it then renders the
|
|
871
|
-
* Table with a custom component and a custom props callback for the `species`
|
|
872
|
-
* Cell. The header row at the top of the table and the Id column at the start
|
|
873
|
-
* of each row is removed.
|
|
874
|
-
*
|
|
875
|
-
* ```jsx
|
|
876
|
-
* import React from 'react';
|
|
877
|
-
* import {createRoot} from 'react-dom/client';
|
|
878
|
-
* import {createStore} from 'tinybase';
|
|
879
|
-
* import {CellView, Provider} from 'tinybase/ui-react';
|
|
880
|
-
* import {SortedTableInHtmlTable} from 'tinybase/ui-react-dom';
|
|
881
|
-
*
|
|
882
|
-
* const App = ({store}) => (
|
|
883
|
-
* <Provider store={store}>
|
|
884
|
-
* <Pane />
|
|
885
|
-
* </Provider>
|
|
886
|
-
* );
|
|
887
|
-
*
|
|
888
|
-
* const Pane = () => (
|
|
889
|
-
* <SortedTableInHtmlTable
|
|
890
|
-
* tableId="pets"
|
|
891
|
-
* cellId="species"
|
|
892
|
-
* customCells={customCells}
|
|
893
|
-
* headerRow={false}
|
|
894
|
-
* idColumn={false}
|
|
895
|
-
* />
|
|
896
|
-
* );
|
|
897
|
-
*
|
|
898
|
-
* const FormattedCellView = ({tableId, rowId, cellId, bold}) => (
|
|
899
|
-
* <>
|
|
900
|
-
* {bold ? <b>{rowId}</b> : rowId}:
|
|
901
|
-
* <CellView tableId={tableId} rowId={rowId} cellId={cellId} />
|
|
902
|
-
* </>
|
|
903
|
-
* );
|
|
904
|
-
* const customCells = {
|
|
905
|
-
* species: {
|
|
906
|
-
* component: FormattedCellView,
|
|
907
|
-
* getComponentProps: (rowId) => ({bold: rowId == 'fido'}),
|
|
908
|
-
* },
|
|
909
|
-
* };
|
|
910
|
-
*
|
|
911
|
-
* const store = createStore().setTables({
|
|
912
|
-
* pets: {
|
|
913
|
-
* fido: {species: 'dog'},
|
|
914
|
-
* felix: {species: 'cat'},
|
|
915
|
-
* },
|
|
916
|
-
* });
|
|
917
|
-
* const app = document.createElement('div');
|
|
918
|
-
* createRoot(app).render(<App store={store} />); // !act
|
|
919
|
-
* console.log(app.innerHTML);
|
|
920
|
-
* // ->
|
|
921
|
-
* `
|
|
922
|
-
* <table>
|
|
923
|
-
* <tbody>
|
|
924
|
-
* <tr>
|
|
925
|
-
* <td>felix:cat</td>
|
|
926
|
-
* </tr>
|
|
927
|
-
* <tr>
|
|
928
|
-
* <td><b>fido</b>:dog</td>
|
|
929
|
-
* </tr>
|
|
930
|
-
* </tbody>
|
|
931
|
-
* </table>
|
|
932
|
-
* `;
|
|
933
|
-
* ```
|
|
934
|
-
* @category Store components
|
|
935
|
-
* @since v4.1.0
|
|
936
|
-
*/
|
|
937
|
-
SortedTableInHtmlTable: (
|
|
938
|
-
props: SortedTableInHtmlTableProps<Schemas> & HtmlTableProps,
|
|
939
|
-
) => ComponentReturnType;
|
|
940
|
-
|
|
941
|
-
/**
|
|
942
|
-
* The ValuesInHtmlTable component renders the keyed value contents of a Store
|
|
943
|
-
* as an HTML <table> element, and registers a listener so that any changes to
|
|
944
|
-
* that result will cause a re-render.
|
|
945
|
-
*
|
|
946
|
-
* See the <ValuesInHtmlTable /> demo for this component in action.
|
|
947
|
-
*
|
|
948
|
-
* The component's props identify which Row to render based on Table Id, Row Id,
|
|
949
|
-
* and Store (which is either the default context Store, a named context Store,
|
|
950
|
-
* or an explicit reference).
|
|
951
|
-
*
|
|
952
|
-
* This component renders a Store by iterating over its Value objects. By
|
|
953
|
-
* default the Values are in turn rendered with the ValueView component, but you
|
|
954
|
-
* can override this behavior by providing a `valueComponent` prop, a custom
|
|
955
|
-
* component of your own that will render a Value based on ValueProps. You can
|
|
956
|
-
* also pass additional props to your custom component with the
|
|
957
|
-
* `getValueComponentProps` callback prop.
|
|
958
|
-
*
|
|
959
|
-
* This component uses the useValueIds hook under the covers, which means that
|
|
960
|
-
* any changes to the structure of the Values in the Store will cause a
|
|
961
|
-
* re-render.
|
|
962
|
-
*
|
|
963
|
-
* You can use the `headerRow` and `idColumn` props to control whether labels
|
|
964
|
-
* and Ids appear in a <th> element at the top of the table, and the start of
|
|
965
|
-
* each row.
|
|
966
|
-
* @param props The props for this component.
|
|
967
|
-
* @returns A rendering of the Values in a <table> element.
|
|
968
|
-
* @example
|
|
969
|
-
* This example creates a Provider context into which a default Store is
|
|
970
|
-
* provided. The ValuesInHtmlTable component within it then renders the Values
|
|
971
|
-
* in a <table> element with a CSS class.
|
|
972
|
-
*
|
|
973
|
-
* ```jsx
|
|
974
|
-
* import React from 'react';
|
|
975
|
-
* import {createRoot} from 'react-dom/client';
|
|
976
|
-
* import {createStore} from 'tinybase';
|
|
977
|
-
* import {Provider} from 'tinybase/ui-react';
|
|
978
|
-
* import {ValuesInHtmlTable} from 'tinybase/ui-react-dom';
|
|
979
|
-
*
|
|
980
|
-
* const App = ({store}) => (
|
|
981
|
-
* <Provider store={store}>
|
|
982
|
-
* <Pane />
|
|
983
|
-
* </Provider>
|
|
984
|
-
* );
|
|
985
|
-
* const Pane = () => <ValuesInHtmlTable className="values" />;
|
|
986
|
-
*
|
|
987
|
-
* const store = createStore().setValues({open: true, employees: 3});
|
|
988
|
-
* const app = document.createElement('div');
|
|
989
|
-
* createRoot(app).render(<App store={store} />); // !act
|
|
990
|
-
* console.log(app.innerHTML);
|
|
991
|
-
* // ->
|
|
992
|
-
* `
|
|
993
|
-
* <table class="values">
|
|
994
|
-
* <thead>
|
|
995
|
-
* <tr>
|
|
996
|
-
* <th>Id</th>
|
|
997
|
-
* <th>Value</th>
|
|
998
|
-
* </tr>
|
|
999
|
-
* </thead>
|
|
1000
|
-
* <tbody>
|
|
1001
|
-
* <tr>
|
|
1002
|
-
* <th>open</th>
|
|
1003
|
-
* <td>true</td>
|
|
1004
|
-
* </tr>
|
|
1005
|
-
* <tr>
|
|
1006
|
-
* <th>employees</th>
|
|
1007
|
-
* <td>3</td>
|
|
1008
|
-
* </tr>
|
|
1009
|
-
* </tbody>
|
|
1010
|
-
* </table>
|
|
1011
|
-
* `;
|
|
1012
|
-
* ```
|
|
1013
|
-
* @example
|
|
1014
|
-
* This example creates a Provider context into which a default Store is
|
|
1015
|
-
* provided. The ValuesInHtmlTable component within it then renders the Row
|
|
1016
|
-
* with a custom Cell component and a custom props callback. The header row at
|
|
1017
|
-
* the top of the table and the Id column at the start of each row is removed.
|
|
1018
|
-
*
|
|
1019
|
-
* ```jsx
|
|
1020
|
-
* import React from 'react';
|
|
1021
|
-
* import {createRoot} from 'react-dom/client';
|
|
1022
|
-
* import {createStore} from 'tinybase';
|
|
1023
|
-
* import {Provider, ValueView} from 'tinybase/ui-react';
|
|
1024
|
-
* import {ValuesInHtmlTable} from 'tinybase/ui-react-dom';
|
|
1025
|
-
*
|
|
1026
|
-
* const App = ({store}) => (
|
|
1027
|
-
* <Provider store={store}>
|
|
1028
|
-
* <Pane />
|
|
1029
|
-
* </Provider>
|
|
1030
|
-
* );
|
|
1031
|
-
* const getBoldProp = (valueId) => ({bold: valueId == 'open'});
|
|
1032
|
-
* const Pane = () => (
|
|
1033
|
-
* <ValuesInHtmlTable
|
|
1034
|
-
* valueComponent={FormattedValueView}
|
|
1035
|
-
* getValueComponentProps={getBoldProp}
|
|
1036
|
-
* headerRow={false}
|
|
1037
|
-
* idColumn={false}
|
|
1038
|
-
* />
|
|
1039
|
-
* );
|
|
1040
|
-
* const FormattedValueView = ({valueId, bold}) => (
|
|
1041
|
-
* <>
|
|
1042
|
-
* {bold ? <b>{valueId}</b> : valueId}
|
|
1043
|
-
* {': '}
|
|
1044
|
-
* <ValueView valueId={valueId} />
|
|
1045
|
-
* </>
|
|
1046
|
-
* );
|
|
1047
|
-
*
|
|
1048
|
-
* const store = createStore().setValues({open: true, employees: 3});
|
|
1049
|
-
* const app = document.createElement('div');
|
|
1050
|
-
* createRoot(app).render(<App store={store} />); // !act
|
|
1051
|
-
* console.log(app.innerHTML);
|
|
1052
|
-
* // ->
|
|
1053
|
-
* `
|
|
1054
|
-
* <table>
|
|
1055
|
-
* <tbody>
|
|
1056
|
-
* <tr><td><b>open</b>: true</td></tr>
|
|
1057
|
-
* <tr><td>employees: 3</td></tr>
|
|
1058
|
-
* </tbody>
|
|
1059
|
-
* </table>
|
|
1060
|
-
* `;
|
|
1061
|
-
* ```
|
|
1062
|
-
* @category Store components
|
|
1063
|
-
* @since v4.1.0
|
|
1064
|
-
*/
|
|
1065
|
-
ValuesInHtmlTable: (
|
|
1066
|
-
props: ValuesInHtmlTableProps<Schemas> & HtmlTableProps,
|
|
1067
|
-
) => ComponentReturnType;
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* The SliceInHtmlTable component renders the contents of a Slice as an HTML
|
|
1071
|
-
* <table> element, and registers a listener so that any changes to that result
|
|
1072
|
-
* will cause a re-render.
|
|
1073
|
-
*
|
|
1074
|
-
* See the <SliceInHtmlTable /> demo for this component in action.
|
|
1075
|
-
*
|
|
1076
|
-
* The component's props identify which Slice to render based on Index Id, Slice
|
|
1077
|
-
* Id, and Indexes object (which is either the default context Indexes object, a
|
|
1078
|
-
* named context Indexes object, or an explicit reference).
|
|
1079
|
-
*
|
|
1080
|
-
* This component renders a Slice by iterating over its Row objects. By default
|
|
1081
|
-
* the Cells are in turn rendered with the CellView component, but you can
|
|
1082
|
-
* override this behavior by providing a `component` for each Cell in the
|
|
1083
|
-
* `customCells` prop. You can pass additional props to that custom component
|
|
1084
|
-
* with the `getComponentProps` callback. See the CustomCell type for more
|
|
1085
|
-
* details.
|
|
1086
|
-
*
|
|
1087
|
-
* This component uses the useSliceRowIds hook under the covers, which means
|
|
1088
|
-
* that any changes to the structure of the Slice will cause a re-render.
|
|
1089
|
-
*
|
|
1090
|
-
* You can use the `headerRow` and `idColumn` props to control whether labels
|
|
1091
|
-
* and Ids appear in a <th> element at the top of the table, and the start of
|
|
1092
|
-
* each row.
|
|
1093
|
-
* @param props The props for this component.
|
|
1094
|
-
* @returns A rendering of the Slice in a <table> element.
|
|
1095
|
-
* @example
|
|
1096
|
-
* This example creates a Provider context into which a default Indexes object
|
|
1097
|
-
* is provided. The SliceInHtmlTable component within it then renders the Slice
|
|
1098
|
-
* in a <table> element with a CSS class.
|
|
1099
|
-
*
|
|
1100
|
-
* ```jsx
|
|
1101
|
-
* import React from 'react';
|
|
1102
|
-
* import {createRoot} from 'react-dom/client';
|
|
1103
|
-
* import {createIndexes, createStore} from 'tinybase';
|
|
1104
|
-
* import {Provider} from 'tinybase/ui-react';
|
|
1105
|
-
* import {SliceInHtmlTable} from 'tinybase/ui-react-dom';
|
|
1106
|
-
*
|
|
1107
|
-
* const App = ({indexes}) => (
|
|
1108
|
-
* <Provider indexes={indexes}>
|
|
1109
|
-
* <Pane />
|
|
1110
|
-
* </Provider>
|
|
1111
|
-
* );
|
|
1112
|
-
* const Pane = () => (
|
|
1113
|
-
* <SliceInHtmlTable indexId="bySpecies" sliceId="dog" className="slice" />
|
|
1114
|
-
* );
|
|
1115
|
-
*
|
|
1116
|
-
* const store = createStore().setTable('pets', {
|
|
1117
|
-
* fido: {species: 'dog'},
|
|
1118
|
-
* felix: {species: 'cat'},
|
|
1119
|
-
* cujo: {species: 'dog'},
|
|
1120
|
-
* });
|
|
1121
|
-
* const indexes = createIndexes(store);
|
|
1122
|
-
* indexes.setIndexDefinition('bySpecies', 'pets', 'species');
|
|
1123
|
-
*
|
|
1124
|
-
* const app = document.createElement('div');
|
|
1125
|
-
* createRoot(app).render(<App indexes={indexes} />); // !act
|
|
1126
|
-
* console.log(app.innerHTML);
|
|
1127
|
-
* // ->
|
|
1128
|
-
* `
|
|
1129
|
-
* <table class="slice">
|
|
1130
|
-
* <thead>
|
|
1131
|
-
* <tr>
|
|
1132
|
-
* <th>Id</th>
|
|
1133
|
-
* <th>species</th>
|
|
1134
|
-
* </tr>
|
|
1135
|
-
* </thead>
|
|
1136
|
-
* <tbody>
|
|
1137
|
-
* <tr>
|
|
1138
|
-
* <th>fido</th>
|
|
1139
|
-
* <td>dog</td>
|
|
1140
|
-
* </tr>
|
|
1141
|
-
* <tr>
|
|
1142
|
-
* <th>cujo</th>
|
|
1143
|
-
* <td>dog</td>
|
|
1144
|
-
* </tr>
|
|
1145
|
-
* </tbody>
|
|
1146
|
-
* </table>
|
|
1147
|
-
* `;
|
|
1148
|
-
* ```
|
|
1149
|
-
* @example
|
|
1150
|
-
* This example creates a Provider context into which a default Indexes object
|
|
1151
|
-
* is provided. The SliceInHtmlTable component within it then renders the Slice
|
|
1152
|
-
* with a custom component and a custom props callback for the `species` Cell.
|
|
1153
|
-
* The header row at the top of the table and the Id column at the start of each
|
|
1154
|
-
* row is removed.
|
|
1155
|
-
*
|
|
1156
|
-
* ```jsx
|
|
1157
|
-
* import React from 'react';
|
|
1158
|
-
* import {createRoot} from 'react-dom/client';
|
|
1159
|
-
* import {createIndexes, createStore} from 'tinybase';
|
|
1160
|
-
* import {CellView, Provider} from 'tinybase/ui-react';
|
|
1161
|
-
* import {SliceInHtmlTable} from 'tinybase/ui-react-dom';
|
|
1162
|
-
*
|
|
1163
|
-
* const App = ({indexes}) => (
|
|
1164
|
-
* <Provider indexes={indexes}>
|
|
1165
|
-
* <Pane />
|
|
1166
|
-
* </Provider>
|
|
1167
|
-
* );
|
|
1168
|
-
* const Pane = () => (
|
|
1169
|
-
* <SliceInHtmlTable
|
|
1170
|
-
* indexId="bySpecies"
|
|
1171
|
-
* sliceId="dog"
|
|
1172
|
-
* customCells={customCells}
|
|
1173
|
-
* headerRow={false}
|
|
1174
|
-
* idColumn={false}
|
|
1175
|
-
* />
|
|
1176
|
-
* );
|
|
1177
|
-
*
|
|
1178
|
-
* const FormattedCellView = ({tableId, rowId, cellId, bold}) => (
|
|
1179
|
-
* <>
|
|
1180
|
-
* {bold ? <b>{rowId}</b> : rowId}:
|
|
1181
|
-
* <CellView tableId={tableId} rowId={rowId} cellId={cellId} />
|
|
1182
|
-
* </>
|
|
1183
|
-
* );
|
|
1184
|
-
* const customCells = {
|
|
1185
|
-
* species: {
|
|
1186
|
-
* component: FormattedCellView,
|
|
1187
|
-
* getComponentProps: (rowId) => ({bold: rowId == 'fido'}),
|
|
1188
|
-
* },
|
|
1189
|
-
* };
|
|
1190
|
-
*
|
|
1191
|
-
* const store = createStore().setTable('pets', {
|
|
1192
|
-
* fido: {species: 'dog', color: 'brown'},
|
|
1193
|
-
* felix: {species: 'cat'},
|
|
1194
|
-
* cujo: {species: 'dog'},
|
|
1195
|
-
* });
|
|
1196
|
-
* const indexes = createIndexes(store);
|
|
1197
|
-
* indexes.setIndexDefinition('bySpecies', 'pets', 'species');
|
|
1198
|
-
*
|
|
1199
|
-
* const app = document.createElement('div');
|
|
1200
|
-
* createRoot(app).render(<App indexes={indexes} />); // !act
|
|
1201
|
-
* console.log(app.innerHTML);
|
|
1202
|
-
* // ->
|
|
1203
|
-
* `
|
|
1204
|
-
* <table>
|
|
1205
|
-
* <tbody>
|
|
1206
|
-
* <tr>
|
|
1207
|
-
* <td><b>fido</b>:</td>
|
|
1208
|
-
* </tr>
|
|
1209
|
-
* <tr>
|
|
1210
|
-
* <td>cujo:</td>
|
|
1211
|
-
* </tr>
|
|
1212
|
-
* </tbody>
|
|
1213
|
-
* </table>
|
|
1214
|
-
* `;
|
|
1215
|
-
* ```
|
|
1216
|
-
* @category Indexes components
|
|
1217
|
-
* @since v4.1.0
|
|
1218
|
-
*/
|
|
1219
|
-
SliceInHtmlTable: (
|
|
1220
|
-
props: SliceInHtmlTableProps<Schemas> & HtmlTableProps,
|
|
1221
|
-
) => ComponentReturnType;
|
|
1222
|
-
|
|
1223
|
-
/**
|
|
1224
|
-
* The RelationshipInHtmlTable component renders the contents of the two Tables
|
|
1225
|
-
* linked by a Relationship as an HTML <table> element, and registers a listener
|
|
1226
|
-
* so that any changes to that result will cause a re-render.
|
|
1227
|
-
*
|
|
1228
|
-
* See the <RelationshipInHtmlTable /> demo for this component in action.
|
|
1229
|
-
*
|
|
1230
|
-
* The component's props identify which Relationship to render based on
|
|
1231
|
-
* Relationship Id and Relationships object (which is either the default context
|
|
1232
|
-
* Relationships object, a named context Relationships object, or an explicit
|
|
1233
|
-
* reference).
|
|
1234
|
-
*
|
|
1235
|
-
* This component renders the two Table objects by iterating over their related
|
|
1236
|
-
* Row objects. By default the Cells are in turn rendered with the CellView
|
|
1237
|
-
* component, but you can override this behavior by providing a `component` for
|
|
1238
|
-
* each Cell in the `customCells` prop. You can pass additional props to that
|
|
1239
|
-
* custom component with the `getComponentProps` callback. See the CustomCell
|
|
1240
|
-
* type for more details.
|
|
1241
|
-
*
|
|
1242
|
-
* Note the use of dotted 'tableId.cellId' string pairs when specifying custom
|
|
1243
|
-
* rendering for the cells in this table, since Cells from both the
|
|
1244
|
-
* relationship's 'local' and 'remote' Table objects can be rendered and need to
|
|
1245
|
-
* be distinguished.
|
|
1246
|
-
*
|
|
1247
|
-
* This component uses the useRowIds and useRemoteRowId hooks under the covers,
|
|
1248
|
-
* which means that any changes to the structure of either Table resulting in a
|
|
1249
|
-
* change to the relationship will cause a re-render.
|
|
1250
|
-
*
|
|
1251
|
-
* You can use the `headerRow` and `idColumn` props to control whether labels
|
|
1252
|
-
* and Ids appear in a <th> element at the top of the table, and the start of
|
|
1253
|
-
* each row.
|
|
1254
|
-
* @param props The props for this component.
|
|
1255
|
-
* @returns A rendering of the two Tables linked by a Relationship in a
|
|
1256
|
-
* <table> element.
|
|
1257
|
-
* @example
|
|
1258
|
-
* This example creates a Provider context into which a default Relationships
|
|
1259
|
-
* object is provided. The RelationshipInHtmlTable component within it then
|
|
1260
|
-
* renders the two Tables linked by a relationship in a <table> element with a
|
|
1261
|
-
* CSS class. Note the dotted pairs that are used as column headings.
|
|
1262
|
-
*
|
|
1263
|
-
* ```jsx
|
|
1264
|
-
* import React from 'react';
|
|
1265
|
-
* import {createRoot} from 'react-dom/client';
|
|
1266
|
-
* import {createRelationships, createStore} from 'tinybase';
|
|
1267
|
-
* import {Provider} from 'tinybase/ui-react';
|
|
1268
|
-
* import {RelationshipInHtmlTable} from 'tinybase/ui-react-dom';
|
|
1269
|
-
*
|
|
1270
|
-
* const App = ({relationships}) => (
|
|
1271
|
-
* <Provider relationships={relationships}>
|
|
1272
|
-
* <Pane />
|
|
1273
|
-
* </Provider>
|
|
1274
|
-
* );
|
|
1275
|
-
* const Pane = () => (
|
|
1276
|
-
* <RelationshipInHtmlTable
|
|
1277
|
-
* relationshipId="petSpecies"
|
|
1278
|
-
* className="relationship"
|
|
1279
|
-
* />
|
|
1280
|
-
* );
|
|
1281
|
-
*
|
|
1282
|
-
* const relationships = createRelationships(
|
|
1283
|
-
* createStore()
|
|
1284
|
-
* .setTable('pets', {fido: {species: 'dog'}, cujo: {species: 'dog'}})
|
|
1285
|
-
* .setTable('species', {wolf: {price: 10}, dog: {price: 5}}),
|
|
1286
|
-
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
1287
|
-
*
|
|
1288
|
-
* const app = document.createElement('div');
|
|
1289
|
-
* const root = createRoot(app);
|
|
1290
|
-
* root.render(<App relationships={relationships} />); // !act
|
|
1291
|
-
* console.log(app.innerHTML);
|
|
1292
|
-
* // ->
|
|
1293
|
-
* `
|
|
1294
|
-
* <table class="relationship">
|
|
1295
|
-
* <thead>
|
|
1296
|
-
* <tr>
|
|
1297
|
-
* <th>pets.Id</th>
|
|
1298
|
-
* <th>species.Id</th>
|
|
1299
|
-
* <th>pets.species</th>
|
|
1300
|
-
* <th>species.price</th>
|
|
1301
|
-
* </tr>
|
|
1302
|
-
* </thead>
|
|
1303
|
-
* <tbody>
|
|
1304
|
-
* <tr>
|
|
1305
|
-
* <th>fido</th>
|
|
1306
|
-
* <th>dog</th>
|
|
1307
|
-
* <td>dog</td>
|
|
1308
|
-
* <td>5</td>
|
|
1309
|
-
* </tr>
|
|
1310
|
-
* <tr>
|
|
1311
|
-
* <th>cujo</th>
|
|
1312
|
-
* <th>dog</th>
|
|
1313
|
-
* <td>dog</td>
|
|
1314
|
-
* <td>5</td>
|
|
1315
|
-
* </tr>
|
|
1316
|
-
* </tbody>
|
|
1317
|
-
* </table>
|
|
1318
|
-
* `;
|
|
1319
|
-
* ```
|
|
1320
|
-
* @example
|
|
1321
|
-
* This example creates a Provider context into which a default Relationships
|
|
1322
|
-
* object is provided. The RelationshipInHtmlTable component within it then
|
|
1323
|
-
* renders the two Tables linked by a relationship with a custom component and a
|
|
1324
|
-
* custom props callback for the `species` Cell. The header row at the top of
|
|
1325
|
-
* the table and the Id column at the start of each row is removed.
|
|
1326
|
-
*
|
|
1327
|
-
* ```jsx
|
|
1328
|
-
* import React from 'react';
|
|
1329
|
-
* import {createRoot} from 'react-dom/client';
|
|
1330
|
-
* import {createRelationships, createStore} from 'tinybase';
|
|
1331
|
-
* import {CellView, Provider} from 'tinybase/ui-react';
|
|
1332
|
-
* import {RelationshipInHtmlTable} from 'tinybase/ui-react-dom';
|
|
1333
|
-
*
|
|
1334
|
-
* const App = ({relationships}) => (
|
|
1335
|
-
* <Provider relationships={relationships}>
|
|
1336
|
-
* <Pane />
|
|
1337
|
-
* </Provider>
|
|
1338
|
-
* );
|
|
1339
|
-
* const Pane = () => (
|
|
1340
|
-
* <RelationshipInHtmlTable
|
|
1341
|
-
* relationshipId="petSpecies"
|
|
1342
|
-
* customCells={customCells}
|
|
1343
|
-
* idColumn={false}
|
|
1344
|
-
* headerRow={false}
|
|
1345
|
-
* />
|
|
1346
|
-
* );
|
|
1347
|
-
*
|
|
1348
|
-
* const FormattedCellView = ({tableId, rowId, cellId, store, bold}) => (
|
|
1349
|
-
* <>
|
|
1350
|
-
* {bold ? <b>{rowId}</b> : rowId}:
|
|
1351
|
-
* <CellView
|
|
1352
|
-
* tableId={tableId}
|
|
1353
|
-
* rowId={rowId}
|
|
1354
|
-
* cellId={cellId}
|
|
1355
|
-
* store={store}
|
|
1356
|
-
* />
|
|
1357
|
-
* </>
|
|
1358
|
-
* );
|
|
1359
|
-
* const customCells = {
|
|
1360
|
-
* 'species.price': {
|
|
1361
|
-
* component: FormattedCellView,
|
|
1362
|
-
* getComponentProps: (rowId) => ({bold: rowId == 'dog'}),
|
|
1363
|
-
* },
|
|
1364
|
-
* };
|
|
1365
|
-
*
|
|
1366
|
-
* const relationships = createRelationships(
|
|
1367
|
-
* createStore()
|
|
1368
|
-
* .setTable('pets', {fido: {species: 'dog'}, cujo: {species: 'wolf'}})
|
|
1369
|
-
* .setTable('species', {wolf: {price: 10}, dog: {price: 5}}),
|
|
1370
|
-
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
1371
|
-
*
|
|
1372
|
-
* const app = document.createElement('div');
|
|
1373
|
-
* const root = createRoot(app);
|
|
1374
|
-
* root.render(<App relationships={relationships} />); // !act
|
|
1375
|
-
* console.log(app.innerHTML);
|
|
1376
|
-
* // ->
|
|
1377
|
-
* `
|
|
1378
|
-
* <table>
|
|
1379
|
-
* <tbody>
|
|
1380
|
-
* <tr>
|
|
1381
|
-
* <td><b>dog</b>:5</td>
|
|
1382
|
-
* </tr>
|
|
1383
|
-
* <tr>
|
|
1384
|
-
* <td>wolf:10</td>
|
|
1385
|
-
* </tr>
|
|
1386
|
-
* </tbody>
|
|
1387
|
-
* </table>
|
|
1388
|
-
* `;
|
|
1389
|
-
* ```
|
|
1390
|
-
* @category Relationships components
|
|
1391
|
-
* @since v4.1.0
|
|
1392
|
-
*/
|
|
1393
|
-
RelationshipInHtmlTable: (
|
|
1394
|
-
props: RelationshipInHtmlTableProps<Schemas> & HtmlTableProps,
|
|
1395
|
-
) => ComponentReturnType;
|
|
1396
|
-
|
|
1397
|
-
/**
|
|
1398
|
-
* The ResultTableInHtmlTable component renders the contents of a single query's
|
|
1399
|
-
* ResultTable in a Queries object as an HTML <table> element, and registers a
|
|
1400
|
-
* listener so that any changes to that result will cause a re-render.
|
|
1401
|
-
*
|
|
1402
|
-
* See the <ResultTableInHtmlTable /> demo for this component in action.
|
|
1403
|
-
*
|
|
1404
|
-
* The component's props identify which ResultTable to render based on query Id,
|
|
1405
|
-
* and Queries object (which is either the default context Queries object, a
|
|
1406
|
-
* named context Queries object, or by explicit reference).
|
|
1407
|
-
*
|
|
1408
|
-
* This component renders a ResultTable by iterating over its Row objects. By
|
|
1409
|
-
* default the Cells are in turn rendered with the CellView component, but you
|
|
1410
|
-
* can override this behavior by providing a `component` for each Cell in the
|
|
1411
|
-
* `customCells` prop. You can pass additional props to that custom component
|
|
1412
|
-
* with the `getComponentProps` callback. See the ResultCustomCell type for more
|
|
1413
|
-
* details.
|
|
1414
|
-
*
|
|
1415
|
-
* This component uses the useRowIds hook under the covers, which means that any
|
|
1416
|
-
* changes to the structure of the Table will cause a re-render.
|
|
1417
|
-
*
|
|
1418
|
-
* You can use the `headerRow` and `idColumn` props to control whether the Ids
|
|
1419
|
-
* appear in a <th> element at the top of the table, and the start of each row.
|
|
1420
|
-
* @param props The props for this component.
|
|
1421
|
-
* @returns A rendering of the ResultTable in a <table> element.
|
|
1422
|
-
* @example
|
|
1423
|
-
* This example creates a Provider context into which a default Queries object
|
|
1424
|
-
* is provided. The ResultTableInHtmlTable component within it then renders the
|
|
1425
|
-
* ResultTable in a <table> element with a CSS class.
|
|
1426
|
-
*
|
|
1427
|
-
* ```jsx
|
|
1428
|
-
* import React from 'react';
|
|
1429
|
-
* import {createRoot} from 'react-dom/client';
|
|
1430
|
-
* import {createQueries, createStore} from 'tinybase';
|
|
1431
|
-
* import {Provider} from 'tinybase/ui-react';
|
|
1432
|
-
* import {ResultTableInHtmlTable} from 'tinybase/ui-react-dom';
|
|
1433
|
-
*
|
|
1434
|
-
* const App = ({queries}) => (
|
|
1435
|
-
* <Provider queries={queries}>
|
|
1436
|
-
* <Pane />
|
|
1437
|
-
* </Provider>
|
|
1438
|
-
* );
|
|
1439
|
-
* const Pane = () => (
|
|
1440
|
-
* <ResultTableInHtmlTable queryId="petColors" className="table" />
|
|
1441
|
-
* );
|
|
1442
|
-
*
|
|
1443
|
-
* const queries = createQueries(
|
|
1444
|
-
* createStore().setTable('pets', {
|
|
1445
|
-
* fido: {species: 'dog', color: 'brown'},
|
|
1446
|
-
* felix: {species: 'cat', color: 'black'},
|
|
1447
|
-
* }),
|
|
1448
|
-
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
1449
|
-
* const app = document.createElement('div');
|
|
1450
|
-
* createRoot(app).render(<App queries={queries} />); // !act
|
|
1451
|
-
* console.log(app.innerHTML);
|
|
1452
|
-
* // ->
|
|
1453
|
-
* `
|
|
1454
|
-
* <table class="table">
|
|
1455
|
-
* <thead>
|
|
1456
|
-
* <tr>
|
|
1457
|
-
* <th>Id</th>
|
|
1458
|
-
* <th>color</th>
|
|
1459
|
-
* </tr>
|
|
1460
|
-
* </thead>
|
|
1461
|
-
* <tbody>
|
|
1462
|
-
* <tr>
|
|
1463
|
-
* <th>fido</th>
|
|
1464
|
-
* <td>brown</td>
|
|
1465
|
-
* </tr>
|
|
1466
|
-
* <tr>
|
|
1467
|
-
* <th>felix</th>
|
|
1468
|
-
* <td>black</td>
|
|
1469
|
-
* </tr>
|
|
1470
|
-
* </tbody>
|
|
1471
|
-
* </table>
|
|
1472
|
-
* `;
|
|
1473
|
-
* ```
|
|
1474
|
-
* @example
|
|
1475
|
-
* This example creates a Provider context into which a default Queries object
|
|
1476
|
-
* is provided. The ResultTableInHtmlTable component within it then renders the
|
|
1477
|
-
* ResultTable with a custom component and a custom props callback for the
|
|
1478
|
-
* `color` Cell. The header row at the top of the table and the Id column at
|
|
1479
|
-
* the start of each row is removed.
|
|
1480
|
-
*
|
|
1481
|
-
* ```jsx
|
|
1482
|
-
* import React from 'react';
|
|
1483
|
-
* import {createRoot} from 'react-dom/client';
|
|
1484
|
-
* import {createQueries, createStore} from 'tinybase';
|
|
1485
|
-
* import {Provider, ResultCellView} from 'tinybase/ui-react';
|
|
1486
|
-
* import {ResultTableInHtmlTable} from 'tinybase/ui-react-dom';
|
|
1487
|
-
*
|
|
1488
|
-
* const App = ({queries}) => (
|
|
1489
|
-
* <Provider queries={queries}>
|
|
1490
|
-
* <Pane />
|
|
1491
|
-
* </Provider>
|
|
1492
|
-
* );
|
|
1493
|
-
* const Pane = () => (
|
|
1494
|
-
* <ResultTableInHtmlTable
|
|
1495
|
-
* queryId="petColors"
|
|
1496
|
-
* customCells={customCells}
|
|
1497
|
-
* headerRow={false}
|
|
1498
|
-
* idColumn={false}
|
|
1499
|
-
* />
|
|
1500
|
-
* );
|
|
1501
|
-
*
|
|
1502
|
-
* const FormattedResultCellView = ({queryId, rowId, cellId, bold}) => (
|
|
1503
|
-
* <>
|
|
1504
|
-
* {bold ? <b>{rowId}</b> : rowId}:
|
|
1505
|
-
* <ResultCellView queryId={queryId} rowId={rowId} cellId={cellId} />
|
|
1506
|
-
* </>
|
|
1507
|
-
* );
|
|
1508
|
-
* const customCells = {
|
|
1509
|
-
* color: {
|
|
1510
|
-
* component: FormattedResultCellView,
|
|
1511
|
-
* getComponentProps: (rowId) => ({bold: rowId == 'fido'}),
|
|
1512
|
-
* },
|
|
1513
|
-
* };
|
|
1514
|
-
*
|
|
1515
|
-
* const queries = createQueries(
|
|
1516
|
-
* createStore().setTable('pets', {
|
|
1517
|
-
* fido: {species: 'dog', color: 'brown'},
|
|
1518
|
-
* felix: {species: 'cat', color: 'black'},
|
|
1519
|
-
* }),
|
|
1520
|
-
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
1521
|
-
* const app = document.createElement('div');
|
|
1522
|
-
* createRoot(app).render(<App queries={queries} />); // !act
|
|
1523
|
-
* console.log(app.innerHTML);
|
|
1524
|
-
* // ->
|
|
1525
|
-
* `
|
|
1526
|
-
* <table>
|
|
1527
|
-
* <tbody>
|
|
1528
|
-
* <tr>
|
|
1529
|
-
* <td><b>fido</b>:brown</td>
|
|
1530
|
-
* </tr>
|
|
1531
|
-
* <tr>
|
|
1532
|
-
* <td>felix:black</td>
|
|
1533
|
-
* </tr>
|
|
1534
|
-
* </tbody>
|
|
1535
|
-
* </table>
|
|
1536
|
-
* `;
|
|
1537
|
-
* ```
|
|
1538
|
-
* @category Queries components
|
|
1539
|
-
* @since v4.1.0
|
|
1540
|
-
*/
|
|
1541
|
-
ResultTableInHtmlTable: (
|
|
1542
|
-
props: ResultTableInHtmlTableProps<Schemas> & HtmlTableProps,
|
|
1543
|
-
) => ComponentReturnType;
|
|
1544
|
-
|
|
1545
|
-
/**
|
|
1546
|
-
* The SortedTableInHtmlTable component renders the contents of a single query's
|
|
1547
|
-
* sorted ResultTable in a Queries object as an HTML <table> element, and
|
|
1548
|
-
* registers a listener so that any changes to that result will cause a
|
|
1549
|
-
* re-render.
|
|
1550
|
-
*
|
|
1551
|
-
* See the <ResultSortedTableInHtmlTable /> demo for this component in action.
|
|
1552
|
-
*
|
|
1553
|
-
* The component's props identify which ResultTable to render based on query Id,
|
|
1554
|
-
* and Queries object (which is either the default context Queries object, a
|
|
1555
|
-
* named context Queries object, or by explicit reference). It also takes a Cell
|
|
1556
|
-
* Id to sort by and a boolean to indicate that the sorting should be in
|
|
1557
|
-
* descending order. The `offset` and `limit` props are used to paginate
|
|
1558
|
-
* results, but default to `0` and `undefined` to return all available Row Ids
|
|
1559
|
-
* if not specified.
|
|
1560
|
-
*
|
|
1561
|
-
* This component renders a ResultTable by iterating over its Row objects, in
|
|
1562
|
-
* the order dictated by the sort parameters. By default the Cells are in turn
|
|
1563
|
-
* rendered with the CellView component, but you can override this behavior by
|
|
1564
|
-
* providing a `component` for each Cell in the `customCells` prop. You can pass
|
|
1565
|
-
* additional props to that custom component with the `getComponentProps`
|
|
1566
|
-
* callback. See the ResultCustomCell type for more details.
|
|
1567
|
-
*
|
|
1568
|
-
* This component uses the useSortedRowIds hook under the covers, which means
|
|
1569
|
-
* that any changes to the structure or sorting of the ResultTable will cause a
|
|
1570
|
-
* re-render.
|
|
1571
|
-
*
|
|
1572
|
-
* You can use the `headerRow` and `idColumn` props to control whether the Ids
|
|
1573
|
-
* appear in a <th> element at the top of the table, and the start of each row.
|
|
1574
|
-
*
|
|
1575
|
-
* The `sortOnClick` prop makes the table's sorting interactive such that the
|
|
1576
|
-
* user can click on a column heading to sort by that column. The style classes
|
|
1577
|
-
* `sorted` and `ascending` (or `descending`) are added so that you can provide
|
|
1578
|
-
* hints to the user how the sorting is being applied.
|
|
1579
|
-
*
|
|
1580
|
-
* Provide a paginator component for the ResultTable with the `paginator` prop.
|
|
1581
|
-
* Set to `true` to use the default SortedTablePaginator, or provide your own
|
|
1582
|
-
* component that accepts SortedTablePaginatorProps.
|
|
1583
|
-
*
|
|
1584
|
-
* Finally, the `onChange` prop lets you listen to a user's changes to the
|
|
1585
|
-
* ResultTable's sorting or pagination.
|
|
1586
|
-
* @param props The props for this component.
|
|
1587
|
-
* @returns A rendering of the ResultTable in a <table> element.
|
|
1588
|
-
* @example
|
|
1589
|
-
* This example creates a Provider context into which a default Queries object
|
|
1590
|
-
* is provided. The ResultSortedTableInHtmlTable component within it then
|
|
1591
|
-
* renders the ResultTable in a <table> element with a CSS class.
|
|
1592
|
-
*
|
|
1593
|
-
* ```jsx
|
|
1594
|
-
* import React from 'react';
|
|
1595
|
-
* import {createRoot} from 'react-dom/client';
|
|
1596
|
-
* import {createQueries, createStore} from 'tinybase';
|
|
1597
|
-
* import {Provider} from 'tinybase/ui-react';
|
|
1598
|
-
* import {ResultSortedTableInHtmlTable} from 'tinybase/ui-react-dom';
|
|
1599
|
-
*
|
|
1600
|
-
* const App = ({queries}) => (
|
|
1601
|
-
* <Provider queries={queries}>
|
|
1602
|
-
* <Pane />
|
|
1603
|
-
* </Provider>
|
|
1604
|
-
* );
|
|
1605
|
-
* const Pane = () => (
|
|
1606
|
-
* <ResultSortedTableInHtmlTable
|
|
1607
|
-
* queryId="petColors"
|
|
1608
|
-
* cellId="color"
|
|
1609
|
-
* className="table"
|
|
1610
|
-
* />
|
|
1611
|
-
* );
|
|
1612
|
-
*
|
|
1613
|
-
* const queries = createQueries(
|
|
1614
|
-
* createStore().setTable('pets', {
|
|
1615
|
-
* fido: {species: 'dog', color: 'brown'},
|
|
1616
|
-
* felix: {species: 'cat', color: 'black'},
|
|
1617
|
-
* }),
|
|
1618
|
-
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
1619
|
-
* const app = document.createElement('div');
|
|
1620
|
-
* createRoot(app).render(<App queries={queries} />); // !act
|
|
1621
|
-
* console.log(app.innerHTML);
|
|
1622
|
-
* // ->
|
|
1623
|
-
* `
|
|
1624
|
-
* <table class="table">
|
|
1625
|
-
* <thead>
|
|
1626
|
-
* <tr>
|
|
1627
|
-
* <th>Id</th>
|
|
1628
|
-
* <th class="sorted ascending">↑ color</th>
|
|
1629
|
-
* </tr>
|
|
1630
|
-
* </thead>
|
|
1631
|
-
* <tbody>
|
|
1632
|
-
* <tr>
|
|
1633
|
-
* <th>felix</th>
|
|
1634
|
-
* <td>black</td>
|
|
1635
|
-
* </tr>
|
|
1636
|
-
* <tr>
|
|
1637
|
-
* <th>fido</th>
|
|
1638
|
-
* <td>brown</td>
|
|
1639
|
-
* </tr>
|
|
1640
|
-
* </tbody>
|
|
1641
|
-
* </table>
|
|
1642
|
-
* `;
|
|
1643
|
-
* ```
|
|
1644
|
-
* @example
|
|
1645
|
-
* This example creates a Provider context into which a default Queries object
|
|
1646
|
-
* is provided. The ResultSortedTableInHtmlTable component within it then
|
|
1647
|
-
* renders the ResultTable with a custom component and a custom props callback
|
|
1648
|
-
* for the `color` Cell. The header row at the top of the table and the Id
|
|
1649
|
-
* column at the start of each row is removed.
|
|
1650
|
-
*
|
|
1651
|
-
* ```jsx
|
|
1652
|
-
* import React from 'react';
|
|
1653
|
-
* import {createRoot} from 'react-dom/client';
|
|
1654
|
-
* import {createQueries, createStore} from 'tinybase';
|
|
1655
|
-
* import {Provider, ResultCellView} from 'tinybase/ui-react';
|
|
1656
|
-
* import {ResultSortedTableInHtmlTable} from 'tinybase/ui-react-dom';
|
|
1657
|
-
*
|
|
1658
|
-
* const App = ({queries}) => (
|
|
1659
|
-
* <Provider queries={queries}>
|
|
1660
|
-
* <Pane />
|
|
1661
|
-
* </Provider>
|
|
1662
|
-
* );
|
|
1663
|
-
*
|
|
1664
|
-
* const Pane = () => (
|
|
1665
|
-
* <ResultSortedTableInHtmlTable
|
|
1666
|
-
* queryId="petColors"
|
|
1667
|
-
* cellId="color"
|
|
1668
|
-
* customCells={customCells}
|
|
1669
|
-
* headerRow={false}
|
|
1670
|
-
* idColumn={false}
|
|
1671
|
-
* />
|
|
1672
|
-
* );
|
|
1673
|
-
*
|
|
1674
|
-
* const FormattedResultCellView = ({queryId, rowId, cellId, bold}) => (
|
|
1675
|
-
* <>
|
|
1676
|
-
* {bold ? <b>{rowId}</b> : rowId}:
|
|
1677
|
-
* <ResultCellView queryId={queryId} rowId={rowId} cellId={cellId} />
|
|
1678
|
-
* </>
|
|
1679
|
-
* );
|
|
1680
|
-
* const customCells = {
|
|
1681
|
-
* color: {
|
|
1682
|
-
* component: FormattedResultCellView,
|
|
1683
|
-
* getComponentProps: (rowId) => ({bold: rowId == 'fido'}),
|
|
1684
|
-
* },
|
|
1685
|
-
* };
|
|
1686
|
-
*
|
|
1687
|
-
* const queries = createQueries(
|
|
1688
|
-
* createStore().setTable('pets', {
|
|
1689
|
-
* fido: {species: 'dog', color: 'brown'},
|
|
1690
|
-
* felix: {species: 'cat', color: 'black'},
|
|
1691
|
-
* }),
|
|
1692
|
-
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
1693
|
-
* const app = document.createElement('div');
|
|
1694
|
-
* createRoot(app).render(<App queries={queries} />); // !act
|
|
1695
|
-
* console.log(app.innerHTML);
|
|
1696
|
-
* // ->
|
|
1697
|
-
* `
|
|
1698
|
-
* <table>
|
|
1699
|
-
* <tbody>
|
|
1700
|
-
* <tr>
|
|
1701
|
-
* <td>felix:black</td>
|
|
1702
|
-
* </tr>
|
|
1703
|
-
* <tr>
|
|
1704
|
-
* <td><b>fido</b>:brown</td>
|
|
1705
|
-
* </tr>
|
|
1706
|
-
* </tbody>
|
|
1707
|
-
* </table>
|
|
1708
|
-
* `;
|
|
1709
|
-
* ```
|
|
1710
|
-
* @category Queries components
|
|
1711
|
-
* @since v4.1.0
|
|
15
|
+
* InspectorProps props are used to configure the Inspector component.
|
|
16
|
+
* @category Props
|
|
17
|
+
* @since v5.0.0
|
|
1712
18
|
*/
|
|
1713
|
-
|
|
1714
|
-
props: ResultSortedTableInHtmlTableProps<Schemas> & HtmlTableProps,
|
|
1715
|
-
) => ComponentReturnType;
|
|
1716
|
-
|
|
19
|
+
export type InspectorProps = {
|
|
1717
20
|
/**
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
* The component's props identify which Cell to render based on Table Id, Row
|
|
1725
|
-
* Id, Cell Id, and Store (which is either the default context Store, a named
|
|
1726
|
-
* context Store, or an explicit reference).
|
|
1727
|
-
*
|
|
1728
|
-
* A Cell contains a string, number, or boolean, so the value is rendered in an
|
|
1729
|
-
* appropriate <input> tag and a button lets the user change type, if possible.
|
|
1730
|
-
*
|
|
1731
|
-
* Set the `showType` prop to false to remove the ability for the user to see or
|
|
1732
|
-
* change the Cell type. They will also not be able to change the type if there
|
|
1733
|
-
* is a TablesSchema applied to the Store.
|
|
1734
|
-
*
|
|
1735
|
-
* This component uses the useCell hook under the covers, which means that any
|
|
1736
|
-
* changes to the specified Cell outside of this component will cause a
|
|
1737
|
-
* re-render.
|
|
1738
|
-
*
|
|
1739
|
-
* You can provide a custom className prop which well be used on the root of the
|
|
1740
|
-
* resulting element. If omitted the element's class will be `editableCell`. The
|
|
1741
|
-
* debugIds prop has no effect on this component.
|
|
1742
|
-
* @param props The props for this component.
|
|
1743
|
-
* @returns An editable rendering of the Cell.
|
|
1744
|
-
* @example
|
|
1745
|
-
* This example creates a Provider context into which a default Store is
|
|
1746
|
-
* provided. The EditableCellView component within it then renders an editable
|
|
1747
|
-
* Cell.
|
|
1748
|
-
*
|
|
1749
|
-
* ```jsx
|
|
1750
|
-
* import React from 'react';
|
|
1751
|
-
* import {createRoot} from 'react-dom/client';
|
|
1752
|
-
* import {createStore} from 'tinybase';
|
|
1753
|
-
* import {Provider} from 'tinybase/ui-react';
|
|
1754
|
-
* import {EditableCellView} from 'tinybase/ui-react-dom';
|
|
1755
|
-
*
|
|
1756
|
-
* const App = ({store}) => (
|
|
1757
|
-
* <Provider store={store}>
|
|
1758
|
-
* <Pane />
|
|
1759
|
-
* </Provider>
|
|
1760
|
-
* );
|
|
1761
|
-
* const Pane = () => (
|
|
1762
|
-
* <EditableCellView tableId="pets" rowId="fido" cellId="color" />
|
|
1763
|
-
* );
|
|
1764
|
-
*
|
|
1765
|
-
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
1766
|
-
* const app = document.createElement('div');
|
|
1767
|
-
* createRoot(app).render(<App store={store} />); // !act
|
|
1768
|
-
* console.log(app.innerHTML);
|
|
1769
|
-
* // ->
|
|
1770
|
-
* `
|
|
1771
|
-
* <div class="editableCell">
|
|
1772
|
-
* <button class="string">string</button>
|
|
1773
|
-
* <input value="brown">
|
|
1774
|
-
* </div>
|
|
1775
|
-
* `;
|
|
1776
|
-
* ```
|
|
1777
|
-
* @category Store components
|
|
1778
|
-
* @since v4.1.0
|
|
1779
|
-
*/
|
|
1780
|
-
EditableCellView: (
|
|
1781
|
-
props: CellProps<Schemas> & {
|
|
1782
|
-
className?: string;
|
|
1783
|
-
readonly showType?: boolean;
|
|
1784
|
-
},
|
|
1785
|
-
) => ComponentReturnType;
|
|
1786
|
-
|
|
21
|
+
* An optional string to indicate where you want the inspector to first
|
|
22
|
+
* appear.
|
|
23
|
+
* @category Prop
|
|
24
|
+
* @since v5.0.0
|
|
25
|
+
*/
|
|
26
|
+
readonly position?: 'top' | 'right' | 'bottom' | 'left' | 'full';
|
|
1787
27
|
/**
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
* The component's props identify which Value to render based on Table Id, Row
|
|
1795
|
-
* Id, Value Id, and Store (which is either the default context Store, a named
|
|
1796
|
-
* context Store, or an explicit reference).
|
|
1797
|
-
*
|
|
1798
|
-
* A Value contains a string, number, or boolean, so the value is rendered in an
|
|
1799
|
-
* appropriate <input> tag and a button lets the user change type, if possible.
|
|
1800
|
-
*
|
|
1801
|
-
* Set the `showType` prop to false to remove the ability for the user to see or
|
|
1802
|
-
* change the Value type. They will also not be able to change the type if there
|
|
1803
|
-
* is a ValuesSchema applied to the Store.
|
|
1804
|
-
*
|
|
1805
|
-
* This component uses the useValue hook under the covers, which means that any
|
|
1806
|
-
* changes to the specified Value outside of this component will cause a
|
|
1807
|
-
* re-render.
|
|
1808
|
-
*
|
|
1809
|
-
* You can provide a custom className prop which well be used on the root of the
|
|
1810
|
-
* resulting element. If omitted the element's class will be `editableValue`.
|
|
1811
|
-
* The debugIds prop has no effect on this component.
|
|
1812
|
-
* @param props The props for this component.
|
|
1813
|
-
* @returns An editable rendering of the Value.
|
|
1814
|
-
* @example
|
|
1815
|
-
* This example creates a Provider context into which a default Store is
|
|
1816
|
-
* provided. The EditableValueView component within it then renders an editable
|
|
1817
|
-
* Value.
|
|
1818
|
-
*
|
|
1819
|
-
* ```jsx
|
|
1820
|
-
* import React from 'react';
|
|
1821
|
-
* import {createRoot} from 'react-dom/client';
|
|
1822
|
-
* import {createStore} from 'tinybase';
|
|
1823
|
-
* import {Provider} from 'tinybase/ui-react';
|
|
1824
|
-
* import {EditableValueView} from 'tinybase/ui-react-dom';
|
|
1825
|
-
*
|
|
1826
|
-
* const App = ({store}) => (
|
|
1827
|
-
* <Provider store={store}>
|
|
1828
|
-
* <Pane />
|
|
1829
|
-
* </Provider>
|
|
1830
|
-
* );
|
|
1831
|
-
* const Pane = () => <EditableValueView valueId="employees" />;
|
|
1832
|
-
*
|
|
1833
|
-
* const store = createStore().setValue('employees', 3);
|
|
1834
|
-
* const app = document.createElement('div');
|
|
1835
|
-
* createRoot(app).render(<App store={store} />); // !act
|
|
1836
|
-
* console.log(app.innerHTML);
|
|
1837
|
-
* // ->
|
|
1838
|
-
* `
|
|
1839
|
-
* <div class="editableValue">
|
|
1840
|
-
* <button class="number">number</button>
|
|
1841
|
-
* <input type="number" value="3">
|
|
1842
|
-
* </div>
|
|
1843
|
-
* `;
|
|
1844
|
-
* ```
|
|
1845
|
-
* @category Store components
|
|
1846
|
-
* @since v4.1.0
|
|
1847
|
-
*/
|
|
1848
|
-
EditableValueView: (
|
|
1849
|
-
props: ValueProps<Schemas> & {
|
|
1850
|
-
className?: string;
|
|
1851
|
-
readonly showType?: boolean;
|
|
1852
|
-
},
|
|
1853
|
-
) => ComponentReturnType;
|
|
1854
|
-
|
|
28
|
+
* An optional boolean to indicate whether the inspector should start in the
|
|
29
|
+
* opened state.
|
|
30
|
+
* @category Prop
|
|
31
|
+
* @since v5.0.0
|
|
32
|
+
*/
|
|
33
|
+
readonly open?: boolean;
|
|
1855
34
|
/**
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
*
|
|
1864
|
-
* The component's props identify initial pagination settings, and it will fire
|
|
1865
|
-
* an event when the pagination changes.
|
|
1866
|
-
* @param props The props for this component.
|
|
1867
|
-
* @returns The rendering of a paginator control with a label, and next and
|
|
1868
|
-
* previous buttons, where appropriate.
|
|
1869
|
-
* @example
|
|
1870
|
-
* This example creates a Provider context into which a default Store is
|
|
1871
|
-
* provided. The SortedTableInHtmlTable component within it then renders the
|
|
1872
|
-
* Table in a <table> element with a SortedTablePaginator (the default).
|
|
1873
|
-
*
|
|
1874
|
-
* ```jsx
|
|
1875
|
-
* import React from 'react';
|
|
1876
|
-
* import {createRoot} from 'react-dom/client';
|
|
1877
|
-
* import {createStore} from 'tinybase';
|
|
1878
|
-
* import {Provider} from 'tinybase/ui-react';
|
|
1879
|
-
* import {SortedTableInHtmlTable} from 'tinybase/ui-react-dom';
|
|
1880
|
-
*
|
|
1881
|
-
* const App = ({store}) => (
|
|
1882
|
-
* <Provider store={store}>
|
|
1883
|
-
* <Pane />
|
|
1884
|
-
* </Provider>
|
|
1885
|
-
* );
|
|
1886
|
-
* const Pane = () => (
|
|
1887
|
-
* <SortedTableInHtmlTable
|
|
1888
|
-
* tableId="pets"
|
|
1889
|
-
* cellId="species"
|
|
1890
|
-
* limit={2}
|
|
1891
|
-
* paginator={true}
|
|
1892
|
-
* />
|
|
1893
|
-
* );
|
|
1894
|
-
*
|
|
1895
|
-
* const store = createStore().setTables({
|
|
1896
|
-
* pets: {
|
|
1897
|
-
* fido: {species: 'dog'},
|
|
1898
|
-
* felix: {species: 'cat'},
|
|
1899
|
-
* cujo: {species: 'wolf'},
|
|
1900
|
-
* lowly: {species: 'worm'},
|
|
1901
|
-
* polly: {species: 'parrot'},
|
|
1902
|
-
* },
|
|
1903
|
-
* });
|
|
1904
|
-
* const app = document.createElement('div');
|
|
1905
|
-
* createRoot(app).render(<App store={store} />); // !act
|
|
1906
|
-
* console.log(app.innerHTML);
|
|
1907
|
-
* // ->
|
|
1908
|
-
* `
|
|
1909
|
-
* <table>
|
|
1910
|
-
* <caption>
|
|
1911
|
-
* <button class="previous" disabled="">←</button>
|
|
1912
|
-
* <button class="next">→</button>
|
|
1913
|
-
* 1 to 2 of 5 rows
|
|
1914
|
-
* </caption>
|
|
1915
|
-
* <thead>
|
|
1916
|
-
* <tr>
|
|
1917
|
-
* <th>Id</th>
|
|
1918
|
-
* <th class="sorted ascending">↑ species</th>
|
|
1919
|
-
* </tr>
|
|
1920
|
-
* </thead>
|
|
1921
|
-
* <tbody>
|
|
1922
|
-
* <tr>
|
|
1923
|
-
* <th>felix</th>
|
|
1924
|
-
* <td>cat</td>
|
|
1925
|
-
* </tr>
|
|
1926
|
-
* <tr>
|
|
1927
|
-
* <th>fido</th>
|
|
1928
|
-
* <td>dog</td>
|
|
1929
|
-
* </tr>
|
|
1930
|
-
* </tbody>
|
|
1931
|
-
* </table>
|
|
1932
|
-
* `;
|
|
1933
|
-
* ```
|
|
1934
|
-
* @category Store components
|
|
1935
|
-
* @since v4.1.0
|
|
1936
|
-
*/
|
|
1937
|
-
SortedTablePaginator: (
|
|
1938
|
-
props: SortedTablePaginatorProps,
|
|
1939
|
-
) => ComponentReturnType;
|
|
35
|
+
* An optional number to indicate the hue of the inspector's UI, defaulting to
|
|
36
|
+
* 270.
|
|
37
|
+
* @category Prop
|
|
38
|
+
* @since v6.6.0
|
|
39
|
+
*/
|
|
40
|
+
readonly hue?: number;
|
|
41
|
+
};
|
|
1940
42
|
|
|
1941
|
-
|
|
43
|
+
/**
|
|
1942
44
|
* The Inspector component renders a tool which allows you to view and edit the
|
|
1943
45
|
* content of a Store in a debug web environment.
|
|
1944
46
|
*
|
|
@@ -1982,5 +84,4 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
1982
84
|
* @essential Using React
|
|
1983
85
|
* @since v5.0.0
|
|
1984
86
|
*/
|
|
1985
|
-
|
|
1986
|
-
};
|
|
87
|
+
export function Inspector(props: InspectorProps): ComponentReturnType;
|