kui-complex 0.0.1 → 0.0.3

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/dist/index.es.js CHANGED
@@ -1,2 +1,750 @@
1
+ import { jsx as jsx$1, jsxs, Fragment } from '@emotion/react/jsx-runtime';
2
+ import styled from '@emotion/styled';
3
+ import { css } from '@emotion/react';
4
+ import { jsx, jsxs as jsxs$1, Fragment as Fragment$1 } from 'react/jsx-runtime';
5
+ import { Caption, Button, Container, Grid, InputWithAdornments, Heading, IconButton, LinearProgress, Divider, Modal, Switch as Switch$1 } from 'kui-basic';
6
+ import { themeOld } from 'kui-basic/src';
7
+ import * as React from 'react';
8
+ import { useEffect, useRef, useState, forwardRef } from 'react';
9
+ import { useHistory } from 'react-router-dom';
10
+ import { HalfArrowIcon, PrevArrowIcon, NextArrowIcon, CalendarIcon, ArrowBackIcon, ArrowNextIcon, ClosedEyeIcon, OpenEyeIcon, CheckIcon } from 'kui-icon/src';
11
+ import _ from 'lodash';
12
+ import DatePicker, { registerLocale } from 'react-datepicker';
13
+ import { Controller } from 'react-hook-form';
14
+ import InputMask from 'react-input-mask';
15
+ import { scroller, Events, Link, animateScroll, Element } from 'react-scroll';
16
+ import ru from 'date-fns/locale/ru';
17
+ import { DateTime } from 'luxon';
18
+ import Swiper from 'react-id-swiper';
1
19
 
