@alfalab/core-components-date-range-input 2.2.8 → 2.2.9

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 (65) hide show
  1. package/Component.desktop.d.ts +5 -4
  2. package/Component.desktop.js +4 -2
  3. package/Component.mobile.d.ts +5 -4
  4. package/Component.mobile.js +4 -2
  5. package/Component.responsive.d.ts +5 -4
  6. package/Component.responsive.js +7 -5
  7. package/components/date-range-input/Component.d.ts +108 -0
  8. package/components/date-range-input/Component.js +220 -13
  9. package/components/date-range-input/index.css +6 -6
  10. package/components/date-range-input/index.d.ts +1 -1
  11. package/components/date-range-input/index.js +3 -1
  12. package/cssm/Component.desktop.d.ts +5 -4
  13. package/cssm/Component.desktop.js +4 -2
  14. package/cssm/Component.mobile.d.ts +5 -4
  15. package/cssm/Component.mobile.js +4 -2
  16. package/cssm/Component.responsive.d.ts +5 -4
  17. package/cssm/Component.responsive.js +7 -5
  18. package/cssm/components/date-range-input/Component.d.ts +108 -0
  19. package/cssm/components/date-range-input/Component.js +219 -14
  20. package/cssm/components/date-range-input/index.d.ts +1 -1
  21. package/cssm/components/date-range-input/index.js +3 -1
  22. package/cssm/desktop.js +3 -1
  23. package/cssm/index.js +5 -3
  24. package/cssm/mobile.js +4 -2
  25. package/cssm/responsive.js +5 -3
  26. package/desktop.js +3 -1
  27. package/esm/Component.desktop.d.ts +5 -4
  28. package/esm/Component.desktop.js +5 -3
  29. package/esm/Component.mobile.d.ts +5 -4
  30. package/esm/Component.mobile.js +5 -3
  31. package/esm/Component.responsive.d.ts +5 -4
  32. package/esm/Component.responsive.js +7 -5
  33. package/esm/components/date-range-input/Component.d.ts +108 -0
  34. package/esm/components/date-range-input/Component.js +216 -12
  35. package/esm/components/date-range-input/index.css +6 -6
  36. package/esm/components/date-range-input/index.d.ts +1 -1
  37. package/esm/components/date-range-input/index.js +3 -1
  38. package/esm/desktop.js +3 -1
  39. package/esm/index.js +5 -3
  40. package/esm/mobile.js +4 -2
  41. package/esm/responsive.js +5 -3
  42. package/index.js +5 -3
  43. package/mobile.js +4 -2
  44. package/modern/Component.desktop.d.ts +5 -4
  45. package/modern/Component.desktop.js +3 -2
  46. package/modern/Component.mobile.d.ts +5 -4
  47. package/modern/Component.mobile.js +3 -2
  48. package/modern/Component.responsive.d.ts +5 -4
  49. package/modern/Component.responsive.js +5 -4
  50. package/modern/components/date-range-input/Component.d.ts +16 -104
  51. package/modern/components/date-range-input/Component.js +65 -28
  52. package/modern/components/date-range-input/index.css +6 -6
  53. package/modern/components/date-range-input/index.js +1 -0
  54. package/modern/desktop.js +1 -0
  55. package/modern/index.js +1 -0
  56. package/modern/mobile.js +1 -0
  57. package/modern/responsive.js +1 -0
  58. package/package.json +7 -6
  59. package/responsive.js +5 -3
  60. package/Component-3b1e7e1b.d.ts +0 -229
  61. package/Component-3b1e7e1b.js +0 -225
  62. package/cssm/Component-540e1474.d.ts +0 -229
  63. package/cssm/Component-540e1474.js +0 -224
  64. package/esm/Component-bc49bcb7.d.ts +0 -229
  65. package/esm/Component-bc49bcb7.js +0 -215
@@ -4,7 +4,20 @@ import { ChangeEvent, ElementType } from "react";
4
4
  import { CalendarMobileProps, CalendarProps } from "@alfalab/core-components-calendar";
