@pixelium/web-vue 0.0.2-fix → 0.0.3-alpha
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 +42 -0
- package/README.zh.md +6 -3
- package/dist/font.css +1 -1
- package/dist/index.d.ts +1602 -248
- package/dist/normalize.css +2 -0
- package/dist/pixelium-vue-icon-hn.cjs +1 -1
- package/dist/pixelium-vue-icon-hn.css +2 -1
- package/dist/pixelium-vue-icon-hn.js +8533 -8154
- package/dist/pixelium-vue-icon-hn.umd.cjs +1 -1
- package/dist/pixelium-vue-icon-pa.cjs +1 -1
- package/dist/pixelium-vue-icon-pa.css +2 -1
- package/dist/pixelium-vue-icon-pa.js +10625 -10143
- package/dist/pixelium-vue-icon-pa.umd.cjs +1 -1
- package/dist/pixelium-vue.cjs +2 -2
- package/dist/pixelium-vue.css +2 -1
- package/dist/pixelium-vue.js +7407 -5854
- package/dist/pixelium-vue.umd.cjs +2 -2
- package/es/aside/index.css +1 -0
- package/es/aside/index.js +46 -151
- package/es/auto-complete/draw.d.ts +1 -1
- package/es/auto-complete/draw.js +26 -51
- package/es/auto-complete/index.css +92 -32
- package/es/auto-complete/index.d.ts +12 -15
- package/es/auto-complete/index.js +338 -400
- package/es/auto-complete/type.d.ts +25 -13
- package/es/avatar/css.js +2 -0
- package/es/avatar/draw.d.ts +2 -0
- package/es/avatar/draw.js +11 -0
- package/es/avatar/index.css +49 -0
- package/es/avatar/index.d.ts +15 -0
- package/es/avatar/index.js +110 -0
- package/es/avatar/type.d.ts +34 -0
- package/es/button/draw.d.ts +4 -4
- package/es/button/draw.js +213 -297
- package/es/button/index.css +40 -30
- package/es/button/index.d.ts +0 -4
- package/es/button/index.js +230 -256
- package/es/button/type.d.ts +3 -3
- package/es/button-group/index.css +0 -3
- package/es/button-group/index.d.ts +1 -2
- package/es/button-group/index.js +59 -31
- package/es/button-group/type.d.ts +21 -4
- package/es/checkbox/css.js +2 -0
- package/es/checkbox/draw.d.ts +4 -0
- package/es/checkbox/draw.js +46 -0
- package/es/checkbox/index.css +85 -0
- package/es/checkbox/index.d.ts +31 -0
- package/es/checkbox/index.js +206 -0
- package/es/checkbox/type.d.ts +88 -0
- package/es/checkbox-group/css.js +2 -0
- package/es/checkbox-group/index.css +20 -0
- package/es/checkbox-group/index.d.ts +23 -0
- package/es/checkbox-group/index.js +84 -0
- package/es/checkbox-group/type.d.ts +78 -0
- package/es/col/index.d.ts +2 -2
- package/es/col/index.js +43 -58
- package/es/container/index.css +1 -0
- package/es/container/index.js +18 -31
- package/es/divider/index.js +39 -53
- package/es/empty/index.css +4 -4
- package/es/empty/index.js +16 -71
- package/es/entry.js +102 -0
- package/es/footer/index.css +1 -0
- package/es/footer/index.js +31 -40
- package/es/form/css.js +1 -0
- package/es/form/index.d.ts +27 -0
- package/es/form/index.js +125 -0
- package/es/form/type.d.ts +238 -0
- package/es/form/use-form.d.ts +4 -0
- package/es/form/use-form.js +48 -0
- package/es/form-item/css.js +2 -0
- package/es/form-item/index.css +77 -0
- package/es/form-item/index.d.ts +37 -0
- package/es/form-item/index.js +318 -0
- package/es/form-item/type.d.ts +96 -0
- package/es/grid/index.js +56 -75
- package/es/grid-item/css.js +0 -1
- package/es/grid-item/index.d.ts +1 -1
- package/es/grid-item/index.js +85 -121
- package/es/header/index.css +1 -0
- package/es/header/index.js +31 -40
- package/es/icon/index.js +44 -55
- package/es/icons/css-hn.js +0 -1
- package/es/icons/css-pa.js +0 -1
- package/es/icons/icon-hn.js +10337 -15986
- package/es/icons/icon-pa.js +12573 -17447
- package/es/image/css.js +2 -0
- package/es/image/index.css +69 -0
- package/es/image/index.d.ts +35 -0
- package/es/image/index.js +199 -0
- package/es/image/type.d.ts +126 -0
- package/es/index.css +1 -515
- package/es/index.d.ts +22 -2
- package/es/index.js +144 -123
- package/es/input/draw.d.ts +1 -1
- package/es/input/draw.js +26 -51
- package/es/input/index.css +85 -33
- package/es/input/index.d.ts +9 -16
- package/es/input/index.js +319 -423
- package/es/input/type.d.ts +3 -3
- package/es/input-group/index.css +0 -1
- package/es/input-group/index.d.ts +2 -2
- package/es/input-group/index.js +66 -37
- package/es/input-group/type.d.ts +16 -4
- package/es/input-group-label/draw.d.ts +1 -1
- package/es/input-group-label/draw.js +26 -51
- package/es/input-group-label/index.css +33 -22
- package/es/input-group-label/index.d.ts +1 -4
- package/es/input-group-label/index.js +104 -127
- package/es/input-group-label/type.d.ts +3 -3
- package/es/input-number/draw.d.ts +1 -1
- package/es/input-number/draw.js +26 -51
- package/es/input-number/index.css +90 -35
- package/es/input-number/index.d.ts +9 -16
- package/es/input-number/index.js +428 -536
- package/es/input-number/type.d.ts +3 -3
- package/es/input-tag/draw.d.ts +1 -1
- package/es/input-tag/draw.js +26 -48
- package/es/input-tag/index.css +100 -33
- package/es/input-tag/index.d.ts +7 -13
- package/es/input-tag/index.js +442 -467
- package/es/input-tag/type.d.ts +24 -13
- package/es/link/index.js +75 -106
- package/es/main/index.css +4 -0
- package/es/main/index.d.ts +4 -1
- package/es/main/index.js +15 -15
- package/es/main/type.d.ts +7 -0
- package/es/mask/index.js +94 -115
- package/es/message/index.css +1 -1
- package/es/message/index.js +168 -346
- package/es/message-box/css.js +1 -1
- package/es/message-box/index.js +98 -114
- package/es/message-box/message-box-wrapped.js +33 -46
- package/es/message-box/message-box.js +79 -111
- package/es/option-list/index.css +13 -13
- package/es/option-list/index.d.ts +4 -31
- package/es/option-list/index.js +99 -167
- package/es/option-list/type.d.ts +5 -1
- package/es/pixelate/pixel.d.ts +5 -0
- package/es/pixelate/pixel.js +70 -0
- package/es/pixelate/pixelate.worker.d.ts +1 -0
- package/es/popover/index.d.ts +13 -99
- package/es/popover/index.js +75 -238
- package/es/popover/type.d.ts +7 -2
- package/es/popup/css.js +1 -0
- package/es/popup/index.d.ts +210 -0
- package/es/popup/index.js +203 -0
- package/es/popup/type.d.ts +105 -0
- package/es/popup-content/draw.d.ts +2 -2
- package/es/popup-content/draw.js +98 -143
- package/es/popup-content/index.css +11 -11
- package/es/popup-content/index.d.ts +1 -0
- package/es/popup-content/index.js +253 -1576
- package/es/popup-content/type.d.ts +1 -0
- package/es/popup-trigger/index.d.ts +8 -2
- package/es/popup-trigger/index.js +122 -95
- package/es/popup-trigger/type.d.ts +4 -1
- package/es/popup-wrapper/css.js +2 -0
- package/es/popup-wrapper/index.css +14 -0
- package/es/popup-wrapper/index.d.ts +18 -0
- package/es/popup-wrapper/index.js +67 -0
- package/es/popup-wrapper/type.d.ts +9 -0
- package/es/radio/css.js +1 -0
- package/es/radio/draw.d.ts +4 -0
- package/es/radio/draw.js +47 -0
- package/es/radio/index.d.ts +30 -0
- package/es/radio/index.js +190 -0
- package/es/radio/style.css +73 -0
- package/es/radio/type.d.ts +76 -0
- package/es/radio-group/css.js +2 -0
- package/es/radio-group/index.css +20 -0
- package/es/radio-group/index.d.ts +23 -0
- package/es/radio-group/index.js +77 -0
- package/es/radio-group/type.d.ts +77 -0
- package/es/row/index.js +56 -70
- package/es/select/draw.d.ts +1 -1
- package/es/select/draw.js +26 -51
- package/es/select/index.css +118 -36
- package/es/select/index.d.ts +14 -16
- package/es/select/index.js +625 -675
- package/es/select/type.d.ts +60 -25
- package/es/share/const/event-bus-key.js +1 -6
- package/es/share/const/index.d.ts +4 -0
- package/es/share/const/index.js +22 -24
- package/es/share/const/provide-key.d.ts +5 -0
- package/es/share/const/provide-key.js +6 -5
- package/es/share/const/style.d.ts +6 -0
- package/es/share/const/style.js +7 -0
- package/es/share/hook/use-cancelable-delay.d.ts +1 -0
- package/es/share/hook/use-cancelable-delay.js +42 -0
- package/es/share/hook/use-click-outside-listener.d.ts +1 -1
- package/es/share/hook/use-click-outside-listener.js +28 -41
- package/es/share/hook/use-composition.js +17 -15
- package/es/share/hook/use-controlled-mode.d.ts +3 -3
- package/es/share/hook/use-controlled-mode.js +20 -23
- package/es/share/hook/use-dark-mode.js +51 -65
- package/es/share/hook/use-index-of-children.d.ts +2 -1
- package/es/share/hook/use-index-of-children.js +47 -45
- package/es/share/hook/use-lazy-load.d.ts +10 -0
- package/es/share/hook/use-lazy-load.js +133 -0
- package/es/share/hook/use-props-detect.d.ts +2 -0
- package/es/share/hook/use-resize-observer.d.ts +1 -2
- package/es/share/hook/use-resize-observer.js +28 -20
- package/es/share/hook/use-screen-width.js +27 -36
- package/es/share/hook/use-smooth-transition.d.ts +2 -0
- package/es/share/hook/use-smooth-transition.js +65 -0
- package/es/share/hook/use-textarea-height.js +86 -92
- package/es/share/hook/use-theme-mode.js +41 -42
- package/es/share/hook/use-transition-end.d.ts +2 -0
- package/es/share/hook/use-transition-end.js +12 -0
- package/es/share/hook/use-watch-global-css-var.js +12 -16
- package/es/share/hook/use-window-resize-listener.d.ts +1 -0
- package/es/share/hook/use-window-resize-listener.js +15 -0
- package/es/share/hook/use-z-index.js +30 -27
- package/es/share/style/index.css +5 -0
- package/es/share/type/index.d.ts +18 -3
- package/es/share/util/color.d.ts +5 -3
- package/es/share/util/color.js +156 -149
- package/es/share/util/common.d.ts +7 -2
- package/es/share/util/common.js +127 -65
- package/es/share/util/console.d.ts +3 -3
- package/es/share/util/console.js +10 -7
- package/es/share/util/dom.d.ts +19 -0
- package/es/share/util/dom.js +88 -0
- package/es/share/util/env.d.ts +1 -0
- package/es/share/util/env.js +5 -4
- package/es/share/util/event-bus.js +3 -20
- package/es/share/util/lru-cache.js +29 -33
- package/es/share/util/pixel.d.ts +4 -0
- package/es/share/util/plot.d.ts +8 -3
- package/es/share/util/plot.js +457 -229
- package/es/share/util/reactivity.d.ts +8 -0
- package/es/share/util/reactivity.js +23 -0
- package/es/share/util/render.js +31 -41
- package/es/share/util/theme.d.ts +3 -0
- package/es/share/util/theme.js +77 -57
- package/es/slider/css.js +2 -0
- package/es/slider/draw.d.ts +25 -0
- package/es/slider/draw.js +113 -0
- package/es/slider/index.css +119 -0
- package/es/slider/index.d.ts +66 -0
- package/es/slider/index.js +503 -0
- package/es/slider/type.d.ts +162 -0
- package/es/slider/util.d.ts +37 -0
- package/es/slider/util.js +130 -0
- package/es/space/index.css +24 -29
- package/es/space/index.js +73 -97
- package/es/spin/index.css +18 -17
- package/es/spin/index.js +72 -102
- package/es/spin/type.d.ts +11 -5
- package/es/switch/css.js +2 -0
- package/es/switch/draw.d.ts +2 -0
- package/es/switch/draw.js +18 -0
- package/es/switch/index.css +121 -0
- package/es/switch/index.d.ts +42 -0
- package/es/switch/index.js +259 -0
- package/es/switch/type.d.ts +133 -0
- package/es/tag/draw.d.ts +2 -2
- package/es/tag/draw.js +80 -127
- package/es/tag/index.css +38 -22
- package/es/tag/index.d.ts +2 -2
- package/es/tag/index.js +121 -190
- package/es/tag/type.d.ts +3 -3
- package/es/text-outline/css.js +2 -0
- package/es/text-outline/index.css +4 -0
- package/es/text-outline/index.d.ts +17 -0
- package/es/text-outline/index.js +33 -0
- package/es/text-outline/type.d.ts +23 -0
- package/es/textarea/draw.js +9 -11
- package/es/textarea/index.css +37 -23
- package/es/textarea/index.d.ts +8 -14
- package/es/textarea/index.js +274 -262
- package/es/tooltip/index.d.ts +100 -4
- package/es/tooltip/index.js +70 -226
- package/es/tooltip/type.d.ts +7 -2
- package/es/vendor.js +504 -0
- package/es/virtual-list/css.js +2 -0
- package/es/virtual-list/index.css +25 -0
- package/es/virtual-list/index.d.ts +11 -0
- package/es/virtual-list/index.js +313 -0
- package/es/virtual-list/type.d.ts +26 -0
- package/package.json +10 -16
- package/es/grid-item/index.css +0 -0
- /package/es/message-box/{message-box.css → index.css} +0 -0
|
@@ -1,48 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
const useIndexOfChildren = (eventBusKey) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { t as inBrowser } from "../util/env.js";
|
|
2
|
+
import { t as EventBus } from "../util/event-bus.js";
|
|
3
|
+
import { getCurrentInstance, nextTick, onBeforeUnmount, onMounted, onUpdated, ref } from "vue";
|
|
4
|
+
const useIndexOfChildren = (eventBusKey, elGetter) => {
|
|
5
|
+
const index = ref(-1);
|
|
6
|
+
const last = ref(false);
|
|
7
|
+
const first = ref(false);
|
|
8
|
+
const instance = getCurrentInstance();
|
|
9
|
+
const callback = () => {
|
|
10
|
+
if (instance) {
|
|
11
|
+
var _instance$vnode$el;
|
|
12
|
+
const parent = (_instance$vnode$el = instance.vnode.el) === null || _instance$vnode$el === void 0 ? void 0 : _instance$vnode$el.parentElement;
|
|
13
|
+
const el = elGetter ? elGetter(instance) : instance.vnode.el;
|
|
14
|
+
if (el && parent && parent.children.length) {
|
|
15
|
+
index.value = [...parent.children].indexOf(el);
|
|
16
|
+
last.value = index.value === parent.children.length - 1;
|
|
17
|
+
first.value = index.value === 0;
|
|
18
|
+
} else {
|
|
19
|
+
index.value = -1;
|
|
20
|
+
last.value = false;
|
|
21
|
+
first.value = false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
if (inBrowser()) {
|
|
26
|
+
EventBus.on(eventBusKey, callback);
|
|
27
|
+
onMounted(() => {
|
|
28
|
+
nextTick(() => {
|
|
29
|
+
callback();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
onUpdated(() => {
|
|
33
|
+
callback();
|
|
34
|
+
});
|
|
35
|
+
onBeforeUnmount(() => {
|
|
36
|
+
EventBus.off(eventBusKey, callback);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return [
|
|
40
|
+
index,
|
|
41
|
+
first,
|
|
42
|
+
last
|
|
43
|
+
];
|
|
39
44
|
};
|
|
40
45
|
const emitParentUpdate = (eventBusKey) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
export {
|
|
46
|
-
emitParentUpdate as e,
|
|
47
|
-
useIndexOfChildren as u
|
|
46
|
+
onUpdated(() => {
|
|
47
|
+
EventBus.emit(eventBusKey);
|
|
48
|
+
});
|
|
48
49
|
};
|
|
50
|
+
export { useIndexOfChildren as n, emitParentUpdate as t };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
type LazyLoadOptions = {
|
|
3
|
+
onLoad?: (img: HTMLImageElement, event: Event) => void;
|
|
4
|
+
onError?: (img: HTMLImageElement, error: string | Event) => void;
|
|
5
|
+
onLoading?: (img: HTMLImageElement) => void;
|
|
6
|
+
rootMargin?: number | [number, number];
|
|
7
|
+
root?: HTMLElement | string;
|
|
8
|
+
};
|
|
9
|
+
export declare function useLazyLoad(imgRef: Ref<HTMLImageElement | null>, options?: LazyLoadOptions): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { B as y, D as S, _ as E, w as Qn } from "../../vendor.js";
|
|
2
|
+
import { n as logWarn } from "../util/console.js";
|
|
3
|
+
import { n as checkIntersection } from "../util/dom.js";
|
|
4
|
+
import { nextTick, onMounted, onUnmounted } from "vue";
|
|
5
|
+
var observedElementMap = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
var VIEWPORT_FAKE_ELEMENT = {};
|
|
7
|
+
var observerMap = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
var imgOptionsMap = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
function useLazyLoad(imgRef, options = {}) {
|
|
10
|
+
const curOptions = Qn(options, { lazyOffset: 0 });
|
|
11
|
+
let curRoot = void 0;
|
|
12
|
+
const loadImageImpl = (img, imgOptions, src, srcset) => {
|
|
13
|
+
var _imgOptions$onLoading;
|
|
14
|
+
(_imgOptions$onLoading = imgOptions.onLoading) === null || _imgOptions$onLoading === void 0 || _imgOptions$onLoading.call(imgOptions, img);
|
|
15
|
+
const tempImg = new Image();
|
|
16
|
+
tempImg.src = src || "";
|
|
17
|
+
tempImg.referrerPolicy = img.referrerPolicy;
|
|
18
|
+
tempImg.crossOrigin = img.crossOrigin;
|
|
19
|
+
tempImg.srcset = srcset || "";
|
|
20
|
+
tempImg.onload = (e) => {
|
|
21
|
+
var _imgOptions$onLoad;
|
|
22
|
+
(_imgOptions$onLoad = imgOptions.onLoad) === null || _imgOptions$onLoad === void 0 || _imgOptions$onLoad.call(imgOptions, img, e);
|
|
23
|
+
};
|
|
24
|
+
tempImg.onerror = (error) => {
|
|
25
|
+
var _imgOptions$onError;
|
|
26
|
+
(_imgOptions$onError = imgOptions.onError) === null || _imgOptions$onError === void 0 || _imgOptions$onError.call(imgOptions, img, error);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const loadImage = (img) => {
|
|
30
|
+
const src = img.dataset.src;
|
|
31
|
+
const srcset = img.dataset.srcset;
|
|
32
|
+
if (!src && !srcset) return;
|
|
33
|
+
loadImageImpl(img, imgOptionsMap.get(img), src, srcset);
|
|
34
|
+
};
|
|
35
|
+
const key = S(curOptions.rootMargin) ? `${curOptions.rootMargin[0]}-${curOptions.rootMargin[1]}` : String(curOptions.rootMargin);
|
|
36
|
+
const getObserver = () => {
|
|
37
|
+
const keyEl = curRoot || VIEWPORT_FAKE_ELEMENT;
|
|
38
|
+
let observers = observerMap.get(keyEl);
|
|
39
|
+
if (!observers) {
|
|
40
|
+
observerMap.set(keyEl, /* @__PURE__ */ new Map());
|
|
41
|
+
observers = observerMap.get(keyEl);
|
|
42
|
+
}
|
|
43
|
+
const observer = observers.get(key);
|
|
44
|
+
return {
|
|
45
|
+
observers,
|
|
46
|
+
observer
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const getObservedElements = (key$1) => {
|
|
50
|
+
const keyEl = curRoot || VIEWPORT_FAKE_ELEMENT;
|
|
51
|
+
let observedSetMap = observedElementMap.get(keyEl);
|
|
52
|
+
if (!observedSetMap) {
|
|
53
|
+
observedElementMap.set(keyEl, /* @__PURE__ */ new Map());
|
|
54
|
+
observedSetMap = observedElementMap.get(keyEl);
|
|
55
|
+
}
|
|
56
|
+
let observedSet = observedSetMap.get(key$1);
|
|
57
|
+
if (!observedSet) {
|
|
58
|
+
observedSetMap.set(key$1, /* @__PURE__ */ new Set());
|
|
59
|
+
observedSet = observedSetMap.get(key$1);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
observedSet,
|
|
63
|
+
observedSetMap
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const initObserver = () => {
|
|
67
|
+
const { observer, observers } = getObserver();
|
|
68
|
+
if (observer) return;
|
|
69
|
+
const rootMargin = !E(curOptions.rootMargin) ? S(curOptions.rootMargin) ? `${curOptions.rootMargin[1]}px ${curOptions.rootMargin[0]}px` : `${curOptions.rootMargin}px` : void 0;
|
|
70
|
+
const curObserver = new IntersectionObserver((entries) => {
|
|
71
|
+
entries.forEach((entry) => {
|
|
72
|
+
if (entry.isIntersecting) {
|
|
73
|
+
const img = entry.target;
|
|
74
|
+
loadImage(img);
|
|
75
|
+
unobserve(img);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}, {
|
|
79
|
+
root: curRoot,
|
|
80
|
+
rootMargin
|
|
81
|
+
});
|
|
82
|
+
observers.set(key, curObserver);
|
|
83
|
+
};
|
|
84
|
+
const observe = (img) => {
|
|
85
|
+
const { observedSet } = getObservedElements(key);
|
|
86
|
+
if (observedSet.has(img) || img.dataset.loaded === "true") return;
|
|
87
|
+
const { observers } = getObserver();
|
|
88
|
+
observers.get(key).observe(img);
|
|
89
|
+
observedSet.add(img);
|
|
90
|
+
imgOptionsMap.set(img, curOptions);
|
|
91
|
+
};
|
|
92
|
+
const unobserve = (img) => {
|
|
93
|
+
const { observedSet, observedSetMap } = getObservedElements(key);
|
|
94
|
+
const { observers } = getObserver();
|
|
95
|
+
observers.get(key).unobserve(img);
|
|
96
|
+
observedSet.delete(img);
|
|
97
|
+
imgOptionsMap.delete(img);
|
|
98
|
+
if (observedSet.size === 0) {
|
|
99
|
+
observers.get(key).disconnect();
|
|
100
|
+
observers.delete(key);
|
|
101
|
+
observedSetMap.delete(key);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const scanImages = () => {
|
|
105
|
+
if (!imgRef.value) return;
|
|
106
|
+
observe(imgRef.value);
|
|
107
|
+
};
|
|
108
|
+
const init = () => {
|
|
109
|
+
nextTick(() => {
|
|
110
|
+
if (!imgRef.value) return;
|
|
111
|
+
if (y(curOptions.root)) {
|
|
112
|
+
const dom = document.querySelector(curOptions.root);
|
|
113
|
+
if (dom instanceof HTMLElement) curRoot = dom;
|
|
114
|
+
else logWarn(`The DOM node for the visible area of lazy loading was not found, and the viewport is used as the visible area by default.`, true);
|
|
115
|
+
} else curRoot = curOptions.root;
|
|
116
|
+
initObserver();
|
|
117
|
+
const intersection = checkIntersection(imgRef.value, curRoot);
|
|
118
|
+
const marginX = S(curOptions.rootMargin) ? curOptions.rootMargin[0] : curOptions.rootMargin || 0;
|
|
119
|
+
const marginY = S(curOptions.rootMargin) ? curOptions.rootMargin[1] : curOptions.rootMargin || 0;
|
|
120
|
+
if (intersection.hasIntersection || intersection.x < marginX && intersection.y < marginY) {
|
|
121
|
+
const src = imgRef.value.dataset.src;
|
|
122
|
+
const srcset = imgRef.value.dataset.srcset;
|
|
123
|
+
if (src || srcset) loadImageImpl(imgRef.value, curOptions, src, srcset);
|
|
124
|
+
} else scanImages();
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
const destroy = () => {
|
|
128
|
+
if (imgRef.value) unobserve(imgRef.value);
|
|
129
|
+
};
|
|
130
|
+
onMounted(init);
|
|
131
|
+
onUnmounted(destroy);
|
|
132
|
+
}
|
|
133
|
+
export { useLazyLoad as t };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { Nullish } from 'parsnip-kit';
|
|
2
1
|
import { type Ref } from 'vue';
|
|
3
|
-
export declare const useResizeObserver: (ref: Ref<
|
|
2
|
+
export declare const useResizeObserver: (ref: Ref<HTMLElement | null | undefined>, callback: () => void, leading?: boolean) => void;
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
const useResizeObserver = (ref, callback, leading) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { n as inVitest, t as inBrowser } from "../util/env.js";
|
|
2
|
+
import { nextTick, onBeforeUnmount, onMounted, watch } from "vue";
|
|
3
|
+
const useResizeObserver = (ref$1, callback, leading) => {
|
|
4
|
+
if (leading) onMounted(() => {
|
|
5
|
+
nextTick(() => {
|
|
6
|
+
callback();
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
if (!inBrowser()) return;
|
|
10
|
+
if (inVitest()) return;
|
|
11
|
+
let resizeObserver = null;
|
|
12
|
+
watch(ref$1, (element) => {
|
|
13
|
+
if (resizeObserver) {
|
|
14
|
+
resizeObserver.disconnect();
|
|
15
|
+
resizeObserver = null;
|
|
16
|
+
}
|
|
17
|
+
if (element) {
|
|
18
|
+
resizeObserver = new ResizeObserver(callback);
|
|
19
|
+
resizeObserver.observe(element);
|
|
20
|
+
}
|
|
21
|
+
}, { flush: "post" });
|
|
22
|
+
onBeforeUnmount(() => {
|
|
23
|
+
if (resizeObserver) {
|
|
24
|
+
resizeObserver.disconnect();
|
|
25
|
+
resizeObserver = null;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
21
28
|
};
|
|
29
|
+
export { useResizeObserver as t };
|
|
@@ -1,38 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { s as SCREEN_SIZE_TYPE } from "../const/index.js";
|
|
2
|
+
import { t as inBrowser } from "../util/env.js";
|
|
3
|
+
import { computed, onBeforeUnmount, ref } from "vue";
|
|
4
4
|
const useScreenWidth = () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (inBrowser()) {
|
|
29
|
-
window.addEventListener("resize", handleResize);
|
|
30
|
-
onBeforeUnmount(() => {
|
|
31
|
-
window.removeEventListener("resize", handleResize);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return [screenSizeType, screenWidth];
|
|
35
|
-
};
|
|
36
|
-
export {
|
|
37
|
-
useScreenWidth as u
|
|
5
|
+
const screenWidth = ref(0);
|
|
6
|
+
function handleResize() {
|
|
7
|
+
if (!inBrowser()) return;
|
|
8
|
+
screenWidth.value = window.innerWidth;
|
|
9
|
+
}
|
|
10
|
+
handleResize();
|
|
11
|
+
const screenSizeType = computed(() => {
|
|
12
|
+
let type;
|
|
13
|
+
if (screenWidth.value <= 576) type = SCREEN_SIZE_TYPE.XS;
|
|
14
|
+
else if (screenWidth.value <= 768) type = SCREEN_SIZE_TYPE.SM;
|
|
15
|
+
else if (screenWidth.value <= 992) type = SCREEN_SIZE_TYPE.MD;
|
|
16
|
+
else if (screenWidth.value <= 1200) type = SCREEN_SIZE_TYPE.LG;
|
|
17
|
+
else if (screenWidth.value <= 1600) type = SCREEN_SIZE_TYPE.XL;
|
|
18
|
+
else type = SCREEN_SIZE_TYPE.XXL;
|
|
19
|
+
return type;
|
|
20
|
+
});
|
|
21
|
+
if (inBrowser()) {
|
|
22
|
+
window.addEventListener("resize", handleResize);
|
|
23
|
+
onBeforeUnmount(() => {
|
|
24
|
+
window.removeEventListener("resize", handleResize);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return [screenSizeType, screenWidth];
|
|
38
28
|
};
|
|
29
|
+
export { useScreenWidth as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type TransitionDirection = 'forward' | 'backward';
|
|
2
|
+
export declare function useSmoothTransition(duration?: number, initialValue?: number): readonly [import("vue").Ref<number, number>, (direction: TransitionDirection, newDuration?: number) => void, () => void, import("vue").Ref<boolean, boolean>];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { _ as E } from "../../vendor.js";
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
function cubicBezier(t, x1, y1, x2, y2) {
|
|
4
|
+
const calcBezier = (t$1, a1, a2) => {
|
|
5
|
+
return 3 * a1 * t$1 * (1 - t$1) ** 2 + 3 * a2 * t$1 ** 2 * (1 - t$1) + t$1 ** 3;
|
|
6
|
+
};
|
|
7
|
+
const getTForX = (x) => {
|
|
8
|
+
let low = 0, high = 1;
|
|
9
|
+
let tMid = x;
|
|
10
|
+
for (let i = 0; i < 8; i++) {
|
|
11
|
+
const xMid = calcBezier(tMid, x1, x2);
|
|
12
|
+
if (Math.abs(x - xMid) < 1e-6) return tMid;
|
|
13
|
+
if (x < xMid) high = tMid;
|
|
14
|
+
else low = tMid;
|
|
15
|
+
tMid = (low + high) / 2;
|
|
16
|
+
}
|
|
17
|
+
return tMid;
|
|
18
|
+
};
|
|
19
|
+
return calcBezier(getTForX(t), y1, y2);
|
|
20
|
+
}
|
|
21
|
+
var ease = (t) => cubicBezier(t, .25, .1, .25, 1);
|
|
22
|
+
function useSmoothTransition(duration = 250, initialValue = 0) {
|
|
23
|
+
const value = ref(Math.max(0, Math.min(1, initialValue)));
|
|
24
|
+
const isPlaying = ref(false);
|
|
25
|
+
let animationFrameId = null;
|
|
26
|
+
let startTime = null;
|
|
27
|
+
let startValue = null;
|
|
28
|
+
let targetValue = null;
|
|
29
|
+
const pause = () => {
|
|
30
|
+
if (animationFrameId) {
|
|
31
|
+
cancelAnimationFrame(animationFrameId);
|
|
32
|
+
animationFrameId = null;
|
|
33
|
+
}
|
|
34
|
+
isPlaying.value = false;
|
|
35
|
+
};
|
|
36
|
+
const update = (timestamp) => {
|
|
37
|
+
if (!startTime || E(startValue) || E(targetValue) || !duration) return;
|
|
38
|
+
const elapsed = timestamp - startTime;
|
|
39
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
40
|
+
const easedProgress = ease(progress);
|
|
41
|
+
value.value = startValue + (targetValue - startValue) * easedProgress;
|
|
42
|
+
if (progress < 1) animationFrameId = requestAnimationFrame(update);
|
|
43
|
+
else {
|
|
44
|
+
pause();
|
|
45
|
+
value.value = targetValue;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const play = (direction, newDuration = duration) => {
|
|
49
|
+
if (newDuration <= 0) return;
|
|
50
|
+
if (isPlaying.value && animationFrameId) cancelAnimationFrame(animationFrameId);
|
|
51
|
+
isPlaying.value = true;
|
|
52
|
+
startTime = performance.now();
|
|
53
|
+
startValue = value.value;
|
|
54
|
+
targetValue = direction === "forward" ? 1 : 0;
|
|
55
|
+
duration = newDuration;
|
|
56
|
+
animationFrameId = requestAnimationFrame(update);
|
|
57
|
+
};
|
|
58
|
+
return [
|
|
59
|
+
value,
|
|
60
|
+
play,
|
|
61
|
+
pause,
|
|
62
|
+
isPlaying
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
export { useSmoothTransition as t };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const HIDDEN_STYLE = `
|
|
1
|
+
import { P as ke, x as Nn } from "../../vendor.js";
|
|
2
|
+
import { t as inBrowser } from "../util/env.js";
|
|
3
|
+
import { t as useResizeObserver } from "./use-resize-observer.js";
|
|
4
|
+
import { onBeforeUnmount, ref } from "vue";
|
|
5
|
+
var hiddenTextarea = null;
|
|
6
|
+
var HIDDEN_STYLE = `
|
|
8
7
|
position:absolute!important;
|
|
9
8
|
top:-9999px!important;
|
|
10
9
|
left:-9999px!important;
|
|
@@ -16,101 +15,96 @@ const HIDDEN_STYLE = `
|
|
|
16
15
|
height:0!important;
|
|
17
16
|
z-index:-9999!important;
|
|
18
17
|
`;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
var SIZING_STYLE = [
|
|
19
|
+
"letter-spacing",
|
|
20
|
+
"line-height",
|
|
21
|
+
"padding-top",
|
|
22
|
+
"padding-bottom",
|
|
23
|
+
"font-family",
|
|
24
|
+
"font-weight",
|
|
25
|
+
"font-size",
|
|
26
|
+
"font-variant",
|
|
27
|
+
"text-rendering",
|
|
28
|
+
"text-transform",
|
|
29
|
+
"width",
|
|
30
|
+
"padding-left",
|
|
31
|
+
"padding-right",
|
|
32
|
+
"border-width",
|
|
33
|
+
"box-sizing"
|
|
35
34
|
];
|
|
36
35
|
function calculateNodeStyling(target) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
const style = window.getComputedStyle(target);
|
|
37
|
+
const boxSizing = style.getPropertyValue("box-sizing");
|
|
38
|
+
const paddingSize = parseFloat(style.getPropertyValue("padding-top")) + parseFloat(style.getPropertyValue("padding-bottom"));
|
|
39
|
+
const borderSize = parseFloat(style.getPropertyValue("border-top-width")) + parseFloat(style.getPropertyValue("border-bottom-width"));
|
|
40
|
+
return {
|
|
41
|
+
sizingStyle: SIZING_STYLE.map((name) => `${name}:${style.getPropertyValue(name)}`).join(";"),
|
|
42
|
+
paddingSize,
|
|
43
|
+
borderSize,
|
|
44
|
+
boxSizing
|
|
45
|
+
};
|
|
45
46
|
}
|
|
46
47
|
function getHeight(node, minRows = 1, maxRows = Infinity) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
minHeight,
|
|
68
|
-
maxHeight
|
|
69
|
-
};
|
|
48
|
+
if (!hiddenTextarea) {
|
|
49
|
+
hiddenTextarea = document.createElement("textarea");
|
|
50
|
+
document.body.appendChild(hiddenTextarea);
|
|
51
|
+
}
|
|
52
|
+
const { sizingStyle, paddingSize, borderSize, boxSizing } = calculateNodeStyling(node);
|
|
53
|
+
const nodeWidth = node.getBoundingClientRect().width;
|
|
54
|
+
hiddenTextarea.setAttribute("style", `${sizingStyle};${Nn(HIDDEN_STYLE, (pattern) => pattern === "width" ? String(nodeWidth) : "")}`);
|
|
55
|
+
hiddenTextarea.value = "";
|
|
56
|
+
let singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
|
|
57
|
+
const minHeight = singleRowHeight * minRows + (boxSizing === "border-box" ? paddingSize + borderSize : 0);
|
|
58
|
+
const maxHeight = singleRowHeight * maxRows + (boxSizing === "border-box" ? paddingSize + borderSize : 0);
|
|
59
|
+
hiddenTextarea.value = node.value || node.placeholder || "";
|
|
60
|
+
let height = hiddenTextarea.scrollHeight;
|
|
61
|
+
height += +(boxSizing === "border-box") * borderSize;
|
|
62
|
+
height = ke(height, minHeight, maxHeight);
|
|
63
|
+
return {
|
|
64
|
+
height,
|
|
65
|
+
minHeight,
|
|
66
|
+
maxHeight
|
|
67
|
+
};
|
|
70
68
|
}
|
|
71
|
-
|
|
69
|
+
var textareaMounted = 0;
|
|
72
70
|
function calcTextareaHeight(textarea, minRows, maxRows) {
|
|
73
|
-
|
|
74
|
-
return height;
|
|
71
|
+
return getHeight(textarea, minRows, maxRows);
|
|
75
72
|
}
|
|
76
73
|
function destroyHiddenTextarea() {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
textareaMounted--;
|
|
75
|
+
if (hiddenTextarea && textareaMounted <= 0) {
|
|
76
|
+
hiddenTextarea.remove();
|
|
77
|
+
hiddenTextarea = null;
|
|
78
|
+
}
|
|
82
79
|
}
|
|
83
80
|
function recordTextareaMounted() {
|
|
84
|
-
|
|
81
|
+
textareaMounted++;
|
|
85
82
|
}
|
|
86
83
|
const useTextareaHeight = (textareaRef, props) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return [height, minHeight, maxHeight, callback];
|
|
113
|
-
};
|
|
114
|
-
export {
|
|
115
|
-
useTextareaHeight as u
|
|
84
|
+
const height = ref(void 0);
|
|
85
|
+
const minHeight = ref(void 0);
|
|
86
|
+
const maxHeight = ref(void 0);
|
|
87
|
+
const callback = () => {
|
|
88
|
+
if (!inBrowser()) return;
|
|
89
|
+
if (textareaRef.value) {
|
|
90
|
+
const data = calcTextareaHeight(textareaRef.value, props.minRows || 1, props.maxRows || Infinity);
|
|
91
|
+
height.value = data.height;
|
|
92
|
+
maxHeight.value = data.maxHeight;
|
|
93
|
+
minHeight.value = data.minHeight;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
if (inBrowser()) {
|
|
97
|
+
recordTextareaMounted();
|
|
98
|
+
useResizeObserver(textareaRef, callback, true);
|
|
99
|
+
onBeforeUnmount(() => {
|
|
100
|
+
destroyHiddenTextarea();
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return [
|
|
104
|
+
height,
|
|
105
|
+
minHeight,
|
|
106
|
+
maxHeight,
|
|
107
|
+
callback
|
|
108
|
+
];
|
|
116
109
|
};
|
|
110
|
+
export { useTextareaHeight as t };
|