@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.
- package/lib/AggregateSearch/CLSPL/CLQLLexer.js +80 -0
- package/lib/AggregateSearch/CLSPL/CLQLParser.js +2797 -0
- package/lib/AggregateSearch/CLSPL/CLQLParserListener.js +349 -0
- package/lib/AggregateSearch/CLSPL/CLQLParserVisitor.js +253 -0
- package/lib/AggregateSearch/CLSPL/SPLStagy.js +189 -0
- package/lib/AggregateSearch/CLSPL/index.js +176 -0
- package/lib/AggregateSearch/CLSPL/makeTokenizeFn.js +18 -0
- package/lib/AggregateSearch/CLSPL/token.js +7 -0
- package/lib/AggregateSearch/components/DropDown/assets/combined.svg +22 -0
- package/lib/AggregateSearch/components/DropDown/assets/copy.svg +22 -0
- package/lib/AggregateSearch/components/DropDown/assets/delete.svg +24 -0
- package/lib/AggregateSearch/components/DropDown/assets/home.svg +20 -0
- package/lib/AggregateSearch/components/DropDown/assets/key.svg +21 -0
- package/lib/AggregateSearch/components/DropDown/assets/star.svg +22 -0
- package/lib/AggregateSearch/components/DropDown/assets/time-circle.svg +20 -0
- package/lib/AggregateSearch/components/DropDown/assets/value.svg +23 -0
- package/lib/AggregateSearch/components/DropDown/index.js +556 -0
- package/lib/AggregateSearch/components/DropDown/index.less +102 -0
- package/lib/AggregateSearch/components/SwitchBtn/assets/tag-icon.svg +17 -0
- package/lib/AggregateSearch/components/SwitchBtn/assets/text-icon.svg +18 -0
- package/lib/AggregateSearch/components/SwitchBtn/index.js +24 -0
- package/lib/AggregateSearch/components/SwitchBtn/index.less +15 -0
- package/lib/AggregateSearch/hooks/useDropDown.js +399 -0
- package/lib/AggregateSearch/index.js +350 -0
- package/lib/AggregateSearch/index.less +123 -0
- package/lib/AggregateSearch/utils/index.js +362 -0
- package/lib/PropertyControlViewer/assets/doSelect.less +1 -1
- package/lib/PropertyControlViewer/assets/index.less +3 -3
- package/lib/PropertyControlViewer/components/DoCiUnitBitmap.js +1 -1
- package/lib/PropertyControlViewer/components/DoDefaultPlaceholder.js +1 -1
- package/lib/PropertyControlViewer/components/DoUser.js +4 -4
- package/lib/PropertyControlViewer/components/TagShowMoreList/index.js +1 -1
- package/lib/PropertyControlViewer/config/utils.js +5 -4
- package/lib/PropertyControlViewer/index.js +77 -76
- package/lib/PropertyControlViewer/index.less +30 -0
- package/lib/index.js +2 -1
- package/package.json +5 -3
|
@@ -0,0 +1,350 @@
|
|
|
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
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."); }
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
6
|
+
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; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
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; }
|
|
9
|
+
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); } }
|
|
10
|
+
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); }); }; }
|
|
11
|
+
import React, { useEffect, useRef, useState, useMemo } from "react";
|
|
12
|
+
import PropTypes from "prop-types";
|
|
13
|
+
import { textInit, getCursorPosition, getCursorNodeAndIndex, setCursorPosition, genHtmlAndSyntaxCheckResByString, checkSyntax } from "./utils";
|
|
14
|
+
import SwitchBtn from "./components/SwitchBtn";
|
|
15
|
+
import DropDown from "./components/DropDown";
|
|
16
|
+
import "./index.less";
|
|
17
|
+
import useDropDown from "./hooks/useDropDown";
|
|
18
|
+
var AggregateSearch = function AggregateSearch(_ref) {
|
|
19
|
+
var _ref$onChange = _ref.onChange,
|
|
20
|
+
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
21
|
+
value = _ref.value,
|
|
22
|
+
_ref$fetchKeyList = _ref.fetchKeyList,
|
|
23
|
+
fetchKeyList = _ref$fetchKeyList === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
24
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
25
|
+
while (1) switch (_context.prev = _context.next) {
|
|
26
|
+
case 0:
|
|
27
|
+
return _context.abrupt("return", []);
|
|
28
|
+
case 1:
|
|
29
|
+
case "end":
|
|
30
|
+
return _context.stop();
|
|
31
|
+
}
|
|
32
|
+
}, _callee);
|
|
33
|
+
})) : _ref$fetchKeyList,
|
|
34
|
+
_ref$fetchValueList = _ref.fetchValueList,
|
|
35
|
+
fetchValueList = _ref$fetchValueList === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
36
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
37
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
return _context2.abrupt("return", []);
|
|
40
|
+
case 1:
|
|
41
|
+
case "end":
|
|
42
|
+
return _context2.stop();
|
|
43
|
+
}
|
|
44
|
+
}, _callee2);
|
|
45
|
+
})) : _ref$fetchValueList,
|
|
46
|
+
_ref$fetchHistoryList = _ref.fetchHistoryList,
|
|
47
|
+
fetchHistoryList = _ref$fetchHistoryList === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
48
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
49
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
return _context3.abrupt("return", []);
|
|
52
|
+
case 1:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context3.stop();
|
|
55
|
+
}
|
|
56
|
+
}, _callee3);
|
|
57
|
+
})) : _ref$fetchHistoryList,
|
|
58
|
+
_ref$onHistoryDelete = _ref.onHistoryDelete,
|
|
59
|
+
onHistoryDelete = _ref$onHistoryDelete === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
60
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
61
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
62
|
+
case 0:
|
|
63
|
+
return _context4.abrupt("return", false);
|
|
64
|
+
case 1:
|
|
65
|
+
case "end":
|
|
66
|
+
return _context4.stop();
|
|
67
|
+
}
|
|
68
|
+
}, _callee4);
|
|
69
|
+
})) : _ref$onHistoryDelete,
|
|
70
|
+
_ref$onHelpClick = _ref.onHelpClick,
|
|
71
|
+
onHelpClick = _ref$onHelpClick === void 0 ? function () {} : _ref$onHelpClick,
|
|
72
|
+
mode = _ref.mode,
|
|
73
|
+
_ref$defaultMode = _ref.defaultMode,
|
|
74
|
+
defaultMode = _ref$defaultMode === void 0 ? "tag" : _ref$defaultMode;
|
|
75
|
+
// 输入模式
|
|
76
|
+
var _useState = useState(defaultMode),
|
|
77
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
78
|
+
selMode = _useState2[0],
|
|
79
|
+
setSelMode = _useState2[1]; // tag | text
|
|
80
|
+
|
|
81
|
+
var curMode = mode || selMode;
|
|
82
|
+
|
|
83
|
+
// 输入内容
|
|
84
|
+
var _useState3 = useState(""),
|
|
85
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
86
|
+
selValue = _useState4[0],
|
|
87
|
+
setSelValue = _useState4[1];
|
|
88
|
+
var container = useRef(null);
|
|
89
|
+
var containerWrapperRef = useRef(null);
|
|
90
|
+
// 是否正在输入中文
|
|
91
|
+
var isComposing = useRef(false);
|
|
92
|
+
var handleSyntaxCheck = /*#__PURE__*/function () {
|
|
93
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(inputStr) {
|
|
94
|
+
var checkRes, column, msg, _getCursorNodeAndInde, errorNode, findParent, errorTag;
|
|
95
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
96
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
_context5.next = 2;
|
|
99
|
+
return checkSyntax(inputStr);
|
|
100
|
+
case 2:
|
|
101
|
+
checkRes = _context5.sent;
|
|
102
|
+
if (!checkRes) {
|
|
103
|
+
_context5.next = 10;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
column = checkRes.column, msg = checkRes.msg; // 找到目标节点,高亮提示错误
|
|
107
|
+
_getCursorNodeAndInde = getCursorNodeAndIndex(container.current, column), errorNode = _getCursorNodeAndInde.targetNode;
|
|
108
|
+
findParent = function findParent(node) {
|
|
109
|
+
var _node$dataset;
|
|
110
|
+
if (!node || node === container.current) {
|
|
111
|
+
var nextSiblingIndex = column > 0 ? column - 1 : column + 1;
|
|
112
|
+
column = nextSiblingIndex;
|
|
113
|
+
var _getCursorNodeAndInde2 = getCursorNodeAndIndex(container.current, nextSiblingIndex),
|
|
114
|
+
newErrorNode = _getCursorNodeAndInde2.targetNode;
|
|
115
|
+
if (!newErrorNode && (nextSiblingIndex < 0 || nextSiblingIndex > inputStr.length)) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
return findParent(newErrorNode);
|
|
119
|
+
}
|
|
120
|
+
var dataAttr = (_node$dataset = node.dataset) === null || _node$dataset === void 0 ? void 0 : _node$dataset["attr"];
|
|
121
|
+
if (dataAttr && ["tag-box"].includes(dataAttr)) {
|
|
122
|
+
return node;
|
|
123
|
+
}
|
|
124
|
+
return findParent(node.parentNode);
|
|
125
|
+
};
|
|
126
|
+
errorTag = findParent(errorNode);
|
|
127
|
+
if (errorTag) {
|
|
128
|
+
errorTag.classList.add("syntax-error");
|
|
129
|
+
errorTag.setAttribute("data-error", msg);
|
|
130
|
+
}
|
|
131
|
+
return _context5.abrupt("return", true);
|
|
132
|
+
case 10:
|
|
133
|
+
return _context5.abrupt("return", false);
|
|
134
|
+
case 11:
|
|
135
|
+
case "end":
|
|
136
|
+
return _context5.stop();
|
|
137
|
+
}
|
|
138
|
+
}, _callee5);
|
|
139
|
+
}));
|
|
140
|
+
return function handleSyntaxCheck(_x) {
|
|
141
|
+
return _ref6.apply(this, arguments);
|
|
142
|
+
};
|
|
143
|
+
}();
|
|
144
|
+
var handleValueChange = /*#__PURE__*/function () {
|
|
145
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(inputStr, mode) {
|
|
146
|
+
var checkRes, planeTextPosition, htmlString, _getCursorNodeAndInde3, targetNode, targetIndex;
|
|
147
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
148
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
149
|
+
case 0:
|
|
150
|
+
if (!((mode || curMode) === "text")) {
|
|
151
|
+
_context6.next = 6;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
_context6.next = 3;
|
|
155
|
+
return checkSyntax(inputStr);
|
|
156
|
+
case 3:
|
|
157
|
+
checkRes = _context6.sent;
|
|
158
|
+
if (checkRes) {
|
|
159
|
+
container.current.classList.add("syntax-error");
|
|
160
|
+
container.current.setAttribute("data-error", checkRes.msg);
|
|
161
|
+
} else {
|
|
162
|
+
container.current.classList.remove("syntax-error");
|
|
163
|
+
container.current.removeAttribute("data-error");
|
|
164
|
+
}
|
|
165
|
+
return _context6.abrupt("return");
|
|
166
|
+
case 6:
|
|
167
|
+
// 计算当前光标位置(纯文本模式)
|
|
168
|
+
planeTextPosition = getCursorPosition(container.current); // 将纯文本模式转为html模式(语法解析器)
|
|
169
|
+
htmlString = genHtmlAndSyntaxCheckResByString(inputStr);
|
|
170
|
+
container.current.innerHTML = htmlString;
|
|
171
|
+
// 找到格式化后的光标位置
|
|
172
|
+
if (planeTextPosition !== null) {
|
|
173
|
+
_getCursorNodeAndInde3 = getCursorNodeAndIndex(container.current, planeTextPosition), targetNode = _getCursorNodeAndInde3.targetNode, targetIndex = _getCursorNodeAndInde3.targetIndex; // 设置光标位置
|
|
174
|
+
setCursorPosition(targetNode, targetIndex);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// 检测语法
|
|
178
|
+
_context6.next = 12;
|
|
179
|
+
return handleSyntaxCheck(inputStr);
|
|
180
|
+
case 12:
|
|
181
|
+
setSelValue(container.current.innerText);
|
|
182
|
+
case 13:
|
|
183
|
+
case "end":
|
|
184
|
+
return _context6.stop();
|
|
185
|
+
}
|
|
186
|
+
}, _callee6);
|
|
187
|
+
}));
|
|
188
|
+
return function handleValueChange(_x2, _x3) {
|
|
189
|
+
return _ref7.apply(this, arguments);
|
|
190
|
+
};
|
|
191
|
+
}();
|
|
192
|
+
var _useDropDown = useDropDown(container, handleValueChange),
|
|
193
|
+
dropStatus = _useDropDown.dropStatus,
|
|
194
|
+
visible = _useDropDown.visible,
|
|
195
|
+
quickSelect = _useDropDown.quickSelect,
|
|
196
|
+
onHistorySelect = _useDropDown.onHistorySelect,
|
|
197
|
+
setVisible = _useDropDown.setVisible;
|
|
198
|
+
var onInput = /*#__PURE__*/function () {
|
|
199
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(e) {
|
|
200
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
201
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
202
|
+
case 0:
|
|
203
|
+
if (!isComposing.current) {
|
|
204
|
+
_context7.next = 2;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
return _context7.abrupt("return");
|
|
208
|
+
case 2:
|
|
209
|
+
handleValueChange(e.target.innerText);
|
|
210
|
+
onChange(e.target.innerText);
|
|
211
|
+
case 4:
|
|
212
|
+
case "end":
|
|
213
|
+
return _context7.stop();
|
|
214
|
+
}
|
|
215
|
+
}, _callee7);
|
|
216
|
+
}));
|
|
217
|
+
return function onInput(_x4) {
|
|
218
|
+
return _ref8.apply(this, arguments);
|
|
219
|
+
};
|
|
220
|
+
}();
|
|
221
|
+
useEffect(function () {
|
|
222
|
+
if (value !== null && value !== void 0 ? value : "noValue" !== "noValue") {
|
|
223
|
+
handleValueChange(value);
|
|
224
|
+
}
|
|
225
|
+
}, [value]);
|
|
226
|
+
|
|
227
|
+
// 监听点击事件(container以外的地方)
|
|
228
|
+
useEffect(function () {
|
|
229
|
+
var handleClick = function handleClick(e) {
|
|
230
|
+
if (container.current && !container.current.contains(e.target)) {
|
|
231
|
+
setVisible(false);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
document.addEventListener("click", handleClick);
|
|
235
|
+
return function () {
|
|
236
|
+
document.removeEventListener("click", handleClick);
|
|
237
|
+
};
|
|
238
|
+
}, []);
|
|
239
|
+
var onFocus = function onFocus() {
|
|
240
|
+
setVisible(true);
|
|
241
|
+
};
|
|
242
|
+
var onModeChange = function onModeChange(mode) {
|
|
243
|
+
setSelMode(mode);
|
|
244
|
+
if (mode === "text") {
|
|
245
|
+
container.current.innerText = container.current.innerText;
|
|
246
|
+
} else {
|
|
247
|
+
// 移除错误提示
|
|
248
|
+
container.current.classList.remove("syntax-error");
|
|
249
|
+
container.current.removeAttribute("data-error");
|
|
250
|
+
}
|
|
251
|
+
handleValueChange(container.current.innerText, mode);
|
|
252
|
+
};
|
|
253
|
+
return /*#__PURE__*/React.createElement(DropDown, {
|
|
254
|
+
onHelpClick: onHelpClick,
|
|
255
|
+
visible: visible && curMode === "tag",
|
|
256
|
+
keyOption: {
|
|
257
|
+
value: dropStatus.key.isShow ? dropStatus.key.value : null,
|
|
258
|
+
fetchFuc: fetchKeyList,
|
|
259
|
+
onSelect: function onSelect(value) {
|
|
260
|
+
quickSelect(value, "key");
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
valueOption: {
|
|
264
|
+
value: dropStatus.value.isShow ? {
|
|
265
|
+
key: dropStatus.value.key,
|
|
266
|
+
value: dropStatus.value.value
|
|
267
|
+
} : null,
|
|
268
|
+
fetchFuc: fetchValueList,
|
|
269
|
+
onSelect: function onSelect(value) {
|
|
270
|
+
quickSelect(value, "value");
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
historyOption: {
|
|
274
|
+
value: selValue,
|
|
275
|
+
fetchFuc: fetchHistoryList,
|
|
276
|
+
onSelect: function onSelect(value, record) {
|
|
277
|
+
onHistorySelect(value);
|
|
278
|
+
},
|
|
279
|
+
onCopy: function onCopy() {},
|
|
280
|
+
onDelete: onHistoryDelete
|
|
281
|
+
},
|
|
282
|
+
matchOption: {
|
|
283
|
+
isShow: dropStatus.match.isShow,
|
|
284
|
+
onSelect: function onSelect(value) {
|
|
285
|
+
quickSelect(value, "match");
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
combinedOption: {
|
|
289
|
+
isShow: dropStatus.combined.isShow,
|
|
290
|
+
onSelect: function onSelect(value) {
|
|
291
|
+
quickSelect(value, "combined");
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
containerWrapperRef: containerWrapperRef
|
|
295
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
296
|
+
className: "aggregate-search-wrapper",
|
|
297
|
+
ref: containerWrapperRef
|
|
298
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
299
|
+
spellCheck: false,
|
|
300
|
+
onCompositionEnd: function onCompositionEnd() {
|
|
301
|
+
return isComposing.current = false;
|
|
302
|
+
},
|
|
303
|
+
onCompositionStart: function onCompositionStart() {
|
|
304
|
+
return isComposing.current = true;
|
|
305
|
+
},
|
|
306
|
+
className: "aggregate-search-input",
|
|
307
|
+
ref: container,
|
|
308
|
+
"data-attr": "container",
|
|
309
|
+
contentEditable: true,
|
|
310
|
+
suppressContentEditableWarning: true,
|
|
311
|
+
onPaste: textInit // 只粘贴纯文本 去除html标签
|
|
312
|
+
,
|
|
313
|
+
onInput: onInput,
|
|
314
|
+
onFocus: onFocus
|
|
315
|
+
}), /*#__PURE__*/React.createElement(SwitchBtn, {
|
|
316
|
+
onChange: onModeChange,
|
|
317
|
+
mode: mode || selMode
|
|
318
|
+
})));
|
|
319
|
+
};
|
|
320
|
+
AggregateSearch.propTypes = {
|
|
321
|
+
/**
|
|
322
|
+
* 受控value
|
|
323
|
+
*/
|
|
324
|
+
value: PropTypes.string,
|
|
325
|
+
/**
|
|
326
|
+
* 文本内容变化的回调,(value) => {}
|
|
327
|
+
*/
|
|
328
|
+
onChange: PropTypes.func,
|
|
329
|
+
/**
|
|
330
|
+
* 可生成标签对模式下触发搜索标签key的回调,需要返回promise,async(value)=>[],参数为当前光标所在标签的key值:需要该值请求下拉列表key值数据
|
|
331
|
+
*/
|
|
332
|
+
fetchKeyList: PropTypes.func,
|
|
333
|
+
/**
|
|
334
|
+
* 可生成标签对模式下触发搜索标签value的回调,需要返回promise,async(value)=>[],参数为当前光标所在标签的value值:需要该值请求下拉列表value值数据
|
|
335
|
+
*/
|
|
336
|
+
fetchValueList: PropTypes.func,
|
|
337
|
+
/**
|
|
338
|
+
* 可生成标签对模式下触发历史记录搜索的回调,需要返回promise,async(value)=>[],参数为聚合搜索框内当前所有文本内容:需要该值请求下拉列表历史记录数据
|
|
339
|
+
*/
|
|
340
|
+
fetchHistoryList: PropTypes.func,
|
|
341
|
+
/**
|
|
342
|
+
* 帮助按钮点击回调
|
|
343
|
+
*/
|
|
344
|
+
onHelpClick: PropTypes.func,
|
|
345
|
+
/**
|
|
346
|
+
* 删除历史记录回调,需要返回promise,async(id)=>Boolean
|
|
347
|
+
*/
|
|
348
|
+
onHistoryDelete: PropTypes.func
|
|
349
|
+
};
|
|
350
|
+
export default AggregateSearch;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// == when hoverd
|
|
2
|
+
.hover(@color: @input-hover-border-color) {
|
|
3
|
+
border-color: @color;
|
|
4
|
+
border-right-width: @border-width-base !important;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// input status
|
|
8
|
+
// == when focus or actived
|
|
9
|
+
.active(@color: @outline-color) {
|
|
10
|
+
border-color:~`colorPalette('@{color}', 5) `;
|
|
11
|
+
border-right-width: @border-width-base !important;
|
|
12
|
+
outline: 0;
|
|
13
|
+
box-shadow: @input-outline-offset @outline-blur-size @outline-width fade(@color, 20%);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.aggregate-search-wrapper {
|
|
17
|
+
background: #FFFFFF;
|
|
18
|
+
border-radius: 2px;
|
|
19
|
+
font-size: 12px;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: flex-start;
|
|
22
|
+
white-space: pre-wrap;
|
|
23
|
+
position: relative;
|
|
24
|
+
.aggregate-search-input {
|
|
25
|
+
position: relative;
|
|
26
|
+
padding: 0 10px;
|
|
27
|
+
flex: 1;
|
|
28
|
+
min-height: 26px;
|
|
29
|
+
line-height: 24px;
|
|
30
|
+
border: @border-width-base @border-style-base @input-border-color;
|
|
31
|
+
border-radius: @border-radius-base 0 0 @border-radius-base;
|
|
32
|
+
|
|
33
|
+
// 聚焦样式修改
|
|
34
|
+
&:focus {
|
|
35
|
+
.active();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 取消默认聚焦样式
|
|
39
|
+
&:focus-visible {
|
|
40
|
+
outline: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&:empty:before {
|
|
44
|
+
content: '搜索指标标识、维度、或通过筛选区筛选指标';
|
|
45
|
+
font-size: 12px;
|
|
46
|
+
color: rgba(0, 0, 0, 0.45);
|
|
47
|
+
line-height: 20px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&:focus:before {
|
|
51
|
+
content: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.tag-box {
|
|
55
|
+
position: relative;
|
|
56
|
+
background: #FFFFFF;
|
|
57
|
+
border: 1px solid #E3E3E3;
|
|
58
|
+
border-radius: 2px;
|
|
59
|
+
height: 18px;
|
|
60
|
+
line-height: 16px;
|
|
61
|
+
display: inline-block;
|
|
62
|
+
margin-right: 2px;
|
|
63
|
+
padding-right: 6px;
|
|
64
|
+
// margin-top: -1px;
|
|
65
|
+
|
|
66
|
+
.tag-con {
|
|
67
|
+
display: inline-block;
|
|
68
|
+
height: 16px;
|
|
69
|
+
line-height: 16px;
|
|
70
|
+
|
|
71
|
+
&:first-child {
|
|
72
|
+
padding-left: 6px;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.tag-con-key {
|
|
77
|
+
background: rgba(0, 0, 0, 0.06);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.tag-con-key-last {
|
|
81
|
+
padding-right: 4px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.tag-con-keyword {
|
|
85
|
+
color: #FA8C16;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.tag-con-identifier {
|
|
89
|
+
color: #FA8C16;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.tag-con-match {
|
|
93
|
+
color: #FA8C16;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
.syntax-error {
|
|
101
|
+
// 语法错误,高亮样式
|
|
102
|
+
border: 1px solid #FF4D4F !important;
|
|
103
|
+
|
|
104
|
+
&:hover {
|
|
105
|
+
|
|
106
|
+
// 伪类展示属性值
|
|
107
|
+
&:before {
|
|
108
|
+
content: attr(data-error);
|
|
109
|
+
position: absolute;
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
bottom: 26px;
|
|
112
|
+
left: -1px;
|
|
113
|
+
height: 20px;
|
|
114
|
+
line-height: 20px;
|
|
115
|
+
background: #FFF1F0;
|
|
116
|
+
border: 1px solid #FF4D4F;
|
|
117
|
+
border-radius: 0 0 2px 2px;
|
|
118
|
+
font-size: 12px;
|
|
119
|
+
color: #FF4D4F;
|
|
120
|
+
padding: 0 10px;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|