tenjin-ui-kit 0.3.25 → 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.
|
@@ -7,14 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
|
|
10
|
-
var _Menu = _interopRequireDefault(require("@mui/material/Menu"));
|
|
11
|
-
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
12
10
|
var _fa = require("react-icons/fa");
|
|
11
|
+
var _reactDom = require("react-dom");
|
|
13
12
|
var _text = _interopRequireDefault(require("../text"));
|
|
14
13
|
var _excluded = ["options", "onChange", "value", "defaultValue", "fullWidth"];
|
|
15
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
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); }
|
|
17
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
|
+
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
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); }
|
|
@@ -24,20 +24,22 @@ 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
28
|
var options = _ref.options,
|
|
28
29
|
onChange = _ref.onChange,
|
|
29
30
|
propValue = _ref.value,
|
|
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],
|
|
36
38
|
setSearchTerm = _React$useState2[1];
|
|
37
|
-
var _React$useState3 = React.useState(
|
|
39
|
+
var _React$useState3 = React.useState(false),
|
|
38
40
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
isDropdownOpen = _React$useState4[0],
|
|
42
|
+
setIsDropdownOpen = _React$useState4[1];
|
|
41
43
|
var _React$useState5 = React.useState(propValue || defaultValue),
|
|
42
44
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
43
45
|
value = _React$useState6[0],
|
|
@@ -53,37 +55,39 @@ 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
|
-
var toggleDropdown = function toggleDropdown(
|
|
63
|
-
|
|
64
|
+
var toggleDropdown = function toggleDropdown() {
|
|
65
|
+
setIsDropdownOpen(function (prev) {
|
|
66
|
+
return !prev;
|
|
67
|
+
});
|
|
64
68
|
};
|
|
65
69
|
var handleOptionClick = function handleOptionClick(selectedValue) {
|
|
66
70
|
setValue(selectedValue);
|
|
67
|
-
|
|
71
|
+
setIsDropdownOpen(false);
|
|
68
72
|
onChange({
|
|
69
73
|
target: {
|
|
70
74
|
value: selectedValue
|
|
71
75
|
}
|
|
72
76
|
});
|
|
73
77
|
};
|
|
74
|
-
var
|
|
75
|
-
|
|
78
|
+
var handleCloseDropdown = function handleCloseDropdown() {
|
|
79
|
+
setIsDropdownOpen(false);
|
|
76
80
|
};
|
|
77
|
-
|
|
78
|
-
return /*#__PURE__*/React.createElement(_FormControl.default, {
|
|
81
|
+
return /*#__PURE__*/React.createElement(_FormControl.default, _extends({
|
|
79
82
|
sx: {
|
|
80
83
|
width: fullWidth ? "100%" : 200
|
|
81
84
|
}
|
|
82
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
83
86
|
style: {
|
|
84
87
|
position: "relative",
|
|
85
88
|
width: "100%"
|
|
86
|
-
}
|
|
89
|
+
},
|
|
90
|
+
ref: triggerRef
|
|
87
91
|
}, /*#__PURE__*/React.createElement("div", {
|
|
88
92
|
onClick: toggleDropdown,
|
|
89
93
|
style: {
|
|
@@ -91,7 +95,6 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
91
95
|
border: "1px solid #ccc",
|
|
92
96
|
borderRadius: "4px",
|
|
93
97
|
cursor: "pointer",
|
|
94
|
-
flexDirection: "row",
|
|
95
98
|
display: "flex",
|
|
96
99
|
alignItems: "center",
|
|
97
100
|
justifyContent: "space-between"
|
|
@@ -100,26 +103,21 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
100
103
|
style: {
|
|
101
104
|
flexGrow: 1
|
|
102
105
|
}
|
|
103
|
-
}, value ? options.find(function (opt) {
|
|
106
|
+
}, value ? (_options$find = options.find(function (opt) {
|
|
104
107
|
return opt.value === value;
|
|
105
|
-
}).label : "Select Option"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_fa.FaCaretDown, null))), /*#__PURE__*/React.createElement(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
horizontal: "left"
|
|
119
|
-
},
|
|
120
|
-
transformOrigin: {
|
|
121
|
-
vertical: "top",
|
|
122
|
-
horizontal: "left"
|
|
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", {
|
|
109
|
+
style: {
|
|
110
|
+
position: "absolute",
|
|
111
|
+
top: "".concat(triggerRef.current.getBoundingClientRect().bottom + 8, "px"),
|
|
112
|
+
left: "".concat(triggerRef.current.getBoundingClientRect().left, "px"),
|
|
113
|
+
width: "".concat(triggerRef.current.offsetWidth, "px"),
|
|
114
|
+
backgroundColor: "#fff",
|
|
115
|
+
border: "1px solid #ccc",
|
|
116
|
+
borderRadius: "4px",
|
|
117
|
+
boxShadow: "0px 4px 6px rgba(0, 0, 0, 0.1)",
|
|
118
|
+
maxHeight: "200px",
|
|
119
|
+
overflowY: "auto",
|
|
120
|
+
zIndex: 2000
|
|
123
121
|
}
|
|
124
122
|
}, /*#__PURE__*/React.createElement("div", {
|
|
125
123
|
style: {
|
|
@@ -135,10 +133,6 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
135
133
|
background: 'white url("https://static.thenounproject.com/png/101791-200.png") no-repeat left',
|
|
136
134
|
backgroundPosition: "0.875rem center",
|
|
137
135
|
backgroundSize: "1.125rem",
|
|
138
|
-
position: "sticky",
|
|
139
|
-
top: 0,
|
|
140
|
-
zIndex: 9999,
|
|
141
|
-
backgroundColor: "white !important",
|
|
142
136
|
height: "2.188rem",
|
|
143
137
|
margin: 0,
|
|
144
138
|
width: "100%",
|
|
@@ -158,18 +152,19 @@ var GroupedSelect = function GroupedSelect(_ref) {
|
|
|
158
152
|
},
|
|
159
153
|
semibold: true
|
|
160
154
|
}, pageTitle), options.map(function (option) {
|
|
161
|
-
return /*#__PURE__*/React.createElement(
|
|
155
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
162
156
|
key: option.value,
|
|
163
157
|
onClick: function onClick() {
|
|
164
158
|
return handleOptionClick(option.value);
|
|
165
159
|
},
|
|
166
160
|
style: {
|
|
167
161
|
padding: "8px 24px",
|
|
168
|
-
cursor: "pointer"
|
|
162
|
+
cursor: "pointer",
|
|
163
|
+
borderBottom: "1px solid #f0f0f0"
|
|
169
164
|
}
|
|
170
165
|
}, option.label);
|
|
171
166
|
}));
|
|
172
|
-
})))));
|
|
167
|
+
}))), document.body));
|
|
173
168
|
};
|
|
174
169
|
var _default = GroupedSelect;
|
|
175
170
|
exports.default = _default;
|