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