@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,17 +1,15 @@
1
1
  <template>
2
2
  <view
3
- :style="tools._style([customStyle])"
4
- :class="
5
- tools.cls(classPrefix, [
6
- ['top', label || scaleTextArray.length],
7
- ['disabled', disabled],
8
- ['range', range]
9
- ]) +
10
- ' ' +
11
- tClass +
12
- ' ' +
13
- (vertical ? classPrefix + '--vertical' : '')
14
- "
3
+ :style="'' + tools._style([customStyle])"
4
+ :class="'' + tools.cls(classPrefix, [
5
+ ['top', label || scaleTextArray.length],
6
+ ['disabled', disabled],
7
+ ['range', range]
8
+ ]) +
9
+ ' ' +
10
+ tClass +
11
+ ' ' +
12
+ (vertical ? classPrefix + '--vertical' : '')"
15
13
  >
16
14
  <block v-if="!range">
17
15
  <text
@@ -22,7 +20,7 @@
22
20
  </text>
23
21
  <view
24
22
  id="sliderLine"
25
- :class="tools.cls(classPrefix + '__bar', [['disabled', disabled], theme, ['marks', isScale && theme == 'capsule']]) + ' ' + tClassBar"
23
+ :class="'' + tools.cls(classPrefix + '__bar', [['disabled', disabled], theme, ['marks', isScale && theme == 'capsule']]) + ' ' + tClassBar"
26
24
  @click="onSingleLineTap"
27
25
  >
28
26
  <block v-if="isScale">
@@ -30,7 +28,7 @@
30
28
  v-for="(item, index) in scaleArray"
31
29
  :key="index"
32
30
  :class="
