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