sadais-piui 1.1.2-beta → 1.2.2-beta2

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 (39) hide show
  1. package/CHANGELOG.md +482 -240
  2. package/README.md +2 -3
  3. package/components/pi-bottom-bar/index.vue +15 -2
  4. package/components/pi-canvas/index.vue +400 -0
  5. package/components/pi-circle-progress/index.vue +196 -173
  6. package/components/pi-count-up/index.vue +68 -62
  7. package/components/pi-dropdown/components/dropdown-tab.vue +62 -0
  8. package/components/pi-dropdown/index.vue +152 -151
  9. package/components/pi-dropdown-item/index.vue +169 -41
  10. package/components/pi-form-item/index.vue +13 -1
  11. package/components/pi-img/index.vue +1 -0
  12. package/components/pi-img-cropper/index.vue +20 -16
  13. package/components/pi-img-cropper/touch.js +5 -3
  14. package/components/pi-input/index.vue +9 -2
  15. package/components/pi-notify/index.vue +132 -48
  16. package/components/pi-popup/index.vue +1 -3
  17. package/components/pi-radio/index.vue +10 -1
  18. package/components/pi-radio-group/index.vue +21 -2
  19. package/components/pi-select/index.vue +13 -3
  20. package/components/pi-steps/index.vue +141 -96
  21. package/components/pi-switch/index.vue +2 -3
  22. package/components/pi-tabs/index.vue +1 -2
  23. package/components/pi-upload-img/index.vue +104 -32
  24. package/config/bottomBar.js +1 -0
  25. package/config/checkbox.js +1 -1
  26. package/config/circleProgress.js +13 -0
  27. package/config/countUp.js +13 -0
  28. package/config/dropdown.js +17 -8
  29. package/config/dropdownItem.js +23 -5
  30. package/config/form.js +3 -3
  31. package/config/imgCropper.js +4 -2
  32. package/config/notify.js +6 -2
  33. package/config/radio.js +2 -1
  34. package/config/radioGroup.js +2 -1
  35. package/config/steps.js +10 -5
  36. package/config/{upload-img.js → uploadImg.js} +6 -3
  37. package/index.js +2 -2
  38. package/package.json +3 -3
  39. package/scss/variable.scss +1 -1
@@ -9,7 +9,7 @@
9
9
  ]"
10
10
  :style="[
11
11
  {
12
- 'zIndex': getMask.zIndex,
12
+ 'z-index': getMask.zIndex,
13
13
  'background': getMask.background,
14
14
  'animation-duration': getDuration.css
15
15
  }
