@arrai-innovations/reactive-helpers 21.1.2 → 22.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/LICENSE +28 -0
- package/README.md +109 -21
- package/config/commonCrud.js +4 -6
- package/config/listCrud.js +20 -22
- package/config/objectCrud.js +30 -37
- package/package.json +93 -89
- package/types/config/listCrud.d.ts +83 -26
- package/types/config/objectCrud.d.ts +123 -44
- package/types/use/cancellableIntent.d.ts +27 -31
- package/types/use/combineClasses.d.ts +4 -1
- package/types/use/error.d.ts +39 -19
- package/types/use/list.d.ts +27 -26
- package/types/use/listCalculated.d.ts +21 -39
- package/types/use/listFilter.d.ts +25 -33
- package/types/use/listInstance.d.ts +88 -80
- package/types/use/listRelated.d.ts +26 -46
- package/types/use/listSearch.d.ts +54 -52
- package/types/use/listSort.d.ts +25 -39
- package/types/use/listSubscription.d.ts +28 -35
- package/types/use/loading.d.ts +20 -10
- package/types/use/loadingError.d.ts +12 -3
- package/types/use/object.d.ts +8 -5
- package/types/use/objectCalculated.d.ts +30 -27
- package/types/use/objectInstance.d.ts +67 -73
- package/types/use/objectRelated.d.ts +41 -33
- package/types/use/objectSubscription.d.ts +32 -43
- package/types/use/proxyError.d.ts +15 -6
- package/types/use/proxyLoading.d.ts +11 -5
- package/types/use/proxyLoadingError.d.ts +19 -7
- package/types/use/search.d.ts +33 -29
- package/types/utils/assignReactiveObject.d.ts +3 -0
- package/types/utils/cancellablePromise.d.ts +5 -5
- package/types/utils/classes.d.ts +7 -1
- package/types/utils/deepUnref.d.ts +1 -1
- package/types/utils/isReactiveTyped.d.ts +2 -0
- package/types/utils/keyDiff.d.ts +4 -6
- package/types/utils/relatedCalculatedHelpers.d.ts +2 -0
- package/types/utils/watches.d.ts +1 -1
- package/use/cancellableIntent.js +27 -7
- package/use/combineClasses.js +1 -1
- package/use/error.js +10 -14
- package/use/list.js +6 -18
- package/use/listCalculated.js +7 -22
- package/use/listFilter.js +8 -21
- package/use/listInstance.js +25 -44
- package/use/listRelated.js +9 -28
- package/use/listSearch.js +8 -17
- package/use/listSort.js +27 -41
- package/use/listSubscription.js +10 -25
- package/use/loading.js +5 -7
- package/use/loadingError.js +3 -3
- package/use/object.js +7 -19
- package/use/objectCalculated.js +9 -15
- package/use/objectInstance.js +46 -47
- package/use/objectRelated.js +13 -20
- package/use/objectSubscription.js +11 -25
- package/use/proxyError.js +10 -10
- package/use/proxyLoading.js +5 -5
- package/use/proxyLoadingError.js +10 -8
- package/use/search.js +5 -11
- package/utils/assignReactiveObject.js +3 -3
- package/utils/cancellablePromise.js +4 -4
- package/utils/classes.js +2 -2
- package/utils/deepUnref.js +1 -5
- package/utils/isReactiveTyped.js +2 -0
- package/utils/keyDiff.js +1 -3
- package/utils/relatedCalculatedHelpers.js +2 -0
package/types/use/search.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A reactive object for passing document options or search options to useSearch.
|
|
3
|
-
*
|
|
4
|
-
* @typedef {object} SearchProps
|
|
2
|
+
* @typedef {object} SearchProps - A reactive object for passing document options or search options to useSearch.
|
|
5
3
|
* @property {DocumentOptions} customDocumentOptions - FlexSearch.Document options.
|
|
6
4
|
* @property {SearchOptions} customSearchOptions - Search options.
|
|
7
5
|
* @property {string} pkKey - The primary key field.
|
|
@@ -23,15 +21,15 @@ export function useSearch({ props, throttle }: {
|
|
|
23
21
|
*/
|
|
24
22
|
export type SearchProps = {
|
|
25
23
|
/**
|
|
26
|
-
*
|
|
24
|
+
* FlexSearch.Document options.
|
|
27
25
|
*/
|
|
28
26
|
customDocumentOptions: DocumentOptions;
|
|
29
27
|
/**
|
|
30
|
-
*
|
|
28
|
+
* Search options.
|
|
31
29
|
*/
|
|
32
30
|
customSearchOptions: SearchOptions;
|
|
33
31
|
/**
|
|
34
|
-
*
|
|
32
|
+
* The primary key field.
|
|
35
33
|
*/
|
|
36
34
|
pkKey: string;
|
|
37
35
|
};
|
|
@@ -40,7 +38,7 @@ export type SearchProps = {
|
|
|
40
38
|
*/
|
|
41
39
|
export type SearchOptions = {
|
|
42
40
|
/**
|
|
43
|
-
*
|
|
41
|
+
* Limit of results.
|
|
44
42
|
*/
|
|
45
43
|
limit: number;
|
|
46
44
|
};
|
|
@@ -49,95 +47,101 @@ export type SearchOptions = {
|
|
|
49
47
|
*/
|
|
50
48
|
export type DocumentOptions = {
|
|
51
49
|
/**
|
|
52
|
-
*
|
|
50
|
+
* The document field to use as an identifier. Populated from `pkKey`.
|
|
53
51
|
*/
|
|
54
52
|
id: string;
|
|
55
53
|
/**
|
|
56
|
-
*
|
|
54
|
+
* The document field to use as a tag. Default is false, can be set to a string.
|
|
57
55
|
*/
|
|
58
56
|
tag: boolean | string;
|
|
59
57
|
/**
|
|
60
|
-
*
|
|
58
|
+
* Fields to index. Can be a single string, an array of strings, or an array of objects specifying custom index options.
|
|
61
59
|
*/
|
|
62
60
|
index: string | string[] | object[];
|
|
63
61
|
/**
|
|
64
|
-
*
|
|
62
|
+
* Specifies if and what document fields to store. Can be false, a string, or an array of strings. Default is false.
|
|
65
63
|
*/
|
|
66
64
|
store: boolean | string | string[];
|
|
67
65
|
/**
|
|
68
|
-
*
|
|
66
|
+
* Specifies the tokenizer to use.
|
|
69
67
|
*/
|
|
70
68
|
tokenizer?: string;
|
|
71
69
|
/**
|
|
72
|
-
*
|
|
70
|
+
* Minimum length of a token to be indexed.
|
|
73
71
|
*/
|
|
74
72
|
minLength?: number;
|
|
75
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* The raw reactive state of a search instance (query, results, status flags, and search options).
|
|
76
|
+
*/
|
|
76
77
|
export type SearchRawState = {
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
+
* The search string.
|
|
79
80
|
*/
|
|
80
81
|
search: string;
|
|
81
82
|
/**
|
|
82
|
-
*
|
|
83
|
+
* The results, where the keys are the ids of the objects that match, and the values are true.
|
|
83
84
|
*/
|
|
84
85
|
results: object;
|
|
85
86
|
/**
|
|
86
|
-
*
|
|
87
|
+
* Whether the search has been performed.
|
|
87
88
|
*/
|
|
88
89
|
searched: boolean;
|
|
89
90
|
/**
|
|
90
|
-
*
|
|
91
|
+
* Whether the search is currently running.
|
|
91
92
|
*/
|
|
92
93
|
searching: boolean;
|
|
93
94
|
/**
|
|
94
|
-
*
|
|
95
|
+
* FlexSearch.Document options.
|
|
95
96
|
*/
|
|
96
97
|
customDocumentOptions: DocumentOptions;
|
|
97
98
|
/**
|
|
98
|
-
*
|
|
99
|
+
* Search options.
|
|
99
100
|
*/
|
|
100
101
|
customSearchOptions: SearchOptions;
|
|
101
102
|
/**
|
|
102
|
-
*
|
|
103
|
+
* The number of times the search has been called.
|
|
103
104
|
*/
|
|
104
105
|
called: number;
|
|
105
106
|
/**
|
|
106
|
-
*
|
|
107
|
+
* The number of times the search has been called, but has not yet returned.
|
|
107
108
|
*/
|
|
108
109
|
pending: number;
|
|
109
110
|
/**
|
|
110
|
-
*
|
|
111
|
+
* Whether the search is currently running or has pending calls.
|
|
111
112
|
*/
|
|
112
113
|
running: boolean;
|
|
113
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* The reactive search instance returned by useSearch, exposing its state, index mutators, event target, and stop.
|
|
117
|
+
*/
|
|
114
118
|
export type SearchInstance = {
|
|
115
119
|
/**
|
|
116
|
-
*
|
|
120
|
+
* The state.
|
|
117
121
|
*/
|
|
118
122
|
state: import("vue").UnwrapNestedRefs<SearchRawState>;
|
|
119
123
|
/**
|
|
120
|
-
*
|
|
124
|
+
* Add an index.
|
|
121
125
|
*/
|
|
122
126
|
addIndex: Function;
|
|
123
127
|
/**
|
|
124
|
-
*
|
|
128
|
+
* Update an index.
|
|
125
129
|
*/
|
|
126
130
|
updateIndex: Function;
|
|
127
131
|
/**
|
|
128
|
-
*
|
|
132
|
+
* Remove an index.
|
|
129
133
|
*/
|
|
130
134
|
removeIndex: Function;
|
|
131
135
|
/**
|
|
132
|
-
*
|
|
136
|
+
* Clear the index.
|
|
133
137
|
*/
|
|
134
138
|
clearIndex: Function;
|
|
135
139
|
/**
|
|
136
|
-
*
|
|
140
|
+
* An event target.
|
|
137
141
|
*/
|
|
138
142
|
events: EventTarget;
|
|
139
143
|
/**
|
|
140
|
-
*
|
|
144
|
+
* Stop the effect scope.
|
|
141
145
|
*/
|
|
142
146
|
stop: Function;
|
|
143
147
|
};
|
|
@@ -111,4 +111,7 @@ export class AssignReactiveObjectError extends Error {
|
|
|
111
111
|
* and refs must ultimately resolve to objects or arrays
|
|
112
112
|
*/
|
|
113
113
|
export type ValidTargetOrSource = import("vue").Ref<object | any[]> | object | any[];
|
|
114
|
+
/**
|
|
115
|
+
* The validated target and source values returned by the reactive-object assignment validator.
|
|
116
|
+
*/
|
|
114
117
|
export type validateTargetAndSourceResult = object;
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @template T
|
|
5
5
|
* @param {Promise<T>} inner - The inner promise to wrap.
|
|
6
|
-
* @param {(() => Promise<void> | void)=} cancel - Optional cancel function.
|
|
6
|
+
* @param {((reason?: any) => Promise<void> | void)=} cancel - Optional cancel function.
|
|
7
7
|
* @returns {MaybeCancellablePromise<T>} The wrapped promise with an optional cancel method.
|
|
8
8
|
*/
|
|
9
|
-
export function wrapMaybeCancellable<T>(inner: Promise<T>, cancel?: (() => Promise<void> | void) | undefined): MaybeCancellablePromise<T>;
|
|
10
|
-
export function CancellablePromise<T>(promise: Promise<T>, cancel: () => (Promise<void> | void)): CancellablePromise<T>;
|
|
9
|
+
export function wrapMaybeCancellable<T>(inner: Promise<T>, cancel?: ((reason?: any) => Promise<void> | void) | undefined): MaybeCancellablePromise<T>;
|
|
10
|
+
export function CancellablePromise<T>(promise: Promise<T>, cancel: (reason?: any) => (Promise<void> | void)): CancellablePromise<T>;
|
|
11
11
|
/**
|
|
12
|
-
* A
|
|
12
|
+
* A promise augmented with a cancel method to abort the pending operation.
|
|
13
13
|
*/
|
|
14
14
|
export type CancellablePromise<T> = Promise<T> & {
|
|
15
15
|
cancel: (reason?: any) => Promise<void> | void;
|
|
@@ -32,7 +32,7 @@ export namespace CancellablePromise {
|
|
|
32
32
|
function resolve<T_1>(value: T_1): MaybeCancellablePromise<T_1>;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* A
|
|
35
|
+
* A promise that may optionally carry a cancel method to abort the pending operation.
|
|
36
36
|
*/
|
|
37
37
|
export type MaybeCancellablePromise<T> = Promise<T> & {
|
|
38
38
|
cancel?: (reason?: any) => Promise<void> | void;
|
package/types/utils/classes.d.ts
CHANGED
|
@@ -5,12 +5,18 @@ export function combineClasses(...classes: (CombinedClassesArgument | CombinedCl
|
|
|
5
5
|
export function stringifyClasses(...classes: (CombinedClassesArgument | CombinedClassesArgument[])[]): string;
|
|
6
6
|
export function stringifyClass(cls: CombinedClassesArgument | CombinedClassesArgument[] | null | undefined): string | null | undefined;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The normalized form of the CSS classes, either as a string of space-separated class names or an
|
|
9
9
|
*/
|
|
10
10
|
export type CombinedClasses = (string | {
|
|
11
11
|
[classnames: string]: boolean | import("vue").Ref<boolean>;
|
|
12
12
|
} | {
|
|
13
13
|
[classnames: string]: boolean | import("vue").Ref<boolean>;
|
|
14
14
|
}[]);
|
|
15
|
+
/**
|
|
16
|
+
* A boolean value or a Vue ref to a boolean.
|
|
17
|
+
*/
|
|
15
18
|
export type BooleanOrRef = boolean | import("vue").Ref<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* A single class-specifying argument accepted by combineClasses (a string, array, set, map, object, or ref).
|
|
21
|
+
*/
|
|
16
22
|
export type CombinedClassesArgument = string | string[] | Set<any> | Map<any, any> | object | import("vue").Ref<any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function deepUnref<T>(val: T): DeepUnwrap<T> | T;
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* A recursive type that unwraps Vue refs from a nested object, array, or primitive.
|
|
4
4
|
*/
|
|
5
5
|
export type DeepUnwrap<T> = T extends import("vue").Ref<infer U> ? DeepUnwrap<U> : T extends Array<infer V> ? Array<DeepUnwrap<V>> : T extends object ? { [K in keyof T]: DeepUnwrap<T[K]>; } : T;
|
package/types/utils/keyDiff.d.ts
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
* @module utils/keyDiff.js
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
|
-
* Result object of keyDiff and keyDiffDeep.
|
|
9
|
-
*
|
|
10
|
-
* @typedef {object} KeyDiffResult
|
|
8
|
+
* @typedef {object} KeyDiffResult - Result object of keyDiff and keyDiffDeep.
|
|
11
9
|
* @property {Set<string>} [sameKeys] - If sameKeys option is true, return keys that are the same.
|
|
12
10
|
* @property {Set<string>} [removedKeys] - If removedKeys option is true, return keys that are removed.
|
|
13
11
|
* @property {Set<string>} [addedKeys] - If addedKeys option is true, return keys that are added.
|
|
@@ -48,15 +46,15 @@ export function keyDiffDeep(newObj: object, oldObj: object, options?: object): K
|
|
|
48
46
|
*/
|
|
49
47
|
export type KeyDiffResult = {
|
|
50
48
|
/**
|
|
51
|
-
*
|
|
49
|
+
* If sameKeys option is true, return keys that are the same.
|
|
52
50
|
*/
|
|
53
51
|
sameKeys?: Set<string>;
|
|
54
52
|
/**
|
|
55
|
-
*
|
|
53
|
+
* If removedKeys option is true, return keys that are removed.
|
|
56
54
|
*/
|
|
57
55
|
removedKeys?: Set<string>;
|
|
58
56
|
/**
|
|
59
|
-
*
|
|
57
|
+
* If addedKeys option is true, return keys that are added.
|
|
60
58
|
*/
|
|
61
59
|
addedKeys?: Set<string>;
|
|
62
60
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/** @internal */
|
|
1
2
|
export const relatedItemRegex: RegExp;
|
|
3
|
+
/** @internal */
|
|
2
4
|
export const calculatedItemRegex: RegExp;
|
|
3
5
|
export function getObjectRelatedCalculatedByKey(obj: object, relatedObj: object, calculatedObj: object, key: string): [object, string];
|
|
4
6
|
export function getObjectRelatedByKey(obj: object, relatedObj: object, key: string): [object, string];
|
package/types/utils/watches.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ export class AwaitTimeout {
|
|
|
92
92
|
resolve: (value: any) => void;
|
|
93
93
|
reject: (reason?: any) => void;
|
|
94
94
|
timeout: number;
|
|
95
|
-
timeoutId:
|
|
95
|
+
timeoutId: number;
|
|
96
96
|
cancelledError: AwaitTimeoutError;
|
|
97
97
|
/**
|
|
98
98
|
* Starts the timeout process. If the timeout duration is reached without being stopped, the promise resolves.
|
package/use/cancellableIntent.js
CHANGED
|
@@ -56,9 +56,7 @@ export class CancellableIntentError extends Error {
|
|
|
56
56
|
*/
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* The common run tracking arguments.
|
|
60
|
-
*
|
|
61
|
-
* @typedef {object} CommonRunTracking
|
|
59
|
+
* @typedef {object} CommonRunTracking - The common run tracking arguments.
|
|
62
60
|
* @property {RunId} runId - The unique identifier for your run.
|
|
63
61
|
* @property {IsCurrentRunFn} isCurrentRun - A function that checks if the current run ID matches your run ID.
|
|
64
62
|
*/
|
|
@@ -80,9 +78,7 @@ export class CancellableIntentError extends Error {
|
|
|
80
78
|
*/
|
|
81
79
|
|
|
82
80
|
/**
|
|
83
|
-
* Cancel function signature for cancellable intent.
|
|
84
|
-
*
|
|
85
|
-
* @typedef {Function} CancelFn
|
|
81
|
+
* @typedef {Function} CancelFn - Cancel function signature for cancellable intent.
|
|
86
82
|
* @param {any} reason - The reason for cancellation.
|
|
87
83
|
* @param {boolean} [forceClearActive=false] - Whether to force clear the active state.
|
|
88
84
|
* @returns {Promise<void>} - A promise that resolves when the cancellation is complete.
|
|
@@ -184,7 +180,13 @@ export function useCancellableIntent({
|
|
|
184
180
|
guardArguments: readonly(internalState.guardArguments),
|
|
185
181
|
});
|
|
186
182
|
let previousWatchValues = null,
|
|
187
|
-
cancelFunction = null
|
|
183
|
+
cancelFunction = null,
|
|
184
|
+
// The run id whose in-flight promise `cancelFunction` would cancel. Paired with cancelFunction
|
|
185
|
+
// so a deliberate cancel can mark exactly which run it is tearing down.
|
|
186
|
+
cancelFunctionRunId = null;
|
|
187
|
+
// Run ids cancelled on purpose (via instance.cancel). Their promises reject with the cancel
|
|
188
|
+
// reason, which is not an error, so the run's catch handler skips setError for these.
|
|
189
|
+
const cancelledRunIds = new Set();
|
|
188
190
|
|
|
189
191
|
const doIntentWatch = () => {
|
|
190
192
|
loadingError.clearError();
|
|
@@ -225,8 +227,10 @@ export function useCancellableIntent({
|
|
|
225
227
|
|
|
226
228
|
if (awaitablePromise.cancel) {
|
|
227
229
|
cancelFunction = awaitablePromise.cancel.bind(awaitablePromise);
|
|
230
|
+
cancelFunctionRunId = thisRunId;
|
|
228
231
|
} else {
|
|
229
232
|
cancelFunction = null;
|
|
233
|
+
cancelFunctionRunId = null;
|
|
230
234
|
}
|
|
231
235
|
// we don't want to await this, because we want to be able to cancel it
|
|
232
236
|
awaitablePromise
|
|
@@ -237,11 +241,21 @@ export function useCancellableIntent({
|
|
|
237
241
|
}
|
|
238
242
|
})
|
|
239
243
|
.catch(async (err) => {
|
|
244
|
+
// A deliberate cancellation (instance.cancel) rejects this run's promise with the
|
|
245
|
+
// cancel reason; that is the intended outcome, not an error, so don't surface it.
|
|
246
|
+
if (cancelledRunIds.delete(thisRunId)) {
|
|
247
|
+
if (state.clearActiveOnResolved) {
|
|
248
|
+
internalState.activeCount--;
|
|
249
|
+
}
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
240
252
|
const cancelPromise = instance.cancel("Error in awaitableWithCancel", true);
|
|
241
253
|
loadingError.setError(err);
|
|
242
254
|
await cancelPromise;
|
|
243
255
|
})
|
|
244
256
|
.finally(() => {
|
|
257
|
+
// Drop any stale marker for this run (e.g. cancelled after it had already resolved).
|
|
258
|
+
cancelledRunIds.delete(thisRunId);
|
|
245
259
|
internalState.resolvingCount--;
|
|
246
260
|
});
|
|
247
261
|
};
|
|
@@ -316,7 +330,13 @@ export function useCancellableIntent({
|
|
|
316
330
|
cancel: async (/** @type {any} */ reason, forceClearActive = false) => {
|
|
317
331
|
if (cancelFunction) {
|
|
318
332
|
const toCancel = cancelFunction;
|
|
333
|
+
const runId = cancelFunctionRunId;
|
|
319
334
|
cancelFunction = null;
|
|
335
|
+
cancelFunctionRunId = null;
|
|
336
|
+
// Mark this run as deliberately cancelled so its rejection is not treated as an error.
|
|
337
|
+
if (runId !== null) {
|
|
338
|
+
cancelledRunIds.add(runId);
|
|
339
|
+
}
|
|
320
340
|
if (!state.clearActiveOnResolved || forceClearActive) {
|
|
321
341
|
internalState.activeCount--;
|
|
322
342
|
}
|
package/use/combineClasses.js
CHANGED
|
@@ -21,7 +21,7 @@ const isRefOrReactive = (v) => isRef(v) || isReactive(v);
|
|
|
21
21
|
* string[] |
|
|
22
22
|
* { [key: string]: boolean | import("vue").Ref<boolean> } |
|
|
23
23
|
* import("vue").Ref<string | string[]>
|
|
24
|
-
* )} CSSClasses
|
|
24
|
+
* )} CSSClasses - The accepted ways of specifying CSS classes to useCombineClasses (a string, array, class-map, or ref thereof).
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/**
|
package/use/error.js
CHANGED
|
@@ -1,40 +1,36 @@
|
|
|
1
1
|
import { readonly, ref } from "vue";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @typedef {() => void} ClearErrorFn
|
|
5
|
-
* @typedef {import("vue").Ref<Error|null>} ErrorRef
|
|
6
|
-
* @typedef {import("vue").Ref<boolean>} ErroredRef
|
|
7
|
-
* @typedef {Readonly<ErrorRef>} ErrorReadonlyRef
|
|
8
|
-
* @typedef {Readonly<ErroredRef>} ErroredReadonlyRef
|
|
4
|
+
* @typedef {() => void} ClearErrorFn - Signature for the function that clears the current error state.
|
|
5
|
+
* @typedef {import("vue").Ref<Error|null>} ErrorRef - A Vue ref holding the current error, or null when there is none.
|
|
6
|
+
* @typedef {import("vue").Ref<boolean>} ErroredRef - A Vue ref to the boolean indicating whether an error has occurred.
|
|
7
|
+
* @typedef {Readonly<ErrorRef>} ErrorReadonlyRef - A readonly Vue ref holding the current error, or null when there is none.
|
|
8
|
+
* @typedef {Readonly<ErroredRef>} ErroredReadonlyRef - A readonly Vue ref to the boolean indicating whether an error has occurred.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @typedef {object} ErrorProperties
|
|
12
|
+
* @typedef {object} ErrorProperties - The reactive error-state members (error and errored) contributed by the useError composable.
|
|
13
13
|
* @property {ErrorReadonlyRef} error - The error that occurred.
|
|
14
14
|
* @property {ErroredReadonlyRef} errored - Whether an error has occurred.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @typedef {object} ErrorFunctions
|
|
18
|
+
* @typedef {object} ErrorFunctions - The error-state actions (setError, clearError) contributed by the useError composable.
|
|
19
19
|
* @property {(error: Error) => void} setError - Set the error state.
|
|
20
20
|
* @property {ClearErrorFn} clearError - Clear the error state.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Proxies can still clear errors but cannot set them directly.
|
|
25
|
-
*
|
|
26
|
-
* @typedef {object} ErrorReadOnlyFunctions
|
|
24
|
+
* @typedef {object} ErrorReadOnlyFunctions - Proxies can still clear errors but cannot set them directly.
|
|
27
25
|
* @property {ClearErrorFn} clearError - Clear the error state.
|
|
28
26
|
*/
|
|
29
27
|
|
|
30
28
|
/**
|
|
31
|
-
* @typedef {ErrorProperties & ErrorReadOnlyFunctions} ReadonlyErrorStatus
|
|
29
|
+
* @typedef {ErrorProperties & ErrorReadOnlyFunctions} ReadonlyErrorStatus - The readonly error-state API (error and errored plus clearError) exposed to consumers and proxies.
|
|
32
30
|
*/
|
|
33
31
|
|
|
34
32
|
/**
|
|
35
|
-
* The error state API.
|
|
36
|
-
*
|
|
37
|
-
* @typedef {ErrorProperties & ErrorFunctions} ErrorStatus
|
|
33
|
+
* @typedef {ErrorProperties & ErrorFunctions} ErrorStatus - The error state API.
|
|
38
34
|
*/
|
|
39
35
|
|
|
40
36
|
/**
|
package/use/list.js
CHANGED
|
@@ -34,9 +34,7 @@ export class ListError extends Error {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Defines properties for configuring the list management system.
|
|
38
|
-
*
|
|
39
|
-
* @typedef {object} ListRawProps
|
|
37
|
+
* @typedef {object} ListRawProps - Defines properties for configuring the list management system.
|
|
40
38
|
* @property {object} params - The arguments to pass to the registered list crud handlers, related to the list itself.
|
|
41
39
|
* @property {string} pkKey - The primary key for the list items.
|
|
42
40
|
* @property {object} target - General arguments to pass to the registered list crud handlers, often related to endpoints.
|
|
@@ -54,7 +52,7 @@ export class ListError extends Error {
|
|
|
54
52
|
*/
|
|
55
53
|
|
|
56
54
|
/**
|
|
57
|
-
* @typedef {object} ListOptions
|
|
55
|
+
* @typedef {object} ListOptions - The configuration options used to create a fully managed list via useList.
|
|
58
56
|
* @property {ListRawProps} props - The properties for configuring the list.
|
|
59
57
|
* @property {import('../config/listCrud.js').ListCrudHandlers} [handlers] - Additional handlers to be included in the list manager.
|
|
60
58
|
* @property {number} [searchThrottle] - The throttle time for text search.
|
|
@@ -63,8 +61,6 @@ export class ListError extends Error {
|
|
|
63
61
|
*/
|
|
64
62
|
|
|
65
63
|
/**
|
|
66
|
-
* Holds references to instances of all list-related composables, facilitating direct access and management.
|
|
67
|
-
*
|
|
68
64
|
* @typedef {{
|
|
69
65
|
* listInstance: import('./listInstance.js').ListInstance,
|
|
70
66
|
* listSubscription: import('./listSubscription.js').ListSubscription,
|
|
@@ -73,33 +69,25 @@ export class ListError extends Error {
|
|
|
73
69
|
* listFilter: import('./listFilter.js').ListFilter,
|
|
74
70
|
* listSearch: import('./listSearch.js').ListSearch,
|
|
75
71
|
* listSort: import('./listSort.js').ListSort
|
|
76
|
-
* }} ListManaged
|
|
72
|
+
* }} ListManaged - Holds references to instances of all list-related composables, facilitating direct access and management.
|
|
77
73
|
*/
|
|
78
74
|
|
|
79
75
|
/**
|
|
80
|
-
* Aggregates all functions provided by various list-related composables, allowing for a unified approach to calling these methods.
|
|
81
|
-
*
|
|
82
76
|
* @typedef {(
|
|
83
77
|
* import('./listInstance.js').ListInstanceFunctions
|
|
84
78
|
* & import('./listSubscription.js').ListSubscriptionFunctions
|
|
85
|
-
* )} ListFunctions
|
|
79
|
+
* )} ListFunctions - Aggregates all functions provided by various list-related composables, allowing for a unified approach to calling these methods.
|
|
86
80
|
*/
|
|
87
81
|
|
|
88
82
|
/**
|
|
89
|
-
* Encapsulates properties relevant to the overall management of list-related hooks, including state, direct access to hooks,
|
|
90
|
-
* and scoped effects.
|
|
91
|
-
*
|
|
92
|
-
* @typedef {object} ListManagerProperties
|
|
83
|
+
* @typedef {object} ListManagerProperties - Encapsulates properties relevant to the overall management of list-related hooks, including state, direct access to hooks, and scoped effects.
|
|
93
84
|
* @property {ListManaged} managed - A readonly reference to the managed list hooks.
|
|
94
85
|
* @property {import('./listSort.js').ListSortState} state - Represents the final reactive state in the list processing chain.
|
|
95
86
|
* @property {() => void} stop - A function to stop the effect scope and clean up resources.
|
|
96
87
|
*/
|
|
97
88
|
|
|
98
89
|
/**
|
|
99
|
-
* Combines functionality and properties to represent a fully managed list instance,
|
|
100
|
-
* orchestrating various functionalities such as sorting, searching, filtering, and state management.
|
|
101
|
-
*
|
|
102
|
-
* @typedef {ListFunctions & ListManagerProperties} ListManager
|
|
90
|
+
* @typedef {ListFunctions & ListManagerProperties} ListManager - Combines functionality and properties to represent a fully managed list instance, orchestrating various functionalities such as sorting, searching, filtering, and state management.
|
|
103
91
|
*/
|
|
104
92
|
|
|
105
93
|
/* eslint-disable jsdoc/valid-types */
|
package/use/listCalculated.js
CHANGED
|
@@ -14,10 +14,6 @@ import { computed, effectScope, nextTick, reactive, ref, toRef, toRefs, unref, w
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Defines rules for dynamically calculating new properties for objects in a list. Each rule is a function that takes an
|
|
18
|
-
* object from the list, optionally its related objects, and previously calculated properties to compute a new
|
|
19
|
-
* property. These functions are reactive and re-evaluate when underlying dependencies change.
|
|
20
|
-
*
|
|
21
17
|
* @typedef {{
|
|
22
18
|
* [rule: string]: (
|
|
23
19
|
* object: import('../use/objectInstance.js').ExistingCrudObject,
|
|
@@ -28,7 +24,7 @@ import { computed, effectScope, nextTick, reactive, ref, toRef, toRefs, unref, w
|
|
|
28
24
|
* [rule: string]: import('vue').ComputedRef<any>,
|
|
29
25
|
* }
|
|
30
26
|
* ) => any,
|
|
31
|
-
* }} ListCalculatedRules
|
|
27
|
+
* }} ListCalculatedRules - Defines rules for dynamically calculating new properties for objects in a list. Each rule is a function that takes an object from the list, optionally its related objects, and previously calculated properties to compute a new property. These functions are reactive and re-evaluate when underlying dependencies change.
|
|
32
28
|
*/
|
|
33
29
|
|
|
34
30
|
/**
|
|
@@ -45,33 +41,26 @@ import { computed, effectScope, nextTick, reactive, ref, toRef, toRefs, unref, w
|
|
|
45
41
|
*/
|
|
46
42
|
|
|
47
43
|
/**
|
|
48
|
-
* The raw parent state for a list calculated.
|
|
49
|
-
*
|
|
50
44
|
* @typedef {(
|
|
51
45
|
* import('./listInstance.js').ListInstanceRawState &
|
|
52
46
|
* Partial<import('./listSubscription.js').ListSubscriptionRawState> &
|
|
53
47
|
* Partial<import('./listRelated.js').ListRelatedRawState>
|
|
54
|
-
* )} ListCalculatedParentRawState
|
|
48
|
+
* )} ListCalculatedParentRawState - The raw parent state for a list calculated.
|
|
55
49
|
*/
|
|
56
50
|
|
|
57
51
|
/**
|
|
58
|
-
* The state for a list calculated property.
|
|
59
|
-
*
|
|
60
52
|
* @typedef {import('vue').UnwrapNestedRefs<
|
|
61
53
|
* ListCalculatedParentRawState &
|
|
62
54
|
* ListCalculatedRawState
|
|
63
|
-
* >} ListCalculatedState
|
|
55
|
+
* >} ListCalculatedState - The state for a list calculated property.
|
|
64
56
|
*/
|
|
65
57
|
|
|
66
58
|
/**
|
|
67
|
-
* Represents a combined reactive state that includes properties from list related,
|
|
68
|
-
* subscription, and instance modules.
|
|
69
|
-
*
|
|
70
59
|
* @typedef {import('vue').UnwrapNestedRefs<(
|
|
71
60
|
* import('./listInstance.js').ListInstanceRawState &
|
|
72
61
|
* Partial<import('./listSubscription.js').ListSubscriptionRawState> &
|
|
73
62
|
* Partial<import('./listRelated.js').ListRelatedRawState>
|
|
74
|
-
* )>} ListCalculatedParentState
|
|
63
|
+
* )>} ListCalculatedParentState - Represents a combined reactive state that includes properties from list related, subscription, and instance modules.
|
|
75
64
|
*/
|
|
76
65
|
|
|
77
66
|
/**
|
|
@@ -85,9 +74,7 @@ import { computed, effectScope, nextTick, reactive, ref, toRef, toRefs, unref, w
|
|
|
85
74
|
*/
|
|
86
75
|
|
|
87
76
|
/**
|
|
88
|
-
* The properties for the list computed composition function.
|
|
89
|
-
*
|
|
90
|
-
* @typedef {object} ListCalculatedProperties
|
|
77
|
+
* @typedef {object} ListCalculatedProperties - The properties for the list computed composition function.
|
|
91
78
|
* @property {ListCalculatedState} state - The state for the list calculated property.
|
|
92
79
|
* @property {ListCalculatedParentState} parentState - The parent state object.
|
|
93
80
|
* @property {() => void} stop - Stops composition's effects and cleans up resources.
|
|
@@ -96,9 +83,7 @@ import { computed, effectScope, nextTick, reactive, ref, toRef, toRefs, unref, w
|
|
|
96
83
|
// if we provided functions, we would add a typedef and mix them into ListCalculated
|
|
97
84
|
|
|
98
85
|
/**
|
|
99
|
-
* The instance of `useListCalculated`.
|
|
100
|
-
*
|
|
101
|
-
* @typedef {ListCalculatedProperties} ListCalculated
|
|
86
|
+
* @typedef {ListCalculatedProperties} ListCalculated - The instance of `useListCalculated`.
|
|
102
87
|
*/
|
|
103
88
|
|
|
104
89
|
/**
|
|
@@ -228,7 +213,7 @@ export function useListCalculated({ parentState, calculatedObjectsRules }) {
|
|
|
228
213
|
));
|
|
229
214
|
} else {
|
|
230
215
|
if (isEmpty(calculatedObjectsObject)) {
|
|
231
|
-
|
|
216
|
+
continue;
|
|
232
217
|
}
|
|
233
218
|
removedRuleKeys = Object.keys(calculatedObjectsObject);
|
|
234
219
|
addedRuleKeys = [];
|
package/use/listFilter.js
CHANGED
|
@@ -11,7 +11,7 @@ import { computed, effectScope, isRef, reactive, toRef, toRefs, unref, watch } f
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* @typedef {import('vue').Ref<import('../use/objectInstance.js').ExistingCrudObject>[]} ObjectsInOrderRefs
|
|
14
|
+
* @typedef {import('vue').Ref<import('../use/objectInstance.js').ExistingCrudObject>[]} ObjectsInOrderRefs - An array of Vue refs to the list's existing objects in their current order.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -23,10 +23,7 @@ import { computed, effectScope, isRef, reactive, toRef, toRefs, unref, watch } f
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Defines the structure of the reactive state used by the list filter. This state includes both filters and
|
|
27
|
-
* the results of applying these filters to a list.
|
|
28
|
-
*
|
|
29
|
-
* @typedef {object} ListFilterRawState
|
|
26
|
+
* @typedef {object} ListFilterRawState - Defines the structure of the reactive state used by the list filter. This state includes both filters and the results of applying these filters to a list.
|
|
30
27
|
* @property {ListFilterAllowedFilter} [allowedFilter] - Function to determine if an item should be included based on custom logic.
|
|
31
28
|
* @property {ListFilterExcludedFilter} [excludedFilter] - Function to determine if an item should be excluded based on custom logic.
|
|
32
29
|
*/
|
|
@@ -39,39 +36,31 @@ import { computed, effectScope, isRef, reactive, toRef, toRefs, unref, watch } f
|
|
|
39
36
|
* Partial<import('./listSubscription.js').ListSubscriptionRawState> &
|
|
40
37
|
* Partial<import('./listRelated.js').ListRelatedRawState> &
|
|
41
38
|
* Partial<import('./listCalculated.js').ListCalculatedRawState>
|
|
42
|
-
* )} ListFilterParentRawState
|
|
39
|
+
* )} ListFilterParentRawState - The raw, pre-unwrapped parent state consumed by the list filter mixin, aggregating the upstream list composable states.
|
|
43
40
|
*/
|
|
44
41
|
|
|
45
42
|
/**
|
|
46
|
-
* The parent state for a list filter.
|
|
47
|
-
*
|
|
48
43
|
* @typedef {import('vue').UnwrapNestedRefs<(
|
|
49
44
|
* ListFilterParentRawState
|
|
50
|
-
* )>} ListFilterParentState
|
|
45
|
+
* )>} ListFilterParentState - The parent state for a list filter.
|
|
51
46
|
*/
|
|
52
47
|
|
|
53
48
|
/**
|
|
54
|
-
* Describes the combined state from various list-related composables that might interact with the list filter.
|
|
55
|
-
*
|
|
56
49
|
* @typedef {import('vue').UnwrapNestedRefs<
|
|
57
50
|
* ListFilterParentRawState &
|
|
58
51
|
* ListFilterRawState
|
|
59
|
-
* >} ListFilterState
|
|
52
|
+
* >} ListFilterState - Describes the combined state from various list-related composables that might interact with the list filter.
|
|
60
53
|
*/
|
|
61
54
|
|
|
62
55
|
/**
|
|
63
|
-
* Configuration options for initializing a list filter. Includes references to the parent state and filter functions.
|
|
64
|
-
*
|
|
65
|
-
* @typedef {object} ListFilterOptions
|
|
56
|
+
* @typedef {object} ListFilterOptions - Configuration options for initializing a list filter. Includes references to the parent state and filter functions.
|
|
66
57
|
* @property {ListFilterParentState} parentState - The parent state.
|
|
67
58
|
* @property {import('vue').Ref<Function>|Function} [allowedFilter] - A function that returns true if an item should be included, which can be reactive.
|
|
68
59
|
* @property {import('vue').Ref<Function>|Function} [excludedFilter] - A function that returns true if an item should be excluded, which can be reactive.
|
|
69
60
|
*/
|
|
70
61
|
|
|
71
62
|
/**
|
|
72
|
-
* The properties of a list filter, including its state and associated Vue composition API utilities.
|
|
73
|
-
*
|
|
74
|
-
* @typedef {object} ListFilterProperties
|
|
63
|
+
* @typedef {object} ListFilterProperties - The properties of a list filter, including its state and associated Vue composition API utilities.
|
|
75
64
|
* @property {ListFilterState} state - The reactive state managing the filter logic and results.
|
|
76
65
|
* @property {ListFilterParentState} parentState - The state of the list being filtered.
|
|
77
66
|
* @property {() => void} stop - A function to stop the effect scope and clean up resources.
|
|
@@ -80,9 +69,7 @@ import { computed, effectScope, isRef, reactive, toRef, toRefs, unref, watch } f
|
|
|
80
69
|
// if we provided functions, we would add a typedef and mix them into ListFilter
|
|
81
70
|
|
|
82
71
|
/**
|
|
83
|
-
* Represents an instance of a list filter, including its state and associated Vue composition API utilities.
|
|
84
|
-
*
|
|
85
|
-
* @typedef {ListFilterProperties} ListFilter
|
|
72
|
+
* @typedef {ListFilterProperties} ListFilter - Represents an instance of a list filter, including its state and associated Vue composition API utilities.
|
|
86
73
|
*
|
|
87
74
|
*/
|
|
88
75
|
|