5
5
  import { InputProps } from "@alfalab/core-components-input";
6
6
  import { PopoverProps } from "@alfalab/core-components-popover";
7
- type DateRangeInputProps = Omit<InputProps, 'onChange'> & {
7
+ type ConditionalProps = {
8
+ /**
9
+ * Обработчик изменения значения
10
+ */
11
+ picker: true;
12
+ /**
13
+ * Обработчик закрытия календаря
14
+ */
15
+ onClose?: () => void;
16
+ } | {
17
+ picker?: false;
18
+ onClose?: never;
19
+ };
20
+ type DateRangeInputProps = Omit<InputProps, 'onChange'> & ConditionalProps & {
8
21
  /**
9
22
  * Дополнительный класс
10
23
  */
@@ -17,10 +30,6 @@ type DateRangeInputProps = Omit<InputProps, 'onChange'> & {
17
30
  * Дополнительный класс для поповера
18
31
  */
19
32
  popoverClassName?: string;
20
- /**
21
- * Обработчик изменения значения
22
- */
23
- picker?: boolean;
24
33
  /**
25
34
  * Обработчик изменения значения
26
35
  */
@@ -95,102 +104,5 @@ type DateRangeInputProps = Omit<InputProps, 'onChange'> & {
95
104
  */
96
105
  view?: 'desktop' | 'mobile';
97
106
  };
98
- declare const DateRangeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
99
- /**
100
- * Дополнительный класс
101
- */
102
- className?: string | undefined;
103
- /**
104
- * Дополнительный класс для инпута
105
- */
106
- inputClassName?: string | undefined;
107
- /**
108
- * Дополнительный класс для поповера
109
- */
110
- popoverClassName?: string | undefined;
111
- /**
112
- * Обработчик изменения значения
113
- */
114
- picker?: boolean | undefined;
115
- /**
116
- * Обработчик изменения значения
117
- */
118
- onChange?: ((payload: {
119
- dateFrom?: Date;
120
- dateTo?: Date;
121
- value: string;
122
- }, event?: ChangeEvent<HTMLInputElement>) => void) | undefined;
123
- /**
124
- * Обработчик окончания ввода
125
- */
126
- onComplete?: ((payload: {
127
- dateFrom: Date;
128
- dateTo: Date;
129
- value: string;
130
- }, event?: ChangeEvent<HTMLInputElement>) => void) | undefined;
131
- /**
132
- * Компонент календаря
133
- */
134
- Calendar?: React.ElementType<any> | undefined;
135
- /**
136
- * Доп. пропсы для календаря
137
- */
138
- calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
139
- open: boolean;
140
- title?: string | undefined;
141
- onClose?: (() => void) | undefined;
142
- yearsAmount?: number | undefined;
143
- hasHeader?: boolean | undefined;
144
- allowSelectionFromEmptyRange?: boolean | undefined;
145
- } & Record<string, unknown>) | undefined;
146
- /**
147
- * Месяц в календаре по умолчанию (timestamp)
148
- */
149
- defaultMonth?: number | undefined;
150
- /**
151
- * Минимальная дата, доступная для выбора (timestamp)
152
- */
153
- minDate?: number | undefined;
154
- /**
155
- * Максимальная дата, доступная для выбора (timestamp)
156
- */
157
- maxDate?: number | undefined;
158
- /**
159
- * Список событий
160
- */
161
- events?: (number | Date)[] | undefined;
162
- /**
163
- * Список выходных
164
- */
165
- offDays?: (number | Date)[] | undefined;
166
- /**
167
- * Состояние открытия по умолчанию
168
- */
169
- defaultOpen?: boolean | undefined;
170
- /**
171
- * Позиционирование поповера с календарем
172
- */
173
- popoverPosition?: PopoverProps['position'];
174
- /**
175
- * z-index Popover
176
- */
177
- zIndexPopover?: PopoverProps['zIndex'];
178
- /**
179
- * Запрещает поповеру менять свою позицию.
180
- * Например, если места снизу недостаточно,то он все равно будет показан снизу
181
- */
182
- preventFlip?: boolean | undefined;
183
- /**
184
- * Календарь будет принимать ширину инпута
185
- */
186
- useAnchorWidth?: boolean | undefined;
187
- /**
188
- * Растягивает компонент на ширину контейнера
189
- */
190
- block?: boolean | undefined;
191
- /**
192
- * Отображение компонента в мобильном или десктопном виде
193
- */
194
- view?: "desktop" | "mobile" | undefined;
195
- } & React.RefAttributes<HTMLInputElement>>;
196
- export { DateRangeInputProps, DateRangeInput };
107
+ declare const DateRangeInput: React.ForwardRefExoticComponent<DateRangeInputProps & React.RefAttributes<HTMLInputElement>>;
108
+ export { ConditionalProps, DateRangeInputProps, DateRangeInput };
@@ -1,6 +1,7 @@
1
1
  import React, { useRef, useState, useEffect } from 'react';
