@chaoswise/business 0.0.6 → 0.0.7

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.
Files changed (37) hide show
  1. package/lib/AggregateSearch/CLSPL/CLQLLexer.js +80 -0
  2. package/lib/AggregateSearch/CLSPL/CLQLParser.js +2797 -0
  3. package/lib/AggregateSearch/CLSPL/CLQLParserListener.js +349 -0
  4. package/lib/AggregateSearch/CLSPL/CLQLParserVisitor.js +253 -0
  5. package/lib/AggregateSearch/CLSPL/SPLStagy.js +189 -0
  6. package/lib/AggregateSearch/CLSPL/index.js +176 -0
  7. package/lib/AggregateSearch/CLSPL/makeTokenizeFn.js +18 -0
  8. package/lib/AggregateSearch/CLSPL/token.js +7 -0
  9. package/lib/AggregateSearch/components/DropDown/assets/combined.svg +22 -0
  10. package/lib/AggregateSearch/components/DropDown/assets/copy.svg +22 -0
  11. package/lib/AggregateSearch/components/DropDown/assets/delete.svg +24 -0
  12. package/lib/AggregateSearch/components/DropDown/assets/home.svg +20 -0
  13. package/lib/AggregateSearch/components/DropDown/assets/key.svg +21 -0
  14. package/lib/AggregateSearch/components/DropDown/assets/star.svg +22 -0
  15. package/lib/AggregateSearch/components/DropDown/assets/time-circle.svg +20 -0
  16. package/lib/AggregateSearch/components/DropDown/assets/value.svg +23 -0
  17. package/lib/AggregateSearch/components/DropDown/index.js +556 -0
  18. package/lib/AggregateSearch/components/DropDown/index.less +102 -0
  19. package/lib/AggregateSearch/components/SwitchBtn/assets/tag-icon.svg +17 -0
  20. package/lib/AggregateSearch/components/SwitchBtn/assets/text-icon.svg +18 -0
  21. package/lib/AggregateSearch/components/SwitchBtn/index.js +24 -0
  22. package/lib/AggregateSearch/components/SwitchBtn/index.less +15 -0
  23. package/lib/AggregateSearch/hooks/useDropDown.js +399 -0
  24. package/lib/AggregateSearch/index.js +350 -0
  25. package/lib/AggregateSearch/index.less +123 -0
  26. package/lib/AggregateSearch/utils/index.js +362 -0
  27. package/lib/PropertyControlViewer/assets/doSelect.less +1 -1
  28. package/lib/PropertyControlViewer/assets/index.less +3 -3
  29. package/lib/PropertyControlViewer/components/DoCiUnitBitmap.js +1 -1
  30. package/lib/PropertyControlViewer/components/DoDefaultPlaceholder.js +1 -1
  31. package/lib/PropertyControlViewer/components/DoUser.js +4 -4
  32. package/lib/PropertyControlViewer/components/TagShowMoreList/index.js +1 -1
  33. package/lib/PropertyControlViewer/config/utils.js +5 -4
  34. package/lib/PropertyControlViewer/index.js +77 -76
  35. package/lib/PropertyControlViewer/index.less +30 -0
  36. package/lib/index.js +2 -1
  37. package/package.json +5 -3
