tenjin-ui-kit 0.3.26 → 0.3.28

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 }; }
@@ -23,13 +24,14 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
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; }
24
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; }
25
26
  var GroupedSelect = function GroupedSelect(_ref) {
26
- var _options$find;
27
+ var _options$find, _Object$entries;
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],
@@ -45,18 +47,20 @@ var GroupedSelect = function GroupedSelect(_ref) {
45
47
  var groupOptionsByPageTitle = function groupOptionsByPageTitle(options) {
46
48
  var grouped = {};
47
49
  options.forEach(function (option) {
48
- if (!grouped[option.pageTitle]) {
49
- grouped[option.pageTitle] = [];
50
+ var _grouped$option$pageT;
51
+ if (!grouped[option === null || option === void 0 ? void 0 : option.pageTitle]) {
52
+ grouped[option === null || option === void 0 ? void 0 : option.pageTitle] = [];
50
53
  }
51
- grouped[option.pageTitle].push(option);
54
+ (_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);
52
55
  });
53
56
  return grouped;
54
57
  };
55
58
  var handleSearchChange = function handleSearchChange(event) {
56
- setSearchTerm(event.target.value.toLowerCase());
59
+ setSearchTerm(event.target.value);
57
60
  };
58
61
  var filteredOptions = options.filter(function (option) {
59
- return option.label.toLowerCase().includes(searchTerm) || option.pageTitle.toLowerCase().includes(searchTerm);
62
+ var _option$label, _option$pageTitle;
63
+ 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));
60
64
  });
61
65
  var groupedOptions = groupOptionsByPageTitle(filteredOptions);
62
66
  var toggleDropdown = function toggleDropdown() {
@@ -84,7 +88,8 @@ var GroupedSelect = function GroupedSelect(_ref) {
84
88
  style: {
85
89
  position: "relative",
86
90
  width: "100%"
87
- }
91
+ },
92
+ ref: triggerRef
88
93
  }, /*#__PURE__*/React.createElement("div", {
89
94
  onClick: toggleDropdown,
90
95
  style: {
@@ -100,20 +105,21 @@ var GroupedSelect = function GroupedSelect(_ref) {
100
105
  style: {
101
106
  flexGrow: 1
102
107
  }
103
- }, value ? (_options$find = options.find(function (opt) {
104
- 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
+ }, value ? options === null || options === void 0 ? void 0 : (_options$find = options.find(function (opt) {
109
+ return (opt === null || opt === void 0 ? void 0 : opt.value) === value;
110
+ })) === 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
111
  style: {
107
112
  position: "absolute",
108
- top: "100%",
109
- left: 0,
110
- right: 0,
113
+ top: "".concat(triggerRef.current.getBoundingClientRect().bottom + 8, "px"),
114
+ left: "".concat(triggerRef.current.getBoundingClientRect().left, "px"),
115
+ width: "".concat(triggerRef.current.offsetWidth, "px"),
111
116
  backgroundColor: "#fff",
112
117
  border: "1px solid #ccc",
113
118
  borderRadius: "4px",
119
+ boxShadow: "0px 4px 6px rgba(0, 0, 0, 0.1)",
114
120
  maxHeight: "200px",
115
121
  overflowY: "auto",
116
- zIndex: 1000
122
+ zIndex: 2000
117
123
  }
118
124
  }, /*#__PURE__*/React.createElement("div", {
119
125
  style: {
@@ -129,17 +135,13 @@ var GroupedSelect = function GroupedSelect(_ref) {
129
135
  background: 'white url("https://static.thenounproject.com/png/101791-200.png") no-repeat left',
130
136
  backgroundPosition: "0.875rem center",
131
137
  backgroundSize: "1.125rem",
132
- position: "sticky",
133
- top: 0,
134
- zIndex: 9999,
135
- backgroundColor: "white",
136
138
  height: "2.188rem",
137
139
  margin: 0,
138
140
  width: "100%",
139
141
  border: "1px solid #949494",
140
142
  borderRadius: "4px"
141
143
  }
142
- }), Object.entries(groupedOptions).map(function (_ref2) {
144
+ }), (_Object$entries = Object.entries(groupedOptions)) === null || _Object$entries === void 0 ? void 0 : _Object$entries.map(function (_ref2) {
143
145
  var _ref3 = _slicedToArray(_ref2, 2),
144
146
  pageTitle = _ref3[0],
145
147
  options = _ref3[1];
@@ -151,7 +153,7 @@ var GroupedSelect = function GroupedSelect(_ref) {
151
153
  backgroundColor: "#f5f5f5"
152
154
  },
153
155
  semibold: true
154
- }, pageTitle), options.map(function (option) {
156
+ }, pageTitle !== null && pageTitle !== void 0 ? pageTitle : "N/A"), options.map(function (option) {
155
157
  return /*#__PURE__*/React.createElement("div", {
156
158
  key: option.value,
157
159
  onClick: function onClick() {
@@ -164,7 +166,7 @@ var GroupedSelect = function GroupedSelect(_ref) {
164
166
  }
165
167
  }, option.label);
166
168
  }));
167
- })))));
169
+ }))), document.body));
168
170
  };
169
171
  var _default = GroupedSelect;
170
172
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tenjin-ui-kit",
3
- "version": "0.3.26",
3
+ "version": "0.3.28",
4
4
  "repository": {
5
5
  "url": "https://gitlab.com/yethi/react/tenjin-ui-kit.git"
6
6
  },