@coreui/react 5.0.0-alpha.1 → 5.0.0-alpha.3
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/avatar/CAvatar.d.ts +1 -1
- package/dist/components/badge/CBadge.d.ts +1 -1
- package/dist/components/card/CCard.d.ts +1 -1
- package/dist/components/dropdown/CDropdown.d.ts +1 -0
- package/dist/components/dropdown/CDropdownToggle.d.ts +6 -0
- package/dist/index.es.js +45 -19
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +45 -19
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/avatar/CAvatar.tsx +1 -1
- package/src/components/badge/CBadge.tsx +1 -1
- package/src/components/button/CButton.tsx +1 -1
- package/src/components/button/__tests__/__snapshots__/CButton.spec.tsx.snap +0 -1
- package/src/components/card/CCard.tsx +1 -1
- package/src/components/carousel/__tests__/__snapshots__/CCarousel.spec.tsx.snap +9 -5
- package/src/components/dropdown/CDropdown.tsx +43 -1
- package/src/components/dropdown/CDropdownToggle.tsx +12 -5
- package/src/components/nav/__tests__/__snapshots__/CNav.spec.tsx.snap +5 -4
- package/src/components/navbar/__tests__/CNavbar.spec.tsx +1 -1
- package/src/components/navbar/__tests__/__snapshots__/CNavbar.spec.tsx.snap +2 -1
- package/src/components/progress/__tests__/__snapshots__/CProgress.spec.tsx.snap +10 -5
- package/src/components/progress/__tests__/__snapshots__/CProgressBar.spec.tsx.snap +0 -8
- package/src/components/widgets/CWidgetStatsA.tsx +1 -1
- package/src/components/widgets/CWidgetStatsB.tsx +2 -2
- package/src/components/widgets/CWidgetStatsC.tsx +4 -12
- package/src/components/widgets/CWidgetStatsD.tsx +1 -1
- package/src/components/widgets/CWidgetStatsE.tsx +1 -1
- package/src/components/widgets/CWidgetStatsF.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsA.spec.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsB.spec.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsC.spec.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsD.spec.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsE.spec.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsF.spec.tsx +1 -1
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsA.spec.tsx.snap +1 -1
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsB.spec.tsx.snap +12 -7
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsC.spec.tsx.snap +14 -9
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsD.spec.tsx.snap +2 -2
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsE.spec.tsx.snap +1 -1
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsF.spec.tsx.snap +2 -2
- package/src/types.ts +14 -7
package/dist/index.js
CHANGED
|
@@ -4799,7 +4799,7 @@ CBreadcrumbItem.displayName = 'CBreadcrumbItem';
|
|
|
4799
4799
|
var CButton = React.forwardRef(function (_a, ref) {
|
|
4800
4800
|
var _b;
|
|
4801
4801
|
var children = _a.children, className = _a.className, _c = _a.color, color = _c === void 0 ? 'primary' : _c, _d = _a.component, component = _d === void 0 ? 'button' : _d, shape = _a.shape, size = _a.size, _e = _a.type, type = _e === void 0 ? 'button' : _e, variant = _a.variant, rest = __rest(_a, ["children", "className", "color", "component", "shape", "size", "type", "variant"]);
|
|
4802
|
-
return (React.createElement(CLink, __assign({ component: rest.href ? 'a' : component, type: type, className: classNames('btn', variant ? "btn-".concat(variant, "-").concat(color) : "btn-".concat(color), (_b = {}, _b["btn-".concat(size)] = size, _b), shape, className) }, rest, { ref: ref }), children));
|
|
4802
|
+
return (React.createElement(CLink, __assign({ component: rest.href ? 'a' : component }, (!rest.href && { type: type }), { className: classNames('btn', variant ? "btn-".concat(variant, "-").concat(color) : "btn-".concat(color), (_b = {}, _b["btn-".concat(size)] = size, _b), shape, className) }, rest, { ref: ref }), children));
|
|
4803
4803
|
});
|
|
4804
4804
|
CButton.propTypes = {
|
|
4805
4805
|
children: PropTypes.node,
|
|
@@ -5220,6 +5220,18 @@ CConditionalPortal.propTypes = {
|
|
|
5220
5220
|
};
|
|
5221
5221
|
CConditionalPortal.displayName = 'CConditionalPortal';
|
|
5222
5222
|
|
|
5223
|
+
var getNextActiveElement = function (list, activeElement, shouldGetNext, isCycleAllowed) {
|
|
5224
|
+
var listLength = list.length;
|
|
5225
|
+
var index = list.indexOf(activeElement);
|
|
5226
|
+
if (index === -1) {
|
|
5227
|
+
return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
|
|
5228
|
+
}
|
|
5229
|
+
index += shouldGetNext ? 1 : -1;
|
|
5230
|
+
if (isCycleAllowed) {
|
|
5231
|
+
index = (index + listLength) % listLength;
|
|
5232
|
+
}
|
|
5233
|
+
return list[Math.max(0, Math.min(index, listLength - 1))];
|
|
5234
|
+
};
|
|
5223
5235
|
var getPlacement = function (placement, direction, alignment, isRTL) {
|
|
5224
5236
|
var _placement = placement;
|
|
5225
5237
|
if (direction === 'dropup') {
|
|
@@ -5282,18 +5294,33 @@ var CDropdown = React.forwardRef(function (_a, ref) {
|
|
|
5282
5294
|
}, [visible]);
|
|
5283
5295
|
React.useEffect(function () {
|
|
5284
5296
|
if (_visible && dropdownToggleRef.current && dropdownMenuRef.current) {
|
|
5297
|
+
dropdownToggleRef.current.focus();
|
|
5285
5298
|
popper && initPopper(dropdownToggleRef.current, dropdownMenuRef.current, popperConfig);
|
|
5286
5299
|
window.addEventListener('mouseup', handleMouseUp);
|
|
5287
5300
|
window.addEventListener('keyup', handleKeyup);
|
|
5301
|
+
dropdownToggleRef.current.addEventListener('keydown', handleKeydown);
|
|
5302
|
+
dropdownMenuRef.current.addEventListener('keydown', handleKeydown);
|
|
5288
5303
|
onShow && onShow();
|
|
5289
5304
|
}
|
|
5290
5305
|
return function () {
|
|
5291
5306
|
popper && destroyPopper();
|
|
5292
5307
|
window.removeEventListener('mouseup', handleMouseUp);
|
|
5293
5308
|
window.removeEventListener('keyup', handleKeyup);
|
|
5309
|
+
dropdownToggleRef.current &&
|
|
5310
|
+
dropdownToggleRef.current.removeEventListener('keydown', handleKeydown);
|
|
5311
|
+
dropdownMenuRef.current &&
|
|
5312
|
+
dropdownMenuRef.current.removeEventListener('keydown', handleKeydown);
|
|
5294
5313
|
onHide && onHide();
|
|
5295
5314
|
};
|
|
5296
5315
|
}, [_visible]);
|
|
5316
|
+
var handleKeydown = function (event) {
|
|
5317
|
+
if (_visible && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
5318
|
+
var target = event.target;
|
|
5319
|
+
event.preventDefault();
|
|
5320
|
+
var items = [].concat.apply([], Element.prototype.querySelectorAll.call(dropdownMenuRef.current, '.dropdown-item:not(.disabled):not(:disabled)'));
|
|
5321
|
+
getNextActiveElement(items, target, event.key === 'ArrowDown', true).focus();
|
|
5322
|
+
}
|
|
5323
|
+
};
|
|
5297
5324
|
var handleKeyup = function (event) {
|
|
5298
5325
|
if (autoClose === false) {
|
|
5299
5326
|
return;
|
|
@@ -5321,7 +5348,6 @@ var CDropdown = React.forwardRef(function (_a, ref) {
|
|
|
5321
5348
|
'dropup dropup-center': direction === 'dropup-center'
|
|
5322
5349
|
},
|
|
5323
5350
|
_b["".concat(direction)] = direction && direction !== 'center' && direction !== 'dropup-center',
|
|
5324
|
-
_b.show = _visible,
|
|
5325
5351
|
_b), className) }, rest, { ref: forkedRef }), children))));
|
|
5326
5352
|
});
|
|
5327
5353
|
var alignmentDirection = PropTypes.oneOf(['start', 'end']);
|
|
@@ -5433,8 +5459,8 @@ CDropdownMenu.propTypes = {
|
|
|
5433
5459
|
CDropdownMenu.displayName = 'CDropdownMenu';
|
|
5434
5460
|
|
|
5435
5461
|
var CDropdownToggle = function (_a) {
|
|
5436
|
-
var children = _a.children, _b = _a.caret, caret = _b === void 0 ? true : _b, custom = _a.custom, className = _a.className, split = _a.split,
|
|
5437
|
-
var
|
|
5462
|
+
var children = _a.children, _b = _a.caret, caret = _b === void 0 ? true : _b, custom = _a.custom, className = _a.className, _c = _a.navLink, navLink = _c === void 0 ? true : _c, split = _a.split, _d = _a.trigger, trigger = _d === void 0 ? 'click' : _d, rest = __rest(_a, ["children", "caret", "custom", "className", "navLink", "split", "trigger"]);
|
|
5463
|
+
var _e = React.useContext(CDropdownContext), dropdownToggleRef = _e.dropdownToggleRef, variant = _e.variant, visible = _e.visible, setVisible = _e.setVisible;
|
|
5438
5464
|
var triggers = __assign(__assign({}, ((trigger === 'click' || trigger.includes('click')) && {
|
|
5439
5465
|
onClick: function (event) {
|
|
5440
5466
|
event.preventDefault();
|
|
@@ -5445,19 +5471,19 @@ var CDropdownToggle = function (_a) {
|
|
|
5445
5471
|
onBlur: function () { return setVisible(false); },
|
|
5446
5472
|
}));
|
|
5447
5473
|
var togglerProps = __assign({ className: classNames({
|
|
5474
|
+
'nav-link': variant === 'nav-item' && navLink,
|
|
5448
5475
|
'dropdown-toggle': caret,
|
|
5449
5476
|
'dropdown-toggle-split': split,
|
|
5450
|
-
|
|
5477
|
+
show: visible,
|
|
5451
5478
|
}, className), 'aria-expanded': visible }, (!rest.disabled && __assign({}, triggers)));
|
|
5452
|
-
// We use any because Toggler can be `a` as well as `button`.
|
|
5453
5479
|
var Toggler = function () {
|
|
5454
5480
|
if (custom && React.isValidElement(children)) {
|
|
5455
5481
|
return (React.createElement(React.Fragment, null, React.cloneElement(children, __assign(__assign({ 'aria-expanded': visible }, (!rest.disabled && __assign({}, triggers))), { ref: dropdownToggleRef }))));
|
|
5456
5482
|
}
|
|
5457
|
-
if (variant === 'nav-item') {
|
|
5458
|
-
return (React.createElement("a", __assign({ href: "#" }, togglerProps, { ref: dropdownToggleRef }), children));
|
|
5483
|
+
if (variant === 'nav-item' && navLink) {
|
|
5484
|
+
return (React.createElement("a", __assign({ href: "#" }, togglerProps, { role: "button", ref: dropdownToggleRef }), children));
|
|
5459
5485
|
}
|
|
5460
|
-
return (React.createElement(CButton, __assign({
|
|
5486
|
+
return (React.createElement(CButton, __assign({}, togglerProps, { tabIndex: 0 }, rest, { ref: dropdownToggleRef }),
|
|
5461
5487
|
children,
|
|
5462
5488
|
split && React.createElement("span", { className: "visually-hidden" }, "Toggle Dropdown")));
|
|
5463
5489
|
};
|
|
@@ -7418,7 +7444,7 @@ CTooltip.displayName = 'CTooltip';
|
|
|
7418
7444
|
var CWidgetStatsA = React.forwardRef(function (_a, ref) {
|
|
7419
7445
|
var _b;
|
|
7420
7446
|
var action = _a.action, chart = _a.chart, className = _a.className, color = _a.color, title = _a.title, value = _a.value, rest = __rest(_a, ["action", "chart", "className", "color", "title", "value"]);
|
|
7421
|
-
return (React.createElement(CCard, __assign({ className: classNames((_b = {}, _b["bg-".concat(color)] = color, _b['text-
|
|
7447
|
+
return (React.createElement(CCard, __assign({ className: classNames((_b = {}, _b["bg-".concat(color)] = color, _b['text-white'] = color, _b), className) }, rest, { ref: ref }),
|
|
7422
7448
|
React.createElement(CCardBody, { className: "pb-0 d-flex justify-content-between align-items-start" },
|
|
7423
7449
|
React.createElement("div", null,
|
|
7424
7450
|
value && React.createElement("div", { className: "fs-4 fw-semibold" }, value),
|
|
@@ -7438,12 +7464,12 @@ CWidgetStatsA.displayName = 'CWidgetStatsA';
|
|
|
7438
7464
|
|
|
7439
7465
|
var CWidgetStatsB = React.forwardRef(function (_a, ref) {
|
|
7440
7466
|
var className = _a.className, color = _a.color, inverse = _a.inverse, progress = _a.progress, text = _a.text, title = _a.title, value = _a.value, rest = __rest(_a, ["className", "color", "inverse", "progress", "text", "title", "value"]);
|
|
7441
|
-
return (React.createElement(CCard, __assign({ className: className, color: color }, (inverse && { textColor: '
|
|
7467
|
+
return (React.createElement(CCard, __assign({ className: className, color: color }, (inverse && { textColor: 'white' }), rest, { ref: ref }),
|
|
7442
7468
|
React.createElement(CCardBody, null,
|
|
7443
7469
|
value && React.createElement("div", { className: "fs-4 fw-semibold" }, value),
|
|
7444
7470
|
title && React.createElement("div", null, title),
|
|
7445
7471
|
React.createElement(CProgress, __assign({ className: "my-2", height: 4 }, (inverse && { white: true }), progress)),
|
|
7446
|
-
text && (React.createElement("small", { className: inverse ? 'text-
|
|
7472
|
+
text && (React.createElement("small", { className: inverse ? 'text-white text-opacity-75' : 'text-body-secondary' }, text)))));
|
|
7447
7473
|
});
|
|
7448
7474
|
CWidgetStatsB.propTypes = {
|
|
7449
7475
|
className: PropTypes.string,
|
|
@@ -7458,11 +7484,11 @@ CWidgetStatsB.displayName = 'CWidgetCWidgetStatsB';
|
|
|
7458
7484
|
|
|
7459
7485
|
var CWidgetStatsC = React.forwardRef(function (_a, ref) {
|
|
7460
7486
|
var className = _a.className, color = _a.color, icon = _a.icon, inverse = _a.inverse, progress = _a.progress, title = _a.title, value = _a.value, rest = __rest(_a, ["className", "color", "icon", "inverse", "progress", "title", "value"]);
|
|
7461
|
-
return (React.createElement(CCard, __assign({ className: className, color: color }, (inverse && { textColor: '
|
|
7487
|
+
return (React.createElement(CCard, __assign({ className: className, color: color }, (inverse && { textColor: 'white' }), rest, { ref: ref }),
|
|
7462
7488
|
React.createElement(CCardBody, null,
|
|
7463
|
-
icon &&
|
|
7464
|
-
value &&
|
|
7465
|
-
title && (React.createElement("div", { className: inverse ? 'text-
|
|
7489
|
+
icon && React.createElement("div", { className: "text-end mb-4" }, icon),
|
|
7490
|
+
value && React.createElement("div", { className: "fs-4 fw-semibold" }, value),
|
|
7491
|
+
title && (React.createElement("div", { className: inverse ? 'text-white text-opacity-75' : 'text-body-secondary' }, title)),
|
|
7466
7492
|
React.createElement(CProgress, __assign({ className: "mt-3 mb-0", height: 4 }, (inverse && { white: true }), progress)))));
|
|
7467
7493
|
});
|
|
7468
7494
|
CWidgetStatsC.propTypes = {
|
|
@@ -7491,7 +7517,7 @@ var CWidgetStatsD = React.forwardRef(function (_a, ref) {
|
|
|
7491
7517
|
index % 2 !== 0 && React.createElement("div", { className: "vr" }),
|
|
7492
7518
|
React.createElement(CCol, null,
|
|
7493
7519
|
React.createElement("div", { className: "fs-5 fw-semibold" }, value.value),
|
|
7494
|
-
React.createElement("div", { className: "text-uppercase text-
|
|
7520
|
+
React.createElement("div", { className: "text-uppercase text-body-secondary small" }, value.title))));
|
|
7495
7521
|
}))));
|
|
7496
7522
|
});
|
|
7497
7523
|
CWidgetStatsD.propTypes = {
|
|
@@ -7507,7 +7533,7 @@ var CWidgetStatsE = React.forwardRef(function (_a, ref) {
|
|
|
7507
7533
|
var chart = _a.chart, className = _a.className, title = _a.title, value = _a.value, rest = __rest(_a, ["chart", "className", "title", "value"]);
|
|
7508
7534
|
return (React.createElement(CCard, __assign({ className: classNames(className) }, rest, { ref: ref }),
|
|
7509
7535
|
React.createElement(CCardBody, { className: "text-center" },
|
|
7510
|
-
title && (React.createElement("div", { className: "text-
|
|
7536
|
+
title && (React.createElement("div", { className: "text-body-secondary small text-uppercase fw-semibold" }, title)),
|
|
7511
7537
|
value && React.createElement("div", { className: "fs-6 fw-semibold py-3" }, value),
|
|
7512
7538
|
chart)));
|
|
7513
7539
|
});
|
|
@@ -7527,7 +7553,7 @@ var CWidgetStatsF = React.forwardRef(function (_a, ref) {
|
|
|
7527
7553
|
React.createElement("div", { className: "me-3 text-white bg-".concat(color, " ").concat(padding ? 'p-3' : 'p-4') }, icon),
|
|
7528
7554
|
React.createElement("div", null,
|
|
7529
7555
|
React.createElement("div", { className: "fs-6 fw-semibold text-".concat(color) }, value),
|
|
7530
|
-
React.createElement("div", { className: "text-
|
|
7556
|
+
React.createElement("div", { className: "text-body-secondary text-uppercase fw-semibold small" }, title))),
|
|
7531
7557
|
footer && React.createElement(CCardFooter, null, footer)));
|
|
7532
7558
|
});
|
|
7533
7559
|
CWidgetStatsF.propTypes = {
|