@v-c/trigger 0.0.9 → 0.0.11
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.
- package/dist/Popup/Arrow.cjs +91 -1
- package/dist/Popup/Arrow.js +60 -38
- package/dist/Popup/Mask.cjs +66 -1
- package/dist/Popup/Mask.js +35 -32
- package/dist/Popup/PopupContent.cjs +29 -1
- package/dist/Popup/PopupContent.js +15 -8
- package/dist/Popup/index.cjs +365 -1
- package/dist/Popup/index.js +194 -160
- package/dist/UniqueProvider/UniqueContainer.cjs +159 -1
- package/dist/UniqueProvider/UniqueContainer.js +87 -67
- package/dist/UniqueProvider/index.cjs +213 -1
- package/dist/UniqueProvider/index.js +177 -131
- package/dist/UniqueProvider/useTargetState.cjs +42 -1
- package/dist/UniqueProvider/useTargetState.js +39 -10
- package/dist/context.cjs +38 -1
- package/dist/context.js +27 -16
- package/dist/hooks/useAction.cjs +32 -1
- package/dist/hooks/useAction.js +27 -12
- package/dist/hooks/useAlign.cjs +499 -1
- package/dist/hooks/useAlign.d.ts +1 -1
- package/dist/hooks/useAlign.js +445 -204
- package/dist/hooks/useDelay.cjs +27 -1
- package/dist/hooks/useDelay.js +23 -12
- package/dist/hooks/useOffsetStyle.cjs +36 -1
- package/dist/hooks/useOffsetStyle.js +28 -12
- package/dist/hooks/useWatch.cjs +37 -1
- package/dist/hooks/useWatch.js +28 -17
- package/dist/hooks/useWinClick.cjs +67 -1
- package/dist/hooks/useWinClick.js +56 -39
- package/dist/index.cjs +700 -1
- package/dist/index.js +501 -312
- package/dist/util.cjs +101 -1
- package/dist/util.js +86 -54
- package/package.json +3 -3
package/dist/Popup/index.js
CHANGED
|
@@ -1,331 +1,365 @@
|
|
|
1
|
-
import { defineComponent
|
|
2
|
-
import
|
|
3
|
-
import { classNames
|
|
4
|
-
import { toPropsRefs
|
|
5
|
-
import { getTransitionProps
|
|
6
|
-
import
|
|
7
|
-
import { Arrow
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
const
|
|
11
|
-
autoDestroy:
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { defineComponent, computed, shallowRef, watchEffect, nextTick, createVNode, Transition, withDirectives, mergeProps, vShow, mergeDefaults } from "vue";
|
|
2
|
+
import ResizeObserver from "@v-c/resize-observer";
|
|
3
|
+
import { classNames } from "@v-c/util";
|
|
4
|
+
import { toPropsRefs } from "@v-c/util/dist/props-util";
|
|
5
|
+
import { getTransitionProps } from "@v-c/util/dist/utils/transition";
|
|
6
|
+
import useOffsetStyle from "../hooks/useOffsetStyle.js";
|
|
7
|
+
import { Arrow } from "./Arrow.js";
|
|
8
|
+
import Mask from "./Mask.js";
|
|
9
|
+
import PopupContent from "./PopupContent.js";
|
|
10
|
+
const defaults = {
|
|
11
|
+
autoDestroy: true
|
|
12
|
+
};
|
|
13
|
+
const Popup = /* @__PURE__ */ defineComponent((props, {
|
|
14
|
+
attrs,
|
|
15
|
+
expose
|
|
15
16
|
}) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
const popupContent = computed(() => typeof props.popup === "function" ? props.popup() : props.popup);
|
|
18
|
+
const {
|
|
19
|
+
offsetX,
|
|
20
|
+
offsetR,
|
|
21
|
+
offsetY,
|
|
22
|
+
offsetB,
|
|
23
|
+
open,
|
|
24
|
+
ready,
|
|
25
|
+
align
|
|
26
|
+
} = toPropsRefs(props, "offsetX", "offsetB", "offsetY", "offsetR", "ready", "open", "align");
|
|
27
|
+
const isNodeVisible = computed(() => props.open || props.keepDom);
|
|
28
|
+
const isMobile = computed(() => !!props.mobile);
|
|
29
|
+
const getPopupContainerNeedParams = props?.getPopupContainer?.length > 0;
|
|
30
|
+
const mergedProps = computed(() => {
|
|
25
31
|
const {
|
|
26
|
-
mobile
|
|
27
|
-
mask
|
|
28
|
-
maskMotion
|
|
29
|
-
motion
|
|
30
|
-
} =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
mobile,
|
|
33
|
+
mask,
|
|
34
|
+
maskMotion,
|
|
35
|
+
motion
|
|
36
|
+
} = props;
|
|
37
|
+
if (mobile) {
|
|
38
|
+
return [mobile.mask, mobile.maskMotion, mobile.motion];
|
|
39
|
+
}
|
|
40
|
+
return [mask, maskMotion, motion];
|
|
41
|
+
});
|
|
42
|
+
const show = shallowRef(!props.getPopupContainer || !getPopupContainerNeedParams);
|
|
43
|
+
watchEffect(async () => {
|
|
44
|
+
await nextTick();
|
|
45
|
+
const getPopupContainerNeedParams2 = props?.getPopupContainer?.length > 0;
|
|
46
|
+
const target = props.target;
|
|
47
|
+
if (!show.value && getPopupContainerNeedParams2 && target) {
|
|
48
|
+
show.value = true;
|
|
49
|
+
}
|
|
37
50
|
});
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
const onInternalResize = (size, element) => {
|
|
52
|
+
props?.onResize?.(size, element);
|
|
53
|
+
props?.onAlign?.();
|
|
54
|
+
};
|
|
55
|
+
const offsetStyle = useOffsetStyle(isMobile, ready, open, align, offsetR, offsetB, offsetX, offsetY);
|
|
56
|
+
const popupElementRef = shallowRef();
|
|
57
|
+
expose({
|
|
58
|
+
getElement: () => popupElementRef.value,
|
|
59
|
+
nativeElement: popupElementRef
|
|
60
|
+
});
|
|
61
|
+
return () => {
|
|
62
|
+
if (!show.value) {
|
|
46
63
|
return null;
|
|
64
|
+
}
|
|
47
65
|
const {
|
|
48
|
-
stretch
|
|
49
|
-
targetHeight
|
|
50
|
-
targetWidth
|
|
51
|
-
portal:
|
|
52
|
-
forceRender
|
|
53
|
-
getPopupContainer
|
|
54
|
-
target
|
|
55
|
-
autoDestroy
|
|
56
|
-
zIndex
|
|
57
|
-
prefixCls
|
|
66
|
+
stretch,
|
|
67
|
+
targetHeight,
|
|
68
|
+
targetWidth,
|
|
69
|
+
portal: Portal,
|
|
70
|
+
forceRender,
|
|
71
|
+
getPopupContainer,
|
|
72
|
+
target,
|
|
73
|
+
autoDestroy,
|
|
74
|
+
zIndex,
|
|
75
|
+
prefixCls,
|
|
58
76
|
// Arrow
|
|
59
|
-
arrow
|
|
60
|
-
arrowPos
|
|
61
|
-
align:
|
|
62
|
-
onMouseEnter
|
|
63
|
-
onMouseLeave
|
|
64
|
-
onPointerEnter
|
|
65
|
-
onPointerDownCapture
|
|
66
|
-
onClick
|
|
67
|
-
fresh
|
|
68
|
-
onPrepare
|
|
69
|
-
onVisibleChanged
|
|
70
|
-
} =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
arrow,
|
|
78
|
+
arrowPos,
|
|
79
|
+
align: align2,
|
|
80
|
+
onMouseEnter,
|
|
81
|
+
onMouseLeave,
|
|
82
|
+
onPointerEnter,
|
|
83
|
+
onPointerDownCapture,
|
|
84
|
+
onClick,
|
|
85
|
+
fresh,
|
|
86
|
+
onPrepare,
|
|
87
|
+
onVisibleChanged
|
|
88
|
+
} = props;
|
|
89
|
+
const miscStyle = {};
|
|
90
|
+
if (stretch) {
|
|
91
|
+
if (stretch.includes("height") && targetHeight) {
|
|
92
|
+
miscStyle.height = `${targetHeight}px`;
|
|
93
|
+
} else if (stretch.includes("minHeight") && targetHeight) {
|
|
94
|
+
miscStyle.minHeight = `${targetHeight}px`;
|
|
95
|
+
}
|
|
96
|
+
if (stretch.includes("width") && targetWidth) {
|
|
97
|
+
miscStyle.width = `${targetWidth}px`;
|
|
98
|
+
} else if (stretch.includes("minWidth") && targetWidth) {
|
|
99
|
+
miscStyle.minWidth = `${targetWidth}px`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!open.value) {
|
|
103
|
+
miscStyle.pointerEvents = "none";
|
|
104
|
+
}
|
|
105
|
+
const [mergedMask, mergedMaskMotion, mergedPopupMotion] = mergedProps.value;
|
|
106
|
+
const popupMotionName = mergedPopupMotion?.name ?? mergedPopupMotion?.motionName;
|
|
107
|
+
const baseTransitionProps = getTransitionProps(popupMotionName, mergedPopupMotion);
|
|
108
|
+
const mergedTransitionProps = {
|
|
109
|
+
...baseTransitionProps,
|
|
110
|
+
onBeforeEnter: (element) => {
|
|
111
|
+
onPrepare?.();
|
|
112
|
+
baseTransitionProps?.onBeforeEnter?.(element);
|
|
82
113
|
},
|
|
83
|
-
onAfterEnter: (
|
|
84
|
-
|
|
114
|
+
onAfterEnter: (element) => {
|
|
115
|
+
baseTransitionProps?.onAfterEnter?.(element);
|
|
116
|
+
onVisibleChanged?.(true);
|
|
85
117
|
},
|
|
86
|
-
onAfterLeave: (
|
|
87
|
-
|
|
118
|
+
onAfterLeave: (element) => {
|
|
119
|
+
baseTransitionProps.onAfterLeave?.(element);
|
|
120
|
+
onVisibleChanged?.(false);
|
|
88
121
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
122
|
+
};
|
|
123
|
+
const cls = classNames(prefixCls, attrs.class, props.className, {
|
|
124
|
+
[`${prefixCls}-mobile`]: isMobile.value
|
|
91
125
|
});
|
|
92
|
-
return
|
|
93
|
-
open:
|
|
94
|
-
getContainer:
|
|
95
|
-
autoDestroy:
|
|
126
|
+
return createVNode(Portal, {
|
|
127
|
+
"open": forceRender || isNodeVisible.value,
|
|
128
|
+
"getContainer": getPopupContainer && (() => getPopupContainer(target)),
|
|
129
|
+
"autoDestroy": autoDestroy
|
|
96
130
|
}, {
|
|
97
|
-
default: () => [
|
|
98
|
-
prefixCls:
|
|
99
|
-
open:
|
|
100
|
-
zIndex:
|
|
101
|
-
mask:
|
|
102
|
-
motion:
|
|
103
|
-
mobile:
|
|
104
|
-
}, null),
|
|
105
|
-
onResize:
|
|
106
|
-
disabled: !
|
|
131
|
+
default: () => [createVNode(Mask, {
|
|
132
|
+
"prefixCls": prefixCls,
|
|
133
|
+
"open": open.value,
|
|
134
|
+
"zIndex": zIndex,
|
|
135
|
+
"mask": mergedMask,
|
|
136
|
+
"motion": mergedMaskMotion,
|
|
137
|
+
"mobile": isMobile.value
|
|
138
|
+
}, null), createVNode(ResizeObserver, {
|
|
139
|
+
"onResize": onInternalResize,
|
|
140
|
+
"disabled": !open.value
|
|
107
141
|
}, {
|
|
108
|
-
default: () => [
|
|
109
|
-
default: () => [
|
|
110
|
-
ref:
|
|
111
|
-
class:
|
|
112
|
-
style: [{
|
|
113
|
-
"--arrow-x": `${
|
|
114
|
-
"--arrow-y": `${
|
|
115
|
-
},
|
|
142
|
+
default: () => [createVNode(Transition, mergedTransitionProps, {
|
|
143
|
+
default: () => [withDirectives(createVNode("div", mergeProps({
|
|
144
|
+
"ref": popupElementRef,
|
|
145
|
+
"class": cls,
|
|
146
|
+
"style": [{
|
|
147
|
+
"--arrow-x": `${arrowPos.x || 0}px`,
|
|
148
|
+
"--arrow-y": `${arrowPos.y || 0}px`
|
|
149
|
+
}, offsetStyle.value, miscStyle, {
|
|
116
150
|
boxSizing: "border-box",
|
|
117
|
-
zIndex
|
|
118
|
-
},
|
|
119
|
-
onMouseenter:
|
|
120
|
-
onMouseleave:
|
|
121
|
-
onPointerenter:
|
|
122
|
-
onClick:
|
|
151
|
+
zIndex
|
|
152
|
+
}, props.style],
|
|
153
|
+
"onMouseenter": onMouseEnter,
|
|
154
|
+
"onMouseleave": onMouseLeave,
|
|
155
|
+
"onPointerenter": onPointerEnter,
|
|
156
|
+
"onClick": onClick
|
|
123
157
|
}, {
|
|
124
|
-
onPointerdownCapture:
|
|
125
|
-
}), [
|
|
126
|
-
prefixCls:
|
|
127
|
-
arrow:
|
|
128
|
-
arrowPos:
|
|
129
|
-
align:
|
|
130
|
-
}, null),
|
|
131
|
-
cache: !
|
|
158
|
+
onPointerdownCapture: onPointerDownCapture
|
|
159
|
+
}), [arrow && createVNode(Arrow, {
|
|
160
|
+
"prefixCls": prefixCls,
|
|
161
|
+
"arrow": arrow,
|
|
162
|
+
"arrowPos": arrowPos,
|
|
163
|
+
"align": align2
|
|
164
|
+
}, null), createVNode(PopupContent, {
|
|
165
|
+
"cache": !open.value && !fresh
|
|
132
166
|
}, {
|
|
133
|
-
default: () => [
|
|
134
|
-
})]), [[
|
|
167
|
+
default: () => [popupContent.value]
|
|
168
|
+
})]), [[vShow, open.value]])]
|
|
135
169
|
})]
|
|
136
170
|
})]
|
|
137
171
|
});
|
|
138
172
|
};
|
|
139
173
|
}, {
|
|
140
|
-
props: /* @__PURE__ */
|
|
174
|
+
props: /* @__PURE__ */ mergeDefaults({
|
|
141
175
|
prefixCls: {
|
|
142
176
|
type: String,
|
|
143
|
-
required:
|
|
177
|
+
required: true,
|
|
144
178
|
default: void 0
|
|
145
179
|
},
|
|
146
180
|
className: {
|
|
147
181
|
type: String,
|
|
148
|
-
required:
|
|
182
|
+
required: false,
|
|
149
183
|
default: void 0
|
|
150
184
|
},
|
|
151
185
|
style: {
|
|
152
186
|
type: null,
|
|
153
|
-
required:
|
|
187
|
+
required: false,
|
|
154
188
|
default: void 0
|
|
155
189
|
},
|
|
156
190
|
popup: {
|
|
157
191
|
type: Function,
|
|
158
|
-
required:
|
|
159
|
-
skipCheck:
|
|
192
|
+
required: false,
|
|
193
|
+
skipCheck: true,
|
|
160
194
|
default: void 0
|
|
161
195
|
},
|
|
162
196
|
target: {
|
|
163
197
|
type: null,
|
|
164
|
-
required:
|
|
198
|
+
required: true,
|
|
165
199
|
default: void 0
|
|
166
200
|
},
|
|
167
201
|
onMouseEnter: {
|
|
168
202
|
type: Function,
|
|
169
|
-
required:
|
|
203
|
+
required: false,
|
|
170
204
|
default: void 0
|
|
171
205
|
},
|
|
172
206
|
onMouseLeave: {
|
|
173
207
|
type: Function,
|
|
174
|
-
required:
|
|
208
|
+
required: false,
|
|
175
209
|
default: void 0
|
|
176
210
|
},
|
|
177
211
|
onPointerEnter: {
|
|
178
212
|
type: Function,
|
|
179
|
-
required:
|
|
213
|
+
required: false,
|
|
180
214
|
default: void 0
|
|
181
215
|
},
|
|
182
216
|
onPointerDownCapture: {
|
|
183
217
|
type: Function,
|
|
184
|
-
required:
|
|
218
|
+
required: false,
|
|
185
219
|
default: void 0
|
|
186
220
|
},
|
|
187
221
|
zIndex: {
|
|
188
222
|
type: Number,
|
|
189
|
-
required:
|
|
223
|
+
required: false,
|
|
190
224
|
default: void 0
|
|
191
225
|
},
|
|
192
226
|
mask: {
|
|
193
227
|
type: Boolean,
|
|
194
|
-
required:
|
|
228
|
+
required: false,
|
|
195
229
|
default: void 0
|
|
196
230
|
},
|
|
197
231
|
onVisibleChanged: {
|
|
198
232
|
type: Function,
|
|
199
|
-
required:
|
|
233
|
+
required: true,
|
|
200
234
|
default: void 0
|
|
201
235
|
},
|
|
202
236
|
align: {
|
|
203
237
|
type: Object,
|
|
204
|
-
required:
|
|
238
|
+
required: false,
|
|
205
239
|
default: void 0
|
|
206
240
|
},
|
|
207
241
|
arrow: {
|
|
208
242
|
type: Object,
|
|
209
|
-
required:
|
|
243
|
+
required: false,
|
|
210
244
|
default: void 0
|
|
211
245
|
},
|
|
212
246
|
arrowPos: {
|
|
213
247
|
type: Object,
|
|
214
|
-
required:
|
|
248
|
+
required: true,
|
|
215
249
|
default: void 0
|
|
216
250
|
},
|
|
217
251
|
open: {
|
|
218
252
|
type: Boolean,
|
|
219
|
-
required:
|
|
253
|
+
required: true,
|
|
220
254
|
default: void 0
|
|
221
255
|
},
|
|
222
256
|
keepDom: {
|
|
223
257
|
type: Boolean,
|
|
224
|
-
required:
|
|
258
|
+
required: true,
|
|
225
259
|
default: void 0
|
|
226
260
|
},
|
|
227
261
|
fresh: {
|
|
228
262
|
type: Boolean,
|
|
229
|
-
required:
|
|
263
|
+
required: false,
|
|
230
264
|
default: void 0
|
|
231
265
|
},
|
|
232
266
|
onClick: {
|
|
233
267
|
type: Function,
|
|
234
|
-
required:
|
|
268
|
+
required: false,
|
|
235
269
|
default: void 0
|
|
236
270
|
},
|
|
237
271
|
motion: {
|
|
238
272
|
type: Object,
|
|
239
|
-
required:
|
|
273
|
+
required: false,
|
|
240
274
|
default: void 0
|
|
241
275
|
},
|
|
242
276
|
maskMotion: {
|
|
243
277
|
type: Object,
|
|
244
|
-
required:
|
|
278
|
+
required: false,
|
|
245
279
|
default: void 0
|
|
246
280
|
},
|
|
247
281
|
forceRender: {
|
|
248
282
|
type: Boolean,
|
|
249
|
-
required:
|
|
283
|
+
required: false,
|
|
250
284
|
default: void 0
|
|
251
285
|
},
|
|
252
286
|
getPopupContainer: {
|
|
253
287
|
type: Function,
|
|
254
|
-
required:
|
|
288
|
+
required: false,
|
|
255
289
|
default: void 0
|
|
256
290
|
},
|
|
257
291
|
autoDestroy: {
|
|
258
292
|
type: Boolean,
|
|
259
|
-
required:
|
|
293
|
+
required: false,
|
|
260
294
|
default: void 0
|
|
261
295
|
},
|
|
262
296
|
portal: {
|
|
263
297
|
type: null,
|
|
264
|
-
required:
|
|
298
|
+
required: true,
|
|
265
299
|
default: void 0
|
|
266
300
|
},
|
|
267
301
|
ready: {
|
|
268
302
|
type: Boolean,
|
|
269
|
-
required:
|
|
303
|
+
required: true,
|
|
270
304
|
default: void 0
|
|
271
305
|
},
|
|
272
306
|
offsetX: {
|
|
273
307
|
type: Number,
|
|
274
|
-
required:
|
|
308
|
+
required: true,
|
|
275
309
|
default: void 0
|
|
276
310
|
},
|
|
277
311
|
offsetY: {
|
|
278
312
|
type: Number,
|
|
279
|
-
required:
|
|
313
|
+
required: true,
|
|
280
314
|
default: void 0
|
|
281
315
|
},
|
|
282
316
|
offsetR: {
|
|
283
317
|
type: Number,
|
|
284
|
-
required:
|
|
318
|
+
required: true,
|
|
285
319
|
default: void 0
|
|
286
320
|
},
|
|
287
321
|
offsetB: {
|
|
288
322
|
type: Number,
|
|
289
|
-
required:
|
|
323
|
+
required: true,
|
|
290
324
|
default: void 0
|
|
291
325
|
},
|
|
292
326
|
onAlign: {
|
|
293
327
|
type: null,
|
|
294
|
-
required:
|
|
328
|
+
required: true,
|
|
295
329
|
default: void 0
|
|
296
330
|
},
|
|
297
331
|
onPrepare: {
|
|
298
332
|
type: Function,
|
|
299
|
-
required:
|
|
333
|
+
required: true,
|
|
300
334
|
default: void 0
|
|
301
335
|
},
|
|
302
336
|
stretch: {
|
|
303
337
|
type: String,
|
|
304
|
-
required:
|
|
338
|
+
required: false,
|
|
305
339
|
default: void 0
|
|
306
340
|
},
|
|
307
341
|
targetWidth: {
|
|
308
342
|
type: Number,
|
|
309
|
-
required:
|
|
343
|
+
required: false,
|
|
310
344
|
default: void 0
|
|
311
345
|
},
|
|
312
346
|
targetHeight: {
|
|
313
347
|
type: Number,
|
|
314
|
-
required:
|
|
348
|
+
required: false,
|
|
315
349
|
default: void 0
|
|
316
350
|
},
|
|
317
351
|
onResize: {
|
|
318
352
|
type: null,
|
|
319
|
-
required:
|
|
353
|
+
required: false,
|
|
320
354
|
default: void 0
|
|
321
355
|
},
|
|
322
356
|
mobile: {
|
|
323
357
|
type: Object,
|
|
324
|
-
required:
|
|
358
|
+
required: false,
|
|
325
359
|
default: void 0
|
|
326
360
|
}
|
|
327
|
-
},
|
|
361
|
+
}, defaults)
|
|
328
362
|
});
|
|
329
363
|
export {
|
|
330
|
-
|
|
364
|
+
Popup as default
|
|
331
365
|
};
|
|
@@ -1 +1,159 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const propsUtil = require("@v-c/util/dist/props-util");
|
|
5
|
+
const transition = require("@v-c/util/dist/utils/transition");
|
|
6
|
+
const useOffsetStyle = require("../hooks/useOffsetStyle.cjs");
|
|
7
|
+
const UniqueContainer = /* @__PURE__ */ vue.defineComponent((props) => {
|
|
8
|
+
const motionVisible = vue.shallowRef(false);
|
|
9
|
+
const {
|
|
10
|
+
open,
|
|
11
|
+
isMobile,
|
|
12
|
+
align,
|
|
13
|
+
ready,
|
|
14
|
+
offsetR,
|
|
15
|
+
offsetB,
|
|
16
|
+
offsetX,
|
|
17
|
+
offsetY
|
|
18
|
+
} = propsUtil.toPropsRefs(props, "open", "isMobile", "align", "ready", "offsetR", "offsetB", "offsetX", "offsetY");
|
|
19
|
+
const offsetStyle = useOffsetStyle.default(isMobile, ready, open, align, offsetR, offsetB, offsetX, offsetY);
|
|
20
|
+
const cachedOffsetStyleRef = vue.shallowRef(offsetStyle.value);
|
|
21
|
+
vue.watchEffect(() => {
|
|
22
|
+
if (ready.value) {
|
|
23
|
+
cachedOffsetStyleRef.value = offsetStyle.value;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
vue.watch(open, (nextVisible) => {
|
|
27
|
+
if (nextVisible) {
|
|
28
|
+
motionVisible.value = true;
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
immediate: true
|
|
32
|
+
});
|
|
33
|
+
return () => {
|
|
34
|
+
const {
|
|
35
|
+
popupSize,
|
|
36
|
+
motion,
|
|
37
|
+
prefixCls,
|
|
38
|
+
uniqueContainerClassName,
|
|
39
|
+
arrowPos,
|
|
40
|
+
uniqueContainerStyle
|
|
41
|
+
} = props;
|
|
42
|
+
const sizeStyle = {};
|
|
43
|
+
if (popupSize) {
|
|
44
|
+
sizeStyle.width = `${popupSize.width}px`;
|
|
45
|
+
sizeStyle.height = `${popupSize.height}px`;
|
|
46
|
+
}
|
|
47
|
+
const baseTransitionProps = transition.getTransitionProps(motion?.name, motion);
|
|
48
|
+
const mergedTransitionProps = {
|
|
49
|
+
...baseTransitionProps,
|
|
50
|
+
onBeforeAppear: (element) => {
|
|
51
|
+
motionVisible.value = true;
|
|
52
|
+
baseTransitionProps.onBeforeAppear?.(element);
|
|
53
|
+
},
|
|
54
|
+
onBeforeEnter: (element) => {
|
|
55
|
+
motionVisible.value = true;
|
|
56
|
+
baseTransitionProps.onBeforeEnter?.(element);
|
|
57
|
+
},
|
|
58
|
+
onAfterAppear: (element) => {
|
|
59
|
+
motionVisible.value = true;
|
|
60
|
+
baseTransitionProps.onAfterAppear?.(element);
|
|
61
|
+
},
|
|
62
|
+
onAfterEnter: (element) => {
|
|
63
|
+
motionVisible.value = true;
|
|
64
|
+
baseTransitionProps.onAfterEnter?.(element);
|
|
65
|
+
},
|
|
66
|
+
onAfterLeave: (element) => {
|
|
67
|
+
motionVisible.value = false;
|
|
68
|
+
baseTransitionProps.onAfterLeave?.(element);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const containerCls = `${prefixCls}-unique-container`;
|
|
72
|
+
return vue.createVNode(vue.Transition, mergedTransitionProps, {
|
|
73
|
+
default: () => [vue.withDirectives(vue.createVNode("div", {
|
|
74
|
+
"class": [containerCls, uniqueContainerClassName, {
|
|
75
|
+
[`${containerCls}-visible`]: motionVisible.value,
|
|
76
|
+
[`${containerCls}-hidden`]: !motionVisible.value
|
|
77
|
+
}],
|
|
78
|
+
"style": [{
|
|
79
|
+
"--arrow-x": `${arrowPos?.x || 0}px`,
|
|
80
|
+
"--arrow-y": `${arrowPos?.y || 0}px`
|
|
81
|
+
}, cachedOffsetStyleRef.value, sizeStyle, uniqueContainerStyle]
|
|
82
|
+
}, null), [[vue.vShow, open.value]])]
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}, {
|
|
86
|
+
props: {
|
|
87
|
+
prefixCls: {
|
|
88
|
+
type: String,
|
|
89
|
+
required: true,
|
|
90
|
+
default: void 0
|
|
91
|
+
},
|
|
92
|
+
isMobile: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
required: true,
|
|
95
|
+
default: void 0
|
|
96
|
+
},
|
|
97
|
+
ready: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
required: true,
|
|
100
|
+
default: void 0
|
|
101
|
+
},
|
|
102
|
+
open: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
required: true,
|
|
105
|
+
default: void 0
|
|
106
|
+
},
|
|
107
|
+
align: {
|
|
108
|
+
type: Object,
|
|
109
|
+
required: true,
|
|
110
|
+
default: void 0
|
|
111
|
+
},
|
|
112
|
+
offsetR: {
|
|
113
|
+
type: Number,
|
|
114
|
+
required: true,
|
|
115
|
+
default: void 0
|
|
116
|
+
},
|
|
117
|
+
offsetB: {
|
|
118
|
+
type: Number,
|
|
119
|
+
required: true,
|
|
120
|
+
default: void 0
|
|
121
|
+
},
|
|
122
|
+
offsetX: {
|
|
123
|
+
type: Number,
|
|
124
|
+
required: true,
|
|
125
|
+
default: void 0
|
|
126
|
+
},
|
|
127
|
+
offsetY: {
|
|
128
|
+
type: Number,
|
|
129
|
+
required: true,
|
|
130
|
+
default: void 0
|
|
131
|
+
},
|
|
132
|
+
arrowPos: {
|
|
133
|
+
type: Object,
|
|
134
|
+
required: false,
|
|
135
|
+
default: void 0
|
|
136
|
+
},
|
|
137
|
+
popupSize: {
|
|
138
|
+
type: Object,
|
|
139
|
+
required: false,
|
|
140
|
+
default: void 0
|
|
141
|
+
},
|
|
142
|
+
motion: {
|
|
143
|
+
type: Object,
|
|
144
|
+
required: false,
|
|
145
|
+
default: void 0
|
|
146
|
+
},
|
|
147
|
+
uniqueContainerClassName: {
|
|
148
|
+
type: String,
|
|
149
|
+
required: false,
|
|
150
|
+
default: void 0
|
|
151
|
+
},
|
|
152
|
+
uniqueContainerStyle: {
|
|
153
|
+
type: null,
|
|
154
|
+
required: false,
|
|
155
|
+
default: void 0
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
exports.default = UniqueContainer;
|