@v-c/trigger 1.0.1 → 1.0.3

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,11 +1,13 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
6
  const require_util = require("../util.cjs");
4
7
  let vue = require("vue");
5
- let __v_c_util_dist_Dom_findDOMNode = require("@v-c/util/dist/Dom/findDOMNode");
6
- let __v_c_util_dist_Dom_isVisible = require("@v-c/util/dist/Dom/isVisible");
7
- __v_c_util_dist_Dom_isVisible = require_rolldown_runtime.__toESM(__v_c_util_dist_Dom_isVisible);
8
- let __v_c_util_dist_raf = require("@v-c/util/dist/raf");
8
+ let _v_c_util_dist_Dom_findDOMNode = require("@v-c/util/dist/Dom/findDOMNode");
9
+ let _v_c_util_dist_Dom_isVisible = require("@v-c/util/dist/Dom/isVisible");
10
+ _v_c_util_dist_Dom_isVisible = require_rolldown_runtime.__toESM(_v_c_util_dist_Dom_isVisible);
9
11
  function getUnitOffset(size, offset = 0) {
10
12
  const offsetStr = `${offset}`;
11
13
  const cells = offsetStr.match(/^(.*)\%$/);
@@ -42,50 +44,12 @@ function reversePoints(points, index) {
42
44
  l: "r",
43
45
  r: "l"
44
46
  };
45
- return points.map((point, i) => {
46
- if (i === index) return reverseMap[point] || "c";
47
- return point;
48
- }).join("");
47
+ const clone = [...points];
48
+ clone[index] = reverseMap[points[index]] || "c";
49
+ return clone;
49
50
  }
