tinybase 9.5.0-beta.0 → 9.5.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.
- package/@types/_internal/store/with-schemas/index.d.ts +43 -8
- package/@types/mergeable-store/with-schemas/index.d.ts +30 -11
- package/@types/queries/index.d.ts +11 -11
- package/@types/queries/with-schemas/index.d.ts +17 -3
- package/@types/schematizers/index.d.ts +6 -4
- package/@types/schematizers/schematizer-arktype/index.d.ts +6 -6
- package/@types/schematizers/schematizer-arktype/with-schemas/index.d.ts +112 -1
- package/@types/schematizers/schematizer-effect/index.d.ts +9 -11
- package/@types/schematizers/schematizer-effect/with-schemas/index.d.ts +114 -1
- package/@types/schematizers/schematizer-typebox/index.d.ts +7 -7
- package/@types/schematizers/schematizer-typebox/with-schemas/index.d.ts +114 -1
- package/@types/schematizers/schematizer-valibot/index.d.ts +6 -6
- package/@types/schematizers/schematizer-valibot/with-schemas/index.d.ts +112 -1
- package/@types/schematizers/schematizer-yup/index.d.ts +5 -4
- package/@types/schematizers/schematizer-yup/with-schemas/index.d.ts +112 -1
- package/@types/schematizers/schematizer-zod/index.d.ts +6 -6
- package/@types/schematizers/schematizer-zod/with-schemas/index.d.ts +112 -1
- package/@types/schematizers/with-schemas/index.d.ts +113 -4
- package/@types/store/index.d.ts +175 -16
- package/@types/store/with-schemas/index.d.ts +238 -55
- package/@types/synchronizers/with-schemas/index.d.ts +12 -2
- package/@types/ui-react/with-schemas/index.d.ts +576 -7
- package/@types/ui-react-dom/with-schemas/index.d.ts +84 -0
- package/@types/ui-solid/with-schemas/index.d.ts +340 -7
- package/@types/ui-solid-dom/with-schemas/index.d.ts +84 -0
- package/@types/ui-svelte/with-schemas/index.d.ts +30 -0
- package/@types/ui-svelte-dom/with-schemas/index.d.ts +84 -0
- package/agents.md +4 -0
- package/index.js +76 -22
- package/mergeable-store/index.js +76 -22
- package/mergeable-store/with-schemas/index.js +76 -22
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/schematizers/index.js +1 -1
- package/min/schematizers/index.js.gz +0 -0
- package/min/schematizers/schematizer-arktype/index.js +1 -1
- package/min/schematizers/schematizer-arktype/index.js.gz +0 -0
- package/min/schematizers/schematizer-arktype/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-arktype/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-effect/index.js +1 -1
- package/min/schematizers/schematizer-effect/index.js.gz +0 -0
- package/min/schematizers/schematizer-effect/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-effect/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-typebox/index.js +1 -1
- package/min/schematizers/schematizer-typebox/index.js.gz +0 -0
- package/min/schematizers/schematizer-typebox/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-typebox/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-valibot/index.js +1 -1
- package/min/schematizers/schematizer-valibot/index.js.gz +0 -0
- package/min/schematizers/schematizer-valibot/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-valibot/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-yup/index.js +1 -1
- package/min/schematizers/schematizer-yup/index.js.gz +0 -0
- package/min/schematizers/schematizer-yup/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-yup/with-schemas/index.js.gz +0 -0
- package/min/schematizers/schematizer-zod/index.js +1 -1
- package/min/schematizers/schematizer-zod/index.js.gz +0 -0
- package/min/schematizers/schematizer-zod/with-schemas/index.js +1 -1
- package/min/schematizers/schematizer-zod/with-schemas/index.js.gz +0 -0
- package/min/schematizers/with-schemas/index.js +1 -1
- package/min/schematizers/with-schemas/index.js.gz +0 -0
- package/min/store/index.js +1 -1
- package/min/store/index.js.gz +0 -0
- package/min/store/with-schemas/index.js +1 -1
- package/min/store/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-inspector/index.js +1 -1
- package/min/ui-solid-inspector/index.js.gz +0 -0
- package/min/ui-solid-inspector/with-schemas/index.js +1 -1
- package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-inspector/index.js +1 -1
- package/min/ui-svelte-inspector/index.js.gz +0 -0
- package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
- package/min/ui-svelte-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +76 -22
- package/omni/with-schemas/index.js +76 -22
- package/package.json +2 -2
- package/readme.md +14 -14
- package/releases.md +95 -65
- package/schematizers/index.js +54 -6
- package/schematizers/schematizer-arktype/index.js +99 -19
- package/schematizers/schematizer-arktype/with-schemas/index.js +99 -19
- package/schematizers/schematizer-effect/index.js +101 -11
- package/schematizers/schematizer-effect/with-schemas/index.js +101 -11
- package/schematizers/schematizer-typebox/index.js +87 -11
- package/schematizers/schematizer-typebox/with-schemas/index.js +87 -11
- package/schematizers/schematizer-valibot/index.js +125 -21
- package/schematizers/schematizer-valibot/with-schemas/index.js +125 -21
- package/schematizers/schematizer-yup/index.js +58 -14
- package/schematizers/schematizer-yup/with-schemas/index.js +58 -14
- package/schematizers/schematizer-zod/index.js +131 -12
- package/schematizers/schematizer-zod/with-schemas/index.js +131 -12
- package/schematizers/with-schemas/index.js +54 -6
- package/store/index.js +76 -22
- package/store/with-schemas/index.js +76 -22
- package/ui-react-inspector/index.js +76 -22
- package/ui-react-inspector/with-schemas/index.js +76 -22
- package/ui-solid-inspector/index.js +76 -22
- package/ui-solid-inspector/with-schemas/index.js +76 -22
- package/ui-svelte-inspector/index.js +76 -22
- package/ui-svelte-inspector/with-schemas/index.js +76 -22
- package/with-schemas/index.js +76 -22
|
@@ -231,6 +231,18 @@ export type TableInHtmlTableProps<
|
|
|
231
231
|
[CellId in CellIdFromSchema<Schemas[0], TableId>]?:
|
|
232
232
|
string | CustomCell<Schemas, TableId, CellId>;
|
|
233
233
|
};
|
|
234
|
+
/**
|
|
235
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
236
|
+
* @category Prop
|
|
237
|
+
* @since v6.6.0
|
|
238
|
+
*/
|
|
239
|
+
readonly extraCellsBefore?: ExtraRowCell<Schemas, TableId>[];
|
|
240
|
+
/**
|
|
241
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
242
|
+
* @category Prop
|
|
243
|
+
* @since v6.6.0
|
|
244
|
+
*/
|
|
245
|
+
readonly extraCellsAfter?: ExtraRowCell<Schemas, TableId>[];
|
|
234
246
|
}
|
|
235
247
|
: never
|
|
236
248
|
: never;
|
|
@@ -311,6 +323,18 @@ export type SortedTableInHtmlTableProps<
|
|
|
311
323
|
string | CustomCell<Schemas, TableId, CellId>;
|
|
312
324
|
};
|
|
313
325
|
/**
|
|
326
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
327
|
+
* @category Prop
|
|
328
|
+
* @since v6.6.0
|
|
329
|
+
*/
|
|
330
|
+
readonly extraCellsBefore?: ExtraRowCell<Schemas, TableId>[];
|
|
331
|
+
/**
|
|
332
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
333
|
+
* @category Prop
|
|
334
|
+
* @since v6.6.0
|
|
335
|
+
*/
|
|
336
|
+
readonly extraCellsAfter?: ExtraRowCell<Schemas, TableId>[];
|
|
337
|
+
/**
|
|
314
338
|
* Whether the table should be interactive such that clicking a header changes
|
|
315
339
|
* the sorting and/or direction.
|
|
316
340
|
* @category Prop
|
|
@@ -378,6 +402,18 @@ export type ValuesInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
|
378
402
|
* @since v4.1.0
|
|
379
403
|
*/
|
|
380
404
|
readonly getValueComponentProps?: (valueId: Id) => ExtraProps;
|
|
405
|
+
/**
|
|
406
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
407
|
+
* @category Prop
|
|
408
|
+
* @since v6.6.0
|
|
409
|
+
*/
|
|
410
|
+
readonly extraCellsBefore?: ExtraValueCell<Schemas>[];
|
|
411
|
+
/**
|
|
412
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
413
|
+
* @category Prop
|
|
414
|
+
* @since v6.6.0
|
|
415
|
+
*/
|
|
416
|
+
readonly extraCellsAfter?: ExtraValueCell<Schemas>[];
|
|
381
417
|
};
|
|
382
418
|
|
|
383
419
|
/**
|
|
@@ -426,6 +462,18 @@ export type SliceInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
|
426
462
|
*/
|
|
427
463
|
readonly customCells?:
|
|
428
464
|
Ids | {[cellId: Id]: string | CustomCell<NoSchemas, Id, Id>};
|
|
465
|
+
/**
|
|
466
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
467
|
+
* @category Prop
|
|
468
|
+
* @since v6.6.0
|
|
469
|
+
*/
|
|
470
|
+
readonly extraCellsBefore?: ExtraRowCell<NoSchemas, Id>[];
|
|
471
|
+
/**
|
|
472
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
473
|
+
* @category Prop
|
|
474
|
+
* @since v6.6.0
|
|
475
|
+
*/
|
|
476
|
+
readonly extraCellsAfter?: ExtraRowCell<NoSchemas, Id>[];
|
|
429
477
|
};
|
|
430
478
|
|
|
431
479
|
/**
|
|
@@ -476,6 +524,18 @@ export type RelationshipInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
|
476
524
|
*/
|
|
477
525
|
readonly customCells?:
|
|
478
526
|
Ids | {[cellId: Id]: string | CustomCell<NoSchemas, Id, Id>};
|
|
527
|
+
/**
|
|
528
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
529
|
+
* @category Prop
|
|
530
|
+
* @since v6.6.0
|
|
531
|
+
*/
|
|
532
|
+
readonly extraCellsBefore?: ExtraRowCell<NoSchemas, Id>[];
|
|
533
|
+
/**
|
|
534
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
535
|
+
* @category Prop
|
|
536
|
+
* @since v6.6.0
|
|
537
|
+
*/
|
|
538
|
+
readonly extraCellsAfter?: ExtraRowCell<NoSchemas, Id>[];
|
|
479
539
|
};
|
|
480
540
|
|
|
481
541
|
/**
|
|
@@ -511,6 +571,18 @@ export type ResultTableInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
|
511
571
|
*/
|
|
512
572
|
readonly customCells?:
|
|
513
573
|
Ids | {[cellId: Id]: string | CustomResultCell<Schemas>};
|
|
574
|
+
/**
|
|
575
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
576
|
+
* @category Prop
|
|
577
|
+
* @since v6.6.0
|
|
578
|
+
*/
|
|
579
|
+
readonly extraCellsBefore?: ExtraRowCell<NoSchemas, Id>[];
|
|
580
|
+
/**
|
|
581
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
582
|
+
* @category Prop
|
|
583
|
+
* @since v6.6.0
|
|
584
|
+
*/
|
|
585
|
+
readonly extraCellsAfter?: ExtraRowCell<NoSchemas, Id>[];
|
|
514
586
|
};
|
|
515
587
|
|
|
516
588
|
/**
|
|
@@ -574,6 +646,18 @@ export type ResultSortedTableInHtmlTableProps<Schemas extends OptionalSchemas> =
|
|
|
574
646
|
readonly customCells?:
|
|
575
647
|
Ids | {[cellId: Id]: string | CustomResultCell<Schemas>};
|
|
576
648
|
/**
|
|
649
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
650
|
+
* @category Prop
|
|
651
|
+
* @since v6.6.0
|
|
652
|
+
*/
|
|
653
|
+
readonly extraCellsBefore?: ExtraRowCell<NoSchemas, Id>[];
|
|
654
|
+
/**
|
|
655
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
656
|
+
* @category Prop
|
|
657
|
+
* @since v6.6.0
|
|
658
|
+
*/
|
|
659
|
+
readonly extraCellsAfter?: ExtraRowCell<NoSchemas, Id>[];
|
|
660
|
+
/**
|
|
577
661
|
* Whether the table should be interactive such that clicking a header changes
|
|
578
662
|
* the sorting and/or direction.
|
|
579
663
|
* @category Prop
|
|
@@ -7098,7 +7098,52 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
7098
7098
|
metricsOrMetricsId?: MaybeAccessor<MetricsOrMetricsId<Schemas> | undefined>,
|
|
7099
7099
|
) => Accessor<Metrics<Schemas> | undefined>;
|
|
7100
7100
|
|
|
7101
|
-
|
|
7101
|
+
/**
|
|
7102
|
+
* The useProvideMetrics primitive is used to add a Metrics object by Id to a
|
|
7103
|
+
* Provider component, but imperatively from a component within it.
|
|
7104
|
+
*
|
|
7105
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
7106
|
+
*
|
|
7107
|
+
* ```ts override
|
|
7108
|
+
* useProvideMetrics(metricsId: Id, metrics: Metrics): void;
|
|
7109
|
+
* ```
|
|
7110
|
+
*
|
|
7111
|
+
* Normally you will register a Metrics object by Id in a context by using the
|
|
7112
|
+
* `metricsById` prop of the top-level Provider component. This primitive,
|
|
7113
|
+
* however, lets you dynamically add a new Metrics object to the context, from
|
|
7114
|
+
* within a descendent component. This is useful for applications where the set
|
|
7115
|
+
* of Metrics objects is not known at the time of the first render of the root
|
|
7116
|
+
* Provider.
|
|
7117
|
+
*
|
|
7118
|
+
* A Metrics object added to the Provider context in this way will be available
|
|
7119
|
+
* to other components within the context (using the useMetrics primitive and so
|
|
7120
|
+
* on). If you use the same Id as an existing Metrics object registration, the
|
|
7121
|
+
* new one will take priority over one provided by the `metricsById` prop.
|
|
7122
|
+
* @param metricsId The Id of the Metrics object to be registered with the
|
|
7123
|
+
* Provider.
|
|
7124
|
+
* @param metrics The Metrics object to be registered.
|
|
7125
|
+
* @example
|
|
7126
|
+
* ```js
|
|
7127
|
+
* import {createRoot} from 'solid-js';
|
|
7128
|
+
* import {createMetrics, createStore} from 'tinybase';
|
|
7129
|
+
* import {useProvideMetrics} from 'tinybase/ui-solid';
|
|
7130
|
+
*
|
|
7131
|
+
* createRoot((dispose) => {
|
|
7132
|
+
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
7133
|
+
* const metrics = createMetrics(store).setMetricDefinition(
|
|
7134
|
+
* 'petCount',
|
|
7135
|
+
* 'pets',
|
|
7136
|
+
* 'count',
|
|
7137
|
+
* );
|
|
7138
|
+
* useProvideMetrics('petMetrics', metrics);
|
|
7139
|
+
* console.log(metrics.getMetric('petCount'));
|
|
7140
|
+
* // -> 1
|
|
7141
|
+
* dispose();
|
|
7142
|
+
* });
|
|
7143
|
+
* ```
|
|
7144
|
+
* @category Metrics primitives
|
|
7145
|
+
* @since v8.3.0
|
|
7146
|
+
*/
|
|
7102
7147
|
useProvideMetrics: (metricsId: Id, metrics: Metrics<Schemas>) => void;
|
|
7103
7148
|
|
|
7104
7149
|
/**
|
|
@@ -7741,7 +7786,52 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
7741
7786
|
indexesOrIndexesId?: MaybeAccessor<IndexesOrIndexesId<Schemas> | undefined>,
|
|
7742
7787
|
) => Accessor<Indexes<Schemas> | undefined>;
|
|
7743
7788
|
|
|
7744
|
-
|
|
7789
|
+
/**
|
|
7790
|
+
* The useProvideIndexes primitive is used to add an Indexes object by Id to a
|
|
7791
|
+
* Provider component, but imperatively from a component within it.
|
|
7792
|
+
*
|
|
7793
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
7794
|
+
*
|
|
7795
|
+
* ```ts override
|
|
7796
|
+
* useProvideIndexes(indexesId: Id, indexes: Indexes): void;
|
|
7797
|
+
* ```
|
|
7798
|
+
*
|
|
7799
|
+
* Normally you will register an Indexes object by Id in a context by using the
|
|
7800
|
+
* `indexesById` prop of the top-level Provider component. This primitive,
|
|
7801
|
+
* however, lets you dynamically add a new Indexes object to the context, from
|
|
7802
|
+
* within a descendent component. This is useful for applications where the set
|
|
7803
|
+
* of Indexes objects is not known at the time of the first render of the root
|
|
7804
|
+
* Provider.
|
|
7805
|
+
*
|
|
7806
|
+
* An Indexes object added to the Provider context in this way will be available
|
|
7807
|
+
* to other components within the context (using the useIndexes primitive and so
|
|
7808
|
+
* on). If you use the same Id as an existing Indexes object registration, the
|
|
7809
|
+
* new one will take priority over one provided by the `indexesById` prop.
|
|
7810
|
+
* @param indexesId The Id of the Indexes object to be registered with the
|
|
7811
|
+
* Provider.
|
|
7812
|
+
* @param indexes The Indexes object to be registered.
|
|
7813
|
+
* @example
|
|
7814
|
+
* ```js
|
|
7815
|
+
* import {createRoot} from 'solid-js';
|
|
7816
|
+
* import {createIndexes, createStore} from 'tinybase';
|
|
7817
|
+
* import {useProvideIndexes} from 'tinybase/ui-solid';
|
|
7818
|
+
*
|
|
7819
|
+
* createRoot((dispose) => {
|
|
7820
|
+
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
7821
|
+
* const indexes = createIndexes(store).setIndexDefinition(
|
|
7822
|
+
* 'petsByColor',
|
|
7823
|
+
* 'pets',
|
|
7824
|
+
* 'color',
|
|
7825
|
+
* );
|
|
7826
|
+
* useProvideIndexes('petIndexes', indexes);
|
|
7827
|
+
* console.log(JSON.stringify(indexes.getSliceIds('petsByColor')));
|
|
7828
|
+
* // -> '["brown"]'
|
|
7829
|
+
* dispose();
|
|
7830
|
+
* });
|
|
7831
|
+
* ```
|
|
7832
|
+
* @category Indexes primitives
|
|
7833
|
+
* @since v8.3.0
|
|
7834
|
+
*/
|
|
7745
7835
|
useProvideIndexes: (indexesId: Id, indexes: Indexes<Schemas>) => void;
|
|
7746
7836
|
|
|
7747
7837
|
/**
|
|
@@ -8662,7 +8752,56 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
8662
8752
|
>,
|
|
8663
8753
|
) => Accessor<Relationships<Schemas> | undefined>;
|
|
8664
8754
|
|
|
8665
|
-
|
|
8755
|
+
/**
|
|
8756
|
+
* The useProvideRelationships primitive is used to add a Relationships object
|
|
8757
|
+
* by Id to a Provider component, but imperatively from a component within it.
|
|
8758
|
+
*
|
|
8759
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
8760
|
+
*
|
|
8761
|
+
* ```ts override
|
|
8762
|
+
* useProvideRelationships(
|
|
8763
|
+
* relationshipsId: Id,
|
|
8764
|
+
* relationships: Relationships,
|
|
8765
|
+
* ): void;
|
|
8766
|
+
* ```
|
|
8767
|
+
*
|
|
8768
|
+
* Normally you will register a Relationships object by Id in a context by using
|
|
8769
|
+
* the `relationshipsById` prop of the top-level Provider component. This
|
|
8770
|
+
* primitive, however, lets you dynamically add a new Relationships object to
|
|
8771
|
+
* the context, from within a component. This is useful for applications where
|
|
8772
|
+
* the set of Relationships objects is not known at the time of the first render
|
|
8773
|
+
* of the root Provider.
|
|
8774
|
+
*
|
|
8775
|
+
* A Relationships object added to the Provider context in this way will be
|
|
8776
|
+
* available to other components within the context (using the useRelationships
|
|
8777
|
+
* primitive and so on). If you use the same Id as an existing Relationships
|
|
8778
|
+
* object registration, the new one will take priority over one provided by the
|
|
8779
|
+
* `relationshipsById` prop.
|
|
8780
|
+
* @param relationshipsId The Id of the Relationships object to be registered
|
|
8781
|
+
* with the Provider.
|
|
8782
|
+
* @param relationships The Relationships object to be registered.
|
|
8783
|
+
* @example
|
|
8784
|
+
* ```js
|
|
8785
|
+
* import {createRoot} from 'solid-js';
|
|
8786
|
+
* import {createRelationships, createStore} from 'tinybase';
|
|
8787
|
+
* import {useProvideRelationships} from 'tinybase/ui-solid';
|
|
8788
|
+
*
|
|
8789
|
+
* createRoot((dispose) => {
|
|
8790
|
+
* const store = createStore()
|
|
8791
|
+
* .setTable('pets', {fido: {species: 'dog'}})
|
|
8792
|
+
* .setTable('species', {dog: {price: 5}});
|
|
8793
|
+
* const relationships = createRelationships(
|
|
8794
|
+
* store,
|
|
8795
|
+
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
8796
|
+
* useProvideRelationships('petRelationships', relationships);
|
|
8797
|
+
* console.log(relationships.getRemoteRowId('petSpecies', 'fido'));
|
|
8798
|
+
* // -> 'dog'
|
|
8799
|
+
* dispose();
|
|
8800
|
+
* });
|
|
8801
|
+
* ```
|
|
8802
|
+
* @category Relationships primitives
|
|
8803
|
+
* @since v8.3.0
|
|
8804
|
+
*/
|
|
8666
8805
|
useProvideRelationships: (
|
|
8667
8806
|
relationshipsId: Id,
|
|
8668
8807
|
relationships: Relationships<Schemas>,
|
|
@@ -9790,7 +9929,57 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
9790
9929
|
queriesOrQueriesId?: MaybeAccessor<QueriesOrQueriesId<Schemas> | undefined>,
|
|
9791
9930
|
) => Accessor<Queries<Schemas> | undefined>;
|
|
9792
9931
|
|
|
9793
|
-
|
|
9932
|
+
/**
|
|
9933
|
+
* The useProvideQueries primitive is used to add a Queries object by Id to a
|
|
9934
|
+
* Provider component, but imperatively from a component within it.
|
|
9935
|
+
*
|
|
9936
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
9937
|
+
*
|
|
9938
|
+
* ```ts override
|
|
9939
|
+
* useProvideQueries(queriesId: Id, queries: Queries): void;
|
|
9940
|
+
* ```
|
|
9941
|
+
*
|
|
9942
|
+
* Normally you will register a Queries object by Id in a context by using the
|
|
9943
|
+
* `queriesById` prop of the top-level Provider component. This primitive,
|
|
9944
|
+
* however, lets you dynamically add a new Queries object to the context, from
|
|
9945
|
+
* within a component. This is useful for applications where the set of Queries
|
|
9946
|
+
* objects is not known at the time of the first render of the root Provider.
|
|
9947
|
+
*
|
|
9948
|
+
* A Queries object added to the Provider context in this way will be available
|
|
9949
|
+
* to other components within the context (using the useQueries primitive and so
|
|
9950
|
+
* on). If you use the same Id as an existing Queries object registration, the
|
|
9951
|
+
* new one will take priority over one provided by the `queriesById` prop.
|
|
9952
|
+
* @param queriesId The Id of the Queries object to be registered with the
|
|
9953
|
+
* Provider.
|
|
9954
|
+
* @param queries The Queries object to be registered.
|
|
9955
|
+
* @example
|
|
9956
|
+
* ```js
|
|
9957
|
+
* import {createRoot} from 'solid-js';
|
|
9958
|
+
* import {createQueries, createStore} from 'tinybase';
|
|
9959
|
+
* import {useProvideQueries} from 'tinybase/ui-solid';
|
|
9960
|
+
*
|
|
9961
|
+
* createRoot((dispose) => {
|
|
9962
|
+
* const store = createStore().setRow('pets', 'fido', {
|
|
9963
|
+
* color: 'brown',
|
|
9964
|
+
* legs: 4,
|
|
9965
|
+
* });
|
|
9966
|
+
* const queries = createQueries(store).setQueryDefinition(
|
|
9967
|
+
* 'brownLegs',
|
|
9968
|
+
* 'pets',
|
|
9969
|
+
* ({select, where}) => {
|
|
9970
|
+
* select('legs');
|
|
9971
|
+
* where('color', 'brown');
|
|
9972
|
+
* },
|
|
9973
|
+
* );
|
|
9974
|
+
* useProvideQueries('petQueries', queries);
|
|
9975
|
+
* console.log(JSON.stringify(queries.getResultTable('brownLegs')));
|
|
9976
|
+
* // -> '{"fido":{"legs":4}}'
|
|
9977
|
+
* dispose();
|
|
9978
|
+
* });
|
|
9979
|
+
* ```
|
|
9980
|
+
* @category Queries primitives
|
|
9981
|
+
* @since v8.3.0
|
|
9982
|
+
*/
|
|
9794
9983
|
useProvideQueries: (queriesId: Id, queries: Queries<Schemas>) => void;
|
|
9795
9984
|
|
|
9796
9985
|
/**
|
|
@@ -12744,7 +12933,52 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
12744
12933
|
>,
|
|
12745
12934
|
) => Accessor<Checkpoints<Schemas> | undefined>;
|
|
12746
12935
|
|
|
12747
|
-
|
|
12936
|
+
/**
|
|
12937
|
+
* The useProvideCheckpoints primitive is used to add a Checkpoints object by Id
|
|
12938
|
+
* to a Provider component, but imperatively from a component within it.
|
|
12939
|
+
*
|
|
12940
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
12941
|
+
*
|
|
12942
|
+
* ```ts override
|
|
12943
|
+
* useProvideCheckpoints(
|
|
12944
|
+
* checkpointsId: Id,
|
|
12945
|
+
* checkpoints: Checkpoints,
|
|
12946
|
+
* ): void;
|
|
12947
|
+
* ```
|
|
12948
|
+
*
|
|
12949
|
+
* Normally you will register a Checkpoints object by Id in a context by using
|
|
12950
|
+
* the `checkpointsById` prop of the top-level Provider component. This
|
|
12951
|
+
* primitive, however, lets you dynamically add a new Checkpoints object to the
|
|
12952
|
+
* context, from within a component. This is useful for applications where the
|
|
12953
|
+
* set of Checkpoints objects is not known at the time of the first render of
|
|
12954
|
+
* the root Provider.
|
|
12955
|
+
*
|
|
12956
|
+
* A Checkpoints object added to the Provider context in this way will be
|
|
12957
|
+
* available to other components within the context (using the useCheckpoints
|
|
12958
|
+
* primitive and so on). If you use the same Id as an existing Checkpoints
|
|
12959
|
+
* object registration, the new one will take priority over one provided by the
|
|
12960
|
+
* `checkpointsById` prop.
|
|
12961
|
+
* @param checkpointsId The Id of the Checkpoints object to be registered with
|
|
12962
|
+
* the Provider.
|
|
12963
|
+
* @param checkpoints The Checkpoints object to be registered.
|
|
12964
|
+
* @example
|
|
12965
|
+
* ```js
|
|
12966
|
+
* import {createRoot} from 'solid-js';
|
|
12967
|
+
* import {createCheckpoints, createStore} from 'tinybase';
|
|
12968
|
+
* import {useProvideCheckpoints} from 'tinybase/ui-solid';
|
|
12969
|
+
*
|
|
12970
|
+
* createRoot((dispose) => {
|
|
12971
|
+
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
12972
|
+
* const checkpoints = createCheckpoints(store);
|
|
12973
|
+
* useProvideCheckpoints('petCheckpoints', checkpoints);
|
|
12974
|
+
* console.log(JSON.stringify(checkpoints.getCheckpointIds()));
|
|
12975
|
+
* // -> '[[],"0",[]]'
|
|
12976
|
+
* dispose();
|
|
12977
|
+
* });
|
|
12978
|
+
* ```
|
|
12979
|
+
* @category Checkpoints primitives
|
|
12980
|
+
* @since v8.3.0
|
|
12981
|
+
*/
|
|
12748
12982
|
useProvideCheckpoints: (
|
|
12749
12983
|
checkpointsId: Id,
|
|
12750
12984
|
checkpoints: Checkpoints<Schemas>,
|
|
@@ -14110,7 +14344,54 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
14110
14344
|
>,
|
|
14111
14345
|
) => Accessor<Persister<Schemas, Persists.StoreOrMergeableStore> | undefined>;
|
|
14112
14346
|
|
|
14113
|
-
|
|
14347
|
+
/**
|
|
14348
|
+
* The useProvidePersister primitive is used to add a Persister object by Id to
|
|
14349
|
+
* a Provider component, but imperatively from a component within it.
|
|
14350
|
+
*
|
|
14351
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
14352
|
+
*
|
|
14353
|
+
* ```ts override
|
|
14354
|
+
* useProvidePersister(
|
|
14355
|
+
* persisterId: Id,
|
|
14356
|
+
* persister: AnyPersister,
|
|
14357
|
+
* ): void;
|
|
14358
|
+
* ```
|
|
14359
|
+
*
|
|
14360
|
+
* Normally you will register a Persister object by Id in a context by using the
|
|
14361
|
+
* `persistersById` prop of the top-level Provider component. This primitive,
|
|
14362
|
+
* however, lets you dynamically add a new Persister object to the context, from
|
|
14363
|
+
* within a component. This is useful for applications where the set of
|
|
14364
|
+
* Persister objects is not known at the time of the first render of the root
|
|
14365
|
+
* Provider.
|
|
14366
|
+
*
|
|
14367
|
+
* A Persister object added to the Provider context in this way will be
|
|
14368
|
+
* available to other components within the context (using the usePersister
|
|
14369
|
+
* primitive and so on). If you use the same Id as an existing Persister object
|
|
14370
|
+
* registration, the new one will take priority over one provided by the
|
|
14371
|
+
* `persistersById` prop.
|
|
14372
|
+
* @param persisterId The Id of the Persister object to be registered with the
|
|
14373
|
+
* Provider.
|
|
14374
|
+
* @param persister The Persister object to be registered.
|
|
14375
|
+
* @example
|
|
14376
|
+
* ```js
|
|
14377
|
+
* import {createRoot} from 'solid-js';
|
|
14378
|
+
* import {createStore} from 'tinybase';
|
|
14379
|
+
* import {createSessionPersister} from 'tinybase/persisters/persister-browser';
|
|
14380
|
+
* import {useProvidePersister} from 'tinybase/ui-solid';
|
|
14381
|
+
*
|
|
14382
|
+
* createRoot((dispose) => {
|
|
14383
|
+
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
14384
|
+
* const persister = createSessionPersister(store, 'pets');
|
|
14385
|
+
* useProvidePersister('petPersister', persister);
|
|
14386
|
+
* console.log(persister.getStatus());
|
|
14387
|
+
* // -> 0
|
|
14388
|
+
* persister.destroy();
|
|
14389
|
+
* dispose();
|
|
14390
|
+
* });
|
|
14391
|
+
* ```
|
|
14392
|
+
* @category Persister primitives
|
|
14393
|
+
* @since v8.3.0
|
|
14394
|
+
*/
|
|
14114
14395
|
useProvidePersister: (
|
|
14115
14396
|
persisterId: Id,
|
|
14116
14397
|
persister: AnyPersister<Schemas> | undefined,
|
|
@@ -14681,7 +14962,59 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
14681
14962
|
>,
|
|
14682
14963
|
) => Accessor<Synchronizer<Schemas> | undefined>;
|
|
14683
14964
|
|
|
14684
|
-
|
|
14965
|
+
/**
|
|
14966
|
+
* The useProvideSynchronizer primitive is used to add a Synchronizer object by
|
|
14967
|
+
* Id to a Provider component, but imperatively from a component within it.
|
|
14968
|
+
*
|
|
14969
|
+
* This has schema-based typing. The following is a simplified representation:
|
|
14970
|
+
*
|
|
14971
|
+
* ```ts override
|
|
14972
|
+
* useProvideSynchronizer(
|
|
14973
|
+
* synchronizerId: Id,
|
|
14974
|
+
* synchronizer: Synchronizer,
|
|
14975
|
+
* ): void;
|
|
14976
|
+
* ```
|
|
14977
|
+
*
|
|
14978
|
+
* Normally you will register a Synchronizer object by Id in a context by using
|
|
14979
|
+
* the `synchronizersById` prop of the top-level Provider component. This
|
|
14980
|
+
* primitive, however, lets you dynamically add a new Synchronizer object to the
|
|
14981
|
+
* context, from within a component. This is useful for applications where the
|
|
14982
|
+
* set of Synchronizer objects is not known at the time of the first render of
|
|
14983
|
+
* the root Provider.
|
|
14984
|
+
*
|
|
14985
|
+
* A Synchronizer object added to the Provider context in this way will be
|
|
14986
|
+
* available to other components within the context (using the useSynchronizer
|
|
14987
|
+
* primitive and so on). If you use the same Id as an existing Synchronizer
|
|
14988
|
+
* object registration, the new one will take priority over one provided by the
|
|
14989
|
+
* `synchronizersById` prop.
|
|
14990
|
+
* @param synchronizerId The Id of the Synchronizer object to be registered with
|
|
14991
|
+
* the Provider.
|
|
14992
|
+
* @param synchronizer The Synchronizer object to be registered.
|
|
14993
|
+
* @example
|
|
14994
|
+
* ```js
|
|
14995
|
+
* import {createRoot} from 'solid-js';
|
|
14996
|
+
* import {createMergeableStore} from 'tinybase';
|
|
14997
|
+
* import {createLocalSynchronizer} from 'tinybase/synchronizers/synchronizer-local';
|
|
14998
|
+
* import {useProvideSynchronizer} from 'tinybase/ui-solid';
|
|
14999
|
+
*
|
|
15000
|
+
* createRoot((dispose) => {
|
|
15001
|
+
* const store = createMergeableStore().setCell(
|
|
15002
|
+
* 'pets',
|
|
15003
|
+
* 'fido',
|
|
15004
|
+
* 'color',
|
|
15005
|
+
* 'brown',
|
|
15006
|
+
* );
|
|
15007
|
+
* const synchronizer = createLocalSynchronizer(store);
|
|
15008
|
+
* useProvideSynchronizer('petSynchronizer', synchronizer);
|
|
15009
|
+
* console.log(synchronizer.getStatus());
|
|
15010
|
+
* // -> 0
|
|
15011
|
+
* synchronizer.destroy();
|
|
15012
|
+
* dispose();
|
|
15013
|
+
* });
|
|
15014
|
+
* ```
|
|
15015
|
+
* @category Synchronizer primitives
|
|
15016
|
+
* @since v8.3.0
|
|
15017
|
+
*/
|
|
14685
15018
|
useProvideSynchronizer: (
|
|
14686
15019
|
synchronizerId: Id,
|
|
14687
15020
|
synchronizer: Synchronizer<Schemas> | undefined,
|
|
@@ -232,6 +232,18 @@ export type TableInHtmlTableProps<
|
|
|
232
232
|
[CellId in CellIdFromSchema<Schemas[0], TableId>]?:
|
|
233
233
|
string | CustomCell<Schemas, TableId, CellId>;
|
|
234
234
|
};
|
|
235
|
+
/**
|
|
236
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
237
|
+
* @category Prop
|
|
238
|
+
* @since v8.4.0
|
|
239
|
+
*/
|
|
240
|
+
readonly extraCellsBefore?: ExtraRowCell<Schemas, TableId>[];
|
|
241
|
+
/**
|
|
242
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
243
|
+
* @category Prop
|
|
244
|
+
* @since v8.4.0
|
|
245
|
+
*/
|
|
246
|
+
readonly extraCellsAfter?: ExtraRowCell<Schemas, TableId>[];
|
|
235
247
|
}
|
|
236
248
|
: never
|
|
237
249
|
: never;
|
|
@@ -312,6 +324,18 @@ export type SortedTableInHtmlTableProps<
|
|
|
312
324
|
string | CustomCell<Schemas, TableId, CellId>;
|
|
313
325
|
};
|
|
314
326
|
/**
|
|
327
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
328
|
+
* @category Prop
|
|
329
|
+
* @since v8.4.0
|
|
330
|
+
*/
|
|
331
|
+
readonly extraCellsBefore?: ExtraRowCell<Schemas, TableId>[];
|
|
332
|
+
/**
|
|
333
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
334
|
+
* @category Prop
|
|
335
|
+
* @since v8.4.0
|
|
336
|
+
*/
|
|
337
|
+
readonly extraCellsAfter?: ExtraRowCell<Schemas, TableId>[];
|
|
338
|
+
/**
|
|
315
339
|
* Whether the table should be interactive such that clicking a header changes
|
|
316
340
|
* the sorting and/or direction.
|
|
317
341
|
* @category Prop
|
|
@@ -379,6 +403,18 @@ export type ValuesInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
|
379
403
|
* @since v8.4.0
|
|
380
404
|
*/
|
|
381
405
|
readonly getValueComponentProps?: (valueId: Id) => ExtraProps;
|
|
406
|
+
/**
|
|
407
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
408
|
+
* @category Prop
|
|
409
|
+
* @since v8.4.0
|
|
410
|
+
*/
|
|
411
|
+
readonly extraCellsBefore?: ExtraValueCell<Schemas>[];
|
|
412
|
+
/**
|
|
413
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
414
|
+
* @category Prop
|
|
415
|
+
* @since v8.4.0
|
|
416
|
+
*/
|
|
417
|
+
readonly extraCellsAfter?: ExtraValueCell<Schemas>[];
|
|
382
418
|
};
|
|
383
419
|
|
|
384
420
|
/**
|
|
@@ -427,6 +463,18 @@ export type SliceInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
|
427
463
|
*/
|
|
428
464
|
readonly customCells?:
|
|
429
465
|
Ids | {[cellId: Id]: string | CustomCell<NoSchemas, Id, Id>};
|
|
466
|
+
/**
|
|
467
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
468
|
+
* @category Prop
|
|
469
|
+
* @since v8.4.0
|
|
470
|
+
*/
|
|
471
|
+
readonly extraCellsBefore?: ExtraRowCell<NoSchemas, Id>[];
|
|
472
|
+
/**
|
|
473
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
474
|
+
* @category Prop
|
|
475
|
+
* @since v8.4.0
|
|
476
|
+
*/
|
|
477
|
+
readonly extraCellsAfter?: ExtraRowCell<NoSchemas, Id>[];
|
|
430
478
|
};
|
|
431
479
|
|
|
432
480
|
/**
|
|
@@ -477,6 +525,18 @@ export type RelationshipInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
|
477
525
|
*/
|
|
478
526
|
readonly customCells?:
|
|
479
527
|
Ids | {[cellId: Id]: string | CustomCell<NoSchemas, Id, Id>};
|
|
528
|
+
/**
|
|
529
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
530
|
+
* @category Prop
|
|
531
|
+
* @since v8.4.0
|
|
532
|
+
*/
|
|
533
|
+
readonly extraCellsBefore?: ExtraRowCell<NoSchemas, Id>[];
|
|
534
|
+
/**
|
|
535
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
536
|
+
* @category Prop
|
|
537
|
+
* @since v8.4.0
|
|
538
|
+
*/
|
|
539
|
+
readonly extraCellsAfter?: ExtraRowCell<NoSchemas, Id>[];
|
|
480
540
|
};
|
|
481
541
|
|
|
482
542
|
/**
|
|
@@ -512,6 +572,18 @@ export type ResultTableInHtmlTableProps<Schemas extends OptionalSchemas> = {
|
|
|
512
572
|
*/
|
|
513
573
|
readonly customCells?:
|
|
514
574
|
Ids | {[cellId: Id]: string | CustomResultCell<Schemas>};
|
|
575
|
+
/**
|
|
576
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
577
|
+
* @category Prop
|
|
578
|
+
* @since v8.4.0
|
|
579
|
+
*/
|
|
580
|
+
readonly extraCellsBefore?: ExtraRowCell<NoSchemas, Id>[];
|
|
581
|
+
/**
|
|
582
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
583
|
+
* @category Prop
|
|
584
|
+
* @since v8.4.0
|
|
585
|
+
*/
|
|
586
|
+
readonly extraCellsAfter?: ExtraRowCell<NoSchemas, Id>[];
|
|
515
587
|
};
|
|
516
588
|
|
|
517
589
|
/**
|
|
@@ -575,6 +647,18 @@ export type ResultSortedTableInHtmlTableProps<Schemas extends OptionalSchemas> =
|
|
|
575
647
|
readonly customCells?:
|
|
576
648
|
Ids | {[cellId: Id]: string | CustomResultCell<Schemas>};
|
|
577
649
|
/**
|
|
650
|
+
* An optional list of extra Cells to render before the main table Cells.
|
|
651
|
+
* @category Prop
|
|
652
|
+
* @since v8.4.0
|
|
653
|
+
*/
|
|
654
|
+
readonly extraCellsBefore?: ExtraRowCell<NoSchemas, Id>[];
|
|
655
|
+
/**
|
|
656
|
+
* An optional list of extra Cells to render after the main table Cells.
|
|
657
|
+
* @category Prop
|
|
658
|
+
* @since v8.4.0
|
|
659
|
+
*/
|
|
660
|
+
readonly extraCellsAfter?: ExtraRowCell<NoSchemas, Id>[];
|
|
661
|
+
/**
|
|
578
662
|
* Whether the table should be interactive such that clicking a header changes
|
|
579
663
|
* the sorting and/or direction.
|
|
580
664
|
* @category Prop
|
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ui-svelte module of the TinyBase project provides reactive functions,
|
|
3
|
+
* listener functions, and components to make it easy to create reactive Svelte
|
|
4
|
+
* 5 apps with Store objects.
|
|
5
|
+
*
|
|
6
|
+
* The reactive functions in this module provide access to the data and
|
|
7
|
+
* structures exposed by other modules in the project. They return reactive
|
|
8
|
+
* objects with a `current` property. Those functions register listeners such
|
|
9
|
+
* that components using them re-render when data changes.
|
|
10
|
+
*
|
|
11
|
+
* The components in this module provide a further abstraction over those
|
|
12
|
+
* reactive functions, and use Svelte snippet props to customize rendering in an
|
|
13
|
+
* idiomatic way.
|
|
14
|
+
*
|
|
15
|
+
* Functions like the getStore function and getMetrics function return TinyBase
|
|
16
|
+
* objects directly from Provider context. Functions like the getCell function,
|
|
17
|
+
* the getRow function, the getTable function, the getValue function, and the
|
|
18
|
+
* hasCell function return reactive objects whose `current` property reflects
|
|
19
|
+
* underlying TinyBase data.
|
|
20
|
+
*
|
|
21
|
+
* Function parameters accept either plain values or reactive getter functions
|
|
22
|
+
* (as per the MaybeGetter type), so passing `() => tableId` from a `let`-bound
|
|
23
|
+
* Svelte prop makes the function re-execute whenever the prop changes.
|
|
24
|
+
* @see Building UIs With Svelte guide
|
|
25
|
+
* @see Hello World (Svelte) demo
|
|
26
|
+
* @see Countries (Svelte) demo
|
|
27
|
+
* @packageDocumentation
|
|
28
|
+
* @module ui-svelte
|
|
29
|
+
* @since v8.1.0
|
|
30
|
+
*/
|
|
1
31
|
import type {Component, Snippet} from 'svelte';
|
|
2
32
|
import type {
|
|
3
33
|
AllCellIdFromSchema,
|