@blueking/bkui-form 0.0.42-beta.11 → 0.0.42-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/vue2/common/FieldGroupWrap.d.ts +1 -0
- package/dist/bkui-form-es-min.js +6 -6
- package/dist/bkui-form-es.js +246 -220
- package/dist/bkui-form-es.js.map +1 -1
- package/dist/bkui-form-umd-min.js +6 -6
- package/dist/bkui-form-umd.js +246 -220
- package/dist/bkui-form-umd.js.map +1 -1
- package/dist/bkui-form.css +4 -1
- package/dist/controller/form-vue2.d.ts +5 -3
- package/dist/core/reaction.d.ts +2 -1
- package/dist/core/validator.d.ts +6 -5
- package/dist/core/widgetTree.d.ts +1 -2
- package/dist/types/bkui-form.d.ts +44 -4
- package/package.json +1 -1
package/dist/bkui-form-umd.js
CHANGED
|
@@ -1758,197 +1758,6 @@
|
|
|
1758
1758
|
return typeof expression === 'string' && /{{.*}}/.test(expression);
|
|
1759
1759
|
};
|
|
1760
1760
|
|
|
1761
|
-
var WidgetNode = /*#__PURE__*/function () {
|
|
1762
|
-
function WidgetNode(config) {
|
|
1763
|
-
_classCallCheck(this, WidgetNode);
|
|
1764
|
-
this.id = void 0;
|
|
1765
|
-
this.instance = void 0;
|
|
1766
|
-
this.parent = void 0;
|
|
1767
|
-
this.type = void 0;
|
|
1768
|
-
this.index = void 0;
|
|
1769
|
-
// todo
|
|
1770
|
-
this.children = void 0;
|
|
1771
|
-
var id = config.id,
|
|
1772
|
-
instance = config.instance,
|
|
1773
|
-
parent = config.parent,
|
|
1774
|
-
index = config.index,
|
|
1775
|
-
type = config.type,
|
|
1776
|
-
_config$children = config.children,
|
|
1777
|
-
children = _config$children === void 0 ? [] : _config$children;
|
|
1778
|
-
this.id = id;
|
|
1779
|
-
this.type = type;
|
|
1780
|
-
this.index = index;
|
|
1781
|
-
this.instance = instance;
|
|
1782
|
-
this.parent = parent;
|
|
1783
|
-
this.children = children;
|
|
1784
|
-
}
|
|
1785
|
-
// 当前node的值
|
|
1786
|
-
return _createClass(WidgetNode, [{
|
|
1787
|
-
key: "value",
|
|
1788
|
-
get: function get() {
|
|
1789
|
-
var _this$instance;
|
|
1790
|
-
return (_this$instance = this.instance) === null || _this$instance === void 0 ? void 0 : _this$instance.value;
|
|
1791
|
-
}
|
|
1792
|
-
// 是否含有可见子节点
|
|
1793
|
-
}, {
|
|
1794
|
-
key: "isChildrenVisible",
|
|
1795
|
-
get: function get() {
|
|
1796
|
-
if (this.type === 'node') {
|
|
1797
|
-
var _this$instance2;
|
|
1798
|
-
return (_this$instance2 = this.instance) === null || _this$instance2 === void 0 ? void 0 : _this$instance2.state.visible;
|
|
1799
|
-
}
|
|
1800
|
-
return this.children.some(function (child) {
|
|
1801
|
-
return child.isChildrenVisible;
|
|
1802
|
-
});
|
|
1803
|
-
}
|
|
1804
|
-
/**
|
|
1805
|
-
* 获取 parents
|
|
1806
|
-
*/
|
|
1807
|
-
}, {
|
|
1808
|
-
key: "parents",
|
|
1809
|
-
get: function get() {
|
|
1810
|
-
if (!this.parent) {
|
|
1811
|
-
return [];
|
|
1812
|
-
}
|
|
1813
|
-
return [].concat(_toConsumableArray(this.parent.parents), [this.parent]);
|
|
1814
|
-
}
|
|
1815
|
-
// 第一个子节点
|
|
1816
|
-
}, {
|
|
1817
|
-
key: "firstChild",
|
|
1818
|
-
get: function get() {
|
|
1819
|
-
return this.children[0] || null;
|
|
1820
|
-
}
|
|
1821
|
-
// 最后一个子节点
|
|
1822
|
-
}, {
|
|
1823
|
-
key: "lastChild",
|
|
1824
|
-
get: function get() {
|
|
1825
|
-
return this.children[this.children.length - 1] || null;
|
|
1826
|
-
}
|
|
1827
|
-
// 指定属性下的同胞节点
|
|
1828
|
-
}, {
|
|
1829
|
-
key: "getSibling",
|
|
1830
|
-
value: function getSibling(lastProp) {
|
|
1831
|
-
var _this$parent;
|
|
1832
|
-
var reg = new RegExp("".concat(Path.getPathLastProp(this.id) || '', "$"));
|
|
1833
|
-
var id = this.id.replace(reg, lastProp);
|
|
1834
|
-
return (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.children.find(function (node) {
|
|
1835
|
-
return node.id === id;
|
|
1836
|
-
});
|
|
1837
|
-
}
|
|
1838
|
-
// 获取所以同胞节点(不含自己)
|
|
1839
|
-
}, {
|
|
1840
|
-
key: "getSiblings",
|
|
1841
|
-
value: function getSiblings() {
|
|
1842
|
-
var _this$parent2,
|
|
1843
|
-
_this = this;
|
|
1844
|
-
return ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.children.filter(function (node) {
|
|
1845
|
-
return node.instance !== _this.instance;
|
|
1846
|
-
})) || [];
|
|
1847
|
-
}
|
|
1848
|
-
/**
|
|
1849
|
-
* 是否是叶子节点
|
|
1850
|
-
*/
|
|
1851
|
-
}, {
|
|
1852
|
-
key: "isLeaf",
|
|
1853
|
-
get: function get() {
|
|
1854
|
-
return !this.children.length;
|
|
1855
|
-
}
|
|
1856
|
-
}, {
|
|
1857
|
-
key: "appendChild",
|
|
1858
|
-
value: function appendChild(node) {
|
|
1859
|
-
var _this$children;
|
|
1860
|
-
var nodes = Array.isArray(node) ? node : [node];
|
|
1861
|
-
var offset = node.index !== undefined ? node.index : this.children.length;
|
|
1862
|
-
(_this$children = this.children).splice.apply(_this$children, [offset, 0].concat(_toConsumableArray(nodes)));
|
|
1863
|
-
this.children.slice(offset).forEach(function (node, index) {
|
|
1864
|
-
node.index = offset + index;
|
|
1865
|
-
});
|
|
1866
|
-
return nodes;
|
|
1867
|
-
}
|
|
1868
|
-
}, {
|
|
1869
|
-
key: "removeChild",
|
|
1870
|
-
value: function removeChild(node) {
|
|
1871
|
-
var _this2 = this;
|
|
1872
|
-
var nodes = Array.isArray(node) ? node : [node];
|
|
1873
|
-
var removedChildIndex = [];
|
|
1874
|
-
nodes.forEach(function (node) {
|
|
1875
|
-
var index = node.index;
|
|
1876
|
-
removedChildIndex.push(index);
|
|
1877
|
-
_this2.children.splice(index, 1);
|
|
1878
|
-
});
|
|
1879
|
-
var minIndex = Math.min.apply(Math, removedChildIndex);
|
|
1880
|
-
this.children.slice(minIndex).forEach(function (node, index) {
|
|
1881
|
-
node.index = minIndex + index;
|
|
1882
|
-
});
|
|
1883
|
-
return nodes;
|
|
1884
|
-
}
|
|
1885
|
-
}]);
|
|
1886
|
-
}();
|
|
1887
|
-
var WidgetTree = /*#__PURE__*/function () {
|
|
1888
|
-
function WidgetTree() {
|
|
1889
|
-
_classCallCheck(this, WidgetTree);
|
|
1890
|
-
this.widgetMap = {};
|
|
1891
|
-
}
|
|
1892
|
-
return _createClass(WidgetTree, [{
|
|
1893
|
-
key: "addWidgetNode",
|
|
1894
|
-
value: function addWidgetNode(path, instance, type, index) {
|
|
1895
|
-
if (path === '') {
|
|
1896
|
-
// 根节点
|
|
1897
|
-
var node = new WidgetNode({
|
|
1898
|
-
id: '',
|
|
1899
|
-
type: type,
|
|
1900
|
-
index: index,
|
|
1901
|
-
parent: null,
|
|
1902
|
-
instance: instance,
|
|
1903
|
-
children: []
|
|
1904
|
-
});
|
|
1905
|
-
this.widgetMap[path] = node;
|
|
1906
|
-
} else {
|
|
1907
|
-
// 普通节点
|
|
1908
|
-
var parentId = Path.getParentPath(path);
|
|
1909
|
-
var parentNode = this.widgetMap[parentId];
|
|
1910
|
-
var _node = new WidgetNode({
|
|
1911
|
-
id: (instance === null || instance === void 0 ? void 0 : instance.path) || path,
|
|
1912
|
-
type: type,
|
|
1913
|
-
index: index,
|
|
1914
|
-
parent: parentNode,
|
|
1915
|
-
instance: instance,
|
|
1916
|
-
children: []
|
|
1917
|
-
});
|
|
1918
|
-
if (!parentNode) {
|
|
1919
|
-
console.warn('Unexpected parent id, please check widget node', _node);
|
|
1920
|
-
} else {
|
|
1921
|
-
parentNode.appendChild(_node);
|
|
1922
|
-
}
|
|
1923
|
-
this.widgetMap[path] = _node;
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
}, {
|
|
1927
|
-
key: "removeWidgetNode",
|
|
1928
|
-
value: function removeWidgetNode(path, instance) {
|
|
1929
|
-
var node = this.widgetMap[path];
|
|
1930
|
-
if (node) {
|
|
1931
|
-
if (node.parent) {
|
|
1932
|
-
var children = node.parent.children;
|
|
1933
|
-
var index = children.findIndex(function (item) {
|
|
1934
|
-
return item.instance === instance;
|
|
1935
|
-
});
|
|
1936
|
-
if (index > -1) {
|
|
1937
|
-
children.splice(index, 1);
|
|
1938
|
-
children.slice(index).forEach(function (node, i) {
|
|
1939
|
-
node.index = index + i;
|
|
1940
|
-
});
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
if (node.instance === instance) {
|
|
1944
|
-
delete this.widgetMap[path];
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
}]);
|
|
1949
|
-
}();
|
|
1950
|
-
var widgetTree = new WidgetTree();
|
|
1951
|
-
|
|
1952
1761
|
var reactionsMap = {};
|
|
1953
1762
|
var subscribe = function subscribe(path, typeName, fn) {
|
|
1954
1763
|
if (!reactionsMap[path]) {
|
|
@@ -1980,7 +1789,7 @@
|
|
|
1980
1789
|
* @param reaction 传入的reacion配置
|
|
1981
1790
|
* @returns viod
|
|
1982
1791
|
*/
|
|
1983
|
-
var resolveReaction = function resolveReaction(crtInsPath, targetPath, reaction) {
|
|
1792
|
+
var resolveReaction = function resolveReaction(crtInsPath, targetPath, reaction, widgetTree) {
|
|
1984
1793
|
return function () {
|
|
1985
1794
|
var _ref = widgetTree.widgetMap[crtInsPath] || {},
|
|
1986
1795
|
crtInstance = _ref.instance; // 当前组件实例,用来条件表达式判断
|
|
@@ -2025,6 +1834,7 @@
|
|
|
2025
1834
|
};
|
|
2026
1835
|
var reactionRegister = function reactionRegister(path) {
|
|
2027
1836
|
var reactions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1837
|
+
var widgetTree = arguments.length > 2 ? arguments[2] : undefined;
|
|
2028
1838
|
var _ref3 = widgetTree.widgetMap[path] || {},
|
|
2029
1839
|
instance = _ref3.instance;
|
|
2030
1840
|
if (reactions && Array.isArray(reactions)) {
|
|
@@ -2036,13 +1846,13 @@
|
|
|
2036
1846
|
subscribePaths.forEach(function (p) {
|
|
2037
1847
|
var sourcePathItem = parsePath(p, instance);
|
|
2038
1848
|
if (typeof reaction.lifetime === 'string') {
|
|
2039
|
-
subscribe(sourcePathItem, "lifetime/".concat(reaction.lifetime), resolveReaction(path, targePath, reaction));
|
|
1849
|
+
subscribe(sourcePathItem, "lifetime/".concat(reaction.lifetime), resolveReaction(path, targePath, reaction, widgetTree));
|
|
2040
1850
|
}
|
|
2041
1851
|
if (typeof reaction.effect === 'string') {
|
|
2042
|
-
subscribe(sourcePathItem, "effect/".concat(reaction.effect), resolveReaction(path, targePath, reaction));
|
|
1852
|
+
subscribe(sourcePathItem, "effect/".concat(reaction.effect), resolveReaction(path, targePath, reaction, widgetTree));
|
|
2043
1853
|
}
|
|
2044
1854
|
if (!reaction.lifetime && !reaction.effect) {
|
|
2045
|
-
subscribe(sourcePathItem, 'valChange', resolveReaction(path, targePath, reaction));
|
|
1855
|
+
subscribe(sourcePathItem, 'valChange', resolveReaction(path, targePath, reaction, widgetTree));
|
|
2046
1856
|
}
|
|
2047
1857
|
});
|
|
2048
1858
|
});
|
|
@@ -9776,7 +9586,7 @@
|
|
|
9776
9586
|
};
|
|
9777
9587
|
};
|
|
9778
9588
|
// 设置表单项校验状态
|
|
9779
|
-
var setWidgetErrorTips = function setWidgetErrorTips(path, isError, errorMsg) {
|
|
9589
|
+
var setWidgetErrorTips = function setWidgetErrorTips(path, isError, errorMsg, widgetTree) {
|
|
9780
9590
|
var formItem = widgetTree.widgetMap[path];
|
|
9781
9591
|
var instance = formItem.instance;
|
|
9782
9592
|
if (formItem.type === 'node') {
|
|
@@ -9809,7 +9619,7 @@
|
|
|
9809
9619
|
* 校验单个表单项
|
|
9810
9620
|
* @param path 字段路径
|
|
9811
9621
|
*/
|
|
9812
|
-
var validateFormItem = function validateFormItem(path) {
|
|
9622
|
+
var validateFormItem = function validateFormItem(path, widgetTree) {
|
|
9813
9623
|
var _instance$schema;
|
|
9814
9624
|
// TODO 校验逻辑梳理
|
|
9815
9625
|
var formItem = widgetTree.widgetMap[path];
|
|
@@ -9849,7 +9659,7 @@
|
|
|
9849
9659
|
var errorsText = ajv.errorsText(schemaValidate.errors, {
|
|
9850
9660
|
separator: '\n'
|
|
9851
9661
|
});
|
|
9852
|
-
setWidgetErrorTips(path, true, errorsText);
|
|
9662
|
+
setWidgetErrorTips(path, true, errorsText, widgetTree);
|
|
9853
9663
|
return {
|
|
9854
9664
|
result: false,
|
|
9855
9665
|
message: errorsText,
|
|
@@ -9878,7 +9688,7 @@
|
|
|
9878
9688
|
_iterator.f();
|
|
9879
9689
|
}
|
|
9880
9690
|
if (isError) {
|
|
9881
|
-
setWidgetErrorTips(path, true, errorMsg);
|
|
9691
|
+
setWidgetErrorTips(path, true, errorMsg, widgetTree);
|
|
9882
9692
|
return {
|
|
9883
9693
|
result: false,
|
|
9884
9694
|
message: errorMsg,
|
|
@@ -9894,24 +9704,24 @@
|
|
|
9894
9704
|
/**
|
|
9895
9705
|
* 校验整个表单
|
|
9896
9706
|
*/
|
|
9897
|
-
var validateForm = function validateForm() {
|
|
9707
|
+
var validateForm = function validateForm(widgetTree) {
|
|
9898
9708
|
var isValid = true;
|
|
9899
9709
|
Object.keys(widgetTree.widgetMap).forEach(function (path) {
|
|
9900
9710
|
var _validateFormItem;
|
|
9901
|
-
if (!((_validateFormItem = validateFormItem(path)) !== null && _validateFormItem !== void 0 && _validateFormItem.result)) isValid = false;
|
|
9711
|
+
if (!((_validateFormItem = validateFormItem(path, widgetTree)) !== null && _validateFormItem !== void 0 && _validateFormItem.result)) isValid = false;
|
|
9902
9712
|
});
|
|
9903
9713
|
return isValid;
|
|
9904
9714
|
};
|
|
9905
9715
|
/**
|
|
9906
9716
|
* 校验表单(抛出具体错误信息)
|
|
9907
9717
|
*/
|
|
9908
|
-
var validateFormWithResult = function validateFormWithResult() {
|
|
9718
|
+
var validateFormWithResult = function validateFormWithResult(widgetTree) {
|
|
9909
9719
|
return new Promise(function (resolve, reject) {
|
|
9910
9720
|
var result = Object.keys(widgetTree.widgetMap).filter(function (path) {
|
|
9911
9721
|
var _widgetTree$widgetMap;
|
|
9912
9722
|
return ((_widgetTree$widgetMap = widgetTree.widgetMap[path]) === null || _widgetTree$widgetMap === void 0 ? void 0 : _widgetTree$widgetMap.type) === 'node';
|
|
9913
9723
|
}).reduce(function (pre, path) {
|
|
9914
|
-
var validateResult = validateFormItem(path);
|
|
9724
|
+
var validateResult = validateFormItem(path, widgetTree);
|
|
9915
9725
|
if (!(validateResult !== null && validateResult !== void 0 && validateResult.result)) {
|
|
9916
9726
|
pre.push(validateResult);
|
|
9917
9727
|
}
|
|
@@ -9954,8 +9764,8 @@
|
|
|
9954
9764
|
* 触发校验
|
|
9955
9765
|
* @param path 字段路径
|
|
9956
9766
|
*/
|
|
9957
|
-
var dispatchValidate = function dispatchValidate(path) {
|
|
9958
|
-
return validateFormItem(path);
|
|
9767
|
+
var dispatchValidate = function dispatchValidate(path, widgetTree) {
|
|
9768
|
+
return validateFormItem(path, widgetTree);
|
|
9959
9769
|
};
|
|
9960
9770
|
|
|
9961
9771
|
// 事件订阅器
|
|
@@ -10045,6 +9855,7 @@
|
|
|
10045
9855
|
var Widget = Vue__default["default"].extend({
|
|
10046
9856
|
name: 'Widget',
|
|
10047
9857
|
props: props,
|
|
9858
|
+
inject: ['widgetTree'],
|
|
10048
9859
|
data: function data() {
|
|
10049
9860
|
return {
|
|
10050
9861
|
loading: false,
|
|
@@ -10063,10 +9874,10 @@
|
|
|
10063
9874
|
},
|
|
10064
9875
|
computed: {
|
|
10065
9876
|
widgetMap: function widgetMap() {
|
|
10066
|
-
return widgetTree.widgetMap;
|
|
9877
|
+
return this.widgetTree.widgetMap;
|
|
10067
9878
|
},
|
|
10068
9879
|
widgetNode: function widgetNode() {
|
|
10069
|
-
return widgetTree.widgetMap[this.path];
|
|
9880
|
+
return this.widgetTree.widgetMap[this.path];
|
|
10070
9881
|
},
|
|
10071
9882
|
parent: function parent() {
|
|
10072
9883
|
var _this$widgetNode;
|
|
@@ -10084,7 +9895,7 @@
|
|
|
10084
9895
|
if (!deepEquals(newValue, oldValue)) {
|
|
10085
9896
|
setTimeout(function () {
|
|
10086
9897
|
reactionDispatch(_this.path, 'valChange');
|
|
10087
|
-
dispatchValidate(_this.path);
|
|
9898
|
+
dispatchValidate(_this.path, _this.widgetTree);
|
|
10088
9899
|
}, 0);
|
|
10089
9900
|
}
|
|
10090
9901
|
}
|
|
@@ -10116,17 +9927,17 @@
|
|
|
10116
9927
|
}
|
|
10117
9928
|
});
|
|
10118
9929
|
// 注册widget TreeNode
|
|
10119
|
-
widgetTree.addWidgetNode(this.path, this, 'node');
|
|
9930
|
+
this.widgetTree.addWidgetNode(this.path, this, 'node');
|
|
10120
9931
|
},
|
|
10121
9932
|
mounted: function mounted() {
|
|
10122
9933
|
// 注册联动
|
|
10123
|
-
reactionRegister(this.path, this.widgetSchema['ui:reactions']);
|
|
9934
|
+
reactionRegister(this.path, this.widgetSchema['ui:reactions'], this.widgetTree);
|
|
10124
9935
|
// 首次联动
|
|
10125
9936
|
reactionDispatch(this.path, 'valChange');
|
|
10126
9937
|
reactionDispatch(this.path, 'lifetime/init');
|
|
10127
9938
|
},
|
|
10128
9939
|
beforeDestroy: function beforeDestroy() {
|
|
10129
|
-
widgetTree.removeWidgetNode(this.path, this);
|
|
9940
|
+
this.widgetTree.removeWidgetNode(this.path, this);
|
|
10130
9941
|
reactionUnRegister(this.path);
|
|
10131
9942
|
},
|
|
10132
9943
|
methods: {
|
|
@@ -10947,6 +10758,7 @@
|
|
|
10947
10758
|
var TableWidget = Vue__default["default"].extend({
|
|
10948
10759
|
name: 'TableWidget',
|
|
10949
10760
|
props: props,
|
|
10761
|
+
inject: ['widgetTree'],
|
|
10950
10762
|
watch: {
|
|
10951
10763
|
value: {
|
|
10952
10764
|
immediate: true,
|
|
@@ -10956,9 +10768,9 @@
|
|
|
10956
10768
|
(_this$value = this.value) === null || _this$value === void 0 ? void 0 : _this$value.forEach(function (_, index) {
|
|
10957
10769
|
var path = "".concat(_this.path, ".").concat(index);
|
|
10958
10770
|
// 销毁上一次的缓存
|
|
10959
|
-
widgetTree.removeWidgetNode(path, null);
|
|
10771
|
+
_this.widgetTree.removeWidgetNode(path, null);
|
|
10960
10772
|
// 重新当前行的父节点
|
|
10961
|
-
widgetTree.addWidgetNode(path, null, 'group');
|
|
10773
|
+
_this.widgetTree.addWidgetNode(path, null, 'group');
|
|
10962
10774
|
});
|
|
10963
10775
|
}
|
|
10964
10776
|
}
|
|
@@ -11139,6 +10951,7 @@
|
|
|
11139
10951
|
|
|
11140
10952
|
var FieldGroupWrap = Vue__default["default"].extend({
|
|
11141
10953
|
name: 'FieldGroupWrap',
|
|
10954
|
+
inject: ['widgetTree'],
|
|
11142
10955
|
props: _objectSpread2(_objectSpread2({}, props), {}, {
|
|
11143
10956
|
// 组类型
|
|
11144
10957
|
type: {
|
|
@@ -11165,6 +10978,10 @@
|
|
|
11165
10978
|
hideEmptyRow: {
|
|
11166
10979
|
type: Boolean,
|
|
11167
10980
|
default: false
|
|
10981
|
+
},
|
|
10982
|
+
description: {
|
|
10983
|
+
type: String,
|
|
10984
|
+
default: ''
|
|
11168
10985
|
}
|
|
11169
10986
|
}),
|
|
11170
10987
|
data: function data() {
|
|
@@ -11178,14 +10995,14 @@
|
|
|
11178
10995
|
},
|
|
11179
10996
|
created: function created() {
|
|
11180
10997
|
// 注册widget TreeNode
|
|
11181
|
-
widgetTree.addWidgetNode(this.path, this, 'group');
|
|
10998
|
+
this.widgetTree.addWidgetNode(this.path, this, 'group');
|
|
11182
10999
|
},
|
|
11183
11000
|
mounted: function mounted() {
|
|
11184
11001
|
// 更新样式
|
|
11185
11002
|
this.$forceUpdate();
|
|
11186
11003
|
},
|
|
11187
11004
|
beforeDestroy: function beforeDestroy() {
|
|
11188
|
-
widgetTree.removeWidgetNode(this.path, this);
|
|
11005
|
+
this.widgetTree.removeWidgetNode(this.path, this);
|
|
11189
11006
|
},
|
|
11190
11007
|
methods: {
|
|
11191
11008
|
setState: function setState(key, value) {
|
|
@@ -11253,7 +11070,13 @@
|
|
|
11253
11070
|
}],
|
|
11254
11071
|
"style": schemaFormStyle
|
|
11255
11072
|
}, [title && this.showTitle ? h("span", {
|
|
11256
|
-
"
|
|
11073
|
+
"directives": [{
|
|
11074
|
+
name: "bk-tooltips",
|
|
11075
|
+
value: this.description
|
|
11076
|
+
}],
|
|
11077
|
+
"class": ['bk-schema-form-group-title', this.type, {
|
|
11078
|
+
'has-desc': !!this.description
|
|
11079
|
+
}]
|
|
11257
11080
|
}, [title, hasError ? h("span", {
|
|
11258
11081
|
"class": "bk-schema-form-group__error-tips"
|
|
11259
11082
|
}, [h("span", {
|
|
@@ -11721,6 +11544,197 @@
|
|
|
11721
11544
|
var css_248z = "";
|
|
11722
11545
|
styleInject(css_248z);
|
|
11723
11546
|
|
|
11547
|
+
var WidgetNode = /*#__PURE__*/function () {
|
|
11548
|
+
function WidgetNode(config) {
|
|
11549
|
+
_classCallCheck(this, WidgetNode);
|
|
11550
|
+
this.id = void 0;
|
|
11551
|
+
this.instance = void 0;
|
|
11552
|
+
this.parent = void 0;
|
|
11553
|
+
this.type = void 0;
|
|
11554
|
+
this.index = void 0;
|
|
11555
|
+
// todo
|
|
11556
|
+
this.children = void 0;
|
|
11557
|
+
var id = config.id,
|
|
11558
|
+
instance = config.instance,
|
|
11559
|
+
parent = config.parent,
|
|
11560
|
+
index = config.index,
|
|
11561
|
+
type = config.type,
|
|
11562
|
+
_config$children = config.children,
|
|
11563
|
+
children = _config$children === void 0 ? [] : _config$children;
|
|
11564
|
+
this.id = id;
|
|
11565
|
+
this.type = type;
|
|
11566
|
+
this.index = index;
|
|
11567
|
+
this.instance = instance;
|
|
11568
|
+
this.parent = parent;
|
|
11569
|
+
this.children = children;
|
|
11570
|
+
}
|
|
11571
|
+
// 当前node的值
|
|
11572
|
+
return _createClass(WidgetNode, [{
|
|
11573
|
+
key: "value",
|
|
11574
|
+
get: function get() {
|
|
11575
|
+
var _this$instance;
|
|
11576
|
+
return (_this$instance = this.instance) === null || _this$instance === void 0 ? void 0 : _this$instance.value;
|
|
11577
|
+
}
|
|
11578
|
+
// 是否含有可见子节点
|
|
11579
|
+
}, {
|
|
11580
|
+
key: "isChildrenVisible",
|
|
11581
|
+
get: function get() {
|
|
11582
|
+
if (this.type === 'node') {
|
|
11583
|
+
var _this$instance2;
|
|
11584
|
+
return (_this$instance2 = this.instance) === null || _this$instance2 === void 0 ? void 0 : _this$instance2.state.visible;
|
|
11585
|
+
}
|
|
11586
|
+
return this.children.some(function (child) {
|
|
11587
|
+
return child.isChildrenVisible;
|
|
11588
|
+
});
|
|
11589
|
+
}
|
|
11590
|
+
/**
|
|
11591
|
+
* 获取 parents
|
|
11592
|
+
*/
|
|
11593
|
+
}, {
|
|
11594
|
+
key: "parents",
|
|
11595
|
+
get: function get() {
|
|
11596
|
+
if (!this.parent) {
|
|
11597
|
+
return [];
|
|
11598
|
+
}
|
|
11599
|
+
return [].concat(_toConsumableArray(this.parent.parents), [this.parent]);
|
|
11600
|
+
}
|
|
11601
|
+
// 第一个子节点
|
|
11602
|
+
}, {
|
|
11603
|
+
key: "firstChild",
|
|
11604
|
+
get: function get() {
|
|
11605
|
+
return this.children[0] || null;
|
|
11606
|
+
}
|
|
11607
|
+
// 最后一个子节点
|
|
11608
|
+
}, {
|
|
11609
|
+
key: "lastChild",
|
|
11610
|
+
get: function get() {
|
|
11611
|
+
return this.children[this.children.length - 1] || null;
|
|
11612
|
+
}
|
|
11613
|
+
// 指定属性下的同胞节点
|
|
11614
|
+
}, {
|
|
11615
|
+
key: "getSibling",
|
|
11616
|
+
value: function getSibling(lastProp) {
|
|
11617
|
+
var _this$parent;
|
|
11618
|
+
var reg = new RegExp("".concat(Path.getPathLastProp(this.id) || '', "$"));
|
|
11619
|
+
var id = this.id.replace(reg, lastProp);
|
|
11620
|
+
return (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.children.find(function (node) {
|
|
11621
|
+
return node.id === id;
|
|
11622
|
+
});
|
|
11623
|
+
}
|
|
11624
|
+
// 获取所以同胞节点(不含自己)
|
|
11625
|
+
}, {
|
|
11626
|
+
key: "getSiblings",
|
|
11627
|
+
value: function getSiblings() {
|
|
11628
|
+
var _this$parent2,
|
|
11629
|
+
_this = this;
|
|
11630
|
+
return ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.children.filter(function (node) {
|
|
11631
|
+
return node.instance !== _this.instance;
|
|
11632
|
+
})) || [];
|
|
11633
|
+
}
|
|
11634
|
+
/**
|
|
11635
|
+
* 是否是叶子节点
|
|
11636
|
+
*/
|
|
11637
|
+
}, {
|
|
11638
|
+
key: "isLeaf",
|
|
11639
|
+
get: function get() {
|
|
11640
|
+
return !this.children.length;
|
|
11641
|
+
}
|
|
11642
|
+
}, {
|
|
11643
|
+
key: "appendChild",
|
|
11644
|
+
value: function appendChild(node) {
|
|
11645
|
+
var _this$children;
|
|
11646
|
+
var nodes = Array.isArray(node) ? node : [node];
|
|
11647
|
+
var offset = node.index !== undefined ? node.index : this.children.length;
|
|
11648
|
+
(_this$children = this.children).splice.apply(_this$children, [offset, 0].concat(_toConsumableArray(nodes)));
|
|
11649
|
+
this.children.slice(offset).forEach(function (node, index) {
|
|
11650
|
+
node.index = offset + index;
|
|
11651
|
+
});
|
|
11652
|
+
return nodes;
|
|
11653
|
+
}
|
|
11654
|
+
}, {
|
|
11655
|
+
key: "removeChild",
|
|
11656
|
+
value: function removeChild(node) {
|
|
11657
|
+
var _this2 = this;
|
|
11658
|
+
var nodes = Array.isArray(node) ? node : [node];
|
|
11659
|
+
var removedChildIndex = [];
|
|
11660
|
+
nodes.forEach(function (node) {
|
|
11661
|
+
var index = node.index;
|
|
11662
|
+
removedChildIndex.push(index);
|
|
11663
|
+
_this2.children.splice(index, 1);
|
|
11664
|
+
});
|
|
11665
|
+
var minIndex = Math.min.apply(Math, removedChildIndex);
|
|
11666
|
+
this.children.slice(minIndex).forEach(function (node, index) {
|
|
11667
|
+
node.index = minIndex + index;
|
|
11668
|
+
});
|
|
11669
|
+
return nodes;
|
|
11670
|
+
}
|
|
11671
|
+
}]);
|
|
11672
|
+
}();
|
|
11673
|
+
var WidgetTree = /*#__PURE__*/function () {
|
|
11674
|
+
function WidgetTree() {
|
|
11675
|
+
_classCallCheck(this, WidgetTree);
|
|
11676
|
+
this.widgetMap = {};
|
|
11677
|
+
}
|
|
11678
|
+
return _createClass(WidgetTree, [{
|
|
11679
|
+
key: "addWidgetNode",
|
|
11680
|
+
value: function addWidgetNode(path, instance, type, index) {
|
|
11681
|
+
if (path === '') {
|
|
11682
|
+
// 根节点
|
|
11683
|
+
var node = new WidgetNode({
|
|
11684
|
+
id: '',
|
|
11685
|
+
type: type,
|
|
11686
|
+
index: index,
|
|
11687
|
+
parent: null,
|
|
11688
|
+
instance: instance,
|
|
11689
|
+
children: []
|
|
11690
|
+
});
|
|
11691
|
+
this.widgetMap[path] = node;
|
|
11692
|
+
} else {
|
|
11693
|
+
// 普通节点
|
|
11694
|
+
var parentId = Path.getParentPath(path);
|
|
11695
|
+
var parentNode = this.widgetMap[parentId];
|
|
11696
|
+
var _node = new WidgetNode({
|
|
11697
|
+
id: (instance === null || instance === void 0 ? void 0 : instance.path) || path,
|
|
11698
|
+
type: type,
|
|
11699
|
+
index: index,
|
|
11700
|
+
parent: parentNode,
|
|
11701
|
+
instance: instance,
|
|
11702
|
+
children: []
|
|
11703
|
+
});
|
|
11704
|
+
if (!parentNode) {
|
|
11705
|
+
console.warn('Unexpected parent id, please check widget node', _node);
|
|
11706
|
+
} else {
|
|
11707
|
+
parentNode.appendChild(_node);
|
|
11708
|
+
}
|
|
11709
|
+
this.widgetMap[path] = _node;
|
|
11710
|
+
}
|
|
11711
|
+
}
|
|
11712
|
+
}, {
|
|
11713
|
+
key: "removeWidgetNode",
|
|
11714
|
+
value: function removeWidgetNode(path, instance) {
|
|
11715
|
+
var node = this.widgetMap[path];
|
|
11716
|
+
if (node) {
|
|
11717
|
+
if (node.parent) {
|
|
11718
|
+
var children = node.parent.children;
|
|
11719
|
+
var index = children.findIndex(function (item) {
|
|
11720
|
+
return item.instance === instance;
|
|
11721
|
+
});
|
|
11722
|
+
if (index > -1) {
|
|
11723
|
+
children.splice(index, 1);
|
|
11724
|
+
children.slice(index).forEach(function (node, i) {
|
|
11725
|
+
node.index = index + i;
|
|
11726
|
+
});
|
|
11727
|
+
}
|
|
11728
|
+
}
|
|
11729
|
+
if (node.instance === instance) {
|
|
11730
|
+
delete this.widgetMap[path];
|
|
11731
|
+
}
|
|
11732
|
+
}
|
|
11733
|
+
}
|
|
11734
|
+
}]);
|
|
11735
|
+
}();
|
|
11736
|
+
// export default new WidgetTree();
|
|
11737
|
+
|
|
11724
11738
|
var defaultOptions = {
|
|
11725
11739
|
namespace: 'bk',
|
|
11726
11740
|
components: {
|
|
@@ -11768,7 +11782,8 @@
|
|
|
11768
11782
|
data: function data() {
|
|
11769
11783
|
return {
|
|
11770
11784
|
rootData: {},
|
|
11771
|
-
formKey: 'bk-ui-form'
|
|
11785
|
+
formKey: 'bk-ui-form',
|
|
11786
|
+
widgetTree: new WidgetTree()
|
|
11772
11787
|
};
|
|
11773
11788
|
},
|
|
11774
11789
|
watch: {
|
|
@@ -11819,9 +11834,15 @@
|
|
|
11819
11834
|
this.$emit('change', newValue, oldValue);
|
|
11820
11835
|
}
|
|
11821
11836
|
},
|
|
11822
|
-
validateForm: validateForm
|
|
11823
|
-
|
|
11824
|
-
|
|
11837
|
+
validateForm: function validateForm$1() {
|
|
11838
|
+
return validateForm(this.widgetTree);
|
|
11839
|
+
},
|
|
11840
|
+
validateFormItem: function validateFormItem$1(path) {
|
|
11841
|
+
return validateFormItem(path, this.widgetTree);
|
|
11842
|
+
},
|
|
11843
|
+
validate: function validate() {
|
|
11844
|
+
return validateFormWithResult(this.widgetTree);
|
|
11845
|
+
},
|
|
11825
11846
|
validateSchema: validateSchema
|
|
11826
11847
|
},
|
|
11827
11848
|
render: function render(h) {
|
|
@@ -11864,6 +11885,11 @@
|
|
|
11864
11885
|
}
|
|
11865
11886
|
}
|
|
11866
11887
|
})]);
|
|
11888
|
+
},
|
|
11889
|
+
provide: function provide() {
|
|
11890
|
+
return {
|
|
11891
|
+
widgetTree: this.widgetTree
|
|
11892
|
+
};
|
|
11867
11893
|
}
|
|
11868
11894
|
});
|
|
11869
11895
|
}
|