@studio-west/component-sw 1.0.3 → 1.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/README.md +284 -76
- package/dist/{SwAffix-C-WH1AXb.js → SwAffix-DQctfUrW.js} +45 -18
- package/dist/{SwBackTop-DmChxDF3.js → SwBackTop-C2evKTw6.js} +13 -8
- package/dist/SwBreadcrumb-BhK5ikm_.js +47 -0
- package/dist/SwDrawer-BOufiYl-.js +116 -0
- package/dist/SwEmpty-Bcga9O61.js +35 -0
- package/dist/SwProgress-DeUCmFKn.js +95 -0
- package/dist/SwRate-CL9lWRld.js +104 -0
- package/dist/SwSegmented-FmTR7s71.js +74 -0
- package/dist/{SwSwitch-Cxk-eNTf.js → SwSwitch-D7fUgARl.js} +9 -3
- package/dist/component-sw.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +9 -4
- package/package.json +5 -1
- package/types/index.d.ts +77 -1
- package/dist/SwDrawer-CE-pDRBB.js +0 -86
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, defineComponent as a, normalizeClass as o, openBlock as s, renderList as c, toDisplayString as l } from "vue";
|
|
2
|
+
//#region src/components/SwBreadcrumb.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
+
var u = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "sep",
|
|
6
|
+
"aria-hidden": "true"
|
|
7
|
+
}, d = ["href", "onClick"], f = ["aria-current", "onClick"], p = /* @__PURE__ */ a({
|
|
8
|
+
__name: "SwBreadcrumb",
|
|
9
|
+
props: {
|
|
10
|
+
class: { default: "" },
|
|
11
|
+
items: { default: () => [] },
|
|
12
|
+
separator: { default: "/" }
|
|
13
|
+
},
|
|
14
|
+
emits: ["select"],
|
|
15
|
+
setup(a, { emit: p }) {
|
|
16
|
+
let m = a, h = p, g = t(() => {
|
|
17
|
+
let e = ["sw-breadcrumb"];
|
|
18
|
+
return m.class && e.push(m.class), e;
|
|
19
|
+
}), _ = (e, t, n) => {
|
|
20
|
+
if (e.disabled) {
|
|
21
|
+
n.preventDefault();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
h("select", e, t);
|
|
25
|
+
};
|
|
26
|
+
return (t, a) => (s(), r("nav", {
|
|
27
|
+
class: o(g.value),
|
|
28
|
+
"aria-label": "breadcrumb"
|
|
29
|
+
}, [i("ol", null, [(s(!0), r(e, null, c(m.items, (e, t) => (s(), r("li", {
|
|
30
|
+
key: `${e.label}-${t}`,
|
|
31
|
+
class: o({
|
|
32
|
+
disabled: e.disabled,
|
|
33
|
+
current: t === m.items.length - 1
|
|
34
|
+
})
|
|
35
|
+
}, [t > 0 ? (s(), r("span", u, l(m.separator), 1)) : n("", !0), e.href && t < m.items.length - 1 && !e.disabled ? (s(), r("a", {
|
|
36
|
+
key: 1,
|
|
37
|
+
href: e.href,
|
|
38
|
+
onClick: (n) => _(e, t, n)
|
|
39
|
+
}, l(e.label), 9, d)) : (s(), r("span", {
|
|
40
|
+
key: 2,
|
|
41
|
+
"aria-current": t === m.items.length - 1 ? "page" : void 0,
|
|
42
|
+
onClick: (n) => _(e, t, n)
|
|
43
|
+
}, l(e.label), 9, f))], 2))), 128))])], 2));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { p as default };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { n as e } from "./SwIcon-BbL8Tu2z.js";
|
|
2
|
+
import { t } from "./SwButton-XAFVTlsb.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 = ["aria-modal", "aria-hidden"], O = ["aria-expanded", "aria-label"], k = {
|
|
6
|
+
key: 1,
|
|
7
|
+
class: "label"
|
|
8
|
+
}, A = { key: 1 }, j = { class: "sw-drawer-body" }, M = { key: 2 }, N = 250, P = /* @__PURE__ */ d({
|
|
9
|
+
__name: "SwDrawer",
|
|
10
|
+
props: /*@__PURE__*/ f({
|
|
11
|
+
class: { default: "" },
|
|
12
|
+
title: { default: "" },
|
|
13
|
+
placement: { default: "right" },
|
|
14
|
+
size: { default: "30%" },
|
|
15
|
+
after: { default: "" },
|
|
16
|
+
iconAfter: { default: "" },
|
|
17
|
+
modal: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: !1
|
|
20
|
+
},
|
|
21
|
+
closeOnClickModal: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: !0
|
|
24
|
+
},
|
|
25
|
+
tab: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: !1
|
|
28
|
+
},
|
|
29
|
+
tabLabel: { default: "" },
|
|
30
|
+
tabBefore: { default: "" }
|
|
31
|
+
}, {
|
|
32
|
+
modelValue: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: !1
|
|
35
|
+
},
|
|
36
|
+
modelModifiers: {}
|
|
37
|
+
}),
|
|
38
|
+
emits: /*@__PURE__*/ f(["close"], ["update:modelValue"]),
|
|
39
|
+
setup(d, { emit: f }) {
|
|
40
|
+
let P = S(d, "modelValue"), F = d, I = f, L = C(), R = v(""), z = i(() => F.after || F.iconAfter), B = i(() => P.value || F.tab), V = i(() => F.tab && !(F.modal && P.value)), H = i(() => F.modal && P.value), U = i(() => F.placement === "top" || F.placement === "bottom"), W = i(() => U.value ? { height: F.size } : { width: F.size }), G = () => {
|
|
41
|
+
typeof document > "u" || (R.value = document.body.style.overflow, document.body.style.overflow = "hidden");
|
|
42
|
+
}, K = () => {
|
|
43
|
+
typeof document > "u" || (document.body.style.overflow = R.value);
|
|
44
|
+
}, q = () => {
|
|
45
|
+
P.value = !1, I("close");
|
|
46
|
+
}, J = () => {
|
|
47
|
+
P.value ? q() : P.value = !0;
|
|
48
|
+
}, Y = () => {
|
|
49
|
+
H.value && F.closeOnClickModal && q();
|
|
50
|
+
}, X = (e) => {
|
|
51
|
+
e.key === "Escape" && P.value && q();
|
|
52
|
+
};
|
|
53
|
+
w(() => P.value, (e) => {
|
|
54
|
+
typeof window > "u" || (e ? (F.modal && G(), p(() => window.addEventListener("keydown", X))) : (window.removeEventListener("keydown", X), K()));
|
|
55
|
+
});
|
|
56
|
+
let Z = () => {
|
|
57
|
+
K();
|
|
58
|
+
};
|
|
59
|
+
return g(() => {
|
|
60
|
+
K(), typeof window < "u" && window.removeEventListener("keydown", X);
|
|
61
|
+
}), (i, f) => (_(), a(n, { to: "body" }, [u(r, {
|
|
62
|
+
name: "sw-drawer",
|
|
63
|
+
appear: P.value,
|
|
64
|
+
duration: {
|
|
65
|
+
enter: N,
|
|
66
|
+
leave: N
|
|
67
|
+
},
|
|
68
|
+
onAfterLeave: Z
|
|
69
|
+
}, {
|
|
70
|
+
default: T(() => [B.value ? (_(), s("div", {
|
|
71
|
+
key: 0,
|
|
72
|
+
class: m([
|
|
73
|
+
H.value ? "sw-drawer-mask is-modal" : "sw-drawer-host",
|
|
74
|
+
F.class,
|
|
75
|
+
{
|
|
76
|
+
"is-open": P.value,
|
|
77
|
+
"is-peek": d.tab && !P.value
|
|
78
|
+
}
|
|
79
|
+
]),
|
|
80
|
+
onClick: E(Y, ["self"])
|
|
81
|
+
}, [c("aside", {
|
|
82
|
+
class: m(["sw-drawer", [`is-${d.placement}`, { "is-closed": !P.value }]]),
|
|
83
|
+
style: h(W.value),
|
|
84
|
+
role: "dialog",
|
|
85
|
+
"aria-modal": H.value ? "true" : void 0,
|
|
86
|
+
"aria-hidden": P.value ? void 0 : "true"
|
|
87
|
+
}, [
|
|
88
|
+
V.value ? (_(), s("button", {
|
|
89
|
+
key: 0,
|
|
90
|
+
type: "button",
|
|
91
|
+
class: "tab",
|
|
92
|
+
"aria-expanded": P.value,
|
|
93
|
+
"aria-label": d.tabLabel || "drawer tab",
|
|
94
|
+
onClick: E(J, ["stop"])
|
|
95
|
+
}, [y(i.$slots, "tab", {}, () => [d.tabBefore ? (_(), a(e, {
|
|
96
|
+
key: 0,
|
|
97
|
+
"icon-class": d.tabBefore
|
|
98
|
+
}, null, 8, ["icon-class"])) : o("", !0), d.tabLabel ? (_(), s("span", k, b(d.tabLabel), 1)) : o("", !0)])], 8, O)) : o("", !0),
|
|
99
|
+
d.title || x(L).header || z.value ? (_(), s("header", A, [y(i.$slots, "header", {}, () => [l(b(d.title), 1)]), z.value ? (_(), a(t, {
|
|
100
|
+
key: 0,
|
|
101
|
+
link: "",
|
|
102
|
+
type: "primary",
|
|
103
|
+
onClick: q
|
|
104
|
+
}, {
|
|
105
|
+
default: T(() => [u(e, { "icon-class": z.value }, null, 8, ["icon-class"])]),
|
|
106
|
+
_: 1
|
|
107
|
+
})) : o("", !0)])) : o("", !0),
|
|
108
|
+
c("div", j, [y(i.$slots, "default")]),
|
|
109
|
+
x(L).footer ? (_(), s("footer", M, [y(i.$slots, "footer")])) : o("", !0)
|
|
110
|
+
], 14, D)], 2)) : o("", !0)]),
|
|
111
|
+
_: 3
|
|
112
|
+
}, 8, ["appear", "duration"])]));
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
//#endregion
|
|
116
|
+
export { P as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { n as e } from "./SwIcon-BbL8Tu2z.js";
|
|
2
|
+
import { computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, createVNode as o, defineComponent as s, normalizeClass as c, normalizeStyle as l, openBlock as u, renderSlot as d, toDisplayString as f } from "vue";
|
|
3
|
+
//#region src/components/SwEmpty.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var p = { class: "description" }, m = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "extra"
|
|
7
|
+
}, h = "https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline", g = /* @__PURE__ */ s({
|
|
8
|
+
__name: "SwEmpty",
|
|
9
|
+
props: {
|
|
10
|
+
class: { default: "" },
|
|
11
|
+
description: { default: "Нет данных" },
|
|
12
|
+
before: { default: "" },
|
|
13
|
+
imageSize: { default: 3 }
|
|
14
|
+
},
|
|
15
|
+
setup(s) {
|
|
16
|
+
let g = `${h}/clipboard-off.svg`, _ = s, v = t(() => {
|
|
17
|
+
let e = ["sw-empty"];
|
|
18
|
+
return _.class && e.push(_.class), e;
|
|
19
|
+
}), y = t(() => _.before || g), b = t(() => ({
|
|
20
|
+
fontSize: `${_.imageSize}em`,
|
|
21
|
+
width: "1em",
|
|
22
|
+
height: "1em"
|
|
23
|
+
}));
|
|
24
|
+
return (t, s) => (u(), r("div", { class: c(v.value) }, [
|
|
25
|
+
i("div", {
|
|
26
|
+
class: "image",
|
|
27
|
+
style: l(b.value)
|
|
28
|
+
}, [d(t.$slots, "image", {}, () => [o(e, { "icon-class": y.value }, null, 8, ["icon-class"])])], 4),
|
|
29
|
+
i("p", p, [d(t.$slots, "description", {}, () => [a(f(_.description), 1)])]),
|
|
30
|
+
t.$slots.default ? (u(), r("div", m, [d(t.$slots, "default")])) : n("", !0)
|
|
31
|
+
], 2));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
//#endregion
|
|
35
|
+
export { g as default };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, defineComponent as o, normalizeClass as s, normalizeStyle as c, openBlock as l, renderSlot as u, toDisplayString as d } from "vue";
|
|
2
|
+
//#region src/components/SwProgress.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
+
var f = ["aria-valuenow"], p = ["width", "height"], m = [
|
|
4
|
+
"cx",
|
|
5
|
+
"cy",
|
|
6
|
+
"r",
|
|
7
|
+
"stroke-width"
|
|
8
|
+
], h = [
|
|
9
|
+
"cx",
|
|
10
|
+
"cy",
|
|
11
|
+
"r",
|
|
12
|
+
"stroke-width",
|
|
13
|
+
"stroke-dasharray",
|
|
14
|
+
"stroke-dashoffset"
|
|
15
|
+
], g = {
|
|
16
|
+
key: 0,
|
|
17
|
+
class: "text"
|
|
18
|
+
}, _ = {
|
|
19
|
+
key: 0,
|
|
20
|
+
class: "text"
|
|
21
|
+
}, v = /* @__PURE__ */ o({
|
|
22
|
+
__name: "SwProgress",
|
|
23
|
+
props: {
|
|
24
|
+
class: { default: "" },
|
|
25
|
+
percentage: { default: 0 },
|
|
26
|
+
type: { default: "primary" },
|
|
27
|
+
circle: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: !1
|
|
30
|
+
},
|
|
31
|
+
width: { default: 120 },
|
|
32
|
+
strokeWidth: { default: 6 },
|
|
33
|
+
showText: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: !0
|
|
36
|
+
},
|
|
37
|
+
text: { default: "" },
|
|
38
|
+
indeterminate: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: !1
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
setup(o) {
|
|
44
|
+
let v = o, y = t(() => Math.min(100, Math.max(0, Number(v.percentage) || 0))), b = t(() => v.text === "" ? `${Math.round(y.value)}%` : v.text), x = t(() => {
|
|
45
|
+
let e = ["sw-progress"];
|
|
46
|
+
return v.circle && e.push("circle"), v.indeterminate && e.push("indeterminate"), v.type && e.push("sw-" + v.type), v.class && e.push(v.class), e;
|
|
47
|
+
}), S = t(() => ({ height: `${v.strokeWidth}px` })), C = t(() => v.indeterminate ? {} : { width: `${y.value}%` }), w = t(() => {
|
|
48
|
+
let e = (v.width - v.strokeWidth) / 2;
|
|
49
|
+
return Math.max(0, e);
|
|
50
|
+
}), T = t(() => 2 * Math.PI * w.value), E = t(() => T.value * (1 - y.value / 100)), D = t(() => ({
|
|
51
|
+
width: `${v.width}px`,
|
|
52
|
+
height: `${v.width}px`
|
|
53
|
+
}));
|
|
54
|
+
return (t, o) => (l(), r("div", {
|
|
55
|
+
class: s(x.value),
|
|
56
|
+
role: "progressbar",
|
|
57
|
+
"aria-valuenow": v.indeterminate ? void 0 : y.value,
|
|
58
|
+
"aria-valuemin": "0",
|
|
59
|
+
"aria-valuemax": "100"
|
|
60
|
+
}, [v.circle ? (l(), r("div", {
|
|
61
|
+
key: 0,
|
|
62
|
+
class: "circle-box",
|
|
63
|
+
style: c(D.value)
|
|
64
|
+
}, [(l(), r("svg", {
|
|
65
|
+
width: v.width,
|
|
66
|
+
height: v.width,
|
|
67
|
+
"aria-hidden": "true"
|
|
68
|
+
}, [i("circle", {
|
|
69
|
+
class: "track",
|
|
70
|
+
cx: v.width / 2,
|
|
71
|
+
cy: v.width / 2,
|
|
72
|
+
r: w.value,
|
|
73
|
+
fill: "none",
|
|
74
|
+
"stroke-width": v.strokeWidth
|
|
75
|
+
}, null, 8, m), i("circle", {
|
|
76
|
+
class: "fill",
|
|
77
|
+
cx: v.width / 2,
|
|
78
|
+
cy: v.width / 2,
|
|
79
|
+
r: w.value,
|
|
80
|
+
fill: "none",
|
|
81
|
+
"stroke-width": v.strokeWidth,
|
|
82
|
+
"stroke-dasharray": T.value,
|
|
83
|
+
"stroke-dashoffset": v.indeterminate ? void 0 : E.value,
|
|
84
|
+
"stroke-linecap": "round"
|
|
85
|
+
}, null, 8, h)], 8, p)), v.showText ? (l(), r("span", g, [u(t.$slots, "default", {}, () => [a(d(b.value), 1)])])) : n("", !0)], 4)) : (l(), r(e, { key: 1 }, [i("div", {
|
|
86
|
+
class: "bar",
|
|
87
|
+
style: c(S.value)
|
|
88
|
+
}, [i("div", {
|
|
89
|
+
class: "fill",
|
|
90
|
+
style: c(C.value)
|
|
91
|
+
}, null, 4)], 4), v.showText ? (l(), r("span", _, [u(t.$slots, "default", {}, () => [a(d(b.value), 1)])])) : n("", !0)], 64))], 10, f));
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
//#endregion
|
|
95
|
+
export { v as default };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { n as e } from "./SwIcon-BbL8Tu2z.js";
|
|
2
|
+
import { Fragment as t, computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, mergeModels as c, normalizeClass as l, openBlock as u, ref as d, renderList as f, toDisplayString as p, useModel as m } from "vue";
|
|
3
|
+
//#region src/components/SwRate.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var h = ["aria-disabled"], g = [
|
|
5
|
+
"aria-checked",
|
|
6
|
+
"aria-label",
|
|
7
|
+
"disabled",
|
|
8
|
+
"tabindex",
|
|
9
|
+
"onMousemove",
|
|
10
|
+
"onClick",
|
|
11
|
+
"onKeydown"
|
|
12
|
+
], _ = { class: "void" }, v = { class: "fill" }, y = {
|
|
13
|
+
key: 0,
|
|
14
|
+
class: "score"
|
|
15
|
+
}, b = "https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline", x = "https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/filled", S = /* @__PURE__ */ s({
|
|
16
|
+
__name: "SwRate",
|
|
17
|
+
props: /*@__PURE__*/ c({
|
|
18
|
+
class: { default: "" },
|
|
19
|
+
max: { default: 5 },
|
|
20
|
+
allowHalf: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: !1
|
|
23
|
+
},
|
|
24
|
+
disabled: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: !1
|
|
27
|
+
},
|
|
28
|
+
readonly: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: !1
|
|
31
|
+
},
|
|
32
|
+
clearable: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: !1
|
|
35
|
+
},
|
|
36
|
+
showScore: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: !1
|
|
39
|
+
},
|
|
40
|
+
size: { default: "" },
|
|
41
|
+
voidIcon: { default: "" },
|
|
42
|
+
icon: { default: "" }
|
|
43
|
+
}, {
|
|
44
|
+
modelValue: { default: 0 },
|
|
45
|
+
modelModifiers: {}
|
|
46
|
+
}),
|
|
47
|
+
emits: /*@__PURE__*/ c(["change"], ["update:modelValue"]),
|
|
48
|
+
setup(s, { emit: c }) {
|
|
49
|
+
let S = `${b}/star.svg`, C = `${x}/star.svg`, w = s, T = m(s, "modelValue"), E = c, D = d(null), O = n(() => w.disabled || w.readonly), k = n(() => D.value != null && !O.value ? D.value : T.value), A = n(() => {
|
|
50
|
+
let e = ["sw-rate"];
|
|
51
|
+
return w.size && e.push("sw-" + w.size), w.disabled && e.push("sw-disabled"), w.readonly && e.push("readonly"), w.class && e.push(w.class), e;
|
|
52
|
+
}), j = n(() => w.voidIcon || S), M = n(() => w.icon || C), N = n(() => Array.from({ length: w.max }, (e, t) => t + 1)), P = (e) => {
|
|
53
|
+
let t = k.value;
|
|
54
|
+
return t >= e ? "full" : w.allowHalf && t >= e - .5 ? "half" : "empty";
|
|
55
|
+
}, F = (e, t) => w.allowHalf && t ? e - .5 : e, I = (e) => {
|
|
56
|
+
if (O.value) return;
|
|
57
|
+
let t = e;
|
|
58
|
+
w.clearable && t === T.value && (t = 0), t !== T.value && (T.value = t, E("change", t));
|
|
59
|
+
}, L = (e, t) => {
|
|
60
|
+
if (O.value) return;
|
|
61
|
+
let n = t.currentTarget.getBoundingClientRect(), r = w.allowHalf && t.clientX - n.left < n.width / 2;
|
|
62
|
+
D.value = F(e, r);
|
|
63
|
+
}, R = () => {
|
|
64
|
+
D.value = null;
|
|
65
|
+
}, z = (e, t) => {
|
|
66
|
+
if (O.value) return;
|
|
67
|
+
let n = t.currentTarget.getBoundingClientRect(), r = w.allowHalf && t.clientX - n.left < n.width / 2;
|
|
68
|
+
I(F(e, r));
|
|
69
|
+
}, B = (e, t) => {
|
|
70
|
+
if (!O.value) {
|
|
71
|
+
if (t.key === "Enter" || t.key === " ") t.preventDefault(), I(e);
|
|
72
|
+
else if (t.key === "ArrowRight" || t.key === "ArrowUp") {
|
|
73
|
+
t.preventDefault();
|
|
74
|
+
let e = w.allowHalf ? .5 : 1;
|
|
75
|
+
I(Math.min(w.max, T.value + e));
|
|
76
|
+
} else if (t.key === "ArrowLeft" || t.key === "ArrowDown") {
|
|
77
|
+
t.preventDefault();
|
|
78
|
+
let e = w.allowHalf ? .5 : 1;
|
|
79
|
+
I(Math.max(0, T.value - e));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return (n, s) => (u(), i("div", {
|
|
84
|
+
class: l(A.value),
|
|
85
|
+
role: "radiogroup",
|
|
86
|
+
"aria-disabled": w.disabled || void 0,
|
|
87
|
+
onMouseleave: R
|
|
88
|
+
}, [(u(!0), i(t, null, f(N.value, (t) => (u(), i("button", {
|
|
89
|
+
key: t,
|
|
90
|
+
type: "button",
|
|
91
|
+
class: l(["star", P(t)]),
|
|
92
|
+
role: "radio",
|
|
93
|
+
"aria-checked": T.value >= t - (w.allowHalf ? .5 : 0),
|
|
94
|
+
"aria-label": `${t}`,
|
|
95
|
+
disabled: w.disabled,
|
|
96
|
+
tabindex: O.value ? -1 : 0,
|
|
97
|
+
onMousemove: (e) => L(t, e),
|
|
98
|
+
onClick: (e) => z(t, e),
|
|
99
|
+
onKeydown: (e) => B(t, e)
|
|
100
|
+
}, [a("span", _, [o(e, { "icon-class": j.value }, null, 8, ["icon-class"])]), a("span", v, [o(e, { "icon-class": M.value }, null, 8, ["icon-class"])])], 42, g))), 128)), w.showScore ? (u(), i("span", y, p(k.value), 1)) : r("", !0)], 42, h));
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
//#endregion
|
|
104
|
+
export { S as default };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { n as e } from "./SwIcon-BbL8Tu2z.js";
|
|
2
|
+
import { Fragment as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, defineComponent as s, mergeModels as c, normalizeClass as l, openBlock as u, renderList as d, toDisplayString as f, useModel as p } from "vue";
|
|
3
|
+
//#region src/components/SwSegmented.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var m = ["aria-disabled"], h = [
|
|
5
|
+
"aria-checked",
|
|
6
|
+
"disabled",
|
|
7
|
+
"tabindex",
|
|
8
|
+
"onClick",
|
|
9
|
+
"onKeydown"
|
|
10
|
+
], g = { class: "text" }, _ = /* @__PURE__ */ s({
|
|
11
|
+
__name: "SwSegmented",
|
|
12
|
+
props: /*@__PURE__*/ c({
|
|
13
|
+
class: { default: "" },
|
|
14
|
+
options: { default: () => [] },
|
|
15
|
+
size: { default: "" },
|
|
16
|
+
disabled: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: !1
|
|
19
|
+
},
|
|
20
|
+
block: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: !1
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
modelValue: { default: "" },
|
|
26
|
+
modelModifiers: {}
|
|
27
|
+
}),
|
|
28
|
+
emits: /*@__PURE__*/ c(["change"], ["update:modelValue"]),
|
|
29
|
+
setup(s, { emit: c }) {
|
|
30
|
+
let _ = s, v = p(s, "modelValue"), y = c, b = n(() => {
|
|
31
|
+
let e = ["sw-segmented"];
|
|
32
|
+
return _.size && e.push("sw-" + _.size), _.block && e.push("block"), _.disabled && e.push("sw-disabled"), _.class && e.push(_.class), e;
|
|
33
|
+
}), x = (e) => {
|
|
34
|
+
_.disabled || e.disabled || e.value !== v.value && (v.value = e.value, y("change", e.value));
|
|
35
|
+
}, S = (e, t, n) => {
|
|
36
|
+
if (_.disabled) return;
|
|
37
|
+
let r = _.options.map((e, t) => ({
|
|
38
|
+
o: e,
|
|
39
|
+
i: t
|
|
40
|
+
})).filter(({ o: e }) => !e.disabled);
|
|
41
|
+
if (!r.length) return;
|
|
42
|
+
let i = r.findIndex(({ i: e }) => e === t);
|
|
43
|
+
if (n.key === "ArrowRight" || n.key === "ArrowDown") {
|
|
44
|
+
n.preventDefault();
|
|
45
|
+
let e = r[(i + 1) % r.length];
|
|
46
|
+
x(e.o);
|
|
47
|
+
} else if (n.key === "ArrowLeft" || n.key === "ArrowUp") {
|
|
48
|
+
n.preventDefault();
|
|
49
|
+
let e = r[(i - 1 + r.length) % r.length];
|
|
50
|
+
x(e.o);
|
|
51
|
+
} else (n.key === "Enter" || n.key === " ") && (n.preventDefault(), x(e));
|
|
52
|
+
};
|
|
53
|
+
return (n, s) => (u(), a("div", {
|
|
54
|
+
class: l(b.value),
|
|
55
|
+
role: "radiogroup",
|
|
56
|
+
"aria-disabled": _.disabled || void 0
|
|
57
|
+
}, [(u(!0), a(t, null, d(_.options, (t, n) => (u(), a("button", {
|
|
58
|
+
key: `${t.value}-${n}`,
|
|
59
|
+
type: "button",
|
|
60
|
+
class: l(["item", { active: t.value === v.value }]),
|
|
61
|
+
role: "radio",
|
|
62
|
+
"aria-checked": t.value === v.value,
|
|
63
|
+
disabled: _.disabled || t.disabled,
|
|
64
|
+
tabindex: _.disabled || t.disabled ? -1 : t.value === v.value ? 0 : -1,
|
|
65
|
+
onClick: (e) => x(t),
|
|
66
|
+
onKeydown: (e) => S(t, n, e)
|
|
67
|
+
}, [t.before ? (u(), r(e, {
|
|
68
|
+
key: 0,
|
|
69
|
+
"icon-class": t.before
|
|
70
|
+
}, null, 8, ["icon-class"])) : i("", !0), o("span", g, f(t.label), 1)], 42, h))), 128))], 10, m));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
//#endregion
|
|
74
|
+
export { _ as default };
|
|
@@ -3,7 +3,8 @@ import { computed as e, createElementBlock as t, createElementVNode as n, define
|
|
|
3
3
|
var l = [
|
|
4
4
|
"name",
|
|
5
5
|
"id",
|
|
6
|
-
"checked"
|
|
6
|
+
"checked",
|
|
7
|
+
"disabled"
|
|
7
8
|
], u = [
|
|
8
9
|
"for",
|
|
9
10
|
"data-onlabel",
|
|
@@ -20,6 +21,10 @@ var l = [
|
|
|
20
21
|
checkbox: {
|
|
21
22
|
type: Boolean,
|
|
22
23
|
default: !1
|
|
24
|
+
},
|
|
25
|
+
disabled: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: !1
|
|
23
28
|
}
|
|
24
29
|
}, {
|
|
25
30
|
modelValue: { type: Boolean },
|
|
@@ -29,18 +34,19 @@ var l = [
|
|
|
29
34
|
setup(r) {
|
|
30
35
|
let i = c(r, "modelValue"), d = r, f = e(() => {
|
|
31
36
|
let e = ["sw-switch"];
|
|
32
|
-
return d.size.length > 0 && e.push("sw-" + d.size), d.checkbox && e.push("sw-checkbox"), d.class.length > 0 && e.push(d.class), e;
|
|
37
|
+
return d.size.length > 0 && e.push("sw-" + d.size), d.checkbox && e.push("sw-checkbox"), d.disabled && e.push("sw-disabled"), d.class.length > 0 && e.push(d.class), e;
|
|
33
38
|
}), p = (e) => {
|
|
34
39
|
let t = e.target;
|
|
35
40
|
i.value = t.checked;
|
|
36
41
|
};
|
|
37
|
-
return (e,
|
|
42
|
+
return (e, c) => (o(), t("div", { class: a(f.value) }, [
|
|
38
43
|
n("input", {
|
|
39
44
|
type: "checkbox",
|
|
40
45
|
name: d.name,
|
|
41
46
|
class: "sw-control",
|
|
42
47
|
id: d.id,
|
|
43
48
|
checked: i.value,
|
|
49
|
+
disabled: r.disabled,
|
|
44
50
|
onChange: p
|
|
45
51
|
}, null, 40, l),
|
|
46
52
|
n("label", {
|