@vueuse/integrations 6.4.1 → 6.5.3

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