@deque/cauldron-react 6.4.1 → 6.4.2-canary.0b8be6a5

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/cauldron.css CHANGED
@@ -42,11 +42,10 @@
42
42
  a.Button--primary,
43
43
  a.Button--secondary {
44
44
  text-decoration: none;
45
- padding: 9px 18px;
46
45
  }
47
46
 
48
47
  a.Button--thin {
49
- padding: 0 16px;
48
+ padding: 0 var(--space-small);
50
49
  }
51
50
 
52
51
  .Icon {
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import React, { ButtonHTMLAttributes, Ref } from 'react';
2
2
  export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
3
3
  buttonRef?: Ref<HTMLButtonElement>;
4
- variant?: 'primary' | 'secondary' | 'error' | 'link' | 'tag';
4
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'link' | 'tag';
5
5
  thin?: boolean;
6
6
  }
7
7
  declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -7,8 +7,8 @@ export interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {
7
7
  dialogRef?: React.Ref<HTMLDivElement>;
8
8
  onClose?: () => void;
9
9
  forceAction?: boolean;
10
- heading: React.ReactElement<any> | {
11
- text: React.ReactElement<any>;
10
+ heading: string | React.ReactElement<any> | {
11
+ text: React.ReactElement<any> | string;
12
12
  level: number | undefined;
13
13
  };
14
14
  closeButtonText?: string;
@@ -19,7 +19,7 @@ export interface IconButtonProps extends PolymorphicProps<React.HTMLAttributes<H
19
19
  * @deprecated use `tooltipProps.portal` instead
20
20
  */
21
21
  tooltipPortal?: TooltipProps['portal'];
22
- variant?: 'primary' | 'secondary' | 'error';
22
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'error';
23
23
  large?: boolean;
24
24
  }
25
25
  declare const IconButton: PolymorphicComponent<IconButtonProps>;
@@ -10,6 +10,7 @@ export interface NoticeProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
10
10
  type?: keyof typeof iconTypeMap;
11
11
  title: ContentNode;
12
12
  icon?: IconType;
13
+ variant?: 'default' | 'condensed';
13
14
  children?: ReactNode;
14
15
  }
15
16
  declare const Notice: React.ForwardRefExoticComponent<NoticeProps & React.RefAttributes<HTMLDivElement>>;
@@ -7,11 +7,12 @@ export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {
7
7
  variant?: 'text' | 'info' | 'big';
8
8
  association?: 'aria-labelledby' | 'aria-describedby' | 'none';
9
9
  show?: boolean | undefined;
10
+ defaultShow?: boolean;
10
11
  placement?: Placement;
11
12
  portal?: React.RefObject<HTMLElement> | HTMLElement;
12
13
  hideElementOnHidden?: boolean;
13
14
  }
