tinybase 6.1.0-beta.1 → 6.1.0-beta.2

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