@alfalab/core-components-date-range-input 2.1.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/{esm/Component.d.ts → Component-105ad648.d.ts} +46 -5
  2. package/{Component.js → Component-105ad648.js} +25 -33
  3. package/Component.desktop.d.ts +5 -0
  4. package/Component.desktop.js +22 -0
  5. package/Component.mobile.d.ts +5 -0
  6. package/Component.mobile.js +22 -0
  7. package/Component.responsive.d.ts +12 -0
  8. package/Component.responsive.js +32 -0
  9. package/components/date-range-input/Component.d.ts +0 -0
  10. package/components/date-range-input/Component.js +18 -0
  11. package/{esm → components/date-range-input}/index.css +6 -6
  12. package/components/date-range-input/index.d.ts +1 -0
  13. package/components/date-range-input/index.js +18 -0
  14. package/cssm/{Component.d.ts → Component-a4cfbf46.d.ts} +46 -5
  15. package/cssm/{Component.js → Component-a4cfbf46.js} +27 -35
  16. package/cssm/Component.desktop.d.ts +5 -0
  17. package/cssm/Component.desktop.js +23 -0
  18. package/cssm/Component.mobile.d.ts +5 -0
  19. package/cssm/Component.mobile.js +23 -0
  20. package/cssm/Component.responsive.d.ts +12 -0
  21. package/cssm/Component.responsive.js +33 -0
  22. package/cssm/components/date-range-input/Component.d.ts +0 -0
  23. package/cssm/components/date-range-input/Component.js +19 -0
  24. package/cssm/components/date-range-input/index.d.ts +1 -0
  25. package/cssm/components/date-range-input/index.js +19 -0
  26. package/cssm/{index.module.css → components/date-range-input/index.module.css} +0 -0
  27. package/cssm/desktop.d.ts +2 -0
  28. package/cssm/desktop.js +20 -0
  29. package/cssm/index.d.ts +1 -1
  30. package/cssm/index.js +8 -7
  31. package/cssm/mobile.d.ts +2 -0
  32. package/cssm/mobile.js +20 -0
  33. package/cssm/responsive.d.ts +2 -0
  34. package/cssm/responsive.js +23 -0
  35. package/cssm/utils/format.js +9 -11
  36. package/cssm/utils/index.js +1 -3
  37. package/desktop.d.ts +2 -0
  38. package/desktop.js +19 -0
  39. package/{modern/Component.d.ts → esm/Component-e59830f5.d.ts} +46 -5
  40. package/esm/{Component.js → Component-e59830f5.js} +10 -17
  41. package/esm/Component.desktop.d.ts +5 -0
  42. package/esm/Component.desktop.js +16 -0
  43. package/esm/Component.mobile.d.ts +5 -0
  44. package/esm/Component.mobile.js +16 -0
  45. package/esm/Component.responsive.d.ts +12 -0
  46. package/esm/Component.responsive.js +26 -0
  47. package/esm/components/date-range-input/Component.d.ts +0 -0
  48. package/esm/components/date-range-input/Component.js +12 -0
  49. package/{index.css → esm/components/date-range-input/index.css} +6 -6
  50. package/esm/components/date-range-input/index.d.ts +1 -0
  51. package/esm/components/date-range-input/index.js +12 -0
  52. package/esm/desktop.d.ts +2 -0
  53. package/esm/desktop.js +13 -0
  54. package/esm/index.d.ts +1 -1
  55. package/esm/index.js +6 -3
  56. package/esm/mobile.d.ts +2 -0
  57. package/esm/mobile.js +13 -0
  58. package/esm/responsive.d.ts +2 -0
  59. package/esm/responsive.js +16 -0
  60. package/esm/utils/format.js +3 -3
  61. package/esm/utils/index.js +1 -1
  62. package/index.d.ts +1 -1
  63. package/index.js +7 -6
  64. package/mobile.d.ts +2 -0
  65. package/mobile.js +19 -0
  66. package/modern/Component.desktop.d.ts +5 -0
  67. package/modern/Component.desktop.js +16 -0
  68. package/modern/Component.mobile.d.ts +5 -0
  69. package/modern/Component.mobile.js +16 -0
  70. package/modern/Component.responsive.d.ts +12 -0
  71. package/modern/Component.responsive.js +25 -0
  72. package/{Component.d.ts → modern/components/date-range-input/Component.d.ts} +12 -4
  73. package/modern/{Component.js → components/date-range-input/Component.js} +5 -11
  74. package/modern/{index.css → components/date-range-input/index.css} +6 -6
  75. package/modern/components/date-range-input/index.d.ts +1 -0
  76. package/modern/components/date-range-input/index.js +12 -0
  77. package/modern/desktop.d.ts +2 -0
  78. package/modern/desktop.js +13 -0
  79. package/modern/index.d.ts +1 -1
  80. package/modern/index.js +6 -3
  81. package/modern/mobile.d.ts +2 -0
  82. package/modern/mobile.js +13 -0
  83. package/modern/responsive.d.ts +2 -0
  84. package/modern/responsive.js +16 -0
  85. package/modern/utils/index.js +1 -1
  86. package/package.json +5 -5
  87. package/responsive.d.ts +2 -0
  88. package/responsive.js +22 -0
  89. package/utils/format.js +9 -11
  90. package/utils/index.js +1 -3
