tenjin-ui-kit 0.3.26 → 0.3.27
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.
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
|
|
10
10
|
var _fa = require("react-icons/fa");
|
|
11
|
+
var _reactDom = require("react-dom");
|
|
11
12
|
var _text = _interopRequireDefault(require("../text"));
|
|
12
13
|
var _excluded = ["options", "onChange", "value", "defaultValue", "fullWidth"];
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -30,6 +31,7 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
30
31
|
defaultValue = _ref.defaultValue,
|
|
31
32
|
fullWidth = _ref.fullWidth,
|
|
32
33
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
var triggerRef = React.useRef(null);
|
|
33
35
|
var _React$useState = React.useState(""),
|
|
34
36
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
35
37
|
searchTerm = _React$useState2[0],
|
|
@@ -53,10 +55,10 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
53
55
|
return grouped;
|
|
54
56
|
};
|
|
55
57
|
var handleSearchChange = function handleSearchChange(event) {
|
|
56
|
-
setSearchTerm(event.target.value
|
|
58
|
+
setSearchTerm(event.target.value);
|
|
57
59
|
};
|
|
58
60
|
var filteredOptions = options.filter(function (option) {
|
|
59
|
-
return option.label.
|
|
61
|
+
return option.label.includes(searchTerm) || option.pageTitle.includes(searchTerm);
|
|
60
62
|
});
|
|
61
63
|
var groupedOptions = groupOptionsByPageTitle(filteredOptions);
|
|
62
64
|
var toggleDropdown = function toggleDropdown() {
|
|
@@ -84,7 +86,8 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
84
86
|
style: {
|
|
85
87
|
position: "relative",
|
|
86
88
|
width: "100%"
|
|
87
|
-
}
|
|
89
|
+
},
|
|
90
|
+
ref: triggerRef
|
|
88
91
|
}, /*#__PURE__*/React.createElement("div", {
|
|
89
92
|
onClick: toggleDropdown,
|
|
90
93
|
style: {
|
|
@@ -102,18 +105,19 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
102
105
|
}
|
|
103
106
|
}, value ? (_options$find = options.find(function (opt) {
|
|
104
107
|
return opt.value === value;
|
|
105
|
-
})) === 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__*/React.createElement("div", {
|
|
108
|
+
})) === 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", {
|
|
106
109
|
style: {
|
|
107
110
|
position: "absolute",
|
|
108
|
-
top: "
|
|
109
|
-
left:
|
|
110
|
-
|
|
111
|
+
top: "".concat(triggerRef.current.getBoundingClientRect().bottom + 8, "px"),
|
|
112
|
+
left: "".concat(triggerRef.current.getBoundingClientRect().left, "px"),
|
|
113
|
+
width: "".concat(triggerRef.current.offsetWidth, "px"),
|
|
111
114
|
backgroundColor: "#fff",
|
|
112
115
|
border: "1px solid #ccc",
|
|
113
116
|
borderRadius: "4px",
|
|
117
|
+
boxShadow: "0px 4px 6px rgba(0, 0, 0, 0.1)",
|
|
114
118
|
maxHeight: "200px",
|
|
115
119
|
overflowY: "auto",
|
|
116
|
-
zIndex:
|
|
120
|
+
zIndex: 2000
|
|
117
121
|
}
|
|
118
122
|
}, /*#__PURE__*/React.createElement("div", {
|
|
119
123
|
style: {
|
|
@@ -129,10 +133,6 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
129
133
|
background: 'white url("https://static.thenounproject.com/png/101791-200.png") no-repeat left',
|
|
130
134
|
backgroundPosition: "0.875rem center",
|
|
131
135
|
backgroundSize: "1.125rem",
|
|
132
|
-
position: "sticky",
|
|
133
|
-
top: 0,
|
|
134
|
-
zIndex: 9999,
|
|
135
|
-
backgroundColor: "white",
|
|
136
136
|
height: "2.188rem",
|
|
137
137
|
margin: 0,
|
|
138
138
|
width: "100%",
|
|
@@ -164,7 +164,7 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
164
164
|
}
|
|
165
165
|
}, option.label);
|
|
166
166
|
}));
|
|
167
|
-
})))));
|
|
167
|
+
}))), document.body));
|
|
168
168
|
};
|
|
169
169
|
var _default = GroupedSelect;
|
|
170
170
|
exports.default = _default;
|