stellar-ui-v2 1.40.21 → 1.40.23

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,220 +1,220 @@
1
- <template>
2
- <!-- #ifdef MP-WEIXIN -->
3
- <page-container
4
- v-if="useWxNative"
5
- :show="show"
6
- :duration="duration"
7
- :z-index="zIndex"
8
- :overlay="overlay"
9
- :position="position"
10
- :round="round"
11
- :close-on-slide-down="closeOnSlideDown"
12
- :overlay-style="overlayStyle"
13
- :custom-style="customStyle"
14
- :safe-area-inset-bottom="safeAreaInsetBottom"
15
- @beforeenter="emitEvent('beforeenter', $event)"
16
- @enter="emitEvent('enter', $event)"
17
- @afterenter="emitEvent('afterenter', $event)"
18
- @beforeleave="emitEvent('beforeleave', $event)"
19
- @leave="emitEvent('leave', $event)"
20
- @afterleave="emitEvent('afterleave', $event)"
21
- @clickoverlay="onClickOverlay"
22
- >
23
- <slot></slot>
24
- </page-container>
25
-
26
- <ste-popup
27
- v-else
28
- :show.sync="innerShow"
29
- :duration="duration"
30
- :zIndex="zIndex"
31
- :showMask="overlay"
32
- :position="popupPosition"
33
- :round="round"
34
- :isMaskClick="overlay"
35
- :showClose="false"
36
- @clickMask="onClickOverlay"
37
- @open-after="onPopupOpenAfter"
38
- >
39
- <view class="ste-pate-container-content" :class="{ 'safe-area-bottom': safeAreaInsetBottom && position === 'bottom' }" :style="customStyle">
40
- <slot></slot>
41
- </view>
42
- </ste-popup>
43
- <!-- #endif -->
44
-
45
- <!-- #ifndef MP-WEIXIN -->
46
- <ste-popup
47
- :show.sync="innerShow"
48
- :duration="duration"
49
- :zIndex="zIndex"
50
- :showMask="overlay"
51
- :position="popupPosition"
52
- :round="round"
53
- :isMaskClick="overlay"
54
- :showClose="false"
55
- @clickMask="onClickOverlay"
56
- @open-after="onPopupOpenAfter"
57
- >
58
- <view class="ste-pate-container-content" :class="{ 'safe-area-bottom': safeAreaInsetBottom && position === 'bottom' }" :style="customStyle">
59
- <slot></slot>
60
- </view>
61
- </ste-popup>
62
- <!-- #endif -->
63
- </template>
64
-
65
- <script>
66
- /**
67
- * ste-pate-container 页面容器
68
- * @description 微信小程序下使用原生 page-container,其他平台使用 ste-popup 兼容实现
69
- * @property {Boolean} show 是否显示容器
70
- * @property {Number} duration 动画时长,单位 ms
71
- * @property {Number} zIndex 层级
72
- * @property {Boolean} overlay 是否显示遮罩
73
- * @property {String} position 弹出位置,top/bottom/right/center
74
- * @property {Boolean} round 是否展示圆角
75
- * @property {Boolean} closeOnSlideDown 是否允许下滑关闭(仅微信小程序)
76
- * @property {String} overlayStyle 遮罩层样式(仅微信小程序)
77
- * @property {String} customStyle 容器样式
78
- * @property {Boolean} safeAreaInsetBottom 是否适配底部安全区
79
- */
80
- export default {
81
- group: '基础组件',
82
- title: 'PageContainer 页面容器',
83
- name: 'ste-pate-container',
84
- props: {
85
- show: { type: [Boolean, null], default: false },
86
- duration: { type: [Number, null], default: 300 },
87
- zIndex: { type: [Number, String, null], default: 100 },
88
- overlay: { type: [Boolean, null], default: true },
89
- position: {
90
- type: [String, null],
91
- default: 'bottom',
92
- validator(value) {
93
- return ['top', 'bottom', 'right', 'center'].includes(value);
94
- },
95
- },
96
- round: { type: [Boolean, null], default: false },
97
- closeOnSlideDown: { type: [Boolean, null], default: false },
98
- overlayStyle: { type: [String, null], default: '' },
99
- customStyle: { type: [String, null], default: '' },
100
- safeAreaInsetBottom: { type: [Boolean, null], default: false },
101
- },
102
- data() {
103
- return {
104
- innerShow: this.show,
105
- leaveTimer: null,
106
- useWxNative: false,
107
- };
108
- },
109
- computed: {
110
- popupPosition() {
111
- if (['top', 'bottom', 'right', 'center'].includes(this.position)) {
112
- return this.position;
113
- }
114
- return 'bottom';
115
- },
116
- },
117
- watch: {
118
- show(newVal) {
119
- if (!this.useWxNative) {
120
- if (this.innerShow !== newVal) {
121
- this.innerShow = newVal;
122
- }
123
- this.triggerTransition(newVal);
124
- }
125
- },
126
- innerShow(newVal) {
127
- if (!this.useWxNative && newVal !== this.show) {
128
- this.$emit('update:show', newVal);
129
- }
130
- },
131
- },
132
- beforeDestroy() {
133
- this.clearTimers();
134
- this.releaseWxNativeOwner();
135
- },
136
- created() {
137
- this.initMode();
138
- if (!this.useWxNative && this.show) {
139
- this.triggerTransition(true);
140
- }
141
- },
142
- methods: {
143
- getGlobalScope() {
144
- if (typeof globalThis !== 'undefined') return globalThis;
145
- if (typeof global !== 'undefined') return global;
146
- return {};
147
- },
148
- initMode() {
149
- // #ifdef MP-WEIXIN
150
- const scope = this.getGlobalScope();
151
- if (!scope.__stePateContainerOwnerUid) {
152
- scope.__stePateContainerOwnerUid = this._uid;
153
- this.useWxNative = true;
154
- return;
155
- }
156
- this.useWxNative = scope.__stePateContainerOwnerUid === this._uid;
157
- // #endif
158
- // #ifndef MP-WEIXIN
159
- this.useWxNative = false;
160
- // #endif
161
- },
162
- releaseWxNativeOwner() {
163
- // #ifdef MP-WEIXIN
164
- const scope = this.getGlobalScope();
165
- if (scope.__stePateContainerOwnerUid === this._uid) {
166
- scope.__stePateContainerOwnerUid = null;
167
- }
168
- // #endif
169
- },
170
- emitEvent(eventName, e) {
171
- this.$emit(eventName, e);
172
- },
173
- onClickOverlay(e) {
174
- this.$emit('clickoverlay', e);
175
- },
176
- onPopupOpenAfter(e) {
177
- this.$emit('afterenter', e);
178
- },
179
- open() {
180
- this.$emit('update:show', true);
181
- },
182
- close() {
183
- this.$emit('update:show', false);
184
- },
185
- clearTimers() {
186
- if (this.leaveTimer) {
187
- clearTimeout(this.leaveTimer);
188
- this.leaveTimer = null;
189
- }
190
- },
191
- triggerTransition(show) {
192
- this.clearTimers();
193
- if (show) {
194
- this.$emit('beforeenter');
195
- this.$emit('enter');
196
- return;
197
- }
198
- this.$emit('beforeleave');
199
- this.$emit('leave');
200
- this.leaveTimer = setTimeout(() => {
201
- this.$emit('afterleave');
202
- this.leaveTimer = null;
203
- }, this.duration);
204
- },
205
- },
206
- };
207
- </script>
208
-
209
- <style lang="scss" scoped>
210
- .ste-pate-container-content {
211
- width: 100%;
212
- height: 100%;
213
- }
214
-
215
- .safe-area-bottom {
216
- padding-bottom: constant(safe-area-inset-bottom);
217
- padding-bottom: env(safe-area-inset-bottom);
218
- box-sizing: border-box;
219
- }
220
- </style>
1
+ <template>
2
+ <!-- #ifdef MP-WEIXIN -->
3
+ <page-container
4
+ v-if="useWxNative"
5
+ :show="show"
6
+ :duration="duration"
7
+ :z-index="zIndex"
8
+ :overlay="overlay"
9
+ :position="position"
10
+ :round="round"
11
+ :close-on-slide-down="closeOnSlideDown"
12
+ :overlay-style="overlayStyle"
13
+ :custom-style="customStyle"
14
+ :safe-area-inset-bottom="safeAreaInsetBottom"
15
+ @beforeenter="emitEvent('beforeenter', $event)"
16
+ @enter="emitEvent('enter', $event)"
17
+ @afterenter="emitEvent('afterenter', $event)"
18
+ @beforeleave="emitEvent('beforeleave', $event)"
19
+ @leave="emitEvent('leave', $event)"
20
+ @afterleave="emitEvent('afterleave', $event)"
21
+ @clickoverlay="onClickOverlay"
22
+ >
23
+ <slot></slot>
24
+ </page-container>
25
+
26
+ <ste-popup
27
+ v-else
28
+ :show.sync="innerShow"
29
+ :duration="duration"
30
+ :zIndex="zIndex"
31
+ :showMask="overlay"
32
+ :position="popupPosition"
33
+ :round="round"
34
+ :isMaskClick="overlay"
35
+ :showClose="false"
36
+ @clickMask="onClickOverlay"
37
+ @open-after="onPopupOpenAfter"
38
+ >
39
+ <view class="ste-page-container-content" :class="{ 'safe-area-bottom': safeAreaInsetBottom && position === 'bottom' }" :style="customStyle">
40
+ <slot></slot>
41
+ </view>
42
+ </ste-popup>
43
+ <!-- #endif -->
44
+
45
+ <!-- #ifndef MP-WEIXIN -->
46
+ <ste-popup
47
+ :show.sync="innerShow"
48
+ :duration="duration"
49
+ :zIndex="zIndex"
50
+ :showMask="overlay"
51
+ :position="popupPosition"
52
+ :round="round"
53
+ :isMaskClick="overlay"
54
+ :showClose="false"
55
+ @clickMask="onClickOverlay"
56
+ @open-after="onPopupOpenAfter"
57
+ >
58
+ <view class="ste-page-container-content" :class="{ 'safe-area-bottom': safeAreaInsetBottom && position === 'bottom' }" :style="customStyle">
59
+ <slot></slot>
60
+ </view>
61
+ </ste-popup>
62
+ <!-- #endif -->
63
+ </template>
64
+
65
+ <script>
66
+ /**
67
+ * ste-page-container 页面容器
68
+ * @description 微信小程序下使用原生 page-container,其他平台使用 ste-popup 兼容实现
69
+ * @property {Boolean} show 是否显示容器
70
+ * @property {Number} duration 动画时长,单位 ms
71
+ * @property {Number} zIndex 层级
72
+ * @property {Boolean} overlay 是否显示遮罩
73
+ * @property {String} position 弹出位置,top/bottom/right/center
74
+ * @property {Boolean} round 是否展示圆角
75
+ * @property {Boolean} closeOnSlideDown 是否允许下滑关闭(仅微信小程序)
76
+ * @property {String} overlayStyle 遮罩层样式(仅微信小程序)
77
+ * @property {String} customStyle 容器样式
78
+ * @property {Boolean} safeAreaInsetBottom 是否适配底部安全区
79
+ */
80
+ export default {
81
+ group: '基础组件',
82
+ title: 'PageContainer 页面容器',
83
+ name: 'ste-page-container',
84
+ props: {
85
+ show: { type: Boolean, default: false },
86
+ duration: { type: Number, default: 300 },
87
+ zIndex: { type: [Number, String], default: 100 },
88
+ overlay: { type: Boolean, default: true },
89
+ position: {
90
+ type: String,
91
+ default: 'bottom',
92
+ validator(value) {
93
+ return ['top', 'bottom', 'right', 'center'].includes(value);
94
+ },
95
+ },
96
+ round: { type: Boolean, default: false },
97
+ closeOnSlideDown: { type: Boolean, default: false },
98
+ overlayStyle: { type: String, default: '' },
99
+ customStyle: { type: String, default: '' },
100
+ safeAreaInsetBottom: { type: Boolean, default: false },
101
+ },
102
+ data() {
103
+ return {
104
+ innerShow: this.show,
105
+ leaveTimer: null,
106
+ useWxNative: false,
107
+ };
108
+ },
109
+ computed: {
110
+ popupPosition() {
111
+ if (['top', 'bottom', 'right', 'center'].includes(this.position)) {
112
+ return this.position;
113
+ }
114
+ return 'bottom';
115
+ },
116
+ },
117
+ watch: {
118
+ show(newVal) {
119
+ if (!this.useWxNative) {
120
+ if (this.innerShow !== newVal) {
121
+ this.innerShow = newVal;
122
+ }
123
+ this.triggerTransition(newVal);
124
+ }
125
+ },
126
+ innerShow(newVal) {
127
+ if (!this.useWxNative && newVal !== this.show) {
128
+ this.$emit('update:show', newVal);
129
+ }
130
+ },
131
+ },
132
+ beforeDestroy() {
133
+ this.clearTimers();
134
+ this.releaseWxNativeOwner();
135
+ },
136
+ created() {
137
+ this.initMode();
138
+ if (!this.useWxNative && this.show) {
139
+ this.triggerTransition(true);
140
+ }
141
+ },
142
+ methods: {
143
+ getGlobalScope() {
144
+ if (typeof globalThis !== 'undefined') return globalThis;
145
+ if (typeof global !== 'undefined') return global;
146
+ return {};
147
+ },
148
+ initMode() {
149
+ // #ifdef MP-WEIXIN
150
+ const scope = this.getGlobalScope();
151
+ if (!scope.__stePageContainerOwnerUid) {
152
+ scope.__stePageContainerOwnerUid = this._uid;
153
+ this.useWxNative = true;
154
+ return;
155
+ }
156
+ this.useWxNative = scope.__stePageContainerOwnerUid === this._uid;
157
+ // #endif
158
+ // #ifndef MP-WEIXIN
159
+ this.useWxNative = false;
160
+ // #endif
161
+ },
162
+ releaseWxNativeOwner() {
163
+ // #ifdef MP-WEIXIN
164
+ const scope = this.getGlobalScope();
165
+ if (scope.__stePageContainerOwnerUid === this._uid) {
166
+ scope.__stePageContainerOwnerUid = null;
167
+ }
168
+ // #endif
169
+ },
170
+ emitEvent(eventName, e) {
171
+ this.$emit(eventName, e);
172
+ },
173
+ onClickOverlay(e) {
174
+ this.$emit('clickoverlay', e);
175
+ },
176
+ onPopupOpenAfter(e) {
177
+ this.$emit('afterenter', e);
178
+ },
179
+ open() {
180
+ this.$emit('update:show', true);
181
+ },
182
+ close() {
183
+ this.$emit('update:show', false);
184
+ },
185
+ clearTimers() {
186
+ if (this.leaveTimer) {
187
+ clearTimeout(this.leaveTimer);
188
+ this.leaveTimer = null;
189
+ }
190
+ },
191
+ triggerTransition(show) {
192
+ this.clearTimers();
193
+ if (show) {
194
+ this.$emit('beforeenter');
195
+ this.$emit('enter');
196
+ return;
197
+ }
198
+ this.$emit('beforeleave');
199
+ this.$emit('leave');
200
+ this.leaveTimer = setTimeout(() => {
201
+ this.$emit('afterleave');
202
+ this.leaveTimer = null;
203
+ }, this.duration);
204
+ },
205
+ },
206
+ };
207
+ </script>
208
+
209
+ <style lang="scss" scoped>
210
+ .ste-page-container-content {
211
+ width: 100%;
212
+ height: 100%;
213
+ }
214
+
215
+ .safe-area-bottom {
216
+ padding-bottom: constant(safe-area-inset-bottom);
217
+ padding-bottom: env(safe-area-inset-bottom);
218
+ box-sizing: border-box;
219
+ }
220
+ </style>