@coreui/react 5.0.0-alpha.1 → 5.0.0-alpha.2
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/index.es.js +41 -19
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +41 -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 +3 -12
- 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']);
|
|
@@ -5434,7 +5460,7 @@ CDropdownMenu.displayName = 'CDropdownMenu';
|
|
|
5434
5460
|
|
|
5435
5461
|
var CDropdownToggle = function (_a) {
|
|
5436
5462
|
var children = _a.children, _b = _a.caret, caret = _b === void 0 ? true : _b, custom = _a.custom, className = _a.className, split = _a.split, _c = _a.trigger, trigger = _c === void 0 ? 'click' : _c, rest = __rest(_a, ["children", "caret", "custom", "className", "split", "trigger"]);
|
|
5437
|
-
var _d = React.useContext(CDropdownContext), dropdownToggleRef = _d.dropdownToggleRef,
|
|
5463
|
+
var _d = React.useContext(CDropdownContext), dropdownToggleRef = _d.dropdownToggleRef, visible = _d.visible, setVisible = _d.setVisible;
|
|
5438
5464
|
var triggers = __assign(__assign({}, ((trigger === 'click' || trigger.includes('click')) && {
|
|
5439
5465
|
onClick: function (event) {
|
|
5440
5466
|
event.preventDefault();
|
|
@@ -5447,17 +5473,13 @@ var CDropdownToggle = function (_a) {
|
|
|
5447
5473
|
var togglerProps = __assign({ className: classNames({
|
|
5448
5474
|
'dropdown-toggle': caret,
|
|
5449
5475
|
'dropdown-toggle-split': split,
|
|
5450
|
-
|
|
5476
|
+
show: visible,
|
|
5451
5477
|
}, className), 'aria-expanded': visible }, (!rest.disabled && __assign({}, triggers)));
|
|
5452
|
-
// We use any because Toggler can be `a` as well as `button`.
|
|
5453
5478
|
var Toggler = function () {
|
|
5454
5479
|
if (custom && React.isValidElement(children)) {
|
|
5455
5480
|
return (React.createElement(React.Fragment, null, React.cloneElement(children, __assign(__assign({ 'aria-expanded': visible }, (!rest.disabled && __assign({}, triggers))), { ref: dropdownToggleRef }))));
|
|
5456
5481
|
}
|
|
5457
|
-
|
|
5458
|
-
return (React.createElement("a", __assign({ href: "#" }, togglerProps, { ref: dropdownToggleRef }), children));
|
|
5459
|
-
}
|
|
5460
|
-
return (React.createElement(CButton, __assign({ type: "button" }, togglerProps, { tabIndex: 0 }, rest, { ref: dropdownToggleRef }),
|
|
5482
|
+
return (React.createElement(CButton, __assign({}, togglerProps, { tabIndex: 0 }, rest, { ref: dropdownToggleRef }),
|
|
5461
5483
|
children,
|
|
5462
5484
|
split && React.createElement("span", { className: "visually-hidden" }, "Toggle Dropdown")));
|
|
5463
5485
|
};
|
|
@@ -7418,7 +7440,7 @@ CTooltip.displayName = 'CTooltip';
|
|
|
7418
7440
|
var CWidgetStatsA = React.forwardRef(function (_a, ref) {
|
|
7419
7441
|
var _b;
|
|
7420
7442
|
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-
|
|
7443
|
+
return (React.createElement(CCard, __assign({ className: classNames((_b = {}, _b["bg-".concat(color)] = color, _b['text-white'] = color, _b), className) }, rest, { ref: ref }),
|
|
7422
7444
|
React.createElement(CCardBody, { className: "pb-0 d-flex justify-content-between align-items-start" },
|
|
7423
7445
|
React.createElement("div", null,
|
|
7424
7446
|
value && React.createElement("div", { className: "fs-4 fw-semibold" }, value),
|
|
@@ -7438,12 +7460,12 @@ CWidgetStatsA.displayName = 'CWidgetStatsA';
|
|
|
7438
7460
|
|
|
7439
7461
|
var CWidgetStatsB = React.forwardRef(function (_a, ref) {
|
|
7440
7462
|
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: '
|
|
7463
|
+
return (React.createElement(CCard, __assign({ className: className, color: color }, (inverse && { textColor: 'white' }), rest, { ref: ref }),
|
|
7442
7464
|
React.createElement(CCardBody, null,
|
|
7443
7465
|
value && React.createElement("div", { className: "fs-4 fw-semibold" }, value),
|
|
7444
7466
|
title && React.createElement("div", null, title),
|
|
7445
7467
|
React.createElement(CProgress, __assign({ className: "my-2", height: 4 }, (inverse && { white: true }), progress)),
|
|
7446
|
-
text && (React.createElement("small", { className: inverse ? 'text-
|
|
7468
|
+
text && (React.createElement("small", { className: inverse ? 'text-white text-opacity-75' : 'text-body-secondary' }, text)))));
|
|
7447
7469
|
});
|
|
7448
7470
|
CWidgetStatsB.propTypes = {
|
|
7449
7471
|
className: PropTypes.string,
|
|
@@ -7458,11 +7480,11 @@ CWidgetStatsB.displayName = 'CWidgetCWidgetStatsB';
|
|
|
7458
7480
|
|
|
7459
7481
|
var CWidgetStatsC = React.forwardRef(function (_a, ref) {
|
|
7460
7482
|
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: '
|
|
7483
|
+
return (React.createElement(CCard, __assign({ className: className, color: color }, (inverse && { textColor: 'white' }), rest, { ref: ref }),
|
|
7462
7484
|
React.createElement(CCardBody, null,
|
|
7463
|
-
icon &&
|
|
7464
|
-
value &&
|
|
7465
|
-
title && (React.createElement("div", { className: inverse ? 'text-
|
|
7485
|
+
icon && React.createElement("div", { className: "text-end mb-4" }, icon),
|
|
7486
|
+
value && React.createElement("div", { className: "fs-4 fw-semibold" }, value),
|
|
7487
|
+
title && (React.createElement("div", { className: inverse ? 'text-white text-opacity-75' : 'text-body-secondary' }, title)),
|
|
7466
7488
|
React.createElement(CProgress, __assign({ className: "mt-3 mb-0", height: 4 }, (inverse && { white: true }), progress)))));
|
|
7467
7489
|
});
|
|
7468
7490
|
CWidgetStatsC.propTypes = {
|
|
@@ -7491,7 +7513,7 @@ var CWidgetStatsD = React.forwardRef(function (_a, ref) {
|
|
|
7491
7513
|
index % 2 !== 0 && React.createElement("div", { className: "vr" }),
|
|
7492
7514
|
React.createElement(CCol, null,
|
|
7493
7515
|
React.createElement("div", { className: "fs-5 fw-semibold" }, value.value),
|
|
7494
|
-
React.createElement("div", { className: "text-uppercase text-
|
|
7516
|
+
React.createElement("div", { className: "text-uppercase text-body-secondary small" }, value.title))));
|
|
7495
7517
|
}))));
|
|
7496
7518
|
});
|
|
7497
7519
|
CWidgetStatsD.propTypes = {
|
|
@@ -7507,7 +7529,7 @@ var CWidgetStatsE = React.forwardRef(function (_a, ref) {
|
|
|
7507
7529
|
var chart = _a.chart, className = _a.className, title = _a.title, value = _a.value, rest = __rest(_a, ["chart", "className", "title", "value"]);
|
|
7508
7530
|
return (React.createElement(CCard, __assign({ className: classNames(className) }, rest, { ref: ref }),
|
|
7509
7531
|
React.createElement(CCardBody, { className: "text-center" },
|
|
7510
|
-
title && (React.createElement("div", { className: "text-
|
|
7532
|
+
title && (React.createElement("div", { className: "text-body-secondary small text-uppercase fw-semibold" }, title)),
|
|
7511
7533
|
value && React.createElement("div", { className: "fs-6 fw-semibold py-3" }, value),
|
|
7512
7534
|
chart)));
|
|
7513
7535
|
});
|
|
@@ -7527,7 +7549,7 @@ var CWidgetStatsF = React.forwardRef(function (_a, ref) {
|
|
|
7527
7549
|
React.createElement("div", { className: "me-3 text-white bg-".concat(color, " ").concat(padding ? 'p-3' : 'p-4') }, icon),
|
|
7528
7550
|
React.createElement("div", null,
|
|
7529
7551
|
React.createElement("div", { className: "fs-6 fw-semibold text-".concat(color) }, value),
|
|
7530
|
-
React.createElement("div", { className: "text-
|
|
7552
|
+
React.createElement("div", { className: "text-body-secondary text-uppercase fw-semibold small" }, title))),
|
|
7531
7553
|
footer && React.createElement(CCardFooter, null, footer)));
|
|
7532
7554
|
});
|
|
7533
7555
|
CWidgetStatsF.propTypes = {
|