uview-pro 0.0.1

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.
Files changed (149) hide show
  1. package/changelog.md +6 -0
  2. package/components/u-action-sheet/u-action-sheet.vue +205 -0
  3. package/components/u-alert-tips/u-alert-tips.vue +241 -0
  4. package/components/u-avatar/u-avatar.vue +220 -0
  5. package/components/u-avatar-cropper/u-avatar-cropper.vue +329 -0
  6. package/components/u-avatar-cropper/weCropper.d.ts +54 -0
  7. package/components/u-avatar-cropper/weCropper.js +1267 -0
  8. package/components/u-avatar-cropper/weCropper.ts +1254 -0
  9. package/components/u-back-top/u-back-top.vue +156 -0
  10. package/components/u-badge/u-badge.vue +189 -0
  11. package/components/u-button/u-button.vue +562 -0
  12. package/components/u-calendar/u-calendar.vue +725 -0
  13. package/components/u-car-keyboard/u-car-keyboard.vue +236 -0
  14. package/components/u-card/u-card.vue +240 -0
  15. package/components/u-cell-group/u-cell-group.vue +56 -0
  16. package/components/u-cell-item/u-cell-item.vue +245 -0
  17. package/components/u-checkbox/u-checkbox.vue +310 -0
  18. package/components/u-checkbox-group/u-checkbox-group.vue +134 -0
  19. package/components/u-circle-progress/u-circle-progress.vue +210 -0
  20. package/components/u-col/u-col.vue +135 -0
  21. package/components/u-collapse/u-collapse.vue +82 -0
  22. package/components/u-collapse-item/u-collapse-item.vue +190 -0
  23. package/components/u-column-notice/u-column-notice.vue +264 -0
  24. package/components/u-count-down/u-count-down.vue +333 -0
  25. package/components/u-count-to/u-count-to.vue +297 -0
  26. package/components/u-divider/u-divider.vue +141 -0
  27. package/components/u-dropdown/u-dropdown.vue +311 -0
  28. package/components/u-dropdown-item/u-dropdown-item.vue +135 -0
  29. package/components/u-empty/u-empty.vue +111 -0
  30. package/components/u-field/u-field.vue +469 -0
  31. package/components/u-form/u-form.vue +162 -0
  32. package/components/u-form-item/u-form-item.vue +476 -0
  33. package/components/u-full-screen/u-full-screen.vue +80 -0
  34. package/components/u-gap/u-gap.vue +48 -0
  35. package/components/u-grid/u-grid.vue +101 -0
  36. package/components/u-grid-item/u-grid-item.vue +136 -0
  37. package/components/u-icon/u-icon.vue +389 -0
  38. package/components/u-image/types.ts +48 -0
  39. package/components/u-image/u-image.vue +218 -0
  40. package/components/u-index-anchor/u-index-anchor.vue +101 -0
  41. package/components/u-index-list/u-index-list.vue +376 -0
  42. package/components/u-input/u-input.vue +462 -0
  43. package/components/u-keyboard/u-keyboard.vue +188 -0
  44. package/components/u-lazy-load/u-lazy-load.vue +288 -0
  45. package/components/u-line/u-line.vue +71 -0
  46. package/components/u-line-progress/u-line-progress.vue +128 -0
  47. package/components/u-link/u-link.vue +87 -0
  48. package/components/u-loading/u-loading.vue +111 -0
  49. package/components/u-loadmore/u-loadmore.vue +205 -0
  50. package/components/u-mask/u-mask.vue +137 -0
  51. package/components/u-message-input/u-message-input.vue +315 -0
  52. package/components/u-modal/u-modal.vue +284 -0
  53. package/components/u-navbar/u-navbar.vue +314 -0
  54. package/components/u-no-network/image.ts +2 -0
  55. package/components/u-no-network/u-no-network.vue +311 -0
  56. package/components/u-notice-bar/u-notice-bar.vue +274 -0
  57. package/components/u-number-box/u-number-box.vue +344 -0
  58. package/components/u-number-keyboard/u-number-keyboard.vue +170 -0
  59. package/components/u-parse/libs/CssHandler.js +100 -0
  60. package/components/u-parse/libs/MpHtmlParser.js +580 -0
  61. package/components/u-parse/libs/config.js +80 -0
  62. package/components/u-parse/libs/handler.wxs +22 -0
  63. package/components/u-parse/libs/trees.vue +505 -0
  64. package/components/u-parse/u-parse.vue +645 -0
  65. package/components/u-picker/u-picker.vue +808 -0
  66. package/components/u-popup/u-popup.vue +404 -0
  67. package/components/u-radio/u-radio.vue +272 -0
  68. package/components/u-radio-group/u-radio-group.vue +116 -0
  69. package/components/u-rate/u-rate.vue +349 -0
  70. package/components/u-read-more/u-read-more.vue +199 -0
  71. package/components/u-row/u-row.vue +95 -0
  72. package/components/u-row-notice/u-row-notice.vue +273 -0
  73. package/components/u-search/u-search.vue +298 -0
  74. package/components/u-section/u-section.vue +175 -0
  75. package/components/u-select/u-select.vue +387 -0
  76. package/components/u-skeleton/u-skeleton.vue +230 -0
  77. package/components/u-slider/u-slider.vue +293 -0
  78. package/components/u-steps/u-steps.vue +200 -0
  79. package/components/u-sticky/u-sticky.vue +189 -0
  80. package/components/u-subsection/u-subsection.vue +388 -0
  81. package/components/u-swipe-action/u-swipe-action.vue +289 -0
  82. package/components/u-swiper/u-swiper.vue +305 -0
  83. package/components/u-switch/u-switch.vue +146 -0
  84. package/components/u-tabbar/u-tabbar.vue +347 -0
  85. package/components/u-table/u-table.vue +104 -0
  86. package/components/u-tabs/u-tabs.vue +322 -0
  87. package/components/u-tabs-swiper/u-tabs-swiper.vue +426 -0
  88. package/components/u-tag/u-tag.vue +270 -0
  89. package/components/u-td/u-td.vue +76 -0
  90. package/components/u-th/u-th.vue +70 -0
  91. package/components/u-time-line/u-time-line.vue +39 -0
  92. package/components/u-time-line-item/u-time-line-item.vue +88 -0
  93. package/components/u-toast/types.ts +4 -0
  94. package/components/u-toast/u-toast.vue +238 -0
  95. package/components/u-top-tips/u-top-tips.vue +118 -0
  96. package/components/u-tr/u-tr.vue +24 -0
  97. package/components/u-upload/u-upload.vue +600 -0
  98. package/components/u-verification-code/u-verification-code.vue +194 -0
  99. package/components/u-waterfall/u-waterfall.vue +186 -0
  100. package/iconfont.css +910 -0
  101. package/index.scss +23 -0
  102. package/index.ts +166 -0
  103. package/libs/config/config.ts +26 -0
  104. package/libs/config/zIndex.ts +37 -0
  105. package/libs/css/color.scss +155 -0
  106. package/libs/css/common.scss +176 -0
  107. package/libs/css/style.components.scss +7 -0
  108. package/libs/css/style.h5.scss +8 -0
  109. package/libs/css/style.mp.scss +72 -0
  110. package/libs/css/style.nvue.scss +3 -0
  111. package/libs/css/style.vue.scss +175 -0
  112. package/libs/function/$parent.ts +22 -0
  113. package/libs/function/addUnit.ts +13 -0
  114. package/libs/function/color.ts +37 -0
  115. package/libs/function/colorGradient.ts +123 -0
  116. package/libs/function/debounce.ts +28 -0
  117. package/libs/function/deepClone.ts +39 -0
  118. package/libs/function/deepMerge.ts +34 -0
  119. package/libs/function/getParent.ts +59 -0
  120. package/libs/function/getRect.ts +26 -0
  121. package/libs/function/guid.ts +42 -0
  122. package/libs/function/md5.ts +397 -0
  123. package/libs/function/parent.ts +21 -0
  124. package/libs/function/queryParams.ts +60 -0
  125. package/libs/function/random.ts +16 -0
  126. package/libs/function/randomArray.ts +11 -0
  127. package/libs/function/route.ts +118 -0
  128. package/libs/function/sys.ts +15 -0
  129. package/libs/function/test.ts +229 -0
  130. package/libs/function/throttle.ts +31 -0
  131. package/libs/function/timeFormat.ts +54 -0
  132. package/libs/function/timeFrom.ts +48 -0
  133. package/libs/function/toast.ts +14 -0
  134. package/libs/function/trim.ts +21 -0
  135. package/libs/function/type2icon.ts +36 -0
  136. package/libs/hooks/useEmitter.ts +77 -0
  137. package/libs/hooks/useParent.ts +29 -0
  138. package/libs/request/index.ts +237 -0
  139. package/libs/store/index.ts +88 -0
  140. package/libs/util/area.ts +1 -0
  141. package/libs/util/async-validator.js +1356 -0
  142. package/libs/util/city.ts +1 -0
  143. package/libs/util/emitter.ts +112 -0
  144. package/libs/util/mitt.ts +118 -0
  145. package/libs/util/parent.ts +20 -0
  146. package/libs/util/province.ts +1 -0
  147. package/package.json +98 -0
  148. package/readme.md +165 -0
  149. package/theme.scss +38 -0
