@tdesign/uniapp 0.7.3 → 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 (197) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +1 -1
  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/checkbox.vue +127 -127
  26. package/dist/checkbox/props.ts +6 -6
  27. package/dist/checkbox/type.ts +3 -3
  28. package/dist/checkbox-group/checkbox-group.vue +175 -173
  29. package/dist/checkbox-group/props.ts +6 -6
  30. package/dist/checkbox-group/type.ts +4 -4
  31. package/dist/col/col.vue +26 -24
  32. package/dist/collapse/collapse.vue +83 -81
  33. package/dist/collapse-panel/collapse-panel.vue +121 -119
  34. package/dist/collapse-panel/props.ts +4 -4
  35. package/dist/collapse-panel/type.ts +2 -2
  36. package/dist/color-picker/README.md +1 -1
  37. package/dist/color-picker/color-picker.vue +324 -322
  38. package/dist/color-picker/props.ts +2 -2
  39. package/dist/color-picker/template.vue +14 -10
  40. package/dist/common/common.ts +1 -0
  41. package/dist/common/style/theme/index.css +5 -5
  42. package/dist/common/utils.js +7 -2
  43. package/dist/common/validator.js +172 -0
  44. package/dist/config-provider/README.en-US.md +184 -0
  45. package/dist/config-provider/README.md +234 -0
  46. package/dist/config-provider/config-provider.vue +105 -0
  47. package/dist/config-provider/config-store.js +70 -0
  48. package/dist/config-provider/props.ts +16 -0
  49. package/dist/config-provider/reactive-state.js +39 -0
  50. package/dist/config-provider/type.ts +401 -0
  51. package/dist/config-provider/use-config.js +29 -0
  52. package/dist/config-provider/utils.js +29 -0
  53. package/dist/count-down/count-down.vue +98 -97
  54. package/dist/date-time-picker/date-time-picker.vue +410 -395
  55. package/dist/demo/demo.vue +1 -0
  56. package/dist/dialog/dialog.vue +175 -173
  57. package/dist/divider/divider.vue +38 -36
  58. package/dist/draggable/draggable.vue +60 -58
  59. package/dist/drawer/README.md +1 -1
  60. package/dist/drawer/drawer.vue +48 -46
  61. package/dist/dropdown-item/dropdown-item.vue +209 -207
  62. package/dist/dropdown-item/props.ts +4 -4
  63. package/dist/dropdown-item/type.ts +3 -3
  64. package/dist/dropdown-menu/dropdown-menu.vue +93 -99
  65. package/dist/empty/empty.vue +43 -42
  66. package/dist/fab/fab.vue +88 -86
  67. package/dist/footer/footer.vue +36 -34
  68. package/dist/form/README.en-US.md +17 -24
  69. package/dist/form/README.md +18 -25
  70. package/dist/form/form.css +1 -166
  71. package/dist/form/form.vue +251 -236
  72. package/dist/form/props.ts +2 -21
  73. package/dist/form/type.ts +7 -70
  74. package/dist/form-item/README.en-US.md +4 -5
  75. package/dist/form-item/README.md +4 -5
  76. package/dist/form-item/form-item.css +69 -96
  77. package/dist/form-item/form-item.vue +315 -336
  78. package/dist/form-item/form-model.ts +125 -173
  79. package/dist/form-item/props.ts +4 -17
  80. package/dist/form-item/type.ts +43 -1
  81. package/dist/grid/grid.vue +53 -51
  82. package/dist/grid-item/grid-item.vue +121 -119
  83. package/dist/guide/README.md +1 -1
  84. package/dist/guide/guide.vue +281 -277
  85. package/dist/icon/README.md +2 -4
  86. package/dist/icon/icon.vue +78 -76
  87. package/dist/image/README.md +1 -1
  88. package/dist/image/image.vue +103 -101
  89. package/dist/image-viewer/image-viewer.vue +160 -158
  90. package/dist/image-viewer/props.ts +2 -2
  91. package/dist/image-viewer/type.ts +1 -1
  92. package/dist/index.js +3 -0
  93. package/dist/indexes/indexes.vue +264 -267
  94. package/dist/indexes-anchor/indexes-anchor.vue +41 -41
  95. package/dist/input/input.vue +192 -192
  96. package/dist/input/props.ts +6 -6
  97. package/dist/input/type.ts +3 -3
  98. package/dist/link/link.vue +73 -71
  99. package/dist/loading/loading.vue +59 -59
  100. package/dist/locale/ar_KW.ts +157 -0
  101. package/dist/locale/en_US.ts +146 -0
  102. package/dist/locale/it_IT.ts +145 -0
  103. package/dist/locale/ja_JP.ts +132 -0
  104. package/dist/locale/ko_KR.ts +132 -0
  105. package/dist/locale/ru_RU.ts +157 -0
  106. package/dist/locale/zh_CN.ts +133 -0
  107. package/dist/locale/zh_TW.ts +132 -0
  108. package/dist/message/message.vue +181 -173
  109. package/dist/message/props.ts +2 -2
  110. package/dist/message/type.ts +1 -1
  111. package/dist/message-item/message-item.vue +192 -184
  112. package/dist/mixins/using-config.js +39 -0
  113. package/dist/navbar/navbar.vue +201 -199
  114. package/dist/notice-bar/notice-bar.vue +175 -171
  115. package/dist/notice-bar/props.ts +2 -2
  116. package/dist/notice-bar/type.ts +1 -1
  117. package/dist/npm/dayjs/esm/locale/ar.js +81 -0
  118. package/dist/npm/dayjs/esm/locale/it.js +39 -0
  119. package/dist/overlay/overlay.vue +50 -48
  120. package/dist/picker/picker.vue +168 -161
  121. package/dist/picker-item/picker-item.vue +269 -269
  122. package/dist/popover/README.md +1 -1
  123. package/dist/popover/popover.vue +262 -261
  124. package/dist/popover/props.ts +4 -4
  125. package/dist/popover/type.ts +2 -2
  126. package/dist/popup/popup.vue +46 -45
  127. package/dist/progress/README.md +1 -1
  128. package/dist/progress/progress.vue +76 -76
  129. package/dist/pull-down-refresh/props.ts +2 -2
  130. package/dist/pull-down-refresh/pull-down-refresh.vue +240 -234
  131. package/dist/pull-down-refresh/type.ts +1 -1
  132. package/dist/qrcode/README.md +1 -1
  133. package/dist/qrcode/components/qrcode-canvas/qrcode-canvas.vue +340 -338
  134. package/dist/qrcode/components/qrcode-status/qrcode-status.vue +6 -6
  135. package/dist/qrcode/qrcode.vue +93 -87
  136. package/dist/radio/props.ts +6 -6
  137. package/dist/radio/radio.vue +118 -120
  138. package/dist/radio/type.ts +3 -3
  139. package/dist/radio-group/props.ts +4 -4
  140. package/dist/radio-group/radio-group.vue +136 -134
  141. package/dist/radio-group/type.ts +4 -4
  142. package/dist/rate/computed.js +2 -2
  143. package/dist/rate/props.ts +4 -4
  144. package/dist/rate/rate.vue +155 -154
  145. package/dist/rate/type.ts +2 -2
  146. package/dist/result/result.vue +41 -39
  147. package/dist/row/row.vue +38 -36
  148. package/dist/scroll-view/scroll-view.vue +24 -22
  149. package/dist/search/props.ts +2 -2
  150. package/dist/search/search.vue +127 -125
  151. package/dist/search/type.ts +1 -1
  152. package/dist/side-bar/side-bar.vue +57 -55
  153. package/dist/side-bar-item/side-bar-item.vue +86 -86
  154. package/dist/skeleton/skeleton.vue +126 -124
  155. package/dist/slider/README.md +1 -1
  156. package/dist/slider/props.ts +2 -2
  157. package/dist/slider/slider.vue +457 -457
  158. package/dist/slider/type.ts +1 -1
  159. package/dist/step-item/step-item.vue +77 -75
  160. package/dist/stepper/props.ts +2 -2
  161. package/dist/stepper/stepper.vue +168 -149
  162. package/dist/stepper/type.ts +1 -1
  163. package/dist/steps/props.ts +2 -2
  164. package/dist/steps/steps.vue +83 -81
  165. package/dist/steps/type.ts +1 -1
  166. package/dist/sticky/sticky.vue +104 -102
  167. package/dist/swipe-cell/swipe-cell.vue +91 -89
  168. package/dist/swiper/README.md +1 -1
  169. package/dist/swiper/swiper.vue +91 -89
  170. package/dist/swiper-nav/swiper-nav.vue +38 -36
  171. package/dist/switch/props.ts +2 -2
  172. package/dist/switch/switch.vue +62 -62
  173. package/dist/switch/type.ts +1 -1
  174. package/dist/tab-bar/tab-bar.vue +88 -86
  175. package/dist/tab-bar-item/tab-bar-item.vue +85 -82
  176. package/dist/tab-panel/tab-panel.vue +66 -64
  177. package/dist/tabs/tabs.vue +294 -287
  178. package/dist/tag/tag.vue +79 -77
  179. package/dist/textarea/props.ts +6 -6
  180. package/dist/textarea/textarea.vue +127 -126
  181. package/dist/textarea/type.ts +3 -3
  182. package/dist/toast/toast.vue +107 -106
  183. package/dist/transition/transition.vue +30 -28
  184. package/dist/tree-select/tree-select.vue +151 -151
  185. package/dist/types/config-provider.d.ts +7 -0
  186. package/dist/types/index.d.ts +2 -0
  187. package/dist/types/popover.d.ts +7 -0
  188. package/dist/upload/README.en-US.md +13 -14
  189. package/dist/upload/README.md +11 -12
  190. package/dist/upload/props.ts +2 -4
  191. package/dist/upload/type.ts +12 -11
  192. package/dist/upload/upload.css +1 -1
  193. package/dist/upload/upload.vue +672 -512
  194. package/dist/watermark/watermark.vue +151 -149
  195. package/global.d.ts +2 -0
  196. package/package.json +15 -3
  197. 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>