@deque/cauldron-react 4.1.0-canary.e368ef0b → 4.1.0-canary.e3763bf9

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
@@ -34,7 +34,8 @@
34
34
  --expandcollapse-panel-color: var(--accent-light);
35
35
  }
36
36
 
37
- a.Button--primary {
37
+ a.Button--primary,
38
+ a.Button--secondary {
38
39
  text-decoration: none;
39
40
  padding: 9px 18px;
40
41
  }
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- export interface ClickOutsideListenerProps {
4
- children: React.ReactNode;
3
+ export interface ClickOutsideListenerProps<T extends HTMLElement = HTMLElement> {
4
+ children?: React.ReactNode;
5
5
  onClickOutside: (e: MouseEvent | TouchEvent) => void;
6
6
  mouseEvent?: 'mousedown' | 'click' | 'mouseup' | false;
7
7
  touchEvent?: 'touchstart' | 'touchend' | false;
8
+ target?: T;
8
9
  }
9
10
  export default class ClickOutsideListener extends React.Component<ClickOutsideListenerProps> {
10
11
  static defaultProps: {
@@ -12,7 +13,8 @@ export default class ClickOutsideListener extends React.Component<ClickOutsideLi
12
13
  touchEvent: string;
13
14
  };
14
15
  static propTypes: {
15
- children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
16
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
+ target: PropTypes.Requireable<any>;
16
18
  onClickOutside: PropTypes.Validator<(...args: any[]) => any>;
17
19
  mouseEvent: PropTypes.Requireable<string | boolean>;
18
20
  touchEvent: PropTypes.Requireable<string | boolean>;
@@ -27,5 +29,5 @@ export default class ClickOutsideListener extends React.Component<ClickOutsideLi
27
29
  resolveRef: (node: HTMLElement) => void;
28
30
  render(): React.FunctionComponentElement<{
29
31
  ref: (node: HTMLElement) => void;
30
- }>;
32
+ }> | null;
31
33
  }
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  export interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
4
4
  linkRef?: React.Ref<HTMLAnchorElement>;
5
- variant?: 'button';
5
+ variant?: 'button' | 'button-secondary';
6
6
  }
7
7
  declare const Link: {
8
8
  ({ children, linkRef, className, variant, ...other }: LinkProps): JSX.Element;
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  interface LoaderOverlayProps extends React.HTMLAttributes<HTMLDivElement> {
3
3
  variant?: 'large' | 'small';
4
4
  label?: string;
5
+ focusOnInitialRender?: boolean;
6
+ children?: React.ReactNode;
5
7
  }
6
8
  declare const LoaderOverlay: React.ForwardRefExoticComponent<LoaderOverlayProps & React.RefAttributes<HTMLDivElement>>;
7
9
  export default LoaderOverlay;
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- interface BaseStepProps {
3
+ interface BaseStepProps extends React.LiHTMLAttributes<HTMLLIElement> {
4
4
  status: 'current' | 'complete' | 'future';
5
- className?: string;
6
5
  }
7
6
  interface StepWithChildren extends BaseStepProps {
8
7
  children: React.ReactNode;
@@ -11,7 +11,7 @@ export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {
11
11
  portal?: React.RefObject<HTMLElement> | HTMLElement;
12
12
  hideElementOnHidden?: boolean;
13
13
  }
14
- declare function Tooltip({ id: propId, placement: initialPlacement, children, portal, target, association, variant, show: showProp, hideElementOnHidden, className, ...props }: TooltipProps): React.ReactPortal | null;
14
+ declare function Tooltip({ id: propId, placement: initialPlacement, children, portal, target, association, variant, show: initialShow, hideElementOnHidden, className, ...props }: TooltipProps): React.ReactPortal | null;
15
15
  declare namespace Tooltip {
16
16
  var displayName: string;
17
17
  var propTypes: {
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface ColumnGroupHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ }
4
+ declare const ColumnGroupHeader: React.ForwardRefExoticComponent<ColumnGroupHeaderProps & React.RefAttributes<HTMLDivElement>>;
5
+ export default ColumnGroupHeader;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface ColumnHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ }
4
+ declare const ColumnHeader: React.ForwardRefExoticComponent<ColumnHeaderProps & React.RefAttributes<HTMLDivElement>>;
5
+ export default ColumnHeader;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ declare const ColumnLeft: React.ForwardRefExoticComponent<(React.HTMLAttributes<HTMLDivElement> & {
3
+ 'aria-label': string;
4
+ } & React.RefAttributes<HTMLDivElement>) | (React.HTMLAttributes<HTMLDivElement> & {
5
+ 'aria-labelledby': string;
6
+ } & React.RefAttributes<HTMLDivElement>)>;
7
+ export default ColumnLeft;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface ColumnListProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ }
4
+ declare const ColumnList: React.ForwardRefExoticComponent<ColumnListProps & React.RefAttributes<HTMLDivElement>>;
5
+ export default ColumnList;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ declare const ColumnRight: React.ForwardRefExoticComponent<(React.HTMLAttributes<HTMLDivElement> & {
3
+ 'aria-label': string;
4
+ } & React.RefAttributes<HTMLDivElement>) | (React.HTMLAttributes<HTMLDivElement> & {
5
+ 'aria-labelledby': string;
6
+ } & React.RefAttributes<HTMLDivElement>)>;
7
+ export default ColumnRight;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface TwoColumnPanelProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ initialCollapsed?: boolean;
4
+ showCollapsedPanelLabel?: string;
5
+ hideCollapsedPanelLabel?: string;
6
+ }
7
+ declare const TwoColumnPanel: React.ForwardRefExoticComponent<TwoColumnPanelProps & React.RefAttributes<HTMLDivElement>>;
8
+ export default TwoColumnPanel;
@@ -0,0 +1,6 @@
1
+ export { default } from './TwoColumnPanel';
2
+ export { default as ColumnHeader } from './ColumnHeader';
3
+ export { default as ColumnGroupHeader } from './ColumnGroupHeader';
4
+ export { default as ColumnLeft } from './ColumnLeft';
5
+ export { default as ColumnRight } from './ColumnRight';
6
+ export { default as ColumnList } from './ColumnList';
package/lib/index.d.ts CHANGED
@@ -48,6 +48,7 @@ export { Address, AddressLine, AddressCityStateZip } from './components/Address'
48
48
  export { default as Pagination } from './components/Pagination';
49
49
  export { default as FieldWrap } from './components/FieldWrap';
50
50
  export { default as Breadcrumb, BreadcrumbItem, BreadcrumbLink } from './components/Breadcrumb';
51
+ export { default as TwoColumnPanel, ColumnHeader, ColumnGroupHeader, ColumnLeft, ColumnRight, ColumnList } from './components/TwoColumnPanel';
51
52
  /**
52
53
  * Helpers / Utils
53
54
  */
package/lib/index.js CHANGED
@@ -608,12 +608,13 @@ var ClickOutsideListener = /** @class */ (function (_super) {
608
608
  var _this = _super !== null && _super.apply(this, arguments) || this;
609
609
  _this.handleEvent = function (event) {
610
610
  var _a = _this, nodeRef = _a.nodeRef, props = _a.props;
611
- var onClickOutside = props.onClickOutside;
611
+ var onClickOutside = props.onClickOutside, target = props.target;
612
612
  if (event.defaultPrevented) {
613
613
  return;
614
614
  }
615
- var target = event.target;
616
- if (nodeRef && !nodeRef.contains(target)) {
615
+ var eventTarget = event.target;
616
+ if ((target && !target.contains(eventTarget)) ||
617
+ (nodeRef && !nodeRef.contains(eventTarget))) {
617
618
  onClickOutside(event);
618
619
  }
619
620
  };
@@ -656,16 +657,19 @@ var ClickOutsideListener = /** @class */ (function (_super) {
656
657
  };
657
658
  ClickOutsideListener.prototype.render = function () {
658
659
  var _a = this, props = _a.props, resolveRef = _a.resolveRef;
659
- return React__default.cloneElement(props.children, {
660
- ref: resolveRef
661
- });
660
+ return !props.children
661
+ ? null
662
+ : React__default.cloneElement(props.children, {
663
+ ref: resolveRef
664
+ });
662
665
  };
663
666
  ClickOutsideListener.defaultProps = {
664
667
  mouseEvent: 'click',
665
668
  touchEvent: 'touchend'
666
669
  };
667
670
  ClickOutsideListener.propTypes = {
668
- children: PropTypes.node.isRequired,
671
+ children: PropTypes.node,
672
+ target: PropTypes.any,
669
673
  onClickOutside: PropTypes.func.isRequired,
670
674
  mouseEvent: PropTypes.oneOf(['mousedown', 'click', 'mouseup', false]),
671
675
  touchEvent: PropTypes.oneOf(['touchstart', 'touchend', false])
@@ -1475,15 +1479,14 @@ var fireCustomEvent = function (show, button) {
1475
1479
  };
1476
1480
  function Tooltip(_a) {
1477
1481
  var _this = this;
1478
- 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, showProp = _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"]);
1482
+ 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"]);
1479
1483
  var _g = tslib.__read(propId ? [propId] : nextId.useId(1, 'tooltip'), 1), id = _g[0];
1480
- var hovering = React.useRef(false);
1481
- var _h = tslib.__read(React.useState(initialPlacement), 2), placement = _h[0], setPlacement = _h[1];
1482
- var _j = tslib.__read(React.useState(!!showProp), 2), showTooltip = _j[0], setShowTooltip = _j[1];
1483
- var _k = tslib.__read(React.useState(null), 2), targetElement = _k[0], setTargetElement = _k[1];
1484
- var _l = tslib.__read(React.useState(null), 2), tooltipElement = _l[0], setTooltipElement = _l[1];
1485
- var _m = tslib.__read(React.useState(null), 2), arrowElement = _m[0], setArrowElement = _m[1];
1486
- var _o = reactPopper.usePopper(targetElement, tooltipElement, {
1484
+ var hideTimeoutRef = React.useRef(null);
1485
+ var _h = tslib.__read(React.useState(!!initialShow), 2), showTooltip = _h[0], setShowTooltip = _h[1];
1486
+ var _j = tslib.__read(React.useState(null), 2), targetElement = _j[0], setTargetElement = _j[1];
1487
+ var _k = tslib.__read(React.useState(null), 2), tooltipElement = _k[0], setTooltipElement = _k[1];
1488
+ var _l = tslib.__read(React.useState(null), 2), arrowElement = _l[0], setArrowElement = _l[1];
1489
+ var _m = reactPopper.usePopper(targetElement, tooltipElement, {
1487
1490
  placement: initialPlacement,
1488
1491
  modifiers: [
1489
1492
  { name: 'preventOverflow', options: { padding: 8 } },
@@ -1491,11 +1494,17 @@ function Tooltip(_a) {
1491
1494
  { name: 'offset', options: { offset: [0, 8] } },
1492
1495
  { name: 'arrow', options: { padding: 5, element: arrowElement } }
1493
1496
  ]
1494
- }), styles = _o.styles, attributes = _o.attributes, update = _o.update;
1495
- var show = function () { return tslib.__awaiter(_this, void 0, void 0, function () {
1497
+ }), styles = _m.styles, attributes = _m.attributes, update = _m.update;
1498
+ // Show the tooltip
1499
+ var show = React.useCallback(function () { return tslib.__awaiter(_this, void 0, void 0, function () {
1496
1500
  return tslib.__generator(this, function (_a) {
1497
1501
  switch (_a.label) {
1498
1502
  case 0:
1503
+ // Clear the hide timeout if there was one pending
1504
+ if (hideTimeoutRef.current) {
1505
+ clearTimeout(hideTimeoutRef.current);
1506
+ hideTimeoutRef.current = null;
1507
+ }
1499
1508
  if (!update) return [3 /*break*/, 2];
1500
1509
  return [4 /*yield*/, update()];
1501
1510
  case 1:
@@ -1507,45 +1516,31 @@ function Tooltip(_a) {
1507
1516
  return [2 /*return*/];
1508
1517
  }
1509
1518
  });
1510
- }); };
1511
- var hide = function (_a) {
1512
- var target = _a.target;
1513
- if (document.activeElement !== target) {
1514
- setTimeout(function () {
1515
- if (!hovering.current) {
1516
- setShowTooltip(false);
1517
- fireCustomEvent(false, targetElement);
1518
- }
1519
+ }); }, [
1520
+ targetElement,
1521
+ // update starts off as null
1522
+ update
1523
+ ]);
1524
+ // Hide the tooltip
1525
+ var hide = React.useCallback(function () {
1526
+ if (!hideTimeoutRef.current) {
1527
+ hideTimeoutRef.current = setTimeout(function () {
1528
+ hideTimeoutRef.current = null;
1529
+ setShowTooltip(false);
1530
+ fireCustomEvent(false, targetElement);
1519
1531
  }, TIP_HIDE_DELAY);
1520
1532
  }
1521
- };
1522
- var handleTriggerMouseEnter = function () {
1523
- hovering.current = true;
1524
- show();
1525
- };
1526
- var handleTriggerMouseLeave = function (e) {
1527
- hovering.current = false;
1528
- hide(e);
1529
- };
1530
- var handleTipMouseEnter = function () {
1531
- hovering.current = true;
1532
- };
1533
- var handleTipMouseLeave = function (e) {
1534
- hovering.current = false;
1535
- hide(e);
1536
- };
1533
+ }, [targetElement]);
1534
+ // Keep targetElement in sync with target prop
1537
1535
  React.useEffect(function () {
1538
1536
  var targetElement = target && 'current' in target ? target.current : target;
1539
1537
  setTargetElement(targetElement);
1540
1538
  }, [target]);
1541
- var popperPlacement = (attributes.popper &&
1539
+ // Get popper placement
1540
+ var placement = (attributes.popper &&
1542
1541
  attributes.popper['data-popper-placement']) ||
1543
1542
  initialPlacement;
1544
- React.useEffect(function () {
1545
- if (popperPlacement) {
1546
- setPlacement(popperPlacement);
1547
- }
1548
- }, [popperPlacement]);
1543
+ // Only listen to key ups when the tooltip is visible
1549
1544
  React.useEffect(function () {
1550
1545
  var handleEscape = function (event) {
1551
1546
  if (event.key === 'Escape' ||
@@ -1564,31 +1559,30 @@ function Tooltip(_a) {
1564
1559
  return function () {
1565
1560
  targetElement.removeEventListener('keyup', handleEscape);
1566
1561
  };
1567
- }, [showProp]);
1562
+ }, [showTooltip]);
1563
+ // Handle hover and focus events for the targetElement
1568
1564
  React.useEffect(function () {
1569
- if (typeof showProp !== undefined) {
1570
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('mouseenter', handleTriggerMouseEnter);
1571
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('mouseleave', handleTriggerMouseLeave);
1572
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('focusin', show);
1573
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('focusout', hide);
1574
- }
1565
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('mouseenter', show);
1566
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('mouseleave', hide);
1567
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('focusin', show);
1568
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener('focusout', hide);
1575
1569
  return function () {
1576
1570
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('mouseenter', show);
1577
1571
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('mouseleave', hide);
1578
1572
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('focusin', show);
1579
1573
  targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener('focusout', hide);
1580
1574
  };
1581
- }, [targetElement, showProp]);
1575
+ }, [targetElement, show, hide]);
1576
+ // Handle hover events for the tooltipElement
1582
1577
  React.useEffect(function () {
1583
- if (tooltipElement) {
1584
- tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.addEventListener('mouseenter', handleTipMouseEnter);
1585
- tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.addEventListener('mouseleave', handleTipMouseLeave);
1586
- }
1578
+ tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.addEventListener('mouseenter', show);
1579
+ tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.addEventListener('mouseleave', hide);
1587
1580
  return function () {
1588
- tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.removeEventListener('mouseenter', handleTipMouseEnter);
1589
- tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.removeEventListener('mouseleave', handleTipMouseLeave);
1581
+ tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.removeEventListener('mouseenter', show);
1582
+ tooltipElement === null || tooltipElement === void 0 ? void 0 : tooltipElement.removeEventListener('mouseleave', hide);
1590
1583
  };
1591
- }, [tooltipElement]);
1584
+ }, [tooltipElement, show, hide]);
1585
+ // Keep the target's id in sync
1592
1586
  React.useEffect(function () {
1593
1587
  var attrText = targetElement === null || targetElement === void 0 ? void 0 : targetElement.getAttribute(association);
1594
1588
  if (!(attrText === null || attrText === void 0 ? void 0 : attrText.includes(id || ''))) {
@@ -2022,7 +2016,7 @@ var queryAll = function (selector, context) {
2022
2016
  var typeMap = {
2023
2017
  confirmation: {
2024
2018
  className: 'success',
2025
- icon: 'info-circle'
2019
+ icon: 'check-circle'
2026
2020
  },
2027
2021
  caution: {
2028
2022
  className: 'warning',
@@ -2196,7 +2190,8 @@ var Link = function (_a) {
2196
2190
  var children = _a.children, linkRef = _a.linkRef, className = _a.className, variant = _a.variant, other = tslib.__rest(_a, ["children", "linkRef", "className", "variant"]);
2197
2191
  return (React__default.createElement("a", tslib.__assign({ ref: linkRef, className: classNames(className, {
2198
2192
  Link: !variant,
2199
- 'Button--primary': variant === 'button'
2193
+ 'Button--primary': variant === 'button',
2194
+ 'Button--secondary': variant === 'button-secondary'
2200
2195
  }) }, other), children));
2201
2196
  };
2202
2197
  Link.propTypes = {
@@ -7984,22 +7979,39 @@ function AxeLoader() {
7984
7979
  }
7985
7980
 
7986
7981
  var LoaderOverlay = React__default.forwardRef(function (_a, ref) {
7987
- var className = _a.className, variant = _a.variant, label = _a.label, other = tslib.__rest(_a, ["className", "variant", "label"]);
7982
+ 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"]);
7983
+ var overlayRef = typeof ref === 'function' || !ref ? React.createRef() : ref;
7984
+ React.useEffect(function () {
7985
+ if (!!focusOnInitialRender && overlayRef.current) {
7986
+ setTimeout(function () {
7987
+ var _a;
7988
+ return (_a = overlayRef.current) === null || _a === void 0 ? void 0 : _a.focus();
7989
+ });
7990
+ }
7991
+ return;
7992
+ }, [overlayRef.current]);
7993
+ React.useEffect(function () {
7994
+ if (typeof ref === 'function') {
7995
+ ref(overlayRef.current);
7996
+ }
7997
+ }, [ref]);
7988
7998
  return (React__default.createElement("div", tslib.__assign({ className: classNames('Loader__overlay', className, variant === 'large'
7989
7999
  ? 'Loader__overlay--large'
7990
8000
  : variant === 'small'
7991
8001
  ? 'Loader__overlay--small'
7992
- : ''), ref: ref }, other),
8002
+ : ''), ref: overlayRef, tabIndex: -1 }, other),
7993
8003
  React__default.createElement("div", { className: "Loader__overlay__loader" },
7994
8004
  React__default.createElement(Loader, { variant: variant }),
7995
8005
  React__default.createElement(AxeLoader, null)),
7996
8006
  label ? React__default.createElement("span", { className: "Loader__overlay__label" }, label) : null,
7997
- other.children));
8007
+ children));
7998
8008
  });
7999
8009
  LoaderOverlay.propTypes = {
8000
8010
  className: PropTypes.string,
8001
8011
  variant: PropTypes.oneOf(['large', 'small']),
8002
- label: PropTypes.string
8012
+ label: PropTypes.string,
8013
+ focusOnInitialRender: PropTypes.bool,
8014
+ children: PropTypes.node
8003
8015
  };
8004
8016
  LoaderOverlay.displayName = 'LoaderOverlay';
8005
8017
 
@@ -8275,23 +8287,34 @@ var DescriptionDetails = function (_a) {
8275
8287
  DescriptionDetails.displayName = 'DescriptionDetails';
8276
8288
  DescriptionDetails.propTypes = commonPropTypes;
8277
8289
 
8278
- var isTooltip = function (props) {
8290
+ var isTooltipProps = function (props) {
8279
8291
  return !!props.tooltip;
8280
8292
  };
8281
8293
  var Step = function (props) {
8282
- var status = props.status, className = props.className, other = tslib.__rest(props, ["status", "className"]);
8283
- return (React__default.createElement("li", tslib.__assign({ className: classNames('Stepper__step', "Stepper__step--" + status, className), "aria-current": status === 'current' ? 'step' : 'false' }, other),
8294
+ var _a;
8295
+ var children = props.children, status = props.status, className = props.className, other = tslib.__rest(props, ["children", "status", "className"]);
8296
+ var tooltip;
8297
+ var tooltipText;
8298
+ var liProps;
8299
+ var isTooltip = isTooltipProps(other);
8300
+ if (isTooltip) {
8301
+ (_a = other, (tooltip = _a.tooltip, tooltipText = _a.tooltipText, _a), liProps = tslib.__rest(_a, ["tooltip", "tooltipText"]));
8302
+ }
8303
+ else {
8304
+ liProps = other;
8305
+ }
8306
+ return (React__default.createElement("li", tslib.__assign({ className: classNames('Stepper__step', "Stepper__step--" + status, className), "aria-current": status === 'current' ? 'step' : 'false' }, liProps),
8284
8307
  React__default.createElement("div", { className: "Stepper__step-line" }),
8285
- React__default.createElement("div", { className: "Stepper__step-content" }, isTooltip(props) ? (React__default.createElement(TooltipTabstop, { placement: "bottom", tooltip: props.tooltip,
8308
+ React__default.createElement("div", { className: "Stepper__step-content" }, isTooltip ? (React__default.createElement(TooltipTabstop, { placement: "bottom", tooltip: tooltip,
8286
8309
  // the pseudo content (ex: "1") is conveyed
8287
8310
  // by the list item's position in the set of
8288
8311
  // list items, therefore it is safe to clobber
8289
8312
  // it with the contents of the tooltip in the
8290
8313
  // tab stop's accessible name.
8291
- association: "aria-labelledby", "aria-label": isTooltip(props) ? props.tooltipText : undefined },
8314
+ association: "aria-labelledby", "aria-label": tooltipText },
8292
8315
  React__default.createElement("div", { className: "Stepper__step-indicator" }))) : (React__default.createElement(React__default.Fragment, null,
8293
8316
  React__default.createElement("div", { className: "Stepper__step-indicator" }),
8294
- 'children' in props && (React__default.createElement("div", { className: "Stepper__step-label" }, props.children)))))));
8317
+ children ? (React__default.createElement("div", { className: "Stepper__step-label" }, children)) : null)))));
8295
8318
  };
8296
8319
  Step.displayName = 'Step';
8297
8320
  Step.propTypes = {
@@ -8481,6 +8504,172 @@ var BreadcrumbLink = React.forwardRef(function (_a, ref) {
8481
8504
  return (React__default.createElement(ElementType, tslib.__assign({ className: classNames('Link', 'Breadcrumb__Link', className), ref: ref }, props), children));
8482
8505
  });
8483
8506
 
8507
+ var TwoColumnPanel = React.forwardRef(function (_a, ref) {
8508
+ var className = _a.className, children = _a.children, _b = _a.initialCollapsed, initialCollapsed = _b === void 0 ? false : _b, _c = _a.showCollapsedPanelLabel, showCollapsedPanelLabel = _c === void 0 ? 'Show Panel' : _c, _d = _a.hideCollapsedPanelLabel, hideCollapsedPanelLabel = _d === void 0 ? 'Hide Panel' : _d, props = tslib.__rest(_a, ["className", "children", "initialCollapsed", "showCollapsedPanelLabel", "hideCollapsedPanelLabel"]);
8509
+ var _e = tslib.__read(React.useState(initialCollapsed), 2), isCollapsed = _e[0], setCollapsed = _e[1];
8510
+ var _f = tslib.__read(React.useState(false), 2), isFocusTrap = _f[0], setIsFocusTrap = _f[1];
8511
+ var _g = tslib.__read(React.useState(!initialCollapsed), 2), showPanel = _g[0], setShowPanel = _g[1];
8512
+ var togglePanel = function () {
8513
+ if (isCollapsed) {
8514
+ setShowPanel(true);
8515
+ }
8516
+ // Set collapsed state on next tick so css transitions can be applied
8517
+ requestAnimationFrame(function () {
8518
+ var _a, _b;
8519
+ var collapsed = !isCollapsed;
8520
+ setCollapsed(collapsed);
8521
+ if (!collapsed) {
8522
+ (_a = columnLeftRef.current) === null || _a === void 0 ? void 0 : _a.focus();
8523
+ }
8524
+ else {
8525
+ (_b = columnRightRef.current) === null || _b === void 0 ? void 0 : _b.focus();
8526
+ }
8527
+ });
8528
+ };
8529
+ var toggleButtonRef = React.useRef(null);
8530
+ var closeButtonRef = React.useRef(null);
8531
+ var columnLeftRef = React.useRef(null);
8532
+ var columnRightRef = React.useRef(null);
8533
+ var columnLeft = React__default.Children.toArray(children).find(function (child) { return child.type === ColumnLeft; });
8534
+ // The ColumnLeftComponent will end up being a focus trap when < 720px
8535
+ // This component also gets unmounted when not visible meaning that any
8536
+ // aria relationships cannot be set to items inside the component since
8537
+ // they will not be present in the dom
8538
+ var ColumnLeftComponent;
8539
+ var columnLeftId;
8540
+ if (React.isValidElement(columnLeft)) {
8541
+ var ref_1 = columnLeft.props.ref || columnLeftRef;
8542
+ var id = (columnLeftId =
8543
+ columnLeft.props.id || nextId.useId(undefined, 'sidebar-')[0]);
8544
+ var CloseButton = (React__default.createElement("div", { className: "TwoColumnPanel__Close" },
8545
+ React__default.createElement("button", { type: "button", onClick: togglePanel, ref: closeButtonRef, "aria-label": hideCollapsedPanelLabel },
8546
+ React__default.createElement(Icon, { type: "close" })),
8547
+ React__default.createElement(Tooltip, { target: closeButtonRef, association: "aria-labelledby", hideElementOnHidden: true }, hideCollapsedPanelLabel)));
8548
+ var children_1 = tslib.__spread([
8549
+ CloseButton
8550
+ ], React__default.Children.toArray(columnLeft.props.children));
8551
+ ColumnLeftComponent = React.cloneElement(columnLeft, { id: id, ref: ref_1, tabIndex: -1 }, children_1.map(function (child, index) {
8552
+ return React.cloneElement(child, { key: "left-" + index });
8553
+ }));
8554
+ }
8555
+ var columnRight = React__default.Children.toArray(children).find(function (child) { return child.type === ColumnRight; });
8556
+ var ColumnRightComponent;
8557
+ if (React.isValidElement(columnRight)) {
8558
+ var ref_2 = columnRight.props.ref || columnRightRef;
8559
+ var ToggleButton = (React__default.createElement("div", { className: "TwoColumnPanel__ButtonToggle" },
8560
+ React__default.createElement("button", { type: "button", onClick: togglePanel, ref: toggleButtonRef, "aria-label": !isCollapsed ? hideCollapsedPanelLabel : showCollapsedPanelLabel, "aria-expanded": !isCollapsed, "aria-controls": columnLeftId },
8561
+ React__default.createElement(Icon, { type: !isCollapsed ? 'chevron-double-left' : 'chevron-double-right' })),
8562
+ React__default.createElement(Tooltip, { target: toggleButtonRef, association: "aria-labelledby", hideElementOnHidden: true }, !isCollapsed ? hideCollapsedPanelLabel : showCollapsedPanelLabel)));
8563
+ var children_2 = tslib.__spread([
8564
+ ToggleButton
8565
+ ], React__default.Children.toArray(columnRight.props.children));
8566
+ ColumnRightComponent = React.cloneElement(columnRight, { ref: ref_2, tabIndex: -1 }, children_2.map(function (child, index) {
8567
+ return React.cloneElement(child, { key: "right-" + index });
8568
+ }));
8569
+ }
8570
+ React.useLayoutEffect(function () {
8571
+ var _a;
8572
+ var handleTransitionEnd = function () {
8573
+ if (columnLeftRef.current && isCollapsed) {
8574
+ setShowPanel(false);
8575
+ }
8576
+ };
8577
+ (_a = columnLeftRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('transitionend', handleTransitionEnd);
8578
+ return function () {
8579
+ var _a;
8580
+ (_a = columnLeftRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('transitionend', handleTransitionEnd);
8581
+ };
8582
+ }, [columnLeftRef.current, isCollapsed]);
8583
+ // When the collapsable panel starts to overlay content, it needs to become a focus trap and collapsed by default
8584
+ React.useLayoutEffect(function () {
8585
+ var mediaQueryList = matchMedia('(max-width: 45rem)');
8586
+ var handleMatch = function (matches) {
8587
+ setIsFocusTrap(matches);
8588
+ var collapsed = matches ? true : isCollapsed;
8589
+ setCollapsed(collapsed);
8590
+ setShowPanel(!collapsed);
8591
+ };
8592
+ var listener = function (_a) {
8593
+ var matches = _a.matches;
8594
+ return handleMatch(matches);
8595
+ };
8596
+ if (mediaQueryList.matches) {
8597
+ handleMatch(mediaQueryList.matches);
8598
+ }
8599
+ mediaQueryList.addEventListener('change', listener);
8600
+ return function () {
8601
+ mediaQueryList.removeEventListener('change', listener);
8602
+ };
8603
+ }, []);
8604
+ React.useEffect(function () {
8605
+ var handleEscape = function (event) {
8606
+ if (event.key === 'Escape' ||
8607
+ event.key === 'Esc' ||
8608
+ event.keyCode === 27) {
8609
+ setCollapsed(true);
8610
+ }
8611
+ };
8612
+ var targetElement = document.body;
8613
+ if (isFocusTrap) {
8614
+ targetElement.addEventListener('keyup', handleEscape);
8615
+ }
8616
+ else {
8617
+ targetElement.removeEventListener('keyup', handleEscape);
8618
+ }
8619
+ return function () {
8620
+ targetElement.removeEventListener('keyup', handleEscape);
8621
+ };
8622
+ }, [isFocusTrap]);
8623
+ var handleClickOutside = function () {
8624
+ if (!isCollapsed && isFocusTrap) {
8625
+ setCollapsed(true);
8626
+ }
8627
+ };
8628
+ return (React__default.createElement("div", tslib.__assign({ className: classNames('TwoColumnPanel', className, {
8629
+ 'TwoColumnPanel--show': !isCollapsed,
8630
+ 'TwoColumnPanel--hide': isCollapsed
8631
+ }) }, props, { ref: ref }),
8632
+ React__default.createElement(FocusTrap, { active: !isCollapsed && isFocusTrap, focusTrapOptions: {
8633
+ escapeDeactivates: true,
8634
+ allowOutsideClick: true,
8635
+ fallbackFocus: columnLeftRef.current
8636
+ }, containerElements: [columnLeftRef.current] }),
8637
+ React__default.createElement(ClickOutsideListener, { onClickOutside: handleClickOutside, target: columnLeftRef.current }),
8638
+ showPanel ? ColumnLeftComponent : null,
8639
+ ColumnRightComponent));
8640
+ });
8641
+ TwoColumnPanel.displayName = 'TwoColumnPanel';
8642
+
8643
+ var ColumnHeader = React.forwardRef(function (_a, ref) {
8644
+ var className = _a.className, children = _a.children, props = tslib.__rest(_a, ["className", "children"]);
8645
+ return (React__default.createElement("div", tslib.__assign({ className: classNames('TwoColumnPanel__Header', className) }, props, { ref: ref }), children));
8646
+ });
8647
+ ColumnHeader.displayName = 'ColumnHeader';
8648
+
8649
+ var ColumnGroupHeader = React.forwardRef(function (_a, ref) {
8650
+ var className = _a.className, children = _a.children, props = tslib.__rest(_a, ["className", "children"]);
8651
+ return (React__default.createElement("div", tslib.__assign({ className: classNames('TwoColumnPanel__GroupHeader', className) }, props, { ref: ref }), children));
8652
+ });
8653
+ ColumnGroupHeader.displayName = 'ColumnGroupHeader';
8654
+
8655
+ var ColumnLeft = React.forwardRef(function (_a, ref) {
8656
+ var className = _a.className, children = _a.children, props = tslib.__rest(_a, ["className", "children"]);
8657
+ return (React__default.createElement("section", tslib.__assign({ className: classNames('TwoColumnPanel__Left', className) }, props, { ref: ref }), children));
8658
+ });
8659
+ ColumnLeft.displayName = 'ColumnLeft';
8660
+
8661
+ var ColumnRight = React.forwardRef(function (_a, ref) {
8662
+ var className = _a.className, children = _a.children, props = tslib.__rest(_a, ["className", "children"]);
8663
+ return (React__default.createElement("section", tslib.__assign({ className: classNames('TwoColumnPanel__Right', className) }, props, { ref: ref }), children));
8664
+ });
8665
+ ColumnRight.displayName = 'ColumnRight';
8666
+
8667
+ var ColumnList = React.forwardRef(function (_a, ref) {
8668
+ var className = _a.className, children = _a.children, props = tslib.__rest(_a, ["className", "children"]);
8669
+ return (React__default.createElement("div", tslib.__assign({ className: classNames('TwoColumnPanel__List', className) }, props, { ref: ref }), children));
8670
+ });
8671
+ ColumnList.displayName = 'ColumnList';
8672
+
8484
8673
  var LIGHT_THEME_CLASS = 'cauldron--theme-light';
8485
8674
  var DARK_THEME_CLASS = 'cauldron--theme-dark';
8486
8675
  var ThemeContext = React.createContext({});
@@ -8558,6 +8747,11 @@ exports.CardHeader = CardHeader;
8558
8747
  exports.Checkbox = Checkbox;
8559
8748
  exports.ClickOutsideListener = ClickOutsideListener;
8560
8749
  exports.Code = Code;
8750
+ exports.ColumnGroupHeader = ColumnGroupHeader;
8751
+ exports.ColumnHeader = ColumnHeader;
8752
+ exports.ColumnLeft = ColumnLeft;
8753
+ exports.ColumnList = ColumnList;
8754
+ exports.ColumnRight = ColumnRight;
8561
8755
  exports.DescriptionDetails = DescriptionDetails;
8562
8756
  exports.DescriptionList = DescriptionList;
8563
8757
  exports.DescriptionListItem = DescriptionListItem;
@@ -8626,6 +8820,7 @@ exports.TopBar = TopBar$1;
8626
8820
  exports.TopBarItem = MenuItem;
8627
8821
  exports.TopBarMenu = TopBarMenu;
8628
8822
  exports.TopBarTrigger = TopBarTrigger;
8823
+ exports.TwoColumnPanel = TwoColumnPanel;
8629
8824
  exports.Workspace = Workspace;
8630
8825
  exports.focusableSelector = focusableSelector;
8631
8826
  exports.iconTypes = iconTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "4.1.0-canary.e368ef0b",
3
+ "version": "4.1.0-canary.e3763bf9",
4
4
  "description": "Fully accessible react components library for Deque Cauldron",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@popperjs/core": "^2.5.4",
25
25
  "classnames": "^2.2.6",
26
- "focus-trap-react": "^3.0.5",
26
+ "focus-trap-react": "^8.9.0",
27
27
  "focusable": "^2.3.0",
28
28
  "keyname": "^0.1.0",
29
29
  "prop-types": "^15.6.0",