mali-applet-ui 0.1.40 → 0.1.42

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.
@@ -13,8 +13,8 @@
13
13
  </view>
14
14
  <view v-if="showConfirmButton || showCancelButton || showFooter" class="ml-drawer-footer">
15
15
  <slot name="footer">
16
- <ml-button v-if="showCancelButton" width="40%" round @click="cancelEvent">{{ cancelButtonText }}</ml-button>
17
- <ml-button v-if="showConfirmButton" status="primary" width="40%" round @click="confirmEvent">{{ confirmButtonText }}</ml-button>
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
18
  </slot>
19
19
  </view>
20
20
  </view>
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <view class="ml-tooltip" :class="[className || '', `placement-${placement || 'bottom'}`]">
3
+ <view class="ml-tooltip-content" @click="toggleVisible">
4
+ <slot></slot>
5
+ </view>
6
+ <ml-tooltip-view v-if="showTip" :title="title" :placement="placement" position="absolute" :top="top" :left="left"></ml-tooltip-view>
7
+ </view>
8
+ </template>
9
+
10
+ <script>
11
+ export default {
12
+ name: 'MlTooltip',
13
+ options: {
14
+ virtualHost: true
15
+ },
16
+ props: {
17
+ value: Boolean,
18
+ title: String,
19
+ placement: String,
20
+ trigger: String,
21
+ className: String
22
+ },
23
+ data () {
24
+ return {
25
+ showTip: false,
26
+ top: 0,
27
+ left: 0
28
+ }
29
+ },
30
+ watch: {
31
+ value (value) {
32
+ this.showTip = value
33
+ }
34
+ },
35
+ created () {
36
+ this.showTip = this.value
37
+ },
38
+ methods: {
39
+ open () {
40
+ this.top = 0
41
+ this.left = 0
42
+ const value = true
43
+ this.showTip = value
44
+ this.$emit('input', value)
45
+ },
46
+ close () {
47
+ const value = false
48
+ this.showTip = value
49
+ this.$emit('input', value)
50
+ },
51
+ toggleVisible () {
52
+ if (!this.trigger || ['tap', 'click'].includes(this.trigger)) {
53
+ if (this.showTip) {
54
+ this.close()
55
+ } else {
56
+ this.open()
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+ </script>
63
+
64
+ <style lang="scss">
65
+ .ml-tooltip {
66
+ position: relative;
67
+ display: inline-block;
68
+ vertical-align: middle;
69
+ .ml-tooltip-content {
70
+ display: inline-block;
71
+ vertical-align: middle;
72
+ }
73
+ }
74
+ </style>
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <view class="ml-tooltip-view" :class="[className || '', `placement-${placement || 'bottom'}`]" :style="tipStyles">
3
+ <view class="ml-tooltip-warpper">
4
+ <view class="ml-tooltip-title">
5
+ <slow name="title">{{ title }}</slow>
6
+ </view>
7
+ <view class="ml-tooltip-arrows">
8
+ <ml-icon v-if="placement === 'bottom'" name="arrow-up-filling" />
9
+ <ml-icon v-else-if="placement === 'top'" name="arrow-down-filling" />
10
+ <ml-icon v-else-if="placement === 'right'" name="arrow-left-filling" />
11
+ <ml-icon v-else-if="placement === 'left'" name="arrow-right-filling" />
12
+ </view>
13
+ </view>
14
+ </view>
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+ name: 'MlTooltipView',
20
+ props: {
21
+ title: String,
22
+ position: String,
23
+ top: String,
24
+ left: String,
25
+ bottom: String,
26
+ right: String,
27
+ placement: String,
28
+ className: String
29
+ },
30
+ computed: {
31
+ tipStyles () {
32
+ const posSys = this.position ? `position: ${this.position};` : ''
33
+ const topSys = this.top ? `top: ${this.top};` : ''
34
+ const bottomSys = this.bottom ? `bottom: ${this.bottom};` : ''
35
+ const leftSys = this.left ? `left: ${this.left};` : ''
36
+ const rightSys = this.right ? `right: ${this.right};` : ''
37
+ return `${posSys}${topSys}${bottomSys}${leftSys}${rightSys}`
38
+ }
39
+ }
40
+ }
41
+ </script>
42
+
43
+ <style lang="scss">
44
+ .ml-tooltip-view {
45
+ z-index: 900;
46
+ .ml-tooltip-warpper {
47
+ position: relative;
48
+ display: inline-block;
49
+ color: #FFFFFF;
50
+ white-space: nowrap;
51
+ padding: $ml-page-interval-margin 24rpx;
52
+ background: rgba(0, 0, 0, 0.85);
53
+ border-radius: $ml-border-radius;
54
+ max-width: 80vw;
55
+ }
56
+ .ml-tooltip-arrows {
57
+ position: absolute;
58
+ color: rgba(0, 0, 0, 0.85);
59
+ font-size: 32rpx;
60
+ }
61
+ &.placement-bottom {
62
+ .ml-tooltip-title {
63
+ top: calc(100% + 20rpx);
64
+ }
65
+ .ml-tooltip-arrows {
66
+ top: -22rpx;
67
+ left: 10rpx;
68
+ }
69
+ }
70
+ &.placement-top {
71
+ .ml-tooltip-title {
72
+ bottom: calc(100% + 20rpx);
73
+ }
74
+ .ml-tooltip-arrows {
75
+ bottom: -22rpx;
76
+ left: 10rpx;
77
+ }
78
+ }
79
+ &.placement-left {
80
+ .ml-tooltip-title {
81
+ top: 0;
82
+ right: calc(100% + 20rpx);
83
+ }
84
+ .ml-tooltip-arrows {
85
+ right: -20rpx;
86
+ top: 10rpx;
87
+ }
88
+ }
89
+ &.placement-right {
90
+ .ml-tooltip-title {
91
+ top: 0;
92
+ left: calc(100% + 20rpx);
93
+ }
94
+ .ml-tooltip-arrows {
95
+ left: -20rpx;
96
+ top: 10rpx;
97
+ }
98
+ }
99
+ }
100
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.1.40",
3
+ "version": "0.1.42",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",
@@ -1,200 +0,0 @@
1
- <template>
2
- <view class="ml-popup" :class="[className || '', `placement-${placement || 'bottom'}`, {'is-visible': visible, 'is-animate': isAnimate}]" @tap="tapMaskEvent">
3
- <view v-if="visible" class="ml-popup-warpper" @tap.stop>
4
- <view v-if="showHeader" class="ml-popup-header">
5
- <slot name="header">
6
- <view v-if="title" class="ml-popup-header-title">{{ title }}</view>
7
- </slot>
8
- </view>
9
- <view class="ml-popup-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-popup-footer">
15
- <slot name="footer">
16
- <ml-button v-if="showCancelButton" width="40%" round @click="cancelEvent">{{ cancelButtonText }}</ml-button>
17
- <ml-button v-if="showConfirmButton" status="primary" width="40%" round @click="confirmEvent">{{ confirmButtonText }}</ml-button>
18
- </slot>
19
- </view>
20
- </view>
21
- </view>
22
- </template>
23
-
24
- <script>
25
- export default {
26
- name: 'MlPopup',
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
- placement: String,
38
- maskClosable: Boolean,
39
- showConfirmButton: Boolean,
40
- confirmButtonText: {
41
- type: String,
42
- default: '确认'
43
- },
44
- confirmClosable: Boolean,
45
- showCancelButton: Boolean,
46
- cancelButtonText: {
47
- type: String,
48
- default: '取消'
49
- },
50
- cancelClosable: {
51
- type: Boolean,
52
- default: true
53
- },
54
- className: String
55
- },
56
- data () {
57
- return {
58
- visible: false,
59
- isAnimate: false,
60
- animateTime: null
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
- clearTimeout(this.animateTime)
91
- this.isAnimate = true
92
- this.isAnimate = false
93
- this.animateTime = setTimeout(() => {
94
- this.visible = false
95
- this.$emit('input', false)
96
- this.$emit('hide', {})
97
- }, 300)
98
- },
99
- open () {
100
- clearTimeout(this.animateTime)
101
- this.isAnimate = false
102
- this.visible = true
103
- this.animateTime = setTimeout(() => {
104
- this.isAnimate = true
105
- this.$emit('show', {})
106
- }, 20)
107
- this.$emit('input', true)
108
- },
109
- tapMaskEvent () {
110
- if (this.maskClosable) {
111
- this.close()
112
- }
113
- },
114
- cancelEvent () {
115
- if (this.cancelClosable) {
116
- this.close()
117
- }
118
- this.$emit('cancel', {})
119
- },
120
- confirmEvent () {
121
- if (this.confirmClosable) {
122
- this.close()
123
- }
124
- this.$emit('confirm', {})
125
- }
126
- }
127
- }
128
- </script>
129
-
130
- <style lang="scss">
131
- .ml-popup {
132
- display: none;
133
- position: fixed;
134
- top: 0;
135
- left: 0;
136
- width: $ml-page-full-width;
137
- height: 100vh;
138
- z-index: 999;
139
- background-color: rgba(0, 0, 0, 0.4);
140
- // #ifdef H5
141
- left: 50%;
142
- transform: translateX(-50%);
143
- // #endif
144
- &.is-visible {
145
- display: block;
146
- }
147
- &.placement-left {
148
- &.is-animate {
149
- .ml-popup-warpper {
150
- transform: translateX(0);
151
- }
152
- }
153
- .ml-popup-warpper {
154
- height: 100%;
155
- transform: translateX(-100%);
156
- }
157
- }
158
- &.placement-bottom {
159
- &.is-animate {
160
- .ml-popup-warpper {
161
- transform: translateY(0);
162
- }
163
- }
164
- .ml-popup-warpper {
165
- width: 100%;
166
- transform: translateY(100%);
167
- }
168
- }
169
- }
170
- .ml-popup-warpper {
171
- position: absolute;
172
- bottom: 0;
173
- left: 0;
174
- padding-bottom: 20rpx;
175
- background: #fff;
176
- transition: transform 0.25s ease, transform 0.3s ease;
177
- }
178
- .ml-popup-header {
179
- padding: 10rpx 20rpx;
180
- }
181
- .ml-popup-header-title {
182
- text-align: center;
183
- height: 70rpx;
184
- line-height: 70rpx;
185
- font-size: $uni-font-size-base;
186
- overflow: hidden;
187
- text-overflow: ellipsis;
188
- white-space: nowrap;
189
- }
190
- .ml-popup-body {
191
- padding: 20rpx;
192
- overflow: auto;
193
- height: 500rpx;
194
- }
195
- .ml-popup-footer {
196
- display: flex;
197
- flex-direction: row;
198
- padding: 20rpx;
199
- }
200
- </style>