2
2
  import mergeRefs from 'react-merge-refs';
3
3
  import cn from 'classnames';
4
+ import { startOfMonth } from 'date-fns';
4
5
  import dateFnsIsValid from 'date-fns/isValid';
5
6
  import { usePeriod, Calendar } from '@alfalab/core-components-calendar/modern';
6
7
  import { IconButton } from '@alfalab/core-components-icon-button/modern';
@@ -8,28 +9,64 @@ import { Input } from '@alfalab/core-components-input/modern';
8
9
  import { Popover } from '@alfalab/core-components-popover/modern';
9
10
  import { useDidUpdateEffect } from '@alfalab/hooks';
10
11
  import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
11
- import { parseTimestampToDate, DATE_FORMAT, DATE_MASK, format, parseDateString, isCompleteDateInput, isValid } from '../../utils/format.js';
12
+ import { parseTimestampToDate, DATE_FORMAT, format, parseDateString, DATE_MASK, isCompleteDateInput, isValid } from '../../utils/format.js';
12
13
  import 'date-fns/parse';
13
14
 
14
- const styles = {"component":"date-range-input__component_19t6q","calendarContainer":"date-range-input__calendarContainer_19t6q","calendarResponsive":"date-range-input__calendarResponsive_19t6q","block":"date-range-input__block_19t6q"};
15
+ const styles = {"component":"date-range-input__component_1iuwu","calendarContainer":"date-range-input__calendarContainer_1iuwu","calendarResponsive":"date-range-input__calendarResponsive_1iuwu","block":"date-range-input__block_1iuwu"};
15
16
  require('./index.css')
16
17
 
