@tdesign/uniapp 0.8.1 → 0.9.1

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 (287) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/action-sheet/README.en-US.md +4 -3
  3. package/dist/action-sheet/README.md +4 -3
  4. package/dist/action-sheet/action-sheet.vue +16 -12
  5. package/dist/action-sheet/computed.js +1 -1
  6. package/dist/action-sheet/props.ts +5 -0
  7. package/dist/action-sheet/type.ts +6 -1
  8. package/dist/avatar/README.en-US.md +1 -1
  9. package/dist/avatar/README.md +1 -1
  10. package/dist/avatar/avatar.vue +10 -9
  11. package/dist/avatar-group/avatar-group.vue +4 -4
  12. package/dist/back-top/README.en-US.md +1 -1
  13. package/dist/back-top/README.md +1 -1
  14. package/dist/back-top/back-top.vue +5 -4
  15. package/dist/badge/README.en-US.md +2 -1
  16. package/dist/badge/README.md +2 -1
  17. package/dist/badge/badge.css +1 -1
  18. package/dist/badge/badge.vue +4 -2
  19. package/dist/button/README.en-US.md +1 -1
  20. package/dist/button/README.md +1 -1
  21. package/dist/button/button.vue +17 -11
  22. package/dist/calendar/README.en-US.md +1 -1
  23. package/dist/calendar/README.md +1 -1
  24. package/dist/calendar/calendar-header.vue +2 -1
  25. package/dist/calendar/calendar.vue +15 -9
  26. package/dist/calendar/template.vue +12 -9
  27. package/dist/cascader/README.en-US.md +1 -1
  28. package/dist/cascader/README.md +1 -1
  29. package/dist/cascader/cascader.vue +8 -8
  30. package/dist/cell/README.en-US.md +1 -1
  31. package/dist/cell/README.md +1 -1
  32. package/dist/cell/cell.vue +34 -36
  33. package/dist/cell-group/cell-group.vue +5 -3
  34. package/dist/check-tag/check-tag.vue +6 -3
  35. package/dist/checkbox/README.en-US.md +1 -1
  36. package/dist/checkbox/README.md +1 -1
  37. package/dist/checkbox/checkbox.vue +5 -4
  38. package/dist/checkbox-group/checkbox-group.vue +5 -3
  39. package/dist/col/col.vue +7 -3
  40. package/dist/collapse/README.en-US.md +1 -1
  41. package/dist/collapse/README.md +1 -1
  42. package/dist/collapse/collapse.vue +6 -4
  43. package/dist/collapse-panel/collapse-panel.vue +15 -6
  44. package/dist/color-picker/README.en-US.md +1 -1
  45. package/dist/color-picker/README.md +1 -1
  46. package/dist/color-picker/color-picker.vue +9 -7
  47. package/dist/color-picker/template.vue +2 -1
  48. package/dist/common/canvas/index.js +1 -1
  49. package/dist/common/shared/color-picker/color.js +1 -0
  50. package/dist/common/src/instantiationDecorator.js +1 -1
  51. package/dist/common/style/theme/index-light.css +282 -0
  52. package/dist/common/style/theme/index-light.less +9 -0
  53. package/dist/common/style/theme/raw/_components-light.less +8 -0
  54. package/dist/common/style/theme/raw/_light-only.less +181 -0
  55. package/dist/common/version.js +1 -1
  56. package/dist/config-provider/config-provider.vue +3 -1
  57. package/dist/count-down/README.en-US.md +1 -1
  58. package/dist/count-down/README.md +1 -1
  59. package/dist/count-down/count-down.vue +5 -3
  60. package/dist/date-time-picker/README.en-US.md +1 -1
  61. package/dist/date-time-picker/README.md +1 -1
  62. package/dist/date-time-picker/date-time-picker.vue +8 -6
  63. package/dist/date-time-picker/locale/dayjs.js +6 -6
  64. package/dist/demo-navbar/demo-navbar.vue +1 -1
  65. package/dist/dialog/README.en-US.md +1 -1
  66. package/dist/dialog/README.md +1 -1
  67. package/dist/dialog/dialog.vue +10 -7
  68. package/dist/dialog/index.js +2 -1
  69. package/dist/divider/README.en-US.md +1 -1
  70. package/dist/divider/README.md +1 -1
  71. package/dist/divider/divider.vue +4 -2
  72. package/dist/draggable/draggable.vue +5 -2
  73. package/dist/drawer/README.en-US.md +1 -1
  74. package/dist/drawer/README.md +1 -1
  75. package/dist/drawer/drawer.vue +7 -5
  76. package/dist/dropdown-item/dropdown-item.vue +16 -11
  77. package/dist/dropdown-menu/README.en-US.md +1 -1
  78. package/dist/dropdown-menu/README.md +1 -1
  79. package/dist/dropdown-menu/dropdown-menu.vue +11 -9
  80. package/dist/empty/README.en-US.md +1 -1
  81. package/dist/empty/README.md +1 -1
  82. package/dist/empty/empty.vue +5 -4
  83. package/dist/fab/README.en-US.md +1 -1
  84. package/dist/fab/README.md +1 -1
  85. package/dist/fab/fab.vue +9 -6
  86. package/dist/fab/props.ts +1 -1
  87. package/dist/fab/type.ts +1 -1
  88. package/dist/footer/README.en-US.md +1 -1
  89. package/dist/footer/README.md +1 -1
  90. package/dist/footer/footer.vue +8 -7
  91. package/dist/form/README.en-US.md +3 -1
  92. package/dist/form/README.md +3 -1
  93. package/dist/form/form.vue +4 -2
  94. package/dist/form/props.ts +9 -0
  95. package/dist/form/type.ts +5 -0
  96. package/dist/form-item/README.en-US.md +2 -1
  97. package/dist/form-item/README.md +2 -1
  98. package/dist/form-item/form-item.css +2 -2
  99. package/dist/form-item/form-item.vue +36 -27
  100. package/dist/form-item/props.ts +8 -0
  101. package/dist/form-item/type.ts +4 -0
  102. package/dist/grid/README.en-US.md +1 -1
  103. package/dist/grid/README.md +1 -1
  104. package/dist/grid/grid.vue +4 -3
  105. package/dist/grid-item/README.en-US.md +1 -1
  106. package/dist/grid-item/README.md +1 -1
  107. package/dist/grid-item/grid-item.vue +8 -6
  108. package/dist/guide/README.en-US.md +1 -1
  109. package/dist/guide/README.md +1 -1
  110. package/dist/guide/guide.vue +8 -7
  111. package/dist/icon/icon.vue +5 -2
  112. package/dist/image/README.en-US.md +1 -1
  113. package/dist/image/README.md +1 -1
  114. package/dist/image/image.vue +6 -5
  115. package/dist/image-viewer/README.en-US.md +4 -3
  116. package/dist/image-viewer/README.md +4 -3
  117. package/dist/image-viewer/image-viewer.css +12 -0
  118. package/dist/image-viewer/image-viewer.vue +84 -21
  119. package/dist/image-viewer/props.ts +5 -0
  120. package/dist/image-viewer/type.ts +6 -1
  121. package/dist/indexes/README.en-US.md +1 -1
  122. package/dist/indexes/README.md +1 -1
  123. package/dist/indexes/computed.js +6 -2
  124. package/dist/indexes/indexes.css +7 -2
  125. package/dist/indexes/indexes.vue +8 -5
  126. package/dist/indexes/props.ts +5 -0
  127. package/dist/indexes/type.ts +5 -0
  128. package/dist/indexes-anchor/README.en-US.md +1 -1
  129. package/dist/indexes-anchor/README.md +1 -1
  130. package/dist/indexes-anchor/indexes-anchor.vue +5 -3
  131. package/dist/input/README.en-US.md +1 -1
  132. package/dist/input/README.md +1 -1
  133. package/dist/input/input.vue +9 -7
  134. package/dist/link/README.en-US.md +1 -1
  135. package/dist/link/README.md +1 -1
  136. package/dist/link/link.vue +6 -3
  137. package/dist/loading/README.en-US.md +1 -1
  138. package/dist/loading/README.md +1 -1
  139. package/dist/loading/loading.vue +4 -2
  140. package/dist/message/index.js +2 -1
  141. package/dist/message/message.vue +4 -3
  142. package/dist/message-item/index.js +1 -1
  143. package/dist/message-item/message-item.vue +7 -5
  144. package/dist/mixins/page-scroll.js +1 -1
  145. package/dist/mixins/using-config.js +1 -1
  146. package/dist/mixins/using-custom-navbar.js +1 -1
  147. package/dist/navbar/README.en-US.md +1 -1
  148. package/dist/navbar/README.md +2 -2
  149. package/dist/navbar/navbar.vue +5 -4
  150. package/dist/notice-bar/README.en-US.md +1 -1
  151. package/dist/notice-bar/README.md +1 -1
  152. package/dist/notice-bar/notice-bar.vue +4 -3
  153. package/dist/overlay/README.en-US.md +1 -1
  154. package/dist/overlay/README.md +1 -1
  155. package/dist/overlay/overlay.vue +6 -3
  156. package/dist/picker/README.en-US.md +1 -1
  157. package/dist/picker/README.md +1 -1
  158. package/dist/picker/picker.vue +11 -9
  159. package/dist/picker-item/README.en-US.md +1 -1
  160. package/dist/picker-item/README.md +1 -1
  161. package/dist/picker-item/picker-item.vue +6 -5
  162. package/dist/popover/README.en-US.md +1 -1
  163. package/dist/popover/README.md +1 -1
  164. package/dist/popover/popover.vue +8 -5
  165. package/dist/popup/README.en-US.md +1 -1
  166. package/dist/popup/README.md +1 -1
  167. package/dist/popup/popup.vue +8 -5
  168. package/dist/progress/README.en-US.md +1 -1
  169. package/dist/progress/README.md +1 -1
  170. package/dist/progress/progress.vue +5 -4
  171. package/dist/pull-down-refresh/README.en-US.md +1 -1
  172. package/dist/pull-down-refresh/README.md +1 -1
  173. package/dist/pull-down-refresh/pull-down-refresh.vue +7 -5
  174. package/dist/qrcode/components/qrcode-canvas/qrcode-canvas.vue +8 -7
  175. package/dist/qrcode/components/qrcode-status/qrcode-status.vue +2 -1
  176. package/dist/qrcode/qrcode.vue +5 -3
  177. package/dist/radio/README.en-US.md +1 -1
  178. package/dist/radio/README.md +1 -1
  179. package/dist/radio/radio.vue +5 -4
  180. package/dist/radio-group/radio-group.vue +5 -4
  181. package/dist/rate/README.en-US.md +1 -1
  182. package/dist/rate/README.md +1 -1
  183. package/dist/rate/rate.vue +8 -5
  184. package/dist/result/README.en-US.md +1 -1
  185. package/dist/result/README.md +1 -1
  186. package/dist/result/result.vue +5 -4
  187. package/dist/row/row.vue +7 -3
  188. package/dist/scroll-view/scroll-view.vue +1 -1
  189. package/dist/search/README.en-US.md +1 -1
  190. package/dist/search/README.md +1 -1
  191. package/dist/search/search.css +5 -0
  192. package/dist/search/search.vue +21 -21
  193. package/dist/segmented/README.en-US.md +42 -0
  194. package/dist/segmented/README.md +75 -0
  195. package/dist/segmented/props.ts +31 -0
  196. package/dist/segmented/segmented.css +66 -0
  197. package/dist/segmented/segmented.vue +177 -0
  198. package/dist/segmented/type.ts +41 -0
  199. package/dist/side-bar/README.en-US.md +1 -1
  200. package/dist/side-bar/README.md +1 -1
  201. package/dist/side-bar/side-bar.vue +5 -3
  202. package/dist/side-bar-item/side-bar-item.vue +7 -6
  203. package/dist/skeleton/README.en-US.md +1 -1
  204. package/dist/skeleton/README.md +1 -1
  205. package/dist/skeleton/skeleton.vue +6 -3
  206. package/dist/slider/README.en-US.md +1 -1
  207. package/dist/slider/README.md +1 -1
  208. package/dist/slider/slider.vue +7 -5
  209. package/dist/step-item/step-item.vue +5 -4
  210. package/dist/stepper/README.en-US.md +1 -1
  211. package/dist/stepper/README.md +1 -1
  212. package/dist/stepper/stepper.vue +5 -3
  213. package/dist/steps/README.en-US.md +1 -1
  214. package/dist/steps/README.md +1 -1
  215. package/dist/steps/steps.vue +5 -3
  216. package/dist/sticky/sticky.vue +4 -3
  217. package/dist/swipe-cell/swipe-cell.vue +7 -5
  218. package/dist/swiper/README.en-US.md +1 -1
  219. package/dist/swiper/README.md +1 -1
  220. package/dist/swiper/swiper.vue +7 -5
  221. package/dist/swiper-nav/swiper-nav.vue +6 -3
  222. package/dist/switch/README.en-US.md +1 -1
  223. package/dist/switch/README.md +1 -1
  224. package/dist/switch/switch.vue +5 -4
  225. package/dist/tab-bar/README.en-US.md +1 -1
  226. package/dist/tab-bar/README.md +1 -1
  227. package/dist/tab-bar/tab-bar.vue +5 -3
  228. package/dist/tab-bar-item/tab-bar-item.vue +10 -10
  229. package/dist/tab-panel/tab-panel.vue +5 -3
  230. package/dist/table/README.en-US.md +72 -0
  231. package/dist/table/README.md +117 -0
  232. package/dist/table/base-table-props.ts +105 -0
  233. package/dist/table/props.ts +94 -0
  234. package/dist/table/table.css +251 -0
  235. package/dist/table/table.vue +582 -0
  236. package/dist/table/type.ts +180 -0
  237. package/dist/tabs/README.en-US.md +1 -1
  238. package/dist/tabs/README.md +1 -1
  239. package/dist/tabs/tabs.css +4 -0
  240. package/dist/tabs/tabs.vue +11 -9
  241. package/dist/tag/README.en-US.md +1 -1
  242. package/dist/tag/README.md +1 -1
  243. package/dist/tag/tag.vue +6 -3
  244. package/dist/textarea/README.en-US.md +1 -1
  245. package/dist/textarea/README.md +1 -1
  246. package/dist/textarea/textarea.vue +6 -3
  247. package/dist/theme-light.css +282 -0
  248. package/dist/theme-light.css.d.ts +2 -0
  249. package/dist/theme-light.less +1 -0
  250. package/dist/theme-light.less.d.ts +2 -0
  251. package/dist/toast/README.en-US.md +1 -1
  252. package/dist/toast/README.md +1 -1
  253. package/dist/toast/toast.vue +8 -7
  254. package/dist/transition/transition.vue +2 -2
  255. package/dist/tree-select/README.en-US.md +1 -1
  256. package/dist/tree-select/README.md +1 -1
  257. package/dist/tree-select/tree-select.vue +14 -9
  258. package/dist/types/action-sheet.d.ts +1 -1
  259. package/dist/types/avatar-group.d.ts +1 -1
  260. package/dist/types/avatar.d.ts +1 -1
  261. package/dist/types/back-top.d.ts +1 -1
  262. package/dist/types/badge.d.ts +1 -1
  263. package/dist/types/button.d.ts +1 -1
  264. package/dist/types/calendar.d.ts +1 -1
  265. package/dist/types/cascader.d.ts +1 -1
  266. package/dist/types/cell-group.d.ts +1 -1
  267. package/dist/types/cell.d.ts +1 -1
  268. package/dist/types/check-tag.d.ts +1 -1
  269. package/dist/types/checkbox-group.d.ts +1 -1
  270. package/dist/types/checkbox.d.ts +1 -1
  271. package/dist/types/col.d.ts +1 -1
  272. package/dist/types/collapse-panel.d.ts +1 -1
  273. package/dist/types/collapse.d.ts +1 -1
  274. package/dist/types/color-picker.d.ts +1 -1
  275. package/dist/types/index.d.ts +2 -0
  276. package/dist/types/segmented.d.ts +7 -0
  277. package/dist/types/table.d.ts +7 -0
  278. package/dist/upload/README.en-US.md +1 -1
  279. package/dist/upload/README.md +1 -1
  280. package/dist/upload/upload.vue +32 -32
  281. package/dist/watermark/README.en-US.md +1 -1
  282. package/dist/watermark/README.md +1 -1
  283. package/dist/watermark/utils/generateBase64Url.js +6 -6
  284. package/dist/watermark/watermark.vue +4 -3
  285. package/global.d.ts +2 -0
  286. package/package.json +33 -9
  287. package/{dist/script → script}/postinstall.js +18 -2