@@ -2,13 +2,11 @@ import React, { useRef, useState, useEffect } from 'react';
2
2
  import mergeRefs from 'react-merge-refs';
3
3
  import cn from 'classnames';
4
4
  import dateFnsIsValid from 'date-fns/isValid';
5
- import { usePeriod, CalendarMobile, Calendar } from '@alfalab/core-components-calendar/esm';
5
+ import { usePeriod, Calendar } from '@alfalab/core-components-calendar/esm';
6
6
  import { IconButton } from '@alfalab/core-components-icon-button/esm';
7
7
  import { Input } from '@alfalab/core-components-input/esm';
8
8
  import { Popover } from '@alfalab/core-components-popover/esm';
9
- import { useMedia } from '@alfalab/hooks';
10
9
  import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
11
- import 'date-fns/parse';
12
10
  import { parseTimestampToDate, DATE_FORMAT, DATE_MASK, format, parseDateString, isCompleteDateInput, isValid } from './utils/format.js';
13
11
 
14
12
  /******************************************************************************
@@ -50,24 +48,19 @@ function __rest(s, e) {
50
48
  return t;
51
49
  }
52
50
 
53
- var styles = {"component":"date-range-input__component_1l4m9","calendarContainer":"date-range-input__calendarContainer_1l4m9","calendarResponsive":"date-range-input__calendarResponsive_1l4m9","block":"date-range-input__block_1l4m9"};
54
- require('./index.css')
51
+ var styles = {"component":"date-range-input__component_1yhrr","calendarContainer":"date-range-input__calendarContainer_1yhrr","calendarResponsive":"date-range-input__calendarResponsive_1yhrr","block":"date-range-input__block_1yhrr"};
52
+ require('./components/date-range-input/index.css')
55
53
 
56
54
  /* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
57
55
  var DateRangeInput = React.forwardRef(function (_a, ref) {
58
56
  var _b, _c;
59
57
  var _d;
60
- var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, picker = _a.picker, _e = _a.defaultValue, defaultValue = _e === void 0 ? '' : _e, propValue = _a.value, onChange = _a.onChange, onComplete = _a.onComplete, rightAddons = _a.rightAddons, useAnchorWidth = _a.useAnchorWidth, block = _a.block, _f = _a.popoverPosition, popoverPosition = _f === void 0 ? 'bottom-start' : _f, zIndexPopover = _a.zIndexPopover, preventFlip = _a.preventFlip, _g = _a.Calendar, Calendar$1 = _g === void 0 ? Calendar : _g, _h = _a.calendarProps, calendarProps = _h === void 0 ? {} : _h, defaultMonth = _a.defaultMonth, _j = _a.minDate, minDate = _j === void 0 ? calendarProps.minDate : _j, _k = _a.maxDate, maxDate = _k === void 0 ? calendarProps.maxDate : _k, _l = _a.offDays, offDays = _l === void 0 ? calendarProps.offDays || [] : _l, _m = _a.events, events = _m === void 0 ? calendarProps.events || [] : _m, _o = _a.defaultOpen, defaultOpen = _o === void 0 ? false : _o, restProps = __rest(_a, ["className", "inputClassName", "popoverClassName", "disabled", "readOnly", "picker", "defaultValue", "value", "onChange", "onComplete", "rightAddons", "useAnchorWidth", "block", "popoverPosition", "zIndexPopover", "preventFlip", "Calendar", "calendarProps", "defaultMonth", "minDate", "maxDate", "offDays", "events", "defaultOpen"]);
61
- var view = useMedia([
62
- ['mobile', '(max-width: 1023px)'],
63
- ['desktop', '(min-width: 1024px)'],
64
- ], 'desktop')[0];
58
+ var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, picker = _a.picker, _e = _a.defaultValue, defaultValue = _e === void 0 ? '' : _e, propValue = _a.value, onChange = _a.onChange, onComplete = _a.onComplete, rightAddons = _a.rightAddons, useAnchorWidth = _a.useAnchorWidth, block = _a.block, _f = _a.popoverPosition, popoverPosition = _f === void 0 ? 'bottom-start' : _f, zIndexPopover = _a.zIndexPopover, preventFlip = _a.preventFlip, _g = _a.Calendar, Calendar$1 = _g === void 0 ? Calendar : _g, _h = _a.calendarProps, calendarProps = _h === void 0 ? {} : _h, defaultMonth = _a.defaultMonth, _j = _a.minDate, minDate = _j === void 0 ? calendarProps.minDate : _j, _k = _a.maxDate, maxDate = _k === void 0 ? calendarProps.maxDate : _k, _l = _a.offDays, offDays = _l === void 0 ? calendarProps.offDays || [] : _l, _m = _a.events, events = _m === void 0 ? calendarProps.events || [] : _m, _o = _a.defaultOpen, defaultOpen = _o === void 0 ? false : _o, _p = _a.view, view = _p === void 0 ? 'desktop' : _p, restProps = __rest(_a, ["className", "inputClassName", "popoverClassName", "disabled", "readOnly", "picker", "defaultValue", "value", "onChange", "onComplete", "rightAddons", "useAnchorWidth", "block", "popoverPosition", "zIndexPopover", "preventFlip", "Calendar", "calendarProps", "defaultMonth", "minDate", "maxDate", "offDays", "events", "defaultOpen", "view"]);
65
59
  var inputRef = useRef(null);
66
60
  var calendarRef = useRef(null);
67
- var _p = useState(propValue || defaultValue), value = _p[0], setValue = _p[1];
68
- var _q = useState(false), open = _q[0], setOpen = _q[1];
61
+ var _q = useState(propValue || defaultValue), value = _q[0], setValue = _q[1];
62
+ var _r = useState(false), open = _r[0], setOpen = _r[1];
69
63
  var inputDisabled = disabled || readOnly;
70
- var CalendarComponent = view === 'desktop' ? Calendar$1 : CalendarMobile;
71
64
  var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
72
65
  useEffect(function () {
73
66
  setOpen(defaultOpen);
@@ -95,7 +88,7 @@ var DateRangeInput = React.forwardRef(function (_a, ref) {
95
88
  });
96
89
  }
97
90
  };
98
- var _r = usePeriod({ onPeriodChange: handlePeriodChange }), selectedFrom = _r.selectedFrom, selectedTo = _r.selectedTo, updatePeriod = _r.updatePeriod, resetPeriod = _r.resetPeriod, setStart = _r.setStart, setEnd = _r.setEnd;
91
+ var _s = usePeriod({ onPeriodChange: handlePeriodChange }), selectedFrom = _s.selectedFrom, selectedTo = _s.selectedTo, updatePeriod = _s.updatePeriod, resetPeriod = _s.resetPeriod, setStart = _s.setStart, setEnd = _s.setEnd;
99
92
  var handleInputWrapperFocus = function (event) {
100
93
  if (view === 'desktop') {
101
94
  if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {
@@ -172,7 +165,7 @@ var DateRangeInput = React.forwardRef(function (_a, ref) {
172
165
  };
173
166
  useEffect(function () {
174
167
  if (selectedFrom && selectedTo) {
175
- setValue(parseTimestampToDate(selectedFrom) + " - " + parseTimestampToDate(selectedTo));
168
+ setValue("".concat(parseTimestampToDate(selectedFrom), " - ").concat(parseTimestampToDate(selectedTo)));
176
169
  }
177
170
  else if (selectedFrom && value.length < DATE_FORMAT.length) {
178
171
  setValue(parseTimestampToDate(selectedFrom));
@@ -194,7 +187,7 @@ var DateRangeInput = React.forwardRef(function (_a, ref) {
194
187
  var renderCalendar = function () { return (
195
188
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
196
189
  React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
197
- React.createElement(CalendarComponent, __assign({}, calendarProps, { responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, selectedFrom: selectedFrom, selectedTo: selectedTo, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })))); };
190
+ React.createElement(Calendar$1, __assign({}, calendarProps, { responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, selectedFrom: selectedFrom, selectedTo: selectedTo, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })))); };
198
191
  return (React.createElement("div", { className: cn(styles.component, className, (_b = {},
199
192
  _b[styles.block] = block,
200
193
  _b)), onClick: inputDisabled ? undefined : handleInputWrapperClick, onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
@@ -206,4 +199,4 @@ var DateRangeInput = React.forwardRef(function (_a, ref) {
206
199
  _c)), className: popoverClassName, position: popoverPosition, offset: [0, 8], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
207
200
  });
208
201
 
209
- export { DateRangeInput };
202
+ export { DateRangeInput as D, __assign as _, __rest as a };
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { DateRangeInputProps } from "./Component-e59830f5";
3
+ type DateRangeInputDesktopProps = Omit<DateRangeInputProps, 'view'>;
4
+ declare const DateRangeInputDesktop: FC<DateRangeInputDesktopProps>;
5
+ export { DateRangeInputDesktopProps, DateRangeInputDesktop };
@@ -0,0 +1,16 @@
1
+ import { D as DateRangeInput, _ as __assign } from './Component-e59830f5.js';
2
+ import React from 'react';
3
+ import 'react-merge-refs';
4
+ import 'classnames';
5
+ import 'date-fns/isValid';
6
+ import '@alfalab/core-components-calendar/esm';
7
+ import '@alfalab/core-components-icon-button/esm';
8
+ import '@alfalab/core-components-input/esm';
9
+ import '@alfalab/core-components-popover/esm';
10
+ import '@alfalab/icons-glyph/CalendarMIcon';
11
+ import './utils/format.js';
12
+ import 'date-fns/parse';
13
+
14
+ var DateRangeInputDesktop = function (props) { return (React.createElement(DateRangeInput, __assign({}, props))); };
15
+
16
+ export { DateRangeInputDesktop };
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { DateRangeInputProps } from "./Component-e59830f5";
3
+ type DateRangeInputMobileProps = Omit<DateRangeInputProps, 'view'>;
4
+ declare const DateRangeInputMobile: FC<DateRangeInputMobileProps>;
5
+ export { DateRangeInputMobileProps, DateRangeInputMobile };
@@ -0,0 +1,16 @@
1
+ import { D as DateRangeInput, _ as __assign } from './Component-e59830f5.js';
2
+ import React from 'react';
3
+ import { CalendarMobile } from '@alfalab/core-components-calendar/esm';
4
+ import 'react-merge-refs';
5
+ import 'classnames';
6
+ import 'date-fns/isValid';
7
+ import '@alfalab/core-components-icon-button/esm';
8
+ import '@alfalab/core-components-input/esm';
9
+ import '@alfalab/core-components-popover/esm';
10
+ import '@alfalab/icons-glyph/CalendarMIcon';
11
+ import './utils/format.js';
12
+ import 'date-fns/parse';
13
+
14
+ var DateRangeInputMobile = function (props) { return (React.createElement(DateRangeInput, __assign({ Calendar: CalendarMobile, view: 'mobile' }, props))); };
15
+
16
+ export { DateRangeInputMobile };
@@ -0,0 +1,12 @@
1
+ import { FC } from 'react';
2
+ import { DateRangeInputProps } from "./Component-e59830f5";
3
+ type DateRangeInputResponsiveProps = Omit<DateRangeInputProps, 'view'> & {
4
+ /**
5
+ * Контрольная точка, с нее начинается desktop версия
6
+ * @default 1024
7
+ */
8
+ breakpoint?: number;
9
+ };
10
+ type DateRangeInputMedia = 'desktop' | 'mobile';
11
+ declare const DateRangeInputResponsive: FC<DateRangeInputResponsiveProps>;
12
+ export { DateRangeInputResponsiveProps, DateRangeInputMedia, DateRangeInputResponsive };
@@ -0,0 +1,26 @@
1
+ import { a as __rest, _ as __assign } from './Component-e59830f5.js';
2
+ import React from 'react';
3
+ import { useMedia } from '@alfalab/hooks';
4
+ import { DateRangeInputDesktop } from './Component.desktop.js';
5
+ import { DateRangeInputMobile } from './Component.mobile.js';
6
+ import 'react-merge-refs';
7
+ import 'classnames';
8
+ import 'date-fns/isValid';
9
+ import '@alfalab/core-components-calendar/esm';
10
+ import '@alfalab/core-components-icon-button/esm';
11
+ import '@alfalab/core-components-input/esm';
12
+ import '@alfalab/core-components-popover/esm';
13
+ import '@alfalab/icons-glyph/CalendarMIcon';
14
+ import './utils/format.js';
15
+ import 'date-fns/parse';
16
+
17
+ var DateRangeInputResponsive = function (_a) {
18
+ var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps = __rest(_a, ["breakpoint"]);
19
+ var view = useMedia([
20
+ ['mobile', "(max-width: ".concat(breakpoint - 1, "px)")],
21
+ ['desktop', "(min-width: ".concat(breakpoint, "px)")],
22
+ ], 'desktop')[0];
23
+ return view === 'desktop' ? (React.createElement(DateRangeInputDesktop, __assign({}, restProps))) : (React.createElement(DateRangeInputMobile, __assign({}, restProps)));
24
+ };
25
+
26
+ export { DateRangeInputResponsive };
File without changes
@@ -0,0 +1,12 @@
1
+ export { D as DateRangeInput } from '../../Component-e59830f5.js';
2
+ import 'react';
3
+ import 'react-merge-refs';
4
+ import 'classnames';
5
+ import 'date-fns/isValid';
6
+ import '@alfalab/core-components-calendar/esm';
7
+ import '@alfalab/core-components-icon-button/esm';
8
+ import '@alfalab/core-components-input/esm';
9
+ import '@alfalab/core-components-popover/esm';
10
+ import '@alfalab/icons-glyph/CalendarMIcon';
11
+ import '../../utils/format.js';
12
+ import 'date-fns/parse';
@@ -1,4 +1,4 @@
1
- /* hash: 1exyq */
1
+ /* hash: 2v93k */
2
2
  :root {
3
3
 
4
4
  /* Hard */
@@ -39,26 +39,26 @@
39
39
  :root {
40
40
  --calendar-popover-border-radius: 0 0 var(--border-radius-s) var(--border-radius-s);
41
41
  }
42
- .date-range-input__component_1l4m9 {
42
+ .date-range-input__component_1yhrr {
43
43
  display: inline-block;
44
44
  outline: none;
45
45
  position: relative;
46
46
  }
47
- .date-range-input__calendarContainer_1l4m9 {
47
+ .date-range-input__calendarContainer_1yhrr {
48
48
  display: inline-block;
49
49
  box-sizing: border-box;
50
50
  border-radius: var(--calendar-popover-border-radius)
51
51
  }
52
52
  @media (max-width: 374px) {
53
- .date-range-input__calendarContainer_1l4m9 {
53
+ .date-range-input__calendarContainer_1yhrr {
54
54
  width: 100%;
55
55
  min-width: 288px
56
56
  }
57
57
  }
58
- .date-range-input__calendarResponsive_1l4m9 {
58
+ .date-range-input__calendarResponsive_1yhrr {
59
59
  width: var(--calendar-width);
60
60
  padding: 0 var(--gap-m);
61
61
  }
62
- .date-range-input__block_1l4m9 {
62
+ .date-range-input__block_1yhrr {
63
63
  width: 100%;
64
64
  }
@@ -0,0 +1 @@
1
+ export * from "../../Component-e59830f5";
@@ -0,0 +1,12 @@
1
+ export { D as DateRangeInput } from '../../Component-e59830f5.js';
2
+ import 'react';
3
+ import 'react-merge-refs';
4
+ import 'classnames';
5
+ import 'date-fns/isValid';
6
+ import '@alfalab/core-components-calendar/esm';
7
+ import '@alfalab/core-components-icon-button/esm';
8
+ import '@alfalab/core-components-input/esm';
9
+ import '@alfalab/core-components-popover/esm';
10
+ import '@alfalab/icons-glyph/CalendarMIcon';
11
+ import '../../utils/format.js';
12
+ import 'date-fns/parse';
@@ -0,0 +1,2 @@
1
+ export * from "./Component.desktop";
2
+ export {};
package/esm/desktop.js ADDED
@@ -0,0 +1,13 @@
1
+ export { DateRangeInputDesktop } from './Component.desktop.js';
2
+ import './Component-e59830f5.js';
3
+ import 'react';
4
+ import 'react-merge-refs';
5
+ import 'classnames';
6
+ import 'date-fns/isValid';
7
+ import '@alfalab/core-components-calendar/esm';
8
+ import '@alfalab/core-components-icon-button/esm';
9
+ import '@alfalab/core-components-input/esm';
10
+ import '@alfalab/core-components-popover/esm';
11
+ import '@alfalab/icons-glyph/CalendarMIcon';
12
+ import './utils/format.js';
13
+ import 'date-fns/parse';
package/esm/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./Component";
1
+ export { DateRangeInputResponsive as DateRangeInput, DateRangeInputResponsiveProps as DateRangeInputProps } from "./responsive";
package/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
- export { DateRangeInput } from './Component.js';
1
+ export { DateRangeInputResponsive as DateRangeInput } from './Component.responsive.js';
2
+ import './Component-e59830f5.js';
2
3
  import 'react';
3
4
  import 'react-merge-refs';
4
5
  import 'classnames';
@@ -7,7 +8,9 @@ import '@alfalab/core-components-calendar/esm';
7
8
  import '@alfalab/core-components-icon-button/esm';
8
9
  import '@alfalab/core-components-input/esm';
9
10
  import '@alfalab/core-components-popover/esm';
10
- import '@alfalab/hooks';
11
11
  import '@alfalab/icons-glyph/CalendarMIcon';
12
- import 'date-fns/parse';
13
12
  import './utils/format.js';
13
+ import 'date-fns/parse';
14
+ import '@alfalab/hooks';
15
+ import './Component.desktop.js';
16
+ import './Component.mobile.js';
@@ -0,0 +1,2 @@
1
+ export * from "./Component.mobile";
2
+ export {};
package/esm/mobile.js ADDED
@@ -0,0 +1,13 @@
1
+ export { DateRangeInputMobile } from './Component.mobile.js';
2
+ import './Component-e59830f5.js';
3
+ import 'react';
4
+ import 'react-merge-refs';
5
+ import 'classnames';
6
+ import 'date-fns/isValid';
7
+ import '@alfalab/core-components-calendar/esm';
8
+ import '@alfalab/core-components-icon-button/esm';
9
+ import '@alfalab/core-components-input/esm';
10
+ import '@alfalab/core-components-popover/esm';
11
+ import '@alfalab/icons-glyph/CalendarMIcon';
12
+ import './utils/format.js';
13
+ import 'date-fns/parse';
@@ -0,0 +1,2 @@
1
+ export * from "./Component.responsive";
2
+ export {};
@@ -0,0 +1,16 @@
1
+ export { DateRangeInputResponsive } from './Component.responsive.js';
2
+ import './Component-e59830f5.js';
3
+ import 'react';
4
+ import 'react-merge-refs';
5
+ import 'classnames';
6
+ import 'date-fns/isValid';
7
+ import '@alfalab/core-components-calendar/esm';
8
+ import '@alfalab/core-components-icon-button/esm';
9
+ import '@alfalab/core-components-input/esm';
10
+ import '@alfalab/core-components-popover/esm';
11
+ import '@alfalab/icons-glyph/CalendarMIcon';
12
+ import './utils/format.js';
13
+ import 'date-fns/parse';
14
+ import '@alfalab/hooks';
15
+ import './Component.desktop.js';
16
+ import './Component.mobile.js';
@@ -72,12 +72,12 @@ var parseTimestampToDate = function (timestamp) {
72
72
  var month = date.getMonth() + 1;
73
73
  var day = date.getDate();
74
74
  if (month < 10) {
75
- month = "0" + month;
75
+ month = "0".concat(month);
76
76
  }
77
77
  if (day < 10) {
78
- day = "0" + day;
78
+ day = "0".concat(day);
79
79
  }
80
- return day + "." + month + "." + year;
80
+ return "".concat(day, ".").concat(month, ".").concat(year);
81
81
  };
82
82
 
83
83
  export { DATE_FORMAT, DATE_MASK, format, isCompleteDateInput, isValid, parseDateString, parseTimestampToDate };
@@ -1,3 +1,3 @@
1
+ export { DATE_FORMAT, DATE_MASK, format, isCompleteDateInput, isValid, parseDateString, parseTimestampToDate } from './format.js';
1
2
  import 'date-fns/isValid';
2
3
  import 'date-fns/parse';
3
- export { DATE_FORMAT, DATE_MASK, format, isCompleteDateInput, isValid, parseDateString, parseTimestampToDate } from './format.js';
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./Component";
1
+ export { DateRangeInputResponsive as DateRangeInput, DateRangeInputResponsiveProps as DateRangeInputProps } from "./responsive";
package/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var Component = require('./Component.js');
3
+ var Component_responsive = require('./Component.responsive.js');
4
+ require('./Component-105ad648.js');
6
5
  require('react');
7
6
  require('react-merge-refs');
8
7
  require('classnames');
@@ -11,11 +10,13 @@ require('@alfalab/core-components-calendar');
11
10
  require('@alfalab/core-components-icon-button');
12
11
  require('@alfalab/core-components-input');
13
12
  require('@alfalab/core-components-popover');
14
- require('@alfalab/hooks');
15
13
  require('@alfalab/icons-glyph/CalendarMIcon');
16
- require('date-fns/parse');
17
14
  require('./utils/format.js');
15
+ require('date-fns/parse');
16
+ require('@alfalab/hooks');
17
+ require('./Component.desktop.js');
18
+ require('./Component.mobile.js');
18
19
 
19
20
 
20
21
 
21
- exports.DateRangeInput = Component.DateRangeInput;
22
+ exports.DateRangeInput = Component_responsive.DateRangeInputResponsive;
package/mobile.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./Component.mobile";
2
+ export {};
package/mobile.js ADDED
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var Component_mobile = require('./Component.mobile.js');
4
+ require('./Component-105ad648.js');
5
+ require('react');
6
+ require('react-merge-refs');
7
+ require('classnames');
8
+ require('date-fns/isValid');
9
+ require('@alfalab/core-components-calendar');
10
+ require('@alfalab/core-components-icon-button');
11
+ require('@alfalab/core-components-input');
12
+ require('@alfalab/core-components-popover');
13
+ require('@alfalab/icons-glyph/CalendarMIcon');
14
+ require('./utils/format.js');
15
+ require('date-fns/parse');
16
+
17
+
18
+
19
+ exports.DateRangeInputMobile = Component_mobile.DateRangeInputMobile;
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { DateRangeInputProps } from "./components/date-range-input/Component";
3
+ type DateRangeInputDesktopProps = Omit<DateRangeInputProps, 'view'>;
4
+ declare const DateRangeInputDesktop: FC<DateRangeInputDesktopProps>;
5
+ export { DateRangeInputDesktopProps, DateRangeInputDesktop };
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { DateRangeInput } from './components/date-range-input/Component.js';
3
+ import 'react-merge-refs';
4
+ import 'classnames';
5
+ import 'date-fns/isValid';
6
+ import '@alfalab/core-components-calendar/modern';
7
+ import '@alfalab/core-components-icon-button/modern';
8
+ import '@alfalab/core-components-input/modern';
9
+ import '@alfalab/core-components-popover/modern';
10
+ import '@alfalab/icons-glyph/CalendarMIcon';
11
+ import './utils/format.js';
12
+ import 'date-fns/parse';
13
+
14
+ const DateRangeInputDesktop = (props) => (React.createElement(DateRangeInput, { ...props }));
15
+
16
+ export { DateRangeInputDesktop };
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { DateRangeInputProps } from "./components/date-range-input/Component";
3
+ type DateRangeInputMobileProps = Omit<DateRangeInputProps, 'view'>;
4
+ declare const DateRangeInputMobile: FC<DateRangeInputMobileProps>;
5
+ export { DateRangeInputMobileProps, DateRangeInputMobile };
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { CalendarMobile } from '@alfalab/core-components-calendar/modern';
3
+ import { DateRangeInput } from './components/date-range-input/Component.js';
4
+ import 'react-merge-refs';
5
+ import 'classnames';
6
+ import 'date-fns/isValid';
7
+ import '@alfalab/core-components-icon-button/modern';
8
+ import '@alfalab/core-components-input/modern';
9
+ import '@alfalab/core-components-popover/modern';
10
+ import '@alfalab/icons-glyph/CalendarMIcon';
11
+ import './utils/format.js';
12
+ import 'date-fns/parse';
13
+
14
+ const DateRangeInputMobile = (props) => (React.createElement(DateRangeInput, { Calendar: CalendarMobile, view: 'mobile', ...props }));
15
+
16
+ export { DateRangeInputMobile };
@@ -0,0 +1,12 @@
1
+ import { FC } from 'react';
2
+ import { DateRangeInputProps } from "./components/date-range-input/Component";
3
+ type DateRangeInputResponsiveProps = Omit<DateRangeInputProps, 'view'> & {
4
+ /**
5
+ * Контрольная точка, с нее начинается desktop версия
6
+ * @default 1024
7
+ */
8
+ breakpoint?: number;
9
+ };
10
+ type DateRangeInputMedia = 'desktop' | 'mobile';
11
+ declare const DateRangeInputResponsive: FC<DateRangeInputResponsiveProps>;
12
+ export { DateRangeInputResponsiveProps, DateRangeInputMedia, DateRangeInputResponsive };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { useMedia } from '@alfalab/hooks';
3
+ import { DateRangeInputDesktop } from './Component.desktop.js';
4
+ import { DateRangeInputMobile } from './Component.mobile.js';
5
+ import './components/date-range-input/Component.js';
6
+ import 'react-merge-refs';
7
+ import 'classnames';
8
+ import 'date-fns/isValid';
9
+ import '@alfalab/core-components-calendar/modern';
10
+ import '@alfalab/core-components-icon-button/modern';
11
+ import '@alfalab/core-components-input/modern';
12
+ import '@alfalab/core-components-popover/modern';
13
+ import '@alfalab/icons-glyph/CalendarMIcon';
14
+ import './utils/format.js';
15
+ import 'date-fns/parse';
16
+
17
+ const DateRangeInputResponsive = ({ breakpoint = 1024, ...restProps }) => {
18
+ const [view] = useMedia([
19
+ ['mobile', `(max-width: ${breakpoint - 1}px)`],
20
+ ['desktop', `(min-width: ${breakpoint}px)`],
21
+ ], 'desktop');
22
+ return view === 'desktop' ? (React.createElement(DateRangeInputDesktop, { ...restProps })) : (React.createElement(DateRangeInputMobile, { ...restProps }));
23
+ };
24
+
25
+ export { DateRangeInputResponsive };
@@ -40,7 +40,7 @@ type DateRangeInputProps = Omit<InputProps, 'onChange'> & {
40
40
  /**
41
41
  * Компонент календаря
42
42
  */
43
- Calendar?: ElementType<CalendarProps>;
43
+ Calendar?: ElementType;
44
44
  /**
45
45
  * Доп. пропсы для календаря
46
46
  */
@@ -90,6 +90,10 @@ type DateRangeInputProps = Omit<InputProps, 'onChange'> & {
90
90
  * Растягивает компонент на ширину контейнера
91
91
  */
92
92
  block?: boolean;
93
+ /**
94
+ * Отображение компонента в мобильном или десктопном виде
95
+ */
96
+ view?: 'desktop' | 'mobile';
93
97
  };
94
98
  declare const DateRangeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
95
99
  /**
@@ -115,7 +119,7 @@ declare const DateRangeInput: React.ForwardRefExoticComponent<Omit<InputProps, "
115
119
  dateFrom?: Date;
116
120
  dateTo?: Date;
117
121
  value: string;
118
- }, event?: React.ChangeEvent<HTMLInputElement> | undefined) => void) | undefined;
122
+ }, event?: ChangeEvent<HTMLInputElement>) => void) | undefined;
119
123
  /**
120
124
  * Обработчик окончания ввода
121
125
  */
@@ -123,11 +127,11 @@ declare const DateRangeInput: React.ForwardRefExoticComponent<Omit<InputProps, "
123
127
  dateFrom: Date;
124
128
  dateTo: Date;
125
129
  value: string;
126
- }, event?: React.ChangeEvent<HTMLInputElement> | undefined) => void) | undefined;
130
+ }, event?: ChangeEvent<HTMLInputElement>) => void) | undefined;
127
131
  /**
128
132
  * Компонент календаря
129
133
  */
130
- Calendar?: React.ElementType<CalendarProps> | undefined;
134
+ Calendar?: React.ElementType<any> | undefined;
131
135
  /**
132
136
  * Доп. пропсы для календаря
133
137
  */
@@ -184,5 +188,9 @@ declare const DateRangeInput: React.ForwardRefExoticComponent<Omit<InputProps, "
184
188
  * Растягивает компонент на ширину контейнера
185
189
  */
186
190
  block?: boolean | undefined;
191
+ /**
192
+ * Отображение компонента в мобильном или десктопном виде
193
+ */
194
+ view?: "desktop" | "mobile" | undefined;
187
195
  } & React.RefAttributes<HTMLInputElement>>;
