@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
@@ -0,0 +1,401 @@
1
+ /* eslint-disable */
2
+
3
+ /**
4
+ * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
5
+ * */
6
+
7
+ import type { FormErrorMessage } from '../form/type';
8
+ import type { TdImageProps as ImageProps } from '../image/type';
9
+
10
+ export interface TdConfigProviderProps {
11
+ /**
12
+ * 全局配置
13
+ */
14
+ globalConfig?: GlobalConfigProvider;
15
+ /**
16
+ * 全局配置
17
+ */
18
+ themeVars?: object;
19
+ }
20
+
21
+ export interface GlobalConfigProvider {
22
+ /**
23
+ * 动作面板全局配置
24
+ */
25
+ actionSheet?: ActionSheetConfig;
26
+ /**
27
+ * 日历组件全局配置
28
+ */
29
+ calendar?: CalendarConfig;
30
+ /**
31
+ * 级联选择器全局配置
32
+ */
33
+ cascader?: CascaderConfig;
34
+ /**
35
+ * CSS 类名前缀
36
+ * @default t
37
+ */
38
+ classPrefix?: string;
39
+ /**
40
+ * 时间选择器全局配置
41
+ */
42
+ dateTimePicker?: DateTimePickerConfig;
43
+ /**
44
+ * 下拉菜单全局配置
45
+ */
46
+ dropdownMenu?: DropdownMenuConfig;
47
+ /**
48
+ * 引导全局配置
49
+ */
50
+ guide?: GuideConfig;
51
+ /**
52
+ * 选择器全局配置
53
+ */
54
+ picker?: PickerConfig;
55
+ /**
56
+ * 下拉刷新全局配置
57
+ */
58
+ pullDownRefresh?: PullDownRefreshConfig;
59
+ /**
60
+ * 二维码全局配置
61
+ */
62
+ qrcode?: QRCodeConfig;
63
+ /**
64
+ * 评分全局配置
65
+ */
66
+ rate?: RateConfig;
67
+ /**
68
+ * 标签栏全局配置
69
+ */
70
+ tabBar?: TabBarConfig;
71
+ /**
72
+ * 上传组件全局配置
73
+ */
74
+ upload?: UploadConfig;
75
+ }
76
+
77
+ export interface ActionSheetConfig {
78
+ /**
79
+ * 语言配置,“取消” 按钮描述文本
80
+ * @default ''
81
+ */
82
+ cancel?: string;
83
+ }
84
+
85
+ export interface AttachmentsConfig {
86
+ /**
87
+ * 语言配置,附件上传状态描述文本
88
+ */
89
+ status?: { pending: string; fail: string };
90
+ }
91
+
92
+ export interface CalendarConfig {
93
+ /**
94
+ * 语言配置,“确定” 按钮描述文本
95
+ * @default ''
96
+ */
97
+ confirm?: string;
98
+ /**
99
+ * 语言配置,日期月面板标题描述文本。示例:“{year} / {month}”
100
+ * @default ''
101
+ */
102
+ monthTitle?: string;
103
+ /**
104
+ * 月文本描述,默认值:['1 月', '2 月', '3 月', '4 月', '5 月', '6 月', '7 月', '8 月', '9 月', '10 月', '11 月', '12 月']
105
+ */
106
+ months?: string[];
107
+ /**
108
+ * 语言配置,组件标题“请选择日期”描述文本
109
+ * @default ''
110
+ */
111
+ title?: string;
112
+ /**
113
+ * 星期文本描述,默认值:['日', '一', '二', '三', '四', '五', '六']
114
+ */
115
+ weekdays?: string[];
116
+ }
117
+
118
+ export interface CascaderConfig {
119
+ /**
120
+ * 语言配置,未选中时的提示文案“选择选项”描述文本
121
+ * @default ''
122
+ */
123
+ placeholder?: string;
124
+ /**
125
+ * 语言配置,组件标题“选择地址”描述文本
126
+ * @default ''
127
+ */
128
+ title?: string;
129
+ }
130
+
131
+ export interface ChatActionbarConfig {
132
+ /**
133
+ * 语言配置,对话操作栏描述文本
134
+ */
135
+ actionBar?: { replay: string; copy: string; good: string; bad: string; share: string; quote: string };
136
+ }
137
+
138
+ export interface ChatSenderConfig {
139
+ /**
140
+ * 语言配置,占位符描述文本
141
+ * @default ''
142
+ */
143
+ placeholder?: string;
144
+ /**
145
+ * 语言配置,发送按钮描述文本
146
+ * @default ''
147
+ */
148
+ sendText?: string;
149
+ /**
150
+ * 语言配置,停止发送按钮描述文本
151
+ * @default ''
152
+ */
153
+ stopText?: string;
154
+ }
155
+
156
+ export interface ChatThinkingConfig {
157
+ /**
158
+ * 语言配置,思考状态描述文本
159
+ */
160
+ status?: { pending: string; complete: string; stop: string };
161
+ }
162
+
163
+ export interface DateTimePickerConfig {
164
+ /**
165
+ * 语言配置,“取消”按钮描述文本
166
+ * @default ''
167
+ */
168
+ cancel?: string;
169
+ /**
170
+ * 语言配置,“确定”按钮描述文本
171
+ * @default ''
172
+ */
173
+ confirm?: string;
174
+ /**
175
+ * 语言配置,“日” 描述文本
176
+ * @default ''
177
+ */
178
+ dateLabel?: string;
179
+ /**
180
+ * 日期格式化规则
181
+ * @default 'YYYY-MM-DD HH:mm:ss'
182
+ */
183
+ format?: string;
184
+ /**
185
+ * 语言配置,“时” 描述文本
186
+ * @default ''
187
+ */
188
+ hourLabel?: string;
189
+ /**
190
+ * 语言配置,“分” 描述文本
191
+ * @default ''
192
+ */
193
+ minuteLabel?: string;
194
+ /**
195
+ * 语言配置,“月” 描述文本
196
+ * @default ''
197
+ */
198
+ monthLabel?: string;
199
+ /**
200
+ * 语言配置,“秒” 描述文本
201
+ * @default ''
202
+ */
203
+ secondLabel?: string;
204
+ /**
205
+ * 语言配置,组件标题“选择时间”描述文本
206
+ * @default ''
207
+ */
208
+ title?: string;
209
+ /**
210
+ * 语言配置,“年” 描述文本
211
+ * @default ''
212
+ */
213
+ yearLabel?: string;
214
+ }
215
+
216
+ export interface DropdownMenuConfig {
217
+ /**
218
+ * 语言配置,“确定” 按钮描述文本
219
+ * @default ''
220
+ */
221
+ confirm?: string;
222
+ /**
223
+ * 语言配置,“重置” 按钮描述文本
224
+ * @default ''
225
+ */
226
+ reset?: string;
227
+ }
228
+
229
+ export interface FormConfig {
230
+ /**
231
+ * 字段旁边的冒号,中文为“:”
232
+ * @default ''
233
+ */
234
+ colonText?: string;
235
+ /**
236
+ * 表单错误信息配置,示例:`{ idcard: '请输入正确的身份证号码', max: '字符长度不能超过 ${max}' }`
237
+ */
238
+ errorMessage?: FormErrorMessage;
239
+ /**
240
+ * 是否显示必填符号(*),默认显示
241
+ * @default true
242
+ */
243
+ requiredMark?: boolean;
244
+ /**
245
+ * 表单必填符号(*)显示位置
246
+ * @default left
247
+ */
248
+ requiredMarkPosition?: 'left' | 'right';
249
+ }
250
+
251
+ export interface GuideConfig {
252
+ /**
253
+ * 语言配置, “返回” 描述文本
254
+ * @default ''
255
+ */
256
+ back?: string;
257
+ /**
258
+ * 语言配置, “完成” 描述文本
259
+ * @default ''
260
+ */
261
+ finish?: string;
262
+ /**
263
+ * 语言配置, “下一步” 描述文本
264
+ * @default ''
265
+ */
266
+ next?: string;
267
+ /**
268
+ * 语言配置, “跳过” 描述文本
269
+ * @default ''
270
+ */
271
+ skip?: string;
272
+ }
273
+
274
+ export interface ImageConfig {
275
+ /**
276
+ * 图片加载失败显示的文本,中文默认为“图片无法显示”
277
+ * @default ''
278
+ */
279
+ errorText?: string;
280
+ /**
281
+ * 图片加载中显示的文本,中文默认为“图片加载中”
282
+ * @default ''
283
+ */
284
+ loadingText?: string;
285
+ /**
286
+ * 统一替换图片 `src` 地址,参数为组件的全部属性,返回值为新的图片地址
287
+ */
288
+ replaceImageSrc?: (params: ImageProps) => string;
289
+ }
290
+
291
+ export interface InputConfig {
292
+ /**
293
+ * 语言配置,“请输入”占位符描述文本
294
+ * @default ''
295
+ */
296
+ placeholder?: string;
297
+ }
298
+
299
+ export interface PickerConfig {
300
+ /**
301
+ * 语言配置,“取消” 按钮描述文本
302
+ * @default ''
303
+ */
304
+ cancel?: string;
305
+ /**
306
+ * 语言配置,“确认” 按钮描述文本
307
+ * @default ''
308
+ */
309
+ confirm?: string;
310
+ }
311
+
312
+ export interface PullDownRefreshConfig {
313
+ /**
314
+ * 提示文本描述,默认值:['下拉刷新', '松手刷新', '正在刷新', '刷新完成']
315
+ */
316
+ loadingTexts?: string[];
317
+ }
318
+
319
+ export interface QRCodeConfig {
320
+ /**
321
+ * 语言配置,“二维码过期”描述文本
322
+ * @default ''
323
+ */
324
+ expiredText?: string;
325
+ /**
326
+ * 语言配置,“点击刷新”描述文本
327
+ * @default ''
328
+ */
329
+ refreshText?: string;
330
+ /**
331
+ * 语言配置,“已扫描”描述文本
332
+ * @default ''
333
+ */
334
+ scannedText?: string;
335
+ }
336
+
337
+ export interface RateConfig {
338
+ /**
339
+ * 语言配置,“未评分”描述文本
340
+ * @default ''
341
+ */
342
+ noValueText?: string;
343
+ /**
344
+ * 语言配置,评分值描述文本。示例:“{value} 分”
345
+ * @default ''
346
+ */
347
+ valueText?: string;
348
+ }
349
+
350
+ export interface TabBarConfig {
351
+ /**
352
+ * 语言配置,“有n+条新的消息”描述文本。示例:“有 {value}+ 条消息”
353
+ * @default ''
354
+ */
355
+ haveMoreNewsAriaLabel?: string;
356
+ /**
357
+ * 语言配置,“有n条新的消息”描述文本。示例:“有 {value} 条消息”
358
+ * @default ''
359
+ */
360
+ haveNewsAriaLabel?: string;
361
+ /**
362
+ * 语言配置,“有很多消息”描述文本
363
+ * @default ''
364
+ */
365
+ moreNewsAriaLabel?: string;
366
+ /**
367
+ * 语言配置,“有新的消息”描述文本
368
+ * @default ''
369
+ */
370
+ newsAriaLabel?: string;
371
+ }
372
+
373
+ export interface UploadConfig {
374
+ /**
375
+ * 语言配置,上传进度相关。示例:{ uploadText: '上传中', waitingText: '待上传', 'failText': '上传失败', successText: '上传成功' }
376
+ */
377
+ progress?: UploadConfigProgress;
378
+ }
379
+
380
+ export interface UploadConfigProgress {
381
+ /**
382
+ * 语言配置,“上传失败”文本描述
383
+ * @default ''
384
+ */
385
+ failText?: string;
386
+ /**
387
+ * 语言配置,“上传成功”文本描述
388
+ * @default ''
389
+ */
390
+ successText?: string;
391
+ /**
392
+ * 语言配置,“上传中”文本描述
393
+ * @default ''
394
+ */
395
+ uploadingText?: string;
396
+ /**
397
+ * 语言配置,“待上传”文本描述
398
+ * @default ''
399
+ */
400
+ waitingText?: string;
401
+ }
@@ -0,0 +1,29 @@
1
+ import { configStore } from './config-store';
2
+
3
+ export function getComponentLocale(component, componentName, defaultLocale, localePropName) {
4
+ let componentLocale = {};
5
+ if (localePropName && component[localePropName]) {
6
+ componentLocale = component[localePropName];
7
+ }
8
+ const globalLocaleConfig = configStore.currentLocale.value;
9
+ const globalLocale = (globalLocaleConfig && globalLocaleConfig[componentName]) || {};
10
+ return {
11
+ ...defaultLocale,
12
+ ...globalLocale,
13
+ ...componentLocale,
14
+ };
15
+ }
16
+
17
+ export function useConfig(componentName) {
18
+ return {
19
+ getLocale(defaultLocale, component) {
20
+ return getComponentLocale(component, componentName, defaultLocale);
21
+ },
22
+ subscribeLocale(component, callback) {
23
+ const unsubscribe = configStore.currentLocale.subscribe((locale) => {
24
+ callback(locale);
25
+ });
26
+ return unsubscribe;
27
+ },
28
+ };
29
+ }
@@ -0,0 +1,29 @@
1
+ import { hyphenate } from '../common/utils';
2
+
3
+ /**
4
+ * 将主题变量对象转换为 CSS 变量对象
5
+ * @param {Object} themeVars 主题变量对象
6
+ * @param {string} varPrefix CSS 变量前缀
7
+ * @returns {Object} CSS 变量对象
8
+ */
9
+ export default function themeVarsToCSS(themeVars, varPrefix = '--td-') {
10
+ const cssVarMap = {};
11
+
12
+ Object.keys(themeVars).forEach((key) => {
13
+ let cssVarName;
14
+
15
+ // key 以 -- 开头,认为是标准的 css vars,直接使用
16
+ if (key.startsWith('--')) {
17
+ cssVarName = key;
18
+ } else if (key.includes('-')) {
19
+ // 如果 key 包含短横线,认为是 kebab-case 格式,直接使用
20
+ cssVarName = `${varPrefix}${key}`;
21
+ } else {
22
+ cssVarName = `${varPrefix}${hyphenate(key)}`;
23
+ }
24
+
25
+ cssVarMap[cssVarName] = String(themeVars[key]);
26
+ });
27
+
28
+ return cssVarMap;
29
+ }
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <view
3
- :style="tools._style([customStyle])"
3
+ :style="'' + tools._style([customStyle])"
4
4
  :class="classPrefix + ' ' + classPrefix + '--' + theme + ' ' + classPrefix + '--' + size + ' ' + tClass"
