@arrai-innovations/reactive-helpers 11.4.2 → 13.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/.husky/pre-commit +0 -1
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.prettierignore +1 -0
- package/README.md +11 -10
- package/config/listCrud.js +32 -1
- package/config/objectCrud.js +47 -1
- package/docs/README.md +43 -0
- package/docs/config/listCrud.md +97 -0
- package/docs/config/objectCrud.md +123 -0
- package/docs/use/cancellableIntent.md +163 -0
- package/docs/use/combineClasses.md +52 -0
- package/docs/use/list.md +285 -0
- package/docs/use/listCalculated.md +773 -0
- package/docs/use/listFilter.md +877 -0
- package/docs/use/listInstance.md +483 -0
- package/docs/use/listKeys.md +91 -0
- package/docs/use/listRelated.md +685 -0
- package/docs/use/listSearch.md +889 -0
- package/docs/use/listSort.md +1144 -0
- package/docs/use/listSubscription.md +379 -0
- package/docs/use/loadingError.md +21 -0
- package/docs/use/object.md +437 -0
- package/docs/use/objectCalculated.md +606 -0
- package/docs/use/objectInstance.md +486 -0
- package/docs/use/objectRelated.md +588 -0
- package/docs/use/objectSubscription.md +459 -0
- package/docs/use/paginatedListInstance.md +147 -0
- package/docs/use/search.md +311 -0
- package/docs/use/watchesRunning.md +80 -0
- package/docs/utils/assignReactiveObject.md +351 -0
- package/docs/utils/classes.md +100 -0
- package/docs/utils/compact.md +57 -0
- package/docs/utils/deleteKey.md +53 -0
- package/docs/utils/flattenPaths.md +45 -0
- package/docs/utils/getFakeId.md +34 -0
- package/docs/utils/keyDiff.md +101 -0
- package/docs/utils/loadingCombine.md +28 -0
- package/docs/utils/proxyRunning.md +33 -0
- package/docs/utils/relatedCalculatedHelpers.md +75 -0
- package/docs/utils/set.md +139 -0
- package/docs/utils/transformWalk.md +33 -0
- package/docs/utils/watches.md +441 -0
- package/eslint.config.js +125 -0
- package/index.js +34 -3
- package/lint-staged.config.js +5 -1
- package/makeTypeDoc.sh +25 -0
- package/package.json +27 -19
- package/tests/unit/config/listCrud.spec.js +5 -0
- package/tests/unit/config/objectCrud.spec.js +5 -0
- package/tests/unit/crudPromise.js +22 -3
- package/tests/unit/mockOnUnmounted.js +1 -1
- package/tests/unit/use/cancellableIntent.spec.js +2 -0
- package/tests/unit/use/listCalculated.spec.js +4 -3
- package/tests/unit/use/listFilter.spec.js +11 -7
- package/tests/unit/use/listInstance.spec.js +32 -14
- package/tests/unit/use/listRelated.spec.js +3 -2
- package/tests/unit/use/listSearch.spec.js +9 -7
- package/tests/unit/use/listSort.spec.js +29 -22
- package/tests/unit/use/listSubscription.spec.js +11 -5
- package/tests/unit/use/objectInstance.spec.js +15 -2
- package/tests/unit/use/objectSubscription.spec.js +31 -16
- package/tests/unit/use/search.spec.js +2 -2
- package/tests/unit/utils/assignReactiveObject.spec.js +21 -13
- package/tests/unit/utils/classes.spec.js +7 -6
- package/tests/unit/utils/watches.spec.js +4 -4
- package/tsconfig.json +19 -0
- package/typedoc-local-plugins/customize-output.js +13 -0
- package/typedoc.json +12 -0
- package/use/cancellableIntent.js +73 -2
- package/use/combineClasses.js +41 -31
- package/use/list.js +139 -5
- package/use/listCalculated.js +175 -10
- package/use/listFilter.js +175 -21
- package/use/listInstance.js +215 -94
- package/use/listRelated.js +260 -72
- package/use/listSearch.js +178 -57
- package/use/listSort.js +188 -21
- package/use/listSubscription.js +211 -63
- package/use/loadingError.js +43 -0
- package/use/object.js +187 -23
- package/use/objectCalculated.js +168 -16
- package/use/objectInstance.js +183 -102
- package/use/objectRelated.js +276 -84
- package/use/objectSubscription.js +169 -17
- package/use/paginatedListInstance.js +30 -1
- package/use/search.js +39 -23
- package/use/watchesRunning.js +41 -6
- package/utils/assignReactiveObject.js +139 -88
- package/utils/classes.js +57 -48
- package/utils/compact.js +28 -2
- package/utils/deleteKey.js +14 -1
- package/utils/flattenPaths.js +19 -9
- package/utils/getFakeId.js +11 -1
- package/utils/keyDiff.js +26 -35
- package/utils/loadingCombine.js +7 -4
- package/utils/proxyRunning.js +16 -8
- package/utils/relatedCalculatedHelpers.js +17 -0
- package/utils/set.js +66 -0
- package/utils/transformWalk.js +7 -6
- package/utils/watches.js +205 -71
- package/.eslintignore +0 -2
- package/.eslintrc.cjs +0 -25
- package/.jsdoc2md.json +0 -4
- package/config/index.js +0 -2
- package/docs.md +0 -1002
- package/jsdoc-to-markdown.sh +0 -16
- package/tests/unit/.eslintrc.cjs +0 -11
- package/tests/unit/config/index.spec.js +0 -18
- package/tests/unit/use/index.spec.js +0 -18
- package/tests/unit/utils/index.spec.js +0 -18
- package/use/index.js +0 -19
- package/utils/debugMessage.js +0 -209
- package/utils/debugWatch.js +0 -29
- package/utils/index.js +0 -16
- package/utils/lifecycleDebug.js +0 -126
package/.husky/pre-commit
CHANGED
package/.prettierignore
CHANGED
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Vue.js 3 utility composition functions to help manipulate objects and lists.
|
|
|
14
14
|
- [Install](#install)
|
|
15
15
|
- [Usage](#usage)
|
|
16
16
|
- [Import](#import)
|
|
17
|
-
- [
|
|
17
|
+
- [Documentation](#documentation)
|
|
18
18
|
- [List](#list)
|
|
19
19
|
- [Instance](#instance)
|
|
20
20
|
- [Subscription](#subscription)
|
|
@@ -55,11 +55,9 @@ import { useListInstance } from "@arrai-innovations/reactive-helpers/use/listIns
|
|
|
55
55
|
import { useObjectInstance } from "@arrai-innovations/reactive-helpers/use";
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
### Documentation
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
[View the JSDocs](./docs.md)
|
|
60
|
+
See the [generated documentation](./docs/README.md) for list of available modules and imports.
|
|
63
61
|
|
|
64
62
|
### List
|
|
65
63
|
|
|
@@ -587,7 +585,10 @@ setObjectCrud({
|
|
|
587
585
|
```js
|
|
588
586
|
// similar to list, but for a single object.
|
|
589
587
|
import {
|
|
590
|
-
useObjectInstance,
|
|
588
|
+
useObjectInstance,
|
|
589
|
+
useObjectSubscription,
|
|
590
|
+
useObjectRelated,
|
|
591
|
+
useObjectCalculated,
|
|
591
592
|
} from "@arrai-innovations/reactive-helpers";
|
|
592
593
|
|
|
593
594
|
const contactObject = useObjectInstance({
|
|
@@ -599,12 +600,12 @@ const contactObject = useObjectInstance({
|
|
|
599
600
|
fields: ["id", "has_name", "lexical_name", "organization", "phone"],
|
|
600
601
|
},
|
|
601
602
|
id: contactId,
|
|
602
|
-
}
|
|
603
|
+
},
|
|
603
604
|
});
|
|
604
605
|
console.log(contactObject.state.object);
|
|
605
606
|
const contactSubscription = useObjectSubscription({
|
|
606
607
|
objectInstance: contactObject,
|
|
607
|
-
})
|
|
608
|
+
});
|
|
608
609
|
// or
|
|
609
610
|
const contactSubscription = useObjectSubscription({
|
|
610
611
|
props: {
|
|
@@ -615,7 +616,7 @@ const contactSubscription = useObjectSubscription({
|
|
|
615
616
|
fields: ["id", "has_name", "lexical_name", "organization", "phone"],
|
|
616
617
|
},
|
|
617
618
|
id: contactId,
|
|
618
|
-
}
|
|
619
|
+
},
|
|
619
620
|
});
|
|
620
621
|
console.log(contactSubscription.state.object);
|
|
621
622
|
const organizations = useList({
|
|
@@ -626,7 +627,7 @@ const organizations = useList({
|
|
|
626
627
|
retrieveArgs: {
|
|
627
628
|
fields: ["id", "name"],
|
|
628
629
|
},
|
|
629
|
-
}
|
|
630
|
+
},
|
|
630
631
|
});
|
|
631
632
|
await organizations.list();
|
|
632
633
|
const contactRelated = useObjectRelated({
|
package/config/listCrud.js
CHANGED
|
@@ -9,6 +9,24 @@ const defaultCrud = {
|
|
|
9
9
|
subscribe: undefined,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} ListCrudFunctions
|
|
14
|
+
* @property {Function} [list] - The list function to get a list of items.
|
|
15
|
+
* @property {Function} [subscribe] - The subscribe function to get a subscription to a list of items.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {object} ListCrudArgs
|
|
20
|
+
* @property {object} [args={}] - The default arguments for the crud functions.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Set the list and subscribe functions for the default crud.
|
|
25
|
+
*
|
|
26
|
+
* @param {ListCrudFunctions & Partial<ListCrudArgs>} options - The options for the default crud.
|
|
27
|
+
* @throws {Error} - If unknown keys are passed.
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
12
30
|
export const setListCrud = ({ list, subscribe, args = {}, ...rest }) => {
|
|
13
31
|
defaultCrud.list = list;
|
|
14
32
|
defaultCrud.subscribe = subscribe;
|
|
@@ -18,6 +36,16 @@ export const setListCrud = ({ list, subscribe, args = {}, ...rest }) => {
|
|
|
18
36
|
}
|
|
19
37
|
};
|
|
20
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Get the previously set list and subscribe functions for the default crud.
|
|
41
|
+
*
|
|
42
|
+
* @param {import("vue").UnwrapNestedRefs<ListCrudFunctions & ListCrudArgs>} reactiveCrud - The reactive crud object, which will be mutated.
|
|
43
|
+
* @param {object} options - The options for the default crud.
|
|
44
|
+
* @param {import("vue").UnwrapNestedRefs<{
|
|
45
|
+
* crudArgs: object|undefined,
|
|
46
|
+
* }>} [options.props] - The props to set for the crud.
|
|
47
|
+
* @param {ListCrudFunctions & ListCrudArgs} [options.functions] - The functions to set for the crud.
|
|
48
|
+
*/
|
|
21
49
|
export const getListCrud = (reactiveCrud, { props, functions } = {}) => {
|
|
22
50
|
// don't mutate the default crud
|
|
23
51
|
Object.assign(reactiveCrud, cloneDeep(defaultCrud));
|
|
@@ -27,7 +55,10 @@ export const getListCrud = (reactiveCrud, { props, functions } = {}) => {
|
|
|
27
55
|
if (functions) {
|
|
28
56
|
for (const [key, value] of Object.entries(functions)) {
|
|
29
57
|
if (isFunction(value) && key in reactiveCrud) {
|
|
30
|
-
reactiveCrud[key] = isReactive(functions)
|
|
58
|
+
reactiveCrud[key] = isReactive(functions)
|
|
59
|
+
? // @ts-ignore - this is a valid key...
|
|
60
|
+
toRef(functions, key)
|
|
61
|
+
: value;
|
|
31
62
|
} else {
|
|
32
63
|
throw Error(`Invalid function "${key}" for getListCrud: invalid key or not a function.`);
|
|
33
64
|
}
|
package/config/objectCrud.js
CHANGED
|
@@ -13,6 +13,38 @@ const defaultCrud = {
|
|
|
13
13
|
subscribe: undefined,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Defines the CRUD-related functions and additional utilities provided by the object instance.
|
|
18
|
+
*
|
|
19
|
+
* @typedef {object} ObjectCrudArgsProperties
|
|
20
|
+
* @property {object} [args={}] - The arguments to be passed to the crud functions.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Defines the CRUD-related functions and additional utilities provided by the object instance.
|
|
25
|
+
*
|
|
26
|
+
* @typedef {object} ObjectCrudFunctions
|
|
27
|
+
* @property {Function} [create] - A function to be used instead of the default crud create function.
|
|
28
|
+
* @property {Function} [retrieve] - A function to be used instead of the default crud retrieve function.
|
|
29
|
+
* @property {Function} [update] - A function to be used instead of the default crud update function.
|
|
30
|
+
* @property {Function} [delete] - A function to be used instead of the default crud delete function.
|
|
31
|
+
* @property {Function} [patch] - A function to be used instead of the default crud patch function.
|
|
32
|
+
* @property {Function} [subscribe] - A function to be used instead of the default crud subscribe function.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The CRUD arguments.
|
|
37
|
+
*
|
|
38
|
+
* @typedef {ObjectCrudArgsProperties & ObjectCrudFunctions} ObjectCrudArgs
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set the object crud functions.
|
|
44
|
+
*
|
|
45
|
+
* @param {ObjectCrudArgs} options - The options for the object crud functions.
|
|
46
|
+
* @throws {Error} - if unknown keys are passed.
|
|
47
|
+
*/
|
|
16
48
|
export const setObjectCrud = ({ retrieve, create, update, patch, delete: deleteFn, subscribe, args = {}, ...rest }) => {
|
|
17
49
|
defaultCrud.retrieve = retrieve;
|
|
18
50
|
defaultCrud.create = create;
|
|
@@ -27,6 +59,17 @@ export const setObjectCrud = ({ retrieve, create, update, patch, delete: deleteF
|
|
|
27
59
|
}
|
|
28
60
|
};
|
|
29
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Get the previously set object crud functions.
|
|
64
|
+
*
|
|
65
|
+
* @param {import("vue").UnwrapNestedRefs<object>} reactiveCrud - The reactive object you want to add the resulting crud to.
|
|
66
|
+
* @param {object} options - The options for the reactive crud object.
|
|
67
|
+
* @param {import("vue").UnwrapNestedRefs<{
|
|
68
|
+
* crudArgs: ObjectCrudArgsProperties|undefined,
|
|
69
|
+
* }>} [options.props] - The props with any passed crudArgs.
|
|
70
|
+
* @param {ObjectCrudFunctions} [options.functions] - Any functions to override the default crud functions.
|
|
71
|
+
* @throws {Error} - If an invalid function is passed, or if the function is not a function.
|
|
72
|
+
*/
|
|
30
73
|
export const getObjectCrud = (reactiveCrud, { props, functions } = {}) => {
|
|
31
74
|
// don't mutate the default crud
|
|
32
75
|
Object.assign(reactiveCrud, cloneDeep(defaultCrud));
|
|
@@ -36,7 +79,10 @@ export const getObjectCrud = (reactiveCrud, { props, functions } = {}) => {
|
|
|
36
79
|
if (functions) {
|
|
37
80
|
for (const [key, value] of Object.entries(functions)) {
|
|
38
81
|
if (isFunction(value) && key in reactiveCrud) {
|
|
39
|
-
reactiveCrud[key] = isReactive(functions)
|
|
82
|
+
reactiveCrud[key] = isReactive(functions)
|
|
83
|
+
? // @ts-ignore - key is a keyof ObjectCrudFunctions...
|
|
84
|
+
toRef(functions, key)
|
|
85
|
+
: value;
|
|
40
86
|
} else {
|
|
41
87
|
throw Error(`Invalid function "${key}" for getObjectCrud: invalid key or not a function.`);
|
|
42
88
|
}
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
**@arrai-innovations/reactive-helpers** • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# @arrai-innovations/reactive-helpers
|
|
6
|
+
|
|
7
|
+
## Modules
|
|
8
|
+
|
|
9
|
+
- [config/listCrud](config/listCrud.md)
|
|
10
|
+
- [config/objectCrud](config/objectCrud.md)
|
|
11
|
+
- [use/cancellableIntent](use/cancellableIntent.md)
|
|
12
|
+
- [use/combineClasses](use/combineClasses.md)
|
|
13
|
+
- [use/list](use/list.md)
|
|
14
|
+
- [use/listCalculated](use/listCalculated.md)
|
|
15
|
+
- [use/listFilter](use/listFilter.md)
|
|
16
|
+
- [use/listInstance](use/listInstance.md)
|
|
17
|
+
- [use/listKeys](use/listKeys.md)
|
|
18
|
+
- [use/listRelated](use/listRelated.md)
|
|
19
|
+
- [use/listSearch](use/listSearch.md)
|
|
20
|
+
- [use/listSort](use/listSort.md)
|
|
21
|
+
- [use/listSubscription](use/listSubscription.md)
|
|
22
|
+
- [use/loadingError](use/loadingError.md)
|
|
23
|
+
- [use/object](use/object.md)
|
|
24
|
+
- [use/objectCalculated](use/objectCalculated.md)
|
|
25
|
+
- [use/objectInstance](use/objectInstance.md)
|
|
26
|
+
- [use/objectRelated](use/objectRelated.md)
|
|
27
|
+
- [use/objectSubscription](use/objectSubscription.md)
|
|
28
|
+
- [use/paginatedListInstance](use/paginatedListInstance.md)
|
|
29
|
+
- [use/search](use/search.md)
|
|
30
|
+
- [use/watchesRunning](use/watchesRunning.md)
|
|
31
|
+
- [utils/assignReactiveObject](utils/assignReactiveObject.md)
|
|
32
|
+
- [utils/classes](utils/classes.md)
|
|
33
|
+
- [utils/compact](utils/compact.md)
|
|
34
|
+
- [utils/deleteKey](utils/deleteKey.md)
|
|
35
|
+
- [utils/flattenPaths](utils/flattenPaths.md)
|
|
36
|
+
- [utils/getFakeId](utils/getFakeId.md)
|
|
37
|
+
- [utils/keyDiff](utils/keyDiff.md)
|
|
38
|
+
- [utils/loadingCombine](utils/loadingCombine.md)
|
|
39
|
+
- [utils/proxyRunning](utils/proxyRunning.md)
|
|
40
|
+
- [utils/relatedCalculatedHelpers](utils/relatedCalculatedHelpers.md)
|
|
41
|
+
- [utils/set](utils/set.md)
|
|
42
|
+
- [utils/transformWalk](utils/transformWalk.md)
|
|
43
|
+
- [utils/watches](utils/watches.md)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
[**@arrai-innovations/reactive-helpers**](../README.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@arrai-innovations/reactive-helpers](../README.md) / config/listCrud
|
|
6
|
+
|
|
7
|
+
# config/listCrud
|
|
8
|
+
|
|
9
|
+
## Interfaces
|
|
10
|
+
|
|
11
|
+
### ListCrudArgs
|
|
12
|
+
|
|
13
|
+
#### Properties
|
|
14
|
+
|
|
15
|
+
##### args
|
|
16
|
+
|
|
17
|
+
> **args**: `any`
|
|
18
|
+
|
|
19
|
+
The default arguments for the crud functions.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### ListCrudFunctions
|
|
24
|
+
|
|
25
|
+
#### Properties
|
|
26
|
+
|
|
27
|
+
##### list
|
|
28
|
+
|
|
29
|
+
> **list**: `Function`
|
|
30
|
+
|
|
31
|
+
The list function to get a list of items.
|
|
32
|
+
|
|
33
|
+
##### subscribe
|
|
34
|
+
|
|
35
|
+
> **subscribe**: `Function`
|
|
36
|
+
|
|
37
|
+
The subscribe function to get a subscription to a list of items.
|
|
38
|
+
|
|
39
|
+
## Functions
|
|
40
|
+
|
|
41
|
+
### getListCrud()
|
|
42
|
+
|
|
43
|
+
> **getListCrud**(`reactiveCrud`, `options`): `void`
|
|
44
|
+
|
|
45
|
+
Get the previously set list and subscribe functions for the default crud.
|
|
46
|
+
|
|
47
|
+
#### Parameters
|
|
48
|
+
|
|
49
|
+
• **reactiveCrud**
|
|
50
|
+
|
|
51
|
+
The reactive crud object, which will be mutated.
|
|
52
|
+
|
|
53
|
+
• **reactiveCrud.args**: `any`
|
|
54
|
+
|
|
55
|
+
The default arguments for the crud functions.
|
|
56
|
+
|
|
57
|
+
• **reactiveCrud.list**: `Function`
|
|
58
|
+
|
|
59
|
+
The list function to get a list of items.
|
|
60
|
+
|
|
61
|
+
• **reactiveCrud.subscribe**: `Function`
|
|
62
|
+
|
|
63
|
+
The subscribe function to get a subscription to a list of items.
|
|
64
|
+
|
|
65
|
+
• **options** = `{}`
|
|
66
|
+
|
|
67
|
+
The options for the default crud.
|
|
68
|
+
|
|
69
|
+
• **options.functions**: [`ListCrudFunctions`](listCrud.md#listcrudfunctions) & [`ListCrudArgs`](listCrud.md#listcrudargs)
|
|
70
|
+
|
|
71
|
+
The functions to set for the crud.
|
|
72
|
+
|
|
73
|
+
• **options.props**
|
|
74
|
+
|
|
75
|
+
The props to set for the crud.
|
|
76
|
+
|
|
77
|
+
• **options.props.crudArgs**: `any`
|
|
78
|
+
|
|
79
|
+
#### Returns
|
|
80
|
+
|
|
81
|
+
`void`
|
|
82
|
+
|
|
83
|
+
***
|
|
84
|
+
|
|
85
|
+
### setListCrud()
|
|
86
|
+
|
|
87
|
+
> **setListCrud**(`options`): `void`
|
|
88
|
+
|
|
89
|
+
#### Parameters
|
|
90
|
+
|
|
91
|
+
• **options**: [`ListCrudFunctions`](listCrud.md#listcrudfunctions) & `Partial`\<[`ListCrudArgs`](listCrud.md#listcrudargs)\>
|
|
92
|
+
|
|
93
|
+
The options for the default crud.
|
|
94
|
+
|
|
95
|
+
#### Returns
|
|
96
|
+
|
|
97
|
+
`void`
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
[**@arrai-innovations/reactive-helpers**](../README.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@arrai-innovations/reactive-helpers](../README.md) / config/objectCrud
|
|
6
|
+
|
|
7
|
+
# config/objectCrud
|
|
8
|
+
|
|
9
|
+
## Interfaces
|
|
10
|
+
|
|
11
|
+
### ObjectCrudArgsProperties
|
|
12
|
+
|
|
13
|
+
#### Properties
|
|
14
|
+
|
|
15
|
+
##### args
|
|
16
|
+
|
|
17
|
+
> **args**: `any`
|
|
18
|
+
|
|
19
|
+
The arguments to be passed to the crud functions.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### ObjectCrudFunctions
|
|
24
|
+
|
|
25
|
+
#### Properties
|
|
26
|
+
|
|
27
|
+
##### create
|
|
28
|
+
|
|
29
|
+
> **create**: `Function`
|
|
30
|
+
|
|
31
|
+
A function to be used instead of the default crud create function.
|
|
32
|
+
|
|
33
|
+
##### delete
|
|
34
|
+
|
|
35
|
+
> **delete**: `Function`
|
|
36
|
+
|
|
37
|
+
A function to be used instead of the default crud delete function.
|
|
38
|
+
|
|
39
|
+
##### patch
|
|
40
|
+
|
|
41
|
+
> **patch**: `Function`
|
|
42
|
+
|
|
43
|
+
A function to be used instead of the default crud patch function.
|
|
44
|
+
|
|
45
|
+
##### retrieve
|
|
46
|
+
|
|
47
|
+
> **retrieve**: `Function`
|
|
48
|
+
|
|
49
|
+
A function to be used instead of the default crud retrieve function.
|
|
50
|
+
|
|
51
|
+
##### subscribe
|
|
52
|
+
|
|
53
|
+
> **subscribe**: `Function`
|
|
54
|
+
|
|
55
|
+
A function to be used instead of the default crud subscribe function.
|
|
56
|
+
|
|
57
|
+
##### update
|
|
58
|
+
|
|
59
|
+
> **update**: `Function`
|
|
60
|
+
|
|
61
|
+
A function to be used instead of the default crud update function.
|
|
62
|
+
|
|
63
|
+
## Type Aliases
|
|
64
|
+
|
|
65
|
+
### ObjectCrudArgs
|
|
66
|
+
|
|
67
|
+
> **ObjectCrudArgs**\<\>: [`ObjectCrudArgsProperties`](objectCrud.md#objectcrudargsproperties) & [`ObjectCrudFunctions`](objectCrud.md#objectcrudfunctions)
|
|
68
|
+
|
|
69
|
+
#### Type Parameters
|
|
70
|
+
|
|
71
|
+
## Functions
|
|
72
|
+
|
|
73
|
+
### getObjectCrud()
|
|
74
|
+
|
|
75
|
+
> **getObjectCrud**(`reactiveCrud`, `options`): `void`
|
|
76
|
+
|
|
77
|
+
Get the previously set object crud functions.
|
|
78
|
+
|
|
79
|
+
#### Parameters
|
|
80
|
+
|
|
81
|
+
• **reactiveCrud**: `any`
|
|
82
|
+
|
|
83
|
+
The reactive object you want to add the resulting crud to.
|
|
84
|
+
|
|
85
|
+
• **options** = `{}`
|
|
86
|
+
|
|
87
|
+
The options for the reactive crud object.
|
|
88
|
+
|
|
89
|
+
• **options.functions**: [`ObjectCrudFunctions`](objectCrud.md#objectcrudfunctions)
|
|
90
|
+
|
|
91
|
+
Any functions to override the default crud functions.
|
|
92
|
+
|
|
93
|
+
• **options.props**
|
|
94
|
+
|
|
95
|
+
The props with any passed crudArgs.
|
|
96
|
+
|
|
97
|
+
• **options.props.crudArgs**
|
|
98
|
+
|
|
99
|
+
• **options.props.crudArgs.args**: `any`
|
|
100
|
+
|
|
101
|
+
The arguments to be passed to the crud functions.
|
|
102
|
+
|
|
103
|
+
#### Returns
|
|
104
|
+
|
|
105
|
+
`void`
|
|
106
|
+
|
|
107
|
+
***
|
|
108
|
+
|
|
109
|
+
### setObjectCrud()
|
|
110
|
+
|
|
111
|
+
> **setObjectCrud**(`options`): `void`
|
|
112
|
+
|
|
113
|
+
Set the object crud functions.
|
|
114
|
+
|
|
115
|
+
#### Parameters
|
|
116
|
+
|
|
117
|
+
• **options**: [`ObjectCrudArgs`](objectCrud.md#objectcrudargs)
|
|
118
|
+
|
|
119
|
+
The options for the object crud functions.
|
|
120
|
+
|
|
121
|
+
#### Returns
|
|
122
|
+
|
|
123
|
+
`void`
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
[**@arrai-innovations/reactive-helpers**](../README.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@arrai-innovations/reactive-helpers](../README.md) / use/cancellableIntent
|
|
6
|
+
|
|
7
|
+
# use/cancellableIntent
|
|
8
|
+
|
|
9
|
+
## Interfaces
|
|
10
|
+
|
|
11
|
+
### CancellableIntent
|
|
12
|
+
|
|
13
|
+
The instance of the cancellable intent.
|
|
14
|
+
|
|
15
|
+
#### Properties
|
|
16
|
+
|
|
17
|
+
##### cancel
|
|
18
|
+
|
|
19
|
+
> **cancel**: `Function`
|
|
20
|
+
|
|
21
|
+
Cancel the cancellable intent.
|
|
22
|
+
|
|
23
|
+
##### guardArguments
|
|
24
|
+
|
|
25
|
+
> **guardArguments**: `any`
|
|
26
|
+
|
|
27
|
+
The guard arguments.
|
|
28
|
+
|
|
29
|
+
##### state
|
|
30
|
+
|
|
31
|
+
> **state**: `any`
|
|
32
|
+
|
|
33
|
+
The state of the cancellable intent.
|
|
34
|
+
|
|
35
|
+
##### stop
|
|
36
|
+
|
|
37
|
+
> **stop**: `Function`
|
|
38
|
+
|
|
39
|
+
Stop the cancellable intent.
|
|
40
|
+
|
|
41
|
+
##### watchArguments
|
|
42
|
+
|
|
43
|
+
> **watchArguments**: `any`
|
|
44
|
+
|
|
45
|
+
The watch arguments.
|
|
46
|
+
|
|
47
|
+
***
|
|
48
|
+
|
|
49
|
+
### CancellableIntentOptions
|
|
50
|
+
|
|
51
|
+
The options for the cancellable intent.
|
|
52
|
+
|
|
53
|
+
#### Properties
|
|
54
|
+
|
|
55
|
+
##### awaitableWithCancel()
|
|
56
|
+
|
|
57
|
+
> **awaitableWithCancel**: () => [`CancellablePromise`](cancellableIntent.md#cancellablepromise)
|
|
58
|
+
|
|
59
|
+
The function that returns a promise that can be cancelled.
|
|
60
|
+
|
|
61
|
+
###### Returns
|
|
62
|
+
|
|
63
|
+
[`CancellablePromise`](cancellableIntent.md#cancellablepromise)
|
|
64
|
+
|
|
65
|
+
##### clearActiveOnResolved
|
|
66
|
+
|
|
67
|
+
> **clearActiveOnResolved**: `boolean`
|
|
68
|
+
|
|
69
|
+
Whether to clear the active state when the promise resolves.
|
|
70
|
+
|
|
71
|
+
##### guardArguments
|
|
72
|
+
|
|
73
|
+
> **guardArguments**: `any`
|
|
74
|
+
|
|
75
|
+
The reactive object to watch for truthiness before running the intent.
|
|
76
|
+
|
|
77
|
+
##### watchArguments
|
|
78
|
+
|
|
79
|
+
> **watchArguments**: `any`
|
|
80
|
+
|
|
81
|
+
The reactive object to watch for changes.
|
|
82
|
+
|
|
83
|
+
## Type Aliases
|
|
84
|
+
|
|
85
|
+
### CancellableIntentState
|
|
86
|
+
|
|
87
|
+
> **CancellableIntentState**\<\>: `UnwrapNestedRefs`
|
|
88
|
+
|
|
89
|
+
The state of the cancellable intent.
|
|
90
|
+
|
|
91
|
+
#### Type Parameters
|
|
92
|
+
|
|
93
|
+
***
|
|
94
|
+
|
|
95
|
+
### CancellablePromise
|
|
96
|
+
|
|
97
|
+
> **CancellablePromise**\<\>: `Promise`\<`any`\> & `object`
|
|
98
|
+
|
|
99
|
+
#### Type declaration
|
|
100
|
+
|
|
101
|
+
##### cancel()
|
|
102
|
+
|
|
103
|
+
> **cancel**: () => `Promise`\<`void`\> \| `void`
|
|
104
|
+
|
|
105
|
+
###### Returns
|
|
106
|
+
|
|
107
|
+
`Promise`\<`void`\> \| `void`
|
|
108
|
+
|
|
109
|
+
#### Type Parameters
|
|
110
|
+
|
|
111
|
+
## Functions
|
|
112
|
+
|
|
113
|
+
### useCancellableIntent()
|
|
114
|
+
|
|
115
|
+
> **useCancellableIntent**(`options`): [`CancellableIntent`](cancellableIntent.md#cancellableintent)
|
|
116
|
+
|
|
117
|
+
Calls your awaitable function with the arguments you pass in when the watch arguments change and are all truthy.
|
|
118
|
+
Watch arguments should be a reactive object.
|
|
119
|
+
If the promise is not resolved before the watch arguments change again, the previous promise is cancelled.
|
|
120
|
+
|
|
121
|
+
#### Parameters
|
|
122
|
+
|
|
123
|
+
• **options**: [`CancellableIntentOptions`](cancellableIntent.md#cancellableintentoptions)
|
|
124
|
+
|
|
125
|
+
The options for the cancellable intent.
|
|
126
|
+
|
|
127
|
+
#### Returns
|
|
128
|
+
|
|
129
|
+
[`CancellableIntent`](cancellableIntent.md#cancellableintent)
|
|
130
|
+
|
|
131
|
+
- The instance of the cancellable intent.
|
|
132
|
+
|
|
133
|
+
#### Example
|
|
134
|
+
|
|
135
|
+
```vue
|
|
136
|
+
<script setup>
|
|
137
|
+
import { useCancellableIntent } from "@vueda/use/cancellableIntent.js";
|
|
138
|
+
import { ref, computed, onMounted, onUnmounted } from "vue";
|
|
139
|
+
|
|
140
|
+
const myValue = ref(0);
|
|
141
|
+
const myOtherValue = ref(0);
|
|
142
|
+
|
|
143
|
+
const myIntent = useCancellableIntent({
|
|
144
|
+
awaitableWithCancel: async () => {
|
|
145
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
146
|
+
console.log("resolved");
|
|
147
|
+
return true;
|
|
148
|
+
},
|
|
149
|
+
watchArguments: { myValue, myOtherValue },
|
|
150
|
+
guardArguments: { myValue: computed(() => myValue.value > 0) },
|
|
151
|
+
clearActiveOnResolved: true,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
onMounted(() => {
|
|
155
|
+
setTimeout(() => {
|
|
156
|
+
myValue.value = 1;
|
|
157
|
+
myOtherValue.value = 1;
|
|
158
|
+
}, 500);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
onUnmounted(() => myIntent.stop());
|
|
162
|
+
</script>
|
|
163
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[**@arrai-innovations/reactive-helpers**](../README.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@arrai-innovations/reactive-helpers](../README.md) / use/combineClasses
|
|
6
|
+
|
|
7
|
+
# use/combineClasses
|
|
8
|
+
|
|
9
|
+
## Functions
|
|
10
|
+
|
|
11
|
+
### useCombineClasses()
|
|
12
|
+
|
|
13
|
+
> **useCombineClasses**(...`classes`): `Ref`\<[`CombinedClasses`](../utils/classes.md#combinedclasses)\>
|
|
14
|
+
|
|
15
|
+
Normalize various ways of specifying CSS classes into an object for use in Vue.js with reactivity. If refs are
|
|
16
|
+
present, the resulting object will be a ref containing an array of objects to preserve order of operations in
|
|
17
|
+
reactive contexts.
|
|
18
|
+
|
|
19
|
+
#### Parameters
|
|
20
|
+
|
|
21
|
+
• ...**classes**: (`string` \| `string`[] \| `object` \| `Ref`\<`string` \| `string`[]\>)[]
|
|
22
|
+
|
|
23
|
+
A mixed array containing multiple ways of specifying CSS classes.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`Ref`\<[`CombinedClasses`](../utils/classes.md#combinedclasses)\>
|
|
28
|
+
|
|
29
|
+
- A ref
|
|
30
|
+
containing an object or array of objects containing CSS classes. Arrays are used if refs are present, to
|
|
31
|
+
preserve order of operations in reactive contexts.
|
|
32
|
+
|
|
33
|
+
#### Example
|
|
34
|
+
|
|
35
|
+
```vue
|
|
36
|
+
<script setup>
|
|
37
|
+
import { useCombineClasses } from "@vueda/use/combineClasses.js";
|
|
38
|
+
import { ref } from "vue";
|
|
39
|
+
const myClasses = useCombineClasses(
|
|
40
|
+
"class1",
|
|
41
|
+
["class2", "class3"],
|
|
42
|
+
{ class4: true, class5: false },
|
|
43
|
+
ref("class6"),
|
|
44
|
+
ref(["class7", "class8"]),
|
|
45
|
+
ref({ class9: true, class10: false }),
|
|
46
|
+
);
|
|
47
|
+
// myClasses.value = [
|
|
48
|
+
// { class1: true, class2: true, class3: true, class4: true, class5: false },
|
|
49
|
+
// { class6: true, class7: true, class8: true, class9: true, class10: false }
|
|
50
|
+
// ]
|
|
51
|
+
</script>
|
|
52
|
+
```
|