@coreui/react-pro 4.14.0 → 4.15.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/README.md CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
  Several quick start options are available:
44
44
 
45
- - [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v4.14.0.zip)
45
+ - [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v4.15.0.zip)
46
46
  - Clone the repo: `git clone https://github.com/coreui/coreui-react.git`
47
47
  - Install with [npm](https://www.npmjs.com/): `npm install @coreui/react`
48
48
  - Install with [yarn](https://yarnpkg.com/): `yarn add @coreui/react`
@@ -4,9 +4,15 @@ export interface CConditionalPortalProps {
4
4
  * @ignore
5
5
  */
6
6
  children: ReactNode;
7
+ /**
8
+ * An HTML element or function that returns a single element, with `document.body` as the default.
9
+ *
10
+ * @since v4.11.0
11
+ */
12
+ container?: Element | (() => Element | null) | null;
7
13
  /**
8
14
  * Render some children into a different part of the DOM
9
15
  */
10
- portal: boolean;
16
+ portal: boolean | any;
11
17
  }
12
18
  export declare const CConditionalPortal: FC<CConditionalPortalProps>;
@@ -38,6 +38,12 @@ export interface CDropdownProps extends HTMLAttributes<HTMLDivElement | HTMLLIEl
38
38
  * Component used for the root node. Either a string to use a HTML element or a component.
39
39
  */
40
40
  component?: string | ElementType;
41
+ /**
42
+ * Appends the react dropdown menu to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`.
43
+ *
44
+ * @since v4.11.0
45
+ */
46
+ container?: Element | (() => Element | null) | null;
41
47
  /**
42
48
  * Sets a darker color scheme to match a dark navbar.
43
49
  */
@@ -11,6 +11,12 @@ export interface CPopoverProps extends Omit<HTMLAttributes<HTMLDivElement>, 'tit
11
11
  * A string of all className you want applied to the component.
12
12
  */
13
13
  className?: string;
14
+ /**
15
+ * Appends the react popover to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`.
16
+ *
17
+ * @since v4.11.0
18
+ */
19
+ container?: Element | (() => Element | null) | null;
14
20
  /**
15
21
  * Content node for your component.
16
22
  */
@@ -11,6 +11,12 @@ export interface CTooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'con
11
11
  * A string of all className you want applied to the component.
12
12
  */
13
13
  className?: string;
14
+ /**
15
+ * Appends the react tooltip to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`.
16
+ *
17
+ * @since v4.11.0
18
+ */
19
+ container?: Element | (() => Element | null) | null;
14
20
  /**
15
21
  * Content node for your component.
16
22
  */
package/dist/index.es.js CHANGED
@@ -5222,13 +5222,24 @@ CCarouselItem.propTypes = {
5222
5222
  };
5223
5223
  CCarouselItem.displayName = 'CCarouselItem';
5224
5224
 
5225
+ var getContainer = function (container) {
5226
+ if (container) {
5227
+ return typeof container === 'function' ? container() : container;
5228
+ }
5229
+ return document.body;
5230
+ };
5225
5231
  var CConditionalPortal = function (_a) {
5226
- var children = _a.children, portal = _a.portal;
5227
- return typeof window !== 'undefined' && portal ? (createPortal(children, document.body)) : (React$1.createElement(React$1.Fragment, null, children));
5232
+ var children = _a.children, container = _a.container, portal = _a.portal;
5233
+ var _b = useState(null), _container = _b[0], setContainer = _b[1];
5234
+ useEffect(function () {
5235
+ portal && setContainer(getContainer(container) || document.body);
5236
+ }, [container, portal]);
5237
+ return typeof window !== 'undefined' && portal && _container ? (createPortal(children, _container)) : (React$1.createElement(React$1.Fragment, null, children));
5228
5238
  };
5229
5239
  CConditionalPortal.propTypes = {
5230
5240
  children: PropTypes$1.node,
5231
- portal: PropTypes$1.bool.isRequired,
5241
+ container: PropTypes$1.any,
5242
+ portal: PropTypes$1.bool,
5232
5243
  };
5233
5244
  CConditionalPortal.displayName = 'CConditionalPortal';
5234
5245
 
@@ -9495,7 +9506,7 @@ var CDateRangePicker = forwardRef(function (_a, ref) {
9495
9506
  }, [startDate]);
9496
9507
  useEffect(function () {
9497
9508
  setEndDate(endDate ? new Date(endDate) : null);
9498
- setCalendarDate(endDate ? new Date(endDate) : new Date());
9509
+ range && setCalendarDate(endDate ? new Date(endDate) : new Date());
9499
9510
  }, [endDate]);
9500
9511
  useEffect(function () {
9501
9512
  maxDate && setMaxDate(new Date(maxDate));
@@ -9707,7 +9718,7 @@ var getPlacement = function (placement, direction, alignment, isRTL) {
9707
9718
  var CDropdownContext = createContext({});
9708
9719
  var CDropdown = forwardRef(function (_a, ref) {
9709
9720
  var _b;
9710
- 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, _d = _a.offset, offset = _d === void 0 ? [0, 2] : _d, onHide = _a.onHide, onShow = _a.onShow, _e = _a.placement, placement = _e === void 0 ? 'bottom-start' : _e, _f = _a.popper, popper = _f === void 0 ? true : _f, _g = _a.portal, portal = _g === void 0 ? false : _g, _h = _a.variant, variant = _h === void 0 ? 'btn-group' : _h, _j = _a.component, component = _j === void 0 ? 'div' : _j, _k = _a.visible, visible = _k === void 0 ? false : _k, rest = __rest$1(_a, ["children", "alignment", "autoClose", "className", "dark", "direction", "offset", "onHide", "onShow", "placement", "popper", "portal", "variant", "component", "visible"]);
9721
+ var children = _a.children, alignment = _a.alignment, _c = _a.autoClose, autoClose = _c === void 0 ? true : _c, className = _a.className, container = _a.container, dark = _a.dark, direction = _a.direction, _d = _a.offset, offset = _d === void 0 ? [0, 2] : _d, onHide = _a.onHide, onShow = _a.onShow, _e = _a.placement, placement = _e === void 0 ? 'bottom-start' : _e, _f = _a.popper, popper = _f === void 0 ? true : _f, _g = _a.portal, portal = _g === void 0 ? false : _g, _h = _a.variant, variant = _h === void 0 ? 'btn-group' : _h, _j = _a.component, component = _j === void 0 ? 'div' : _j, _k = _a.visible, visible = _k === void 0 ? false : _k, rest = __rest$1(_a, ["children", "alignment", "autoClose", "className", "container", "dark", "direction", "offset", "onHide", "onShow", "placement", "popper", "portal", "variant", "component", "visible"]);
9711
9722
  var dropdownRef = useRef(null);
9712
9723
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9713
9724
  var dropdownToggleRef = useRef(null);
@@ -9722,6 +9733,7 @@ var CDropdown = forwardRef(function (_a, ref) {
9722
9733
  }
9723
9734
  var contextValues = {
9724
9735
  alignment: alignment,
9736
+ container: container,
9725
9737
  dark: dark,
9726
9738
  dropdownToggleRef: dropdownToggleRef,
9727
9739
  dropdownMenuRef: dropdownMenuRef,
@@ -9876,9 +9888,9 @@ var alignmentClassNames = function (alignment) {
9876
9888
  };
9877
9889
  var CDropdownMenu = forwardRef(function (_a, ref) {
9878
9890
  var children = _a.children, className = _a.className, _b = _a.component, Component = _b === void 0 ? 'ul' : _b, rest = __rest$1(_a, ["children", "className", "component"]);
9879
- var _c = useContext(CDropdownContext), alignment = _c.alignment, dark = _c.dark, dropdownMenuRef = _c.dropdownMenuRef, popper = _c.popper, portal = _c.portal, visible = _c.visible;
9891
+ var _c = useContext(CDropdownContext), alignment = _c.alignment, container = _c.container, dark = _c.dark, dropdownMenuRef = _c.dropdownMenuRef, popper = _c.popper, portal = _c.portal, visible = _c.visible;
9880
9892
  var forkedRef = useForkedRef(ref, dropdownMenuRef);
9881
- return (React$1.createElement(CConditionalPortal, { portal: portal !== null && portal !== void 0 ? portal : false },
9893
+ return (React$1.createElement(CConditionalPortal, { container: container, portal: portal !== null && portal !== void 0 ? portal : false },
9882
9894
  React$1.createElement(Component, __assign$1({ className: classNames$1('dropdown-menu', {
9883
9895
  'dropdown-menu-dark': dark,
9884
9896
  show: visible,
@@ -11668,7 +11680,7 @@ CProgress.propTypes = {
11668
11680
  CProgress.displayName = 'CProgress';
11669
11681
 
11670
11682
  var CPopover = forwardRef(function (_a, ref) {
11671
- var children = _a.children, _b = _a.animation, animation = _b === void 0 ? true : _b, className = _a.className, content = _a.content, _c = _a.delay, delay = _c === void 0 ? 0 : _c, _d = _a.fallbackPlacements, fallbackPlacements = _d === void 0 ? ['top', 'right', 'bottom', 'left'] : _d, _e = _a.offset, offset = _e === void 0 ? [0, 8] : _e, onHide = _a.onHide, onShow = _a.onShow, _f = _a.placement, placement = _f === void 0 ? 'top' : _f, title = _a.title, _g = _a.trigger, trigger = _g === void 0 ? 'click' : _g, visible = _a.visible, rest = __rest$1(_a, ["children", "animation", "className", "content", "delay", "fallbackPlacements", "offset", "onHide", "onShow", "placement", "title", "trigger", "visible"]);
11683
+ var children = _a.children, _b = _a.animation, animation = _b === void 0 ? true : _b, className = _a.className, container = _a.container, content = _a.content, _c = _a.delay, delay = _c === void 0 ? 0 : _c, _d = _a.fallbackPlacements, fallbackPlacements = _d === void 0 ? ['top', 'right', 'bottom', 'left'] : _d, _e = _a.offset, offset = _e === void 0 ? [0, 8] : _e, onHide = _a.onHide, onShow = _a.onShow, _f = _a.placement, placement = _f === void 0 ? 'top' : _f, title = _a.title, _g = _a.trigger, trigger = _g === void 0 ? 'click' : _g, visible = _a.visible, rest = __rest$1(_a, ["children", "animation", "className", "container", "content", "delay", "fallbackPlacements", "offset", "onHide", "onShow", "placement", "title", "trigger", "visible"]);
11672
11684
  var popoverRef = useRef(null);
11673
11685
  var togglerRef = useRef(null);
11674
11686
  var forkedRef = useForkedRef(ref, popoverRef);
@@ -11726,8 +11738,8 @@ var CPopover = forwardRef(function (_a, ref) {
11726
11738
  onMouseEnter: function () { return toggleVisible(true); },
11727
11739
  onMouseLeave: function () { return toggleVisible(false); },
11728
11740
  }))),
11729
- typeof window !== 'undefined' &&
11730
- createPortal(React$1.createElement(Transition$1, { in: _visible, mountOnEnter: true, nodeRef: popoverRef, onEnter: onShow, onExit: onHide, timeout: {
11741
+ React$1.createElement(CConditionalPortal, { container: container, portal: true },
11742
+ React$1.createElement(Transition$1, { in: _visible, mountOnEnter: true, nodeRef: popoverRef, onEnter: onShow, onExit: onHide, timeout: {
11731
11743
  enter: 0,
11732
11744
  exit: popoverRef.current
11733
11745
  ? getTransitionDurationFromElement(popoverRef.current) + 50
@@ -11738,12 +11750,13 @@ var CPopover = forwardRef(function (_a, ref) {
11738
11750
  }, className), ref: forkedRef, role: "tooltip" }, rest),
11739
11751
  React$1.createElement("div", { className: "popover-arrow" }),
11740
11752
  React$1.createElement("div", { className: "popover-header" }, title),
11741
- React$1.createElement("div", { className: "popover-body" }, content))); }), document.body)));
11753
+ React$1.createElement("div", { className: "popover-body" }, content))); }))));
11742
11754
  });
11743
11755
  CPopover.propTypes = {
11744
11756
  animation: PropTypes$1.bool,
11745
11757
  children: PropTypes$1.node,
11746
11758
  className: PropTypes$1.string,
11759
+ container: PropTypes$1.any,
11747
11760
  content: PropTypes$1.oneOfType([PropTypes$1.string, PropTypes$1.node]),
11748
11761
  delay: PropTypes$1.oneOfType([
11749
11762
  PropTypes$1.number,
@@ -13997,7 +14010,7 @@ var CSmartTable = forwardRef(function (_a, ref) {
13997
14010
  { sides: ['bottom'], query: 'tbody' },
13998
14011
  ] }, elementCover))),
13999
14012
  (pagination || itemsPerPageSelect) && (React$1.createElement("div", { className: "row" },
14000
- React$1.createElement("div", { className: "col" }, ((pagination && numberOfPages > 1) || paginationProps) && (React$1.createElement(CSmartPagination, __assign$1({ activePage: _activePage, onActivePageChange: function (page) {
14013
+ React$1.createElement("div", { className: "col" }, ((pagination && numberOfPages > 1) || (paginationProps && paginationProps.pages > 1)) && (React$1.createElement(CSmartPagination, __assign$1({ activePage: _activePage, onActivePageChange: function (page) {
14001
14014
  pagination && typeof pagination === 'object' && pagination.external
14002
14015
  ? onActivePageChange && onActivePageChange(page)
14003
14016
  : setActivePage(page);
@@ -14375,7 +14388,7 @@ CToaster.propTypes = {
14375
14388
  CToaster.displayName = 'CToaster';
14376
14389
 
14377
14390
  var CTooltip = forwardRef(function (_a, ref) {
14378
- var children = _a.children, _b = _a.animation, animation = _b === void 0 ? true : _b, className = _a.className, content = _a.content, _c = _a.delay, delay = _c === void 0 ? 0 : _c, _d = _a.fallbackPlacements, fallbackPlacements = _d === void 0 ? ['top', 'right', 'bottom', 'left'] : _d, _e = _a.offset, offset = _e === void 0 ? [0, 6] : _e, onHide = _a.onHide, onShow = _a.onShow, _f = _a.placement, placement = _f === void 0 ? 'top' : _f, _g = _a.trigger, trigger = _g === void 0 ? ['hover', 'focus'] : _g, visible = _a.visible, rest = __rest$1(_a, ["children", "animation", "className", "content", "delay", "fallbackPlacements", "offset", "onHide", "onShow", "placement", "trigger", "visible"]);
14391
+ var children = _a.children, _b = _a.animation, animation = _b === void 0 ? true : _b, className = _a.className, container = _a.container, content = _a.content, _c = _a.delay, delay = _c === void 0 ? 0 : _c, _d = _a.fallbackPlacements, fallbackPlacements = _d === void 0 ? ['top', 'right', 'bottom', 'left'] : _d, _e = _a.offset, offset = _e === void 0 ? [0, 6] : _e, onHide = _a.onHide, onShow = _a.onShow, _f = _a.placement, placement = _f === void 0 ? 'top' : _f, _g = _a.trigger, trigger = _g === void 0 ? ['hover', 'focus'] : _g, visible = _a.visible, rest = __rest$1(_a, ["children", "animation", "className", "container", "content", "delay", "fallbackPlacements", "offset", "onHide", "onShow", "placement", "trigger", "visible"]);
14379
14392
  var tooltipRef = useRef(null);
14380
14393
  var togglerRef = useRef(null);
14381
14394
  var forkedRef = useForkedRef(ref, tooltipRef);
@@ -14433,8 +14446,8 @@ var CTooltip = forwardRef(function (_a, ref) {
14433
14446
  onMouseEnter: function () { return toggleVisible(true); },
14434
14447
  onMouseLeave: function () { return toggleVisible(false); },
14435
14448
  }))),
14436
- typeof window !== 'undefined' &&
14437
- createPortal(React$1.createElement(Transition$1, { in: _visible, mountOnEnter: true, nodeRef: tooltipRef, onEnter: onShow, onExit: onHide, timeout: {
14449
+ React$1.createElement(CConditionalPortal, { container: container, portal: true },
14450
+ React$1.createElement(Transition$1, { in: _visible, mountOnEnter: true, nodeRef: tooltipRef, onEnter: onShow, onExit: onHide, timeout: {
14438
14451
  enter: 0,
14439
14452
  exit: tooltipRef.current
14440
14453
  ? getTransitionDurationFromElement(tooltipRef.current) + 50
@@ -14444,11 +14457,12 @@ var CTooltip = forwardRef(function (_a, ref) {
14444
14457
  show: state === 'entered',
14445
14458
  }, className), ref: forkedRef, role: "tooltip" }, rest),
14446
14459
  React$1.createElement("div", { className: "tooltip-arrow" }),
14447
- React$1.createElement("div", { className: "tooltip-inner" }, content))); }), document.body)));
14460
+ React$1.createElement("div", { className: "tooltip-inner" }, content))); }))));
14448
14461
  });
14449
14462
  CTooltip.propTypes = {
14450
14463
  animation: PropTypes$1.bool,
14451
14464
  children: PropTypes$1.node,
14465
+ container: PropTypes$1.any,
14452
14466
  content: PropTypes$1.oneOfType([PropTypes$1.string, PropTypes$1.node]),
14453
14467
  delay: PropTypes$1.oneOfType([
14454
14468
  PropTypes$1.number,