shineout 3.9.4 → 3.9.5-beta.2

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/cjs/index.js CHANGED
@@ -522,5 +522,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
522
522
  // 此文件由脚本自动生成,请勿直接修改。
523
523
  // This file was generated automatically by a script. Please do not modify it directly.
524
524
  var _default = exports.default = {
525
- version: '3.9.4'
525
+ version: '3.9.5-beta.2'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12401,7 +12401,7 @@ var handleStyle = function handleStyle(style) {
12401
12401
  };
12402
12402
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12403
12403
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12404
- /* harmony default export */ var version = ('3.9.4');
12404
+ /* harmony default export */ var version = ('3.9.5-beta.2');
12405
12405
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12406
12406
 
12407
12407
 
@@ -31586,50 +31586,46 @@ function shallowEqualExceptFalsely(objA, objB) {
31586
31586
  }
31587
31587
  /* harmony default export */ var shallow_equal = (shallowEqual);
31588
31588
  ;// CONCATENATED MODULE: ../hooks/src/utils/dom/document.ts
31589
- var cachedZoom = 0;
31590
- var getCurrentCSSZoom = function getCurrentCSSZoom() {
31591
- if (cachedZoom) return cachedZoom;
31592
- if (typeof window === 'undefined' || typeof navigator === 'undefined' || !document.body) {
31593
- return 1;
31594
- }
31595
- var currentCSSZoom = Math.round(document.body.getBoundingClientRect().width) / document.body.clientWidth;
31596
- if (window.ResizeObserver) {
31597
- // 监听document.body的变化,更新缓存的zoom
31598
- var resizeObserver = new ResizeObserver(function () {
31599
- cachedZoom = Math.round(document.body.getBoundingClientRect().width) / document.body.clientWidth;
31600
- });
31601
- resizeObserver.observe(document.body);
31602
- }
31603
- cachedZoom = currentCSSZoom;
31604
- return currentCSSZoom;
31605
- };
31589
+ // 缓存容器的 zoom 值,避免重复计算
31590
+ // 使用 WeakMap 确保容器元素被销毁时缓存也会被清理
31591
+ var zoomCache = new WeakMap();
31606
31592
 
31607
- // export const getZoomBoundingClientRect = (element: HTMLElement) => {
31608
- // const currentCSSZoom = getCurrentCSSZoom()
31609
- // if (currentCSSZoom === 1 || !currentCSSZoom) {
31610
- // return element.getBoundingClientRect()
31611
- // }
31612
- // const isNotZoom = currentCSSZoom === 1 || !currentCSSZoom
31613
-
31614
- // if (isNotZoom) {
31615
- // return element.getBoundingClientRect()
31616
- // }
31593
+ /**
31594
+ * 计算容器的累积 zoom 值
31595
+ * 当弹出层通过 position: absolute 定位在容器内时,需要用容器的 zoom 值来修正坐标
31596
+ * 因为 getBoundingClientRect() 返回的是应用 zoom 后的视口坐标,
31597
+ * 但 CSS 的 left/top 值会在容器的 zoom 坐标系中解释
31598
+ * @param container - 容器元素,默认为 document.body
31599
+ * @returns 容器的累积 zoom 值
31600
+ */
31601
+ var getRelativeZoom = function getRelativeZoom(_element) {
31602
+ var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.body;
31603
+ if (!container || typeof window === 'undefined') return 1;
31617
31604
 
31618
- // const zoomRatio = 1 / currentCSSZoom
31619
- // const rect = element.getBoundingClientRect()
31605
+ // 检查缓存
31606
+ var cached = zoomCache.get(container);
31607
+ if (cached !== undefined) {
31608
+ return cached;
31609
+ }
31610
+ var zoom = 1;
31611
+ var current = container;
31620
31612
 
31621
- // return {
31622
- // x: rect.x * zoomRatio,
31623
- // y: rect.y * zoomRatio,
31624
- // top: rect.top * zoomRatio,
31625
- // right: rect.right * zoomRatio,
31626
- // bottom: rect.bottom * zoomRatio,
31627
- // left: rect.left * zoomRatio,
31628
- // width: rect.width * zoomRatio,
31629
- // height: rect.height * zoomRatio,
31630
- // }
31631
- // }
31613
+ // 从容器向上遍历到 document,累积所有的 zoom 值
31614
+ while (current && current !== document.documentElement) {
31615
+ var computedStyle = window.getComputedStyle(current);
31616
+ // zoom 不是标准 CSS 属性,需要通过索引访问
31617
+ var zoomValue = computedStyle.zoom || '1';
31618
+ var currentZoom = parseFloat(zoomValue);
31619
+ if (!isNaN(currentZoom) && currentZoom !== 0) {
31620
+ zoom *= currentZoom;
31621
+ }
31622
+ current = current.parentElement;
31623
+ }
31632
31624
 
31625
+ // 缓存计算结果
31626
+ zoomCache.set(container, zoom);
31627
+ return zoom;
31628
+ };
31633
31629
  var getScrollPosition = function getScrollPosition(element) {
31634
31630
  if (!element) return {
31635
31631
  scrollTop: 0,
@@ -31967,19 +31963,23 @@ var usePositionStyle = function usePositionStyle(config) {
31967
31963
  }
31968
31964
  var _getAbsolutePositionS = getAbsolutePositionStyle(rect, position),
31969
31965
  style = _getAbsolutePositionS.style;
31970
- var currentCSSZoom = getCurrentCSSZoom();
31971
- if (currentCSSZoom && currentCSSZoom !== 1) {
31966
+
31967
+ // 计算从触发元素到挂载容器之间的相对 zoom
31968
+ var rootContainer = getContainer() || document.body;
31969
+ var relativeZoom = getRelativeZoom(parentElRef.current, rootContainer);
31970
+ if (relativeZoom && relativeZoom !== 1) {
31971
+ var zoomRatio = 1 / relativeZoom;
31972
31972
  if (style.left && typeof style.left === 'number') {
31973
- style.left = style.left * (1 / currentCSSZoom);
31973
+ style.left = style.left * zoomRatio;
31974
31974
  }
31975
31975
  if (style.top && typeof style.top === 'number') {
31976
- style.top = style.top * (1 / currentCSSZoom);
31976
+ style.top = style.top * zoomRatio;
31977
31977
  }
31978
31978
  if (style.right && typeof style.right === 'number') {
31979
- style.right = style.right * (1 / currentCSSZoom);
31979
+ style.right = style.right * zoomRatio;
31980
31980
  }
31981
31981
  if (style.bottom && typeof style.bottom === 'number') {
31982
- style.bottom = style.bottom * (1 / currentCSSZoom);
31982
+ style.bottom = style.bottom * zoomRatio;
31983
31983
  }
31984
31984
  }
31985
31985
  return {
@@ -59831,7 +59831,7 @@ var usePagination = function usePagination(props) {
59831
59831
  var handleChange = usePersistFn(function (c, size) {
59832
59832
  if (c === current && size === undefined) return;
59833
59833
  setCurrent(c);
59834
- setPageSize(size || pageSizeProp);
59834
+ setPageSize(size || pageSize);
59835
59835
  if (onChange) {
59836
59836
  var sizeChange = size !== undefined && pageSize !== size;
59837
59837
  onChange(c, size || pageSize, sizeChange);
@@ -74772,7 +74772,7 @@ var upload_interface = __webpack_require__(8821);
74772
74772
 
74773
74773
 
74774
74774
  /* harmony default export */ var src_0 = ({
74775
- version: '3.9.4'
74775
+ version: '3.9.5-beta.2'
74776
74776
  });
74777
74777
  }();
74778
74778
  /******/ return __webpack_exports__;