50
- function parseOriginValue(value, size, axis) {
51
- const fallback = size / 2;
52
- if (!value) return fallback;
53
- const val = value.trim();
54
- if (!val) return fallback;
55
- if (val.endsWith("%")) return size * (parseFloat(val) / 100);
56
- if (val.endsWith("px")) return parseFloat(val);
57
- if (val === "center") return fallback;
58
- if (axis === "x") {
59
- if (val === "left") return 0;
60
- if (val === "right") return size;
61
- } else if (axis === "y") {
62
- if (val === "top") return 0;
63
- if (val === "bottom") return size;
64
- }
65
- const num = parseFloat(val);
66
- return Number.isNaN(num) ? fallback : num;
67
- }
68
- function getTransformOriginPoint(origin, width, height) {
69
- const [originX = "50%", originY = "50%"] = origin?.split(/\s+/).filter(Boolean) ?? [];
70
- return [parseOriginValue(originX, width, "x"), parseOriginValue(originY, height, "y")];
71
- }
72
- function normalizeRect(rect, scaleX, scaleY, originX, originY) {
73
- const rawX = rect.x ?? rect.left;
74
- const rawY = rect.y ?? rect.top;
75
- const width = rect.width / scaleX;
76
- const height = rect.height / scaleY;
77
- const x = rawX - (1 - scaleX) * originX;
78
- const y = rawY - (1 - scaleY) * originY;
79
- return {
80
- x,
81
- y,
82
- width,
83
- height,
84
- left: x,
85
- top: y,
86
- right: x + width,
87
- bottom: y + height
88
- };
51
+ function flatPoints(points) {
52
+ return points.join("");
89
53
  }
90
54
  function shouldSwitchPlacement(isOverflow, isVisibleFirst, newVisibleArea, originVisibleArea, newRecommendArea, originRecommendArea) {
91
55
  if (isOverflow) return newVisibleArea > originVisibleArea || newVisibleArea === originVisibleArea && (!isVisibleFirst || newRecommendArea >= originRecommendArea);
@@ -113,7 +77,9 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
113
77
  const resetFlipCache = () => {
114
78
  prevFlipRef.value = {};
115
79
  };
116
- const _onAlign = () => {
80
+ let cacheTargetRect = null;
81
+ const _onAlign = (cache = false) => {
82
+ if (cache && !cacheTargetRect) return;
117
83
  if (popupEle.value && target.value && open.value && !mobile?.value) {
118
84
  const popupElement = popupEle.value;
119
85
  const doc = popupElement.ownerDocument;
@@ -148,7 +114,12 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
148
114
  height: 0
149
115
  };
150
116
  else {
151
- const rect = target.value.getBoundingClientRect();
117
+ const targetRectInfo = target.value.getBoundingClientRect();
118
+ const rect = cache ? Object.assign(targetRectInfo, cacheTargetRect ?? {}) : targetRectInfo;
119
+ if (!cache) cacheTargetRect = {
120
+ width: rect.width,
121
+ height: rect.height
122
+ };
152
123
  rect.x = rect.x ?? rect.left;
153
124
  rect.y = rect.y ?? rect.top;
154
125
  targetRect = {
@@ -194,20 +165,16 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
194
165
  popupElement.style.bottom = originBottom;
195
166
  popupElement.style.overflow = originOverflow;
196
167
  popupElement.parentElement?.removeChild(placeholderElement);
197
- const widthValue = parseFloat(popupComputedStyle.width);
198
- const heightValue = parseFloat(popupComputedStyle.height);
199
- const baseWidth = !Number.isNaN(widthValue) && widthValue > 0 ? widthValue : popupElement.offsetWidth;
200
- const baseHeight = !Number.isNaN(heightValue) && heightValue > 0 ? heightValue : popupElement.offsetHeight;
201
- const safeBaseWidth = baseWidth || rawPopupRect.width || 1;
202
- const safeBaseHeight = baseHeight || rawPopupRect.height || 1;
203
- const scaleX$1 = require_util.toNum(Math.round(rawPopupRect.width / safeBaseWidth * 1e3) / 1e3);
204
- const scaleY$1 = require_util.toNum(Math.round(rawPopupRect.height / safeBaseHeight * 1e3) / 1e3);
205
- if (scaleX$1 === 0 || scaleY$1 === 0 || (0, __v_c_util_dist_Dom_findDOMNode.isDOM)(target) && !(0, __v_c_util_dist_Dom_isVisible.default)(target)) return;
206
- const [originX, originY] = getTransformOriginPoint(popupComputedStyle.transformOrigin, safeBaseWidth, safeBaseHeight);
207
- const popupRect = normalizeRect(rawPopupRect, scaleX$1, scaleY$1, originX, originY);
208
- const popupMirrorRect = normalizeRect(rawPopupMirrorRect, scaleX$1, scaleY$1, originX, originY);
168
+ const popupRect = rawPopupRect;
169
+ popupRect.x = popupRect.x ?? popupRect.left;
170
+ popupRect.y = popupRect.y ?? popupRect.top;
171
+ const { height, width } = popupComputedStyle;
209
172
  const popupHeight = popupRect.height;
210
173
  const popupWidth = popupRect.width;
174
+ const popupMirrorRect = rawPopupMirrorRect;
175
+ const scaleX$1 = require_util.toNum(Math.floor(popupWidth / parseFloat(width) * 1e3) / 1e3);
176
+ const scaleY$1 = require_util.toNum(Math.floor(popupHeight / parseFloat(height) * 1e3) / 1e3);
177
+ if (scaleX$1 === 0 || scaleY$1 === 0 || (0, _v_c_util_dist_Dom_findDOMNode.isDOM)(target) && !(0, _v_c_util_dist_Dom_isVisible.default)(target)) return;
211
178
  const { offset, targetOffset } = placementInfo;
212
179
  let [popupOffsetX, popupOffsetY] = getNumberOffset(popupRect, offset);
213
180
  const [targetOffsetX, targetOffsetY] = getNumberOffset(targetRect, targetOffset);
@@ -219,6 +186,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
219
186
  const targetAlignPoint = getAlignPoint(targetRect, targetPoints);
220
187
  const popupAlignPoint = getAlignPoint(popupRect, popupPoints);
221
188
  const nextAlignInfo = { ...placementInfo };
189
+ let nextPoints = [popupPoints, targetPoints];
222
190
  let nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX;
223
191
  let nextOffsetY = targetAlignPoint.y - popupAlignPoint.y + popupOffsetY;
224
192
  function getIntersectionVisibleArea(offsetX$1, offsetY$1, area = visibleArea) {
@@ -265,7 +233,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
265
233
  prevFlipRef.value.bt = true;
266
234
  nextOffsetY = tmpNextOffsetY;
267
235
  popupOffsetY = -popupOffsetY;
268
- nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
236
+ nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
269
237
  } else prevFlipRef.value.bt = false;
270
238
  }
271
239
  const overflowTop = nextPopupY < adjustCheckVisibleArea.top;
@@ -277,7 +245,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
277
245
  prevFlipRef.value.tb = true;
278
246
  nextOffsetY = tmpNextOffsetY;
279
247
  popupOffsetY = -popupOffsetY;
280
- nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
248
+ nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
281
249
  } else prevFlipRef.value.tb = false;
282
250
  }
283
251
  const needAdjustX = supportAdjust(adjustX);
@@ -291,7 +259,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
291
259
  prevFlipRef.value.rl = true;
292
260
  nextOffsetX = tmpNextOffsetX;
293
261
  popupOffsetX = -popupOffsetX;
294
- nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
262
+ nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
295
263
  } else prevFlipRef.value.rl = false;
296
264
  }
297
265
  const overflowLeft = nextPopupX < adjustCheckVisibleArea.left;
@@ -303,9 +271,10 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
303
271
  prevFlipRef.value.lr = true;
304
272
  nextOffsetX = tmpNextOffsetX;
305
273
  popupOffsetX = -popupOffsetX;
306
- nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
274
+ nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
307
275
  } else prevFlipRef.value.lr = false;
