@selectwin/kit 0.1.25 → 0.1.26
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/dist/SelectGlobe.d.ts +3 -2
- package/dist/index.js +38 -38
- package/package.json +1 -1
package/dist/SelectGlobe.d.ts
CHANGED
|
@@ -38,8 +38,9 @@ type SelectGlobeOwnProps = {
|
|
|
38
38
|
legend?: boolean;
|
|
39
39
|
/** Draw the real continents (Natural Earth land). */
|
|
40
40
|
map?: boolean;
|
|
41
|
-
/** Notified after each scroll-zoom
|
|
42
|
-
*
|
|
41
|
+
/** Notified after each scroll-zoom event with the new scale (clamped 0.8–1.8). The step is
|
|
42
|
+
* proportional to the wheel delta, so trackpads glide instead of jumping. Lets the host
|
|
43
|
+
* derive granularity from zoom, maps-style (e.g. country → state → city). */
|
|
43
44
|
onZoomChange?: (scale: number) => void;
|
|
44
45
|
};
|
|
45
46
|
export type SelectGlobeProps = SelectGlobeOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectGlobeOwnProps>;
|
package/dist/index.js
CHANGED
|
@@ -36,24 +36,24 @@ function Ks({ className: t, theme: n, glowTarget: l }) {
|
|
|
36
36
|
function G() {
|
|
37
37
|
const z = s.getBoundingClientRect();
|
|
38
38
|
L = z.left, E = z.top, w = z.width, N = z.height;
|
|
39
|
-
const
|
|
40
|
-
s.width = Math.round(w *
|
|
39
|
+
const he = Math.min(window.devicePixelRatio || 1, 2);
|
|
40
|
+
s.width = Math.round(w * he), s.height = Math.round(N * he), a.setTransform(he, 0, 0, he, 0, 0);
|
|
41
41
|
const ie = s.closest(".select-auth") ?? document;
|
|
42
42
|
A = l ? ie.querySelector(l) : null, C = [];
|
|
43
|
-
const
|
|
43
|
+
const pe = Math.ceil(w / o) + 1, de = Math.ceil(N / o) + 1, ae = (w - (pe - 1) * o) / 2, $e = (N - (de - 1) * o) / 2;
|
|
44
44
|
for (let Ce = 0; Ce < de; Ce++)
|
|
45
|
-
for (let Le = 0; Le <
|
|
45
|
+
for (let Le = 0; Le < pe; Le++) {
|
|
46
46
|
const Ne = ae + Le * o, Ie = $e + Ce * o;
|
|
47
47
|
C.push({ x: Ne, y: Ie, phase: (Ne + Ie) * 0.013 });
|
|
48
48
|
}
|
|
49
49
|
B.x === 0 && B.y === 0 && (B.x = T = w / 2, B.y = I = N / 2);
|
|
50
50
|
}
|
|
51
|
-
function J(z,
|
|
51
|
+
function J(z, he, ie, pe, de) {
|
|
52
52
|
if (!A) return;
|
|
53
|
-
const ae = A.getBoundingClientRect(), $e = ae.left - L + ae.width / 2, Ce = ae.top - E + ae.height / 2, Le = ae.width / 2, Ne = ae.height / 2, Ie = (z - $e) / (Le + y), ke = (
|
|
53
|
+
const ae = A.getBoundingClientRect(), $e = ae.left - L + ae.width / 2, Ce = ae.top - E + ae.height / 2, Le = ae.width / 2, Ne = ae.height / 2, Ie = (z - $e) / (Le + y), ke = (he - Ce) / (Ne + y), Ue = Math.sqrt(Ie * Ie + ke * ke), je = Ue < 1 ? 1 - Ue : 0, Fe = je * je * (3 - 2 * je);
|
|
54
54
|
if (Fe > 1e-3 || F > 1e-3) {
|
|
55
|
-
const P = on((z - $e) / Math.max(Le, 1), -1, 1) * 10 * Fe, V = on((
|
|
56
|
-
A.style.setProperty("--select-card-glow", Fe.toFixed(3)), A.style.setProperty("--select-card-glow-rgb", `${ie}, ${
|
|
55
|
+
const P = on((z - $e) / Math.max(Le, 1), -1, 1) * 10 * Fe, V = on((he - Ce) / Math.max(Ne, 1), -1, 1) * 10 * Fe;
|
|
56
|
+
A.style.setProperty("--select-card-glow", Fe.toFixed(3)), A.style.setProperty("--select-card-glow-rgb", `${ie}, ${pe}, ${de}`), A.style.setProperty("--select-card-glow-x", `${P.toFixed(1)}px`), A.style.setProperty("--select-card-glow-y", `${V.toFixed(1)}px`);
|
|
57
57
|
}
|
|
58
58
|
F = Fe;
|
|
59
59
|
}
|
|
@@ -64,15 +64,15 @@ function Ks({ className: t, theme: n, glowTarget: l }) {
|
|
|
64
64
|
A == null || A.style.setProperty("--select-card-glow", "0");
|
|
65
65
|
}
|
|
66
66
|
function me(z) {
|
|
67
|
-
let
|
|
68
|
-
z - O < v ? (
|
|
69
|
-
const
|
|
67
|
+
let he, ie;
|
|
68
|
+
z - O < v ? (he = T, ie = I) : (he = w * 0.5 + Math.cos(z * 0.45) * w * 0.3, ie = N * 0.5 + Math.sin(z * 0.6) * N * 0.28), W(he), Z(ie);
|
|
69
|
+
const pe = B.x, de = B.y;
|
|
70
70
|
a.clearRect(0, 0, w, N);
|
|
71
71
|
for (let ae = 0; ae < C.length; ae++) {
|
|
72
|
-
const $e = C[ae], Ce = $e.x -
|
|
73
|
-
ke > 0.12 ? (a.shadowColor = `rgba(${S},${k},${M},${0.6 * ke})`, a.shadowBlur = 12 * ke) : a.shadowBlur = 0, a.beginPath(), a.arc(P, V, i * U, 0, x), a.fillStyle = `rgba(${ee},${se},${
|
|
72
|
+
const $e = C[ae], Ce = $e.x - pe, Le = $e.y - de, Ne = Math.sqrt(Ce * Ce + Le * Le), Ie = Ne < h ? 1 - Ne / h : 0, ke = Ie * Ie, Ue = Math.sin(z * 1.4 + $e.phase) * 0.5 + 0.5, je = ke * u, Fe = Ne > 1e-4 ? 1 / Ne : 0, P = $e.x - Ce * Fe * je, V = $e.y - Le * Fe * je, U = 1 + ke * (f - 1) + Ue * 0.14, oe = Math.min(1, g + Ue * 0.08 + ke * (1 - g)), ee = _ + (S - _) * ke | 0, se = p + (k - p) * ke | 0, ue = b + (M - b) * ke | 0;
|
|
73
|
+
ke > 0.12 ? (a.shadowColor = `rgba(${S},${k},${M},${0.6 * ke})`, a.shadowBlur = 12 * ke) : a.shadowBlur = 0, a.beginPath(), a.arc(P, V, i * U, 0, x), a.fillStyle = `rgba(${ee},${se},${ue},${oe})`, a.fill();
|
|
74
74
|
}
|
|
75
|
-
a.shadowBlur = 0, J(
|
|
75
|
+
a.shadowBlur = 0, J(pe, de, S, k, M);
|
|
76
76
|
}
|
|
77
77
|
function Se(z) {
|
|
78
78
|
T = z.clientX - L, I = z.clientY - E, O = Me.ticker.time;
|
|
@@ -384,7 +384,7 @@ function Qs({
|
|
|
384
384
|
const w = Me.quickTo(p, "x", { duration: 0.5, ease: "power3.out" }), N = Me.quickTo(p, "y", { duration: 0.5, ease: "power3.out" });
|
|
385
385
|
function C(G, J) {
|
|
386
386
|
if (!x) return;
|
|
387
|
-
const re = x.getBoundingClientRect(), me = re.left - v + re.width / 2, Se = re.top - y + re.height / 2, ne = re.width / 2, H = re.height / 2, Q = 18, z = (G - me) / (ne + Q),
|
|
387
|
+
const re = x.getBoundingClientRect(), me = re.left - v + re.width / 2, Se = re.top - y + re.height / 2, ne = re.width / 2, H = re.height / 2, Q = 18, z = (G - me) / (ne + Q), he = (J - Se) / (H + Q), ie = Math.sqrt(z * z + he * he), pe = ie < 1 ? 1 - ie : 0, de = pe * pe * (3 - 2 * pe);
|
|
388
388
|
if (de > 1e-3 || $ > 1e-3) {
|
|
389
389
|
const ae = Ye((G - me) / Math.max(ne, 1), -1, 1) * 10 * de, $e = Ye((J - Se) / Math.max(H, 1), -1, 1) * 10 * de;
|
|
390
390
|
x.style.setProperty("--select-card-glow", de.toFixed(3)), x.style.setProperty("--select-card-glow-rgb", `${u[0]}, ${u[1]}, ${u[2]}`), x.style.setProperty("--select-card-glow-x", `${ae.toFixed(1)}px`), x.style.setProperty("--select-card-glow-y", `${$e.toFixed(1)}px`);
|
|
@@ -868,10 +868,10 @@ const lt = R(function({ htmlFor: n, label: l, info: c, action: s, className: a,
|
|
|
868
868
|
] });
|
|
869
869
|
}), We = R(function({ label: n, value: l, onChange: c, type: s = "text", labelAction: a, info: r, description: d, hint: o, error: i, prefix: h, suffix: u, mono: f, autoComplete: g, placeholder: v, required: y, disabled: x, readOnly: $, name: _, id: p, minLength: b, maxLength: S, min: k, max: M, step: w, inputMode: N, autoFocus: C, onBlur: L, onKeyDown: E, size: A = "md", className: F, ...B }, T) {
|
|
870
870
|
const I = te(), O = p ?? I, [W, Z] = D(!1), G = s === "password", J = G && W ? "text" : s, re = i ? `${O}-err` : o ? `${O}-hint` : void 0, me = h != null || u != null, Se = s === "number" && !me && !$, ne = l === "" ? null : Number(l), H = (ie) => {
|
|
871
|
-
const
|
|
872
|
-
let ae = (ne != null && Number.isFinite(ne) ? ne : 0) + ie *
|
|
871
|
+
const pe = Number(w ?? 1) || 1;
|
|
872
|
+
let ae = (ne != null && Number.isFinite(ne) ? ne : 0) + ie * pe;
|
|
873
873
|
k != null && (ae = Math.max(Number(k), ae)), M != null && (ae = Math.min(Number(M), ae)), c(String(ae));
|
|
874
|
-
}, Q = k != null && ne != null && ne <= Number(k), z = M != null && ne != null && ne >= Number(M),
|
|
874
|
+
}, Q = k != null && ne != null && ne <= Number(k), z = M != null && ne != null && ne >= Number(M), he = /* @__PURE__ */ e(
|
|
875
875
|
"input",
|
|
876
876
|
{
|
|
877
877
|
id: O,
|
|
@@ -903,7 +903,7 @@ const lt = R(function({ htmlFor: n, label: l, info: c, action: s, className: a,
|
|
|
903
903
|
d && /* @__PURE__ */ e("p", { className: "select-field__desc", children: d }),
|
|
904
904
|
/* @__PURE__ */ m("div", { className: `select-input-wrap${me ? " select-input-wrap--affixed" : ""}${i ? " select-input-wrap--error" : ""}`, children: [
|
|
905
905
|
h != null && /* @__PURE__ */ e("span", { className: "select-input__affix select-input__affix--prefix", children: h }),
|
|
906
|
-
|
|
906
|
+
he,
|
|
907
907
|
u != null && /* @__PURE__ */ e("span", { className: "select-input__affix select-input__affix--suffix", children: u }),
|
|
908
908
|
G && /* @__PURE__ */ e(
|
|
909
909
|
"button",
|
|
@@ -1305,8 +1305,8 @@ const Va = R(function({ files: n, onChange: l, accept: c, maxSizeMB: s = 10, all
|
|
|
1305
1305
|
r([]), s(Q.slice(0, 1));
|
|
1306
1306
|
return;
|
|
1307
1307
|
}
|
|
1308
|
-
const z = Math.min(E - c.length, L - A),
|
|
1309
|
-
s(
|
|
1308
|
+
const z = Math.min(E - c.length, L - A), he = [...c, ...Q.slice(0, Math.max(0, z))];
|
|
1309
|
+
s(he);
|
|
1310
1310
|
}, Z = () => {
|
|
1311
1311
|
const H = M.trim();
|
|
1312
1312
|
if (H) {
|
|
@@ -6447,10 +6447,10 @@ const Rn = (t, n) => Math.abs(t.lat - n.lat) < 1e-6 && Math.abs(t.lng - n.lng) <
|
|
|
6447
6447
|
const P = _.current;
|
|
6448
6448
|
if (!P) return;
|
|
6449
6449
|
const V = (U) => {
|
|
6450
|
-
var
|
|
6450
|
+
var se;
|
|
6451
6451
|
U.preventDefault();
|
|
6452
|
-
const oe =
|
|
6453
|
-
w.current = Math.max(0.8, Math.min(1.8,
|
|
6452
|
+
const oe = Math.max(-240, Math.min(240, U.deltaMode ? U.deltaY * 40 : U.deltaY)), ee = w.current * Math.exp(-oe * 12e-4);
|
|
6453
|
+
w.current = Math.max(0.8, Math.min(1.8, ee)), (se = J.current) == null || se.call(J, w.current), Z(), B((ue) => (ue + 1) % 1e6);
|
|
6454
6454
|
};
|
|
6455
6455
|
return P.addEventListener("wheel", V, { passive: !1 }), () => P.removeEventListener("wheel", V);
|
|
6456
6456
|
}, []);
|
|
@@ -6467,7 +6467,7 @@ const Rn = (t, n) => Math.abs(t.lat - n.lat) < 1e-6 && Math.abs(t.lng - n.lng) <
|
|
|
6467
6467
|
}, ne = (p / 2 - 6) * w.current, H = p / 2, Q = p / 2, z = (P) => {
|
|
6468
6468
|
const V = bt(P, k.current.lng, k.current.lat);
|
|
6469
6469
|
return { x: H + ne * V[0], y: Q - ne * V[1], z: V[2] };
|
|
6470
|
-
},
|
|
6470
|
+
}, he = xe(() => {
|
|
6471
6471
|
const V = [];
|
|
6472
6472
|
for (let U = -180; U < 180; U += 30) {
|
|
6473
6473
|
const oe = [];
|
|
@@ -6487,7 +6487,7 @@ const Rn = (t, n) => Math.abs(t.lat - n.lat) < 1e-6 && Math.abs(t.lng - n.lng) <
|
|
|
6487
6487
|
return V;
|
|
6488
6488
|
}),
|
|
6489
6489
|
[]
|
|
6490
|
-
),
|
|
6490
|
+
), pe = (P) => ({ x: H + ne * P[0], y: Q - ne * P[1] });
|
|
6491
6491
|
let de = "", ae = "";
|
|
6492
6492
|
if (h)
|
|
6493
6493
|
for (const P of ie) {
|
|
@@ -6495,22 +6495,22 @@ const Rn = (t, n) => Math.abs(t.lat - n.lat) < 1e-6 && Math.abs(t.lng - n.lng) <
|
|
|
6495
6495
|
let oe = !1;
|
|
6496
6496
|
for (const se of V)
|
|
6497
6497
|
if (se[2] > 0) {
|
|
6498
|
-
const
|
|
6499
|
-
ae += `${oe ? "L" : "M"}${
|
|
6498
|
+
const ue = pe(se);
|
|
6499
|
+
ae += `${oe ? "L" : "M"}${ue.x.toFixed(1)},${ue.y.toFixed(1)}`, oe = !0;
|
|
6500
6500
|
} else oe = !1;
|
|
6501
6501
|
const ee = [];
|
|
6502
6502
|
for (let se = 0; se < U; se++) {
|
|
6503
|
-
const
|
|
6504
|
-
if (Ve && ee.push({ v:
|
|
6505
|
-
const Je =
|
|
6506
|
-
ee.push({ v: [
|
|
6503
|
+
const ue = V[se], fe = V[(se + 1) % U], Ve = ue[2] > 0, Pe = fe[2] > 0;
|
|
6504
|
+
if (Ve && ee.push({ v: ue, edge: !1 }), Ve !== Pe) {
|
|
6505
|
+
const Je = ue[2] / (ue[2] - fe[2]);
|
|
6506
|
+
ee.push({ v: [ue[0] + (fe[0] - ue[0]) * Je, ue[1] + (fe[1] - ue[1]) * Je, 0], edge: !0 });
|
|
6507
6507
|
}
|
|
6508
6508
|
}
|
|
6509
6509
|
if (ee.length >= 3) {
|
|
6510
6510
|
const se = (fe, Ve) => {
|
|
6511
|
-
const Pe =
|
|
6511
|
+
const Pe = pe(Ve.v);
|
|
6512
6512
|
if (fe.edge && Ve.edge) {
|
|
6513
|
-
const Je = Math.atan2(
|
|
6513
|
+
const Je = Math.atan2(pe(fe.v).y - Q, pe(fe.v).x - H);
|
|
6514
6514
|
let Ze = Math.atan2(Pe.y - Q, Pe.x - H) - Je;
|
|
6515
6515
|
for (; Ze > Math.PI; ) Ze -= 2 * Math.PI;
|
|
6516
6516
|
for (; Ze < -Math.PI; ) Ze += 2 * Math.PI;
|
|
@@ -6518,8 +6518,8 @@ const Rn = (t, n) => Math.abs(t.lat - n.lat) < 1e-6 && Math.abs(t.lng - n.lng) <
|
|
|
6518
6518
|
return `A${ne.toFixed(1)},${ne.toFixed(1)} 0 0 ${mt} ${Pe.x.toFixed(1)},${Pe.y.toFixed(1)}`;
|
|
6519
6519
|
}
|
|
6520
6520
|
return `L${Pe.x.toFixed(1)},${Pe.y.toFixed(1)}`;
|
|
6521
|
-
},
|
|
6522
|
-
de += `M${
|
|
6521
|
+
}, ue = pe(ee[0].v);
|
|
6522
|
+
de += `M${ue.x.toFixed(1)},${ue.y.toFixed(1)}`;
|
|
6523
6523
|
for (let fe = 1; fe < ee.length; fe++) de += se(ee[fe - 1], ee[fe]);
|
|
6524
6524
|
de += se(ee[ee.length - 1], ee[0]), de += "Z";
|
|
6525
6525
|
}
|
|
@@ -6548,7 +6548,7 @@ const Rn = (t, n) => Math.abs(t.lat - n.lat) < 1e-6 && Math.abs(t.lng - n.lng) <
|
|
|
6548
6548
|
const mt = Ze / 40, ft = Pn(U, oe, mt), Pt = 1 + 0.34 * Math.sin(Math.PI * mt), $l = bt(ft, k.current.lng, k.current.lat), an = z([ft[0] * Pt, ft[1] * Pt, ft[2] * Pt]);
|
|
6549
6549
|
$l[2] > -0.05 ? (ee += `${se ? "L" : "M"}${an.x.toFixed(1)},${an.y.toFixed(1)}`, se = !0) : se = !1;
|
|
6550
6550
|
}
|
|
6551
|
-
const
|
|
6551
|
+
const ue = S.current ? 0.5 : (E.current * Ie + V * 0.27) % 1, fe = Pn(U, oe, ue), Ve = 1 + 0.34 * Math.sin(Math.PI * ue), Pe = bt(fe, k.current.lng, k.current.lat), Je = z([fe[0] * Ve, fe[1] * Ve, fe[2] * Ve]), sn = Ne != null && (Rn(P.from, Ne) || Rn(P.to, Ne));
|
|
6552
6552
|
return { d: ee, col: P.color ?? d, i: V, flow: { ...Je, vis: Pe[2] > 0 }, active: sn };
|
|
6553
6553
|
}), Ue = Ne != null, je = i ? [...n].sort((P, V) => (V.value ?? 0) - (P.value ?? 0)).slice(0, 6) : [];
|
|
6554
6554
|
return /* @__PURE__ */ m("div", { ref: y, ...v, className: `select-globe${g ? " " + g : ""}`, children: [
|
|
@@ -6625,7 +6625,7 @@ const Rn = (t, n) => Math.abs(t.lat - n.lat) < 1e-6 && Math.abs(t.lng - n.lng) <
|
|
|
6625
6625
|
stroke: `color-mix(in srgb, ${d} 68%, transparent)`
|
|
6626
6626
|
}
|
|
6627
6627
|
),
|
|
6628
|
-
|
|
6628
|
+
he.map((P, V) => /* @__PURE__ */ e("path", { d: $e(P), className: "select-globe__grid" }, `g${V}`)),
|
|
6629
6629
|
ke.map((P) => /* @__PURE__ */ m(
|
|
6630
6630
|
"g",
|
|
6631
6631
|
{
|
package/package.json
CHANGED