tttb 0.1.24

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 (235) hide show
  1. package/README.md +42 -0
  2. package/dist/_virtual/_plugin-vue_export-helper.js +9 -0
  3. package/dist/components/Button/index.js +6 -0
  4. package/dist/components/Button/index.vue.js +7 -0
  5. package/dist/components/Button/index.vue2.js +57 -0
  6. package/dist/components/Button/types.js +8 -0
  7. package/dist/components/Checkbox/index.js +6 -0
  8. package/dist/components/Checkbox/index.vue.js +7 -0
  9. package/dist/components/Checkbox/index.vue2.js +35 -0
  10. package/dist/components/Checkbox/types.js +7 -0
  11. package/dist/components/Dialog/DialogItem.vue.js +7 -0
  12. package/dist/components/Dialog/DialogItem.vue2.js +78 -0
  13. package/dist/components/Dialog/DialogPrompt.vue.js +7 -0
  14. package/dist/components/Dialog/DialogPrompt.vue2.js +63 -0
  15. package/dist/components/Dialog/index.js +6 -0
  16. package/dist/components/Dialog/index.vue.js +7 -0
  17. package/dist/components/Dialog/index.vue2.js +81 -0
  18. package/dist/components/Icon/index.js +6 -0
  19. package/dist/components/Icon/index.vue.js +43 -0
  20. package/dist/components/Icon/index.vue2.js +4 -0
  21. package/dist/components/Loading/index.js +6 -0
  22. package/dist/components/Loading/index.vue.js +7 -0
  23. package/dist/components/Loading/index.vue2.js +37 -0
  24. package/dist/components/Loading/types.js +7 -0
  25. package/dist/components/Message/index.js +6 -0
  26. package/dist/components/Message/index.vue.js +7 -0
  27. package/dist/components/Message/index.vue2.js +91 -0
  28. package/dist/components/Modal/index.js +6 -0
  29. package/dist/components/Modal/index.vue.js +7 -0
  30. package/dist/components/Modal/index.vue2.js +39 -0
  31. package/dist/components/Modal/types.js +7 -0
  32. package/dist/components/Nav/index.js +6 -0
  33. package/dist/components/Nav/index.vue.js +7 -0
  34. package/dist/components/Nav/index.vue2.js +95 -0
  35. package/dist/components/Pagination/index.js +6 -0
  36. package/dist/components/Pagination/index.vue.js +7 -0
  37. package/dist/components/Pagination/index.vue2.js +162 -0
  38. package/dist/components/Pagination/types.js +8 -0
  39. package/dist/components/Popconfirm/index.js +7 -0
  40. package/dist/components/Popconfirm/index.vue.js +92 -0
  41. package/dist/components/Popconfirm/index.vue3.js +5 -0
  42. package/dist/components/Popconfirm/types.js +14 -0
  43. package/dist/components/Popover/index.js +7 -0
  44. package/dist/components/Popover/index.vue.js +32 -0
  45. package/dist/components/Popover/index.vue3.js +5 -0
  46. package/dist/components/Progress/index.js +6 -0
  47. package/dist/components/Progress/index.vue.js +7 -0
  48. package/dist/components/Progress/index.vue2.js +38 -0
  49. package/dist/components/Progress/types.js +7 -0
  50. package/dist/components/RouterNav/index.js +6 -0
  51. package/dist/components/RouterNav/index.vue.js +33 -0
  52. package/dist/components/RouterNav/index.vue2.js +4 -0
  53. package/dist/components/Switch/index.js +6 -0
  54. package/dist/components/Switch/index.vue.js +7 -0
  55. package/dist/components/Switch/index.vue2.js +76 -0
  56. package/dist/components/Switch/types.js +6 -0
  57. package/dist/components/Table/index.js +6 -0
  58. package/dist/components/Table/index.vue.js +7 -0
  59. package/dist/components/Table/index.vue2.js +57 -0
  60. package/dist/components/Timer/index.js +6 -0
  61. package/dist/components/Timer/index.vue.js +31 -0
  62. package/dist/components/Timer/index.vue2.js +4 -0
  63. package/dist/components/Tooltip/TooltipContent.vue.js +33 -0
  64. package/dist/components/Tooltip/TooltipContent.vue2.js +4 -0
  65. package/dist/components/Tooltip/TooltipItem.vue.js +58 -0
  66. package/dist/components/Tooltip/TooltipItem.vue2.js +4 -0
  67. package/dist/components/Tooltip/TooltipLayer.vue.js +49 -0
  68. package/dist/components/Tooltip/TooltipLayer.vue2.js +4 -0
  69. package/dist/components/Tooltip/index.js +6 -0
  70. package/dist/components/Tooltip/index.vue.js +74 -0
  71. package/dist/components/Tooltip/index.vue2.js +4 -0
  72. package/dist/components/Tooltip/manager.js +107 -0
  73. package/dist/components/Tooltip/types.js +21 -0
  74. package/dist/components/Tooltip/useTooltip.js +43 -0
  75. package/dist/components/Warn/index.js +6 -0
  76. package/dist/components/Warn/index.vue.js +7 -0
  77. package/dist/components/Warn/index.vue2.js +21 -0
  78. package/dist/components/Warn/types.js +6 -0
  79. package/dist/components/Watermark/index.js +6 -0
  80. package/dist/components/Watermark/index.vue.js +7 -0
  81. package/dist/components/Watermark/index.vue2.js +54 -0
  82. package/dist/components/Watermark/types.js +10 -0
  83. package/dist/components/Watermark/useWatermarkBg.js +11 -0
  84. package/dist/components/helpers.js +25 -0
  85. package/dist/components.js +40 -0
  86. package/dist/directives/vBackTop.js +110 -0
  87. package/dist/directives/vDelayIn.js +41 -0
  88. package/dist/directives/vHoldPointer.js +112 -0
  89. package/dist/directives/vLazy.js +65 -0
  90. package/dist/directives/vLoading.js +50 -0
  91. package/dist/directives/vRipple.js +81 -0
  92. package/dist/directives/vSlideIn.js +39 -0
  93. package/dist/directives/vTextJump.js +50 -0
  94. package/dist/directives/vTooltip.js +55 -0
  95. package/dist/directives.js +20 -0
  96. package/dist/hooks/useAudio.js +112 -0
  97. package/dist/hooks/useElementScroll.js +30 -0
  98. package/dist/hooks/useGSAP.js +40 -0
  99. package/dist/hooks/useRefreshRate.js +26 -0
  100. package/dist/hooks/useWindowBackTop.js +86 -0
  101. package/dist/hooks.js +13 -0
  102. package/dist/icons/brands.js +554 -0
  103. package/dist/icons/regular.js +278 -0
  104. package/dist/icons/solid.js +1989 -0
  105. package/dist/index.js +130 -0
  106. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +448 -0
  107. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +400 -0
  108. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +136 -0
  109. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +130 -0
  110. package/dist/node_modules/@floating-ui/vue/dist/floating-ui.vue.js +131 -0
  111. package/dist/node_modules/@fortawesome/fontawesome-svg-core/index.js +3074 -0
  112. package/dist/node_modules/@fortawesome/free-brands-svg-icons/index.js +3156 -0
  113. package/dist/node_modules/@fortawesome/free-regular-svg-icons/index.js +1228 -0
  114. package/dist/node_modules/@fortawesome/free-solid-svg-icons/index.js +9602 -0
  115. package/dist/node_modules/@fortawesome/vue-fontawesome/index.es.js +487 -0
  116. package/dist/node_modules/gsap/CSSPlugin.js +424 -0
  117. package/dist/node_modules/gsap/gsap-core.js +1645 -0
  118. package/dist/node_modules/gsap/index.js +13 -0
  119. package/dist/tttb.css +1 -0
  120. package/dist/types/bundle.d.ts +10 -0
  121. package/dist/types/components/Button/index.d.ts +22 -0
  122. package/dist/types/components/Button/types.d.ts +12 -0
  123. package/dist/types/components/Checkbox/index.d.ts +29 -0
  124. package/dist/types/components/Checkbox/types.d.ts +8 -0
  125. package/dist/types/components/Dialog/DialogItem.d.ts +38 -0
  126. package/dist/types/components/Dialog/DialogPrompt.d.ts +16 -0
  127. package/dist/types/components/Dialog/index.d.ts +10 -0
  128. package/dist/types/components/Dialog/types.d.ts +35 -0
  129. package/dist/types/components/Icon/index.d.ts +3 -0
  130. package/dist/types/components/Icon/types.d.ts +2 -0
  131. package/dist/types/components/Loading/index.d.ts +6 -0
  132. package/dist/types/components/Loading/types.d.ts +8 -0
  133. package/dist/types/components/Message/index.d.ts +9 -0
  134. package/dist/types/components/Message/types.d.ts +12 -0
  135. package/dist/types/components/Modal/index.d.ts +21 -0
  136. package/dist/types/components/Modal/types.d.ts +11 -0
  137. package/dist/types/components/Nav/index.d.ts +7 -0
  138. package/dist/types/components/Nav/types.d.ts +14 -0
  139. package/dist/types/components/Pagination/index.d.ts +18 -0
  140. package/dist/types/components/Pagination/types.d.ts +16 -0
  141. package/dist/types/components/Popconfirm/index.d.ts +266 -0
  142. package/dist/types/components/Popconfirm/types.d.ts +26 -0
  143. package/dist/types/components/Popover/index.d.ts +150 -0
  144. package/dist/types/components/Progress/index.d.ts +21 -0
  145. package/dist/types/components/Progress/types.d.ts +9 -0
  146. package/dist/types/components/RouterNav/index.d.ts +2 -0
  147. package/dist/types/components/Switch/index.d.ts +13 -0
  148. package/dist/types/components/Switch/types.d.ts +6 -0
  149. package/dist/types/components/Table/index.d.ts +31 -0
  150. package/dist/types/components/Table/types.d.ts +3 -0
  151. package/dist/types/components/Timer/index.d.ts +6 -0
  152. package/dist/types/components/Tooltip/TooltipContent.d.ts +16 -0
  153. package/dist/types/components/Tooltip/TooltipItem.d.ts +45 -0
  154. package/dist/types/components/Tooltip/TooltipLayer.d.ts +2 -0
  155. package/dist/types/components/Tooltip/index.d.ts +42 -0
  156. package/dist/types/components/Tooltip/manager.d.ts +3384 -0
  157. package/dist/types/components/Tooltip/types.d.ts +52 -0
  158. package/dist/types/components/Tooltip/useTooltip.d.ts +8 -0
  159. package/dist/types/components/Warn/index.d.ts +20 -0
  160. package/dist/types/components/Warn/types.d.ts +6 -0
  161. package/dist/types/components/Watermark/index.d.ts +28 -0
  162. package/dist/types/components/Watermark/types.d.ts +14 -0
  163. package/dist/types/components/Watermark/useWatermarkBg.d.ts +6 -0
  164. package/dist/types/components/helpers.d.ts +14 -0
  165. package/dist/types/components/index.d.ts +19 -0
  166. package/dist/types/directives/helper.d.ts +4 -0
  167. package/dist/types/directives/index.d.ts +9 -0
  168. package/dist/types/directives/vBackTop.d.ts +3 -0
  169. package/dist/types/directives/vDelayIn.d.ts +3 -0
  170. package/dist/types/directives/vHoldPointer.d.ts +3 -0
  171. package/dist/types/directives/vLazy.d.ts +3 -0
  172. package/dist/types/directives/vLoading.d.ts +3 -0
  173. package/dist/types/directives/vRipple.d.ts +3 -0
  174. package/dist/types/directives/vSlideIn.d.ts +3 -0
  175. package/dist/types/directives/vTextJump.d.ts +3 -0
  176. package/dist/types/directives/vTooltip.d.ts +8 -0
  177. package/dist/types/hooks/index.d.ts +5 -0
  178. package/dist/types/hooks/useAudio.d.ts +38 -0
  179. package/dist/types/hooks/useElementScroll.d.ts +32 -0
  180. package/dist/types/hooks/useGSAP.d.ts +32 -0
  181. package/dist/types/hooks/useRefreshRate.d.ts +5 -0
  182. package/dist/types/hooks/useWindowBackTop.d.ts +14 -0
  183. package/dist/types/icons/brands.d.ts +551 -0
  184. package/dist/types/icons/regular.d.ts +275 -0
  185. package/dist/types/icons/solid.d.ts +1986 -0
  186. package/dist/types/router/index.d.ts +2 -0
  187. package/dist/types/utils/chance.d.ts +7 -0
  188. package/dist/types/utils/copyToClipboard.d.ts +6 -0
  189. package/dist/types/utils/debounce.d.ts +15 -0
  190. package/dist/types/utils/deepClone.d.ts +6 -0
  191. package/dist/types/utils/deepEqual.d.ts +5 -0
  192. package/dist/types/utils/dialog.d.ts +8 -0
  193. package/dist/types/utils/getId.d.ts +6 -0
  194. package/dist/types/utils/getRandomColor.d.ts +4 -0
  195. package/dist/types/utils/getRandomInt.d.ts +6 -0
  196. package/dist/types/utils/getRandomStr.d.ts +6 -0
  197. package/dist/types/utils/index.d.ts +23 -0
  198. package/dist/types/utils/injectStyles.d.ts +9 -0
  199. package/dist/types/utils/isElementOverflow.d.ts +20 -0
  200. package/dist/types/utils/isEmpty.d.ts +6 -0
  201. package/dist/types/utils/isMobile.d.ts +6 -0
  202. package/dist/types/utils/isObject.d.ts +4 -0
  203. package/dist/types/utils/isPromise.d.ts +6 -0
  204. package/dist/types/utils/localStorage.d.ts +24 -0
  205. package/dist/types/utils/msg.d.ts +8 -0
  206. package/dist/types/utils/omit.d.ts +6 -0
  207. package/dist/types/utils/pick.d.ts +6 -0
  208. package/dist/types/utils/sessionStorage.d.ts +24 -0
  209. package/dist/types/utils/shuffleArray.d.ts +6 -0
  210. package/dist/types/utils/throttle.d.ts +7 -0
  211. package/dist/utils/chance.js +7 -0
  212. package/dist/utils/copyToClipboard.js +21 -0
  213. package/dist/utils/debounce.js +14 -0
  214. package/dist/utils/deepClone.js +17 -0
  215. package/dist/utils/deepEqual.js +40 -0
  216. package/dist/utils/dialog.js +43 -0
  217. package/dist/utils/getId.js +10 -0
  218. package/dist/utils/getRandomColor.js +4 -0
  219. package/dist/utils/getRandomInt.js +4 -0
  220. package/dist/utils/getRandomStr.js +5 -0
  221. package/dist/utils/injectStyles.js +24 -0
  222. package/dist/utils/isElementOverflow.js +22 -0
  223. package/dist/utils/isEmpty.js +4 -0
  224. package/dist/utils/isMobile.js +7 -0
  225. package/dist/utils/isObject.js +4 -0
  226. package/dist/utils/isPromise.js +4 -0
  227. package/dist/utils/localStorage.js +47 -0
  228. package/dist/utils/msg.js +21 -0
  229. package/dist/utils/omit.js +9 -0
  230. package/dist/utils/pick.js +9 -0
  231. package/dist/utils/sessionStorage.js +47 -0
  232. package/dist/utils/shuffleArray.js +10 -0
  233. package/dist/utils/throttle.js +11 -0
  234. package/dist/utils.js +49 -0
  235. package/package.json +95 -0