17
18
  /* 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, view = 'desktop', ...restProps }, ref) => {
19
+ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverClassName, disabled, readOnly, picker, defaultValue = '', value: propValue, onChange, onComplete, onClose, 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) => {
19
20
  const inputRef = useRef(null);
21
+ const iconRef = useRef(null);
20
22
  const calendarRef = useRef(null);
21
23
  const [value, setValue] = useState(propValue || defaultValue);
22
- const [open, setOpen] = useState(false);
24
+ const [open, setOpen] = useState(defaultOpen);
23
25
  const inputDisabled = disabled || readOnly;
24
26
  const calendarResponsive = calendarProps?.responsive ?? true;
27
+ const { selectedFrom, selectedTo, updatePeriod, resetPeriod, setStart, setEnd } = usePeriod({ onPeriodChange: handlePeriodChange });
28
+ useEffect(() => {
29
+ if (value) {
30
+ setCalendarPeriod(getDates(value));
31
+ }
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33
+ }, []);
25
34
  useEffect(() => {
26
- setOpen(defaultOpen);
27
- }, [defaultOpen]);
35
+ setValue((prevValue) => {
36
+ if (selectedFrom && selectedTo) {
37
+ const from = parseTimestampToDate(selectedFrom);
38
+ const to = parseTimestampToDate(selectedTo);
39
+ return `${from} - ${to}`;
40
+ }
41
+ if (selectedFrom && prevValue.length < DATE_FORMAT.length) {
42
+ return parseTimestampToDate(selectedFrom);
43
+ }
44
+ return prevValue;
45
+ });
46
+ }, [selectedFrom, selectedTo]);
28
47
  useDidUpdateEffect(() => {
29
48
  const newPropValue = propValue || '';
30
- setValue((prevValue) => (prevValue === newPropValue ? prevValue : newPropValue));
49
+ setValue((prevValue) => {
50
+ if (prevValue === newPropValue) {
51
+ return prevValue;
52
+ }
53
+ const dates = getDates(newPropValue);
54
+ setCalendarPeriod(dates);
55
+ return dates.formattedValue;
56
+ });
31
57
  }, [propValue]);
32
- const handlePeriodChange = (selectedFrom, selectedTo) => {
58
+ function getDates(val) {
59
+ const formattedValue = format(val);
60
+ const dateArr = formattedValue.split('-').map((v) => v.trim());
61
+ const dateFrom = dateArr[0] ? parseDateString(dateArr[0]) : undefined;
62
+ const dateTo = dateArr[1] ? parseDateString(dateArr[1]) : undefined;
63
+ return { formattedValue, dateFrom, dateTo, dateArr };
64
+ }
65
+ function setCalendarPeriod({ dateFrom, dateTo }) {
66
+ setStart(dateFrom?.getTime());
67
+ setEnd(dateTo?.getTime());
68
+ }
69
+ function handlePeriodChange(selectedFrom, selectedTo) {
33
70
  if (selectedFrom && !selectedTo && value.length === DATE_MASK.length) {
34
71
  setValue(parseTimestampToDate(selectedFrom));
35
72
  }
@@ -54,8 +91,7 @@ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverCla
54
91
  value: newValue,
55
92
  });
56
93
  }
57
- };
58
- const { selectedFrom, selectedTo, updatePeriod, resetPeriod, setStart, setEnd } = usePeriod({ onPeriodChange: handlePeriodChange });
94
+ }
59
95
  const handleInputWrapperFocus = (event) => {
60
96
  if (view === 'desktop') {
61
97
  if (picker) {
@@ -69,8 +105,13 @@ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverCla
69
105
  const handleBlur = (event) => {
70
106
  if (view === 'desktop') {
71
107
  const target = (event.relatedTarget || document.activeElement);
72
- if (calendarRef.current && calendarRef.current.contains(target) === false) {
108
+ if (calendarRef.current?.contains(target) === false &&
109
+ inputRef.current?.contains(target) === false &&
110
+ iconRef.current?.contains(target) === false) {
73
111
  setOpen(false);
112
+ if (onClose) {
113
+ onClose();
114
+ }
74
115
  }
75
116
  }
76
117
  };
@@ -88,10 +129,7 @@ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverCla
88
129
  if ((dots && dots.length > 4) || (hyphen && hyphen.length > 1)) {
89
130
  return;
90
131
  }
91
- const formattedValue = format(newValue);
92
- const dateArr = formattedValue.split(' - ');
93
- const dateFrom = dateArr[0] ? parseDateString(dateArr[0]) : undefined;
94
- const dateTo = dateArr[1] ? parseDateString(dateArr[1]) : undefined;
132
+ const { formattedValue, dateFrom, dateTo, dateArr } = getDates(newValue);
95
133
  if (!dateFrom && !dateTo) {
96
134
  resetPeriod();
97
135
  }
@@ -125,6 +163,9 @@ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverCla
125
163
  }
126
164
  };
127
165
  const handleCalendarClose = () => {
166
+ if (view === 'mobile' && onClose) {
167
+ onClose();
168
+ }
128
169
  setOpen(false);
129
170
  };
130
171
  const handleClear = () => {
@@ -136,14 +177,6 @@ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverCla
136
177
  updatePeriod(date);
137
178
  }
138
179
  };
139
- useEffect(() => {
140
- if (selectedFrom && selectedTo) {
141
- setValue(`${parseTimestampToDate(selectedFrom)} - ${parseTimestampToDate(selectedTo)}`);
142
- }
143
- else if (selectedFrom && value.length < DATE_FORMAT.length) {
144
- setValue(parseTimestampToDate(selectedFrom));
145
- }
146
- }, [selectedFrom, selectedTo, value]);
147
180
  const handleCalendarWrapperMouseDown = (event) => {
148
181
  // Не дает инпуту терять фокус при выборе даты
149
182
  event.preventDefault();
@@ -155,16 +188,20 @@ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverCla
155
188
  inputRef.current.focus();
156
189
  }
157
190
  };
158
- const renderCalendar = () => (
159
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
160
- React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
161
- 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 })));
191
+ const renderCalendar = () => {
192
+ const activeMonth = (selectedTo && startOfMonth(selectedTo)) ||
193
+ (selectedFrom && startOfMonth(selectedFrom));
194
+ return (
195
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
196
+ React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
197
+ React.createElement(Calendar$1, { ...calendarProps, responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: activeMonth || defaultMonth, selectedFrom: selectedFrom, selectedTo: selectedTo, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })));
198
+ };
162
199
  return (React.createElement("div", { className: cn(styles.component, className, {
163
200
  [styles.block]: block,
164
201
  }), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
165
202
  React.createElement(Input, { ...restProps, block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, rightAddons: React.createElement(React.Fragment, null,
166
203
  rightAddons,
167
- picker && (React.createElement(IconButton, { onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 'xxs' }))) }),
204
+ picker && (React.createElement(IconButton, { ref: iconRef, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 'xxs' }))) }),
168
205
  picker && (React.createElement(Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn(styles.calendarContainer, {
169
206
  [styles.calendarResponsive]: calendarResponsive,
170
207
  }), className: popoverClassName, position: popoverPosition, offset: [0, 8], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
@@ -1,4 +1,4 @@
1
- /* hash: r7gvi */
1
+ /* hash: 19sow */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  } :root {
@@ -40,21 +40,21 @@
40
40
  /* marker */
41
41
  } :root {
42
42
  --calendar-popover-border-radius: var(--border-radius-m);
43
- } .date-range-input__component_19t6q {
43
+ } .date-range-input__component_1iuwu {
44
44
  display: inline-block;
45
45
  outline: none;
46
46
  position: relative;
47
- } .date-range-input__calendarContainer_19t6q {
47
+ } .date-range-input__calendarContainer_1iuwu {
48
48
  display: inline-block;
49
49
  box-sizing: border-box;
50
50
  border-radius: var(--calendar-popover-border-radius)
51
- } @media (max-width: 374px) { .date-range-input__calendarContainer_19t6q {
51
+ } @media (max-width: 374px) { .date-range-input__calendarContainer_1iuwu {
52
52
  width: 100%;
53
53
  min-width: 288px
54
54
  }
55
- } .date-range-input__calendarResponsive_19t6q {
55
+ } .date-range-input__calendarResponsive_1iuwu {
56
56
  width: var(--calendar-width);
57
57
  padding: 0 var(--gap-m);
58
- } .date-range-input__block_19t6q {
58
+ } .date-range-input__block_1iuwu {
59
59
  width: 100%;
60
60
  }
@@ -2,6 +2,7 @@ export { DateRangeInput } from './Component.js';
2
2
  import 'react';
3
3
  import 'react-merge-refs';
4
4
  import 'classnames';
5
+ import 'date-fns';
5
6
  import 'date-fns/isValid';
6
7
  import '@alfalab/core-components-calendar/modern';
7
8
  import '@alfalab/core-components-icon-button/modern';
package/modern/desktop.js CHANGED
@@ -3,6 +3,7 @@ import 'react';
3
3
  import './components/date-range-input/Component.js';
4
4
  import 'react-merge-refs';
5
5
  import 'classnames';
6
+ import 'date-fns';
6
7
  import 'date-fns/isValid';
7
8
  import '@alfalab/core-components-calendar/modern';
8
9
  import '@alfalab/core-components-icon-button/modern';
package/modern/index.js CHANGED
@@ -5,6 +5,7 @@ import './Component.desktop.js';
5
5
  import './components/date-range-input/Component.js';
6
6
  import 'react-merge-refs';
7
7
  import 'classnames';
8
+ import 'date-fns';
8
9
  import 'date-fns/isValid';
9
10
  import '@alfalab/core-components-calendar/modern';
10
11
  import '@alfalab/core-components-icon-button/modern';
package/modern/mobile.js CHANGED
@@ -4,6 +4,7 @@ import '@alfalab/core-components-calendar/modern';
4
4
  import './components/date-range-input/Component.js';
5
5
  import 'react-merge-refs';
6
6
  import 'classnames';
7
+ import 'date-fns';
7
8
  import 'date-fns/isValid';
8
9
  import '@alfalab/core-components-icon-button/modern';
9
10
  import '@alfalab/core-components-input/modern';
@@ -5,6 +5,7 @@ import './Component.desktop.js';
5
5
  import './components/date-range-input/Component.js';
6
6
  import 'react-merge-refs';
7
7
  import 'classnames';
8
+ import 'date-fns';
8
9
  import 'date-fns/isValid';
9
10
  import '@alfalab/core-components-calendar/modern';
10
11
  import '@alfalab/core-components-icon-button/modern';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-date-range-input",
3
- "version": "2.2.8",
3
+ "version": "2.2.9",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -15,11 +15,12 @@
15
15
  "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
16
16
  },
