tinybase 4.1.0-beta.1 → 4.1.0-beta.3
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/bin/cli.js +1 -1
- package/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/cjs/checkpoints.cjs +1 -1
- package/lib/cjs/checkpoints.cjs.gz +0 -0
- package/lib/cjs/indexes.cjs +1 -1
- package/lib/cjs/indexes.cjs.gz +0 -0
- package/lib/cjs/metrics.cjs +1 -1
- package/lib/cjs/metrics.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-browser.cjs +1 -1
- package/lib/cjs/persisters/persister-browser.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs +1 -1
- package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-file.cjs +1 -1
- package/lib/cjs/persisters/persister-file.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-remote.cjs +1 -1
- package/lib/cjs/persisters/persister-remote.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-sqlite-wasm.cjs +1 -1
- package/lib/cjs/persisters/persister-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-sqlite3.cjs +1 -1
- package/lib/cjs/persisters/persister-sqlite3.cjs.gz +0 -0
- package/lib/cjs/queries.cjs +1 -1
- package/lib/cjs/queries.cjs.gz +0 -0
- package/lib/cjs/relationships.cjs +1 -1
- package/lib/cjs/relationships.cjs.gz +0 -0
- package/lib/cjs/store.cjs +1 -1
- package/lib/cjs/store.cjs.gz +0 -0
- package/lib/cjs/tinybase.cjs +1 -1
- package/lib/cjs/tinybase.cjs.gz +0 -0
- package/lib/cjs/tools.cjs +1 -1
- package/lib/cjs/tools.cjs.gz +0 -0
- package/lib/cjs/ui-react-dom.cjs +1 -1
- package/lib/cjs/ui-react-dom.cjs.gz +0 -0
- package/lib/cjs/ui-react.cjs +1 -1
- package/lib/cjs/ui-react.cjs.gz +0 -0
- package/lib/cjs-es6/checkpoints.cjs +1 -1
- package/lib/cjs-es6/checkpoints.cjs.gz +0 -0
- package/lib/cjs-es6/indexes.cjs +1 -1
- package/lib/cjs-es6/indexes.cjs.gz +0 -0
- package/lib/cjs-es6/metrics.cjs +1 -1
- package/lib/cjs-es6/metrics.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-browser.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-browser.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-file.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-file.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-remote.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-remote.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-sqlite3.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-sqlite3.cjs.gz +0 -0
- package/lib/cjs-es6/queries.cjs +1 -1
- package/lib/cjs-es6/queries.cjs.gz +0 -0
- package/lib/cjs-es6/relationships.cjs +1 -1
- package/lib/cjs-es6/relationships.cjs.gz +0 -0
- package/lib/cjs-es6/store.cjs +1 -1
- package/lib/cjs-es6/store.cjs.gz +0 -0
- package/lib/cjs-es6/tinybase.cjs +1 -1
- package/lib/cjs-es6/tinybase.cjs.gz +0 -0
- package/lib/cjs-es6/tools.cjs +1 -1
- package/lib/cjs-es6/tools.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react-dom.cjs +1 -1
- package/lib/cjs-es6/ui-react-dom.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react.cjs +1 -1
- package/lib/cjs-es6/ui-react.cjs.gz +0 -0
- package/lib/debug/checkpoints.js +6 -6
- package/lib/debug/indexes.js +7 -7
- package/lib/debug/metrics.js +12 -12
- package/lib/debug/persisters/persister-browser.js +10 -19
- package/lib/debug/persisters/persister-cr-sqlite-wasm.js +6 -15
- package/lib/debug/persisters/persister-file.js +10 -19
- package/lib/debug/persisters/persister-remote.js +10 -19
- package/lib/debug/persisters/persister-sqlite-wasm.js +6 -15
- package/lib/debug/persisters/persister-sqlite3.js +6 -15
- package/lib/debug/persisters.js +4 -4
- package/lib/debug/queries.js +1 -0
- package/lib/debug/relationships.js +7 -7
- package/lib/debug/store.js +16 -24
- package/lib/debug/tinybase.js +21 -28
- package/lib/debug/tools.js +14 -13
- package/lib/debug/ui-react-dom.js +253 -33
- package/lib/debug/ui-react.js +26 -4
- package/lib/es6/checkpoints.js +1 -1
- package/lib/es6/checkpoints.js.gz +0 -0
- package/lib/es6/indexes.js +1 -1
- package/lib/es6/indexes.js.gz +0 -0
- package/lib/es6/metrics.js +1 -1
- package/lib/es6/metrics.js.gz +0 -0
- package/lib/es6/persisters/persister-browser.js +1 -1
- package/lib/es6/persisters/persister-browser.js.gz +0 -0
- package/lib/es6/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/es6/persisters/persister-file.js +1 -1
- package/lib/es6/persisters/persister-file.js.gz +0 -0
- package/lib/es6/persisters/persister-remote.js +1 -1
- package/lib/es6/persisters/persister-remote.js.gz +0 -0
- package/lib/es6/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/es6/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/es6/persisters/persister-sqlite3.js +1 -1
- package/lib/es6/persisters/persister-sqlite3.js.gz +0 -0
- package/lib/es6/queries.js +1 -1
- package/lib/es6/queries.js.gz +0 -0
- package/lib/es6/relationships.js +1 -1
- package/lib/es6/relationships.js.gz +0 -0
- package/lib/es6/store.js +1 -1
- package/lib/es6/store.js.gz +0 -0
- package/lib/es6/tinybase.js +1 -1
- package/lib/es6/tinybase.js.gz +0 -0
- package/lib/es6/tools.js +1 -1
- package/lib/es6/tools.js.gz +0 -0
- package/lib/es6/ui-react-dom.js +1 -1
- package/lib/es6/ui-react-dom.js.gz +0 -0
- package/lib/es6/ui-react.js +1 -1
- package/lib/es6/ui-react.js.gz +0 -0
- package/lib/indexes.js +1 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.js +1 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/persisters/persister-browser.js +1 -1
- package/lib/persisters/persister-browser.js.gz +0 -0
- package/lib/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/persisters/persister-file.js +1 -1
- package/lib/persisters/persister-file.js.gz +0 -0
- package/lib/persisters/persister-remote.js +1 -1
- package/lib/persisters/persister-remote.js.gz +0 -0
- package/lib/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/persisters/persister-sqlite3.js +1 -1
- package/lib/persisters/persister-sqlite3.js.gz +0 -0
- package/lib/queries.js +1 -1
- package/lib/queries.js.gz +0 -0
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- 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/tools.js +1 -1
- package/lib/tools.js.gz +0 -0
- package/lib/types/queries.d.ts +167 -0
- package/lib/types/ui-react-dom.d.ts +568 -70
- package/lib/types/ui-react.d.ts +269 -58
- package/lib/types/with-schemas/internal/ui-react.d.ts +32 -22
- package/lib/types/with-schemas/queries.d.ts +185 -0
- package/lib/types/with-schemas/ui-react-dom.d.ts +647 -93
- package/lib/types/with-schemas/ui-react.d.ts +281 -50
- package/lib/ui-react-dom.js +1 -1
- package/lib/ui-react-dom.js.gz +0 -0
- 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/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/persisters/persister-browser.js +1 -1
- package/lib/umd/persisters/persister-browser.js.gz +0 -0
- package/lib/umd/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/umd/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/umd/persisters/persister-file.js +1 -1
- package/lib/umd/persisters/persister-file.js.gz +0 -0
- package/lib/umd/persisters/persister-remote.js +1 -1
- package/lib/umd/persisters/persister-remote.js.gz +0 -0
- package/lib/umd/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/umd/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/umd/persisters/persister-sqlite3.js +1 -1
- package/lib/umd/persisters/persister-sqlite3.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/tools.js +1 -1
- package/lib/umd/tools.js.gz +0 -0
- package/lib/umd/ui-react-dom.js +1 -1
- package/lib/umd/ui-react-dom.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.js.gz +0 -0
- package/lib/umd-es6/checkpoints.js +1 -1
- package/lib/umd-es6/checkpoints.js.gz +0 -0
- package/lib/umd-es6/indexes.js +1 -1
- package/lib/umd-es6/indexes.js.gz +0 -0
- package/lib/umd-es6/metrics.js +1 -1
- package/lib/umd-es6/metrics.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-browser.js +1 -1
- package/lib/umd-es6/persisters/persister-browser.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-file.js +1 -1
- package/lib/umd-es6/persisters/persister-file.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-remote.js +1 -1
- package/lib/umd-es6/persisters/persister-remote.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/umd-es6/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-sqlite3.js +1 -1
- package/lib/umd-es6/persisters/persister-sqlite3.js.gz +0 -0
- package/lib/umd-es6/queries.js +1 -1
- package/lib/umd-es6/queries.js.gz +0 -0
- package/lib/umd-es6/relationships.js +1 -1
- package/lib/umd-es6/relationships.js.gz +0 -0
- package/lib/umd-es6/store.js +1 -1
- package/lib/umd-es6/store.js.gz +0 -0
- package/lib/umd-es6/tinybase.js +1 -1
- package/lib/umd-es6/tinybase.js.gz +0 -0
- package/lib/umd-es6/tools.js +1 -1
- package/lib/umd-es6/tools.js.gz +0 -0
- package/lib/umd-es6/ui-react-dom.js +1 -1
- package/lib/umd-es6/ui-react-dom.js.gz +0 -0
- package/lib/umd-es6/ui-react.js +1 -1
- package/lib/umd-es6/ui-react.js.gz +0 -0
- package/package.json +17 -17
- package/readme.md +2 -2
|
@@ -15,33 +15,54 @@ import {
|
|
|
15
15
|
CellProps,
|
|
16
16
|
ComponentReturnType,
|
|
17
17
|
ExtraProps,
|
|
18
|
+
QueriesOrQueriesId,
|
|
19
|
+
ResultCellProps,
|
|
18
20
|
StoreOrStoreId,
|
|
19
21
|
ValueProps,
|
|
20
22
|
} from './ui-react';
|
|
21
23
|
import {Id, Ids} from './common';
|
|
22
24
|
import {ComponentType} from 'react';
|
|
23
25
|
|
|
24
|
-
//
|
|
25
|
-
export type
|
|
26
|
+
// CustomCell
|
|
27
|
+
export type CustomCell = {
|
|
26
28
|
/**
|
|
27
|
-
*
|
|
29
|
+
* An optional string that will be used as the label at the top of the table
|
|
30
|
+
* column for this Cell.
|
|
28
31
|
*/
|
|
29
|
-
readonly
|
|
32
|
+
readonly label?: string;
|
|
30
33
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
34
|
+
* An optional custom component for rendering each Cell in the Table (to
|
|
35
|
+
* override the default CellView component).
|
|
33
36
|
*/
|
|
34
|
-
readonly
|
|
37
|
+
readonly component?: ComponentType<CellProps>;
|
|
35
38
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
39
|
+
* An optional function for generating extra props for each custom Cell
|
|
40
|
+
* component based on Row and Cell Id.
|
|
38
41
|
*/
|
|
39
|
-
readonly
|
|
42
|
+
readonly getComponentProps?: (rowId: Id, cellId: Id) => ExtraProps;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// CustomResultCell
|
|
46
|
+
export type CustomResultCell = {
|
|
40
47
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
48
|
+
* An optional string that will be used as the label at the top of the table
|
|
49
|
+
* column for this Cell.
|
|
43
50
|
*/
|
|
44
|
-
readonly
|
|
51
|
+
readonly label?: string;
|
|
52
|
+
/**
|
|
53
|
+
* An optional custom component for rendering each Cell in the ResultTable (to
|
|
54
|
+
* override the default ResultCellView component).
|
|
55
|
+
*/
|
|
56
|
+
readonly component?: ComponentType<ResultCellProps>;
|
|
57
|
+
/**
|
|
58
|
+
* An optional function for generating extra props for each custom Cell
|
|
59
|
+
* component based on Row and Cell Id.
|
|
60
|
+
*/
|
|
61
|
+
readonly getComponentProps?: (rowId: Id, cellId: Id) => ExtraProps;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// HtmlTableProps
|
|
65
|
+
export type HtmlTableProps = {
|
|
45
66
|
/**
|
|
46
67
|
* A string className to use on the root of the resulting element.
|
|
47
68
|
*/
|
|
@@ -56,11 +77,33 @@ export type TableInHtmlTableProps = {
|
|
|
56
77
|
* defaulting to `true`.
|
|
57
78
|
*/
|
|
58
79
|
readonly idColumn?: boolean;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// TableInHtmlTableProps
|
|
83
|
+
export type TableInHtmlTableProps = {
|
|
84
|
+
/**
|
|
85
|
+
* The Id of the Table in the Store to be rendered.
|
|
86
|
+
*/
|
|
87
|
+
readonly tableId: Id;
|
|
88
|
+
/**
|
|
89
|
+
* The Store to be accessed: omit for the default context Store, provide an Id
|
|
90
|
+
* for a named context Store, or provide an explicit reference.
|
|
91
|
+
*/
|
|
92
|
+
readonly store?: StoreOrStoreId;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the Cells should be editable. This affects the default CellView
|
|
95
|
+
* component (to use the EditableCellView component instead) but of course
|
|
96
|
+
* will not affect custom Cell components if you have set them.
|
|
97
|
+
*/
|
|
98
|
+
readonly editable?: boolean;
|
|
59
99
|
/**
|
|
60
100
|
* An optional list of Cell Ids to use for rendering a prescribed set of the
|
|
61
|
-
*
|
|
101
|
+
* Table's Cells in a given order. This can also be an object with the desired
|
|
102
|
+
* Cell Ids as keys, and with a value that can either be a string label to
|
|
103
|
+
* show in the column header, or a CustomCell object to further configure the
|
|
104
|
+
* column.
|
|
62
105
|
*/
|
|
63
|
-
readonly
|
|
106
|
+
readonly customCells?: Ids | {[cellId: Id]: string | CustomCell};
|
|
64
107
|
};
|
|
65
108
|
|
|
66
109
|
// SortedTableInHtmlTableProps
|
|
@@ -92,34 +135,87 @@ export type SortedTableInHtmlTableProps = {
|
|
|
92
135
|
*/
|
|
93
136
|
readonly store?: StoreOrStoreId;
|
|
94
137
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
138
|
+
* Whether the Cells should be editable. This affects the default CellView
|
|
139
|
+
* component (to use the EditableCellView component instead) but of course
|
|
140
|
+
* will not affect custom Cell components if you have set them.
|
|
97
141
|
*/
|
|
98
|
-
readonly
|
|
142
|
+
readonly editable?: boolean;
|
|
99
143
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
144
|
+
* An optional list of Cell Ids to use for rendering a prescribed set of the
|
|
145
|
+
* Table's Cells in a given order. This can also be an object with the desired
|
|
146
|
+
* Cell Ids as keys, and with a value that can either be a string label to
|
|
147
|
+
* show in the column header, or a CustomCell object to further configure the
|
|
148
|
+
* column.
|
|
102
149
|
*/
|
|
103
|
-
readonly
|
|
150
|
+
readonly customCells?: Ids | {[cellId: Id]: string | CustomCell};
|
|
104
151
|
/**
|
|
105
|
-
*
|
|
152
|
+
* Whether the table should be interactive such that clicking a header changes
|
|
153
|
+
* the sorting and/or direction.
|
|
106
154
|
*/
|
|
107
|
-
readonly
|
|
155
|
+
readonly sortOnClick?: boolean;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// ResultTableInHtmlTableProps
|
|
159
|
+
export type ResultTableInHtmlTableProps = {
|
|
108
160
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
161
|
+
* The Id of the query in the Queries object for which the ResultTable will be
|
|
162
|
+
* rendered.
|
|
111
163
|
*/
|
|
112
|
-
readonly
|
|
164
|
+
readonly queryId: Id;
|
|
113
165
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
166
|
+
* The Queries object to be accessed: omit for the default context Queries
|
|
167
|
+
* object, provide an Id for a named context Queries object, or provide an
|
|
168
|
+
* explicit reference.
|
|
116
169
|
*/
|
|
117
|
-
readonly
|
|
170
|
+
readonly queries?: QueriesOrQueriesId;
|
|
171
|
+
/**
|
|
172
|
+
* An optional list of Cell Ids to use for rendering a prescribed set of the
|
|
173
|
+
* ResultTable's Cells in a given order. This can also be an object with the
|
|
174
|
+
* desired Cell Ids as keys, and with a value that can either be a string
|
|
175
|
+
* label to show in the column header, or a ResultCustomCell object to further
|
|
176
|
+
* configure the column.
|
|
177
|
+
*/
|
|
178
|
+
readonly customCells?: Ids | {[cellId: Id]: string | CustomResultCell};
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// ResultSortedTableInHtmlTableProps
|
|
182
|
+
export type ResultSortedTableInHtmlTableProps = {
|
|
183
|
+
/**
|
|
184
|
+
* The Id of the query in the Queries object for which the ResultTable will be
|
|
185
|
+
* rendered.
|
|
186
|
+
*/
|
|
187
|
+
readonly queryId: Id;
|
|
188
|
+
/**
|
|
189
|
+
* The Id of the Cell whose values are used for the sorting. If omitted, the
|
|
190
|
+
* view will sort the Row Id itself.
|
|
191
|
+
*/
|
|
192
|
+
readonly cellId?: Id;
|
|
193
|
+
/**
|
|
194
|
+
* Whether the sorting should be in descending order.
|
|
195
|
+
*/
|
|
196
|
+
readonly descending?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* The number of Row Ids to skip for pagination purposes.
|
|
199
|
+
*/
|
|
200
|
+
readonly offset?: number;
|
|
201
|
+
/**
|
|
202
|
+
* The maximum number of Row Ids to return.
|
|
203
|
+
*/
|
|
204
|
+
readonly limit?: number;
|
|
205
|
+
/**
|
|
206
|
+
* The Queries object to be accessed: omit for the default context Queries
|
|
207
|
+
* object, provide an Id for a named context Queries object, or provide an
|
|
208
|
+
* explicit reference.
|
|
209
|
+
*/
|
|
210
|
+
readonly queries?: QueriesOrQueriesId;
|
|
118
211
|
/**
|
|
119
212
|
* An optional list of Cell Ids to use for rendering a prescribed set of the
|
|
120
|
-
*
|
|
213
|
+
* ResultTable's Cells in a given order. This can also be an object with the
|
|
214
|
+
* desired Cell Ids as keys, and with a value that can either be a string
|
|
215
|
+
* label to show in the column header, or a ResultCustomCell object to further
|
|
216
|
+
* configure the column.
|
|
121
217
|
*/
|
|
122
|
-
readonly
|
|
218
|
+
readonly customCells?: Ids | {[cellId: Id]: string | CustomResultCell};
|
|
123
219
|
/**
|
|
124
220
|
* Whether the table should be interactive such that clicking a header changes
|
|
125
221
|
* the sorting and/or direction.
|
|
@@ -134,6 +230,12 @@ export type ValuesInHtmlTableProps = {
|
|
|
134
230
|
* for a named context Store, or provide an explicit reference.
|
|
135
231
|
*/
|
|
136
232
|
readonly store?: StoreOrStoreId;
|
|
233
|
+
/**
|
|
234
|
+
* Whether the Values should be editable. This affects the default ValueView
|
|
235
|
+
* component (to use the EditableValueView component instead) but of course
|
|
236
|
+
* will not affect a custom valueComponent if you have set one.
|
|
237
|
+
*/
|
|
238
|
+
readonly editable?: boolean;
|
|
137
239
|
/**
|
|
138
240
|
* A custom component for rendering each Value in the Store (to override the
|
|
139
241
|
* default ValueView component).
|
|
@@ -144,20 +246,6 @@ export type ValuesInHtmlTableProps = {
|
|
|
144
246
|
* on its Id.
|
|
145
247
|
*/
|
|
146
248
|
readonly getValueComponentProps?: (valueId: Id) => ExtraProps;
|
|
147
|
-
/**
|
|
148
|
-
* A string className to use on the root of the resulting element.
|
|
149
|
-
*/
|
|
150
|
-
readonly className?: string;
|
|
151
|
-
/**
|
|
152
|
-
* Whether a header row should be rendered at the top of the table, defaulting
|
|
153
|
-
* to `true`.
|
|
154
|
-
*/
|
|
155
|
-
readonly headerRow?: boolean;
|
|
156
|
-
/**
|
|
157
|
-
* Whether an Id column should be rendered on the left of the table,
|
|
158
|
-
* defaulting to `true`.
|
|
159
|
-
*/
|
|
160
|
-
readonly idColumn?: boolean;
|
|
161
249
|
};
|
|
162
250
|
|
|
163
251
|
/**
|
|
@@ -172,11 +260,11 @@ export type ValuesInHtmlTableProps = {
|
|
|
172
260
|
* See the <TableInHtmlTable /> demo for this component in action.
|
|
173
261
|
*
|
|
174
262
|
* This component renders a Table by iterating over its Row objects. By default
|
|
175
|
-
*
|
|
176
|
-
* override this behavior by providing a `
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
263
|
+
* the Cells are in turn rendered with the CellView component, but you can
|
|
264
|
+
* override this behavior by providing a `component` for each Cell in the
|
|
265
|
+
* `customCells` prop. You can pass additional props to that custom component
|
|
266
|
+
* with the `getComponentProps` callback. See the CustomCell type for more
|
|
267
|
+
* details.
|
|
180
268
|
*
|
|
181
269
|
* This component uses the useRowIds hook under the covers, which means that any
|
|
182
270
|
* changes to the structure of the Table will cause a re-render.
|
|
@@ -185,7 +273,6 @@ export type ValuesInHtmlTableProps = {
|
|
|
185
273
|
* appear in a <th> element at the top of the table, and the start of each row.
|
|
186
274
|
* @param props The props for this component.
|
|
187
275
|
* @returns A rendering of the Table in a <table> element.
|
|
188
|
-
* @see <TableInHtmlTable /> demo
|
|
189
276
|
* @example
|
|
190
277
|
* This example creates a Provider context into which a default Store is
|
|
191
278
|
* provided. The TableInHtmlTable component within it then renders the Table in
|
|
@@ -231,8 +318,9 @@ export type ValuesInHtmlTableProps = {
|
|
|
231
318
|
* @example
|
|
232
319
|
* This example creates a Provider context into which a default Store is
|
|
233
320
|
* provided. The TableInHtmlTable component within it then renders the Table
|
|
234
|
-
* with a custom
|
|
235
|
-
* the top of the table and the Id column at the start of each
|
|
321
|
+
* with a custom component and a custom props callback for the `species` Cell.
|
|
322
|
+
* The header row at the top of the table and the Id column at the start of each
|
|
323
|
+
* row is removed.
|
|
236
324
|
*
|
|
237
325
|
* ```jsx
|
|
238
326
|
* const App = ({store}) => (
|
|
@@ -243,18 +331,24 @@ export type ValuesInHtmlTableProps = {
|
|
|
243
331
|
* const Pane = () => (
|
|
244
332
|
* <TableInHtmlTable
|
|
245
333
|
* tableId="pets"
|
|
246
|
-
*
|
|
247
|
-
* getCellComponentProps={(rowId, cellId) => ({bold: rowId == 'fido'})}
|
|
334
|
+
* customCells={customCells}
|
|
248
335
|
* headerRow={false}
|
|
249
336
|
* idColumn={false}
|
|
250
337
|
* />
|
|
251
338
|
* );
|
|
339
|
+
*
|
|
252
340
|
* const FormattedCellView = ({tableId, rowId, cellId, bold}) => (
|
|
253
341
|
* <>
|
|
254
342
|
* {bold ? <b>{rowId}</b> : rowId}:
|
|
255
343
|
* <CellView tableId={tableId} rowId={rowId} cellId={cellId} />
|
|
256
344
|
* </>
|
|
257
345
|
* );
|
|
346
|
+
* const customCells = {
|
|
347
|
+
* species: {
|
|
348
|
+
* component: FormattedCellView,
|
|
349
|
+
* getComponentProps: (rowId, cellId) => ({bold: rowId == 'fido'}),
|
|
350
|
+
* },
|
|
351
|
+
* };
|
|
258
352
|
*
|
|
259
353
|
* const store = createStore().setTable('pets', {
|
|
260
354
|
* fido: {species: 'dog'},
|
|
@@ -281,7 +375,7 @@ export type ValuesInHtmlTableProps = {
|
|
|
281
375
|
* @since v4.1.0
|
|
282
376
|
*/
|
|
283
377
|
export function TableInHtmlTable(
|
|
284
|
-
props: TableInHtmlTableProps,
|
|
378
|
+
props: TableInHtmlTableProps & HtmlTableProps,
|
|
285
379
|
): ComponentReturnType;
|
|
286
380
|
|
|
287
381
|
/**
|
|
@@ -298,12 +392,12 @@ export function TableInHtmlTable(
|
|
|
298
392
|
*
|
|
299
393
|
* See the <SortedTableInHtmlTable /> demo for this component in action.
|
|
300
394
|
*
|
|
301
|
-
* This component renders a
|
|
302
|
-
* order dictated by the sort parameters. By default
|
|
303
|
-
* with the
|
|
304
|
-
* providing a `
|
|
305
|
-
*
|
|
306
|
-
*
|
|
395
|
+
* This component renders a ResultTable by iterating over its Row objects, in
|
|
396
|
+
* the order dictated by the sort parameters. By default the Cells are in turn
|
|
397
|
+
* rendered with the CellView component, but you can override this behavior by
|
|
398
|
+
* providing a `component` for each Cell in the `customCells` prop. You can pass
|
|
399
|
+
* additional props to that custom component with the `getComponentProps`
|
|
400
|
+
* callback. See the CustomCell type for more details.
|
|
307
401
|
*
|
|
308
402
|
* This component uses the useSortedRowIds hook under the covers, which means
|
|
309
403
|
* that any changes to the structure or sorting of the Table will cause a
|
|
@@ -371,9 +465,9 @@ export function TableInHtmlTable(
|
|
|
371
465
|
* @example
|
|
372
466
|
* This example creates a Provider context into which a default Store is
|
|
373
467
|
* provided. The SortedTableInHtmlTable component within it then renders the
|
|
374
|
-
* Table with a custom
|
|
375
|
-
* at the top of the table and the Id column at the start
|
|
376
|
-
* removed.
|
|
468
|
+
* Table with a custom component and a custom props callback for the `species`
|
|
469
|
+
* Cell. The header row at the top of the table and the Id column at the start
|
|
470
|
+
* of each row is removed.
|
|
377
471
|
*
|
|
378
472
|
* ```jsx
|
|
379
473
|
* const App = ({store}) => (
|
|
@@ -381,22 +475,29 @@ export function TableInHtmlTable(
|
|
|
381
475
|
* <Pane />
|
|
382
476
|
* </Provider>
|
|
383
477
|
* );
|
|
478
|
+
*
|
|
384
479
|
* const Pane = () => (
|
|
385
480
|
* <SortedTableInHtmlTable
|
|
386
481
|
* tableId="pets"
|
|
387
482
|
* cellId="species"
|
|
388
|
-
*
|
|
389
|
-
* getCellComponentProps={(rowId, cellId) => ({bold: rowId == 'fido'})}
|
|
483
|
+
* customCells={customCells}
|
|
390
484
|
* headerRow={false}
|
|
391
485
|
* idColumn={false}
|
|
392
486
|
* />
|
|
393
487
|
* );
|
|
488
|
+
*
|
|
394
489
|
* const FormattedCellView = ({tableId, rowId, cellId, bold}) => (
|
|
395
490
|
* <>
|
|
396
491
|
* {bold ? <b>{rowId}</b> : rowId}:
|
|
397
492
|
* <CellView tableId={tableId} rowId={rowId} cellId={cellId} />
|
|
398
493
|
* </>
|
|
399
494
|
* );
|
|
495
|
+
* const customCells = {
|
|
496
|
+
* species: {
|
|
497
|
+
* component: FormattedCellView,
|
|
498
|
+
* getComponentProps: (rowId, cellId) => ({bold: rowId == 'fido'}),
|
|
499
|
+
* },
|
|
500
|
+
* };
|
|
400
501
|
*
|
|
401
502
|
* const store = createStore().setTables({
|
|
402
503
|
* pets: {
|
|
@@ -425,7 +526,7 @@ export function TableInHtmlTable(
|
|
|
425
526
|
* @since v4.1.0
|
|
426
527
|
*/
|
|
427
528
|
export function SortedTableInHtmlTable(
|
|
428
|
-
props: SortedTableInHtmlTableProps,
|
|
529
|
+
props: SortedTableInHtmlTableProps & HtmlTableProps,
|
|
429
530
|
): ComponentReturnType;
|
|
430
531
|
|
|
431
532
|
/**
|
|
@@ -440,7 +541,7 @@ export function SortedTableInHtmlTable(
|
|
|
440
541
|
* See the <ValuesInHtmlTable /> demo for this component in action.
|
|
441
542
|
*
|
|
442
543
|
* This component renders a Store by iterating over its Value objects. By
|
|
443
|
-
* default
|
|
544
|
+
* default the Values are in turn rendered with the ValueView component, but you
|
|
444
545
|
* can override this behavior by providing a `valueComponent` prop, a custom
|
|
445
546
|
* component of your own that will render a Value based on ValueProps. You can
|
|
446
547
|
* also pass additional props to your custom component with the
|
|
@@ -540,5 +641,402 @@ export function SortedTableInHtmlTable(
|
|
|
540
641
|
* @since v4.1.0
|
|
541
642
|
*/
|
|
542
643
|
export function ValuesInHtmlTable(
|
|
543
|
-
props: ValuesInHtmlTableProps,
|
|
644
|
+
props: ValuesInHtmlTableProps & HtmlTableProps,
|
|
645
|
+
): ComponentReturnType;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* The ResultTableInHtmlTable component renders the contents of a single query's
|
|
649
|
+
* ResultTable in a Queries object as an HTML <table> element, and registers a
|
|
650
|
+
* listener so that any changes to that result will cause a re-render.
|
|
651
|
+
*
|
|
652
|
+
* The component's props identify which ResultTable to render based on query Id,
|
|
653
|
+
* and Queries object (which is either the default context Queries object, a
|
|
654
|
+
* named context Queries object, or by explicit reference).
|
|
655
|
+
*
|
|
656
|
+
* See the <ResultTableInHtmlTable /> demo for this component in action.
|
|
657
|
+
*
|
|
658
|
+
* This component renders a ResultTable by iterating over its Row objects. By
|
|
659
|
+
* default the Cells are in turn rendered with the CellView component, but you
|
|
660
|
+
* can override this behavior by providing a `component` for each Cell in the
|
|
661
|
+
* `customCells` prop. You can pass additional props to that custom
|
|
662
|
+
* component with the `getComponentProps` callback. See the ResultCustomCell
|
|
663
|
+
* type for more details.
|
|
664
|
+
*
|
|
665
|
+
* This component uses the useRowIds hook under the covers, which means that any
|
|
666
|
+
* changes to the structure of the Table will cause a re-render.
|
|
667
|
+
*
|
|
668
|
+
* You can use the `headerRow` and `idColumn` props to control whether the Ids
|
|
669
|
+
* appear in a <th> element at the top of the table, and the start of each row.
|
|
670
|
+
* @param props The props for this component.
|
|
671
|
+
* @returns A rendering of the ResultTable in a <table> element.
|
|
672
|
+
* @example
|
|
673
|
+
* This example creates a Provider context into which a default Queries object
|
|
674
|
+
* is provided. The ResultTableInHtmlTable component within it then renders the
|
|
675
|
+
* ResultTable in a <table> element with a CSS class.
|
|
676
|
+
*
|
|
677
|
+
* ```jsx
|
|
678
|
+
* const App = ({queries}) => (
|
|
679
|
+
* <Provider queries={queries}>
|
|
680
|
+
* <Pane />
|
|
681
|
+
* </Provider>
|
|
682
|
+
* );
|
|
683
|
+
* const Pane = () => (
|
|
684
|
+
* <ResultTableInHtmlTable queryId="petColors" className="table" />
|
|
685
|
+
* );
|
|
686
|
+
*
|
|
687
|
+
* const queries = createQueries(
|
|
688
|
+
* createStore().setTable('pets', {
|
|
689
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
690
|
+
* felix: {species: 'cat', color: 'black'},
|
|
691
|
+
* }),
|
|
692
|
+
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
693
|
+
* const app = document.createElement('div');
|
|
694
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
695
|
+
* console.log(app.innerHTML);
|
|
696
|
+
* // ->
|
|
697
|
+
* `
|
|
698
|
+
* <table class="table">
|
|
699
|
+
* <thead>
|
|
700
|
+
* <tr>
|
|
701
|
+
* <th>Id</th>
|
|
702
|
+
* <th>color</th>
|
|
703
|
+
* </tr>
|
|
704
|
+
* </thead>
|
|
705
|
+
* <tbody>
|
|
706
|
+
* <tr>
|
|
707
|
+
* <th>fido</th>
|
|
708
|
+
* <td>brown</td>
|
|
709
|
+
* </tr>
|
|
710
|
+
* <tr>
|
|
711
|
+
* <th>felix</th>
|
|
712
|
+
* <td>black</td>
|
|
713
|
+
* </tr>
|
|
714
|
+
* </tbody>
|
|
715
|
+
* </table>
|
|
716
|
+
* `;
|
|
717
|
+
* ```
|
|
718
|
+
* @example
|
|
719
|
+
* This example creates a Provider context into which a default Queries object
|
|
720
|
+
* is provided. The ResultTableInHtmlTable component within it then renders the
|
|
721
|
+
* ResultTable with a custom component and a custom props callback for the
|
|
722
|
+
* `color` Cell. The header row at the top of the table and the Id column at
|
|
723
|
+
* the start of each row is removed.
|
|
724
|
+
*
|
|
725
|
+
* ```jsx
|
|
726
|
+
* const App = ({queries}) => (
|
|
727
|
+
* <Provider queries={queries}>
|
|
728
|
+
* <Pane />
|
|
729
|
+
* </Provider>
|
|
730
|
+
* );
|
|
731
|
+
* const Pane = () => (
|
|
732
|
+
* <ResultTableInHtmlTable
|
|
733
|
+
* queryId="petColors"
|
|
734
|
+
* customCells={customCells}
|
|
735
|
+
* headerRow={false}
|
|
736
|
+
* idColumn={false}
|
|
737
|
+
* />
|
|
738
|
+
* );
|
|
739
|
+
*
|
|
740
|
+
* const FormattedResultCellView = ({queryId, rowId, cellId, bold}) => (
|
|
741
|
+
* <>
|
|
742
|
+
* {bold ? <b>{rowId}</b> : rowId}:
|
|
743
|
+
* <ResultCellView queryId={queryId} rowId={rowId} cellId={cellId} />
|
|
744
|
+
* </>
|
|
745
|
+
* );
|
|
746
|
+
* const customCells = {
|
|
747
|
+
* color: {
|
|
748
|
+
* component: FormattedResultCellView,
|
|
749
|
+
* getComponentProps: (rowId, cellId) => ({bold: rowId == 'fido'}),
|
|
750
|
+
* },
|
|
751
|
+
* };
|
|
752
|
+
*
|
|
753
|
+
* const queries = createQueries(
|
|
754
|
+
* createStore().setTable('pets', {
|
|
755
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
756
|
+
* felix: {species: 'cat', color: 'black'},
|
|
757
|
+
* }),
|
|
758
|
+
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
759
|
+
* const app = document.createElement('div');
|
|
760
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
761
|
+
* console.log(app.innerHTML);
|
|
762
|
+
* // ->
|
|
763
|
+
* `
|
|
764
|
+
* <table>
|
|
765
|
+
* <tbody>
|
|
766
|
+
* <tr>
|
|
767
|
+
* <td><b>fido</b>:brown</td>
|
|
768
|
+
* </tr>
|
|
769
|
+
* <tr>
|
|
770
|
+
* <td>felix:black</td>
|
|
771
|
+
* </tr>
|
|
772
|
+
* </tbody>
|
|
773
|
+
* </table>
|
|
774
|
+
* `;
|
|
775
|
+
* ```
|
|
776
|
+
* @category Store components
|
|
777
|
+
* @since v4.1.0
|
|
778
|
+
*/
|
|
779
|
+
export function ResultTableInHtmlTable(
|
|
780
|
+
props: ResultTableInHtmlTableProps & HtmlTableProps,
|
|
781
|
+
): ComponentReturnType;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* The SortedTableInHtmlTable component renders the contents of a single query's
|
|
785
|
+
* sorted ResultTable in a Queries object as an HTML <table> element, and
|
|
786
|
+
* registers a listener so that any changes to that result will cause a
|
|
787
|
+
* re-render.
|
|
788
|
+
*
|
|
789
|
+
* The component's props identify which ResultTable to render based on query Id,
|
|
790
|
+
* and Queries object (which is either the default context Queries object, a
|
|
791
|
+
* named context Queries object, or by explicit reference). It also takes a Cell
|
|
792
|
+
* Id to sort by and a boolean to indicate that the sorting should be in
|
|
793
|
+
* descending order. The `offset` and `limit` props are used to paginate
|
|
794
|
+
* results, but default to `0` and `undefined` to return all available Row Ids
|
|
795
|
+
* if not specified.
|
|
796
|
+
*
|
|
797
|
+
* See the <ResultSortedTableInHtmlTable /> demo for this component in action.
|
|
798
|
+
*
|
|
799
|
+
* This component renders a ResultTable by iterating over its Row objects, in
|
|
800
|
+
* the order dictated by the sort parameters. By default the Cells are in turn
|
|
801
|
+
* rendered with the CellView component, but you can override this behavior by
|
|
802
|
+
* providing a `component` for each Cell in the `customCells` prop. You
|
|
803
|
+
* can pass additional props to that custom component with the
|
|
804
|
+
* `getComponentProps` callback. See the ResultCustomCell type for more details.
|
|
805
|
+
*
|
|
806
|
+
* This component uses the useSortedRowIds hook under the covers, which means
|
|
807
|
+
* that any changes to the structure or sorting of the ResultTable will cause a
|
|
808
|
+
* re-render.
|
|
809
|
+
*
|
|
810
|
+
* You can use the `headerRow` and `idColumn` props to control whether the Ids
|
|
811
|
+
* appear in a <th> element at the top of the table, and the start of each row.
|
|
812
|
+
*
|
|
813
|
+
* The `sortOnClick` prop makes the table's sorting interactive such that the
|
|
814
|
+
* user can click on a column heading to sort by that column. The style classes
|
|
815
|
+
* `sorted` and `ascending` (or `descending`) are added so that you can provide
|
|
816
|
+
* hints to the user how the sorting is being applied.
|
|
817
|
+
* @param props The props for this component.
|
|
818
|
+
* @returns A rendering of the ResultTable in a <table> element.
|
|
819
|
+
* @example
|
|
820
|
+
* This example creates a Provider context into which a default Queries object
|
|
821
|
+
* is provided. The ResultSortedTableInHtmlTable component within it then
|
|
822
|
+
* renders the ResultTable in a <table> element with a CSS class.
|
|
823
|
+
*
|
|
824
|
+
* ```jsx
|
|
825
|
+
* const App = ({queries}) => (
|
|
826
|
+
* <Provider queries={queries}>
|
|
827
|
+
* <Pane />
|
|
828
|
+
* </Provider>
|
|
829
|
+
* );
|
|
830
|
+
* const Pane = () => (
|
|
831
|
+
* <ResultSortedTableInHtmlTable
|
|
832
|
+
* queryId="petColors"
|
|
833
|
+
* cellId="color"
|
|
834
|
+
* className="table"
|
|
835
|
+
* />
|
|
836
|
+
* );
|
|
837
|
+
*
|
|
838
|
+
* const queries = createQueries(
|
|
839
|
+
* createStore().setTable('pets', {
|
|
840
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
841
|
+
* felix: {species: 'cat', color: 'black'},
|
|
842
|
+
* }),
|
|
843
|
+
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
844
|
+
* const app = document.createElement('div');
|
|
845
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
846
|
+
* console.log(app.innerHTML);
|
|
847
|
+
* // ->
|
|
848
|
+
* `
|
|
849
|
+
* <table class="table">
|
|
850
|
+
* <thead>
|
|
851
|
+
* <tr>
|
|
852
|
+
* <th>Id</th>
|
|
853
|
+
* <th class="sorted ascending">color</th>
|
|
854
|
+
* </tr>
|
|
855
|
+
* </thead>
|
|
856
|
+
* <tbody>
|
|
857
|
+
* <tr>
|
|
858
|
+
* <th>felix</th>
|
|
859
|
+
* <td>black</td>
|
|
860
|
+
* </tr>
|
|
861
|
+
* <tr>
|
|
862
|
+
* <th>fido</th>
|
|
863
|
+
* <td>brown</td>
|
|
864
|
+
* </tr>
|
|
865
|
+
* </tbody>
|
|
866
|
+
* </table>
|
|
867
|
+
* `;
|
|
868
|
+
* ```
|
|
869
|
+
* @example
|
|
870
|
+
* This example creates a Provider context into which a default Queries object
|
|
871
|
+
* is provided. The ResultSortedTableInHtmlTable component within it then
|
|
872
|
+
* renders the ResultTable with a custom component and a custom props callback
|
|
873
|
+
* for the `color` Cell. The header row at the top of the table and the Id
|
|
874
|
+
* column at the start of each row is removed.
|
|
875
|
+
*
|
|
876
|
+
* ```jsx
|
|
877
|
+
* const App = ({queries}) => (
|
|
878
|
+
* <Provider queries={queries}>
|
|
879
|
+
* <Pane />
|
|
880
|
+
* </Provider>
|
|
881
|
+
* );
|
|
882
|
+
*
|
|
883
|
+
* const Pane = () => (
|
|
884
|
+
* <ResultSortedTableInHtmlTable
|
|
885
|
+
* queryId="petColors"
|
|
886
|
+
* cellId="color"
|
|
887
|
+
* customCells={customCells}
|
|
888
|
+
* headerRow={false}
|
|
889
|
+
* idColumn={false}
|
|
890
|
+
* />
|
|
891
|
+
* );
|
|
892
|
+
*
|
|
893
|
+
* const FormattedResultCellView = ({queryId, rowId, cellId, bold}) => (
|
|
894
|
+
* <>
|
|
895
|
+
* {bold ? <b>{rowId}</b> : rowId}:
|
|
896
|
+
* <ResultCellView queryId={queryId} rowId={rowId} cellId={cellId} />
|
|
897
|
+
* </>
|
|
898
|
+
* );
|
|
899
|
+
* const customCells = {
|
|
900
|
+
* color: {
|
|
901
|
+
* component: FormattedResultCellView,
|
|
902
|
+
* getComponentProps: (rowId, cellId) => ({bold: rowId == 'fido'}),
|
|
903
|
+
* },
|
|
904
|
+
* };
|
|
905
|
+
*
|
|
906
|
+
* const queries = createQueries(
|
|
907
|
+
* createStore().setTable('pets', {
|
|
908
|
+
* fido: {species: 'dog', color: 'brown'},
|
|
909
|
+
* felix: {species: 'cat', color: 'black'},
|
|
910
|
+
* }),
|
|
911
|
+
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
912
|
+
* const app = document.createElement('div');
|
|
913
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
914
|
+
* console.log(app.innerHTML);
|
|
915
|
+
* // ->
|
|
916
|
+
* `
|
|
917
|
+
* <table>
|
|
918
|
+
* <tbody>
|
|
919
|
+
* <tr>
|
|
920
|
+
* <td>felix:black</td>
|
|
921
|
+
* </tr>
|
|
922
|
+
* <tr>
|
|
923
|
+
* <td><b>fido</b>:brown</td>
|
|
924
|
+
* </tr>
|
|
925
|
+
* </tbody>
|
|
926
|
+
* </table>
|
|
927
|
+
* `;
|
|
928
|
+
* ```
|
|
929
|
+
* @category Store components
|
|
930
|
+
* @since v4.1.0
|
|
931
|
+
*/
|
|
932
|
+
export function ResultSortedTableInHtmlTable(
|
|
933
|
+
props: ResultSortedTableInHtmlTableProps & HtmlTableProps,
|
|
934
|
+
): ComponentReturnType;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* The EditableCellView component renders the value of a single Cell in a way
|
|
938
|
+
* that can be edited in a web browser, and registers a listener so that any
|
|
939
|
+
* changes to that result will cause a re-render.
|
|
940
|
+
*
|
|
941
|
+
* The component's props identify which Cell to render based on Table Id, Row
|
|
942
|
+
* Id, Cell Id, and Store (which is either the default context Store, a named
|
|
943
|
+
* context Store, or an explicit reference).
|
|
944
|
+
*
|
|
945
|
+
* A Cell contains a string, number, or boolean, so the value is rendered in an
|
|
946
|
+
* appropriate <input> tag and a button lets the user change type, if possible.
|
|
947
|
+
*
|
|
948
|
+
* This component uses the useCell hook under the covers, which means that any
|
|
949
|
+
* changes to the specified Cell outside of this component will cause a
|
|
950
|
+
* re-render.
|
|
951
|
+
*
|
|
952
|
+
* You can provide a custom className prop which well be used on the root of the
|
|
953
|
+
* resulting element. If omitted the element's class will be `editableCell`. The
|
|
954
|
+
* debugIds prop has no effect on this component.
|
|
955
|
+
* @param props The props for this component.
|
|
956
|
+
* @returns An editable rendering of the Cell.
|
|
957
|
+
* @example
|
|
958
|
+
* This example creates a Provider context into which a default Store is
|
|
959
|
+
* provided. The EditableCellView component within it then renders an editable
|
|
960
|
+
* Cell.
|
|
961
|
+
*
|
|
962
|
+
* ```jsx
|
|
963
|
+
* const App = ({store}) => (
|
|
964
|
+
* <Provider store={store}>
|
|
965
|
+
* <Pane />
|
|
966
|
+
* </Provider>
|
|
967
|
+
* );
|
|
968
|
+
* const Pane = () => (
|
|
969
|
+
* <EditableCellView tableId="pets" rowId="fido" cellId="color" />
|
|
970
|
+
* );
|
|
971
|
+
*
|
|
972
|
+
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
973
|
+
* const app = document.createElement('div');
|
|
974
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
975
|
+
* console.log(app.innerHTML);
|
|
976
|
+
* // ->
|
|
977
|
+
* `
|
|
978
|
+
* <div class="editableCell">
|
|
979
|
+
* <button type="button" class="string">string</button>
|
|
980
|
+
* <input value="brown">
|
|
981
|
+
* </div>
|
|
982
|
+
* `;
|
|
983
|
+
* ```
|
|
984
|
+
* @category Store components
|
|
985
|
+
* @since v4.1.0
|
|
986
|
+
*/
|
|
987
|
+
export function EditableCellView(
|
|
988
|
+
props: CellProps & {readonly className?: string},
|
|
989
|
+
): ComponentReturnType;
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* The EditableValueView component renders the value of a single Value in a way
|
|
993
|
+
* that can be edited in a web browser, and registers a listener so that any
|
|
994
|
+
* changes to that result will cause a re-render.
|
|
995
|
+
*
|
|
996
|
+
* The component's props identify which Value to render based on Table Id, Row
|
|
997
|
+
* Id, Value Id, and Store (which is either the default context Store, a named
|
|
998
|
+
* context Store, or an explicit reference).
|
|
999
|
+
*
|
|
1000
|
+
* A Value contains a string, number, or boolean, so the value is rendered in an
|
|
1001
|
+
* appropriate <input> tag and a button lets the user change type, if possible.
|
|
1002
|
+
*
|
|
1003
|
+
* This component uses the useValue hook under the covers, which means that any
|
|
1004
|
+
* changes to the specified Value outside of this component will cause a
|
|
1005
|
+
* re-render.
|
|
1006
|
+
*
|
|
1007
|
+
* You can provide a custom className prop which well be used on the root of the
|
|
1008
|
+
* resulting element. If omitted the element's class will be `editableValue`.
|
|
1009
|
+
* The debugIds prop has no effect on this component.
|
|
1010
|
+
* @param props The props for this component.
|
|
1011
|
+
* @returns An editable rendering of the Value.
|
|
1012
|
+
* @example
|
|
1013
|
+
* This example creates a Provider context into which a default Store is
|
|
1014
|
+
* provided. The EditableValueView component within it then renders an editable
|
|
1015
|
+
* Value.
|
|
1016
|
+
*
|
|
1017
|
+
* ```jsx
|
|
1018
|
+
* const App = ({store}) => (
|
|
1019
|
+
* <Provider store={store}>
|
|
1020
|
+
* <Pane />
|
|
1021
|
+
* </Provider>
|
|
1022
|
+
* );
|
|
1023
|
+
* const Pane = () => <EditableValueView valueId="employees" />;
|
|
1024
|
+
*
|
|
1025
|
+
* const store = createStore().setValue('employees', 3);
|
|
1026
|
+
* const app = document.createElement('div');
|
|
1027
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
1028
|
+
* console.log(app.innerHTML);
|
|
1029
|
+
* // ->
|
|
1030
|
+
* `
|
|
1031
|
+
* <div class="editableValue">
|
|
1032
|
+
* <button type="button" class="number">number</button>
|
|
1033
|
+
* <input type="number" value="3">
|
|
1034
|
+
* </div>
|
|
1035
|
+
* `;
|
|
1036
|
+
* ```
|
|
1037
|
+
* @category Store components
|
|
1038
|
+
* @since v4.1.0
|
|
1039
|
+
*/
|
|
1040
|
+
export function EditableValueView(
|
|
1041
|
+
props: ValueProps & {readonly className?: string},
|
|
544
1042
|
): ComponentReturnType;
|