tinybase 2.2.6 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +1 -1
- package/lib/checkpoints.d.ts +18 -3
- package/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/debug/checkpoints.d.ts +18 -3
- package/lib/debug/checkpoints.js +97 -49
- package/lib/debug/indexes.js +31 -16
- package/lib/debug/metrics.js +31 -16
- package/lib/debug/persisters.d.ts +33 -23
- package/lib/debug/persisters.js +10 -5
- package/lib/debug/queries.js +2 -2
- package/lib/debug/relationships.js +31 -16
- package/lib/debug/store.d.ts +2022 -383
- package/lib/debug/store.js +440 -108
- package/lib/debug/tinybase.js +508 -140
- package/lib/debug/tools.d.ts +89 -38
- package/lib/debug/tools.js +757 -453
- package/lib/debug/ui-react.d.ts +1525 -381
- package/lib/debug/ui-react.js +163 -12
- package/lib/es6/checkpoints.d.ts +18 -3
- 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.d.ts +33 -23
- package/lib/es6/persisters.js +1 -1
- package/lib/es6/persisters.js.gz +0 -0
- package/lib/es6/relationships.js +1 -1
- package/lib/es6/relationships.js.gz +0 -0
- package/lib/es6/store.d.ts +2022 -383
- 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.d.ts +89 -38
- package/lib/es6/tools.js +1 -1
- package/lib/es6/tools.js.gz +0 -0
- package/lib/es6/ui-react.d.ts +1525 -381
- 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.d.ts +33 -23
- package/lib/persisters.js +1 -1
- package/lib/persisters.js.gz +0 -0
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.d.ts +2022 -383
- 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.d.ts +89 -38
- package/lib/tools.js +1 -1
- package/lib/tools.js.gz +0 -0
- package/lib/ui-react.d.ts +1525 -381
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/checkpoints.d.ts +18 -3
- 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.d.ts +33 -23
- package/lib/umd/persisters.js +1 -1
- package/lib/umd/persisters.js.gz +0 -0
- package/lib/umd/relationships.js +1 -1
- package/lib/umd/relationships.js.gz +0 -0
- package/lib/umd/store.d.ts +2022 -383
- 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.d.ts +89 -38
- package/lib/umd/tools.js +1 -1
- package/lib/umd/tools.js.gz +0 -0
- package/lib/umd/ui-react.d.ts +1525 -381
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.js.gz +0 -0
- package/lib/umd-es6/checkpoints.d.ts +18 -3
- 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.d.ts +33 -23
- package/lib/umd-es6/persisters.js +1 -1
- package/lib/umd-es6/persisters.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.d.ts +2022 -383
- 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.d.ts +89 -38
- package/lib/umd-es6/tools.js +1 -1
- package/lib/umd-es6/tools.js.gz +0 -0
- package/lib/umd-es6/ui-react.d.ts +1525 -381
- package/lib/umd-es6/ui-react.js +1 -1
- package/lib/umd-es6/ui-react.js.gz +0 -0
- package/package.json +26 -26
- package/readme.md +20 -19
package/lib/umd/ui-react.d.ts
CHANGED
|
@@ -39,6 +39,11 @@ import {
|
|
|
39
39
|
TableListener,
|
|
40
40
|
Tables,
|
|
41
41
|
TablesListener,
|
|
42
|
+
Value,
|
|
43
|
+
ValueIdsListener,
|
|
44
|
+
ValueListener,
|
|
45
|
+
Values,
|
|
46
|
+
ValuesListener,
|
|
42
47
|
} from './store.d';
|
|
43
48
|
import {
|
|
44
49
|
CheckpointIds,
|
|
@@ -231,10 +236,11 @@ export type UndoOrRedoInformation = [boolean, Callback, Id | undefined, string];
|
|
|
231
236
|
* };
|
|
232
237
|
*
|
|
233
238
|
* const app = document.createElement('div');
|
|
234
|
-
*
|
|
239
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
240
|
+
* root.render(<App />); // !act
|
|
235
241
|
* // -> 'Store created'
|
|
236
242
|
*
|
|
237
|
-
*
|
|
243
|
+
* root.render(<App />); // !act
|
|
238
244
|
* // No second Store creation
|
|
239
245
|
*
|
|
240
246
|
* console.log(app.innerHTML);
|
|
@@ -256,13 +262,14 @@ export type UndoOrRedoInformation = [boolean, Callback, Id | undefined, string];
|
|
|
256
262
|
* };
|
|
257
263
|
*
|
|
258
264
|
* const app = document.createElement('div');
|
|
259
|
-
*
|
|
265
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
266
|
+
* root.render(<App fidoSpecies="dog" />); // !act
|
|
260
267
|
* // -> 'Store created for fido as dog'
|
|
261
268
|
*
|
|
262
269
|
* console.log(app.innerHTML);
|
|
263
270
|
* // -> '<span>dog</span>'
|
|
264
271
|
*
|
|
265
|
-
*
|
|
272
|
+
* root.render(<App fidoSpecies="cat" />); // !act
|
|
266
273
|
* // -> 'Store created for fido as cat'
|
|
267
274
|
*
|
|
268
275
|
* console.log(app.innerHTML);
|
|
@@ -285,8 +292,8 @@ export function useCreateStore(
|
|
|
285
292
|
* component.
|
|
286
293
|
*
|
|
287
294
|
* The useStore hook lets you either get a reference to the default Store (when
|
|
288
|
-
* called without a parameter), or one of the Store objects that are named by
|
|
289
|
-
*
|
|
295
|
+
* called without a parameter), or one of the Store objects that are named by Id
|
|
296
|
+
* (when called with an Id parameter).
|
|
290
297
|
*
|
|
291
298
|
* @param id An optional Id for accessing a Store that was named with an Id in
|
|
292
299
|
* the Provider.
|
|
@@ -307,7 +314,7 @@ export function useCreateStore(
|
|
|
307
314
|
*
|
|
308
315
|
* const store = createStore();
|
|
309
316
|
* const app = document.createElement('div');
|
|
310
|
-
*
|
|
317
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
311
318
|
* console.log(app.innerHTML);
|
|
312
319
|
* // -> '<span>0</span>'
|
|
313
320
|
* ```
|
|
@@ -328,7 +335,7 @@ export function useCreateStore(
|
|
|
328
335
|
*
|
|
329
336
|
* const store = createStore();
|
|
330
337
|
* const app = document.createElement('div');
|
|
331
|
-
*
|
|
338
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
332
339
|
* console.log(app.innerHTML);
|
|
333
340
|
* // -> '<span>0</span>'
|
|
334
341
|
* ```
|
|
@@ -337,7 +344,7 @@ export function useCreateStore(
|
|
|
337
344
|
export function useStore(id?: Id): Store | undefined;
|
|
338
345
|
|
|
339
346
|
/**
|
|
340
|
-
* The useTables hook returns a Tables object containing the
|
|
347
|
+
* The useTables hook returns a Tables object containing the tabular data of a
|
|
341
348
|
* Store, and registers a listener so that any changes to that result will cause
|
|
342
349
|
* a re-render.
|
|
343
350
|
*
|
|
@@ -354,7 +361,7 @@ export function useStore(id?: Id): Store | undefined;
|
|
|
354
361
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
355
362
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
356
363
|
* reference.
|
|
357
|
-
* @returns A Tables object containing the
|
|
364
|
+
* @returns A Tables object containing the tabular data of the Store.
|
|
358
365
|
* @example
|
|
359
366
|
* This example creates a Store outside the application, which is used in the
|
|
360
367
|
* useTables hook by reference. A change to the data in the Store re-renders the
|
|
@@ -365,7 +372,8 @@ export function useStore(id?: Id): Store | undefined;
|
|
|
365
372
|
* const App = () => <span>{JSON.stringify(useTables(store))}</span>;
|
|
366
373
|
*
|
|
367
374
|
* const app = document.createElement('div');
|
|
368
|
-
*
|
|
375
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
376
|
+
* root.render(<App />); // !act
|
|
369
377
|
* console.log(app.innerHTML);
|
|
370
378
|
* // -> '<span>{"pets":{"fido":{"color":"brown"}}}</span>'
|
|
371
379
|
*
|
|
@@ -387,7 +395,7 @@ export function useStore(id?: Id): Store | undefined;
|
|
|
387
395
|
*
|
|
388
396
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
389
397
|
* const app = document.createElement('div');
|
|
390
|
-
*
|
|
398
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
391
399
|
* console.log(app.innerHTML);
|
|
392
400
|
* // -> '<span>{"pets":{"fido":{"color":"brown"}}}</span>'
|
|
393
401
|
* ```
|
|
@@ -405,7 +413,7 @@ export function useStore(id?: Id): Store | undefined;
|
|
|
405
413
|
*
|
|
406
414
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
407
415
|
* const app = document.createElement('div');
|
|
408
|
-
*
|
|
416
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
409
417
|
* console.log(app.innerHTML);
|
|
410
418
|
* // -> '<span>{"pets":{"fido":{"color":"brown"}}}</span>'
|
|
411
419
|
* ```
|
|
@@ -415,7 +423,8 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
|
|
|
415
423
|
|
|
416
424
|
/**
|
|
417
425
|
* The useTableIds hook returns the Ids of every Table in a Store, and registers
|
|
418
|
-
* a listener so that any changes to that result will cause a re-render.
|
|
426
|
+
* a listener so that any changes to that result will cause a re-render.
|
|
427
|
+
*
|
|
419
428
|
* A Provider component is used to wrap part of an application in a context, and
|
|
420
429
|
* it can contain a default Store or a set of Store objects named by Id. The
|
|
421
430
|
* useTableIds hook lets you indicate which Store to get data for: omit the
|
|
@@ -440,7 +449,7 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
|
|
|
440
449
|
* const App = () => <span>{JSON.stringify(useTableIds(store))}</span>;
|
|
441
450
|
*
|
|
442
451
|
* const app = document.createElement('div');
|
|
443
|
-
*
|
|
452
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
444
453
|
* console.log(app.innerHTML);
|
|
445
454
|
* // -> '<span>["pets"]</span>'
|
|
446
455
|
*
|
|
@@ -462,7 +471,7 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
|
|
|
462
471
|
*
|
|
463
472
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
464
473
|
* const app = document.createElement('div');
|
|
465
|
-
*
|
|
474
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
466
475
|
* console.log(app.innerHTML);
|
|
467
476
|
* // -> '<span>["pets"]</span>'
|
|
468
477
|
* ```
|
|
@@ -480,7 +489,7 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
|
|
|
480
489
|
*
|
|
481
490
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
482
491
|
* const app = document.createElement('div');
|
|
483
|
-
*
|
|
492
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
484
493
|
* console.log(app.innerHTML);
|
|
485
494
|
* // -> '<span>["pets"]</span>'
|
|
486
495
|
* ```
|
|
@@ -489,9 +498,9 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
|
|
|
489
498
|
export function useTableIds(storeOrStoreId?: StoreOrStoreId): Ids;
|
|
490
499
|
|
|
491
500
|
/**
|
|
492
|
-
* The useTable hook returns an object containing the
|
|
493
|
-
*
|
|
494
|
-
*
|
|
501
|
+
* The useTable hook returns an object containing the data of a single Table in
|
|
502
|
+
* a Store, and registers a listener so that any changes to that result will
|
|
503
|
+
* cause a re-render.
|
|
495
504
|
*
|
|
496
505
|
* A Provider component is used to wrap part of an application in a context, and
|
|
497
506
|
* it can contain a default Store or a set of Store objects named by Id. The
|
|
@@ -518,7 +527,7 @@ export function useTableIds(storeOrStoreId?: StoreOrStoreId): Ids;
|
|
|
518
527
|
* const App = () => <span>{JSON.stringify(useTable('pets', store))}</span>;
|
|
519
528
|
*
|
|
520
529
|
* const app = document.createElement('div');
|
|
521
|
-
*
|
|
530
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
522
531
|
* console.log(app.innerHTML);
|
|
523
532
|
* // -> '<span>{"fido":{"color":"brown"}}</span>'
|
|
524
533
|
*
|
|
@@ -540,7 +549,7 @@ export function useTableIds(storeOrStoreId?: StoreOrStoreId): Ids;
|
|
|
540
549
|
*
|
|
541
550
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
542
551
|
* const app = document.createElement('div');
|
|
543
|
-
*
|
|
552
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
544
553
|
* console.log(app.innerHTML);
|
|
545
554
|
* // -> '<span>{"fido":{"color":"brown"}}</span>'
|
|
546
555
|
* ```
|
|
@@ -560,7 +569,7 @@ export function useTableIds(storeOrStoreId?: StoreOrStoreId): Ids;
|
|
|
560
569
|
*
|
|
561
570
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
562
571
|
* const app = document.createElement('div');
|
|
563
|
-
*
|
|
572
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
564
573
|
* console.log(app.innerHTML);
|
|
565
574
|
* // -> '<span>{"fido":{"color":"brown"}}</span>'
|
|
566
575
|
* ```
|
|
@@ -598,7 +607,7 @@ export function useTable(tableId: Id, storeOrStoreId?: StoreOrStoreId): Table;
|
|
|
598
607
|
* const App = () => <span>{JSON.stringify(useRowIds('pets', store))}</span>;
|
|
599
608
|
*
|
|
600
609
|
* const app = document.createElement('div');
|
|
601
|
-
*
|
|
610
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
602
611
|
* console.log(app.innerHTML);
|
|
603
612
|
* // -> '<span>["fido"]</span>'
|
|
604
613
|
*
|
|
@@ -620,7 +629,7 @@ export function useTable(tableId: Id, storeOrStoreId?: StoreOrStoreId): Table;
|
|
|
620
629
|
*
|
|
621
630
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
622
631
|
* const app = document.createElement('div');
|
|
623
|
-
*
|
|
632
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
624
633
|
* console.log(app.innerHTML);
|
|
625
634
|
* // -> '<span>["fido"]</span>'
|
|
626
635
|
* ```
|
|
@@ -640,7 +649,7 @@ export function useTable(tableId: Id, storeOrStoreId?: StoreOrStoreId): Table;
|
|
|
640
649
|
*
|
|
641
650
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
642
651
|
* const app = document.createElement('div');
|
|
643
|
-
*
|
|
652
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
644
653
|
* console.log(app.innerHTML);
|
|
645
654
|
* // -> '<span>["fido"]</span>'
|
|
646
655
|
* ```
|
|
@@ -694,7 +703,7 @@ export function useRowIds(tableId: Id, storeOrStoreId?: StoreOrStoreId): Ids;
|
|
|
694
703
|
* );
|
|
695
704
|
*
|
|
696
705
|
* const app = document.createElement('div');
|
|
697
|
-
*
|
|
706
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
698
707
|
* console.log(app.innerHTML);
|
|
699
708
|
* // -> '<span>["felix","fido"]</span>'
|
|
700
709
|
*
|
|
@@ -721,7 +730,7 @@ export function useRowIds(tableId: Id, storeOrStoreId?: StoreOrStoreId): Ids;
|
|
|
721
730
|
* },
|
|
722
731
|
* });
|
|
723
732
|
* const app = document.createElement('div');
|
|
724
|
-
*
|
|
733
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
725
734
|
* console.log(app.innerHTML);
|
|
726
735
|
* // -> '<span>["felix","fido"]</span>'
|
|
727
736
|
* ```
|
|
@@ -750,7 +759,7 @@ export function useRowIds(tableId: Id, storeOrStoreId?: StoreOrStoreId): Ids;
|
|
|
750
759
|
* },
|
|
751
760
|
* });
|
|
752
761
|
* const app = document.createElement('div');
|
|
753
|
-
*
|
|
762
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
754
763
|
* console.log(app.innerHTML);
|
|
755
764
|
* // -> '<span>["felix","fido"]</span>'
|
|
756
765
|
* ```
|
|
@@ -767,9 +776,9 @@ export function useSortedRowIds(
|
|
|
767
776
|
): Ids;
|
|
768
777
|
|
|
769
778
|
/**
|
|
770
|
-
* The useRow hook returns an object containing the
|
|
771
|
-
*
|
|
772
|
-
*
|
|
779
|
+
* The useRow hook returns an object containing the data of a single Row in a
|
|
780
|
+
* given Table, and registers a listener so that any changes to that result will
|
|
781
|
+
* cause a re-render.
|
|
773
782
|
*
|
|
774
783
|
* A Provider component is used to wrap part of an application in a context, and
|
|
775
784
|
* it can contain a default Store or a set of Store objects named by Id. The
|
|
@@ -799,7 +808,7 @@ export function useSortedRowIds(
|
|
|
799
808
|
* );
|
|
800
809
|
*
|
|
801
810
|
* const app = document.createElement('div');
|
|
802
|
-
*
|
|
811
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
803
812
|
* console.log(app.innerHTML);
|
|
804
813
|
* // -> '<span>{"color":"brown"}</span>'
|
|
805
814
|
*
|
|
@@ -821,7 +830,7 @@ export function useSortedRowIds(
|
|
|
821
830
|
*
|
|
822
831
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
823
832
|
* const app = document.createElement('div');
|
|
824
|
-
*
|
|
833
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
825
834
|
* console.log(app.innerHTML);
|
|
826
835
|
* // -> '<span>{"color":"brown"}</span>'
|
|
827
836
|
* ```
|
|
@@ -841,7 +850,7 @@ export function useSortedRowIds(
|
|
|
841
850
|
*
|
|
842
851
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
843
852
|
* const app = document.createElement('div');
|
|
844
|
-
*
|
|
853
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
845
854
|
* console.log(app.innerHTML);
|
|
846
855
|
* // -> '<span>{"color":"brown"}</span>'
|
|
847
856
|
* ```
|
|
@@ -886,7 +895,7 @@ export function useRow(
|
|
|
886
895
|
* );
|
|
887
896
|
*
|
|
888
897
|
* const app = document.createElement('div');
|
|
889
|
-
*
|
|
898
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
890
899
|
* console.log(app.innerHTML);
|
|
891
900
|
* // -> '<span>["color"]</span>'
|
|
892
901
|
*
|
|
@@ -910,7 +919,7 @@ export function useRow(
|
|
|
910
919
|
*
|
|
911
920
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
912
921
|
* const app = document.createElement('div');
|
|
913
|
-
*
|
|
922
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
914
923
|
* console.log(app.innerHTML);
|
|
915
924
|
* // -> '<span>["color"]</span>'
|
|
916
925
|
* ```
|
|
@@ -930,7 +939,7 @@ export function useRow(
|
|
|
930
939
|
*
|
|
931
940
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
932
941
|
* const app = document.createElement('div');
|
|
933
|
-
*
|
|
942
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
934
943
|
* console.log(app.innerHTML);
|
|
935
944
|
* // -> '<span>["color"]</span>'
|
|
936
945
|
* ```
|
|
@@ -974,7 +983,7 @@ export function useCellIds(
|
|
|
974
983
|
* const App = () => <span>{useCell('pets', 'fido', 'color', store)}</span>;
|
|
975
984
|
*
|
|
976
985
|
* const app = document.createElement('div');
|
|
977
|
-
*
|
|
986
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
978
987
|
* console.log(app.innerHTML);
|
|
979
988
|
* // -> '<span>brown</span>'
|
|
980
989
|
*
|
|
@@ -996,7 +1005,7 @@ export function useCellIds(
|
|
|
996
1005
|
*
|
|
997
1006
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
998
1007
|
* const app = document.createElement('div');
|
|
999
|
-
*
|
|
1008
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
1000
1009
|
* console.log(app.innerHTML);
|
|
1001
1010
|
* // -> '<span>brown</span>'
|
|
1002
1011
|
* ```
|
|
@@ -1016,7 +1025,7 @@ export function useCellIds(
|
|
|
1016
1025
|
*
|
|
1017
1026
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
1018
1027
|
* const app = document.createElement('div');
|
|
1019
|
-
*
|
|
1028
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
1020
1029
|
* console.log(app.innerHTML);
|
|
1021
1030
|
* // -> '<span>brown</span>'
|
|
1022
1031
|
* ```
|
|
@@ -1029,12 +1038,248 @@ export function useCell(
|
|
|
1029
1038
|
storeOrStoreId?: StoreOrStoreId,
|
|
1030
1039
|
): Cell | undefined;
|
|
1031
1040
|
|
|
1041
|
+
/**
|
|
1042
|
+
* The useValues hook returns a Values object containing the keyed value data of
|
|
1043
|
+
* a Store, and registers a listener so that any changes to that result will
|
|
1044
|
+
* cause a re-render.
|
|
1045
|
+
*
|
|
1046
|
+
* A Provider component is used to wrap part of an application in a context, and
|
|
1047
|
+
* it can contain a default Store or a set of Store objects named by Id. The
|
|
1048
|
+
* useValues hook lets you indicate which Store to get data for: omit the
|
|
1049
|
+
* optional parameter for the default context Store, provide an Id for a named
|
|
1050
|
+
* context Store, or provide a Store explicitly by reference.
|
|
1051
|
+
*
|
|
1052
|
+
* When first rendered, this hook will create a listener so that changes to the
|
|
1053
|
+
* Values will cause a re-render. When the component containing this hook is
|
|
1054
|
+
* unmounted, the listener will be automatically removed.
|
|
1055
|
+
*
|
|
1056
|
+
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
1057
|
+
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1058
|
+
* reference.
|
|
1059
|
+
* @returns A Values object containing the keyed value data of the Store.
|
|
1060
|
+
* @example
|
|
1061
|
+
* This example creates a Store outside the application, which is used in the
|
|
1062
|
+
* useValues hook by reference. A change to the data in the Store re-renders the
|
|
1063
|
+
* component.
|
|
1064
|
+
*
|
|
1065
|
+
* ```jsx
|
|
1066
|
+
* const store = createStore().setValue('open', true);
|
|
1067
|
+
* const App = () => <span>{JSON.stringify(useValues(store))}</span>;
|
|
1068
|
+
*
|
|
1069
|
+
* const app = document.createElement('div');
|
|
1070
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1071
|
+
* console.log(app.innerHTML);
|
|
1072
|
+
* // -> '<span>{"open":true}</span>'
|
|
1073
|
+
*
|
|
1074
|
+
* store.setValue('open', false); // !act
|
|
1075
|
+
* console.log(app.innerHTML);
|
|
1076
|
+
* // -> '<span>{"open":false}</span>'
|
|
1077
|
+
* ```
|
|
1078
|
+
* @example
|
|
1079
|
+
* This example creates a Provider context into which a default Store is
|
|
1080
|
+
* provided. A component within it then uses the useValues hook.
|
|
1081
|
+
*
|
|
1082
|
+
* ```jsx
|
|
1083
|
+
* const App = ({store}) => (
|
|
1084
|
+
* <Provider store={store}>
|
|
1085
|
+
* <Pane />
|
|
1086
|
+
* </Provider>
|
|
1087
|
+
* );
|
|
1088
|
+
* const Pane = () => <span>{JSON.stringify(useValues())}</span>;
|
|
1089
|
+
*
|
|
1090
|
+
* const store = createStore().setValue('open', true);
|
|
1091
|
+
* const app = document.createElement('div');
|
|
1092
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
1093
|
+
* console.log(app.innerHTML);
|
|
1094
|
+
* // -> '<span>{"open":true}</span>'
|
|
1095
|
+
* ```
|
|
1096
|
+
* @example
|
|
1097
|
+
* This example creates a Provider context into which a Store is provided, named
|
|
1098
|
+
* by Id. A component within it then uses the useValues hook.
|
|
1099
|
+
*
|
|
1100
|
+
* ```jsx
|
|
1101
|
+
* const App = ({store}) => (
|
|
1102
|
+
* <Provider storesById={{petStore: store}}>
|
|
1103
|
+
* <Pane />
|
|
1104
|
+
* </Provider>
|
|
1105
|
+
* );
|
|
1106
|
+
* const Pane = () => <span>{JSON.stringify(useValues('petStore'))}</span>;
|
|
1107
|
+
*
|
|
1108
|
+
* const store = createStore().setValue('open', true);
|
|
1109
|
+
* const app = document.createElement('div');
|
|
1110
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
1111
|
+
* console.log(app.innerHTML);
|
|
1112
|
+
* // -> '<span>{"open":true}</span>'
|
|
1113
|
+
* ```
|
|
1114
|
+
* @category Store hooks
|
|
1115
|
+
* @since v3.0.0
|
|
1116
|
+
*/
|
|
1117
|
+
export function useValues(storeOrStoreId?: StoreOrStoreId): Values;
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* The useValueIds hook returns the Ids of every Value in a Store, and registers
|
|
1121
|
+
* a listener so that any changes to that result will cause a re-render.
|
|
1122
|
+
*
|
|
1123
|
+
* A Provider component is used to wrap part of an application in a context, and
|
|
1124
|
+
* it can contain a default Store or a set of Store objects named by Id. The
|
|
1125
|
+
* useValueIds hook lets you indicate which Store to get data for: omit the
|
|
1126
|
+
* optional parameter for the default context Store, provide an Id for a named
|
|
1127
|
+
* context Store, or provide a Store explicitly by reference.
|
|
1128
|
+
*
|
|
1129
|
+
* When first rendered, this hook will create a listener so that changes to the
|
|
1130
|
+
* Value Ids will cause a re-render. When the component containing this hook is
|
|
1131
|
+
* unmounted, the listener will be automatically removed.
|
|
1132
|
+
*
|
|
1133
|
+
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
1134
|
+
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1135
|
+
* reference.
|
|
1136
|
+
* @returns An array of the Ids of every Value in the Store.
|
|
1137
|
+
* @example
|
|
1138
|
+
* This example creates a Store outside the application, which is used in the
|
|
1139
|
+
* useValueIds hook by reference. A change to the data in the Store re-renders
|
|
1140
|
+
* the component.
|
|
1141
|
+
*
|
|
1142
|
+
* ```jsx
|
|
1143
|
+
* const store = createStore().setValue('open', true);
|
|
1144
|
+
* const App = () => <span>{JSON.stringify(useValueIds(store))}</span>;
|
|
1145
|
+
*
|
|
1146
|
+
* const app = document.createElement('div');
|
|
1147
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1148
|
+
* console.log(app.innerHTML);
|
|
1149
|
+
* // -> '<span>["open"]</span>'
|
|
1150
|
+
*
|
|
1151
|
+
* store.setValue('employees', 3); // !act
|
|
1152
|
+
* console.log(app.innerHTML);
|
|
1153
|
+
* // -> '<span>["open","employees"]</span>'
|
|
1154
|
+
* ```
|
|
1155
|
+
* @example
|
|
1156
|
+
* This example creates a Provider context into which a default Store is
|
|
1157
|
+
* provided. A component within it then uses the useValueIds hook.
|
|
1158
|
+
*
|
|
1159
|
+
* ```jsx
|
|
1160
|
+
* const App = ({store}) => (
|
|
1161
|
+
* <Provider store={store}>
|
|
1162
|
+
* <Pane />
|
|
1163
|
+
* </Provider>
|
|
1164
|
+
* );
|
|
1165
|
+
* const Pane = () => <span>{JSON.stringify(useValueIds())}</span>;
|
|
1166
|
+
*
|
|
1167
|
+
* const store = createStore().setValue('open', true);
|
|
1168
|
+
* const app = document.createElement('div');
|
|
1169
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
1170
|
+
* console.log(app.innerHTML);
|
|
1171
|
+
* // -> '<span>["open"]</span>'
|
|
1172
|
+
* ```
|
|
1173
|
+
* @example
|
|
1174
|
+
* This example creates a Provider context into which a Store is provided, named
|
|
1175
|
+
* by Id. A component within it then uses the useValueIds hook.
|
|
1176
|
+
*
|
|
1177
|
+
* ```jsx
|
|
1178
|
+
* const App = ({store}) => (
|
|
1179
|
+
* <Provider storesById={{petStore: store}}>
|
|
1180
|
+
* <Pane />
|
|
1181
|
+
* </Provider>
|
|
1182
|
+
* );
|
|
1183
|
+
* const Pane = () => <span>{JSON.stringify(useValueIds('petStore'))}</span>;
|
|
1184
|
+
*
|
|
1185
|
+
* const store = createStore().setValue('open', true);
|
|
1186
|
+
* const app = document.createElement('div');
|
|
1187
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
1188
|
+
* console.log(app.innerHTML);
|
|
1189
|
+
* // -> '<span>["open"]</span>'
|
|
1190
|
+
* ```
|
|
1191
|
+
* @category Store hooks
|
|
1192
|
+
* @since v3.0.0
|
|
1193
|
+
*/
|
|
1194
|
+
export function useValueIds(storeOrStoreId?: StoreOrStoreId): Ids;
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* The useValue hook returns an object containing the data of a single Value in
|
|
1198
|
+
* a Store, and registers a listener so that any changes to that result will
|
|
1199
|
+
* cause a re-render.
|
|
1200
|
+
*
|
|
1201
|
+
* A Provider component is used to wrap part of an application in a context, and
|
|
1202
|
+
* it can contain a default Store or a set of Store objects named by Id. The
|
|
1203
|
+
* useValue hook lets you indicate which Store to get data for: omit the final
|
|
1204
|
+
* optional final parameter for the default context Store, provide an Id for a
|
|
1205
|
+
* named context Store, or provide a Store explicitly by reference.
|
|
1206
|
+
*
|
|
1207
|
+
* When first rendered, this hook will create a listener so that changes to the
|
|
1208
|
+
* Value will cause a re-render. When the component containing this hook is
|
|
1209
|
+
* unmounted, the listener will be automatically removed.
|
|
1210
|
+
*
|
|
1211
|
+
* @param valueId The Id of the Value in the Store.
|
|
1212
|
+
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
1213
|
+
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1214
|
+
* reference.
|
|
1215
|
+
* @returns An object containing the entire data of the Value.
|
|
1216
|
+
* @example
|
|
1217
|
+
* This example creates a Store outside the application, which is used in the
|
|
1218
|
+
* useValue hook by reference. A change to the data in the Store re-renders the
|
|
1219
|
+
* component.
|
|
1220
|
+
*
|
|
1221
|
+
* ```jsx
|
|
1222
|
+
* const store = createStore().setValue('open', true);
|
|
1223
|
+
* const App = () => <span>{JSON.stringify(useValue('open', store))}</span>;
|
|
1224
|
+
*
|
|
1225
|
+
* const app = document.createElement('div');
|
|
1226
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1227
|
+
* console.log(app.innerHTML);
|
|
1228
|
+
* // -> '<span>true</span>'
|
|
1229
|
+
*
|
|
1230
|
+
* store.setValue('open', false); // !act
|
|
1231
|
+
* console.log(app.innerHTML);
|
|
1232
|
+
* // -> '<span>false</span>'
|
|
1233
|
+
* ```
|
|
1234
|
+
* @example
|
|
1235
|
+
* This example creates a Provider context into which a default Store is
|
|
1236
|
+
* provided. A component within it then uses the useValue hook.
|
|
1237
|
+
*
|
|
1238
|
+
* ```jsx
|
|
1239
|
+
* const App = ({store}) => (
|
|
1240
|
+
* <Provider store={store}>
|
|
1241
|
+
* <Pane />
|
|
1242
|
+
* </Provider>
|
|
1243
|
+
* );
|
|
1244
|
+
* const Pane = () => <span>{JSON.stringify(useValue('open'))}</span>;
|
|
1245
|
+
*
|
|
1246
|
+
* const store = createStore().setValue('open', true);
|
|
1247
|
+
* const app = document.createElement('div');
|
|
1248
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
1249
|
+
* console.log(app.innerHTML);
|
|
1250
|
+
* // -> '<span>true</span>'
|
|
1251
|
+
* ```
|
|
1252
|
+
* @example
|
|
1253
|
+
* This example creates a Provider context into which a Store is provided, named
|
|
1254
|
+
* by Id. A component within it then uses the useValue hook.
|
|
1255
|
+
*
|
|
1256
|
+
* ```jsx
|
|
1257
|
+
* const App = ({store}) => (
|
|
1258
|
+
* <Provider storesById={{petStore: store}}>
|
|
1259
|
+
* <Pane />
|
|
1260
|
+
* </Provider>
|
|
1261
|
+
* );
|
|
1262
|
+
* const Pane = () => (
|
|
1263
|
+
* <span>{JSON.stringify(useValue('open', 'petStore'))}</span>
|
|
1264
|
+
* );
|
|
1265
|
+
*
|
|
1266
|
+
* const store = createStore().setValue('open', true);
|
|
1267
|
+
* const app = document.createElement('div');
|
|
1268
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
1269
|
+
* console.log(app.innerHTML);
|
|
1270
|
+
* // -> '<span>true</span>'
|
|
1271
|
+
* ```
|
|
1272
|
+
* @category Store hooks
|
|
1273
|
+
* @since v3.0.0
|
|
1274
|
+
*/
|
|
1275
|
+
export function useValue(valueId: Id, storeOrStoreId?: StoreOrStoreId): Value;
|
|
1276
|
+
|
|
1032
1277
|
/**
|
|
1033
1278
|
* The useSetTablesCallback hook returns a parameterized callback that can be
|
|
1034
|
-
* used to set the
|
|
1279
|
+
* used to set the tabular data of a Store.
|
|
1035
1280
|
*
|
|
1036
1281
|
* This hook is useful, for example, when creating an event handler that will
|
|
1037
|
-
* mutate the data in Store. In this case, the parameter will likely be the
|
|
1282
|
+
* mutate the data in the Store. In this case, the parameter will likely be the
|
|
1038
1283
|
* event, so that you can use data from it as part of the mutation.
|
|
1039
1284
|
*
|
|
1040
1285
|
* The first parameter is a function which will produce the Tables object that
|
|
@@ -1090,7 +1335,7 @@ export function useCell(
|
|
|
1090
1335
|
* };
|
|
1091
1336
|
*
|
|
1092
1337
|
* const app = document.createElement('div');
|
|
1093
|
-
*
|
|
1338
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1094
1339
|
* const span = app.querySelector('span');
|
|
1095
1340
|
* console.log(span.innerHTML);
|
|
1096
1341
|
* // -> '{"pets":{"nemo":{"species":"fish"}}}'
|
|
@@ -1114,10 +1359,10 @@ export function useSetTablesCallback<Parameter>(
|
|
|
1114
1359
|
|
|
1115
1360
|
/**
|
|
1116
1361
|
* The useSetTableCallback hook returns a parameterized callback that can be
|
|
1117
|
-
* used to set the
|
|
1362
|
+
* used to set the data of a single Table in a Store.
|
|
1118
1363
|
*
|
|
1119
1364
|
* This hook is useful, for example, when creating an event handler that will
|
|
1120
|
-
* mutate the data in Store. In this case, the parameter will likely be the
|
|
1365
|
+
* mutate the data in the Store. In this case, the parameter will likely be the
|
|
1121
1366
|
* event, so that you can use data from it as part of the mutation.
|
|
1122
1367
|
*
|
|
1123
1368
|
* The second parameter is a function which will produce the Table object that
|
|
@@ -1175,7 +1420,7 @@ export function useSetTablesCallback<Parameter>(
|
|
|
1175
1420
|
* };
|
|
1176
1421
|
*
|
|
1177
1422
|
* const app = document.createElement('div');
|
|
1178
|
-
*
|
|
1423
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1179
1424
|
* const span = app.querySelector('span');
|
|
1180
1425
|
* console.log(span.innerHTML);
|
|
1181
1426
|
* // -> '{"nemo":{"species":"fish"}}'
|
|
@@ -1200,10 +1445,10 @@ export function useSetTableCallback<Parameter>(
|
|
|
1200
1445
|
|
|
1201
1446
|
/**
|
|
1202
1447
|
* The useSetRowCallback hook returns a parameterized callback that can be used
|
|
1203
|
-
* to set the
|
|
1448
|
+
* to set the data of a single Row in a Store.
|
|
1204
1449
|
*
|
|
1205
1450
|
* This hook is useful, for example, when creating an event handler that will
|
|
1206
|
-
* mutate the data in Store. In this case, the parameter will likely be the
|
|
1451
|
+
* mutate the data in the Store. In this case, the parameter will likely be the
|
|
1207
1452
|
* event, so that you can use data from it as part of the mutation.
|
|
1208
1453
|
*
|
|
1209
1454
|
* The third parameter is a function which will produce the Row object that will
|
|
@@ -1263,7 +1508,7 @@ export function useSetTableCallback<Parameter>(
|
|
|
1263
1508
|
* };
|
|
1264
1509
|
*
|
|
1265
1510
|
* const app = document.createElement('div');
|
|
1266
|
-
*
|
|
1511
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1267
1512
|
* const span = app.querySelector('span');
|
|
1268
1513
|
* console.log(span.innerHTML);
|
|
1269
1514
|
* // -> '{"species":"fish"}'
|
|
@@ -1292,7 +1537,7 @@ export function useSetRowCallback<Parameter>(
|
|
|
1292
1537
|
* to create a new Row in a Store.
|
|
1293
1538
|
*
|
|
1294
1539
|
* This hook is useful, for example, when creating an event handler that will
|
|
1295
|
-
* mutate the data in Store. In this case, the parameter will likely be the
|
|
1540
|
+
* mutate the data in the Store. In this case, the parameter will likely be the
|
|
1296
1541
|
* event, so that you can use data from it as part of the mutation.
|
|
1297
1542
|
*
|
|
1298
1543
|
* The second parameter is a function which will produce the Row object that
|
|
@@ -1350,7 +1595,7 @@ export function useSetRowCallback<Parameter>(
|
|
|
1350
1595
|
* };
|
|
1351
1596
|
*
|
|
1352
1597
|
* const app = document.createElement('div');
|
|
1353
|
-
*
|
|
1598
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1354
1599
|
* const span = app.querySelector('span');
|
|
1355
1600
|
* console.log(span.innerHTML);
|
|
1356
1601
|
* // -> '{"nemo":{"species":"fish"}}'
|
|
@@ -1375,7 +1620,7 @@ export function useAddRowCallback<Parameter>(
|
|
|
1375
1620
|
|
|
1376
1621
|
/**
|
|
1377
1622
|
* The useSetPartialRowCallback hook returns a parameterized callback that can
|
|
1378
|
-
* be used to
|
|
1623
|
+
* be used to set partial data of a single Row in the Store, leaving other Cell
|
|
1379
1624
|
* values unaffected.
|
|
1380
1625
|
*
|
|
1381
1626
|
* This hook is useful, for example, when creating an event handler that will
|
|
@@ -1440,7 +1685,7 @@ export function useAddRowCallback<Parameter>(
|
|
|
1440
1685
|
* };
|
|
1441
1686
|
*
|
|
1442
1687
|
* const app = document.createElement('div');
|
|
1443
|
-
*
|
|
1688
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1444
1689
|
* const span = app.querySelector('span');
|
|
1445
1690
|
* console.log(span.innerHTML);
|
|
1446
1691
|
* // -> '{"species":"fish"}'
|
|
@@ -1469,7 +1714,7 @@ export function useSetPartialRowCallback<Parameter>(
|
|
|
1469
1714
|
* to set the value of a single Cell in a Store.
|
|
1470
1715
|
*
|
|
1471
1716
|
* This hook is useful, for example, when creating an event handler that will
|
|
1472
|
-
* mutate the data in Store. In this case, the parameter will likely be the
|
|
1717
|
+
* mutate the data in the Store. In this case, the parameter will likely be the
|
|
1473
1718
|
* event, so that you can use data from it as part of the mutation.
|
|
1474
1719
|
*
|
|
1475
1720
|
* The fourth parameter is a function which will produce the Cell object that
|
|
@@ -1531,7 +1776,7 @@ export function useSetPartialRowCallback<Parameter>(
|
|
|
1531
1776
|
* };
|
|
1532
1777
|
*
|
|
1533
1778
|
* const app = document.createElement('div');
|
|
1534
|
-
*
|
|
1779
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1535
1780
|
* const span = app.querySelector('span');
|
|
1536
1781
|
* console.log(span.innerHTML);
|
|
1537
1782
|
* // -> '{"species":"fish"}'
|
|
@@ -1568,7 +1813,7 @@ export function useSetPartialRowCallback<Parameter>(
|
|
|
1568
1813
|
* };
|
|
1569
1814
|
*
|
|
1570
1815
|
* const app = document.createElement('div');
|
|
1571
|
-
*
|
|
1816
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1572
1817
|
* const span = app.querySelector('span');
|
|
1573
1818
|
* console.log(span.innerHTML);
|
|
1574
1819
|
* // -> '{"visits":1}'
|
|
@@ -1594,132 +1839,389 @@ export function useSetCellCallback<Parameter>(
|
|
|
1594
1839
|
): ParameterizedCallback<Parameter>;
|
|
1595
1840
|
|
|
1596
1841
|
/**
|
|
1597
|
-
* The
|
|
1598
|
-
*
|
|
1842
|
+
* The useSetValuesCallback hook returns a parameterized callback that can be
|
|
1843
|
+
* used to set the keyed value data of a Store.
|
|
1599
1844
|
*
|
|
1600
1845
|
* This hook is useful, for example, when creating an event handler that will
|
|
1601
|
-
*
|
|
1846
|
+
* mutate the data in the Store. In this case, the parameter will likely be the
|
|
1847
|
+
* event, so that you can use data from it as part of the mutation.
|
|
1848
|
+
*
|
|
1849
|
+
* The first parameter is a function which will produce the Values object that
|
|
1850
|
+
* will then be used to update the Store in the callback.
|
|
1851
|
+
*
|
|
1852
|
+
* If that function has any other dependencies, the changing of which should
|
|
1853
|
+
* also cause the callback to be recreated, you can provide them in an array in
|
|
1854
|
+
* the optional second parameter, just as you would for any React hook with
|
|
1855
|
+
* dependencies.
|
|
1602
1856
|
*
|
|
1603
1857
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
1604
1858
|
* set of dependencies) which will be called just after the Store has been
|
|
1605
1859
|
* updated. This is a useful place to call the addCheckpoint method, for
|
|
1606
|
-
* example, if you wish to add the
|
|
1860
|
+
* example, if you wish to add the mutation to your application's undo stack.
|
|
1607
1861
|
*
|
|
1608
|
-
* The Store to which the callback will make the
|
|
1862
|
+
* The Store to which the callback will make the mutation (indicated by the
|
|
1609
1863
|
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
1610
1864
|
* dependency for the callback.
|
|
1611
1865
|
*
|
|
1866
|
+
* @param getValues A function which returns the Values object that will be used
|
|
1867
|
+
* to update the Store, based on the parameter the callback will receive (and
|
|
1868
|
+
* which is most likely a DOM event).
|
|
1869
|
+
* @param getValuesDeps An optional array of dependencies for the `getValues`
|
|
1870
|
+
* function, which, if any change, result in the regeneration of the callback.
|
|
1871
|
+
* This parameter defaults to an empty array.
|
|
1612
1872
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
1613
1873
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1614
1874
|
* reference.
|
|
1615
|
-
* @param then A function which is called after the
|
|
1616
|
-
* to the Store.
|
|
1875
|
+
* @param then A function which is called after the mutation, with a reference
|
|
1876
|
+
* to the Store and the Values used in the update.
|
|
1617
1877
|
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
1618
1878
|
* which, if any change, result in the regeneration of the callback. This
|
|
1619
1879
|
* parameter defaults to an empty array.
|
|
1620
|
-
* @returns A callback for subsequent use.
|
|
1880
|
+
* @returns A parameterized callback for subsequent use.
|
|
1621
1881
|
* @example
|
|
1622
|
-
* This example uses the
|
|
1623
|
-
* which
|
|
1882
|
+
* This example uses the useSetValuesCallback hook to create an event handler
|
|
1883
|
+
* which updates the Store when the `span` element is clicked.
|
|
1624
1884
|
*
|
|
1625
1885
|
* ```jsx
|
|
1626
|
-
* const store = createStore().
|
|
1886
|
+
* const store = createStore().setValues({open: true});
|
|
1627
1887
|
* const App = () => {
|
|
1628
|
-
* const handleClick =
|
|
1629
|
-
*
|
|
1888
|
+
* const handleClick = useSetValuesCallback(
|
|
1889
|
+
* (e) => ({bubbles: e.bubbles}),
|
|
1890
|
+
* [],
|
|
1891
|
+
* store,
|
|
1892
|
+
* (store, values) => console.log(`Updated: ${JSON.stringify(values)}`),
|
|
1630
1893
|
* );
|
|
1631
1894
|
* return (
|
|
1632
1895
|
* <span id="span" onClick={handleClick}>
|
|
1633
|
-
* {JSON.stringify(
|
|
1896
|
+
* {JSON.stringify(useValues(store))}
|
|
1634
1897
|
* </span>
|
|
1635
1898
|
* );
|
|
1636
1899
|
* };
|
|
1637
1900
|
*
|
|
1638
1901
|
* const app = document.createElement('div');
|
|
1639
|
-
*
|
|
1902
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1640
1903
|
* const span = app.querySelector('span');
|
|
1641
1904
|
* console.log(span.innerHTML);
|
|
1642
|
-
* // -> '{"
|
|
1905
|
+
* // -> '{"open":true}'
|
|
1643
1906
|
*
|
|
1644
1907
|
* // User clicks the <span> element:
|
|
1645
1908
|
* // -> span MouseEvent('click', {bubbles: true})
|
|
1646
|
-
* // -> '
|
|
1909
|
+
* // -> 'Updated: {"bubbles":true}'
|
|
1647
1910
|
*
|
|
1648
1911
|
* console.log(span.innerHTML);
|
|
1649
|
-
* // -> '{}'
|
|
1912
|
+
* // -> '{"bubbles":true}'
|
|
1650
1913
|
* ```
|
|
1651
1914
|
* @category Store hooks
|
|
1915
|
+
* @since v3.0.0
|
|
1652
1916
|
*/
|
|
1653
|
-
export function
|
|
1917
|
+
export function useSetValuesCallback<Parameter>(
|
|
1918
|
+
getValues: (parameter: Parameter, store: Store) => Values,
|
|
1919
|
+
getValuesDeps?: React.DependencyList,
|
|
1654
1920
|
storeOrStoreId?: StoreOrStoreId,
|
|
1655
|
-
then?: (store: Store) => void,
|
|
1921
|
+
then?: (store: Store, values: Values) => void,
|
|
1656
1922
|
thenDeps?: React.DependencyList,
|
|
1657
|
-
):
|
|
1923
|
+
): ParameterizedCallback<Parameter>;
|
|
1658
1924
|
|
|
1659
1925
|
/**
|
|
1660
|
-
* The
|
|
1661
|
-
*
|
|
1926
|
+
* The useSetPartialValuesCallback hook returns a parameterized callback that
|
|
1927
|
+
* can be used to set partial Values data in the Store, leaving other Values
|
|
1928
|
+
* unaffected.
|
|
1662
1929
|
*
|
|
1663
1930
|
* This hook is useful, for example, when creating an event handler that will
|
|
1664
|
-
*
|
|
1931
|
+
* mutate the data in the Store. In this case, the parameter will likely be the
|
|
1932
|
+
* event, so that you can use data from it as part of the mutation.
|
|
1933
|
+
*
|
|
1934
|
+
* The third parameter is a function which will produce the partial Values
|
|
1935
|
+
* object that will then be used to update the Store in the callback.
|
|
1936
|
+
*
|
|
1937
|
+
* If that function has any other dependencies, the changing of which should
|
|
1938
|
+
* also cause the callback to be recreated, you can provide them in an array in
|
|
1939
|
+
* the optional fourth parameter, just as you would for any React hook with
|
|
1940
|
+
* dependencies.
|
|
1665
1941
|
*
|
|
1666
1942
|
* For convenience, you can optionally provide a `then` function (with its own
|
|
1667
1943
|
* set of dependencies) which will be called just after the Store has been
|
|
1668
1944
|
* updated. This is a useful place to call the addCheckpoint method, for
|
|
1669
|
-
* example, if you wish to add the
|
|
1945
|
+
* example, if you wish to add the mutation to your application's undo stack.
|
|
1670
1946
|
*
|
|
1671
|
-
* The Store to which the callback will make the
|
|
1947
|
+
* The Store to which the callback will make the mutation (indicated by the
|
|
1672
1948
|
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
1673
1949
|
* dependency for the callback.
|
|
1674
1950
|
*
|
|
1675
|
-
* @param
|
|
1951
|
+
* @param getPartialValues A function which returns the partial Values object
|
|
1952
|
+
* that will be used to update the Store, based on the parameter the callback
|
|
1953
|
+
* will receive (and which is most likely a DOM event).
|
|
1954
|
+
* @param getPartialValuesDeps An optional array of dependencies for the
|
|
1955
|
+
* `getValues` function, which, if any change, result in the regeneration of the
|
|
1956
|
+
* callback. This parameter defaults to an empty array.
|
|
1676
1957
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
1677
1958
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1678
1959
|
* reference.
|
|
1679
|
-
* @param then A function which is called after the
|
|
1680
|
-
* to the Store.
|
|
1960
|
+
* @param then A function which is called after the mutation, with a reference
|
|
1961
|
+
* to the Store and the Values used in the update.
|
|
1681
1962
|
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
1682
1963
|
* which, if any change, result in the regeneration of the callback. This
|
|
1683
1964
|
* parameter defaults to an empty array.
|
|
1684
|
-
* @returns A callback for subsequent use.
|
|
1965
|
+
* @returns A parameterized callback for subsequent use.
|
|
1685
1966
|
* @example
|
|
1686
|
-
* This example uses the
|
|
1687
|
-
* which
|
|
1967
|
+
* This example uses the useSetPartialValuesCallback hook to create an event
|
|
1968
|
+
* handler which updates the Store when the `span` element is clicked.
|
|
1688
1969
|
*
|
|
1689
1970
|
* ```jsx
|
|
1690
|
-
* const store = createStore().
|
|
1971
|
+
* const store = createStore().setValues({open: true});
|
|
1691
1972
|
* const App = () => {
|
|
1692
|
-
* const handleClick =
|
|
1693
|
-
*
|
|
1973
|
+
* const handleClick = useSetPartialValuesCallback(
|
|
1974
|
+
* (e) => ({bubbles: e.bubbles}),
|
|
1975
|
+
* [],
|
|
1976
|
+
* store,
|
|
1977
|
+
* (store, partialValues) =>
|
|
1978
|
+
* console.log(`Updated: ${JSON.stringify(partialValues)}`),
|
|
1694
1979
|
* );
|
|
1695
1980
|
* return (
|
|
1696
1981
|
* <span id="span" onClick={handleClick}>
|
|
1697
|
-
* {JSON.stringify(
|
|
1982
|
+
* {JSON.stringify(useValues(store))}
|
|
1698
1983
|
* </span>
|
|
1699
1984
|
* );
|
|
1700
1985
|
* };
|
|
1701
1986
|
*
|
|
1702
1987
|
* const app = document.createElement('div');
|
|
1703
|
-
*
|
|
1988
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1704
1989
|
* const span = app.querySelector('span');
|
|
1705
1990
|
* console.log(span.innerHTML);
|
|
1706
|
-
* // -> '{"
|
|
1991
|
+
* // -> '{"open":true}'
|
|
1707
1992
|
*
|
|
1708
1993
|
* // User clicks the <span> element:
|
|
1709
1994
|
* // -> span MouseEvent('click', {bubbles: true})
|
|
1710
|
-
* // -> '
|
|
1995
|
+
* // -> 'Updated: {"bubbles":true}'
|
|
1711
1996
|
*
|
|
1712
1997
|
* console.log(span.innerHTML);
|
|
1713
|
-
* // -> '{}'
|
|
1998
|
+
* // -> '{"open":true,"bubbles":true}'
|
|
1714
1999
|
* ```
|
|
1715
2000
|
* @category Store hooks
|
|
2001
|
+
* @since v3.0.0
|
|
1716
2002
|
*/
|
|
1717
|
-
export function
|
|
1718
|
-
|
|
2003
|
+
export function useSetPartialValuesCallback<Parameter>(
|
|
2004
|
+
getPartialValues: (parameter: Parameter, store: Store) => Values,
|
|
2005
|
+
getPartialValuesDeps?: React.DependencyList,
|
|
1719
2006
|
storeOrStoreId?: StoreOrStoreId,
|
|
1720
|
-
then?: (store: Store) => void,
|
|
2007
|
+
then?: (store: Store, partialValues: Values) => void,
|
|
1721
2008
|
thenDeps?: React.DependencyList,
|
|
1722
|
-
):
|
|
2009
|
+
): ParameterizedCallback<Parameter>;
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* The useSetValueCallback hook returns a parameterized callback that can be
|
|
2013
|
+
* used to set the data of a single Value in a Store.
|
|
2014
|
+
*
|
|
2015
|
+
* This hook is useful, for example, when creating an event handler that will
|
|
2016
|
+
* mutate the data in the Store. In this case, the parameter will likely be the
|
|
2017
|
+
* event, so that you can use data from it as part of the mutation.
|
|
2018
|
+
*
|
|
2019
|
+
* The second parameter is a function which will produce the Value object that
|
|
2020
|
+
* will then be used to update the Store in the callback.
|
|
2021
|
+
*
|
|
2022
|
+
* If that function has any other dependencies, the changing of which should
|
|
2023
|
+
* also cause the callback to be recreated, you can provide them in an array in
|
|
2024
|
+
* the optional third parameter, just as you would for any React hook with
|
|
2025
|
+
* dependencies.
|
|
2026
|
+
*
|
|
2027
|
+
* For convenience, you can optionally provide a `then` function (with its own
|
|
2028
|
+
* set of dependencies) which will be called just after the Store has been
|
|
2029
|
+
* updated. This is a useful place to call the addCheckpoint method, for
|
|
2030
|
+
* example, if you wish to add the mutation to your application's undo stack.
|
|
2031
|
+
*
|
|
2032
|
+
* The Store to which the callback will make the mutation (indicated by the
|
|
2033
|
+
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
2034
|
+
* dependency for the callback.
|
|
2035
|
+
*
|
|
2036
|
+
* @param valueId The Id of the Value in the Store to set.
|
|
2037
|
+
* @param getValue A function which returns the Value object that will be used
|
|
2038
|
+
* to update the Store, based on the parameter the callback will receive (and
|
|
2039
|
+
* which is most likely a DOM event).
|
|
2040
|
+
* @param getValueDeps An optional array of dependencies for the `getValue`
|
|
2041
|
+
* function, which, if any change, result in the regeneration of the callback.
|
|
2042
|
+
* This parameter defaults to an empty array.
|
|
2043
|
+
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
2044
|
+
* Store, provide an Id for a named context Store, or provide an explicit
|
|
2045
|
+
* reference.
|
|
2046
|
+
* @param then A function which is called after the mutation, with a reference
|
|
2047
|
+
* to the Store and the Value used in the update.
|
|
2048
|
+
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
2049
|
+
* which, if any change, result in the regeneration of the callback. This
|
|
2050
|
+
* parameter defaults to an empty array.
|
|
2051
|
+
* @returns A parameterized callback for subsequent use.
|
|
2052
|
+
* @example
|
|
2053
|
+
* This example uses the useSetValueCallback hook to create an event handler
|
|
2054
|
+
* which updates the Store when the `span` element is clicked.
|
|
2055
|
+
*
|
|
2056
|
+
* ```jsx
|
|
2057
|
+
* const store = createStore().setValue('open', true);
|
|
2058
|
+
* const App = () => {
|
|
2059
|
+
* const handleClick = useSetValueCallback(
|
|
2060
|
+
* 'bubbles',
|
|
2061
|
+
* (e) => e.bubbles,
|
|
2062
|
+
* [],
|
|
2063
|
+
* store,
|
|
2064
|
+
* (store, value) => console.log(`Updated: ${JSON.stringify(value)}`),
|
|
2065
|
+
* );
|
|
2066
|
+
* return (
|
|
2067
|
+
* <span id="span" onClick={handleClick}>
|
|
2068
|
+
* {JSON.stringify(useValues(store))}
|
|
2069
|
+
* </span>
|
|
2070
|
+
* );
|
|
2071
|
+
* };
|
|
2072
|
+
*
|
|
2073
|
+
* const app = document.createElement('div');
|
|
2074
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
2075
|
+
* const span = app.querySelector('span');
|
|
2076
|
+
* console.log(span.innerHTML);
|
|
2077
|
+
* // -> '{"open":true}'
|
|
2078
|
+
*
|
|
2079
|
+
* // User clicks the <span> element:
|
|
2080
|
+
* // -> span MouseEvent('click', {bubbles: true})
|
|
2081
|
+
* // -> 'Updated: true'
|
|
2082
|
+
*
|
|
2083
|
+
* console.log(span.innerHTML);
|
|
2084
|
+
* // -> '{"open":true,"bubbles":true}'
|
|
2085
|
+
* ```
|
|
2086
|
+
* @category Store hooks
|
|
2087
|
+
* @since v3.0.0
|
|
2088
|
+
*/
|
|
2089
|
+
export function useSetValueCallback<Parameter>(
|
|
2090
|
+
valueId: Id,
|
|
2091
|
+
getValue: (parameter: Parameter, store: Store) => Value,
|
|
2092
|
+
getValueDeps?: React.DependencyList,
|
|
2093
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
2094
|
+
then?: (store: Store, value: Value) => void,
|
|
2095
|
+
thenDeps?: React.DependencyList,
|
|
2096
|
+
): ParameterizedCallback<Parameter>;
|
|
2097
|
+
|
|
2098
|
+
/**
|
|
2099
|
+
* The useDelTablesCallback hook returns a callback that can be used to remove
|
|
2100
|
+
* all of the tabular data in a Store.
|
|
2101
|
+
*
|
|
2102
|
+
* This hook is useful, for example, when creating an event handler that will
|
|
2103
|
+
* delete data in a Store.
|
|
2104
|
+
*
|
|
2105
|
+
* For convenience, you can optionally provide a `then` function (with its own
|
|
2106
|
+
* set of dependencies) which will be called just after the Store has been
|
|
2107
|
+
* updated. This is a useful place to call the addCheckpoint method, for
|
|
2108
|
+
* example, if you wish to add the deletion to your application's undo stack.
|
|
2109
|
+
*
|
|
2110
|
+
* The Store to which the callback will make the deletion (indicated by the
|
|
2111
|
+
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
2112
|
+
* dependency for the callback.
|
|
2113
|
+
*
|
|
2114
|
+
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
2115
|
+
* Store, provide an Id for a named context Store, or provide an explicit
|
|
2116
|
+
* reference.
|
|
2117
|
+
* @param then A function which is called after the deletion, with a reference
|
|
2118
|
+
* to the Store.
|
|
2119
|
+
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
2120
|
+
* which, if any change, result in the regeneration of the callback. This
|
|
2121
|
+
* parameter defaults to an empty array.
|
|
2122
|
+
* @returns A callback for subsequent use.
|
|
2123
|
+
* @example
|
|
2124
|
+
* This example uses the useDelTablesCallback hook to create an event handler
|
|
2125
|
+
* which deletes from the Store when the `span` element is clicked.
|
|
2126
|
+
*
|
|
2127
|
+
* ```jsx
|
|
2128
|
+
* const store = createStore().setTables({pets: {nemo: {species: 'fish'}}});
|
|
2129
|
+
* const App = () => {
|
|
2130
|
+
* const handleClick = useDelTablesCallback(store, () =>
|
|
2131
|
+
* console.log('Deleted'),
|
|
2132
|
+
* );
|
|
2133
|
+
* return (
|
|
2134
|
+
* <span id="span" onClick={handleClick}>
|
|
2135
|
+
* {JSON.stringify(useTables(store))}
|
|
2136
|
+
* </span>
|
|
2137
|
+
* );
|
|
2138
|
+
* };
|
|
2139
|
+
*
|
|
2140
|
+
* const app = document.createElement('div');
|
|
2141
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
2142
|
+
* const span = app.querySelector('span');
|
|
2143
|
+
* console.log(span.innerHTML);
|
|
2144
|
+
* // -> '{"pets":{"nemo":{"species":"fish"}}}'
|
|
2145
|
+
*
|
|
2146
|
+
* // User clicks the <span> element:
|
|
2147
|
+
* // -> span MouseEvent('click', {bubbles: true})
|
|
2148
|
+
* // -> 'Deleted'
|
|
2149
|
+
*
|
|
2150
|
+
* console.log(span.innerHTML);
|
|
2151
|
+
* // -> '{}'
|
|
2152
|
+
* ```
|
|
2153
|
+
* @category Store hooks
|
|
2154
|
+
*/
|
|
2155
|
+
export function useDelTablesCallback(
|
|
2156
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
2157
|
+
then?: (store: Store) => void,
|
|
2158
|
+
thenDeps?: React.DependencyList,
|
|
2159
|
+
): Callback;
|
|
2160
|
+
|
|
2161
|
+
/**
|
|
2162
|
+
* The useDelTableCallback hook returns a callback that can be used to remove a
|
|
2163
|
+
* single Table from a Store.
|
|
2164
|
+
*
|
|
2165
|
+
* This hook is useful, for example, when creating an event handler that will
|
|
2166
|
+
* delete data in a Store.
|
|
2167
|
+
*
|
|
2168
|
+
* For convenience, you can optionally provide a `then` function (with its own
|
|
2169
|
+
* set of dependencies) which will be called just after the Store has been
|
|
2170
|
+
* updated. This is a useful place to call the addCheckpoint method, for
|
|
2171
|
+
* example, if you wish to add the deletion to your application's undo stack.
|
|
2172
|
+
*
|
|
2173
|
+
* The Store to which the callback will make the deletion (indicated by the
|
|
2174
|
+
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
2175
|
+
* dependency for the callback.
|
|
2176
|
+
*
|
|
2177
|
+
* @param tableId The Id of the Table in the Store.
|
|
2178
|
+
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
2179
|
+
* Store, provide an Id for a named context Store, or provide an explicit
|
|
2180
|
+
* reference.
|
|
2181
|
+
* @param then A function which is called after the deletion, with a reference
|
|
2182
|
+
* to the Store.
|
|
2183
|
+
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
2184
|
+
* which, if any change, result in the regeneration of the callback. This
|
|
2185
|
+
* parameter defaults to an empty array.
|
|
2186
|
+
* @returns A callback for subsequent use.
|
|
2187
|
+
* @example
|
|
2188
|
+
* This example uses the useDelTableCallback hook to create an event handler
|
|
2189
|
+
* which deletes from the Store when the `span` element is clicked.
|
|
2190
|
+
*
|
|
2191
|
+
* ```jsx
|
|
2192
|
+
* const store = createStore().setTables({pets: {nemo: {species: 'fish'}}});
|
|
2193
|
+
* const App = () => {
|
|
2194
|
+
* const handleClick = useDelTableCallback('pets', store, () =>
|
|
2195
|
+
* console.log('Deleted'),
|
|
2196
|
+
* );
|
|
2197
|
+
* return (
|
|
2198
|
+
* <span id="span" onClick={handleClick}>
|
|
2199
|
+
* {JSON.stringify(useTables(store))}
|
|
2200
|
+
* </span>
|
|
2201
|
+
* );
|
|
2202
|
+
* };
|
|
2203
|
+
*
|
|
2204
|
+
* const app = document.createElement('div');
|
|
2205
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
2206
|
+
* const span = app.querySelector('span');
|
|
2207
|
+
* console.log(span.innerHTML);
|
|
2208
|
+
* // -> '{"pets":{"nemo":{"species":"fish"}}}'
|
|
2209
|
+
*
|
|
2210
|
+
* // User clicks the <span> element:
|
|
2211
|
+
* // -> span MouseEvent('click', {bubbles: true})
|
|
2212
|
+
* // -> 'Deleted'
|
|
2213
|
+
*
|
|
2214
|
+
* console.log(span.innerHTML);
|
|
2215
|
+
* // -> '{}'
|
|
2216
|
+
* ```
|
|
2217
|
+
* @category Store hooks
|
|
2218
|
+
*/
|
|
2219
|
+
export function useDelTableCallback(
|
|
2220
|
+
tableId: Id,
|
|
2221
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
2222
|
+
then?: (store: Store) => void,
|
|
2223
|
+
thenDeps?: React.DependencyList,
|
|
2224
|
+
): Callback;
|
|
1723
2225
|
|
|
1724
2226
|
/**
|
|
1725
2227
|
* The useDelRowCallback hook returns a callback that can be used to remove a
|
|
@@ -1766,7 +2268,7 @@ export function useDelTableCallback(
|
|
|
1766
2268
|
* };
|
|
1767
2269
|
*
|
|
1768
2270
|
* const app = document.createElement('div');
|
|
1769
|
-
*
|
|
2271
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1770
2272
|
* const span = app.querySelector('span');
|
|
1771
2273
|
* console.log(span.innerHTML);
|
|
1772
2274
|
* // -> '{"pets":{"nemo":{"species":"fish"}}}'
|
|
@@ -1808,8 +2310,8 @@ export function useDelRowCallback(
|
|
|
1808
2310
|
* @param rowId The Id of the Row in the Table.
|
|
1809
2311
|
* @param cellId The Id of the Cell in the Row.
|
|
1810
2312
|
* @param forceDel An optional flag to indicate that the whole Row should be
|
|
1811
|
-
* deleted, even if a
|
|
1812
|
-
* `false`.
|
|
2313
|
+
* deleted, even if a TablesSchema provides a default value for this Cell.
|
|
2314
|
+
* Defaults to `false`.
|
|
1813
2315
|
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
1814
2316
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1815
2317
|
* reference.
|
|
@@ -1842,7 +2344,7 @@ export function useDelRowCallback(
|
|
|
1842
2344
|
* };
|
|
1843
2345
|
*
|
|
1844
2346
|
* const app = document.createElement('div');
|
|
1845
|
-
*
|
|
2347
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
1846
2348
|
* const span = app.querySelector('span');
|
|
1847
2349
|
* console.log(span.innerHTML);
|
|
1848
2350
|
* // -> '{"pets":{"nemo":{"species":"fish"}}}'
|
|
@@ -1866,9 +2368,139 @@ export function useDelCellCallback(
|
|
|
1866
2368
|
thenDeps?: React.DependencyList,
|
|
1867
2369
|
): Callback;
|
|
1868
2370
|
|
|
2371
|
+
/**
|
|
2372
|
+
* The useDelValuesCallback hook returns a callback that can be used to remove
|
|
2373
|
+
* all of the keyed value data in a Store.
|
|
2374
|
+
*
|
|
2375
|
+
* This hook is useful, for example, when creating an event handler that will
|
|
2376
|
+
* delete data in a Store.
|
|
2377
|
+
*
|
|
2378
|
+
* For convenience, you can optionally provide a `then` function (with its own
|
|
2379
|
+
* set of dependencies) which will be called just after the Store has been
|
|
2380
|
+
* updated. This is a useful place to call the addCheckpoint method, for
|
|
2381
|
+
* example, if you wish to add the deletion to your application's undo stack.
|
|
2382
|
+
*
|
|
2383
|
+
* The Store to which the callback will make the deletion (indicated by the
|
|
2384
|
+
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
2385
|
+
* dependency for the callback.
|
|
2386
|
+
*
|
|
2387
|
+
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
2388
|
+
* Store, provide an Id for a named context Store, or provide an explicit
|
|
2389
|
+
* reference.
|
|
2390
|
+
* @param then A function which is called after the deletion, with a reference
|
|
2391
|
+
* to the Store.
|
|
2392
|
+
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
2393
|
+
* which, if any change, result in the regeneration of the callback. This
|
|
2394
|
+
* parameter defaults to an empty array.
|
|
2395
|
+
* @returns A callback for subsequent use.
|
|
2396
|
+
* @example
|
|
2397
|
+
* This example uses the useDelValuesCallback hook to create an event handler
|
|
2398
|
+
* which deletes from the Store when the `span` element is clicked.
|
|
2399
|
+
*
|
|
2400
|
+
* ```jsx
|
|
2401
|
+
* const store = createStore().setValues({open: true});
|
|
2402
|
+
* const App = () => {
|
|
2403
|
+
* const handleClick = useDelValuesCallback(store, () =>
|
|
2404
|
+
* console.log('Deleted'),
|
|
2405
|
+
* );
|
|
2406
|
+
* return (
|
|
2407
|
+
* <span id="span" onClick={handleClick}>
|
|
2408
|
+
* {JSON.stringify(useValues(store))}
|
|
2409
|
+
* </span>
|
|
2410
|
+
* );
|
|
2411
|
+
* };
|
|
2412
|
+
*
|
|
2413
|
+
* const app = document.createElement('div');
|
|
2414
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
2415
|
+
* const span = app.querySelector('span');
|
|
2416
|
+
* console.log(span.innerHTML);
|
|
2417
|
+
* // -> '{"open":true}'
|
|
2418
|
+
*
|
|
2419
|
+
* // User clicks the <span> element:
|
|
2420
|
+
* // -> span MouseEvent('click', {bubbles: true})
|
|
2421
|
+
* // -> 'Deleted'
|
|
2422
|
+
*
|
|
2423
|
+
* console.log(span.innerHTML);
|
|
2424
|
+
* // -> '{}'
|
|
2425
|
+
* ```
|
|
2426
|
+
* @category Store hooks
|
|
2427
|
+
* @since v3.0.0
|
|
2428
|
+
*/
|
|
2429
|
+
export function useDelValuesCallback(
|
|
2430
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
2431
|
+
then?: (store: Store) => void,
|
|
2432
|
+
thenDeps?: React.DependencyList,
|
|
2433
|
+
): Callback;
|
|
2434
|
+
|
|
2435
|
+
/**
|
|
2436
|
+
* The useDelValueCallback hook returns a callback that can be used to remove a
|
|
2437
|
+
* single Value from a Store.
|
|
2438
|
+
*
|
|
2439
|
+
* This hook is useful, for example, when creating an event handler that will
|
|
2440
|
+
* delete data in a Store.
|
|
2441
|
+
*
|
|
2442
|
+
* For convenience, you can optionally provide a `then` function (with its own
|
|
2443
|
+
* set of dependencies) which will be called just after the Store has been
|
|
2444
|
+
* updated. This is a useful place to call the addCheckpoint method, for
|
|
2445
|
+
* example, if you wish to add the deletion to your application's undo stack.
|
|
2446
|
+
*
|
|
2447
|
+
* The Store to which the callback will make the deletion (indicated by the
|
|
2448
|
+
* hook's `storeOrStoreId` parameter) is always automatically used as a hook
|
|
2449
|
+
* dependency for the callback.
|
|
2450
|
+
*
|
|
2451
|
+
* @param valueId The Id of the Value in the Store.
|
|
2452
|
+
* @param storeOrStoreId The Store to be updated: omit for the default context
|
|
2453
|
+
* Store, provide an Id for a named context Store, or provide an explicit
|
|
2454
|
+
* reference.
|
|
2455
|
+
* @param then A function which is called after the deletion, with a reference
|
|
2456
|
+
* to the Store.
|
|
2457
|
+
* @param thenDeps An optional array of dependencies for the `then` function,
|
|
2458
|
+
* which, if any change, result in the regeneration of the callback. This
|
|
2459
|
+
* parameter defaults to an empty array.
|
|
2460
|
+
* @returns A callback for subsequent use.
|
|
2461
|
+
* @example
|
|
2462
|
+
* This example uses the useDelValueCallback hook to create an event handler
|
|
2463
|
+
* which deletes from the Store when the `span` element is clicked.
|
|
2464
|
+
*
|
|
2465
|
+
* ```jsx
|
|
2466
|
+
* const store = createStore().setValues({open: true, employees: 3});
|
|
2467
|
+
* const App = () => {
|
|
2468
|
+
* const handleClick = useDelValueCallback('open', store, () =>
|
|
2469
|
+
* console.log('Deleted'),
|
|
2470
|
+
* );
|
|
2471
|
+
* return (
|
|
2472
|
+
* <span id="span" onClick={handleClick}>
|
|
2473
|
+
* {JSON.stringify(useValues(store))}
|
|
2474
|
+
* </span>
|
|
2475
|
+
* );
|
|
2476
|
+
* };
|
|
2477
|
+
*
|
|
2478
|
+
* const app = document.createElement('div');
|
|
2479
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
2480
|
+
* const span = app.querySelector('span');
|
|
2481
|
+
* console.log(span.innerHTML);
|
|
2482
|
+
* // -> '{"open":true,"employees":3}'
|
|
2483
|
+
*
|
|
2484
|
+
* // User clicks the <span> element:
|
|
2485
|
+
* // -> span MouseEvent('click', {bubbles: true})
|
|
2486
|
+
* // -> 'Deleted'
|
|
2487
|
+
*
|
|
2488
|
+
* console.log(span.innerHTML);
|
|
2489
|
+
* // -> '{"employees":3}'
|
|
2490
|
+
* ```
|
|
2491
|
+
* @category Store hooks
|
|
2492
|
+
* @since v3.0.0
|
|
2493
|
+
*/
|
|
2494
|
+
export function useDelValueCallback(
|
|
2495
|
+
valueId: Id,
|
|
2496
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
2497
|
+
then?: (store: Store) => void,
|
|
2498
|
+
thenDeps?: React.DependencyList,
|
|
2499
|
+
): Callback;
|
|
2500
|
+
|
|
1869
2501
|
/**
|
|
1870
2502
|
* The useTablesListener hook registers a listener function with a Store that
|
|
1871
|
-
* will be called whenever data in it changes.
|
|
2503
|
+
* will be called whenever tabular data in it changes.
|
|
1872
2504
|
*
|
|
1873
2505
|
* This hook is useful for situations where a component needs to register its
|
|
1874
2506
|
* own specific listener to do more than simply tracking the value (which is
|
|
@@ -1879,8 +2511,8 @@ export function useDelCellCallback(
|
|
|
1879
2511
|
* for you: when the listener changes (per its `listenerDeps` dependencies) or
|
|
1880
2512
|
* the component unmounts, the listener on the underlying Store will be deleted.
|
|
1881
2513
|
*
|
|
1882
|
-
* @param listener The function that will be called whenever data in the
|
|
1883
|
-
* changes.
|
|
2514
|
+
* @param listener The function that will be called whenever tabular data in the
|
|
2515
|
+
* Store changes.
|
|
1884
2516
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
1885
2517
|
* function, which, if any change, result in the re-registration of the
|
|
1886
2518
|
* listener. This parameter defaults to an empty array.
|
|
@@ -1907,14 +2539,15 @@ export function useDelCellCallback(
|
|
|
1907
2539
|
*
|
|
1908
2540
|
* const store = createStore().setTables({pets: {fido: {color: 'brown'}}});
|
|
1909
2541
|
* const app = document.createElement('div');
|
|
1910
|
-
*
|
|
2542
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
2543
|
+
* root.render(<App store={store} />); // !act
|
|
1911
2544
|
* console.log(store.getListenerStats().tables);
|
|
1912
2545
|
* // -> 1
|
|
1913
2546
|
*
|
|
1914
2547
|
* store.setCell('pets', 'fido', 'color', 'walnut'); // !act
|
|
1915
2548
|
* // -> 'Tables changed'
|
|
1916
2549
|
*
|
|
1917
|
-
*
|
|
2550
|
+
* root.unmount(); // !act
|
|
1918
2551
|
* console.log(store.getListenerStats().tables);
|
|
1919
2552
|
* // -> 0
|
|
1920
2553
|
* ```
|
|
@@ -1969,14 +2602,15 @@ export function useTablesListener(
|
|
|
1969
2602
|
*
|
|
1970
2603
|
* const store = createStore().setTables({pets: {fido: {color: 'brown'}}});
|
|
1971
2604
|
* const app = document.createElement('div');
|
|
1972
|
-
*
|
|
2605
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
2606
|
+
* root.render(<App store={store} />); // !act
|
|
1973
2607
|
* console.log(store.getListenerStats().tableIds);
|
|
1974
2608
|
* // -> 1
|
|
1975
2609
|
*
|
|
1976
2610
|
* store.setTable('species', {dog: {price: 5}}); // !act
|
|
1977
2611
|
* // -> 'Table Ids changed'
|
|
1978
2612
|
*
|
|
1979
|
-
*
|
|
2613
|
+
* root.unmount(); // !act
|
|
1980
2614
|
* console.log(store.getListenerStats().tableIds);
|
|
1981
2615
|
* // -> 0
|
|
1982
2616
|
* ```
|
|
@@ -2034,14 +2668,15 @@ export function useTableIdsListener(
|
|
|
2034
2668
|
*
|
|
2035
2669
|
* const store = createStore().setTables({pets: {fido: {color: 'brown'}}});
|
|
2036
2670
|
* const app = document.createElement('div');
|
|
2037
|
-
*
|
|
2671
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
2672
|
+
* root.render(<App store={store} />); // !act
|
|
2038
2673
|
* console.log(store.getListenerStats().table);
|
|
2039
2674
|
* // -> 1
|
|
2040
2675
|
*
|
|
2041
2676
|
* store.setCell('pets', 'fido', 'color', 'walnut'); // !act
|
|
2042
2677
|
* // -> 'Table changed'
|
|
2043
2678
|
*
|
|
2044
|
-
*
|
|
2679
|
+
* root.unmount(); // !act
|
|
2045
2680
|
* console.log(store.getListenerStats().table);
|
|
2046
2681
|
* // -> 0
|
|
2047
2682
|
* ```
|
|
@@ -2100,14 +2735,15 @@ export function useTableListener(
|
|
|
2100
2735
|
*
|
|
2101
2736
|
* const store = createStore().setTables({pets: {fido: {color: 'brown'}}});
|
|
2102
2737
|
* const app = document.createElement('div');
|
|
2103
|
-
*
|
|
2738
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
2739
|
+
* root.render(<App store={store} />); // !act
|
|
2104
2740
|
* console.log(store.getListenerStats().rowIds);
|
|
2105
2741
|
* // -> 1
|
|
2106
2742
|
*
|
|
2107
2743
|
* store.setRow('pets', 'felix', {color: 'black'}); // !act
|
|
2108
2744
|
* // -> 'Row Ids changed'
|
|
2109
2745
|
*
|
|
2110
|
-
*
|
|
2746
|
+
* root.unmount(); // !act
|
|
2111
2747
|
* console.log(store.getListenerStats().rowIds);
|
|
2112
2748
|
* // -> 0
|
|
2113
2749
|
* ```
|
|
@@ -2177,14 +2813,15 @@ export function useRowIdsListener(
|
|
|
2177
2813
|
* },
|
|
2178
2814
|
* });
|
|
2179
2815
|
* const app = document.createElement('div');
|
|
2180
|
-
*
|
|
2816
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
2817
|
+
* root.render(<App store={store} />); // !act
|
|
2181
2818
|
* console.log(store.getListenerStats().sortedRowIds);
|
|
2182
2819
|
* // -> 1
|
|
2183
2820
|
*
|
|
2184
2821
|
* store.setRow('pets', 'cujo', {species: 'wolf'}); // !act
|
|
2185
2822
|
* // -> 'Sorted Row Ids changed'
|
|
2186
2823
|
*
|
|
2187
|
-
*
|
|
2824
|
+
* root.unmount(); // !act
|
|
2188
2825
|
* console.log(store.getListenerStats().sortedRowIds);
|
|
2189
2826
|
* // -> 0
|
|
2190
2827
|
* ```
|
|
@@ -2238,7 +2875,228 @@ export function useSortedRowIdsListener(
|
|
|
2238
2875
|
* default context Store, provide an Id for a named context Store, or provide an
|
|
2239
2876
|
* explicit reference.
|
|
2240
2877
|
* @example
|
|
2241
|
-
* This example uses the useRowListener hook to create a listener that is
|
|
2878
|
+
* This example uses the useRowListener hook to create a listener that is
|
|
2879
|
+
* scoped to a single component. When the component is unmounted, the listener
|
|
2880
|
+
* is removed from the Store.
|
|
2881
|
+
*
|
|
2882
|
+
* ```jsx
|
|
2883
|
+
* const App = ({store}) => (
|
|
2884
|
+
* <Provider store={store}>
|
|
2885
|
+
* <Pane />
|
|
2886
|
+
* </Provider>
|
|
2887
|
+
* );
|
|
2888
|
+
* const Pane = () => {
|
|
2889
|
+
* useRowListener('pets', 'fido', () => console.log('Row changed'));
|
|
2890
|
+
* return <span>App</span>;
|
|
2891
|
+
* };
|
|
2892
|
+
*
|
|
2893
|
+
* const store = createStore().setTables({pets: {fido: {color: 'brown'}}});
|
|
2894
|
+
* const app = document.createElement('div');
|
|
2895
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
2896
|
+
* root.render(<App store={store} />); // !act
|
|
2897
|
+
* console.log(store.getListenerStats().row);
|
|
2898
|
+
* // -> 1
|
|
2899
|
+
*
|
|
2900
|
+
* store.setCell('pets', 'fido', 'color', 'walnut'); // !act
|
|
2901
|
+
* // -> 'Row changed'
|
|
2902
|
+
*
|
|
2903
|
+
* root.unmount(); // !act
|
|
2904
|
+
* console.log(store.getListenerStats().row);
|
|
2905
|
+
* // -> 0
|
|
2906
|
+
* ```
|
|
2907
|
+
* @category Store hooks
|
|
2908
|
+
*/
|
|
2909
|
+
export function useRowListener(
|
|
2910
|
+
tableId: IdOrNull,
|
|
2911
|
+
rowId: IdOrNull,
|
|
2912
|
+
listener: RowListener,
|
|
2913
|
+
listenerDeps?: React.DependencyList,
|
|
2914
|
+
mutator?: boolean,
|
|
2915
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
2916
|
+
): void;
|
|
2917
|
+
|
|
2918
|
+
/**
|
|
2919
|
+
* The useCellIdsListener hook registers a listener function with a Store that
|
|
2920
|
+
* will be called whenever the Cell Ids in a Row change.
|
|
2921
|
+
*
|
|
2922
|
+
* This hook is useful for situations where a component needs to register its
|
|
2923
|
+
* own specific listener to do more than simply tracking the value (which is
|
|
2924
|
+
* more easily done with the useCellIds hook).
|
|
2925
|
+
*
|
|
2926
|
+
* You can either listen to a single Row (by specifying the Table Id and Row Id
|
|
2927
|
+
* as the method's first two parameters) or changes to any Row (by providing
|
|
2928
|
+
* `null` wildcards).
|
|
2929
|
+
*
|
|
2930
|
+
* Both, either, or neither of the `tableId` and `rowId` parameters can be
|
|
2931
|
+
* wildcarded with `null`. You can listen to a specific Row in a specific Table,
|
|
2932
|
+
* any Row in a specific Table, a specific Row in any Table, or any Row in any
|
|
2933
|
+
* Table.
|
|
2934
|
+
*
|
|
2935
|
+
* Unlike the addCellIdsListener method, which returns a listener Id and
|
|
2936
|
+
* requires you to remove it manually, the useCellIdsListener hook manages this
|
|
2937
|
+
* lifecycle for you: when the listener changes (per its `listenerDeps`
|
|
2938
|
+
* dependencies) or the component unmounts, the listener on the underlying Store
|
|
2939
|
+
* will be deleted.
|
|
2940
|
+
*
|
|
2941
|
+
* @param tableId The Id of the Table to listen to, or `null` as a wildcard.
|
|
2942
|
+
* @param rowId The Id of the Row to listen to, or `null` as a wildcard.
|
|
2943
|
+
* @param listener The function that will be called whenever the Cell Ids in the
|
|
2944
|
+
* Row change.
|
|
2945
|
+
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
2946
|
+
* function, which, if any change, result in the re-registration of the
|
|
2947
|
+
* listener. This parameter defaults to an empty array.
|
|
2948
|
+
* @param mutator An optional boolean that indicates that the listener mutates
|
|
2949
|
+
* Store data.
|
|
2950
|
+
* @param storeOrStoreId The Store to register the listener with: omit for the
|
|
2951
|
+
* default context Store, provide an Id for a named context Store, or provide an
|
|
2952
|
+
* explicit reference.
|
|
2953
|
+
* @example
|
|
2954
|
+
* This example uses the useCellIdsListener hook to create a listener that is
|
|
2955
|
+
* scoped to a single component. When the component is unmounted, the listener
|
|
2956
|
+
* is removed from the Store.
|
|
2957
|
+
*
|
|
2958
|
+
* ```jsx
|
|
2959
|
+
* const App = ({store}) => (
|
|
2960
|
+
* <Provider store={store}>
|
|
2961
|
+
* <Pane />
|
|
2962
|
+
* </Provider>
|
|
2963
|
+
* );
|
|
2964
|
+
* const Pane = () => {
|
|
2965
|
+
* useCellIdsListener('pets', 'fido', () =>
|
|
2966
|
+
* console.log('Cell Ids changed'),
|
|
2967
|
+
* );
|
|
2968
|
+
* return <span>App</span>;
|
|
2969
|
+
* };
|
|
2970
|
+
*
|
|
2971
|
+
* const store = createStore().setTables({pets: {fido: {color: 'brown'}}});
|
|
2972
|
+
* const app = document.createElement('div');
|
|
2973
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
2974
|
+
* root.render(<App store={store} />); // !act
|
|
2975
|
+
* console.log(store.getListenerStats().cellIds);
|
|
2976
|
+
* // -> 1
|
|
2977
|
+
*
|
|
2978
|
+
* store.setCell('pets', 'fido', 'species', 'dog'); // !act
|
|
2979
|
+
* // -> 'Cell Ids changed'
|
|
2980
|
+
*
|
|
2981
|
+
* root.unmount(); // !act
|
|
2982
|
+
* console.log(store.getListenerStats().cellIds);
|
|
2983
|
+
* // -> 0
|
|
2984
|
+
* ```
|
|
2985
|
+
* @category Store hooks
|
|
2986
|
+
*/
|
|
2987
|
+
export function useCellIdsListener(
|
|
2988
|
+
tableId: IdOrNull,
|
|
2989
|
+
rowId: IdOrNull,
|
|
2990
|
+
listener: CellIdsListener,
|
|
2991
|
+
listenerDeps?: React.DependencyList,
|
|
2992
|
+
mutator?: boolean,
|
|
2993
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
2994
|
+
): void;
|
|
2995
|
+
|
|
2996
|
+
/**
|
|
2997
|
+
* The useCellListener hook registers a listener function with a Store that will
|
|
2998
|
+
* be called whenever data in a Cell changes.
|
|
2999
|
+
*
|
|
3000
|
+
* This hook is useful for situations where a component needs to register its
|
|
3001
|
+
* own specific listener to do more than simply tracking the value (which is
|
|
3002
|
+
* more easily done with the useCell hook).
|
|
3003
|
+
*
|
|
3004
|
+
* You can either listen to a single Cell (by specifying the Table Id, Row Id,
|
|
3005
|
+
* and Cell Id as the method's first three parameters) or changes to any Cell
|
|
3006
|
+
* (by providing `null` wildcards).
|
|
3007
|
+
*
|
|
3008
|
+
* All, some, or none of the `tableId`, `rowId`, and `cellId` parameters can be
|
|
3009
|
+
* wildcarded with `null`. You can listen to a specific Cell in a specific Row
|
|
3010
|
+
* in a specific Table, any Cell in any Row in any Table, for example - or every
|
|
3011
|
+
* other combination of wildcards.
|
|
3012
|
+
*
|
|
3013
|
+
* Unlike the addCellListener method, which returns a listener Id and requires
|
|
3014
|
+
* you to remove it manually, the useCellListener hook manages this lifecycle
|
|
3015
|
+
* for you: when the listener changes (per its `listenerDeps` dependencies) or
|
|
3016
|
+
* the component unmounts, the listener on the underlying Store will be deleted.
|
|
3017
|
+
*
|
|
3018
|
+
* @param tableId The Id of the Table to listen to, or `null` as a wildcard.
|
|
3019
|
+
* @param rowId The Id of the Row to listen to, or `null` as a wildcard.
|
|
3020
|
+
* @param cellId The Id of the Cell to listen to, or `null` as a wildcard.
|
|
3021
|
+
* @param listener The function that will be called whenever data in the Cell
|
|
3022
|
+
* changes.
|
|
3023
|
+
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
3024
|
+
* function, which, if any change, result in the re-registration of the
|
|
3025
|
+
* listener. This parameter defaults to an empty array.
|
|
3026
|
+
* @param mutator An optional boolean that indicates that the listener mutates
|
|
3027
|
+
* Store data.
|
|
3028
|
+
* @param storeOrStoreId The Store to register the listener with: omit for the
|
|
3029
|
+
* default context Store, provide an Id for a named context Store, or provide an
|
|
3030
|
+
* explicit reference.
|
|
3031
|
+
* @example
|
|
3032
|
+
* This example uses the useCellListener hook to create a listener that is
|
|
3033
|
+
* scoped to a single component. When the component is unmounted, the listener
|
|
3034
|
+
* is removed from the Store.
|
|
3035
|
+
*
|
|
3036
|
+
* ```jsx
|
|
3037
|
+
* const App = ({store}) => (
|
|
3038
|
+
* <Provider store={store}>
|
|
3039
|
+
* <Pane />
|
|
3040
|
+
* </Provider>
|
|
3041
|
+
* );
|
|
3042
|
+
* const Pane = () => {
|
|
3043
|
+
* useCellListener('pets', 'fido', 'color', () =>
|
|
3044
|
+
* console.log('Cell changed'),
|
|
3045
|
+
* );
|
|
3046
|
+
* return <span>App</span>;
|
|
3047
|
+
* };
|
|
3048
|
+
*
|
|
3049
|
+
* const store = createStore().setTables({pets: {fido: {color: 'brown'}}});
|
|
3050
|
+
* const app = document.createElement('div');
|
|
3051
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
3052
|
+
* root.render(<App store={store} />); // !act
|
|
3053
|
+
* console.log(store.getListenerStats().cell);
|
|
3054
|
+
* // -> 1
|
|
3055
|
+
*
|
|
3056
|
+
* store.setCell('pets', 'fido', 'color', 'walnut'); // !act
|
|
3057
|
+
* // -> 'Cell changed'
|
|
3058
|
+
*
|
|
3059
|
+
* root.unmount(); // !act
|
|
3060
|
+
* console.log(store.getListenerStats().cell);
|
|
3061
|
+
* // -> 0
|
|
3062
|
+
* ```
|
|
3063
|
+
* @category Store hooks
|
|
3064
|
+
*/
|
|
3065
|
+
export function useCellListener(
|
|
3066
|
+
tableId: IdOrNull,
|
|
3067
|
+
rowId: IdOrNull,
|
|
3068
|
+
cellId: IdOrNull,
|
|
3069
|
+
listener: CellListener,
|
|
3070
|
+
listenerDeps?: React.DependencyList,
|
|
3071
|
+
mutator?: boolean,
|
|
3072
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
3073
|
+
): void;
|
|
3074
|
+
|
|
3075
|
+
/**
|
|
3076
|
+
* The useValuesListener hook registers a listener function with a Store that
|
|
3077
|
+
* will be called whenever keyed value data in it changes.
|
|
3078
|
+
*
|
|
3079
|
+
* This hook is useful for situations where a component needs to register its
|
|
3080
|
+
* own specific listener to do more than simply tracking the value (which is
|
|
3081
|
+
* more easily done with the useValues hook).
|
|
3082
|
+
*
|
|
3083
|
+
* Unlike the addValuesListener method, which returns a listener Id and requires
|
|
3084
|
+
* you to remove it manually, the useValuesListener hook manages this lifecycle
|
|
3085
|
+
* for you: when the listener changes (per its `listenerDeps` dependencies) or
|
|
3086
|
+
* the component unmounts, the listener on the underlying Store will be deleted.
|
|
3087
|
+
*
|
|
3088
|
+
* @param listener The function that will be called whenever keyed value data in
|
|
3089
|
+
* the Store changes.
|
|
3090
|
+
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
3091
|
+
* function, which, if any change, result in the re-registration of the
|
|
3092
|
+
* listener. This parameter defaults to an empty array.
|
|
3093
|
+
* @param mutator An optional boolean that indicates that the listener mutates
|
|
3094
|
+
* Store data.
|
|
3095
|
+
* @param storeOrStoreId The Store to register the listener with: omit for the
|
|
3096
|
+
* default context Store, provide an Id for a named context Store, or provide an
|
|
3097
|
+
* explicit reference.
|
|
3098
|
+
* @example
|
|
3099
|
+
* This example uses the useValuesListener hook to create a listener that is
|
|
2242
3100
|
* scoped to a single component. When the component is unmounted, the listener
|
|
2243
3101
|
* is removed from the Store.
|
|
2244
3102
|
*
|
|
@@ -2249,61 +3107,50 @@ export function useSortedRowIdsListener(
|
|
|
2249
3107
|
* </Provider>
|
|
2250
3108
|
* );
|
|
2251
3109
|
* const Pane = () => {
|
|
2252
|
-
*
|
|
3110
|
+
* useValuesListener(() => console.log('Values changed'));
|
|
2253
3111
|
* return <span>App</span>;
|
|
2254
3112
|
* };
|
|
2255
3113
|
*
|
|
2256
|
-
* const store = createStore().
|
|
3114
|
+
* const store = createStore().setValues({open: true});
|
|
2257
3115
|
* const app = document.createElement('div');
|
|
2258
|
-
*
|
|
2259
|
-
*
|
|
3116
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
3117
|
+
* root.render(<App store={store} />); // !act
|
|
3118
|
+
* console.log(store.getListenerStats().values);
|
|
2260
3119
|
* // -> 1
|
|
2261
3120
|
*
|
|
2262
|
-
* store.
|
|
2263
|
-
* // -> '
|
|
3121
|
+
* store.setValue('open', false); // !act
|
|
3122
|
+
* // -> 'Values changed'
|
|
2264
3123
|
*
|
|
2265
|
-
*
|
|
2266
|
-
* console.log(store.getListenerStats().
|
|
3124
|
+
* root.unmount(); // !act
|
|
3125
|
+
* console.log(store.getListenerStats().values);
|
|
2267
3126
|
* // -> 0
|
|
2268
3127
|
* ```
|
|
2269
3128
|
* @category Store hooks
|
|
3129
|
+
* @since v3.0.0
|
|
2270
3130
|
*/
|
|
2271
|
-
export function
|
|
2272
|
-
|
|
2273
|
-
rowId: IdOrNull,
|
|
2274
|
-
listener: RowListener,
|
|
3131
|
+
export function useValuesListener(
|
|
3132
|
+
listener: ValuesListener,
|
|
2275
3133
|
listenerDeps?: React.DependencyList,
|
|
2276
3134
|
mutator?: boolean,
|
|
2277
3135
|
storeOrStoreId?: StoreOrStoreId,
|
|
2278
3136
|
): void;
|
|
2279
3137
|
|
|
2280
3138
|
/**
|
|
2281
|
-
* The
|
|
2282
|
-
* will be called whenever the
|
|
3139
|
+
* The useValueIdsListener hook registers a listener function with a Store that
|
|
3140
|
+
* will be called whenever the Value Ids in it change.
|
|
2283
3141
|
*
|
|
2284
3142
|
* This hook is useful for situations where a component needs to register its
|
|
2285
3143
|
* own specific listener to do more than simply tracking the value (which is
|
|
2286
|
-
* more easily done with the
|
|
2287
|
-
*
|
|
2288
|
-
* You can either listen to a single Row (by specifying the Table Id and Row Id
|
|
2289
|
-
* as the method's first two parameters) or changes to any Row (by providing
|
|
2290
|
-
* `null` wildcards).
|
|
2291
|
-
*
|
|
2292
|
-
* Both, either, or neither of the `tableId` and `rowId` parameters can be
|
|
2293
|
-
* wildcarded with `null`. You can listen to a specific Row in a specific Table,
|
|
2294
|
-
* any Row in a specific Table, a specific Row in any Table, or any Row in any
|
|
2295
|
-
* Table.
|
|
3144
|
+
* more easily done with the useValueIds hook).
|
|
2296
3145
|
*
|
|
2297
|
-
* Unlike the
|
|
2298
|
-
* requires you to remove it manually, the
|
|
3146
|
+
* Unlike the addValueIdsListener method, which returns a listener Id and
|
|
3147
|
+
* requires you to remove it manually, the useValueIdsListener hook manages this
|
|
2299
3148
|
* lifecycle for you: when the listener changes (per its `listenerDeps`
|
|
2300
3149
|
* dependencies) or the component unmounts, the listener on the underlying Store
|
|
2301
3150
|
* will be deleted.
|
|
2302
3151
|
*
|
|
2303
|
-
* @param
|
|
2304
|
-
*
|
|
2305
|
-
* @param listener The function that will be called whenever the Cell Ids in the
|
|
2306
|
-
* Row change.
|
|
3152
|
+
* @param listener The function that will be called whenever the Value Ids in
|
|
3153
|
+
* the Store change.
|
|
2307
3154
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
2308
3155
|
* function, which, if any change, result in the re-registration of the
|
|
2309
3156
|
* listener. This parameter defaults to an empty array.
|
|
@@ -2313,7 +3160,7 @@ export function useRowListener(
|
|
|
2313
3160
|
* default context Store, provide an Id for a named context Store, or provide an
|
|
2314
3161
|
* explicit reference.
|
|
2315
3162
|
* @example
|
|
2316
|
-
* This example uses the
|
|
3163
|
+
* This example uses the useValueIdsListener hook to create a listener that is
|
|
2317
3164
|
* scoped to a single component. When the component is unmounted, the listener
|
|
2318
3165
|
* is removed from the Store.
|
|
2319
3166
|
*
|
|
@@ -2324,62 +3171,52 @@ export function useRowListener(
|
|
|
2324
3171
|
* </Provider>
|
|
2325
3172
|
* );
|
|
2326
3173
|
* const Pane = () => {
|
|
2327
|
-
*
|
|
2328
|
-
* console.log('Cell Ids changed'),
|
|
2329
|
-
* );
|
|
3174
|
+
* useValueIdsListener(() => console.log('Value Ids changed'));
|
|
2330
3175
|
* return <span>App</span>;
|
|
2331
3176
|
* };
|
|
2332
3177
|
*
|
|
2333
|
-
* const store = createStore().
|
|
3178
|
+
* const store = createStore().setValues({open: true});
|
|
2334
3179
|
* const app = document.createElement('div');
|
|
2335
|
-
*
|
|
2336
|
-
*
|
|
3180
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
3181
|
+
* root.render(<App store={store} />); // !act
|
|
3182
|
+
* console.log(store.getListenerStats().valueIds);
|
|
2337
3183
|
* // -> 1
|
|
2338
3184
|
*
|
|
2339
|
-
* store.
|
|
2340
|
-
* // -> '
|
|
3185
|
+
* store.setValue('employees', 3); // !act
|
|
3186
|
+
* // -> 'Value Ids changed'
|
|
2341
3187
|
*
|
|
2342
|
-
*
|
|
2343
|
-
* console.log(store.getListenerStats().
|
|
3188
|
+
* root.unmount(); // !act
|
|
3189
|
+
* console.log(store.getListenerStats().valueIds);
|
|
2344
3190
|
* // -> 0
|
|
2345
3191
|
* ```
|
|
2346
3192
|
* @category Store hooks
|
|
3193
|
+
* @since v3.0.0
|
|
2347
3194
|
*/
|
|
2348
|
-
export function
|
|
2349
|
-
|
|
2350
|
-
rowId: IdOrNull,
|
|
2351
|
-
listener: CellIdsListener,
|
|
3195
|
+
export function useValueIdsListener(
|
|
3196
|
+
listener: ValueIdsListener,
|
|
2352
3197
|
listenerDeps?: React.DependencyList,
|
|
2353
3198
|
mutator?: boolean,
|
|
2354
3199
|
storeOrStoreId?: StoreOrStoreId,
|
|
2355
3200
|
): void;
|
|
2356
3201
|
|
|
2357
3202
|
/**
|
|
2358
|
-
* The
|
|
2359
|
-
* be called whenever data in a
|
|
3203
|
+
* The useValueListener hook registers a listener function with a Store that
|
|
3204
|
+
* will be called whenever data in a Value changes.
|
|
2360
3205
|
*
|
|
2361
3206
|
* This hook is useful for situations where a component needs to register its
|
|
2362
3207
|
* own specific listener to do more than simply tracking the value (which is
|
|
2363
|
-
* more easily done with the
|
|
2364
|
-
*
|
|
2365
|
-
* You can either listen to a single Cell (by specifying the Table Id, Row Id,
|
|
2366
|
-
* and Cell Id as the method's first three parameters) or changes to any Cell
|
|
2367
|
-
* (by providing `null` wildcards).
|
|
3208
|
+
* more easily done with the useValue hook).
|
|
2368
3209
|
*
|
|
2369
|
-
*
|
|
2370
|
-
*
|
|
2371
|
-
* in a specific Table, any Cell in any Row in any Table, for example - or every
|
|
2372
|
-
* other combination of wildcards.
|
|
3210
|
+
* You can either listen to a single Value (by specifying its Id as the method's
|
|
3211
|
+
* first parameter) or changes to any Value (by providing a `null` wildcard).
|
|
2373
3212
|
*
|
|
2374
|
-
* Unlike the
|
|
2375
|
-
* you to remove it manually, the
|
|
3213
|
+
* Unlike the addValueListener method, which returns a listener Id and requires
|
|
3214
|
+
* you to remove it manually, the useValueListener hook manages this lifecycle
|
|
2376
3215
|
* for you: when the listener changes (per its `listenerDeps` dependencies) or
|
|
2377
3216
|
* the component unmounts, the listener on the underlying Store will be deleted.
|
|
2378
3217
|
*
|
|
2379
|
-
* @param
|
|
2380
|
-
* @param
|
|
2381
|
-
* @param cellId The Id of the Cell to listen to, or `null` as a wildcard.
|
|
2382
|
-
* @param listener The function that will be called whenever data in the Cell
|
|
3218
|
+
* @param valueId The Id of the Value to listen to, or `null` as a wildcard.
|
|
3219
|
+
* @param listener The function that will be called whenever data in the Value
|
|
2383
3220
|
* changes.
|
|
2384
3221
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
2385
3222
|
* function, which, if any change, result in the re-registration of the
|
|
@@ -2390,7 +3227,7 @@ export function useCellIdsListener(
|
|
|
2390
3227
|
* default context Store, provide an Id for a named context Store, or provide an
|
|
2391
3228
|
* explicit reference.
|
|
2392
3229
|
* @example
|
|
2393
|
-
* This example uses the
|
|
3230
|
+
* This example uses the useValueListener hook to create a listener that is
|
|
2394
3231
|
* scoped to a single component. When the component is unmounted, the listener
|
|
2395
3232
|
* is removed from the Store.
|
|
2396
3233
|
*
|
|
@@ -2401,32 +3238,30 @@ export function useCellIdsListener(
|
|
|
2401
3238
|
* </Provider>
|
|
2402
3239
|
* );
|
|
2403
3240
|
* const Pane = () => {
|
|
2404
|
-
*
|
|
2405
|
-
* console.log('Cell changed'),
|
|
2406
|
-
* );
|
|
3241
|
+
* useValueListener('open', () => console.log('Value changed'));
|
|
2407
3242
|
* return <span>App</span>;
|
|
2408
3243
|
* };
|
|
2409
3244
|
*
|
|
2410
|
-
* const store = createStore().
|
|
3245
|
+
* const store = createStore().setValues({open: true});
|
|
2411
3246
|
* const app = document.createElement('div');
|
|
2412
|
-
*
|
|
2413
|
-
*
|
|
3247
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
3248
|
+
* root.render(<App store={store} />); // !act
|
|
3249
|
+
* console.log(store.getListenerStats().value);
|
|
2414
3250
|
* // -> 1
|
|
2415
3251
|
*
|
|
2416
|
-
* store.
|
|
2417
|
-
* // -> '
|
|
3252
|
+
* store.setValue('open', false); // !act
|
|
3253
|
+
* // -> 'Value changed'
|
|
2418
3254
|
*
|
|
2419
|
-
*
|
|
2420
|
-
* console.log(store.getListenerStats().
|
|
3255
|
+
* root.unmount(); // !act
|
|
3256
|
+
* console.log(store.getListenerStats().value);
|
|
2421
3257
|
* // -> 0
|
|
2422
3258
|
* ```
|
|
2423
3259
|
* @category Store hooks
|
|
3260
|
+
* @since v3.0.0
|
|
2424
3261
|
*/
|
|
2425
|
-
export function
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
cellId: IdOrNull,
|
|
2429
|
-
listener: CellListener,
|
|
3262
|
+
export function useValueListener(
|
|
3263
|
+
valueId: IdOrNull,
|
|
3264
|
+
listener: ValueListener,
|
|
2430
3265
|
listenerDeps?: React.DependencyList,
|
|
2431
3266
|
mutator?: boolean,
|
|
2432
3267
|
storeOrStoreId?: StoreOrStoreId,
|
|
@@ -2484,10 +3319,11 @@ export function useCellListener(
|
|
|
2484
3319
|
* };
|
|
2485
3320
|
*
|
|
2486
3321
|
* const app = document.createElement('div');
|
|
2487
|
-
*
|
|
3322
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
3323
|
+
* root.render(<App />); // !act
|
|
2488
3324
|
* // -> 'Metrics created'
|
|
2489
3325
|
*
|
|
2490
|
-
*
|
|
3326
|
+
* root.render(<App />); // !act
|
|
2491
3327
|
* // No second Metrics creation
|
|
2492
3328
|
*
|
|
2493
3329
|
* console.log(app.innerHTML);
|
|
@@ -2521,13 +3357,14 @@ export function useCellListener(
|
|
|
2521
3357
|
* };
|
|
2522
3358
|
*
|
|
2523
3359
|
* const app = document.createElement('div');
|
|
2524
|
-
*
|
|
3360
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
3361
|
+
* root.render(<App tableToCount="pets" />); // !act
|
|
2525
3362
|
* // -> 'Count created for pets table'
|
|
2526
3363
|
*
|
|
2527
3364
|
* console.log(app.innerHTML);
|
|
2528
3365
|
* // -> '<span>1</span>'
|
|
2529
3366
|
*
|
|
2530
|
-
*
|
|
3367
|
+
* root.render(<App tableToCount="species" />); // !act
|
|
2531
3368
|
* // -> 'Count created for species table'
|
|
2532
3369
|
*
|
|
2533
3370
|
* console.log(app.innerHTML);
|
|
@@ -2574,7 +3411,7 @@ export function useCreateMetrics(
|
|
|
2574
3411
|
*
|
|
2575
3412
|
* const metrics = createMetrics(createStore());
|
|
2576
3413
|
* const app = document.createElement('div');
|
|
2577
|
-
*
|
|
3414
|
+
* ReactDOMClient.createRoot(app).render(<App metrics={metrics} />); // !act
|
|
2578
3415
|
* console.log(app.innerHTML);
|
|
2579
3416
|
* // -> '<span>0</span>'
|
|
2580
3417
|
* ```
|
|
@@ -2596,7 +3433,7 @@ export function useCreateMetrics(
|
|
|
2596
3433
|
*
|
|
2597
3434
|
* const metrics = createMetrics(createStore());
|
|
2598
3435
|
* const app = document.createElement('div');
|
|
2599
|
-
*
|
|
3436
|
+
* ReactDOMClient.createRoot(app).render(<App metrics={metrics} />); // !act
|
|
2600
3437
|
* console.log(app.innerHTML);
|
|
2601
3438
|
* // -> '<span>0</span>'
|
|
2602
3439
|
* ```
|
|
@@ -2640,7 +3477,7 @@ export function useMetrics(id?: Id): Metrics | undefined;
|
|
|
2640
3477
|
* const App = () => <span>{useMetric('highestPrice', metrics)}</span>;
|
|
2641
3478
|
*
|
|
2642
3479
|
* const app = document.createElement('div');
|
|
2643
|
-
*
|
|
3480
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
2644
3481
|
* console.log(app.innerHTML);
|
|
2645
3482
|
* // -> '<span>5</span>'
|
|
2646
3483
|
*
|
|
@@ -2669,7 +3506,7 @@ export function useMetrics(id?: Id): Metrics | undefined;
|
|
|
2669
3506
|
* ).setMetricDefinition('highestPrice', 'species', 'max', 'price');
|
|
2670
3507
|
*
|
|
2671
3508
|
* const app = document.createElement('div');
|
|
2672
|
-
*
|
|
3509
|
+
* ReactDOMClient.createRoot(app).render(<App metrics={metrics} />); // !act
|
|
2673
3510
|
* console.log(app.innerHTML);
|
|
2674
3511
|
* // -> '<span>5</span>'
|
|
2675
3512
|
* ```
|
|
@@ -2694,7 +3531,7 @@ export function useMetrics(id?: Id): Metrics | undefined;
|
|
|
2694
3531
|
* ).setMetricDefinition('highestPrice', 'species', 'max', 'price');
|
|
2695
3532
|
*
|
|
2696
3533
|
* const app = document.createElement('div');
|
|
2697
|
-
*
|
|
3534
|
+
* ReactDOMClient.createRoot(app).render(<App metrics={metrics} />); // !act
|
|
2698
3535
|
* console.log(app.innerHTML);
|
|
2699
3536
|
* // -> '<span>5</span>'
|
|
2700
3537
|
* ```
|
|
@@ -2756,14 +3593,15 @@ export function useMetric(
|
|
|
2756
3593
|
* metrics.setMetricDefinition('highestPrice', 'species', 'max', 'price');
|
|
2757
3594
|
*
|
|
2758
3595
|
* const app = document.createElement('div');
|
|
2759
|
-
*
|
|
3596
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
3597
|
+
* root.render(<App metrics={metrics} />); // !act
|
|
2760
3598
|
* console.log(metrics.getListenerStats().metric);
|
|
2761
3599
|
* // -> 1
|
|
2762
3600
|
*
|
|
2763
3601
|
* store.setCell('species', 'horse', 'price', 20); // !act
|
|
2764
3602
|
* // -> 'Metric changed'
|
|
2765
3603
|
*
|
|
2766
|
-
*
|
|
3604
|
+
* root.unmount(); // !act
|
|
2767
3605
|
* console.log(metrics.getListenerStats().metric);
|
|
2768
3606
|
* // -> 0
|
|
2769
3607
|
* ```
|
|
@@ -2833,10 +3671,11 @@ export function useMetricListener(
|
|
|
2833
3671
|
* };
|
|
2834
3672
|
*
|
|
2835
3673
|
* const app = document.createElement('div');
|
|
2836
|
-
*
|
|
3674
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
3675
|
+
* root.render(<App />); // !act
|
|
2837
3676
|
* // -> 'Indexes created'
|
|
2838
3677
|
*
|
|
2839
|
-
*
|
|
3678
|
+
* root.render(<App />); // !act
|
|
2840
3679
|
* // No second Indexes creation
|
|
2841
3680
|
*
|
|
2842
3681
|
* console.log(app.innerHTML);
|
|
@@ -2873,13 +3712,14 @@ export function useMetricListener(
|
|
|
2873
3712
|
* };
|
|
2874
3713
|
*
|
|
2875
3714
|
* const app = document.createElement('div');
|
|
2876
|
-
*
|
|
3715
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
3716
|
+
* root.render(<App cellToIndex="species" />); // !act
|
|
2877
3717
|
* // -> 'Index created for species cell'
|
|
2878
3718
|
*
|
|
2879
3719
|
* console.log(app.innerHTML);
|
|
2880
3720
|
* // -> '<span>["dog","cat"]</span>'
|
|
2881
3721
|
*
|
|
2882
|
-
*
|
|
3722
|
+
* root.render(<App cellToIndex="color" />); // !act
|
|
2883
3723
|
* // -> 'Index created for color cell'
|
|
2884
3724
|
*
|
|
2885
3725
|
* console.log(app.innerHTML);
|
|
@@ -2926,7 +3766,7 @@ export function useCreateIndexes(
|
|
|
2926
3766
|
*
|
|
2927
3767
|
* const indexes = createIndexes(createStore());
|
|
2928
3768
|
* const app = document.createElement('div');
|
|
2929
|
-
*
|
|
3769
|
+
* ReactDOMClient.createRoot(app).render(<App indexes={indexes} />); // !act
|
|
2930
3770
|
* console.log(app.innerHTML);
|
|
2931
3771
|
* // -> '<span>0</span>'
|
|
2932
3772
|
* ```
|
|
@@ -2948,7 +3788,7 @@ export function useCreateIndexes(
|
|
|
2948
3788
|
*
|
|
2949
3789
|
* const indexes = createIndexes(createStore());
|
|
2950
3790
|
* const app = document.createElement('div');
|
|
2951
|
-
*
|
|
3791
|
+
* ReactDOMClient.createRoot(app).render(<App indexes={indexes} />); // !act
|
|
2952
3792
|
* console.log(app.innerHTML);
|
|
2953
3793
|
* // -> '<span>0</span>'
|
|
2954
3794
|
* ```
|
|
@@ -2994,7 +3834,7 @@ export function useIndexes(id?: Id): Indexes | undefined;
|
|
|
2994
3834
|
* );
|
|
2995
3835
|
*
|
|
2996
3836
|
* const app = document.createElement('div');
|
|
2997
|
-
*
|
|
3837
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
2998
3838
|
* console.log(app.innerHTML);
|
|
2999
3839
|
* // -> '<span>["dog","cat"]</span>'
|
|
3000
3840
|
*
|
|
@@ -3023,7 +3863,7 @@ export function useIndexes(id?: Id): Indexes | undefined;
|
|
|
3023
3863
|
* ).setIndexDefinition('bySpecies', 'pets', 'species');
|
|
3024
3864
|
*
|
|
3025
3865
|
* const app = document.createElement('div');
|
|
3026
|
-
*
|
|
3866
|
+
* ReactDOMClient.createRoot(app).render(<App indexes={indexes} />); // !act
|
|
3027
3867
|
* console.log(app.innerHTML);
|
|
3028
3868
|
* // -> '<span>["dog","cat"]</span>'
|
|
3029
3869
|
* ```
|
|
@@ -3050,7 +3890,7 @@ export function useIndexes(id?: Id): Indexes | undefined;
|
|
|
3050
3890
|
* ).setIndexDefinition('bySpecies', 'pets', 'species');
|
|
3051
3891
|
*
|
|
3052
3892
|
* const app = document.createElement('div');
|
|
3053
|
-
*
|
|
3893
|
+
* ReactDOMClient.createRoot(app).render(<App indexes={indexes} />); // !act
|
|
3054
3894
|
* console.log(app.innerHTML);
|
|
3055
3895
|
* // -> '<span>["dog","cat"]</span>'
|
|
3056
3896
|
* ```
|
|
@@ -3103,7 +3943,7 @@ export function useSliceIds(
|
|
|
3103
3943
|
* );
|
|
3104
3944
|
*
|
|
3105
3945
|
* const app = document.createElement('div');
|
|
3106
|
-
*
|
|
3946
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
3107
3947
|
* console.log(app.innerHTML);
|
|
3108
3948
|
* // -> '<span>["fido","cujo"]</span>'
|
|
3109
3949
|
*
|
|
@@ -3134,7 +3974,7 @@ export function useSliceIds(
|
|
|
3134
3974
|
* ).setIndexDefinition('bySpecies', 'pets', 'species');
|
|
3135
3975
|
*
|
|
3136
3976
|
* const app = document.createElement('div');
|
|
3137
|
-
*
|
|
3977
|
+
* ReactDOMClient.createRoot(app).render(<App indexes={indexes} />); // !act
|
|
3138
3978
|
* console.log(app.innerHTML);
|
|
3139
3979
|
* // -> '<span>["fido","cujo"]</span>'
|
|
3140
3980
|
* ```
|
|
@@ -3163,7 +4003,7 @@ export function useSliceIds(
|
|
|
3163
4003
|
* ).setIndexDefinition('bySpecies', 'pets', 'species');
|
|
3164
4004
|
*
|
|
3165
4005
|
* const app = document.createElement('div');
|
|
3166
|
-
*
|
|
4006
|
+
* ReactDOMClient.createRoot(app).render(<App indexes={indexes} />); // !act
|
|
3167
4007
|
* console.log(app.innerHTML);
|
|
3168
4008
|
* // -> '<span>["fido","cujo"]</span>'
|
|
3169
4009
|
* ```
|
|
@@ -3227,14 +4067,15 @@ export function useSliceRowIds(
|
|
|
3227
4067
|
* indexes.setIndexDefinition('bySpecies', 'pets', 'species');
|
|
3228
4068
|
*
|
|
3229
4069
|
* const app = document.createElement('div');
|
|
3230
|
-
*
|
|
4070
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4071
|
+
* root.render(<App indexes={indexes} />); // !act
|
|
3231
4072
|
* console.log(indexes.getListenerStats().sliceIds);
|
|
3232
4073
|
* // -> 1
|
|
3233
4074
|
*
|
|
3234
4075
|
* store.setRow('pets', 'lowly', {species: 'worm'}); // !act
|
|
3235
4076
|
* // -> 'Slice Ids changed'
|
|
3236
4077
|
*
|
|
3237
|
-
*
|
|
4078
|
+
* root.unmount(); // !act
|
|
3238
4079
|
* console.log(indexes.getListenerStats().sliceIds);
|
|
3239
4080
|
* // -> 0
|
|
3240
4081
|
* ```
|
|
@@ -3307,14 +4148,15 @@ export function useSliceIdsListener(
|
|
|
3307
4148
|
* indexes.setIndexDefinition('bySpecies', 'pets', 'species');
|
|
3308
4149
|
*
|
|
3309
4150
|
* const app = document.createElement('div');
|
|
3310
|
-
*
|
|
4151
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4152
|
+
* root.render(<App indexes={indexes} />); // !act
|
|
3311
4153
|
* console.log(indexes.getListenerStats().sliceRowIds);
|
|
3312
4154
|
* // -> 1
|
|
3313
4155
|
*
|
|
3314
4156
|
* store.setRow('pets', 'toto', {species: 'dog'}); // !act
|
|
3315
4157
|
* // -> 'Slice Row Ids changed'
|
|
3316
4158
|
*
|
|
3317
|
-
*
|
|
4159
|
+
* root.unmount(); // !act
|
|
3318
4160
|
* console.log(indexes.getListenerStats().sliceRowIds);
|
|
3319
4161
|
* // -> 0
|
|
3320
4162
|
* ```
|
|
@@ -3388,10 +4230,11 @@ export function useSliceRowIdsListener(
|
|
|
3388
4230
|
* };
|
|
3389
4231
|
*
|
|
3390
4232
|
* const app = document.createElement('div');
|
|
3391
|
-
*
|
|
4233
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4234
|
+
* root.render(<App />); // !act
|
|
3392
4235
|
* // -> 'Relationships created'
|
|
3393
4236
|
*
|
|
3394
|
-
*
|
|
4237
|
+
* root.render(<App />); // !act
|
|
3395
4238
|
* // No second Relationships creation
|
|
3396
4239
|
*
|
|
3397
4240
|
* console.log(app.innerHTML);
|
|
@@ -3433,13 +4276,14 @@ export function useSliceRowIdsListener(
|
|
|
3433
4276
|
* };
|
|
3434
4277
|
*
|
|
3435
4278
|
* const app = document.createElement('div');
|
|
3436
|
-
*
|
|
4279
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4280
|
+
* root.render(<App remoteTableAndCellToLink="species" />); // !act
|
|
3437
4281
|
* // -> 'Relationship created to species'
|
|
3438
4282
|
*
|
|
3439
4283
|
* console.log(app.innerHTML);
|
|
3440
4284
|
* // -> '<span>dog</span>'
|
|
3441
4285
|
*
|
|
3442
|
-
*
|
|
4286
|
+
* root.render(<App remoteTableAndCellToLink="color" />); // !act
|
|
3443
4287
|
* // -> 'Relationship created to color'
|
|
3444
4288
|
*
|
|
3445
4289
|
* console.log(app.innerHTML);
|
|
@@ -3490,7 +4334,8 @@ export function useCreateRelationships(
|
|
|
3490
4334
|
*
|
|
3491
4335
|
* const relationships = createRelationships(createStore());
|
|
3492
4336
|
* const app = document.createElement('div');
|
|
3493
|
-
*
|
|
4337
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4338
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
3494
4339
|
* console.log(app.innerHTML);
|
|
3495
4340
|
* // -> '<span>0</span>'
|
|
3496
4341
|
* ```
|
|
@@ -3514,7 +4359,8 @@ export function useCreateRelationships(
|
|
|
3514
4359
|
*
|
|
3515
4360
|
* const relationships = createRelationships(createStore());
|
|
3516
4361
|
* const app = document.createElement('div');
|
|
3517
|
-
*
|
|
4362
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4363
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
3518
4364
|
* console.log(app.innerHTML);
|
|
3519
4365
|
* // -> '<span>0</span>'
|
|
3520
4366
|
* ```
|
|
@@ -3565,7 +4411,7 @@ export function useRelationships(id?: Id): Relationships | undefined;
|
|
|
3565
4411
|
* );
|
|
3566
4412
|
*
|
|
3567
4413
|
* const app = document.createElement('div');
|
|
3568
|
-
*
|
|
4414
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
3569
4415
|
* console.log(app.innerHTML);
|
|
3570
4416
|
* // -> '<span>dog</span>'
|
|
3571
4417
|
*
|
|
@@ -3592,7 +4438,8 @@ export function useRelationships(id?: Id): Relationships | undefined;
|
|
|
3592
4438
|
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
3593
4439
|
*
|
|
3594
4440
|
* const app = document.createElement('div');
|
|
3595
|
-
*
|
|
4441
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4442
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
3596
4443
|
* console.log(app.innerHTML);
|
|
3597
4444
|
* // -> '<span>dog</span>'
|
|
3598
4445
|
* ```
|
|
@@ -3617,7 +4464,8 @@ export function useRelationships(id?: Id): Relationships | undefined;
|
|
|
3617
4464
|
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
3618
4465
|
*
|
|
3619
4466
|
* const app = document.createElement('div');
|
|
3620
|
-
*
|
|
4467
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4468
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
3621
4469
|
* console.log(app.innerHTML);
|
|
3622
4470
|
* // -> '<span>dog</span>'
|
|
3623
4471
|
* ```
|
|
@@ -3674,7 +4522,7 @@ export function useRemoteRowId(
|
|
|
3674
4522
|
* );
|
|
3675
4523
|
*
|
|
3676
4524
|
* const app = document.createElement('div');
|
|
3677
|
-
*
|
|
4525
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
3678
4526
|
* console.log(app.innerHTML);
|
|
3679
4527
|
* // -> '<span>["fido","cujo"]</span>'
|
|
3680
4528
|
*
|
|
@@ -3703,7 +4551,8 @@ export function useRemoteRowId(
|
|
|
3703
4551
|
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
3704
4552
|
*
|
|
3705
4553
|
* const app = document.createElement('div');
|
|
3706
|
-
*
|
|
4554
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4555
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
3707
4556
|
* console.log(app.innerHTML);
|
|
3708
4557
|
* // -> '<span>["fido","cujo"]</span>'
|
|
3709
4558
|
* ```
|
|
@@ -3732,7 +4581,8 @@ export function useRemoteRowId(
|
|
|
3732
4581
|
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
3733
4582
|
*
|
|
3734
4583
|
* const app = document.createElement('div');
|
|
3735
|
-
*
|
|
4584
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4585
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
3736
4586
|
* console.log(app.innerHTML);
|
|
3737
4587
|
* // -> '<span>["fido","cujo"]</span>'
|
|
3738
4588
|
* ```
|
|
@@ -3791,7 +4641,7 @@ export function useLocalRowIds(
|
|
|
3791
4641
|
* );
|
|
3792
4642
|
*
|
|
3793
4643
|
* const app = document.createElement('div');
|
|
3794
|
-
*
|
|
4644
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
3795
4645
|
* console.log(app.innerHTML);
|
|
3796
4646
|
* // -> '<span>["fido","felix","cujo"]</span>'
|
|
3797
4647
|
*
|
|
@@ -3823,7 +4673,8 @@ export function useLocalRowIds(
|
|
|
3823
4673
|
* ).setRelationshipDefinition('petSequence', 'pets', 'pets', 'next');
|
|
3824
4674
|
*
|
|
3825
4675
|
* const app = document.createElement('div');
|
|
3826
|
-
*
|
|
4676
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4677
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
3827
4678
|
* console.log(app.innerHTML);
|
|
3828
4679
|
* // -> '<span>["fido","felix","cujo"]</span>'
|
|
3829
4680
|
* ```
|
|
@@ -3854,7 +4705,8 @@ export function useLocalRowIds(
|
|
|
3854
4705
|
* ).setRelationshipDefinition('petSequence', 'pets', 'pets', 'next');
|
|
3855
4706
|
*
|
|
3856
4707
|
* const app = document.createElement('div');
|
|
3857
|
-
*
|
|
4708
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4709
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
3858
4710
|
* console.log(app.innerHTML);
|
|
3859
4711
|
* // -> '<span>["fido","felix","cujo"]</span>'
|
|
3860
4712
|
* ```
|
|
@@ -3933,14 +4785,15 @@ export function useLinkedRowIds(
|
|
|
3933
4785
|
* );
|
|
3934
4786
|
*
|
|
3935
4787
|
* const app = document.createElement('div');
|
|
3936
|
-
*
|
|
4788
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4789
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
3937
4790
|
* console.log(relationships.getListenerStats().remoteRowId);
|
|
3938
4791
|
* // -> 1
|
|
3939
4792
|
*
|
|
3940
4793
|
* store.setCell('pets', 'cujo', 'species', 'wolf'); // !act
|
|
3941
4794
|
* // -> 'Remote Row Id changed'
|
|
3942
4795
|
*
|
|
3943
|
-
*
|
|
4796
|
+
* root.unmount(); // !act
|
|
3944
4797
|
* console.log(relationships.getListenerStats().remoteRowId);
|
|
3945
4798
|
* // -> 0
|
|
3946
4799
|
* ```
|
|
@@ -4021,14 +4874,15 @@ export function useRemoteRowIdListener(
|
|
|
4021
4874
|
* );
|
|
4022
4875
|
*
|
|
4023
4876
|
* const app = document.createElement('div');
|
|
4024
|
-
*
|
|
4877
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4878
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
4025
4879
|
* console.log(relationships.getListenerStats().localRowIds);
|
|
4026
4880
|
* // -> 1
|
|
4027
4881
|
*
|
|
4028
4882
|
* store.setRow('pets', 'toto', {species: 'dog'}); // !act
|
|
4029
4883
|
* // -> 'Local Row Ids changed'
|
|
4030
4884
|
*
|
|
4031
|
-
*
|
|
4885
|
+
* root.unmount(); // !act
|
|
4032
4886
|
* console.log(relationships.getListenerStats().localRowIds);
|
|
4033
4887
|
* // -> 0
|
|
4034
4888
|
* ```
|
|
@@ -4105,7 +4959,8 @@ export function useLocalRowIdsListener(
|
|
|
4105
4959
|
* );
|
|
4106
4960
|
*
|
|
4107
4961
|
* const app = document.createElement('div');
|
|
4108
|
-
*
|
|
4962
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
4963
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
4109
4964
|
* console.log(relationships.getListenerStats().linkedRowIds);
|
|
4110
4965
|
* // -> 1
|
|
4111
4966
|
*
|
|
@@ -4113,7 +4968,7 @@ export function useLocalRowIdsListener(
|
|
|
4113
4968
|
* store.setCell('pets', 'cujo', 'next', 'toto'); // !act
|
|
4114
4969
|
* // -> 'Linked Row Ids changed'
|
|
4115
4970
|
*
|
|
4116
|
-
*
|
|
4971
|
+
* root.unmount(); // !act
|
|
4117
4972
|
* console.log(relationships.getListenerStats().linkedRowIds);
|
|
4118
4973
|
* // -> 0
|
|
4119
4974
|
* ```
|
|
@@ -4188,10 +5043,11 @@ export function useLinkedRowIdsListener(
|
|
|
4188
5043
|
* };
|
|
4189
5044
|
*
|
|
4190
5045
|
* const app = document.createElement('div');
|
|
4191
|
-
*
|
|
5046
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
5047
|
+
* root.render(<App />); // !act
|
|
4192
5048
|
* // -> 'Queries created'
|
|
4193
5049
|
*
|
|
4194
|
-
*
|
|
5050
|
+
* root.render(<App />); // !act
|
|
4195
5051
|
* // No second Queries creation
|
|
4196
5052
|
*
|
|
4197
5053
|
* console.log(app.innerHTML);
|
|
@@ -4229,10 +5085,11 @@ export function useLinkedRowIdsListener(
|
|
|
4229
5085
|
* };
|
|
4230
5086
|
*
|
|
4231
5087
|
* const app = document.createElement('div');
|
|
4232
|
-
*
|
|
5088
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
5089
|
+
* root.render(<App />); // !act
|
|
4233
5090
|
* // -> 'Queries created'
|
|
4234
5091
|
*
|
|
4235
|
-
*
|
|
5092
|
+
* root.render(<App />); // !act
|
|
4236
5093
|
* // No second Queries creation
|
|
4237
5094
|
*
|
|
4238
5095
|
* console.log(app.innerHTML);
|
|
@@ -4280,7 +5137,7 @@ export function useCreateQueries(
|
|
|
4280
5137
|
*
|
|
4281
5138
|
* const queries = createQueries(createStore());
|
|
4282
5139
|
* const app = document.createElement('div');
|
|
4283
|
-
*
|
|
5140
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4284
5141
|
* console.log(app.innerHTML);
|
|
4285
5142
|
* // -> '<span>0</span>'
|
|
4286
5143
|
* ```
|
|
@@ -4302,7 +5159,7 @@ export function useCreateQueries(
|
|
|
4302
5159
|
*
|
|
4303
5160
|
* const queries = createQueries(createStore());
|
|
4304
5161
|
* const app = document.createElement('div');
|
|
4305
|
-
*
|
|
5162
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4306
5163
|
* console.log(app.innerHTML);
|
|
4307
5164
|
* // -> '<span>0</span>'
|
|
4308
5165
|
* ```
|
|
@@ -4356,7 +5213,7 @@ export function useQueries(id?: Id): Queries | undefined;
|
|
|
4356
5213
|
* );
|
|
4357
5214
|
*
|
|
4358
5215
|
* const app = document.createElement('div');
|
|
4359
|
-
*
|
|
5216
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
4360
5217
|
* console.log(app.innerHTML);
|
|
4361
5218
|
* // -> '<span>{"fido":{"color":"brown"},"cujo":{"color":"black"}}</span>'
|
|
4362
5219
|
*
|
|
@@ -4389,7 +5246,7 @@ export function useQueries(id?: Id): Queries | undefined;
|
|
|
4389
5246
|
* where('species', 'dog');
|
|
4390
5247
|
* });
|
|
4391
5248
|
* const app = document.createElement('div');
|
|
4392
|
-
*
|
|
5249
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4393
5250
|
* console.log(app.innerHTML);
|
|
4394
5251
|
* // -> '<span>{"fido":{"color":"brown"},"cujo":{"color":"black"}}</span>'
|
|
4395
5252
|
* ```
|
|
@@ -4419,7 +5276,7 @@ export function useQueries(id?: Id): Queries | undefined;
|
|
|
4419
5276
|
* where('species', 'dog');
|
|
4420
5277
|
* });
|
|
4421
5278
|
* const app = document.createElement('div');
|
|
4422
|
-
*
|
|
5279
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4423
5280
|
* console.log(app.innerHTML);
|
|
4424
5281
|
* // -> '<span>{"fido":{"color":"brown"},"cujo":{"color":"black"}}</span>'
|
|
4425
5282
|
* ```
|
|
@@ -4450,8 +5307,8 @@ export function useResultTable(
|
|
|
4450
5307
|
* @param queryId The Id of the query.
|
|
4451
5308
|
* @param queriesOrQueriesId The Queries object to be accessed: omit for the
|
|
4452
5309
|
* default context Queries object, provide an Id for a named context Queries
|
|
4453
|
-
* object, or provide an explicit reference.
|
|
4454
|
-
*
|
|
5310
|
+
* object, or provide an explicit reference. See the addResultRowIdsListener
|
|
5311
|
+
* method for more details.
|
|
4455
5312
|
* @returns An array of the Ids of every Row in the result of the query.
|
|
4456
5313
|
* @example
|
|
4457
5314
|
* This example creates a Queries object outside the application, which is used
|
|
@@ -4477,7 +5334,7 @@ export function useResultTable(
|
|
|
4477
5334
|
* );
|
|
4478
5335
|
*
|
|
4479
5336
|
* const app = document.createElement('div');
|
|
4480
|
-
*
|
|
5337
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
4481
5338
|
* console.log(app.innerHTML);
|
|
4482
5339
|
* // -> '<span>["fido","cujo"]</span>'
|
|
4483
5340
|
*
|
|
@@ -4510,7 +5367,7 @@ export function useResultTable(
|
|
|
4510
5367
|
* where('species', 'dog');
|
|
4511
5368
|
* });
|
|
4512
5369
|
* const app = document.createElement('div');
|
|
4513
|
-
*
|
|
5370
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4514
5371
|
* console.log(app.innerHTML);
|
|
4515
5372
|
* // -> '<span>["fido","cujo"]</span>'
|
|
4516
5373
|
* ```
|
|
@@ -4540,7 +5397,7 @@ export function useResultTable(
|
|
|
4540
5397
|
* where('species', 'dog');
|
|
4541
5398
|
* });
|
|
4542
5399
|
* const app = document.createElement('div');
|
|
4543
|
-
*
|
|
5400
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4544
5401
|
* console.log(app.innerHTML);
|
|
4545
5402
|
* // -> '<span>["fido","cujo"]</span>'
|
|
4546
5403
|
* ```
|
|
@@ -4613,7 +5470,7 @@ export function useResultRowIds(
|
|
|
4613
5470
|
* );
|
|
4614
5471
|
*
|
|
4615
5472
|
* const app = document.createElement('div');
|
|
4616
|
-
*
|
|
5473
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
4617
5474
|
* console.log(app.innerHTML);
|
|
4618
5475
|
* // -> '<span>["cujo","fido"]</span>'
|
|
4619
5476
|
*
|
|
@@ -4648,7 +5505,7 @@ export function useResultRowIds(
|
|
|
4648
5505
|
* where('species', 'dog');
|
|
4649
5506
|
* });
|
|
4650
5507
|
* const app = document.createElement('div');
|
|
4651
|
-
*
|
|
5508
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4652
5509
|
* console.log(app.innerHTML);
|
|
4653
5510
|
* // -> '<span>["cujo","fido"]</span>'
|
|
4654
5511
|
* ```
|
|
@@ -4689,7 +5546,7 @@ export function useResultRowIds(
|
|
|
4689
5546
|
* where('species', 'dog');
|
|
4690
5547
|
* });
|
|
4691
5548
|
* const app = document.createElement('div');
|
|
4692
|
-
*
|
|
5549
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4693
5550
|
* console.log(app.innerHTML);
|
|
4694
5551
|
* // -> '<span>["cujo","fido"]</span>'
|
|
4695
5552
|
* ```
|
|
@@ -4706,7 +5563,7 @@ export function useResultSortedRowIds(
|
|
|
4706
5563
|
): Ids;
|
|
4707
5564
|
|
|
4708
5565
|
/**
|
|
4709
|
-
* The useResultRow hook returns an object containing the
|
|
5566
|
+
* The useResultRow hook returns an object containing the data of a
|
|
4710
5567
|
* single Row in the result Table of the given query, and registers a listener
|
|
4711
5568
|
* so that any changes to that Row will cause a re-render.
|
|
4712
5569
|
*
|
|
@@ -4752,7 +5609,7 @@ export function useResultSortedRowIds(
|
|
|
4752
5609
|
* );
|
|
4753
5610
|
*
|
|
4754
5611
|
* const app = document.createElement('div');
|
|
4755
|
-
*
|
|
5612
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
4756
5613
|
* console.log(app.innerHTML);
|
|
4757
5614
|
* // -> '<span>{"color":"brown"}</span>'
|
|
4758
5615
|
*
|
|
@@ -4785,7 +5642,7 @@ export function useResultSortedRowIds(
|
|
|
4785
5642
|
* where('species', 'dog');
|
|
4786
5643
|
* });
|
|
4787
5644
|
* const app = document.createElement('div');
|
|
4788
|
-
*
|
|
5645
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4789
5646
|
* console.log(app.innerHTML);
|
|
4790
5647
|
* // -> '<span>{"color":"brown"}</span>'
|
|
4791
5648
|
* ```
|
|
@@ -4817,7 +5674,7 @@ export function useResultSortedRowIds(
|
|
|
4817
5674
|
* where('species', 'dog');
|
|
4818
5675
|
* });
|
|
4819
5676
|
* const app = document.createElement('div');
|
|
4820
|
-
*
|
|
5677
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4821
5678
|
* console.log(app.innerHTML);
|
|
4822
5679
|
* // -> '<span>{"color":"brown"}</span>'
|
|
4823
5680
|
* ```
|
|
@@ -4881,7 +5738,7 @@ export function useResultRow(
|
|
|
4881
5738
|
* );
|
|
4882
5739
|
*
|
|
4883
5740
|
* const app = document.createElement('div');
|
|
4884
|
-
*
|
|
5741
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
4885
5742
|
* console.log(app.innerHTML);
|
|
4886
5743
|
* // -> '<span>["species","color"]</span>'
|
|
4887
5744
|
*
|
|
@@ -4915,7 +5772,7 @@ export function useResultRow(
|
|
|
4915
5772
|
* where('species', 'dog');
|
|
4916
5773
|
* });
|
|
4917
5774
|
* const app = document.createElement('div');
|
|
4918
|
-
*
|
|
5775
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4919
5776
|
* console.log(app.innerHTML);
|
|
4920
5777
|
* // -> '<span>["species","color"]</span>'
|
|
4921
5778
|
* ```
|
|
@@ -4948,7 +5805,7 @@ export function useResultRow(
|
|
|
4948
5805
|
* where('species', 'dog');
|
|
4949
5806
|
* });
|
|
4950
5807
|
* const app = document.createElement('div');
|
|
4951
|
-
*
|
|
5808
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
4952
5809
|
* console.log(app.innerHTML);
|
|
4953
5810
|
* // -> '<span>["species","color"]</span>'
|
|
4954
5811
|
* ```
|
|
@@ -5010,7 +5867,7 @@ export function useResultCellIds(
|
|
|
5010
5867
|
* );
|
|
5011
5868
|
*
|
|
5012
5869
|
* const app = document.createElement('div');
|
|
5013
|
-
*
|
|
5870
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
5014
5871
|
* console.log(app.innerHTML);
|
|
5015
5872
|
* // -> '<span>brown</span>'
|
|
5016
5873
|
*
|
|
@@ -5044,7 +5901,7 @@ export function useResultCellIds(
|
|
|
5044
5901
|
* where('species', 'dog');
|
|
5045
5902
|
* });
|
|
5046
5903
|
* const app = document.createElement('div');
|
|
5047
|
-
*
|
|
5904
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
5048
5905
|
* console.log(app.innerHTML);
|
|
5049
5906
|
* // -> '<span>brown</span>'
|
|
5050
5907
|
* ```
|
|
@@ -5075,7 +5932,7 @@ export function useResultCellIds(
|
|
|
5075
5932
|
* where('species', 'dog');
|
|
5076
5933
|
* });
|
|
5077
5934
|
* const app = document.createElement('div');
|
|
5078
|
-
*
|
|
5935
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
5079
5936
|
* console.log(app.innerHTML);
|
|
5080
5937
|
* // -> '<span>brown</span>'
|
|
5081
5938
|
* ```
|
|
@@ -5145,14 +6002,15 @@ export function useResultCell(
|
|
|
5145
6002
|
* ({select}) => select('color'),
|
|
5146
6003
|
* );
|
|
5147
6004
|
* const app = document.createElement('div');
|
|
5148
|
-
*
|
|
6005
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6006
|
+
* root.render(<App queries={queries} />); // !act
|
|
5149
6007
|
* console.log(queries.getListenerStats().table);
|
|
5150
6008
|
* // -> 1
|
|
5151
6009
|
*
|
|
5152
6010
|
* store.setCell('pets', 'fido', 'color', 'walnut'); // !act
|
|
5153
6011
|
* // -> 'Result table changed'
|
|
5154
6012
|
*
|
|
5155
|
-
*
|
|
6013
|
+
* root.unmount(); // !act
|
|
5156
6014
|
* console.log(queries.getListenerStats().table);
|
|
5157
6015
|
* // -> 0
|
|
5158
6016
|
* ```
|
|
@@ -5222,14 +6080,15 @@ export function useResultTableListener(
|
|
|
5222
6080
|
* ({select}) => select('color'),
|
|
5223
6081
|
* );
|
|
5224
6082
|
* const app = document.createElement('div');
|
|
5225
|
-
*
|
|
6083
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6084
|
+
* root.render(<App queries={queries} />); // !act
|
|
5226
6085
|
* console.log(queries.getListenerStats().rowIds);
|
|
5227
6086
|
* // -> 1
|
|
5228
6087
|
*
|
|
5229
6088
|
* store.setRow('pets', 'rex', {species: 'dog', color: 'tan'}); // !act
|
|
5230
6089
|
* // -> 'Result Row Ids changed'
|
|
5231
6090
|
*
|
|
5232
|
-
*
|
|
6091
|
+
* root.unmount(); // !act
|
|
5233
6092
|
* console.log(queries.getListenerStats().rowIds);
|
|
5234
6093
|
* // -> 0
|
|
5235
6094
|
* ```
|
|
@@ -5306,14 +6165,15 @@ export function useResultRowIdsListener(
|
|
|
5306
6165
|
* ({select}) => select('color'),
|
|
5307
6166
|
* );
|
|
5308
6167
|
* const app = document.createElement('div');
|
|
5309
|
-
*
|
|
6168
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6169
|
+
* root.render(<App queries={queries} />); // !act
|
|
5310
6170
|
* console.log(queries.getListenerStats().sortedRowIds);
|
|
5311
6171
|
* // -> 1
|
|
5312
6172
|
*
|
|
5313
6173
|
* store.setRow('pets', 'cujo', {color: 'tan'}); // !act
|
|
5314
6174
|
* // -> 'Sorted result Row Ids changed'
|
|
5315
6175
|
*
|
|
5316
|
-
*
|
|
6176
|
+
* root.unmount(); // !act
|
|
5317
6177
|
* console.log(queries.getListenerStats().sortedRowIds);
|
|
5318
6178
|
* // -> 0
|
|
5319
6179
|
* ```
|
|
@@ -5393,14 +6253,15 @@ export function useResultSortedRowIdsListener(
|
|
|
5393
6253
|
* ({select}) => select('color'),
|
|
5394
6254
|
* );
|
|
5395
6255
|
* const app = document.createElement('div');
|
|
5396
|
-
*
|
|
6256
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6257
|
+
* root.render(<App queries={queries} />); // !act
|
|
5397
6258
|
* console.log(queries.getListenerStats().row);
|
|
5398
6259
|
* // -> 1
|
|
5399
6260
|
*
|
|
5400
6261
|
* store.setCell('pets', 'fido', 'color', 'walnut'); // !act
|
|
5401
6262
|
* // -> 'Result row changed'
|
|
5402
6263
|
*
|
|
5403
|
-
*
|
|
6264
|
+
* root.unmount(); // !act
|
|
5404
6265
|
* console.log(queries.getListenerStats().row);
|
|
5405
6266
|
* // -> 0
|
|
5406
6267
|
* ```
|
|
@@ -5477,14 +6338,15 @@ export function useResultRowListener(
|
|
|
5477
6338
|
* },
|
|
5478
6339
|
* );
|
|
5479
6340
|
* const app = document.createElement('div');
|
|
5480
|
-
*
|
|
6341
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6342
|
+
* root.render(<App queries={queries} />); // !act
|
|
5481
6343
|
* console.log(queries.getListenerStats().cellIds);
|
|
5482
6344
|
* // -> 1
|
|
5483
6345
|
*
|
|
5484
6346
|
* store.setCell('pets', 'fido', 'legs', 4); // !act
|
|
5485
6347
|
* // -> 'Result cell Ids changed'
|
|
5486
6348
|
*
|
|
5487
|
-
*
|
|
6349
|
+
* root.unmount(); // !act
|
|
5488
6350
|
* console.log(queries.getListenerStats().cellIds);
|
|
5489
6351
|
* // -> 0
|
|
5490
6352
|
* ```
|
|
@@ -5563,14 +6425,15 @@ export function useResultCellIdsListener(
|
|
|
5563
6425
|
* ({select}) => select('color'),
|
|
5564
6426
|
* );
|
|
5565
6427
|
* const app = document.createElement('div');
|
|
5566
|
-
*
|
|
6428
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6429
|
+
* root.render(<App queries={queries} />); // !act
|
|
5567
6430
|
* console.log(queries.getListenerStats().cell);
|
|
5568
6431
|
* // -> 1
|
|
5569
6432
|
*
|
|
5570
6433
|
* store.setCell('pets', 'fido', 'color', 'walnut'); // !act
|
|
5571
6434
|
* // -> 'Result cell changed'
|
|
5572
6435
|
*
|
|
5573
|
-
*
|
|
6436
|
+
* root.unmount(); // !act
|
|
5574
6437
|
* console.log(queries.getListenerStats().cell);
|
|
5575
6438
|
* // -> 0
|
|
5576
6439
|
* ```
|
|
@@ -5634,10 +6497,11 @@ export function useResultCellListener(
|
|
|
5634
6497
|
* };
|
|
5635
6498
|
*
|
|
5636
6499
|
* const app = document.createElement('div');
|
|
5637
|
-
*
|
|
6500
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6501
|
+
* root.render(<App />); // !act
|
|
5638
6502
|
* // -> 'Checkpoints created'
|
|
5639
6503
|
*
|
|
5640
|
-
*
|
|
6504
|
+
* root.render(<App />); // !act
|
|
5641
6505
|
* // No second Checkpoints creation
|
|
5642
6506
|
*
|
|
5643
6507
|
* console.log(app.innerHTML);
|
|
@@ -5665,13 +6529,14 @@ export function useResultCellListener(
|
|
|
5665
6529
|
* };
|
|
5666
6530
|
*
|
|
5667
6531
|
* const app = document.createElement('div');
|
|
5668
|
-
*
|
|
6532
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6533
|
+
* root.render(<App size={20} />); // !act
|
|
5669
6534
|
* // -> 'Checkpoints created, size 20'
|
|
5670
6535
|
*
|
|
5671
6536
|
* console.log(app.innerHTML);
|
|
5672
6537
|
* // -> '<span>[[],"0",[]]</span>'
|
|
5673
6538
|
*
|
|
5674
|
-
*
|
|
6539
|
+
* root.render(<App size={50} />); // !act
|
|
5675
6540
|
* // -> 'Checkpoints created, size 50'
|
|
5676
6541
|
*
|
|
5677
6542
|
* console.log(app.innerHTML);
|
|
@@ -5720,7 +6585,8 @@ export function useCreateCheckpoints(
|
|
|
5720
6585
|
*
|
|
5721
6586
|
* const checkpoints = createCheckpoints(createStore());
|
|
5722
6587
|
* const app = document.createElement('div');
|
|
5723
|
-
*
|
|
6588
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6589
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
5724
6590
|
* console.log(app.innerHTML);
|
|
5725
6591
|
* // -> '<span>0</span>'
|
|
5726
6592
|
* ```
|
|
@@ -5744,7 +6610,8 @@ export function useCreateCheckpoints(
|
|
|
5744
6610
|
*
|
|
5745
6611
|
* const checkpoints = createCheckpoints(createStore());
|
|
5746
6612
|
* const app = document.createElement('div');
|
|
5747
|
-
*
|
|
6613
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6614
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
5748
6615
|
* console.log(app.innerHTML);
|
|
5749
6616
|
* // -> '<span>0</span>'
|
|
5750
6617
|
* ```
|
|
@@ -5787,7 +6654,7 @@ export function useCheckpoints(id?: Id): Checkpoints | undefined;
|
|
|
5787
6654
|
* );
|
|
5788
6655
|
*
|
|
5789
6656
|
* const app = document.createElement('div');
|
|
5790
|
-
*
|
|
6657
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
5791
6658
|
* console.log(app.innerHTML);
|
|
5792
6659
|
* // -> '<span>[[],"0",[]]</span>'
|
|
5793
6660
|
*
|
|
@@ -5817,7 +6684,8 @@ export function useCheckpoints(id?: Id): Checkpoints | undefined;
|
|
|
5817
6684
|
* );
|
|
5818
6685
|
*
|
|
5819
6686
|
* const app = document.createElement('div');
|
|
5820
|
-
*
|
|
6687
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6688
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
5821
6689
|
* console.log(app.innerHTML);
|
|
5822
6690
|
* // -> '<span>[[],"0",[]]</span>'
|
|
5823
6691
|
* ```
|
|
@@ -5841,7 +6709,8 @@ export function useCheckpoints(id?: Id): Checkpoints | undefined;
|
|
|
5841
6709
|
* );
|
|
5842
6710
|
*
|
|
5843
6711
|
* const app = document.createElement('div');
|
|
5844
|
-
*
|
|
6712
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6713
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
5845
6714
|
* console.log(app.innerHTML);
|
|
5846
6715
|
* // -> '<span>[[],"0",[]]</span>'
|
|
5847
6716
|
* ```
|
|
@@ -5883,7 +6752,7 @@ export function useCheckpointIds(
|
|
|
5883
6752
|
* const App = () => <span>{useCheckpoint('1', checkpoints)}</span>;
|
|
5884
6753
|
*
|
|
5885
6754
|
* const app = document.createElement('div');
|
|
5886
|
-
*
|
|
6755
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
5887
6756
|
* console.log(app.innerHTML);
|
|
5888
6757
|
* // -> '<span></span>'
|
|
5889
6758
|
*
|
|
@@ -5910,7 +6779,8 @@ export function useCheckpointIds(
|
|
|
5910
6779
|
* ).setCheckpoint('0', 'initial');
|
|
5911
6780
|
*
|
|
5912
6781
|
* const app = document.createElement('div');
|
|
5913
|
-
*
|
|
6782
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6783
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
5914
6784
|
* console.log(app.innerHTML);
|
|
5915
6785
|
* // -> '<span>initial</span>'
|
|
5916
6786
|
* ```
|
|
@@ -5932,7 +6802,8 @@ export function useCheckpointIds(
|
|
|
5932
6802
|
* ).setCheckpoint('0', 'initial');
|
|
5933
6803
|
*
|
|
5934
6804
|
* const app = document.createElement('div');
|
|
5935
|
-
*
|
|
6805
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
6806
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
5936
6807
|
* console.log(app.innerHTML);
|
|
5937
6808
|
* // -> '<span>initial</span>'
|
|
5938
6809
|
* ```
|
|
@@ -6007,7 +6878,7 @@ export function useCheckpoint(
|
|
|
6007
6878
|
* };
|
|
6008
6879
|
*
|
|
6009
6880
|
* const app = document.createElement('div');
|
|
6010
|
-
*
|
|
6881
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
6011
6882
|
* const span = app.querySelector('span');
|
|
6012
6883
|
*
|
|
6013
6884
|
* store.setCell('pets', 'nemo', 'color', 'orange');
|
|
@@ -6055,7 +6926,7 @@ export function useSetCheckpointCallback<Parameter>(
|
|
|
6055
6926
|
* );
|
|
6056
6927
|
*
|
|
6057
6928
|
* const app = document.createElement('div');
|
|
6058
|
-
*
|
|
6929
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
6059
6930
|
* const span = app.querySelector('span');
|
|
6060
6931
|
*
|
|
6061
6932
|
* store.setCell('pets', 'nemo', 'color', 'orange');
|
|
@@ -6103,7 +6974,7 @@ export function useGoBackwardCallback(
|
|
|
6103
6974
|
* );
|
|
6104
6975
|
*
|
|
6105
6976
|
* const app = document.createElement('div');
|
|
6106
|
-
*
|
|
6977
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
6107
6978
|
* const span = app.querySelector('span');
|
|
6108
6979
|
*
|
|
6109
6980
|
* store.setCell('pets', 'nemo', 'color', 'orange');
|
|
@@ -6183,7 +7054,7 @@ export function useGoForwardCallback(
|
|
|
6183
7054
|
* };
|
|
6184
7055
|
*
|
|
6185
7056
|
* const app = document.createElement('div');
|
|
6186
|
-
*
|
|
7057
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
6187
7058
|
* const span = app.querySelector('span');
|
|
6188
7059
|
*
|
|
6189
7060
|
* store.setCell('pets', 'nemo', 'color', 'orange');
|
|
@@ -6237,7 +7108,7 @@ export function useGoToCallback<Parameter>(
|
|
|
6237
7108
|
* };
|
|
6238
7109
|
*
|
|
6239
7110
|
* const app = document.createElement('div');
|
|
6240
|
-
*
|
|
7111
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
6241
7112
|
* console.log(app.innerHTML);
|
|
6242
7113
|
* // -> '<span>Nothing to undo</span>'
|
|
6243
7114
|
*
|
|
@@ -6283,7 +7154,7 @@ export function useUndoInformation(
|
|
|
6283
7154
|
* };
|
|
6284
7155
|
*
|
|
6285
7156
|
* const app = document.createElement('div');
|
|
6286
|
-
*
|
|
7157
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
6287
7158
|
* console.log(app.innerHTML);
|
|
6288
7159
|
* // -> '<span>Nothing to redo</span>'
|
|
6289
7160
|
*
|
|
@@ -6342,7 +7213,8 @@ export function useRedoInformation(
|
|
|
6342
7213
|
* const checkpoints = createCheckpoints(store);
|
|
6343
7214
|
*
|
|
6344
7215
|
* const app = document.createElement('div');
|
|
6345
|
-
*
|
|
7216
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
7217
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
6346
7218
|
* console.log(checkpoints.getListenerStats().checkpointIds);
|
|
6347
7219
|
* // -> 1
|
|
6348
7220
|
*
|
|
@@ -6351,7 +7223,7 @@ export function useRedoInformation(
|
|
|
6351
7223
|
* checkpoints.addCheckpoint(); // !act
|
|
6352
7224
|
* // -> 'Checkpoint Ids changed'
|
|
6353
7225
|
*
|
|
6354
|
-
*
|
|
7226
|
+
* root.unmount(); // !act
|
|
6355
7227
|
* console.log(checkpoints.getListenerStats().checkpointIds);
|
|
6356
7228
|
* // -> 0
|
|
6357
7229
|
* ```
|
|
@@ -6414,14 +7286,15 @@ export function useCheckpointIdsListener(
|
|
|
6414
7286
|
* const checkpoints = createCheckpoints(store);
|
|
6415
7287
|
*
|
|
6416
7288
|
* const app = document.createElement('div');
|
|
6417
|
-
*
|
|
7289
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
7290
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
6418
7291
|
* console.log(checkpoints.getListenerStats().checkpoint);
|
|
6419
7292
|
* // -> 1
|
|
6420
7293
|
*
|
|
6421
7294
|
* checkpoints.setCheckpoint('0', 'initial'); // !act
|
|
6422
7295
|
* // -> 'Checkpoint label changed'
|
|
6423
7296
|
*
|
|
6424
|
-
*
|
|
7297
|
+
* root.unmount(); // !act
|
|
6425
7298
|
* console.log(checkpoints.getListenerStats().checkpoint);
|
|
6426
7299
|
* // -> 0
|
|
6427
7300
|
* ```
|
|
@@ -6502,17 +7375,18 @@ export function useCheckpointListener(
|
|
|
6502
7375
|
* sessionStorage.setItem('pets', '{"pets":{"fido":{"species":"dog"}}}');
|
|
6503
7376
|
*
|
|
6504
7377
|
* const app = document.createElement('div');
|
|
6505
|
-
*
|
|
7378
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
7379
|
+
* root.render(<App />); // !act
|
|
6506
7380
|
* // -> 'Persister created'
|
|
6507
7381
|
*
|
|
6508
7382
|
* // ... // !act
|
|
6509
|
-
*
|
|
7383
|
+
* root.render(<App />); // !act
|
|
6510
7384
|
* // No second Persister creation
|
|
6511
7385
|
*
|
|
6512
7386
|
* console.log(app.innerHTML);
|
|
6513
7387
|
* // -> '<span>{\"pets\":{\"fido\":{\"species\":\"dog\"}}}</span>'
|
|
6514
7388
|
*
|
|
6515
|
-
*
|
|
7389
|
+
* root.unmount(); // !act
|
|
6516
7390
|
* ```
|
|
6517
7391
|
* @example
|
|
6518
7392
|
* This example creates a Persister at the top level of a React application. The
|
|
@@ -6542,21 +7416,22 @@ export function useCheckpointListener(
|
|
|
6542
7416
|
* sessionStorage.setItem('cujoStore', '{"pets":{"cujo":{"species":"dog"}}}');
|
|
6543
7417
|
*
|
|
6544
7418
|
* const app = document.createElement('div');
|
|
6545
|
-
*
|
|
7419
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
7420
|
+
* root.render(<App sessionKey="fidoStore" />); // !act
|
|
6546
7421
|
* // -> 'Persister created for session key fidoStore'
|
|
6547
7422
|
*
|
|
6548
7423
|
* // ... // !act
|
|
6549
7424
|
* console.log(app.innerHTML);
|
|
6550
7425
|
* // -> '<span>{\"pets\":{\"fido\":{\"species\":\"dog\"}}}</span>'
|
|
6551
7426
|
*
|
|
6552
|
-
*
|
|
7427
|
+
* root.render(<App sessionKey="cujoStore" />); // !act
|
|
6553
7428
|
* // -> 'Persister created for session key cujoStore'
|
|
6554
7429
|
*
|
|
6555
7430
|
* // ... // !act
|
|
6556
7431
|
* console.log(app.innerHTML);
|
|
6557
7432
|
* // -> '<span>{\"pets\":{\"cujo\":{\"species\":\"dog\"}}}</span>'
|
|
6558
7433
|
*
|
|
6559
|
-
*
|
|
7434
|
+
* root.unmount(); // !act
|
|
6560
7435
|
* ```
|
|
6561
7436
|
* @category Persister hooks
|
|
6562
7437
|
*/
|
|
@@ -6602,7 +7477,7 @@ export type TablesProps = {
|
|
|
6602
7477
|
*/
|
|
6603
7478
|
readonly separator?: ReactElement | string;
|
|
6604
7479
|
/**
|
|
6605
|
-
* Whether the component should also render the Ids of
|
|
7480
|
+
* Whether the component should also render the Ids of each Table, and its
|
|
6606
7481
|
* descendent objects, to assist with debugging.
|
|
6607
7482
|
*/
|
|
6608
7483
|
readonly debugIds?: boolean;
|
|
@@ -6742,7 +7617,7 @@ export type RowProps = {
|
|
|
6742
7617
|
};
|
|
6743
7618
|
|
|
6744
7619
|
/**
|
|
6745
|
-
*
|
|
7620
|
+
* CellProps props are used for components that refer to a single Cell in a Row,
|
|
6746
7621
|
* such as the CellView component.
|
|
6747
7622
|
*
|
|
6748
7623
|
* @category Props
|
|
@@ -6772,6 +7647,64 @@ export type CellProps = {
|
|
|
6772
7647
|
readonly debugIds?: boolean;
|
|
6773
7648
|
};
|
|
6774
7649
|
|
|
7650
|
+
/**
|
|
7651
|
+
* ValuesProps props are used for components that refer to all the Values in a
|
|
7652
|
+
* Store, such as the ValuesView component.
|
|
7653
|
+
*
|
|
7654
|
+
* @category Props
|
|
7655
|
+
* @since v3.0.0
|
|
7656
|
+
*/
|
|
7657
|
+
export type ValuesProps = {
|
|
7658
|
+
/**
|
|
7659
|
+
* The Store to be accessed: omit for the default context Store, provide an Id
|
|
7660
|
+
* for a named context Store, or provide an explicit reference.
|
|
7661
|
+
*/
|
|
7662
|
+
readonly store?: StoreOrStoreId;
|
|
7663
|
+
/**
|
|
7664
|
+
* A custom component for rendering each Value in the Store (to override the
|
|
7665
|
+
* default ValueView component).
|
|
7666
|
+
*/
|
|
7667
|
+
readonly valueComponent?: ComponentType<ValueProps>;
|
|
7668
|
+
/**
|
|
7669
|
+
* A function for generating extra props for each custom Value component based
|
|
7670
|
+
* on its Id.
|
|
7671
|
+
*/
|
|
7672
|
+
readonly getValueComponentProps?: (valueId: Id) => ExtraProps;
|
|
7673
|
+
/**
|
|
7674
|
+
* A component or string to separate each Value component.
|
|
7675
|
+
*/
|
|
7676
|
+
readonly separator?: ReactElement | string;
|
|
7677
|
+
/**
|
|
7678
|
+
* Whether the component should also render the Ids of each Value to assist
|
|
7679
|
+
* with debugging.
|
|
7680
|
+
*/
|
|
7681
|
+
readonly debugIds?: boolean;
|
|
7682
|
+
};
|
|
7683
|
+
|
|
7684
|
+
/**
|
|
7685
|
+
* ValueProps props are used for components that refer to a single Value in a
|
|
7686
|
+
* Row, such as the ValueView component.
|
|
7687
|
+
*
|
|
7688
|
+
* @category Props
|
|
7689
|
+
* @since v3.0.0
|
|
7690
|
+
*/
|
|
7691
|
+
export type ValueProps = {
|
|
7692
|
+
/**
|
|
7693
|
+
* The Id of the Value in the Row to be rendered.
|
|
7694
|
+
*/
|
|
7695
|
+
readonly valueId: Id;
|
|
7696
|
+
/**
|
|
7697
|
+
* The Store to be accessed: omit for the default context Store, provide an Id
|
|
7698
|
+
* for a named context Store, or provide an explicit reference.
|
|
7699
|
+
*/
|
|
7700
|
+
readonly store?: StoreOrStoreId;
|
|
7701
|
+
/**
|
|
7702
|
+
* Whether the component should also render the Id of the Value to assist with
|
|
7703
|
+
* debugging.
|
|
7704
|
+
*/
|
|
7705
|
+
readonly debugIds?: boolean;
|
|
7706
|
+
};
|
|
7707
|
+
|
|
6775
7708
|
/**
|
|
6776
7709
|
* MetricProps props are used for components that refer to a single Metric in a
|
|
6777
7710
|
* Metrics object, such as the MetricView component.
|
|
@@ -6876,8 +7809,8 @@ export type SliceProps = {
|
|
|
6876
7809
|
|
|
6877
7810
|
/**
|
|
6878
7811
|
* RemoteRowProps props are used for components that refer to a single
|
|
6879
|
-
* Relationship in a Relationships object, and where you want to render a
|
|
6880
|
-
*
|
|
7812
|
+
* Relationship in a Relationships object, and where you want to render a remote
|
|
7813
|
+
* Row based on a local Row, such as in the RemoteRowView component.
|
|
6881
7814
|
*
|
|
6882
7815
|
* @category Props
|
|
6883
7816
|
*/
|
|
@@ -6958,9 +7891,8 @@ export type LocalRowsProps = {
|
|
|
6958
7891
|
|
|
6959
7892
|
/**
|
|
6960
7893
|
* LinkedRowsProps props are used for components that refer to a single
|
|
6961
|
-
* Relationship in a Relationships object, and where you want to render a
|
|
6962
|
-
*
|
|
6963
|
-
* component.
|
|
7894
|
+
* Relationship in a Relationships object, and where you want to render a linked
|
|
7895
|
+
* list of Rows starting from a first Row, such as the LinkedRowsView component.
|
|
6964
7896
|
*
|
|
6965
7897
|
* @category Props
|
|
6966
7898
|
*/
|
|
@@ -7424,7 +8356,8 @@ export type ComponentReturnType = ReactElement<any, any> | null;
|
|
|
7424
8356
|
* metrics.setMetricDefinition('highestPrice', 'species', 'max', 'price');
|
|
7425
8357
|
*
|
|
7426
8358
|
* const app = document.createElement('div');
|
|
7427
|
-
*
|
|
8359
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
8360
|
+
* root.render(<App store={store} metrics={metrics} />); // !act
|
|
7428
8361
|
* console.log(app.innerHTML);
|
|
7429
8362
|
* // -> '<span>5,4,5</span>'
|
|
7430
8363
|
* ```
|
|
@@ -7467,7 +8400,8 @@ export type ComponentReturnType = ReactElement<any, any> | null;
|
|
|
7467
8400
|
* metrics.setMetricDefinition('highestPrice', 'species', 'max', 'price');
|
|
7468
8401
|
*
|
|
7469
8402
|
* const app = document.createElement('div');
|
|
7470
|
-
*
|
|
8403
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
8404
|
+
* root.render(<App petStore={petStore} metrics={metrics} />); // !act
|
|
7471
8405
|
* console.log(app.innerHTML);
|
|
7472
8406
|
* // -> '<span>5,5,2</span>'
|
|
7473
8407
|
* ```
|
|
@@ -7510,7 +8444,7 @@ export function Provider(
|
|
|
7510
8444
|
* );
|
|
7511
8445
|
*
|
|
7512
8446
|
* const app = document.createElement('div');
|
|
7513
|
-
*
|
|
8447
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
7514
8448
|
* console.log(app.innerHTML);
|
|
7515
8449
|
* // -> '<span>brown</span>'
|
|
7516
8450
|
*
|
|
@@ -7537,7 +8471,7 @@ export function Provider(
|
|
|
7537
8471
|
*
|
|
7538
8472
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
7539
8473
|
* const app = document.createElement('div');
|
|
7540
|
-
*
|
|
8474
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
7541
8475
|
* console.log(app.innerHTML);
|
|
7542
8476
|
* // -> '<span>color:{brown}</span>'
|
|
7543
8477
|
* ```
|
|
@@ -7560,7 +8494,7 @@ export function Provider(
|
|
|
7560
8494
|
*
|
|
7561
8495
|
* const store = createStore().setCell('pets', 'fido', 'color', 'brown');
|
|
7562
8496
|
* const app = document.createElement('div');
|
|
7563
|
-
*
|
|
8497
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
7564
8498
|
* console.log(app.innerHTML);
|
|
7565
8499
|
* // -> '<span></span>'
|
|
7566
8500
|
* ```
|
|
@@ -7606,7 +8540,7 @@ export function CellView(props: CellProps): ComponentReturnType;
|
|
|
7606
8540
|
* );
|
|
7607
8541
|
*
|
|
7608
8542
|
* const app = document.createElement('div');
|
|
7609
|
-
*
|
|
8543
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
7610
8544
|
* console.log(app.innerHTML);
|
|
7611
8545
|
* // -> '<div>dog</div>'
|
|
7612
8546
|
*
|
|
@@ -7636,7 +8570,7 @@ export function CellView(props: CellProps): ComponentReturnType;
|
|
|
7636
8570
|
* color: 'walnut',
|
|
7637
8571
|
* });
|
|
7638
8572
|
* const app = document.createElement('div');
|
|
7639
|
-
*
|
|
8573
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
7640
8574
|
* console.log(app.innerHTML);
|
|
7641
8575
|
* // -> '<div>fido:{species:{dog}color:{walnut}}</div>'
|
|
7642
8576
|
* ```
|
|
@@ -7674,7 +8608,7 @@ export function CellView(props: CellProps): ComponentReturnType;
|
|
|
7674
8608
|
* color: 'walnut',
|
|
7675
8609
|
* });
|
|
7676
8610
|
* const app = document.createElement('div');
|
|
7677
|
-
*
|
|
8611
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
7678
8612
|
* console.log(app.innerHTML);
|
|
7679
8613
|
* // -> '<div><span><b>species</b>: dog</span><span>color: walnut</span></div>'
|
|
7680
8614
|
* ```
|
|
@@ -7731,7 +8665,7 @@ export function RowView(props: RowProps): ComponentReturnType;
|
|
|
7731
8665
|
* );
|
|
7732
8666
|
*
|
|
7733
8667
|
* const app = document.createElement('div');
|
|
7734
|
-
*
|
|
8668
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
7735
8669
|
* console.log(app.innerHTML);
|
|
7736
8670
|
* // -> '<div>cat/dog</div>'
|
|
7737
8671
|
*
|
|
@@ -7763,7 +8697,7 @@ export function RowView(props: RowProps): ComponentReturnType;
|
|
|
7763
8697
|
* },
|
|
7764
8698
|
* });
|
|
7765
8699
|
* const app = document.createElement('div');
|
|
7766
|
-
*
|
|
8700
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
7767
8701
|
* console.log(app.innerHTML);
|
|
7768
8702
|
* // -> '<div>pets:{felix:{species:{cat}}fido:{species:{dog}}}</div>'
|
|
7769
8703
|
* ```
|
|
@@ -7803,7 +8737,7 @@ export function RowView(props: RowProps): ComponentReturnType;
|
|
|
7803
8737
|
* },
|
|
7804
8738
|
* });
|
|
7805
8739
|
* const app = document.createElement('div');
|
|
7806
|
-
*
|
|
8740
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
7807
8741
|
* console.log(app.innerHTML);
|
|
7808
8742
|
* // -> '<div><span>felix: cat</span><span><b>fido</b>: dog</span></div>'
|
|
7809
8743
|
* ```
|
|
@@ -7849,7 +8783,7 @@ export function SortedTableView(props: SortedTableProps): ComponentReturnType;
|
|
|
7849
8783
|
* );
|
|
7850
8784
|
*
|
|
7851
8785
|
* const app = document.createElement('div');
|
|
7852
|
-
*
|
|
8786
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
7853
8787
|
* console.log(app.innerHTML);
|
|
7854
8788
|
* // -> '<div>dog</div>'
|
|
7855
8789
|
*
|
|
@@ -7879,7 +8813,7 @@ export function SortedTableView(props: SortedTableProps): ComponentReturnType;
|
|
|
7879
8813
|
* felix: {species: 'cat'},
|
|
7880
8814
|
* });
|
|
7881
8815
|
* const app = document.createElement('div');
|
|
7882
|
-
*
|
|
8816
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
7883
8817
|
* console.log(app.innerHTML);
|
|
7884
8818
|
* // -> '<div>pets:{fido:{species:{dog}}felix:{species:{cat}}}</div>'
|
|
7885
8819
|
* ```
|
|
@@ -7916,7 +8850,7 @@ export function SortedTableView(props: SortedTableProps): ComponentReturnType;
|
|
|
7916
8850
|
* felix: {species: 'cat'},
|
|
7917
8851
|
* });
|
|
7918
8852
|
* const app = document.createElement('div');
|
|
7919
|
-
*
|
|
8853
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
7920
8854
|
* console.log(app.innerHTML);
|
|
7921
8855
|
* // -> '<div><span><b>fido</b>: dog</span><span>felix: cat</span></div>'
|
|
7922
8856
|
* ```
|
|
@@ -7925,8 +8859,9 @@ export function SortedTableView(props: SortedTableProps): ComponentReturnType;
|
|
|
7925
8859
|
export function TableView(props: TableProps): ComponentReturnType;
|
|
7926
8860
|
|
|
7927
8861
|
/**
|
|
7928
|
-
* The TablesView component renders the contents of a Store, and
|
|
7929
|
-
* listener so that any changes to that result will cause a
|
|
8862
|
+
* The TablesView component renders the tabular contents of a Store, and
|
|
8863
|
+
* registers a listener so that any changes to that result will cause a
|
|
8864
|
+
* re-render.
|
|
7930
8865
|
*
|
|
7931
8866
|
* The component's props can identify which Store to render - either the default
|
|
7932
8867
|
* context Store, a named context Store, or an explicit reference.
|
|
@@ -7952,18 +8887,18 @@ export function TableView(props: TableProps): ComponentReturnType;
|
|
|
7952
8887
|
* const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
|
|
7953
8888
|
* const App = () => (
|
|
7954
8889
|
* <div>
|
|
7955
|
-
* <TablesView store={store} />
|
|
8890
|
+
* <TablesView store={store} separator="/" />
|
|
7956
8891
|
* </div>
|
|
7957
8892
|
* );
|
|
7958
8893
|
*
|
|
7959
8894
|
* const app = document.createElement('div');
|
|
7960
|
-
*
|
|
8895
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
7961
8896
|
* console.log(app.innerHTML);
|
|
7962
8897
|
* // -> '<div>dog</div>'
|
|
7963
8898
|
*
|
|
7964
8899
|
* store.setTable('species', {dog: {price: 5}}); // !act
|
|
7965
8900
|
* console.log(app.innerHTML);
|
|
7966
|
-
* // -> '<div>
|
|
8901
|
+
* // -> '<div>dog/5</div>'
|
|
7967
8902
|
* ```
|
|
7968
8903
|
* @example
|
|
7969
8904
|
* This example creates a Provider context into which a default Store is
|
|
@@ -7978,7 +8913,7 @@ export function TableView(props: TableProps): ComponentReturnType;
|
|
|
7978
8913
|
* );
|
|
7979
8914
|
* const Pane = () => (
|
|
7980
8915
|
* <div>
|
|
7981
|
-
* <TablesView
|
|
8916
|
+
* <TablesView debugIds={true} />
|
|
7982
8917
|
* </div>
|
|
7983
8918
|
* );
|
|
7984
8919
|
*
|
|
@@ -7987,7 +8922,7 @@ export function TableView(props: TableProps): ComponentReturnType;
|
|
|
7987
8922
|
* species: {dog: {price: 5}},
|
|
7988
8923
|
* });
|
|
7989
8924
|
* const app = document.createElement('div');
|
|
7990
|
-
*
|
|
8925
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
7991
8926
|
* console.log(app.innerHTML);
|
|
7992
8927
|
* // -> '<div>pets:{fido:{species:{dog}}}species:{dog:{price:{5}}}</div>'
|
|
7993
8928
|
* ```
|
|
@@ -8023,7 +8958,7 @@ export function TableView(props: TableProps): ComponentReturnType;
|
|
|
8023
8958
|
* species: {dog: {price: 5}},
|
|
8024
8959
|
* });
|
|
8025
8960
|
* const app = document.createElement('div');
|
|
8026
|
-
*
|
|
8961
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
8027
8962
|
* console.log(app.innerHTML);
|
|
8028
8963
|
* // -> '<div><span><b>pets</b>: dog</span><span>species: 5</span></div>'
|
|
8029
8964
|
* ```
|
|
@@ -8031,6 +8966,203 @@ export function TableView(props: TableProps): ComponentReturnType;
|
|
|
8031
8966
|
*/
|
|
8032
8967
|
export function TablesView(props: TablesProps): ComponentReturnType;
|
|
8033
8968
|
|
|
8969
|
+
/**
|
|
8970
|
+
* The ValueView component renders the value of a single Value, and registers a
|
|
8971
|
+
* listener so that any changes to that result will cause a re-render.
|
|
8972
|
+
*
|
|
8973
|
+
* The component's props identify which Value to render based on Value Id and
|
|
8974
|
+
* Store (which is either the default context Store, a named context Store, or
|
|
8975
|
+
* an explicit reference).
|
|
8976
|
+
*
|
|
8977
|
+
* A Value contains a string, number, or boolean, so the value is rendered
|
|
8978
|
+
* directly without further decoration. You can create your own ValueView-like
|
|
8979
|
+
* component to customize the way that a Value is rendered: see the ValuesView
|
|
8980
|
+
* component for more details.
|
|
8981
|
+
*
|
|
8982
|
+
* This component uses the useValue hook under the covers, which means that any
|
|
8983
|
+
* changes to the specified Value will cause a re-render.
|
|
8984
|
+
*
|
|
8985
|
+
* @param props The props for this component.
|
|
8986
|
+
* @returns A rendering of the Value, or nothing, if not present.
|
|
8987
|
+
* @example
|
|
8988
|
+
* This example creates a Store outside the application, which is used in the
|
|
8989
|
+
* ValueView component by reference. A change to the data in the Store
|
|
8990
|
+
* re-renders the component.
|
|
8991
|
+
*
|
|
8992
|
+
* ```jsx
|
|
8993
|
+
* const store = createStore().setValue('open', true);
|
|
8994
|
+
* const App = () => (
|
|
8995
|
+
* <span>
|
|
8996
|
+
* <ValueView valueId="open" store={store} />
|
|
8997
|
+
* </span>
|
|
8998
|
+
* );
|
|
8999
|
+
*
|
|
9000
|
+
* const app = document.createElement('div');
|
|
9001
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
9002
|
+
* console.log(app.innerHTML);
|
|
9003
|
+
* // -> '<span>true</span>'
|
|
9004
|
+
*
|
|
9005
|
+
* store.setValue('open', false); // !act
|
|
9006
|
+
* console.log(app.innerHTML);
|
|
9007
|
+
* // -> '<span>false</span>'
|
|
9008
|
+
* ```
|
|
9009
|
+
* @example
|
|
9010
|
+
* This example creates a Provider context into which a default Store is
|
|
9011
|
+
* provided. The ValueView component within it then renders the Value (with its
|
|
9012
|
+
* Id for readability).
|
|
9013
|
+
*
|
|
9014
|
+
* ```jsx
|
|
9015
|
+
* const App = ({store}) => (
|
|
9016
|
+
* <Provider store={store}>
|
|
9017
|
+
* <Pane />
|
|
9018
|
+
* </Provider>
|
|
9019
|
+
* );
|
|
9020
|
+
* const Pane = () => (
|
|
9021
|
+
* <span>
|
|
9022
|
+
* <ValueView valueId="open" debugIds={true} />
|
|
9023
|
+
* </span>
|
|
9024
|
+
* );
|
|
9025
|
+
*
|
|
9026
|
+
* const store = createStore().setValue('open', true);
|
|
9027
|
+
* const app = document.createElement('div');
|
|
9028
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
9029
|
+
* console.log(app.innerHTML);
|
|
9030
|
+
* // -> '<span>open:{true}</span>'
|
|
9031
|
+
* ```
|
|
9032
|
+
* @example
|
|
9033
|
+
* This example creates a Provider context into which a default Store is
|
|
9034
|
+
* provided. The ValueView component within it then attempts to render a
|
|
9035
|
+
* non-existent Value.
|
|
9036
|
+
*
|
|
9037
|
+
* ```jsx
|
|
9038
|
+
* const App = ({store}) => (
|
|
9039
|
+
* <Provider store={store}>
|
|
9040
|
+
* <Pane />
|
|
9041
|
+
* </Provider>
|
|
9042
|
+
* );
|
|
9043
|
+
* const Pane = () => (
|
|
9044
|
+
* <span>
|
|
9045
|
+
* <ValueView valueId="website" />
|
|
9046
|
+
* </span>
|
|
9047
|
+
* );
|
|
9048
|
+
*
|
|
9049
|
+
* const store = createStore().setValue('open', true);
|
|
9050
|
+
* const app = document.createElement('div');
|
|
9051
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
9052
|
+
* console.log(app.innerHTML);
|
|
9053
|
+
* // -> '<span></span>'
|
|
9054
|
+
* ```
|
|
9055
|
+
* @category Store components
|
|
9056
|
+
* @since v3.0.0
|
|
9057
|
+
*/
|
|
9058
|
+
export function ValueView(props: ValueProps): ComponentReturnType;
|
|
9059
|
+
|
|
9060
|
+
/**
|
|
9061
|
+
* The ValuesView component renders the keyed value contents of a Store, and
|
|
9062
|
+
* registers a listener so that any changes to that result will cause a
|
|
9063
|
+
* re-render.
|
|
9064
|
+
*
|
|
9065
|
+
* The component's props can identify which Store to render - either the default
|
|
9066
|
+
* context Store, a named context Store, or an explicit reference.
|
|
9067
|
+
*
|
|
9068
|
+
* This component renders a Store by iterating over its Value objects. By
|
|
9069
|
+
* default these are in turn rendered with the ValueView component, but you can
|
|
9070
|
+
* override this behavior by providing a `valueComponent` prop, a custom
|
|
9071
|
+
* component of your own that will render a Value based on ValueProps. You can
|
|
9072
|
+
* also pass additional props to your custom component with the
|
|
9073
|
+
* `getValueComponentProps` callback prop.
|
|
9074
|
+
*
|
|
9075
|
+
* This component uses the useTableIds hook under the covers, which means that
|
|
9076
|
+
* any changes to the structure of the Store will cause a re-render.
|
|
9077
|
+
*
|
|
9078
|
+
* This component uses the useValueIds hook under the covers, which means that
|
|
9079
|
+
* any changes to the Store's Values will cause a re-render.
|
|
9080
|
+
*
|
|
9081
|
+
* @param props The props for this component.
|
|
9082
|
+
* @returns A rendering of the Values, or nothing, if not present.
|
|
9083
|
+
* @example
|
|
9084
|
+
* This example creates a Store outside the application, which is used in the
|
|
9085
|
+
* ValuesView component by reference. A change to the data in the Store
|
|
9086
|
+
* re-renders the component.
|
|
9087
|
+
*
|
|
9088
|
+
* ```jsx
|
|
9089
|
+
* const store = createStore().setValue('open', true);
|
|
9090
|
+
* const App = () => (
|
|
9091
|
+
* <div>
|
|
9092
|
+
* <ValuesView store={store} separator="/" />
|
|
9093
|
+
* </div>
|
|
9094
|
+
* );
|
|
9095
|
+
*
|
|
9096
|
+
* const app = document.createElement('div');
|
|
9097
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
9098
|
+
* console.log(app.innerHTML);
|
|
9099
|
+
* // -> '<div>true</div>'
|
|
9100
|
+
*
|
|
9101
|
+
* store.setValue('employees', 3); // !act
|
|
9102
|
+
* console.log(app.innerHTML);
|
|
9103
|
+
* // -> '<div>true/3</div>'
|
|
9104
|
+
* ```
|
|
9105
|
+
* @example
|
|
9106
|
+
* This example creates a Provider context into which a default Store is
|
|
9107
|
+
* provided. The ValuesView component within it then renders the Values (with
|
|
9108
|
+
* Ids for readability).
|
|
9109
|
+
*
|
|
9110
|
+
* ```jsx
|
|
9111
|
+
* const App = ({store}) => (
|
|
9112
|
+
* <Provider store={store}>
|
|
9113
|
+
* <Pane />
|
|
9114
|
+
* </Provider>
|
|
9115
|
+
* );
|
|
9116
|
+
* const Pane = () => (
|
|
9117
|
+
* <div>
|
|
9118
|
+
* <ValuesView debugIds={true} />
|
|
9119
|
+
* </div>
|
|
9120
|
+
* );
|
|
9121
|
+
*
|
|
9122
|
+
* const store = createStore().setValues({open: true, employees: 3});
|
|
9123
|
+
* const app = document.createElement('div');
|
|
9124
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
9125
|
+
* console.log(app.innerHTML);
|
|
9126
|
+
* // -> '<div>open:{true}employees:{3}</div>'
|
|
9127
|
+
* ```
|
|
9128
|
+
* @example
|
|
9129
|
+
* This example creates a Provider context into which a default Store is
|
|
9130
|
+
* provided. The ValuesView component within it then renders the Values with a
|
|
9131
|
+
* custom Value component and a custom props callback.
|
|
9132
|
+
*
|
|
9133
|
+
* ```jsx
|
|
9134
|
+
* const App = ({store}) => (
|
|
9135
|
+
* <Provider store={store}>
|
|
9136
|
+
* <Pane />
|
|
9137
|
+
* </Provider>
|
|
9138
|
+
* );
|
|
9139
|
+
* const Pane = () => (
|
|
9140
|
+
* <div>
|
|
9141
|
+
* <ValuesView
|
|
9142
|
+
* valueComponent={FormattedValueView}
|
|
9143
|
+
* getValueComponentProps={(valueId) => ({bold: valueId == 'open'})}
|
|
9144
|
+
* />
|
|
9145
|
+
* </div>
|
|
9146
|
+
* );
|
|
9147
|
+
* const FormattedValueView = ({valueId, bold}) => (
|
|
9148
|
+
* <span>
|
|
9149
|
+
* {bold ? <b>{valueId}</b> : valueId}
|
|
9150
|
+
* {': '}
|
|
9151
|
+
* <ValueView valueId={valueId} />
|
|
9152
|
+
* </span>
|
|
9153
|
+
* );
|
|
9154
|
+
*
|
|
9155
|
+
* const store = createStore().setValues({open: true, employees: 3});
|
|
9156
|
+
* const app = document.createElement('div');
|
|
9157
|
+
* ReactDOMClient.createRoot(app).render(<App store={store} />); // !act
|
|
9158
|
+
* console.log(app.innerHTML);
|
|
9159
|
+
* // -> '<div><span><b>open</b>: true</span><span>employees: 3</span></div>'
|
|
9160
|
+
* ```
|
|
9161
|
+
* @category Store components
|
|
9162
|
+
* @since v3.0.0
|
|
9163
|
+
*/
|
|
9164
|
+
export function ValuesView(props: ValuesProps): ComponentReturnType;
|
|
9165
|
+
|
|
8034
9166
|
/**
|
|
8035
9167
|
* The MetricView component renders the current value of a Metric, and registers
|
|
8036
9168
|
* a listener so that any changes to that result will cause a re-render.
|
|
@@ -8064,7 +9196,7 @@ export function TablesView(props: TablesProps): ComponentReturnType;
|
|
|
8064
9196
|
* );
|
|
8065
9197
|
*
|
|
8066
9198
|
* const app = document.createElement('div');
|
|
8067
|
-
*
|
|
9199
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
8068
9200
|
* console.log(app.innerHTML);
|
|
8069
9201
|
* // -> '<div>5</div>'
|
|
8070
9202
|
*
|
|
@@ -8098,7 +9230,7 @@ export function TablesView(props: TablesProps): ComponentReturnType;
|
|
|
8098
9230
|
* metrics.setMetricDefinition('highestPrice', 'species', 'max', 'price');
|
|
8099
9231
|
*
|
|
8100
9232
|
* const app = document.createElement('div');
|
|
8101
|
-
*
|
|
9233
|
+
* ReactDOMClient.createRoot(app).render(<App metrics={metrics} />); // !act
|
|
8102
9234
|
* console.log(app.innerHTML);
|
|
8103
9235
|
* // -> '<div>highestPrice:{5}</div>'
|
|
8104
9236
|
* ```
|
|
@@ -8128,7 +9260,7 @@ export function TablesView(props: TablesProps): ComponentReturnType;
|
|
|
8128
9260
|
* metrics.setMetricDefinition('highestPrice', 'species', 'max', 'price');
|
|
8129
9261
|
*
|
|
8130
9262
|
* const app = document.createElement('div');
|
|
8131
|
-
*
|
|
9263
|
+
* ReactDOMClient.createRoot(app).render(<App metrics={metrics} />); // !act
|
|
8132
9264
|
* console.log(app.innerHTML);
|
|
8133
9265
|
* // -> '<div></div>'
|
|
8134
9266
|
* ```
|
|
@@ -8179,7 +9311,7 @@ export function MetricView(props: MetricProps): ComponentReturnType;
|
|
|
8179
9311
|
* );
|
|
8180
9312
|
*
|
|
8181
9313
|
* const app = document.createElement('div');
|
|
8182
|
-
*
|
|
9314
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
8183
9315
|
* console.log(app.innerHTML);
|
|
8184
9316
|
* // -> '<div>dog</div>'
|
|
8185
9317
|
*
|
|
@@ -8212,7 +9344,7 @@ export function MetricView(props: MetricProps): ComponentReturnType;
|
|
|
8212
9344
|
* indexes.setIndexDefinition('bySpecies', 'pets', 'species');
|
|
8213
9345
|
*
|
|
8214
9346
|
* const app = document.createElement('div');
|
|
8215
|
-
*
|
|
9347
|
+
* ReactDOMClient.createRoot(app).render(<App indexes={indexes} />); // !act
|
|
8216
9348
|
* console.log(app.innerHTML);
|
|
8217
9349
|
* // -> '<div>dog:{fido:{species:{dog}}cujo:{species:{dog}}}</div>'
|
|
8218
9350
|
* ```
|
|
@@ -8254,7 +9386,7 @@ export function MetricView(props: MetricProps): ComponentReturnType;
|
|
|
8254
9386
|
* indexes.setIndexDefinition('bySpecies', 'pets', 'species');
|
|
8255
9387
|
*
|
|
8256
9388
|
* const app = document.createElement('div');
|
|
8257
|
-
*
|
|
9389
|
+
* ReactDOMClient.createRoot(app).render(<App indexes={indexes} />); // !act
|
|
8258
9390
|
* console.log(app.innerHTML);
|
|
8259
9391
|
* // -> '<div><span><b>fido</b>: dog/brown</span><span>cujo: dog</span></div>'
|
|
8260
9392
|
* ```
|
|
@@ -8301,7 +9433,7 @@ export function SliceView(props: SliceProps): ComponentReturnType;
|
|
|
8301
9433
|
* );
|
|
8302
9434
|
*
|
|
8303
9435
|
* const app = document.createElement('div');
|
|
8304
|
-
*
|
|
9436
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
8305
9437
|
* console.log(app.innerHTML);
|
|
8306
9438
|
* // -> '<div>dog/cat</div>'
|
|
8307
9439
|
*
|
|
@@ -8334,7 +9466,7 @@ export function SliceView(props: SliceProps): ComponentReturnType;
|
|
|
8334
9466
|
* indexes.setIndexDefinition('bySpecies', 'pets', 'species');
|
|
8335
9467
|
*
|
|
8336
9468
|
* const app = document.createElement('div');
|
|
8337
|
-
*
|
|
9469
|
+
* ReactDOMClient.createRoot(app).render(<App indexes={indexes} />); // !act
|
|
8338
9470
|
* console.log(app.innerHTML);
|
|
8339
9471
|
* // -> '<div>bySpecies:{dog:{fido:{species:{dog}}cujo:{species:{dog}}}}</div>'
|
|
8340
9472
|
* ```
|
|
@@ -8375,7 +9507,7 @@ export function SliceView(props: SliceProps): ComponentReturnType;
|
|
|
8375
9507
|
* indexes.setIndexDefinition('bySpecies', 'pets', 'species');
|
|
8376
9508
|
*
|
|
8377
9509
|
* const app = document.createElement('div');
|
|
8378
|
-
*
|
|
9510
|
+
* ReactDOMClient.createRoot(app).render(<App indexes={indexes} />); // !act
|
|
8379
9511
|
* console.log(app.innerHTML);
|
|
8380
9512
|
* // -> '<div><span><b>dog</b>: dog/dog</span><span>cat: cat</span></div>'
|
|
8381
9513
|
* ```
|
|
@@ -8431,7 +9563,7 @@ export function IndexView(props: IndexProps): ComponentReturnType;
|
|
|
8431
9563
|
* );
|
|
8432
9564
|
*
|
|
8433
9565
|
* const app = document.createElement('div');
|
|
8434
|
-
*
|
|
9566
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
8435
9567
|
* console.log(app.innerHTML);
|
|
8436
9568
|
* // -> '<div>5</div>'
|
|
8437
9569
|
*
|
|
@@ -8467,7 +9599,8 @@ export function IndexView(props: IndexProps): ComponentReturnType;
|
|
|
8467
9599
|
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
8468
9600
|
*
|
|
8469
9601
|
* const app = document.createElement('div');
|
|
8470
|
-
*
|
|
9602
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
9603
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
8471
9604
|
* console.log(app.innerHTML);
|
|
8472
9605
|
* // -> '<div>cujo:{dog:{price:{5}}}</div>'
|
|
8473
9606
|
* ```
|
|
@@ -8507,7 +9640,8 @@ export function IndexView(props: IndexProps): ComponentReturnType;
|
|
|
8507
9640
|
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
8508
9641
|
*
|
|
8509
9642
|
* const app = document.createElement('div');
|
|
8510
|
-
*
|
|
9643
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
9644
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
8511
9645
|
* console.log(app.innerHTML);
|
|
8512
9646
|
* // -> '<div><span><b>dog</b>: 5</span></div>'
|
|
8513
9647
|
* ```
|
|
@@ -8564,7 +9698,7 @@ export function RemoteRowView(props: RemoteRowProps): ComponentReturnType;
|
|
|
8564
9698
|
* );
|
|
8565
9699
|
*
|
|
8566
9700
|
* const app = document.createElement('div');
|
|
8567
|
-
*
|
|
9701
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
8568
9702
|
* console.log(app.innerHTML);
|
|
8569
9703
|
* // -> '<div>dog/dog</div>'
|
|
8570
9704
|
*
|
|
@@ -8600,7 +9734,8 @@ export function RemoteRowView(props: RemoteRowProps): ComponentReturnType;
|
|
|
8600
9734
|
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
8601
9735
|
*
|
|
8602
9736
|
* const app = document.createElement('div');
|
|
8603
|
-
*
|
|
9737
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
9738
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
8604
9739
|
* console.log(app.innerHTML);
|
|
8605
9740
|
* // -> '<div>dog:{fido:{species:{dog}}cujo:{species:{dog}}}</div>'
|
|
8606
9741
|
* ```
|
|
@@ -8640,7 +9775,8 @@ export function RemoteRowView(props: RemoteRowProps): ComponentReturnType;
|
|
|
8640
9775
|
* ).setRelationshipDefinition('petSpecies', 'pets', 'species', 'species');
|
|
8641
9776
|
*
|
|
8642
9777
|
* const app = document.createElement('div');
|
|
8643
|
-
*
|
|
9778
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
9779
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
8644
9780
|
* console.log(app.innerHTML);
|
|
8645
9781
|
* // -> '<div><span><b>fido</b>: dog</span><span>cujo: dog</span></div>'
|
|
8646
9782
|
* ```
|
|
@@ -8699,7 +9835,7 @@ export function LocalRowsView(props: LocalRowsProps): ComponentReturnType;
|
|
|
8699
9835
|
* );
|
|
8700
9836
|
*
|
|
8701
9837
|
* const app = document.createElement('div');
|
|
8702
|
-
*
|
|
9838
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
8703
9839
|
* console.log(app.innerHTML);
|
|
8704
9840
|
* // -> '<div>felix/cujo/dog</div>'
|
|
8705
9841
|
*
|
|
@@ -8737,7 +9873,8 @@ export function LocalRowsView(props: LocalRowsProps): ComponentReturnType;
|
|
|
8737
9873
|
* ).setRelationshipDefinition('petSequence', 'pets', 'pets', 'next');
|
|
8738
9874
|
*
|
|
8739
9875
|
* const app = document.createElement('div');
|
|
8740
|
-
*
|
|
9876
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
9877
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
8741
9878
|
* console.log(app.innerHTML);
|
|
8742
9879
|
* // -> '<div>fido:{fido:{next:{felix}}felix:{species:{cat}}}</div>'
|
|
8743
9880
|
* ```
|
|
@@ -8778,7 +9915,8 @@ export function LocalRowsView(props: LocalRowsProps): ComponentReturnType;
|
|
|
8778
9915
|
* ).setRelationshipDefinition('petSequence', 'pets', 'pets', 'next');
|
|
8779
9916
|
*
|
|
8780
9917
|
* const app = document.createElement('div');
|
|
8781
|
-
*
|
|
9918
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
9919
|
+
* root.render(<App relationships={relationships} />); // !act
|
|
8782
9920
|
* console.log(app.innerHTML);
|
|
8783
9921
|
* // -> '<div><span><b>fido</b>: felix</span><span>felix: cat</span></div>'
|
|
8784
9922
|
* ```
|
|
@@ -8833,7 +9971,7 @@ export function LinkedRowsView(props: LinkedRowsProps): ComponentReturnType;
|
|
|
8833
9971
|
* );
|
|
8834
9972
|
*
|
|
8835
9973
|
* const app = document.createElement('div');
|
|
8836
|
-
*
|
|
9974
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
8837
9975
|
* console.log(app.innerHTML);
|
|
8838
9976
|
* // -> '<span>brown</span>'
|
|
8839
9977
|
*
|
|
@@ -8871,7 +10009,7 @@ export function LinkedRowsView(props: LinkedRowsProps): ComponentReturnType;
|
|
|
8871
10009
|
* }),
|
|
8872
10010
|
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
8873
10011
|
* const app = document.createElement('div');
|
|
8874
|
-
*
|
|
10012
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
8875
10013
|
* console.log(app.innerHTML);
|
|
8876
10014
|
* // -> '<span>color:{brown}</span>'
|
|
8877
10015
|
* ```
|
|
@@ -8900,7 +10038,7 @@ export function LinkedRowsView(props: LinkedRowsProps): ComponentReturnType;
|
|
|
8900
10038
|
* }),
|
|
8901
10039
|
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
8902
10040
|
* const app = document.createElement('div');
|
|
8903
|
-
*
|
|
10041
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
8904
10042
|
* console.log(app.innerHTML);
|
|
8905
10043
|
* // -> '<span></span>'
|
|
8906
10044
|
* ```
|
|
@@ -8965,7 +10103,7 @@ export function ResultCellView(props: ResultCellProps): ComponentReturnType;
|
|
|
8965
10103
|
* );
|
|
8966
10104
|
*
|
|
8967
10105
|
* const app = document.createElement('div');
|
|
8968
|
-
*
|
|
10106
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
8969
10107
|
* console.log(app.innerHTML);
|
|
8970
10108
|
* // -> '<div>dog/brown</div>'
|
|
8971
10109
|
*
|
|
@@ -9001,7 +10139,7 @@ export function ResultCellView(props: ResultCellProps): ComponentReturnType;
|
|
|
9001
10139
|
* select('color');
|
|
9002
10140
|
* });
|
|
9003
10141
|
* const app = document.createElement('div');
|
|
9004
|
-
*
|
|
10142
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
9005
10143
|
* console.log(app.innerHTML);
|
|
9006
10144
|
* // -> '<div>fido:{species:{dog}color:{brown}}</div>'
|
|
9007
10145
|
* ```
|
|
@@ -9047,7 +10185,7 @@ export function ResultCellView(props: ResultCellProps): ComponentReturnType;
|
|
|
9047
10185
|
* select('color');
|
|
9048
10186
|
* });
|
|
9049
10187
|
* const app = document.createElement('div');
|
|
9050
|
-
*
|
|
10188
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
9051
10189
|
* console.log(app.innerHTML);
|
|
9052
10190
|
* // -> '<div><span><b>species</b>: dog</span><span>color: brown</span></div>'
|
|
9053
10191
|
* ```
|
|
@@ -9109,7 +10247,7 @@ export function ResultRowView(props: ResultRowProps): ComponentReturnType;
|
|
|
9109
10247
|
* );
|
|
9110
10248
|
*
|
|
9111
10249
|
* const app = document.createElement('div');
|
|
9112
|
-
*
|
|
10250
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
9113
10251
|
* console.log(app.innerHTML);
|
|
9114
10252
|
* // -> '<div>black/brown</div>'
|
|
9115
10253
|
*
|
|
@@ -9145,7 +10283,7 @@ export function ResultRowView(props: ResultRowProps): ComponentReturnType;
|
|
|
9145
10283
|
* }),
|
|
9146
10284
|
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
9147
10285
|
* const app = document.createElement('div');
|
|
9148
|
-
*
|
|
10286
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
9149
10287
|
* console.log(app.innerHTML);
|
|
9150
10288
|
* // -> '<div>petColors:{felix:{color:{black}}fido:{color:{brown}}}</div>'
|
|
9151
10289
|
* ```
|
|
@@ -9185,7 +10323,7 @@ export function ResultRowView(props: ResultRowProps): ComponentReturnType;
|
|
|
9185
10323
|
* }),
|
|
9186
10324
|
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
9187
10325
|
* const app = document.createElement('div');
|
|
9188
|
-
*
|
|
10326
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
9189
10327
|
* console.log(app.innerHTML);
|
|
9190
10328
|
* // -> '<div><span>felix: black</span><span><b>fido</b>: brown</span></div>'
|
|
9191
10329
|
* ```
|
|
@@ -9239,7 +10377,7 @@ export function ResultSortedTableView(
|
|
|
9239
10377
|
* );
|
|
9240
10378
|
*
|
|
9241
10379
|
* const app = document.createElement('div');
|
|
9242
|
-
*
|
|
10380
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
9243
10381
|
* console.log(app.innerHTML);
|
|
9244
10382
|
* // -> '<div>brown/black</div>'
|
|
9245
10383
|
*
|
|
@@ -9271,7 +10409,7 @@ export function ResultSortedTableView(
|
|
|
9271
10409
|
* }),
|
|
9272
10410
|
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
9273
10411
|
* const app = document.createElement('div');
|
|
9274
|
-
*
|
|
10412
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
9275
10413
|
* console.log(app.innerHTML);
|
|
9276
10414
|
* // -> '<div>petColors:{fido:{color:{brown}}felix:{color:{black}}}</div>'
|
|
9277
10415
|
* ```
|
|
@@ -9310,7 +10448,7 @@ export function ResultSortedTableView(
|
|
|
9310
10448
|
* }),
|
|
9311
10449
|
* ).setQueryDefinition('petColors', 'pets', ({select}) => select('color'));
|
|
9312
10450
|
* const app = document.createElement('div');
|
|
9313
|
-
*
|
|
10451
|
+
* ReactDOMClient.createRoot(app).render(<App queries={queries} />); // !act
|
|
9314
10452
|
* console.log(app.innerHTML);
|
|
9315
10453
|
* // -> '<div><span><b>fido</b>: brown</span><span>felix: black</span></div>'
|
|
9316
10454
|
* ```
|
|
@@ -9353,7 +10491,7 @@ export function ResultTableView(props: ResultTableProps): ComponentReturnType;
|
|
|
9353
10491
|
* );
|
|
9354
10492
|
*
|
|
9355
10493
|
* const app = document.createElement('div');
|
|
9356
|
-
*
|
|
10494
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
9357
10495
|
* console.log(app.innerHTML);
|
|
9358
10496
|
* // -> '<div>1:{}</div>'
|
|
9359
10497
|
*
|
|
@@ -9406,7 +10544,7 @@ export function CheckpointView(props: CheckpointProps): ComponentReturnType;
|
|
|
9406
10544
|
* );
|
|
9407
10545
|
*
|
|
9408
10546
|
* const app = document.createElement('div');
|
|
9409
|
-
*
|
|
10547
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
9410
10548
|
* console.log(app.innerHTML);
|
|
9411
10549
|
* // -> '<div></div>'
|
|
9412
10550
|
*
|
|
@@ -9448,7 +10586,8 @@ export function CheckpointView(props: CheckpointProps): ComponentReturnType;
|
|
|
9448
10586
|
* checkpoints.addCheckpoint('sale'); // !act
|
|
9449
10587
|
*
|
|
9450
10588
|
* const app = document.createElement('div');
|
|
9451
|
-
*
|
|
10589
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
10590
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
9452
10591
|
* console.log(app.innerHTML);
|
|
9453
10592
|
* // -> '<div>0:{initial}1:{identified}</div>'
|
|
9454
10593
|
* ```
|
|
@@ -9495,7 +10634,8 @@ export function CheckpointView(props: CheckpointProps): ComponentReturnType;
|
|
|
9495
10634
|
* checkpoints.addCheckpoint('sale'); // !act
|
|
9496
10635
|
*
|
|
9497
10636
|
* const app = document.createElement('div');
|
|
9498
|
-
*
|
|
10637
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
10638
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
9499
10639
|
* console.log(app.innerHTML);
|
|
9500
10640
|
* // -> '<div><span><b>0</b>: initial</span><span>1: identified</span></div>'
|
|
9501
10641
|
* ```
|
|
@@ -9540,7 +10680,7 @@ export function BackwardCheckpointsView(
|
|
|
9540
10680
|
* );
|
|
9541
10681
|
*
|
|
9542
10682
|
* const app = document.createElement('div');
|
|
9543
|
-
*
|
|
10683
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
9544
10684
|
* console.log(app.innerHTML);
|
|
9545
10685
|
* // -> '<div></div>'
|
|
9546
10686
|
*
|
|
@@ -9581,7 +10721,8 @@ export function BackwardCheckpointsView(
|
|
|
9581
10721
|
* checkpoints.addCheckpoint('identified'); // !act
|
|
9582
10722
|
*
|
|
9583
10723
|
* const app = document.createElement('div');
|
|
9584
|
-
*
|
|
10724
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
10725
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
9585
10726
|
* console.log(app.innerHTML);
|
|
9586
10727
|
* // -> '<div>1:{identified}</div>'
|
|
9587
10728
|
* ```
|
|
@@ -9625,7 +10766,8 @@ export function BackwardCheckpointsView(
|
|
|
9625
10766
|
* checkpoints.addCheckpoint('identified'); // !act
|
|
9626
10767
|
*
|
|
9627
10768
|
* const app = document.createElement('div');
|
|
9628
|
-
*
|
|
10769
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
10770
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
9629
10771
|
* console.log(app.innerHTML);
|
|
9630
10772
|
* // -> '<div><span><b>1</b>: identified</span></div>'
|
|
9631
10773
|
*
|
|
@@ -9676,7 +10818,7 @@ export function CurrentCheckpointView(
|
|
|
9676
10818
|
* );
|
|
9677
10819
|
*
|
|
9678
10820
|
* const app = document.createElement('div');
|
|
9679
|
-
*
|
|
10821
|
+
* ReactDOMClient.createRoot(app).render(<App />); // !act
|
|
9680
10822
|
* console.log(app.innerHTML);
|
|
9681
10823
|
* // -> '<div></div>'
|
|
9682
10824
|
*
|
|
@@ -9719,7 +10861,8 @@ export function CurrentCheckpointView(
|
|
|
9719
10861
|
* checkpoints.goTo('0'); // !act
|
|
9720
10862
|
*
|
|
9721
10863
|
* const app = document.createElement('div');
|
|
9722
|
-
*
|
|
10864
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
10865
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
9723
10866
|
* console.log(app.innerHTML);
|
|
9724
10867
|
* // -> '<div>1:{identified}2:{sale}</div>'
|
|
9725
10868
|
* ```
|
|
@@ -9766,7 +10909,8 @@ export function CurrentCheckpointView(
|
|
|
9766
10909
|
* checkpoints.goTo('0'); // !act
|
|
9767
10910
|
*
|
|
9768
10911
|
* const app = document.createElement('div');
|
|
9769
|
-
*
|
|
10912
|
+
* const root = ReactDOMClient.createRoot(app);
|
|
10913
|
+
* root.render(<App checkpoints={checkpoints} />); // !act
|
|
9770
10914
|
* console.log(app.innerHTML);
|
|
9771
10915
|
* // -> '<div><span><b>1</b>: identified</span><span>2: sale</span></div>'
|
|
9772
10916
|
* ```
|