sadais-piui 1.2.7-beta15 → 1.2.7-beta151

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 (75) hide show
  1. package/.prettierrc +8 -0
  2. package/components/pi-action-sheet/index.vue +260 -247
  3. package/components/pi-badge/index.vue +11 -1
  4. package/components/pi-bottom-bar/index.vue +1 -1
  5. package/components/pi-calendar/index.vue +207 -182
  6. package/components/pi-calendar-input/index.vue +61 -30
  7. package/components/pi-calendar-panel/components/calendar-days/index.vue +91 -52
  8. package/components/pi-calendar-panel/index.vue +28 -12
  9. package/components/pi-canvas/index.vue +8 -1
  10. package/components/pi-cascader/index.vue +601 -0
  11. package/components/pi-checkbox/index.vue +8 -4
  12. package/components/pi-checkbox-group/index.vue +12 -11
  13. package/components/pi-circle-progress/index.vue +53 -16
  14. package/components/pi-code-input/index.vue +11 -3
  15. package/components/pi-collapse/index.vue +16 -6
  16. package/components/pi-collapse-item/index.vue +35 -22
  17. package/components/pi-date-picker/index.vue +512 -391
  18. package/components/pi-date-picker-input/index.vue +61 -30
  19. package/components/pi-dropdown/components/dropdown-tab.vue +33 -23
  20. package/components/pi-dropdown/index.vue +34 -19
  21. package/components/pi-dropdown-item/index.vue +70 -58
  22. package/components/pi-form-item/index.vue +98 -20
  23. package/components/pi-grid/index.vue +1 -1
  24. package/components/pi-grid-item/index.vue +4 -4
  25. package/components/pi-img/index.vue +275 -267
  26. package/components/pi-img-cropper/index.vue +6 -3
  27. package/components/pi-input/index.vue +97 -36
  28. package/components/pi-list-item/index.vue +1 -1
  29. package/components/pi-marquee/index.vue +322 -310
  30. package/components/pi-marquee-pure-css/index.vue +267 -0
  31. package/components/pi-mask/index.vue +3 -1
  32. package/components/pi-modal/index.vue +311 -303
  33. package/components/pi-pagination/index.vue +13 -0
  34. package/components/pi-picker/index.vue +332 -317
  35. package/components/pi-popup/index.vue +4 -1
  36. package/components/pi-popup-select/index.vue +13 -4
  37. package/components/pi-radio/index.vue +12 -11
  38. package/components/pi-radio-group/index.vue +25 -5
  39. package/components/pi-regions-select/index.vue +6 -1
  40. package/components/pi-regions-select-input/index.vue +69 -31
  41. package/components/pi-search/index.vue +37 -2
  42. package/components/pi-section/index.vue +1 -1
  43. package/components/pi-select/index.vue +237 -22
  44. package/components/pi-select-input/index.vue +106 -41
  45. package/components/pi-stepper/index.vue +135 -121
  46. package/components/pi-steps/index.vue +115 -36
  47. package/components/pi-swiper/index.vue +22 -7
  48. package/components/pi-switch/index.vue +5 -1
  49. package/components/pi-table/index.vue +351 -0
  50. package/components/pi-tabs/index.vue +46 -10
  51. package/components/pi-upload-img/index.vue +895 -44
  52. package/components/pi-webview/index.vue +95 -82
  53. package/config/actionSheet.js +0 -1
  54. package/config/calendarInput.js +2 -1
  55. package/config/calendarPanel.js +2 -1
  56. package/config/cascader.js +22 -0
  57. package/config/circleProgress.js +12 -4
  58. package/config/codeInput.js +2 -1
  59. package/config/datePicker.js +29 -24
  60. package/config/datePickerInput.js +2 -1
  61. package/config/dropdown.js +3 -1
  62. package/config/input.js +5 -3
  63. package/config/marqueePureCss.js +18 -0
  64. package/config/regionsSelectInput.js +2 -1
  65. package/config/select.js +13 -1
  66. package/config/selectInput.js +2 -1
  67. package/config/steps.js +1 -1
  68. package/config/table.js +9 -0
  69. package/config/uploadImg.js +33 -11
  70. package/mixin/emitter.js +8 -1
  71. package/mixin/value-sync.js +5 -0
  72. package/package.json +5 -2
  73. package/scss/common.scss +11 -14
  74. package/scss/icon/icon.scss +2 -1
  75. package/scss/mixin.scss +5 -5
