intelicoreact 0.0.82 → 0.0.86
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/Input/Input.js +12 -8
- package/dist/Atomic/FormElements/Input/Input.stories.js +4 -0
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +34 -32
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +29 -19
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +124 -87
- package/dist/Atomic/FormElements/NumericInput/NumericInput.stories.js +6 -10
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +4 -4
- package/dist/Atomic/UI/Calendar/Calendar.js +6 -4
- package/dist/Atomic/UI/Calendar/Calendar.scss +19 -3
- package/dist/Functions/inputExecutor.js +1 -1
- package/package.json +2 -2
- package/src/Atomic/FormElements/Input/Input.js +13 -9
- package/src/Atomic/FormElements/Input/Input.stories.js +4 -0
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +19 -17
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +17 -14
- package/src/Atomic/FormElements/NumericInput/NumericInput.js +106 -64
- package/src/Atomic/FormElements/NumericInput/NumericInput.stories.js +6 -22
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +4 -4
- package/src/Atomic/UI/Calendar/Calendar.js +3 -3
- package/src/Atomic/UI/Calendar/Calendar.scss +19 -3
- package/src/Functions/inputExecutor.js +6 -15
|
@@ -58,7 +58,9 @@ var Input = function Input(_ref) {
|
|
|
58
58
|
error = _ref.error,
|
|
59
59
|
icon = _ref.icon,
|
|
60
60
|
symbolsLimit = _ref.symbolsLimit,
|
|
61
|
-
blinkTime = _ref.blinkTime
|
|
61
|
+
blinkTime = _ref.blinkTime,
|
|
62
|
+
_ref$isFocusDefault = _ref.isFocusDefault,
|
|
63
|
+
isFocusDefault = _ref$isFocusDefault === void 0 ? false : _ref$isFocusDefault;
|
|
62
64
|
var DEFAULT_BLINK_TIME = 100; // STATES
|
|
63
65
|
|
|
64
66
|
var _useState = (0, _react.useState)(false),
|
|
@@ -109,19 +111,19 @@ var Input = function Input(_ref) {
|
|
|
109
111
|
},
|
|
110
112
|
focus: function focus(e) {
|
|
111
113
|
setIsFocused(true);
|
|
112
|
-
if (isPriceInput && isOnlyNumber
|
|
114
|
+
if (isPriceInput && isOnlyNumber) onChange(removeComma(value));
|
|
113
115
|
if (onFocus) onFocus(e);
|
|
114
116
|
},
|
|
115
117
|
blur: function blur(e) {
|
|
116
118
|
setIsFocused(false);
|
|
117
119
|
setEditing(false);
|
|
118
120
|
|
|
119
|
-
if (
|
|
120
|
-
onChange(
|
|
121
|
+
if (isTwoDigitAfterDot) {
|
|
122
|
+
onChange(cutOffsingleDot(value));
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
if (
|
|
124
|
-
onChange(
|
|
125
|
+
if (isPriceInput && isOnlyNumber) {
|
|
126
|
+
onChange(addCommas(value));
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
if (onBlur) onBlur(e);
|
|
@@ -138,7 +140,6 @@ var Input = function Input(_ref) {
|
|
|
138
140
|
}();
|
|
139
141
|
|
|
140
142
|
if (!_index.KEYBOARD_SERVICE_KEYS.includes(e.key) && changedValue === previousValue) setIsAttemptToChange(true);
|
|
141
|
-
console.log(changedValue, previousValue);
|
|
142
143
|
if (_index.KEYBOARD_SERVICE_KEYS.includes(e.key) || !currentSet) previousValueRef.current = value;else previousValueRef.current = previousValue + currentSet[0];
|
|
143
144
|
}
|
|
144
145
|
|
|
@@ -147,7 +148,7 @@ var Input = function Input(_ref) {
|
|
|
147
148
|
};
|
|
148
149
|
|
|
149
150
|
function cutOffsingleDot(value) {
|
|
150
|
-
return value.slice(-1) === '.' ? value.slice(0, -1) : value;
|
|
151
|
+
return value.toString().slice(-1) === '.' ? value.slice(0, -1) : value;
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
(0, _react.useEffect)(function () {
|
|
@@ -192,6 +193,9 @@ var Input = function Input(_ref) {
|
|
|
192
193
|
}, blinkTime || DEFAULT_BLINK_TIME);
|
|
193
194
|
}
|
|
194
195
|
}, [isAttemptToChange]);
|
|
196
|
+
(0, _react.useEffect)(function () {
|
|
197
|
+
if (inputRef !== null && inputRef !== void 0 && inputRef.current && typeof isFocusDefault === 'boolean') setIsFocused(isFocusDefault);
|
|
198
|
+
}, [inputRef, isFocusDefault]);
|
|
195
199
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
196
200
|
className: (0, _classnames.default)("input__wrap", (0, _defineProperty2.default)({}, "input__wrap_focus", isFocused), (0, _defineProperty2.default)({}, "input__wrap_error", error || isToHighlightError), (0, _defineProperty2.default)({}, "input__wrap_disabled", disabled))
|
|
197
201
|
}, renderInput(), icon, withDelete && /*#__PURE__*/_react.default.createElement("span", {
|
|
@@ -49,6 +49,9 @@ var _default = {
|
|
|
49
49
|
isTwoDigitAfterDot: {
|
|
50
50
|
description: 'boolean - only two digits after dot'
|
|
51
51
|
},
|
|
52
|
+
isFocusDefault: {
|
|
53
|
+
description: 'boolean - if true, input will be focused on mount'
|
|
54
|
+
},
|
|
52
55
|
placeholder: {
|
|
53
56
|
description: 'text'
|
|
54
57
|
},
|
|
@@ -103,6 +106,7 @@ var InputTemplate = Template.bind({});
|
|
|
103
106
|
exports.InputTemplate = InputTemplate;
|
|
104
107
|
InputTemplate.args = {
|
|
105
108
|
type: 'text',
|
|
109
|
+
isFocusDefault: false,
|
|
106
110
|
isOnlyNumber: false,
|
|
107
111
|
isOnlyString: false,
|
|
108
112
|
isPriceInput: false,
|
|
@@ -26,49 +26,48 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
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
28
|
var InputCalendar = function InputCalendar(_ref) {
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
var value = _ref.value,
|
|
30
|
+
minDate = _ref.minDate,
|
|
31
|
+
maxDate = _ref.maxDate,
|
|
32
|
+
onChange = _ref.onChange,
|
|
33
|
+
_ref$className = _ref.className,
|
|
34
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
35
|
+
_ref$placeholder = _ref.placeholder,
|
|
36
|
+
placeholder = _ref$placeholder === void 0 ? 'mm/dd/yyyy' : _ref$placeholder,
|
|
37
|
+
_ref$mask = _ref.mask,
|
|
38
|
+
mask = _ref$mask === void 0 ? '99/99/9999' : _ref$mask;
|
|
39
|
+
|
|
40
|
+
var _useState = (0, _react.useState)(false),
|
|
33
41
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var _useState3 = (0, _react.useState)(date),
|
|
38
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
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];
|
|
42
|
+
isOpened = _useState2[0],
|
|
43
|
+
setIsOpened = _useState2[1];
|
|
46
44
|
|
|
47
45
|
var calendarRef = (0, _react.useRef)(null);
|
|
48
46
|
(0, _useClickOutside.useClickOutside)(calendarRef, function () {
|
|
49
47
|
return setIsOpened(false);
|
|
50
48
|
});
|
|
51
49
|
|
|
52
|
-
var changeInputValue = function changeInputValue(
|
|
53
|
-
if (
|
|
54
|
-
setDate((0, _moment.default)(value).format('L'));
|
|
55
|
-
setInputValue((0, _moment.default)(value).format('L'));
|
|
56
|
-
} else {
|
|
57
|
-
setInputValue(value);
|
|
58
|
-
}
|
|
50
|
+
var changeInputValue = function changeInputValue(val) {
|
|
51
|
+
if (onChange) onChange(val);
|
|
59
52
|
};
|
|
60
53
|
|
|
61
|
-
var changeCalendarDay = function changeCalendarDay(
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
var changeCalendarDay = function changeCalendarDay(val) {
|
|
55
|
+
if (onChange) onChange(val);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var getCalendarValue = function getCalendarValue(value) {
|
|
59
|
+
var date = (0, _moment.default)(value).format('L');
|
|
60
|
+
if (date !== "Invalid date") return date;
|
|
61
|
+
return (0, _moment.default)(new Date()).format('L');
|
|
64
62
|
};
|
|
65
63
|
|
|
66
64
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
67
|
-
className: "calendar-container",
|
|
65
|
+
className: "input__wrap calendar-container ".concat(className),
|
|
68
66
|
ref: calendarRef
|
|
69
67
|
}, /*#__PURE__*/_react.default.createElement(_reactInputMask.default, {
|
|
70
|
-
mask:
|
|
71
|
-
|
|
68
|
+
mask: mask,
|
|
69
|
+
placeholder: placeholder,
|
|
70
|
+
value: value,
|
|
72
71
|
onChange: function onChange(e) {
|
|
73
72
|
return changeInputValue(e.target.value);
|
|
74
73
|
},
|
|
@@ -76,12 +75,15 @@ var InputCalendar = function InputCalendar(_ref) {
|
|
|
76
75
|
onFocus: function onFocus() {
|
|
77
76
|
return setIsOpened(!isOpened);
|
|
78
77
|
}
|
|
79
|
-
}), isOpened ? /*#__PURE__*/_react.default.createElement(_Calendar.default, {
|
|
80
|
-
date:
|
|
78
|
+
}), console.log(value, getCalendarValue(value)), isOpened ? /*#__PURE__*/_react.default.createElement(_Calendar.default, {
|
|
79
|
+
date: getCalendarValue(value),
|
|
81
80
|
setDate: function setDate(newDate) {
|
|
82
81
|
return changeCalendarDay(newDate);
|
|
83
82
|
},
|
|
84
|
-
params:
|
|
83
|
+
params: {
|
|
84
|
+
minDate: minDate,
|
|
85
|
+
maxDate: maxDate
|
|
86
|
+
}
|
|
85
87
|
}) : null);
|
|
86
88
|
};
|
|
87
89
|
|
|
@@ -7,11 +7,13 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.
|
|
10
|
+
exports.CalendarTemplate = exports.default = void 0;
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
17
|
|
|
16
18
|
var _InputCalendar = _interopRequireDefault(require("./InputCalendar"));
|
|
17
19
|
|
|
@@ -21,26 +23,34 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
21
23
|
|
|
22
24
|
global.lng = 'en';
|
|
23
25
|
var _default = {
|
|
24
|
-
title: 'Form Elements/
|
|
25
|
-
component: _InputCalendar.default
|
|
26
|
+
title: 'Form Elements/Input Calendar',
|
|
27
|
+
component: _InputCalendar.default,
|
|
28
|
+
argTypes: {
|
|
29
|
+
value: {
|
|
30
|
+
description: 'string (mm.dd.yyyy)'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
26
33
|
};
|
|
27
34
|
exports.default = _default;
|
|
28
35
|
|
|
29
36
|
var Template = function Template(args) {
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
var _useState = (0, _react.useState)(''),
|
|
38
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
39
|
+
date = _useState2[0],
|
|
40
|
+
setDate = _useState2[1];
|
|
41
|
+
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_InputCalendar.default, (0, _extends2.default)({}, args, {
|
|
43
|
+
value: date,
|
|
44
|
+
onChange: function onChange(val) {
|
|
45
|
+
return setDate(val);
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
38
48
|
};
|
|
39
49
|
|
|
40
|
-
var
|
|
41
|
-
exports.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
minDate: '10/
|
|
45
|
-
maxDate: '10/
|
|
50
|
+
var CalendarTemplate = Template.bind({});
|
|
51
|
+
exports.CalendarTemplate = CalendarTemplate;
|
|
52
|
+
CalendarTemplate.args = {
|
|
53
|
+
value: '',
|
|
54
|
+
minDate: '10/14/2020',
|
|
55
|
+
maxDate: '10/14/2022'
|
|
46
56
|
};
|
|
@@ -37,6 +37,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
37
37
|
|
|
38
38
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
39
39
|
|
|
40
|
+
var timerOutside;
|
|
41
|
+
var timerFocus;
|
|
42
|
+
|
|
40
43
|
var NumericInput = function NumericInput(_ref) {
|
|
41
44
|
var onChange = _ref.onChange,
|
|
42
45
|
disabled = _ref.disabled,
|
|
@@ -49,8 +52,6 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
49
52
|
value = _ref.value,
|
|
50
53
|
placeholder = _ref.placeholder,
|
|
51
54
|
className = _ref.className,
|
|
52
|
-
_ref$type = _ref.type,
|
|
53
|
-
type = _ref$type === void 0 ? 'number' : _ref$type,
|
|
54
55
|
onBlur = _ref.onBlur,
|
|
55
56
|
onFocus = _ref.onFocus,
|
|
56
57
|
onKeyUp = _ref.onKeyUp,
|
|
@@ -62,38 +63,51 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
62
63
|
symbolsLimit = _ref.symbolsLimit,
|
|
63
64
|
isNotBlinkErrors = _ref.isNotBlinkErrors,
|
|
64
65
|
blinkTime = _ref.blinkTime,
|
|
65
|
-
isPriceInput = _ref.isPriceInput
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var
|
|
69
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
70
|
-
isFocused = _useState2[0],
|
|
71
|
-
setIsFocused = _useState2[1];
|
|
72
|
-
|
|
73
|
-
var _useState3 = (0, _react.useState)(false),
|
|
74
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
75
|
-
isEditing = _useState4[0],
|
|
76
|
-
setEditing = _useState4[1];
|
|
66
|
+
isPriceInput = _ref.isPriceInput,
|
|
67
|
+
_ref$isFocusDefault = _ref.isFocusDefault,
|
|
68
|
+
isFocusDefault = _ref$isFocusDefault === void 0 ? false : _ref$isFocusDefault;
|
|
69
|
+
var DEFAULT_BLINK_TIME = 200; //REFS
|
|
77
70
|
|
|
78
71
|
var inputRef = (0, _react.useRef)(null);
|
|
79
72
|
var decRef = (0, _react.useRef)(null);
|
|
80
73
|
var incRef = (0, _react.useRef)(null);
|
|
81
|
-
var
|
|
74
|
+
var wrapRef = (0, _react.useRef)(null);
|
|
75
|
+
var previousValueRef = (0, _react.useRef)(value); // STATES
|
|
76
|
+
|
|
77
|
+
var _useState = (0, _react.useState)(value || min || ''),
|
|
78
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
79
|
+
inputValue = _useState2[0],
|
|
80
|
+
setInputValue = _useState2[1];
|
|
81
|
+
|
|
82
|
+
var _useState3 = (0, _react.useState)(inputValue),
|
|
83
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
84
|
+
inputValueFormated = _useState4[0],
|
|
85
|
+
setInputValueFormated = _useState4[1];
|
|
82
86
|
|
|
83
|
-
var _useState5 = (0, _react.useState)(
|
|
87
|
+
var _useState5 = (0, _react.useState)(0),
|
|
84
88
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
intMemoVal = _useState6[0],
|
|
90
|
+
setIntMemoVal = _useState6[1];
|
|
87
91
|
|
|
88
92
|
var _useState7 = (0, _react.useState)(false),
|
|
89
93
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
isFocused = _useState8[0],
|
|
95
|
+
setIsFocused = _useState8[1];
|
|
92
96
|
|
|
93
|
-
var _useState9 = (0, _react.useState)(
|
|
97
|
+
var _useState9 = (0, _react.useState)(false),
|
|
94
98
|
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
isEditing = _useState10[0],
|
|
100
|
+
setEditing = _useState10[1];
|
|
101
|
+
|
|
102
|
+
var _useState11 = (0, _react.useState)(false),
|
|
103
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
104
|
+
isAttemptToChange = _useState12[0],
|
|
105
|
+
setIsAttemptToChange = _useState12[1];
|
|
106
|
+
|
|
107
|
+
var _useState13 = (0, _react.useState)(false),
|
|
108
|
+
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
109
|
+
isToHighlightError = _useState14[0],
|
|
110
|
+
setIsToHighlightError = _useState14[1];
|
|
97
111
|
|
|
98
112
|
var onlyNumbers = _inputExecutor.formatInput.onlyNumbers;
|
|
99
113
|
var _formatInput$priceInp = _inputExecutor.formatInput.priceInput,
|
|
@@ -104,8 +118,8 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
104
118
|
change: function change(e) {
|
|
105
119
|
var inputValue = e.target ? onlyNumbers(e.target.value) : e;
|
|
106
120
|
|
|
107
|
-
if (inputValue
|
|
108
|
-
inputValue = parseFloat(inputValue)
|
|
121
|
+
if (inputValue && (decRef.current.contains(e.target) || incRef.current.contains(e.target))) {
|
|
122
|
+
inputValue = parseFloat(inputValue);
|
|
109
123
|
|
|
110
124
|
if (min && +min > inputValue) {
|
|
111
125
|
inputValue = min;
|
|
@@ -116,37 +130,27 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
116
130
|
inputValue = inputValue.toString().substring(0, +symbolsLimit);
|
|
117
131
|
}
|
|
118
132
|
|
|
119
|
-
|
|
120
|
-
onChange(inputValue.toString());
|
|
133
|
+
setInputValue(inputValue.toString());
|
|
121
134
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
onChange('');
|
|
135
|
+
clear: function clear() {
|
|
136
|
+
handle.change(min || '');
|
|
125
137
|
},
|
|
126
138
|
focus: function focus(e) {
|
|
139
|
+
if (isFocused) return;
|
|
127
140
|
setIsFocused(true);
|
|
128
|
-
if (isPriceInput) onChange(removeComma(value));
|
|
129
141
|
if (onFocus) onFocus(e);
|
|
130
142
|
},
|
|
131
143
|
blur: function blur(e) {
|
|
144
|
+
if (!isFocused) return;
|
|
132
145
|
setIsFocused(false);
|
|
133
146
|
setEditing(false);
|
|
134
|
-
|
|
135
|
-
if (isPriceInput) {
|
|
136
|
-
if (!isFinite(value)) {
|
|
137
|
-
value = intMemoVal;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
onChange(addCommas(value));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
147
|
if (onBlur) onBlur(e);
|
|
144
148
|
},
|
|
145
149
|
keyUp: function keyUp(e) {
|
|
146
150
|
if (!isNotBlinkErrors) {
|
|
147
|
-
var
|
|
151
|
+
var _previousValueRef$cur;
|
|
148
152
|
|
|
149
|
-
var changedValue = '' + (
|
|
153
|
+
var changedValue = '' + (value !== null && value !== void 0 ? value : '');
|
|
150
154
|
var previousValue = '' + ((_previousValueRef$cur = previousValueRef.current) !== null && _previousValueRef$cur !== void 0 ? _previousValueRef$cur : '');
|
|
151
155
|
|
|
152
156
|
var currentSet = function () {
|
|
@@ -159,23 +163,26 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
159
163
|
|
|
160
164
|
if (onKeyUp) onKeyUp(e.keyCode, e.target.value);
|
|
161
165
|
},
|
|
162
|
-
decrement: function decrement() {
|
|
166
|
+
decrement: function decrement(e) {
|
|
163
167
|
handle.change(intMemoVal - +numStep);
|
|
164
168
|
},
|
|
165
|
-
increment: function increment() {
|
|
169
|
+
increment: function increment(e) {
|
|
166
170
|
handle.change(intMemoVal + +numStep);
|
|
167
171
|
}
|
|
168
|
-
};
|
|
172
|
+
}; //Check Outside Click
|
|
169
173
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
};
|
|
174
|
+
(0, _react.useEffect)(function () {
|
|
175
|
+
var handleClickOutside = function handleClickOutside(event) {
|
|
176
|
+
if (!wrapRef.current.contains(event.target)) {
|
|
177
|
+
setIsFocused(false);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
178
180
|
|
|
181
|
+
document.addEventListener('mousedown', handleClickOutside, true);
|
|
182
|
+
return function () {
|
|
183
|
+
return document.removeEventListener('mousedown', handleClickOutside, true);
|
|
184
|
+
};
|
|
185
|
+
}, []);
|
|
179
186
|
(0, _react.useEffect)(function () {
|
|
180
187
|
if (!isNotBlinkErrors && isAttemptToChange) {
|
|
181
188
|
setIsAttemptToChange(false);
|
|
@@ -184,55 +191,82 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
184
191
|
setIsToHighlightError(false);
|
|
185
192
|
}, blinkTime || DEFAULT_BLINK_TIME);
|
|
186
193
|
}
|
|
187
|
-
}, [isAttemptToChange]);
|
|
194
|
+
}, [isAttemptToChange]); //On Input Value Change
|
|
195
|
+
|
|
188
196
|
(0, _react.useEffect)(function () {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}, []);
|
|
197
|
+
if (inputValue !== value) setIsFocused(true);
|
|
198
|
+
setInputValueFormated(isPriceInput ? isFocused ? removeComma(inputValue) : addCommas(inputValue) : inputValue);
|
|
199
|
+
setIntMemoVal(parseInt(inputValue));
|
|
200
|
+
if (typeof onChange === 'function') onChange(inputValue === null || inputValue === void 0 ? void 0 : inputValue.toString());
|
|
201
|
+
}, [inputValue]); //On Integer Value Change
|
|
202
|
+
|
|
203
|
+
(0, _react.useEffect)(function () {
|
|
204
|
+
if (isNaN(intMemoVal)) setIntMemoVal(min || 0);
|
|
205
|
+
}, [intMemoVal]); //On Focuse Change
|
|
206
|
+
|
|
194
207
|
(0, _react.useEffect)(function () {
|
|
195
|
-
|
|
196
|
-
|
|
208
|
+
setInputValueFormated(isPriceInput ? isFocused ? removeComma(inputValue) : addCommas(inputValue) : inputValue);
|
|
209
|
+
|
|
210
|
+
if (isFocused) {
|
|
211
|
+
var _inputRef$current;
|
|
212
|
+
|
|
213
|
+
if (typeof onFocus === 'function') onFocus({
|
|
214
|
+
target: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current
|
|
215
|
+
});
|
|
216
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
217
|
+
} else {
|
|
218
|
+
var _inputRef$current2;
|
|
219
|
+
|
|
220
|
+
if (typeof onBlur === 'function') onBlur({
|
|
221
|
+
target: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current
|
|
222
|
+
});
|
|
223
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.blur();
|
|
224
|
+
}
|
|
225
|
+
}, [isFocused]);
|
|
197
226
|
(0, _react.useEffect)(function () {
|
|
198
|
-
if (
|
|
199
|
-
}, [
|
|
200
|
-
|
|
201
|
-
var uniProps = _objectSpread(_objectSpread({
|
|
202
|
-
className: "input ".concat(className),
|
|
203
|
-
placeholder: placeholder,
|
|
204
|
-
value: value || '',
|
|
205
|
-
disabled: disabled,
|
|
206
|
-
onChange: handle.change,
|
|
207
|
-
onFocus: handle.focus,
|
|
208
|
-
onBlur: handle.blur,
|
|
209
|
-
onKeyUp: handle.keyUp,
|
|
210
|
-
min: min,
|
|
211
|
-
max: max
|
|
212
|
-
}, maskChar ? {
|
|
213
|
-
maskChar: maskChar
|
|
214
|
-
} : {}), formatChars ? {
|
|
215
|
-
formatChars: formatChars
|
|
216
|
-
} : {});
|
|
227
|
+
if (inputRef !== null && inputRef !== void 0 && inputRef.current && typeof isFocusDefault === 'boolean') setIsFocused(isFocusDefault);
|
|
228
|
+
}, [inputRef, isFocusDefault]);
|
|
217
229
|
|
|
218
230
|
function renderInput() {
|
|
231
|
+
var uniProps = _objectSpread(_objectSpread({
|
|
232
|
+
className: "input ".concat(className || ''),
|
|
233
|
+
placeholder: placeholder,
|
|
234
|
+
value: inputValueFormated,
|
|
235
|
+
disabled: disabled,
|
|
236
|
+
onChange: handle.change,
|
|
237
|
+
onFocus: function onFocus() {
|
|
238
|
+
setIsFocused(true);
|
|
239
|
+
setEditing(true);
|
|
240
|
+
},
|
|
241
|
+
onBlur: function onBlur() {
|
|
242
|
+
return setEditing(false);
|
|
243
|
+
},
|
|
244
|
+
onKeyUp: handle.keyUp,
|
|
245
|
+
min: min,
|
|
246
|
+
max: max
|
|
247
|
+
}, maskChar ? {
|
|
248
|
+
maskChar: maskChar
|
|
249
|
+
} : {}), formatChars ? {
|
|
250
|
+
formatChars: formatChars
|
|
251
|
+
} : {});
|
|
252
|
+
|
|
219
253
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({}, uniProps, {
|
|
220
254
|
ref: inputRef,
|
|
221
|
-
type:
|
|
255
|
+
type: "text"
|
|
222
256
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
223
257
|
className: "input__nums"
|
|
224
258
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
225
259
|
ref: decRef,
|
|
226
|
-
|
|
227
|
-
return handle.decrement();
|
|
260
|
+
onMouseDown: function onMouseDown(e) {
|
|
261
|
+
return handle.decrement(e);
|
|
228
262
|
},
|
|
229
263
|
className: (0, _classnames.default)("input__num-btn", {
|
|
230
264
|
disabled: +value <= min
|
|
231
265
|
})
|
|
232
266
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.Minus, null)), /*#__PURE__*/_react.default.createElement("button", {
|
|
233
267
|
ref: incRef,
|
|
234
|
-
|
|
235
|
-
return handle.increment();
|
|
268
|
+
onMouseDown: function onMouseDown(e) {
|
|
269
|
+
return handle.increment(e);
|
|
236
270
|
},
|
|
237
271
|
className: (0, _classnames.default)("input__num-btn", {
|
|
238
272
|
disabled: +value >= max
|
|
@@ -241,12 +275,15 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
241
275
|
}
|
|
242
276
|
|
|
243
277
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
278
|
+
ref: wrapRef,
|
|
244
279
|
className: (0, _classnames.default)("input__wrap", (0, _defineProperty2.default)({}, "input__wrap_focus", isFocused), (0, _defineProperty2.default)({}, "input__wrap_error", error || isToHighlightError), (0, _defineProperty2.default)({}, "input__wrap_disabled", disabled))
|
|
245
280
|
}, renderInput(), icon, withDelete && /*#__PURE__*/_react.default.createElement("span", {
|
|
246
281
|
className: (0, _classnames.default)("input__close", {
|
|
247
|
-
hidden: !
|
|
282
|
+
hidden: !inputValue
|
|
248
283
|
}),
|
|
249
|
-
onClick:
|
|
284
|
+
onClick: function onClick() {
|
|
285
|
+
return handle.clear();
|
|
286
|
+
}
|
|
250
287
|
}));
|
|
251
288
|
};
|
|
252
289
|
|
|
@@ -31,6 +31,9 @@ var _default = {
|
|
|
31
31
|
disabled: {
|
|
32
32
|
description: 'boolean'
|
|
33
33
|
},
|
|
34
|
+
isFocusDefault: {
|
|
35
|
+
description: 'boolean - if true, input will be focused on mount'
|
|
36
|
+
},
|
|
34
37
|
isInitialFocus: {
|
|
35
38
|
description: 'boolean - if true, the input will be focused on mount'
|
|
36
39
|
},
|
|
@@ -55,13 +58,6 @@ var _default = {
|
|
|
55
58
|
placeholder: {
|
|
56
59
|
description: 'text'
|
|
57
60
|
},
|
|
58
|
-
type: {
|
|
59
|
-
description: "'text', 'number', 'password', 'color', 'date', 'datetime-local', 'month', 'time', 'email', 'range'",
|
|
60
|
-
control: {
|
|
61
|
-
type: 'select',
|
|
62
|
-
options: ['text', 'number', 'password', 'color', 'date', 'datetime-local', 'month', 'time', 'email', 'range']
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
61
|
icon: {
|
|
66
62
|
description: 'JSX'
|
|
67
63
|
},
|
|
@@ -91,7 +87,7 @@ var _default = {
|
|
|
91
87
|
exports.default = _default;
|
|
92
88
|
|
|
93
89
|
var Template = function Template(args) {
|
|
94
|
-
var _useState = (0, _react.useState)(''),
|
|
90
|
+
var _useState = (0, _react.useState)('15000'),
|
|
95
91
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
96
92
|
value = _useState2[0],
|
|
97
93
|
setValue = _useState2[1];
|
|
@@ -105,8 +101,8 @@ var Template = function Template(args) {
|
|
|
105
101
|
var NumericInputTemplate = Template.bind({});
|
|
106
102
|
exports.NumericInputTemplate = NumericInputTemplate;
|
|
107
103
|
NumericInputTemplate.args = {
|
|
108
|
-
type: 'text',
|
|
109
104
|
disabled: false,
|
|
105
|
+
isFocusDefault: false,
|
|
110
106
|
error: '',
|
|
111
107
|
isPriceInput: false,
|
|
112
108
|
mask: '',
|
|
@@ -115,7 +111,7 @@ NumericInputTemplate.args = {
|
|
|
115
111
|
numStep: 100,
|
|
116
112
|
min: '0',
|
|
117
113
|
max: '15000',
|
|
118
|
-
symbolsLimit:
|
|
114
|
+
symbolsLimit: 5,
|
|
119
115
|
placeholder: 'Placeholder',
|
|
120
116
|
icon: /*#__PURE__*/_react.default.createElement(_reactFeather.User, null)
|
|
121
117
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.range-calendar {
|
|
1
|
+
.range-calendar, .calendar {
|
|
2
2
|
width: 195px;
|
|
3
3
|
min-height: 195px;
|
|
4
4
|
display: flex;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
display: flex;
|
|
13
13
|
justify-content: space-between;
|
|
14
14
|
align-items: center;
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
&__title {
|
|
17
17
|
line-height: 20px;
|
|
18
18
|
font-weight: 500;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
&__next, &__prev {
|
|
28
28
|
width: 16px;
|
|
29
29
|
height: 16px;
|
|
30
|
-
background-color: #E2E6F8;
|
|
30
|
+
//background-color: #E2E6F8;
|
|
31
31
|
border-radius: 5px;
|
|
32
32
|
color: #171D33;
|
|
33
33
|
}
|
|
@@ -98,4 +98,4 @@
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
}
|
|
101
|
+
}
|
|
@@ -36,8 +36,10 @@ function _default(props) {
|
|
|
36
36
|
allowNext = _props$allowNext === void 0 ? true : _props$allowNext,
|
|
37
37
|
params = props.params,
|
|
38
38
|
className = props.className;
|
|
39
|
-
var minDate = params.minDate,
|
|
40
|
-
|
|
39
|
+
var _params$minDate = params.minDate,
|
|
40
|
+
minDate = _params$minDate === void 0 ? '01/01/1900' : _params$minDate,
|
|
41
|
+
_params$maxDate = params.maxDate,
|
|
42
|
+
maxDate = _params$maxDate === void 0 ? (0, _moment.default)().format('MM/DD/YYYY') : _params$maxDate;
|
|
41
43
|
|
|
42
44
|
var _useState = (0, _react.useState)({}),
|
|
43
45
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -113,7 +115,7 @@ function _default(props) {
|
|
|
113
115
|
};
|
|
114
116
|
|
|
115
117
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
116
|
-
className: "calendar ".concat(className)
|
|
118
|
+
className: "calendar ".concat(className ? className : "")
|
|
117
119
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
118
120
|
className: "calendar-header"
|
|
119
121
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -132,7 +134,7 @@ function _default(props) {
|
|
|
132
134
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
133
135
|
key: "day-of-week_".concat(dayOfWeek),
|
|
134
136
|
className: "calendar__day calendar__day--title"
|
|
135
|
-
}, (0, _moment.default)().weekday(dayOfWeek).format('dd')
|
|
137
|
+
}, (0, _moment.default)().weekday(dayOfWeek).format('dd'));
|
|
136
138
|
})), Object.keys(days).map(function (week, index) {
|
|
137
139
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
138
140
|
key: "week_".concat(index),
|