@tdesign/uniapp 0.7.2 → 0.8.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 (199) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +32 -2
  3. package/dist/action-sheet/README.md +1 -1
  4. package/dist/action-sheet/action-sheet.vue +158 -150
  5. package/dist/action-sheet/props.ts +2 -2
  6. package/dist/action-sheet/type.ts +1 -1
  7. package/dist/avatar/avatar.vue +89 -87
  8. package/dist/avatar-group/avatar-group.vue +69 -67
  9. package/dist/back-top/back-top.vue +60 -58
  10. package/dist/badge/badge.vue +69 -59
  11. package/dist/button/button.vue +121 -116
  12. package/dist/button/props.ts +2 -2
  13. package/dist/button/type.ts +1 -1
  14. package/dist/calendar/calendar-header.vue +4 -4
  15. package/dist/calendar/calendar.vue +308 -297
  16. package/dist/calendar/template.vue +1 -1
  17. package/dist/cascader/README.en-US.md +2 -1
  18. package/dist/cascader/README.md +2 -1
  19. package/dist/cascader/cascader.vue +340 -328
  20. package/dist/cascader/props.ts +6 -1
  21. package/dist/cascader/type.ts +6 -0
  22. package/dist/cell/cell.vue +127 -121
  23. package/dist/cell-group/cell-group.vue +32 -30
  24. package/dist/check-tag/check-tag.vue +73 -71
  25. package/dist/checkbox/README.en-US.md +6 -6
  26. package/dist/checkbox/README.md +5 -5
  27. package/dist/checkbox/checkbox.vue +127 -127
  28. package/dist/checkbox/props.ts +6 -6
  29. package/dist/checkbox/type.ts +6 -4
  30. package/dist/checkbox-group/checkbox-group.vue +175 -173
  31. package/dist/checkbox-group/props.ts +6 -6
  32. package/dist/checkbox-group/type.ts +6 -4
  33. package/dist/col/col.vue +26 -24
  34. package/dist/collapse/collapse.vue +83 -81
  35. package/dist/collapse-panel/collapse-panel.vue +121 -119
  36. package/dist/collapse-panel/props.ts +4 -4
  37. package/dist/collapse-panel/type.ts +2 -2
  38. package/dist/color-picker/README.md +1 -1
  39. package/dist/color-picker/color-picker.vue +324 -322
  40. package/dist/color-picker/props.ts +2 -2
  41. package/dist/color-picker/template.vue +14 -10
  42. package/dist/common/common.ts +1 -0
  43. package/dist/common/style/theme/index.css +57 -61
  44. package/dist/common/utils.js +7 -2
  45. package/dist/common/validator.js +172 -0
  46. package/dist/config-provider/README.en-US.md +184 -0
  47. package/dist/config-provider/README.md +234 -0
  48. package/dist/config-provider/config-provider.vue +105 -0
  49. package/dist/config-provider/config-store.js +70 -0
  50. package/dist/config-provider/props.ts +16 -0
  51. package/dist/config-provider/reactive-state.js +39 -0
  52. package/dist/config-provider/type.ts +401 -0
  53. package/dist/config-provider/use-config.js +29 -0
  54. package/dist/config-provider/utils.js +29 -0
  55. package/dist/count-down/count-down.vue +98 -97
  56. package/dist/date-time-picker/date-time-picker.vue +410 -395
  57. package/dist/demo/demo.vue +1 -0
  58. package/dist/dialog/dialog.vue +176 -173
  59. package/dist/divider/divider.vue +38 -36
  60. package/dist/draggable/draggable.vue +60 -58
  61. package/dist/drawer/README.md +1 -1
  62. package/dist/drawer/drawer.vue +48 -46
  63. package/dist/dropdown-item/dropdown-item.vue +209 -207
  64. package/dist/dropdown-item/props.ts +4 -4
  65. package/dist/dropdown-item/type.ts +3 -3
  66. package/dist/dropdown-menu/dropdown-menu.vue +93 -99
  67. package/dist/empty/empty.vue +43 -42
  68. package/dist/fab/fab.vue +88 -86
  69. package/dist/footer/footer.vue +36 -34
  70. package/dist/form/README.en-US.md +17 -24
  71. package/dist/form/README.md +18 -25
  72. package/dist/form/form.css +1 -166
  73. package/dist/form/form.vue +251 -236
  74. package/dist/form/props.ts +2 -21
  75. package/dist/form/type.ts +7 -70
  76. package/dist/form-item/README.en-US.md +4 -5
  77. package/dist/form-item/README.md +4 -5
  78. package/dist/form-item/form-item.css +69 -96
  79. package/dist/form-item/form-item.vue +315 -336
  80. package/dist/form-item/form-model.ts +125 -173
  81. package/dist/form-item/props.ts +4 -17
  82. package/dist/form-item/type.ts +43 -1
  83. package/dist/grid/grid.vue +53 -51
  84. package/dist/grid-item/grid-item.vue +121 -119
  85. package/dist/guide/README.md +1 -1
  86. package/dist/guide/guide.vue +281 -277
  87. package/dist/icon/README.md +2 -4
  88. package/dist/icon/icon.vue +78 -76
  89. package/dist/image/README.md +1 -1
  90. package/dist/image/image.vue +103 -101
  91. package/dist/image-viewer/image-viewer.vue +160 -158
  92. package/dist/image-viewer/props.ts +2 -2
  93. package/dist/image-viewer/type.ts +1 -1
  94. package/dist/index.js +3 -0
  95. package/dist/indexes/indexes.vue +264 -267
  96. package/dist/indexes-anchor/indexes-anchor.vue +41 -41
  97. package/dist/input/input.vue +192 -192
  98. package/dist/input/props.ts +6 -6
  99. package/dist/input/type.ts +3 -3
  100. package/dist/link/link.vue +73 -71
  101. package/dist/loading/loading.vue +59 -59
  102. package/dist/locale/ar_KW.ts +157 -0
  103. package/dist/locale/en_US.ts +146 -0
  104. package/dist/locale/it_IT.ts +145 -0
  105. package/dist/locale/ja_JP.ts +132 -0
  106. package/dist/locale/ko_KR.ts +132 -0
  107. package/dist/locale/ru_RU.ts +157 -0
  108. package/dist/locale/zh_CN.ts +133 -0
  109. package/dist/locale/zh_TW.ts +132 -0
  110. package/dist/message/message.vue +181 -173
  111. package/dist/message/props.ts +2 -2
  112. package/dist/message/type.ts +1 -1
  113. package/dist/message-item/message-item.vue +192 -184
  114. package/dist/mixins/using-config.js +39 -0
  115. package/dist/navbar/navbar.vue +201 -199
  116. package/dist/notice-bar/notice-bar.vue +175 -171
  117. package/dist/notice-bar/props.ts +2 -2
  118. package/dist/notice-bar/type.ts +1 -1
  119. package/dist/npm/dayjs/esm/locale/ar.js +81 -0
  120. package/dist/npm/dayjs/esm/locale/it.js +39 -0
  121. package/dist/overlay/overlay.vue +50 -48
  122. package/dist/picker/picker.vue +168 -161
  123. package/dist/picker-item/picker-item.vue +269 -269
  124. package/dist/popover/README.md +1 -1
  125. package/dist/popover/popover.vue +262 -261
  126. package/dist/popover/props.ts +4 -4
  127. package/dist/popover/type.ts +2 -2
  128. package/dist/popup/popup.vue +46 -45
  129. package/dist/progress/README.md +1 -1
  130. package/dist/progress/progress.vue +76 -76
  131. package/dist/pull-down-refresh/props.ts +2 -2
  132. package/dist/pull-down-refresh/pull-down-refresh.vue +240 -234
  133. package/dist/pull-down-refresh/type.ts +1 -1
  134. package/dist/qrcode/README.md +1 -1
  135. package/dist/qrcode/components/qrcode-canvas/qrcode-canvas.vue +340 -338
  136. package/dist/qrcode/components/qrcode-status/qrcode-status.vue +6 -6
  137. package/dist/qrcode/qrcode.vue +93 -87
  138. package/dist/radio/props.ts +6 -6
  139. package/dist/radio/radio.vue +118 -120
  140. package/dist/radio/type.ts +3 -3
  141. package/dist/radio-group/props.ts +4 -4
  142. package/dist/radio-group/radio-group.vue +136 -134
  143. package/dist/radio-group/type.ts +4 -4
  144. package/dist/rate/computed.js +2 -2
  145. package/dist/rate/props.ts +4 -4
  146. package/dist/rate/rate.vue +155 -154
  147. package/dist/rate/type.ts +2 -2
  148. package/dist/result/result.vue +41 -39
  149. package/dist/row/row.vue +38 -36
  150. package/dist/scroll-view/scroll-view.vue +24 -22
  151. package/dist/search/props.ts +2 -2
  152. package/dist/search/search.vue +127 -125
  153. package/dist/search/type.ts +1 -1
  154. package/dist/side-bar/side-bar.vue +57 -55
  155. package/dist/side-bar-item/side-bar-item.vue +86 -86
  156. package/dist/skeleton/skeleton.vue +126 -124
  157. package/dist/slider/README.md +1 -1
  158. package/dist/slider/props.ts +2 -2
  159. package/dist/slider/slider.vue +457 -457
  160. package/dist/slider/type.ts +1 -1
  161. package/dist/step-item/step-item.vue +77 -75
  162. package/dist/stepper/props.ts +2 -2
  163. package/dist/stepper/stepper.vue +168 -149
  164. package/dist/stepper/type.ts +1 -1
  165. package/dist/steps/props.ts +2 -2
  166. package/dist/steps/steps.vue +83 -81
  167. package/dist/steps/type.ts +1 -1
  168. package/dist/sticky/sticky.vue +104 -102
  169. package/dist/swipe-cell/swipe-cell.vue +91 -89
  170. package/dist/swiper/README.md +1 -1
  171. package/dist/swiper/swiper.vue +91 -89
  172. package/dist/swiper-nav/swiper-nav.vue +38 -36
  173. package/dist/switch/props.ts +2 -2
  174. package/dist/switch/switch.vue +62 -62
  175. package/dist/switch/type.ts +1 -1
  176. package/dist/tab-bar/tab-bar.vue +88 -86
  177. package/dist/tab-bar-item/tab-bar-item.vue +85 -82
  178. package/dist/tab-panel/tab-panel.vue +66 -64
  179. package/dist/tabs/tabs.vue +294 -287
  180. package/dist/tag/tag.vue +79 -77
  181. package/dist/textarea/props.ts +6 -6
  182. package/dist/textarea/textarea.vue +127 -126
  183. package/dist/textarea/type.ts +3 -3
  184. package/dist/toast/toast.vue +107 -106
  185. package/dist/transition/transition.vue +30 -28
  186. package/dist/tree-select/tree-select.vue +151 -151
  187. package/dist/types/config-provider.d.ts +7 -0
  188. package/dist/types/index.d.ts +2 -0
  189. package/dist/types/popover.d.ts +7 -0
  190. package/dist/upload/README.en-US.md +13 -14
  191. package/dist/upload/README.md +11 -12
  192. package/dist/upload/props.ts +2 -4
  193. package/dist/upload/type.ts +12 -11
  194. package/dist/upload/upload.css +1 -1
  195. package/dist/upload/upload.vue +672 -512
  196. package/dist/watermark/watermark.vue +151 -149
  197. package/global.d.ts +2 -0
  198. package/package.json +16 -2
  199. package/dist/form/form-item-props.ts +0 -56
