@panpanzhao/component-ui 0.0.8 → 0.0.10

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.
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 72);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 73);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -94,18 +94,19 @@ module.exports = require("@vue/babel-helper-vue-jsx-merge-props");
94
94
 
95
95
  /***/ }),
96
96
 
97
- /***/ 19:
97
+ /***/ 20:
98
98
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
99
99
 
100
100
  "use strict";
101
101
 
102
102
  // EXPORTS
103
- __webpack_require__.d(__webpack_exports__, "d", function() { return /* reexport */ uuid; });
104
- __webpack_require__.d(__webpack_exports__, "a", function() { return /* reexport */ findTree; });
105
- __webpack_require__.d(__webpack_exports__, "b", function() { return /* reexport */ findTreeIndex; });
106
- __webpack_require__.d(__webpack_exports__, "c", function() { return /* reexport */ spliceTreeSelf; });
103
+ __webpack_require__.d(__webpack_exports__, "e", function() { return /* reexport */ uuid; });
104
+ __webpack_require__.d(__webpack_exports__, "a", function() { return /* reexport */ eachTree; });
105
+ __webpack_require__.d(__webpack_exports__, "b", function() { return /* reexport */ findTree; });
106
+ __webpack_require__.d(__webpack_exports__, "c", function() { return /* reexport */ findTreeIndex; });
107
+ __webpack_require__.d(__webpack_exports__, "d", function() { return /* reexport */ spliceTreeSelf; });
107
108
 
108
- // UNUSED EXPORTS: mapTree, eachTree, getTree, filterTree, everyTree, someTree, spliceTree, getTreeDepth, getTreeAncestors, getTreeParent
109
+ // UNUSED EXPORTS: mapTree, getTree, filterTree, everyTree, someTree, spliceTree, getTreeDepth, getTreeAncestors, getTreeParent
109
110
 
110
111
  // CONCATENATED MODULE: ./src/utils/helper.js
111
112
  // 参考 https://github.com/streamich/v4-uuid
@@ -441,77 +442,77 @@ function spliceTreeSelf(tree, idx, deleteCount) {
441
442
 
442
443
  /***/ }),
443
444
 
444
- /***/ 20:
445
+ /***/ 22:
445
446
  /***/ (function(module, exports) {
446
447
 
447
448
  module.exports = require("element-ui/lib/input");
448
449
 
449
450
  /***/ }),
450
451
 
451
- /***/ 29:
452
+ /***/ 3:
452
453
  /***/ (function(module, exports) {
453
454
 
454
- module.exports = require("codemirror");
455
+ module.exports = require("@panpanzhao/component-ui/lib/utils/formula");
455
456
 
456
457
  /***/ }),
457
458
 
458
- /***/ 5:
459
+ /***/ 33:
459
460
  /***/ (function(module, exports) {
460
461
 
461
- module.exports = require("element-ui/lib/tabs");
462
+ module.exports = require("codemirror");
462
463
 
463
464
  /***/ }),
464
465
 
465
- /***/ 59:
466
+ /***/ 6:
466
467
  /***/ (function(module, exports) {
467
468
 
468
- module.exports = require("element-ui/lib/tree");
469
+ module.exports = require("element-ui/lib/tabs");
469
470
 
470
471
  /***/ }),
471
472
 
472
- /***/ 6:
473
+ /***/ 62:
473
474
  /***/ (function(module, exports) {
474
475
 
475
- module.exports = require("element-ui/lib/tab-pane");
476
+ module.exports = require("element-ui/lib/tree");
476
477
 
477
478
  /***/ }),
478
479
 
479
- /***/ 60:
480
+ /***/ 63:
480
481
  /***/ (function(module, exports) {
481
482
 
482
483
  module.exports = require("element-ui/lib/badge");
483
484
 
484
485
  /***/ }),
485
486
 
486
- /***/ 61:
487
+ /***/ 64:
487
488
  /***/ (function(module, exports) {
488
489
 
489
490
  module.exports = require("element-ui/lib/message");
490
491
 
491
492
  /***/ }),
