form-driver 0.1.6 → 0.1.8
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.js +1 -1
- package/es/m3.js +16 -8
- package/lib/m3.js +16 -8
- package/package.json +2 -2
- package/src/types/MEnumType.ts +22 -21
- package/src/ui/editor/basic/ASelector.tsx +12 -3
package/es/m3.js
CHANGED
|
@@ -1503,10 +1503,10 @@ var MEnumType = {
|
|
|
1503
1503
|
return assembly.theme.READABLE_BLANK;
|
|
1504
1504
|
}
|
|
1505
1505
|
},
|
|
1506
|
-
standardValue: function standardValue(assembly, s,
|
|
1506
|
+
standardValue: function standardValue(assembly, s, value, strict) {
|
|
1507
1507
|
if (!strict) {
|
|
1508
1508
|
// value的类型各种可能都有,如果不要求严格,就不用处理了
|
|
1509
|
-
return
|
|
1509
|
+
return value;
|
|
1510
1510
|
}
|
|
1511
1511
|
|
|
1512
1512
|
var fs = MUtil.option(s);
|
|
@@ -1514,13 +1514,14 @@ var MEnumType = {
|
|
|
1514
1514
|
for (var _iterator3 = _createForOfIteratorHelperLoose$b(fs), _step3; !(_step3 = _iterator3()).done;) {
|
|
1515
1515
|
var f = _step3.value;
|
|
1516
1516
|
|
|
1517
|
-
|
|
1518
|
-
|
|
1517
|
+
// @ts-ignore
|
|
1518
|
+
if (MUtil.isEquals(f.value, _.isObject(value) ? value == null ? void 0 : value.value : value, s.tolerate)) {
|
|
1519
|
+
return value;
|
|
1519
1520
|
}
|
|
1520
1521
|
}
|
|
1521
1522
|
|
|
1522
1523
|
if (s.openOption || s.enumOpen) {
|
|
1523
|
-
return
|
|
1524
|
+
return value;
|
|
1524
1525
|
} else {
|
|
1525
1526
|
return undefined;
|
|
1526
1527
|
}
|
|
@@ -18420,8 +18421,15 @@ var ASelector = /*#__PURE__*/function (_BaseViewer) {
|
|
|
18420
18421
|
var options = this._enums.map(function (m, index) {
|
|
18421
18422
|
var _m$label;
|
|
18422
18423
|
|
|
18423
|
-
if (
|
|
18424
|
-
|
|
18424
|
+
if (_.isObject(value)) {
|
|
18425
|
+
// @ts-ignore
|
|
18426
|
+
if (value.value === m.value) {
|
|
18427
|
+
initIndex = index;
|
|
18428
|
+
}
|
|
18429
|
+
} else {
|
|
18430
|
+
if (value === m.value) {
|
|
18431
|
+
initIndex = index;
|
|
18432
|
+
}
|
|
18425
18433
|
}
|
|
18426
18434
|
|
|
18427
18435
|
return /*#__PURE__*/React.createElement(Select$1.Option, {
|
|
@@ -18491,7 +18499,7 @@ var ASelector = /*#__PURE__*/function (_BaseViewer) {
|
|
|
18491
18499
|
width: "100%"
|
|
18492
18500
|
},
|
|
18493
18501
|
onChange: function onChange(vv) {
|
|
18494
|
-
|
|
18502
|
+
_BaseViewer.prototype.changeValue.call(_this2, p != null && p.labelInValue ? _this2._enums[vv.value] : _this2._enums[vv].value);
|
|
18495
18503
|
}
|
|
18496
18504
|
}, p), options);
|
|
18497
18505
|
}
|
package/lib/m3.js
CHANGED
|
@@ -1523,10 +1523,10 @@ var MEnumType = {
|
|
|
1523
1523
|
return assembly.theme.READABLE_BLANK;
|
|
1524
1524
|
}
|
|
1525
1525
|
},
|
|
1526
|
-
standardValue: function standardValue(assembly, s,
|
|
1526
|
+
standardValue: function standardValue(assembly, s, value, strict) {
|
|
1527
1527
|
if (!strict) {
|
|
1528
1528
|
// value的类型各种可能都有,如果不要求严格,就不用处理了
|
|
1529
|
-
return
|
|
1529
|
+
return value;
|
|
1530
1530
|
}
|
|
1531
1531
|
|
|
1532
1532
|
var fs = MUtil.option(s);
|
|
@@ -1534,13 +1534,14 @@ var MEnumType = {
|
|
|
1534
1534
|
for (var _iterator3 = _createForOfIteratorHelperLoose$b(fs), _step3; !(_step3 = _iterator3()).done;) {
|
|
1535
1535
|
var f = _step3.value;
|
|
1536
1536
|
|
|
1537
|
-
|
|
1538
|
-
|
|
1537
|
+
// @ts-ignore
|
|
1538
|
+
if (MUtil.isEquals(f.value, ___default["default"].isObject(value) ? value == null ? void 0 : value.value : value, s.tolerate)) {
|
|
1539
|
+
return value;
|
|
1539
1540
|
}
|
|
1540
1541
|
}
|
|
1541
1542
|
|
|
1542
1543
|
if (s.openOption || s.enumOpen) {
|
|
1543
|
-
return
|
|
1544
|
+
return value;
|
|
1544
1545
|
} else {
|
|
1545
1546
|
return undefined;
|
|
1546
1547
|
}
|
|
@@ -18440,8 +18441,15 @@ var ASelector = /*#__PURE__*/function (_BaseViewer) {
|
|
|
18440
18441
|
var options = this._enums.map(function (m, index) {
|
|
18441
18442
|
var _m$label;
|
|
18442
18443
|
|
|
18443
|
-
if (
|
|
18444
|
-
|
|
18444
|
+
if (___default["default"].isObject(value)) {
|
|
18445
|
+
// @ts-ignore
|
|
18446
|
+
if (value.value === m.value) {
|
|
18447
|
+
initIndex = index;
|
|
18448
|
+
}
|
|
18449
|
+
} else {
|
|
18450
|
+
if (value === m.value) {
|
|
18451
|
+
initIndex = index;
|
|
18452
|
+
}
|
|
18445
18453
|
}
|
|
18446
18454
|
|
|
18447
18455
|
return /*#__PURE__*/React__default["default"].createElement(Select__default["default"].Option, {
|
|
@@ -18511,7 +18519,7 @@ var ASelector = /*#__PURE__*/function (_BaseViewer) {
|
|
|
18511
18519
|
width: "100%"
|
|
18512
18520
|
},
|
|
18513
18521
|
onChange: function onChange(vv) {
|
|
18514
|
-
|
|
18522
|
+
_BaseViewer.prototype.changeValue.call(_this2, p != null && p.labelInValue ? _this2._enums[vv.value] : _this2._enums[vv].value);
|
|
18515
18523
|
}
|
|
18516
18524
|
}, p), options);
|
|
18517
18525
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "form-driver",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "An efficient framework for creating forms.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"authors": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"b": "npm run clean && npm run build",
|
|
15
15
|
"i": "yarn",
|
|
16
16
|
"ri": "rm -rf node_modules && npm run i",
|
|
17
|
-
"pub": "npm run b && npm version patch && npm publish && git push",
|
|
17
|
+
"pub": "git add . && git commit -m 'update' & npm run b && npm version patch && npm publish && git push",
|
|
18
18
|
"patch": "npm version patch && npm publish && git push",
|
|
19
19
|
"submodule": "git submodule update --init",
|
|
20
20
|
"ut-pull": "cd ./demo/src/ut_autoTest/ut_case && git pull",
|
package/src/types/MEnumType.ts
CHANGED
|
@@ -1,65 +1,66 @@
|
|
|
1
1
|
import { MUtil } from "../framework/MUtil";
|
|
2
|
-
import {MValidationResult, MFieldSchemaAnonymity} from '../framework/Schema';
|
|
3
|
-
import { MType} from "./MType";
|
|
2
|
+
import { MValidationResult, MFieldSchemaAnonymity } from '../framework/Schema';
|
|
3
|
+
import { MType } from "./MType";
|
|
4
4
|
import { validateRequired } from "../framework/Validator";
|
|
5
5
|
import { Assembly, assembly } from '../framework/Assembly';
|
|
6
6
|
import _ from "lodash";
|
|
7
7
|
|
|
8
8
|
// 选项是否合法、开放选项是否合法
|
|
9
|
-
function validateCandidate(a:Assembly, schema:MFieldSchemaAnonymity, value:any, path:string): MValidationResult {
|
|
9
|
+
function validateCandidate(a: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string): MValidationResult {
|
|
10
10
|
let fs = MUtil.option(schema);
|
|
11
11
|
console.log('validateCandidate', value)
|
|
12
|
-
for(let f of fs){
|
|
12
|
+
for (let f of fs) {
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
if(MUtil.isEquals(f.value, _.isObject(value) ? value?.value : value, schema.tolerate)){
|
|
14
|
+
if (MUtil.isEquals(f.value, _.isObject(value) ? value?.value : value, schema.tolerate)) {
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
const openOption = _.clone(schema.openOption ?? schema.enumOpen)
|
|
19
|
-
if(openOption){
|
|
19
|
+
if (openOption) {
|
|
20
20
|
openOption.required = true; // 既然勾上了开放选项,就必须填, TODO 把开放选项标注成必填,可以在schema预处理做
|
|
21
21
|
return assembly.validate(openOption, value, "")
|
|
22
22
|
}
|
|
23
|
-
return {message:'请选择一个选项', path}
|
|
23
|
+
return { message: '请选择一个选项', path }
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export const MEnumType: MType = {
|
|
27
27
|
validators: [validateRequired, validateCandidate],
|
|
28
28
|
|
|
29
|
-
createDefaultValue: (assembly:Assembly, s:MFieldSchemaAnonymity):any =>{
|
|
30
|
-
if(s.defaultValue){
|
|
29
|
+
createDefaultValue: (assembly: Assembly, s: MFieldSchemaAnonymity): any => {
|
|
30
|
+
if (s.defaultValue) {
|
|
31
31
|
return _.clone(s.defaultValue);
|
|
32
32
|
} else {
|
|
33
33
|
return undefined;
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
|
|
37
|
-
toReadable: (assembly:Assembly, s:MFieldSchemaAnonymity, v:any):string => {
|
|
37
|
+
toReadable: (assembly: Assembly, s: MFieldSchemaAnonymity, v: any): string => {
|
|
38
38
|
const fs = MUtil.option(s);
|
|
39
|
-
for(let f of fs) {
|
|
40
|
-
if(f.value === v){
|
|
39
|
+
for (let f of fs) {
|
|
40
|
+
if (f.value === v) {
|
|
41
41
|
return f.label ?? v;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
if(s.openOption){
|
|
44
|
+
if (s.openOption) {
|
|
45
45
|
return v;
|
|
46
46
|
} else {
|
|
47
47
|
return assembly.theme.READABLE_BLANK;
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
|
|
51
|
-
standardValue: (assembly:Assembly, s:MFieldSchemaAnonymity,
|
|
52
|
-
if(!strict) { // value的类型各种可能都有,如果不要求严格,就不用处理了
|
|
53
|
-
return
|
|
51
|
+
standardValue: (assembly: Assembly, s: MFieldSchemaAnonymity, value: any, strict: boolean): any => {
|
|
52
|
+
if (!strict) { // value的类型各种可能都有,如果不要求严格,就不用处理了
|
|
53
|
+
return value;
|
|
54
54
|
}
|
|
55
55
|
const fs = MUtil.option(s);
|
|
56
|
-
for(let f of fs){
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
for (let f of fs) {
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
if (MUtil.isEquals(f.value, _.isObject(value) ? value?.value : value, s.tolerate)) {
|
|
59
|
+
return value;
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
if(s.openOption || s.enumOpen) {
|
|
62
|
-
return
|
|
62
|
+
if (s.openOption || s.enumOpen) {
|
|
63
|
+
return value;
|
|
63
64
|
} else {
|
|
64
65
|
return undefined;
|
|
65
66
|
}
|
|
@@ -43,8 +43,15 @@ export class ASelector extends BaseViewer {
|
|
|
43
43
|
} else {
|
|
44
44
|
let initIndex = undefined;
|
|
45
45
|
const options = this._enums.map((m, index) => {
|
|
46
|
-
if (
|
|
47
|
-
|
|
46
|
+
if (_.isObject(value)) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
if (value.value === m.value) {
|
|
49
|
+
initIndex = index;
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
if (value === m.value) {
|
|
53
|
+
initIndex = index;
|
|
54
|
+
}
|
|
48
55
|
}
|
|
49
56
|
return <Select.Option key={index} value={index}>{m.label ?? m.value}</Select.Option>
|
|
50
57
|
});
|
|
@@ -78,7 +85,9 @@ export class ASelector extends BaseViewer {
|
|
|
78
85
|
: menu
|
|
79
86
|
}}
|
|
80
87
|
style={{ width: "100%" }}
|
|
81
|
-
onChange={(vv: any) =>
|
|
88
|
+
onChange={(vv: any) => {
|
|
89
|
+
super.changeValue(p?.labelInValue ? this._enums[vv.value] : this._enums[vv].value)
|
|
90
|
+
}}
|
|
82
91
|
{...p}
|
|
83
92
|
>
|
|
84
93
|
{options}
|