@arrai-innovations/reactive-helpers 13.0.2 → 13.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/listCrud.js +55 -2
- package/config/objectCrud.js +62 -6
- package/docs/config/listCrud.md +163 -4
- package/docs/config/objectCrud.md +234 -12
- package/docs/use/combineClasses.md +9 -1
- package/docs/use/listInstance.md +10 -2
- package/docs/use/loadingError.md +70 -2
- package/docs/use/object.md +120 -24
- package/docs/use/objectCalculated.md +120 -24
- package/docs/use/objectInstance.md +120 -24
- package/docs/use/objectRelated.md +120 -24
- package/docs/use/objectSubscription.md +60 -12
- package/index.js +1 -0
- package/package.json +1 -1
- package/use/combineClasses.js +10 -6
- package/use/listInstance.js +4 -1
- package/use/loadingError.js +13 -6
|
@@ -36,42 +36,90 @@ The crud functions.
|
|
|
36
36
|
|
|
37
37
|
The arguments to be passed to the crud functions.
|
|
38
38
|
|
|
39
|
-
###### crud.create
|
|
39
|
+
###### crud.create()
|
|
40
40
|
|
|
41
|
-
> **create**: `
|
|
41
|
+
> **create**: (`CreateDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
42
42
|
|
|
43
43
|
A function to be used instead of the default crud create function.
|
|
44
44
|
|
|
45
|
-
######
|
|
45
|
+
###### Parameters
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
• **CreateDetailArgs**: `any`
|
|
48
|
+
|
|
49
|
+
###### Returns
|
|
50
|
+
|
|
51
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
52
|
+
|
|
53
|
+
###### crud.delete()
|
|
54
|
+
|
|
55
|
+
> **delete**: (`DeleteDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
48
56
|
|
|
49
57
|
A function to be used instead of the default crud delete function.
|
|
50
58
|
|
|
51
|
-
######
|
|
59
|
+
###### Parameters
|
|
60
|
+
|
|
61
|
+
• **DeleteDetailArgs**: `any`
|
|
62
|
+
|
|
63
|
+
###### Returns
|
|
52
64
|
|
|
53
|
-
|
|
65
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
66
|
+
|
|
67
|
+
###### crud.patch()
|
|
68
|
+
|
|
69
|
+
> **patch**: (`PartialDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
54
70
|
|
|
55
71
|
A function to be used instead of the default crud patch function.
|
|
56
72
|
|
|
57
|
-
######
|
|
73
|
+
###### Parameters
|
|
74
|
+
|
|
75
|
+
• **PartialDetailArgs**: `any`
|
|
76
|
+
|
|
77
|
+
###### Returns
|
|
78
|
+
|
|
79
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
80
|
+
|
|
81
|
+
###### crud.retrieve()
|
|
58
82
|
|
|
59
|
-
> **retrieve**: `
|
|
83
|
+
> **retrieve**: (`RetrieveDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
60
84
|
|
|
61
85
|
A function to be used instead of the default crud retrieve function.
|
|
62
86
|
|
|
63
|
-
######
|
|
87
|
+
###### Parameters
|
|
64
88
|
|
|
65
|
-
|
|
89
|
+
• **RetrieveDetailArgs**: `any`
|
|
90
|
+
|
|
91
|
+
###### Returns
|
|
92
|
+
|
|
93
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
94
|
+
|
|
95
|
+
###### crud.subscribe()
|
|
96
|
+
|
|
97
|
+
> **subscribe**: (`SubscribeArgs`) => `void`
|
|
66
98
|
|
|
67
99
|
A function to be used instead of the default crud subscribe function.
|
|
68
100
|
|
|
69
|
-
######
|
|
101
|
+
###### Parameters
|
|
102
|
+
|
|
103
|
+
• **SubscribeArgs**: `any`
|
|
104
|
+
|
|
105
|
+
###### Returns
|
|
70
106
|
|
|
71
|
-
|
|
107
|
+
`void`
|
|
108
|
+
|
|
109
|
+
###### crud.update()
|
|
110
|
+
|
|
111
|
+
> **update**: (`UpdateDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
72
112
|
|
|
73
113
|
A function to be used instead of the default crud update function.
|
|
74
114
|
|
|
115
|
+
###### Parameters
|
|
116
|
+
|
|
117
|
+
• **UpdateDetailArgs**: `any`
|
|
118
|
+
|
|
119
|
+
###### Returns
|
|
120
|
+
|
|
121
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
122
|
+
|
|
75
123
|
###### deleted
|
|
76
124
|
|
|
77
125
|
> **deleted**: `boolean`
|
|
@@ -168,42 +216,90 @@ The crud functions.
|
|
|
168
216
|
|
|
169
217
|
The arguments to be passed to the crud functions.
|
|
170
218
|
|
|
171
|
-
###### crud.create
|
|
219
|
+
###### crud.create()
|
|
172
220
|
|
|
173
|
-
> **create**: `
|
|
221
|
+
> **create**: (`CreateDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
174
222
|
|
|
175
223
|
A function to be used instead of the default crud create function.
|
|
176
224
|
|
|
177
|
-
######
|
|
225
|
+
###### Parameters
|
|
178
226
|
|
|
179
|
-
|
|
227
|
+
• **CreateDetailArgs**: `any`
|
|
228
|
+
|
|
229
|
+
###### Returns
|
|
230
|
+
|
|
231
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
232
|
+
|
|
233
|
+
###### crud.delete()
|
|
234
|
+
|
|
235
|
+
> **delete**: (`DeleteDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
180
236
|
|
|
181
237
|
A function to be used instead of the default crud delete function.
|
|
182
238
|
|
|
183
|
-
######
|
|
239
|
+
###### Parameters
|
|
240
|
+
|
|
241
|
+
• **DeleteDetailArgs**: `any`
|
|
242
|
+
|
|
243
|
+
###### Returns
|
|
184
244
|
|
|
185
|
-
|
|
245
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
246
|
+
|
|
247
|
+
###### crud.patch()
|
|
248
|
+
|
|
249
|
+
> **patch**: (`PartialDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
186
250
|
|
|
187
251
|
A function to be used instead of the default crud patch function.
|
|
188
252
|
|
|
189
|
-
######
|
|
253
|
+
###### Parameters
|
|
254
|
+
|
|
255
|
+
• **PartialDetailArgs**: `any`
|
|
256
|
+
|
|
257
|
+
###### Returns
|
|
258
|
+
|
|
259
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
260
|
+
|
|
261
|
+
###### crud.retrieve()
|
|
190
262
|
|
|
191
|
-
> **retrieve**: `
|
|
263
|
+
> **retrieve**: (`RetrieveDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
192
264
|
|
|
193
265
|
A function to be used instead of the default crud retrieve function.
|
|
194
266
|
|
|
195
|
-
######
|
|
267
|
+
###### Parameters
|
|
196
268
|
|
|
197
|
-
|
|
269
|
+
• **RetrieveDetailArgs**: `any`
|
|
270
|
+
|
|
271
|
+
###### Returns
|
|
272
|
+
|
|
273
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
274
|
+
|
|
275
|
+
###### crud.subscribe()
|
|
276
|
+
|
|
277
|
+
> **subscribe**: (`SubscribeArgs`) => `void`
|
|
198
278
|
|
|
199
279
|
A function to be used instead of the default crud subscribe function.
|
|
200
280
|
|
|
201
|
-
######
|
|
281
|
+
###### Parameters
|
|
282
|
+
|
|
283
|
+
• **SubscribeArgs**: `any`
|
|
284
|
+
|
|
285
|
+
###### Returns
|
|
202
286
|
|
|
203
|
-
|
|
287
|
+
`void`
|
|
288
|
+
|
|
289
|
+
###### crud.update()
|
|
290
|
+
|
|
291
|
+
> **update**: (`UpdateDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
204
292
|
|
|
205
293
|
A function to be used instead of the default crud update function.
|
|
206
294
|
|
|
295
|
+
###### Parameters
|
|
296
|
+
|
|
297
|
+
• **UpdateDetailArgs**: `any`
|
|
298
|
+
|
|
299
|
+
###### Returns
|
|
300
|
+
|
|
301
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
302
|
+
|
|
207
303
|
###### deleted
|
|
208
304
|
|
|
209
305
|
> **deleted**: `boolean`
|
|
@@ -167,42 +167,90 @@ The crud functions.
|
|
|
167
167
|
|
|
168
168
|
The arguments to be passed to the crud functions.
|
|
169
169
|
|
|
170
|
-
###### crud.create
|
|
170
|
+
###### crud.create()
|
|
171
171
|
|
|
172
|
-
> **create**: `
|
|
172
|
+
> **create**: (`CreateDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
173
173
|
|
|
174
174
|
A function to be used instead of the default crud create function.
|
|
175
175
|
|
|
176
|
-
######
|
|
176
|
+
###### Parameters
|
|
177
|
+
|
|
178
|
+
• **CreateDetailArgs**: `any`
|
|
179
|
+
|
|
180
|
+
###### Returns
|
|
181
|
+
|
|
182
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
177
183
|
|
|
178
|
-
|
|
184
|
+
###### crud.delete()
|
|
185
|
+
|
|
186
|
+
> **delete**: (`DeleteDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
179
187
|
|
|
180
188
|
A function to be used instead of the default crud delete function.
|
|
181
189
|
|
|
182
|
-
######
|
|
190
|
+
###### Parameters
|
|
191
|
+
|
|
192
|
+
• **DeleteDetailArgs**: `any`
|
|
193
|
+
|
|
194
|
+
###### Returns
|
|
183
195
|
|
|
184
|
-
|
|
196
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
197
|
+
|
|
198
|
+
###### crud.patch()
|
|
199
|
+
|
|
200
|
+
> **patch**: (`PartialDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
185
201
|
|
|
186
202
|
A function to be used instead of the default crud patch function.
|
|
187
203
|
|
|
188
|
-
######
|
|
204
|
+
###### Parameters
|
|
189
205
|
|
|
190
|
-
|
|
206
|
+
• **PartialDetailArgs**: `any`
|
|
207
|
+
|
|
208
|
+
###### Returns
|
|
209
|
+
|
|
210
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
211
|
+
|
|
212
|
+
###### crud.retrieve()
|
|
213
|
+
|
|
214
|
+
> **retrieve**: (`RetrieveDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
191
215
|
|
|
192
216
|
A function to be used instead of the default crud retrieve function.
|
|
193
217
|
|
|
194
|
-
######
|
|
218
|
+
###### Parameters
|
|
195
219
|
|
|
196
|
-
|
|
220
|
+
• **RetrieveDetailArgs**: `any`
|
|
221
|
+
|
|
222
|
+
###### Returns
|
|
223
|
+
|
|
224
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
225
|
+
|
|
226
|
+
###### crud.subscribe()
|
|
227
|
+
|
|
228
|
+
> **subscribe**: (`SubscribeArgs`) => `void`
|
|
197
229
|
|
|
198
230
|
A function to be used instead of the default crud subscribe function.
|
|
199
231
|
|
|
200
|
-
######
|
|
232
|
+
###### Parameters
|
|
233
|
+
|
|
234
|
+
• **SubscribeArgs**: `any`
|
|
235
|
+
|
|
236
|
+
###### Returns
|
|
237
|
+
|
|
238
|
+
`void`
|
|
239
|
+
|
|
240
|
+
###### crud.update()
|
|
201
241
|
|
|
202
|
-
> **update**: `
|
|
242
|
+
> **update**: (`UpdateDetailArgs`) => [`ResponseData`](../config/objectCrud.md#responsedata)
|
|
203
243
|
|
|
204
244
|
A function to be used instead of the default crud update function.
|
|
205
245
|
|
|
246
|
+
###### Parameters
|
|
247
|
+
|
|
248
|
+
• **UpdateDetailArgs**: `any`
|
|
249
|
+
|
|
250
|
+
###### Returns
|
|
251
|
+
|
|
252
|
+
[`ResponseData`](../config/objectCrud.md#responsedata)
|
|
253
|
+
|
|
206
254
|
###### deleted
|
|
207
255
|
|
|
208
256
|
> **deleted**: `boolean`
|
package/index.js
CHANGED
package/package.json
CHANGED
package/use/combineClasses.js
CHANGED
|
@@ -15,6 +15,15 @@ import { isRef, ref, watch, isReactive } from "vue";
|
|
|
15
15
|
*/
|
|
16
16
|
const isRefOrReactive = (v) => isRef(v) || isReactive(v);
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {(
|
|
20
|
+
* string |
|
|
21
|
+
* string[] |
|
|
22
|
+
* { [key: string]: boolean | import("vue").Ref<boolean> } |
|
|
23
|
+
* import("vue").Ref<string | string[]>
|
|
24
|
+
* )} CSSClasses
|
|
25
|
+
*/
|
|
26
|
+
|
|
18
27
|
/**
|
|
19
28
|
* Normalize various ways of specifying CSS classes into an object for use in Vue.js with reactivity. If refs are
|
|
20
29
|
* present, the resulting object will be a ref containing an array of objects to preserve order of operations in
|
|
@@ -40,12 +49,7 @@ const isRefOrReactive = (v) => isRef(v) || isReactive(v);
|
|
|
40
49
|
* </script>
|
|
41
50
|
* ```
|
|
42
51
|
*
|
|
43
|
-
* @param {...(
|
|
44
|
-
* string |
|
|
45
|
-
* string[] |
|
|
46
|
-
* { [key: string]: boolean | import("vue").Ref<boolean> } |
|
|
47
|
-
* import("vue").Ref<string | string[]>
|
|
48
|
-
* )} classes - A mixed array containing multiple ways of specifying CSS classes.
|
|
52
|
+
* @param {...(CSSClasses)} classes - A mixed array containing multiple ways of specifying CSS classes.
|
|
49
53
|
* @returns {import("vue").Ref<import('../utils/classes.js').CombinedClasses>} - A ref
|
|
50
54
|
* containing an object or array of objects containing CSS classes. Arrays are used if refs are present, to
|
|
51
55
|
* preserve order of operations in reactive contexts.
|
package/use/listInstance.js
CHANGED
|
@@ -51,7 +51,10 @@ export class ListInstanceError extends Error {
|
|
|
51
51
|
* @typedef {object} ListInstanceOptions
|
|
52
52
|
* @property {import('vue').UnwrapNestedRefs<ListInstanceProps>} props - The props for the list instance.
|
|
53
53
|
* @property {object} [functions] - Default implementation are used as set by `setListCrud`.
|
|
54
|
-
* @property {
|
|
54
|
+
* @property {import('../config/listCrud.js').ListFn} [functions.list] - Provide the implementation for the list
|
|
55
|
+
* function.
|
|
56
|
+
* @property {import('../config/listCrud.js').SubscribeFn} [functions.subscribe] - Provide the implementation for the
|
|
57
|
+
* subscribe function.
|
|
55
58
|
* @property {boolean} [keepOldPages=false] - If true, pages will not be cleared when defaultPageCallback is called.
|
|
56
59
|
*/
|
|
57
60
|
|
package/use/loadingError.js
CHANGED
|
@@ -5,20 +5,27 @@ import { readonly, ref } from "vue";
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
11
|
-
* @property {import("vue").Ref<boolean
|
|
12
|
-
* @property {import("vue").Ref<Error|null>} error - The error that occurred.
|
|
13
|
-
* @property {import("vue").Ref<boolean>} errored - Whether an error has occurred.
|
|
8
|
+
* @typedef {object} LoadingError
|
|
9
|
+
* @property {Readonly<import("vue").Ref<boolean|undefined>>} loading - Whether the component is loading.
|
|
10
|
+
* @property {Readonly<import("vue").Ref<Error|null>>} error - The error that occurred.
|
|
11
|
+
* @property {Readonly<import("vue").Ref<boolean>>} errored - Whether an error has occurred.
|
|
14
12
|
* @property {() => void} setLoading - Set the loading state.
|
|
15
13
|
* @property {() => void} clearLoading - Clear the loading state.
|
|
16
14
|
* @property {(error) => void} setError - Set the error state.
|
|
17
15
|
* @property {() => void} clearError - Clear the error state.
|
|
18
16
|
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A composable function for managing loading and error states.
|
|
20
|
+
*
|
|
21
|
+
* @returns {LoadingError} - An object containing reactive fields and actions for loading and error states.
|
|
22
|
+
*/
|
|
19
23
|
export function useLoadingError() {
|
|
24
|
+
/** @type {import("vue").Ref<boolean|undefined>} */
|
|
20
25
|
const loading = ref(undefined);
|
|
26
|
+
/** @type {import("vue").Ref<Error|null>} */
|
|
21
27
|
const error = ref(null);
|
|
28
|
+
/** @type {import("vue").Ref<boolean>} */
|
|
22
29
|
const errored = ref(false);
|
|
23
30
|
|
|
24
31
|
return {
|