tenjin-ui-kit 0.3.74 → 0.3.76
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/common/hooks/apiHooks.js +91 -199
- package/common/hooks/newApiHook.js +127 -258
- package/common/utils/security/index.js +2 -2
- package/common/utils/security/securityConfig.js +1 -2
- package/components/Canvas.js +172 -101
- package/components/DragBox/index.js +21 -31
- package/components/InputWithChip/index.js +178 -83
- package/components/RightContext/index.js +17 -41
- package/components/WorkFlow.js +19 -29
- package/components/WorkFlowBuilder.js +32 -56
- package/components/alert/Style.js +11 -14
- package/components/alert/index.js +8 -14
- package/components/attachment/index.js +26 -31
- package/components/authenticationProvider/AuthError.js +3 -4
- package/components/authenticationProvider/AuthLoader.js +3 -4
- package/components/authenticationProvider/index.js +58 -130
- package/components/avatar/index.js +24 -23
- package/components/avatar/styles.js +76 -77
- package/components/breadCrumbs/index.js +64 -89
- package/components/breadCrumbs/style.js +1 -4
- package/components/browsingTestCaseLayout/DetailsViewLayout/DetailsViewContent/index.js +7 -6
- package/components/browsingTestCaseLayout/DetailsViewLayout/DetailsViewContent/style.js +5 -8
- package/components/browsingTestCaseLayout/DetailsViewLayout/DetailsViewHeader/index.js +7 -6
- package/components/browsingTestCaseLayout/TreeViewLayout/TreeViewContent/Index.js +8 -7
- package/components/browsingTestCaseLayout/TreeViewLayout/TreeViewHeader/Index.js +8 -7
- package/components/browsingTestCaseLayout/TreeViewLayout/TreeViewHeader/style.js +16 -19
- package/components/browsingTestCaseLayout/index.js +30 -46
- package/components/button/index.js +47 -58
- package/components/chatBotModal/index.js +40 -61
- package/components/checkBox/index.js +8 -10
- package/components/combobox/index.js +66 -100
- package/components/divider/index.js +9 -18
- package/components/editableField/index.js +19 -46
- package/components/error/index.js +6 -12
- package/components/errorBoundary/index.js +74 -98
- package/components/fileUploader/index.js +46 -58
- package/components/fileUploader/style.js +46 -49
- package/components/filter/ValueSelector.js +148 -243
- package/components/filter/index.js +43 -66
- package/components/iconButton/index.js +3 -4
- package/components/input/index.js +70 -90
- package/components/layout/index.js +36 -49
- package/components/layout/main/index.js +13 -14
- package/components/layout/main/style.js +11 -14
- package/components/layout/pageContent/index.js +8 -7
- package/components/layout/sidebar/FlatMenu.js +51 -47
- package/components/layout/sidebar/GroupedIconMenu.js +169 -194
- package/components/layout/sidebar/GroupedMenu.js +45 -50
- package/components/layout/sidebar/ProjectMenu.js +165 -185
- package/components/layout/sidebar/index.js +27 -26
- package/components/layout/sidebar/style.js +138 -143
- package/components/layout/topBar/ProjectTopbar.js +86 -119
- package/components/layout/topBar/UserAvatar.js +51 -65
- package/components/layout/topBar/index.js +23 -41
- package/components/loader/index.js +9 -12
- package/components/menu/index.js +23 -42
- package/components/modal/Modal.js +5 -6
- package/components/modal/index.js +16 -20
- package/components/modal/style.js +53 -56
- package/components/optionMenu/index.js +32 -47
- package/components/pagination/index.js +23 -43
- package/components/pagination/style.js +25 -28
- package/components/paginationUpdated/index.js +19 -26
- package/components/paper/index.js +20 -22
- package/components/paper/style.js +24 -27
- package/components/reactSelect/index.js +64 -97
- package/components/reactSelect/style.js +131 -151
- package/components/richTextEditor/index.js +24 -48
- package/components/select/GroupedSelect.js +56 -100
- package/components/select/SimpleSelect.js +59 -99
- package/components/select/index.js +56 -69
- package/components/simpleSelect/index.js +18 -22
- package/components/sort/index.js +23 -36
- package/components/switch/index.js +14 -15
- package/components/switch/style.js +29 -32
- package/components/switch/switch.js +30 -47
- package/components/table/ReactTable.js +59 -83
- package/components/table/SimpleTable.js +67 -91
- package/components/table/index.js +300 -206
- package/components/text/index.js +22 -30
- package/components/timeStamp/index.js +4 -6
- package/components/timeStamp/style.js +12 -15
- package/components/topBar/index.js +86 -102
- package/components/tree/index.js +30 -58
- package/components/tree/style.js +20 -23
- package/components/valuePicker/ValueSelector.js +78 -160
- package/components/valuePicker/index.js +30 -50
- package/components/wrapperLayout/layout/index.js +8 -7
- package/components/wrapperLayout/main/index.js +8 -7
- package/components/wrapperLayout/main/pageContainer/index.js +6 -5
- package/components/wrapperLayout/main/sideBar/index.js +171 -175
- package/components/wrapperLayout/main/sideBar/style.js +177 -183
- package/components/wrapperLayout/topBar/UserAvatar.js +6 -5
- package/components/wrapperLayout/topBar/avatar.js +15 -18
- package/components/wrapperLayout/topBar/index.js +115 -107
- package/components/wrapperLayout/topBar/menuIcon.js +6 -5
- package/components/wrapperLayout/topBar/style.js +63 -64
- package/http/index.js +92 -188
- package/index.js +53 -55
- package/package.json +6 -3
- package/templates/listPage/index.js +168 -196
- package/themes/default.js +5 -7
- package/themes/defaultSmall.js +2 -3
- package/themes/responsiveTheme.js +6 -8
|
@@ -10,268 +10,177 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var colors = _interopRequireWildcard(require("@mui/material/colors"));
|
|
11
11
|
var _button = _interopRequireDefault(require("../button"));
|
|
12
12
|
var _text = _interopRequireDefault(require("../text"));
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
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); }
|
|
17
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
18
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
20
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
21
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
22
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
23
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
24
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
25
|
-
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."); }
|
|
26
|
-
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); }
|
|
27
|
-
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; }
|
|
28
|
-
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; } }
|
|
29
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
30
|
-
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; }
|
|
31
|
-
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; }
|
|
32
|
-
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; }
|
|
33
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
34
|
-
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); }
|
|
35
|
-
var determineSelectedOptions = function determineSelectedOptions(options, selectedIds, valueKey) {
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const determineSelectedOptions = (options, selectedIds, valueKey) => {
|
|
36
16
|
if (!options || options.length < 1) return [];
|
|
37
17
|
if (!selectedIds || selectedIds.length < 1) return options;
|
|
38
|
-
return options.map(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
18
|
+
return options.map(o => ({
|
|
19
|
+
...o,
|
|
20
|
+
selected: selectedIds.includes(o[valueKey])
|
|
21
|
+
}));
|
|
43
22
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var itemRefs = (0, _react.useRef)([]);
|
|
81
|
-
var clearBtnRef = (0, _react.useRef)(null);
|
|
82
|
-
var _useState11 = (0, _react.useState)(false),
|
|
83
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
84
|
-
clearFocused = _useState12[0],
|
|
85
|
-
setClearFocused = _useState12[1];
|
|
86
|
-
(0, _react.useImperativeHandle)(ref, function () {
|
|
87
|
-
return {
|
|
88
|
-
handleKeyDown: function handleKeyDown(e) {
|
|
89
|
-
if (e.key === "Tab") {
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
e.stopPropagation();
|
|
92
|
-
if (clearFocused) {
|
|
93
|
-
setClearFocused(false);
|
|
94
|
-
requestAnimationFrame(function () {
|
|
95
|
-
var _inputRef$current;
|
|
96
|
-
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
97
|
-
});
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
setClearFocused(true);
|
|
101
|
-
setActiveIndex(-1);
|
|
23
|
+
const ValueSelector = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
24
|
+
let {
|
|
25
|
+
options,
|
|
26
|
+
valueKey,
|
|
27
|
+
displayKey,
|
|
28
|
+
avatarKey,
|
|
29
|
+
colorKey,
|
|
30
|
+
onChange,
|
|
31
|
+
multiple,
|
|
32
|
+
defaultSelectedOptionIds,
|
|
33
|
+
fetchData,
|
|
34
|
+
showClearItems,
|
|
35
|
+
showAvatar,
|
|
36
|
+
setSearch,
|
|
37
|
+
inputRef,
|
|
38
|
+
searchText
|
|
39
|
+
} = _ref;
|
|
40
|
+
const theme = (0, _material.useTheme)();
|
|
41
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
42
|
+
const [localOptions, setLocalOptions] = (0, _react.useState)([]);
|
|
43
|
+
const [filter, setFilter] = (0, _react.useState)("");
|
|
44
|
+
const [filteredLocalOptions, setFilteredLocalOptions] = (0, _react.useState)([]);
|
|
45
|
+
const [activeIndex, setActiveIndex] = (0, _react.useState)(-1);
|
|
46
|
+
const itemRefs = (0, _react.useRef)([]);
|
|
47
|
+
const clearBtnRef = (0, _react.useRef)(null);
|
|
48
|
+
const [clearFocused, setClearFocused] = (0, _react.useState)(false);
|
|
49
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
50
|
+
handleKeyDown: e => {
|
|
51
|
+
if (e.key === "Tab") {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
e.stopPropagation();
|
|
54
|
+
if (clearFocused) {
|
|
55
|
+
setClearFocused(false);
|
|
56
|
+
requestAnimationFrame(() => {
|
|
57
|
+
inputRef?.current?.focus();
|
|
58
|
+
});
|
|
102
59
|
return;
|
|
103
60
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
61
|
+
setClearFocused(true);
|
|
62
|
+
setActiveIndex(-1);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!["ArrowDown", "ArrowUp", "Enter"].includes(e.key)) return;
|
|
66
|
+
if (e.key === "ArrowDown") {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
if (clearFocused) {
|
|
69
|
+
setClearFocused(false);
|
|
70
|
+
setActiveIndex(0);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
setActiveIndex(prev => {
|
|
74
|
+
if (filteredLocalOptions.length === 0) return -1;
|
|
75
|
+
return prev < filteredLocalOptions.length - 1 ? prev + 1 : 0;
|
|
76
|
+
});
|
|
77
|
+
} else if (e.key === "ArrowUp") {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
if (clearFocused) {
|
|
80
|
+
setClearFocused(false);
|
|
81
|
+
setActiveIndex(0);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
setActiveIndex(prev => {
|
|
85
|
+
if (filteredLocalOptions.length === 0) return -1;
|
|
86
|
+
return prev > 0 ? prev - 1 : filteredLocalOptions.length - 1;
|
|
87
|
+
});
|
|
88
|
+
} else if (e.key === "Enter") {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
if (clearFocused) {
|
|
91
|
+
handleClearSelection();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (activeIndex >= 0 && activeIndex < filteredLocalOptions.length) {
|
|
95
|
+
handleSelection(filteredLocalOptions[activeIndex]);
|
|
136
96
|
}
|
|
137
97
|
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
(0, _react.useEffect)(
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
(0, _react.useEffect)(() => {
|
|
141
101
|
if (activeIndex >= 0 && itemRefs.current[activeIndex]) {
|
|
142
102
|
itemRefs.current[activeIndex].scrollIntoView({
|
|
143
103
|
block: "nearest"
|
|
144
104
|
});
|
|
145
105
|
}
|
|
146
106
|
}, [activeIndex]);
|
|
147
|
-
(0, _react.useEffect)(
|
|
107
|
+
(0, _react.useEffect)(() => {
|
|
148
108
|
resolveOptions();
|
|
149
109
|
}, []);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
setLoading(false);
|
|
172
|
-
return _context.abrupt("return", response);
|
|
173
|
-
case 11:
|
|
174
|
-
case "end":
|
|
175
|
-
return _context.stop();
|
|
176
|
-
}
|
|
177
|
-
}, _callee);
|
|
178
|
-
}));
|
|
179
|
-
return function fetchAsyncData() {
|
|
180
|
-
return _ref2.apply(this, arguments);
|
|
181
|
-
};
|
|
182
|
-
}();
|
|
183
|
-
var resolveOptions = /*#__PURE__*/function () {
|
|
184
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
185
|
-
var tempOptions;
|
|
186
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
187
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
188
|
-
case 0:
|
|
189
|
-
tempOptions = [];
|
|
190
|
-
if (!fetchData) {
|
|
191
|
-
_context2.next = 7;
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
_context2.next = 4;
|
|
195
|
-
return fetchAsyncData();
|
|
196
|
-
case 4:
|
|
197
|
-
tempOptions = _context2.sent;
|
|
198
|
-
_context2.next = 8;
|
|
199
|
-
break;
|
|
200
|
-
case 7:
|
|
201
|
-
tempOptions = _toConsumableArray(options);
|
|
202
|
-
case 8:
|
|
203
|
-
setLocalOptions(determineSelectedOptions(tempOptions, defaultSelectedOptionIds, valueKey));
|
|
204
|
-
case 9:
|
|
205
|
-
case "end":
|
|
206
|
-
return _context2.stop();
|
|
207
|
-
}
|
|
208
|
-
}, _callee2);
|
|
209
|
-
}));
|
|
210
|
-
return function resolveOptions() {
|
|
211
|
-
return _ref3.apply(this, arguments);
|
|
212
|
-
};
|
|
213
|
-
}();
|
|
214
|
-
var filterOptions = function filterOptions() {
|
|
110
|
+
const fetchAsyncData = async () => {
|
|
111
|
+
setLoading(true);
|
|
112
|
+
let response = null;
|
|
113
|
+
if (fetchData) {
|
|
114
|
+
response = await fetchData();
|
|
115
|
+
} else {
|
|
116
|
+
response = [];
|
|
117
|
+
}
|
|
118
|
+
setLoading(false);
|
|
119
|
+
return response;
|
|
120
|
+
};
|
|
121
|
+
const resolveOptions = async () => {
|
|
122
|
+
let tempOptions = [];
|
|
123
|
+
if (fetchData) {
|
|
124
|
+
tempOptions = await fetchAsyncData();
|
|
125
|
+
} else {
|
|
126
|
+
tempOptions = [...options];
|
|
127
|
+
}
|
|
128
|
+
setLocalOptions(determineSelectedOptions(tempOptions, defaultSelectedOptionIds, valueKey));
|
|
129
|
+
};
|
|
130
|
+
const filterOptions = () => {
|
|
215
131
|
if (filter) {
|
|
216
|
-
setFilteredLocalOptions(localOptions.filter(
|
|
217
|
-
|
|
132
|
+
setFilteredLocalOptions(localOptions.filter(o => {
|
|
133
|
+
let searchTarget = o[displayKey].toLowerCase();
|
|
218
134
|
return searchTarget.includes(filter.toLowerCase());
|
|
219
135
|
}));
|
|
220
136
|
} else {
|
|
221
|
-
setFilteredLocalOptions(
|
|
137
|
+
setFilteredLocalOptions([...localOptions]);
|
|
222
138
|
}
|
|
223
139
|
};
|
|
224
|
-
(0, _react.useEffect)(
|
|
140
|
+
(0, _react.useEffect)(() => {
|
|
225
141
|
filterOptions();
|
|
226
142
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
227
143
|
}, [localOptions, filter]);
|
|
228
|
-
|
|
229
|
-
|
|
144
|
+
const handleSelection = option => {
|
|
145
|
+
let newOptions = [];
|
|
230
146
|
if (multiple) {
|
|
231
|
-
newOptions = localOptions.map(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
});
|
|
147
|
+
newOptions = localOptions.map(o => o[valueKey] === option[valueKey] ? {
|
|
148
|
+
...o,
|
|
149
|
+
selected: o.selected ? false : true
|
|
150
|
+
} : o);
|
|
236
151
|
} else {
|
|
237
|
-
newOptions = localOptions.map(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
152
|
+
newOptions = localOptions.map(o => o[valueKey] === option[valueKey] ? {
|
|
153
|
+
...o,
|
|
154
|
+
selected: true
|
|
155
|
+
} : {
|
|
156
|
+
...o,
|
|
157
|
+
selected: false
|
|
243
158
|
});
|
|
244
159
|
}
|
|
245
|
-
onChange(newOptions.filter(
|
|
246
|
-
return o.selected;
|
|
247
|
-
}));
|
|
160
|
+
onChange(newOptions.filter(o => o.selected));
|
|
248
161
|
setLocalOptions(newOptions);
|
|
249
162
|
};
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
});
|
|
163
|
+
const handleClearSelection = () => {
|
|
164
|
+
let newOptions = localOptions.map(l => ({
|
|
165
|
+
...l,
|
|
166
|
+
selected: false
|
|
167
|
+
}));
|
|
256
168
|
onChange([]);
|
|
257
169
|
setLocalOptions(newOptions);
|
|
258
170
|
setSearch("");
|
|
259
171
|
};
|
|
260
|
-
(0, _react.useEffect)(
|
|
261
|
-
|
|
172
|
+
(0, _react.useEffect)(() => {
|
|
173
|
+
const clearFocus = () => {
|
|
262
174
|
setClearFocused(false);
|
|
263
175
|
};
|
|
264
176
|
window.addEventListener("mousedown", clearFocus);
|
|
265
|
-
return
|
|
177
|
+
return () => {
|
|
266
178
|
window.removeEventListener("mousedown", clearFocus);
|
|
267
179
|
};
|
|
268
180
|
}, []);
|
|
269
|
-
(0, _react.useEffect)(
|
|
181
|
+
(0, _react.useEffect)(() => {
|
|
270
182
|
if (searchText) {
|
|
271
|
-
setFilteredLocalOptions(localOptions.filter(
|
|
272
|
-
var _o$displayKey;
|
|
273
|
-
return (_o$displayKey = o[displayKey]) === null || _o$displayKey === void 0 ? void 0 : _o$displayKey.toLowerCase().includes(searchText.toLowerCase());
|
|
274
|
-
}));
|
|
183
|
+
setFilteredLocalOptions(localOptions.filter(o => o[displayKey]?.toLowerCase().includes(searchText.toLowerCase())));
|
|
275
184
|
} else {
|
|
276
185
|
setFilteredLocalOptions(localOptions);
|
|
277
186
|
}
|
|
@@ -296,33 +205,30 @@ var ValueSelector = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
296
205
|
sx: {
|
|
297
206
|
padding: "0rem 0.5rem"
|
|
298
207
|
}
|
|
299
|
-
},
|
|
208
|
+
}, filteredLocalOptions?.length === 0 ? /*#__PURE__*/_react.default.createElement(_text.default, {
|
|
300
209
|
color: "secondary"
|
|
301
|
-
}, "No Data") : filteredLocalOptions.map(
|
|
302
|
-
|
|
303
|
-
|
|
210
|
+
}, "No Data") : filteredLocalOptions.map((o, index) => {
|
|
211
|
+
const altVal = o[avatarKey] === "/" ? " " : o[displayKey];
|
|
212
|
+
const bgcAvatar = colors[o[colorKey]] ? colors[o[colorKey]][500] : "red";
|
|
304
213
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
305
214
|
key: o[valueKey]
|
|
306
215
|
}, /*#__PURE__*/_react.default.createElement(_material.ListItem, {
|
|
307
216
|
dense: true,
|
|
308
217
|
disablePadding: true,
|
|
309
|
-
ref:
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
218
|
+
ref: el => itemRefs.current[index] = el,
|
|
219
|
+
sx: {
|
|
220
|
+
...(o.selected && {
|
|
221
|
+
backgroundColor: "#F5FAFF"
|
|
222
|
+
}),
|
|
223
|
+
...(activeIndex === index && {
|
|
224
|
+
backgroundColor: theme.palette.action.hover
|
|
225
|
+
})
|
|
226
|
+
}
|
|
317
227
|
}, /*#__PURE__*/_react.default.createElement(_material.ListItemButton, {
|
|
318
228
|
disableRipple: true,
|
|
319
229
|
dense: true,
|
|
320
|
-
onClick:
|
|
321
|
-
|
|
322
|
-
},
|
|
323
|
-
onMouseEnter: function onMouseEnter() {
|
|
324
|
-
return setActiveIndex(index);
|
|
325
|
-
}
|
|
230
|
+
onClick: () => handleSelection(o),
|
|
231
|
+
onMouseEnter: () => setActiveIndex(index)
|
|
326
232
|
}, multiple && /*#__PURE__*/_react.default.createElement(_material.ListItemIcon, {
|
|
327
233
|
sx: {
|
|
328
234
|
minWidth: "initial"
|
|
@@ -340,7 +246,7 @@ var ValueSelector = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
340
246
|
alignItems: "center"
|
|
341
247
|
},
|
|
342
248
|
gap: 1
|
|
343
|
-
}, o
|
|
249
|
+
}, o?.icon, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
344
250
|
display: "flex",
|
|
345
251
|
justifyContent: "space-between",
|
|
346
252
|
width: "100%"
|
|
@@ -373,7 +279,7 @@ var ValueSelector = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
373
279
|
style: {
|
|
374
280
|
cursor: "pointer",
|
|
375
281
|
justifySelf: "end",
|
|
376
|
-
border: clearFocused ?
|
|
282
|
+
border: clearFocused ? `2px solid ${theme.palette.primary.main}` : "2px solid transparent",
|
|
377
283
|
borderRadius: 4
|
|
378
284
|
}
|
|
379
285
|
}, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
@@ -401,5 +307,4 @@ ValueSelector.propTypes = {
|
|
|
401
307
|
defaultSelectedOptionIds: _propTypes.default.array,
|
|
402
308
|
fetchData: _propTypes.default.func
|
|
403
309
|
};
|
|
404
|
-
var _default = ValueSelector;
|
|
405
|
-
exports.default = _default;
|
|
310
|
+
var _default = exports.default = ValueSelector;
|