@alfalab/core-components-calendar-input 8.1.3 → 8.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.
- package/{esm/Component.d.ts → Component-98dcf994.d.ts} +45 -6
- package/{Component.js → Component-98dcf994.js} +21 -23
- package/Component.desktop.d.ts +5 -0
- package/Component.desktop.js +22 -0
- package/Component.mobile.d.ts +5 -0
- package/Component.mobile.js +22 -0
- package/Component.responsive.d.ts +12 -0
- package/Component.responsive.js +32 -0
- package/components/calendar-input/Component.d.ts +0 -0
- package/components/calendar-input/Component.js +18 -0
- package/{esm → components/calendar-input}/index.css +11 -11
- package/components/calendar-input/index.d.ts +1 -0
- package/components/calendar-input/index.js +18 -0
- package/cssm/{Component.d.ts → Component-fde0c12c.d.ts} +45 -6
- package/cssm/{Component.js → Component-fde0c12c.js} +23 -24
- package/cssm/Component.desktop.d.ts +5 -0
- package/cssm/Component.desktop.js +23 -0
- package/cssm/Component.mobile.d.ts +5 -0
- package/cssm/Component.mobile.js +23 -0
- package/cssm/Component.responsive.d.ts +12 -0
- package/cssm/Component.responsive.js +33 -0
- package/cssm/components/calendar-input/Component.d.ts +0 -0
- package/cssm/components/calendar-input/Component.js +19 -0
- package/cssm/components/calendar-input/index.d.ts +1 -0
- package/cssm/components/calendar-input/index.js +19 -0
- package/cssm/{index.module.css → components/calendar-input/index.module.css} +0 -0
- package/cssm/desktop.d.ts +2 -0
- package/cssm/desktop.js +20 -0
- package/cssm/index.d.ts +1 -1
- package/cssm/index.js +7 -4
- package/cssm/mobile.d.ts +2 -0
- package/cssm/mobile.js +20 -0
- package/cssm/responsive.d.ts +2 -0
- package/cssm/responsive.js +23 -0
- package/cssm/utils.js +9 -3
- package/desktop.d.ts +2 -0
- package/desktop.js +19 -0
- package/{modern/Component.d.ts → esm/Component-8d1a1461.d.ts} +45 -6
- package/esm/{Component.js → Component-8d1a1461.js} +8 -17
- package/esm/Component.desktop.d.ts +5 -0
- package/esm/Component.desktop.js +16 -0
- package/esm/Component.mobile.d.ts +5 -0
- package/esm/Component.mobile.js +16 -0
- package/esm/Component.responsive.d.ts +12 -0
- package/esm/Component.responsive.js +26 -0
- package/esm/components/calendar-input/Component.d.ts +0 -0
- package/esm/components/calendar-input/Component.js +12 -0
- package/{index.css → esm/components/calendar-input/index.css} +11 -11
- package/esm/components/calendar-input/index.d.ts +1 -0
- package/esm/components/calendar-input/index.js +12 -0
- package/esm/desktop.d.ts +2 -0
- package/esm/desktop.js +13 -0
- package/esm/index.d.ts +1 -1
- package/esm/index.js +5 -2
- package/esm/mobile.d.ts +2 -0
- package/esm/mobile.js +13 -0
- package/esm/responsive.d.ts +2 -0
- package/esm/responsive.js +16 -0
- package/index.d.ts +1 -1
- package/index.js +6 -3
- package/mobile.d.ts +2 -0
- package/mobile.js +19 -0
- package/modern/Component.desktop.d.ts +5 -0
- package/modern/Component.desktop.js +16 -0
- package/modern/Component.mobile.d.ts +5 -0
- package/modern/Component.mobile.js +16 -0
- package/modern/Component.responsive.d.ts +12 -0
- package/modern/Component.responsive.js +25 -0
- package/{Component.d.ts → modern/components/calendar-input/Component.d.ts} +11 -5
- package/modern/{Component.js → components/calendar-input/Component.js} +5 -11
- package/modern/{index.css → components/calendar-input/index.css} +11 -11
- package/modern/components/calendar-input/index.d.ts +1 -0
- package/modern/components/calendar-input/index.js +12 -0
- package/modern/desktop.d.ts +2 -0
- package/modern/desktop.js +13 -0
- package/modern/index.d.ts +1 -1
- package/modern/index.js +5 -2
- package/modern/mobile.d.ts +2 -0
- package/modern/mobile.js +13 -0
- package/modern/responsive.d.ts +2 -0
- package/modern/responsive.js +16 -0
- package/package.json +4 -4
- package/responsive.d.ts +2 -0
- package/responsive.js +22 -0
- package/utils.js +9 -3
|
@@ -4,6 +4,39 @@ import { ChangeEvent, ElementType, MouseEvent } from "react";
|
|
|
4
4
|
import { CalendarMobileProps, CalendarProps } from "@alfalab/core-components-calendar";
|
|
5
5
|
import { DateInputProps } from "@alfalab/core-components-date-input";
|
|
6
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;
|
|
7
40
|
type CalendarInputProps = Omit<DateInputProps, 'onChange' | 'mobileMode'> & {
|
|
8
41
|
/**
|
|
9
42
|
* Дополнительный класс
|
|
@@ -69,7 +102,7 @@ type CalendarInputProps = Omit<DateInputProps, 'onChange' | 'mobileMode'> & {
|
|
|
69
102
|
/**
|
|
70
103
|
* Компонент календаря
|
|
71
104
|
*/
|
|
72
|
-
Calendar?: ElementType
|
|
105
|
+
Calendar?: ElementType;
|
|
73
106
|
/**
|
|
74
107
|
* Обработчик изменения значения
|
|
75
108
|
*/
|
|
@@ -100,6 +133,10 @@ type CalendarInputProps = Omit<DateInputProps, 'onChange' | 'mobileMode'> & {
|
|
|
100
133
|
* Календарь будет принимать ширину инпута
|
|
101
134
|
*/
|
|
102
135
|
useAnchorWidth?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Отображение компонента в мобильном или десктопном виде
|
|
138
|
+
*/
|
|
139
|
+
view?: 'desktop' | 'mobile';
|
|
103
140
|
};
|
|
104
141
|
declare const CalendarInput: React.ForwardRefExoticComponent<Omit<DateInputProps, "onChange" | "mobileMode"> & {
|
|
105
142
|
/**
|
|
@@ -119,9 +156,7 @@ declare const CalendarInput: React.ForwardRefExoticComponent<Omit<DateInputProps
|
|
|
119
156
|
*/
|
|
120
157
|
calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
|
|
121
158
|
open: boolean;
|
|
122
|
-
title?: string | undefined;
|
|
123
|
-
* Дополнительный класс для поповера
|
|
124
|
-
*/
|
|
159
|
+
title?: string | undefined;
|
|
125
160
|
onClose?: (() => void) | undefined;
|
|
126
161
|
yearsAmount?: number | undefined;
|
|
127
162
|
hasHeader?: boolean | undefined;
|
|
@@ -175,7 +210,7 @@ declare const CalendarInput: React.ForwardRefExoticComponent<Omit<DateInputProps
|
|
|
175
210
|
/**
|
|
176
211
|
* Компонент календаря
|
|
177
212
|
*/
|
|
178
|
-
Calendar?: React.ElementType<
|
|
213
|
+
Calendar?: React.ElementType<any> | undefined;
|
|
179
214
|
/**
|
|
180
215
|
* Обработчик изменения значения
|
|
181
216
|
*/
|
|
@@ -206,5 +241,9 @@ declare const CalendarInput: React.ForwardRefExoticComponent<Omit<DateInputProps
|
|
|
206
241
|
* Календарь будет принимать ширину инпута
|
|
207
242
|
*/
|
|
208
243
|
useAnchorWidth?: boolean | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* Отображение компонента в мобильном или десктопном виде
|
|
246
|
+
*/
|
|
247
|
+
view?: "desktop" | "mobile" | undefined;
|
|
209
248
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
210
|
-
export { CalendarInputProps, CalendarInput };
|
|
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 };
|
|
@@ -6,12 +6,14 @@ var cn = require('classnames');
|
|
|
6
6
|
var coreComponentsCalendar = require('@alfalab/core-components-calendar');
|
|
7
7
|
var coreComponentsDateInput = require('@alfalab/core-components-date-input');
|
|
8
8
|
var coreComponentsPopover = require('@alfalab/core-components-popover');
|
|
9
|
-
var hooks = require('@alfalab/hooks');
|
|
10
9
|
var CalendarMIcon = require('@alfalab/icons-glyph/CalendarMIcon');
|
|
11
10
|
var utils = require('./utils.js');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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);
|
|
15
17
|
|
|
16
18
|
/******************************************************************************
|
|
17
19
|
Copyright (c) Microsoft Corporation.
|
|
@@ -27,8 +29,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
27
29
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
28
30
|
PERFORMANCE OF THIS SOFTWARE.
|
|
29
31
|
***************************************************************************** */
|
|
30
|
-
|
|
31
|
-
__assign = Object.assign || function __assign(t) {
|
|
32
|
+
exports.__assign = function () {
|
|
33
|
+
exports.__assign = Object.assign || function __assign(t) {
|
|
32
34
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
33
35
|
s = arguments[i];
|
|
34
36
|
for (var p in s)
|
|
@@ -37,7 +39,7 @@ var __assign = function () {
|
|
|
37
39
|
}
|
|
38
40
|
return t;
|
|
39
41
|
};
|
|
40
|
-
return __assign.apply(this, arguments);
|
|
42
|
+
return exports.__assign.apply(this, arguments);
|
|
41
43
|
};
|
|
42
44
|
function __rest(s, e) {
|
|
43
45
|
var t = {};
|
|
@@ -52,25 +54,20 @@ function __rest(s, e) {
|
|
|
52
54
|
return t;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
var styles = {"component":"calendar-
|
|
56
|
-
require('./index.css')
|
|
57
|
+
var styles = {"component":"calendar-input__component_wpjcj","block":"calendar-input__block_wpjcj","calendarContainer":"calendar-input__calendarContainer_wpjcj","calendarResponsive":"calendar-input__calendarResponsive_wpjcj","calendarIcon":"calendar-input__calendarIcon_wpjcj","nativeInput":"calendar-input__nativeInput_wpjcj"};
|
|
58
|
+
require('./components/calendar-input/index.css')
|
|
57
59
|
|
|
58
60
|
var CalendarInput = React.forwardRef(function (_a, ref) {
|
|
59
61
|
var _b, _c;
|
|
60
62
|
var _d;
|
|
61
|
-
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, 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"]);
|
|
62
|
-
var view = hooks.useMedia([
|
|
63
|
-
['mobile', '(max-width: 1023px)'],
|
|
64
|
-
['desktop', '(min-width: 1024px)'],
|
|
65
|
-
], 'desktop')[0];
|
|
66
|
-
var CalendarComponent = view === 'desktop' ? Calendar : coreComponentsCalendar.CalendarMobile;
|
|
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"]);
|
|
67
64
|
var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
|
|
68
65
|
var shouldRenderNative = utils.SUPPORTS_INPUT_TYPE_DATE && mobileMode === 'native';
|
|
69
66
|
var shouldRenderOnlyInput = mobileMode === 'input';
|
|
70
67
|
var shouldRenderStatic = calendarPosition === 'static' && !shouldRenderOnlyInput;
|
|
71
68
|
var shouldRenderPopover = calendarPosition === 'popover' && !shouldRenderNative && !shouldRenderOnlyInput;
|
|
72
|
-
var
|
|
73
|
-
var
|
|
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];
|
|
74
71
|
var calendarValue = inputValue ? coreComponentsDateInput.parseDateString(inputValue).getTime() : undefined;
|
|
75
72
|
var checkInputValueIsValid = React.useCallback(function (newInputValue) {
|
|
76
73
|
if (!newInputValue)
|
|
@@ -162,20 +159,21 @@ var CalendarInput = React.forwardRef(function (_a, ref) {
|
|
|
162
159
|
}, [value]);
|
|
163
160
|
var renderCalendar = function () { return (
|
|
164
161
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
165
|
-
|
|
166
|
-
|
|
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 })))); };
|
|
167
164
|
return (
|
|
168
165
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
169
|
-
|
|
166
|
+
React__default.default.createElement("div", { className: cn__default.default(styles.component, className, (_b = {},
|
|
170
167
|
_b[styles.block] = block,
|
|
171
168
|
_b)), tabIndex: -1, onKeyDown: inputDisabled ? undefined : handleKeyDown, onClick: inputDisabled ? undefined : handleClick, onFocus: inputDisabled ? undefined : handleFocus, onBlur: handleBlur, "data-test-id": dataTestId },
|
|
172
|
-
|
|
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,
|
|
173
170
|
rightAddons,
|
|
174
|
-
shouldRenderPopover && (
|
|
171
|
+
shouldRenderPopover && (React__default.default.createElement(CalendarMIcon.CalendarMIcon, { className: styles.calendarIcon }))), onKeyDown: handleInputKeyDown, onChange: handleInputChange, block: true })),
|
|
175
172
|
shouldRenderStatic && renderCalendar(),
|
|
176
|
-
shouldRenderPopover && (
|
|
173
|
+
shouldRenderPopover && (React__default.default.createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputWrapperRef.current, popperClassName: cn__default.default(styles.calendarContainer, (_c = {},
|
|
177
174
|
_c[styles.calendarResponsive] = calendarResponsive,
|
|
178
175
|
_c)), className: popoverClassName, position: popoverPosition, offset: [0, 4], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
|
|
179
176
|
});
|
|
180
177
|
|
|
181
178
|
exports.CalendarInput = CalendarInput;
|
|
179
|
+
exports.__rest = __rest;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CalendarInputProps } from "./Component-98dcf994";
|
|
3
|
+
type CalendarInputDesktopProps = Omit<CalendarInputProps, 'view'>;
|
|
4
|
+
declare const CalendarInputDesktop: FC<CalendarInputDesktopProps>;
|
|
5
|
+
export { CalendarInputDesktopProps, CalendarInputDesktop };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var components_calendarInput_Component = require('./Component-98dcf994.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
require('react-merge-refs');
|
|
6
|
+
require('classnames');
|
|
7
|
+
require('@alfalab/core-components-calendar');
|
|
8
|
+
require('@alfalab/core-components-date-input');
|
|
9
|
+
require('@alfalab/core-components-popover');
|
|
10
|
+
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
11
|
+
require('./utils.js');
|
|
12
|
+
require('date-fns/format');
|
|
13
|
+
require('date-fns/isSameDay');
|
|
14
|
+
require('date-fns/parse');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
17
|
+
|
|
18
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
19
|
+
|
|
20
|
+
var CalendarInputDesktop = function (props) { return (React__default.default.createElement(components_calendarInput_Component.CalendarInput, components_calendarInput_Component.__assign({}, props))); };
|
|
21
|
+
|
|
22
|
+
exports.CalendarInputDesktop = CalendarInputDesktop;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CalendarInputProps } from "./Component-98dcf994";
|
|
3
|
+
type CalendarInputMobileProps = Omit<CalendarInputProps, 'view'>;
|
|
4
|
+
declare const CalendarInputMobile: FC<CalendarInputMobileProps>;
|
|
5
|
+
export { CalendarInputMobileProps, CalendarInputMobile };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var components_calendarInput_Component = require('./Component-98dcf994.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var coreComponentsCalendar = require('@alfalab/core-components-calendar');
|
|
6
|
+
require('react-merge-refs');
|
|
7
|
+
require('classnames');
|
|
8
|
+
require('@alfalab/core-components-date-input');
|
|
9
|
+
require('@alfalab/core-components-popover');
|
|
10
|
+
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
11
|
+
require('./utils.js');
|
|
12
|
+
require('date-fns/format');
|
|
13
|
+
require('date-fns/isSameDay');
|
|
14
|
+
require('date-fns/parse');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
17
|
+
|
|
18
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
19
|
+
|
|
20
|
+
var CalendarInputMobile = function (props) { return (React__default.default.createElement(components_calendarInput_Component.CalendarInput, components_calendarInput_Component.__assign({ Calendar: coreComponentsCalendar.CalendarMobile, view: 'mobile' }, props))); };
|
|
21
|
+
|
|
22
|
+
exports.CalendarInputMobile = CalendarInputMobile;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CalendarInputProps } from "./Component-98dcf994";
|
|
3
|
+
type CalendarInputResponsiveProps = Omit<CalendarInputProps, 'view'> & {
|
|
4
|
+
/**
|
|
5
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
6
|
+
* @default 1024
|
|
7
|
+
*/
|
|
8
|
+
breakpoint?: number;
|
|
9
|
+
};
|
|
10
|
+
type CalendarInputMedia = 'desktop' | 'mobile';
|
|
11
|
+
declare const CalendarInputResponsive: FC<CalendarInputResponsiveProps>;
|
|
12
|
+
export { CalendarInputResponsiveProps, CalendarInputMedia, CalendarInputResponsive };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var components_calendarInput_Component = require('./Component-98dcf994.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var hooks = require('@alfalab/hooks');
|
|
6
|
+
var Component_desktop = require('./Component.desktop.js');
|
|
7
|
+
var Component_mobile = require('./Component.mobile.js');
|
|
8
|
+
require('react-merge-refs');
|
|
9
|
+
require('classnames');
|
|
10
|
+
require('@alfalab/core-components-calendar');
|
|
11
|
+
require('@alfalab/core-components-date-input');
|
|
12
|
+
require('@alfalab/core-components-popover');
|
|
13
|
+
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
14
|
+
require('./utils.js');
|
|
15
|
+
require('date-fns/format');
|
|
16
|
+
require('date-fns/isSameDay');
|
|
17
|
+
require('date-fns/parse');
|
|
18
|
+
|
|
19
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
20
|
+
|
|
21
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
22
|
+
|
|
23
|
+
var CalendarInputResponsive = function (_a) {
|
|
24
|
+
var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps = components_calendarInput_Component.__rest(_a, ["breakpoint"]);
|
|
25
|
+
var view = hooks.useMedia([
|
|
26
|
+
['mobile', "(max-width: ".concat(breakpoint - 1, "px)")],
|
|
27
|
+
['desktop', "(min-width: ".concat(breakpoint, "px)")],
|
|
28
|
+
], 'desktop')[0];
|
|
29
|
+
return view === 'desktop' ? (React__default.default.createElement(Component_desktop.CalendarInputDesktop, components_calendarInput_Component.__assign({}, restProps))) : (React__default.default.createElement(Component_mobile.CalendarInputMobile, components_calendarInput_Component.__assign({}, restProps)));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.CalendarInputResponsive = CalendarInputResponsive;
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var components_calendarInput_Component = require('../../Component-98dcf994.js');
|
|
4
|
+
require('react');
|
|
5
|
+
require('react-merge-refs');
|
|
6
|
+
require('classnames');
|
|
7
|
+
require('@alfalab/core-components-calendar');
|
|
8
|
+
require('@alfalab/core-components-date-input');
|
|
9
|
+
require('@alfalab/core-components-popover');
|
|
10
|
+
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
11
|
+
require('../../utils.js');
|
|
12
|
+
require('date-fns/format');
|
|
13
|
+
require('date-fns/isSameDay');
|
|
14
|
+
require('date-fns/parse');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.CalendarInput = components_calendarInput_Component.CalendarInput;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1yw0a */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-graphic-primary: #0b1f35;
|
|
4
4
|
}
|
|
@@ -44,39 +44,39 @@
|
|
|
44
44
|
--calendar-input-icon-color: var(--color-light-graphic-primary);
|
|
45
45
|
--calendar-input-popover-border-radius: var(--border-radius-m);
|
|
46
46
|
}
|
|
47
|
-
.calendar-
|
|
47
|
+
.calendar-input__component_wpjcj {
|
|
48
48
|
display: inline-block;
|
|
49
49
|
outline: none;
|
|
50
50
|
position: relative;
|
|
51
51
|
}
|
|
52
|
-
.calendar-
|
|
52
|
+
.calendar-input__block_wpjcj {
|
|
53
53
|
width: 100%;
|
|
54
54
|
}
|
|
55
|
-
.calendar-
|
|
55
|
+
.calendar-input__calendarContainer_wpjcj {
|
|
56
56
|
display: inline-block;
|
|
57
57
|
box-sizing: border-box;
|
|
58
58
|
border-radius: var(--calendar-input-popover-border-radius)
|
|
59
59
|
}
|
|
60
60
|
@media (max-width: 374px) {
|
|
61
|
-
.calendar-
|
|
61
|
+
.calendar-input__calendarContainer_wpjcj {
|
|
62
62
|
width: 100%;
|
|
63
63
|
min-width: 288px
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
.calendar-
|
|
66
|
+
.calendar-input__calendarResponsive_wpjcj {
|
|
67
67
|
width: var(--calendar-width);
|
|
68
68
|
padding: 0 var(--gap-m);
|
|
69
69
|
}
|
|
70
|
-
.calendar-
|
|
70
|
+
.calendar-input__calendarIcon_wpjcj {
|
|
71
71
|
width: 24px;
|
|
72
72
|
height: 24px;
|
|
73
73
|
display: block;
|
|
74
74
|
color: var(--calendar-input-icon-color)
|
|
75
75
|
}
|
|
76
|
-
.calendar-
|
|
76
|
+
.calendar-input__calendarIcon_wpjcj:not(:only-child) {
|
|
77
77
|
margin-right: var(--gap-2xs);
|
|
78
78
|
}
|
|
79
|
-
.calendar-
|
|
79
|
+
.calendar-input__nativeInput_wpjcj {
|
|
80
80
|
opacity: 0;
|
|
81
81
|
position: absolute;
|
|
82
82
|
top: 0;
|
|
@@ -87,9 +87,9 @@
|
|
|
87
87
|
appearance: none;
|
|
88
88
|
z-index: 1
|
|
89
89
|
}
|
|
90
|
-
.calendar-
|
|
90
|
+
.calendar-input__nativeInput_wpjcj::-webkit-calendar-picker-indicator {
|
|
91
91
|
display: none;
|
|
92
92
|
}
|
|
93
|
-
.calendar-
|
|
93
|
+
.calendar-input__nativeInput_wpjcj::-webkit-inner-spin-button {
|
|
94
94
|
display: none;
|
|
95
95
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../Component-98dcf994";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var components_calendarInput_Component = require('../../Component-98dcf994.js');
|
|
4
|
+
require('react');
|
|
5
|
+
require('react-merge-refs');
|
|
6
|
+
require('classnames');
|
|
7
|
+
require('@alfalab/core-components-calendar');
|
|
8
|
+
require('@alfalab/core-components-date-input');
|
|
9
|
+
require('@alfalab/core-components-popover');
|
|
10
|
+
require('@alfalab/icons-glyph/CalendarMIcon');
|
|
11
|
+
require('../../utils.js');
|
|
12
|
+
require('date-fns/format');
|
|
13
|
+
require('date-fns/isSameDay');
|
|
14
|
+
require('date-fns/parse');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.CalendarInput = components_calendarInput_Component.CalendarInput;
|
|
@@ -4,6 +4,39 @@ import { ChangeEvent, ElementType, MouseEvent } from "react";
|
|
|
4
4
|
import { CalendarMobileProps, CalendarProps } from "@alfalab/core-components-calendar";
|
|
5
5
|
import { DateInputProps } from "@alfalab/core-components-date-input";
|
|
6
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;
|
|
7
40
|
type CalendarInputProps = Omit<DateInputProps, 'onChange' | 'mobileMode'> & {
|
|
8
41
|
/**
|
|
9
42
|
* Дополнительный класс
|
|
@@ -69,7 +102,7 @@ type CalendarInputProps = Omit<DateInputProps, 'onChange' | 'mobileMode'> & {
|
|
|
69
102
|
/**
|
|
70
103
|
* Компонент календаря
|
|
71
104
|
*/
|
|
72
|
-
Calendar?: ElementType
|
|
105
|
+
Calendar?: ElementType;
|
|
73
106
|
/**
|
|
74
107
|
* Обработчик изменения значения
|
|
75
108
|
*/
|
|
@@ -100,6 +133,10 @@ type CalendarInputProps = Omit<DateInputProps, 'onChange' | 'mobileMode'> & {
|
|
|
100
133
|
* Календарь будет принимать ширину инпута
|
|
101
134
|
*/
|
|
102
135
|
useAnchorWidth?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Отображение компонента в мобильном или десктопном виде
|
|
138
|
+
*/
|
|
139
|
+
view?: 'desktop' | 'mobile';
|
|
103
140
|
};
|
|
104
141
|
declare const CalendarInput: React.ForwardRefExoticComponent<Omit<DateInputProps, "onChange" | "mobileMode"> & {
|
|
105
142
|
/**
|
|
@@ -119,9 +156,7 @@ declare const CalendarInput: React.ForwardRefExoticComponent<Omit<DateInputProps
|
|
|
119
156
|
*/
|
|
120
157
|
calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
|
|
121
158
|
open: boolean;
|
|
122
|
-
title?: string | undefined;
|
|
123
|
-
* Дополнительный класс для поповера
|
|
124
|
-
*/
|
|
159
|
+
title?: string | undefined;
|
|
125
160
|
onClose?: (() => void) | undefined;
|
|
126
161
|
yearsAmount?: number | undefined;
|
|
127
162
|
hasHeader?: boolean | undefined;
|
|
@@ -175,7 +210,7 @@ declare const CalendarInput: React.ForwardRefExoticComponent<Omit<DateInputProps
|
|
|
175
210
|
/**
|
|
176
211
|
* Компонент календаря
|
|
177
212
|
*/
|
|
178
|
-
Calendar?: React.ElementType<
|
|
213
|
+
Calendar?: React.ElementType<any> | undefined;
|
|
179
214
|
/**
|
|
180
215
|
* Обработчик изменения значения
|
|
181
216
|
*/
|
|
@@ -206,5 +241,9 @@ declare const CalendarInput: React.ForwardRefExoticComponent<Omit<DateInputProps
|
|
|
206
241
|
* Календарь будет принимать ширину инпута
|
|
207
242
|
*/
|
|
208
243
|
useAnchorWidth?: boolean | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* Отображение компонента в мобильном или десктопном виде
|
|
246
|
+
*/
|
|
247
|
+
view?: "desktop" | "mobile" | undefined;
|
|
209
248
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
210
|
-
export { CalendarInputProps, CalendarInput };
|
|
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 };
|
|
@@ -6,13 +6,16 @@ var cn = require('classnames');
|
|
|
6
6
|
var coreComponentsCalendar = require('@alfalab/core-components-calendar/cssm');
|
|
7
7
|
var coreComponentsDateInput = require('@alfalab/core-components-date-input/cssm');
|
|
8
8
|
var coreComponentsPopover = require('@alfalab/core-components-popover/cssm');
|
|
9
|
-
var hooks = require('@alfalab/hooks');
|
|
10
9
|
var CalendarMIcon = require('@alfalab/icons-glyph/CalendarMIcon');
|
|
11
10
|
var utils = require('./utils.js');
|
|
12
|
-
var styles = require('./index.module.css');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
var styles = require('./components/calendar-input/index.module.css');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
14
|
+
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
16
|
+
var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
|
|
17
|
+
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
18
|
+
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
16
19
|
|
|
17
20
|
/******************************************************************************
|
|
18
21
|
Copyright (c) Microsoft Corporation.
|
|
@@ -28,8 +31,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
28
31
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
29
32
|
PERFORMANCE OF THIS SOFTWARE.
|
|
30
33
|
***************************************************************************** */
|
|
31
|
-
|
|
32
|
-
__assign = Object.assign || function __assign(t) {
|
|
34
|
+
exports.__assign = function () {
|
|
35
|
+
exports.__assign = Object.assign || function __assign(t) {
|
|
33
36
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
34
37
|
s = arguments[i];
|
|
35
38
|
for (var p in s)
|
|
@@ -38,7 +41,7 @@ var __assign = function () {
|
|
|
38
41
|
}
|
|
39
42
|
return t;
|
|
40
43
|
};
|
|
41
|
-
return __assign.apply(this, arguments);
|
|
44
|
+
return exports.__assign.apply(this, arguments);
|
|
42
45
|
};
|
|
43
46
|
function __rest(s, e) {
|
|
44
47
|
var t = {};
|
|
@@ -56,19 +59,14 @@ function __rest(s, e) {
|
|
|
56
59
|
var CalendarInput = React.forwardRef(function (_a, ref) {
|
|
57
60
|
var _b, _c;
|
|
58
61
|
var _d;
|
|
59
|
-
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, 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"]);
|
|
60
|
-
var view = hooks.useMedia([
|
|
61
|
-
['mobile', '(max-width: 1023px)'],
|
|
62
|
-
['desktop', '(min-width: 1024px)'],
|
|
63
|
-
], 'desktop')[0];
|
|
64
|
-
var CalendarComponent = view === 'desktop' ? Calendar : coreComponentsCalendar.CalendarMobile;
|
|
62
|
+
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"]);
|
|
65
63
|
var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
|
|
66
64
|
var shouldRenderNative = utils.SUPPORTS_INPUT_TYPE_DATE && mobileMode === 'native';
|
|
67
65
|
var shouldRenderOnlyInput = mobileMode === 'input';
|
|
68
66
|
var shouldRenderStatic = calendarPosition === 'static' && !shouldRenderOnlyInput;
|
|
69
67
|
var shouldRenderPopover = calendarPosition === 'popover' && !shouldRenderNative && !shouldRenderOnlyInput;
|
|
70
|
-
var
|
|
71
|
-
var
|
|
68
|
+
var _v = React.useState(false), open = _v[0], setOpen = _v[1];
|
|
69
|
+
var _w = React.useState(value || defaultValue), inputValue = _w[0], setInputValue = _w[1];
|
|
72
70
|
var calendarValue = inputValue ? coreComponentsDateInput.parseDateString(inputValue).getTime() : undefined;
|
|
73
71
|
var checkInputValueIsValid = React.useCallback(function (newInputValue) {
|
|
74
72
|
if (!newInputValue)
|
|
@@ -160,20 +158,21 @@ var CalendarInput = React.forwardRef(function (_a, ref) {
|
|
|
160
158
|
}, [value]);
|
|
161
159
|
var renderCalendar = function () { return (
|
|
162
160
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
React__default.default.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
162
|
+
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 })))); };
|
|
165
163
|
return (
|
|
166
164
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
167
|
-
|
|
168
|
-
_b[
|
|
165
|
+
React__default.default.createElement("div", { className: cn__default.default(styles__default.default.component, className, (_b = {},
|
|
166
|
+
_b[styles__default.default.block] = block,
|
|
169
167
|
_b)), tabIndex: -1, onKeyDown: inputDisabled ? undefined : handleKeyDown, onClick: inputDisabled ? undefined : handleClick, onFocus: inputDisabled ? undefined : handleFocus, onBlur: handleBlur, "data-test-id": dataTestId },
|
|
170
|
-
|
|
168
|
+
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,
|
|
171
169
|
rightAddons,
|
|
172
|
-
shouldRenderPopover && (
|
|
170
|
+
shouldRenderPopover && (React__default.default.createElement(CalendarMIcon.CalendarMIcon, { className: styles__default.default.calendarIcon }))), onKeyDown: handleInputKeyDown, onChange: handleInputChange, block: true })),
|
|
173
171
|
shouldRenderStatic && renderCalendar(),
|
|
174
|
-
shouldRenderPopover && (
|
|
175
|
-
_c[
|
|
172
|
+
shouldRenderPopover && (React__default.default.createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputWrapperRef.current, popperClassName: cn__default.default(styles__default.default.calendarContainer, (_c = {},
|
|
173
|
+
_c[styles__default.default.calendarResponsive] = calendarResponsive,
|
|
176
174
|
_c)), className: popoverClassName, position: popoverPosition, offset: [0, 4], withTransition: false, preventFlip: preventFlip, zIndex: zIndexPopover }, renderCalendar()))));
|
|
177
175
|
});
|
|
178
176
|
|
|
179
177
|
exports.CalendarInput = CalendarInput;
|
|
178
|
+
exports.__rest = __rest;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CalendarInputProps } from "./Component-fde0c12c";
|
|
3
|
+
type CalendarInputDesktopProps = Omit<CalendarInputProps, 'view'>;
|
|
4
|
+
declare const CalendarInputDesktop: FC<CalendarInputDesktopProps>;
|
|
5
|
+
export { CalendarInputDesktopProps, CalendarInputDesktop };
|