@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/index.cjs CHANGED
@@ -6,7 +6,10 @@ var vueDemi = require('vue-demi');
6
6
  var axios = require('axios');
7
7
  var shared = require('@vueuse/shared');
8
8
  var Cookie = require('universal-cookie');
9
+ var drauu = require('drauu');
10
+ var core = require('@vueuse/core');
9
11
  var focusTrap = require('focus-trap');
12
+ var Fuse = require('fuse.js');
10
13
  var jwt_decode = require('jwt-decode');
11
14
  var nprogress = require('nprogress');
12
15
  var QRCode = require('qrcode');
@@ -15,341 +18,436 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
15
18
 
16
19
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
17
20
  var Cookie__default = /*#__PURE__*/_interopDefaultLegacy(Cookie);
21
+ var Fuse__default = /*#__PURE__*/_interopDefaultLegacy(Fuse);
18
22
  var jwt_decode__default = /*#__PURE__*/_interopDefaultLegacy(jwt_decode);
19
23
  var nprogress__default = /*#__PURE__*/_interopDefaultLegacy(nprogress);
20
24
  var QRCode__default = /*#__PURE__*/_interopDefaultLegacy(QRCode);
21
25
 
22
- /**
23
- * Wrapper for axios.
24
- *
25
- * @see https://vueuse.org/useAxios
26
- * @param url
27
- * @param config
28
- */
29
- function useAxios(url, ...args) {
30
- let config = {};
31
- let instance = axios__default['default'];
32
- if (args.length > 0) {
33
- /**
34
- * Unable to use `instanceof` here becuase of (https://github.com/axios/axios/issues/737)
35
- * so instead we are checking if there is a `requset` on the object to see if it is an
36
- * axios instance
37
- */
38
- if ('request' in args[0])
39
- instance = args[0];
40
- else
41
- config = args[0];
42
- }
43
- if (args.length > 1) {
44
- if ('request' in args[1])
45
- instance = args[1];
46
- }
47
- const response = vueDemi.shallowRef();
48
- const data = vueDemi.shallowRef();
49
- const isFinished = vueDemi.ref(false);
50
- const isLoading = vueDemi.ref(true);
51
- const aborted = vueDemi.ref(false);
52
- const error = vueDemi.shallowRef();
53
- const cancelToken = axios__default['default'].CancelToken.source();
54
- const abort = (message) => {
55
- if (isFinished.value || !isLoading.value)
56
- return;
57
- cancelToken.cancel(message);
58
- aborted.value = true;
59
- isLoading.value = false;
60
- isFinished.value = false;
61
- };
62
- instance(url, Object.assign(Object.assign({}, config), { cancelToken: cancelToken.token }))
63
- .then((r) => {
64
- response.value = r;
65
- data.value = r.data;
66
- })
67
- .catch((e) => {
68
- error.value = e;
69
- })
70
- .finally(() => {
71
- isLoading.value = false;
72
- isFinished.value = true;
73
- });
74
- return {
75
- response,
76
- data,
77
- error,
78
- finished: isFinished,
79
- loading: isLoading,
80
- isFinished,
81
- isLoading,
82
- cancel: abort,
83
- canceled: aborted,
84
- aborted,
85
- abort,
86
- };
26
+ var __defProp$3 = Object.defineProperty;
27
+ var __defProps$1 = Object.defineProperties;
28
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
29
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
30
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
31
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
32
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
33
+ var __spreadValues$3 = (a, b) => {
34
+ for (var prop in b || (b = {}))
35
+ if (__hasOwnProp$3.call(b, prop))
36
+ __defNormalProp$3(a, prop, b[prop]);
37
+ if (__getOwnPropSymbols$3)
38
+ for (var prop of __getOwnPropSymbols$3(b)) {
39
+ if (__propIsEnum$3.call(b, prop))
40
+ __defNormalProp$3(a, prop, b[prop]);
41
+ }
42
+ return a;
43
+ };
44
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
45
+ function useAxios(url, ...args) {
46
+ let config = {};
47
+ let instance = axios__default["default"];
48
+ if (args.length > 0) {
49
+ if ("request" in args[0])
50
+ instance = args[0];
51
+ else
52
+ config = args[0];
53
+ }
54
+ if (args.length > 1) {
55
+ if ("request" in args[1])
56
+ instance = args[1];
57
+ }
58
+ const response = vueDemi.shallowRef();
59
+ const data = vueDemi.shallowRef();
60
+ const isFinished = vueDemi.ref(false);
61
+ const isLoading = vueDemi.ref(true);
62
+ const aborted = vueDemi.ref(false);
63
+ const error = vueDemi.shallowRef();
64
+ const cancelToken = axios__default["default"].CancelToken.source();
65
+ const abort = (message) => {
66
+ if (isFinished.value || !isLoading.value)
67
+ return;
68
+ cancelToken.cancel(message);
69
+ aborted.value = true;
70
+ isLoading.value = false;
71
+ isFinished.value = false;
72
+ };
73
+ instance(url, __spreadProps$1(__spreadValues$3({}, config), { cancelToken: cancelToken.token })).then((r) => {
74
+ response.value = r;
75
+ data.value = r.data;
76
+ }).catch((e) => {
77
+ error.value = e;
78
+ }).finally(() => {
79
+ isLoading.value = false;
80
+ isFinished.value = true;
81
+ });
82
+ return {
83
+ response,
84
+ data,
85
+ error,
86
+ finished: isFinished,
87
+ loading: isLoading,
88
+ isFinished,
89
+ isLoading,
90
+ cancel: abort,
91
+ canceled: aborted,
92
+ aborted,
93
+ abort
94
+ };
87
95
  }
88
96
 
89
- /**
90
- * Creates a new {@link useCookies} function
91
- * @param {Object} req - incoming http request (for SSR)
92
- * @see https://github.com/reactivestack/cookies/tree/master/packages/universal-cookie universal-cookie
93
- * @description Creates universal-cookie instance using request (default is window.document.cookie) and returns {@link useCookies} function with provided universal-cookie instance
94
- */
95
- function createCookies(req) {
96
- const universalCookie = new Cookie__default['default'](req ? req.headers.cookie : null);
97
- return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
98
- }
99
- /**
100
- * Reactive methods to work with cookies (use {@link createCookies} method instead if you are using SSR)
101
- * @param {string[]|null|undefined} dependencies - array of watching cookie's names. Pass empty array if don't want to watch cookies changes.
102
- * @param {Object} options
103
- * @param {boolean} options.doNotParse - don't try parse value as JSON
104
- * @param {boolean} options.autoUpdateDependencies - automatically update watching dependencies
105
- * @param {Object} cookies - universal-cookie instance
106
- */
107
- function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie__default['default']()) {
108
- const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
109
- let previousCookies = cookies.getAll({ doNotParse: true });
110
- /**
111
- * Adds reactivity to get/getAll methods
112
- */
113
- const touches = vueDemi.ref(0);
114
- const onChange = () => {
115
- const newCookies = cookies.getAll({ doNotParse: true });
116
- if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies))
117
- touches.value++;
118
- previousCookies = newCookies;
119
- };
120
- cookies.addChangeListener(onChange);
121
- shared.tryOnScopeDispose(() => {
122
- cookies.removeChangeListener(onChange);
123
- });
124
- return {
125
- /**
126
- * Reactive get cookie by name. If **autoUpdateDependencies = true** then it will update watching dependencies
127
- */
128
- get: (...args) => {
129
- /**
130
- * Auto update watching dependencies if needed
131
- */
132
- if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0]))
133
- watchingDependencies.push(args[0]);
134
- // eslint-disable-next-line no-unused-expressions
135
- touches.value; // adds reactivity to method
136
- return cookies.get(args[0], Object.assign({ doNotParse }, args[1]));
137
- },
138
- /**
139
- * Reactive get all cookies
140
- */
141
- getAll: (...args) => {
142
- // eslint-disable-next-line no-unused-expressions
143
- touches.value; // adds reactivity to method
144
- return cookies.getAll(Object.assign({ doNotParse }, args[0]));
145
- },
146
- set: (...args) => cookies.set(...args),
147
- remove: (...args) => cookies.remove(...args),
148
- addChangeListener: (...args) => cookies.addChangeListener(...args),
149
- removeChangeListener: (...args) => cookies.removeChangeListener(...args),
150
- };
151
- }
152
- function shouldUpdate(dependencies, newCookies, oldCookies) {
153
- if (!dependencies)
154
- return true;
155
- for (const dependency of dependencies) {
156
- if (newCookies[dependency] !== oldCookies[dependency])
157
- return true;
158
- }
159
- return false;
97
+ var __defProp$2 = Object.defineProperty;
98
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
99
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
100
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
101
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
102
+ var __spreadValues$2 = (a, b) => {
103
+ for (var prop in b || (b = {}))
104
+ if (__hasOwnProp$2.call(b, prop))
105
+ __defNormalProp$2(a, prop, b[prop]);
106
+ if (__getOwnPropSymbols$2)
107
+ for (var prop of __getOwnPropSymbols$2(b)) {
108
+ if (__propIsEnum$2.call(b, prop))
109
+ __defNormalProp$2(a, prop, b[prop]);
110
+ }
111
+ return a;
112
+ };
113
+ function createCookies(req) {
114
+ const universalCookie = new Cookie__default["default"](req ? req.headers.cookie : null);
115
+ return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
160
116
  }
161
-
162
- /*! *****************************************************************************
163
- Copyright (c) Microsoft Corporation.
164
-
165
- Permission to use, copy, modify, and/or distribute this software for any
166
- purpose with or without fee is hereby granted.
167
-
168
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
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;
117
+ function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie__default["default"]()) {
118
+ const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
119
+ let previousCookies = cookies.getAll({ doNotParse: true });
120
+ const touches = vueDemi.ref(0);
121
+ const onChange = () => {
122
+ const newCookies = cookies.getAll({ doNotParse: true });
123
+ if (shouldUpdate(watchingDependencies || null, newCookies, previousCookies))
124
+ touches.value++;
125
+ previousCookies = newCookies;
126
+ };
127
+ cookies.addChangeListener(onChange);
128
+ shared.tryOnScopeDispose(() => {
129
+ cookies.removeChangeListener(onChange);
130
+ });
131
+ return {
132
+ get: (...args) => {
133
+ if (autoUpdateDependencies && watchingDependencies && !watchingDependencies.includes(args[0]))
134
+ watchingDependencies.push(args[0]);
135
+ touches.value;
136
+ return cookies.get(args[0], __spreadValues$2({ doNotParse }, args[1]));
137
+ },
138
+ getAll: (...args) => {
139
+ touches.value;
140
+ return cookies.getAll(__spreadValues$2({ doNotParse }, args[0]));
141
+ },
142
+ set: (...args) => cookies.set(...args),
143
+ remove: (...args) => cookies.remove(...args),
144
+ addChangeListener: (...args) => cookies.addChangeListener(...args),
145
+ removeChangeListener: (...args) => cookies.removeChangeListener(...args)
146
+ };
147
+ }
148
+ function shouldUpdate(dependencies, newCookies, oldCookies) {
149
+ if (!dependencies)
150
+ return true;
151
+ for (const dependency of dependencies) {
152
+ if (newCookies[dependency] !== oldCookies[dependency])
153
+ return true;
154
+ }
155
+ return false;
187
156
  }
188
157
 
189
- /**
190
- * Get the dom element of a ref of element or Vue component instance
191
- *
192
- * @param elRef
193
- */
194
- function unrefElement(elRef) {
195
- var _a, _b;
196
- const plain = vueDemi.unref(elRef);
197
- return (_b = (_a = plain) === null || _a === void 0 ? void 0 : _a.$el) !== null && _b !== void 0 ? _b : plain;
158
+ var __defProp$1 = Object.defineProperty;
159
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
160
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
161
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
162
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
163
+ var __spreadValues$1 = (a, b) => {
164
+ for (var prop in b || (b = {}))
165
+ if (__hasOwnProp$1.call(b, prop))
166
+ __defNormalProp$1(a, prop, b[prop]);
167
+ if (__getOwnPropSymbols$1)
168
+ for (var prop of __getOwnPropSymbols$1(b)) {
169
+ if (__propIsEnum$1.call(b, prop))
170
+ __defNormalProp$1(a, prop, b[prop]);
171
+ }
172
+ return a;
173
+ };
174
+ function useDrauu(target, options) {
175
+ const drauuInstance = vueDemi.ref();
176
+ let disposables = [];
177
+ const onChangedHook = core.createEventHook();
178
+ const onCanceledHook = core.createEventHook();
179
+ const onCommittedHook = core.createEventHook();
180
+ const onStartHook = core.createEventHook();
181
+ const onEndHook = core.createEventHook();
182
+ const canUndo = vueDemi.ref(false);
183
+ const canRedo = vueDemi.ref(false);
184
+ const altPressed = vueDemi.ref(false);
185
+ const shiftPressed = vueDemi.ref(false);
186
+ const brush = vueDemi.ref({
187
+ color: "black",
188
+ size: 3,
189
+ arrowEnd: false,
190
+ cornerRadius: 0,
191
+ dasharray: void 0,
192
+ fill: "transparent",
193
+ mode: "draw"
194
+ });
195
+ vueDemi.watch(brush, () => {
196
+ const instance = drauuInstance.value;
197
+ if (instance)
198
+ instance.brush = brush.value;
199
+ }, { deep: true });
200
+ const undo = () => {
201
+ var _a;
202
+ return (_a = drauuInstance.value) == null ? void 0 : _a.undo();
203
+ };
204
+ const redo = () => {
205
+ var _a;
206
+ return (_a = drauuInstance.value) == null ? void 0 : _a.redo();
207
+ };
208
+ const clear = () => {
209
+ var _a;
210
+ return (_a = drauuInstance.value) == null ? void 0 : _a.clear();
211
+ };
212
+ const cancel = () => {
213
+ var _a;
214
+ return (_a = drauuInstance.value) == null ? void 0 : _a.cancel();
215
+ };
216
+ const load = (svg) => {
217
+ var _a;
218
+ return (_a = drauuInstance.value) == null ? void 0 : _a.load(svg);
219
+ };
220
+ const dump = () => {
221
+ var _a;
222
+ return (_a = drauuInstance.value) == null ? void 0 : _a.dump();
223
+ };
224
+ const cleanup = () => {
225
+ var _a;
226
+ disposables.forEach((dispose) => dispose());
227
+ (_a = drauuInstance.value) == null ? void 0 : _a.unmount();
228
+ };
229
+ const syncStatus = () => {
230
+ if (drauuInstance.value) {
231
+ canUndo.value = drauuInstance.value.canUndo();
232
+ canRedo.value = drauuInstance.value.canRedo();
233
+ altPressed.value = drauuInstance.value.altPressed;
234
+ shiftPressed.value = drauuInstance.value.shiftPressed;
235
+ }
236
+ };
237
+ vueDemi.watch(() => core.unrefElement(target), (el) => {
238
+ if (!el || !(el instanceof SVGSVGElement))
239
+ return;
240
+ if (drauuInstance.value)
241
+ cleanup();
242
+ drauuInstance.value = drauu.createDrauu(__spreadValues$1({ el }, options));
243
+ syncStatus();
244
+ disposables = [
245
+ drauuInstance.value.on("canceled", () => onCanceledHook.trigger()),
246
+ drauuInstance.value.on("committed", () => onCommittedHook.trigger()),
247
+ drauuInstance.value.on("start", () => onStartHook.trigger()),
248
+ drauuInstance.value.on("end", () => onEndHook.trigger()),
249
+ drauuInstance.value.on("changed", () => {
250
+ syncStatus();
251
+ onChangedHook.trigger();
252
+ })
253
+ ];
254
+ }, { flush: "post" });
255
+ shared.tryOnScopeDispose(() => cleanup());
256
+ return {
257
+ drauuInstance,
258
+ load,
259
+ dump,
260
+ clear,
261
+ cancel,
262
+ undo,
263
+ redo,
264
+ canUndo,
265
+ canRedo,
266
+ brush,
267
+ onChanged: onChangedHook.on,
268
+ onCommitted: onCommittedHook.on,
269
+ onStart: onStartHook.on,
270
+ onEnd: onEndHook.on,
271
+ onCanceled: onCanceledHook.on
272
+ };
198
273
  }
199
274
 
200
- var SwipeDirection;
201
- (function (SwipeDirection) {
202
- SwipeDirection["UP"] = "UP";
203
- SwipeDirection["RIGHT"] = "RIGHT";
204
- SwipeDirection["DOWN"] = "DOWN";
205
- SwipeDirection["LEFT"] = "LEFT";
206
- SwipeDirection["NONE"] = "NONE";
207
- })(SwipeDirection || (SwipeDirection = {}));
275
+ var __defProp = Object.defineProperty;
276
+ var __defProps = Object.defineProperties;
277
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
278
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
279
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
280
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
281
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
282
+ var __spreadValues = (a, b) => {
283
+ for (var prop in b || (b = {}))
284
+ if (__hasOwnProp.call(b, prop))
285
+ __defNormalProp(a, prop, b[prop]);
286
+ if (__getOwnPropSymbols)
287
+ for (var prop of __getOwnPropSymbols(b)) {
288
+ if (__propIsEnum.call(b, prop))
289
+ __defNormalProp(a, prop, b[prop]);
290
+ }
291
+ return a;
292
+ };
293
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
294
+ var __objRest = (source, exclude) => {
295
+ var target = {};
296
+ for (var prop in source)
297
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
298
+ target[prop] = source[prop];
299
+ if (source != null && __getOwnPropSymbols)
300
+ for (var prop of __getOwnPropSymbols(source)) {
301
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
302
+ target[prop] = source[prop];
303
+ }
304
+ return target;
305
+ };
306
+ function useFocusTrap(target, options = {}) {
307
+ let trap;
308
+ const _a = options, { immediate } = _a, focusTrapOptions = __objRest(_a, ["immediate"]);
309
+ const hasFocus = vueDemi.ref(false);
310
+ const isPaused = vueDemi.ref(false);
311
+ const activate = (opts) => trap && trap.activate(opts);
312
+ const deactivate = (opts) => trap && trap.deactivate(opts);
313
+ const pause = () => {
314
+ if (trap) {
315
+ trap.pause();
316
+ isPaused.value = true;
317
+ }
318
+ };
319
+ const unpause = () => {
320
+ if (trap) {
321
+ trap.unpause();
322
+ isPaused.value = false;
323
+ }
324
+ };
325
+ vueDemi.watch(() => core.unrefElement(target), (el) => {
326
+ if (!el)
327
+ return;
328
+ trap = focusTrap.createFocusTrap(el, __spreadProps(__spreadValues({}, focusTrapOptions), {
329
+ onActivate() {
330
+ hasFocus.value = true;
331
+ if (options.onActivate)
332
+ options.onActivate();
333
+ },
334
+ onDeactivate() {
335
+ hasFocus.value = false;
336
+ if (options.onDeactivate)
337
+ options.onDeactivate();
338
+ }
339
+ }));
340
+ if (immediate)
341
+ activate();
342
+ }, { flush: "post" });
343
+ core.tryOnScopeDispose(() => deactivate());
344
+ return {
345
+ hasFocus,
346
+ isPaused,
347
+ activate,
348
+ deactivate,
349
+ pause,
350
+ unpause
351
+ };
352
+ }
208
353
 
209
- /**
210
- * Reactive focus-trap
211
- *
212
- * @see https://vueuse.org/useFocusTrap
213
- * @param target The target element to trap focus within
214
- * @param options Focus trap options
215
- * @param autoFocus Focus trap automatically when mounted
216
- */
217
- function useFocusTrap(target, options = {}) {
218
- let trap;
219
- const { immediate } = options, focusTrapOptions = __rest(options, ["immediate"]);
220
- const hasFocus = vueDemi.ref(false);
221
- const isPaused = vueDemi.ref(false);
222
- const activate = (opts) => trap && trap.activate(opts);
223
- const deactivate = (opts) => trap && trap.deactivate(opts);
224
- const pause = () => {
225
- if (trap) {
226
- trap.pause();
227
- isPaused.value = true;
228
- }
229
- };
230
- const unpause = () => {
231
- if (trap) {
232
- trap.unpause();
233
- isPaused.value = false;
234
- }
235
- };
236
- vueDemi.watch(() => unrefElement(target), (el) => {
237
- if (!el)
238
- return;
239
- trap = focusTrap.createFocusTrap(el, Object.assign(Object.assign({}, focusTrapOptions), { onActivate() {
240
- hasFocus.value = true;
241
- // Apply if user provided onActivate option
242
- if (options.onActivate)
243
- options.onActivate();
244
- },
245
- onDeactivate() {
246
- hasFocus.value = false;
247
- // Apply if user provided onDeactivate option
248
- if (options.onDeactivate)
249
- options.onDeactivate();
250
- } }));
251
- // Focus if immediate is set to true
252
- if (immediate)
253
- activate();
254
- }, { flush: 'post' });
255
- // Cleanup on unmount
256
- shared.tryOnScopeDispose(() => deactivate());
257
- return {
258
- hasFocus,
259
- isPaused,
260
- activate,
261
- deactivate,
262
- pause,
263
- unpause,
264
- };
354
+ function useFuse(search, data, options) {
355
+ var _a;
356
+ const createFuse = (data2, options2) => {
357
+ var _a2;
358
+ const _options = options2;
359
+ return new Fuse__default["default"]((_a2 = vueDemi.unref(data2)) != null ? _a2 : [], _options);
360
+ };
361
+ const fuse = vueDemi.ref(createFuse(data, (_a = vueDemi.unref(options)) == null ? void 0 : _a.fuseOptions));
362
+ vueDemi.watch(() => {
363
+ var _a2;
364
+ return (_a2 = vueDemi.unref(options)) == null ? void 0 : _a2.fuseOptions;
365
+ }, (newOptions) => {
366
+ fuse.value = createFuse(data, newOptions);
367
+ }, { deep: true });
368
+ vueDemi.watch(() => vueDemi.unref(data), (newData) => {
369
+ fuse.value.setCollection(newData);
370
+ }, { deep: true });
371
+ const results = vueDemi.computed(() => {
372
+ var _a2, _b;
373
+ if (((_a2 = vueDemi.unref(options)) == null ? void 0 : _a2.matchAllWhenSearchEmpty) && !vueDemi.unref(search))
374
+ return vueDemi.unref(data).map((item, index) => ({ item, refIndex: index }));
375
+ const limit = (_b = vueDemi.unref(options)) == null ? void 0 : _b.resultLimit;
376
+ return fuse.value.search(vueDemi.unref(search), limit ? { limit } : void 0);
377
+ });
378
+ return {
379
+ results
380
+ };
265
381
  }
266
382
 
267
- /**
268
- * Reactive decoded jwt token.
269
- *
270
- * @see https://vueuse.org/useJwt
271
- * @param jwt
272
- */
273
- function useJwt(encodedJwt, options = {}) {
274
- const encodedJwtRef = vueDemi.ref(encodedJwt);
275
- const { onError, fallbackValue = null, } = options;
276
- const decodeWithFallback = (encodedJwt, options) => {
277
- try {
278
- return jwt_decode__default['default'](encodedJwt, options);
279
- }
280
- catch (err) {
281
- onError === null || onError === void 0 ? void 0 : onError(err);
282
- return fallbackValue;
283
- }
284
- };
285
- const header = vueDemi.computed(() => decodeWithFallback(encodedJwtRef.value, { header: true }));
286
- const payload = vueDemi.computed(() => decodeWithFallback(encodedJwtRef.value));
287
- return {
288
- header,
289
- payload,
290
- };
383
+ function useJwt(encodedJwt, options = {}) {
384
+ const encodedJwtRef = vueDemi.ref(encodedJwt);
385
+ const {
386
+ onError,
387
+ fallbackValue = null
388
+ } = options;
389
+ const decodeWithFallback = (encodedJwt2, options2) => {
390
+ try {
391
+ return jwt_decode__default["default"](encodedJwt2, options2);
392
+ } catch (err) {
393
+ onError == null ? void 0 : onError(err);
394
+ return fallbackValue;
395
+ }
396
+ };
397
+ const header = vueDemi.computed(() => decodeWithFallback(encodedJwtRef.value, { header: true }));
398
+ const payload = vueDemi.computed(() => decodeWithFallback(encodedJwtRef.value));
399
+ return {
400
+ header,
401
+ payload
402
+ };
291
403
  }
292
404
 
293
- /**
294
- * Reactive progress bar.
295
- *
296
- * @see https://vueuse.org/useNProgress
297
- * @param currentProgress
298
- * @param options
299
- */
300
- function useNProgress(currentProgress = null, options) {
301
- const progress = vueDemi.isRef(currentProgress)
302
- ? currentProgress
303
- : vueDemi.ref(currentProgress);
304
- const isLoading = vueDemi.computed({
305
- set: load => load ? nprogress__default['default'].start() : nprogress__default['default'].done(),
306
- get: () => shared.isNumber(progress.value) && progress.value < 1,
307
- });
308
- if (options)
309
- nprogress__default['default'].configure(options);
310
- const setProgress = nprogress__default['default'].set;
311
- nprogress__default['default'].set = (n) => {
312
- progress.value = n;
313
- return setProgress.call(nprogress__default['default'], n);
314
- };
315
- vueDemi.watchEffect(() => {
316
- if (shared.isNumber(progress.value))
317
- setProgress.call(nprogress__default['default'], progress.value);
318
- });
319
- shared.tryOnScopeDispose(nprogress__default['default'].remove);
320
- return {
321
- isLoading,
322
- progress,
323
- start: nprogress__default['default'].start,
324
- done: nprogress__default['default'].done,
325
- remove: () => {
326
- progress.value = null;
327
- nprogress__default['default'].remove();
328
- },
329
- };
405
+ function useNProgress(currentProgress = null, options) {
406
+ const progress = vueDemi.isRef(currentProgress) ? currentProgress : vueDemi.ref(currentProgress);
407
+ const isLoading = vueDemi.computed({
408
+ set: (load) => load ? nprogress__default["default"].start() : nprogress__default["default"].done(),
409
+ get: () => shared.isNumber(progress.value) && progress.value < 1
410
+ });
411
+ if (options)
412
+ nprogress__default["default"].configure(options);
413
+ const setProgress = nprogress__default["default"].set;
414
+ nprogress__default["default"].set = (n) => {
415
+ progress.value = n;
416
+ return setProgress.call(nprogress__default["default"], n);
417
+ };
418
+ vueDemi.watchEffect(() => {
419
+ if (shared.isNumber(progress.value))
420
+ setProgress.call(nprogress__default["default"], progress.value);
421
+ });
422
+ shared.tryOnScopeDispose(nprogress__default["default"].remove);
423
+ return {
424
+ isLoading,
425
+ progress,
426
+ start: nprogress__default["default"].start,
427
+ done: nprogress__default["default"].done,
428
+ remove: () => {
429
+ progress.value = null;
430
+ nprogress__default["default"].remove();
431
+ }
432
+ };
330
433
  }
331
434
 
332
- /**
333
- * Wrapper for qrcode.
334
- *
335
- * @see https://vueuse.org/useQRCode
336
- * @param text
337
- * @param options
338
- */
339
- function useQRCode(text, options) {
340
- const src = vueDemi.ref(text);
341
- const result = vueDemi.ref('');
342
- vueDemi.watch(src, async (value) => {
343
- if (src.value && shared.isClient)
344
- result.value = await QRCode__default['default'].toDataURL(value, options);
345
- }, { immediate: true });
346
- return result;
435
+ function useQRCode(text, options) {
436
+ const src = vueDemi.ref(text);
437
+ const result = vueDemi.ref("");
438
+ vueDemi.watch(src, async (value) => {
439
+ if (src.value && shared.isClient)
440
+ result.value = await QRCode__default["default"].toDataURL(value, options);
441
+ }, { immediate: true });
442
+ return result;
347
443
  }
348
444
 
349
445
  exports.createCookies = createCookies;
350
446
  exports.useAxios = useAxios;
351
447
  exports.useCookies = useCookies;
448
+ exports.useDrauu = useDrauu;
352
449
  exports.useFocusTrap = useFocusTrap;
450
+ exports.useFuse = useFuse;
353
451
  exports.useJwt = useJwt;
354
452
  exports.useNProgress = useNProgress;
355
453
  exports.useQRCode = useQRCode;