17
17
  "dependencies": {
18
- "@alfalab/core-components-input": "^11.1.6",
19
- "@alfalab/core-components-icon-button": "^6.0.6",
20
- "@alfalab/core-components-calendar": "^6.2.8",
21
- "@alfalab/core-components-popover": "^6.0.6",
18
+ "@alfalab/core-components-input": "^11.1.7",
19
+ "@alfalab/core-components-icon-button": "^6.0.7",
20
+ "@alfalab/core-components-calendar": "^6.2.9",
21
+ "@alfalab/core-components-popover": "^6.0.7",
22
22
  "@alfalab/hooks": "^1.13.0",
23
- "classnames": "^2.3.1"
23
+ "classnames": "^2.3.1",
24
+ "tslib": "^2.4.0"
24
25
  }
25
26
  }
package/responsive.js CHANGED
@@ -1,20 +1,22 @@
1
1
  'use strict';
2
2
 
3
3
  var Component_responsive = require('./Component.responsive.js');
4
- require('./Component-3b1e7e1b.js');
4
+ require('tslib');
5
5
  require('react');
6
+ require('@alfalab/hooks');
7
+ require('./Component.desktop.js');
8
+ require('./components/date-range-input/Component.js');
6
9
  require('react-merge-refs');
7
10
  require('classnames');
