tttb 0.1.19 → 0.1.20

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.

Potentially problematic release.


This version of tttb might be problematic. Click here for more details.

@@ -1,128 +1,113 @@
1
- import { render as g, h as b } from "vue";
2
- import { debounce as w } from "../utils/debounce.js";
1
+ import { render as v, h } from "vue";
2
+ import { debounce as f } from "../utils/debounce.js";
3
3
  import "../utils/dialog.js";
4
- import { injectStyles as k } from "../utils/injectStyles.js";
4
+ import { injectStyles as u } from "../utils/injectStyles.js";
5
5
  import "../utils/localStorage.js";
6
6
  import "../utils/msg.js";
7
7
  import "../utils/sessionStorage.js";
8
- import { DEFAULT_OPTIONS as z } from "../hooks/useWindowBackTop.js";
9
- import x from "../components/Icon/index.js";
10
- import { faAngleUp as O } from "../node_modules/@fortawesome/free-solid-svg-icons/index.js";
11
- import p from "../node_modules/gsap/index.js";
12
- const T = `
8
+ import { DEFAULT_OPTIONS as m } from "../hooks/useWindowBackTop.js";
9
+ import y from "../components/Icon/index.js";
10
+ import { faAngleUp as w } from "../node_modules/@fortawesome/free-solid-svg-icons/index.js";
11
+ import l from "../node_modules/gsap/index.js";
12
+ const g = `
13
13
  .v-back-top-wrapper {
14
- position: absolute;
15
- top: 0;
14
+ position: sticky;
16
15
  left: 0;
17
- width: 0;
16
+ bottom: 0;
17
+ width: 100%;
18
18
  height: 0;
19
- will-change: transform;
19
+ pointer-events: none;
20
20
  }
