shineout 3.6.4-beta.7 → 3.6.4-beta.8

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
@@ -514,5 +514,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
514
514
  // 此文件由脚本自动生成,请勿直接修改。
515
515
  // This file was generated automatically by a script. Please do not modify it directly.
516
516
  var _default = exports.default = {
517
- version: '3.6.4-beta.7'
517
+ version: '3.6.4-beta.8'
518
518
  };
package/dist/shineout.js CHANGED
@@ -12217,7 +12217,7 @@ var handleStyle = function handleStyle(style) {
12217
12217
  };
12218
12218
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12219
12219
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12220
- /* harmony default export */ var version = ('3.6.4-beta.7');
12220
+ /* harmony default export */ var version = ('3.6.4-beta.8');
12221
12221
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12222
12222
 
12223
12223
 
@@ -30383,6 +30383,61 @@ var useCheckElementBorderWidth = function useCheckElementBorderWidth(elementRef)
30383
30383
  }, [getBorderWidth]);
30384
30384
  return borderWidth;
30385
30385
  };
30386
+ ;// CONCATENATED MODULE: ../hooks/src/common/use-position-style/check-element-size.ts
30387
+
30388
+
30389
+ var useCheckElementSize = function useCheckElementSize(targetElementRef) {
30390
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30391
+ var enable = options.enable;
30392
+ var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({
30393
+ width: 0,
30394
+ height: 0
30395
+ }),
30396
+ _useState2 = slicedToArray_default()(_useState, 2),
30397
+ size = _useState2[0],
30398
+ setSize = _useState2[1];
30399
+ var lastSize = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({
30400
+ width: 0,
30401
+ height: 0
30402
+ });
30403
+ var checkSize = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)(function () {
30404
+ if (targetElementRef.current) {
30405
+ var rect = targetElementRef.current.getBoundingClientRect();
30406
+ var newSize = {
30407
+ width: rect.width,
30408
+ height: rect.height
30409
+ };
30410
+ if (newSize.width !== lastSize.current.width || newSize.height !== lastSize.current.height) {
30411
+ setSize(newSize);
30412
+ lastSize.current = newSize;
30413
+ }
30414
+ }
30415
+ }, [targetElementRef]);
30416
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
30417
+ var _window;
30418
+ if (!enable) return;
30419
+ var element = targetElementRef.current;
30420
+ if (!element) return;
30421
+
30422
+ // 初始检查
30423
+ checkSize();
30424
+ var resizeObserver = null;
30425
+ if ((_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
30426
+ resizeObserver = new ResizeObserver(checkSize);
30427
+ resizeObserver.observe(element);
30428
+ }
30429
+
30430
+ // 清理函数
30431
+ return function () {
30432
+ var _resizeObserver;
30433
+ (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 || _resizeObserver.disconnect();
30434
+ };
30435
+ }, [enable, targetElementRef, checkSize]);
30436
+ if (!enable || !targetElementRef) {
30437
+ return null;
30438
+ }
30439
+ return size;
30440
+ };
30386
30441
  // EXTERNAL MODULE: ../../node_modules/.pnpm/react-fast-compare@3.2.2/node_modules/react-fast-compare/index.js
30387
30442
  var react_fast_compare = __webpack_require__(5284);
30388
30443
  var react_fast_compare_default = /*#__PURE__*/__webpack_require__.n(react_fast_compare);
