@chaoswise/business 1.0.0 → 1.0.1
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/index.js +15 -4
- package/lib/AggregateSearch/components/DropDown/index.js +66 -51
- package/lib/AggregateSearch/components/DropDown/index.less +18 -17
- package/lib/AggregateSearch/index.js +34 -36
- package/lib/AggregateSearch/index.less +1 -0
- package/lib/AggregateSearch/utils/index.js +1 -1
- package/lib/ContentEditableSearch/components/CloseAllIcon/index.js +13 -0
- package/lib/ContentEditableSearch/components/CloseAllIcon/index.less +11 -0
- package/lib/ContentEditableSearch/index.js +157 -0
- package/lib/ContentEditableSearch/index.less +65 -0
- package/lib/ContentEditableSearch/utils/index.js +98 -0
- package/lib/PropertyControlViewer/components/DoCommon.js +19 -16
- package/lib/PropertyControlViewer/components/DoUser.js +4 -4
- package/lib/PropertyControlViewer/components/TagShowMoreList/index.js +6 -1
- package/lib/PropertyControlViewer/index.js +76 -9
- package/lib/PropertyControlViewer/index.less +1 -0
- package/lib/index.js +2 -1
- package/package.json +1 -1
|
@@ -102,10 +102,21 @@ var customVisitor = /*#__PURE__*/function (_visitor) {
|
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
104
104
|
} catch (error) {
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
var geterror = function geterror() {
|
|
106
|
+
try {
|
|
107
|
+
return JSON.parse(error.message);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return {
|
|
110
|
+
msg: error.message,
|
|
111
|
+
line: '',
|
|
112
|
+
column: ''
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
var _geterror = geterror(),
|
|
117
|
+
msg = _geterror.msg,
|
|
118
|
+
line = _geterror.line,
|
|
119
|
+
column = _geterror.column;
|
|
109
120
|
callback && callback({
|
|
110
121
|
type: 'error',
|
|
111
122
|
msg: intl.get('3f52c2a1-892d-47fe-b296-49a35ff8c4ee').d('语法错误') + ':' + msg.replace('<EOF>', intl.get('30a2737a-c786-4f9f-bb22-02ca27a557ff').d('结束')).replace('Error:', '') + '',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
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
2
|
import _Dropdown from "@chaoswise/ui/lib/Dropdown";
|
|
3
3
|
import _Button from "@chaoswise/ui/lib/Button";
|
|
4
|
-
import _TooltipText from "@chaoswise/ui/lib/TooltipText";
|
|
5
4
|
import _message from "@chaoswise/ui/lib/message";
|
|
6
5
|
import _Spin from "@chaoswise/ui/lib/Spin";
|
|
6
|
+
import _TooltipText from "@chaoswise/ui/lib/TooltipText";
|
|
7
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
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
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."); }
|
|
@@ -14,20 +14,20 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
14
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
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
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
|
|
18
|
-
import { CopyToClipboard } from
|
|
19
|
-
import ResizeObserver from
|
|
20
|
-
import keyIcon from
|
|
21
|
-
import valueIcon from
|
|
22
|
-
import timeCircleIcon from
|
|
23
|
-
import copyIcon from
|
|
24
|
-
import deleteIcon from
|
|
25
|
-
import combinedIcon from
|
|
26
|
-
import { useIntl } from
|
|
27
|
-
import { DEFAULT_MATCH_OPTION_LIST, DEFAULT_COMBINED_OPTION_LIST } from
|
|
28
|
-
import
|
|
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 { useIntl } from "../../../locales";
|
|
27
|
+
import { DEFAULT_MATCH_OPTION_LIST, DEFAULT_COMBINED_OPTION_LIST } from "./config";
|
|
28
|
+
import "./index.less";
|
|
29
29
|
function judgeNotEmpty(val) {
|
|
30
|
-
return val !== null && typeof val !==
|
|
30
|
+
return val !== null && typeof val !== "undefined";
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// 搜索高亮
|
|
@@ -36,7 +36,7 @@ function highLight(text, keyword) {
|
|
|
36
36
|
return [/*#__PURE__*/React.createElement("span", {
|
|
37
37
|
key: index,
|
|
38
38
|
style: {
|
|
39
|
-
color:
|
|
39
|
+
color: "#FF4D4F"
|
|
40
40
|
}
|
|
41
41
|
}, keyword), str];
|
|
42
42
|
}).slice(1);
|
|
@@ -382,68 +382,82 @@ var DropDown = function DropDown(props) {
|
|
|
382
382
|
}));
|
|
383
383
|
return _historyDelete.apply(this, arguments);
|
|
384
384
|
}
|
|
385
|
+
var onPreventTooltipEvent = function onPreventTooltipEvent(e) {
|
|
386
|
+
e.stopPropagation();
|
|
387
|
+
};
|
|
388
|
+
var TooltipTextDom = function TooltipTextDom(children) {
|
|
389
|
+
return /*#__PURE__*/React.createElement(_TooltipText, {
|
|
390
|
+
title: /*#__PURE__*/React.createElement("span", {
|
|
391
|
+
onClick: onPreventTooltipEvent
|
|
392
|
+
}, children)
|
|
393
|
+
}, children);
|
|
394
|
+
};
|
|
385
395
|
var menu = /*#__PURE__*/React.createElement("div", {
|
|
386
396
|
className: "aggregate-drop-down-wrap",
|
|
387
397
|
onClick: function onClick(e) {
|
|
398
|
+
var _e$nativeEvent, _e$nativeEvent$stopIm;
|
|
388
399
|
e.stopPropagation();
|
|
400
|
+
e === null || e === void 0 || (_e$nativeEvent = e.nativeEvent) === null || _e$nativeEvent === void 0 || (_e$nativeEvent$stopIm = _e$nativeEvent.stopImmediatePropagation) === null || _e$nativeEvent$stopIm === void 0 || _e$nativeEvent$stopIm.call(_e$nativeEvent);
|
|
389
401
|
}
|
|
390
402
|
}, /*#__PURE__*/React.createElement("div", {
|
|
391
403
|
className: "aggregate-drop-down"
|
|
392
404
|
}, keyOptionValueNotEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
393
405
|
className: "list-title"
|
|
394
|
-
}, intl.get(
|
|
406
|
+
}, intl.get("4412a02d-d11d-4231-bf91-fd65afd9ea77").d("标签搜索")), /*#__PURE__*/React.createElement(_Spin, {
|
|
395
407
|
spinning: keyLoading,
|
|
396
|
-
tip: intl.get(
|
|
408
|
+
tip: intl.get("51b43939-ce6a-4a41-9038-832b8ab4a175").d("加载中..."),
|
|
397
409
|
size: "small"
|
|
398
410
|
}, !dropDownKeyListEmpty ? keyList.map(function (record, index) {
|
|
399
411
|
var value = record.value,
|
|
400
412
|
des = record.des;
|
|
413
|
+
var highLightText = highLight(value, keyOptionValue);
|
|
401
414
|
return /*#__PURE__*/React.createElement("div", {
|
|
402
415
|
key: index,
|
|
403
416
|
className: "list",
|
|
404
417
|
onClick: function onClick() {
|
|
405
418
|
keyOption === null || keyOption === void 0 || keyOption.onSelect(value, record);
|
|
406
419
|
}
|
|
407
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
408
|
-
className: "list-title-target-wrapper"
|
|
409
420
|
}, /*#__PURE__*/React.createElement("img", {
|
|
410
421
|
className: "pre-icon",
|
|
411
422
|
src: keyIcon,
|
|
412
423
|
alt: ""
|
|
413
|
-
}),
|
|
424
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
425
|
+
className: "list-title-value-wrapper"
|
|
426
|
+
}, TooltipTextDom(highLightText)), /*#__PURE__*/React.createElement("span", {
|
|
414
427
|
className: "list-title-des-wrapper"
|
|
415
|
-
}, des));
|
|
428
|
+
}, TooltipTextDom(des)));
|
|
416
429
|
}) : /*#__PURE__*/React.createElement("div", {
|
|
417
430
|
className: "empty"
|
|
418
|
-
}, intl.get(
|
|
431
|
+
}, intl.get("1cd159c8-2a4d-4208-a170-55a34b91f671").d("暂无数据,提交搜索后搜索关键字")))), valueOptionValueNotEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
419
432
|
className: "list-title"
|
|
420
433
|
}, "Value"), /*#__PURE__*/React.createElement(_Spin, {
|
|
421
434
|
spinning: valueLoading,
|
|
422
|
-
tip: intl.get(
|
|
435
|
+
tip: intl.get("51b43939-ce6a-4a41-9038-832b8ab4a175").d("加载中..."),
|
|
423
436
|
size: "small"
|
|
424
437
|
}, !dropDownValueListEmpty ? valueList.map(function (record, index) {
|
|
425
438
|
var value = record.value,
|
|
426
439
|
des = record.des;
|
|
440
|
+
var highLightText = highLight(value, valueOptionValue === null || valueOptionValue === void 0 ? void 0 : valueOptionValue.value);
|
|
427
441
|
return /*#__PURE__*/React.createElement("div", {
|
|
428
442
|
key: index,
|
|
429
443
|
className: "list",
|
|
430
444
|
onClick: function onClick() {
|
|
431
445
|
valueOption === null || valueOption === void 0 || valueOption.onSelect(value, record);
|
|
432
446
|
}
|
|
433
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
434
|
-
className: "list-title-target-wrapper"
|
|
435
447
|
}, /*#__PURE__*/React.createElement("img", {
|
|
436
448
|
className: "pre-icon",
|
|
437
449
|
src: valueIcon,
|
|
438
450
|
alt: ""
|
|
439
|
-
}),
|
|
451
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
452
|
+
className: "list-title-value-wrapper"
|
|
453
|
+
}, TooltipTextDom(highLightText)), /*#__PURE__*/React.createElement("span", {
|
|
440
454
|
className: "list-title-des-wrapper"
|
|
441
|
-
}, des));
|
|
455
|
+
}, TooltipTextDom(des)));
|
|
442
456
|
}) : /*#__PURE__*/React.createElement("div", {
|
|
443
457
|
className: "empty"
|
|
444
|
-
}, intl.get(
|
|
458
|
+
}, intl.get("1cd159c8-2a4d-4208-a170-55a34b91f671").d("暂无数据,提交搜索后搜索关键字")))), matchOption.isShow && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
445
459
|
className: "list-title"
|
|
446
|
-
}, intl.get(
|
|
460
|
+
}, intl.get("f2447d25-e81c-4656-9e4c-f66741dd8a52").d("匹配方式")), (matchOption.list || DEFAULT_MATCH_OPTION_LIST).map(function (record, index) {
|
|
447
461
|
var value = record.value,
|
|
448
462
|
des = record.des;
|
|
449
463
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -452,18 +466,18 @@ var DropDown = function DropDown(props) {
|
|
|
452
466
|
onClick: function onClick() {
|
|
453
467
|
matchOption === null || matchOption === void 0 || matchOption.onSelect(value, record);
|
|
454
468
|
}
|
|
455
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
456
|
-
className: "list-title-target-wrapper"
|
|
457
469
|
}, /*#__PURE__*/React.createElement("img", {
|
|
458
470
|
className: "pre-icon",
|
|
459
471
|
src: combinedIcon,
|
|
460
472
|
alt: ""
|
|
461
|
-
}),
|
|
473
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
474
|
+
className: "list-title-value-wrapper"
|
|
475
|
+
}, TooltipTextDom(value)), /*#__PURE__*/React.createElement("span", {
|
|
462
476
|
className: "list-title-des-wrapper"
|
|
463
|
-
}, des));
|
|
477
|
+
}, TooltipTextDom(des)));
|
|
464
478
|
})), combinedOption.isShow && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
465
479
|
className: "list-title"
|
|
466
|
-
}, intl.get(
|
|
480
|
+
}, intl.get("2e8bd2b4-57bf-4778-a254-3b577d0241c5").d("组合符号")), (combinedOption.list || DEFAULT_COMBINED_OPTION_LIST).map(function (record, index) {
|
|
467
481
|
var value = record.value,
|
|
468
482
|
des = record.des;
|
|
469
483
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -472,46 +486,47 @@ var DropDown = function DropDown(props) {
|
|
|
472
486
|
onClick: function onClick() {
|
|
473
487
|
combinedOption === null || combinedOption === void 0 || combinedOption.onSelect(value, record);
|
|
474
488
|
}
|
|
475
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
476
|
-
className: "list-title-target-wrapper"
|
|
477
489
|
}, /*#__PURE__*/React.createElement("img", {
|
|
478
490
|
className: "pre-icon",
|
|
479
491
|
src: combinedIcon,
|
|
480
492
|
alt: ""
|
|
481
|
-
}),
|
|
493
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
494
|
+
className: "list-title-value-wrapper"
|
|
495
|
+
}, TooltipTextDom(value)), /*#__PURE__*/React.createElement("span", {
|
|
482
496
|
className: "list-title-des-wrapper"
|
|
483
|
-
}, des));
|
|
497
|
+
}, TooltipTextDom(des)));
|
|
484
498
|
})), historyOptionValueNotEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
485
499
|
className: "list-title"
|
|
486
|
-
}, intl.get(
|
|
500
|
+
}, intl.get("354fbc6d-1abb-4510-81a9-9aa2efa6f482").d("搜索历史")), /*#__PURE__*/React.createElement(_Spin, {
|
|
487
501
|
spinning: historyLoading,
|
|
488
|
-
tip: intl.get(
|
|
502
|
+
tip: intl.get("51b43939-ce6a-4a41-9038-832b8ab4a175").d("加载中..."),
|
|
489
503
|
size: "small"
|
|
490
504
|
}, !dropDownListHistoryEmpty ? historyList.map(function (record, index) {
|
|
491
505
|
var id = record.id,
|
|
492
506
|
value = record.value,
|
|
493
507
|
des = record.des;
|
|
508
|
+
var highLightText = highLight(value, historyOptionValue);
|
|
494
509
|
return /*#__PURE__*/React.createElement("div", {
|
|
495
510
|
key: index,
|
|
496
511
|
className: "list",
|
|
497
512
|
onClick: function onClick() {
|
|
498
513
|
historyOption === null || historyOption === void 0 || historyOption.onSelect(value, record);
|
|
499
514
|
}
|
|
500
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
501
|
-
className: "list-title-target-wrapper"
|
|
502
515
|
}, /*#__PURE__*/React.createElement("img", {
|
|
503
516
|
className: "pre-icon",
|
|
504
517
|
src: timeCircleIcon,
|
|
505
518
|
alt: ""
|
|
506
|
-
}),
|
|
519
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
520
|
+
className: "list-title-value-wrapper"
|
|
521
|
+
}, TooltipTextDom(highLightText)), /*#__PURE__*/React.createElement("span", {
|
|
507
522
|
className: "list-title-des-wrapper des"
|
|
508
|
-
}, des), /*#__PURE__*/React.createElement("span", {
|
|
523
|
+
}, TooltipTextDom(des)), /*#__PURE__*/React.createElement("span", {
|
|
509
524
|
className: "action"
|
|
510
525
|
}, /*#__PURE__*/React.createElement(CopyToClipboard, {
|
|
511
526
|
text: value,
|
|
512
527
|
onCopy: function onCopy(text) {
|
|
513
528
|
historyOption === null || historyOption === void 0 || historyOption.onCopy(text);
|
|
514
|
-
_message.success(intl.get(
|
|
529
|
+
_message.success(intl.get("15444b85-9196-4bb6-97bd-eb5cd4186cb9").d("搜索条件已复制"));
|
|
515
530
|
}
|
|
516
531
|
}, /*#__PURE__*/React.createElement("img", {
|
|
517
532
|
onClick: function onClick(e) {
|
|
@@ -531,18 +546,18 @@ var DropDown = function DropDown(props) {
|
|
|
531
546
|
})));
|
|
532
547
|
}) : /*#__PURE__*/React.createElement("div", {
|
|
533
548
|
className: "empty"
|
|
534
|
-
}, intl.get(
|
|
549
|
+
}, intl.get("1cd159c8-2a4d-4208-a170-55a34b91f671").d("暂无数据,提交搜索后搜索关键字"))))), /*#__PURE__*/React.createElement("div", {
|
|
535
550
|
className: "desc"
|
|
536
|
-
}, /*#__PURE__*/React.createElement(_TooltipText, null, /*#__PURE__*/React.createElement("span", null, intl.get(
|
|
551
|
+
}, /*#__PURE__*/React.createElement(_TooltipText, null, /*#__PURE__*/React.createElement("span", null, intl.get("be953f09-653f-4715-a3b9-9e0faef199b3").d("全文检索:hello world")), /*#__PURE__*/React.createElement("span", {
|
|
537
552
|
className: "desc-margin-32"
|
|
538
|
-
}, intl.get(
|
|
553
|
+
}, intl.get("ff777cfe-21b4-4eb0-bf80-ebd92081fdf5").d('完全匹配:"hello world"')), /*#__PURE__*/React.createElement("span", {
|
|
539
554
|
className: "desc-margin-32"
|
|
540
|
-
}, intl.get(
|
|
555
|
+
}, intl.get("229e8f35-ce6c-403a-b52e-05346dd8eb0b").d("通配符:*?")), /*#__PURE__*/React.createElement("span", {
|
|
541
556
|
className: "desc-margin-32"
|
|
542
|
-
}, intl.get(
|
|
557
|
+
}, intl.get("e7413527-a5ee-4057-b765-3595cd26c09b").d("关联搜索:status:(error OR warning) AND NOT service:“service_a”"))), /*#__PURE__*/React.createElement(_Button, {
|
|
543
558
|
type: "link",
|
|
544
559
|
onClick: onHelpClick
|
|
545
|
-
}, intl.get(
|
|
560
|
+
}, intl.get("3431b29b-5fb7-411f-8a1d-8d7676b03264").d("帮助文档"))));
|
|
546
561
|
return /*#__PURE__*/React.createElement(_Dropdown, {
|
|
547
562
|
overlay: menu,
|
|
548
563
|
visible: visible,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
.aggregate-drop-down-wrap {
|
|
3
2
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); // 浮层阴影
|
|
4
3
|
background: #fff;
|
|
@@ -27,10 +26,6 @@
|
|
|
27
26
|
left: 0;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
// .ant-spin-dot-spin {
|
|
31
|
-
// font-size: 18px;
|
|
32
|
-
// }
|
|
33
|
-
|
|
34
29
|
.@{ant-prefix}-spin-text {
|
|
35
30
|
width: auto;
|
|
36
31
|
margin-left: 4px;
|
|
@@ -44,17 +39,22 @@
|
|
|
44
39
|
padding: 0 10px;
|
|
45
40
|
color: @text-color-show;
|
|
46
41
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
align-items: center;
|
|
50
|
-
}
|
|
51
|
-
.list-title-des-wrapper{
|
|
42
|
+
|
|
43
|
+
.list-title-des-wrapper {
|
|
52
44
|
color: @text-color-secondary;
|
|
45
|
+
max-width: 100px;
|
|
46
|
+
margin-left: 12px;
|
|
53
47
|
}
|
|
54
48
|
|
|
55
|
-
.list-title
|
|
49
|
+
.list-title-value-wrapper {
|
|
50
|
+
flex: 1;
|
|
51
|
+
width: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.list-title:not(:first-child) {
|
|
56
55
|
margin-top: 8px;
|
|
57
56
|
}
|
|
57
|
+
|
|
58
58
|
.list {
|
|
59
59
|
&:hover {
|
|
60
60
|
cursor: pointer;
|
|
@@ -72,11 +72,12 @@
|
|
|
72
72
|
|
|
73
73
|
line-height: 32px;
|
|
74
74
|
display: flex;
|
|
75
|
-
justify-content: space-between;
|
|
76
75
|
padding: 0 10px;
|
|
77
76
|
align-items: center;
|
|
77
|
+
|
|
78
78
|
.action {
|
|
79
79
|
display: none;
|
|
80
|
+
|
|
80
81
|
.pre-icon {
|
|
81
82
|
&:nth-child(2) {
|
|
82
83
|
margin-right: 0;
|
|
@@ -86,8 +87,6 @@
|
|
|
86
87
|
|
|
87
88
|
.pre-icon {
|
|
88
89
|
margin-right: 8px;
|
|
89
|
-
// height: 16px;
|
|
90
|
-
// width: 16px;
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
92
|
|
|
@@ -107,11 +106,13 @@
|
|
|
107
106
|
align-items: center;
|
|
108
107
|
margin-top: 8px;
|
|
109
108
|
color: @text-color-show;
|
|
110
|
-
|
|
109
|
+
|
|
110
|
+
.desc-margin-32 {
|
|
111
111
|
margin-left: 32px;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
|
|
114
|
+
.@{ant-prefix}-btn-link {
|
|
114
115
|
margin-left: 10px;
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
|
-
}
|
|
118
|
+
}
|
|
@@ -17,12 +17,12 @@ import "./index.less";
|
|
|
17
17
|
import useDropDown from "./hooks/useDropDown";
|
|
18
18
|
import CloseAllIcon from "./components/CloseAllIcon";
|
|
19
19
|
import classnames from "classnames";
|
|
20
|
-
var AggregateSearch = function AggregateSearch(
|
|
21
|
-
var
|
|
22
|
-
onChange =
|
|
23
|
-
value =
|
|
24
|
-
|
|
25
|
-
fetchKeyList =
|
|
20
|
+
var AggregateSearch = function AggregateSearch(props) {
|
|
21
|
+
var _props$onChange = props.onChange,
|
|
22
|
+
onChange = _props$onChange === void 0 ? function () {} : _props$onChange,
|
|
23
|
+
value = props.value,
|
|
24
|
+
_props$fetchKeyList = props.fetchKeyList,
|
|
25
|
+
fetchKeyList = _props$fetchKeyList === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
26
26
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
27
27
|
while (1) switch (_context.prev = _context.next) {
|
|
28
28
|
case 0:
|
|
@@ -32,9 +32,9 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
32
32
|
return _context.stop();
|
|
33
33
|
}
|
|
34
34
|
}, _callee);
|
|
35
|
-
})) :
|
|
36
|
-
|
|
37
|
-
fetchValueList =
|
|
35
|
+
})) : _props$fetchKeyList,
|
|
36
|
+
_props$fetchValueList = props.fetchValueList,
|
|
37
|
+
fetchValueList = _props$fetchValueList === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
38
38
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
39
39
|
while (1) switch (_context2.prev = _context2.next) {
|
|
40
40
|
case 0:
|
|
@@ -44,9 +44,9 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
44
44
|
return _context2.stop();
|
|
45
45
|
}
|
|
46
46
|
}, _callee2);
|
|
47
|
-
})) :
|
|
48
|
-
|
|
49
|
-
fetchHistoryList =
|
|
47
|
+
})) : _props$fetchValueList,
|
|
48
|
+
_props$fetchHistoryLi = props.fetchHistoryList,
|
|
49
|
+
fetchHistoryList = _props$fetchHistoryLi === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
50
50
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
51
51
|
while (1) switch (_context3.prev = _context3.next) {
|
|
52
52
|
case 0:
|
|
@@ -56,9 +56,9 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
56
56
|
return _context3.stop();
|
|
57
57
|
}
|
|
58
58
|
}, _callee3);
|
|
59
|
-
})) :
|
|
60
|
-
|
|
61
|
-
onHistoryDelete =
|
|
59
|
+
})) : _props$fetchHistoryLi,
|
|
60
|
+
_props$onHistoryDelet = props.onHistoryDelete,
|
|
61
|
+
onHistoryDelete = _props$onHistoryDelet === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
62
62
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
63
63
|
while (1) switch (_context4.prev = _context4.next) {
|
|
64
64
|
case 0:
|
|
@@ -68,18 +68,18 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
68
68
|
return _context4.stop();
|
|
69
69
|
}
|
|
70
70
|
}, _callee4);
|
|
71
|
-
})) :
|
|
72
|
-
|
|
73
|
-
onHelpClick =
|
|
74
|
-
|
|
75
|
-
onPressEnter =
|
|
76
|
-
mode =
|
|
77
|
-
|
|
78
|
-
defaultMode =
|
|
79
|
-
placeholder =
|
|
80
|
-
className =
|
|
81
|
-
|
|
82
|
-
style =
|
|
71
|
+
})) : _props$onHistoryDelet,
|
|
72
|
+
_props$onHelpClick = props.onHelpClick,
|
|
73
|
+
onHelpClick = _props$onHelpClick === void 0 ? function () {} : _props$onHelpClick,
|
|
74
|
+
_props$onPressEnter = props.onPressEnter,
|
|
75
|
+
onPressEnter = _props$onPressEnter === void 0 ? function () {} : _props$onPressEnter,
|
|
76
|
+
mode = props.mode,
|
|
77
|
+
_props$defaultMode = props.defaultMode,
|
|
78
|
+
defaultMode = _props$defaultMode === void 0 ? "tag" : _props$defaultMode,
|
|
79
|
+
placeholder = props.placeholder,
|
|
80
|
+
className = props.className,
|
|
81
|
+
_props$style = props.style,
|
|
82
|
+
style = _props$style === void 0 ? {} : _props$style;
|
|
83
83
|
// 输入模式
|
|
84
84
|
var _useState = useState(defaultMode),
|
|
85
85
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -103,7 +103,7 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
103
103
|
// 是否正在输入中文
|
|
104
104
|
var isComposing = useRef(false);
|
|
105
105
|
var handleSyntaxCheck = /*#__PURE__*/function () {
|
|
106
|
-
var
|
|
106
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(inputStr) {
|
|
107
107
|
var checkRes, column, msg, _getCursorNodeAndInde, errorNode, findParent, errorTag;
|
|
108
108
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
109
109
|
while (1) switch (_context5.prev = _context5.next) {
|
|
@@ -151,11 +151,11 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
151
151
|
}, _callee5);
|
|
152
152
|
}));
|
|
153
153
|
return function handleSyntaxCheck(_x) {
|
|
154
|
-
return
|
|
154
|
+
return _ref5.apply(this, arguments);
|
|
155
155
|
};
|
|
156
156
|
}();
|
|
157
157
|
var handleValueChange = /*#__PURE__*/function () {
|
|
158
|
-
var
|
|
158
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(inputStr, mode) {
|
|
159
159
|
var checkRes, planeTextPosition, htmlString, _getCursorNodeAndInde3, targetNode, targetIndex;
|
|
160
160
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
161
161
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -204,7 +204,7 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
204
204
|
}, _callee6);
|
|
205
205
|
}));
|
|
206
206
|
return function handleValueChange(_x2, _x3) {
|
|
207
|
-
return
|
|
207
|
+
return _ref6.apply(this, arguments);
|
|
208
208
|
};
|
|
209
209
|
}();
|
|
210
210
|
var _useDropDown = useDropDown(container, handleValueChange),
|
|
@@ -214,7 +214,7 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
214
214
|
onHistorySelect = _useDropDown.onHistorySelect,
|
|
215
215
|
setVisible = _useDropDown.setVisible;
|
|
216
216
|
var onInput = /*#__PURE__*/function () {
|
|
217
|
-
var
|
|
217
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(e) {
|
|
218
218
|
var cloneDomRemoveCloseBtnDom;
|
|
219
219
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
220
220
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -235,11 +235,11 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
235
235
|
}, _callee7);
|
|
236
236
|
}));
|
|
237
237
|
return function onInput(_x4) {
|
|
238
|
-
return
|
|
238
|
+
return _ref7.apply(this, arguments);
|
|
239
239
|
};
|
|
240
240
|
}();
|
|
241
241
|
useEffect(function () {
|
|
242
|
-
if (value
|
|
242
|
+
if ("value" in props) {
|
|
243
243
|
handleValueChange(value);
|
|
244
244
|
}
|
|
245
245
|
}, [value]);
|
|
@@ -265,7 +265,6 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
265
265
|
// 将下个文本元素的第一个空格去掉
|
|
266
266
|
nextSiblingWrappr.nodeValue = nextSiblingWrappr.nodeValue.replace(/(^\s{1})/, "");
|
|
267
267
|
}
|
|
268
|
-
;
|
|
269
268
|
container.current.removeChild(CloseTagWrapper);
|
|
270
269
|
handleValueChange(container.current.innerText);
|
|
271
270
|
onChange(container.current.innerText);
|
|
@@ -296,7 +295,6 @@ var AggregateSearch = function AggregateSearch(_ref) {
|
|
|
296
295
|
// 回车阻止默认的换行行为
|
|
297
296
|
e.preventDefault();
|
|
298
297
|
var cloneDomRemoveCloseBtnDom = cloneDomRemoveCloseBtn(e.target);
|
|
299
|
-
onChange(cloneDomRemoveCloseBtnDom.innerText);
|
|
300
298
|
onPressEnter(cloneDomRemoveCloseBtnDom.innerText);
|
|
301
299
|
setContentEditable(false);
|
|
302
300
|
setVisible(false);
|
|
@@ -275,7 +275,7 @@ export function textInit(e) {
|
|
|
275
275
|
// get text representation of clipboard
|
|
276
276
|
var text = (e.originalEvent || e).clipboardData.getData("text/plain");
|
|
277
277
|
// insert text manually
|
|
278
|
-
document.execCommand("
|
|
278
|
+
document.execCommand("insertText", false, text);
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
// 获取当前输入的光标位置(纯文本模式)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _Icon from "@chaoswise/ui/lib/Icon";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import "./index.less";
|
|
4
|
+
var CloseAllIcon = function CloseAllIcon(_ref) {
|
|
5
|
+
var onClickCloseAll = _ref.onClickCloseAll;
|
|
6
|
+
return /*#__PURE__*/React.createElement(_Icon, {
|
|
7
|
+
type: "close-circle",
|
|
8
|
+
theme: "filled",
|
|
9
|
+
onClick: onClickCloseAll,
|
|
10
|
+
className: "content-editable-close-all-icon"
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export default CloseAllIcon;
|
|
@@ -0,0 +1,157 @@
|
|
|
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
|
+
var _excluded = ["onChange", "value", "onPressEnter", "placeholder", "className", "render"];
|
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
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; }
|
|
5
|
+
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); } }
|
|
6
|
+
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); }); }; }
|
|
7
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
8
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
9
|
+
import React, { useEffect, useRef, forwardRef, useImperativeHandle } from "react";
|
|
10
|
+
import PropTypes from "prop-types";
|
|
11
|
+
import { textInit, getCursorPosition, getCursorNodeAndIndex, setCursorPosition } from "./utils";
|
|
12
|
+
import "./index.less";
|
|
13
|
+
import CloseAllIcon from "./components/CloseAllIcon";
|
|
14
|
+
import classnames from "classnames";
|
|
15
|
+
var ContentEditableSearch = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
16
|
+
var _props$onChange = props.onChange,
|
|
17
|
+
onChange = _props$onChange === void 0 ? function () {} : _props$onChange,
|
|
18
|
+
value = props.value,
|
|
19
|
+
_props$onPressEnter = props.onPressEnter,
|
|
20
|
+
onPressEnter = _props$onPressEnter === void 0 ? function () {} : _props$onPressEnter,
|
|
21
|
+
placeholder = props.placeholder,
|
|
22
|
+
className = props.className,
|
|
23
|
+
_props$render = props.render,
|
|
24
|
+
render = _props$render === void 0 ? function () {} : _props$render,
|
|
25
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
26
|
+
var container = useRef(null);
|
|
27
|
+
var containerWrapperRef = useRef(null);
|
|
28
|
+
// 是否正在输入中文
|
|
29
|
+
var isComposing = useRef(false);
|
|
30
|
+
useImperativeHandle(ref, function () {
|
|
31
|
+
return {
|
|
32
|
+
getContainerWrapper: function getContainerWrapper() {
|
|
33
|
+
return containerWrapperRef.current;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
var handleValueChange = /*#__PURE__*/function () {
|
|
38
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(inputStr) {
|
|
39
|
+
var planeTextPosition, htmlString, _getCursorNodeAndInde, targetNode, targetIndex;
|
|
40
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
41
|
+
while (1) switch (_context.prev = _context.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
// 计算当前光标位置(纯文本模式)
|
|
44
|
+
planeTextPosition = getCursorPosition(container.current); // 将纯文本模式转为html模式(语法解析器)
|
|
45
|
+
htmlString = render(inputStr);
|
|
46
|
+
if (!htmlString.trim()) {
|
|
47
|
+
// 修复空状态placeholder
|
|
48
|
+
container.current.innerHTML = "";
|
|
49
|
+
} else {
|
|
50
|
+
container.current.innerHTML = htmlString;
|
|
51
|
+
}
|
|
52
|
+
// // 找到格式化后的光标位置
|
|
53
|
+
if (planeTextPosition !== null) {
|
|
54
|
+
_getCursorNodeAndInde = getCursorNodeAndIndex(container.current, planeTextPosition), targetNode = _getCursorNodeAndInde.targetNode, targetIndex = _getCursorNodeAndInde.targetIndex; // 设置光标位置
|
|
55
|
+
setCursorPosition(targetNode, targetIndex);
|
|
56
|
+
}
|
|
57
|
+
case 4:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context.stop();
|
|
60
|
+
}
|
|
61
|
+
}, _callee);
|
|
62
|
+
}));
|
|
63
|
+
return function handleValueChange(_x) {
|
|
64
|
+
return _ref.apply(this, arguments);
|
|
65
|
+
};
|
|
66
|
+
}();
|
|
67
|
+
var onInput = /*#__PURE__*/function () {
|
|
68
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e) {
|
|
69
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
70
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
if (!isComposing.current) {
|
|
73
|
+
_context2.next = 2;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
return _context2.abrupt("return");
|
|
77
|
+
case 2:
|
|
78
|
+
handleValueChange(e.target.innerText);
|
|
79
|
+
onChange(e.target.innerText);
|
|
80
|
+
case 4:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context2.stop();
|
|
83
|
+
}
|
|
84
|
+
}, _callee2);
|
|
85
|
+
}));
|
|
86
|
+
return function onInput(_x2) {
|
|
87
|
+
return _ref2.apply(this, arguments);
|
|
88
|
+
};
|
|
89
|
+
}();
|
|
90
|
+
useEffect(function () {
|
|
91
|
+
if ("value" in props) {
|
|
92
|
+
handleValueChange(value);
|
|
93
|
+
}
|
|
94
|
+
}, [value]);
|
|
95
|
+
var onKeyDown = function onKeyDown(e) {
|
|
96
|
+
var keyCode = e.keyCode;
|
|
97
|
+
if (keyCode === 13) {
|
|
98
|
+
// 回车阻止默认的换行行为
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
onPressEnter(e.target.innerText);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
104
|
+
className: classnames("content-editable-search-wrapper", className, {}),
|
|
105
|
+
ref: containerWrapperRef
|
|
106
|
+
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
spellCheck: false,
|
|
108
|
+
onCompositionEnd: function onCompositionEnd(e) {
|
|
109
|
+
isComposing.current = false;
|
|
110
|
+
// 输入中文结束再触发一次,保证文本框对应内容与当前返回值一致,选项效果不会丢失
|
|
111
|
+
handleValueChange(e.target.innerText);
|
|
112
|
+
onChange(e.target.innerText);
|
|
113
|
+
},
|
|
114
|
+
onCompositionStart: function onCompositionStart() {
|
|
115
|
+
return isComposing.current = true;
|
|
116
|
+
},
|
|
117
|
+
className: "content-editable-search-input",
|
|
118
|
+
ref: container,
|
|
119
|
+
"data-attr": "container",
|
|
120
|
+
"data-placeholder": placeholder,
|
|
121
|
+
contentEditable: true,
|
|
122
|
+
suppressContentEditableWarning: true,
|
|
123
|
+
onPaste: textInit // 只粘贴纯文本 去除html标签
|
|
124
|
+
,
|
|
125
|
+
onInput: onInput,
|
|
126
|
+
onKeyDown: onKeyDown
|
|
127
|
+
}), /*#__PURE__*/React.createElement(CloseAllIcon, {
|
|
128
|
+
onClickCloseAll: function onClickCloseAll() {
|
|
129
|
+
container.current.innerText = "";
|
|
130
|
+
handleValueChange("");
|
|
131
|
+
onChange("");
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
});
|
|
135
|
+
ContentEditableSearch.propTypes = {
|
|
136
|
+
/**
|
|
137
|
+
* 受控value
|
|
138
|
+
*/
|
|
139
|
+
value: PropTypes.string,
|
|
140
|
+
/**
|
|
141
|
+
* 文本内容变化的回调,(value) => {}
|
|
142
|
+
*/
|
|
143
|
+
onChange: PropTypes.func,
|
|
144
|
+
/**
|
|
145
|
+
* 文本内容回车变化的回调,(value) => {}
|
|
146
|
+
*/
|
|
147
|
+
onPressEnter: PropTypes.func,
|
|
148
|
+
/**
|
|
149
|
+
* 内容为空提示
|
|
150
|
+
*/
|
|
151
|
+
placeholder: PropTypes.string,
|
|
152
|
+
/**
|
|
153
|
+
* 聚合搜索框外层容器的类名
|
|
154
|
+
*/
|
|
155
|
+
className: PropTypes.string
|
|
156
|
+
};
|
|
157
|
+
export default ContentEditableSearch;
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
.content-editable-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
|
+
border: @border-width-base @border-style-base @input-border-color;
|
|
25
|
+
border-radius: @border-radius-base;
|
|
26
|
+
width: 100%;
|
|
27
|
+
// 聚焦样式修改
|
|
28
|
+
&:focus-within {
|
|
29
|
+
.active();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
.hover();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 取消默认聚焦样式
|
|
37
|
+
&:focus-visible {
|
|
38
|
+
outline: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.content-editable-search-input {
|
|
42
|
+
position: relative;
|
|
43
|
+
padding: 0 10px;
|
|
44
|
+
flex: 1;
|
|
45
|
+
height: 100%;
|
|
46
|
+
min-height: 26px;
|
|
47
|
+
line-height: 26px;
|
|
48
|
+
outline: none;
|
|
49
|
+
|
|
50
|
+
&:empty:before {
|
|
51
|
+
content: attr(data-placeholder);
|
|
52
|
+
font-size: 12px;
|
|
53
|
+
color: @text-color-secondary;
|
|
54
|
+
line-height: 20px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:empty+.content-editable-close-all-icon {
|
|
58
|
+
display: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:focus:before {
|
|
62
|
+
content: ""; // 不能为none,否则placeholder不显示
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// 粘贴去除格式
|
|
2
|
+
export function textInit(e) {
|
|
3
|
+
// cancel paste
|
|
4
|
+
e.preventDefault();
|
|
5
|
+
// get text representation of clipboard
|
|
6
|
+
var text = (e.originalEvent || e).clipboardData.getData("text/plain");
|
|
7
|
+
// insert text manually
|
|
8
|
+
document.execCommand("insertText", false, text);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 获取当前输入的光标位置(纯文本模式)
|
|
12
|
+
export var getCursorPosition = function getCursorPosition(node) {
|
|
13
|
+
var _endContainer$dataset;
|
|
14
|
+
var selection = window.getSelection();
|
|
15
|
+
if (selection.type !== 'Caret') {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
var range = selection.getRangeAt(0);
|
|
19
|
+
var endContainer = range.endContainer;
|
|
20
|
+
if (((_endContainer$dataset = endContainer.dataset) === null || _endContainer$dataset === void 0 ? void 0 : _endContainer$dataset['attr']) === 'container') {
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 计算纯文本模式下,当前光标所处的位置
|
|
25
|
+
var positionIndex = 0;
|
|
26
|
+
var isBreak = false;
|
|
27
|
+
var loop = function loop(node) {
|
|
28
|
+
var nodes = node.childNodes;
|
|
29
|
+
for (var index = 0; index < nodes.length; index++) {
|
|
30
|
+
if (isBreak) {
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
var element = nodes[index];
|
|
34
|
+
if (element.nodeType === 3) {
|
|
35
|
+
if (element === endContainer) {
|
|
36
|
+
positionIndex += range.endOffset;
|
|
37
|
+
isBreak = true;
|
|
38
|
+
break;
|
|
39
|
+
} else {
|
|
40
|
+
positionIndex += element.data.length;
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
loop(element);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
loop(node);
|
|
48
|
+
return positionIndex;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// 根据纯文本模式下的光标位置,设置html模式下的光标位置
|
|
52
|
+
export var getCursorNodeAndIndex = function getCursorNodeAndIndex(node, positionIndex) {
|
|
53
|
+
var targetNode;
|
|
54
|
+
var targetIndex;
|
|
55
|
+
var sum = 0;
|
|
56
|
+
var isBreak = false;
|
|
57
|
+
var loop = function loop(node) {
|
|
58
|
+
var nodes = node.childNodes;
|
|
59
|
+
for (var index = 0; index < nodes.length; index++) {
|
|
60
|
+
if (isBreak) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
var element = nodes[index];
|
|
64
|
+
if (element.nodeType === 3) {
|
|
65
|
+
var _element$data;
|
|
66
|
+
var elementLength = ((_element$data = element.data) === null || _element$data === void 0 ? void 0 : _element$data.length) || 0;
|
|
67
|
+
if (sum <= positionIndex && sum + elementLength >= positionIndex) {
|
|
68
|
+
targetNode = element;
|
|
69
|
+
targetIndex = positionIndex - sum;
|
|
70
|
+
isBreak = true;
|
|
71
|
+
break;
|
|
72
|
+
} else {
|
|
73
|
+
sum += elementLength;
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
loop(element);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
loop(node);
|
|
81
|
+
return {
|
|
82
|
+
targetNode: targetNode,
|
|
83
|
+
targetIndex: targetIndex
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// 光标跳转到指定位置
|
|
88
|
+
export var setCursorPosition = function setCursorPosition(targetNode, targetIndex) {
|
|
89
|
+
if (!targetNode) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
var selection = window.getSelection();
|
|
93
|
+
var range = new Range();
|
|
94
|
+
range.setStart(targetNode, targetIndex);
|
|
95
|
+
range.collapse(true);
|
|
96
|
+
selection.removeAllRanges();
|
|
97
|
+
selection.addRange(range);
|
|
98
|
+
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import _TooltipText from "@chaoswise/ui/lib/TooltipText";
|
|
1
|
+
import _Tooltip from "@chaoswise/ui/lib/Tooltip";
|
|
3
2
|
import _Typography from "@chaoswise/ui/lib/Typography";
|
|
4
|
-
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; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
3
|
import React, { Fragment } from "react";
|
|
8
4
|
var Paragraph = _Typography.Paragraph;
|
|
9
5
|
var DoCommon = function DoCommon(_ref) {
|
|
@@ -15,19 +11,26 @@ var DoCommon = function DoCommon(_ref) {
|
|
|
15
11
|
wordBreak: "break-all"
|
|
16
12
|
}
|
|
17
13
|
}, (list || []).map(function (item, index) {
|
|
18
|
-
|
|
14
|
+
var _item$value, _item$value2;
|
|
15
|
+
var str = ((_item$value = item.value) === null || _item$value === void 0 ? void 0 : _item$value.toString()) || '-';
|
|
16
|
+
var dom = str.replace(/\n/g, "<br />").split("<br />");
|
|
17
|
+
dom = dom.map(function (item, index) {
|
|
18
|
+
if (index === dom.length - 1) {
|
|
19
|
+
return item;
|
|
20
|
+
}
|
|
21
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, item, /*#__PURE__*/React.createElement("br", null));
|
|
22
|
+
});
|
|
23
|
+
return /*#__PURE__*/React.createElement(_Tooltip, {
|
|
19
24
|
title: item.value,
|
|
20
|
-
key: index
|
|
25
|
+
key: index,
|
|
26
|
+
placement: "topLeft"
|
|
21
27
|
}, paragraphEllipsis ? /*#__PURE__*/React.createElement(Paragraph, {
|
|
22
|
-
ellipsis: paragraphEllipsis
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
whiteSpace: 'initial'
|
|
29
|
-
}, "whiteSpace", 'pre-line')
|
|
30
|
-
}, item.value || '-'));
|
|
28
|
+
ellipsis: paragraphEllipsis
|
|
29
|
+
}, dom) : /*#__PURE__*/React.createElement("span", {
|
|
30
|
+
style: {
|
|
31
|
+
whiteSpace: 'pre-line'
|
|
32
|
+
}
|
|
33
|
+
}, ((_item$value2 = item.value) === null || _item$value2 === void 0 ? void 0 : _item$value2.toString()) || '-'));
|
|
31
34
|
})));
|
|
32
35
|
};
|
|
33
36
|
export default DoCommon;
|
|
@@ -30,8 +30,8 @@ var DoUser = function DoUser(_ref) {
|
|
|
30
30
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, tooltipContent[key], " ", item[key] || '', ' '), /*#__PURE__*/React.createElement("br", null));
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
|
-
var nameKey = componentType ===
|
|
34
|
-
return /*#__PURE__*/React.createElement(Fragment, null, belongComponentType ===
|
|
33
|
+
var nameKey = componentType === "USER_GROUP" ? 'groupName' : 'userAlias';
|
|
34
|
+
return /*#__PURE__*/React.createElement(Fragment, null, belongComponentType === "TABLE" ? /*#__PURE__*/React.createElement(TagShowMoreList, {
|
|
35
35
|
text: list,
|
|
36
36
|
tagCount: 1,
|
|
37
37
|
flag: "user",
|
|
@@ -53,9 +53,9 @@ var DoUser = function DoUser(_ref) {
|
|
|
53
53
|
}, /*#__PURE__*/React.createElement(_Avatar, {
|
|
54
54
|
className: 'ci-detail-avatar',
|
|
55
55
|
size: "small"
|
|
56
|
-
}, (_ref2 = item.userAlias
|
|
56
|
+
}, (_ref2 = item.userAlias ? "".concat(item.userName, "(").concat(item.userAlias, ")") : item.name) === null || _ref2 === void 0 ? void 0 : _ref2.substring(0, 1)), /*#__PURE__*/React.createElement("div", {
|
|
57
57
|
className: 'ci-detail-user-name'
|
|
58
|
-
}, item.userAlias
|
|
58
|
+
}, item.userAlias ? "".concat(item.userName, "(").concat(item.userAlias, ")") : item.name)));
|
|
59
59
|
})));
|
|
60
60
|
};
|
|
61
61
|
export default DoUser;
|
|
@@ -55,7 +55,12 @@ var TagShowMoreList = function TagShowMoreList(props) {
|
|
|
55
55
|
var classNameDiv = _className || 'wrapper-inner';
|
|
56
56
|
return tags.map(function (item, index) {
|
|
57
57
|
var _String;
|
|
58
|
-
var _name =
|
|
58
|
+
var _name = '';
|
|
59
|
+
if (nameKey == 'userAlias') {
|
|
60
|
+
_name = item.userAlias ? "".concat(item === null || item === void 0 ? void 0 : item.userName, "(").concat(item === null || item === void 0 ? void 0 : item.userAlias, ")") : item === null || item === void 0 ? void 0 : item.id;
|
|
61
|
+
} else {
|
|
62
|
+
_name = item[nameKey] || (item === null || item === void 0 ? void 0 : item.ciName) || (item === null || item === void 0 ? void 0 : item.id);
|
|
63
|
+
}
|
|
59
64
|
return /*#__PURE__*/React.createElement(_Tooltip, {
|
|
60
65
|
title: tooltipContentFuc ? tooltipContentFuc(item) : _name,
|
|
61
66
|
key: index,
|
|
@@ -1,15 +1,23 @@
|
|
|
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); }
|
|
1
2
|
import _Tooltip from "@chaoswise/ui/lib/Tooltip";
|
|
2
3
|
import _Form from "@chaoswise/ui/lib/Form";
|
|
3
4
|
import _Collapse from "@chaoswise/ui/lib/Collapse";
|
|
4
|
-
var _excluded = ["schemaData", "detailContent"],
|
|
5
|
-
_excluded2 = ["
|
|
5
|
+
var _excluded = ["schemaData", "detailContent", "filterAttrs"],
|
|
6
|
+
_excluded2 = ["properties", "attrID"],
|
|
7
|
+
_excluded3 = ["item", "detailContent"];
|
|
6
8
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
8
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
9
16
|
import React, { useState, useEffect, useMemo, memo } from 'react';
|
|
10
17
|
import { getDescriptionComp, getDataFunc, judgmentTypeFunc } from './config/utils';
|
|
11
18
|
import { useIntl } from '../locales';
|
|
12
19
|
import './index.less';
|
|
20
|
+
import PropTypes from "prop-types";
|
|
13
21
|
var Panel = _Collapse.Panel;
|
|
14
22
|
var compositeAttr = {
|
|
15
23
|
UNIT_RANGE: 1,
|
|
@@ -21,11 +29,33 @@ var setWidthClassName = {
|
|
|
21
29
|
var PropertyControlViewer = function PropertyControlViewer(_ref) {
|
|
22
30
|
var schemaData = _ref.schemaData,
|
|
23
31
|
detailContent = _ref.detailContent,
|
|
32
|
+
filterAttrs = _ref.filterAttrs,
|
|
24
33
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
25
34
|
var intl = useIntl();
|
|
35
|
+
var _schemaData = useMemo(function () {
|
|
36
|
+
if (!filterAttrs || filterAttrs.length == 0) {
|
|
37
|
+
return schemaData;
|
|
38
|
+
}
|
|
39
|
+
var filteredData = schemaData.map(function (_ref2) {
|
|
40
|
+
var properties = _ref2.properties,
|
|
41
|
+
attrID = _ref2.attrID,
|
|
42
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
43
|
+
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
44
|
+
attrID: attrID,
|
|
45
|
+
properties: properties.filter(function (property) {
|
|
46
|
+
return !filterAttrs.some(function (_ref3) {
|
|
47
|
+
var attrGroupId = _ref3.attrGroupId,
|
|
48
|
+
conditionAttrID = _ref3.attrID;
|
|
49
|
+
return attrID === attrGroupId && property.attrID === conditionAttrID;
|
|
50
|
+
});
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
return filteredData;
|
|
55
|
+
}, [schemaData]);
|
|
26
56
|
var comList = useMemo(function () {
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
57
|
+
if (_schemaData && _schemaData.length > 0) {
|
|
58
|
+
return _schemaData.map(function (i, index) {
|
|
29
59
|
if (i.componentType === 'ATTRIBUTE_GROUP') {
|
|
30
60
|
return /*#__PURE__*/React.createElement(_Collapse, {
|
|
31
61
|
key: i.attrID,
|
|
@@ -71,7 +101,7 @@ var PropertyControlViewer = function PropertyControlViewer(_ref) {
|
|
|
71
101
|
} else {
|
|
72
102
|
return null;
|
|
73
103
|
}
|
|
74
|
-
}, [
|
|
104
|
+
}, [_schemaData]);
|
|
75
105
|
return /*#__PURE__*/React.createElement(_Form, {
|
|
76
106
|
style: {
|
|
77
107
|
minHeight: '100%'
|
|
@@ -81,11 +111,11 @@ var PropertyControlViewer = function PropertyControlViewer(_ref) {
|
|
|
81
111
|
className: "form-properties-box form-properties-view-box"
|
|
82
112
|
}, comList));
|
|
83
113
|
};
|
|
84
|
-
var AttrFormItem = /*#__PURE__*/memo(function (
|
|
114
|
+
var AttrFormItem = /*#__PURE__*/memo(function (_ref4) {
|
|
85
115
|
var _detailContent$conten;
|
|
86
|
-
var item =
|
|
87
|
-
detailContent =
|
|
88
|
-
rest = _objectWithoutProperties(
|
|
116
|
+
var item = _ref4.item,
|
|
117
|
+
detailContent = _ref4.detailContent,
|
|
118
|
+
rest = _objectWithoutProperties(_ref4, _excluded3);
|
|
89
119
|
var attrID = item.attrID,
|
|
90
120
|
attrName = item.attrName,
|
|
91
121
|
componentType = item.componentType,
|
|
@@ -125,4 +155,41 @@ var AttrFormItem = /*#__PURE__*/memo(function (_ref2) {
|
|
|
125
155
|
data: data
|
|
126
156
|
})))));
|
|
127
157
|
});
|
|
158
|
+
PropertyControlViewer.propTypes = {
|
|
159
|
+
/**
|
|
160
|
+
* 模型属性数据
|
|
161
|
+
*/
|
|
162
|
+
schemaData: PropTypes.array.isRequired,
|
|
163
|
+
/**
|
|
164
|
+
* 配置项数据
|
|
165
|
+
*/
|
|
166
|
+
detailContent: PropTypes.object.isRequired,
|
|
167
|
+
/**
|
|
168
|
+
* 需要过滤隐藏的属性
|
|
169
|
+
*/
|
|
170
|
+
filterAttrs: PropTypes.arrayOf(PropTypes.shape({
|
|
171
|
+
"attrGroupId": PropTypes.string,
|
|
172
|
+
"attrID": PropTypes.string
|
|
173
|
+
})),
|
|
174
|
+
/**
|
|
175
|
+
* 属性类型为input和textarea自动溢出省略,为对象时可设置省略行数与是否可展开等
|
|
176
|
+
*/
|
|
177
|
+
paragraphEllipsis: PropTypes.oneOf([PropTypes["boolean"], PropTypes.object]),
|
|
178
|
+
/**
|
|
179
|
+
* 属性类型为select和checkbox, 可设置显示的数量
|
|
180
|
+
*/
|
|
181
|
+
tagCount: PropTypes.number,
|
|
182
|
+
/**
|
|
183
|
+
* 属性类型为quote的点击事件
|
|
184
|
+
*/
|
|
185
|
+
handleClickChange: PropTypes.func,
|
|
186
|
+
/**
|
|
187
|
+
* 属性类型为user,鼠标悬浮显示的tooltip字段
|
|
188
|
+
*/
|
|
189
|
+
userTooltipContent: PropTypes.object,
|
|
190
|
+
/**
|
|
191
|
+
* 属性类型为userGroup, 鼠标悬浮显示的tooltip字段
|
|
192
|
+
*/
|
|
193
|
+
userGroupTooltipContent: PropTypes.object
|
|
194
|
+
};
|
|
128
195
|
export default PropertyControlViewer;
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as PropertyControlViewer } from "./PropertyControlViewer";
|
|
2
2
|
export { default as AggregateSearch } from "./AggregateSearch";
|
|
3
|
-
export { default as Watermark } from "./Watermark";
|
|
3
|
+
export { default as Watermark } from "./Watermark";
|
|
4
|
+
export { default as ContentEditableSearch } from "./ContentEditableSearch";
|