tenjin-ui-kit 0.3.72 → 0.3.74
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.
- package/README.md +13 -13
- package/common/hooks/apiHooks.js +182 -114
- package/common/hooks/newApiHook.js +225 -143
- package/common/utils/security/index.js +2 -2
- package/common/utils/security/securityConfig.js +2 -1
- package/components/Canvas.js +88 -164
- package/components/DragBox/index.js +26 -21
- package/components/InputWithChip/index.js +57 -164
- package/components/RightContext/index.css +20 -20
- package/components/RightContext/index.js +28 -19
- package/components/WorkFlow.js +23 -18
- package/components/WorkFlowBuilder.js +48 -33
- package/components/alert/Style.js +14 -11
- package/components/alert/index.js +12 -10
- package/components/attachment/index.js +28 -21
- package/components/authenticationProvider/AuthError.js +4 -3
- package/components/authenticationProvider/AuthLoader.js +4 -3
- package/components/authenticationProvider/index.js +116 -60
- package/components/avatar/index.js +14 -13
- package/components/avatar/styles.js +77 -74
- package/components/breadCrumbs/index.js +53 -42
- package/components/breadCrumbs/style.js +4 -1
- package/components/browsingTestCaseLayout/DetailsViewLayout/DetailsViewContent/index.js +6 -5
- package/components/browsingTestCaseLayout/DetailsViewLayout/DetailsViewContent/style.js +8 -5
- package/components/browsingTestCaseLayout/DetailsViewLayout/DetailsViewHeader/index.js +5 -4
- package/components/browsingTestCaseLayout/TreeViewLayout/TreeViewContent/Index.js +5 -4
- package/components/browsingTestCaseLayout/TreeViewLayout/TreeViewHeader/Index.js +6 -5
- package/components/browsingTestCaseLayout/TreeViewLayout/TreeViewHeader/style.js +19 -16
- package/components/browsingTestCaseLayout/index.js +30 -25
- package/components/browsingTestCaseLayout/style.css +82 -82
- package/components/button/index.js +43 -36
- package/components/chatBotModal/index.js +45 -36
- package/components/checkBox/index.js +9 -8
- package/components/combobox/index.js +188 -167
- package/components/divider/index.js +18 -14
- package/components/editableField/index.js +28 -19
- package/components/error/index.js +12 -6
- package/components/errorBoundary/index.js +94 -74
- package/components/fileUploader/index.js +35 -30
- package/components/fileUploader/style.js +49 -46
- package/components/filter/ValueSelector.js +207 -135
- package/components/filter/index.js +33 -26
- package/components/iconButton/index.js +4 -3
- package/components/input/index.js +38 -31
- package/components/layout/index.js +31 -27
- package/components/layout/main/index.js +13 -10
- package/components/layout/main/style.js +14 -11
- package/components/layout/pageContent/index.js +7 -6
- package/components/layout/sidebar/FlatMenu.js +43 -43
- package/components/layout/sidebar/GroupedIconMenu.js +108 -95
- package/components/layout/sidebar/GroupedMenu.js +48 -38
- package/components/layout/sidebar/ProjectMenu.js +116 -109
- package/components/layout/sidebar/index.js +18 -15
- package/components/layout/sidebar/style.js +143 -138
- package/components/layout/topBar/ProjectTopbar.js +98 -81
- package/components/layout/topBar/UserAvatar.js +55 -48
- package/components/layout/topBar/index.js +33 -22
- package/components/loader/index.js +12 -9
- package/components/menu/index.js +35 -26
- package/components/modal/Modal.js +6 -5
- package/components/modal/index.js +13 -10
- package/components/modal/style.js +56 -53
- package/components/optionMenu/index.js +66 -59
- package/components/pagination/index.js +39 -24
- package/components/pagination/style.js +28 -25
- package/components/paginationUpdated/index.js +18 -15
- package/components/paper/index.js +16 -15
- package/components/paper/style.js +27 -24
- package/components/reactSelect/index.js +63 -46
- package/components/reactSelect/style.js +150 -117
- package/components/richTextEditor/index.js +44 -25
- package/components/select/GroupedSelect.js +121 -64
- package/components/select/SimpleSelect.js +78 -50
- package/components/select/index.js +54 -38
- package/components/simpleSelect/index.js +15 -12
- package/components/sort/index.js +22 -19
- package/components/switch/index.js +11 -10
- package/components/switch/style.js +32 -29
- package/components/switch/switch.js +23 -17
- package/components/table/ReactTable.js +71 -54
- package/components/table/SimpleTable.js +78 -59
- package/components/table/index.js +186 -311
- package/components/text/index.js +17 -15
- package/components/timeStamp/index.js +6 -4
- package/components/timeStamp/style.js +15 -12
- package/components/topBar/index.js +92 -85
- package/components/tree/index.js +47 -29
- package/components/tree/style.js +23 -20
- package/components/valuePicker/ValueSelector.js +138 -70
- package/components/valuePicker/index.js +26 -19
- package/components/wrapperLayout/layout/index.js +5 -4
- package/components/wrapperLayout/main/index.js +5 -4
- package/components/wrapperLayout/main/pageContainer/index.js +5 -4
- package/components/wrapperLayout/main/sideBar/index.js +110 -120
- package/components/wrapperLayout/main/sideBar/style.js +183 -177
- package/components/wrapperLayout/topBar/UserAvatar.js +5 -4
- package/components/wrapperLayout/topBar/avatar.js +12 -10
- package/components/wrapperLayout/topBar/index.js +97 -111
- package/components/wrapperLayout/topBar/menuIcon.js +5 -4
- package/components/wrapperLayout/topBar/style.js +64 -61
- package/http/index.js +183 -90
- package/index.js +55 -53
- package/package.json +124 -124
- package/templates/listPage/index.js +57 -36
- package/themes/default.js +7 -5
- package/themes/defaultSmall.js +3 -2
- package/themes/responsiveTheme.js +8 -6
|
@@ -1,28 +1,30 @@
|
|
|
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _rte = require("@mantine/rte");
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
function
|
|
16
|
-
function
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
var _excluded = ["controls", "readOnly"];
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
var RichTextEditorTest = function RichTextEditorTest(_ref) {
|
|
21
|
+
var _ref$controls = _ref.controls,
|
|
20
22
|
controls = _ref$controls === void 0 ? {} : _ref$controls,
|
|
21
23
|
_ref$readOnly = _ref.readOnly,
|
|
22
24
|
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
23
25
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
26
|
// By default everything is enabled
|
|
25
|
-
|
|
27
|
+
var defaultControls = {
|
|
26
28
|
bold: true,
|
|
27
29
|
italic: true,
|
|
28
30
|
underline: true,
|
|
@@ -37,22 +39,38 @@ const RichTextEditorTest = _ref => {
|
|
|
37
39
|
alignCenter: true,
|
|
38
40
|
alignRight: true
|
|
39
41
|
};
|
|
40
|
-
|
|
42
|
+
var editorControls = (0, _react.useMemo)(function () {
|
|
41
43
|
if (readOnly) {
|
|
42
44
|
return [];
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
return [["bold", "italic", "underline"].filter(
|
|
46
|
+
var finalControls = _objectSpread(_objectSpread({}, defaultControls), controls);
|
|
47
|
+
return [["bold", "italic", "underline"].filter(function (c) {
|
|
48
|
+
return finalControls[c];
|
|
49
|
+
}), ["link", "image"].filter(function (c) {
|
|
50
|
+
return finalControls[c];
|
|
51
|
+
}), ["unorderedList", "orderedList"].filter(function (c) {
|
|
52
|
+
return finalControls[c];
|
|
53
|
+
}), ["h1", "h2", "h3"].filter(function (c) {
|
|
54
|
+
return finalControls[c];
|
|
55
|
+
}), ["alignLeft", "alignCenter", "alignRight"].filter(function (c) {
|
|
56
|
+
return finalControls[c];
|
|
57
|
+
})].filter(function (group) {
|
|
58
|
+
return group.length > 0;
|
|
59
|
+
});
|
|
46
60
|
}, [controls, readOnly]);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
var mentions = (0, _react.useMemo)(function () {
|
|
62
|
+
return {
|
|
63
|
+
allowedChars: /^[A-Za-z\sÅÄÖåäö]*$/,
|
|
64
|
+
mentionDenotationChars: ["@"],
|
|
65
|
+
source: function source(searchTerm, renderList, mentionChar) {
|
|
66
|
+
var list = mentionChar === "@" ? props.data : "";
|
|
67
|
+
var includesSearchTerm = list.filter(function (item) {
|
|
68
|
+
return item.value.toLowerCase().includes(searchTerm && searchTerm.toLowerCase());
|
|
69
|
+
});
|
|
70
|
+
renderList(includesSearchTerm);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}, [props.data]);
|
|
56
74
|
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_rte.RichTextEditor, {
|
|
57
75
|
controls: editorControls,
|
|
58
76
|
value: props.value,
|
|
@@ -61,4 +79,5 @@ const RichTextEditorTest = _ref => {
|
|
|
61
79
|
readOnly: readOnly
|
|
62
80
|
}));
|
|
63
81
|
};
|
|
64
|
-
var _default =
|
|
82
|
+
var _default = RichTextEditorTest;
|
|
83
|
+
exports.default = _default;
|
|
@@ -1,5 +1,6 @@
|
|
|
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -9,87 +10,125 @@ var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
|
|
|
9
10
|
var _fa = require("react-icons/fa");
|
|
10
11
|
var _reactDom = require("react-dom");
|
|
11
12
|
var _text = _interopRequireDefault(require("../text"));
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(
|
|
14
|
-
function
|
|
15
|
-
function
|
|
16
|
-
function
|
|
13
|
+
var _excluded = ["options", "onChange", "value", "defaultValue", "fullWidth"];
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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); }
|
|
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
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."); }
|
|
18
|
-
function _unsupportedIterableToArray(
|
|
19
|
-
function _arrayLikeToArray(
|
|
20
|
-
function _iterableToArrayLimit(
|
|
21
|
-
function _arrayWithHoles(
|
|
22
|
-
function _objectWithoutProperties(
|
|
23
|
-
function _objectWithoutPropertiesLoose(
|
|
24
|
-
|
|
25
|
-
var _options$find,
|
|
26
|
-
|
|
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); }
|
|
21
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
22
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
23
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
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
|
+
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
|
+
var GroupedSelect = function GroupedSelect(_ref) {
|
|
27
|
+
var _options$find, _triggerRef$current2, _triggerRef$current3, _triggerRef$current4;
|
|
28
|
+
var _ref$options = _ref.options,
|
|
29
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
27
30
|
onChange = _ref.onChange,
|
|
28
31
|
propValue = _ref.value,
|
|
29
32
|
defaultValue = _ref.defaultValue,
|
|
30
33
|
fullWidth = _ref.fullWidth,
|
|
31
34
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
var triggerRef = React.useRef(null);
|
|
36
|
+
var dropdownRef = React.useRef(null);
|
|
37
|
+
var _React$useState = React.useState(""),
|
|
34
38
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
35
39
|
searchTerm = _React$useState2[0],
|
|
36
40
|
setSearchTerm = _React$useState2[1];
|
|
37
|
-
|
|
41
|
+
var _React$useState3 = React.useState(false),
|
|
38
42
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
39
43
|
isDropdownOpen = _React$useState4[0],
|
|
40
44
|
setIsDropdownOpen = _React$useState4[1];
|
|
41
|
-
|
|
45
|
+
var _React$useState5 = React.useState(propValue !== null && propValue !== void 0 ? propValue : defaultValue),
|
|
42
46
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
43
47
|
value = _React$useState6[0],
|
|
44
48
|
setValue = _React$useState6[1];
|
|
45
|
-
|
|
49
|
+
var _React$useState7 = React.useState(null),
|
|
46
50
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
47
51
|
hoveredOption = _React$useState8[0],
|
|
48
52
|
setHoveredOption = _React$useState8[1];
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
grouped[option === null || option === void 0 ? void 0 : option.pageTitle] = [];
|
|
53
|
+
var groupOptionsByPageTitle = React.useCallback(function (options) {
|
|
54
|
+
return options.reduce(function (grouped, option) {
|
|
55
|
+
var pageTitle = option === null || option === void 0 ? void 0 : option.pageTitle;
|
|
56
|
+
if (!grouped[pageTitle]) {
|
|
57
|
+
grouped[pageTitle] = [];
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
|
|
59
|
+
grouped[pageTitle].push(option);
|
|
60
|
+
return grouped;
|
|
61
|
+
}, {});
|
|
62
|
+
}, []);
|
|
63
|
+
var handleSearchChange = function handleSearchChange(event) {
|
|
61
64
|
setSearchTerm(event.target.value);
|
|
62
65
|
};
|
|
63
|
-
|
|
64
|
-
var
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
var filteredOptions = React.useMemo(function () {
|
|
67
|
+
var search = searchTerm.toLowerCase();
|
|
68
|
+
return options.filter(function (option) {
|
|
69
|
+
var _option$label, _option$pageTitle;
|
|
70
|
+
return (option === null || option === void 0 ? void 0 : (_option$label = option.label) === null || _option$label === void 0 ? void 0 : _option$label.toLowerCase().includes(search)) || (option === null || option === void 0 ? void 0 : (_option$pageTitle = option.pageTitle) === null || _option$pageTitle === void 0 ? void 0 : _option$pageTitle.toLowerCase().includes(search));
|
|
71
|
+
});
|
|
72
|
+
}, [options, searchTerm]);
|
|
73
|
+
var groupedOptions = React.useMemo(function () {
|
|
74
|
+
return groupOptionsByPageTitle(filteredOptions);
|
|
75
|
+
}, [filteredOptions, groupOptionsByPageTitle]);
|
|
76
|
+
var toggleDropdown = function toggleDropdown() {
|
|
77
|
+
setIsDropdownOpen(function (prev) {
|
|
78
|
+
return !prev;
|
|
79
|
+
});
|
|
70
80
|
};
|
|
71
|
-
|
|
81
|
+
var handleOptionClick = function handleOptionClick(selectedValue) {
|
|
72
82
|
setValue(selectedValue);
|
|
73
83
|
setIsDropdownOpen(false);
|
|
74
|
-
|
|
84
|
+
setSearchTerm("");
|
|
85
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
75
86
|
target: {
|
|
76
87
|
value: selectedValue
|
|
77
88
|
}
|
|
78
89
|
});
|
|
79
90
|
};
|
|
80
|
-
|
|
91
|
+
var handleCloseDropdown = function handleCloseDropdown() {
|
|
81
92
|
setIsDropdownOpen(false);
|
|
82
93
|
};
|
|
94
|
+
|
|
95
|
+
// Keep internal value in sync if component is used as a controlled component
|
|
96
|
+
React.useEffect(function () {
|
|
97
|
+
if (propValue !== undefined) {
|
|
98
|
+
setValue(propValue);
|
|
99
|
+
}
|
|
100
|
+
}, [propValue]);
|
|
101
|
+
|
|
102
|
+
// Close dropdown when clicking outside
|
|
103
|
+
React.useEffect(function () {
|
|
104
|
+
if (!isDropdownOpen) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
var handleOutsideClick = function handleOutsideClick(event) {
|
|
108
|
+
var _triggerRef$current, _dropdownRef$current;
|
|
109
|
+
var target = event.target;
|
|
110
|
+
var clickedInsideTrigger = (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.contains(target);
|
|
111
|
+
var clickedInsideDropdown = (_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.contains(target);
|
|
112
|
+
if (clickedInsideTrigger || clickedInsideDropdown) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
handleCloseDropdown();
|
|
116
|
+
};
|
|
117
|
+
document.addEventListener("mousedown", handleOutsideClick);
|
|
118
|
+
return function () {
|
|
119
|
+
document.removeEventListener("mousedown", handleOutsideClick);
|
|
120
|
+
};
|
|
121
|
+
}, [isDropdownOpen]);
|
|
83
122
|
return /*#__PURE__*/React.createElement(_FormControl.default, _extends({
|
|
84
123
|
sx: {
|
|
85
124
|
width: fullWidth ? "100%" : 200
|
|
86
125
|
}
|
|
87
126
|
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
127
|
+
ref: triggerRef,
|
|
88
128
|
style: {
|
|
89
129
|
position: "relative",
|
|
90
130
|
width: "100%"
|
|
91
|
-
}
|
|
92
|
-
ref: triggerRef
|
|
131
|
+
}
|
|
93
132
|
}, /*#__PURE__*/React.createElement("div", {
|
|
94
133
|
onClick: toggleDropdown,
|
|
95
134
|
style: {
|
|
@@ -105,12 +144,15 @@ const GroupedSelect = _ref => {
|
|
|
105
144
|
style: {
|
|
106
145
|
flexGrow: 1
|
|
107
146
|
}
|
|
108
|
-
}, value ? options === null || options === void 0
|
|
147
|
+
}, value ? options === null || options === void 0 ? void 0 : (_options$find = options.find(function (option) {
|
|
148
|
+
return (option === null || option === void 0 ? void 0 : option.id) === value;
|
|
149
|
+
})) === 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", {
|
|
150
|
+
ref: dropdownRef,
|
|
109
151
|
style: {
|
|
110
152
|
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"),
|
|
153
|
+
top: "".concat(((_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : _triggerRef$current2.getBoundingClientRect().bottom) + 8, "px"),
|
|
154
|
+
left: "".concat((_triggerRef$current3 = triggerRef.current) === null || _triggerRef$current3 === void 0 ? void 0 : _triggerRef$current3.getBoundingClientRect().left, "px"),
|
|
155
|
+
width: "".concat((_triggerRef$current4 = triggerRef.current) === null || _triggerRef$current4 === void 0 ? void 0 : _triggerRef$current4.offsetWidth, "px"),
|
|
114
156
|
backgroundColor: "#fff",
|
|
115
157
|
border: "1px solid #ccc",
|
|
116
158
|
borderRadius: "4px",
|
|
@@ -137,31 +179,46 @@ const GroupedSelect = _ref => {
|
|
|
137
179
|
margin: 0,
|
|
138
180
|
width: "100%",
|
|
139
181
|
border: "1px solid #949494",
|
|
140
|
-
borderRadius: "4px"
|
|
182
|
+
borderRadius: "4px",
|
|
183
|
+
boxSizing: "border-box"
|
|
141
184
|
}
|
|
142
|
-
}),
|
|
143
|
-
|
|
185
|
+
}), Object.entries(groupedOptions).map(function (_ref2) {
|
|
186
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
144
187
|
pageTitle = _ref3[0],
|
|
145
|
-
|
|
188
|
+
groupedPageOptions = _ref3[1];
|
|
146
189
|
return /*#__PURE__*/React.createElement("div", {
|
|
147
190
|
key: pageTitle
|
|
148
191
|
}, /*#__PURE__*/React.createElement(_text.default, {
|
|
149
192
|
style: {
|
|
150
193
|
padding: "5px 10px"
|
|
151
|
-
// backgroundColor: "#f5f5f5",
|
|
152
194
|
},
|
|
153
195
|
semibold: true
|
|
154
|
-
}, pageTitle
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
196
|
+
}, pageTitle || "N/A"), groupedPageOptions.map(function (option) {
|
|
197
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
198
|
+
key: option === null || option === void 0 ? void 0 : option.id,
|
|
199
|
+
onClick: function onClick() {
|
|
200
|
+
return handleOptionClick(option.id);
|
|
201
|
+
},
|
|
202
|
+
onMouseEnter: function onMouseEnter() {
|
|
203
|
+
return setHoveredOption(option.id);
|
|
204
|
+
},
|
|
205
|
+
onMouseLeave: function onMouseLeave() {
|
|
206
|
+
return setHoveredOption(null);
|
|
207
|
+
},
|
|
208
|
+
style: {
|
|
209
|
+
padding: "8px 24px",
|
|
210
|
+
cursor: "pointer",
|
|
211
|
+
backgroundColor: value === (option === null || option === void 0 ? void 0 : option.id) ? "#f0f0f7" : hoveredOption === (option === null || option === void 0 ? void 0 : option.id) ? "#f5f5f5" : "transparent"
|
|
212
|
+
}
|
|
213
|
+
}, option === null || option === void 0 ? void 0 : option.label);
|
|
214
|
+
}));
|
|
215
|
+
}), Object.keys(groupedOptions).length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
216
|
+
style: {
|
|
217
|
+
padding: "10px",
|
|
218
|
+
textAlign: "center",
|
|
219
|
+
color: "#666"
|
|
220
|
+
}
|
|
221
|
+
}, "No options found"))), document.body));
|
|
166
222
|
};
|
|
167
|
-
var _default =
|
|
223
|
+
var _default = GroupedSelect;
|
|
224
|
+
exports.default = _default;
|