tenjin-ui-kit 0.2.196 → 0.2.198
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/components/select/SimpleSelect.js +33 -7
- package/http/index.js +5 -6
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
15
|
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); }
|
|
16
16
|
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; }
|
|
17
17
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
18
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
18
19
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
19
20
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
20
21
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -75,19 +76,44 @@ var SimpleSelect = function SimpleSelect(_ref) {
|
|
|
75
76
|
return false;
|
|
76
77
|
};
|
|
77
78
|
var displayedOptions = (0, _react.useMemo)(function () {
|
|
78
|
-
var filteredOptions = options.filter(function (option) {
|
|
79
|
-
return containsText(option.label, searchText);
|
|
79
|
+
var filteredOptions = options === null || options === void 0 ? void 0 : options.filter(function (option) {
|
|
80
|
+
return containsText(option === null || option === void 0 ? void 0 : option.label, searchText);
|
|
80
81
|
});
|
|
81
82
|
if (isSearch) {
|
|
82
|
-
setNoDataAvailable(filteredOptions.length === 0);
|
|
83
|
+
setNoDataAvailable((filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.length) === 0);
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
|
|
86
|
+
// const sortedOptions = filteredOptions?.sort((a, b) =>
|
|
87
|
+
// a?.label?.localeCompare(b.label)
|
|
88
|
+
// );
|
|
89
|
+
var sortedOptions = filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.slice().sort(function (a, b) {
|
|
90
|
+
var labelA = typeof a.label === "string" ? a.label : findStringInChildren(a.label.props.children);
|
|
91
|
+
var labelB = typeof b.label === "string" ? b.label : findStringInChildren(b.label.props.children);
|
|
92
|
+
return labelA.localeCompare(labelB);
|
|
86
93
|
});
|
|
94
|
+
function findStringInChildren(children) {
|
|
95
|
+
var _iterator = _createForOfIteratorHelper(children),
|
|
96
|
+
_step;
|
|
97
|
+
try {
|
|
98
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
99
|
+
var child = _step.value;
|
|
100
|
+
if (typeof child === "string") {
|
|
101
|
+
return child;
|
|
102
|
+
} else if (child.props && typeof child.props.children === "string") {
|
|
103
|
+
return child.props.children;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} catch (err) {
|
|
107
|
+
_iterator.e(err);
|
|
108
|
+
} finally {
|
|
109
|
+
_iterator.f();
|
|
110
|
+
}
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
87
113
|
return sortedOptions.map(function (option) {
|
|
88
114
|
return {
|
|
89
|
-
label: option.label,
|
|
90
|
-
value: option.value
|
|
115
|
+
label: option === null || option === void 0 ? void 0 : option.label,
|
|
116
|
+
value: option === null || option === void 0 ? void 0 : option.value
|
|
91
117
|
};
|
|
92
118
|
});
|
|
93
119
|
}, [options, searchText, isSearch]);
|
package/http/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var getApiAccessToken = _authenticationProvider.default.getApiAccessToken;
|
|
|
20
20
|
var getClient = function getClient() {
|
|
21
21
|
return _axios.default.create({
|
|
22
22
|
headers: {
|
|
23
|
-
|
|
23
|
+
'Content-Type': 'application/json'
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
};
|
|
@@ -28,7 +28,7 @@ exports.getClient = getClient;
|
|
|
28
28
|
var getSecureClient = function getSecureClient() {
|
|
29
29
|
return _axios.default.create({
|
|
30
30
|
headers: {
|
|
31
|
-
|
|
31
|
+
'Content-Type': 'application/json',
|
|
32
32
|
Authorization: "Bearer ".concat(getApiAccessToken())
|
|
33
33
|
}
|
|
34
34
|
});
|
|
@@ -210,15 +210,14 @@ exports.doDelete = doDelete;
|
|
|
210
210
|
var parseAxiosError = function parseAxiosError(error) {
|
|
211
211
|
var parsedError = {
|
|
212
212
|
status: 500,
|
|
213
|
-
statusText:
|
|
214
|
-
message:
|
|
213
|
+
statusText: 'Internal Server Error',
|
|
214
|
+
message: 'An unexpected error occurred while processing your request. Please try again. If problem persists, please contact Tenjin support'
|
|
215
215
|
};
|
|
216
216
|
if (error && error.response) {
|
|
217
|
-
var _error$response$data$;
|
|
218
217
|
parsedError = _objectSpread(_objectSpread({}, parsedError), {}, {
|
|
219
218
|
status: error.response.status,
|
|
220
219
|
statusText: error.response.statusText,
|
|
221
|
-
message: error.response.status === 503 ?
|
|
220
|
+
message: error.response.status === 503 ? 'A network error occurred. Please try again' : error.response.status === 401 ? 'Authentication Failed' : error.response.data ? error.response.data.message ? error.response.data.message : 'An unexpected error occurred while processing your request. Please try again. If problem persists, please contact Tenjin support' : 'An unexpected error occurred while processing your request. Please try again. If problem persists, please contact Tenjin support'
|
|
222
221
|
});
|
|
223
222
|
}
|
|
224
223
|
return parsedError;
|