@deque/cauldron-react 6.4.2-canary.dd084439 → 6.4.2-canary.eaeac9f4

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>>;
@@ -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
@@ -1594,6 +1594,7 @@ var Button = React.forwardRef(function (_a, ref) {
1594
1594
  'Button--primary': variant === 'primary',
1595
1595
  'Button--secondary': variant === 'secondary',
1596
1596
  'Button--error': variant === 'error',
1597
+ 'Button--tertiary': variant === 'tertiary',
1597
1598
  Link: variant === 'link',
1598
1599
  Tag: variant === 'tag',
1599
1600
  'Button--tag': variant === 'tag',
@@ -1653,10 +1654,10 @@ var fireCustomEvent = function (show, button) {
1653
1654
  };
1654
1655
  function Tooltip(_a) {
1655
1656
  var _this = this;
1656
- 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"]);
1657
1658
  var _g = tslib.__read(propId ? [propId] : nextId.useId(1, 'tooltip'), 1), id = _g[0];
1658
1659
  var hideTimeoutRef = React.useRef(null);
1659
- 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];
1660
1661
  var _j = tslib.__read(React.useState(null), 2), targetElement = _j[0], setTargetElement = _j[1];
1661
1662
  var _k = tslib.__read(React.useState(null), 2), tooltipElement = _k[0], setTooltipElement = _k[1];
1662
1663
  var _l = tslib.__read(React.useState(null), 2), arrowElement = _l[0], setArrowElement = _l[1];
@@ -1708,12 +1709,20 @@ function Tooltip(_a) {
1708
1709
  fireCustomEvent(false, targetElement);
1709
1710
  }, TIP_HIDE_DELAY);
1710
1711
  }
1712
+ return function () {
1713
+ clearTimeout(hideTimeoutRef.current);
1714
+ };
1711
1715
  }, [targetElement]);
1712
1716
  // Keep targetElement in sync with target prop
1713
1717
  React.useEffect(function () {
1714
1718
  var targetElement = target && 'current' in target ? target.current : target;
1715
1719
  setTargetElement(targetElement);
1716
1720
  }, [target]);
1721
+ React.useEffect(function () {
1722
+ if (typeof showProp === 'boolean') {
1723
+ setShowTooltip(showProp);
1724
+ }
1725
+ }, [showProp]);
1717
1726
  // Get popper placement
1718
1727
  var placement = (attributes.popper &&
1719
1728
  attributes.popper['data-popper-placement']) ||
@@ -1728,7 +1737,7 @@ function Tooltip(_a) {
1728
1737
  }
1729
1738
  };
1730
1739
  var targetElement = document.body;
1731
- if (showTooltip) {
1740
+ if (showTooltip && typeof showProp !== 'boolean') {
1732
1741
  targetElement.addEventListener('keyup', handleEscape, { capture: true });
1733
1742
  }
1734
1743
  else {
@@ -1741,29 +1750,33 @@ function Tooltip(_a) {
1741
1750
  capture: true
1742
1751
  });
1743
1752
  };
1744
- }, [showTooltip]);
1753
+ }, [showTooltip, showProp]);
1745
1754
  // Handle hover and focus events for the targetElement
1746
1755
  React.useEffect(function () {
1747
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('mouseenter', show);
1748
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('mouseleave', hide);
1749
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('focusin', show);
1750
- 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
+ }
1751
1762
  return function () {
1752
1763
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('mouseenter', show);
1753
1764
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('mouseleave', hide);
1754
1765
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('focusin', show);
1755
1766
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('focusout', hide);
1756
1767
  };
1757
- }, [targetElement, show, hide]);
1768
+ }, [targetElement, show, hide, showProp]);
1758
1769
  // Handle hover events for the tooltipElement
1759
1770
  React.useEffect(function () {
1760
- tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.addEventListener('mouseenter', show);
1761
- 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
+ }
1762
1775
  return function () {
1763
1776
  tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.removeEventListener('mouseenter', show);
1764
1777
  tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.removeEventListener('mouseleave', hide);
1765
1778
  };
1766
- }, [tooltipElement, show, hide]);
1779
+ }, [tooltipElement, show, hide, showProp]);
1767
1780
  // Keep the target's id in sync
1768
1781
  React.useEffect(function () {
1769
1782
  if (hasAriaAssociation) {
@@ -1839,6 +1852,7 @@ var IconButton = React.forwardRef(function (_a, ref) {
1839
1852
  IconButton: true,
1840
1853
  'IconButton--primary': variant === 'primary',
1841
1854
  'IconButton--secondary': variant === 'secondary',
1855
+ 'IconButton--tertiary': variant === 'tertiary',
1842
1856
  'IconButton--error': variant === 'error',
1843
1857
  'IconButton--large': large
1844
1858
  }), ref: internalRef, disabled: disabled, tabIndex: disabled ? -1 : tabIndex }, accessibilityProps, other),
@@ -2599,6 +2613,19 @@ var Tag = function (_a) {
2599
2613
  };
2600
2614
  Tag.displayName = 'Tag';
2601
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
+
2602
2629
  var TagButton = React__default["default"].forwardRef(function (_a, ref) {
2603
2630
  var label = _a.label, value = _a.value, icon = _a.icon, className = _a.className, rest = tslib.__rest(_a, ["label", "value", "icon", "className"]);
2604
2631
  return (React__default["default"].createElement(Button, tslib.__assign({ variant: "tag", className: classNames__default["default"]('TagButton', className), ref: ref }, rest),
@@ -3165,13 +3192,13 @@ var iconTypeMap = {
3165
3192
  };
3166
3193
  var Notice = React.forwardRef(function (_a, ref) {
3167
3194
  var _b;
3168
- 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"]);
3169
3196
  return (React__default["default"].createElement("div", tslib.__assign({ className: classNames__default["default"]('Notice', (_b = {},
3170
3197
  _b["Notice--".concat(type)] = type,
3198
+ _b["Notice--condensed"] = variant === 'condensed',
3171
3199
  _b)), ref: ref }, otherProps),
3172
- React__default["default"].createElement("div", { className: "Notice__title" },
3173
- React__default["default"].createElement(Icon, { type: icon || iconTypeMap[type] }),
3174
- title),
3200
+ React__default["default"].createElement(Icon, { type: icon || iconTypeMap[type] }),
3201
+ React__default["default"].createElement("div", { className: "Notice__title" }, title),
3175
3202
  children && React__default["default"].createElement("div", { className: "Notice__content" }, children)));
3176
3203
  });
3177
3204
  Notice.displayName = 'Notice';
@@ -4098,6 +4125,8 @@ exports.Alert = Alert;
4098
4125
  exports.AlertActions = AlertActions;
4099
4126
  exports.AlertContent = AlertContent;
4100
4127
  exports.AriaIsolate = AriaIsolate;
4128
+ exports.Badge = Badge;
4129
+ exports.BadgeLabel = BadgeLabel;
4101
4130
  exports.Breadcrumb = Breadcrumb;
4102
4131
  exports.BreadcrumbItem = BreadcrumbItem;
4103
4132
  exports.BreadcrumbLink = BreadcrumbLink;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "6.4.2-canary.dd084439",
3
+ "version": "6.4.2-canary.eaeac9f4",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",