@@ -0,0 +1,111 @@
1
+ <template>
2
+ <view v-if="show" class="u-loading" :class="mode === 'circle' ? 'u-loading-circle' : 'u-loading-flower'" :style="[cricleStyle]"> </view>
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { computed } from 'vue';
7
+
8
+ defineOptions({
9
+ name: 'u-loading'
10
+ });
11
+
12
+ /**
13
+ * loading 加载动画
14
+ * @description 此组件为一个小动画,目前用在uView的loadmore加载更多和switch开关等组件的正在加载状态场景。
15
+ * @tutorial https://www.uviewui.com/components/loading.html
16
+ * @property {String} mode 模式选择,见官网说明(默认circle)
17
+ * @property {String} color 动画活动区域的颜色,只对 mode = flower 模式有效(默认#c7c7c7)
18
+ * @property {String|Number} size 加载图标的大小,单位rpx(默认34)
19
+ * @property {Boolean} show 是否显示动画(默认true)
20
+ * @example <u-loading mode="circle"></u-loading>
21
+ */
22
+
23
+ const props = defineProps({
24
+ /**
25
+ * 动画的类型
26
+ * @default 'circle'
27
+ */
28
+ mode: { type: String, default: 'circle' },
29
+ /**
30
+ * 动画的颜色
31
+ * @default '#c7c7c7'
32
+ */
33
+ color: { type: String, default: '#c7c7c7' },
34
+ /**
35
+ * 加载图标的大小,单位rpx
36
+ * @default '34'
37
+ */
38
+ size: { type: [String, Number], default: '34' },
39
+ /**
40
+ * 是否显示动画
41
+ * @default true
42
+ */
43
+ show: { type: Boolean, default: true }
44
+ });
45
+
46
+ /**
47
+ * 加载中圆圈动画的样式
48
+ * @returns {Record<string, any>}
49
+ */
50
+ const cricleStyle = computed(() => {
51
+ let style: Record<string, any> = {};
52
+ style.width = props.size + 'rpx';
53
+ style.height = props.size + 'rpx';
54
+ // 只对圆圈模式生效
55
+ if (props.mode === 'circle') {
56
+ style.borderColor = `#e4e4e4 #e4e4e4 #e4e4e4 ${props.color ? props.color : '#c7c7c7'}`;
57
+ }
58
+ return style;
59
+ });
60
+ </script>
61
+
62
+ <style lang="scss" scoped>
63
+ @import '../../libs/css/style.components.scss';
64
+
65
+ .u-loading-circle {
66
+ /* #ifndef APP-NVUE */
67
+ display: inline-flex;
68
+ /* #endif */
69
+ vertical-align: middle;
70
+ width: 28rpx;
71
+ height: 28rpx;
72
+ background: 0 0;
73
+ border-radius: 50%;
74
+ border: 2px solid;
75
+ border-color: #e5e5e5 #e5e5e5 #e5e5e5 #8f8d8e;
76
+ animation: u-circle 1s linear infinite;
77
+ }
78
+
79
+ .u-loading-flower {
80
+ width: 20px;
81
+ height: 20px;
82
+ display: inline-block;
83
+ vertical-align: middle;
84
+ -webkit-animation: u-flower 1s steps(12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99
+ transform: rotate(1turn);
100
+ }
101
+ }
102
+
103
+ @keyframes u-circle {
104
+ 0% {
105
+ transform: rotate(0);
106
+ }
107
+ 100% {
108
+ transform: rotate(360deg);
109
+ }
110
+ }
111
+ </style>
@@ -0,0 +1,205 @@
1
+ <template>
2
+ <view
3
+ class="u-load-more-wrap"
4
+ :style="{
5
+ backgroundColor: props.bgColor,
6
+ marginBottom: props.marginBottom + 'rpx',
7
+ marginTop: props.marginTop + 'rpx',
8
+ height: $u.addUnit(props.height)
9
+ }"
10
+ >
11
+ <u-line color="#d4d4d4" length="50"></u-line>
12
+ <!-- 加载中和没有更多的状态才显示两边的横线 -->
13
+ <view :class="props.status == 'loadmore' || props.status == 'nomore' ? 'u-more' : ''" class="u-load-more-inner">
14
+ <view class="u-loadmore-icon-wrap">
15
+ <u-loading
16
+ class="u-loadmore-icon"
17
+ :color="props.iconColor"
18
+ :mode="props.iconType == 'circle' ? 'circle' : 'flower'"
19
+ :show="props.status == 'loading' && props.icon"
20
+ ></u-loading>
21
+ </view>
22
+ <!-- 如果没有更多的状态下,显示内容为dot(粗点),加载特定样式 -->
23
+ <view class="u-line-1" :style="loadTextStyle" :class="[props.status == 'nomore' && props.isDot == true ? 'u-dot-text' : 'u-more-text']" @tap="loadMore">
24
+ {{ showText }}
25
+ </view>
26
+ </view>
27
+ <u-line color="#d4d4d4" length="50"></u-line>
28
+ </view>
29
+ </template>
30
+
31
+ <script setup lang="ts">
32
+ import { ref, computed } from 'vue';
33
+ import { $u } from '../..';
34
+
35
+ defineOptions({ name: 'u-loadmore' });
36
+
37
+ /**
38
+ * loadmore 加载更多
39
+ * @description 此组件一般用于标识页面底部加载数据时的状态。
40
+ * @tutorial https://www.uviewui.com/components/loadMore.html
41
+ * @property {String} status 组件状态(默认loadmore)
42
+ * @property {String} bg-color 组件背景颜色,在页面是非白色时会用到(默认#ffffff)
43
+ * @property {Boolean} icon 加载中时是否显示图标(默认true)
44
+ * @property {String} icon-type 加载中时的图标类型(默认circle)
45
+ * @property {String} icon-color icon-type为circle时有效,加载中的动画图标的颜色(默认#b7b7b7)
46
+ * @property {Boolean} is-dot status为nomore时,内容显示为一个"●"(默认false)
47
+ * @property {String} color 字体颜色(默认#606266)
48
+ * @property {String|Number} margin-top 到上一个相邻元素的距离
49
+ * @property {String|Number} margin-bottom 到下一个相邻元素的距离
50
+ * @property {Object} load-text 自定义显示的文字,见上方说明示例
51
+ * @event {Function} loadmore status为loadmore时,点击组件会发出此事件
52
+ * @example <u-loadmore :status="status" icon-type="iconType" load-text="loadText" />
53
+ */
54
+ const props = defineProps({
55
+ // 组件背景色
56
+ bgColor: {
57
+ type: String,
58
+ default: 'transparent'
59
+ },
60
+ // 是否显示加载中的图标
61
+ icon: {
62
+ type: Boolean,
63
+ default: true
64
+ },
65
+ // 字体大小
66
+ fontSize: {
67
+ type: String,
68
+ default: '28'
69
+ },
70
+ // 字体颜色
71
+ color: {
72
+ type: String,
73
+ default: '#606266'
74
+ },
75
+ // 组件状态,loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
76
+ status: {
77
+ type: String,
78
+ default: 'loadmore'
79
+ },
80
+ // 加载中状态的图标,flower-花朵状图标,circle-圆圈状图标
81
+ iconType: {
82
+ type: String,
83
+ default: 'circle'
84
+ },
85
+ // 显示的文字
86
+ loadText: {
87
+ type: Object as () => { loadmore: string; loading: string; nomore: string },
88
+ default: () => ({
89
+ loadmore: '加载更多',
90
+ loading: '正在加载...',
91
+ nomore: '没有更多了'
92
+ })
93
+ },
94
+ // 在“没有更多”状态下,是否显示粗点
95
+ isDot: {
96
+ type: Boolean,
97
+ default: false
98
+ },
99
+ // 加载中显示圆圈动画时,动画的颜色
100
+ iconColor: {
101
+ type: String,
102
+ default: '#b7b7b7'
103
+ },
104
+ // 上边距
105
+ marginTop: {
106
+ type: [String, Number],
107
+ default: 0
108
+ },
109
+ // 下边距
110
+ marginBottom: {
111
+ type: [String, Number],
112
+ default: 0
113
+ },
114
+ // 高度,单位rpx
115
+ height: {
116
+ type: [String, Number],
117
+ default: 'auto'
118
+ }
119
+ });
120
+
121
+ const emits = defineEmits(['loadmore']);
122
+
123
+ // 粗点
124
+ const dotText = ref('●');
125
+
126
+ // 加载的文字显示的样式
127
+ const loadTextStyle = computed(() => {
128
+ return {
129
+ color: props.color,
130
+ fontSize: props.fontSize + 'rpx',
131
+ position: 'relative',
132
+ zIndex: 1,
133
+ backgroundColor: props.bgColor
134
+ // 如果是加载中状态,动画和文字需要距离近一点
135
+ };
136
+ });
137
+
138
+ // 加载中圆圈动画的样式
139
+ const cricleStyle = computed(() => {
140
+ return {
141
+ borderColor: `#e5e5e5 #e5e5e5 #e5e5e5 ${props.iconColor}`
142
+ };
143
+ });
144
+
145
+ // 加载中花朵动画形式
146
+ // 动画由base64图片生成,暂不支持修改
147
+ const flowerStyle = computed(() => {
148
+ return {};
149
+ });
150
+
151
+ // 显示的提示文字
152
+ const showText = computed(() => {
153
+ let text = '';
154
+ if (props.status === 'loadmore') text = props.loadText.loadmore;
155
+ else if (props.status === 'loading') text = props.loadText.loading;
156
+ else if (props.status === 'nomore' && props.isDot) text = dotText.value;
157
+ else text = props.loadText.nomore;
158
+ return text;
159
+ });
160
+
161
+ /**
162
+ * 只有在“加载更多”的状态下才发送点击事件,内容不满一屏时无法触发底部上拉事件,所以需要点击来触发
163
+ */
164
+ function loadMore() {
165
+ if (props.status === 'loadmore') emits('loadmore');
166
+ }
167
+ </script>
168
+
169
+ <style scoped lang="scss">
170
+ @import '../../libs/css/style.components.scss';
171
+ /* #ifdef MP */
172
+ // 在mp.scss中,赋予了u-line为flex: 1,这里需要一个明确的长度,所以重置掉它
173
+ // 在组件内部,把组件名(u-line)当做选择器,在微信开发工具会提示不合法,但不影响使用
174
+ u-line {
175
+ flex: none;
176
+ }
177
+ /* #endif */
178
+ .u-load-more-wrap {
179
+ @include vue-flex;
180
+ justify-content: center;
181
+ align-items: center;
182
+ }
183
+ .u-load-more-inner {
184
+ @include vue-flex;
185
+ justify-content: center;
186
+ align-items: center;
187
+ padding: 0 12rpx;
188
+ }
189
+ .u-more {
190
+ position: relative;
191
+ @include vue-flex;
192
+ justify-content: center;
193
+ }
194
+ .u-dot-text {
195
+ font-size: 28rpx;
196
+ }
197
+ .u-loadmore-icon-wrap {
198
+ margin-right: 8rpx;
199
+ }
200
+ .u-loadmore-icon {
201
+ @include vue-flex;
202
+ align-items: center;
203
+ justify-content: center;
204
+ }
205
+ </style>
@@ -0,0 +1,137 @@
1
+ <template>
2
+ <view
3
+ class="u-mask"
4
+ hover-stop-propagation
5
+ :style="[maskStyle, zoomStyle]"
6
+ @tap="click"
7
+ @touchmove.stop.prevent="() => {}"
8
+ :class="{
9
+ 'u-mask-zoom': props.zoom,
10
+ 'u-mask-show': props.show
11
+ }"
12
+ >
13
+ <slot />
14
+ </view>
15
+ </template>
16
+
17
+ <script setup lang="ts">
18
+ import { ref, computed, watch } from 'vue';
19
+ import { $u } from '../..';
20
+
21
+ defineOptions({ name: 'u-mask' });
22
+
23
+ /**
24
+ * mask 遮罩
25
+ * @description 创建一个遮罩层,用于强调特定的页面元素,并阻止用户对遮罩下层的内容进行操作,一般用于弹窗场景
26
+ * @tutorial https://www.uviewui.com/components/mask.html
27
+ * @property {Boolean} show 是否显示遮罩(默认false)
28
+ * @property {String|Number} z-index z-index 层级(默认1070)
29
+ * @property {Object} custom-style 自定义样式对象,见上方说明
30
+ * @property {String|Number} duration 动画时长,单位毫秒(默认300)
31
+ * @property {Boolean} zoom 是否使用scale对遮罩进行缩放(默认true)
32
+ * @property {Boolean} mask-click-able 遮罩是否可点击,为false时点击不会发送click事件(默认true)
33
+ * @event {Function} click mask-click-able为true时,点击遮罩发送此事件
34
+ * @example <u-mask :show="show" @click="show = false"></u-mask>
35
+ */
36
+ const props = defineProps({
37
+ // 是否显示遮罩
38
+ show: {
39
+ type: Boolean,
40
+ default: false
41
+ },
42
+ // 层级z-index
43
+ zIndex: {
44
+ type: [Number, String],
45
+ default: ''
46
+ },
47
+ // 用户自定义样式
48
+ customStyle: {
49
+ type: Object,
50
+ default: () => ({})
51
+ },
52
+ // 遮罩的动画样式, 是否使用zoom进行scale进行缩放
53
+ zoom: {
54
+ type: Boolean,
55
+ default: true
56
+ },
57
+ // 遮罩的过渡时间,单位为ms
58
+ duration: {
59
+ type: [Number, String],
60
+ default: 300
61
+ },
62
+ // 是否可以通过点击遮罩进行关闭
63
+ maskClickAble: {
64
+ type: Boolean,
65
+ default: true
66
+ }
67
+ });
68
+
69
+ const emit = defineEmits(['click']);
70
+
71
+ // 缩放动画样式
72
+ const zoomStyle = ref<{ transform: string }>({ transform: '' });
73
+ // scale值
74
+ const scale = 'scale(1.2, 1.2)';
75
+
76
+ // 监听遮罩显示状态,动态设置缩放动画
77
+ watch(
78
+ () => props.show,
79
+ n => {
80
+ if (n && props.zoom) {
81
+ // 当展示遮罩的时候,设置scale为1,达到缩小(原来为1.2)的效果
82
+ zoomStyle.value.transform = 'scale(1, 1)';
83
+ } else if (!n && props.zoom) {
84
+ // 当隐藏遮罩的时候,设置scale为1.2,达到放大(因为显示遮罩时已重置为1)的效果
85
+ zoomStyle.value.transform = scale;
86
+ }
87
+ }
88
+ );
89
+
90
+ // 遮罩样式
91
+ const maskStyle = computed(() => {
92
+ let style: Record<string, any> = {};
93
+ style.backgroundColor = 'rgba(0, 0, 0, 0.6)';
94
+ if (props.show) style.zIndex = props.zIndex ? props.zIndex : $u.zIndex.mask;
95
+ else style.zIndex = -1;
96
+ style.transition = `all ${Number(props.duration) / 1000}s ease-in-out`;
97
+ // 判断用户传递的对象是否为空,不为空就进行合并
98
+ if (props.customStyle && Object.keys(props.customStyle).length) {
99
+ style = {
100
+ ...style,
101
+ ...props.customStyle
102
+ };
103
+ }
104
+ return style;
105
+ });
106
+
107
+ /**
108
+ * 遮罩点击事件
109
+ * maskClickAble为true时,点击遮罩发送click事件
110
+ */
111
+ function click() {
112
+ if (!props.maskClickAble) return;
113
+ emit('click');
114
+ }
115
+ </script>
116
+
117
+ <style lang="scss" scoped>
118
+ @import '../../libs/css/style.components.scss';
119
+
120
+ .u-mask {
121
+ position: fixed;
122
+ top: 0;
123
+ left: 0;
124
+ right: 0;
125
+ bottom: 0;
126
+ opacity: 0;
127
+ transition: transform 0.3s;
128
+ }
129
+
130
+ .u-mask-show {
131
+ opacity: 1;
132
+ }
133
+
134
+ .u-mask-zoom {
135
+ transform: scale(1.2, 1.2);
136
+ }
137
+ </style>