@coreui/react 4.3.1 → 4.4.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/dropdown/CDropdown.d.ts +1 -3
- package/dist/index.es.js +106 -64
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +106 -64
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/components/carousel/CCarousel.tsx +1 -1
- package/src/components/dropdown/CDropdown.tsx +7 -5
- package/src/components/dropdown/CDropdownMenu.tsx +8 -0
- package/src/components/dropdown/CDropdownToggle.tsx +1 -1
- package/src/components/modal/CModal.tsx +18 -1
- package/src/components/nav/CNavGroup.tsx +4 -1
- package/src/components/sidebar/CSidebarNav.tsx +4 -1
- package/src/components/toast/__tests__/__snapshots__/CToast.spec.tsx.snap +13 -0
package/dist/index.js
CHANGED
|
@@ -1263,9 +1263,9 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1263
1263
|
var classnames = {exports: {}};
|
|
1264
1264
|
|
|
1265
1265
|
/*!
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1266
|
+
Copyright (c) 2018 Jed Watson.
|
|
1267
|
+
Licensed under the MIT License (MIT), see
|
|
1268
|
+
http://jedwatson.github.io/classnames
|
|
1269
1269
|
*/
|
|
1270
1270
|
|
|
1271
1271
|
(function (module) {
|
|
@@ -1294,14 +1294,15 @@ var classnames = {exports: {}};
|
|
|
1294
1294
|
}
|
|
1295
1295
|
}
|
|
1296
1296
|
} else if (argType === 'object') {
|
|
1297
|
-
if (arg.toString
|
|
1298
|
-
for (var key in arg) {
|
|
1299
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
1300
|
-
classes.push(key);
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
} else {
|
|
1297
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
1304
1298
|
classes.push(arg.toString());
|
|
1299
|
+
continue;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
for (var key in arg) {
|
|
1303
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
1304
|
+
classes.push(key);
|
|
1305
|
+
}
|
|
1305
1306
|
}
|
|
1306
1307
|
}
|
|
1307
1308
|
}
|
|
@@ -4255,38 +4256,57 @@ var max = Math.max;
|
|
|
4255
4256
|
var min = Math.min;
|
|
4256
4257
|
var round = Math.round;
|
|
4257
4258
|
|
|
4258
|
-
function
|
|
4259
|
+
function getUAString() {
|
|
4260
|
+
var uaData = navigator.userAgentData;
|
|
4261
|
+
|
|
4262
|
+
if (uaData != null && uaData.brands) {
|
|
4263
|
+
return uaData.brands.map(function (item) {
|
|
4264
|
+
return item.brand + "/" + item.version;
|
|
4265
|
+
}).join(' ');
|
|
4266
|
+
}
|
|
4267
|
+
|
|
4268
|
+
return navigator.userAgent;
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
function isLayoutViewport() {
|
|
4272
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|
4273
|
+
}
|
|
4274
|
+
|
|
4275
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
4259
4276
|
if (includeScale === void 0) {
|
|
4260
4277
|
includeScale = false;
|
|
4261
4278
|
}
|
|
4262
4279
|
|
|
4263
|
-
|
|
4280
|
+
if (isFixedStrategy === void 0) {
|
|
4281
|
+
isFixedStrategy = false;
|
|
4282
|
+
}
|
|
4283
|
+
|
|
4284
|
+
var clientRect = element.getBoundingClientRect();
|
|
4264
4285
|
var scaleX = 1;
|
|
4265
4286
|
var scaleY = 1;
|
|
4266
4287
|
|
|
4267
|
-
if (isHTMLElement(element)
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
// Fallback to 1 in case both values are `0`
|
|
4271
|
-
|
|
4272
|
-
if (offsetWidth > 0) {
|
|
4273
|
-
scaleX = round(rect.width) / offsetWidth || 1;
|
|
4274
|
-
}
|
|
4275
|
-
|
|
4276
|
-
if (offsetHeight > 0) {
|
|
4277
|
-
scaleY = round(rect.height) / offsetHeight || 1;
|
|
4278
|
-
}
|
|
4288
|
+
if (includeScale && isHTMLElement(element)) {
|
|
4289
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
4290
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
4279
4291
|
}
|
|
4280
4292
|
|
|
4293
|
+
var _ref = isElement(element) ? getWindow(element) : window,
|
|
4294
|
+
visualViewport = _ref.visualViewport;
|
|
4295
|
+
|
|
4296
|
+
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
4297
|
+
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
|
4298
|
+
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
|
4299
|
+
var width = clientRect.width / scaleX;
|
|
4300
|
+
var height = clientRect.height / scaleY;
|
|
4281
4301
|
return {
|
|
4282
|
-
width:
|
|
4283
|
-
height:
|
|
4284
|
-
top:
|
|
4285
|
-
right:
|
|
4286
|
-
bottom:
|
|
4287
|
-
left:
|
|
4288
|
-
x:
|
|
4289
|
-
y:
|
|
4302
|
+
width: width,
|
|
4303
|
+
height: height,
|
|
4304
|
+
top: y,
|
|
4305
|
+
right: x + width,
|
|
4306
|
+
bottom: y + height,
|
|
4307
|
+
left: x,
|
|
4308
|
+
x: x,
|
|
4309
|
+
y: y
|
|
4290
4310
|
};
|
|
4291
4311
|
}
|
|
4292
4312
|
|
|
@@ -4381,8 +4401,8 @@ function getTrueOffsetParent(element) {
|
|
|
4381
4401
|
|
|
4382
4402
|
|
|
4383
4403
|
function getContainingBlock(element) {
|
|
4384
|
-
var isFirefox =
|
|
4385
|
-
var isIE =
|
|
4404
|
+
var isFirefox = /firefox/i.test(getUAString());
|
|
4405
|
+
var isIE = /Trident/i.test(getUAString());
|
|
4386
4406
|
|
|
4387
4407
|
if (isIE && isHTMLElement(element)) {
|
|
4388
4408
|
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
|
|
@@ -4822,31 +4842,21 @@ function getWindowScrollBarX(element) {
|
|
|
4822
4842
|
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
|
4823
4843
|
}
|
|
4824
4844
|
|
|
4825
|
-
function getViewportRect(element) {
|
|
4845
|
+
function getViewportRect(element, strategy) {
|
|
4826
4846
|
var win = getWindow(element);
|
|
4827
4847
|
var html = getDocumentElement(element);
|
|
4828
4848
|
var visualViewport = win.visualViewport;
|
|
4829
4849
|
var width = html.clientWidth;
|
|
4830
4850
|
var height = html.clientHeight;
|
|
4831
4851
|
var x = 0;
|
|
4832
|
-
var y = 0;
|
|
4833
|
-
// can be obscured underneath it.
|
|
4834
|
-
// Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
|
|
4835
|
-
// if it isn't open, so if this isn't available, the popper will be detected
|
|
4836
|
-
// to overflow the bottom of the screen too early.
|
|
4852
|
+
var y = 0;
|
|
4837
4853
|
|
|
4838
4854
|
if (visualViewport) {
|
|
4839
4855
|
width = visualViewport.width;
|
|
4840
|
-
height = visualViewport.height;
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
// Feature detection fails in mobile emulation mode in Chrome.
|
|
4845
|
-
// Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
|
|
4846
|
-
// 0.001
|
|
4847
|
-
// Fallback here: "Not Safari" userAgent
|
|
4848
|
-
|
|
4849
|
-
if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
|
|
4856
|
+
height = visualViewport.height;
|
|
4857
|
+
var layoutViewport = isLayoutViewport();
|
|
4858
|
+
|
|
4859
|
+
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
4850
4860
|
x = visualViewport.offsetLeft;
|
|
4851
4861
|
y = visualViewport.offsetTop;
|
|
4852
4862
|
}
|
|
@@ -4940,8 +4950,8 @@ function rectToClientRect(rect) {
|
|
|
4940
4950
|
});
|
|
4941
4951
|
}
|
|
4942
4952
|
|
|
4943
|
-
function getInnerBoundingClientRect(element) {
|
|
4944
|
-
var rect = getBoundingClientRect(element);
|
|
4953
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
4954
|
+
var rect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
4945
4955
|
rect.top = rect.top + element.clientTop;
|
|
4946
4956
|
rect.left = rect.left + element.clientLeft;
|
|
4947
4957
|
rect.bottom = rect.top + element.clientHeight;
|
|
@@ -4953,8 +4963,8 @@ function getInnerBoundingClientRect(element) {
|
|
|
4953
4963
|
return rect;
|
|
4954
4964
|
}
|
|
4955
4965
|
|
|
4956
|
-
function getClientRectFromMixedType(element, clippingParent) {
|
|
4957
|
-
return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
4966
|
+
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
|
4967
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
4958
4968
|
} // A "clipping parent" is an overflowable container with the characteristic of
|
|
4959
4969
|
// clipping (or hiding) overflowing elements with a position different from
|
|
4960
4970
|
// `initial`
|
|
@@ -4977,18 +4987,18 @@ function getClippingParents(element) {
|
|
|
4977
4987
|
// clipping parents
|
|
4978
4988
|
|
|
4979
4989
|
|
|
4980
|
-
function getClippingRect(element, boundary, rootBoundary) {
|
|
4990
|
+
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
|
4981
4991
|
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
|
4982
4992
|
var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
|
4983
4993
|
var firstClippingParent = clippingParents[0];
|
|
4984
4994
|
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
|
4985
|
-
var rect = getClientRectFromMixedType(element, clippingParent);
|
|
4995
|
+
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
|
4986
4996
|
accRect.top = max(rect.top, accRect.top);
|
|
4987
4997
|
accRect.right = min(rect.right, accRect.right);
|
|
4988
4998
|
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
4989
4999
|
accRect.left = max(rect.left, accRect.left);
|
|
4990
5000
|
return accRect;
|
|
4991
|
-
}, getClientRectFromMixedType(element, firstClippingParent));
|
|
5001
|
+
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
|
4992
5002
|
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
4993
5003
|
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
4994
5004
|
clippingRect.x = clippingRect.left;
|
|
@@ -5069,6 +5079,8 @@ function detectOverflow(state, options) {
|
|
|
5069
5079
|
var _options = options,
|
|
5070
5080
|
_options$placement = _options.placement,
|
|
5071
5081
|
placement = _options$placement === void 0 ? state.placement : _options$placement,
|
|
5082
|
+
_options$strategy = _options.strategy,
|
|
5083
|
+
strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
|
|
5072
5084
|
_options$boundary = _options.boundary,
|
|
5073
5085
|
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
|
5074
5086
|
_options$rootBoundary = _options.rootBoundary,
|
|
@@ -5083,7 +5095,7 @@ function detectOverflow(state, options) {
|
|
|
5083
5095
|
var altContext = elementContext === popper ? reference : popper;
|
|
5084
5096
|
var popperRect = state.rects.popper;
|
|
5085
5097
|
var element = state.elements[altBoundary ? altContext : elementContext];
|
|
5086
|
-
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
|
|
5098
|
+
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
|
5087
5099
|
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
|
5088
5100
|
var popperOffsets = computeOffsets({
|
|
5089
5101
|
reference: referenceClientRect,
|
|
@@ -5601,7 +5613,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
|
5601
5613
|
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
5602
5614
|
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
|
5603
5615
|
var documentElement = getDocumentElement(offsetParent);
|
|
5604
|
-
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
|
|
5616
|
+
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
|
5605
5617
|
var scroll = {
|
|
5606
5618
|
scrollLeft: 0,
|
|
5607
5619
|
scrollTop: 0
|
|
@@ -6473,7 +6485,11 @@ var CDropdown = React.forwardRef(function (_a, ref) {
|
|
|
6473
6485
|
};
|
|
6474
6486
|
var _className = classNames(variant === 'nav-item' ? 'nav-item dropdown' : variant, {
|
|
6475
6487
|
show: _visible,
|
|
6476
|
-
}, direction
|
|
6488
|
+
}, direction === 'center'
|
|
6489
|
+
? 'dropdown-center'
|
|
6490
|
+
: direction === 'dropup-center'
|
|
6491
|
+
? 'dropup dropup-center'
|
|
6492
|
+
: direction, className);
|
|
6477
6493
|
React.useEffect(function () {
|
|
6478
6494
|
setVisible(visible);
|
|
6479
6495
|
}, [visible]);
|
|
@@ -6507,7 +6523,7 @@ CDropdown.propTypes = {
|
|
|
6507
6523
|
className: propTypes.exports.string,
|
|
6508
6524
|
component: propTypes.exports.elementType,
|
|
6509
6525
|
dark: propTypes.exports.bool,
|
|
6510
|
-
direction: propTypes.exports.oneOf(['dropup', 'dropend', 'dropstart']),
|
|
6526
|
+
direction: propTypes.exports.oneOf(['center', 'dropup', 'dropup-center', 'dropend', 'dropstart']),
|
|
6511
6527
|
onHide: propTypes.exports.func,
|
|
6512
6528
|
onShow: propTypes.exports.func,
|
|
6513
6529
|
placement: placementPropType,
|
|
@@ -6596,9 +6612,15 @@ var CDropdownMenu = function (_a) {
|
|
|
6596
6612
|
}
|
|
6597
6613
|
};
|
|
6598
6614
|
var _placement = placement;
|
|
6615
|
+
if (direction === 'center') {
|
|
6616
|
+
_placement = 'bottom';
|
|
6617
|
+
}
|
|
6599
6618
|
if (direction === 'dropup') {
|
|
6600
6619
|
_placement = 'top-start';
|
|
6601
6620
|
}
|
|
6621
|
+
if (direction === 'dropup-center') {
|
|
6622
|
+
_placement = 'top';
|
|
6623
|
+
}
|
|
6602
6624
|
if (direction === 'dropend') {
|
|
6603
6625
|
_placement = 'right-start';
|
|
6604
6626
|
}
|
|
@@ -7359,6 +7381,10 @@ var CModal = React.forwardRef(function (_a, ref) {
|
|
|
7359
7381
|
React.useLayoutEffect(function () {
|
|
7360
7382
|
if (_visible) {
|
|
7361
7383
|
document.body.classList.add('modal-open');
|
|
7384
|
+
if (backdrop) {
|
|
7385
|
+
document.body.style.overflow = 'hidden';
|
|
7386
|
+
document.body.style.paddingRight = '0px';
|
|
7387
|
+
}
|
|
7362
7388
|
setTimeout(function () {
|
|
7363
7389
|
var _a;
|
|
7364
7390
|
(_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -7366,8 +7392,18 @@ var CModal = React.forwardRef(function (_a, ref) {
|
|
|
7366
7392
|
}
|
|
7367
7393
|
else {
|
|
7368
7394
|
document.body.classList.remove('modal-open');
|
|
7395
|
+
if (backdrop) {
|
|
7396
|
+
document.body.style.removeProperty('overflow');
|
|
7397
|
+
document.body.style.removeProperty('padding-right');
|
|
7398
|
+
}
|
|
7369
7399
|
}
|
|
7370
|
-
return function () {
|
|
7400
|
+
return function () {
|
|
7401
|
+
document.body.classList.remove('modal-open');
|
|
7402
|
+
if (backdrop) {
|
|
7403
|
+
document.body.style.removeProperty('overflow');
|
|
7404
|
+
document.body.style.removeProperty('padding-right');
|
|
7405
|
+
}
|
|
7406
|
+
};
|
|
7371
7407
|
}, [_visible]);
|
|
7372
7408
|
var handleClickOutside = function (event) {
|
|
7373
7409
|
if (modalContentRef.current &&
|
|
@@ -7510,7 +7546,10 @@ var CSidebarNav = React.forwardRef(function (_a, ref) {
|
|
|
7510
7546
|
return (React__default["default"].createElement("ul", __assign({ className: classes, ref: ref }, rest),
|
|
7511
7547
|
React__default["default"].createElement(CNavContext.Provider, { value: CNavContextValues }, React__default["default"].Children.map(children, function (child, index) {
|
|
7512
7548
|
if (React__default["default"].isValidElement(child)) {
|
|
7513
|
-
return React__default["default"].cloneElement(child, {
|
|
7549
|
+
return React__default["default"].cloneElement(child, {
|
|
7550
|
+
key: index,
|
|
7551
|
+
idx: "".concat(index),
|
|
7552
|
+
});
|
|
7514
7553
|
}
|
|
7515
7554
|
return;
|
|
7516
7555
|
}))));
|
|
@@ -7570,7 +7609,10 @@ var CNavGroup = React.forwardRef(function (_a, ref) {
|
|
|
7570
7609
|
compact: compact,
|
|
7571
7610
|
}), style: __assign(__assign({}, style), transitionStyles[state]), ref: navItemsRef }, React__default["default"].Children.map(children, function (child, index) {
|
|
7572
7611
|
if (React__default["default"].isValidElement(child)) {
|
|
7573
|
-
return React__default["default"].cloneElement(child, {
|
|
7612
|
+
return React__default["default"].cloneElement(child, {
|
|
7613
|
+
key: index,
|
|
7614
|
+
idx: "".concat(idx, ".").concat(index),
|
|
7615
|
+
});
|
|
7574
7616
|
}
|
|
7575
7617
|
return;
|
|
7576
7618
|
}))); })));
|