@@ -1,198 +1,150 @@
1
- // 验证结果接口
2
- interface ValidateResult {
3
- result: boolean;
4
- message?: string;
5
- type?: string;
6
- }
7
-
8
- // 工具函数:安全获取rule属性的实际值
9
- function getRuleValue(field: any, key?: string): any {
10
- if (field && typeof field === 'object' && 'type' in field) {
11
- // 针对type字段,过滤掉'error'和'warning'
12
- if (key === 'type') {
13
- const { value } = field;
14
- if (value === 'error' || value === 'warning') {
15
- return undefined;
16
- }
17
- return value;
18
- }
19
- return field.value;
20
- }
21
- // type字段只允许string
22
- if (key === 'type') {
23
- if (field === 'error' || field === 'warning') {
24
- return undefined;
25
- }
26
- }
27
- return field;
28
- }
1
+ import { isNumber, isBoolean, isObject, isEmpty, isDate, isEmail, isURL } from '../common/validator';
29
2
 
30
- // 验证状态枚举
31
3
  export const ValidateStatus = {
32
4
  TO_BE_VALIDATED: 0,
33
5
  SUCCESS: 1,
34
6
  FAIL: 2,
35
7
  };
36
8
 
37
- // 执行单个验证规则
38
- async function executeRule(value: any, rule: any): Promise<ValidateResult> {
39
- const result: ValidateResult = {
40
- result: true,
41
- };
42
-
43
- // 必填验证
44
- const required = getRuleValue(rule.required);
45
- if (required && (value === undefined || value === null || value === '' || value.length === 0)) {
46
- result.result = false;
47
- result.message = getRuleValue(rule.message) || '此字段为必填项';
48
- result.type = 'error';
49
- return result;
50
- }
51
-
52
- // 如果值为空且不是必填,则跳过其他验证
53
- if (value === undefined || value === null || value === '' || value.length === 0) {
54
- return result;
55
- }
56
-
57
- // 列表最小值验证
58
- const min = getRuleValue(rule.min);
59
- if (min !== undefined) {
60
- const val = Array.isArray(value) ? value.length : Number(value);
61
- if (val < Number(min)) {
62
- result.result = false;
63
- result.message = getRuleValue(rule.message) || `不能小于 ${min}`;
64
- result.type = 'error';
65
- return result;
9
+ /**
10
+ * 计算字符串字符的长度并可以截取字符串。
11
+ * @param str 传入字符串
12
+ * @param maxCharacter 规定最大字符串长度
13
+ * @returns 当没有传入maxCharacter时返回字符串字符长度,当传入maxCharacter时返回截取之后的字符串和长度。
14
+ */
15
+ function getCharacterLength(str: string, maxCharacter?: number) {
16
+ const hasMaxCharacter = isNumber(maxCharacter);
17
+ if (!str || str.length === 0) {
18
+ if (hasMaxCharacter) {
19
+ return {
20
+ length: 0,
21
+ characters: str,
22
+ };
66
23
  }
24
+ return 0;
67
25
  }
68
-
69
- // 列表最大值验证
70
- const max = getRuleValue(rule.max);
71
- if (max !== undefined) {
72
- const val = Array.isArray(value) ? value.length : Number(value);
73
- if (val > Number(max)) {
74
- result.result = false;
75
- result.message = getRuleValue(rule.message) || `不能大于 ${max}`;
76
- result.type = 'error';
77
- return result;
26
+ let len = 0;
27
+ for (let i = 0; i < str.length; i += 1) {
28
+ let currentStringLength = 0;
29
+ if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
30
+ currentStringLength = 2;
31
+ } else {
32
+ currentStringLength = 1;
78
33
  }
79
- }
80
- // 字符串最大长度验证
81
- const maxLength = getRuleValue(rule.maxLength);
82
- if (maxLength !== undefined) {
83
- const len = String(value).length;
84
- if (len > Number(maxLength)) {
85
- result.result = false;
86
- result.message = getRuleValue(rule.message) || `长度不能超过 ${maxLength}`;
87
- result.type = 'error';
88
- return result;
34
+ if (hasMaxCharacter && len + currentStringLength > maxCharacter) {
35
+ return {
36
+ length: len,
37
+ characters: str.slice(0, i),
38
+ };
89
39
  }
40
+ len += currentStringLength;
90
41
  }
91
-
92
- // 字符串最小长度验证
93
- const minLength = getRuleValue(rule.minLength);
94
- if (minLength !== undefined) {
95
- const len = String(value).length;
96
- if (len < Number(minLength)) {
97
- result.result = false;
98
- result.message = getRuleValue(rule.message) || `长度不能少于 ${minLength}`;
99
- result.type = 'error';
100
- return result;
101
- }
42
+ if (hasMaxCharacter) {
43
+ return {
44
+ length: len,
45
+ characters: str,
46
+ };
102
47
  }
48
+ return len;
49
+ }
103
50
 
104
- // 固定长度验证
105
- const len = getRuleValue(rule.len);
106
- if (len !== undefined) {
107
- const strValue = String(value);
108
- if (strValue.length !== Number(len)) {
109
- result.result = false;
110
- result.message = getRuleValue(rule.message) || `长度必须为 ${len}`;
111
- result.type = 'error';
112
- return result;
113
- }
51
+ // `{} / [] / '' / undefined / null` 等内容被认为是空; 0 和 false 被认为是正常数据,部分数据的值就是 0 或者 false
52
+ export function isValueEmpty(val: any): boolean {
53
+ const type: string = Object.prototype.toString.call(val);
54
+ const typeMap: Record<string, any> = {
55
+ Date: '[object Date]',
56
+ };
57
+ if (type === typeMap.Date) {
58
+ return false;
114
59
  }
60
+ return isObject(val) ? isEmpty(val) : ['', undefined, null].includes(val);
61
+ }
115
62
 
116
- // 正则验证
117
- const pattern = getRuleValue(rule.pattern);
118
- if (pattern) {
119
- let regex;
120
- if (pattern instanceof RegExp) {
121
- regex = pattern;
122
- } else if (typeof pattern === 'string') {
123
- regex = new RegExp(pattern);
124
- } else if (pattern && typeof pattern === 'object' && 'test' in pattern) {
125
- regex = pattern;
126
- } else {
127
- result.result = false;
128
- result.message = getRuleValue(rule.message) || '格式不正确';
129
- result.type = 'error';
130
- return result;
63
+ const VALIDATE_MAP = {
64
+ date: isDate,
65
+ url: isURL,
66
+ email: isEmail,
67
+ required: (val: any): boolean => !isValueEmpty(val),
68
+ whitespace: (val: any): boolean => !(/^\s+$/.test(val) || val === ''),
69
+ boolean: (val: any): boolean => isBoolean(val),
70
+ max: (val: any, num: number): boolean => (isNumber(val) ? val <= num : (getCharacterLength(val) as number) <= num),
71
+ min: (val: any, num: number): boolean => (isNumber(val) ? val >= num : (getCharacterLength(val) as number) >= num),
72
+ len: (val: any, num: number): boolean => getCharacterLength(val) === num,
73
+ number: (val: any): boolean => isNumber(val),
74
+ enum: (val: any, strs: Array<string>): boolean => strs.includes(val),
75
+ idcard: (val: any): boolean => /^(\d{18,18}|\d{15,15}|\d{17,17}x)$/i.test(val),
76
+ telnumber: (val: any): boolean => /^1[3-9]\d{9}$/.test(val),
77
+ pattern: (val: any, regexp: RegExp | string): boolean => {
78
+ const reg = typeof regexp === 'string' ? new RegExp(regexp) : regexp;
79
+ return reg.test(val);
80
+ },
81
+ // 自定义校验规则,可能是异步校验
82
+ validator: (
83
+ val: any,
84
+ validate: Function,
85
+ context?: { formData: any; name: string },
86
+ ): any => validate(val, context),
87
+ };
88
+
89
+ /**
90
+ * 校验某一条数据的某一条规则,一种校验规则不满足则不再进行校验。
91
+ * @param value 值
92
+ * @param rule 校验规则
93
+ * @param context 表单上下文,包含 formData 和 name,供自定义校验器使用
94
+ * @returns 两种校验结果,一种是内置校验规则的校验结果,二种是自定义校验规则(validator)的校验结果
95
+ */
96
+ export async function validateOneRule(
97
+ value: any,
98
+ rule: any,
99
+ context?: { formData: any; name: string },
100
+ ): Promise<any> {
101
+ let validateResult: any = { result: true };
102
+ const keys = Object.keys(rule);
103
+ let vOptions: any;
104
+ let vValidateFun: any;
105
+ let isValidatorRule = false;
106
+ for (let i = 0; i < keys.length; i += 1) {
107
+ const key = keys[i];
108
+ // 非必填选项,值为空,非自定义规则:无需校验,直接返回 true
109
+ if (!rule.required && isValueEmpty(value) && !rule.validator) {
110
+ return validateResult;
131
111
  }
132
- if (!regex.test(String(value))) {
133
- result.result = false;
134
- result.message = getRuleValue(rule.message) || '格式不正确';
135
- result.type = 'error';
136
- return result;
112
+ const validateRule = (VALIDATE_MAP as any)[key];
113
+ const ruleItem = rule[key];
114
+ // 找到一个校验规则,则无需再找,因为参数只允许对一个规则进行校验
115
+ if (validateRule && (ruleItem || ruleItem === 0)) {
116
+ // rule 值为 true 则表示没有校验参数,只是对值进行默认规则校验
117
+ vOptions = ruleItem === true ? undefined : ruleItem;
118
+ vValidateFun = validateRule;
119
+ isValidatorRule = key === 'validator';
120
+ break;
137
121
  }
138
122
  }
139
-
140
- // 类型验证
141
- const type = getRuleValue(rule.type, 'type');
142
- if (typeof type === 'string') {
143
- let isValid = true;
144
- if (type === 'email') {
145
- isValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(value));
146
- if (!isValid) {
147
- result.result = false;
148
- result.message = getRuleValue(rule.message) || `${type} 格式不正确`;
149
- result.type = 'error';
150
- return result;
151
- }
152
- } else if (type === 'url') {
153
- try {
154
- const url = new URL(String(value));
155
- isValid = !!url;
156
- } catch (err) {
157
- isValid = false;
158
- }
159
- if (!isValid) {
160
- result.result = false;
161
- result.message = getRuleValue(rule.message) || `${type} 格式不正确`;
162
- result.type = 'error';
163
- return result;
164
- }
165
- } else if (type === 'number') {
166
- isValid = !Number.isNaN(Number(value));
167
- if (!isValid) {
168
- result.result = false;
169
- result.message = getRuleValue(rule.message) || `${type} 格式不正确`;
170
- result.type = 'error';
171
- return result;
172
- }
123
+ if (vValidateFun) {
124
+ validateResult = isValidatorRule
125
+ ? await vValidateFun(value, vOptions, context)
126
+ : await vValidateFun(value, vOptions);
127
+ // 如果校验不通过,则返回校验不通过的规则
128
+ if (isBoolean(validateResult)) {
129
+ return { ...rule, result: validateResult };
173
130
  }
174
- }
175
- // 自定义验证
176
- const validator = getRuleValue(rule.validator);
177
- if (validator) {
178
- const validateResult = await validator(value);
179
- if (!validateResult) {
180
- result.result = false;
181
- result.message = getRuleValue(rule.message) || '验证失败';
182
- result.type = 'error';
183
- return result;
131
+ // 校验结果为对象,只有自定义校验规则会存在这种情况
132
+ if (isObject(validateResult)) {
133
+ return validateResult;
184
134
  }
185
135
  }
186
- return result;
136
+ return validateResult;
187
137
  }
188
138
 
189
- // 验证函数
190
- export async function validate(value: any, rules: any[]): Promise<ValidateResult[]> {
191
- const results: ValidateResult[] = [];
192
-
193
- const promises = rules.map(rule => executeRule(value, rule));
194
- const ruleResults = await Promise.all(promises);
195
- results.push(...ruleResults);
196
-
197
- return results;
139
+ /**
140
+ * 单个数据进行全规则校验
141
+ * 保留 validateRules 别名以兼容已有调用
142
+ */
143
+ export async function validate(value: any, rules: any[], context?: { formData: any; name: string }): Promise<any[]> {
144
+ const all = rules.map(rule => validateOneRule(value, rule, context));
145
+ const r = await Promise.all(all);
146
+ return r;
198
147
  }
148
+
149
+ // 兼容已有导入
150
+ export const validateRules = validate;
@@ -8,19 +8,6 @@ import type { TdFormItemProps } from './type';
8
8
  export default {
9
9
  /** 是否显示右侧箭头 */
10
10
  arrow: Boolean,
11
- /** 表单内容对齐方式,优先级高于 Form.contentAlign */
12
- contentAlign: {
13
- type: String,
14
- validator(val: TdFormItemProps['contentAlign']): boolean {
15
- if (!val) return true;
16
- return ['left', 'right'].includes(val);
17
- },
18
- },
19
- /** label 原生属性 */
20
- for: {
21
- type: String,
22
- default: '',
23
- },
24
11
  /** 表单项说明内容 */
25
12
  help: {
26
13
  type: String,
@@ -49,8 +36,8 @@ export default {
49
36
  },
50
37
  /** 是否显示必填符号(*),优先级高于 Form.requiredMark */
51
38
  requiredMark: {
52
- type: Boolean,
53
- default: undefined,
39
+ type: [Boolean, null],
40
+ default: null as TdFormItemProps['requiredMark'],
54
41
  },
55
42
  /** 表单字段校验规则 */
56
43
  rules: {
@@ -58,7 +45,7 @@ export default {
58
45
  },
59
46
  /** 校验不通过时,是否显示错误提示信息,优先级高于 `Form.showErrorMessage` */
60
47
  showErrorMessage: {
61
- type: Boolean,
62
- default: undefined,
48
+ type: [Boolean, null],
49
+ default: null as TdFormItemProps['showErrorMessage'],
63
50
  },
64
51
  };
@@ -4,4 +4,46 @@
4
4
  * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
5
5
  * */
6
6
 
7
- export type { TdFormItemProps} from '../form/type';
7
+ import type { FormRule } from '../form/type';
8
+
9
+ export interface TdFormItemProps {
10
+ /**
11
+ * 是否显示右侧箭头
12
+ * @default false
13
+ */
14
+ arrow?: boolean;
15
+ /**
16
+ * 表单项说明内容
17
+ */
18
+ help?: string;
19
+ /**
20
+ * 字段标签名称
21
+ * @default ''
22
+ */
23
+ label?: string;
24
+ /**
25
+ * 表单字段标签对齐方式:左对齐、右对齐、顶部对齐。默认使用 Form 的对齐方式,优先级高于 Form.labelAlign
26
+ */
27
+ labelAlign?: 'left' | 'right' | 'top';
28
+ /**
29
+ * 可以整体设置标签宽度,优先级高于 Form.labelWidth
30
+ */
31
+ labelWidth?: string | number;
32
+ /**
33
+ * 表单字段名称
34
+ * @default ''
35
+ */
36
+ name?: string;
37
+ /**
38
+ * 是否显示必填符号(*),优先级高于 Form.requiredMark
39
+ */
40
+ requiredMark?: boolean;
41
+ /**
42
+ * 表单字段校验规则
43
+ */
44
+ rules?: Array<FormRule>;
45
+ /**
46
+ * 校验不通过时,是否显示错误提示信息,优先级高于 `Form.showErrorMessage`
47
+ */
48
+ showErrorMessage?: boolean;
49
+ }
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <view
3
- :style="tools._style([customStyle])"
4
- :class="tools.cls(classPrefix, [theme]) + ' ' + tClass"
3
+ :style="'' + tools._style([customStyle])"
4
+ :class="'' + tools.cls(classPrefix, [theme]) + ' ' + tClass"
5
5
  >
6
6
  <view
7
7
  v-if="column > 0"
@@ -33,60 +33,62 @@ import { ParentMixin, RELATION_MAP } from '../common/relation';
33
33
  const name = `${prefix}-grid`;
34
34
 
35
35
 
36
- export default uniComponent({
37
- name,
38
- options: {
39
- styleIsolation: 'shared',
40
- },
41
- externalClasses: ['t-class'],
42
- mixins: [ParentMixin(RELATION_MAP.GridItem)],
43
- props: {
44
- ...props,
45
- },
46
- data() {
47
- return {
48
- prefix,
49
- classPrefix: name,
50
- contentStyle: '',
51
- tools,
52
- };
53
- },
54
- watch: {
55
- column: 'watchCallback',
56
- hover: 'watchCallback',
57
- align: 'watchCallback',
58
- gutter: 'watchCallback',
59
- border: 'watchCallback',
60
- },
61
- mounted() {
62
- this.updateContentStyle();
63
- },
64
- methods: {
65
- watchCallback() {
66
- this.updateContentStyle();
67
- this.doForChild(t => t.updateStyle?.());
36
+ export default {
37
+ ...uniComponent({
38
+ name,
39
+ options: {
40
+ styleIsolation: 'shared',
41
+ },
42
+ externalClasses: ['t-class'],
43
+ mixins: [ParentMixin(RELATION_MAP.GridItem)],
44
+ props: {
45
+ ...props,
68
46
  },
69
- doForChild(action) {
70
- this.children?.forEach(action);
47
+ data() {
48
+ return {
49
+ prefix,
50
+ classPrefix: name,
51
+ contentStyle: '',
52
+ tools,
53
+ };
71
54
  },
72
- updateContentStyle() {
73
- const contentStyles = [];
74
- const marginStyle = this.getContentMargin();
75
- marginStyle && contentStyles.push(marginStyle);
76
- this.contentStyle = contentStyles.join(';');
55
+ watch: {
56
+ column: 'watchCallback',
57
+ hover: 'watchCallback',
58
+ align: 'watchCallback',
59
+ gutter: 'watchCallback',
60
+ border: 'watchCallback',
61
+ },
62
+ mounted() {
63
+ this.updateContentStyle();
77
64
  },
65
+ methods: {
66
+ watchCallback() {
67
+ this.updateContentStyle();
68
+ this.doForChild(t => t.updateStyle?.());
69
+ },
70
+ doForChild(action) {
71
+ this.children?.forEach(action);
72
+ },
73
+ updateContentStyle() {
74
+ const contentStyles = [];
75
+ const marginStyle = this.getContentMargin();
76
+ marginStyle && contentStyles.push(marginStyle);
77
+ this.contentStyle = contentStyles.join(';');
78
+ },
78
79
 
79
- // 判断需不需要在content上加负margin以实现gutter间距
80
- getContentMargin() {
81
- const { gutter } = this;
82
- let { border } = this;
80
+ // 判断需不需要在content上加负margin以实现gutter间距
81
+ getContentMargin() {
82
+ const { gutter } = this;
83
+ let { border } = this;
83
84
 
84
- if (!border) return `margin-bottom:-${gutter}rpx; margin-right:-${gutter}rpx`;
85
- if (!isObject(border)) border = {} ;
86
- const { width = 2 } = border ;
87
- return `margin-bottom:-${width}rpx; margin-right:-${width}rpx`;
85
+ if (!border) return `margin-bottom:-${gutter}rpx; margin-right:-${gutter}rpx`;
86
+ if (!isObject(border)) border = {} ;
87
+ const { width = 2 } = border ;
88
+ return `margin-bottom:-${width}rpx; margin-right:-${width}rpx`;
89
+ },
88
90
  },
89
- },
90
- });
91
+ }),
92
+ };
91
93
  </script>
92
94
  <style scoped src="./grid.css"></style>