@coreui/react 4.7.0 → 4.8.0

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/dist/index.js CHANGED
@@ -2625,15 +2625,6 @@ CAccordionButton.propTypes = {
2625
2625
  };
2626
2626
  CAccordionButton.displayName = 'CAccordionButton';
2627
2627
 
2628
- var CAccordionCollapse = React.forwardRef(function (_a, ref) {
2629
- var children = _a.children, props = __rest(_a, ["children"]);
2630
- return (React.createElement(CCollapse, __assign({ className: "accordion-collapse" }, props, { ref: ref }), children));
2631
- });
2632
- CAccordionCollapse.propTypes = {
2633
- children: propTypesExports.node,
2634
- };
2635
- CAccordionCollapse.displayName = 'CAccordionCollapse';
2636
-
2637
2628
  var CAccordionHeader = React.forwardRef(function (_a, ref) {
2638
2629
  var children = _a.children, className = _a.className, rest = __rest(_a, ["children", "className"]);
2639
2630
  return (React.createElement("div", __assign({ className: classNames('accordion-header', className) }, rest, { ref: ref }),
@@ -5747,13 +5738,18 @@ function Reference(_ref) {
5747
5738
  });
5748
5739
  }
5749
5740
 
5741
+ var PopperManagerWrapper = function (_a) {
5742
+ var children = _a.children, popper = _a.popper;
5743
+ return popper ? React.createElement(Manager, null, children) : React.createElement(React.Fragment, null, children);
5744
+ };
5750
5745
  var CDropdownContext = React.createContext({});
5751
5746
  var CDropdown = React.forwardRef(function (_a, ref) {
5752
- var children = _a.children, alignment = _a.alignment, _b = _a.autoClose, autoClose = _b === void 0 ? true : _b, className = _a.className, dark = _a.dark, direction = _a.direction, onHide = _a.onHide, onShow = _a.onShow, _c = _a.placement, placement = _c === void 0 ? 'bottom-start' : _c, _d = _a.popper, popper = _d === void 0 ? true : _d, _e = _a.variant, variant = _e === void 0 ? 'btn-group' : _e, _f = _a.component, component = _f === void 0 ? 'div' : _f, _g = _a.visible, visible = _g === void 0 ? false : _g, rest = __rest(_a, ["children", "alignment", "autoClose", "className", "dark", "direction", "onHide", "onShow", "placement", "popper", "variant", "component", "visible"]);
5747
+ var _b;
5748
+ var children = _a.children, alignment = _a.alignment, _c = _a.autoClose, autoClose = _c === void 0 ? true : _c, className = _a.className, dark = _a.dark, direction = _a.direction, onHide = _a.onHide, onShow = _a.onShow, _d = _a.placement, placement = _d === void 0 ? 'bottom-start' : _d, _e = _a.popper, popper = _e === void 0 ? true : _e, _f = _a.portal, portal = _f === void 0 ? false : _f, _g = _a.variant, variant = _g === void 0 ? 'btn-group' : _g, _h = _a.component, component = _h === void 0 ? 'div' : _h, _j = _a.visible, visible = _j === void 0 ? false : _j, rest = __rest(_a, ["children", "alignment", "autoClose", "className", "dark", "direction", "onHide", "onShow", "placement", "popper", "portal", "variant", "component", "visible"]);
5753
5749
  var dropdownRef = React.useRef(null);
5754
5750
  var dropdownToggleRef = React.useRef(null);
5755
5751
  var forkedRef = useForkedRef(ref, dropdownRef);
5756
- var _h = React.useState(visible), _visible = _h[0], setVisible = _h[1];
5752
+ var _k = React.useState(visible), _visible = _k[0], setVisible = _k[1];
5757
5753
  var Component = variant === 'nav-item' ? 'li' : component;
5758
5754
  // Disable popper if responsive aligment is set.
5759
5755
  if (typeof alignment === 'object') {
@@ -5767,6 +5763,7 @@ var CDropdown = React.forwardRef(function (_a, ref) {
5767
5763
  dropdownToggleRef: dropdownToggleRef,
5768
5764
  placement: placement,
5769
5765
  popper: popper,
5766
+ portal: portal,
5770
5767
  variant: variant,
5771
5768
  visible: _visible,
5772
5769
  setVisible: setVisible,
@@ -5778,16 +5775,14 @@ var CDropdown = React.forwardRef(function (_a, ref) {
5778
5775
  _visible && onShow && onShow();
5779
5776
  !_visible && onHide && onHide();
5780
5777
  }, [_visible]);
5781
- var DropdownContent = function () {
5782
- return variant === 'input-group' ? (React.createElement(React.Fragment, null, children)) : (React.createElement(Component, __assign({ className: classNames(variant === 'nav-item' ? 'nav-item dropdown' : variant, {
5783
- 'dropdown-center': direction === 'center',
5784
- 'dropup dropup-center': direction === 'dropup-center',
5785
- direction: direction && direction !== 'center' && direction !== 'dropup-center',
5786
- show: _visible,
5787
- }, className) }, rest, { ref: forkedRef }), children));
5788
- };
5789
- return (React.createElement(CDropdownContext.Provider, { value: contextValues }, popper ? (React.createElement(Manager, null,
5790
- React.createElement(DropdownContent, null))) : (React.createElement(DropdownContent, null))));
5778
+ return (React.createElement(CDropdownContext.Provider, { value: contextValues },
5779
+ React.createElement(PopperManagerWrapper, { popper: popper }, variant === 'input-group' ? (React.createElement(React.Fragment, null, children)) : (React.createElement(Component, __assign({ className: classNames(variant === 'nav-item' ? 'nav-item dropdown' : variant, (_b = {
5780
+ 'dropdown-center': direction === 'center',
5781
+ 'dropup dropup-center': direction === 'dropup-center'
5782
+ },
5783
+ _b["".concat(direction)] = direction && direction !== 'center' && direction !== 'dropup-center',
5784
+ _b.show = _visible,
5785
+ _b), className) }, rest, { ref: forkedRef }), children)))));
5791
5786
  });
5792
5787
  var alignmentDirection = propTypesExports.oneOf(['start', 'end']);
5793
5788
  CDropdown.propTypes = {
@@ -5814,6 +5809,7 @@ CDropdown.propTypes = {
5814
5809
  onShow: propTypesExports.func,
5815
5810
  placement: placementPropType,
5816
5811
  popper: propTypesExports.bool,
5812
+ portal: propTypesExports.bool,
5817
5813
  variant: propTypesExports.oneOf(['btn-group', 'dropdown', 'input-group', 'nav-item']),
5818
5814
  visible: propTypesExports.bool,
5819
5815
  };
@@ -5861,9 +5857,21 @@ CDropdownItemPlain.propTypes = {
5861
5857
  };
5862
5858
  CDropdownItemPlain.displayName = 'CDropdownItemPlain';
5863
5859
 
5860
+ var alignmentClassNames = function (alignment) {
5861
+ var classNames = [];
5862
+ if (typeof alignment === 'object') {
5863
+ Object.keys(alignment).map(function (key) {
5864
+ classNames.push("dropdown-menu".concat(key === 'xs' ? '' : "-".concat(key), "-").concat(alignment[key]));
5865
+ });
5866
+ }
5867
+ if (typeof alignment === 'string') {
5868
+ classNames.push("dropdown-menu-".concat(alignment));
5869
+ }
5870
+ return classNames;
5871
+ };
5864
5872
  var CDropdownMenu = function (_a) {
5865
5873
  var children = _a.children, className = _a.className, _b = _a.component, Component = _b === void 0 ? 'ul' : _b, rest = __rest(_a, ["children", "className", "component"]);
5866
- var _c = React.useContext(CDropdownContext), alignment = _c.alignment, autoClose = _c.autoClose, dark = _c.dark, direction = _c.direction, dropdownToggleRef = _c.dropdownToggleRef, placement = _c.placement, popper = _c.popper, visible = _c.visible, setVisible = _c.setVisible;
5874
+ var _c = React.useContext(CDropdownContext), alignment = _c.alignment, autoClose = _c.autoClose, dark = _c.dark, direction = _c.direction, dropdownToggleRef = _c.dropdownToggleRef, placement = _c.placement, popper = _c.popper, portal = _c.portal, visible = _c.visible, setVisible = _c.setVisible;
5867
5875
  var dropdownMenuRef = React.useRef(null);
5868
5876
  React.useEffect(function () {
5869
5877
  visible && window.addEventListener('mouseup', handleMouseUp);
@@ -5912,29 +5920,18 @@ var CDropdownMenu = function (_a) {
5912
5920
  if (alignment === 'end') {
5913
5921
  _placement = 'bottom-end';
5914
5922
  }
5915
- var alignmentClassNames = function (alignment) {
5916
- var classNames = [];
5917
- if (typeof alignment === 'object') {
5918
- Object.keys(alignment).map(function (key) {
5919
- classNames.push("dropdown-menu".concat(key === 'xs' ? '' : "-".concat(key), "-").concat(alignment[key]));
5920
- });
5921
- }
5922
- if (typeof alignment === 'string') {
5923
- classNames.push("dropdown-menu-".concat(alignment));
5924
- }
5925
- return classNames;
5926
- };
5927
- var dropdownMenuComponent = function (style, ref) { return (React.createElement(Component, __assign({ className: classNames('dropdown-menu', {
5928
- 'dropdown-menu-dark': dark,
5929
- show: visible,
5930
- }, alignment && alignmentClassNames(alignment), className), ref: ref, style: style, role: "menu", "aria-hidden": !visible }, (!popper && { 'data-coreui-popper': 'static' }), rest), Component === 'ul'
5931
- ? React.Children.map(children, function (child, index) {
5932
- if (React.isValidElement(child)) {
5933
- return React.createElement("li", { key: index }, React.cloneElement(child));
5934
- }
5935
- return;
5936
- })
5937
- : children)); };
5923
+ var dropdownMenuComponent = function (style, ref) { return (React.createElement(CConditionalPortal, { portal: portal !== null && portal !== void 0 ? portal : false },
5924
+ React.createElement(Component, __assign({ className: classNames('dropdown-menu', {
5925
+ 'dropdown-menu-dark': dark,
5926
+ show: visible,
5927
+ }, alignment && alignmentClassNames(alignment), className), ref: ref, style: style, role: "menu", "aria-hidden": !visible }, (!popper && { 'data-coreui-popper': 'static' }), rest), Component === 'ul'
5928
+ ? React.Children.map(children, function (child, index) {
5929
+ if (React.isValidElement(child)) {
5930
+ return React.createElement("li", { key: index }, React.cloneElement(child));
5931
+ }
5932
+ return;
5933
+ })
5934
+ : children))); };
5938
5935
  return popper && visible ? (React.createElement(Popper, { innerRef: dropdownMenuRef, placement: _placement }, function (_a) {
5939
5936
  var ref = _a.ref, style = _a.style;
5940
5937
  return dropdownMenuComponent(style, ref);
@@ -6989,11 +6986,9 @@ var COffcanvas = React.forwardRef(function (_a, ref) {
6989
6986
  setVisible(visible);
6990
6987
  }, [visible]);
6991
6988
  React.useEffect(function () {
6992
- if (_visible) {
6993
- if (!scroll) {
6994
- document.body.style.overflow = 'hidden';
6995
- document.body.style.paddingRight = '0px';
6996
- }
6989
+ if (_visible && !scroll) {
6990
+ document.body.style.overflow = 'hidden';
6991
+ document.body.style.paddingRight = '0px';
6997
6992
  return;
6998
6993
  }
6999
6994
  if (!scroll) {
@@ -7940,7 +7935,6 @@ CWidgetStatsF.displayName = 'CWidgetStatsF';
7940
7935
  exports.CAccordion = CAccordion;
7941
7936
  exports.CAccordionBody = CAccordionBody;
7942
7937
  exports.CAccordionButton = CAccordionButton;
7943
- exports.CAccordionCollapse = CAccordionCollapse;
7944
7938
  exports.CAccordionHeader = CAccordionHeader;
7945
7939
  exports.CAccordionItem = CAccordionItem;
7946
7940
  exports.CAlert = CAlert;