@@ -318,8 +318,6 @@ export default {
318
318
 
319
319
  <style lang="scss" scoped>
320
320
  @import '../../scss/mixin.scss';
321
- .pi-popup {
322
- }
323
321
 
324
322
  .ani-scale-center-up {
325
323
  animation: scale-center-up $pi-animation-duration $pi-animation-timing-function both;
@@ -127,6 +127,12 @@ export default {
127
127
  validator: function(value) {
128
128
  return ['line', 'line-circle', 'fill', 'fill-circle'].includes(value)
129
129
  }
130
+ },
131
+ // 能否取消选中状态
132
+ canCancel: {
133
+ type: Boolean,
134
+ // false
135
+ default: radio.canCancel
130
136
  }
131
137
  },
132
138
  data() {
@@ -172,6 +178,9 @@ export default {
172
178
  ? this.$pi.common.addUnit(this.inheritProps.iconSize)
173
179
  : this.$pi.common.addUnit(this.iconSize)
174
180
  },
181
+ getCanCancel() {
182
+ return this.inheritProps.canCancel !== null ? this.inheritProps.canCancel : this.canCancel
183
+ },
175
184
  radioStyle() {
176
185
  const style = {
177
186
  width: this.getSize,
@@ -332,7 +341,7 @@ $unactive-color: #cccccc;
332
341
  .radio-label {
333
342
  color: $pi-primary-color;
334
343
  &.button {
335
- box-shadow: -2px 0 0 0 $pi-primary-color;
344
+ box-shadow: -4rpx 0 0 0 $pi-primary-color;
336
345
  }
337
346
  }
338
347
  &.line,
@@ -37,7 +37,8 @@ export default {
37
37
  'size',
38
38
  'iconSize',
39
39
  'activeColor',
40
- 'activeMode'
40
+ 'activeMode',
41
+ 'canCancel'
41
42
  ])
42
43
  ], // 注入value与val,进行双向绑定
43
44
  options: {
@@ -137,6 +138,12 @@ export default {
137
138
  validator: function(value) {
138
139
  return ['', 'line', 'line-circle', 'fill', 'fill-circle'].includes(value)
139
140
  }
141
+ },
142
+ // 能否取消选中状态
143
+ canCancel: {
144
+ type: Boolean,
145
+ // null
146
+ default: radioGroup.canCancel
140
147
  }
141
148
  },
142
149
  methods: {
@@ -146,7 +153,19 @@ export default {
146
153
  * @arg pi-radio的name属性值
147
154
  */
148
155
  emitChange(childName) {
149
- this.val = childName
156
+ let canCancel = this.canCancel
157
+ if (!canCancel) {
158
+ this._children.forEach(child => {
159
+ if (child.name === childName) {
160
+ canCancel = child.getCanCancel
161
+ }
162
+ })
163
+ }
164
+ if (canCancel && this.val === childName) {
165
+ this.val = ''
166
+ } else {
167
+ this.val = childName
168
+ }
150
169
  this.handleEmitChange()
151
170
  }
152
171
  }
@@ -19,7 +19,12 @@
19
19
  >
20
20
  <view class="pi-select pi-h-100P pi-flex-column" :style="[customStyle]" :class="[customClass]">
21
21
  <slot name="header" />
22
- <scroll-view scroll-y class="pi-scroll">
22
+ <scroll-view
23
+ scroll-y
24
+ class="pi-scroll"
25
+ :scroll-into-view="getFirstSelectedId"
26
+ scroll-with-animation
27
+ >
23
28
  <view
24
29
  v-for="item in getItems"
25
30
  :id="`id-${item[keyField]}`"
@@ -39,7 +44,7 @@
39
44
  </slot>
40
45
  <!-- 如果配置了图片地址,使用图片 -->
41
46
  <pi-img
42
- v-if="getSelectedImg.src"
47
+ v-if="getSelectedImg.src && item.isSelected"
43
48
  :src="getSelectedImg.src"
44
49
  :mode="getSelectedImg.mode"
45
50
  :width="getSelectedImg.width"
@@ -59,7 +64,7 @@
59
64
  />
60
65
  <!-- 默认使用复选框 -->
61
66
  <pi-checkbox
62
- v-else
67
+ v-if="!getSelectedImg.src"
63
68
  readonly
64
69
  :value="item.isSelected"
65
70
  :name="getSelectedCheckbox.name"
@@ -265,6 +270,11 @@ export default {
265
270
  item.isSelected = isSelected
266
271
  return item
267
272
  })
273
+ },
274
+ getFirstSelectedId() {
275
+ const firstSelected = this.selected[0] || this.selected
276
+ const firstSelectedId = firstSelected[this.keyField]
277
+ return firstSelectedId ? `id-${firstSelected[this.keyField]}` : ''
268
278
  }
269
279
  },
