@alfalab/core-components-date-time-input 3.1.12 → 3.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/components/date-time-input/Component.d.ts +12 -0
- package/components/date-time-input/Component.js +11 -5
- package/components/date-time-input/index.css +7 -7
- package/cssm/components/date-time-input/Component.d.ts +12 -0
- package/cssm/components/date-time-input/Component.js +10 -4
- package/esm/components/date-time-input/Component.d.ts +12 -0
- package/esm/components/date-time-input/Component.js +11 -5
- package/esm/components/date-time-input/index.css +7 -7
- package/modern/components/date-time-input/Component.d.ts +12 -0
- package/modern/components/date-time-input/Component.js +9 -3
- package/modern/components/date-time-input/index.css +7 -7
- package/package.json +5 -5
- package/send-stats.js +0 -82
|
@@ -92,6 +92,10 @@ type DateTimeInputProps = Omit<InputProps, 'onChange'> & {
|
|
|
92
92
|
* Отображение компонента в мобильном или десктопном виде
|
|
93
93
|
*/
|
|
94
94
|
view?: 'desktop' | 'mobile';
|
|
95
|
+
/**
|
|
96
|
+
* Запретить ввод с клавиатуры
|
|
97
|
+
*/
|
|
98
|
+
disableUserInput?: boolean;
|
|
95
99
|
};
|
|
96
100
|
declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
|
|
97
101
|
/**
|
|
@@ -133,8 +137,12 @@ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "o
|
|
|
133
137
|
*/
|
|
134
138
|
calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
|
|
135
139
|
open: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Дополнительный класс для поповера
|
|
142
|
+
*/
|
|
136
143
|
title?: string | undefined;
|
|
137
144
|
onClose?: (() => void) | undefined;
|
|
145
|
+
onMonthTitleClick?: ((event: React.MouseEvent<HTMLSpanElement, globalThis.MouseEvent>) => void) | undefined;
|
|
138
146
|
yearsAmount?: number | undefined;
|
|
139
147
|
hasHeader?: boolean | undefined;
|
|
140
148
|
allowSelectionFromEmptyRange?: boolean | undefined;
|
|
@@ -188,5 +196,9 @@ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "o
|
|
|
188
196
|
* Отображение компонента в мобильном или десктопном виде
|
|
189
197
|
*/
|
|
190
198
|
view?: "mobile" | "desktop" | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Запретить ввод с клавиатуры
|
|
201
|
+
*/
|
|
202
|
+
disableUserInput?: boolean | undefined;
|
|
191
203
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
192
204
|
export { DateTimeInputProps, DateTimeInput };
|
|
@@ -22,18 +22,18 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
22
22
|
var mergeRefs__default = /*#__PURE__*/_interopDefaultCompat(mergeRefs);
|
|
23
23
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
24
24
|
|
|
25
|
-
var styles = {"component":"date-time-
|
|
25
|
+
var styles = {"component":"date-time-input__component_unkuq","calendarContainer":"date-time-input__calendarContainer_unkuq","calendarResponsive":"date-time-input__calendarResponsive_unkuq","block":"date-time-input__block_unkuq","calendarIcon":"date-time-input__calendarIcon_unkuq"};
|
|
26
26
|
require('./index.css')
|
|
27
27
|
|
|
28
28
|
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
|
29
29
|
var DateTimeInput = React__default.default.forwardRef(function (_a, ref) {
|
|
30
30
|
var _b, _c;
|
|
31
31
|
var _d;
|
|
32
|
-
var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, picker = _a.picker,
|
|
32
|
+
var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, _e = _a.disableUserInput, disableUserInput = _e === void 0 ? false : _e, picker = _a.picker, _f = _a.defaultValue, defaultValue = _f === void 0 ? '' : _f, propValue = _a.value, onChange = _a.onChange, onComplete = _a.onComplete, rightAddons = _a.rightAddons, useAnchorWidth = _a.useAnchorWidth, block = _a.block, _g = _a.popoverPosition, popoverPosition = _g === void 0 ? 'bottom-start' : _g, zIndexPopover = _a.zIndexPopover, preventFlip = _a.preventFlip, _h = _a.Calendar, Calendar = _h === void 0 ? coreComponentsCalendar.Calendar : _h, _j = _a.calendarProps, calendarProps = _j === void 0 ? {} : _j, defaultMonth = _a.defaultMonth, _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, _p = _a.defaultOpen, defaultOpen = _p === void 0 ? false : _p, error = _a.error, _q = _a.view, view = _q === void 0 ? 'desktop' : _q, restProps = tslib.__rest(_a, ["className", "inputClassName", "popoverClassName", "disabled", "readOnly", "disableUserInput", "picker", "defaultValue", "value", "onChange", "onComplete", "rightAddons", "useAnchorWidth", "block", "popoverPosition", "zIndexPopover", "preventFlip", "Calendar", "calendarProps", "defaultMonth", "minDate", "maxDate", "offDays", "events", "defaultOpen", "error", "view"]);
|
|
33
33
|
var inputRef = React.useRef(null);
|
|
34
34
|
var calendarRef = React.useRef(null);
|
|
35
|
-
var
|
|
36
|
-
var
|
|
35
|
+
var _r = React.useState(propValue || defaultValue), value = _r[0], setValue = _r[1];
|
|
36
|
+
var _s = React.useState(false), open = _s[0], setOpen = _s[1];
|
|
37
37
|
var calendarValue = value ? utils_format.getDateWithoutTime(value).getTime() : undefined;
|
|
38
38
|
var inputDisabled = disabled || readOnly;
|
|
39
39
|
var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
|
|
@@ -121,6 +121,12 @@ var DateTimeInput = React__default.default.forwardRef(function (_a, ref) {
|
|
|
121
121
|
var handleClear = function () {
|
|
122
122
|
setValue('');
|
|
123
123
|
};
|
|
124
|
+
var handleInputKeyDown = function (event) {
|
|
125
|
+
var isCopy = (event.metaKey || event.ctrlKey) && event.key === 'c';
|
|
126
|
+
if (disableUserInput && !isCopy) {
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
124
130
|
var handleCalendarChange = function (date) {
|
|
125
131
|
if (date) {
|
|
126
132
|
var newValue = utils_format.parseTimestampToDate(date);
|
|
@@ -146,7 +152,7 @@ var DateTimeInput = React__default.default.forwardRef(function (_a, ref) {
|
|
|
146
152
|
return (React__default.default.createElement("div", { className: cn__default.default(styles.component, className, (_b = {},
|
|
147
153
|
_b[styles.block] = block,
|
|
148
154
|
_b)), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
149
|
-
React__default.default.createElement(coreComponentsInput.Input, tslib.__assign({}, restProps, { block: block, ref: mergeRefs__default.default([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, error: error, rightAddons: React__default.default.createElement(React__default.default.Fragment, null,
|
|
155
|
+
React__default.default.createElement(coreComponentsInput.Input, tslib.__assign({}, restProps, { block: block, ref: mergeRefs__default.default([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, onKeyDown: handleInputKeyDown, error: error, rightAddons: React__default.default.createElement(React__default.default.Fragment, null,
|
|
150
156
|
rightAddons,
|
|
151
157
|
picker && (React__default.default.createElement(coreComponentsIconButton.IconButton, { className: styles.calendarIcon, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon.CalendarMIcon, size: 's' }))) })),
|
|
152
158
|
picker && (React__default.default.createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn__default.default(styles.calendarContainer, (_c = {},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1gt4g */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-border-secondary: #e9e9eb; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -41,24 +41,24 @@
|
|
|
41
41
|
/* marker */
|
|
42
42
|
} :root {
|
|
43
43
|
--calendar-popover-border-radius: var(--border-radius-m);
|
|
44
|
-
} .date-time-
|
|
44
|
+
} .date-time-input__component_unkuq {
|
|
45
45
|
display: inline-block;
|
|
46
46
|
outline: none;
|
|
47
47
|
position: relative;
|
|
48
|
-
} .date-time-
|
|
48
|
+
} .date-time-input__calendarContainer_unkuq {
|
|
49
49
|
display: inline-block;
|
|
50
50
|
box-sizing: border-box;
|
|
51
51
|
border-radius: var(--calendar-popover-border-radius);
|
|
52
52
|
border: 1px solid var(--color-light-border-secondary)
|
|
53
|
-
} @media (max-width: 374px) { .date-time-
|
|
53
|
+
} @media (max-width: 374px) { .date-time-input__calendarContainer_unkuq {
|
|
54
54
|
width: 100%;
|
|
55
55
|
min-width: 288px
|
|
56
56
|
}
|
|
57
|
-
} .date-time-
|
|
57
|
+
} .date-time-input__calendarResponsive_unkuq {
|
|
58
58
|
width: var(--calendar-width);
|
|
59
|
-
} .date-time-
|
|
59
|
+
} .date-time-input__block_unkuq {
|
|
60
60
|
width: 100%;
|
|
61
|
-
} .date-time-
|
|
61
|
+
} .date-time-input__calendarIcon_unkuq {
|
|
62
62
|
margin-right: var(--gap-s-neg);
|
|
63
63
|
height: 100%;
|
|
64
64
|
}
|
|
@@ -92,6 +92,10 @@ type DateTimeInputProps = Omit<InputProps, 'onChange'> & {
|
|
|
92
92
|
* Отображение компонента в мобильном или десктопном виде
|
|
93
93
|
*/
|
|
94
94
|
view?: 'desktop' | 'mobile';
|
|
95
|
+
/**
|
|
96
|
+
* Запретить ввод с клавиатуры
|
|
97
|
+
*/
|
|
98
|
+
disableUserInput?: boolean;
|
|
95
99
|
};
|
|
96
100
|
declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
|
|
97
101
|
/**
|
|
@@ -133,8 +137,12 @@ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "o
|
|
|
133
137
|
*/
|
|
134
138
|
calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
|
|
135
139
|
open: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Дополнительный класс для поповера
|
|
142
|
+
*/
|
|
136
143
|
title?: string | undefined;
|
|
137
144
|
onClose?: (() => void) | undefined;
|
|
145
|
+
onMonthTitleClick?: ((event: React.MouseEvent<HTMLSpanElement, globalThis.MouseEvent>) => void) | undefined;
|
|
138
146
|
yearsAmount?: number | undefined;
|
|
139
147
|
hasHeader?: boolean | undefined;
|
|
140
148
|
allowSelectionFromEmptyRange?: boolean | undefined;
|
|
@@ -188,5 +196,9 @@ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "o
|
|
|
188
196
|
* Отображение компонента в мобильном или десктопном виде
|
|
189
197
|
*/
|
|
190
198
|
view?: "mobile" | "desktop" | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Запретить ввод с клавиатуры
|
|
201
|
+
*/
|
|
202
|
+
disableUserInput?: boolean | undefined;
|
|
191
203
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
192
204
|
export { DateTimeInputProps, DateTimeInput };
|
|
@@ -28,11 +28,11 @@ var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
|
28
28
|
var DateTimeInput = React__default.default.forwardRef(function (_a, ref) {
|
|
29
29
|
var _b, _c;
|
|
30
30
|
var _d;
|
|
31
|
-
var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, picker = _a.picker,
|
|
31
|
+
var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, _e = _a.disableUserInput, disableUserInput = _e === void 0 ? false : _e, picker = _a.picker, _f = _a.defaultValue, defaultValue = _f === void 0 ? '' : _f, propValue = _a.value, onChange = _a.onChange, onComplete = _a.onComplete, rightAddons = _a.rightAddons, useAnchorWidth = _a.useAnchorWidth, block = _a.block, _g = _a.popoverPosition, popoverPosition = _g === void 0 ? 'bottom-start' : _g, zIndexPopover = _a.zIndexPopover, preventFlip = _a.preventFlip, _h = _a.Calendar, Calendar = _h === void 0 ? coreComponentsCalendar.Calendar : _h, _j = _a.calendarProps, calendarProps = _j === void 0 ? {} : _j, defaultMonth = _a.defaultMonth, _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, _p = _a.defaultOpen, defaultOpen = _p === void 0 ? false : _p, error = _a.error, _q = _a.view, view = _q === void 0 ? 'desktop' : _q, restProps = tslib.__rest(_a, ["className", "inputClassName", "popoverClassName", "disabled", "readOnly", "disableUserInput", "picker", "defaultValue", "value", "onChange", "onComplete", "rightAddons", "useAnchorWidth", "block", "popoverPosition", "zIndexPopover", "preventFlip", "Calendar", "calendarProps", "defaultMonth", "minDate", "maxDate", "offDays", "events", "defaultOpen", "error", "view"]);
|
|
32
32
|
var inputRef = React.useRef(null);
|
|
33
33
|
var calendarRef = React.useRef(null);
|
|
34
|
-
var
|
|
35
|
-
var
|
|
34
|
+
var _r = React.useState(propValue || defaultValue), value = _r[0], setValue = _r[1];
|
|
35
|
+
var _s = React.useState(false), open = _s[0], setOpen = _s[1];
|
|
36
36
|
var calendarValue = value ? utils_format.getDateWithoutTime(value).getTime() : undefined;
|
|
37
37
|
var inputDisabled = disabled || readOnly;
|
|
38
38
|
var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
|
|
@@ -120,6 +120,12 @@ var DateTimeInput = React__default.default.forwardRef(function (_a, ref) {
|
|
|
120
120
|
var handleClear = function () {
|
|
121
121
|
setValue('');
|
|
122
122
|
};
|
|
123
|
+
var handleInputKeyDown = function (event) {
|
|
124
|
+
var isCopy = (event.metaKey || event.ctrlKey) && event.key === 'c';
|
|
125
|
+
if (disableUserInput && !isCopy) {
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
123
129
|
var handleCalendarChange = function (date) {
|
|
124
130
|
if (date) {
|
|
125
131
|
var newValue = utils_format.parseTimestampToDate(date);
|
|
@@ -145,7 +151,7 @@ var DateTimeInput = React__default.default.forwardRef(function (_a, ref) {
|
|
|
145
151
|
return (React__default.default.createElement("div", { className: cn__default.default(styles__default.default.component, className, (_b = {},
|
|
146
152
|
_b[styles__default.default.block] = block,
|
|
147
153
|
_b)), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
148
|
-
React__default.default.createElement(coreComponentsInput.Input, tslib.__assign({}, restProps, { block: block, ref: mergeRefs__default.default([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, error: error, rightAddons: React__default.default.createElement(React__default.default.Fragment, null,
|
|
154
|
+
React__default.default.createElement(coreComponentsInput.Input, tslib.__assign({}, restProps, { block: block, ref: mergeRefs__default.default([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, onKeyDown: handleInputKeyDown, error: error, rightAddons: React__default.default.createElement(React__default.default.Fragment, null,
|
|
149
155
|
rightAddons,
|
|
150
156
|
picker && (React__default.default.createElement(coreComponentsIconButton.IconButton, { className: styles__default.default.calendarIcon, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon.CalendarMIcon, size: 's' }))) })),
|
|
151
157
|
picker && (React__default.default.createElement(coreComponentsPopover.Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn__default.default(styles__default.default.calendarContainer, (_c = {},
|
|
@@ -92,6 +92,10 @@ type DateTimeInputProps = Omit<InputProps, 'onChange'> & {
|
|
|
92
92
|
* Отображение компонента в мобильном или десктопном виде
|
|
93
93
|
*/
|
|
94
94
|
view?: 'desktop' | 'mobile';
|
|
95
|
+
/**
|
|
96
|
+
* Запретить ввод с клавиатуры
|
|
97
|
+
*/
|
|
98
|
+
disableUserInput?: boolean;
|
|
95
99
|
};
|
|
96
100
|
declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
|
|
97
101
|
/**
|
|
@@ -133,8 +137,12 @@ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "o
|
|
|
133
137
|
*/
|
|
134
138
|
calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
|
|
135
139
|
open: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Дополнительный класс для поповера
|
|
142
|
+
*/
|
|
136
143
|
title?: string | undefined;
|
|
137
144
|
onClose?: (() => void) | undefined;
|
|
145
|
+
onMonthTitleClick?: ((event: React.MouseEvent<HTMLSpanElement, globalThis.MouseEvent>) => void) | undefined;
|
|
138
146
|
yearsAmount?: number | undefined;
|
|
139
147
|
hasHeader?: boolean | undefined;
|
|
140
148
|
allowSelectionFromEmptyRange?: boolean | undefined;
|
|
@@ -188,5 +196,9 @@ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "o
|
|
|
188
196
|
* Отображение компонента в мобильном или десктопном виде
|
|
189
197
|
*/
|
|
190
198
|
view?: "mobile" | "desktop" | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Запретить ввод с клавиатуры
|
|
201
|
+
*/
|
|
202
|
+
disableUserInput?: boolean | undefined;
|
|
191
203
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
192
204
|
export { DateTimeInputProps, DateTimeInput };
|
|
@@ -12,18 +12,18 @@ import { getDateWithoutTime, DATE_WITH_TIME_LENGTH, format, getFullDateTime, isC
|
|
|
12
12
|
import 'date-fns/isValid';
|
|
13
13
|
import 'date-fns/parse';
|
|
14
14
|
|
|
15
|
-
var styles = {"component":"date-time-
|
|
15
|
+
var styles = {"component":"date-time-input__component_unkuq","calendarContainer":"date-time-input__calendarContainer_unkuq","calendarResponsive":"date-time-input__calendarResponsive_unkuq","block":"date-time-input__block_unkuq","calendarIcon":"date-time-input__calendarIcon_unkuq"};
|
|
16
16
|
require('./index.css')
|
|
17
17
|
|
|
18
18
|
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
|
19
19
|
var DateTimeInput = React.forwardRef(function (_a, ref) {
|
|
20
20
|
var _b, _c;
|
|
21
21
|
var _d;
|
|
22
|
-
var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, picker = _a.picker,
|
|
22
|
+
var className = _a.className, inputClassName = _a.inputClassName, popoverClassName = _a.popoverClassName, disabled = _a.disabled, readOnly = _a.readOnly, _e = _a.disableUserInput, disableUserInput = _e === void 0 ? false : _e, picker = _a.picker, _f = _a.defaultValue, defaultValue = _f === void 0 ? '' : _f, propValue = _a.value, onChange = _a.onChange, onComplete = _a.onComplete, rightAddons = _a.rightAddons, useAnchorWidth = _a.useAnchorWidth, block = _a.block, _g = _a.popoverPosition, popoverPosition = _g === void 0 ? 'bottom-start' : _g, zIndexPopover = _a.zIndexPopover, preventFlip = _a.preventFlip, _h = _a.Calendar, Calendar$1 = _h === void 0 ? Calendar : _h, _j = _a.calendarProps, calendarProps = _j === void 0 ? {} : _j, defaultMonth = _a.defaultMonth, _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, _p = _a.defaultOpen, defaultOpen = _p === void 0 ? false : _p, error = _a.error, _q = _a.view, view = _q === void 0 ? 'desktop' : _q, restProps = __rest(_a, ["className", "inputClassName", "popoverClassName", "disabled", "readOnly", "disableUserInput", "picker", "defaultValue", "value", "onChange", "onComplete", "rightAddons", "useAnchorWidth", "block", "popoverPosition", "zIndexPopover", "preventFlip", "Calendar", "calendarProps", "defaultMonth", "minDate", "maxDate", "offDays", "events", "defaultOpen", "error", "view"]);
|
|
23
23
|
var inputRef = useRef(null);
|
|
24
24
|
var calendarRef = useRef(null);
|
|
25
|
-
var
|
|
26
|
-
var
|
|
25
|
+
var _r = useState(propValue || defaultValue), value = _r[0], setValue = _r[1];
|
|
26
|
+
var _s = useState(false), open = _s[0], setOpen = _s[1];
|
|
27
27
|
var calendarValue = value ? getDateWithoutTime(value).getTime() : undefined;
|
|
28
28
|
var inputDisabled = disabled || readOnly;
|
|
29
29
|
var calendarResponsive = (_d = calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.responsive) !== null && _d !== void 0 ? _d : true;
|
|
@@ -111,6 +111,12 @@ var DateTimeInput = React.forwardRef(function (_a, ref) {
|
|
|
111
111
|
var handleClear = function () {
|
|
112
112
|
setValue('');
|
|
113
113
|
};
|
|
114
|
+
var handleInputKeyDown = function (event) {
|
|
115
|
+
var isCopy = (event.metaKey || event.ctrlKey) && event.key === 'c';
|
|
116
|
+
if (disableUserInput && !isCopy) {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
}
|
|
119
|
+
};
|
|
114
120
|
var handleCalendarChange = function (date) {
|
|
115
121
|
if (date) {
|
|
116
122
|
var newValue = parseTimestampToDate(date);
|
|
@@ -136,7 +142,7 @@ var DateTimeInput = React.forwardRef(function (_a, ref) {
|
|
|
136
142
|
return (React.createElement("div", { className: cn(styles.component, className, (_b = {},
|
|
137
143
|
_b[styles.block] = block,
|
|
138
144
|
_b)), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
139
|
-
React.createElement(Input, __assign({}, restProps, { block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, error: error, rightAddons: React.createElement(React.Fragment, null,
|
|
145
|
+
React.createElement(Input, __assign({}, restProps, { block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, onKeyDown: handleInputKeyDown, error: error, rightAddons: React.createElement(React.Fragment, null,
|
|
140
146
|
rightAddons,
|
|
141
147
|
picker && (React.createElement(IconButton, { className: styles.calendarIcon, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 's' }))) })),
|
|
142
148
|
picker && (React.createElement(Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn(styles.calendarContainer, (_c = {},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1gt4g */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-border-secondary: #e9e9eb; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -41,24 +41,24 @@
|
|
|
41
41
|
/* marker */
|
|
42
42
|
} :root {
|
|
43
43
|
--calendar-popover-border-radius: var(--border-radius-m);
|
|
44
|
-
} .date-time-
|
|
44
|
+
} .date-time-input__component_unkuq {
|
|
45
45
|
display: inline-block;
|
|
46
46
|
outline: none;
|
|
47
47
|
position: relative;
|
|
48
|
-
} .date-time-
|
|
48
|
+
} .date-time-input__calendarContainer_unkuq {
|
|
49
49
|
display: inline-block;
|
|
50
50
|
box-sizing: border-box;
|
|
51
51
|
border-radius: var(--calendar-popover-border-radius);
|
|
52
52
|
border: 1px solid var(--color-light-border-secondary)
|
|
53
|
-
} @media (max-width: 374px) { .date-time-
|
|
53
|
+
} @media (max-width: 374px) { .date-time-input__calendarContainer_unkuq {
|
|
54
54
|
width: 100%;
|
|
55
55
|
min-width: 288px
|
|
56
56
|
}
|
|
57
|
-
} .date-time-
|
|
57
|
+
} .date-time-input__calendarResponsive_unkuq {
|
|
58
58
|
width: var(--calendar-width);
|
|
59
|
-
} .date-time-
|
|
59
|
+
} .date-time-input__block_unkuq {
|
|
60
60
|
width: 100%;
|
|
61
|
-
} .date-time-
|
|
61
|
+
} .date-time-input__calendarIcon_unkuq {
|
|
62
62
|
margin-right: var(--gap-s-neg);
|
|
63
63
|
height: 100%;
|
|
64
64
|
}
|
|
@@ -92,6 +92,10 @@ type DateTimeInputProps = Omit<InputProps, 'onChange'> & {
|
|
|
92
92
|
* Отображение компонента в мобильном или десктопном виде
|
|
93
93
|
*/
|
|
94
94
|
view?: 'desktop' | 'mobile';
|
|
95
|
+
/**
|
|
96
|
+
* Запретить ввод с клавиатуры
|
|
97
|
+
*/
|
|
98
|
+
disableUserInput?: boolean;
|
|
95
99
|
};
|
|
96
100
|
declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
|
|
97
101
|
/**
|
|
@@ -133,8 +137,12 @@ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "o
|
|
|
133
137
|
*/
|
|
134
138
|
calendarProps?: (CalendarProps & Record<string, unknown>) | (CalendarProps & {
|
|
135
139
|
open: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Дополнительный класс для поповера
|
|
142
|
+
*/
|
|
136
143
|
title?: string | undefined;
|
|
137
144
|
onClose?: (() => void) | undefined;
|
|
145
|
+
onMonthTitleClick?: ((event: React.MouseEvent<HTMLSpanElement, globalThis.MouseEvent>) => void) | undefined;
|
|
138
146
|
yearsAmount?: number | undefined;
|
|
139
147
|
hasHeader?: boolean | undefined;
|
|
140
148
|
allowSelectionFromEmptyRange?: boolean | undefined;
|
|
@@ -188,5 +196,9 @@ declare const DateTimeInput: React.ForwardRefExoticComponent<Omit<InputProps, "o
|
|
|
188
196
|
* Отображение компонента в мобильном или десктопном виде
|
|
189
197
|
*/
|
|
190
198
|
view?: "mobile" | "desktop" | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Запретить ввод с клавиатуры
|
|
201
|
+
*/
|
|
202
|
+
disableUserInput?: boolean | undefined;
|
|
191
203
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
192
204
|
export { DateTimeInputProps, DateTimeInput };
|
|
@@ -11,11 +11,11 @@ import { getDateWithoutTime, DATE_WITH_TIME_LENGTH, format, getFullDateTime, isC
|
|
|
11
11
|
import 'date-fns/isValid';
|
|
12
12
|
import 'date-fns/parse';
|
|
13
13
|
|
|
14
|
-
const styles = {"component":"date-time-
|
|
14
|
+
const styles = {"component":"date-time-input__component_unkuq","calendarContainer":"date-time-input__calendarContainer_unkuq","calendarResponsive":"date-time-input__calendarResponsive_unkuq","block":"date-time-input__block_unkuq","calendarIcon":"date-time-input__calendarIcon_unkuq"};
|
|
15
15
|
require('./index.css')
|
|
16
16
|
|
|
17
17
|
/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
|
|
18
|
-
const DateTimeInput = 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, error, view = 'desktop', ...restProps }, ref) => {
|
|
18
|
+
const DateTimeInput = React.forwardRef(({ className, inputClassName, popoverClassName, disabled, readOnly, disableUserInput = false, 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, error, view = 'desktop', ...restProps }, ref) => {
|
|
19
19
|
const inputRef = useRef(null);
|
|
20
20
|
const calendarRef = useRef(null);
|
|
21
21
|
const [value, setValue] = useState(propValue || defaultValue);
|
|
@@ -107,6 +107,12 @@ const DateTimeInput = React.forwardRef(({ className, inputClassName, popoverClas
|
|
|
107
107
|
const handleClear = () => {
|
|
108
108
|
setValue('');
|
|
109
109
|
};
|
|
110
|
+
const handleInputKeyDown = (event) => {
|
|
111
|
+
const isCopy = (event.metaKey || event.ctrlKey) && event.key === 'c';
|
|
112
|
+
if (disableUserInput && !isCopy) {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
110
116
|
const handleCalendarChange = (date) => {
|
|
111
117
|
if (date) {
|
|
112
118
|
const newValue = parseTimestampToDate(date);
|
|
@@ -132,7 +138,7 @@ const DateTimeInput = React.forwardRef(({ className, inputClassName, popoverClas
|
|
|
132
138
|
return (React.createElement("div", { className: cn(styles.component, className, {
|
|
133
139
|
[styles.block]: block,
|
|
134
140
|
}), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
135
|
-
React.createElement(Input, { ...restProps, block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, error: error, rightAddons: React.createElement(React.Fragment, null,
|
|
141
|
+
React.createElement(Input, { ...restProps, block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, onKeyDown: handleInputKeyDown, error: error, rightAddons: React.createElement(React.Fragment, null,
|
|
136
142
|
rightAddons,
|
|
137
143
|
picker && (React.createElement(IconButton, { className: styles.calendarIcon, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 's' }))) }),
|
|
138
144
|
picker && (React.createElement(Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn(styles.calendarContainer, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1gt4g */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-border-secondary: #e9e9eb; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -41,24 +41,24 @@
|
|
|
41
41
|
/* marker */
|
|
42
42
|
} :root {
|
|
43
43
|
--calendar-popover-border-radius: var(--border-radius-m);
|
|
44
|
-
} .date-time-
|
|
44
|
+
} .date-time-input__component_unkuq {
|
|
45
45
|
display: inline-block;
|
|
46
46
|
outline: none;
|
|
47
47
|
position: relative;
|
|
48
|
-
} .date-time-
|
|
48
|
+
} .date-time-input__calendarContainer_unkuq {
|
|
49
49
|
display: inline-block;
|
|
50
50
|
box-sizing: border-box;
|
|
51
51
|
border-radius: var(--calendar-popover-border-radius);
|
|
52
52
|
border: 1px solid var(--color-light-border-secondary)
|
|
53
|
-
} @media (max-width: 374px) { .date-time-
|
|
53
|
+
} @media (max-width: 374px) { .date-time-input__calendarContainer_unkuq {
|
|
54
54
|
width: 100%;
|
|
55
55
|
min-width: 288px
|
|
56
56
|
}
|
|
57
|
-
} .date-time-
|
|
57
|
+
} .date-time-input__calendarResponsive_unkuq {
|
|
58
58
|
width: var(--calendar-width);
|
|
59
|
-
} .date-time-
|
|
59
|
+
} .date-time-input__block_unkuq {
|
|
60
60
|
width: 100%;
|
|
61
|
-
} .date-time-
|
|
61
|
+
} .date-time-input__calendarIcon_unkuq {
|
|
62
62
|
margin-right: var(--gap-s-neg);
|
|
63
63
|
height: 100%;
|
|
64
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-date-time-input",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@alfalab/core-components-calendar": "^6.
|
|
19
|
-
"@alfalab/core-components-input": "^11.1.
|
|
20
|
-
"@alfalab/core-components-icon-button": "^6.1.
|
|
21
|
-
"@alfalab/core-components-popover": "^6.0.
|
|
18
|
+
"@alfalab/core-components-calendar": "^6.6.1",
|
|
19
|
+
"@alfalab/core-components-input": "^11.1.18",
|
|
20
|
+
"@alfalab/core-components-icon-button": "^6.1.3",
|
|
21
|
+
"@alfalab/core-components-popover": "^6.0.9",
|
|
22
22
|
"@alfalab/hooks": "^1.13.0",
|
|
23
23
|
"classnames": "^2.3.1",
|
|
24
24
|
"tslib": "^2.4.0"
|
package/send-stats.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
const http = require('http');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const { promisify } = require('util');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
const readFile = promisify(fs.readFile);
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
const remoteHost = process.env.NIS_HOST || 'digital';
|
|
10
|
-
const remotePort = process.env.NIS_PORT || 80;
|
|
11
|
-
const remotePath = process.env.NIS_PATH || '/npm-install-stats/api/install-stats';
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const [_, node, os, arch] =
|
|
15
|
-
/node\/v(\d+\.\d+\.\d+) (\w+) (\w+)/.exec(process.env.npm_config_user_agent) || [];
|
|
16
|
-
const [__, npm] = /npm\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
|
|
17
|
-
const [___, yarn] = /yarn\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
|
|
18
|
-
|
|
19
|
-
let ownPackageJson, packageJson;
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const result = await Promise.all([
|
|
23
|
-
readFile(path.join(process.cwd(), 'package.json'), 'utf-8'),
|
|
24
|
-
readFile(path.join(process.cwd(), '../../../package.json'), 'utf-8'),
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
ownPackageJson = JSON.parse(result[0]);
|
|
28
|
-
packageJson = JSON.parse(result[1]);
|
|
29
|
-
} catch (err) {
|
|
30
|
-
ownPackageJson = '';
|
|
31
|
-
packageJson = '';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const data = {
|
|
35
|
-
node,
|
|
36
|
-
npm,
|
|
37
|
-
yarn,
|
|
38
|
-
os,
|
|
39
|
-
arch,
|
|
40
|
-
ownPackageJson: JSON.stringify(ownPackageJson),
|
|
41
|
-
packageJson: JSON.stringify(packageJson),
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const body = JSON.stringify(data);
|
|
45
|
-
|
|
46
|
-
const options = {
|
|
47
|
-
host: remoteHost,
|
|
48
|
-
port: remotePort,
|
|
49
|
-
path: remotePath,
|
|
50
|
-
method: 'POST',
|
|
51
|
-
headers: {
|
|
52
|
-
'Content-Type': 'application/json',
|
|
53
|
-
'Content-Length': body.length,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return new Promise((resolve, reject) => {
|
|
58
|
-
const req = http.request(options, (res) => {
|
|
59
|
-
res.on('end', () => {
|
|
60
|
-
resolve();
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
req.on('error', () => {
|
|
65
|
-
reject();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
req.write(body);
|
|
69
|
-
req.end();
|
|
70
|
-
});
|
|
71
|
-
} catch (error) {
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
main()
|
|
77
|
-
.then(() => {
|
|
78
|
-
process.exit(0);
|
|
79
|
-
})
|
|
80
|
-
.catch(() => {
|
|
81
|
-
process.exit(0);
|
|
82
|
-
});
|