@blueking/bkui-form 0.0.42 → 0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/adapter/vue2/common/FieldGroupWrap.d.ts +4 -3
  2. package/dist/adapter/vue2/field/ArrayField.d.ts +3 -3
  3. package/dist/adapter/vue2/field/BooleanField.d.ts +3 -3
  4. package/dist/adapter/vue2/field/CompositionField.d.ts +3 -3
  5. package/dist/adapter/vue2/field/NumberField.d.ts +3 -3
  6. package/dist/adapter/vue2/field/ObjectField.d.ts +1 -1
  7. package/dist/adapter/vue2/field/SchemaField.d.ts +1 -1
  8. package/dist/adapter/vue2/field/StringField.d.ts +3 -3
  9. package/dist/adapter/vue2/widget/ArrayWidget.d.ts +1 -1
  10. package/dist/adapter/vue2/widget/ButtonWidget.d.ts +1 -1
  11. package/dist/adapter/vue2/widget/CheckboxWidget.d.ts +1 -1
  12. package/dist/adapter/vue2/widget/CollapseGroupWidget.d.ts +2 -1
  13. package/dist/adapter/vue2/widget/ColorPickerWidget.d.ts +1 -1
  14. package/dist/adapter/vue2/widget/InputWidget.d.ts +1 -1
  15. package/dist/adapter/vue2/widget/KeyValueArrayWidget.d.ts +3 -3
  16. package/dist/adapter/vue2/widget/RadioWidget.d.ts +1 -1
  17. package/dist/adapter/vue2/widget/SelectWidget.d.ts +1 -1
  18. package/dist/adapter/vue2/widget/SwitchWidget.d.ts +1 -1
  19. package/dist/adapter/vue2/widget/TabGroupWidget.d.ts +1 -1
  20. package/dist/adapter/vue2/widget/TableWidget.d.ts +3 -3
  21. package/dist/adapter/vue2/widget/UploadWidget.d.ts +14 -0
  22. package/dist/adapter/vue2/widget/Widget.d.ts +1 -1
  23. package/dist/bkui-form-es-min.js +3 -3
  24. package/dist/bkui-form-es.js +490 -262
  25. package/dist/bkui-form-es.js.map +1 -1
  26. package/dist/bkui-form-umd-min.js +3 -3
  27. package/dist/bkui-form-umd.js +490 -262
  28. package/dist/bkui-form-umd.js.map +1 -1
  29. package/dist/bkui-form.css +58 -3
  30. package/dist/controller/form-vue2.d.ts +9 -6
  31. package/dist/controller/props.d.ts +4 -0
  32. package/dist/core/expression.d.ts +3 -1
  33. package/dist/core/reaction.d.ts +2 -1
  34. package/dist/core/validator.d.ts +6 -5
  35. package/dist/core/widgetTree.d.ts +1 -2
  36. package/dist/types/bkui-form.d.ts +50 -8
  37. package/dist/util/index.d.ts +5 -1
  38. package/package.json +6 -6
@@ -642,16 +642,25 @@
642
642
  }
643
643
  if (!sources.length) return target;
644
644
  var source = sources.shift();
645
- if (isObj(target) && isObj(source)) {
646
- for (var key in source) {
647
- if (isObj(source[key])) {
648
- if (!target[key]) Object.assign(target, _defineProperty({}, key, {}));
649
- mergeDeep(target[key], source[key]);
650
- } else {
651
- Object.assign(target, _defineProperty({}, key, source[key]));
645
+ if (source === undefined) {
646
+ return target;
647
+ }
648
+ Object.entries(source).forEach(function (_ref) {
649
+ var _ref2 = _slicedToArray(_ref, 2),
650
+ key = _ref2[0],
651
+ value = _ref2[1];
652
+ var targetValue = target[key];
653
+ if (isObj(value)) {
654
+ if (!(key in target)) {
655
+ target[key] = {};
656
+ } else if (!isObj(targetValue)) {
657
+ target[key] = {};
652
658
  }
659
+ mergeDeep(target[key], value);
660
+ } else {
661
+ target[key] = value;
653
662
  }
654
- }
663
+ });
655
664
  return mergeDeep.apply(void 0, [target].concat(sources));
656
665
  }
657
666
  function isArguments(object) {
@@ -844,7 +853,6 @@
844
853
  key = _ref2[0],
845
854
  value = _ref2[1];
846
855
  if (_this[props].has(key)) {
847
- console.warn('repeat key', key);
848
856
  return;
849
857
  }
850
858
  _this[props].set(key, value);
@@ -1543,6 +1551,10 @@
1543
1551
  type: Boolean,
1544
1552
  default: false
1545
1553
  },
1554
+ disabled: {
1555
+ type: Boolean,
1556
+ default: false
1557
+ },
1546
1558
  readonlyMode: {
1547
1559
  type: String,
1548
1560
  default: 'value',
@@ -1669,7 +1681,6 @@
1669
1681
  }
1670
1682
  });
1671
1683
 
1672
- /* eslint-disable @typescript-eslint/no-unused-vars */
1673
1684
  // 组件对外暴露的上下文
1674
1685
  var getContext = function getContext(instance) {
1675
1686
  var context = instance.context,
@@ -1677,7 +1688,8 @@
1677
1688
  validate = instance.validate,
1678
1689
  schema = instance.schema,
1679
1690
  rootData = instance.rootData,
1680
- widgetNode = instance.widgetNode;
1691
+ widgetNode = instance.widgetNode,
1692
+ getValue = instance.getValue;
1681
1693
  return {
1682
1694
  $self: instance,
1683
1695
  $context: context,
@@ -1686,11 +1698,33 @@
1686
1698
  $loadDataSource: loadDataSource,
1687
1699
  $validate: validate,
1688
1700
  $rootData: rootData,
1689
- $widgetNode: widgetNode
1701
+ $widgetNode: widgetNode,
1702
+ $getValue: getValue,
1703
+ $getCookie: function $getCookie(name) {
1704
+ var cookies = document.cookie.split(';');
1705
+ var _iterator = _createForOfIteratorHelper(cookies),
1706
+ _step;
1707
+ try {
1708
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1709
+ var cookie = _step.value;
1710
+ var _cookie$trim$split = cookie.trim().split('='),
1711
+ _cookie$trim$split2 = _slicedToArray(_cookie$trim$split, 2),
1712
+ key = _cookie$trim$split2[0],
1713
+ value = _cookie$trim$split2[1];
1714
+ if (key === name) return decodeURIComponent(value);
1715
+ }
1716
+ } catch (err) {
1717
+ _iterator.e(err);
1718
+ } finally {
1719
+ _iterator.f();
1720
+ }
1721
+ return null;
1722
+ }
1690
1723
  };
1691
1724
  };
