sadais-piui 1.0.182 → 1.2.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 (40) hide show
  1. package/CHANGELOG.md +482 -240
  2. package/README.md +27 -17
  3. package/components/pi-bottom-bar/index.vue +11 -2
  4. package/components/pi-calendar-panel/index.vue +10 -4
  5. package/components/pi-checkbox-group/index.vue +5 -0
  6. package/components/pi-circle-progress/index.vue +196 -173
  7. package/components/pi-count-up/index.vue +209 -0
  8. package/components/pi-dropdown/components/dropdown-tab.vue +62 -0
  9. package/components/pi-dropdown/index.vue +316 -0
  10. package/components/pi-dropdown-item/index.vue +233 -0
  11. package/components/pi-form-item/index.vue +13 -1
  12. package/components/pi-img-cropper/canvas.js +112 -0
  13. package/components/pi-img-cropper/index.vue +357 -0
  14. package/components/pi-img-cropper/touch.js +163 -0
  15. package/components/pi-img-cropper/vector.js +35 -0
  16. package/components/pi-input/index.vue +9 -2
  17. package/components/pi-line/index.vue +78 -0
  18. package/components/pi-notify/index.vue +239 -0
  19. package/components/pi-popup/index.vue +1 -3
  20. package/components/pi-select/index.vue +5 -5
  21. package/components/pi-steps/index.vue +299 -0
  22. package/components/pi-switch/index.vue +2 -3
  23. package/components/pi-tabs/index.vue +1 -1
  24. package/components/pi-upload-img/index.vue +145 -40
  25. package/config/bottomBar.js +1 -0
  26. package/config/checkbox.js +1 -1
  27. package/config/circleProgress.js +13 -0
  28. package/config/countUp.js +13 -0
  29. package/config/dropdown.js +21 -0
  30. package/config/dropdownItem.js +26 -0
  31. package/config/form.js +3 -3
  32. package/config/imgCropper.js +26 -0
  33. package/config/line.js +8 -0
  34. package/config/notify.js +13 -0
  35. package/config/steps.js +19 -0
  36. package/config/{upload-img.js → uploadImg.js} +5 -1
  37. package/index.js +2 -2
  38. package/package.json +3 -3
  39. package/scss/common.scss +4 -0
  40. package/scss/variable.scss +1 -1
