@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,7 +1,7 @@
1
1
  ---
2
2
  title: Drawer 抽屉
3
3
  description: 用作一组平行关系页面/内容的切换器,相较于Tab,同屏可展示更多的选项数量。
4
- spline: message
4
+ spline: navigation
5
5
  isComponent: true
6
6
  ---
7
7
 
@@ -75,64 +75,66 @@ import tools from '../common/utils.wxs';
75
75
  const name = `${prefix}-drawer`;
76
76
 
77
77
 
78
- export default uniComponent({
79
- name,
80
- options: {
81
- styleIsolation: 'shared',
82
- },
83
- mixins: [
84
- useCustomNavbar,
85
- ],
78
+ export default {
86
79
  components: {
87
80
  TPopup,
88
81
  TIcon,
89
82
  },
90
- props: {
91
- ...props,
92
- },
93
- emits: [
94
- 'update:visible',
95
- 'close',
96
- 'overlay-click',
97
- 'item-click',
98
- ],
99
- data() {
100
- return {
101
- classPrefix: name,
102
- tools,
103
- dataVisible: coalesce(this.visible, this.defaultVisible),
104
- };
105
- },
106
- watch: {
107
- visible(e) {
108
- this.dataVisible = e;
83
+ ...uniComponent({
84
+ name,
85
+ options: {
86
+ styleIsolation: 'shared',
109
87
  },
110
- },
111
- methods: {
88
+ mixins: [
89
+ useCustomNavbar,
90
+ ],
91
+ props: {
92
+ ...props,
93
+ },
94
+ emits: [
95
+ 'update:visible',
96
+ 'close',
97
+ 'overlay-click',
98
+ 'item-click',
99
+ ],
100
+ data() {
101
+ return {
102
+ classPrefix: name,
103
+ tools,
104
+ dataVisible: coalesce(this.visible, this.defaultVisible),
105
+ };
106
+ },
107
+ watch: {
108
+ visible(e) {
109
+ this.dataVisible = e;
110
+ },
111
+ },
112
+ methods: {
112
113
  // closeOnOverlayClick 为 true 时才能触发 popup 的 visible-change 事件
113
- onVisibleChange(detail) {
114
- const { visible } = detail;
115
- const { showOverlay } = this;
114
+ onVisibleChange(detail) {
115
+ const { visible } = detail;
116
+ const { showOverlay } = this;
116
117
 
117
- this.dataVisible = visible;
118
+ this.dataVisible = visible;
118
119
 
119
- if (!visible) {
120
- this.$emit('close', { trigger: 'overlay' });
121
- }
120
+ if (!visible) {
121
+ this.$emit('close', { trigger: 'overlay' });
122
+ }
122
123
 
123
- if (showOverlay) {
124
- this.$emit('overlay-click', { visible });
125
- }
126
- this.$emit('update:visible', visible);
127
- },
124
+ if (showOverlay) {
125
+ this.$emit('overlay-click', { visible });
126
+ }
127
+ this.$emit('update:visible', visible);
128
+ },
128
129
 
129
- onItemClick(detail) {
130
- const { index, item } = detail.currentTarget.dataset;
130
+ onItemClick(detail) {
131
+ const { index, item } = detail.currentTarget.dataset;
131
132
 
132
- this.$emit('item-click', { index, item });
133
+ this.$emit('item-click', { index, item });
134
+ },
133
135
  },
134
- },
135
- });
136
+ }),
137
+ };
136
138
  </script>
137
139
  <style scoped src="./drawer.css"></style>
138
140
  <style>
@@ -2,12 +2,12 @@
2
2
  <view
3
3
  v-if="wrapperVisible"
4
4
  :class="classPrefix + ' ' + tClass"
5
- :style="tools._style([getStyles(top, zIndex), customStyle])"
5
+ :style="'' + tools._style([getStyles(top, zIndex), customStyle])"
6
6
  >
7
7
  <view
8
8
  v-if="show"
9
9
  :class="classPrefix + '__mask'"
10
- :style="tools._style(['height:' + maskHeight + 'px', customStyle])"
10
+ :style="'' + tools._style(['height:' + maskHeight + 'px', customStyle])"
11
11
  @click="handleMaskClick"
12
12
  @touchmove.stop.prevent="closeDropdown"
13
13
  />
@@ -137,24 +137,7 @@ import { canUseVirtualHost } from '../common/version';
137
137
  const name = `${prefix}-dropdown-item`;
138
138
 
139
139
 
140
- export default uniComponent({
141
- name,
142
- options: {
143
- styleIsolation: 'shared',
144
- },
145
- controlledProps: [{
146
- key: 'value',
147
- event: 'change',
148
- }],
149
- externalClasses: [
150
- `${prefix}-class`,
151
- `${prefix}-class-content`,
152
- `${prefix}-class-column`,
153
- `${prefix}-class-column-item`,
154
- `${prefix}-class-column-item-label`,
155
- `${prefix}-class-footer`,
156
- ],
157
- mixins: [ChildrenMixin(RELATION_MAP.DropdownItem)],
140
+ export default {
158
141
  components: {
159
142
  TButton,
160
143
  TRadio,
@@ -163,227 +146,246 @@ export default uniComponent({
163
146
  TCheckboxGroup,
164
147
  TPopup,
165
148
  },
166
- props: {
167
- ...props,
168
- },
169
- emits: ['close', 'closed', 'change', 'reset', 'confirm', 'opened', 'open'],
170
- data() {
171
- return {
172
- prefix,
173
- classPrefix: name,
174
- show: false,
175
- top: 0,
176
- maskHeight: 0,
177
- initValue: null,
178
- hasChanged: false,
179
- duration: menuProps.duration.default,
180
- zIndex: menuProps.zIndex.default,
181
- overlay: menuProps.showOverlay.default,
182
- labelAlias: 'label',
183
- valueAlias: 'value',
184
- computedLabel: '',
185
- firstCheckedValue: '',
186
-
187
- dataValue: coalesce(this.value, this.defaultValue),
188
-
189
- wrapperVisible: false,
190
- tools,
191
-
192
- windowTop: 0,
193
- };
194
- },
195
- computed: {
196
- footerBtnTClass() {
197
- return canUseVirtualHost() ? this.footerBtnRealClass : '';
149
+ ...uniComponent({
150
+ name,
151
+ options: {
152
+ styleIsolation: 'shared',
198
153
  },
199
- footerBtnClass() {
200
- return !canUseVirtualHost() ? this.footerBtnRealClass : '';
154
+ controlledProps: [{
155
+ key: 'value',
156
+ event: 'change',
157
+ }],
158
+ externalClasses: [
159
+ `${prefix}-class`,
160
+ `${prefix}-class-content`,
161
+ `${prefix}-class-column`,
162
+ `${prefix}-class-column-item`,
163
+ `${prefix}-class-column-item-label`,
164
+ `${prefix}-class-footer`,
165
+ ],
166
+ mixins: [ChildrenMixin(RELATION_MAP.DropdownItem)],
167
+ props: {
168
+ ...props,
201
169
  },
202
- footerBtnRealClass() {
203
- const { classPrefix } = this;
204
- return `${classPrefix}__footer-btn ${classPrefix}__reset-btn`;
170
+ emits: ['close', 'closed', 'change', 'reset', 'confirm', 'opened', 'open'],
171
+ data() {
172
+ return {
173
+ prefix,
174
+ classPrefix: name,
175
+ show: false,
176
+ top: 0,
177
+ maskHeight: 0,
178
+ initValue: null,
179
+ hasChanged: false,
180
+ duration: menuProps.duration.default,
181
+ zIndex: menuProps.zIndex.default,
182
+ overlay: menuProps.showOverlay.default,
183
+ labelAlias: 'label',
184
+ valueAlias: 'value',
185
+ computedLabel: '',
186
+ firstCheckedValue: '',
187
+
188
+ dataValue: coalesce(this.value, this.defaultValue),
189
+
190
+ wrapperVisible: false,
191
+ tools,
192
+
193
+ windowTop: 0,
194
+ };
205
195
  },
196
+ computed: {
197
+ footerBtnTClass() {
198
+ return canUseVirtualHost() ? this.footerBtnRealClass : '';
199
+ },
200
+ footerBtnClass() {
201
+ return !canUseVirtualHost() ? this.footerBtnRealClass : '';
202
+ },
203
+ footerBtnRealClass() {
204
+ const { classPrefix } = this;
205
+ return `${classPrefix}__footer-btn ${classPrefix}__reset-btn`;
206
+ },
206
207
 
207
- confirmBtnTClass() {
208
- return canUseVirtualHost() ? this.confirmBtnRealClass : '';
209
- },
210
- confirmBtnClass() {
211
- return !canUseVirtualHost() ? this.confirmBtnRealClass : '';
212
- },
213
- confirmBtnRealClass() {
214
- const { classPrefix } = this;
215
- return `${classPrefix}__footer-btn ${classPrefix}__confirm-btn`;
216
- },
208
+ confirmBtnTClass() {
209
+ return canUseVirtualHost() ? this.confirmBtnRealClass : '';
210
+ },
211
+ confirmBtnClass() {
212
+ return !canUseVirtualHost() ? this.confirmBtnRealClass : '';
213
+ },
214
+ confirmBtnRealClass() {
215
+ const { classPrefix } = this;
216
+ return `${classPrefix}__footer-btn ${classPrefix}__confirm-btn`;
217
+ },
217
218
 
218
- radioGroupCustomStyle() {
219
- return tools._style([
220
- {
221
- width: '100%',
222
- overflow: 'scroll',
223
- boxSizing: 'border-box',
219
+ radioGroupCustomStyle() {
220
+ return tools._style([
221
+ {
222
+ width: '100%',
223
+ overflow: 'scroll',
224
+ boxSizing: 'border-box',
224
225
 
225
- display: 'grid',
226
- gridGap: '0px',
226
+ display: 'grid',
227
+ gridGap: '0px',
227
228
 
228
- gridTemplateColumns: `repeat(${this.optionsColumns}, 1fr)`,
229
- },
230
- ]);
229
+ gridTemplateColumns: `repeat(${this.optionsColumns}, 1fr)`,
230
+ },
231
+ ]);
232
+ },
233
+ checkboxGroupCustomStyle() {
234
+ return tools._style([
235
+ {
236
+ width: '100%',
237
+ overflow: 'scroll',
238
+ boxSizing: 'border-box',
239
+
240
+ display: 'grid',
241
+ gridGap: '12px',
242
+
243
+ gridTemplateColumns: `repeat(${this.optionsColumns}, 1fr)`,
244
+ padding: '16px',
245
+ },
246
+ ]);
247
+ },
231
248
  },
232
- checkboxGroupCustomStyle() {
233
- return tools._style([
234
- {
235
- width: '100%',
236
- overflow: 'scroll',
237
- boxSizing: 'border-box',
238
-
239
- display: 'grid',
240
- gridGap: '12px',
241
-
242
- gridTemplateColumns: `repeat(${this.optionsColumns}, 1fr)`,
243
- padding: '16px',
249
+ watch: {
250
+ keys: {
251
+ handler(obj) {
252
+ this.labelAlias = obj?.label || 'label';
253
+ this.valueAlias = obj?.value || 'value';
244
254
  },
245
- ]);
246
- },
247
- },
248
- watch: {
249
- keys: {
250
- handler(obj) {
251
- this.labelAlias = obj?.label || 'label';
252
- this.valueAlias = obj?.value || 'value';
255
+ immediate: true,
253
256
  },
254
- immediate: true,
255
- },
256
- value: {
257
- handler(value) {
258
- this.dataValue = value;
257
+ value: {
258
+ handler(value) {
259
+ this.dataValue = value;
260
+ },
261
+ immediate: true,
259
262
  },
260
- immediate: true,
261
- },
262
- dataValue: {
263
- handler(v) {
264
- const { options, labelAlias, valueAlias } = this;
263
+ dataValue: {
264
+ handler(v) {
265
+ const { options, labelAlias, valueAlias } = this;
265
266
 
266
- if (this.multiple) {
267
- if (v && !Array.isArray(v)) throw TypeError('应传入数组类型的 value');
268
- }
267
+ if (this.multiple) {
268
+ if (v && !Array.isArray(v)) throw TypeError('应传入数组类型的 value');
269
+ }
269
270
 
270
- const target = options.find(item => item[valueAlias] === v);
271
+ const target = options.find(item => item[valueAlias] === v);
271
272
 
272
- if (target) {
273
- this.computedLabel = target[labelAlias];
274
- }
273
+ if (target) {
274
+ this.computedLabel = target[labelAlias];
275
+ }
276
+ },
277
+ immediate: true,
275
278
  },
276
- immediate: true,
277
- },
278
- label: 'getParentAllItems',
279
- computedLabel: 'getParentAllItems',
280
- disabled: 'getParentAllItems',
281
- show: {
282
- handler(visible) {
283
- if (visible) {
284
- this.getParentBottom(() => {
285
- this.wrapperVisible = true;
286
- });
287
- }
279
+ label: 'getParentAllItems',
280
+ computedLabel: 'getParentAllItems',
281
+ disabled: 'getParentAllItems',
282
+ show: {
283
+ handler(visible) {
284
+ if (visible) {
285
+ this.getParentBottom(() => {
286
+ this.wrapperVisible = true;
287
+ });
288
+ }
289
+ },
290
+ immediate: true,
288
291
  },
289
- immediate: true,
290
292
  },
291
- },
292
- mounted() {
293
- const { windowTop } = getWindowInfo();
294
- this.windowTop = windowTop || 0;
295
- },
296
- methods: {
297
- getStyles,
298
- innerAfterLinked(target) {
299
- const { zIndex, duration, showOverlay } = target;
300
-
301
- this.zIndex = zIndex;
302
- this.duration = duration;
303
- this.showOverlay = showOverlay;
304
- },
305
- getParentAllItems() {
306
- this[RELATION_MAP.DropdownItem]?.getAllItems();
307
- },
308
- closeDropdown() {
309
- this[RELATION_MAP.DropdownItem].activeIdx = -1;
310
- this.show = false;
311
- this.$emit('close');
293
+ mounted() {
294
+ const { windowTop } = getWindowInfo();
295
+ this.windowTop = windowTop || 0;
312
296
  },
297
+ methods: {
298
+ getStyles,
299
+ innerAfterLinked(target) {
300
+ const { zIndex, duration, showOverlay } = target;
301
+
302
+ this.zIndex = zIndex;
303
+ this.duration = duration;
304
+ this.showOverlay = showOverlay;
305
+ },
306
+ getParentAllItems() {
307
+ this[RELATION_MAP.DropdownItem]?.getAllItems();
308
+ },
309
+ closeDropdown() {
310
+ this[RELATION_MAP.DropdownItem].activeIdx = -1;
311
+ this.show = false;
312
+ this.$emit('close');
313
+ },
313
314
 
314
- getParentBottom(cb) {
315
- getRect(this[RELATION_MAP.DropdownItem], `#${prefix}-bar`).then((rect) => {
316
- this.top = rect.bottom + (this.windowTop || 0);
317
- this.maskHeight = rect.top;
315
+ getParentBottom(cb) {
316
+ getRect(this[RELATION_MAP.DropdownItem], `#${prefix}-bar`).then((rect) => {
317
+ this.top = rect.bottom + (this.windowTop || 0);
318
+ this.maskHeight = rect.top;
318
319
 
319
- setTimeout(() => {
320
- cb();
321
- }, 20);
322
- });
323
- },
320
+ setTimeout(() => {
321
+ cb();
322
+ }, 20);
323
+ });
324
+ },
324
325
 
325
- handleTreeClick(e) {
326
- const { level, value: itemValue } = e.currentTarget.dataset;
327
- const { dataValue } = this;
326
+ handleTreeClick(e) {
327
+ const { level, value: itemValue } = e.currentTarget.dataset;
328
+ const { dataValue } = this;
328
329
 
329
- dataValue[level] = itemValue;
330
- this._trigger('change', { value: dataValue });
331
- },
330
+ dataValue[level] = itemValue;
331
+ this._trigger('change', { value: dataValue });
332
+ },
332
333
 
333
- onRadioChange(e, curValue) {
334
- this.handleRadioChange({ value: curValue });
335
- },
336
- onCheckboxChange(e) {
337
- const { checkAll, dataIndeterminate } = this.$refs.checkboxGroupRef;
338
- const { context: { value, label }, checked } = e;
339
- this.$refs.checkboxGroupRef.updateValue({
340
- value,
341
- checkAll,
342
- indeterminate: dataIndeterminate,
343
- checked,
344
- item: { label, value, checked },
345
- validChildren: false,
346
- });
347
- },
334
+ onRadioChange(e, curValue) {
335
+ this.handleRadioChange({ value: curValue });
336
+ },
337
+ onCheckboxChange(e) {
338
+ const { checkAll, dataIndeterminate } = this.$refs.checkboxGroupRef;
339
+ const { context: { value, label }, checked } = e;
340
+ this.$refs.checkboxGroupRef.updateValue({
341
+ value,
342
+ checkAll,
343
+ indeterminate: dataIndeterminate,
344
+ checked,
345
+ item: { label, value, checked },
346
+ validChildren: false,
347
+ });
348
+ },
348
349
 
349
- handleRadioChange(e) {
350
- const { value } = e;
350
+ handleRadioChange(e) {
351
+ const { value } = e;
351
352
 
352
- this._trigger('change', { value });
353
+ this._trigger('change', { value });
353
354
 
354
- if (!this.multiple) {
355
- this.closeDropdown();
356
- } else {
357
- const firstChecked = this.options.find(item => value.includes(item.value));
358
- if (firstChecked) {
359
- this.firstCheckedValue = firstChecked.value;
355
+ if (!this.multiple) {
356
+ this.closeDropdown();
357
+ } else {
358
+ const firstChecked = this.options.find(item => value.includes(item.value));
359
+ if (firstChecked) {
360
+ this.firstCheckedValue = firstChecked.value;
361
+ }
360
362
  }
361
- }
362
- },
363
+ },
363
364
 
364
- handleMaskClick() {
365
- if (this[RELATION_MAP.DropdownItem]?.closeOnClickOverlay) {
366
- this.closeDropdown();
367
- }
368
- },
365
+ handleMaskClick() {
366
+ if (this[RELATION_MAP.DropdownItem]?.closeOnClickOverlay) {
367
+ this.closeDropdown();
368
+ }
369
+ },
369
370
 
370
- handleReset() {
371
- this._trigger('change', { value: [] });
372
- this._trigger('reset');
373
- },
371
+ handleReset() {
372
+ this._trigger('change', { value: [] });
373
+ this._trigger('reset');
374
+ },
374
375
 
375
- handleConfirm() {
376
- this._trigger('confirm', { value: this.dataValue });
377
- this.closeDropdown();
376
+ handleConfirm() {
377
+ this._trigger('confirm', { value: this.dataValue });
378
+ this.closeDropdown();
378
379
  // 在关闭 popup 后才自动滚动到首个选项
379
380
  // this.firstCheckedValue = this.firstCheckedValue;
380
- },
381
+ },
381
382
 
382
- onLeaved() {
383
- this.wrapperVisible = false;
383
+ onLeaved() {
384
+ this.wrapperVisible = false;
385
+ },
384
386
  },
385
- },
386
- });
387
+ }),
388
+ };
387
389
 
388
390
  </script>
389
391
  <style scoped src="./dropdown-item.css"></style>
@@ -40,13 +40,13 @@ export default {
40
40
  },
41
41
  /** 选中值 */
42
42
  value: {
43
- type: [String, Number, Array],
44
- default: undefined as TdDropdownItemProps['value'],
43
+ type: [String, Number, Array, null],
44
+ default: null as TdDropdownItemProps['value'],
45
45
  },
46
46
  /** 选中值,非受控属性 */
47
47
  defaultValue: {
48
- type: [String, Number, Array],
49
- default: undefined as TdDropdownItemProps['defaultValue'],
48
+ type: [String, Number, Array, null],
49
+ default: null as TdDropdownItemProps['defaultValue'],
50
50
  },
51
51
  /** 值改变时触发 */
52
52
  onChange: {
@@ -44,11 +44,11 @@ export interface TdDropdownItemProps {
44
44
  /**
45
45
  * 选中值
46
46
  */
47
- value?: DropdownValue;
47
+ value?: DropdownValue | null;
48
48
  /**
49
49
  * 选中值,非受控属性
50
50
  */
51
- defaultValue?: DropdownValue;
51
+ defaultValue?: DropdownValue | null;
52
52
  /**
53
53
  * 值改变时触发
54
54
  */
@@ -70,7 +70,7 @@ export interface TdDropdownItemProps {
70
70
  export interface DropdownOption {
71
71
  label: string;
72
72
  disabled: boolean;
73
- value: DropdownValue;
73
+ value: DropdownValue | null;
74
74
  }
75
75
 
76
76
  export type DropdownValue = string | number | Array<DropdownValue>;