@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/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/v5.0.0-alpha.
|
|
49
|
+
- [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.0.0-alpha.2.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`
|
|
@@ -34,7 +34,7 @@ export interface CAvatarProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
34
34
|
/**
|
|
35
35
|
* Sets the text color of the component to one of CoreUI’s themed colors.
|
|
36
36
|
*
|
|
37
|
-
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | '
|
|
37
|
+
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | 'primary-emphasis' | 'secondary-emphasis' | 'success-emphasis' | 'danger-emphasis' | 'warning-emphasis' | 'info-emphasis' | 'light-emphasis' | 'body' | 'body-emphasis' | 'body-secondary' | 'body-tertiary' | 'black' | 'black-50' | 'white' | 'white-50' | string
|
|
38
38
|
*/
|
|
39
39
|
textColor?: TextColors;
|
|
40
40
|
}
|
|
@@ -32,7 +32,7 @@ export interface CBadgeProps extends HTMLAttributes<HTMLDivElement | HTMLSpanEle
|
|
|
32
32
|
/**
|
|
33
33
|
* Sets the text color of the component to one of CoreUI’s themed colors.
|
|
34
34
|
*
|
|
35
|
-
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | '
|
|
35
|
+
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | 'primary-emphasis' | 'secondary-emphasis' | 'success-emphasis' | 'danger-emphasis' | 'warning-emphasis' | 'info-emphasis' | 'light-emphasis' | 'body' | 'body-emphasis' | 'body-secondary' | 'body-tertiary' | 'black' | 'black-50' | 'white' | 'white-50' | string
|
|
36
36
|
*/
|
|
37
37
|
textColor?: TextColors;
|
|
38
38
|
}
|
|
@@ -14,7 +14,7 @@ export interface CCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
14
14
|
/**
|
|
15
15
|
* Sets the text color context of the component to one of CoreUI’s themed colors.
|
|
16
16
|
*
|
|
17
|
-
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | '
|
|
17
|
+
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | 'primary-emphasis' | 'secondary-emphasis' | 'success-emphasis' | 'danger-emphasis' | 'warning-emphasis' | 'info-emphasis' | 'light-emphasis' | 'body' | 'body-emphasis' | 'body-secondary' | 'body-tertiary' | 'black' | 'black-50' | 'white' | 'white-50' | string
|
|
18
18
|
*/
|
|
19
19
|
textColor?: string;
|
|
20
20
|
}
|
|
@@ -91,6 +91,7 @@ interface ContextProps extends CDropdownProps {
|
|
|
91
91
|
setVisible: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
|
92
92
|
portal: boolean;
|
|
93
93
|
}
|
|
94
|
+
export declare const getNextActiveElement: (list: HTMLElement[], activeElement: HTMLElement, shouldGetNext: boolean, isCycleAllowed: boolean) => HTMLElement;
|
|
94
95
|
export declare const CDropdownContext: React.Context<ContextProps>;
|
|
95
96
|
export declare const CDropdown: React.ForwardRefExoticComponent<CDropdownProps & React.RefAttributes<HTMLDivElement | HTMLLIElement>>;
|
|
96
97
|
export {};
|
package/dist/index.es.js
CHANGED
|
@@ -4797,7 +4797,7 @@ CBreadcrumbItem.displayName = 'CBreadcrumbItem';
|
|
|
4797
4797
|
var CButton = forwardRef(function (_a, ref) {
|
|
4798
4798
|
var _b;
|
|
4799
4799
|
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"]);
|
|
4800
|
-
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));
|
|
4800
|
+
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));
|
|
4801
4801
|
});
|
|
4802
4802
|
CButton.propTypes = {
|
|
4803
4803
|
children: PropTypes.node,
|
|
@@ -5218,6 +5218,18 @@ CConditionalPortal.propTypes = {
|
|
|
5218
5218
|
};
|
|
5219
5219
|
CConditionalPortal.displayName = 'CConditionalPortal';
|
|
5220
5220
|
|
|
5221
|
+
var getNextActiveElement = function (list, activeElement, shouldGetNext, isCycleAllowed) {
|
|
5222
|
+
var listLength = list.length;
|
|
5223
|
+
var index = list.indexOf(activeElement);
|
|
5224
|
+
if (index === -1) {
|
|
5225
|
+
return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
|
|
5226
|
+
}
|
|
5227
|
+
index += shouldGetNext ? 1 : -1;
|
|
5228
|
+
if (isCycleAllowed) {
|
|
5229
|
+
index = (index + listLength) % listLength;
|
|
5230
|
+
}
|
|
5231
|
+
return list[Math.max(0, Math.min(index, listLength - 1))];
|
|
5232
|
+
};
|
|
5221
5233
|
var getPlacement = function (placement, direction, alignment, isRTL) {
|
|
5222
5234
|
var _placement = placement;
|
|
5223
5235
|
if (direction === 'dropup') {
|
|
@@ -5280,18 +5292,33 @@ var CDropdown = forwardRef(function (_a, ref) {
|
|
|
5280
5292
|
}, [visible]);
|
|
5281
5293
|
useEffect(function () {
|
|
5282
5294
|
if (_visible && dropdownToggleRef.current && dropdownMenuRef.current) {
|
|
5295
|
+
dropdownToggleRef.current.focus();
|
|
5283
5296
|
popper && initPopper(dropdownToggleRef.current, dropdownMenuRef.current, popperConfig);
|
|
5284
5297
|
window.addEventListener('mouseup', handleMouseUp);
|
|
5285
5298
|
window.addEventListener('keyup', handleKeyup);
|
|
5299
|
+
dropdownToggleRef.current.addEventListener('keydown', handleKeydown);
|
|
5300
|
+
dropdownMenuRef.current.addEventListener('keydown', handleKeydown);
|
|
5286
5301
|
onShow && onShow();
|
|
5287
5302
|
}
|
|
5288
5303
|
return function () {
|
|
5289
5304
|
popper && destroyPopper();
|
|
5290
5305
|
window.removeEventListener('mouseup', handleMouseUp);
|
|
5291
5306
|
window.removeEventListener('keyup', handleKeyup);
|
|
5307
|
+
dropdownToggleRef.current &&
|
|
5308
|
+
dropdownToggleRef.current.removeEventListener('keydown', handleKeydown);
|
|
5309
|
+
dropdownMenuRef.current &&
|
|
5310
|
+
dropdownMenuRef.current.removeEventListener('keydown', handleKeydown);
|
|
5292
5311
|
onHide && onHide();
|
|
5293
5312
|
};
|
|
5294
5313
|
}, [_visible]);
|
|
5314
|
+
var handleKeydown = function (event) {
|
|
5315
|
+
if (_visible && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
5316
|
+
var target = event.target;
|
|
5317
|
+
event.preventDefault();
|
|
5318
|
+
var items = [].concat.apply([], Element.prototype.querySelectorAll.call(dropdownMenuRef.current, '.dropdown-item:not(.disabled):not(:disabled)'));
|
|
5319
|
+
getNextActiveElement(items, target, event.key === 'ArrowDown', true).focus();
|
|
5320
|
+
}
|
|
5321
|
+
};
|
|
5295
5322
|
var handleKeyup = function (event) {
|
|
5296
5323
|
if (autoClose === false) {
|
|
5297
5324
|
return;
|
|
@@ -5319,7 +5346,6 @@ var CDropdown = forwardRef(function (_a, ref) {
|
|
|
5319
5346
|
'dropup dropup-center': direction === 'dropup-center'
|
|
5320
5347
|
},
|
|
5321
5348
|
_b["".concat(direction)] = direction && direction !== 'center' && direction !== 'dropup-center',
|
|
5322
|
-
_b.show = _visible,
|
|
5323
5349
|
_b), className) }, rest, { ref: forkedRef }), children))));
|
|
5324
5350
|
});
|
|
5325
5351
|
var alignmentDirection = PropTypes.oneOf(['start', 'end']);
|
|
@@ -5432,7 +5458,7 @@ CDropdownMenu.displayName = 'CDropdownMenu';
|
|
|
5432
5458
|
|
|
5433
5459
|
var CDropdownToggle = function (_a) {
|
|
5434
5460
|
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"]);
|
|
5435
|
-
var _d = useContext(CDropdownContext), dropdownToggleRef = _d.dropdownToggleRef,
|
|
5461
|
+
var _d = useContext(CDropdownContext), dropdownToggleRef = _d.dropdownToggleRef, visible = _d.visible, setVisible = _d.setVisible;
|
|
5436
5462
|
var triggers = __assign(__assign({}, ((trigger === 'click' || trigger.includes('click')) && {
|
|
5437
5463
|
onClick: function (event) {
|
|
5438
5464
|
event.preventDefault();
|
|
@@ -5445,17 +5471,13 @@ var CDropdownToggle = function (_a) {
|
|
|
5445
5471
|
var togglerProps = __assign({ className: classNames({
|
|
5446
5472
|
'dropdown-toggle': caret,
|
|
5447
5473
|
'dropdown-toggle-split': split,
|
|
5448
|
-
|
|
5474
|
+
show: visible,
|
|
5449
5475
|
}, className), 'aria-expanded': visible }, (!rest.disabled && __assign({}, triggers)));
|
|
5450
|
-
// We use any because Toggler can be `a` as well as `button`.
|
|
5451
5476
|
var Toggler = function () {
|
|
5452
5477
|
if (custom && React.isValidElement(children)) {
|
|
5453
5478
|
return (React.createElement(React.Fragment, null, React.cloneElement(children, __assign(__assign({ 'aria-expanded': visible }, (!rest.disabled && __assign({}, triggers))), { ref: dropdownToggleRef }))));
|
|
5454
5479
|
}
|
|
5455
|
-
|
|
5456
|
-
return (React.createElement("a", __assign({ href: "#" }, togglerProps, { ref: dropdownToggleRef }), children));
|
|
5457
|
-
}
|
|
5458
|
-
return (React.createElement(CButton, __assign({ type: "button" }, togglerProps, { tabIndex: 0 }, rest, { ref: dropdownToggleRef }),
|
|
5480
|
+
return (React.createElement(CButton, __assign({}, togglerProps, { tabIndex: 0 }, rest, { ref: dropdownToggleRef }),
|
|
5459
5481
|
children,
|
|
5460
5482
|
split && React.createElement("span", { className: "visually-hidden" }, "Toggle Dropdown")));
|
|
5461
5483
|
};
|
|
@@ -7416,7 +7438,7 @@ CTooltip.displayName = 'CTooltip';
|
|
|
7416
7438
|
var CWidgetStatsA = forwardRef(function (_a, ref) {
|
|
7417
7439
|
var _b;
|
|
7418
7440
|
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"]);
|
|
7419
|
-
return (React.createElement(CCard, __assign({ className: classNames((_b = {}, _b["bg-".concat(color)] = color, _b['text-
|
|
7441
|
+
return (React.createElement(CCard, __assign({ className: classNames((_b = {}, _b["bg-".concat(color)] = color, _b['text-white'] = color, _b), className) }, rest, { ref: ref }),
|
|
7420
7442
|
React.createElement(CCardBody, { className: "pb-0 d-flex justify-content-between align-items-start" },
|
|
7421
7443
|
React.createElement("div", null,
|
|
7422
7444
|
value && React.createElement("div", { className: "fs-4 fw-semibold" }, value),
|
|
@@ -7436,12 +7458,12 @@ CWidgetStatsA.displayName = 'CWidgetStatsA';
|
|
|
7436
7458
|
|
|
7437
7459
|
var CWidgetStatsB = forwardRef(function (_a, ref) {
|
|
7438
7460
|
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"]);
|
|
7439
|
-
return (React.createElement(CCard, __assign({ className: className, color: color }, (inverse && { textColor: '
|
|
7461
|
+
return (React.createElement(CCard, __assign({ className: className, color: color }, (inverse && { textColor: 'white' }), rest, { ref: ref }),
|
|
7440
7462
|
React.createElement(CCardBody, null,
|
|
7441
7463
|
value && React.createElement("div", { className: "fs-4 fw-semibold" }, value),
|
|
7442
7464
|
title && React.createElement("div", null, title),
|
|
7443
7465
|
React.createElement(CProgress, __assign({ className: "my-2", height: 4 }, (inverse && { white: true }), progress)),
|
|
7444
|
-
text && (React.createElement("small", { className: inverse ? 'text-
|
|
7466
|
+
text && (React.createElement("small", { className: inverse ? 'text-white text-opacity-75' : 'text-body-secondary' }, text)))));
|
|
7445
7467
|
});
|
|
7446
7468
|
CWidgetStatsB.propTypes = {
|
|
7447
7469
|
className: PropTypes.string,
|
|
@@ -7456,11 +7478,11 @@ CWidgetStatsB.displayName = 'CWidgetCWidgetStatsB';
|
|
|
7456
7478
|
|
|
7457
7479
|
var CWidgetStatsC = forwardRef(function (_a, ref) {
|
|
7458
7480
|
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"]);
|
|
7459
|
-
return (React.createElement(CCard, __assign({ className: className, color: color }, (inverse && { textColor: '
|
|
7481
|
+
return (React.createElement(CCard, __assign({ className: className, color: color }, (inverse && { textColor: 'white' }), rest, { ref: ref }),
|
|
7460
7482
|
React.createElement(CCardBody, null,
|
|
7461
|
-
icon &&
|
|
7462
|
-
value &&
|
|
7463
|
-
title && (React.createElement("div", { className: inverse ? 'text-
|
|
7483
|
+
icon && React.createElement("div", { className: "text-end mb-4" }, icon),
|
|
7484
|
+
value && React.createElement("div", { className: "fs-4 fw-semibold" }, value),
|
|
7485
|
+
title && (React.createElement("div", { className: inverse ? 'text-white text-opacity-75' : 'text-body-secondary' }, title)),
|
|
7464
7486
|
React.createElement(CProgress, __assign({ className: "mt-3 mb-0", height: 4 }, (inverse && { white: true }), progress)))));
|
|
7465
7487
|
});
|
|
7466
7488
|
CWidgetStatsC.propTypes = {
|
|
@@ -7489,7 +7511,7 @@ var CWidgetStatsD = forwardRef(function (_a, ref) {
|
|
|
7489
7511
|
index % 2 !== 0 && React.createElement("div", { className: "vr" }),
|
|
7490
7512
|
React.createElement(CCol, null,
|
|
7491
7513
|
React.createElement("div", { className: "fs-5 fw-semibold" }, value.value),
|
|
7492
|
-
React.createElement("div", { className: "text-uppercase text-
|
|
7514
|
+
React.createElement("div", { className: "text-uppercase text-body-secondary small" }, value.title))));
|
|
7493
7515
|
}))));
|
|
7494
7516
|
});
|
|
7495
7517
|
CWidgetStatsD.propTypes = {
|
|
@@ -7505,7 +7527,7 @@ var CWidgetStatsE = forwardRef(function (_a, ref) {
|
|
|
7505
7527
|
var chart = _a.chart, className = _a.className, title = _a.title, value = _a.value, rest = __rest(_a, ["chart", "className", "title", "value"]);
|
|
7506
7528
|
return (React.createElement(CCard, __assign({ className: classNames(className) }, rest, { ref: ref }),
|
|
7507
7529
|
React.createElement(CCardBody, { className: "text-center" },
|
|
7508
|
-
title && (React.createElement("div", { className: "text-
|
|
7530
|
+
title && (React.createElement("div", { className: "text-body-secondary small text-uppercase fw-semibold" }, title)),
|
|
7509
7531
|
value && React.createElement("div", { className: "fs-6 fw-semibold py-3" }, value),
|
|
7510
7532
|
chart)));
|
|
7511
7533
|
});
|
|
@@ -7525,7 +7547,7 @@ var CWidgetStatsF = forwardRef(function (_a, ref) {
|
|
|
7525
7547
|
React.createElement("div", { className: "me-3 text-white bg-".concat(color, " ").concat(padding ? 'p-3' : 'p-4') }, icon),
|
|
7526
7548
|
React.createElement("div", null,
|
|
7527
7549
|
React.createElement("div", { className: "fs-6 fw-semibold text-".concat(color) }, value),
|
|
7528
|
-
React.createElement("div", { className: "text-
|
|
7550
|
+
React.createElement("div", { className: "text-body-secondary text-uppercase fw-semibold small" }, title))),
|
|
7529
7551
|
footer && React.createElement(CCardFooter, null, footer)));
|
|
7530
7552
|
});
|
|
7531
7553
|
CWidgetStatsF.propTypes = {
|