mali-applet-ui 1.1.23 → 1.1.25

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.
@@ -0,0 +1,212 @@
1
+ <template>
2
+ <view v-if="isFromReadonly" class="ml-select-picker is-readonly">
3
+ <view class="ml-select-picker-readonly-content">{{ selectLabel }}</view>
4
+ </view>
5
+ <picker v-else class="ml-select-picker" mode="selector" :value="selectIndex" :disabled="disabled" :style="{width: width || '100%'}" :range="optionList" :range-key="optLabelField" @change="changeEvent">
6
+ <view class="ml-select-picker-warpper" :class="[className || '', {'is-border': border, 'is-clear': value !== null}]">
7
+ <view class="ml-select-picker-text">
8
+ <view v-if="value !== null" class="ml-select-picker-label">{{ selectLabel }}</view>
9
+ <view v-else class="ml-select-picker-placeholder">{{ translate(placeholder) }}</view>
10
+ </view>
11
+ <view v-if="clearable && value !== null" class="ml-select-picker-clear-icon" @click.stop="clearEvent">
12
+ <ml-icon name="delete-filling"></ml-icon>
13
+ </view>
14
+ <view v-else class="ml-select-picker-icon">
15
+ <ml-icon name="arrow-right" />
16
+ </view>
17
+ </view>
18
+ </picker>
19
+ </template>
20
+
21
+ <script>
22
+ import XEUtils from 'xe-utils'
23
+ import MaliI18n from '../../../i18n/i18n'
24
+
25
+ export default {
26
+ name: 'MlSelectPicker',
27
+ options: {
28
+ virtualHost: true
29
+ },
30
+ props: {
31
+ value: [Number, String],
32
+ border: Boolean,
33
+ placeholder: {
34
+ type: String,
35
+ default: 'ml.base.pleaseSelect'
36
+ },
37
+ disabled: Boolean,
38
+ clearable: Boolean,
39
+ readonly: Boolean,
40
+ options: Array,
41
+ optionProps: Object,
42
+ width: String,
43
+ isAll: Boolean,
44
+ className: String
45
+ },
46
+ inject: {
47
+ form: {
48
+ from: 'mlForm',
49
+ default: null
50
+ }
51
+ },
52
+ data () {
53
+ return {
54
+ selectIndex: 0
55
+ }
56
+ },
57
+ computed: {
58
+ isFromReadonly () {
59
+ if (this.readonly) {
60
+ return true
61
+ }
62
+ return this.form ? this.form.readonly : false
63
+ },
64
+ optionList () {
65
+ // #ifdef MP-ALIPAY
66
+ if (!this.options || !this.options.length) {
67
+ return [
68
+ {
69
+ [this.optLabelField]: '',
70
+ [this.optValueField]: null
71
+ }
72
+ ]
73
+ }
74
+ // #endif
75
+
76
+ if (this.isAll) {
77
+ return [
78
+ {
79
+ [this.optLabelField]: MaliI18n.t('ml.base.all'),
80
+ [this.optValueField]: ''
81
+ }
82
+ ].concat(this.options.map(item => {
83
+ return {
84
+ ...item,
85
+ [this.optLabelField]: MaliI18n.t(item[this.optLabelField]),
86
+ [this.optValueField]: item[this.optValueField]
87
+ }
88
+ }))
89
+ }
90
+ return this.options.map(item => {
91
+ return {
92
+ ...item,
93
+ [this.optLabelField]: MaliI18n.t(item[this.optLabelField]),
94
+ [this.optValueField]: item[this.optValueField]
95
+ }
96
+ })
97
+ },
98
+ selectLabel () {
99
+ const item = this.optionList.find(item => String(item[this.optValueField]) === String(this.value))
100
+ return MaliI18n.t(XEUtils.toValueString(item ? item[this.optLabelField] : this.value))
101
+ },
102
+ optOptions () {
103
+ return Object.assign({}, this.optionProps)
104
+ },
105
+ optLabelField () {
106
+ return this.optOptions.label || 'label'
107
+ },
108
+ optValueField () {
109
+ return this.optOptions.value || 'value'
110
+ }
111
+ },
112
+ watch: {
113
+ value () {
114
+ this.updateSelectStatus()
115
+ },
116
+ optionList () {
117
+ this.updateSelectStatus()
118
+ }
119
+ },
120
+ created () {
121
+ this.updateSelectStatus()
122
+ },
123
+ methods: {
124
+ translate: MaliI18n.t,
125
+ updateSelectStatus () {
126
+ const index = XEUtils.findIndexOf(this.optionList, item => String(item[this.optValueField]) === String(this.value))
127
+ this.selectIndex = index === -1 ? 0 : index
128
+ },
129
+ changeEvent (e) {
130
+ const index = e.detail.value
131
+ const item = this.optionList[index]
132
+ this.selectIndex = index
133
+ let value = null
134
+ if (item) {
135
+ value = item[this.optValueField]
136
+ }
137
+ this.$emit('input', value)
138
+ if (this.value !== value) {
139
+ this.$emit('change', { value, option: item })
140
+ }
141
+ },
142
+ clearEvent () {
143
+ const value = null
144
+ this.$emit('input', value)
145
+ this.$emit('clear', { value })
146
+ this.$emit('change', { value, option: null })
147
+ }
148
+ }
149
+ }
150
+ </script>
151
+
152
+ <style lang="scss">
153
+ .ml-select-picker {
154
+ display: block;
155
+ font-size: $ml-base-font-size;
156
+ box-sizing: border-box;
157
+ padding: 0;
158
+ position: relative;
159
+ user-select: none;
160
+ flex-direction: row;
161
+ align-items: center;
162
+ width: 100%;
163
+ color: #6a6a6a;
164
+ }
165
+ .ml-select-picker-readonly-content {
166
+ padding: 20rpx;
167
+ }
168
+ .ml-select-picker-warpper {
169
+ position: relative;
170
+ display: flex;
171
+ flex-direction: row;
172
+ align-items: center;
173
+ padding: 0 10rpx;
174
+ height: 70rpx;
175
+ border-radius: $ml-border-radius;
176
+ &.is-border {
177
+ border: 1px solid #e5e5e5;
178
+ background: #fff;
179
+ }
180
+ }
181
+ .ml-select-picker-text {
182
+ flex-grow: 1;
183
+ overflow: hidden;
184
+ .ml-select-picker-label,
185
+ .ml-select-picker-placeholder {
186
+ overflow: hidden;
187
+ text-overflow: ellipsis;
188
+ white-space: nowrap;
189
+ }
190
+ .ml-select-picker-placeholder {
191
+ color: $ml-input-color-placeholder;
192
+ }
193
+ }
194
+ .ml-select-picker-clear-icon {
195
+ width: 34rpx;
196
+ display: flex;
197
+ flex-shrink: 0;
198
+ align-items: center;
199
+ justify-content: center;
200
+ background: #fff;
201
+ color: $ml-input-clear-icon-color;
202
+ font-size: $ml-input-clear-icon-font-size;
203
+ border-radius: 0 $ml-border-radius $ml-border-radius 0;
204
+ }
205
+ .ml-select-picker-icon {
206
+ display: flex;
207
+ flex-shrink: 0;
208
+ align-items: center;
209
+ justify-content: center;
210
+ color: #6a6a6a;
211
+ }
212
+ </style>
@@ -81,6 +81,7 @@ export default {
81
81
  }
