@v-c/trigger 0.0.13 → 0.0.15
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 +60 -89
- package/dist/Popup/Arrow.js +58 -88
- package/dist/Popup/Mask.cjs +53 -64
- package/dist/Popup/Mask.js +49 -63
- package/dist/Popup/PopupContent.cjs +22 -27
- package/dist/Popup/PopupContent.js +18 -26
- package/dist/Popup/index.cjs +312 -366
- package/dist/Popup/index.js +304 -362
- package/dist/UniqueProvider/UniqueContainer.cjs +133 -150
- package/dist/UniqueProvider/UniqueContainer.js +128 -148
- package/dist/UniqueProvider/index.cjs +151 -216
- package/dist/UniqueProvider/index.js +144 -213
- package/dist/UniqueProvider/useTargetState.cjs +39 -39
- package/dist/UniqueProvider/useTargetState.js +37 -39
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/context.cjs +17 -28
- package/dist/context.js +17 -33
- package/dist/hooks/useAction.cjs +19 -25
- package/dist/hooks/useAction.js +17 -25
- package/dist/hooks/useAlign.cjs +388 -592
- package/dist/hooks/useAlign.js +383 -590
- package/dist/hooks/useDelay.cjs +21 -24
- package/dist/hooks/useDelay.js +20 -25
- package/dist/hooks/useOffsetStyle.cjs +34 -37
- package/dist/hooks/useOffsetStyle.js +32 -37
- package/dist/hooks/useWatch.cjs +38 -34
- package/dist/hooks/useWatch.js +36 -34
- package/dist/hooks/useWinClick.cjs +54 -64
- package/dist/hooks/useWinClick.js +51 -63
- package/dist/index.cjs +591 -694
- package/dist/index.js +580 -690
- package/dist/interface.cjs +0 -1
- package/dist/interface.js +0 -1
- package/dist/util.cjs +65 -82
- package/dist/util.js +66 -87
- package/package.json +3 -3
|
@@ -1,216 +1,151 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
"style": mergedOptions.value?.popupStyle,
|
|
153
|
-
"target": mergedOptions.value?.target,
|
|
154
|
-
"open": open.value,
|
|
155
|
-
"keepDom": true,
|
|
156
|
-
"fresh": true,
|
|
157
|
-
"autoDestroy": false,
|
|
158
|
-
"onVisibleChanged": onVisibleChanged,
|
|
159
|
-
"ready": ready.value,
|
|
160
|
-
"offsetX": offsetX.value,
|
|
161
|
-
"offsetY": offsetY.value,
|
|
162
|
-
"offsetR": offsetR.value,
|
|
163
|
-
"offsetB": offsetB.value,
|
|
164
|
-
"onAlign": onAlign,
|
|
165
|
-
"onPrepare": onPrepare,
|
|
166
|
-
"onResize": (size) => {
|
|
167
|
-
popupSize.value = {
|
|
168
|
-
width: size.offsetWidth,
|
|
169
|
-
height: size.offsetHeight
|
|
170
|
-
};
|
|
171
|
-
},
|
|
172
|
-
"arrowPos": {
|
|
173
|
-
x: arrowX.value,
|
|
174
|
-
y: arrowY.value
|
|
175
|
-
},
|
|
176
|
-
"align": alignInfo.value,
|
|
177
|
-
"zIndex": mergedOptions.value?.zIndex,
|
|
178
|
-
"mask": mergedOptions.value?.mask,
|
|
179
|
-
"arrow": mergedOptions.value?.arrow,
|
|
180
|
-
"motion": mergedOptions.value?.popupMotion,
|
|
181
|
-
"maskMotion": mergedOptions.value?.maskMotion,
|
|
182
|
-
"getPopupContainer": mergedOptions.value.getPopupContainer
|
|
183
|
-
}, {
|
|
184
|
-
default: () => [vue.createVNode(UniqueContainer.default, {
|
|
185
|
-
"prefixCls": prefixCls,
|
|
186
|
-
"isMobile": false,
|
|
187
|
-
"ready": ready.value,
|
|
188
|
-
"open": open.value,
|
|
189
|
-
"align": alignInfo.value,
|
|
190
|
-
"offsetX": offsetX.value,
|
|
191
|
-
"offsetY": offsetY.value,
|
|
192
|
-
"offsetR": offsetR.value,
|
|
193
|
-
"offsetB": offsetB.value,
|
|
194
|
-
"arrowPos": {
|
|
195
|
-
x: arrowX.value,
|
|
196
|
-
y: arrowY.value
|
|
197
|
-
},
|
|
198
|
-
"popupSize": popupSize.value,
|
|
199
|
-
"motion": mergedOptions.value?.popupMotion,
|
|
200
|
-
"uniqueContainerClassName": util$1.classNames(mergedOptions.value?.uniqueContainerClassName, alignedClassName.value),
|
|
201
|
-
"uniqueContainerStyle": mergedOptions?.value?.uniqueContainerStyle
|
|
202
|
-
}, null)]
|
|
203
|
-
})]
|
|
204
|
-
})]
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
}, {
|
|
208
|
-
props: {
|
|
209
|
-
postTriggerProps: {
|
|
210
|
-
type: Function,
|
|
211
|
-
required: false,
|
|
212
|
-
default: void 0
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
exports.default = UniqueProvider;
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
|
+
const require_context = require("../context.cjs");
|
|
4
|
+
const require_util = require("../util.cjs");
|
|
5
|
+
const require_useAlign = require("../hooks/useAlign.cjs");
|
|
6
|
+
const require_useDelay = require("../hooks/useDelay.cjs");
|
|
7
|
+
const require_index = require("../Popup/index.cjs");
|
|
8
|
+
const require_UniqueContainer = require("./UniqueContainer.cjs");
|
|
9
|
+
const require_useTargetState = require("./useTargetState.cjs");
|
|
10
|
+
let vue = require("vue");
|
|
11
|
+
let __v_c_portal = require("@v-c/portal");
|
|
12
|
+
__v_c_portal = require_rolldown_runtime.__toESM(__v_c_portal);
|
|
13
|
+
let __v_c_util = require("@v-c/util");
|
|
14
|
+
let __v_c_util_dist_Dom_findDOMNode = require("@v-c/util/dist/Dom/findDOMNode");
|
|
15
|
+
var UniqueProvider = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
16
|
+
const [trigger, open, options, onTargetVisibleChanged] = require_useTargetState.default();
|
|
17
|
+
const mergedOptions = (0, vue.computed)(() => {
|
|
18
|
+
if (!options.value || !props.postTriggerProps) return options.value;
|
|
19
|
+
return props.postTriggerProps(options.value);
|
|
20
|
+
});
|
|
21
|
+
const popupEle = (0, vue.shallowRef)(null);
|
|
22
|
+
const popupSize = (0, vue.ref)(null);
|
|
23
|
+
const externalPopupRef = (0, vue.shallowRef)(null);
|
|
24
|
+
const resolveToElement = (node) => {
|
|
25
|
+
if (!node) return null;
|
|
26
|
+
if ((0, __v_c_util_dist_Dom_findDOMNode.isDOM)(node)) return node;
|
|
27
|
+
const exposed = node;
|
|
28
|
+
if ((0, __v_c_util_dist_Dom_findDOMNode.isDOM)(exposed?.$el)) return exposed.$el;
|
|
29
|
+
const nativeEl = exposed?.nativeElement;
|
|
30
|
+
if ((0, __v_c_util_dist_Dom_findDOMNode.isDOM)(nativeEl?.value)) return nativeEl.value;
|
|
31
|
+
if ((0, __v_c_util_dist_Dom_findDOMNode.isDOM)(nativeEl)) return nativeEl;
|
|
32
|
+
if (typeof exposed?.getElement === "function") {
|
|
33
|
+
const el = exposed.getElement();
|
|
34
|
+
if ((0, __v_c_util_dist_Dom_findDOMNode.isDOM)(el)) return el;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
const setPopupRef = (node) => {
|
|
39
|
+
const element = resolveToElement(node);
|
|
40
|
+
if (!element) return;
|
|
41
|
+
externalPopupRef.value = element;
|
|
42
|
+
if (popupEle.value !== element) popupEle.value = element;
|
|
43
|
+
};
|
|
44
|
+
const isOpenRef = (0, vue.shallowRef)();
|
|
45
|
+
const delayInvoke = require_useDelay.default();
|
|
46
|
+
const show = (showOptions, isOpen) => {
|
|
47
|
+
isOpenRef.value = isOpen;
|
|
48
|
+
delayInvoke(() => {
|
|
49
|
+
trigger(showOptions);
|
|
50
|
+
}, showOptions.delay);
|
|
51
|
+
};
|
|
52
|
+
const hide = (delay) => {
|
|
53
|
+
delayInvoke(() => {
|
|
54
|
+
if (isOpenRef.value?.()) return;
|
|
55
|
+
trigger(false);
|
|
56
|
+
}, delay);
|
|
57
|
+
};
|
|
58
|
+
const onVisibleChanged = (visible) => {
|
|
59
|
+
onTargetVisibleChanged(visible);
|
|
60
|
+
};
|
|
61
|
+
const [ready, offsetX, offsetY, offsetR, offsetB, arrowX, arrowY, , , alignInfo, onAlign] = require_useAlign.default(open, popupEle, (0, vue.computed)(() => mergedOptions.value?.target), (0, vue.computed)(() => mergedOptions.value?.popupPlacement), (0, vue.computed)(() => mergedOptions.value?.builtinPlacements || {}), (0, vue.computed)(() => mergedOptions.value?.popupAlign), void 0, (0, vue.ref)(false));
|
|
62
|
+
const alignedClassName = (0, vue.computed)(() => {
|
|
63
|
+
if (!mergedOptions.value) return "";
|
|
64
|
+
return (0, __v_c_util.classNames)(require_util.getAlignPopupClassName(mergedOptions.value?.builtinPlacements || {}, mergedOptions.value.prefixCls || "", alignInfo.value, false), mergedOptions.value?.getPopupClassNameFromAlign?.(alignInfo.value));
|
|
65
|
+
});
|
|
66
|
+
const contextValue = {
|
|
67
|
+
show,
|
|
68
|
+
hide
|
|
69
|
+
};
|
|
70
|
+
(0, vue.watch)(() => mergedOptions.value?.target, () => {
|
|
71
|
+
onAlign();
|
|
72
|
+
}, { immediate: true });
|
|
73
|
+
const onPrepare = () => {
|
|
74
|
+
onAlign();
|
|
75
|
+
return Promise.resolve();
|
|
76
|
+
};
|
|
77
|
+
const subPopupElements = (0, vue.ref)({});
|
|
78
|
+
const parentContext = require_context.useTriggerContext();
|
|
79
|
+
const triggerContextValue = (0, vue.computed)(() => {
|
|
80
|
+
return { registerSubPopup: (id, subPopupEle) => {
|
|
81
|
+
if (subPopupEle) subPopupElements.value[id] = subPopupEle;
|
|
82
|
+
else delete subPopupElements.value[id];
|
|
83
|
+
parentContext?.value?.registerSubPopup(id, subPopupEle);
|
|
84
|
+
} };
|
|
85
|
+
});
|
|
86
|
+
return () => {
|
|
87
|
+
const prefixCls = mergedOptions?.value?.prefixCls;
|
|
88
|
+
return (0, vue.createVNode)(require_context.UniqueContextProvider, contextValue, { default: () => [slots?.default?.(), !!mergedOptions.value && (0, vue.createVNode)(require_context.TriggerContextProvider, triggerContextValue.value, { default: () => [(0, vue.createVNode)(require_index.default, {
|
|
89
|
+
"ref": setPopupRef,
|
|
90
|
+
"portal": __v_c_portal.default,
|
|
91
|
+
"prefixCls": prefixCls,
|
|
92
|
+
"popup": mergedOptions.value?.popup,
|
|
93
|
+
"className": (0, __v_c_util.classNames)(mergedOptions.value?.popupClassName, alignedClassName.value, `${prefixCls}-unique-controlled`),
|
|
94
|
+
"style": mergedOptions.value?.popupStyle,
|
|
95
|
+
"target": mergedOptions.value?.target,
|
|
96
|
+
"open": open.value,
|
|
97
|
+
"keepDom": true,
|
|
98
|
+
"fresh": true,
|
|
99
|
+
"autoDestroy": false,
|
|
100
|
+
"onVisibleChanged": onVisibleChanged,
|
|
101
|
+
"ready": ready.value,
|
|
102
|
+
"offsetX": offsetX.value,
|
|
103
|
+
"offsetY": offsetY.value,
|
|
104
|
+
"offsetR": offsetR.value,
|
|
105
|
+
"offsetB": offsetB.value,
|
|
106
|
+
"onAlign": onAlign,
|
|
107
|
+
"onPrepare": onPrepare,
|
|
108
|
+
"onResize": (size) => {
|
|
109
|
+
popupSize.value = {
|
|
110
|
+
width: size.offsetWidth,
|
|
111
|
+
height: size.offsetHeight
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
"arrowPos": {
|
|
115
|
+
x: arrowX.value,
|
|
116
|
+
y: arrowY.value
|
|
117
|
+
},
|
|
118
|
+
"align": alignInfo.value,
|
|
119
|
+
"zIndex": mergedOptions.value?.zIndex,
|
|
120
|
+
"mask": mergedOptions.value?.mask,
|
|
121
|
+
"arrow": mergedOptions.value?.arrow,
|
|
122
|
+
"motion": mergedOptions.value?.popupMotion,
|
|
123
|
+
"maskMotion": mergedOptions.value?.maskMotion,
|
|
124
|
+
"getPopupContainer": mergedOptions.value.getPopupContainer
|
|
125
|
+
}, { default: () => [(0, vue.createVNode)(require_UniqueContainer.default, {
|
|
126
|
+
"prefixCls": prefixCls,
|
|
127
|
+
"isMobile": false,
|
|
128
|
+
"ready": ready.value,
|
|
129
|
+
"open": open.value,
|
|
130
|
+
"align": alignInfo.value,
|
|
131
|
+
"offsetX": offsetX.value,
|
|
132
|
+
"offsetY": offsetY.value,
|
|
133
|
+
"offsetR": offsetR.value,
|
|
134
|
+
"offsetB": offsetB.value,
|
|
135
|
+
"arrowPos": {
|
|
136
|
+
x: arrowX.value,
|
|
137
|
+
y: arrowY.value
|
|
138
|
+
},
|
|
139
|
+
"popupSize": popupSize.value,
|
|
140
|
+
"motion": mergedOptions.value?.popupMotion,
|
|
141
|
+
"uniqueContainerClassName": (0, __v_c_util.classNames)(mergedOptions.value?.uniqueContainerClassName, alignedClassName.value),
|
|
142
|
+
"uniqueContainerStyle": mergedOptions?.value?.uniqueContainerStyle
|
|
143
|
+
}, null)] })] })] });
|
|
144
|
+
};
|
|
145
|
+
}, { props: { postTriggerProps: {
|
|
146
|
+
type: Function,
|
|
147
|
+
required: false,
|
|
148
|
+
default: void 0
|
|
149
|
+
} } });
|
|
150
|
+
var UniqueProvider_default = UniqueProvider;
|
|
151
|
+
exports.default = UniqueProvider_default;
|