33
- tools.cls(classPrefix + '__scale-item', [
31
+ '' + tools.cls(classPrefix + '__scale-item', [
34
32
  ['active', innerValue >= item.val],
35
33
  ['disabled', disabled],
36
34
  theme,
@@ -42,14 +40,14 @@
42
40
  >
43
41
  <view
44
42
  v-if="scaleTextArray.length"
45
- :class="tools.cls(classPrefix + '__scale-desc', [theme])"
43
+ :class="'' + tools.cls(classPrefix + '__scale-desc', [theme])"
46
44
  >
47
45
  {{ scaleTextArray[index] }}
48
46
  </view>
49
47
  </view>
50
48
  </block>
51
49
  <view
52
- :class="tools.cls(classPrefix + '__line', [['disabled', disabled], theme, 'single']) + ' ' + tClassBarActive"
50
+ :class="'' + tools.cls(classPrefix + '__line', [['disabled', disabled], theme, 'single']) + ' ' + tClassBarActive"
53
51
  :style="(vertical ? 'height' : 'width') + ': ' + lineBarWidth"
54
52
  >
55
53
  <view
@@ -62,7 +60,7 @@
62
60
  >
63
61
  <view
64
62
  v-if="label || isVisibleToScreenReader"
65
- :class="tools.cls(classPrefix + '__dot-value', [['sr-only', !label]])"
63
+ :class="'' + tools.cls(classPrefix + '__dot-value', [['sr-only', !label]])"
66
64
  aria-role="alert"
67
65
  aria-live="assertive"
68
66
  :aria-hidden="!isVisibleToScreenReader"
@@ -97,7 +95,7 @@
97
95
  </view>
98
96
  <view
99
97
  id="sliderLine"
100
- :class="tools.cls(classPrefix + '__bar', [['disabled', disabled], theme, ['marks', isScale && theme == 'capsule']]) + ' ' + tClassBar"
98
+ :class="'' + tools.cls(classPrefix + '__bar', [['disabled', disabled], theme, ['marks', isScale && theme == 'capsule']]) + ' ' + tClassBar"
101
99
  @click="onLineTap"
102
100
  >
103
101
  <block v-if="isScale">
@@ -105,7 +103,7 @@
105
103
  v-for="(item, index) in scaleArray"
106
104
  :key="index"
107
105
  :class="
108
- tools.cls(classPrefix + '__scale-item', [
106
+ '' + tools.cls(classPrefix + '__scale-item', [
109
107
  ['active', dotTopValue[1] >= item.val && item.val >= dotTopValue[0]],
110
108
  ['disabled', disabled],
111
109
  theme,
@@ -117,14 +115,14 @@
117
115
  >
118
116
  <view
119
117
  v-if="scaleTextArray.length"
120
- :class="tools.cls(classPrefix + '__scale-desc', [theme])"
118
+ :class="'' + tools.cls(classPrefix + '__scale-desc', [theme])"
121
119
  >
122
120
  {{ scaleTextArray[index] }}
123
121
  </view>
124
122
  </view>
125
123
  </block>
126
124
  <view
127
- :class="tools.cls(classPrefix + '__line', [['disabled', disabled], theme]) + ' ' + tClassBarActive"
125
+ :class="'' + tools.cls(classPrefix + '__line', [['disabled', disabled], theme]) + ' ' + tClassBarActive"
128
126
  :style="(vertical ? 'top' : 'left') + ': ' + lineLeft + 'px; ' + (vertical ? 'bottom' : 'right') + ': ' + lineRight + 'px'"
129
127
  >
130
128
  <view
@@ -137,7 +135,7 @@
137
135
  >
138
136
  <view
139
137
  v-if="label || isVisibleToScreenReader"
140
- :class="tools.cls(classPrefix + '__dot-value', [['sr-only', !label]])"
138
+ :class="'' + tools.cls(classPrefix + '__dot-value', [['sr-only', !label]])"
141
139
  aria-role="alert"
142
140
  aria-live="assertive"
143
141
  :aria-hidden="!isVisibleToScreenReader"
@@ -164,7 +162,7 @@
164
162
  >
165
163
  <view
166
164
  v-if="label || isVisibleToScreenReader"
167
- :class="tools.cls(classPrefix + '__dot-value', [['sr-only', !label]])"
165
+ :class="'' + tools.cls(classPrefix + '__dot-value', [['sr-only', !label]])"
168
166
  aria-role="alert"
169
167
  aria-live="assertive"
170
168
  :aria-hidden="!isVisibleToScreenReader"
@@ -206,354 +204,355 @@ import { isString, isFunction } from '../common/validator';
206
204
 
207
205
  const name = `${prefix}-slider`;
208
206
 
209
- export default uniComponent({
210
- name,
211
- options: {
212
- styleIsolation: 'shared',
213
- },
214
- controlledProps: [
215
- {
216
- key: 'value',
217
- event: 'change',
207
+ export default {
208
+ ...uniComponent({
209
+ name,
210
+ options: {
211
+ styleIsolation: 'shared',
218
212
  },
219
- ],
220
- externalClasses: [
221
- `${prefix}-class`,
222
- `${prefix}-class-bar`,
223
- `${prefix}-class-bar-active`,
224
- `${prefix}-class-bar-disabled`,
225
- `${prefix}-class-cursor`,
226
- ],
227
- props: {
228
- ...props,
229
- },
230
- data() {
231
- return {
232
- // 按钮样式列表
233
- sliderStyles: '',
234
- classPrefix: name,
235
- initialLeft: null,
236
- initialRight: null,
237
- activeLeft: 0,
238
- activeRight: 0,
239
- maxRange: 0,
240
- lineLeft: 0,
241
- lineRight: 0,
242
- dotTopValue: [0, 0],
243
- innerValue: 0,
244
- blockSize: 20,
245
- isScale: false,
246
- scaleArray: [],
247
- scaleTextArray: [],
248
- prefix,
249
- realLabel: '',
250
- extremeLabel: [],
251
- isVisibleToScreenReader: false,
252
- identifier: [-1, -1],
253
- __inited: false,
254
- tools,
255
-
256
- lineBarWidth: 0,
257
- };
258
- },
259
- watch: {
260
- value: {
261
- handler(newValue) {
262
- this.handlePropsChange(newValue);
213
+ controlledProps: [
214
+ {
215
+ key: 'value',
216
+ event: 'change',
263
217
  },
264
- // immediate: true,
265
- deep: true,
218
+ ],
219
+ externalClasses: [
220
+ `${prefix}-class`,
221
+ `${prefix}-class-bar`,
222
+ `${prefix}-class-bar-active`,
223
+ `${prefix}-class-bar-disabled`,
224
+ `${prefix}-class-cursor`,
225
+ ],
226
+ props: {
227
+ ...props,
266
228
  },
267
- innerValue: {
268
- handler(newValue) {
269
- this.bus.on('initial', () => this.renderLine(newValue));
270
- this.toggleA11yTips();
271
- },
272
- // immediate: true,
273
- deep: true,
229
+ data() {
230
+ return {
231
+ // 按钮样式列表
232
+ sliderStyles: '',
233
+ classPrefix: name,
234
+ initialLeft: null,
235
+ initialRight: null,
236
+ activeLeft: 0,
237
+ activeRight: 0,
238
+ maxRange: 0,
239
+ lineLeft: 0,
240
+ lineRight: 0,
241
+ dotTopValue: [0, 0],
242
+ innerValue: 0,
243
+ blockSize: 20,
244
+ isScale: false,
245
+ scaleArray: [],
246
+ scaleTextArray: [],
247
+ prefix,
248
+ realLabel: '',
249
+ extremeLabel: [],
250
+ isVisibleToScreenReader: false,
251
+ identifier: [-1, -1],
252
+ __inited: false,
253
+ tools,
254
+
255
+ lineBarWidth: 0,
256
+ };
274
257
  },
275
- marks: {
276
- handler(val) {
277
- this.bus.on('initial', () => this.handleMark(val));
258
+ watch: {
259
+ value: {
260
+ handler(newValue) {
261
+ this.handlePropsChange(newValue);
262
+ },
263
+ // immediate: true,
264
+ deep: true,
278
265
  },
279
- // immediate: true,
280
- deep: true,
281
- },
282
- label: {
283
- handler(val) {
284
- this.isShowLabel = Boolean(val);
266
+ innerValue: {
267
+ handler(newValue) {
268
+ this.bus.on('initial', () => this.renderLine(newValue));
269
+ this.toggleA11yTips();
270
+ },
271
+ // immediate: true,
272
+ deep: true,
273
+ },
274
+ marks: {
275
+ handler(val) {
276
+ this.bus.on('initial', () => this.handleMark(val));
277
+ },
278
+ // immediate: true,
279
+ deep: true,
285
280
  },
286
- immediate: true,
281
+ label: {
282
+ handler(val) {
283
+ this.isShowLabel = Boolean(val);
284
+ },
285
+ immediate: true,
286
+ },
287
+ showExtremeValue: 'getwExtremeLabel',
288
+ min: 'getwExtremeLabel',
289
+ max: 'getwExtremeLabel',
287
290
  },
288
- showExtremeValue: 'getwExtremeLabel',
289
- min: 'getwExtremeLabel',
290
- max: 'getwExtremeLabel',
291
- },
292
- created() {
293
- this.bus = new Bus();
294
- this.bus.on('initial', () => this.handleMark(this.marks));
295
- this.bus.on('initial', () => {
296
- nextTick().then(() => {
297
- this.renderLine(this.innerValue);
291
+ created() {
292
+ this.bus = new Bus();
293
+ this.bus.on('initial', () => this.handleMark(this.marks));
294
+ this.bus.on('initial', () => {
295
+ nextTick().then(() => {
296
+ this.renderLine(this.innerValue);
297
+ });
298
298
  });
299
- });
300
- this.toggleA11yTips();
301
- },
302
- mounted() {
303
- const { value, defaultValue } = this;
304
- // if (!value)
305
- this.handlePropsChange(coalesce(value, defaultValue, 0));
306
- this.init();
307
- this.injectPageScroll();
308
- },
309
-
310
- methods: {
311
- getValue,
312
- getwExtremeLabel() {
313
- const { showExtremeValue, min, max } = this;
314
- if (!showExtremeValue) return;
315
-
316
- this.extremeLabel = [this.getLabelByValue(Number(min), 'min'), this.getLabelByValue(Number(max), 'max')];
299
+ this.toggleA11yTips();
317
300
  },
318
- injectPageScroll() {
319
- const { range, vertical } = this;
320
- if (!range || !vertical) return;
321
- const pages = getCurrentPages() || [];
322
- let curPage = null;
323
- if (pages && pages.length - 1 >= 0) {
324
- curPage = pages[pages.length - 1];
325
- }
326
- if (!curPage) return;
327
- const originPageScroll = curPage?.onPageScroll;
328
- curPage.onPageScroll = (rest) => {
329
- originPageScroll?.call(this, rest);
330
- this.observerScrollTop(rest);
331
- };
301
+ mounted() {
302
+ const { value, defaultValue } = this;
303
+ // if (!value)
304
+ this.handlePropsChange(coalesce(value, defaultValue, 0));
305
+ this.init();
306
+ this.injectPageScroll();
332
307
  },
333
308
 
334
- observerScrollTop(rest) {
335
- const { scrollTop } = rest || {};
336
- this.pageScrollTop = scrollTop;
337
- },
309
+ methods: {
310
+ getValue,
311
+ getwExtremeLabel() {
312
+ const { showExtremeValue, min, max } = this;
313
+ if (!showExtremeValue) return;
338
314
 
339
- toggleA11yTips() {
340
- this.isVisibleToScreenReader = true;
315
+ this.extremeLabel = [this.getLabelByValue(Number(min), 'min'), this.getLabelByValue(Number(max), 'max')];
316
+ },
317
+ injectPageScroll() {
318
+ const { range, vertical } = this;
319
+ if (!range || !vertical) return;
320
+ const pages = getCurrentPages() || [];
321
+ let curPage = null;
322
+ if (pages && pages.length - 1 >= 0) {
323
+ curPage = pages[pages.length - 1];
324
+ }
325
+ if (!curPage) return;
326
+ const originPageScroll = curPage?.onPageScroll;
327
+ curPage.onPageScroll = (rest) => {
328
+ originPageScroll?.call(this, rest);
329
+ this.observerScrollTop(rest);
330
+ };
331
+ },
341
332
 
342
- setTimeout(() => {
343
- this.isVisibleToScreenReader = false;
344
- }, 2000);
345
- },
333
+ observerScrollTop(rest) {
334
+ const { scrollTop } = rest || {};
335
+ this.pageScrollTop = scrollTop;
336
+ },
346
337
 
347
- renderLine(val) {
348
- const { min, max, range } = this;
349
- const { maxRange } = this;
350
-
351
- if (range) {
352
- const left = (maxRange * (val[0] - Number(min))) / (Number(max) - Number(min));
353
- const right = (maxRange * (Number(max) - val[1])) / (Number(max) - Number(min));
354
- // 因为要计算点相对于线的绝对定位,所以要取整条线的长度而非可滑动的范围
355
- this.setLineStyle(left, right);
356
- } else {
357
- this.setSingleBarWidth(val);
358
- }
359
- },
338
+ toggleA11yTips() {
339
+ this.isVisibleToScreenReader = true;
360
340
 
361
- triggerValue(value) {
362
- const { min, max, range } = this;
363
- const trimmedValue = trimValue(value, {
364
- min, max, range,
365
- });
341
+ setTimeout(() => {
342
+ this.isVisibleToScreenReader = false;
343
+ }, 2000);
344
+ },
366
345
 
367
- if (JSON.stringify(this.preval) === JSON.stringify(trimmedValue)) return;
368
- this.preval = value;
346
+ renderLine(val) {
347
+ const { min, max, range } = this;
348
+ const { maxRange } = this;
369
349
 
370
- this._trigger('change', {
371
- value: trimmedValue,
372
- });
373
- if (this._selfControlled) {
374
- this.innerValue = trimmedValue;
375
- }
376
- },
350
+ if (range) {
351
+ const left = (maxRange * (val[0] - Number(min))) / (Number(max) - Number(min));
352
+ const right = (maxRange * (Number(max) - val[1])) / (Number(max) - Number(min));
353
+ // 因为要计算点相对于线的绝对定位,所以要取整条线的长度而非可滑动的范围
354
+ this.setLineStyle(left, right);
355
+ } else {
356
+ this.setSingleBarWidth(val);
357
+ }
358
+ },
377
359
 
378
- getLabelByValue(value, position) {
379
- const { label } = this;
360
+ triggerValue(value) {
361
+ const { min, max, range } = this;
362
+ const trimmedValue = trimValue(value, {
363
+ min, max, range,
364
+ });
365
+
366
+ if (JSON.stringify(this.preval) === JSON.stringify(trimmedValue)) return;
367
+ this.preval = value;
368
+
369
+ this._trigger('change', {
370
+ value: trimmedValue,
371
+ });
372
+ if (this._selfControlled) {
373
+ this.innerValue = trimmedValue;
374
+ }
375
+ },
376
+
377
+ getLabelByValue(value, position) {
378
+ const { label } = this;
379
+
380
+ if (isString(label)) {
381
+ let text = String(value);
382
+ try {
383
+ const rule = /\${value}%/g;
384
+ const enableToReplace = rule.test(label);
385
+ if (enableToReplace) {
386
+ text = label.replace(rule, String(value));
387
+ } else {
388
+ text = label;
389
+ throw new Error();
390
+ }
391
+ } catch (e) {
380
392
 
381
- if (isString(label)) {
382
- let text = String(value);
383
- try {
384
- const rule = /\${value}%/g;
385
- const enableToReplace = rule.test(label);
386
- if (enableToReplace) {
387
- text = label.replace(rule, String(value));
388
- } else {
389
- text = label;
390
- throw new Error();
391
393
  }
392
- } catch (e) {
394
+ return text;
395
+ }
393
396
 
397
+ if (isFunction(label)) {
398
+ return label(value, position);
394
399
  }
395
- return text;
396
- }
397
400
 
398
- if (isFunction(label)) {
399
- return label(value, position);
400
- }
401
+ return String(value);
402
+ },
401
403
 
402
- return String(value);
403
- },
404
+ handlePropsChange(newValue) {
405
+ const { min, max, range } = this;
404
406
 
405
- handlePropsChange(newValue) {
406
- const { min, max, range } = this;
407
+ const value = trimValue(newValue, {
408
+ min, max, range,
409
+ });
407
410
 
408
- const value = trimValue(newValue, {
409
- min, max, range,
410
- });
411
+ const realLabel = this.getLabelByValue(value);
411
412
 
412
- const realLabel = this.getLabelByValue(value);
413
+ // 避免受控模式下死循环,同时不影响初始化后的首次点击
414
+ if (this.preval !== undefined) {
415
+ this.preval = value;
416
+ }
413
417
 
414
- // 避免受控模式下死循环,同时不影响初始化后的首次点击
415
- if (this.preval !== undefined) {
416
- this.preval = value;
417
- }
418
+ const setValueAndTrigger = () => {
419
+ this.innerValue = value;
420
+ this.realLabel = realLabel;
421
+ };
418
422
 
419
- const setValueAndTrigger = () => {
420
- this.innerValue = value;
421
- this.realLabel = realLabel;
422
- };
423
+ // 基本样式未初始化,等待初始化后在改变数据。
424
+ if (this.maxRange === 0) {
425
+ this.init().then(setValueAndTrigger);
426
+ return;
427
+ }
423
428
 
424
- // 基本样式未初始化,等待初始化后在改变数据。
425
- if (this.maxRange === 0) {
426
- this.init().then(setValueAndTrigger);
427
- return;
428
- }
429
+ setValueAndTrigger();
430
+ },
429
431
 
430
- setValueAndTrigger();
431
- },
432
+ valueToPosition(value) {
433
+ const { min, max, theme } = this;
434
+ const { blockSize, maxRange } = this;
435
+ const halfBlock = (theme) === 'capsule' ? Number(blockSize) / 2 : 0;
432
436
 
433
- valueToPosition(value) {
434
- const { min, max, theme } = this;
435
- const { blockSize, maxRange } = this;
436
- const halfBlock = (theme) === 'capsule' ? Number(blockSize) / 2 : 0;
437
+ return Math.round(((Number(value) - Number(min)) / (Number(max) - Number(min))) * maxRange) + halfBlock;
438
+ },
437
439
 
438
- return Math.round(((Number(value) - Number(min)) / (Number(max) - Number(min))) * maxRange) + halfBlock;
439
- },
440
+ handleMark(marks) {
441
+ const calcPos = arr => arr.map(item => ({
442
+ val: item,
443
+ left: this.valueToPosition(item),
444
+ }));
440
445
 
441
- handleMark(marks) {
442
- const calcPos = arr => arr.map(item => ({
443
- val: item,
444
- left: this.valueToPosition(item),
445
- }));
446
-
447
- if (marks?.length && Array.isArray(marks)) {
448
- this.isScale = true;
449
- this.scaleArray = calcPos(marks);
450
- this.scaleTextArray = [];
451
- }
452
-
453
- if (Object.prototype.toString.call(marks) === '[object Object]') {
454
- const scaleArray = Object.keys(marks).map(item => Number(item));
455
- const scaleTextArray = scaleArray.map(item => marks[item]);
456
-
457
- this.isScale = scaleArray.length > 0;
458
- this.scaleArray = calcPos(scaleArray);
459
- this.scaleTextArray = scaleTextArray;
460
- }
461
- },
446
+ if (marks?.length && Array.isArray(marks)) {
447
+ this.isScale = true;
448
+ this.scaleArray = calcPos(marks);
449
+ this.scaleTextArray = [];
450
+ }
462
451
 
463
- setSingleBarWidth(value) {
464
- const width = this.valueToPosition(value);
452
+ if (Object.prototype.toString.call(marks) === '[object Object]') {
453
+ const scaleArray = Object.keys(marks).map(item => Number(item));
454
+ const scaleTextArray = scaleArray.map(item => marks[item]);
465
455
 
466
- this.lineBarWidth = `${width}px`;
467
- },
456
+ this.isScale = scaleArray.length > 0;
457
+ this.scaleArray = calcPos(scaleArray);
458
+ this.scaleTextArray = scaleTextArray;
459
+ }
460
+ },
468
461
 
469
- async init() {
470
- if (this.__inited) return;
471
- await this.getInitialInfo();
472
- this.__inited = true;
473
- this.bus.emit('initial');
474
- },
462
+ setSingleBarWidth(value) {
463
+ const width = this.valueToPosition(value);
475
464
 
476
- async getInitialInfo() {
477
- const line = await getRect(this, '#sliderLine');
478
- const { blockSize } = this;
479
- const { theme, vertical } = this;
480
- const halfBlock = Number(blockSize) / 2;
481
- const { top, bottom, right, left } = line;
482
- let maxRange = vertical ? bottom - top : right - left;
483
- let initialLeft = vertical ? top : left;
484
- let initialRight = vertical ? bottom : right;
485
- if (initialLeft === 0 && initialRight === 0) return;
486
-
487
- if ((theme) === 'capsule') {
488
- maxRange = maxRange - Number(blockSize) - 6; // 6 是边框宽度
489
- initialLeft -= halfBlock;
490
- initialRight -= halfBlock;
491
- }
492
-
493
- this.maxRange = maxRange;
494
- this.initialLeft = initialLeft;
495
- this.initialRight = initialRight;
496
- },
465
+ this.lineBarWidth = `${width}px`;
466
+ },
497
467
 
498
- stepValue(value) {
499
- const { step, min, max } = this;
500
- const decimal = String(step).indexOf('.') > -1 ? String(step).length - String(step).indexOf('.') - 1 : 0;
501
- const closestStep = trimSingleValue(
502
- Number((Math.round(value / Number(step)) * Number(step)).toFixed(decimal)),
503
- Number(min),
504
- Number(max),
505
- );
506
- return closestStep;
507
- },
468
+ async init() {
469
+ if (this.__inited) return;
470
+ await this.getInitialInfo();
471
+ this.__inited = true;
472
+ this.bus.emit('initial');
473
+ },
508
474
 
509
- // 点击滑动条的事件
510
- async onSingleLineTap(e) {
511
- await this.getInitialInfo();
512
- const { disabled } = this;
513
- if (disabled) return;
514
- const isSingleLineTap = this.identifier[0] === -1; // 区分点击滑动条和单游标的滑动
515
- if (isSingleLineTap) {
516
- const [touch] = e.changedTouches;
517
- this.identifier[0] = touch.identifier;
518
- }
519
- const value = await this.getSingleChangeValue(e);
520
-
521
- if (isSingleLineTap) {
522
- this.identifier[0] = -1;
523
- }
524
- this.triggerValue(value);
525
- },
475
+ async getInitialInfo() {
476
+ const line = await getRect(this, '#sliderLine');
477
+ const { blockSize } = this;
478
+ const { theme, vertical } = this;
479
+ const halfBlock = Number(blockSize) / 2;
480
+ const { top, bottom, right, left } = line;
481
+ let maxRange = vertical ? bottom - top : right - left;
482
+ let initialLeft = vertical ? top : left;
483
+ let initialRight = vertical ? bottom : right;
484
+ if (initialLeft === 0 && initialRight === 0) return;
485
+
486
+ if ((theme) === 'capsule') {
487
+ maxRange = maxRange - Number(blockSize) - 6; // 6 是边框宽度
488
+ initialLeft -= halfBlock;
489
+ initialRight -= halfBlock;
490
+ }
491
+
492
+ this.maxRange = maxRange;
493
+ this.initialLeft = initialLeft;
494
+ this.initialRight = initialRight;
495
+ },
496
+
497
+ stepValue(value) {
498
+ const { step, min, max } = this;
499
+ const decimal = String(step).indexOf('.') > -1 ? String(step).length - String(step).indexOf('.') - 1 : 0;
500
+ const closestStep = trimSingleValue(
501
+ Number((Math.round(value / Number(step)) * Number(step)).toFixed(decimal)),
502
+ Number(min),
503
+ Number(max),
504
+ );
505
+ return closestStep;
506
+ },
526
507
 
527
- async getSingleChangeValue(e) {
508
+ // 点击滑动条的事件
509
+ async onSingleLineTap(e) {
510
+ await this.getInitialInfo();
511
+ const { disabled } = this;
512
+ if (disabled) return;
513
+ const isSingleLineTap = this.identifier[0] === -1; // 区分点击滑动条和单游标的滑动
514
+ if (isSingleLineTap) {
515
+ const [touch] = e.changedTouches;
516
+ this.identifier[0] = touch.identifier;
517
+ }
518
+ const value = await this.getSingleChangeValue(e);
519
+
520
+ if (isSingleLineTap) {
521
+ this.identifier[0] = -1;
522
+ }
523
+ this.triggerValue(value);
524
+ },
525
+
526
+ async getSingleChangeValue(e) {
528
527
  // await this.getInitialInfo();
529
- const { min, max, theme, vertical } = this;
530
- const { initialLeft, maxRange, blockSize } = this;
531
- const touch = e.changedTouches.find(item => item.identifier === this.identifier[0]);
532
- if (!touch) return;
533
- const pagePosition = this.getPagePosition(touch);
534
-
535
- let offset = 0;
536
- if ((theme) === 'capsule') {
537
- offset = Number(blockSize);
538
- if (vertical) {
528
+ const { min, max, theme, vertical } = this;
529
+ const { initialLeft, maxRange, blockSize } = this;
530
+ const touch = e.changedTouches.find(item => item.identifier === this.identifier[0]);
531
+ if (!touch) return;
532
+ const pagePosition = this.getPagePosition(touch);
533
+
534
+ let offset = 0;
535
+ if ((theme) === 'capsule') {
536
+ offset = Number(blockSize);
537
+ if (vertical) {
538
+ }
539
+ offset += 3;
540
+ } else if (vertical) {
539
541
  }
540
- offset += 3;
541
- } else if (vertical) {
542
- }
543
-
544
- const currentLeft = pagePosition - initialLeft - offset;
545
- let value = 0;
546
- if (currentLeft <= 0) {
547
- value = Number(min);
548
- } else if (currentLeft >= maxRange) {
549
- value = Number(max);
550
- } else {
551
- value = (currentLeft / maxRange) * (Number(max) - Number(min)) + Number(min);
552
- }
553
- return this.stepValue(value);
554
- },
555
542
 
556
- /**
543
+ const currentLeft = pagePosition - initialLeft - offset;
544
+ let value = 0;
545
+ if (currentLeft <= 0) {
546
+ value = Number(min);
547
+ } else if (currentLeft >= maxRange) {
548
+ value = Number(max);
549
+ } else {
550
+ value = (currentLeft / maxRange) * (Number(max) - Number(min)) + Number(min);
551
+ }
552
+ return this.stepValue(value);
553
+ },
554
+
555
+ /**
557
556
  * 将位置转换为值
558
557
  *
559
558
  * @param {number} posValue 位置数据
@@ -561,157 +560,158 @@ export default uniComponent({
561
560
  * @return {number}
562
561
  * @memberof Slider
563
562
  */
564
- convertPosToValue(posValue, dir) {
565
- const { maxRange } = this;
566
- const { max, min } = this;
567
- return dir === 0
568
- ? (posValue / maxRange) * (Number(max) - Number(min)) + Number(min)
569
- : Number(max) - (posValue / maxRange) * (Number(max) - Number(min));
570
- },
563
+ convertPosToValue(posValue, dir) {
564
+ const { maxRange } = this;
565
+ const { max, min } = this;
566
+ return dir === 0
567
+ ? (posValue / maxRange) * (Number(max) - Number(min)) + Number(min)
568
+ : Number(max) - (posValue / maxRange) * (Number(max) - Number(min));
569
+ },
571
570
 
572
- // 点击范围选择滑动条的事件
573
- onLineTap(e) {
574
- const { disabled, theme, vertical } = this;
575
- const { initialLeft, initialRight, maxRange, blockSize } = this;
576
- if (disabled) return;
577
-
578
- const [touch] = e.changedTouches;
579
- const pagePosition = this.getPagePosition(touch);
580
- const halfBlock = (theme) === 'capsule' ? Number(blockSize) / 2 : 0;
581
-
582
- const currentLeft = pagePosition - initialLeft;
583
- const currentRight = -(pagePosition - initialRight);
584
- if (currentLeft < 0 || currentRight > maxRange + Number(blockSize)) return;
585
-
586
- Promise.all([getRect(this, '#leftDot'), getRect(this, '#rightDot')]).then(([leftDot, rightDot]) => {
587
- const pageScrollTop = this.pageScrollTop || 0;
588
- // 点击处-halfblock 与 leftDot左侧的距离(绝对值)
589
- const leftDotPosition = vertical ? leftDot.top + pageScrollTop : leftDot.left;
590
- const distanceLeft = Math.abs(pagePosition - leftDotPosition - halfBlock);
591
- // 点击处-halfblock 与 rightDot左侧的距离(绝对值)
592
- const rightDotPosition = vertical ? rightDot.top + pageScrollTop : rightDot.left;
593
- const distanceRight = Math.abs(rightDotPosition - pagePosition + halfBlock);
594
- // 哪个绝对值小就移动哪个Dot
595
- const isMoveLeft = distanceLeft < distanceRight;
571
+ // 点击范围选择滑动条的事件
572
+ onLineTap(e) {
573
+ const { disabled, theme, vertical } = this;
574
+ const { initialLeft, initialRight, maxRange, blockSize } = this;
575
+ if (disabled) return;
596
576
 
597
- let offset = 0;
598
- if ((theme) === 'capsule') {
599
- offset = Number(blockSize);
600
- if (vertical) {
601
- offset *= 2;
577
+ const [touch] = e.changedTouches;
578
+ const pagePosition = this.getPagePosition(touch);
579
+ const halfBlock = (theme) === 'capsule' ? Number(blockSize) / 2 : 0;
580
+
581
+ const currentLeft = pagePosition - initialLeft;
582
+ const currentRight = -(pagePosition - initialRight);
583
+ if (currentLeft < 0 || currentRight > maxRange + Number(blockSize)) return;
584
+
585
+ Promise.all([getRect(this, '#leftDot'), getRect(this, '#rightDot')]).then(([leftDot, rightDot]) => {
586
+ const pageScrollTop = this.pageScrollTop || 0;
587
+ // 点击处-halfblock 与 leftDot左侧的距离(绝对值)
588
+ const leftDotPosition = vertical ? leftDot.top + pageScrollTop : leftDot.left;
589
+ const distanceLeft = Math.abs(pagePosition - leftDotPosition - halfBlock);
590
+ // 点击处-halfblock 与 rightDot左侧的距离(绝对值)
591
+ const rightDotPosition = vertical ? rightDot.top + pageScrollTop : rightDot.left;
592
+ const distanceRight = Math.abs(rightDotPosition - pagePosition + halfBlock);
593
+ // 哪个绝对值小就移动哪个Dot
594
+ const isMoveLeft = distanceLeft < distanceRight;
595
+
596
+ let offset = 0;
597
+ if ((theme) === 'capsule') {
598
+ offset = Number(blockSize);
599
+ if (vertical) {
600
+ offset *= 2;
601
+ }
602
+ offset += 6;
603
+ } else if (vertical) {
604
+ offset = Number(blockSize);
602
605
  }
603
- offset += 6;
604
- } else if (vertical) {
605
- offset = Number(blockSize);
606
- }
607
606
 
608
- if (isMoveLeft) {
609
- // 当前leftdot中心 + 左侧偏移量 = 目标左侧中心距离
610
- const left = pagePosition - initialLeft - offset;
611
- const leftValue = this.convertPosToValue(left, 0);
612
- this.triggerValue([this.stepValue(leftValue), this.innerValue[1]]);
613
- } else {
614
- let right = -(pagePosition - initialRight);
615
- if (vertical) {
616
- right += offset / 2;
607
+ if (isMoveLeft) {
608
+ // 当前leftdot中心 + 左侧偏移量 = 目标左侧中心距离
609
+ const left = pagePosition - initialLeft - offset;
610
+ const leftValue = this.convertPosToValue(left, 0);
611
+ this.triggerValue([this.stepValue(leftValue), this.innerValue[1]]);
612
+ } else {
613
+ let right = -(pagePosition - initialRight);
614
+ if (vertical) {
615
+ right += offset / 2;
616
+ }
617
+ const rightValue = this.convertPosToValue(right, 1);
618
+
619
+ this.triggerValue([this.innerValue[0], this.stepValue(rightValue)]);
617
620
  }
618
- const rightValue = this.convertPosToValue(right, 1);
621
+ });
622
+ },
619
623
 
620
- this.triggerValue([this.innerValue[0], this.stepValue(rightValue)]);
624
+ async onTouchStart(e) {
625
+ await this.getInitialInfo();
626
+ this.$emit('dragstart', { e });
627
+ const [touch] = e.changedTouches;
628
+ if (e.currentTarget.id === 'rightDot') {
629
+ this.identifier[1] = touch.identifier;
630
+ } else {
631
+ this.identifier[0] = touch.identifier;
621
632
  }
622
- });
623
- },
633
+ },
624
634
 
625
- async onTouchStart(e) {
626
- await this.getInitialInfo();
627
- this.$emit('dragstart', { e });
628
- const [touch] = e.changedTouches;
629
- if (e.currentTarget.id === 'rightDot') {
630
- this.identifier[1] = touch.identifier;
631
- } else {
632
- this.identifier[0] = touch.identifier;
633
- }
634
- },
635
+ onTouchMoveLeft(e) {
636
+ const { disabled, theme } = this;
637
+ const { initialLeft, innerValue, blockSize } = this;
638
+ if (disabled) return;
635
639
 
636
- onTouchMoveLeft(e) {
637
- const { disabled, theme } = this;
638
- const { initialLeft, innerValue, blockSize } = this;
639
- if (disabled) return;
640
+ const touch = e.changedTouches.find(item => item.identifier === this.identifier[0]);
641
+ if (!touch) return;
642
+ const pagePosition = this.getPagePosition(touch);
643
+ let offset = 0;
644
+ if ((theme) === 'capsule') {
645
+ offset = Number(blockSize) + 3;
646
+ }
647
+ const currentLeft = pagePosition - initialLeft - offset;
640
648
 
641
- const touch = e.changedTouches.find(item => item.identifier === this.identifier[0]);
642
- if (!touch) return;
643
- const pagePosition = this.getPagePosition(touch);
644
- let offset = 0;
645
- if ((theme) === 'capsule') {
646
- offset = Number(blockSize) + 3;
647
- }
648
- const currentLeft = pagePosition - initialLeft - offset;
649
+ const newData = [...(innerValue)];
650
+ const leftValue = this.convertPosToValue(currentLeft, 0);
649
651
 
650
- const newData = [...(innerValue)];
651
- const leftValue = this.convertPosToValue(currentLeft, 0);
652
+ newData[0] = this.stepValue(leftValue);
652
653
 
653
- newData[0] = this.stepValue(leftValue);
654
+ this.triggerValue(newData);
655
+ },
654
656
 
655
- this.triggerValue(newData);
656
- },
657
+ onTouchMoveRight(e) {
658
+ const { disabled, vertical, theme } = this;
659
+ const { initialRight, innerValue } = this;
660
+ if (disabled) return;
657
661
 
658
- onTouchMoveRight(e) {
659
- const { disabled, vertical, theme } = this;
660
- const { initialRight, innerValue } = this;
661
- if (disabled) return;
662
+ const touch = e.changedTouches.find(item => item.identifier === this.identifier[1]);
663
+ if (!touch) return;
662
664
 
663
- const touch = e.changedTouches.find(item => item.identifier === this.identifier[1]);
664
- if (!touch) return;
665
+ const pagePosition = this.getPagePosition(touch);
666
+ let offset = 0;
667
+ if ((theme) === 'capsule') {
668
+ offset -= 3;
669
+ } else if (vertical) {
670
+ }
671
+ const currentRight = -(pagePosition - initialRight - offset);
665
672
 
666
- const pagePosition = this.getPagePosition(touch);
667
- let offset = 0;
668
- if ((theme) === 'capsule') {
669
- offset -= 3;
670
- } else if (vertical) {
671
- }
672
- const currentRight = -(pagePosition - initialRight - offset);
673
+ const newData = [...(innerValue)];
674
+ const rightValue = this.convertPosToValue(currentRight, 1);
675
+ newData[1] = this.stepValue(rightValue);
673
676
 
674
- const newData = [...(innerValue)];
675
- const rightValue = this.convertPosToValue(currentRight, 1);
676
- newData[1] = this.stepValue(rightValue);
677
+ this.triggerValue(newData);
678
+ },
677
679
 
678
- this.triggerValue(newData);
679
- },
680
+ setLineStyle(left, right) {
681
+ const { theme } = this;
682
+ const { blockSize, maxRange } = this;
683
+ const halfBlock = (theme) === 'capsule' ? Number(blockSize) / 2 : 0;
684
+ const [a, b] = this.innerValue ;
685
+ const cut = v => parseInt(v, 10);
680
686
 
681
- setLineStyle(left, right) {
682
- const { theme } = this;
683
- const { blockSize, maxRange } = this;
684
- const halfBlock = (theme) === 'capsule' ? Number(blockSize) / 2 : 0;
685
- const [a, b] = this.innerValue ;
686
- const cut = v => parseInt(v, 10);
687
-
688
- this.dotTopValue = [a, b];
689
- this.realLabel = [this.getLabelByValue(a, 'start'), this.getLabelByValue(b, 'end')];
690
-
691
- if (left + right <= maxRange) {
692
- this.lineLeft = cut(left + halfBlock);
693
- this.lineRight = cut(right + halfBlock);
694
- } else {
695
- this.lineLeft = cut(maxRange + halfBlock - right);
696
- this.lineRight = cut(maxRange - left + halfBlock * 1.5);
697
- }
698
- },
687
+ this.dotTopValue = [a, b];
688
+ this.realLabel = [this.getLabelByValue(a, 'start'), this.getLabelByValue(b, 'end')];
699
689
 
700
- onTouchEnd(e) {
701
- this.$emit('dragend', { e, value: this.innerValue });
702
- if (e.currentTarget.id === 'rightDot') {
703
- this.identifier[1] = -1;
704
- } else {
705
- this.identifier[0] = -1;
706
- }
707
- },
690
+ if (left + right <= maxRange) {
691
+ this.lineLeft = cut(left + halfBlock);
692
+ this.lineRight = cut(right + halfBlock);
693
+ } else {
694
+ this.lineLeft = cut(maxRange + halfBlock - right);
695
+ this.lineRight = cut(maxRange - left + halfBlock * 1.5);
696
+ }
697
+ },
708
698
 
709
- getPagePosition(touch) {
710
- const { clientX, clientY } = touch;
711
- const { vertical } = this;
712
- return vertical ? clientY : clientX;
699
+ onTouchEnd(e) {
700
+ this.$emit('dragend', { e, value: this.innerValue });
701
+ if (e.currentTarget.id === 'rightDot') {
702
+ this.identifier[1] = -1;
703
+ } else {
704
+ this.identifier[0] = -1;
705
+ }
706
+ },
707
+
708
+ getPagePosition(touch) {
709
+ const { clientX, clientY } = touch;
710
+ const { vertical } = this;
711
+ return vertical ? clientY : clientX;
712
+ },
713
713
  },
714
- },
715
- });
714
+ }),
715
+ };
716
716
  </script>
717
717
  <style scoped src="./slider.css"></style>