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