@deque/cauldron-react 3.0.1-canary.41ff0487 → 3.0.1-canary.43fb6953

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,12 +1,11 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  export interface LoaderProps extends React.HTMLAttributes<HTMLDivElement> {
4
- label: string;
4
+ label?: string;
5
5
  }
6
- declare function Loader({ label, className, ...other }: LoaderProps): JSX.Element;
6
+ declare function Loader({ className, label, ...other }: LoaderProps): JSX.Element;
7
7
  declare namespace Loader {
8
8
  var propTypes: {
9
- label: PropTypes.Requireable<string>;
10
9
  className: PropTypes.Requireable<string>;
11
10
  };
12
11
  var displayName: string;
@@ -5,6 +5,7 @@ export interface SideBarProps extends React.HTMLAttributes<HTMLUListElement> {
5
5
  onDismiss: () => void;
6
6
  className?: string;
7
7
  show: boolean;
8
+ navProps: React.HTMLAttributes<HTMLElement>;
8
9
  }
9
10
  interface SideBarState {
10
11
  wide: boolean;
@@ -6,9 +6,13 @@ declare type TabsProps = {
6
6
  initialActiveIndex?: number;
7
7
  thin?: boolean;
8
8
  className?: string;
9
+ onChange?: ({ activeTabIndex, target }: {
10
+ activeTabIndex: number;
11
+ target: HTMLLIElement | null;
12
+ }) => void;
9
13
  } & Cauldron.LabelProps;
10
14
  declare const Tabs: {
11
- ({ children, thin, initialActiveIndex, className, ...labelProp }: TabsProps): JSX.Element;
15
+ ({ children, thin, initialActiveIndex, className, onChange, ...labelProp }: TabsProps): JSX.Element;
12
16
  displayName: string;
13
17
  propTypes: {
14
18
  children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
package/lib/index.js CHANGED
@@ -1150,11 +1150,11 @@ var SideBar = /** @class */ (function (_super) {
1150
1150
  var _a = this.state, animateClass = _a.animateClass, wide = _a.wide;
1151
1151
  // disabling no-unused-vars to prevent onDismiss from being passed through to dom element
1152
1152
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1153
- var _b = this.props, children = _b.children, className = _b.className, show = _b.show, onDismiss = _b.onDismiss, other = tslib.__rest(_b, ["children", "className", "show", "onDismiss"]);
1153
+ var _b = this.props, children = _b.children, className = _b.className, show = _b.show, onDismiss = _b.onDismiss, navProps = _b.navProps, other = tslib.__rest(_b, ["children", "className", "show", "onDismiss", "navProps"]);
1154
1154
  /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
1155
1155
  return (React__default.createElement(React.Fragment, null,
1156
1156
  React__default.createElement(ClickOutsideListener, { onClickOutside: this.handleClickOutside },
1157
- React__default.createElement("nav", null,
1157
+ React__default.createElement("nav", tslib.__assign({}, navProps),
1158
1158
  React__default.createElement("ul", tslib.__assign({ className: classNames('SideBar', className, animateClass) }, other, { ref: this.navList, onKeyDown: this.onKeyDown }), children))),
1159
1159
  React__default.createElement(Scrim, { show: !wide && show })));
1160
1160
  /* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
@@ -1643,6 +1643,13 @@ var IconButton = React.forwardRef(function (_a, ref) {
1643
1643
  accessibilityProps['aria-disabled'] = disabled;
1644
1644
  }
1645
1645
  }
1646
+ React.useEffect(function () {
1647
+ var _a;
1648
+ if (!disabled) {
1649
+ return;
1650
+ }
1651
+ (_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-label', label);
1652
+ }, [disabled]);
1646
1653
  return (React__default.createElement(React__default.Fragment, null,
1647
1654
  React__default.createElement(Component, tslib.__assign({ className: classNames(className, {
1648
1655
  IconButton: true,
@@ -2186,22 +2193,18 @@ Link.propTypes = {
2186
2193
  Link.displayName = 'Link';
2187
2194
 
2188
2195
  function Loader(_a) {
2189
- var label = _a.label, className = _a.className, other = tslib.__rest(_a, ["label", "className"]);
2190
- var props = tslib.__assign(tslib.__assign({}, other), { className: classNames('Loader', className), 'aria-hidden': !label });
2191
- if (label) {
2192
- props.role = 'progressbar';
2193
- props['aria-valuetext'] = label;
2194
- props['aria-busy'] = true;
2195
- props['aria-valuemin'] = 0;
2196
- props['aria-valuemax'] = 100;
2197
- // According to the ARIA 1.2 spec (https://www.w3.org/TR/wai-aria-1.2/#progressbar),
2198
- // the aria-valuenow attribute SHOULD be omitted because the "value" of our progress
2199
- // is "indeterminate".
2196
+ var className = _a.className, label = _a.label, other = tslib.__rest(_a, ["className", "label"]);
2197
+ var props = tslib.__assign(tslib.__assign({}, other), { className: classNames('Loader', className) });
2198
+ if (label === null || label === void 0 ? void 0 : label.length) {
2199
+ props['role'] = 'alert';
2200
+ props.children = React__default.createElement(Offscreen, null, label);
2201
+ }
2202
+ else {
2203
+ props['aria-hidden'] = true;
2200
2204
  }
2201
2205
  return React__default.createElement("div", tslib.__assign({}, props));
2202
2206
  }
2203
2207
  Loader.propTypes = {
2204
- label: PropTypes.string,
2205
2208
  className: PropTypes.string
2206
2209
  };
2207
2210
  Loader.displayName = 'Loader';
@@ -8048,8 +8051,9 @@ Tab.propTypes = {
8048
8051
  };
8049
8052
 
8050
8053
  var Tabs = function (_a) {
8051
- var children = _a.children, thin = _a.thin, _b = _a.initialActiveIndex, initialActiveIndex = _b === void 0 ? 0 : _b, className = _a.className, labelProp = tslib.__rest(_a, ["children", "thin", "initialActiveIndex", "className"]);
8054
+ var children = _a.children, thin = _a.thin, _b = _a.initialActiveIndex, initialActiveIndex = _b === void 0 ? 0 : _b, className = _a.className, onChange = _a.onChange, labelProp = tslib.__rest(_a, ["children", "thin", "initialActiveIndex", "className", "onChange"]);
8052
8055
  var _c = React.useState(initialActiveIndex), activeIndex = _c[0], setActiveIndex = _c[1];
8056
+ var tabsRef = React.useRef(null);
8053
8057
  var focusedTabRef = React.useRef(null);
8054
8058
  var tabs = React__default.Children.toArray(children).filter(function (child) { return child.type === Tab; });
8055
8059
  var tabCount = tabs.length;
@@ -8114,10 +8118,13 @@ var Tabs = function (_a) {
8114
8118
  useDidUpdate(function () {
8115
8119
  var _a;
8116
8120
  (_a = focusedTabRef.current) === null || _a === void 0 ? void 0 : _a.focus();
8121
+ if (typeof onChange === 'function') {
8122
+ onChange({ activeTabIndex: activeIndex, target: focusedTabRef.current });
8123
+ }
8117
8124
  }, [activeIndex]);
8118
8125
  return (React__default.createElement("div", { className: classNames('Tabs', className, {
8119
8126
  'Tabs--thin': thin
8120
- }) },
8127
+ }), ref: tabsRef },
8121
8128
  React__default.createElement("ul", tslib.__assign({ role: "tablist", className: "Tablist" }, labelProp, { onKeyDown: handleKeyDown }), tabComponents)));
8122
8129
  };
8123
8130
  Tabs.displayName = 'Tabs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "3.0.1-canary.41ff0487",
3
+ "version": "3.0.1-canary.43fb6953",
4
4
  "description": "Fully accessible react components library for Deque Cauldron",
5
5
  "publishConfig": {
6
6
  "access": "public"