@@ -0,0 +1,239 @@
1
+ <template>
2
+ <view
3
+ v-if="!closed"
4
+ class="pi-notify pi-fixed-top pi-w-100P pi-text-ellipsis"
5
+ :style="[getNotifyStyle]"
6
+ :class="[`pi-notify-${type}`, getAniClass]"
7
+ >
8
+ <!-- 状态栏占位 -->
9
+ <pi-status-bar :background="bgColor" />
10
+ <!-- 内容插槽 -->
11
+ <div
12
+ class="pi-notify-container pi-text-ellipsis"
13
+ :style="[customStyle, getContainerStyle]"
14
+ :class="[customClass]"
15
+ >
16
+ <!-- message prop -->
17
+ <template v-if="message">{{ message }}</template>
18
+ <slot v-else-if="$slots.default || $slots.$default" />
19
+ </div>
20
+ </view>
21
+ </template>
22
+
23
+ <script>
24
+ import ValueSync from '../../mixin/value-sync'
25
+ import { getConfig } from '../../config'
26
+ import { parseDuration } from '@sadais/piui-tool/tools/common'
27
+
28
+ const TAG = 'PiNotify'
29
+ const { notify } = getConfig()
30
+
31
+ export default {
32
+ name: TAG,
33
+ mixins: [ValueSync],
34
+ props: {
35
+ // 初始值
36
+ value: {
37
+ required: false,
38
+ type: Boolean
39
+ },
40
+ // 自定义样式
41
+ customStyle: {
42
+ type: Object,
43
+ // {}
44
+ default() {
45
+ return notify.customStyle
46
+ }
47
+ },
48
+ // 自定义样式类
49
+ customClass: {
50
+ type: String,
51
+ // ''
52
+ default() {
53
+ return notify.customClass
54
+ }
55
+ },
56
+ // 显示的消息文本
57
+ message: {
58
+ type: String,
59
+ // ''
60
+ default: notify.message
61
+ },
62
+ // notify 类型
63
+ type: {
64
+ type: String,
65
+ // 'primary'
66
+ default: notify.type,
67
+ validator: function(value) {
68
+ return ['primary', 'success', 'danger', 'warning', 'info', 'customDuration', ''].includes(
69
+ value
70
+ )
71
+ }
72
+ },
73
+ // 展示时长,默认单位 ms
74
+ duration: {
75
+ type: [String, Number],
76
+ // 3000
77
+ default: notify.duration
78
+ },
79
+ // 字体颜色
80
+ color: {
81
+ type: String,
82
+ // ''
83
+ default: notify.color
84
+ },
85
+ // 背景颜色
86
+ bgColor: {
87
+ type: String,
88
+ // ''
89
+ default: notify.bgColor
90
+ },
91
+ // 层级z-index
92
+ zIndex: {
93
+ type: [Number, String],
94
+ // 999
95
+ default: notify.zIndex
96
+ },
97
+ // 是否挂载到body下,防止嵌套层级无法遮罩的问题(仅H5环境生效)
98
+ appendToBody: {
99
+ type: Boolean,
100
+ // false
101
+ default: notify.appendToBody
102
+ },
103
+ // 是否自动隐藏,默认 true
104
+ autoHide: {
105
+ type: Boolean,
106
+ // true
107
+ default: notify.autoHide
108
+ },
109
+ // 是否单行显示,默认 false
110
+ singleLine: {
111
+ type: Boolean,
112
+ // false
113
+ default: notify.singleLine
114
+ }
115
+ },
116
+ data() {
117
+ return {
118
+ show: false, // 是否显示节点
119
+ showed: false, // 是否显示动画执行完毕
120
+ closed: true // 是否已关闭(用来防止val为false的情况,动画无法执行)
121
+ }
122
+ },
123
+ computed: {
124
+ getDuration() {
125
+ return parseDuration(this.duration)
126
+ },
127
+ getNotifyStyle() {
128
+ const { color, bgColor, zIndex } = this
129
+ return {
130
+ zIndex,
131
+ color,
132
+ background: bgColor
133
+ }
134
+ },
135
+ getAniClass() {
136
+ return this.show ? 'pi-ani-slide-top-show' : 'pi-ani-slide-top-hide'
137
+ },
138
+ getContainerStyle() {
139
+ const style = {}
140
+ style.whiteSpace = this.singleLine ? 'nowrap' : 'pre-wrap'
141
+
142
+ // #ifdef MP-WEIXIN
143
+ const buttonRect = wx.getMenuButtonBoundingClientRect()
144
+ style.paddingRight = `${buttonRect.width}px`
145
+ // #endif
146
+
147
+ return style
148
+ }
149
+ },
150
+ watch: {
151
+ val: {
152
+ deep: true,
153
+ immediate: true,
154
+ handler(value) {
155
+ value ? this.showNotify() : this.hideNotify()
156
+ }
157
+ }
158
+ },
159
+ destroyed() {
160
+ // #ifdef H5
161
+ if (this.appendToBody && this.$el && this.$el.parentNode) {
162
+ this.$el.parentNode.removeChild(this.$el)
163
+ }
164
+ // #endif
165
+ },
166
+ methods: {
167
+ showNotify() {
168
+ if (this.show) return
169
+ console.log(TAG, '显示通知栏')
170
+ this.closed = false
171
+ this.show = true
172
+ this.showed = false
173
+ this.handleEmitChange()
174
+ setTimeout(() => {
175
+ // 动画执行完毕
176
+ this.showed = true
177
+ // 自动关闭
178
+ this.autoHide &&
179
+ setTimeout(() => {
180
+ this.hideNotify()
181
+ }, this.getDuration.js)
182
+ }, 300)
183
+ // #ifdef H5
184
+ if (this.appendToBody) {
185
+ document.body.appendChild(this.$el)
186
+ }
187
+ // #endif
188
+ },
189
+ hideNotify() {
190
+ if (!this.show || !this.showed) return
191
+ console.log(TAG, '隐藏通知栏')
192
+ this.show = false
193
+ this.showed = false
194
+ setTimeout(() => {
195
+ this.$emit('closed')
196
+ this.closed = true
197
+ this.val = false
198
+ this.handleEmitChange()
199
+ }, 300)
200
+ }
201
+ }
202
+ }
203
+ </script>
204
+
205
+ <style lang="scss" scoped>
206
+ .pi-notify {
207
+ color: $pi-background-color;
208
+ font-size: $pi-font-size;
209
+ padding: 24rpx 32rpx;
210
+ overflow: hidden;
211
+
212
+ transition: all $pi-animation-duration $pi-animation-timing-function;
213
+
214
+ .pi-notify-container {
215
+ text-align: center;
216
+ min-width: 0;
217
+ }
218
+
219
+ &-primary {
220
+ background: $pi-primary-color;
221
+ }
222
+
223
+ &-success {
224
+ background: $pi-fourth-color;
225
+ }
226
+
227
+ &-danger {
228
+ background: #e64340;
229
+ }
230
+
231
+ &-warning {
232
+ background: #f90;
233
+ }
234
+
235
+ &-info {
236
+ background: #909399;
237
+ }
238
+ }
239
+ </style>
@@ -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;
@@ -39,7 +39,7 @@
39
39
  </slot>
40
40
  <!-- 如果配置了图片地址,使用图片 -->
41
41
  <pi-img
42
- v-if="getSelectedImg.src"
42
+ v-if="getSelectedImg.src && item.isSelected"
43
43
  :src="getSelectedImg.src"
44
44
  :mode="getSelectedImg.mode"
45
45
  :width="getSelectedImg.width"
@@ -55,10 +55,11 @@
55
55
  :loading-size="getSelectedImg.loadingSize"
56
56
  :show-error="getSelectedImg.showError"
57
57
  :webp="getSelectedImg.webp"
58
+ custom-class="pi-mg-left-24"
58
59
  />
59
60
  <!-- 默认使用复选框 -->
60
61
  <pi-checkbox
61
- v-else
62
+ v-if="!getSelectedImg.src"
62
63
  readonly
63
64
  :value="item.isSelected"
64
65
  :name="getSelectedCheckbox.name"
@@ -70,6 +71,7 @@
70
71
  :icon-size="getSelectedCheckbox.iconSize"
71
72
  :active-color="getSelectedCheckbox.activeColor"
72
73
  :active-mode="getSelectedCheckbox.activeMode"
74
+ custom-class="pi-mg-left-24"
73
75
  />
74
76
  </view>
75
77
  </scroll-view>
@@ -246,10 +248,8 @@ export default {
246
248
  return this.$pi.lang.mergeDeep(selectPopup, this.popup)
247
249
  },
248
250
  getItemStyle() {
249
- const itemHeight = this.$pi.common.addUnit(this.itemHeight)
250
251
  return {
251
- height: itemHeight,
252
- lineHeight: itemHeight
252
+ height: this.$pi.common.addUnit(this.itemHeight)
253
253
  }
254
254
  },
255
255
  getItems() {
@@ -0,0 +1,299 @@
1
+ <template>
2
+ <view class="pi-steps" :style="[customStyle, { flexDirection: direction }]" :class="customClass">
3
+ <view
4
+ v-for="(item, index) in getItems"
5
+ :key="index"
6
+ class="pi-steps-item"
7
+ :style="itemStyle"
8
+ :class="[itemClass, item.mode, direction, { active: index < val }]"
9
+ >
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
+ <!-- 图标 -->
22
+ <pi-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"
33
+ />
34
+ </view>
35
+
36
+ <!-- 文字 -->
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>
42
+ </view>
43
+
44
+ <!-- 中线 -->
45
+ <view v-if="index < items.length - 1" class="pi-steps-item-line" :style="[lineStyle]">
46
+ <pi-line :direction="direction" length="100%" :hair-line="false" :color="color" />
47
+ </view>
48
+ </view>
49
+ </view>
50
+ </template>
51
+
52
+ <script>
53
+ import ValueSync from '../../mixin/value-sync'
54
+ import { getConfig } from '../../config'
55
+
56
+ const TAG = 'PiSteps'
57
+ const { steps } = getConfig()
58
+ export default {
59
+ name: 'PiSteps',
60
+ // 混入v-model
61
+ mixins: [ValueSync],
62
+ props: {
63
+ // 初始值
64
+ value: {
65
+ required: false
66
+ },
67
+ // 自定义样式,对象形式(默认值:{})
68
+ customStyle: {
69
+ type: Object,
70
+ default() {
71
+ return steps.customStyle
72
+ }
73
+ },
74
+ // 自定义样式类,字符串形式('')
75
+ customClass: {
76
+ type: String,
77
+ default() {
78
+ return steps.customClass
79
+ }
80
+ },
81
+ // 自定义样式,对象形式(默认值:{})
82
+ itemStyle: {
83
+ type: Object,
84
+ default() {
85
+ return steps.customStyle
86
+ }
87
+ },
88
+ // 自定义样式类,字符串形式('')
89
+ itemClass: {
90
+ type: String,
91
+ default() {
92
+ return steps.customClass
93
+ }
94
+ },
95
+ // 步骤条的类型,dot|number|icon
96
+ mode: {
97
+ type: String,
98
+ default: steps.mode
99
+ },
100
+ // 步骤条的数据
101
+ items: {
102
+ type: Array,
103
+ default() {
104
+ return steps.items
105
+ }
106
+ },
107
+ // 激活步骤的颜色
108
+ activeColor: {
109
+ type: String,
110
+ default: steps.activeColor
111
+ },
112
+ // 未激活的颜色
113
+ color: {
114
+ type: String,
115
+ default: steps.color
116
+ },
117
+ // 当前步骤的颜色
118
+ currentColor: {
119
+ type: String,
120
+ default: steps.currentColor
121
+ },
122
+ // 排列方向,row|column
123
+ direction: {
124
+ type: String,
125
+ default: steps.direction
126
+ },
127
+ // 圆点大小
128
+ size: {
129
+ type: String,
130
+ default: steps.size
131
+ },
132
+ // 图标配置
133
+ icon: {
134
+ type: Object,
135
+ default() {
136
+ return steps.icon
137
+ }
138
+ }
139
+ },
140
+ data() {
141
+ return {}
142
+ },
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
+ },
151
+ lineStyle() {
152
+ const style = {}
153
+ const size = this.getDotMaxSize / 2 + 'rpx'
154
+ this.direction === 'column' ? (style.left = size) : (style.top = size)
155
+ return style
156
+ },
157
+ getCurrentColor() {
158
+ return this.currentColor || this.color
159
+ },
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
+ }
184
+ if (index === this.val) {
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
+ }
216
+ }
217
+ item.style = style
218
+ return item
219
+ })
220
+ }
221
+ },
222
+ watch: {},
223
+ methods: {}
224
+ }
225
+ </script>
226
+
227
+ <style lang="scss" scoped>
228
+ .pi-steps {
229
+ display: flex;
230
+ .pi-steps-item {
231
+ position: relative;
232
+ display: flex;
233
+ align-items: flex-start;
234
+ flex: 1;
235
+ font-size: 26rpx;
236
+ &.row {
237
+ display: flex;
238
+ flex-direction: column;
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
+ }
247
+ .pi-steps-item-line {
248
+ position: absolute;
249
+ left: 75%;
250
+ z-index: 0;
251
+ width: 50%;
252
+ }
253
+ }
254
+
255
+ &.column {
256
+ display: flex;
257
+ flex-direction: row;
258
+ justify-content: flex-start;
259
+ align-items: center;
260
+ min-height: 120rpx;
261
+ .pi-steps-item-text {
262
+ width: 95%;
263
+ margin-left: 14rpx;
264
+ display: flex;
265
+ flex-direction: column;
266
+ }
267
+ .pi-steps-item-line {
268
+ position: absolute;
269
+ top: 75%;
270
+ z-index: 0;
271
+ height: 50%;
272
+ }
273
+ }
274
+ .item-dot,
275
+ .step-icon {
276
+ border-radius: 50%;
277
+ overflow: hidden;
278
+ }
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
+ }
296
+ }
297
+ }
298
+ }
299
+ </style>
@@ -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>