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.
Files changed (219) hide show
  1. package/bin/cli.js +1 -1
  2. package/lib/checkpoints.js +1 -1
  3. package/lib/checkpoints.js.gz +0 -0
  4. package/lib/cjs/checkpoints.cjs +1 -1
  5. package/lib/cjs/checkpoints.cjs.gz +0 -0
  6. package/lib/cjs/indexes.cjs +1 -1
  7. package/lib/cjs/indexes.cjs.gz +0 -0
  8. package/lib/cjs/metrics.cjs +1 -1
  9. package/lib/cjs/metrics.cjs.gz +0 -0
  10. package/lib/cjs/persisters/persister-browser.cjs +1 -1
  11. package/lib/cjs/persisters/persister-browser.cjs.gz +0 -0
  12. package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs +1 -1
  13. package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
  14. package/lib/cjs/persisters/persister-file.cjs +1 -1
  15. package/lib/cjs/persisters/persister-file.cjs.gz +0 -0
  16. package/lib/cjs/persisters/persister-remote.cjs +1 -1
  17. package/lib/cjs/persisters/persister-remote.cjs.gz +0 -0
  18. package/lib/cjs/persisters/persister-sqlite-wasm.cjs +1 -1
  19. package/lib/cjs/persisters/persister-sqlite-wasm.cjs.gz +0 -0
  20. package/lib/cjs/persisters/persister-sqlite3.cjs +1 -1
  21. package/lib/cjs/persisters/persister-sqlite3.cjs.gz +0 -0
  22. package/lib/cjs/queries.cjs +1 -1
  23. package/lib/cjs/queries.cjs.gz +0 -0
  24. package/lib/cjs/relationships.cjs +1 -1
  25. package/lib/cjs/relationships.cjs.gz +0 -0
  26. package/lib/cjs/store.cjs +1 -1
  27. package/lib/cjs/store.cjs.gz +0 -0
  28. package/lib/cjs/tinybase.cjs +1 -1
  29. package/lib/cjs/tinybase.cjs.gz +0 -0
  30. package/lib/cjs/tools.cjs +1 -1
  31. package/lib/cjs/tools.cjs.gz +0 -0
  32. package/lib/cjs/ui-react-dom.cjs +1 -1
  33. package/lib/cjs/ui-react-dom.cjs.gz +0 -0
  34. package/lib/cjs/ui-react.cjs +1 -1
  35. package/lib/cjs/ui-react.cjs.gz +0 -0
  36. package/lib/cjs-es6/checkpoints.cjs +1 -1
  37. package/lib/cjs-es6/checkpoints.cjs.gz +0 -0
  38. package/lib/cjs-es6/indexes.cjs +1 -1
  39. package/lib/cjs-es6/indexes.cjs.gz +0 -0
  40. package/lib/cjs-es6/metrics.cjs +1 -1
  41. package/lib/cjs-es6/metrics.cjs.gz +0 -0
  42. package/lib/cjs-es6/persisters/persister-browser.cjs +1 -1
  43. package/lib/cjs-es6/persisters/persister-browser.cjs.gz +0 -0
  44. package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs +1 -1
  45. package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
  46. package/lib/cjs-es6/persisters/persister-file.cjs +1 -1
  47. package/lib/cjs-es6/persisters/persister-file.cjs.gz +0 -0
  48. package/lib/cjs-es6/persisters/persister-remote.cjs +1 -1
  49. package/lib/cjs-es6/persisters/persister-remote.cjs.gz +0 -0
  50. package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs +1 -1
  51. package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs.gz +0 -0
  52. package/lib/cjs-es6/persisters/persister-sqlite3.cjs +1 -1
  53. package/lib/cjs-es6/persisters/persister-sqlite3.cjs.gz +0 -0
  54. package/lib/cjs-es6/queries.cjs +1 -1
  55. package/lib/cjs-es6/queries.cjs.gz +0 -0
  56. package/lib/cjs-es6/relationships.cjs +1 -1
  57. package/lib/cjs-es6/relationships.cjs.gz +0 -0
  58. package/lib/cjs-es6/store.cjs +1 -1
  59. package/lib/cjs-es6/store.cjs.gz +0 -0
  60. package/lib/cjs-es6/tinybase.cjs +1 -1
  61. package/lib/cjs-es6/tinybase.cjs.gz +0 -0
  62. package/lib/cjs-es6/tools.cjs +1 -1
  63. package/lib/cjs-es6/tools.cjs.gz +0 -0
  64. package/lib/cjs-es6/ui-react-dom.cjs +1 -1
  65. package/lib/cjs-es6/ui-react-dom.cjs.gz +0 -0
  66. package/lib/cjs-es6/ui-react.cjs +1 -1
  67. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  68. package/lib/debug/checkpoints.js +6 -6
  69. package/lib/debug/indexes.js +7 -7
  70. package/lib/debug/metrics.js +12 -12
  71. package/lib/debug/persisters/persister-browser.js +10 -19
  72. package/lib/debug/persisters/persister-cr-sqlite-wasm.js +6 -15
  73. package/lib/debug/persisters/persister-file.js +10 -19
  74. package/lib/debug/persisters/persister-remote.js +10 -19
  75. package/lib/debug/persisters/persister-sqlite-wasm.js +6 -15
  76. package/lib/debug/persisters/persister-sqlite3.js +6 -15
  77. package/lib/debug/persisters.js +4 -4
  78. package/lib/debug/queries.js +1 -0
  79. package/lib/debug/relationships.js +7 -7
  80. package/lib/debug/store.js +16 -24
  81. package/lib/debug/tinybase.js +21 -28
  82. package/lib/debug/tools.js +14 -13
  83. package/lib/debug/ui-react-dom.js +253 -33
  84. package/lib/debug/ui-react.js +26 -4
  85. package/lib/es6/checkpoints.js +1 -1
  86. package/lib/es6/checkpoints.js.gz +0 -0
  87. package/lib/es6/indexes.js +1 -1
  88. package/lib/es6/indexes.js.gz +0 -0
  89. package/lib/es6/metrics.js +1 -1
  90. package/lib/es6/metrics.js.gz +0 -0
  91. package/lib/es6/persisters/persister-browser.js +1 -1
  92. package/lib/es6/persisters/persister-browser.js.gz +0 -0
  93. package/lib/es6/persisters/persister-cr-sqlite-wasm.js +1 -1
  94. package/lib/es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  95. package/lib/es6/persisters/persister-file.js +1 -1
  96. package/lib/es6/persisters/persister-file.js.gz +0 -0
  97. package/lib/es6/persisters/persister-remote.js +1 -1
  98. package/lib/es6/persisters/persister-remote.js.gz +0 -0
  99. package/lib/es6/persisters/persister-sqlite-wasm.js +1 -1
  100. package/lib/es6/persisters/persister-sqlite-wasm.js.gz +0 -0
  101. package/lib/es6/persisters/persister-sqlite3.js +1 -1
  102. package/lib/es6/persisters/persister-sqlite3.js.gz +0 -0
  103. package/lib/es6/queries.js +1 -1
  104. package/lib/es6/queries.js.gz +0 -0
  105. package/lib/es6/relationships.js +1 -1
  106. package/lib/es6/relationships.js.gz +0 -0
  107. package/lib/es6/store.js +1 -1
  108. package/lib/es6/store.js.gz +0 -0
  109. package/lib/es6/tinybase.js +1 -1
  110. package/lib/es6/tinybase.js.gz +0 -0
  111. package/lib/es6/tools.js +1 -1
  112. package/lib/es6/tools.js.gz +0 -0
  113. package/lib/es6/ui-react-dom.js +1 -1
  114. package/lib/es6/ui-react-dom.js.gz +0 -0
  115. package/lib/es6/ui-react.js +1 -1
  116. package/lib/es6/ui-react.js.gz +0 -0
  117. package/lib/indexes.js +1 -1
  118. package/lib/indexes.js.gz +0 -0
  119. package/lib/metrics.js +1 -1
  120. package/lib/metrics.js.gz +0 -0
  121. package/lib/persisters/persister-browser.js +1 -1
  122. package/lib/persisters/persister-browser.js.gz +0 -0
  123. package/lib/persisters/persister-cr-sqlite-wasm.js +1 -1
  124. package/lib/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  125. package/lib/persisters/persister-file.js +1 -1
  126. package/lib/persisters/persister-file.js.gz +0 -0
  127. package/lib/persisters/persister-remote.js +1 -1
  128. package/lib/persisters/persister-remote.js.gz +0 -0
  129. package/lib/persisters/persister-sqlite-wasm.js +1 -1
  130. package/lib/persisters/persister-sqlite-wasm.js.gz +0 -0
  131. package/lib/persisters/persister-sqlite3.js +1 -1
  132. package/lib/persisters/persister-sqlite3.js.gz +0 -0
  133. package/lib/queries.js +1 -1
  134. package/lib/queries.js.gz +0 -0
  135. package/lib/relationships.js +1 -1
  136. package/lib/relationships.js.gz +0 -0
  137. package/lib/store.js +1 -1
  138. package/lib/store.js.gz +0 -0
  139. package/lib/tinybase.js +1 -1
  140. package/lib/tinybase.js.gz +0 -0
  141. package/lib/tools.js +1 -1
  142. package/lib/tools.js.gz +0 -0
  143. package/lib/types/queries.d.ts +167 -0
  144. package/lib/types/ui-react-dom.d.ts +568 -70
  145. package/lib/types/ui-react.d.ts +269 -58
  146. package/lib/types/with-schemas/internal/ui-react.d.ts +32 -22
  147. package/lib/types/with-schemas/queries.d.ts +185 -0
  148. package/lib/types/with-schemas/ui-react-dom.d.ts +647 -93
  149. package/lib/types/with-schemas/ui-react.d.ts +281 -50
  150. package/lib/ui-react-dom.js +1 -1
  151. package/lib/ui-react-dom.js.gz +0 -0
  152. package/lib/ui-react.js +1 -1
  153. package/lib/ui-react.js.gz +0 -0
  154. package/lib/umd/checkpoints.js +1 -1
  155. package/lib/umd/checkpoints.js.gz +0 -0
  156. package/lib/umd/indexes.js +1 -1
  157. package/lib/umd/indexes.js.gz +0 -0
  158. package/lib/umd/metrics.js +1 -1
  159. package/lib/umd/metrics.js.gz +0 -0
  160. package/lib/umd/persisters/persister-browser.js +1 -1
  161. package/lib/umd/persisters/persister-browser.js.gz +0 -0
  162. package/lib/umd/persisters/persister-cr-sqlite-wasm.js +1 -1
  163. package/lib/umd/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  164. package/lib/umd/persisters/persister-file.js +1 -1
  165. package/lib/umd/persisters/persister-file.js.gz +0 -0
  166. package/lib/umd/persisters/persister-remote.js +1 -1
  167. package/lib/umd/persisters/persister-remote.js.gz +0 -0
  168. package/lib/umd/persisters/persister-sqlite-wasm.js +1 -1
  169. package/lib/umd/persisters/persister-sqlite-wasm.js.gz +0 -0
  170. package/lib/umd/persisters/persister-sqlite3.js +1 -1
  171. package/lib/umd/persisters/persister-sqlite3.js.gz +0 -0
  172. package/lib/umd/queries.js +1 -1
  173. package/lib/umd/queries.js.gz +0 -0
  174. package/lib/umd/relationships.js +1 -1
  175. package/lib/umd/relationships.js.gz +0 -0
  176. package/lib/umd/store.js +1 -1
  177. package/lib/umd/store.js.gz +0 -0
  178. package/lib/umd/tinybase.js +1 -1
  179. package/lib/umd/tinybase.js.gz +0 -0
  180. package/lib/umd/tools.js +1 -1
  181. package/lib/umd/tools.js.gz +0 -0
  182. package/lib/umd/ui-react-dom.js +1 -1
  183. package/lib/umd/ui-react-dom.js.gz +0 -0
  184. package/lib/umd/ui-react.js +1 -1
  185. package/lib/umd/ui-react.js.gz +0 -0
  186. package/lib/umd-es6/checkpoints.js +1 -1
  187. package/lib/umd-es6/checkpoints.js.gz +0 -0
  188. package/lib/umd-es6/indexes.js +1 -1
  189. package/lib/umd-es6/indexes.js.gz +0 -0
  190. package/lib/umd-es6/metrics.js +1 -1
  191. package/lib/umd-es6/metrics.js.gz +0 -0
  192. package/lib/umd-es6/persisters/persister-browser.js +1 -1
  193. package/lib/umd-es6/persisters/persister-browser.js.gz +0 -0
  194. package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js +1 -1
  195. package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  196. package/lib/umd-es6/persisters/persister-file.js +1 -1
  197. package/lib/umd-es6/persisters/persister-file.js.gz +0 -0
  198. package/lib/umd-es6/persisters/persister-remote.js +1 -1
  199. package/lib/umd-es6/persisters/persister-remote.js.gz +0 -0
  200. package/lib/umd-es6/persisters/persister-sqlite-wasm.js +1 -1
  201. package/lib/umd-es6/persisters/persister-sqlite-wasm.js.gz +0 -0
  202. package/lib/umd-es6/persisters/persister-sqlite3.js +1 -1
  203. package/lib/umd-es6/persisters/persister-sqlite3.js.gz +0 -0
  204. package/lib/umd-es6/queries.js +1 -1
  205. package/lib/umd-es6/queries.js.gz +0 -0
  206. package/lib/umd-es6/relationships.js +1 -1
  207. package/lib/umd-es6/relationships.js.gz +0 -0
  208. package/lib/umd-es6/store.js +1 -1
  209. package/lib/umd-es6/store.js.gz +0 -0
  210. package/lib/umd-es6/tinybase.js +1 -1
  211. package/lib/umd-es6/tinybase.js.gz +0 -0
  212. package/lib/umd-es6/tools.js +1 -1
  213. package/lib/umd-es6/tools.js.gz +0 -0
  214. package/lib/umd-es6/ui-react-dom.js +1 -1
  215. package/lib/umd-es6/ui-react-dom.js.gz +0 -0
  216. package/lib/umd-es6/ui-react.js +1 -1
  217. package/lib/umd-es6/ui-react.js.gz +0 -0
  218. package/package.json +17 -17
  219. package/readme.md +2 -2