270
280
  watch: {
@@ -1,70 +1,48 @@
1
1
  <template>
2
2
  <view class="pi-steps" :style="[customStyle, { flexDirection: direction }]" :class="customClass">
3
3
  <view
4
- v-for="(item, index) in customItem"
4
+ v-for="(item, index) in getItems"
5
5
  :key="index"
6
6
  class="pi-steps-item"
7
7
  :style="itemStyle"
8
- :class="[itemClass, ['pi-steps-item-' + direction]]"
8
+ :class="[itemClass, item.mode, direction, { active: index < val }]"
9
9
  >
10
- <!-- 圆点 -->
11
- <view
12
- v-if="mode === 'dot'"
13
- class="pi-steps-item-dot"
14
- :class="['pi-steps-item-dot-' + direction]"
15
- :style="{
16
- backgroundColor: item.bgColor,
17
- width: size + 'rpx',
18
- height: size + 'rpx'
19
- }"
20
- />
21
-
22
- <!-- 数字-->
23
- <view
24
- v-if="mode === 'number'"
25
- class="pi-steps-item-number"
26
- :style="{
27
- backgroundColor: item.bgColor,
28
- borderColor: item.borderColor,
29
- width: size + 'rpx',
30
- height: size + 'rpx'
31
- }"
32
- >
33
- <text
34
- v-if="current < index"
35
- :style="{
36
- color: item.color
37
- }"
38
- >
39
- {{ index + 1 }}
40
- </text>
41
- <pi-icon v-else :name="icon" color="#ffffff" />
42
- </view>
43
-
44
- <!-- 图标 -->
45
- <view v-if="mode === 'icon'">
10
+ <view class="step-icon pi-flex-row-center" :style="[item.style]">
11
+ <template v-if="item.mode === 'dot'">
12
+ <view class="item-dot pi-radius-round" :style="[item.dotStyle]" />
13
+ </template>
14
+ <!-- 数字-->
15
+ <template v-if="item.mode === 'number'">
16
+ <text v-if="index >= val">
17
+ {{ index + 1 }}
18
+ </text>
19
+ <pi-icon v-else name="check" color="#ffffff" />
20
+ </template>
21
+ <!-- 图标 -->
46
22
  <pi-icon
47
- :style="{
48
- color: item.color
49
- }"
50
- :size="size"
51
- :name="item.icon"
23
+ v-if="item.mode === 'icon'"
24
+ :custom-style="item.icon.customStyle"
25
+ :custom-class="item.icon.customClass"
26
+ :name="item.icon.name"
27
+ :dot="item.icon.dot"
28
+ :dot-radius="item.icon.dotRadius"
29
+ :badge="item.icon.badge"
30
+ :color="item.icon.color"
31
+ :size="item.icon.size"
32
+ :class-prefix="item.icon.classPrefix"
52
33
  />
53
34
  </view>
54
35
 
55
36
  <!-- 文字 -->
56
- <view :class="['pi-steps-item-text-' + direction]" :style="{ color: item.color }">
57
- <view>{{ item.name }}</view>
58
- <text class="pi-fz-20" style="word-break:break-all">{{ item.desc }}</text>
37
+ <view :class="['pi-steps-item-text']" :style="{ color: item.style.fontColor }">
38
+ <slot name="item" :item="item" :index="index" :active="index < val">
39
+ <view>{{ item.name }}</view>
40
+ <text class="pi-fz-20" style="word-break:break-all">{{ item.desc }}</text>
41
+ </slot>
59
42
  </view>
60
43
 
61
44
  <!-- 中线 -->
62
- <view
63
- v-if="index < items.length - 1"
64
- class="pi-steps-item-line"
65
- :class="['pi-steps-item-line-' + mode]"
66
- :style="lineStyle"
67
- >
45
+ <view v-if="index < items.length - 1" class="pi-steps-item-line" :style="[lineStyle]">
68
46
  <pi-line :direction="direction" length="100%" :hair-line="false" :color="color" />
69
47
  </view>
70
48
  </view>
@@ -141,45 +119,102 @@ export default {
141
119
  type: String,
142
120
  default: steps.currentColor
143
121
  },
144
- // 选中图标
145
- icon: {
146
- type: String,
147
- default: steps.icon
148
- },
149
122
  // 排列方向,row|column
150
123
  direction: {
151
124
  type: String,
152
125
  default: steps.direction
153
126
  },
154
- // 图标大小
127
+ // 圆点大小
155
128
  size: {
156
129
  type: String,
157
130
  default: steps.size
131
+ },
132
+ // 图标配置
133
+ icon: {
134
+ type: Object,
135
+ default() {
136
+ return steps.icon
137
+ }
158
138
  }
159
139
  },
160
140
  data() {
161
141
  return {}
162
142
  },
