directix 1.0.0 → 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 +149 -28
- package/dist/index.cjs +2141 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1084 -67
- package/dist/index.iife.js +2141 -172
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +2 -2
- package/dist/index.mjs +2142 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -10
package/dist/index.iife.js
CHANGED
|
@@ -1,142 +1,16 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* directix v1.
|
|
2
|
+
* directix v1.1.0
|
|
3
3
|
* A comprehensive, easy-to-use, and high-performance Vue custom directives library supporting both Vue 2 and Vue 3
|
|
4
4
|
* (c) 2021-present saqqdy <https://github.com/saqqdy>
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
7
|
-
var _VueDemiGlobal = typeof globalThis !== 'undefined'
|
|
8
|
-
? globalThis
|
|
9
|
-
: typeof global !== 'undefined'
|
|
10
|
-
? global
|
|
11
|
-
: typeof self !== 'undefined'
|
|
12
|
-
? self
|
|
13
|
-
: this
|
|
14
|
-
var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
15
|
-
if (VueDemi.install) {
|
|
16
|
-
return VueDemi
|
|
17
|
-
}
|
|
18
|
-
if (!Vue) {
|
|
19
|
-
console.error('[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.')
|
|
20
|
-
return VueDemi
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Vue 2.7
|
|
24
|
-
if (Vue.version.slice(0, 4) === '2.7.') {
|
|
25
|
-
for (var key in Vue) {
|
|
26
|
-
VueDemi[key] = Vue[key]
|
|
27
|
-
}
|
|
28
|
-
VueDemi.isVue2 = true
|
|
29
|
-
VueDemi.isVue3 = false
|
|
30
|
-
VueDemi.install = function () {}
|
|
31
|
-
VueDemi.Vue = Vue
|
|
32
|
-
VueDemi.Vue2 = Vue
|
|
33
|
-
VueDemi.version = Vue.version
|
|
34
|
-
VueDemi.warn = Vue.util.warn
|
|
35
|
-
VueDemi.hasInjectionContext = function() {
|
|
36
|
-
return !!VueDemi.getCurrentInstance()
|
|
37
|
-
}
|
|
38
|
-
function createApp(rootComponent, rootProps) {
|
|
39
|
-
var vm
|
|
40
|
-
var provide = {}
|
|
41
|
-
var app = {
|
|
42
|
-
config: Vue.config,
|
|
43
|
-
use: Vue.use.bind(Vue),
|
|
44
|
-
mixin: Vue.mixin.bind(Vue),
|
|
45
|
-
component: Vue.component.bind(Vue),
|
|
46
|
-
provide: function (key, value) {
|
|
47
|
-
provide[key] = value
|
|
48
|
-
return this
|
|
49
|
-
},
|
|
50
|
-
directive: function (name, dir) {
|
|
51
|
-
if (dir) {
|
|
52
|
-
Vue.directive(name, dir)
|
|
53
|
-
return app
|
|
54
|
-
} else {
|
|
55
|
-
return Vue.directive(name)
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
mount: function (el, hydrating) {
|
|
59
|
-
if (!vm) {
|
|
60
|
-
vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) }))
|
|
61
|
-
vm.$mount(el, hydrating)
|
|
62
|
-
return vm
|
|
63
|
-
} else {
|
|
64
|
-
return vm
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
unmount: function () {
|
|
68
|
-
if (vm) {
|
|
69
|
-
vm.$destroy()
|
|
70
|
-
vm = undefined
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
}
|
|
74
|
-
return app
|
|
75
|
-
}
|
|
76
|
-
VueDemi.createApp = createApp
|
|
77
|
-
}
|
|
78
|
-
// Vue 2.6.x
|
|
79
|
-
else if (Vue.version.slice(0, 2) === '2.') {
|
|
80
|
-
if (VueCompositionAPI) {
|
|
81
|
-
for (var key in VueCompositionAPI) {
|
|
82
|
-
VueDemi[key] = VueCompositionAPI[key]
|
|
83
|
-
}
|
|
84
|
-
VueDemi.isVue2 = true
|
|
85
|
-
VueDemi.isVue3 = false
|
|
86
|
-
VueDemi.install = function () {}
|
|
87
|
-
VueDemi.Vue = Vue
|
|
88
|
-
VueDemi.Vue2 = Vue
|
|
89
|
-
VueDemi.version = Vue.version
|
|
90
|
-
VueDemi.hasInjectionContext = function() {
|
|
91
|
-
return !!VueDemi.getCurrentInstance()
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// Vue 3
|
|
98
|
-
else if (Vue.version.slice(0, 2) === '3.') {
|
|
99
|
-
for (var key in Vue) {
|
|
100
|
-
VueDemi[key] = Vue[key]
|
|
101
|
-
}
|
|
102
|
-
VueDemi.isVue2 = false
|
|
103
|
-
VueDemi.isVue3 = true
|
|
104
|
-
VueDemi.install = function () {}
|
|
105
|
-
VueDemi.Vue = Vue
|
|
106
|
-
VueDemi.Vue2 = undefined
|
|
107
|
-
VueDemi.version = Vue.version
|
|
108
|
-
VueDemi.set = function (target, key, val) {
|
|
109
|
-
if (Array.isArray(target)) {
|
|
110
|
-
target.length = Math.max(target.length, key)
|
|
111
|
-
target.splice(key, 1, val)
|
|
112
|
-
return val
|
|
113
|
-
}
|
|
114
|
-
target[key] = val
|
|
115
|
-
return val
|
|
116
|
-
}
|
|
117
|
-
VueDemi.del = function (target, key) {
|
|
118
|
-
if (Array.isArray(target)) {
|
|
119
|
-
target.splice(key, 1)
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
delete target[key]
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
console.error('[vue-demi] Vue version ' + Vue.version + ' is unsupported.')
|
|
126
|
-
}
|
|
127
|
-
return VueDemi
|
|
128
|
-
})(
|
|
129
|
-
(_VueDemiGlobal.VueDemi = _VueDemiGlobal.VueDemi || (typeof VueDemi !== 'undefined' ? VueDemi : {})),
|
|
130
|
-
_VueDemiGlobal.Vue || (typeof Vue !== 'undefined' ? Vue : undefined),
|
|
131
|
-
_VueDemiGlobal.VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined)
|
|
132
|
-
);
|
|
133
|
-
|
|
134
7
|
var __defProp = Object.defineProperty;
|
|
135
8
|
var __defProps = Object.defineProperties;
|
|
136
9
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
137
10
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
138
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
139
12
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var __pow = Math.pow;
|
|
140
14
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
141
15
|
var __spreadValues = (a, b) => {
|
|
142
16
|
for (var prop in b || (b = {}))
|
|
@@ -183,38 +57,119 @@ var __async = (__this, __arguments, generator) => {
|
|
|
183
57
|
});
|
|
184
58
|
};
|
|
185
59
|
/*!
|
|
186
|
-
* directix v1.
|
|
60
|
+
* directix v1.1.0
|
|
187
61
|
* A comprehensive, easy-to-use, and high-performance Vue custom directives library supporting both Vue 2 and Vue 3
|
|
188
62
|
* (c) 2021-present saqqdy <https://github.com/saqqdy>
|
|
189
63
|
* Released under the MIT License.
|
|
190
64
|
*/
|
|
191
65
|
(function(exports) {
|
|
192
66
|
"use strict";
|
|
193
|
-
let _vueVersion = null;
|
|
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
|
+
}
|
|
194
74
|
function getVueVersion() {
|
|
195
75
|
var _a, _b;
|
|
196
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
|
+
}
|
|
197
92
|
try {
|
|
198
93
|
const vue = require("vue");
|
|
199
|
-
|
|
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") {
|
|
200
112
|
_vueVersion = 2;
|
|
201
|
-
|
|
113
|
+
return _vueVersion;
|
|
114
|
+
}
|
|
115
|
+
if (typeof (vue == null ? void 0 : vue.createApp) === "function" && typeof (vue == null ? void 0 : vue.observable) !== "function") {
|
|
202
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;
|
|
203
130
|
}
|
|
204
|
-
} catch (e) {
|
|
205
131
|
}
|
|
206
132
|
if (_vueVersion === null) {
|
|
207
133
|
if (typeof window !== "undefined") {
|
|
208
134
|
console.warn(
|
|
209
|
-
"[Directix] Unable to detect Vue version, defaulting to Vue 3.
|
|
135
|
+
"[Directix] Unable to detect Vue version, defaulting to Vue 3. Set DIRECTIX_VUE_VERSION=2 or call setVueVersion(2) if using Vue 2."
|
|
210
136
|
);
|
|
211
137
|
}
|
|
212
138
|
_vueVersion = 3;
|
|
213
139
|
}
|
|
214
140
|
return _vueVersion;
|
|
215
141
|
}
|
|
216
|
-
|
|
217
|
-
|
|
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
|
+
}
|
|
218
173
|
const isBrowser = () => {
|
|
219
174
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
220
175
|
};
|
|
@@ -389,19 +344,45 @@ var __async = (__this, __arguments, generator) => {
|
|
|
389
344
|
}
|
|
390
345
|
const wrappedHooks = {
|
|
391
346
|
mounted: hooks.mounted ? (el, binding, vnode) => {
|
|
392
|
-
|
|
393
|
-
hooks.mounted(el, mergedBinding, vnode);
|
|
347
|
+
hooks.mounted(el, applyDefaults(binding, defaults), vnode);
|
|
394
348
|
} : void 0,
|
|
395
349
|
updated: hooks.updated ? (el, binding, vnode, prevBinding, prevVnode) => {
|
|
396
|
-
|
|
397
|
-
hooks.updated(el, mergedBinding, vnode, prevBinding, prevVnode);
|
|
350
|
+
hooks.updated(el, applyDefaults(binding, defaults), vnode, prevBinding, prevVnode);
|
|
398
351
|
} : void 0,
|
|
399
352
|
unmounted: hooks.unmounted
|
|
400
353
|
};
|
|
401
|
-
|
|
402
|
-
|
|
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;
|
|
403
363
|
}
|
|
404
|
-
|
|
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
|
+
};
|
|
405
386
|
}
|
|
406
387
|
function applyDefaults(binding, defaults) {
|
|
407
388
|
if (!defaults) return binding;
|
|
@@ -441,17 +422,29 @@ var __async = (__this, __arguments, generator) => {
|
|
|
441
422
|
}
|
|
442
423
|
return isElement(target) ? target : null;
|
|
443
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
|
+
}
|
|
444
437
|
function on(target, event, handler, options = false) {
|
|
445
438
|
if (!isBrowser()) return;
|
|
446
|
-
const opts = normalizeOptions$
|
|
439
|
+
const opts = normalizeOptions$k(options);
|
|
447
440
|
target.addEventListener(event, handler, opts);
|
|
448
441
|
}
|
|
449
442
|
function off(target, event, handler, options = false) {
|
|
450
443
|
if (!isBrowser()) return;
|
|
451
|
-
const opts = normalizeOptions$
|
|
444
|
+
const opts = normalizeOptions$k(options);
|
|
452
445
|
target.removeEventListener(event, handler, opts);
|
|
453
446
|
}
|
|
454
|
-
function normalizeOptions$
|
|
447
|
+
function normalizeOptions$k(options) {
|
|
455
448
|
if (typeof options === "boolean") {
|
|
456
449
|
return options;
|
|
457
450
|
}
|
|
@@ -461,6 +454,22 @@ var __async = (__this, __arguments, generator) => {
|
|
|
461
454
|
}
|
|
462
455
|
return capture;
|
|
463
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
|
+
}
|
|
464
473
|
function isString(value) {
|
|
465
474
|
return typeof value === "string";
|
|
466
475
|
}
|
|
@@ -658,7 +667,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
658
667
|
prevent: false
|
|
659
668
|
},
|
|
660
669
|
mounted(el, binding) {
|
|
661
|
-
const options = normalizeOptions$
|
|
670
|
+
const options = normalizeOptions$j(binding.value);
|
|
662
671
|
if (options.disabled) return;
|
|
663
672
|
const state = {
|
|
664
673
|
options,
|
|
@@ -693,7 +702,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
693
702
|
const state = el.__clickOutside;
|
|
694
703
|
if (!state) return;
|
|
695
704
|
const oldOptions = state.options;
|
|
696
|
-
const newOptions = normalizeOptions$
|
|
705
|
+
const newOptions = normalizeOptions$j(binding.value);
|
|
697
706
|
if (oldOptions.disabled !== newOptions.disabled) {
|
|
698
707
|
if (newOptions.disabled) {
|
|
699
708
|
state.handlers.forEach((handler, eventType) => {
|
|
@@ -730,7 +739,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
730
739
|
delete el.__clickOutside;
|
|
731
740
|
}
|
|
732
741
|
});
|
|
733
|
-
function normalizeOptions$
|
|
742
|
+
function normalizeOptions$j(binding) {
|
|
734
743
|
var _a, _b, _c, _d, _e;
|
|
735
744
|
if (typeof binding === "function") {
|
|
736
745
|
return {
|
|
@@ -807,7 +816,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
807
816
|
name: "copy",
|
|
808
817
|
ssr: false,
|
|
809
818
|
mounted(el, binding) {
|
|
810
|
-
const options = normalizeOptions$
|
|
819
|
+
const options = normalizeOptions$i(binding.value);
|
|
811
820
|
if (options.disabled) return;
|
|
812
821
|
if (options.title) {
|
|
813
822
|
el.setAttribute("title", options.title);
|
|
@@ -843,7 +852,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
843
852
|
updated(el, binding) {
|
|
844
853
|
const state = el.__copy;
|
|
845
854
|
if (!state) return;
|
|
846
|
-
state.options = normalizeOptions$
|
|
855
|
+
state.options = normalizeOptions$i(binding.value);
|
|
847
856
|
if (state.options.title) {
|
|
848
857
|
el.setAttribute("title", state.options.title);
|
|
849
858
|
}
|
|
@@ -855,7 +864,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
855
864
|
delete el.__copy;
|
|
856
865
|
}
|
|
857
866
|
});
|
|
858
|
-
function normalizeOptions$
|
|
867
|
+
function normalizeOptions$i(binding) {
|
|
859
868
|
if (typeof binding === "string") {
|
|
860
869
|
return { value: binding };
|
|
861
870
|
}
|
|
@@ -863,14 +872,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
863
872
|
}
|
|
864
873
|
const vDebounce = defineDirective({
|
|
865
874
|
name: "debounce",
|
|
866
|
-
ssr:
|
|
875
|
+
ssr: true,
|
|
876
|
+
// SSR safe - event binding is skipped on server
|
|
867
877
|
defaults: {
|
|
868
878
|
wait: 300,
|
|
869
879
|
leading: false,
|
|
870
880
|
trailing: true
|
|
871
881
|
},
|
|
872
882
|
mounted(el, binding) {
|
|
873
|
-
const options = normalizeOptions$
|
|
883
|
+
const options = normalizeOptions$h(binding.value, binding);
|
|
874
884
|
const eventType = getEventTypeFromModifiers$1(binding.modifiers) || getEventType$1(el);
|
|
875
885
|
const debouncedFn = debounce(options.handler, options.wait, {
|
|
876
886
|
leading: options.leading,
|
|
@@ -886,7 +896,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
886
896
|
updated(el, binding) {
|
|
887
897
|
const state = el.__debounce;
|
|
888
898
|
if (!state) return;
|
|
889
|
-
const newOptions = normalizeOptions$
|
|
899
|
+
const newOptions = normalizeOptions$h(binding.value, binding);
|
|
890
900
|
if (newOptions.wait !== state.options.wait || newOptions.leading !== state.options.leading || newOptions.trailing !== state.options.trailing) {
|
|
891
901
|
state.debouncedFn.cancel();
|
|
892
902
|
const debouncedFn = debounce(newOptions.handler, newOptions.wait, {
|
|
@@ -912,7 +922,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
912
922
|
delete el.__debounce;
|
|
913
923
|
}
|
|
914
924
|
});
|
|
915
|
-
function normalizeOptions$
|
|
925
|
+
function normalizeOptions$h(binding, directiveBinding) {
|
|
916
926
|
const wait = parseTime(directiveBinding.arg) || 300;
|
|
917
927
|
if (typeof binding === "function") {
|
|
918
928
|
return { handler: binding, wait };
|
|
@@ -956,14 +966,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
956
966
|
}
|
|
957
967
|
const vThrottle = defineDirective({
|
|
958
968
|
name: "throttle",
|
|
959
|
-
ssr:
|
|
969
|
+
ssr: true,
|
|
970
|
+
// SSR safe - event binding is skipped on server
|
|
960
971
|
defaults: {
|
|
961
972
|
wait: 300,
|
|
962
973
|
leading: true,
|
|
963
974
|
trailing: true
|
|
964
975
|
},
|
|
965
976
|
mounted(el, binding) {
|
|
966
|
-
const options = normalizeOptions$
|
|
977
|
+
const options = normalizeOptions$g(binding.value, binding);
|
|
967
978
|
const eventType = getEventTypeFromModifiers(binding.modifiers) || getEventType(el);
|
|
968
979
|
const throttledFn = throttle(options.handler, options.wait, {
|
|
969
980
|
leading: options.leading,
|
|
@@ -979,7 +990,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
979
990
|
updated(el, binding) {
|
|
980
991
|
const state = el.__throttle;
|
|
981
992
|
if (!state) return;
|
|
982
|
-
const newOptions = normalizeOptions$
|
|
993
|
+
const newOptions = normalizeOptions$g(binding.value, binding);
|
|
983
994
|
if (newOptions.wait !== state.options.wait || newOptions.leading !== state.options.leading || newOptions.trailing !== state.options.trailing) {
|
|
984
995
|
state.throttledFn.cancel();
|
|
985
996
|
const throttledFn = throttle(newOptions.handler, newOptions.wait, {
|
|
@@ -1005,7 +1016,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1005
1016
|
delete el.__throttle;
|
|
1006
1017
|
}
|
|
1007
1018
|
});
|
|
1008
|
-
function normalizeOptions$
|
|
1019
|
+
function normalizeOptions$g(binding, directiveBinding) {
|
|
1009
1020
|
const wait = parseTime(directiveBinding.arg) || 300;
|
|
1010
1021
|
if (typeof binding === "function") {
|
|
1011
1022
|
return { handler: binding, wait };
|
|
@@ -1060,13 +1071,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1060
1071
|
}
|
|
1061
1072
|
const vFocus = defineDirective({
|
|
1062
1073
|
name: "focus",
|
|
1063
|
-
ssr:
|
|
1074
|
+
ssr: true,
|
|
1075
|
+
// SSR safe - will skip focus on server
|
|
1064
1076
|
defaults: {
|
|
1065
1077
|
focus: true,
|
|
1066
1078
|
refocus: false
|
|
1067
1079
|
},
|
|
1068
1080
|
mounted(el, binding) {
|
|
1069
|
-
|
|
1081
|
+
if (!isBrowser()) return;
|
|
1082
|
+
const options = normalizeOptions$f(binding.value);
|
|
1070
1083
|
if (!options.focus || !isFocusable(el)) {
|
|
1071
1084
|
if (options.focus) {
|
|
1072
1085
|
console.warn("[Directix] v-focus: Element is not focusable");
|
|
@@ -1094,7 +1107,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1094
1107
|
updated(el, binding) {
|
|
1095
1108
|
const state = el.__focus;
|
|
1096
1109
|
if (!state) return;
|
|
1097
|
-
const newOptions = normalizeOptions(binding.value);
|
|
1110
|
+
const newOptions = normalizeOptions$f(binding.value);
|
|
1098
1111
|
if (newOptions.onFocus !== state.options.onFocus) {
|
|
1099
1112
|
el.removeEventListener("focus", state.handleFocus);
|
|
1100
1113
|
state.handleFocus = () => {
|
|
@@ -1126,7 +1139,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1126
1139
|
delete el.__focus;
|
|
1127
1140
|
}
|
|
1128
1141
|
});
|
|
1129
|
-
function normalizeOptions(binding) {
|
|
1142
|
+
function normalizeOptions$f(binding) {
|
|
1130
1143
|
if (typeof binding === "boolean") {
|
|
1131
1144
|
return { focus: binding, refocus: false };
|
|
1132
1145
|
}
|
|
@@ -1149,14 +1162,1935 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1149
1162
|
}
|
|
1150
1163
|
return false;
|
|
1151
1164
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
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
|
+
}
|
|
1160
3094
|
const { directives, all = false } = options;
|
|
1161
3095
|
if (all || !directives) {
|
|
1162
3096
|
Object.entries(allDirectives).forEach(([name, directive]) => {
|
|
@@ -1180,6 +3114,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1180
3114
|
exports.addCleanupVue2 = addCleanup$1;
|
|
1181
3115
|
exports.addCleanupVue3 = addCleanup;
|
|
1182
3116
|
exports.clickOutside = vClickOutside;
|
|
3117
|
+
exports.configurePermission = configurePermission;
|
|
1183
3118
|
exports.copy = vCopy;
|
|
1184
3119
|
exports.createVue2Directive = createVue2Directive;
|
|
1185
3120
|
exports.createVue3Directive = createVue3Directive;
|
|
@@ -1192,7 +3127,11 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1192
3127
|
exports.focus = vFocus;
|
|
1193
3128
|
exports.generateId = generateId;
|
|
1194
3129
|
exports.get = get;
|
|
3130
|
+
exports.getPermissionConfig = getPermissionConfig;
|
|
1195
3131
|
exports.getVueVersion = getVueVersion;
|
|
3132
|
+
exports.hover = vHover;
|
|
3133
|
+
exports.infiniteScroll = vInfiniteScroll;
|
|
3134
|
+
exports.intersect = vIntersect;
|
|
1196
3135
|
exports.isArray = isArray;
|
|
1197
3136
|
exports.isBoolean = isBoolean;
|
|
1198
3137
|
exports.isBrowser = isBrowser;
|
|
@@ -1204,9 +3143,23 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1204
3143
|
exports.isSSR = isSSR;
|
|
1205
3144
|
exports.isString = isString;
|
|
1206
3145
|
exports.isVue2 = isVue2;
|
|
3146
|
+
exports.isVue27 = isVue27;
|
|
1207
3147
|
exports.isVue3 = isVue3;
|
|
3148
|
+
exports.lazy = vLazy;
|
|
3149
|
+
exports.loading = vLoading;
|
|
3150
|
+
exports.longPress = vLongPress;
|
|
3151
|
+
exports.mask = vMask;
|
|
3152
|
+
exports.mutation = vMutation;
|
|
1208
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;
|
|
1209
3160
|
exports.set = set;
|
|
3161
|
+
exports.setVueVersion = setVueVersion;
|
|
3162
|
+
exports.sticky = vSticky;
|
|
1210
3163
|
exports.supportsClipboard = supportsClipboard;
|
|
1211
3164
|
exports.supportsIntersectionObserver = supportsIntersectionObserver;
|
|
1212
3165
|
exports.supportsMutationObserver = supportsMutationObserver;
|
|
@@ -1218,7 +3171,23 @@ var __async = (__this, __arguments, generator) => {
|
|
|
1218
3171
|
exports.vCopy = vCopy;
|
|
1219
3172
|
exports.vDebounce = vDebounce;
|
|
1220
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;
|
|
1221
3188
|
exports.vThrottle = vThrottle;
|
|
3189
|
+
exports.vVisible = vVisible;
|
|
3190
|
+
exports.visible = vVisible;
|
|
1222
3191
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1223
3192
|
})(this.Directix = this.Directix || {});
|
|
1224
3193
|
//# sourceMappingURL=index.iife.js.map
|