mali-applet-ui 0.0.38 → 0.0.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.
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <view class="ml-form" :class="[className || '', {'is-vertical': vertical}]">
3
- <uni-forms ref="uniForm" :modelValue="data" :rules="formRules" :label-position="vertical ? 'top' : 'left'">
2
+ <view class="ml-form" :class="[className || '']">
3
+ <uni-forms :key="fKey" ref="uniForm" :modelValue="data" :rules="formRules" :label-position="vertical ? 'top' : 'left'">
4
4
  <slot></slot>
5
5
  </uni-forms>
6
6
  </view>
@@ -19,10 +19,17 @@ export default {
19
19
  items: Array,
20
20
  rules: Object,
21
21
  vertical: Boolean,
22
+ labelWidth: String,
22
23
  className: String
23
24
  },
25
+ provide() {
26
+ return {
27
+ mlForm: this
28
+ }
29
+ },
24
30
  data () {
25
31
  return {
32
+ fKey: 1
26
33
  }
27
34
  },
28
35
  computed: {
@@ -38,6 +45,11 @@ export default {
38
45
  return rest
39
46
  }
40
47
  },
48
+ created () {
49
+ this.$nextTick(() => {
50
+ this.fKey++
51
+ })
52
+ },
41
53
  methods: {
42
54
  matchComponent (item, name) {
43
55
  return item.itemRender && item.itemRender.name === name
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <view class="ml-form-group" :class="className">
3
+ <slot></slot>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ name: 'MlFormItem',
10
+ options: {
11
+ virtualHost: true
12
+ },
13
+ props: {
14
+ className: String
15
+ }
16
+ }
17
+ </script>
18
+
19
+ <style lang="scss">
20
+ .ml-form-group {
21
+ margin: 10rpx 0;
22
+ padding: 20rpx;
23
+ border-radius: 10rpx;
24
+ background: #ffffff;
25
+ }
26
+ </style>
@@ -1,5 +1,11 @@
1
1
  <template>
2
- <uni-forms-item :class="className" :label="title" :name="field">
2
+ <uni-forms-item
3
+ ref="uniFormItem"
4
+ :class="className"
5
+ :label="title"
6
+ :name="field"
7
+ :label-width="itemLabelWidth"
8
+ :label-position="itemVertical">
3
9
  <slot></slot>
4
10
  </uni-forms-item>
5
11
  </template>
@@ -13,7 +19,52 @@ export default {
13
19
  props: {
14
20
  title: String,
15
21
  field: String,
22
+ vertical: {
23
+ type: Boolean,
24
+ default: null
25
+ },
26
+ labelWidth: String,
16
27
  className: String
28
+ },
29
+ inject: {
30
+ form: {
31
+ from: 'mlForm',
32
+ default: null
33
+ }
34
+ },
35
+ computed: {
36
+ itemVertical () {
37
+ let vertical = this.vertical
38
+ if (!vertical) {
39
+ vertical = this.form ? this.form.vertical : ''
40
+ }
41
+ return vertical ? 'top' : 'left'
42
+ },
43
+ itemLabelWidth () {
44
+ let labelWidth = this.labelWidth
45
+ if (!labelWidth) {
46
+ labelWidth = this.form ? this.form.labelWidth : ''
47
+ }
48
+ if (labelWidth && !isNaN(labelWidth)) {
49
+ labelWidth = `${labelWidth}rpx`
50
+ }
51
+ return labelWidth
52
+ }
53
+ },
54
+ created () {
55
+ this.init()
56
+ },
57
+ watch: {
58
+ itemVertical () {
59
+ this.init()
60
+ }
61
+ },
62
+ methods: {
63
+ init () {
64
+ this.$nextTick(() => {
65
+ this.$refs.uniFormItem.localLabelPos = this.itemVertical
66
+ })
67
+ }
17
68
  }
18
69
  }
19
70
  </script>
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <picker :value="value" class="ml-month-picker" :class="[className || '', {'is-border': border}]" mode="date" fields="month" @change="changeEvent">
3
- <view class="picker-warpper">
4
- <view class="picker-text">{{ value || '请选择' }}</view>
5
- <ml-icon class="picker-icon" name="arrow-down"></ml-icon>
2
+ <picker :value="value" class="ml-month-picker" mode="date" fields="month" @change="changeEvent">
3
+ <view class="ml-month-picker-warpper" :class="[className || '', {'is-border': border}]">
4
+ <view class="ml-month-picker-text">{{ value || '请选择' }}</view>
5
+ <ml-icon class="ml-month-picker-icon" name="arrow-down"></ml-icon>
6
6
  </view>
7
7
  </picker>
8
8
  </template>
@@ -30,34 +30,33 @@ export default {
30
30
 
31
31
  <style lang="scss">
32
32
  .ml-month-picker {
33
- font-size: 14px;
33
+ display: inline-block;
34
+ font-size: $uni-font-size-base;
34
35
  box-sizing: border-box;
35
- border-radius: 4px;
36
- padding: 0 5px;
37
- padding-left: 10px;
36
+ padding: 0;
38
37
  position: relative;
39
- display: flex;
40
38
  user-select: none;
41
39
  flex-direction: row;
42
40
  align-items: center;
43
- height: 35px;
44
- width: 240rpx;
41
+ width: 100%;
45
42
  color: #6a6a6a;
43
+ }
44
+ .ml-month-picker-warpper {
45
+ position: relative;
46
+ display: flex;
47
+ flex-direction: row;
48
+ align-items: center;
49
+ padding: 0 10rpx;
50
+ height: 70rpx;
51
+ border-radius: 10rpx;
46
52
  &.is-border {
47
53
  border: 1px solid #e5e5e5;
48
54
  }
49
- .picker-warpper {
50
- position: relative;
51
- display: flex;
52
- flex-direction: row;
53
- align-items: center;
54
- width: 194rpx;
55
- }
56
- .picker-text {
57
- flex-grow: 1;
58
- }
59
- .picker-icon {
60
- color: #6a6a6a;
61
- }
55
+ }
56
+ .ml-month-picker-text {
57
+ flex-grow: 1;
58
+ }
59
+ .ml-month-picker-icon {
60
+ color: #6a6a6a;
62
61
  }
63
62
  </style>
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <picker class="ml-select-picker" :class="[className || '', {'is-border': border}]" :range="optionList" :range-key="optLabelField" @change="changeEvent">
3
- <view class="ml-select-picker-warpper" :style="{width: width || '160rpx'}">
2
+ <picker class="ml-select-picker" :style="{width: width || '100%'}" :range="optionList" :range-key="optLabelField" @change="changeEvent">
3
+ <view class="ml-select-picker-warpper" :class="[className || '', {'is-border': border}]">
4
4
  <view class="ml-select-picker-text">
5
5
  <text v-if="value !== null">{{ selectName }}</text>
6
6
  <text v-else class="picker-placeholder">{{ placeholder }}</text>
@@ -78,27 +78,28 @@ export default {
78
78
 
79
79
  <style lang="scss">
80
80
  .ml-select-picker {
81
+ display: inline-block;
81
82
  font-size: $uni-font-size-base;
82
83
  box-sizing: border-box;
83
- border-radius: 8rpx;
84
- padding: 0 10rpx;
85
- padding-left: 20rpx;
84
+ padding: 0;
86
85
  position: relative;
87
- display: inline-flex;;
88
86
  user-select: none;
89
87
  flex-direction: row;
90
88
  align-items: center;
91
- height: 70rpx;
89
+ width: 100%;
92
90
  color: #6a6a6a;
93
- &.is-border {
94
- border: 1px solid #e5e5e5;
95
- }
96
91
  }
97
92
  .ml-select-picker-warpper {
98
93
  position: relative;
99
94
  display: flex;
100
95
  flex-direction: row;
101
96
  align-items: center;
97
+ padding: 0 10rpx;
98
+ height: 70rpx;
99
+ border-radius: 10rpx;
100
+ &.is-border {
101
+ border: 1px solid #e5e5e5;
102
+ }
102
103
  }
103
104
  .ml-select-picker-text {
104
105
  flex-grow: 1;
@@ -1,11 +1,11 @@
1
1
  <template>
2
2
  <view class="ml-textarea" :class="[className || '', {'is-border': border}]">
3
- <view v-if="readonly" class="content">{{ inpVal }}</view>
3
+ <view v-if="readonly" class="ml-textarea-content">{{ inpVal }}</view>
4
4
  <view v-else>
5
- <textarea class="textarea" v-model="inpVal" :rows="rows" :maxlength="maxLength" :placeholder="placeholder" @input="inputEvent" :style="{color: fontColor, height: `${rows * 30}rpx`}"></textarea>
6
- <view v-if="showWordLimit" class="word-count">
7
- <VoiceInput v-if="showVoice" class="word-voice" v-model="inpVal" @input="inputEvent"></VoiceInput>
8
- <view class="word-numbers">{{ value ? value.length : 0 }}/{{ maxLength }}</view>
5
+ <textarea class="ml-textarea-inp" v-model="inpVal" :rows="rows" :maxlength="maxLength" :placeholder="placeholder" @input="inputEvent" :style="{color: fontColor, height: `${rows * 30}rpx`}"></textarea>
6
+ <view v-if="showWordLimit" class="ml-textarea-word-count">
7
+ <VoiceInput v-if="showVoice" v-model="inpVal" @input="inputEvent"></VoiceInput>
8
+ <view class="ml-textarea-word-numbers">{{ value ? value.length : 0 }}/{{ maxLength }}</view>
9
9
  </view>
10
10
  </view>
11
11
  </view>
@@ -80,26 +80,27 @@ export default {
80
80
  <style lang="scss">
81
81
  .ml-textarea {
82
82
  font-size: $uni-font-size-base;
83
- padding: 20rpx 10rpx 10rpx 30rpx;
83
+ padding: 20rpx 10rpx 10rpx 20rpx;
84
84
  &.is-border {
85
85
  border: 1px solid #e5e5e5;
86
86
  border-radius: 10rpx;
87
87
  }
88
- & > .content {
88
+ .ml-textarea-content {
89
89
  width: 100%;
90
90
  overflow: auto;
91
91
  word-break: break-all;
92
92
  }
93
- .textarea {
93
+ .ml-textarea-inp {
94
94
  color: rgba(39, 42, 48, 0.4500);
95
95
  height: 280rpx;
96
96
  width: 100%;
97
+ font-size: $uni-font-size-base;
97
98
  }
98
- .word-count {
99
+ .ml-textarea-word-count {
99
100
  padding-top: 10rpx;
100
101
  display: flex;
101
102
  }
102
- .word-numbers {
103
+ .ml-textarea-word-numbers {
103
104
  flex-grow: 1;
104
105
  color: #999999;
105
106
  text-align: right;
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <picker :value="value" class="ml-year-picker" :class="[className || '', {'is-border': border}]" mode="date" fields="year" @change="changeEvent">
3
- <view class="picker-warpper">
4
- <view class="picker-text">{{ value || '请选择' }}</view>
5
- <ml-icon class="picker-icon" name="arrow-down"></ml-icon>
2
+ <picker :value="value" class="ml-year-picker" mode="date" fields="year" @change="changeEvent">
3
+ <view class="ml-year-picker-warpper" :class="[className || '', {'is-border': border}]">
4
+ <view class="ml-year-picker-text">{{ value || '请选择' }}</view>
5
+ <ml-icon class="ml-year-picker-icon" name="arrow-down"></ml-icon>
6
6
  </view>
7
7
  </picker>
8
8
  </template>
@@ -30,34 +30,33 @@ export default {
30
30
 
31
31
  <style lang="scss">
32
32
  .ml-year-picker {
33
- font-size: 14px;
33
+ display: inline-block;
34
+ font-size: $uni-font-size-base;
34
35
  box-sizing: border-box;
35
- border-radius: 4px;
36
- padding: 0 5px;
37
- padding-left: 10px;
36
+ padding: 0;
38
37
  position: relative;
39
- display: flex;
40
38
  user-select: none;
41
39
  flex-direction: row;
42
40
  align-items: center;
43
- height: 35px;
44
- width: 240rpx;
41
+ width: 100%;
45
42
  color: #6a6a6a;
43
+ }
44
+ .ml-year-picker-warpper {
45
+ position: relative;
46
+ display: flex;
47
+ flex-direction: row;
48
+ align-items: center;
49
+ padding: 0 10rpx;
50
+ height: 70rpx;
51
+ border-radius: 10rpx;
46
52
  &.is-border {
47
53
  border: 1px solid #e5e5e5;
48
54
  }
49
- .picker-warpper {
50
- position: relative;
51
- display: flex;
52
- flex-direction: row;
53
- align-items: center;
54
- width: 194rpx;
55
- }
56
- .picker-text {
57
- flex-grow: 1;
58
- }
59
- .picker-icon {
60
- color: #6a6a6a;
61
- }
55
+ }
56
+ .ml-year-picker-text {
57
+ flex-grow: 1;
58
+ }
59
+ .ml-year-picker-icon {
60
+ color: #6a6a6a;
62
61
  }
63
62
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",
@@ -1,33 +0,0 @@
1
- <template>
2
- <view class="ml-fixed-bottom" :class="[className || '']" :style="styles">
3
- <slot></slot>
4
- </view>
5
- </template>
6
-
7
- <script>
8
- export default {
9
- name: 'MlFixedBottom',
10
- options: {
11
- virtualHost: true
12
- },
13
- props: {
14
- bottom: String,
15
- className: String
16
- },
17
- computed: {
18
- styles () {
19
- return this.bottom ? `bottom:${this.bottom};` : ''
20
- }
21
- }
22
- }
23
- </script>
24
-
25
- <style lang="scss">
26
- .ml-fixed-bottom {
27
- display: flex;
28
- flex-direction: row;
29
- position: fixed;
30
- width: 100%;
31
- bottom: 40rpx;
32
- }
33
- </style>