@vueuse/integrations 10.11.0 → 11.0.0-beta.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 +34 -20
- package/index.d.cts +17 -25
- package/index.d.mts +17 -25
- package/index.d.ts +17 -25
- package/index.iife.js +33 -19
- package/index.iife.min.js +1 -1
- package/index.mjs +15 -20
- package/package.json +13 -13
- package/useChangeCase.cjs +31 -17
- package/useChangeCase.d.cts +10 -19
- package/useChangeCase.d.mts +10 -19
- package/useChangeCase.d.ts +10 -19
- package/useChangeCase.iife.js +31 -17
- package/useChangeCase.iife.min.js +1 -1
- package/useChangeCase.mjs +13 -18
- package/useFuse.d.cts +7 -6
- package/useFuse.d.mts +7 -6
- package/useFuse.d.ts +7 -6
- package/useJwt.cjs +2 -2
- package/useJwt.iife.js +2 -2
- package/useJwt.iife.min.js +1 -1
- package/useJwt.mjs +2 -2
package/index.cjs
CHANGED
|
@@ -4,18 +4,37 @@ var shared = require('@vueuse/shared');
|
|
|
4
4
|
var Schema = require('async-validator');
|
|
5
5
|
var vueDemi = require('vue-demi');
|
|
6
6
|
var axios = require('axios');
|
|
7
|
-
var changeCase
|
|
7
|
+
var changeCase = require('change-case');
|
|
8
8
|
var Cookie = require('universal-cookie');
|
|
9
9
|
var drauu = require('drauu');
|
|
10
10
|
var core = require('@vueuse/core');
|
|
11
11
|
var focusTrap = require('focus-trap');
|
|
12
12
|
var Fuse = require('fuse.js');
|
|
13
13
|
var idbKeyval = require('idb-keyval');
|
|
14
|
-
var
|
|
14
|
+
var jwtDecode = require('jwt-decode');
|
|
15
15
|
var nprogress = require('nprogress');
|
|
16
16
|
var QRCode = require('qrcode');
|
|
17
17
|
var Sortable = require('sortablejs');
|
|
18
18
|
|
|
19
|
+
function _interopNamespaceDefault(e) {
|
|
20
|
+
var n = Object.create(null);
|
|
21
|
+
if (e) {
|
|
22
|
+
Object.keys(e).forEach(function (k) {
|
|
23
|
+
if (k !== 'default') {
|
|
24
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
25
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return e[k]; }
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
n.default = e;
|
|
33
|
+
return Object.freeze(n);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var changeCase__namespace = /*#__PURE__*/_interopNamespaceDefault(changeCase);
|
|
37
|
+
|
|
19
38
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
20
39
|
function useAsyncValidator(value, rules, options = {}) {
|
|
21
40
|
const {
|
|
@@ -201,28 +220,23 @@ function useAxios(...args) {
|
|
|
201
220
|
};
|
|
202
221
|
}
|
|
203
222
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
constantCase: changeCase$1.constantCase,
|
|
209
|
-
dotCase: changeCase$1.dotCase,
|
|
210
|
-
headerCase: changeCase$1.headerCase,
|
|
211
|
-
noCase: changeCase$1.noCase,
|
|
212
|
-
paramCase: changeCase$1.paramCase,
|
|
213
|
-
pascalCase: changeCase$1.pascalCase,
|
|
214
|
-
pathCase: changeCase$1.pathCase,
|
|
215
|
-
sentenceCase: changeCase$1.sentenceCase,
|
|
216
|
-
snakeCase: changeCase$1.snakeCase
|
|
217
|
-
});
|
|
218
|
-
|
|
223
|
+
const changeCaseTransforms = /* @__PURE__ */ Object.values(changeCase__namespace).filter((v) => typeof v === "function" && v.name.endsWith("Case")).reduce((acc, fn) => {
|
|
224
|
+
acc[fn.name] = fn;
|
|
225
|
+
return acc;
|
|
226
|
+
}, {});
|
|
219
227
|
function useChangeCase(input, type, options) {
|
|
228
|
+
const typeRef = vueDemi.computed(() => {
|
|
229
|
+
const t = shared.toValue(type);
|
|
230
|
+
if (!changeCaseTransforms[t])
|
|
231
|
+
throw new Error(`Invalid change case type "${t}"`);
|
|
232
|
+
return t;
|
|
233
|
+
});
|
|
220
234
|
if (typeof input === "function")
|
|
221
|
-
return vueDemi.computed(() =>
|
|
235
|
+
return vueDemi.computed(() => changeCaseTransforms[typeRef.value](shared.toValue(input), shared.toValue(options)));
|
|
222
236
|
const text = vueDemi.ref(input);
|
|
223
237
|
return vueDemi.computed({
|
|
224
238
|
get() {
|
|
225
|
-
return
|
|
239
|
+
return changeCaseTransforms[typeRef.value](text.value, shared.toValue(options));
|
|
226
240
|
},
|
|
227
241
|
set(value) {
|
|
228
242
|
text.value = value;
|
|
@@ -549,7 +563,7 @@ function useJwt(encodedJwt, options = {}) {
|
|
|
549
563
|
} = options;
|
|
550
564
|
const decodeWithFallback = (encodedJwt2, options2) => {
|
|
551
565
|
try {
|
|
552
|
-
return
|
|
566
|
+
return jwtDecode.jwtDecode(encodedJwt2, options2);
|
|
553
567
|
} catch (err) {
|
|
554
568
|
onError == null ? void 0 : onError(err);
|
|
555
569
|
return fallbackValue;
|
package/index.d.cts
CHANGED
|
@@ -3,14 +3,16 @@ import { ValidateError, ValidateOption, Rules } from 'async-validator';
|
|
|
3
3
|
import * as vue_demi from 'vue-demi';
|
|
4
4
|
import { Ref, ShallowRef, WritableComputedRef, ComputedRef } from 'vue-demi';
|
|
5
5
|
import { AxiosResponse, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
6
|
-
import
|
|
6
|
+
import * as changeCase from 'change-case';
|
|
7
|
+
import { Options } from 'change-case';
|
|
7
8
|
import * as universal_cookie from 'universal-cookie';
|
|
8
9
|
import universal_cookie__default from 'universal-cookie';
|
|
9
10
|
import { IncomingMessage } from 'node:http';
|
|
10
11
|
import { Options as Options$1, Drauu, Brush } from 'drauu';
|
|
11
12
|
import { EventHookOn, MaybeComputedElementRef, Fn, MaybeElementRef, ConfigurableDocument, MaybeRefOrGetter as MaybeRefOrGetter$1 } from '@vueuse/core';
|
|
12
13
|
import { Options as Options$2, ActivateOptions, DeactivateOptions } from 'focus-trap';
|
|
13
|
-
import
|
|
14
|
+
import * as fuse_js from 'fuse.js';
|
|
15
|
+
import { IFuseOptions, FuseResult } from 'fuse.js';
|
|
14
16
|
import { JwtPayload, JwtHeader } from 'jwt-decode';
|
|
15
17
|
import nprogress, { NProgressOptions } from 'nprogress';
|
|
16
18
|
import QRCode from 'qrcode';
|
|
@@ -155,24 +157,14 @@ declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: Axios
|
|
|
155
157
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
|
|
156
158
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>, instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
declare
|
|
165
|
-
declare
|
|
166
|
-
declare const changeCase_pathCase: typeof pathCase;
|
|
167
|
-
declare const changeCase_sentenceCase: typeof sentenceCase;
|
|
168
|
-
declare const changeCase_snakeCase: typeof snakeCase;
|
|
169
|
-
declare namespace changeCase {
|
|
170
|
-
export { changeCase_camelCase as camelCase, changeCase_capitalCase as capitalCase, changeCase_constantCase as constantCase, changeCase_dotCase as dotCase, changeCase_headerCase as headerCase, changeCase_noCase as noCase, changeCase_paramCase as paramCase, changeCase_pascalCase as pascalCase, changeCase_pathCase as pathCase, changeCase_sentenceCase as sentenceCase, changeCase_snakeCase as snakeCase };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
type ChangeCaseType = keyof typeof changeCase;
|
|
174
|
-
declare function useChangeCase(input: MaybeRef<string>, type: ChangeCaseType, options?: Options | undefined): WritableComputedRef<string>;
|
|
175
|
-
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: ChangeCaseType, options?: Options | undefined): ComputedRef<string>;
|
|
160
|
+
type EndsWithCase<T> = T extends `${infer _}Case` ? T : never;
|
|
161
|
+
type FilterKeys<T> = {
|
|
162
|
+
[K in keyof T as K extends string ? K : never]: EndsWithCase<K>;
|
|
163
|
+
};
|
|
164
|
+
type ChangeCaseKeys = FilterKeys<typeof changeCase>;
|
|
165
|
+
type ChangeCaseType = ChangeCaseKeys[keyof ChangeCaseKeys];
|
|
166
|
+
declare function useChangeCase(input: MaybeRef<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): WritableComputedRef<string>;
|
|
167
|
+
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): ComputedRef<string>;
|
|
176
168
|
|
|
177
169
|
/**
|
|
178
170
|
* Creates a new {@link useCookies} function
|
|
@@ -299,7 +291,7 @@ interface UseFocusTrapReturn {
|
|
|
299
291
|
*/
|
|
300
292
|
declare function useFocusTrap(target: MaybeElementRef, options?: UseFocusTrapOptions): UseFocusTrapReturn;
|
|
301
293
|
|
|
302
|
-
type FuseOptions<T> =
|
|
294
|
+
type FuseOptions<T> = IFuseOptions<T>;
|
|
303
295
|
interface UseFuseOptions<T> {
|
|
304
296
|
fuseOptions?: FuseOptions<T>;
|
|
305
297
|
resultLimit?: number;
|
|
@@ -307,14 +299,14 @@ interface UseFuseOptions<T> {
|
|
|
307
299
|
}
|
|
308
300
|
declare function useFuse<DataItem>(search: MaybeRefOrGetter<string>, data: MaybeRefOrGetter<DataItem[]>, options?: MaybeRefOrGetter<UseFuseOptions<DataItem>>): {
|
|
309
301
|
fuse: vue_demi.Ref<{
|
|
310
|
-
search: <R = DataItem>(pattern: string |
|
|
311
|
-
setCollection: (docs: readonly DataItem[], index?:
|
|
302
|
+
search: <R = DataItem>(pattern: string | fuse_js.Expression, options?: fuse_js.FuseSearchOptions | undefined) => FuseResult<R>[];
|
|
303
|
+
setCollection: (docs: readonly DataItem[], index?: fuse_js.FuseIndex<DataItem> | undefined) => void;
|
|
312
304
|
add: (doc: DataItem) => void;
|
|
313
305
|
remove: (predicate: (doc: DataItem, idx: number) => boolean) => DataItem[];
|
|
314
306
|
removeAt: (idx: number) => void;
|
|
315
|
-
getIndex: () =>
|
|
307
|
+
getIndex: () => fuse_js.FuseIndex<DataItem>;
|
|
316
308
|
}>;
|
|
317
|
-
results: ComputedRef<
|
|
309
|
+
results: ComputedRef<FuseResult<DataItem>[]>;
|
|
318
310
|
};
|
|
319
311
|
type UseFuseReturn = ReturnType<typeof useFuse>;
|
|
320
312
|
|
package/index.d.mts
CHANGED
|
@@ -3,14 +3,16 @@ import { ValidateError, ValidateOption, Rules } from 'async-validator';
|
|
|
3
3
|
import * as vue_demi from 'vue-demi';
|
|
4
4
|
import { Ref, ShallowRef, WritableComputedRef, ComputedRef } from 'vue-demi';
|
|
5
5
|
import { AxiosResponse, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
6
|
-
import
|
|
6
|
+
import * as changeCase from 'change-case';
|
|
7
|
+
import { Options } from 'change-case';
|
|
7
8
|
import * as universal_cookie from 'universal-cookie';
|
|
8
9
|
import universal_cookie__default from 'universal-cookie';
|
|
9
10
|
import { IncomingMessage } from 'node:http';
|
|
10
11
|
import { Options as Options$1, Drauu, Brush } from 'drauu';
|
|
11
12
|
import { EventHookOn, MaybeComputedElementRef, Fn, MaybeElementRef, ConfigurableDocument, MaybeRefOrGetter as MaybeRefOrGetter$1 } from '@vueuse/core';
|
|
12
13
|
import { Options as Options$2, ActivateOptions, DeactivateOptions } from 'focus-trap';
|
|
13
|
-
import
|
|
14
|
+
import * as fuse_js from 'fuse.js';
|
|
15
|
+
import { IFuseOptions, FuseResult } from 'fuse.js';
|
|
14
16
|
import { JwtPayload, JwtHeader } from 'jwt-decode';
|
|
15
17
|
import nprogress, { NProgressOptions } from 'nprogress';
|
|
16
18
|
import QRCode from 'qrcode';
|
|
@@ -155,24 +157,14 @@ declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: Axios
|
|
|
155
157
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
|
|
156
158
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>, instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
declare
|
|
165
|
-
declare
|
|
166
|
-
declare const changeCase_pathCase: typeof pathCase;
|
|
167
|
-
declare const changeCase_sentenceCase: typeof sentenceCase;
|
|
168
|
-
declare const changeCase_snakeCase: typeof snakeCase;
|
|
169
|
-
declare namespace changeCase {
|
|
170
|
-
export { changeCase_camelCase as camelCase, changeCase_capitalCase as capitalCase, changeCase_constantCase as constantCase, changeCase_dotCase as dotCase, changeCase_headerCase as headerCase, changeCase_noCase as noCase, changeCase_paramCase as paramCase, changeCase_pascalCase as pascalCase, changeCase_pathCase as pathCase, changeCase_sentenceCase as sentenceCase, changeCase_snakeCase as snakeCase };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
type ChangeCaseType = keyof typeof changeCase;
|
|
174
|
-
declare function useChangeCase(input: MaybeRef<string>, type: ChangeCaseType, options?: Options | undefined): WritableComputedRef<string>;
|
|
175
|
-
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: ChangeCaseType, options?: Options | undefined): ComputedRef<string>;
|
|
160
|
+
type EndsWithCase<T> = T extends `${infer _}Case` ? T : never;
|
|
161
|
+
type FilterKeys<T> = {
|
|
162
|
+
[K in keyof T as K extends string ? K : never]: EndsWithCase<K>;
|
|
163
|
+
};
|
|
164
|
+
type ChangeCaseKeys = FilterKeys<typeof changeCase>;
|
|
165
|
+
type ChangeCaseType = ChangeCaseKeys[keyof ChangeCaseKeys];
|
|
166
|
+
declare function useChangeCase(input: MaybeRef<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): WritableComputedRef<string>;
|
|
167
|
+
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): ComputedRef<string>;
|
|
176
168
|
|
|
177
169
|
/**
|
|
178
170
|
* Creates a new {@link useCookies} function
|
|
@@ -299,7 +291,7 @@ interface UseFocusTrapReturn {
|
|
|
299
291
|
*/
|
|
300
292
|
declare function useFocusTrap(target: MaybeElementRef, options?: UseFocusTrapOptions): UseFocusTrapReturn;
|
|
301
293
|
|
|
302
|
-
type FuseOptions<T> =
|
|
294
|
+
type FuseOptions<T> = IFuseOptions<T>;
|
|
303
295
|
interface UseFuseOptions<T> {
|
|
304
296
|
fuseOptions?: FuseOptions<T>;
|
|
305
297
|
resultLimit?: number;
|
|
@@ -307,14 +299,14 @@ interface UseFuseOptions<T> {
|
|
|
307
299
|
}
|
|
308
300
|
declare function useFuse<DataItem>(search: MaybeRefOrGetter<string>, data: MaybeRefOrGetter<DataItem[]>, options?: MaybeRefOrGetter<UseFuseOptions<DataItem>>): {
|
|
309
301
|
fuse: vue_demi.Ref<{
|
|
310
|
-
search: <R = DataItem>(pattern: string |
|
|
311
|
-
setCollection: (docs: readonly DataItem[], index?:
|
|
302
|
+
search: <R = DataItem>(pattern: string | fuse_js.Expression, options?: fuse_js.FuseSearchOptions | undefined) => FuseResult<R>[];
|
|
303
|
+
setCollection: (docs: readonly DataItem[], index?: fuse_js.FuseIndex<DataItem> | undefined) => void;
|
|
312
304
|
add: (doc: DataItem) => void;
|
|
313
305
|
remove: (predicate: (doc: DataItem, idx: number) => boolean) => DataItem[];
|
|
314
306
|
removeAt: (idx: number) => void;
|
|
315
|
-
getIndex: () =>
|
|
307
|
+
getIndex: () => fuse_js.FuseIndex<DataItem>;
|
|
316
308
|
}>;
|
|
317
|
-
results: ComputedRef<
|
|
309
|
+
results: ComputedRef<FuseResult<DataItem>[]>;
|
|
318
310
|
};
|
|
319
311
|
type UseFuseReturn = ReturnType<typeof useFuse>;
|
|
320
312
|
|
package/index.d.ts
CHANGED
|
@@ -3,14 +3,16 @@ import { ValidateError, ValidateOption, Rules } from 'async-validator';
|
|
|
3
3
|
import * as vue_demi from 'vue-demi';
|
|
4
4
|
import { Ref, ShallowRef, WritableComputedRef, ComputedRef } from 'vue-demi';
|
|
5
5
|
import { AxiosResponse, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
6
|
-
import
|
|
6
|
+
import * as changeCase from 'change-case';
|
|
7
|
+
import { Options } from 'change-case';
|
|
7
8
|
import * as universal_cookie from 'universal-cookie';
|
|
8
9
|
import universal_cookie__default from 'universal-cookie';
|
|
9
10
|
import { IncomingMessage } from 'node:http';
|
|
10
11
|
import { Options as Options$1, Drauu, Brush } from 'drauu';
|
|
11
12
|
import { EventHookOn, MaybeComputedElementRef, Fn, MaybeElementRef, ConfigurableDocument, MaybeRefOrGetter as MaybeRefOrGetter$1 } from '@vueuse/core';
|
|
12
13
|
import { Options as Options$2, ActivateOptions, DeactivateOptions } from 'focus-trap';
|
|
13
|
-
import
|
|
14
|
+
import * as fuse_js from 'fuse.js';
|
|
15
|
+
import { IFuseOptions, FuseResult } from 'fuse.js';
|
|
14
16
|
import { JwtPayload, JwtHeader } from 'jwt-decode';
|
|
15
17
|
import nprogress, { NProgressOptions } from 'nprogress';
|
|
16
18
|
import QRCode from 'qrcode';
|
|
@@ -155,24 +157,14 @@ declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: Axios
|
|
|
155
157
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
|
|
156
158
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>, instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
declare
|
|
165
|
-
declare
|
|
166
|
-
declare const changeCase_pathCase: typeof pathCase;
|
|
167
|
-
declare const changeCase_sentenceCase: typeof sentenceCase;
|
|
168
|
-
declare const changeCase_snakeCase: typeof snakeCase;
|
|
169
|
-
declare namespace changeCase {
|
|
170
|
-
export { changeCase_camelCase as camelCase, changeCase_capitalCase as capitalCase, changeCase_constantCase as constantCase, changeCase_dotCase as dotCase, changeCase_headerCase as headerCase, changeCase_noCase as noCase, changeCase_paramCase as paramCase, changeCase_pascalCase as pascalCase, changeCase_pathCase as pathCase, changeCase_sentenceCase as sentenceCase, changeCase_snakeCase as snakeCase };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
type ChangeCaseType = keyof typeof changeCase;
|
|
174
|
-
declare function useChangeCase(input: MaybeRef<string>, type: ChangeCaseType, options?: Options | undefined): WritableComputedRef<string>;
|
|
175
|
-
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: ChangeCaseType, options?: Options | undefined): ComputedRef<string>;
|
|
160
|
+
type EndsWithCase<T> = T extends `${infer _}Case` ? T : never;
|
|
161
|
+
type FilterKeys<T> = {
|
|
162
|
+
[K in keyof T as K extends string ? K : never]: EndsWithCase<K>;
|
|
163
|
+
};
|
|
164
|
+
type ChangeCaseKeys = FilterKeys<typeof changeCase>;
|
|
165
|
+
type ChangeCaseType = ChangeCaseKeys[keyof ChangeCaseKeys];
|
|
166
|
+
declare function useChangeCase(input: MaybeRef<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): WritableComputedRef<string>;
|
|
167
|
+
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): ComputedRef<string>;
|
|
176
168
|
|
|
177
169
|
/**
|
|
178
170
|
* Creates a new {@link useCookies} function
|
|
@@ -299,7 +291,7 @@ interface UseFocusTrapReturn {
|
|
|
299
291
|
*/
|
|
300
292
|
declare function useFocusTrap(target: MaybeElementRef, options?: UseFocusTrapOptions): UseFocusTrapReturn;
|
|
301
293
|
|
|
302
|
-
type FuseOptions<T> =
|
|
294
|
+
type FuseOptions<T> = IFuseOptions<T>;
|
|
303
295
|
interface UseFuseOptions<T> {
|
|
304
296
|
fuseOptions?: FuseOptions<T>;
|
|
305
297
|
resultLimit?: number;
|
|
@@ -307,14 +299,14 @@ interface UseFuseOptions<T> {
|
|
|
307
299
|
}
|
|
308
300
|
declare function useFuse<DataItem>(search: MaybeRefOrGetter<string>, data: MaybeRefOrGetter<DataItem[]>, options?: MaybeRefOrGetter<UseFuseOptions<DataItem>>): {
|
|
309
301
|
fuse: vue_demi.Ref<{
|
|
310
|
-
search: <R = DataItem>(pattern: string |
|
|
311
|
-
setCollection: (docs: readonly DataItem[], index?:
|
|
302
|
+
search: <R = DataItem>(pattern: string | fuse_js.Expression, options?: fuse_js.FuseSearchOptions | undefined) => FuseResult<R>[];
|
|
303
|
+
setCollection: (docs: readonly DataItem[], index?: fuse_js.FuseIndex<DataItem> | undefined) => void;
|
|
312
304
|
add: (doc: DataItem) => void;
|
|
313
305
|
remove: (predicate: (doc: DataItem, idx: number) => boolean) => DataItem[];
|
|
314
306
|
removeAt: (idx: number) => void;
|
|
315
|
-
getIndex: () =>
|
|
307
|
+
getIndex: () => fuse_js.FuseIndex<DataItem>;
|
|
316
308
|
}>;
|
|
317
|
-
results: ComputedRef<
|
|
309
|
+
results: ComputedRef<FuseResult<DataItem>[]>;
|
|
318
310
|
};
|
|
319
311
|
type UseFuseReturn = ReturnType<typeof useFuse>;
|
|
320
312
|
|
package/index.iife.js
CHANGED
|
@@ -118,9 +118,28 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
118
118
|
(globalThis || self).VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined)
|
|
119
119
|
);
|
|
120
120
|
;
|
|
121
|
-
;(function (exports, shared, Schema, vueDemi, axios, changeCase
|
|
121
|
+
;(function (exports, shared, Schema, vueDemi, axios, changeCase, Cookie, drauu, core, focusTrap, Fuse, idbKeyval, jwtDecode, nprogress, QRCode, Sortable) {
|
|
122
122
|
'use strict';
|
|
123
123
|
|
|
124
|
+
function _interopNamespaceDefault(e) {
|
|
125
|
+
var n = Object.create(null);
|
|
126
|
+
if (e) {
|
|
127
|
+
Object.keys(e).forEach(function (k) {
|
|
128
|
+
if (k !== 'default') {
|
|
129
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
130
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function () { return e[k]; }
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
n.default = e;
|
|
138
|
+
return Object.freeze(n);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
var changeCase__namespace = /*#__PURE__*/_interopNamespaceDefault(changeCase);
|
|
142
|
+
|
|
124
143
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
125
144
|
function useAsyncValidator(value, rules, options = {}) {
|
|
126
145
|
const {
|
|
@@ -306,28 +325,23 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
306
325
|
};
|
|
307
326
|
}
|
|
308
327
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
constantCase: changeCase$1.constantCase,
|
|
314
|
-
dotCase: changeCase$1.dotCase,
|
|
315
|
-
headerCase: changeCase$1.headerCase,
|
|
316
|
-
noCase: changeCase$1.noCase,
|
|
317
|
-
paramCase: changeCase$1.paramCase,
|
|
318
|
-
pascalCase: changeCase$1.pascalCase,
|
|
319
|
-
pathCase: changeCase$1.pathCase,
|
|
320
|
-
sentenceCase: changeCase$1.sentenceCase,
|
|
321
|
-
snakeCase: changeCase$1.snakeCase
|
|
322
|
-
});
|
|
323
|
-
|
|
328
|
+
const changeCaseTransforms = /* @__PURE__ */ Object.values(changeCase__namespace).filter((v) => typeof v === "function" && v.name.endsWith("Case")).reduce((acc, fn) => {
|
|
329
|
+
acc[fn.name] = fn;
|
|
330
|
+
return acc;
|
|
331
|
+
}, {});
|
|
324
332
|
function useChangeCase(input, type, options) {
|
|
333
|
+
const typeRef = vueDemi.computed(() => {
|
|
334
|
+
const t = shared.toValue(type);
|
|
335
|
+
if (!changeCaseTransforms[t])
|
|
336
|
+
throw new Error(`Invalid change case type "${t}"`);
|
|
337
|
+
return t;
|
|
338
|
+
});
|
|
325
339
|
if (typeof input === "function")
|
|
326
|
-
return vueDemi.computed(() =>
|
|
340
|
+
return vueDemi.computed(() => changeCaseTransforms[typeRef.value](shared.toValue(input), shared.toValue(options)));
|
|
327
341
|
const text = vueDemi.ref(input);
|
|
328
342
|
return vueDemi.computed({
|
|
329
343
|
get() {
|
|
330
|
-
return
|
|
344
|
+
return changeCaseTransforms[typeRef.value](text.value, shared.toValue(options));
|
|
331
345
|
},
|
|
332
346
|
set(value) {
|
|
333
347
|
text.value = value;
|
|
@@ -654,7 +668,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
654
668
|
} = options;
|
|
655
669
|
const decodeWithFallback = (encodedJwt2, options2) => {
|
|
656
670
|
try {
|
|
657
|
-
return
|
|
671
|
+
return jwtDecode.jwtDecode(encodedJwt2, options2);
|
|
658
672
|
} catch (err) {
|
|
659
673
|
onError == null ? void 0 : onError(err);
|
|
660
674
|
return fallbackValue;
|
package/index.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(l,o,T){if(l.install)return l;if(!o)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),l;if(o.version.slice(0,4)==="2.7."){let p=function(A,P){var h,G={},N={config:o.config,use:o.use.bind(o),mixin:o.mixin.bind(o),component:o.component.bind(o),provide:function(g,L){return G[g]=L,this},directive:function(g,L){return L?(o.directive(g,L),N):o.directive(g)},mount:function(g,L){return h||(h=new o(Object.assign({propsData:P},A,{provide:Object.assign(G,A.provide)})),h.$mount(g,L),h)},unmount:function(){h&&(h.$destroy(),h=void 0)}};return N};var B=p;for(var n in o)l[n]=o[n];l.isVue2=!0,l.isVue3=!1,l.install=function(){},l.Vue=o,l.Vue2=o,l.version=o.version,l.warn=o.util.warn,l.hasInjectionContext=function(){return!!l.getCurrentInstance()},l.createApp=p}else if(o.version.slice(0,2)==="2.")if(T){for(var n in T)l[n]=T[n];l.isVue2=!0,l.isVue3=!1,l.install=function(){},l.Vue=o,l.Vue2=o,l.version=o.version,l.hasInjectionContext=function(){return!!l.getCurrentInstance()}}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(o.version.slice(0,2)==="3."){for(var n in o)l[n]=o[n];l.isVue2=!1,l.isVue3=!0,l.install=function(){},l.Vue=o,l.Vue2=void 0,l.version=o.version,l.set=function(p,A,P){return Array.isArray(p)?(p.length=Math.max(p.length,A),p.splice(A,1,P),P):(p[A]=P,P)},l.del=function(p,A){if(Array.isArray(p)){p.splice(A,1);return}delete p[A]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");return l}((globalThis||self).VueDemi=(globalThis||self).VueDemi||(typeof VueDemi<"u"?VueDemi:{}),(globalThis||self).Vue||(typeof Vue<"u"?Vue:void 0),(globalThis||self).VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(l,o,T,n,B,p,A,P,h,G,N,g,L,E,V,$){"use strict";const D=T.default||T;function ee(t,r,e={}){const{validateOption:a={},immediate:s=!0,manual:f=!1}=e,c=o.toRef(t),i=n.shallowRef(null),u=n.ref(!0),C=n.ref(!s||f),w=n.computed(()=>{var d;return((d=i.value)==null?void 0:d.errors)||[]}),y=n.computed(()=>{var d;return((d=i.value)==null?void 0:d.fields)||{}}),I=n.computed(()=>new D(o.toValue(r))),_=async()=>{u.value=!1,C.value=!1;try{await I.value.validate(c.value,a),C.value=!0,i.value=null}catch(d){i.value=d}finally{u.value=!0}return{pass:C.value,errorInfo:i.value,errors:w.value,errorFields:y.value}};f||n.watch([c,I],()=>_(),{immediate:s,deep:!0});const S={isFinished:u,pass:C,errors:w,errorInfo:i,errorFields:y,execute:_};function F(){return new Promise((d,R)=>{o.until(u).toBe(!0).then(()=>d(S)).catch(O=>R(O))})}return{...S,then(d,R){return F().then(d,R)}}}function te(...t){const r=typeof t[0]=="string"?t[0]:void 0,e=typeof r=="string"?1:0,a={immediate:!!e,shallow:!0,abortPrevious:!0};let s={},f=B,c=a;const i=b=>!!b?.request;t.length>0+e&&(i(t[0+e])?f=t[0+e]:s=t[0+e]),t.length>1+e&&i(t[1+e])&&(f=t[1+e]),(t.length===2+e&&!i(t[1+e])||t.length===3+e)&&(c=t[t.length-1]||a);const{initialData:u,shallow:C,onSuccess:w=o.noop,onError:y=o.noop,immediate:I,resetOnExecute:_=!1}=c,S=n.shallowRef(),F=(C?n.shallowRef:n.ref)(u),d=n.ref(!1),R=n.ref(!1),O=n.ref(!1),k=n.shallowRef();let U=new AbortController;const j=b=>{d.value||!R.value||(U.abort(b),U=new AbortController,O.value=!0,R.value=!1,d.value=!1)},v=b=>{R.value=b,d.value=!b},m=()=>{_&&(F.value=u)},J=()=>new Promise((b,W)=>{o.until(d).toBe(!0).then(()=>k.value?W(k.value):b(X))}),x={then:(...b)=>J().then(...b),catch:(...b)=>J().catch(...b)};let Q=0;const K=(b=r,W={})=>{k.value=void 0;const Y=typeof b=="string"?b:r??W.url;if(Y===void 0)return k.value=new B.AxiosError(B.AxiosError.ERR_INVALID_URL),d.value=!0,x;m(),c.abortPrevious!==!1&&j(),v(!0),Q+=1;const ve=Q;return O.value=!1,f(Y,{...s,...typeof b=="object"?b:W,signal:U.signal}).then(H=>{if(O.value)return;S.value=H;const Z=H.data;F.value=Z,w(Z)}).catch(H=>{k.value=H,y(H)}).finally(()=>{var H;(H=c.onFinish)==null||H.call(c),ve===Q&&v(!1)}),x};I&&r&&K();const X={response:S,data:F,error:k,isFinished:d,isLoading:R,cancel:j,isAborted:O,isCanceled:O,abort:j,execute:K};return{...X,...x}}var z=Object.freeze({__proto__:null,camelCase:p.camelCase,capitalCase:p.capitalCase,constantCase:p.constantCase,dotCase:p.dotCase,headerCase:p.headerCase,noCase:p.noCase,paramCase:p.paramCase,pascalCase:p.pascalCase,pathCase:p.pathCase,sentenceCase:p.sentenceCase,snakeCase:p.snakeCase});function ne(t,r,e){if(typeof t=="function")return n.computed(()=>z[r](o.toValue(t),e));const a=n.ref(t);return n.computed({get(){return z[r](a.value,e)},set(s){a.value=s}})}function oe(t){const r=new A(t?t.headers.cookie:null);return(e,{doNotParse:a=!1,autoUpdateDependencies:s=!1}={})=>M(e,{doNotParse:a,autoUpdateDependencies:s},r)}function M(t,{doNotParse:r=!1,autoUpdateDependencies:e=!1}={},a=new A){const s=e?[...t||[]]:t;let f=a.getAll({doNotParse:!0});const c=n.ref(0),i=()=>{const u=a.getAll({doNotParse:!0});ae(s||null,u,f)&&c.value++,f=u};return a.addChangeListener(i),o.tryOnScopeDispose(()=>{a.removeChangeListener(i)}),{get:(...u)=>(e&&s&&!s.includes(u[0])&&s.push(u[0]),c.value,a.get(u[0],{doNotParse:r,...u[1]})),getAll:(...u)=>(c.value,a.getAll({doNotParse:r,...u[0]})),set:(...u)=>a.set(...u),remove:(...u)=>a.remove(...u),addChangeListener:(...u)=>a.addChangeListener(...u),removeChangeListener:(...u)=>a.removeChangeListener(...u)}}function ae(t,r,e){if(!t)return!0;for(const a of t)if(r[a]!==e[a])return!0;return!1}function le(t,r){const e=n.ref();let a=[];const s=h.createEventHook(),f=h.createEventHook(),c=h.createEventHook(),i=h.createEventHook(),u=h.createEventHook(),C=n.ref(!1),w=n.ref(!1),y=n.ref(!1),I=n.ref(!1),_=n.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw",...r?.brush});n.watch(_,()=>{const v=e.value;v&&(v.brush=_.value,v.mode=_.value.mode)},{deep:!0});const S=()=>{var v;return(v=e.value)==null?void 0:v.undo()},F=()=>{var v;return(v=e.value)==null?void 0:v.redo()},d=()=>{var v;return(v=e.value)==null?void 0:v.clear()},R=()=>{var v;return(v=e.value)==null?void 0:v.cancel()},O=v=>{var m;return(m=e.value)==null?void 0:m.load(v)},k=()=>{var v;return(v=e.value)==null?void 0:v.dump()},U=()=>{var v;a.forEach(m=>m()),(v=e.value)==null||v.unmount()},j=()=>{e.value&&(C.value=e.value.canUndo(),w.value=e.value.canRedo(),y.value=e.value.altPressed,I.value=e.value.shiftPressed)};return n.watch(()=>h.unrefElement(t),v=>{!v||typeof SVGSVGElement>"u"||!(v instanceof SVGSVGElement)||(e.value&&U(),e.value=P.createDrauu({el:v,...r}),j(),a=[e.value.on("canceled",()=>f.trigger()),e.value.on("committed",m=>c.trigger(m)),e.value.on("start",()=>i.trigger()),e.value.on("end",()=>u.trigger()),e.value.on("changed",()=>{j(),s.trigger()})])},{flush:"post"}),o.tryOnScopeDispose(()=>U()),{drauuInstance:e,load:O,dump:k,clear:d,cancel:R,undo:S,redo:F,canUndo:C,canRedo:w,brush:_,onChanged:s.on,onCommitted:c.on,onStart:i.on,onEnd:u.on,onCanceled:f.on}}function re(t,r={}){let e;const{immediate:a,...s}=r,f=n.ref(!1),c=n.ref(!1),i=y=>e&&e.activate(y),u=y=>e&&e.deactivate(y),C=()=>{e&&(e.pause(),c.value=!0)},w=()=>{e&&(e.unpause(),c.value=!1)};return n.watch(()=>h.unrefElement(t),y=>{y&&(e=G.createFocusTrap(y,{...s,onActivate(){f.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){f.value=!1,r.onDeactivate&&r.onDeactivate()}}),a&&i())},{flush:"post"}),h.tryOnScopeDispose(()=>u()),{hasFocus:f,isPaused:c,activate:i,deactivate:u,pause:C,unpause:w}}function se(t,r,e){const a=()=>{var c,i;return new N((c=o.toValue(r))!=null?c:[],(i=o.toValue(e))==null?void 0:i.fuseOptions)},s=n.ref(a());n.watch(()=>{var c;return(c=o.toValue(e))==null?void 0:c.fuseOptions},()=>{s.value=a()},{deep:!0}),n.watch(()=>o.toValue(r),c=>{s.value.setCollection(c)},{deep:!0});const f=n.computed(()=>{const c=o.toValue(e);if(c?.matchAllWhenSearchEmpty&&!o.toValue(t))return o.toValue(r).map((u,C)=>({item:u,refIndex:C}));const i=c?.resultLimit;return s.value.search(o.toValue(t),i?{limit:i}:void 0)});return{fuse:s,results:f}}function ue(t,r,e={}){const{flush:a="pre",deep:s=!0,shallow:f=!1,onError:c=d=>{console.error(d)},writeDefaults:i=!0}=e,u=n.ref(!1),C=(f?n.shallowRef:n.ref)(r),w=o.toValue(r);async function y(){try{const d=await g.get(t);d===void 0?w!=null&&i&&await g.set(t,w):C.value=d}catch(d){c(d)}u.value=!0}y();async function I(){try{C.value==null?await g.del(t):await g.update(t,()=>n.toRaw(C.value))}catch(d){c(d)}}const{pause:_,resume:S}=h.watchPausable(C,()=>I(),{flush:a,deep:s});async function F(d){_(),C.value=d,await I(),S()}return{set:F,isFinished:u,data:C}}function ce(t,r={}){const{onError:e,fallbackValue:a=null}=r,s=(i,u)=>{try{return L(i,u)}catch(C){return e?.(C),a}},f=n.computed(()=>s(o.toValue(t),{header:!0})),c=n.computed(()=>s(o.toValue(t)));return{header:f,payload:c}}function ie(t=null,r){const e=n.ref(t),a=n.computed({set:f=>f?E.start():E.done(),get:()=>typeof e.value=="number"&&e.value<1});r&&E.configure(r);const s=E.set;return E.set=f=>(e.value=f,s.call(E,f)),n.watchEffect(()=>{typeof e.value=="number"&&o.isClient&&s.call(E,e.value)}),o.tryOnScopeDispose(E.remove),{isLoading:a,progress:e,start:E.start,done:E.done,remove:()=>{e.value=null,E.remove()}}}function fe(t,r){const e=o.toRef(t),a=n.ref("");return n.watch(e,async s=>{e.value&&o.isClient&&(a.value=await V.toDataURL(s,r))},{immediate:!0}),a}function de(t,r,e={}){let a;const{document:s=h.defaultDocument,...f}=e,c={onUpdate:w=>{q(r,w.oldIndex,w.newIndex)}},i=()=>{const w=typeof t=="string"?s?.querySelector(t):h.unrefElement(t);!w||a!==void 0||(a=new $(w,{...c,...f}))},u=()=>{a?.destroy(),a=void 0},C=(w,y)=>{if(y!==void 0)a?.option(w,y);else return a?.option(w)};return h.tryOnMounted(i),h.tryOnScopeDispose(u),{stop:u,start:i,option:C}}function q(t,r,e){const a=n.isRef(t),s=a?[...h.toValue(t)]:h.toValue(t);if(e>=0&&e<s.length){const f=s.splice(r,1)[0];n.nextTick(()=>{s.splice(e,0,f),a&&(t.value=s)})}}l.createCookies=oe,l.moveArrayElement=q,l.useAsyncValidator=ee,l.useAxios=te,l.useChangeCase=ne,l.useCookies=M,l.useDrauu=le,l.useFocusTrap=re,l.useFuse=se,l.useIDBKeyval=ue,l.useJwt=ce,l.useNProgress=ie,l.useQRCode=fe,l.useSortable=de})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,VueDemi,axios,changeCase,UniversalCookie,Drauu,VueUse,focusTrap,Fuse,idbKeyval,jwt_decode,nprogress,QRCode,Sortable);
|
|
1
|
+
var VueDemi=function(l,n,H){if(l.install)return l;if(!n)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),l;if(n.version.slice(0,4)==="2.7."){let b=function(g,F){var p,W={},B={config:n.config,use:n.use.bind(n),mixin:n.mixin.bind(n),component:n.component.bind(n),provide:function(A,j){return W[A]=j,this},directive:function(A,j){return j?(n.directive(A,j),B):n.directive(A)},mount:function(A,j){return p||(p=new n(Object.assign({propsData:F},g,{provide:Object.assign(W,g.provide)})),p.$mount(A,j),p)},unmount:function(){p&&(p.$destroy(),p=void 0)}};return B};var N=b;for(var o in n)l[o]=n[o];l.isVue2=!0,l.isVue3=!1,l.install=function(){},l.Vue=n,l.Vue2=n,l.version=n.version,l.warn=n.util.warn,l.hasInjectionContext=function(){return!!l.getCurrentInstance()},l.createApp=b}else if(n.version.slice(0,2)==="2.")if(H){for(var o in H)l[o]=H[o];l.isVue2=!0,l.isVue3=!1,l.install=function(){},l.Vue=n,l.Vue2=n,l.version=n.version,l.hasInjectionContext=function(){return!!l.getCurrentInstance()}}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(n.version.slice(0,2)==="3."){for(var o in n)l[o]=n[o];l.isVue2=!1,l.isVue3=!0,l.install=function(){},l.Vue=n,l.Vue2=void 0,l.version=n.version,l.set=function(b,g,F){return Array.isArray(b)?(b.length=Math.max(b.length,g),b.splice(g,1,F),F):(b[g]=F,F)},l.del=function(b,g){if(Array.isArray(b)){b.splice(g,1);return}delete b[g]}}else console.error("[vue-demi] Vue version "+n.version+" is unsupported.");return l}((globalThis||self).VueDemi=(globalThis||self).VueDemi||(typeof VueDemi<"u"?VueDemi:{}),(globalThis||self).Vue||(typeof Vue<"u"?Vue:void 0),(globalThis||self).VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(l,n,H,o,N,b,g,F,p,W,B,A,j,E,Z,V){"use strict";function D(t){var r=Object.create(null);return t&&Object.keys(t).forEach(function(e){if(e!=="default"){var a=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,a.get?a:{enumerable:!0,get:function(){return t[e]}})}}),r.default=t,Object.freeze(r)}var ee=D(b);const te=H.default||H;function ne(t,r,e={}){const{validateOption:a={},immediate:s=!0,manual:i=!1}=e,c=n.toRef(t),f=o.shallowRef(null),u=o.ref(!0),h=o.ref(!s||i),w=o.computed(()=>{var d;return((d=f.value)==null?void 0:d.errors)||[]}),y=o.computed(()=>{var d;return((d=f.value)==null?void 0:d.fields)||{}}),_=o.computed(()=>new te(n.toValue(r))),O=async()=>{u.value=!1,h.value=!1;try{await _.value.validate(c.value,a),h.value=!0,f.value=null}catch(d){f.value=d}finally{u.value=!0}return{pass:h.value,errorInfo:f.value,errors:w.value,errorFields:y.value}};i||o.watch([c,_],()=>O(),{immediate:s,deep:!0});const I={isFinished:u,pass:h,errors:w,errorInfo:f,errorFields:y,execute:O};function P(){return new Promise((d,R)=>{n.until(u).toBe(!0).then(()=>d(I)).catch(S=>R(S))})}return{...I,then(d,R){return P().then(d,R)}}}function oe(...t){const r=typeof t[0]=="string"?t[0]:void 0,e=typeof r=="string"?1:0,a={immediate:!!e,shallow:!0,abortPrevious:!0};let s={},i=N,c=a;const f=C=>!!C?.request;t.length>0+e&&(f(t[0+e])?i=t[0+e]:s=t[0+e]),t.length>1+e&&f(t[1+e])&&(i=t[1+e]),(t.length===2+e&&!f(t[1+e])||t.length===3+e)&&(c=t[t.length-1]||a);const{initialData:u,shallow:h,onSuccess:w=n.noop,onError:y=n.noop,immediate:_,resetOnExecute:O=!1}=c,I=o.shallowRef(),P=(h?o.shallowRef:o.ref)(u),d=o.ref(!1),R=o.ref(!1),S=o.ref(!1),m=o.shallowRef();let U=new AbortController;const k=C=>{d.value||!R.value||(U.abort(C),U=new AbortController,S.value=!0,R.value=!1,d.value=!1)},v=C=>{R.value=C,d.value=!C},L=()=>{O&&(P.value=u)},q=()=>new Promise((C,G)=>{n.until(d).toBe(!0).then(()=>m.value?G(m.value):C(K))}),Q={then:(...C)=>q().then(...C),catch:(...C)=>q().catch(...C)};let $=0;const J=(C=r,G={})=>{m.value=void 0;const X=typeof C=="string"?C:r??G.url;if(X===void 0)return m.value=new N.AxiosError(N.AxiosError.ERR_INVALID_URL),d.value=!0,Q;L(),c.abortPrevious!==!1&&k(),v(!0),$+=1;const he=$;return S.value=!1,i(X,{...s,...typeof C=="object"?C:G,signal:U.signal}).then(T=>{if(S.value)return;I.value=T;const Y=T.data;P.value=Y,w(Y)}).catch(T=>{m.value=T,y(T)}).finally(()=>{var T;(T=c.onFinish)==null||T.call(c),he===$&&v(!1)}),Q};_&&r&&J();const K={response:I,data:P,error:m,isFinished:d,isLoading:R,cancel:k,isAborted:S,isCanceled:S,abort:k,execute:J};return{...K,...Q}}const x=Object.values(ee).filter(t=>typeof t=="function"&&t.name.endsWith("Case")).reduce((t,r)=>(t[r.name]=r,t),{});function ae(t,r,e){const a=o.computed(()=>{const i=n.toValue(r);if(!x[i])throw new Error(`Invalid change case type "${i}"`);return i});if(typeof t=="function")return o.computed(()=>x[a.value](n.toValue(t),n.toValue(e)));const s=o.ref(t);return o.computed({get(){return x[a.value](s.value,n.toValue(e))},set(i){s.value=i}})}function re(t){const r=new g(t?t.headers.cookie:null);return(e,{doNotParse:a=!1,autoUpdateDependencies:s=!1}={})=>z(e,{doNotParse:a,autoUpdateDependencies:s},r)}function z(t,{doNotParse:r=!1,autoUpdateDependencies:e=!1}={},a=new g){const s=e?[...t||[]]:t;let i=a.getAll({doNotParse:!0});const c=o.ref(0),f=()=>{const u=a.getAll({doNotParse:!0});le(s||null,u,i)&&c.value++,i=u};return a.addChangeListener(f),n.tryOnScopeDispose(()=>{a.removeChangeListener(f)}),{get:(...u)=>(e&&s&&!s.includes(u[0])&&s.push(u[0]),c.value,a.get(u[0],{doNotParse:r,...u[1]})),getAll:(...u)=>(c.value,a.getAll({doNotParse:r,...u[0]})),set:(...u)=>a.set(...u),remove:(...u)=>a.remove(...u),addChangeListener:(...u)=>a.addChangeListener(...u),removeChangeListener:(...u)=>a.removeChangeListener(...u)}}function le(t,r,e){if(!t)return!0;for(const a of t)if(r[a]!==e[a])return!0;return!1}function se(t,r){const e=o.ref();let a=[];const s=p.createEventHook(),i=p.createEventHook(),c=p.createEventHook(),f=p.createEventHook(),u=p.createEventHook(),h=o.ref(!1),w=o.ref(!1),y=o.ref(!1),_=o.ref(!1),O=o.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw",...r?.brush});o.watch(O,()=>{const v=e.value;v&&(v.brush=O.value,v.mode=O.value.mode)},{deep:!0});const I=()=>{var v;return(v=e.value)==null?void 0:v.undo()},P=()=>{var v;return(v=e.value)==null?void 0:v.redo()},d=()=>{var v;return(v=e.value)==null?void 0:v.clear()},R=()=>{var v;return(v=e.value)==null?void 0:v.cancel()},S=v=>{var L;return(L=e.value)==null?void 0:L.load(v)},m=()=>{var v;return(v=e.value)==null?void 0:v.dump()},U=()=>{var v;a.forEach(L=>L()),(v=e.value)==null||v.unmount()},k=()=>{e.value&&(h.value=e.value.canUndo(),w.value=e.value.canRedo(),y.value=e.value.altPressed,_.value=e.value.shiftPressed)};return o.watch(()=>p.unrefElement(t),v=>{!v||typeof SVGSVGElement>"u"||!(v instanceof SVGSVGElement)||(e.value&&U(),e.value=F.createDrauu({el:v,...r}),k(),a=[e.value.on("canceled",()=>i.trigger()),e.value.on("committed",L=>c.trigger(L)),e.value.on("start",()=>f.trigger()),e.value.on("end",()=>u.trigger()),e.value.on("changed",()=>{k(),s.trigger()})])},{flush:"post"}),n.tryOnScopeDispose(()=>U()),{drauuInstance:e,load:S,dump:m,clear:d,cancel:R,undo:I,redo:P,canUndo:h,canRedo:w,brush:O,onChanged:s.on,onCommitted:c.on,onStart:f.on,onEnd:u.on,onCanceled:i.on}}function ue(t,r={}){let e;const{immediate:a,...s}=r,i=o.ref(!1),c=o.ref(!1),f=y=>e&&e.activate(y),u=y=>e&&e.deactivate(y),h=()=>{e&&(e.pause(),c.value=!0)},w=()=>{e&&(e.unpause(),c.value=!1)};return o.watch(()=>p.unrefElement(t),y=>{y&&(e=W.createFocusTrap(y,{...s,onActivate(){i.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){i.value=!1,r.onDeactivate&&r.onDeactivate()}}),a&&f())},{flush:"post"}),p.tryOnScopeDispose(()=>u()),{hasFocus:i,isPaused:c,activate:f,deactivate:u,pause:h,unpause:w}}function ce(t,r,e){const a=()=>{var c,f;return new B((c=n.toValue(r))!=null?c:[],(f=n.toValue(e))==null?void 0:f.fuseOptions)},s=o.ref(a());o.watch(()=>{var c;return(c=n.toValue(e))==null?void 0:c.fuseOptions},()=>{s.value=a()},{deep:!0}),o.watch(()=>n.toValue(r),c=>{s.value.setCollection(c)},{deep:!0});const i=o.computed(()=>{const c=n.toValue(e);if(c?.matchAllWhenSearchEmpty&&!n.toValue(t))return n.toValue(r).map((u,h)=>({item:u,refIndex:h}));const f=c?.resultLimit;return s.value.search(n.toValue(t),f?{limit:f}:void 0)});return{fuse:s,results:i}}function ie(t,r,e={}){const{flush:a="pre",deep:s=!0,shallow:i=!1,onError:c=d=>{console.error(d)},writeDefaults:f=!0}=e,u=o.ref(!1),h=(i?o.shallowRef:o.ref)(r),w=n.toValue(r);async function y(){try{const d=await A.get(t);d===void 0?w!=null&&f&&await A.set(t,w):h.value=d}catch(d){c(d)}u.value=!0}y();async function _(){try{h.value==null?await A.del(t):await A.update(t,()=>o.toRaw(h.value))}catch(d){c(d)}}const{pause:O,resume:I}=p.watchPausable(h,()=>_(),{flush:a,deep:s});async function P(d){O(),h.value=d,await _(),I()}return{set:P,isFinished:u,data:h}}function fe(t,r={}){const{onError:e,fallbackValue:a=null}=r,s=(f,u)=>{try{return j.jwtDecode(f,u)}catch(h){return e?.(h),a}},i=o.computed(()=>s(n.toValue(t),{header:!0})),c=o.computed(()=>s(n.toValue(t)));return{header:i,payload:c}}function de(t=null,r){const e=o.ref(t),a=o.computed({set:i=>i?E.start():E.done(),get:()=>typeof e.value=="number"&&e.value<1});r&&E.configure(r);const s=E.set;return E.set=i=>(e.value=i,s.call(E,i)),o.watchEffect(()=>{typeof e.value=="number"&&n.isClient&&s.call(E,e.value)}),n.tryOnScopeDispose(E.remove),{isLoading:a,progress:e,start:E.start,done:E.done,remove:()=>{e.value=null,E.remove()}}}function ve(t,r){const e=n.toRef(t),a=o.ref("");return o.watch(e,async s=>{e.value&&n.isClient&&(a.value=await Z.toDataURL(s,r))},{immediate:!0}),a}function pe(t,r,e={}){let a;const{document:s=p.defaultDocument,...i}=e,c={onUpdate:w=>{M(r,w.oldIndex,w.newIndex)}},f=()=>{const w=typeof t=="string"?s?.querySelector(t):p.unrefElement(t);!w||a!==void 0||(a=new V(w,{...c,...i}))},u=()=>{a?.destroy(),a=void 0},h=(w,y)=>{if(y!==void 0)a?.option(w,y);else return a?.option(w)};return p.tryOnMounted(f),p.tryOnScopeDispose(u),{stop:u,start:f,option:h}}function M(t,r,e){const a=o.isRef(t),s=a?[...p.toValue(t)]:p.toValue(t);if(e>=0&&e<s.length){const i=s.splice(r,1)[0];o.nextTick(()=>{s.splice(e,0,i),a&&(t.value=s)})}}l.createCookies=re,l.moveArrayElement=M,l.useAsyncValidator=ne,l.useAxios=oe,l.useChangeCase=ae,l.useCookies=z,l.useDrauu=se,l.useFocusTrap=ue,l.useFuse=ce,l.useIDBKeyval=ie,l.useJwt=fe,l.useNProgress=de,l.useQRCode=ve,l.useSortable=pe})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,VueDemi,axios,changeCase,UniversalCookie,Drauu,VueUse,focusTrap,Fuse,idbKeyval,jwt_decode,nprogress,QRCode,Sortable);
|
package/index.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import { toRef, toValue, until, noop, tryOnScopeDispose, isClient } from '@vueus
|
|
|
2
2
|
import Schema from 'async-validator';
|
|
3
3
|
import { shallowRef, ref, computed, watch, toRaw, watchEffect, isRef, nextTick } from 'vue-demi';
|
|
4
4
|
import axios, { AxiosError } from 'axios';
|
|
5
|
-
import
|
|
5
|
+
import * as changeCase from 'change-case';
|
|
6
6
|
import Cookie from 'universal-cookie';
|
|
7
7
|
import { createDrauu } from 'drauu';
|
|
8
8
|
import { createEventHook, unrefElement, tryOnScopeDispose as tryOnScopeDispose$1, watchPausable, tryOnMounted, toValue as toValue$1, defaultDocument } from '@vueuse/core';
|
|
9
9
|
import { createFocusTrap } from 'focus-trap';
|
|
10
10
|
import Fuse from 'fuse.js';
|
|
11
11
|
import { get, set, del, update } from 'idb-keyval';
|
|
12
|
-
import
|
|
12
|
+
import { jwtDecode } from 'jwt-decode';
|
|
13
13
|
import nprogress from 'nprogress';
|
|
14
14
|
import QRCode from 'qrcode';
|
|
15
15
|
import Sortable from 'sortablejs';
|
|
@@ -199,28 +199,23 @@ function useAxios(...args) {
|
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
constantCase: constantCase,
|
|
207
|
-
dotCase: dotCase,
|
|
208
|
-
headerCase: headerCase,
|
|
209
|
-
noCase: noCase,
|
|
210
|
-
paramCase: paramCase,
|
|
211
|
-
pascalCase: pascalCase,
|
|
212
|
-
pathCase: pathCase,
|
|
213
|
-
sentenceCase: sentenceCase,
|
|
214
|
-
snakeCase: snakeCase
|
|
215
|
-
});
|
|
216
|
-
|
|
202
|
+
const changeCaseTransforms = /* @__PURE__ */ Object.values(changeCase).filter((v) => typeof v === "function" && v.name.endsWith("Case")).reduce((acc, fn) => {
|
|
203
|
+
acc[fn.name] = fn;
|
|
204
|
+
return acc;
|
|
205
|
+
}, {});
|
|
217
206
|
function useChangeCase(input, type, options) {
|
|
207
|
+
const typeRef = computed(() => {
|
|
208
|
+
const t = toValue(type);
|
|
209
|
+
if (!changeCaseTransforms[t])
|
|
210
|
+
throw new Error(`Invalid change case type "${t}"`);
|
|
211
|
+
return t;
|
|
212
|
+
});
|
|
218
213
|
if (typeof input === "function")
|
|
219
|
-
return computed(() =>
|
|
214
|
+
return computed(() => changeCaseTransforms[typeRef.value](toValue(input), toValue(options)));
|
|
220
215
|
const text = ref(input);
|
|
221
216
|
return computed({
|
|
222
217
|
get() {
|
|
223
|
-
return
|
|
218
|
+
return changeCaseTransforms[typeRef.value](text.value, toValue(options));
|
|
224
219
|
},
|
|
225
220
|
set(value) {
|
|
226
221
|
text.value = value;
|
|
@@ -547,7 +542,7 @@ function useJwt(encodedJwt, options = {}) {
|
|
|
547
542
|
} = options;
|
|
548
543
|
const decodeWithFallback = (encodedJwt2, options2) => {
|
|
549
544
|
try {
|
|
550
|
-
return
|
|
545
|
+
return jwtDecode(encodedJwt2, options2);
|
|
551
546
|
} catch (err) {
|
|
552
547
|
onError == null ? void 0 : onError(err);
|
|
553
548
|
return fallbackValue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/integrations",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0-beta.1",
|
|
4
4
|
"description": "Integration wrappers for utility libraries",
|
|
5
5
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -95,16 +95,16 @@
|
|
|
95
95
|
"peerDependencies": {
|
|
96
96
|
"async-validator": "^4",
|
|
97
97
|
"axios": "^1",
|
|
98
|
-
"change-case": "^
|
|
99
|
-
"drauu": "^0.
|
|
98
|
+
"change-case": "^5",
|
|
99
|
+
"drauu": "^0.4",
|
|
100
100
|
"focus-trap": "^7",
|
|
101
|
-
"fuse.js": "^
|
|
101
|
+
"fuse.js": "^7",
|
|
102
102
|
"idb-keyval": "^6",
|
|
103
|
-
"jwt-decode": "^
|
|
103
|
+
"jwt-decode": "^4",
|
|
104
104
|
"nprogress": "^0.2",
|
|
105
105
|
"qrcode": "^1.5",
|
|
106
106
|
"sortablejs": "^1",
|
|
107
|
-
"universal-cookie": "^
|
|
107
|
+
"universal-cookie": "^7"
|
|
108
108
|
},
|
|
109
109
|
"peerDependenciesMeta": {
|
|
110
110
|
"async-validator": {
|
|
@@ -145,8 +145,8 @@
|
|
|
145
145
|
}
|
|
146
146
|
},
|
|
147
147
|
"dependencies": {
|
|
148
|
-
"@vueuse/core": "
|
|
149
|
-
"@vueuse/shared": "
|
|
148
|
+
"@vueuse/core": "11.0.0-beta.1",
|
|
149
|
+
"@vueuse/shared": "11.0.0-beta.1",
|
|
150
150
|
"vue-demi": ">=0.14.8"
|
|
151
151
|
},
|
|
152
152
|
"devDependencies": {
|
|
@@ -155,15 +155,15 @@
|
|
|
155
155
|
"@types/sortablejs": "^1.15.8",
|
|
156
156
|
"async-validator": "^4.2.5",
|
|
157
157
|
"axios": "^1.7.2",
|
|
158
|
-
"change-case": "^4.
|
|
159
|
-
"drauu": "^0.
|
|
158
|
+
"change-case": "^5.4.4",
|
|
159
|
+
"drauu": "^0.4.0",
|
|
160
160
|
"focus-trap": "^7.5.4",
|
|
161
|
-
"fuse.js": "^
|
|
161
|
+
"fuse.js": "^7.0.0",
|
|
162
162
|
"idb-keyval": "^6.2.1",
|
|
163
|
-
"jwt-decode": "^
|
|
163
|
+
"jwt-decode": "^4.0.0",
|
|
164
164
|
"nprogress": "^0.2.0",
|
|
165
165
|
"qrcode": "^1.5.3",
|
|
166
166
|
"sortablejs": "^1.15.2",
|
|
167
|
-
"universal-cookie": "^
|
|
167
|
+
"universal-cookie": "^7.1.4"
|
|
168
168
|
}
|
|
169
169
|
}
|
package/useChangeCase.cjs
CHANGED
|
@@ -2,30 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
var shared = require('@vueuse/shared');
|
|
4
4
|
var vueDemi = require('vue-demi');
|
|
5
|
-
var changeCase
|
|
5
|
+
var changeCase = require('change-case');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var changeCase__namespace = /*#__PURE__*/_interopNamespaceDefault(changeCase);
|
|
21
25
|
|
|
26
|
+
const changeCaseTransforms = /* @__PURE__ */ Object.values(changeCase__namespace).filter((v) => typeof v === "function" && v.name.endsWith("Case")).reduce((acc, fn) => {
|
|
27
|
+
acc[fn.name] = fn;
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
22
30
|
function useChangeCase(input, type, options) {
|
|
31
|
+
const typeRef = vueDemi.computed(() => {
|
|
32
|
+
const t = shared.toValue(type);
|
|
33
|
+
if (!changeCaseTransforms[t])
|
|
34
|
+
throw new Error(`Invalid change case type "${t}"`);
|
|
35
|
+
return t;
|
|
36
|
+
});
|
|
23
37
|
if (typeof input === "function")
|
|
24
|
-
return vueDemi.computed(() =>
|
|
38
|
+
return vueDemi.computed(() => changeCaseTransforms[typeRef.value](shared.toValue(input), shared.toValue(options)));
|
|
25
39
|
const text = vueDemi.ref(input);
|
|
26
40
|
return vueDemi.computed({
|
|
27
41
|
get() {
|
|
28
|
-
return
|
|
42
|
+
return changeCaseTransforms[typeRef.value](text.value, shared.toValue(options));
|
|
29
43
|
},
|
|
30
44
|
set(value) {
|
|
31
45
|
text.value = value;
|
package/useChangeCase.d.cts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as changeCase from 'change-case';
|
|
2
|
+
import { Options } from 'change-case';
|
|
2
3
|
import { MaybeRef, MaybeRefOrGetter } from '@vueuse/shared';
|
|
3
4
|
import { WritableComputedRef, ComputedRef } from 'vue-demi';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare
|
|
12
|
-
declare
|
|
13
|
-
declare const changeCase_pathCase: typeof pathCase;
|
|
14
|
-
declare const changeCase_sentenceCase: typeof sentenceCase;
|
|
15
|
-
declare const changeCase_snakeCase: typeof snakeCase;
|
|
16
|
-
declare namespace changeCase {
|
|
17
|
-
export { changeCase_camelCase as camelCase, changeCase_capitalCase as capitalCase, changeCase_constantCase as constantCase, changeCase_dotCase as dotCase, changeCase_headerCase as headerCase, changeCase_noCase as noCase, changeCase_paramCase as paramCase, changeCase_pascalCase as pascalCase, changeCase_pathCase as pathCase, changeCase_sentenceCase as sentenceCase, changeCase_snakeCase as snakeCase };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type ChangeCaseType = keyof typeof changeCase;
|
|
21
|
-
declare function useChangeCase(input: MaybeRef<string>, type: ChangeCaseType, options?: Options | undefined): WritableComputedRef<string>;
|
|
22
|
-
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: ChangeCaseType, options?: Options | undefined): ComputedRef<string>;
|
|
6
|
+
type EndsWithCase<T> = T extends `${infer _}Case` ? T : never;
|
|
7
|
+
type FilterKeys<T> = {
|
|
8
|
+
[K in keyof T as K extends string ? K : never]: EndsWithCase<K>;
|
|
9
|
+
};
|
|
10
|
+
type ChangeCaseKeys = FilterKeys<typeof changeCase>;
|
|
11
|
+
type ChangeCaseType = ChangeCaseKeys[keyof ChangeCaseKeys];
|
|
12
|
+
declare function useChangeCase(input: MaybeRef<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): WritableComputedRef<string>;
|
|
13
|
+
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): ComputedRef<string>;
|
|
23
14
|
|
|
24
15
|
export { type ChangeCaseType, useChangeCase };
|
package/useChangeCase.d.mts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as changeCase from 'change-case';
|
|
2
|
+
import { Options } from 'change-case';
|
|
2
3
|
import { MaybeRef, MaybeRefOrGetter } from '@vueuse/shared';
|
|
3
4
|
import { WritableComputedRef, ComputedRef } from 'vue-demi';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare
|
|
12
|
-
declare
|
|
13
|
-
declare const changeCase_pathCase: typeof pathCase;
|
|
14
|
-
declare const changeCase_sentenceCase: typeof sentenceCase;
|
|
15
|
-
declare const changeCase_snakeCase: typeof snakeCase;
|
|
16
|
-
declare namespace changeCase {
|
|
17
|
-
export { changeCase_camelCase as camelCase, changeCase_capitalCase as capitalCase, changeCase_constantCase as constantCase, changeCase_dotCase as dotCase, changeCase_headerCase as headerCase, changeCase_noCase as noCase, changeCase_paramCase as paramCase, changeCase_pascalCase as pascalCase, changeCase_pathCase as pathCase, changeCase_sentenceCase as sentenceCase, changeCase_snakeCase as snakeCase };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type ChangeCaseType = keyof typeof changeCase;
|
|
21
|
-
declare function useChangeCase(input: MaybeRef<string>, type: ChangeCaseType, options?: Options | undefined): WritableComputedRef<string>;
|
|
22
|
-
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: ChangeCaseType, options?: Options | undefined): ComputedRef<string>;
|
|
6
|
+
type EndsWithCase<T> = T extends `${infer _}Case` ? T : never;
|
|
7
|
+
type FilterKeys<T> = {
|
|
8
|
+
[K in keyof T as K extends string ? K : never]: EndsWithCase<K>;
|
|
9
|
+
};
|
|
10
|
+
type ChangeCaseKeys = FilterKeys<typeof changeCase>;
|
|
11
|
+
type ChangeCaseType = ChangeCaseKeys[keyof ChangeCaseKeys];
|
|
12
|
+
declare function useChangeCase(input: MaybeRef<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): WritableComputedRef<string>;
|
|
13
|
+
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): ComputedRef<string>;
|
|
23
14
|
|
|
24
15
|
export { type ChangeCaseType, useChangeCase };
|
package/useChangeCase.d.ts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as changeCase from 'change-case';
|
|
2
|
+
import { Options } from 'change-case';
|
|
2
3
|
import { MaybeRef, MaybeRefOrGetter } from '@vueuse/shared';
|
|
3
4
|
import { WritableComputedRef, ComputedRef } from 'vue-demi';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare
|
|
12
|
-
declare
|
|
13
|
-
declare const changeCase_pathCase: typeof pathCase;
|
|
14
|
-
declare const changeCase_sentenceCase: typeof sentenceCase;
|
|
15
|
-
declare const changeCase_snakeCase: typeof snakeCase;
|
|
16
|
-
declare namespace changeCase {
|
|
17
|
-
export { changeCase_camelCase as camelCase, changeCase_capitalCase as capitalCase, changeCase_constantCase as constantCase, changeCase_dotCase as dotCase, changeCase_headerCase as headerCase, changeCase_noCase as noCase, changeCase_paramCase as paramCase, changeCase_pascalCase as pascalCase, changeCase_pathCase as pathCase, changeCase_sentenceCase as sentenceCase, changeCase_snakeCase as snakeCase };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type ChangeCaseType = keyof typeof changeCase;
|
|
21
|
-
declare function useChangeCase(input: MaybeRef<string>, type: ChangeCaseType, options?: Options | undefined): WritableComputedRef<string>;
|
|
22
|
-
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: ChangeCaseType, options?: Options | undefined): ComputedRef<string>;
|
|
6
|
+
type EndsWithCase<T> = T extends `${infer _}Case` ? T : never;
|
|
7
|
+
type FilterKeys<T> = {
|
|
8
|
+
[K in keyof T as K extends string ? K : never]: EndsWithCase<K>;
|
|
9
|
+
};
|
|
10
|
+
type ChangeCaseKeys = FilterKeys<typeof changeCase>;
|
|
11
|
+
type ChangeCaseType = ChangeCaseKeys[keyof ChangeCaseKeys];
|
|
12
|
+
declare function useChangeCase(input: MaybeRef<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): WritableComputedRef<string>;
|
|
13
|
+
declare function useChangeCase(input: MaybeRefOrGetter<string>, type: MaybeRefOrGetter<ChangeCaseType>, options?: MaybeRefOrGetter<Options> | undefined): ComputedRef<string>;
|
|
23
14
|
|
|
24
15
|
export { type ChangeCaseType, useChangeCase };
|
package/useChangeCase.iife.js
CHANGED
|
@@ -118,31 +118,45 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
118
118
|
(globalThis || self).VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined)
|
|
119
119
|
);
|
|
120
120
|
;
|
|
121
|
-
;(function (exports, shared, vueDemi, changeCase
|
|
121
|
+
;(function (exports, shared, vueDemi, changeCase) {
|
|
122
122
|
'use strict';
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
124
|
+
function _interopNamespaceDefault(e) {
|
|
125
|
+
var n = Object.create(null);
|
|
126
|
+
if (e) {
|
|
127
|
+
Object.keys(e).forEach(function (k) {
|
|
128
|
+
if (k !== 'default') {
|
|
129
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
130
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function () { return e[k]; }
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
n.default = e;
|
|
138
|
+
return Object.freeze(n);
|
|
139
|
+
}
|
|
138
140
|
|
|
141
|
+
var changeCase__namespace = /*#__PURE__*/_interopNamespaceDefault(changeCase);
|
|
142
|
+
|
|
143
|
+
const changeCaseTransforms = /* @__PURE__ */ Object.values(changeCase__namespace).filter((v) => typeof v === "function" && v.name.endsWith("Case")).reduce((acc, fn) => {
|
|
144
|
+
acc[fn.name] = fn;
|
|
145
|
+
return acc;
|
|
146
|
+
}, {});
|
|
139
147
|
function useChangeCase(input, type, options) {
|
|
148
|
+
const typeRef = vueDemi.computed(() => {
|
|
149
|
+
const t = shared.toValue(type);
|
|
150
|
+
if (!changeCaseTransforms[t])
|
|
151
|
+
throw new Error(`Invalid change case type "${t}"`);
|
|
152
|
+
return t;
|
|
153
|
+
});
|
|
140
154
|
if (typeof input === "function")
|
|
141
|
-
return vueDemi.computed(() =>
|
|
155
|
+
return vueDemi.computed(() => changeCaseTransforms[typeRef.value](shared.toValue(input), shared.toValue(options)));
|
|
142
156
|
const text = vueDemi.ref(input);
|
|
143
157
|
return vueDemi.computed({
|
|
144
158
|
get() {
|
|
145
|
-
return
|
|
159
|
+
return changeCaseTransforms[typeRef.value](text.value, shared.toValue(options));
|
|
146
160
|
},
|
|
147
161
|
set(value) {
|
|
148
162
|
text.value = value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(n,e,
|
|
1
|
+
var VueDemi=function(n,e,l){if(n.install)return n;if(!e)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),n;if(e.version.slice(0,4)==="2.7."){let r=function(o,u){var t,i={},c={config:e.config,use:e.use.bind(e),mixin:e.mixin.bind(e),component:e.component.bind(e),provide:function(s,a){return i[s]=a,this},directive:function(s,a){return a?(e.directive(s,a),c):e.directive(s)},mount:function(s,a){return t||(t=new e(Object.assign({propsData:u},o,{provide:Object.assign(i,o.provide)})),t.$mount(s,a),t)},unmount:function(){t&&(t.$destroy(),t=void 0)}};return c};var p=r;for(var f in e)n[f]=e[f];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=e,n.Vue2=e,n.version=e.version,n.warn=e.util.warn,n.hasInjectionContext=function(){return!!n.getCurrentInstance()},n.createApp=r}else if(e.version.slice(0,2)==="2.")if(l){for(var f in l)n[f]=l[f];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=e,n.Vue2=e,n.version=e.version,n.hasInjectionContext=function(){return!!n.getCurrentInstance()}}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(e.version.slice(0,2)==="3."){for(var f in e)n[f]=e[f];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=e,n.Vue2=void 0,n.version=e.version,n.set=function(r,o,u){return Array.isArray(r)?(r.length=Math.max(r.length,o),r.splice(o,1,u),u):(r[o]=u,u)},n.del=function(r,o){if(Array.isArray(r)){r.splice(o,1);return}delete r[o]}}else console.error("[vue-demi] Vue version "+e.version+" is unsupported.");return n}((globalThis||self).VueDemi=(globalThis||self).VueDemi||(typeof VueDemi<"u"?VueDemi:{}),(globalThis||self).Vue||(typeof Vue<"u"?Vue:void 0),(globalThis||self).VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(n,e,l,f){"use strict";function p(t){var i=Object.create(null);return t&&Object.keys(t).forEach(function(c){if(c!=="default"){var s=Object.getOwnPropertyDescriptor(t,c);Object.defineProperty(i,c,s.get?s:{enumerable:!0,get:function(){return t[c]}})}}),i.default=t,Object.freeze(i)}var r=p(f);const o=Object.values(r).filter(t=>typeof t=="function"&&t.name.endsWith("Case")).reduce((t,i)=>(t[i.name]=i,t),{});function u(t,i,c){const s=l.computed(()=>{const d=e.toValue(i);if(!o[d])throw new Error(`Invalid change case type "${d}"`);return d});if(typeof t=="function")return l.computed(()=>o[s.value](e.toValue(t),e.toValue(c)));const a=l.ref(t);return l.computed({get(){return o[s.value](a.value,e.toValue(c))},set(d){a.value=d}})}n.useChangeCase=u})(this.VueUse=this.VueUse||{},VueUse,VueDemi,changeCase);
|
package/useChangeCase.mjs
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { toValue } from '@vueuse/shared';
|
|
2
2
|
import { computed, ref } from 'vue-demi';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
var changeCase = /*#__PURE__*/Object.freeze({
|
|
6
|
-
__proto__: null,
|
|
7
|
-
camelCase: camelCase,
|
|
8
|
-
capitalCase: capitalCase,
|
|
9
|
-
constantCase: constantCase,
|
|
10
|
-
dotCase: dotCase,
|
|
11
|
-
headerCase: headerCase,
|
|
12
|
-
noCase: noCase,
|
|
13
|
-
paramCase: paramCase,
|
|
14
|
-
pascalCase: pascalCase,
|
|
15
|
-
pathCase: pathCase,
|
|
16
|
-
sentenceCase: sentenceCase,
|
|
17
|
-
snakeCase: snakeCase
|
|
18
|
-
});
|
|
3
|
+
import * as changeCase from 'change-case';
|
|
19
4
|
|
|
5
|
+
const changeCaseTransforms = /* @__PURE__ */ Object.values(changeCase).filter((v) => typeof v === "function" && v.name.endsWith("Case")).reduce((acc, fn) => {
|
|
6
|
+
acc[fn.name] = fn;
|
|
7
|
+
return acc;
|
|
8
|
+
}, {});
|
|
20
9
|
function useChangeCase(input, type, options) {
|
|
10
|
+
const typeRef = computed(() => {
|
|
11
|
+
const t = toValue(type);
|
|
12
|
+
if (!changeCaseTransforms[t])
|
|
13
|
+
throw new Error(`Invalid change case type "${t}"`);
|
|
14
|
+
return t;
|
|
15
|
+
});
|
|
21
16
|
if (typeof input === "function")
|
|
22
|
-
return computed(() =>
|
|
17
|
+
return computed(() => changeCaseTransforms[typeRef.value](toValue(input), toValue(options)));
|
|
23
18
|
const text = ref(input);
|
|
24
19
|
return computed({
|
|
25
20
|
get() {
|
|
26
|
-
return
|
|
21
|
+
return changeCaseTransforms[typeRef.value](text.value, toValue(options));
|
|
27
22
|
},
|
|
28
23
|
set(value) {
|
|
29
24
|
text.value = value;
|
package/useFuse.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
2
|
import { ComputedRef } from 'vue-demi';
|
|
3
|
-
import
|
|
3
|
+
import * as fuse_js from 'fuse.js';
|
|
4
|
+
import { IFuseOptions, FuseResult } from 'fuse.js';
|
|
4
5
|
import { MaybeRefOrGetter } from '@vueuse/shared';
|
|
5
6
|
|
|
6
|
-
type FuseOptions<T> =
|
|
7
|
+
type FuseOptions<T> = IFuseOptions<T>;
|
|
7
8
|
interface UseFuseOptions<T> {
|
|
8
9
|
fuseOptions?: FuseOptions<T>;
|
|
9
10
|
resultLimit?: number;
|
|
@@ -11,14 +12,14 @@ interface UseFuseOptions<T> {
|
|
|
11
12
|
}
|
|
12
13
|
declare function useFuse<DataItem>(search: MaybeRefOrGetter<string>, data: MaybeRefOrGetter<DataItem[]>, options?: MaybeRefOrGetter<UseFuseOptions<DataItem>>): {
|
|
13
14
|
fuse: vue_demi.Ref<{
|
|
14
|
-
search: <R = DataItem>(pattern: string |
|
|
15
|
-
setCollection: (docs: readonly DataItem[], index?:
|
|
15
|
+
search: <R = DataItem>(pattern: string | fuse_js.Expression, options?: fuse_js.FuseSearchOptions | undefined) => FuseResult<R>[];
|
|
16
|
+
setCollection: (docs: readonly DataItem[], index?: fuse_js.FuseIndex<DataItem> | undefined) => void;
|
|
16
17
|
add: (doc: DataItem) => void;
|
|
17
18
|
remove: (predicate: (doc: DataItem, idx: number) => boolean) => DataItem[];
|
|
18
19
|
removeAt: (idx: number) => void;
|
|
19
|
-
getIndex: () =>
|
|
20
|
+
getIndex: () => fuse_js.FuseIndex<DataItem>;
|
|
20
21
|
}>;
|
|
21
|
-
results: ComputedRef<
|
|
22
|
+
results: ComputedRef<FuseResult<DataItem>[]>;
|
|
22
23
|
};
|
|
23
24
|
type UseFuseReturn = ReturnType<typeof useFuse>;
|
|
24
25
|
|
package/useFuse.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
2
|
import { ComputedRef } from 'vue-demi';
|
|
3
|
-
import
|
|
3
|
+
import * as fuse_js from 'fuse.js';
|
|
4
|
+
import { IFuseOptions, FuseResult } from 'fuse.js';
|
|
4
5
|
import { MaybeRefOrGetter } from '@vueuse/shared';
|
|
5
6
|
|
|
6
|
-
type FuseOptions<T> =
|
|
7
|
+
type FuseOptions<T> = IFuseOptions<T>;
|
|
7
8
|
interface UseFuseOptions<T> {
|
|
8
9
|
fuseOptions?: FuseOptions<T>;
|
|
9
10
|
resultLimit?: number;
|
|
@@ -11,14 +12,14 @@ interface UseFuseOptions<T> {
|
|
|
11
12
|
}
|
|
12
13
|
declare function useFuse<DataItem>(search: MaybeRefOrGetter<string>, data: MaybeRefOrGetter<DataItem[]>, options?: MaybeRefOrGetter<UseFuseOptions<DataItem>>): {
|
|
13
14
|
fuse: vue_demi.Ref<{
|
|
14
|
-
search: <R = DataItem>(pattern: string |
|
|
15
|
-
setCollection: (docs: readonly DataItem[], index?:
|
|
15
|
+
search: <R = DataItem>(pattern: string | fuse_js.Expression, options?: fuse_js.FuseSearchOptions | undefined) => FuseResult<R>[];
|
|
16
|
+
setCollection: (docs: readonly DataItem[], index?: fuse_js.FuseIndex<DataItem> | undefined) => void;
|
|
16
17
|
add: (doc: DataItem) => void;
|
|
17
18
|
remove: (predicate: (doc: DataItem, idx: number) => boolean) => DataItem[];
|
|
18
19
|
removeAt: (idx: number) => void;
|
|
19
|
-
getIndex: () =>
|
|
20
|
+
getIndex: () => fuse_js.FuseIndex<DataItem>;
|
|
20
21
|
}>;
|
|
21
|
-
results: ComputedRef<
|
|
22
|
+
results: ComputedRef<FuseResult<DataItem>[]>;
|
|
22
23
|
};
|
|
23
24
|
type UseFuseReturn = ReturnType<typeof useFuse>;
|
|
24
25
|
|
package/useFuse.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
2
|
import { ComputedRef } from 'vue-demi';
|
|
3
|
-
import
|
|
3
|
+
import * as fuse_js from 'fuse.js';
|
|
4
|
+
import { IFuseOptions, FuseResult } from 'fuse.js';
|
|
4
5
|
import { MaybeRefOrGetter } from '@vueuse/shared';
|
|
5
6
|
|
|
6
|
-
type FuseOptions<T> =
|
|
7
|
+
type FuseOptions<T> = IFuseOptions<T>;
|
|
7
8
|
interface UseFuseOptions<T> {
|
|
8
9
|
fuseOptions?: FuseOptions<T>;
|
|
9
10
|
resultLimit?: number;
|
|
@@ -11,14 +12,14 @@ interface UseFuseOptions<T> {
|
|
|
11
12
|
}
|
|
12
13
|
declare function useFuse<DataItem>(search: MaybeRefOrGetter<string>, data: MaybeRefOrGetter<DataItem[]>, options?: MaybeRefOrGetter<UseFuseOptions<DataItem>>): {
|
|
13
14
|
fuse: vue_demi.Ref<{
|
|
14
|
-
search: <R = DataItem>(pattern: string |
|
|
15
|
-
setCollection: (docs: readonly DataItem[], index?:
|
|
15
|
+
search: <R = DataItem>(pattern: string | fuse_js.Expression, options?: fuse_js.FuseSearchOptions | undefined) => FuseResult<R>[];
|
|
16
|
+
setCollection: (docs: readonly DataItem[], index?: fuse_js.FuseIndex<DataItem> | undefined) => void;
|
|
16
17
|
add: (doc: DataItem) => void;
|
|
17
18
|
remove: (predicate: (doc: DataItem, idx: number) => boolean) => DataItem[];
|
|
18
19
|
removeAt: (idx: number) => void;
|
|
19
|
-
getIndex: () =>
|
|
20
|
+
getIndex: () => fuse_js.FuseIndex<DataItem>;
|
|
20
21
|
}>;
|
|
21
|
-
results: ComputedRef<
|
|
22
|
+
results: ComputedRef<FuseResult<DataItem>[]>;
|
|
22
23
|
};
|
|
23
24
|
type UseFuseReturn = ReturnType<typeof useFuse>;
|
|
24
25
|
|
package/useJwt.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var vueDemi = require('vue-demi');
|
|
4
4
|
var shared = require('@vueuse/shared');
|
|
5
|
-
var
|
|
5
|
+
var jwtDecode = require('jwt-decode');
|
|
6
6
|
|
|
7
7
|
function useJwt(encodedJwt, options = {}) {
|
|
8
8
|
const {
|
|
@@ -11,7 +11,7 @@ function useJwt(encodedJwt, options = {}) {
|
|
|
11
11
|
} = options;
|
|
12
12
|
const decodeWithFallback = (encodedJwt2, options2) => {
|
|
13
13
|
try {
|
|
14
|
-
return
|
|
14
|
+
return jwtDecode.jwtDecode(encodedJwt2, options2);
|
|
15
15
|
} catch (err) {
|
|
16
16
|
onError == null ? void 0 : onError(err);
|
|
17
17
|
return fallbackValue;
|
package/useJwt.iife.js
CHANGED
|
@@ -118,7 +118,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
118
118
|
(globalThis || self).VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined)
|
|
119
119
|
);
|
|
120
120
|
;
|
|
121
|
-
;(function (exports, vueDemi, shared,
|
|
121
|
+
;(function (exports, vueDemi, shared, jwtDecode) {
|
|
122
122
|
'use strict';
|
|
123
123
|
|
|
124
124
|
function useJwt(encodedJwt, options = {}) {
|
|
@@ -128,7 +128,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
128
128
|
} = options;
|
|
129
129
|
const decodeWithFallback = (encodedJwt2, options2) => {
|
|
130
130
|
try {
|
|
131
|
-
return
|
|
131
|
+
return jwtDecode.jwtDecode(encodedJwt2, options2);
|
|
132
132
|
} catch (err) {
|
|
133
133
|
onError == null ? void 0 : onError(err);
|
|
134
134
|
return fallbackValue;
|
package/useJwt.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(n,r,
|
|
1
|
+
var VueDemi=function(n,r,l){if(n.install)return n;if(!r)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),n;if(r.version.slice(0,4)==="2.7."){let o=function(t,i){var s,a={},d={config:r.config,use:r.use.bind(r),mixin:r.mixin.bind(r),component:r.component.bind(r),provide:function(c,f){return a[c]=f,this},directive:function(c,f){return f?(r.directive(c,f),d):r.directive(c)},mount:function(c,f){return s||(s=new r(Object.assign({propsData:i},t,{provide:Object.assign(a,t.provide)})),s.$mount(c,f),s)},unmount:function(){s&&(s.$destroy(),s=void 0)}};return d};var u=o;for(var e in r)n[e]=r[e];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=r,n.Vue2=r,n.version=r.version,n.warn=r.util.warn,n.hasInjectionContext=function(){return!!n.getCurrentInstance()},n.createApp=o}else if(r.version.slice(0,2)==="2.")if(l){for(var e in l)n[e]=l[e];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=r,n.Vue2=r,n.version=r.version,n.hasInjectionContext=function(){return!!n.getCurrentInstance()}}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(r.version.slice(0,2)==="3."){for(var e in r)n[e]=r[e];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=r,n.Vue2=void 0,n.version=r.version,n.set=function(o,t,i){return Array.isArray(o)?(o.length=Math.max(o.length,t),o.splice(t,1,i),i):(o[t]=i,i)},n.del=function(o,t){if(Array.isArray(o)){o.splice(t,1);return}delete o[t]}}else console.error("[vue-demi] Vue version "+r.version+" is unsupported.");return n}((globalThis||self).VueDemi=(globalThis||self).VueDemi||(typeof VueDemi<"u"?VueDemi:{}),(globalThis||self).Vue||(typeof Vue<"u"?Vue:void 0),(globalThis||self).VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(n,r,l,e){"use strict";function u(o,t={}){const{onError:i,fallbackValue:s=null}=t,a=(f,v)=>{try{return e.jwtDecode(f,v)}catch(p){return i?.(p),s}},d=r.computed(()=>a(l.toValue(o),{header:!0})),c=r.computed(()=>a(l.toValue(o)));return{header:d,payload:c}}n.useJwt=u})(this.VueUse=this.VueUse||{},VueDemi,VueUse,jwt_decode);
|
package/useJwt.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed } from 'vue-demi';
|
|
2
2
|
import { toValue } from '@vueuse/shared';
|
|
3
|
-
import
|
|
3
|
+
import { jwtDecode } from 'jwt-decode';
|
|
4
4
|
|
|
5
5
|
function useJwt(encodedJwt, options = {}) {
|
|
6
6
|
const {
|
|
@@ -9,7 +9,7 @@ function useJwt(encodedJwt, options = {}) {
|
|
|
9
9
|
} = options;
|
|
10
10
|
const decodeWithFallback = (encodedJwt2, options2) => {
|
|
11
11
|
try {
|
|
12
|
-
return
|
|
12
|
+
return jwtDecode(encodedJwt2, options2);
|
|
13
13
|
} catch (err) {
|
|
14
14
|
onError == null ? void 0 : onError(err);
|
|
15
15
|
return fallbackValue;
|