@coreui/react 4.10.1 → 4.11.1
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 +63 -36
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +63 -36
- 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/modal/CModal.tsx +1 -4
- package/src/components/popover/CPopover.tsx +69 -51
- package/src/components/tooltip/CTooltip.tsx +69 -58
package/dist/index.js
CHANGED
|
@@ -5160,13 +5160,24 @@ CCarouselItem.propTypes = {
|
|
|
5160
5160
|
};
|
|
5161
5161
|
CCarouselItem.displayName = 'CCarouselItem';
|
|
5162
5162
|
|
|
5163
|
+
var getContainer = function (container) {
|
|
5164
|
+
if (container) {
|
|
5165
|
+
return typeof container === 'function' ? container() : container;
|
|
5166
|
+
}
|
|
5167
|
+
return document.body;
|
|
5168
|
+
};
|
|
5163
5169
|
var CConditionalPortal = function (_a) {
|
|
5164
|
-
var children = _a.children, portal = _a.portal;
|
|
5165
|
-
|
|
5170
|
+
var children = _a.children, container = _a.container, portal = _a.portal;
|
|
5171
|
+
var _b = React.useState(null), _container = _b[0], setContainer = _b[1];
|
|
5172
|
+
React.useEffect(function () {
|
|
5173
|
+
portal && setContainer(getContainer(container) || document.body);
|
|
5174
|
+
}, [container, portal]);
|
|
5175
|
+
return typeof window !== 'undefined' && portal && _container ? (ReactDOM.createPortal(children, _container)) : (React.createElement(React.Fragment, null, children));
|
|
5166
5176
|
};
|
|
5167
5177
|
CConditionalPortal.propTypes = {
|
|
5168
5178
|
children: PropTypes.node,
|
|
5169
|
-
|
|
5179
|
+
container: PropTypes.any,
|
|
5180
|
+
portal: PropTypes.bool,
|
|
5170
5181
|
};
|
|
5171
5182
|
CConditionalPortal.displayName = 'CConditionalPortal';
|
|
5172
5183
|
|
|
@@ -5192,7 +5203,7 @@ var getPlacement = function (placement, direction, alignment, isRTL) {
|
|
|
5192
5203
|
var CDropdownContext = React.createContext({});
|
|
5193
5204
|
var CDropdown = React.forwardRef(function (_a, ref) {
|
|
5194
5205
|
var _b;
|
|
5195
|
-
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"]);
|
|
5206
|
+
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"]);
|
|
5196
5207
|
var dropdownRef = React.useRef(null);
|
|
5197
5208
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5198
5209
|
var dropdownToggleRef = React.useRef(null);
|
|
@@ -5207,6 +5218,7 @@ var CDropdown = React.forwardRef(function (_a, ref) {
|
|
|
5207
5218
|
}
|
|
5208
5219
|
var contextValues = {
|
|
5209
5220
|
alignment: alignment,
|
|
5221
|
+
container: container,
|
|
5210
5222
|
dark: dark,
|
|
5211
5223
|
dropdownToggleRef: dropdownToggleRef,
|
|
5212
5224
|
dropdownMenuRef: dropdownMenuRef,
|
|
@@ -5361,9 +5373,9 @@ var alignmentClassNames = function (alignment) {
|
|
|
5361
5373
|
};
|
|
5362
5374
|
var CDropdownMenu = React.forwardRef(function (_a, ref) {
|
|
5363
5375
|
var children = _a.children, className = _a.className, _b = _a.component, Component = _b === void 0 ? 'ul' : _b, rest = __rest(_a, ["children", "className", "component"]);
|
|
5364
|
-
var _c = React.useContext(CDropdownContext), alignment = _c.alignment, dark = _c.dark, dropdownMenuRef = _c.dropdownMenuRef, popper = _c.popper, portal = _c.portal, visible = _c.visible;
|
|
5376
|
+
var _c = React.useContext(CDropdownContext), alignment = _c.alignment, container = _c.container, dark = _c.dark, dropdownMenuRef = _c.dropdownMenuRef, popper = _c.popper, portal = _c.portal, visible = _c.visible;
|
|
5365
5377
|
var forkedRef = useForkedRef(ref, dropdownMenuRef);
|
|
5366
|
-
return (React.createElement(CConditionalPortal, { portal: portal !== null && portal !== void 0 ? portal : false },
|
|
5378
|
+
return (React.createElement(CConditionalPortal, { container: container, portal: portal !== null && portal !== void 0 ? portal : false },
|
|
5367
5379
|
React.createElement(Component, __assign({ className: classNames('dropdown-menu', {
|
|
5368
5380
|
'dropdown-menu-dark': dark,
|
|
5369
5381
|
show: visible,
|
|
@@ -6097,8 +6109,7 @@ var CModal = React.forwardRef(function (_a, ref) {
|
|
|
6097
6109
|
};
|
|
6098
6110
|
}, [_visible]);
|
|
6099
6111
|
var handleClickOutside = function (event) {
|
|
6100
|
-
if (
|
|
6101
|
-
!modalContentRef.current.contains(event.target)) {
|
|
6112
|
+
if (modalRef.current && modalRef.current == event.target) {
|
|
6102
6113
|
handleDismiss();
|
|
6103
6114
|
}
|
|
6104
6115
|
};
|
|
@@ -6664,10 +6675,11 @@ CProgress.propTypes = {
|
|
|
6664
6675
|
CProgress.displayName = 'CProgress';
|
|
6665
6676
|
|
|
6666
6677
|
var CPopover = React.forwardRef(function (_a, ref) {
|
|
6667
|
-
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
|
|
6678
|
+
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; _a.onShow; var _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"]);
|
|
6668
6679
|
var popoverRef = React.useRef(null);
|
|
6669
6680
|
var togglerRef = React.useRef(null);
|
|
6670
6681
|
var forkedRef = useForkedRef(ref, popoverRef);
|
|
6682
|
+
var uID = React.useRef("popover".concat(Math.floor(Math.random() * 1000000)));
|
|
6671
6683
|
var _h = usePopper(), initPopper = _h.initPopper, destroyPopper = _h.destroyPopper;
|
|
6672
6684
|
var _j = React.useState(visible), _visible = _j[0], setVisible = _j[1];
|
|
6673
6685
|
var _delay = typeof delay === 'number' ? { show: delay, hide: delay } : delay;
|
|
@@ -6697,14 +6709,6 @@ var CPopover = React.forwardRef(function (_a, ref) {
|
|
|
6697
6709
|
React.useEffect(function () {
|
|
6698
6710
|
setVisible(visible);
|
|
6699
6711
|
}, [visible]);
|
|
6700
|
-
React.useEffect(function () {
|
|
6701
|
-
if (_visible && togglerRef.current && popoverRef.current) {
|
|
6702
|
-
initPopper(togglerRef.current, popoverRef.current, popperConfig);
|
|
6703
|
-
}
|
|
6704
|
-
return function () {
|
|
6705
|
-
destroyPopper();
|
|
6706
|
-
};
|
|
6707
|
-
}, [_visible]);
|
|
6708
6712
|
var toggleVisible = function (visible) {
|
|
6709
6713
|
if (visible) {
|
|
6710
6714
|
setTimeout(function () { return setVisible(true); }, _delay.show);
|
|
@@ -6713,7 +6717,9 @@ var CPopover = React.forwardRef(function (_a, ref) {
|
|
|
6713
6717
|
setTimeout(function () { return setVisible(false); }, _delay.hide);
|
|
6714
6718
|
};
|
|
6715
6719
|
return (React.createElement(React.Fragment, null,
|
|
6716
|
-
React.cloneElement(children, __assign(__assign(__assign({
|
|
6720
|
+
React.cloneElement(children, __assign(__assign(__assign(__assign(__assign({}, (_visible && {
|
|
6721
|
+
'aria-describedby': uID.current,
|
|
6722
|
+
})), { ref: togglerRef }), ((trigger === 'click' || trigger.includes('click')) && {
|
|
6717
6723
|
onClick: function () { return toggleVisible(!_visible); },
|
|
6718
6724
|
})), ((trigger === 'focus' || trigger.includes('focus')) && {
|
|
6719
6725
|
onFocus: function () { return toggleVisible(true); },
|
|
@@ -6722,8 +6728,18 @@ var CPopover = React.forwardRef(function (_a, ref) {
|
|
|
6722
6728
|
onMouseEnter: function () { return toggleVisible(true); },
|
|
6723
6729
|
onMouseLeave: function () { return toggleVisible(false); },
|
|
6724
6730
|
}))),
|
|
6725
|
-
|
|
6726
|
-
|
|
6731
|
+
React.createElement(CConditionalPortal, { container: container, portal: true },
|
|
6732
|
+
React.createElement(Transition$1, { in: _visible, mountOnEnter: true, nodeRef: popoverRef, onEnter: function () {
|
|
6733
|
+
if (togglerRef.current && popoverRef.current) {
|
|
6734
|
+
initPopper(togglerRef.current, popoverRef.current, popperConfig);
|
|
6735
|
+
}
|
|
6736
|
+
}, onEntering: function () {
|
|
6737
|
+
if (togglerRef.current && popoverRef.current) {
|
|
6738
|
+
popoverRef.current.style.display = 'initial';
|
|
6739
|
+
}
|
|
6740
|
+
}, onExit: onHide, onExited: function () {
|
|
6741
|
+
destroyPopper();
|
|
6742
|
+
}, timeout: {
|
|
6727
6743
|
enter: 0,
|
|
6728
6744
|
exit: popoverRef.current
|
|
6729
6745
|
? getTransitionDurationFromElement(popoverRef.current) + 50
|
|
@@ -6731,15 +6747,18 @@ var CPopover = React.forwardRef(function (_a, ref) {
|
|
|
6731
6747
|
}, unmountOnExit: true }, function (state) { return (React.createElement("div", __assign({ className: classNames('popover', 'bs-popover-auto', {
|
|
6732
6748
|
fade: animation,
|
|
6733
6749
|
show: state === 'entered',
|
|
6734
|
-
}, className), ref: forkedRef, role: "tooltip"
|
|
6750
|
+
}, className), id: uID.current, ref: forkedRef, role: "tooltip", style: {
|
|
6751
|
+
display: 'none',
|
|
6752
|
+
} }, rest),
|
|
6735
6753
|
React.createElement("div", { className: "popover-arrow" }),
|
|
6736
6754
|
React.createElement("div", { className: "popover-header" }, title),
|
|
6737
|
-
React.createElement("div", { className: "popover-body" }, content))); })
|
|
6755
|
+
React.createElement("div", { className: "popover-body" }, content))); }))));
|
|
6738
6756
|
});
|
|
6739
6757
|
CPopover.propTypes = {
|
|
6740
6758
|
animation: PropTypes.bool,
|
|
6741
6759
|
children: PropTypes.node,
|
|
6742
6760
|
className: PropTypes.string,
|
|
6761
|
+
container: PropTypes.any,
|
|
6743
6762
|
content: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
6744
6763
|
delay: PropTypes.oneOfType([
|
|
6745
6764
|
PropTypes.number,
|
|
@@ -7280,10 +7299,11 @@ CToaster.propTypes = {
|
|
|
7280
7299
|
CToaster.displayName = 'CToaster';
|
|
7281
7300
|
|
|
7282
7301
|
var CTooltip = React.forwardRef(function (_a, ref) {
|
|
7283
|
-
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
|
|
7302
|
+
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; _a.onShow; var _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"]);
|
|
7284
7303
|
var tooltipRef = React.useRef(null);
|
|
7285
7304
|
var togglerRef = React.useRef(null);
|
|
7286
7305
|
var forkedRef = useForkedRef(ref, tooltipRef);
|
|
7306
|
+
var uID = React.useRef("tooltip".concat(Math.floor(Math.random() * 1000000)));
|
|
7287
7307
|
var _h = usePopper(), initPopper = _h.initPopper, destroyPopper = _h.destroyPopper;
|
|
7288
7308
|
var _j = React.useState(visible), _visible = _j[0], setVisible = _j[1];
|
|
7289
7309
|
var _delay = typeof delay === 'number' ? { show: delay, hide: delay } : delay;
|
|
@@ -7313,14 +7333,6 @@ var CTooltip = React.forwardRef(function (_a, ref) {
|
|
|
7313
7333
|
React.useEffect(function () {
|
|
7314
7334
|
setVisible(visible);
|
|
7315
7335
|
}, [visible]);
|
|
7316
|
-
React.useEffect(function () {
|
|
7317
|
-
if (_visible && togglerRef.current && tooltipRef.current) {
|
|
7318
|
-
initPopper(togglerRef.current, tooltipRef.current, popperConfig);
|
|
7319
|
-
}
|
|
7320
|
-
return function () {
|
|
7321
|
-
destroyPopper();
|
|
7322
|
-
};
|
|
7323
|
-
}, [_visible]);
|
|
7324
7336
|
var toggleVisible = function (visible) {
|
|
7325
7337
|
if (visible) {
|
|
7326
7338
|
setTimeout(function () { return setVisible(true); }, _delay.show);
|
|
@@ -7329,7 +7341,9 @@ var CTooltip = React.forwardRef(function (_a, ref) {
|
|
|
7329
7341
|
setTimeout(function () { return setVisible(false); }, _delay.hide);
|
|
7330
7342
|
};
|
|
7331
7343
|
return (React.createElement(React.Fragment, null,
|
|
7332
|
-
React.cloneElement(children, __assign(__assign(__assign({
|
|
7344
|
+
React.cloneElement(children, __assign(__assign(__assign(__assign(__assign({}, (_visible && {
|
|
7345
|
+
'aria-describedby': uID.current,
|
|
7346
|
+
})), { ref: togglerRef }), ((trigger === 'click' || trigger.includes('click')) && {
|
|
7333
7347
|
onClick: function () { return toggleVisible(!_visible); },
|
|
7334
7348
|
})), ((trigger === 'focus' || trigger.includes('focus')) && {
|
|
7335
7349
|
onFocus: function () { return toggleVisible(true); },
|
|
@@ -7338,8 +7352,18 @@ var CTooltip = React.forwardRef(function (_a, ref) {
|
|
|
7338
7352
|
onMouseEnter: function () { return toggleVisible(true); },
|
|
7339
7353
|
onMouseLeave: function () { return toggleVisible(false); },
|
|
7340
7354
|
}))),
|
|
7341
|
-
|
|
7342
|
-
|
|
7355
|
+
React.createElement(CConditionalPortal, { container: container, portal: true },
|
|
7356
|
+
React.createElement(Transition$1, { in: _visible, mountOnEnter: true, nodeRef: tooltipRef, onEnter: function () {
|
|
7357
|
+
if (togglerRef.current && tooltipRef.current) {
|
|
7358
|
+
initPopper(togglerRef.current, tooltipRef.current, popperConfig);
|
|
7359
|
+
}
|
|
7360
|
+
}, onEntering: function () {
|
|
7361
|
+
if (togglerRef.current && tooltipRef.current) {
|
|
7362
|
+
tooltipRef.current.style.display = 'initial';
|
|
7363
|
+
}
|
|
7364
|
+
}, onExit: onHide, onExited: function () {
|
|
7365
|
+
destroyPopper();
|
|
7366
|
+
}, timeout: {
|
|
7343
7367
|
enter: 0,
|
|
7344
7368
|
exit: tooltipRef.current
|
|
7345
7369
|
? getTransitionDurationFromElement(tooltipRef.current) + 50
|
|
@@ -7347,13 +7371,16 @@ var CTooltip = React.forwardRef(function (_a, ref) {
|
|
|
7347
7371
|
}, unmountOnExit: true }, function (state) { return (React.createElement("div", __assign({ className: classNames('tooltip', 'bs-tooltip-auto', {
|
|
7348
7372
|
fade: animation,
|
|
7349
7373
|
show: state === 'entered',
|
|
7350
|
-
}, className), ref: forkedRef, role: "tooltip"
|
|
7374
|
+
}, className), id: uID.current, ref: forkedRef, role: "tooltip", style: {
|
|
7375
|
+
display: 'none',
|
|
7376
|
+
} }, rest),
|
|
7351
7377
|
React.createElement("div", { className: "tooltip-arrow" }),
|
|
7352
|
-
React.createElement("div", { className: "tooltip-inner" }, content))); })
|
|
7378
|
+
React.createElement("div", { className: "tooltip-inner" }, content))); }))));
|
|
7353
7379
|
});
|
|
7354
7380
|
CTooltip.propTypes = {
|
|
7355
7381
|
animation: PropTypes.bool,
|
|
7356
7382
|
children: PropTypes.node,
|
|
7383
|
+
container: PropTypes.any,
|
|
7357
7384
|
content: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
7358
7385
|
delay: PropTypes.oneOfType([
|
|
7359
7386
|
PropTypes.number,
|