mali-applet-ui 0.2.37 → 0.2.39

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.
package/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  Mali-Applet-UI 码里云小程序组件库
4
4
 
5
+ ## 发布npm
6
+
7
+ ```
8
+ npm run release
9
+ ```
10
+
5
11
  ## 安装
6
12
 
7
13
  ```bash
@@ -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,171 @@
1
+ <template>
2
+ <view class="ml-modal" :class="[className || '', {'is-visible': visible}]" @tap="tapMaskEvent">
3
+ <view v-if="visible" class="ml-modal-warpper" @tap.stop.prevent>
4
+ <view v-if="showHeader" class="ml-modal-header">
5
+ <slot name="header">
6
+ <view v-if="title" class="ml-modal-header-title">{{ title }}</view>
7
+ </slot>
8
+ </view>
9
+ <view class="ml-modal-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-modal-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
+ maskClosable: {
38
+ type: Boolean,
39
+ default: true
40
+ },
41
+ showConfirmButton: Boolean,
42
+ confirmButtonText: {
43
+ type: String,
44
+ default: '确认'
45
+ },
46
+ confirmClosable: Boolean,
47
+ showCancelButton: Boolean,
48
+ cancelButtonText: {
49
+ type: String,
50
+ default: '取消'
51
+ },
52
+ cancelClosable: {
53
+ type: Boolean,
54
+ default: true
55
+ },
56
+ className: String
57
+ },
58
+ data () {
59
+ return {
60
+ visible: false
61
+ }
62
+ },
63
+ computed: {
64
+ bodyStyles () {
65
+ const wSty = this.width ? `width:${this.width};` : ''
66
+ const hSty = this.height ? `height:${this.height};` : ''
67
+ return `${wSty}${hSty}`
68
+ }
69
+ },
70
+ watch: {
71
+ value (val) {
72
+ if (val) {
73
+ this.open()
74
+ } else {
75
+ this.close()
76
+ }
77
+ }
78
+ },
79
+ created () {
80
+ this.$nextTick(() => {
81
+ if (this.value) {
82
+ this.open()
83
+ } else {
84
+ this.close()
85
+ }
86
+ })
87
+ },
88
+ methods: {
89
+ close () {
90
+ this.visible = false
91
+ this.$emit('input', false)
92
+ this.$emit('hide', {})
93
+ },
94
+ open () {
95
+ this.visible = true
96
+ this.$emit('show', {})
97
+ this.$emit('input', true)
98
+ },
99
+ tapMaskEvent () {
100
+ if (this.maskClosable) {
101
+ this.close()
102
+ }
103
+ },
104
+ cancelEvent () {
105
+ if (this.cancelClosable) {
106
+ this.close()
107
+ }
108
+ this.$emit('cancel', {})
109
+ },
110
+ confirmEvent () {
111
+ if (this.confirmClosable) {
112
+ this.close()
113
+ }
114
+ this.$emit('confirm', {})
115
+ }
116
+ }
117
+ }
118
+ </script>
119
+
120
+ <style lang="scss">
121
+ .ml-modal {
122
+ display: none;
123
+ position: fixed;
124
+ top: 0;
125
+ left: 0;
126
+ width: $ml-page-full-width;
127
+ height: 100vh;
128
+ z-index: 999;
129
+ background-color: rgba(0, 0, 0, 0.4);
130
+ // #ifdef H5
131
+ left: 50%;
132
+ transform: translateX(-50%);
133
+ // #endif
134
+ &.is-visible {
135
+ display: block;
136
+ }
137
+ .ml-modal-warpper {
138
+ position: absolute;
139
+ top: 50%;
140
+ left: 50%;
141
+ transform: translate(-50%, -50%);
142
+ background: #fff;
143
+ }
144
+ .ml-modal-header {
145
+ display: flex;
146
+ flex-direction: row;
147
+ align-items: center;
148
+ padding: 10rpx 20rpx;
149
+ min-height: 90rpx;
150
+ font-size: $uni-font-size-lg;
151
+ }
152
+ .ml-modal-header-title {
153
+ text-align: center;
154
+ overflow: hidden;
155
+ text-overflow: ellipsis;
156
+ white-space: nowrap;
157
+ }
158
+ .ml-modal-body {
159
+ padding: 20rpx;
160
+ width: 600rpx;
161
+ overflow: auto;
162
+ max-height: 600rpx;
163
+ }
164
+ .ml-modal-footer {
165
+ display: flex;
166
+ flex-direction: row;
167
+ align-items: center;
168
+ padding: 20rpx;
169
+ }
170
+ }
171
+ </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
 
@@ -50,6 +56,7 @@ export default {
50
56
  },
51
57
  min: [String, Number],
52
58
  max: [String, Number],
59
+ step: [String, Number],
53
60
  controls: Boolean,
54
61
  placeholder: {
55
62
  type: String,
@@ -81,6 +88,24 @@ export default {
81
88
  computed: {
82
89
  isFromReadonly () {
83
90
  return this.form ? this.form.readonly : false
91
+ },
92
+ minNum () {
93
+ if (XEUtils.isNumber(this.min) || this.min) {
94
+ return XEUtils.toNumber(this.min || 0)
95
+ }
96
+ return null
97
+ },
98
+ maxNum () {
99
+ if (XEUtils.isNumber(this.max) || this.max) {
100
+ return XEUtils.toNumber(this.max)
101
+ }
102
+ return null
103
+ },
104
+ stepNum () {
105
+ if (XEUtils.isNumber(this.step) || this.step) {
106
+ return XEUtils.toNumber(this.step) || 1
107
+ }
108
+ return 1
84
109
  }
85
110
  },
86
111
  watch: {
@@ -119,6 +144,22 @@ export default {
119
144
  }
120
145
  return { status: true, value: numVal }
121
146
  },
147
+ minusEvent () {
148
+ const numVal = XEUtils.toNumber(this.inpVal)
149
+ if (this.minNum === null || (numVal > this.minNum)) {
150
+ this.inpVal = numVal - this.stepNum
151
+ this.$emit('input', this.inpVal)
152
+ this.$emit('change', {})
153
+ }
154
+ },
155
+ plusEvent () {
156
+ const numVal = XEUtils.toNumber(this.inpVal)
157
+ if (this.maxNum === null || (numVal < this.maxNum)) {
158
+ this.inpVal = numVal + this.stepNum
159
+ this.$emit('input', this.inpVal)
160
+ this.$emit('change', {})
161
+ }
162
+ },
122
163
  blurEvent () {
123
164
  const rest = this.checkValue()
124
165
  this.updateModel = rest.status
@@ -126,11 +167,13 @@ export default {
126
167
  },
127
168
  inputEvent () {
128
169
  this.$emit('input', this.inpVal)
170
+ this.$emit('change', {})
129
171
  },
130
172
  clearEvent () {
131
173
  this.inpVal = ''
132
174
  this.inputEvent()
133
175
  this.$emit('clear', { value: this.inpVal })
176
+ this.$emit('change', {})
134
177
  }
135
178
  }
136
179
  }
@@ -162,13 +205,19 @@ export default {
162
205
  text-align: right;
163
206
  }
164
207
  }
165
- &.is-border {
208
+ &.is-border,
209
+ &.is-controls {
166
210
  .ml-number-input-inp,
167
211
  .ml-number-input-simulate {
168
212
  border: 1px solid #e5e5e5;
169
213
  border-radius: $ml-border-radius;
170
214
  }
171
215
  }
216
+ &.is-controls {
217
+ .ml-number-input-simulate {
218
+ border-radius: 0;
219
+ }
220
+ }
172
221
  .ml-number-input-inp,
173
222
  .ml-number-input-simulate {
174
223
  font-size: $uni-font-size-base;
@@ -190,5 +239,20 @@ export default {
190
239
  color: #c0c4cc;
191
240
  border-radius: 0 $ml-border-radius $ml-border-radius 0;
192
241
  }
242
+ .ml-number-input-minus-btn,
243
+ .ml-number-input-plus-btn {
244
+ display: flex;
245
+ align-items: center;
246
+ justify-content: center;
247
+ width: 80rpx;
248
+ border: 1px solid #e5e5e5;
249
+ font-size: 32rpx;
250
+ }
251
+ .ml-number-input-minus-btn {
252
+ border-right: 0;
253
+ }
254
+ .ml-number-input-plus-btn {
255
+ border-left: 0;
256
+ }
193
257
  }
194
258
  </style>
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <ml-drawer :value="value" :title="title" :height="height" :maskClosable="maskClosable" :showFooter="showFooter" placement="bottom" cancelClosable confirmClosable showHeader @input="inputEvent">
3
+ <template #header>
4
+ <view class="ml-picker-drawer-header">
5
+ <view class="ml-picker-drawer-title">
6
+ <ml-row>
7
+ <ml-col shrink @click="cancelEvent">
8
+ <view class="ml-picker-drawer-close-btn">
9
+ <ml-icon name="close" />
10
+ </view>
11
+ </ml-col>
12
+ <ml-col align="center">{{ title }}</ml-col>
13
+ <ml-col shrink>
14
+ <view class="ml-picker-drawer-confirm-btn">
15
+ <ml-button type="text" @click="confirmEvent">确定</ml-button>
16
+ </view>
17
+ </ml-col>
18
+ </ml-row>
19
+ </view>
20
+ <view class="ml-picker-drawer-top">
21
+ <slot name="top"></slot>
22
+ </view>
23
+ </view>
24
+ </template>
25
+ <template>
26
+ <slot></slot>
27
+ </template>
28
+ <template #footer>
29
+ <slot name="footer"></slot>
30
+ </template>
31
+ </ml-drawer>
32
+ </template>
33
+
34
+ <script>
35
+ export default {
36
+ name: 'MlPickerDrawer',
37
+ props: {
38
+ value: Boolean,
39
+ title: {
40
+ type: String,
41
+ default: '请选择'
42
+ },
43
+ height: String,
44
+ showFooter: Boolean,
45
+ placement: String,
46
+ maskClosable: {
47
+ type: Boolean,
48
+ default: true
49
+ },
50
+ maskClosable: {
51
+ type: Boolean,
52
+ default: true
53
+ },
54
+ confirmClosable: Boolean,
55
+ cancelClosable: {
56
+ type: Boolean,
57
+ default: true
58
+ },
59
+ className: String
60
+ },
61
+ data () {
62
+ return {
63
+ }
64
+ },
65
+ methods: {
66
+ cancelEvent () {
67
+ if (this.cancelClosable) {
68
+ this.$emit('input', false)
69
+ }
70
+ this.$emit('cancel', {})
71
+ },
72
+ confirmEvent () {
73
+ if (this.confirmClosable) {
74
+ this.$emit('input', false)
75
+ }
76
+ this.$emit('confirm', {})
77
+ },
78
+ inputEvent (value) {
79
+ this.$emit('input', value)
80
+ }
81
+ }
82
+ }
83
+ </script>
84
+
85
+ <style lang="scss">
86
+ .ml-picker-drawer-header {
87
+ display: block;
88
+ width: 100%;
89
+ .ml-picker-drawer-title {
90
+ height: 80rpx;
91
+ line-height: 80rpx;
92
+ }
93
+ .ml-picker-drawer-close-btn {
94
+ width: 80rpx;
95
+ text-align: center;
96
+ }
97
+ .ml-picker-drawer-confirm-btn {
98
+ padding-left: 20rpx;
99
+ }
100
+ }
101
+ </style>
@@ -16,7 +16,7 @@
16
16
  </view>
17
17
  </view>
18
18
 
19
- <ml-drawer v-model="showPopup" title="请选择省/市" height="500rpx" showConfirmButton showCancelButton @confirm="confirmEvent">
19
+ <ml-picker-drawer v-model="showPopup" title="请选择省/市" height="500rpx" showConfirmButton showCancelButton @confirm="confirmEvent">
20
20
  <picker-view v-if="showPicker" :value="selectVals" @change="changeEvent" style="height: 400rpx;text-align: center;">
21
21
  <picker-view-column>
22
22
  <view class="ml-province-city-picker-picker-item" v-for="(item, index) in provinceList" :key="index">{{ item[optLabelField] }}</view>
@@ -25,7 +25,7 @@
25
25
  <view class="ml-province-city-picker-picker-item" v-for="(item, index) in cityList" :key="index">{{ item[optLabelField] }}</view>
26
26
  </picker-view-column>
27
27
  </picker-view>
28
- </ml-drawer>
28
+ </ml-picker-drawer>
29
29
  </view>
30
30
  </template>
31
31
 
@@ -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.37",
3
+ "version": "0.2.39",
4
4
  "description": "码里云小程序组件库",
5
5
  "scripts": {
6
6
  "release": "node script/release.js && npm publish"