308
276
  }
277
+ nextAlignInfo.points = [flatPoints(nextPoints[0]), flatPoints(nextPoints[1])];
309
278
  syncNextPopupPosition();
310
279
  const numShiftX = shiftX === true ? 0 : shiftX;
311
280
  if (typeof numShiftX === "number") {
@@ -343,21 +312,21 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
343
312
  let offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
344
313
  let offsetY4Bottom = popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
345
314
  if (scaleX$1 === 1) {
346
- nextOffsetX = Math.round(nextOffsetX);
347
- offsetX4Right = Math.round(offsetX4Right);
315
+ nextOffsetX = Math.floor(nextOffsetX);
316
+ offsetX4Right = Math.floor(offsetX4Right);
348
317
  }
349
318
  if (scaleY$1 === 1) {
350
- nextOffsetY = Math.round(nextOffsetY);
351
- offsetY4Bottom = Math.round(offsetY4Bottom);
319
+ nextOffsetY = Math.floor(nextOffsetY);
320
+ offsetY4Bottom = Math.floor(offsetY4Bottom);
352
321
  }
353
322
  const nextOffsetInfo = {
354
323
  ready: true,
355
- offsetX: nextOffsetX,
356
- offsetY: nextOffsetY,
357
- offsetR: offsetX4Right,
358
- offsetB: offsetY4Bottom,
359
- arrowX: nextArrowX,
360
- arrowY: nextArrowY,
324
+ offsetX: nextOffsetX / scaleX$1,
325
+ offsetY: nextOffsetY / scaleY$1,
326
+ offsetR: offsetX4Right / scaleX$1,
327
+ offsetB: offsetY4Bottom / scaleY$1,
328
+ arrowX: nextArrowX / scaleX$1,
329
+ arrowY: nextArrowY / scaleY$1,
361
330
  scaleX: scaleX$1,
362
331
  scaleY: scaleY$1,
363
332
  align: nextAlignInfo
@@ -365,12 +334,12 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
365
334
  Object.assign(offsetInfo, nextOffsetInfo);
366
335
  }
367
336
  };