20
+ /******************************************************************************
21
+ Copyright (c) Microsoft Corporation.
22
+
23
+ Permission to use, copy, modify, and/or distribute this software for any
24
+ purpose with or without fee is hereby granted.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
27
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
28
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
29
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
30
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
31
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
32
+ PERFORMANCE OF THIS SOFTWARE.
33
+ ***************************************************************************** */
34
+
35
+ var __assign = function() {
36
+ __assign = Object.assign || function __assign(t) {
37
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
38
+ s = arguments[i];
39
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
40
+ }
41
+ return t;
42
+ };
43
+ return __assign.apply(this, arguments);
44
+ };
45
+
46
+ function __rest(s, e) {
47
+ var t = {};
48
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
+ t[p] = s[p];
50
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
+ t[p[i]] = s[p[i]];
54
+ }
55
+ return t;
56
+ }
57
+
58
+ function __makeTemplateObject(cooked, raw) {
59
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
60
+ return cooked;
61
+ }
62
+
63
+ var paletteBasic = themeOld.palette, themeBasicParams = __rest(themeOld, ["palette"]);
64
+ var palette = {
65
+ brand: __assign(__assign({}, paletteBasic.primary), { background: paletteBasic.primary.light2 }),
66
+ grey: {
67
+ seventy: paletteBasic.secondary.main,
68
+ sixty: paletteBasic.secondary.gray60,
69
+ fiftyP: paletteBasic.secondary.gray50,
70
+ fourty: paletteBasic.secondary.gray40,
71
+ thirty: paletteBasic.secondary.gray30,
72
+ fifteenB: paletteBasic.secondary.gray15,
73
+ zero: paletteBasic.secondary.white,
74
+ },
75
+ background: __assign(__assign({}, paletteBasic.background), { light1: paletteBasic.background.main, light4: "#C5C6C7" }),
76
+ green: {
77
+ fiftyP: paletteBasic.success.main,
78
+ seventy: paletteBasic.success.green70,
79
+ sixty: paletteBasic.success.green60,
80
+ ten: paletteBasic.success.green10,
81
+ five: paletteBasic.success.green5,
82
+ },
83
+ red: {
84
+ fiftyP: paletteBasic.error.main,
85
+ seventy: paletteBasic.error.red70,
86
+ sixty: paletteBasic.error.red60,
87
+ ten: paletteBasic.error.red10,
88
+ five: paletteBasic.error.red5,
89
+ },
90
+ blue: {
91
+ fiftyP: paletteBasic.info.main,
92
+ seventy: paletteBasic.info.blue70,
93
+ sixty: paletteBasic.info.blue60,
94
+ ten: paletteBasic.info.blue10,
95
+ five: paletteBasic.info.blue5,
96
+ },
97
+ purple: {
98
+ fiftyP: paletteBasic.purple.main,
99
+ seventy: paletteBasic.purple.purple70,
100
+ sixty: paletteBasic.purple.purple60,
101
+ ten: paletteBasic.purple.purple10,
102
+ five: paletteBasic.purple.purple5,
103
+ },
104
+ };
105
+ var theme = __assign({ palette: palette }, themeBasicParams);
106
+
107
+ var UndefinedAvatar = function (_a) {
108
+ var label = _a.label, otherProps = __rest(_a, ["label"]);
109
+ if (!label) {
110
+ return jsx("div", {});
111
+ }
112
+ var formattedLabel = label
113
+ .split(" ")
114
+ .map(function (el) { return el[0]; })
115
+ .slice(0, 3)
116
+ .join("");
117
+ return (jsx(Wrapper$8, __assign({ "data-testid": "undefined_avatar" }, { children: jsx(Caption, __assign({ size: "xs", weight: 600, colorGroup: "brand", color: "main" }, otherProps, { children: formattedLabel })) })));
118
+ };
119
+ var Wrapper$8 = styled.div(templateObject_1$n || (templateObject_1$n = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n border-radius: 50%;\n background-color: ", ";\n display: flex;\n justify-content: center;\n align-items: center;\n &,\n p {\n transition: all ease-out 0.3s;\n }\n @media (min-width: 900px) {\n &:hover {\n background-color: ", ";\n p {\n color: white;\n }\n }\n }\n"], ["\n width: 100%;\n height: 100%;\n border-radius: 50%;\n background-color: ", ";\n display: flex;\n justify-content: center;\n align-items: center;\n &,\n p {\n transition: all ease-out 0.3s;\n }\n @media (min-width: 900px) {\n &:hover {\n background-color: ", ";\n p {\n color: white;\n }\n }\n }\n"])), theme.palette.brand.light, theme.palette.brand.main);
120
+ var templateObject_1$n;
121
+
122
+ var Avatar = function (_a) {
123
+ var size = _a.size, fullName = _a.fullName, imageUrl = _a.imageUrl, avatarRef = _a.avatarRef, otherProps = __rest(_a, ["size", "fullName", "imageUrl", "avatarRef"]);
124
+ return (jsx$1(Wrapper$7, __assign({ css: sizeStyles[size], ref: avatarRef }, otherProps, { children: imageUrl ? (jsx$1(StyledImage, { "data-testid": "avatar_image", src: imageUrl, alt: "avatar" })) : (jsx$1(StyledUndefinedAvatar, { label: fullName, avatarSize: size })) })));
125
+ };
126
+ var Wrapper$7 = styled.div(templateObject_1$m || (templateObject_1$m = __makeTemplateObject(["\n border-radius: 50%;\n overflow: hidden;\n cursor: pointer;\n"], ["\n border-radius: 50%;\n overflow: hidden;\n cursor: pointer;\n"])));
127
+ var StyledImage = styled.img(templateObject_2$d || (templateObject_2$d = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n border-radius: 50%;\n object-fit: cover;\n"], ["\n width: 100%;\n height: 100%;\n border-radius: 50%;\n object-fit: cover;\n"])));
128
+ var largeAvatarCSS = function (_a) {
129
+ var avatarSize = _a.avatarSize;
130
+ return avatarSize === "lg" && css(templateObject_3$5 || (templateObject_3$5 = __makeTemplateObject(["\n font-size: 32px;\n "], ["\n font-size: 32px;\n "])));
131
+ };
132
+ var StyledUndefinedAvatar = styled(UndefinedAvatar, {
133
+ shouldForwardProp: function (prop) { return prop !== "size"; },
134
+ })(templateObject_4$1 || (templateObject_4$1 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), largeAvatarCSS);
135
+ var sizeStyles = {
136
+ s: css(templateObject_5$1 || (templateObject_5$1 = __makeTemplateObject(["\n width: 40px;\n height: 40px;\n @media (max-width: 600px) {\n width: 32px;\n height: 32px;\n }\n "], ["\n width: 40px;\n height: 40px;\n @media (max-width: 600px) {\n width: 32px;\n height: 32px;\n }\n "]))),
137
+ lg: css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n width: 80px;\n height: 80px;\n "], ["\n width: 80px;\n height: 80px;\n "]))),
138
+ };
139
+ var templateObject_1$m, templateObject_2$d, templateObject_3$5, templateObject_4$1, templateObject_5$1, templateObject_6;
140
+
141
+ var ButtonTab = function (_a) {
142
+ var index = _a.index, onClick = _a.onClick, isActive = _a.isActive, label = _a.label;
143
+ var handleClick = function () {
144
+ onClick(index);
145
+ };
146
+ return (jsx$1(StyledButton, __assign({ variant: isActive ? "orange" : "white", captionWeight: isActive ? 600 : 400, onClick: handleClick, css: !isActive && inactiveStyles }, { children: label })));
147
+ };
148
+ var StyledButton = styled(Button)(templateObject_1$l || (templateObject_1$l = __makeTemplateObject(["\n margin-right: 24px;\n &:last-of-type {\n margin-right: 0;\n }\n"], ["\n margin-right: 24px;\n &:last-of-type {\n margin-right: 0;\n }\n"])));
149
+ var inactiveStyles = css(templateObject_2$c || (templateObject_2$c = __makeTemplateObject(["\n p {\n color: ", ";\n }\n"], ["\n p {\n color: ", ";\n }\n"])), theme.palette.grey.seventy);
150
+ var templateObject_1$l, templateObject_2$c;
151
+
152
+ var ButtonsPanel = function (_a) {
153
+ var tabs = _a.tabs, tabPanels = _a.tabPanels, paths = _a.paths, activeTab = _a.activeTab, isSticky = _a.isSticky, onChange = _a.onChange, otherProps = __rest(_a, ["tabs", "tabPanels", "paths", "activeTab", "isSticky", "onChange"]);
154
+ var _b = React.useState(Number(activeTab)), value = _b[0], setValue = _b[1];
155
+ var history = useHistory();
156
+ var handleChange = function (newValue) {
157
+ setValue(newValue);
158
+ if (paths && paths.length > 0) {
159
+ history.push(paths[newValue]);
160
+ }
161
+ if (onChange) {
162
+ onChange();
163
+ }
164
+ };
165
+ useEffect(function () {
166
+ setValue(Number(activeTab));
167
+ }, [activeTab]);
168
+ return (jsxs(Fragment, { children: [jsx$1(StyledContainer$1, __assign({ css: isSticky && { position: "sticky" } }, otherProps, { children: jsx$1(Container, { children: tabs.map(function (item, index) { return (jsx$1(ButtonTab, { index: index, onClick: handleChange, isActive: index === value, label: item.label }, item.label)); }) }) })), tabPanels.map(function (item, index) { return (jsx$1(Content, __assign({ role: "tabpanel", hidden: value !== index }, { children: value === index && jsx$1(Fragment, { children: item }) }), index)); })] }));
169
+ };
170
+ ButtonsPanel.defaultProps = {
171
+ isSticky: false,
172
+ };
173
+ var Content = styled.div(templateObject_1$k || (templateObject_1$k = __makeTemplateObject(["\n height: 100%;\n"], ["\n height: 100%;\n"])));
174
+ var StyledContainer$1 = styled.div(templateObject_2$b || (templateObject_2$b = __makeTemplateObject(["\n background: ", ";\n top: 80px;\n z-index: 4;\n padding-top: 16px;\n padding-bottom: 24px;\n @media (max-width: 1200px) {\n padding-bottom: 18px;\n }\n @media (max-width: 600px) {\n top: 48px;\n }\n"], ["\n background: ", ";\n top: 80px;\n z-index: 4;\n padding-top: 16px;\n padding-bottom: 24px;\n @media (max-width: 1200px) {\n padding-bottom: 18px;\n }\n @media (max-width: 600px) {\n top: 48px;\n }\n"])), theme.palette.grey.zero);
175
+ var templateObject_1$k, templateObject_2$b;
176
+
177
+ var dropdownStyles = function (_a) {
178
+ var isOpen = _a.isOpen;
179
+ return css(templateObject_1$j || (templateObject_1$j = __makeTemplateObject(["\n width: 100%;\n max-height: 389px;\n display: ", ";\n position: absolute;\n background: ", ";\n z-index: 3;\n border: 1px solid ", ";\n top: 64px;\n box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.1);\n border-radius: 8px;\n overflow: auto;\n -ms-overflow-style: none;\n scrollbar-width: none;\n overflow-y: scroll;\n user-select: none;\n &::-webkit-scrollbar {\n width: 0px;\n },\n"], ["\n width: 100%;\n max-height: 389px;\n display: ", ";\n position: absolute;\n background: ", ";\n z-index: 3;\n border: 1px solid ", ";\n top: 64px;\n box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.1);\n border-radius: 8px;\n overflow: auto;\n -ms-overflow-style: none;\n scrollbar-width: none;\n overflow-y: scroll;\n user-select: none;\n &::-webkit-scrollbar {\n width: 0px;\n },\n"])), isOpen ? "flex" : "none", theme.palette.grey.zero, theme.palette.grey.fifteenB);
180
+ };
181
+ var InputDropdown = function (_a) {
182
+ var isOpen = _a.isOpen, handleClose = _a.handleClose, buttonRef = _a.buttonRef, children = _a.children, otherProps = __rest(_a, ["isOpen", "handleClose", "buttonRef", "children"]);
183
+ var dropdownRef = useRef(null);
184
+ var closePopUp = function (e) {
185
+ if (dropdownRef.current && buttonRef && buttonRef.current) {
186
+ if (!dropdownRef.current.contains(e.target) &&
187
+ !buttonRef.current.contains(e.target)) {
188
+ handleClose();
189
+ }
190
+ }
191
+ };
192
+ useEffect(function () {
193
+ document.addEventListener("click", closePopUp);
194
+ return function () {
195
+ document.removeEventListener("click", closePopUp);
196
+ };
197
+ });
198
+ if (!isOpen) {
199
+ return null;
200
+ }
201
+ return (jsx$1(Grid, __assign({ "data-testid": "input_dropdown", container: true, ref: dropdownRef, css: dropdownStyles({ isOpen: isOpen }) }, otherProps, { children: children })));
202
+ };
203
+ var templateObject_1$j;
204
+
205
+ var InputSelectDropdown = function (_a) {
206
+ var options = _a.options, inputRef = _a.inputRef, isOpenDropdown = _a.isOpenDropdown, handleCloseDropdown = _a.handleCloseDropdown, handleSelect = _a.handleSelect, selectedValue = _a.selectedValue;
207
+ useEffect(function () {
208
+ var _a;
209
+ if (isOpenDropdown) {
210
+ (_a = document
211
+ .querySelector("[data-value=autocomplete_option_".concat(selectedValue, "]"))) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
212
+ }
213
+ }, [isOpenDropdown]);
214
+ return (jsx$1(InputDropdown, __assign({ buttonRef: inputRef, isOpen: isOpenDropdown, handleClose: handleCloseDropdown, css: {
215
+ maxHeight: "142px",
216
+ padding: "4px",
217
+ } }, { children: options.map(function (option, key) { return (jsx$1(OptionWrapper, __assign({ onClick: function () { return handleSelect(option); }, "data-value": "autocomplete_option_".concat(option.value), "data-testid": "autocomplete_option_".concat(key) }, { children: jsx$1(StyledOption, __assign({ css: selectedValue === option.value && selectedStyles }, { children: jsx$1(Caption, __assign({ size: "sm", weight: 500 }, { children: option.label })) })) }), option.label)); }) })));
218
+ };
219
+ var OptionWrapper = styled.div(templateObject_1$i || (templateObject_1$i = __makeTemplateObject(["\n width: 100%;\n padding: 2px 0;\n cursor: pointer;\n"], ["\n width: 100%;\n padding: 2px 0;\n cursor: pointer;\n"])));
220
+ var StyledOption = styled.div(templateObject_2$a || (templateObject_2$a = __makeTemplateObject(["\n padding: 8px;\n transition: all ease-out 0.3s;\n border-radius: 4px;\n &:hover {\n background-color: ", ";\n }\n"], ["\n padding: 8px;\n transition: all ease-out 0.3s;\n border-radius: 4px;\n &:hover {\n background-color: ", ";\n }\n"])), theme.palette.background.light1);
221
+ var selectedStyles = css(templateObject_3$4 || (templateObject_3$4 = __makeTemplateObject(["\n background-color: ", ";\n"], ["\n background-color: ", ";\n"])), theme.palette.background.light1);
222
+ var templateObject_1$i, templateObject_2$a, templateObject_3$4;
223
+
224
+ var getFormValue = function (name, form) {
225
+ var names = name === null || name === void 0 ? void 0 : name.split(".");
226
+ var fieldValue = form === null || form === void 0 ? void 0 : form.control._formValues;
227
+ names === null || names === void 0 ? void 0 : names.forEach(function (field) {
228
+ if (fieldValue) {
229
+ fieldValue = fieldValue[field];
230
+ }
231
+ });
232
+ return fieldValue;
233
+ };
234
+ var getFormError = function (name, form) {
235
+ var names = name === null || name === void 0 ? void 0 : name.split(".");
236
+ var fieldError = form === null || form === void 0 ? void 0 : form.formState.errors;
237
+ names === null || names === void 0 ? void 0 : names.forEach(function (field) {
238
+ if (fieldError) {
239
+ // @ts-ignore
240
+ fieldError = fieldError[field];
241
+ }
242
+ });
243
+ return fieldError === null || fieldError === void 0 ? void 0 : fieldError.message;
244
+ };
245
+
246
+ var InputSelect = function (_a) {
247
+ var _b, _c, _d, _e;
248
+ var options = _a.options, name = _a.name; _a.isLoading; var disabled = _a.disabled, handleChange = _a.handleChange, form = _a.form, valueProp = _a.value, inputProps = __rest(_a, ["options", "name", "isLoading", "disabled", "handleChange", "form", "value"]);
249
+ var _f = useState(false), isOpenDropdown = _f[0], setIsOpenDropDown = _f[1];
250
+ var _g = useState(getFormValue(name, form)), value = _g[0], setValue = _g[1];
251
+ var inputRef = useRef(null);
252
+ var selectedLabel = (_b = options === null || options === void 0 ? void 0 : options.find(function (option) {
253
+ return String(option.value) === String(valueProp || value);
254
+ })) === null || _b === void 0 ? void 0 : _b.label;
255
+ var error = (_c = form === null || form === void 0 ? void 0 : form.formState.errors[name]) === null || _c === void 0 ? void 0 : _c.message;
256
+ var control = form === null || form === void 0 ? void 0 : form.control.register(name);
257
+ var handleOpenDropdown = function () {
258
+ var _a, _b, _c, _d;
259
+ if ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.parentElement) {
260
+ (_d = (_c = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _c === void 0 ? void 0 : _c.parentElement) === null || _d === void 0 ? void 0 : _d.parentElement.focus();
261
+ }
262
+ setIsOpenDropDown(function (prev) { return !prev; });
263
+ };
264
+ var handleCloseDropdown = function () {
265
+ setIsOpenDropDown(false);
266
+ };
267
+ var handleSelect = function (option) {
268
+ setValue(option.value);
269
+ if (handleChange) {
270
+ handleChange(option.value);
271
+ }
272
+ if (form) {
273
+ control === null || control === void 0 ? void 0 : control.onChange({
274
+ target: { value: option.value, name: name },
275
+ type: "change",
276
+ });
277
+ }
278
+ handleCloseDropdown();
279
+ };
280
+ return (jsxs(Wrapper$6, { children: [jsx$1("input", { name: name, autoComplete: "off", hidden: true }), jsx$1(StyledInput, __assign({ onClick: handleOpenDropdown, ref: inputRef, disabled: disabled, readOnly: true, value: selectedLabel, errorMessage: error }, inputProps, { endIcon: !disabled && (jsx$1(HalfArrowIcon, { width: 12, height: 13, css: [
281
+ { transition: "all linear .2s" },
282
+ isOpenDropdown && { transform: "rotate(180deg)" },
283
+ ] })) }, form.register(name))), options.length > 0 && !disabled && (jsx$1(InputSelectDropdown, { options: options, inputRef: {
284
+ current: (_e = (_d = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.parentElement,
285
+ }, isOpenDropdown: isOpenDropdown, handleCloseDropdown: handleCloseDropdown, handleSelect: handleSelect, selectedValue: valueProp || value }))] }));
286
+ };
287
+ var Wrapper$6 = styled.div(templateObject_1$h || (templateObject_1$h = __makeTemplateObject(["\n position: relative;\n text-align: left;\n"], ["\n position: relative;\n text-align: left;\n"])));
288
+ var StyledInput = styled(InputWithAdornments)(templateObject_2$9 || (templateObject_2$9 = __makeTemplateObject(["\n cursor: pointer;\n input,\n label {\n cursor: pointer !important;\n }\n"], ["\n cursor: pointer;\n input,\n label {\n cursor: pointer !important;\n }\n"])));
289
+ var templateObject_1$h, templateObject_2$9;
290
+
291
+ var SelectYear = function (_a) {
292
+ var yearOptions = _a.yearOptions; _a.options; var props = __rest(_a, ["yearOptions", "options"]);
293
+ return (jsx(InputSelect, __assign({ label: "Year", options: yearOptions }, props)));
294
+ };
295
+
296
+ var monthValues = [
297
+ { value: 0, label: "January" },
298
+ { value: 1, label: "February" },
299
+ { value: 2, label: "March" },
300
+ { value: 3, label: "April" },
301
+ { value: 4, label: "May" },
302
+ { value: 5, label: "June" },
303
+ { value: 6, label: "July" },
304
+ { value: 7, label: "August" },
305
+ { value: 8, label: "September" },
306
+ { value: 9, label: "October" },
307
+ { value: 10, label: "November" },
308
+ { value: 11, label: "December" },
309
+ ];
310
+ var SelectMonth = function (_a) {
311
+ _a.options; var props = __rest(_a, ["options"]);
312
+ return (jsx(InputSelect, __assign({ label: "Month", options: monthValues }, props)));
313
+ };
314
+
315
+ var CalendarHeaderWithSelect = function (_a) {
316
+ var changeMonth = _a.changeMonth, changeYear = _a.changeYear, date = _a.date, yearOptions = _a.yearOptions;
317
+ var year = date.getFullYear();
318
+ var month = date.getMonth();
319
+ return (jsx(Wrapper$5, { children: jsxs$1(Grid, __assign({ container: true, spacing: 2 }, { children: [jsx(Grid, __assign({ item: true, xs: 6 }, { children: jsx(SelectYear, { yearOptions: yearOptions, value: year, handleChange: changeYear }) })), jsx(Grid, __assign({ item: true, xs: 6 }, { children: jsx(SelectMonth, { value: month, handleChange: changeMonth }) }))] })) }));
320
+ };
321
+ var Wrapper$5 = styled.div(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\n margin-bottom: 24px;\n @media (max-width: 900px) {\n padding: 0 18px;\n margin-bottom: 20px;\n }\n"], ["\n margin-bottom: 24px;\n @media (max-width: 900px) {\n padding: 0 18px;\n margin-bottom: 20px;\n }\n"])));
322
+ var templateObject_1$g;
323
+
324
+ var CalendarStandardContainer = function (_a) {
325
+ _a.arrowProps; _a.showPopperArrow; var props = __rest(_a, ["arrowProps", "showPopperArrow"]);
326
+ return jsx(DatePickerContainer, __assign({}, props));
327
+ };
328
+ var DatePickerContainer = styled.div(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n padding: 0;\n border: none !important;\n border-radius: 0 !important;\n background: transparent !important;\n overflow: hidden;\n width: 100%;\n height: 100%;\n .react-datepicker__header {\n background-color: transparent !important;\n }\n .react-datepicker__month-container {\n width: 100%;\n height: 100%;\n }\n .react-datepicker__day-names {\n display: flex;\n justify-content: space-between;\n .react-datepicker__day-name {\n font-family: \"Inter\", sans-serif;\n font-weight: 600;\n font-size: 14px;\n color: ", ";\n text-transform: uppercase;\n margin: 0;\n width: 33px;\n line-height: normal;\n }\n }\n .react-datepicker__month {\n padding: 0;\n margin: 20px 0 0 !important;\n border: none;\n width: 100%;\n height: calc(100% - 85px);\n .react-datepicker__week {\n display: flex;\n justify-content: space-between;\n }\n }\n .react-datepicker__week {\n margin-bottom: 10px;\n &:last-of-type {\n margin-bottom: 0;\n }\n }\n .react-datepicker__day {\n width: 33px;\n height: 33px;\n user-select: none;\n border-radius: 50% !important;\n transition: background ease-out 0.3s;\n border: 1px solid transparent;\n margin: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n font-weight: 500;\n font-size: 16px;\n &:hover {\n background: ", ";\n }\n &:active {\n background: ", ";\n }\n }\n .react-datepicker__day--outside-month,\n .react-datepicker__day--disabled {\n color: #a6aebc;\n p {\n color: #a6aebc;\n }\n }\n .react-datepicker__day--keyboard-selected {\n background: transparent;\n color: inherit;\n }\n .react-datepicker__day--selected {\n background: white;\n border: 1px solid #e1e4e8;\n color: ", ";\n p {\n color: ", ";\n }\n }\n .react-datepicker__day--selected.warning_day {\n border-color: ", ";\n background-color: ", ";\n color: ", ";\n }\n @media (max-width: 600px) {\n .react-datepicker__day {\n max-width: 48px;\n max-height: 48px;\n width: calc((100vw - (18px * 7)) / 7);\n height: calc((100vw - (18px * 7)) / 7);\n }\n .react-datepicker__day-names {\n .react-datepicker__day-name {\n max-width: 48px;\n width: calc((100vw - (18px * 7)) / 7);\n }\n }\n }\n @media (max-width: 350px) {\n .react-datepicker__day {\n width: calc((100vw - (6px * 7)) / 7);\n height: calc((100vw - (6px * 7)) / 7);\n }\n .react-datepicker__day-names {\n .react-datepicker__day-name {\n width: calc((100vw - (6px * 7)) / 7);\n }\n }\n }\n"], ["\n padding: 0;\n border: none !important;\n border-radius: 0 !important;\n background: transparent !important;\n overflow: hidden;\n width: 100%;\n height: 100%;\n .react-datepicker__header {\n background-color: transparent !important;\n }\n .react-datepicker__month-container {\n width: 100%;\n height: 100%;\n }\n .react-datepicker__day-names {\n display: flex;\n justify-content: space-between;\n .react-datepicker__day-name {\n font-family: \"Inter\", sans-serif;\n font-weight: 600;\n font-size: 14px;\n color: ", ";\n text-transform: uppercase;\n margin: 0;\n width: 33px;\n line-height: normal;\n }\n }\n .react-datepicker__month {\n padding: 0;\n margin: 20px 0 0 !important;\n border: none;\n width: 100%;\n height: calc(100% - 85px);\n .react-datepicker__week {\n display: flex;\n justify-content: space-between;\n }\n }\n .react-datepicker__week {\n margin-bottom: 10px;\n &:last-of-type {\n margin-bottom: 0;\n }\n }\n .react-datepicker__day {\n width: 33px;\n height: 33px;\n user-select: none;\n border-radius: 50% !important;\n transition: background ease-out 0.3s;\n border: 1px solid transparent;\n margin: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n font-weight: 500;\n font-size: 16px;\n &:hover {\n background: ", ";\n }\n &:active {\n background: ", ";\n }\n }\n .react-datepicker__day--outside-month,\n .react-datepicker__day--disabled {\n color: #a6aebc;\n p {\n color: #a6aebc;\n }\n }\n .react-datepicker__day--keyboard-selected {\n background: transparent;\n color: inherit;\n }\n .react-datepicker__day--selected {\n background: white;\n border: 1px solid #e1e4e8;\n color: ", ";\n p {\n color: ", ";\n }\n }\n .react-datepicker__day--selected.warning_day {\n border-color: ", ";\n background-color: ", ";\n color: ", ";\n }\n @media (max-width: 600px) {\n .react-datepicker__day {\n max-width: 48px;\n max-height: 48px;\n width: calc((100vw - (18px * 7)) / 7);\n height: calc((100vw - (18px * 7)) / 7);\n }\n .react-datepicker__day-names {\n .react-datepicker__day-name {\n max-width: 48px;\n width: calc((100vw - (18px * 7)) / 7);\n }\n }\n }\n @media (max-width: 350px) {\n .react-datepicker__day {\n width: calc((100vw - (6px * 7)) / 7);\n height: calc((100vw - (6px * 7)) / 7);\n }\n .react-datepicker__day-names {\n .react-datepicker__day-name {\n width: calc((100vw - (6px * 7)) / 7);\n }\n }\n }\n"])), theme.palette.grey.fiftyP, theme.palette.background.light3, theme.palette.background.light3, theme.palette.brand.main, theme.palette.brand.main, theme.palette.grey.fifteenB, theme.palette.red.fiftyP, theme.palette.grey.zero);
329
+ var templateObject_1$f;
330
+
331
+ var CalendarStandardHeader = function (_a) {
332
+ var decreaseMonth = _a.decreaseMonth, increaseMonth = _a.increaseMonth, nextMonthButtonDisabled = _a.nextMonthButtonDisabled, prevMonthButtonDisabled = _a.prevMonthButtonDisabled, date = _a.date;
333
+ var title = _.capitalize(date.toLocaleString("ru", { month: "long", year: "numeric" })).slice(0, -3);
334
+ return (jsxs$1(HeaderWrapper, __assign({ container: true, alignItems: "center", justify: "space-between" }, { children: [jsx(Grid, __assign({ item: true }, { children: jsx(StyledHeading, __assign({ size: "h4" }, { children: title })) })), jsx(Grid, __assign({ item: true }, { children: jsxs$1(Grid, __assign({ container: true, spacing: 2 }, { children: [jsx(Grid, __assign({ item: true }, { children: jsx(CircleButtonStyled, __assign({ isCircle: true, size: "xs", "data-testid": "prev_month_button", variant: "white", disabled: prevMonthButtonDisabled, onClick: decreaseMonth }, { children: jsx(PrevArrowIcon, { width: 10, height: 10 }) })) })), jsx(Grid, __assign({ item: true }, { children: jsx(CircleButtonStyled, __assign({ isCircle: true, size: "xs", variant: "white", disabled: nextMonthButtonDisabled, onClick: increaseMonth }, { children: jsx(NextArrowIcon, { width: 10, height: 10 }) })) }))] })) }))] })));
335
+ };
336
+ var HeaderWrapper = styled(Grid)(templateObject_1$e || (templateObject_1$e = __makeTemplateObject(["\n padding: 0 6px 34px;\n @media (max-width: 600px) {\n h2 {\n font-size: 16px;\n }\n }\n"], ["\n padding: 0 6px 34px;\n @media (max-width: 600px) {\n h2 {\n font-size: 16px;\n }\n }\n"])));
337
+ var StyledHeading = styled(Heading)(templateObject_2$8 || (templateObject_2$8 = __makeTemplateObject(["\n @media (max-width: 600px) {\n font-weight: 700;\n }\n"], ["\n @media (max-width: 600px) {\n font-weight: 700;\n }\n"])));
338
+ var CircleButtonStyled = styled(Button)(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n border-color: transparent !important;\n &:disabled {\n background-color: white !important;\n }\n"], ["\n border-color: transparent !important;\n &:disabled {\n background-color: white !important;\n }\n"])));
339
+ var templateObject_1$e, templateObject_2$8, templateObject_3$3;
340
+
341
+ var InputForDatepicker = forwardRef(function (_a, ref) {
342
+ var onClick = _a.onClick; _a.onBlur; _a.onFocus; var props = __rest(_a, ["onClick", "onBlur", "onFocus"]);
343
+ var onChange = props.onChange, readOnly = props.readOnly, disabled = props.disabled, mask = props.mask, handleCLick = props.handleCLick, other = __rest(props, ["onChange", "readOnly", "disabled", "mask", "handleCLick"]);
344
+ var handleIconClick = function () {
345
+ if (handleCLick) {
346
+ handleCLick();
347
+ }
348
+ else {
349
+ onClick();
350
+ }
351
+ };
352
+ return (jsx(InputMask, __assign({ mask: mask, onChange: onChange, value: props.value, maskPlaceholder: null, alwaysShowMask: false, disabled: disabled, readOnly: readOnly }, { children: function () { return (jsx(InputWithAdornments, __assign({ onChange: onChange, disabled: disabled, value: props.value, endIcon: jsx(IconWrapper, __assign({ onClick: handleIconClick }, { children: jsx(CalendarIcon, { width: 19, height: 21 }) })) }, other, { ref: ref }))); } })));
353
+ });
354
+ var IconWrapper = styled.div(templateObject_1$d || (templateObject_1$d = __makeTemplateObject(["\n display: flex;\n align-items: center;\n cursor: pointer;\n z-index: 1;\n"], ["\n display: flex;\n align-items: center;\n cursor: pointer;\n z-index: 1;\n"])));
355
+ var templateObject_1$d;
356
+
357
+ var MonthPickerContainer = function (_a) {
358
+ _a.arrowProps; _a.showPopperArrow; var props = __rest(_a, ["arrowProps", "showPopperArrow"]);
359
+ return jsx(StyledContainer, __assign({}, props));
360
+ };
361
+ var StyledContainer = styled.div(templateObject_1$c || (templateObject_1$c = __makeTemplateObject(["\n box-shadow: 0px 26px 34px rgba(0, 0, 0, 0.1);\n border-radius: 12px !important;\n border: 1px solid #fbfbfd !important;\n background: #fff;\n overflow: hidden;\n z-index: 5;\n @media (max-width: 600px) {\n width: 100%;\n height: 262px;\n box-shadow: 0px 5px 16px rgba(0, 0, 0, 0.1);\n }\n"], ["\n box-shadow: 0px 26px 34px rgba(0, 0, 0, 0.1);\n border-radius: 12px !important;\n border: 1px solid #fbfbfd !important;\n background: #fff;\n overflow: hidden;\n z-index: 5;\n @media (max-width: 600px) {\n width: 100%;\n height: 262px;\n box-shadow: 0px 5px 16px rgba(0, 0, 0, 0.1);\n }\n"])));
362
+ var templateObject_1$c;
363
+
364
+ var MonthPickerHeader = function (_a) {
365
+ var decreaseYear = _a.decreaseYear, increaseYear = _a.increaseYear, nextYearButtonDisabled = _a.nextYearButtonDisabled, prevYearButtonDisabled = _a.prevYearButtonDisabled, date = _a.date;
366
+ return (jsxs$1(StyledHeader, __assign({ container: true, alignItems: "center", justify: "space-between" }, { children: [jsx(Grid, __assign({ item: true }, { children: jsx(StyledIconButton, __assign({ disabled: prevYearButtonDisabled, onClick: decreaseYear }, { children: jsx(ArrowBackIcon, { width: 14, height: 12 }) })) })), jsx(Grid, __assign({ item: true }, { children: jsx(Caption, __assign({ size: "sm", weight: 600 }, { children: date.getFullYear() })) })), jsx(Grid, __assign({ item: true }, { children: jsx(StyledIconButton, __assign({ disabled: nextYearButtonDisabled, onClick: increaseYear }, { children: jsx(ArrowNextIcon, { width: 14, height: 12 }) })) }))] })));
367
+ };
368
+ var StyledIconButton = styled(IconButton)(templateObject_1$b || (templateObject_1$b = __makeTemplateObject(["\n &.Mui-disabled {\n opacity: 0;\n }\n"], ["\n &.Mui-disabled {\n opacity: 0;\n }\n"])));
369
+ var StyledHeader = styled(Grid)(templateObject_2$7 || (templateObject_2$7 = __makeTemplateObject(["\n background: #fff;\n padding: 4px 16px;\n border-radius: 12px 12px 0 0;\n"], ["\n background: #fff;\n padding: 4px 16px;\n border-radius: 12px 12px 0 0;\n"])));
370
+ var templateObject_1$b, templateObject_2$7;
371
+
372
+ var DesktopInputWithMonthPicker = function (_a) {
373
+ var name = _a.name, form = _a.form, disabled = _a.disabled, datePickerProps = _a.datePickerProps, otherProps = __rest(_a, ["name", "form", "disabled", "datePickerProps"]);
374
+ var error = getFormError(name, form);
375
+ var formValue = getFormValue(name, form);
376
+ return (jsx(Wrapper$4, { children: jsx(Controller, { name: name, control: form.control, render: function (_a) {
377
+ var field = _a.field;
378
+ return (jsx(DatePicker, __assign({ selected: field.value, onChange: field.onChange, disabled: disabled, customInput: jsx(InputForDatepicker, __assign({ mask: "99.9999", name: name, disabled: disabled, error: error, isLabelShrink: Boolean(formValue) }, otherProps)), showMonthYearPicker: true, dateFormat: "MM.yyyy", popperPlacement: "bottom-end", calendarContainer: MonthPickerContainer, renderCustomHeader: function (props) { return (jsx(MonthPickerHeader, __assign({}, props))); } }, datePickerProps)));
379
+ } }) }));
380
+ };
381
+ var Wrapper$4 = styled.div(templateObject_1$a || (templateObject_1$a = __makeTemplateObject(["\n @media (max-width: 600px) {\n display: none;\n }\n"], ["\n @media (max-width: 600px) {\n display: none;\n }\n"])));
382
+ var templateObject_1$a;
383
+
384
+ var MenuItem = function (_a) {
385
+ var tab = _a.tab, active = _a.active, index = _a.index, handleClick = _a.handleClick, offset = _a.offset, isScrolling = _a.isScrolling, setIsScrolling = _a.setIsScrolling;
386
+ var startScrolling = function () {
387
+ setIsScrolling(true);
388
+ };
389
+ var endScrolling = function () {
390
+ setIsScrolling(false);
391
+ };
392
+ var handleSelect = function () {
393
+ if (!isScrolling) {
394
+ handleClick(index);
395
+ }
396
+ };
397
+ useEffect(function () {
398
+ if (active === index) {
399
+ scroller.scrollTo(tab.label, { offset: offset });
400
+ }
401
+ Events.scrollEvent.register("begin", function (to, element) {
402
+ startScrolling();
403
+ if (element) {
404
+ handleClick(Number(element.dataset.index));
405
+ }
406
+ });
407
+ Events.scrollEvent.register("end", function (to, element) {
408
+ setTimeout(endScrolling);
409
+ });
410
+ return function () {
411
+ Events.scrollEvent.remove("begin");
412
+ Events.scrollEvent.remove("end");
413
+ };
414
+ }, []);
415
+ return (jsx$1(Link, __assign({ to: tab.label, spy: true, smooth: true, duration: 500, offset: offset, onSetActive: handleSelect }, { children: jsx$1(ButtonWrapper$1, { children: jsx$1(Button, __assign({ variant: Number(active) === index ? "orange" : "transparentWithBorder", size: "xs", css: Number(active) !== index && disabledStyles }, { children: tab.label })) }) })));
416
+ };
417
+ var ButtonWrapper$1 = styled.div(templateObject_1$9 || (templateObject_1$9 = __makeTemplateObject(["\n margin-right: 8px;\n width: max-content;\n max-width: 150px;\n @media (max-width: 900px) {\n max-width: unset;\n }\n"], ["\n margin-right: 8px;\n width: max-content;\n max-width: 150px;\n @media (max-width: 900px) {\n max-width: unset;\n }\n"])));
418
+ var disabledStyles = css(templateObject_2$6 || (templateObject_2$6 = __makeTemplateObject(["\n p {\n color: ", ";\n font-weight: 400;\n },\n"], ["\n p {\n color: ", ";\n font-weight: 400;\n },\n"])), theme.palette.grey.seventy);
419
+ var templateObject_1$9, templateObject_2$6;
420
+
421
+ var DesktopMenuPanel = function (_a) {
422
+ var tabs = _a.tabs, variant = _a.variant, other = __rest(_a, ["tabs", "variant"]);
423
+ return (jsx$1(Wrapper$3, __assign({ container: true, css: variant === "white" && { background: "white" } }, { children: tabs.map(function (tab, index) { return (jsx$1(Grid, __assign({ item: true }, { children: jsx$1(MenuItem, __assign({ tab: tab, index: index, offset: -121 }, other), tab.label) }), index)); }) })));
424
+ };
425
+ var Wrapper$3 = styled(Grid)(templateObject_1$8 || (templateObject_1$8 = __makeTemplateObject(["\n position: sticky;\n top: 49px;\n left: 0;\n z-index: 11;\n background-color: ", ";\n padding: 16px 16px 24px;\n @media (max-width: 900px) {\n justify-content: space-between;\n }\n @media (max-width: 765px) {\n display: none;\n }\n"], ["\n position: sticky;\n top: 49px;\n left: 0;\n z-index: 11;\n background-color: ", ";\n padding: 16px 16px 24px;\n @media (max-width: 900px) {\n justify-content: space-between;\n }\n @media (max-width: 765px) {\n display: none;\n }\n"])), theme.palette.background.light1);
426
+ var templateObject_1$8;
427
+
428
+ var InputWithForm = forwardRef(function (_a, ref) {
429
+ var form = _a.form, name = _a.name, errorProp = _a.error, otherProps = __rest(_a, ["form", "name", "error"]);
430
+ var error = typeof errorProp !== "undefined" && String(errorProp).length > 0
431
+ ? errorProp
432
+ : getFormError(name, form);
433
+ return (jsx(InputWithAdornments, __assign({ errorMessage: error, inputRef: ref }, form === null || form === void 0 ? void 0 : form.register(name), otherProps)));
434
+ });
435
+
436
+ var InputWithController = forwardRef(function (_a, ref) {
437
+ var form = _a.form, name = _a.name, defaultValue = _a.defaultValue, inputProps = __rest(_a, ["form", "name", "defaultValue"]);
438
+ var handleChange = function (e, field) {
439
+ field.onChange(e);
440
+ if (inputProps.onChange) {
441
+ inputProps.onChange(e);
442
+ }
443
+ };
444
+ return (jsx(Controller, { control: form === null || form === void 0 ? void 0 : form.control, name: name, defaultValue: defaultValue, render: function (_a) {
445
+ var field = _a.field;
446
+ return (jsx(InputWithForm, __assign({ ref: ref, name: name, form: form }, inputProps, { onBlur: field.onBlur, onChange: function (e) {
447
+ return handleChange(e, field);
448
+ }, value: field.value || "" })));
449
+ } }));
450
+ });
451
+
452
+ var strengthCoefficients = {
453
+ weak: 0,
454
+ simple: 1,
455
+ medium: 2,
456
+ hard: 3,
457
+ };
458
+ var strengthColors = {
459
+ weak: theme.palette.red.fiftyP,
460
+ simple: theme.palette.brand.main,
461
+ medium: theme.palette.blue.fiftyP,
462
+ hard: theme.palette.green.fiftyP,
463
+ };
464
+ var strengthTexts = {
465
+ weak: "Очень простой",
466
+ simple: "Простой",
467
+ medium: "Средний",
468
+ hard: "Сложный",
469
+ };
470
+ var PassportStrengthBar = function (_a) {
471
+ var strength = _a.strength;
472
+ var color = strength
473
+ ? strengthColors[strength]
474
+ : "";
475
+ var strengthKey = strength
476
+ ? strengthCoefficients[strength]
477
+ : -1;
478
+ return (jsxs(Wrapper$2, __assign({ "data-testid": "strength_bar", className: String(!strength && "hidden") }, { children: [jsx$1(ReliabilityLevelWrapper, { children: Object.keys(strengthCoefficients).map(function (item, key) { return (jsx$1(ReliabilityLevel, { children: jsx$1(StyledLinearProgress, { "data-testid": "progress_item_".concat(item), value: strengthKey >= key ? 100 : 0, color: color }) }, item)); }) }), jsx$1(Caption, __assign({ "data-testid": "strength_bar_explanation", size: "s", css: { color: color } }, { children: strength && strengthTexts[strength] })), jsx$1(Description, __assign({ size: "s", color: "fiftyP" }, { children: "\u041F\u0430\u0440\u043E\u043B\u044C \u0434\u043E\u043B\u0436\u0435\u043D \u0441\u043E\u0441\u0442\u043E\u044F\u0442\u044C \u0438\u0437 10 \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432, \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C \u0446\u0438\u0444\u0440\u044B, \u0431\u043E\u043B\u044C\u0448\u0438\u0435 \u0438 \u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0435 \u043B\u0430\u0442\u0438\u043D\u0441\u043A\u0438\u0435 \u0431\u0443\u0432\u044B" }))] })));
479
+ };
480
+ var Wrapper$2 = styled.div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n margin-top: 16px;\n min-height: 86px;\n @media (max-width: 900px) {\n min-height: unset;\n }\n &.hidden {\n opacity: 0;\n @media (max-width: 900px) {\n display: none;\n }\n }\n"], ["\n margin-top: 16px;\n min-height: 86px;\n @media (max-width: 900px) {\n min-height: unset;\n }\n &.hidden {\n opacity: 0;\n @media (max-width: 900px) {\n display: none;\n }\n }\n"])));
481
+ var ReliabilityLevelWrapper = styled.div(templateObject_2$5 || (templateObject_2$5 = __makeTemplateObject(["\n display: flex;\n margin-bottom: 8px;\n"], ["\n display: flex;\n margin-bottom: 8px;\n"])));
482
+ var ReliabilityLevel = styled.div(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n width: calc(100% / 4);\n margin-right: 16px;\n &:last-of-type {\n margin-right: 0;\n }\n"], ["\n width: calc(100% / 4);\n margin-right: 16px;\n &:last-of-type {\n margin-right: 0;\n }\n"])));
483
+ var StyledLinearProgress = styled(LinearProgress)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n height: 8px;\n border-radius: 8px;\n background-color: ", ";\n & .KUI-LinearProgress_bar {\n background-color: ", ";\n width: 102%;\n }\n"], ["\n height: 8px;\n border-radius: 8px;\n background-color: ", ";\n & .KUI-LinearProgress_bar {\n background-color: ", ";\n width: 102%;\n }\n"])), theme.palette.grey.fifteenB, function (_a) {
484
+ var color = _a.color;
485
+ return color;
486
+ });
487
+ var Description = styled(Caption)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-top: 16px;\n @media (max-width: 900px) {\n margin-top: 8px;\n font-size: 12px;\n }\n"], ["\n margin-top: 16px;\n @media (max-width: 900px) {\n margin-top: 8px;\n font-size: 12px;\n }\n"])));
488
+ var templateObject_1$7, templateObject_2$5, templateObject_3$2, templateObject_4, templateObject_5;
489
+
490
+ var isValidWithMaskExp = /^[^_]+$/;
491
+ var simplePasswordRegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{10,}$/;
492
+ var mediumPasswordRegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{12,}$/;
493
+ var strongPasswordRegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{14,}$/;
494
+
495
+ var InputPassword = function (props) {
496
+ var _a = useState(false), showPassword = _a[0], setShowPassword = _a[1];
497
+ var _b = useState(null), strength = _b[0], setStrength = _b[1];
498
+ var handleShowChange = function () {
499
+ setShowPassword(function (prev) { return !prev; });
500
+ };
501
+ var checkPasswordStrength = function (value) {
502
+ if (value.length === 0) {
503
+ setStrength(null);
504
+ return;
505
+ }
506
+ if (strongPasswordRegExp.test(value)) {
507
+ setStrength("hard");
508
+ }
509
+ else if (mediumPasswordRegExp.test(value)) {
510
+ setStrength("medium");
511
+ }
512
+ else if (simplePasswordRegExp.test(value)) {
513
+ setStrength("simple");
514
+ }
515
+ else {
516
+ setStrength("weak");
517
+ }
518
+ };
519
+ var handleChange = function (e) {
520
+ var targetValue = e.target.value;
521
+ checkPasswordStrength(targetValue);
522
+ };
523
+ useEffect(function () {
524
+ var form = props.form, name = props.name;
525
+ var fieldValue = getFormValue(name, form);
526
+ if (typeof fieldValue === "string") {
527
+ checkPasswordStrength(fieldValue);
528
+ }
529
+ }, []);
530
+ return (jsxs$1(Fragment$1, { children: [jsx(InputWithController, __assign({ type: showPassword ? "text" : "password", autoComplete: "new_password", onChange: handleChange, "data-testid": "input_password", endIcon: jsx(EyeIconWrapper, __assign({ "data-testid": "show_value_btn", onClick: handleShowChange }, { children: showPassword ? jsx(ClosedEyeIcon, {}) : jsx(OpenEyeIcon, {}) })) }, props)), jsx(PassportStrengthBar, { strength: strength })] }));
531
+ };
532
+ var EyeIconWrapper = styled.div(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject(["\n height: 18px;\n display: flex;\n align-items: center;\n cursor: pointer;\n"], ["\n height: 18px;\n display: flex;\n align-items: center;\n cursor: pointer;\n"])));
533
+ var templateObject_1$6;
534
+
535
+ var InputTextAreaMobile = function (props) { return (jsxs$1(Fragment$1, { children: [jsx(InputWrapper, { children: jsx(InputWithController, __assign({}, props)) }), jsx(TextAreaWrapper, { children: jsx(InputWithController, __assign({ isTextArea: true }, props)) })] })); };
536
+ var InputWrapper = styled.div(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n @media (max-width: 900px) {\n display: none;\n }\n"], ["\n @media (max-width: 900px) {\n display: none;\n }\n"])));
537
+ var TextAreaWrapper = styled.div(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["\n @media (min-width: 901px) {\n display: none;\n }\n"], ["\n @media (min-width: 901px) {\n display: none;\n }\n"])));
538
+ var templateObject_1$5, templateObject_2$4;
539
+
540
+ var useToggle = function (isModalOpen) {
541
+ if (isModalOpen === void 0) { isModalOpen = false; }
542
+ var _a = useState(isModalOpen), isOpen = _a[0], setIsOpen = _a[1];
543
+ var handleClose = function () {
544
+ setIsOpen(false);
545
+ };
546
+ var handleOpen = function () {
547
+ setIsOpen(true);
548
+ };
549
+ return [isOpen, handleOpen, handleClose];
550
+ };
551
+
552
+ var ModalFooter = function (_a) {
553
+ var label = _a.label, button = _a.button, otherProps = __rest(_a, ["label", "button"]);
554
+ return (jsxs$1(StyledFooter, { children: [jsx(Divider, {}), jsx(ButtonWrapper, { children: button || (jsx(ButtonStyled, __assign({ fullWidth: true, size: "s", endIcon: jsx(CheckIcon, {}) }, otherProps, { children: label }))) })] }));
555
+ };
556
+ var StyledFooter = styled.div(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n background: ", ";\n border-radius: 0 0 12px 12px;\n z-index: 10;\n position: sticky;\n bottom: 0;\n left: 0;\n"], ["\n background: ", ";\n border-radius: 0 0 12px 12px;\n z-index: 10;\n position: sticky;\n bottom: 0;\n left: 0;\n"])), theme.palette.grey.zero);
557
+ var ButtonWrapper = styled.div(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-end;\n padding: 24px 40px;\n @media (max-width: 600px) {\n padding: 24px 16px;\n }\n"], ["\n display: flex;\n justify-content: flex-end;\n padding: 24px 40px;\n @media (max-width: 600px) {\n padding: 24px 16px;\n }\n"])));
558
+ var ButtonStyled = styled(Button)(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject(["\n @media (max-width: 600px) {\n width: 100%;\n }\n"], ["\n @media (max-width: 600px) {\n width: 100%;\n }\n"])));
559
+ var templateObject_1$4, templateObject_2$3, templateObject_3$1;
560
+
561
+ registerLocale("ru", ru);
562
+ var generateYearRange = function (offsetFromCurrent, maxYearCount) {
563
+ var endYear = DateTime.now().year - offsetFromCurrent;
564
+ return _.range(maxYearCount).map(function (elem) {
565
+ var fullYear = endYear - elem;
566
+ return {
567
+ value: fullYear,
568
+ label: fullYear,
569
+ };
570
+ });
571
+ };
572
+ var InputWithDatePicker = function (_a) {
573
+ var title = _a.title, description = _a.description, name = _a.name, form = _a.form, disabled = _a.disabled, yearParams = _a.yearParams, props = __rest(_a, ["title", "description", "name", "form", "disabled", "yearParams"]);
574
+ var fieldValue = getFormValue(name, form);
575
+ var error = getFormError(name, form);
576
+ var control = form.control.register(name);
577
+ var _b = useToggle(), isModalOpen = _b[0], handleModalOpen = _b[1], handleModalClose = _b[2];
578
+ var _c = useState(DateTime.fromJSDate(new Date(String(fieldValue))).toFormat("dd.MM.yyyy")), value = _c[0], setValue = _c[1];
579
+ var _d = useState(DateTime.fromFormat(value, "dd.MM.yyyy").toJSDate()), date = _d[0], setDate = _d[1];
580
+ var yearList = generateYearRange(yearParams.min, yearParams.max);
581
+ var handleChange = function (e) {
582
+ var targetValue = e.target.value;
583
+ setValue(targetValue);
584
+ if (targetValue.length !== 0 && isValidWithMaskExp.test(targetValue)) {
585
+ var jsDate = DateTime.fromFormat(targetValue, "dd.MM.yyyy").toJSDate();
586
+ setDate(jsDate);
587
+ control === null || control === void 0 ? void 0 : control.onChange({ target: { value: jsDate, name: name }, type: "change" });
588
+ }
589
+ else {
590
+ setDate(null);
591
+ control === null || control === void 0 ? void 0 : control.onChange({ target: { value: null, name: name }, type: "change" });
592
+ }
593
+ };
594
+ var acceptWithDateSelected = function () {
595
+ if (date) {
596
+ setValue(DateTime.fromJSDate(date).toFormat("dd.MM.yyyy"));
597
+ control === null || control === void 0 ? void 0 : control.onChange({ target: { value: date, name: name }, type: "change" });
598
+ handleModalClose();
599
+ }
600
+ };
601
+ return (jsxs(Fragment, { children: [jsx$1(InputForDatepicker, __assign({ mask: "99.99.9999", name: name, handleCLick: handleModalOpen, value: value, onChange: handleChange, disabled: disabled, error: error, isLabelShrink: Boolean(fieldValue) }, props)), jsxs(Modal, __assign({ title: title, description: description, isOpen: isModalOpen, handleClose: handleModalClose }, { children: [jsx$1(ContentWrapper$1, { children: jsx$1(DatePicker, { inline: true, selected: date, onChange: function (newDate) { return setDate(newDate); }, locale: "ru", calendarContainer: StyledCalendarStandardContainer, renderCustomHeader: function (headProps) { return (jsx$1(CalendarHeaderWithSelect, __assign({ yearOptions: yearList }, headProps))); }, renderDayContents: function (day) { return jsx$1(DayContent, { children: day }); } }) }), jsx$1(ModalFooter, { fullWidth: true, disabled: !date, onClick: acceptWithDateSelected, label: "\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C" })] }))] }));
602
+ };
603
+ InputWithDatePicker.defaultProps = {
604
+ title: "Дата рождения",
605
+ description: "Выберите год, месяц и число вашего рождения",
606
+ yearParams: { min: 18, max: 120 },
607
+ };
608
+ var ContentWrapper$1 = styled.div(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n padding: 36px 40px 24px;\n @media (max-width: 600px) {\n padding: 20px 0 0;\n }\n"], ["\n padding: 36px 40px 24px;\n @media (max-width: 600px) {\n padding: 20px 0 0;\n }\n"])));
609
+ var StyledCalendarStandardContainer = styled(CalendarStandardContainer)(templateObject_2$2 || (templateObject_2$2 = __makeTemplateObject(["\n height: 410px;\n .react-datepicker__header {\n padding: 0 !important;\n }\n .react-datepicker__day-names {\n padding: 35px 22px 0;\n background-color: ", ";\n border-radius: 16px 16px 0 0;\n @media (max-width: 900px) {\n padding: 24px 16px 0;\n }\n }\n .react-datepicker__month {\n justify-content: space-between;\n height: calc(100% - 124px);\n background-color: ", ";\n border-radius: 0 0 16px 16px;\n padding: 20px 22px 24px;\n margin: 0 !important;\n @media (max-width: 900px) {\n padding: 20px 16px 24px;\n }\n }\n @media (max-width: 600px) {\n height: auto;\n margin-bottom: -4px;\n }\n"], ["\n height: 410px;\n .react-datepicker__header {\n padding: 0 !important;\n }\n .react-datepicker__day-names {\n padding: 35px 22px 0;\n background-color: ", ";\n border-radius: 16px 16px 0 0;\n @media (max-width: 900px) {\n padding: 24px 16px 0;\n }\n }\n .react-datepicker__month {\n justify-content: space-between;\n height: calc(100% - 124px);\n background-color: ", ";\n border-radius: 0 0 16px 16px;\n padding: 20px 22px 24px;\n margin: 0 !important;\n @media (max-width: 900px) {\n padding: 20px 16px 24px;\n }\n }\n @media (max-width: 600px) {\n height: auto;\n margin-bottom: -4px;\n }\n"])), theme.palette.background.light1, theme.palette.background.light1);
610
+ var DayContent = styled.span(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-top: 1px;\n @media (max-width: 600px) {\n font-weight: 400;\n }\n"], ["\n padding-top: 1px;\n @media (max-width: 600px) {\n font-weight: 400;\n }\n"])));
611
+ var templateObject_1$3, templateObject_2$2, templateObject_3;
612
+
613
+ var shortMonths = [
614
+ "ЯНВ",
615
+ "ФЕВ",
616
+ "МАРТ",
617
+ "АПР",
618
+ "МАЙ",
619
+ "ИЮНЬ",
620
+ "ИЮЛЬ",
621
+ "АВГ",
622
+ "СЕНТ",
623
+ "ОКТ",
624
+ "НОЯБ",
625
+ "ДЕК",
626
+ ];
627
+
628
+ var ruCustom = __assign(__assign({}, ru), { localize: {
629
+ month: function (n) { return shortMonths[n]; },
630
+ ordinalNumber: function () { return ""; },
631
+ era: function () { return ""; },
632
+ quarter: function () { return ""; },
633
+ dayPeriod: function () { return ""; },
634
+ day: function () { return ""; },
635
+ } });
636
+ var MobileInputWithMonthPicker = function (_a) {
637
+ var title = _a.title, name = _a.name, form = _a.form, disabled = _a.disabled, datePickerProps = _a.datePickerProps, props = __rest(_a, ["title", "name", "form", "disabled", "datePickerProps"]);
638
+ var fieldValue = getFormValue(name, form);
639
+ var error = getFormError(name, form);
640
+ var control = form.control.register(name);
641
+ var _b = useToggle(), isModalOpen = _b[0], handleModalOpen = _b[1], handleModalClose = _b[2];
642
+ var _c = useState(DateTime.fromJSDate(new Date(String(fieldValue))).toFormat("MM.yyyy")), value = _c[0], setValue = _c[1];
643
+ var _d = useState(DateTime.fromFormat(value, "MM.yyyy").toJSDate()), date = _d[0], setDate = _d[1];
644
+ var handleChange = function (e) {
645
+ var targetValue = e.target.value;
646
+ setValue(targetValue);
647
+ if (targetValue.length !== 0 && isValidWithMaskExp.test(targetValue)) {
648
+ var jsDate = DateTime.fromFormat(targetValue, "MM.yyyy").toJSDate();
649
+ setDate(jsDate);
650
+ control === null || control === void 0 ? void 0 : control.onChange({ target: { value: jsDate, name: name }, type: "change" });
651
+ }
652
+ else {
653
+ setDate(null);
654
+ control === null || control === void 0 ? void 0 : control.onChange({ target: { value: null, name: name }, type: "change" });
655
+ }
656
+ };
657
+ var acceptWithDateSelected = function () {
658
+ if (date) {
659
+ setValue(DateTime.fromJSDate(date).toFormat("MM.yyyy"));
660
+ }
661
+ else {
662
+ setValue("");
663
+ }
664
+ control === null || control === void 0 ? void 0 : control.onChange({ target: { value: date, name: name }, type: "change" });
665
+ handleModalClose();
666
+ };
667
+ return (jsxs$1(Wrapper$1, { children: [jsx(InputForDatepicker, __assign({ mask: "99.9999", name: name, handleCLick: handleModalOpen, value: value, onChange: handleChange, disabled: disabled, error: error, isLabelShrink: Boolean(fieldValue) }, props)), jsxs$1(Modal, __assign({ title: title, isOpen: isModalOpen, handleClose: handleModalClose }, { children: [jsx(ContentWrapper, { children: jsx(DatePicker, __assign({ inline: true, showMonthYearPicker: true, dateFormat: "MM.yyyy", selected: date, onChange: function (newDate) { return setDate(newDate); }, locale: ruCustom, calendarContainer: MonthPickerContainer, renderCustomHeader: function (headProps) { return jsx(MonthPickerHeader, __assign({}, headProps)); } }, datePickerProps)) }), jsx(ModalFooter, { fullWidth: true, disabled: !date, onClick: acceptWithDateSelected, label: "\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C" })] }))] }));
668
+ };
669
+ var Wrapper$1 = styled.div(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n @media (min-width: 601px) {\n display: none;\n }\n"], ["\n @media (min-width: 601px) {\n display: none;\n }\n"])));
670
+ var ContentWrapper = styled.div(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n @media (max-width: 600px) {\n padding: 16px 16px 8px;\n }\n"], ["\n @media (max-width: 600px) {\n padding: 16px 16px 8px;\n }\n"])));
671
+ var templateObject_1$2, templateObject_2$1;
672
+
673
+ var InputWithMonthPicker = function (props) { return (jsxs$1(Fragment$1, { children: [jsx(DesktopInputWithMonthPicker, __assign({}, props)), jsx(MobileInputWithMonthPicker, __assign({}, props))] })); };
674
+
675
+ var MobileMenuPanel = function (_a) {
676
+ var tabs = _a.tabs, handleClick = _a.handleClick, variant = _a.variant, other = __rest(_a, ["tabs", "handleClick", "variant"]);
677
+ var swiperRef = useRef(null);
678
+ var slideTo = function (index) {
679
+ setTimeout(function () {
680
+ var _a, _b;
681
+ (_b = (_a = swiperRef.current) === null || _a === void 0 ? void 0 : _a.swiper) === null || _b === void 0 ? void 0 : _b.slideTo(index);
682
+ }, 16);
683
+ handleClick(index);
684
+ };
685
+ return (jsx$1(Wrapper, __assign({ css: variant === "white" && { background: "white" } }, { children: jsx$1(Swiper, __assign({ spaceBetween: 8, slidesPerView: "auto", slideToClickedSlide: true, ref: swiperRef }, { children: tabs.map(function (tab, index) { return (jsx$1(SlideWrapper, { children: jsx$1(MenuItem, __assign({ tab: tab, index: index, handleClick: slideTo, offset: -121 }, other), tab.label) }, index)); }) })) })));
686
+ };
687
+ var Wrapper = styled.div(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n position: sticky;\n top: 49px;\n left: 0;\n z-index: 11;\n background: ", ";\n padding: 16px 0 24px;\n @media (min-width: 766px) {\n display: none;\n }\n"], ["\n position: sticky;\n top: 49px;\n left: 0;\n z-index: 11;\n background: ", ";\n padding: 16px 0 24px;\n @media (min-width: 766px) {\n display: none;\n }\n"])), theme.palette.background.light1);
688
+ var SlideWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: max-content !important;\n &:first-of-type {\n padding-left: 16px;\n }\n"], ["\n width: max-content !important;\n &:first-of-type {\n padding-left: 16px;\n }\n"])));
689
+ var templateObject_1$1, templateObject_2;
690
+
691
+ var useWindowWidth = function (time) {
692
+ if (time === void 0) { time = 10; }
693
+ var _a = useState(0), width = _a[0], setWidth = _a[1];
694
+ useEffect(function () {
695
+ setWidth(window.innerWidth);
696
+ var handleResize = _.debounce(function () {
697
+ setWidth(window.innerWidth);
698
+ }, time);
699
+ window.addEventListener("resize", handleResize);
700
+ return function () { return window.removeEventListener("resize", handleResize); };
701
+ }, []);
702
+ return width;
703
+ };
704
+
705
+ var MenuPanel = function (_a) {
706
+ var tabs = _a.tabs, tabPanels = _a.tabPanels, paths = _a.paths, activeTab = _a.activeTab, variant = _a.variant;
707
+ var width = useWindowWidth();
708
+ var _b = React.useState(activeTab), value = _b[0], setValue = _b[1];
709
+ var _c = React.useState(false), isScrolling = _c[0], setIsScrolling = _c[1];
710
+ var history = useHistory();
711
+ var handleClick = function (index) {
712
+ if (paths[index]) {
713
+ setValue(index);
714
+ var pathName = history.location.pathname;
715
+ var currentLocation = "".concat(pathName).concat(history.location.search);
716
+ var newLocation = "".concat(pathName).concat(paths[index]);
717
+ if (currentLocation !== newLocation) {
718
+ history.replace(newLocation);
719
+ }
720
+ }
721
+ };
722
+ useEffect(function () {
723
+ setValue(activeTab);
724
+ }, [activeTab]);
725
+ useEffect(function () {
726
+ if (typeof activeTab !== "number" && width < 901) {
727
+ animateScroll.scrollToTop();
728
+ }
729
+ }, []);
730
+ if (width === 0) {
731
+ return null;
732
+ }
733
+ return (jsxs("div", { children: [width > 765 ? (jsx$1(DesktopMenuPanel, { tabs: tabs, active: value, handleClick: handleClick, variant: variant, isScrolling: isScrolling, setIsScrolling: setIsScrolling })) : (jsx$1(MobileMenuPanel, { tabs: tabs, active: value, handleClick: handleClick, variant: variant, isScrolling: isScrolling, setIsScrolling: setIsScrolling })), tabPanels.map(function (item, index) { return (jsx$1("div", __assign({ css: index === tabPanels.length - 1 && fullHeightStyles }, { children: jsx$1(Element, __assign({ name: tabs[index].label, "data-index": index }, { children: item }), index) }), index)); })] }));
734
+ };
735
+ MenuPanel.defaultProps = {
736
+ variant: "grey",
737
+ };
738
+ var fullHeightStyles = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: calc(100vh - 121px);\n"], ["\n height: calc(100vh - 121px);\n"])));
739
+ var templateObject_1;
740
+
741
+ var Switch = function (_a) {
742
+ var form = _a.form, name = _a.name, props = __rest(_a, ["form", "name"]);
743
+ return (jsx$1(Controller, { control: form === null || form === void 0 ? void 0 : form.control, name: name, render: function (_a) {
744
+ var field = _a.field;
745
+ return (jsx$1(Switch$1, __assign({ checked: Boolean(field.value), onChange: field.onChange, "data-testid": name }, props)));
746
+ } }));
747
+ };
748
+
749
+ export { Avatar, ButtonTab, ButtonsPanel, CalendarHeaderWithSelect, CalendarStandardContainer, CalendarStandardHeader, DesktopInputWithMonthPicker, DesktopMenuPanel, InputDropdown, InputForDatepicker, InputPassword, InputSelect, InputSelectDropdown, InputTextAreaMobile, InputWithController, InputWithDatePicker, InputWithForm, InputWithMonthPicker, MenuItem, MenuPanel, MobileInputWithMonthPicker, MobileMenuPanel, MonthPickerContainer, MonthPickerHeader, PassportStrengthBar, SelectMonth, SelectYear, Switch, UndefinedAvatar };
2
750
  //# sourceMappingURL=index.es.js.map