@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,6 +1,6 @@
1
1
  <template>
2
2
  <scroll-view
3
- :style="tools._style([customStyle, 'max-height: calc(100vh - ' + distanceTop + 'px)'])"
3
+ :style="'' + tools._style([customStyle, 'max-height: calc(100vh - ' + distanceTop + 'px)'])"
4
4
  :class="classPrefix + ' ' + tClass"
5
5
  type="list"
6
6
  :scroll-top="scrollTop"
@@ -70,7 +70,9 @@ import { getObserver } from '../common/wechat';
70
70
  import { ParentMixin, RELATION_MAP } from '../common/relation';
71
71
 
72
72
 
73
- const name = `${prefix}-pull-down-refresh`;
73
+ import usingConfig from '../mixins/using-config';
74
+ const componentName = 'pull-down-refresh';
75
+ const name = `${prefix}-${componentName}`;
74
76
  const defaultLoadingTexts = ['下拉刷新', '松手刷新', '正在刷新', '刷新完成'];
75
77
  const REFRESH_STATUS_MAP = {
76
78
  INITIAL: -1,
@@ -81,284 +83,288 @@ const REFRESH_STATUS_MAP = {
81
83
  };
82
84
 
83
85
 
84
- export default uniComponent({
85
- name,
86
- options: {
87
- styleIsolation: 'shared',
88
- },
89
- externalClasses: [
90
- `${prefix}-class`,
91
- `${prefix}-class-loading`,
92
- `${prefix}-class-text`,
93
- `${prefix}-class-indicator`,
94
- ],
95
- mixins: [
96
- ParentMixin(RELATION_MAP.BackTop),
97
- ],
86
+ export default {
98
87
  components: {
99
88
  TLoading,
100
89
  },
101
- props: {
102
- ...props,
103
- },
104
- emits: [
105
- 'scrolltolower',
106
- 'scroll',
107
- 'change',
108
- 'refresh',
109
- 'dragstart',
110
- 'dragging',
111
- 'dragend',
112
- 'timeout',
113
- ],
114
- data() {
115
- return {
116
- prefix,
117
- classPrefix: name,
118
- distanceTop: 0,
119
- barHeight: 0,
120
- tipsHeight: 0,
121
- refreshStatus: REFRESH_STATUS_MAP.INITIAL,
122
- loosing: false,
123
- enableToRefresh: true,
124
- scrollTop: 0,
125
- iMaxBarHeight: 0,
126
- iLoadingBarHeight: 0,
127
-
128
- pixelRatio: 1,
129
- startPoint: null,
130
- isPulling: false,
131
- maxRefreshAnimateTimeFlag: 0,
132
- closingAnimateTimeFlag: 0,
133
- refreshStatusTimer: null,
134
-
135
- tools,
136
- REFRESH_STATUS_MAP,
137
- };
138
- },
139
- computed: {
140
- touchEnable() {
141
- return this.refreshStatus !== REFRESH_STATUS_MAP.LOADING
90
+ ...uniComponent({
91
+ name,
92
+ options: {
93
+ styleIsolation: 'shared',
94
+ },
95
+ externalClasses: [
96
+ `${prefix}-class`,
97
+ `${prefix}-class-loading`,
98
+ `${prefix}-class-text`,
99
+ `${prefix}-class-indicator`,
100
+ ],
101
+ mixins: [
102
+ ParentMixin(RELATION_MAP.BackTop),
103
+ usingConfig({ componentName }),
104
+ ],
105
+ props: {
106
+ ...props,
107
+ },
108
+ emits: [
109
+ 'scrolltolower',
110
+ 'scroll',
111
+ 'change',
112
+ 'refresh',
113
+ 'dragstart',
114
+ 'dragging',
115
+ 'dragend',
116
+ 'timeout',
117
+ ],
118
+ data() {
119
+ return {
120
+ prefix,
121
+ classPrefix: name,
122
+ distanceTop: 0,
123
+ barHeight: 0,
124
+ tipsHeight: 0,
125
+ refreshStatus: REFRESH_STATUS_MAP.INITIAL,
126
+ loosing: false,
127
+ enableToRefresh: true,
128
+ scrollTop: 0,
129
+ iMaxBarHeight: 0,
130
+ iLoadingBarHeight: 0,
131
+
132
+ pixelRatio: 1,
133
+ startPoint: null,
134
+ isPulling: false,
135
+ maxRefreshAnimateTimeFlag: 0,
136
+ closingAnimateTimeFlag: 0,
137
+ refreshStatusTimer: null,
138
+
139
+ tools,
140
+ REFRESH_STATUS_MAP,
141
+ dataLoadingTexts: [],
142
+ };
143
+ },
144
+ computed: {
145
+ touchEnable() {
146
+ return this.refreshStatus !== REFRESH_STATUS_MAP.LOADING
142
147
  && this.refreshStatus !== REFRESH_STATUS_MAP.SUCCESS
143
148
  && !this.disabled;
149
+ },
144
150
  },
145
- },
146
- watch: {
147
- value(val) {
148
- if (!val) {
149
- clearTimeout(this.maxRefreshAnimateTimeFlag);
151
+ watch: {
152
+ value(val) {
153
+ if (!val) {
154
+ clearTimeout(this.maxRefreshAnimateTimeFlag);
150
155
 
151
- if (this.refreshStatus > REFRESH_STATUS_MAP.PULLING) {
152
- this.refreshStatus = REFRESH_STATUS_MAP.SUCCESS;
153
- }
156
+ if (this.refreshStatus > REFRESH_STATUS_MAP.PULLING) {
157
+ this.refreshStatus = REFRESH_STATUS_MAP.SUCCESS;
158
+ }
154
159
 
155
- clearTimeout(this.successTimer);
160
+ clearTimeout(this.successTimer);
156
161
 
157
- this.successTimer = setTimeout(() => {
158
- this.barHeight = 0;
159
- this.refreshStatus = REFRESH_STATUS_MAP.INITIAL;
160
- }, unitConvert(this.successDuration));
161
- } else {
162
- this.doRefresh();
163
- }
164
- },
165
-
166
- barHeight(val) {
167
- this.resetTimer();
168
- if (val === 0 && this.refreshStatus !== REFRESH_STATUS_MAP.INITIAL) {
169
- this.refreshStatusTimer = setTimeout(() => {
170
- this.refreshStatus = REFRESH_STATUS_MAP.INITIAL;
171
- }, 240);
172
- }
162
+ this.successTimer = setTimeout(() => {
163
+ this.barHeight = 0;
164
+ this.refreshStatus = REFRESH_STATUS_MAP.INITIAL;
165
+ }, unitConvert(this.successDuration));
166
+ } else {
167
+ this.doRefresh();
168
+ }
169
+ },
170
+
171
+ barHeight(val) {
172
+ this.resetTimer();
173
+ if (val === 0 && this.refreshStatus !== REFRESH_STATUS_MAP.INITIAL) {
174
+ this.refreshStatusTimer = setTimeout(() => {
175
+ this.refreshStatus = REFRESH_STATUS_MAP.INITIAL;
176
+ }, 240);
177
+ }
173
178
 
174
- this.tipsHeight = Math.min(val, this.iLoadingBarHeight);
175
- },
179
+ this.tipsHeight = Math.min(val, this.iLoadingBarHeight);
180
+ },
176
181
 
177
- maxBarHeight(v) {
178
- this.iMaxBarHeight = unitConvert(v);
179
- },
182
+ maxBarHeight(v) {
183
+ this.iMaxBarHeight = unitConvert(v);
184
+ },
180
185
 
181
- loadingBarHeight(v) {
182
- this.iLoadingBarHeight = unitConvert(v);
186
+ loadingBarHeight(v) {
187
+ this.iLoadingBarHeight = unitConvert(v);
188
+ },
183
189
  },
184
- },
185
- mounted() {
186
- const { screenWidth } = systemInfo;
187
- const { loadingTexts, maxBarHeight, loadingBarHeight } = this;
188
- const isCustomLoadingTexts = Array.isArray(loadingTexts) && loadingTexts.length >= 4;
189
-
190
- this.iMaxBarHeight = unitConvert(maxBarHeight);
191
- this.iLoadingBarHeight = unitConvert(loadingBarHeight);
192
- this.dataLoadingTexts = isCustomLoadingTexts ? loadingTexts : defaultLoadingTexts;
193
-
194
- this.pixelRatio = 750 / screenWidth;
190
+ mounted() {
191
+ const { screenWidth } = systemInfo;
192
+ const { loadingTexts, maxBarHeight, loadingBarHeight } = this;
193
+ const isCustomLoadingTexts = Array.isArray(loadingTexts) && loadingTexts.length >= 4;
195
194
 
196
- this.updateDistanceTop();
197
- },
195
+ this.iMaxBarHeight = unitConvert(maxBarHeight);
196
+ this.iLoadingBarHeight = unitConvert(loadingBarHeight);
197
+ this.dataLoadingTexts = isCustomLoadingTexts ? loadingTexts : defaultLoadingTexts;
198
198
 
199
- beforeUnmount() {
200
- clearTimeout(this.maxRefreshAnimateTimeFlag);
201
- clearTimeout(this.closingAnimateTimeFlag);
202
- this.resetTimer();
203
- },
204
- methods: {
205
- updateDistanceTop() {
206
- const update = (top) => {
207
- this.distanceTop = top;
208
- };
199
+ this.pixelRatio = 750 / screenWidth;
209
200
 
210
- getRect(this, `.${name}`).then((rect) => {
211
- if (rect.top) {
212
- update(rect.top);
213
- return;
214
- }
215
-
216
- getObserver(this, `.${name}`).then((res) => {
217
- if (res.intersectionRatio > 0) {
218
- update(res.boundingClientRect.top);
219
- }
220
- });
221
- });
201
+ this.updateDistanceTop();
222
202
  },
223
203
 
224
- resetTimer() {
225
- if (this.refreshStatusTimer) {
226
- clearTimeout(this.refreshStatusTimer);
227
- this.refreshStatusTimer = null;
228
- }
204
+ beforeUnmount() {
205
+ clearTimeout(this.maxRefreshAnimateTimeFlag);
206
+ clearTimeout(this.closingAnimateTimeFlag);
207
+ this.resetTimer();
229
208
  },
209
+ methods: {
210
+ updateDistanceTop() {
211
+ const update = (top) => {
212
+ this.distanceTop = top;
213
+ };
214
+
215
+ getRect(this, `.${name}`).then((rect) => {
216
+ if (rect.top) {
217
+ update(rect.top);
218
+ return;
219
+ }
230
220
 
231
- onScrollToBottom() {
232
- this.$emit('scrolltolower');
233
- },
221
+ getObserver(this, `.${name}`).then((res) => {
222
+ if (res.intersectionRatio > 0) {
223
+ update(res.boundingClientRect.top);
224
+ }
225
+ });
226
+ });
227
+ },
234
228
 
235
- onScrollToTop() {
236
- this.enableToRefresh = true;
237
- },
229
+ resetTimer() {
230
+ if (this.refreshStatusTimer) {
231
+ clearTimeout(this.refreshStatusTimer);
232
+ this.refreshStatusTimer = null;
233
+ }
234
+ },
238
235
 
239
- onScroll(e) {
240
- const { scrollTop } = e.detail;
236
+ onScrollToBottom() {
237
+ this.$emit('scrolltolower');
238
+ },
241
239
 
242
- this.enableToRefresh = scrollTop === 0;
243
- this.$emit('scroll', { scrollTop });
244
- },
240
+ onScrollToTop() {
241
+ this.enableToRefresh = true;
242
+ },
245
243
 
246
- onTouchStart(e) {
247
- if (this.isPulling || !this.enableToRefresh || !this.touchEnable) return;
244
+ onScroll(e) {
245
+ const { scrollTop } = e.detail;
248
246
 
249
- const { touches } = e;
250
- this.$emit('dragstart', e);
247
+ this.enableToRefresh = scrollTop === 0;
248
+ this.$emit('scroll', { scrollTop });
249
+ },
251
250
 
252
- if (touches.length !== 1) return;
253
- const { pageX, pageY } = touches[0];
251
+ onTouchStart(e) {
252
+ if (this.isPulling || !this.enableToRefresh || !this.touchEnable) return;
254
253
 
255
- this.loosing = false;
256
- this.startPoint = { pageX, pageY };
257
- this.isPulling = true;
258
- },
254
+ const { touches } = e;
255
+ this.$emit('dragstart', e);
259
256
 
260
- onTouchMove(e) {
261
- if (!this.startPoint || !this.touchEnable) return;
257
+ if (touches.length !== 1) return;
258
+ const { pageX, pageY } = touches[0];
262
259
 
260
+ this.loosing = false;
261
+ this.startPoint = { pageX, pageY };
262
+ this.isPulling = true;
263
+ },
263
264
 
264
- const { touches } = e;
265
+ onTouchMove(e) {
266
+ if (!this.startPoint || !this.touchEnable) return;
265
267
 
266
- if (touches.length !== 1) return;
267
268
 
268
- const { pageY } = touches[0];
269
- const offset = pageY - this.startPoint.pageY;
269
+ const { touches } = e;
270
270
 
271
- if (offset > 0) {
272
- this.setRefreshBarHeight(offset);
273
- }
274
- this.$emit('dragging', e);
275
- },
271
+ if (touches.length !== 1) return;
276
272
 
277
- onTouchEnd(e) {
278
- if (!this.startPoint || this.disabled) return;
279
- const { changedTouches } = e;
280
- if (changedTouches.length !== 1) return;
281
- const { pageY } = changedTouches[0];
273
+ const { pageY } = touches[0];
274
+ const offset = pageY - this.startPoint.pageY;
282
275
 
283
- const barHeight = pageY - this.startPoint.pageY;
284
- this.startPoint = null; // 清掉起点,之后将忽略touchMove、touchEnd事件
285
- this.isPulling = false;
276
+ if (offset > 0) {
277
+ this.setRefreshBarHeight(offset);
278
+ }
279
+ this.$emit('dragging', e);
280
+ },
281
+
282
+ onTouchEnd(e) {
283
+ if (!this.startPoint || this.disabled) return;
284
+ const { changedTouches } = e;
285
+ if (changedTouches.length !== 1) return;
286
+ const { pageY } = changedTouches[0];
287
+
288
+ const barHeight = pageY - this.startPoint.pageY;
289
+ this.startPoint = null; // 清掉起点,之后将忽略touchMove、touchEnd事件
290
+ this.isPulling = false;
291
+
292
+ this.loosing = true;
293
+
294
+ // 松开时高度超过阈值则触发刷新
295
+ if (barHeight > this.iLoadingBarHeight) {
296
+ this._trigger('change', { value: true });
297
+ this.$emit('refresh');
298
+ } else {
299
+ this.barHeight = 0;
300
+ }
286
301
 
287
- this.loosing = true;
302
+ this.$emit('dragend', e);
303
+ },
288
304
 
289
- // 松开时高度超过阈值则触发刷新
290
- if (barHeight > this.iLoadingBarHeight) {
291
- this._trigger('change', { value: true });
292
- this.$emit('refresh');
293
- } else {
294
- this.barHeight = 0;
295
- }
305
+ doRefresh() {
306
+ if (this.disabled) return;
307
+ this.barHeight = this.iLoadingBarHeight;
308
+ this.refreshStatus = REFRESH_STATUS_MAP.LOADING;
309
+ this.loosing = true;
296
310
 
297
- this.$emit('dragend', e);
298
- },
311
+ this.maxRefreshAnimateTimeFlag = setTimeout(() => {
312
+ this.maxRefreshAnimateTimeFlag = null;
299
313
 
300
- doRefresh() {
301
- if (this.disabled) return;
302
- this.barHeight = this.iLoadingBarHeight;
303
- this.refreshStatus = REFRESH_STATUS_MAP.LOADING;
304
- this.loosing = true;
314
+ if (this.refreshStatus === REFRESH_STATUS_MAP.LOADING) {
315
+ // 超时回调
316
+ this.$emit('timeout');
317
+ this._trigger('change', { value: false });
318
+ }
319
+ }, this.refreshTimeout);
320
+ },
305
321
 
306
- this.maxRefreshAnimateTimeFlag = setTimeout(() => {
307
- this.maxRefreshAnimateTimeFlag = null;
322
+ setRefreshBarHeight(value) {
323
+ const barHeight = Math.min(value, this.iMaxBarHeight);
324
+ const data = { barHeight };
308
325
 
309
- if (this.refreshStatus === REFRESH_STATUS_MAP.LOADING) {
310
- // 超时回调
311
- this.$emit('timeout');
312
- this._trigger('change', { value: false });
326
+ if (barHeight >= this.iLoadingBarHeight) {
327
+ data.refreshStatus = REFRESH_STATUS_MAP.LOSING;
328
+ } else {
329
+ data.refreshStatus = REFRESH_STATUS_MAP.PULLING;
313
330
  }
314
- }, this.refreshTimeout);
315
- },
316
-
317
- setRefreshBarHeight(value) {
318
- const barHeight = Math.min(value, this.iMaxBarHeight);
319
- const data = { barHeight };
320
-
321
- if (barHeight >= this.iLoadingBarHeight) {
322
- data.refreshStatus = REFRESH_STATUS_MAP.LOSING;
323
- } else {
324
- data.refreshStatus = REFRESH_STATUS_MAP.PULLING;
325
- }
326
- return new Promise((resolve) => {
327
- Object.keys(data).forEach((key) => {
328
- this[key] = data[key];
331
+ return new Promise((resolve) => {
332
+ Object.keys(data).forEach((key) => {
333
+ this[key] = data[key];
334
+ });
335
+ setTimeout(() => {
336
+ resolve(barHeight);
337
+ }, 20);
329
338
  });
339
+ },
340
+
341
+ setScrollTop(scrollTop) {
342
+ this.scrollTop = scrollTop;
343
+ },
344
+
345
+ scrollToTop() {
346
+ let parsed = false;
347
+
348
+ // #ifdef APP-PLUS || MP
349
+ this.scrollTop = 0;
330
350
  setTimeout(() => {
331
- resolve(barHeight);
332
- }, 20);
333
- });
334
- },
351
+ this.scrollTop = 0.01;
352
+ });
353
+ parsed = true;
354
+ // #endif
335
355
 
336
- setScrollTop(scrollTop) {
337
- this.scrollTop = scrollTop;
338
- },
356
+ // #ifdef H5
357
+ // https://yuanbao.tencent.com/chat/naQivTmsDa/c10ae37f-c66f-4489-ac4e-e72710a3f65a
358
+ this.scrollTop = this.scrollTop === 0 ? 0.01 : 0;
359
+ parsed = true;
360
+ // #endif
339
361
 
340
- scrollToTop() {
341
- let parsed = false;
342
-
343
- // #ifdef APP-PLUS || MP
344
- this.scrollTop = 0;
345
- setTimeout(() => {
346
- this.scrollTop = 0.01;
347
- });
348
- parsed = true;
349
- // #endif
350
-
351
- // #ifdef H5
352
- // https://yuanbao.tencent.com/chat/naQivTmsDa/c10ae37f-c66f-4489-ac4e-e72710a3f65a
353
- this.scrollTop = this.scrollTop === 0 ? 0.01 : 0;
354
- parsed = true;
355
- // #endif
356
-
357
- if (!parsed) {
358
- this.setScrollTop(0);
359
- }
362
+ if (!parsed) {
363
+ this.setScrollTop(0);
364
+ }
365
+ },
360
366
  },
361
- },
362
- });
367
+ }),
368
+ };
363
369
  </script>
364
370
  <style scoped src="./pull-down-refresh.css"></style>
@@ -81,7 +81,7 @@ export interface TdPullDownRefreshProps {
81
81
  * 组件状态,值为 `true` 表示下拉状态,值为 `false` 表示收起状态
82
82
  * @default false
83
83
  */
84
- value?: boolean;
84
+ value?: boolean | null;
85
85
  /**
86
86
  * 组件状态,值为 `true` 表示下拉状态,值为 `false` 表示收起状态,非受控属性
87
87
  * @default false
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: QRCode 二维码
3
3
  description: 二维码能够将文本转换生成二维码的组件,支持自定义配色和 Logo 配置。
4
- spline: message
4
+ spline: data
5
5
  isComponent: true
6
6
  ---
7
7