@arrai-innovations/reactive-helpers 10.4.2 → 11.0.0
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/.circleci/config.yml +3 -3
- package/README.md +120 -143
- package/config/listCrud.js +0 -1
- package/docs.md +178 -34
- package/package.json +3 -1
- package/tests/unit/use/listFilter.spec.js +195 -167
- package/tests/unit/use/listSearch.spec.js +505 -0
- package/tests/unit/use/listSort.spec.js +0 -1
- package/tests/unit/use/listSubscription.spec.js +91 -108
- package/tests/unit/use/search.spec.js +217 -36
- package/tests/unit/utils/assignReactiveObject.spec.js +0 -1
- package/tests/unit/{use → utils}/watches.spec.js +27 -3
- package/use/cancellableIntent.js +8 -3
- package/use/index.js +2 -0
- package/use/list.js +41 -14
- package/use/listCalculated.js +22 -19
- package/use/listFilter.js +128 -154
- package/use/listInstance.js +0 -28
- package/use/listKeys.js +94 -0
- package/use/listRelated.js +22 -14
- package/use/listSearch.js +358 -0
- package/use/listSort.js +30 -42
- package/use/listSubscription.js +3 -13
- package/use/search.js +154 -64
- package/utils/assignReactiveObject.js +58 -14
- package/utils/index.js +1 -0
- package/utils/keyDiff.js +13 -7
- package/utils/relatedCalculatedHelpers.js +17 -0
- package/utils/watches.js +14 -11
package/docs.md
CHANGED
|
@@ -29,36 +29,46 @@
|
|
|
29
29
|
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
30
30
|
| [useCombineClasses(classes)] |
|
|
31
31
|
| [useListInstance(options)] | `useListInstance` is a Vue composition function that manages a list of objects. It has the ability to retrieve the list from an implementation, or subscribe to updates from an implementation. It tracks the objects in the list, and their added order. |
|
|
32
|
+
| [useListSearch(options)] | Text filter for list items. This will not be performant for large lists, as each item will be watched. However, the results will reactively update. |
|
|
32
33
|
| [useListSubscription(options)] | `useListSubscription` creates a reactive object that manages a list of objects, as returned by `useListInstance`, causing the list to be re-fetched as needed and listening for updates to the list. |
|
|
33
34
|
| [useObjectInstances(instanceArgs)] | Initializes multiple useObjectInstance instances, returning an object of them based on the keys of the instanceArgs. |
|
|
34
35
|
| [useObjectInstance(options)] | Initializes an object instance to manage create, retrieve, update, delete, and patch operations. |
|
|
36
|
+
| [useSearch(options)] | A reactive wrapper around FlexSearch.Index |
|
|
35
37
|
|
|
36
38
|
## Typedefs
|
|
37
39
|
|
|
38
|
-
| Name
|
|
39
|
-
|
|
|
40
|
-
| [CSSValue]
|
|
41
|
-
| [CSSObject]
|
|
42
|
-
| [CSSClasses]
|
|
43
|
-
| [CSSStringOrObject]
|
|
44
|
-
| [ListInstanceOptions]
|
|
45
|
-
| [ListInstanceState]
|
|
46
|
-
| [ListInstance]
|
|
47
|
-
| [
|
|
48
|
-
| [
|
|
49
|
-
| [
|
|
50
|
-
| [
|
|
51
|
-
| [
|
|
52
|
-
| [
|
|
53
|
-
| [
|
|
54
|
-
| [ObjectInstanceOptions]
|
|
55
|
-
| [
|
|
56
|
-
| [
|
|
57
|
-
| [
|
|
58
|
-
| [
|
|
59
|
-
| [
|
|
60
|
-
| [
|
|
61
|
-
| [
|
|
40
|
+
| Name | Description |
|
|
41
|
+
| --------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
42
|
+
| [CSSValue] | A string representing a CSS class or a space-separated list of CSS classes. |
|
|
43
|
+
| [CSSObject] | A CSS object where keys are CSS classes and values are booleans indicating whether to apply the class. |
|
|
44
|
+
| [CSSClasses] | A mixed array containing multiple ways of specifying CSS classes. |
|
|
45
|
+
| [CSSStringOrObject] | The amalgamated classes as returned by `objectifyClasses` & `combineClasses`. |
|
|
46
|
+
| [ListInstanceOptions] | The configuration options used to create a list instance. |
|
|
47
|
+
| [ListInstanceState] | A reactive object that manages a list of objects, as returned by `useListInstance`. |
|
|
48
|
+
| [ListInstance] |
|
|
49
|
+
| [ListSearchProps] |
|
|
50
|
+
| [ListSearchInstance] |
|
|
51
|
+
| [ListSearchInstanceOptions] |
|
|
52
|
+
| [ListSubscriptionOptions] | The configuration options used to create a list subscription. |
|
|
53
|
+
| [ListSubscriptionState] | A reactive object that manages a list of objects, as returned by `useListInstance`. |
|
|
54
|
+
| [ListSubscription] |
|
|
55
|
+
| [ObjectCrudFunctions] |
|
|
56
|
+
| [ObjectInstanceOptions] |
|
|
57
|
+
| [ObjectInstance] |
|
|
58
|
+
| [ObjectInstanceProps] |
|
|
59
|
+
| [ObjectInstanceOptions] |
|
|
60
|
+
| [ObjectInstanceState] |
|
|
61
|
+
| [ObjectInstanceInstance] |
|
|
62
|
+
| [SearchOptions] | FlexSearch.Document search options |
|
|
63
|
+
| [DocumentOptions] | FlexSearch.Document options |
|
|
64
|
+
| [SearchState] |
|
|
65
|
+
| [SearchInstance] |
|
|
66
|
+
| [SearchProps] | A reactive object for passing document options or search options to useSearch |
|
|
67
|
+
| [CSSValue] | A string representing a CSS class or a space-separated list of CSS classes. |
|
|
68
|
+
| [CSSObject] | A CSS object where keys are CSS classes and values are booleans indicating whether to apply the class. |
|
|
69
|
+
| [CSSClasses] | A mixed array containing multiple ways of specifying CSS classes. |
|
|
70
|
+
| [CSSClassesWithRefs] | A mixed array containing multiple ways of specifying CSS classes. |
|
|
71
|
+
| [CSSStringOrObject] | A CSS object or a space-separated list of CSS classes. |
|
|
62
72
|
|
|
63
73
|
## utils/assignReactiveObject
|
|
64
74
|
|
|
@@ -268,11 +278,11 @@ are the same, what keys are removed, and what keys are added.
|
|
|
268
278
|
**Kind**: inner method of [`utils/keyDiff`]
|
|
269
279
|
**Returns**: `KeyDiffResult` - - the differences
|
|
270
280
|
|
|
271
|
-
| Param | Type
|
|
272
|
-
| ----------- |
|
|
273
|
-
| newKeys | `Array.<string>` | keys to consider as new |
|
|
274
|
-
| oldKeys | `Array.<string>` | keys to consider as old |
|
|
275
|
-
| \[options\] | `KeyDiffOptions`
|
|
281
|
+
| Param | Type | Description |
|
|
282
|
+
| ----------- | ------------------------- | ------------------------------ |
|
|
283
|
+
| newKeys | `Array.<string>` \| `Set` | keys to consider as new |
|
|
284
|
+
| oldKeys | `Array.<string>` \| `Set` | keys to consider as old |
|
|
285
|
+
| \[options\] | `KeyDiffOptions` | which differences are returned |
|
|
276
286
|
|
|
277
287
|
### utils/keyDiff~keyDiffDeep(newObj, oldObj, \[options\])
|
|
278
288
|
|
|
@@ -312,11 +322,11 @@ Result object of keyDiff and keyDiffDeep
|
|
|
312
322
|
**Kind**: inner typedef of [`utils/keyDiff`]
|
|
313
323
|
**Properties**
|
|
314
324
|
|
|
315
|
-
| Name | Type
|
|
316
|
-
| --------------- |
|
|
317
|
-
| \[sameKeys\] | `
|
|
318
|
-
| \[removedKeys\] | `
|
|
319
|
-
| \[addedKeys\] | `
|
|
325
|
+
| Name | Type | Description |
|
|
326
|
+
| --------------- | ----- | ----------------------------------------------------------- |
|
|
327
|
+
| \[sameKeys\] | `Set` | if sameKeys option is true, return keys that are the same |
|
|
328
|
+
| \[removedKeys\] | `Set` | if removedKeys option is true, return keys that are removed |
|
|
329
|
+
| \[addedKeys\] | `Set` | if addedKeys option is true, return keys that are added |
|
|
320
330
|
|
|
321
331
|
## utils/lifecycleDebug
|
|
322
332
|
|
|
@@ -488,6 +498,18 @@ It tracks the objects in the list, and their added order.
|
|
|
488
498
|
| ------- | ----------------------- | -------------------------------------------- |
|
|
489
499
|
| options | [`ListInstanceOptions`] | the options used to create the list instance |
|
|
490
500
|
|
|
501
|
+
## useListSearch(options)
|
|
502
|
+
|
|
503
|
+
Text filter for list items. This will not be performant for large lists, as each item will be watched.
|
|
504
|
+
However, the results will reactively update.
|
|
505
|
+
|
|
506
|
+
**Kind**: global function
|
|
507
|
+
**Returns**: [`ListSearchInstance`] - - the instance
|
|
508
|
+
|
|
509
|
+
| Param | Type | Description |
|
|
510
|
+
| ------- | ----------------------------- | ------------- |
|
|
511
|
+
| options | [`ListSearchInstanceOptions`] | the arguments |
|
|
512
|
+
|
|
491
513
|
## useListSubscription(options)
|
|
492
514
|
|
|
493
515
|
`useListSubscription` creates a reactive object that manages a list of objects, as returned by `useListInstance`,
|
|
@@ -522,6 +544,19 @@ Initializes an object instance to manage create, retrieve, update, delete, and p
|
|
|
522
544
|
| ------- | ------------------------- | ---------------------------------------------- |
|
|
523
545
|
| options | [`ObjectInstanceOptions`] | The options to be passed to useObjectInstance. |
|
|
524
546
|
|
|
547
|
+
## useSearch(options)
|
|
548
|
+
|
|
549
|
+
A reactive wrapper around FlexSearch.Index
|
|
550
|
+
|
|
551
|
+
**Kind**: global function
|
|
552
|
+
**Returns**: [`SearchInstance`] - - the instance
|
|
553
|
+
|
|
554
|
+
| Param | Type | Description |
|
|
555
|
+
| -------------------- | --------------- | ------------------ |
|
|
556
|
+
| options | `object` | options |
|
|
557
|
+
| options.props | [`SearchProps`] | props |
|
|
558
|
+
| \[options.throttle\] | `number` | throttle wait time |
|
|
559
|
+
|
|
525
560
|
## CSSValue
|
|
526
561
|
|
|
527
562
|
A string representing a CSS class or a space-separated list of CSS classes.
|
|
@@ -608,6 +643,42 @@ A reactive object that manages a list of objects, as returned by `useListInstanc
|
|
|
608
643
|
| state | [`ListInstanceState`] | the list instance state |
|
|
609
644
|
| effectScope | `object` | a Vue effect scope |
|
|
610
645
|
|
|
646
|
+
## ListSearchProps
|
|
647
|
+
|
|
648
|
+
**Kind**: global typedef
|
|
649
|
+
**Properties**
|
|
650
|
+
|
|
651
|
+
| Name | Type | Default | Description |
|
|
652
|
+
| ----------------------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
653
|
+
| textSearchRules | `array` | | rules for what to search for. Keys are the keys to search for, values are functions that take the object and return the value to search for. |
|
|
654
|
+
| textSearchValue | `string` | | the value to search for. |
|
|
655
|
+
| customDocumentOptions | `object` | | FlexSearch.Document options |
|
|
656
|
+
| customSearchOptions | `object` | | FlexSearch.Search options |
|
|
657
|
+
| \[customSearchOptions.limit\] | `object` | `1000` | FlexSearch.Search options |
|
|
658
|
+
|
|
659
|
+
## ListSearchInstance
|
|
660
|
+
|
|
661
|
+
**Kind**: global typedef
|
|
662
|
+
**Properties**
|
|
663
|
+
|
|
664
|
+
| Name | Type | Description |
|
|
665
|
+
| --------------- | ------------------ | --------------------- |
|
|
666
|
+
| state | `object` | the state |
|
|
667
|
+
| textSearchIndex | [`SearchInstance`] | the text search index |
|
|
668
|
+
| effectScope | `object` | a Vue effect scope |
|
|
669
|
+
|
|
670
|
+
## ListSearchInstanceOptions
|
|
671
|
+
|
|
672
|
+
**Kind**: global typedef
|
|
673
|
+
**Properties**
|
|
674
|
+
|
|
675
|
+
| Name | Type | Default | Description |
|
|
676
|
+
| -------------------- | ------------------- | ------- | -------------------------------------------------- |
|
|
677
|
+
| parentState | `object` | | the list being filtered |
|
|
678
|
+
| props | [`ListSearchProps`] | | reactive properties |
|
|
679
|
+
| \[throttle\] | `number` | `500` | throttle wait time |
|
|
680
|
+
| \[showAllWhenEmpty\] | `boolean` | `true` | whether to show all items when the search is empty |
|
|
681
|
+
|
|
611
682
|
## ListSubscriptionOptions
|
|
612
683
|
|
|
613
684
|
The configuration options used to create a list subscription.
|
|
@@ -751,6 +822,61 @@ A reactive object that manages a list of objects, as returned by `useListInstanc
|
|
|
751
822
|
| clearError | `function` | call to clear the error state. |
|
|
752
823
|
| clear | `function` | call to clear the object state. |
|
|
753
824
|
|
|
825
|
+
## SearchOptions
|
|
826
|
+
|
|
827
|
+
FlexSearch.Document search options
|
|
828
|
+
|
|
829
|
+
**Kind**: global typedef
|
|
830
|
+
**Properties**
|
|
831
|
+
|
|
832
|
+
| Name | Type | Description |
|
|
833
|
+
| ----- | -------- | ---------------- |
|
|
834
|
+
| limit | `number` | limit of results |
|
|
835
|
+
|
|
836
|
+
## DocumentOptions
|
|
837
|
+
|
|
838
|
+
FlexSearch.Document options
|
|
839
|
+
|
|
840
|
+
**Kind**: global typedef
|
|
841
|
+
|
|
842
|
+
## SearchState
|
|
843
|
+
|
|
844
|
+
**Kind**: global typedef
|
|
845
|
+
**Properties**
|
|
846
|
+
|
|
847
|
+
| Name | Type | Description |
|
|
848
|
+
| --------- | --------- | ------------------------------------------------------------------------------------------ |
|
|
849
|
+
| search | `string` | the search string |
|
|
850
|
+
| results | `object` | the results, where the keys are the ids of the objects that match, and the values are true |
|
|
851
|
+
| searched | `boolean` | whether the search has been performed |
|
|
852
|
+
| searching | `boolean` | whether the search is currently running |
|
|
853
|
+
|
|
854
|
+
## SearchInstance
|
|
855
|
+
|
|
856
|
+
**Kind**: global typedef
|
|
857
|
+
**Properties**
|
|
858
|
+
|
|
859
|
+
| Name | Type | Description |
|
|
860
|
+
| ----------- | --------------- | ------------------ |
|
|
861
|
+
| state | [`SearchState`] | the state |
|
|
862
|
+
| addIndex | `function` | add an index |
|
|
863
|
+
| updateIndex | `function` | update an index |
|
|
864
|
+
| removeIndex | `function` | remove an index |
|
|
865
|
+
| clearIndex | `function` | clear the index |
|
|
866
|
+
| effectScope | `object` | a Vue effect scope |
|
|
867
|
+
|
|
868
|
+
## SearchProps
|
|
869
|
+
|
|
870
|
+
A reactive object for passing document options or search options to useSearch
|
|
871
|
+
|
|
872
|
+
**Kind**: global typedef
|
|
873
|
+
**Properties**
|
|
874
|
+
|
|
875
|
+
| Name | Type | Description |
|
|
876
|
+
| --------------------- | ------------------- | --------------------------- |
|
|
877
|
+
| customDocumentOptions | [`DocumentOptions`] | FlexSearch.Document options |
|
|
878
|
+
| customSearchOptions | [`SearchOptions`] | search options |
|
|
879
|
+
|
|
754
880
|
## CSSValue
|
|
755
881
|
|
|
756
882
|
A string representing a CSS class or a space-separated list of CSS classes.
|
|
@@ -805,6 +931,9 @@ A CSS object or a space-separated list of CSS classes.
|
|
|
805
931
|
[listinstanceoptions]: #listinstanceoptions
|
|
806
932
|
[listinstancestate]: #listinstancestate
|
|
807
933
|
[listinstance]: #listinstance
|
|
934
|
+
[listsearchprops]: #listsearchprops
|
|
935
|
+
[listsearchinstance]: #listsearchinstance
|
|
936
|
+
[listsearchinstanceoptions]: #listsearchinstanceoptions
|
|
808
937
|
[listsubscriptionoptions]: #listsubscriptionoptions
|
|
809
938
|
[listsubscriptionstate]: #listsubscriptionstate
|
|
810
939
|
[listsubscription]: #listsubscription
|
|
@@ -814,6 +943,11 @@ A CSS object or a space-separated list of CSS classes.
|
|
|
814
943
|
[objectinstanceprops]: #objectinstanceprops
|
|
815
944
|
[objectinstancestate]: #objectinstancestate
|
|
816
945
|
[objectinstanceinstance]: #objectinstanceinstance
|
|
946
|
+
[searchoptions]: #searchoptions
|
|
947
|
+
[documentoptions]: #documentoptions
|
|
948
|
+
[searchstate]: #searchstate
|
|
949
|
+
[searchinstance]: #searchinstance
|
|
950
|
+
[searchprops]: #searchprops
|
|
817
951
|
[cssclasseswithrefs]: #cssclasseswithrefs
|
|
818
952
|
[~validtargetorsource]: #utilsassignreactiveobjectvalidtargetorsource
|
|
819
953
|
[`utils/assignreactiveobject`]: #utilsassignreactiveobject
|
|
@@ -832,19 +966,29 @@ A CSS object or a space-separated list of CSS classes.
|
|
|
832
966
|
[`cssclasseswithrefs`]: #cssclasseswithrefs
|
|
833
967
|
[`listinstance`]: #listinstance
|
|
834
968
|
[`listinstanceoptions`]: #listinstanceoptions
|
|
969
|
+
[`listsearchinstance`]: #listsearchinstance
|
|
970
|
+
[`listsearchinstanceoptions`]: #listsearchinstanceoptions
|
|
835
971
|
[`listsubscription`]: #listsubscription
|
|
836
972
|
[`listsubscriptionoptions`]: #listsubscriptionoptions
|
|
837
973
|
[`objectinstanceinstance`]: #objectinstanceinstance
|
|
974
|
+
[`searchinstance`]: #searchinstance
|
|
975
|
+
[`searchprops`]: #searchprops
|
|
838
976
|
[`listinstancestate`]: #listinstancestate
|
|
977
|
+
[`listsearchprops`]: #listsearchprops
|
|
839
978
|
[`listsubscriptionstate`]: #listsubscriptionstate
|
|
840
979
|
[`objectinstanceprops`]: #objectinstanceprops
|
|
841
980
|
[`objectcrudfunctions`]: #objectcrudfunctions
|
|
842
981
|
[`objectinstancestate`]: #objectinstancestate
|
|
982
|
+
[`searchstate`]: #searchstate
|
|
983
|
+
[`documentoptions`]: #documentoptions
|
|
984
|
+
[`searchoptions`]: #searchoptions
|
|
843
985
|
[usecombineclasses(classes)]: #usecombineclassesclasses
|
|
844
986
|
[uselistinstance(options)]: #uselistinstanceoptions
|
|
987
|
+
[uselistsearch(options)]: #uselistsearchoptions
|
|
845
988
|
[uselistsubscription(options)]: #uselistsubscriptionoptions
|
|
846
989
|
[useobjectinstances(instanceargs)]: #useobjectinstancesinstanceargs
|
|
847
990
|
[useobjectinstance(options)]: #useobjectinstanceoptions
|
|
991
|
+
[usesearch(options)]: #usesearchoptions
|
|
848
992
|
[~addreactiveobject(target, source, \[exclude\], \[addedkeys\])]: #utilsassignreactiveobjectaddreactiveobjecttarget-source-exclude-addedkeys
|
|
849
993
|
[~updatereactiveobject(target, source, \[exclude\], \[samekeys\])]: #utilsassignreactiveobjectupdatereactiveobjecttarget-source-exclude-samekeys
|
|
850
994
|
[~addorupdatereactiveobject(target, source, \[exclude\], \[addedkeys\], \[samekeys\])]: #utilsassignreactiveobjectaddorupdatereactiveobjecttarget-source-exclude-addedkeys-samekeys
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrai-innovations/reactive-helpers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -43,11 +43,13 @@
|
|
|
43
43
|
"eslint-plugin-vue": "^8.7.1",
|
|
44
44
|
"flush-promises": "^1.0.2",
|
|
45
45
|
"jsdoc-to-markdown": "^8.0.0",
|
|
46
|
+
"jsdom": "^22.1.0",
|
|
46
47
|
"lint-staged": "^13.2.2",
|
|
47
48
|
"prettier": "2.6.2",
|
|
48
49
|
"vitest": "^0.34.1"
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
52
|
+
"@jcoreio/async-throttle": "^1.6.0",
|
|
51
53
|
"browser-util-inspect": "^0.2.0",
|
|
52
54
|
"flexsearch": "0.7.21",
|
|
53
55
|
"husky": "^7.0.4",
|