tinybase 2.0.0-beta.1 → 2.0.0-beta.4
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/lib/checkpoints.d.ts +5 -4
- package/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/common.js +1 -1
- package/lib/common.js.gz +0 -0
- package/lib/debug/checkpoints.d.ts +5 -4
- package/lib/debug/checkpoints.js +13 -16
- package/lib/debug/common.js +4 -1
- package/lib/debug/indexes.d.ts +4 -2
- package/lib/debug/indexes.js +13 -15
- package/lib/debug/metrics.d.ts +1 -1
- package/lib/debug/metrics.js +13 -16
- package/lib/debug/persisters.d.ts +7 -1
- package/lib/debug/queries.d.ts +296 -326
- package/lib/debug/queries.js +71 -192
- package/lib/debug/relationships.d.ts +7 -6
- package/lib/debug/relationships.js +13 -16
- package/lib/debug/store.d.ts +386 -86
- package/lib/debug/store.js +278 -216
- package/lib/debug/tinybase.js +322 -390
- package/lib/debug/ui-react.d.ts +850 -68
- package/lib/debug/ui-react.js +217 -120
- package/lib/indexes.d.ts +4 -2
- package/lib/indexes.js +1 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.d.ts +1 -1
- package/lib/metrics.js +1 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/persisters.d.ts +7 -1
- package/lib/queries.d.ts +296 -326
- package/lib/queries.js +1 -1
- package/lib/queries.js.gz +0 -0
- package/lib/relationships.d.ts +7 -6
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.d.ts +386 -86
- package/lib/store.js +1 -1
- package/lib/store.js.gz +0 -0
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/ui-react.d.ts +850 -68
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/checkpoints.js +1 -1
- package/lib/umd/checkpoints.js.gz +0 -0
- package/lib/umd/common.js +1 -1
- package/lib/umd/common.js.gz +0 -0
- package/lib/umd/indexes.js +1 -1
- package/lib/umd/indexes.js.gz +0 -0
- package/lib/umd/metrics.js +1 -1
- package/lib/umd/metrics.js.gz +0 -0
- package/lib/umd/queries.js +1 -1
- package/lib/umd/queries.js.gz +0 -0
- package/lib/umd/relationships.js +1 -1
- package/lib/umd/relationships.js.gz +0 -0
- package/lib/umd/store.js +1 -1
- package/lib/umd/store.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.js.gz +0 -0
- package/package.json +28 -27
- package/readme.md +11 -11
package/lib/debug/ui-react.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* @see Building UIs With Checkpoints guide
|
|
18
18
|
* @see Countries demo
|
|
19
19
|
* @see Todo App demos
|
|
20
|
-
* @see
|
|
20
|
+
* @see Drawing demo
|
|
21
21
|
* @packageDocumentation
|
|
22
22
|
* @module ui-react
|
|
23
23
|
*/
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
Row,
|
|
32
32
|
RowIdsListener,
|
|
33
33
|
RowListener,
|
|
34
|
+
SortedRowIdsListener,
|
|
34
35
|
Store,
|
|
35
36
|
Table,
|
|
36
37
|
TableIdsListener,
|
|
@@ -153,6 +154,7 @@ export type RelationshipsOrRelationshipsId = Relationships | Id;
|
|
|
153
154
|
* parameter or a prop, allowing you to pass in either the Store or its Id.
|
|
154
155
|
*
|
|
155
156
|
* @category Identity
|
|
157
|
+
* @since v2.0.0
|
|
156
158
|
*/
|
|
157
159
|
export type QueriesOrQueriesId = Queries | Id;
|
|
158
160
|
|
|
@@ -426,9 +428,6 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
|
|
|
426
428
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
427
429
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
428
430
|
* reference.
|
|
429
|
-
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
430
|
-
* listener should be called if the set of Ids remains the same but their order
|
|
431
|
-
* changes. See the addTableIdsListener method for more details.
|
|
432
431
|
* @returns An array of the Ids of every Table in the Store.
|
|
433
432
|
* @example
|
|
434
433
|
* This example creates a Store outside the application, which is used in the
|
|
@@ -486,10 +485,7 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
|
|
|
486
485
|
* ```
|
|
487
486
|
* @category Store hooks
|
|
488
487
|
*/
|
|
489
|
-
export function useTableIds(
|
|
490
|
-
storeOrStoreId?: StoreOrStoreId,
|
|
491
|
-
trackReorder?: boolean,
|
|
492
|
-
): Ids;
|
|
488
|
+
export function useTableIds(storeOrStoreId?: StoreOrStoreId): Ids;
|
|
493
489
|
|
|
494
490
|
/**
|
|
495
491
|
* The useTable hook returns an object containing the entire data of a single
|
|
@@ -590,9 +586,6 @@ export function useTable(tableId: Id, storeOrStoreId?: StoreOrStoreId): Table;
|
|
|
590
586
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
591
587
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
592
588
|
* reference.
|
|
593
|
-
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
594
|
-
* listener should be called if the set of Ids remains the same but their order
|
|
595
|
-
* changes. See the addRowIdsListener method for more details.
|
|
596
589
|
* @returns An array of the Ids of every Row in the Table.
|
|
597
590
|
* @example
|
|
598
591
|
* This example creates a Store outside the application, which is used in the
|
|
@@ -652,10 +645,124 @@ export function useTable(tableId: Id, storeOrStoreId?: StoreOrStoreId): Table;
|
|
|
652
645
|
* ```
|
|
653
646
|
* @category Store hooks
|
|
654
647
|
*/
|
|
655
|
-
export function useRowIds(
|
|
648
|
+
export function useRowIds(tableId: Id, storeOrStoreId?: StoreOrStoreId): Ids;
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* The useSortedRowIds hook returns the sorted (and optionally, paginated) Ids
|
|
652
|
+
* of every Row in a given Table, and registers a listener so that any changes
|
|
653
|
+
* to that result will cause a re-render.
|
|
654
|
+
*
|
|
655
|
+
* A Provider component is used to wrap part of an application in a context, and
|
|
656
|
+
* it can contain a default Store or a set of Store objects named by Id. The
|
|
657
|
+
* useSortedRowIds hook lets you indicate which Store to get data for: omit the
|
|
658
|
+
* optional final parameter for the default context Store, provide an Id for a
|
|
659
|
+
* named context Store, or provide a Store explicitly by reference.
|
|
660
|
+
*
|
|
661
|
+
* When first rendered, this hook will create a listener so that changes to the
|
|
662
|
+
* sorted Row Ids will cause a re-render. When the component containing this
|
|
663
|
+
* hook is unmounted, the listener will be automatically removed.
|
|
664
|
+
*
|
|
665
|
+
* @param tableId The Id of the Table in the Store.
|
|
666
|
+
* @param cellId The Id of the Cell whose values are used for the sorting, or
|
|
667
|
+
* `undefined` to by sort the Row Id itself.
|
|
668
|
+
* @param descending Whether the sorting should be in descending order.
|
|
669
|
+
* @param offset The number of Row Ids to skip for pagination purposes, if any.
|
|
670
|
+
* @param limit The maximum number of Row Ids to return, or `undefined` for all.
|
|
671
|
+
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
672
|
+
* Store, provide an Id for a named context Store, or provide an explicit
|
|
673
|
+
* reference.
|
|
674
|
+
* @returns An array of the sorted Ids of every Row in the Table.
|
|
675
|
+
* @example
|
|
676
|
+
* This example creates a Store outside the application, which is used in the
|
|
677
|
+
* useSortedRowIds hook by reference. A change to the data in the Store
|
|
678
|
+
* re-renders the component.
|
|
679
|
+
*
|
|
680
|
+
* ```jsx
|
|
681
|
+
* const store = createStore().setTables({
|
|
682
|
+
* pets: {
|
|
683
|
+
* fido: {species: 'dog'},
|
|
684
|
+
* felix: {species: 'cat'},
|
|
685
|
+
* },
|
|
686
|
+
* });
|
|
687
|
+
* const App = () => (
|
|
688
|
+
* <span>
|
|
689
|
+
* {JSON.stringify(
|
|
690
|
+
* useSortedRowIds('pets', 'species', false, 0, undefined, store),
|
|
691
|
+
* )}
|
|
692
|
+
* </span>
|
|
693
|
+
* );
|
|
694
|
+
*
|
|
695
|
+
* const app = document.createElement('div');
|
|
696
|
+
* ReactDOM.render(<App />, app); // !act
|
|
697
|
+
* console.log(app.innerHTML);
|
|
698
|
+
* // -> '<span>["felix","fido"]</span>'
|
|
699
|
+
*
|
|
700
|
+
* store.setRow('pets', 'cujo', {species: 'wolf'}); // !act
|
|
701
|
+
* console.log(app.innerHTML);
|
|
702
|
+
* // -> '<span>["felix","fido","cujo"]</span>'
|
|
703
|
+
* ```
|
|
704
|
+
* @example
|
|
705
|
+
* This example creates a Provider context into which a default Store is
|
|
706
|
+
* provided. A component within it then uses the useSortedRowIds hook.
|
|
707
|
+
*
|
|
708
|
+
* ```jsx
|
|
709
|
+
* const App = ({store}) => (
|
|
710
|
+
* <Provider store={store}>
|
|
711
|
+
* <Pane />
|
|
712
|
+
* </Provider>
|
|
713
|
+
* );
|
|
714
|
+
* const Pane = () => <span>{JSON.stringify(useSortedRowIds('pets'))}</span>;
|
|
715
|
+
*
|
|
716
|
+
* const store = createStore().setTables({
|
|
717
|
+
* pets: {
|
|
718
|
+
* fido: {species: 'dog'},
|
|
719
|
+
* felix: {species: 'cat'},
|
|
720
|
+
* },
|
|
721
|
+
* });
|
|
722
|
+
* const app = document.createElement('div');
|
|
723
|
+
* ReactDOM.render(<App store={store} />, app); // !act
|
|
724
|
+
* console.log(app.innerHTML);
|
|
725
|
+
* // -> '<span>["felix","fido"]</span>'
|
|
726
|
+
* ```
|
|
727
|
+
* @example
|
|
728
|
+
* This example creates a Provider context into which a Store is provided, named
|
|
729
|
+
* by Id. A component within it then uses the useSortedRowIds hook.
|
|
730
|
+
*
|
|
731
|
+
* ```jsx
|
|
732
|
+
* const App = ({store}) => (
|
|
733
|
+
* <Provider storesById={{petStore: store}}>
|
|
734
|
+
* <Pane />
|
|
735
|
+
* </Provider>
|
|
736
|
+
* );
|
|
737
|
+
* const Pane = () => (
|
|
738
|
+
* <span>
|
|
739
|
+
* {JSON.stringify(
|
|
740
|
+
* useSortedRowIds('pets', 'species', false, 0, undefined, 'petStore'),
|
|
741
|
+
* )}
|
|
742
|
+
* </span>
|
|
743
|
+
* );
|
|
744
|
+
*
|
|
745
|
+
* const store = createStore().setTables({
|
|
746
|
+
* pets: {
|
|
747
|
+
* fido: {species: 'dog'},
|
|
748
|
+
* felix: {species: 'cat'},
|
|
749
|
+
* },
|
|
750
|
+
* });
|
|
751
|
+
* const app = document.createElement('div');
|
|
752
|
+
* ReactDOM.render(<App store={store} />, app); // !act
|
|
753
|
+
* console.log(app.innerHTML);
|
|
754
|
+
* // -> '<span>["felix","fido"]</span>'
|
|
755
|
+
* ```
|
|
756
|
+
* @category Store hooks
|
|
757
|
+
* @since v2.0.0
|
|
758
|
+
*/
|
|
759
|
+
export function useSortedRowIds(
|
|
656
760
|
tableId: Id,
|
|
761
|
+
cellId?: Id,
|
|
762
|
+
descending?: boolean,
|
|
763
|
+
offset?: number,
|
|
764
|
+
limit?: number,
|
|
657
765
|
storeOrStoreId?: StoreOrStoreId,
|
|
658
|
-
trackReorder?: boolean,
|
|
659
766
|
): Ids;
|
|
660
767
|
|
|
661
768
|
/**
|
|
@@ -765,9 +872,6 @@ export function useRow(
|
|
|
765
872
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
766
873
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
767
874
|
* reference.
|
|
768
|
-
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
769
|
-
* listener should be called if the set of Ids remains the same but their order
|
|
770
|
-
* changes. See the addCellIdsListener method for more details.
|
|
771
875
|
* @returns An array of the Ids of every Cell in the Row.
|
|
772
876
|
* @example
|
|
773
877
|
* This example creates a Store outside the application, which is used in the
|
|
@@ -835,7 +939,6 @@ export function useCellIds(
|
|
|
835
939
|
tableId: Id,
|
|
836
940
|
rowId: Id,
|
|
837
941
|
storeOrStoreId?: StoreOrStoreId,
|
|
838
|
-
trackReorder?: boolean,
|
|
839
942
|
): Ids;
|
|
840
943
|
|
|
841
944
|
/**
|
|
@@ -1842,9 +1945,6 @@ export function useTablesListener(
|
|
|
1842
1945
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
1843
1946
|
* function, which, if any change, result in the re-registration of the
|
|
1844
1947
|
* listener. This parameter defaults to an empty array.
|
|
1845
|
-
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
1846
|
-
* listener should be called if the set of Ids remains the same but their order
|
|
1847
|
-
* changes. See the addTableIdsListener method for more details.
|
|
1848
1948
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
1849
1949
|
* Store data.
|
|
1850
1950
|
* @param storeOrStoreId The Store to register the listener with: omit for the
|
|
@@ -1884,7 +1984,6 @@ export function useTablesListener(
|
|
|
1884
1984
|
export function useTableIdsListener(
|
|
1885
1985
|
listener: TableIdsListener,
|
|
1886
1986
|
listenerDeps?: React.DependencyList,
|
|
1887
|
-
trackReorder?: boolean,
|
|
1888
1987
|
mutator?: boolean,
|
|
1889
1988
|
storeOrStoreId?: StoreOrStoreId,
|
|
1890
1989
|
): void;
|
|
@@ -1977,9 +2076,6 @@ export function useTableListener(
|
|
|
1977
2076
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
1978
2077
|
* function, which, if any change, result in the re-registration of the
|
|
1979
2078
|
* listener. This parameter defaults to an empty array.
|
|
1980
|
-
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
1981
|
-
* listener should be called if the set of Ids remains the same but their order
|
|
1982
|
-
* changes. See the addRowIdsListener method for more details.
|
|
1983
2079
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
1984
2080
|
* Store data.
|
|
1985
2081
|
* @param storeOrStoreId The Store to register the listener with: omit for the
|
|
@@ -2020,7 +2116,88 @@ export function useRowIdsListener(
|
|
|
2020
2116
|
tableId: IdOrNull,
|
|
2021
2117
|
listener: RowIdsListener,
|
|
2022
2118
|
listenerDeps?: React.DependencyList,
|
|
2023
|
-
|
|
2119
|
+
mutator?: boolean,
|
|
2120
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
2121
|
+
): void;
|
|
2122
|
+
|
|
2123
|
+
/**
|
|
2124
|
+
* The useSortedRowIdsListener hook registers a listener function with a Store
|
|
2125
|
+
* that will be called whenever sorted (and optionally, paginated) Row Ids in a
|
|
2126
|
+
* Table change.
|
|
2127
|
+
*
|
|
2128
|
+
* This hook is useful for situations where a component needs to register its
|
|
2129
|
+
* own specific listener to do more than simply tracking the value (which is
|
|
2130
|
+
* more easily done with the useSortedRowIds hook).
|
|
2131
|
+
*
|
|
2132
|
+
* Unlike the addSortedRowIdsListener method, which returns a listener Id and
|
|
2133
|
+
* requires you to remove it manually, the useSortedRowIdsListener hook manages
|
|
2134
|
+
* this lifecycle for you: when the listener changes (per its `listenerDeps`
|
|
2135
|
+
* dependencies) or the component unmounts, the listener on the underlying Store
|
|
2136
|
+
* will be deleted.
|
|
2137
|
+
*
|
|
2138
|
+
* @param tableId The Id of the Table in the Store.
|
|
2139
|
+
* @param cellId The Id of the Cell whose values are used for the sorting, or
|
|
2140
|
+
* `undefined` to by sort the Row Id itself.
|
|
2141
|
+
* @param descending Whether the sorting should be in descending order.
|
|
2142
|
+
* @param offset The number of Row Ids to skip for pagination purposes, if any.
|
|
2143
|
+
* @param limit The maximum number of Row Ids to return, or `undefined` for all.
|
|
2144
|
+
* @param listener The function that will be called whenever the sorted Row Ids
|
|
2145
|
+
* in the Table change.
|
|
2146
|
+
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
2147
|
+
* function, which, if any change, result in the re-registration of the
|
|
2148
|
+
* listener. This parameter defaults to an empty array.
|
|
2149
|
+
* @param mutator An optional boolean that indicates that the listener mutates
|
|
2150
|
+
* Store data.
|
|
2151
|
+
* @param storeOrStoreId The Store to register the listener with: omit for the
|
|
2152
|
+
* default context Store, provide an Id for a named context Store, or provide an
|
|
2153
|
+
* explicit reference.
|
|
2154
|
+
* @example
|
|
2155
|
+
* This example uses the useSortedRowIdsListener hook to create a listener that
|
|
2156
|
+
* is scoped to a single component. When the component is unmounted, the
|
|
2157
|
+
* listener is removed from the Store.
|
|
2158
|
+
*
|
|
2159
|
+
* ```jsx
|
|
2160
|
+
* const App = ({store}) => (
|
|
2161
|
+
* <Provider store={store}>
|
|
2162
|
+
* <Pane />
|
|
2163
|
+
* </Provider>
|
|
2164
|
+
* );
|
|
2165
|
+
* const Pane = () => {
|
|
2166
|
+
* useSortedRowIdsListener('pets', 'species', false, 0, undefined, () =>
|
|
2167
|
+
* console.log('Sorted Row Ids changed'),
|
|
2168
|
+
* );
|
|
2169
|
+
* return <span>App</span>;
|
|
2170
|
+
* };
|
|
2171
|
+
*
|
|
2172
|
+
* const store = createStore().setTables({
|
|
2173
|
+
* pets: {
|
|
2174
|
+
* fido: {species: 'dog'},
|
|
2175
|
+
* felix: {species: 'cat'},
|
|
2176
|
+
* },
|
|
2177
|
+
* });
|
|
2178
|
+
* const app = document.createElement('div');
|
|
2179
|
+
* ReactDOM.render(<App store={store} />, app); // !act
|
|
2180
|
+
* console.log(store.getListenerStats().sortedRowIds);
|
|
2181
|
+
* // -> 1
|
|
2182
|
+
*
|
|
2183
|
+
* store.setRow('pets', 'cujo', {species: 'wolf'}); // !act
|
|
2184
|
+
* // -> 'Sorted Row Ids changed'
|
|
2185
|
+
*
|
|
2186
|
+
* ReactDOM.unmountComponentAtNode(app); // !act
|
|
2187
|
+
* console.log(store.getListenerStats().sortedRowIds);
|
|
2188
|
+
* // -> 0
|
|
2189
|
+
* ```
|
|
2190
|
+
* @category Store hooks
|
|
2191
|
+
* @since v2.0.0
|
|
2192
|
+
*/
|
|
2193
|
+
export function useSortedRowIdsListener(
|
|
2194
|
+
tableId: Id,
|
|
2195
|
+
cellId: Id | undefined,
|
|
2196
|
+
descending: boolean,
|
|
2197
|
+
offset: number,
|
|
2198
|
+
limit: number | undefined,
|
|
2199
|
+
listener: SortedRowIdsListener,
|
|
2200
|
+
listenerDeps?: React.DependencyList,
|
|
2024
2201
|
mutator?: boolean,
|
|
2025
2202
|
storeOrStoreId?: StoreOrStoreId,
|
|
2026
2203
|
): void;
|
|
@@ -2129,9 +2306,6 @@ export function useRowListener(
|
|
|
2129
2306
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
2130
2307
|
* function, which, if any change, result in the re-registration of the
|
|
2131
2308
|
* listener. This parameter defaults to an empty array.
|
|
2132
|
-
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
2133
|
-
* listener should be called if the set of Ids remains the same but their order
|
|
2134
|
-
* changes. See the addCellIdsListener method for more details.
|
|
2135
2309
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
2136
2310
|
* Store data.
|
|
2137
2311
|
* @param storeOrStoreId The Store to register the listener with: omit for the
|
|
@@ -2175,7 +2349,6 @@ export function useCellIdsListener(
|
|
|
2175
2349
|
rowId: IdOrNull,
|
|
2176
2350
|
listener: CellIdsListener,
|
|
2177
2351
|
listenerDeps?: React.DependencyList,
|
|
2178
|
-
trackReorder?: boolean,
|
|
2179
2352
|
mutator?: boolean,
|
|
2180
2353
|
storeOrStoreId?: StoreOrStoreId,
|
|
2181
2354
|
): void;
|
|
@@ -4065,7 +4238,7 @@ export function useLinkedRowIdsListener(
|
|
|
4065
4238
|
* // -> '<span>brown</span>'
|
|
4066
4239
|
* ```
|
|
4067
4240
|
* @category Queries hooks
|
|
4068
|
-
* @since v2.0.0
|
|
4241
|
+
* @since v2.0.0
|
|
4069
4242
|
*/
|
|
4070
4243
|
export function useCreateQueries(
|
|
4071
4244
|
store: Store,
|
|
@@ -4133,6 +4306,7 @@ export function useCreateQueries(
|
|
|
4133
4306
|
* // -> '<span>0</span>'
|
|
4134
4307
|
* ```
|
|
4135
4308
|
* @category Queries hooks
|
|
4309
|
+
* @since v2.0.0
|
|
4136
4310
|
*/
|
|
4137
4311
|
export function useQueries(id?: Id): Queries | undefined;
|
|
4138
4312
|
|
|
@@ -4249,6 +4423,7 @@ export function useQueries(id?: Id): Queries | undefined;
|
|
|
4249
4423
|
* // -> '<span>{"fido":{"color":"brown"},"cujo":{"color":"black"}}</span>'
|
|
4250
4424
|
* ```
|
|
4251
4425
|
* @category Queries hooks
|
|
4426
|
+
* @since v2.0.0
|
|
4252
4427
|
*/
|
|
4253
4428
|
export function useResultTable(
|
|
4254
4429
|
queryId: Id,
|
|
@@ -4275,8 +4450,6 @@ export function useResultTable(
|
|
|
4275
4450
|
* @param queriesOrQueriesId The Queries object to be accessed: omit for the
|
|
4276
4451
|
* default context Queries object, provide an Id for a named context Queries
|
|
4277
4452
|
* object, or provide an explicit reference.
|
|
4278
|
-
* @param trackReorder An optional boolean that indicates that the listener
|
|
4279
|
-
* should be called if the set of Ids remains the same but their order changes.
|
|
4280
4453
|
* See the addResultRowIdsListener method for more details.
|
|
4281
4454
|
* @returns An array of the Ids of every Row in the result of the query.
|
|
4282
4455
|
* @example
|
|
@@ -4371,11 +4544,164 @@ export function useResultTable(
|
|
|
4371
4544
|
* // -> '<span>["fido","cujo"]</span>'
|
|
4372
4545
|
* ```
|
|
4373
4546
|
* @category Queries hooks
|
|
4547
|
+
* @since v2.0.0
|
|
4374
4548
|
*/
|
|
4375
4549
|
export function useResultRowIds(
|
|
4376
4550
|
queryId: Id,
|
|
4377
4551
|
queriesOrQueriesId?: QueriesOrQueriesId,
|
|
4378
|
-
|
|
4552
|
+
): Ids;
|
|
4553
|
+
|
|
4554
|
+
/**
|
|
4555
|
+
* The useResultSortedRowIds hook returns the sorted (and optionally, paginated)
|
|
4556
|
+
* Ids of every Row in the result Table of the given query, and registers a
|
|
4557
|
+
* listener so that any changes to those Ids will cause a re-render.
|
|
4558
|
+
*
|
|
4559
|
+
* A Provider component is used to wrap part of an application in a context, and
|
|
4560
|
+
* it can contain a default Queries object or a set of Queries objects named by
|
|
4561
|
+
* Id. The useResultSortedRowIds hook lets you indicate which Queries object to
|
|
4562
|
+
* get data for: omit the final optional final parameter for the default context
|
|
4563
|
+
* Queries object, provide an Id for a named context Queries object, or provide
|
|
4564
|
+
* a Queries object explicitly by reference.
|
|
4565
|
+
*
|
|
4566
|
+
* When first rendered, this hook will create a listener so that changes to the
|
|
4567
|
+
* sorted result Row Ids will cause a re-render. When the component containing
|
|
4568
|
+
* this hook is unmounted, the listener will be automatically removed.
|
|
4569
|
+
*
|
|
4570
|
+
* @param queryId The Id of the query.
|
|
4571
|
+
* @param cellId The Id of the result Cell whose values are used for the
|
|
4572
|
+
* sorting, or `undefined` to by sort the result Row Id itself.
|
|
4573
|
+
* @param descending Whether the sorting should be in descending order.
|
|
4574
|
+
* @param offset The number of Row Ids to skip for pagination purposes, if any.
|
|
4575
|
+
* @param limit The maximum number of Row Ids to return, or `undefined` for all.
|
|
4576
|
+
* @param queriesOrQueriesId The Queries object to be accessed: omit for the
|
|
4577
|
+
* default context Queries object, provide an Id for a named context Queries
|
|
4578
|
+
* object, or provide an explicit reference.
|
|
4579
|
+
* @returns An array of the Ids of every Row in the result of the query.
|
|
4580
|
+
* @example
|
|
4581
|
+
* This example creates a Queries object outside the application, which is used
|
|
4582
|
+
* in the useResultSortedRowIds hook by reference. A change to the data in the
|
|
4583
|
+
* query re-renders the component.
|
|
4584
|
+
*
|
|
4585
|
+
* ```jsx
|
|
4586
|
+
* const store = createStore().setTable('pets', {
|
|
4587
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
4588
|
+
* felix: {species: 'cat', color: 'black'},
|
|
4589
|
+
* cujo: {species: 'dog', color: 'black'},
|
|
4590
|
+
* });
|
|
4591
|
+
* const queries = createQueries(store).setQueryDefinition(
|
|
4592
|
+
* 'dogColors',
|
|
4593
|
+
* 'pets',
|
|
4594
|
+
* ({select, where}) => {
|
|
4595
|
+
* select('color');
|
|
4596
|
+
* where('species', 'dog');
|
|
4597
|
+
* },
|
|
4598
|
+
* );
|
|
4599
|
+
* const App = () => (
|
|
4600
|
+
* <span>
|
|
4601
|
+
* {JSON.stringify(
|
|
4602
|
+
* useResultSortedRowIds(
|
|
4603
|
+
* 'dogColors',
|
|
4604
|
+
* 'color',
|
|
4605
|
+
* false,
|
|
4606
|
+
* 0,
|
|
4607
|
+
* undefined,
|
|
4608
|
+
* queries,
|
|
4609
|
+
* ),
|
|
4610
|
+
* )}
|
|
4611
|
+
* </span>
|
|
4612
|
+
* );
|
|
4613
|
+
*
|
|
4614
|
+
* const app = document.createElement('div');
|
|
4615
|
+
* ReactDOM.render(<App />, app); // !act
|
|
4616
|
+
* console.log(app.innerHTML);
|
|
4617
|
+
* // -> '<span>["cujo","fido"]</span>'
|
|
4618
|
+
*
|
|
4619
|
+
* store.setCell('pets', 'cujo', 'species', 'wolf'); // !act
|
|
4620
|
+
* console.log(app.innerHTML);
|
|
4621
|
+
* // -> '<span>["fido"]</span>'
|
|
4622
|
+
* ```
|
|
4623
|
+
* @example
|
|
4624
|
+
* This example creates a Provider context into which a default Queries object
|
|
4625
|
+
* is provided. A component within it then uses the useResultSortedRowIds hook.
|
|
4626
|
+
*
|
|
4627
|
+
* ```jsx
|
|
4628
|
+
* const App = ({queries}) => (
|
|
4629
|
+
* <Provider queries={queries}>
|
|
4630
|
+
* <Pane />
|
|
4631
|
+
* </Provider>
|
|
4632
|
+
* );
|
|
4633
|
+
* const Pane = () => (
|
|
4634
|
+
* <span>
|
|
4635
|
+
* {JSON.stringify(useResultSortedRowIds('dogColors', 'color'))}
|
|
4636
|
+
* </span>
|
|
4637
|
+
* );
|
|
4638
|
+
*
|
|
4639
|
+
* const queries = createQueries(
|
|
4640
|
+
* createStore().setTable('pets', {
|
|
4641
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
4642
|
+
* felix: {species: 'cat', color: 'black'},
|
|
4643
|
+
* cujo: {species: 'dog', color: 'black'},
|
|
4644
|
+
* }),
|
|
4645
|
+
* ).setQueryDefinition('dogColors', 'pets', ({select, where}) => {
|
|
4646
|
+
* select('color');
|
|
4647
|
+
* where('species', 'dog');
|
|
4648
|
+
* });
|
|
4649
|
+
* const app = document.createElement('div');
|
|
4650
|
+
* ReactDOM.render(<App queries={queries} />, app); // !act
|
|
4651
|
+
* console.log(app.innerHTML);
|
|
4652
|
+
* // -> '<span>["cujo","fido"]</span>'
|
|
4653
|
+
* ```
|
|
4654
|
+
* @example
|
|
4655
|
+
* This example creates a Provider context into which a Queries object is
|
|
4656
|
+
* provided, named by Id. A component within it then uses the
|
|
4657
|
+
* useResultSortedRowIds hook.
|
|
4658
|
+
*
|
|
4659
|
+
* ```jsx
|
|
4660
|
+
* const App = ({queries}) => (
|
|
4661
|
+
* <Provider queriesById={{petQueries: queries}}>
|
|
4662
|
+
* <Pane />
|
|
4663
|
+
* </Provider>
|
|
4664
|
+
* );
|
|
4665
|
+
* const Pane = () => (
|
|
4666
|
+
* <span>
|
|
4667
|
+
* {JSON.stringify(
|
|
4668
|
+
* useResultSortedRowIds(
|
|
4669
|
+
* 'dogColors',
|
|
4670
|
+
* 'color',
|
|
4671
|
+
* false,
|
|
4672
|
+
* 0,
|
|
4673
|
+
* undefined,
|
|
4674
|
+
* 'petQueries',
|
|
4675
|
+
* ),
|
|
4676
|
+
* )}
|
|
4677
|
+
* </span>
|
|
4678
|
+
* );
|
|
4679
|
+
*
|
|
4680
|
+
* const queries = createQueries(
|
|
4681
|
+
* createStore().setTable('pets', {
|
|
4682
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
4683
|
+
* felix: {species: 'cat', color: 'black'},
|
|
4684
|
+
* cujo: {species: 'dog', color: 'black'},
|
|
4685
|
+
* }),
|
|
4686
|
+
* ).setQueryDefinition('dogColors', 'pets', ({select, where}) => {
|
|
4687
|
+
* select('color');
|
|
4688
|
+
* where('species', 'dog');
|
|
4689
|
+
* });
|
|
4690
|
+
* const app = document.createElement('div');
|
|
4691
|
+
* ReactDOM.render(<App queries={queries} />, app); // !act
|
|
4692
|
+
* console.log(app.innerHTML);
|
|
4693
|
+
* // -> '<span>["cujo","fido"]</span>'
|
|
4694
|
+
* ```
|
|
4695
|
+
* @category Queries hooks
|
|
4696
|
+
* @since v2.0.0
|
|
4697
|
+
*/
|
|
4698
|
+
export function useResultSortedRowIds(
|
|
4699
|
+
queryId: Id,
|
|
4700
|
+
cellId?: Id,
|
|
4701
|
+
descending?: boolean,
|
|
4702
|
+
offset?: number,
|
|
4703
|
+
limit?: number,
|
|
4704
|
+
queriesOrQueriesId?: QueriesOrQueriesId,
|
|
4379
4705
|
): Ids;
|
|
4380
4706
|
|
|
4381
4707
|
/**
|
|
@@ -4495,6 +4821,7 @@ export function useResultRowIds(
|
|
|
4495
4821
|
* // -> '<span>{"color":"brown"}</span>'
|
|
4496
4822
|
* ```
|
|
4497
4823
|
* @category Queries hooks
|
|
4824
|
+
* @since v2.0.0
|
|
4498
4825
|
*/
|
|
4499
4826
|
export function useResultRow(
|
|
4500
4827
|
queryId: Id,
|
|
@@ -4625,6 +4952,7 @@ export function useResultRow(
|
|
|
4625
4952
|
* // -> '<span>["species","color"]</span>'
|
|
4626
4953
|
* ```
|
|
4627
4954
|
* @category Queries hooks
|
|
4955
|
+
* @since v2.0.0
|
|
4628
4956
|
*/
|
|
4629
4957
|
export function useResultCellIds(
|
|
4630
4958
|
queryId: Id,
|
|
@@ -4751,6 +5079,7 @@ export function useResultCellIds(
|
|
|
4751
5079
|
* // -> '<span>brown</span>'
|
|
4752
5080
|
* ```
|
|
4753
5081
|
* @category Queries hooks
|
|
5082
|
+
* @since v2.0.0
|
|
4754
5083
|
*/
|
|
4755
5084
|
export function useResultCell(
|
|
4756
5085
|
queryId: Id,
|
|
@@ -4827,6 +5156,7 @@ export function useResultCell(
|
|
|
4827
5156
|
* // -> 0
|
|
4828
5157
|
* ```
|
|
4829
5158
|
* @category Queries hooks
|
|
5159
|
+
* @since v2.0.0
|
|
4830
5160
|
*/
|
|
4831
5161
|
export function useResultTableListener(
|
|
4832
5162
|
queryId: IdOrNull,
|
|
@@ -4859,9 +5189,6 @@ export function useResultTableListener(
|
|
|
4859
5189
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
4860
5190
|
* function, which, if any change, result in the re-registration of the
|
|
4861
5191
|
* listener. This parameter defaults to an empty array.
|
|
4862
|
-
* @param trackReorder An optional boolean that indicates that the listener
|
|
4863
|
-
* should be called if the set of Ids remains the same but their order changes.
|
|
4864
|
-
* See the addResultRowIdsListener method for more details.
|
|
4865
5192
|
* @param queriesOrQueriesId The Queries object to register the listener with:
|
|
4866
5193
|
* omit for the default context Queries object, provide an Id for a named
|
|
4867
5194
|
* context Queries object, or provide an explicit reference.
|
|
@@ -4878,7 +5205,7 @@ export function useResultTableListener(
|
|
|
4878
5205
|
* );
|
|
4879
5206
|
* const Pane = () => {
|
|
4880
5207
|
* useResultRowIdsListener('petColors', () =>
|
|
4881
|
-
* console.log('Result
|
|
5208
|
+
* console.log('Result Row Ids changed'),
|
|
4882
5209
|
* );
|
|
4883
5210
|
* return <span>App</span>;
|
|
4884
5211
|
* };
|
|
@@ -4899,25 +5226,113 @@ export function useResultTableListener(
|
|
|
4899
5226
|
* // -> 1
|
|
4900
5227
|
*
|
|
4901
5228
|
* store.setRow('pets', 'rex', {species: 'dog', color: 'tan'}); // !act
|
|
4902
|
-
* // -> 'Result
|
|
5229
|
+
* // -> 'Result Row Ids changed'
|
|
4903
5230
|
*
|
|
4904
5231
|
* ReactDOM.unmountComponentAtNode(app); // !act
|
|
4905
5232
|
* console.log(queries.getListenerStats().rowIds);
|
|
4906
5233
|
* // -> 0
|
|
4907
5234
|
* ```
|
|
4908
5235
|
* @category Queries hooks
|
|
5236
|
+
* @since v2.0.0
|
|
4909
5237
|
*/
|
|
4910
5238
|
export function useResultRowIdsListener(
|
|
4911
5239
|
queryId: IdOrNull,
|
|
4912
5240
|
listener: ResultRowIdsListener,
|
|
4913
5241
|
listenerDeps?: React.DependencyList,
|
|
4914
|
-
trackReorder?: boolean,
|
|
4915
5242
|
queriesOrQueriesId?: QueriesOrQueriesId,
|
|
4916
5243
|
): void;
|
|
4917
5244
|
|
|
4918
5245
|
/**
|
|
4919
|
-
* The
|
|
4920
|
-
* object that will be called whenever
|
|
5246
|
+
* The useResultSortedRowIdsListener hook registers a listener function with a
|
|
5247
|
+
* Queries object that will be called whenever the sorted (and optionally,
|
|
5248
|
+
* paginated) Row Ids in a result Table change.
|
|
5249
|
+
*
|
|
5250
|
+
* This hook is useful for situations where a component needs to register its
|
|
5251
|
+
* own specific listener to do more than simply tracking the value (which is
|
|
5252
|
+
* more easily done with the useResultSortedRowIds hook).
|
|
5253
|
+
*
|
|
5254
|
+
* Unlike the addResultSortedRowIdsListener method, which returns a listener Id
|
|
5255
|
+
* and requires you to remove it manually, the useResultSortedRowIdsListener
|
|
5256
|
+
* hook manages this lifecycle for you: when the listener changes (per its
|
|
5257
|
+
* `listenerDeps` dependencies) or the component unmounts, the listener on the
|
|
5258
|
+
* underlying Queries object will be deleted.
|
|
5259
|
+
*
|
|
5260
|
+
* @param queryId The Id of the query to listen to.
|
|
5261
|
+
* @param cellId The Id of the Cell whose values are used for the sorting, or
|
|
5262
|
+
* `undefined` to by sort the Row Id itself.
|
|
5263
|
+
* @param descending Whether the sorting should be in descending order.
|
|
5264
|
+
* @param offset The number of Row Ids to skip for pagination purposes, if any.
|
|
5265
|
+
* @param limit The maximum number of Row Ids to return, or `undefined` for all.
|
|
5266
|
+
* @param listener The function that will be called whenever the Row Ids in the
|
|
5267
|
+
* matching result Table change.
|
|
5268
|
+
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
5269
|
+
* function, which, if any change, result in the re-registration of the
|
|
5270
|
+
* listener. This parameter defaults to an empty array.
|
|
5271
|
+
* @param queriesOrQueriesId The Queries object to register the listener with:
|
|
5272
|
+
* omit for the default context Queries object, provide an Id for a named
|
|
5273
|
+
* context Queries object, or provide an explicit reference.
|
|
5274
|
+
* @example
|
|
5275
|
+
* This example uses the useResultSortedRowIdsListener hook to create a listener
|
|
5276
|
+
* that is scoped to a single component. When the component is unmounted, the
|
|
5277
|
+
* listener is removed from the Queries object.
|
|
5278
|
+
*
|
|
5279
|
+
* ```jsx
|
|
5280
|
+
* const App = ({queries}) => (
|
|
5281
|
+
* <Provider queries={queries}>
|
|
5282
|
+
* <Pane />
|
|
5283
|
+
* </Provider>
|
|
5284
|
+
* );
|
|
5285
|
+
* const Pane = () => {
|
|
5286
|
+
* useResultSortedRowIdsListener(
|
|
5287
|
+
* 'petColors',
|
|
5288
|
+
* 'color',
|
|
5289
|
+
* false,
|
|
5290
|
+
* 0,
|
|
5291
|
+
* undefined,
|
|
5292
|
+
* () => console.log('Sorted result Row Ids changed'),
|
|
5293
|
+
* );
|
|
5294
|
+
* return <span>App</span>;
|
|
5295
|
+
* };
|
|
5296
|
+
*
|
|
5297
|
+
* const store = createStore().setTable('pets', {
|
|
5298
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
5299
|
+
* felix: {species: 'cat', color: 'black'},
|
|
5300
|
+
* cujo: {species: 'dog', color: 'black'},
|
|
5301
|
+
* });
|
|
5302
|
+
* const queries = createQueries(store).setQueryDefinition(
|
|
5303
|
+
* 'petColors',
|
|
5304
|
+
* 'pets',
|
|
5305
|
+
* ({select}) => select('color'),
|
|
5306
|
+
* );
|
|
5307
|
+
* const app = document.createElement('div');
|
|
5308
|
+
* ReactDOM.render(<App queries={queries} />, app); // !act
|
|
5309
|
+
* console.log(queries.getListenerStats().sortedRowIds);
|
|
5310
|
+
* // -> 1
|
|
5311
|
+
*
|
|
5312
|
+
* store.setRow('pets', 'cujo', {color: 'tan'}); // !act
|
|
5313
|
+
* // -> 'Sorted result Row Ids changed'
|
|
5314
|
+
*
|
|
5315
|
+
* ReactDOM.unmountComponentAtNode(app); // !act
|
|
5316
|
+
* console.log(queries.getListenerStats().sortedRowIds);
|
|
5317
|
+
* // -> 0
|
|
5318
|
+
* ```
|
|
5319
|
+
* @category Queries hooks
|
|
5320
|
+
* @since v2.0.0
|
|
5321
|
+
*/
|
|
5322
|
+
export function useResultSortedRowIdsListener(
|
|
5323
|
+
queryId: Id,
|
|
5324
|
+
cellId: Id | undefined,
|
|
5325
|
+
descending: boolean,
|
|
5326
|
+
offset: number,
|
|
5327
|
+
limit: number | undefined,
|
|
5328
|
+
listener: ResultRowIdsListener,
|
|
5329
|
+
listenerDeps?: React.DependencyList,
|
|
5330
|
+
queriesOrQueriesId?: QueriesOrQueriesId,
|
|
5331
|
+
): void;
|
|
5332
|
+
|
|
5333
|
+
/**
|
|
5334
|
+
* The useResultRowListener hook registers a listener function with a Queries
|
|
5335
|
+
* object that will be called whenever data in a result Row changes.
|
|
4921
5336
|
*
|
|
4922
5337
|
* This hook is useful for situations where a component needs to register its
|
|
4923
5338
|
* own specific listener to do more than simply tracking the value (which is
|
|
@@ -4989,6 +5404,7 @@ export function useResultRowIdsListener(
|
|
|
4989
5404
|
* // -> 0
|
|
4990
5405
|
* ```
|
|
4991
5406
|
* @category Queries hooks
|
|
5407
|
+
* @since v2.0.0
|
|
4992
5408
|
*/
|
|
4993
5409
|
export function useResultRowListener(
|
|
4994
5410
|
queryId: IdOrNull,
|
|
@@ -5072,6 +5488,7 @@ export function useResultRowListener(
|
|
|
5072
5488
|
* // -> 0
|
|
5073
5489
|
* ```
|
|
5074
5490
|
* @category Queries hooks
|
|
5491
|
+
* @since v2.0.0
|
|
5075
5492
|
*/
|
|
5076
5493
|
export function useResultCellIdsListener(
|
|
5077
5494
|
queryId: IdOrNull,
|
|
@@ -5157,6 +5574,7 @@ export function useResultCellIdsListener(
|
|
|
5157
5574
|
* // -> 0
|
|
5158
5575
|
* ```
|
|
5159
5576
|
* @category Queries hooks
|
|
5577
|
+
* @since v2.0.0
|
|
5160
5578
|
*/
|
|
5161
5579
|
export function useResultCellListener(
|
|
5162
5580
|
queryId: IdOrNull,
|
|
@@ -6168,12 +6586,6 @@ export type TablesProps = {
|
|
|
6168
6586
|
* for a named context Store, or provide an explicit reference.
|
|
6169
6587
|
*/
|
|
6170
6588
|
readonly store?: StoreOrStoreId;
|
|
6171
|
-
/**
|
|
6172
|
-
* An optional boolean that indicates that the component should re-render if
|
|
6173
|
-
* the set of Table Ids in the Store remains the same but their order changes.
|
|
6174
|
-
* See the addTableIdsListener method for more details.
|
|
6175
|
-
*/
|
|
6176
|
-
readonly trackReorder?: boolean;
|
|
6177
6589
|
/**
|
|
6178
6590
|
* A component for rendering each Table in the Store (to override the default
|
|
6179
6591
|
* TableView component).
|
|
@@ -6212,11 +6624,60 @@ export type TableProps = {
|
|
|
6212
6624
|
*/
|
|
6213
6625
|
readonly store?: StoreOrStoreId;
|
|
6214
6626
|
/**
|
|
6215
|
-
*
|
|
6216
|
-
*
|
|
6217
|
-
|
|
6627
|
+
* A custom component for rendering each Row in the Table (to override the
|
|
6628
|
+
* default RowView component).
|
|
6629
|
+
*/
|
|
6630
|
+
readonly rowComponent?: ComponentType<RowProps>;
|
|
6631
|
+
/**
|
|
6632
|
+
* A function for generating extra props for each custom Row component based
|
|
6633
|
+
* on its Id.
|
|
6634
|
+
*/
|
|
6635
|
+
readonly getRowComponentProps?: (rowId: Id) => ExtraProps;
|
|
6636
|
+
/**
|
|
6637
|
+
* A component or string to separate each Row component.
|
|
6638
|
+
*/
|
|
6639
|
+
readonly separator?: ReactElement | string;
|
|
6640
|
+
/**
|
|
6641
|
+
* Whether the component should also render the Id of the Table, and its
|
|
6642
|
+
* descendent objects, to assist with debugging.
|
|
6643
|
+
*/
|
|
6644
|
+
readonly debugIds?: boolean;
|
|
6645
|
+
};
|
|
6646
|
+
|
|
6647
|
+
/**
|
|
6648
|
+
* SortedTableProps props are used for components that refer to a single sorted
|
|
6649
|
+
* Table in a Store, such as the SortedTableView component.
|
|
6650
|
+
*
|
|
6651
|
+
* @category Props
|
|
6652
|
+
* @since v2.0.0
|
|
6653
|
+
*/
|
|
6654
|
+
export type SortedTableProps = {
|
|
6655
|
+
/**
|
|
6656
|
+
* The Id of the Table in the Store to be rendered.
|
|
6657
|
+
*/
|
|
6658
|
+
readonly tableId: Id;
|
|
6659
|
+
/**
|
|
6660
|
+
* The Id of the Cell whose values are used for the sorting. If omitted, the
|
|
6661
|
+
* view will sort the Row Id itself.
|
|
6218
6662
|
*/
|
|
6219
|
-
readonly
|
|
6663
|
+
readonly cellId?: Id;
|
|
6664
|
+
/**
|
|
6665
|
+
* Whether the sorting should be in descending order.
|
|
6666
|
+
*/
|
|
6667
|
+
readonly descending?: boolean;
|
|
6668
|
+
/**
|
|
6669
|
+
* The number of Row Ids to skip for pagination purposes.
|
|
6670
|
+
*/
|
|
6671
|
+
readonly offset?: number;
|
|
6672
|
+
/**
|
|
6673
|
+
* The maximum number of Row Ids to return.
|
|
6674
|
+
*/
|
|
6675
|
+
readonly limit?: number;
|
|
6676
|
+
/**
|
|
6677
|
+
* The Store to be accessed: omit for the default context Store, provide an Id
|
|
6678
|
+
* for a named context Store, or provide an explicit reference.
|
|
6679
|
+
*/
|
|
6680
|
+
readonly store?: StoreOrStoreId;
|
|
6220
6681
|
/**
|
|
6221
6682
|
* A custom component for rendering each Row in the Table (to override the
|
|
6222
6683
|
* default RowView component).
|
|
@@ -6258,12 +6719,6 @@ export type RowProps = {
|
|
|
6258
6719
|
* for a named context Store, or provide an explicit reference.
|
|
6259
6720
|
*/
|
|
6260
6721
|
readonly store?: StoreOrStoreId;
|
|
6261
|
-
/**
|
|
6262
|
-
* An optional boolean that indicates that the component should re-render if
|
|
6263
|
-
* the set of Cell Ids remains the same but their order changes. See the
|
|
6264
|
-
* addCellIdsListener method for more details.
|
|
6265
|
-
*/
|
|
6266
|
-
readonly trackReorder?: boolean;
|
|
6267
6722
|
/**
|
|
6268
6723
|
* A custom component for rendering each Cell in the Row (to override the
|
|
6269
6724
|
* default CellView component).
|
|
@@ -6549,6 +7004,7 @@ export type LinkedRowsProps = {
|
|
|
6549
7004
|
* result Table, such as the ResultTableView component.
|
|
6550
7005
|
*
|
|
6551
7006
|
* @category Props
|
|
7007
|
+
* @since v2.0.0
|
|
6552
7008
|
*/
|
|
6553
7009
|
export type ResultTableProps = {
|
|
6554
7010
|
/**
|
|
@@ -6563,11 +7019,62 @@ export type ResultTableProps = {
|
|
|
6563
7019
|
*/
|
|
6564
7020
|
readonly queries?: QueriesOrQueriesId;
|
|
6565
7021
|
/**
|
|
6566
|
-
*
|
|
6567
|
-
*
|
|
6568
|
-
|
|
7022
|
+
* A custom component for rendering each Row in the Table (to override the
|
|
7023
|
+
* default ResultRowView component).
|
|
7024
|
+
*/
|
|
7025
|
+
readonly resultRowComponent?: ComponentType<ResultRowProps>;
|
|
7026
|
+
/**
|
|
7027
|
+
* A function for generating extra props for each custom Row component based
|
|
7028
|
+
* on its Id.
|
|
7029
|
+
*/
|
|
7030
|
+
readonly getResultRowComponentProps?: (rowId: Id) => ExtraProps;
|
|
7031
|
+
/**
|
|
7032
|
+
* A component or string to separate each Row component.
|
|
7033
|
+
*/
|
|
7034
|
+
readonly separator?: ReactElement | string;
|
|
7035
|
+
/**
|
|
7036
|
+
* Whether the component should also render the Id of the query, and its
|
|
7037
|
+
* descendent objects, to assist with debugging.
|
|
7038
|
+
*/
|
|
7039
|
+
readonly debugIds?: boolean;
|
|
7040
|
+
};
|
|
7041
|
+
|
|
7042
|
+
/**
|
|
7043
|
+
* ResultSortedTableProps props are used for components that refer to a single
|
|
7044
|
+
* sorted query result Table, such as the ResultSortedTableView component.
|
|
7045
|
+
*
|
|
7046
|
+
* @category Props
|
|
7047
|
+
* @since v2.0.0
|
|
7048
|
+
*/
|
|
7049
|
+
export type ResultSortedTableProps = {
|
|
7050
|
+
/**
|
|
7051
|
+
* The Id of the query in the Queries object for which the sorted result Table
|
|
7052
|
+
* will be rendered.
|
|
7053
|
+
*/
|
|
7054
|
+
readonly queryId: Id;
|
|
7055
|
+
/**
|
|
7056
|
+
* The Id of the Cell whose values are used for the sorting. If omitted, the
|
|
7057
|
+
* view will sort the Row Id itself.
|
|
7058
|
+
*/
|
|
7059
|
+
readonly cellId?: Id;
|
|
7060
|
+
/**
|
|
7061
|
+
* Whether the sorting should be in descending order.
|
|
6569
7062
|
*/
|
|
6570
|
-
readonly
|
|
7063
|
+
readonly descending?: boolean;
|
|
7064
|
+
/**
|
|
7065
|
+
* The number of Row Ids to skip for pagination purposes.
|
|
7066
|
+
*/
|
|
7067
|
+
readonly offset?: number;
|
|
7068
|
+
/**
|
|
7069
|
+
* The maximum number of Row Ids to return.
|
|
7070
|
+
*/
|
|
7071
|
+
readonly limit?: number;
|
|
7072
|
+
/**
|
|
7073
|
+
* The Queries object to be accessed: omit for the default context Queries
|
|
7074
|
+
* object, provide an Id for a named context Queries object, or provide an
|
|
7075
|
+
* explicit reference.
|
|
7076
|
+
*/
|
|
7077
|
+
readonly queries?: QueriesOrQueriesId;
|
|
6571
7078
|
/**
|
|
6572
7079
|
* A custom component for rendering each Row in the Table (to override the
|
|
6573
7080
|
* default ResultRowView component).
|
|
@@ -6594,6 +7101,7 @@ export type ResultTableProps = {
|
|
|
6594
7101
|
* query result Table, such as the ResultRowView component.
|
|
6595
7102
|
*
|
|
6596
7103
|
* @category Props
|
|
7104
|
+
* @since v2.0.0
|
|
6597
7105
|
*/
|
|
6598
7106
|
export type ResultRowProps = {
|
|
6599
7107
|
/**
|
|
@@ -6637,6 +7145,7 @@ export type ResultRowProps = {
|
|
|
6637
7145
|
* Row of a result Table, such as the ResultCellView component.
|
|
6638
7146
|
*
|
|
6639
7147
|
* @category Props
|
|
7148
|
+
* @since v2.0.0
|
|
6640
7149
|
*/
|
|
6641
7150
|
export type ResultCellProps = {
|
|
6642
7151
|
/**
|
|
@@ -6789,8 +7298,8 @@ export type ForwardCheckpointsProps = {
|
|
|
6789
7298
|
|
|
6790
7299
|
/**
|
|
6791
7300
|
* ProviderProps props are used with the Provider component, so that Store
|
|
6792
|
-
* Metrics, Indexes, Relationships, and Checkpoints objects can be
|
|
6793
|
-
* the context of an application and used throughout.
|
|
7301
|
+
* Metrics, Indexes, Relationships, Queries, and Checkpoints objects can be
|
|
7302
|
+
* passed into the context of an application and used throughout.
|
|
6794
7303
|
*
|
|
6795
7304
|
* One of each type of object can be provided as a default within the context.
|
|
6796
7305
|
* Additionally, multiple of each type of object can be provided in an Id-keyed
|
|
@@ -6841,12 +7350,12 @@ export type ProviderProps = {
|
|
|
6841
7350
|
readonly relationshipsById?: {[relationshipsId: Id]: Relationships};
|
|
6842
7351
|
/**
|
|
6843
7352
|
* A default single Queries object that will be available within the Provider
|
|
6844
|
-
* context.
|
|
7353
|
+
* context, since v2.0.0.
|
|
6845
7354
|
*/
|
|
6846
7355
|
readonly queries?: Queries;
|
|
6847
7356
|
/**
|
|
6848
7357
|
* An object containing multiple Queries objects that will be available within
|
|
6849
|
-
* the Provider context by their Id.
|
|
7358
|
+
* the Provider context by their Id, since v2.0.0.
|
|
6850
7359
|
*/
|
|
6851
7360
|
readonly queriesById?: {[queriesId: Id]: Queries};
|
|
6852
7361
|
/**
|
|
@@ -6873,9 +7382,9 @@ export type ComponentReturnType = ReactElement<any, any> | null;
|
|
|
6873
7382
|
* The Provider component is used to wrap part of an application in a context
|
|
6874
7383
|
* that provides default objects to be used by hooks and components within.
|
|
6875
7384
|
*
|
|
6876
|
-
* Store, Metrics, Indexes, Relationships, and Checkpoints objects can
|
|
6877
|
-
* into the context of an application and used throughout. One of each
|
|
6878
|
-
* object can be provided as a default within the context. Additionally,
|
|
7385
|
+
* Store, Metrics, Indexes, Relationships, Queries, and Checkpoints objects can
|
|
7386
|
+
* be passed into the context of an application and used throughout. One of each
|
|
7387
|
+
* type of object can be provided as a default within the context. Additionally,
|
|
6879
7388
|
* multiple of each type of object can be provided in an Id-keyed map to the
|
|
6880
7389
|
* `___ById` props.
|
|
6881
7390
|
*
|
|
@@ -7172,6 +7681,136 @@ export function CellView(props: CellProps): ComponentReturnType;
|
|
|
7172
7681
|
*/
|
|
7173
7682
|
export function RowView(props: RowProps): ComponentReturnType;
|
|
7174
7683
|
|
|
7684
|
+
/**
|
|
7685
|
+
* The SortedTableView component renders the contents of a single sorted Table
|
|
7686
|
+
* in a Store, and registers a listener so that any changes to that result will
|
|
7687
|
+
* cause a re-render.
|
|
7688
|
+
*
|
|
7689
|
+
* The component's props identify which Table to render based on Table Id, and
|
|
7690
|
+
* Store (which is either the default context Store, a named context Store, or
|
|
7691
|
+
* by explicit reference). It also takes a Cell Id to sort by and a boolean to
|
|
7692
|
+
* indicate that the sorting should be in descending order. The `offset` and
|
|
7693
|
+
* `limit` props are used to paginate results, but default to `0` and
|
|
7694
|
+
* `undefined` to return all available Row Ids if not specified.
|
|
7695
|
+
*
|
|
7696
|
+
* This component renders a Table by iterating over its Row objects, in the
|
|
7697
|
+
* order dictated by the sort parameters. By default these are in turn rendered
|
|
7698
|
+
* with the RowView component, but you can override this behavior by providing a
|
|
7699
|
+
* `rowComponent` prop, a custom component of your own that will render a Row
|
|
7700
|
+
* based on RowProps. You can also pass additional props to your custom
|
|
7701
|
+
* component with the `getRowComponentProps` callback prop.
|
|
7702
|
+
*
|
|
7703
|
+
* This component uses the useSortedRowIds hook under the covers, which means
|
|
7704
|
+
* that any changes to the structure or sorting of the Table will cause a
|
|
7705
|
+
* re-render.
|
|
7706
|
+
*
|
|
7707
|
+
* @param props The props for this component.
|
|
7708
|
+
* @returns A rendering of the Table, or nothing, if not present.
|
|
7709
|
+
* @example
|
|
7710
|
+
* This example creates a Store outside the application, which is used in the
|
|
7711
|
+
* SortedTableView component by reference. A change to the data in the Store
|
|
7712
|
+
* re-renders the component.
|
|
7713
|
+
*
|
|
7714
|
+
* ```jsx
|
|
7715
|
+
* const store = createStore().setTables({
|
|
7716
|
+
* pets: {
|
|
7717
|
+
* fido: {species: 'dog'},
|
|
7718
|
+
* felix: {species: 'cat'},
|
|
7719
|
+
* },
|
|
7720
|
+
* });
|
|
7721
|
+
* const App = () => (
|
|
7722
|
+
* <div>
|
|
7723
|
+
* <SortedTableView
|
|
7724
|
+
* tableId="pets"
|
|
7725
|
+
* cellId="species"
|
|
7726
|
+
* store={store}
|
|
7727
|
+
* separator="/"
|
|
7728
|
+
* />
|
|
7729
|
+
* </div>
|
|
7730
|
+
* );
|
|
7731
|
+
*
|
|
7732
|
+
* const app = document.createElement('div');
|
|
7733
|
+
* ReactDOM.render(<App />, app); // !act
|
|
7734
|
+
* console.log(app.innerHTML);
|
|
7735
|
+
* // -> '<div>cat/dog</div>'
|
|
7736
|
+
*
|
|
7737
|
+
* store.setRow('pets', 'cujo', {species: 'wolf'}); // !act
|
|
7738
|
+
* console.log(app.innerHTML);
|
|
7739
|
+
* // -> '<div>cat/dog/wolf</div>'
|
|
7740
|
+
* ```
|
|
7741
|
+
* @example
|
|
7742
|
+
* This example creates a Provider context into which a default Store is
|
|
7743
|
+
* provided. The SortedTableView component within it then renders the Table
|
|
7744
|
+
* (with Ids for readability).
|
|
7745
|
+
*
|
|
7746
|
+
* ```jsx
|
|
7747
|
+
* const App = ({store}) => (
|
|
7748
|
+
* <Provider store={store}>
|
|
7749
|
+
* <Pane />
|
|
7750
|
+
* </Provider>
|
|
7751
|
+
* );
|
|
7752
|
+
* const Pane = () => (
|
|
7753
|
+
* <div>
|
|
7754
|
+
* <SortedTableView tableId="pets" cellId="species" debugIds={true} />
|
|
7755
|
+
* </div>
|
|
7756
|
+
* );
|
|
7757
|
+
*
|
|
7758
|
+
* const store = createStore().setTables({
|
|
7759
|
+
* pets: {
|
|
7760
|
+
* fido: {species: 'dog'},
|
|
7761
|
+
* felix: {species: 'cat'},
|
|
7762
|
+
* },
|
|
7763
|
+
* });
|
|
7764
|
+
* const app = document.createElement('div');
|
|
7765
|
+
* ReactDOM.render(<App store={store} />, app); // !act
|
|
7766
|
+
* console.log(app.innerHTML);
|
|
7767
|
+
* // -> '<div>pets:{felix:{species:{cat}}fido:{species:{dog}}}</div>'
|
|
7768
|
+
* ```
|
|
7769
|
+
* @example
|
|
7770
|
+
* This example creates a Provider context into which a default Store is
|
|
7771
|
+
* provided. The SortedTableView component within it then renders the Table with
|
|
7772
|
+
* a custom Row component and a custom props callback.
|
|
7773
|
+
*
|
|
7774
|
+
* ```jsx
|
|
7775
|
+
* const App = ({store}) => (
|
|
7776
|
+
* <Provider store={store}>
|
|
7777
|
+
* <Pane />
|
|
7778
|
+
* </Provider>
|
|
7779
|
+
* );
|
|
7780
|
+
* const Pane = () => (
|
|
7781
|
+
* <div>
|
|
7782
|
+
* <SortedTableView
|
|
7783
|
+
* tableId="pets"
|
|
7784
|
+
* cellId="species"
|
|
7785
|
+
* rowComponent={FormattedRowView}
|
|
7786
|
+
* getRowComponentProps={(rowId) => ({bold: rowId == 'fido'})}
|
|
7787
|
+
* />
|
|
7788
|
+
* </div>
|
|
7789
|
+
* );
|
|
7790
|
+
* const FormattedRowView = ({tableId, rowId, bold}) => (
|
|
7791
|
+
* <span>
|
|
7792
|
+
* {bold ? <b>{rowId}</b> : rowId}
|
|
7793
|
+
* {': '}
|
|
7794
|
+
* <RowView tableId={tableId} rowId={rowId} />
|
|
7795
|
+
* </span>
|
|
7796
|
+
* );
|
|
7797
|
+
*
|
|
7798
|
+
* const store = createStore().setTables({
|
|
7799
|
+
* pets: {
|
|
7800
|
+
* fido: {species: 'dog'},
|
|
7801
|
+
* felix: {species: 'cat'},
|
|
7802
|
+
* },
|
|
7803
|
+
* });
|
|
7804
|
+
* const app = document.createElement('div');
|
|
7805
|
+
* ReactDOM.render(<App store={store} />, app); // !act
|
|
7806
|
+
* console.log(app.innerHTML);
|
|
7807
|
+
* // -> '<div><span>felix: cat</span><span><b>fido</b>: dog</span></div>'
|
|
7808
|
+
* ```
|
|
7809
|
+
* @category Store components
|
|
7810
|
+
* @since v2.0.0
|
|
7811
|
+
*/
|
|
7812
|
+
export function SortedTableView(props: SortedTableProps): ComponentReturnType;
|
|
7813
|
+
|
|
7175
7814
|
/**
|
|
7176
7815
|
* The TableView component renders the contents of a single Table in a Store,
|
|
7177
7816
|
* and registers a listener so that any changes to that result will cause a
|
|
@@ -8265,6 +8904,7 @@ export function LinkedRowsView(props: LinkedRowsProps): ComponentReturnType;
|
|
|
8265
8904
|
* // -> '<span></span>'
|
|
8266
8905
|
* ```
|
|
8267
8906
|
* @category Queries components
|
|
8907
|
+
* @since v2.0.0
|
|
8268
8908
|
*/
|
|
8269
8909
|
export function ResultCellView(props: ResultCellProps): ComponentReturnType;
|
|
8270
8910
|
|
|
@@ -8411,9 +9051,150 @@ export function ResultCellView(props: ResultCellProps): ComponentReturnType;
|
|
|
8411
9051
|
* // -> '<div><span><b>species</b>: dog</span><span>color: brown</span></div>'
|
|
8412
9052
|
* ```
|
|
8413
9053
|
* @category Queries components
|
|
9054
|
+
* @since v2.0.0
|
|
8414
9055
|
*/
|
|
8415
9056
|
export function ResultRowView(props: ResultRowProps): ComponentReturnType;
|
|
8416
9057
|
|
|
9058
|
+
/**
|
|
9059
|
+
* The ResultSortedTableView component renders the contents of a single query's
|
|
9060
|
+
* sorted result Table in a Queries object, and registers a listener so that any
|
|
9061
|
+
* changes to that result will cause a re-render.
|
|
9062
|
+
*
|
|
9063
|
+
* The component's props identify which Table to render based on query Id, and
|
|
9064
|
+
* Queries object (which is either the default context Queries object, a named
|
|
9065
|
+
* context Queries object, or by explicit reference). It also takes a Cell Id to
|
|
9066
|
+
* sort by and a boolean to indicate that the sorting should be in descending
|
|
9067
|
+
* order. The `offset` and `limit` props are used to paginate results, but
|
|
9068
|
+
* default to `0` and `undefined` to return all available Row Ids if not
|
|
9069
|
+
* specified.
|
|
9070
|
+
*
|
|
9071
|
+
* This component renders a result Table by iterating over its Row objects, in
|
|
9072
|
+
* the order dictated by the sort parameters. By default these are in turn
|
|
9073
|
+
* rendered with the ResultRowView component, but you can override this behavior
|
|
9074
|
+
* by providing a `resultRowComponent` prop, a custom component of your own that
|
|
9075
|
+
* will render a Row based on ResultRowProps. You can also pass additional props
|
|
9076
|
+
* to your custom component with the `getResultRowComponentProps` callback prop.
|
|
9077
|
+
*
|
|
9078
|
+
* This component uses the useResultSortedRowIds hook under the covers, which
|
|
9079
|
+
* means that any changes to the structure or sorting of the result Table will
|
|
9080
|
+
* cause a re-render.
|
|
9081
|
+
*
|
|
9082
|
+
* @param props The props for this component.
|
|
9083
|
+
* @returns A rendering of the result Table, or nothing, if not present.
|
|
9084
|
+
* @example
|
|
9085
|
+
* This example creates a Queries object outside the application, which is used
|
|
9086
|
+
* in the ResultSortedTableView component by reference. A change to the data in
|
|
9087
|
+
* the Store re-renders the component.
|
|
9088
|
+
*
|
|
9089
|
+
* ```jsx
|
|
9090
|
+
* const store = createStore().setTable('pets', {
|
|
9091
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
9092
|
+
* felix: {species: 'cat', color: 'black'},
|
|
9093
|
+
* });
|
|
9094
|
+
* const queries = createQueries(store).setQueryDefinition(
|
|
9095
|
+
* 'petColors',
|
|
9096
|
+
* 'pets',
|
|
9097
|
+
* ({select}) => select('color'),
|
|
9098
|
+
* );
|
|
9099
|
+
* const App = () => (
|
|
9100
|
+
* <div>
|
|
9101
|
+
* <ResultSortedTableView
|
|
9102
|
+
* queryId="petColors"
|
|
9103
|
+
* cellId="color"
|
|
9104
|
+
* queries={queries}
|
|
9105
|
+
* separator="/"
|
|
9106
|
+
* />
|
|
9107
|
+
* </div>
|
|
9108
|
+
* );
|
|
9109
|
+
*
|
|
9110
|
+
* const app = document.createElement('div');
|
|
9111
|
+
* ReactDOM.render(<App />, app); // !act
|
|
9112
|
+
* console.log(app.innerHTML);
|
|
9113
|
+
* // -> '<div>black/brown</div>'
|
|
9114
|
+
*
|
|
9115
|
+
* store.setCell('pets', 'felix', 'color', 'white'); // !act
|
|
9116
|
+
* console.log(app.innerHTML);
|
|
9117
|
+
* // -> '<div>brown/white</div>'
|
|
9118
|
+
* ```
|
|
9119
|
+
* @example
|
|
9120
|
+
* This example creates a Provider context into which a default Queries object
|
|
9121
|
+
* is provided. The ResultSortedTableView component within it then renders the
|
|
9122
|
+
* Table (with Ids for readability).
|
|
9123
|
+
*
|
|
9124
|
+
* ```jsx
|
|
9125
|
+
* const App = ({queries}) => (
|
|
9126
|
+
* <Provider queries={queries}>
|
|
9127
|
+
* <Pane />
|
|
9128
|
+
* </Provider>
|
|
9129
|
+
* );
|
|
9130
|
+
* const Pane = () => (
|
|
9131
|
+
* <div>
|
|
9132
|
+
* <ResultSortedTableView
|
|
9133
|
+
* queryId="petColors"
|
|
9134
|
+
* cellId="color"
|
|
9135
|
+
* debugIds={true}
|
|
9136
|
+
* />
|
|
9137
|
+
* </div>
|
|
9138
|
+
* );
|
|
9139
|
+
*
|
|
9140
|
+
* const queries = createQueries(
|
|
9141
|
+
* createStore().setTable('pets', {
|
|
9142
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
9143
|
+
* felix: {species: 'cat', color: 'black'},
|
|
9144
|
+
* }),
|
|
9145
|
+
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
9146
|
+
* const app = document.createElement('div');
|
|
9147
|
+
* ReactDOM.render(<App queries={queries} />, app); // !act
|
|
9148
|
+
* console.log(app.innerHTML);
|
|
9149
|
+
* // -> '<div>petColors:{felix:{color:{black}}fido:{color:{brown}}}</div>'
|
|
9150
|
+
* ```
|
|
9151
|
+
* @example
|
|
9152
|
+
* This example creates a Provider context into which a default Queries object
|
|
9153
|
+
* is provided. The ResultSortedTableView component within it then renders the
|
|
9154
|
+
* Table with a custom Row component and a custom props callback.
|
|
9155
|
+
*
|
|
9156
|
+
* ```jsx
|
|
9157
|
+
* const App = ({queries}) => (
|
|
9158
|
+
* <Provider queries={queries}>
|
|
9159
|
+
* <Pane />
|
|
9160
|
+
* </Provider>
|
|
9161
|
+
* );
|
|
9162
|
+
* const Pane = () => (
|
|
9163
|
+
* <div>
|
|
9164
|
+
* <ResultSortedTableView
|
|
9165
|
+
* queryId="petColors"
|
|
9166
|
+
* cellId="color"
|
|
9167
|
+
* resultRowComponent={FormattedRowView}
|
|
9168
|
+
* getResultRowComponentProps={(rowId) => ({bold: rowId == 'fido'})}
|
|
9169
|
+
* />
|
|
9170
|
+
* </div>
|
|
9171
|
+
* );
|
|
9172
|
+
* const FormattedRowView = ({queryId, rowId, bold}) => (
|
|
9173
|
+
* <span>
|
|
9174
|
+
* {bold ? <b>{rowId}</b> : rowId}
|
|
9175
|
+
* {': '}
|
|
9176
|
+
* <ResultRowView queryId={queryId} rowId={rowId} />
|
|
9177
|
+
* </span>
|
|
9178
|
+
* );
|
|
9179
|
+
*
|
|
9180
|
+
* const queries = createQueries(
|
|
9181
|
+
* createStore().setTable('pets', {
|
|
9182
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
9183
|
+
* felix: {species: 'cat', color: 'black'},
|
|
9184
|
+
* }),
|
|
9185
|
+
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
9186
|
+
* const app = document.createElement('div');
|
|
9187
|
+
* ReactDOM.render(<App queries={queries} />, app); // !act
|
|
9188
|
+
* console.log(app.innerHTML);
|
|
9189
|
+
* // -> '<div><span>felix: black</span><span><b>fido</b>: brown</span></div>'
|
|
9190
|
+
* ```
|
|
9191
|
+
* @category Queries components
|
|
9192
|
+
* @since v2.0.0
|
|
9193
|
+
*/
|
|
9194
|
+
export function ResultSortedTableView(
|
|
9195
|
+
props: ResultSortedTableProps,
|
|
9196
|
+
): ComponentReturnType;
|
|
9197
|
+
|
|
8417
9198
|
/**
|
|
8418
9199
|
* The ResultTableView component renders the contents of a single query's result
|
|
8419
9200
|
* Table in a Queries object, and registers a listener so that any changes to
|
|
@@ -8533,6 +9314,7 @@ export function ResultRowView(props: ResultRowProps): ComponentReturnType;
|
|
|
8533
9314
|
* // -> '<div><span><b>fido</b>: brown</span><span>felix: black</span></div>'
|
|
8534
9315
|
* ```
|
|
8535
9316
|
* @category Queries components
|
|
9317
|
+
* @since v2.0.0
|
|
8536
9318
|
*/
|
|
8537
9319
|
export function ResultTableView(props: ResultTableProps): ComponentReturnType;
|
|
8538
9320
|
|