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
@@ -1,5 +1,17 @@
1
1
  <template>
2
- <view class="pi-input-wrap" :style="[getInputWrapStyle]">
2
+ <view
3
+ class="pi-input-wrap"
4
+ :style="[getInputWrapStyle]"
5
+ :class="[{ disabled: getDisabled }]"
6
+ >
7
+ <!-- 当disabled,增加一个abso的蒙层,为了触发click事件 -->
8
+ <view
9
+ v-if="getDisabled"
10
+ class="pi-input-mask"
11
+ :style="{ width: `calc(100% - ${closeIconWidth}px)` }"
12
+ @tap="handleItemClick"
13
+ />
14
+
3
15
  <textarea
4
16
  v-if="type === 'textarea'"
5
17
  class="pi-input-textarea"
@@ -10,11 +22,12 @@
10
22
  :placeholder="placeholder"
11
23
  :placeholder-style="placeholderStyle"
12
24
  :placeholder-class="placeholderClass"
13
- :disabled="getDisabled"
14
- :maxlength="maxlength"
25
+ :maxlength="parseInt(maxlength, 10)"
15
26
  :cursor-spacing="cursorSpacing"
16
27
  :focus="focus"
28
+ :disabled="getDisabled"
17
29
  :confirm-hold="confirmHold"
30
+ :confirm-type="confirmType"
18
31
  :cursor="cursor"
19
32
  :selection-start="selectionStart"
20
33
  :selection-end="selectionEnd"
@@ -24,13 +37,13 @@
24
37
  :show-confirm-bar="showConfirmbar"
25
38
  :auto-height="autoHeight"
26
39
  :disable-default-padding="disableDefaultPadding"
27
- @tap="handleItemClick"
28
- @input="handleInput"
29
40
  @focus="handleFocus"
41
+ @input="handleInput"
30
42
  @blur="handleBlur"
31
43
  @confirm="handleConfirm"
32
44
  @keyboardheightchange="$emit('keyboardheightchange', $event)"
33
45
  @linechange="$emit('linechange', $event)"
46
+ @tap="handleItemClick"
34
47
  />
35
48
  <input
36
49
  v-else
@@ -43,38 +56,41 @@
43
56
  :placeholder="placeholder"
44
57
  :placeholder-style="placeholderStyle"
45
58
  :placeholder-class="placeholderClass"
46
- :disabled="getDisabled"
47
- :maxlength="maxlength"
59
+ :maxlength="parseInt(maxlength, 10)"
48
60
  :cursor-spacing="cursorSpacing"
49
61
  :focus="focus"
62
+ :disabled="getDisabled"
50
63
  :confirm-hold="confirmHold"
64
+ :confirm-type="confirmType"
51
65
  :cursor="cursor"
52
66
  :selection-start="selectionStart"
53
67
  :selection-end="selectionEnd"
54
68
  :adjust-position="adjustPosition"
55
69
  :hold-keyboard="holdKeyboard"
56
70
  :auto-blur="autoBlur"
57
- @tap="handleItemClick"
58
- @input="handleInput"
59
71
  @focus="handleFocus"
72
+ @input="handleInput"
60
73
  @blur="handleBlur"
61
74
  @confirm="handleConfirm"
62
75
  @keyboardheightchange="$emit('keyboardheightchange', $event)"
76
+ @tap="handleItemClick"
63
77
  />
64
78
  <!-- 清空icon -->
65
- <pi-icon
66
- v-if="clearable && val"
67
- :custom-style="clearIcon.customStyle"
68
- :custom-class="`pi-pd-left-8 ${clearIcon.customClass}`"
69
- :name="clearIcon.name"
70
- :dot="clearIcon.dot"
71
- :dot-radius="clearIcon.dotRadius"
72
- :badge="clearIcon.badge"
73
- :color="clearIcon.color"
74
- :size="clearIcon.size"
75
- :class-prefix="clearIcon.classPrefix"
76
- @tap="handleChange('')"
77
- />
79
+ <view class="pi-input-close-icon">
80
+ <pi-icon
81
+ v-if="showClearIcon"
82
+ :custom-style="clearIcon.customStyle"
83
+ :custom-class="`pi-pd-left-12 ${clearIcon.customClass}`"
84
+ :name="clearIcon.name"
85
+ :dot="clearIcon.dot"
86
+ :dot-radius="clearIcon.dotRadius"
87
+ :badge="clearIcon.badge"
88
+ :color="clearIcon.color"
89
+ :size="clearIcon.size"
90
+ :class-prefix="clearIcon.classPrefix"
91
+ @click="handleClearInput"
92
+ />
93
+ </view>
78
94
  </view>
