@deque/cauldron-react 4.3.0-canary.9d2b7bb9 → 4.3.0-canary.9df9e64f

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.
@@ -2,7 +2,7 @@ import React, { InputHTMLAttributes, Ref } from 'react';
2
2
  export interface CheckboxProps extends InputHTMLAttributes<HTMLInputElement> {
3
3
  id: string;
4
4
  label: React.ReactNode;
5
- labelDescription?: string;
5
+ labelDescription?: React.ReactNode;
6
6
  error?: React.ReactNode;
7
7
  customIcon?: React.ReactNode;
8
8
  checkboxRef?: Ref<HTMLInputElement>;
@@ -1,9 +1,16 @@
1
+ /**
2
+ * Unfortunately, eslint does not recognize the Polymorphic component has propTypes set
3
+ *
4
+ * We might be able to remove this if we upgrade eslint and associated plugins
5
+ * See: https://github.com/dequelabs/cauldron/issues/451
6
+ */
7
+ import React from 'react';
1
8
  import * as Polymorphic from '../../utils/polymorphic-type';
2
9
  import { IconType } from '../Icon';
3
10
  import { TooltipProps } from '../Tooltip';
4
11
  export interface IconButtonOwnProps {
5
12
  icon: IconType;
6
- label: string;
13
+ label: React.ReactNode;
7
14
  tooltipPlacement?: TooltipProps['placement'];
8
15
  tooltipVariant?: TooltipProps['variant'];
9
16
  tooltipPortal?: TooltipProps['portal'];
@@ -4,6 +4,7 @@ interface LoaderOverlayProps extends React.HTMLAttributes<HTMLDivElement> {
4
4
  label?: string;
5
5
  focusOnInitialRender?: boolean;
6
6
  children?: React.ReactNode;
7
+ focusTrap?: boolean;
7
8
  }
8
9
  declare const LoaderOverlay: React.ForwardRefExoticComponent<LoaderOverlayProps & React.RefAttributes<HTMLDivElement>>;
9
10
  export default LoaderOverlay;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  export interface RadioItem extends React.InputHTMLAttributes<HTMLInputElement> {
4
- label: string;
4
+ label: React.ReactNode;
5
5
  value?: string;
6
- labelDescription?: string;
6
+ labelDescription?: React.ReactNode;
7
7
  }
8
8
  export interface RadioGroupProps {
9
9
  name?: string;
package/lib/index.js CHANGED
@@ -1665,13 +1665,6 @@ var IconButton = React.forwardRef(function (_a, ref) {
1665
1665
  accessibilityProps['aria-disabled'] = disabled;
1666
1666
  }
1667
1667
  }
1668
- React.useEffect(function () {
1669
- var _a;
1670
- if (!disabled) {
1671
- return;
1672
- }
1673
- (_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-label', label);
1674
- }, [disabled]);
1675
1668
  return (React__default.createElement(React__default.Fragment, null,
1676
1669
  React__default.createElement(Component, tslib.__assign({ className: classNames(className, {
1677
1670
  IconButton: true,
@@ -1679,7 +1672,8 @@ var IconButton = React.forwardRef(function (_a, ref) {
1679
1672
  'IconButton--secondary': variant === 'secondary',
1680
1673
  'IconButton--error': variant === 'error'
1681
1674
  }), ref: internalRef, disabled: disabled, tabIndex: disabled ? -1 : tabIndex }, accessibilityProps, other),
1682
- React__default.createElement(Icon, { type: icon })),
1675
+ React__default.createElement(Icon, { type: icon }),
1676
+ React__default.createElement(Offscreen, null, label)),
1683
1677
  !disabled && (React__default.createElement(Tooltip, { target: internalRef, placement: tooltipPlacement, variant: tooltipVariant, portal: tooltipPortal, association: "aria-labelledby", hideElementOnHidden: true }, label))));
1684
1678
  });
1685
1679
  IconButton.propTypes = {
@@ -1687,7 +1681,7 @@ IconButton.propTypes = {
1687
1681
  as: PropTypes.elementType,
1688
1682
  // @ts-expect-error
1689
1683
  icon: PropTypes.string.isRequired,
1690
- label: PropTypes.string.isRequired,
1684
+ label: PropTypes.node.isRequired,
1691
1685
  // @ts-expect-error
1692
1686
  tooltipPlacement: PropTypes.string,
1693
1687
  // @ts-expect-error
@@ -2362,7 +2356,7 @@ var RadioGroup = function (_a) {
2362
2356
  var _a;
2363
2357
  handleChange(radioValue);
2364
2358
  onChange(radio, (_a = inputs.current) === null || _a === void 0 ? void 0 : _a[index]);
2365
- }, disabled: disabled, checked: isChecked, "aria-describedby": labelDescription && id + "Desc" }, other)),
2359
+ }, disabled: disabled, checked: isChecked, "aria-describedby": labelDescription ? id + "Desc" : undefined }, other)),
2366
2360
  React__default.createElement("label", { htmlFor: id, className: classNames('Field__label', {
2367
2361
  'Field__label--disabled': disabled
2368
2362
  }) }, label),
