@studio-west/component-sw 0.13.19 → 1.0.1
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/README.md +262 -39
- package/dist/SwAffix-C-WH1AXb.js +81 -0
- package/dist/SwBackTop-CUlHSCLN.js +42 -0
- package/dist/{SwButton-DpOGpsBS.js → SwButton-yBtJyLyA.js} +1 -1
- package/dist/{SwSelect-DDNh3p6B.js → SwDadata-DqTWDCFW.js} +5 -5
- package/dist/{SwDatePicker-BwgaZLnR.js → SwDatePicker-4iPLiAJM.js} +1 -1
- package/dist/SwDrawer-CWWOrjf8.js +86 -0
- package/dist/{SwDropdownItem-DthBPUxn.js → SwDropdownItem-D1v0dRnc.js} +1 -1
- package/dist/{SwFile-DfeOYJQc.js → SwFile-CL1CigYW.js} +2 -2
- package/dist/{SwGide-BjQbQiBI.js → SwGuide-CjSEK9oe.js} +8 -8
- package/dist/{SwIcon-B-HHyuxu.js → SwIcon-Bjw7BuaO.js} +2 -2
- package/dist/{SwInput-BQXnoovf.js → SwInput-pYuctxdZ.js} +2 -2
- package/dist/{SwMessage-BghpMRWc.js → SwMessage-CmzUF6Jz.js} +2 -2
- package/dist/SwSelect-BK_EkJCH.js +139 -0
- package/dist/{SwSlider-Cl9pwY6h.js → SwSlider-Bxgz0rv5.js} +69 -28
- package/dist/{SwTable-DE3cDsvN.js → SwTable-DzUOHu08.js} +96 -94
- package/dist/SwTag-snjqhsXj.js +52 -0
- package/dist/component-sw.css +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +17 -13
- package/dist/{utils-qzwUfWRX.js → utils-B970mUhr.js} +1 -1
- package/package.json +1 -1
- package/types/components.d.ts +2 -2
- package/types/index.d.ts +57 -1
- package/dist/SwTag-DjZlthUS.js +0 -51
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { n as e } from "./SwIcon-Bjw7BuaO.js";
|
|
2
|
+
import { t } from "./SwButton-yBtJyLyA.js";
|
|
3
|
+
import { Teleport as n, Transition as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, mergeModels as f, nextTick as p, normalizeClass as m, normalizeStyle as h, onUnmounted as g, openBlock as _, ref as v, renderSlot as y, toDisplayString as b, unref as x, useModel as S, useSlots as C, watch as w, withCtx as T, withModifiers as E } from "vue";
|
|
4
|
+
//#region src/components/SwDrawer.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var D = { key: 0 }, O = { class: "sw-drawer-body" }, k = { key: 1 }, A = 250, j = /* @__PURE__ */ d({
|
|
6
|
+
__name: "SwDrawer",
|
|
7
|
+
props: /*@__PURE__*/ f({
|
|
8
|
+
class: { default: "" },
|
|
9
|
+
title: { default: "" },
|
|
10
|
+
placement: { default: "right" },
|
|
11
|
+
size: { default: "30%" },
|
|
12
|
+
after: { default: "" },
|
|
13
|
+
iconAfter: { default: "" },
|
|
14
|
+
modal: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: !1
|
|
17
|
+
},
|
|
18
|
+
closeOnClickModal: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: !0
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
modelValue: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: !1
|
|
26
|
+
},
|
|
27
|
+
modelModifiers: {}
|
|
28
|
+
}),
|
|
29
|
+
emits: /*@__PURE__*/ f(["close"], ["update:modelValue"]),
|
|
30
|
+
setup(d, { emit: f }) {
|
|
31
|
+
let j = S(d, "modelValue"), M = d, N = f, P = C(), F = v(""), I = i(() => M.after || M.iconAfter), L = () => {
|
|
32
|
+
typeof document > "u" || (F.value = document.body.style.overflow, document.body.style.overflow = "hidden");
|
|
33
|
+
}, R = () => {
|
|
34
|
+
typeof document > "u" || (document.body.style.overflow = F.value);
|
|
35
|
+
}, z = () => {
|
|
36
|
+
j.value = !1, N("close");
|
|
37
|
+
}, B = () => {
|
|
38
|
+
M.closeOnClickModal && z();
|
|
39
|
+
}, V = (e) => {
|
|
40
|
+
e.key === "Escape" && j.value && z();
|
|
41
|
+
};
|
|
42
|
+
w(() => j.value, (e) => {
|
|
43
|
+
typeof window > "u" || (e ? (L(), p(() => window.addEventListener("keydown", V))) : window.removeEventListener("keydown", V));
|
|
44
|
+
});
|
|
45
|
+
let H = () => {
|
|
46
|
+
R();
|
|
47
|
+
};
|
|
48
|
+
return g(() => {
|
|
49
|
+
R(), typeof window < "u" && window.removeEventListener("keydown", V);
|
|
50
|
+
}), (i, f) => (_(), a(n, { to: "body" }, [u(r, {
|
|
51
|
+
name: "sw-drawer",
|
|
52
|
+
appear: "",
|
|
53
|
+
duration: {
|
|
54
|
+
enter: A,
|
|
55
|
+
leave: A
|
|
56
|
+
},
|
|
57
|
+
onAfterLeave: H
|
|
58
|
+
}, {
|
|
59
|
+
default: T(() => [j.value ? (_(), s("div", {
|
|
60
|
+
key: 0,
|
|
61
|
+
class: m(["sw-drawer-mask", [M.class, { "is-modal": d.modal }]]),
|
|
62
|
+
onClick: E(B, ["self"])
|
|
63
|
+
}, [c("aside", {
|
|
64
|
+
class: m(["sw-drawer", [`is-${d.placement}`]]),
|
|
65
|
+
style: h({ width: d.size }),
|
|
66
|
+
role: "dialog",
|
|
67
|
+
"aria-modal": "true"
|
|
68
|
+
}, [
|
|
69
|
+
d.title || x(P).header || I.value ? (_(), s("header", D, [y(i.$slots, "header", {}, () => [l(b(d.title), 1)]), I.value ? (_(), a(t, {
|
|
70
|
+
key: 0,
|
|
71
|
+
link: "",
|
|
72
|
+
type: "primary",
|
|
73
|
+
onClick: z
|
|
74
|
+
}, {
|
|
75
|
+
default: T(() => [u(e, { "icon-class": I.value }, null, 8, ["icon-class"])]),
|
|
76
|
+
_: 1
|
|
77
|
+
})) : o("", !0)])) : o("", !0),
|
|
78
|
+
c("div", O, [y(i.$slots, "default")]),
|
|
79
|
+
x(P).footer ? (_(), s("footer", k, [y(i.$slots, "footer")])) : o("", !0)
|
|
80
|
+
], 6)], 2)) : o("", !0)]),
|
|
81
|
+
_: 3
|
|
82
|
+
}, 8, ["duration"])]));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
//#endregion
|
|
86
|
+
export { j as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e } from "./SwIcon-
|
|
1
|
+
import { n as e } from "./SwIcon-Bjw7BuaO.js";
|
|
2
2
|
import { computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, normalizeClass as o, openBlock as s, renderSlot as c } from "vue";
|
|
3
3
|
//#region src/components/SwDropdownItem.vue
|
|
4
4
|
var l = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as e } from "./SwIcon-
|
|
2
|
-
import { t } from "./SwButton-
|
|
1
|
+
import { n as e } from "./SwIcon-Bjw7BuaO.js";
|
|
2
|
+
import { t } from "./SwButton-yBtJyLyA.js";
|
|
3
3
|
import { Fragment as n, computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createVNode as s, defineComponent as c, mergeModels as l, nextTick as u, normalizeClass as d, normalizeStyle as f, onUnmounted as p, openBlock as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, unref as y, useModel as ee, watch as te, withCtx as b, withModifiers as ne } from "vue";
|
|
4
4
|
//#region src/utils/mediaCrop.ts
|
|
5
5
|
function re(e, t, n, r) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { i as e } from "./utils-
|
|
2
|
-
import { n as t } from "./SwIcon-
|
|
3
|
-
import { t as n } from "./SwButton-
|
|
1
|
+
import { i as e } from "./utils-B970mUhr.js";
|
|
2
|
+
import { n as t } from "./SwIcon-Bjw7BuaO.js";
|
|
3
|
+
import { t as n } from "./SwButton-yBtJyLyA.js";
|
|
4
4
|
import r from "./SwDropdown-DpedC6Bn.js";
|
|
5
5
|
import { computed as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, mergeModels as l, normalizeClass as u, onMounted as d, openBlock as f, ref as p, renderSlot as m, toDisplayString as h, useModel as g, watchEffect as _, withCtx as v } from "vue";
|
|
6
|
-
//#region src/components/
|
|
6
|
+
//#region src/components/SwGuide.vue
|
|
7
7
|
var y = ["src"], b = {
|
|
8
|
-
__name: "
|
|
8
|
+
__name: "SwGuide",
|
|
9
9
|
props: /*@__PURE__*/ l({
|
|
10
10
|
steps: {
|
|
11
11
|
type: Array,
|
|
@@ -72,14 +72,14 @@ var y = ["src"], b = {
|
|
|
72
72
|
r.disconnect(), window.removeEventListener("resize", n), window.removeEventListener("scroll", n);
|
|
73
73
|
});
|
|
74
74
|
}), d(() => window.onload = () => C.value = document.querySelector(E.steps[w.value]?.tag)), (e, i) => (f(), a("div", {
|
|
75
|
-
class: "sw-
|
|
76
|
-
ref_key: "
|
|
75
|
+
class: "sw-guide",
|
|
76
|
+
ref_key: "swGuide",
|
|
77
77
|
ref: x
|
|
78
78
|
}, [
|
|
79
79
|
i[6] ||= o("div", { class: "overlay0" }, null, -1),
|
|
80
80
|
i[7] ||= o("div", { class: "overlay1" }, null, -1),
|
|
81
81
|
c(r, {
|
|
82
|
-
class: "
|
|
82
|
+
class: "guide",
|
|
83
83
|
trigger: "none",
|
|
84
84
|
placement: E.steps[w.value].placement,
|
|
85
85
|
modelValue: S.value,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as e } from "./utils-
|
|
2
|
-
import { t } from "./
|
|
1
|
+
import { r as e } from "./utils-B970mUhr.js";
|
|
2
|
+
import { t } from "./SwDadata-DqTWDCFW.js";
|
|
3
3
|
import { computed as n, createElementBlock as r, createElementVNode as i, mergeProps as a, openBlock as o, unref as s } from "vue";
|
|
4
4
|
//#region src/components/SwIcon.vue
|
|
5
5
|
var c = /* @__PURE__ */ t({ default: () => u }), l = ["href"], u = /*@__PURE__*/ Object.assign({ inheritAttrs: !1 }, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as e } from "./utils-
|
|
2
|
-
import { n as t } from "./SwIcon-
|
|
1
|
+
import { n as e } from "./utils-B970mUhr.js";
|
|
2
|
+
import { n as t } from "./SwIcon-Bjw7BuaO.js";
|
|
3
3
|
import { computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createTextVNode as o, defineComponent as s, mergeModels as c, mergeProps as l, nextTick as u, normalizeClass as d, openBlock as f, ref as p, renderSlot as m, toDisplayString as h, useModel as g, vModelDynamic as _, vModelText as v, watch as y, withDirectives as b, withModifiers as x } from "vue";
|
|
4
4
|
//#region src/components/SwInput.vue?vue&type=script&setup=true&lang.ts
|
|
5
5
|
var S = ["for"], C = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as e } from "./SwIcon-
|
|
2
|
-
import { t } from "./SwButton-
|
|
1
|
+
import { n as e } from "./SwIcon-Bjw7BuaO.js";
|
|
2
|
+
import { t } from "./SwButton-yBtJyLyA.js";
|
|
3
3
|
import { computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, mergeModels as c, nextTick as l, normalizeClass as u, onUnmounted as d, openBlock as f, ref as p, renderSlot as m, toDisplayString as h, unref as g, useModel as _, useSlots as v, watch as y, withCtx as b } from "vue";
|
|
4
4
|
//#region src/components/SwMessage.vue
|
|
5
5
|
var x = { key: 0 }, S = {
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { t as e } from "./SwTag-snjqhsXj.js";
|
|
2
|
+
import { Fragment as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, defineComponent as c, mergeModels as l, nextTick as u, normalizeClass as d, onMounted as f, onUnmounted as p, openBlock as m, ref as h, renderList as g, toDisplayString as _, useModel as v, vShow as y, watch as b, withDirectives as x } from "vue";
|
|
3
|
+
//#region src/components/SwSelect.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var S = ["aria-expanded"], C = { class: "sw-select-values" }, w = {
|
|
5
|
+
key: 1,
|
|
6
|
+
class: "sw-select-label"
|
|
7
|
+
}, T = {
|
|
8
|
+
key: 2,
|
|
9
|
+
class: "sw-select-placeholder"
|
|
10
|
+
}, E = { class: "sw-select-popup" }, D = ["aria-multiselectable"], O = [
|
|
11
|
+
"aria-selected",
|
|
12
|
+
"onClick",
|
|
13
|
+
"onMouseenter"
|
|
14
|
+
], k = {
|
|
15
|
+
key: 0,
|
|
16
|
+
class: "sw-select-check"
|
|
17
|
+
}, A = /* @__PURE__ */ c({
|
|
18
|
+
__name: "SwSelect",
|
|
19
|
+
props: /*@__PURE__*/ l({
|
|
20
|
+
class: { default: "" },
|
|
21
|
+
size: { default: "large" },
|
|
22
|
+
placeholder: { default: "" },
|
|
23
|
+
options: { default: () => [] },
|
|
24
|
+
multiple: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: !1
|
|
27
|
+
},
|
|
28
|
+
clearable: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: !1
|
|
31
|
+
},
|
|
32
|
+
disabled: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: !1
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
modelValue: {},
|
|
38
|
+
modelModifiers: {}
|
|
39
|
+
}),
|
|
40
|
+
emits: ["update:modelValue"],
|
|
41
|
+
setup(c) {
|
|
42
|
+
let l = v(c, "modelValue"), A = c, j = h(!1), M = h(-1), N = h(null), P = h(null), F = n(() => A.multiple ? Array.isArray(l.value) ? l.value : [] : l.value === void 0 || l.value === null || l.value === "" ? [] : [l.value]), I = n(() => A.options.filter((e) => F.value.includes(e.value))), L = n(() => A.multiple ? "" : A.options.find((e) => e.value === l.value)?.label ?? ""), R = n(() => F.value.length > 0), z = () => {
|
|
43
|
+
A.disabled || (j.value = !j.value, j.value && (M.value = -1));
|
|
44
|
+
}, B = () => {
|
|
45
|
+
j.value = !1, M.value = -1;
|
|
46
|
+
}, V = (e) => F.value.includes(e), H = (e) => {
|
|
47
|
+
if (!e.disabled) if (A.multiple) {
|
|
48
|
+
let t = Array.isArray(l.value) ? [...l.value] : [], n = t.indexOf(e.value);
|
|
49
|
+
n >= 0 ? t.splice(n, 1) : t.push(e.value), l.value = t;
|
|
50
|
+
} else l.value = e.value, B();
|
|
51
|
+
}, U = (e) => {
|
|
52
|
+
!A.multiple || !Array.isArray(l.value) || (l.value = l.value.filter((t) => t !== e));
|
|
53
|
+
}, W = (e) => {
|
|
54
|
+
e.stopPropagation(), l.value = A.multiple ? [] : void 0, B();
|
|
55
|
+
}, G = () => A.options.map((e, t) => t).filter((e) => !A.options[e].disabled), K = (e) => {
|
|
56
|
+
let t = G();
|
|
57
|
+
if (!t.length) return;
|
|
58
|
+
let n = t.indexOf(M.value), r = n < 0 ? e > 0 ? t[0] : t[t.length - 1] : t[(n + e + t.length) % t.length];
|
|
59
|
+
M.value = r, J();
|
|
60
|
+
}, q = (e) => {
|
|
61
|
+
if (A.disabled) return;
|
|
62
|
+
if (!j.value) {
|
|
63
|
+
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), j.value = !0);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
let t = G();
|
|
67
|
+
t.length && (e.key === "ArrowDown" ? (e.preventDefault(), K(1)) : e.key === "ArrowUp" ? (e.preventDefault(), K(-1)) : e.key === "Home" ? (e.preventDefault(), M.value = t[0], J()) : e.key === "End" ? (e.preventDefault(), M.value = t[t.length - 1], J()) : e.key === "Enter" || e.key === " " ? (e.preventDefault(), M.value >= 0 && H(A.options[M.value])) : e.key === "Escape" && (e.preventDefault(), B()));
|
|
68
|
+
}, J = () => {
|
|
69
|
+
u(() => {
|
|
70
|
+
(P.value?.querySelector(".is-active"))?.scrollIntoView({ block: "nearest" });
|
|
71
|
+
});
|
|
72
|
+
}, Y = (e) => {
|
|
73
|
+
!j.value || !N.value || N.value.contains(e.target) || B();
|
|
74
|
+
};
|
|
75
|
+
return f(() => {
|
|
76
|
+
typeof document < "u" && document.addEventListener("click", Y, !0);
|
|
77
|
+
}), p(() => {
|
|
78
|
+
typeof document < "u" && document.removeEventListener("click", Y, !0);
|
|
79
|
+
}), b(() => A.multiple, (e) => {
|
|
80
|
+
e && !Array.isArray(l.value) && (l.value = l.value == null ? [] : [l.value]), !e && Array.isArray(l.value) && (l.value = l.value[0]);
|
|
81
|
+
}, { immediate: !0 }), (n, l) => (m(), a("div", {
|
|
82
|
+
ref_key: "rootRef",
|
|
83
|
+
ref: N,
|
|
84
|
+
class: d(["sw-select", [
|
|
85
|
+
A.class,
|
|
86
|
+
A.size,
|
|
87
|
+
{
|
|
88
|
+
"is-open": j.value,
|
|
89
|
+
"is-disabled": c.disabled
|
|
90
|
+
}
|
|
91
|
+
]]),
|
|
92
|
+
tabindex: "0",
|
|
93
|
+
role: "combobox",
|
|
94
|
+
"aria-expanded": j.value,
|
|
95
|
+
onKeydown: q
|
|
96
|
+
}, [o("div", {
|
|
97
|
+
class: "sw-select-trigger",
|
|
98
|
+
onClick: z
|
|
99
|
+
}, [
|
|
100
|
+
o("div", C, [c.multiple && I.value.length ? (m(!0), a(t, { key: 0 }, g(I.value, (t) => (m(), r(e, {
|
|
101
|
+
key: String(t.value),
|
|
102
|
+
size: "small",
|
|
103
|
+
closable: "",
|
|
104
|
+
label: t.label,
|
|
105
|
+
onClose: (e) => U(t.value)
|
|
106
|
+
}, null, 8, ["label", "onClose"]))), 128)) : L.value ? (m(), a("span", w, _(L.value), 1)) : (m(), a("span", T, _(c.placeholder), 1))]),
|
|
107
|
+
c.clearable && R.value && !c.disabled ? (m(), a("button", {
|
|
108
|
+
key: 0,
|
|
109
|
+
type: "button",
|
|
110
|
+
class: "sw-select-clear",
|
|
111
|
+
"aria-label": "Очистить",
|
|
112
|
+
onClick: W
|
|
113
|
+
}, " × ")) : i("", !0),
|
|
114
|
+
l[0] ||= o("span", {
|
|
115
|
+
class: "sw-select-arrow",
|
|
116
|
+
"aria-hidden": "true"
|
|
117
|
+
}, "▾", -1)
|
|
118
|
+
]), x(o("div", E, [o("ul", {
|
|
119
|
+
ref_key: "listRef",
|
|
120
|
+
ref: P,
|
|
121
|
+
class: "sw-select-list",
|
|
122
|
+
role: "listbox",
|
|
123
|
+
"aria-multiselectable": c.multiple
|
|
124
|
+
}, [(m(!0), a(t, null, g(c.options, (e, t) => (m(), a("li", {
|
|
125
|
+
key: t,
|
|
126
|
+
role: "option",
|
|
127
|
+
class: d({
|
|
128
|
+
"is-active": t === M.value,
|
|
129
|
+
"is-selected": V(e.value),
|
|
130
|
+
"is-disabled": e.disabled
|
|
131
|
+
}),
|
|
132
|
+
"aria-selected": V(e.value),
|
|
133
|
+
onClick: (t) => H(e),
|
|
134
|
+
onMouseenter: (e) => M.value = t
|
|
135
|
+
}, [c.multiple ? (m(), a("span", k, _(V(e.value) ? "✓" : ""), 1)) : i("", !0), s(" " + _(e.label), 1)], 42, O))), 128))], 8, D)], 512), [[y, j.value]])], 42, S));
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
//#endregion
|
|
139
|
+
export { A as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./utils-
|
|
1
|
+
import { t as e } from "./utils-B970mUhr.js";
|
|
2
2
|
import { Fragment as t, computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, mergeModels as o, normalizeClass as s, normalizeStyle as c, onMounted as l, onUnmounted as u, openBlock as d, ref as f, renderList as p, renderSlot as m, toDisplayString as h, useModel as g, withModifiers as _ } from "vue";
|
|
3
3
|
//#region src/components/SwSlider.vue
|
|
4
4
|
var v = [
|
|
@@ -38,6 +38,10 @@ var v = [
|
|
|
38
38
|
showValue: {
|
|
39
39
|
type: Boolean,
|
|
40
40
|
default: !1
|
|
41
|
+
},
|
|
42
|
+
trackColor: {
|
|
43
|
+
type: Array,
|
|
44
|
+
default: () => []
|
|
41
45
|
}
|
|
42
46
|
}, {
|
|
43
47
|
modelValue: {
|
|
@@ -97,14 +101,16 @@ var v = [
|
|
|
97
101
|
let e = P.value[0] || 0, t = P.value[P.value.length - 1] || 0, n = Math.min(e, t);
|
|
98
102
|
return {
|
|
99
103
|
height: `${Math.max(e, t) - n}%`,
|
|
100
|
-
|
|
104
|
+
bottom: `${n}%`,
|
|
105
|
+
top: "auto",
|
|
101
106
|
left: "0",
|
|
102
107
|
width: "100%"
|
|
103
108
|
};
|
|
104
109
|
}
|
|
105
110
|
return {
|
|
106
111
|
height: `${P.value[0] || 0}%`,
|
|
107
|
-
|
|
112
|
+
bottom: "0",
|
|
113
|
+
top: "auto",
|
|
108
114
|
left: "0",
|
|
109
115
|
width: "100%"
|
|
110
116
|
};
|
|
@@ -124,65 +130,100 @@ var v = [
|
|
|
124
130
|
top: "0",
|
|
125
131
|
height: "100%"
|
|
126
132
|
};
|
|
127
|
-
}), I = n(() =>
|
|
128
|
-
|
|
133
|
+
}), I = n(() => {
|
|
134
|
+
let e = b.trackColor;
|
|
135
|
+
if (!e?.length) return [];
|
|
136
|
+
let t = e[e.length - 1], n = P.value, r = [];
|
|
137
|
+
if (j.value) for (let e = 0; e < n.length - 1; e++) r.push({
|
|
138
|
+
start: n[e],
|
|
139
|
+
end: n[e + 1]
|
|
140
|
+
});
|
|
141
|
+
else n.length && r.push({
|
|
142
|
+
start: 0,
|
|
143
|
+
end: n[0]
|
|
144
|
+
});
|
|
145
|
+
return r.map(({ start: n, end: r }, i) => {
|
|
146
|
+
let a = e[i] ?? t;
|
|
147
|
+
return b.vertical ? {
|
|
148
|
+
bottom: `${n}%`,
|
|
149
|
+
height: `${r - n}%`,
|
|
150
|
+
top: "auto",
|
|
151
|
+
left: "0",
|
|
152
|
+
width: "100%",
|
|
153
|
+
background: a
|
|
154
|
+
} : {
|
|
155
|
+
left: `${n}%`,
|
|
156
|
+
width: `${r - n}%`,
|
|
157
|
+
top: "0",
|
|
158
|
+
height: "100%",
|
|
159
|
+
background: a
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
}), L = n(() => P.value.map((e, t) => b.vertical ? {
|
|
163
|
+
top: `${100 - e}%`,
|
|
164
|
+
bottom: "auto",
|
|
129
165
|
zIndex: M.value.length - t
|
|
130
166
|
} : {
|
|
131
167
|
left: `${e}%`,
|
|
132
168
|
zIndex: M.value.length - t
|
|
133
|
-
}));
|
|
134
|
-
function
|
|
169
|
+
})), R = (e, t, n) => b.vertical ? 1 - (t - n.top) / n.height : (e - n.left) / n.width;
|
|
170
|
+
function z(e) {
|
|
135
171
|
let t = Math.round((e - b.min) / b.step), n = b.min + t * b.step;
|
|
136
172
|
return Math.max(b.min, Math.min(b.max, n));
|
|
137
173
|
}
|
|
138
|
-
function
|
|
174
|
+
function B(e) {
|
|
139
175
|
if (j.value || C.value) return;
|
|
140
176
|
let t = x.value;
|
|
141
177
|
if (!t) return;
|
|
142
|
-
let n = t.getBoundingClientRect(), r =
|
|
143
|
-
N([
|
|
178
|
+
let n = t.getBoundingClientRect(), r = Math.max(0, Math.min(1, R(e.clientX, e.clientY, n))), i = b.max - b.min;
|
|
179
|
+
N([z(b.min + r * i)]);
|
|
144
180
|
}
|
|
145
|
-
function
|
|
181
|
+
function V(e, t) {
|
|
146
182
|
let n = x.value || e.target?.closest?.(".sw-slider");
|
|
147
|
-
n && (T = n.getBoundingClientRect(), w.value = t, C.value = !0, D(t),
|
|
183
|
+
n && (T = n.getBoundingClientRect(), w.value = t, C.value = !0, D(t), W(e.clientX ?? e.touches?.[0]?.clientX, e.clientY ?? e.touches?.[0]?.clientY));
|
|
148
184
|
}
|
|
149
|
-
function
|
|
150
|
-
C.value && (e.preventDefault?.(),
|
|
185
|
+
function H(e) {
|
|
186
|
+
C.value && (e.preventDefault?.(), W(e.clientX ?? e.touches?.[0]?.clientX, e.clientY ?? e.touches?.[0]?.clientY));
|
|
151
187
|
}
|
|
152
|
-
function
|
|
188
|
+
function U() {
|
|
153
189
|
C.value && (C.value = !1, w.value = null, T = null);
|
|
154
190
|
}
|
|
155
|
-
function
|
|
191
|
+
function W(e, t) {
|
|
156
192
|
if (!T || w.value === null) return;
|
|
157
|
-
let n =
|
|
158
|
-
|
|
193
|
+
let n = Math.max(0, Math.min(1, R(e, t, T))), r = b.max - b.min, i = z(b.min + n * r), a = [...M.value];
|
|
194
|
+
a[w.value] = i, N(a);
|
|
159
195
|
}
|
|
160
196
|
return l(() => {
|
|
161
|
-
window.addEventListener("mousemove",
|
|
197
|
+
window.addEventListener("mousemove", H, { passive: !1 }), window.addEventListener("mouseup", U), window.addEventListener("touchmove", H, { passive: !1 }), window.addEventListener("touchend", U), S.value = Array(M.value.length).fill(!1);
|
|
162
198
|
}), u(() => {
|
|
163
|
-
window.removeEventListener("mousemove",
|
|
199
|
+
window.removeEventListener("mousemove", H), window.removeEventListener("mouseup", U), window.removeEventListener("touchmove", H), window.removeEventListener("touchend", U);
|
|
164
200
|
}), (e, n) => (d(), i("div", {
|
|
165
201
|
class: s(E.value),
|
|
166
202
|
ref_key: "rootRef",
|
|
167
203
|
ref: x
|
|
168
204
|
}, [a("div", {
|
|
169
205
|
class: "track",
|
|
170
|
-
onClick:
|
|
171
|
-
onMousedown: n[0] ||= _((e) =>
|
|
172
|
-
onTouchstart: n[1] ||= _((e) =>
|
|
173
|
-
}, [
|
|
206
|
+
onClick: B,
|
|
207
|
+
onMousedown: n[0] ||= _((e) => V(e, 0), ["prevent"]),
|
|
208
|
+
onTouchstart: n[1] ||= _((e) => V(e.touches[0], 0), ["prevent"])
|
|
209
|
+
}, [I.value.length ? (d(!0), i(t, { key: 0 }, p(I.value, (e, t) => (d(), i("div", {
|
|
210
|
+
key: t,
|
|
211
|
+
class: "fill",
|
|
212
|
+
style: c(e)
|
|
213
|
+
}, null, 4))), 128)) : (d(), i("div", {
|
|
214
|
+
key: 1,
|
|
174
215
|
class: "fill",
|
|
175
216
|
style: c(F.value)
|
|
176
|
-
}, null, 4)], 32), (d(!0), i(t, null, p(M.value, (t, n) => (d(), i("div", {
|
|
217
|
+
}, null, 4))], 32), (d(!0), i(t, null, p(M.value, (t, n) => (d(), i("div", {
|
|
177
218
|
class: "thumb",
|
|
178
219
|
key: n,
|
|
179
|
-
style: c(
|
|
220
|
+
style: c(L.value[n]),
|
|
180
221
|
onMouseenter: (e) => D(n),
|
|
181
222
|
onMouseleave: (e) => O(n),
|
|
182
223
|
onFocus: (e) => D(n),
|
|
183
224
|
onBlur: (e) => O(n),
|
|
184
|
-
onMousedown: _((e) =>
|
|
185
|
-
onTouchstart: _((e) =>
|
|
225
|
+
onMousedown: _((e) => V(e, n), ["prevent"]),
|
|
226
|
+
onTouchstart: _((e) => V(e.touches[0], n), ["prevent"])
|
|
186
227
|
}, [m(e.$slots, "default", {
|
|
187
228
|
index: n,
|
|
188
229
|
value: t
|