188
196
  export { DateRangeInputProps, DateRangeInput };
@@ -2,30 +2,24 @@ import React, { useRef, useState, useEffect } from 'react';
2
2
  import mergeRefs from 'react-merge-refs';
3
3
  import cn from 'classnames';
4
4
  import dateFnsIsValid from 'date-fns/isValid';
5
- import { Calendar, usePeriod, CalendarMobile } from '@alfalab/core-components-calendar/modern';
5
+ import { usePeriod, Calendar } from '@alfalab/core-components-calendar/modern';
6
6
  import { IconButton } from '@alfalab/core-components-icon-button/modern';
7
7
  import { Input } from '@alfalab/core-components-input/modern';
8
8
  import { Popover } from '@alfalab/core-components-popover/modern';
9
- import { useMedia } from '@alfalab/hooks';
10
9
  import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
10
+ import { parseTimestampToDate, DATE_FORMAT, DATE_MASK, format, parseDateString, isCompleteDateInput, isValid } from '../../utils/format.js';
11
11
  import 'date-fns/parse';
12
- import { parseTimestampToDate, DATE_FORMAT, DATE_MASK, format, parseDateString, isCompleteDateInput, isValid } from './utils/format.js';
13
12
 
14
- var styles = {"component":"date-range-input__component_1l4m9","calendarContainer":"date-range-input__calendarContainer_1l4m9","calendarResponsive":"date-range-input__calendarResponsive_1l4m9","block":"date-range-input__block_1l4m9"};
13
+ const styles = {"component":"date-range-input__component_1yhrr","calendarContainer":"date-range-input__calendarContainer_1yhrr","calendarResponsive":"date-range-input__calendarResponsive_1yhrr","block":"date-range-input__block_1yhrr"};
15
14
  require('./index.css')