79
95
  </template>
80
96
 
@@ -266,17 +282,25 @@ export default {
266
282
  default() {
267
283
  return input.clearIcon
268
284
  }
285
+ },
286
+ // 是否失去焦点更新v-model
287
+ updateOnBlur: {
288
+ type: Boolean,
289
+ // true
290
+ default: input.updateOnBlur
269
291
  }
270
292
  },
271
293
  data() {
272
294
  return {
273
- focused: this.focus
295
+ focused: this.focus,
296
+ closeIconWidth: 0
274
297
  }
275
298
  },
276
299
  computed: {
277
300
  getDisabled() {
278
301
  const parentFormItem = this.$pi.parent(this, 'PiFormItem')
279
- const disabled = this.disabled || (parentFormItem && parentFormItem.getDisabled)
302
+ const disabled =
303
+ this.disabled || (parentFormItem && parentFormItem.getDisabled)
280
304
  return disabled
281
305
  },
282
306
  getInputWrapStyle() {
@@ -287,35 +311,64 @@ export default {
287
311
  if (this.$pi.lang.isString(this.border)) {
288
312
  style.border = this.border
289
313
  } else {
290
- style.border = '1Px solid #d9d9d9'
314
+ style.border = '1px solid #d9d9d9'
291
315
  }
292
316
  }
293
317
  return style
318
+ },
319
+ showClearIcon() {
320
+ return this.clearable && this.val
294
321
  }
295
322
  },
323
+ watch: {
324
+ showClearIcon() {
325
+ this.$nextTick(() => {
326
+ this.init()
327
+ })
328
+ }
329
+ },
330
+ mounted() {
331
+ this.init()
332
+ },
296
333
  methods: {
334
+ async init() {
335
+ if (!this.closeIconWidth) {
336
+ const closeIconRect = await this.$pi.common.queryRect(
337
+ this,
338
+ '.pi-input-close-icon',
339
+ false
340
+ )
341
+ if (closeIconRect && closeIconRect.width) {
342
+ this.closeIconWidth = closeIconRect.width
343
+ }
344
+ }
345
+ },
297
346
  handleItemClick(e) {
298
347
  this.$emit('click', e)
299
348
  },
300
- handleInput: debounce(function(e) {
301
- let value = e.detail.value
302
- // 输入内容
349
+ handleInput(e) {
350
+ const value = e.detail.value
303
351
  this.handleChange(value)
304
- }, 50),
352
+ },
305
353
  handleFocus() {
306
354
  this.focused = true
307
355
  // 获得焦点
308
356
  this.$emit('focus')
309
357
  },
310
358
  handleBlur(e) {
359
+ const value = e.detail.value
360
+ if (this.updateOnBlur) {
361
+ this.handleChange(value)
362
+ }
363
+ this.$emit('blur', value)
311
364
  setTimeout(() => {
312
365
  this.focused = false
366
+ this.dispatch('PiFormItem', 'form-blur', value)
313
367
  }, 100)
314
- // 失去焦点
315
- this.$emit('blur', e.detail.value)
316
- setTimeout(() => {
317
- this.dispatch('PiFormItem', 'form-blur', e.detail.value)
318
- }, 40)
368
+ },
369
+ handleClearInput() {
370
+ this.handleChange('')
371
+ this.$emit('clear')
319
372
  },
320
373
  /**
321
374
  * @vuese
@@ -328,8 +381,6 @@ export default {
328
381
  handleChange(value) {
329
382
  this.val = value
330
383
  this.handleEmitChange()
331
- this.dispatch('PiForm', 'form-change', this.val)
332
- this.dispatch('PiFormItem', 'form-change', this.val)
333
384
  }
334
385
  }
335
386
  }
@@ -337,6 +388,7 @@ export default {
337
388
 
338
389
  <style lang="scss" scoped>
339
390
  .pi-input-wrap {
391
+ position: relative;
340
392
  width: 100%;
341
393
  display: flex;
342
394
  align-items: center;
@@ -344,5 +396,14 @@ export default {
344
396
  .pi-input-textarea {
345
397
  width: 100%;
346
398
  }
399
+
400
+ .pi-input-mask {
401
+ position: absolute;
402
+ left: 0;
403
+ top: 0;
404
+ bottom: 0;
405
+ background: transparent;
406
+ z-index: 101;
407
+ }
347
408
  }
348
409
  </style>
@@ -326,7 +326,7 @@ export default {
326
326
  }
327
327
  &.border {
328
328
  @include pi-border;
329
- &::after {
329
+ &::before {
330
330
  border: 0 solid $pi-list-border-color;
331
331
  border-bottom-width: $pi-list-border-width;
332
332
  }