14
- declare function Tooltip({ id: propId, placement: initialPlacement, children, portal, target, association, variant, show: initialShow, hideElementOnHidden, className, ...props }: TooltipProps): JSX.Element;
15
+ declare function Tooltip({ id: propId, placement: initialPlacement, children, portal, target, association, variant, show: showProp, defaultShow, hideElementOnHidden, className, ...props }: TooltipProps): JSX.Element;
15
16
  declare namespace Tooltip {
16
17
  var displayName: string;
17
18
  }
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
@@ -1437,6 +1437,7 @@ var Dialog = /** @class */ (function (_super) {
1437
1437
  ? heading.level
1438
1438
  : 2);
1439
1439
  var Dialog = (React__default["default"].createElement(FocusTrap__default["default"], { focusTrapOptions: {
1440
+ allowOutsideClick: true,
1440
1441
  onDeactivate: this.close,
1441
1442
  escapeDeactivates: !forceAction,
1442
1443
  fallbackFocus: '.Dialog__heading'
@@ -1593,6 +1594,7 @@ var Button = React.forwardRef(function (_a, ref) {
1593
1594
  'Button--primary': variant === 'primary',
1594
1595
  'Button--secondary': variant === 'secondary',
1595
1596
  'Button--error': variant === 'error',
1597
+ 'Button--tertiary': variant === 'tertiary',
1596
1598
  Link: variant === 'link',
1597
1599
  Tag: variant === 'tag',
1598
1600
  'Button--tag': variant === 'tag',
@@ -1652,10 +1654,10 @@ var fireCustomEvent = function (show, button) {
1652
1654
  };
1653
1655
  function Tooltip(_a) {
1654
1656
  var _this = this;
1655
- var propId = _a.id, _b = _a.placement, initialPlacement = _b === void 0 ? 'auto' : _b, children = _a.children, portal = _a.portal, target = _a.target, _c = _a.association, association = _c === void 0 ? 'aria-describedby' : _c, _d = _a.variant, variant = _d === void 0 ? 'text' : _d, _e = _a.show, initialShow = _e === void 0 ? false : _e, _f = _a.hideElementOnHidden, hideElementOnHidden = _f === void 0 ? false : _f, className = _a.className, props = tslib.__rest(_a, ["id", "placement", "children", "portal", "target", "association", "variant", "show", "hideElementOnHidden", "className"]);
1657
+ var propId = _a.id, _b = _a.placement, initialPlacement = _b === void 0 ? 'auto' : _b, children = _a.children, portal = _a.portal, target = _a.target, _c = _a.association, association = _c === void 0 ? 'aria-describedby' : _c, _d = _a.variant, variant = _d === void 0 ? 'text' : _d, showProp = _a.show, _e = _a.defaultShow, defaultShow = _e === void 0 ? false : _e, _f = _a.hideElementOnHidden, hideElementOnHidden = _f === void 0 ? false : _f, className = _a.className, props = tslib.__rest(_a, ["id", "placement", "children", "portal", "target", "association", "variant", "show", "defaultShow", "hideElementOnHidden", "className"]);
1656
1658
  var _g = tslib.__read(propId ? [propId] : nextId.useId(1, 'tooltip'), 1), id = _g[0];
1657
1659
  var hideTimeoutRef = React.useRef(null);
1658
- var _h = tslib.__read(React.useState(!!initialShow), 2), showTooltip = _h[0], setShowTooltip = _h[1];
1660
+ var _h = tslib.__read(React.useState(!!showProp || defaultShow), 2), showTooltip = _h[0], setShowTooltip = _h[1];
1659
1661
  var _j = tslib.__read(React.useState(null), 2), targetElement = _j[0], setTargetElement = _j[1];
1660
1662
  var _k = tslib.__read(React.useState(null), 2), tooltipElement = _k[0], setTooltipElement = _k[1];
1661
1663
  var _l = tslib.__read(React.useState(null), 2), arrowElement = _l[0], setArrowElement = _l[1];
@@ -1707,12 +1709,20 @@ function Tooltip(_a) {
1707
1709
  fireCustomEvent(false, targetElement);
1708
1710
  }, TIP_HIDE_DELAY);
1709
1711
  }
1712
+ return function () {
1713
+ clearTimeout(hideTimeoutRef.current);
1714
+ };
1710
1715
  }, [targetElement]);
1711
1716
  // Keep targetElement in sync with target prop
1712
1717
  React.useEffect(function () {
1713
1718
  var targetElement = target && 'current' in target ? target.current : target;
1714
1719
  setTargetElement(targetElement);
1715
1720
  }, [target]);
1721
+ React.useEffect(function () {
1722
+ if (typeof showProp === 'boolean') {
1723
+ setShowTooltip(showProp);
1724
+ }
1725
+ }, [showProp]);
1716
1726
  // Get popper placement
1717
1727
  var placement = (attributes.popper &&
1718
1728
  attributes.popper['data-popper-placement']) ||
@@ -1727,38 +1737,46 @@ function Tooltip(_a) {
1727
1737
  }
1728
1738
  };
1729
1739
  var targetElement = document.body;
1730
- if (showTooltip) {
1731
- targetElement.addEventListener('keyup', handleEscape);
1740
+ if (showTooltip && typeof showProp !== 'boolean') {
1741
+ targetElement.addEventListener('keyup', handleEscape, { capture: true });
1732
1742
  }
1733
1743
  else {
1734
- targetElement.removeEventListener('keyup', handleEscape);
1744
+ targetElement.removeEventListener('keyup', handleEscape, {
1745
+ capture: true
1746
+ });
1735
1747
  }
1736
1748
  return function () {
1737
- targetElement.removeEventListener('keyup', handleEscape);
1749
+ targetElement.removeEventListener('keyup', handleEscape, {
1750
+ capture: true
1751
+ });
1738
1752
  };
1739
- }, [showTooltip]);
1753
+ }, [showTooltip, showProp]);
1740
1754
  // Handle hover and focus events for the targetElement
