geekin-devtoys 0.0.3 → 0.0.5
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/lib/GPercent/index.js +1 -0
- package/lib/GPercent/index.mjs +105 -0
- package/lib/GPercent/style.css +1 -0
- package/lib/index/index.js +1 -1
- package/lib/index/index.mjs +7 -7
- package/package.json +9 -9
- package/lib/Demo/index.js +0 -1
- package/lib/Demo/index.mjs +0 -24
- package/lib/Demo/style.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),S="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='11px'%20height='12px'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20transform='matrix(1%200%200%201%20-1755%20-466%20)'%3e%3cpath%20d='M%201755.77886671114%20477.5%20L%201760.5%20467.199345551568%20L%201765.22113328886%20477.5%20L%201755.77886671114%20477.5%20Z%20'%20fill-rule='nonzero'%20fill='%23fa3239'%20stroke='none'%20/%3e%3cpath%20d='M%201755%20478%20L%201760.5%20466%20L%201766%20478%20L%201755%20478%20Z%20M%201760.5%20468.398691103136%20L%201756.55773342227%20477%20L%201764.44226657773%20477%20L%201760.5%20468.398691103136%20Z%20'%20fill-rule='nonzero'%20fill='%23797979'%20stroke='none'%20/%3e%3c/g%3e%3c/svg%3e",E="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='11px'%20height='12px'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20transform='matrix(1%200%200%201%20-1755%20-304%20)'%3e%3cpath%20d='M%201755.77886671114%20315.5%20L%201760.5%20305.199345551568%20L%201765.22113328886%20315.5%20L%201755.77886671114%20315.5%20Z%20'%20fill-rule='nonzero'%20fill='%232ce534'%20stroke='none'%20/%3e%3cpath%20d='M%201755%20316%20L%201760.5%20304%20L%201766%20316%20L%201755%20316%20Z%20M%201760.5%20306.398691103136%20L%201756.55773342227%20315%20L%201764.44226657773%20315%20L%201760.5%20306.398691103136%20Z%20'%20fill-rule='nonzero'%20fill='%23797979'%20stroke='none'%20/%3e%3c/g%3e%3c/svg%3e",N={class:"g-percent-symbol-updown"},P={src:S,alt:"down",style:{transform:"rotate(180deg)"},class:"g-percent-svg"},V={src:E,alt:"up",class:"g-percent-svg"},z=t.defineComponent({name:"GPercent",__name:"index",props:{to:{},from:{default:0},direction:{default:""},delay:{default:0},duration:{default:2},className:{default:""},startWhen:{type:Boolean,default:!0},decimalPlaces:{default:0},onStart:{},onEnd:{}},setup(o){const e=o,r=t.useTemplateRef("elementRef"),n=t.ref(e.direction==="down"?e.to:e.from),a=t.ref(!1),s=t.ref(null),m=t.ref(!1);let l=null;const g=t.computed(()=>20+40*(1/e.duration)),w=t.computed(()=>200*(1/e.duration));let i=0;const p=c=>{const u=e.direction==="down"?e.from:e.to,_=n.value,f=u-_,L=f*w.value,b=i*g.value,M=L-b;i+=M*.016,n.value+=i*.016,n.value=Math.max(0,Math.min(100,n.value));const y=Math.pow(10,-e.decimalPlaces)*.1,k=Math.pow(10,-e.decimalPlaces)*.1;Math.abs(f)>y||Math.abs(i)>k?s.value=requestAnimationFrame(p):(n.value=u,s.value=null,e.onEnd&&e.onEnd())},v=()=>{m.value||!a.value||!e.startWhen||(m.value=!0,e.onStart&&e.onStart(),setTimeout(()=>{i=0,s.value=requestAnimationFrame(p)},e.delay*1e3))},h=()=>{r.value&&(l=new IntersectionObserver(([c])=>{c.isIntersecting&&!a.value&&(a.value=!0,v())},{threshold:0,rootMargin:"0px"}),l.observe(r.value))},x=()=>{s.value&&(cancelAnimationFrame(s.value),s.value=null),l&&(l.disconnect(),l=null)};return t.watch([()=>e.from,()=>e.to,()=>e.direction],()=>{n.value=e.direction==="down"?e.to:e.from,m.value=!1},{immediate:!0}),t.watch(()=>e.startWhen,()=>{e.startWhen&&a.value&&!m.value&&v()}),t.onMounted(async()=>{await t.nextTick(),h()}),t.onUnmounted(()=>{x()}),(c,u)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"elementRef",ref:r,class:t.normalizeClass([c.className,"g-percent-container"])},[t.createElementVNode("div",N,[t.withDirectives(t.createElementVNode("img",P,null,512),[[t.vShow,e.direction==="down"]]),t.withDirectives(t.createElementVNode("img",V,null,512),[[t.vShow,e.direction==="up"]])]),t.createElementVNode("span",{class:t.normalizeClass(["g-percent-number",{"g-percent-number-down":e.direction==="down","g-percent-number-up":e.direction==="up"}])},t.toDisplayString(n.value.toFixed(e.decimalPlaces)),3),t.createElementVNode("div",{class:t.normalizeClass(["g-percent-symbol",{"g-percent-number-down":e.direction==="down","g-percent-number-up":e.direction==="up"}])},[t.renderSlot(c.$slots,"symbol",{},()=>[u[0]||(u[0]=t.createTextVNode("%"))],!0)],2)],2))}}),F=(o,e)=>{const r=o.__vccOpts||o;for(const[n,a]of e)r[n]=a;return r},d=F(z,[["__scopeId","data-v-33634690"]]);d.install=o=>{o.component(d.name,d)};exports.GPercent=d;exports.default=d;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { defineComponent as A, useTemplateRef as E, ref as m, computed as h, watch as x, onMounted as T, nextTick as N, onUnmounted as O, createElementBlock as R, openBlock as V, normalizeClass as p, createElementVNode as u, withDirectives as _, vShow as L, toDisplayString as W, renderSlot as B, createTextVNode as q } from "vue";
|
|
2
|
+
const C = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='11px'%20height='12px'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20transform='matrix(1%200%200%201%20-1755%20-466%20)'%3e%3cpath%20d='M%201755.77886671114%20477.5%20L%201760.5%20467.199345551568%20L%201765.22113328886%20477.5%20L%201755.77886671114%20477.5%20Z%20'%20fill-rule='nonzero'%20fill='%23fa3239'%20stroke='none'%20/%3e%3cpath%20d='M%201755%20478%20L%201760.5%20466%20L%201766%20478%20L%201755%20478%20Z%20M%201760.5%20468.398691103136%20L%201756.55773342227%20477%20L%201764.44226657773%20477%20L%201760.5%20468.398691103136%20Z%20'%20fill-rule='nonzero'%20fill='%23797979'%20stroke='none'%20/%3e%3c/g%3e%3c/svg%3e", D = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='11px'%20height='12px'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20transform='matrix(1%200%200%201%20-1755%20-304%20)'%3e%3cpath%20d='M%201755.77886671114%20315.5%20L%201760.5%20305.199345551568%20L%201765.22113328886%20315.5%20L%201755.77886671114%20315.5%20Z%20'%20fill-rule='nonzero'%20fill='%232ce534'%20stroke='none'%20/%3e%3cpath%20d='M%201755%20316%20L%201760.5%20304%20L%201766%20316%20L%201755%20316%20Z%20M%201760.5%20306.398691103136%20L%201756.55773342227%20315%20L%201764.44226657773%20315%20L%201760.5%20306.398691103136%20Z%20'%20fill-rule='nonzero'%20fill='%23797979'%20stroke='none'%20/%3e%3c/g%3e%3c/svg%3e", G = { class: "g-percent-symbol-updown" }, U = {
|
|
3
|
+
src: C,
|
|
4
|
+
alt: "down",
|
|
5
|
+
style: { transform: "rotate(180deg)" },
|
|
6
|
+
class: "g-percent-svg"
|
|
7
|
+
}, $ = {
|
|
8
|
+
src: D,
|
|
9
|
+
alt: "up",
|
|
10
|
+
class: "g-percent-svg"
|
|
11
|
+
}, j = /* @__PURE__ */ A({
|
|
12
|
+
name: "GPercent",
|
|
13
|
+
__name: "index",
|
|
14
|
+
props: {
|
|
15
|
+
to: {},
|
|
16
|
+
from: { default: 0 },
|
|
17
|
+
direction: { default: "" },
|
|
18
|
+
delay: { default: 0 },
|
|
19
|
+
duration: { default: 2 },
|
|
20
|
+
className: { default: "" },
|
|
21
|
+
startWhen: { type: Boolean, default: !0 },
|
|
22
|
+
decimalPlaces: { default: 0 },
|
|
23
|
+
onStart: {},
|
|
24
|
+
onEnd: {}
|
|
25
|
+
},
|
|
26
|
+
setup(n) {
|
|
27
|
+
const e = n, o = E("elementRef"), t = m(e.direction === "down" ? e.to : e.from), r = m(!1), a = m(null), d = m(!1);
|
|
28
|
+
let s = null;
|
|
29
|
+
const b = h(() => 20 + 40 * (1 / e.duration)), M = h(() => 200 * (1 / e.duration));
|
|
30
|
+
let l = 0;
|
|
31
|
+
const v = (i) => {
|
|
32
|
+
const c = e.direction === "down" ? e.from : e.to, S = t.value, w = c - S, F = w * M.value, I = l * b.value, P = F - I;
|
|
33
|
+
l += P * 0.016, t.value += l * 0.016, t.value = Math.max(0, Math.min(100, t.value));
|
|
34
|
+
const Z = Math.pow(10, -e.decimalPlaces) * 0.1, z = Math.pow(10, -e.decimalPlaces) * 0.1;
|
|
35
|
+
Math.abs(w) > Z || Math.abs(l) > z ? a.value = requestAnimationFrame(v) : (t.value = c, a.value = null, e.onEnd && e.onEnd());
|
|
36
|
+
}, g = () => {
|
|
37
|
+
d.value || !r.value || !e.startWhen || (d.value = !0, e.onStart && e.onStart(), setTimeout(() => {
|
|
38
|
+
l = 0, a.value = requestAnimationFrame(v);
|
|
39
|
+
}, e.delay * 1e3));
|
|
40
|
+
}, k = () => {
|
|
41
|
+
o.value && (s = new IntersectionObserver(
|
|
42
|
+
([i]) => {
|
|
43
|
+
i.isIntersecting && !r.value && (r.value = !0, g());
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
threshold: 0,
|
|
47
|
+
rootMargin: "0px"
|
|
48
|
+
}
|
|
49
|
+
), s.observe(o.value));
|
|
50
|
+
}, y = () => {
|
|
51
|
+
a.value && (cancelAnimationFrame(a.value), a.value = null), s && (s.disconnect(), s = null);
|
|
52
|
+
};
|
|
53
|
+
return x(
|
|
54
|
+
[() => e.from, () => e.to, () => e.direction],
|
|
55
|
+
() => {
|
|
56
|
+
t.value = e.direction === "down" ? e.to : e.from, d.value = !1;
|
|
57
|
+
},
|
|
58
|
+
{ immediate: !0 }
|
|
59
|
+
), x(
|
|
60
|
+
() => e.startWhen,
|
|
61
|
+
() => {
|
|
62
|
+
e.startWhen && r.value && !d.value && g();
|
|
63
|
+
}
|
|
64
|
+
), T(async () => {
|
|
65
|
+
await N(), k();
|
|
66
|
+
}), O(() => {
|
|
67
|
+
y();
|
|
68
|
+
}), (i, c) => (V(), R("div", {
|
|
69
|
+
ref_key: "elementRef",
|
|
70
|
+
ref: o,
|
|
71
|
+
class: p([i.className, "g-percent-container"])
|
|
72
|
+
}, [
|
|
73
|
+
u("div", G, [
|
|
74
|
+
_(u("img", U, null, 512), [
|
|
75
|
+
[L, e.direction === "down"]
|
|
76
|
+
]),
|
|
77
|
+
_(u("img", $, null, 512), [
|
|
78
|
+
[L, e.direction === "up"]
|
|
79
|
+
])
|
|
80
|
+
]),
|
|
81
|
+
u("span", {
|
|
82
|
+
class: p(["g-percent-number", { "g-percent-number-down": e.direction === "down", "g-percent-number-up": e.direction === "up" }])
|
|
83
|
+
}, W(t.value.toFixed(e.decimalPlaces)), 3),
|
|
84
|
+
u("div", {
|
|
85
|
+
class: p(["g-percent-symbol", { "g-percent-number-down": e.direction === "down", "g-percent-number-up": e.direction === "up" }])
|
|
86
|
+
}, [
|
|
87
|
+
B(i.$slots, "symbol", {}, () => [
|
|
88
|
+
c[0] || (c[0] = q("%"))
|
|
89
|
+
], !0)
|
|
90
|
+
], 2)
|
|
91
|
+
], 2));
|
|
92
|
+
}
|
|
93
|
+
}), H = (n, e) => {
|
|
94
|
+
const o = n.__vccOpts || n;
|
|
95
|
+
for (const [t, r] of e)
|
|
96
|
+
o[t] = r;
|
|
97
|
+
return o;
|
|
98
|
+
}, f = /* @__PURE__ */ H(j, [["__scopeId", "data-v-33634690"]]);
|
|
99
|
+
f.install = (n) => {
|
|
100
|
+
n.component(f.name, f);
|
|
101
|
+
};
|
|
102
|
+
export {
|
|
103
|
+
f as GPercent,
|
|
104
|
+
f as default
|
|
105
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.g-percent-container[data-v-33634690]{display:inline-flex;align-items:center;justify-content:center}.g-percent-number-down[data-v-33634690]{color:#ff4d4f}.g-percent-number-up[data-v-33634690]{color:#52c41a}.g-percent-svg[data-v-33634690]{width:8px;height:8px}
|
package/lib/index/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../GCount/index.js"),o=require("../GPercent/index.js"),t={GCount:n.default,GPercent:o.default},r=c=>{Object.keys(t).forEach(u=>{const e=t[u];c.component(e.name,e)})},s={install:r};exports.GCount=n.default;exports.GPercent=o.default;exports.default=s;
|
package/lib/index/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import e from "../
|
|
2
|
-
import
|
|
3
|
-
const n = {
|
|
1
|
+
import e from "../GCount/index.mjs";
|
|
2
|
+
import s from "../GPercent/index.mjs";
|
|
3
|
+
const n = { GCount: e, GPercent: s }, m = (t) => {
|
|
4
4
|
Object.keys(n).forEach((c) => {
|
|
5
5
|
const o = n[c];
|
|
6
6
|
t.component(o.name, o);
|
|
7
7
|
});
|
|
8
|
-
},
|
|
8
|
+
}, p = { install: m };
|
|
9
9
|
export {
|
|
10
|
-
e as
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
e as GCount,
|
|
11
|
+
s as GPercent,
|
|
12
|
+
p as default
|
|
13
13
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geekin-devtoys",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"author": "leon",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "geekin-devtoys组件库",
|
|
@@ -35,14 +35,6 @@
|
|
|
35
35
|
"import": "./lib/index/style.css",
|
|
36
36
|
"require": "./lib/index/style.css"
|
|
37
37
|
},
|
|
38
|
-
"./Demo": {
|
|
39
|
-
"import": "./lib/Demo/index.mjs",
|
|
40
|
-
"require": "./lib/Demo/index.js"
|
|
41
|
-
},
|
|
42
|
-
"./Demo/style": {
|
|
43
|
-
"import": "./lib/Demo/style.css",
|
|
44
|
-
"require": "./lib/Demo/style.css"
|
|
45
|
-
},
|
|
46
38
|
"./GCount": {
|
|
47
39
|
"import": "./lib/GCount/index.mjs",
|
|
48
40
|
"require": "./lib/GCount/index.js"
|
|
@@ -50,6 +42,14 @@
|
|
|
50
42
|
"./GCount/style": {
|
|
51
43
|
"import": "./lib/GCount/style.css",
|
|
52
44
|
"require": "./lib/GCount/style.css"
|
|
45
|
+
},
|
|
46
|
+
"./GPercent": {
|
|
47
|
+
"import": "./lib/GPercent/index.mjs",
|
|
48
|
+
"require": "./lib/GPercent/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./GPercent/style": {
|
|
51
|
+
"import": "./lib/GPercent/style.css",
|
|
52
|
+
"require": "./lib/GPercent/style.css"
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
package/lib/Demo/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),a=(e,s)=>{const o=e.__vccOpts||e;for(const[c,r]of s)o[c]=r;return o},_={class:"demo"},i=Object.assign({name:"Demo"},{__name:"index",props:{msg:String},setup(e){return(s,o)=>(n.openBlock(),n.createElementBlock("div",_,n.toDisplayString(e.msg),1))}}),t=a(i,[["__scopeId","data-v-bd7af65f"]]);t.install=e=>{e.component(t.name,t)};exports.Demo=t;exports.default=t;
|
package/lib/Demo/index.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createElementBlock as a, openBlock as r, toDisplayString as _ } from "vue";
|
|
2
|
-
const m = (t, n) => {
|
|
3
|
-
const e = t.__vccOpts || t;
|
|
4
|
-
for (const [s, c] of n)
|
|
5
|
-
e[s] = c;
|
|
6
|
-
return e;
|
|
7
|
-
}, p = { class: "demo" }, i = /* @__PURE__ */ Object.assign({
|
|
8
|
-
name: "Demo"
|
|
9
|
-
}, {
|
|
10
|
-
__name: "index",
|
|
11
|
-
props: {
|
|
12
|
-
msg: String
|
|
13
|
-
},
|
|
14
|
-
setup(t) {
|
|
15
|
-
return (n, e) => (r(), a("div", p, _(t.msg), 1));
|
|
16
|
-
}
|
|
17
|
-
}), o = /* @__PURE__ */ m(i, [["__scopeId", "data-v-bd7af65f"]]);
|
|
18
|
-
o.install = (t) => {
|
|
19
|
-
t.component(o.name, o);
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
o as Demo,
|
|
23
|
-
o as default
|
|
24
|
-
};
|
package/lib/Demo/style.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.demo[data-v-bd7af65f]{width:200px;height:40px;background-color:#7fffd4;margin:20px}
|