@@ -0,0 +1,556 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ import _Dropdown from "@chaoswise/ui/lib/Antd/Dropdown";
3
+ import _Button from "@chaoswise/ui/lib/Button";
4
+ import _TooltipText from "@chaoswise/ui/lib/TooltipText";
5
+ import _message from "@chaoswise/ui/lib/message";
6
+ import _Spin from "@chaoswise/ui/lib/Antd/Spin";
7
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+ 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."); }
10
+ 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); }
11
+ 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; }
12
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+ 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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
15
+ 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); } }
16
+ 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); }); }; }
17
+ import React, { useEffect, useState, useMemo, useRef } from "react";
18
+ import { CopyToClipboard } from "react-copy-to-clipboard";
19
+ import ResizeObserver from "resize-observer-polyfill";
20
+ import keyIcon from "./assets/key.svg";
21
+ import valueIcon from "./assets/value.svg";
22
+ import timeCircleIcon from "./assets/time-circle.svg";
23
+ import copyIcon from "./assets/copy.svg";
24
+ import deleteIcon from "./assets/delete.svg";
25
+ import combinedIcon from "./assets/combined.svg";
26
+ import "./index.less";
27
+ function judgeNotEmpty(val) {
28
+ return val !== null && typeof val !== "undefined";
29
+ }
30
+
31
+ // 搜索高亮
32
+ function highLight(text, keyword) {
33
+ return text.split(keyword).flatMap(function (str, index) {
34
+ return [/*#__PURE__*/React.createElement("span", {
35
+ key: index,
36
+ style: {
37
+ color: "#FF4D4F"
38
+ }
39
+ }, keyword), str];
40
+ }).slice(1);
41
+ }
42
+
43
+ // 匹配方式
44
+ var DEFAULT_MATCH_OPTION_LIST = [{
45
+ value: ":",
46
+ des: "等于"
47
+ }, {
48
+ value: "NOT:",
49
+ des: "不等于"
50
+ },
51
+ // { value: "*", des: "模糊匹配/包含" },
52
+ // { value: "NOT*", des: "反向模糊匹配/不包含" },
53
+ // { value: "~", des: "存在" },
54
+ // { value: "NOT~", des: "不存在" },
55
+ {
56
+ value: ">",
57
+ des: "大于"
58
+ }, {
59
+ value: ">=",
60
+ des: "大于等于"
61
+ }, {
62
+ value: "<",
63
+ des: "小于"
64
+ }, {
65
+ value: "<=",
66
+ des: "小于等于"
67
+ }];
68
+
69
+ // 组合符号
70
+ var DEFAULT_COMBINED_OPTION_LIST = [{
71
+ value: "()",
72
+ des: "括号"
73
+ },
74
+ // { value: '""', des: "双引号" },
75
+ {
76
+ value: "[]",
77
+ des: "数值区间"
78
+ }];
79
+
80
+ /**
81
+ * 异步加载对应数据
82
+ * 高亮显示对应搜索关键字
83
+ * 选择后的回调(字符串)
84
+ */
85
+ var DropDown = function DropDown(props) {
86
+ var _props$onHelpClick = props.onHelpClick,
87
+ onHelpClick = _props$onHelpClick === void 0 ? function () {} : _props$onHelpClick,
88
+ children = props.children,
89
+ _props$visible = props.visible,
90
+ visible = _props$visible === void 0 ? false : _props$visible,
91
+ _props$keyOption = props.keyOption,
92
+ keyOption = _props$keyOption === void 0 ? {
93
+ value: null,
94
+ fetchFuc: function () {
95
+ var _fetchFuc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value) {
96
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
97
+ while (1) switch (_context.prev = _context.next) {
98
+ case 0:
99
+ case "end":
100
+ return _context.stop();
101
+ }
102
+ }, _callee);
103
+ }));
104
+ function fetchFuc(_x) {
105
+ return _fetchFuc.apply(this, arguments);
106
+ }
107
+ return fetchFuc;
108
+ }(),
109
+ onSelect: function onSelect(value) {}
110
+ } : _props$keyOption,
111
+ _props$valueOption = props.valueOption,
112
+ valueOption = _props$valueOption === void 0 ? {
113
+ value: {
114
+ key: null,
115
+ value: null
116
+ },
117
+ fetchFuc: function () {
118
+ var _fetchFuc2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
119
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
120
+ while (1) switch (_context2.prev = _context2.next) {
121
+ case 0:
122
+ case "end":
123
+ return _context2.stop();
124
+ }
125
+ }, _callee2);
126
+ }));
127
+ function fetchFuc() {
128
+ return _fetchFuc2.apply(this, arguments);
129
+ }
130
+ return fetchFuc;
131
+ }(),
132
+ onSelect: function onSelect() {}
133
+ } : _props$valueOption,
134
+ _props$historyOption = props.historyOption,
135
+ historyOption = _props$historyOption === void 0 ? {
136
+ value: null,
137
+ fetchFuc: function () {
138
+ var _fetchFuc3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
139
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
140
+ while (1) switch (_context3.prev = _context3.next) {
141
+ case 0:
142
+ case "end":
143
+ return _context3.stop();
144
+ }
145
+ }, _callee3);
146
+ }));
147
+ function fetchFuc() {
148
+ return _fetchFuc3.apply(this, arguments);
149
+ }
150
+ return fetchFuc;
151
+ }(),
152
+ onSelect: function onSelect() {},
153
+ onCopy: function onCopy() {},
154
+ onDelete: function () {
155
+ var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(id) {
156
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
157
+ while (1) switch (_context4.prev = _context4.next) {
158
+ case 0:
159
+ case "end":
160
+ return _context4.stop();
161
+ }
162
+ }, _callee4);
163
+ }));
164
+ function onDelete(_x2) {
165
+ return _onDelete.apply(this, arguments);
166
+ }
167
+ return onDelete;
168
+ }()
169
+ } : _props$historyOption,
170
+ _props$matchOption = props.matchOption,
171
+ matchOption = _props$matchOption === void 0 ? {
172
+ isShow: false,
173
+ list: list,
174
+ // 内置 // : >= NOT <=
175
+ onSelect: function onSelect() {}
176
+ } : _props$matchOption,
177
+ _props$combinedOption = props.combinedOption,
178
+ combinedOption = _props$combinedOption === void 0 ? {
179
+ isShow: false,
180
+ list: [],
181
+ // 内置 ()
182
+ onSelect: function onSelect() {}
183
+ } : _props$combinedOption,
184
+ containerWrapperRef = props.containerWrapperRef;
185
+
186
+ // 输入值
187
+ var keyOptionValue = keyOption.value;
188
+ var valueOptionValue = valueOption.value;
189
+ var historyOptionValue = historyOption.value;
190
+ var _useState = useState(false),
191
+ _useState2 = _slicedToArray(_useState, 2),
192
+ keyLoading = _useState2[0],
193
+ setKeyLoading = _useState2[1];
194
+ var _useState3 = useState(false),
195
+ _useState4 = _slicedToArray(_useState3, 2),
196
+ valueLoading = _useState4[0],
197
+ setValueLoading = _useState4[1];
198
+ var _useState5 = useState(false),
199
+ _useState6 = _slicedToArray(_useState5, 2),
200
+ historyLoading = _useState6[0],
201
+ setHistoryLoading = _useState6[1];
202
+ var _useState7 = useState([]),
203
+ _useState8 = _slicedToArray(_useState7, 2),
204
+ keyList = _useState8[0],
205
+ setKeyList = _useState8[1];
206
+ var _useState9 = useState([]),
207
+ _useState10 = _slicedToArray(_useState9, 2),
208
+ valueList = _useState10[0],
209
+ setValueList = _useState10[1];
210
+ var _useState11 = useState([]),
211
+ _useState12 = _slicedToArray(_useState11, 2),
212
+ historyList = _useState12[0],
213
+ setHistoryList = _useState12[1];
214
+ var _useState13 = useState(0),
215
+ _useState14 = _slicedToArray(_useState13, 2),
216
+ height = _useState14[0],
217
+ setHeight = _useState14[1];
218
+ var watcher = useRef(null);
219
+ useEffect(function () {
220
+ // 监听外壳容器变化
221
+ watcher.current = new ResizeObserver(function (entries) {
222
+ var _iterator = _createForOfIteratorHelper(entries),
223
+ _step;
224
+ try {
225
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
226
+ var entry = _step.value;
227
+ var target = entry.target,
228
+ _entry$contentRect = entry.contentRect,
229
+ _entry$contentRect2 = _entry$contentRect === void 0 ? {} : _entry$contentRect,
230
+ _height = _entry$contentRect2.height;
231
+ if (target === containerWrapperRef.current) {
232
+ setHeight(_height);
233
+ }
234
+ }
235
+ } catch (err) {
236
+ _iterator.e(err);
237
+ } finally {
238
+ _iterator.f();
239
+ }
240
+ });
241
+ watcher.current.observe(containerWrapperRef.current);
242
+ return function () {
243
+ if (containerWrapperRef.current) {
244
+ var _watcher$current;
245
+ (_watcher$current = watcher.current) === null || _watcher$current === void 0 || _watcher$current.unobserve(containerWrapperRef.current);
246
+ }
247
+ };
248
+ }, []);
249
+ // key
250
+ useEffect(function () {
251
+ var fetchValue = /*#__PURE__*/function () {
252
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
253
+ var res;
254
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
255
+ while (1) switch (_context5.prev = _context5.next) {
256
+ case 0:
257
+ setKeyLoading(true);
258
+ _context5.next = 3;
259
+ return keyOption === null || keyOption === void 0 ? void 0 : keyOption.fetchFuc(keyOptionValue);
260
+ case 3:
261
+ _context5.t0 = _context5.sent;
262
+ if (_context5.t0) {
263
+ _context5.next = 6;
264
+ break;
265
+ }
266
+ _context5.t0 = [];
267
+ case 6:
268
+ res = _context5.t0;
269
+ setKeyList(res);
270
+ setKeyLoading(false);
271
+ case 9:
272
+ case "end":
273
+ return _context5.stop();
274
+ }
275
+ }, _callee5);
276
+ }));
277
+ return function fetchValue() {
278
+ return _ref.apply(this, arguments);
279
+ };
280
+ }();
281
+ if (visible && judgeNotEmpty(keyOptionValue)) {
282
+ fetchValue();
283
+ }
284
+ }, [visible, keyOptionValue]);
285
+
286
+ // value
287
+ useEffect(function () {
288
+ var fetchValue = /*#__PURE__*/function () {
289
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
290
+ var res;
291
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
292
+ while (1) switch (_context6.prev = _context6.next) {
293
+ case 0:
294
+ setValueLoading(true);
295
+ _context6.next = 3;
296
+ return valueOption === null || valueOption === void 0 ? void 0 : valueOption.fetchFuc(valueOptionValue);
297
+ case 3:
298
+ _context6.t0 = _context6.sent;
299
+ if (_context6.t0) {
300
+ _context6.next = 6;
301
+ break;
302
+ }
303
+ _context6.t0 = [];
304
+ case 6:
305
+ res = _context6.t0;
306
+ setValueList(res);
307
+ setValueLoading(false);
308
+ case 9:
309
+ case "end":
310
+ return _context6.stop();
311
+ }
312
+ }, _callee6);
313
+ }));
314
+ return function fetchValue() {
315
+ return _ref2.apply(this, arguments);
316
+ };
317
+ }();
318
+ if (visible && judgeNotEmpty(valueOptionValue)) {
319
+ fetchValue();
320
+ }
321
+ }, [visible, valueOptionValue]);
322
+
323
+ // history
324
+ useEffect(function () {
325
+ var fetchValue = /*#__PURE__*/function () {
326
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
327
+ var res;
328
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
329
+ while (1) switch (_context7.prev = _context7.next) {
330
+ case 0:
331
+ setHistoryLoading(true);
332
+ _context7.next = 3;
333
+ return historyOption === null || historyOption === void 0 ? void 0 : historyOption.fetchFuc(historyOptionValue);
334
+ case 3:
335
+ _context7.t0 = _context7.sent;
336
+ if (_context7.t0) {
337
+ _context7.next = 6;
338
+ break;
339
+ }
340
+ _context7.t0 = [];
341
+ case 6:
342
+ res = _context7.t0;
343
+ setHistoryList(res);
344
+ setHistoryLoading(false);
345
+ case 9:
346
+ case "end":
347
+ return _context7.stop();
348
+ }
349
+ }, _callee7);
350
+ }));
351
+ return function fetchValue() {
352
+ return _ref3.apply(this, arguments);
353
+ };
354
+ }();
355
+ if (visible && judgeNotEmpty(historyOptionValue)) {
356
+ fetchValue();
357
+ }
358
+ }, [visible, historyOptionValue]);
359
+
360
+ // key
361
+ var keyOptionValueNotEmpty = useMemo(function () {
362
+ return judgeNotEmpty(keyOptionValue);
363
+ }, [keyOptionValue]);
364
+ // key列表为空
365
+ var dropDownKeyListEmpty = useMemo(function () {
366
+ return keyList.length === 0;
367
+ }, [keyList]);
368
+
369
+ // value
370
+ var valueOptionValueNotEmpty = useMemo(function () {
371
+ return judgeNotEmpty(valueOptionValue);
372
+ }, [valueOptionValue]);
373
+ // value列表为空
374
+ var dropDownValueListEmpty = useMemo(function () {
375
+ return valueList.length === 0;
376
+ }, [valueList]);
377
+ // history
378
+ var historyOptionValueNotEmpty = useMemo(function () {
379
+ return judgeNotEmpty(historyOptionValue);
380
+ }, [historyOptionValue]);
381
+ // 搜索历史列表为空
382
+ var dropDownListHistoryEmpty = useMemo(function () {
383
+ return historyList.length === 0;
384
+ }, [historyList]);
385
+
386
+ // 搜索历史列表删除
387
+ function historyDelete(_x3, _x4) {
388
+ return _historyDelete.apply(this, arguments);
389
+ }
390
+ function _historyDelete() {
391
+ _historyDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id, record) {
392
+ var success;
393
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
394
+ while (1) switch (_context8.prev = _context8.next) {
395
+ case 0:
396
+ _context8.next = 2;
397
+ return historyOption === null || historyOption === void 0 ? void 0 : historyOption.onDelete(id, record);
398
+ case 2:
399
+ success = _context8.sent;
400
+ if (success) {
401
+ setHistoryList(historyList.filter(function (item) {
402
+ return item.id !== id;
403
+ }));
404
+ }
405
+ case 4:
406
+ case "end":
407
+ return _context8.stop();
408
+ }
409
+ }, _callee8);
410
+ }));
411
+ return _historyDelete.apply(this, arguments);
412
+ }
413
+ var menu = /*#__PURE__*/React.createElement("div", {
414
+ className: "aggregate-drop-down-wrap"
415
+ }, /*#__PURE__*/React.createElement("div", {
416
+ className: "aggregate-drop-down"
417
+ }, keyOptionValueNotEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
418
+ className: "list-title"
419
+ }, "\u6807\u7B7E\u641C\u7D22"), /*#__PURE__*/React.createElement(_Spin, {
420
+ spinning: keyLoading,
421
+ tip: "\u52A0\u8F7D\u4E2D..."
422
+ }, !dropDownKeyListEmpty ? keyList.map(function (record, index) {
423
+ var value = record.value,
424
+ des = record.des;
425
+ return /*#__PURE__*/React.createElement("div", {
426
+ key: index,
427
+ className: "list",
428
+ onClick: function onClick() {
429
+ keyOption === null || keyOption === void 0 || keyOption.onSelect(value, record);
430
+ }
431
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("img", {
432
+ className: "pre-icon",
433
+ src: keyIcon,
434
+ alt: ""
435
+ }), highLight(value, keyOptionValue)), /*#__PURE__*/React.createElement("span", null, des));
436
+ }) : /*#__PURE__*/React.createElement("div", {
437
+ className: "empty"
438
+ }, "\u6682\u65E0\u6570\u636E\uFF0C\u63D0\u4EA4\u641C\u7D22\u540E\u641C\u7D22\u5173\u952E\u5B57"))), valueOptionValueNotEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
439
+ className: "list-title"
440
+ }, "Value"), /*#__PURE__*/React.createElement(_Spin, {
441
+ spinning: valueLoading,
442
+ tip: "\u52A0\u8F7D\u4E2D..."
443
+ }, !dropDownValueListEmpty ? valueList.map(function (record, index) {
444
+ var value = record.value,
445
+ des = record.des;
446
+ return /*#__PURE__*/React.createElement("div", {
447
+ key: index,
448
+ className: "list",
449
+ onClick: function onClick() {
450
+ valueOption === null || valueOption === void 0 || valueOption.onSelect(value, record);
451
+ }
452
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("img", {
453
+ className: "pre-icon",
454
+ src: valueIcon,
455
+ alt: ""
456
+ }), highLight(value, valueOptionValue === null || valueOptionValue === void 0 ? void 0 : valueOptionValue.value)), /*#__PURE__*/React.createElement("span", null, des));
457
+ }) : /*#__PURE__*/React.createElement("div", {
458
+ className: "empty"
459
+ }, "\u6682\u65E0\u6570\u636E\uFF0C\u63D0\u4EA4\u641C\u7D22\u540E\u641C\u7D22\u5173\u952E\u5B57"))), matchOption.isShow && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
460
+ className: "list-title"
461
+ }, "\u5339\u914D\u65B9\u5F0F"), (matchOption.list || DEFAULT_MATCH_OPTION_LIST).map(function (record, index) {
462
+ var value = record.value,
463
+ des = record.des;
464
+ return /*#__PURE__*/React.createElement("div", {
465
+ key: index,
466
+ className: "list",
467
+ onClick: function onClick() {
468
+ matchOption === null || matchOption === void 0 || matchOption.onSelect(value, record);
469
+ }
470
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("img", {
471
+ className: "pre-icon",
472
+ src: combinedIcon,
473
+ alt: ""
474
+ }), value), /*#__PURE__*/React.createElement("span", null, des));
475
+ })), combinedOption.isShow && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
476
+ className: "list-title"
477
+ }, "\u7EC4\u5408\u7B26\u53F7"), (combinedOption.list || DEFAULT_COMBINED_OPTION_LIST).map(function (record, index) {
478
+ var value = record.value,
479
+ des = record.des;
480
+ return /*#__PURE__*/React.createElement("div", {
481
+ key: index,
482
+ className: "list",
483
+ onClick: function onClick() {
484
+ combinedOption === null || combinedOption === void 0 || combinedOption.onSelect(value, record);
485
+ }
486
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("img", {
487
+ className: "pre-icon",
488
+ src: combinedIcon,
489
+ alt: ""
490
+ }), value), /*#__PURE__*/React.createElement("span", null, des));
491
+ })), historyOptionValueNotEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
492
+ className: "list-title"
493
+ }, "\u641C\u7D22\u5386\u53F2"), /*#__PURE__*/React.createElement(_Spin, {
494
+ spinning: historyLoading,
495
+ tip: "\u52A0\u8F7D\u4E2D..."
496
+ }, !dropDownListHistoryEmpty ? historyList.map(function (record, index) {
497
+ var id = record.id,
498
+ value = record.value,
499
+ des = record.des;
500
+ return /*#__PURE__*/React.createElement("div", {
501
+ key: index,
502
+ className: "list",
503
+ onClick: function onClick() {
504
+ historyOption === null || historyOption === void 0 || historyOption.onSelect(value, record);
505
+ }
506
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("img", {
507
+ className: "pre-icon",
508
+ src: timeCircleIcon,
509
+ alt: ""
510
+ }), highLight(value, historyOptionValue)), /*#__PURE__*/React.createElement("span", {
511
+ className: "des"
512
+ }, des), /*#__PURE__*/React.createElement("span", {
513
+ className: "action"
514
+ }, /*#__PURE__*/React.createElement(CopyToClipboard, {
515
+ text: value,
516
+ onCopy: function onCopy(text) {
517
+ historyOption === null || historyOption === void 0 || historyOption.onCopy(text);
518
+ _message.success("搜索条件已复制");
519
+ }
520
+ }, /*#__PURE__*/React.createElement("img", {
521
+ onClick: function onClick(e) {
522
+ return e.stopPropagation();
523
+ },
524
+ className: "pre-icon",
525
+ src: copyIcon,
526
+ alt: ""
527
+ })), /*#__PURE__*/React.createElement("img", {
528
+ className: "pre-icon",
529
+ src: deleteIcon,
530
+ alt: "",
531
+ onClick: function onClick(e) {
532
+ e.stopPropagation();
533
+ historyDelete(id, record);
534
+ }
535
+ })));
536
+ }) : /*#__PURE__*/React.createElement("div", {
537
+ className: "empty"
538
+ }, "\u6682\u65E0\u6570\u636E\uFF0C\u63D0\u4EA4\u641C\u7D22\u540E\u641C\u7D22\u5173\u952E\u5B57")))), /*#__PURE__*/React.createElement("div", {
539
+ className: "desc"
540
+ }, /*#__PURE__*/React.createElement(_TooltipText, null, "\u5168\u6587\u68C0\u7D22\uFF1Ahello world \u5B8C\u5168\u5339\u914D\uFF1A\u201Chello world\u201D \u901A\u914D\u7B26\uFF1A* \uFF1F \u5173\u8054\u641C\u7D22\uFF1Astatus:(error OR warning) AND NOT service:\u201Cservice_a\u201D"), /*#__PURE__*/React.createElement(_Button, {
541
+ type: "link",
542
+ onClick: onHelpClick
543
+ }, "\u5E2E\u52A9\u6587\u6863")));
544
+ return /*#__PURE__*/React.createElement(_Dropdown, {
545
+ overlay: menu,
546
+ visible: visible,
547
+ getPopupContainer: function getPopupContainer(node) {
548
+ return node;
549
+ },
550
+ overlayStyle: {
551
+ top: height,
552
+ left: 0
553
+ }
554
+ }, children);
555
+ };
556
+ export default DropDown;
@@ -0,0 +1,102 @@
1
+
2
+ .aggregate-drop-down-wrap {
3
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); // 浮层阴影
4
+ background: #fff;
5
+
6
+ .aggregate-drop-down {
7
+ width: 100%;
8
+ max-height: 380px;
9
+ padding: 4px 0;
10
+ overflow: auto;
11
+ justify-content: center;
12
+ align-items: center;
13
+
14
+ .ant-spin-nested-loading {
15
+
16
+ .ant-spin {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+
21
+ .ant-spin-dot-spin,
22
+ .ant-spin-text {
23
+ position: relative;
24
+ margin: 0;
25
+ padding: 0;
26
+ top: 0;
27
+ left: 0;
28
+ }
29
+
30
+ .ant-spin-dot-spin {
31
+ font-size: 18px;
32
+ }
33
+
34
+ .ant-spin-text {
35
+ width: auto;
36
+ margin-left: 4px;
37
+ }
38
+ }
39
+ }
40
+
41
+ .list-title {
42
+ line-height: 32px;
43
+ background-color: rgba(0, 0, 0, 0.02);
44
+ padding: 0 10px;
45
+ }
46
+
47
+ .list {
48
+ &:hover {
49
+ cursor: pointer;
50
+ background-color: #E6F7FF;
51
+
52
+ .des {
53
+ display: none;
54
+ }
55
+
56
+ .action {
57
+ display: block;
58
+ }
59
+ }
60
+
61
+ line-height: 32px;
62
+ display: flex;
63
+ justify-content: space-between;
64
+ padding: 0 10px;
65
+
66
+ .action {
67
+ display: none;
68
+
69
+ .pre-icon {
70
+ &:nth-child(2) {
71
+ margin-right: 0;
72
+ }
73
+ }
74
+ }
75
+
76
+ .pre-icon {
77
+ margin-right: 8px;
78
+ height: 16px;
79
+ width: 16px;
80
+ }
81
+ }
82
+
83
+ .empty {
84
+ line-height: 32px;
85
+ padding: 0 10px;
86
+ }
87
+ }
88
+
89
+ .desc {
90
+ width: 100%;
91
+ line-height: 32px;
92
+ padding: 0 10px;
93
+ background: rgba(0, 0, 0, 0.02);
94
+ display: flex;
95
+ justify-content: space-between;
96
+ align-items: center;
97
+
98
+ .ant-btn-link {
99
+ margin-left: 10px;
100
+ }
101
+ }
102
+ }