492
493
 
493
- /***/ 65:
494
+ /***/ 66:
494
495
  /***/ (function(module, exports) {
495
496
 
496
497
  module.exports = require("codemirror/mode/javascript/javascript");
497
498
 
498
499
  /***/ }),
499
500
 
500
- /***/ 66:
501
+ /***/ 67:
501
502
  /***/ (function(module, exports) {
502
503
 
503
504
  module.exports = require("codemirror/mode/htmlmixed/htmlmixed");
504
505
 
505
506
  /***/ }),
506
507
 
507
- /***/ 67:
508
+ /***/ 68:
508
509
  /***/ (function(module, exports) {
509
510
 
510
511
  module.exports = require("codemirror/addon/mode/simple");
511
512
 
512
513
  /***/ }),
513
514
 
514
- /***/ 68:
515
+ /***/ 69:
515
516
  /***/ (function(module, exports) {
516
517
 
517
518
  module.exports = require("codemirror/addon/mode/multiplex");
@@ -521,11 +522,11 @@ module.exports = require("codemirror/addon/mode/multiplex");
521
522
  /***/ 7:
522
523
  /***/ (function(module, exports) {
523
524
 
524
- module.exports = require("element-ui/lib/collapse");
525
+ module.exports = require("element-ui/lib/tab-pane");
525
526
 
526
527
  /***/ }),
527
528
 
528
- /***/ 72:
529
+ /***/ 73:
529
530
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
530
531
 
531
532
  "use strict";
@@ -537,20 +538,20 @@ var babel_helper_vue_jsx_merge_props_ = __webpack_require__(0);
537
538
  var babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(babel_helper_vue_jsx_merge_props_);
538
539
 
539
540
  // EXTERNAL MODULE: external "codemirror"
540
- var external_codemirror_ = __webpack_require__(29);
541
+ var external_codemirror_ = __webpack_require__(33);
541
542
  var external_codemirror_default = /*#__PURE__*/__webpack_require__.n(external_codemirror_);
542
543
 
543
544
  // EXTERNAL MODULE: external "codemirror/mode/javascript/javascript"
544
- var javascript_ = __webpack_require__(65);
545
+ var javascript_ = __webpack_require__(66);
545
546
 
546
547
  // EXTERNAL MODULE: external "codemirror/mode/htmlmixed/htmlmixed"
547
- var htmlmixed_ = __webpack_require__(66);
548
+ var htmlmixed_ = __webpack_require__(67);
548
549
 
549
550
  // EXTERNAL MODULE: external "codemirror/addon/mode/simple"
550
- var simple_ = __webpack_require__(67);
551
+ var simple_ = __webpack_require__(68);
551
552
 
552
553
  // EXTERNAL MODULE: external "codemirror/addon/mode/multiplex"
553
- var multiplex_ = __webpack_require__(68);
554
+ var multiplex_ = __webpack_require__(69);
554
555
 
555
556
  // CONCATENATED MODULE: ./src/components/formula/src/codeMirror.js
556
557
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
@@ -627,9 +628,9 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
627
628
  methods: {
628
629
  setValue: function setValue(value) {
629
630
  var doc = this.editor.getDoc();
630
- if (value && value !== doc.getValue()) {
631
+ if (value !== doc.getValue()) {
631
632
  var cursor = doc.getCursor();
632
- doc.setValue(value);
633
+ doc.setValue(value || "");
633
634
  doc.setCursor(cursor);
634
635
  }
635
636
  },
@@ -651,15 +652,15 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
651
652
  }
652
653
  });
653
654
  // EXTERNAL MODULE: external "element-ui/lib/input"
654
- var input_ = __webpack_require__(20);
655
+ var input_ = __webpack_require__(22);
655
656
  var input_default = /*#__PURE__*/__webpack_require__.n(input_);
656
657
 
657
658
  // EXTERNAL MODULE: external "element-ui/lib/collapse"
658
- var collapse_ = __webpack_require__(7);
659
+ var collapse_ = __webpack_require__(8);
659
660
  var collapse_default = /*#__PURE__*/__webpack_require__.n(collapse_);
660
661
 
661
662
  // EXTERNAL MODULE: external "element-ui/lib/collapse-item"
662
- var collapse_item_ = __webpack_require__(8);
663
+ var collapse_item_ = __webpack_require__(9);
663
664
  var collapse_item_default = /*#__PURE__*/__webpack_require__.n(collapse_item_);
664
665
 
665
666
  // CONCATENATED MODULE: ./src/components/formula/src/funcList.js
@@ -781,23 +782,23 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
781
782
  }
