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