shineout 3.3.6-beta.1 → 3.3.6-beta.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.
package/cjs/index.js CHANGED
@@ -476,5 +476,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
476
476
  // 此文件由脚本自动生成,请勿直接修改。
477
477
  // This file was generated automatically by a script. Please do not modify it directly.
478
478
  var _default = exports.default = {
479
- version: '3.3.6-beta.1'
479
+ version: '3.3.6-beta.3'
480
480
  };
package/dist/shineout.js CHANGED
@@ -11968,7 +11968,7 @@ var handleStyle = function handleStyle(style) {
11968
11968
  };
11969
11969
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
11970
11970
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
11971
- /* harmony default export */ var version = ('3.3.6-beta.1');
11971
+ /* harmony default export */ var version = ('3.3.6-beta.3');
11972
11972
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
11973
11973
 
11974
11974
 
@@ -26045,7 +26045,8 @@ var tooltipStyle = objectSpread2_default()(objectSpread2_default()({}, tooltip_a
26045
26045
  backgroundColor: src.tooltipDangerBackgroundColor,
26046
26046
  color: src.tooltipDangerColor
26047
26047
  },
26048
- '&::before': {
26048
+ // '&::before': {
26049
+ '& $arrow': {
26049
26050
  'z-index': 1,
26050
26051
  position: 'absolute',
26051
26052
  content: '" "',
@@ -26060,19 +26061,13 @@ var tooltipStyle = objectSpread2_default()(objectSpread2_default()({}, tooltip_a
26060
26061
  },
26061
26062
  '&[data-soui-position^="bottom"]': {
26062
26063
  marginTop: arrowGap - 2,
26063
- '&::before': {
26064
- top: '0',
26065
- left: '0',
26066
- right: '0',
26067
- margin: 'auto'
26068
- },
26069
- '&[dir=ltr]::before': {
26064
+ '&[dir=ltr] $arrow': {
26070
26065
  transform: 'translate(0, -50%) rotate(-45deg)'
26071
26066
  },
26072
- '&[dir=rtl]::before': {
26067
+ '&[dir=rtl] $arrow': {
26073
26068
  transform: 'translate(0, -50%) rotate(45deg)'
26074
26069
  },
26075
- '&::after': {
26070
+ '& $arrow::after': {
26076
26071
  top: arrowGap * -1,
26077
26072
  left: '0',
26078
26073
  right: '0',
@@ -26084,105 +26079,105 @@ var tooltipStyle = objectSpread2_default()(objectSpread2_default()({}, tooltip_a
26084
26079
  },
26085
26080
  '&[data-soui-position^="top"]': {
26086
26081
  marginTop: (arrowGap - 2) * -1,
26087
- '&::before': {
26088
- bottom: '0',
26089
- transform: 'translate(0, 50%) rotate(135deg)',
26090
- left: '0',
26091
- right: '0',
26092
- margin: 'auto'
26093
- },
26094
- '&[dir=ltr]::before': {
26082
+ '&[dir=ltr] $arrow': {
26095
26083
  transform: 'translate(0, 50%) rotate(135deg)'
26096
26084
  },
26097
- '&[dir=rtl]::before': {
26085
+ '&[dir=rtl] $arrow': {
26098
26086
  transform: 'translate(0, 50%) rotate(-135deg)'
26099
- },
26100
- '&::after': {
26101
- bottom: arrowGap * -1,
26102
- left: '0',
26103
- right: '0',
26104
- content: '" "',
26105
- display: 'block',
26106
- height: arrowGap,
26107
- position: 'absolute'
26108
26087
  }
26088
+ // '&::before': {
26089
+ // bottom: '0',
26090
+ // transform: 'translate(0, 50%) rotate(135deg)',
26091
+ // left: '0',
26092
+ // right: '0',
26093
+ // margin: 'auto',
26094
+ // },
26095
+ // '&[dir=ltr]::before': {
26096
+ // transform: 'translate(0, 50%) rotate(135deg)',
26097
+ // },
26098
+ // '&[dir=rtl]::before': {
26099
+ // transform: 'translate(0, 50%) rotate(-135deg)',
26100
+ // },
26101
+ // '&::after': {
26102
+ // bottom: arrowGap * -1,
26103
+ // left: '0',
26104
+ // right: '0',
26105
+ // content: '" "',
26106
+ // display: 'block',
26107
+ // height: arrowGap,
26108
+ // position: 'absolute',
26109
+ // },
26109
26110
  },
26110
26111
  '&[data-soui-position^="left"]': {
26111
26112
  marginLeft: (arrowGap - 2) * -1,
26112
- '&[dir=ltr]': {
26113
- marginLeft: (arrowGap - 2) * -1
26114
- },
26115
- '&[dir=rtl]': {
26116
- marginRight: (arrowGap - 2) * -1
26117
- },
26118
- '&::before': {
26119
- right: 0,
26120
- top: '0',
26121
- bottom: '0',
26122
- margin: 'auto'
26123
- },
26124
- '&[dir=ltr]::before': {
26113
+ '&[dir=ltr] $arrow': {
26125
26114
  transform: 'translate(50%, 0) rotate(45deg)'
26126
26115
  },
26127
- '&[dir=rtl]::before': {
26116
+ '&[dir=rtl] $arrow': {
26128
26117
  transform: 'translate(50%, 0) rotate(135deg)'
26129
- },
26130
- '&::after': {
26131
- left: arrowGap * -1,
26132
- top: '0',
26133
- bottom: '0',
26134
- content: '" "',
26135
- display: 'block',
26136
- width: arrowGap,
26137
- position: 'absolute'
26138
26118
  }
26119
+
26120
+ // '&[dir=ltr]': { marginLeft: (arrowGap - 2) * -1 },
26121
+ // '&[dir=rtl]': { marginRight: (arrowGap - 2) * -1 },
26122
+ // '&::before': {
26123
+ // right: 0,
26124
+ // top: '0',
26125
+ // bottom: '0',
26126
+ // margin: 'auto',
26127
+ // },
26128
+ // '&[dir=ltr]::before': {
26129
+ // transform: 'translate(50%, 0) rotate(45deg)',
26130
+ // },
26131
+ // '&[dir=rtl]::before': {
26132
+ // transform: 'translate(50%, 0) rotate(135deg)',
26133
+ // },
26134
+ // '&::after': {
26135
+ // left: arrowGap * -1,
26136
+ // top: '0',
26137
+ // bottom: '0',
26138
+ // content: '" "',
26139
+ // display: 'block',
26140
+ // width: arrowGap,
26141
+ // position: 'absolute',
26142
+ // },
26139
26143
  },
26140
26144
  '&[data-soui-position^="right"]': {
26141
26145
  marginLeft: arrowGap - 2,
26142
- '&[dir=ltr]': {
26143
- marginLeft: arrowGap - 2
26144
- },
26145
- '&[dir=rtl]': {
26146
- marginRight: arrowGap - 2
26147
- },
26148
- '&::before': {
26149
- left: '0',
26150
- top: '0',
26151
- bottom: '0',
26152
- margin: 'auto'
26153
- },
26154
- '&[dir=ltr]::before': {
26146
+ '&[dir=ltr] $arrow': {
26155
26147
  transform: 'translate(-50%, 0) rotate(-135deg)'
26156
26148
  },
26157
- '&[dir=rtl]::before': {
26149
+ '&[dir=rtl] $arrow': {
26158
26150
  transform: 'translate(-50%, 0) rotate(-45deg)'
26159
- },
26160
- '&::after': {
26161
- left: arrowGap * -1,
26162
- top: '0',
26163
- bottom: '0',
26164
- content: '" "',
26165
- display: 'block',
26166
- width: arrowGap,
26167
- position: 'absolute'
26168
26151
  }
26169
- },
26170
- '&&[data-soui-position$="-left"]::before': {
26171
- left: tooltip_arrowMargin,
26172
- right: 'auto'
26173
- },
26174
- '&&[data-soui-position$="-right"]::before': {
26175
- right: tooltip_arrowMargin,
26176
- left: 'auto'
26177
- },
26178
- '&&[data-soui-position$="-top"]::before': {
26179
- top: tooltip_arrowMargin,
26180
- bottom: 'auto'
26181
- },
26182
- '&&[data-soui-position$="-bottom"]::before': {
26183
- bottom: tooltip_arrowMargin,
26184
- top: 'auto'
26152
+
26153
+ // '&[dir=ltr]': { marginLeft: arrowGap - 2 },
26154
+ // '&[dir=rtl]': { marginRight: arrowGap - 2 },
26155
+ // '&::before': {
26156
+ // left: '0',
26157
+ // top: '0',
26158
+ // bottom: '0',
26159
+ // margin: 'auto',
26160
+ // },
26161
+ // '&[dir=ltr]::before': {
26162
+ // transform: 'translate(-50%, 0) rotate(-135deg)',
26163
+ // },
26164
+ // '&[dir=rtl]::before': {
26165
+ // transform: 'translate(-50%, 0) rotate(-45deg)',
26166
+ // },
26167
+ // '&::after': {
26168
+ // left: arrowGap * -1,
26169
+ // top: '0',
26170
+ // bottom: '0',
26171
+ // content: '" "',
26172
+ // display: 'block',
26173
+ // width: arrowGap,
26174
+ // position: 'absolute',
26175
+ // },
26185
26176
  }
26177
+ // '&&[data-soui-position$="-left"]::before': { left: arrowMargin, right: 'auto' },
26178
+ // '&&[data-soui-position$="-right"]::before': { right: arrowMargin, left: 'auto' },
26179
+ // '&&[data-soui-position$="-top"]::before': { top: arrowMargin, bottom: 'auto' },
26180
+ // '&&[data-soui-position$="-bottom"]::before': { bottom: arrowMargin, top: 'auto' },
26186
26181
  },
26187
26182
  wrapperOpen: {
26188
26183
  display: 'block',
@@ -26202,6 +26197,12 @@ var tooltipStyle = objectSpread2_default()(objectSpread2_default()({}, tooltip_a
26202
26197
  target: {
26203
26198
  display: 'inline-block'
26204
26199
  },
26200
+ arrow: {
26201
+ // before
26202
+ '&::before': {
26203
+ content: "''"
26204
+ }
26205
+ },
26205
26206
  content: {
26206
26207
  padding: "".concat(src.tooltipPaddingY, " ").concat(src.tooltipPaddingX),
26207
26208
  fontSize: src.tooltipFontSize
@@ -28308,6 +28309,10 @@ var usePositionStyle = function usePositionStyle(config) {
28308
28309
  _useState2 = slicedToArray_default()(_useState, 2),
28309
28310
  style = _useState2[0],
28310
28311
  setStyle = _useState2[1];
28312
+ var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
28313
+ _useState4 = slicedToArray_default()(_useState3, 2),
28314
+ arrayStyle = _useState4[0],
28315
+ setArrayStyle = _useState4[1];
28311
28316
  var _React$useRef = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef({
28312
28317
  element: null,
28313
28318
  containerRect: {
@@ -28381,10 +28386,12 @@ var usePositionStyle = function usePositionStyle(config) {
28381
28386
  };
28382
28387
  };
28383
28388
  var getAbsolutePositionStyle = function getAbsolutePositionStyle(rect, position) {
28389
+ var _popupElRef$current;
28384
28390
  var style = {
28385
28391
  position: 'absolute',
28386
28392
  zIndex: zIndex
28387
28393
  };
28394
+ var arrayStyle = {};
28388
28395
  if (fixedWidth) {
28389
28396
  var widthKey = fixedWidth === 'min' ? 'minWidth' : 'width';
28390
28397
  style[widthKey] = rect.width;
@@ -28394,6 +28401,7 @@ var usePositionStyle = function usePositionStyle(config) {
28394
28401
  var containerRect = rootContainer.getBoundingClientRect();
28395
28402
  var bodyRect = (document.documentElement || document.body).getBoundingClientRect();
28396
28403
  var containerScrollBarWidth = rootContainer.offsetWidth - rootContainer.clientWidth;
28404
+ var targetRect = (_popupElRef$current = popupElRef.current) === null || _popupElRef$current === void 0 ? void 0 : _popupElRef$current.getBoundingClientRect();
28397
28405
  var containerScroll = {
28398
28406
  left: rootContainer.scrollLeft,
28399
28407
  top: rootContainer.scrollTop
@@ -28410,14 +28418,25 @@ var usePositionStyle = function usePositionStyle(config) {
28410
28418
  if (h === 'left') {
28411
28419
  style.left = rect.left - containerRect.left + containerScroll.left;
28412
28420
  style.transform = '';
28421
+ arrayStyle.left = "8px";
28413
28422
  if (adjust) {
28414
28423
  overRight = rect.left + context.popUpWidth - bodyRect.right + containerScrollBarWidth;
28424
+ if (style.left < 0 && targetRect) {
28425
+ style.left = 'auto';
28426
+ }
28415
28427
  }
28416
28428
  } else if (h === 'right') {
28417
28429
  style.right = containerRect.right - rect.right + containerScrollBarWidth - containerScroll.left;
28418
28430
  style.left = 'auto';
28419
28431
  style.transform = '';
28420
- if (adjust) overLeft = bodyRect.left - (rect.right - context.popUpWidth);
28432
+ arrayStyle.right = "8px";
28433
+ if (adjust) {
28434
+ overLeft = bodyRect.left - (rect.right - context.popUpWidth);
28435
+ if (style.right < 0 && targetRect) {
28436
+ style.left = bodyRect.width - targetRect.width;
28437
+ style.right = 'auto';
28438
+ }
28439
+ }
28421
28440
  } else {
28422
28441
  // 居中对齐
28423
28442
  style.left = rect.left + rect.width / 2 - containerRect.left + containerScroll.left;
@@ -28426,6 +28445,9 @@ var usePositionStyle = function usePositionStyle(config) {
28426
28445
  overRight = rect.left + rect.width / 2 + context.popUpWidth / 2 - bodyRect.width + containerScrollBarWidth;
28427
28446
  overLeft = bodyRect.left - (rect.left + rect.width / 2 - context.popUpWidth / 2);
28428
28447
  }
28448
+ if (targetRect) {
28449
+ arrayStyle.left = "".concat(targetRect.width / 2 - 5.9, "px");
28450
+ }
28429
28451
  }
28430
28452
  if (adjust) {
28431
28453
  // 调节左右溢出
@@ -28434,16 +28456,26 @@ var usePositionStyle = function usePositionStyle(config) {
28434
28456
  style.left -= overRight;
28435
28457
  // 扣除触发器距离页面右侧的距离,以保证从右侧弹出的窗口最右边对齐触发器最右边
28436
28458
  style.left -= toRightDistance;
28459
+ if (targetRect) {
28460
+ arrayStyle.left = "".concat((targetRect === null || targetRect === void 0 ? void 0 : targetRect.width) - context.parentRect.width / 2 - 5.9, "px");
28461
+ }
28437
28462
  }
28438
28463
  if (overLeft > 0) {
28439
28464
  style.left += overLeft;
28465
+ arrayStyle.left = "".concat(rect.width / 2 - 5.9, "px");
28440
28466
  }
28441
28467
  }
28442
28468
  if (v === 'bottom') {
28443
28469
  style.top = rect.bottom - containerRect.top + containerScroll.top + popupGap;
28470
+ if (targetRect) {
28471
+ arrayStyle.top = "".concat(0, "px");
28472
+ }
28444
28473
  } else {
28445
28474
  style.top = rect.top - containerRect.top + containerScroll.top - popupGap;
28446
28475
  style.transform += 'translateY(-100%)';
28476
+ if (targetRect) {
28477
+ arrayStyle.top = "".concat(targetRect.height - 5.9 - 4, "px");
28478
+ }
28447
28479
  }
28448
28480
  } else if (horizontalPosition.includes(targetPosition)) {
28449
28481
  var _targetPosition$split3 = targetPosition.split('-'),
@@ -28453,45 +28485,88 @@ var usePositionStyle = function usePositionStyle(config) {
28453
28485
  if (_v === 'top') {
28454
28486
  style.top = rect.top - containerRect.top + containerScroll.top;
28455
28487
  style.transform = '';
28488
+ arrayStyle.top = "8px";
28456
28489
  } else if (_v === 'bottom') {
28457
28490
  style.top = rect.bottom - containerRect.top + containerScroll.top;
28491
+ arrayStyle.bottom = "8px";
28458
28492
  style.transform = 'translateY(-100%)';
28459
28493
  } else {
28460
28494
  // 居中对齐
28461
28495
  style.top = rect.top - containerRect.top + containerScroll.top + rect.height / 2;
28496
+ if (targetRect) {
28497
+ arrayStyle.top = "".concat(targetRect.height / 2 - 5.9 / 2, "px");
28498
+ }
28462
28499
  style.transform = 'translateY(-50%)';
28463
28500
  }
28464
28501
  if (_h === 'right') {
28465
28502
  style.left = rect.right - containerRect.left + containerScroll.left + popupGap;
28466
28503
  } else {
28467
28504
  style.left = rect.left - containerRect.left + containerScroll.left - popupGap;
28505
+ arrayStyle.right = "0px";
28468
28506
  style.transform += ' translateX(-100%)';
28469
28507
  }
28470
28508
  } else if (position === 'cover') {
28471
28509
  style.top = rect.top - containerRect.top + containerScroll.top;
28472
28510
  style.left = rect.left - containerRect.left + containerScroll.left;
28473
28511
  }
28474
- return style;
28512
+ return {
28513
+ style: style,
28514
+ arrayStyle: arrayStyle
28515
+ };
28475
28516
  };
28476
28517
  var getAbsoluteStyle = function getAbsoluteStyle(position) {
28477
- if (!parentElRef.current) return hideStyle;
28518
+ if (!parentElRef.current) return {
28519
+ style: hideStyle
28520
+ };
28478
28521
  var rect = context.parentRect;
28479
28522
  if (scrollElRef !== null && scrollElRef !== void 0 && scrollElRef.current) {
28480
28523
  var _scrollElRef$current;
28481
28524
  var visibleRect = ((_scrollElRef$current = scrollElRef.current) === null || _scrollElRef$current === void 0 ? void 0 : _scrollElRef$current.getBoundingClientRect()) || {};
28482
28525
  if (rect.bottom < visibleRect.top || rect.top > visibleRect.bottom || rect.right < visibleRect.left || rect.left > visibleRect.right) {
28483
- return hideStyle;
28526
+ return {
28527
+ style: hideStyle
28528
+ };
28484
28529
  }
28485
28530
  }
28486
- var style = getAbsolutePositionStyle(rect, position);
28487
- return style;
28531
+ var _getAbsolutePositionS = getAbsolutePositionStyle(rect, position),
28532
+ style = _getAbsolutePositionS.style,
28533
+ arrayStyle = _getAbsolutePositionS.arrayStyle;
28534
+
28535
+ // TODO: 如果是版本大于chrome128,需要根据currentCSSZoom处理chrome的bug
28536
+ if (!isChromeLowerThan(128)) {
28537
+ // @ts-ignore currentCSSZoom
28538
+ var currentCSSZoom = document.body.currentCSSZoom;
28539
+ if (currentCSSZoom === 1 || !currentCSSZoom) return {
28540
+ style: style,
28541
+ arrayStyle: arrayStyle
28542
+ };
28543
+ if (style.left && typeof style.left === 'number') {
28544
+ style.left = style.left * (1 / currentCSSZoom);
28545
+ }
28546
+ if (style.top && typeof style.top === 'number') {
28547
+ style.top = style.top * (1 / currentCSSZoom);
28548
+ }
28549
+ if (style.right && typeof style.right === 'number') {
28550
+ style.right = style.right * (1 / currentCSSZoom);
28551
+ }
28552
+ if (style.bottom && typeof style.bottom === 'number') {
28553
+ style.bottom = style.bottom * (1 / currentCSSZoom);
28554
+ }
28555
+ }
28556
+ return {
28557
+ style: style,
28558
+ arrayStyle: arrayStyle
28559
+ };
28488
28560
  };
28489
28561
  var getStyle = function getStyle() {
28490
28562
  var newStyle = {};
28563
+ var newArrayStyle = {};
28491
28564
  var _ref2 = config || {},
28492
28565
  position = _ref2.position,
28493
28566
  absolute = _ref2.absolute;
28494
- if (!position || !show || !parentElRef.current) return style;
28567
+ if (!position || !show || !parentElRef.current) return {
28568
+ newStyle: style
28569
+ };
28495
28570
  context.parentRect = parentElRef.current.getBoundingClientRect();
28496
28571
  if (adjust) {
28497
28572
  var popupInfo = getPopUpInfo(context.parentRect);
@@ -28506,22 +28581,35 @@ var usePositionStyle = function usePositionStyle(config) {
28506
28581
  fixedWidth: fixedWidth
28507
28582
  });
28508
28583
  } else {
28509
- newStyle = getAbsoluteStyle(realPosition);
28584
+ var _ref3 = getAbsoluteStyle(realPosition),
28585
+ nextStyle = _ref3.style,
28586
+ nextArrayStyle = _ref3.arrayStyle;
28587
+ newStyle = nextStyle;
28588
+ newArrayStyle = nextArrayStyle;
28510
28589
  }
28511
28590
  // for animation
28512
28591
  if (realPosition.indexOf('top') === 0) {
28513
28592
  newStyle.transformOrigin = 'center bottom';
28514
28593
  }
28515
- return newStyle;
28594
+ return {
28595
+ newStyle: newStyle,
28596
+ newArrayStyle: newArrayStyle
28597
+ };
28516
28598
  };
28517
28599
  var updateStyle = use_persist_fn(function () {
28518
- var newStyle = getStyle();
28600
+ var _getStyle = getStyle(),
28601
+ newStyle = _getStyle.newStyle,
28602
+ newArrayStyle = _getStyle.newArrayStyle;
28519
28603
  if (newStyle && !shallow_equal(style, newStyle)) {
28520
28604
  setStyle(newStyle);
28605
+ setArrayStyle(newArrayStyle || {});
28521
28606
  }
28522
28607
  });
28523
28608
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(updateStyle, [show, position, absolute, updateKey, fixedWidth]);
28524
- return style;
28609
+ return {
28610
+ style: style,
28611
+ arrayStyle: arrayStyle
28612
+ };
28525
28613
  };
28526
28614
  /* harmony default export */ var use_position_style = ((/* unused pure expression or super */ null && (usePositionStyle)));
28527
28615
  // EXTERNAL MODULE: external {"root":"ReactDOM","commonjs2":"react-dom","commonjs":"react-dom","amd":"react-dom"}
@@ -29166,6 +29254,7 @@ var AbsoluteList = function AbsoluteList(props) {
29166
29254
  _props$zIndex = props.zIndex,
29167
29255
  zIndex = _props$zIndex === void 0 ? 1051 : _props$zIndex,
29168
29256
  focus = props.focus,
29257
+ arrowRef = props.arrowRef,
29169
29258
  popupElRef = props.popupElRef,
29170
29259
  updateKey = props.updateKey,
29171
29260
  popupGap = props.popupGap,
@@ -29184,23 +29273,33 @@ var AbsoluteList = function AbsoluteList(props) {
29184
29273
  rendered: false
29185
29274
  }),
29186
29275
  context = _useRef.current;
29187
- var style = usePositionStyle({
29188
- getContainer: getRoot,
29189
- position: position,
29190
- absolute: !!absolute,
29191
- parentElRef: parentElRef,
29192
- show: focus,
29193
- fixedWidth: fixedWidth,
29194
- zIndex: zIndex,
29195
- scrollElRef: scrollElRef,
29196
- popupElRef: popupElRef,
29197
- updateKey: updateKey,
29198
- popupGap: popupGap,
29199
- adjust: adjust
29200
- });
29276
+ var _usePositionStyle = usePositionStyle({
29277
+ getContainer: getRoot,
29278
+ position: position,
29279
+ absolute: !!absolute,
29280
+ parentElRef: parentElRef,
29281
+ show: focus,
29282
+ fixedWidth: fixedWidth,
29283
+ zIndex: zIndex,
29284
+ scrollElRef: scrollElRef,
29285
+ popupElRef: popupElRef,
29286
+ updateKey: updateKey,
29287
+ popupGap: popupGap,
29288
+ adjust: adjust
29289
+ }),
29290
+ style = _usePositionStyle.style,
29291
+ arrayStyle = _usePositionStyle.arrayStyle;
29201
29292
  var childStyle = children.props.style;
29202
29293
  var newStyle = objectSpread2_default()(objectSpread2_default()({}, style), childStyle);
29203
29294
  if ( /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().isValidElement(children) === false) return null;
29295
+ if (arrowRef && arrayStyle && Object.keys(arrayStyle).length > 0) {
29296
+ Object.keys(arrayStyle).forEach(function (key) {
29297
+ if (arrowRef.current) {
29298
+ // @ts-ignore
29299
+ arrowRef.current.style[key] = arrayStyle[key];
29300
+ }
29301
+ });
29302
+ }
29204
29303
  var styledChild = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().cloneElement(children, {
29205
29304
  style: newStyle
29206
29305
  });
@@ -29314,6 +29413,7 @@ var getMenuPosition = function getMenuPosition(target) {
29314
29413
  };
29315
29414
  var getPopoverPosition = function getPopoverPosition(target) {
29316
29415
  var priorityDirection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'vertical';
29416
+ var popup = arguments.length > 2 ? arguments[2] : undefined;
29317
29417
  var position = 'bottom-left';
29318
29418
  if (!target) return position;
29319
29419
  var rect = target.getBoundingClientRect();
@@ -29335,11 +29435,24 @@ var getPopoverPosition = function getPopoverPosition(target) {
29335
29435
  position += '-top';
29336
29436
  }
29337
29437
  } else {
29438
+ var popupRect = popup === null || popup === void 0 ? void 0 : popup.getBoundingClientRect();
29338
29439
  if (verticalPoint > windowHeight / 2) position = 'top';else position = 'bottom';
29339
- if (horizontalPoint > windowWidth * 0.6) {
29340
- position += '-right';
29341
- } else if (horizontalPoint < windowWidth * 0.4) {
29342
- position += '-left';
29440
+
29441
+ // 如果渲染了弹出内容,则根据弹出内容宽度计算是否自动调整位置
29442
+ if (popupRect) {
29443
+ if ((popupRect === null || popupRect === void 0 ? void 0 : popupRect.width) / 2 > rect.left) {
29444
+ position += '-left';
29445
+ }
29446
+ if ((popupRect === null || popupRect === void 0 ? void 0 : popupRect.width) / 2 > windowWidth - rect.right) {
29447
+ position += '-right';
29448
+ }
29449
+ } else {
29450
+ // 兜底计算
29451
+ if (horizontalPoint > windowWidth * 0.6) {
29452
+ position += '-right';
29453
+ } else if (horizontalPoint < windowWidth * 0.4) {
29454
+ position += '-left';
29455
+ }
29343
29456
  }
29344
29457
  }
29345
29458
  return position;
@@ -29347,7 +29460,8 @@ var getPopoverPosition = function getPopoverPosition(target) {
29347
29460
  var getPosition = function getPosition(target) {
29348
29461
  var priorityDirection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'vertical';
29349
29462
  var mode = arguments.length > 2 ? arguments[2] : undefined;
29350
- if (mode === 'popover') return getPopoverPosition(target, priorityDirection);
29463
+ var popup = arguments.length > 3 ? arguments[3] : undefined;
29464
+ if (mode === 'popover') return getPopoverPosition(target, priorityDirection, popup);
29351
29465
  if (mode === 'menu') return getMenuPosition(target, priorityDirection);
29352
29466
  return 'bottom-left';
29353
29467
  };
@@ -29389,6 +29503,7 @@ var usePopup = function usePopup(props) {
29389
29503
  removeChild = _useContext.removeChild;
29390
29504
  var targetRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
29391
29505
  var popupRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
29506
+ var arrowRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
29392
29507
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
29393
29508
  bindChild(popupRef);
29394
29509
  return function () {
@@ -29420,11 +29535,12 @@ var usePopup = function usePopup(props) {
29420
29535
  setPositionState = _useState4[1];
29421
29536
  var position = isPositionControl ? props.position : positionState;
29422
29537
  var updatePosition = use_persist_fn(function () {
29423
- if (isPositionControl) return;
29424
- if (props.position === 'auto' || !props.position) {
29425
- var newPosition = getPosition(targetRef.current, props.priorityDirection, autoMode);
29538
+ // if (isPositionControl) return;
29539
+ // if (props.position === 'auto' || !props.position) {
29540
+ setTimeout(function () {
29541
+ var newPosition = getPosition(targetRef.current, props.priorityDirection, autoMode, popupRef.current || undefined);
29426
29542
  if (newPosition !== position) setPositionState(newPosition);
29427
- }
29543
+ }, 10);
29428
29544
  });
29429
29545
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
29430
29546
  if (props.open) {
@@ -29553,6 +29669,7 @@ var usePopup = function usePopup(props) {
29553
29669
  position: position,
29554
29670
  targetRef: targetRef,
29555
29671
  popupRef: popupRef,
29672
+ arrowRef: arrowRef,
29556
29673
  getTargetProps: getTargetProps,
29557
29674
  openPop: openPop,
29558
29675
  closePop: closePop,
@@ -58593,7 +58710,8 @@ var Tooltip = function Tooltip(props) {
58593
58710
  _props$type = props.type,
58594
58711
  type = _props$type === void 0 ? 'default' : _props$type,
58595
58712
  _props$position = props.position,
58596
- popsitionProps = _props$position === void 0 ? 'bottom' : _props$position;
58713
+ popsitionProps = _props$position === void 0 ? 'auto' : _props$position;
58714
+ var arrowStyleRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({});
58597
58715
  var tooltipClasses = jssStyle === null || jssStyle === void 0 || (_jssStyle$tooltip = jssStyle.tooltip) === null || _jssStyle$tooltip === void 0 ? void 0 : _jssStyle$tooltip.call(jssStyle);
58598
58716
  var config = useConfig();
58599
58717
  var childrenProps = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.isValidElement)(children) ? children === null || children === void 0 ? void 0 : children.props : {};
@@ -58610,7 +58728,8 @@ var Tooltip = function Tooltip(props) {
58610
58728
  position = _usePopup.position,
58611
58729
  getTargetProps = _usePopup.getTargetProps,
58612
58730
  targetRef = _usePopup.targetRef,
58613
- popupRef = _usePopup.popupRef;
58731
+ popupRef = _usePopup.popupRef,
58732
+ arrowRef = _usePopup.arrowRef;
58614
58733
  if (! /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.isValidElement)(children)) {
58615
58734
  console.error(new Error('Tooltip children expect a single ReactElement.'));
58616
58735
  return null;
@@ -58641,12 +58760,16 @@ var Tooltip = function Tooltip(props) {
58641
58760
  focus: open,
58642
58761
  parentElRef: targetRef,
58643
58762
  popupElRef: popupRef,
58763
+ arrowRef: arrowRef,
58644
58764
  absolute: true,
58765
+ adjust: popsitionProps === 'auto',
58645
58766
  position: position,
58646
58767
  fixedWidth: false,
58647
- popupGap: 0,
58768
+ popupGap: 0
58769
+ // arrowStyleRef={arrowStyleRef}
58770
+ ,
58648
58771
  zIndex: zIndex,
58649
- children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", objectSpread2_default()(objectSpread2_default()({
58772
+ children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", objectSpread2_default()(objectSpread2_default()({
58650
58773
  className: classnames_default()(className, tooltipClasses === null || tooltipClasses === void 0 ? void 0 : tooltipClasses.wrapper, open && (tooltipClasses === null || tooltipClasses === void 0 ? void 0 : tooltipClasses.wrapperOpen))
58651
58774
  }, getDataAttribute({
58652
58775
  type: type,
@@ -58655,11 +58778,17 @@ var Tooltip = function Tooltip(props) {
58655
58778
  ref: popupRef,
58656
58779
  onMouseLeave: events.onMouseLeave,
58657
58780
  dir: config.direction,
58658
- children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
58781
+ children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", objectSpread2_default()({
58782
+ ref: arrowRef,
58783
+ style: arrowStyleRef.current,
58784
+ className: tooltipClasses === null || tooltipClasses === void 0 ? void 0 : tooltipClasses.arrow
58785
+ }, getDataAttribute({
58786
+ role: 'arrow'
58787
+ }))), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
58659
58788
  style: style,
58660
58789
  className: classnames_default()(tooltipClasses === null || tooltipClasses === void 0 ? void 0 : tooltipClasses.content),
58661
58790
  children: tip
58662
- })
58791
+ })]
58663
58792
  }))
58664
58793
  })]
58665
58794
  });
@@ -63751,7 +63880,7 @@ var upload_interface = __webpack_require__(8821);
63751
63880
 
63752
63881
 
63753
63882
  /* harmony default export */ var src_0 = ({
63754
- version: '3.3.6-beta.1'
63883
+ version: '3.3.6-beta.3'
63755
63884
  });
63756
63885
  }();
63757
63886
  /******/ return __webpack_exports__;