intelicoreact 1.1.15 → 1.1.16
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/FileLoaderLocal/FileLoaderLocal.js +6 -20
- package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +6 -7
- package/dist/Functions/utils.js +15 -2
- package/dist/Molecular/InputAddress/InputAddress.js +62 -34
- package/dist/Molecular/InputAddress/InputAddress.scss +1 -1
- package/package.json +1 -1
|
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
10
|
var _react = _interopRequireDefault(require("react"));
|
|
13
11
|
|
|
14
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -52,32 +50,19 @@ var FileLoaderLocal = function FileLoaderLocal(_ref) {
|
|
|
52
50
|
return file.size > maxItemSizeBytes;
|
|
53
51
|
};
|
|
54
52
|
|
|
55
|
-
function getUniqueExtensionsList(extList) {
|
|
56
|
-
// Split the extensions list into an array
|
|
57
|
-
var extArray = extList === null || extList === void 0 ? void 0 : extList.split(',').map(function (ext) {
|
|
58
|
-
return ext.trim().toUpperCase();
|
|
59
|
-
}); // Remove duplicates using a Set
|
|
60
|
-
|
|
61
|
-
var uniqueExts = (0, _toConsumableArray2.default)(new Set(extArray)); // Join the unique extensions into a string
|
|
62
|
-
|
|
63
|
-
var uniqueExtString = uniqueExts.join(', '); // Return the final message
|
|
64
|
-
|
|
65
|
-
return "Only ".concat(uniqueExtString, " are allowed");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
53
|
var checkExtension = function checkExtension(valueExtension) {
|
|
69
54
|
return accept.includes(valueExtension);
|
|
70
55
|
};
|
|
71
56
|
|
|
72
57
|
var handle = {
|
|
73
58
|
change: function change(e) {
|
|
74
|
-
var _e$target, _e$target$files;
|
|
59
|
+
var _name$match, _e$target, _e$target$files, _e$target2, _e$target2$files;
|
|
75
60
|
|
|
76
61
|
var name = getFileName(e.target.value);
|
|
77
|
-
var valueExtension = name === null || name === void 0 ? void 0 : name.match(/[^\.]+$/)[0];
|
|
62
|
+
var valueExtension = name === null || name === void 0 ? void 0 : (_name$match = name.match(/[^\.]+$/)) === null || _name$match === void 0 ? void 0 : _name$match[0];
|
|
78
63
|
var file = (_e$target = e.target) === null || _e$target === void 0 ? void 0 : (_e$target$files = _e$target.files) === null || _e$target$files === void 0 ? void 0 : _e$target$files[0];
|
|
79
64
|
|
|
80
|
-
if (isFileSizeOutOfLimit(e.target.files[0])) {
|
|
65
|
+
if (isFileSizeOutOfLimit((_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : (_e$target2$files = _e$target2.files) === null || _e$target2$files === void 0 ? void 0 : _e$target2$files[0])) {
|
|
81
66
|
onChange({
|
|
82
67
|
id: id,
|
|
83
68
|
name: name,
|
|
@@ -90,7 +75,8 @@ var FileLoaderLocal = function FileLoaderLocal(_ref) {
|
|
|
90
75
|
} else if (!checkExtension(valueExtension)) {
|
|
91
76
|
var _accept$replace;
|
|
92
77
|
|
|
93
|
-
var allowedExtensions = ((_accept$replace = accept.replace(/\./g, '')) === null || _accept$replace === void 0 ? void 0 : _accept$replace.toUpperCase()) || 'JPG, PNG, PDF';
|
|
78
|
+
var allowedExtensions = (accept === null || accept === void 0 ? void 0 : (_accept$replace = accept.replace(/\./g, '')) === null || _accept$replace === void 0 ? void 0 : _accept$replace.toUpperCase()) || 'JPG, PNG, PDF';
|
|
79
|
+
var uniqExts = (0, _utils.getUniqueFileExtensions)(allowedExtensions);
|
|
94
80
|
onChange({
|
|
95
81
|
id: id,
|
|
96
82
|
groupId: groupId,
|
|
@@ -98,7 +84,7 @@ var FileLoaderLocal = function FileLoaderLocal(_ref) {
|
|
|
98
84
|
valueExtension: valueExtension,
|
|
99
85
|
e: e,
|
|
100
86
|
file: file,
|
|
101
|
-
error:
|
|
87
|
+
error: "Only ".concat(uniqExts, " are allowed")
|
|
102
88
|
});
|
|
103
89
|
} else onChange({
|
|
104
90
|
id: id,
|
|
@@ -41,6 +41,8 @@ var FileLoaderLocalGroup = function FileLoaderLocalGroup(_ref) {
|
|
|
41
41
|
groupsArray = _ref$groupsArray === void 0 ? [] : _ref$groupsArray,
|
|
42
42
|
isSingleGroup = _ref.isSingleGroup,
|
|
43
43
|
onChange = _ref.onChange,
|
|
44
|
+
_ref$labelPrefix = _ref.labelPrefix,
|
|
45
|
+
labelPrefix = _ref$labelPrefix === void 0 ? DEFAULT_LABEL_PREFIX : _ref$labelPrefix,
|
|
44
46
|
testId = _ref.testId;
|
|
45
47
|
|
|
46
48
|
var _useState = (0, _react.useState)((0, _utils.clone)(groupsArray)),
|
|
@@ -139,20 +141,17 @@ var FileLoaderLocalGroup = function FileLoaderLocalGroup(_ref) {
|
|
|
139
141
|
onChange(oldDataWithRemovedFile);
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
|
-
};
|
|
144
|
+
};
|
|
143
145
|
|
|
144
146
|
var renderLabel = function renderLabel(group) {
|
|
145
147
|
var _group$accept;
|
|
146
148
|
|
|
147
|
-
var
|
|
148
|
-
var concatedAcceptList = (acceptExtensionsList === null || acceptExtensionsList === void 0 ? void 0 : acceptExtensionsList.map(function (item, i) {
|
|
149
|
-
return item.replace('.', '').toUpperCase().concat("".concat(acceptExtensionsList.length - 1 !== i ? ',' : ''));
|
|
150
|
-
})) || '';
|
|
149
|
+
var uniqueExts = (0, _utils.getUniqueFileExtensions)(group === null || group === void 0 ? void 0 : (_group$accept = group.accept) === null || _group$accept === void 0 ? void 0 : _group$accept.replace(/\./g, ''));
|
|
151
150
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
152
151
|
className: "file-loader-local__top-label"
|
|
153
|
-
},
|
|
152
|
+
}, labelPrefix, " ", group === null || group === void 0 ? void 0 : group.groupTitleDescription, ' ', /*#__PURE__*/_react.default.createElement("span", {
|
|
154
153
|
className: "file-loader-local__top-label-extension"
|
|
155
|
-
}, "(",
|
|
154
|
+
}, "(", uniqueExts, "):"));
|
|
156
155
|
};
|
|
157
156
|
|
|
158
157
|
var renderGroups = function renderGroups() {
|
package/dist/Functions/utils.js
CHANGED
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
10
10
|
exports.transformUTCTimeToLocal = transformUTCTimeToLocal;
|
|
11
11
|
exports.transformUTCHoursToLocal = transformUTCHoursToLocal;
|
|
12
12
|
exports.downloadEmulation = downloadEmulation;
|
|
13
|
-
exports.getCorrectTestId = exports.disableDefaultBehavior = exports.getOS = exports.renderFileSize = exports.getBase64 = exports.compareAlphabetical = exports.setCarretToEnd = exports.compare = exports.downloadFile = exports.checkedRef = exports.capitalized = exports.firstLetterCapital = exports.changeMeta = exports.addBitDepthPoints = exports.throttle = exports.debounce = exports.getColorById = exports.getStyles = exports.logout = exports.omitKeys = exports.clone = exports.useOutsideToggle = exports.handleObjectChange = void 0;
|
|
13
|
+
exports.getCorrectTestId = exports.disableDefaultBehavior = exports.getOS = exports.getUniqueFileExtensions = exports.renderFileSize = exports.getBase64 = exports.compareAlphabetical = exports.setCarretToEnd = exports.compare = exports.downloadFile = exports.checkedRef = exports.capitalized = exports.firstLetterCapital = exports.changeMeta = exports.addBitDepthPoints = exports.throttle = exports.debounce = exports.getColorById = exports.getStyles = exports.logout = exports.omitKeys = exports.clone = exports.useOutsideToggle = exports.handleObjectChange = void 0;
|
|
14
14
|
|
|
15
15
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
16
16
|
|
|
@@ -419,6 +419,19 @@ var renderFileSize = function renderFileSize(bytes) {
|
|
|
419
419
|
var i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
420
420
|
return "".concat(parseFloat((bytes / Math.pow(k, i)).toFixed(dm)), " ").concat(sizes[i]);
|
|
421
421
|
};
|
|
422
|
+
|
|
423
|
+
exports.renderFileSize = renderFileSize;
|
|
424
|
+
|
|
425
|
+
var getUniqueFileExtensions = function getUniqueFileExtensions(extListString) {
|
|
426
|
+
// Split the extensions list into an array
|
|
427
|
+
var extArray = extListString === null || extListString === void 0 ? void 0 : extListString.split(',').map(function (ext) {
|
|
428
|
+
return ext.trim().toUpperCase();
|
|
429
|
+
}); // Remove duplicates using a Set
|
|
430
|
+
|
|
431
|
+
var uniqueExts = (0, _toConsumableArray2.default)(new Set(extArray)); // Join the unique extensions into a string
|
|
432
|
+
|
|
433
|
+
return uniqueExts.join(', ');
|
|
434
|
+
};
|
|
422
435
|
/**
|
|
423
436
|
* If the platform is one of the macOS platforms, return macOS. If the platform is one of the iOS
|
|
424
437
|
* platforms, return iOS. If the platform is one of the Windows platforms, return Windows. If the user
|
|
@@ -427,7 +440,7 @@ var renderFileSize = function renderFileSize(bytes) {
|
|
|
427
440
|
*/
|
|
428
441
|
|
|
429
442
|
|
|
430
|
-
exports.
|
|
443
|
+
exports.getUniqueFileExtensions = getUniqueFileExtensions;
|
|
431
444
|
|
|
432
445
|
var getOS = function getOS() {
|
|
433
446
|
var _window$navigator, _window$navigator$use;
|
|
@@ -32,6 +32,8 @@ var InputAddress = function InputAddress(_ref) {
|
|
|
32
32
|
className = _ref$className === void 0 ? '' : _ref$className,
|
|
33
33
|
_ref$isClearable = _ref.isClearable,
|
|
34
34
|
isClearable = _ref$isClearable === void 0 ? true : _ref$isClearable,
|
|
35
|
+
_ref$isKeyboardContro = _ref.isKeyboardControlled,
|
|
36
|
+
isKeyboardControlled = _ref$isKeyboardContro === void 0 ? true : _ref$isKeyboardContro,
|
|
35
37
|
_ref$fieldKey = _ref.fieldKey,
|
|
36
38
|
fieldKey = _ref$fieldKey === void 0 ? '' : _ref$fieldKey,
|
|
37
39
|
_ref$testId = _ref.testId,
|
|
@@ -48,6 +50,7 @@ var InputAddress = function InputAddress(_ref) {
|
|
|
48
50
|
_ref$getListItems = _ref.getListItems,
|
|
49
51
|
getListItems = _ref$getListItems === void 0 ? function () {} : _ref$getListItems;
|
|
50
52
|
var inputRef = (0, _react.useRef)(null);
|
|
53
|
+
var listRef = (0, _react.useRef)(null);
|
|
51
54
|
|
|
52
55
|
var _useState = (0, _react.useState)(false),
|
|
53
56
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -108,47 +111,71 @@ var InputAddress = function InputAddress(_ref) {
|
|
|
108
111
|
};
|
|
109
112
|
|
|
110
113
|
var onKeyDown = function onKeyDown(keyCode) {
|
|
111
|
-
if (!isListVisible) return false;
|
|
112
|
-
|
|
113
|
-
if (keyCode === 40) {
|
|
114
|
-
if (hightlightedIndex === null) {
|
|
115
|
-
setHightlightedIndex(0);
|
|
116
|
-
return;
|
|
117
|
-
} else if (hightlightedIndex + 1 < (listItems === null || listItems === void 0 ? void 0 : listItems.length)) {
|
|
118
|
-
setHightlightedIndex(function (i) {
|
|
119
|
-
return i + 1;
|
|
120
|
-
});
|
|
121
|
-
return;
|
|
122
|
-
} else if (hightlightedIndex === (listItems === null || listItems === void 0 ? void 0 : listItems.length) - 1) {
|
|
123
|
-
setHightlightedIndex(0);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (keyCode === 38) {
|
|
129
|
-
if (hightlightedIndex === null) {
|
|
130
|
-
setHightlightedIndex((listItems === null || listItems === void 0 ? void 0 : listItems.length) - 1);
|
|
131
|
-
return;
|
|
132
|
-
} else if (hightlightedIndex - 1 >= 0) {
|
|
133
|
-
setHightlightedIndex(function (i) {
|
|
134
|
-
return i - 1;
|
|
135
|
-
});
|
|
136
|
-
return;
|
|
137
|
-
} else if (hightlightedIndex === 0) {
|
|
138
|
-
setHightlightedIndex((listItems === null || listItems === void 0 ? void 0 : listItems.length) - 1);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
114
|
+
if (!isListVisible || !isKeyboardControlled) return false;
|
|
142
115
|
|
|
143
116
|
if (keyCode === 13) {
|
|
144
117
|
var _inputRef$current2;
|
|
145
118
|
|
|
119
|
+
// Enter Controller
|
|
146
120
|
setQueryAsItem(null, listItems[hightlightedIndex]);
|
|
147
121
|
setHightlightedIndex(null);
|
|
148
122
|
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.blur();
|
|
149
|
-
}
|
|
150
|
-
|
|
123
|
+
} else {
|
|
124
|
+
var _listRef$current, _listRef$current$getB, _listRef$current2, _listRef$current2$get, _listRef$current3, _newHightlightedEleme;
|
|
125
|
+
|
|
126
|
+
var prevHightlightedIndex = hightlightedIndex;
|
|
127
|
+
var newHightlightedIndex = null;
|
|
128
|
+
var listItemsElements = document.getElementsByClassName('input-address__list--item');
|
|
129
|
+
var listTop = listRef === null || listRef === void 0 ? void 0 : (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : (_listRef$current$getB = _listRef$current.getBoundingClientRect()) === null || _listRef$current$getB === void 0 ? void 0 : _listRef$current$getB.top;
|
|
130
|
+
var listHeight = listRef === null || listRef === void 0 ? void 0 : (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : (_listRef$current2$get = _listRef$current2.getBoundingClientRect()) === null || _listRef$current2$get === void 0 ? void 0 : _listRef$current2$get.height;
|
|
131
|
+
var listScrollTop = (listRef === null || listRef === void 0 ? void 0 : (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.scrollTop) || 0;
|
|
132
|
+
/** Arrows Controllers **/
|
|
133
|
+
|
|
134
|
+
if (keyCode === 40) {
|
|
135
|
+
// Down Key Controller
|
|
136
|
+
if (hightlightedIndex === null || hightlightedIndex === (listItems === null || listItems === void 0 ? void 0 : listItems.length) - 1) {
|
|
137
|
+
newHightlightedIndex = 0;
|
|
138
|
+
} else if (hightlightedIndex + 1 < (listItems === null || listItems === void 0 ? void 0 : listItems.length)) {
|
|
139
|
+
newHightlightedIndex = hightlightedIndex + 1;
|
|
140
|
+
}
|
|
141
|
+
} else if (keyCode === 38) {
|
|
142
|
+
// Up Key Controller
|
|
143
|
+
if (hightlightedIndex === null || hightlightedIndex === 0) {
|
|
144
|
+
newHightlightedIndex = (listItems === null || listItems === void 0 ? void 0 : listItems.length) - 1;
|
|
145
|
+
} else if (hightlightedIndex - 1 >= 0) {
|
|
146
|
+
newHightlightedIndex = hightlightedIndex - 1;
|
|
147
|
+
}
|
|
148
|
+
} // Scroll to Element
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
var newHightlightedElement = listItemsElements[newHightlightedIndex];
|
|
152
|
+
var newHightlightedElementHeight = newHightlightedElement === null || newHightlightedElement === void 0 ? void 0 : (_newHightlightedEleme = newHightlightedElement.getBoundingClientRect()) === null || _newHightlightedEleme === void 0 ? void 0 : _newHightlightedEleme.height;
|
|
153
|
+
var newHightlightedElementTopInList = newHightlightedElement === null || newHightlightedElement === void 0 ? void 0 : newHightlightedElement.offsetTop;
|
|
151
154
|
|
|
155
|
+
if (newHightlightedElementTopInList + newHightlightedElementHeight > listScrollTop + listHeight) {
|
|
156
|
+
if (Math.abs(newHightlightedElementTopInList + newHightlightedElementHeight - (listScrollTop + listHeight)) <= newHightlightedElementHeight) {
|
|
157
|
+
var _listRef$current4;
|
|
158
|
+
|
|
159
|
+
listRef === null || listRef === void 0 ? void 0 : (_listRef$current4 = listRef.current) === null || _listRef$current4 === void 0 ? void 0 : _listRef$current4.scrollTo(0, listScrollTop + newHightlightedElementHeight);
|
|
160
|
+
} else {
|
|
161
|
+
var _listRef$current5;
|
|
162
|
+
|
|
163
|
+
listRef === null || listRef === void 0 ? void 0 : (_listRef$current5 = listRef.current) === null || _listRef$current5 === void 0 ? void 0 : _listRef$current5.scrollTo(0, newHightlightedElementTopInList);
|
|
164
|
+
}
|
|
165
|
+
} else if (newHightlightedElementTopInList < listScrollTop) {
|
|
166
|
+
if (Math.abs(newHightlightedElementTopInList - listScrollTop) < newHightlightedElementHeight) {
|
|
167
|
+
var _listRef$current6;
|
|
168
|
+
|
|
169
|
+
listRef === null || listRef === void 0 ? void 0 : (_listRef$current6 = listRef.current) === null || _listRef$current6 === void 0 ? void 0 : _listRef$current6.scrollTo(0, listScrollTop - newHightlightedElementHeight);
|
|
170
|
+
} else {
|
|
171
|
+
var _listRef$current7;
|
|
172
|
+
|
|
173
|
+
listRef === null || listRef === void 0 ? void 0 : (_listRef$current7 = listRef.current) === null || _listRef$current7 === void 0 ? void 0 : _listRef$current7.scrollTo(0, newHightlightedElementTopInList);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
setHightlightedIndex(newHightlightedIndex);
|
|
178
|
+
}
|
|
152
179
|
};
|
|
153
180
|
|
|
154
181
|
(0, _react.useEffect)(function () {
|
|
@@ -221,7 +248,8 @@ var InputAddress = function InputAddress(_ref) {
|
|
|
221
248
|
};
|
|
222
249
|
|
|
223
250
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
224
|
-
className: "input-address__list"
|
|
251
|
+
className: "input-address__list",
|
|
252
|
+
ref: listRef
|
|
225
253
|
}, !(listItems !== null && listItems !== void 0 && listItems.length) ? renderLoader() : listItems === null || listItems === void 0 ? void 0 : listItems.map(renderListItem));
|
|
226
254
|
};
|
|
227
255
|
|