mali-applet-ui 0.1.89 → 0.1.90

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.
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <view class="ml-checkbox-button" :class="[className || '', {'is-disabled': disabled}]">
3
- <view class="ml-checkbox-button-item" v-for="(item, index) in options" :class="{'is-disabled': disabled, 'is-active': value.includes(item.value)}" :key="index" @tap="changeEvent(item)">{{ item.label }}</view>
3
+ <view v-if="isAll" class="ml-checkbox-button-item" @tap="changeAllEvent">全部/取消</view>
4
+ <view class="ml-checkbox-button-item" v-for="(item, index) in optionList" :class="{'is-disabled': disabled, 'is-active': value.includes(item.value)}" :key="index" @tap="changeEvent(item)">{{ item.label }}</view>
4
5
  </view>
5
6
  </template>
6
7
 
@@ -11,12 +12,23 @@ export default {
11
12
  virtualHost: true
12
13
  },
13
14
  props: {
14
- value: [Boolean, Number, String],
15
+ value: Array,
16
+ isAll: Boolean,
15
17
  options: Array,
16
18
  disabled: Boolean,
17
19
  className: String
18
20
  },
21
+ computed: {
22
+ optionList () {
23
+ return this.options || []
24
+ }
25
+ },
19
26
  methods: {
27
+ changeAllEvent () {
28
+ const value = this.value.length >= this.optionList.length ? [] : this.optionList.map(option => option.value)
29
+ this.$emit('input', value)
30
+ this.$emit('change', { value })
31
+ },
20
32
  changeEvent (option) {
21
33
  if (this.disabled) {
22
34
  return
@@ -36,15 +48,17 @@ export default {
36
48
  <style lang="scss">
37
49
  .ml-checkbox-button {
38
50
  display: inline-flex;
51
+ flex-wrap: wrap;
39
52
  }
40
53
  .ml-checkbox-button-item {
41
54
  border: 1px solid #e5e5e5;
42
- padding: 0 24rpx;
55
+ padding: 0 32rpx;
43
56
  height: 60rpx;
44
57
  line-height: 60rpx;
45
58
  border-radius: $ml-border-radius;
46
- & + .ml-checkbox-button-item {
47
- margin-left: 20rpx;
59
+ margin: 10rpx 20rpx 10rpx 0;
60
+ &:last-child {
61
+ margin-left: 0;
48
62
  }
49
63
  &.is-active {
50
64
  color: #ffffff;
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <view class="ml-radio-button" :class="[className || '', {'is-disabled': disabled}]">
3
- <view class="ml-radio-button-item" v-for="(item, index) in options" :class="{'is-disabled': disabled, 'is-active': value === item.value}" :key="index" @tap="changeEvent(item)">{{ item.label }}</view>
3
+ <view class="ml-radio-button-item" v-for="(item, index) in optionList" :class="{'is-disabled': disabled, 'is-active': value === item.value}" :key="index" @tap="changeEvent(item)">{{ item.label }}</view>
4
4
  </view>
5
5
  </template>
6
6
 
@@ -12,10 +12,24 @@ export default {
12
12
  },
13
13
  props: {
14
14
  value: [Boolean, Number, String],
15
+ isAll: Boolean,
15
16
  options: Array,
16
17
  disabled: Boolean,
17
18
  className: String
18
19
  },
20
+ computed: {
21
+ optionList () {
22
+ if (this.isAll) {
23
+ return [
24
+ {
25
+ label: '全部',
26
+ value: ''
27
+ }
28
+ ].concat(this.options)
29
+ }
30
+ return this.options || []
31
+ }
32
+ },
19
33
  methods: {
20
34
  changeEvent (option) {
21
35
  if (this.disabled) {
@@ -36,7 +50,7 @@ export default {
36
50
  }
37
51
  .ml-radio-button-item {
38
52
  border: 1px solid #e5e5e5;
39
- padding: 0 24rpx;
53
+ padding: 0 32rpx;
40
54
  height: 60rpx;
41
55
  line-height: 60rpx;
42
56
  border-radius: $ml-border-radius;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.1.89",
3
+ "version": "0.1.90",
4
4
  "description": "码里云小程序组件库",
5
5
  "scripts": {
6
6
  "release": "node script/release.js && npm publish"