@sendelius/vue 0.4.2 → 0.5.0

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.
Files changed (92) hide show
  1. package/dist/Autocomplete.css +1 -0
  2. package/dist/Btn.css +1 -0
  3. package/dist/Checkbox.css +1 -0
  4. package/dist/Confirm.css +1 -0
  5. package/dist/Cookie.css +1 -0
  6. package/dist/Error.css +1 -0
  7. package/dist/Input.css +1 -0
  8. package/dist/InputCity.css +1 -0
  9. package/dist/InputDate-CRpVPH9p.js +9795 -0
  10. package/dist/InputDate.css +1 -0
  11. package/dist/InputPassword.css +1 -0
  12. package/dist/InputPhone-CTq4y49q.js +272 -0
  13. package/dist/Popup-BIJpeS3t.js +150 -0
  14. package/dist/Popup.css +1 -0
  15. package/dist/Progress.css +1 -0
  16. package/dist/Select.css +1 -0
  17. package/dist/Success.css +1 -0
  18. package/dist/Table.css +1 -0
  19. package/dist/TableFooter.css +1 -0
  20. package/dist/TableHeader.css +1 -0
  21. package/dist/TableItems.css +1 -0
  22. package/dist/TablePagination.css +1 -0
  23. package/dist/Warning.css +1 -0
  24. package/dist/_plugin-vue_export-helper-Djzt4Yr7.js +7 -0
  25. package/dist/api/api.d.ts +2 -2
  26. package/dist/api/index.d.ts +1 -1
  27. package/dist/api/requests.d.ts +8 -6
  28. package/dist/config/config.d.ts +3 -1
  29. package/dist/index.js +214 -0
  30. package/dist/ui/btn/Btn.d.ts +4 -0
  31. package/dist/ui/btn/Btn.js +102 -0
  32. package/dist/ui/btn/Btn.vue.d.ts +9 -3
  33. package/dist/ui/cookie/Cookie.d.ts +4 -0
  34. package/dist/ui/cookie/Cookie.js +22 -0
  35. package/dist/ui/cookie/Cookie.vue.d.ts +5 -1
  36. package/dist/ui/form/Autocomplete.d.ts +4 -0
  37. package/dist/ui/form/Autocomplete.js +172 -0
  38. package/dist/ui/form/Autocomplete.vue.d.ts +12 -6
  39. package/dist/ui/form/Checkbox.d.ts +4 -0
  40. package/dist/ui/form/Checkbox.js +69 -0
  41. package/dist/ui/form/Checkbox.vue.d.ts +9 -3
  42. package/dist/ui/form/Input.d.ts +4 -0
  43. package/dist/ui/form/Input.js +92 -0
  44. package/dist/ui/form/Input.vue.d.ts +7 -2
  45. package/dist/ui/form/InputCity.d.ts +4 -0
  46. package/dist/ui/form/InputCity.js +86 -0
  47. package/dist/ui/form/InputDate.d.ts +4 -0
  48. package/dist/ui/form/InputDate.js +1 -0
  49. package/dist/ui/form/InputDate.vue.d.ts +7 -2
  50. package/dist/ui/form/InputPassword.d.ts +4 -0
  51. package/dist/ui/form/InputPassword.js +100 -0
  52. package/dist/ui/form/InputPassword.vue.d.ts +7 -2
  53. package/dist/ui/form/InputPhone.d.ts +4 -0
  54. package/dist/ui/form/InputPhone.js +1 -0
  55. package/dist/ui/form/Select.d.ts +4 -0
  56. package/dist/ui/form/Select.js +76 -0
  57. package/dist/ui/form/Select.vue.d.ts +9 -3
  58. package/dist/ui/notice/Error.d.ts +4 -0
  59. package/dist/ui/notice/Error.js +84 -0
  60. package/dist/ui/notice/Error.vue.d.ts +9 -3
  61. package/dist/ui/notice/Success.d.ts +4 -0
  62. package/dist/ui/notice/Success.js +70 -0
  63. package/dist/ui/notice/Success.vue.d.ts +7 -2
  64. package/dist/ui/notice/Warning.d.ts +4 -0
  65. package/dist/ui/notice/Warning.js +74 -0
  66. package/dist/ui/notice/Warning.vue.d.ts +7 -2
  67. package/dist/ui/popup/Confirm.d.ts +4 -0
  68. package/dist/ui/popup/Confirm.js +61 -0
  69. package/dist/ui/popup/Popup.d.ts +4 -0
  70. package/dist/ui/popup/Popup.js +1 -0
  71. package/dist/ui/progress/Progress.d.ts +4 -0
  72. package/dist/ui/progress/Progress.js +23 -0
  73. package/dist/ui/table/Table.d.ts +4 -0
  74. package/dist/ui/table/Table.js +178 -0
  75. package/dist/ui/table/Table.vue.d.ts +21 -12
  76. package/dist/ui/table/TableFilters.d.ts +4 -0
  77. package/dist/ui/table/TableFilters.js +8 -0
  78. package/dist/ui/table/TableFooter.d.ts +4 -0
  79. package/dist/ui/table/TableFooter.js +142 -0
  80. package/dist/ui/table/TableFooter.vue.d.ts +9 -3
  81. package/dist/ui/table/TableHeader.d.ts +4 -0
  82. package/dist/ui/table/TableHeader.js +157 -0
  83. package/dist/ui/table/TableHeader.vue.d.ts +7 -2
  84. package/dist/ui/table/TableItems.d.ts +4 -0
  85. package/dist/ui/table/TableItems.js +83 -0
  86. package/dist/ui/table/TableItems.vue.d.ts +12 -9
  87. package/dist/ui/table/TablePagination.d.ts +4 -0
  88. package/dist/ui/table/TablePagination.js +92 -0
  89. package/dist/ui/table/TablePagination.vue.d.ts +7 -2
  90. package/package.json +16 -13
  91. package/dist/sendelius-vue.css +0 -2
  92. package/dist/sendelius-vue.js +0 -11918
