@alfalab/core-components-calendar-input 8.2.8 → 8.2.10

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 (60) hide show
  1. package/Component.desktop.d.ts +4 -3
  2. package/Component.desktop.js +3 -2
  3. package/Component.mobile.d.ts +4 -3
  4. package/Component.mobile.js +3 -2
  5. package/Component.responsive.d.ts +10 -3
  6. package/Component.responsive.js +6 -5
  7. package/components/calendar-input/Component.d.ts +216 -0
  8. package/components/calendar-input/Component.js +135 -10
  9. package/components/calendar-input/index.css +11 -11
  10. package/components/calendar-input/index.d.ts +1 -1
  11. package/components/calendar-input/index.js +2 -1
  12. package/cssm/Component.desktop.d.ts +4 -3
  13. package/cssm/Component.desktop.js +3 -2
  14. package/cssm/Component.mobile.d.ts +4 -3
  15. package/cssm/Component.mobile.js +3 -2
  16. package/cssm/Component.responsive.d.ts +10 -3
  17. package/cssm/Component.responsive.js +6 -5
  18. package/cssm/components/calendar-input/Component.d.ts +216 -0
  19. package/cssm/components/calendar-input/Component.js +134 -11
  20. package/cssm/components/calendar-input/index.d.ts +1 -1
  21. package/cssm/components/calendar-input/index.js +2 -1
  22. package/cssm/desktop.js +2 -1
  23. package/cssm/index.js +4 -3
  24. package/cssm/mobile.js +3 -2
  25. package/cssm/responsive.js +4 -3
  26. package/desktop.js +2 -1
  27. package/esm/Component.desktop.d.ts +4 -3
  28. package/esm/Component.desktop.js +4 -3
  29. package/esm/Component.mobile.d.ts +4 -3
  30. package/esm/Component.mobile.js +4 -3
  31. package/esm/Component.responsive.d.ts +10 -3
  32. package/esm/Component.responsive.js +6 -5
  33. package/esm/components/calendar-input/Component.d.ts +216 -0
  34. package/esm/components/calendar-input/Component.js +132 -9
  35. package/esm/components/calendar-input/index.css +11 -11
  36. package/esm/components/calendar-input/index.d.ts +1 -1
  37. package/esm/components/calendar-input/index.js +2 -1
  38. package/esm/desktop.js +2 -1
  39. package/esm/index.js +4 -3
  40. package/esm/mobile.js +3 -2
  41. package/esm/responsive.js +4 -3
  42. package/index.js +4 -3
  43. package/mobile.js +3 -2
  44. package/modern/Component.desktop.d.ts +3 -2
  45. package/modern/Component.desktop.js +2 -2
  46. package/modern/Component.mobile.d.ts +3 -2
  47. package/modern/Component.mobile.js +2 -2
  48. package/modern/Component.responsive.d.ts +9 -2
  49. package/modern/Component.responsive.js +4 -4
  50. package/modern/components/calendar-input/Component.d.ts +1 -1
  51. package/modern/components/calendar-input/Component.js +1 -1
  52. package/modern/components/calendar-input/index.css +11 -11
  53. package/package.json +6 -5
  54. package/responsive.js +4 -3
  55. package/Component-60ae032f.d.ts +0 -249
  56. package/Component-60ae032f.js +0 -179
  57. package/cssm/Component-fde0c12c.d.ts +0 -249
  58. package/cssm/Component-fde0c12c.js +0 -178
  59. package/esm/Component-6e641637.d.ts +0 -249
  60. package/esm/Component-6e641637.js +0 -170
