@deque/cauldron-react 6.27.0-canary.abfc9efd → 6.27.0-canary.b5fbb03d

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.
@@ -1,8 +1,17 @@
1
1
  import React, { type ButtonHTMLAttributes, type Ref } from 'react';
2
- export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
2
+ import type { TagSize } from '../Tag';
3
+ interface ButtonBaseProps extends ButtonHTMLAttributes<HTMLButtonElement> {
3
4
  buttonRef?: Ref<HTMLButtonElement>;
4
- variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'danger' | 'danger-secondary' | 'link' | 'tag' | 'badge';
5
5
  thin?: boolean;
6
6
  }
7
+ interface ButtonTagProps extends ButtonBaseProps {
8
+ variant: 'tag';
9
+ size?: TagSize;
10
+ }
11
+ interface ButtonNonTagProps extends ButtonBaseProps {
12
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'danger' | 'danger-secondary' | 'link' | 'badge';
13
+ size?: never;
14
+ }
15
+ export type ButtonProps = ButtonTagProps | ButtonNonTagProps;
7
16
  declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
8
17
  export default Button;
@@ -3,7 +3,7 @@ import { ContentNode } from '../../types';
3
3
  import Button from '../Button';
4
4
  import Tooltip from '../Tooltip';
5
5
  type ButtonProps = React.ComponentProps<typeof Button>;
