mali-applet-ui 0.1.6 → 0.1.7

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.
@@ -4,8 +4,8 @@
4
4
  </view>
5
5
  <view v-else class="ml-amount-input" :class="[{'is-right': align === 'right', 'is-border': border}, className]">
6
6
  <view v-if="showTip" class="ml-amount-tip">
7
- <text>首位:</text>
8
- <text>{{ firstNumLabel }}</text>
7
+ <view>首位:</view>
8
+ <view class="ml-amount-tip-label">{{ firstNumLabel }}</view>
9
9
  </view>
10
10
  <input
11
11
  v-model="inpVal"
@@ -30,7 +30,7 @@ export default {
30
30
  virtualHost: true
31
31
  },
32
32
  props: {
33
- value: String,
33
+ value: [String, Number],
34
34
  align: String,
35
35
  border: Boolean,
36
36
  min: {
@@ -39,7 +39,7 @@ export default {
39
39
  },
40
40
  max: {
41
41
  type: [Number, String],
42
- default: 9999999999999
42
+ default: 9999999999
43
43
  },
44
44
  maxLength: {
45
45
  type: Number,
@@ -124,7 +124,10 @@ export default {
124
124
  },
125
125
  watch: {
126
126
  value (val) {
127
- this.inpVal = val
127
+ if (!this.updateModel) {
128
+ this.inpVal = val
129
+ }
130
+ this.updateModel = false
128
131
  },
129
132
  min () {
130
133
  this.checkValue()
@@ -134,14 +137,14 @@ export default {
134
137
  }
135
138
  },
136
139
  created () {
137
- this.updateValue()
140
+ this.updateValue(this.inpVal)
138
141
  },
139
142
  methods: {
140
- updateValue () {
141
- this.inpVal = this.value ? XEUtils.toFixed(XEUtils.toNumber(this.value), 2) : ''
143
+ updateValue (value) {
144
+ this.inpVal = value === '' || XEUtils.eqNull(value) ? '' : XEUtils.toFixed(XEUtils.toNumber(value), 2)
142
145
  },
143
146
  checkValue () {
144
- const numVal = XEUtils.toNumber(this.value)
147
+ const numVal = XEUtils.toNumber(this.inpVal)
145
148
  if (this.minNum !== null && (numVal < this.minNum)) {
146
149
  this.$emit('input', this.minNum)
147
150
  return { status: false, value: this.minNum }
@@ -155,12 +158,15 @@ export default {
155
158
  this.$emit('input', val)
156
159
  return { status: false, value: val }
157
160
  }
158
- return { status: true, value: 0 }
161
+ return { status: true, value: numVal }
159
162
  },
160
163
  blurEvent () {
161
- this.checkValue()
162
- this.updateValue()
163
- this.$emit('blur')
164
+ const rest = this.checkValue()
165
+ this.updateModel = rest.status
166
+ this.$nextTick(() => {
167
+ this.updateValue(rest.value)
168
+ })
169
+ this.$emit('blur', { value: this.inpVal })
164
170
  },
165
171
  inputEvent () {
166
172
  const value = this.inpVal
@@ -186,10 +192,16 @@ export default {
186
192
  }
187
193
  }
188
194
  .ml-amount-tip {
195
+ display: flex;
196
+ flex-direction: row;
189
197
  position: absolute;
190
198
  top: -60rpx;
191
199
  right: 10rpx;
192
200
  z-index: 1;
201
+ .ml-amount-tip-label {
202
+ min-width: 60rpx;
203
+ text-align: right;
204
+ }
193
205
  }
194
206
  .ml-amount-input-inp {
195
207
  font-size: $uni-font-size-base;
@@ -10,6 +10,7 @@
10
10
  <view class="ml-form-item-content-warpper">
11
11
  <slot>
12
12
  <ml-input v-if="matchComponent('MlInput')" :value="itemValue" border @change="modelEvent"></ml-input>
13
+ <ml-number-input v-if="matchComponent('MlNumberInput')" :value="itemValue" border @change="modelEvent"></ml-number-input>
13
14
  <ml-date-picker v-else-if="matchComponent('MlDatePicker')" :value="itemValue" border @change="modelEvent"></ml-date-picker>
14
15
  <ml-select-picker v-else-if="matchComponent('MlSelectPicker')" :value="itemValue" :options="renderOpts.options" border @change="modelEvent"></ml-select-picker>
15
16
  <ml-textarea v-else-if="matchComponent('MlTextarea')" :value="itemValue" :rows="renderOpts.rows || 3" :showVoice="renderOpts.showVoice || true" border @change="modelEvent"></ml-textarea>
@@ -2,7 +2,7 @@
2
2
  <view v-if="isFromReadonly" class="ml-input is-readonly">
3
3
  <view class="ml-input-readonly-content">{{ inpVal }}</view>
4
4
  </view>
5
- <view v-else class="ml-input" :class="[className || '', {'is-right': align === 'right', 'is-border': border, 'is-prefix': prefixIcon || type === 'search', 'is-suffix': suffixIcon, 'is-disabled': disabled}]">
5
+ <view v-else class="ml-input" :class="[className || '', {'is-right': align === 'right', 'is-border': border, 'is-prefix': prefixIcon || type === 'search', 'is-suffix': suffixIcon, 'is-disabled': disabled, 'is-clear': clearable && inpVal}]">
6
6
  <view v-if="prefixIcon || type === 'search'" class="ml-input-prefix-icon">
7
7
  <ml-icon v-if="prefixIcon" :className="prefixIcon"></ml-icon>
8
8
  <ml-icon v-else name="search"></ml-icon>
@@ -14,8 +14,12 @@
14
14
  autocomplete="off"
15
15
  :placeholder="placeholder"
16
16
  :maxlength="maxlength"
17
- @input="inputEvent"
17
+ @input="inputEvent"
18
+ @blur="blurEvent"
18
19
  @confirm="confirmEvent"/>
20
+ <view v-if="clearable && inpVal" class="ml-input-clear-icon" @click.stop="clearEvent">
21
+ <ml-icon name="delete-filling"></ml-icon>
22
+ </view>
19
23
  <view v-if="suffixIcon" class="ml-input-suffix-icon">
20
24
  <ml-icon :className="suffixIcon"></ml-icon>
21
25
  </view>
@@ -36,13 +40,14 @@ export default {
36
40
  disabled: Boolean,
37
41
  prefixIcon: String,
38
42
  suffixIcon: String,
43
+ clearable: Boolean,
39
44
  placeholder: {
40
45
  type: String,
41
46
  default: '请输入'
42
47
  },
43
48
  maxlength: {
44
- type: String,
45
- default: '50'
49
+ type: [String, Number],
50
+ default: 30
46
51
  },
47
52
  className: String
48
53
  },
@@ -76,9 +81,17 @@ export default {
76
81
  this.$emit('input', value)
77
82
  this.$emit('change', { value })
78
83
  },
84
+ blurEvent () {
85
+ this.$emit('blur', { value: this.inpVal })
86
+ },
79
87
  confirmEvent () {
80
88
  const value = this.inpVal
81
89
  this.$emit('confirm', { value })
90
+ },
91
+ clearEvent () {
92
+ this.inpVal = ''
93
+ this.inputEvent()
94
+ this.$emit('clear', { value: this.inpVal })
82
95
  }
83
96
  }
84
97
  }
@@ -98,6 +111,16 @@ export default {
98
111
  width: 100%;
99
112
  font-size: $uni-font-size-base;
100
113
  }
114
+ .ml-input-clear-icon {
115
+ width: 60rpx;
116
+ display: flex;
117
+ flex-shrink: 0;
118
+ align-items: center;
119
+ justify-content: center;
120
+ background: #fff;
121
+ color: #c0c4cc;
122
+ border-radius: 0 10rpx 10rpx 0;
123
+ }
101
124
  .ml-input-prefix-icon,
102
125
  .ml-input-suffix-icon {
103
126
  min-width: 70rpx;
@@ -123,6 +146,10 @@ export default {
123
146
  &.is-prefix,
124
147
  &.is-suffix,
125
148
  &.is-border {
149
+ .ml-input-clear-icon {
150
+ border: 1px solid #e5e5e5;
151
+ border-left: 0;
152
+ }
126
153
  .ml-input-inp {
127
154
  border: 1px solid #e5e5e5;
128
155
  border-radius: 10rpx;
@@ -138,6 +165,10 @@ export default {
138
165
  }
139
166
  }
140
167
  &.is-suffix {
168
+ .ml-input-clear-icon {
169
+ border-radius: 0;
170
+ border-right: 0;
171
+ }
141
172
  .ml-input-suffix-icon {
142
173
  border-radius: 0 10rpx 10rpx 0;
143
174
  }
@@ -146,6 +177,12 @@ export default {
146
177
  border-radius: 10rpx 0 0 10rpx;
147
178
  }
148
179
  }
180
+ &.is-clear {
181
+ .ml-input-inp {
182
+ padding-right: 0;
183
+ border-right: 0;
184
+ }
185
+ }
149
186
  &.is-prefix.is-suffix {
150
187
  .ml-input-inp {
151
188
  border-radius: 0;
@@ -8,17 +8,20 @@
8
8
  :placeholder="placeholder"
9
9
  :maxlength="maxLength"
10
10
  :disabled="disabled"
11
+ @blur="blurEvent"
11
12
  @input="inputEvent" />
12
13
  </template>
13
14
 
14
15
  <script>
16
+ import XEUtils from 'xe-utils'
17
+
15
18
  export default {
16
19
  name: 'MlNumberInput',
17
20
  options: {
18
21
  virtualHost: true
19
22
  },
20
23
  props: {
21
- value: String,
24
+ value: [String, Number],
22
25
  align: String,
23
26
  border: Boolean,
24
27
  type: String,
@@ -43,13 +46,29 @@ export default {
43
46
  },
44
47
  watch: {
45
48
  value (val) {
46
- this.inpVal = val
49
+ if (!this.updateModel) {
50
+ this.inpVal = val
51
+ }
52
+ this.updateModel = false
47
53
  }
48
54
  },
49
55
  created () {
50
56
  this.inpVal = this.value
51
57
  },
52
58
  methods: {
59
+ checkValue () {
60
+ const numVal = XEUtils.toNumber(this.inpVal)
61
+ if (`${numVal}` !== `${this.value}`) {
62
+ this.$emit('input', numVal)
63
+ return { status: false, value: numVal }
64
+ }
65
+ return { status: true, value: numVal }
66
+ },
67
+ blurEvent () {
68
+ const rest = this.checkValue()
69
+ this.updateModel = rest.status
70
+ this.$emit('blur', { value: this.inpVal })
71
+ },
53
72
  inputEvent () {
54
73
  this.$emit('input', this.inpVal)
55
74
  }
@@ -146,7 +146,7 @@ export default {
146
146
  width: 100%;
147
147
  padding-bottom: 20rpx;
148
148
  transform: translateY(100%);
149
- transition: transform 0.3s ease, transform 0.3s ease;
149
+ transition: transform 0.25s ease, transform 0.3s ease;
150
150
  background: #fff;
151
151
  }
152
152
  .ml-popup-header-title {
@@ -3,12 +3,15 @@
3
3
  <view class="ml-select-picker-readonly-content">{{ selectLabel }}</view>
4
4
  </view>
5
5
  <picker v-else class="ml-select-picker" :style="{width: width || '100%'}" :range="optionList" :range-key="optLabelField" @change="changeEvent">
6
- <view class="ml-select-picker-warpper" :class="[className || '', {'is-border': border}]">
6
+ <view class="ml-select-picker-warpper" :class="[className || '', {'is-border': border, 'is-clear': value !== null}]">
7
7
  <view class="ml-select-picker-text">
8
8
  <text v-if="value !== null">{{ selectLabel }}</text>
9
9
  <text v-else class="picker-placeholder">{{ placeholder }}</text>
10
10
  </view>
11
- <view class="ml-select-picker-icon">
11
+ <view v-if="clearable && value !== null" class="ml-select-clear-icon" @click.stop="clearEvent">
12
+ <ml-icon name="delete-filling"></ml-icon>
13
+ </view>
14
+ <view v-else class="ml-select-picker-icon">
12
15
  <ml-icon name="arrow-down" />
13
16
  </view>
14
17
  </view>
@@ -28,6 +31,7 @@ export default {
28
31
  type: String,
29
32
  default: '请选择'
30
33
  },
34
+ clearable: Boolean,
31
35
  options: Array,
32
36
  optionProps: Object,
33
37
  width: String,
@@ -83,6 +87,12 @@ export default {
83
87
  }
84
88
  this.$emit('input', value)
85
89
  this.$emit('change', { value, option: item })
90
+ },
91
+ clearEvent () {
92
+ const value = null
93
+ this.$emit('input', value)
94
+ this.$emit('change', { value, option: null })
95
+ this.$emit('clear', { value })
86
96
  }
87
97
  }
88
98
  }
@@ -109,11 +119,12 @@ export default {
109
119
  display: flex;
110
120
  flex-direction: row;
111
121
  align-items: center;
112
- padding: 0 10rpx;
122
+ padding: 0 20rpx;
113
123
  height: 70rpx;
114
124
  border-radius: 10rpx;
115
125
  &.is-border {
116
126
  border: 1px solid #e5e5e5;
127
+ background: #fff;
117
128
  }
118
129
  }
119
130
  .ml-select-picker-text {
@@ -123,8 +134,22 @@ export default {
123
134
  text-overflow: ellipsis;
124
135
  white-space: nowrap;
125
136
  }
137
+ .ml-select-clear-icon {
138
+ width: 60rpx;
139
+ display: flex;
140
+ flex-shrink: 0;
141
+ align-items: center;
142
+ justify-content: center;
143
+ background: #fff;
144
+ color: #c0c4cc;
145
+ border-radius: 0 10rpx 10rpx 0;
146
+ }
126
147
  .ml-select-picker-icon {
127
- display: inline;
148
+ width: 60rpx;
149
+ display: flex;
150
+ flex-shrink: 0;
151
+ align-items: center;
152
+ justify-content: center;
128
153
  color: #6a6a6a;
129
154
  }
130
155
  </style>
@@ -7,7 +7,7 @@
7
7
  <view v-else>
8
8
  <textarea class="ml-textarea-inp" v-model="inpVal" :rows="rows" :maxlength="maxLength" :placeholder="placeholder" :show-count="false" @input="inputEvent" :style="{color: fontColor, height: `${rows * 30}rpx`}"></textarea>
9
9
  <view v-if="showWordLimit" class="ml-textarea-word-count">
10
- <VoiceInput v-if="showVoice" v-model="inpVal" @input="inputEvent"></VoiceInput>
10
+ <!-- <VoiceInput v-if="showVoice" v-model="inpVal" @input="inputEvent"></VoiceInput> -->
11
11
  <view class="ml-textarea-word-numbers">{{ value ? value.length : 0 }}/{{ maxLength }}</view>
12
12
  </view>
13
13
  </view>
@@ -37,7 +37,7 @@ export default {
37
37
  },
38
38
  maxLength: {
39
39
  type: Number,
40
- default: 250
40
+ default: 200
41
41
  },
42
42
  placeholder: {
43
43
  type: String,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",