shineout 3.8.4-beta.6 → 3.8.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
@@ -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.8.4-beta.6'
525
+ version: '3.8.4-beta.8'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12386,7 +12386,7 @@ var handleStyle = function handleStyle(style) {
12386
12386
  };
12387
12387
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12388
12388
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12389
- /* harmony default export */ var version = ('3.8.4-beta.6');
12389
+ /* harmony default export */ var version = ('3.8.4-beta.8');
12390
12390
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12391
12391
 
12392
12392
 
@@ -30750,6 +30750,10 @@ var usePopup = function usePopup(props) {
30750
30750
  var handleMouseEnter = use_persist_fn(function (e) {
30751
30751
  var _targetEvents$onMouse, _targetRef$current, _popupRef$current2;
30752
30752
  targetEvents === null || targetEvents === void 0 || (_targetEvents$onMouse = targetEvents.onMouseEnter) === null || _targetEvents$onMouse === void 0 || _targetEvents$onMouse.call(targetEvents, e);
30753
+ // todo: 考虑是否严格一些执行,比如需要判断是否是子元素
30754
+ // if (targetRef.current?.contains(e.target as Node)) {
30755
+ // targetEvents?.onMouseEnter?.(e);
30756
+ // }
30753
30757
  if (trigger !== 'hover') return;
30754
30758
  var isParentContainsCurrent = (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.contains(e.target);
30755
30759
  if (isParentContainsCurrent || popupRef !== null && popupRef !== void 0 && (_popupRef$current2 = popupRef.current) !== null && _popupRef$current2 !== void 0 && _popupRef$current2.contains(e.target)) {
@@ -30759,6 +30763,10 @@ var usePopup = function usePopup(props) {
30759
30763
  var handleMouseLeave = use_persist_fn(function (e) {
30760
30764
  var _targetEvents$onMouse2, _popupRef$current3;
30761
30765
  targetEvents === null || targetEvents === void 0 || (_targetEvents$onMouse2 = targetEvents.onMouseLeave) === null || _targetEvents$onMouse2 === void 0 || _targetEvents$onMouse2.call(targetEvents, e);
30766
+ // todo: 考虑是否严格一些执行,比如需要判断是否是子元素
30767
+ // if (targetRef.current?.contains(e.target as Node)) {
30768
+ // targetEvents?.onMouseLeave?.(e);
30769
+ // }
30762
30770
  if (trigger !== 'hover') return;
30763
30771
  // @ts-ignore
30764
30772
  if (e.relatedTarget instanceof HTMLElement && (_popupRef$current3 = popupRef.current) !== null && _popupRef$current3 !== void 0 && _popupRef$current3.contains(e.relatedTarget)) {
@@ -31535,10 +31543,43 @@ var usePositionStyle = function usePositionStyle(config) {
31535
31543
  setPopupElWidth(popupElRef.current.getBoundingClientRect().width);
31536
31544
  }
31537
31545
  }, [show, popupElRef.current]);
31538
- var adjustPosition = function adjustPosition(position) {
31546
+ var adjustHorizontalPosition = function adjustHorizontalPosition(position) {
31547
+ var _config$onAdjust;
31548
+ var winWidth = docSize.width;
31539
31549
  var winHeight = docSize.height;
31540
- if (!verticalPosition.includes(position)) return position;
31541
31550
  var newPosition = position;
31551
+ var _position$split = position.split('-'),
31552
+ _position$split2 = slicedToArray_default()(_position$split, 2),
31553
+ h = _position$split2[0],
31554
+ v = _position$split2[1];
31555
+ if (h === 'right') {
31556
+ var horizontalPoint = context.parentRect.left + context.parentRect.width;
31557
+ if (horizontalPoint / winWidth > 0.5 && horizontalPoint + context.popUpWidth > winWidth) {
31558
+ newPosition = position.replace('right', 'left');
31559
+ }
31560
+ } else if (h === 'left') {
31561
+ var _horizontalPoint = context.parentRect.left;
31562
+ if (_horizontalPoint / winWidth < 0.5 && _horizontalPoint < context.popUpWidth) {
31563
+ newPosition = position.replace('left', 'right');
31564
+ }
31565
+ }
31566
+ if (v === 'top') {
31567
+ var verticalPoint = context.parentRect.top;
31568
+ if (verticalPoint / winHeight > 0.5 && verticalPoint + context.popUpHeight > winHeight) {
31569
+ newPosition = newPosition.replace('top', 'bottom');
31570
+ }
31571
+ } else if (v === 'bottom') {
31572
+ var _verticalPoint = context.parentRect.bottom;
31573
+ if (_verticalPoint / winHeight < 0.5 && _verticalPoint < context.popUpHeight) {
31574
+ newPosition = newPosition.replace('bottom', 'top');
31575
+ }
31576
+ }
31577
+ config === null || config === void 0 || (_config$onAdjust = config.onAdjust) === null || _config$onAdjust === void 0 || _config$onAdjust.call(config, newPosition);
31578
+ return newPosition;
31579
+ };
31580
+ var adjustVerticalPosition = function adjustVerticalPosition(position) {
31581
+ var newPosition = position;
31582
+ var winHeight = docSize.height;
31542
31583
  var verticalPoint = context.parentRect.top + context.parentRect.height / 2;
31543
31584
  if (position.startsWith('top')) {
31544
31585
  if (verticalPoint / winHeight < 0.5 && context.parentRect.top - context.popUpHeight - popupGap < 0) {
@@ -31563,15 +31604,21 @@ var usePositionStyle = function usePositionStyle(config) {
31563
31604
  }
31564
31605
  } else {
31565
31606
  // absolute 场景下,右侧溢出判断需要考虑弹出层元素的尺寸
31566
- var _position$split = position.split('-'),
31567
- _position$split2 = slicedToArray_default()(_position$split, 2),
31568
- _horizontalPosition = _position$split2[1];
31607
+ var _position$split3 = position.split('-'),
31608
+ _position$split4 = slicedToArray_default()(_position$split3, 2),
31609
+ _horizontalPosition = _position$split4[1];
31569
31610
  if (_horizontalPosition === 'left' && context.parentRect.left + (popupElWidth || context.popUpWidth) > docSize.width) {
31570
31611
  newPosition = newPosition.replace('left', 'right');
31571
31612
  }
31572
31613
  }
31573
31614
  return newPosition;
31574
31615
  };
31616
+ var adjustPosition = function adjustPosition(position) {
31617
+ if (!verticalPosition.includes(position)) {
31618
+ return adjustHorizontalPosition(position);
31619
+ }
31620
+ return adjustVerticalPosition(position);
31621
+ };
31575
31622
  var getPopUpInfo = function getPopUpInfo(parentRect) {
31576
31623
  var _popupElRef$current$p;
31577
31624
  if (!popupElRef.current) return {
@@ -32451,6 +32498,7 @@ var AbsoluteList = function AbsoluteList(props) {
32451
32498
  updateKey = props.updateKey,
32452
32499
  popupGap = props.popupGap,
32453
32500
  adjust = props.adjust,
32501
+ onAdjust = props.onAdjust,
32454
32502
  offset = props.offset,
32455
32503
  _props$destroy = props.destroy,
32456
32504
  destroy = _props$destroy === void 0 ? false : _props$destroy,
@@ -32494,7 +32542,8 @@ var AbsoluteList = function AbsoluteList(props) {
32494
32542
  updateKey: updateKey,
32495
32543
  popupGap: popupGap,
32496
32544
  adjust: adjust,
32497
- offset: offset
32545
+ offset: offset,
32546
+ onAdjust: onAdjust
32498
32547
  }),
32499
32548
  style = _usePositionStyle.style;
32500
32549
  var childStyle = children.props.style;
@@ -32585,11 +32634,15 @@ var Popover = function Popover(props) {
32585
32634
  closePop = _usePopup.closePop,
32586
32635
  Provider = _usePopup.Provider,
32587
32636
  providerValue = _usePopup.providerValue;
32588
- var events = getTargetProps();
32589
- var _React$useState = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useState(0),
32637
+ var _React$useState = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useState(position),
32590
32638
  _React$useState2 = slicedToArray_default()(_React$useState, 2),
32591
- updateKey = _React$useState2[0],
32592
- setUpdateKey = _React$useState2[1];
32639
+ positionState = _React$useState2[0],
32640
+ setPositionState = _React$useState2[1];
32641
+ var events = getTargetProps();
32642
+ var _React$useState3 = external_root_React_commonjs2_react_commonjs_react_amd_react_default().useState(0),
32643
+ _React$useState4 = slicedToArray_default()(_React$useState3, 2),
32644
+ updateKey = _React$useState4[0],
32645
+ setUpdateKey = _React$useState4[1];
32593
32646
  var handleUpdateKey = usePersistFn(function () {
32594
32647
  setUpdateKey(function (prev) {
32595
32648
  return (prev + 1) % 2;
@@ -32693,6 +32746,7 @@ var Popover = function Popover(props) {
32693
32746
  destroy: destroy,
32694
32747
  zIndex: zIndex,
32695
32748
  adjust: props.adjust,
32749
+ onAdjust: props.adjust ? setPositionState : undefined,
32696
32750
  lazy: props.lazy,
32697
32751
  offset: props.offset,
32698
32752
  updateKey: updateKey,
@@ -32700,7 +32754,7 @@ var Popover = function Popover(props) {
32700
32754
  className: classnames_default()(className, popoverStyle === null || popoverStyle === void 0 ? void 0 : popoverStyle.rootClass, popoverStyle === null || popoverStyle === void 0 ? void 0 : popoverStyle.wrapper, open && (popoverStyle === null || popoverStyle === void 0 ? void 0 : popoverStyle.wrapperOpen), !showArrow && (popoverStyle === null || popoverStyle === void 0 ? void 0 : popoverStyle.hideArrow)),
32701
32755
  style: containerStyle
32702
32756
  }, getDataAttribute({
32703
- position: position,
32757
+ position: props.adjust ? positionState : position,
32704
32758
  type: type
32705
32759
  })), props.attributes), {}, {
32706
32760
  ref: popupRef,
@@ -33482,6 +33536,17 @@ var Tooltip = function Tooltip(props) {
33482
33536
  })
33483
33537
  })
33484
33538
  }) : children;
33539
+ var innerProps = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
33540
+ if (persistent) {
33541
+ return trigger === 'hover' ? objectSpread2_default()(objectSpread2_default()({}, events), {}, {
33542
+ onMouseEnter: undefined,
33543
+ onMouseLeave: undefined
33544
+ }) : objectSpread2_default()(objectSpread2_default()({}, events), {}, {
33545
+ onClick: undefined
33546
+ });
33547
+ }
33548
+ return events;
33549
+ }, [persistent, events, trigger]);
33485
33550
  return /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
33486
33551
  children: [/*#__PURE__*/(0,jsx_runtime.jsx)("noscript", {
33487
33552
  ref: function ref(el) {
@@ -33491,7 +33556,7 @@ var Tooltip = function Tooltip(props) {
33491
33556
  if (targetRef.current === targetEl) return;
33492
33557
  targetRef.current = targetEl;
33493
33558
  }
33494
- }, 'ns'), /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.cloneElement)(inner, events), /*#__PURE__*/(0,jsx_runtime.jsx)(absolute_list, {
33559
+ }, 'ns'), /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.cloneElement)(inner, innerProps), /*#__PURE__*/(0,jsx_runtime.jsx)(absolute_list, {
33495
33560
  focus: open,
33496
33561
  parentElRef: targetRef,
33497
33562
  popupElRef: popupRef,
@@ -50213,7 +50278,7 @@ var Dropdown = function Dropdown(props) {
50213
50278
  fixedWidth: 'min',
50214
50279
  popupGap: 4,
50215
50280
  popupElRef: popupRef,
50216
- adjust: !isSub && adjust,
50281
+ adjust: adjust,
50217
50282
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(animation_list, {
50218
50283
  display: columns ? 'grid' : 'block',
50219
50284
  className: classnames_default()(dropdownClasses === null || dropdownClasses === void 0 ? void 0 : dropdownClasses.list, hasChildren && (dropdownClasses === null || dropdownClasses === void 0 ? void 0 : dropdownClasses.listHasChildren), columns !== undefined && columns > 1 && (dropdownClasses === null || dropdownClasses === void 0 ? void 0 : dropdownClasses.boxList), size === 'small' && (dropdownClasses === null || dropdownClasses === void 0 ? void 0 : dropdownClasses.listSmall), size === 'large' && (dropdownClasses === null || dropdownClasses === void 0 ? void 0 : dropdownClasses.listLarge)),
@@ -73213,7 +73278,7 @@ var upload_interface = __webpack_require__(8821);
73213
73278
 
73214
73279
 
73215
73280
  /* harmony default export */ var src_0 = ({
73216
- version: '3.8.4-beta.6'
73281
+ version: '3.8.4-beta.8'
73217
73282
  });
73218
73283
  }();
73219
73284
  /******/ return __webpack_exports__;