@@ -49,6 +49,9 @@ import { parseDuration } from '@sadais/piui-tool/tools/common'
49
49
  const TAG = 'PiTabs'
50
50
  const { tabs } = getConfig()
51
51
 
52
+ let MAX_RETRY = 10
53
+ let timer = null
54
+
52
55
  export default {
53
56
  name: 'PiTabs',
54
57
  // 混入v-model
@@ -263,13 +266,14 @@ export default {
263
266
  left: 0,
264
267
  width: 0
265
268
  }
266
- if (!this.tabRects.length) return rect
267
- const activeIndex =
268
- this.activeIndex >= this.tabRects.length ? this.tabRects.length - 1 : this.activeIndex
269
- rect.left = this.tabRects.slice(0, activeIndex).reduce((previous, current) => {
270
- return previous + current.width
271
- }, 0)
272
- rect.width = this.tabRects[activeIndex].width
269
+ if (this.tabRects.length) {
270
+ const activeIndex =
271
+ this.activeIndex >= this.tabRects.length ? this.tabRects.length - 1 : this.activeIndex
272
+ rect.left = this.tabRects.slice(0, activeIndex).reduce((previous, current) => {
273
+ return previous + current.width
274
+ }, 0)
275
+ rect.width = this.tabRects[activeIndex].width
276
+ }
273
277
  return rect
274
278
  },
275
279
  scrollLeft() {
@@ -284,6 +288,7 @@ export default {
284
288
  height: this.getSliderBarHeight,
285
289
  borderRadius: this.getSliderBarRadius,
286
290
  transitionDuration: duration.css,
291
+ transform: `translate(${this.activeRect.left}px, -25%)`,
287
292
  ...this.sliderBarStyle
288
293
  }
289
294
  let sliderScrollLeft = this.activeRect.left
@@ -328,14 +333,39 @@ export default {
328
333
  mounted() {
329
334
  this.init()
330
335
  },
336
+ beforeDestroy() {
337
+ this.clearTimer()
338
+ },
331
339
  methods: {
340
+ clearTimer() {
341
+ if (timer) {
342
+ clearInterval(timer)
343
+ timer = null
344
+ MAX_RETRY = 10
345
+ }
346
+ },
332
347
  async init() {
333
348
  const srollWrapRect = await this.$pi.common.queryRect(this, '.pi-tabs', false)
334
349
  if (srollWrapRect) {
335
350
  this.tabsWidth = srollWrapRect.width
336
351
  }
337
- this.tabRects = await this.$pi.common.queryRect(this, '.pi-tab', true)
338
- console.log(TAG, '计算.pi-tab布局', this.tabRects)
352
+ this.initTabRects()
353
+ this.clearTimer()
354
+ timer = setInterval(() => {
355
+ this.initTabRects()
356
+ }, 200)
357
+ },
358
+ async initTabRects() {
359
+ MAX_RETRY--
360
+ const tabRects = await this.$pi.common.queryRect(this, '.pi-tab', true)
361
+ const tabWidth = this.tabRects.reduce((previous, current) => {
362
+ return previous + current.width
363
+ }, 0)
364
+ this.tabRects = tabRects
365
+ this.$forceUpdate()
366
+ if (tabWidth || MAX_RETRY <= 0) {
367
+ this.clearTimer()
368
+ }
339
369
  },
340
370
  handleSelectItem(item) {
341
371
  if (item[this.disabledField]) return
@@ -359,7 +389,6 @@ export default {
359
389
  display: inline-flex;
360
390
  font-size: 30rpx;
361
391
  text-align: center;
362
- transition: all $pi-animation-duration $pi-animation-timing-function;
363
392
  &.active {
364
393
  color: $pi-primary-color;
365
394
  }
@@ -397,3 +426,10 @@ export default {
397
426
  }
398
427
  }
399
428
  </style>
429
+
430
+ <style lang="scss">
431
+ .pi-tabs scoped-slots-item {
432
+ width: 100%;
433
+ height: 100%;
434
+ }
435
+ </style>