intelicoreact 0.0.91 → 0.0.94
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/dist/Atomic/FormElements/Dropdown/Dropdown.js +3 -2
- package/dist/Atomic/FormElements/Dropdown/Dropdown.scss +6 -0
- package/dist/Atomic/FormElements/Dropdown/Dropdown.stories.js +1 -0
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +3 -2
- package/dist/Atomic/FormElements/Dropdown/components/{Loader.scss → DropdownLoader.scss} +0 -0
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +17 -5
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.scss +23 -0
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +28 -5
- package/dist/Atomic/UI/Calendar/Calendar.js +90 -16
- package/dist/Atomic/UI/Calendar/Calendar.scss +73 -26
- package/dist/Atomic/UI/Calendar/Calendar.stories.js +20 -3
- package/package.json +1 -1
- package/src/Atomic/FormElements/Dropdown/Dropdown.js +8 -2
- package/src/Atomic/FormElements/Dropdown/Dropdown.scss +6 -0
- package/src/Atomic/FormElements/Dropdown/Dropdown.stories.js +1 -0
- package/src/Atomic/FormElements/Dropdown/components/DropdownLoader.js +2 -2
- package/src/Atomic/FormElements/Dropdown/components/{Loader.scss → DropdownLoader.scss} +0 -0
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +38 -9
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.scss +23 -0
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +19 -10
- package/src/Atomic/UI/Calendar/Calendar.js +82 -11
- package/src/Atomic/UI/Calendar/Calendar.scss +73 -26
- package/src/Atomic/UI/Calendar/Calendar.stories.js +9 -7
|
@@ -50,7 +50,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
50
50
|
className = _ref.className,
|
|
51
51
|
isSearchable = _ref.isSearchable,
|
|
52
52
|
entity = _ref.entity,
|
|
53
|
-
scrollReactionObj = _ref.scrollReactionObj
|
|
53
|
+
scrollReactionObj = _ref.scrollReactionObj,
|
|
54
|
+
isListTop = _ref.isListTop;
|
|
54
55
|
|
|
55
56
|
var _useState = (0, _react.useState)(false),
|
|
56
57
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -235,7 +236,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
235
236
|
return setIsOpen(!isOpen);
|
|
236
237
|
}
|
|
237
238
|
}, isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen && filteredOptions.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
238
|
-
className: "".concat(RC, "__list"),
|
|
239
|
+
className: (0, _classnames.default)("".concat(RC, "__list"), (0, _defineProperty2.default)({}, "".concat(RC, "__list-top"), isListTop)),
|
|
239
240
|
ref: dropdownListRef
|
|
240
241
|
}, depend.options.map(function (filteredOption) {
|
|
241
242
|
var _filteredOption$items2;
|
|
@@ -102,6 +102,7 @@ var Template = function Template(args) {
|
|
|
102
102
|
var DropdownTemplate = Template.bind({});
|
|
103
103
|
exports.DropdownTemplate = DropdownTemplate;
|
|
104
104
|
DropdownTemplate.args = {
|
|
105
|
+
// isListTop: true,
|
|
105
106
|
entity: 'entity',
|
|
106
107
|
value: 'drop6',
|
|
107
108
|
placeholder: 'Placeholder',
|
|
@@ -9,9 +9,10 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
-
require("./
|
|
12
|
+
require("./DropdownLoader.scss");
|
|
13
13
|
|
|
14
|
-
var DropdownLoader = function DropdownLoader() {
|
|
14
|
+
var DropdownLoader = function DropdownLoader(_ref) {
|
|
15
|
+
var variant = _ref.variant;
|
|
15
16
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
16
17
|
className: "dropdown-loader-box j5"
|
|
17
18
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
File without changes
|
|
@@ -17,10 +17,14 @@ var _moment = _interopRequireDefault(require("moment"));
|
|
|
17
17
|
|
|
18
18
|
var _reactInputMask = _interopRequireDefault(require("react-input-mask"));
|
|
19
19
|
|
|
20
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
21
|
+
|
|
20
22
|
var _Calendar = _interopRequireDefault(require("../../UI/Calendar/Calendar"));
|
|
21
23
|
|
|
22
24
|
var _useClickOutside = require("../../../Functions/useClickOutside");
|
|
23
25
|
|
|
26
|
+
require("./InputCalendar.scss");
|
|
27
|
+
|
|
24
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
29
|
|
|
26
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -35,7 +39,10 @@ var InputCalendar = function InputCalendar(_ref) {
|
|
|
35
39
|
_ref$placeholder = _ref.placeholder,
|
|
36
40
|
placeholder = _ref$placeholder === void 0 ? 'mm/dd/yyyy' : _ref$placeholder,
|
|
37
41
|
_ref$mask = _ref.mask,
|
|
38
|
-
mask = _ref$mask === void 0 ? '99/99/9999' : _ref$mask
|
|
42
|
+
mask = _ref$mask === void 0 ? '99/99/9999' : _ref$mask,
|
|
43
|
+
isDontLimitFuture = _ref.isDontLimitFuture,
|
|
44
|
+
isListTop = _ref.isListTop,
|
|
45
|
+
disabled = _ref.disabled;
|
|
39
46
|
|
|
40
47
|
var _useState = (0, _react.useState)(false),
|
|
41
48
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -57,12 +64,14 @@ var InputCalendar = function InputCalendar(_ref) {
|
|
|
57
64
|
|
|
58
65
|
var getCalendarValue = function getCalendarValue(value) {
|
|
59
66
|
var date = (0, _moment.default)(value).format('L');
|
|
60
|
-
if (date !==
|
|
67
|
+
if (date !== 'Invalid date') return date;
|
|
61
68
|
return (0, _moment.default)(new Date()).format('L');
|
|
62
69
|
};
|
|
63
70
|
|
|
64
71
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
65
|
-
className:
|
|
72
|
+
className: (0, _classnames.default)('input__wrap calendar-container', className, {
|
|
73
|
+
'calendar-container_disabled': disabled
|
|
74
|
+
}),
|
|
66
75
|
ref: calendarRef
|
|
67
76
|
}, /*#__PURE__*/_react.default.createElement(_reactInputMask.default, {
|
|
68
77
|
mask: mask,
|
|
@@ -73,7 +82,7 @@ var InputCalendar = function InputCalendar(_ref) {
|
|
|
73
82
|
},
|
|
74
83
|
className: "calendar-dropdown",
|
|
75
84
|
onFocus: function onFocus() {
|
|
76
|
-
return setIsOpened(
|
|
85
|
+
return setIsOpened(true);
|
|
77
86
|
}
|
|
78
87
|
}), isOpened ? /*#__PURE__*/_react.default.createElement(_Calendar.default, {
|
|
79
88
|
date: getCalendarValue(value),
|
|
@@ -83,7 +92,10 @@ var InputCalendar = function InputCalendar(_ref) {
|
|
|
83
92
|
params: {
|
|
84
93
|
minDate: minDate,
|
|
85
94
|
maxDate: maxDate
|
|
86
|
-
}
|
|
95
|
+
},
|
|
96
|
+
isDontLimitFuture: isDontLimitFuture,
|
|
97
|
+
isListTop: isListTop,
|
|
98
|
+
setIsOpened: setIsOpened
|
|
87
99
|
}) : null);
|
|
88
100
|
};
|
|
89
101
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.calendar-container {
|
|
2
|
+
min-width: 200px;
|
|
3
|
+
position: relative;
|
|
4
|
+
|
|
5
|
+
&_disabled {
|
|
6
|
+
pointer-events: none;
|
|
7
|
+
opacity: 0.5;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.calendar {
|
|
11
|
+
position: absolute;
|
|
12
|
+
z-index: 9;
|
|
13
|
+
top: 100%;
|
|
14
|
+
padding: 10px 16px;
|
|
15
|
+
border: 1px solid var(--border-color);
|
|
16
|
+
|
|
17
|
+
&_list-top {
|
|
18
|
+
bottom: calc(100% + 4px);
|
|
19
|
+
top: auto;
|
|
20
|
+
box-shadow: 0 -3px 15px rgb(0 0 0 / 15%);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -39,18 +39,41 @@ var Template = function Template(args) {
|
|
|
39
39
|
date = _useState2[0],
|
|
40
40
|
setDate = _useState2[1];
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
var _useState3 = (0, _react.useState)(false),
|
|
43
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
44
|
+
disabled = _useState4[0],
|
|
45
|
+
setDisabled = _useState4[1];
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_InputCalendar.default, (0, _extends2.default)({}, args, {
|
|
43
48
|
value: date,
|
|
44
49
|
onChange: function onChange(val) {
|
|
45
50
|
return setDate(val);
|
|
51
|
+
},
|
|
52
|
+
disabled: disabled
|
|
53
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
54
|
+
style: {
|
|
55
|
+
display: 'flex',
|
|
56
|
+
flexFlow: 'row nowrap',
|
|
57
|
+
justifyContent: 'flex-end',
|
|
58
|
+
marginTop: '10px'
|
|
59
|
+
}
|
|
60
|
+
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
61
|
+
style: {
|
|
62
|
+
border: 'solid 1px black',
|
|
63
|
+
padding: '10px',
|
|
64
|
+
width: '80px'
|
|
65
|
+
},
|
|
66
|
+
onClick: function onClick() {
|
|
67
|
+
return setDisabled(!disabled);
|
|
46
68
|
}
|
|
47
|
-
}));
|
|
69
|
+
}, disabled ? 'Enable' : 'Disable')));
|
|
48
70
|
};
|
|
49
71
|
|
|
50
72
|
var CalendarTemplate = Template.bind({});
|
|
51
73
|
exports.CalendarTemplate = CalendarTemplate;
|
|
52
74
|
CalendarTemplate.args = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
75
|
+
minDate: '01/01/1900',
|
|
76
|
+
maxDate: '01/01/2100',
|
|
77
|
+
isDontLimitFuture: true // isListTop: true,
|
|
78
|
+
|
|
56
79
|
};
|
|
@@ -13,12 +13,14 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
13
13
|
|
|
14
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
15
|
|
|
16
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
-
|
|
18
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
17
|
|
|
18
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
|
+
|
|
20
20
|
var _moment = _interopRequireDefault(require("moment"));
|
|
21
21
|
|
|
22
|
+
var _reactInputMask = _interopRequireDefault(require("react-input-mask"));
|
|
23
|
+
|
|
22
24
|
var _reactFeather = require("react-feather");
|
|
23
25
|
|
|
24
26
|
require("./Calendar.scss");
|
|
@@ -30,16 +32,18 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
30
32
|
function _default(props) {
|
|
31
33
|
var date = props.date,
|
|
32
34
|
setDate = props.setDate,
|
|
35
|
+
setIsOpened = props.setIsOpened,
|
|
33
36
|
_props$allowPrev = props.allowPrev,
|
|
34
37
|
allowPrev = _props$allowPrev === void 0 ? true : _props$allowPrev,
|
|
35
38
|
_props$allowNext = props.allowNext,
|
|
36
39
|
allowNext = _props$allowNext === void 0 ? true : _props$allowNext,
|
|
37
40
|
params = props.params,
|
|
38
|
-
className = props.className
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
className = props.className,
|
|
42
|
+
isDontLimitFuture = props.isDontLimitFuture,
|
|
43
|
+
isListTop = props.isListTop; // const { minDate = '01/01/1900', maxDate = moment().format('MM/DD/YYYY') } = params;
|
|
44
|
+
|
|
45
|
+
var minDate = params.minDate,
|
|
46
|
+
maxDate = params.maxDate;
|
|
43
47
|
|
|
44
48
|
var _useState = (0, _react.useState)({}),
|
|
45
49
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -51,10 +55,28 @@ function _default(props) {
|
|
|
51
55
|
showDate = _useState4[0],
|
|
52
56
|
setShowDate = _useState4[1];
|
|
53
57
|
|
|
58
|
+
var _useState5 = (0, _react.useState)(false),
|
|
59
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
60
|
+
isChangeYear = _useState6[0],
|
|
61
|
+
setIsChangeYear = _useState6[1];
|
|
62
|
+
|
|
63
|
+
var _useState7 = (0, _react.useState)((0, _moment.default)(showDate).format('YYYY')),
|
|
64
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
65
|
+
inputYearValue = _useState8[0],
|
|
66
|
+
setInputYearValue = _useState8[1];
|
|
67
|
+
|
|
68
|
+
var yearInputRef = (0, _react.useRef)(null);
|
|
54
69
|
var selectedDay = (0, _moment.default)(showDate);
|
|
55
|
-
var isError = 'Invalid date';
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
var isError = 'Invalid date'; // const title = useMemo(
|
|
71
|
+
// () => (selectedDay.format('MMM') === isError ? isError : `${selectedDay.format('MMM')} ${moment(showDate).format('YYYY')}`),
|
|
72
|
+
// [date, showDate]
|
|
73
|
+
// );
|
|
74
|
+
|
|
75
|
+
var showMonth = (0, _react.useMemo)(function () {
|
|
76
|
+
return (0, _moment.default)(showDate).format('MMM');
|
|
77
|
+
}, [date, showDate]);
|
|
78
|
+
var showYear = (0, _react.useMemo)(function () {
|
|
79
|
+
return (0, _moment.default)(showDate).format('YYYY');
|
|
58
80
|
}, [date, showDate]);
|
|
59
81
|
(0, _react.useEffect)(function () {
|
|
60
82
|
var result = {};
|
|
@@ -89,7 +111,7 @@ function _default(props) {
|
|
|
89
111
|
var classNames = (0, _classnames.default)('calendar__day', {
|
|
90
112
|
'calendar__day--clickable': day
|
|
91
113
|
}, {
|
|
92
|
-
'calendar__day--disabled': isFutureDay
|
|
114
|
+
'calendar__day--disabled': !isDontLimitFuture && isFutureDay
|
|
93
115
|
}, {
|
|
94
116
|
'calendar__day--disabled': isBeforeDay
|
|
95
117
|
}, {
|
|
@@ -98,8 +120,9 @@ function _default(props) {
|
|
|
98
120
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
99
121
|
key: "".concat(week, "_").concat(dayOfWeek),
|
|
100
122
|
className: classNames,
|
|
101
|
-
onClick: day && !isFutureDay ? function () {
|
|
102
|
-
|
|
123
|
+
onClick: day && (isDontLimitFuture || !isFutureDay) ? function () {
|
|
124
|
+
setDate((0, _moment.default)(day.date).format('L'));
|
|
125
|
+
setIsOpened(false);
|
|
103
126
|
} : null // onMouseOver={day && !isFutureDay ? () => onHover(day.date) : null}
|
|
104
127
|
// onMouseLeave={() => onHover(null)}
|
|
105
128
|
|
|
@@ -114,8 +137,35 @@ function _default(props) {
|
|
|
114
137
|
setShowDate((0, _moment.default)(showDate).add(1, 'month').format('L'));
|
|
115
138
|
};
|
|
116
139
|
|
|
140
|
+
var closeYearInput = function closeYearInput() {
|
|
141
|
+
var newDate = function () {
|
|
142
|
+
var dateArr = showDate.split('/');
|
|
143
|
+
var oldYear = dateArr[2];
|
|
144
|
+
dateArr[2] = inputYearValue;
|
|
145
|
+
return (0, _moment.default)(dateArr.join('/')).format('MM/DD/YYYY') === isError ? showDate : (0, _moment.default)(dateArr.join('/')).format('MM/DD/YYYY');
|
|
146
|
+
}();
|
|
147
|
+
|
|
148
|
+
var resultDate = newDate;
|
|
149
|
+
if (minDate && (0, _moment.default)(minDate) > (0, _moment.default)(newDate)) resultDate = (0, _moment.default)(showDate).format('MM/DD/YYYY');else if (maxDate && (0, _moment.default)(maxDate) < (0, _moment.default)(newDate)) resultDate = (0, _moment.default)(showDate).format('MM/DD/YYYY');
|
|
150
|
+
setIsChangeYear(false);
|
|
151
|
+
setShowDate(resultDate);
|
|
152
|
+
setInputYearValue(resultDate);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
(0, _react.useEffect)(function () {
|
|
156
|
+
if (isChangeYear && yearInputRef.current) {
|
|
157
|
+
var input = yearInputRef.current.getElementsByTagName('input')[0];
|
|
158
|
+
setInputYearValue(showYear);
|
|
159
|
+
setTimeout(function () {
|
|
160
|
+
input.focus();
|
|
161
|
+
input.select();
|
|
162
|
+
}, 0);
|
|
163
|
+
}
|
|
164
|
+
}, [isChangeYear]);
|
|
117
165
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
118
|
-
className:
|
|
166
|
+
className: (0, _classnames.default)('calendar', className, {
|
|
167
|
+
'calendar_list-top': isListTop
|
|
168
|
+
})
|
|
119
169
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
120
170
|
className: "calendar-header"
|
|
121
171
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -123,8 +173,32 @@ function _default(props) {
|
|
|
123
173
|
}, allowPrev && /*#__PURE__*/_react.default.createElement("div", {
|
|
124
174
|
onClick: handlePrev
|
|
125
175
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronLeft, null))), /*#__PURE__*/_react.default.createElement("div", {
|
|
126
|
-
className:
|
|
127
|
-
|
|
176
|
+
className: (0, _classnames.default)('calendar-header__title'),
|
|
177
|
+
ref: yearInputRef
|
|
178
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
179
|
+
className: "calendar-header__title-month"
|
|
180
|
+
}, "".concat(showMonth, " ")), /*#__PURE__*/_react.default.createElement("span", {
|
|
181
|
+
className: (0, _classnames.default)('calendar-header__title-year', {
|
|
182
|
+
'calendar-header__title-year_change-mode': isChangeYear
|
|
183
|
+
}),
|
|
184
|
+
onClick: function onClick() {
|
|
185
|
+
return setIsChangeYear(true);
|
|
186
|
+
}
|
|
187
|
+
}, isChangeYear ? /*#__PURE__*/_react.default.createElement(_reactInputMask.default, {
|
|
188
|
+
className: "calendar-header__title-year-change-input",
|
|
189
|
+
value: inputYearValue,
|
|
190
|
+
mask: "9999",
|
|
191
|
+
onBlur: function onBlur(e) {
|
|
192
|
+
return closeYearInput();
|
|
193
|
+
},
|
|
194
|
+
onKeyUp: function onKeyUp(e) {
|
|
195
|
+
if (e.key === 'Escape') setIsChangeYear(false);
|
|
196
|
+
if (e.key === 'Enter') closeYearInput();
|
|
197
|
+
},
|
|
198
|
+
onChange: function onChange(e) {
|
|
199
|
+
return setInputYearValue(e.target.value);
|
|
200
|
+
}
|
|
201
|
+
}) : "".concat(showYear))), /*#__PURE__*/_react.default.createElement("div", {
|
|
128
202
|
className: "calendar-header__next"
|
|
129
203
|
}, allowNext && /*#__PURE__*/_react.default.createElement("div", {
|
|
130
204
|
onClick: handleNext
|
|
@@ -425,23 +425,25 @@
|
|
|
425
425
|
// box-shadow: 0 0 3px 0 rgb(0 123 255 / 50%);
|
|
426
426
|
// }
|
|
427
427
|
// }
|
|
428
|
-
.calendar-header {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
428
|
+
// .calendar-header {
|
|
429
|
+
// display: flex;
|
|
430
|
+
// justify-content: center;
|
|
431
|
+
// align-items: center;
|
|
432
|
+
|
|
433
|
+
// &__prev,
|
|
434
|
+
// &__next {
|
|
435
|
+
// display: flex;
|
|
436
|
+
// height: auto;
|
|
437
|
+
// cursor: pointer;
|
|
438
|
+
// }
|
|
439
|
+
// }
|
|
432
440
|
|
|
433
|
-
&__prev,
|
|
434
|
-
&__next{
|
|
435
|
-
display: flex;
|
|
436
|
-
height: auto;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
441
|
.calendar {
|
|
440
442
|
background: #ffffff;
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
443
|
+
border: 1px solid #e2e5ec;
|
|
444
|
+
box-shadow: 0 5px 20px rgb(0 0 0 / 15%);
|
|
445
|
+
margin-top: 4px;
|
|
446
|
+
padding: 5px 0;
|
|
445
447
|
|
|
446
448
|
min-height: 195px;
|
|
447
449
|
width: 260px;
|
|
@@ -449,6 +451,63 @@
|
|
|
449
451
|
flex-direction: column;
|
|
450
452
|
user-select: none;
|
|
451
453
|
|
|
454
|
+
&-header {
|
|
455
|
+
display: flex;
|
|
456
|
+
justify-content: center;
|
|
457
|
+
align-items: center;
|
|
458
|
+
|
|
459
|
+
box-sizing: border-box;
|
|
460
|
+
&__title {
|
|
461
|
+
&-month {
|
|
462
|
+
margin-right: 5px;
|
|
463
|
+
}
|
|
464
|
+
&-year {
|
|
465
|
+
box-sizing: border-box;
|
|
466
|
+
width: 45px;
|
|
467
|
+
height: 100%;
|
|
468
|
+
padding: 0 5px;
|
|
469
|
+
cursor: pointer;
|
|
470
|
+
display: flex;
|
|
471
|
+
flex-flow: row nowrap;
|
|
472
|
+
justify-content: center;
|
|
473
|
+
align-items: center;
|
|
474
|
+
|
|
475
|
+
&:hover:not(.calendar-header__title-year_change-mode) {
|
|
476
|
+
text-decoration: underline;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
&.calendar-header__title-year_change-mode {
|
|
480
|
+
height: 24px;
|
|
481
|
+
padding: 0 3px;
|
|
482
|
+
border-style: solid;
|
|
483
|
+
border-width: 1px;
|
|
484
|
+
border-color: inherit;
|
|
485
|
+
border-radius: var(--border-radius);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
&-change-input {
|
|
489
|
+
box-sizing: border-box;
|
|
490
|
+
width: 100%;
|
|
491
|
+
border: none;
|
|
492
|
+
outline: none;
|
|
493
|
+
margin: 0;
|
|
494
|
+
padding: 0;
|
|
495
|
+
display: inline;
|
|
496
|
+
font-size: inherit;
|
|
497
|
+
line-height: inherit;
|
|
498
|
+
font-weight: inherit;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
&__prev,
|
|
504
|
+
&__next {
|
|
505
|
+
display: flex;
|
|
506
|
+
height: auto;
|
|
507
|
+
cursor: pointer;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
452
511
|
&__week {
|
|
453
512
|
display: flex;
|
|
454
513
|
}
|
|
@@ -516,18 +575,6 @@
|
|
|
516
575
|
}
|
|
517
576
|
}
|
|
518
577
|
|
|
519
|
-
&-container {
|
|
520
|
-
min-width: 200px;
|
|
521
|
-
position: relative;
|
|
522
|
-
.calendar {
|
|
523
|
-
position: absolute;
|
|
524
|
-
z-index: 9;
|
|
525
|
-
top: 100%;
|
|
526
|
-
padding: 10px 16px;
|
|
527
|
-
border: 1px solid var(--border-color);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
578
|
&-dropdown {
|
|
532
579
|
appearance: none;
|
|
533
580
|
background-color: white;
|
|
@@ -2,15 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports.CalendarTemplate = exports.default = void 0;
|
|
9
11
|
|
|
10
|
-
var
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
17
|
|
|
12
18
|
var _Calendar = _interopRequireDefault(require("./Calendar"));
|
|
13
19
|
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
|
|
14
24
|
global.lng = 'en';
|
|
15
25
|
var _default = {
|
|
16
26
|
title: 'Calendar',
|
|
@@ -19,17 +29,24 @@ var _default = {
|
|
|
19
29
|
exports.default = _default;
|
|
20
30
|
|
|
21
31
|
var Template = function Template(args) {
|
|
32
|
+
var _useState = (0, _react.useState)('12/03/2021'),
|
|
33
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
34
|
+
date = _useState2[0],
|
|
35
|
+
setDate = _useState2[1];
|
|
36
|
+
|
|
22
37
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
23
38
|
style: {
|
|
24
39
|
width: '320px'
|
|
25
40
|
}
|
|
26
|
-
}, /*#__PURE__*/_react.default.createElement(_Calendar.default, args
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement(_Calendar.default, (0, _extends2.default)({}, args, {
|
|
42
|
+
date: date,
|
|
43
|
+
setDate: setDate
|
|
44
|
+
})));
|
|
27
45
|
};
|
|
28
46
|
|
|
29
47
|
var CalendarTemplate = Template.bind({});
|
|
30
48
|
exports.CalendarTemplate = CalendarTemplate;
|
|
31
49
|
CalendarTemplate.args = {
|
|
32
|
-
date: '12/03/2021',
|
|
33
50
|
params: {},
|
|
34
51
|
setDate: function setDate() {
|
|
35
52
|
return null;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ import './Dropdown.scss';
|
|
|
8
8
|
|
|
9
9
|
const RC = 'dropdown';
|
|
10
10
|
|
|
11
|
-
const Dropdown = ({ options = [], value, error, disabled, onChange, placeholder, className, isSearchable, entity, scrollReactionObj }) => {
|
|
11
|
+
const Dropdown = ({ options = [], value, error, disabled, onChange, placeholder, className, isSearchable, entity, scrollReactionObj, isListTop }) => {
|
|
12
12
|
const [isOpen, setIsOpen] = useState(false);
|
|
13
13
|
const [searchValue, setSearchValue] = useState();
|
|
14
14
|
const dropdownRef = useRef(null);
|
|
@@ -157,8 +157,14 @@ const Dropdown = ({ options = [], value, error, disabled, onChange, placeholder,
|
|
|
157
157
|
{isOpen ? <ChevronUp /> : <ChevronDown />}
|
|
158
158
|
</span>
|
|
159
159
|
</button>
|
|
160
|
+
|
|
160
161
|
{isOpen && filteredOptions.length > 0 && (
|
|
161
|
-
<div
|
|
162
|
+
<div
|
|
163
|
+
className={cn(`${RC}__list`, {
|
|
164
|
+
[`${RC}__list-top`]: isListTop,
|
|
165
|
+
})}
|
|
166
|
+
ref={dropdownListRef}
|
|
167
|
+
>
|
|
162
168
|
{depend.options.map((filteredOption) =>
|
|
163
169
|
filteredOption.items?.length ? filteredOptionList(filteredOption) : getMarkupForElement(filteredOption)
|
|
164
170
|
)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import './
|
|
2
|
+
import './DropdownLoader.scss';
|
|
3
3
|
|
|
4
|
-
const DropdownLoader = function () {
|
|
4
|
+
const DropdownLoader = function ({ variant }) {
|
|
5
5
|
return (
|
|
6
6
|
<div className="dropdown-loader-box j5">
|
|
7
7
|
<div className={`lds-ring${variant === 'little' ? ' lds-ring_little' : ''}`}>
|
|
File without changes
|
|
@@ -1,42 +1,71 @@
|
|
|
1
1
|
import React, { useState, useRef } from 'react';
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
import InputMask from 'react-input-mask';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
|
|
4
6
|
import Calendar from '../../UI/Calendar/Calendar';
|
|
5
7
|
import { useClickOutside } from '../../../Functions/useClickOutside';
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
import './InputCalendar.scss';
|
|
10
|
+
|
|
11
|
+
const InputCalendar = ({
|
|
12
|
+
value,
|
|
13
|
+
minDate,
|
|
14
|
+
maxDate,
|
|
15
|
+
onChange,
|
|
16
|
+
className = '',
|
|
17
|
+
placeholder = 'mm/dd/yyyy',
|
|
18
|
+
mask = '99/99/9999',
|
|
19
|
+
isDontLimitFuture,
|
|
20
|
+
isListTop,
|
|
21
|
+
disabled,
|
|
22
|
+
}) => {
|
|
8
23
|
const [isOpened, setIsOpened] = useState(false);
|
|
9
24
|
const calendarRef = useRef(null);
|
|
10
25
|
|
|
11
26
|
useClickOutside(calendarRef, () => setIsOpened(false));
|
|
12
27
|
|
|
13
|
-
const changeInputValue = val => {
|
|
28
|
+
const changeInputValue = (val) => {
|
|
14
29
|
if (onChange) onChange(val);
|
|
15
30
|
};
|
|
16
31
|
|
|
17
|
-
const changeCalendarDay = val => {
|
|
32
|
+
const changeCalendarDay = (val) => {
|
|
18
33
|
if (onChange) onChange(val);
|
|
19
34
|
};
|
|
20
35
|
|
|
21
36
|
const getCalendarValue = (value) => {
|
|
22
37
|
const date = moment(value).format('L');
|
|
23
38
|
|
|
24
|
-
if(date !==
|
|
39
|
+
if (date !== 'Invalid date') return date;
|
|
25
40
|
|
|
26
41
|
return moment(new Date()).format('L');
|
|
27
|
-
}
|
|
42
|
+
};
|
|
28
43
|
|
|
29
44
|
return (
|
|
30
|
-
<div
|
|
45
|
+
<div
|
|
46
|
+
className={cn('input__wrap calendar-container', className, {
|
|
47
|
+
'calendar-container_disabled': disabled,
|
|
48
|
+
})}
|
|
49
|
+
ref={calendarRef}
|
|
50
|
+
>
|
|
31
51
|
<InputMask
|
|
32
52
|
mask={mask}
|
|
33
53
|
placeholder={placeholder}
|
|
34
54
|
value={value}
|
|
35
|
-
onChange={e => changeInputValue(e.target.value)}
|
|
55
|
+
onChange={(e) => changeInputValue(e.target.value)}
|
|
36
56
|
className="calendar-dropdown"
|
|
37
|
-
onFocus={() => setIsOpened(
|
|
57
|
+
onFocus={() => setIsOpened(true)}
|
|
38
58
|
/>
|
|
39
|
-
{isOpened ?
|
|
59
|
+
{isOpened ? (
|
|
60
|
+
<Calendar
|
|
61
|
+
date={getCalendarValue(value)}
|
|
62
|
+
setDate={(newDate) => changeCalendarDay(newDate)}
|
|
63
|
+
params={{ minDate, maxDate }}
|
|
64
|
+
isDontLimitFuture={isDontLimitFuture}
|
|
65
|
+
isListTop={isListTop}
|
|
66
|
+
setIsOpened={setIsOpened}
|
|
67
|
+
/>
|
|
68
|
+
) : null}
|
|
40
69
|
</div>
|
|
41
70
|
);
|
|
42
71
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.calendar-container {
|
|
2
|
+
min-width: 200px;
|
|
3
|
+
position: relative;
|
|
4
|
+
|
|
5
|
+
&_disabled {
|
|
6
|
+
pointer-events: none;
|
|
7
|
+
opacity: 0.5;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.calendar {
|
|
11
|
+
position: absolute;
|
|
12
|
+
z-index: 9;
|
|
13
|
+
top: 100%;
|
|
14
|
+
padding: 10px 16px;
|
|
15
|
+
border: 1px solid var(--border-color);
|
|
16
|
+
|
|
17
|
+
&_list-top {
|
|
18
|
+
bottom: calc(100% + 4px);
|
|
19
|
+
top: auto;
|
|
20
|
+
box-shadow: 0 -3px 15px rgb(0 0 0 / 15%);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -3,28 +3,37 @@ import InputCalendar from './InputCalendar';
|
|
|
3
3
|
|
|
4
4
|
global.lng = 'en';
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
export default {
|
|
8
7
|
title: 'Form Elements/Input Calendar',
|
|
9
8
|
component: InputCalendar,
|
|
10
9
|
argTypes: {
|
|
11
10
|
value: {
|
|
12
|
-
description: 'string (mm.dd.yyyy)'
|
|
11
|
+
description: 'string (mm.dd.yyyy)',
|
|
13
12
|
},
|
|
14
|
-
}
|
|
13
|
+
},
|
|
15
14
|
};
|
|
16
15
|
|
|
17
|
-
const Template = args => {
|
|
16
|
+
const Template = (args) => {
|
|
18
17
|
const [date, setDate] = useState('');
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const [disabled, setDisabled] = useState(false);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<InputCalendar {...args} value={date} onChange={(val) => setDate(val)} disabled={disabled} />
|
|
23
|
+
<div style={{ display: 'flex', flexFlow: 'row nowrap', justifyContent: 'flex-end', marginTop: '10px' }}>
|
|
24
|
+
<button style={{ border: 'solid 1px black', padding: '10px', width: '80px' }} onClick={() => setDisabled(!disabled)}>
|
|
25
|
+
{disabled ? 'Enable' : 'Disable'}
|
|
26
|
+
</button>
|
|
27
|
+
</div>
|
|
28
|
+
</>
|
|
29
|
+
);
|
|
21
30
|
};
|
|
22
31
|
|
|
23
32
|
export const CalendarTemplate = Template.bind({});
|
|
24
33
|
|
|
25
34
|
CalendarTemplate.args = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
minDate: '01/01/1900',
|
|
36
|
+
maxDate: '01/01/2100',
|
|
37
|
+
isDontLimitFuture: true,
|
|
38
|
+
// isListTop: true,
|
|
30
39
|
};
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState, useRef } from 'react';
|
|
1
2
|
import cn from 'classnames';
|
|
2
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import moment from 'moment';
|
|
4
|
+
import InputMask from 'react-input-mask';
|
|
4
5
|
import { ChevronLeft, ChevronRight } from 'react-feather';
|
|
5
6
|
import './Calendar.scss';
|
|
6
7
|
|
|
7
8
|
export default function (props) {
|
|
8
|
-
const { date, setDate, allowPrev = true, allowNext = true, params, className } = props;
|
|
9
|
-
const { minDate = '01/01/1900', maxDate = moment().format('MM/DD/YYYY') } = params;
|
|
9
|
+
const { date, setDate, setIsOpened, allowPrev = true, allowNext = true, params, className, isDontLimitFuture, isListTop } = props;
|
|
10
|
+
// const { minDate = '01/01/1900', maxDate = moment().format('MM/DD/YYYY') } = params;
|
|
11
|
+
const { minDate, maxDate } = params;
|
|
10
12
|
const [days, setDays] = useState({});
|
|
11
13
|
const [showDate, setShowDate] = useState(date);
|
|
14
|
+
const [isChangeYear, setIsChangeYear] = useState(false);
|
|
15
|
+
const [inputYearValue, setInputYearValue] = useState(moment(showDate).format('YYYY'));
|
|
16
|
+
const yearInputRef = useRef(null);
|
|
12
17
|
|
|
13
18
|
const selectedDay = moment(showDate);
|
|
14
19
|
const isError = 'Invalid date';
|
|
15
20
|
|
|
16
|
-
const title = useMemo(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
);
|
|
21
|
+
// const title = useMemo(
|
|
22
|
+
// () => (selectedDay.format('MMM') === isError ? isError : `${selectedDay.format('MMM')} ${moment(showDate).format('YYYY')}`),
|
|
23
|
+
// [date, showDate]
|
|
24
|
+
// );
|
|
25
|
+
|
|
26
|
+
const showMonth = useMemo(() => moment(showDate).format('MMM'), [date, showDate]);
|
|
27
|
+
const showYear = useMemo(() => moment(showDate).format('YYYY'), [date, showDate]);
|
|
28
|
+
|
|
20
29
|
useEffect(() => {
|
|
21
30
|
const result = {};
|
|
22
31
|
const day = selectedDay.startOf('month');
|
|
@@ -43,7 +52,7 @@ export default function (props) {
|
|
|
43
52
|
const classNames = cn(
|
|
44
53
|
'calendar__day',
|
|
45
54
|
{ 'calendar__day--clickable': day },
|
|
46
|
-
{ 'calendar__day--disabled': isFutureDay },
|
|
55
|
+
{ 'calendar__day--disabled': !isDontLimitFuture && isFutureDay },
|
|
47
56
|
{ 'calendar__day--disabled': isBeforeDay },
|
|
48
57
|
{ 'calendar__day--selected': moment(date).format() === moment(day.date).format() }
|
|
49
58
|
);
|
|
@@ -52,7 +61,14 @@ export default function (props) {
|
|
|
52
61
|
<div
|
|
53
62
|
key={`${week}_${dayOfWeek}`}
|
|
54
63
|
className={classNames}
|
|
55
|
-
onClick={
|
|
64
|
+
onClick={
|
|
65
|
+
day && (isDontLimitFuture || !isFutureDay)
|
|
66
|
+
? () => {
|
|
67
|
+
setDate(moment(day.date).format('L'));
|
|
68
|
+
setIsOpened(false);
|
|
69
|
+
}
|
|
70
|
+
: null
|
|
71
|
+
}
|
|
56
72
|
// onMouseOver={day && !isFutureDay ? () => onHover(day.date) : null}
|
|
57
73
|
// onMouseLeave={() => onHover(null)}
|
|
58
74
|
>
|
|
@@ -69,8 +85,39 @@ export default function (props) {
|
|
|
69
85
|
setShowDate(moment(showDate).add(1, 'month').format('L'));
|
|
70
86
|
};
|
|
71
87
|
|
|
88
|
+
const closeYearInput = () => {
|
|
89
|
+
const newDate = (() => {
|
|
90
|
+
const dateArr = showDate.split('/');
|
|
91
|
+
const oldYear = dateArr[2];
|
|
92
|
+
dateArr[2] = inputYearValue;
|
|
93
|
+
return moment(dateArr.join('/')).format('MM/DD/YYYY') === isError ? showDate : moment(dateArr.join('/')).format('MM/DD/YYYY');
|
|
94
|
+
})();
|
|
95
|
+
let resultDate = newDate;
|
|
96
|
+
if (minDate && moment(minDate) > moment(newDate)) resultDate = moment(showDate).format('MM/DD/YYYY');
|
|
97
|
+
else if (maxDate && moment(maxDate) < moment(newDate)) resultDate = moment(showDate).format('MM/DD/YYYY');
|
|
98
|
+
|
|
99
|
+
setIsChangeYear(false);
|
|
100
|
+
setShowDate(resultDate);
|
|
101
|
+
setInputYearValue(resultDate);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (isChangeYear && yearInputRef.current) {
|
|
106
|
+
const input = yearInputRef.current.getElementsByTagName('input')[0];
|
|
107
|
+
setInputYearValue(showYear);
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
input.focus();
|
|
110
|
+
input.select();
|
|
111
|
+
}, 0);
|
|
112
|
+
}
|
|
113
|
+
}, [isChangeYear]);
|
|
114
|
+
|
|
72
115
|
return (
|
|
73
|
-
<div
|
|
116
|
+
<div
|
|
117
|
+
className={cn('calendar', className, {
|
|
118
|
+
'calendar_list-top': isListTop,
|
|
119
|
+
})}
|
|
120
|
+
>
|
|
74
121
|
<div className="calendar-header">
|
|
75
122
|
<div className="calendar-header__prev">
|
|
76
123
|
{allowPrev && (
|
|
@@ -79,7 +126,31 @@ export default function (props) {
|
|
|
79
126
|
</div>
|
|
80
127
|
)}
|
|
81
128
|
</div>
|
|
82
|
-
<div className=
|
|
129
|
+
<div className={cn('calendar-header__title')} ref={yearInputRef}>
|
|
130
|
+
<span className="calendar-header__title-month">{`${showMonth} `}</span>
|
|
131
|
+
<span
|
|
132
|
+
className={cn('calendar-header__title-year', {
|
|
133
|
+
'calendar-header__title-year_change-mode': isChangeYear,
|
|
134
|
+
})}
|
|
135
|
+
onClick={() => setIsChangeYear(true)}
|
|
136
|
+
>
|
|
137
|
+
{isChangeYear ? (
|
|
138
|
+
<InputMask
|
|
139
|
+
className="calendar-header__title-year-change-input"
|
|
140
|
+
value={inputYearValue}
|
|
141
|
+
mask="9999"
|
|
142
|
+
onBlur={(e) => closeYearInput()}
|
|
143
|
+
onKeyUp={(e) => {
|
|
144
|
+
if (e.key === 'Escape') setIsChangeYear(false);
|
|
145
|
+
if (e.key === 'Enter') closeYearInput();
|
|
146
|
+
}}
|
|
147
|
+
onChange={(e) => setInputYearValue(e.target.value)}
|
|
148
|
+
/>
|
|
149
|
+
) : (
|
|
150
|
+
`${showYear}`
|
|
151
|
+
)}
|
|
152
|
+
</span>
|
|
153
|
+
</div>
|
|
83
154
|
<div className="calendar-header__next">
|
|
84
155
|
{allowNext && (
|
|
85
156
|
<div onClick={handleNext}>
|
|
@@ -425,23 +425,25 @@
|
|
|
425
425
|
// box-shadow: 0 0 3px 0 rgb(0 123 255 / 50%);
|
|
426
426
|
// }
|
|
427
427
|
// }
|
|
428
|
-
.calendar-header {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
428
|
+
// .calendar-header {
|
|
429
|
+
// display: flex;
|
|
430
|
+
// justify-content: center;
|
|
431
|
+
// align-items: center;
|
|
432
|
+
|
|
433
|
+
// &__prev,
|
|
434
|
+
// &__next {
|
|
435
|
+
// display: flex;
|
|
436
|
+
// height: auto;
|
|
437
|
+
// cursor: pointer;
|
|
438
|
+
// }
|
|
439
|
+
// }
|
|
432
440
|
|
|
433
|
-
&__prev,
|
|
434
|
-
&__next{
|
|
435
|
-
display: flex;
|
|
436
|
-
height: auto;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
441
|
.calendar {
|
|
440
442
|
background: #ffffff;
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
443
|
+
border: 1px solid #e2e5ec;
|
|
444
|
+
box-shadow: 0 5px 20px rgb(0 0 0 / 15%);
|
|
445
|
+
margin-top: 4px;
|
|
446
|
+
padding: 5px 0;
|
|
445
447
|
|
|
446
448
|
min-height: 195px;
|
|
447
449
|
width: 260px;
|
|
@@ -449,6 +451,63 @@
|
|
|
449
451
|
flex-direction: column;
|
|
450
452
|
user-select: none;
|
|
451
453
|
|
|
454
|
+
&-header {
|
|
455
|
+
display: flex;
|
|
456
|
+
justify-content: center;
|
|
457
|
+
align-items: center;
|
|
458
|
+
|
|
459
|
+
box-sizing: border-box;
|
|
460
|
+
&__title {
|
|
461
|
+
&-month {
|
|
462
|
+
margin-right: 5px;
|
|
463
|
+
}
|
|
464
|
+
&-year {
|
|
465
|
+
box-sizing: border-box;
|
|
466
|
+
width: 45px;
|
|
467
|
+
height: 100%;
|
|
468
|
+
padding: 0 5px;
|
|
469
|
+
cursor: pointer;
|
|
470
|
+
display: flex;
|
|
471
|
+
flex-flow: row nowrap;
|
|
472
|
+
justify-content: center;
|
|
473
|
+
align-items: center;
|
|
474
|
+
|
|
475
|
+
&:hover:not(.calendar-header__title-year_change-mode) {
|
|
476
|
+
text-decoration: underline;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
&.calendar-header__title-year_change-mode {
|
|
480
|
+
height: 24px;
|
|
481
|
+
padding: 0 3px;
|
|
482
|
+
border-style: solid;
|
|
483
|
+
border-width: 1px;
|
|
484
|
+
border-color: inherit;
|
|
485
|
+
border-radius: var(--border-radius);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
&-change-input {
|
|
489
|
+
box-sizing: border-box;
|
|
490
|
+
width: 100%;
|
|
491
|
+
border: none;
|
|
492
|
+
outline: none;
|
|
493
|
+
margin: 0;
|
|
494
|
+
padding: 0;
|
|
495
|
+
display: inline;
|
|
496
|
+
font-size: inherit;
|
|
497
|
+
line-height: inherit;
|
|
498
|
+
font-weight: inherit;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
&__prev,
|
|
504
|
+
&__next {
|
|
505
|
+
display: flex;
|
|
506
|
+
height: auto;
|
|
507
|
+
cursor: pointer;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
452
511
|
&__week {
|
|
453
512
|
display: flex;
|
|
454
513
|
}
|
|
@@ -516,18 +575,6 @@
|
|
|
516
575
|
}
|
|
517
576
|
}
|
|
518
577
|
|
|
519
|
-
&-container {
|
|
520
|
-
min-width: 200px;
|
|
521
|
-
position: relative;
|
|
522
|
-
.calendar {
|
|
523
|
-
position: absolute;
|
|
524
|
-
z-index: 9;
|
|
525
|
-
top: 100%;
|
|
526
|
-
padding: 10px 16px;
|
|
527
|
-
border: 1px solid var(--border-color);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
578
|
&-dropdown {
|
|
532
579
|
appearance: none;
|
|
533
580
|
background-color: white;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import Calendar from './Calendar';
|
|
3
3
|
|
|
4
4
|
global.lng = 'en';
|
|
@@ -8,16 +8,18 @@ export default {
|
|
|
8
8
|
component: Calendar,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const Template = args =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const Template = args => {
|
|
12
|
+
const [date, setDate] = useState('12/03/2021');
|
|
13
|
+
return (
|
|
14
|
+
<div style={{ width: '320px' }}>
|
|
15
|
+
<Calendar {...args} date={date} setDate={setDate} />
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
16
19
|
|
|
17
20
|
export const CalendarTemplate = Template.bind({});
|
|
18
21
|
|
|
19
22
|
CalendarTemplate.args = {
|
|
20
|
-
date: '12/03/2021',
|
|
21
23
|
params: {},
|
|
22
24
|
setDate: () => null,
|
|
23
25
|
className: ''
|