@@ -8027,7 +8021,7 @@ function useSharedRef(ref) {
8027
8021
  }
8028
8022
 
8029
8023
  var LoaderOverlay = React.forwardRef(function (_a, ref) {
8030
- var className = _a.className, variant = _a.variant, label = _a.label, children = _a.children, focusOnInitialRender = _a.focusOnInitialRender, other = tslib.__rest(_a, ["className", "variant", "label", "children", "focusOnInitialRender"]);
8024
+ var className = _a.className, variant = _a.variant, label = _a.label, children = _a.children, focusOnInitialRender = _a.focusOnInitialRender, _b = _a.focusTrap, focusTrap = _b === void 0 ? false : _b, other = tslib.__rest(_a, ["className", "variant", "label", "children", "focusOnInitialRender", "focusTrap"]);
8031
8025
  var overlayRef = useSharedRef(ref);
8032
8026
  React.useEffect(function () {
8033
8027
  if (!!focusOnInitialRender && overlayRef.current) {
@@ -8038,16 +8032,25 @@ var LoaderOverlay = React.forwardRef(function (_a, ref) {
8038
8032
  }
8039
8033
  return;
8040
8034
  }, [overlayRef.current]);
8041
- return (React__default.createElement("div", tslib.__assign({ className: classNames('Loader__overlay', className, variant === 'large'
8042
- ? 'Loader__overlay--large'
8043
- : variant === 'small'
8044
- ? 'Loader__overlay--small'
8045
- : ''), ref: overlayRef, tabIndex: -1 }, other),
8046
- React__default.createElement("div", { className: "Loader__overlay__loader" },
8047
- React__default.createElement(Loader, { variant: variant }),
8048
- React__default.createElement(AxeLoader, null)),
8049
- label ? React__default.createElement("span", { className: "Loader__overlay__label" }, label) : null,
8050
- children));
8035
+ var Wrapper = focusTrap ? FocusTrap : React__default.Fragment;
8036
+ var wrapperProps = focusTrap
8037
+ ? {
8038
+ focusTrapOptions: {
8039
+ fallbackFocus: '.Loader__overlay'
8040
+ }
8041
+ }
8042
+ : {};
8043
+ return (React__default.createElement(Wrapper, tslib.__assign({}, wrapperProps),
8044
+ React__default.createElement("div", tslib.__assign({ className: classNames('Loader__overlay', className, variant === 'large'
8045
+ ? 'Loader__overlay--large'
8046
+ : variant === 'small'
8047
+ ? 'Loader__overlay--small'
8048
+ : ''), ref: overlayRef, tabIndex: -1 }, other),
8049
+ React__default.createElement("div", { className: "Loader__overlay__loader" },
8050
+ React__default.createElement(Loader, { variant: variant }),
8051
+ React__default.createElement(AxeLoader, null)),
8052
+ label ? (React__default.createElement("span", { className: "Loader__overlay__label" }, label)) : null,
8053
+ children)));
8051
8054
  });
8052
8055
  LoaderOverlay.propTypes = {
8053
8056
  className: PropTypes.string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "4.3.0-canary.9d2b7bb9",
3
+ "version": "4.3.0-canary.9df9e64f",
4
4
  "description": "Fully accessible react components library for Deque Cauldron",
5
5
  "publishConfig": {
6
6
  "access": "public"