triafly-ui-kit 1.0.23 → 1.0.24
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 +93 -93
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/assets/Accordeon.css +1 -0
- package/dist/assets/Alert.css +1 -0
- package/dist/assets/Avatar.css +1 -0
- package/dist/assets/Badge.css +1 -0
- package/dist/assets/Button.css +1 -0
- package/dist/assets/ButtonsArray.css +1 -0
- package/dist/assets/Checkbox.css +1 -0
- package/dist/assets/CliTextareaInput.css +1 -0
- package/dist/assets/CustomLink.css +1 -0
- package/dist/assets/DatePicker.css +1 -0
- package/dist/assets/DropdownInput.css +1 -0
- package/dist/assets/DropdownMenu.css +1 -0
- package/dist/assets/FileUpload.css +1 -0
- package/dist/assets/FormRoot.css +1 -0
- package/dist/assets/Loader.css +1 -0
- package/dist/assets/ModalWindow.css +1 -0
- package/dist/assets/Pagination.css +1 -0
- package/dist/assets/Radio.css +1 -0
- package/dist/assets/SearchInput.css +1 -0
- package/dist/assets/Skeleton.css +1 -0
- package/dist/assets/Switch.css +1 -0
- package/dist/assets/Table.css +1 -0
- package/dist/assets/Tabs.css +1 -0
- package/dist/assets/TextInput.css +1 -0
- package/dist/assets/TextareaInput.css +1 -0
- package/dist/assets/ToastContext.css +1 -0
- package/dist/assets/Tooltip.css +1 -0
- package/dist/assets/Tooltip2.css +1 -0
- package/dist/assets/fonts/FiraCode-Regular.ttf +0 -0
- package/dist/assets/fonts/Manrope-Bold.ttf +0 -0
- package/dist/assets/fonts/Manrope-Regular.ttf +0 -0
- package/dist/assets/fonts/Manrope-SemiBold.ttf +0 -0
- package/dist/assets/fonts/RobotoSlab-SemiBold.ttf +0 -0
- package/dist/components/Ui/Accordeon/Accordeon.js +33 -0
- package/dist/components/Ui/Accordeon/Accordeon.stories.js +72 -0
- package/dist/components/Ui/Accordeon/index.js +4 -0
- package/dist/components/Ui/Alert/Alert.js +14 -0
- package/dist/components/Ui/Alert/index.js +4 -0
- package/dist/components/Ui/Avatar/Avatar.js +10 -0
- package/dist/components/Ui/Avatar/index.js +4 -0
- package/dist/components/Ui/Badge/Badge.js +43 -0
- package/dist/components/Ui/Badge/index.js +4 -0
- package/dist/components/Ui/Button/Button.js +49 -0
- package/dist/components/Ui/Button/index.js +4 -0
- package/dist/components/Ui/ButtonsArray/ButtonsArray.js +28 -0
- package/dist/components/Ui/ButtonsArray/ButtonsArray.stories.js +78 -0
- package/dist/components/Ui/ButtonsArray/index.js +4 -0
- package/dist/components/Ui/Checkbox/Checkbox.js +39 -0
- package/dist/components/Ui/Checkbox/Checkbox.stories.js +120 -0
- package/dist/components/Ui/Checkbox/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/CliTextareaInput.js +121 -0
- package/dist/components/Ui/CliTextareaInput/index.js +23 -0
- package/dist/components/Ui/CliTextareaInput/utils/escapeHtml/escapeHtml.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/fixJson/fixJson.js +12 -0
- package/dist/components/Ui/CliTextareaInput/utils/highlightSyntax/highlightSyntax.js +20 -0
- package/dist/components/Ui/CliTextareaInput/utils/highlightSyntax/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/index.js +17 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useFixFormat/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useFixFormat/useFixFormat.js +29 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useHistoryNavigation/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useHistoryNavigation/useHistoryNavigation.js +34 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useKeyHandlers/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useKeyHandlers/useKeyHandlers.js +45 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useLineNumbers/index.js +5 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useLineNumbers/useLineNumbers.js +17 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useScrollSync/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useScrollSync/useScrollSync.js +13 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useTextActions/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useTextActions/useTextActions.js +37 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useTextCoursore/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useTextCoursore/useTextCoursore.js +14 -0
- package/dist/components/Ui/CliTextareaInput/utils/index.js +21 -0
- package/dist/components/Ui/CliTextareaInput/utils/processJson/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/processJson/processJson.js +11 -0
- package/dist/components/Ui/CliTextareaInput/utils/processXml/processXml.js +8 -0
- package/dist/components/Ui/CliTextareaInput/utils/processYml/processYml.js +27 -0
- package/dist/components/Ui/CliTextareaInput/utils/types.js +1 -0
- package/dist/components/Ui/CustomLink/CustomLink.js +49 -0
- package/dist/components/Ui/CustomLink/index.js +4 -0
- package/dist/components/Ui/DatePicker/DatePicker.js +175 -0
- package/dist/components/Ui/DatePicker/DatePicker.stories.js +114 -0
- package/dist/components/Ui/DatePicker/index.js +4 -0
- package/dist/components/Ui/DropdownInput/DropdownInput.js +91 -0
- package/dist/components/Ui/DropdownInput/DropdownInput.stories.js +77 -0
- package/dist/components/Ui/DropdownInput/index.js +4 -0
- package/dist/components/Ui/DropdownMenu/DropdownMenu.js +83 -0
- package/dist/components/Ui/DropdownMenu/DropdownMenu.stories.js +50 -0
- package/dist/components/Ui/DropdownMenu/index.js +4 -0
- package/dist/components/Ui/FileUpload/FileUpload.js +615 -0
- package/dist/components/Ui/FileUpload/fn.js +10 -0
- package/dist/components/Ui/FileUpload/index.js +4 -0
- package/dist/components/Ui/FileUpload/types.js +1 -0
- package/dist/components/Ui/Form/FormContext/FormContext.js +5 -0
- package/dist/components/Ui/Form/FormItem/FormItem.js +107 -0
- package/dist/components/Ui/Form/FormItem/fn.js +25 -0
- package/dist/components/Ui/Form/FormItem/types.js +1 -0
- package/dist/components/Ui/Form/FormRoot/FormRoot.js +25 -0
- package/dist/components/Ui/Form/FormRoot/index.js +4 -0
- package/dist/components/Ui/Form/FormRoot/types.js +1 -0
- package/dist/components/Ui/Form/index.js +6 -0
- package/dist/components/Ui/Form/useForm/index.js +4 -0
- package/dist/components/Ui/Form/useForm/useForm.js +111 -0
- package/dist/components/Ui/Form/utils/fn.js +31 -0
- package/dist/components/Ui/Form/utils/types.js +1 -0
- package/dist/components/Ui/Icons/Icons.js +577 -0
- package/dist/components/Ui/Icons/index.js +97 -0
- package/dist/components/Ui/Icons/utils/CreateIcon.js +23 -0
- package/dist/components/Ui/Loader/Loader.js +6 -0
- package/dist/components/Ui/Loader/index.js +4 -0
- package/dist/components/Ui/ModalWindow/ModalWindow.js +50 -0
- package/dist/components/Ui/ModalWindow/index.js +4 -0
- package/dist/components/Ui/Pagination/Pagination.js +294 -0
- package/dist/components/Ui/Pagination/index.js +4 -0
- package/dist/components/Ui/Radio/Radio.js +30 -0
- package/dist/components/Ui/Radio/Radio.stories.js +42 -0
- package/dist/components/Ui/Radio/index.js +4 -0
- package/dist/components/Ui/SearchInput/SearchData.js +30 -0
- package/dist/components/Ui/SearchInput/SearchInput.js +109 -0
- package/dist/components/Ui/Skeleton/Skeleton.js +28 -0
- package/dist/components/Ui/Skeleton/index.js +4 -0
- package/dist/components/Ui/Switch/Switch.js +25 -0
- package/dist/components/Ui/Switch/index.js +4 -0
- package/dist/components/Ui/Table/MemoizedRow/MemoizedRow.js +79 -0
- package/dist/components/Ui/Table/Table.js +160 -0
- package/dist/components/Ui/Table/TableTypes.js +1 -0
- package/dist/components/Ui/Table/index.js +4 -0
- package/dist/components/Ui/Tabs/Tabs.js +24 -0
- package/dist/components/Ui/Tabs/Tabs.stories.js +67 -0
- package/dist/components/Ui/Tabs/index.js +4 -0
- package/dist/components/Ui/TextInput/TextInput.js +85 -0
- package/dist/components/Ui/TextInput/TextInput.stories.js +225 -0
- package/dist/components/Ui/TextInput/index.js +4 -0
- package/dist/components/Ui/TextareaInput/TextareaInput.js +68 -0
- package/dist/components/Ui/TextareaInput/TextareaInput.stories.js +19 -0
- package/dist/components/Ui/TextareaInput/index.js +4 -0
- package/dist/components/Ui/Tooltip/Tooltip.js +92 -0
- package/dist/components/Ui/Tooltip/Tooltip.stories.js +92 -0
- package/dist/components/Ui/Tooltip/index.js +4 -0
- package/dist/context/ToastContext/ToastContext.js +40 -0
- package/dist/context/ToastContext/index.js +5 -0
- package/dist/context/TriaflyContext/TriaflyContext.types.js +1 -0
- package/dist/context/TriaflyContext/TriaflyProvider.js +27 -0
- package/dist/context/TriaflyContext/hooks/index.js +8 -0
- package/dist/context/TriaflyContext/hooks/useBreakpointValue/index.js +4 -0
- package/dist/context/TriaflyContext/hooks/useBreakpointValue/useBreakpointValue.js +11 -0
- package/dist/context/TriaflyContext/hooks/useModal/index.js +4 -0
- package/dist/context/TriaflyContext/hooks/useModal/useModal.js +16 -0
- package/dist/context/TriaflyContext/hooks/useTheme/index.js +4 -0
- package/dist/context/TriaflyContext/hooks/useTheme/useTheme.js +17 -0
- package/dist/context/TriaflyContext/index.js +12 -0
- package/dist/index-2QXL0WYc.js +45 -0
- package/dist/main.d.ts +1243 -0
- package/dist/main.js +164 -0
- package/dist/vite-env.d.js +1 -0
- package/package.json +106 -106
@@ -0,0 +1,175 @@
|
|
1
|
+
import { jsxs as i, jsx as n } from "react/jsx-runtime";
|
2
|
+
import { useState as w, useRef as $, useEffect as N } from "react";
|
3
|
+
import { IconCalendarBlank as A, IconCaretUpDown as G, IconCaretLeft as I, IconCaretRight as S } from "../Icons/Icons.js";
|
4
|
+
import '../../../assets/DatePicker.css';const H = [
|
5
|
+
"Январь",
|
6
|
+
"Февраль",
|
7
|
+
"Март",
|
8
|
+
"Апрель",
|
9
|
+
"Май",
|
10
|
+
"Июнь",
|
11
|
+
"Июль",
|
12
|
+
"Август",
|
13
|
+
"Сентябрь",
|
14
|
+
"Октябрь",
|
15
|
+
"Ноябрь",
|
16
|
+
"Декабрь"
|
17
|
+
], X = ({
|
18
|
+
name: O = "date",
|
19
|
+
value: r = null,
|
20
|
+
onChange: x = () => {
|
21
|
+
},
|
22
|
+
placeholder: L = "Любая дата",
|
23
|
+
className: R = "",
|
24
|
+
inputClassName: T = "",
|
25
|
+
calendarClassName: E = "",
|
26
|
+
minDate: M,
|
27
|
+
maxDate: v
|
28
|
+
}) => {
|
29
|
+
const [c, k] = w(r), [d, u] = w(r ? new Date(r) : /* @__PURE__ */ new Date()), [F, g] = w(!1), m = $(null), D = $(null), j = (t) => {
|
30
|
+
const o = t.getDate(), e = t.getMonth() + 1, p = t.getFullYear();
|
31
|
+
return `${o}-${e < 10 ? "0" + e : e}-${p}`;
|
32
|
+
};
|
33
|
+
N(() => {
|
34
|
+
k(r), r && u(new Date(r));
|
35
|
+
}, [r]), N(() => {
|
36
|
+
D.current && (D.current.value = c ? c.toISOString().split("T")[0] : "");
|
37
|
+
}, [c]), N(() => {
|
38
|
+
const t = (o) => {
|
39
|
+
m.current && !m.current.contains(o.target) && g(!1);
|
40
|
+
};
|
41
|
+
return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
|
42
|
+
}, []);
|
43
|
+
const y = (t, o = 0) => {
|
44
|
+
const e = new Date(
|
45
|
+
d.getFullYear(),
|
46
|
+
d.getMonth() + o,
|
47
|
+
t
|
48
|
+
);
|
49
|
+
k(e), x(e), u(new Date(e)), g(!1);
|
50
|
+
}, Y = (t) => {
|
51
|
+
u((o) => {
|
52
|
+
const e = new Date(o);
|
53
|
+
return e.setMonth(e.getMonth() + t), e;
|
54
|
+
});
|
55
|
+
}, b = (t) => {
|
56
|
+
u((o) => {
|
57
|
+
const e = new Date(o);
|
58
|
+
return e.setFullYear(e.getFullYear() + t), e;
|
59
|
+
});
|
60
|
+
}, P = () => {
|
61
|
+
const t = d.getFullYear(), o = d.getMonth(), e = /* @__PURE__ */ new Date(), p = new Date(t, o, 1), B = new Date(t, o + 1, 0).getDate(), U = p.getDay() || 7, W = new Date(t, o, 0).getDate(), q = U - 1, h = [];
|
62
|
+
for (let a = q; a > 0; a--) {
|
63
|
+
const s = W - a + 1, l = new Date(t, o - 1, s), f = l.getDate() === e.getDate() && l.getMonth() === e.getMonth() && l.getFullYear() === e.getFullYear();
|
64
|
+
h.push(
|
65
|
+
/* @__PURE__ */ n(
|
66
|
+
"div",
|
67
|
+
{
|
68
|
+
className: `day other-month ${f ? "today" : ""}`,
|
69
|
+
onClick: () => y(s, -1),
|
70
|
+
children: s
|
71
|
+
},
|
72
|
+
`prev-${s}`
|
73
|
+
)
|
74
|
+
);
|
75
|
+
}
|
76
|
+
for (let a = 1; a <= B; a++) {
|
77
|
+
const s = new Date(t, o, a), l = c && s.getDate() === c.getDate() && s.getMonth() === c.getMonth() && s.getFullYear() === c.getFullYear(), f = s.getDate() === e.getDate() && s.getMonth() === e.getMonth() && s.getFullYear() === e.getFullYear(), C = M && s < M || v && s > v;
|
78
|
+
h.push(
|
79
|
+
/* @__PURE__ */ n(
|
80
|
+
"div",
|
81
|
+
{
|
82
|
+
className: `day ${l ? "selected" : ""} ${C ? "disabled" : ""} ${f ? "today" : ""}`,
|
83
|
+
onClick: () => !C && y(a),
|
84
|
+
children: a
|
85
|
+
},
|
86
|
+
`current-${a}`
|
87
|
+
)
|
88
|
+
);
|
89
|
+
}
|
90
|
+
const z = 42 - h.length;
|
91
|
+
for (let a = 1; a <= z; a++) {
|
92
|
+
const s = new Date(t, o + 1, a), l = s.getDate() === e.getDate() && s.getMonth() === e.getMonth() && s.getFullYear() === e.getFullYear();
|
93
|
+
h.push(
|
94
|
+
/* @__PURE__ */ n(
|
95
|
+
"div",
|
96
|
+
{
|
97
|
+
className: `day other-month ${l ? "today" : ""}`,
|
98
|
+
onClick: () => y(a, 1),
|
99
|
+
children: a
|
100
|
+
},
|
101
|
+
`next-${a}`
|
102
|
+
)
|
103
|
+
);
|
104
|
+
}
|
105
|
+
return h;
|
106
|
+
};
|
107
|
+
return /* @__PURE__ */ i("div", { className: `datepicker ${R}`, ref: m, children: [
|
108
|
+
/* @__PURE__ */ n(
|
109
|
+
"input",
|
110
|
+
{
|
111
|
+
type: "date",
|
112
|
+
ref: D,
|
113
|
+
name: O,
|
114
|
+
className: "native-input",
|
115
|
+
"aria-hidden": "true"
|
116
|
+
}
|
117
|
+
),
|
118
|
+
/* @__PURE__ */ i("div", { className: `datepicker-input ${T}`, onClick: () => g(!F), children: [
|
119
|
+
/* @__PURE__ */ n(A, {}),
|
120
|
+
/* @__PURE__ */ n("span", { className: "placeholder", children: c ? j(c) : L }),
|
121
|
+
/* @__PURE__ */ n(G, { className: "caret" })
|
122
|
+
] }),
|
123
|
+
F && /* @__PURE__ */ i("div", { className: `datepicker-calendar ${E}`, children: [
|
124
|
+
/* @__PURE__ */ i("div", { className: "calendar-controls", children: [
|
125
|
+
/* @__PURE__ */ i("div", { className: "month-control", children: [
|
126
|
+
/* @__PURE__ */ n(
|
127
|
+
"button",
|
128
|
+
{
|
129
|
+
className: "nav-button",
|
130
|
+
onClick: () => Y(-1),
|
131
|
+
"aria-label": "Предыдущий месяц",
|
132
|
+
children: /* @__PURE__ */ n(I, {})
|
133
|
+
}
|
134
|
+
),
|
135
|
+
/* @__PURE__ */ n("span", { className: "current-month", children: H[d.getMonth()] }),
|
136
|
+
/* @__PURE__ */ n(
|
137
|
+
"button",
|
138
|
+
{
|
139
|
+
className: "nav-button",
|
140
|
+
onClick: () => Y(1),
|
141
|
+
"aria-label": "Следующий месяц",
|
142
|
+
children: /* @__PURE__ */ n(S, {})
|
143
|
+
}
|
144
|
+
)
|
145
|
+
] }),
|
146
|
+
/* @__PURE__ */ i("div", { className: "year-control", children: [
|
147
|
+
/* @__PURE__ */ n(
|
148
|
+
"button",
|
149
|
+
{
|
150
|
+
className: "nav-button",
|
151
|
+
onClick: () => b(-1),
|
152
|
+
"aria-label": "Предыдущий год",
|
153
|
+
children: /* @__PURE__ */ n(I, {})
|
154
|
+
}
|
155
|
+
),
|
156
|
+
/* @__PURE__ */ n("span", { className: "current-year", children: d.getFullYear() }),
|
157
|
+
/* @__PURE__ */ n(
|
158
|
+
"button",
|
159
|
+
{
|
160
|
+
className: "nav-button",
|
161
|
+
onClick: () => b(1),
|
162
|
+
"aria-label": "Следующий год",
|
163
|
+
children: /* @__PURE__ */ n(S, {})
|
164
|
+
}
|
165
|
+
)
|
166
|
+
] })
|
167
|
+
] }),
|
168
|
+
/* @__PURE__ */ n("div", { className: "calendar-weekdays", children: ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"].map((t) => /* @__PURE__ */ n("div", { className: "weekday", children: t }, t)) }),
|
169
|
+
/* @__PURE__ */ n("div", { className: "calendar-days", children: P() })
|
170
|
+
] })
|
171
|
+
] });
|
172
|
+
};
|
173
|
+
export {
|
174
|
+
X as DatePicker
|
175
|
+
};
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import { jsxs as a, jsx as e } from "react/jsx-runtime";
|
2
|
+
import l from "react";
|
3
|
+
import { DatePicker as r } from "./DatePicker.js";
|
4
|
+
const m = {
|
5
|
+
title: "UIKit/DatePicker",
|
6
|
+
component: r,
|
7
|
+
tags: ["autodocs"],
|
8
|
+
argTypes: {
|
9
|
+
value: {
|
10
|
+
control: "date",
|
11
|
+
description: "Выбранная дата (timestamp)"
|
12
|
+
},
|
13
|
+
onChange: {
|
14
|
+
action: "dateChanged",
|
15
|
+
description: "Обработчик изменения даты"
|
16
|
+
},
|
17
|
+
className: {
|
18
|
+
control: "text",
|
19
|
+
description: "Класс для основного контейнера"
|
20
|
+
},
|
21
|
+
inputClassName: {
|
22
|
+
control: "text",
|
23
|
+
description: "Класс для кастомного инпута"
|
24
|
+
},
|
25
|
+
calendarClassName: {
|
26
|
+
control: "text",
|
27
|
+
description: "Класс для календаря"
|
28
|
+
},
|
29
|
+
placeholder: {
|
30
|
+
control: "text",
|
31
|
+
description: "Текст плейсхолдера"
|
32
|
+
},
|
33
|
+
minDate: {
|
34
|
+
control: "date",
|
35
|
+
description: "Минимальная доступная дата"
|
36
|
+
},
|
37
|
+
maxDate: {
|
38
|
+
control: "date",
|
39
|
+
description: "Максимальная доступная дата"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}, u = {
|
43
|
+
args: {
|
44
|
+
placeholder: "Любая дата"
|
45
|
+
}
|
46
|
+
}, x = {
|
47
|
+
args: {
|
48
|
+
value: new Date(2023, 5, 15),
|
49
|
+
placeholder: "Выберите дату"
|
50
|
+
}
|
51
|
+
}, h = {
|
52
|
+
args: {
|
53
|
+
minDate: new Date(2023, 0, 1),
|
54
|
+
maxDate: new Date(2023, 11, 31)
|
55
|
+
}
|
56
|
+
}, g = {
|
57
|
+
args: {
|
58
|
+
inputClassName: "custom-input",
|
59
|
+
calendarClassName: "custom-calendar"
|
60
|
+
},
|
61
|
+
decorators: [
|
62
|
+
(o) => /* @__PURE__ */ a("div", { children: [
|
63
|
+
/* @__PURE__ */ e("style", { children: `
|
64
|
+
.custom-input {
|
65
|
+
border: 2px solid #6366f1;
|
66
|
+
background-color: #f0f0ff;
|
67
|
+
padding: 12px;
|
68
|
+
border-radius: 8px;
|
69
|
+
}
|
70
|
+
.custom-calendar {
|
71
|
+
border: 2px solid #6366f1;
|
72
|
+
box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
|
73
|
+
}
|
74
|
+
.custom-calendar .day.selected {
|
75
|
+
background-color: #6366f1;
|
76
|
+
}
|
77
|
+
` }),
|
78
|
+
/* @__PURE__ */ e(o, {})
|
79
|
+
] })
|
80
|
+
]
|
81
|
+
}, D = {
|
82
|
+
render: function() {
|
83
|
+
const [t, n] = l.useState(null);
|
84
|
+
return /* @__PURE__ */ a("div", { style: { maxWidth: "300px" }, children: [
|
85
|
+
/* @__PURE__ */ e(r, { value: t, onChange: n, placeholder: "Контролируемый выбор" }),
|
86
|
+
/* @__PURE__ */ a("div", { style: { marginTop: "16px", fontSize: "14px" }, children: [
|
87
|
+
"Выбрано: ",
|
88
|
+
t ? t.toLocaleDateString("ru-RU") : "дата не выбрана"
|
89
|
+
] })
|
90
|
+
] });
|
91
|
+
}
|
92
|
+
}, f = {
|
93
|
+
render: function() {
|
94
|
+
const [t, n] = l.useState(null);
|
95
|
+
return /* @__PURE__ */ a("form", { onSubmit: (i) => {
|
96
|
+
i.preventDefault(), alert(`Выбрана дата: ${t == null ? void 0 : t.toLocaleDateString("ru-RU")}`);
|
97
|
+
}, style: { maxWidth: "300px" }, children: [
|
98
|
+
/* @__PURE__ */ a("div", { style: { marginBottom: "16px" }, children: [
|
99
|
+
/* @__PURE__ */ e("label", { style: { display: "block", marginBottom: "4px" }, children: "Дата события:" }),
|
100
|
+
/* @__PURE__ */ e(r, { name: "eventDate", value: t, onChange: n })
|
101
|
+
] }),
|
102
|
+
/* @__PURE__ */ e("button", { type: "submit", children: "Отправить" })
|
103
|
+
] });
|
104
|
+
}
|
105
|
+
};
|
106
|
+
export {
|
107
|
+
D as Controlled,
|
108
|
+
g as CustomStyled,
|
109
|
+
u as Default,
|
110
|
+
f as InForm,
|
111
|
+
h as WithDateRange,
|
112
|
+
x as WithInitialDate,
|
113
|
+
m as default
|
114
|
+
};
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import { jsxs as c, jsx as n } from "react/jsx-runtime";
|
2
|
+
import { useState as m, useRef as O, useEffect as g } from "react";
|
3
|
+
import { IconCaretUpDown as E, IconWarningCircle as P } from "../Icons/Icons.js";
|
4
|
+
import '../../../assets/DropdownInput.css';const j = ({
|
5
|
+
label: v,
|
6
|
+
options: i,
|
7
|
+
value: o,
|
8
|
+
onChange: f,
|
9
|
+
name: C = "DropdownInput",
|
10
|
+
placeholder: r,
|
11
|
+
errorMessage: d = !1,
|
12
|
+
isDisabled: h = !1,
|
13
|
+
className: k = ""
|
14
|
+
}) => {
|
15
|
+
var w;
|
16
|
+
const [u, p] = m(!1), [s, N] = m(o || ""), [I, x] = m(!1), t = O(null);
|
17
|
+
g(() => {
|
18
|
+
const e = (l) => {
|
19
|
+
t.current && !t.current.contains(l.target) && p(!1);
|
20
|
+
};
|
21
|
+
return document.addEventListener("click", e), () => {
|
22
|
+
document.removeEventListener("click", e);
|
23
|
+
};
|
24
|
+
}, []), g(() => {
|
25
|
+
N(o || "");
|
26
|
+
}, [o]);
|
27
|
+
const b = (e) => {
|
28
|
+
N(e), p(!1), f && f(e);
|
29
|
+
}, $ = (e) => {
|
30
|
+
var l;
|
31
|
+
if (e.stopPropagation(), !u) {
|
32
|
+
const a = (l = t.current) == null ? void 0 : l.getBoundingClientRect(), D = window.innerHeight - ((a == null ? void 0 : a.bottom) || 0);
|
33
|
+
x(D < 304);
|
34
|
+
}
|
35
|
+
p((a) => !a);
|
36
|
+
};
|
37
|
+
return /* @__PURE__ */ c("div", { className: `dropdown-input ${k}`, ref: t, children: [
|
38
|
+
/* @__PURE__ */ c(
|
39
|
+
"select",
|
40
|
+
{
|
41
|
+
name: C,
|
42
|
+
value: s,
|
43
|
+
onChange: (e) => b(e.target.value),
|
44
|
+
className: "dropdown-input__native",
|
45
|
+
disabled: h,
|
46
|
+
children: [
|
47
|
+
/* @__PURE__ */ n("option", { value: "", disabled: !0, children: r }),
|
48
|
+
i.map((e) => /* @__PURE__ */ n("option", { value: e.value, children: e.label }, e.value))
|
49
|
+
]
|
50
|
+
}
|
51
|
+
),
|
52
|
+
v && /* @__PURE__ */ n("label", { children: v }),
|
53
|
+
/* @__PURE__ */ c(
|
54
|
+
"div",
|
55
|
+
{
|
56
|
+
className: `input-box
|
57
|
+
${u ? "opened" : ""}
|
58
|
+
${h ? "disabled" : ""}
|
59
|
+
${d ? "invalid" : ""}`,
|
60
|
+
onClick: $,
|
61
|
+
children: [
|
62
|
+
/* @__PURE__ */ n("span", { className: "input-value", children: s === void 0 ? (
|
63
|
+
// Если значение не передано
|
64
|
+
/* @__PURE__ */ n("span", { className: "placeholder", children: r })
|
65
|
+
) : ((w = i.find((e) => e.value === s)) == null ? void 0 : w.label) || /* @__PURE__ */ n("span", { className: "placeholder", children: r }) }),
|
66
|
+
/* @__PURE__ */ n(E, { className: "caret" }),
|
67
|
+
u && /* @__PURE__ */ n("ul", { className: `options ${I ? "above" : ""}`, children: i.map((e) => /* @__PURE__ */ n(
|
68
|
+
"li",
|
69
|
+
{
|
70
|
+
onClick: (l) => {
|
71
|
+
l.stopPropagation(), b(e.value);
|
72
|
+
},
|
73
|
+
className: s === e.value ? "option--selected" : "",
|
74
|
+
children: e.label
|
75
|
+
},
|
76
|
+
e.value
|
77
|
+
)) })
|
78
|
+
]
|
79
|
+
}
|
80
|
+
),
|
81
|
+
d && /* @__PURE__ */ c("span", { className: "helper-text error", children: [
|
82
|
+
/* @__PURE__ */ n(P, { className: "icon", size: 12 }),
|
83
|
+
d
|
84
|
+
] })
|
85
|
+
] });
|
86
|
+
};
|
87
|
+
j.displayName = "DropdownInput";
|
88
|
+
export {
|
89
|
+
j as DropdownInput,
|
90
|
+
j as default
|
91
|
+
};
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
2
|
+
import s from "react";
|
3
|
+
import { DropdownInput as a } from "./DropdownInput.js";
|
4
|
+
const h = {
|
5
|
+
title: "UIKit/DropdownInput",
|
6
|
+
component: a,
|
7
|
+
parameters: { layout: "centered" },
|
8
|
+
argTypes: {
|
9
|
+
label: { control: "text" },
|
10
|
+
name: { control: "text" },
|
11
|
+
options: { control: "object" },
|
12
|
+
placeholder: { control: "text" },
|
13
|
+
value: { control: "text" },
|
14
|
+
errorMessage: { control: "text" },
|
15
|
+
isDisabled: { control: "boolean" }
|
16
|
+
}
|
17
|
+
}, e = (l) => {
|
18
|
+
const [o, t] = s.useState(l.value || "");
|
19
|
+
return /* @__PURE__ */ r(a, { ...l, value: o, onChange: (n) => {
|
20
|
+
t(n);
|
21
|
+
} });
|
22
|
+
}, d = e.bind({});
|
23
|
+
d.args = {
|
24
|
+
label: "Выберите опцию",
|
25
|
+
name: "dropdown",
|
26
|
+
options: [
|
27
|
+
{ value: "1", label: "Опция 1" },
|
28
|
+
{ value: "2", label: "Опция 2" },
|
29
|
+
{ value: "3", label: "Опция 3" }
|
30
|
+
],
|
31
|
+
placeholder: "Выберите..."
|
32
|
+
};
|
33
|
+
const c = e.bind({});
|
34
|
+
c.args = {
|
35
|
+
label: "Выберите опцию",
|
36
|
+
name: "dropdown",
|
37
|
+
options: [
|
38
|
+
{ value: "1", label: "Опция 1" },
|
39
|
+
{ value: "2", label: "Опция 2" },
|
40
|
+
{ value: "3", label: "Опция 3" }
|
41
|
+
],
|
42
|
+
placeholder: "Выберите...",
|
43
|
+
value: "2"
|
44
|
+
// Предустановленное значение
|
45
|
+
};
|
46
|
+
const u = e.bind({});
|
47
|
+
u.args = {
|
48
|
+
label: "Выберите опцию",
|
49
|
+
name: "dropdown",
|
50
|
+
options: [
|
51
|
+
{ value: "1", label: "Опция 1" },
|
52
|
+
{ value: "2", label: "Опция 2" },
|
53
|
+
{ value: "3", label: "Опция 3" }
|
54
|
+
],
|
55
|
+
placeholder: "Выберите...",
|
56
|
+
isDisabled: !0
|
57
|
+
// Отключаем селект
|
58
|
+
};
|
59
|
+
const b = e.bind({});
|
60
|
+
b.args = {
|
61
|
+
label: "Выберите опцию",
|
62
|
+
name: "dropdown",
|
63
|
+
options: [
|
64
|
+
{ value: "1", label: "Опция 1" },
|
65
|
+
{ value: "2", label: "Опция 2" },
|
66
|
+
{ value: "3", label: "Опция 3" }
|
67
|
+
],
|
68
|
+
placeholder: "Выберите...",
|
69
|
+
errorMessage: "Пожалуйста, выберите опцию."
|
70
|
+
};
|
71
|
+
export {
|
72
|
+
d as Default,
|
73
|
+
u as Disabled,
|
74
|
+
b as WithErrorMessage,
|
75
|
+
c as WithSelectedValue,
|
76
|
+
h as default
|
77
|
+
};
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import { jsxs as R, jsx as h } from "react/jsx-runtime";
|
2
|
+
import { useState as a, useRef as b, useLayoutEffect as C } from "react";
|
3
|
+
import '../../../assets/DropdownMenu.css';const O = ({
|
4
|
+
content: m,
|
5
|
+
horizontalPosition: s = "right",
|
6
|
+
verticalPosition: c = "bottom",
|
7
|
+
iconTrigger: N
|
8
|
+
}) => {
|
9
|
+
const [d, o] = a(!1), [j, n] = a(s), [H, l] = a(c), f = b(null), u = b(null);
|
10
|
+
C(() => {
|
11
|
+
if (d && f.current && u.current) {
|
12
|
+
const e = u.current.getBoundingClientRect(), t = f.current.getBoundingClientRect(), r = window.innerHeight, i = window.innerWidth;
|
13
|
+
if (c === "bottom" && e.bottom + t.height > r ? l("top") : c === "top" && e.top - t.height < 0 ? l("bottom") : l(c), s === "left" && e.left + t.width > i)
|
14
|
+
n("right");
|
15
|
+
else if (s === "right" && e.right - t.width < 0)
|
16
|
+
n("left");
|
17
|
+
else if (s === "center") {
|
18
|
+
const g = e.left + e.width / 2 - t.width / 2;
|
19
|
+
g < 0 ? n("left") : g + t.width > i ? n("right") : n("center");
|
20
|
+
} else
|
21
|
+
n(s);
|
22
|
+
}
|
23
|
+
}, [d, s, c]), C(() => {
|
24
|
+
const e = (t) => {
|
25
|
+
f.current && !f.current.contains(t.target) && u.current && !u.current.contains(t.target) && o(!1);
|
26
|
+
};
|
27
|
+
return d && document.addEventListener("click", e), () => {
|
28
|
+
document.removeEventListener("click", e);
|
29
|
+
};
|
30
|
+
}, [d]);
|
31
|
+
const k = () => {
|
32
|
+
var e, t;
|
33
|
+
if (!d) {
|
34
|
+
const r = (e = u.current) == null ? void 0 : e.getBoundingClientRect(), i = (t = f.current) == null ? void 0 : t.getBoundingClientRect();
|
35
|
+
if (r && i) {
|
36
|
+
const g = window.innerHeight, w = window.innerWidth;
|
37
|
+
if (c === "bottom" && r.bottom + i.height > g ? l("top") : c === "top" && r.top - i.height < 0 ? l("bottom") : l(c), s === "left" && r.left + i.width > w)
|
38
|
+
n("right");
|
39
|
+
else if (s === "right" && r.right - i.width < 0)
|
40
|
+
n("left");
|
41
|
+
else if (s === "center") {
|
42
|
+
const p = r.left + r.width / 2 - i.width / 2;
|
43
|
+
p < 0 ? n("left") : p + i.width > w ? n("right") : n("center");
|
44
|
+
} else
|
45
|
+
n(s);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
o(!d);
|
49
|
+
}, x = (e) => {
|
50
|
+
e && e(), o(!1);
|
51
|
+
};
|
52
|
+
return /* @__PURE__ */ R("div", { className: `dropdowm-menu ${d ? "open" : ""}`, children: [
|
53
|
+
/* @__PURE__ */ h("div", { className: "menu-trigger", onClick: k, ref: u, children: N || /* @__PURE__ */ h("div", { className: "dots" }) }),
|
54
|
+
/* @__PURE__ */ h("div", { className: "fader" }),
|
55
|
+
/* @__PURE__ */ h(
|
56
|
+
"ul",
|
57
|
+
{
|
58
|
+
className: "menu-list",
|
59
|
+
"data-x-fit": j,
|
60
|
+
"data-y-fit": H,
|
61
|
+
ref: f,
|
62
|
+
children: m == null ? void 0 : m.map(({ icon: e, isDanger: t, title: r, onClick: i }, g) => /* @__PURE__ */ R(
|
63
|
+
"li",
|
64
|
+
{
|
65
|
+
onClick: () => {
|
66
|
+
i && x(i);
|
67
|
+
},
|
68
|
+
className: `menu-item ${t ? "danger" : ""}`,
|
69
|
+
children: [
|
70
|
+
e,
|
71
|
+
/* @__PURE__ */ h("span", { className: "label", children: r })
|
72
|
+
]
|
73
|
+
},
|
74
|
+
g
|
75
|
+
))
|
76
|
+
}
|
77
|
+
)
|
78
|
+
] });
|
79
|
+
};
|
80
|
+
export {
|
81
|
+
O as DropdownMenu,
|
82
|
+
O as default
|
83
|
+
};
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
2
|
+
import { IconEye as t, IconRoleX as n, IconTrash as i } from "../Icons/Icons.js";
|
3
|
+
import { DropdownMenu as e } from "./DropdownMenu.js";
|
4
|
+
const l = {
|
5
|
+
title: "UIKit/DropdownMenu",
|
6
|
+
component: e,
|
7
|
+
tags: ["autodocs"],
|
8
|
+
// Автоматическая генерация документации
|
9
|
+
argTypes: {
|
10
|
+
content: {
|
11
|
+
control: "object",
|
12
|
+
// Позволяет редактировать content в интерфейсе Storybook
|
13
|
+
description: "Массив элементов меню"
|
14
|
+
},
|
15
|
+
horizontalPosition: {
|
16
|
+
control: "select",
|
17
|
+
options: ["left", "center", "right"],
|
18
|
+
description: "Позиционирование меню относительно триггера"
|
19
|
+
},
|
20
|
+
verticalPosition: {
|
21
|
+
control: "select",
|
22
|
+
options: ["top", "bottom"],
|
23
|
+
description: "Позиционирование меню относительно триггера"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}, a = {
|
27
|
+
args: {
|
28
|
+
content: [
|
29
|
+
{
|
30
|
+
icon: /* @__PURE__ */ o(t, {}),
|
31
|
+
title: "Просмотр"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
icon: /* @__PURE__ */ o(n, {}),
|
35
|
+
title: "Назначить другую роль"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
icon: /* @__PURE__ */ o(i, {}),
|
39
|
+
title: "Удалить",
|
40
|
+
isDanger: !0
|
41
|
+
}
|
42
|
+
],
|
43
|
+
horizontalPosition: "left",
|
44
|
+
verticalPosition: "bottom"
|
45
|
+
}
|
46
|
+
};
|
47
|
+
export {
|
48
|
+
a as Default,
|
49
|
+
l as default
|
50
|
+
};
|