package/dist/index.js ADDED
@@ -0,0 +1,214 @@
1
+ import e from "./ui/progress/Progress.js";
2
+ import t from "./ui/btn/Btn.js";
3
+ import n from "./ui/cookie/Cookie.js";
4
+ import r from "./ui/form/Input.js";
5
+ import i from "./ui/form/Autocomplete.js";
6
+ import { t as a } from "./InputPhone-CTq4y49q.js";
7
+ import o from "./ui/form/Select.js";
8
+ import s from "./ui/form/InputCity.js";
9
+ import { t as c } from "./InputDate-CRpVPH9p.js";
10
+ import l from "./ui/form/InputPassword.js";
11
+ import u from "./ui/form/Checkbox.js";
12
+ import d from "./ui/notice/Warning.js";
13
+ import f from "./ui/notice/Error.js";
14
+ import p from "./ui/notice/Success.js";
15
+ import { n as m, t as h } from "./Popup-BIJpeS3t.js";
16
+ import g from "./ui/table/Table.js";
17
+ import _ from "axios";
18
+ import { defineStore as v } from "pinia";
19
+ import { ref as y } from "vue";
20
+ // src/config/config.js
21
+ var b = {
22
+ router: null,
23
+ api: { default: "" },
24
+ baseTitle: "",
25
+ baseTitleSeparator: " - ",
26
+ routeAfterLogin: "/",
27
+ routeAfterLogout: "/",
28
+ urlUserInfo: "/auth/me",
29
+ urlLogin: "/auth/login",
30
+ urlLogout: "/auth/logout",
31
+ onUnauthorized: null,
32
+ onLogout: null
33
+ }, x = (e = {}) => {
34
+ b = {
35
+ ...b,
36
+ ...e
37
+ };
38
+ }, S = () => b, C = {}, w = () => {
39
+ let e = S(), t = {
40
+ withCredentials: !0,
41
+ headers: {
42
+ "Content-Type": "application/json",
43
+ Accept: "application/json"
44
+ }
45
+ };
46
+ return Object.entries(e.api).forEach(([e, n]) => {
47
+ C[e] = _.create({
48
+ ...t,
49
+ baseURL: n
50
+ });
51
+ }), C;
52
+ }, T = (e = "default") => {
53
+ let t = C[e] || C.default;
54
+ if (!t) throw Error("@sendelius/vue: API-клиенты не инициализированы. Вызови initApi().");
55
+ return t;
56
+ }, E = class extends Error {
57
+ constructor({ status: e = null, data: t = null } = {}) {
58
+ let n = t?.error, r = {
59
+ code: n?.code ?? "UNKNOWN_ERROR",
60
+ message: n?.message ?? "неизвестная ошибка",
61
+ field: n?.field ?? null
62
+ };
63
+ super(r.message), this.name = "ApiError", this.status = e, this.data = t, this.error = r, this.field = r.field;
64
+ }
65
+ };
66
+ // src/api/requests.js
67
+ async function D(e, t, n = {}, r = {}, i = "default") {
68
+ let a = T(i), o;
69
+ try {
70
+ o = e === "get" ? await a.get(t, {
71
+ params: n,
72
+ ...r
73
+ }) : e === "delete" ? await a.delete(t, {
74
+ data: n,
75
+ ...r
76
+ }) : await a[e](t, n, r);
77
+ } catch (e) {
78
+ throw e.response?.status === 401 && S().onUnauthorized?.(), new E({
79
+ status: e.response?.status ?? null,
80
+ data: e.response?.data ?? null
81
+ });
82
+ }
83
+ let s = o.data;
84
+ if (s?.status !== "success") throw new E({
85
+ status: o.status,
86
+ data: s
87
+ });
88
+ return s;
89
+ }
90
+ function O(e = "default") {
91
+ return {
92
+ get: (t, n = {}, r = {}) => D("get", t, n, r, e),
93
+ post: (t, n = {}, r = {}) => D("post", t, n, r, e),
94
+ put: (t, n = {}, r = {}) => D("put", t, n, r, e),
95
+ patch: (t, n = {}, r = {}) => D("patch", t, n, r, e),
96
+ remove: (t, n = {}, r = {}) => D("delete", t, n, r, e),
97
+ request: (t, n, r = {}, i = {}) => D(t, n, r, i, e)
98
+ };
99
+ }
100
+ // src/auth/auth.js
101
+ var { get: k, post: A, remove: j } = O("auth"), M = v("auth", {
102
+ state: () => ({
103
+ user: {},
104
+ avatar: {
105
+ color: "#000000",
106
+ initials: "",
107
+ image: ""
108
+ },
109
+ isAuth: !1,
110
+ isInit: !1
111
+ }),
112
+ actions: {
113
+ async init(e = !0) {
114
+ if (this.isInit && e) return this.isAuth;
115
+ try {
116
+ let e = await k(S().urlUserInfo);
117
+ e?.user ? (this.user = e.user, this.avatar = e.user.avatar ?? this.avatar, this.isAuth = !0) : this.clear();
118
+ } catch {
119
+ this.clear();
120
+ } finally {
121
+ this.isInit = !0;
122
+ }
123
+ return this.isAuth;
124
+ },
125
+ async login(e, t, n) {
126
+ n ||= "";
127
+ try {
128
+ await A(S().urlLogin, {
129
+ login: e,
130
+ password: t,
131
+ captcha: n
132
+ }), await this.init(!1);
133
+ let r = S().router;
134
+ return r && await r.push(S().routeAfterLogin), !0;
135
+ } catch (e) {
136
+ throw e;
137
+ }
138
+ },
139
+ async logout() {
140
+ try {
141
+ await j(S().urlLogout);
142
+ } finally {
143
+ this.clear(), S().onLogout?.();
144
+ let e = S().router;
145
+ e && await e.push(S().routeAfterLogout);
146
+ }
147
+ },
148
+ clear() {
149
+ this.user = {}, this.avatar = {
150
+ color: "#000000",
151
+ initials: "",
152
+ image: ""
153
+ }, this.isAuth = !1;
154
+ }
155
+ }
156
+ });
157
+ function N() {
158
+ return M();
159
+ }
160
+ // src/captcha/captcha.js
161
+ var { get: P, post: F } = O("auth");
162
+ async function I() {
163
+ let e = await L(), t = await z(e.challenge);
164
+ return R(e.id, t);
165
+ }
166
+ async function L() {
167
+ return P("/captcha/challenge");
168
+ }
169
+ async function R(e, t) {
170
+ return (await F("/captcha/verify", {
171
+ id: e,
172
+ nonce: t
173
+ }))?.token;
174
+ }
175
+ async function z(e) {
176
+ let t = "0".repeat(4), n = 0;
177
+ for (;;) {
178
+ if ((await B(`${e}:${n}`)).startsWith(t)) return n;
179
+ n++;
180
+ }
181
+ }
182
+ async function B(e) {
183
+ let t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t);
184
+ return Array.from(new Uint8Array(n)).map((e) => e.toString(16).padStart(2, "0")).join("");
185
+ }
186
+ // src/captcha/store.js
187
+ var V = v("captcha", () => {
188
+ let e = y(""), t = y(!1), n = y(!1), r = null;
189
+ return {
190
+ token: e,
191
+ isInit: t,
192
+ isLoading: n,
193
+ init: async () => t.value ? e.value : r || (n.value = !0, r = I().then((n) => (e.value = n, t.value = !0, n)).finally(() => {
194
+ n.value = !1, r = null;
195
+ }), r)
196
+ };
197
+ });
198
+ function H() {
199
+ return V();
200
+ }
201
+ // src/helpers/declension.js
202
+ function U(e, t, n, r) {
203
+ let i = Math.abs(e) % 100, a = i % 10, o;
204
+ return o = i >= 11 && i <= 19 ? r : a === 1 ? t : a >= 2 && a <= 4 ? n : r, `${e} ${o}`;
205
+ }
206
+ // src/helpers/title.js
207
+ function W(e, t, n) {
208
+ t ??= S().baseTitle, n ??= S().baseTitleSeparator, t || (n = ""), document.title = e ? `${e}${n}${t}` : t;
209
+ }
210
+ // src/helpers/objects.js
211
+ function G(e) {
212
+ return Array.isArray(e) ? e.length === 0 : e && typeof e == "object" ? Object.keys(e).length === 0 : !0;
213
+ }
214
+ export { E as ApiError, i as SndAutocomplete, t as SndBtn, u as SndCheckbox, n as SndCookie, f as SndError, r as SndInput, s as SndInputCity, c as SndInputDate, l as SndInputPassword, a as SndInputPhone, h as SndPopup, e as SndProgress, o as SndSelect, p as SndSuccess, g as SndTable, d as SndWarning, x as configure, U as declension, T as getClient, S as getConfig, w as initApi, G as isEmpty, W as setTitle, O as useApi, N as useAuth, H as useCaptcha, m as usePopup };
@@ -0,0 +1,4 @@
1
+ export {}
2
+ import _default from './Btn.vue.js'
3
+ export default _default
4
+ export {}
@@ -0,0 +1,102 @@
1
+ import e from "../progress/Progress.js";
2
+ import { t } from "../../_plugin-vue_export-helper-Djzt4Yr7.js";
3
+ import { computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createVNode as o, normalizeClass as s, openBlock as c, renderSlot as l, resolveComponent as u, withCtx as d } from "vue";
4
+ import '../../Btn.css';// src/ui/btn/Btn.vue
5
+ var f = ["href"], p = /*#__PURE__*/ t({
6
+ __name: "Btn",
7
+ props: {
8
+ href: {
9
+ type: String,
10
+ default: ""
11
+ },
12
+ to: {
13
+ type: String,
14
+ default: ""
15
+ },
16
+ size: {
17
+ type: String,
18
+ default: "",
19
+ validator: (e) => [
20
+ "",
21
+ "small",
22
+ "big"
23
+ ].includes(e)
24
+ },
25
+ variant: {
26
+ type: String,
27
+ default: "",
28
+ validator: (e) => [
29
+ "",
30
+ "outline",
31
+ "gray",
32
+ "red",
33
+ "green"
34
+ ].includes(e)
35
+ },
36
+ hover: {
37
+ type: String,
38
+ default: "",
39
+ validator: (e) => [
40
+ "",
41
+ "blue",
42
+ "red",
43
+ "green"
44
+ ].includes(e)
45
+ },
46
+ progressLabel: {
47
+ type: String,
48
+ default: ""
49
+ },
50
+ progressShow: {
51
+ type: Boolean,
52
+ default: !1
53
+ },
54
+ withIcon: {
55
+ type: Boolean,
56
+ default: !1
57
+ }
58
+ },
59
+ setup(t) {
60
+ let p = t, m = n(() => [{
61
+ "btn-big": p.size === "big",
62
+ "btn-small": p.size === "small",
63
+ "btn-outline": p.variant === "outline",
64
+ "btn-gray": p.variant === "gray",
65
+ "btn-red": p.variant === "red",
66
+ "btn-green": p.variant === "green",
67
+ "btn-hover-blue": p.hover === "blue",
68
+ "btn-hover-red": p.hover === "red",
69
+ "btn-hover-green": p.hover === "green",
70
+ "btn-progress": p.progressLabel,
71
+ "btn-with-icon": p.withIcon
72
+ }]);
73
+ return (n, p) => {
74
+ let h = u("RouterLink");
75
+ return t.to ? (c(), r(h, {
76
+ key: 0,
77
+ to: t.to,
78
+ class: s(["btn", m.value])
79
+ }, {
80
+ default: d(() => [o(e, {
81
+ show: t.progressShow,
82
+ label: t.progressLabel
83
+ }, null, 8, ["show", "label"]), t.progressShow ? i("", !0) : l(n.$slots, "default", {}, void 0, !0, 0)]),
84
+ _: 3
85
+ }, 8, ["to", "class"])) : t.href ? (c(), a("a", {
86
+ key: 1,
87
+ href: t.href,
88
+ class: s(["btn", m.value])
89
+ }, [o(e, {
90
+ show: t.progressShow,
91
+ label: t.progressLabel
92
+ }, null, 8, ["show", "label"]), t.progressShow ? i("", !0) : l(n.$slots, "default", {}, void 0, !0, 0)], 10, f)) : (c(), a("button", {
93
+ key: 2,
94
+ class: s(["btn", m.value])
95
+ }, [o(e, {
96
+ show: t.progressShow,
97
+ label: t.progressLabel
98
+ }, null, 8, ["show", "label"]), t.progressShow ? i("", !0) : l(n.$slots, "default", {}, void 0, !0, 0)], 2));
99
+ };
100
+ }
101
+ }, [["__scopeId", "data-v-a0ffba5d"]]);
102
+ export { p as default };
@@ -1,7 +1,13 @@
1
1
  declare const component: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
