tenjin-ui-kit 0.2.151 → 0.2.152
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
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); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -15,6 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
14
|
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
15
|
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
16
|
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); }
|
|
17
|
+
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); }
|
|
18
18
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
19
|
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."); }
|
|
20
20
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -39,6 +39,7 @@ var SimpleSelect = function SimpleSelect(_ref) {
|
|
|
39
39
|
loading = _ref.loading,
|
|
40
40
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
41
41
|
isSearch = true; //by default
|
|
42
|
+
|
|
42
43
|
var _useState = (0, _react.useState)(""),
|
|
43
44
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
45
|
searchText = _useState2[0],
|
|
@@ -47,18 +48,28 @@ var SimpleSelect = function SimpleSelect(_ref) {
|
|
|
47
48
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
48
49
|
noDataAvailable = _useState4[0],
|
|
49
50
|
setNoDataAvailable = _useState4[1];
|
|
51
|
+
var validateChildren = function validateChildren(type, searchText) {
|
|
52
|
+
if (_typeof(type) !== "object") {
|
|
53
|
+
return typeof type === "string" && type.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
|
|
54
|
+
}
|
|
55
|
+
if (_typeof(type.props) === "object" && Array.isArray(type.props.children)) {
|
|
56
|
+
return type.props.children.some(function (data) {
|
|
57
|
+
return validateChildren(data, searchText);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
};
|
|
50
62
|
var containsText = function containsText(text, searchText) {
|
|
51
|
-
|
|
63
|
+
if (typeof text === "string" && typeof searchText === "string") {
|
|
64
|
+
return text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
|
|
65
|
+
}
|
|
66
|
+
if (_typeof(text) === "object" && text.props && Array.isArray(text.props.children)) {
|
|
67
|
+
return text.props.children.some(function (data) {
|
|
68
|
+
return validateChildren(data, searchText);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
52
72
|
};
|
|
53
|
-
|
|
54
|
-
// const displayedOptions = useMemo(() => {
|
|
55
|
-
// return options
|
|
56
|
-
// .filter((option) => containsText(option.label, searchText))
|
|
57
|
-
// .map((option) => ({
|
|
58
|
-
// label: option.label,
|
|
59
|
-
// value: option.value,
|
|
60
|
-
// }));
|
|
61
|
-
// }, [options, searchText]);
|
|
62
73
|
var displayedOptions = (0, _react.useMemo)(function () {
|
|
63
74
|
var filteredOptions = options.filter(function (option) {
|
|
64
75
|
return containsText(option.label, searchText);
|