782
783
  });
783
784
  // EXTERNAL MODULE: external "element-ui/lib/tabs"
784
- var tabs_ = __webpack_require__(5);
785
+ var tabs_ = __webpack_require__(6);
785
786
  var tabs_default = /*#__PURE__*/__webpack_require__.n(tabs_);
786
787
 
787
788
  // EXTERNAL MODULE: external "element-ui/lib/tab-pane"
788
- var tab_pane_ = __webpack_require__(6);
789
+ var tab_pane_ = __webpack_require__(7);
789
790
  var tab_pane_default = /*#__PURE__*/__webpack_require__.n(tab_pane_);
790
791
 
791
792
  // EXTERNAL MODULE: external "element-ui/lib/tree"
792
- var tree_ = __webpack_require__(59);
793
+ var tree_ = __webpack_require__(62);
793
794
  var tree_default = /*#__PURE__*/__webpack_require__.n(tree_);
794
795
 
795
796
  // EXTERNAL MODULE: external "element-ui/lib/badge"
796
- var badge_ = __webpack_require__(60);
797
+ var badge_ = __webpack_require__(63);
797
798
  var badge_default = /*#__PURE__*/__webpack_require__.n(badge_);
798
799
 
799
800
  // EXTERNAL MODULE: ./src/utils/index.js + 2 modules
800
- var utils = __webpack_require__(19);
801
+ var utils = __webpack_require__(20);
801
802
 
802
803
  // CONCATENATED MODULE: ./src/components/formula/src/variableList.js
803
804
 
@@ -836,13 +837,19 @@ var utils = __webpack_require__(19);
836
837
  filterVars: []
837
838
  };
838
839
  },
840
+ watch: {
841
+ data: function data(value) {
842
+ this.searchVal = null;
843
+ this.filterVars = value;
844
+ }
845
+ },
839
846
  created: function created() {
840
847
  this.filterVars = this.data || [];
841
848
  },
842
849
  methods: {
843
850
  handleSearch: function handleSearch(val) {
844
851
  this.searchVal = val;
845
- var filtered = Object(utils["a" /* findTree */])(this.data, function (i) {
852
+ var filtered = Object(utils["b" /* findTree */])(this.data, function (i) {
846
853
  return ~i.label.indexOf(val);
847
854
  });
848
855
  this.filterVars = !val ? this.data : filtered ? [filtered] : [];
@@ -884,7 +891,7 @@ var utils = __webpack_require__(19);
884
891
  "attrs": {
885
892
  "value": "self"
886
893
  }
887
- }, [h("label", [data.label])]), data.label && (!this.selfVariableName || data.value !== this.selfVariableName) && h("label", [data.label]), data.tag ? h("span", {
894
+ }, [h("label", [data.label])]), data.label && (!this.selfVariableName || data.value !== this.selfVariableName) && h("label", [data.label]), data.label && data.tag ? h("span", {
888
895
  "class": this.classPrefix + "-item-tag"
889
896
  }, [data.tag]) : null]);
890
897
  },
@@ -985,30 +992,10 @@ var utils = __webpack_require__(19);
985
992
  }
986
993
  });
987
994
  // CONCATENATED MODULE: ./src/components/formula/src/plugin.js
988
- /**
989
- * @file 扩展 codemirror
990
- */
991
995
 
992
996
  /**
993
- * 遍历树
994
- * @param tree
995
- * @param iterator
997
+ * @file 扩展 codemirror
996
998
  */