@@ -0,0 +1,81 @@
1
+ import "../utils/dialog.js";
2
+ import { injectStyles as f } from "../utils/injectStyles.js";
3
+ import "../utils/localStorage.js";
4
+ import "../utils/msg.js";
5
+ import "../utils/sessionStorage.js";
6
+ const c = /* @__PURE__ */ new WeakMap(), m = `
7
+ .v-ripple-effect {
8
+ position: absolute;
9
+ border-radius: 50%;
10
+ pointer-events: none;
11
+ will-change: transform, opacity;
12
+ animation: v-ripple-animation 1s linear forwards;
13
+ }
14
+ @keyframes v-ripple-animation {
15
+ from {
16
+ transform: scale(0);
17
+ opacity: 0.35;
18
+ }
19
+ to {
20
+ transform: scale(4);
21
+ opacity: 0;
22
+ }
23
+ }
24
+ `;
25
+ f(m, "v-ripple-styles");
26
+ function u(t) {
27
+ return t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "" || t === "inherit";
28
+ }
29
+ function y(t) {
30
+ let e = t, i = "";
31
+ for (; e && e !== document.body; ) {
32
+ const l = getComputedStyle(e).backgroundColor;
33
+ if (!u(l)) {
34
+ i = l;
35
+ break;
36
+ }
37
+ e = e.parentElement;
38
+ }
39
+ if (!i) return "rgba(0, 0, 0, 0.15)";
40
+ const n = i.match(/\d+/g);
41
+ if (!n || n.length < 3) return "rgba(0, 0, 0, 0.15)";
42
+ const r = parseInt(n[0], 10), a = parseInt(n[1], 10), s = parseInt(n[2], 10);
43
+ return (r * 299 + a * 587 + s * 114) / 1e3 >= 128 ? "rgba(0, 0, 0, 0.15)" : "rgba(255, 255, 255, 0.3)";
44
+ }
45
+ const g = (t, e, i) => {
46
+ if (e.disabled) return;
47
+ const n = e.getBoundingClientRect(), r = t.clientX, a = t.clientY;
48
+ let s, p;
49
+ r !== void 0 ? (s = r - n.left, p = a - n.top) : (s = n.width / 2, p = n.height / 2);
50
+ const o = document.createElement("span");
51
+ o.className = "v-ripple-effect";
52
+ const l = Math.max(n.width, n.height), d = l / 2;
53
+ o.style.width = `${l}px`, o.style.height = `${l}px`, o.style.left = `${s - d}px`, o.style.top = `${p - d}px`, i.value && typeof i.value == "string" ? o.style.background = i.value : o.style.background = y(e), e.appendChild(o), o.addEventListener(
54
+ "animationend",
55
+ () => {
56
+ o && o.parentNode === e && o.remove();
57
+ },
58
+ { once: !0 }
59
+ );
60
+ }, C = {
61
+ name: "ripple",
62
+ mounted(t, e) {
63
+ const i = t.style.position, n = t.style.overflow, r = getComputedStyle(t);
64
+ r.position === "static" && (t.style.position = "relative"), r.overflow !== "hidden" && (t.style.overflow = "hidden");
65
+ const a = ((s) => g(s, t, e));
66
+ c.set(t, {
67
+ handler: a,
68
+ originalPosition: i,
69
+ originalOverflow: n
70
+ }), t.addEventListener("pointerdown", a);
71
+ },
72
+ unmounted(t) {
73
+ const e = c.get(t);
74
+ if (!e) return;
75
+ const { handler: i, originalPosition: n, originalOverflow: r } = e;
76
+ t.removeEventListener("pointerdown", i), t.style.position = n, t.style.overflow = r, c.delete(t);
77
+ }
78
+ };
79
+ export {
80
+ C as default
81
+ };
@@ -0,0 +1,39 @@
1
+ const o = /* @__PURE__ */ new WeakMap(), a = new IntersectionObserver((n) => {
2
+ for (const t of n) {
3
+ const e = t.target, i = o.get(e);
4
+ i && t.isIntersecting && (i.play(), a.unobserve(e));
5
+ }
6
+ }), s = (n) => n.getBoundingClientRect().top - 100 > window.innerHeight, r = {
7
+ name: "slide-in",
8
+ mounted(n, t) {
9
+ if (!s(n))
10
+ return;
11
+ const e = n.animate(
12
+ [
13
+ {
14
+ transform: "translateY(100px)",
15
+ opacity: 0.5
16
+ },
17
+ {
18
+ transform: "translateY(0px)",
19
+ opacity: 1
20
+ }
21
+ ],
22
+ {
23
+ duration: 600,
24
+ easing: "ease-out",
25
+ delay: t.value || 0,
26
+ fill: "both"
27
+ }
28
+ );
29
+ e.pause(), e.onfinish = e.cancel, o.set(n, e), a.observe(n);
30
+ },
31
+ unmounted(n) {
32
+ a.unobserve(n);
33
+ const t = o.get(n);
34
+ t && (t.cancel(), o.delete(n));
35
+ }
36
+ };
37
+ export {
38
+ r as default
39
+ };
@@ -0,0 +1,50 @@
1
+ import "../utils/dialog.js";
2
+ import { getRandomColor as a } from "../utils/getRandomColor.js";
3
+ import { getRandomInt as s } from "../utils/getRandomInt.js";
4
+ import { injectStyles as i } from "../utils/injectStyles.js";
5
+ import "../utils/localStorage.js";
6
+ import "../utils/msg.js";
7
+ import "../utils/sessionStorage.js";
8
+ const n = /* @__PURE__ */ new WeakMap(), c = `
9
+ .v-text-jump {
10
+ /* 使用三段式渐变确保循环无缝,且增加颜色过渡区域 */
11
+ background-image: linear-gradient(
12
+ 90deg,
13
+ var(--vtj-c-1) 0%,
14
+ var(--vtj-c-2) 25%,
15
+ var(--vtj-c-1) 50%,
16
+ var(--vtj-c-2) 75%,
17
+ var(--vtj-c-1) 100%
18
+ );
19
+ background-size: 200% 100%;
20
+ background-clip: text;
21
+ color: transparent;
22
+ }
23
+ `;
24
+ i(c, "v-text-jump-styles");
25
+ const g = {
26
+ name: "text-jump",
27
+ mounted(t, o) {
28
+ const e = o.value || [a(), a()];
29
+ t.classList.add("v-text-jump"), t.style.setProperty("--vtj-c-1", e[0]), t.style.setProperty("--vtj-c-2", e[1]);
30
+ const r = t.animate([{ backgroundPositionX: "200%" }, { backgroundPositionX: "0%" }], {
31
+ duration: 3e3,
32
+ // 缩短时间让节奏更明显
33
+ easing: "ease-in-out",
34
+ iterations: 1 / 0,
35
+ delay: s(0, 10) * -300
36
+ });
37
+ n.set(t, r);
38
+ },
39
+ updated(t, o) {
40
+ const e = o.value || [a(), a()];
41
+ t.style.setProperty("--vtj-c-1", e[0]), t.style.setProperty("--vtj-c-2", e[1]);
42
+ },
43
+ unmounted(t) {
44
+ const o = n.get(t);
45
+ o && (o.cancel(), n.delete(t));
46
+ }
47
+ };
48
+ export {
49
+ g as default
50
+ };
@@ -0,0 +1,55 @@
1
+ import { state as l, tooltipActions as p } from "../components/Tooltip/manager.js";
2
+ import { defaultProps as c } from "../components/Tooltip/types.js";
3
+ import { isObject as v } from "../utils/isObject.js";
4
+ import "../utils/dialog.js";
5
+ import { isElementOverflow as g } from "../utils/isElementOverflow.js";
6
+ import "../utils/localStorage.js";
7
+ import "../utils/msg.js";
8
+ import "../utils/sessionStorage.js";
9
+ const i = /* @__PURE__ */ new WeakMap(), a = (e) => typeof e == "string" || typeof e == "number" ? { ...c, content: String(e) } : v(e) ? { ...c, ...e } : { ...c }, m = (e, t) => {
10
+ const { trigger: o, closeDelay: n, overflow: d } = t, r = () => {
11
+ d && !g(e) || p.show(!0, null, {
12
+ triggerEl: e,
13
+ content: t.content,
14
+ props: t
15
+ });
16
+ }, s = () => {
17
+ p.hide(!0, null, n);
18
+ }, u = () => {
19
+ l.singleton.isVisible && l.singleton.triggerEl === e ? s() : r();
20
+ };
21
+ return o === "hover" ? (e.addEventListener("mouseenter", r), e.addEventListener("mouseleave", s)) : o === "click" && e.addEventListener("click", u), () => {
22
+ o === "hover" ? (e.removeEventListener("mouseenter", r), e.removeEventListener("mouseleave", s)) : o === "click" && e.removeEventListener("click", u);
23
+ };
24
+ }, f = (e) => {
25
+ const t = i.get(e);
26
+ t && (t(), i.delete(e)), l.singleton.triggerEl === e && p.hide(!0, null, 0);
27
+ }, C = {
28
+ name: "tooltip",
29
+ /**
30
+ * 元素挂载时绑定Tooltip
31
+ */
32
+ mounted(e, t) {
33
+ const o = a(t.value), n = m(e, o);
34
+ i.set(e, n);
35
+ },
36
+ /**
37
+ * 指令值更新时重新绑定(仅值真变化时)
38
+ */
39
+ updated(e, t) {
40
+ if (t.value !== t.oldValue) {
41
+ f(e);
42
+ const o = a(t.value), n = m(e, o);
43
+ i.set(e, n);
44
+ }
45
+ },
46
+ /**
47
+ * 元素卸载前清理所有关联资源
48
+ */
49
+ beforeUnmount(e) {
50
+ f(e);
51
+ }
52
+ };
53
+ export {
54
+ C as default
55
+ };
@@ -0,0 +1,20 @@
1
+ import { default as a } from "./directives/vBackTop.js";
2
+ import { default as r } from "./directives/vDelayIn.js";
3
+ import { default as l } from "./directives/vHoldPointer.js";
4
+ import { default as d } from "./directives/vLazy.js";
5
+ import { default as u } from "./directives/vLoading.js";
6
+ import { default as s } from "./directives/vRipple.js";
7
+ import { default as i } from "./directives/vSlideIn.js";
8
+ import { default as T } from "./directives/vTextJump.js";
9
+ import { default as I } from "./directives/vTooltip.js";
10
+ export {
11
+ a as vBackTop,
12
+ r as vDelayIn,
13
+ l as vHoldPointer,
14
+ d as vLazy,
15
+ u as vLoading,
16
+ s as vRipple,
17
+ i as vSlideIn,
18
+ T as vTextJump,
19
+ I as vTooltip
20
+ };
@@ -0,0 +1,112 @@
1
+ import { reactive as w, onMounted as R, onUnmounted as E, readonly as T, watch as M } from "vue";
2
+ const x = (l, s = {}) => {
3
+ const o = {
4
+ autoplay: !1,
5
+ loop: !1,
6
+ volume: 0.5,
7
+ muted: !1,
8
+ playbackRate: 1,
9
+ preload: "metadata",
10
+ ...s
11
+ };
12
+ let e = null;
13
+ const a = w({
14
+ playing: !1,
15
+ paused: !0,
16
+ ended: !1,
17
+ duration: 0,
18
+ currentTime: 0,
19
+ buffered: 0,
20
+ volume: o.volume,
21
+ muted: o.muted,
22
+ playbackRate: o.playbackRate,
23
+ loading: !0,
24
+ canplay: !1,
25
+ error: null
26
+ }), r = {}, f = () => {
27
+ if (typeof window > "u") return;
28
+ e = new Audio();
29
+ const t = typeof l == "string" ? l : l.value;
30
+ e.src = t, e.loop = o.loop, e.volume = o.volume, e.muted = o.muted, e.playbackRate = o.playbackRate, e.preload = o.preload, r.loadedmetadata = () => {
31
+ a.duration = e.duration, a.loading = !1;
32
+ }, r.timeupdate = () => {
33
+ a.currentTime = e.currentTime, e.buffered.length > 0 && (a.buffered = e.buffered.end(e.buffered.length - 1));
34
+ }, r.progress = () => {
35
+ e.buffered.length > 0 && (a.buffered = e.buffered.end(e.buffered.length - 1));
36
+ }, r.play = () => {
37
+ a.playing = !0, a.paused = !1, a.ended = !1;
38
+ }, r.pause = () => {
39
+ a.playing = !1, a.paused = !0;
40
+ }, r.ended = () => {
41
+ a.playing = !1, a.paused = !0, a.ended = !0, o.loop || (a.currentTime = 0);
42
+ }, r.canplay = () => {
43
+ a.canplay = !0, a.loading = !1;
44
+ }, r.waiting = () => {
45
+ a.loading = !0;
46
+ }, r.error = (n) => {
47
+ a.error = e.error ? new Error(`Audio error code: ${e.error.code}`) : new Error("Unknown audio error"), a.loading = !1, a.playing = !1, console.error("Audio playback error:", n);
48
+ }, r.volumechange = () => {
49
+ a.volume = e.volume, a.muted = e.muted;
50
+ }, r.ratechange = () => {
51
+ a.playbackRate = e.playbackRate;
52
+ }, Object.entries(r).forEach(([n, k]) => {
53
+ e.addEventListener(n, k);
54
+ }), typeof l != "string" && M(l, (n) => {
55
+ e && n !== e.src && (d(), e.src = n, a.loading = !0, a.canplay = !1, a.currentTime = 0, a.duration = 0, a.ended = !1, e.load(), o.autoplay && u());
56
+ }), o.autoplay && u().catch(() => {
57
+ });
58
+ }, u = async () => {
59
+ if (e)
60
+ try {
61
+ await e.play();
62
+ } catch (t) {
63
+ throw a.error = t instanceof Error ? t : new Error("Playback failed"), t;
64
+ }
65
+ }, d = () => {
66
+ e?.pause();
67
+ }, c = () => {
68
+ a.playing ? d() : u();
69
+ }, p = () => {
70
+ e && (d(), e.currentTime = 0, a.ended = !1);
71
+ }, i = (t) => {
72
+ if (!e || !isFinite(t)) return;
73
+ const n = Math.max(0, Math.min(t, a.duration || t));
74
+ e.currentTime = n;
75
+ }, m = (t) => {
76
+ i(a.currentTime + t);
77
+ }, y = (t) => {
78
+ if (!e) return;
79
+ const n = Math.max(0, Math.min(1, t));
80
+ e.volume = n;
81
+ }, g = (t) => {
82
+ e && (e.muted = t);
83
+ }, b = (t) => {
84
+ e && (e.playbackRate = Math.max(0.25, Math.min(4, t)));
85
+ }, h = (t) => {
86
+ e && (e.loop = t);
87
+ }, v = () => {
88
+ e && (e.pause(), Object.entries(r).forEach(([t, n]) => {
89
+ e.removeEventListener(t, n);
90
+ }), e.src = "", e.load(), e = null);
91
+ };
92
+ return R(f), E(v), {
93
+ // 返回只读状态,防止外部直接修改
94
+ state: T(a),
95
+ // 控制方法
96
+ play: u,
97
+ pause: d,
98
+ toggle: c,
99
+ stop: p,
100
+ seek: i,
101
+ seekRelative: m,
102
+ setVolume: y,
103
+ setMuted: g,
104
+ setPlaybackRate: b,
105
+ setLoop: h,
106
+ // 原始 audio 元素(高级用法)
107
+ getAudioElement: () => e
108
+ };
109
+ };
110
+ export {
111
+ x as useAudio
112
+ };
@@ -0,0 +1,30 @@
1
+ import { onMounted as d, onBeforeUnmount as p, onActivated as g, onDeactivated as m, toValue as a, nextTick as v } from "vue";
2
+ import { sessionStorage as l } from "../utils/sessionStorage.js";
3
+ function k(n, u = {}) {
4
+ const { id: f = "default", autoRestore: r = !0 } = u, i = () => `scroll_pos:${f}`, t = () => {
5
+ const o = a(n);
6
+ if (!o) return;
7
+ const s = i();
8
+ l.set(s, o.scrollTop);
9
+ }, e = async () => {
10
+ const o = a(n);
11
+ if (!o) return;
12
+ const s = i(), c = l.get(s);
13
+ c && (await v(), o.scrollTop = c);
14
+ };
15
+ return d(() => {
16
+ r && e();
17
+ }), p(() => {
18
+ t();
19
+ }), g(() => {
20
+ r && e();
21
+ }), m(() => {
22
+ t();
23
+ }), {
24
+ save: t,
25
+ restore: e
26
+ };
27
+ }
28
+ export {
29
+ k as useElementScroll
30
+ };
@@ -0,0 +1,40 @@
1
+ import { onMounted as a, watch as u, onScopeDispose as v, toValue as x } from "vue";
2
+ import r from "../node_modules/gsap/index.js";
3
+ function C(n, f) {
4
+ const i = typeof n == "function", p = i ? n : n?.callback, t = (i ? f : n) || {}, l = t.revertOnUpdate !== !1;
5
+ let e;
6
+ const d = () => {
7
+ e && e.revert();
8
+ const o = x(t.scope) || void 0;
9
+ e = r.context((c) => {
10
+ p && p(r, c);
11
+ }, o);
12
+ };
13
+ return a(() => {
14
+ d();
15
+ }), t.dependencies && t.dependencies.length > 0 && u(
16
+ t.dependencies,
17
+ () => {
18
+ l && d();
19
+ },
20
+ {
21
+ deep: !0,
22
+ flush: "post"
23
+ // 确保依赖更新导致的 DOM 渲染完成后再执行
24
+ }
25
+ ), v(() => {
26
+ e?.revert();
27
+ }), {
28
+ g: r,
29
+ safe: (o) => (...c) => {
30
+ let s;
31
+ return e ? e.add(() => {
32
+ s = o(...c);
33
+ }) : s = o(...c), s;
34
+ },
35
+ getContext: () => e
36
+ };
37
+ }
38
+ export {
39
+ C as useGSAP
40
+ };
@@ -0,0 +1,26 @@
1
+ import { ref as c, onMounted as f, onUnmounted as d } from "vue";
2
+ const h = (i = 500) => {
3
+ const o = c(0);
4
+ let e = null, t = 0, n = 0;
5
+ const r = (u) => {
6
+ t++;
7
+ const l = u - n;
8
+ if (l >= i) {
9
+ const m = Math.round(t * 1e3 / l);
10
+ o.value = Math.max(1, Math.min(360, m)), t = 0, n = u;
11
+ }
12
+ e = requestAnimationFrame(r);
13
+ }, a = () => {
14
+ e || (t = 0, n = performance.now(), e = requestAnimationFrame(r));
15
+ }, s = () => {
16
+ e !== null && (cancelAnimationFrame(e), e = null);
17
+ };
18
+ return f(a), d(s), {
19
+ refreshRate: o,
20
+ start: a,
21
+ stop: s
22
+ };
23
+ };
24
+ export {
25
+ h as useRefreshRate
26
+ };
@@ -0,0 +1,86 @@
1
+ import { onMounted as d, onBeforeUnmount as m, render as s, h as f } from "vue";
2
+ import { debounce as y } from "../utils/debounce.js";
3
+ import "../utils/dialog.js";
4
+ import { injectStyles as w } from "../utils/injectStyles.js";
5
+ import "../utils/localStorage.js";
6
+ import "../utils/msg.js";
7
+ import "../utils/sessionStorage.js";
8
+ import u from "../components/Icon/index.js";
9
+ import { faAngleUp as v } from "../node_modules/@fortawesome/free-solid-svg-icons/index.js";
10
+ import i from "../node_modules/gsap/index.js";
11
+ const b = {
12
+ type: "primary",
13
+ right: 20,
14
+ bottom: 20,
15
+ size: 36,
16
+ scrollThreshold: 200,
17
+ animationOffset: 30,
18
+ zIndex: 999
19
+ }, h = `
20
+ .v-window-back-top {
21
+ position: fixed;
22
+ width: var(--size, 36px);
23
+ height: var(--size, 36px);
24
+ color: var(--color-white, #fff);
25
+ font-size: calc(var(--size, 36px) * 0.5);
26
+ border-radius: 50%;
27
+ display: none;
28
+ align-items: center;
29
+ justify-content: center;
30
+ cursor: pointer;
31
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
32
+ will-change: transform, opacity;
33
+ }
34
+ .v-window-back-top:hover {
35
+ filter: brightness(1.1);
36
+ }
37
+ `;
38
+ w(h, "v-window-back-top-styles");
39
+ const L = (l = {}) => {
40
+ const t = { ...b, ...l };
41
+ let e = null, n = !1;
42
+ const c = () => {
43
+ const o = document.createElement("div");
44
+ return o.className = `v-window-back-top bg-${t.type}`, o.style.zIndex = `${t.zIndex}`, o.style.right = `${t.right}px`, o.style.bottom = `${t.bottom}px`, o.style.setProperty("--size", `${t.size}px`), o.title = "Back to top", s(f(u, { icon: v }), o), o.addEventListener("click", (p) => {
45
+ p.stopPropagation(), window.scrollTo({ top: 0, behavior: "smooth" });
46
+ }), document.body.appendChild(o), o;
47
+ }, a = (o) => {
48
+ !e || n === o || (n = o, i.killTweensOf(e), o ? i.to(e, {
49
+ y: 0,
50
+ opacity: 1,
51
+ scale: 1,
52
+ duration: 0.4,
53
+ ease: "back.out(1.7)",
54
+ overwrite: !0,
55
+ onStart: () => {
56
+ e && (e.style.display = "flex");
57
+ }
58
+ }) : i.to(e, {
59
+ y: t.animationOffset,
60
+ opacity: 0,
61
+ scale: 0.6,
62
+ duration: 0.3,
63
+ ease: "power2.in",
64
+ overwrite: !0,
65
+ onComplete: () => {
66
+ e && (e.style.display = "none");
67
+ }
68
+ }));
69
+ }, r = y(() => {
70
+ const o = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
71
+ a(o > t.scrollThreshold);
72
+ }, 100);
73
+ d(() => {
74
+ e = c(), i.set(e, {
75
+ y: t.animationOffset,
76
+ opacity: 0,
77
+ scale: 0.8
78
+ }), window.addEventListener("scroll", r, { passive: !0 }), r();
79
+ }), m(() => {
80
+ e && (window.removeEventListener("scroll", r), i.killTweensOf(e), s(null, e), e.remove(), e = null);
81
+ });
82
+ };
83
+ export {
84
+ b as DEFAULT_OPTIONS,
85
+ L as useWindowBackTop
86
+ };
package/dist/hooks.js ADDED
@@ -0,0 +1,13 @@
1
+ import { useAudio as r } from "./hooks/useAudio.js";
2
+ import { useElementScroll as f } from "./hooks/useElementScroll.js";
3
+ import { useGSAP as p } from "./hooks/useGSAP.js";
4
+ import { useRefreshRate as u } from "./hooks/useRefreshRate.js";
5
+ import { DEFAULT_OPTIONS as l, useWindowBackTop as A } from "./hooks/useWindowBackTop.js";
6
+ export {
7
+ l as DEFAULT_OPTIONS,
8
+ r as useAudio,
9
+ f as useElementScroll,
10
+ p as useGSAP,
11
+ u as useRefreshRate,
12
+ A as useWindowBackTop
13
+ };