@deque/cauldron-react 4.7.0-canary.b07c7ee0 → 4.7.0-canary.be438adc

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.
@@ -8,6 +8,7 @@ export interface ClickOutsideListenerProps<T extends HTMLElement = HTMLElement>
8
8
  target?: T;
9
9
  }
10
10
  export default class ClickOutsideListener extends React.Component<ClickOutsideListenerProps> {
11
+ static displayName: string;
11
12
  static defaultProps: {
12
13
  mouseEvent: string;
13
14
  touchEvent: string;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- interface LoaderOverlayProps extends React.HTMLAttributes<HTMLDivElement> {
2
+ export interface LoaderOverlayProps extends React.HTMLAttributes<HTMLDivElement> {
3
3
  variant?: 'large' | 'small';
4
4
  label?: string;
5
5
  focusOnInitialRender?: boolean;
@@ -5,7 +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
+ navProps?: React.HTMLAttributes<HTMLElement>;
9
9
  }
10
10
  interface SideBarState {
11
11
  wide: boolean;
@@ -8,6 +8,7 @@ export interface ToastProps {
8
8
  toastRef: React.Ref<HTMLDivElement>;
9
9
  focus?: boolean;
10
10
  show?: boolean;
11
+ dismissible?: boolean;
11
12
  children: React.ReactNode;
12
13
  }
13
14
  interface ToastState {
@@ -24,6 +25,7 @@ export default class Toast extends React.Component<ToastProps, ToastState> {
24
25
  toastRef: () => void;
25
26
  focus: boolean;
26
27
  show: boolean;
28
+ dismissible: boolean;
27
29
  };
28
30
  static propTypes: {
29
31
  children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
@@ -35,6 +37,7 @@ export default class Toast extends React.Component<ToastProps, ToastState> {
35
37
  }>>;
36
38
  focus: PropTypes.Requireable<boolean>;
37
39
  show: PropTypes.Requireable<boolean>;
40
+ dismissible: PropTypes.Requireable<boolean>;
38
41
  };
39
42
  static displayName: string;
40
43
  private el;
package/lib/index.js CHANGED
@@ -305,7 +305,7 @@ var Icon = React.forwardRef(function (_a, ref) {
305
305
  var data = tslib.__assign(tslib.__assign({}, other), { 'aria-hidden': !label, className: classNames('Icon', "Icon--".concat(type), className, (_b = {},
306
306
  _b["Icon__".concat(direction)] = !!direction,
307
307
  _b)) });
308
- return (React__default.createElement("div", tslib.__assign({ ref: ref }, data),
308
+ return (React__default.createElement("span", tslib.__assign({ ref: ref }, data),
309
309
  label && React__default.createElement(Offscreen, null, label),
310
310
  IconSVG && React__default.createElement(IconSVG, null)));
311
311
  });
@@ -899,6 +899,7 @@ var ClickOutsideListener = /** @class */ (function (_super) {
899
899
  ref: resolveRef
900
900
  });
901
901
  };
902
+ ClickOutsideListener.displayName = 'ClickOutsideListener';
902
903
  ClickOutsideListener.defaultProps = {
903
904
  mouseEvent: 'click',
904
905
  touchEvent: 'touchend'
@@ -1560,8 +1561,10 @@ var Dialog = /** @class */ (function (_super) {
1560
1561
  };
1561
1562
  Dialog.prototype.close = function () {
1562
1563
  var _a, _b, _c;
1563
- (_a = this.state.isolator) === null || _a === void 0 ? void 0 : _a.deactivate();
1564
- (_c = (_b = this.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
1564
+ if (this.props.show) {
1565
+ (_a = this.state.isolator) === null || _a === void 0 ? void 0 : _a.deactivate();
1566
+ (_c = (_b = this.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
1567
+ }
1565
1568
  };
1566
1569
  Dialog.prototype.handleClickOutside = function () {
1567
1570
  var _a = this.props, show = _a.show, forceAction = _a.forceAction;
@@ -2339,7 +2342,7 @@ var Toast = /** @class */ (function (_super) {
2339
2342
  var _a = this.props, type = _a.type, children = _a.children,
2340
2343
  // prevent `onDismiss` from being passed-through to DOM
2341
2344
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2342
- onDismiss = _a.onDismiss, dismissText = _a.dismissText, toastRef = _a.toastRef, focus = _a.focus, show = _a.show, otherProps = tslib.__rest(_a, ["type", "children", "onDismiss", "dismissText", "toastRef", "focus", "show"]);
2345
+ onDismiss = _a.onDismiss, dismissText = _a.dismissText, toastRef = _a.toastRef, focus = _a.focus, show = _a.show, dismissible = _a.dismissible, otherProps = tslib.__rest(_a, ["type", "children", "onDismiss", "dismissText", "toastRef", "focus", "show", "dismissible"]);
2343
2346
  var scrim = type === 'action-needed' && show ? (React__default.createElement("div", { className: "Scrim--light Scrim--show Scrim--fade-in" })) : null;
2344
2347
  var defaultProps = {
2345
2348
  tabIndex: -1,
@@ -2356,7 +2359,7 @@ var Toast = /** @class */ (function (_super) {
2356
2359
  React__default.createElement("div", { className: "Toast__message" },
2357
2360
  React__default.createElement(Icon, { type: typeMap[type].icon }),
2358
2361
  React__default.createElement("div", { className: "Toast__message-content" }, children)),
2359
- type !== 'action-needed' && (React__default.createElement("button", { type: "button", className: 'Toast__dismiss', "aria-label": dismissText, onClick: this.dismissToast },
2362
+ type !== 'action-needed' && dismissible && (React__default.createElement("button", { type: "button", className: 'Toast__dismiss', "aria-label": dismissText, onClick: this.dismissToast },
2360
2363
  React__default.createElement(Icon, { type: "close" })))),
2361
2364
  scrim));
2362
2365
  };
@@ -2407,7 +2410,8 @@ var Toast = /** @class */ (function (_super) {
2407
2410
  // eslint-disable-next-line @typescript-eslint/no-empty-function
2408
2411
  toastRef: function () { },
2409
2412
  focus: true,
2410
- show: false
2413
+ show: false,
2414
+ dismissible: true
2411
2415
  };
2412
2416
  Toast.propTypes = {
2413
2417
  // the ui to be added as the message of the toast
@@ -2426,7 +2430,9 @@ var Toast = /** @class */ (function (_super) {
2426
2430
  // whether or not to focus the toast
2427
2431
  focus: PropTypes.bool,
2428
2432
  // whether or not to show the toast
2429
- show: PropTypes.bool
2433
+ show: PropTypes.bool,
2434
+ // whether or not the toast is dismissible
2435
+ dismissible: PropTypes.bool
2430
2436
  };
2431
2437
  Toast.displayName = 'Toast';
2432
2438
  return Toast;
@@ -8365,7 +8371,6 @@ var Tabs = function (_a) {
8365
8371
  var children = _a.children, thin = _a.thin, _b = _a.orientation, orientation = _b === void 0 ? 'horizontal' : _b, _c = _a.initialActiveIndex, initialActiveIndex = _c === void 0 ? 0 : _c, className = _a.className, onChange = _a.onChange, labelProp = tslib.__rest(_a, ["children", "thin", "orientation", "initialActiveIndex", "className", "onChange"]);
8366
8372
  var _d = tslib.__read(React.useState(initialActiveIndex), 2), activeIndex = _d[0], setActiveIndex = _d[1];
8367
8373
  var tabsRef = React.useRef(null);
8368
- var focusedTabRef = React.useRef(null);
8369
8374
  var tabs = React__default.Children.toArray(children).filter(function (child) { return child.type === Tab; });
8370
8375
  var tabCount = tabs.length;
8371
8376
  var handleClick = function (index) {
@@ -8438,14 +8443,15 @@ var Tabs = function (_a) {
8438
8443
  }, [activeIndex]);
8439
8444
  var config = tslib.__assign((_a = { id: id, className: classNames('Tab', {
8440
8445
  'Tab--active': selected
8441
- }), tabIndex: index === activeIndex ? 0 : -1 }, _a['aria-controls'] = (_b = target.current) === null || _b === void 0 ? void 0 : _b.id, _a['aria-selected'] = selected, _a.ref = index === activeIndex ? focusedTabRef : null, _a.onClick = function () { return handleClick(index); }, _a), other);
8446
+ }), tabIndex: index === activeIndex ? 0 : -1 }, _a['aria-controls'] = (_b = target.current) === null || _b === void 0 ? void 0 : _b.id, _a['aria-selected'] = selected, _a.onClick = function () { return handleClick(index); }, _a), other);
8442
8447
  return React__default.cloneElement(child, config);
8443
8448
  });
8444
8449
  useDidUpdate(function () {
8445
8450
  var _a;
8446
- (_a = focusedTabRef.current) === null || _a === void 0 ? void 0 : _a.focus();
8451
+ var activeTab = (_a = tabsRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(':scope > [role="tablist"] > [aria-selected="true"]');
8452
+ activeTab === null || activeTab === void 0 ? void 0 : activeTab.focus();
8447
8453
  if (typeof onChange === 'function') {
8448
- onChange({ activeTabIndex: activeIndex, target: focusedTabRef.current });
8454
+ onChange({ activeTabIndex: activeIndex, target: activeTab });
8449
8455
  }
8450
8456
  }, [activeIndex]);
8451
8457
  return (React__default.createElement("div", { className: classNames('Tabs', className, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "4.7.0-canary.b07c7ee0",
3
+ "version": "4.7.0-canary.be438adc",
4
4
  "description": "Fully accessible react components library for Deque Cauldron",
5
5
  "publishConfig": {
6
6
  "access": "public"