@@ -30509,6 +30564,7 @@ var getCurrentCSSZoom = function getCurrentCSSZoom() {
30509
30564
 
30510
30565
 
30511
30566
 
30567
+
30512
30568
  var horizontalPosition = ['left-bottom', 'left-top', 'right-bottom', 'right-top', 'left', 'right'];
30513
30569
  var verticalPosition = ['bottom-left', 'bottom-right', 'top-left', 'top-right', 'bottom', 'top'];
30514
30570
  var hideStyle = {
@@ -30563,6 +30619,9 @@ var usePositionStyle = function usePositionStyle(config) {
30563
30619
  var parentElBorderWidth = useCheckElementBorderWidth(parentElRef, {
30564
30620
  direction: 'horizontal'
30565
30621
  });
30622
+ var popupElSize = useCheckElementSize(popupElRef, {
30623
+ enable: show
30624
+ });
30566
30625
  var adjustPosition = function adjustPosition(position) {
30567
30626
  var winHeight = docSize.height;
30568
30627
  if (!verticalPosition.includes(position)) return position;
@@ -30799,7 +30858,7 @@ var usePositionStyle = function usePositionStyle(config) {
30799
30858
  // 当父元素的滚动容器滚动时,判断是否需要更新弹出层位置,包括是否隐藏弹出层(通过hideStyle隐藏,不是show状态)
30800
30859
  context.prevParentPosition = parentElNewPosition;
30801
30860
  });
30802
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(updateStyle, [show, position, absolute, updateKey, fixedWidth, parentElNewPosition]);
30861
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(updateStyle, [show, position, absolute, updateKey, fixedWidth, parentElNewPosition, popupElSize]);
30803
30862
  return {
30804
30863
  style: style
30805
30864
  };
@@ -31592,11 +31651,11 @@ var Popover = function Popover(props) {
31592
31651
  _React$useState2 = slicedToArray_default()(_React$useState, 2),
31593
31652
  updateKey = _React$useState2[0],
31594
31653
  setUpdateKey = _React$useState2[1];
31595
- var handleUpdateKey = function handleUpdateKey() {
31654
+ var handleUpdateKey = usePersistFn(function () {
31596
31655
  setUpdateKey(function (prev) {
31597
31656
  return (prev + 1) % 2;
31598
31657
  });
31599
- };
31658
+ });
31600
31659
  var bindEvents = function bindEvents() {
31601
31660
  var _window;
31602
31661
  var targetEl = targetRef.current;
@@ -31609,9 +31668,9 @@ var Popover = function Popover(props) {
31609
31668
  targetEl.addEventListener('click', closePop);
31610
31669
  }
31611
31670
  (_window = window) === null || _window === void 0 || _window.addEventListener('resize', handleUpdateKey);
31612
- var scrollContainer = getClosestScrollContainer(targetEl);
31613
- if (scrollContainer) {
31614
- scrollContainer.addEventListener('scroll', handleUpdateKey);
31671
+ if (props.adjust) {
31672
+ var scrollContainer = getClosestScrollContainer(targetEl);
31673
+ if (scrollContainer) scrollContainer.addEventListener('scroll', handleUpdateKey);
31615
31674
  }
31616
31675
  };
31617
31676
  var unbindEvents = function unbindEvents() {
@@ -31624,9 +31683,9 @@ var Popover = function Popover(props) {
31624
31683
  if (events.onClick) targetEl.removeEventListener('click', events.onClick);
31625
31684
  targetEl.removeEventListener('click', closePop);
31626
31685
  (_window2 = window) === null || _window2 === void 0 || _window2.removeEventListener('resize', handleUpdateKey);
31627
- var scrollContainer = getClosestScrollContainer(targetEl);
31628
- if (scrollContainer) {
31629
- scrollContainer.addEventListener('scroll', handleUpdateKey);
31686
+ if (props.adjust) {
31687
+ var scrollContainer = getClosestScrollContainer(targetEl);
31688
+ if (scrollContainer) scrollContainer.removeEventListener('scroll', handleUpdateKey);
31630
31689
  }
31631
31690
  };
31632
31691
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
@@ -50235,11 +50294,11 @@ var Tooltip = function Tooltip(props) {
50235
50294
  _React$useState2 = slicedToArray_default()(_React$useState, 2),
50236
50295
  updateKey = _React$useState2[0],
50237
50296
  setUpdateKey = _React$useState2[1];
50238
- var handleUpdateKey = function handleUpdateKey() {
50297
+ var handleUpdateKey = usePersistFn(function () {
50239
50298
  setUpdateKey(function (prev) {
50240
50299
  return (prev + 1) % 2;
50241
50300
  });
50242
- };
50301
+ });
50243
50302
  var bindEvents = function bindEvents() {
50244
50303
  var _window;
50245
50304
  var targetEl = targetRef.current;
@@ -50248,10 +50307,6 @@ var Tooltip = function Tooltip(props) {
50248
50307
  if (events.onMouseLeave) targetEl.addEventListener('mouseleave', events.onMouseLeave);
50249
50308
  if (events.onClick) targetEl.addEventListener('click', events.onClick);
50250
50309
  (_window = window) === null || _window === void 0 || _window.addEventListener('resize', handleUpdateKey);
50251
- var scrollContainer = getClosestScrollContainer(targetEl);
50252
- if (scrollContainer) {
50253
- scrollContainer.addEventListener('scroll', handleUpdateKey);
50254
- }
50255
50310
  };
50256
50311
  var unbindEvents = function unbindEvents() {
50257
50312
  var _window2;
@@ -50263,10 +50318,6 @@ var Tooltip = function Tooltip(props) {
50263
50318
  if (events.onClick) targetEl.removeEventListener('click', events.onClick);
50264
50319
  targetEl.removeEventListener('click', closePop);
50265
50320
  (_window2 = window) === null || _window2 === void 0 || _window2.removeEventListener('resize', handleUpdateKey);
50266
- var scrollContainer = getClosestScrollContainer(targetEl);
50267
- if (scrollContainer) {
50268
- scrollContainer.addEventListener('scroll', handleUpdateKey);
50269
- }
50270
50321
  };
50271
50322
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
50272
50323
  if (!persistent) return;
@@ -69924,7 +69975,7 @@ var upload_interface = __webpack_require__(8821);
69924
69975
 
69925
69976
 
69926
69977
  /* harmony default export */ var src_0 = ({
69927
- version: '3.6.4-beta.7'
69978
+ version: '3.6.4-beta.8'
69928
69979
  });
69929
69980
  }();
69930
69981
  /******/ return __webpack_exports__;