6
- export interface CopyButtonProps extends Omit<ButtonProps, 'onCopy' | 'onClick'> {
6
+ export interface CopyButtonProps extends Omit<ButtonProps, 'onCopy' | 'onClick' | 'size'> {
7
7
  value: string;
8
8
  variant?: Extract<ButtonProps['variant'], 'primary' | 'secondary' | 'tertiary'>;
9
9
  children?: ContentNode;
@@ -7,18 +7,6 @@ export interface IconButtonProps extends PolymorphicProps<React.HTMLAttributes<H
7
7
  label: React.ReactNode;
8
8
  tooltipProps?: Omit<TooltipProps, 'children' | 'target'>;
9
9
  disabled?: boolean;
10
- /**
11
- * @deprecated use `tooltipProps.placement` instead
12
- */
13
- tooltipPlacement?: TooltipProps['placement'];
14
- /**
15
- * @deprecated use `tooltipProps.variant` instead
16
- */
17
- tooltipVariant?: TooltipProps['variant'];
18
- /**
19
- * @deprecated use `tooltipProps.portal` instead
20
- */
21
- tooltipPortal?: TooltipProps['portal'];
22
10
  variant?: 'primary' | 'secondary' | 'tertiary' | 'error';
23
11
  large?: boolean;
24
12
  }
@@ -4,7 +4,9 @@ type SortDirection = 'ascending' | 'descending' | 'none';
4
4
  interface TableHeaderProps extends Omit<React.ThHTMLAttributes<HTMLTableHeaderCellElement>, 'align'> {
5
5
  sortDirection?: SortDirection;
6
6
  onSort?: () => void;
7
+ /** @deprecated No longer used. Sort state is communicated via aria-sort. */
7
8
  sortAscendingAnnouncement?: string;
9
+ /** @deprecated No longer used. Sort state is communicated via aria-sort. */
8
10
  sortDescendingAnnouncement?: string;
9
11
  align?: ColumnAlignment;
10
12
  variant?: 'header' | 'cell';
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
+ export type TagSize = 'default' | 'small';
2
3
  interface TagProps {
3
4
  children: React.ReactNode;
4
5
  className?: string;
5
- size?: 'default' | 'small';
6
+ size?: TagSize;
6
7
  }
7
8
  export declare const TagLabel: {
8
9
  ({ children, className, ...other }: TagProps): React.JSX.Element;
@@ -1,11 +1,13 @@
1
- import React from 'react';
1
+ import React, { type ButtonHTMLAttributes } from 'react';
2
2
  import { IconType } from '../Icon';
3
3
  import { ContentNode } from '../../types';
4
- interface TagButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
4
+ import { type TagSize } from '../Tag';
5
+ interface TagButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value'> {
5
6
  label: ContentNode;
6
7
  value: ContentNode;
7
8
  icon: IconType;
8
9
  onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
10
+ size?: TagSize;
9
11
  }
10
12
  declare const TagButton: React.ForwardRefExoticComponent<TagButtonProps & React.RefAttributes<HTMLButtonElement>>;
11
13
  export default TagButton;
package/lib/index.d.ts CHANGED
@@ -37,7 +37,7 @@ export { default as Sidebar, SideBarItem } from './components/SideBar';
37
37
  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
- export { default as Tag, TagLabel } from './components/Tag';
40
+ export { default as Tag, TagLabel, type TagSize } from './components/Tag';
41
41
  export { default as Badge, BadgeLabel } from './components/Badge';
42
42
  export { default as ImpactBadge } from './components/ImpactBadge';
43
43
  export { default as TagButton } from './components/TagButton';
package/lib/index.js CHANGED
@@ -1768,7 +1768,7 @@ var SkipLink = /** @class */ (function (_super) {
1768
1768
  }(React__default["default"].Component));
1769
1769
 
1770
1770
  var Button = React.forwardRef(function (_a, ref) {
1771
- var _b = _a.variant, variant = _b === void 0 ? 'primary' : _b, thin = _a.thin, children = _a.children, className = _a.className, buttonRef = _a.buttonRef, other = tslib.__rest(_a, ["variant", "thin", "children", "className", "buttonRef"]);
1771
+ var _b = _a.variant, variant = _b === void 0 ? 'primary' : _b, thin = _a.thin, size = _a.size, children = _a.children, className = _a.className, buttonRef = _a.buttonRef, other = tslib.__rest(_a, ["variant", "thin", "size", "children", "className", "buttonRef"]);
1772
1772
  return (React__default["default"].createElement("button", tslib.__assign({ type: "button", className: classNames__default["default"](className, {
1773
1773
  'Button--primary': variant === 'primary',
1774
1774
  'Button--secondary': variant === 'secondary',
@@ -1779,6 +1779,7 @@ var Button = React.forwardRef(function (_a, ref) {
1779
1779
  Link: variant === 'link',
1780
1780
  Tag: variant === 'tag',
1781
1781
  'Button--tag': variant === 'tag',
1782
+ 'Tag--small': variant === 'tag' && size === 'small',
1782
1783
  'Button--thin': thin,
1783
1784
  'Button--badge': variant === 'badge'
1784
1785
  }), ref: ref || buttonRef }, other), children));
@@ -2118,7 +2119,7 @@ var looksLikeLink = function (props) {
2118
2119
  return 'to' in props || 'href' in props;
2119
2120
  };
2120
2121
  var IconButton = React.forwardRef(function (_a, ref) {
2121
- var _b = _a.as, Component = _b === void 0 ? 'button' : _b, icon = _a.icon, label = _a.label, tooltipPlacement = _a.tooltipPlacement, tooltipVariant = _a.tooltipVariant, tooltipPortal = _a.tooltipPortal, _c = _a.tooltipProps, tooltipPropsProp = _c === void 0 ? {} : _c, className = _a.className, _d = _a.variant, variant = _d === void 0 ? 'secondary' : _d, disabled = _a.disabled, _e = _a.tabIndex, tabIndex = _e === void 0 ? 0 : _e, large = _a.large, other = tslib.__rest(_a, ["as", "icon", "label", "tooltipPlacement", "tooltipVariant", "tooltipPortal", "tooltipProps", "className", "variant", "disabled", "tabIndex", "large"]);
2122
+ var _b = _a.as, Component = _b === void 0 ? 'button' : _b, icon = _a.icon, label = _a.label, _c = _a.tooltipProps, tooltipPropsProp = _c === void 0 ? {} : _c, className = _a.className, _d = _a.variant, variant = _d === void 0 ? 'secondary' : _d, disabled = _a.disabled, _e = _a.tabIndex, tabIndex = _e === void 0 ? 0 : _e, large = _a.large, other = tslib.__rest(_a, ["as", "icon", "label", "tooltipProps", "className", "variant", "disabled", "tabIndex", "large"]);
2122
2123
  var internalRef = React.useRef();
2123
2124
  React.useImperativeHandle(ref, function () { return internalRef.current; });
2124
2125
  // Configure additional properties based on the type of the Component
@@ -2136,15 +2137,7 @@ var IconButton = React.forwardRef(function (_a, ref) {
2136
2137
  accessibilityProps['aria-disabled'] = disabled;
2137
2138
  }
2138
2139
  }
2139
- if (process.env.NODE_ENV !== 'production') {
2140
- if (!!tooltipPlacement || !!tooltipVariant || !!tooltipPortal) {
2141
- React__default["default"].useEffect(function () {
2142
- console.warn('[IconButton] The following props are deprecated: tooltipPlacement, tooltipVariant, tooltipPortal. ' +
2143
- 'See https://cauldron.dequelabs.com/components/IconButton for recommended replacement.');
2144
- }, []);
2145
- }
2146
- }
2147
- var tooltipProps = tslib.__assign({ placement: tooltipPlacement || 'auto', variant: tooltipVariant, portal: tooltipPortal, association: 'aria-labelledby', hideElementOnHidden: true }, tooltipPropsProp);
2140
+ var tooltipProps = tslib.__assign({ placement: 'auto', association: 'aria-labelledby', hideElementOnHidden: true }, tooltipPropsProp);
2148
2141
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
2149
2142
  React__default["default"].createElement(Component, tslib.__assign({ className: classNames__default["default"](className, {
2150
2143
  IconButton: true,
@@ -3042,8 +3035,8 @@ var ImpactBadge = React.forwardRef(function (_a, ref) {
3042
3035
  ImpactBadge.displayName = 'ImpactBadge';
3043
3036
 
3044
3037
  var TagButton = React__default["default"].forwardRef(function (_a, ref) {
3045
- var label = _a.label, value = _a.value, icon = _a.icon, className = _a.className, rest = tslib.__rest(_a, ["label", "value", "icon", "className"]);
3046
- return (React__default["default"].createElement(Button, tslib.__assign({ variant: "tag", className: classNames__default["default"]('TagButton', className), ref: ref }, rest),
3038
+ var label = _a.label, value = _a.value, icon = _a.icon, className = _a.className, size = _a.size, rest = tslib.__rest(_a, ["label", "value", "icon", "className", "size"]);
3039
+ return (React__default["default"].createElement(Button, tslib.__assign({ variant: "tag", className: classNames__default["default"]('TagButton', className), size: size, ref: ref }, rest),
3047
3040
  React__default["default"].createElement(TagLabel, null, label),
3048
3041
  value,
3049
3042
  React__default["default"].createElement(Icon, { className: "TagButton__icon", type: icon })));
@@ -3186,23 +3179,25 @@ var TableHead = React.forwardRef(function (_a, ref) {
3186
3179
  TableHead.displayName = 'TableHead';
3187
3180
 
3188
3181
  var TableHeader = React.forwardRef(function (_a, ref) {
3189
- var children = _a.children, sortDirection = _a.sortDirection, onSort = _a.onSort, className = _a.className, _b = _a.sortAscendingAnnouncement, sortAscendingAnnouncement = _b === void 0 ? 'sorted ascending' : _b, _c = _a.sortDescendingAnnouncement, sortDescendingAnnouncement = _c === void 0 ? 'sorted descending' : _c, align = _a.align, _d = _a.variant, variant = _d === void 0 ? 'header' : _d, style = _a.style, other = tslib.__rest(_a, ["children", "sortDirection", "onSort", "className", "sortAscendingAnnouncement", "sortDescendingAnnouncement", "align", "variant", "style"]);
3182
+ var children = _a.children, sortDirection = _a.sortDirection, onSort = _a.onSort, className = _a.className, _sortAscendingAnnouncement = _a.sortAscendingAnnouncement, _sortDescendingAnnouncement = _a.sortDescendingAnnouncement, align = _a.align, _b = _a.variant, variant = _b === void 0 ? 'header' : _b, style = _a.style, other = tslib.__rest(_a, ["children", "sortDirection", "onSort", "className", "sortAscendingAnnouncement", "sortDescendingAnnouncement", "align", "variant", "style"]);
3190
3183
  var tableHeaderRef = useSharedRef(ref);
3191
- var _e = useTable(), layout = _e.layout, columns = _e.columns;
3184
+ var _c = useTable(), layout = _c.layout, columns = _c.columns;
3192
3185
  var tableGridStyles = useTableGridStyles({
3193
3186
  elementRef: tableHeaderRef,
3194
3187
  align: align,
3195
3188
  columns: columns,
3196
3189
  layout: layout
3197
3190
  });
3198
- // When the sort direction changes, we want to announce the change in a live region
3199
- // because changes to the sort value is not widely supported yet
3200
- // see: https://a11ysupport.io/tech/aria/aria-sort_attribute
3201
- var announcement = sortDirection === 'ascending'
3202
- ? sortAscendingAnnouncement
3203
- : sortDirection === 'descending'
3204
- ? sortDescendingAnnouncement
3205
- : '';
3191
+ React.useEffect(function () {
3192
+ if (process.env.NODE_ENV === 'production')
3193
+ return;
3194
+ if (_sortAscendingAnnouncement !== undefined ||
3195
+ _sortDescendingAnnouncement !== undefined) {
3196
+ console.warn('[TableHeader] The following props are deprecated and no longer used: sortAscendingAnnouncement, sortDescendingAnnouncement. ' +
3197
+ 'Sort state is communicated via aria-sort. ' +
3198
+ 'See https://cauldron.dequelabs.com/components/Table for more information.');
3199
+ }
3200
+ }, [_sortAscendingAnnouncement, _sortDescendingAnnouncement]);
3206
3201
  return (React__default["default"].createElement("th", tslib.__assign({ ref: tableHeaderRef, "aria-sort": sortDirection, className: classNames__default["default"](variant === 'cell'
3207
3202
  ? ['TableCell', 'TableHeader--cell-variant']
3208
3203
  : 'TableHeader', className, {
@@ -3210,9 +3205,7 @@ var TableHeader = React.forwardRef(function (_a, ref) {
3210
3205
  'TableHeader--sort-descending': sortDirection === 'descending'
3211
3206
  }), style: tslib.__assign(tslib.__assign({}, tableGridStyles), style) }, other), !!onSort && !!sortDirection ? (React__default["default"].createElement("button", { onClick: onSort, className: "TableHeader__sort-button", type: "button" },
3212
3207
  children,
3213
- React__default["default"].createElement("span", { "aria-hidden": "true" }, sortDirection === 'none' ? (React__default["default"].createElement(Icon, { type: "sort-triangle" })) : sortDirection === 'ascending' ? (React__default["default"].createElement(Icon, { type: "table-sort-ascending" })) : (React__default["default"].createElement(Icon, { type: "table-sort-descending" }))),
3214
- React__default["default"].createElement(Offscreen, null,
3215
- React__default["default"].createElement("span", { role: "status", "aria-live": "polite" }, announcement)))) : (children)));
3208
+ React__default["default"].createElement("span", { "aria-hidden": "true" }, sortDirection === 'none' ? (React__default["default"].createElement(Icon, { type: "sort-triangle" })) : sortDirection === 'ascending' ? (React__default["default"].createElement(Icon, { type: "table-sort-ascending" })) : (React__default["default"].createElement(Icon, { type: "table-sort-descending" }))))) : (children)));
3216
3209
  });
3217
3210
  TableHeader.displayName = 'TableHeader';
3218
3211
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "6.27.0-canary.abfc9efd",
3
+ "version": "6.27.0-canary.b5fbb03d",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",