tinybase 8.2.0-beta.0 → 8.2.0-beta.1

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