1741
1755
  React.useEffect(function () {
1742
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('mouseenter', show);
1743
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('mouseleave', hide);
1744
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('focusin', show);
1745
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('focusout', hide);
1756
+ if (typeof showProp !== 'boolean') {
1757
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('mouseenter', show);
1758
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('mouseleave', hide);
1759
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('focusin', show);
1760
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('focusout', hide);
1761
+ }
1746
1762
  return function () {
1747
1763
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('mouseenter', show);
1748
1764
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('mouseleave', hide);
1749
1765
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('focusin', show);
1750
1766
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('focusout', hide);
1751
1767
  };
1752
- }, [targetElement, show, hide]);
1768
+ }, [targetElement, show, hide, showProp]);
1753
1769
  // Handle hover events for the tooltipElement
1754
1770
  React.useEffect(function () {
1755
- tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.addEventListener('mouseenter', show);
1756
- tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.addEventListener('mouseleave', hide);
1771
+ if (typeof showProp !== 'boolean') {
1772
+ tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.addEventListener('mouseenter', show);
1773
+ tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.addEventListener('mouseleave', hide);
1774
+ }
1757
1775
  return function () {
1758
1776
  tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.removeEventListener('mouseenter', show);
1759
1777
  tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.removeEventListener('mouseleave', hide);
1760
1778
  };
1761
- }, [tooltipElement, show, hide]);
1779
+ }, [tooltipElement, show, hide, showProp]);
1762
1780
  // Keep the target's id in sync