21
+
21
22
  .v-back-top-inner {
22
- width: var(--size, 36px);
23
- height: var(--size, 36px);
23
+ --size: var(--vbt-size, 36px);
24
+ position: absolute;
25
+ width: var(--size);
26
+ height: var(--size);
24
27
  color: var(--color-white, #fff);
25
- font-size: calc(var(--size, 36px) * 0.5);
28
+ font-size: calc(var(--size) * 0.5);
26
29
  border-radius: 50%;
27
30
  display: none;
28
31
  align-items: center;
29
32
  justify-content: center;
30
33
  cursor: pointer;
31
- box-shadow: 0 2px 8px rgba(0,0,0,0.2);
34
+ pointer-events: auto;
35
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
36
+ will-change: transform, opacity;
32
37
  }
38
+
33
39
  .v-back-top-inner:hover {
34
40
  filter: brightness(1.1);
41
+ transform: translateY(-2px);
35
42
  }
36
43
  `;
37
- k(T, "v-back-top-styles");
38
- const S = (e, t) => {
39
- const o = document.createElement("div");
40
- o.className = "v-back-top-wrapper", o.style.zIndex = `${t.zIndex}`;
41
- const i = document.createElement("div");
42
- return i.className = `v-back-top-inner bg-${t.type}`, i.style.setProperty("--size", `${t.size}px`), i.title = "回到顶部", g(b(x, { icon: O }), i), i.addEventListener("click", (r) => {
43
- r.stopPropagation(), e.scrollTo({ top: 0, behavior: "smooth" });
44
- }), o.appendChild(i), e.appendChild(o), { wrapper: o, inner: i };
45
- }, l = (e) => {
46
- const { el: t, wrapper: o, clientHeight: i, clientWidth: r, options: s } = e, c = t.scrollTop + i - s.size - s.bottom, a = t.scrollLeft + r - s.size - s.right;
47
- o.style.transform = `translate3d(${a}px, ${c}px, 0)`;
48
- }, y = (e, t) => {
49
- if (e.visible === t) return;
50
- e.visible = t;
51
- const { inner: o, options: i } = e;
52
- p.killTweensOf(o), t ? p.to(o, {
53
- y: 0,
54
- opacity: 1,
55
- scale: 1,
56
- duration: 0.4,
57
- ease: "back.out(1.7)",
58
- overwrite: !0,
59
- onStart: () => {
60
- o.style.display = "flex";
61
- }
62
- }) : p.to(o, {
63
- y: i.animationOffset,
64
- opacity: 0,
65
- scale: 0.8,
66
- duration: 0.3,
67
- ease: "power2.in",
68
- overwrite: !0,
69
- onComplete: () => {
70
- o.style.display = "none";
71
- }
72
- });
73
- }, d = /* @__PURE__ */ new WeakMap(), R = {
44
+ u(g, "v-back-top-styles");
45
+ const b = (e) => {
46
+ const { wrapper: o, inner: t, options: r } = e;
47
+ o.style.zIndex = `${r.zIndex}`, t.style.setProperty("--vbt-size", `${r.size}px`), t.style.right = `${r.right}px`, t.style.bottom = `${r.bottom}px`, t.className = `v-back-top-inner bg-${r.type}`;
48
+ }, c = /* @__PURE__ */ new WeakMap(), P = {
74
49
  name: "back-top",
75
- mounted(e, t) {
76
- const o = t.value || {}, i = { ...z, ...o }, r = getComputedStyle(e);
77
- let s = "";
78
- r.position === "static" && (s = e.style.position, e.style.position = "relative");
79
- const { wrapper: c, inner: a } = S(e, i);
80
- p.set(a, {
81
- y: i.animationOffset,
82
- opacity: 0,
83
- scale: 0.8
84
- });
85
- const n = {
86
- wrapper: c,
87
- inner: a,
88
- el: e,
89
- options: i,
50
+ mounted(e, o) {
51
+ const t = { ...m, ...o.value };
52
+ let r = "";
53
+ getComputedStyle(e).position === "static" && (r = e.style.position, e.style.position = "relative");
54
+ const a = document.createElement("div");
55
+ a.className = "v-back-top-wrapper";
56
+ const i = document.createElement("div");
57
+ i.title = "Back to top", v(h(y, { icon: w }), i), i.addEventListener("click", (n) => {
58
+ n.stopPropagation(), e.scrollTo({ top: 0, behavior: "smooth" });
59
+ }), a.appendChild(i), e.appendChild(a);
60
+ const s = {
61
+ wrapper: a,
62
+ inner: i,
63
+ options: t,
90
64
  visible: !1,
91
- clientHeight: e.clientHeight,
92
- clientWidth: e.clientWidth,
93
- ticking: !1,
94
- originalPosition: s,
95
- handlers: {}
65
+ handler: () => {
66
+ },
67
+ observer: null,
68
+ originalPosition: r
96
69
  };
97
- l(n);
98
- const m = w(() => {
99
- const h = e.scrollTop > i.scrollThreshold;
100
- y(n, h);
101
- }, 100), f = () => {
102
- n.ticking || (requestAnimationFrame(() => {
103
- l(n), m(), n.ticking = !1;
104
- }), n.ticking = !0);
105
- }, u = new ResizeObserver((h) => {
106
- for (const v of h)
107
- n.clientHeight = v.contentRect.height, n.clientWidth = v.contentRect.width, l(n), m();
108
- });
109
- u.observe(e), e.addEventListener("scroll", f, { passive: !0 }), n.handlers.scroll = f, n.handlers.resize = u, d.set(e, n), l(n), m();
70
+ b(s);
71
+ const p = f(() => {
72
+ const n = e.scrollTop > s.options.scrollThreshold;
73
+ s.visible !== n && (s.visible = n, l.killTweensOf(i), n ? l.to(i, {
74
+ y: 0,
75
+ opacity: 1,
76
+ scale: 1,
77
+ duration: 0.4,
78
+ ease: "back.out(1.7)",
79
+ overwrite: !0,
80
+ onStart: () => {
81
+ i.style.display = "flex";
82
+ }
83
+ }) : l.to(i, {
84
+ y: t.animationOffset,
85
+ opacity: 0,
86
+ scale: 0.8,
87
+ duration: 0.3,
88
+ ease: "power2.in",
89
+ overwrite: !0,
90
+ onComplete: () => {
91
+ i.style.display = "none";
92
+ }
93
+ }));
94
+ }, 100);
95
+ e.addEventListener("scroll", p, { passive: !0 });
96
+ const d = new ResizeObserver(p);
97
+ d.observe(e), s.handler = p, s.observer = d, c.set(e, s), p();
110
98
  },
111
- updated(e, t) {
112
- const o = d.get(e);
113
- if (!o || t.value === t.oldValue) return;
114
- const i = t.value || {};
115
- Object.assign(o.options, i);
116
- const { inner: r, wrapper: s, options: c } = o;
117
- r.style.setProperty("--size", `${c.size}px`), s.style.zIndex = `${c.zIndex}`, r.className = `v-back-top-inner bg-${c.type}`, l(o);
118
- const a = e.scrollTop > c.scrollThreshold;
119
- y(o, a);
99
+ updated(e, o) {
100
+ const t = c.get(e);
101
+ if (!t) return;
102
+ t.options = { ...m, ...o.value }, b(t);
103
+ const r = e.scrollTop > t.options.scrollThreshold;
104
+ t.visible !== r && t.handler();
120
105
  },
121
106
  unmounted(e) {
122
- const t = d.get(e);
123
- t && (e.removeEventListener("scroll", t.handlers.scroll), t.handlers.resize.disconnect(), e.style.position = t.originalPosition, g(null, t.inner), t.wrapper.remove(), p.killTweensOf(t.inner), d.delete(e));
107
+ const o = c.get(e);
108
+ o && (e.removeEventListener("scroll", o.handler), o.observer.disconnect(), l.killTweensOf(o.inner), v(null, o.inner), o.wrapper.remove(), c.delete(e));
124
109
  }
125
110
  };
126
111
  export {
127
- R as default
112
+ P as default
128
113
  };
@@ -29,3 +29,22 @@ type __VLS_WithTemplateSlots<T, S> = T & {
29
29
  $slots: S;
30
30
  };
31
31
  };
32
+ ue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
33
+ $slots: {
34
+ default?(_: {
35
+ row: {
36
+ index: number;
37
+ key: string;
38
+ data: any;
39
+ };
40
+ }): any;
41
+ empty?(_: {
42
+ row: {
43
+ index: number;
44
+ key: string;
45
+ data: any;
46
+ };
47
+ }): any;
48
+ };
49
+ })>;
50
+ export default _default;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": "^20.19.0 || >=22.12.0"
5
5
  },
6
- "version": "0.1.19",
6
+ "version": "0.1.20",
7
7
  "description": "this is a Vue3 components library",
8
8
  "author": "tttb <3190360451@qq.com>",
9
9
  "type": "module",