5
5
  aria-role="option"
6
6
  >
@@ -32,7 +32,6 @@
32
32
  </view>
33
33
  </template>
34
34
  <script>
35
- import TIcon from '../icon/icon';
36
35
  import { uniComponent } from '../common/src/index';
37
36
  import { prefix } from '../common/config';
38
37
  import props from './props';
@@ -44,121 +43,123 @@ import { format as formatUtil } from './computed.js';
44
43
  const name = `${prefix}-count-down`;
45
44
 
46
45
 
47
- export default uniComponent({
48
- name,
49
- options: {
50
- styleIsolation: 'shared',
51
- },
52
- externalClasses: [
53
- `${prefix}-class`,
54
- `${prefix}-class-count`,
55
- `${prefix}-class-split`,
56
- ],
46
+ export default {
57
47
  components: {
58
- TIcon,
59
- },
60
- props: {
61
- ...props,
62
- },
63
- data() {
64
- return {
65
- prefix,
66
- classPrefix: name,
67
- timeDataUnit: TimeDataUnit,
68
- timeData: parseTimeData(0),
69
- formattedTime: '0',
70
- tools,
71
- timeoutId: null,
72
- isInitialTime: false,
73
- };
74
48
  },
75
- watch: {
76
- time: {
77
- handler() {
78
- this.reset();
49
+ ...uniComponent({
50
+ name,
51
+ options: {
52
+ styleIsolation: 'shared',
53
+ },
54
+ externalClasses: [
55
+ `${prefix}-class`,
56
+ `${prefix}-class-count`,
57
+ `${prefix}-class-split`,
58
+ ],
59
+ props: {
60
+ ...props,
61
+ },
62
+ data() {
63
+ return {
64
+ prefix,
65
+ classPrefix: name,
66
+ timeDataUnit: TimeDataUnit,
67
+ timeData: parseTimeData(0),
68
+ formattedTime: '0',
69
+ tools,
70
+ timeoutId: null,
71
+ isInitialTime: false,
72
+ timeRange: [],
73
+ };
74
+ },
75
+ watch: {
76
+ time: {
77
+ handler() {
78
+ this.reset();
79
+ },
80
+ immediate: true,
79
81
  },
80
- immediate: true,
81
82
  },
82
- },
83
- mounted() {
83
+ mounted() {
84
84
 
85
- },
86
- beforeUnmount() {
87
- if (this.timeoutId) {
88
- clearTimeout(this.timeoutId);
89
- this.timeoutId = null;
90
- }
91
- },
92
- methods: {
93
- formatUtil,
94
- start() {
95
- if (this.counting) {
96
- return;
97
- }
98
-
99
- this.counting = true;
100
- this.endTime = Date.now() + this.remain;
101
- this.doCount();
102
85
  },
103
-
104
- pause() {
105
- this.counting = false;
106
- this.timeoutId && clearTimeout(this.timeoutId);
86
+ beforeUnmount() {
87
+ if (this.timeoutId) {
88
+ clearTimeout(this.timeoutId);
89
+ this.timeoutId = null;
90
+ }
107
91
  },
92
+ methods: {
93
+ formatUtil,
94
+ start() {
95
+ if (this.counting) {
96
+ return;
97
+ }
108
98
 
109
- reset() {
110
- this.pause();
111
- this.remain = this.time;
112
- this.updateTime(this.remain);
99
+ this.counting = true;
100
+ this.endTime = Date.now() + this.remain;
101
+ this.doCount();
102
+ },
113
103
 
114
- if (this.autoStart && this.remain > 0) {
115
- this.start();
116
- }
104
+ pause() {
105
+ this.counting = false;
106
+ this.timeoutId && clearTimeout(this.timeoutId);
107
+ },
117
108
 
118
- this.isInitialTime = true;
119
- },
109
+ reset() {
110
+ this.pause();
111
+ this.remain = this.time;
112
+ this.updateTime(this.remain);
120
113
 
121
- getTime() {
122
- return Math.max(this.endTime - Date.now(), 0);
123
- },
114
+ if (this.autoStart && this.remain > 0) {
115
+ this.start();
116
+ }
124
117
 
125
- updateTime(remain) {
126
- const { format } = this;
127
- this.remain = remain;
128
- const timeData = parseTimeData(remain);
129
- this.$emit('change', timeData);
118
+ this.isInitialTime = true;
119
+ },
130
120
 
131
- const { timeText } = parseFormat(remain, format);
121
+ getTime() {
122
+ return Math.max(this.endTime - Date.now(), 0);
123
+ },
132
124
 
133
- const timeRange = format.split(':');
125
+ updateTime(remain) {
126
+ const { format } = this;
127
+ this.remain = remain;
128
+ const timeData = parseTimeData(remain);
129
+ this.$emit('change', timeData);
134
130
 
135
- this.timeRange = timeRange;
136
- this.timeData = timeData;
137
- this.formattedTime = timeText.replace(/:/g, ' : ');
131
+ const { timeText } = parseFormat(remain, format);
138
132
 
139
- if (remain === 0 && (this.counting || this.isInitialTime)) {
140
- this.pause();
141
- this.$emit('finish');
142
- this.counting = false;
143
- }
144
- },
133
+ const timeRange = format.split(':');
145
134
 
146
- doCount() {
147
- this.timeoutId = setTimeout(() => {
148
- const time = this.getTime();
135
+ this.timeRange = timeRange;
136
+ this.timeData = timeData;
137
+ this.formattedTime = timeText.replace(/:/g, ' : ');
149
138
 
150
- if (this.millisecond) {
151
- this.updateTime(time);
152
- } else if (!isSameSecond(time, this.remain) || time === 0) {
153
- this.updateTime(time);
139
+ if (remain === 0 && (this.counting || this.isInitialTime)) {
140
+ this.pause();
141
+ this.$emit('finish');
142
+ this.counting = false;
154
143
  }
144
+ },
155
145
 
156
- if (time !== 0) {
157
- this.doCount();
158
- }
159
- }, 33); // 30 帧,因此 1000 / 30 = 33
146
+ doCount() {
147
+ this.timeoutId = setTimeout(() => {
148
+ const time = this.getTime();
149
+
150
+ if (this.millisecond) {
151
+ this.updateTime(time);
152
+ } else if (!isSameSecond(time, this.remain) || time === 0) {
153
+ this.updateTime(time);
154
+ }
155
+
156
+ if (time !== 0) {
157
+ this.doCount();
158
+ }
159
+ }, 33); // 30 帧,因此 1000 / 30 = 33
160
+ },
160
161
  },
161
- },
162
- });
162
+ }),
163
+ };
163
164
  </script>
164
165
  <style scoped src="./count-down.css"></style>