@deque/cauldron-react 6.4.2-canary.9eab948b → 6.4.2-canary.a3f374a6
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/lib/components/Badge/index.d.ts +11 -0
- package/lib/components/Dialog/index.d.ts +3 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +43 -2
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
size?: 'default' | 'small';
|
|
5
|
+
}
|
|
6
|
+
interface BadgeLabelProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const BadgeLabel: React.ForwardRefExoticComponent<BadgeLabelProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export default Badge;
|
|
@@ -35,6 +35,9 @@ export default class Dialog extends React.Component<DialogProps, DialogState> {
|
|
|
35
35
|
close(): void;
|
|
36
36
|
handleClickOutside(): void;
|
|
37
37
|
focusHeading(): void;
|
|
38
|
+
private handleEscape;
|
|
39
|
+
private attachEventListeners;
|
|
40
|
+
private removeEventListeners;
|
|
38
41
|
}
|
|
39
42
|
interface DialogAlignmentProps {
|
|
40
43
|
align?: 'left' | 'center' | 'right';
|
package/lib/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export { default as Code } from './components/Code';
|
|
|
38
38
|
export { default as LoaderOverlay } from './components/LoaderOverlay';
|
|
39
39
|
export { default as Line } from './components/Line';
|
|
40
40
|
export { default as Tag, TagLabel } from './components/Tag';
|
|
41
|
+
export { default as Badge, BadgeLabel } from './components/Badge';
|
|
41
42
|
export { default as TagButton } from './components/TagButton';
|
|
42
43
|
export { default as Table, TableBody, TableCell, TableHead, TableHeader, TableRow, TableFooter } from './components/Table';
|
|
43
44
|
export { default as Tabs, Tab, TabPanel } from './components/Tabs';
|
package/lib/index.js
CHANGED
|
@@ -1386,6 +1386,9 @@ var AriaIsolate = /** @class */ (function () {
|
|
|
1386
1386
|
return AriaIsolate;
|
|
1387
1387
|
}());
|
|
1388
1388
|
|
|
1389
|
+
var isEscape = function (event) {
|
|
1390
|
+
return event.key === 'Escape' || event.key === 'Esc' || event.keyCode === 27;
|
|
1391
|
+
};
|
|
1389
1392
|
var noop = function () {
|
|
1390
1393
|
//not empty
|
|
1391
1394
|
};
|
|
@@ -1397,24 +1400,29 @@ var Dialog = /** @class */ (function (_super) {
|
|
|
1397
1400
|
_this.close = _this.close.bind(_this);
|
|
1398
1401
|
_this.focusHeading = _this.focusHeading.bind(_this);
|
|
1399
1402
|
_this.handleClickOutside = _this.handleClickOutside.bind(_this);
|
|
1403
|
+
_this.handleEscape = _this.handleEscape.bind(_this);
|
|
1400
1404
|
_this.state = {};
|
|
1401
1405
|
return _this;
|
|
1402
1406
|
}
|
|
1403
1407
|
Dialog.prototype.componentDidMount = function () {
|
|
1404
1408
|
var _this = this;
|
|
1405
1409
|
if (this.props.show) {
|
|
1410
|
+
this.attachEventListeners();
|
|
1406
1411
|
this.attachIsolator(function () { return setTimeout(_this.focusHeading); });
|
|
1407
1412
|
}
|
|
1408
1413
|
};
|
|
1409
1414
|
Dialog.prototype.componentWillUnmount = function () {
|
|
1410
1415
|
var isolator = this.state.isolator;
|
|
1411
1416
|
isolator === null || isolator === void 0 ? void 0 : isolator.deactivate();
|
|
1417
|
+
this.removeEventListeners();
|
|
1412
1418
|
};
|
|
1413
1419
|
Dialog.prototype.componentDidUpdate = function (prevProps) {
|
|
1414
1420
|
if (!prevProps.show && this.props.show) {
|
|
1415
1421
|
this.attachIsolator(this.focusHeading);
|
|
1422
|
+
this.attachEventListeners();
|
|
1416
1423
|
}
|
|
1417
1424
|
else if (prevProps.show && !this.props.show) {
|
|
1425
|
+
this.removeEventListeners();
|
|
1418
1426
|
this.close();
|
|
1419
1427
|
}
|
|
1420
1428
|
};
|
|
@@ -1438,8 +1446,7 @@ var Dialog = /** @class */ (function (_super) {
|
|
|
1438
1446
|
: 2);
|
|
1439
1447
|
var Dialog = (React__default["default"].createElement(FocusTrap__default["default"], { focusTrapOptions: {
|
|
1440
1448
|
allowOutsideClick: true,
|
|
1441
|
-
|
|
1442
|
-
escapeDeactivates: !forceAction,
|
|
1449
|
+
escapeDeactivates: false,
|
|
1443
1450
|
fallbackFocus: '.Dialog__heading'
|
|
1444
1451
|
} },
|
|
1445
1452
|
React__default["default"].createElement(ClickOutsideListener, { onClickOutside: this.handleClickOutside },
|
|
@@ -1481,6 +1488,24 @@ var Dialog = /** @class */ (function (_super) {
|
|
|
1481
1488
|
}
|
|
1482
1489
|
(_a = this.state.isolator) === null || _a === void 0 ? void 0 : _a.activate();
|
|
1483
1490
|
};
|
|
1491
|
+
Dialog.prototype.handleEscape = function (keyboardEvent) {
|
|
1492
|
+
if (!keyboardEvent.defaultPrevented && isEscape(keyboardEvent)) {
|
|
1493
|
+
this.close();
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1496
|
+
Dialog.prototype.attachEventListeners = function () {
|
|
1497
|
+
var forceAction = this.props.forceAction;
|
|
1498
|
+
if (!forceAction) {
|
|
1499
|
+
var portal = this.props.portal || document.body;
|
|
1500
|
+
var targetElement = portal instanceof HTMLElement ? portal : portal.current;
|
|
1501
|
+
targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('keyup', this.handleEscape);
|
|
1502
|
+
}
|
|
1503
|
+
};
|
|
1504
|
+
Dialog.prototype.removeEventListeners = function () {
|
|
1505
|
+
var portal = this.props.portal || document.body;
|
|
1506
|
+
var targetElement = portal instanceof HTMLElement ? portal : portal.current;
|
|
1507
|
+
targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('keyup', this.handleEscape);
|
|
1508
|
+
};
|
|
1484
1509
|
Dialog.defaultProps = {
|
|
1485
1510
|
onClose: noop,
|
|
1486
1511
|
forceAction: false,
|
|
@@ -1733,6 +1758,7 @@ function Tooltip(_a) {
|
|
|
1733
1758
|
if (event.key === 'Escape' ||
|
|
1734
1759
|
event.key === 'Esc' ||
|
|
1735
1760
|
event.keyCode === 27) {
|
|
1761
|
+
event.preventDefault();
|
|
1736
1762
|
setShowTooltip(false);
|
|
1737
1763
|
}
|
|
1738
1764
|
};
|
|
@@ -2613,6 +2639,19 @@ var Tag = function (_a) {
|
|
|
2613
2639
|
};
|
|
2614
2640
|
Tag.displayName = 'Tag';
|
|
2615
2641
|
|
|
2642
|
+
var BadgeLabel = React.forwardRef(function (_a, ref) {
|
|
2643
|
+
var children = _a.children, className = _a.className, other = tslib.__rest(_a, ["children", "className"]);
|
|
2644
|
+
return (React__default["default"].createElement("div", tslib.__assign({ ref: ref, className: classNames__default["default"]('Badge__Label', className) }, other), children));
|
|
2645
|
+
});
|
|
2646
|
+
BadgeLabel.displayName = 'BadgeLabel';
|
|
2647
|
+
var Badge = React.forwardRef(function (_a, ref) {
|
|
2648
|
+
var children = _a.children, className = _a.className, _b = _a.size, size = _b === void 0 ? 'default' : _b, other = tslib.__rest(_a, ["children", "className", "size"]);
|
|
2649
|
+
return (React__default["default"].createElement("div", tslib.__assign({ className: classNames__default["default"]('Badge', className, {
|
|
2650
|
+
'Badge--small': size === 'small'
|
|
2651
|
+
}), ref: ref }, other), children));
|
|
2652
|
+
});
|
|
2653
|
+
Badge.displayName = 'Badge';
|
|
2654
|
+
|
|
2616
2655
|
var TagButton = React__default["default"].forwardRef(function (_a, ref) {
|
|
2617
2656
|
var label = _a.label, value = _a.value, icon = _a.icon, className = _a.className, rest = tslib.__rest(_a, ["label", "value", "icon", "className"]);
|
|
2618
2657
|
return (React__default["default"].createElement(Button, tslib.__assign({ variant: "tag", className: classNames__default["default"]('TagButton', className), ref: ref }, rest),
|
|
@@ -4112,6 +4151,8 @@ exports.Alert = Alert;
|
|
|
4112
4151
|
exports.AlertActions = AlertActions;
|
|
4113
4152
|
exports.AlertContent = AlertContent;
|
|
4114
4153
|
exports.AriaIsolate = AriaIsolate;
|
|
4154
|
+
exports.Badge = Badge;
|
|
4155
|
+
exports.BadgeLabel = BadgeLabel;
|
|
4115
4156
|
exports.Breadcrumb = Breadcrumb;
|
|
4116
4157
|
exports.BreadcrumbItem = BreadcrumbItem;
|
|
4117
4158
|
exports.BreadcrumbLink = BreadcrumbLink;
|
package/package.json
CHANGED