@@ -5,19 +5,24 @@
5
5
  >
6
6
  <view :class="formItemClass + '-wrap ' + formItemClass + '--' + dataLabelAlign + ' ' + tClassWrap">
7
7
  <!-- 标签区域 -->
8
- <view
9
- v-if="label"
10
- :class="labelClass + ' ' + labelClass + '--' + dataLabelAlign
11
- + (dataRequiredMark ? ' ' + labelClass + '--required' : '')
12
- + (dataRequiredMark && requiredMarkPosition === 'right' ? ' ' + labelClass + '--required-right' : '')
13
- + ' ' + tClassLabel"
14
- :style="'width: ' + dataLabelWidth"
15
- >
16
- <label :for="forId">{{ label }}</label>
17
- <template v-if="colon">
18
- {{ globalConfig.colonText }}
19
- </template>
20
- </view>
8
+ <slot name="label">
9
+ <view
10
+ v-if="label"
11
+ :class="labelClass + ' ' + labelClass + '--' + dataLabelAlign
12
+ + (dataRequiredMark ? ' ' + labelClass + '--required' : '')
13
+ + (dataRequiredMark && requiredMarkPosition === 'right' ? ' ' + labelClass + '--required-right' : '')
14
+ + ' ' + tClassLabel"
15
+ :style="'width: ' + dataLabelWidth"
16
+ >
17
+ <label
18
+ :class="labelClass + '-text'"
19
+ :for="forId"
20
+ >{{ label }}</label>
21
+ <template v-if="colon">
22
+ {{ globalConfig.colonText }}
23
+ </template>
24
+ </view>
25
+ </slot>
21
26
 
