@studio-west/component-sw 0.13.16 → 0.13.18
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/LICENSE +12 -198
- package/README.md +160 -15
- package/dist/SwBadge-BOqWsTgl.js +43 -0
- package/dist/{SwButton-DBj7jzhd.js → SwButton-DpOGpsBS.js} +1 -1
- package/dist/SwDropdown-DpedC6Bn.js +177 -0
- package/dist/{SwDropdownItem-09XdzVHh.js → SwDropdownItem-DthBPUxn.js} +1 -1
- package/dist/{SwFile-BTNWhEX-.js → SwFile-DfeOYJQc.js} +2 -2
- package/dist/{SwGide-BScP5PoP.js → SwGide-BjQbQiBI.js} +3 -3
- package/dist/{SwIcon-Ce_Lj65y.js → SwIcon-B-HHyuxu.js} +1 -1
- package/dist/SwInput-BQXnoovf.js +163 -0
- package/dist/{SwMessage-BRYFF_qT.js → SwMessage-BghpMRWc.js} +2 -2
- package/dist/SwPagination-jTW9BD5P.js +121 -0
- package/dist/{SwSelect-Bo9kUY7P.js → SwSelect-DDNh3p6B.js} +588 -566
- package/dist/SwTag-DjZlthUS.js +51 -0
- package/dist/component-sw.css +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +14 -11
- package/package.json +7 -3
- package/types/index.d.ts +42 -0
- package/dist/SwDropdown-D5nIZEAM.js +0 -131
- package/dist/SwInput-D5cZvb4H.js +0 -104
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { Teleport as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, mergeModels as a, nextTick as o, normalizeClass as s, normalizeStyle as c, onMounted as l, onUnmounted as u, openBlock as d, ref as f, renderSlot as p, unref as m, useModel as h, watch as g, watchEffect as _, withModifiers as v } from "vue";
|
|
2
|
+
//#region src/components/SwDropdown.vue
|
|
3
|
+
var y = ["id"], b = {
|
|
4
|
+
__name: "SwDropdown",
|
|
5
|
+
props: /*@__PURE__*/ a({
|
|
6
|
+
class: {
|
|
7
|
+
type: String,
|
|
8
|
+
default: ""
|
|
9
|
+
},
|
|
10
|
+
size: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: ""
|
|
13
|
+
},
|
|
14
|
+
type: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: ""
|
|
17
|
+
},
|
|
18
|
+
trigger: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: "click"
|
|
21
|
+
},
|
|
22
|
+
placement: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: "bottom-left"
|
|
25
|
+
},
|
|
26
|
+
maxWidth: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: 0
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
modelValue: {},
|
|
32
|
+
modelModifiers: {}
|
|
33
|
+
}),
|
|
34
|
+
emits: ["update:modelValue"],
|
|
35
|
+
setup(a, { expose: b }) {
|
|
36
|
+
let x = a, S = h(a, "modelValue"), C = f(null), w = f(null), T = f({}), E = f(""), D = Math.ceil(Math.random() * 1e3), O = f(0), k = f(-1), A = t(() => {
|
|
37
|
+
let e = ["sw-dropdown"];
|
|
38
|
+
return x.size.length > 0 && e.push("sw-" + x.size), x.type.length > 0 && e.push("sw-" + x.type), e;
|
|
39
|
+
}), j = () => w.value ? [...w.value.querySelectorAll(".sw-dropdown-item")] : [], M = (e) => {
|
|
40
|
+
let t = j();
|
|
41
|
+
if (!t.length) return;
|
|
42
|
+
let n = (e % t.length + t.length) % t.length;
|
|
43
|
+
k.value = n, t.forEach((e, t) => {
|
|
44
|
+
e.classList.toggle("is-active", t === n), t === n && e.scrollIntoView({ block: "nearest" });
|
|
45
|
+
});
|
|
46
|
+
}, N = () => {
|
|
47
|
+
o(() => {
|
|
48
|
+
w.value && (w.value.focus({ preventScroll: !0 }), k.value = -1, j().forEach((e) => e.classList.remove("is-active")));
|
|
49
|
+
});
|
|
50
|
+
}, P = (e) => {
|
|
51
|
+
if (!S.value) return;
|
|
52
|
+
let t = j();
|
|
53
|
+
switch (e.key) {
|
|
54
|
+
case "Escape":
|
|
55
|
+
e.preventDefault(), e.stopPropagation(), S.value = !1, C.value?.querySelector("button, [tabindex], a, input")?.focus?.() || C.value?.focus?.();
|
|
56
|
+
break;
|
|
57
|
+
case "ArrowDown":
|
|
58
|
+
e.preventDefault(), M(k.value + 1);
|
|
59
|
+
break;
|
|
60
|
+
case "ArrowUp":
|
|
61
|
+
e.preventDefault(), M(k.value <= 0 ? t.length - 1 : k.value - 1);
|
|
62
|
+
break;
|
|
63
|
+
case "Home":
|
|
64
|
+
e.preventDefault(), M(0);
|
|
65
|
+
break;
|
|
66
|
+
case "End":
|
|
67
|
+
e.preventDefault(), M(t.length - 1);
|
|
68
|
+
break;
|
|
69
|
+
case "Enter":
|
|
70
|
+
case " ":
|
|
71
|
+
k.value >= 0 && t[k.value] && (e.preventDefault(), t[k.value].click());
|
|
72
|
+
break;
|
|
73
|
+
case "Tab":
|
|
74
|
+
S.value = !1;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
g(S, (e) => {
|
|
79
|
+
typeof document > "u" || (e ? N() : k.value = -1);
|
|
80
|
+
});
|
|
81
|
+
let F = new ResizeObserver(() => {
|
|
82
|
+
S.value && O.value++, O.value > 99 && (O.value = 1);
|
|
83
|
+
});
|
|
84
|
+
_(() => {
|
|
85
|
+
if (!S.value || !w.value || !C.value) return;
|
|
86
|
+
O.value < 2 && F.observe(w.value);
|
|
87
|
+
let e = window.pageYOffset || document.documentElement.scrollTop, t = window.pageXOffset || document.documentElement.scrollLeft;
|
|
88
|
+
document.body.style.position = "fixed", document.body.style.top = `-${e}px`, document.body.style.left = `-${t}px`, document.body.style.position = "", document.body.style.top = "", document.body.style.left = "", document.documentElement.scrollTop = e, document.documentElement.scrollLeft = t;
|
|
89
|
+
let n = C.value.getBoundingClientRect(), r = window.innerWidth, i = window.innerHeight, a = w.value.offsetHeight, o = w.value.offsetWidth, s = n.left + n.width / 2 + t, c = n.top + n.height / 2 + e, l = n.height / 2 + 8, [u, d] = x.placement.split("-", 2);
|
|
90
|
+
switch (u) {
|
|
91
|
+
case "bottom":
|
|
92
|
+
c = e + i - a - l - 8 < c ? c - l - a : c + l, d === void 0 && (s -= o / 2);
|
|
93
|
+
break;
|
|
94
|
+
case "top":
|
|
95
|
+
c = e + a + l + 8 > c ? c + l : c - l - a, d === void 0 && (s -= o / 2);
|
|
96
|
+
break;
|
|
97
|
+
case "left":
|
|
98
|
+
s - o - n.width / 2 - 8 < 0 ? s + n.width / 2 + 8 + o < r ? (s = s + n.width / 2 + 8, c -= a / 2) : (c = e + a + l + 8 > c ? c + l : c - l - a, s = s + n.width / 2 < r ? s + n.width / 2 - o : s - o / 2) : (s = s - o - n.width / 2 - 8, c -= a / 2);
|
|
99
|
+
break;
|
|
100
|
+
case "right":
|
|
101
|
+
s + n.width / 2 + 8 + o > r ? s - o - n.width / 2 - 8 > 0 ? (s = s - o - n.width / 2 - 8, c -= a / 2) : (c = e + a + l + 8 > c ? c + l : c - l - a, s -= n.width / 2) : (s = s + n.width / 2 + 8, c -= a / 2);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
switch (d) {
|
|
105
|
+
case "left":
|
|
106
|
+
s = t + r - 8 > s - n.width / 2 + o ? s - n.width / 2 : s - o + n.width / 2;
|
|
107
|
+
break;
|
|
108
|
+
case "right":
|
|
109
|
+
s = 8 < s + n.width / 2 - o ? s - o + n.width / 2 : s - n.width / 2;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
s < 0 && (s = 0), c < 0 && (c = 0);
|
|
113
|
+
let f = n.left + n.width / 2 + t, p = n.top + n.height / 2 + e, m = s + o / 2 - f, h = c + a / 2 - p, g;
|
|
114
|
+
g = Math.abs(h) >= Math.abs(m) ? h > 0 ? "top" : "bottom" : m > 0 ? "left" : "right";
|
|
115
|
+
let _ = g === "top" || g === "bottom" ? Math.max(12, Math.min(o - 12, f - s)) : Math.max(12, Math.min(a - 12, p - c));
|
|
116
|
+
E.value = `arrow-${g}`;
|
|
117
|
+
let v = 0;
|
|
118
|
+
for (let e = C.value; e && e !== document.documentElement; e = e.parentElement) {
|
|
119
|
+
let t = getComputedStyle(e).zIndex;
|
|
120
|
+
if (t === "auto") continue;
|
|
121
|
+
let n = Number.parseInt(t, 10);
|
|
122
|
+
if (!Number.isNaN(n)) {
|
|
123
|
+
v = n;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
T.value = {
|
|
128
|
+
position: "absolute",
|
|
129
|
+
top: `${c}px`,
|
|
130
|
+
left: `${s}px`,
|
|
131
|
+
maxWidth: x.maxWidth > 0 ? `${x.maxWidth}px` : "",
|
|
132
|
+
"--sw-dropdown-arrow": `${_}px`,
|
|
133
|
+
"--sw-z-index": String(v)
|
|
134
|
+
};
|
|
135
|
+
}, { flush: "post" });
|
|
136
|
+
let I = () => {
|
|
137
|
+
x.trigger === "click" && (S.value = !S.value);
|
|
138
|
+
}, L = () => {
|
|
139
|
+
x.trigger === "hover" && (S.value = !S.value);
|
|
140
|
+
}, R = () => {
|
|
141
|
+
x.trigger === "context" && (S.value = !S.value);
|
|
142
|
+
}, z = () => {
|
|
143
|
+
S.value && O.value++, O.value > 99 && (O.value = 1);
|
|
144
|
+
};
|
|
145
|
+
b({ handleResize: z });
|
|
146
|
+
let B = (e) => {
|
|
147
|
+
x.trigger !== "none" && !e.target.closest(`[id="${D}"]`) && C.value && !C.value.contains(e.target) && (S.value = !1);
|
|
148
|
+
}, V = (e) => {
|
|
149
|
+
e.key === "Escape" && S.value && (S.value = !1);
|
|
150
|
+
};
|
|
151
|
+
return l(() => {
|
|
152
|
+
typeof window > "u" || (window.addEventListener("resize", z), document.documentElement.ontouchstart === void 0 ? document.documentElement.addEventListener("click", B, !0) : document.documentElement.addEventListener("touchstart", B, !0), window.onscrollend === void 0 ? window.addEventListener("scroll", z) : window.addEventListener("scrollend", z), document.addEventListener("keydown", V));
|
|
153
|
+
}), u(() => {
|
|
154
|
+
F.disconnect(), !(typeof window > "u") && (window.removeEventListener("resize", z), document.documentElement.ontouchstart === void 0 ? document.documentElement.removeEventListener("click", B) : document.documentElement.removeEventListener("touchstart", B), window.onscrollend === void 0 ? window.removeEventListener("scroll", z) : window.removeEventListener("scrollend", z), document.removeEventListener("keydown", V));
|
|
155
|
+
}), (t, a) => (d(), i("div", {
|
|
156
|
+
class: s(A.value),
|
|
157
|
+
onClick: a[0] ||= (e) => I(),
|
|
158
|
+
onMouseover: a[1] ||= v((e) => L(), ["stop"]),
|
|
159
|
+
onMouseleave: a[2] ||= v((e) => L(), ["stop"]),
|
|
160
|
+
onContextmenu: a[3] ||= v((e) => R(), ["stop"]),
|
|
161
|
+
ref_key: "dropdownRef",
|
|
162
|
+
ref: C
|
|
163
|
+
}, [p(t.$slots, "default"), (d(), n(e, { to: "body" }, [S.value ? (d(), i("ul", {
|
|
164
|
+
key: 0,
|
|
165
|
+
ref_key: "popupRef",
|
|
166
|
+
ref: w,
|
|
167
|
+
id: m(D),
|
|
168
|
+
class: s(["sw-dropdown-popup", [x.class, E.value]]),
|
|
169
|
+
style: c(T.value),
|
|
170
|
+
tabindex: "-1",
|
|
171
|
+
role: "menu",
|
|
172
|
+
onKeydown: P
|
|
173
|
+
}, [p(t.$slots, "dropdown")], 46, y)) : r("", !0)]))], 34));
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
//#endregion
|
|
177
|
+
export { b as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e } from "./SwIcon-
|
|
1
|
+
import { n as e } from "./SwIcon-B-HHyuxu.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-B-HHyuxu.js";
|
|
2
|
+
import { t } from "./SwButton-DpOGpsBS.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,7 +1,7 @@
|
|
|
1
1
|
import { i as e } from "./utils-qzwUfWRX.js";
|
|
2
|
-
import { n as t } from "./SwIcon-
|
|
3
|
-
import { t as n } from "./SwButton-
|
|
4
|
-
import r from "./SwDropdown-
|
|
2
|
+
import { n as t } from "./SwIcon-B-HHyuxu.js";
|
|
3
|
+
import { t as n } from "./SwButton-DpOGpsBS.js";
|
|
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
6
|
//#region src/components/SwGide.vue
|
|
7
7
|
var y = ["src"], b = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as e } from "./utils-qzwUfWRX.js";
|
|
2
|
-
import { t } from "./SwSelect-
|
|
2
|
+
import { t } from "./SwSelect-DDNh3p6B.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 }, {
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { n as e } from "./utils-qzwUfWRX.js";
|
|
2
|
+
import { n as t } from "./SwIcon-B-HHyuxu.js";
|
|
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
|
+
//#region src/components/SwInput.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var S = ["for"], C = {
|
|
6
|
+
key: 0,
|
|
7
|
+
title: "Это поле обязательно для заполнения."
|
|
8
|
+
}, w = [
|
|
9
|
+
"required",
|
|
10
|
+
"placeholder",
|
|
11
|
+
"id",
|
|
12
|
+
"name",
|
|
13
|
+
"rows",
|
|
14
|
+
"maxlength",
|
|
15
|
+
"minlength",
|
|
16
|
+
"autofocus"
|
|
17
|
+
], T = [
|
|
18
|
+
"required",
|
|
19
|
+
"placeholder",
|
|
20
|
+
"type",
|
|
21
|
+
"inputmode",
|
|
22
|
+
"id",
|
|
23
|
+
"name",
|
|
24
|
+
"size",
|
|
25
|
+
"maxlength",
|
|
26
|
+
"minlength",
|
|
27
|
+
"autofocus"
|
|
28
|
+
], E = "https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline", D = /* @__PURE__ */ s({
|
|
29
|
+
__name: "SwInput",
|
|
30
|
+
props: /*@__PURE__*/ c({
|
|
31
|
+
before: { default: "" },
|
|
32
|
+
after: { default: "" },
|
|
33
|
+
placeholder: { default: "" },
|
|
34
|
+
label: { default: "" },
|
|
35
|
+
name: {},
|
|
36
|
+
class: { default: "" },
|
|
37
|
+
size: { default: "" },
|
|
38
|
+
type: { default: "text" },
|
|
39
|
+
inputMode: { default: "text" },
|
|
40
|
+
required: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: !1
|
|
43
|
+
},
|
|
44
|
+
maxlength: { default: 128 },
|
|
45
|
+
minlength: { default: 1 },
|
|
46
|
+
inputSize: { default: 60 },
|
|
47
|
+
autofocus: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: !1
|
|
50
|
+
},
|
|
51
|
+
clearable: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: !1
|
|
54
|
+
},
|
|
55
|
+
rows: { default: 3 }
|
|
56
|
+
}, {
|
|
57
|
+
modelValue: {},
|
|
58
|
+
modelModifiers: {}
|
|
59
|
+
}),
|
|
60
|
+
emits: /*@__PURE__*/ c([
|
|
61
|
+
"suffix",
|
|
62
|
+
"prefix",
|
|
63
|
+
"focusInput",
|
|
64
|
+
"clear"
|
|
65
|
+
], ["update:modelValue"]),
|
|
66
|
+
setup(s, { emit: c }) {
|
|
67
|
+
let D = `${E}/x.svg`, O = `${E}/eye.svg`, k = `${E}/eye-off.svg`, A = g(s, "modelValue"), j = s, M = c, N = p(!1), P = p(!1), F = p(null), I = n(() => j.type === "textarea"), L = n(() => j.type === "password"), R = n(() => (A.value?.length ?? 0) > 0), z = n(() => j.clearable && R.value), B = n(() => L.value ? P.value ? "text" : "password" : j.type === "phone" ? "text" : j.type), V = n(() => {
|
|
68
|
+
let e = ["sw-input"];
|
|
69
|
+
return j.size.length > 0 && e.push("sw-" + j.size), j.class.length > 0 && e.push(j.class), I.value && e.push("textarea"), (N.value || R.value) && e.push("sw-input--active"), e;
|
|
70
|
+
}), H = n(() => j.required && j.label.length === 0 ? `${j.placeholder}*` : j.placeholder), U = (e) => {
|
|
71
|
+
N.value = !0, M("focusInput");
|
|
72
|
+
let t = e.target;
|
|
73
|
+
if ("setSelectionRange" in t && !I.value) {
|
|
74
|
+
let e = A.value?.length || 0;
|
|
75
|
+
try {
|
|
76
|
+
t.setSelectionRange(e, e);
|
|
77
|
+
} catch {}
|
|
78
|
+
}
|
|
79
|
+
}, W = () => {
|
|
80
|
+
N.value = !1;
|
|
81
|
+
}, G = () => {
|
|
82
|
+
M("suffix");
|
|
83
|
+
}, K = () => {
|
|
84
|
+
M("prefix");
|
|
85
|
+
}, q = () => {
|
|
86
|
+
A.value = "", M("clear"), u(() => F.value?.focus());
|
|
87
|
+
}, J = () => {
|
|
88
|
+
P.value = !P.value, u(() => F.value?.focus());
|
|
89
|
+
}, Y = (t, n) => {
|
|
90
|
+
if (j.type !== "phone" || t == null) return;
|
|
91
|
+
let r = e(t, n);
|
|
92
|
+
r !== t && (A.value = r);
|
|
93
|
+
};
|
|
94
|
+
return y(A, (e, t) => {
|
|
95
|
+
Y(e, t);
|
|
96
|
+
}), (e, n) => (f(), a("div", { class: d(V.value) }, [
|
|
97
|
+
j.before.length > 0 ? (f(), r(t, {
|
|
98
|
+
key: 0,
|
|
99
|
+
"icon-class": j.before,
|
|
100
|
+
onClick: K
|
|
101
|
+
}, null, 8, ["icon-class"])) : m(e.$slots, "prefix", {}, void 0, void 0, 1),
|
|
102
|
+
j.label.length > 0 ? (f(), a("label", {
|
|
103
|
+
key: 2,
|
|
104
|
+
for: j.name
|
|
105
|
+
}, [o(h(j.label), 1), j.required ? (f(), a("span", C, "*")) : i("", !0)], 8, S)) : i("", !0),
|
|
106
|
+
I.value ? b((f(), a("textarea", l({
|
|
107
|
+
key: 3,
|
|
108
|
+
ref_key: "fieldRef",
|
|
109
|
+
ref: F,
|
|
110
|
+
"onUpdate:modelValue": n[0] ||= (e) => A.value = e,
|
|
111
|
+
required: j.required,
|
|
112
|
+
placeholder: H.value,
|
|
113
|
+
id: j.name,
|
|
114
|
+
name: j.name,
|
|
115
|
+
rows: j.rows,
|
|
116
|
+
maxlength: j.maxlength,
|
|
117
|
+
minlength: j.minlength,
|
|
118
|
+
autofocus: j.autofocus
|
|
119
|
+
}, e.$attrs, {
|
|
120
|
+
onFocus: U,
|
|
121
|
+
onBlur: W
|
|
122
|
+
}), null, 16, w)), [[v, A.value]]) : b((f(), a("input", l({
|
|
123
|
+
key: 4,
|
|
124
|
+
ref_key: "fieldRef",
|
|
125
|
+
ref: F,
|
|
126
|
+
"onUpdate:modelValue": n[1] ||= (e) => A.value = e,
|
|
127
|
+
required: j.required,
|
|
128
|
+
placeholder: H.value,
|
|
129
|
+
type: B.value,
|
|
130
|
+
inputmode: j.inputMode,
|
|
131
|
+
id: j.name,
|
|
132
|
+
name: j.name,
|
|
133
|
+
size: j.inputSize,
|
|
134
|
+
maxlength: j.maxlength,
|
|
135
|
+
minlength: j.minlength,
|
|
136
|
+
autofocus: j.autofocus,
|
|
137
|
+
autocomplete: "off"
|
|
138
|
+
}, e.$attrs, {
|
|
139
|
+
onFocus: U,
|
|
140
|
+
onBlur: W
|
|
141
|
+
}), null, 16, T)), [[_, A.value]]),
|
|
142
|
+
z.value ? (f(), r(t, {
|
|
143
|
+
key: 5,
|
|
144
|
+
class: "sw-input-action",
|
|
145
|
+
"icon-class": D,
|
|
146
|
+
onClick: x(q, ["stop"])
|
|
147
|
+
})) : i("", !0),
|
|
148
|
+
L.value ? (f(), r(t, {
|
|
149
|
+
key: 6,
|
|
150
|
+
class: "sw-input-action",
|
|
151
|
+
"icon-class": P.value ? k : O,
|
|
152
|
+
onClick: x(J, ["stop"])
|
|
153
|
+
}, null, 8, ["icon-class"])) : i("", !0),
|
|
154
|
+
j.after.length > 0 ? (f(), r(t, {
|
|
155
|
+
key: 7,
|
|
156
|
+
"icon-class": j.after,
|
|
157
|
+
onClick: G
|
|
158
|
+
}, null, 8, ["icon-class"])) : m(e.$slots, "suffix", {}, void 0, void 0, 8)
|
|
159
|
+
], 2));
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
//#endregion
|
|
163
|
+
export { D as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as e } from "./SwIcon-
|
|
2
|
-
import { t } from "./SwButton-
|
|
1
|
+
import { n as e } from "./SwIcon-B-HHyuxu.js";
|
|
2
|
+
import { t } from "./SwButton-DpOGpsBS.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,121 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, defineComponent as a, mergeModels as o, normalizeClass as s, openBlock as c, renderList as l, toDisplayString as u, useModel as d, watch as f } from "vue";
|
|
2
|
+
//#region src/components/SwPagination.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
+
var p = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "total"
|
|
6
|
+
}, m = {
|
|
7
|
+
key: 1,
|
|
8
|
+
class: "sizes"
|
|
9
|
+
}, h = ["value", "disabled"], g = ["value"], _ = ["disabled"], v = [
|
|
10
|
+
"disabled",
|
|
11
|
+
"aria-current",
|
|
12
|
+
"onClick"
|
|
13
|
+
], y = ["disabled"], b = /* @__PURE__ */ a({
|
|
14
|
+
__name: "SwPagination",
|
|
15
|
+
props: /*@__PURE__*/ o({
|
|
16
|
+
class: { default: "" },
|
|
17
|
+
size: { default: "" },
|
|
18
|
+
total: { default: 0 },
|
|
19
|
+
pagerCount: { default: 7 },
|
|
20
|
+
disabled: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: !1
|
|
23
|
+
},
|
|
24
|
+
showTotal: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: !1
|
|
27
|
+
},
|
|
28
|
+
showSize: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: !0
|
|
31
|
+
},
|
|
32
|
+
pageSizes: { default: () => [
|
|
33
|
+
10,
|
|
34
|
+
20,
|
|
35
|
+
50,
|
|
36
|
+
100
|
|
37
|
+
] }
|
|
38
|
+
}, {
|
|
39
|
+
modelValue: { default: 1 },
|
|
40
|
+
modelModifiers: {},
|
|
41
|
+
pageSize: { default: 10 },
|
|
42
|
+
pageSizeModifiers: {}
|
|
43
|
+
}),
|
|
44
|
+
emits: /*@__PURE__*/ o(["change", "size-change"], ["update:modelValue", "update:pageSize"]),
|
|
45
|
+
setup(a, { emit: o }) {
|
|
46
|
+
let b = a, x = d(a, "modelValue"), S = d(a, "pageSize"), C = o, w = t(() => Math.max(1, Math.ceil(b.total / Math.max(1, S.value)))), T = t(() => {
|
|
47
|
+
let e = [...b.pageSizes];
|
|
48
|
+
return e.includes(S.value) || e.unshift(S.value), e.sort((e, t) => e - t);
|
|
49
|
+
}), E = t(() => {
|
|
50
|
+
let e = b.pagerCount < 5 ? 5 : b.pagerCount;
|
|
51
|
+
return e % 2 == 0 ? e + 1 : e;
|
|
52
|
+
}), D = t(() => {
|
|
53
|
+
let e = w.value, t = Math.min(Math.max(1, x.value), e), n = E.value;
|
|
54
|
+
if (e <= n) return Array.from({ length: e }, (e, t) => t + 1);
|
|
55
|
+
let r = Math.floor(n / 2), i = Math.max(2, t - r + 1), a = Math.min(e - 1, t + r - 1);
|
|
56
|
+
t - 1 <= r && (i = 2, a = n - 2), e - t <= r && (i = e - (n - 3), a = e - 1);
|
|
57
|
+
let o = [1];
|
|
58
|
+
i > 2 && o.push("…");
|
|
59
|
+
for (let e = i; e <= a; e++) o.push(e);
|
|
60
|
+
return a < e - 1 && o.push("…"), o.push(e), o;
|
|
61
|
+
}), O = t(() => {
|
|
62
|
+
let e = ["sw-pagination"];
|
|
63
|
+
return b.size && e.push("sw-" + b.size), b.disabled && e.push("sw-disabled"), b.class && e.push(b.class), e;
|
|
64
|
+
}), k = (e) => {
|
|
65
|
+
if (b.disabled) return;
|
|
66
|
+
let t = Math.min(Math.max(1, e), w.value);
|
|
67
|
+
t !== x.value && (x.value = t, C("change", t));
|
|
68
|
+
}, A = (e) => {
|
|
69
|
+
if (b.disabled) return;
|
|
70
|
+
let t = Number(e.target.value);
|
|
71
|
+
if (!Number.isFinite(t) || t < 1 || t === S.value) return;
|
|
72
|
+
S.value = t, C("size-change", t);
|
|
73
|
+
let n = Math.max(1, Math.ceil(b.total / t));
|
|
74
|
+
x.value > n ? k(n) : x.value < 1 && k(1);
|
|
75
|
+
};
|
|
76
|
+
return f(w, (e) => {
|
|
77
|
+
x.value > e && (x.value = e);
|
|
78
|
+
}), (t, a) => (c(), r("nav", {
|
|
79
|
+
class: s(O.value),
|
|
80
|
+
"aria-label": "pagination"
|
|
81
|
+
}, [
|
|
82
|
+
b.showTotal ? (c(), r("span", p, "Всего " + u(b.total), 1)) : n("", !0),
|
|
83
|
+
b.showSize ? (c(), r("label", m, [i("select", {
|
|
84
|
+
value: S.value,
|
|
85
|
+
disabled: b.disabled,
|
|
86
|
+
"aria-label": "page size",
|
|
87
|
+
onChange: A
|
|
88
|
+
}, [(c(!0), r(e, null, l(T.value, (e) => (c(), r("option", {
|
|
89
|
+
key: e,
|
|
90
|
+
value: e
|
|
91
|
+
}, u(e) + " / стр.", 9, g))), 128))], 40, h)])) : n("", !0),
|
|
92
|
+
i("button", {
|
|
93
|
+
type: "button",
|
|
94
|
+
class: "btn",
|
|
95
|
+
"aria-label": "previous",
|
|
96
|
+
disabled: b.disabled || x.value <= 1,
|
|
97
|
+
onClick: a[0] ||= (e) => k(x.value - 1)
|
|
98
|
+
}, " ‹ ", 8, _),
|
|
99
|
+
(c(!0), r(e, null, l(D.value, (e, t) => (c(), r("button", {
|
|
100
|
+
key: `${e}-${t}`,
|
|
101
|
+
type: "button",
|
|
102
|
+
class: s(["btn", {
|
|
103
|
+
active: e === x.value,
|
|
104
|
+
more: e === "…"
|
|
105
|
+
}]),
|
|
106
|
+
disabled: b.disabled || e === "…",
|
|
107
|
+
"aria-current": e === x.value ? "page" : void 0,
|
|
108
|
+
onClick: (t) => e !== "…" && k(e)
|
|
109
|
+
}, u(e), 11, v))), 128)),
|
|
110
|
+
i("button", {
|
|
111
|
+
type: "button",
|
|
112
|
+
class: "btn",
|
|
113
|
+
"aria-label": "next",
|
|
114
|
+
disabled: b.disabled || x.value >= w.value,
|
|
115
|
+
onClick: a[1] ||= (e) => k(x.value + 1)
|
|
116
|
+
}, " › ", 8, y)
|
|
117
|
+
], 2));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
//#endregion
|
|
121
|
+
export { b as default };
|