@coreui/react 4.10.1 → 4.11.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 +1 -1
- package/dist/components/conditional-portal/CConditionalPortal.d.ts +7 -1
- package/dist/components/dropdown/CDropdown.d.ts +6 -0
- package/dist/components/popover/CPopover.d.ts +6 -0
- package/dist/components/tooltip/CTooltip.d.ts +6 -0
- package/dist/index.es.js +28 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +28 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/conditional-portal/CConditionalPortal.tsx +31 -6
- package/src/components/dropdown/CDropdown.tsx +8 -0
- package/src/components/dropdown/CDropdownMenu.tsx +2 -2
- package/src/components/popover/CPopover.tsx +47 -40
- package/src/components/tooltip/CTooltip.tsx +46 -47
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
|
|
47
47
|
Several quick start options are available:
|
|
48
48
|
|
|
49
|
-
- [Download the latest release](https://github.com/coreui/coreui-react/archive/v4.
|
|
49
|
+
- [Download the latest release](https://github.com/coreui/coreui-react/archive/v4.11.0.zip)
|
|
50
50
|
- Clone the repo: `git clone https://github.com/coreui/coreui-react.git`
|
|
51
51
|
- Install with [npm](https://www.npmjs.com/): `npm install @coreui/react`
|
|
52
52
|
- 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
|
@@ -5158,13 +5158,24 @@ CCarouselItem.propTypes = {
|
|
|
5158
5158
|
};
|
|
5159
5159
|
CCarouselItem.displayName = 'CCarouselItem';
|
|
5160
5160
|
|
|
5161
|
+
var getContainer = function (container) {
|
|
5162
|
+
if (container) {
|
|
5163
|
+
return typeof container === 'function' ? container() : container;
|
|
5164
|
+
}
|
|
5165
|
+
return document.body;
|
|
5166
|
+
};
|
|
5161
5167
|
var CConditionalPortal = function (_a) {
|
|
5162
|
-
var children = _a.children, portal = _a.portal;
|
|
5163
|
-
|
|
5168
|
+
var children = _a.children, container = _a.container, portal = _a.portal;
|
|
5169
|
+
var _b = useState(null), _container = _b[0], setContainer = _b[1];
|
|
5170
|
+
useEffect(function () {
|
|
5171
|
+
portal && setContainer(getContainer(container) || document.body);
|
|
5172
|
+
}, [container, portal]);
|
|
5173
|
+
return typeof window !== 'undefined' && portal && _container ? (createPortal(children, _container)) : (React.createElement(React.Fragment, null, children));
|
|
5164
5174
|
};
|
|
5165
5175
|
CConditionalPortal.propTypes = {
|
|
5166
5176
|
children: PropTypes.node,
|
|
5167
|
-
|
|
5177
|
+
container: PropTypes.any,
|
|
5178
|
+
portal: PropTypes.bool,
|
|
5168
5179
|
};
|
|
5169
5180
|
CConditionalPortal.displayName = 'CConditionalPortal';
|
|
5170
5181
|
|
|
@@ -5190,7 +5201,7 @@ var getPlacement = function (placement, direction, alignment, isRTL) {
|
|
|
5190
5201
|
var CDropdownContext = createContext({});
|
|
5191
5202
|
var CDropdown = forwardRef(function (_a, ref) {
|
|
5192
5203
|
var _b;
|
|
5193
|
-
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(_a, ["children", "alignment", "autoClose", "className", "dark", "direction", "offset", "onHide", "onShow", "placement", "popper", "portal", "variant", "component", "visible"]);
|
|
5204
|
+
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(_a, ["children", "alignment", "autoClose", "className", "container", "dark", "direction", "offset", "onHide", "onShow", "placement", "popper", "portal", "variant", "component", "visible"]);
|
|
5194
5205
|
var dropdownRef = useRef(null);
|
|
5195
5206
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5196
5207
|
var dropdownToggleRef = useRef(null);
|
|
@@ -5205,6 +5216,7 @@ var CDropdown = forwardRef(function (_a, ref) {
|
|
|
5205
5216
|
}
|
|
5206
5217
|
var contextValues = {
|
|
5207
5218
|
alignment: alignment,
|
|
5219
|
+
container: container,
|
|
5208
5220
|
dark: dark,
|
|
5209
5221
|
dropdownToggleRef: dropdownToggleRef,
|
|
5210
5222
|
dropdownMenuRef: dropdownMenuRef,
|
|
@@ -5359,9 +5371,9 @@ var alignmentClassNames = function (alignment) {
|
|
|
5359
5371
|
};
|
|
5360
5372
|
var CDropdownMenu = forwardRef(function (_a, ref) {
|
|
5361
5373
|
var children = _a.children, className = _a.className, _b = _a.component, Component = _b === void 0 ? 'ul' : _b, rest = __rest(_a, ["children", "className", "component"]);
|
|
5362
|
-
var _c = useContext(CDropdownContext), alignment = _c.alignment, dark = _c.dark, dropdownMenuRef = _c.dropdownMenuRef, popper = _c.popper, portal = _c.portal, visible = _c.visible;
|
|
5374
|
+
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;
|
|
5363
5375
|
var forkedRef = useForkedRef(ref, dropdownMenuRef);
|
|
5364
|
-
return (React.createElement(CConditionalPortal, { portal: portal !== null && portal !== void 0 ? portal : false },
|
|
5376
|
+
return (React.createElement(CConditionalPortal, { container: container, portal: portal !== null && portal !== void 0 ? portal : false },
|
|
5365
5377
|
React.createElement(Component, __assign({ className: classNames('dropdown-menu', {
|
|
5366
5378
|
'dropdown-menu-dark': dark,
|
|
5367
5379
|
show: visible,
|
|
@@ -6662,7 +6674,7 @@ CProgress.propTypes = {
|
|
|
6662
6674
|
CProgress.displayName = 'CProgress';
|
|
6663
6675
|
|
|
6664
6676
|
var CPopover = forwardRef(function (_a, ref) {
|
|
6665
|
-
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(_a, ["children", "animation", "className", "content", "delay", "fallbackPlacements", "offset", "onHide", "onShow", "placement", "title", "trigger", "visible"]);
|
|
6677
|
+
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(_a, ["children", "animation", "className", "container", "content", "delay", "fallbackPlacements", "offset", "onHide", "onShow", "placement", "title", "trigger", "visible"]);
|
|
6666
6678
|
var popoverRef = useRef(null);
|
|
6667
6679
|
var togglerRef = useRef(null);
|
|
6668
6680
|
var forkedRef = useForkedRef(ref, popoverRef);
|
|
@@ -6720,8 +6732,8 @@ var CPopover = forwardRef(function (_a, ref) {
|
|
|
6720
6732
|
onMouseEnter: function () { return toggleVisible(true); },
|
|
6721
6733
|
onMouseLeave: function () { return toggleVisible(false); },
|
|
6722
6734
|
}))),
|
|
6723
|
-
|
|
6724
|
-
|
|
6735
|
+
React.createElement(CConditionalPortal, { container: container, portal: true },
|
|
6736
|
+
React.createElement(Transition$1, { in: _visible, mountOnEnter: true, nodeRef: popoverRef, onEnter: onShow, onExit: onHide, timeout: {
|
|
6725
6737
|
enter: 0,
|
|
6726
6738
|
exit: popoverRef.current
|
|
6727
6739
|
? getTransitionDurationFromElement(popoverRef.current) + 50
|
|
@@ -6732,12 +6744,13 @@ var CPopover = forwardRef(function (_a, ref) {
|
|
|
6732
6744
|
}, className), ref: forkedRef, role: "tooltip" }, rest),
|
|
6733
6745
|
React.createElement("div", { className: "popover-arrow" }),
|
|
6734
6746
|
React.createElement("div", { className: "popover-header" }, title),
|
|
6735
|
-
React.createElement("div", { className: "popover-body" }, content))); })
|
|
6747
|
+
React.createElement("div", { className: "popover-body" }, content))); }))));
|
|
6736
6748
|
});
|
|
6737
6749
|
CPopover.propTypes = {
|
|
6738
6750
|
animation: PropTypes.bool,
|
|
6739
6751
|
children: PropTypes.node,
|
|
6740
6752
|
className: PropTypes.string,
|
|
6753
|
+
container: PropTypes.any,
|
|
6741
6754
|
content: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
6742
6755
|
delay: PropTypes.oneOfType([
|
|
6743
6756
|
PropTypes.number,
|
|
@@ -7278,7 +7291,7 @@ CToaster.propTypes = {
|
|
|
7278
7291
|
CToaster.displayName = 'CToaster';
|
|
7279
7292
|
|
|
7280
7293
|
var CTooltip = forwardRef(function (_a, ref) {
|
|
7281
|
-
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(_a, ["children", "animation", "className", "content", "delay", "fallbackPlacements", "offset", "onHide", "onShow", "placement", "trigger", "visible"]);
|
|
7294
|
+
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(_a, ["children", "animation", "className", "container", "content", "delay", "fallbackPlacements", "offset", "onHide", "onShow", "placement", "trigger", "visible"]);
|
|
7282
7295
|
var tooltipRef = useRef(null);
|
|
7283
7296
|
var togglerRef = useRef(null);
|
|
7284
7297
|
var forkedRef = useForkedRef(ref, tooltipRef);
|
|
@@ -7336,8 +7349,8 @@ var CTooltip = forwardRef(function (_a, ref) {
|
|
|
7336
7349
|
onMouseEnter: function () { return toggleVisible(true); },
|
|
7337
7350
|
onMouseLeave: function () { return toggleVisible(false); },
|
|
7338
7351
|
}))),
|
|
7339
|
-
|
|
7340
|
-
|
|
7352
|
+
React.createElement(CConditionalPortal, { container: container, portal: true },
|
|
7353
|
+
React.createElement(Transition$1, { in: _visible, mountOnEnter: true, nodeRef: tooltipRef, onEnter: onShow, onExit: onHide, timeout: {
|
|
7341
7354
|
enter: 0,
|
|
7342
7355
|
exit: tooltipRef.current
|
|
7343
7356
|
? getTransitionDurationFromElement(tooltipRef.current) + 50
|
|
@@ -7347,11 +7360,12 @@ var CTooltip = forwardRef(function (_a, ref) {
|
|
|
7347
7360
|
show: state === 'entered',
|
|
7348
7361
|
}, className), ref: forkedRef, role: "tooltip" }, rest),
|
|
7349
7362
|
React.createElement("div", { className: "tooltip-arrow" }),
|
|
7350
|
-
React.createElement("div", { className: "tooltip-inner" }, content))); })
|
|
7363
|
+
React.createElement("div", { className: "tooltip-inner" }, content))); }))));
|
|
7351
7364
|
});
|
|
7352
7365
|
CTooltip.propTypes = {
|
|
7353
7366
|
animation: PropTypes.bool,
|
|
7354
7367
|
children: PropTypes.node,
|
|
7368
|
+
container: PropTypes.any,
|
|
7355
7369
|
content: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
7356
7370
|
delay: PropTypes.oneOfType([
|
|
7357
7371
|
PropTypes.number,
|