22
27
  <!-- 内容区域 -->
23
28
  <view :class="formClass + '__controls ' + errorClasses + ' ' + tClassControls">
@@ -28,12 +33,14 @@
28
33
  <slot />
29
34
  </view>
30
35
  <!-- 帮助信息 -->
31
- <view
32
- v-if="help"
33
- :class="formItemClass + '-help ' + formClass + '__controls--' + dataContentAlign + ' ' + tClassHelp"
34
- >
35
- {{ help }}
36
- </view>
36
+ <slot name="help">
37
+ <view
38
+ v-if="help"
39
+ :class="formItemClass + '-help ' + formClass + '__controls--' + dataContentAlign + ' ' + tClassHelp"
40
+ >
41
+ {{ help }}
42
+ </view>
43
+ </slot>
37
44
 
38
45
  <!-- 校验提示信息 -->
39
46
  <view
@@ -53,16 +60,18 @@
53
60
  </view>
54
61
  </template>
55
62
  <script>
56
- import { uniComponent } from '../common/src/index';
57
- import { getRect } from '../common/utils';
58
63
  import { prefix } from '../common/config';
59
- import props from './props';
60
- import { validateRules, ValidateStatus } from './form-model';
61
- import TIcon from '../icon/icon.vue';
64
+
62
65
  import { ChildrenMixin, RELATION_MAP } from '../common/relation';
