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.
Files changed (49) hide show
  1. package/DesktopInputWithMonthPicker/cjs/index.js +5 -8
  2. package/DesktopInputWithMonthPicker/cjs/index.js.map +1 -1
  3. package/DesktopInputWithMonthPicker/cjs/package.json +1 -2
  4. package/DesktopInputWithMonthPicker/index.js +6 -8
  5. package/DesktopInputWithMonthPicker/index.js.map +1 -1
  6. package/DesktopInputWithMonthPicker/package.json +1 -2
  7. package/InputForDatepicker/cjs/index.js +5 -8
  8. package/InputForDatepicker/cjs/index.js.map +1 -1
  9. package/InputForDatepicker/cjs/package.json +1 -2
  10. package/InputForDatepicker/index.js +6 -8
  11. package/InputForDatepicker/index.js.map +1 -1
  12. package/InputForDatepicker/package.json +1 -2
  13. package/InputPhoneWithForm/cjs/index.js +53 -17
  14. package/InputPhoneWithForm/cjs/index.js.map +1 -1
  15. package/InputPhoneWithForm/index.js +33 -16
  16. package/InputPhoneWithForm/index.js.map +1 -1
  17. package/InputWithDatePicker/cjs/index.js +75 -41
  18. package/InputWithDatePicker/cjs/index.js.map +1 -1
  19. package/InputWithDatePicker/cjs/package.json +1 -2
  20. package/InputWithDatePicker/index.js +34 -17
  21. package/InputWithDatePicker/index.js.map +1 -1
  22. package/InputWithDatePicker/package.json +1 -2
  23. package/InputWithMask/cjs/index.js +1 -9
  24. package/InputWithMask/cjs/index.js.map +1 -1
  25. package/InputWithMask/index.js +1 -9
  26. package/InputWithMask/index.js.map +1 -1
  27. package/InputWithMonthPicker/cjs/index.js +5 -8
  28. package/InputWithMonthPicker/cjs/index.js.map +1 -1
  29. package/InputWithMonthPicker/cjs/package.json +1 -2
  30. package/InputWithMonthPicker/index.js +6 -8
  31. package/InputWithMonthPicker/index.js.map +1 -1
  32. package/InputWithMonthPicker/package.json +1 -2
  33. package/MobileInputWithMonthPicker/cjs/index.js +5 -8
  34. package/MobileInputWithMonthPicker/cjs/index.js.map +1 -1
  35. package/MobileInputWithMonthPicker/cjs/package.json +1 -2
  36. package/MobileInputWithMonthPicker/index.js +6 -8
  37. package/MobileInputWithMonthPicker/index.js.map +1 -1
  38. package/MobileInputWithMonthPicker/package.json +1 -2
  39. package/TestForm/cjs/index.js +79 -80
  40. package/TestForm/cjs/index.js.map +1 -1
  41. package/TestForm/cjs/package.json +0 -1
  42. package/TestForm/index.js +41 -41
  43. package/TestForm/index.js.map +1 -1
  44. package/TestForm/package.json +0 -1
  45. package/cjs/index.js +39 -41
  46. package/cjs/index.js.map +1 -1
  47. package/index.js +40 -41
  48. package/index.js.map +1 -1
  49. package/package.json +1 -1
package/index.js CHANGED
@@ -6,14 +6,13 @@ import { css, Global } from '@emotion/react';
6
6
  import * as React from 'react';
7
7
  import { forwardRef, useEffect, useRef, useState } from 'react';
8
8
  import { jsx, jsxs as jsxs$1, Fragment as Fragment$1 } from 'react/jsx-runtime';
9
- import { Caption, theme, Button, Container, Grid, InputWithAdornments, Heading, IconButton, InputWithMask as InputWithMask$1, LinearProgress, Divider, Modal, Switch as Switch$1, InputWithCountryDropdown } from 'kui-basic';
9
+ import { Caption, theme, Button, Container, Grid, InputWithAdornments, Heading, InputWithMask as InputWithMask$1, IconButton, LinearProgress, Divider, Modal, Switch as Switch$1, InputWithCountryDropdown } from 'kui-basic';
10
10
  import { useNavigate } from 'react-router-dom';