163
143
  computed: {
144
+ getDotMaxSize() {
145
+ return this.items.reduce((pre, cur) => {
146
+ const icon = this.$pi.lang.mergeDeep(this.getIcon, cur.icon)
147
+ const size = parseInt(icon.size || this.size, 10)
148
+ return size > pre ? size : pre
149
+ }, 0)
150
+ },
164
151
  lineStyle() {
165
- let style = {}
166
- let size = this.size / 2 + 'rpx'
152
+ const style = {}
153
+ const size = this.getDotMaxSize / 2 + 'rpx'
167
154
  this.direction === 'column' ? (style.left = size) : (style.top = size)
168
155
  return style
169
156
  },
170
- current() {
171
- return this.val
157
+ getCurrentColor() {
158
+ return this.currentColor || this.color
172
159
  },
173
- customItem() {
174
- return this.items.map((item, index) => {
160
+
161
+ getIcon() {
162
+ return this.$pi.lang.mergeDeep(steps.rightIcon, this.icon)
163
+ },
164
+ getItems() {
165
+ const getSize = this.$pi.common.addUnit(this.size)
166
+ const getDotMaxSize = this.$pi.common.addUnit(this.getDotMaxSize)
167
+
168
+ return this.items.map((originitem, index) => {
169
+ const item = { ...originitem, dotStyle: {} }
170
+ const style = {}
171
+ item.mode = item.mode || this.mode
172
+ item.icon = this.$pi.lang.mergeDeep(this.getIcon, item.icon)
173
+ if (item.mode === 'dot') {
174
+ style.width = getDotMaxSize
175
+ style.height = getDotMaxSize
176
+ item.dotStyle.width = getSize
177
+ item.dotStyle.height = getSize
178
+ }
179
+ if (item.mode === 'number') {
180
+ style.width = getDotMaxSize
181
+ style.height = getDotMaxSize
182
+ style.color = '#ffffff'
183
+ }
175
184
  if (index === this.val) {
176
- item.bgColor = item.borderColor = item.color = this.currentColor
177
- } else if (index < this.val) {
178
- item.bgColor = item.borderColor = item.color = this.activeColor
179
- } else {
180
- item.borderColor = item.color = this.color
181
- item.bgColor = this.mode === 'number' ? 'transparent' : this.color
185
+ // 当前步骤
186
+ style.fontColor = this.getCurrentColor
187
+ if (item.mode === 'icon') {
188
+ style.color = this.getCurrentColor
189
+ } else if (item.mode === 'dot') {
190
+ item.dotStyle.backgroundColor = this.getCurrentColor
191
+ } else {
192
+ style.backgroundColor = this.getCurrentColor
193
+ }
194
+ } else if (index < this.val && this.activeColor) {
195
+ // 已激活步骤
196
+ style.fontColor = this.activeColor
197
+ if (item.mode === 'icon') {
198
+ style.color = this.activeColor
199
+ } else if (item.mode === 'dot') {
200
+ item.dotStyle.backgroundColor = this.getCurrentColor
201
+ } else {
202
+ style.backgroundColor = this.activeColor
203
+ }
204
+ } else if (index > this.val) {
205
+ // 未激活步骤
206
+ style.fontColor = this.color
207
+ if (item.mode === 'dot') {
208
+ item.dotStyle.backgroundColor = this.color
209
+ }
210
+ if (item.mode === 'icon') {
211
+ style.color = this.color
212
+ }
213
+ if (item.mode === 'number') {
214
+ style.backgroundColor = this.color
215
+ }
182
216
  }
217
+ item.style = style
183
218
  return item
184
219
  })
185
220
  }
@@ -198,10 +233,17 @@ export default {
198
233
  align-items: flex-start;
199
234
  flex: 1;
200
235
  font-size: 26rpx;
201
- &-row {
236
+ &.row {
202
237
  display: flex;
203
238
  flex-direction: column;
204
239
  align-items: center;
240
+ .pi-steps-item-text {
241
+ margin-top: 14rpx;
242
+ text-align: center;
243
+ display: flex;
244
+ flex-direction: column;
245
+ align-items: center;
246
+ }
205
247
  .pi-steps-item-line {
206
248
  position: absolute;
207
249
  left: 75%;
@@ -210,44 +252,47 @@ export default {
210
252
  }
211
253
  }
212
254
 
213
- &-column {
255
+ &.column {
214
256
  display: flex;
215
257
  flex-direction: row;
216
258
  justify-content: flex-start;
259
+ align-items: center;
217
260
  min-height: 120rpx;
261
+ .pi-steps-item-text {
262
+ width: 95%;
263
+ margin-left: 14rpx;
264
+ display: flex;
265
+ flex-direction: column;
266
+ }
218
267
  .pi-steps-item-line {
219
268
  position: absolute;
220
- top: 40%;
269
+ top: 75%;
221
270
  z-index: 0;
222
271
  height: 50%;
223
272
  }
224
273
  }
225
- &-dot {
274
+ .item-dot,
275
+ .step-icon {
226
276
  border-radius: 50%;
227
- &-column {
228
- margin-top: 4rpx;
229
- }
230
- }
231
- &-number {
232
- display: flex;
233
- align-items: center;
234
- justify-content: center;
235
277
  overflow: hidden;
236
- border: 1px solid #8799a3;
237
- border-radius: 50%;
238
278
  }
239
- &-text-row {
240
- margin-top: 14rpx;
241
- text-align: center;
242
- display: flex;
243
- flex-direction: column;
244
- align-items: center;
245
- }
246
- &-text-column {
247
- width: 95%;
248
- margin-left: 14rpx;
249
- display: flex;
250
- flex-direction: column;
279
+
280
+ &.active {
281
+ .pi-steps-item-text {
282
+ color: $pi-primary-color;
283
+ }
284
+
285
+ .item-dot {
286
+ background-color: $pi-primary-color;
287
+ }
288
+
289
+ &.icon .step-icon {
290
+ color: $pi-primary-color;
291
+ }
292
+
293
+ &.number .step-icon {
294
+ background-color: $pi-primary-color;
295
+ }
251
296
  }
252
297
  }
253
298
  }
@@ -192,7 +192,7 @@ export default {
192
192
  display: inline-block;
193
193
  width: 2em;
194
194
  height: 1em;
195
- border: 4rpx solid #e5e5e5;
195
+ border: 2rpx solid #e5e5e5;
196
196
  transition: background-color $pi-animation-duration;
197
197
  .switch-node {
198
198
  position: relative;
@@ -200,8 +200,7 @@ export default {
200
200
  background: #ffffff;
201
201
  border-radius: 50%;
202
202
  /* stylelint-disable */
203
- box-shadow: -2rpx 4rpx 4rpx 0 rgba(0, 0, 0, 0.1),
204
- 0 4rpx 23rpx 0 rgba(0, 0, 0, 0.08),
203
+ box-shadow: -2rpx 4rpx 4rpx 0 rgba(0, 0, 0, 0.1), 0 4rpx 23rpx 0 rgba(0, 0, 0, 0.08),
205
204
  0 0 4rpx 0 rgba(0, 0, 0, 0.2);
206
205
  transition: all cubic-bezier(0.3, 1.05, 0.4, 1.05) $pi-animation-duration;
207
206
  }
@@ -25,7 +25,7 @@
25
25
  >
26
26
  <!-- slot slot-scoped只支持app,h5,微信小程序平台 -->
27
27
  <!-- <template slot="item" slot-scope="{ item }">{{ item.tag }}</template> -->
28
- <slot name="item" :item="item" :active="activeIndex === index">
28
+ <slot name="item" :item="item" :index="index" :active="activeIndex === index">
29
29
  {{ item[displayField] }}
30
30
  </slot>
31
31
  </view>
@@ -333,7 +333,6 @@ export default {
333
333
  if (srollWrapRect) {
334
334
  this.tabsWidth = srollWrapRect.width
335
335
  }
336
- console.warn('this.tabsWidth', this.tabsWidth)
337
336
  this.tabRects = await this.$pi.common.queryRect(this, '.pi-tab', true)
338
337
  console.log(TAG, '计算.pi-tab布局', this.tabRects)
339
338
  },