66
+ import { uniComponent } from '../common/src/index';
67
+ import { getRect } from '../common/utils';
63
68
  import tools from '../common/utils.wxs';
64
- import usingConfig from '../mixins/using-config';
65
69
  import { isNumeric } from '../common/validator';
70
+ import TIcon from '../icon/icon.vue';
71
+ import usingConfig from '../mixins/using-config';
72
+
73
+ import { validateRules, ValidateStatus } from './form-model';
74
+ import props from './props';
66
75
 
67
76
  const parentComponentName = 'form';
68
77
  const componentName = 'form-item';
@@ -162,14 +171,14 @@ export default {
162
171
  const formRules = target.rules?.[this.name];
163
172
  const isRequired = formRules?.some(rule => rule.required);
164
173
 
165
- this.dataRules = formRules;
174
+ this.dataRules = formRules || [];
166
175
  this.colon = target.colon;
167
176
  this.dataLabelAlign = labelAlign || target.labelAlign;
168
177
  this.dataLabelWidth = normalizeLabelWidth(labelWidth || target.labelWidth);
169
178
  this.dataContentAlign = contentAlign || target.contentAlign;
170
179
  this.dataRequiredMark = requiredMark || target.requiredMark || globalConfig.requiredMark || isRequired;
171
180
  this.dataShowErrorMessage = typeof showErrorMessage === 'boolean' ? showErrorMessage : target.showErrorMessage;
172
- this.requiredMarkPosition = target.requiredMarkPosition || globalConfig.requiredMarkPosition;
181
+ this.requiredMarkPosition = target.requiredMarkPosition || globalConfig.requiredMarkPosition || 'left';
173
182
  },
