@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/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.4.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`
|
|
@@ -44,10 +44,8 @@ export interface CDropdownProps extends HTMLAttributes<HTMLDivElement | HTMLLIEl
|
|
|
44
44
|
dark?: boolean;
|
|
45
45
|
/**
|
|
46
46
|
* Sets a specified direction and location of the dropdown menu.
|
|
47
|
-
*
|
|
48
|
-
* @type 'dropup' | 'dropend' | 'dropstart'
|
|
49
47
|
*/
|
|
50
|
-
direction?: 'dropup' | 'dropend' | 'dropstart';
|
|
48
|
+
direction?: 'center' | 'dropup' | 'dropup-center' | 'dropend' | 'dropstart';
|
|
51
49
|
/**
|
|
52
50
|
* Callback fired when the component requests to be hidden.
|
|
53
51
|
*/
|
package/dist/index.es.js
CHANGED
|
@@ -1236,9 +1236,9 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1236
1236
|
var classnames = {exports: {}};
|
|
1237
1237
|
|
|
1238
1238
|
/*!
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1239
|
+
Copyright (c) 2018 Jed Watson.
|
|
1240
|
+
Licensed under the MIT License (MIT), see
|
|
1241
|
+
http://jedwatson.github.io/classnames
|
|
1242
1242
|
*/
|
|
1243
1243
|
|
|
1244
1244
|
(function (module) {
|
|
@@ -1267,14 +1267,15 @@ var classnames = {exports: {}};
|
|
|
1267
1267
|
}
|
|
1268
1268
|
}
|
|
1269
1269
|
} else if (argType === 'object') {
|
|
1270
|
-
if (arg.toString
|
|
1271
|
-
for (var key in arg) {
|
|
1272
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
1273
|
-
classes.push(key);
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
} else {
|
|
1270
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
1277
1271
|
classes.push(arg.toString());
|
|
1272
|
+
continue;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
for (var key in arg) {
|
|
1276
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
1277
|
+
classes.push(key);
|
|
1278
|
+
}
|
|
1278
1279
|
}
|
|
1279
1280
|
}
|
|
1280
1281
|
}
|
|
@@ -4228,38 +4229,57 @@ var max = Math.max;
|
|
|
4228
4229
|
var min = Math.min;
|
|
4229
4230
|
var round = Math.round;
|
|
4230
4231
|
|
|
4231
|
-
function
|
|
4232
|
+
function getUAString() {
|
|
4233
|
+
var uaData = navigator.userAgentData;
|
|
4234
|
+
|
|
4235
|
+
if (uaData != null && uaData.brands) {
|
|
4236
|
+
return uaData.brands.map(function (item) {
|
|
4237
|
+
return item.brand + "/" + item.version;
|
|
4238
|
+
}).join(' ');
|
|
4239
|
+
}
|
|
4240
|
+
|
|
4241
|
+
return navigator.userAgent;
|
|
4242
|
+
}
|
|
4243
|
+
|
|
4244
|
+
function isLayoutViewport() {
|
|
4245
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|
4246
|
+
}
|
|
4247
|
+
|
|
4248
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
4232
4249
|
if (includeScale === void 0) {
|
|
4233
4250
|
includeScale = false;
|
|
4234
4251
|
}
|
|
4235
4252
|
|
|
4236
|
-
|
|
4253
|
+
if (isFixedStrategy === void 0) {
|
|
4254
|
+
isFixedStrategy = false;
|
|
4255
|
+
}
|
|
4256
|
+
|
|
4257
|
+
var clientRect = element.getBoundingClientRect();
|
|
4237
4258
|
var scaleX = 1;
|
|
4238
4259
|
var scaleY = 1;
|
|
4239
4260
|
|
|
4240
|
-
if (isHTMLElement(element)
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
// Fallback to 1 in case both values are `0`
|
|
4244
|
-
|
|
4245
|
-
if (offsetWidth > 0) {
|
|
4246
|
-
scaleX = round(rect.width) / offsetWidth || 1;
|
|
4247
|
-
}
|
|
4248
|
-
|
|
4249
|
-
if (offsetHeight > 0) {
|
|
4250
|
-
scaleY = round(rect.height) / offsetHeight || 1;
|
|
4251
|
-
}
|
|
4261
|
+
if (includeScale && isHTMLElement(element)) {
|
|
4262
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
4263
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
4252
4264
|
}
|
|
4253
4265
|
|
|
4266
|
+
var _ref = isElement(element) ? getWindow(element) : window,
|
|
4267
|
+
visualViewport = _ref.visualViewport;
|
|
4268
|
+
|
|
4269
|
+
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
4270
|
+
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
|
4271
|
+
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
|
4272
|
+
var width = clientRect.width / scaleX;
|
|
4273
|
+
var height = clientRect.height / scaleY;
|
|
4254
4274
|
return {
|
|
4255
|
-
width:
|
|
4256
|
-
height:
|
|
4257
|
-
top:
|
|
4258
|
-
right:
|
|
4259
|
-
bottom:
|
|
4260
|
-
left:
|
|
4261
|
-
x:
|
|
4262
|
-
y:
|
|
4275
|
+
width: width,
|
|
4276
|
+
height: height,
|
|
4277
|
+
top: y,
|
|
4278
|
+
right: x + width,
|
|
4279
|
+
bottom: y + height,
|
|
4280
|
+
left: x,
|
|
4281
|
+
x: x,
|
|
4282
|
+
y: y
|
|
4263
4283
|
};
|
|
4264
4284
|
}
|
|
4265
4285
|
|
|
@@ -4354,8 +4374,8 @@ function getTrueOffsetParent(element) {
|
|
|
4354
4374
|
|
|
4355
4375
|
|
|
4356
4376
|
function getContainingBlock(element) {
|
|
4357
|
-
var isFirefox =
|
|
4358
|
-
var isIE =
|
|
4377
|
+
var isFirefox = /firefox/i.test(getUAString());
|
|
4378
|
+
var isIE = /Trident/i.test(getUAString());
|
|
4359
4379
|
|
|
4360
4380
|
if (isIE && isHTMLElement(element)) {
|
|
4361
4381
|
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
|
|
@@ -4795,31 +4815,21 @@ function getWindowScrollBarX(element) {
|
|
|
4795
4815
|
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
|
4796
4816
|
}
|
|
4797
4817
|
|
|
4798
|
-
function getViewportRect(element) {
|
|
4818
|
+
function getViewportRect(element, strategy) {
|
|
4799
4819
|
var win = getWindow(element);
|
|
4800
4820
|
var html = getDocumentElement(element);
|
|
4801
4821
|
var visualViewport = win.visualViewport;
|
|
4802
4822
|
var width = html.clientWidth;
|
|
4803
4823
|
var height = html.clientHeight;
|
|
4804
4824
|
var x = 0;
|
|
4805
|
-
var y = 0;
|
|
4806
|
-
// can be obscured underneath it.
|
|
4807
|
-
// Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
|
|
4808
|
-
// if it isn't open, so if this isn't available, the popper will be detected
|
|
4809
|
-
// to overflow the bottom of the screen too early.
|
|
4825
|
+
var y = 0;
|
|
4810
4826
|
|
|
4811
4827
|
if (visualViewport) {
|
|
4812
4828
|
width = visualViewport.width;
|
|
4813
|
-
height = visualViewport.height;
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
// Feature detection fails in mobile emulation mode in Chrome.
|
|
4818
|
-
// Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
|
|
4819
|
-
// 0.001
|
|
4820
|
-
// Fallback here: "Not Safari" userAgent
|
|
4821
|
-
|
|
4822
|
-
if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
|
|
4829
|
+
height = visualViewport.height;
|
|
4830
|
+
var layoutViewport = isLayoutViewport();
|
|
4831
|
+
|
|
4832
|
+
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
4823
4833
|
x = visualViewport.offsetLeft;
|
|
4824
4834
|
y = visualViewport.offsetTop;
|
|
4825
4835
|
}
|
|
@@ -4913,8 +4923,8 @@ function rectToClientRect(rect) {
|
|
|
4913
4923
|
});
|
|
4914
4924
|
}
|
|
4915
4925
|
|
|
4916
|
-
function getInnerBoundingClientRect(element) {
|
|
4917
|
-
var rect = getBoundingClientRect(element);
|
|
4926
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
4927
|
+
var rect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
4918
4928
|
rect.top = rect.top + element.clientTop;
|
|
4919
4929
|
rect.left = rect.left + element.clientLeft;
|
|
4920
4930
|
rect.bottom = rect.top + element.clientHeight;
|
|
@@ -4926,8 +4936,8 @@ function getInnerBoundingClientRect(element) {
|
|
|
4926
4936
|
return rect;
|
|
4927
4937
|
}
|
|
4928
4938
|
|
|
4929
|
-
function getClientRectFromMixedType(element, clippingParent) {
|
|
4930
|
-
return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
4939
|
+
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
|
4940
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
4931
4941
|
} // A "clipping parent" is an overflowable container with the characteristic of
|
|
4932
4942
|
// clipping (or hiding) overflowing elements with a position different from
|
|
4933
4943
|
// `initial`
|
|
@@ -4950,18 +4960,18 @@ function getClippingParents(element) {
|
|
|
4950
4960
|
// clipping parents
|
|
4951
4961
|
|
|
4952
4962
|
|
|
4953
|
-
function getClippingRect(element, boundary, rootBoundary) {
|
|
4963
|
+
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
|
4954
4964
|
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
|
4955
4965
|
var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
|
4956
4966
|
var firstClippingParent = clippingParents[0];
|
|
4957
4967
|
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
|
4958
|
-
var rect = getClientRectFromMixedType(element, clippingParent);
|
|
4968
|
+
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
|
4959
4969
|
accRect.top = max(rect.top, accRect.top);
|
|
4960
4970
|
accRect.right = min(rect.right, accRect.right);
|
|
4961
4971
|
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
4962
4972
|
accRect.left = max(rect.left, accRect.left);
|
|
4963
4973
|
return accRect;
|
|
4964
|
-
}, getClientRectFromMixedType(element, firstClippingParent));
|
|
4974
|
+
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
|
4965
4975
|
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
4966
4976
|
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
4967
4977
|
clippingRect.x = clippingRect.left;
|
|
@@ -5042,6 +5052,8 @@ function detectOverflow(state, options) {
|
|
|
5042
5052
|
var _options = options,
|
|
5043
5053
|
_options$placement = _options.placement,
|
|
5044
5054
|
placement = _options$placement === void 0 ? state.placement : _options$placement,
|
|
5055
|
+
_options$strategy = _options.strategy,
|
|
5056
|
+
strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
|
|
5045
5057
|
_options$boundary = _options.boundary,
|
|
5046
5058
|
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
|
5047
5059
|
_options$rootBoundary = _options.rootBoundary,
|
|
@@ -5056,7 +5068,7 @@ function detectOverflow(state, options) {
|
|
|
5056
5068
|
var altContext = elementContext === popper ? reference : popper;
|
|
5057
5069
|
var popperRect = state.rects.popper;
|
|
5058
5070
|
var element = state.elements[altBoundary ? altContext : elementContext];
|
|
5059
|
-
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
|
|
5071
|
+
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
|
5060
5072
|
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
|
5061
5073
|
var popperOffsets = computeOffsets({
|
|
5062
5074
|
reference: referenceClientRect,
|
|
@@ -5574,7 +5586,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
|
5574
5586
|
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
5575
5587
|
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
|
5576
5588
|
var documentElement = getDocumentElement(offsetParent);
|
|
5577
|
-
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
|
|
5589
|
+
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
|
5578
5590
|
var scroll = {
|
|
5579
5591
|
scrollLeft: 0,
|
|
5580
5592
|
scrollTop: 0
|
|
@@ -6446,7 +6458,11 @@ var CDropdown = forwardRef(function (_a, ref) {
|
|
|
6446
6458
|
};
|
|
6447
6459
|
var _className = classNames(variant === 'nav-item' ? 'nav-item dropdown' : variant, {
|
|
6448
6460
|
show: _visible,
|
|
6449
|
-
}, direction
|
|
6461
|
+
}, direction === 'center'
|
|
6462
|
+
? 'dropdown-center'
|
|
6463
|
+
: direction === 'dropup-center'
|
|
6464
|
+
? 'dropup dropup-center'
|
|
6465
|
+
: direction, className);
|
|
6450
6466
|
useEffect(function () {
|
|
6451
6467
|
setVisible(visible);
|
|
6452
6468
|
}, [visible]);
|
|
@@ -6480,7 +6496,7 @@ CDropdown.propTypes = {
|
|
|
6480
6496
|
className: propTypes.exports.string,
|
|
6481
6497
|
component: propTypes.exports.elementType,
|
|
6482
6498
|
dark: propTypes.exports.bool,
|
|
6483
|
-
direction: propTypes.exports.oneOf(['dropup', 'dropend', 'dropstart']),
|
|
6499
|
+
direction: propTypes.exports.oneOf(['center', 'dropup', 'dropup-center', 'dropend', 'dropstart']),
|
|
6484
6500
|
onHide: propTypes.exports.func,
|
|
6485
6501
|
onShow: propTypes.exports.func,
|
|
6486
6502
|
placement: placementPropType,
|
|
@@ -6569,9 +6585,15 @@ var CDropdownMenu = function (_a) {
|
|
|
6569
6585
|
}
|
|
6570
6586
|
};
|
|
6571
6587
|
var _placement = placement;
|
|
6588
|
+
if (direction === 'center') {
|
|
6589
|
+
_placement = 'bottom';
|
|
6590
|
+
}
|
|
6572
6591
|
if (direction === 'dropup') {
|
|
6573
6592
|
_placement = 'top-start';
|
|
6574
6593
|
}
|
|
6594
|
+
if (direction === 'dropup-center') {
|
|
6595
|
+
_placement = 'top';
|
|
6596
|
+
}
|
|
6575
6597
|
if (direction === 'dropend') {
|
|
6576
6598
|
_placement = 'right-start';
|
|
6577
6599
|
}
|
|
@@ -7332,6 +7354,10 @@ var CModal = forwardRef(function (_a, ref) {
|
|
|
7332
7354
|
useLayoutEffect(function () {
|
|
7333
7355
|
if (_visible) {
|
|
7334
7356
|
document.body.classList.add('modal-open');
|
|
7357
|
+
if (backdrop) {
|
|
7358
|
+
document.body.style.overflow = 'hidden';
|
|
7359
|
+
document.body.style.paddingRight = '0px';
|
|
7360
|
+
}
|
|
7335
7361
|
setTimeout(function () {
|
|
7336
7362
|
var _a;
|
|
7337
7363
|
(_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -7339,8 +7365,18 @@ var CModal = forwardRef(function (_a, ref) {
|
|
|
7339
7365
|
}
|
|
7340
7366
|
else {
|
|
7341
7367
|
document.body.classList.remove('modal-open');
|
|
7368
|
+
if (backdrop) {
|
|
7369
|
+
document.body.style.removeProperty('overflow');
|
|
7370
|
+
document.body.style.removeProperty('padding-right');
|
|
7371
|
+
}
|
|
7342
7372
|
}
|
|
7343
|
-
return function () {
|
|
7373
|
+
return function () {
|
|
7374
|
+
document.body.classList.remove('modal-open');
|
|
7375
|
+
if (backdrop) {
|
|
7376
|
+
document.body.style.removeProperty('overflow');
|
|
7377
|
+
document.body.style.removeProperty('padding-right');
|
|
7378
|
+
}
|
|
7379
|
+
};
|
|
7344
7380
|
}, [_visible]);
|
|
7345
7381
|
var handleClickOutside = function (event) {
|
|
7346
7382
|
if (modalContentRef.current &&
|
|
@@ -7483,7 +7519,10 @@ var CSidebarNav = forwardRef(function (_a, ref) {
|
|
|
7483
7519
|
return (React__default.createElement("ul", __assign({ className: classes, ref: ref }, rest),
|
|
7484
7520
|
React__default.createElement(CNavContext.Provider, { value: CNavContextValues }, React__default.Children.map(children, function (child, index) {
|
|
7485
7521
|
if (React__default.isValidElement(child)) {
|
|
7486
|
-
return React__default.cloneElement(child, {
|
|
7522
|
+
return React__default.cloneElement(child, {
|
|
7523
|
+
key: index,
|
|
7524
|
+
idx: "".concat(index),
|
|
7525
|
+
});
|
|
7487
7526
|
}
|
|
7488
7527
|
return;
|
|
7489
7528
|
}))));
|
|
@@ -7543,7 +7582,10 @@ var CNavGroup = forwardRef(function (_a, ref) {
|
|
|
7543
7582
|
compact: compact,
|
|
7544
7583
|
}), style: __assign(__assign({}, style), transitionStyles[state]), ref: navItemsRef }, React__default.Children.map(children, function (child, index) {
|
|
7545
7584
|
if (React__default.isValidElement(child)) {
|
|
7546
|
-
return React__default.cloneElement(child, {
|
|
7585
|
+
return React__default.cloneElement(child, {
|
|
7586
|
+
key: index,
|
|
7587
|
+
idx: "".concat(idx, ".").concat(index),
|
|
7588
|
+
});
|
|
7547
7589
|
}
|
|
7548
7590
|
return;
|
|
7549
7591
|
}))); })));
|