16
15
 
17
16
  /* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
18
- const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverClassName, disabled, readOnly, picker, defaultValue = '', value: propValue, onChange, onComplete, rightAddons, useAnchorWidth, block, popoverPosition = 'bottom-start', zIndexPopover, preventFlip, Calendar: Calendar$1 = Calendar, calendarProps = {}, defaultMonth, minDate = calendarProps.minDate, maxDate = calendarProps.maxDate, offDays = calendarProps.offDays || [], events = calendarProps.events || [], defaultOpen = false, ...restProps }, ref) => {
19
- const [view] = useMedia([
20
- ['mobile', '(max-width: 1023px)'],
21
- ['desktop', '(min-width: 1024px)'],
22
- ], 'desktop');
17
+ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverClassName, disabled, readOnly, picker, defaultValue = '', value: propValue, onChange, onComplete, rightAddons, useAnchorWidth, block, popoverPosition = 'bottom-start', zIndexPopover, preventFlip, Calendar: Calendar$1 = Calendar, calendarProps = {}, defaultMonth, minDate = calendarProps.minDate, maxDate = calendarProps.maxDate, offDays = calendarProps.offDays || [], events = calendarProps.events || [], defaultOpen = false, view = 'desktop', ...restProps }, ref) => {
23
18
  const inputRef = useRef(null);
24
19
  const calendarRef = useRef(null);
25
20
  const [value, setValue] = useState(propValue || defaultValue);
26
21
  const [open, setOpen] = useState(false);
27
22
  const inputDisabled = disabled || readOnly;
28
- const CalendarComponent = view === 'desktop' ? Calendar$1 : CalendarMobile;
29
23
  const calendarResponsive = calendarProps?.responsive ?? true;
30
24
  useEffect(() => {
31
25
  setOpen(defaultOpen);
@@ -151,7 +145,7 @@ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverCla
151
145
  const renderCalendar = () => (
152
146
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
153
147
  React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
154
- React.createElement(CalendarComponent, { ...calendarProps, responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, selectedFrom: selectedFrom, selectedTo: selectedTo, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })));
148
+ React.createElement(Calendar$1, { ...calendarProps, responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, selectedFrom: selectedFrom, selectedTo: selectedTo, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })));
155
149
  return (React.createElement("div", { className: cn(styles.component, className, {
156
150
  [styles.block]: block,
157
151
  }), onClick: inputDisabled ? undefined : handleInputWrapperClick, onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },