mali-applet-ui 0.2.36 → 0.2.38

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.
@@ -33,9 +33,9 @@ export default {
33
33
  }
34
34
  },
35
35
  methods: {
36
- tapEvent (e) {
37
- this.$emit('tap', { $event: e })
38
- this.$emit('click', { $event: e })
36
+ tapEvent () {
37
+ this.$emit('tap', {})
38
+ this.$emit('click', {})
39
39
  }
40
40
  }
41
41
  }
@@ -27,11 +27,10 @@ export default {
27
27
  },
28
28
  methods: {
29
29
  clickEvent (e) {
30
- this.$emit('click', { $event: e })
31
30
  },
32
31
  tapEvent () {
33
- this.$emit('tap', { $event: e })
34
- this.$emit('click', { $event: e })
32
+ this.$emit('tap', {})
33
+ this.$emit('click', {})
35
34
  }
36
35
  }
37
36
  }
@@ -0,0 +1,175 @@
1
+ <template>
2
+ <view class="ml-modal" :class="[className || '', `placement-${placement || 'bottom'}`, {'is-visible': visible}]" @tap="tapMaskEvent">
3
+ <view v-if="visible" class="ml-drawer-warpper" @tap.stop.prevent>
4
+ <view v-if="showHeader" class="ml-drawer-header">
5
+ <slot name="header">
6
+ <view v-if="title" class="ml-drawer-header-title">{{ title }}</view>
7
+ </slot>
8
+ </view>
9
+ <view class="ml-drawer-body" :style="bodyStyles">
10
+ <scroll-view scroll-y>
11
+ <slot></slot>
12
+ </scroll-view>
13
+ </view>
14
+ <view v-if="showConfirmButton || showCancelButton || showFooter" class="ml-drawer-footer">
15
+ <slot name="footer">
16
+ <ml-button v-if="showCancelButton" @click="cancelEvent">{{ cancelButtonText }}</ml-button>
17
+ <ml-button v-if="showConfirmButton" status="primary" @click="confirmEvent">{{ confirmButtonText }}</ml-button>
18
+ </slot>
19
+ </view>
20
+ </view>
21
+ </view>
22
+ </template>
23
+
24
+ <script>
25
+ export default {
26
+ name: 'MlModal',
27
+ props: {
28
+ value: Boolean,
29
+ title: String,
30
+ height: String,
31
+ width: String,
32
+ showHeader: {
33
+ type: Boolean,
34
+ default: true
35
+ },
36
+ showFooter: Boolean,
37
+ placement: String,
38
+ maskClosable: {
39
+ type: Boolean,
40
+ default: true
41
+ },
42
+ showConfirmButton: Boolean,
43
+ confirmButtonText: {
44
+ type: String,
45
+ default: '确认'
46
+ },
47
+ confirmClosable: Boolean,
48
+ showCancelButton: Boolean,
49
+ cancelButtonText: {
50
+ type: String,
51
+ default: '取消'
52
+ },
53
+ cancelClosable: {
54
+ type: Boolean,
55
+ default: true
56
+ },
57
+ className: String
58
+ },
59
+ data () {
60
+ return {
61
+ visible: false,
62
+ animateTime: null
63
+ }
64
+ },
65
+ computed: {
66
+ bodyStyles () {
67
+ const wSty = this.width ? `width:${this.width};` : ''
68
+ const hSty = this.height ? `height:${this.height};` : ''
69
+ return `${wSty}${hSty}`
70
+ }
71
+ },
72
+ watch: {
73
+ value (val) {
74
+ if (val) {
75
+ this.open()
76
+ } else {
77
+ this.close()
78
+ }
79
+ }
80
+ },
81
+ created () {
82
+ this.$nextTick(() => {
83
+ if (this.value) {
84
+ this.open()
85
+ } else {
86
+ this.close()
87
+ }
88
+ })
89
+ },
90
+ methods: {
91
+ close () {
92
+ clearTimeout(this.animateTime)
93
+ this.visible = false
94
+ this.$emit('input', false)
95
+ this.$emit('hide', {})
96
+ },
97
+ open () {
98
+ clearTimeout(this.animateTime)
99
+ this.visible = true
100
+ this.$emit('show', {})
101
+ this.$emit('input', true)
102
+ },
103
+ tapMaskEvent () {
104
+ if (this.maskClosable) {
105
+ this.close()
106
+ }
107
+ },
108
+ cancelEvent () {
109
+ if (this.cancelClosable) {
110
+ this.close()
111
+ }
112
+ this.$emit('cancel', {})
113
+ },
114
+ confirmEvent () {
115
+ if (this.confirmClosable) {
116
+ this.close()
117
+ }
118
+ this.$emit('confirm', {})
119
+ }
120
+ }
121
+ }
122
+ </script>
123
+
124
+ <style lang="scss">
125
+ .ml-drawer {
126
+ display: none;
127
+ position: fixed;
128
+ top: 0;
129
+ left: 0;
130
+ width: $ml-page-full-width;
131
+ height: 100vh;
132
+ z-index: 999;
133
+ background-color: rgba(0, 0, 0, 0.4);
134
+ // #ifdef H5
135
+ left: 50%;
136
+ transform: translateX(-50%);
137
+ // #endif
138
+ &.is-visible {
139
+ display: block;
140
+ }
141
+ .ml-drawer-warpper {
142
+ position: absolute;
143
+ bottom: 0;
144
+ left: 0;
145
+ padding-bottom: 20rpx;
146
+ background: #fff;
147
+ transition: transform 0.25s ease, transform 0.3s ease;
148
+ }
149
+ .ml-drawer-header {
150
+ display: flex;
151
+ flex-direction: row;
152
+ align-items: center;
153
+ padding: 10rpx 20rpx;
154
+ min-height: 90rpx;
155
+ font-size: $uni-font-size-lg;
156
+ }
157
+ .ml-drawer-header-title {
158
+ text-align: center;
159
+ overflow: hidden;
160
+ text-overflow: ellipsis;
161
+ white-space: nowrap;
162
+ }
163
+ .ml-drawer-body {
164
+ padding: 20rpx;
165
+ overflow: auto;
166
+ height: 500rpx;
167
+ }
168
+ .ml-drawer-footer {
169
+ display: flex;
170
+ flex-direction: row;
171
+ align-items: center;
172
+ padding: 20rpx;
173
+ }
174
+ }
175
+ </style>
@@ -8,7 +8,10 @@
8
8
  <text v-else class="ml-number-input-placeholder">{{ placeholder }}</text>
9
9
  </view>
10
10
  </view>
11
- <view v-else class="ml-number-input" :class="[{'is-right': align === 'right', 'is-border': border, 'is-disabled': disabled, 'is-clear': clearable && inpVal}, className]">
11
+ <view v-else class="ml-number-input" :class="[{'is-right': align === 'right', 'is-border': border, 'is-controls': controls, 'is-disabled': disabled, 'is-clear': clearable && inpVal}, className]">
12
+ <view v-if="controls" class="ml-number-input-minus-btn" @click="minusEvent">
13
+ <ml-icon name="minus" />
14
+ </view>
12
15
  <input
13
16
  class="ml-number-input-inp"
14
17
  v-model="inpVal"
@@ -23,6 +26,9 @@
23
26
  <view v-if="clearable && !disabled && inpVal" class="ml-number-input-clear-icon" @click.stop="clearEvent">
24
27
  <ml-icon name="delete-filling"></ml-icon>
25
28
  </view>
29
+ <view v-if="controls" class="ml-number-input-plus-btn" @click="plusEvent">
30
+ <ml-icon name="add" />
31
+ </view>
26
32
  </view>
27
33
  </template>
28
34
 
@@ -48,6 +54,9 @@ export default {
48
54
  type: Number,
49
55
  default: 12
50
56
  },