82
82
  ].concat(this.options.map(item => {
83
83
  return {
84
+ ...item,
84
85
  [this.optLabelField]: MaliI18n.t(item[this.optLabelField]),
85
86
  [this.optValueField]: item[this.optValueField]
86
87
  }
@@ -88,6 +89,7 @@ export default {
88
89
  }
89
90
  return this.options.map(item => {
90
91
  return {
92
+ ...item,
91
93
  [this.optLabelField]: MaliI18n.t(item[this.optLabelField]),
92
94
  [this.optValueField]: item[this.optValueField]
93
95
  }
@@ -8,7 +8,6 @@
8
8
  <text v-else class="ml-textarea-placeholder">{{ translate(placeholder) }}</text>
9
9
  </view>
10
10
  <view v-if="showWordLimit && !disabled" class="ml-textarea-word-count">
11
- <!-- <VoiceInput v-if="showVoice" v-model="inpVal" @input="inputEvent"></VoiceInput> -->
12
11
  <view class="ml-textarea-word-numbers">{{ value ? value.length : 0 }}/{{ maxLength }}</view>
13
12
  </view>
14
13
  </view>
@@ -27,7 +26,6 @@
27
26
  @blur="blurEvent"
28
27
  :style="{color: fontColor, height: `${rows * 30}rpx`}" />
29
28
  <view v-if="showWordLimit && !disabled" class="ml-textarea-word-count">
30
- <!-- <VoiceInput v-if="showVoice" v-model="inpVal" @input="inputEvent"></VoiceInput> -->
31
29
  <view class="ml-textarea-word-numbers">{{ value ? value.length : 0 }}/{{ maxLength }}</view>
32
30
  </view>
33
31
  </view>
@@ -38,16 +36,12 @@
38
36
  import MaliUtils from '../../../utils'
39
37
  import MaliI18n from '../../../i18n/i18n'
40
38
  import XEUtils from 'xe-utils'
41
- // import VoiceInput from './voice-input.vue'
42
39
 
43
40
  export default {
44
41
  name: 'MlTextarea',
45
42
  options: {
46
43
  virtualHost: true
47
44
  },
48
- // components: {
49
- // VoiceInput
50
- // },
51
45
  props: {
52
46
  value: {
53
47
  type: String,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "1.1.23",
3
+ "version": "1.1.25",
4
4
  "description": "vue2 码里云小程序组件库",
5
5
  "files": [
6
6
  "lib",