@vueuse/integrations 6.3.2 → 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/README.md +1 -0
- package/index.cjs +378 -312
- package/index.d.ts +32 -4
- package/index.iife.js +378 -314
- package/index.iife.min.js +1 -1
- package/index.mjs +379 -314
- package/package.json +9 -4
- 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 +127 -0
- package/useDrauu.d.ts +32 -0
- package/useDrauu.iife.js +186 -0
- package/useDrauu.iife.min.js +1 -0
- package/useDrauu.mjs +123 -0
- 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,337 +1,402 @@
|
|
|
1
|
-
import { shallowRef, ref,
|
|
1
|
+
import { shallowRef, ref, watch, computed, isRef, watchEffect } from 'vue-demi';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { tryOnScopeDispose, isNumber, isClient } from '@vueuse/shared';
|
|
4
4
|
import Cookie from 'universal-cookie';
|
|
5
|
+
import { createDrauu } from 'drauu';
|
|
6
|
+
import { createEventHook, unrefElement, tryOnScopeDispose as tryOnScopeDispose$1 } from '@vueuse/core';
|
|
5
7
|
import { createFocusTrap } from 'focus-trap';
|
|
6
8
|
import jwt_decode from 'jwt-decode';
|
|
7
9
|
import nprogress from 'nprogress';
|
|
8
10
|
import QRCode from 'qrcode';
|
|
9
11
|
|
|
10
|
-
|
|
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
|
-
|
|
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
|
+
};
|
|
75
81
|
}
|
|
76
82
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
|
|
97
|
-
let previousCookies = cookies.getAll({ doNotParse: true });
|
|
98
|
-
/**
|
|
99
|
-
* Adds reactivity to get/getAll methods
|
|
100
|
-
*/
|
|
101
|
-
const touches = ref(0);
|
|
102
|
-
const onChange = () => {
|
|
103
|
-
const newCookies = cookies.getAll({ doNotParse: true });
|
|
104
|
-
if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies))
|
|
105
|
-
touches.value++;
|
|
106
|
-
previousCookies = newCookies;
|
|
107
|
-
};
|
|
108
|
-
cookies.addChangeListener(onChange);
|
|
109
|
-
tryOnScopeDispose(() => {
|
|
110
|
-
cookies.removeChangeListener(onChange);
|
|
111
|
-
});
|
|
112
|
-
return {
|
|
113
|
-
/**
|
|
114
|
-
* Reactive get cookie by name. If **autoUpdateDependencies = true** then it will update watching dependencies
|
|
115
|
-
*/
|
|
116
|
-
get: (...args) => {
|
|
117
|
-
/**
|
|
118
|
-
* Auto update watching dependencies if needed
|
|
119
|
-
*/
|
|
120
|
-
if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0]))
|
|
121
|
-
watchingDependencies.push(args[0]);
|
|
122
|
-
// eslint-disable-next-line no-unused-expressions
|
|
123
|
-
touches.value; // adds reactivity to method
|
|
124
|
-
return cookies.get(args[0], Object.assign({ doNotParse }, args[1]));
|
|
125
|
-
},
|
|
126
|
-
/**
|
|
127
|
-
* Reactive get all cookies
|
|
128
|
-
*/
|
|
129
|
-
getAll: (...args) => {
|
|
130
|
-
// eslint-disable-next-line no-unused-expressions
|
|
131
|
-
touches.value; // adds reactivity to method
|
|
132
|
-
return cookies.getAll(Object.assign({ doNotParse }, args[0]));
|
|
133
|
-
},
|
|
134
|
-
set: (...args) => cookies.set(...args),
|
|
135
|
-
remove: (...args) => cookies.remove(...args),
|
|
136
|
-
addChangeListener: (...args) => cookies.addChangeListener(...args),
|
|
137
|
-
removeChangeListener: (...args) => cookies.removeChangeListener(...args),
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function shouldUpdate(dependencies, newCookies, oldCookies) {
|
|
141
|
-
if (!dependencies)
|
|
142
|
-
return true;
|
|
143
|
-
for (const dependency of dependencies) {
|
|
144
|
-
if (newCookies[dependency] !== oldCookies[dependency])
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
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);
|
|
148
102
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
+
};
|
|
175
133
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const plain = unref(elRef);
|
|
185
|
-
return (_b = (_a = plain) === null || _a === void 0 ? void 0 : _a.$el) !== null && _b !== void 0 ? _b : plain;
|
|
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;
|
|
186
142
|
}
|
|
187
143
|
|
|
188
|
-
var
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
+
};
|
|
259
|
+
}
|
|
196
260
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
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
|
+
};
|
|
253
338
|
}
|
|
254
339
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return {
|
|
276
|
-
header,
|
|
277
|
-
payload,
|
|
278
|
-
};
|
|
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
|
+
};
|
|
279
360
|
}
|
|
280
361
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
isLoading,
|
|
310
|
-
progress,
|
|
311
|
-
start: nprogress.start,
|
|
312
|
-
done: nprogress.done,
|
|
313
|
-
remove: () => {
|
|
314
|
-
progress.value = null;
|
|
315
|
-
nprogress.remove();
|
|
316
|
-
},
|
|
317
|
-
};
|
|
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
|
+
};
|
|
318
390
|
}
|
|
319
391
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const src = ref(text);
|
|
329
|
-
const result = ref('');
|
|
330
|
-
watch(src, async (value) => {
|
|
331
|
-
if (src.value && isClient)
|
|
332
|
-
result.value = await QRCode.toDataURL(value, options);
|
|
333
|
-
}, { immediate: true });
|
|
334
|
-
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;
|
|
335
400
|
}
|
|
336
401
|
|
|
337
|
-
export { createCookies, useAxios, useCookies, useFocusTrap, useJwt, useNProgress, useQRCode };
|
|
402
|
+
export { createCookies, useAxios, useCookies, useDrauu, useFocusTrap, useJwt, useNProgress, useQRCode };
|