intelicoreact 0.0.87 → 0.0.91
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 +43 -19
- package/dist/Atomic/FormElements/Dropdown/Dropdown.scss +6 -0
- package/dist/Atomic/FormElements/Dropdown/Dropdown.stories.js +34 -7
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +23 -0
- package/dist/Atomic/FormElements/Dropdown/components/Loader.scss +57 -0
- package/dist/Atomic/FormElements/Input/Input.js +29 -10
- package/package.json +1 -2
- package/src/Atomic/FormElements/Dropdown/Dropdown.js +66 -35
- package/src/Atomic/FormElements/Dropdown/Dropdown.scss +6 -0
- package/src/Atomic/FormElements/Dropdown/Dropdown.stories.js +22 -8
- package/src/Atomic/FormElements/Dropdown/components/DropdownLoader.js +17 -0
- package/src/Atomic/FormElements/Dropdown/components/Loader.scss +57 -0
- package/src/Atomic/FormElements/Input/Input.js +46 -34
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
exports.default = void 0;
|
|
11
11
|
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
+
|
|
12
14
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
15
|
|
|
14
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -21,11 +23,13 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
21
23
|
|
|
22
24
|
var _reactFeather = require("react-feather");
|
|
23
25
|
|
|
26
|
+
var _DropdownLoader = _interopRequireDefault(require("./components/DropdownLoader"));
|
|
27
|
+
|
|
24
28
|
require("./Dropdown.scss");
|
|
25
29
|
|
|
26
30
|
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); }
|
|
27
31
|
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
|
|
29
33
|
|
|
30
34
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
31
35
|
|
|
@@ -34,29 +38,32 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
34
38
|
var RC = 'dropdown';
|
|
35
39
|
|
|
36
40
|
var Dropdown = function Dropdown(_ref) {
|
|
37
|
-
var _options$find
|
|
41
|
+
var _options$find;
|
|
38
42
|
|
|
39
43
|
var _ref$options = _ref.options,
|
|
40
44
|
options = _ref$options === void 0 ? [] : _ref$options,
|
|
41
45
|
value = _ref.value,
|
|
42
46
|
error = _ref.error,
|
|
47
|
+
disabled = _ref.disabled,
|
|
43
48
|
onChange = _ref.onChange,
|
|
44
49
|
placeholder = _ref.placeholder,
|
|
45
50
|
className = _ref.className,
|
|
46
51
|
isSearchable = _ref.isSearchable,
|
|
47
|
-
entity = _ref.entity
|
|
52
|
+
entity = _ref.entity,
|
|
53
|
+
scrollReactionObj = _ref.scrollReactionObj;
|
|
48
54
|
|
|
49
55
|
var _useState = (0, _react.useState)(false),
|
|
50
56
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
51
57
|
isOpen = _useState2[0],
|
|
52
58
|
setIsOpen = _useState2[1];
|
|
53
59
|
|
|
54
|
-
var _useState3 = (0, _react.useState)(
|
|
60
|
+
var _useState3 = (0, _react.useState)(),
|
|
55
61
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
56
62
|
searchValue = _useState4[0],
|
|
57
63
|
setSearchValue = _useState4[1];
|
|
58
64
|
|
|
59
65
|
var dropdownRef = (0, _react.useRef)(null);
|
|
66
|
+
var dropdownListRef = (0, _react.useRef)(null);
|
|
60
67
|
if (!options) return null;
|
|
61
68
|
var filteredGroups = options.filter(function (item) {
|
|
62
69
|
var _item$items;
|
|
@@ -153,14 +160,6 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
153
160
|
})) : null;
|
|
154
161
|
};
|
|
155
162
|
|
|
156
|
-
(0, _react.useEffect)(function () {
|
|
157
|
-
if (!value) setSearchValue(null);
|
|
158
|
-
document.addEventListener('click', handleClickOutside, true);
|
|
159
|
-
return function () {
|
|
160
|
-
return document.removeEventListener('click', handleClickOutside, true);
|
|
161
|
-
};
|
|
162
|
-
}, [value]);
|
|
163
|
-
|
|
164
163
|
var filteredOptionList = function filteredOptionList(filteredOption) {
|
|
165
164
|
var _filteredOption$items;
|
|
166
165
|
|
|
@@ -183,8 +182,34 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
183
182
|
return el.value === value;
|
|
184
183
|
})) === null || _item$items4$find === void 0 ? void 0 : _item$items4$find.label);
|
|
185
184
|
}, null);
|
|
185
|
+
var doScrollCallback = (0, _react.useCallback)(function (e) {
|
|
186
|
+
var callback = scrollReactionObj.callback,
|
|
187
|
+
isWithAnyScrolling = scrollReactionObj.isWithAnyScrolling;
|
|
188
|
+
|
|
189
|
+
if (callback && typeof callback === 'function') {
|
|
190
|
+
if (isWithAnyScrolling) callback(e);else if (e.target.clientHeight + e.target.scrollTop >= e.target.scrollHeight) callback(e);
|
|
191
|
+
}
|
|
192
|
+
}, [filteredOptions]);
|
|
193
|
+
(0, _react.useEffect)(function () {
|
|
194
|
+
if (!value) setSearchValue(null);
|
|
195
|
+
document.addEventListener('click', handleClickOutside, true);
|
|
196
|
+
return function () {
|
|
197
|
+
return document.removeEventListener('click', handleClickOutside, true);
|
|
198
|
+
};
|
|
199
|
+
}, [value]);
|
|
200
|
+
(0, _react.useEffect)(function () {
|
|
201
|
+
if (scrollReactionObj && (0, _typeof2.default)(scrollReactionObj) === 'object' && isOpen && dropdownListRef && dropdownListRef.current) {
|
|
202
|
+
dropdownListRef.current.addEventListener('scroll', doScrollCallback);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return function () {
|
|
206
|
+
if (scrollReactionObj && (0, _typeof2.default)(scrollReactionObj) === 'object') removeEventListener('scroll', doScrollCallback);
|
|
207
|
+
};
|
|
208
|
+
}, [isOpen, dropdownListRef]);
|
|
186
209
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
187
|
-
className: (0, _classnames.default)(RC, className
|
|
210
|
+
className: (0, _classnames.default)(RC, className, {
|
|
211
|
+
disabled: disabled
|
|
212
|
+
}),
|
|
188
213
|
ref: dropdownRef
|
|
189
214
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
190
215
|
className: "".concat(RC, "__trigger input__wrap ").concat(!value ? 'placeholder' : '', " ").concat(error ? 'error' : ''),
|
|
@@ -193,9 +218,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
193
218
|
}
|
|
194
219
|
}, isSearchable ? /*#__PURE__*/_react.default.createElement("input", {
|
|
195
220
|
className: "".concat(RC, "__input"),
|
|
196
|
-
value: searchValue ||
|
|
197
|
-
return el.value === value;
|
|
198
|
-
})) === null || _filteredOptions$find === void 0 ? void 0 : _filteredOptions$find.label) || '',
|
|
221
|
+
value: searchValue || selectedLabel || '',
|
|
199
222
|
onChange: function onChange(e) {
|
|
200
223
|
onSearchHandler(e.target.value);
|
|
201
224
|
},
|
|
@@ -212,12 +235,13 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
212
235
|
return setIsOpen(!isOpen);
|
|
213
236
|
}
|
|
214
237
|
}, isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen && filteredOptions.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
215
|
-
className: "".concat(RC, "__list")
|
|
238
|
+
className: "".concat(RC, "__list"),
|
|
239
|
+
ref: dropdownListRef
|
|
216
240
|
}, depend.options.map(function (filteredOption) {
|
|
217
241
|
var _filteredOption$items2;
|
|
218
242
|
|
|
219
243
|
return (_filteredOption$items2 = filteredOption.items) !== null && _filteredOption$items2 !== void 0 && _filteredOption$items2.length ? filteredOptionList(filteredOption) : getMarkupForElement(filteredOption);
|
|
220
|
-
})));
|
|
244
|
+
}), disabled && isOpen && /*#__PURE__*/_react.default.createElement(_DropdownLoader.default, null)));
|
|
221
245
|
};
|
|
222
246
|
|
|
223
247
|
var _default = Dropdown;
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
&__list {
|
|
48
|
+
position: relative;
|
|
48
49
|
background: #ffffff;
|
|
49
50
|
border: 1px solid #e2e5ec;
|
|
50
51
|
box-shadow: 0 5px 20px rgb(0 0 0 / 15%);
|
|
@@ -177,4 +178,9 @@
|
|
|
177
178
|
font-size: 10px;
|
|
178
179
|
color: $color--secondary;
|
|
179
180
|
}
|
|
181
|
+
|
|
182
|
+
&.disabled {
|
|
183
|
+
pointer-events: none;
|
|
184
|
+
opacity: 0.5;
|
|
185
|
+
}
|
|
180
186
|
}
|
|
@@ -44,32 +44,59 @@ var _default = {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
exports.default = _default;
|
|
47
|
+
var blockStyles = {
|
|
48
|
+
display: 'flex',
|
|
49
|
+
flexFlow: 'row no-wrap',
|
|
50
|
+
alignItems: 'center'
|
|
51
|
+
};
|
|
47
52
|
var buttonStyles = {
|
|
48
53
|
border: 'solid 1px #000',
|
|
49
|
-
padding: '5px'
|
|
54
|
+
padding: '5px',
|
|
55
|
+
margin: '0 0 0 50px'
|
|
50
56
|
};
|
|
51
57
|
|
|
52
58
|
var Template = function Template(args) {
|
|
53
|
-
var _useState = (0, _react.useState)(
|
|
59
|
+
var _useState = (0, _react.useState)(args.value),
|
|
54
60
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
55
61
|
value = _useState2[0],
|
|
56
62
|
setValue = _useState2[1];
|
|
57
63
|
|
|
58
|
-
|
|
64
|
+
var _useState3 = (0, _react.useState)(false),
|
|
65
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
66
|
+
disabled = _useState4[0],
|
|
67
|
+
setDisabled = _useState4[1];
|
|
68
|
+
|
|
69
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
70
|
+
style: blockStyles
|
|
71
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
72
|
+
key: "dropdown",
|
|
59
73
|
style: {
|
|
60
74
|
width: 200
|
|
61
75
|
}
|
|
62
76
|
}, /*#__PURE__*/_react.default.createElement(_Dropdown.default, (0, _extends2.default)({}, args, {
|
|
63
77
|
value: value,
|
|
64
|
-
onChange: setValue
|
|
78
|
+
onChange: setValue,
|
|
79
|
+
disabled: disabled,
|
|
80
|
+
scrollReactionObj: {
|
|
81
|
+
callback: function callback(e) {
|
|
82
|
+
return setDisabled(true);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
65
85
|
}))), /*#__PURE__*/_react.default.createElement("button", {
|
|
86
|
+
key: "reset",
|
|
87
|
+
style: buttonStyles,
|
|
88
|
+
className: "mt10",
|
|
89
|
+
onClick: function onClick() {
|
|
90
|
+
return setValue('');
|
|
91
|
+
}
|
|
92
|
+
}, "Reset"), /*#__PURE__*/_react.default.createElement("button", {
|
|
93
|
+
key: "enable/disable",
|
|
66
94
|
style: buttonStyles,
|
|
67
95
|
className: "mt10",
|
|
68
96
|
onClick: function onClick() {
|
|
69
|
-
|
|
70
|
-
setValue('');
|
|
97
|
+
return setDisabled(!disabled);
|
|
71
98
|
}
|
|
72
|
-
},
|
|
99
|
+
}, disabled ? 'enable' : 'disable'));
|
|
73
100
|
};
|
|
74
101
|
|
|
75
102
|
var DropdownTemplate = Template.bind({});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
require("./Loader.scss");
|
|
13
|
+
|
|
14
|
+
var DropdownLoader = function DropdownLoader() {
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
16
|
+
className: "dropdown-loader-box j5"
|
|
17
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
18
|
+
className: "lds-ring".concat(variant === 'little' ? ' lds-ring_little' : '')
|
|
19
|
+
}, /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("div", null)));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var _default = DropdownLoader;
|
|
23
|
+
exports.default = _default;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
@mixin fill-parent {
|
|
2
|
+
left: 0;
|
|
3
|
+
top: 0;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.dropdown-loader-box {
|
|
9
|
+
position: absolute;
|
|
10
|
+
@include fill-parent;
|
|
11
|
+
background: #fff;
|
|
12
|
+
opacity: 0.1;
|
|
13
|
+
z-index: 100;
|
|
14
|
+
}
|
|
15
|
+
.lds-ring {
|
|
16
|
+
display: inline-block;
|
|
17
|
+
position: relative;
|
|
18
|
+
width: 100px;
|
|
19
|
+
height: 100px;
|
|
20
|
+
}
|
|
21
|
+
.lds-ring.lds-ring_little {
|
|
22
|
+
width: 20px;
|
|
23
|
+
height: 20px;
|
|
24
|
+
}
|
|
25
|
+
.lds-ring div {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
display: block;
|
|
28
|
+
position: absolute;
|
|
29
|
+
width: 84px;
|
|
30
|
+
height: 84px;
|
|
31
|
+
margin: 8px;
|
|
32
|
+
border: 8px solid #000;
|
|
33
|
+
border-radius: 50%;
|
|
34
|
+
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
|
35
|
+
border-color: #000 transparent transparent transparent;
|
|
36
|
+
}
|
|
37
|
+
.lds-ring_little div {
|
|
38
|
+
width: 20px;
|
|
39
|
+
height: 20px;
|
|
40
|
+
}
|
|
41
|
+
.lds-ring div:nth-child(1) {
|
|
42
|
+
animation-delay: -0.45s;
|
|
43
|
+
}
|
|
44
|
+
.lds-ring div:nth-child(2) {
|
|
45
|
+
animation-delay: -0.3s;
|
|
46
|
+
}
|
|
47
|
+
.lds-ring div:nth-child(3) {
|
|
48
|
+
animation-delay: -0.15s;
|
|
49
|
+
}
|
|
50
|
+
@keyframes lds-ring {
|
|
51
|
+
0% {
|
|
52
|
+
transform: rotate(0deg);
|
|
53
|
+
}
|
|
54
|
+
100% {
|
|
55
|
+
transform: rotate(360deg);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -90,7 +90,8 @@ var Input = function Input(_ref) {
|
|
|
90
90
|
onlyString = _inputExecutor.formatInput.onlyString;
|
|
91
91
|
var _formatInput$priceInp = _inputExecutor.formatInput.priceInput,
|
|
92
92
|
addCommas = _formatInput$priceInp.addCommas,
|
|
93
|
-
removeComma = _formatInput$priceInp.removeComma;
|
|
93
|
+
removeComma = _formatInput$priceInp.removeComma;
|
|
94
|
+
var isUseErrorsBlink = !isNotBlinkErrors && !mask; // HANDLES
|
|
94
95
|
|
|
95
96
|
var handle = {
|
|
96
97
|
change: function change(e) {
|
|
@@ -129,18 +130,36 @@ var Input = function Input(_ref) {
|
|
|
129
130
|
if (onBlur) onBlur(e);
|
|
130
131
|
},
|
|
131
132
|
keyUp: function keyUp(e) {
|
|
132
|
-
if (
|
|
133
|
+
if (isUseErrorsBlink) {
|
|
133
134
|
var _previousValueRef$cur;
|
|
134
135
|
|
|
135
136
|
var changedValue = '' + (value !== null && value !== void 0 ? value : '');
|
|
136
137
|
var previousValue = '' + ((_previousValueRef$cur = previousValueRef.current) !== null && _previousValueRef$cur !== void 0 ? _previousValueRef$cur : '');
|
|
137
|
-
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
var short = previousValue.length <= changedValue.length ? previousValue : changedValue;
|
|
139
|
+
var long = previousValue.length > changedValue.length ? previousValue : changedValue;
|
|
140
|
+
var infoAboutDifferencesSameness = short.split('').reduce(function (acc, symbol, idx) {
|
|
141
|
+
if (acc.countOn && symbol === long[idx]) acc.same.push(symbol);else {
|
|
142
|
+
acc.countOn = false;
|
|
143
|
+
acc.differences.push([idx, symbol]);
|
|
144
|
+
}
|
|
145
|
+
return acc;
|
|
146
|
+
}, {
|
|
147
|
+
same: [],
|
|
148
|
+
countOn: true,
|
|
149
|
+
differences: []
|
|
150
|
+
});
|
|
151
|
+
var samePart = infoAboutDifferencesSameness.same.join('');
|
|
152
|
+
var differencesLength = infoAboutDifferencesSameness.differences.length;
|
|
153
|
+
var currentSet = changedValue.replace(samePart, '');
|
|
154
|
+
|
|
155
|
+
var getNext = function getNext(inputPartToAdd, correctedSamePart) {
|
|
156
|
+
var partToAdd = inputPartToAdd || currentSet;
|
|
157
|
+
var currentSamePart = correctedSamePart || samePart;
|
|
158
|
+
return changedValue.includes(e.key) && e.key !== changedValue[changedValue.length - 1] ? currentSamePart + (partToAdd[0] || '') : changedValue;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
if (!_index.KEYBOARD_SERVICE_KEYS.includes(e.key) && changedValue === previousValue) setIsAttemptToChange(!(!differencesLength && e.key === changedValue[changedValue.length - 2]));
|
|
162
|
+
if (!previousValueRef.current || _index.KEYBOARD_SERVICE_KEYS.includes(e.key)) previousValueRef.current = getNext();else if (changedValue === samePart) previousValueRef.current = getNext(changedValue, changedValue.slice(0, -1));else previousValueRef.current = getNext();
|
|
144
163
|
}
|
|
145
164
|
|
|
146
165
|
if (onKeyUp) onKeyUp(e.keyCode, e);
|
|
@@ -185,7 +204,7 @@ var Input = function Input(_ref) {
|
|
|
185
204
|
}
|
|
186
205
|
|
|
187
206
|
(0, _react.useEffect)(function () {
|
|
188
|
-
if (
|
|
207
|
+
if (isUseErrorsBlink && isAttemptToChange) {
|
|
189
208
|
setIsAttemptToChange(null);
|
|
190
209
|
setIsToHighlightError(true);
|
|
191
210
|
setTimeout(function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intelicoreact",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.91",
|
|
4
4
|
"description": "fix input-calendar",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,6 +23,5 @@
|
|
|
23
23
|
"@babel/polyfill": "^7.12.1",
|
|
24
24
|
"@babel/preset-env": "^7.15.6",
|
|
25
25
|
"anme": "^1.0.0"
|
|
26
|
-
|
|
27
26
|
}
|
|
28
27
|
}
|
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect } from 'react';
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { Check, ChevronDown, ChevronUp } from 'react-feather';
|
|
4
4
|
|
|
5
|
+
import DropdownLoader from './components/DropdownLoader';
|
|
6
|
+
|
|
5
7
|
import './Dropdown.scss';
|
|
6
8
|
|
|
7
9
|
const RC = 'dropdown';
|
|
8
10
|
|
|
9
|
-
const Dropdown = ({ options = [], value, error, onChange, placeholder, className, isSearchable, entity }) => {
|
|
11
|
+
const Dropdown = ({ options = [], value, error, disabled, onChange, placeholder, className, isSearchable, entity, scrollReactionObj }) => {
|
|
10
12
|
const [isOpen, setIsOpen] = useState(false);
|
|
11
|
-
const [searchValue, setSearchValue] = useState(
|
|
13
|
+
const [searchValue, setSearchValue] = useState();
|
|
12
14
|
const dropdownRef = useRef(null);
|
|
15
|
+
const dropdownListRef = useRef(null);
|
|
16
|
+
|
|
13
17
|
if (!options) return null;
|
|
14
18
|
const filteredGroups = options
|
|
15
|
-
.filter(item => item.items?.length)
|
|
16
|
-
.map(item => ({ ...item, items: item.items.filter(el => el?.label?.toLowerCase().includes(searchValue?.toLowerCase() || '')) }))
|
|
17
|
-
.filter(item => item.items?.length > 0);
|
|
19
|
+
.filter((item) => item.items?.length)
|
|
20
|
+
.map((item) => ({ ...item, items: item.items.filter((el) => el?.label?.toLowerCase().includes(searchValue?.toLowerCase() || '')) }))
|
|
21
|
+
.filter((item) => item.items?.length > 0);
|
|
18
22
|
|
|
19
23
|
const filteredItems = options
|
|
20
|
-
.filter(item => !item.items?.length)
|
|
21
|
-
.filter(item => item?.label?.toLowerCase().includes(searchValue?.toLowerCase() || ''));
|
|
24
|
+
.filter((item) => !item.items?.length)
|
|
25
|
+
.filter((item) => item?.label?.toLowerCase().includes(searchValue?.toLowerCase() || ''));
|
|
22
26
|
|
|
23
27
|
const filteredOptions = [...filteredItems, ...filteredGroups];
|
|
24
28
|
|
|
25
29
|
const modalBtnTrigger = entity && entity !== '' && typeof entity === 'string';
|
|
26
|
-
const onChangeHandler = item => {
|
|
30
|
+
const onChangeHandler = (item) => {
|
|
27
31
|
setIsOpen(false);
|
|
28
32
|
setSearchValue(null);
|
|
29
33
|
onChange(item.value);
|
|
30
34
|
};
|
|
31
35
|
// decorator
|
|
32
|
-
const getDepends = getDependsTrigger => {
|
|
33
|
-
const newOnChange = e => {
|
|
36
|
+
const getDepends = (getDependsTrigger) => {
|
|
37
|
+
const newOnChange = (e) => {
|
|
34
38
|
if (e.value === 'open_modal') {
|
|
35
39
|
onChange('open_modal');
|
|
36
40
|
} else {
|
|
@@ -43,34 +47,34 @@ const Dropdown = ({ options = [], value, error, onChange, placeholder, className
|
|
|
43
47
|
{
|
|
44
48
|
label: `New ${entity}`,
|
|
45
49
|
value: 'open_modal',
|
|
46
|
-
className: 'dropdown__list-item--modal'
|
|
50
|
+
className: 'dropdown__list-item--modal',
|
|
47
51
|
},
|
|
48
|
-
...filteredOptions
|
|
52
|
+
...filteredOptions,
|
|
49
53
|
];
|
|
50
54
|
|
|
51
55
|
return {
|
|
52
|
-
onChange: changeItem => (getDependsTrigger ? newOnChange(changeItem) : onChangeHandler(changeItem)),
|
|
53
|
-
options: getDependsTrigger ? newOptions : options
|
|
56
|
+
onChange: (changeItem) => (getDependsTrigger ? newOnChange(changeItem) : onChangeHandler(changeItem)),
|
|
57
|
+
options: getDependsTrigger ? newOptions : options,
|
|
54
58
|
};
|
|
55
59
|
};
|
|
56
60
|
|
|
57
|
-
const handleClickOutside = event => {
|
|
61
|
+
const handleClickOutside = (event) => {
|
|
58
62
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
59
63
|
setIsOpen(false);
|
|
60
64
|
setSearchValue(null);
|
|
61
65
|
}
|
|
62
66
|
};
|
|
63
67
|
|
|
64
|
-
const onSearchHandler = name => {
|
|
68
|
+
const onSearchHandler = (name) => {
|
|
65
69
|
setSearchValue(name);
|
|
66
70
|
};
|
|
67
71
|
|
|
68
|
-
const hightlightedText = text =>
|
|
69
|
-
searchValue ? text?.replace(new RegExp(searchValue, 'i'), match => `<span class="bg--yellow">${match}</span>`) : text;
|
|
72
|
+
const hightlightedText = (text) =>
|
|
73
|
+
searchValue ? text?.replace(new RegExp(searchValue, 'i'), (match) => `<span class="bg--yellow">${match}</span>`) : text;
|
|
70
74
|
|
|
71
75
|
const depend = getDepends(modalBtnTrigger);
|
|
72
76
|
|
|
73
|
-
const getMarkupForElement = item =>
|
|
77
|
+
const getMarkupForElement = (item) =>
|
|
74
78
|
item.label.toLowerCase().includes(searchValue?.toLowerCase() || '') ? (
|
|
75
79
|
<button
|
|
76
80
|
key={item.value}
|
|
@@ -84,25 +88,51 @@ const Dropdown = ({ options = [], value, error, onChange, placeholder, className
|
|
|
84
88
|
</button>
|
|
85
89
|
) : null;
|
|
86
90
|
|
|
87
|
-
|
|
88
|
-
if (!value) setSearchValue(null);
|
|
89
|
-
document.addEventListener('click', handleClickOutside, true);
|
|
90
|
-
return () => document.removeEventListener('click', handleClickOutside, true);
|
|
91
|
-
}, [value]);
|
|
92
|
-
|
|
93
|
-
const filteredOptionList = filteredOption =>
|
|
91
|
+
const filteredOptionList = (filteredOption) =>
|
|
94
92
|
filteredOption.items?.length > 0 ? (
|
|
95
93
|
<div key={filteredOption.value} className={`${RC}-group`}>
|
|
96
94
|
<div className={`${RC}-group__name`}>{filteredOption.label}</div>
|
|
97
|
-
{filteredOption.items.map(el => getMarkupForElement(el))}
|
|
95
|
+
{filteredOption.items.map((el) => getMarkupForElement(el))}
|
|
98
96
|
</div>
|
|
99
97
|
) : null;
|
|
100
98
|
|
|
101
99
|
const selectedLabel =
|
|
102
|
-
options.find(el => el.value === value)?.label ||
|
|
100
|
+
options.find((el) => el.value === value)?.label ||
|
|
101
|
+
options.reduce((acc, item) => acc || item.items?.find((el) => el.value === value)?.label, null);
|
|
102
|
+
|
|
103
|
+
const doScrollCallback = useCallback(
|
|
104
|
+
(e) => {
|
|
105
|
+
const { callback, isWithAnyScrolling } = scrollReactionObj;
|
|
106
|
+
if (callback && typeof callback === 'function') {
|
|
107
|
+
if (isWithAnyScrolling) callback(e);
|
|
108
|
+
else if (e.target.clientHeight + e.target.scrollTop >= e.target.scrollHeight) callback(e);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
[filteredOptions]
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!value) setSearchValue(null);
|
|
116
|
+
document.addEventListener('click', handleClickOutside, true);
|
|
117
|
+
return () => document.removeEventListener('click', handleClickOutside, true);
|
|
118
|
+
}, [value]);
|
|
119
|
+
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (scrollReactionObj && typeof scrollReactionObj === 'object' && isOpen && dropdownListRef && dropdownListRef.current) {
|
|
122
|
+
dropdownListRef.current.addEventListener('scroll', doScrollCallback);
|
|
123
|
+
}
|
|
124
|
+
return () => {
|
|
125
|
+
if (scrollReactionObj && typeof scrollReactionObj === 'object') removeEventListener('scroll', doScrollCallback);
|
|
126
|
+
};
|
|
127
|
+
}, [isOpen, dropdownListRef]);
|
|
103
128
|
|
|
104
129
|
return (
|
|
105
|
-
<div
|
|
130
|
+
<div
|
|
131
|
+
className={cn(RC, className, {
|
|
132
|
+
disabled: disabled,
|
|
133
|
+
})}
|
|
134
|
+
ref={dropdownRef}
|
|
135
|
+
>
|
|
106
136
|
<button
|
|
107
137
|
className={`${RC}__trigger input__wrap ${!value ? 'placeholder' : ''} ${error ? 'error' : ''}`}
|
|
108
138
|
onClick={() => (!isSearchable ? setIsOpen(!isOpen) : null)}
|
|
@@ -110,12 +140,12 @@ const Dropdown = ({ options = [], value, error, onChange, placeholder, className
|
|
|
110
140
|
{isSearchable ? (
|
|
111
141
|
<input
|
|
112
142
|
className={`${RC}__input`}
|
|
113
|
-
value={searchValue ||
|
|
114
|
-
onChange={e => {
|
|
143
|
+
value={searchValue || selectedLabel || ''}
|
|
144
|
+
onChange={(e) => {
|
|
115
145
|
onSearchHandler(e.target.value);
|
|
116
146
|
}}
|
|
117
147
|
placeholder={placeholder}
|
|
118
|
-
onFocus={e => {
|
|
148
|
+
onFocus={(e) => {
|
|
119
149
|
e.target.select();
|
|
120
150
|
setIsOpen(true);
|
|
121
151
|
}}
|
|
@@ -128,10 +158,11 @@ const Dropdown = ({ options = [], value, error, onChange, placeholder, className
|
|
|
128
158
|
</span>
|
|
129
159
|
</button>
|
|
130
160
|
{isOpen && filteredOptions.length > 0 && (
|
|
131
|
-
<div className={`${RC}__list`}>
|
|
132
|
-
{depend.options.map(filteredOption =>
|
|
161
|
+
<div className={`${RC}__list`} ref={dropdownListRef}>
|
|
162
|
+
{depend.options.map((filteredOption) =>
|
|
133
163
|
filteredOption.items?.length ? filteredOptionList(filteredOption) : getMarkupForElement(filteredOption)
|
|
134
164
|
)}
|
|
165
|
+
{disabled && isOpen && <DropdownLoader />}
|
|
135
166
|
</div>
|
|
136
167
|
)}
|
|
137
168
|
</div>
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
&__list {
|
|
48
|
+
position: relative;
|
|
48
49
|
background: #ffffff;
|
|
49
50
|
border: 1px solid #e2e5ec;
|
|
50
51
|
box-shadow: 0 5px 20px rgb(0 0 0 / 15%);
|
|
@@ -177,4 +178,9 @@
|
|
|
177
178
|
font-size: 10px;
|
|
178
179
|
color: $color--secondary;
|
|
179
180
|
}
|
|
181
|
+
|
|
182
|
+
&.disabled {
|
|
183
|
+
pointer-events: none;
|
|
184
|
+
opacity: 0.5;
|
|
185
|
+
}
|
|
180
186
|
}
|
|
@@ -20,20 +20,34 @@ export default {
|
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const blockStyles = {
|
|
24
|
+
display: 'flex',
|
|
25
|
+
flexFlow: 'row no-wrap',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const buttonStyles = {
|
|
24
30
|
border: 'solid 1px #000',
|
|
25
|
-
padding: '5px'
|
|
31
|
+
padding: '5px',
|
|
32
|
+
margin: '0 0 0 50px',
|
|
26
33
|
};
|
|
27
34
|
|
|
28
35
|
const Template = (args) => {
|
|
29
|
-
const [value, setValue] = useState(
|
|
36
|
+
const [value, setValue] = useState(args.value);
|
|
37
|
+
const [disabled, setDisabled] = useState(false);
|
|
30
38
|
return (
|
|
31
|
-
|
|
32
|
-
<div style={{ width: 200 }}>
|
|
33
|
-
<Dropdown {...args} value={value} onChange={setValue} />
|
|
39
|
+
<div style={blockStyles}>
|
|
40
|
+
<div key="dropdown" style={{ width: 200 }}>
|
|
41
|
+
<Dropdown {...args} value={value} onChange={setValue} disabled={disabled} scrollReactionObj={{ callback: (e) => setDisabled(true) }} />
|
|
34
42
|
</div>
|
|
35
|
-
<button style={buttonStyles} className=
|
|
36
|
-
|
|
43
|
+
<button key="reset" style={buttonStyles} className="mt10" onClick={() => setValue('')}>
|
|
44
|
+
Reset
|
|
45
|
+
</button>
|
|
46
|
+
|
|
47
|
+
<button key="enable/disable" style={buttonStyles} className="mt10" onClick={() => setDisabled(!disabled)}>
|
|
48
|
+
{disabled ? 'enable' : 'disable'}
|
|
49
|
+
</button>
|
|
50
|
+
</div>
|
|
37
51
|
);
|
|
38
52
|
};
|
|
39
53
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './Loader.scss';
|
|
3
|
+
|
|
4
|
+
const DropdownLoader = function () {
|
|
5
|
+
return (
|
|
6
|
+
<div className="dropdown-loader-box j5">
|
|
7
|
+
<div className={`lds-ring${variant === 'little' ? ' lds-ring_little' : ''}`}>
|
|
8
|
+
<div />
|
|
9
|
+
<div />
|
|
10
|
+
<div />
|
|
11
|
+
<div />
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default DropdownLoader;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
@mixin fill-parent {
|
|
2
|
+
left: 0;
|
|
3
|
+
top: 0;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.dropdown-loader-box {
|
|
9
|
+
position: absolute;
|
|
10
|
+
@include fill-parent;
|
|
11
|
+
background: #fff;
|
|
12
|
+
opacity: 0.1;
|
|
13
|
+
z-index: 100;
|
|
14
|
+
}
|
|
15
|
+
.lds-ring {
|
|
16
|
+
display: inline-block;
|
|
17
|
+
position: relative;
|
|
18
|
+
width: 100px;
|
|
19
|
+
height: 100px;
|
|
20
|
+
}
|
|
21
|
+
.lds-ring.lds-ring_little {
|
|
22
|
+
width: 20px;
|
|
23
|
+
height: 20px;
|
|
24
|
+
}
|
|
25
|
+
.lds-ring div {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
display: block;
|
|
28
|
+
position: absolute;
|
|
29
|
+
width: 84px;
|
|
30
|
+
height: 84px;
|
|
31
|
+
margin: 8px;
|
|
32
|
+
border: 8px solid #000;
|
|
33
|
+
border-radius: 50%;
|
|
34
|
+
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
|
35
|
+
border-color: #000 transparent transparent transparent;
|
|
36
|
+
}
|
|
37
|
+
.lds-ring_little div {
|
|
38
|
+
width: 20px;
|
|
39
|
+
height: 20px;
|
|
40
|
+
}
|
|
41
|
+
.lds-ring div:nth-child(1) {
|
|
42
|
+
animation-delay: -0.45s;
|
|
43
|
+
}
|
|
44
|
+
.lds-ring div:nth-child(2) {
|
|
45
|
+
animation-delay: -0.3s;
|
|
46
|
+
}
|
|
47
|
+
.lds-ring div:nth-child(3) {
|
|
48
|
+
animation-delay: -0.15s;
|
|
49
|
+
}
|
|
50
|
+
@keyframes lds-ring {
|
|
51
|
+
0% {
|
|
52
|
+
transform: rotate(0deg);
|
|
53
|
+
}
|
|
54
|
+
100% {
|
|
55
|
+
transform: rotate(360deg);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -29,7 +29,7 @@ const Input = ({
|
|
|
29
29
|
icon,
|
|
30
30
|
symbolsLimit,
|
|
31
31
|
blinkTime,
|
|
32
|
-
isFocusDefault = false
|
|
32
|
+
isFocusDefault = false,
|
|
33
33
|
}) => {
|
|
34
34
|
const DEFAULT_BLINK_TIME = 100;
|
|
35
35
|
// STATES
|
|
@@ -42,6 +42,8 @@ const Input = ({
|
|
|
42
42
|
|
|
43
43
|
const { onlyNumbers, onlyString } = formatInput;
|
|
44
44
|
const { addCommas, removeComma } = formatInput.priceInput;
|
|
45
|
+
const isUseErrorsBlink = !isNotBlinkErrors && !mask;
|
|
46
|
+
|
|
45
47
|
// HANDLES
|
|
46
48
|
const handle = {
|
|
47
49
|
change: (e) => {
|
|
@@ -50,8 +52,7 @@ const Input = ({
|
|
|
50
52
|
inputValue = inputValue.substring(0, +symbolsLimit);
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
if (isOnlyNumber && !isTwoDigitAfterDot)
|
|
54
|
-
inputValue = onlyNumbers(inputValue);
|
|
55
|
+
if (isOnlyNumber && !isTwoDigitAfterDot) inputValue = onlyNumbers(inputValue);
|
|
55
56
|
if (isTwoDigitAfterDot) inputValue = onlyNumbers(inputValue, true);
|
|
56
57
|
if (isOnlyString) inputValue = onlyString(inputValue);
|
|
57
58
|
|
|
@@ -79,28 +80,47 @@ const Input = ({
|
|
|
79
80
|
if (onBlur) onBlur(e);
|
|
80
81
|
},
|
|
81
82
|
keyUp: (e) => {
|
|
82
|
-
if (
|
|
83
|
+
if (isUseErrorsBlink) {
|
|
83
84
|
const changedValue = '' + (value ?? '');
|
|
84
85
|
const previousValue = '' + (previousValueRef.current ?? '');
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
|
|
87
|
+
const short = previousValue.length <= changedValue.length ? previousValue : changedValue;
|
|
88
|
+
const long = previousValue.length > changedValue.length ? previousValue : changedValue;
|
|
89
|
+
|
|
90
|
+
const infoAboutDifferencesSameness = short.split('').reduce(
|
|
91
|
+
(acc, symbol, idx) => {
|
|
92
|
+
if (acc.countOn && symbol === long[idx]) acc.same.push(symbol);
|
|
93
|
+
else {
|
|
94
|
+
acc.countOn = false;
|
|
95
|
+
acc.differences.push([idx, symbol]);
|
|
96
|
+
}
|
|
97
|
+
return acc;
|
|
98
|
+
},
|
|
99
|
+
{ same: [], countOn: true, differences: [] }
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const samePart = infoAboutDifferencesSameness.same.join('');
|
|
103
|
+
const differencesLength = infoAboutDifferencesSameness.differences.length;
|
|
104
|
+
const currentSet = changedValue.replace(samePart, '');
|
|
105
|
+
|
|
106
|
+
const getNext = (inputPartToAdd, correctedSamePart) => {
|
|
107
|
+
const partToAdd = inputPartToAdd || currentSet;
|
|
108
|
+
const currentSamePart = correctedSamePart || samePart;
|
|
109
|
+
return changedValue.includes(e.key) && e.key !== changedValue[changedValue.length - 1]
|
|
110
|
+
? currentSamePart + (partToAdd[0] || '')
|
|
111
|
+
: changedValue;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
if (!KEYBOARD_SERVICE_KEYS.includes(e.key) && changedValue === previousValue)
|
|
115
|
+
setIsAttemptToChange(!(!differencesLength && e.key === changedValue[changedValue.length - 2]));
|
|
116
|
+
|
|
117
|
+
if (!previousValueRef.current || KEYBOARD_SERVICE_KEYS.includes(e.key)) previousValueRef.current = getNext();
|
|
118
|
+
else if (changedValue === samePart) previousValueRef.current = getNext(changedValue, changedValue.slice(0, -1));
|
|
119
|
+
else previousValueRef.current = getNext();
|
|
100
120
|
}
|
|
101
121
|
|
|
102
122
|
if (onKeyUp) onKeyUp(e.keyCode, e);
|
|
103
|
-
}
|
|
123
|
+
},
|
|
104
124
|
};
|
|
105
125
|
|
|
106
126
|
function cutOffsingleDot(value) {
|
|
@@ -121,7 +141,7 @@ const Input = ({
|
|
|
121
141
|
onBlur: handle.blur,
|
|
122
142
|
onKeyUp: handle.keyUp,
|
|
123
143
|
...(maskChar ? { maskChar } : {}),
|
|
124
|
-
...(formatChars ? { formatChars } : {})
|
|
144
|
+
...(formatChars ? { formatChars } : {}),
|
|
125
145
|
};
|
|
126
146
|
|
|
127
147
|
function renderInput() {
|
|
@@ -129,13 +149,11 @@ const Input = ({
|
|
|
129
149
|
return <InputMask {...uniProps} ref={inputRef} mask={mask} />;
|
|
130
150
|
}
|
|
131
151
|
|
|
132
|
-
return
|
|
133
|
-
<input {...uniProps} ref={inputRef} type={isPriceInput ? 'text' : type} />
|
|
134
|
-
);
|
|
152
|
+
return <input {...uniProps} ref={inputRef} type={isPriceInput ? 'text' : type} />;
|
|
135
153
|
}
|
|
136
154
|
|
|
137
155
|
useEffect(() => {
|
|
138
|
-
if (
|
|
156
|
+
if (isUseErrorsBlink && isAttemptToChange) {
|
|
139
157
|
setIsAttemptToChange(null);
|
|
140
158
|
setIsToHighlightError(true);
|
|
141
159
|
setTimeout(() => {
|
|
@@ -145,9 +163,8 @@ const Input = ({
|
|
|
145
163
|
}, [isAttemptToChange]);
|
|
146
164
|
|
|
147
165
|
useEffect(() => {
|
|
148
|
-
if (inputRef?.current && typeof isFocusDefault === 'boolean')
|
|
149
|
-
|
|
150
|
-
setEditing(isFocusDefault);
|
|
166
|
+
if (inputRef?.current && typeof isFocusDefault === 'boolean') setIsFocused(isFocusDefault);
|
|
167
|
+
setEditing(isFocusDefault);
|
|
151
168
|
}, [inputRef, isFocusDefault]);
|
|
152
169
|
|
|
153
170
|
return (
|
|
@@ -161,12 +178,7 @@ const Input = ({
|
|
|
161
178
|
>
|
|
162
179
|
{renderInput()}
|
|
163
180
|
{icon}
|
|
164
|
-
{withDelete && (
|
|
165
|
-
<span
|
|
166
|
-
className={cn(`input__close`, { hidden: !value })}
|
|
167
|
-
onClick={handle.toggleEdit}
|
|
168
|
-
/>
|
|
169
|
-
)}
|
|
181
|
+
{withDelete && <span className={cn(`input__close`, { hidden: !value })} onClick={handle.toggleEdit} />}
|
|
170
182
|
</div>
|
|
171
183
|
);
|
|
172
184
|
};
|