997
- function eachTree(tree, iterator, level, paths) {
998
- if (level === void 0) {
999
- level = 1;
1000
- }
1001
- if (paths === void 0) {
1002
- paths = [];
1003
- }
1004
- tree.map(function (item, index) {
1005
- var currentPath = paths.concat(item);
1006
- iterator(item, index, level, currentPath);
1007
- if (item.children && item.children.splice) {
1008
- eachTree(item.children, iterator, level + 1, currentPath);
1009
- }
1010
- });
1011
- }
1012
999
  function replaceStrByIndex(str, idx, key, replaceKey) {
1013
1000
  var from = str.slice(0, idx);
1014
1001
  var left = str.slice(idx);
@@ -1026,20 +1013,29 @@ function plugin_editorFactory(dom, cm, props) {
1026
1013
  mode: props && props.evalMode ? 'text/formula' : 'text/formula-template'
1027
1014
  });
1028
1015
  }
1029
- var FormulaPlugin = /*#__PURE__*/function () {
1016
+ var plugin_FormulaPlugin = /*#__PURE__*/function () {
1030
1017
  function FormulaPlugin(editor, cm, getProps) {
1018
+ var _this = this;
1031
1019
  this.editor = editor;
1032
1020
  this.cm = cm;
1033
1021
  this.getProps = getProps;
1034
- // editor.on('change', this.autoMarkText);
1022
+ editor.on('change', function (editorDom) {
1023
+ //处理第一次初始化
1024
+ var val = editorDom.getDoc().getValue();
1025
+ var _this$getProps = _this.getProps(),
1026
+ value = _this$getProps.value;
1027
+ if (val == value) {
1028
+ _this.autoMarkText();
1029
+ }
1030
+ });
1035
1031
  this.autoMarkText();
1036
1032
  }
1037
1033
  var _proto = FormulaPlugin.prototype;
1038
1034
  _proto.autoMarkText = function autoMarkText() {
1039
- var _this$getProps = this.getProps(),
1040
- functions = _this$getProps.functions,
1041
- variables = _this$getProps.variables,
1042
- value = _this$getProps.value;
1035
+ var _this$getProps2 = this.getProps(),
1036
+ functions = _this$getProps2.functions,
1037
+ variables = _this$getProps2.variables,
1038
+ value = _this$getProps2.value;
1043
1039
  if (value) {
1044
1040
  // todo functions 也需要自动替换
1045
1041
  this.autoMark(variables);
@@ -1109,8 +1105,8 @@ var FormulaPlugin = /*#__PURE__*/function () {
1109
1105
  };
1110
1106
  _proto.insertContent = function insertContent(value, type) {
1111
1107
  var from = this.editor.getCursor();
1112
- var _this$getProps2 = this.getProps(),
1113
- evalMode = _this$getProps2.evalMode;
1108
+ var _this$getProps3 = this.getProps(),
1109
+ evalMode = _this$getProps3.evalMode;
1114
1110
  if (type === 'variable') {
1115
1111
  this.editor.replaceSelection(value.key);
1116
1112
  var to = this.editor.getCursor();
@@ -1152,12 +1148,12 @@ var FormulaPlugin = /*#__PURE__*/function () {
1152
1148
  });
1153
1149
  };
1154
1150
  _proto.autoMark = function autoMark(variables) {
1155
- var _this = this;
1151
+ var _this2 = this;
1156
1152
  if (!Array.isArray(variables) || !variables.length) {
1157
1153
  return;
1158
1154
  }
1159
1155
  var varMap = {};
1160
- eachTree(variables, function (item) {
1156
+ Object(utils["a" /* eachTree */])(variables, function (item) {
1161
1157
  if (item.value) {
1162
1158
  varMap[item.value] = item.label;
1163
1159
  }
@@ -1167,14 +1163,14 @@ var FormulaPlugin = /*#__PURE__*/function () {
1167
1163
  });
1168
1164
  var editor = this.editor;
1169
1165
  var lines = editor.lineCount();
1170
- var _this$getProps3 = this.getProps(),
1171
- _this$getProps3$evalM = _this$getProps3.evalMode,
1172
- evalMode = _this$getProps3$evalM === void 0 ? true : _this$getProps3$evalM;
1166
+ var _this$getProps4 = this.getProps(),
1167
+ _this$getProps4$evalM = _this$getProps4.evalMode,
1168
+ evalMode = _this$getProps4$evalM === void 0 ? true : _this$getProps4$evalM;
1173
1169
  var _loop = function _loop(line) {
1174
1170
  var content = editor.getLine(line);
1175
1171
  // 标记方法调用
1176
1172
  content.replace(/([A-Z]+)\s*\(/g, function (_, func, pos) {
1177
- _this.markText({
1173
+ _this2.markText({
1178
1174
  line: line,
1179
1175
  ch: pos
1180
1176
  }, {
@@ -1192,7 +1188,7 @@ var FormulaPlugin = /*#__PURE__*/function () {
1192
1188
  var encode = replaceStrByIndex(content, idx, v, REPLACE_KEY);
1193
1189
  var reg = getRegExpByMode(evalMode, REPLACE_KEY);
1194
1190
  if (reg.test(encode)) {
1195
- _this.markText({
1191
+ _this2.markText({
1196
1192
  line: line,
1197
1193
  ch: idx
1198
1194
  }, {
@@ -1230,7 +1226,6 @@ function registerLaunguageMode(cm) {
1230
1226
  cm.defineMode('formula', function (config, parserConfig) {
1231
1227
  var formula = cm.getMode(config, 'javascript');
1232
1228
  if (!parserConfig || !parserConfig.base) return formula;
1233
- debugger;
1234
1229
  return cm.multiplexingMode(cm.getMode(config, parserConfig.base), {
1235
1230
  open: '${',
1236
1231
  close: '}',
@@ -2789,9 +2784,12 @@ function registerLaunguageMode(cm) {
2789
2784
  namespace: "其他"
2790
2785
  }]);
2791
2786
  // EXTERNAL MODULE: external "element-ui/lib/message"
2792
- var message_ = __webpack_require__(61);
2787
+ var message_ = __webpack_require__(64);
2793
2788
  var message_default = /*#__PURE__*/__webpack_require__.n(message_);
2794
2789
 
2790
+ // EXTERNAL MODULE: external "@panpanzhao/component-ui/lib/utils/formula"
2791
+ var formula_ = __webpack_require__(3);
2792
+
2795
2793
  // CONCATENATED MODULE: ./src/components/formula/src/index.js
2796
2794
 
2797
2795
 
@@ -2802,6 +2800,8 @@ var message_default = /*#__PURE__*/__webpack_require__.n(message_);
2802
2800
 
2803
2801
 
2804
2802
 
2803
+
2804
+
2805
2805
  /* harmony default export */ var src = ({
2806
2806
  name: "Formula",
2807
2807
  componentName: "Formula",
@@ -2867,7 +2867,7 @@ var message_default = /*#__PURE__*/__webpack_require__.n(message_);
2867
2867
  },
2868
2868
  handleEditorMounted: function handleEditorMounted(cm, editor) {
2869
2869
  var _this = this;
2870
- this.editorPlugin = new FormulaPlugin(editor, cm, function () {
2870
+ this.editorPlugin = new plugin_FormulaPlugin(editor, cm, function () {
2871
2871
  return _this.$props;
2872
2872
  });
2873
2873
  },
@@ -2901,6 +2901,7 @@ var message_default = /*#__PURE__*/__webpack_require__.n(message_);
2901
2901
  }, 'variable');
2902
2902
  },
2903
2903
  handleChange: function handleChange(value) {
2904
+ this.$emit("input", value);
2904
2905
  this.$emit("change", value);
2905
2906
  },
2906
2907
  handleFocus: function handleFocus() {
@@ -2914,6 +2915,74 @@ var message_default = /*#__PURE__*/__webpack_require__.n(message_);
2914
2915
  value: "name",
2915
2916
  label: "名称"
2916
2917
  });
2918
+ },
2919
+ validate: function validate() {
2920
+ var value = this.value;
2921
+ try {
2922
+ value ? Object(formula_["parse"])(value, {
2923
+ evalMode: this.evalMode
2924
+ }) : null;
2925
+ } catch (e) {
2926
+ return "\u516C\u5F0F\u503C\u6821\u9A8C\u9519\u8BEF\uFF0C\u9519\u8BEF\u7684\u4F4D\u7F6E/\u539F\u56E0\u662F " + e.message;
2927
+ }
2928
+ return;
2929
+ },
2930
+ replaceStrByIndex: function replaceStrByIndex(str, idx, key, replaceKey) {
2931
+ var from = str.slice(0, idx);
2932
+ var left = str.slice(idx);
2933
+ return from + left.replace(key, replaceKey);
2934
+ },
2935
+ getRegExpByMode: function getRegExpByMode(evalMode, key) {
2936
+ var reg = evalMode ? "\\b" + key + "\\b" : "\\$\\{[^\\{\\}]*\\b" + key + "\\b[^\\{\\}]*\\}";
2937
+ return new RegExp(reg);
2938
+ },
2939
+ highlightValue: function highlightValue(value, variables, evalMode) {
2940
+ var _this2 = this;
2941
+ if (evalMode === void 0) {
2942
+ evalMode = true;
2943
+ }
2944
+ if (!Array.isArray(variables) || !variables.length || !value) {
2945
+ return;
2946
+ }
2947
+ var varMap = {};
2948
+ Object(utils["a" /* eachTree */])(variables, function (item) {
2949
+ if (item.value) {
2950
+ var key = item.value;
2951
+ varMap[key] = item.label;
2952
+ }
2953
+ });
2954
+ var vars = Object.keys(varMap).filter(function (item) {
2955
+ return item;
2956
+ }).sort(function (a, b) {
2957
+ return b.length - a.length;
2958
+ });
2959
+ var content = value || '';
2960
+ var html = '';
2961
+
2962
+ // 标记方法调用
2963
+ html = content.replace(/([A-Z]+)\s*\(/g, function (_, func, pos) {
2964
+ return _ && _.replace(func, "<span class=\"c-func\">" + func + "</span>");
2965
+ });
2966
+ var REPLACE_KEY = 'AMIS_FORMULA_REPLACE_KEY';
2967
+ vars.forEach(function (v) {
2968
+ var from = 0;
2969
+ var idx = -1;
2970
+ while (~(idx = content.indexOf(v, from))) {
2971
+ var encodeHtml = _this2.replaceStrByIndex(html, idx, v, REPLACE_KEY);
2972
+ var reg = _this2.getRegExpByMode(evalMode, REPLACE_KEY);
2973
+
2974
+ // 如果匹配到则高亮,没有匹配到替换成原值
2975
+ if (reg.test(encodeHtml)) {
2976
+ html = encodeHtml.replace(REPLACE_KEY, "<span class=\"c-field\">" + varMap[v] + "</span>");
2977
+ } else {
2978
+ html = encodeHtml.replace(REPLACE_KEY, v);
2979
+ }
2980
+ from = idx + v.length;
2981
+ }
2982
+ });
2983
+ return {
2984
+ html: html
2985
+ };
2917
2986
  }
2918
2987
  },
2919
2988
  beforeDestroy: function beforeDestroy() {
@@ -2988,6 +3057,13 @@ src.install = function (Vue) {
2988
3057
  /***/ 8:
2989
3058
  /***/ (function(module, exports) {
2990
3059
 
3060
+ module.exports = require("element-ui/lib/collapse");
3061
+
3062
+ /***/ }),
3063
+
3064
+ /***/ 9:
3065
+ /***/ (function(module, exports) {
3066
+
2991
3067
  module.exports = require("element-ui/lib/collapse-item");
2992
3068
 
2993
3069
  /***/ })