11
+ require('date-fns');
8
12
  require('date-fns/isValid');
9
13
  require('@alfalab/core-components-calendar');
10
14
  require('@alfalab/core-components-icon-button');
11
15
  require('@alfalab/core-components-input');
12
16
  require('@alfalab/core-components-popover');
13
- require('@alfalab/hooks');
14
17
  require('@alfalab/icons-glyph/CalendarMIcon');
15
18
  require('./utils/format.js');
16
19
  require('date-fns/parse');
17
- require('./Component.desktop.js');
18
20
  require('./Component.mobile.js');
19
21
 
20
22
 
@@ -1,229 +0,0 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent, ElementType } from "react";
4
- import { CalendarMobileProps, CalendarProps } from "@alfalab/core-components-calendar";
5
- import { InputProps } from "@alfalab/core-components-input";
6
- import { PopoverProps } from "@alfalab/core-components-popover";
7
- declare function __extends(d: any, b: any): void;
8
- declare function __rest(s: any, e: any): {};
9
- declare function __decorate(decorators: any, target: any, key: any, desc: any, ...args: any[]): any;
10
- declare function __param(paramIndex: any, decorator: any): (target: any, key: any) => void;
11
- declare function __metadata(metadataKey: any, metadataValue: any): any;
12
- declare function __awaiter(thisArg: any, _arguments: any, P: any, generator: any): any;
13
- declare function __generator(thisArg: any, body: any): {
14
- next: (v: any) => any;
15
- throw: (v: any) => any;
16
- return: (v: any) => any;
17
- };
18
- declare function __exportStar(m: any, o: any): void;
19
- declare function __values(o: any): any;
20
- declare function __read(o: any, n: any): any;
21
- declare function __spread(...args: any[]): any[];
22
- declare function __spreadArrays(...args: any[]): any[];
23
- declare function __spreadArray(to: any, from: any, pack: any, ...args: any[]): any;
24
- declare function __await(v: any): __await;
25
- declare class __await {
26
- constructor(v: any);
27
- v: any;
28
- }
29
- declare function __asyncGenerator(thisArg: any, _arguments: any, generator: any): {};
30
- declare function __asyncDelegator(o: any): {};
31
- declare function __asyncValues(o: any): any;
32
- declare function __makeTemplateObject(cooked: any, raw: any): any;
33
- declare function __importStar(mod: any): any;
34
- declare function __importDefault(mod: any): any;
35
- declare function __classPrivateFieldGet(receiver: any, state: any, kind: any, f: any): any;
36
- declare function __classPrivateFieldSet(receiver: any, state: any, value: any, kind: any, f: any): any;
37
- declare function __classPrivateFieldIn(state: any, receiver: any): any;
38
- declare function __assign(...args: any[]): any;
39
- declare function __createBinding(o: any, m: any, k: any, k2: any): void;
40
- type DateRangeInputProps = Omit<InputProps, 'onChange'> & {
41
- /**
42
- * Дополнительный класс
43
- */
44
- className?: string;
45
- /**
46
- * Дополнительный класс для инпута
47
- */
48
- inputClassName?: string;
49
- /**
50
- * Дополнительный класс для поповера
51
- */
52
- popoverClassName?: string;
53
- /**
54
- * Обработчик изменения значения
55
- */
56
- picker?: boolean;
57
- /**
58
- * Обработчик изменения значения
59
- */
60
- onChange?: (payload: {
61
- dateFrom?: Date;
62
- dateTo?: Date;
63
- value: string;
64
- }, event?: ChangeEvent<HTMLInputElement>) => void;
65
- /**
66
- * Обработчик окончания ввода
67
- */
68
- onComplete?: (payload: {
69
- dateFrom: Date;
70
- dateTo: Date;
71
- value: string;
72
- }, event?: ChangeEvent<HTMLInputElement>) => void;
73
- /**
74
- * Компонент календаря
75
- */
76
- Calendar?: ElementType;
77
- /**
78
- * Доп. пропсы для календаря
79
- */
80
- calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarMobileProps & Record<string, unknown>);
81
- /**
82
- * Месяц в календаре по умолчанию (timestamp)
83
- */
84
- defaultMonth?: number;
85
- /**
86
- * Минимальная дата, доступная для выбора (timestamp)
87
- */
88
- minDate?: number;
89
- /**
90
- * Максимальная дата, доступная для выбора (timestamp)
91
- */
92
- maxDate?: number;
93
- /**
94
- * Список событий
95
- */
96
- events?: Array<Date | number>;
97
- /**
98
- * Список выходных
99
- */
100
- offDays?: Array<Date | number>;
101
- /**
102
- * Состояние открытия по умолчанию
103
- */
104
- defaultOpen?: boolean;
105
- /**
106
- * Позиционирование поповера с календарем
107
- */
108
- popoverPosition?: PopoverProps['position'];
109
- /**
110
- * z-index Popover
111
- */
112
- zIndexPopover?: PopoverProps['zIndex'];
113
- /**
114
- * Запрещает поповеру менять свою позицию.
115
- * Например, если места снизу недостаточно,то он все равно будет показан снизу
116
- */
117
- preventFlip?: boolean;
118
- /**
119
- * Календарь будет принимать ширину инпута
120
- */
121
- useAnchorWidth?: boolean;
122
- /**
123
- * Растягивает компонент на ширину контейнера
124
- */
125
- block?: boolean;
126
- /**
127
- * Отображение компонента в мобильном или десктопном виде
128
- */
129
- view?: 'desktop' | 'mobile';
130
- };
131
- declare const DateRangeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
132
- /**
133
- * Дополнительный класс
134
- */
135
- className?: string | undefined;
136
- /**
137
- * Дополнительный класс для инпута
138
- */
139
- inputClassName?: string | undefined;
140
- /**
141
- * Дополнительный класс для поповера
142
- */
143
- popoverClassName?: string | undefined;
144
- /**
145
- * Обработчик изменения значения
146
- */
147
- picker?: boolean | undefined;
148
- /**
149
- * Обработчик изменения значения
150
- */
151
- onChange?: ((payload: {
152
- dateFrom?: Date;
153
- dateTo?: Date;
154
- value: string;
155
- }, event?: ChangeEvent<HTMLInputElement>) => void) | undefined;
156
- /**
157
- * Обработчик окончания ввода
158
- */
159
- onComplete?: ((payload: {
160
- dateFrom: Date;
161
- dateTo: Date;
162
- value: string;
163
- }, event?: ChangeEvent<HTMLInputElement>) => void) | undefined;
164
- /**
165
- * Компонент календаря
166
- */
167
- Calendar?: React.ElementType<any> | undefined;
168
- /**
169
- * Доп. пропсы для календаря
170
- */
171
- calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
172
- open: boolean;
173
- title?: string | undefined;
174
- onClose?: (() => void) | undefined;
175
- yearsAmount?: number | undefined;
176
- hasHeader?: boolean | undefined;
177
- allowSelectionFromEmptyRange?: boolean | undefined;
178
- } & Record<string, unknown>) | undefined;
179
- /**
180
- * Месяц в календаре по умолчанию (timestamp)
181
- */
182
- defaultMonth?: number | undefined;
183
- /**
184
- * Минимальная дата, доступная для выбора (timestamp)
185
- */
186
- minDate?: number | undefined;
187
- /**
188
- * Максимальная дата, доступная для выбора (timestamp)
189
- */
190
- maxDate?: number | undefined;
191
- /**
192
- * Список событий
193
- */
194
- events?: (number | Date)[] | undefined;
195
- /**
196
- * Список выходных
197
- */
198
- offDays?: (number | Date)[] | undefined;
199
- /**
200
- * Состояние открытия по умолчанию
201
- */
202
- defaultOpen?: boolean | undefined;
203
- /**
204
- * Позиционирование поповера с календарем
205
- */
206
- popoverPosition?: PopoverProps['position'];
207
- /**
208
- * z-index Popover
209
- */
210
- zIndexPopover?: PopoverProps['zIndex'];
211
- /**
212
- * Запрещает поповеру менять свою позицию.
213
- * Например, если места снизу недостаточно,то он все равно будет показан снизу
214
- */
215
- preventFlip?: boolean | undefined;
216
- /**
217
- * Календарь будет принимать ширину инпута
218
- */
219
- useAnchorWidth?: boolean | undefined;
220
- /**
221
- * Растягивает компонент на ширину контейнера
222
- */
223
- block?: boolean | undefined;
224
- /**
225
- * Отображение компонента в мобильном или десктопном виде
226
- */
227
- view?: "desktop" | "mobile" | undefined;
228
- } & React.RefAttributes<HTMLInputElement>>;
229
- export { __extends, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __spreadArray, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet, __classPrivateFieldIn, __assign, __createBinding, DateRangeInputProps, DateRangeInput };