368
- const onAlign = (0, __v_c_util_dist_raf.rafDebounce)(_onAlign);
369
- const triggerAlign = () => {
337
+ const onAlign = _onAlign;
338
+ const triggerAlign = (cache) => {
370
339
  alignCountRef.value += 1;
371
340
  const id = alignCountRef.value;
372
341
  Promise.resolve().then(() => {
373
- if (alignCountRef.value === id) onAlign();
342
+ if (alignCountRef.value === id) onAlign(cache);
374
343
  });
375
344
  };
376
345
  (0, vue.watch)(popupEle, async (ele) => {
@@ -1,4 +1,4 @@
1
1
  import { Ref } from 'vue';
2
2
  import { TriggerProps } from '../index.tsx';
3
3
  import { AlignType } from '../interface';
4
- export default function useAlign(open: Ref<boolean>, popupEle: Ref<HTMLElement>, target: Ref<HTMLElement | [x: number, y: number]>, placement: Ref<string>, builtinPlacements: Ref<any>, popupAlign?: Ref<AlignType | undefined>, onPopupAlign?: TriggerProps['onPopupAlign'], mobile?: Ref<boolean | undefined>): readonly [Ref<boolean, boolean>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<any, any>, () => void];
4
+ export default function useAlign(open: Ref<boolean>, popupEle: Ref<HTMLElement>, target: Ref<HTMLElement | [x: number, y: number]>, placement: Ref<string>, builtinPlacements: Ref<any>, popupAlign?: Ref<AlignType | undefined>, onPopupAlign?: TriggerProps['onPopupAlign'], mobile?: Ref<boolean | undefined>): readonly [Ref<boolean, boolean>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<number, number>, Ref<any, any>, (cache?: boolean) => void];
@@ -2,7 +2,6 @@ import { collectScroller, getVisibleArea, getWin, toNum } from "../util.js";
2
2
  import { computed, nextTick, reactive, ref, shallowRef, toRefs, watch } from "vue";
3
3
  import { isDOM } from "@v-c/util/dist/Dom/findDOMNode";
4
4
  import isVisible from "@v-c/util/dist/Dom/isVisible";
5
- import { rafDebounce } from "@v-c/util/dist/raf";
6
5
  function getUnitOffset(size, offset = 0) {
7
6
  const offsetStr = `${offset}`;
8
7
  const cells = offsetStr.match(/^(.*)\%$/);
@@ -39,50 +38,12 @@ function reversePoints(points, index) {
39
38
  l: "r",
40
39
  r: "l"
41
40
  };
42
- return points.map((point, i) => {
43
- if (i === index) return reverseMap[point] || "c";
44
- return point;
45
- }).join("");
41
+ const clone = [...points];
42
+ clone[index] = reverseMap[points[index]] || "c";
43
+ return clone;
46
44
  }
47
- function parseOriginValue(value, size, axis) {
48
- const fallback = size / 2;
49
- if (!value) return fallback;
50
- const val = value.trim();
51
- if (!val) return fallback;
52
- if (val.endsWith("%")) return size * (parseFloat(val) / 100);
53
- if (val.endsWith("px")) return parseFloat(val);
54
- if (val === "center") return fallback;
55
- if (axis === "x") {
56
- if (val === "left") return 0;
57
- if (val === "right") return size;
58
- } else if (axis === "y") {
59
- if (val === "top") return 0;
60
- if (val === "bottom") return size;
61
- }
62
- const num = parseFloat(val);
63
- return Number.isNaN(num) ? fallback : num;
64
- }
65
- function getTransformOriginPoint(origin, width, height) {
66
- const [originX = "50%", originY = "50%"] = origin?.split(/\s+/).filter(Boolean) ?? [];
67
- return [parseOriginValue(originX, width, "x"), parseOriginValue(originY, height, "y")];
68
- }
69
- function normalizeRect(rect, scaleX, scaleY, originX, originY) {
70
- const rawX = rect.x ?? rect.left;
71
- const rawY = rect.y ?? rect.top;
72
- const width = rect.width / scaleX;
73
- const height = rect.height / scaleY;
74
- const x = rawX - (1 - scaleX) * originX;
75
- const y = rawY - (1 - scaleY) * originY;
76
- return {
77
- x,
78
- y,
79
- width,
80
- height,
81
- left: x,
82
- top: y,
83
- right: x + width,
84
- bottom: y + height
85
- };
45
+ function flatPoints(points) {
46
+ return points.join("");
86
47
  }
87
48
  function shouldSwitchPlacement(isOverflow, isVisibleFirst, newVisibleArea, originVisibleArea, newRecommendArea, originRecommendArea) {
88
49
  if (isOverflow) return newVisibleArea > originVisibleArea || newVisibleArea === originVisibleArea && (!isVisibleFirst || newRecommendArea >= originRecommendArea);
@@ -110,7 +71,9 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
110
71
  const resetFlipCache = () => {
111
72
  prevFlipRef.value = {};
112
73
  };
113
- const _onAlign = () => {
74
+ let cacheTargetRect = null;
75
+ const _onAlign = (cache = false) => {
76
+ if (cache && !cacheTargetRect) return;
114
77
  if (popupEle.value && target.value && open.value && !mobile?.value) {
115
78
  const popupElement = popupEle.value;
116
79
  const doc = popupElement.ownerDocument;
@@ -145,7 +108,12 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
145
108
  height: 0
146
109
  };
147
110
  else {
148
- const rect = target.value.getBoundingClientRect();
111
+ const targetRectInfo = target.value.getBoundingClientRect();
112
+ const rect = cache ? Object.assign(targetRectInfo, cacheTargetRect ?? {}) : targetRectInfo;
113
+ if (!cache) cacheTargetRect = {
114
+ width: rect.width,
115
+ height: rect.height
116
+ };
149
117
  rect.x = rect.x ?? rect.left;
150
118
  rect.y = rect.y ?? rect.top;
151
119
  targetRect = {
@@ -191,20 +159,16 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
191
159
  popupElement.style.bottom = originBottom;
192
160
  popupElement.style.overflow = originOverflow;
193
161
  popupElement.parentElement?.removeChild(placeholderElement);
194
- const widthValue = parseFloat(popupComputedStyle.width);
195
- const heightValue = parseFloat(popupComputedStyle.height);
196
- const baseWidth = !Number.isNaN(widthValue) && widthValue > 0 ? widthValue : popupElement.offsetWidth;
197
- const baseHeight = !Number.isNaN(heightValue) && heightValue > 0 ? heightValue : popupElement.offsetHeight;
198
- const safeBaseWidth = baseWidth || rawPopupRect.width || 1;
199
- const safeBaseHeight = baseHeight || rawPopupRect.height || 1;
200
- const scaleX$1 = toNum(Math.round(rawPopupRect.width / safeBaseWidth * 1e3) / 1e3);
201
- const scaleY$1 = toNum(Math.round(rawPopupRect.height / safeBaseHeight * 1e3) / 1e3);
202
- if (scaleX$1 === 0 || scaleY$1 === 0 || isDOM(target) && !isVisible(target)) return;
203
- const [originX, originY] = getTransformOriginPoint(popupComputedStyle.transformOrigin, safeBaseWidth, safeBaseHeight);
204
- const popupRect = normalizeRect(rawPopupRect, scaleX$1, scaleY$1, originX, originY);
205
- const popupMirrorRect = normalizeRect(rawPopupMirrorRect, scaleX$1, scaleY$1, originX, originY);
162
+ const popupRect = rawPopupRect;
163
+ popupRect.x = popupRect.x ?? popupRect.left;
164
+ popupRect.y = popupRect.y ?? popupRect.top;
165
+ const { height, width } = popupComputedStyle;
206
166
  const popupHeight = popupRect.height;
207
167
  const popupWidth = popupRect.width;
168
+ const popupMirrorRect = rawPopupMirrorRect;
169
+ const scaleX$1 = toNum(Math.floor(popupWidth / parseFloat(width) * 1e3) / 1e3);
170
+ const scaleY$1 = toNum(Math.floor(popupHeight / parseFloat(height) * 1e3) / 1e3);
171
+ if (scaleX$1 === 0 || scaleY$1 === 0 || isDOM(target) && !isVisible(target)) return;
208
172
  const { offset, targetOffset } = placementInfo;
209
173
  let [popupOffsetX, popupOffsetY] = getNumberOffset(popupRect, offset);
210
174
  const [targetOffsetX, targetOffsetY] = getNumberOffset(targetRect, targetOffset);
@@ -216,6 +180,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
216
180
  const targetAlignPoint = getAlignPoint(targetRect, targetPoints);
217
181
  const popupAlignPoint = getAlignPoint(popupRect, popupPoints);
218
182
  const nextAlignInfo = { ...placementInfo };
183
+ let nextPoints = [popupPoints, targetPoints];
219
184
  let nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX;
220
185
  let nextOffsetY = targetAlignPoint.y - popupAlignPoint.y + popupOffsetY;
221
186
  function getIntersectionVisibleArea(offsetX$1, offsetY$1, area = visibleArea) {
@@ -262,7 +227,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
262
227
  prevFlipRef.value.bt = true;
263
228
  nextOffsetY = tmpNextOffsetY;
264
229
  popupOffsetY = -popupOffsetY;
265
- nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
230
+ nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
266
231
  } else prevFlipRef.value.bt = false;
267
232
  }
268
233
  const overflowTop = nextPopupY < adjustCheckVisibleArea.top;
@@ -274,7 +239,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
274
239
  prevFlipRef.value.tb = true;
275
240
  nextOffsetY = tmpNextOffsetY;
276
241
  popupOffsetY = -popupOffsetY;
277
- nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
242
+ nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
278
243
  } else prevFlipRef.value.tb = false;
279
244
  }
280
245
  const needAdjustX = supportAdjust(adjustX);
@@ -288,7 +253,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
288
253
  prevFlipRef.value.rl = true;
289
254
  nextOffsetX = tmpNextOffsetX;
290
255
  popupOffsetX = -popupOffsetX;
291
- nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
256
+ nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
292
257
  } else prevFlipRef.value.rl = false;
293
258
  }
294
259
  const overflowLeft = nextPopupX < adjustCheckVisibleArea.left;
@@ -300,9 +265,10 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
300
265
  prevFlipRef.value.lr = true;
301
266
  nextOffsetX = tmpNextOffsetX;
302
267
  popupOffsetX = -popupOffsetX;
303
- nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
268
+ nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
304
269
  } else prevFlipRef.value.lr = false;
305
270
  }
271
+ nextAlignInfo.points = [flatPoints(nextPoints[0]), flatPoints(nextPoints[1])];
306
272
  syncNextPopupPosition();
307
273
  const numShiftX = shiftX === true ? 0 : shiftX;
308
274
  if (typeof numShiftX === "number") {
@@ -340,21 +306,21 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
340
306
  let offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
341
307
  let offsetY4Bottom = popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
342
308
  if (scaleX$1 === 1) {
343
- nextOffsetX = Math.round(nextOffsetX);
344
- offsetX4Right = Math.round(offsetX4Right);
309
+ nextOffsetX = Math.floor(nextOffsetX);
310
+ offsetX4Right = Math.floor(offsetX4Right);
345
311
  }
346
312
  if (scaleY$1 === 1) {
347
- nextOffsetY = Math.round(nextOffsetY);
348
- offsetY4Bottom = Math.round(offsetY4Bottom);
313
+ nextOffsetY = Math.floor(nextOffsetY);
314
+ offsetY4Bottom = Math.floor(offsetY4Bottom);
349
315
  }
350
316
  const nextOffsetInfo = {
351
317
  ready: true,
352
- offsetX: nextOffsetX,
353
- offsetY: nextOffsetY,
354
- offsetR: offsetX4Right,
355
- offsetB: offsetY4Bottom,
356
- arrowX: nextArrowX,
357
- arrowY: nextArrowY,
318
+ offsetX: nextOffsetX / scaleX$1,
319
+ offsetY: nextOffsetY / scaleY$1,
320
+ offsetR: offsetX4Right / scaleX$1,
321
+ offsetB: offsetY4Bottom / scaleY$1,
322
+ arrowX: nextArrowX / scaleX$1,
323
+ arrowY: nextArrowY / scaleY$1,
358
324
  scaleX: scaleX$1,
359
325
  scaleY: scaleY$1,
360
326
  align: nextAlignInfo
@@ -362,12 +328,12 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
362
328
  Object.assign(offsetInfo, nextOffsetInfo);
363
329
  }
364
330
  };
365
- const onAlign = rafDebounce(_onAlign);
366
- const triggerAlign = () => {
331
+ const onAlign = _onAlign;
332
+ const triggerAlign = (cache) => {
367
333
  alignCountRef.value += 1;
368
334
  const id = alignCountRef.value;
369
335
  Promise.resolve().then(() => {
370
- if (alignCountRef.value === id) onAlign();
336
+ if (alignCountRef.value === id) onAlign(cache);
371
337
  });
372
338
  };
373
339
  watch(popupEle, async (ele) => {
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
6
  let vue = require("vue");
4
7
  function useDelay() {
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
6
  let vue = require("vue");
4
7
  function useOffsetStyle(isMobile, ready, open, align, offsetR, offsetB, offsetX, offsetY) {
@@ -10,7 +13,7 @@ function useOffsetStyle(isMobile, ready, open, align, offsetR, offsetB, offsetX,
10
13
  right: AUTO,
11
14
  bottom: AUTO
12
15
  };
13
- if (!(offsetX.value > 0 || offsetY.value > 0 || offsetR.value > 0 || offsetB.value > 0)) return {};
16
+ if (!ready.value && open.value) return {};
14
17
  if (!isMobile.value && (ready.value || !open.value)) {
15
18
  const { points } = align.value ?? {};
16
19
  const dynamicInset = align.value?.dynamicInset || align.value?._experimental?.dynamicInset;
@@ -8,7 +8,7 @@ function useOffsetStyle(isMobile, ready, open, align, offsetR, offsetB, offsetX,
8
8
  right: AUTO,
9
9
  bottom: AUTO
10
10
  };
11
- if (!(offsetX.value > 0 || offsetY.value > 0 || offsetR.value > 0 || offsetB.value > 0)) return {};
11
+ if (!ready.value && open.value) return {};
12
12
  if (!isMobile.value && (ready.value || !open.value)) {
13
13
  const { points } = align.value ?? {};
14
14
  const dynamicInset = align.value?.dynamicInset || align.value?._experimental?.dynamicInset;
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
6
  const require_util = require("../util.cjs");
4
7
  let vue = require("vue");
@@ -1,9 +1,12 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
6
  const require_util = require("../util.cjs");
4
7
  let vue = require("vue");
5
- let __v_c_util = require("@v-c/util");
6
- let __v_c_util_dist_Dom_shadow = require("@v-c/util/dist/Dom/shadow");
8
+ let _v_c_util = require("@v-c/util");
9
+ let _v_c_util_dist_Dom_shadow = require("@v-c/util/dist/Dom/shadow");
7
10
  function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable, inPopupOrChild, triggerOpen) {
8
11
  const openRef = (0, vue.shallowRef)(open.value);
9
12
  (0, vue.watchEffect)(() => {
@@ -28,7 +31,7 @@ function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable,
28
31
  win.addEventListener("pointerdown", onPointerDown, true);
29
32
  win.addEventListener("mousedown", onTriggerClose, true);
30
33
  win.addEventListener("contextmenu", onTriggerClose, true);
31
- const targetShadowRoot = (0, __v_c_util_dist_Dom_shadow.getShadowRoot)(targetEle$1);
34
+ const targetShadowRoot = (0, _v_c_util_dist_Dom_shadow.getShadowRoot)(targetEle$1);
32
35
  if (targetShadowRoot) {
33
36
  targetShadowRoot.addEventListener("mousedown", onTriggerClose, true);
34
37
  targetShadowRoot.addEventListener("contextmenu", onTriggerClose, true);
@@ -36,7 +39,7 @@ function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable,
36
39
  if (process.env.NODE_ENV !== "production" && targetEle$1) {
37
40
  const targetRoot = targetEle$1.getRootNode?.();
38
41
  const popupRoot = popupEle$1.getRootNode?.();
39
- (0, __v_c_util.warning)(targetRoot === popupRoot, `trigger element and popup element should in same shadow root.`);
42
+ (0, _v_c_util.warning)(targetRoot === popupRoot, `trigger element and popup element should in same shadow root.`);
40
43
  }
41
44
  onCleanup(() => {
42
45
  win.removeEventListener("pointerdown", onPointerDown, true);