1692
1725
  var executeExpression = function executeExpression(expression, instance) {
1693
1726
  var $dep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
1727
+ var $args = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1694
1728
  var _getContext = getContext(instance),
1695
1729
  $self = _getContext.$self,
1696
1730
  $context = _getContext.$context,
@@ -1699,7 +1733,9 @@
1699
1733
  $loadDataSource = _getContext.$loadDataSource,
1700
1734
  $validate = _getContext.$validate,
1701
1735
  $rootData = _getContext.$rootData,
1702
- $widgetNode = _getContext.$widgetNode;
1736
+ $widgetNode = _getContext.$widgetNode,
1737
+ $getValue = _getContext.$getValue,
1738
+ $getCookie = _getContext.$getCookie;
1703
1739
  var context = {
1704
1740
  $self: $self,
1705
1741
  $context: $context,
@@ -1709,8 +1745,12 @@
1709
1745
  $validate: $validate,
1710
1746
  $rootData: $rootData,
1711
1747
  $widgetNode: $widgetNode,
1712
- $dep: $dep
1748
+ $dep: $dep,
1749
+ $getValue: $getValue,
1750
+ $getCookie: $getCookie,
1751
+ $args: $args
1713
1752
  };
1753
+ if (['boolean', 'number'].includes(_typeof(expression))) return expression;
1714
1754
  if (typeof expression === 'string') {
1715
1755
  if (!/^{{.+}}$/.test(expression.trim())) return expression; // 没有上下文时直接返回
1716
1756
  var expStr = expression.trim().replace(/(^{{)|(}}$)/g, '') // 去掉{{ }}
@@ -1726,6 +1766,9 @@
1726
1766
  _ref.$rootData;
1727
1767
  _ref.$widgetNode;
1728
1768
  _ref.$dep;
1769
+ _ref.$getValue;
1770
+ _ref.$getCookie;
1771
+ _ref.$args;
1729
1772
  try {
1730
1773
  // eslint-disable-next-line no-eval
1731
1774
  return innerFuncs.includes(expStr) ? eval("".concat(expStr, "()")) : eval(expStr);
@@ -1746,197 +1789,6 @@
1746
1789
  return typeof expression === 'string' && /{{.*}}/.test(expression);
1747
1790
  };
1748
1791
 
1749
- var WidgetNode = /*#__PURE__*/function () {
1750
- function WidgetNode(config) {
1751
- _classCallCheck(this, WidgetNode);
1752
- this.id = void 0;
1753
- this.instance = void 0;
1754
- this.parent = void 0;
1755
- this.type = void 0;
1756
- this.index = void 0;
1757
- // todo
1758
- this.children = void 0;
1759
- var id = config.id,
1760
- instance = config.instance,
1761
- parent = config.parent,
1762
- index = config.index,
1763
- type = config.type,
1764
- _config$children = config.children,
1765
- children = _config$children === void 0 ? [] : _config$children;
1766
- this.id = id;
1767
- this.type = type;
1768
- this.index = index;
1769
- this.instance = instance;
1770
- this.parent = parent;
1771
- this.children = children;
1772
- }
1773
- // 当前node的值
1774
- return _createClass(WidgetNode, [{
1775
- key: "value",
1776
- get: function get() {
1777
- var _this$instance;
1778
- return (_this$instance = this.instance) === null || _this$instance === void 0 ? void 0 : _this$instance.value;
1779
- }
1780
- // 是否含有可见子节点
1781
- }, {
1782
- key: "isChildrenVisible",
1783
- get: function get() {
1784
- if (this.type === 'node') {
1785
- var _this$instance2;
1786
- return (_this$instance2 = this.instance) === null || _this$instance2 === void 0 ? void 0 : _this$instance2.state.visible;
1787
- }
1788
- return this.children.some(function (child) {
1789
- return child.isChildrenVisible;
1790
- });
1791
- }
1792
- /**
1793
- * 获取 parents
1794
- */
1795
- }, {
1796
- key: "parents",
1797
- get: function get() {
1798
- if (!this.parent) {
1799
- return [];
1800
- }
1801
- return [].concat(_toConsumableArray(this.parent.parents), [this.parent]);
1802
- }
1803
- // 第一个子节点
1804
- }, {
1805
- key: "firstChild",
1806
- get: function get() {
1807
- return this.children[0] || null;
1808
- }
1809
- // 最后一个子节点
1810
- }, {
1811
- key: "lastChild",
1812
- get: function get() {
1813
- return this.children[this.children.length - 1] || null;
1814
- }
1815
- // 指定属性下的同胞节点
1816
- }, {
1817
- key: "getSibling",
1818
- value: function getSibling(lastProp) {
1819
- var _this$parent;
1820
- var reg = new RegExp("".concat(Path.getPathLastProp(this.id) || '', "$"));
1821
- var id = this.id.replace(reg, lastProp);
1822
- return (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.children.find(function (node) {
1823
- return node.id === id;
1824
- });
1825
- }
1826
- // 获取所以同胞节点(不含自己)
1827
- }, {
1828
- key: "getSiblings",
1829
- value: function getSiblings() {
1830
- var _this$parent2,
1831
- _this = this;
1832
- return ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.children.filter(function (node) {
1833
- return node.instance !== _this.instance;
1834
- })) || [];
1835
- }
1836
- /**
1837
- * 是否是叶子节点
1838
- */
1839
- }, {
1840
- key: "isLeaf",
1841
- get: function get() {
1842
- return !this.children.length;
1843
- }
1844
- }, {
1845
- key: "appendChild",
1846
- value: function appendChild(node) {
1847
- var _this$children;
1848
- var nodes = Array.isArray(node) ? node : [node];
1849
- var offset = node.index !== undefined ? node.index : this.children.length;
1850
- (_this$children = this.children).splice.apply(_this$children, [offset, 0].concat(_toConsumableArray(nodes)));
1851
- this.children.slice(offset).forEach(function (node, index) {
1852
- node.index = offset + index;
1853
- });
1854
- return nodes;
1855
- }
1856
- }, {
1857
- key: "removeChild",
1858
- value: function removeChild(node) {
1859
- var _this2 = this;
1860
- var nodes = Array.isArray(node) ? node : [node];
1861
- var removedChildIndex = [];
1862
- nodes.forEach(function (node) {
1863
- var index = node.index;
1864
- removedChildIndex.push(index);
1865
- _this2.children.splice(index, 1);
1866
- });
1867
- var minIndex = Math.min.apply(Math, removedChildIndex);
1868
- this.children.slice(minIndex).forEach(function (node, index) {
1869
- node.index = minIndex + index;
1870
- });
1871
- return nodes;
1872
- }
1873
- }]);
1874
- }();
1875
- var WidgetTree = /*#__PURE__*/function () {
1876
- function WidgetTree() {
1877
- _classCallCheck(this, WidgetTree);
1878
- this.widgetMap = {};
1879
- }
1880
- return _createClass(WidgetTree, [{
1881
- key: "addWidgetNode",
1882
- value: function addWidgetNode(path, instance, type, index) {
1883
- if (path === '') {
1884
- // 根节点
1885
- var node = new WidgetNode({
1886
- id: '',
1887
- type: type,
1888
- index: index,
1889
- parent: null,
1890
- instance: instance,
1891
- children: []
1892
- });
1893
- this.widgetMap[path] = node;
1894
- } else {
1895
- // 普通节点
1896
- var parentId = Path.getParentPath(path);
1897
- var parentNode = this.widgetMap[parentId];
1898
- var _node = new WidgetNode({
1899
- id: (instance === null || instance === void 0 ? void 0 : instance.path) || path,
1900
- type: type,
1901
- index: index,
1902
- parent: parentNode,
1903
- instance: instance,
1904
- children: []
1905
- });
1906
- if (!parentNode) {
1907
- console.warn('Unexpected parent id, please check widget node', _node);
1908
- } else {
1909
- parentNode.appendChild(_node);
1910
- }
1911
- this.widgetMap[path] = _node;
1912
- }
1913
- }
1914
- }, {
1915
- key: "removeWidgetNode",
1916
- value: function removeWidgetNode(path, instance) {
1917
- var node = this.widgetMap[path];
1918
- if (node) {
1919
- if (node.parent) {
1920
- var children = node.parent.children;
1921
- var index = children.findIndex(function (item) {
1922
- return item.instance === instance;
1923
- });
1924
- if (index > -1) {
1925
- children.splice(index, 1);
1926
- children.slice(index).forEach(function (node, i) {
1927
- node.index = index + i;
1928
- });
1929
- }
1930
- }
1931
- if (node.instance === instance) {
1932
- delete this.widgetMap[path];
1933
- }
1934
- }
1935
- }
1936
- }]);
1937
- }();
1938
- var widgetTree = new WidgetTree();
1939
-
1940
1792
  var reactionsMap = {};
1941
1793
  var subscribe = function subscribe(path, typeName, fn) {
1942
1794
  if (!reactionsMap[path]) {
@@ -1968,7 +1820,7 @@
1968
1820
  * @param reaction 传入的reacion配置
1969
1821
  * @returns viod
1970
1822
  */
1971
- var resolveReaction = function resolveReaction(crtInsPath, targetPath, reaction) {
1823
+ var resolveReaction = function resolveReaction(crtInsPath, targetPath, reaction, widgetTree) {
1972
1824
  return function () {
1973
1825
  var _ref = widgetTree.widgetMap[crtInsPath] || {},
1974
1826
  crtInstance = _ref.instance; // 当前组件实例,用来条件表达式判断
@@ -2013,6 +1865,7 @@
2013
1865
  };
2014
1866
  var reactionRegister = function reactionRegister(path) {
2015
1867
  var reactions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1868
+ var widgetTree = arguments.length > 2 ? arguments[2] : undefined;
2016
1869
  var _ref3 = widgetTree.widgetMap[path] || {},
2017
1870
  instance = _ref3.instance;
2018
1871
  if (reactions && Array.isArray(reactions)) {
@@ -2024,13 +1877,13 @@
2024
1877
  subscribePaths.forEach(function (p) {
2025
1878
  var sourcePathItem = parsePath(p, instance);
2026
1879
  if (typeof reaction.lifetime === 'string') {
2027
- subscribe(sourcePathItem, "lifetime/".concat(reaction.lifetime), resolveReaction(path, targePath, reaction));
1880
+ subscribe(sourcePathItem, "lifetime/".concat(reaction.lifetime), resolveReaction(path, targePath, reaction, widgetTree));
2028
1881
  }
2029
1882
  if (typeof reaction.effect === 'string') {
2030
- subscribe(sourcePathItem, "effect/".concat(reaction.effect), resolveReaction(path, targePath, reaction));
1883
+ subscribe(sourcePathItem, "effect/".concat(reaction.effect), resolveReaction(path, targePath, reaction, widgetTree));
2031
1884
  }
2032
1885
  if (!reaction.lifetime && !reaction.effect) {
2033
- subscribe(sourcePathItem, 'valChange', resolveReaction(path, targePath, reaction));
1886
+ subscribe(sourcePathItem, 'valChange', resolveReaction(path, targePath, reaction, widgetTree));
2034
1887
  }
2035
1888
  });
2036
1889
  });
@@ -9764,7 +9617,7 @@
9764
9617
  };
9765
9618
  };
9766
9619
  // 设置表单项校验状态
9767
- var setWidgetErrorTips = function setWidgetErrorTips(path, isError, errorMsg) {
9620
+ var setWidgetErrorTips = function setWidgetErrorTips(path, isError, errorMsg, widgetTree) {
9768
9621
  var formItem = widgetTree.widgetMap[path];
9769
9622
  var instance = formItem.instance;
9770
9623
  if (formItem.type === 'node') {
@@ -9797,7 +9650,7 @@
9797
9650
  * 校验单个表单项
9798
9651
  * @param path 字段路径
9799
9652
  */
9800
- var validateFormItem = function validateFormItem(path) {
9653
+ var validateFormItem = function validateFormItem(path, widgetTree) {
9801
9654
  var _instance$schema;
9802
9655
  // TODO 校验逻辑梳理
9803
9656
  var formItem = widgetTree.widgetMap[path];
@@ -9837,7 +9690,7 @@
9837
9690
  var errorsText = ajv.errorsText(schemaValidate.errors, {
9838
9691
  separator: '\n'
9839
9692
  });
9840
- setWidgetErrorTips(path, true, errorsText);
9693
+ setWidgetErrorTips(path, true, errorsText, widgetTree);
9841
9694
  return {
9842
9695
  result: false,
9843
9696
  message: errorsText,
@@ -9866,7 +9719,7 @@
9866
9719
  _iterator.f();
9867
9720
  }
9868
9721
  if (isError) {
9869
- setWidgetErrorTips(path, true, errorMsg);
9722
+ setWidgetErrorTips(path, true, errorMsg, widgetTree);
9870
9723
  return {
9871
9724
  result: false,
9872
9725
  message: errorMsg,
@@ -9882,24 +9735,24 @@
9882
9735
  /**
9883
9736
  * 校验整个表单
9884
9737
  */
9885
- var validateForm = function validateForm() {
9738
+ var validateForm = function validateForm(widgetTree) {
9886
9739
  var isValid = true;
9887
9740
  Object.keys(widgetTree.widgetMap).forEach(function (path) {
9888
9741
  var _validateFormItem;
9889
- if (!((_validateFormItem = validateFormItem(path)) !== null && _validateFormItem !== void 0 && _validateFormItem.result)) isValid = false;
9742
+ if (!((_validateFormItem = validateFormItem(path, widgetTree)) !== null && _validateFormItem !== void 0 && _validateFormItem.result)) isValid = false;
9890
9743
  });
9891
9744
  return isValid;
9892
9745
  };
9893
9746
  /**
9894
9747
  * 校验表单(抛出具体错误信息)
9895
9748
  */
9896
- var validateFormWithResult = function validateFormWithResult() {
9749
+ var validateFormWithResult = function validateFormWithResult(widgetTree) {
9897
9750
  return new Promise(function (resolve, reject) {
9898
9751
  var result = Object.keys(widgetTree.widgetMap).filter(function (path) {
9899
9752
  var _widgetTree$widgetMap;
9900
9753
  return ((_widgetTree$widgetMap = widgetTree.widgetMap[path]) === null || _widgetTree$widgetMap === void 0 ? void 0 : _widgetTree$widgetMap.type) === 'node';
9901
9754
  }).reduce(function (pre, path) {
9902
- var validateResult = validateFormItem(path);
9755
+ var validateResult = validateFormItem(path, widgetTree);
9903
9756
  if (!(validateResult !== null && validateResult !== void 0 && validateResult.result)) {
9904
9757
  pre.push(validateResult);
9905
9758
  }
@@ -9942,8 +9795,8 @@
9942
9795
  * 触发校验
9943
9796
  * @param path 字段路径
9944
9797
  */
9945
- var dispatchValidate = function dispatchValidate(path) {
9946
- return validateFormItem(path);
9798
+ var dispatchValidate = function dispatchValidate(path, widgetTree) {
9799
+ return validateFormItem(path, widgetTree);
9947
9800
  };
9948
9801
 
9949
9802
  // 事件订阅器
@@ -10033,6 +9886,7 @@
10033
9886
  var Widget = Vue__default["default"].extend({
10034
9887
  name: 'Widget',
10035
9888
  props: props,
9889
+ inject: ['widgetTree'],
10036
9890
  data: function data() {
10037
9891
  return {
10038
9892
  loading: false,
@@ -10051,10 +9905,10 @@
10051
9905
  },
10052
9906
  computed: {
10053
9907
  widgetMap: function widgetMap() {
10054
- return widgetTree.widgetMap;
9908
+ return this.widgetTree.widgetMap;
10055
9909
  },
10056
9910
  widgetNode: function widgetNode() {
10057
- return widgetTree.widgetMap[this.path];
9911
+ return this.widgetTree.widgetMap[this.path];
10058
9912
  },
10059
9913
  parent: function parent() {
10060
9914
  var _this$widgetNode;
@@ -10072,7 +9926,7 @@
10072
9926
  if (!deepEquals(newValue, oldValue)) {
10073
9927
  setTimeout(function () {
10074
9928
  reactionDispatch(_this.path, 'valChange');
10075
- dispatchValidate(_this.path);
9929
+ dispatchValidate(_this.path, _this.widgetTree);
10076
9930
  }, 0);
10077
9931
  }
10078
9932
  }
@@ -10104,17 +9958,17 @@
10104
9958
  }
10105
9959
  });
10106
9960
  // 注册widget TreeNode
10107
- widgetTree.addWidgetNode(this.path, this, 'node');
9961
+ this.widgetTree.addWidgetNode(this.path, this, 'node');
10108
9962
  },
10109
9963
  mounted: function mounted() {
10110
9964
  // 注册联动
10111
- reactionRegister(this.path, this.widgetSchema['ui:reactions']);
9965
+ reactionRegister(this.path, this.widgetSchema['ui:reactions'], this.widgetTree);
10112
9966
  // 首次联动
10113
9967
  reactionDispatch(this.path, 'valChange');
10114
9968
  reactionDispatch(this.path, 'lifetime/init');
10115
9969
  },
10116
9970
  beforeDestroy: function beforeDestroy() {
10117
- widgetTree.removeWidgetNode(this.path, this);
9971
+ this.widgetTree.removeWidgetNode(this.path, this);
10118
9972
  reactionUnRegister(this.path);
10119
9973
  },
10120
9974
  methods: {
@@ -10233,7 +10087,14 @@
10233
10087
  }
10234
10088
  },
10235
10089
  render: function render(h) {
10236
- var _events$callbacks, _this$$scopedSlots$de, _this$$scopedSlots$de2, _this$$scopedSlots, _this$widgetSchema$ui5, _this$$scopedSlots$su, _this$$scopedSlots2;
10090
+ var _events$callbacks,
10091
+ _this$$scopedSlots$de,
10092
+ _this$$scopedSlots$de2,
10093
+ _this$$scopedSlots,
10094
+ _this5 = this,
10095
+ _this$widgetSchema$ui5,
10096
+ _this$$scopedSlots$su,
10097
+ _this$$scopedSlots2;
10237
10098
  var _Schema$getUiComponen = Schema.getUiComponent(this.widgetSchema),
10238
10099
  name = _Schema$getUiComponen.name,
10239
10100
  uiVnodeData = _objectWithoutProperties(_Schema$getUiComponen, _excluded2);
@@ -10263,6 +10124,7 @@
10263
10124
  path: self.path,
10264
10125
  value: value
10265
10126
  });
10127
+ reactionDispatch(self.path, 'effect/update');
10266
10128
  }]),
10267
10129
  click: function click() {
10268
10130
  reactionDispatch(self.path, 'effect/click');
@@ -10282,7 +10144,10 @@
10282
10144
  // 渲染删除按钮(用于数组类型widget删除)
10283
10145
  var renderDelete = function renderDelete() {
10284
10146
  return h('span', {
10285
- class: ['bk-schema-form-group-delete'],
10147
+ class: ['bk-schema-form-group-delete', {
10148
+ disabled: _this5.disabled,
10149
+ readonly: _this5.readonly
10150
+ }],
10286
10151
  style: {
10287
10152
  right: '0px',
10288
10153
  top: '0px'
@@ -10391,7 +10256,9 @@
10391
10256
  'ui:component': {
10392
10257
  props: {
10393
10258
  type: 'number',
10394
- min: ((_ctx$props$schema = ctx.props.schema) === null || _ctx$props$schema === void 0 ? void 0 : _ctx$props$schema.type) === 'integer' ? 0 : -Infinity
10259
+ min: ((_ctx$props$schema = ctx.props.schema) === null || _ctx$props$schema === void 0 ? void 0 : _ctx$props$schema.type) === 'integer' ? 0 : -Infinity,
10260
+ allowNumberPaste: true,
10261
+ allowNumberCopy: true
10395
10262
  }
10396
10263
  }
10397
10264
  }, ctx.props.schema)
@@ -10403,10 +10270,12 @@
10403
10270
 
10404
10271
  var messages = {
10405
10272
  'zh-CN': {
10406
- add: '添加'
10273
+ add: '添加',
10274
+ required: '必填项'
10407
10275
  },
10408
10276
  'en-US': {
10409
- add: 'Add'
10277
+ add: 'Add',
10278
+ required: 'Required'
10410
10279
  }
10411
10280
  };
10412
10281
  function locale(item) {
@@ -10445,6 +10314,7 @@
10445
10314
  },
10446
10315
  // 添加item
10447
10316
  handleAddItem: function handleAddItem() {
10317
+ if (this.disabled || this.readonly) return;
10448
10318
  var data = Schema.getSchemaDefaultValue(this.schema.items);
10449
10319
  var value = JSON.parse(JSON.stringify(this.value || []));
10450
10320
  value.push(data);
@@ -10455,6 +10325,7 @@
10455
10325
  },
10456
10326
  // 删除item
10457
10327
  handleDeleteItem: function handleDeleteItem(path) {
10328
+ if (this.disabled || this.readonly) return;
10458
10329
  var index = Number(Path.getPathLastProp(path));
10459
10330
  var value = JSON.parse(JSON.stringify(this.value || []));
10460
10331
  value.splice(index, 1);
@@ -10465,7 +10336,13 @@
10465
10336
  }
10466
10337
  },
10467
10338
  render: function render(h) {
10468
- var _this = this;
10339
+ var _this = this,
10340
+ _self$value,
10341
+ _this$schema,
10342
+ _this$schema$uiProps,
10343
+ _this$schema2,
10344
+ _this$schema3,
10345
+ _this$schema3$uiProp;
10469
10346
  var self = this;
10470
10347
  var arrVnodeList = (Array.isArray(this.value) ? this.value : []).map(function (_, index) {
10471
10348
  var curPath = Path.getCurPath(_this.path, index);
@@ -10489,18 +10366,24 @@
10489
10366
  var _Schema$getGroupWrap = Schema.getGroupWrap(this.schema),
10490
10367
  name = _Schema$getGroupWrap.name,
10491
10368
  vnode = _objectWithoutProperties(_Schema$getGroupWrap, _excluded$2);
10369
+ var error = ((_self$value = self.value) === null || _self$value === void 0 ? void 0 : _self$value.length) === 0 && self.required;
10492
10370
  return h(name, mergeDeep({
10493
10371
  props: _objectSpread2(_objectSpread2({}, this.$props), {}, {
10494
10372
  layout: {},
10495
10373
  showTitle: true // 数组类型默认展示分组title
10496
10374
  }),
10497
10375
  style: _objectSpread2({}, this.layout.item || {})
10498
- }, vnode), [].concat(_toConsumableArray(arrVnodeList), [h(registry.getBaseWidget('form-item'), {
10376
+ }, vnode), [].concat(_toConsumableArray(arrVnodeList), [!this.readonly ? h(registry.getBaseWidget('form-item'), {
10499
10377
  class: {
10500
10378
  'bk-schema-form-item-auto-height': true
10501
10379
  }
10502
10380
  }, [h('span', {
10503
- class: ['bk-schema-form-group-add'],
10381
+ class: ['bk-schema-form-group-add', {
10382
+ 'error': error
10383
+ }, (_this$schema = this.schema) === null || _this$schema === void 0 ? void 0 : (_this$schema$uiProps = _this$schema['ui:props']) === null || _this$schema$uiProps === void 0 ? void 0 : _this$schema$uiProps.size, {
10384
+ disabled: this.disabled,
10385
+ readonly: this.readonly
10386
+ }],
10504
10387
  on: {
10505
10388
  click: function click() {
10506
10389
  self.handleAddItem();
@@ -10508,7 +10391,9 @@
10508
10391
  }
10509
10392
  }, [h('i', {
10510
10393
  class: ['bk-icon icon-plus-circle-shape mr5']
10511
- }), locale('add')])])]));
10394
+ }), "".concat(locale('add')).concat(((_this$schema2 = this.schema) === null || _this$schema2 === void 0 ? void 0 : _this$schema2.title) || '')]), error && ((_this$schema3 = this.schema) === null || _this$schema3 === void 0 ? void 0 : (_this$schema3$uiProp = _this$schema3['ui:props']) === null || _this$schema3$uiProp === void 0 ? void 0 : _this$schema3$uiProp.size) === 'large' && h('p', {
10395
+ class: ['bk-schema-form-item__error-tips']
10396
+ }, [locale('required')])]) : null]));
10512
10397
  }
10513
10398
  });
10514
10399
 
@@ -10919,6 +10804,7 @@
10919
10804
  var TableWidget = Vue__default["default"].extend({
10920
10805
  name: 'TableWidget',
10921
10806
  props: props,
10807
+ inject: ['widgetTree'],
10922
10808
  watch: {
10923
10809
  value: {
10924
10810
  immediate: true,
@@ -10928,9 +10814,9 @@
10928
10814
  (_this$value = this.value) === null || _this$value === void 0 ? void 0 : _this$value.forEach(function (_, index) {
10929
10815
  var path = "".concat(_this.path, ".").concat(index);
10930
10816
  // 销毁上一次的缓存
10931
- widgetTree.removeWidgetNode(path, null);
10817
+ _this.widgetTree.removeWidgetNode(path, null);
10932
10818
  // 重新当前行的父节点
10933
- widgetTree.addWidgetNode(path, null, 'group');
10819
+ _this.widgetTree.addWidgetNode(path, null, 'group');
10934
10820
  });
10935
10821
  }
10936
10822
  }
@@ -10977,7 +10863,19 @@
10977
10863
  }
10978
10864
  var uiOptions = Schema.getUiOptions(schema);
10979
10865
  var getTableColumn = function getTableColumn() {
10980
- var VNodeList = Object.keys(properties).map(function (key) {
10866
+ // 表格列排序优先取 ui:order 属性里配置的顺序
10867
+ var colKeys = Object.keys(properties);
10868
+ var orders = (schemaItems === null || schemaItems === void 0 ? void 0 : schemaItems['ui:order']) || [];
10869
+ var orderMap = new Map();
10870
+ orders.forEach(function (key, index) {
10871
+ orderMap.set(key, index);
10872
+ });
10873
+ colKeys.sort(function (a, b) {
10874
+ var orderA = orderMap.has(a) ? orderMap.get(a) : Infinity;
10875
+ var orderB = orderMap.has(b) ? orderMap.get(b) : Infinity;
10876
+ return orderA - orderB;
10877
+ });
10878
+ var VNodeList = colKeys.map(function (key) {
10981
10879
  var _colField$uiProps, _colField$uiProps2;
10982
10880
  var colField = properties[key];
10983
10881
  // 仅支持基础数据类型的属性配置,render-header、sort-method、formatter等Function类型的属性不属于json支持的数据类型,配置将不会生效
@@ -11099,6 +10997,7 @@
11099
10997
 
11100
10998
  var FieldGroupWrap = Vue__default["default"].extend({
11101
10999
  name: 'FieldGroupWrap',
11000
+ inject: ['widgetTree'],
11102
11001
  props: _objectSpread2(_objectSpread2({}, props), {}, {
11103
11002
  // 组类型
11104
11003
  type: {
@@ -11125,6 +11024,10 @@
11125
11024
  hideEmptyRow: {
11126
11025
  type: Boolean,
11127
11026
  default: false
11027
+ },
11028
+ description: {
11029
+ type: String,
11030
+ default: ''
11128
11031
  }
11129
11032
  }),
11130
11033
  data: function data() {
@@ -11138,14 +11041,14 @@
11138
11041
  },
11139
11042
  created: function created() {
11140
11043
  // 注册widget TreeNode
11141
- widgetTree.addWidgetNode(this.path, this, 'group');
11044
+ this.widgetTree.addWidgetNode(this.path, this, 'group');
11142
11045
  },
11143
11046
  mounted: function mounted() {
11144
11047
  // 更新样式
11145
11048
  this.$forceUpdate();
11146
11049
  },
11147
11050
  beforeDestroy: function beforeDestroy() {
11148
- widgetTree.removeWidgetNode(this.path, this);
11051
+ this.widgetTree.removeWidgetNode(this.path, this);
11149
11052
  },
11150
11053
  methods: {
11151
11054
  setState: function setState(key, value) {
@@ -11168,9 +11071,9 @@
11168
11071
  render: function render(h) {
11169
11072
  var _this$layout,
11170
11073
  _this$layout2,
11074
+ _this = this,
11171
11075
  _this$schema,
11172
- _this$layout3,
11173
- _this = this;
11076
+ _this$layout3;
11174
11077
  var schemaFormStyle = _objectSpread2({
11175
11078
  position: 'relative',
11176
11079
  border: this.border ? '1px solid #dcdee5' : 'none',
@@ -11183,7 +11086,10 @@
11183
11086
  var self = this;
11184
11087
  var renderDelete = function renderDelete() {
11185
11088
  return h('span', {
11186
- class: ['bk-schema-form-group-delete'],
11089
+ class: ['bk-schema-form-group-delete', {
11090
+ disabled: _this.disabled,
11091
+ readonly: _this.readonly
11092
+ }],
11187
11093
  style: {
11188
11094
  right: '10px',
11189
11095
  top: '10px'
@@ -11210,7 +11116,14 @@
11210
11116
  }],
11211
11117
  "style": schemaFormStyle
11212
11118
  }, [title && this.showTitle ? h("span", {
11213
- "class": ['bk-schema-form-group-title', this.type]
11119
+ "directives": [{
11120
+ name: "bk-tooltips",
11121
+ value: this.description
11122
+ }],
11123
+ "class": ['bk-schema-form-group-title', this.type, {
11124
+ 'group-has-desc': !!this.description,
11125
+ 'is-required': this.required
11126
+ }]
11214
11127
  }, [title, hasError ? h("span", {
11215
11128
  "class": "bk-schema-form-group__error-tips"
11216
11129
  }, [h("span", {
@@ -11218,7 +11131,7 @@
11218
11131
  }, [groupErrorTipsContent])]) : null]) : null, h("div", {
11219
11132
  "style": groupContentStyle,
11220
11133
  "class": "bk-schema-form-group-content"
11221
- }, [this.$slots.default]), this.removeable && renderDelete()]);
11134
+ }, [this.$slots.default]), this.removeable && !this.readonly && renderDelete()]);
11222
11135
  }
11223
11136
  });
11224
11137
 
@@ -11241,12 +11154,12 @@
11241
11154
  },
11242
11155
  methods: {
11243
11156
  handleAddItem: function handleAddItem() {
11244
- if (this.disabled) return;
11157
+ if (this.disabled || this.readonly) return;
11245
11158
  var data = Schema.getSchemaDefaultValue(this.schema.items);
11246
11159
  this.$emit('input', [].concat(_toConsumableArray(this.value), [data]));
11247
11160
  },
11248
11161
  handleRemoveItem: function handleRemoveItem(index) {
11249
- if (this.disabled) return;
11162
+ if (this.disabled || this.readonly) return;
11250
11163
  var value = JSON.parse(JSON.stringify(this.value));
11251
11164
  value.splice(index, 1);
11252
11165
  this.$emit('input', value);
@@ -11269,7 +11182,7 @@
11269
11182
  _this$value2;
11270
11183
  var labelBtnStyle = {
11271
11184
  'font-size': '16px',
11272
- color: '#979ba5',
11185
+ color: this.disabled ? '#c4c6cc' : '#979ba5',
11273
11186
  cursor: this.disabled ? 'not-allowed' : 'pointer',
11274
11187
  display: 'inline-block'
11275
11188
  };
@@ -11448,10 +11361,7 @@
11448
11361
  props: _objectSpread2(_objectSpread2({}, props), {}, {
11449
11362
  type: {
11450
11363
  type: String,
11451
- default: 'default',
11452
- validator: function validator(value) {
11453
- return ['default', 'normal', 'card'].includes(value);
11454
- }
11364
+ default: 'default' // 'default', 'normal', 'card'
11455
11365
  },
11456
11366
  showTitle: {
11457
11367
  type: Boolean,
@@ -11470,6 +11380,10 @@
11470
11380
  verifiable: {
11471
11381
  type: Boolean,
11472
11382
  default: false
11383
+ },
11384
+ collapseStyle: {
11385
+ type: String,
11386
+ default: 'normal' // normal: 修改后的样式参看BCS,default: 组件样式
11473
11387
  }
11474
11388
  }),
11475
11389
  data: function data() {
@@ -11480,7 +11394,6 @@
11480
11394
  render: function render(h) {
11481
11395
  var _this$schema,
11482
11396
  _this = this;
11483
- var collapseStyle = {};
11484
11397
  var collapseTitleStyle = {
11485
11398
  background: '#f5f7fa',
11486
11399
  'border-radius': '2px',
@@ -11513,9 +11426,9 @@
11513
11426
  hideArrow: true,
11514
11427
  name: key
11515
11428
  },
11516
- class: ['mb15']
11429
+ class: _this.collapseStyle === 'normal' ? ['mb15'] : []
11517
11430
  }, [h('div', {
11518
- style: collapseTitleStyle
11431
+ style: _this.collapseStyle === 'normal' ? collapseTitleStyle : {}
11519
11432
  }, [h('i', {
11520
11433
  class: ['bk-icon icon-down-shape mr5'],
11521
11434
  style: _objectSpread2(_objectSpread2({}, collapseIconStyle), {}, {
@@ -11539,7 +11452,7 @@
11539
11452
  return h(FieldGroupWrap, {
11540
11453
  props: _objectSpread2({}, groupWrapProps)
11541
11454
  }, [h(registry.getBaseWidget('collapse'), {
11542
- style: collapseStyle,
11455
+ class: this.collapseStyle,
11543
11456
  props: {
11544
11457
  value: this.activeName
11545
11458
  },
@@ -11648,6 +11561,114 @@
11648
11561
  }
11649
11562
  });
11650
11563
 
11564
+ var UploadWidget = Vue__default["default"].extend({
11565
+ name: 'UploadWidget',
11566
+ props: {
11567
+ value: {
11568
+ type: Array,
11569
+ default: function _default() {
11570
+ return [];
11571
+ }
11572
+ },
11573
+ isUploadSuccessed: {
11574
+ type: String
11575
+ },
11576
+ responseHandler: {
11577
+ type: String
11578
+ }
11579
+ },
11580
+ methods: {
11581
+ request: function request(options) {
11582
+ var _this = this;
11583
+ var xhr = new XMLHttpRequest();
11584
+ options.fileObj.xhr = xhr;
11585
+ var formData = new FormData();
11586
+ options.data.forEach(function (item) {
11587
+ formData.append(item.name, executeExpression(item.value, _this.$parent.$parent));
11588
+ });
11589
+ formData.append(options.fileName, options.fileObj.origin);
11590
+ xhr.onreadystatechange = function () {
11591
+ if (xhr.readyState === 4) {
11592
+ var reponseText = _this.parseResponse(xhr.responseText || xhr.response);
11593
+ if (xhr.status < 200 || xhr.status >= 300) {
11594
+ options.fileObj.progress = 100 + '%';
11595
+ options.fileObj.errorMsg = reponseText.message || '上传失败';
11596
+ options.onError(options.fileObj, options.fileList, xhr.response);
11597
+ } else {
11598
+ options.onSuccess(reponseText, options.fileObj);
11599
+ }
11600
+ options.onDone(options.fileObj);
11601
+ }
11602
+ };
11603
+ xhr.upload.addEventListener('progress', options.onProgress, false);
11604
+ xhr.withCredentials = options.withCredentials;
11605
+ xhr.open(options.method, options.url, true);
11606
+ if (options.header) {
11607
+ if (Array.isArray(options.header)) {
11608
+ options.header.forEach(function (head) {
11609
+ var headerKey = head.name;
11610
+ var headerVal = executeExpression(head.value, _this.$parent.$parent);
11611
+ xhr.setRequestHeader(headerKey, headerVal);
11612
+ });
11613
+ } else {
11614
+ var headerKey = options.header.name;
11615
+ var headerVal = executeExpression(options.header.value, this.$parent.$parent);
11616
+ xhr.setRequestHeader(headerKey, headerVal);
11617
+ }
11618
+ }
11619
+ xhr.send(formData);
11620
+ return {
11621
+ abort: function abort() {
11622
+ xhr.abort();
11623
+ }
11624
+ };
11625
+ },
11626
+ parseResponse: function parseResponse(response) {
11627
+ if (!response) {
11628
+ return response || {};
11629
+ }
11630
+ try {
11631
+ return JSON.parse(response);
11632
+ } catch (error) {
11633
+ return response || {};
11634
+ }
11635
+ },
11636
+ handleResCode: function handleResCode(res) {
11637
+ var successed = true;
11638
+ if (this.isUploadSuccessed) {
11639
+ successed = executeExpression(this.isUploadSuccessed, this.$parent.$parent, [], {
11640
+ response: res
11641
+ });
11642
+ }
11643
+ if (!successed) return;
11644
+ if (this.responseHandler) {
11645
+ var files = executeExpression(this.responseHandler, this.$parent.$parent, [], {
11646
+ response: res
11647
+ });
11648
+ this.$emit('input', files);
11649
+ }
11650
+ return true;
11651
+ },
11652
+ handleSuccess: function handleSuccess(file, fileList) {
11653
+ if (!this.responseHandler) {
11654
+ this.$emit('input', fileList);
11655
+ }
11656
+ }
11657
+ },
11658
+ render: function render(h) {
11659
+ return h(registry.getBaseWidget('upload'), {
11660
+ props: _objectSpread2({
11661
+ customRequest: this.request,
11662
+ files: this.value,
11663
+ handleResCode: this.handleResCode
11664
+ }, this.$attrs),
11665
+ on: {
11666
+ 'on-success': this.handleSuccess
11667
+ }
11668
+ });
11669
+ }
11670
+ });
11671
+
11651
11672
  function styleInject(css, ref) {
11652
11673
  if ( ref === void 0 ) ref = {};
11653
11674
  var insertAt = ref.insertAt;
@@ -11678,6 +11699,197 @@
11678
11699
  var css_248z = "";
11679
11700
  styleInject(css_248z);
11680
11701
 
11702
+ var WidgetNode = /*#__PURE__*/function () {
11703
+ function WidgetNode(config) {
11704
+ _classCallCheck(this, WidgetNode);
11705
+ this.id = void 0;
11706
+ this.instance = void 0;
11707
+ this.parent = void 0;
11708
+ this.type = void 0;
11709
+ this.index = void 0;
11710
+ // todo
11711
+ this.children = void 0;
11712
+ var id = config.id,
11713
+ instance = config.instance,
11714
+ parent = config.parent,
11715
+ index = config.index,
11716
+ type = config.type,
11717
+ _config$children = config.children,
11718
+ children = _config$children === void 0 ? [] : _config$children;
11719
+ this.id = id;
11720
+ this.type = type;
11721
+ this.index = index;
11722
+ this.instance = instance;
11723
+ this.parent = parent;
11724
+ this.children = children;
11725
+ }
11726
+ // 当前node的值
11727
+ return _createClass(WidgetNode, [{
11728
+ key: "value",
11729
+ get: function get() {
11730
+ var _this$instance;
11731
+ return (_this$instance = this.instance) === null || _this$instance === void 0 ? void 0 : _this$instance.value;
11732
+ }
11733
+ // 是否含有可见子节点
11734
+ }, {
11735
+ key: "isChildrenVisible",
11736
+ get: function get() {
11737
+ if (this.type === 'node') {
11738
+ var _this$instance2;
11739
+ return (_this$instance2 = this.instance) === null || _this$instance2 === void 0 ? void 0 : _this$instance2.state.visible;
11740
+ }
11741
+ return this.children.some(function (child) {
11742
+ return child.isChildrenVisible;
11743
+ });
11744
+ }
11745
+ /**
11746
+ * 获取 parents
11747
+ */
11748
+ }, {
11749
+ key: "parents",
11750
+ get: function get() {
11751
+ if (!this.parent) {
11752
+ return [];
11753
+ }
11754
+ return [].concat(_toConsumableArray(this.parent.parents), [this.parent]);
11755
+ }
11756
+ // 第一个子节点
11757
+ }, {
11758
+ key: "firstChild",
11759
+ get: function get() {
11760
+ return this.children[0] || null;
11761
+ }
11762
+ // 最后一个子节点
11763
+ }, {
11764
+ key: "lastChild",
11765
+ get: function get() {
11766
+ return this.children[this.children.length - 1] || null;
11767
+ }
11768
+ // 指定属性下的同胞节点
11769
+ }, {
11770
+ key: "getSibling",
11771
+ value: function getSibling(lastProp) {
11772
+ var _this$parent;
11773
+ var reg = new RegExp("".concat(Path.getPathLastProp(this.id) || '', "$"));
11774
+ var id = this.id.replace(reg, lastProp);
11775
+ return (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.children.find(function (node) {
11776
+ return node.id === id;
11777
+ });
11778
+ }
11779
+ // 获取所以同胞节点(不含自己)
11780
+ }, {
11781
+ key: "getSiblings",
11782
+ value: function getSiblings() {
11783
+ var _this$parent2,
11784
+ _this = this;
11785
+ return ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.children.filter(function (node) {
11786
+ return node.instance !== _this.instance;
11787
+ })) || [];
11788
+ }
11789
+ /**
11790
+ * 是否是叶子节点
11791
+ */
11792
+ }, {
11793
+ key: "isLeaf",
11794
+ get: function get() {
11795
+ return !this.children.length;
11796
+ }
11797
+ }, {
11798
+ key: "appendChild",
11799
+ value: function appendChild(node) {
11800
+ var _this$children;
11801
+ var nodes = Array.isArray(node) ? node : [node];
11802
+ var offset = node.index !== undefined ? node.index : this.children.length;
11803
+ (_this$children = this.children).splice.apply(_this$children, [offset, 0].concat(_toConsumableArray(nodes)));
11804
+ this.children.slice(offset).forEach(function (node, index) {
11805
+ node.index = offset + index;
11806
+ });
11807
+ return nodes;
11808
+ }
11809
+ }, {
11810
+ key: "removeChild",
11811
+ value: function removeChild(node) {
11812
+ var _this2 = this;
11813
+ var nodes = Array.isArray(node) ? node : [node];
11814
+ var removedChildIndex = [];
11815
+ nodes.forEach(function (node) {
11816
+ var index = node.index;
11817
+ removedChildIndex.push(index);
11818
+ _this2.children.splice(index, 1);
11819
+ });
11820
+ var minIndex = Math.min.apply(Math, removedChildIndex);
11821
+ this.children.slice(minIndex).forEach(function (node, index) {
11822
+ node.index = minIndex + index;
11823
+ });
11824
+ return nodes;
11825
+ }
11826
+ }]);
11827
+ }();
11828
+ var WidgetTree = /*#__PURE__*/function () {
11829
+ function WidgetTree() {
11830
+ _classCallCheck(this, WidgetTree);
11831
+ this.widgetMap = {};
11832
+ }
11833
+ return _createClass(WidgetTree, [{
11834
+ key: "addWidgetNode",
11835
+ value: function addWidgetNode(path, instance, type, index) {
11836
+ if (path === '') {
11837
+ // 根节点
11838
+ var node = new WidgetNode({
11839
+ id: '',
11840
+ type: type,
11841
+ index: index,
11842
+ parent: null,
11843
+ instance: instance,
11844
+ children: []
11845
+ });
11846
+ this.widgetMap[path] = node;
11847
+ } else {
11848
+ // 普通节点
11849
+ var parentId = Path.getParentPath(path);
11850
+ var parentNode = this.widgetMap[parentId];
11851
+ var _node = new WidgetNode({
11852
+ id: (instance === null || instance === void 0 ? void 0 : instance.path) || path,
11853
+ type: type,
11854
+ index: index,
11855
+ parent: parentNode,
11856
+ instance: instance,
11857
+ children: []
11858
+ });
11859
+ if (!parentNode) {
11860
+ console.warn('Unexpected parent id, please check widget node', _node);
11861
+ } else {
11862
+ parentNode.appendChild(_node);
11863
+ }
11864
+ this.widgetMap[path] = _node;
11865
+ }
11866
+ }
11867
+ }, {
11868
+ key: "removeWidgetNode",
11869
+ value: function removeWidgetNode(path, instance) {
11870
+ var node = this.widgetMap[path];
11871
+ if (node) {
11872
+ if (node.parent) {
11873
+ var children = node.parent.children;
11874
+ var index = children.findIndex(function (item) {
11875
+ return item.instance === instance;
11876
+ });
11877
+ if (index > -1) {
11878
+ children.splice(index, 1);
11879
+ children.slice(index).forEach(function (node, i) {
11880
+ node.index = index + i;
11881
+ });
11882
+ }
11883
+ }
11884
+ if (node.instance === instance) {
11885
+ delete this.widgetMap[path];
11886
+ }
11887
+ }
11888
+ }
11889
+ }]);
11890
+ }();
11891
+ // export default new WidgetTree();
11892
+
11681
11893
  var defaultOptions = {
11682
11894
  namespace: 'bk',
11683
11895
  components: {
@@ -11693,7 +11905,8 @@
11693
11905
  switcher: SwitcherWidget,
11694
11906
  color: ColorWidget,
11695
11907
  bfInput: InputWidget,
11696
- input: 'bk-input'
11908
+ input: 'bk-input',
11909
+ bfUpload: UploadWidget
11697
11910
  },
11698
11911
  fields: {
11699
11912
  object: ObjectField,
@@ -11725,7 +11938,8 @@
11725
11938
  data: function data() {
11726
11939
  return {
11727
11940
  rootData: {},
11728
- formKey: 'bk-ui-form'
11941
+ formKey: 'bk-ui-form',
11942
+ widgetTree: new WidgetTree()
11729
11943
  };
11730
11944
  },
11731
11945
  watch: {
@@ -11750,8 +11964,11 @@
11750
11964
  registryGlobalRules(value);
11751
11965
  }
11752
11966
  },
11753
- value: function value() {
11754
- this.initFormData();
11967
+ value: {
11968
+ handler: function handler() {
11969
+ this.initFormData();
11970
+ },
11971
+ deep: true
11755
11972
  }
11756
11973
  },
11757
11974
  beforeCreate: function beforeCreate() {
@@ -11773,9 +11990,15 @@
11773
11990
  this.$emit('change', newValue, oldValue);
11774
11991
  }
11775
11992
  },
11776
- validateForm: validateForm,
11777
- validateFormItem: validateFormItem,
11778
- validate: validateFormWithResult,
11993
+ validateForm: function validateForm$1() {
11994
+ return validateForm(this.widgetTree);
11995
+ },
11996
+ validateFormItem: function validateFormItem$1(path) {
11997
+ return validateFormItem(path, this.widgetTree);
11998
+ },
11999
+ validate: function validate() {
12000
+ return validateFormWithResult(this.widgetTree);
12001
+ },
11779
12002
  validateSchema: validateSchema
11780
12003
  },
11781
12004
  render: function render(h) {
@@ -11818,6 +12041,11 @@
11818
12041
  }
11819
12042
  }
11820
12043
  })]);
12044
+ },
12045
+ provide: function provide() {
12046
+ return {
12047
+ widgetTree: this.widgetTree
12048
+ };
11821
12049
  }
11822
12050
  });
11823
12051
  }