1763
1781
  React.useEffect(function () {
1764
1782
  if (hasAriaAssociation) {
@@ -1834,6 +1852,7 @@ var IconButton = React.forwardRef(function (_a, ref) {
1834
1852
  IconButton: true,
1835
1853
  'IconButton--primary': variant === 'primary',
1836
1854
  'IconButton--secondary': variant === 'secondary',
1855
+ 'IconButton--tertiary': variant === 'tertiary',
1837
1856
  'IconButton--error': variant === 'error',
1838
1857
  'IconButton--large': large
1839
1858
  }), ref: internalRef, disabled: disabled, tabIndex: disabled ? -1 : tabIndex }, accessibilityProps, other),
@@ -2594,6 +2613,19 @@ var Tag = function (_a) {
2594
2613
  };
2595
2614
  Tag.displayName = 'Tag';
2596
2615
 
2616
+ var BadgeLabel = React.forwardRef(function (_a, ref) {
2617
+ var children = _a.children, className = _a.className, other = tslib.__rest(_a, ["children", "className"]);
2618
+ return (React__default["default"].createElement("div", tslib.__assign({ ref: ref, className: classNames__default["default"]('Badge__Label', className) }, other), children));
2619
+ });
2620
+ BadgeLabel.displayName = 'BadgeLabel';
2621
+ var Badge = React.forwardRef(function (_a, ref) {
2622
+ var children = _a.children, className = _a.className, _b = _a.size, size = _b === void 0 ? 'default' : _b, other = tslib.__rest(_a, ["children", "className", "size"]);
2623
+ return (React__default["default"].createElement("div", tslib.__assign({ className: classNames__default["default"]('Badge', className, {
2624
+ 'Badge--small': size === 'small'
2625
+ }), ref: ref }, other), children));
2626
+ });
2627
+ Badge.displayName = 'Badge';
2628
+
2597
2629
  var TagButton = React__default["default"].forwardRef(function (_a, ref) {
2598
2630
  var label = _a.label, value = _a.value, icon = _a.icon, className = _a.className, rest = tslib.__rest(_a, ["label", "value", "icon", "className"]);
2599
2631
  return (React__default["default"].createElement(Button, tslib.__assign({ variant: "tag", className: classNames__default["default"]('TagButton', className), ref: ref }, rest),
@@ -3160,13 +3192,13 @@ var iconTypeMap = {
3160
3192
  };
3161
3193
  var Notice = React.forwardRef(function (_a, ref) {
3162
3194
  var _b;
3163
- var _c = _a.type, type = _c === void 0 ? 'info' : _c, title = _a.title, icon = _a.icon, children = _a.children, otherProps = tslib.__rest(_a, ["type", "title", "icon", "children"]);
3195
+ var _c = _a.type, type = _c === void 0 ? 'info' : _c, title = _a.title, icon = _a.icon, _d = _a.variant, variant = _d === void 0 ? 'default' : _d, children = _a.children, otherProps = tslib.__rest(_a, ["type", "title", "icon", "variant", "children"]);
3164
3196
  return (React__default["default"].createElement("div", tslib.__assign({ className: classNames__default["default"]('Notice', (_b = {},
3165
3197
  _b["Notice--".concat(type)] = type,
3198
+ _b["Notice--condensed"] = variant === 'condensed',
3166
3199
  _b)), ref: ref }, otherProps),
3167
- React__default["default"].createElement("div", { className: "Notice__title" },
3168
- React__default["default"].createElement(Icon, { type: icon || iconTypeMap[type] }),
3169
- title),
3200
+ React__default["default"].createElement(Icon, { type: icon || iconTypeMap[type] }),
3201
+ React__default["default"].createElement("div", { className: "Notice__title" }, title),
3170
3202
  children && React__default["default"].createElement("div", { className: "Notice__content" }, children)));
3171
3203
  });
3172
3204
  Notice.displayName = 'Notice';
@@ -4093,6 +4125,8 @@ exports.Alert = Alert;
4093
4125
  exports.AlertActions = AlertActions;
4094
4126
  exports.AlertContent = AlertContent;
4095
4127
  exports.AriaIsolate = AriaIsolate;
4128
+ exports.Badge = Badge;
4129
+ exports.BadgeLabel = BadgeLabel;
4096
4130
  exports.Breadcrumb = Breadcrumb;
4097
4131
  exports.BreadcrumbItem = BreadcrumbItem;
4098
4132
  exports.BreadcrumbLink = BreadcrumbLink;
package/lib/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReactElement, ReactFragment, ReactPortal } from 'react';
1
+ import type { ReactElement, ReactPortal } from 'react';
2
2
  export declare namespace Cauldron {
3
3
  type LabelProps = {
4
4
  'aria-label': string;
@@ -10,4 +10,4 @@ export declare namespace Cauldron {
10
10
  * This type is meant to ensure that a prop can actually be rendered as content.
11
11
  * Explicit equivalent of Exclude<ReactNode, boolean | null | undefined>
12
12
  */
13
- export type ContentNode = string | number | ReactFragment | ReactPortal | ReactElement;
13
+ export type ContentNode = string | number | ReactPortal | ReactElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "6.4.1",
3
+ "version": "6.4.2-canary.0b8be6a5",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",
@@ -47,7 +47,6 @@
47
47
  "@testing-library/react": "^12",
48
48
  "@testing-library/user-event": "^14.5.2",
49
49
  "@types/classnames": "^2.2.10",
50
- "@types/enzyme-adapter-react-16": "^1.0.9",
51
50
  "@types/jest": "^29.5.11",
52
51
  "@types/jest-axe": "^3.5.4",
53
52
  "@types/node": "^17.0.42",
@@ -59,8 +58,6 @@
59
58
  "babel-plugin-module-resolver": "^4.0.0",
60
59
  "babel-plugin-transform-export-extensions": "^6.22.0",
61
60
  "concurrently": "^5.3.0",
62
- "enzyme": "^3.11.0",
63
- "enzyme-adapter-react-16": "^1.15.2",
64
61
  "jest": "^29.7.0",
65
62
  "jest-axe": "^8.0.0",
66
63
  "jest-environment-jsdom": "^29.7.0",