@@ -69,6 +69,7 @@ import {
69
69
  ResultCellListener,
70
70
  ResultRowIdsListener,
71
71
  ResultRowListener,
72
+ ResultTableCellIdsListener,
72
73
  ResultTableListener,
73
74
  } from './queries.d';
74
75
  import {Persister} from './persisters.d';
@@ -5273,7 +5274,7 @@ export function useQueries(id?: Id): Queries | undefined;
5273
5274
 
5274
5275
  /**
5275
5276
  * The useResultTable hook returns an object containing the entire data of the
5276
- * result Table of the given query, and registers a listener so that any changes
5277
+ * ResultTable of the given query, and registers a listener so that any changes
5277
5278
  * to that result will cause a re-render.
5278
5279
  *
5279
5280
  * A Provider component is used to wrap part of an application in a context, and
@@ -5290,7 +5291,7 @@ export function useQueries(id?: Id): Queries | undefined;
5290
5291
  * @param queriesOrQueriesId The Queries object to be accessed: omit for the
5291
5292
  * default context Queries object, provide an Id for a named context Queries
5292
5293
  * object, or provide an explicit reference.
5293
- * @returns An object containing the entire data of the result Table.
5294
+ * @returns An object containing the entire data of the ResultTable.
5294
5295
  * @example
5295
5296
  * This example creates a Queries object outside the application, which is used
5296
5297
  * in the useTable hook by reference. A change to the data in the query
@@ -5391,7 +5392,136 @@ export function useResultTable(
5391
5392
  ): Table;
5392
5393
 
5393
5394
  /**
5394
- * The useResultRowIds hook returns the Ids of every Row in the result Table of
5395
+ * The useResultTableCellIds hook returns the Ids of every Cell used across the
5396
+ * whole ResultTable of the given query, and registers a listener so that any
5397
+ * changes to those Ids will cause a re-render.
5398
+ *
5399
+ * A Provider component is used to wrap part of an application in a context, and
5400
+ * it can contain a default Queries object or a set of Queries objects named by
5401
+ * Id. The useResultTableCellIds hook lets you indicate which Queries object to
5402
+ * get data for: omit the final optional final parameter for the default context
5403
+ * Queries object, provide an Id for a named context Queries object, or provide
5404
+ * a Queries object explicitly by reference.
5405
+ *
5406
+ * When first rendered, this hook will create a listener so that changes to the
5407
+ * result Cell Ids will cause a re-render. When the component containing this
5408
+ * hook is unmounted, the listener will be automatically removed.
5409
+ * @param queryId The Id of the query.
5410
+ * @param queriesOrQueriesId The Queries object to be accessed: omit for the
5411
+ * default context Queries object, provide an Id for a named context Queries
5412
+ * object, or provide an explicit reference. See the
5413
+ * addResultTableCellIdsListener method for more details.
5414
+ * @returns An array of the Ids of every Cell in the result of the query.
5415
+ * @example
5416
+ * This example creates a Queries object outside the application, which is used
5417
+ * in the useResultTableCellIds hook by reference. A change to the data in the
5418
+ * query re-renders the component.
5419
+ *
5420
+ * ```jsx
5421
+ * const store = createStore().setTable('pets', {
5422
+ * fido: {species: 'dog', color: 'brown'},
5423
+ * felix: {species: 'cat', color: 'black'},
5424
+ * cujo: {species: 'dog', color: 'black'},
5425
+ * });
5426
+ * const queries = createQueries(store).setQueryDefinition(
5427
+ * 'dogColorsAndLegs',
5428
+ * 'pets',
5429
+ * ({select, where}) => {
5430
+ * select('color');
5431
+ * select('legs');
5432
+ * where('species', 'dog');
5433
+ * },
5434
+ * );
5435
+ * const App = () => (
5436
+ * <span>
5437
+ * {JSON.stringify(useResultTableCellIds('dogColorsAndLegs', queries))}
5438
+ * </span>
5439
+ * );
5440
+ *
5441
+ * const app = document.createElement('div');
5442
+ * ReactDOMClient.createRoot(app).render(<App />); // !act
5443
+ * console.log(app.innerHTML);
5444
+ * // -> '<span>["color"]</span>'
5445
+ *
5446
+ * store.setCell('pets', 'cujo', 'legs', 4); // !act
5447
+ * console.log(app.innerHTML);
5448
+ * // -> '<span>["color","legs"]</span>'
5449
+ * ```
5450
+ * @example
5451
+ * This example creates a Provider context into which a default Queries object
5452
+ * is provided. A component within it then uses the useResultTableCellIds hook.
5453
+ *
5454
+ * ```jsx
5455
+ * const App = ({queries}) => (
5456
+ * <Provider queries={queries}>
5457
+ * <Pane />
5458
+ * </Provider>
5459
+ * );
5460
+ * const Pane = () => (
5461
+ * <span>{JSON.stringify(useResultTableCellIds('dogColorsAndLegs'))}</span>
5462
+ * );
5463
+ *
5464
+ * const queries = createQueries(
5465
+ * createStore().setTable('pets', {
5466
+ * fido: {species: 'dog', color: 'brown'},
5467
+ * felix: {species: 'cat', color: 'black'},
5468
+ * cujo: {species: 'dog', color: 'black', legs: 4},
5469
+ * }),
5470
+ * ).setQueryDefinition('dogColorsAndLegs', 'pets', ({select, where}) => {
5471
+ * select('color');
5472
+ * select('legs');
5473
+ * where('species', 'dog');
5474
+ * });
5475
+ * const app = document.createElement('div');
5476
+ * ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
5477
+ * console.log(app.innerHTML);
5478
+ * // -> '<span>["color","legs"]</span>'
5479
+ * ```
5480
+ * @example
5481
+ * This example creates a Provider context into which a Queries object is
5482
+ * provided, named by Id. A component within it then uses the
5483
+ * useResultTableCellIds hook.
5484
+ *
5485
+ * ```jsx
5486
+ * const App = ({queries}) => (
5487
+ * <Provider queriesById={{petQueries: queries}}>
5488
+ * <Pane />
5489
+ * </Provider>
5490
+ * );
5491
+ * const Pane = () => (
5492
+ * <span>
5493
+ * {JSON.stringify(
5494
+ * useResultTableCellIds('dogColorsAndLegs', 'petQueries'),
5495
+ * )}
5496
+ * </span>
5497
+ * );
5498
+ *
5499
+ * const queries = createQueries(
5500
+ * createStore().setTable('pets', {
5501
+ * fido: {species: 'dog', color: 'brown'},
5502
+ * felix: {species: 'cat', color: 'black'},
5503
+ * cujo: {species: 'dog', color: 'black', legs: 4},
5504
+ * }),
5505
+ * ).setQueryDefinition('dogColorsAndLegs', 'pets', ({select, where}) => {
5506
+ * select('color');
5507
+ * select('legs');
5508
+ * where('species', 'dog');
5509
+ * });
5510
+ * const app = document.createElement('div');
5511
+ * ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
5512
+ * console.log(app.innerHTML);
5513
+ * // -> '<span>["color","legs"]</span>'
5514
+ * ```
5515
+ * @category Queries hooks
5516
+ * @since v4.1.0
5517
+ */
5518
+ export function useResultTableCellIds(
5519
+ queryId: Id,
5520
+ queriesOrQueriesId?: QueriesOrQueriesId,
5521
+ ): Ids;
5522
+
5523
+ /**
5524
+ * The useResultRowIds hook returns the Ids of every Row in the ResultTable of
5395
5525
  * the given query, and registers a listener so that any changes to those Ids
5396
5526
  * will cause a re-render.
5397
5527
  *
@@ -5512,7 +5642,7 @@ export function useResultRowIds(
5512
5642
 
5513
5643
  /**
5514
5644
  * The useResultSortedRowIds hook returns the sorted (and optionally, paginated)
5515
- * Ids of every Row in the result Table of the given query, and registers a
5645
+ * Ids of every Row in the ResultTable of the given query, and registers a
5516
5646
  * listener so that any changes to those Ids will cause a re-render.
5517
5647
  *
5518
5648
  * A Provider component is used to wrap part of an application in a context, and
@@ -5663,9 +5793,9 @@ export function useResultSortedRowIds(
5663
5793
  ): Ids;
5664
5794
 
5665
5795
  /**
5666
- * The useResultRow hook returns an object containing the data of a
5667
- * single Row in the result Table of the given query, and registers a listener
5668
- * so that any changes to that Row will cause a re-render.
5796
+ * The useResultRow hook returns an object containing the data of a single Row
5797
+ * in the ResultTable of the given query, and registers a listener so that any
5798
+ * changes to that Row will cause a re-render.
5669
5799
  *
5670
5800
  * A Provider component is used to wrap part of an application in a context, and
5671
5801
  * it can contain a default Queries object or a set of Queries objects named by
@@ -5678,11 +5808,11 @@ export function useResultSortedRowIds(
5678
5808
  * result Row will cause a re-render. When the component containing this hook is
5679
5809
  * unmounted, the listener will be automatically removed.
5680
5810
  * @param queryId The Id of the query.
5681
- * @param rowId The Id of the Row in the result Table.
5811
+ * @param rowId The Id of the Row in the ResultTable.
5682
5812
  * @param queriesOrQueriesId The Queries object to be accessed: omit for the
5683
5813
  * default context Queries object, provide an Id for a named context Queries
5684
5814
  * object, or provide an explicit reference.
5685
- * @returns An object containing the entire data of the Row in the result Table
5815
+ * @returns An object containing the entire data of the Row in the ResultTable
5686
5816
  * of the query.
5687
5817
  * @example
5688
5818
  * This example creates a Queries object outside the application, which is used
@@ -5788,7 +5918,7 @@ export function useResultRow(
5788
5918
 
5789
5919
  /**
5790
5920
  * The useResultCellIds hook returns the Ids of every Cell in a given Row in the
5791
- * result Table of the given query, and registers a listener so that any changes
5921
+ * ResultTable of the given query, and registers a listener so that any changes
5792
5922
  * to those Ids will cause a re-render.
5793
5923
  *
5794
5924
  * A Provider component is used to wrap part of an application in a context, and
@@ -5802,7 +5932,7 @@ export function useResultRow(
5802
5932
  * result Cell Ids will cause a re-render. When the component containing this
5803
5933
  * hook is unmounted, the listener will be automatically removed.
5804
5934
  * @param queryId The Id of the query.
5805
- * @param rowId The Id of the Row in the result Table.
5935
+ * @param rowId The Id of the Row in the ResultTable.
5806
5936
  * @param queriesOrQueriesId The Queries object to be accessed: omit for the
5807
5937
  * default context Queries object, provide an Id for a named context Queries
5808
5938
  * object, or provide an explicit reference.
@@ -5918,7 +6048,7 @@ export function useResultCellIds(
5918
6048
 
5919
6049
  /**
5920
6050
  * The useResultCell hook returns the value of a single Cell in a given Row in
5921
- * the result Table of the given query, and registers a listener so that any
6051
+ * the ResultTable of the given query, and registers a listener so that any
5922
6052
  * changes to that value will cause a re-render.
5923
6053
  *
5924
6054
  * A Provider component is used to wrap part of an application in a context, and
@@ -5932,7 +6062,7 @@ export function useResultCellIds(
5932
6062
  * result Cell will cause a re-render. When the component containing this hook
5933
6063
  * is unmounted, the listener will be automatically removed.
5934
6064
  * @param queryId The Id of the query.
5935
- * @param rowId The Id of the Row in the result Table.
6065
+ * @param rowId The Id of the Row in the ResultTable.
5936
6066
  * @param cellId The Id of the Cell in the Row.
5937
6067
  * @param queriesOrQueriesId The Queries object to be accessed: omit for the
5938
6068
  * default context Queries object, provide an Id for a named context Queries
@@ -6045,14 +6175,14 @@ export function useResultCell(
6045
6175
 
6046
6176
  /**
6047
6177
  * The useResultTableListener hook registers a listener function with a Queries
6048
- * object that will be called whenever data in a result Table changes.
6178
+ * object that will be called whenever data in a ResultTable changes.
6049
6179
  *
6050
6180
  * This hook is useful for situations where a component needs to register its
6051
6181
  * own specific listener to do more than simply tracking the value (which is
6052
6182
  * more easily done with the useResultTable hook).
6053
6183
  *
6054
- * You can either listen to a single result Table (by specifying a query Id as
6055
- * the method's first parameter) or changes to any result Table (by providing a
6184
+ * You can either listen to a single ResultTable (by specifying a query Id as
6185
+ * the method's first parameter) or changes to any ResultTable (by providing a
6056
6186
  * `null` wildcard).
6057
6187
  *
6058
6188
  * Unlike the addResultTableListener method, which returns a listener Id and
@@ -6062,7 +6192,7 @@ export function useResultCell(
6062
6192
  * Queries object will be deleted.
6063
6193
  * @param queryId The Id of the query to listen to, or `null` as a wildcard.
6064
6194
  * @param listener The function that will be called whenever data in the
6065
- * matching result Table changes.
6195
+ * matching ResultTable changes.
6066
6196
  * @param listenerDeps An optional array of dependencies for the `listener`
6067
6197
  * function, which, if any change, result in the re-registration of the
6068
6198
  * listener. This parameter defaults to an empty array.
@@ -6120,16 +6250,97 @@ export function useResultTableListener(
6120
6250
  queriesOrQueriesId?: QueriesOrQueriesId,
6121
6251
  ): void;
6122
6252
 
6253
+ /**
6254
+ * The useResultTableCellIdsListener hook registers a listener function with a
6255
+ * Queries object that will be called whenever the Cell Ids that appear anywhere
6256
+ * in a ResultTable change.
6257
+ *
6258
+ * This hook is useful for situations where a component needs to register its
6259
+ * own specific listener to do more than simply tracking the value (which is
6260
+ * more easily done with the useResultTableCellIds hook).
6261
+ *
6262
+ * You can either listen to a single ResultTable (by specifying a query Id as
6263
+ * the method's first parameter) or changes to any ResultTable (by providing a
6264
+ * `null` wildcard).
6265
+ *
6266
+ * Unlike the addResultTableCellIdsListener method, which returns a listener Id
6267
+ * and requires you to remove it manually, the useResultTableCellIdsListener
6268
+ * hook manages this lifecycle for you: when the listener changes (per its
6269
+ * `listenerDeps` dependencies) or the component unmounts, the listener on the
6270
+ * underlying Queries object will be deleted.
6271
+ * @param queryId The Id of the query to listen to, or `null` as a wildcard.
6272
+ * @param listener The function that will be called whenever the Cell Ids that
6273
+ * appear anywhere in the ResultTable change.
6274
+ * @param listenerDeps An optional array of dependencies for the `listener`
6275
+ * function, which, if any change, result in the re-registration of the
6276
+ * listener. This parameter defaults to an empty array.
6277
+ * @param queriesOrQueriesId The Queries object to register the listener with:
6278
+ * omit for the default context Queries object, provide an Id for a named
6279
+ * context Queries object, or provide an explicit reference.
6280
+ * @example
6281
+ * This example uses the useResultTableCellIdsListener hook to create a listener
6282
+ * that is scoped to a single component. When the component is unmounted, the
6283
+ * listener is removed from the Queries object.
6284
+ *
6285
+ * ```jsx
6286
+ * const App = ({queries}) => (
6287
+ * <Provider queries={queries}>
6288
+ * <Pane />
6289
+ * </Provider>
6290
+ * );
6291
+ * const Pane = () => {
6292
+ * useResultTableCellIdsListener('petColorsAndLegs', () =>
6293
+ * console.log('Result Cell Ids changed'),
6294
+ * );
6295
+ * return <span>App</span>;
6296
+ * };
6297
+ *
6298
+ * const store = createStore().setTable('pets', {
6299
+ * fido: {species: 'dog', color: 'brown'},
6300
+ * felix: {species: 'cat', color: 'black'},
6301
+ * cujo: {species: 'dog', color: 'black'},
6302
+ * });
6303
+ * const queries = createQueries(store).setQueryDefinition(
6304
+ * 'petColorsAndLegs',
6305
+ * 'pets',
6306
+ * ({select}) => {
6307
+ * select('color');
6308
+ * select('legs');
6309
+ * },
6310
+ * );
6311
+ * const app = document.createElement('div');
6312
+ * const root = ReactDOMClient.createRoot(app);
6313
+ * root.render(<App queries={queries} />); // !act
6314
+ * console.log(queries.getListenerStats().tableCellIds);
6315
+ * // -> 1
6316
+ *
6317
+ * store.setCell('pets', 'cujo', 'legs', 4); // !act
6318
+ * // -> 'Result Cell Ids changed'
6319
+ *
6320
+ * root.unmount(); // !act
6321
+ * console.log(queries.getListenerStats().tableCellIds);
6322
+ * // -> 0
6323
+ * ```
6324
+ * @category Queries hooks
6325
+ * @since v4.1.0
6326
+ */
6327
+ export function useResultTableCellIdsListener(
6328
+ queryId: IdOrNull,
6329
+ listener: ResultTableCellIdsListener,
6330
+ listenerDeps?: React.DependencyList,
6331
+ queriesOrQueriesId?: QueriesOrQueriesId,
6332
+ ): void;
6333
+
6123
6334
  /**
6124
6335
  * The useResultRowIdsListener hook registers a listener function with a Queries
6125
- * object that will be called whenever the Row Ids in a result Table change.
6336
+ * object that will be called whenever the Row Ids in a ResultTable change.
6126
6337
  *
6127
6338
  * This hook is useful for situations where a component needs to register its
6128
6339
  * own specific listener to do more than simply tracking the value (which is
6129
6340
  * more easily done with the useResultRowIds hook).
6130
6341
  *
6131
- * You can either listen to a single result Table (by specifying a query Id as
6132
- * the method's first parameter) or changes to any result Table (by providing a
6342
+ * You can either listen to a single ResultTable (by specifying a query Id as
6343
+ * the method's first parameter) or changes to any ResultTable (by providing a
6133
6344
  * `null` wildcard).
6134
6345
  *
6135
6346
  * Unlike the addResultRowIdsListener method, which returns a listener Id and
@@ -6139,7 +6350,7 @@ export function useResultTableListener(
6139
6350
  * Queries object will be deleted.
6140
6351
  * @param queryId The Id of the query to listen to, or `null` as a wildcard.
6141
6352
  * @param listener The function that will be called whenever the Row Ids in the
6142
- * matching result Table change.
6353
+ * matching ResultTable change.
6143
6354
  * @param listenerDeps An optional array of dependencies for the `listener`
6144
6355
  * function, which, if any change, result in the re-registration of the
6145
6356
  * listener. This parameter defaults to an empty array.
@@ -6200,7 +6411,7 @@ export function useResultRowIdsListener(
6200
6411
  /**
6201
6412
  * The useResultSortedRowIdsListener hook registers a listener function with a
6202
6413
  * Queries object that will be called whenever the sorted (and optionally,
6203
- * paginated) Row Ids in a result Table change.
6414
+ * paginated) Row Ids in a ResultTable change.
6204
6415
  *
6205
6416
  * This hook is useful for situations where a component needs to register its
6206
6417
  * own specific listener to do more than simply tracking the value (which is
@@ -6218,7 +6429,7 @@ export function useResultRowIdsListener(
6218
6429
  * @param offset The number of Row Ids to skip for pagination purposes, if any.
6219
6430
  * @param limit The maximum number of Row Ids to return, or `undefined` for all.
6220
6431
  * @param listener The function that will be called whenever the Row Ids in the
6221
- * matching result Table change.
6432
+ * matching ResultTable change.
6222
6433
  * @param listenerDeps An optional array of dependencies for the `listener`
6223
6434
  * function, which, if any change, result in the re-registration of the
6224
6435
  * listener. This parameter defaults to an empty array.
@@ -6391,7 +6602,7 @@ export function useResultRowListener(
6391
6602
  * @param queryId The Id of the query to listen to, or `null` as a wildcard.
6392
6603
  * @param rowId The Id of the result Row to listen to, or `null` as a wildcard.
6393
6604
  * @param listener The function that will be called whenever the Row Ids in the
6394
- * matching result Table change.
6605
+ * matching ResultTable change.
6395
6606
  * @param listenerDeps An optional array of dependencies for the `listener`
6396
6607
  * function, which, if any change, result in the re-registration of the
6397
6608
  * listener. This parameter defaults to an empty array.
@@ -8022,14 +8233,14 @@ export type LinkedRowsProps = {
8022
8233
 
8023
8234
  /**
8024
8235
  * ResultTableProps props are used for components that refer to a single query
8025
- * result Table, such as the ResultTableView component.
8236
+ * ResultTable, such as the ResultTableView component.
8026
8237
  * @category Props
8027
8238
  * @since v2.0.0
8028
8239
  */
