@studio-west/component-sw 0.13.11 → 0.13.17

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.
@@ -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-C4RHAbK1.js";
2
- import { t } from "./SwButton-BfG2InPf.js";
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 = {
@@ -27,16 +27,20 @@ var x = { key: 0 }, S = {
27
27
  }),
28
28
  emits: ["update:modelValue"],
29
29
  setup(c) {
30
- let S = _(c, "modelValue"), C = c, w = n(() => C.after || C.iconAfter), T = p(null), E = v(), D = (e) => {
30
+ let S = _(c, "modelValue"), C = c, w = n(() => C.after || C.iconAfter), T = p(null), E = v(), D = p(""), O = () => {
31
+ D.value = document.body.style.overflow, document.body.style.overflow = "hidden";
32
+ }, k = () => {
33
+ document.body.style.overflow = D.value;
34
+ }, A = (e) => {
31
35
  if (T.value && S.value) {
32
36
  let t = T.value.getBoundingClientRect();
33
37
  e.clientX >= t.left && e.clientX <= t.right && e.clientY >= t.top && e.clientY <= t.bottom || (S.value = !1);
34
38
  }
35
39
  };
36
40
  return y(() => S.value, (e) => {
37
- e ? (T.value.showModal(), l(), window.addEventListener("click", D, !0)) : (T.value.close(), window.removeEventListener("click", D));
41
+ e ? (T.value.showModal(), O(), l(), window.addEventListener("click", A, !0)) : (T.value.close(), k(), window.removeEventListener("click", A));
38
42
  }), d(() => {
39
- window.removeEventListener("click", D);
43
+ k(), window.removeEventListener("click", A);
40
44
  }), (n, c) => (f(), i("dialog", {
41
45
  class: u("sw-message " + C.class),
42
46
  ref_key: "messageRef",
@@ -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 };