11
11
  import { DateTime } from 'luxon';
12
12
  import { HalfArrowIcon, PrevArrowIcon, NextArrowIcon, CalendarIcon, ArrowBackIcon, ArrowNextIcon, ClosedEyeIcon, OpenEyeIcon, CheckIcon } from 'kui-icon';
13
13
  import _ from 'lodash';
14
14
  import DatePicker from 'react-datepicker';
15
15
  import { Controller, useController } from 'react-hook-form';
16
- import InputMask from 'react-input-mask';
17
16
  import { scroller, Events, Link, animateScroll, Element } from 'react-scroll';
18
17
  import ru from 'date-fns/locale/ru';
19
18
  import { useLocation } from 'react-router';
@@ -339,19 +338,18 @@ var StyledHeading = styled(Heading)(templateObject_2$a || (templateObject_2$a =
339
338
  var CircleButtonStyled = styled(Button)(templateObject_3$4 || (templateObject_3$4 = __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"])));
340
339
  var templateObject_1$l, templateObject_2$a, templateObject_3$4;
341
340
 
342
- var InputForDatepicker = forwardRef(function (_a, ref) {
343
- var onClick = _a.onClick, onBlur = _a.onBlur, onFocus = _a.onFocus, props = __rest(_a, ["onClick", "onBlur", "onFocus"]);
344
- 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"]);
341
+ var InputForDatepicker = forwardRef(function (props, ref) {
342
+ var onClick = props.onClick, disabled = props.disabled, handleClick = props.handleClick, startIcon = props.startIcon, other = __rest(props, ["onClick", "disabled", "handleClick", "startIcon"]);
345
343
  var handleIconClick = function () {
346
- if (handleCLick) {
347
- handleCLick();
344
+ if (handleClick) {
345
+ handleClick();
348
346
  }
349
347
  else {
350
348
  onClick();
351
349
  }
352
350
  };
353
351
  var Icon = function () { return (jsx(IconWrapper, __assign({ disabled: disabled, onClick: handleIconClick }, { children: startIcon || jsx(CalendarIcon, { width: 19, height: 21 }) }))); };
354
- return (jsx(InputMask, __assign({ mask: mask, onChange: onChange, value: props.value, maskPlaceholder: null, alwaysShowMask: false, disabled: disabled, readOnly: readOnly, onFocus: onFocus, onBlur: onBlur }, { children: function () { return (jsx(InputWithAdornments, __assign({ onChange: onChange, disabled: disabled, value: props.value, endIcon: !startIcon && jsx(Icon, {}), startIcon: startIcon && jsx(Icon, {}) }, other, { ref: ref }))); } })));
352
+ return (jsx(InputWithMask$1, __assign({ disabled: disabled, endIcon: !startIcon && jsx(Icon, {}), startIcon: startIcon && jsx(Icon, {}) }, other, { ref: ref })));
355
353
  });
356
354
  var IconWrapper = styled.div(templateObject_1$k || (templateObject_1$k = __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"])));
357
355
  var templateObject_1$k;
@@ -434,14 +432,6 @@ var InputWithMask = forwardRef(function (_a, ref) {
434
432
  inputProps.onChange(e);
435
433
  }
436
434
  };
437
- var forwardedRef = function (elem, field) {
438
- if (ref) {
439
- // eslint-disable-next-line no-param-reassign
440
- // @ts-ignore
441
- ref.current = elem;
442
- }
443
- field.ref(elem);
444
- };
445
435
  var getError = function (fieldState) {
446
436
  var _a;
447
437
  return typeof error !== "undefined" && String(error).length > 0
@@ -452,7 +442,7 @@ var InputWithMask = forwardRef(function (_a, ref) {
452
442
  var field = _a.field, fieldState = _a.fieldState;
453
443
  return (jsx(InputWithMask$1, __assign({ message: getError(fieldState) }, field, inputProps, { onChange: function (e) {
454
444
  return handleChange(e, field);
455
- }, value: field.value || "", ref: function (e) { return forwardedRef(e, field); } })));
445
+ }, inputRef: ref })));
456
446
  } }));
457
447
  });
458
448
 
@@ -587,6 +577,31 @@ var ButtonWrapper = styled.div(templateObject_2$5 || (templateObject_2$5 = __mak
587
577
  var ButtonStyled = styled(Button)(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n @media (max-width: 600px) {\n width: 100%;\n }\n"], ["\n @media (max-width: 600px) {\n width: 100%;\n }\n"])));
588
578
  var templateObject_1$b, templateObject_2$5, templateObject_3$2;
589
579
 
580
+ function setRef(ref, value) {
581
+ if (typeof ref === "function") {
582
+ ref(value);
583
+ }
584
+ else if (ref) {
585
+ ref.current = value;
586
+ }
587
+ }
588
+ function useForkRef() {
589
+ var refs = [];
590
+ for (var _i = 0; _i < arguments.length; _i++) {
591
+ refs[_i] = arguments[_i];
592
+ }
593
+ return React.useMemo(function () {
594
+ if (refs.every(function (ref) { return ref == null; })) {
595
+ return null;
596
+ }
597
+ return function (instance) {
598
+ refs.forEach(function (ref) {
599
+ setRef(ref, instance);
600
+ });
601
+ };
602
+ }, refs);
603
+ }
604
+
590
605
  var generateYearRange = function (offsetFromCurrent, maxYearCount) {
591
606
  if (!offsetFromCurrent || !maxYearCount)
592
607
  return [];
@@ -654,15 +669,8 @@ var InputWithDatePicker = forwardRef(function (_a, ref) {
654
669
  var handleDateChange = function (newDate) {
655
670
  setDate(newDate);
656
671
  };
657
- var forwardedRef = function (elem) {
658
- if (ref) {
659
- // eslint-disable-next-line no-param-reassign
660
- // @ts-ignore
661
- ref.current = elem;
662
- }
663
- field.ref(elem);
664
- };
665
- 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 })] }))] }));
672
+ var forwardedRef = useForkRef(ref, field.ref);
673
+ 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 })] }))] }));
666
674
  });
