form-driver 0.1.0

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 (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/dist/m3.css +310 -0
  4. package/dist/m3.js +1 -0
  5. package/es/m3.css +310 -0
  6. package/es/m3.js +20919 -0
  7. package/lib/m3.css +310 -0
  8. package/lib/m3.js +20959 -0
  9. package/package.json +132 -0
  10. package/src/.DS_Store +0 -0
  11. package/src/framework/Ajax.ts +96 -0
  12. package/src/framework/Assembly.tsx +165 -0
  13. package/src/framework/Init.tsx +196 -0
  14. package/src/framework/M3.tsx +94 -0
  15. package/src/framework/MContext.ts +15 -0
  16. package/src/framework/MFieldViewer.tsx +32 -0
  17. package/src/framework/MUtil.tsx +653 -0
  18. package/src/framework/MViewer.less +128 -0
  19. package/src/framework/MViewer.tsx +180 -0
  20. package/src/framework/MViewerDebug.tsx +95 -0
  21. package/src/framework/Persistant.ts +90 -0
  22. package/src/framework/Schema.ts +386 -0
  23. package/src/framework/SchemaFunc.ts +30 -0
  24. package/src/framework/Validator.ts +160 -0
  25. package/src/framework/editorMap.ts +109 -0
  26. package/src/index.ts +33 -0
  27. package/src/types/MArrayType.ts +73 -0
  28. package/src/types/MCascadeType.ts +35 -0
  29. package/src/types/MCnAddressType.ts +54 -0
  30. package/src/types/MDateRangeType.ts +52 -0
  31. package/src/types/MDateTimeType.ts +53 -0
  32. package/src/types/MDecorationType.ts +6 -0
  33. package/src/types/MEnumType.ts +65 -0
  34. package/src/types/MExperienceType.ts +81 -0
  35. package/src/types/MFloatType.ts +10 -0
  36. package/src/types/MGB2260Type.ts +56 -0
  37. package/src/types/MIntDiffType.ts +6 -0
  38. package/src/types/MIntType.ts +44 -0
  39. package/src/types/MKvSetType.ts +50 -0
  40. package/src/types/MMatrixType.ts +52 -0
  41. package/src/types/MObjectType.ts +89 -0
  42. package/src/types/MSetType.ts +220 -0
  43. package/src/types/MStringType.ts +27 -0
  44. package/src/types/MTelType.ts +14 -0
  45. package/src/types/MType.ts +77 -0
  46. package/src/types/MVLPairType.ts +35 -0
  47. package/src/types/gb2260.json +1 -0
  48. package/src/ui/BaseViewer.tsx +110 -0
  49. package/src/ui/editor/.DS_Store +0 -0
  50. package/src/ui/editor/basic/.DS_Store +0 -0
  51. package/src/ui/editor/basic/ACascadePicker.tsx +114 -0
  52. package/src/ui/editor/basic/ACheckBox.tsx +104 -0
  53. package/src/ui/editor/basic/ADatetimePicker.tsx +76 -0
  54. package/src/ui/editor/basic/AGB2260.tsx +52 -0
  55. package/src/ui/editor/basic/AInputBox.tsx +59 -0
  56. package/src/ui/editor/basic/AIntBox.tsx +39 -0
  57. package/src/ui/editor/basic/AKvSet.less +9 -0
  58. package/src/ui/editor/basic/AKvSet.tsx +90 -0
  59. package/src/ui/editor/basic/ARadio.tsx +86 -0
  60. package/src/ui/editor/basic/ARangePicker.tsx +129 -0
  61. package/src/ui/editor/basic/ARate.less +8 -0
  62. package/src/ui/editor/basic/ARate.tsx +37 -0
  63. package/src/ui/editor/basic/ARemoteSelector.tsx +116 -0
  64. package/src/ui/editor/basic/ASelector.tsx +88 -0
  65. package/src/ui/editor/basic/ASetSelector.tsx +65 -0
  66. package/src/ui/editor/basic/ASpecInputBox.tsx +20 -0
  67. package/src/ui/editor/basic/ATreeSelect.tsx +41 -0
  68. package/src/ui/editor/basic/AUpload.tsx +119 -0
  69. package/src/ui/editor/basic/NPS.less +21 -0
  70. package/src/ui/editor/basic/NPS.tsx +47 -0
  71. package/src/ui/editor/complex/AArray.less +10 -0
  72. package/src/ui/editor/complex/AArray.tsx +104 -0
  73. package/src/ui/editor/complex/AArrayGrid.tsx +115 -0
  74. package/src/ui/editor/complex/ACnAddress.less +15 -0
  75. package/src/ui/editor/complex/ACnAddress.tsx +61 -0
  76. package/src/ui/editor/complex/ADialogForm.tsx +45 -0
  77. package/src/ui/editor/complex/AExperience.tsx +85 -0
  78. package/src/ui/editor/complex/AForm.less +35 -0
  79. package/src/ui/editor/complex/AForm.tsx +340 -0
  80. package/src/ui/editor/complex/AIntDiff.tsx +77 -0
  81. package/src/ui/editor/complex/AMatrix.less +18 -0
  82. package/src/ui/editor/complex/AMatrix.tsx +242 -0
  83. package/src/ui/editor/complex/ATable.less +4 -0
  84. package/src/ui/editor/complex/ATable.tsx +33 -0
  85. package/src/ui/editor/complex/JsonEditor.tsx +37 -0
  86. package/src/ui/readable/A.tsx +33 -0
  87. package/src/ui/readable/ArrayViewer.tsx +46 -0
  88. package/src/ui/readable/DecorationViewer.tsx +76 -0
  89. package/src/ui/readable/DivViewer.tsx +11 -0
  90. package/src/ui/widget/Collapsible.tsx +156 -0
  91. package/src/ui/widget/Segment.less +39 -0
  92. package/src/ui/widget/Segment.tsx +40 -0
  93. package/src/ui/widget/SegmentEditSwitch.tsx +46 -0
  94. package/src/ui/widget/SelectBox.tsx +43 -0
  95. package/src/ui/widget/UnderlineInputBox.less +47 -0
  96. package/src/ui/widget/UnderlineInputBox.tsx +10 -0
  97. package/types/framework/Ajax.d.ts +5 -0
  98. package/types/framework/Assembly.d.ts +59 -0
  99. package/types/framework/Init.d.ts +4 -0
  100. package/types/framework/M3.d.ts +6 -0
  101. package/types/framework/MContext.d.ts +11 -0
  102. package/types/framework/MFieldViewer.d.ts +8 -0
  103. package/types/framework/MUtil.d.ts +180 -0
  104. package/types/framework/MViewer.d.ts +75 -0
  105. package/types/framework/MViewerDebug.d.ts +11 -0
  106. package/types/framework/Persistant.d.ts +17 -0
  107. package/types/framework/Schema.d.ts +306 -0
  108. package/types/framework/SchemaFunc.d.ts +14 -0
  109. package/types/framework/Validator.d.ts +53 -0
  110. package/types/framework/editorMap.d.ts +107 -0
  111. package/types/index.d.ts +21 -0
  112. package/types/types/MArrayType.d.ts +2 -0
  113. package/types/types/MCascadeType.d.ts +11 -0
  114. package/types/types/MCnAddressType.d.ts +2 -0
  115. package/types/types/MDateRangeType.d.ts +7 -0
  116. package/types/types/MDateTimeType.d.ts +11 -0
  117. package/types/types/MDecorationType.d.ts +7 -0
  118. package/types/types/MEnumType.d.ts +2 -0
  119. package/types/types/MExperienceType.d.ts +5 -0
  120. package/types/types/MFloatType.d.ts +2 -0
  121. package/types/types/MGB2260Type.d.ts +9 -0
  122. package/types/types/MIntDiffType.d.ts +2 -0
  123. package/types/types/MIntType.d.ts +2 -0
  124. package/types/types/MKvSetType.d.ts +11 -0
  125. package/types/types/MMatrixType.d.ts +5 -0
  126. package/types/types/MObjectType.d.ts +11 -0
  127. package/types/types/MSetType.d.ts +7 -0
  128. package/types/types/MStringType.d.ts +2 -0
  129. package/types/types/MTelType.d.ts +4 -0
  130. package/types/types/MType.d.ts +46 -0
  131. package/types/types/MVLPairType.d.ts +5 -0
  132. package/types/ui/BaseViewer.d.ts +45 -0
  133. package/types/ui/editor/basic/ACascadePicker.d.ts +11 -0
  134. package/types/ui/editor/basic/ACheckBox.d.ts +17 -0
  135. package/types/ui/editor/basic/ADatetimePicker.d.ts +15 -0
  136. package/types/ui/editor/basic/AGB2260.d.ts +10 -0
  137. package/types/ui/editor/basic/AInputBox.d.ts +8 -0
  138. package/types/ui/editor/basic/AIntBox.d.ts +9 -0
  139. package/types/ui/editor/basic/AKvSet.d.ts +19 -0
  140. package/types/ui/editor/basic/ARadio.d.ts +14 -0
  141. package/types/ui/editor/basic/ARangePicker.d.ts +30 -0
  142. package/types/ui/editor/basic/ARate.d.ts +13 -0
  143. package/types/ui/editor/basic/ARemoteSelector.d.ts +15 -0
  144. package/types/ui/editor/basic/ASelector.d.ts +14 -0
  145. package/types/ui/editor/basic/ASetSelector.d.ts +10 -0
  146. package/types/ui/editor/basic/ASpecInputBox.d.ts +9 -0
  147. package/types/ui/editor/basic/ATreeSelect.d.ts +18 -0
  148. package/types/ui/editor/basic/AUpload.d.ts +33 -0
  149. package/types/ui/editor/basic/NPS.d.ts +13 -0
  150. package/types/ui/editor/complex/AArray.d.ts +11 -0
  151. package/types/ui/editor/complex/AArrayGrid.d.ts +13 -0
  152. package/types/ui/editor/complex/ACnAddress.d.ts +10 -0
  153. package/types/ui/editor/complex/ADialogForm.d.ts +11 -0
  154. package/types/ui/editor/complex/AExperience.d.ts +16 -0
  155. package/types/ui/editor/complex/AForm.d.ts +46 -0
  156. package/types/ui/editor/complex/AIntDiff.d.ts +14 -0
  157. package/types/ui/editor/complex/AMatrix.d.ts +48 -0
  158. package/types/ui/editor/complex/ATable.d.ts +9 -0
  159. package/types/ui/editor/complex/JsonEditor.d.ts +9 -0
  160. package/types/ui/readable/A.d.ts +5 -0
  161. package/types/ui/readable/ArrayViewer.d.ts +5 -0
  162. package/types/ui/readable/DecorationViewer.d.ts +3 -0
  163. package/types/ui/readable/DivViewer.d.ts +5 -0
  164. package/types/ui/widget/Collapsible.d.ts +46 -0
  165. package/types/ui/widget/Segment.d.ts +18 -0
  166. package/types/ui/widget/SegmentEditSwitch.d.ts +20 -0
  167. package/types/ui/widget/SelectBox.d.ts +13 -0
  168. package/types/ui/widget/UnderlineInputBox.d.ts +6 -0
@@ -0,0 +1,14 @@
1
+ import { ValueConst } from './Schema';
2
+ /**
3
+ * schema里可以使用的函数都定义在这里
4
+ */
5
+ export declare const SchemaFunc: {
6
+ /**
7
+ * 是否选中shouldSelected中的某个选项.
8
+ *
9
+ * @param v 适用于enum/set/string/int
10
+ * @param shouldSelected 选中值
11
+ * @returns
12
+ */
13
+ is(v: any | any[], shouldSelected: ValueConst | ValueConst[]): boolean;
14
+ };
@@ -0,0 +1,53 @@
1
+ import { Assembly } from './Assembly';
2
+ import { MFieldSchemaAnonymity, MValidationResult } from './Schema';
3
+ export declare type VALIDATOR = (a: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string) => MValidationResult;
4
+ /**
5
+ * 非空校验,数据不能是null/undefined/""/NaN/[]
6
+ * 要在其他条件之前,以便required=false时短路掉nil的数据,否则后面的校验全都得处理nil
7
+ * @param a
8
+ * @param schema
9
+ * @param value
10
+ * @param path
11
+ * @returns
12
+ */
13
+ export declare function validateRequired(a: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string): MValidationResult;
14
+ /** 和validateRequired相同,但不短路 */
15
+ export declare function validateRequiredNS(a: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string): MValidationResult;
16
+ export declare function validateDateMinMax(a: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string): MValidationResult;
17
+ /**
18
+ * 数组项数不超过[min, max]
19
+ * @param schema
20
+ * @param value 应该是个数组
21
+ */
22
+ export declare function validateArrayItemMinMax(a: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string): MValidationResult;
23
+ /**
24
+ * 字符串长度不超过[min, max]
25
+ * @param schema
26
+ * @param value 应该是个字符串
27
+ */
28
+ export declare function validateStringMinMax(a: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string): MValidationResult;
29
+ /**
30
+ * 数字不超过[min, max]
31
+ * @param schema
32
+ * @param value 应该是个数字
33
+ */
34
+ export declare function validateNumberMinMax(a: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string): MValidationResult;
35
+ export declare function generateRegexValidate(regex: RegExp, mismatchMsg: string): VALIDATOR;
36
+ /**
37
+ * 数据用Object.prototype.toString.call返回的类型是预期的
38
+ * 可以用Object.prototype.toString.call(<预期的类型>)来查看你想要的数据类型的expectType
39
+ * @param expectType 预期类型,例如:"[object Object]" "[object Null]" "[object Number]" "[object Date]" "[object Array]"
40
+ * @param mismatchMsg 如果不匹配,提示的错误信息
41
+ * @returns
42
+ */
43
+ export declare function generateJsPrototypeValidate(expectType: string, mismatchMsg?: string): VALIDATOR;
44
+ export declare function generateSchemaValidate(valueSchema: MFieldSchemaAnonymity, mismatchMsg?: string): VALIDATOR;
45
+ declare const _default: {
46
+ validateRequired: typeof validateRequired;
47
+ validateRequiredNS: typeof validateRequiredNS;
48
+ validateDateMinMax: typeof validateDateMinMax;
49
+ validateStringMinMax: typeof validateStringMinMax;
50
+ validateNumberMinMax: typeof validateNumberMinMax;
51
+ generateRegexValidate: typeof generateRegexValidate;
52
+ };
53
+ export default _default;
@@ -0,0 +1,107 @@
1
+ declare const editorMap: {
2
+ AInputBox: {
3
+ editor: string;
4
+ type: string;
5
+ };
6
+ ARate: {
7
+ editor: string;
8
+ type: string;
9
+ };
10
+ NPS: {
11
+ editor: string;
12
+ type: string;
13
+ };
14
+ AIntBox: {
15
+ editor: string;
16
+ type: string;
17
+ };
18
+ AFloatBox: {
19
+ editor: string;
20
+ type: string;
21
+ };
22
+ ARadio: {
23
+ editor: string;
24
+ type: string;
25
+ };
26
+ ASelector: {
27
+ editor: string;
28
+ type: string;
29
+ };
30
+ ASetSelector: {
31
+ editor: string;
32
+ type: string;
33
+ };
34
+ ARemoteSelector: {
35
+ editor: string;
36
+ type: string;
37
+ };
38
+ AArrayGrid: {
39
+ editor: string;
40
+ type: string;
41
+ };
42
+ ACascadePicker: {
43
+ editor: string;
44
+ type: string;
45
+ };
46
+ AGB2260: {
47
+ editor: string;
48
+ type: string;
49
+ };
50
+ ARangePicker: {
51
+ editor: string;
52
+ type: string;
53
+ };
54
+ ADatetimePicker: {
55
+ editor: string;
56
+ type: string;
57
+ };
58
+ AYearPicker: {
59
+ editor: string;
60
+ type: string;
61
+ };
62
+ AYearMonthPicker: {
63
+ editor: string;
64
+ type: string;
65
+ };
66
+ AYearMonthDayPicker: {
67
+ editor: string;
68
+ type: string;
69
+ };
70
+ ACheckBox: {
71
+ editor: string;
72
+ type: string;
73
+ };
74
+ AArray: {
75
+ editor: string;
76
+ type: string;
77
+ };
78
+ AMatrix: {
79
+ editor: string;
80
+ type: string;
81
+ };
82
+ AExperience: {
83
+ editor: string;
84
+ type: string;
85
+ };
86
+ AKvSet: {
87
+ editor: string;
88
+ type: string;
89
+ };
90
+ ACnAddress: {
91
+ editor: string;
92
+ type: string;
93
+ };
94
+ ATelBox: {
95
+ editor: string;
96
+ type: string;
97
+ };
98
+ AEmailBox: {
99
+ editor: string;
100
+ type: string;
101
+ };
102
+ DecorationViewer: {
103
+ editor: string;
104
+ type: string;
105
+ };
106
+ };
107
+ export default editorMap;
@@ -0,0 +1,21 @@
1
+ import 'antd/dist/antd.css';
2
+ import 'antd-mobile/dist/antd-mobile.css';
3
+ import { Ajax } from './framework/Ajax';
4
+ import { M3UISpecSegmentItem, MFieldSchema, M3UISpec, MFieldSchemaAnonymity } from './framework/Schema';
5
+ import { MViewerDebug } from './framework/MViewerDebug';
6
+ import { MORPH, VIEWER, assembly, MTheme, Assembly } from './framework/Assembly';
7
+ import { ViewerState, Viewer, BaseViewer } from './ui/BaseViewer';
8
+ import { MViewer, SubmitBar, useM3Database } from './framework/MViewer';
9
+ import M3 from './framework/M3';
10
+ import { MFieldViewer } from './framework/MFieldViewer';
11
+ import { MContext } from './framework/MContext';
12
+ import { MUtil } from './framework/MUtil';
13
+ import { Segment } from "./ui/widget/Segment";
14
+ import { UnderlineInputBox } from './ui/widget/UnderlineInputBox';
15
+ import { SegmentEditSwitch, SegmentEditSwitchState } from './ui/widget/SegmentEditSwitch';
16
+ import { ensureM3 } from './framework/Init';
17
+ import Validator from './framework/Validator';
18
+ import { MType, EmtpyType, createDefaultValue } from './types/MType';
19
+ export { M3, MContext, MFieldViewer, BaseViewer, assembly, SegmentEditSwitch, Viewer, UnderlineInputBox, Segment, MUtil, Ajax, MViewer, MViewerDebug, SubmitBar, useM3Database, ensureM3, Validator, EmtpyType, createDefaultValue, Assembly };
20
+ export type { M3UISpec, ViewerState, SegmentEditSwitchState, M3UISpecSegmentItem, MFieldSchema, MFieldSchemaAnonymity, MORPH, VIEWER, MType, MTheme };
21
+ export default M3;
@@ -0,0 +1,2 @@
1
+ import { MType } from "./MType";
2
+ export declare const MArrayType: MType;
@@ -0,0 +1,11 @@
1
+ import { MType } from "./MType";
2
+ /**
3
+ * 级联多选的值示例:
4
+ * 值类型:
5
+ * [
6
+ * { "label": "jiangsu", "value": "jiangsu" },
7
+ * { "label": "nanjing", "value": "nanjiong, chi" },
8
+ * { "label": "nanjing", "value": "zhong hua men" }
9
+ * ]
10
+ */
11
+ export declare const MCascadeType: MType;
@@ -0,0 +1,2 @@
1
+ import { MType } from "./MType";
2
+ export declare const MCnAddress: MType;
@@ -0,0 +1,7 @@
1
+ import { MFieldSchemaAnonymity } from "../framework/Schema";
2
+ import { MType } from "./MType";
3
+ import { Assembly } from "../framework/Assembly";
4
+ export declare function timeRangeExpr(assembly: Assembly, from: number | string, to: number | string, tillNow: boolean, readableFormat?: string): string;
5
+ export declare const MDateRangeType: MType & {
6
+ toReadableN: (assembly: Assembly, s: MFieldSchemaAnonymity, vs: any) => string | undefined;
7
+ };
@@ -0,0 +1,11 @@
1
+ import { MFieldSchemaAnonymity } from '../framework/Schema';
2
+ import { MType } from "./MType";
3
+ export interface MDateTimeAntConf {
4
+ dataFormat: string;
5
+ readableFormat: string;
6
+ mode: undefined | 'date' | 'year' | 'month' | 'time';
7
+ showTime: boolean;
8
+ }
9
+ export declare const MDateTimeType: MType & {
10
+ antConf: (schema: MFieldSchemaAnonymity) => MDateTimeAntConf | undefined;
11
+ };
@@ -0,0 +1,7 @@
1
+ /** HTML装饰物,并不修改数据 */
2
+ export declare const MDecorationType: {
3
+ validators: any[];
4
+ createDefaultValue: (assembly: import("..").Assembly, s: Pick<import("..").MFieldSchema, "type" | "label" | "editor" | "readable" | "option" | "enumFields" | "setFields" | "openOption" | "enumOpen" | "setOpen" | "defaultValue" | "props" | "stringLines" | "min" | "max" | "required" | "showIf" | "column" | "toReadable" | "tolerate" | "screenAdaption" | "postfix" | "popoverDesc" | "requiredMessage" | "placeholder" | "objectFields" | "objectLabelFields" | "stringAllowSpaceOnly" | "matrix" | "arrayMember" | "arrayAddLabel" | "experience" | "dateRange" | "dataFormat" | "intDiff" | "css" | "removeConfirm" | "mcs" | "uispec" | "hpOrg" | "ossFile" | "decoration" | "remote" | "a" | "style" | "layoutHint" | "options" | "bizData">) => any;
5
+ standardValue: (assembly: import("..").Assembly, s: Pick<import("..").MFieldSchema, "type" | "label" | "editor" | "readable" | "option" | "enumFields" | "setFields" | "openOption" | "enumOpen" | "setOpen" | "defaultValue" | "props" | "stringLines" | "min" | "max" | "required" | "showIf" | "column" | "toReadable" | "tolerate" | "screenAdaption" | "postfix" | "popoverDesc" | "requiredMessage" | "placeholder" | "objectFields" | "objectLabelFields" | "stringAllowSpaceOnly" | "matrix" | "arrayMember" | "arrayAddLabel" | "experience" | "dateRange" | "dataFormat" | "intDiff" | "css" | "removeConfirm" | "mcs" | "uispec" | "hpOrg" | "ossFile" | "decoration" | "remote" | "a" | "style" | "layoutHint" | "options" | "bizData">, v: any, strict: boolean) => any;
6
+ toReadable: (assembly: import("..").Assembly, s: Pick<import("..").MFieldSchema, "type" | "label" | "editor" | "readable" | "option" | "enumFields" | "setFields" | "openOption" | "enumOpen" | "setOpen" | "defaultValue" | "props" | "stringLines" | "min" | "max" | "required" | "showIf" | "column" | "toReadable" | "tolerate" | "screenAdaption" | "postfix" | "popoverDesc" | "requiredMessage" | "placeholder" | "objectFields" | "objectLabelFields" | "stringAllowSpaceOnly" | "matrix" | "arrayMember" | "arrayAddLabel" | "experience" | "dateRange" | "dataFormat" | "intDiff" | "css" | "removeConfirm" | "mcs" | "uispec" | "hpOrg" | "ossFile" | "decoration" | "remote" | "a" | "style" | "layoutHint" | "options" | "bizData">, vs: any) => string;
7
+ };
@@ -0,0 +1,2 @@
1
+ import { MType } from "./MType";
2
+ export declare const MEnumType: MType;
@@ -0,0 +1,5 @@
1
+ import { MFieldSchemaAnonymity, MValidationResult } from "../framework/Schema";
2
+ import { MType } from "./MType";
3
+ import { Assembly } from '../framework/Assembly';
4
+ export declare function validateExperience(assembly: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string): MValidationResult;
5
+ export declare const MExperienceType: MType;
@@ -0,0 +1,2 @@
1
+ import { MType } from "./MType";
2
+ export declare const MFloatType: MType;
@@ -0,0 +1,9 @@
1
+ import { MType } from "./MType";
2
+ export interface GB2260CodeInfo {
3
+ label: string[];
4
+ code: string[];
5
+ }
6
+ export declare const MGB2260Type: MType & {
7
+ lookup: (code: number | string) => GB2260CodeInfo | undefined;
8
+ gb2260: any;
9
+ };
@@ -0,0 +1,2 @@
1
+ import { MType } from "./MType";
2
+ export declare const MIntDiffType: MType;
@@ -0,0 +1,2 @@
1
+ import { MType } from "./MType";
2
+ export declare const MIntType: MType;
@@ -0,0 +1,11 @@
1
+ import { MType } from "./MType";
2
+ /**
3
+ * 类似这种题:
4
+ * B8: 您现在在做的事业务部门的岗位吗?
5
+ * 1. 是,具体职位是 _______
6
+ * 2. 否,我的部门是 _______
7
+ *
8
+ * 数据结构
9
+ * {1:'CEO', 2:'营销'}
10
+ */
11
+ export declare const MKvSetType: MType;
@@ -0,0 +1,5 @@
1
+ import { MFieldSchemaAnonymity, MValidationResult } from "../framework/Schema";
2
+ import { MType } from "./MType";
3
+ import { Assembly } from '../framework/Assembly';
4
+ export declare function validateMatrix(a: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string): MValidationResult;
5
+ export declare const MMatrixType: MType;
@@ -0,0 +1,11 @@
1
+ import { MFieldSchemaAnonymity, MValidationResult } from "../framework/Schema";
2
+ import { MType } from "./MType";
3
+ import { Assembly } from '../framework/Assembly';
4
+ export declare function validateObject(assembly: Assembly, schema: MFieldSchemaAnonymity, value: any, path: string): MValidationResult;
5
+ /**
6
+ * JSON对象
7
+ * 注意:
8
+ * 1. string/number/boolean等不算有效的JSON对象
9
+ * 2. undefined/null在required=false时是有效的
10
+ */
11
+ export declare const MObjectType: MType;
@@ -0,0 +1,7 @@
1
+ import { MFieldSchemaAnonymity } from "../framework/Schema";
2
+ import { MType } from "./MType";
3
+ export declare const MSetType: MType & {
4
+ change: (isAdd: boolean, newValue: any, value: any[], s: MFieldSchemaAnonymity) => any[];
5
+ openValueIndex: (s: MFieldSchemaAnonymity, vs: any[]) => number;
6
+ clearOpenValue: (s: MFieldSchemaAnonymity, vs: any[], keepOne: boolean) => any[];
7
+ };
@@ -0,0 +1,2 @@
1
+ import { MType } from "./MType";
2
+ export declare const MStringType: MType;
@@ -0,0 +1,4 @@
1
+ import { MType } from "./MType";
2
+ export declare const MCnPhoneType: MType;
3
+ export declare const MEmailType: MType;
4
+ export declare const MTelType: MType;
@@ -0,0 +1,46 @@
1
+ import { MFieldSchemaAnonymity } from '../framework/Schema';
2
+ import { VALIDATOR } from "../framework/Validator";
3
+ import { Assembly } from '../framework/Assembly';
4
+ import { ClassType } from 'react';
5
+ /**
6
+ * 定义一个数据类型的处理规则
7
+ */
8
+ export interface MType {
9
+ /** 这种数据类型的验证器 */
10
+ validators: VALIDATOR[];
11
+ /** 将字段值转换成可读字符串的表达式 */
12
+ toReadable: (assembly: Assembly, s: MFieldSchemaAnonymity, v: any) => string;
13
+ /**
14
+ * 预处理数据,使其符合schema描述
15
+ * 1. strict=true:处理后完全符合schema描述,例如set中option未出现的值,对于有tolerate配置的enum选项转换成option中的值
16
+ * 2. strict=false:处理后数据类型符合schema描述,但值未必符合,例如保证set值是数组,但可能并非都是schema中定义的候选值
17
+ * 3. 即使strict模式,nil也是被允许的,表示值未填
18
+ * 4. 如果数据类型不正确,此方法应返回defaultValue
19
+ * @param strict 严格模式
20
+ */
21
+ standardValue: (assembly: Assembly, s: MFieldSchemaAnonymity, v: any, strict: boolean) => any;
22
+ /**
23
+ * 获取此类型的默认值
24
+ */
25
+ createDefaultValue: (assembly: Assembly, s: MFieldSchemaAnonymity) => any;
26
+ }
27
+ /**
28
+ * 定义一个插件类型
29
+ */
30
+ export interface PluginType {
31
+ /** 数据类型的字段 */
32
+ name: string;
33
+ /** 数据类型的处理规则 */
34
+ type: MType;
35
+ /** 数据类型的编辑模式 */
36
+ editor: ClassType<any, any, any> | string;
37
+ /** 数据类型的展示模式 */
38
+ readable: ClassType<any, any, any> | string;
39
+ }
40
+ export declare const EmtpyType: {
41
+ validators: any[];
42
+ createDefaultValue: (assembly: Assembly, s: MFieldSchemaAnonymity) => any;
43
+ standardValue: (assembly: Assembly, s: MFieldSchemaAnonymity, v: any, strict: boolean) => any;
44
+ toReadable: (assembly: Assembly, s: MFieldSchemaAnonymity, vs: any) => string;
45
+ };
46
+ export declare function createDefaultValue(assembly: Assembly, s: MFieldSchemaAnonymity): string | number | true;
@@ -0,0 +1,5 @@
1
+ import { MType } from "./MType";
2
+ /**
3
+ * 数据示例 { "value": 608793, "label": "test小二" }
4
+ */
5
+ export declare const MVLPairType: MType;
@@ -0,0 +1,45 @@
1
+ import React, { ReactNode } from "react";
2
+ import { MProp } from "../framework/Schema";
3
+ export interface ViewerState {
4
+ ctrlVersion?: number;
5
+ noValidate?: boolean;
6
+ }
7
+ /**
8
+ * 每一个Viewer,都用来表达(展示readable/编辑editor)json上的一个值 / 或者不会改变数据的装饰物
9
+ * 这个类负责展示校验错误,提供数据存取api
10
+ */
11
+ export declare abstract class Viewer<S extends ViewerState> extends React.Component<MProp, S> {
12
+ /**
13
+ * 获取此字段在database中的值
14
+ */
15
+ getValue(): any;
16
+ getParentValue(): any;
17
+ /**
18
+ * 当字段值变化时,调用此方法把值写回database,并且回调afterChange
19
+ * 调用changeValue后Editor会刷新,不需要额外再setState了
20
+ * @param v - 编辑器在数组中时,子编辑器changeValue(undefined)表示它要删除此元素
21
+ * @param updateCtrlVersion - 子类可以用state.ctrlVersion作为key的一部分,在数据变化时用changeValue(value, true)改变输入框的内容
22
+ * @param final - 参考AFTER_CHANGE_CALLBACK
23
+ */
24
+ changeValueEx(v: any, updateCtrlVersion: boolean, final: boolean): void;
25
+ /**
26
+ * changeValueEx(v, false, true)的快捷方式
27
+ * @param v
28
+ */
29
+ changeValue(v: any): void;
30
+ /**
31
+ * 子类实现编辑器元素的渲染,render根据这个元素再加上校验
32
+ */
33
+ protected abstract element(ctx?: any): ReactNode;
34
+ render(): JSX.Element;
35
+ getPlaceholder(index?: number): string | undefined;
36
+ antProp(useVersionCtrl?: boolean): {
37
+ key: string;
38
+ placeholder: string;
39
+ bordered: boolean;
40
+ disabled: boolean;
41
+ };
42
+ }
43
+ export declare abstract class BaseViewer extends Viewer<ViewerState> {
44
+ constructor(p: MProp);
45
+ }
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { MFieldSchema } from '../../../framework/Schema';
3
+ import { BaseViewer } from "../../..";
4
+ export declare function labelExpr(d: any, remote: MFieldSchema["remote"]): any;
5
+ export declare function convert(node: {}, dataPath: any, valuePath: any, childPath: any): {};
6
+ export declare function findById(node: any, id: any, labelPath: any, valuePath: any, childPath: any): any;
7
+ export declare class ACascadePicker extends BaseViewer {
8
+ fetchCandidate: (key: string) => void;
9
+ constructor(props: any);
10
+ element(): JSX.Element;
11
+ }
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { BaseViewer } from '../../BaseViewer';
3
+ import { MEnumField, MProp, ValueConst } from '../../../framework/Schema';
4
+ /**
5
+ * 多选
6
+ * 示例:{label:"1.13 除爱人/对象之外,目前和您一起生活的家庭成员包括(多选):",name:"familyAccompany",type:"set", option: "父亲 母亲 孩子 爱人/对象的父亲 爱人/对象的母亲 兄弟姐妹"},
7
+ * 值:["孩子", "父亲"]
8
+ */
9
+ export declare class ACheckBox extends BaseViewer {
10
+ _enumFields: MEnumField[];
11
+ _enumValues: ValueConst[];
12
+ /** 这个是开放输入框的值 */
13
+ _inputBoxValue: ValueConst;
14
+ constructor(p: MProp);
15
+ _createBr(): JSX.Element;
16
+ element(ctx: any): any[];
17
+ }
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { BaseViewer } from '../../BaseViewer';
3
+ /**
4
+ * 日期选择框
5
+ * 配置示例:
6
+ * {label:"1.2 您的出生年份是",name:"birthday", type:"AYearPicker"},
7
+ * {label:"1.14 您是什么时间来到现在这个城市的?",name:"enterCity", type:"yearAndMonth"},
8
+ * 类型是year时,dataFormat默认是YYYY,例如: 2020,表示2020年
9
+ * 类型是yearAndMonth时,dataFormat默认是YYYYMM,例如:202001,表示2020年1月
10
+ * 类型是yearMonthDay时,dataFormat默认是YYYYMMDD,例如:20200101,表示2020年1月1号
11
+ * 类型是dateTime时,dataFormat默认是x,例如1608897466955
12
+ */
13
+ export declare class ADatetimePicker extends BaseViewer {
14
+ element(): JSX.Element;
15
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { BaseViewer } from '../../BaseViewer';
3
+ /**
4
+ * 选择中国的省市县
5
+ * 示例:{label:"1.5 您目前的居住地",name:"reside", type:"gb2260"},
6
+ * 数据是gb2260的地区代码
7
+ */
8
+ export declare class AGB2260 extends BaseViewer {
9
+ element(): JSX.Element;
10
+ }
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { BaseViewer } from '../../BaseViewer';
3
+ import { MProp } from "../../../framework/Schema";
4
+ export declare class AInputBox extends BaseViewer {
5
+ value: string;
6
+ constructor(p: MProp);
7
+ element(): JSX.Element;
8
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { BaseViewer } from "../../BaseViewer";
3
+ /**
4
+ * 输入整数的输入框
5
+ * 定义示例:{label:"2.3 请问今年以来您平均每月工作多少天?",name:"workdayPerMonth", type:"int"},
6
+ */
7
+ export declare class AIntBox extends BaseViewer {
8
+ element(): JSX.Element;
9
+ }
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import { BaseViewer } from '../../BaseViewer';
3
+ import { MEnumField, MProp, ValueConst } from '../../../framework/Schema';
4
+ import "./AKvSet.less";
5
+ /**
6
+ * 可以填值的多选,max=1时可以当单选用
7
+ * B8: 您现在在做的事业务部门的岗位吗?
8
+ * 1. 是,具体职位是 _______
9
+ * 2. 否,我的部门是 _______
10
+ */
11
+ export declare class AKvSet extends BaseViewer {
12
+ _enumFields: MEnumField[];
13
+ _enumValues: ValueConst[];
14
+ /** 这个是开放输入框的值 */
15
+ _inputBoxValue: ValueConst[];
16
+ constructor(p: MProp);
17
+ _createBr(): JSX.Element;
18
+ element(): JSX.Element[];
19
+ }
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { BaseViewer } from '../../BaseViewer';
3
+ /**
4
+ * 单选框,用于enum
5
+ * 支持开放选项。
6
+ * 定义示例:
7
+ * {label:"1.1 您的性别是", name:"gendar", type:"enum", option: [{label:"男", value:"M"},{label:"女", value:"F"}] },
8
+ * {label:"1.1 您的性别是", name:"gendar", type:"enum", option:"男 女"},
9
+ */
10
+ export declare class ARadio extends BaseViewer {
11
+ /** 开放输入框的值 */
12
+ _inputBoxValue: string;
13
+ element(ctx: any): JSX.Element;
14
+ }
@@ -0,0 +1,30 @@
1
+ import { Component, RefObject } from "react";
2
+ import moment from "moment";
3
+ import { RangePickerProps } from "antd/lib/date-picker";
4
+ import { Viewer, ViewerState } from '../../BaseViewer';
5
+ import { MProp } from "../../../framework/Schema";
6
+ export declare type ARangePickerData = [string | null | undefined, string | null | undefined, boolean | null | undefined];
7
+ declare type AntData = [moment.Moment | null, moment.Moment | null];
8
+ interface State extends ViewerState {
9
+ mobileDlg: boolean;
10
+ }
11
+ export declare class ARangePicker extends Viewer<State> {
12
+ _pickerRef: RefObject<Component<RangePickerProps, any, any>>;
13
+ _onCalendarChangeValue?: AntData | null;
14
+ constructor(p: MProp);
15
+ componentDidUpdate(): void;
16
+ componentDidMount(): void;
17
+ _patchTillnow(): void;
18
+ /**
19
+ * RangePicker的数据转换成json上的数据类型
20
+ * @param r
21
+ */
22
+ _rangePicker2Data(v: AntData | null | undefined, tillNow: boolean): ARangePickerData | undefined;
23
+ /**
24
+ * json上的数据转换成RangePicker的数据
25
+ * @param d
26
+ */
27
+ _data2rangePicker(d: ARangePickerData): AntData;
28
+ element(): JSX.Element;
29
+ }
30
+ export {};
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { BaseViewer } from "../../BaseViewer";
3
+ import './ARate.less';
4
+ import { MProp } from "../../../framework/Schema";
5
+ /**
6
+ * antd 的评分组件 https://ant.design/components/rate-cn/
7
+ * { editor: 'ARate', name: 'score', label: "评分", required: true, props: {count: 8} }
8
+ */
9
+ export declare class ARate extends BaseViewer {
10
+ value: string;
11
+ constructor(p: MProp);
12
+ element(): JSX.Element;
13
+ }
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { Viewer, ViewerState } from '../../BaseViewer';
3
+ import { MFieldSchema } from '../../../framework/Schema';
4
+ interface State extends ViewerState {
5
+ candidate: any[];
6
+ fetching: boolean;
7
+ q: string;
8
+ }
9
+ export declare function labelExpr(d: any, remote: MFieldSchema["remote"]): any;
10
+ export declare class ARemoteSelector extends Viewer<State> {
11
+ fetchCandidate: (key: string) => void;
12
+ constructor(props: any);
13
+ element(): JSX.Element;
14
+ }
15
+ export {};
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { MEnumField, MProp } from '../../../framework/Schema';
3
+ import { BaseViewer } from '../../BaseViewer';
4
+ /**
5
+ * 下拉选择框
6
+ * 定义示例: {label:"1.1 您的性别是", name:"gendar", type:"enum", typeArg: [{label:"男", value:"M"},{label:"女", value:"F"}] },
7
+ */
8
+ export declare class ASelector extends BaseViewer {
9
+ /** 开放输入框的值 */
10
+ _inputBoxValue: string;
11
+ _enums: MEnumField[];
12
+ constructor(p: MProp);
13
+ element(): JSX.Element;
14
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { BaseViewer } from "../../BaseViewer";
3
+ /**
4
+ * 下拉框多选
5
+ * 示例:{label:"1.13 除爱人/对象之外,目前和您一起生活的家庭成员包括(多选):",name:"familyAccompany",type:"set", editor:"ASetSelector", option: "父亲 母亲 孩子 爱人/对象的父亲 爱人/对象的母亲 兄弟姐妹"},
6
+ * 值:["孩子", "父亲"]
7
+ */
8
+ export declare class ASetSelector extends BaseViewer {
9
+ element(): JSX.Element;
10
+ }