@chaoswise/business 1.0.1 → 1.0.2
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.
|
@@ -14,7 +14,7 @@ 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 "react";
|
|
17
|
+
import React, { useEffect, useState, useMemo, useRef, useCallback } from "react";
|
|
18
18
|
import { CopyToClipboard } from "react-copy-to-clipboard";
|
|
19
19
|
import ResizeObserver from "resize-observer-polyfill";
|
|
20
20
|
import keyIcon from "./assets/key.svg";
|
|
@@ -24,6 +24,7 @@ import copyIcon from "./assets/copy.svg";
|
|
|
24
24
|
import deleteIcon from "./assets/delete.svg";
|
|
25
25
|
import combinedIcon from "./assets/combined.svg";
|
|
26
26
|
import { useIntl } from "../../../locales";
|
|
27
|
+
import { debounce } from "@chaoswise/utils";
|
|
27
28
|
import { DEFAULT_MATCH_OPTION_LIST, DEFAULT_COMBINED_OPTION_LIST } from "./config";
|
|
28
29
|
import "./index.less";
|
|
29
30
|
function judgeNotEmpty(val) {
|
|
@@ -31,7 +32,9 @@ function judgeNotEmpty(val) {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
// 搜索高亮
|
|
34
|
-
function highLight(
|
|
35
|
+
function highLight() {
|
|
36
|
+
var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
37
|
+
var keyword = arguments.length > 1 ? arguments[1] : undefined;
|
|
35
38
|
return text.split(keyword).flatMap(function (str, index) {
|
|
36
39
|
return [/*#__PURE__*/React.createElement("span", {
|
|
37
40
|
key: index,
|
|
@@ -146,9 +149,9 @@ var DropDown = function DropDown(props) {
|
|
|
146
149
|
// 内置 ()
|
|
147
150
|
onSelect: function onSelect() {}
|
|
148
151
|
} : _props$combinedOption,
|
|
149
|
-
containerWrapperRef = props.containerWrapperRef
|
|
152
|
+
containerWrapperRef = props.containerWrapperRef,
|
|
153
|
+
debounceWait = props.debounceWait;
|
|
150
154
|
var intl = useIntl();
|
|
151
|
-
|
|
152
155
|
// 输入值
|
|
153
156
|
var keyOptionValue = keyOption.value;
|
|
154
157
|
var valueOptionValue = valueOption.value;
|
|
@@ -219,113 +222,115 @@ var DropDown = function DropDown(props) {
|
|
|
219
222
|
};
|
|
220
223
|
}, []);
|
|
221
224
|
// key
|
|
225
|
+
var fetchKey = /*#__PURE__*/function () {
|
|
226
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(keyOptionValue) {
|
|
227
|
+
var res;
|
|
228
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
229
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
230
|
+
case 0:
|
|
231
|
+
setKeyLoading(true);
|
|
232
|
+
_context5.next = 3;
|
|
233
|
+
return keyOption === null || keyOption === void 0 ? void 0 : keyOption.fetchFuc(keyOptionValue);
|
|
234
|
+
case 3:
|
|
235
|
+
_context5.t0 = _context5.sent;
|
|
236
|
+
if (_context5.t0) {
|
|
237
|
+
_context5.next = 6;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
_context5.t0 = [];
|
|
241
|
+
case 6:
|
|
242
|
+
res = _context5.t0;
|
|
243
|
+
setKeyList(res);
|
|
244
|
+
setKeyLoading(false);
|
|
245
|
+
case 9:
|
|
246
|
+
case "end":
|
|
247
|
+
return _context5.stop();
|
|
248
|
+
}
|
|
249
|
+
}, _callee5);
|
|
250
|
+
}));
|
|
251
|
+
return function fetchKey(_x3) {
|
|
252
|
+
return _ref.apply(this, arguments);
|
|
253
|
+
};
|
|
254
|
+
}();
|
|
255
|
+
var fetchValue = /*#__PURE__*/function () {
|
|
256
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(valueOptionValue) {
|
|
257
|
+
var res;
|
|
258
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
259
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
260
|
+
case 0:
|
|
261
|
+
setValueLoading(true);
|
|
262
|
+
_context6.next = 3;
|
|
263
|
+
return valueOption === null || valueOption === void 0 ? void 0 : valueOption.fetchFuc(valueOptionValue);
|
|
264
|
+
case 3:
|
|
265
|
+
_context6.t0 = _context6.sent;
|
|
266
|
+
if (_context6.t0) {
|
|
267
|
+
_context6.next = 6;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
_context6.t0 = [];
|
|
271
|
+
case 6:
|
|
272
|
+
res = _context6.t0;
|
|
273
|
+
setValueList(res);
|
|
274
|
+
setValueLoading(false);
|
|
275
|
+
case 9:
|
|
276
|
+
case "end":
|
|
277
|
+
return _context6.stop();
|
|
278
|
+
}
|
|
279
|
+
}, _callee6);
|
|
280
|
+
}));
|
|
281
|
+
return function fetchValue(_x4) {
|
|
282
|
+
return _ref2.apply(this, arguments);
|
|
283
|
+
};
|
|
284
|
+
}();
|
|
285
|
+
var fetchHistory = /*#__PURE__*/function () {
|
|
286
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(historyOptionValue) {
|
|
287
|
+
var res;
|
|
288
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
289
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
290
|
+
case 0:
|
|
291
|
+
setHistoryLoading(true);
|
|
292
|
+
_context7.next = 3;
|
|
293
|
+
return historyOption === null || historyOption === void 0 ? void 0 : historyOption.fetchFuc(historyOptionValue);
|
|
294
|
+
case 3:
|
|
295
|
+
_context7.t0 = _context7.sent;
|
|
296
|
+
if (_context7.t0) {
|
|
297
|
+
_context7.next = 6;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
_context7.t0 = [];
|
|
301
|
+
case 6:
|
|
302
|
+
res = _context7.t0;
|
|
303
|
+
setHistoryList(res);
|
|
304
|
+
setHistoryLoading(false);
|
|
305
|
+
case 9:
|
|
306
|
+
case "end":
|
|
307
|
+
return _context7.stop();
|
|
308
|
+
}
|
|
309
|
+
}, _callee7);
|
|
310
|
+
}));
|
|
311
|
+
return function fetchHistory(_x5) {
|
|
312
|
+
return _ref3.apply(this, arguments);
|
|
313
|
+
};
|
|
314
|
+
}();
|
|
315
|
+
var fetchKeyDebounce = useCallback(debounce(fetchKey, debounceWait), []);
|
|
316
|
+
var fetchValueDebounce = useCallback(debounce(fetchValue, debounceWait), []);
|
|
317
|
+
var fetchHistoryDebounce = useCallback(debounce(fetchHistory, debounceWait), []);
|
|
222
318
|
useEffect(function () {
|
|
223
|
-
var fetchValue = /*#__PURE__*/function () {
|
|
224
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
225
|
-
var res;
|
|
226
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
227
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
228
|
-
case 0:
|
|
229
|
-
setKeyLoading(true);
|
|
230
|
-
_context5.next = 3;
|
|
231
|
-
return keyOption === null || keyOption === void 0 ? void 0 : keyOption.fetchFuc(keyOptionValue);
|
|
232
|
-
case 3:
|
|
233
|
-
_context5.t0 = _context5.sent;
|
|
234
|
-
if (_context5.t0) {
|
|
235
|
-
_context5.next = 6;
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
_context5.t0 = [];
|
|
239
|
-
case 6:
|
|
240
|
-
res = _context5.t0;
|
|
241
|
-
setKeyList(res);
|
|
242
|
-
setKeyLoading(false);
|
|
243
|
-
case 9:
|
|
244
|
-
case "end":
|
|
245
|
-
return _context5.stop();
|
|
246
|
-
}
|
|
247
|
-
}, _callee5);
|
|
248
|
-
}));
|
|
249
|
-
return function fetchValue() {
|
|
250
|
-
return _ref.apply(this, arguments);
|
|
251
|
-
};
|
|
252
|
-
}();
|
|
253
319
|
if (visible && judgeNotEmpty(keyOptionValue)) {
|
|
254
|
-
|
|
320
|
+
fetchKeyDebounce(keyOptionValue);
|
|
255
321
|
}
|
|
256
322
|
}, [visible, keyOptionValue]);
|
|
257
|
-
|
|
258
323
|
// value
|
|
259
324
|
useEffect(function () {
|
|
260
|
-
var fetchValue = /*#__PURE__*/function () {
|
|
261
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
262
|
-
var res;
|
|
263
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
264
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
265
|
-
case 0:
|
|
266
|
-
setValueLoading(true);
|
|
267
|
-
_context6.next = 3;
|
|
268
|
-
return valueOption === null || valueOption === void 0 ? void 0 : valueOption.fetchFuc(valueOptionValue);
|
|
269
|
-
case 3:
|
|
270
|
-
_context6.t0 = _context6.sent;
|
|
271
|
-
if (_context6.t0) {
|
|
272
|
-
_context6.next = 6;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
_context6.t0 = [];
|
|
276
|
-
case 6:
|
|
277
|
-
res = _context6.t0;
|
|
278
|
-
setValueList(res);
|
|
279
|
-
setValueLoading(false);
|
|
280
|
-
case 9:
|
|
281
|
-
case "end":
|
|
282
|
-
return _context6.stop();
|
|
283
|
-
}
|
|
284
|
-
}, _callee6);
|
|
285
|
-
}));
|
|
286
|
-
return function fetchValue() {
|
|
287
|
-
return _ref2.apply(this, arguments);
|
|
288
|
-
};
|
|
289
|
-
}();
|
|
290
325
|
if (visible && judgeNotEmpty(valueOptionValue)) {
|
|
291
|
-
|
|
326
|
+
fetchValueDebounce(valueOptionValue);
|
|
292
327
|
}
|
|
293
328
|
}, [visible, valueOptionValue]);
|
|
294
329
|
|
|
295
330
|
// history
|
|
296
331
|
useEffect(function () {
|
|
297
|
-
var fetchValue = /*#__PURE__*/function () {
|
|
298
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
299
|
-
var res;
|
|
300
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
301
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
302
|
-
case 0:
|
|
303
|
-
setHistoryLoading(true);
|
|
304
|
-
_context7.next = 3;
|
|
305
|
-
return historyOption === null || historyOption === void 0 ? void 0 : historyOption.fetchFuc(historyOptionValue);
|
|
306
|
-
case 3:
|
|
307
|
-
_context7.t0 = _context7.sent;
|
|
308
|
-
if (_context7.t0) {
|
|
309
|
-
_context7.next = 6;
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
_context7.t0 = [];
|
|
313
|
-
case 6:
|
|
314
|
-
res = _context7.t0;
|
|
315
|
-
setHistoryList(res);
|
|
316
|
-
setHistoryLoading(false);
|
|
317
|
-
case 9:
|
|
318
|
-
case "end":
|
|
319
|
-
return _context7.stop();
|
|
320
|
-
}
|
|
321
|
-
}, _callee7);
|
|
322
|
-
}));
|
|
323
|
-
return function fetchValue() {
|
|
324
|
-
return _ref3.apply(this, arguments);
|
|
325
|
-
};
|
|
326
|
-
}();
|
|
327
332
|
if (visible && judgeNotEmpty(historyOptionValue)) {
|
|
328
|
-
|
|
333
|
+
fetchHistoryDebounce(historyOptionValue);
|
|
329
334
|
}
|
|
330
335
|
}, [visible, historyOptionValue]);
|
|
331
336
|
|
|
@@ -356,7 +361,7 @@ var DropDown = function DropDown(props) {
|
|
|
356
361
|
}, [historyList]);
|
|
357
362
|
|
|
358
363
|
// 搜索历史列表删除
|
|
359
|
-
function historyDelete(
|
|
364
|
+
function historyDelete(_x6, _x7) {
|
|
360
365
|
return _historyDelete.apply(this, arguments);
|
|
361
366
|
}
|
|
362
367
|
function _historyDelete() {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _Tooltip from "@chaoswise/ui/lib/Tooltip";
|
|
2
|
-
import React from
|
|
3
|
-
import textIcon from
|
|
4
|
-
import tagIcon from
|
|
5
|
-
import { useIntl } from
|
|
6
|
-
import
|
|
2
|
+
import React from "react";
|
|
3
|
+
import textIcon from "./assets/text-icon.svg";
|
|
4
|
+
import tagIcon from "./assets/tag-icon.svg";
|
|
5
|
+
import { useIntl } from "../../../locales";
|
|
6
|
+
import "./index.less";
|
|
7
7
|
var SwitchBtn = function SwitchBtn(_ref) {
|
|
8
8
|
var mode = _ref.mode,
|
|
9
9
|
onChange = _ref.onChange;
|
|
10
10
|
var intl = useIntl();
|
|
11
|
-
var icon = mode ===
|
|
12
|
-
var title = mode ===
|
|
11
|
+
var icon = mode === "text" ? textIcon : tagIcon;
|
|
12
|
+
var title = mode === "text" ? intl.get("1e9cc6b2-f761-4aaa-a216-9f842c6f8fce").d("切换为筛选模式") : intl.get("5faa90fc-6455-499a-a0d5-c7ff9c9867df").d("切换为手写CQL语法模式");
|
|
13
13
|
var onClick = function onClick() {
|
|
14
|
-
onChange(mode ===
|
|
14
|
+
onChange(mode === "text" ? "tag" : "text");
|
|
15
15
|
};
|
|
16
16
|
return /*#__PURE__*/React.createElement(_Tooltip, {
|
|
17
17
|
title: title
|
|
@@ -13,7 +13,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
13
13
|
import React, { useRef, useEffect, useState } from "react";
|
|
14
14
|
import { getCursorPosition, getCursorNodeAndIndex, setCursorPosition, isObjectEqual } from "../utils";
|
|
15
15
|
var MATCH_LIST = [">=", "<=", ">", "<", ":"];
|
|
16
|
-
var useDropDown = function useDropDown(container, handleValueChange) {
|
|
16
|
+
var useDropDown = function useDropDown(container, handleValueChange, onChange) {
|
|
17
17
|
// 记录上一次的tag光标所处的type和value
|
|
18
18
|
var preTagInfo = useRef({});
|
|
19
19
|
|
|
@@ -149,6 +149,7 @@ var useDropDown = function useDropDown(container, handleValueChange) {
|
|
|
149
149
|
// 插入字符串下标位置内容
|
|
150
150
|
if (currentPositionIndex.current !== null) {
|
|
151
151
|
handleValueChange(newStr);
|
|
152
|
+
onChange(newStr);
|
|
152
153
|
// 光标移动到插入字符串后面
|
|
153
154
|
var _getCursorNodeAndInde2 = getCursorNodeAndIndex(container.current, newIndex),
|
|
154
155
|
targetNode = _getCursorNodeAndInde2.targetNode,
|
|
@@ -214,6 +215,7 @@ var useDropDown = function useDropDown(container, handleValueChange) {
|
|
|
214
215
|
};
|
|
215
216
|
var onHistorySelect = function onHistorySelect(value) {
|
|
216
217
|
handleValueChange(value);
|
|
218
|
+
onChange(value);
|
|
217
219
|
// 光标移动到插入字符串后面
|
|
218
220
|
var _getCursorNodeAndInde3 = getCursorNodeAndIndex(container.current, value.length),
|
|
219
221
|
targetNode = _getCursorNodeAndInde3.targetNode,
|
|
@@ -79,7 +79,9 @@ var AggregateSearch = function AggregateSearch(props) {
|
|
|
79
79
|
placeholder = props.placeholder,
|
|
80
80
|
className = props.className,
|
|
81
81
|
_props$style = props.style,
|
|
82
|
-
style = _props$style === void 0 ? {} : _props$style
|
|
82
|
+
style = _props$style === void 0 ? {} : _props$style,
|
|
83
|
+
_props$debounceWait = props.debounceWait,
|
|
84
|
+
debounceWait = _props$debounceWait === void 0 ? 300 : _props$debounceWait;
|
|
83
85
|
// 输入模式
|
|
84
86
|
var _useState = useState(defaultMode),
|
|
85
87
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -207,7 +209,7 @@ var AggregateSearch = function AggregateSearch(props) {
|
|
|
207
209
|
return _ref6.apply(this, arguments);
|
|
208
210
|
};
|
|
209
211
|
}();
|
|
210
|
-
var _useDropDown = useDropDown(container, handleValueChange),
|
|
212
|
+
var _useDropDown = useDropDown(container, handleValueChange, onChange),
|
|
211
213
|
dropStatus = _useDropDown.dropStatus,
|
|
212
214
|
visible = _useDropDown.visible,
|
|
213
215
|
quickSelect = _useDropDown.quickSelect,
|
|
@@ -341,7 +343,8 @@ var AggregateSearch = function AggregateSearch(props) {
|
|
|
341
343
|
quickSelect(value, "combined");
|
|
342
344
|
}
|
|
343
345
|
},
|
|
344
|
-
containerWrapperRef: containerWrapperRef
|
|
346
|
+
containerWrapperRef: containerWrapperRef,
|
|
347
|
+
debounceWait: debounceWait
|
|
345
348
|
}, /*#__PURE__*/React.createElement("div", {
|
|
346
349
|
className: classnames("aggregate-search-wrapper", className, {
|
|
347
350
|
"aggregate-search-text-wrapper": curMode === "text"
|
|
@@ -426,6 +429,10 @@ AggregateSearch.propTypes = {
|
|
|
426
429
|
/**
|
|
427
430
|
* 用于设置容器外壳的样式
|
|
428
431
|
*/
|
|
429
|
-
style: PropTypes.object
|
|
432
|
+
style: PropTypes.object,
|
|
433
|
+
/**
|
|
434
|
+
* 防抖时间默认为300ms
|
|
435
|
+
*/
|
|
436
|
+
debounceWait: PropTypes.number
|
|
430
437
|
};
|
|
431
438
|
export default AggregateSearch;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chaoswise/business",
|
|
3
3
|
"packageName": "chaoswiseBusiness",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"description": "业务组件库",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ui",
|
|
@@ -111,5 +111,6 @@
|
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public"
|
|
113
113
|
},
|
|
114
|
-
"license": "MIT"
|
|
114
|
+
"license": "MIT",
|
|
115
|
+
"gitHead": "3afd9f5a5ef3366719650108213fc011128ce303"
|
|
115
116
|
}
|