@pixelium/web-vue 0.0.2-fix → 0.0.3-beta

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.
Files changed (285) hide show
  1. package/README.md +42 -0
  2. package/README.zh.md +6 -3
  3. package/coverage/base.css +224 -0
  4. package/coverage/block-navigation.js +87 -0
  5. package/coverage/coverage-final.json +106 -0
  6. package/coverage/favicon.png +0 -0
  7. package/coverage/index.html +926 -0
  8. package/coverage/prettify.css +1 -0
  9. package/coverage/prettify.js +2 -0
  10. package/coverage/sort-arrow-sprite.png +0 -0
  11. package/coverage/sorter.js +210 -0
  12. package/dist/font.css +1 -1
  13. package/dist/index.d.ts +1593 -248
  14. package/dist/normalize.css +2 -0
  15. package/dist/pixelium-vue-icon-hn.cjs +1 -1
  16. package/dist/pixelium-vue-icon-hn.css +2 -1
  17. package/dist/pixelium-vue-icon-hn.js +8533 -8154
  18. package/dist/pixelium-vue-icon-hn.umd.cjs +1 -1
  19. package/dist/pixelium-vue-icon-pa.cjs +1 -1
  20. package/dist/pixelium-vue-icon-pa.css +2 -1
  21. package/dist/pixelium-vue-icon-pa.js +10625 -10143
  22. package/dist/pixelium-vue-icon-pa.umd.cjs +1 -1
  23. package/dist/pixelium-vue.cjs +2 -2
  24. package/dist/pixelium-vue.css +2 -1
  25. package/dist/pixelium-vue.js +7402 -5854
  26. package/dist/pixelium-vue.umd.cjs +2 -2
  27. package/es/aside/index.js +46 -151
  28. package/es/auto-complete/draw.d.ts +1 -1
  29. package/es/auto-complete/draw.js +26 -51
  30. package/es/auto-complete/index.css +92 -32
  31. package/es/auto-complete/index.d.ts +12 -15
  32. package/es/auto-complete/index.js +338 -400
  33. package/es/auto-complete/type.d.ts +25 -13
  34. package/es/avatar/css.js +2 -0
  35. package/es/avatar/draw.d.ts +2 -0
  36. package/es/avatar/draw.js +11 -0
  37. package/es/avatar/index.css +49 -0
  38. package/es/avatar/index.d.ts +15 -0
  39. package/es/avatar/index.js +110 -0
  40. package/es/avatar/type.d.ts +34 -0
  41. package/es/button/draw.d.ts +4 -4
  42. package/es/button/draw.js +213 -297
  43. package/es/button/index.css +40 -30
  44. package/es/button/index.d.ts +0 -4
  45. package/es/button/index.js +230 -256
  46. package/es/button/type.d.ts +3 -3
  47. package/es/button-group/index.css +0 -3
  48. package/es/button-group/index.d.ts +1 -2
  49. package/es/button-group/index.js +59 -31
  50. package/es/button-group/type.d.ts +21 -4
  51. package/es/checkbox/css.js +2 -0
  52. package/es/checkbox/draw.d.ts +4 -0
  53. package/es/checkbox/draw.js +46 -0
  54. package/es/checkbox/index.css +85 -0
  55. package/es/checkbox/index.d.ts +31 -0
  56. package/es/checkbox/index.js +206 -0
  57. package/es/checkbox/type.d.ts +88 -0
  58. package/es/checkbox-group/css.js +2 -0
  59. package/es/checkbox-group/index.css +20 -0
  60. package/es/checkbox-group/index.d.ts +23 -0
  61. package/es/checkbox-group/index.js +84 -0
  62. package/es/checkbox-group/type.d.ts +78 -0
  63. package/es/col/index.d.ts +2 -2
  64. package/es/col/index.js +43 -58
  65. package/es/container/index.js +18 -31
  66. package/es/divider/index.js +39 -53
  67. package/es/empty/index.css +4 -4
  68. package/es/empty/index.js +16 -71
  69. package/es/entry.js +102 -0
  70. package/es/footer/index.js +31 -40
  71. package/es/form/css.js +1 -0
  72. package/es/form/index.d.ts +27 -0
  73. package/es/form/index.js +125 -0
  74. package/es/form/type.d.ts +238 -0
  75. package/es/form/use-form.d.ts +4 -0
  76. package/es/form/use-form.js +48 -0
  77. package/es/form-item/css.js +2 -0
  78. package/es/form-item/index.css +77 -0
  79. package/es/form-item/index.d.ts +37 -0
  80. package/es/form-item/index.js +318 -0
  81. package/es/form-item/type.d.ts +96 -0
  82. package/es/grid/index.js +56 -75
  83. package/es/grid-item/css.js +0 -1
  84. package/es/grid-item/index.d.ts +1 -1
  85. package/es/grid-item/index.js +85 -121
  86. package/es/header/index.js +31 -40
  87. package/es/icon/index.js +44 -55
  88. package/es/icons/css-hn.js +0 -1
  89. package/es/icons/css-pa.js +0 -1
  90. package/es/icons/icon-hn.js +10337 -15986
  91. package/es/icons/icon-pa.js +12573 -17447
  92. package/es/image/css.js +2 -0
  93. package/es/image/index.css +69 -0
  94. package/es/image/index.d.ts +35 -0
  95. package/es/image/index.js +199 -0
  96. package/es/image/type.d.ts +126 -0
  97. package/es/index.css +1 -515
  98. package/es/index.d.ts +22 -2
  99. package/es/index.js +143 -123
  100. package/es/input/draw.d.ts +1 -1
  101. package/es/input/draw.js +26 -51
  102. package/es/input/index.css +85 -33
  103. package/es/input/index.d.ts +9 -16
  104. package/es/input/index.js +319 -423
  105. package/es/input/type.d.ts +3 -3
  106. package/es/input-group/index.css +0 -1
  107. package/es/input-group/index.d.ts +2 -2
  108. package/es/input-group/index.js +66 -37
  109. package/es/input-group/type.d.ts +16 -4
  110. package/es/input-group-label/draw.d.ts +1 -1
  111. package/es/input-group-label/draw.js +26 -51
  112. package/es/input-group-label/index.css +33 -22
  113. package/es/input-group-label/index.d.ts +1 -4
  114. package/es/input-group-label/index.js +104 -127
  115. package/es/input-group-label/type.d.ts +3 -3
  116. package/es/input-number/draw.d.ts +1 -1
  117. package/es/input-number/draw.js +26 -51
  118. package/es/input-number/index.css +90 -35
  119. package/es/input-number/index.d.ts +9 -16
  120. package/es/input-number/index.js +428 -536
  121. package/es/input-number/type.d.ts +3 -3
  122. package/es/input-tag/draw.d.ts +1 -1
  123. package/es/input-tag/draw.js +26 -48
  124. package/es/input-tag/index.css +100 -33
  125. package/es/input-tag/index.d.ts +7 -13
  126. package/es/input-tag/index.js +442 -467
  127. package/es/input-tag/type.d.ts +24 -13
  128. package/es/link/index.js +75 -106
  129. package/es/main/index.js +11 -15
  130. package/es/mask/index.js +94 -115
  131. package/es/message/index.css +1 -1
  132. package/es/message/index.js +168 -346
  133. package/es/message-box/css.js +1 -1
  134. package/es/message-box/index.js +98 -114
  135. package/es/message-box/message-box-wrapped.js +33 -46
  136. package/es/message-box/message-box.js +79 -111
  137. package/es/option-list/index.css +13 -13
  138. package/es/option-list/index.d.ts +4 -31
  139. package/es/option-list/index.js +99 -167
  140. package/es/option-list/type.d.ts +5 -1
  141. package/es/pixelate/pixel.d.ts +5 -0
  142. package/es/pixelate/pixel.js +70 -0
  143. package/es/pixelate/pixelate.worker.d.ts +1 -0
  144. package/es/popover/index.d.ts +13 -99
  145. package/es/popover/index.js +75 -238
  146. package/es/popover/type.d.ts +7 -2
  147. package/es/popup/css.js +1 -0
  148. package/es/popup/index.d.ts +210 -0
  149. package/es/popup/index.js +203 -0
  150. package/es/popup/type.d.ts +105 -0
  151. package/es/popup-content/draw.d.ts +2 -2
  152. package/es/popup-content/draw.js +98 -143
  153. package/es/popup-content/index.css +11 -11
  154. package/es/popup-content/index.d.ts +1 -0
  155. package/es/popup-content/index.js +253 -1576
  156. package/es/popup-content/type.d.ts +1 -0
  157. package/es/popup-trigger/index.d.ts +8 -2
  158. package/es/popup-trigger/index.js +122 -95
  159. package/es/popup-trigger/type.d.ts +4 -1
  160. package/es/popup-wrapper/css.js +2 -0
  161. package/es/popup-wrapper/index.css +14 -0
  162. package/es/popup-wrapper/index.d.ts +18 -0
  163. package/es/popup-wrapper/index.js +67 -0
  164. package/es/popup-wrapper/type.d.ts +9 -0
  165. package/es/radio/css.js +1 -0
  166. package/es/radio/draw.d.ts +4 -0
  167. package/es/radio/draw.js +47 -0
  168. package/es/radio/index.d.ts +30 -0
  169. package/es/radio/index.js +190 -0
  170. package/es/radio/style.css +73 -0
  171. package/es/radio/type.d.ts +76 -0
  172. package/es/radio-group/css.js +2 -0
  173. package/es/radio-group/index.css +20 -0
  174. package/es/radio-group/index.d.ts +23 -0
  175. package/es/radio-group/index.js +77 -0
  176. package/es/radio-group/type.d.ts +77 -0
  177. package/es/row/index.js +56 -70
  178. package/es/select/draw.d.ts +1 -1
  179. package/es/select/draw.js +26 -51
  180. package/es/select/index.css +118 -36
  181. package/es/select/index.d.ts +14 -16
  182. package/es/select/index.js +625 -675
  183. package/es/select/type.d.ts +60 -25
  184. package/es/share/const/event-bus-key.js +1 -6
  185. package/es/share/const/index.d.ts +4 -0
  186. package/es/share/const/index.js +22 -24
  187. package/es/share/const/provide-key.d.ts +5 -0
  188. package/es/share/const/provide-key.js +6 -5
  189. package/es/share/const/style.d.ts +6 -0
  190. package/es/share/const/style.js +7 -0
  191. package/es/share/hook/use-cancelable-delay.d.ts +1 -0
  192. package/es/share/hook/use-cancelable-delay.js +42 -0
  193. package/es/share/hook/use-click-outside-listener.d.ts +1 -1
  194. package/es/share/hook/use-click-outside-listener.js +28 -41
  195. package/es/share/hook/use-composition.js +17 -15
  196. package/es/share/hook/use-controlled-mode.d.ts +3 -3
  197. package/es/share/hook/use-controlled-mode.js +20 -23
  198. package/es/share/hook/use-dark-mode.js +51 -65
  199. package/es/share/hook/use-index-of-children.d.ts +2 -1
  200. package/es/share/hook/use-index-of-children.js +47 -45
  201. package/es/share/hook/use-lazy-load.d.ts +10 -0
  202. package/es/share/hook/use-lazy-load.js +133 -0
  203. package/es/share/hook/use-props-detect.d.ts +2 -0
  204. package/es/share/hook/use-resize-observer.d.ts +1 -2
  205. package/es/share/hook/use-resize-observer.js +28 -20
  206. package/es/share/hook/use-screen-width.js +27 -36
  207. package/es/share/hook/use-smooth-transition.d.ts +2 -0
  208. package/es/share/hook/use-smooth-transition.js +65 -0
  209. package/es/share/hook/use-textarea-height.js +86 -92
  210. package/es/share/hook/use-theme-mode.js +41 -42
  211. package/es/share/hook/use-transition-end.d.ts +2 -0
  212. package/es/share/hook/use-transition-end.js +12 -0
  213. package/es/share/hook/use-watch-global-css-var.js +12 -16
  214. package/es/share/hook/use-window-resize-listener.d.ts +1 -0
  215. package/es/share/hook/use-window-resize-listener.js +15 -0
  216. package/es/share/hook/use-z-index.js +30 -27
  217. package/es/share/type/index.d.ts +18 -3
  218. package/es/share/util/color.d.ts +5 -3
  219. package/es/share/util/color.js +156 -149
  220. package/es/share/util/common.d.ts +7 -2
  221. package/es/share/util/common.js +127 -65
  222. package/es/share/util/console.d.ts +3 -3
  223. package/es/share/util/console.js +10 -7
  224. package/es/share/util/dom.d.ts +19 -0
  225. package/es/share/util/dom.js +88 -0
  226. package/es/share/util/env.d.ts +1 -0
  227. package/es/share/util/env.js +5 -4
  228. package/es/share/util/event-bus.js +3 -20
  229. package/es/share/util/lru-cache.js +29 -33
  230. package/es/share/util/pixel.d.ts +4 -0
  231. package/es/share/util/plot.d.ts +8 -3
  232. package/es/share/util/plot.js +457 -229
  233. package/es/share/util/reactivity.d.ts +8 -0
  234. package/es/share/util/reactivity.js +23 -0
  235. package/es/share/util/render.js +31 -41
  236. package/es/share/util/theme.d.ts +3 -0
  237. package/es/share/util/theme.js +77 -57
  238. package/es/slider/css.js +2 -0
  239. package/es/slider/draw.d.ts +25 -0
  240. package/es/slider/draw.js +113 -0
  241. package/es/slider/index.css +119 -0
  242. package/es/slider/index.d.ts +66 -0
  243. package/es/slider/index.js +503 -0
  244. package/es/slider/type.d.ts +162 -0
  245. package/es/slider/util.d.ts +37 -0
  246. package/es/slider/util.js +130 -0
  247. package/es/space/index.css +24 -29
  248. package/es/space/index.js +73 -97
  249. package/es/spin/index.css +18 -17
  250. package/es/spin/index.js +72 -102
  251. package/es/spin/type.d.ts +11 -5
  252. package/es/switch/css.js +2 -0
  253. package/es/switch/draw.d.ts +2 -0
  254. package/es/switch/draw.js +18 -0
  255. package/es/switch/index.css +121 -0
  256. package/es/switch/index.d.ts +42 -0
  257. package/es/switch/index.js +259 -0
  258. package/es/switch/type.d.ts +133 -0
  259. package/es/tag/draw.d.ts +2 -2
  260. package/es/tag/draw.js +80 -127
  261. package/es/tag/index.css +38 -22
  262. package/es/tag/index.d.ts +2 -2
  263. package/es/tag/index.js +121 -190
  264. package/es/tag/type.d.ts +3 -3
  265. package/es/text-outline/css.js +2 -0
  266. package/es/text-outline/index.css +4 -0
  267. package/es/text-outline/index.d.ts +17 -0
  268. package/es/text-outline/index.js +33 -0
  269. package/es/text-outline/type.d.ts +23 -0
  270. package/es/textarea/draw.js +9 -11
  271. package/es/textarea/index.css +37 -23
  272. package/es/textarea/index.d.ts +8 -14
  273. package/es/textarea/index.js +274 -262
  274. package/es/tooltip/index.d.ts +100 -4
  275. package/es/tooltip/index.js +70 -226
  276. package/es/tooltip/type.d.ts +7 -2
  277. package/es/vendor.js +504 -0
  278. package/es/virtual-list/css.js +2 -0
  279. package/es/virtual-list/index.css +25 -0
  280. package/es/virtual-list/index.d.ts +11 -0
  281. package/es/virtual-list/index.js +313 -0
  282. package/es/virtual-list/type.d.ts +26 -0
  283. package/package.json +10 -16
  284. package/es/grid-item/index.css +0 -0
  285. /package/es/message-box/{message-box.css → index.css} +0 -0
