kui-complex 0.0.50 → 0.0.51
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/DesktopInputWithMonthPicker/cjs/index.js +5 -8
- package/DesktopInputWithMonthPicker/cjs/index.js.map +1 -1
- package/DesktopInputWithMonthPicker/cjs/package.json +1 -2
- package/DesktopInputWithMonthPicker/index.js +6 -8
- package/DesktopInputWithMonthPicker/index.js.map +1 -1
- package/DesktopInputWithMonthPicker/package.json +1 -2
- package/InputForDatepicker/cjs/index.js +5 -8
- package/InputForDatepicker/cjs/index.js.map +1 -1
- package/InputForDatepicker/cjs/package.json +1 -2
- package/InputForDatepicker/index.js +6 -8
- package/InputForDatepicker/index.js.map +1 -1
- package/InputForDatepicker/package.json +1 -2
- package/InputPhoneWithForm/cjs/index.js +53 -17
- package/InputPhoneWithForm/cjs/index.js.map +1 -1
- package/InputPhoneWithForm/index.js +33 -16
- package/InputPhoneWithForm/index.js.map +1 -1
- package/InputWithDatePicker/cjs/index.js +75 -41
- package/InputWithDatePicker/cjs/index.js.map +1 -1
- package/InputWithDatePicker/cjs/package.json +1 -2
- package/InputWithDatePicker/index.js +34 -17
- package/InputWithDatePicker/index.js.map +1 -1
- package/InputWithDatePicker/package.json +1 -2
- package/InputWithMask/cjs/index.js +1 -9
- package/InputWithMask/cjs/index.js.map +1 -1
- package/InputWithMask/index.js +1 -9
- package/InputWithMask/index.js.map +1 -1
- package/InputWithMonthPicker/cjs/index.js +5 -8
- package/InputWithMonthPicker/cjs/index.js.map +1 -1
- package/InputWithMonthPicker/cjs/package.json +1 -2
- package/InputWithMonthPicker/index.js +6 -8
- package/InputWithMonthPicker/index.js.map +1 -1
- package/InputWithMonthPicker/package.json +1 -2
- package/MobileInputWithMonthPicker/cjs/index.js +5 -8
- package/MobileInputWithMonthPicker/cjs/index.js.map +1 -1
- package/MobileInputWithMonthPicker/cjs/package.json +1 -2
- package/MobileInputWithMonthPicker/index.js +6 -8
- package/MobileInputWithMonthPicker/index.js.map +1 -1
- package/MobileInputWithMonthPicker/package.json +1 -2
- package/TestForm/cjs/index.js +79 -80
- package/TestForm/cjs/index.js.map +1 -1
- package/TestForm/cjs/package.json +0 -1
- package/TestForm/index.js +41 -41
- package/TestForm/index.js.map +1 -1
- package/TestForm/package.json +0 -1
- package/cjs/index.js +39 -41
- package/cjs/index.js.map +1 -1
- package/index.js +40 -41
- package/index.js.map +1 -1
- package/package.json +1 -1
package/TestForm/index.js
CHANGED
|
@@ -2,8 +2,9 @@ import { jsx, jsxs as jsxs$1, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
|
2
2
|
import { Controller, useController, useForm } from 'react-hook-form';
|
|
3
3
|
import * as yup from 'yup';
|
|
4
4
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
5
|
+
import * as React from 'react';
|
|
5
6
|
import { forwardRef, useRef, useEffect, useState } from 'react';
|
|
6
|
-
import { InputWithAdornments, Grid, theme, Caption, Divider, Button, Modal, IconButton, InputWithCountryDropdown, Switch as Switch$1, LinearProgress
|
|
7
|
+
import { InputWithAdornments, Grid, theme, Caption, InputWithMask as InputWithMask$1, Divider, Button, Modal, IconButton, InputWithCountryDropdown, Switch as Switch$1, LinearProgress } from 'kui-basic';
|
|
7
8
|
import { jsx as jsx$1, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
8
9
|
import styled from '@emotion/styled';
|
|
9
10
|
import { HalfArrowIcon, CalendarIcon, CheckIcon, ArrowBackIcon, ArrowNextIcon, ClosedEyeIcon, OpenEyeIcon } from 'kui-icon';
|
|
@@ -11,7 +12,6 @@ import { css } from '@emotion/react';
|
|
|
11
12
|
import DatePicker from 'react-datepicker';
|
|
12
13
|
import { DateTime } from 'luxon';
|
|
13
14
|
import _ from 'lodash';
|
|
14
|
-
import InputMask from 'react-input-mask';
|
|
15
15
|
import ru from 'date-fns/locale/ru';
|
|
16
16
|
|
|
17
17
|
/******************************************************************************
|
|
@@ -225,19 +225,18 @@ var Wrapper$4 = styled.div(templateObject_1$b || (templateObject_1$b = __makeTem
|
|
|
225
225
|
var StyledInput = styled(InputWithAdornments)(templateObject_2$5 || (templateObject_2$5 = __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"])));
|
|
226
226
|
var templateObject_1$b, templateObject_2$5;
|
|
227
227
|
|
|
228
|
-
var InputForDatepicker = forwardRef(function (
|
|
229
|
-
var onClick =
|
|
230
|
-
var onChange = props.onChange, readOnly = props.readOnly, disabled = props.disabled, mask = props.mask, handleCLick = props.handleCLick, startIcon = props.startIcon, other = __rest(props, ["onChange", "readOnly", "disabled", "mask", "handleCLick", "startIcon"]);
|
|
228
|
+
var InputForDatepicker = forwardRef(function (props, ref) {
|
|
229
|
+
var onClick = props.onClick, disabled = props.disabled, handleClick = props.handleClick, startIcon = props.startIcon, other = __rest(props, ["onClick", "disabled", "handleClick", "startIcon"]);
|
|
231
230
|
var handleIconClick = function () {
|
|
232
|
-
if (
|
|
233
|
-
|
|
231
|
+
if (handleClick) {
|
|
232
|
+
handleClick();
|
|
234
233
|
}
|
|
235
234
|
else {
|
|
236
235
|
onClick();
|
|
237
236
|
}
|
|
238
237
|
};
|
|
239
238
|
var Icon = function () { return (jsx(IconWrapper, __assign({ disabled: disabled, onClick: handleIconClick }, { children: startIcon || jsx(CalendarIcon, { width: 19, height: 21 }) }))); };
|
|
240
|
-
return (jsx(
|
|
239
|
+
return (jsx(InputWithMask$1, __assign({ disabled: disabled, endIcon: !startIcon && jsx(Icon, {}), startIcon: startIcon && jsx(Icon, {}) }, other, { ref: ref })));
|
|
241
240
|
});
|
|
242
241
|
var IconWrapper = styled.div(templateObject_1$a || (templateObject_1$a = __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"])));
|
|
243
242
|
var templateObject_1$a;
|
|
@@ -317,6 +316,31 @@ var CalendarStandardContainer = forwardRef(function (_a, ref) {
|
|
|
317
316
|
var DatePickerContainer = styled.div(templateObject_1$7 || (templateObject_1$7 = __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.seventy, theme.palette.grey.zero);
|
|
318
317
|
var templateObject_1$7;
|
|
319
318
|
|
|
319
|
+
function setRef(ref, value) {
|
|
320
|
+
if (typeof ref === "function") {
|
|
321
|
+
ref(value);
|
|
322
|
+
}
|
|
323
|
+
else if (ref) {
|
|
324
|
+
ref.current = value;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function useForkRef() {
|
|
328
|
+
var refs = [];
|
|
329
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
330
|
+
refs[_i] = arguments[_i];
|
|
331
|
+
}
|
|
332
|
+
return React.useMemo(function () {
|
|
333
|
+
if (refs.every(function (ref) { return ref == null; })) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
return function (instance) {
|
|
337
|
+
refs.forEach(function (ref) {
|
|
338
|
+
setRef(ref, instance);
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
}, refs);
|
|
342
|
+
}
|
|
343
|
+
|
|
320
344
|
var generateYearRange = function (offsetFromCurrent, maxYearCount) {
|
|
321
345
|
if (!offsetFromCurrent || !maxYearCount)
|
|
322
346
|
return [];
|
|
@@ -384,15 +408,8 @@ var InputWithDatePicker = forwardRef(function (_a, ref) {
|
|
|
384
408
|
var handleDateChange = function (newDate) {
|
|
385
409
|
setDate(newDate);
|
|
386
410
|
};
|
|
387
|
-
var forwardedRef =
|
|
388
|
-
|
|
389
|
-
// eslint-disable-next-line no-param-reassign
|
|
390
|
-
// @ts-ignore
|
|
391
|
-
ref.current = elem;
|
|
392
|
-
}
|
|
393
|
-
field.ref(elem);
|
|
394
|
-
};
|
|
395
|
-
return (jsxs(Fragment, { children: [jsx$1(InputForDatepicker, __assign({ mask: "99.99.9999", name: name, handleCLick: handleModalOpen, value: formattedValue || value, onChange: handleChange, disabled: disabled, message: error, ref: forwardedRef }, props)), jsxs(StyledModal, __assign({ title: title, description: description, isOpen: isModalOpen, handleClose: handleModalClose, alignTitle: alignTitle }, { children: [jsx$1(ContentWrapper$1, { children: jsx$1(DatePicker, __assign({ inline: true, selected: date || formattedDate, onChange: handleDateChange, calendarContainer: StyledCalendarStandardContainer, renderCustomHeader: function (headProps) { return (jsx$1(CalendarHeaderWithSelect, __assign({ yearOptions: yearList, max: max, min: min }, headProps))); }, renderDayContents: function (day) { return (jsx$1(DayContent, { children: day })); }, maxDate: max === null || max === void 0 ? void 0 : max.toJSDate(), minDate: min === null || min === void 0 ? void 0 : min.toJSDate() }, datePickerProps)) }), jsx$1(ModalFooter, { fullWidth: true, disabled: !formattedDate && !date, onClick: acceptWithDateSelected, label: footerLabel })] }))] }));
|
|
411
|
+
var forwardedRef = useForkRef(ref, field.ref);
|
|
412
|
+
return (jsxs(Fragment, { children: [jsx$1(InputForDatepicker, __assign({ mask: "00.00.0000", name: name, handleClick: handleModalOpen, value: formattedValue || value, onChange: handleChange, disabled: disabled, message: error, ref: forwardedRef }, props)), jsxs(StyledModal, __assign({ title: title, description: description, isOpen: isModalOpen, handleClose: handleModalClose, alignTitle: alignTitle }, { children: [jsx$1(ContentWrapper$1, { children: jsx$1(DatePicker, __assign({ inline: true, selected: date || formattedDate, onChange: handleDateChange, calendarContainer: StyledCalendarStandardContainer, renderCustomHeader: function (headProps) { return (jsx$1(CalendarHeaderWithSelect, __assign({ yearOptions: yearList, max: max, min: min }, headProps))); }, renderDayContents: function (day) { return (jsx$1(DayContent, { children: day })); }, maxDate: max === null || max === void 0 ? void 0 : max.toJSDate(), minDate: min === null || min === void 0 ? void 0 : min.toJSDate() }, datePickerProps)) }), jsx$1(ModalFooter, { fullWidth: true, disabled: !formattedDate && !date, onClick: acceptWithDateSelected, label: footerLabel })] }))] }));
|
|
396
413
|
});
|
|
397
414
|
InputWithDatePicker.defaultProps = {
|
|
398
415
|
title: "Дата рождения",
|
|
@@ -526,29 +543,20 @@ var InputPhoneWithForm = forwardRef(function (props, ref) {
|
|
|
526
543
|
};
|
|
527
544
|
var handleChange = function (e) {
|
|
528
545
|
phoneRegister.field.onChange(e);
|
|
529
|
-
if (other.onChange) {
|
|
530
|
-
other.onChange(e);
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
var forwardedRef = function (elem) {
|
|
534
|
-
if (ref) {
|
|
535
|
-
// eslint-disable-next-line no-param-reassign
|
|
536
|
-
// @ts-ignore
|
|
537
|
-
ref.current = elem;
|
|
538
|
-
}
|
|
539
|
-
phoneRegister.field.ref(elem);
|
|
540
|
-
};
|
|
541
|
-
useEffect(function () {
|
|
542
546
|
if (!codeRegister.field.value) {
|
|
543
547
|
codeRegister.field.onChange({
|
|
544
548
|
target: { value: "7", name: "".concat(name, ".phoneCode") },
|
|
545
549
|
type: "change",
|
|
546
550
|
});
|
|
547
551
|
}
|
|
548
|
-
|
|
552
|
+
if (other.onChange) {
|
|
553
|
+
other.onChange(e);
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
var forwardedRef = useForkRef(ref, phoneRegister.field.ref);
|
|
549
557
|
return (jsx(InputWithCountryDropdown, __assign({ message: errorMessage,
|
|
550
558
|
// @ts-ignore
|
|
551
|
-
hiddenInputProps: __assign(__assign(
|
|
559
|
+
hiddenInputProps: __assign(__assign({}, codeRegister.field), hiddenInputProps), onSelectCountry: handleCountryChange }, phoneRegister.field, other, { onChange: handleChange, ref: forwardedRef, autoComplete: "false" })));
|
|
552
560
|
});
|
|
553
561
|
InputPhoneWithForm.defaultProps = {
|
|
554
562
|
name: "phone",
|
|
@@ -648,14 +656,6 @@ var InputWithMask = forwardRef(function (_a, ref) {
|
|
|
648
656
|
inputProps.onChange(e);
|
|
649
657
|
}
|
|
650
658
|
};
|
|
651
|
-
var forwardedRef = function (elem, field) {
|
|
652
|
-
if (ref) {
|
|
653
|
-
// eslint-disable-next-line no-param-reassign
|
|
654
|
-
// @ts-ignore
|
|
655
|
-
ref.current = elem;
|
|
656
|
-
}
|
|
657
|
-
field.ref(elem);
|
|
658
|
-
};
|
|
659
659
|
var getError = function (fieldState) {
|
|
660
660
|
var _a;
|
|
661
661
|
return typeof error !== "undefined" && String(error).length > 0
|
|
@@ -666,7 +666,7 @@ var InputWithMask = forwardRef(function (_a, ref) {
|
|
|
666
666
|
var field = _a.field, fieldState = _a.fieldState;
|
|
667
667
|
return (jsx(InputWithMask$1, __assign({ message: getError(fieldState) }, field, inputProps, { onChange: function (e) {
|
|
668
668
|
return handleChange(e, field);
|
|
669
|
-
},
|
|
669
|
+
}, inputRef: ref })));
|
|
670
670
|
} }));
|
|
671
671
|
});
|
|
672
672
|
|