2
- declare var __VLS_12: {};
3
- declare var __VLS_19: {};
4
- declare var __VLS_26: {};
2
+ declare function __VLS_template(): {
3
+ __VLS_Slots: {
4
+ default?: (props: {}) => any;
5
+ } & {
6
+ default?: (props: {}) => any;
7
+ } & {
8
+ default?: (props: {}) => any;
9
+ };
10
+ };
5
11
  declare const __VLS_base: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
6
12
  href: {
7
13
  type: StringConstructor;
@@ -0,0 +1,4 @@
1
+ export {}
2
+ import _default from './Cookie.vue.js'
3
+ export default _default
4
+ export {}
@@ -0,0 +1,22 @@
1
+ import e from "../btn/Btn.js";
2
+ import { t } from "../../_plugin-vue_export-helper-Djzt4Yr7.js";
3
+ import { createCommentVNode as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, createVNode as o, onMounted as s, openBlock as c, ref as l, renderSlot as u, withCtx as d } from "vue";
4
+ import '../../Cookie.css';// src/ui/cookie/Cookie.vue
5
+ var f = {
6
+ key: 0,
7
+ class: "cookie"
8
+ }, p = /*#__PURE__*/ t({
9
+ __name: "Cookie",
10
+ setup(t) {
11
+ let p = l(!1), m = () => {
12
+ localStorage.setItem("cookieAccepted", "1"), p.value = !1;
13
+ };
14
+ return s(() => {
15
+ p.value = localStorage.getItem("cookieAccepted") !== "1";
16
+ }), (t, s) => p.value ? (c(), r("div", f, [i("div", null, [u(t.$slots, "default", {}, void 0, !0)]), o(e, { onClick: m }, {
17
+ default: d(() => [...s[0] ||= [a("Согласен", -1)]]),
18
+ _: 1
19
+ })])) : n("", !0);
20
+ }
21
+ }, [["__scopeId", "data-v-40628050"]]);
22
+ export { p as default };
@@ -1,5 +1,9 @@
1
1
  declare const component: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
2
- declare var __VLS_1: {};
2
+ declare function __VLS_template(): {
3
+ __VLS_Slots: {
4
+ default?: (props: {}) => any;
5
+ };
6
+ };
3
7
  declare const __VLS_base: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
4
8
 
5
9
  export default component;
@@ -0,0 +1,4 @@
1
+ export {}
2
+ import _default from './Autocomplete.vue.js'
3
+ export default _default
4
+ export {}
@@ -0,0 +1,172 @@
1
+ import e from "./Input.js";
2
+ import t from "../progress/Progress.js";
3
+ import { t as n } from "../../_plugin-vue_export-helper-Djzt4Yr7.js";
4
+ import { Fragment as r, Teleport as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createTextVNode as c, createVNode as l, nextTick as u, normalizeClass as d, normalizeStyle as f, onBeforeUnmount as p, onMounted as m, openBlock as h, ref as g, renderList as _, renderSlot as v, watch as y, withCtx as b, withModifiers as x } from "vue";
5
+ import '../../Autocomplete.css';// src/ui/form/Autocomplete.vue
6
+ var S = ["onMousedown"], C = {
7
+ key: 0,
8
+ class: "autocomplete-empty"
9
+ }, w = /*#__PURE__*/ n({
10
+ __name: "Autocomplete",
11
+ props: {
12
+ modelValue: {
13
+ type: [String, Number],
14
+ default: ""
15
+ },
16
+ autocomplete: {
17
+ type: Function,
18
+ default: null
19
+ },
20
+ label: {
21
+ type: [String, Boolean],
22
+ default: ""
23
+ },
24
+ error: {
25
+ type: String,
26
+ default: ""
27
+ },
28
+ required: {
29
+ type: Boolean,
30
+ default: !1
31
+ },
32
+ minLength: {
33
+ type: Number,
34
+ default: 2
35
+ },
36
+ delay: {
37
+ type: Number,
38
+ default: 300
39
+ }
40
+ },
41
+ emits: [
42
+ "update:modelValue",
43
+ "select",
44
+ "focus",
45
+ "blur"
46
+ ],
47
+ setup(n, { expose: w, emit: T }) {
48
+ let E = n, D = T, O = g(null), k = g(null), A = g(null), j = g(E.modelValue), M = g([]), N = g(-1), P = g(!1), F = g(!1), I = g(!1), L = g({}), R = g({
49
+ "autocomplete-dropdown__top": !1,
50
+ "autocomplete-dropdown__bottom": !0
51
+ }), z = null, B = 0, V = () => {
52
+ P.value = !1, M.value = [], F.value = !1, N.value = -1;
53
+ }, H = async () => {
54
+ let e = j.value;
55
+ if (!E.autocomplete || e.length < E.minLength) {
56
+ V();
57
+ return;
58
+ }
59
+ let t = ++B;
60
+ I.value = !0, P.value = !0, M.value = [], F.value = !1, N.value = -1;
61
+ try {
62
+ let n = await E.autocomplete(e);
63
+ if (t !== B) return;
64
+ M.value = n ?? [], F.value = M.value.length === 0, N.value = M.value.length ? 0 : -1;
65
+ } catch {
66
+ if (t !== B) return;
67
+ M.value = [], F.value = !1, N.value = -1;
68
+ } finally {
69
+ t === B && (I.value = !1);
70
+ }
71
+ await u(), Y();
72
+ }, U = () => {
73
+ clearTimeout(z), j.value.length < E.minLength ? (B++, V(), I.value = !1) : z = setTimeout(H, E.delay);
74
+ }, W = (e) => {
75
+ V(), D("select", e);
76
+ }, G = (e) => {
77
+ if (M.value.length) switch (e.key) {
78
+ case "ArrowDown":
79
+ e.preventDefault(), N.value++, N.value >= M.value.length && (N.value = 0);
80
+ break;
81
+ case "ArrowUp":
82
+ e.preventDefault(), N.value--, N.value < 0 && (N.value = M.value.length - 1);
83
+ break;
84
+ case "Enter":
85
+ e.preventDefault(), N.value >= 0 && W(M.value[N.value]);
86
+ break;
87
+ case "Escape": e.preventDefault(), V();
88
+ }
89
+ }, K = async (e) => {
90
+ D("focus", e), j.value.length >= E.minLength && (P.value = !0, await u(), Y());
91
+ }, q = (e) => {
92
+ D("blur", e);
93
+ }, J = (e) => {
94
+ O.value?.contains(e.target) || A.value?.contains(e.target) || V();
95
+ }, Y = () => {
96
+ if (!O.value) return;
97
+ let e = O.value.getBoundingClientRect(), t = A.value?.offsetHeight ?? 0, n = window.innerHeight - e.bottom, r = e.top;
98
+ t && n < t && r >= t ? (L.value = {
99
+ bottom: `${window.innerHeight - e.top}px`,
100
+ left: `${e.left}px`,
101
+ width: `${e.width}px`,
102
+ top: "auto"
103
+ }, R.value = {
104
+ "autocomplete-dropdown__top": !0,
105
+ "autocomplete-dropdown__bottom": !1
106
+ }) : (L.value = {
107
+ top: `${e.bottom}px`,
108
+ left: `${e.left}px`,
109
+ width: `${e.width}px`,
110
+ bottom: "auto"
111
+ }, R.value = {
112
+ "autocomplete-dropdown__top": !1,
113
+ "autocomplete-dropdown__bottom": !0
114
+ });
115
+ };
116
+ y(() => E.modelValue, (e) => {
117
+ j.value = e;
118
+ }), y(() => E.modelValue, (e) => {
119
+ j.value = e;
120
+ });
121
+ let X = (e) => {
122
+ j.value = e, D("update:modelValue", e), U();
123
+ };
124
+ return m(() => {
125
+ document.addEventListener("mousedown", J), window.addEventListener("resize", Y), window.addEventListener("scroll", Y, !0);
126
+ }), p(() => {
127
+ clearTimeout(z), document.removeEventListener("mousedown", J), window.removeEventListener("resize", Y), window.removeEventListener("scroll", Y, !0);
128
+ }), w({
129
+ focus: () => k.value?.focus(),
130
+ blur: () => k.value?.blur()
131
+ }), (u, p) => (h(), s("div", {
132
+ ref_key: "autocomplete",
133
+ ref: O,
134
+ class: d(["autocomplete", { "show-dropdown": P.value && (M.value.length || F.value) }])
135
+ }, [l(e, {
136
+ ref_key: "input",
137
+ ref: k,
138
+ "model-value": j.value,
139
+ label: n.label,
140
+ error: n.error,
141
+ required: n.required,
142
+ autocompleteOff: "",
143
+ "onUpdate:modelValue": X,
144
+ onFocus: K,
145
+ onBlur: q,
146
+ onKeydown: G
147
+ }, {
148
+ before: b(() => [v(u.$slots, "before", {}, void 0, !0)]),
149
+ after: b(() => [l(t, { show: I.value }, null, 8, ["show"]), (h(), a(i, { to: "body" }, [P.value && (M.value.length || F.value) ? (h(), s("div", {
150
+ key: 0,
151
+ ref_key: "dropdown",
152
+ ref: A,
153
+ class: d(["autocomplete-dropdown", R.value]),
154
+ style: f(L.value)
155
+ }, [(h(!0), s(r, null, _(M.value, (e, t) => (h(), s("div", {
156
+ key: e.id,
157
+ class: d({ active: t === N.value }),
158
+ onMousedown: x((t) => W(e), ["prevent"])
159
+ }, [v(u.$slots, "default", {
160
+ item: e,
161
+ index: t
162
+ }, void 0, !0)], 42, S))), 128)), F.value ? (h(), s("div", C, [v(u.$slots, "empty", {}, () => [p[0] ||= c(" Ничего не найдено ", -1)], !0)])) : o("", !0)], 6)) : o("", !0)]))]),
163
+ _: 3
164
+ }, 8, [
165
+ "model-value",
166
+ "label",
167
+ "error",
168
+ "required"
169
+ ])], 2));
170
+ }
171
+ }, [["__scopeId", "data-v-d783e5e2"]]);
172
+ export { w as default };
@@ -1,10 +1,16 @@
1
1
  declare const component: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
2
- declare var __VLS_13: {};
3
- declare namespace __VLS_28 {
4
- let item: any;
5
- let index: number;
6
- }
7
- declare var __VLS_30: {};
2
+ declare function __VLS_template(): {
3
+ __VLS_Slots: {
4
+ before?: (props: {}) => any;
5
+ } & {
6
+ default?: (props: {
7
+ item: any;
8
+ index: number;
9
+ }) => any;
10
+ } & {
11
+ empty?: (props: {}) => any;
12
+ };
13
+ };
8
14
  declare const __VLS_base: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
9
15
  modelValue: {
10
16
  type: (StringConstructor | NumberConstructor)[];
@@ -0,0 +1,4 @@
1
+ export {}
2
+ import _default from './Checkbox.vue.js'
3
+ export default _default
4
+ export {}
@@ -0,0 +1,69 @@
1
+ import { t as e } from "../../_plugin-vue_export-helper-Djzt4Yr7.js";
2
+ import { computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, normalizeClass as a, openBlock as o, ref as s, renderSlot as c, toDisplayString as l, unref as u, useSlots as d, vModelCheckbox as f, withDirectives as p, withModifiers as m } from "vue";
3
+ import '../../Checkbox.css';// src/ui/form/Checkbox.vue
4
+ var h = [
5
+ "value",
6
+ "required",
7
+ "disabled"
8
+ ], g = { key: 0 }, _ = { key: 1 }, v = {
9
+ key: 0,
10
+ class: "error"
11
+ }, y = /*#__PURE__*/ e({
12
+ __name: "Checkbox",
13
+ props: {
14
+ modelValue: {
15
+ type: [String, Boolean],
16
+ default: ""
17
+ },
18
+ label: {
19
+ type: String,
20
+ default: ""
21
+ },
22
+ required: {
23
+ type: Boolean,
24
+ default: !1
25
+ },
26
+ disabled: {
27
+ type: Boolean,
28
+ default: !1
29
+ },
30
+ value: {
31
+ type: String,
32
+ default: ""
33
+ },
34
+ error: {
35
+ type: String,
36
+ default: ""
37
+ }
38
+ },
39
+ emits: ["update:modelValue"],
40
+ setup(e, { emit: y }) {
41
+ let b = d(), x = e, S = y, C = s(null), w = `checkbox-${Math.random().toString(16).slice(2)}`, T = s(""), E = t(() => [{ "checkbox-error": x.error || T.value }]), D = t({
42
+ get: () => x.modelValue,
43
+ set: (e) => {
44
+ S("update:modelValue", e), T.value = "";
45
+ }
46
+ }), O = () => {
47
+ T.value = C.value?.validationMessage ?? "";
48
+ };
49
+ return (t, s) => (o(), r("div", { class: a(["checkbox", E.value]) }, [
50
+ c(t.$slots, "before", {}, void 0, !0),
51
+ p(i("input", {
52
+ ref_key: "input",
53
+ ref: C,
54
+ id: w,
55
+ type: "checkbox",
56
+ "onUpdate:modelValue": s[0] ||= (e) => D.value = e,
57
+ value: e.value,
58
+ required: e.required,
59
+ disabled: e.disabled,
60
+ onInvalid: m(O, ["prevent"]),
61
+ onInput: O
62
+ }, null, 40, h), [[f, D.value]]),
63
+ i("label", { for: w }, [e.label ? (o(), r("span", g, l(e.label), 1)) : u(b).label ? (o(), r("span", _, [c(t.$slots, "label", {}, void 0, !0)])) : n("", !0)]),
64
+ e.error || T.value ? (o(), r("div", v, l(e.error || T.value), 1)) : n("", !0),
65
+ c(t.$slots, "after", {}, void 0, !0)
66
+ ], 2));
67
+ }
68
+ }, [["__scopeId", "data-v-5152abd6"]]);
69
+ export { y as default };
@@ -1,7 +1,13 @@
1
1
  declare const component: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
2
- declare var __VLS_1: {};
3
- declare var __VLS_3: {};
4
- declare var __VLS_5: {};
2
+ declare function __VLS_template(): {
3
+ __VLS_Slots: {
4
+ before?: (props: {}) => any;
5
+ } & {
6
+ label?: (props: {}) => any;
7
+ } & {
8
+ after?: (props: {}) => any;
9
+ };
10
+ };
5
11
  declare const __VLS_base: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
6
12
  modelValue: {
7
13
  type: (StringConstructor | BooleanConstructor)[];
@@ -0,0 +1,4 @@
1
+ export {}
2
+ import _default from './Input.vue.js'
3
+ export default _default
4
+ export {}