174
183
  innerAfterUnlinked() {
175
184
  if (this.form) {
@@ -8,6 +8,14 @@ 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
+ },
11
19
  /** 表单项说明内容 */
12
20
  help: {
13
21
  type: String,
@@ -12,6 +12,10 @@ export interface TdFormItemProps {
12
12
  * @default false
13
13
  */
14
14
  arrow?: boolean;
15
+ /**
16
+ * 表单内容对齐方式:左对齐、右对齐,优先级高于 Form.contentAlign
17
+ */
18
+ contentAlign?: 'left' | 'right';
15
19
  /**
16
20
  * 表单项说明内容
17
21
  */
@@ -70,7 +70,7 @@ t-class-text | \-
70
70
  ### CSS Variables
71
71
 
72
72
  The component provides the following CSS variables, which can be used to customize styles.
73
- Name | Default Value | Description
73
+ Name | Default Value | Description
74
74
  -- | -- | --
75
75
  --td-grid-bg-color | @bg-color-container | -
76
76
  --td-grid-card-radius | @radius-large | -
@@ -123,7 +123,7 @@ t-class-text | 文本样式类
123
123
  ### CSS Variables
124
124
 
125
125
  组件提供了下列 CSS 变量,可用于自定义样式。
126
- 名称 | 默认值 | 描述
126
+ 名称 | 默认值 | 描述
127
127
  -- | -- | --
128
128
  --td-grid-bg-color | @bg-color-container | -
129
129
  --td-grid-card-radius | @radius-large | -
@@ -22,12 +22,13 @@
22
22
  </view>
23
23
  </template>
24
24
  <script>
25
- import { uniComponent } from '../common/src/index';
26
25
  import { prefix } from '../common/config';
26
+ import { ParentMixin, RELATION_MAP } from '../common/relation';
27
+ import { uniComponent } from '../common/src/index';
28
+ import tools from '../common/utils.wxs';
27
29
  import { isObject } from '../common/validator';
30
+
28
31
  import props from './props';
29
- import tools from '../common/utils.wxs';
30
- import { ParentMixin, RELATION_MAP } from '../common/relation';
31
32
 
32
33
 
33
34
  const name = `${prefix}-grid`;
@@ -45,7 +45,7 @@ t-class-text | \-
45
45
  ### CSS Variables
46
46
 
47
47
  The component provides the following CSS variables, which can be used to customize styles.
48
- Name | Default Value | Description
48
+ Name | Default Value | Description
49
49
  -- | -- | --
50
50
  --td-grid-item-bg-color | @bg-color-container | -
51
51
  --td-grid-item-description-color | @text-color-placeholder | -
@@ -45,7 +45,7 @@ t-class-text | 文本样式类
45
45
  ### CSS Variables
46
46
 
47
47
  组件提供了下列 CSS 变量,可用于自定义样式。
48
- 名称 | 默认值 | 描述
48
+ 名称 | 默认值 | 描述
49
49
  -- | -- | --
50
50
  --td-grid-item-bg-color | @bg-color-container | -
51
51
  --td-grid-item-description-color | @text-color-placeholder | -
@@ -118,17 +118,19 @@
118
118
  </view>
119
119
  </template>
120
120
  <script>
121
- import TImage from '../image/image';
122
- import TIcon from '../icon/icon';
123
121
  import TBadge from '../badge/badge';
124
122
 
125
- import { uniComponent } from '../common/src/index';
126
123
  import { prefix } from '../common/config';
127
- import props from './props';
124
+
125
+ import { ChildrenMixin, RELATION_MAP } from '../common/relation';
126
+ import { uniComponent } from '../common/src/index';
128
127
  import { uniqueFactory, setIcon } from '../common/utils';
129
- import { isObject } from '../common/validator';
130
128
  import tools from '../common/utils.wxs';
131
- import { ChildrenMixin, RELATION_MAP } from '../common/relation';
129
+ import { isObject } from '../common/validator';
130
+ import TIcon from '../icon/icon';
131
+ import TImage from '../image/image';
132
+
133
+ import props from './props';
132
134
 
133
135
 
134
136
  const name = `${prefix}-grid-item`;
@@ -70,7 +70,7 @@ title | String | - | title of current step | N
70
70
  ### CSS Variables
71
71
 
72
72
  The component provides the following CSS variables, which can be used to customize styles.
73
- Name | Default Value | Description
73
+ Name | Default Value | Description
74
74
  -- | -- | --
75
75
  --td-guide-body-color | @text-color-secondary | -
76
76
  --td-guide-dialog-body-font | @font-body-large | -
@@ -109,7 +109,7 @@ title | String | - | 当前步骤的标题内容,支持插槽:slot="title-{{
109
109
  ### CSS Variables
110
110
 
111
111
  组件提供了下列 CSS 变量,可用于自定义样式。
112
- 名称 | 默认值 | 描述
112
+ 名称 | 默认值 | 描述
113
113
  -- | -- | --
114
114
  --td-guide-body-color | @text-color-secondary | -
115
115
  --td-guide-dialog-body-font | @font-body-large | -
@@ -210,18 +210,19 @@
210
210
  </template>
211
211
 
212
212
  <script>
213
- import TOverlay from '../overlay/overlay';
214
- import TPopup from '../popup/popup';
215
- import { uniComponent } from '../common/src/index';
216
- import props from './props';
217
213
  import { prefix } from '../common/config';
218
- import { isFunction, isNumeric } from '../common/validator';
214
+ import { uniComponent } from '../common/src/index';
219
215
  import { debounce, getRect, rpx2px, styles, unitConvert, nextTick, systemInfo, coalesce } from '../common/utils';
216
+ import { isFunction, isNumeric } from '../common/validator';
217
+ import usingConfig from '../mixins/using-config';
218
+ import useCustomNavbar from '../mixins/using-custom-navbar';
219
+ import TOverlay from '../overlay/overlay';
220
+ import TPopup from '../popup/popup';
221
+
220
222
  import ContentComp from './content.vue';
223
+ import props from './props';
221
224
 
222
- import useCustomNavbar from '../mixins/using-custom-navbar';
223
225
 
224
- import usingConfig from '../mixins/using-config';
225
226
  const componentName = 'guide';
226
227
  const name = `${prefix}-${componentName}`;
227
228
 
@@ -24,12 +24,15 @@
24
24
  </view>
25
25
  </template>
26
26
  <script>
27
- import { uniComponent } from '../common/src/index';
28
27
  import { prefix } from '../common/config';
29
- import props from './props';
28
+ import { uniComponent } from '../common/src/index';
29
+
30
+
30
31
  import { styles, addUnit, getRect } from '../common/utils';
31
32
  import tools from '../common/utils.wxs';
32
33
 
34
+ import props from './props';
35
+
33
36
 
34
37
  const name = `${prefix}-icon`;
35
38
  export default {
@@ -43,7 +43,7 @@ t-class-load | \-
43
43
  ### CSS Variables
44
44
 
45
45
  The component provides the following CSS variables, which can be used to customize styles.
46
- Name | Default Value | Description
46
+ Name | Default Value | Description
47
47
  -- | -- | --
48
48
  --td-image-color | @text-color-placeholder | -
49
49
  --td-image-loading-bg-color | @bg-color-secondarycontainer | -
@@ -80,7 +80,7 @@ t-class-load | 加载样式类
80
80
  ### CSS Variables
81
81
 
82
82
  组件提供了下列 CSS 变量,可用于自定义样式。
83
- 名称 | 默认值 | 描述
83
+ 名称 | 默认值 | 描述
84
84
  -- | -- | --
85
85
  --td-image-color | @text-color-placeholder | -
86
86
  --td-image-loading-bg-color | @bg-color-secondarycontainer | -
@@ -83,14 +83,15 @@
83
83
  </view>
84
84
  </template>
85
85
  <script>
86
- import TLoading from '../loading/loading';
87
- import TIcon from '../icon/icon';
88
- import { uniComponent } from '../common/src/index';
89
- import ImageProps from './props';
90
86
  import { prefix } from '../common/config';
87
+ import { uniComponent } from '../common/src/index';
91
88
  import { addUnit, getRect, appBaseInfo } from '../common/utils';
92
- import { compareVersion } from '../common/version';
93
89
  import tools from '../common/utils.wxs';
90
+ import { compareVersion } from '../common/version';
91
+ import TIcon from '../icon/icon';
92
+ import TLoading from '../loading/loading';
93
+
94
+ import ImageProps from './props';
94
95
 
95
96
 
96
97
  const name = `${prefix}-image`;
@@ -14,10 +14,11 @@ image-props | Object | - | Typescript: `ImageProps`,[Image API Documents](./im
14
14
  images | Array | [] | Typescript: `Array<string>` | N
15
15
  initial-index | Number | 0 | Typescript: `Number` | N
16
16
  lazy | Boolean | true | \- | N
17
+ max-zoom | Number | 3 | \- | N
17
18
  show-index | Boolean | false | \- | N
18
19
  using-custom-navbar | Boolean | false | \- | N
19
- visible | Boolean | false | hide or show image viewer。`v-model:visible` is supported | N
20
- default-visible | Boolean | false | hide or show image viewer。uncontrolled property | N
20
+ visible | Boolean | false | hide or show image viewer。`v-model:visible` is supported。Typescript: `boolean \| null` | N
21
+ default-visible | Boolean | false | hide or show image viewer。uncontrolled property。Typescript: `boolean \| null` | N
21
22
 
22
23
  ### ImageViewer Events
23
24
 
@@ -37,7 +38,7 @@ delete-btn | \-
37
38
  ### CSS Variables
38
39
 
39
40
  The component provides the following CSS variables, which can be used to customize styles.
40
- Name | Default Value | Description
41
+ Name | Default Value | Description
41
42
  -- | -- | --
42
43
  --td-image-viewer-close-margin-left | @spacer-1 | -
43
44
  --td-image-viewer-delete-margin-right | @spacer-1 | -
@@ -45,10 +45,11 @@ image-props | Object | - | 透传至 Image 组件。TS 类型:`ImageProps`,[
45
45
  images | Array | [] | 图片数组。TS 类型:`Array<string>` | N
46
46
  initial-index | Number | 0 | 初始化页码。TS 类型:`Number` | N
47
47
  lazy | Boolean | true | 是否开启图片懒加载。开启后会预加载当前图片、相邻图片 | N
48
+ max-zoom | Number | 3 | 图片最大放大比例 | N
48
49
  show-index | Boolean | false | 是否显示页码 | N
49
50
  using-custom-navbar | Boolean | false | 是否使用了自定义导航栏 | N
50
- visible | Boolean | false | 隐藏/显示预览。支持语法糖 `v-model:visible` | N
51
- default-visible | Boolean | false | 隐藏/显示预览。非受控属性 | N
51
+ visible | Boolean | false | 隐藏/显示预览。支持语法糖 `v-model:visible`。TS 类型:`boolean \| null` | N
52
+ default-visible | Boolean | false | 隐藏/显示预览。非受控属性。TS 类型:`boolean \| null` | N
52
53
 
53
54
  ### ImageViewer Events
54
55
 
@@ -68,7 +69,7 @@ delete-btn | 删除操作
68
69
  ### CSS Variables
69
70
 
70
71
  组件提供了下列 CSS 变量,可用于自定义样式。
71
- 名称 | 默认值 | 描述
72
+ 名称 | 默认值 | 描述
72
73
  -- | -- | --
73
74
  --td-image-viewer-close-margin-left | @spacer-1 | -
74
75
  --td-image-viewer-delete-margin-right | @spacer-1 | -
@@ -28,6 +28,18 @@
28
28
  .t-image-viewer .swiper {
29
29
  outline: 0;
30
30
  }
31
+ .t-image-viewer__movable-area {
32
+ width: 100%;
33
+ height: 100%;
34
+ overflow: hidden;
35
+ }
36
+ .t-image-viewer__movable-view {
37
+ width: 100%;
38
+ height: 100%;
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ }
31
43
  .t-image-viewer__image {
32
44
  width: 100%;
33
45
  display: inline-block;
@@ -7,7 +7,6 @@
7
7
  :aria-modal="true"
8
8
  aria-role="dialog"
9
9
  aria-label="图片查看器"
10
- @touchmove.stop.prevent="true"
11
10
  >
12
11
  <view
13
12
  :class="classPrefix + '__mask'"
@@ -15,6 +14,7 @@
15
14
  :style="'' + tools._style([backgroundColor && '--td-image-viewer-mask-bg-color: ' + backgroundColor])"
16
15
  aria-role="button"
17
16
  aria-label="关闭"
17
+ @touchmove.prevent="() => {}"
18
18
  @click="(e) => onClose(e, 'overlay')"
19
19
  />
20
20
  <block v-if="images && images.length">
@@ -33,21 +33,42 @@
33
33
  :key="index"
34
34
  :class="classPrefix + '__preview-image'"
35
35
  >
36
- <t-image
37
- v-if="!lazy || shouldLoadImage(index, currentSwiperIndex, loadedImageIndexes)"
38
- :t-class="prefix + '-image--external'"
39
- :class="classPrefix + '__image'"
40
- :custom-style="(imagesStyle[index] && imagesStyle[index].style) || ''"
41
- :data-index="index"
42
- :src="item"
43
- :mode="(imageProps && imageProps.mode) || 'aspectFit'"
44
- :lazy="(imageProps && imageProps.lazy) || false"
45
- :loading="(imageProps && imageProps.loading) || 'default'"
46
- :shape="(imageProps && imageProps.shape) || 'square'"
47
- :webp="(imageProps && imageProps.webp) || false"
48
- :show-menu-by-longpress="(imageProps && imageProps.showMenuByLongpress) || false"
49
- @load="(e) => onImageLoadSuccess(e, { index })"
50
- />
36
+ <movable-area
37
+ :class="classPrefix + '__movable-area'"
38
+ scale-area
39
+ @touchmove="onAreaTouchMove"
40
+ >
41
+ <movable-view
42
+ :class="classPrefix + '__movable-view'"
43
+ direction="all"
44
+ :scale="true"
45
+ :scale-min="1"
46
+ :scale-max="maxZoom"
47
+ :scale-value="index === currentSwiperIndex ? currentScale : 1"
48
+ :damping="100"
49
+ :friction="20"
50
+ :out-of-bounds="false"
51
+ :disabled="false"
52
+ @scale="onMovableScale"
53
+ @tap.stop="onImageDoubleTap(index)"
54
+ >
55
+ <t-image
56
+ v-if="!lazy || shouldLoadImage(index, currentSwiperIndex, loadedImageIndexes)"
57
+ :t-class="prefix + '-image--external'"
58
+ :class="classPrefix + '__image'"
59
+ :custom-style="(imagesStyle[index] && imagesStyle[index].style) || ''"
60
+ :data-index="index"
61
+ :src="item"
62
+ :mode="(imageProps && imageProps.mode) || 'aspectFit'"
63
+ :lazy="(imageProps && imageProps.lazy) || false"
64
+ :loading="(imageProps && imageProps.loading) || 'default'"
65
+ :shape="(imageProps && imageProps.shape) || 'square'"
66
+ :webp="(imageProps && imageProps.webp) || false"
67
+ :show-menu-by-longpress="(imageProps && imageProps.showMenuByLongpress) || false"
68
+ @load="(e) => onImageLoadSuccess(e, { index })"
69
+ />
70
+ </movable-view>
71
+ </movable-area>
51
72
  </swiper-item>
52
73
  </swiper>
53
74
  </view>
@@ -111,16 +132,21 @@
111
132
  </view>
112
133
  </template>
113
134
  <script>
114
- import TImage from '../image/image';
115
- import TIcon from '../icon/icon';
135
+ import { prefix } from '../common/config';
116
136
  import { uniComponent } from '../common/src/index';
117
137
  import { styles, calcIcon, systemInfo } from '../common/utils';
118
- import { prefix } from '../common/config';
119
- import props from './props';
138
+
139
+
120
140
  import tools from '../common/utils.wxs';
121
- import { shouldLoadImage } from './computed.js';
141
+ import TIcon from '../icon/icon';
142
+ import TImage from '../image/image';
143
+
144
+
122
145
  import useCustomNavbar from '../mixins/using-custom-navbar';
123
146
 
147
+ import { shouldLoadImage } from './computed.js';
148
+ import props from './props';
149
+
124
150
 
125
151
  const name = `${prefix}-image-viewer`;
126
152
 
@@ -161,6 +187,8 @@ export default {
161
187
  iDeleteBtn: null,
162
188
  iCloseBtn: null,
163
189
  dataVisible: this.visible,
190
+ currentScale: 1,
191
+ lastTapTime: 0,
164
192
  };
165
193
  },
166
194
  watch: {
@@ -297,11 +325,46 @@ export default {
297
325
  const {
298
326
  detail: { current },
299
327
  } = e;
328
+ // 切换图片时重置缩放,避免上一张的缩放状态影响当前图
329
+ this.currentScale = 1;
300
330
  this.currentSwiperIndex = current;
301
331
 
302
332
  this._trigger('change', { index: current });
303
333
  },
304
334
 
335
+ onMovableScale(e) {
336
+ const scale = e?.detail?.scale ?? 1;
337
+ this.currentScale = scale;
338
+ },
339
+
340
+ onAreaTouchMove(e) {
341
+ // 当图片处于缩放状态时,阻止 touchmove 冒泡到 swiper,避免误触翻页(H5 端兜底)
342
+ // movable-view 自身仍会响应拖动/pinch,不受影响
343
+ // 注:小程序端原生 swiper 滑动手势底层接管,stopPropagation 无效,留作平台限制
344
+ if (this.currentScale > 1) {
345
+ if (e && typeof e.stopPropagation === 'function') {
346
+ e.stopPropagation();
347
+ }
348
+ if (e && typeof e.preventDefault === 'function') {
349
+ e.preventDefault();
350
+ }
351
+ }
352
+ },
353
+
354
+ onImageDoubleTap(index) {
355
+ // 仅响应当前图片,避免影响其它 swiper-item
356
+ if (index !== this.currentSwiperIndex) return;
357
+ const now = Date.now();
358
+ if (now - this.lastTapTime < 300) {
359
+ // 双击:在 1 与 maxZoom 之间切换
360
+ const max = Number(this.maxZoom) || 3;
361
+ this.currentScale = this.currentScale > 1 ? 1 : max;
362
+ this.lastTapTime = 0;
363
+ } else {
364
+ this.lastTapTime = now;
365
+ }
366
+ },
367
+
305
368
  onClose(e, source) {
306
369
  this._trigger('close', { visible: false, trigger: source || 'button', index: this.currentSwiperIndex });
307
370
  },
@@ -40,6 +40,11 @@ export default {
40
40
  type: Boolean,
41
41
  default: true,
42
42
  },
43
+ /** 图片最大放大比例 */
44
+ maxZoom: {
45
+ type: Number,
46
+ default: 3,
47
+ },
43
48
  /** 是否显示页码 */
44
49
  showIndex: Boolean,
45
50
  /** 是否使用了自定义导航栏 */
@@ -41,6 +41,11 @@ export interface TdImageViewerProps {
41
41
  * @default true
42
42
  */
43
43
  lazy?: boolean;
44
+ /**
45
+ * 图片最大放大比例
46
+ * @default 3
47
+ */
48
+ maxZoom?: number;
44
49
  /**
45
50
  * 是否显示页码
46
51
  * @default false
@@ -60,7 +65,7 @@ export interface TdImageViewerProps {
60
65
  * 隐藏/显示预览,非受控属性
61
66
  * @default false
62
67
  */
63
- defaultVisible?: boolean;
68
+ defaultVisible?: boolean | null;
64
69
  /**
65
70
  * 翻页时回调
66
71
  */
@@ -52,7 +52,7 @@ t-class-sidebar-item | \-
52
52
  ### CSS Variables
53
53
 
54
54
  The component provides the following CSS variables, which can be used to customize styles.
55
- Name | Default Value | Description
55
+ Name | Default Value | Description
56
56
  -- | -- | --
57
57
  --td-indexes-sidebar-active-bg-color | @brand-color | -
58
58
  --td-indexes-sidebar-active-color | @text-color-anti | -
@@ -83,7 +83,7 @@ t-class-sidebar-item | 侧边栏选项样式类
83
83
  ### CSS Variables
84
84
 
85
85
  组件提供了下列 CSS 变量,可用于自定义样式。
86
- 名称 | 默认值 | 描述
86
+ 名称 | 默认值 | 描述
87
87
  -- | -- | --
88
88
  --td-indexes-sidebar-active-bg-color | @brand-color | -
89
89
  --td-indexes-sidebar-active-color | @text-color-anti | -
@@ -1,4 +1,8 @@
1
- export function getFirstCharacter(str) {
2
- return str.toString().substring(0, 1);
1
+ export function getFirstCharacter(str, showFullIndex) {
2
+ const res = str.toString();
3
+ if (showFullIndex) {
4
+ return res;
5
+ }
6
+ return res.substring(0, 1);
3
7
  }
4
8
 
@@ -5,17 +5,22 @@
5
5
  .t-indexes__sidebar {
6
6
  position: fixed;
7
7
  right: var(--td-indexes-sidebar-right, 16rpx);
8
- width: var(--td-indexes-sidebar-item-size, 40rpx);
9
8
  color: var(--td-indexes-sidebar-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
10
9
  font: var(--td-indexes-sidebar-font, var(--td-font-body-small, 24rpx / 40rpx var(--td-font-family, PingFang SC, Microsoft YaHei, Arial Regular)));
11
10
  display: flex;
11
+ align-items: center;
12
+ justify-content: center;
12
13
  flex-flow: column nowrap;
13
14
  top: 50%;
14
15
  transform: translateY(-50%);
15
16
  z-index: 1;
16
17
  }
17
18
  .t-indexes__sidebar-item {
18
- border-radius: 50%;
19
+ min-width: var(--td-indexes-sidebar-item-size, 40rpx);
20
+ height: var(--td-indexes-sidebar-item-size, 40rpx);
21
+ padding: 0 calc(var(--td-spacer, 16rpx) / 2);
22
+ box-sizing: border-box;
23
+ border-radius: var(--td-indexes-sidebar-item-size, 40rpx);
19
24
  position: relative;
20
25
  text-align: center;
21
26
  }