@vueuse/integrations 6.3.3 → 6.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/index.cjs +409 -311
- package/index.d.ts +45 -5
- package/index.iife.js +408 -313
- package/index.iife.min.js +1 -1
- package/index.mjs +408 -313
- package/package.json +19 -5
- package/useAxios.cjs +69 -65
- package/useAxios.d.ts +1 -1
- package/useAxios.iife.js +70 -66
- package/useAxios.iife.min.js +1 -1
- package/useAxios.mjs +69 -65
- package/useCookies.cjs +59 -71
- package/useCookies.iife.js +60 -72
- package/useCookies.iife.min.js +1 -1
- package/useCookies.mjs +59 -71
- package/useDrauu.cjs +127 -0
- package/useDrauu.d.ts +32 -0
- package/useDrauu.iife.js +186 -0
- package/useDrauu.iife.min.js +1 -0
- package/useDrauu.mjs +123 -0
- package/useFocusTrap/component.cjs +31 -0
- package/useFocusTrap/component.d.ts +6 -0
- package/useFocusTrap/component.mjs +27 -0
- package/useFocusTrap.cjs +78 -104
- package/useFocusTrap.iife.js +83 -109
- package/useFocusTrap.iife.min.js +1 -1
- package/useFocusTrap.mjs +79 -105
- package/useFuse.cjs +41 -0
- package/useFuse.d.ts +16 -0
- package/useFuse.iife.js +102 -0
- package/useFuse.iife.min.js +1 -0
- package/useFuse.mjs +33 -0
- package/useJwt.cjs +20 -24
- package/useJwt.iife.js +21 -25
- package/useJwt.iife.min.js +1 -1
- package/useJwt.mjs +20 -24
- package/useNProgress.cjs +28 -37
- package/useNProgress.iife.js +29 -38
- package/useNProgress.iife.min.js +1 -1
- package/useNProgress.mjs +28 -37
- package/useQRCode.cjs +8 -15
- package/useQRCode.iife.js +9 -16
- package/useQRCode.iife.min.js +1 -1
- package/useQRCode.mjs +8 -15
package/useFocusTrap.iife.js
CHANGED
|
@@ -59,116 +59,90 @@
|
|
|
59
59
|
window.VueDemi = VueDemi
|
|
60
60
|
})(window)
|
|
61
61
|
;
|
|
62
|
-
;(function (exports,
|
|
63
|
-
|
|
62
|
+
;(function (exports, core, vueDemi, focusTrap) {
|
|
63
|
+
'use strict';
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
hasFocus.value = true;
|
|
144
|
-
// Apply if user provided onActivate option
|
|
145
|
-
if (options.onActivate)
|
|
146
|
-
options.onActivate();
|
|
147
|
-
},
|
|
148
|
-
onDeactivate() {
|
|
149
|
-
hasFocus.value = false;
|
|
150
|
-
// Apply if user provided onDeactivate option
|
|
151
|
-
if (options.onDeactivate)
|
|
152
|
-
options.onDeactivate();
|
|
153
|
-
} }));
|
|
154
|
-
// Focus if immediate is set to true
|
|
155
|
-
if (immediate)
|
|
156
|
-
activate();
|
|
157
|
-
}, { flush: 'post' });
|
|
158
|
-
// Cleanup on unmount
|
|
159
|
-
shared.tryOnScopeDispose(() => deactivate());
|
|
160
|
-
return {
|
|
161
|
-
hasFocus,
|
|
162
|
-
isPaused,
|
|
163
|
-
activate,
|
|
164
|
-
deactivate,
|
|
165
|
-
pause,
|
|
166
|
-
unpause,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
65
|
+
var __defProp = Object.defineProperty;
|
|
66
|
+
var __defProps = Object.defineProperties;
|
|
67
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
68
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
69
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
70
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
71
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
72
|
+
var __spreadValues = (a, b) => {
|
|
73
|
+
for (var prop in b || (b = {}))
|
|
74
|
+
if (__hasOwnProp.call(b, prop))
|
|
75
|
+
__defNormalProp(a, prop, b[prop]);
|
|
76
|
+
if (__getOwnPropSymbols)
|
|
77
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
78
|
+
if (__propIsEnum.call(b, prop))
|
|
79
|
+
__defNormalProp(a, prop, b[prop]);
|
|
80
|
+
}
|
|
81
|
+
return a;
|
|
82
|
+
};
|
|
83
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
84
|
+
var __objRest = (source, exclude) => {
|
|
85
|
+
var target = {};
|
|
86
|
+
for (var prop in source)
|
|
87
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
88
|
+
target[prop] = source[prop];
|
|
89
|
+
if (source != null && __getOwnPropSymbols)
|
|
90
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
91
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
92
|
+
target[prop] = source[prop];
|
|
93
|
+
}
|
|
94
|
+
return target;
|
|
95
|
+
};
|
|
96
|
+
function useFocusTrap(target, options = {}) {
|
|
97
|
+
let trap;
|
|
98
|
+
const _a = options, { immediate } = _a, focusTrapOptions = __objRest(_a, ["immediate"]);
|
|
99
|
+
const hasFocus = vueDemi.ref(false);
|
|
100
|
+
const isPaused = vueDemi.ref(false);
|
|
101
|
+
const activate = (opts) => trap && trap.activate(opts);
|
|
102
|
+
const deactivate = (opts) => trap && trap.deactivate(opts);
|
|
103
|
+
const pause = () => {
|
|
104
|
+
if (trap) {
|
|
105
|
+
trap.pause();
|
|
106
|
+
isPaused.value = true;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const unpause = () => {
|
|
110
|
+
if (trap) {
|
|
111
|
+
trap.unpause();
|
|
112
|
+
isPaused.value = false;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
vueDemi.watch(() => core.unrefElement(target), (el) => {
|
|
116
|
+
if (!el)
|
|
117
|
+
return;
|
|
118
|
+
trap = focusTrap.createFocusTrap(el, __spreadProps(__spreadValues({}, focusTrapOptions), {
|
|
119
|
+
onActivate() {
|
|
120
|
+
hasFocus.value = true;
|
|
121
|
+
if (options.onActivate)
|
|
122
|
+
options.onActivate();
|
|
123
|
+
},
|
|
124
|
+
onDeactivate() {
|
|
125
|
+
hasFocus.value = false;
|
|
126
|
+
if (options.onDeactivate)
|
|
127
|
+
options.onDeactivate();
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
if (immediate)
|
|
131
|
+
activate();
|
|
132
|
+
}, { flush: "post" });
|
|
133
|
+
core.tryOnScopeDispose(() => deactivate());
|
|
134
|
+
return {
|
|
135
|
+
hasFocus,
|
|
136
|
+
isPaused,
|
|
137
|
+
activate,
|
|
138
|
+
deactivate,
|
|
139
|
+
pause,
|
|
140
|
+
unpause
|
|
141
|
+
};
|
|
142
|
+
}
|
|
169
143
|
|
|
170
|
-
|
|
144
|
+
exports.useFocusTrap = useFocusTrap;
|
|
171
145
|
|
|
172
|
-
|
|
146
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
173
147
|
|
|
174
|
-
}(this.VueUse = this.VueUse || {},
|
|
148
|
+
})(this.VueUse = this.VueUse || {}, VueUse, VueDemi, focusTrap);
|
package/useFocusTrap.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(f){if(!f.VueDemi){var i={},s=f.Vue;if(s)if(s.version.slice(0,2)==="2."){var v=f.VueCompositionAPI;if(v){for(var c in v)i[c]=v[c];i.isVue2=!0,i.isVue3=!1,i.install=function(){},i.Vue=s,i.Vue2=s,i.version=s.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.")}else if(s.version.slice(0,2)==="3."){for(var c in s)i[c]=s[c];i.isVue2=!1,i.isVue3=!0,i.install=function(){},i.Vue=s,i.Vue2=void 0,i.version=s.version,i.set=function(a,o,u){return Array.isArray(a)?(a.length=Math.max(a.length,o),a.splice(o,1,u),u):(a[o]=u,u)},i.del=function(a,o){if(Array.isArray(a)){a.splice(o,1);return}delete a[o]}}else console.error("[vue-demi] Vue version "+s.version+" is unsupported.");else console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.");f.VueDemi=i}})(window),function(f,i,s,v){"use strict";var c=Object.defineProperty,a=Object.defineProperties,o=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,V=(t,r,e)=>r in t?c(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,b=(t,r)=>{for(var e in r||(r={}))_.call(r,e)&&V(t,e,r[e]);if(u)for(var e of u(r))m.call(r,e)&&V(t,e,r[e]);return t},h=(t,r)=>a(t,o(r)),y=(t,r)=>{var e={};for(var n in t)_.call(t,n)&&r.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&u)for(var n of u(t))r.indexOf(n)<0&&m.call(t,n)&&(e[n]=t[n]);return e};function D(t,r={}){let e;const n=r,{immediate:A}=n,j=y(n,["immediate"]),p=s.ref(!1),d=s.ref(!1),O=l=>e&&e.activate(l),P=l=>e&&e.deactivate(l),T=()=>{e&&(e.pause(),d.value=!0)},w=()=>{e&&(e.unpause(),d.value=!1)};return s.watch(()=>i.unrefElement(t),l=>{!l||(e=v.createFocusTrap(l,h(b({},j),{onActivate(){p.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){p.value=!1,r.onDeactivate&&r.onDeactivate()}})),A&&O())},{flush:"post"}),i.tryOnScopeDispose(()=>P()),{hasFocus:p,isPaused:d,activate:O,deactivate:P,pause:T,unpause:w}}f.useFocusTrap=D,Object.defineProperty(f,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},VueUse,VueDemi,focusTrap);
|
package/useFocusTrap.mjs
CHANGED
|
@@ -1,110 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { unrefElement, tryOnScopeDispose } from '@vueuse/core';
|
|
2
|
+
import { ref, watch } from 'vue-demi';
|
|
3
3
|
import { createFocusTrap } from 'focus-trap';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
trap = createFocusTrap(el, Object.assign(Object.assign({}, focusTrapOptions), { onActivate() {
|
|
83
|
-
hasFocus.value = true;
|
|
84
|
-
// Apply if user provided onActivate option
|
|
85
|
-
if (options.onActivate)
|
|
86
|
-
options.onActivate();
|
|
87
|
-
},
|
|
88
|
-
onDeactivate() {
|
|
89
|
-
hasFocus.value = false;
|
|
90
|
-
// Apply if user provided onDeactivate option
|
|
91
|
-
if (options.onDeactivate)
|
|
92
|
-
options.onDeactivate();
|
|
93
|
-
} }));
|
|
94
|
-
// Focus if immediate is set to true
|
|
95
|
-
if (immediate)
|
|
96
|
-
activate();
|
|
97
|
-
}, { flush: 'post' });
|
|
98
|
-
// Cleanup on unmount
|
|
99
|
-
tryOnScopeDispose(() => deactivate());
|
|
100
|
-
return {
|
|
101
|
-
hasFocus,
|
|
102
|
-
isPaused,
|
|
103
|
-
activate,
|
|
104
|
-
deactivate,
|
|
105
|
-
pause,
|
|
106
|
-
unpause,
|
|
107
|
-
};
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defProps = Object.defineProperties;
|
|
7
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
function useFocusTrap(target, options = {}) {
|
|
37
|
+
let trap;
|
|
38
|
+
const _a = options, { immediate } = _a, focusTrapOptions = __objRest(_a, ["immediate"]);
|
|
39
|
+
const hasFocus = ref(false);
|
|
40
|
+
const isPaused = ref(false);
|
|
41
|
+
const activate = (opts) => trap && trap.activate(opts);
|
|
42
|
+
const deactivate = (opts) => trap && trap.deactivate(opts);
|
|
43
|
+
const pause = () => {
|
|
44
|
+
if (trap) {
|
|
45
|
+
trap.pause();
|
|
46
|
+
isPaused.value = true;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const unpause = () => {
|
|
50
|
+
if (trap) {
|
|
51
|
+
trap.unpause();
|
|
52
|
+
isPaused.value = false;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
watch(() => unrefElement(target), (el) => {
|
|
56
|
+
if (!el)
|
|
57
|
+
return;
|
|
58
|
+
trap = createFocusTrap(el, __spreadProps(__spreadValues({}, focusTrapOptions), {
|
|
59
|
+
onActivate() {
|
|
60
|
+
hasFocus.value = true;
|
|
61
|
+
if (options.onActivate)
|
|
62
|
+
options.onActivate();
|
|
63
|
+
},
|
|
64
|
+
onDeactivate() {
|
|
65
|
+
hasFocus.value = false;
|
|
66
|
+
if (options.onDeactivate)
|
|
67
|
+
options.onDeactivate();
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
if (immediate)
|
|
71
|
+
activate();
|
|
72
|
+
}, { flush: "post" });
|
|
73
|
+
tryOnScopeDispose(() => deactivate());
|
|
74
|
+
return {
|
|
75
|
+
hasFocus,
|
|
76
|
+
isPaused,
|
|
77
|
+
activate,
|
|
78
|
+
deactivate,
|
|
79
|
+
pause,
|
|
80
|
+
unpause
|
|
81
|
+
};
|
|
108
82
|
}
|
|
109
83
|
|
|
110
84
|
export { useFocusTrap };
|
package/useFuse.cjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Fuse = require('fuse.js');
|
|
6
|
+
var vueDemi = require('vue-demi');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var Fuse__default = /*#__PURE__*/_interopDefaultLegacy(Fuse);
|
|
11
|
+
|
|
12
|
+
function useFuse(search, data, options) {
|
|
13
|
+
var _a;
|
|
14
|
+
const createFuse = (data2, options2) => {
|
|
15
|
+
var _a2;
|
|
16
|
+
const _options = options2;
|
|
17
|
+
return new Fuse__default["default"]((_a2 = vueDemi.unref(data2)) != null ? _a2 : [], _options);
|
|
18
|
+
};
|
|
19
|
+
const fuse = vueDemi.ref(createFuse(data, (_a = vueDemi.unref(options)) == null ? void 0 : _a.fuseOptions));
|
|
20
|
+
vueDemi.watch(() => {
|
|
21
|
+
var _a2;
|
|
22
|
+
return (_a2 = vueDemi.unref(options)) == null ? void 0 : _a2.fuseOptions;
|
|
23
|
+
}, (newOptions) => {
|
|
24
|
+
fuse.value = createFuse(data, newOptions);
|
|
25
|
+
}, { deep: true });
|
|
26
|
+
vueDemi.watch(() => vueDemi.unref(data), (newData) => {
|
|
27
|
+
fuse.value.setCollection(newData);
|
|
28
|
+
}, { deep: true });
|
|
29
|
+
const results = vueDemi.computed(() => {
|
|
30
|
+
var _a2, _b;
|
|
31
|
+
if (((_a2 = vueDemi.unref(options)) == null ? void 0 : _a2.matchAllWhenSearchEmpty) && !vueDemi.unref(search))
|
|
32
|
+
return vueDemi.unref(data).map((item, index) => ({ item, refIndex: index }));
|
|
33
|
+
const limit = (_b = vueDemi.unref(options)) == null ? void 0 : _b.resultLimit;
|
|
34
|
+
return fuse.value.search(vueDemi.unref(search), limit ? { limit } : void 0);
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
results
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.useFuse = useFuse;
|
package/useFuse.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Fuse from 'fuse.js';
|
|
2
|
+
import { ComputedRef } from 'vue-demi';
|
|
3
|
+
import { MaybeRef } from '@vueuse/shared';
|
|
4
|
+
|
|
5
|
+
declare type FuseOptions<T> = Fuse.IFuseOptions<T>;
|
|
6
|
+
declare type UseFuseOptions<T> = {
|
|
7
|
+
fuseOptions?: FuseOptions<T>;
|
|
8
|
+
resultLimit?: number;
|
|
9
|
+
matchAllWhenSearchEmpty?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare function useFuse<DataItem>(search: MaybeRef<string>, data: MaybeRef<DataItem[]>, options?: MaybeRef<UseFuseOptions<DataItem>>): {
|
|
12
|
+
results: ComputedRef<Fuse.FuseResult<DataItem>[]>;
|
|
13
|
+
};
|
|
14
|
+
declare type UseFuseReturn = ReturnType<typeof useFuse>;
|
|
15
|
+
|
|
16
|
+
export { FuseOptions, UseFuseOptions, UseFuseReturn, useFuse };
|
package/useFuse.iife.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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, Fuse, vueDemi) {
|
|
63
|
+
'use strict';
|
|
64
|
+
|
|
65
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
66
|
+
|
|
67
|
+
var Fuse__default = /*#__PURE__*/_interopDefaultLegacy(Fuse);
|
|
68
|
+
|
|
69
|
+
function useFuse(search, data, options) {
|
|
70
|
+
var _a;
|
|
71
|
+
const createFuse = (data2, options2) => {
|
|
72
|
+
var _a2;
|
|
73
|
+
const _options = options2;
|
|
74
|
+
return new Fuse__default["default"]((_a2 = vueDemi.unref(data2)) != null ? _a2 : [], _options);
|
|
75
|
+
};
|
|
76
|
+
const fuse = vueDemi.ref(createFuse(data, (_a = vueDemi.unref(options)) == null ? void 0 : _a.fuseOptions));
|
|
77
|
+
vueDemi.watch(() => {
|
|
78
|
+
var _a2;
|
|
79
|
+
return (_a2 = vueDemi.unref(options)) == null ? void 0 : _a2.fuseOptions;
|
|
80
|
+
}, (newOptions) => {
|
|
81
|
+
fuse.value = createFuse(data, newOptions);
|
|
82
|
+
}, { deep: true });
|
|
83
|
+
vueDemi.watch(() => vueDemi.unref(data), (newData) => {
|
|
84
|
+
fuse.value.setCollection(newData);
|
|
85
|
+
}, { deep: true });
|
|
86
|
+
const results = vueDemi.computed(() => {
|
|
87
|
+
var _a2, _b;
|
|
88
|
+
if (((_a2 = vueDemi.unref(options)) == null ? void 0 : _a2.matchAllWhenSearchEmpty) && !vueDemi.unref(search))
|
|
89
|
+
return vueDemi.unref(data).map((item, index) => ({ item, refIndex: index }));
|
|
90
|
+
const limit = (_b = vueDemi.unref(options)) == null ? void 0 : _b.resultLimit;
|
|
91
|
+
return fuse.value.search(vueDemi.unref(search), limit ? { limit } : void 0);
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
results
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
exports.useFuse = useFuse;
|
|
99
|
+
|
|
100
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
101
|
+
|
|
102
|
+
})(this.VueUse = this.VueUse || {}, Fuse, VueDemi);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(o){if(!o.VueDemi){var r={},e=o.Vue;if(e)if(e.version.slice(0,2)==="2."){var l=o.VueCompositionAPI;if(l){for(var t in l)r[t]=l[t];r.isVue2=!0,r.isVue3=!1,r.install=function(){},r.Vue=e,r.Vue2=e,r.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 t in e)r[t]=e[t];r.isVue2=!1,r.isVue3=!0,r.install=function(){},r.Vue=e,r.Vue2=void 0,r.version=e.version,r.set=function(n,u,i){return Array.isArray(n)?(n.length=Math.max(n.length,u),n.splice(u,1,i),i):(n[u]=i,i)},r.del=function(n,u){if(Array.isArray(n)){n.splice(u,1);return}delete n[u]}}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`.");o.VueDemi=r}})(window),function(o,r,e){"use strict";function l(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var t=l(r);function n(u,i,c){var V;const p=(s,a)=>{var f;const v=a;return new t.default((f=e.unref(s))!=null?f:[],v)},d=e.ref(p(i,(V=e.unref(c))==null?void 0:V.fuseOptions));return e.watch(()=>{var s;return(s=e.unref(c))==null?void 0:s.fuseOptions},s=>{d.value=p(i,s)},{deep:!0}),e.watch(()=>e.unref(i),s=>{d.value.setCollection(s)},{deep:!0}),{results:e.computed(()=>{var s,a;if(((s=e.unref(c))==null?void 0:s.matchAllWhenSearchEmpty)&&!e.unref(u))return e.unref(i).map((v,_)=>({item:v,refIndex:_}));const f=(a=e.unref(c))==null?void 0:a.resultLimit;return d.value.search(e.unref(u),f?{limit:f}:void 0)})}}o.useFuse=n,Object.defineProperty(o,"__esModule",{value:!0})}(this.VueUse=this.VueUse||{},Fuse,VueDemi);
|
package/useFuse.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Fuse from 'fuse.js';
|
|
2
|
+
import { ref, unref, watch, computed } from 'vue-demi';
|
|
3
|
+
|
|
4
|
+
function useFuse(search, data, options) {
|
|
5
|
+
var _a;
|
|
6
|
+
const createFuse = (data2, options2) => {
|
|
7
|
+
var _a2;
|
|
8
|
+
const _options = options2;
|
|
9
|
+
return new Fuse((_a2 = unref(data2)) != null ? _a2 : [], _options);
|
|
10
|
+
};
|
|
11
|
+
const fuse = ref(createFuse(data, (_a = unref(options)) == null ? void 0 : _a.fuseOptions));
|
|
12
|
+
watch(() => {
|
|
13
|
+
var _a2;
|
|
14
|
+
return (_a2 = unref(options)) == null ? void 0 : _a2.fuseOptions;
|
|
15
|
+
}, (newOptions) => {
|
|
16
|
+
fuse.value = createFuse(data, newOptions);
|
|
17
|
+
}, { deep: true });
|
|
18
|
+
watch(() => unref(data), (newData) => {
|
|
19
|
+
fuse.value.setCollection(newData);
|
|
20
|
+
}, { deep: true });
|
|
21
|
+
const results = computed(() => {
|
|
22
|
+
var _a2, _b;
|
|
23
|
+
if (((_a2 = unref(options)) == null ? void 0 : _a2.matchAllWhenSearchEmpty) && !unref(search))
|
|
24
|
+
return unref(data).map((item, index) => ({ item, refIndex: index }));
|
|
25
|
+
const limit = (_b = unref(options)) == null ? void 0 : _b.resultLimit;
|
|
26
|
+
return fuse.value.search(unref(search), limit ? { limit } : void 0);
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
results
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { useFuse };
|