@@ -1,4 +1,4 @@
1
- /* hash: 9cpr5 */
1
+ /* hash: 2y3kn */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-graphic-primary: #0b1f35;
@@ -43,31 +43,31 @@
43
43
  } :root {
44
44
  --calendar-input-icon-color: var(--color-light-graphic-primary);
45
45
  --calendar-input-popover-border-radius: var(--border-radius-m);
46
- } .calendar-input__component_1dwtp {
46
+ } .calendar-input__component_1n7rs {
47
47
  display: inline-block;
48
48
  outline: none;
49
49
  position: relative;
50
- } .calendar-input__block_1dwtp {
50
+ } .calendar-input__block_1n7rs {
51
51
  width: 100%;
52
- } .calendar-input__calendarContainer_1dwtp {
52
+ } .calendar-input__calendarContainer_1n7rs {
53
53
  display: inline-block;
54
54
  box-sizing: border-box;
55
55
  border-radius: var(--calendar-input-popover-border-radius)
56
- } @media (max-width: 374px) { .calendar-input__calendarContainer_1dwtp {
56
+ } @media (max-width: 374px) { .calendar-input__calendarContainer_1n7rs {
57
57
  width: 100%;
58
58
  min-width: 288px
59
59
  }
60
- } .calendar-input__calendarResponsive_1dwtp {
60
+ } .calendar-input__calendarResponsive_1n7rs {
61
61
  width: var(--calendar-width);
62
62
  padding: 0 var(--gap-m);
63
- } .calendar-input__calendarIcon_1dwtp {
63
+ } .calendar-input__calendarIcon_1n7rs {
64
64
  width: 24px;
65
65
  height: 24px;
66
66
  display: block;
67
67
  color: var(--calendar-input-icon-color)
68
- } .calendar-input__calendarIcon_1dwtp:not(:only-child) {
68
+ } .calendar-input__calendarIcon_1n7rs:not(:only-child) {
69
69
  margin-right: var(--gap-2xs);
70
- } .calendar-input__nativeInput_1dwtp {
70
+ } .calendar-input__nativeInput_1n7rs {
71
71
  opacity: 0;
72
72
  position: absolute;
73
73
  top: 0;
@@ -77,8 +77,8 @@
77
77
  -webkit-appearance: none;
78
78
  appearance: none;
79
79
  z-index: 1
80
- } .calendar-input__nativeInput_1dwtp::-webkit-calendar-picker-indicator {
80
+ } .calendar-input__nativeInput_1n7rs::-webkit-calendar-picker-indicator {
81
81
  display: none;
82
- } .calendar-input__nativeInput_1dwtp::-webkit-inner-spin-button {
82
+ } .calendar-input__nativeInput_1n7rs::-webkit-inner-spin-button {
83
83
  display: none;
84
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-calendar-input",
3
- "version": "8.2.8",
3
+ "version": "8.2.10",
4
4
  "description": "Calendar input component",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -18,12 +18,13 @@
18
18
  "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
19
19
  },
20
20
  "dependencies": {
21
- "@alfalab/core-components-calendar": "^6.2.8",
22
- "@alfalab/core-components-date-input": "^4.1.6",
23
- "@alfalab/core-components-popover": "^6.0.6",
21
+ "@alfalab/core-components-calendar": "^6.2.10",
22
+ "@alfalab/core-components-date-input": "^4.1.7",
23
+ "@alfalab/core-components-popover": "^6.0.7",
24
24
  "@alfalab/hooks": "^1.7.0",
25
25
  "classnames": "^2.3.1",
26
26
  "date-fns": "^2.16.1",
27
- "react-merge-refs": "^1.1.0"
27
+ "react-merge-refs": "^1.1.0",
28
+ "tslib": "^2.4.0"
28
29
  }
29
30
  }
package/responsive.js CHANGED
@@ -1,8 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var Component_responsive = require('./Component.responsive.js');
4
- require('./Component-60ae032f.js');
4
+ require('tslib');
5
5
  require('react');
6
+ require('@alfalab/hooks');
7
+ require('./Component.desktop.js');
8
+ require('./components/calendar-input/Component.js');
6
9
  require('react-merge-refs');
7
10
  require('classnames');
8
11
  require('@alfalab/core-components-calendar');
@@ -13,8 +16,6 @@ require('./utils.js');
13
16
  require('date-fns/format');
14
17
  require('date-fns/isSameDay');
15
18
  require('date-fns/parse');
16
- require('@alfalab/hooks');
17
- require('./Component.desktop.js');
18
19
  require('./Component.mobile.js');
19
20
 
20
21
 
