@vueuse/integrations 6.4.1 → 6.5.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/index.cjs +375 -401
- package/index.d.ts +20 -49
- package/index.iife.js +376 -403
- package/index.iife.min.js +1 -1
- package/index.mjs +377 -403
- package/package.json +5 -5
- package/useAxios.cjs +69 -65
- package/useAxios.iife.js +70 -66
- package/useAxios.iife.min.js +1 -1
- package/useAxios.mjs +69 -65
- package/useCookies.cjs +59 -71
- package/useCookies.iife.js +60 -72
- package/useCookies.iife.min.js +1 -1
- package/useCookies.mjs +59 -71
- package/useDrauu.cjs +116 -108
- package/useDrauu.d.ts +21 -50
- package/useDrauu.iife.js +117 -110
- package/useDrauu.iife.min.js +1 -1
- package/useDrauu.mjs +118 -110
- package/useFocusTrap.cjs +78 -104
- package/useFocusTrap.iife.js +83 -109
- package/useFocusTrap.iife.min.js +1 -1
- package/useFocusTrap.mjs +79 -105
- package/useJwt.cjs +20 -24
- package/useJwt.iife.js +21 -25
- package/useJwt.iife.min.js +1 -1
- package/useJwt.mjs +20 -24
- package/useNProgress.cjs +28 -37
- package/useNProgress.iife.js +29 -38
- package/useNProgress.iife.min.js +1 -1
- package/useNProgress.mjs +28 -37
- package/useQRCode.cjs +8 -15
- package/useQRCode.iife.js +9 -16
- package/useQRCode.iife.min.js +1 -1
- package/useQRCode.mjs +8 -15
package/index.mjs
CHANGED
|
@@ -1,428 +1,402 @@
|
|
|
1
|
-
import { shallowRef, ref,
|
|
1
|
+
import { shallowRef, ref, watch, computed, isRef, watchEffect } from 'vue-demi';
|
|
2
2
|
import axios from 'axios';
|
|
3
|
-
import { tryOnScopeDispose,
|
|
3
|
+
import { tryOnScopeDispose, isNumber, isClient } from '@vueuse/shared';
|
|
4
4
|
import Cookie from 'universal-cookie';
|
|
5
5
|
import { createDrauu } from 'drauu';
|
|
6
|
+
import { createEventHook, unrefElement, tryOnScopeDispose as tryOnScopeDispose$1 } from '@vueuse/core';
|
|
6
7
|
import { createFocusTrap } from 'focus-trap';
|
|
7
8
|
import jwt_decode from 'jwt-decode';
|
|
8
9
|
import nprogress from 'nprogress';
|
|
9
10
|
import QRCode from 'qrcode';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
12
|
+
var __defProp$3 = Object.defineProperty;
|
|
13
|
+
var __defProps$1 = Object.defineProperties;
|
|
14
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
15
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
16
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
18
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
19
|
+
var __spreadValues$3 = (a, b) => {
|
|
20
|
+
for (var prop in b || (b = {}))
|
|
21
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
22
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
23
|
+
if (__getOwnPropSymbols$3)
|
|
24
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
25
|
+
if (__propIsEnum$3.call(b, prop))
|
|
26
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
27
|
+
}
|
|
28
|
+
return a;
|
|
29
|
+
};
|
|
30
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
31
|
+
function useAxios(url, ...args) {
|
|
32
|
+
let config = {};
|
|
33
|
+
let instance = axios;
|
|
34
|
+
if (args.length > 0) {
|
|
35
|
+
if ("request" in args[0])
|
|
36
|
+
instance = args[0];
|
|
37
|
+
else
|
|
38
|
+
config = args[0];
|
|
39
|
+
}
|
|
40
|
+
if (args.length > 1) {
|
|
41
|
+
if ("request" in args[1])
|
|
42
|
+
instance = args[1];
|
|
43
|
+
}
|
|
44
|
+
const response = shallowRef();
|
|
45
|
+
const data = shallowRef();
|
|
46
|
+
const isFinished = ref(false);
|
|
47
|
+
const isLoading = ref(true);
|
|
48
|
+
const aborted = ref(false);
|
|
49
|
+
const error = shallowRef();
|
|
50
|
+
const cancelToken = axios.CancelToken.source();
|
|
51
|
+
const abort = (message) => {
|
|
52
|
+
if (isFinished.value || !isLoading.value)
|
|
53
|
+
return;
|
|
54
|
+
cancelToken.cancel(message);
|
|
55
|
+
aborted.value = true;
|
|
56
|
+
isLoading.value = false;
|
|
57
|
+
isFinished.value = false;
|
|
58
|
+
};
|
|
59
|
+
instance(url, __spreadProps$1(__spreadValues$3({}, config), { cancelToken: cancelToken.token })).then((r) => {
|
|
60
|
+
response.value = r;
|
|
61
|
+
data.value = r.data;
|
|
62
|
+
}).catch((e) => {
|
|
63
|
+
error.value = e;
|
|
64
|
+
}).finally(() => {
|
|
65
|
+
isLoading.value = false;
|
|
66
|
+
isFinished.value = true;
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
response,
|
|
70
|
+
data,
|
|
71
|
+
error,
|
|
72
|
+
finished: isFinished,
|
|
73
|
+
loading: isLoading,
|
|
74
|
+
isFinished,
|
|
75
|
+
isLoading,
|
|
76
|
+
cancel: abort,
|
|
77
|
+
canceled: aborted,
|
|
78
|
+
aborted,
|
|
79
|
+
abort
|
|
80
|
+
};
|
|
76
81
|
}
|
|
77
82
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
|
|
98
|
-
let previousCookies = cookies.getAll({ doNotParse: true });
|
|
99
|
-
/**
|
|
100
|
-
* Adds reactivity to get/getAll methods
|
|
101
|
-
*/
|
|
102
|
-
const touches = ref(0);
|
|
103
|
-
const onChange = () => {
|
|
104
|
-
const newCookies = cookies.getAll({ doNotParse: true });
|
|
105
|
-
if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies))
|
|
106
|
-
touches.value++;
|
|
107
|
-
previousCookies = newCookies;
|
|
108
|
-
};
|
|
109
|
-
cookies.addChangeListener(onChange);
|
|
110
|
-
tryOnScopeDispose(() => {
|
|
111
|
-
cookies.removeChangeListener(onChange);
|
|
112
|
-
});
|
|
113
|
-
return {
|
|
114
|
-
/**
|
|
115
|
-
* Reactive get cookie by name. If **autoUpdateDependencies = true** then it will update watching dependencies
|
|
116
|
-
*/
|
|
117
|
-
get: (...args) => {
|
|
118
|
-
/**
|
|
119
|
-
* Auto update watching dependencies if needed
|
|
120
|
-
*/
|
|
121
|
-
if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0]))
|
|
122
|
-
watchingDependencies.push(args[0]);
|
|
123
|
-
// eslint-disable-next-line no-unused-expressions
|
|
124
|
-
touches.value; // adds reactivity to method
|
|
125
|
-
return cookies.get(args[0], Object.assign({ doNotParse }, args[1]));
|
|
126
|
-
},
|
|
127
|
-
/**
|
|
128
|
-
* Reactive get all cookies
|
|
129
|
-
*/
|
|
130
|
-
getAll: (...args) => {
|
|
131
|
-
// eslint-disable-next-line no-unused-expressions
|
|
132
|
-
touches.value; // adds reactivity to method
|
|
133
|
-
return cookies.getAll(Object.assign({ doNotParse }, args[0]));
|
|
134
|
-
},
|
|
135
|
-
set: (...args) => cookies.set(...args),
|
|
136
|
-
remove: (...args) => cookies.remove(...args),
|
|
137
|
-
addChangeListener: (...args) => cookies.addChangeListener(...args),
|
|
138
|
-
removeChangeListener: (...args) => cookies.removeChangeListener(...args),
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
function shouldUpdate(dependencies, newCookies, oldCookies) {
|
|
142
|
-
if (!dependencies)
|
|
143
|
-
return true;
|
|
144
|
-
for (const dependency of dependencies) {
|
|
145
|
-
if (newCookies[dependency] !== oldCookies[dependency])
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
return false;
|
|
83
|
+
var __defProp$2 = Object.defineProperty;
|
|
84
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
85
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
86
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
87
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
88
|
+
var __spreadValues$2 = (a, b) => {
|
|
89
|
+
for (var prop in b || (b = {}))
|
|
90
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
91
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
92
|
+
if (__getOwnPropSymbols$2)
|
|
93
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
94
|
+
if (__propIsEnum$2.call(b, prop))
|
|
95
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
96
|
+
}
|
|
97
|
+
return a;
|
|
98
|
+
};
|
|
99
|
+
function createCookies(req) {
|
|
100
|
+
const universalCookie = new Cookie(req ? req.headers.cookie : null);
|
|
101
|
+
return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
|
|
149
102
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
103
|
+
function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie()) {
|
|
104
|
+
const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
|
|
105
|
+
let previousCookies = cookies.getAll({ doNotParse: true });
|
|
106
|
+
const touches = ref(0);
|
|
107
|
+
const onChange = () => {
|
|
108
|
+
const newCookies = cookies.getAll({ doNotParse: true });
|
|
109
|
+
if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies))
|
|
110
|
+
touches.value++;
|
|
111
|
+
previousCookies = newCookies;
|
|
112
|
+
};
|
|
113
|
+
cookies.addChangeListener(onChange);
|
|
114
|
+
tryOnScopeDispose(() => {
|
|
115
|
+
cookies.removeChangeListener(onChange);
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
get: (...args) => {
|
|
119
|
+
if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0]))
|
|
120
|
+
watchingDependencies.push(args[0]);
|
|
121
|
+
touches.value;
|
|
122
|
+
return cookies.get(args[0], __spreadValues$2({ doNotParse }, args[1]));
|
|
123
|
+
},
|
|
124
|
+
getAll: (...args) => {
|
|
125
|
+
touches.value;
|
|
126
|
+
return cookies.getAll(__spreadValues$2({ doNotParse }, args[0]));
|
|
127
|
+
},
|
|
128
|
+
set: (...args) => cookies.set(...args),
|
|
129
|
+
remove: (...args) => cookies.remove(...args),
|
|
130
|
+
addChangeListener: (...args) => cookies.addChangeListener(...args),
|
|
131
|
+
removeChangeListener: (...args) => cookies.removeChangeListener(...args)
|
|
132
|
+
};
|
|
160
133
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
170
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
171
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
172
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
173
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
174
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
175
|
-
***************************************************************************** */
|
|
176
|
-
|
|
177
|
-
function __rest(s, e) {
|
|
178
|
-
var t = {};
|
|
179
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
180
|
-
t[p] = s[p];
|
|
181
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
182
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
183
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
184
|
-
t[p[i]] = s[p[i]];
|
|
185
|
-
}
|
|
186
|
-
return t;
|
|
134
|
+
function shouldUpdate(dependencies, newCookies, oldCookies) {
|
|
135
|
+
if (!dependencies)
|
|
136
|
+
return true;
|
|
137
|
+
for (const dependency of dependencies) {
|
|
138
|
+
if (newCookies[dependency] !== oldCookies[dependency])
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
187
142
|
}
|
|
188
143
|
|
|
189
|
-
var
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
function useDrauu(target, options) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
144
|
+
var __defProp$1 = Object.defineProperty;
|
|
145
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
146
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
147
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
148
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
149
|
+
var __spreadValues$1 = (a, b) => {
|
|
150
|
+
for (var prop in b || (b = {}))
|
|
151
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
152
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
153
|
+
if (__getOwnPropSymbols$1)
|
|
154
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
155
|
+
if (__propIsEnum$1.call(b, prop))
|
|
156
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
157
|
+
}
|
|
158
|
+
return a;
|
|
159
|
+
};
|
|
160
|
+
function useDrauu(target, options) {
|
|
161
|
+
const drauuInstance = ref();
|
|
162
|
+
let disposables = [];
|
|
163
|
+
const onChangedHook = createEventHook();
|
|
164
|
+
const onCanceledHook = createEventHook();
|
|
165
|
+
const onCommittedHook = createEventHook();
|
|
166
|
+
const onStartHook = createEventHook();
|
|
167
|
+
const onEndHook = createEventHook();
|
|
168
|
+
const canUndo = ref(false);
|
|
169
|
+
const canRedo = ref(false);
|
|
170
|
+
const altPressed = ref(false);
|
|
171
|
+
const shiftPressed = ref(false);
|
|
172
|
+
const brush = ref({
|
|
173
|
+
color: "black",
|
|
174
|
+
size: 3,
|
|
175
|
+
arrowEnd: false,
|
|
176
|
+
cornerRadius: 0,
|
|
177
|
+
dasharray: void 0,
|
|
178
|
+
fill: "transparent",
|
|
179
|
+
mode: "draw"
|
|
180
|
+
});
|
|
181
|
+
watch(brush, () => {
|
|
182
|
+
const instance = drauuInstance.value;
|
|
183
|
+
if (instance)
|
|
184
|
+
instance.brush = brush.value;
|
|
185
|
+
}, { deep: true });
|
|
186
|
+
const undo = () => {
|
|
187
|
+
var _a;
|
|
188
|
+
return (_a = drauuInstance.value) == null ? void 0 : _a.undo();
|
|
189
|
+
};
|
|
190
|
+
const redo = () => {
|
|
191
|
+
var _a;
|
|
192
|
+
return (_a = drauuInstance.value) == null ? void 0 : _a.redo();
|
|
193
|
+
};
|
|
194
|
+
const clear = () => {
|
|
195
|
+
var _a;
|
|
196
|
+
return (_a = drauuInstance.value) == null ? void 0 : _a.clear();
|
|
197
|
+
};
|
|
198
|
+
const cancel = () => {
|
|
199
|
+
var _a;
|
|
200
|
+
return (_a = drauuInstance.value) == null ? void 0 : _a.cancel();
|
|
201
|
+
};
|
|
202
|
+
const load = (svg) => {
|
|
203
|
+
var _a;
|
|
204
|
+
return (_a = drauuInstance.value) == null ? void 0 : _a.load(svg);
|
|
205
|
+
};
|
|
206
|
+
const dump = () => {
|
|
207
|
+
var _a;
|
|
208
|
+
return (_a = drauuInstance.value) == null ? void 0 : _a.dump();
|
|
209
|
+
};
|
|
210
|
+
const cleanup = () => {
|
|
211
|
+
var _a;
|
|
212
|
+
disposables.forEach((dispose) => dispose());
|
|
213
|
+
(_a = drauuInstance.value) == null ? void 0 : _a.unmount();
|
|
214
|
+
};
|
|
215
|
+
const syncStatus = () => {
|
|
216
|
+
if (drauuInstance.value) {
|
|
217
|
+
canUndo.value = drauuInstance.value.canUndo();
|
|
218
|
+
canRedo.value = drauuInstance.value.canRedo();
|
|
219
|
+
altPressed.value = drauuInstance.value.altPressed;
|
|
220
|
+
shiftPressed.value = drauuInstance.value.shiftPressed;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
watch(() => unrefElement(target), (el) => {
|
|
224
|
+
if (!el || !(el instanceof SVGSVGElement))
|
|
225
|
+
return;
|
|
226
|
+
if (drauuInstance.value)
|
|
227
|
+
cleanup();
|
|
228
|
+
drauuInstance.value = createDrauu(__spreadValues$1({ el }, options));
|
|
229
|
+
syncStatus();
|
|
230
|
+
disposables = [
|
|
231
|
+
drauuInstance.value.on("canceled", () => onCanceledHook.trigger()),
|
|
232
|
+
drauuInstance.value.on("committed", () => onCommittedHook.trigger()),
|
|
233
|
+
drauuInstance.value.on("start", () => onStartHook.trigger()),
|
|
234
|
+
drauuInstance.value.on("end", () => onEndHook.trigger()),
|
|
235
|
+
drauuInstance.value.on("changed", () => {
|
|
236
|
+
syncStatus();
|
|
237
|
+
onChangedHook.trigger();
|
|
238
|
+
})
|
|
239
|
+
];
|
|
240
|
+
}, { flush: "post" });
|
|
241
|
+
tryOnScopeDispose(() => cleanup());
|
|
242
|
+
return {
|
|
243
|
+
drauuInstance,
|
|
244
|
+
load,
|
|
245
|
+
dump,
|
|
246
|
+
clear,
|
|
247
|
+
cancel,
|
|
248
|
+
undo,
|
|
249
|
+
redo,
|
|
250
|
+
canUndo,
|
|
251
|
+
canRedo,
|
|
252
|
+
brush,
|
|
253
|
+
onChanged: onChangedHook.on,
|
|
254
|
+
onCommitted: onCommittedHook.on,
|
|
255
|
+
onStart: onStartHook.on,
|
|
256
|
+
onEnd: onEndHook.on,
|
|
257
|
+
onCanceled: onCanceledHook.on
|
|
258
|
+
};
|
|
286
259
|
}
|
|
287
260
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
261
|
+
var __defProp = Object.defineProperty;
|
|
262
|
+
var __defProps = Object.defineProperties;
|
|
263
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
264
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
265
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
266
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
267
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
268
|
+
var __spreadValues = (a, b) => {
|
|
269
|
+
for (var prop in b || (b = {}))
|
|
270
|
+
if (__hasOwnProp.call(b, prop))
|
|
271
|
+
__defNormalProp(a, prop, b[prop]);
|
|
272
|
+
if (__getOwnPropSymbols)
|
|
273
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
274
|
+
if (__propIsEnum.call(b, prop))
|
|
275
|
+
__defNormalProp(a, prop, b[prop]);
|
|
276
|
+
}
|
|
277
|
+
return a;
|
|
278
|
+
};
|
|
279
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
280
|
+
var __objRest = (source, exclude) => {
|
|
281
|
+
var target = {};
|
|
282
|
+
for (var prop in source)
|
|
283
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
284
|
+
target[prop] = source[prop];
|
|
285
|
+
if (source != null && __getOwnPropSymbols)
|
|
286
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
287
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
288
|
+
target[prop] = source[prop];
|
|
289
|
+
}
|
|
290
|
+
return target;
|
|
291
|
+
};
|
|
292
|
+
function useFocusTrap(target, options = {}) {
|
|
293
|
+
let trap;
|
|
294
|
+
const _a = options, { immediate } = _a, focusTrapOptions = __objRest(_a, ["immediate"]);
|
|
295
|
+
const hasFocus = ref(false);
|
|
296
|
+
const isPaused = ref(false);
|
|
297
|
+
const activate = (opts) => trap && trap.activate(opts);
|
|
298
|
+
const deactivate = (opts) => trap && trap.deactivate(opts);
|
|
299
|
+
const pause = () => {
|
|
300
|
+
if (trap) {
|
|
301
|
+
trap.pause();
|
|
302
|
+
isPaused.value = true;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const unpause = () => {
|
|
306
|
+
if (trap) {
|
|
307
|
+
trap.unpause();
|
|
308
|
+
isPaused.value = false;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
watch(() => unrefElement(target), (el) => {
|
|
312
|
+
if (!el)
|
|
313
|
+
return;
|
|
314
|
+
trap = createFocusTrap(el, __spreadProps(__spreadValues({}, focusTrapOptions), {
|
|
315
|
+
onActivate() {
|
|
316
|
+
hasFocus.value = true;
|
|
317
|
+
if (options.onActivate)
|
|
318
|
+
options.onActivate();
|
|
319
|
+
},
|
|
320
|
+
onDeactivate() {
|
|
321
|
+
hasFocus.value = false;
|
|
322
|
+
if (options.onDeactivate)
|
|
323
|
+
options.onDeactivate();
|
|
324
|
+
}
|
|
325
|
+
}));
|
|
326
|
+
if (immediate)
|
|
327
|
+
activate();
|
|
328
|
+
}, { flush: "post" });
|
|
329
|
+
tryOnScopeDispose$1(() => deactivate());
|
|
330
|
+
return {
|
|
331
|
+
hasFocus,
|
|
332
|
+
isPaused,
|
|
333
|
+
activate,
|
|
334
|
+
deactivate,
|
|
335
|
+
pause,
|
|
336
|
+
unpause
|
|
337
|
+
};
|
|
344
338
|
}
|
|
345
339
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
return {
|
|
367
|
-
header,
|
|
368
|
-
payload,
|
|
369
|
-
};
|
|
340
|
+
function useJwt(encodedJwt, options = {}) {
|
|
341
|
+
const encodedJwtRef = ref(encodedJwt);
|
|
342
|
+
const {
|
|
343
|
+
onError,
|
|
344
|
+
fallbackValue = null
|
|
345
|
+
} = options;
|
|
346
|
+
const decodeWithFallback = (encodedJwt2, options2) => {
|
|
347
|
+
try {
|
|
348
|
+
return jwt_decode(encodedJwt2, options2);
|
|
349
|
+
} catch (err) {
|
|
350
|
+
onError == null ? void 0 : onError(err);
|
|
351
|
+
return fallbackValue;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const header = computed(() => decodeWithFallback(encodedJwtRef.value, { header: true }));
|
|
355
|
+
const payload = computed(() => decodeWithFallback(encodedJwtRef.value));
|
|
356
|
+
return {
|
|
357
|
+
header,
|
|
358
|
+
payload
|
|
359
|
+
};
|
|
370
360
|
}
|
|
371
361
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
isLoading,
|
|
401
|
-
progress,
|
|
402
|
-
start: nprogress.start,
|
|
403
|
-
done: nprogress.done,
|
|
404
|
-
remove: () => {
|
|
405
|
-
progress.value = null;
|
|
406
|
-
nprogress.remove();
|
|
407
|
-
},
|
|
408
|
-
};
|
|
362
|
+
function useNProgress(currentProgress = null, options) {
|
|
363
|
+
const progress = isRef(currentProgress) ? currentProgress : ref(currentProgress);
|
|
364
|
+
const isLoading = computed({
|
|
365
|
+
set: (load) => load ? nprogress.start() : nprogress.done(),
|
|
366
|
+
get: () => isNumber(progress.value) && progress.value < 1
|
|
367
|
+
});
|
|
368
|
+
if (options)
|
|
369
|
+
nprogress.configure(options);
|
|
370
|
+
const setProgress = nprogress.set;
|
|
371
|
+
nprogress.set = (n) => {
|
|
372
|
+
progress.value = n;
|
|
373
|
+
return setProgress.call(nprogress, n);
|
|
374
|
+
};
|
|
375
|
+
watchEffect(() => {
|
|
376
|
+
if (isNumber(progress.value))
|
|
377
|
+
setProgress.call(nprogress, progress.value);
|
|
378
|
+
});
|
|
379
|
+
tryOnScopeDispose(nprogress.remove);
|
|
380
|
+
return {
|
|
381
|
+
isLoading,
|
|
382
|
+
progress,
|
|
383
|
+
start: nprogress.start,
|
|
384
|
+
done: nprogress.done,
|
|
385
|
+
remove: () => {
|
|
386
|
+
progress.value = null;
|
|
387
|
+
nprogress.remove();
|
|
388
|
+
}
|
|
389
|
+
};
|
|
409
390
|
}
|
|
410
391
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const src = ref(text);
|
|
420
|
-
const result = ref('');
|
|
421
|
-
watch(src, async (value) => {
|
|
422
|
-
if (src.value && isClient)
|
|
423
|
-
result.value = await QRCode.toDataURL(value, options);
|
|
424
|
-
}, { immediate: true });
|
|
425
|
-
return result;
|
|
392
|
+
function useQRCode(text, options) {
|
|
393
|
+
const src = ref(text);
|
|
394
|
+
const result = ref("");
|
|
395
|
+
watch(src, async (value) => {
|
|
396
|
+
if (src.value && isClient)
|
|
397
|
+
result.value = await QRCode.toDataURL(value, options);
|
|
398
|
+
}, { immediate: true });
|
|
399
|
+
return result;
|
|
426
400
|
}
|
|
427
401
|
|
|
428
402
|
export { createCookies, useAxios, useCookies, useDrauu, useFocusTrap, useJwt, useNProgress, useQRCode };
|