tenjin-ui-kit 0.3.27 → 0.3.29
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.
|
@@ -24,7 +24,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
24
24
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
25
25
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
26
26
|
var GroupedSelect = function GroupedSelect(_ref) {
|
|
27
|
-
var _options$find;
|
|
27
|
+
var _options$find, _Object$entries;
|
|
28
28
|
var options = _ref.options,
|
|
29
29
|
onChange = _ref.onChange,
|
|
30
30
|
propValue = _ref.value,
|
|
@@ -44,13 +44,18 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
44
44
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
45
45
|
value = _React$useState6[0],
|
|
46
46
|
setValue = _React$useState6[1];
|
|
47
|
+
var _React$useState7 = React.useState(null),
|
|
48
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
49
|
+
hoveredOption = _React$useState8[0],
|
|
50
|
+
setHoveredOption = _React$useState8[1];
|
|
47
51
|
var groupOptionsByPageTitle = function groupOptionsByPageTitle(options) {
|
|
48
52
|
var grouped = {};
|
|
49
53
|
options.forEach(function (option) {
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
var _grouped$option$pageT;
|
|
55
|
+
if (!grouped[option === null || option === void 0 ? void 0 : option.pageTitle]) {
|
|
56
|
+
grouped[option === null || option === void 0 ? void 0 : option.pageTitle] = [];
|
|
52
57
|
}
|
|
53
|
-
grouped[option.pageTitle].push(option);
|
|
58
|
+
(_grouped$option$pageT = grouped[option === null || option === void 0 ? void 0 : option.pageTitle]) === null || _grouped$option$pageT === void 0 ? void 0 : _grouped$option$pageT.push(option);
|
|
54
59
|
});
|
|
55
60
|
return grouped;
|
|
56
61
|
};
|
|
@@ -58,7 +63,8 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
58
63
|
setSearchTerm(event.target.value);
|
|
59
64
|
};
|
|
60
65
|
var filteredOptions = options.filter(function (option) {
|
|
61
|
-
|
|
66
|
+
var _option$label, _option$pageTitle;
|
|
67
|
+
return (option === null || option === void 0 ? void 0 : (_option$label = option.label) === null || _option$label === void 0 ? void 0 : _option$label.includes(searchTerm)) || (option === null || option === void 0 ? void 0 : (_option$pageTitle = option.pageTitle) === null || _option$pageTitle === void 0 ? void 0 : _option$pageTitle.includes(searchTerm));
|
|
62
68
|
});
|
|
63
69
|
var groupedOptions = groupOptionsByPageTitle(filteredOptions);
|
|
64
70
|
var toggleDropdown = function toggleDropdown() {
|
|
@@ -103,8 +109,8 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
103
109
|
style: {
|
|
104
110
|
flexGrow: 1
|
|
105
111
|
}
|
|
106
|
-
}, value ? (_options$find = options.find(function (opt) {
|
|
107
|
-
return opt.value === value;
|
|
112
|
+
}, value ? options === null || options === void 0 ? void 0 : (_options$find = options.find(function (opt) {
|
|
113
|
+
return (opt === null || opt === void 0 ? void 0 : opt.value) === value;
|
|
108
114
|
})) === null || _options$find === void 0 ? void 0 : _options$find.label : "Select Option"), /*#__PURE__*/React.createElement("div", null, isDropdownOpen ? /*#__PURE__*/React.createElement(_fa.FaCaretUp, null) : /*#__PURE__*/React.createElement(_fa.FaCaretDown, null)))), isDropdownOpen && /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/React.createElement("div", {
|
|
109
115
|
style: {
|
|
110
116
|
position: "absolute",
|
|
@@ -139,7 +145,7 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
139
145
|
border: "1px solid #949494",
|
|
140
146
|
borderRadius: "4px"
|
|
141
147
|
}
|
|
142
|
-
}), Object.entries(groupedOptions).map(function (_ref2) {
|
|
148
|
+
}), (_Object$entries = Object.entries(groupedOptions)) === null || _Object$entries === void 0 ? void 0 : _Object$entries.map(function (_ref2) {
|
|
143
149
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
144
150
|
pageTitle = _ref3[0],
|
|
145
151
|
options = _ref3[1];
|
|
@@ -147,20 +153,27 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
147
153
|
key: pageTitle
|
|
148
154
|
}, /*#__PURE__*/React.createElement(_text.default, {
|
|
149
155
|
style: {
|
|
150
|
-
padding: "5px 10px"
|
|
151
|
-
backgroundColor: "#f5f5f5"
|
|
156
|
+
padding: "5px 10px"
|
|
157
|
+
// backgroundColor: "#f5f5f5",
|
|
152
158
|
},
|
|
159
|
+
|
|
153
160
|
semibold: true
|
|
154
|
-
}, pageTitle), options.map(function (option) {
|
|
161
|
+
}, pageTitle !== null && pageTitle !== void 0 ? pageTitle : "N/A"), options.map(function (option) {
|
|
155
162
|
return /*#__PURE__*/React.createElement("div", {
|
|
156
163
|
key: option.value,
|
|
157
164
|
onClick: function onClick() {
|
|
158
165
|
return handleOptionClick(option.value);
|
|
159
166
|
},
|
|
167
|
+
onMouseEnter: function onMouseEnter() {
|
|
168
|
+
return setHoveredOption(option.value);
|
|
169
|
+
},
|
|
170
|
+
onMouseLeave: function onMouseLeave() {
|
|
171
|
+
return setHoveredOption(null);
|
|
172
|
+
},
|
|
160
173
|
style: {
|
|
161
174
|
padding: "8px 24px",
|
|
162
175
|
cursor: "pointer",
|
|
163
|
-
|
|
176
|
+
backgroundColor: value === option.value ? "#f0f0f7" : hoveredOption === option.value ? "#f5f5f5" : "transparent"
|
|
164
177
|
}
|
|
165
178
|
}, option.label);
|
|
166
179
|
}));
|