@@ -1,249 +0,0 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent, ElementType, MouseEvent } from "react";
4
- import { CalendarMobileProps, CalendarProps } from "@alfalab/core-components-calendar";
5
- import { DateInputProps } from "@alfalab/core-components-date-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 CalendarInputProps = Omit<DateInputProps, 'onChange' | 'mobileMode'> & {
41
- /**
42
- * Дополнительный класс
43
- */
44
- className?: string;
45
- /**
46
- * Дополнительный класс для инпута
47
- */
48
- inputClassName?: string;
49
- /**
50
- * Дополнительный класс для поповера
51
- */
52
- popoverClassName?: string;
53
- /**
54
- * Доп. пропсы для календаря
55
- */
56
- calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarMobileProps & Record<string, unknown>);
57
- /**
58
- * Значение инпута (используется и для календаря)
59
- */
60
- value?: string;
61
- /**
62
- * Начальное значение инпута
63
- */
64
- defaultValue?: string;
65
- /**
66
- * Состояние открытия по умолчанию
67
- */
68
- defaultOpen?: boolean;
69
- /**
70
- * Месяц в календаре по умолчанию (timestamp)
71
- */
72
- defaultMonth?: number;
73
- /**
74
- * Минимальная дата, доступная для выбора (timestamp)
75
- */
76
- minDate?: number;
77
- /**
78
- * Максимальная дата, доступная для выбора (timestamp)
79
- */
80
- maxDate?: number;
81
- /**
82
- * Список событий
83
- */
84
- events?: Array<Date | number>;
85
- /**
86
- * Список выходных
87
- */
88
- offDays?: Array<Date | number>;
89
- /**
90
- * Определяет, как рендерить календарь — в поповере или снизу инпута
91
- */
92
- calendarPosition?: 'static' | 'popover';
93
- /**
94
- * Запрещает поповеру менять свою позицию.
95
- * Например, если места снизу недостаточно,то он все равно будет показан снизу
96
- */
97
- preventFlip?: boolean;
98
- /**
99
- * Управление нативным режимом на мобильных устройствах
100
- */
101
- mobileMode?: 'native' | 'popover' | 'input';
102
- /**
103
- * Компонент календаря
104
- */
105
- Calendar?: ElementType;
106
- /**
107
- * Обработчик изменения значения
108
- */
109
- onChange?: (event: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLButtonElement> | null, payload: {
110
- date: Date;
111
- value: string;
112
- }) => void;
113
- /**
114
- * Обработчик ввода в инпут
115
- */
116
- onInputChange?: (event: ChangeEvent<HTMLInputElement>, payload: {
117
- value: string;
118
- date: Date;
119
- }) => void;
120
- /**
121
- * Обработчик изменения календаря
122
- */
123
- onCalendarChange?: CalendarProps['onChange'];
124
- /**
125
- * Позиционирование поповера с календарем
126
- */
127
- popoverPosition?: PopoverProps['position'];
128
- /**
129
- * z-index Popover
130
- */
131
- zIndexPopover?: PopoverProps['zIndex'];
132
- /**
133
- * Календарь будет принимать ширину инпута
134
- */
135
- useAnchorWidth?: boolean;
136
- /**
137
- * Отображение компонента в мобильном или десктопном виде
138
- */
139
- view?: 'desktop' | 'mobile';
140
- };
141
- declare const CalendarInput: React.ForwardRefExoticComponent<Omit<DateInputProps, "onChange" | "mobileMode"> & {
142
- /**
143
- * Дополнительный класс
144
- */
145
- className?: string | undefined;
146
- /**
147
- * Дополнительный класс для инпута
148
- */
149
- inputClassName?: string | undefined;
150
- /**
151
- * Дополнительный класс для поповера
152
- */
153
- popoverClassName?: string | undefined;
154
- /**
155
- * Доп. пропсы для календаря
156
- */
157
- calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
158
- open: boolean;
159
- title?: string | undefined;
160
- onClose?: (() => void) | undefined;
161
- yearsAmount?: number | undefined;
162
- hasHeader?: boolean | undefined;
163
- allowSelectionFromEmptyRange?: boolean | undefined;
164
- } & Record<string, unknown>) | undefined;
165
- /**
166
- * Значение инпута (используется и для календаря)
167
- */
168
- value?: string | undefined;
169
- /**
170
- * Начальное значение инпута
171
- */
172
- defaultValue?: string | undefined;
173
- /**
174
- * Состояние открытия по умолчанию
175
- */
176
- defaultOpen?: boolean | undefined;
177
- /**
178
- * Месяц в календаре по умолчанию (timestamp)
179
- */
180
- defaultMonth?: number | undefined;
181
- /**
182
- * Минимальная дата, доступная для выбора (timestamp)
183
- */
184
- minDate?: number | undefined;
185
- /**
186
- * Максимальная дата, доступная для выбора (timestamp)
187
- */
188
- maxDate?: number | undefined;
189
- /**
190
- * Список событий
191
- */
192
- events?: (number | Date)[] | undefined;
193
- /**
194
- * Список выходных
195
- */
196
- offDays?: (number | Date)[] | undefined;
197
- /**
198
- * Определяет, как рендерить календарь — в поповере или снизу инпута
199
- */
200
- calendarPosition?: "static" | "popover" | undefined;
201
- /**
202
- * Запрещает поповеру менять свою позицию.
203
- * Например, если места снизу недостаточно,то он все равно будет показан снизу
204
- */
205
- preventFlip?: boolean | undefined;
206
- /**
207
- * Управление нативным режимом на мобильных устройствах
208
- */
209
- mobileMode?: "input" | "native" | "popover" | undefined;
210
- /**
211
- * Компонент календаря
212
- */
213
- Calendar?: React.ElementType<any> | undefined;
214
- /**
215
- * Обработчик изменения значения
216
- */
217
- onChange?: ((event: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLButtonElement> | null, payload: {
218
- date: Date;
219
- value: string;
220
- }) => void) | undefined;
221
- /**
222
- * Обработчик ввода в инпут
223
- */
224
- onInputChange?: ((event: ChangeEvent<HTMLInputElement>, payload: {
225
- value: string;
226
- date: Date;
227
- }) => void) | undefined;
228
- /**
229
- * Обработчик изменения календаря
230
- */
231
- onCalendarChange?: CalendarProps['onChange'];
232
- /**
233
- * Позиционирование поповера с календарем
234
- */
235
- popoverPosition?: PopoverProps['position'];
236
- /**
237
- * z-index Popover
238
- */
239
- zIndexPopover?: PopoverProps['zIndex'];
240
- /**
241
- * Календарь будет принимать ширину инпута
242
- */
243
- useAnchorWidth?: boolean | undefined;
244
- /**
245
- * Отображение компонента в мобильном или десктопном виде
246
- */
247
- view?: "desktop" | "mobile" | undefined;
248
- } & React.RefAttributes<HTMLInputElement>>;
249
- 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, CalendarInputProps, CalendarInput };
@@ -1,179 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var mergeRefs = require('react-merge-refs');
5
- var cn = require('classnames');
6
- var coreComponentsCalendar = require('@alfalab/core-components-calendar');
7
- var coreComponentsDateInput = require('@alfalab/core-components-date-input');
8
- var coreComponentsPopover = require('@alfalab/core-components-popover');
9
- var CalendarMIcon = require('@alfalab/icons-glyph/CalendarMIcon');
10
- var utils = require('./utils.js');
11
-
12
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
13
-
14
- var React__default = /*#__PURE__*/_interopDefaultCompat(React);
15
- var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
16
- var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
17
-
18
- /******************************************************************************
19
- Copyright (c) Microsoft Corporation.
20
-
21
- Permission to use, copy, modify, and/or distribute this software for any
22
- purpose with or without fee is hereby granted.
23
-
24
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
25
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
26
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
27
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
28
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
29
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30
- PERFORMANCE OF THIS SOFTWARE.
31
- ***************************************************************************** */
32
- exports.__assign = function () {
33
- exports.__assign = Object.assign || function __assign(t) {
34
- for (var s, i = 1, n = arguments.length; i < n; i++) {
35
- s = arguments[i];
36
- for (var p in s)
37
- if (Object.prototype.hasOwnProperty.call(s, p))
38
- t[p] = s[p];
39
- }
40
- return t;
41
- };
42
- return exports.__assign.apply(this, arguments);
43
- };
44
- function __rest(s, e) {
45
- var t = {};
46
- for (var p in s)
47
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
48
- t[p] = s[p];
49
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
50
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
51
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
52
- t[p[i]] = s[p[i]];
53
- }
54
- return t;
55
- }
56
-
57
- var styles = {"component":"calendar-input__component_1dwtp","block":"calendar-input__block_1dwtp","calendarContainer":"calendar-input__calendarContainer_1dwtp","calendarResponsive":"calendar-input__calendarResponsive_1dwtp","calendarIcon":"calendar-input__calendarIcon_1dwtp","nativeInput":"calendar-input__nativeInput_1dwtp"};
58
- require('./components/calendar-input/index.css')
59
-
60
- var CalendarInput = React.forwardRef(function (_a, ref) {
61
- var _b, _c;
62
- var _d;
63
- var _e = _a.block, block = _e === void 0 ? false : _e, className = _a.className; _a.inputClassName; var popoverClassName = _a.popoverClassName, _f = _a.defaultOpen, defaultOpen = _f === void 0 ? false : _f, defaultMonth = _a.defaultMonth, _g = _a.defaultValue, defaultValue = _g === void 0 ? '' : _g, _h = _a.calendarPosition, calendarPosition = _h === void 0 ? 'popover' : _h, value = _a.value, dataTestId = _a.dataTestId, _j = _a.calendarProps, calendarProps = _j === void 0 ? {} : _j, _k = _a.minDate, minDate = _k === void 0 ? calendarProps.minDate : _k, _l = _a.maxDate, maxDate = _l === void 0 ? calendarProps.maxDate : _l, _m = _a.offDays, offDays = _m === void 0 ? calendarProps.offDays || [] : _m, _o = _a.events, events = _o === void 0 ? calendarProps.events || [] : _o, preventFlip = _a.preventFlip, _p = _a.mobileMode, mobileMode = _p === void 0 ? 'popover' : _p, _q = _a.wrapperRef, wrapperRef = _q === void 0 ? null : _q, disabled = _a.disabled, _r = _a.onChange, onChange = _r === void 0 ? function () { return null; } : _r, onInputChange = _a.onInputChange, onCalendarChange = _a.onCalendarChange, onKeyDown = _a.onKeyDown, readOnly = _a.readOnly, _s = _a.Calendar, Calendar = _s === void 0 ? coreComponentsCalendar.Calendar : _s, _t = _a.popoverPosition, popoverPosition = _t === void 0 ? 'bottom-start' : _t, zIndexPopover = _a.zIndexPopover, useAnchorWidth = _a.useAnchorWidth, rightAddons = _a.rightAddons, error = _a.error, _u = _a.view, view = _u === void 0 ? 'desktop' : _u, restProps = __rest(_a, ["block", "className", "inputClassName", "popoverClassName", "defaultOpen", "defaultMonth", "defaultValue", "calendarPosition", "value", "dataTestId", "calendarProps", "minDate", "maxDate", "offDays", "events", "preventFlip", "mobileMode", "wrapperRef", "disabled", "onChange", "onInputChange", "onCalendarChange", "onKeyDown", "readOnly", "Calendar", "popoverPosition", "zIndexPopover", "useAnchorWidth", "rightAddons", "error", "view"]);
64
- var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
65
- var shouldRenderNative = utils.SUPPORTS_INPUT_TYPE_DATE && mobileMode === 'native';
66
- var shouldRenderOnlyInput = mobileMode === 'input';
67
- var shouldRenderStatic = calendarPosition === 'static' && !shouldRenderOnlyInput;
68
- var shouldRenderPopover = calendarPosition === 'popover' && !shouldRenderNative && !shouldRenderOnlyInput;
69
- var _v = React.useState(false), open = _v[0], setOpen = _v[1];
70
- var _w = React.useState(value || defaultValue), inputValue = _w[0], setInputValue = _w[1];
71
- var calendarValue = inputValue ? coreComponentsDateInput.parseDateString(inputValue).getTime() : undefined;
72
- var checkInputValueIsValid = React.useCallback(function (newInputValue) {
73
- if (!newInputValue)
74
- return false;
75
- var dateValue = coreComponentsDateInput.parseDateString(newInputValue).getTime();
76
- return !!(dateValue &&
77
- coreComponentsDateInput.isCompleteDateInput(newInputValue) &&
78
- coreComponentsCalendar.dateInLimits(dateValue, minDate, maxDate) &&
79
- !offDays.includes(dateValue));
80
- }, [maxDate, minDate, offDays]);
81
- var inputDisabled = disabled || readOnly;
82
- var inputWrapperRef = React.useRef(null);
83
- var calendarRef = React.useRef(null);
84
- var handleKeyDown = React.useCallback(function (event) {
85
- if (event.target.tagName === 'INPUT' && event.key === 'Enter') {
86
- setOpen(!open);
87
- }
88
- if (event.key === 'Escape') {
89
- setOpen(false);
90
- }
91
- }, [open]);
92
- var handleClick = React.useCallback(function () {
93
- if (!open)
94
- setOpen(true);
95
- }, [open]);
96
- var handleFocus = React.useCallback(function (event) {
97
- if (view === 'desktop') {
98
- setOpen(true);
99
- if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {
100
- calendarRef.current.focus();
101
- }
102
- }
103
- }, [open, view]);
104
- var handleBlur = React.useCallback(function (event) {
105
- if (view === 'desktop') {
106
- var target = (event.relatedTarget || document.activeElement);
107
- if (calendarRef.current && calendarRef.current.contains(target) === false) {
108
- setOpen(false);
109
- }
110
- }
111
- }, [view]);
112
- var handleInputKeyDown = React.useCallback(function (event) {
113
- if (['ArrowDown', 'ArrowUp'].includes(event.key) && calendarRef.current) {
114
- event.preventDefault();
115
- calendarRef.current.focus();
116
- }
117
- if (onKeyDown)
118
- onKeyDown(event);
119
- }, [onKeyDown]);
120
- var changeHandler = React.useCallback(function (event, newValue, newDate, initiator, shouldChange) {
121
- if (initiator === void 0) { initiator = 'input'; }
122
- if (shouldChange === void 0) { shouldChange = true; }
123
- if (initiator === 'input' && event && onInputChange) {
124
- onInputChange(event, { value: newValue, date: newDate });
125
- }
126
- if (initiator === 'calendar' && onCalendarChange) {
127
- onCalendarChange(newDate.getTime());
128
- }
129
- setInputValue(newValue);
130
- if (shouldChange) {
131
- onChange(event, { date: newDate, value: newValue });
132
- }
133
- }, [onCalendarChange, onChange, onInputChange]);
134
- var handleInputChange = React.useCallback(function (event, payload) {
135
- changeHandler(event, payload.value, payload.date, 'input', !payload.value || checkInputValueIsValid(payload.value));
136
- }, [changeHandler, checkInputValueIsValid]);
137
- var handleCalendarChange = React.useCallback(function (date) {
138
- if (date) {
139
- changeHandler(null, coreComponentsDateInput.formatDate(date), new Date(date), 'calendar');
140
- }
141
- if (view === 'desktop') {
142
- setOpen(false);
143
- }
144
- }, [changeHandler, view]);
145
- var handleCalendarWrapperMouseDown = React.useCallback(function (event) {
146
- // Не дает инпуту терять фокус при выборе даты
147
- event.preventDefault();
148
- }, []);
149
- var handleCalendarClose = React.useCallback(function () {
150
- setOpen(false);
151
- }, []);
152
- React.useEffect(function () {
153
- setOpen(defaultOpen);
154
- }, [defaultOpen]);
155
- React.useEffect(function () {
156
- if (typeof value !== 'undefined') {
157
- setInputValue(value);
158
- }
159
- }, [value]);
160
- var renderCalendar = function () { return (
161
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
162
- React__default.default.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
163
- React__default.default.createElement(Calendar, exports.__assign({}, calendarProps, { responsive: calendarResponsive, open: open, onClose: handleCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, value: checkInputValueIsValid(inputValue) ? calendarValue : undefined, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events })))); };
164
- return (
165
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
166
- React__default.default.createElement("div", { className: cn__default.default(styles.component, className, (_b = {},
167
- _b[styles.block] = block,
168
- _b)), tabIndex: -1, onKeyDown: inputDisabled ? undefined : handleKeyDown, onClick: inputDisabled ? undefined : handleClick, onFocus: inputDisabled ? undefined : handleFocus, onBlur: handleBlur, "data-test-id": dataTestId },
169
- React__default.default.createElement(coreComponentsDateInput.DateInput, exports.__assign({}, restProps, { ref: ref, wrapperRef: mergeRefs__default.default([wrapperRef, inputWrapperRef]), value: inputValue, defaultValue: defaultValue, disabled: disabled, readOnly: readOnly, mobileMode: mobileMode === 'native' ? 'native' : 'input', error: error, rightAddons: React__default.default.createElement(React__default.default.Fragment, null,
170
- rightAddons,
171
- shouldRenderPopover && (React__default.default.createElement(CalendarMIcon.CalendarMIcon, { className: styles.calendarIcon }))), onKeyDown: handleInputKeyDown, onChange: handleInputChange, block: true })),
172
- shouldRenderStatic && renderCalendar(),
173
- shouldRenderPopover && (React__default.default.createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputWrapperRef.current, popperClassName: cn__default.default(styles.calendarContainer, (_c = {},
174
- _c[styles.calendarResponsive] = calendarResponsive,
175
- _c)), className: popoverClassName, position: popoverPosition, offset: [0, 4], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
176
- });
177
-
178
- exports.CalendarInput = CalendarInput;
179
- exports.__rest = __rest;