57
+ min: [String, Number],
58
+ max: [String, Number],
59
+ controls: Boolean,
51
60
  placeholder: {
52
61
  type: String,
53
62
  default: '请输入'
@@ -78,7 +87,19 @@ export default {
78
87
  computed: {
79
88
  isFromReadonly () {
80
89
  return this.form ? this.form.readonly : false
81
- }
90
+ },
91
+ minNum () {
92
+ if (XEUtils.isNumber(this.min) || this.min) {
93
+ return Number(this.min || 0)
94
+ }
95
+ return null
96
+ },
97
+ maxNum () {
98
+ if (XEUtils.isNumber(this.max) || this.max) {
99
+ return Number(this.max)
100
+ }
101
+ return null
102
+ },
82
103
  },
83
104
  watch: {
84
105
  value (val) {
@@ -116,6 +137,22 @@ export default {
116
137
  }
117
138
  return { status: true, value: numVal }
118
139
  },
140
+ minusEvent () {
141
+ const numVal = XEUtils.toNumber(this.inpVal)
142
+ if (this.minNum === null || (numVal > this.minNum)) {
143
+ this.inpVal = numVal - 1
144
+ this.$emit('input', this.inpVal)
145
+ this.$emit('change', {})
146
+ }
147
+ },
148
+ plusEvent () {
149
+ const numVal = XEUtils.toNumber(this.inpVal)
150
+ if (this.maxNum === null || (numVal < this.maxNum)) {
151
+ this.inpVal = numVal + 1
152
+ this.$emit('input', this.inpVal)
153
+ this.$emit('change', {})
154
+ }
155
+ },
119
156
  blurEvent () {
120
157
  const rest = this.checkValue()
121
158
  this.updateModel = rest.status
@@ -123,11 +160,13 @@ export default {
123
160
  },
124
161
  inputEvent () {
125
162
  this.$emit('input', this.inpVal)
163
+ this.$emit('change', {})
126
164
  },
127
165
  clearEvent () {
128
166
  this.inpVal = ''
129
167
  this.inputEvent()
130
168
  this.$emit('clear', { value: this.inpVal })
169
+ this.$emit('change', {})
131
170
  }
132
171
  }
133
172
  }
@@ -159,13 +198,19 @@ export default {
159
198
  text-align: right;
160
199
  }
161
200
  }
162
- &.is-border {
201
+ &.is-border,
202
+ &.is-controls {
163
203
  .ml-number-input-inp,
164
204
  .ml-number-input-simulate {
165
205
  border: 1px solid #e5e5e5;
166
206
  border-radius: $ml-border-radius;
167
207
  }
168
208
  }
209
+ &.is-controls {
210
+ .ml-number-input-simulate {
211
+ border-radius: 0;
212
+ }
213
+ }
169
214
  .ml-number-input-inp,
170
215
  .ml-number-input-simulate {
171
216
  font-size: $uni-font-size-base;
@@ -187,5 +232,20 @@ export default {
187
232
  color: #c0c4cc;
188
233
  border-radius: 0 $ml-border-radius $ml-border-radius 0;
189
234
  }
235
+ .ml-number-input-minus-btn,
236
+ .ml-number-input-plus-btn {
237
+ display: flex;
238
+ align-items: center;
239
+ justify-content: center;
240
+ width: 80rpx;
241
+ border: 1px solid #e5e5e5;
242
+ font-size: 32rpx;
243
+ }
244
+ .ml-number-input-minus-btn {
245
+ border-right: 0;
246
+ }
247
+ .ml-number-input-plus-btn {
248
+ border-left: 0;
249
+ }
190
250
  }
191
251
  </style>
@@ -16,9 +16,9 @@ export default {
16
16
  className: String
17
17
  },
18
18
  methods: {
19
- tapEvent (e) {
20
- this.$emit('tap', { $event: e })
21
- this.$emit('click', { $event: e })
19
+ tapEvent () {
20
+ this.$emit('tap', {})
21
+ this.$emit('click', {})
22
22
  }
23
23
  }
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.2.36",
3
+ "version": "0.2.38",
4
4
  "description": "码里云小程序组件库",
5
5
  "scripts": {
6
6
  "release": "node script/release.js && npm publish"