intelicoreact 0.0.46 → 0.0.52
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/Calendar/Calendar.js +10 -3
- package/dist/Atomic/FormElements/Calendar/Calendar.scss +1 -1
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +10 -3
- package/dist/Atomic/FormElements/Dropdown/Dropdown.stories.js +2 -1
- package/dist/Atomic/FormElements/Input/Input.js +5 -4
- package/dist/Atomic/FormElements/Input/Input.stories.js +5 -1
- package/dist/Atomic/FormElements/{Calendar/Calendar.stories.js → InputCalendar/InputCalendar.js} +39 -25
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +46 -0
- package/dist/Atomic/UI/Price/Price.js +1 -0
- package/package.json +2 -2
- package/src/Atomic/FormElements/Calendar/Calendar.js +7 -3
- package/src/Atomic/FormElements/Calendar/Calendar.scss +1 -1
- package/src/Atomic/FormElements/Dropdown/Dropdown.js +9 -4
- package/src/Atomic/FormElements/Dropdown/Dropdown.stories.js +1 -1
- package/src/Atomic/FormElements/Input/Input.js +5 -4
- package/src/Atomic/FormElements/Input/Input.stories.js +3 -1
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +43 -0
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +27 -0
- package/src/Atomic/UI/Price/Price.js +1 -0
- package/src/Atomic/FormElements/Calendar/Calendar.stories.js +0 -38
|
@@ -33,7 +33,10 @@ function _default(props) {
|
|
|
33
33
|
_props$allowPrev = props.allowPrev,
|
|
34
34
|
allowPrev = _props$allowPrev === void 0 ? true : _props$allowPrev,
|
|
35
35
|
_props$allowNext = props.allowNext,
|
|
36
|
-
allowNext = _props$allowNext === void 0 ? true : _props$allowNext
|
|
36
|
+
allowNext = _props$allowNext === void 0 ? true : _props$allowNext,
|
|
37
|
+
params = props.params;
|
|
38
|
+
var minDate = params.minDate,
|
|
39
|
+
maxDate = params.maxDate;
|
|
37
40
|
|
|
38
41
|
var _useState = (0, _react.useState)({}),
|
|
39
42
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -73,14 +76,18 @@ function _default(props) {
|
|
|
73
76
|
if (!day) return /*#__PURE__*/_react.default.createElement("div", {
|
|
74
77
|
className: "calendar__day"
|
|
75
78
|
});
|
|
76
|
-
var isFutureDay = day && (0, _moment.default)(day.date).isAfter((0, _moment.default)(), 'day');
|
|
79
|
+
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');
|
|
80
|
+
var isBeforeDay = day && (0, _moment.default)(day.date).isBefore((0, _moment.default)(minDate || ''), 'day');
|
|
77
81
|
var classNames = (0, _classnames.default)('calendar__day', {
|
|
78
82
|
'calendar__day--clickable': day
|
|
79
83
|
}, {
|
|
80
84
|
'calendar__day--disabled': isFutureDay
|
|
85
|
+
}, {
|
|
86
|
+
'calendar__day--disabled': isBeforeDay
|
|
81
87
|
}, {
|
|
82
88
|
'calendar__day--selected': selectedDay.format() === (0, _moment.default)(day.date).format()
|
|
83
|
-
});
|
|
89
|
+
}); // console.log(isMaxDate, isMinDate);
|
|
90
|
+
|
|
84
91
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
85
92
|
key: "".concat(week, "_").concat(dayOfWeek),
|
|
86
93
|
className: classNames,
|
|
@@ -118,6 +118,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
118
118
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
119
119
|
className: (0, _classnames.default)("".concat(RC, "__active-icon"), (0, _defineProperty2.default)({}, "".concat(RC, "__active-icon_active"), item.value === value))
|
|
120
120
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.Check, null)), /*#__PURE__*/_react.default.createElement("div", {
|
|
121
|
+
className: item.className || '',
|
|
121
122
|
dangerouslySetInnerHTML: {
|
|
122
123
|
__html: hightlightedText(item.label)
|
|
123
124
|
}
|
|
@@ -159,7 +160,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
159
160
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
160
161
|
className: "".concat(RC, "__trigger input__wrap ").concat(!value ? 'placeholder' : '', " ").concat(error ? 'error' : ''),
|
|
161
162
|
onClick: function onClick() {
|
|
162
|
-
return setIsOpen(!isOpen);
|
|
163
|
+
return !isSearchable ? setIsOpen(!isOpen) : null;
|
|
163
164
|
}
|
|
164
165
|
}, isSearchable ? /*#__PURE__*/_react.default.createElement("input", {
|
|
165
166
|
className: "".concat(RC, "__input"),
|
|
@@ -167,11 +168,17 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
167
168
|
onChange: function onChange(e) {
|
|
168
169
|
return onSearchHandler(e.target.value);
|
|
169
170
|
},
|
|
170
|
-
placeholder: placeholder
|
|
171
|
+
placeholder: placeholder,
|
|
172
|
+
onFocus: function onFocus() {
|
|
173
|
+
return setIsOpen(true);
|
|
174
|
+
}
|
|
171
175
|
}) : /*#__PURE__*/_react.default.createElement("span", {
|
|
172
176
|
className: "text"
|
|
173
177
|
}, selectedLabel || placeholder), /*#__PURE__*/_react.default.createElement("span", {
|
|
174
|
-
className: (0, _classnames.default)("".concat(RC, "__arrow"), (0, _defineProperty2.default)({}, "".concat(RC, "__arrow_active"), isOpen))
|
|
178
|
+
className: (0, _classnames.default)("".concat(RC, "__arrow"), (0, _defineProperty2.default)({}, "".concat(RC, "__arrow_active"), isOpen)),
|
|
179
|
+
onClick: function onClick() {
|
|
180
|
+
return setIsOpen(!isOpen);
|
|
181
|
+
}
|
|
175
182
|
}, isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen && filteredOptions.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
176
183
|
className: "".concat(RC, "__list")
|
|
177
184
|
}, filteredOptions.map(function (filteredOption) {
|
|
@@ -49,7 +49,8 @@ var Input = function Input(_ref) {
|
|
|
49
49
|
onKeyUp = _ref.onKeyUp,
|
|
50
50
|
mask = _ref.mask,
|
|
51
51
|
error = _ref.error,
|
|
52
|
-
icon = _ref.icon
|
|
52
|
+
icon = _ref.icon,
|
|
53
|
+
symbolsLimit = _ref.symbolsLimit;
|
|
53
54
|
|
|
54
55
|
// STATES
|
|
55
56
|
var _useState = (0, _react.useState)(false),
|
|
@@ -65,8 +66,8 @@ var Input = function Input(_ref) {
|
|
|
65
66
|
var inputRef = (0, _react.useRef)(null); // HANDLES
|
|
66
67
|
|
|
67
68
|
var handle = {
|
|
68
|
-
change: function change(
|
|
69
|
-
var inputValue =
|
|
69
|
+
change: function change(e) {
|
|
70
|
+
var inputValue = e.target ? e.target.value : e;
|
|
70
71
|
|
|
71
72
|
if (isNumeric || type === 'number' && inputValue !== '') {
|
|
72
73
|
inputValue = parseFloat(inputValue) || '';
|
|
@@ -74,7 +75,7 @@ var Input = function Input(_ref) {
|
|
|
74
75
|
if (min && +min > inputValue) {
|
|
75
76
|
inputValue = min;
|
|
76
77
|
} else if (max && +max < inputValue) inputValue = max;
|
|
77
|
-
}
|
|
78
|
+
} else if (symbolsLimit && inputValue.length > +symbolsLimit) inputValue = inputValue.substring(0, +symbolsLimit);
|
|
78
79
|
|
|
79
80
|
onChange(inputValue.toString());
|
|
80
81
|
},
|
|
@@ -71,6 +71,9 @@ var _default = {
|
|
|
71
71
|
mask: {
|
|
72
72
|
description: 'string: force input to masked https://www.npmjs.com/package/react-input-mask'
|
|
73
73
|
},
|
|
74
|
+
symbolsLimit: {
|
|
75
|
+
description: 'Set limit of symbols in input, overhead will be ignored'
|
|
76
|
+
},
|
|
74
77
|
onBlur: {
|
|
75
78
|
description: 'custom callback on blur'
|
|
76
79
|
},
|
|
@@ -109,5 +112,6 @@ InputTemplate.args = {
|
|
|
109
112
|
max: '5',
|
|
110
113
|
placeholder: 'Placeholder',
|
|
111
114
|
mask: '',
|
|
112
|
-
icon: /*#__PURE__*/_react.default.createElement(_reactFeather.User, null)
|
|
115
|
+
icon: /*#__PURE__*/_react.default.createElement(_reactFeather.User, null),
|
|
116
|
+
symbolsLimit: 225
|
|
113
117
|
};
|
package/dist/Atomic/FormElements/{Calendar/Calendar.stories.js → InputCalendar/InputCalendar.js}
RENAMED
|
@@ -7,54 +7,70 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.
|
|
10
|
+
exports.default = void 0;
|
|
11
11
|
|
|
12
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
13
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
|
-
var _yup = require("yup");
|
|
17
|
-
|
|
18
16
|
var _useClickOutside = require("../../../Functions/useClickOutside");
|
|
19
17
|
|
|
20
|
-
var _Calendar = _interopRequireDefault(require("
|
|
18
|
+
var _Calendar = _interopRequireDefault(require("../Calendar/Calendar"));
|
|
21
19
|
|
|
22
20
|
var _reactInputMask = _interopRequireDefault(require("react-input-mask"));
|
|
23
21
|
|
|
22
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
23
|
+
|
|
24
24
|
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
25
|
|
|
26
26
|
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; }
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
component: _Calendar.default
|
|
32
|
-
};
|
|
33
|
-
exports.default = _default;
|
|
28
|
+
var InputCalendar = function InputCalendar(_ref) {
|
|
29
|
+
var data = _ref.data,
|
|
30
|
+
params = _ref.params;
|
|
34
31
|
|
|
35
|
-
var
|
|
36
|
-
var _useState = (0, _react.useState)(args.date),
|
|
32
|
+
var _useState = (0, _react.useState)(data),
|
|
37
33
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
38
34
|
date = _useState2[0],
|
|
39
|
-
|
|
35
|
+
setDate = _useState2[1];
|
|
40
36
|
|
|
41
|
-
var _useState3 = (0, _react.useState)(
|
|
37
|
+
var _useState3 = (0, _react.useState)(date),
|
|
42
38
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
inputValue = _useState4[0],
|
|
40
|
+
setInputValue = _useState4[1];
|
|
41
|
+
|
|
42
|
+
var _useState5 = (0, _react.useState)(false),
|
|
43
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
44
|
+
isOpened = _useState6[0],
|
|
45
|
+
setIsOpened = _useState6[1];
|
|
45
46
|
|
|
46
47
|
var calendarRef = (0, _react.useRef)(null);
|
|
47
48
|
(0, _useClickOutside.useClickOutside)(calendarRef, function () {
|
|
48
49
|
return setIsOpened(false);
|
|
49
50
|
});
|
|
51
|
+
|
|
52
|
+
var changeInputValue = function changeInputValue(value) {
|
|
53
|
+
if (!value.includes('_') && value) {
|
|
54
|
+
setDate((0, _moment.default)(value).format('L'));
|
|
55
|
+
setInputValue((0, _moment.default)(value).format('L'));
|
|
56
|
+
} else {
|
|
57
|
+
setInputValue(value);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
var changeCalendarDay = function changeCalendarDay(value) {
|
|
62
|
+
setDate(value);
|
|
63
|
+
setInputValue(value);
|
|
64
|
+
};
|
|
65
|
+
|
|
50
66
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
51
67
|
className: "calendar-container",
|
|
52
68
|
ref: calendarRef
|
|
53
69
|
}, /*#__PURE__*/_react.default.createElement(_reactInputMask.default, {
|
|
54
70
|
mask: "99/99/9999",
|
|
55
|
-
value:
|
|
71
|
+
value: inputValue,
|
|
56
72
|
onChange: function onChange(e) {
|
|
57
|
-
return
|
|
73
|
+
return changeInputValue(e.target.value);
|
|
58
74
|
},
|
|
59
75
|
className: "calendar-dropdown",
|
|
60
76
|
onFocus: function onFocus() {
|
|
@@ -63,13 +79,11 @@ var Template = function Template(args) {
|
|
|
63
79
|
}), isOpened ? /*#__PURE__*/_react.default.createElement(_Calendar.default, {
|
|
64
80
|
date: date,
|
|
65
81
|
setDate: function setDate(newDate) {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
82
|
+
return changeCalendarDay(newDate);
|
|
83
|
+
},
|
|
84
|
+
params: params
|
|
68
85
|
}) : null);
|
|
69
86
|
};
|
|
70
87
|
|
|
71
|
-
var
|
|
72
|
-
exports.
|
|
73
|
-
CalendarSimple.args = {
|
|
74
|
-
date: '10/11/2021'
|
|
75
|
-
};
|
|
88
|
+
var _default = InputCalendar;
|
|
89
|
+
exports.default = _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.Calendar = exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _yup = require("yup");
|
|
15
|
+
|
|
16
|
+
var _InputCalendar = _interopRequireDefault(require("./InputCalendar"));
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
global.lng = 'en';
|
|
23
|
+
var _default = {
|
|
24
|
+
title: 'Form Elements/InputCalendar',
|
|
25
|
+
component: _InputCalendar.default
|
|
26
|
+
};
|
|
27
|
+
exports.default = _default;
|
|
28
|
+
|
|
29
|
+
var Template = function Template(args) {
|
|
30
|
+
var params = {
|
|
31
|
+
minDate: args === null || args === void 0 ? void 0 : args.minDate,
|
|
32
|
+
maxDate: args === null || args === void 0 ? void 0 : args.maxDate
|
|
33
|
+
};
|
|
34
|
+
return /*#__PURE__*/_react.default.createElement(_InputCalendar.default, {
|
|
35
|
+
data: args.date,
|
|
36
|
+
params: params
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var Calendar = Template.bind({});
|
|
41
|
+
exports.Calendar = Calendar;
|
|
42
|
+
Calendar.args = {
|
|
43
|
+
date: '10/14/2021',
|
|
44
|
+
minDate: '10/11/2021',
|
|
45
|
+
maxDate: '10/25/2021'
|
|
46
|
+
};
|
package/package.json
CHANGED
|
@@ -5,8 +5,8 @@ import { ChevronLeft, ChevronRight } from 'react-feather';
|
|
|
5
5
|
import './Calendar.scss';
|
|
6
6
|
|
|
7
7
|
export default function (props) {
|
|
8
|
-
const { date, setDate, allowPrev = true, allowNext = true } = props;
|
|
9
|
-
|
|
8
|
+
const { date, setDate, allowPrev = true, allowNext = true, params } = props;
|
|
9
|
+
const { minDate, maxDate } = params;
|
|
10
10
|
const [days, setDays] = useState({});
|
|
11
11
|
|
|
12
12
|
const selectedDay = moment(date);
|
|
@@ -36,15 +36,19 @@ export default function (props) {
|
|
|
36
36
|
const renderDay = (week, dayOfWeek) => {
|
|
37
37
|
const day = days[week][dayOfWeek];
|
|
38
38
|
if (!day) return <div className="calendar__day" />;
|
|
39
|
-
const isFutureDay = day && moment(day.date).isAfter(moment(), 'day');
|
|
39
|
+
const isFutureDay = day && maxDate ? moment(day.date).isAfter(moment(maxDate || ''), 'day') : moment(day.date).isAfter(moment(), 'day');
|
|
40
|
+
const isBeforeDay = day && moment(day.date).isBefore(moment(minDate || ''), 'day');
|
|
40
41
|
|
|
41
42
|
const classNames = cn(
|
|
42
43
|
'calendar__day',
|
|
43
44
|
{ 'calendar__day--clickable': day },
|
|
44
45
|
{ 'calendar__day--disabled': isFutureDay },
|
|
46
|
+
{ 'calendar__day--disabled': isBeforeDay },
|
|
45
47
|
{ 'calendar__day--selected': selectedDay.format() === moment(day.date).format() }
|
|
46
48
|
);
|
|
47
49
|
|
|
50
|
+
// console.log(isMaxDate, isMinDate);
|
|
51
|
+
|
|
48
52
|
return (
|
|
49
53
|
<div
|
|
50
54
|
key={`${week}_${dayOfWeek}`}
|
|
@@ -53,7 +53,7 @@ const Dropdown = ({ options, value, error, onChange, placeholder, className, isS
|
|
|
53
53
|
<span className={cn(`${RC}__active-icon`, { [`${RC}__active-icon_active`]: item.value === value })}>
|
|
54
54
|
<Check />
|
|
55
55
|
</span>
|
|
56
|
-
<div dangerouslySetInnerHTML={{ __html: hightlightedText(item.label) }} />
|
|
56
|
+
<div className={item.className || ''} dangerouslySetInnerHTML={{ __html: hightlightedText(item.label) }} />
|
|
57
57
|
</button>
|
|
58
58
|
) : null;
|
|
59
59
|
|
|
@@ -75,18 +75,23 @@ const Dropdown = ({ options, value, error, onChange, placeholder, className, isS
|
|
|
75
75
|
|
|
76
76
|
return (
|
|
77
77
|
<div className={cn(RC, className)} ref={dropdownRef}>
|
|
78
|
-
<button className={`${RC}__trigger input__wrap ${!value ? 'placeholder' : ''} ${error ? 'error' : ''}`} onClick={() => setIsOpen(!isOpen)}>
|
|
78
|
+
<button className={`${RC}__trigger input__wrap ${!value ? 'placeholder' : ''} ${error ? 'error' : ''}`} onClick={() => !isSearchable ? setIsOpen(!isOpen) : null}>
|
|
79
79
|
{isSearchable ? (
|
|
80
80
|
<input
|
|
81
81
|
className={`${RC}__input`}
|
|
82
82
|
value={searchValue ?? selectedLabel}
|
|
83
83
|
onChange={e => onSearchHandler(e.target.value)}
|
|
84
84
|
placeholder={placeholder}
|
|
85
|
+
onFocus={() => setIsOpen(true)}
|
|
85
86
|
/>
|
|
86
87
|
) : (
|
|
87
|
-
<span className="text">
|
|
88
|
+
<span className="text">
|
|
89
|
+
{selectedLabel || placeholder}
|
|
90
|
+
</span>
|
|
88
91
|
)}
|
|
89
|
-
<span className={cn(`${RC}__arrow`, { [`${RC}__arrow_active`]: isOpen })}
|
|
92
|
+
<span className={cn(`${RC}__arrow`, { [`${RC}__arrow_active`]: isOpen })} onClick={() => setIsOpen(!isOpen)}>
|
|
93
|
+
{isOpen ? <ChevronUp /> : <ChevronDown />}
|
|
94
|
+
</span>
|
|
90
95
|
</button>
|
|
91
96
|
{isOpen && filteredOptions.length > 0 && (
|
|
92
97
|
<div className={`${RC}__list`}>
|
|
@@ -32,7 +32,7 @@ DropdownTemplate.args = {
|
|
|
32
32
|
placeholder: 'Placeholder',
|
|
33
33
|
isSearchable: true,
|
|
34
34
|
options: [
|
|
35
|
-
{ label: 'Dropdown1', value: 'drop1' },
|
|
35
|
+
{ label: 'Dropdown1', value: 'drop1', className: 'status status--approved' },
|
|
36
36
|
{ label: 'Dropdown2', value: 'drop2' },
|
|
37
37
|
{ label: 'Dropdown3', value: 'drop3', disabled: true },
|
|
38
38
|
{ label: 'Dropdown4', value: 'drop4' },
|
|
@@ -23,6 +23,7 @@ const Input = ({
|
|
|
23
23
|
mask,
|
|
24
24
|
error,
|
|
25
25
|
icon,
|
|
26
|
+
symbolsLimit,
|
|
26
27
|
}) => {
|
|
27
28
|
// STATES
|
|
28
29
|
const [isFocused, setIsFocused] = useState(false);
|
|
@@ -30,14 +31,14 @@ const Input = ({
|
|
|
30
31
|
const inputRef = useRef(null);
|
|
31
32
|
// HANDLES
|
|
32
33
|
const handle = {
|
|
33
|
-
change:
|
|
34
|
-
let inputValue =
|
|
34
|
+
change: e => {
|
|
35
|
+
let inputValue = e.target ? e.target.value : e;
|
|
35
36
|
if (isNumeric || (type === 'number' && inputValue !== '')) {
|
|
36
37
|
inputValue = parseFloat(inputValue) || '';
|
|
37
38
|
if (min && +min > inputValue) {
|
|
38
39
|
inputValue = min;
|
|
39
40
|
} else if (max && +max < inputValue) inputValue = max;
|
|
40
|
-
}
|
|
41
|
+
} else if (symbolsLimit && inputValue.length > +symbolsLimit) inputValue = inputValue.substring(0, +symbolsLimit);
|
|
41
42
|
onChange(inputValue.toString());
|
|
42
43
|
},
|
|
43
44
|
toggleEdit: () => {
|
|
@@ -70,7 +71,7 @@ const Input = ({
|
|
|
70
71
|
onBlur: handle.blur,
|
|
71
72
|
onKeyUp: handle.keyUp,
|
|
72
73
|
min,
|
|
73
|
-
max
|
|
74
|
+
max,
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
function renderInput() {
|
|
@@ -43,6 +43,7 @@ export default {
|
|
|
43
43
|
value: { description: '(* - required prop)' },
|
|
44
44
|
className: { description: 'string' },
|
|
45
45
|
mask: { description: 'string: force input to masked https://www.npmjs.com/package/react-input-mask' },
|
|
46
|
+
symbolsLimit: { description: 'Set limit of symbols in input, overhead will be ignored' },
|
|
46
47
|
onBlur: { description: 'custom callback on blur' },
|
|
47
48
|
onFocus: { description: 'custom callback on focus' },
|
|
48
49
|
onKeyUp: { description: 'custom callback on keyup, returns event keyCode' }
|
|
@@ -67,5 +68,6 @@ InputTemplate.args = {
|
|
|
67
68
|
max: '5',
|
|
68
69
|
placeholder: 'Placeholder',
|
|
69
70
|
mask: '',
|
|
70
|
-
icon: <User
|
|
71
|
+
icon: <User />,
|
|
72
|
+
symbolsLimit: 225
|
|
71
73
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import { useClickOutside } from '../../../Functions/useClickOutside';
|
|
3
|
+
import Calendar from '../Calendar/Calendar';
|
|
4
|
+
import InputMask from 'react-input-mask';
|
|
5
|
+
import moment from 'moment';
|
|
6
|
+
|
|
7
|
+
const InputCalendar = ({ data, params }) => {
|
|
8
|
+
const [date, setDate] = useState(data);
|
|
9
|
+
const [inputValue, setInputValue] = useState(date);
|
|
10
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
11
|
+
const calendarRef = useRef(null);
|
|
12
|
+
|
|
13
|
+
useClickOutside(calendarRef, () => setIsOpened(false));
|
|
14
|
+
|
|
15
|
+
const changeInputValue = (value) => {
|
|
16
|
+
if (!value.includes('_') && value) {
|
|
17
|
+
setDate(moment(value).format('L'));
|
|
18
|
+
setInputValue(moment(value).format('L'));
|
|
19
|
+
} else {
|
|
20
|
+
setInputValue(value);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const changeCalendarDay = (value) => {
|
|
25
|
+
setDate(value);
|
|
26
|
+
setInputValue(value);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="calendar-container" ref={calendarRef}>
|
|
31
|
+
<InputMask
|
|
32
|
+
mask="99/99/9999"
|
|
33
|
+
value={inputValue}
|
|
34
|
+
onChange={(e) => changeInputValue(e.target.value)}
|
|
35
|
+
className="calendar-dropdown"
|
|
36
|
+
onFocus={() => setIsOpened(!isOpened)}
|
|
37
|
+
/>
|
|
38
|
+
{isOpened ? <Calendar date={date} setDate={(newDate) => changeCalendarDay(newDate)} params={params} /> : null}
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default InputCalendar;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { ref } from 'yup';
|
|
3
|
+
import InputCalendar from './InputCalendar';
|
|
4
|
+
|
|
5
|
+
global.lng = 'en';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Form Elements/InputCalendar',
|
|
9
|
+
component: InputCalendar,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const Template = (args) => {
|
|
13
|
+
const params = {
|
|
14
|
+
minDate: args?.minDate,
|
|
15
|
+
maxDate: args?.maxDate,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return <InputCalendar data={args.date} params={params} />;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const Calendar = Template.bind({});
|
|
22
|
+
|
|
23
|
+
Calendar.args = {
|
|
24
|
+
date: '10/14/2021',
|
|
25
|
+
minDate: '10/11/2021',
|
|
26
|
+
maxDate: '10/25/2021',
|
|
27
|
+
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
-
import { ref } from 'yup';
|
|
3
|
-
import { useClickOutside } from '../../../Functions/useClickOutside';
|
|
4
|
-
import Calendar from './Calendar';
|
|
5
|
-
import InputMask from 'react-input-mask';
|
|
6
|
-
|
|
7
|
-
global.lng = 'en';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
title: 'Form Elements/Calendar',
|
|
11
|
-
component: Calendar,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const Template = (args) => {
|
|
15
|
-
const [date, setDate] = useState(args.date);
|
|
16
|
-
const [isOpened, setIsOpened] = useState(false);
|
|
17
|
-
const calendarRef = useRef(null);
|
|
18
|
-
useClickOutside(calendarRef, () => setIsOpened(false));
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<div className="calendar-container" ref={calendarRef}>
|
|
22
|
-
<InputMask
|
|
23
|
-
mask="99/99/9999"
|
|
24
|
-
value={date}
|
|
25
|
-
onChange={(e) => setDate(e.target.value)}
|
|
26
|
-
className="calendar-dropdown"
|
|
27
|
-
onFocus={() => setIsOpened(!isOpened)}
|
|
28
|
-
/>
|
|
29
|
-
{isOpened ? <Calendar date={date} setDate={(newDate) => setDate(newDate)} /> : null}
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const CalendarSimple = Template.bind({});
|
|
35
|
-
|
|
36
|
-
CalendarSimple.args = {
|
|
37
|
-
date: '10/11/2021',
|
|
38
|
-
};
|