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