form-driver 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/m3.css +1 -1
- package/dist/m3.js +1 -1
- package/es/m3.css +1 -1
- package/es/m3.js +99 -111
- package/lib/m3.css +1 -1
- package/lib/m3.js +99 -111
- package/package.json +1 -1
- package/src/ui/editor/complex/ACheckDrag.tsx +46 -40
- package/src/ui/widget/SortDrag.less +1 -1
- package/src/ui/widget/SortDrag.tsx +1 -14
package/es/m3.css
CHANGED
package/es/m3.js
CHANGED
|
@@ -19478,7 +19478,7 @@ var SortDrag = /*#__PURE__*/memo(function (props) {
|
|
|
19478
19478
|
var sortList = props.sortList,
|
|
19479
19479
|
changeOriginDataSource = props.changeOriginDataSource;
|
|
19480
19480
|
|
|
19481
|
-
var _useState = useState(
|
|
19481
|
+
var _useState = useState(sortList),
|
|
19482
19482
|
items = _useState[0],
|
|
19483
19483
|
setItems = _useState[1]; // 记录当前拖拽的 item id
|
|
19484
19484
|
|
|
@@ -19577,22 +19577,6 @@ var SortDrag = /*#__PURE__*/memo(function (props) {
|
|
|
19577
19577
|
});
|
|
19578
19578
|
};
|
|
19579
19579
|
}, [items]);
|
|
19580
|
-
useEffect(function () {
|
|
19581
|
-
var checkedItems = sortList.filter(function (item) {
|
|
19582
|
-
return item.isChecked;
|
|
19583
|
-
}).sort(function (a, b) {
|
|
19584
|
-
return a.checkedIndex - b.checkedIndex;
|
|
19585
|
-
});
|
|
19586
|
-
var unCheckedItems = sortList.filter(function (item) {
|
|
19587
|
-
return !item.isChecked;
|
|
19588
|
-
});
|
|
19589
|
-
console.log("DRAG: 排序之后实际展示的数据", {
|
|
19590
|
-
sortList: sortList,
|
|
19591
|
-
checkedItems: checkedItems,
|
|
19592
|
-
unCheckedItems: unCheckedItems
|
|
19593
|
-
});
|
|
19594
|
-
setItems([].concat(checkedItems, unCheckedItems));
|
|
19595
|
-
}, [sortList]);
|
|
19596
19580
|
return jsx("div", {
|
|
19597
19581
|
className: "sortDrag",
|
|
19598
19582
|
children: items.map(function (item, index) {
|
|
@@ -19697,15 +19681,12 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19697
19681
|
};
|
|
19698
19682
|
|
|
19699
19683
|
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState, snapshot) {
|
|
19700
|
-
|
|
19701
|
-
|
|
19702
|
-
setTimeout(function () {
|
|
19703
|
-
console.log("DRAG: 组件更新", _this2.checkFields, _this2.state.data);
|
|
19684
|
+
setTimeout(function () {// console.log("DRAG: 组件更新", this.checkFields, this.state.data);
|
|
19704
19685
|
}, 2000);
|
|
19705
19686
|
};
|
|
19706
19687
|
|
|
19707
19688
|
_proto.element = function element(ctx) {
|
|
19708
|
-
var
|
|
19689
|
+
var _this2 = this,
|
|
19709
19690
|
_ref;
|
|
19710
19691
|
|
|
19711
19692
|
var data = this.state.data;
|
|
@@ -19720,30 +19701,30 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19720
19701
|
var checkboxs = this.checkFields.map(function (m, index) {
|
|
19721
19702
|
var _ctx$rootProps$schema;
|
|
19722
19703
|
|
|
19723
|
-
var isShow = MUtil.isShow(
|
|
19704
|
+
var isShow = MUtil.isShow(_this2.props.database, (_ctx$rootProps$schema = ctx.rootProps.schema) == null ? void 0 : _ctx$rootProps$schema.objectFields, m.showIf);
|
|
19724
19705
|
if (!isShow) return null;
|
|
19725
19706
|
var checkIndex = values == null ? void 0 : values.findIndex(function (e) {
|
|
19726
19707
|
return e === m.value;
|
|
19727
19708
|
});
|
|
19728
19709
|
|
|
19729
19710
|
if (m.remark === "openOption") {
|
|
19730
|
-
var
|
|
19711
|
+
var _this2$props$schema$o;
|
|
19731
19712
|
|
|
19732
|
-
var key =
|
|
19713
|
+
var key = _this2._inputBoxValue;
|
|
19733
19714
|
var checked = values == null ? void 0 : values.findIndex(function (e) {
|
|
19734
19715
|
return e === key;
|
|
19735
19716
|
});
|
|
19736
19717
|
return [jsxs(DIYCheckbox, {
|
|
19737
|
-
disabled:
|
|
19718
|
+
disabled: _this2.props.disable,
|
|
19738
19719
|
checked: checked !== -1,
|
|
19739
19720
|
checkedIcon: checked ? checked + 1 : 1,
|
|
19740
19721
|
onChange: function onChange(e) {
|
|
19741
|
-
var max =
|
|
19722
|
+
var max = _this2.props.schema.max;
|
|
19742
19723
|
|
|
19743
19724
|
if (max > 0 && e.target.checked) {
|
|
19744
19725
|
var len = values ? values.length : 0; // 选择第 max + 1 项时,提示并组织
|
|
19745
19726
|
|
|
19746
|
-
if (len >=
|
|
19727
|
+
if (len >= _this2.props.schema.max) {
|
|
19747
19728
|
Modal.info({
|
|
19748
19729
|
title: "\u6B64\u9898\u6700\u591A\u53EA\u80FD\u9009\u62E9 " + max + " \u9879",
|
|
19749
19730
|
okText: "确认",
|
|
@@ -19755,13 +19736,13 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19755
19736
|
}
|
|
19756
19737
|
}
|
|
19757
19738
|
|
|
19758
|
-
var currentCheckValue = MSetType.change(e.target.checked, key, values,
|
|
19759
|
-
|
|
19760
|
-
|
|
19739
|
+
var currentCheckValue = MSetType.change(e.target.checked, key, values, _this2.props.schema, true); // console.log("当前选中的数据ccc", currentCheckValue);
|
|
19740
|
+
|
|
19741
|
+
_this2.dataRef = currentCheckValue;
|
|
19761
19742
|
setTimeout(function () {
|
|
19762
|
-
_Viewer.prototype.changeValue.call(
|
|
19743
|
+
_Viewer.prototype.changeValue.call(_this2, currentCheckValue);
|
|
19763
19744
|
|
|
19764
|
-
|
|
19745
|
+
_this2.setState({
|
|
19765
19746
|
data: currentCheckValue
|
|
19766
19747
|
});
|
|
19767
19748
|
}, 0);
|
|
@@ -19770,36 +19751,35 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19770
19751
|
style: {
|
|
19771
19752
|
marginRight: "10px"
|
|
19772
19753
|
},
|
|
19773
|
-
children: (
|
|
19754
|
+
children: (_this2$props$schema$o = _this2.props.schema.openOption.label) != null ? _this2$props$schema$o : "其他"
|
|
19774
19755
|
}), jsx("span", {
|
|
19775
19756
|
onBlurCapture: function onBlurCapture(e) {
|
|
19776
|
-
console.log("输入框失去焦点",
|
|
19757
|
+
// console.log("输入框失去焦点", this.dataRef);
|
|
19777
19758
|
setTimeout(function () {
|
|
19778
|
-
_Viewer.prototype.changeValue.call(
|
|
19759
|
+
_Viewer.prototype.changeValue.call(_this2, _this2.dataRef);
|
|
19779
19760
|
|
|
19780
|
-
|
|
19781
|
-
data:
|
|
19761
|
+
_this2.setState({
|
|
19762
|
+
data: _this2.dataRef
|
|
19782
19763
|
});
|
|
19783
19764
|
}, 0);
|
|
19784
19765
|
},
|
|
19785
19766
|
children: jsx(MFieldViewer, {
|
|
19786
|
-
morph:
|
|
19787
|
-
schema:
|
|
19788
|
-
database:
|
|
19767
|
+
morph: _this2.props.morph,
|
|
19768
|
+
schema: _this2.props.schema.openOption,
|
|
19769
|
+
database: _this2,
|
|
19789
19770
|
path: "_inputBoxValue",
|
|
19790
19771
|
afterChange: function afterChange(path, str, final) {
|
|
19791
|
-
var matchEnum =
|
|
19772
|
+
var matchEnum = _this2.checkFields.find(function (e) {
|
|
19792
19773
|
return e.value === str && e.remark !== "openOption";
|
|
19793
|
-
});
|
|
19774
|
+
}); // console.log("输入框 afterChange", str, values, matchEnum);
|
|
19794
19775
|
|
|
19795
|
-
console.log("输入框 afterChange", str, values, matchEnum);
|
|
19796
19776
|
|
|
19797
19777
|
if (matchEnum) {
|
|
19798
19778
|
// 不能让用户输入某个枚举值
|
|
19799
|
-
|
|
19779
|
+
_this2._inputBoxValue = "";
|
|
19800
19780
|
|
|
19801
19781
|
_.remove(values, function (e) {
|
|
19802
|
-
return !
|
|
19782
|
+
return !_this2.checkValues.includes(e);
|
|
19803
19783
|
});
|
|
19804
19784
|
|
|
19805
19785
|
if (!values.includes(str)) {
|
|
@@ -19807,15 +19787,15 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19807
19787
|
}
|
|
19808
19788
|
|
|
19809
19789
|
queueMicrotask(function () {
|
|
19810
|
-
_Viewer.prototype.changeValueEx.call(
|
|
19790
|
+
_Viewer.prototype.changeValueEx.call(_this2, values, true, final);
|
|
19811
19791
|
|
|
19812
|
-
|
|
19792
|
+
_this2.setState({
|
|
19813
19793
|
data: values
|
|
19814
19794
|
});
|
|
19815
19795
|
});
|
|
19816
19796
|
} else {
|
|
19817
19797
|
var idx = values.findIndex(function (v) {
|
|
19818
|
-
var index =
|
|
19798
|
+
var index = _this2.checkFields.filter(function (e) {
|
|
19819
19799
|
return e.remark !== "openOption";
|
|
19820
19800
|
}).findIndex(function (e) {
|
|
19821
19801
|
return e.value === v;
|
|
@@ -19825,24 +19805,24 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19825
19805
|
});
|
|
19826
19806
|
|
|
19827
19807
|
if (!_.isNil(idx) || str === "") {
|
|
19828
|
-
|
|
19808
|
+
_this2._inputBoxValue = str;
|
|
19829
19809
|
values[idx] = str;
|
|
19830
|
-
|
|
19831
|
-
|
|
19810
|
+
_this2.dataRef = values;
|
|
19811
|
+
_this2.checkFields = _this2.checkFields.map(function (e) {
|
|
19832
19812
|
return e.remark === "openOption" ? _objectSpread$9(_objectSpread$9({}, e), {}, {
|
|
19833
19813
|
value: str
|
|
19834
19814
|
}) : e;
|
|
19835
|
-
});
|
|
19836
|
-
|
|
19837
|
-
|
|
19838
|
-
|
|
19839
|
-
|
|
19840
|
-
|
|
19841
|
-
MUtil.set(
|
|
19815
|
+
}); // console.log("输入框数据", {
|
|
19816
|
+
// values,
|
|
19817
|
+
// checkFields: this.checkFields,
|
|
19818
|
+
// dataRef: this.dataRef,
|
|
19819
|
+
// });
|
|
19820
|
+
|
|
19821
|
+
MUtil.set(_this2.props.database, _this2.props.path, values);
|
|
19842
19822
|
}
|
|
19843
19823
|
}
|
|
19844
19824
|
},
|
|
19845
|
-
parent:
|
|
19825
|
+
parent: _this2.props.schema,
|
|
19846
19826
|
forceValid: false,
|
|
19847
19827
|
disable: openIndex < 0,
|
|
19848
19828
|
style: {
|
|
@@ -19850,22 +19830,22 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19850
19830
|
}
|
|
19851
19831
|
})
|
|
19852
19832
|
})]
|
|
19853
|
-
}, "openOption"),
|
|
19833
|
+
}, "openOption"), _this2._createBr()];
|
|
19854
19834
|
}
|
|
19855
19835
|
|
|
19856
19836
|
return [jsx(DIYCheckbox, {
|
|
19857
|
-
disabled:
|
|
19837
|
+
disabled: _this2.props.disable,
|
|
19858
19838
|
checkedIcon: checkIndex === -1 ? 1 : checkIndex + 1,
|
|
19859
19839
|
checked: _.includes(values, m.value),
|
|
19860
19840
|
onChange: function onChange(e) {
|
|
19861
|
-
var currentCheckValue = MSetType.change(e.target.checked, m.value, values,
|
|
19862
|
-
|
|
19863
|
-
var max =
|
|
19841
|
+
var currentCheckValue = MSetType.change(e.target.checked, m.value, values, _this2.props.schema, true); // console.log("当前变化的 value", values, currentCheckValue);
|
|
19842
|
+
|
|
19843
|
+
var max = _this2.props.schema.max;
|
|
19864
19844
|
|
|
19865
19845
|
if (max > 0 && e.target.checked) {
|
|
19866
19846
|
var len = values ? values.length : 0; // 选择第 max + 1 项时,提示并组织
|
|
19867
19847
|
|
|
19868
|
-
if (len >=
|
|
19848
|
+
if (len >= _this2.props.schema.max) {
|
|
19869
19849
|
Modal.info({
|
|
19870
19850
|
title: "\u6B64\u9898\u6700\u591A\u53EA\u80FD\u9009\u62E9 " + max + " \u9879",
|
|
19871
19851
|
okText: "确认",
|
|
@@ -19877,22 +19857,22 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19877
19857
|
}
|
|
19878
19858
|
}
|
|
19879
19859
|
|
|
19880
|
-
|
|
19860
|
+
_this2.dataRef = currentCheckValue;
|
|
19881
19861
|
queueMicrotask(function () {
|
|
19882
|
-
_Viewer.prototype.changeValue.call(
|
|
19862
|
+
_Viewer.prototype.changeValue.call(_this2, currentCheckValue);
|
|
19883
19863
|
|
|
19884
|
-
|
|
19864
|
+
_this2.setState({
|
|
19885
19865
|
data: currentCheckValue
|
|
19886
19866
|
});
|
|
19887
19867
|
});
|
|
19888
19868
|
},
|
|
19889
19869
|
children: ACheckBoxLabel(m)
|
|
19890
|
-
}, m.value),
|
|
19870
|
+
}, m.value), _this2._createBr()];
|
|
19891
19871
|
}); // 定义更换数据源的方法
|
|
19892
19872
|
|
|
19893
19873
|
var changeOriginDataSource = function changeOriginDataSource(newData) {
|
|
19894
|
-
console.log("新数据", newData);
|
|
19895
|
-
|
|
19874
|
+
// console.log("新数据", newData);
|
|
19875
|
+
// 更新排序后的选项数据
|
|
19896
19876
|
var sortedCheckFields = newData.map(function (item) {
|
|
19897
19877
|
return _objectSpread$9(_objectSpread$9({}, item), {}, {
|
|
19898
19878
|
label: item.label,
|
|
@@ -19906,12 +19886,12 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19906
19886
|
return item.id;
|
|
19907
19887
|
}); // 同时更新schema中的option顺序,以确保后续操作基于新的排序
|
|
19908
19888
|
|
|
19909
|
-
var newSchema = _objectSpread$9({},
|
|
19889
|
+
var newSchema = _objectSpread$9({}, _this2.props.schema);
|
|
19910
19890
|
|
|
19911
19891
|
var isHaveOpenOption = sortedCheckFields.filter(function (e) {
|
|
19912
19892
|
return e.remark === "openOption";
|
|
19913
|
-
});
|
|
19914
|
-
|
|
19893
|
+
}); // console.log("isHaveOpenOption", isHaveOpenOption);
|
|
19894
|
+
|
|
19915
19895
|
newSchema.option = isHaveOpenOption ? sortedCheckFields == null ? void 0 : sortedCheckFields.filter(function (e) {
|
|
19916
19896
|
return e.remark !== "openOption";
|
|
19917
19897
|
}) : sortedCheckFields;
|
|
@@ -19922,52 +19902,60 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19922
19902
|
// newSchema,
|
|
19923
19903
|
// });
|
|
19924
19904
|
|
|
19925
|
-
|
|
19926
|
-
|
|
19905
|
+
_this2.checkFields = sortedCheckFields;
|
|
19906
|
+
_this2.dataRef = sortedData;
|
|
19927
19907
|
setTimeout(function () {
|
|
19928
|
-
|
|
19908
|
+
_this2.setState({
|
|
19929
19909
|
data: sortedData
|
|
19930
19910
|
});
|
|
19931
19911
|
|
|
19932
|
-
MUtil.set(
|
|
19912
|
+
MUtil.set(_this2.props.database, _this2.props.path, sortedData);
|
|
19933
19913
|
}, 0);
|
|
19934
19914
|
};
|
|
19935
19915
|
|
|
19936
|
-
|
|
19937
|
-
|
|
19938
|
-
|
|
19939
|
-
|
|
19940
|
-
|
|
19941
|
-
|
|
19942
|
-
|
|
19943
|
-
|
|
19916
|
+
var sortList = (_ref = checkboxs != null ? checkboxs : []) == null ? void 0 : _ref.map(function (cpn, index) {
|
|
19917
|
+
var _this2$checkFields$in, _this2$checkFields$in2, _this2$dataRef, _this2$dataRef2, _this2$checkFields$in3, _this2$checkFields$in4;
|
|
19918
|
+
|
|
19919
|
+
var checkFieldsValue;
|
|
19920
|
+
checkFieldsValue = (_this2$checkFields$in = _this2.checkFields[index]) == null ? void 0 : _this2$checkFields$in.value;
|
|
19921
|
+
var isOpenOp = ((_this2$checkFields$in2 = _this2.checkFields[index]) == null ? void 0 : _this2$checkFields$in2.remark) === "openOption";
|
|
19922
|
+
|
|
19923
|
+
if (isOpenOp) {
|
|
19924
|
+
checkFieldsValue = _this2._inputBoxValue;
|
|
19925
|
+
} // console.log("DRAG: 实际传递进如 SortDrag的数据", {
|
|
19926
|
+
// data,
|
|
19927
|
+
// dataRef: this.dataRef,
|
|
19928
|
+
// checkFields: this.checkFields,
|
|
19929
|
+
// schema: this.props.database,
|
|
19930
|
+
// isOpenOp,
|
|
19931
|
+
// openValue: this._inputBoxValue,
|
|
19932
|
+
// });
|
|
19944
19933
|
|
|
19945
|
-
if (isOpenOp) {
|
|
19946
|
-
checkFieldsValue = _this3._inputBoxValue;
|
|
19947
|
-
}
|
|
19948
19934
|
|
|
19949
|
-
|
|
19950
|
-
|
|
19951
|
-
|
|
19952
|
-
|
|
19953
|
-
|
|
19954
|
-
|
|
19955
|
-
|
|
19956
|
-
|
|
19957
|
-
|
|
19958
|
-
|
|
19959
|
-
|
|
19960
|
-
|
|
19961
|
-
checkedIndex: ((_this3$dataRef2 = _this3.dataRef) == null ? void 0 : _this3$dataRef2.findIndex(function (e) {
|
|
19962
|
-
return e === checkFieldsValue;
|
|
19963
|
-
})) + 1,
|
|
19964
|
-
cpn: cpn,
|
|
19965
|
-
id: "" + checkFieldsValue,
|
|
19966
|
-
label: (_this3$checkFields$in3 = _this3.checkFields[index]) == null ? void 0 : _this3$checkFields$in3.label,
|
|
19967
|
-
remark: (_this3$checkFields$in4 = _this3.checkFields[index]) == null ? void 0 : _this3$checkFields$in4.remark
|
|
19968
|
-
};
|
|
19969
|
-
})
|
|
19935
|
+
return {
|
|
19936
|
+
isChecked: _this2.dataRef ? ((_this2$dataRef = _this2.dataRef) == null ? void 0 : _this2$dataRef.findIndex(function (e) {
|
|
19937
|
+
return e === checkFieldsValue;
|
|
19938
|
+
})) !== -1 : false,
|
|
19939
|
+
checkedIndex: ((_this2$dataRef2 = _this2.dataRef) == null ? void 0 : _this2$dataRef2.findIndex(function (e) {
|
|
19940
|
+
return e === checkFieldsValue;
|
|
19941
|
+
})) + 1,
|
|
19942
|
+
cpn: cpn,
|
|
19943
|
+
id: "" + checkFieldsValue,
|
|
19944
|
+
label: (_this2$checkFields$in3 = _this2.checkFields[index]) == null ? void 0 : _this2$checkFields$in3.label,
|
|
19945
|
+
remark: (_this2$checkFields$in4 = _this2.checkFields[index]) == null ? void 0 : _this2$checkFields$in4.remark
|
|
19946
|
+
};
|
|
19970
19947
|
});
|
|
19948
|
+
var finalSortList = sortList.filter(function (item) {
|
|
19949
|
+
return item.isChecked;
|
|
19950
|
+
}).sort(function (a, b) {
|
|
19951
|
+
return a.checkedIndex - b.checkedIndex;
|
|
19952
|
+
}).concat(sortList.filter(function (item) {
|
|
19953
|
+
return !item.isChecked;
|
|
19954
|
+
}));
|
|
19955
|
+
return jsx(SortDrag, {
|
|
19956
|
+
changeOriginDataSource: changeOriginDataSource,
|
|
19957
|
+
sortList: finalSortList
|
|
19958
|
+
}, MUtil.unique());
|
|
19971
19959
|
};
|
|
19972
19960
|
|
|
19973
19961
|
return ACheckDrag;
|
package/lib/m3.css
CHANGED