@vueuse/integrations 8.0.0-beta.2 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/index.cjs +52 -13
- package/index.d.ts +71 -14
- package/index.iife.js +53 -15
- package/index.iife.min.js +1 -1
- package/index.mjs +53 -15
- package/package.json +18 -11
- package/useAxios.cjs +23 -13
- package/useAxios.d.ts +35 -9
- package/useAxios.iife.js +23 -13
- package/useAxios.iife.min.js +1 -1
- package/useAxios.mjs +23 -13
- package/useChangeCase.cjs +35 -0
- package/useChangeCase.d.ts +35 -0
- package/useChangeCase.iife.js +96 -0
- package/useChangeCase.iife.min.js +1 -0
- package/useChangeCase.mjs +31 -0
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ npm i <b>@vueuse/integrations</b>
|
|
|
15
15
|
<!--GENERATED LIST, DO NOT MODIFY MANUALLY-->
|
|
16
16
|
<!--FUNCTIONS_LIST_STARTS-->
|
|
17
17
|
- [`useAxios`](https://vueuse.org/integrations/useAxios/) — wrapper for [`axios`](https://github.com/axios/axios)
|
|
18
|
+
- [`useChangeCase`](https://vueuse.org/integrations/useChangeCase/) — wrapper for [`change-case`](https://github.com/blakeembrey/change-case)
|
|
18
19
|
- [`useCookies`](https://vueuse.org/integrations/useCookies/) — wrapper for [`universal-cookie`](https://www.npmjs.com/package/universal-cookie)
|
|
19
20
|
- [`useDrauu`](https://vueuse.org/integrations/useDrauu/) — reactive instance for [drauu](https://github.com/antfu/drauu)
|
|
20
21
|
- [`useFocusTrap`](https://vueuse.org/integrations/useFocusTrap/) — reactive wrapper for [`focus-trap`](https://github.com/focus-trap/focus-trap)
|
package/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var vueDemi = require('vue-demi');
|
|
6
6
|
var shared = require('@vueuse/shared');
|
|
7
7
|
var axios = require('axios');
|
|
8
|
+
var changeCase$1 = require('change-case');
|
|
8
9
|
var Cookie = require('universal-cookie');
|
|
9
10
|
var drauu = require('drauu');
|
|
10
11
|
var core = require('@vueuse/core');
|
|
@@ -42,21 +43,23 @@ var __spreadValues$3 = (a, b) => {
|
|
|
42
43
|
return a;
|
|
43
44
|
};
|
|
44
45
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
45
|
-
function useAxios(
|
|
46
|
+
function useAxios(...args) {
|
|
47
|
+
const url = typeof args[0] === "string" ? args[0] : void 0;
|
|
48
|
+
const argsPlaceholder = url ? 1 : 0;
|
|
46
49
|
let defaultConfig = {};
|
|
47
50
|
let instance = axios__default["default"];
|
|
48
|
-
let options = { immediate:
|
|
49
|
-
if (args.length > 0) {
|
|
50
|
-
if ("request" in args[0])
|
|
51
|
-
instance = args[0];
|
|
51
|
+
let options = { immediate: !!argsPlaceholder };
|
|
52
|
+
if (args.length > 0 + argsPlaceholder) {
|
|
53
|
+
if ("request" in args[0 + argsPlaceholder])
|
|
54
|
+
instance = args[0 + argsPlaceholder];
|
|
52
55
|
else
|
|
53
|
-
defaultConfig = args[0];
|
|
56
|
+
defaultConfig = args[0 + argsPlaceholder];
|
|
54
57
|
}
|
|
55
|
-
if (args.length > 1) {
|
|
56
|
-
if ("request" in args[1])
|
|
57
|
-
instance = args[1];
|
|
58
|
+
if (args.length > 1 + argsPlaceholder) {
|
|
59
|
+
if ("request" in args[1 + argsPlaceholder])
|
|
60
|
+
instance = args[1 + argsPlaceholder];
|
|
58
61
|
}
|
|
59
|
-
if (args.length === 2 && !("request" in args[1]) || args.length === 3)
|
|
62
|
+
if (args.length === 2 + argsPlaceholder && !("request" in args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
|
|
60
63
|
options = args[args.length - 1];
|
|
61
64
|
const response = vueDemi.shallowRef();
|
|
62
65
|
const data = vueDemi.shallowRef();
|
|
@@ -77,9 +80,17 @@ function useAxios(url, ...args) {
|
|
|
77
80
|
isLoading.value = loading2;
|
|
78
81
|
isFinished.value = !loading2;
|
|
79
82
|
};
|
|
80
|
-
const execute = (config = {}) => {
|
|
83
|
+
const execute = (executeUrl = url, config = {}) => {
|
|
84
|
+
let _url = "";
|
|
85
|
+
let _config;
|
|
86
|
+
if (typeof executeUrl === "string") {
|
|
87
|
+
_url = executeUrl;
|
|
88
|
+
_config = config;
|
|
89
|
+
} else {
|
|
90
|
+
_config = config;
|
|
91
|
+
}
|
|
81
92
|
loading(true);
|
|
82
|
-
instance(
|
|
93
|
+
instance(_url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig), _config), { cancelToken: cancelToken.token })).then((r) => {
|
|
83
94
|
response.value = r;
|
|
84
95
|
data.value = r.data;
|
|
85
96
|
}).catch((e) => {
|
|
@@ -88,7 +99,7 @@ function useAxios(url, ...args) {
|
|
|
88
99
|
loading(false);
|
|
89
100
|
});
|
|
90
101
|
};
|
|
91
|
-
if (options.immediate)
|
|
102
|
+
if (options.immediate && url)
|
|
92
103
|
execute();
|
|
93
104
|
const result = {
|
|
94
105
|
response,
|
|
@@ -116,6 +127,33 @@ function useAxios(url, ...args) {
|
|
|
116
127
|
});
|
|
117
128
|
}
|
|
118
129
|
|
|
130
|
+
var changeCase = /*#__PURE__*/Object.freeze({
|
|
131
|
+
__proto__: null,
|
|
132
|
+
camelCase: changeCase$1.camelCase,
|
|
133
|
+
capitalCase: changeCase$1.capitalCase,
|
|
134
|
+
constantCase: changeCase$1.constantCase,
|
|
135
|
+
dotCase: changeCase$1.dotCase,
|
|
136
|
+
headerCase: changeCase$1.headerCase,
|
|
137
|
+
noCase: changeCase$1.noCase,
|
|
138
|
+
paramCase: changeCase$1.paramCase,
|
|
139
|
+
pascalCase: changeCase$1.pascalCase,
|
|
140
|
+
pathCase: changeCase$1.pathCase,
|
|
141
|
+
sentenceCase: changeCase$1.sentenceCase,
|
|
142
|
+
snakeCase: changeCase$1.snakeCase
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
function useChangeCase(input, type, options) {
|
|
146
|
+
const text = vueDemi.ref(input);
|
|
147
|
+
return vueDemi.computed({
|
|
148
|
+
get() {
|
|
149
|
+
return changeCase[type](text.value, options);
|
|
150
|
+
},
|
|
151
|
+
set(value) {
|
|
152
|
+
text.value = value;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
119
157
|
var __defProp$2 = Object.defineProperty;
|
|
120
158
|
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
121
159
|
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
@@ -466,6 +504,7 @@ function useQRCode(text, options) {
|
|
|
466
504
|
|
|
467
505
|
exports.createCookies = createCookies;
|
|
468
506
|
exports.useAxios = useAxios;
|
|
507
|
+
exports.useChangeCase = useChangeCase;
|
|
469
508
|
exports.useCookies = useCookies;
|
|
470
509
|
exports.useDrauu = useDrauu;
|
|
471
510
|
exports.useFocusTrap = useFocusTrap;
|
package/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
|
-
import { Ref, ComputedRef } from 'vue-demi';
|
|
2
|
+
import { ShallowRef, Ref, WritableComputedRef, ComputedRef } from 'vue-demi';
|
|
3
3
|
import { AxiosResponse, AxiosError, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
4
|
+
import { camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase, Options } from 'change-case';
|
|
5
|
+
import { MaybeRef } from '@vueuse/shared';
|
|
4
6
|
import * as universal_cookie from 'universal-cookie';
|
|
5
7
|
import universal_cookie__default from 'universal-cookie';
|
|
6
8
|
import { IncomingMessage } from 'http';
|
|
7
|
-
import { Options, Drauu, Brush } from 'drauu';
|
|
9
|
+
import { Options as Options$1, Drauu, Brush } from 'drauu';
|
|
8
10
|
import { EventHookOn, MaybeElementRef, Fn } from '@vueuse/core';
|
|
9
|
-
import { Options as Options$
|
|
11
|
+
import { Options as Options$2, ActivateOptions, DeactivateOptions } from 'focus-trap';
|
|
10
12
|
import Fuse from 'fuse.js';
|
|
11
|
-
import { MaybeRef } from '@vueuse/shared';
|
|
12
13
|
import { JwtPayload, JwtHeader } from 'jwt-decode';
|
|
13
14
|
import nprogress, { NProgressOptions } from 'nprogress';
|
|
14
15
|
import QRCode from 'qrcode';
|
|
@@ -17,7 +18,7 @@ interface UseAxiosReturn<T> {
|
|
|
17
18
|
/**
|
|
18
19
|
* Axios Response
|
|
19
20
|
*/
|
|
20
|
-
response:
|
|
21
|
+
response: ShallowRef<AxiosResponse<T> | undefined>;
|
|
21
22
|
/**
|
|
22
23
|
* Axios response data
|
|
23
24
|
*/
|
|
@@ -37,27 +38,83 @@ interface UseAxiosReturn<T> {
|
|
|
37
38
|
/**
|
|
38
39
|
* Any errors that may have occurred
|
|
39
40
|
*/
|
|
40
|
-
error:
|
|
41
|
+
error: ShallowRef<AxiosError<T> | undefined>;
|
|
41
42
|
/**
|
|
42
43
|
* Aborts the current request
|
|
43
44
|
*/
|
|
44
45
|
abort: (message?: string | undefined) => void;
|
|
46
|
+
/**
|
|
47
|
+
* isFinished alias
|
|
48
|
+
*/
|
|
49
|
+
finished: Ref<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* loading alias
|
|
52
|
+
*/
|
|
53
|
+
loading: Ref<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* abort alias
|
|
56
|
+
*/
|
|
57
|
+
cancel: (message?: string | undefined) => void;
|
|
58
|
+
/**
|
|
59
|
+
* abort aborted
|
|
60
|
+
*/
|
|
61
|
+
canceled: Ref<boolean>;
|
|
62
|
+
}
|
|
63
|
+
interface StrictUseAxiosReturn<T> extends UseAxiosReturn<T> {
|
|
45
64
|
/**
|
|
46
65
|
* Manually call the axios request
|
|
47
66
|
*/
|
|
48
|
-
execute: (config?: AxiosRequestConfig) => void;
|
|
67
|
+
execute: (url?: string, config?: AxiosRequestConfig) => void;
|
|
68
|
+
}
|
|
69
|
+
interface EasyUseAxiosReturn<T> extends UseAxiosReturn<T> {
|
|
70
|
+
/**
|
|
71
|
+
* Manually call the axios request
|
|
72
|
+
*/
|
|
73
|
+
execute: (url: string, config?: AxiosRequestConfig) => void;
|
|
49
74
|
}
|
|
50
75
|
interface UseAxiosOptions {
|
|
51
76
|
/**
|
|
52
77
|
* Will automatically run axios request when `useAxios` is used
|
|
53
78
|
*
|
|
54
|
-
* @default true
|
|
55
79
|
*/
|
|
56
80
|
immediate?: boolean;
|
|
57
81
|
}
|
|
58
|
-
declare function useAxios<T = any>(url: string, config?: AxiosRequestConfig, options?: UseAxiosOptions):
|
|
59
|
-
declare function useAxios<T = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions):
|
|
60
|
-
declare function useAxios<T = any>(url: string, config: AxiosRequestConfig, instance: AxiosInstance, options?: UseAxiosOptions):
|
|
82
|
+
declare function useAxios<T = any>(url: string, config?: AxiosRequestConfig, options?: UseAxiosOptions): StrictUseAxiosReturn<T> & PromiseLike<StrictUseAxiosReturn<T>>;
|
|
83
|
+
declare function useAxios<T = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T> & PromiseLike<StrictUseAxiosReturn<T>>;
|
|
84
|
+
declare function useAxios<T = any>(url: string, config: AxiosRequestConfig, instance: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T> & PromiseLike<StrictUseAxiosReturn<T>>;
|
|
85
|
+
declare function useAxios<T = any>(config?: AxiosRequestConfig): EasyUseAxiosReturn<T> & PromiseLike<EasyUseAxiosReturn<T>>;
|
|
86
|
+
declare function useAxios<T = any>(instance?: AxiosInstance): EasyUseAxiosReturn<T> & PromiseLike<EasyUseAxiosReturn<T>>;
|
|
87
|
+
declare function useAxios<T = any>(config?: AxiosRequestConfig, instance?: AxiosInstance): EasyUseAxiosReturn<T> & PromiseLike<EasyUseAxiosReturn<T>>;
|
|
88
|
+
|
|
89
|
+
declare const changeCase_camelCase: typeof camelCase;
|
|
90
|
+
declare const changeCase_capitalCase: typeof capitalCase;
|
|
91
|
+
declare const changeCase_constantCase: typeof constantCase;
|
|
92
|
+
declare const changeCase_dotCase: typeof dotCase;
|
|
93
|
+
declare const changeCase_headerCase: typeof headerCase;
|
|
94
|
+
declare const changeCase_noCase: typeof noCase;
|
|
95
|
+
declare const changeCase_paramCase: typeof paramCase;
|
|
96
|
+
declare const changeCase_pascalCase: typeof pascalCase;
|
|
97
|
+
declare const changeCase_pathCase: typeof pathCase;
|
|
98
|
+
declare const changeCase_sentenceCase: typeof sentenceCase;
|
|
99
|
+
declare const changeCase_snakeCase: typeof snakeCase;
|
|
100
|
+
declare namespace changeCase {
|
|
101
|
+
export {
|
|
102
|
+
changeCase_camelCase as camelCase,
|
|
103
|
+
changeCase_capitalCase as capitalCase,
|
|
104
|
+
changeCase_constantCase as constantCase,
|
|
105
|
+
changeCase_dotCase as dotCase,
|
|
106
|
+
changeCase_headerCase as headerCase,
|
|
107
|
+
changeCase_noCase as noCase,
|
|
108
|
+
changeCase_paramCase as paramCase,
|
|
109
|
+
changeCase_pascalCase as pascalCase,
|
|
110
|
+
changeCase_pathCase as pathCase,
|
|
111
|
+
changeCase_sentenceCase as sentenceCase,
|
|
112
|
+
changeCase_snakeCase as snakeCase,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
declare type ChangeCaseType = keyof typeof changeCase;
|
|
117
|
+
declare function useChangeCase(input: MaybeRef<string>, type: ChangeCaseType, options?: Options | undefined): WritableComputedRef<string>;
|
|
61
118
|
|
|
62
119
|
/**
|
|
63
120
|
* Creates a new {@link useCookies} function
|
|
@@ -108,7 +165,7 @@ declare function useCookies(dependencies?: string[] | null, { doNotParse, autoUp
|
|
|
108
165
|
removeChangeListener: (callback: universal_cookie.CookieChangeListener) => void;
|
|
109
166
|
};
|
|
110
167
|
|
|
111
|
-
declare type UseDrauuOptions = Omit<Options, 'el'>;
|
|
168
|
+
declare type UseDrauuOptions = Omit<Options$1, 'el'>;
|
|
112
169
|
interface UseDrauuReturn {
|
|
113
170
|
drauuInstance: Ref<Drauu | undefined>;
|
|
114
171
|
load: (svg: string) => void;
|
|
@@ -135,7 +192,7 @@ interface UseDrauuReturn {
|
|
|
135
192
|
*/
|
|
136
193
|
declare function useDrauu(target: MaybeElementRef, options?: UseDrauuOptions): UseDrauuReturn;
|
|
137
194
|
|
|
138
|
-
interface UseFocusTrapOptions extends Options$
|
|
195
|
+
interface UseFocusTrapOptions extends Options$2 {
|
|
139
196
|
/**
|
|
140
197
|
* Immediately activate the trap
|
|
141
198
|
*/
|
|
@@ -246,4 +303,4 @@ declare function useNProgress(currentProgress?: MaybeRef<number | null | undefin
|
|
|
246
303
|
*/
|
|
247
304
|
declare function useQRCode(text: MaybeRef<string>, options?: QRCode.QRCodeToDataURLOptions): vue_demi.Ref<string>;
|
|
248
305
|
|
|
249
|
-
export { FuseOptions, JwtOptions, JwtResult, UseAxiosOptions, UseAxiosReturn, UseDrauuOptions, UseDrauuReturn, UseFocusTrapOptions, UseFocusTrapReturn, UseFuseOptions, UseFuseReturn, createCookies, useAxios, useCookies, useDrauu, useFocusTrap, useFuse, useJwt, useNProgress, useQRCode };
|
|
306
|
+
export { ChangeCaseType, EasyUseAxiosReturn, FuseOptions, JwtOptions, JwtResult, StrictUseAxiosReturn, UseAxiosOptions, UseAxiosReturn, UseDrauuOptions, UseDrauuReturn, UseFocusTrapOptions, UseFocusTrapReturn, UseFuseOptions, UseFuseReturn, createCookies, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useJwt, useNProgress, useQRCode };
|
package/index.iife.js
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
window.VueDemi = VueDemi
|
|
60
60
|
})(window)
|
|
61
61
|
;
|
|
62
|
-
;(function (exports, vueDemi, shared, axios, Cookie, drauu, core, focusTrap, Fuse, jwt_decode, nprogress, QRCode) {
|
|
62
|
+
;(function (exports, vueDemi, shared, axios, changeCase$1, Cookie, drauu, core, focusTrap, Fuse, jwt_decode, nprogress, QRCode) {
|
|
63
63
|
'use strict';
|
|
64
64
|
|
|
65
65
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -90,21 +90,23 @@
|
|
|
90
90
|
return a;
|
|
91
91
|
};
|
|
92
92
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
93
|
-
function useAxios(
|
|
93
|
+
function useAxios(...args) {
|
|
94
|
+
const url = typeof args[0] === "string" ? args[0] : void 0;
|
|
95
|
+
const argsPlaceholder = url ? 1 : 0;
|
|
94
96
|
let defaultConfig = {};
|
|
95
97
|
let instance = axios__default["default"];
|
|
96
|
-
let options = { immediate:
|
|
97
|
-
if (args.length > 0) {
|
|
98
|
-
if ("request" in args[0])
|
|
99
|
-
instance = args[0];
|
|
98
|
+
let options = { immediate: !!argsPlaceholder };
|
|
99
|
+
if (args.length > 0 + argsPlaceholder) {
|
|
100
|
+
if ("request" in args[0 + argsPlaceholder])
|
|
101
|
+
instance = args[0 + argsPlaceholder];
|
|
100
102
|
else
|
|
101
|
-
defaultConfig = args[0];
|
|
103
|
+
defaultConfig = args[0 + argsPlaceholder];
|
|
102
104
|
}
|
|
103
|
-
if (args.length > 1) {
|
|
104
|
-
if ("request" in args[1])
|
|
105
|
-
instance = args[1];
|
|
105
|
+
if (args.length > 1 + argsPlaceholder) {
|
|
106
|
+
if ("request" in args[1 + argsPlaceholder])
|
|
107
|
+
instance = args[1 + argsPlaceholder];
|
|
106
108
|
}
|
|
107
|
-
if (args.length === 2 && !("request" in args[1]) || args.length === 3)
|
|
109
|
+
if (args.length === 2 + argsPlaceholder && !("request" in args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
|
|
108
110
|
options = args[args.length - 1];
|
|
109
111
|
const response = vueDemi.shallowRef();
|
|
110
112
|
const data = vueDemi.shallowRef();
|
|
@@ -125,9 +127,17 @@
|
|
|
125
127
|
isLoading.value = loading2;
|
|
126
128
|
isFinished.value = !loading2;
|
|
127
129
|
};
|
|
128
|
-
const execute = (config = {}) => {
|
|
130
|
+
const execute = (executeUrl = url, config = {}) => {
|
|
131
|
+
let _url = "";
|
|
132
|
+
let _config;
|
|
133
|
+
if (typeof executeUrl === "string") {
|
|
134
|
+
_url = executeUrl;
|
|
135
|
+
_config = config;
|
|
136
|
+
} else {
|
|
137
|
+
_config = config;
|
|
138
|
+
}
|
|
129
139
|
loading(true);
|
|
130
|
-
instance(
|
|
140
|
+
instance(_url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig), _config), { cancelToken: cancelToken.token })).then((r) => {
|
|
131
141
|
response.value = r;
|
|
132
142
|
data.value = r.data;
|
|
133
143
|
}).catch((e) => {
|
|
@@ -136,7 +146,7 @@
|
|
|
136
146
|
loading(false);
|
|
137
147
|
});
|
|
138
148
|
};
|
|
139
|
-
if (options.immediate)
|
|
149
|
+
if (options.immediate && url)
|
|
140
150
|
execute();
|
|
141
151
|
const result = {
|
|
142
152
|
response,
|
|
@@ -164,6 +174,33 @@
|
|
|
164
174
|
});
|
|
165
175
|
}
|
|
166
176
|
|
|
177
|
+
var changeCase = /*#__PURE__*/Object.freeze({
|
|
178
|
+
__proto__: null,
|
|
179
|
+
camelCase: changeCase$1.camelCase,
|
|
180
|
+
capitalCase: changeCase$1.capitalCase,
|
|
181
|
+
constantCase: changeCase$1.constantCase,
|
|
182
|
+
dotCase: changeCase$1.dotCase,
|
|
183
|
+
headerCase: changeCase$1.headerCase,
|
|
184
|
+
noCase: changeCase$1.noCase,
|
|
185
|
+
paramCase: changeCase$1.paramCase,
|
|
186
|
+
pascalCase: changeCase$1.pascalCase,
|
|
187
|
+
pathCase: changeCase$1.pathCase,
|
|
188
|
+
sentenceCase: changeCase$1.sentenceCase,
|
|
189
|
+
snakeCase: changeCase$1.snakeCase
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
function useChangeCase(input, type, options) {
|
|
193
|
+
const text = vueDemi.ref(input);
|
|
194
|
+
return vueDemi.computed({
|
|
195
|
+
get() {
|
|
196
|
+
return changeCase[type](text.value, options);
|
|
197
|
+
},
|
|
198
|
+
set(value) {
|
|
199
|
+
text.value = value;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
167
204
|
var __defProp$2 = Object.defineProperty;
|
|
168
205
|
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
169
206
|
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
@@ -514,6 +551,7 @@
|
|
|
514
551
|
|
|
515
552
|
exports.createCookies = createCookies;
|
|
516
553
|
exports.useAxios = useAxios;
|
|
554
|
+
exports.useChangeCase = useChangeCase;
|
|
517
555
|
exports.useCookies = useCookies;
|
|
518
556
|
exports.useDrauu = useDrauu;
|
|
519
557
|
exports.useFocusTrap = useFocusTrap;
|
|
@@ -524,4 +562,4 @@
|
|
|
524
562
|
|
|
525
563
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
526
564
|
|
|
527
|
-
})(this.VueUse = this.VueUse || {}, VueDemi, VueUse, axios, UniversalCookie, Drauu, VueUse, focusTrap, Fuse, jwt_decode, nprogress, QRCode);
|
|
565
|
+
})(this.VueUse = this.VueUse || {}, VueDemi, VueUse, axios, changeCase$1, UniversalCookie, Drauu, VueUse, focusTrap, Fuse, jwt_decode, nprogress, QRCode);
|
package/index.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(v){if(!v.VueDemi){var n={},c=v.Vue;if(c)if(c.version.slice(0,2)==="2."){var
|
|
1
|
+
(function(v){if(!v.VueDemi){var n={},c=v.Vue;if(c)if(c.version.slice(0,2)==="2."){var j=v.VueCompositionAPI;if(j){for(var d in j)n[d]=j[d];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=c,n.Vue2=c,n.version=c.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if(c.version.slice(0,2)==="3."){for(var d in c)n[d]=c[d];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=c,n.Vue2=void 0,n.version=c.version,n.set=function(C,y,h){return Array.isArray(C)?(C.length=Math.max(C.length,y),C.splice(y,1,h),h):(C[y]=h,h)},n.del=function(C,y){if(Array.isArray(C)){C.splice(y,1);return}delete C[y]}}else console.error("[vue-demi] Vue version "+c.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");v.VueDemi=n}})(window),function(v,n,c,j,d,C,y,h,Y,Z,x,D,ee){"use strict";function V(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var k=V(j),N=V(C),te=V(Z),re=V(x),P=V(D),ne=V(ee),ae=Object.defineProperty,oe=Object.defineProperties,le=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,U=(t,r,e)=>r in t?ae(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,H=(t,r)=>{for(var e in r||(r={}))se.call(r,e)&&U(t,e,r[e]);if(T)for(var e of T(r))ue.call(r,e)&&U(t,e,r[e]);return t},G=(t,r)=>oe(t,le(r));function fe(...t){const r=typeof t[0]=="string"?t[0]:void 0,e=r?1:0;let a={},s=k.default,f={immediate:!!e};t.length>0+e&&("request"in t[0+e]?s=t[0+e]:a=t[0+e]),t.length>1+e&&"request"in t[1+e]&&(s=t[1+e]),(t.length===2+e&&!("request"in t[1+e])||t.length===3+e)&&(f=t[t.length-1]);const p=n.shallowRef(),u=n.shallowRef(),o=n.ref(!1),i=n.ref(!1),_=n.ref(!1),m=n.shallowRef(),w=k.default.CancelToken.source(),E=O=>{o.value||!i.value||(w.cancel(O),_.value=!0,i.value=!1,o.value=!1)},R=O=>{i.value=O,o.value=!O},F=(O=r,g={})=>{let b="",S;typeof O=="string"&&(b=O),S=g,R(!0),s(b,G(H(H({},a),S),{cancelToken:w.token})).then(l=>{p.value=l,u.value=l.data}).catch(l=>{m.value=l}).finally(()=>{R(!1)})};f.immediate&&r&&F();const $={response:p,data:u,error:m,finished:o,loading:i,isFinished:o,isLoading:i,cancel:E,canceled:_,aborted:_,abort:E,execute:F};function I(){return new Promise((O,g)=>{c.until(o).toBe(!0).then(()=>O($)).catch(b=>g(b))})}return G(H({},$),{then(O,g){return I().then(O,g)}})}var ce=Object.freeze({__proto__:null,camelCase:d.camelCase,capitalCase:d.capitalCase,constantCase:d.constantCase,dotCase:d.dotCase,headerCase:d.headerCase,noCase:d.noCase,paramCase:d.paramCase,pascalCase:d.pascalCase,pathCase:d.pathCase,sentenceCase:d.sentenceCase,snakeCase:d.snakeCase});function ie(t,r,e){const a=n.ref(t);return n.computed({get(){return ce[r](a.value,e)},set(s){a.value=s}})}var de=Object.defineProperty,Q=Object.getOwnPropertySymbols,ve=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,J=(t,r,e)=>r in t?de(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,q=(t,r)=>{for(var e in r||(r={}))ve.call(r,e)&&J(t,e,r[e]);if(Q)for(var e of Q(r))pe.call(r,e)&&J(t,e,r[e]);return t};function _e(t){const r=new N.default(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 N.default){const s=e?[...t||[]]:t;let f=a.getAll({doNotParse:!0});const p=n.ref(0),u=()=>{const o=a.getAll({doNotParse:!0});he(s||null,o,f)&&p.value++,f=o};return a.addChangeListener(u),c.tryOnScopeDispose(()=>{a.removeChangeListener(u)}),{get:(...o)=>(e&&s&&!s.includes(o[0])&&s.push(o[0]),p.value,a.get(o[0],q({doNotParse:r},o[1]))),getAll:(...o)=>(p.value,a.getAll(q({doNotParse:r},o[0]))),set:(...o)=>a.set(...o),remove:(...o)=>a.remove(...o),addChangeListener:(...o)=>a.addChangeListener(...o),removeChangeListener:(...o)=>a.removeChangeListener(...o)}}function he(t,r,e){if(!t)return!0;for(const a of t)if(r[a]!==e[a])return!0;return!1}var Oe=Object.defineProperty,M=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,W=(t,r,e)=>r in t?Oe(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,we=(t,r)=>{for(var e in r||(r={}))Ce.call(r,e)&&W(t,e,r[e]);if(M)for(var e of M(r))Pe.call(r,e)&&W(t,e,r[e]);return t};function ye(t,r){const e=n.ref();let a=[];const s=h.createEventHook(),f=h.createEventHook(),p=h.createEventHook(),u=h.createEventHook(),o=h.createEventHook(),i=n.ref(!1),_=n.ref(!1),m=n.ref(!1),w=n.ref(!1),E=n.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw"});n.watch(E,()=>{const l=e.value;l&&(l.brush=E.value)},{deep:!0});const R=()=>{var l;return(l=e.value)==null?void 0:l.undo()},F=()=>{var l;return(l=e.value)==null?void 0:l.redo()},$=()=>{var l;return(l=e.value)==null?void 0:l.clear()},I=()=>{var l;return(l=e.value)==null?void 0:l.cancel()},O=l=>{var L;return(L=e.value)==null?void 0:L.load(l)},g=()=>{var l;return(l=e.value)==null?void 0:l.dump()},b=()=>{var l;a.forEach(L=>L()),(l=e.value)==null||l.unmount()},S=()=>{e.value&&(i.value=e.value.canUndo(),_.value=e.value.canRedo(),m.value=e.value.altPressed,w.value=e.value.shiftPressed)};return n.watch(()=>h.unrefElement(t),l=>{!l||typeof SVGSVGElement=="undefined"||!(l instanceof SVGSVGElement)||(e.value&&b(),e.value=y.createDrauu(we({el:l},r)),S(),a=[e.value.on("canceled",()=>f.trigger()),e.value.on("committed",()=>p.trigger()),e.value.on("start",()=>u.trigger()),e.value.on("end",()=>o.trigger()),e.value.on("changed",()=>{S(),s.trigger()})])},{flush:"post"}),c.tryOnScopeDispose(()=>b()),{drauuInstance:e,load:O,dump:g,clear:$,cancel:I,undo:R,redo:F,canUndo:i,canRedo:_,brush:E,onChanged:s.on,onCommitted:p.on,onStart:u.on,onEnd:o.on,onCanceled:f.on}}var me=Object.defineProperty,ge=Object.defineProperties,be=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,X=(t,r,e)=>r in t?me(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Ve=(t,r)=>{for(var e in r||(r={}))B.call(r,e)&&X(t,e,r[e]);if(A)for(var e of A(r))K.call(r,e)&&X(t,e,r[e]);return t},Ee=(t,r)=>ge(t,be(r)),Se=(t,r)=>{var e={};for(var a in t)B.call(t,a)&&r.indexOf(a)<0&&(e[a]=t[a]);if(t!=null&&A)for(var a of A(t))r.indexOf(a)<0&&K.call(t,a)&&(e[a]=t[a]);return e};function je(t,r={}){let e;const a=r,{immediate:s}=a,f=Se(a,["immediate"]),p=n.ref(!1),u=n.ref(!1),o=w=>e&&e.activate(w),i=w=>e&&e.deactivate(w),_=()=>{e&&(e.pause(),u.value=!0)},m=()=>{e&&(e.unpause(),u.value=!1)};return n.watch(()=>h.unrefElement(t),w=>{!w||(e=Y.createFocusTrap(w,Ee(Ve({},f),{onActivate(){p.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){p.value=!1,r.onDeactivate&&r.onDeactivate()}})),s&&o())},{flush:"post"}),h.tryOnScopeDispose(()=>i()),{hasFocus:p,isPaused:u,activate:o,deactivate:i,pause:_,unpause:m}}function Ae(t,r,e){var a;const s=(u,o)=>{var i;const _=o;return new te.default((i=n.unref(u))!=null?i:[],_)},f=n.ref(s(r,(a=n.unref(e))==null?void 0:a.fuseOptions));return n.watch(()=>{var u;return(u=n.unref(e))==null?void 0:u.fuseOptions},u=>{f.value=s(r,u)},{deep:!0}),n.watch(()=>n.unref(r),u=>{f.value.setCollection(u)},{deep:!0}),{results:n.computed(()=>{var u,o;if(((u=n.unref(e))==null?void 0:u.matchAllWhenSearchEmpty)&&!n.unref(t))return n.unref(r).map((_,m)=>({item:_,refIndex:m}));const i=(o=n.unref(e))==null?void 0:o.resultLimit;return f.value.search(n.unref(t),i?{limit:i}:void 0)})}}function Re(t,r={}){const e=n.ref(t),{onError:a,fallbackValue:s=null}=r,f=(o,i)=>{try{return re.default(o,i)}catch(_){return a==null||a(_),s}},p=n.computed(()=>f(e.value,{header:!0})),u=n.computed(()=>f(e.value));return{header:p,payload:u}}function Fe(t=null,r){const e=n.isRef(t)?t:n.ref(t),a=n.computed({set:f=>f?P.default.start():P.default.done(),get:()=>c.isNumber(e.value)&&e.value<1});r&&P.default.configure(r);const s=P.default.set;return P.default.set=f=>(e.value=f,s.call(P.default,f)),n.watchEffect(()=>{c.isNumber(e.value)&&s.call(P.default,e.value)}),c.tryOnScopeDispose(P.default.remove),{isLoading:a,progress:e,start:P.default.start,done:P.default.done,remove:()=>{e.value=null,P.default.remove()}}}function $e(t,r){const e=n.ref(t),a=n.ref("");return n.watch(e,async s=>{e.value&&c.isClient&&(a.value=await ne.default.toDataURL(s,r))},{immediate:!0}),a}v.createCookies=_e,v.useAxios=fe,v.useChangeCase=ie,v.useCookies=z,v.useDrauu=ye,v.useFocusTrap=je,v.useFuse=Ae,v.useJwt=Re,v.useNProgress=Fe,v.useQRCode=$e,Object.defineProperty(v,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,VueUse,axios,changeCase$1,UniversalCookie,Drauu,VueUse,focusTrap,Fuse,jwt_decode,nprogress,QRCode);
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { shallowRef, ref, watch, unref,
|
|
1
|
+
import { shallowRef, ref, computed, watch, unref, isRef, watchEffect } from 'vue-demi';
|
|
2
2
|
import { until, tryOnScopeDispose, isNumber, isClient } from '@vueuse/shared';
|
|
3
3
|
import axios from 'axios';
|
|
4
|
+
import { camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase } from 'change-case';
|
|
4
5
|
import Cookie from 'universal-cookie';
|
|
5
6
|
import { createDrauu } from 'drauu';
|
|
6
7
|
import { createEventHook, unrefElement, tryOnScopeDispose as tryOnScopeDispose$1 } from '@vueuse/core';
|
|
@@ -29,21 +30,23 @@ var __spreadValues$3 = (a, b) => {
|
|
|
29
30
|
return a;
|
|
30
31
|
};
|
|
31
32
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
32
|
-
function useAxios(
|
|
33
|
+
function useAxios(...args) {
|
|
34
|
+
const url = typeof args[0] === "string" ? args[0] : void 0;
|
|
35
|
+
const argsPlaceholder = url ? 1 : 0;
|
|
33
36
|
let defaultConfig = {};
|
|
34
37
|
let instance = axios;
|
|
35
|
-
let options = { immediate:
|
|
36
|
-
if (args.length > 0) {
|
|
37
|
-
if ("request" in args[0])
|
|
38
|
-
instance = args[0];
|
|
38
|
+
let options = { immediate: !!argsPlaceholder };
|
|
39
|
+
if (args.length > 0 + argsPlaceholder) {
|
|
40
|
+
if ("request" in args[0 + argsPlaceholder])
|
|
41
|
+
instance = args[0 + argsPlaceholder];
|
|
39
42
|
else
|
|
40
|
-
defaultConfig = args[0];
|
|
43
|
+
defaultConfig = args[0 + argsPlaceholder];
|
|
41
44
|
}
|
|
42
|
-
if (args.length > 1) {
|
|
43
|
-
if ("request" in args[1])
|
|
44
|
-
instance = args[1];
|
|
45
|
+
if (args.length > 1 + argsPlaceholder) {
|
|
46
|
+
if ("request" in args[1 + argsPlaceholder])
|
|
47
|
+
instance = args[1 + argsPlaceholder];
|
|
45
48
|
}
|
|
46
|
-
if (args.length === 2 && !("request" in args[1]) || args.length === 3)
|
|
49
|
+
if (args.length === 2 + argsPlaceholder && !("request" in args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
|
|
47
50
|
options = args[args.length - 1];
|
|
48
51
|
const response = shallowRef();
|
|
49
52
|
const data = shallowRef();
|
|
@@ -64,9 +67,17 @@ function useAxios(url, ...args) {
|
|
|
64
67
|
isLoading.value = loading2;
|
|
65
68
|
isFinished.value = !loading2;
|
|
66
69
|
};
|
|
67
|
-
const execute = (config = {}) => {
|
|
70
|
+
const execute = (executeUrl = url, config = {}) => {
|
|
71
|
+
let _url = "";
|
|
72
|
+
let _config;
|
|
73
|
+
if (typeof executeUrl === "string") {
|
|
74
|
+
_url = executeUrl;
|
|
75
|
+
_config = config;
|
|
76
|
+
} else {
|
|
77
|
+
_config = config;
|
|
78
|
+
}
|
|
68
79
|
loading(true);
|
|
69
|
-
instance(
|
|
80
|
+
instance(_url, __spreadProps$1(__spreadValues$3(__spreadValues$3({}, defaultConfig), _config), { cancelToken: cancelToken.token })).then((r) => {
|
|
70
81
|
response.value = r;
|
|
71
82
|
data.value = r.data;
|
|
72
83
|
}).catch((e) => {
|
|
@@ -75,7 +86,7 @@ function useAxios(url, ...args) {
|
|
|
75
86
|
loading(false);
|
|
76
87
|
});
|
|
77
88
|
};
|
|
78
|
-
if (options.immediate)
|
|
89
|
+
if (options.immediate && url)
|
|
79
90
|
execute();
|
|
80
91
|
const result = {
|
|
81
92
|
response,
|
|
@@ -103,6 +114,33 @@ function useAxios(url, ...args) {
|
|
|
103
114
|
});
|
|
104
115
|
}
|
|
105
116
|
|
|
117
|
+
var changeCase = /*#__PURE__*/Object.freeze({
|
|
118
|
+
__proto__: null,
|
|
119
|
+
camelCase: camelCase,
|
|
120
|
+
capitalCase: capitalCase,
|
|
121
|
+
constantCase: constantCase,
|
|
122
|
+
dotCase: dotCase,
|
|
123
|
+
headerCase: headerCase,
|
|
124
|
+
noCase: noCase,
|
|
125
|
+
paramCase: paramCase,
|
|
126
|
+
pascalCase: pascalCase,
|
|
127
|
+
pathCase: pathCase,
|
|
128
|
+
sentenceCase: sentenceCase,
|
|
129
|
+
snakeCase: snakeCase
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
function useChangeCase(input, type, options) {
|
|
133
|
+
const text = ref(input);
|
|
134
|
+
return computed({
|
|
135
|
+
get() {
|
|
136
|
+
return changeCase[type](text.value, options);
|
|
137
|
+
},
|
|
138
|
+
set(value) {
|
|
139
|
+
text.value = value;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
106
144
|
var __defProp$2 = Object.defineProperty;
|
|
107
145
|
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
108
146
|
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
@@ -451,4 +489,4 @@ function useQRCode(text, options) {
|
|
|
451
489
|
return result;
|
|
452
490
|
}
|
|
453
491
|
|
|
454
|
-
export { createCookies, useAxios, useCookies, useDrauu, useFocusTrap, useFuse, useJwt, useNProgress, useQRCode };
|
|
492
|
+
export { createCookies, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useJwt, useNProgress, useQRCode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/integrations",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "Integration wrappers for utility libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -12,14 +12,18 @@
|
|
|
12
12
|
"url": "https://github.com/vueuse/vueuse/issues"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
|
+
"author": "Anthony Fu <https://github.com/antfu>",
|
|
15
16
|
"repository": {
|
|
16
17
|
"type": "git",
|
|
17
18
|
"url": "git+https://github.com/vueuse/vueuse.git",
|
|
18
19
|
"directory": "packages/integrations"
|
|
19
20
|
},
|
|
20
21
|
"funding": "https://github.com/sponsors/antfu",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
22
|
+
"main": "./index.cjs",
|
|
23
|
+
"module": "./index.mjs",
|
|
24
|
+
"types": "./index.d.ts",
|
|
25
|
+
"unpkg": "./index.iife.min.js",
|
|
26
|
+
"jsdelivr": "./index.iife.min.js",
|
|
23
27
|
"exports": {
|
|
24
28
|
".": {
|
|
25
29
|
"import": "./index.mjs",
|
|
@@ -71,15 +75,17 @@
|
|
|
71
75
|
"import": "./useQRCode.mjs",
|
|
72
76
|
"require": "./useQRCode.cjs",
|
|
73
77
|
"types": "./useQRCode.d.ts"
|
|
78
|
+
},
|
|
79
|
+
"./useChangeCase": {
|
|
80
|
+
"import": "./useChangeCase.mjs",
|
|
81
|
+
"require": "./useChangeCase.cjs",
|
|
82
|
+
"types": "./useChangeCase.d.ts"
|
|
74
83
|
}
|
|
75
84
|
},
|
|
76
|
-
"
|
|
77
|
-
"jsdelivr": "./index.iife.min.js",
|
|
78
|
-
"module": "./index.mjs",
|
|
79
|
-
"unpkg": "./index.iife.min.js",
|
|
80
|
-
"types": "./index.d.ts",
|
|
85
|
+
"sideEffects": false,
|
|
81
86
|
"peerDependencies": {
|
|
82
87
|
"axios": "*",
|
|
88
|
+
"change-case": "*",
|
|
83
89
|
"drauu": "*",
|
|
84
90
|
"focus-trap": "*",
|
|
85
91
|
"fuse.js": "*",
|
|
@@ -115,14 +121,15 @@
|
|
|
115
121
|
}
|
|
116
122
|
},
|
|
117
123
|
"dependencies": {
|
|
118
|
-
"@vueuse/core": "8.0.
|
|
119
|
-
"@vueuse/shared": "8.0.
|
|
124
|
+
"@vueuse/core": "8.0.1",
|
|
125
|
+
"@vueuse/shared": "8.0.1",
|
|
120
126
|
"vue-demi": "*"
|
|
121
127
|
},
|
|
122
128
|
"devDependencies": {
|
|
123
129
|
"@types/nprogress": "^0.2.0",
|
|
124
130
|
"@types/qrcode": "^1.4.2",
|
|
125
|
-
"axios": "^0.26.
|
|
131
|
+
"axios": "^0.26.1",
|
|
132
|
+
"change-case": "^4.1.2",
|
|
126
133
|
"drauu": "^0.3.0",
|
|
127
134
|
"focus-trap": "^6.7.3",
|
|
128
135
|
"fuse.js": "^6.5.3",
|
package/useAxios.cjs
CHANGED
|
@@ -29,21 +29,23 @@ var __spreadValues = (a, b) => {
|
|
|
29
29
|
return a;
|
|
30
30
|
};
|
|
31
31
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
32
|
-
function useAxios(
|
|
32
|
+
function useAxios(...args) {
|
|
33
|
+
const url = typeof args[0] === "string" ? args[0] : void 0;
|
|
34
|
+
const argsPlaceholder = url ? 1 : 0;
|
|
33
35
|
let defaultConfig = {};
|
|
34
36
|
let instance = axios__default["default"];
|
|
35
|
-
let options = { immediate:
|
|
36
|
-
if (args.length > 0) {
|
|
37
|
-
if ("request" in args[0])
|
|
38
|
-
instance = args[0];
|
|
37
|
+
let options = { immediate: !!argsPlaceholder };
|
|
38
|
+
if (args.length > 0 + argsPlaceholder) {
|
|
39
|
+
if ("request" in args[0 + argsPlaceholder])
|
|
40
|
+
instance = args[0 + argsPlaceholder];
|
|
39
41
|
else
|
|
40
|
-
defaultConfig = args[0];
|
|
42
|
+
defaultConfig = args[0 + argsPlaceholder];
|
|
41
43
|
}
|
|
42
|
-
if (args.length > 1) {
|
|
43
|
-
if ("request" in args[1])
|
|
44
|
-
instance = args[1];
|
|
44
|
+
if (args.length > 1 + argsPlaceholder) {
|
|
45
|
+
if ("request" in args[1 + argsPlaceholder])
|
|
46
|
+
instance = args[1 + argsPlaceholder];
|
|
45
47
|
}
|
|
46
|
-
if (args.length === 2 && !("request" in args[1]) || args.length === 3)
|
|
48
|
+
if (args.length === 2 + argsPlaceholder && !("request" in args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
|
|
47
49
|
options = args[args.length - 1];
|
|
48
50
|
const response = vueDemi.shallowRef();
|
|
49
51
|
const data = vueDemi.shallowRef();
|
|
@@ -64,9 +66,17 @@ function useAxios(url, ...args) {
|
|
|
64
66
|
isLoading.value = loading2;
|
|
65
67
|
isFinished.value = !loading2;
|
|
66
68
|
};
|
|
67
|
-
const execute = (config = {}) => {
|
|
69
|
+
const execute = (executeUrl = url, config = {}) => {
|
|
70
|
+
let _url = "";
|
|
71
|
+
let _config;
|
|
72
|
+
if (typeof executeUrl === "string") {
|
|
73
|
+
_url = executeUrl;
|
|
74
|
+
_config = config;
|
|
75
|
+
} else {
|
|
76
|
+
_config = config;
|
|
77
|
+
}
|
|
68
78
|
loading(true);
|
|
69
|
-
instance(
|
|
79
|
+
instance(_url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig), _config), { cancelToken: cancelToken.token })).then((r) => {
|
|
70
80
|
response.value = r;
|
|
71
81
|
data.value = r.data;
|
|
72
82
|
}).catch((e) => {
|
|
@@ -75,7 +85,7 @@ function useAxios(url, ...args) {
|
|
|
75
85
|
loading(false);
|
|
76
86
|
});
|
|
77
87
|
};
|
|
78
|
-
if (options.immediate)
|
|
88
|
+
if (options.immediate && url)
|
|
79
89
|
execute();
|
|
80
90
|
const result = {
|
|
81
91
|
response,
|
package/useAxios.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Ref } from 'vue-demi';
|
|
1
|
+
import { ShallowRef, Ref } from 'vue-demi';
|
|
2
2
|
import { AxiosResponse, AxiosError, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
3
3
|
|
|
4
4
|
interface UseAxiosReturn<T> {
|
|
5
5
|
/**
|
|
6
6
|
* Axios Response
|
|
7
7
|
*/
|
|
8
|
-
response:
|
|
8
|
+
response: ShallowRef<AxiosResponse<T> | undefined>;
|
|
9
9
|
/**
|
|
10
10
|
* Axios response data
|
|
11
11
|
*/
|
|
@@ -25,26 +25,52 @@ interface UseAxiosReturn<T> {
|
|
|
25
25
|
/**
|
|
26
26
|
* Any errors that may have occurred
|
|
27
27
|
*/
|
|
28
|
-
error:
|
|
28
|
+
error: ShallowRef<AxiosError<T> | undefined>;
|
|
29
29
|
/**
|
|
30
30
|
* Aborts the current request
|
|
31
31
|
*/
|
|
32
32
|
abort: (message?: string | undefined) => void;
|
|
33
|
+
/**
|
|
34
|
+
* isFinished alias
|
|
35
|
+
*/
|
|
36
|
+
finished: Ref<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* loading alias
|
|
39
|
+
*/
|
|
40
|
+
loading: Ref<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* abort alias
|
|
43
|
+
*/
|
|
44
|
+
cancel: (message?: string | undefined) => void;
|
|
45
|
+
/**
|
|
46
|
+
* abort aborted
|
|
47
|
+
*/
|
|
48
|
+
canceled: Ref<boolean>;
|
|
49
|
+
}
|
|
50
|
+
interface StrictUseAxiosReturn<T> extends UseAxiosReturn<T> {
|
|
51
|
+
/**
|
|
52
|
+
* Manually call the axios request
|
|
53
|
+
*/
|
|
54
|
+
execute: (url?: string, config?: AxiosRequestConfig) => void;
|
|
55
|
+
}
|
|
56
|
+
interface EasyUseAxiosReturn<T> extends UseAxiosReturn<T> {
|
|
33
57
|
/**
|
|
34
58
|
* Manually call the axios request
|
|
35
59
|
*/
|
|
36
|
-
execute: (config?: AxiosRequestConfig) => void;
|
|
60
|
+
execute: (url: string, config?: AxiosRequestConfig) => void;
|
|
37
61
|
}
|
|
38
62
|
interface UseAxiosOptions {
|
|
39
63
|
/**
|
|
40
64
|
* Will automatically run axios request when `useAxios` is used
|
|
41
65
|
*
|
|
42
|
-
* @default true
|
|
43
66
|
*/
|
|
44
67
|
immediate?: boolean;
|
|
45
68
|
}
|
|
46
|
-
declare function useAxios<T = any>(url: string, config?: AxiosRequestConfig, options?: UseAxiosOptions):
|
|
47
|
-
declare function useAxios<T = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions):
|
|
48
|
-
declare function useAxios<T = any>(url: string, config: AxiosRequestConfig, instance: AxiosInstance, options?: UseAxiosOptions):
|
|
69
|
+
declare function useAxios<T = any>(url: string, config?: AxiosRequestConfig, options?: UseAxiosOptions): StrictUseAxiosReturn<T> & PromiseLike<StrictUseAxiosReturn<T>>;
|
|
70
|
+
declare function useAxios<T = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T> & PromiseLike<StrictUseAxiosReturn<T>>;
|
|
71
|
+
declare function useAxios<T = any>(url: string, config: AxiosRequestConfig, instance: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T> & PromiseLike<StrictUseAxiosReturn<T>>;
|
|
72
|
+
declare function useAxios<T = any>(config?: AxiosRequestConfig): EasyUseAxiosReturn<T> & PromiseLike<EasyUseAxiosReturn<T>>;
|
|
73
|
+
declare function useAxios<T = any>(instance?: AxiosInstance): EasyUseAxiosReturn<T> & PromiseLike<EasyUseAxiosReturn<T>>;
|
|
74
|
+
declare function useAxios<T = any>(config?: AxiosRequestConfig, instance?: AxiosInstance): EasyUseAxiosReturn<T> & PromiseLike<EasyUseAxiosReturn<T>>;
|
|
49
75
|
|
|
50
|
-
export { UseAxiosOptions, UseAxiosReturn, useAxios };
|
|
76
|
+
export { EasyUseAxiosReturn, StrictUseAxiosReturn, UseAxiosOptions, UseAxiosReturn, useAxios };
|
package/useAxios.iife.js
CHANGED
|
@@ -85,21 +85,23 @@
|
|
|
85
85
|
return a;
|
|
86
86
|
};
|
|
87
87
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
88
|
-
function useAxios(
|
|
88
|
+
function useAxios(...args) {
|
|
89
|
+
const url = typeof args[0] === "string" ? args[0] : void 0;
|
|
90
|
+
const argsPlaceholder = url ? 1 : 0;
|
|
89
91
|
let defaultConfig = {};
|
|
90
92
|
let instance = axios__default["default"];
|
|
91
|
-
let options = { immediate:
|
|
92
|
-
if (args.length > 0) {
|
|
93
|
-
if ("request" in args[0])
|
|
94
|
-
instance = args[0];
|
|
93
|
+
let options = { immediate: !!argsPlaceholder };
|
|
94
|
+
if (args.length > 0 + argsPlaceholder) {
|
|
95
|
+
if ("request" in args[0 + argsPlaceholder])
|
|
96
|
+
instance = args[0 + argsPlaceholder];
|
|
95
97
|
else
|
|
96
|
-
defaultConfig = args[0];
|
|
98
|
+
defaultConfig = args[0 + argsPlaceholder];
|
|
97
99
|
}
|
|
98
|
-
if (args.length > 1) {
|
|
99
|
-
if ("request" in args[1])
|
|
100
|
-
instance = args[1];
|
|
100
|
+
if (args.length > 1 + argsPlaceholder) {
|
|
101
|
+
if ("request" in args[1 + argsPlaceholder])
|
|
102
|
+
instance = args[1 + argsPlaceholder];
|
|
101
103
|
}
|
|
102
|
-
if (args.length === 2 && !("request" in args[1]) || args.length === 3)
|
|
104
|
+
if (args.length === 2 + argsPlaceholder && !("request" in args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
|
|
103
105
|
options = args[args.length - 1];
|
|
104
106
|
const response = vueDemi.shallowRef();
|
|
105
107
|
const data = vueDemi.shallowRef();
|
|
@@ -120,9 +122,17 @@
|
|
|
120
122
|
isLoading.value = loading2;
|
|
121
123
|
isFinished.value = !loading2;
|
|
122
124
|
};
|
|
123
|
-
const execute = (config = {}) => {
|
|
125
|
+
const execute = (executeUrl = url, config = {}) => {
|
|
126
|
+
let _url = "";
|
|
127
|
+
let _config;
|
|
128
|
+
if (typeof executeUrl === "string") {
|
|
129
|
+
_url = executeUrl;
|
|
130
|
+
_config = config;
|
|
131
|
+
} else {
|
|
132
|
+
_config = config;
|
|
133
|
+
}
|
|
124
134
|
loading(true);
|
|
125
|
-
instance(
|
|
135
|
+
instance(_url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig), _config), { cancelToken: cancelToken.token })).then((r) => {
|
|
126
136
|
response.value = r;
|
|
127
137
|
data.value = r.data;
|
|
128
138
|
}).catch((e) => {
|
|
@@ -131,7 +141,7 @@
|
|
|
131
141
|
loading(false);
|
|
132
142
|
});
|
|
133
143
|
};
|
|
134
|
-
if (options.immediate)
|
|
144
|
+
if (options.immediate && url)
|
|
135
145
|
execute();
|
|
136
146
|
const result = {
|
|
137
147
|
response,
|
package/useAxios.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(l){if(!l.VueDemi){var n={},o=l.Vue;if(o)if(o.version.slice(0,2)==="2."){var p=l.VueCompositionAPI;if(p){for(var a in p)n[a]=p[a];n.isVue2=!0,n.isVue3=!1,n.install=function(){},n.Vue=o,n.Vue2=o,n.version=o.version}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 a in o)n[a]=o[a];n.isVue2=!1,n.isVue3=!0,n.install=function(){},n.Vue=o,n.Vue2=void 0,n.version=o.version,n.set=function(i,u,f){return Array.isArray(i)?(i.length=Math.max(i.length,u),i.splice(u,1,f),f):(i[u]=f,f)},n.del=function(i,u){if(Array.isArray(i)){i.splice(u,1);return}delete i[u]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");l.VueDemi=n}})(window),function(l,n,o,p){"use strict";function a(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var i=a(p),u=Object.defineProperty,f=Object.defineProperties,F=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,I=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,b=(e,r,t)=>r in e?u(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,V=(e,r)=>{for(var t in r||(r={}))I.call(r,t)&&b(e,t,r[t]);if(O)for(var t of O(r))L.call(r,t)&&b(e,t,r[t]);return e},w=(e,r)=>f(e,F(r));function M(...e){const r=typeof e[0]=="string"?e[0]:void 0,t=r?1:0;let j={},m=i.default,A={immediate:!!t};e.length>0+t&&("request"in e[0+t]?m=e[0+t]:j=e[0+t]),e.length>1+t&&"request"in e[1+t]&&(m=e[1+t]),(e.length===2+t&&!("request"in e[1+t])||e.length===3+t)&&(A=e[e.length-1]);const x=n.shallowRef(),q=n.shallowRef(),c=n.ref(!1),v=n.ref(!1),P=n.ref(!1),R=n.shallowRef(),T=i.default.CancelToken.source(),U=s=>{c.value||!v.value||(T.cancel(s),P.value=!0,v.value=!1,c.value=!1)},C=s=>{v.value=s,c.value=!s},D=(s=r,d={})=>{let h="",y;typeof s=="string"&&(h=s),y=d,C(!0),m(h,w(V(V({},j),y),{cancelToken:T.token})).then(_=>{x.value=_,q.value=_.data}).catch(_=>{R.value=_}).finally(()=>{C(!1)})};A.immediate&&r&&D();const E={response:x,data:q,error:R,finished:c,loading:v,isFinished:c,isLoading:v,cancel:U,canceled:P,aborted:P,abort:U,execute:D};function S(){return new Promise((s,d)=>{o.until(c).toBe(!0).then(()=>s(E)).catch(h=>d(h))})}return w(V({},E),{then(s,d){return S().then(s,d)}})}l.useAxios=M,Object.defineProperty(l,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,VueUse,axios);
|
package/useAxios.mjs
CHANGED
|
@@ -21,21 +21,23 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
return a;
|
|
22
22
|
};
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
function useAxios(
|
|
24
|
+
function useAxios(...args) {
|
|
25
|
+
const url = typeof args[0] === "string" ? args[0] : void 0;
|
|
26
|
+
const argsPlaceholder = url ? 1 : 0;
|
|
25
27
|
let defaultConfig = {};
|
|
26
28
|
let instance = axios;
|
|
27
|
-
let options = { immediate:
|
|
28
|
-
if (args.length > 0) {
|
|
29
|
-
if ("request" in args[0])
|
|
30
|
-
instance = args[0];
|
|
29
|
+
let options = { immediate: !!argsPlaceholder };
|
|
30
|
+
if (args.length > 0 + argsPlaceholder) {
|
|
31
|
+
if ("request" in args[0 + argsPlaceholder])
|
|
32
|
+
instance = args[0 + argsPlaceholder];
|
|
31
33
|
else
|
|
32
|
-
defaultConfig = args[0];
|
|
34
|
+
defaultConfig = args[0 + argsPlaceholder];
|
|
33
35
|
}
|
|
34
|
-
if (args.length > 1) {
|
|
35
|
-
if ("request" in args[1])
|
|
36
|
-
instance = args[1];
|
|
36
|
+
if (args.length > 1 + argsPlaceholder) {
|
|
37
|
+
if ("request" in args[1 + argsPlaceholder])
|
|
38
|
+
instance = args[1 + argsPlaceholder];
|
|
37
39
|
}
|
|
38
|
-
if (args.length === 2 && !("request" in args[1]) || args.length === 3)
|
|
40
|
+
if (args.length === 2 + argsPlaceholder && !("request" in args[1 + argsPlaceholder]) || args.length === 3 + argsPlaceholder)
|
|
39
41
|
options = args[args.length - 1];
|
|
40
42
|
const response = shallowRef();
|
|
41
43
|
const data = shallowRef();
|
|
@@ -56,9 +58,17 @@ function useAxios(url, ...args) {
|
|
|
56
58
|
isLoading.value = loading2;
|
|
57
59
|
isFinished.value = !loading2;
|
|
58
60
|
};
|
|
59
|
-
const execute = (config = {}) => {
|
|
61
|
+
const execute = (executeUrl = url, config = {}) => {
|
|
62
|
+
let _url = "";
|
|
63
|
+
let _config;
|
|
64
|
+
if (typeof executeUrl === "string") {
|
|
65
|
+
_url = executeUrl;
|
|
66
|
+
_config = config;
|
|
67
|
+
} else {
|
|
68
|
+
_config = config;
|
|
69
|
+
}
|
|
60
70
|
loading(true);
|
|
61
|
-
instance(
|
|
71
|
+
instance(_url, __spreadProps(__spreadValues(__spreadValues({}, defaultConfig), _config), { cancelToken: cancelToken.token })).then((r) => {
|
|
62
72
|
response.value = r;
|
|
63
73
|
data.value = r.data;
|
|
64
74
|
}).catch((e) => {
|
|
@@ -67,7 +77,7 @@ function useAxios(url, ...args) {
|
|
|
67
77
|
loading(false);
|
|
68
78
|
});
|
|
69
79
|
};
|
|
70
|
-
if (options.immediate)
|
|
80
|
+
if (options.immediate && url)
|
|
71
81
|
execute();
|
|
72
82
|
const result = {
|
|
73
83
|
response,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var vueDemi = require('vue-demi');
|
|
6
|
+
var changeCase$1 = require('change-case');
|
|
7
|
+
|
|
8
|
+
var changeCase = /*#__PURE__*/Object.freeze({
|
|
9
|
+
__proto__: null,
|
|
10
|
+
camelCase: changeCase$1.camelCase,
|
|
11
|
+
capitalCase: changeCase$1.capitalCase,
|
|
12
|
+
constantCase: changeCase$1.constantCase,
|
|
13
|
+
dotCase: changeCase$1.dotCase,
|
|
14
|
+
headerCase: changeCase$1.headerCase,
|
|
15
|
+
noCase: changeCase$1.noCase,
|
|
16
|
+
paramCase: changeCase$1.paramCase,
|
|
17
|
+
pascalCase: changeCase$1.pascalCase,
|
|
18
|
+
pathCase: changeCase$1.pathCase,
|
|
19
|
+
sentenceCase: changeCase$1.sentenceCase,
|
|
20
|
+
snakeCase: changeCase$1.snakeCase
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function useChangeCase(input, type, options) {
|
|
24
|
+
const text = vueDemi.ref(input);
|
|
25
|
+
return vueDemi.computed({
|
|
26
|
+
get() {
|
|
27
|
+
return changeCase[type](text.value, options);
|
|
28
|
+
},
|
|
29
|
+
set(value) {
|
|
30
|
+
text.value = value;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.useChangeCase = useChangeCase;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase, Options } from 'change-case';
|
|
2
|
+
import { MaybeRef } from '@vueuse/shared';
|
|
3
|
+
import { WritableComputedRef } from 'vue-demi';
|
|
4
|
+
|
|
5
|
+
declare const changeCase_camelCase: typeof camelCase;
|
|
6
|
+
declare const changeCase_capitalCase: typeof capitalCase;
|
|
7
|
+
declare const changeCase_constantCase: typeof constantCase;
|
|
8
|
+
declare const changeCase_dotCase: typeof dotCase;
|
|
9
|
+
declare const changeCase_headerCase: typeof headerCase;
|
|
10
|
+
declare const changeCase_noCase: typeof noCase;
|
|
11
|
+
declare const changeCase_paramCase: typeof paramCase;
|
|
12
|
+
declare const changeCase_pascalCase: typeof pascalCase;
|
|
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 {
|
|
18
|
+
changeCase_camelCase as camelCase,
|
|
19
|
+
changeCase_capitalCase as capitalCase,
|
|
20
|
+
changeCase_constantCase as constantCase,
|
|
21
|
+
changeCase_dotCase as dotCase,
|
|
22
|
+
changeCase_headerCase as headerCase,
|
|
23
|
+
changeCase_noCase as noCase,
|
|
24
|
+
changeCase_paramCase as paramCase,
|
|
25
|
+
changeCase_pascalCase as pascalCase,
|
|
26
|
+
changeCase_pathCase as pathCase,
|
|
27
|
+
changeCase_sentenceCase as sentenceCase,
|
|
28
|
+
changeCase_snakeCase as snakeCase,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare type ChangeCaseType = keyof typeof changeCase;
|
|
33
|
+
declare function useChangeCase(input: MaybeRef<string>, type: ChangeCaseType, options?: Options | undefined): WritableComputedRef<string>;
|
|
34
|
+
|
|
35
|
+
export { ChangeCaseType, useChangeCase };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
;(function (window) {
|
|
2
|
+
if (window.VueDemi) {
|
|
3
|
+
return
|
|
4
|
+
}
|
|
5
|
+
var VueDemi = {}
|
|
6
|
+
var Vue = window.Vue
|
|
7
|
+
if (Vue) {
|
|
8
|
+
if (Vue.version.slice(0, 2) === '2.') {
|
|
9
|
+
var VueCompositionAPI = window.VueCompositionAPI
|
|
10
|
+
if (VueCompositionAPI) {
|
|
11
|
+
for (var key in VueCompositionAPI) {
|
|
12
|
+
VueDemi[key] = VueCompositionAPI[key]
|
|
13
|
+
}
|
|
14
|
+
VueDemi.isVue2 = true
|
|
15
|
+
VueDemi.isVue3 = false
|
|
16
|
+
VueDemi.install = function (){}
|
|
17
|
+
VueDemi.Vue = Vue
|
|
18
|
+
VueDemi.Vue2 = Vue
|
|
19
|
+
VueDemi.version = Vue.version
|
|
20
|
+
} else {
|
|
21
|
+
console.error(
|
|
22
|
+
'[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.'
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
} else if (Vue.version.slice(0, 2) === '3.') {
|
|
26
|
+
for (var key in Vue) {
|
|
27
|
+
VueDemi[key] = Vue[key]
|
|
28
|
+
}
|
|
29
|
+
VueDemi.isVue2 = false
|
|
30
|
+
VueDemi.isVue3 = true
|
|
31
|
+
VueDemi.install = function (){}
|
|
32
|
+
VueDemi.Vue = Vue
|
|
33
|
+
VueDemi.Vue2 = undefined
|
|
34
|
+
VueDemi.version = Vue.version
|
|
35
|
+
VueDemi.set = function(target, key, val) {
|
|
36
|
+
if (Array.isArray(target)) {
|
|
37
|
+
target.length = Math.max(target.length, key)
|
|
38
|
+
target.splice(key, 1, val)
|
|
39
|
+
return val
|
|
40
|
+
}
|
|
41
|
+
target[key] = val
|
|
42
|
+
return val
|
|
43
|
+
}
|
|
44
|
+
VueDemi.del = function(target, key) {
|
|
45
|
+
if (Array.isArray(target)) {
|
|
46
|
+
target.splice(key, 1)
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
delete target[key]
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
console.error('[vue-demi] Vue version ' + Vue.version + ' is unsupported.')
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
console.error(
|
|
56
|
+
'[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.'
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
window.VueDemi = VueDemi
|
|
60
|
+
})(window)
|
|
61
|
+
;
|
|
62
|
+
;(function (exports, vueDemi, changeCase$1) {
|
|
63
|
+
'use strict';
|
|
64
|
+
|
|
65
|
+
var changeCase = /*#__PURE__*/Object.freeze({
|
|
66
|
+
__proto__: null,
|
|
67
|
+
camelCase: changeCase$1.camelCase,
|
|
68
|
+
capitalCase: changeCase$1.capitalCase,
|
|
69
|
+
constantCase: changeCase$1.constantCase,
|
|
70
|
+
dotCase: changeCase$1.dotCase,
|
|
71
|
+
headerCase: changeCase$1.headerCase,
|
|
72
|
+
noCase: changeCase$1.noCase,
|
|
73
|
+
paramCase: changeCase$1.paramCase,
|
|
74
|
+
pascalCase: changeCase$1.pascalCase,
|
|
75
|
+
pathCase: changeCase$1.pathCase,
|
|
76
|
+
sentenceCase: changeCase$1.sentenceCase,
|
|
77
|
+
snakeCase: changeCase$1.snakeCase
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
function useChangeCase(input, type, options) {
|
|
81
|
+
const text = vueDemi.ref(input);
|
|
82
|
+
return vueDemi.computed({
|
|
83
|
+
get() {
|
|
84
|
+
return changeCase[type](text.value, options);
|
|
85
|
+
},
|
|
86
|
+
set(value) {
|
|
87
|
+
text.value = value;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
exports.useChangeCase = useChangeCase;
|
|
93
|
+
|
|
94
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
95
|
+
|
|
96
|
+
})(this.VueUse = this.VueUse || {}, VueDemi, changeCase$1);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(n){if(!n.VueDemi){var s={},e=n.Vue;if(e)if(e.version.slice(0,2)==="2."){var a=n.VueCompositionAPI;if(a){for(var u in a)s[u]=a[u];s.isVue2=!0,s.isVue3=!1,s.install=function(){},s.Vue=e,s.Vue2=e,s.version=e.version}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 u in e)s[u]=e[u];s.isVue2=!1,s.isVue3=!0,s.install=function(){},s.Vue=e,s.Vue2=void 0,s.version=e.version,s.set=function(r,i,o){return Array.isArray(r)?(r.length=Math.max(r.length,i),r.splice(i,1,o),o):(r[i]=o,o)},s.del=function(r,i){if(Array.isArray(r)){r.splice(i,1);return}delete r[i]}}else console.error("[vue-demi] Vue version "+e.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");n.VueDemi=s}})(window),function(n,s,e){"use strict";var a=Object.freeze({__proto__:null,camelCase:e.camelCase,capitalCase:e.capitalCase,constantCase:e.constantCase,dotCase:e.dotCase,headerCase:e.headerCase,noCase:e.noCase,paramCase:e.paramCase,pascalCase:e.pascalCase,pathCase:e.pathCase,sentenceCase:e.sentenceCase,snakeCase:e.snakeCase});function u(r,i,o){const t=s.ref(r);return s.computed({get(){return a[i](t.value,o)},set(l){t.value=l}})}n.useChangeCase=u,Object.defineProperty(n,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueDemi,changeCase$1);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ref, computed } from 'vue-demi';
|
|
2
|
+
import { camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase } from 'change-case';
|
|
3
|
+
|
|
4
|
+
var changeCase = /*#__PURE__*/Object.freeze({
|
|
5
|
+
__proto__: null,
|
|
6
|
+
camelCase: camelCase,
|
|
7
|
+
capitalCase: capitalCase,
|
|
8
|
+
constantCase: constantCase,
|
|
9
|
+
dotCase: dotCase,
|
|
10
|
+
headerCase: headerCase,
|
|
11
|
+
noCase: noCase,
|
|
12
|
+
paramCase: paramCase,
|
|
13
|
+
pascalCase: pascalCase,
|
|
14
|
+
pathCase: pathCase,
|
|
15
|
+
sentenceCase: sentenceCase,
|
|
16
|
+
snakeCase: snakeCase
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function useChangeCase(input, type, options) {
|
|
20
|
+
const text = ref(input);
|
|
21
|
+
return computed({
|
|
22
|
+
get() {
|
|
23
|
+
return changeCase[type](text.value, options);
|
|
24
|
+
},
|
|
25
|
+
set(value) {
|
|
26
|
+
text.value = value;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { useChangeCase };
|