667
675
  InputWithDatePicker.defaultProps = {
668
676
  title: "Дата рождения",
@@ -845,29 +853,20 @@ var InputPhoneWithForm = forwardRef(function (props, ref) {
845
853
  };
846
854
  var handleChange = function (e) {
847
855
  phoneRegister.field.onChange(e);
848
- if (other.onChange) {
849
- other.onChange(e);
850
- }
851
- };
852
- var forwardedRef = function (elem) {
853
- if (ref) {
854
- // eslint-disable-next-line no-param-reassign
855
- // @ts-ignore
856
- ref.current = elem;
857
- }
858
- phoneRegister.field.ref(elem);
859
- };
860
- useEffect(function () {
861
856
  if (!codeRegister.field.value) {
862
857
  codeRegister.field.onChange({
863
858
  target: { value: "7", name: "".concat(name, ".phoneCode") },
864
859
  type: "change",
865
860
  });
866
861
  }
867
- }, []);
862
+ if (other.onChange) {
863
+ other.onChange(e);
864
+ }
865
+ };
866
+ var forwardedRef = useForkRef(ref, phoneRegister.field.ref);
868
867
  return (jsx(InputWithCountryDropdown, __assign({ message: errorMessage,
869
868
  // @ts-ignore
870
- hiddenInputProps: __assign(__assign(__assign({}, codeRegister.field), hiddenInputProps), { value: codeRegister.field.value || "7" }), onSelectCountry: handleCountryChange }, phoneRegister.field, other, { onChange: handleChange, ref: forwardedRef, autoComplete: "false" })));
869
+ hiddenInputProps: __assign(__assign({}, codeRegister.field), hiddenInputProps), onSelectCountry: handleCountryChange }, phoneRegister.field, other, { onChange: handleChange, ref: forwardedRef, autoComplete: "false" })));
871
870
  });
872
871
  InputPhoneWithForm.defaultProps = {
873
872
  name: "phone",