@studio-west/component-sw 0.8.8 → 0.9.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.
@@ -1,9 +1,9 @@
1
- import { mergeModels as y, useModel as w, ref as D, computed as V, watch as C, createElementBlock as d, openBlock as s, normalizeClass as I, createBlock as v, renderSlot as _, createCommentVNode as x, withDirectives as A, createTextVNode as E, toDisplayString as R, createElementVNode as T, vModelDynamic as F } from "vue";
2
- import { S } from "./index-BU4MvzL6.js";
1
+ import { mergeModels as y, useModel as w, ref as D, computed as V, watch as C, createElementBlock as d, openBlock as u, normalizeClass as A, createBlock as _, renderSlot as v, createCommentVNode as x, withDirectives as E, createTextVNode as I, toDisplayString as R, createElementVNode as T, vModelDynamic as F } from "vue";
2
+ import { _ as k } from "./index-BqSnlKYz.js";
3
3
  const O = ["for"], U = {
4
4
  key: 0,
5
5
  title: "Это поле обязательно для заполнения."
6
- }, j = ["required", "placeholder", "type", "id", "name", "size", "maxlength", "minlength", "autofocus", "readonly", "inputmode"], J = {
6
+ }, j = ["required", "placeholder", "type", "id", "name", "size", "maxlength", "minlength", "autofocus", "readonly", "inputmode", "spellcheck"], J = {
7
7
  __name: "SwInput",
8
8
  props: /* @__PURE__ */ y({
9
9
  before: { type: String, default: "" },
@@ -20,7 +20,8 @@ const O = ["for"], U = {
20
20
  minlength: { type: Number, default: 1 },
21
21
  inputSize: { type: Number, default: 60 },
22
22
  autofocus: { type: Boolean, default: !1 },
23
- readonly: { type: Boolean, default: !1 }
23
+ readonly: { type: Boolean, default: !1 },
24
+ spellcheck: { type: Boolean, default: !1 }
24
25
  }, {
25
26
  modelValue: {},
26
27
  modelModifiers: {}
@@ -28,18 +29,18 @@ const O = ["for"], U = {
28
29
  emits: /* @__PURE__ */ y(["suffix", "prefix", "focusInput"], ["update:modelValue"]),
29
30
  setup(m, { emit: b }) {
30
31
  var g;
31
- const o = w(m, "modelValue"), e = m, r = D(null), i = b, k = (t) => {
32
+ const o = w(m, "modelValue"), e = m, r = D(null), i = b, S = (t) => {
32
33
  i("focusInput"), t.target.setSelectionRange(o.value.length, o.value.length), r.value !== null && (r.value.style.top = "-.6em");
33
- }, z = (t) => {
34
+ }, $ = (t) => {
34
35
  var l;
35
36
  ((l = o.value) == null ? void 0 : l.length) === 0 && r.value !== null && r.value.removeAttribute("style");
36
37
  };
37
38
  ((g = o.value) == null ? void 0 : g.length) > 0 && r.value !== null && (r.value.style.top = "-.6em");
38
- const $ = () => {
39
+ const z = () => {
39
40
  i("suffix");
40
- }, q = () => {
41
+ }, B = () => {
41
42
  i("prefix");
42
- }, B = V(
43
+ }, q = V(
43
44
  () => {
44
45
  let t = ["sw-input"];
45
46
  return e.size.length > 0 && t.push("sw-" + e.size), e.class.length > 0 && t.push(e.class), t;
@@ -55,32 +56,32 @@ const O = ["for"], U = {
55
56
  const c = "+0 (___) ___-__-__";
56
57
  let a = 0;
57
58
  const N = c.replace(/\D/g, ""), h = n.replace(/\D/g, "");
58
- let u = c.replace(/[_\d]/g, (f) => a < h.length ? h.charAt(a++) || N.charAt(a) : f);
59
- a = u.indexOf("_"), a !== -1 && (a = a < 5 ? 3 : a, u = u.slice(0, a));
59
+ let s = c.replace(/[_\d]/g, (f) => a < h.length ? h.charAt(a++) || N.charAt(a) : f);
60
+ a = s.indexOf("_"), a !== -1 && (a = a < 5 ? 3 : a, s = s.slice(0, a));
60
61
  let p = c.slice(0, n.length).replace(
61
62
  /_+/g,
62
63
  (f) => `\\d{1,${f.length}}`
63
64
  ).replace(/[+()]/g, "\\$&");
64
- if (p = new RegExp(`^${p}$`), u = u.replace(/[-—]$|(\) )$/g, ""), !p.test(n) || n.length < 5) return u;
65
+ if (p = new RegExp(`^${p}$`), s = s.replace(/[-—]$|(\) )$/g, ""), !p.test(n) || n.length < 5) return s;
65
66
  };
66
- return (t, l) => (s(), d("div", {
67
- class: I(B.value)
67
+ return (t, l) => (u(), d("div", {
68
+ class: A(q.value)
68
69
  }, [
69
- e.before.length > 0 ? (s(), v(S, {
70
+ e.before.length > 0 ? (u(), _(k, {
70
71
  key: 0,
71
72
  "icon-class": e.before,
72
- onClick: q
73
- }, null, 8, ["icon-class"])) : _(t.$slots, "prefix", { key: 1 }),
74
- e.label.length > 0 ? (s(), d("label", {
73
+ onClick: B
74
+ }, null, 8, ["icon-class"])) : v(t.$slots, "prefix", { key: 1 }),
75
+ e.label.length > 0 ? (u(), d("label", {
75
76
  key: 2,
76
77
  for: e.name,
77
78
  ref_key: "lab",
78
79
  ref: r
79
80
  }, [
80
- E(R(e.label), 1),
81
- e.required ? (s(), d("span", U, "*")) : x("", !0)
81
+ I(R(e.label), 1),
82
+ e.required ? (u(), d("span", U, "*")) : x("", !0)
82
83
  ], 8, O)) : x("", !0),
83
- A(T("input", {
84
+ E(T("input", {
84
85
  "onUpdate:modelValue": l[0] || (l[0] = (n) => o.value = n),
85
86
  required: e.required,
86
87
  placeholder: e.required && e.label.length === 0 ? e.placeholder + "*" : e.placeholder,
@@ -88,21 +89,22 @@ const O = ["for"], U = {
88
89
  id: e.name,
89
90
  name: e.name,
90
91
  size: e.inputSize,
91
- onFocus: k,
92
- onBlur: z,
92
+ onFocus: S,
93
+ onBlur: $,
93
94
  maxlength: e.maxlength,
94
95
  minlength: e.minlength,
95
96
  autofocus: e.autofocus,
96
97
  readonly: e.readonly,
97
- inputmode: e.inputMode
98
+ inputmode: e.inputMode,
99
+ spellcheck: e.spellcheck
98
100
  }, null, 40, j), [
99
101
  [F, o.value]
100
102
  ]),
101
- e.after.length > 0 ? (s(), v(S, {
103
+ e.after.length > 0 ? (u(), _(k, {
102
104
  key: 3,
103
105
  "icon-class": e.after,
104
- onClick: $
105
- }, null, 8, ["icon-class"])) : _(t.$slots, "suffix", { key: 4 })
106
+ onClick: z
107
+ }, null, 8, ["icon-class"])) : v(t.$slots, "suffix", { key: 4 })
106
108
  ], 2));
107
109
  }
108
110
  };
@@ -0,0 +1,58 @@
1
+ import { mergeModels as f, useModel as p, ref as g, useSlots as v, watch as k, nextTick as w, onUnmounted as _, createElementBlock as c, openBlock as d, normalizeClass as y, createCommentVNode as h, renderSlot as n, createElementVNode as S, unref as V, createTextVNode as $, createVNode as m, toDisplayString as C, withCtx as E } from "vue";
2
+ import M from "./SwButton-85-tKHA7.js";
3
+ import { _ as N } from "./index-BqSnlKYz.js";
4
+ const L = ["open"], x = { key: 0 }, z = {
5
+ __name: "SwMessage",
6
+ props: /* @__PURE__ */ f({
7
+ name: { type: String, default: "" },
8
+ class: { type: String, default: "" },
9
+ iconAfter: { type: String, default: "" }
10
+ }, {
11
+ modelValue: {},
12
+ modelModifiers: {}
13
+ }),
14
+ emits: ["update:modelValue"],
15
+ setup(a) {
16
+ const t = p(a, "modelValue"), o = a, s = g(null), u = v(), l = (e) => {
17
+ s.value && !s.value.contains(e.target) && (t.value = !1);
18
+ };
19
+ return k(() => t.value, async (e) => {
20
+ e ? (await w(), window.addEventListener("click", l, !0)) : window.removeEventListener("click", l);
21
+ }), _(() => {
22
+ window.removeEventListener("click", l);
23
+ }), (e, r) => {
24
+ var i;
25
+ return d(), c("dialog", {
26
+ open: t.value,
27
+ class: y(["sw-message", o.class]),
28
+ ref_key: "messageRef",
29
+ ref: s
30
+ }, [
31
+ o.name.length > 0 || (i = V(u)) != null && i.header ? (d(), c("header", x, [
32
+ n(e.$slots, "header", {}, () => [
33
+ $(C(o.name) + " ", 1),
34
+ m(M, {
35
+ link: "",
36
+ type: "primary",
37
+ onClick: r[0] || (r[0] = (A) => t.value = !1)
38
+ }, {
39
+ default: E(() => [
40
+ m(N, {
41
+ "icon-class": o.iconAfter
42
+ }, null, 8, ["icon-class"])
43
+ ]),
44
+ _: 1
45
+ })
46
+ ])
47
+ ])) : h("", !0),
48
+ n(e.$slots, "default"),
49
+ S("footer", null, [
50
+ n(e.$slots, "footer")
51
+ ])
52
+ ], 10, L);
53
+ };
54
+ }
55
+ };
56
+ export {
57
+ z as default
58
+ };
@@ -0,0 +1,58 @@
1
+ import { mergeModels as m, useModel as c, ref as f, useSlots as v, watch as h, nextTick as y, createElementBlock as i, openBlock as p, normalizeClass as _, createCommentVNode as g, renderSlot as r, createElementVNode as S, unref as k, createTextVNode as P, createVNode as d, toDisplayString as V, withCtx as $ } from "vue";
2
+ import w from "./SwButton-85-tKHA7.js";
3
+ import { _ as C } from "./index-BqSnlKYz.js";
4
+ const N = ["id", "open", "popover"], M = { key: 0 }, T = {
5
+ __name: "SwPopover",
6
+ props: /* @__PURE__ */ m({
7
+ popover: { type: String, default: "auto" },
8
+ name: { type: String, default: "" },
9
+ class: { type: String, default: "" },
10
+ iconAfter: { type: String, default: "" },
11
+ id: { type: String, default: "Popover" }
12
+ }, {
13
+ modelValue: {},
14
+ modelModifiers: {}
15
+ }),
16
+ emits: ["update:modelValue"],
17
+ setup(l) {
18
+ const s = c(l, "modelValue"), e = l, t = f(null), u = v();
19
+ return h(() => s.value, (o) => {
20
+ o ? y(() => t.value.showPopover()) : t.value.hidePopover();
21
+ }), (o, a) => {
22
+ var n;
23
+ return p(), i("dialog", {
24
+ id: e.id,
25
+ open: s.value,
26
+ popover: e.popover,
27
+ class: _("sw-popover" + e.class),
28
+ ref_key: "Popover",
29
+ ref: t
30
+ }, [
31
+ e.name.length > 0 || (n = k(u)) != null && n.header ? (p(), i("header", M, [
32
+ r(o.$slots, "header", {}, () => [
33
+ P(V(e.name) + " ", 1),
34
+ d(w, {
35
+ link: "",
36
+ type: "primary",
37
+ onClick: a[0] || (a[0] = (x) => t.value.hidePopover())
38
+ }, {
39
+ default: $(() => [
40
+ d(C, {
41
+ "icon-class": e.iconAfter
42
+ }, null, 8, ["icon-class"])
43
+ ]),
44
+ _: 1
45
+ })
46
+ ])
47
+ ])) : g("", !0),
48
+ r(o.$slots, "default"),
49
+ S("footer", null, [
50
+ r(o.$slots, "footer")
51
+ ])
52
+ ], 10, N);
53
+ };
54
+ }
55
+ };
56
+ export {
57
+ T as default
58
+ };
@@ -0,0 +1,55 @@
1
+ import { createElementBlock as m, openBlock as s, normalizeStyle as o, createElementVNode as u, toDisplayString as r } from "vue";
2
+ const c = ["min", "max", "step", "value"], p = { class: "slider__value" }, y = {
3
+ __name: "SwSlider",
4
+ props: {
5
+ modelValue: {
6
+ type: Number,
7
+ required: !0
8
+ },
9
+ min: {
10
+ type: Number,
11
+ default: 0
12
+ },
13
+ max: {
14
+ type: Number,
15
+ default: 100
16
+ },
17
+ step: {
18
+ type: Number,
19
+ default: 1
20
+ },
21
+ width: {
22
+ type: String,
23
+ default: "300px"
24
+ }
25
+ },
26
+ emits: ["update:modelValue"],
27
+ setup(e, { emit: n }) {
28
+ const l = n, d = (t) => {
29
+ const a = parseFloat(t.target.value);
30
+ l("update:modelValue", a);
31
+ }, i = (t) => {
32
+ const a = parseFloat(t.target.value);
33
+ l("update:modelValue", a);
34
+ };
35
+ return (t, a) => (s(), m("div", {
36
+ class: "slider",
37
+ style: o({ "--slider-width": e.width })
38
+ }, [
39
+ u("input", {
40
+ type: "range",
41
+ class: "slider__input",
42
+ min: e.min,
43
+ max: e.max,
44
+ step: e.step,
45
+ value: e.modelValue,
46
+ onInput: d,
47
+ onChange: i
48
+ }, null, 40, c),
49
+ u("div", p, r(e.modelValue), 1)
50
+ ], 4));
51
+ }
52
+ };
53
+ export {
54
+ y as default
55
+ };
@@ -0,0 +1,165 @@
1
+ import { createElementBlock as d, unref as D, openBlock as u, mergeProps as w, createElementVNode as b, ref as $, onMounted as x, onUnmounted as A, computed as I, createBlock as f, Transition as C, withCtx as M, createCommentVNode as P, normalizeClass as j, renderSlot as m, createTextVNode as E, toDisplayString as N, createApp as z, h as F, defineAsyncComponent as O } from "vue";
2
+ function B(e) {
3
+ return /^(https?:|mailto:|tel:)/.test(e);
4
+ }
5
+ function q(e, n) {
6
+ if (arguments.length === 0 || !e)
7
+ return null;
8
+ const o = n || "{Y}-{m}-{d} {G}:{i}:{s}";
9
+ let t;
10
+ typeof e == "object" ? t = e : (typeof e == "string" && (/^[0-9]+$/.test(e) ? e = parseInt(e) : e = e.replace(new RegExp(/-/gm), "/")), typeof e == "number" && e.toString().length === 10 && (e = e * 1e3), t = new Date(e));
11
+ const s = "ru-RU", r = {
12
+ Y: t.getFullYear(),
13
+ m: (t.getMonth() + 1).toString().padStart(2, "0"),
14
+ d: t.getDate(),
15
+ dd: t.getDate().toString().padStart(2, "0"),
16
+ G: t.getHours(),
17
+ H: t.getHours().toString().padStart(2, "0"),
18
+ i: t.getMinutes().toString().padStart(2, "0"),
19
+ s: t.getSeconds().toString().padStart(2, "0"),
20
+ D: new Intl.DateTimeFormat(s, { weekday: "short" }).format(t),
21
+ F: new Intl.DateTimeFormat(s, { month: "long" }).format(t),
22
+ M: new Intl.DateTimeFormat(s, { month: "short" }).format(t)
23
+ };
24
+ return o.replace(/{(dd|[YmdGHisDFM])+}/g, (i, c) => r[c]);
25
+ }
26
+ const G = ["href"], S = {
27
+ __name: "SwIcon",
28
+ props: {
29
+ prefix: { type: String, default: "icon" },
30
+ iconClass: { type: String, required: !0 },
31
+ className: { type: String, default: "" }
32
+ },
33
+ setup(e) {
34
+ const n = e, o = B(n.iconClass);
35
+ return (t, s) => D(o) ? (u(), d("div", w({
36
+ key: 0,
37
+ style: "mask: url(" + n.iconClass + ") no-repeat 50% 50%;",
38
+ class: "svg-external-icon svg-icon"
39
+ }, t.$attrs), null, 16)) : (u(), d("svg", w({
40
+ key: 1,
41
+ class: "svg-icon icon-" + (n.className || n.iconClass),
42
+ "aria-hidden": "true"
43
+ }, t.$attrs), [
44
+ b("use", {
45
+ href: "#" + n.prefix + "-" + n.iconClass
46
+ }, null, 8, G)
47
+ ], 16));
48
+ }
49
+ }, H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
50
+ __proto__: null,
51
+ default: S
52
+ }, Symbol.toStringTag, { value: "Module" })), _ = {
53
+ __name: "SwAlert",
54
+ props: {
55
+ message: { type: String, default: "Default message" },
56
+ before: { type: String, default: "" },
57
+ class: { type: String, default: "" },
58
+ after: { type: String, default: "" },
59
+ size: { type: String, default: "" },
60
+ duration: { type: Number, default: 6e3 },
61
+ type: { type: String, default: "info", validator: (e) => ["success", "warning", "error", "info"].includes(e) }
62
+ },
63
+ emits: ["closed"],
64
+ setup(e, { emit: n }) {
65
+ const o = e, t = n, s = $(!1);
66
+ let r = null;
67
+ const i = () => {
68
+ s.value = !0, v();
69
+ }, c = () => {
70
+ s.value = !1, t("closed");
71
+ }, a = () => {
72
+ r && (clearTimeout(r), r = null);
73
+ }, T = () => {
74
+ v();
75
+ }, v = () => {
76
+ r = setTimeout(c, o.duration);
77
+ };
78
+ x(() => {
79
+ i();
80
+ }), A(() => {
81
+ r && clearTimeout(r);
82
+ });
83
+ const k = I(() => {
84
+ const l = ["sw-alert"];
85
+ return o.size.length > 0 && l.push(`sw-${o.size}`), o.type.length > 0 && l.push(`sw-${o.type}`), o.class.length > 0 && l.push(o.class), l;
86
+ });
87
+ return (l, U) => (u(), f(C, { name: "fade" }, {
88
+ default: M(() => [
89
+ s.value ? (u(), d("div", {
90
+ key: 0,
91
+ class: j(k.value),
92
+ onMouseenter: a,
93
+ onMouseleave: T
94
+ }, [
95
+ o.before.length > 0 ? (u(), f(S, {
96
+ key: 0,
97
+ "icon-class": o.before
98
+ }, null, 8, ["icon-class"])) : m(l.$slots, "prefix", { key: 1 }),
99
+ m(l.$slots, "default", {}, () => [
100
+ E(N(o.message), 1)
101
+ ]),
102
+ o.after.length > 0 ? (u(), f(S, {
103
+ key: 2,
104
+ "icon-class": o.after,
105
+ onClick: c
106
+ }, null, 8, ["icon-class"])) : m(l.$slots, "suffix", { key: 3 }),
107
+ b("footer", null, [
108
+ m(l.$slots, "footer")
109
+ ])
110
+ ], 34)) : P("", !0)
111
+ ]),
112
+ _: 3
113
+ }));
114
+ }
115
+ }, Y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
116
+ __proto__: null,
117
+ default: _
118
+ }, Symbol.toStringTag, { value: "Module" }));
119
+ let p = document.querySelector("div.sw-alert-wrapper");
120
+ function y(e = {}) {
121
+ p || (p = document.createElement("div"), p.className = "sw-alert-wrapper", document.body.appendChild(p));
122
+ const {
123
+ prefix: n,
124
+ suffix: o,
125
+ footer: t,
126
+ ...s
127
+ } = e, r = (a) => a == null ? null : typeof a == "function" ? a : typeof a == "string" ? () => [a] : Array.isArray(a) ? () => a : () => [a], i = z({
128
+ setup() {
129
+ return () => F(
130
+ _,
131
+ {
132
+ ...s,
133
+ onClose: () => {
134
+ p.removeChild(i._container), i.unmount();
135
+ }
136
+ },
137
+ {
138
+ ...n != null && { prefix: r(n) },
139
+ ...o != null && { suffix: r(o) },
140
+ ...t != null && { footer: r(t) }
141
+ }
142
+ );
143
+ }
144
+ }), c = i.mount(document.createElement("div"));
145
+ p.appendChild(c.$el);
146
+ }
147
+ const h = /* @__PURE__ */ Object.assign({ "./components/SwAlert.vue": () => Promise.resolve().then(() => Y), "./components/SwButton.vue": () => import("./SwButton-85-tKHA7.js"), "./components/SwCollapse.vue": () => import("./SwCollapse-CuN3EbT6.js"), "./components/SwDatePicker.vue": () => import("./SwDatePicker-jkMxCTN0.js"), "./components/SwDropdown.vue": () => import("./SwDropdown-DQGTnnKw.js"), "./components/SwDropdownItem.vue": () => import("./SwDropdownItem-BcFUu896.js"), "./components/SwFormItem.vue": () => import("./SwFormItem-CaA4jsoa.js"), "./components/SwGide.vue": () => import("./SwGide-TCfG-aUP.js"), "./components/SwIcon.vue": () => Promise.resolve().then(() => H), "./components/SwInput.vue": () => import("./SwInput-BfVbDGqo.js"), "./components/SwMessage.vue": () => import("./SwMessage-DL3XthhU.js"), "./components/SwPopover.vue": () => import("./SwPopover-B4oOez4M.js"), "./components/SwSection.vue": () => import("./SwSection-D8ooQ21I.js"), "./components/SwSelect.vue": () => import("./SwSelect-C2RKinez.js"), "./components/SwSkeleton.vue": () => import("./SwSkeleton-B7ysp8L9.js"), "./components/SwSkeletonItem.vue": () => import("./SwSkeletonItem-CU7LvihY.js"), "./components/SwSlider.vue": () => import("./SwSlider-BTpjTOzs.js"), "./components/SwSwitch.vue": () => import("./SwSwitch-6rl1IT4p.js"), "./components/SwTable.vue": () => import("./SwTable-BLrFhlyO.js"), "./components/SwTableColumn.vue": () => import("./SwTableColumn-BLF5bPuJ.js"), "./components/SwTabs.vue": () => import("./SwTabs-DkSI4oAh.js"), "./components/SwTabsPane.vue": () => import("./SwTabsPane-Dwtj8g7T.js") }), g = {};
148
+ for (const e in h) {
149
+ const n = e.split("/").pop().replace(".vue", "").replace(/-(\w)/g, (o, t) => t.toUpperCase());
150
+ g[n] = O(() => h[e]());
151
+ }
152
+ const L = {
153
+ install(e) {
154
+ Object.keys(g).forEach((n) => {
155
+ e.component(n, g[n]);
156
+ }), e.config.globalProperties.$Alert = y, e.provide("Alert", y);
157
+ }
158
+ };
159
+ export {
160
+ y as A,
161
+ L,
162
+ S as _,
163
+ g as c,
164
+ q as p
165
+ };