@@ -1,48 +1,50 @@
1
- import { onUpdated, ref, getCurrentInstance, onMounted, nextTick, onBeforeUnmount } from "vue";
2
- import { i as inBrowser } from "../util/env.js";
3
- import { E as EventBus } from "../util/event-bus.js";
4
- const useIndexOfChildren = (eventBusKey) => {
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 && instance.vnode.el instanceof HTMLElement) {
11
- const parent = instance.vnode.el.parentElement;
12
- if (parent && parent.children.length) {
13
- const arr = [...parent.children];
14
- index.value = arr.indexOf(instance.vnode.el);
15
- last.value = index.value === parent.children.length - 1;
16
- first.value = index.value === 0;
17
- } else {
18
- index.value = -1;
19
- last.value = false;
20
- first.value = false;
21
- }
22
- }
23
- };
24
- if (inBrowser()) {
25
- EventBus.on(eventBusKey, callback);
26
- onMounted(() => {
27
- nextTick(() => {
28
- callback();
29
- });
30
- });
31
- onUpdated(() => {
32
- callback();
33
- });
34
- onBeforeUnmount(() => {
35
- EventBus.off(eventBusKey, callback);
36
- });
37
- }
38
- return [index, first, last];
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
- onUpdated(() => {
42
- EventBus.emit(eventBusKey);
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 };
@@ -0,0 +1,2 @@
1
+ import { type Ref } from 'vue';
2
+ export declare function usePropsDetect<T extends Record<string, any>, U extends keyof T>(props: T, fields?: Array<U> | U, emptyValues?: Record<U, any>): Ref<Record<U, boolean>, Record<U, boolean>>;
@@ -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<Nullish | HTMLElement>, callback: () => any, leading?: boolean) => ResizeObserver | null;
2
+ export declare const useResizeObserver: (ref: Ref<HTMLElement | null | undefined>, callback: () => void, leading?: boolean) => void;
@@ -1,21 +1,29 @@
1
- import { onMounted, onBeforeUnmount } from "vue";
2
- import { i as inBrowser } from "../util/env.js";
3
- const useResizeObserver = (ref, callback, leading) => {
4
- if (!inBrowser()) {
5
- return null;
6
- }
7
- const resizeObserver = new ResizeObserver(callback);
8
- onMounted(() => {
9
- setTimeout(() => {
10
- leading && callback();
11
- ref.value && resizeObserver.observe(ref.value);
12
- });
13
- });
14
- onBeforeUnmount(() => {
15
- resizeObserver.disconnect();
16
- });
17
- return resizeObserver;
18
- };
19
- export {
20
- useResizeObserver as u
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 { ref, computed, onBeforeUnmount } from "vue";
2
- import { S as SCREEN_SIZE_TYPE } from "../const/index.js";
3
- import { i as inBrowser } from "../util/env.js";
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
- 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) {
14
- type = SCREEN_SIZE_TYPE.XS;
15
- } else if (screenWidth.value <= 768) {
16
- type = SCREEN_SIZE_TYPE.SM;
17
- } else if (screenWidth.value <= 992) {
18
- type = SCREEN_SIZE_TYPE.MD;
19
- } else if (screenWidth.value <= 1200) {
20
- type = SCREEN_SIZE_TYPE.LG;
21
- } else if (screenWidth.value <= 1600) {
22
- type = SCREEN_SIZE_TYPE.XL;
23
- } else {
24
- type = SCREEN_SIZE_TYPE.XXL;
25
- }
26
- return type;
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 { C as Cn } from "../../aside/index.js";
2
- import { c as clamp } from "../util/common.js";
3
- import { ref, onBeforeUnmount } from "vue";
4
- import { u as useResizeObserver } from "./use-resize-observer.js";
5
- import { i as inBrowser } from "../util/env.js";
6
- let hiddenTextarea = null;
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
- const SIZING_STYLE = [
20
- "letter-spacing",
21
- "line-height",
22
- "padding-top",
23
- "padding-bottom",
24
- "font-family",
25
- "font-weight",
26
- "font-size",
27
- "font-variant",
28
- "text-rendering",
29
- "text-transform",
30
- "width",
31
- "padding-left",
32
- "padding-right",
33
- "border-width",
34
- "box-sizing"
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
- const style = window.getComputedStyle(target);
38
- const boxSizing = style.getPropertyValue("box-sizing");
39
- const paddingSize = parseFloat(style.getPropertyValue("padding-top")) + parseFloat(style.getPropertyValue("padding-bottom"));
40
- const borderSize = parseFloat(style.getPropertyValue("border-top-width")) + parseFloat(style.getPropertyValue("border-bottom-width"));
41
- const sizingStyle = SIZING_STYLE.map(
42
- (name) => `${name}:${style.getPropertyValue(name)}`
43
- ).join(";");
44
- return { sizingStyle, paddingSize, borderSize, boxSizing };
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
- if (!hiddenTextarea) {
48
- hiddenTextarea = document.createElement("textarea");
49
- document.body.appendChild(hiddenTextarea);
50
- }
51
- const { sizingStyle, paddingSize, borderSize, boxSizing } = calculateNodeStyling(node);
52
- const nodeWidth = node.getBoundingClientRect().width;
53
- hiddenTextarea.setAttribute(
54
- "style",
55
- `${sizingStyle};${Cn(HIDDEN_STYLE, (pattern) => pattern === "width" ? String(nodeWidth) : "")}`
56
- );
57
- hiddenTextarea.value = "";
58
- let singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
59
- const minHeight = singleRowHeight * minRows + (boxSizing === "border-box" ? paddingSize + borderSize : 0);
60
- const maxHeight = singleRowHeight * maxRows + (boxSizing === "border-box" ? paddingSize + borderSize : 0);
61
- hiddenTextarea.value = node.value || node.placeholder || "";
62
- let height = hiddenTextarea.scrollHeight;
63
- height += +(boxSizing === "border-box") * borderSize;
64
- height = clamp(height, minHeight, maxHeight);
65
- return {
66
- height,
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
- let textareaMounted = 0;
69
+ var textareaMounted = 0;
72
70
  function calcTextareaHeight(textarea, minRows, maxRows) {
73
- const height = getHeight(textarea, minRows, maxRows);
74
- return height;
71
+ return getHeight(textarea, minRows, maxRows);
75
72
  }
76
73
  function destroyHiddenTextarea() {
77
- textareaMounted--;
78
- if (hiddenTextarea && textareaMounted <= 0) {
79
- hiddenTextarea.remove();
80
- hiddenTextarea = null;
81
- }
74
+ textareaMounted--;
75
+ if (hiddenTextarea && textareaMounted <= 0) {
76
+ hiddenTextarea.remove();
77
+ hiddenTextarea = null;
78
+ }
82
79
  }
83
80
  function recordTextareaMounted() {
84
- textareaMounted++;
81
+ textareaMounted++;
85
82
  }
86
83
  const useTextareaHeight = (textareaRef, props) => {
87
- const height = ref(void 0);
88
- const minHeight = ref(void 0);
89
- const maxHeight = ref(void 0);
90
- const callback = () => {
91
- if (!inBrowser()) {
92
- return;
93
- }
94
- if (textareaRef.value) {
95
- const data = calcTextareaHeight(
96
- textareaRef.value,
97
- props.minRows || 1,
98
- props.maxRows || Infinity
99
- );
100
- height.value = data.height;
101
- maxHeight.value = data.maxHeight;
102
- minHeight.value = data.minHeight;
103
- }
104
- };
105
- if (inBrowser()) {
106
- recordTextareaMounted();
107
- useResizeObserver(textareaRef, callback, true);
108
- onBeforeUnmount(() => {
109
- destroyHiddenTextarea();
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 };