8029
8240
  export type ResultTableProps = {
8030
8241
  /**
8031
- * The Id of the query in the Queries object for which the result Table will
8032
- * be rendered.
8242
+ * The Id of the query in the Queries object for which the ResultTable will be
8243
+ * rendered.
8033
8244
  */
8034
8245
  readonly queryId: Id;
8035
8246
  /**
@@ -8061,13 +8272,13 @@ export type ResultTableProps = {
8061
8272
 
8062
8273
  /**
8063
8274
  * ResultSortedTableProps props are used for components that refer to a single
8064
- * sorted query result Table, such as the ResultSortedTableView component.
8275
+ * sorted query ResultTable, such as the ResultSortedTableView component.
8065
8276
  * @category Props
8066
8277
  * @since v2.0.0
8067
8278
  */
8068
8279
  export type ResultSortedTableProps = {
8069
8280
  /**
8070
- * The Id of the query in the Queries object for which the sorted result Table
8281
+ * The Id of the query in the Queries object for which the sorted ResultTable
8071
8282
  * will be rendered.
8072
8283
  */
8073
8284
  readonly queryId: Id;
@@ -8117,18 +8328,18 @@ export type ResultSortedTableProps = {
8117
8328
 
8118
8329
  /**
8119
8330
  * ResultRowProps props are used for components that refer to a single Row in a
8120
- * query result Table, such as the ResultRowView component.
8331
+ * query ResultTable, such as the ResultRowView component.
8121
8332
  * @category Props
8122
8333
  * @since v2.0.0
8123
8334
  */
8124
8335
  export type ResultRowProps = {
8125
8336
  /**
8126
- * The Id of the query in the Queries object for which the result Table will
8127
- * be rendered.
8337
+ * The Id of the query in the Queries object for which the ResultTable will be
8338
+ * rendered.
8128
8339
  */
8129
8340
  readonly queryId: Id;
8130
8341
  /**
8131
- * The Id of the Row in the result Table to be rendered.
8342
+ * The Id of the Row in the ResultTable to be rendered.
8132
8343
  */
8133
8344
  readonly rowId: Id;
8134
8345
  /**
@@ -8160,14 +8371,14 @@ export type ResultRowProps = {
8160
8371
 
8161
8372
  /**
8162
8373
  * ResultRowProps props are used for components that refer to a single Cell in a
8163
- * Row of a result Table, such as the ResultCellView component.
8374
+ * Row of a ResultTable, such as the ResultCellView component.
8164
8375
  * @category Props
8165
8376
  * @since v2.0.0
8166
8377
  */
8167
8378
  export type ResultCellProps = {
8168
8379
  /**
8169
- * The Id of the query in the Queries object for which the result Table will
8170
- * be rendered.
8380
+ * The Id of the query in the Queries object for which the ResultTable will be
8381
+ * rendered.
8171
8382
  */
8172
8383
  readonly queryId: Id;
8173
8384
  /**
@@ -10016,7 +10227,7 @@ export function LinkedRowsView(props: LinkedRowsProps): ComponentReturnType;
10016
10227
 
10017
10228
  /**
10018
10229
  * The ResultCellView component renders the value of a single Cell in a given
10019
- * Row, in a given query's result Table, and registers a listener so that any
10230
+ * Row, in a given query's ResultTable, and registers a listener so that any
10020
10231
  * changes to that result will cause a re-render.
10021
10232
  *
10022
10233
  * The component's props identify which Cell to render based on query Id, Row
@@ -10138,7 +10349,7 @@ export function ResultCellView(props: ResultCellProps): ComponentReturnType;
10138
10349
 
10139
10350
  /**
10140
10351
  * The ResultRowView component renders the contents of a single Row in a given
10141
- * query's result Table, and registers a listener so that any changes to that
10352
+ * query's ResultTable, and registers a listener so that any changes to that
10142
10353
  * result will cause a re-render.
10143
10354
  *
10144
10355
  * The component's props identify which Row to render based on query Id, Row Id,
@@ -10284,18 +10495,18 @@ export function ResultRowView(props: ResultRowProps): ComponentReturnType;
10284
10495
 
10285
10496
  /**
10286
10497
  * The ResultSortedTableView component renders the contents of a single query's
10287
- * sorted result Table in a Queries object, and registers a listener so that any
10498
+ * sorted ResultTable in a Queries object, and registers a listener so that any
10288
10499
  * changes to that result will cause a re-render.
10289
10500
  *
10290
- * The component's props identify which Table to render based on query Id, and
10291
- * Queries object (which is either the default context Queries object, a named
10292
- * context Queries object, or by explicit reference). It also takes a Cell Id to
10293
- * sort by and a boolean to indicate that the sorting should be in descending
10294
- * order. The `offset` and `limit` props are used to paginate results, but
10295
- * default to `0` and `undefined` to return all available Row Ids if not
10296
- * specified.
10501
+ * The component's props identify which ResultTable to render based on query Id,
10502
+ * and Queries object (which is either the default context Queries object, a
10503
+ * named context Queries object, or by explicit reference). It also takes a Cell
10504
+ * Id to sort by and a boolean to indicate that the sorting should be in
10505
+ * descending order. The `offset` and `limit` props are used to paginate
10506
+ * results, but default to `0` and `undefined` to return all available Row Ids
10507
+ * if not specified.
10297
10508
  *
10298
- * This component renders a result Table by iterating over its Row objects, in
10509
+ * This component renders a ResultTable by iterating over its Row objects, in
10299
10510
  * the order dictated by the sort parameters. By default these are in turn
10300
10511
  * rendered with the ResultRowView component, but you can override this behavior
10301
10512
  * by providing a `resultRowComponent` prop, a custom component of your own that
@@ -10303,10 +10514,10 @@ export function ResultRowView(props: ResultRowProps): ComponentReturnType;
10303
10514
  * to your custom component with the `getResultRowComponentProps` callback prop.
10304
10515
  *
10305
10516
  * This component uses the useResultSortedRowIds hook under the covers, which
10306
- * means that any changes to the structure or sorting of the result Table will
10517
+ * means that any changes to the structure or sorting of the ResultTable will
10307
10518
  * cause a re-render.
10308
10519
  * @param props The props for this component.
10309
- * @returns A rendering of the result Table, or nothing, if not present.
10520
+ * @returns A rendering of the ResultTable, or nothing, if not present.
10310
10521
  * @example
10311
10522
  * This example creates a Queries object outside the application, which is used
10312
10523
  * in the ResultSortedTableView component by reference. A change to the data in
@@ -10422,15 +10633,15 @@ export function ResultSortedTableView(
10422
10633
  ): ComponentReturnType;
10423
10634
 
10424
10635
  /**
10425
- * The ResultTableView component renders the contents of a single query's result
10426
- * Table in a Queries object, and registers a listener so that any changes to
10427
- * that result will cause a re-render.
10636
+ * The ResultTableView component renders the contents of a single query's
10637
+ * ResultTable in a Queries object, and registers a listener so that any changes
10638
+ * to that result will cause a re-render.
10428
10639
  *
10429
- * The component's props identify which Table to render based on query Id, and
10430
- * Queries object (which is either the default context Queries object, a named
10431
- * context Queries object, or by explicit reference).
10640
+ * The component's props identify which ResultTable to render based on query Id,
10641
+ * and Queries object (which is either the default context Queries object, a
10642
+ * named context Queries object, or by explicit reference).
10432
10643
  *
10433
- * This component renders a result Table by iterating over its Row objects. By
10644
+ * This component renders a ResultTable by iterating over its Row objects. By
10434
10645
  * default these are in turn rendered with the ResultRowView component, but you
10435
10646
  * can override this behavior by providing a `resultRowComponent` prop, a custom
10436
10647
  * component of your own that will render a Row based on ResultRowProps. You can
@@ -10438,9 +10649,9 @@ export function ResultSortedTableView(
10438
10649
  * `getResultRowComponentProps` callback prop.
10439
10650
  *
10440
10651
  * This component uses the useResultRowIds hook under the covers, which means
10441
- * that any changes to the structure of the result Table will cause a re-render.
10652
+ * that any changes to the structure of the ResultTable will cause a re-render.
10442
10653
  * @param props The props for this component.
10443
- * @returns A rendering of the result Table, or nothing, if not present.
10654
+ * @returns A rendering of the ResultTable, or nothing, if not present.
10444
10655
  * @example
10445
10656
  * This example creates a Queries object outside the application, which is used
10446
10657
  * in the ResultTableView component by reference. A change to the data in the
@@ -224,32 +224,42 @@ export type CellProps<
224
224
  >,
225
225
  > = TableIds extends infer TableId
226
226
  ? TableId extends TableIdFromSchema<Schemas[0]>
227
- ? {
228
- /**
227
+ ? CellPropsForTableIdAndCellId<
228
+ Schemas,
229
+ TableId,
230
+ CellIdFromSchema<Schemas[0], TableId>
231
+ >
232
+ : never
233
+ : never;
234
+
235
+ export type CellPropsForTableIdAndCellId<
236
+ Schemas extends OptionalSchemas,
237
+ TableId extends TableIdFromSchema<Schemas[0]>,
238
+ CellId extends CellIdFromSchema<Schemas[0], TableId>,
239
+ > = {
240
+ /**
229
241
  * The Id of the Table in the Store.
230
242
  */
231
- readonly tableId: TableId;
232
- /**
243
+ readonly tableId: TableId;
244
+ /**
233
245
  * The Id of the Row in the Table.
234
246
  */
235
- readonly rowId: Id;
236
- /**
247
+ readonly rowId: Id;
248
+ /**
237
249
  * The Id of the Cell in the Row to be rendered.
238
250
  */
239
- readonly cellId: CellIdFromSchema<Schemas[0], TableId>;
240
- /**
251
+ readonly cellId: CellId;
252
+ /**
241
253
  * The Store to be accessed: omit for the default context Store, provide an Id
242
254
  * for a named context Store, or provide an explicit reference.
243
255
  */
244
- readonly store?: StoreOrStoreId<Schemas>;
245
- /**
256
+ readonly store?: StoreOrStoreId<Schemas>;
257
+ /**
246
258
  * Whether the component should also render the Id of the Cell to assist with
247
259
  * debugging.
248
260
  */
249
- readonly debugIds?: boolean;
250
- }
251
- : never
252
- : never;
261
+ readonly debugIds?: boolean;
262
+ };
253
263
 
254
264
  export type ValuesProps<Schemas extends OptionalSchemas> = {
255
265
  /**
@@ -485,8 +495,8 @@ export type LinkedRowsProps<Schemas extends OptionalSchemas> = {
485
495
 
486
496
  export type ResultTableProps<Schemas extends OptionalSchemas> = {
487
497
  /**
488
- * The Id of the query in the Queries object for which the result Table will
489
- * be rendered.
498
+ * The Id of the query in the Queries object for which the ResultTable will be
499
+ * rendered.
490
500
  */
491
501
  readonly queryId: Id;
492
502
  /**
@@ -518,7 +528,7 @@ export type ResultTableProps<Schemas extends OptionalSchemas> = {
518
528
 
519
529
  export type ResultSortedTableProps<Schemas extends OptionalSchemas> = {
520
530
  /**
521
- * The Id of the query in the Queries object for which the sorted result Table
531
+ * The Id of the query in the Queries object for which the sorted ResultTable
522
532
  * will be rendered.
523
533
  */
524
534
  readonly queryId: Id;
@@ -568,12 +578,12 @@ export type ResultSortedTableProps<Schemas extends OptionalSchemas> = {
568
578
 
569
579
  export type ResultRowProps<Schemas extends OptionalSchemas> = {
570
580
  /**
571
- * The Id of the query in the Queries object for which the result Table will
572
- * be rendered.
581
+ * The Id of the query in the Queries object for which the ResultTable will be
582
+ * rendered.
573
583
  */
574
584
  readonly queryId: Id;
575
585
  /**
576
- * The Id of the Row in the result Table to be rendered.
586
+ * The Id of the Row in the ResultTable to be rendered.
577
587
  */
578
588
  readonly rowId: Id;
579
589
  /**
@@ -605,8 +615,8 @@ export type ResultRowProps<Schemas extends OptionalSchemas> = {
605
615
 
606
616
  export type ResultCellProps<Schemas extends OptionalSchemas> = {
607
617
  /**
608
- * The Id of the query in the Queries object for which the result Table will
609
- * be rendered.
618
+ * The Id of the query in the Queries object for which the ResultTable will be
619
+ * rendered.
610
620
  */
611
621
  readonly queryId: Id;
612
622
  /**