intelicoreact 0.0.91 → 0.0.92
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 +2 -1
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +5 -3
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +3 -2
- package/dist/Atomic/UI/Calendar/Calendar.js +89 -15
- package/dist/Atomic/UI/Calendar/Calendar.scss +52 -5
- 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 +1 -1
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +14 -7
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +7 -8
- package/src/Atomic/UI/Calendar/Calendar.js +80 -11
- package/src/Atomic/UI/Calendar/Calendar.scss +52 -5
- 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',
|
|
@@ -11,7 +11,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
|
|
12
12
|
require("./Loader.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", {
|
|
@@ -35,7 +35,8 @@ var InputCalendar = function InputCalendar(_ref) {
|
|
|
35
35
|
_ref$placeholder = _ref.placeholder,
|
|
36
36
|
placeholder = _ref$placeholder === void 0 ? 'mm/dd/yyyy' : _ref$placeholder,
|
|
37
37
|
_ref$mask = _ref.mask,
|
|
38
|
-
mask = _ref$mask === void 0 ? '99/99/9999' : _ref$mask
|
|
38
|
+
mask = _ref$mask === void 0 ? '99/99/9999' : _ref$mask,
|
|
39
|
+
dontLimitFuture = _ref.dontLimitFuture;
|
|
39
40
|
|
|
40
41
|
var _useState = (0, _react.useState)(false),
|
|
41
42
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -57,7 +58,7 @@ var InputCalendar = function InputCalendar(_ref) {
|
|
|
57
58
|
|
|
58
59
|
var getCalendarValue = function getCalendarValue(value) {
|
|
59
60
|
var date = (0, _moment.default)(value).format('L');
|
|
60
|
-
if (date !==
|
|
61
|
+
if (date !== 'Invalid date') return date;
|
|
61
62
|
return (0, _moment.default)(new Date()).format('L');
|
|
62
63
|
};
|
|
63
64
|
|
|
@@ -83,7 +84,8 @@ var InputCalendar = function InputCalendar(_ref) {
|
|
|
83
84
|
params: {
|
|
84
85
|
minDate: minDate,
|
|
85
86
|
maxDate: maxDate
|
|
86
|
-
}
|
|
87
|
+
},
|
|
88
|
+
dontLimitFuture: dontLimitFuture
|
|
87
89
|
}) : null);
|
|
88
90
|
};
|
|
89
91
|
|
|
@@ -51,6 +51,7 @@ var CalendarTemplate = Template.bind({});
|
|
|
51
51
|
exports.CalendarTemplate = CalendarTemplate;
|
|
52
52
|
CalendarTemplate.args = {
|
|
53
53
|
value: '',
|
|
54
|
-
minDate: '10/14/2020',
|
|
55
|
-
maxDate: '10/14/2022'
|
|
54
|
+
// minDate: '10/14/2020',
|
|
55
|
+
// maxDate: '10/14/2022',
|
|
56
|
+
dontLimitFuture: true
|
|
56
57
|
};
|
|
@@ -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");
|
|
@@ -35,11 +37,11 @@ function _default(props) {
|
|
|
35
37
|
_props$allowNext = props.allowNext,
|
|
36
38
|
allowNext = _props$allowNext === void 0 ? true : _props$allowNext,
|
|
37
39
|
params = props.params,
|
|
38
|
-
className = props.className
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
maxDate =
|
|
40
|
+
className = props.className,
|
|
41
|
+
dontLimitFuture = props.dontLimitFuture; // const { minDate = '01/01/1900', maxDate = moment().format('MM/DD/YYYY') } = params;
|
|
42
|
+
|
|
43
|
+
var minDate = params.minDate,
|
|
44
|
+
maxDate = params.maxDate;
|
|
43
45
|
|
|
44
46
|
var _useState = (0, _react.useState)({}),
|
|
45
47
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -51,11 +53,31 @@ function _default(props) {
|
|
|
51
53
|
showDate = _useState4[0],
|
|
52
54
|
setShowDate = _useState4[1];
|
|
53
55
|
|
|
56
|
+
var _useState5 = (0, _react.useState)(false),
|
|
57
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
58
|
+
isChangeYear = _useState6[0],
|
|
59
|
+
setIsChangeYear = _useState6[1];
|
|
60
|
+
|
|
61
|
+
var _useState7 = (0, _react.useState)((0, _moment.default)(showDate).format('YYYY')),
|
|
62
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
63
|
+
inputYearValue = _useState8[0],
|
|
64
|
+
setInputYearValue = _useState8[1];
|
|
65
|
+
|
|
66
|
+
var yearInputRef = (0, _react.useRef)(null);
|
|
54
67
|
var selectedDay = (0, _moment.default)(showDate);
|
|
55
|
-
var isError = 'Invalid date';
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
var isError = 'Invalid date'; // const title = useMemo(
|
|
69
|
+
// () => (selectedDay.format('MMM') === isError ? isError : `${selectedDay.format('MMM')} ${moment(showDate).format('YYYY')}`),
|
|
70
|
+
// [date, showDate]
|
|
71
|
+
// );
|
|
72
|
+
|
|
73
|
+
var showMonth = (0, _react.useMemo)(function () {
|
|
74
|
+
return (0, _moment.default)(showDate).format('MMM');
|
|
75
|
+
}, [date, showDate]);
|
|
76
|
+
var showYear = (0, _react.useMemo)(function () {
|
|
77
|
+
return (0, _moment.default)(showDate).format('YYYY');
|
|
58
78
|
}, [date, showDate]);
|
|
79
|
+
console.log('date - ', date);
|
|
80
|
+
console.log('showDate - ', showDate);
|
|
59
81
|
(0, _react.useEffect)(function () {
|
|
60
82
|
var result = {};
|
|
61
83
|
var day = selectedDay.startOf('month');
|
|
@@ -86,10 +108,12 @@ function _default(props) {
|
|
|
86
108
|
});
|
|
87
109
|
var isFutureDay = day && maxDate ? (0, _moment.default)(day.date).isAfter((0, _moment.default)(maxDate || ''), 'day') : (0, _moment.default)(day.date).isAfter((0, _moment.default)(), 'day');
|
|
88
110
|
var isBeforeDay = day && (0, _moment.default)(day.date).isBefore((0, _moment.default)(minDate || ''), 'day');
|
|
111
|
+
console.log('isFutureDay - ', isFutureDay);
|
|
112
|
+
console.log('isBeforeDay - ', isBeforeDay);
|
|
89
113
|
var classNames = (0, _classnames.default)('calendar__day', {
|
|
90
114
|
'calendar__day--clickable': day
|
|
91
115
|
}, {
|
|
92
|
-
'calendar__day--disabled': isFutureDay
|
|
116
|
+
'calendar__day--disabled': !dontLimitFuture && isFutureDay
|
|
93
117
|
}, {
|
|
94
118
|
'calendar__day--disabled': isBeforeDay
|
|
95
119
|
}, {
|
|
@@ -98,7 +122,7 @@ function _default(props) {
|
|
|
98
122
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
99
123
|
key: "".concat(week, "_").concat(dayOfWeek),
|
|
100
124
|
className: classNames,
|
|
101
|
-
onClick: day && !isFutureDay ? function () {
|
|
125
|
+
onClick: day && (dontLimitFuture || !isFutureDay) ? function () {
|
|
102
126
|
return setDate((0, _moment.default)(day.date).format('L'));
|
|
103
127
|
} : null // onMouseOver={day && !isFutureDay ? () => onHover(day.date) : null}
|
|
104
128
|
// onMouseLeave={() => onHover(null)}
|
|
@@ -114,8 +138,33 @@ function _default(props) {
|
|
|
114
138
|
setShowDate((0, _moment.default)(showDate).add(1, 'month').format('L'));
|
|
115
139
|
};
|
|
116
140
|
|
|
141
|
+
var closeYearInput = function closeYearInput() {
|
|
142
|
+
var newDate = function () {
|
|
143
|
+
var dateArr = showDate.split('/');
|
|
144
|
+
var oldYear = dateArr[2];
|
|
145
|
+
dateArr[2] = inputYearValue;
|
|
146
|
+
return (0, _moment.default)(dateArr.join('/')).format('MM/DD/YYYY') === isError ? showDate : (0, _moment.default)(dateArr.join('/')).format('MM/DD/YYYY');
|
|
147
|
+
}();
|
|
148
|
+
|
|
149
|
+
var resultDate = newDate;
|
|
150
|
+
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');
|
|
151
|
+
setIsChangeYear(false);
|
|
152
|
+
setShowDate(resultDate);
|
|
153
|
+
setInputYearValue(resultDate);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
(0, _react.useEffect)(function () {
|
|
157
|
+
if (isChangeYear && yearInputRef.current) {
|
|
158
|
+
var input = yearInputRef.current.getElementsByTagName('input')[0];
|
|
159
|
+
setInputYearValue(showYear);
|
|
160
|
+
setTimeout(function () {
|
|
161
|
+
input.focus();
|
|
162
|
+
input.select();
|
|
163
|
+
}, 0);
|
|
164
|
+
}
|
|
165
|
+
}, [isChangeYear]);
|
|
117
166
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
118
|
-
className: "calendar ".concat(className ? className :
|
|
167
|
+
className: "calendar ".concat(className ? className : '')
|
|
119
168
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
120
169
|
className: "calendar-header"
|
|
121
170
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -123,8 +172,33 @@ function _default(props) {
|
|
|
123
172
|
}, allowPrev && /*#__PURE__*/_react.default.createElement("div", {
|
|
124
173
|
onClick: handlePrev
|
|
125
174
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronLeft, null))), /*#__PURE__*/_react.default.createElement("div", {
|
|
126
|
-
className:
|
|
127
|
-
|
|
175
|
+
className: (0, _classnames.default)('calendar-header__title'),
|
|
176
|
+
ref: yearInputRef
|
|
177
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
178
|
+
className: "calendar-header__title-month"
|
|
179
|
+
}, "".concat(showMonth, " ")), /*#__PURE__*/_react.default.createElement("span", {
|
|
180
|
+
className: (0, _classnames.default)('calendar-header__title-year', {
|
|
181
|
+
'calendar-header__title-year_change-mode': isChangeYear
|
|
182
|
+
}),
|
|
183
|
+
onClick: function onClick() {
|
|
184
|
+
return setIsChangeYear(true);
|
|
185
|
+
}
|
|
186
|
+
}, isChangeYear ? /*#__PURE__*/_react.default.createElement(_reactInputMask.default, {
|
|
187
|
+
className: "calendar-header__title-year-change-input",
|
|
188
|
+
value: inputYearValue,
|
|
189
|
+
mask: "9999",
|
|
190
|
+
onBlur: function onBlur(e) {
|
|
191
|
+
return closeYearInput();
|
|
192
|
+
},
|
|
193
|
+
onKeyUp: function onKeyUp(e) {
|
|
194
|
+
if (e.key === 'Escape') setIsChangeYear(false);
|
|
195
|
+
if (e.key === 'Enter') closeYearInput();
|
|
196
|
+
},
|
|
197
|
+
onChange: function onChange(e) {
|
|
198
|
+
console.log(e.target.value);
|
|
199
|
+
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
|
|
@@ -431,17 +431,18 @@
|
|
|
431
431
|
align-items: center;
|
|
432
432
|
|
|
433
433
|
&__prev,
|
|
434
|
-
&__next{
|
|
434
|
+
&__next {
|
|
435
435
|
display: flex;
|
|
436
436
|
height: auto;
|
|
437
|
+
cursor: pointer;
|
|
437
438
|
}
|
|
438
439
|
}
|
|
439
440
|
.calendar {
|
|
440
441
|
background: #ffffff;
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
442
|
+
border: 1px solid #e2e5ec;
|
|
443
|
+
box-shadow: 0 5px 20px rgb(0 0 0 / 15%);
|
|
444
|
+
margin-top: 4px;
|
|
445
|
+
padding: 5px 0;
|
|
445
446
|
|
|
446
447
|
min-height: 195px;
|
|
447
448
|
width: 260px;
|
|
@@ -449,6 +450,52 @@
|
|
|
449
450
|
flex-direction: column;
|
|
450
451
|
user-select: none;
|
|
451
452
|
|
|
453
|
+
&-header {
|
|
454
|
+
box-sizing: border-box;
|
|
455
|
+
&__title {
|
|
456
|
+
&-month {
|
|
457
|
+
margin-right: 5px;
|
|
458
|
+
}
|
|
459
|
+
&-year {
|
|
460
|
+
box-sizing: border-box;
|
|
461
|
+
width: 45px;
|
|
462
|
+
height: 100%;
|
|
463
|
+
padding: 0 5px;
|
|
464
|
+
cursor: pointer;
|
|
465
|
+
display: flex;
|
|
466
|
+
flex-flow: row nowrap;
|
|
467
|
+
justify-content: center;
|
|
468
|
+
align-items: center;
|
|
469
|
+
|
|
470
|
+
&:hover:not(.calendar-header__title-year_change-mode) {
|
|
471
|
+
text-decoration: underline;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
&.calendar-header__title-year_change-mode {
|
|
475
|
+
height: 24px;
|
|
476
|
+
padding: 0 3px;
|
|
477
|
+
border-style: solid;
|
|
478
|
+
border-width: 1px;
|
|
479
|
+
border-color: inherit;
|
|
480
|
+
border-radius: var(--border-radius);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
&-change-input {
|
|
484
|
+
box-sizing: border-box;
|
|
485
|
+
width: 100%;
|
|
486
|
+
border: none;
|
|
487
|
+
outline: none;
|
|
488
|
+
margin: 0;
|
|
489
|
+
padding: 0;
|
|
490
|
+
display: inline;
|
|
491
|
+
font-size: inherit;
|
|
492
|
+
line-height: inherit;
|
|
493
|
+
font-weight: inherit;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
452
499
|
&__week {
|
|
453
500
|
display: flex;
|
|
454
501
|
}
|
|
@@ -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
2
|
import './Loader.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' : ''}`}>
|
|
@@ -4,27 +4,27 @@ import InputMask from 'react-input-mask';
|
|
|
4
4
|
import Calendar from '../../UI/Calendar/Calendar';
|
|
5
5
|
import { useClickOutside } from '../../../Functions/useClickOutside';
|
|
6
6
|
|
|
7
|
-
const InputCalendar = ({ value, minDate, maxDate, onChange, className = '', placeholder = 'mm/dd/yyyy', mask = '99/99/9999' }) => {
|
|
7
|
+
const InputCalendar = ({ value, minDate, maxDate, onChange, className = '', placeholder = 'mm/dd/yyyy', mask = '99/99/9999', dontLimitFuture }) => {
|
|
8
8
|
const [isOpened, setIsOpened] = useState(false);
|
|
9
9
|
const calendarRef = useRef(null);
|
|
10
10
|
|
|
11
11
|
useClickOutside(calendarRef, () => setIsOpened(false));
|
|
12
12
|
|
|
13
|
-
const changeInputValue = val => {
|
|
13
|
+
const changeInputValue = (val) => {
|
|
14
14
|
if (onChange) onChange(val);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const changeCalendarDay = val => {
|
|
17
|
+
const changeCalendarDay = (val) => {
|
|
18
18
|
if (onChange) onChange(val);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const getCalendarValue = (value) => {
|
|
22
22
|
const date = moment(value).format('L');
|
|
23
23
|
|
|
24
|
-
if(date !==
|
|
24
|
+
if (date !== 'Invalid date') return date;
|
|
25
25
|
|
|
26
26
|
return moment(new Date()).format('L');
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
30
|
<div className={`input__wrap calendar-container ${className}`} ref={calendarRef}>
|
|
@@ -32,11 +32,18 @@ const InputCalendar = ({ value, minDate, maxDate, onChange, className = '', plac
|
|
|
32
32
|
mask={mask}
|
|
33
33
|
placeholder={placeholder}
|
|
34
34
|
value={value}
|
|
35
|
-
onChange={e => changeInputValue(e.target.value)}
|
|
35
|
+
onChange={(e) => changeInputValue(e.target.value)}
|
|
36
36
|
className="calendar-dropdown"
|
|
37
37
|
onFocus={() => setIsOpened(!isOpened)}
|
|
38
38
|
/>
|
|
39
|
-
{isOpened ?
|
|
39
|
+
{isOpened ? (
|
|
40
|
+
<Calendar
|
|
41
|
+
date={getCalendarValue(value)}
|
|
42
|
+
setDate={(newDate) => changeCalendarDay(newDate)}
|
|
43
|
+
params={{ minDate, maxDate }}
|
|
44
|
+
dontLimitFuture={dontLimitFuture}
|
|
45
|
+
/>
|
|
46
|
+
) : null}
|
|
40
47
|
</div>
|
|
41
48
|
);
|
|
42
49
|
};
|
|
@@ -3,28 +3,27 @@ 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
18
|
|
|
20
|
-
return <InputCalendar {...args} value={date} onChange={val => setDate(val)} />;
|
|
19
|
+
return <InputCalendar {...args} value={date} onChange={(val) => setDate(val)} />;
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
export const CalendarTemplate = Template.bind({});
|
|
24
23
|
|
|
25
24
|
CalendarTemplate.args = {
|
|
26
25
|
value: '',
|
|
27
|
-
minDate: '10/14/2020',
|
|
28
|
-
maxDate: '10/14/2022',
|
|
29
|
-
|
|
26
|
+
// minDate: '10/14/2020',
|
|
27
|
+
// maxDate: '10/14/2022',
|
|
28
|
+
dontLimitFuture: true,
|
|
30
29
|
};
|
|
@@ -1,22 +1,34 @@
|
|
|
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, allowPrev = true, allowNext = true, params, className, dontLimitFuture } = 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
|
+
|
|
29
|
+
console.log('date - ', date);
|
|
30
|
+
console.log('showDate - ', showDate);
|
|
31
|
+
|
|
20
32
|
useEffect(() => {
|
|
21
33
|
const result = {};
|
|
22
34
|
const day = selectedDay.startOf('month');
|
|
@@ -40,10 +52,13 @@ export default function (props) {
|
|
|
40
52
|
const isFutureDay = day && maxDate ? moment(day.date).isAfter(moment(maxDate || ''), 'day') : moment(day.date).isAfter(moment(), 'day');
|
|
41
53
|
const isBeforeDay = day && moment(day.date).isBefore(moment(minDate || ''), 'day');
|
|
42
54
|
|
|
55
|
+
console.log('isFutureDay - ', isFutureDay);
|
|
56
|
+
console.log('isBeforeDay - ', isBeforeDay);
|
|
57
|
+
|
|
43
58
|
const classNames = cn(
|
|
44
59
|
'calendar__day',
|
|
45
60
|
{ 'calendar__day--clickable': day },
|
|
46
|
-
{ 'calendar__day--disabled': isFutureDay },
|
|
61
|
+
{ 'calendar__day--disabled': !dontLimitFuture && isFutureDay },
|
|
47
62
|
{ 'calendar__day--disabled': isBeforeDay },
|
|
48
63
|
{ 'calendar__day--selected': moment(date).format() === moment(day.date).format() }
|
|
49
64
|
);
|
|
@@ -52,7 +67,7 @@ export default function (props) {
|
|
|
52
67
|
<div
|
|
53
68
|
key={`${week}_${dayOfWeek}`}
|
|
54
69
|
className={classNames}
|
|
55
|
-
onClick={day && !isFutureDay ? () => setDate(moment(day.date).format('L')) : null}
|
|
70
|
+
onClick={day && (dontLimitFuture || !isFutureDay) ? () => setDate(moment(day.date).format('L')) : null}
|
|
56
71
|
// onMouseOver={day && !isFutureDay ? () => onHover(day.date) : null}
|
|
57
72
|
// onMouseLeave={() => onHover(null)}
|
|
58
73
|
>
|
|
@@ -69,8 +84,35 @@ export default function (props) {
|
|
|
69
84
|
setShowDate(moment(showDate).add(1, 'month').format('L'));
|
|
70
85
|
};
|
|
71
86
|
|
|
87
|
+
const closeYearInput = () => {
|
|
88
|
+
const newDate = (() => {
|
|
89
|
+
const dateArr = showDate.split('/');
|
|
90
|
+
const oldYear = dateArr[2];
|
|
91
|
+
dateArr[2] = inputYearValue;
|
|
92
|
+
return moment(dateArr.join('/')).format('MM/DD/YYYY') === isError ? showDate : moment(dateArr.join('/')).format('MM/DD/YYYY');
|
|
93
|
+
})();
|
|
94
|
+
let resultDate = newDate;
|
|
95
|
+
if (minDate && moment(minDate) > moment(newDate)) resultDate = moment(showDate).format('MM/DD/YYYY');
|
|
96
|
+
else if (maxDate && moment(maxDate) < moment(newDate)) resultDate = moment(showDate).format('MM/DD/YYYY');
|
|
97
|
+
|
|
98
|
+
setIsChangeYear(false);
|
|
99
|
+
setShowDate(resultDate);
|
|
100
|
+
setInputYearValue(resultDate);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (isChangeYear && yearInputRef.current) {
|
|
105
|
+
const input = yearInputRef.current.getElementsByTagName('input')[0];
|
|
106
|
+
setInputYearValue(showYear);
|
|
107
|
+
setTimeout(() => {
|
|
108
|
+
input.focus();
|
|
109
|
+
input.select();
|
|
110
|
+
}, 0);
|
|
111
|
+
}
|
|
112
|
+
}, [isChangeYear]);
|
|
113
|
+
|
|
72
114
|
return (
|
|
73
|
-
<div className={`calendar ${className ? className :
|
|
115
|
+
<div className={`calendar ${className ? className : ''}`}>
|
|
74
116
|
<div className="calendar-header">
|
|
75
117
|
<div className="calendar-header__prev">
|
|
76
118
|
{allowPrev && (
|
|
@@ -79,7 +121,34 @@ export default function (props) {
|
|
|
79
121
|
</div>
|
|
80
122
|
)}
|
|
81
123
|
</div>
|
|
82
|
-
<div className=
|
|
124
|
+
<div className={cn('calendar-header__title')} ref={yearInputRef}>
|
|
125
|
+
<span className="calendar-header__title-month">{`${showMonth} `}</span>
|
|
126
|
+
<span
|
|
127
|
+
className={cn('calendar-header__title-year', {
|
|
128
|
+
'calendar-header__title-year_change-mode': isChangeYear,
|
|
129
|
+
})}
|
|
130
|
+
onClick={() => setIsChangeYear(true)}
|
|
131
|
+
>
|
|
132
|
+
{isChangeYear ? (
|
|
133
|
+
<InputMask
|
|
134
|
+
className="calendar-header__title-year-change-input"
|
|
135
|
+
value={inputYearValue}
|
|
136
|
+
mask="9999"
|
|
137
|
+
onBlur={(e) => closeYearInput()}
|
|
138
|
+
onKeyUp={(e) => {
|
|
139
|
+
if (e.key === 'Escape') setIsChangeYear(false);
|
|
140
|
+
if (e.key === 'Enter') closeYearInput();
|
|
141
|
+
}}
|
|
142
|
+
onChange={(e) => {
|
|
143
|
+
console.log(e.target.value);
|
|
144
|
+
setInputYearValue(e.target.value);
|
|
145
|
+
}}
|
|
146
|
+
/>
|
|
147
|
+
) : (
|
|
148
|
+
`${showYear}`
|
|
149
|
+
)}
|
|
150
|
+
</span>
|
|
151
|
+
</div>
|
|
83
152
|
<div className="calendar-header__next">
|
|
84
153
|
{allowNext && (
|
|
85
154
|
<div onClick={handleNext}>
|
|
@@ -431,17 +431,18 @@
|
|
|
431
431
|
align-items: center;
|
|
432
432
|
|
|
433
433
|
&__prev,
|
|
434
|
-
&__next{
|
|
434
|
+
&__next {
|
|
435
435
|
display: flex;
|
|
436
436
|
height: auto;
|
|
437
|
+
cursor: pointer;
|
|
437
438
|
}
|
|
438
439
|
}
|
|
439
440
|
.calendar {
|
|
440
441
|
background: #ffffff;
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
442
|
+
border: 1px solid #e2e5ec;
|
|
443
|
+
box-shadow: 0 5px 20px rgb(0 0 0 / 15%);
|
|
444
|
+
margin-top: 4px;
|
|
445
|
+
padding: 5px 0;
|
|
445
446
|
|
|
446
447
|
min-height: 195px;
|
|
447
448
|
width: 260px;
|
|
@@ -449,6 +450,52 @@
|
|
|
449
450
|
flex-direction: column;
|
|
450
451
|
user-select: none;
|
|
451
452
|
|
|
453
|
+
&-header {
|
|
454
|
+
box-sizing: border-box;
|
|
455
|
+
&__title {
|
|
456
|
+
&-month {
|
|
457
|
+
margin-right: 5px;
|
|
458
|
+
}
|
|
459
|
+
&-year {
|
|
460
|
+
box-sizing: border-box;
|
|
461
|
+
width: 45px;
|
|
462
|
+
height: 100%;
|
|
463
|
+
padding: 0 5px;
|
|
464
|
+
cursor: pointer;
|
|
465
|
+
display: flex;
|
|
466
|
+
flex-flow: row nowrap;
|
|
467
|
+
justify-content: center;
|
|
468
|
+
align-items: center;
|
|
469
|
+
|
|
470
|
+
&:hover:not(.calendar-header__title-year_change-mode) {
|
|
471
|
+
text-decoration: underline;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
&.calendar-header__title-year_change-mode {
|
|
475
|
+
height: 24px;
|
|
476
|
+
padding: 0 3px;
|
|
477
|
+
border-style: solid;
|
|
478
|
+
border-width: 1px;
|
|
479
|
+
border-color: inherit;
|
|
480
|
+
border-radius: var(--border-radius);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
&-change-input {
|
|
484
|
+
box-sizing: border-box;
|
|
485
|
+
width: 100%;
|
|
486
|
+
border: none;
|
|
487
|
+
outline: none;
|
|
488
|
+
margin: 0;
|
|
489
|
+
padding: 0;
|
|
490
|
+
display: inline;
|
|
491
|
+
font-size: inherit;
|
|
492
|
+
line-height: inherit;
|
|
493
|
+
font-weight: inherit;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
452
499
|
&__week {
|
|
453
500
|
display: flex;
|
|
454
501
|
}
|
|
@@ -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: ''
|