directix 1.0.0-beta.2 → 1.1.0
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 +242 -35
- package/dist/index.cjs +3191 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1217 -200
- package/dist/index.iife.js +3193 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.iife.min.js +7 -0
- package/dist/index.mjs +3191 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +97 -95
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -1033
- package/dist/index.esm.js.map +0 -1
|
@@ -0,0 +1,3193 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* directix v1.1.0
|
|
3
|
+
* A comprehensive, easy-to-use, and high-performance Vue custom directives library supporting both Vue 2 and Vue 3
|
|
4
|
+
* (c) 2021-present saqqdy <https://github.com/saqqdy>
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defProps = Object.defineProperties;
|
|
9
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var __pow = Math.pow;
|
|
14
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __spreadValues = (a, b) => {
|
|
16
|
+
for (var prop in b || (b = {}))
|
|
17
|
+
if (__hasOwnProp.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
if (__getOwnPropSymbols)
|
|
20
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
21
|
+
if (__propIsEnum.call(b, prop))
|
|
22
|
+
__defNormalProp(a, prop, b[prop]);
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
25
|
+
};
|
|
26
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
27
|
+
var __objRest = (source, exclude) => {
|
|
28
|
+
var target = {};
|
|
29
|
+
for (var prop in source)
|
|
30
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
if (source != null && __getOwnPropSymbols)
|
|
33
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
34
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
35
|
+
target[prop] = source[prop];
|
|
36
|
+
}
|
|
37
|
+
return target;
|
|
38
|
+
};
|
|
39
|
+
var __async = (__this, __arguments, generator) => {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
var fulfilled = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.next(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var rejected = (value) => {
|
|
49
|
+
try {
|
|
50
|
+
step(generator.throw(value));
|
|
51
|
+
} catch (e) {
|
|
52
|
+
reject(e);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
56
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/*!
|
|
60
|
+
* directix v1.1.0
|
|
61
|
+
* A comprehensive, easy-to-use, and high-performance Vue custom directives library supporting both Vue 2 and Vue 3
|
|
62
|
+
* (c) 2021-present saqqdy <https://github.com/saqqdy>
|
|
63
|
+
* Released under the MIT License.
|
|
64
|
+
*/
|
|
65
|
+
(function(exports) {
|
|
66
|
+
"use strict";
|
|
67
|
+
let _vueVersion = null, _isVue2 = null, _isVue27 = null, _isVue3 = null;
|
|
68
|
+
function parseVersion(version) {
|
|
69
|
+
if (version.startsWith("2.7")) return 2.7;
|
|
70
|
+
if (version.startsWith("2")) return 2;
|
|
71
|
+
if (version.startsWith("3")) return 3;
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
function getVueVersion() {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (_vueVersion !== null) return _vueVersion;
|
|
77
|
+
if (typeof process !== "undefined") {
|
|
78
|
+
const envVersion = process.env.DIRECTIX_VUE_VERSION;
|
|
79
|
+
if (envVersion === "2.7") {
|
|
80
|
+
_vueVersion = 2.7;
|
|
81
|
+
return _vueVersion;
|
|
82
|
+
}
|
|
83
|
+
if (envVersion === "2") {
|
|
84
|
+
_vueVersion = 2;
|
|
85
|
+
return _vueVersion;
|
|
86
|
+
}
|
|
87
|
+
if (envVersion === "3") {
|
|
88
|
+
_vueVersion = 3;
|
|
89
|
+
return _vueVersion;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const vue = require("vue");
|
|
94
|
+
const version = parseVersion(vue == null ? void 0 : vue.version);
|
|
95
|
+
if (version !== null) {
|
|
96
|
+
_vueVersion = version;
|
|
97
|
+
return _vueVersion;
|
|
98
|
+
}
|
|
99
|
+
} catch (e) {
|
|
100
|
+
}
|
|
101
|
+
if (typeof window !== "undefined") {
|
|
102
|
+
const win = window;
|
|
103
|
+
const vue = win.Vue;
|
|
104
|
+
if (vue == null ? void 0 : vue.version) {
|
|
105
|
+
const version = parseVersion(vue.version);
|
|
106
|
+
if (version !== null) {
|
|
107
|
+
_vueVersion = version;
|
|
108
|
+
return _vueVersion;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (typeof (vue == null ? void 0 : vue.observable) === "function") {
|
|
112
|
+
_vueVersion = 2;
|
|
113
|
+
return _vueVersion;
|
|
114
|
+
}
|
|
115
|
+
if (typeof (vue == null ? void 0 : vue.createApp) === "function" && typeof (vue == null ? void 0 : vue.observable) !== "function") {
|
|
116
|
+
_vueVersion = 3;
|
|
117
|
+
return _vueVersion;
|
|
118
|
+
}
|
|
119
|
+
const devtools = win.__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
|
120
|
+
if ((_a = devtools == null ? void 0 : devtools.Vue) == null ? void 0 : _a.version) {
|
|
121
|
+
const version = parseVersion(devtools.Vue.version);
|
|
122
|
+
if (version !== null) {
|
|
123
|
+
_vueVersion = version;
|
|
124
|
+
return _vueVersion;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if ((_b = devtools == null ? void 0 : devtools.apps) == null ? void 0 : _b.length) {
|
|
128
|
+
_vueVersion = 3;
|
|
129
|
+
return _vueVersion;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (_vueVersion === null) {
|
|
133
|
+
if (typeof window !== "undefined") {
|
|
134
|
+
console.warn(
|
|
135
|
+
"[Directix] Unable to detect Vue version, defaulting to Vue 3. Set DIRECTIX_VUE_VERSION=2 or call setVueVersion(2) if using Vue 2."
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
_vueVersion = 3;
|
|
139
|
+
}
|
|
140
|
+
return _vueVersion;
|
|
141
|
+
}
|
|
142
|
+
function setVueVersion(version) {
|
|
143
|
+
_vueVersion = version;
|
|
144
|
+
_isVue2 = version === 2 || version === 2.7;
|
|
145
|
+
_isVue27 = version === 2.7;
|
|
146
|
+
_isVue3 = version === 3;
|
|
147
|
+
}
|
|
148
|
+
function resetVueVersion() {
|
|
149
|
+
_vueVersion = null;
|
|
150
|
+
_isVue2 = null;
|
|
151
|
+
_isVue27 = null;
|
|
152
|
+
_isVue3 = null;
|
|
153
|
+
}
|
|
154
|
+
function isVue2() {
|
|
155
|
+
if (_isVue2 === null) {
|
|
156
|
+
const version = getVueVersion();
|
|
157
|
+
_isVue2 = version === 2 || version === 2.7;
|
|
158
|
+
}
|
|
159
|
+
return _isVue2;
|
|
160
|
+
}
|
|
161
|
+
function isVue27() {
|
|
162
|
+
if (_isVue27 === null) {
|
|
163
|
+
_isVue27 = getVueVersion() === 2.7;
|
|
164
|
+
}
|
|
165
|
+
return _isVue27;
|
|
166
|
+
}
|
|
167
|
+
function isVue3() {
|
|
168
|
+
if (_isVue3 === null) {
|
|
169
|
+
_isVue3 = getVueVersion() === 3;
|
|
170
|
+
}
|
|
171
|
+
return _isVue3;
|
|
172
|
+
}
|
|
173
|
+
const isBrowser = () => {
|
|
174
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
175
|
+
};
|
|
176
|
+
const isSSR = () => !isBrowser();
|
|
177
|
+
const supportsPassive = () => {
|
|
178
|
+
if (!isBrowser()) return false;
|
|
179
|
+
let supports = false;
|
|
180
|
+
try {
|
|
181
|
+
const options = {
|
|
182
|
+
get passive() {
|
|
183
|
+
supports = true;
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
window.addEventListener("test", null, options);
|
|
188
|
+
window.removeEventListener("test", null, options);
|
|
189
|
+
} catch (e) {
|
|
190
|
+
supports = false;
|
|
191
|
+
}
|
|
192
|
+
return supports;
|
|
193
|
+
};
|
|
194
|
+
const supportsIntersectionObserver = () => {
|
|
195
|
+
return isBrowser() && "IntersectionObserver" in window;
|
|
196
|
+
};
|
|
197
|
+
const supportsResizeObserver = () => {
|
|
198
|
+
return isBrowser() && "ResizeObserver" in window;
|
|
199
|
+
};
|
|
200
|
+
const supportsClipboard = () => {
|
|
201
|
+
return isBrowser() && "clipboard" in navigator;
|
|
202
|
+
};
|
|
203
|
+
const supportsMutationObserver = () => {
|
|
204
|
+
return isBrowser() && "MutationObserver" in window;
|
|
205
|
+
};
|
|
206
|
+
function createVue2Directive(hooks) {
|
|
207
|
+
const directive = {
|
|
208
|
+
bind(el, binding, vnode) {
|
|
209
|
+
const state = {
|
|
210
|
+
value: binding.value,
|
|
211
|
+
vnode,
|
|
212
|
+
cleanup: []
|
|
213
|
+
};
|
|
214
|
+
el.__directix_state__ = state;
|
|
215
|
+
},
|
|
216
|
+
inserted(el, binding, vnode) {
|
|
217
|
+
if (hooks.mounted) {
|
|
218
|
+
hooks.mounted(el, normalizeBinding(binding), vnode);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
update(el, binding, vnode, oldVnode) {
|
|
222
|
+
const state = el.__directix_state__;
|
|
223
|
+
if (hooks.updated) {
|
|
224
|
+
hooks.updated(
|
|
225
|
+
el,
|
|
226
|
+
normalizeBinding(binding),
|
|
227
|
+
vnode,
|
|
228
|
+
normalizeBinding(__spreadProps(__spreadValues({}, binding), { value: binding.oldValue })),
|
|
229
|
+
oldVnode
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
if (state) {
|
|
233
|
+
state.value = binding.value;
|
|
234
|
+
state.vnode = vnode;
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
componentUpdated(_el, _binding, _vnode, _oldVnode) {
|
|
238
|
+
},
|
|
239
|
+
unbind(el, binding, vnode) {
|
|
240
|
+
if (hooks.unmounted) {
|
|
241
|
+
hooks.unmounted(el, normalizeBinding(binding), vnode);
|
|
242
|
+
}
|
|
243
|
+
const state = el.__directix_state__;
|
|
244
|
+
if (state == null ? void 0 : state.cleanup) {
|
|
245
|
+
state.cleanup.forEach((fn) => fn());
|
|
246
|
+
}
|
|
247
|
+
delete el.__directix_state__;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
return directive;
|
|
251
|
+
}
|
|
252
|
+
function normalizeBinding(binding) {
|
|
253
|
+
var _a;
|
|
254
|
+
return {
|
|
255
|
+
value: binding.value,
|
|
256
|
+
oldValue: (_a = binding.oldValue) != null ? _a : null,
|
|
257
|
+
arg: binding.arg,
|
|
258
|
+
modifiers: binding.modifiers || {},
|
|
259
|
+
instance: binding.instance || null
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function addCleanup$1(el, fn) {
|
|
263
|
+
const state = el.__directix_state__;
|
|
264
|
+
if (state) {
|
|
265
|
+
state.cleanup.push(fn);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function createVue3Directive(hooks) {
|
|
269
|
+
const directive = {
|
|
270
|
+
created(el, binding, vnode) {
|
|
271
|
+
const state = {
|
|
272
|
+
value: binding.value,
|
|
273
|
+
vnode,
|
|
274
|
+
cleanup: []
|
|
275
|
+
};
|
|
276
|
+
el.__directix_state__ = state;
|
|
277
|
+
},
|
|
278
|
+
beforeMount(_el, _binding, _vnode) {
|
|
279
|
+
},
|
|
280
|
+
mounted(el, binding, vnode) {
|
|
281
|
+
if (hooks.mounted) {
|
|
282
|
+
hooks.mounted(el, normalizeBindingVue3(binding), vnode);
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
beforeUpdate(_el, _binding, _vnode, _prevVnode) {
|
|
286
|
+
},
|
|
287
|
+
updated(el, binding, vnode, prevVnode) {
|
|
288
|
+
const state = el.__directix_state__;
|
|
289
|
+
if (hooks.updated) {
|
|
290
|
+
hooks.updated(
|
|
291
|
+
el,
|
|
292
|
+
normalizeBindingVue3(binding),
|
|
293
|
+
vnode,
|
|
294
|
+
normalizeBindingVue3(__spreadProps(__spreadValues({}, binding), { value: binding.oldValue })),
|
|
295
|
+
prevVnode
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
if (state) {
|
|
299
|
+
state.value = binding.value;
|
|
300
|
+
state.vnode = vnode;
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
beforeUnmount(_el, _binding, _vnode) {
|
|
304
|
+
},
|
|
305
|
+
unmounted(el, binding, vnode) {
|
|
306
|
+
if (hooks.unmounted) {
|
|
307
|
+
hooks.unmounted(el, normalizeBindingVue3(binding), vnode);
|
|
308
|
+
}
|
|
309
|
+
const state = el.__directix_state__;
|
|
310
|
+
if (state == null ? void 0 : state.cleanup) {
|
|
311
|
+
state.cleanup.forEach((fn) => fn());
|
|
312
|
+
}
|
|
313
|
+
delete el.__directix_state__;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
return directive;
|
|
317
|
+
}
|
|
318
|
+
function normalizeBindingVue3(binding) {
|
|
319
|
+
var _a;
|
|
320
|
+
return {
|
|
321
|
+
value: binding.value,
|
|
322
|
+
oldValue: (_a = binding.oldValue) != null ? _a : null,
|
|
323
|
+
arg: binding.arg,
|
|
324
|
+
modifiers: binding.modifiers || {},
|
|
325
|
+
instance: binding.instance
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function addCleanup(el, fn) {
|
|
329
|
+
const state = el.__directix_state__;
|
|
330
|
+
if (state) {
|
|
331
|
+
state.cleanup.push(fn);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function defineDirective(definition) {
|
|
335
|
+
var _b;
|
|
336
|
+
const _a = definition, { name, version, ssr, defaults } = _a, hooks = __objRest(_a, ["name", "version", "ssr", "defaults"]);
|
|
337
|
+
if (isSSR() && !ssr) {
|
|
338
|
+
if (typeof process !== "undefined" && ((_b = process.env) == null ? void 0 : _b.NODE_ENV) !== "test") {
|
|
339
|
+
console.warn(
|
|
340
|
+
`[Directix] Directive "${name}" is not compatible with SSR. It will be a no-op on the server side.`
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
return createNoOpDirective();
|
|
344
|
+
}
|
|
345
|
+
const wrappedHooks = {
|
|
346
|
+
mounted: hooks.mounted ? (el, binding, vnode) => {
|
|
347
|
+
hooks.mounted(el, applyDefaults(binding, defaults), vnode);
|
|
348
|
+
} : void 0,
|
|
349
|
+
updated: hooks.updated ? (el, binding, vnode, prevBinding, prevVnode) => {
|
|
350
|
+
hooks.updated(el, applyDefaults(binding, defaults), vnode, prevBinding, prevVnode);
|
|
351
|
+
} : void 0,
|
|
352
|
+
unmounted: hooks.unmounted
|
|
353
|
+
};
|
|
354
|
+
return createLazyDirective(wrappedHooks);
|
|
355
|
+
}
|
|
356
|
+
function createLazyDirective(hooks) {
|
|
357
|
+
let cachedDirective = null;
|
|
358
|
+
function getDirective() {
|
|
359
|
+
if (!cachedDirective) {
|
|
360
|
+
cachedDirective = getVueVersion() === 2 ? createVue2Directive(hooks) : createVue3Directive(hooks);
|
|
361
|
+
}
|
|
362
|
+
return cachedDirective;
|
|
363
|
+
}
|
|
364
|
+
function createHook(hookName) {
|
|
365
|
+
return function(el, binding, vnode, prevVnode) {
|
|
366
|
+
var _a, _b;
|
|
367
|
+
(_b = (_a = getDirective())[hookName]) == null ? void 0 : _b.call(_a, el, binding, vnode, prevVnode);
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
// Vue 2 hooks
|
|
372
|
+
bind: createHook("bind"),
|
|
373
|
+
inserted: createHook("inserted"),
|
|
374
|
+
update: createHook("update"),
|
|
375
|
+
componentUpdated: createHook("componentUpdated"),
|
|
376
|
+
unbind: createHook("unbind"),
|
|
377
|
+
// Vue 3 hooks
|
|
378
|
+
created: createHook("created"),
|
|
379
|
+
beforeMount: createHook("beforeMount"),
|
|
380
|
+
mounted: createHook("mounted"),
|
|
381
|
+
beforeUpdate: createHook("beforeUpdate"),
|
|
382
|
+
updated: createHook("updated"),
|
|
383
|
+
beforeUnmount: createHook("beforeUnmount"),
|
|
384
|
+
unmounted: createHook("unmounted")
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function applyDefaults(binding, defaults) {
|
|
388
|
+
if (!defaults) return binding;
|
|
389
|
+
const value = typeof binding.value === "object" && binding.value !== null ? __spreadValues(__spreadValues({}, defaults), binding.value) : binding.value;
|
|
390
|
+
return __spreadProps(__spreadValues({}, binding), { value });
|
|
391
|
+
}
|
|
392
|
+
function createNoOpDirective() {
|
|
393
|
+
return {
|
|
394
|
+
mounted: () => {
|
|
395
|
+
},
|
|
396
|
+
updated: () => {
|
|
397
|
+
},
|
|
398
|
+
unmounted: () => {
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
function defineDirectiveGroup(name, directives) {
|
|
403
|
+
return {
|
|
404
|
+
name,
|
|
405
|
+
directives,
|
|
406
|
+
install(app, _options) {
|
|
407
|
+
Object.entries(directives).forEach(([directiveName, directive]) => {
|
|
408
|
+
const fullName = `${name}-${directiveName}`;
|
|
409
|
+
app.directive(fullName, directive);
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
function isElement(value) {
|
|
415
|
+
return value instanceof Element;
|
|
416
|
+
}
|
|
417
|
+
function getElement(target) {
|
|
418
|
+
if (!target) return null;
|
|
419
|
+
if (typeof target === "string") {
|
|
420
|
+
if (!isBrowser()) return null;
|
|
421
|
+
return document.querySelector(target);
|
|
422
|
+
}
|
|
423
|
+
return isElement(target) ? target : null;
|
|
424
|
+
}
|
|
425
|
+
function getScrollParent(el) {
|
|
426
|
+
if (!isBrowser()) return window;
|
|
427
|
+
let parent = el.parentElement;
|
|
428
|
+
while (parent) {
|
|
429
|
+
const { overflow, overflowX, overflowY } = getComputedStyle(parent);
|
|
430
|
+
if (/(auto|scroll)/.test(overflow + overflowX + overflowY)) {
|
|
431
|
+
return parent;
|
|
432
|
+
}
|
|
433
|
+
parent = parent.parentElement;
|
|
434
|
+
}
|
|
435
|
+
return window;
|
|
436
|
+
}
|
|
437
|
+
function on(target, event, handler, options = false) {
|
|
438
|
+
if (!isBrowser()) return;
|
|
439
|
+
const opts = normalizeOptions$k(options);
|
|
440
|
+
target.addEventListener(event, handler, opts);
|
|
441
|
+
}
|
|
442
|
+
function off(target, event, handler, options = false) {
|
|
443
|
+
if (!isBrowser()) return;
|
|
444
|
+
const opts = normalizeOptions$k(options);
|
|
445
|
+
target.removeEventListener(event, handler, opts);
|
|
446
|
+
}
|
|
447
|
+
function normalizeOptions$k(options) {
|
|
448
|
+
if (typeof options === "boolean") {
|
|
449
|
+
return options;
|
|
450
|
+
}
|
|
451
|
+
const { capture = false, passive = false, once = false } = options;
|
|
452
|
+
if (supportsPassive()) {
|
|
453
|
+
return { capture, passive, once };
|
|
454
|
+
}
|
|
455
|
+
return capture;
|
|
456
|
+
}
|
|
457
|
+
function getEventPosition(e) {
|
|
458
|
+
let clientX = 0, clientY = 0;
|
|
459
|
+
if ("touches" in e && e.touches.length > 0) {
|
|
460
|
+
clientX = e.touches[0].clientX;
|
|
461
|
+
clientY = e.touches[0].clientY;
|
|
462
|
+
} else if ("clientX" in e) {
|
|
463
|
+
clientX = e.clientX;
|
|
464
|
+
clientY = e.clientY;
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
x: clientX,
|
|
468
|
+
y: clientY,
|
|
469
|
+
clientX,
|
|
470
|
+
clientY
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function isString(value) {
|
|
474
|
+
return typeof value === "string";
|
|
475
|
+
}
|
|
476
|
+
function isNumber(value) {
|
|
477
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
478
|
+
}
|
|
479
|
+
function isBoolean(value) {
|
|
480
|
+
return typeof value === "boolean";
|
|
481
|
+
}
|
|
482
|
+
function isFunction(value) {
|
|
483
|
+
return typeof value === "function";
|
|
484
|
+
}
|
|
485
|
+
function isObject(value) {
|
|
486
|
+
return typeof value === "object" && value !== null;
|
|
487
|
+
}
|
|
488
|
+
function isArray(value) {
|
|
489
|
+
return Array.isArray(value);
|
|
490
|
+
}
|
|
491
|
+
function isEmpty(value) {
|
|
492
|
+
if (value === null || value === void 0) return true;
|
|
493
|
+
if (isString(value) || isArray(value)) return value.length === 0;
|
|
494
|
+
if (isObject(value)) return Object.keys(value).length === 0;
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
function isPromise(value) {
|
|
498
|
+
return isObject(value) && isFunction(value.then);
|
|
499
|
+
}
|
|
500
|
+
function deepClone(obj) {
|
|
501
|
+
if (obj === null || typeof obj !== "object") {
|
|
502
|
+
return obj;
|
|
503
|
+
}
|
|
504
|
+
if (Array.isArray(obj)) {
|
|
505
|
+
return obj.map((item) => deepClone(item));
|
|
506
|
+
}
|
|
507
|
+
const cloned = {};
|
|
508
|
+
for (const key in obj) {
|
|
509
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
510
|
+
cloned[key] = deepClone(obj[key]);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return cloned;
|
|
514
|
+
}
|
|
515
|
+
function deepMerge(target, ...sources) {
|
|
516
|
+
if (!sources.length) return target;
|
|
517
|
+
const source = sources.shift();
|
|
518
|
+
if (isObject(target) && isObject(source)) {
|
|
519
|
+
for (const key in source) {
|
|
520
|
+
if (isObject(source[key])) {
|
|
521
|
+
if (!target[key]) {
|
|
522
|
+
Object.assign(target, { [key]: {} });
|
|
523
|
+
}
|
|
524
|
+
deepMerge(
|
|
525
|
+
target[key],
|
|
526
|
+
source[key]
|
|
527
|
+
);
|
|
528
|
+
} else {
|
|
529
|
+
Object.assign(target, { [key]: source[key] });
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return deepMerge(target, ...sources);
|
|
534
|
+
}
|
|
535
|
+
function get(obj, path, defaultValue) {
|
|
536
|
+
const keys = path.split(".");
|
|
537
|
+
let result = obj;
|
|
538
|
+
for (const key of keys) {
|
|
539
|
+
if (result === null || result === void 0) {
|
|
540
|
+
return defaultValue;
|
|
541
|
+
}
|
|
542
|
+
result = result[key];
|
|
543
|
+
}
|
|
544
|
+
return result === void 0 ? defaultValue : result;
|
|
545
|
+
}
|
|
546
|
+
function set(obj, path, value) {
|
|
547
|
+
const keys = path.split(".");
|
|
548
|
+
const lastKey = keys.pop();
|
|
549
|
+
let current = obj;
|
|
550
|
+
for (const key of keys) {
|
|
551
|
+
if (current[key] === void 0) {
|
|
552
|
+
current[key] = {};
|
|
553
|
+
}
|
|
554
|
+
current = current[key];
|
|
555
|
+
}
|
|
556
|
+
current[lastKey] = value;
|
|
557
|
+
}
|
|
558
|
+
function debounce(func, wait = 300, options = {}) {
|
|
559
|
+
let timerId = null, lastArgs = null, lastThis = null;
|
|
560
|
+
const { leading = false, trailing = true } = options;
|
|
561
|
+
const invokeFunc = () => {
|
|
562
|
+
if (lastArgs) {
|
|
563
|
+
func.apply(lastThis, lastArgs);
|
|
564
|
+
lastArgs = null;
|
|
565
|
+
lastThis = null;
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
const debounced = function(...args) {
|
|
569
|
+
lastArgs = args;
|
|
570
|
+
lastThis = this;
|
|
571
|
+
if (timerId) {
|
|
572
|
+
clearTimeout(timerId);
|
|
573
|
+
}
|
|
574
|
+
if (leading && !timerId) {
|
|
575
|
+
invokeFunc();
|
|
576
|
+
}
|
|
577
|
+
timerId = setTimeout(() => {
|
|
578
|
+
if (trailing) {
|
|
579
|
+
invokeFunc();
|
|
580
|
+
}
|
|
581
|
+
timerId = null;
|
|
582
|
+
}, wait);
|
|
583
|
+
};
|
|
584
|
+
debounced.cancel = () => {
|
|
585
|
+
if (timerId) {
|
|
586
|
+
clearTimeout(timerId);
|
|
587
|
+
timerId = null;
|
|
588
|
+
}
|
|
589
|
+
lastArgs = null;
|
|
590
|
+
lastThis = null;
|
|
591
|
+
};
|
|
592
|
+
debounced.flush = () => {
|
|
593
|
+
if (timerId) {
|
|
594
|
+
clearTimeout(timerId);
|
|
595
|
+
invokeFunc();
|
|
596
|
+
timerId = null;
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
return debounced;
|
|
600
|
+
}
|
|
601
|
+
function throttle(func, wait = 300, options = {}) {
|
|
602
|
+
let timerId = null, lastArgs = null, lastThis = null, lastCallTime = 0;
|
|
603
|
+
const { leading = true, trailing = true } = options;
|
|
604
|
+
const invokeFunc = () => {
|
|
605
|
+
if (lastArgs) {
|
|
606
|
+
func.apply(lastThis, lastArgs);
|
|
607
|
+
lastArgs = null;
|
|
608
|
+
lastThis = null;
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
const throttled = function(...args) {
|
|
612
|
+
const now = Date.now();
|
|
613
|
+
if (!lastCallTime && !leading) {
|
|
614
|
+
lastCallTime = now;
|
|
615
|
+
}
|
|
616
|
+
const remaining = wait - (now - lastCallTime);
|
|
617
|
+
lastArgs = args;
|
|
618
|
+
lastThis = this;
|
|
619
|
+
if (remaining <= 0 || remaining > wait) {
|
|
620
|
+
if (timerId) {
|
|
621
|
+
clearTimeout(timerId);
|
|
622
|
+
timerId = null;
|
|
623
|
+
}
|
|
624
|
+
lastCallTime = now;
|
|
625
|
+
invokeFunc();
|
|
626
|
+
} else if (!timerId && trailing) {
|
|
627
|
+
timerId = setTimeout(() => {
|
|
628
|
+
lastCallTime = leading ? Date.now() : 0;
|
|
629
|
+
timerId = null;
|
|
630
|
+
invokeFunc();
|
|
631
|
+
}, remaining);
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
throttled.cancel = () => {
|
|
635
|
+
if (timerId) {
|
|
636
|
+
clearTimeout(timerId);
|
|
637
|
+
timerId = null;
|
|
638
|
+
}
|
|
639
|
+
lastCallTime = 0;
|
|
640
|
+
lastArgs = null;
|
|
641
|
+
lastThis = null;
|
|
642
|
+
};
|
|
643
|
+
return throttled;
|
|
644
|
+
}
|
|
645
|
+
function parseTime(arg) {
|
|
646
|
+
if (!arg) return null;
|
|
647
|
+
if (arg.endsWith("ms")) {
|
|
648
|
+
return Number.parseInt(arg, 10);
|
|
649
|
+
}
|
|
650
|
+
if (arg.endsWith("s")) {
|
|
651
|
+
return Number.parseFloat(arg) * 1e3;
|
|
652
|
+
}
|
|
653
|
+
const num = Number.parseInt(arg, 10);
|
|
654
|
+
return Number.isNaN(num) ? null : num;
|
|
655
|
+
}
|
|
656
|
+
function generateId(prefix = "") {
|
|
657
|
+
return `${prefix}${Date.now().toString(36)}${Math.random().toString(36).slice(2, 9)}`;
|
|
658
|
+
}
|
|
659
|
+
const vClickOutside = defineDirective({
|
|
660
|
+
name: "click-outside",
|
|
661
|
+
ssr: false,
|
|
662
|
+
defaults: {
|
|
663
|
+
capture: true,
|
|
664
|
+
events: ["click"],
|
|
665
|
+
disabled: false,
|
|
666
|
+
stop: false,
|
|
667
|
+
prevent: false
|
|
668
|
+
},
|
|
669
|
+
mounted(el, binding) {
|
|
670
|
+
const options = normalizeOptions$j(binding.value);
|
|
671
|
+
if (options.disabled) return;
|
|
672
|
+
const state = {
|
|
673
|
+
options,
|
|
674
|
+
handlers: /* @__PURE__ */ new Map()
|
|
675
|
+
};
|
|
676
|
+
el.__clickOutside = state;
|
|
677
|
+
const createHandler = (_eventType) => {
|
|
678
|
+
return (event) => {
|
|
679
|
+
if (!isValidClick(el, event, options)) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
if (options.stop) {
|
|
683
|
+
event.stopPropagation();
|
|
684
|
+
}
|
|
685
|
+
if (options.prevent) {
|
|
686
|
+
event.preventDefault();
|
|
687
|
+
}
|
|
688
|
+
options.handler(event);
|
|
689
|
+
};
|
|
690
|
+
};
|
|
691
|
+
options.events.forEach((eventType) => {
|
|
692
|
+
const handler = createHandler();
|
|
693
|
+
state.handlers.set(eventType, handler);
|
|
694
|
+
const listenerOptions = {
|
|
695
|
+
capture: options.capture,
|
|
696
|
+
passive: !options.prevent
|
|
697
|
+
};
|
|
698
|
+
on(document, eventType, handler, listenerOptions);
|
|
699
|
+
});
|
|
700
|
+
},
|
|
701
|
+
updated(el, binding) {
|
|
702
|
+
const state = el.__clickOutside;
|
|
703
|
+
if (!state) return;
|
|
704
|
+
const oldOptions = state.options;
|
|
705
|
+
const newOptions = normalizeOptions$j(binding.value);
|
|
706
|
+
if (oldOptions.disabled !== newOptions.disabled) {
|
|
707
|
+
if (newOptions.disabled) {
|
|
708
|
+
state.handlers.forEach((handler, eventType) => {
|
|
709
|
+
off(document, eventType, handler, { capture: oldOptions.capture });
|
|
710
|
+
});
|
|
711
|
+
state.handlers.clear();
|
|
712
|
+
} else {
|
|
713
|
+
const createHandler = (_eventType) => {
|
|
714
|
+
return (event) => {
|
|
715
|
+
if (!isValidClick(el, event, newOptions)) return;
|
|
716
|
+
if (newOptions.stop) event.stopPropagation();
|
|
717
|
+
if (newOptions.prevent) event.preventDefault();
|
|
718
|
+
newOptions.handler(event);
|
|
719
|
+
};
|
|
720
|
+
};
|
|
721
|
+
newOptions.events.forEach((eventType) => {
|
|
722
|
+
const handler = createHandler();
|
|
723
|
+
state.handlers.set(eventType, handler);
|
|
724
|
+
on(document, eventType, handler, {
|
|
725
|
+
capture: newOptions.capture,
|
|
726
|
+
passive: !newOptions.prevent
|
|
727
|
+
});
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
state.options = newOptions;
|
|
732
|
+
},
|
|
733
|
+
unmounted(el) {
|
|
734
|
+
const state = el.__clickOutside;
|
|
735
|
+
if (!state) return;
|
|
736
|
+
state.handlers.forEach((handler, eventType) => {
|
|
737
|
+
off(document, eventType, handler, { capture: state.options.capture });
|
|
738
|
+
});
|
|
739
|
+
delete el.__clickOutside;
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
function normalizeOptions$j(binding) {
|
|
743
|
+
var _a, _b, _c, _d, _e;
|
|
744
|
+
if (typeof binding === "function") {
|
|
745
|
+
return {
|
|
746
|
+
handler: binding,
|
|
747
|
+
capture: true,
|
|
748
|
+
events: ["click"],
|
|
749
|
+
disabled: false,
|
|
750
|
+
stop: false,
|
|
751
|
+
prevent: false
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
if (!binding) {
|
|
755
|
+
throw new Error("[Directix] v-click-outside: handler is required");
|
|
756
|
+
}
|
|
757
|
+
return __spreadValues({
|
|
758
|
+
capture: (_a = binding.capture) != null ? _a : true,
|
|
759
|
+
events: (_b = binding.events) != null ? _b : ["click"],
|
|
760
|
+
disabled: (_c = binding.disabled) != null ? _c : false,
|
|
761
|
+
stop: (_d = binding.stop) != null ? _d : false,
|
|
762
|
+
prevent: (_e = binding.prevent) != null ? _e : false
|
|
763
|
+
}, binding);
|
|
764
|
+
}
|
|
765
|
+
function isValidClick(el, event, options) {
|
|
766
|
+
var _a;
|
|
767
|
+
const target = event.target;
|
|
768
|
+
if (el.contains(target)) {
|
|
769
|
+
return false;
|
|
770
|
+
}
|
|
771
|
+
if ((_a = options.exclude) == null ? void 0 : _a.length) {
|
|
772
|
+
for (const exclude of options.exclude) {
|
|
773
|
+
const excludeEl = typeof exclude === "function" ? exclude() : getElement(exclude);
|
|
774
|
+
if (excludeEl && (excludeEl === target || excludeEl.contains(target))) {
|
|
775
|
+
return false;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
return true;
|
|
780
|
+
}
|
|
781
|
+
function copyToClipboard(text) {
|
|
782
|
+
return __async(this, null, function* () {
|
|
783
|
+
if (supportsClipboard()) {
|
|
784
|
+
try {
|
|
785
|
+
yield navigator.clipboard.writeText(text);
|
|
786
|
+
return true;
|
|
787
|
+
} catch (e) {
|
|
788
|
+
console.warn("[Directix] Clipboard API failed, falling back to execCommand");
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
return copyWithExecCommand(text);
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
function copyWithExecCommand(text) {
|
|
795
|
+
const textarea = document.createElement("textarea");
|
|
796
|
+
textarea.value = text;
|
|
797
|
+
textarea.style.cssText = `
|
|
798
|
+
position: fixed;
|
|
799
|
+
top: -9999px;
|
|
800
|
+
left: -9999px;
|
|
801
|
+
opacity: 0;
|
|
802
|
+
pointer-events: none;
|
|
803
|
+
`;
|
|
804
|
+
document.body.appendChild(textarea);
|
|
805
|
+
try {
|
|
806
|
+
textarea.select();
|
|
807
|
+
textarea.setSelectionRange(0, textarea.value.length);
|
|
808
|
+
return document.execCommand("copy");
|
|
809
|
+
} catch (e) {
|
|
810
|
+
return false;
|
|
811
|
+
} finally {
|
|
812
|
+
document.body.removeChild(textarea);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
const vCopy = defineDirective({
|
|
816
|
+
name: "copy",
|
|
817
|
+
ssr: false,
|
|
818
|
+
mounted(el, binding) {
|
|
819
|
+
const options = normalizeOptions$i(binding.value);
|
|
820
|
+
if (options.disabled) return;
|
|
821
|
+
if (options.title) {
|
|
822
|
+
el.setAttribute("title", options.title);
|
|
823
|
+
}
|
|
824
|
+
const state = {
|
|
825
|
+
handler: null,
|
|
826
|
+
options
|
|
827
|
+
};
|
|
828
|
+
state.handler = () => __async(null, null, function* () {
|
|
829
|
+
var _a, _b, _c, _d;
|
|
830
|
+
const text = state.options.value;
|
|
831
|
+
if (!text) {
|
|
832
|
+
console.warn("[Directix] v-copy: No text to copy");
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
try {
|
|
836
|
+
const success = yield copyToClipboard(text);
|
|
837
|
+
if (success) {
|
|
838
|
+
(_b = (_a = state.options).onSuccess) == null ? void 0 : _b.call(_a, text);
|
|
839
|
+
el.dispatchEvent(new CustomEvent("copy:success", { detail: { text } }));
|
|
840
|
+
} else {
|
|
841
|
+
throw new Error("Copy failed");
|
|
842
|
+
}
|
|
843
|
+
} catch (err) {
|
|
844
|
+
const error = err;
|
|
845
|
+
(_d = (_c = state.options).onError) == null ? void 0 : _d.call(_c, error);
|
|
846
|
+
el.dispatchEvent(new CustomEvent("copy:error", { detail: { error } }));
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
el.addEventListener("click", state.handler);
|
|
850
|
+
el.__copy = state;
|
|
851
|
+
},
|
|
852
|
+
updated(el, binding) {
|
|
853
|
+
const state = el.__copy;
|
|
854
|
+
if (!state) return;
|
|
855
|
+
state.options = normalizeOptions$i(binding.value);
|
|
856
|
+
if (state.options.title) {
|
|
857
|
+
el.setAttribute("title", state.options.title);
|
|
858
|
+
}
|
|
859
|
+
},
|
|
860
|
+
unmounted(el) {
|
|
861
|
+
const state = el.__copy;
|
|
862
|
+
if (!state) return;
|
|
863
|
+
el.removeEventListener("click", state.handler);
|
|
864
|
+
delete el.__copy;
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
function normalizeOptions$i(binding) {
|
|
868
|
+
if (typeof binding === "string") {
|
|
869
|
+
return { value: binding };
|
|
870
|
+
}
|
|
871
|
+
return binding;
|
|
872
|
+
}
|
|
873
|
+
const vDebounce = defineDirective({
|
|
874
|
+
name: "debounce",
|
|
875
|
+
ssr: true,
|
|
876
|
+
// SSR safe - event binding is skipped on server
|
|
877
|
+
defaults: {
|
|
878
|
+
wait: 300,
|
|
879
|
+
leading: false,
|
|
880
|
+
trailing: true
|
|
881
|
+
},
|
|
882
|
+
mounted(el, binding) {
|
|
883
|
+
const options = normalizeOptions$h(binding.value, binding);
|
|
884
|
+
const eventType = getEventTypeFromModifiers$1(binding.modifiers) || getEventType$1(el);
|
|
885
|
+
const debouncedFn = debounce(options.handler, options.wait, {
|
|
886
|
+
leading: options.leading,
|
|
887
|
+
trailing: options.trailing
|
|
888
|
+
});
|
|
889
|
+
el.addEventListener(eventType, debouncedFn);
|
|
890
|
+
el.__debounce = {
|
|
891
|
+
debouncedFn,
|
|
892
|
+
eventType,
|
|
893
|
+
options
|
|
894
|
+
};
|
|
895
|
+
},
|
|
896
|
+
updated(el, binding) {
|
|
897
|
+
const state = el.__debounce;
|
|
898
|
+
if (!state) return;
|
|
899
|
+
const newOptions = normalizeOptions$h(binding.value, binding);
|
|
900
|
+
if (newOptions.wait !== state.options.wait || newOptions.leading !== state.options.leading || newOptions.trailing !== state.options.trailing) {
|
|
901
|
+
state.debouncedFn.cancel();
|
|
902
|
+
const debouncedFn = debounce(newOptions.handler, newOptions.wait, {
|
|
903
|
+
leading: newOptions.leading,
|
|
904
|
+
trailing: newOptions.trailing
|
|
905
|
+
});
|
|
906
|
+
el.removeEventListener(state.eventType, state.debouncedFn);
|
|
907
|
+
el.addEventListener(state.eventType, debouncedFn);
|
|
908
|
+
el.__debounce = {
|
|
909
|
+
debouncedFn,
|
|
910
|
+
eventType: state.eventType,
|
|
911
|
+
options: newOptions
|
|
912
|
+
};
|
|
913
|
+
} else if (newOptions.handler !== state.options.handler) {
|
|
914
|
+
state.options.handler = newOptions.handler;
|
|
915
|
+
}
|
|
916
|
+
},
|
|
917
|
+
unmounted(el) {
|
|
918
|
+
const state = el.__debounce;
|
|
919
|
+
if (!state) return;
|
|
920
|
+
state.debouncedFn.cancel();
|
|
921
|
+
el.removeEventListener(state.eventType, state.debouncedFn);
|
|
922
|
+
delete el.__debounce;
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
function normalizeOptions$h(binding, directiveBinding) {
|
|
926
|
+
const wait = parseTime(directiveBinding.arg) || 300;
|
|
927
|
+
if (typeof binding === "function") {
|
|
928
|
+
return { handler: binding, wait };
|
|
929
|
+
}
|
|
930
|
+
return __spreadProps(__spreadValues({}, binding), { wait: binding.wait || wait });
|
|
931
|
+
}
|
|
932
|
+
function getEventType$1(el) {
|
|
933
|
+
const tagName = el.tagName.toLowerCase();
|
|
934
|
+
if (tagName === "input" || tagName === "textarea") {
|
|
935
|
+
return "input";
|
|
936
|
+
}
|
|
937
|
+
return "click";
|
|
938
|
+
}
|
|
939
|
+
const EVENT_MODIFIERS$1 = [
|
|
940
|
+
"click",
|
|
941
|
+
"input",
|
|
942
|
+
"change",
|
|
943
|
+
"submit",
|
|
944
|
+
"scroll",
|
|
945
|
+
"resize",
|
|
946
|
+
"mouseenter",
|
|
947
|
+
"mouseleave",
|
|
948
|
+
"mousemove",
|
|
949
|
+
"mousedown",
|
|
950
|
+
"mouseup",
|
|
951
|
+
"keydown",
|
|
952
|
+
"keyup",
|
|
953
|
+
"focus",
|
|
954
|
+
"blur",
|
|
955
|
+
"touchstart",
|
|
956
|
+
"touchmove",
|
|
957
|
+
"touchend"
|
|
958
|
+
];
|
|
959
|
+
function getEventTypeFromModifiers$1(modifiers) {
|
|
960
|
+
for (const modifier of EVENT_MODIFIERS$1) {
|
|
961
|
+
if (modifiers[modifier]) {
|
|
962
|
+
return modifier;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return null;
|
|
966
|
+
}
|
|
967
|
+
const vThrottle = defineDirective({
|
|
968
|
+
name: "throttle",
|
|
969
|
+
ssr: true,
|
|
970
|
+
// SSR safe - event binding is skipped on server
|
|
971
|
+
defaults: {
|
|
972
|
+
wait: 300,
|
|
973
|
+
leading: true,
|
|
974
|
+
trailing: true
|
|
975
|
+
},
|
|
976
|
+
mounted(el, binding) {
|
|
977
|
+
const options = normalizeOptions$g(binding.value, binding);
|
|
978
|
+
const eventType = getEventTypeFromModifiers(binding.modifiers) || getEventType(el);
|
|
979
|
+
const throttledFn = throttle(options.handler, options.wait, {
|
|
980
|
+
leading: options.leading,
|
|
981
|
+
trailing: options.trailing
|
|
982
|
+
});
|
|
983
|
+
el.addEventListener(eventType, throttledFn);
|
|
984
|
+
el.__throttle = {
|
|
985
|
+
throttledFn,
|
|
986
|
+
eventType,
|
|
987
|
+
options
|
|
988
|
+
};
|
|
989
|
+
},
|
|
990
|
+
updated(el, binding) {
|
|
991
|
+
const state = el.__throttle;
|
|
992
|
+
if (!state) return;
|
|
993
|
+
const newOptions = normalizeOptions$g(binding.value, binding);
|
|
994
|
+
if (newOptions.wait !== state.options.wait || newOptions.leading !== state.options.leading || newOptions.trailing !== state.options.trailing) {
|
|
995
|
+
state.throttledFn.cancel();
|
|
996
|
+
const throttledFn = throttle(newOptions.handler, newOptions.wait, {
|
|
997
|
+
leading: newOptions.leading,
|
|
998
|
+
trailing: newOptions.trailing
|
|
999
|
+
});
|
|
1000
|
+
el.removeEventListener(state.eventType, state.throttledFn);
|
|
1001
|
+
el.addEventListener(state.eventType, throttledFn);
|
|
1002
|
+
el.__throttle = {
|
|
1003
|
+
throttledFn,
|
|
1004
|
+
eventType: state.eventType,
|
|
1005
|
+
options: newOptions
|
|
1006
|
+
};
|
|
1007
|
+
} else if (newOptions.handler !== state.options.handler) {
|
|
1008
|
+
state.options.handler = newOptions.handler;
|
|
1009
|
+
}
|
|
1010
|
+
},
|
|
1011
|
+
unmounted(el) {
|
|
1012
|
+
const state = el.__throttle;
|
|
1013
|
+
if (!state) return;
|
|
1014
|
+
state.throttledFn.cancel();
|
|
1015
|
+
el.removeEventListener(state.eventType, state.throttledFn);
|
|
1016
|
+
delete el.__throttle;
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
function normalizeOptions$g(binding, directiveBinding) {
|
|
1020
|
+
const wait = parseTime(directiveBinding.arg) || 300;
|
|
1021
|
+
if (typeof binding === "function") {
|
|
1022
|
+
return { handler: binding, wait };
|
|
1023
|
+
}
|
|
1024
|
+
return __spreadProps(__spreadValues({}, binding), { wait: binding.wait || wait });
|
|
1025
|
+
}
|
|
1026
|
+
function getEventType(el) {
|
|
1027
|
+
const tagName = el.tagName.toLowerCase();
|
|
1028
|
+
if (tagName === "input" || tagName === "textarea") {
|
|
1029
|
+
return "input";
|
|
1030
|
+
}
|
|
1031
|
+
return "click";
|
|
1032
|
+
}
|
|
1033
|
+
const EVENT_MODIFIERS = [
|
|
1034
|
+
"click",
|
|
1035
|
+
"input",
|
|
1036
|
+
"change",
|
|
1037
|
+
"submit",
|
|
1038
|
+
"scroll",
|
|
1039
|
+
"resize",
|
|
1040
|
+
"mouseenter",
|
|
1041
|
+
"mouseleave",
|
|
1042
|
+
"mousemove",
|
|
1043
|
+
"mousedown",
|
|
1044
|
+
"mouseup",
|
|
1045
|
+
"keydown",
|
|
1046
|
+
"keyup",
|
|
1047
|
+
"focus",
|
|
1048
|
+
"blur",
|
|
1049
|
+
"touchstart",
|
|
1050
|
+
"touchmove",
|
|
1051
|
+
"touchend"
|
|
1052
|
+
];
|
|
1053
|
+
function getEventTypeFromModifiers(modifiers) {
|
|
1054
|
+
for (const modifier of EVENT_MODIFIERS) {
|
|
1055
|
+
if (modifiers[modifier]) {
|
|
1056
|
+
return modifier;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return null;
|
|
1060
|
+
}
|
|
1061
|
+
const FOCUSABLE_TAGS = /* @__PURE__ */ new Set(["input", "textarea", "select", "button"]);
|
|
1062
|
+
function isEqual(a, b) {
|
|
1063
|
+
if (a === b) return true;
|
|
1064
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
1065
|
+
const objA = a;
|
|
1066
|
+
const objB = b;
|
|
1067
|
+
const keysA = Object.keys(objA);
|
|
1068
|
+
const keysB = Object.keys(objB);
|
|
1069
|
+
if (keysA.length !== keysB.length) return false;
|
|
1070
|
+
return keysA.every((key) => objA[key] === objB[key]);
|
|
1071
|
+
}
|
|
1072
|
+
const vFocus = defineDirective({
|
|
1073
|
+
name: "focus",
|
|
1074
|
+
ssr: true,
|
|
1075
|
+
// SSR safe - will skip focus on server
|
|
1076
|
+
defaults: {
|
|
1077
|
+
focus: true,
|
|
1078
|
+
refocus: false
|
|
1079
|
+
},
|
|
1080
|
+
mounted(el, binding) {
|
|
1081
|
+
if (!isBrowser()) return;
|
|
1082
|
+
const options = normalizeOptions$f(binding.value);
|
|
1083
|
+
if (!options.focus || !isFocusable(el)) {
|
|
1084
|
+
if (options.focus) {
|
|
1085
|
+
console.warn("[Directix] v-focus: Element is not focusable");
|
|
1086
|
+
}
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
const handleFocus = () => {
|
|
1090
|
+
var _a;
|
|
1091
|
+
return (_a = options.onFocus) == null ? void 0 : _a.call(options, el);
|
|
1092
|
+
};
|
|
1093
|
+
const handleBlur = () => {
|
|
1094
|
+
var _a;
|
|
1095
|
+
return (_a = options.onBlur) == null ? void 0 : _a.call(options, el);
|
|
1096
|
+
};
|
|
1097
|
+
el.addEventListener("focus", handleFocus);
|
|
1098
|
+
el.addEventListener("blur", handleBlur);
|
|
1099
|
+
el.__focus = {
|
|
1100
|
+
options,
|
|
1101
|
+
handleFocus,
|
|
1102
|
+
handleBlur,
|
|
1103
|
+
lastValue: binding.value
|
|
1104
|
+
};
|
|
1105
|
+
el.focus();
|
|
1106
|
+
},
|
|
1107
|
+
updated(el, binding) {
|
|
1108
|
+
const state = el.__focus;
|
|
1109
|
+
if (!state) return;
|
|
1110
|
+
const newOptions = normalizeOptions$f(binding.value);
|
|
1111
|
+
if (newOptions.onFocus !== state.options.onFocus) {
|
|
1112
|
+
el.removeEventListener("focus", state.handleFocus);
|
|
1113
|
+
state.handleFocus = () => {
|
|
1114
|
+
var _a;
|
|
1115
|
+
return (_a = newOptions.onFocus) == null ? void 0 : _a.call(newOptions, el);
|
|
1116
|
+
};
|
|
1117
|
+
el.addEventListener("focus", state.handleFocus);
|
|
1118
|
+
}
|
|
1119
|
+
if (newOptions.onBlur !== state.options.onBlur) {
|
|
1120
|
+
el.removeEventListener("blur", state.handleBlur);
|
|
1121
|
+
state.handleBlur = () => {
|
|
1122
|
+
var _a;
|
|
1123
|
+
return (_a = newOptions.onBlur) == null ? void 0 : _a.call(newOptions, el);
|
|
1124
|
+
};
|
|
1125
|
+
el.addEventListener("blur", state.handleBlur);
|
|
1126
|
+
}
|
|
1127
|
+
const valueChanged = !isEqual(binding.value, state.lastValue);
|
|
1128
|
+
if (newOptions.refocus && newOptions.focus && valueChanged) {
|
|
1129
|
+
el.focus();
|
|
1130
|
+
}
|
|
1131
|
+
state.options = newOptions;
|
|
1132
|
+
state.lastValue = binding.value;
|
|
1133
|
+
},
|
|
1134
|
+
unmounted(el) {
|
|
1135
|
+
const state = el.__focus;
|
|
1136
|
+
if (!state) return;
|
|
1137
|
+
el.removeEventListener("focus", state.handleFocus);
|
|
1138
|
+
el.removeEventListener("blur", state.handleBlur);
|
|
1139
|
+
delete el.__focus;
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
function normalizeOptions$f(binding) {
|
|
1143
|
+
if (typeof binding === "boolean") {
|
|
1144
|
+
return { focus: binding, refocus: false };
|
|
1145
|
+
}
|
|
1146
|
+
return __spreadValues({
|
|
1147
|
+
focus: true,
|
|
1148
|
+
refocus: false
|
|
1149
|
+
}, binding);
|
|
1150
|
+
}
|
|
1151
|
+
function isFocusable(el) {
|
|
1152
|
+
if (!isBrowser()) return false;
|
|
1153
|
+
const tagName = el.tagName.toLowerCase();
|
|
1154
|
+
if (FOCUSABLE_TAGS.has(tagName)) {
|
|
1155
|
+
return !el.disabled;
|
|
1156
|
+
}
|
|
1157
|
+
if (el.isContentEditable) return true;
|
|
1158
|
+
const tabindex = el.getAttribute("tabindex");
|
|
1159
|
+
if (tabindex != null) return tabindex !== "-1";
|
|
1160
|
+
if (tagName === "a" || tagName === "area") {
|
|
1161
|
+
return el.hasAttribute("href");
|
|
1162
|
+
}
|
|
1163
|
+
return false;
|
|
1164
|
+
}
|
|
1165
|
+
let globalObserver = null;
|
|
1166
|
+
function getGlobalObserver(preload) {
|
|
1167
|
+
if (globalObserver) return globalObserver;
|
|
1168
|
+
globalObserver = new IntersectionObserver(
|
|
1169
|
+
(entries) => {
|
|
1170
|
+
entries.forEach((entry) => {
|
|
1171
|
+
if (entry.isIntersecting) {
|
|
1172
|
+
load(entry.target);
|
|
1173
|
+
globalObserver == null ? void 0 : globalObserver.unobserve(entry.target);
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
rootMargin: `${preload}px`
|
|
1179
|
+
}
|
|
1180
|
+
);
|
|
1181
|
+
return globalObserver;
|
|
1182
|
+
}
|
|
1183
|
+
function setSrc(el, src) {
|
|
1184
|
+
if (el.tagName === "IMG") {
|
|
1185
|
+
el.src = src;
|
|
1186
|
+
} else {
|
|
1187
|
+
el.style.backgroundImage = `url("${src}")`;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
function setLazyState(el, state) {
|
|
1191
|
+
el.dataset.lazyState = state;
|
|
1192
|
+
}
|
|
1193
|
+
function getLazyState(el) {
|
|
1194
|
+
return el.dataset.lazyState || "pending";
|
|
1195
|
+
}
|
|
1196
|
+
function load(el) {
|
|
1197
|
+
const state = el.__lazy;
|
|
1198
|
+
if (!state || !state.options.src) return;
|
|
1199
|
+
if (state.options.filter && !state.options.filter(state.options.src)) {
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
setLazyState(el, "loading");
|
|
1203
|
+
state.attempt++;
|
|
1204
|
+
el.classList.add("v-lazy--loading");
|
|
1205
|
+
const img = new Image();
|
|
1206
|
+
img.onload = () => {
|
|
1207
|
+
var _a, _b;
|
|
1208
|
+
setSrc(el, state.options.src);
|
|
1209
|
+
setLazyState(el, "loaded");
|
|
1210
|
+
el.classList.remove("v-lazy--loading");
|
|
1211
|
+
el.classList.add("v-lazy--loaded");
|
|
1212
|
+
(_b = (_a = state.options).onLoad) == null ? void 0 : _b.call(_a, el);
|
|
1213
|
+
};
|
|
1214
|
+
img.onerror = () => {
|
|
1215
|
+
var _a, _b;
|
|
1216
|
+
el.classList.remove("v-lazy--loading");
|
|
1217
|
+
if (state.attempt < (state.options.attempt || 1)) {
|
|
1218
|
+
setTimeout(() => load(el), 1e3 * state.attempt);
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
if (state.options.error) {
|
|
1222
|
+
setSrc(el, state.options.error);
|
|
1223
|
+
}
|
|
1224
|
+
setLazyState(el, "error");
|
|
1225
|
+
el.classList.add("v-lazy--error");
|
|
1226
|
+
(_b = (_a = state.options).onError) == null ? void 0 : _b.call(_a, el, new Error("Failed to load image"));
|
|
1227
|
+
};
|
|
1228
|
+
img.src = state.options.src;
|
|
1229
|
+
}
|
|
1230
|
+
function observe(el) {
|
|
1231
|
+
const state = el.__lazy;
|
|
1232
|
+
if (!state) return;
|
|
1233
|
+
if (!supportsIntersectionObserver()) {
|
|
1234
|
+
load(el);
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
if (state.options.observer) {
|
|
1238
|
+
state.observer = state.options.observer;
|
|
1239
|
+
state.observer.observe(el);
|
|
1240
|
+
} else {
|
|
1241
|
+
const observer = getGlobalObserver(state.options.preload || 0);
|
|
1242
|
+
state.observer = observer;
|
|
1243
|
+
observer.observe(el);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
function unobserve(el) {
|
|
1247
|
+
const state = el.__lazy;
|
|
1248
|
+
if (!state) return;
|
|
1249
|
+
if (state.observer) {
|
|
1250
|
+
state.observer.unobserve(el);
|
|
1251
|
+
} else if (globalObserver) {
|
|
1252
|
+
globalObserver.unobserve(el);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
function normalizeOptions$e(binding) {
|
|
1256
|
+
if (typeof binding === "string") {
|
|
1257
|
+
return { src: binding };
|
|
1258
|
+
}
|
|
1259
|
+
return binding || {};
|
|
1260
|
+
}
|
|
1261
|
+
const vLazy = defineDirective({
|
|
1262
|
+
name: "lazy",
|
|
1263
|
+
ssr: false,
|
|
1264
|
+
defaults: {
|
|
1265
|
+
preload: 0,
|
|
1266
|
+
attempt: 1,
|
|
1267
|
+
disabled: false
|
|
1268
|
+
},
|
|
1269
|
+
mounted(el, binding) {
|
|
1270
|
+
const options = normalizeOptions$e(binding.value);
|
|
1271
|
+
if (options.disabled) return;
|
|
1272
|
+
if (!options.src) {
|
|
1273
|
+
console.warn("[Directix] v-lazy: No source provided");
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
setLazyState(el, "pending");
|
|
1277
|
+
if (options.placeholder) {
|
|
1278
|
+
setSrc(el, options.placeholder);
|
|
1279
|
+
}
|
|
1280
|
+
el.classList.add("v-lazy");
|
|
1281
|
+
const state = {
|
|
1282
|
+
options,
|
|
1283
|
+
attempt: 0
|
|
1284
|
+
};
|
|
1285
|
+
el.__lazy = state;
|
|
1286
|
+
observe(el);
|
|
1287
|
+
},
|
|
1288
|
+
updated(el, binding) {
|
|
1289
|
+
const state = el.__lazy;
|
|
1290
|
+
if (!state) return;
|
|
1291
|
+
const newOptions = normalizeOptions$e(binding.value);
|
|
1292
|
+
if (newOptions.disabled) {
|
|
1293
|
+
unobserve(el);
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
if (newOptions.src !== state.options.src) {
|
|
1297
|
+
state.options = newOptions;
|
|
1298
|
+
state.attempt = 0;
|
|
1299
|
+
if (getLazyState(el) !== "pending") {
|
|
1300
|
+
setLazyState(el, "pending");
|
|
1301
|
+
el.classList.remove("v-lazy--loaded", "v-lazy--error");
|
|
1302
|
+
if (newOptions.placeholder) {
|
|
1303
|
+
setSrc(el, newOptions.placeholder);
|
|
1304
|
+
}
|
|
1305
|
+
observe(el);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
},
|
|
1309
|
+
unmounted(el) {
|
|
1310
|
+
unobserve(el);
|
|
1311
|
+
delete el.__lazy;
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
const STATE_KEY$3 = "__intersect";
|
|
1315
|
+
function normalizeOptions$d(binding) {
|
|
1316
|
+
const options = typeof binding === "function" ? { handler: binding } : __spreadValues({}, binding);
|
|
1317
|
+
if (options.root !== null && typeof options.root === "object" && "value" in options.root) {
|
|
1318
|
+
options.root = options.root.value;
|
|
1319
|
+
}
|
|
1320
|
+
return options;
|
|
1321
|
+
}
|
|
1322
|
+
function createObserverCallback(el, state, options) {
|
|
1323
|
+
return (entries) => {
|
|
1324
|
+
var _a, _b, _c, _d;
|
|
1325
|
+
for (const entry of entries) {
|
|
1326
|
+
if (options.once && state.hasTriggeredOnce) continue;
|
|
1327
|
+
const { isIntersecting } = entry;
|
|
1328
|
+
(_a = options.handler) == null ? void 0 : _a.call(options, entry, state.observer);
|
|
1329
|
+
(_b = options.onChange) == null ? void 0 : _b.call(options, isIntersecting, entry);
|
|
1330
|
+
if (isIntersecting) {
|
|
1331
|
+
(_c = options.onEnter) == null ? void 0 : _c.call(options, entry, state.observer);
|
|
1332
|
+
if (options.once) state.hasTriggeredOnce = true;
|
|
1333
|
+
} else {
|
|
1334
|
+
(_d = options.onLeave) == null ? void 0 : _d.call(options, entry, state.observer);
|
|
1335
|
+
}
|
|
1336
|
+
el.dispatchEvent(new CustomEvent("intersect", { detail: { isIntersecting, entry } }));
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
function createObserver(el, state, options) {
|
|
1341
|
+
return new IntersectionObserver(createObserverCallback(el, state, options), {
|
|
1342
|
+
root: options.root,
|
|
1343
|
+
rootMargin: options.rootMargin,
|
|
1344
|
+
threshold: options.threshold
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
const vIntersect = defineDirective({
|
|
1348
|
+
name: "intersect",
|
|
1349
|
+
ssr: false,
|
|
1350
|
+
defaults: {
|
|
1351
|
+
disabled: false,
|
|
1352
|
+
once: false,
|
|
1353
|
+
rootMargin: "0px",
|
|
1354
|
+
threshold: 0
|
|
1355
|
+
},
|
|
1356
|
+
mounted(el, binding) {
|
|
1357
|
+
const options = normalizeOptions$d(binding.value);
|
|
1358
|
+
if (options.disabled || !isBrowser() || !supportsIntersectionObserver()) {
|
|
1359
|
+
if (!supportsIntersectionObserver()) {
|
|
1360
|
+
console.warn("[Directix] v-intersect: IntersectionObserver not supported");
|
|
1361
|
+
}
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
const state = {
|
|
1365
|
+
options,
|
|
1366
|
+
observer: null,
|
|
1367
|
+
hasTriggeredOnce: false
|
|
1368
|
+
};
|
|
1369
|
+
state.observer = createObserver(el, state, options);
|
|
1370
|
+
el[STATE_KEY$3] = state;
|
|
1371
|
+
state.observer.observe(el);
|
|
1372
|
+
},
|
|
1373
|
+
updated(el, binding) {
|
|
1374
|
+
var _a, _b, _c;
|
|
1375
|
+
const state = el[STATE_KEY$3];
|
|
1376
|
+
if (!state) return;
|
|
1377
|
+
const newOptions = normalizeOptions$d(binding.value);
|
|
1378
|
+
const observerOptionsChanged = newOptions.root !== state.options.root || newOptions.rootMargin !== state.options.rootMargin || newOptions.threshold !== state.options.threshold;
|
|
1379
|
+
if (newOptions.disabled !== state.options.disabled) {
|
|
1380
|
+
if (newOptions.disabled) {
|
|
1381
|
+
(_a = state.observer) == null ? void 0 : _a.disconnect();
|
|
1382
|
+
} else {
|
|
1383
|
+
(_b = state.observer) == null ? void 0 : _b.observe(el);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
if (observerOptionsChanged) {
|
|
1387
|
+
(_c = state.observer) == null ? void 0 : _c.disconnect();
|
|
1388
|
+
state.observer = createObserver(el, state, newOptions);
|
|
1389
|
+
state.observer.observe(el);
|
|
1390
|
+
}
|
|
1391
|
+
state.options = newOptions;
|
|
1392
|
+
},
|
|
1393
|
+
unmounted(el) {
|
|
1394
|
+
var _a;
|
|
1395
|
+
const state = el[STATE_KEY$3];
|
|
1396
|
+
if (!state) return;
|
|
1397
|
+
(_a = state.observer) == null ? void 0 : _a.disconnect();
|
|
1398
|
+
delete el[STATE_KEY$3];
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1401
|
+
function normalizeOptions$c(binding) {
|
|
1402
|
+
if (typeof binding === "boolean") {
|
|
1403
|
+
return { initial: binding };
|
|
1404
|
+
}
|
|
1405
|
+
return __spreadValues({
|
|
1406
|
+
initial: true,
|
|
1407
|
+
disabled: false,
|
|
1408
|
+
useHidden: false
|
|
1409
|
+
}, binding);
|
|
1410
|
+
}
|
|
1411
|
+
const vVisible = defineDirective({
|
|
1412
|
+
name: "visible",
|
|
1413
|
+
ssr: true,
|
|
1414
|
+
// SSR safe - will set initial visibility on server
|
|
1415
|
+
defaults: {
|
|
1416
|
+
initial: true,
|
|
1417
|
+
disabled: false,
|
|
1418
|
+
useHidden: false
|
|
1419
|
+
},
|
|
1420
|
+
mounted(el, binding) {
|
|
1421
|
+
var _a, _b;
|
|
1422
|
+
if (!isBrowser()) return;
|
|
1423
|
+
const options = normalizeOptions$c(binding.value);
|
|
1424
|
+
const originalDisplay = el.style.display;
|
|
1425
|
+
const originalVisibility = el.style.visibility;
|
|
1426
|
+
const state = {
|
|
1427
|
+
options,
|
|
1428
|
+
isVisible: (_a = options.initial) != null ? _a : true,
|
|
1429
|
+
originalDisplay,
|
|
1430
|
+
originalVisibility,
|
|
1431
|
+
transitionEndHandler: (e) => {
|
|
1432
|
+
if (e.propertyName === "opacity" || e.propertyName === "visibility") {
|
|
1433
|
+
el.dispatchEvent(new CustomEvent("visible:transition-end", {
|
|
1434
|
+
detail: { isVisible: state.isVisible }
|
|
1435
|
+
}));
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
el.__visible = state;
|
|
1440
|
+
on(el, "transitionend", state.transitionEndHandler);
|
|
1441
|
+
applyVisibility(el, state, (_b = options.initial) != null ? _b : true);
|
|
1442
|
+
},
|
|
1443
|
+
updated(el, binding) {
|
|
1444
|
+
var _a;
|
|
1445
|
+
const state = el.__visible;
|
|
1446
|
+
if (!state) return;
|
|
1447
|
+
const newOptions = normalizeOptions$c(binding.value);
|
|
1448
|
+
let newVisibility;
|
|
1449
|
+
if (typeof binding.value === "boolean") {
|
|
1450
|
+
newVisibility = binding.value;
|
|
1451
|
+
} else {
|
|
1452
|
+
newVisibility = (_a = newOptions.initial) != null ? _a : true;
|
|
1453
|
+
}
|
|
1454
|
+
if (state.isVisible !== newVisibility) {
|
|
1455
|
+
applyVisibility(el, state, newVisibility);
|
|
1456
|
+
}
|
|
1457
|
+
state.options = newOptions;
|
|
1458
|
+
},
|
|
1459
|
+
unmounted(el) {
|
|
1460
|
+
const state = el.__visible;
|
|
1461
|
+
if (!state) return;
|
|
1462
|
+
off(el, "transitionend", state.transitionEndHandler);
|
|
1463
|
+
el.style.display = state.originalDisplay;
|
|
1464
|
+
el.style.visibility = state.originalVisibility;
|
|
1465
|
+
delete el.__visible;
|
|
1466
|
+
}
|
|
1467
|
+
});
|
|
1468
|
+
function applyVisibility(el, state, isVisible) {
|
|
1469
|
+
const previousVisibility = state.isVisible;
|
|
1470
|
+
state.isVisible = isVisible;
|
|
1471
|
+
if (isVisible) {
|
|
1472
|
+
el.classList.remove("v-hidden");
|
|
1473
|
+
el.classList.add("v-visible");
|
|
1474
|
+
} else {
|
|
1475
|
+
el.classList.remove("v-visible");
|
|
1476
|
+
el.classList.add("v-hidden");
|
|
1477
|
+
}
|
|
1478
|
+
if (state.options.useHidden) {
|
|
1479
|
+
if (isVisible) {
|
|
1480
|
+
el.style.visibility = state.originalVisibility || "visible";
|
|
1481
|
+
} else {
|
|
1482
|
+
const computedStyle = getComputedStyle(el);
|
|
1483
|
+
const hasTransition = computedStyle.transitionDuration !== "0s";
|
|
1484
|
+
if (hasTransition) {
|
|
1485
|
+
const handleTransitionEnd = (e) => {
|
|
1486
|
+
if (e.target === el && (e.propertyName === "opacity" || e.propertyName === "transform")) {
|
|
1487
|
+
if (!state.isVisible) {
|
|
1488
|
+
el.style.visibility = "hidden";
|
|
1489
|
+
}
|
|
1490
|
+
el.removeEventListener("transitionend", handleTransitionEnd);
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
el.addEventListener("transitionend", handleTransitionEnd);
|
|
1494
|
+
} else {
|
|
1495
|
+
el.style.visibility = "hidden";
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
} else {
|
|
1499
|
+
el.style.display = isVisible ? state.originalDisplay : "none";
|
|
1500
|
+
}
|
|
1501
|
+
el.dispatchEvent(new CustomEvent("visible:change", {
|
|
1502
|
+
detail: { isVisible, previousVisibility }
|
|
1503
|
+
}));
|
|
1504
|
+
if (state.options.handler && previousVisibility !== isVisible) {
|
|
1505
|
+
state.options.handler(isVisible);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
function normalizeOptions$b(binding) {
|
|
1509
|
+
if (typeof binding === "boolean") {
|
|
1510
|
+
return { value: binding };
|
|
1511
|
+
}
|
|
1512
|
+
return __spreadValues({
|
|
1513
|
+
value: true,
|
|
1514
|
+
loadingClass: "v-loading",
|
|
1515
|
+
spinnerClass: "v-loading__spinner",
|
|
1516
|
+
textClass: "v-loading__text",
|
|
1517
|
+
background: "rgba(255, 255, 255, 0.9)",
|
|
1518
|
+
lock: false,
|
|
1519
|
+
disabled: false
|
|
1520
|
+
}, binding);
|
|
1521
|
+
}
|
|
1522
|
+
const DEFAULT_SPINNER = `
|
|
1523
|
+
<svg class="v-loading__circular" viewBox="25 25 50 50">
|
|
1524
|
+
<circle class="v-loading__path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/>
|
|
1525
|
+
</svg>
|
|
1526
|
+
`;
|
|
1527
|
+
function createLoadingOverlay(options) {
|
|
1528
|
+
const overlay = document.createElement("div");
|
|
1529
|
+
overlay.className = options.loadingClass || "v-loading";
|
|
1530
|
+
overlay.style.cssText = `
|
|
1531
|
+
position: absolute;
|
|
1532
|
+
top: 0;
|
|
1533
|
+
left: 0;
|
|
1534
|
+
right: 0;
|
|
1535
|
+
bottom: 0;
|
|
1536
|
+
z-index: 1000;
|
|
1537
|
+
background: ${options.background || "rgba(255, 255, 255, 0.9)"};
|
|
1538
|
+
display: flex;
|
|
1539
|
+
flex-direction: column;
|
|
1540
|
+
align-items: center;
|
|
1541
|
+
justify-content: center;
|
|
1542
|
+
`;
|
|
1543
|
+
const spinnerHtml = options.spinner || DEFAULT_SPINNER;
|
|
1544
|
+
const spinnerContainer = document.createElement("div");
|
|
1545
|
+
spinnerContainer.className = options.spinnerClass || "v-loading__spinner";
|
|
1546
|
+
spinnerContainer.innerHTML = spinnerHtml;
|
|
1547
|
+
overlay.appendChild(spinnerContainer);
|
|
1548
|
+
if (options.text) {
|
|
1549
|
+
const textEl = document.createElement("div");
|
|
1550
|
+
textEl.className = options.textClass || "v-loading__text";
|
|
1551
|
+
textEl.textContent = options.text;
|
|
1552
|
+
overlay.appendChild(textEl);
|
|
1553
|
+
}
|
|
1554
|
+
return overlay;
|
|
1555
|
+
}
|
|
1556
|
+
const vLoading = defineDirective({
|
|
1557
|
+
name: "loading",
|
|
1558
|
+
ssr: true,
|
|
1559
|
+
// SSR safe - will skip DOM manipulation on server
|
|
1560
|
+
defaults: {
|
|
1561
|
+
value: true,
|
|
1562
|
+
loadingClass: "v-loading",
|
|
1563
|
+
spinnerClass: "v-loading__spinner",
|
|
1564
|
+
textClass: "v-loading__text",
|
|
1565
|
+
background: "rgba(255, 255, 255, 0.9)",
|
|
1566
|
+
lock: false,
|
|
1567
|
+
disabled: false
|
|
1568
|
+
},
|
|
1569
|
+
mounted(el, binding) {
|
|
1570
|
+
if (!isBrowser()) return;
|
|
1571
|
+
const options = normalizeOptions$b(binding.value);
|
|
1572
|
+
if (options.disabled) return;
|
|
1573
|
+
const computedStyle = getComputedStyle(el);
|
|
1574
|
+
const originalPosition = el.style.position;
|
|
1575
|
+
const originalOverflow = el.style.overflow;
|
|
1576
|
+
const state = {
|
|
1577
|
+
options,
|
|
1578
|
+
loadingOverlay: null,
|
|
1579
|
+
originalPosition,
|
|
1580
|
+
originalOverflow
|
|
1581
|
+
};
|
|
1582
|
+
el.__loading = state;
|
|
1583
|
+
if (computedStyle.position === "static") {
|
|
1584
|
+
el.style.position = "relative";
|
|
1585
|
+
}
|
|
1586
|
+
if (options.value) {
|
|
1587
|
+
showLoading(el, state);
|
|
1588
|
+
}
|
|
1589
|
+
},
|
|
1590
|
+
updated(el, binding) {
|
|
1591
|
+
const state = el.__loading;
|
|
1592
|
+
if (!state) return;
|
|
1593
|
+
const newOptions = normalizeOptions$b(binding.value);
|
|
1594
|
+
if (newOptions.disabled) {
|
|
1595
|
+
hideLoading(el, state);
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
if (newOptions.value && !state.options.value) {
|
|
1599
|
+
showLoading(el, state);
|
|
1600
|
+
} else if (!newOptions.value && state.options.value) {
|
|
1601
|
+
hideLoading(el, state);
|
|
1602
|
+
}
|
|
1603
|
+
if (state.loadingOverlay && newOptions.text !== state.options.text) {
|
|
1604
|
+
const textEl = state.loadingOverlay.querySelector(`.${state.options.textClass}`);
|
|
1605
|
+
if (textEl) {
|
|
1606
|
+
textEl.textContent = newOptions.text || "";
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
state.options = newOptions;
|
|
1610
|
+
},
|
|
1611
|
+
unmounted(el) {
|
|
1612
|
+
const state = el.__loading;
|
|
1613
|
+
if (!state) return;
|
|
1614
|
+
hideLoading(el, state);
|
|
1615
|
+
el.style.position = state.originalPosition;
|
|
1616
|
+
el.style.overflow = state.originalOverflow;
|
|
1617
|
+
delete el.__loading;
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
function showLoading(el, state) {
|
|
1621
|
+
if (state.loadingOverlay) return;
|
|
1622
|
+
state.loadingOverlay = createLoadingOverlay(state.options);
|
|
1623
|
+
el.appendChild(state.loadingOverlay);
|
|
1624
|
+
if (state.options.lock) {
|
|
1625
|
+
el.style.overflow = "hidden";
|
|
1626
|
+
}
|
|
1627
|
+
el.classList.add("v-loading--active");
|
|
1628
|
+
}
|
|
1629
|
+
function hideLoading(el, state) {
|
|
1630
|
+
if (!state.loadingOverlay) return;
|
|
1631
|
+
state.loadingOverlay.remove();
|
|
1632
|
+
state.loadingOverlay = null;
|
|
1633
|
+
if (state.options.lock) {
|
|
1634
|
+
el.style.overflow = state.originalOverflow;
|
|
1635
|
+
}
|
|
1636
|
+
el.classList.remove("v-loading--active");
|
|
1637
|
+
}
|
|
1638
|
+
function getScrollInfo(container, lastScrollLeft, lastScrollTop) {
|
|
1639
|
+
let scrollLeft = 0, scrollTop = 0, scrollLeftMax = 0, scrollTopMax = 0;
|
|
1640
|
+
if (container === window) {
|
|
1641
|
+
scrollLeft = window.scrollX || document.documentElement.scrollLeft;
|
|
1642
|
+
scrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
1643
|
+
scrollLeftMax = document.documentElement.scrollWidth - window.innerWidth;
|
|
1644
|
+
scrollTopMax = document.documentElement.scrollHeight - window.innerHeight;
|
|
1645
|
+
} else {
|
|
1646
|
+
const el = container;
|
|
1647
|
+
scrollLeft = el.scrollLeft;
|
|
1648
|
+
scrollTop = el.scrollTop;
|
|
1649
|
+
scrollLeftMax = el.scrollWidth - el.clientWidth;
|
|
1650
|
+
scrollTopMax = el.scrollHeight - el.clientHeight;
|
|
1651
|
+
}
|
|
1652
|
+
const progressX = scrollLeftMax > 0 ? scrollLeft / scrollLeftMax : 0;
|
|
1653
|
+
const progressY = scrollTopMax > 0 ? scrollTop / scrollTopMax : 0;
|
|
1654
|
+
const directionX = scrollLeft !== lastScrollLeft ? scrollLeft > lastScrollLeft ? 1 : -1 : 0;
|
|
1655
|
+
const directionY = scrollTop !== lastScrollTop ? scrollTop > lastScrollTop ? 1 : -1 : 0;
|
|
1656
|
+
return {
|
|
1657
|
+
scrollLeft,
|
|
1658
|
+
scrollTop,
|
|
1659
|
+
scrollLeftMax,
|
|
1660
|
+
scrollTopMax,
|
|
1661
|
+
progressX,
|
|
1662
|
+
progressY,
|
|
1663
|
+
directionX,
|
|
1664
|
+
directionY,
|
|
1665
|
+
container
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
function normalizeOptions$a(binding) {
|
|
1669
|
+
if (typeof binding === "function") {
|
|
1670
|
+
return { handler: binding, passive: true };
|
|
1671
|
+
}
|
|
1672
|
+
if (!binding) {
|
|
1673
|
+
throw new Error("[Directix] v-scroll: handler is required");
|
|
1674
|
+
}
|
|
1675
|
+
return __spreadValues({
|
|
1676
|
+
passive: true,
|
|
1677
|
+
throttle: 0,
|
|
1678
|
+
disabled: false
|
|
1679
|
+
}, binding);
|
|
1680
|
+
}
|
|
1681
|
+
const vScroll = defineDirective({
|
|
1682
|
+
name: "scroll",
|
|
1683
|
+
ssr: false,
|
|
1684
|
+
defaults: {
|
|
1685
|
+
passive: true,
|
|
1686
|
+
throttle: 0,
|
|
1687
|
+
disabled: false
|
|
1688
|
+
},
|
|
1689
|
+
mounted(el, binding) {
|
|
1690
|
+
const options = normalizeOptions$a(binding.value);
|
|
1691
|
+
if (options.disabled || !isBrowser()) return;
|
|
1692
|
+
let container;
|
|
1693
|
+
if (options.container) {
|
|
1694
|
+
if (options.container === window) {
|
|
1695
|
+
container = window;
|
|
1696
|
+
} else if (typeof options.container === "string") {
|
|
1697
|
+
const found = document.querySelector(options.container);
|
|
1698
|
+
container = found || getScrollParent(el);
|
|
1699
|
+
} else {
|
|
1700
|
+
container = options.container;
|
|
1701
|
+
}
|
|
1702
|
+
} else {
|
|
1703
|
+
const { overflow, overflowX, overflowY } = getComputedStyle(el);
|
|
1704
|
+
const isSelfScrollable = /(auto|scroll)/.test(overflow + overflowX + overflowY);
|
|
1705
|
+
container = isSelfScrollable ? el : getScrollParent(el);
|
|
1706
|
+
}
|
|
1707
|
+
const state = {
|
|
1708
|
+
options,
|
|
1709
|
+
container,
|
|
1710
|
+
lastScrollLeft: 0,
|
|
1711
|
+
lastScrollTop: 0,
|
|
1712
|
+
throttleTimer: null,
|
|
1713
|
+
pendingEvent: null,
|
|
1714
|
+
scrollHandler: (e) => {
|
|
1715
|
+
if (options.throttle && options.throttle > 0) {
|
|
1716
|
+
state.pendingEvent = e;
|
|
1717
|
+
if (!state.throttleTimer) {
|
|
1718
|
+
state.throttleTimer = setTimeout(() => {
|
|
1719
|
+
if (state.pendingEvent) {
|
|
1720
|
+
const info = getScrollInfo(container, state.lastScrollLeft, state.lastScrollTop);
|
|
1721
|
+
state.lastScrollLeft = info.scrollLeft;
|
|
1722
|
+
state.lastScrollTop = info.scrollTop;
|
|
1723
|
+
options.handler(state.pendingEvent, info);
|
|
1724
|
+
}
|
|
1725
|
+
state.throttleTimer = null;
|
|
1726
|
+
state.pendingEvent = null;
|
|
1727
|
+
}, options.throttle);
|
|
1728
|
+
}
|
|
1729
|
+
} else {
|
|
1730
|
+
const info = getScrollInfo(container, state.lastScrollLeft, state.lastScrollTop);
|
|
1731
|
+
state.lastScrollLeft = info.scrollLeft;
|
|
1732
|
+
state.lastScrollTop = info.scrollTop;
|
|
1733
|
+
options.handler(e, info);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
};
|
|
1737
|
+
const initialInfo = getScrollInfo(container, 0, 0);
|
|
1738
|
+
state.lastScrollLeft = initialInfo.scrollLeft;
|
|
1739
|
+
state.lastScrollTop = initialInfo.scrollTop;
|
|
1740
|
+
el.__scroll = state;
|
|
1741
|
+
on(container, "scroll", state.scrollHandler, { passive: options.passive });
|
|
1742
|
+
},
|
|
1743
|
+
updated(el, binding) {
|
|
1744
|
+
const state = el.__scroll;
|
|
1745
|
+
if (!state) return;
|
|
1746
|
+
state.options = normalizeOptions$a(binding.value);
|
|
1747
|
+
},
|
|
1748
|
+
unmounted(el) {
|
|
1749
|
+
const state = el.__scroll;
|
|
1750
|
+
if (!state) return;
|
|
1751
|
+
if (state.throttleTimer) {
|
|
1752
|
+
clearTimeout(state.throttleTimer);
|
|
1753
|
+
}
|
|
1754
|
+
off(state.container, "scroll", state.scrollHandler);
|
|
1755
|
+
delete el.__scroll;
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
function normalizeOptions$9(binding) {
|
|
1759
|
+
if (typeof binding === "function") {
|
|
1760
|
+
return { handler: binding, distance: 0, throttle: 200, useIntersection: true };
|
|
1761
|
+
}
|
|
1762
|
+
if (!binding) {
|
|
1763
|
+
throw new Error("[Directix] v-infinite-scroll: handler is required");
|
|
1764
|
+
}
|
|
1765
|
+
return __spreadValues({
|
|
1766
|
+
distance: 0,
|
|
1767
|
+
disabled: false,
|
|
1768
|
+
loading: false,
|
|
1769
|
+
useIntersection: true,
|
|
1770
|
+
throttle: 200
|
|
1771
|
+
}, binding);
|
|
1772
|
+
}
|
|
1773
|
+
const vInfiniteScroll = defineDirective({
|
|
1774
|
+
name: "infinite-scroll",
|
|
1775
|
+
ssr: false,
|
|
1776
|
+
defaults: {
|
|
1777
|
+
distance: 0,
|
|
1778
|
+
disabled: false,
|
|
1779
|
+
loading: false,
|
|
1780
|
+
useIntersection: true,
|
|
1781
|
+
throttle: 200
|
|
1782
|
+
},
|
|
1783
|
+
mounted(el, binding) {
|
|
1784
|
+
const options = normalizeOptions$9(binding.value);
|
|
1785
|
+
if (options.disabled || !isBrowser()) return;
|
|
1786
|
+
let container;
|
|
1787
|
+
if (options.container) {
|
|
1788
|
+
if (typeof options.container === "string") {
|
|
1789
|
+
const found = document.querySelector(options.container);
|
|
1790
|
+
container = found || getScrollParent(el);
|
|
1791
|
+
} else {
|
|
1792
|
+
container = options.container;
|
|
1793
|
+
}
|
|
1794
|
+
} else {
|
|
1795
|
+
container = getScrollParent(el);
|
|
1796
|
+
}
|
|
1797
|
+
const state = {
|
|
1798
|
+
options,
|
|
1799
|
+
container,
|
|
1800
|
+
sentinel: null,
|
|
1801
|
+
observer: null,
|
|
1802
|
+
throttleTimer: null,
|
|
1803
|
+
isLoading: false,
|
|
1804
|
+
scrollHandler: (_e) => __async(null, null, function* () {
|
|
1805
|
+
if (state.isLoading || state.options.disabled || state.options.loading) {
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
if (state.throttleTimer) {
|
|
1809
|
+
return;
|
|
1810
|
+
}
|
|
1811
|
+
state.throttleTimer = setTimeout(() => {
|
|
1812
|
+
state.throttleTimer = null;
|
|
1813
|
+
}, options.throttle);
|
|
1814
|
+
const shouldLoad = checkShouldLoad(container, el, options.distance || 0);
|
|
1815
|
+
if (shouldLoad) {
|
|
1816
|
+
yield triggerLoad(state, el);
|
|
1817
|
+
}
|
|
1818
|
+
})
|
|
1819
|
+
};
|
|
1820
|
+
el.__infiniteScroll = state;
|
|
1821
|
+
if (options.useIntersection && supportsIntersectionObserver()) {
|
|
1822
|
+
setupIntersectionObserver(el, state);
|
|
1823
|
+
} else {
|
|
1824
|
+
on(container, "scroll", state.scrollHandler, { passive: true });
|
|
1825
|
+
}
|
|
1826
|
+
},
|
|
1827
|
+
updated(el, binding) {
|
|
1828
|
+
const state = el.__infiniteScroll;
|
|
1829
|
+
if (!state) return;
|
|
1830
|
+
state.options = normalizeOptions$9(binding.value);
|
|
1831
|
+
},
|
|
1832
|
+
unmounted(el) {
|
|
1833
|
+
const state = el.__infiniteScroll;
|
|
1834
|
+
if (!state) return;
|
|
1835
|
+
if (state.throttleTimer) {
|
|
1836
|
+
clearTimeout(state.throttleTimer);
|
|
1837
|
+
}
|
|
1838
|
+
if (state.observer) {
|
|
1839
|
+
state.observer.disconnect();
|
|
1840
|
+
}
|
|
1841
|
+
if (state.sentinel && state.sentinel.parentNode) {
|
|
1842
|
+
state.sentinel.parentNode.removeChild(state.sentinel);
|
|
1843
|
+
}
|
|
1844
|
+
off(state.container, "scroll", state.scrollHandler);
|
|
1845
|
+
delete el.__infiniteScroll;
|
|
1846
|
+
}
|
|
1847
|
+
});
|
|
1848
|
+
function checkShouldLoad(container, _el, distance) {
|
|
1849
|
+
if (container === window) {
|
|
1850
|
+
const scrollTop2 = window.scrollY || document.documentElement.scrollTop;
|
|
1851
|
+
const scrollHeight2 = document.documentElement.scrollHeight;
|
|
1852
|
+
const clientHeight2 = window.innerHeight;
|
|
1853
|
+
return scrollTop2 + clientHeight2 >= scrollHeight2 - distance;
|
|
1854
|
+
}
|
|
1855
|
+
const el = container;
|
|
1856
|
+
const scrollTop = el.scrollTop;
|
|
1857
|
+
const scrollHeight = el.scrollHeight;
|
|
1858
|
+
const clientHeight = el.clientHeight;
|
|
1859
|
+
return scrollTop + clientHeight >= scrollHeight - distance;
|
|
1860
|
+
}
|
|
1861
|
+
function triggerLoad(state, el) {
|
|
1862
|
+
return __async(this, null, function* () {
|
|
1863
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1864
|
+
state.isLoading = true;
|
|
1865
|
+
(_b = (_a = state.options).onLoadStart) == null ? void 0 : _b.call(_a);
|
|
1866
|
+
el.classList.add("v-infinite-scroll--loading");
|
|
1867
|
+
try {
|
|
1868
|
+
yield state.options.handler();
|
|
1869
|
+
} catch (err) {
|
|
1870
|
+
(_d = (_c = state.options).onError) == null ? void 0 : _d.call(_c, err);
|
|
1871
|
+
} finally {
|
|
1872
|
+
state.isLoading = false;
|
|
1873
|
+
(_f = (_e = state.options).onLoadEnd) == null ? void 0 : _f.call(_e);
|
|
1874
|
+
el.classList.remove("v-infinite-scroll--loading");
|
|
1875
|
+
}
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
function setupIntersectionObserver(el, state) {
|
|
1879
|
+
const sentinel = document.createElement("div");
|
|
1880
|
+
sentinel.className = "v-infinite-scroll__sentinel";
|
|
1881
|
+
sentinel.style.cssText = `
|
|
1882
|
+
height: 1px;
|
|
1883
|
+
width: 100%;
|
|
1884
|
+
clear: both;
|
|
1885
|
+
`;
|
|
1886
|
+
el.appendChild(sentinel);
|
|
1887
|
+
state.sentinel = sentinel;
|
|
1888
|
+
state.observer = new IntersectionObserver(
|
|
1889
|
+
(entries) => __async(null, null, function* () {
|
|
1890
|
+
for (const entry of entries) {
|
|
1891
|
+
if (entry.isIntersecting) {
|
|
1892
|
+
if (!state.isLoading && !state.options.disabled && !state.options.loading) {
|
|
1893
|
+
yield triggerLoad(state, el);
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
}),
|
|
1898
|
+
{
|
|
1899
|
+
root: state.container === window ? null : state.container,
|
|
1900
|
+
rootMargin: `${state.options.distance || 0}px`,
|
|
1901
|
+
threshold: 0
|
|
1902
|
+
}
|
|
1903
|
+
);
|
|
1904
|
+
state.observer.observe(sentinel);
|
|
1905
|
+
}
|
|
1906
|
+
const STATE_KEY$2 = "__sticky";
|
|
1907
|
+
function normalizeOptions$8(binding) {
|
|
1908
|
+
if (binding === false) return { disabled: true, top: 0, zIndex: 100 };
|
|
1909
|
+
if (typeof binding === "number") return { top: binding, zIndex: 100 };
|
|
1910
|
+
return __spreadValues({
|
|
1911
|
+
top: 0,
|
|
1912
|
+
zIndex: 100,
|
|
1913
|
+
stickyClass: "v-sticky--fixed",
|
|
1914
|
+
disabled: false
|
|
1915
|
+
}, binding && typeof binding === "object" ? binding : {});
|
|
1916
|
+
}
|
|
1917
|
+
function parseOffset(value) {
|
|
1918
|
+
if (value === void 0) return "0";
|
|
1919
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
1920
|
+
}
|
|
1921
|
+
function getScrollContainer(el, customContainer) {
|
|
1922
|
+
if (customContainer) {
|
|
1923
|
+
if (typeof customContainer === "string") {
|
|
1924
|
+
return document.querySelector(customContainer) || getScrollParent(el);
|
|
1925
|
+
}
|
|
1926
|
+
return customContainer;
|
|
1927
|
+
}
|
|
1928
|
+
const parent = el.parentElement;
|
|
1929
|
+
if (parent) {
|
|
1930
|
+
const { overflow, overflowX, overflowY } = getComputedStyle(parent);
|
|
1931
|
+
if (/(auto|scroll)/.test(overflow + overflowX + overflowY)) {
|
|
1932
|
+
return parent;
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
return getScrollParent(el);
|
|
1936
|
+
}
|
|
1937
|
+
function checkSticky(el, state) {
|
|
1938
|
+
if (state.options.disabled) {
|
|
1939
|
+
unsetSticky(el, state);
|
|
1940
|
+
return;
|
|
1941
|
+
}
|
|
1942
|
+
const topOffset = Number.parseFloat(parseOffset(state.options.top));
|
|
1943
|
+
const containerRect = state.container === window ? { top: 0 } : state.container.getBoundingClientRect();
|
|
1944
|
+
const referenceEl = state.placeholder || el;
|
|
1945
|
+
const rect = referenceEl.getBoundingClientRect();
|
|
1946
|
+
const elementTopRelativeToContainer = rect.top - containerRect.top;
|
|
1947
|
+
const shouldSticky = elementTopRelativeToContainer <= topOffset;
|
|
1948
|
+
if (shouldSticky && !state.isSticky) {
|
|
1949
|
+
setSticky(el, state, topOffset, containerRect.top);
|
|
1950
|
+
} else if (!shouldSticky && state.isSticky) {
|
|
1951
|
+
unsetSticky(el, state);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
function setSticky(el, state, topOffset, containerTop) {
|
|
1955
|
+
var _a, _b, _c;
|
|
1956
|
+
state.isSticky = true;
|
|
1957
|
+
const placeholder = document.createElement("div");
|
|
1958
|
+
placeholder.style.cssText = `width:${el.offsetWidth}px;height:${el.offsetHeight}px`;
|
|
1959
|
+
(_a = el.parentNode) == null ? void 0 : _a.insertBefore(placeholder, el);
|
|
1960
|
+
state.placeholder = placeholder;
|
|
1961
|
+
const fixedTop = state.container === window ? topOffset : containerTop + topOffset;
|
|
1962
|
+
el.style.position = "fixed";
|
|
1963
|
+
el.style.top = `${fixedTop}px`;
|
|
1964
|
+
el.style.zIndex = String(state.options.zIndex || 100);
|
|
1965
|
+
el.style.width = `${el.offsetWidth}px`;
|
|
1966
|
+
if (state.options.bottom !== void 0) {
|
|
1967
|
+
el.style.bottom = parseOffset(state.options.bottom);
|
|
1968
|
+
}
|
|
1969
|
+
state.options.stickyClass && el.classList.add(state.options.stickyClass);
|
|
1970
|
+
el.dispatchEvent(new CustomEvent("sticky:change", { detail: { isSticky: true } }));
|
|
1971
|
+
(_c = (_b = state.options).onChange) == null ? void 0 : _c.call(_b, true);
|
|
1972
|
+
}
|
|
1973
|
+
function unsetSticky(el, state) {
|
|
1974
|
+
var _a, _b, _c, _d;
|
|
1975
|
+
if (!state.isSticky) return;
|
|
1976
|
+
state.isSticky = false;
|
|
1977
|
+
(_b = (_a = state.placeholder) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.removeChild(state.placeholder);
|
|
1978
|
+
state.placeholder = null;
|
|
1979
|
+
Object.assign(el.style, state.originalStyles);
|
|
1980
|
+
state.options.stickyClass && el.classList.remove(state.options.stickyClass);
|
|
1981
|
+
el.dispatchEvent(new CustomEvent("sticky:change", { detail: { isSticky: false } }));
|
|
1982
|
+
(_d = (_c = state.options).onChange) == null ? void 0 : _d.call(_c, false);
|
|
1983
|
+
}
|
|
1984
|
+
const vSticky = defineDirective({
|
|
1985
|
+
name: "sticky",
|
|
1986
|
+
ssr: false,
|
|
1987
|
+
defaults: { top: 0, zIndex: 100, stickyClass: "v-sticky--fixed", disabled: false },
|
|
1988
|
+
mounted(el, binding) {
|
|
1989
|
+
const options = normalizeOptions$8(binding.value);
|
|
1990
|
+
if (options.disabled || !isBrowser()) return;
|
|
1991
|
+
const container = getScrollContainer(el, options.container);
|
|
1992
|
+
const state = {
|
|
1993
|
+
options,
|
|
1994
|
+
placeholder: null,
|
|
1995
|
+
originalStyles: {
|
|
1996
|
+
position: el.style.position,
|
|
1997
|
+
top: el.style.top,
|
|
1998
|
+
bottom: el.style.bottom,
|
|
1999
|
+
zIndex: el.style.zIndex,
|
|
2000
|
+
width: el.style.width
|
|
2001
|
+
},
|
|
2002
|
+
isSticky: false,
|
|
2003
|
+
container,
|
|
2004
|
+
scrollHandler: () => checkSticky(el, state),
|
|
2005
|
+
resizeHandler: () => checkSticky(el, state)
|
|
2006
|
+
};
|
|
2007
|
+
el.classList.add("v-sticky");
|
|
2008
|
+
el[STATE_KEY$2] = state;
|
|
2009
|
+
on(container, "scroll", state.scrollHandler, { passive: true });
|
|
2010
|
+
on(window, "resize", state.resizeHandler, { passive: true });
|
|
2011
|
+
checkSticky(el, state);
|
|
2012
|
+
},
|
|
2013
|
+
updated(el, binding) {
|
|
2014
|
+
const state = el[STATE_KEY$2];
|
|
2015
|
+
if (!state) return;
|
|
2016
|
+
state.options = normalizeOptions$8(binding.value);
|
|
2017
|
+
checkSticky(el, state);
|
|
2018
|
+
},
|
|
2019
|
+
unmounted(el) {
|
|
2020
|
+
var _a, _b;
|
|
2021
|
+
const state = el[STATE_KEY$2];
|
|
2022
|
+
if (!state) return;
|
|
2023
|
+
(_b = (_a = state.placeholder) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.removeChild(state.placeholder);
|
|
2024
|
+
Object.assign(el.style, state.originalStyles);
|
|
2025
|
+
el.classList.remove("v-sticky", state.options.stickyClass || "v-sticky--fixed");
|
|
2026
|
+
off(state.container, "scroll", state.scrollHandler);
|
|
2027
|
+
off(window, "resize", state.resizeHandler);
|
|
2028
|
+
delete el[STATE_KEY$2];
|
|
2029
|
+
}
|
|
2030
|
+
});
|
|
2031
|
+
function normalizeOptions$7(binding) {
|
|
2032
|
+
if (typeof binding === "function") {
|
|
2033
|
+
return { handler: binding, duration: 500, distance: 10 };
|
|
2034
|
+
}
|
|
2035
|
+
if (!binding) {
|
|
2036
|
+
throw new Error("[Directix] v-long-press: handler is required");
|
|
2037
|
+
}
|
|
2038
|
+
return __spreadValues({
|
|
2039
|
+
duration: 500,
|
|
2040
|
+
distance: 10,
|
|
2041
|
+
disabled: false,
|
|
2042
|
+
prevent: true,
|
|
2043
|
+
stop: false,
|
|
2044
|
+
tickInterval: 100
|
|
2045
|
+
}, binding);
|
|
2046
|
+
}
|
|
2047
|
+
function getDistance(p1, p2) {
|
|
2048
|
+
return Math.sqrt(__pow(p2.x - p1.x, 2) + __pow(p2.y - p1.y, 2));
|
|
2049
|
+
}
|
|
2050
|
+
const vLongPress = defineDirective({
|
|
2051
|
+
name: "long-press",
|
|
2052
|
+
ssr: false,
|
|
2053
|
+
defaults: {
|
|
2054
|
+
duration: 500,
|
|
2055
|
+
distance: 10,
|
|
2056
|
+
disabled: false,
|
|
2057
|
+
prevent: true,
|
|
2058
|
+
stop: false,
|
|
2059
|
+
tickInterval: 100
|
|
2060
|
+
},
|
|
2061
|
+
mounted(el, binding) {
|
|
2062
|
+
const options = normalizeOptions$7(binding.value);
|
|
2063
|
+
if (options.disabled || !isBrowser()) return;
|
|
2064
|
+
const state = {
|
|
2065
|
+
options,
|
|
2066
|
+
timerId: null,
|
|
2067
|
+
tickTimerId: null,
|
|
2068
|
+
startTime: 0,
|
|
2069
|
+
startPos: { x: 0, y: 0 },
|
|
2070
|
+
startHandler: () => {
|
|
2071
|
+
},
|
|
2072
|
+
endHandler: () => {
|
|
2073
|
+
},
|
|
2074
|
+
moveHandler: () => {
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
state.startHandler = (e) => {
|
|
2078
|
+
var _a;
|
|
2079
|
+
const event = e;
|
|
2080
|
+
if (options.prevent) {
|
|
2081
|
+
event.preventDefault();
|
|
2082
|
+
}
|
|
2083
|
+
if (options.stop) {
|
|
2084
|
+
event.stopPropagation();
|
|
2085
|
+
}
|
|
2086
|
+
if (state.timerId) {
|
|
2087
|
+
clearTimeout(state.timerId);
|
|
2088
|
+
state.timerId = null;
|
|
2089
|
+
}
|
|
2090
|
+
if (state.tickTimerId) {
|
|
2091
|
+
clearInterval(state.tickTimerId);
|
|
2092
|
+
state.tickTimerId = null;
|
|
2093
|
+
}
|
|
2094
|
+
const pos = getEventPosition(event);
|
|
2095
|
+
state.startPos = { x: pos.x, y: pos.y };
|
|
2096
|
+
state.startTime = Date.now();
|
|
2097
|
+
(_a = options.onStart) == null ? void 0 : _a.call(options, event);
|
|
2098
|
+
if (options.onTick) {
|
|
2099
|
+
let remaining = options.duration;
|
|
2100
|
+
state.tickTimerId = setInterval(() => {
|
|
2101
|
+
var _a2;
|
|
2102
|
+
remaining -= options.tickInterval;
|
|
2103
|
+
(_a2 = options.onTick) == null ? void 0 : _a2.call(options, Math.max(0, remaining));
|
|
2104
|
+
}, options.tickInterval);
|
|
2105
|
+
}
|
|
2106
|
+
state.timerId = setTimeout(() => {
|
|
2107
|
+
if (state.tickTimerId) {
|
|
2108
|
+
clearInterval(state.tickTimerId);
|
|
2109
|
+
state.tickTimerId = null;
|
|
2110
|
+
}
|
|
2111
|
+
options.handler(event);
|
|
2112
|
+
}, options.duration);
|
|
2113
|
+
};
|
|
2114
|
+
state.endHandler = (e) => {
|
|
2115
|
+
var _a;
|
|
2116
|
+
const event = e;
|
|
2117
|
+
if (state.timerId) {
|
|
2118
|
+
clearTimeout(state.timerId);
|
|
2119
|
+
state.timerId = null;
|
|
2120
|
+
}
|
|
2121
|
+
if (state.tickTimerId) {
|
|
2122
|
+
clearInterval(state.tickTimerId);
|
|
2123
|
+
state.tickTimerId = null;
|
|
2124
|
+
}
|
|
2125
|
+
if (state.startTime > 0) {
|
|
2126
|
+
(_a = options.onCancel) == null ? void 0 : _a.call(options, event);
|
|
2127
|
+
}
|
|
2128
|
+
state.startTime = 0;
|
|
2129
|
+
};
|
|
2130
|
+
state.moveHandler = (e) => {
|
|
2131
|
+
var _a;
|
|
2132
|
+
if (!state.timerId) return;
|
|
2133
|
+
const event = e;
|
|
2134
|
+
const pos = getEventPosition(event);
|
|
2135
|
+
const distance = getDistance(state.startPos, { x: pos.x, y: pos.y });
|
|
2136
|
+
if (distance > (options.distance || 10)) {
|
|
2137
|
+
if (state.timerId) {
|
|
2138
|
+
clearTimeout(state.timerId);
|
|
2139
|
+
state.timerId = null;
|
|
2140
|
+
}
|
|
2141
|
+
if (state.tickTimerId) {
|
|
2142
|
+
clearInterval(state.tickTimerId);
|
|
2143
|
+
state.tickTimerId = null;
|
|
2144
|
+
}
|
|
2145
|
+
(_a = options.onCancel) == null ? void 0 : _a.call(options, event);
|
|
2146
|
+
state.startTime = 0;
|
|
2147
|
+
}
|
|
2148
|
+
};
|
|
2149
|
+
el.__longPress = state;
|
|
2150
|
+
on(el, "mousedown", state.startHandler);
|
|
2151
|
+
on(el, "mouseup", state.endHandler);
|
|
2152
|
+
on(el, "mouseleave", state.endHandler);
|
|
2153
|
+
on(el, "mousemove", state.moveHandler);
|
|
2154
|
+
on(el, "touchstart", state.startHandler, { passive: !options.prevent });
|
|
2155
|
+
on(el, "touchend", state.endHandler);
|
|
2156
|
+
on(el, "touchcancel", state.endHandler);
|
|
2157
|
+
on(el, "touchmove", state.moveHandler, { passive: true });
|
|
2158
|
+
},
|
|
2159
|
+
updated(el, binding) {
|
|
2160
|
+
const state = el.__longPress;
|
|
2161
|
+
if (!state) {
|
|
2162
|
+
const options = normalizeOptions$7(binding.value);
|
|
2163
|
+
if (!options.disabled) {
|
|
2164
|
+
el.__longPress = null;
|
|
2165
|
+
}
|
|
2166
|
+
return;
|
|
2167
|
+
}
|
|
2168
|
+
state.options = normalizeOptions$7(binding.value);
|
|
2169
|
+
},
|
|
2170
|
+
unmounted(el) {
|
|
2171
|
+
const state = el.__longPress;
|
|
2172
|
+
if (!state) return;
|
|
2173
|
+
if (state.timerId) {
|
|
2174
|
+
clearTimeout(state.timerId);
|
|
2175
|
+
}
|
|
2176
|
+
if (state.tickTimerId) {
|
|
2177
|
+
clearInterval(state.tickTimerId);
|
|
2178
|
+
}
|
|
2179
|
+
off(el, "mousedown", state.startHandler);
|
|
2180
|
+
off(el, "mouseup", state.endHandler);
|
|
2181
|
+
off(el, "mouseleave", state.endHandler);
|
|
2182
|
+
off(el, "mousemove", state.moveHandler);
|
|
2183
|
+
off(el, "touchstart", state.startHandler);
|
|
2184
|
+
off(el, "touchend", state.endHandler);
|
|
2185
|
+
off(el, "touchcancel", state.endHandler);
|
|
2186
|
+
off(el, "touchmove", state.moveHandler);
|
|
2187
|
+
delete el.__longPress;
|
|
2188
|
+
}
|
|
2189
|
+
});
|
|
2190
|
+
function normalizeOptions$6(binding) {
|
|
2191
|
+
if (typeof binding === "function") {
|
|
2192
|
+
return { handler: binding, class: "v-hover" };
|
|
2193
|
+
}
|
|
2194
|
+
return __spreadValues({
|
|
2195
|
+
class: "v-hover",
|
|
2196
|
+
disabled: false,
|
|
2197
|
+
enterDelay: 0,
|
|
2198
|
+
leaveDelay: 0
|
|
2199
|
+
}, binding);
|
|
2200
|
+
}
|
|
2201
|
+
const vHover = defineDirective({
|
|
2202
|
+
name: "hover",
|
|
2203
|
+
ssr: false,
|
|
2204
|
+
defaults: {
|
|
2205
|
+
class: "v-hover",
|
|
2206
|
+
disabled: false,
|
|
2207
|
+
enterDelay: 0,
|
|
2208
|
+
leaveDelay: 0
|
|
2209
|
+
},
|
|
2210
|
+
mounted(el, binding) {
|
|
2211
|
+
const options = normalizeOptions$6(binding.value);
|
|
2212
|
+
if (options.disabled || !isBrowser()) return;
|
|
2213
|
+
const state = {
|
|
2214
|
+
options,
|
|
2215
|
+
isHovering: false,
|
|
2216
|
+
enterTimerId: null,
|
|
2217
|
+
leaveTimerId: null,
|
|
2218
|
+
enterHandler: () => {
|
|
2219
|
+
},
|
|
2220
|
+
leaveHandler: () => {
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
state.enterHandler = (e) => {
|
|
2224
|
+
const event = e;
|
|
2225
|
+
if (state.leaveTimerId) {
|
|
2226
|
+
clearTimeout(state.leaveTimerId);
|
|
2227
|
+
state.leaveTimerId = null;
|
|
2228
|
+
}
|
|
2229
|
+
if (state.isHovering) return;
|
|
2230
|
+
if (options.enterDelay && options.enterDelay > 0) {
|
|
2231
|
+
state.enterTimerId = setTimeout(() => {
|
|
2232
|
+
state.isHovering = true;
|
|
2233
|
+
applyHoverState(el, state, event);
|
|
2234
|
+
}, options.enterDelay);
|
|
2235
|
+
} else {
|
|
2236
|
+
state.isHovering = true;
|
|
2237
|
+
applyHoverState(el, state, event);
|
|
2238
|
+
}
|
|
2239
|
+
};
|
|
2240
|
+
state.leaveHandler = (e) => {
|
|
2241
|
+
const event = e;
|
|
2242
|
+
if (state.enterTimerId) {
|
|
2243
|
+
clearTimeout(state.enterTimerId);
|
|
2244
|
+
state.enterTimerId = null;
|
|
2245
|
+
}
|
|
2246
|
+
if (!state.isHovering) return;
|
|
2247
|
+
if (options.leaveDelay && options.leaveDelay > 0) {
|
|
2248
|
+
state.leaveTimerId = setTimeout(() => {
|
|
2249
|
+
state.isHovering = false;
|
|
2250
|
+
applyLeaveState(el, state, event);
|
|
2251
|
+
}, options.leaveDelay);
|
|
2252
|
+
} else {
|
|
2253
|
+
state.isHovering = false;
|
|
2254
|
+
applyLeaveState(el, state, event);
|
|
2255
|
+
}
|
|
2256
|
+
};
|
|
2257
|
+
el.__hover = state;
|
|
2258
|
+
on(el, "mouseenter", state.enterHandler);
|
|
2259
|
+
on(el, "mouseleave", state.leaveHandler);
|
|
2260
|
+
},
|
|
2261
|
+
updated(el, binding) {
|
|
2262
|
+
const state = el.__hover;
|
|
2263
|
+
if (!state) return;
|
|
2264
|
+
const newOptions = normalizeOptions$6(binding.value);
|
|
2265
|
+
if (newOptions.disabled && !state.options.disabled) {
|
|
2266
|
+
el.classList.remove(state.options.class || "v-hover");
|
|
2267
|
+
} else if (!newOptions.disabled && state.options.disabled) ;
|
|
2268
|
+
state.options = newOptions;
|
|
2269
|
+
},
|
|
2270
|
+
unmounted(el) {
|
|
2271
|
+
const state = el.__hover;
|
|
2272
|
+
if (!state) return;
|
|
2273
|
+
if (state.enterTimerId) {
|
|
2274
|
+
clearTimeout(state.enterTimerId);
|
|
2275
|
+
}
|
|
2276
|
+
if (state.leaveTimerId) {
|
|
2277
|
+
clearTimeout(state.leaveTimerId);
|
|
2278
|
+
}
|
|
2279
|
+
off(el, "mouseenter", state.enterHandler);
|
|
2280
|
+
off(el, "mouseleave", state.leaveHandler);
|
|
2281
|
+
el.classList.remove(state.options.class || "v-hover");
|
|
2282
|
+
delete el.__hover;
|
|
2283
|
+
}
|
|
2284
|
+
});
|
|
2285
|
+
function applyHoverState(el, state, e) {
|
|
2286
|
+
var _a, _b;
|
|
2287
|
+
const { options } = state;
|
|
2288
|
+
if (options.class) {
|
|
2289
|
+
el.classList.add(options.class);
|
|
2290
|
+
}
|
|
2291
|
+
el.dispatchEvent(new CustomEvent("hover:enter", { detail: { event: e } }));
|
|
2292
|
+
(_a = options.onEnter) == null ? void 0 : _a.call(options, e);
|
|
2293
|
+
(_b = options.handler) == null ? void 0 : _b.call(options, true, e);
|
|
2294
|
+
}
|
|
2295
|
+
function applyLeaveState(el, state, e) {
|
|
2296
|
+
var _a, _b;
|
|
2297
|
+
const { options } = state;
|
|
2298
|
+
if (options.class) {
|
|
2299
|
+
el.classList.remove(options.class);
|
|
2300
|
+
}
|
|
2301
|
+
el.dispatchEvent(new CustomEvent("hover:leave", { detail: { event: e } }));
|
|
2302
|
+
(_a = options.onLeave) == null ? void 0 : _a.call(options, e);
|
|
2303
|
+
(_b = options.handler) == null ? void 0 : _b.call(options, false, e);
|
|
2304
|
+
}
|
|
2305
|
+
function normalizeOptions$5(binding) {
|
|
2306
|
+
if (binding === false) {
|
|
2307
|
+
return { disabled: true, color: "currentColor", duration: 600 };
|
|
2308
|
+
}
|
|
2309
|
+
if (typeof binding === "string") {
|
|
2310
|
+
return { color: binding, duration: 600 };
|
|
2311
|
+
}
|
|
2312
|
+
const base = {
|
|
2313
|
+
color: "currentColor",
|
|
2314
|
+
duration: 600,
|
|
2315
|
+
disabled: false,
|
|
2316
|
+
initialScale: 0,
|
|
2317
|
+
finalScale: 2
|
|
2318
|
+
};
|
|
2319
|
+
return binding && typeof binding === "object" ? __spreadValues(__spreadValues({}, base), binding) : base;
|
|
2320
|
+
}
|
|
2321
|
+
function createRipple(event, el, options) {
|
|
2322
|
+
const rect = el.getBoundingClientRect();
|
|
2323
|
+
const x = event.clientX - rect.left;
|
|
2324
|
+
const y = event.clientY - rect.top;
|
|
2325
|
+
const size = Math.max(rect.width, rect.height) * 2;
|
|
2326
|
+
const ripple = document.createElement("span");
|
|
2327
|
+
ripple.className = "v-ripple__wave";
|
|
2328
|
+
ripple.style.cssText = `
|
|
2329
|
+
position: absolute;
|
|
2330
|
+
border-radius: 50%;
|
|
2331
|
+
pointer-events: none;
|
|
2332
|
+
background-color: ${options.color};
|
|
2333
|
+
width: ${size}px;
|
|
2334
|
+
height: ${size}px;
|
|
2335
|
+
left: ${x - size / 2}px;
|
|
2336
|
+
top: ${y - size / 2}px;
|
|
2337
|
+
transform: scale(${options.initialScale});
|
|
2338
|
+
opacity: 0.3;
|
|
2339
|
+
z-index: 0;
|
|
2340
|
+
`;
|
|
2341
|
+
return ripple;
|
|
2342
|
+
}
|
|
2343
|
+
function animateRipple(ripple, options) {
|
|
2344
|
+
const duration = options.duration || 600;
|
|
2345
|
+
const initialScale = options.initialScale || 0;
|
|
2346
|
+
const finalScale = options.finalScale || 2;
|
|
2347
|
+
if (typeof ripple.animate === "function") {
|
|
2348
|
+
ripple.animate(
|
|
2349
|
+
[
|
|
2350
|
+
{ transform: `scale(${initialScale})`, opacity: 0.3 },
|
|
2351
|
+
{ transform: `scale(${finalScale})`, opacity: 0 }
|
|
2352
|
+
],
|
|
2353
|
+
{
|
|
2354
|
+
duration,
|
|
2355
|
+
easing: "ease-out",
|
|
2356
|
+
fill: "forwards"
|
|
2357
|
+
}
|
|
2358
|
+
).onfinish = () => {
|
|
2359
|
+
ripple.remove();
|
|
2360
|
+
};
|
|
2361
|
+
} else {
|
|
2362
|
+
ripple.style.transition = `transform ${duration}ms ease-out, opacity ${duration}ms ease-out`;
|
|
2363
|
+
String(ripple.offsetHeight);
|
|
2364
|
+
ripple.style.transform = `scale(${finalScale})`;
|
|
2365
|
+
ripple.style.opacity = "0";
|
|
2366
|
+
setTimeout(() => {
|
|
2367
|
+
ripple.remove();
|
|
2368
|
+
}, duration);
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
const vRipple = defineDirective({
|
|
2372
|
+
name: "ripple",
|
|
2373
|
+
ssr: false,
|
|
2374
|
+
defaults: {
|
|
2375
|
+
color: "currentColor",
|
|
2376
|
+
duration: 600,
|
|
2377
|
+
disabled: false,
|
|
2378
|
+
initialScale: 0,
|
|
2379
|
+
finalScale: 2
|
|
2380
|
+
},
|
|
2381
|
+
mounted(el, binding) {
|
|
2382
|
+
const options = normalizeOptions$5(binding.value);
|
|
2383
|
+
if (options.disabled || !isBrowser()) return;
|
|
2384
|
+
const computedStyle = getComputedStyle(el);
|
|
2385
|
+
if (computedStyle.position === "static") {
|
|
2386
|
+
el.style.position = "relative";
|
|
2387
|
+
}
|
|
2388
|
+
if (computedStyle.overflow === "visible") {
|
|
2389
|
+
el.style.overflow = "hidden";
|
|
2390
|
+
}
|
|
2391
|
+
el.classList.add("v-ripple");
|
|
2392
|
+
const state = {
|
|
2393
|
+
options,
|
|
2394
|
+
clickHandler: (e) => {
|
|
2395
|
+
if (state.options.disabled) return;
|
|
2396
|
+
const mouseEvent = e;
|
|
2397
|
+
const ripple = createRipple(mouseEvent, el, state.options);
|
|
2398
|
+
if (ripple) {
|
|
2399
|
+
el.appendChild(ripple);
|
|
2400
|
+
animateRipple(ripple, state.options);
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
};
|
|
2404
|
+
el.__ripple = state;
|
|
2405
|
+
on(el, "click", state.clickHandler);
|
|
2406
|
+
},
|
|
2407
|
+
updated(el, binding) {
|
|
2408
|
+
const state = el.__ripple;
|
|
2409
|
+
if (!state) return;
|
|
2410
|
+
state.options = normalizeOptions$5(binding.value);
|
|
2411
|
+
},
|
|
2412
|
+
unmounted(el) {
|
|
2413
|
+
const state = el.__ripple;
|
|
2414
|
+
if (!state) return;
|
|
2415
|
+
off(el, "click", state.clickHandler);
|
|
2416
|
+
el.classList.remove("v-ripple");
|
|
2417
|
+
delete el.__ripple;
|
|
2418
|
+
}
|
|
2419
|
+
});
|
|
2420
|
+
const STATE_KEY$1 = "__mask";
|
|
2421
|
+
const TOKEN_PATTERNS = {
|
|
2422
|
+
"#": /\d/,
|
|
2423
|
+
A: /[A-Za-z]/,
|
|
2424
|
+
N: /[A-Za-z0-9]/,
|
|
2425
|
+
X: /./
|
|
2426
|
+
};
|
|
2427
|
+
function parseMask(mask, placeholder) {
|
|
2428
|
+
return [...mask].map((char) => {
|
|
2429
|
+
const pattern = TOKEN_PATTERNS[char];
|
|
2430
|
+
return pattern ? { pattern, placeholder, isLiteral: false } : { pattern: new RegExp(`\\${char}`), placeholder: char, isLiteral: true };
|
|
2431
|
+
});
|
|
2432
|
+
}
|
|
2433
|
+
function normalizeOptions$4(binding) {
|
|
2434
|
+
if (typeof binding === "string") return { mask: binding, placeholder: "_", showPlaceholder: true };
|
|
2435
|
+
if (!(binding == null ? void 0 : binding.mask)) throw new Error("[Directix] v-mask: mask is required");
|
|
2436
|
+
return __spreadValues({ placeholder: "_", showPlaceholder: true, showMaskOnBlur: false, clearIncomplete: false, disabled: false }, binding);
|
|
2437
|
+
}
|
|
2438
|
+
function isInput(el) {
|
|
2439
|
+
return el.tagName === "INPUT" || el.tagName === "TEXTAREA";
|
|
2440
|
+
}
|
|
2441
|
+
function formatValue(value, tokens, placeholder, showPlaceholder) {
|
|
2442
|
+
let result = "", valueIndex = 0;
|
|
2443
|
+
for (const token of tokens) {
|
|
2444
|
+
if (valueIndex >= value.length) {
|
|
2445
|
+
result += token.isLiteral ? token.placeholder : showPlaceholder ? placeholder : "";
|
|
2446
|
+
continue;
|
|
2447
|
+
}
|
|
2448
|
+
const inputChar = value[valueIndex];
|
|
2449
|
+
if (token.isLiteral) {
|
|
2450
|
+
if (inputChar === token.placeholder) valueIndex++;
|
|
2451
|
+
result += token.placeholder;
|
|
2452
|
+
} else if (token.pattern.test(inputChar)) {
|
|
2453
|
+
result += inputChar;
|
|
2454
|
+
valueIndex++;
|
|
2455
|
+
} else if (inputChar === placeholder) {
|
|
2456
|
+
result += showPlaceholder ? placeholder : "";
|
|
2457
|
+
valueIndex++;
|
|
2458
|
+
} else {
|
|
2459
|
+
valueIndex++;
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
return result;
|
|
2463
|
+
}
|
|
2464
|
+
function getRawValue(value, tokens, placeholder) {
|
|
2465
|
+
let raw = "";
|
|
2466
|
+
for (let i = 0; i < value.length && i < tokens.length; i++) {
|
|
2467
|
+
if (!tokens[i].isLiteral && value[i] !== placeholder) {
|
|
2468
|
+
raw += value[i];
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
return raw;
|
|
2472
|
+
}
|
|
2473
|
+
function isComplete(value, tokens, placeholder) {
|
|
2474
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
2475
|
+
if (!tokens[i].isLiteral && (i >= value.length || value[i] === placeholder)) {
|
|
2476
|
+
return false;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
return true;
|
|
2480
|
+
}
|
|
2481
|
+
function getCursorPos(tokens, rawCursorPos) {
|
|
2482
|
+
let pos = rawCursorPos;
|
|
2483
|
+
while (pos < tokens.length && tokens[pos].isLiteral) {
|
|
2484
|
+
pos++;
|
|
2485
|
+
}
|
|
2486
|
+
return Math.min(pos, tokens.length);
|
|
2487
|
+
}
|
|
2488
|
+
const vMask = defineDirective({
|
|
2489
|
+
name: "mask",
|
|
2490
|
+
ssr: false,
|
|
2491
|
+
defaults: { placeholder: "_", showPlaceholder: true, showMaskOnBlur: false, clearIncomplete: false, disabled: false },
|
|
2492
|
+
mounted(el, binding) {
|
|
2493
|
+
var _a;
|
|
2494
|
+
if (!isInput(el)) {
|
|
2495
|
+
console.warn("[Directix] v-mask: directive must be used on input or textarea elements");
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
const options = normalizeOptions$4(binding.value);
|
|
2499
|
+
if (options.disabled || !isBrowser()) return;
|
|
2500
|
+
const placeholder = options.placeholder || "_";
|
|
2501
|
+
const tokens = parseMask(options.mask, placeholder);
|
|
2502
|
+
const inputHandler = (e) => {
|
|
2503
|
+
var _a2, _b, _c;
|
|
2504
|
+
const target = e.target;
|
|
2505
|
+
const rawValue = target.value;
|
|
2506
|
+
const cursorPos = target.selectionStart || 0;
|
|
2507
|
+
const formatted = formatValue(rawValue, tokens, placeholder, (_a2 = options.showPlaceholder) != null ? _a2 : true);
|
|
2508
|
+
if (formatted !== rawValue) {
|
|
2509
|
+
target.value = formatted;
|
|
2510
|
+
target.setSelectionRange(getCursorPos(tokens, cursorPos), getCursorPos(tokens, cursorPos));
|
|
2511
|
+
target.dispatchEvent(new Event("input", { bubbles: true }));
|
|
2512
|
+
return;
|
|
2513
|
+
}
|
|
2514
|
+
(_b = options.onChange) == null ? void 0 : _b.call(options, formatted, getRawValue(formatted, tokens, placeholder));
|
|
2515
|
+
if (isComplete(formatted, tokens, placeholder)) {
|
|
2516
|
+
(_c = options.onComplete) == null ? void 0 : _c.call(options, formatted);
|
|
2517
|
+
}
|
|
2518
|
+
};
|
|
2519
|
+
const focusHandler = () => {
|
|
2520
|
+
if (!el.value && options.showPlaceholder) {
|
|
2521
|
+
el.value = formatValue("", tokens, placeholder, true);
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
const blurHandler = () => {
|
|
2525
|
+
if (!options.showMaskOnBlur && !isComplete(el.value, tokens, placeholder) && options.clearIncomplete) {
|
|
2526
|
+
el.value = "";
|
|
2527
|
+
}
|
|
2528
|
+
};
|
|
2529
|
+
on(el, "input", inputHandler);
|
|
2530
|
+
on(el, "focus", focusHandler);
|
|
2531
|
+
on(el, "blur", blurHandler);
|
|
2532
|
+
el[STATE_KEY$1] = { options, tokens, placeholder, inputHandler, focusHandler, blurHandler };
|
|
2533
|
+
if (el.value) {
|
|
2534
|
+
el.value = formatValue(el.value, tokens, placeholder, (_a = options.showPlaceholder) != null ? _a : true);
|
|
2535
|
+
}
|
|
2536
|
+
},
|
|
2537
|
+
updated(el, binding) {
|
|
2538
|
+
const state = el[STATE_KEY$1];
|
|
2539
|
+
if (!state) return;
|
|
2540
|
+
state.options = normalizeOptions$4(binding.value);
|
|
2541
|
+
state.tokens = parseMask(state.options.mask, state.placeholder);
|
|
2542
|
+
},
|
|
2543
|
+
unmounted(el) {
|
|
2544
|
+
const state = el[STATE_KEY$1];
|
|
2545
|
+
if (!state) return;
|
|
2546
|
+
off(el, "input", state.inputHandler);
|
|
2547
|
+
off(el, "focus", state.focusHandler);
|
|
2548
|
+
off(el, "blur", state.blurHandler);
|
|
2549
|
+
delete el[STATE_KEY$1];
|
|
2550
|
+
}
|
|
2551
|
+
});
|
|
2552
|
+
const STATE_KEY = "__permission";
|
|
2553
|
+
const WILDCARD = "*";
|
|
2554
|
+
let globalConfig = null;
|
|
2555
|
+
function configurePermission(config) {
|
|
2556
|
+
globalConfig = config;
|
|
2557
|
+
}
|
|
2558
|
+
function getPermissionConfig() {
|
|
2559
|
+
return globalConfig;
|
|
2560
|
+
}
|
|
2561
|
+
function normalizeOptions$3(binding) {
|
|
2562
|
+
if (!binding) {
|
|
2563
|
+
throw new Error("[Directix] v-permission: permission value is required");
|
|
2564
|
+
}
|
|
2565
|
+
if (typeof binding === "string") {
|
|
2566
|
+
return { value: binding };
|
|
2567
|
+
}
|
|
2568
|
+
if (Array.isArray(binding)) {
|
|
2569
|
+
return { value: binding };
|
|
2570
|
+
}
|
|
2571
|
+
return binding;
|
|
2572
|
+
}
|
|
2573
|
+
function hasPermission(required, permissions) {
|
|
2574
|
+
return permissions.includes(WILDCARD) || permissions.includes(required);
|
|
2575
|
+
}
|
|
2576
|
+
function verifyPermission(options) {
|
|
2577
|
+
var _a;
|
|
2578
|
+
if (options.check) {
|
|
2579
|
+
return options.check(options.value, options.mode || "some");
|
|
2580
|
+
}
|
|
2581
|
+
if (!globalConfig) {
|
|
2582
|
+
console.warn("[Directix] v-permission: No permission config provided");
|
|
2583
|
+
return true;
|
|
2584
|
+
}
|
|
2585
|
+
const permissions = globalConfig.getPermissions();
|
|
2586
|
+
const roles = ((_a = globalConfig.getRoles) == null ? void 0 : _a.call(globalConfig)) || [];
|
|
2587
|
+
const roleMap = globalConfig.roleMap || {};
|
|
2588
|
+
const required = Array.isArray(options.value) ? options.value : [options.value];
|
|
2589
|
+
const mode = options.mode || "some";
|
|
2590
|
+
function checkSingle(value) {
|
|
2591
|
+
if (value in roleMap) {
|
|
2592
|
+
return roles.includes(value);
|
|
2593
|
+
}
|
|
2594
|
+
if (hasPermission(value, permissions)) {
|
|
2595
|
+
return true;
|
|
2596
|
+
}
|
|
2597
|
+
for (const role of roles) {
|
|
2598
|
+
const rolePermissions = roleMap[role] || [];
|
|
2599
|
+
if (hasPermission(value, rolePermissions)) {
|
|
2600
|
+
return true;
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
return false;
|
|
2604
|
+
}
|
|
2605
|
+
return mode === "every" ? required.every(checkSingle) : required.some(checkSingle);
|
|
2606
|
+
}
|
|
2607
|
+
function handleDenied(el, action, state) {
|
|
2608
|
+
var _a, _b;
|
|
2609
|
+
switch (action) {
|
|
2610
|
+
case "remove":
|
|
2611
|
+
state.parentNode = el.parentNode;
|
|
2612
|
+
state.placeholder = document.createComment("v-permission");
|
|
2613
|
+
(_a = el.parentNode) == null ? void 0 : _a.insertBefore(state.placeholder, el);
|
|
2614
|
+
(_b = el.parentNode) == null ? void 0 : _b.removeChild(el);
|
|
2615
|
+
break;
|
|
2616
|
+
case "disable":
|
|
2617
|
+
state.originalDisabled = el.getAttribute("disabled") || false;
|
|
2618
|
+
el.setAttribute("disabled", "true");
|
|
2619
|
+
el.classList.add("v-permission--disabled");
|
|
2620
|
+
break;
|
|
2621
|
+
case "hide":
|
|
2622
|
+
state.originalDisplay = el.style.display;
|
|
2623
|
+
el.style.display = "none";
|
|
2624
|
+
el.classList.add("v-permission--hidden");
|
|
2625
|
+
break;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
function handleGranted(el, action, state) {
|
|
2629
|
+
switch (action) {
|
|
2630
|
+
case "remove":
|
|
2631
|
+
if (state.placeholder && state.parentNode) {
|
|
2632
|
+
state.parentNode.insertBefore(el, state.placeholder);
|
|
2633
|
+
state.parentNode.removeChild(state.placeholder);
|
|
2634
|
+
state.placeholder = null;
|
|
2635
|
+
}
|
|
2636
|
+
break;
|
|
2637
|
+
case "disable":
|
|
2638
|
+
if (state.originalDisabled === false) {
|
|
2639
|
+
el.removeAttribute("disabled");
|
|
2640
|
+
} else if (state.originalDisabled) {
|
|
2641
|
+
el.setAttribute("disabled", state.originalDisabled);
|
|
2642
|
+
}
|
|
2643
|
+
el.classList.remove("v-permission--disabled");
|
|
2644
|
+
break;
|
|
2645
|
+
case "hide":
|
|
2646
|
+
el.style.display = state.originalDisplay || "";
|
|
2647
|
+
el.classList.remove("v-permission--hidden");
|
|
2648
|
+
break;
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
function getState(el) {
|
|
2652
|
+
if (!el[STATE_KEY]) {
|
|
2653
|
+
el[STATE_KEY] = {
|
|
2654
|
+
options: { value: "" },
|
|
2655
|
+
originalDisplay: "",
|
|
2656
|
+
originalDisabled: false,
|
|
2657
|
+
parentNode: null,
|
|
2658
|
+
placeholder: null
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
return el[STATE_KEY];
|
|
2662
|
+
}
|
|
2663
|
+
function checkPermission(el, binding) {
|
|
2664
|
+
var _a, _b;
|
|
2665
|
+
const state = getState(el);
|
|
2666
|
+
state.options = normalizeOptions$3(binding.value);
|
|
2667
|
+
const granted = verifyPermission(state.options);
|
|
2668
|
+
(_b = (_a = state.options).onChange) == null ? void 0 : _b.call(_a, granted);
|
|
2669
|
+
const action = state.options.action || "remove";
|
|
2670
|
+
if (granted) {
|
|
2671
|
+
handleGranted(el, action, state);
|
|
2672
|
+
} else {
|
|
2673
|
+
handleDenied(el, action, state);
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
function cleanup(el) {
|
|
2677
|
+
const state = el[STATE_KEY];
|
|
2678
|
+
if ((state == null ? void 0 : state.placeholder) && state.parentNode) {
|
|
2679
|
+
state.parentNode.removeChild(state.placeholder);
|
|
2680
|
+
}
|
|
2681
|
+
delete el[STATE_KEY];
|
|
2682
|
+
}
|
|
2683
|
+
const vPermission = defineDirective({
|
|
2684
|
+
name: "permission",
|
|
2685
|
+
ssr: true,
|
|
2686
|
+
mounted(el, binding) {
|
|
2687
|
+
checkPermission(el, binding);
|
|
2688
|
+
},
|
|
2689
|
+
updated(el, binding) {
|
|
2690
|
+
checkPermission(el, binding);
|
|
2691
|
+
},
|
|
2692
|
+
unmounted(el) {
|
|
2693
|
+
cleanup(el);
|
|
2694
|
+
}
|
|
2695
|
+
});
|
|
2696
|
+
const DEFAULT_ALLOWED_TAGS = ["b", "i", "u", "strong", "em", "br", "p", "span", "div"];
|
|
2697
|
+
const DEFAULT_ALLOWED_ATTRIBUTES = ["title", "alt", "href", "src"];
|
|
2698
|
+
const DANGEROUS_TAGS = ["script", "iframe", "object", "embed", "form", "input", "style", "link", "meta", "base"];
|
|
2699
|
+
const DANGEROUS_ATTRIBUTES = ["onclick", "onerror", "onload", "onmouseover", "onfocus", "onblur", "onchange", "onsubmit"];
|
|
2700
|
+
function normalizeOptions$2(binding) {
|
|
2701
|
+
if (binding === false) {
|
|
2702
|
+
return { disabled: true };
|
|
2703
|
+
}
|
|
2704
|
+
if (binding === true) {
|
|
2705
|
+
return {
|
|
2706
|
+
allowedTags: DEFAULT_ALLOWED_TAGS,
|
|
2707
|
+
allowedAttributes: DEFAULT_ALLOWED_ATTRIBUTES
|
|
2708
|
+
};
|
|
2709
|
+
}
|
|
2710
|
+
return __spreadValues({
|
|
2711
|
+
allowedTags: DEFAULT_ALLOWED_TAGS,
|
|
2712
|
+
allowedAttributes: DEFAULT_ALLOWED_ATTRIBUTES,
|
|
2713
|
+
allowDataUrls: false,
|
|
2714
|
+
allowStyles: false,
|
|
2715
|
+
allowClass: false,
|
|
2716
|
+
allowId: false,
|
|
2717
|
+
disabled: false,
|
|
2718
|
+
sanitizeOnUpdate: true
|
|
2719
|
+
}, binding);
|
|
2720
|
+
}
|
|
2721
|
+
function sanitizeHtml(html, options) {
|
|
2722
|
+
var _a;
|
|
2723
|
+
if (options.handler) {
|
|
2724
|
+
return options.handler(html);
|
|
2725
|
+
}
|
|
2726
|
+
const temp = document.createElement("div");
|
|
2727
|
+
temp.innerHTML = html;
|
|
2728
|
+
for (const tag of DANGEROUS_TAGS) {
|
|
2729
|
+
const elements = temp.getElementsByTagName(tag);
|
|
2730
|
+
while (elements.length > 0) {
|
|
2731
|
+
(_a = elements[0].parentNode) == null ? void 0 : _a.removeChild(elements[0]);
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
const processElement = (el) => {
|
|
2735
|
+
var _a2;
|
|
2736
|
+
const tagName = el.tagName.toLowerCase();
|
|
2737
|
+
if (options.allowedTags && !options.allowedTags.includes(tagName)) {
|
|
2738
|
+
const text = document.createTextNode(el.textContent || "");
|
|
2739
|
+
(_a2 = el.parentNode) == null ? void 0 : _a2.replaceChild(text, el);
|
|
2740
|
+
return;
|
|
2741
|
+
}
|
|
2742
|
+
for (const attr of DANGEROUS_ATTRIBUTES) {
|
|
2743
|
+
el.removeAttribute(attr);
|
|
2744
|
+
}
|
|
2745
|
+
const href = el.getAttribute("href");
|
|
2746
|
+
if (href && href.toLowerCase().startsWith("javascript:")) {
|
|
2747
|
+
el.removeAttribute("href");
|
|
2748
|
+
}
|
|
2749
|
+
if (!options.allowDataUrls) {
|
|
2750
|
+
const src = el.getAttribute("src");
|
|
2751
|
+
if (src && src.toLowerCase().startsWith("data:")) {
|
|
2752
|
+
el.removeAttribute("src");
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
if (options.allowedAttributes) {
|
|
2756
|
+
const attrs = Array.from(el.attributes);
|
|
2757
|
+
for (const attr of attrs) {
|
|
2758
|
+
const isAllowed = options.allowedAttributes.includes(attr.name.toLowerCase());
|
|
2759
|
+
const isClass = attr.name === "class" && options.allowClass;
|
|
2760
|
+
const isId = attr.name === "id" && options.allowId;
|
|
2761
|
+
const isStyle = attr.name === "style" && options.allowStyles;
|
|
2762
|
+
if (!isAllowed && !isClass && !isId && !isStyle) {
|
|
2763
|
+
el.removeAttribute(attr.name);
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
for (const child of Array.from(el.children)) {
|
|
2768
|
+
processElement(child);
|
|
2769
|
+
}
|
|
2770
|
+
};
|
|
2771
|
+
for (const child of Array.from(temp.children)) {
|
|
2772
|
+
processElement(child);
|
|
2773
|
+
}
|
|
2774
|
+
return temp.innerHTML;
|
|
2775
|
+
}
|
|
2776
|
+
const vSanitize = defineDirective({
|
|
2777
|
+
name: "sanitize",
|
|
2778
|
+
ssr: true,
|
|
2779
|
+
defaults: {
|
|
2780
|
+
allowedTags: DEFAULT_ALLOWED_TAGS,
|
|
2781
|
+
allowedAttributes: DEFAULT_ALLOWED_ATTRIBUTES,
|
|
2782
|
+
allowDataUrls: false,
|
|
2783
|
+
allowStyles: false,
|
|
2784
|
+
allowClass: false,
|
|
2785
|
+
allowId: false,
|
|
2786
|
+
disabled: false,
|
|
2787
|
+
sanitizeOnUpdate: true
|
|
2788
|
+
},
|
|
2789
|
+
mounted(el, binding) {
|
|
2790
|
+
if (!isBrowser()) return;
|
|
2791
|
+
const options = normalizeOptions$2(binding.value);
|
|
2792
|
+
if (options.disabled) return;
|
|
2793
|
+
el.__sanitize = { options };
|
|
2794
|
+
const content = el.innerHTML;
|
|
2795
|
+
if (content) {
|
|
2796
|
+
el.innerHTML = sanitizeHtml(content, options);
|
|
2797
|
+
}
|
|
2798
|
+
},
|
|
2799
|
+
updated(el, binding) {
|
|
2800
|
+
const state = el.__sanitize;
|
|
2801
|
+
if (!state) return;
|
|
2802
|
+
state.options = normalizeOptions$2(binding.value);
|
|
2803
|
+
if (state.options.disabled || !state.options.sanitizeOnUpdate) return;
|
|
2804
|
+
const content = el.innerHTML;
|
|
2805
|
+
if (content) {
|
|
2806
|
+
el.innerHTML = sanitizeHtml(content, state.options);
|
|
2807
|
+
}
|
|
2808
|
+
},
|
|
2809
|
+
unmounted(el) {
|
|
2810
|
+
delete el.__sanitize;
|
|
2811
|
+
}
|
|
2812
|
+
});
|
|
2813
|
+
function getResizeInfo(entry) {
|
|
2814
|
+
return {
|
|
2815
|
+
width: entry.contentRect.width,
|
|
2816
|
+
height: entry.contentRect.height,
|
|
2817
|
+
contentRect: entry.contentRect,
|
|
2818
|
+
borderBoxSize: entry.borderBoxSize,
|
|
2819
|
+
contentBoxSize: entry.contentBoxSize,
|
|
2820
|
+
devicePixelContentBoxSize: entry.devicePixelContentBoxSize
|
|
2821
|
+
};
|
|
2822
|
+
}
|
|
2823
|
+
function normalizeOptions$1(binding) {
|
|
2824
|
+
if (typeof binding === "function") {
|
|
2825
|
+
return { handler: binding };
|
|
2826
|
+
}
|
|
2827
|
+
if (!binding) {
|
|
2828
|
+
throw new Error("[Directix] v-resize: handler is required");
|
|
2829
|
+
}
|
|
2830
|
+
return __spreadValues({
|
|
2831
|
+
disabled: false,
|
|
2832
|
+
box: "content-box",
|
|
2833
|
+
debounce: 0
|
|
2834
|
+
}, binding);
|
|
2835
|
+
}
|
|
2836
|
+
function createFallbackResize(el, callback) {
|
|
2837
|
+
const iframe = document.createElement("iframe");
|
|
2838
|
+
iframe.style.cssText = `
|
|
2839
|
+
position: absolute;
|
|
2840
|
+
top: 0;
|
|
2841
|
+
left: 0;
|
|
2842
|
+
width: 100%;
|
|
2843
|
+
height: 100%;
|
|
2844
|
+
border: none;
|
|
2845
|
+
pointer-events: none;
|
|
2846
|
+
opacity: 0;
|
|
2847
|
+
`;
|
|
2848
|
+
el.appendChild(iframe);
|
|
2849
|
+
const iWindow = iframe.contentWindow;
|
|
2850
|
+
if (iWindow) {
|
|
2851
|
+
iWindow.addEventListener("resize", callback);
|
|
2852
|
+
}
|
|
2853
|
+
return {
|
|
2854
|
+
iframe,
|
|
2855
|
+
cleanup: () => {
|
|
2856
|
+
if (iWindow) {
|
|
2857
|
+
iWindow.removeEventListener("resize", callback);
|
|
2858
|
+
}
|
|
2859
|
+
iframe.remove();
|
|
2860
|
+
}
|
|
2861
|
+
};
|
|
2862
|
+
}
|
|
2863
|
+
const vResize = defineDirective({
|
|
2864
|
+
name: "resize",
|
|
2865
|
+
ssr: false,
|
|
2866
|
+
defaults: {
|
|
2867
|
+
disabled: false,
|
|
2868
|
+
box: "content-box",
|
|
2869
|
+
debounce: 0
|
|
2870
|
+
},
|
|
2871
|
+
mounted(el, binding) {
|
|
2872
|
+
const options = normalizeOptions$1(binding.value);
|
|
2873
|
+
if (options.disabled || !isBrowser()) return;
|
|
2874
|
+
const computedStyle = getComputedStyle(el);
|
|
2875
|
+
if (computedStyle.position === "static") {
|
|
2876
|
+
el.style.position = "relative";
|
|
2877
|
+
}
|
|
2878
|
+
const state = {
|
|
2879
|
+
options,
|
|
2880
|
+
observer: null,
|
|
2881
|
+
debounceTimer: null,
|
|
2882
|
+
pendingEntry: null,
|
|
2883
|
+
fallbackIframe: null,
|
|
2884
|
+
handler: (entry) => {
|
|
2885
|
+
if (options.debounce && options.debounce > 0) {
|
|
2886
|
+
state.pendingEntry = entry;
|
|
2887
|
+
if (!state.debounceTimer) {
|
|
2888
|
+
state.debounceTimer = setTimeout(() => {
|
|
2889
|
+
if (state.pendingEntry) {
|
|
2890
|
+
options.handler(state.pendingEntry);
|
|
2891
|
+
}
|
|
2892
|
+
state.debounceTimer = null;
|
|
2893
|
+
state.pendingEntry = null;
|
|
2894
|
+
}, options.debounce);
|
|
2895
|
+
}
|
|
2896
|
+
} else {
|
|
2897
|
+
options.handler(entry);
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
};
|
|
2901
|
+
el.__resize = state;
|
|
2902
|
+
if (supportsResizeObserver()) {
|
|
2903
|
+
state.observer = new ResizeObserver((entries) => {
|
|
2904
|
+
for (const entry of entries) {
|
|
2905
|
+
state.handler(entry);
|
|
2906
|
+
}
|
|
2907
|
+
});
|
|
2908
|
+
state.observer.observe(el, { box: options.box });
|
|
2909
|
+
} else {
|
|
2910
|
+
console.warn("[Directix] v-resize: ResizeObserver not supported, using fallback");
|
|
2911
|
+
const { iframe, cleanup: cleanup2 } = createFallbackResize(el, () => {
|
|
2912
|
+
const rect = el.getBoundingClientRect();
|
|
2913
|
+
const entry = {
|
|
2914
|
+
target: el,
|
|
2915
|
+
contentRect: rect,
|
|
2916
|
+
borderBoxSize: [],
|
|
2917
|
+
contentBoxSize: [],
|
|
2918
|
+
devicePixelContentBoxSize: []
|
|
2919
|
+
};
|
|
2920
|
+
state.handler(entry);
|
|
2921
|
+
if (options.onFallback) {
|
|
2922
|
+
options.onFallback(getResizeInfo(entry));
|
|
2923
|
+
}
|
|
2924
|
+
});
|
|
2925
|
+
state.fallbackIframe = iframe;
|
|
2926
|
+
el.__resizeCleanup = cleanup2;
|
|
2927
|
+
}
|
|
2928
|
+
},
|
|
2929
|
+
updated(el, binding) {
|
|
2930
|
+
const state = el.__resize;
|
|
2931
|
+
if (!state) return;
|
|
2932
|
+
state.options = normalizeOptions$1(binding.value);
|
|
2933
|
+
},
|
|
2934
|
+
unmounted(el) {
|
|
2935
|
+
const state = el.__resize;
|
|
2936
|
+
if (!state) return;
|
|
2937
|
+
if (state.debounceTimer) {
|
|
2938
|
+
clearTimeout(state.debounceTimer);
|
|
2939
|
+
}
|
|
2940
|
+
if (state.observer) {
|
|
2941
|
+
state.observer.disconnect();
|
|
2942
|
+
}
|
|
2943
|
+
const cleanup2 = el.__resizeCleanup;
|
|
2944
|
+
if (cleanup2) {
|
|
2945
|
+
cleanup2();
|
|
2946
|
+
}
|
|
2947
|
+
delete el.__resize;
|
|
2948
|
+
delete el.__resizeCleanup;
|
|
2949
|
+
}
|
|
2950
|
+
});
|
|
2951
|
+
function normalizeOptions(binding) {
|
|
2952
|
+
if (typeof binding === "function") {
|
|
2953
|
+
return { handler: binding, childList: true };
|
|
2954
|
+
}
|
|
2955
|
+
if (!binding || !binding.handler) {
|
|
2956
|
+
throw new Error("[Directix] v-mutation: handler is required");
|
|
2957
|
+
}
|
|
2958
|
+
return __spreadValues({
|
|
2959
|
+
attributes: false,
|
|
2960
|
+
childList: true,
|
|
2961
|
+
subtree: false,
|
|
2962
|
+
characterData: false,
|
|
2963
|
+
attributeOldValue: false,
|
|
2964
|
+
characterDataOldValue: false,
|
|
2965
|
+
disabled: false
|
|
2966
|
+
}, binding);
|
|
2967
|
+
}
|
|
2968
|
+
const vMutation = defineDirective({
|
|
2969
|
+
name: "mutation",
|
|
2970
|
+
ssr: false,
|
|
2971
|
+
defaults: {
|
|
2972
|
+
attributes: false,
|
|
2973
|
+
childList: true,
|
|
2974
|
+
subtree: false,
|
|
2975
|
+
characterData: false,
|
|
2976
|
+
attributeOldValue: false,
|
|
2977
|
+
characterDataOldValue: false,
|
|
2978
|
+
disabled: false
|
|
2979
|
+
},
|
|
2980
|
+
mounted(el, binding) {
|
|
2981
|
+
const options = normalizeOptions(binding.value);
|
|
2982
|
+
if (options.disabled || !isBrowser()) return;
|
|
2983
|
+
if (!supportsMutationObserver()) {
|
|
2984
|
+
console.warn("[Directix] v-mutation: MutationObserver not supported");
|
|
2985
|
+
return;
|
|
2986
|
+
}
|
|
2987
|
+
const state = {
|
|
2988
|
+
options,
|
|
2989
|
+
observer: null
|
|
2990
|
+
};
|
|
2991
|
+
state.observer = new MutationObserver((mutations, observer) => {
|
|
2992
|
+
options.handler(mutations, observer);
|
|
2993
|
+
});
|
|
2994
|
+
state.observer.observe(el, {
|
|
2995
|
+
attributes: options.attributes,
|
|
2996
|
+
attributeFilter: options.attributeFilter,
|
|
2997
|
+
childList: options.childList,
|
|
2998
|
+
subtree: options.subtree,
|
|
2999
|
+
characterData: options.characterData,
|
|
3000
|
+
attributeOldValue: options.attributeOldValue,
|
|
3001
|
+
characterDataOldValue: options.characterDataOldValue
|
|
3002
|
+
});
|
|
3003
|
+
el.__mutation = state;
|
|
3004
|
+
},
|
|
3005
|
+
updated(el, binding) {
|
|
3006
|
+
const state = el.__mutation;
|
|
3007
|
+
if (!state) return;
|
|
3008
|
+
const newOptions = normalizeOptions(binding.value);
|
|
3009
|
+
if (newOptions.disabled && !state.options.disabled) {
|
|
3010
|
+
if (state.observer) {
|
|
3011
|
+
state.observer.disconnect();
|
|
3012
|
+
}
|
|
3013
|
+
} else if (!newOptions.disabled && state.options.disabled) {
|
|
3014
|
+
if (state.observer) {
|
|
3015
|
+
state.observer.observe(el, {
|
|
3016
|
+
attributes: newOptions.attributes,
|
|
3017
|
+
attributeFilter: newOptions.attributeFilter,
|
|
3018
|
+
childList: newOptions.childList,
|
|
3019
|
+
subtree: newOptions.subtree,
|
|
3020
|
+
characterData: newOptions.characterData,
|
|
3021
|
+
attributeOldValue: newOptions.attributeOldValue,
|
|
3022
|
+
characterDataOldValue: newOptions.characterDataOldValue
|
|
3023
|
+
});
|
|
3024
|
+
}
|
|
3025
|
+
} else if (!newOptions.disabled) {
|
|
3026
|
+
if (newOptions.attributes !== state.options.attributes || newOptions.childList !== state.options.childList || newOptions.subtree !== state.options.subtree || newOptions.characterData !== state.options.characterData) {
|
|
3027
|
+
if (state.observer) {
|
|
3028
|
+
state.observer.disconnect();
|
|
3029
|
+
state.observer.observe(el, {
|
|
3030
|
+
attributes: newOptions.attributes,
|
|
3031
|
+
attributeFilter: newOptions.attributeFilter,
|
|
3032
|
+
childList: newOptions.childList,
|
|
3033
|
+
subtree: newOptions.subtree,
|
|
3034
|
+
characterData: newOptions.characterData,
|
|
3035
|
+
attributeOldValue: newOptions.attributeOldValue,
|
|
3036
|
+
characterDataOldValue: newOptions.characterDataOldValue
|
|
3037
|
+
});
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
state.options = newOptions;
|
|
3042
|
+
},
|
|
3043
|
+
unmounted(el) {
|
|
3044
|
+
const state = el.__mutation;
|
|
3045
|
+
if (!state) return;
|
|
3046
|
+
if (state.observer) {
|
|
3047
|
+
state.observer.disconnect();
|
|
3048
|
+
}
|
|
3049
|
+
delete el.__mutation;
|
|
3050
|
+
}
|
|
3051
|
+
});
|
|
3052
|
+
const allDirectives = {
|
|
3053
|
+
"click-outside": vClickOutside,
|
|
3054
|
+
copy: vCopy,
|
|
3055
|
+
debounce: vDebounce,
|
|
3056
|
+
throttle: vThrottle,
|
|
3057
|
+
focus: vFocus,
|
|
3058
|
+
lazy: vLazy,
|
|
3059
|
+
intersect: vIntersect,
|
|
3060
|
+
visible: vVisible,
|
|
3061
|
+
loading: vLoading,
|
|
3062
|
+
scroll: vScroll,
|
|
3063
|
+
"infinite-scroll": vInfiniteScroll,
|
|
3064
|
+
sticky: vSticky,
|
|
3065
|
+
"long-press": vLongPress,
|
|
3066
|
+
hover: vHover,
|
|
3067
|
+
ripple: vRipple,
|
|
3068
|
+
mask: vMask,
|
|
3069
|
+
permission: vPermission,
|
|
3070
|
+
sanitize: vSanitize,
|
|
3071
|
+
resize: vResize,
|
|
3072
|
+
mutation: vMutation
|
|
3073
|
+
};
|
|
3074
|
+
const install = (app, options = {}) => {
|
|
3075
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3076
|
+
let vueVersion = null;
|
|
3077
|
+
if (typeof app === "function" && ((_a = app.version) == null ? void 0 : _a.startsWith("2"))) {
|
|
3078
|
+
vueVersion = 2;
|
|
3079
|
+
} else if ((app == null ? void 0 : app.config) && ((_b = app == null ? void 0 : app.version) == null ? void 0 : _b.startsWith("3"))) {
|
|
3080
|
+
vueVersion = 3;
|
|
3081
|
+
} else if (typeof (app == null ? void 0 : app.directive) === "function" && typeof (app == null ? void 0 : app.mixin) === "function" && ((_c = app.version) == null ? void 0 : _c.startsWith("2"))) {
|
|
3082
|
+
vueVersion = 2;
|
|
3083
|
+
} else if (typeof window !== "undefined") {
|
|
3084
|
+
const win = window;
|
|
3085
|
+
if ((_e = (_d = win.Vue) == null ? void 0 : _d.version) == null ? void 0 : _e.startsWith("2")) {
|
|
3086
|
+
vueVersion = 2;
|
|
3087
|
+
} else if ((_g = (_f = win.Vue) == null ? void 0 : _f.version) == null ? void 0 : _g.startsWith("3")) {
|
|
3088
|
+
vueVersion = 3;
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
if (vueVersion) {
|
|
3092
|
+
setVueVersion(vueVersion);
|
|
3093
|
+
}
|
|
3094
|
+
const { directives, all = false } = options;
|
|
3095
|
+
if (all || !directives) {
|
|
3096
|
+
Object.entries(allDirectives).forEach(([name, directive]) => {
|
|
3097
|
+
app.directive(name, directive);
|
|
3098
|
+
});
|
|
3099
|
+
} else {
|
|
3100
|
+
directives.forEach((name) => {
|
|
3101
|
+
const directive = allDirectives[name];
|
|
3102
|
+
if (directive) {
|
|
3103
|
+
app.directive(name, directive);
|
|
3104
|
+
} else {
|
|
3105
|
+
console.warn(`[Directix] Unknown directive: ${name}`);
|
|
3106
|
+
}
|
|
3107
|
+
});
|
|
3108
|
+
}
|
|
3109
|
+
};
|
|
3110
|
+
const Directix = {
|
|
3111
|
+
install
|
|
3112
|
+
};
|
|
3113
|
+
exports.Directix = Directix;
|
|
3114
|
+
exports.addCleanupVue2 = addCleanup$1;
|
|
3115
|
+
exports.addCleanupVue3 = addCleanup;
|
|
3116
|
+
exports.clickOutside = vClickOutside;
|
|
3117
|
+
exports.configurePermission = configurePermission;
|
|
3118
|
+
exports.copy = vCopy;
|
|
3119
|
+
exports.createVue2Directive = createVue2Directive;
|
|
3120
|
+
exports.createVue3Directive = createVue3Directive;
|
|
3121
|
+
exports.debounce = vDebounce;
|
|
3122
|
+
exports.debounceFn = debounce;
|
|
3123
|
+
exports.deepClone = deepClone;
|
|
3124
|
+
exports.deepMerge = deepMerge;
|
|
3125
|
+
exports.defineDirective = defineDirective;
|
|
3126
|
+
exports.defineDirectiveGroup = defineDirectiveGroup;
|
|
3127
|
+
exports.focus = vFocus;
|
|
3128
|
+
exports.generateId = generateId;
|
|
3129
|
+
exports.get = get;
|
|
3130
|
+
exports.getPermissionConfig = getPermissionConfig;
|
|
3131
|
+
exports.getVueVersion = getVueVersion;
|
|
3132
|
+
exports.hover = vHover;
|
|
3133
|
+
exports.infiniteScroll = vInfiniteScroll;
|
|
3134
|
+
exports.intersect = vIntersect;
|
|
3135
|
+
exports.isArray = isArray;
|
|
3136
|
+
exports.isBoolean = isBoolean;
|
|
3137
|
+
exports.isBrowser = isBrowser;
|
|
3138
|
+
exports.isEmpty = isEmpty;
|
|
3139
|
+
exports.isFunction = isFunction;
|
|
3140
|
+
exports.isNumber = isNumber;
|
|
3141
|
+
exports.isObject = isObject;
|
|
3142
|
+
exports.isPromise = isPromise;
|
|
3143
|
+
exports.isSSR = isSSR;
|
|
3144
|
+
exports.isString = isString;
|
|
3145
|
+
exports.isVue2 = isVue2;
|
|
3146
|
+
exports.isVue27 = isVue27;
|
|
3147
|
+
exports.isVue3 = isVue3;
|
|
3148
|
+
exports.lazy = vLazy;
|
|
3149
|
+
exports.loading = vLoading;
|
|
3150
|
+
exports.longPress = vLongPress;
|
|
3151
|
+
exports.mask = vMask;
|
|
3152
|
+
exports.mutation = vMutation;
|
|
3153
|
+
exports.parseTime = parseTime;
|
|
3154
|
+
exports.permission = vPermission;
|
|
3155
|
+
exports.resetVueVersion = resetVueVersion;
|
|
3156
|
+
exports.resize = vResize;
|
|
3157
|
+
exports.ripple = vRipple;
|
|
3158
|
+
exports.sanitize = vSanitize;
|
|
3159
|
+
exports.scroll = vScroll;
|
|
3160
|
+
exports.set = set;
|
|
3161
|
+
exports.setVueVersion = setVueVersion;
|
|
3162
|
+
exports.sticky = vSticky;
|
|
3163
|
+
exports.supportsClipboard = supportsClipboard;
|
|
3164
|
+
exports.supportsIntersectionObserver = supportsIntersectionObserver;
|
|
3165
|
+
exports.supportsMutationObserver = supportsMutationObserver;
|
|
3166
|
+
exports.supportsPassive = supportsPassive;
|
|
3167
|
+
exports.supportsResizeObserver = supportsResizeObserver;
|
|
3168
|
+
exports.throttle = vThrottle;
|
|
3169
|
+
exports.throttleFn = throttle;
|
|
3170
|
+
exports.vClickOutside = vClickOutside;
|
|
3171
|
+
exports.vCopy = vCopy;
|
|
3172
|
+
exports.vDebounce = vDebounce;
|
|
3173
|
+
exports.vFocus = vFocus;
|
|
3174
|
+
exports.vHover = vHover;
|
|
3175
|
+
exports.vInfiniteScroll = vInfiniteScroll;
|
|
3176
|
+
exports.vIntersect = vIntersect;
|
|
3177
|
+
exports.vLazy = vLazy;
|
|
3178
|
+
exports.vLoading = vLoading;
|
|
3179
|
+
exports.vLongPress = vLongPress;
|
|
3180
|
+
exports.vMask = vMask;
|
|
3181
|
+
exports.vMutation = vMutation;
|
|
3182
|
+
exports.vPermission = vPermission;
|
|
3183
|
+
exports.vResize = vResize;
|
|
3184
|
+
exports.vRipple = vRipple;
|
|
3185
|
+
exports.vSanitize = vSanitize;
|
|
3186
|
+
exports.vScroll = vScroll;
|
|
3187
|
+
exports.vSticky = vSticky;
|
|
3188
|
+
exports.vThrottle = vThrottle;
|
|
3189
|
+
exports.vVisible = vVisible;
|
|
3190
|
+
exports.visible = vVisible;
|
|
3191
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3192
|
+
})(this.Directix = this.Directix || {});
|
|
3193
|
+
//# sourceMappingURL=index.iife.js.map
|