@deque/cauldron-react 7.1.0-canary.733aecb0 → 7.1.0-canary.7bc21991

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.
@@ -10,7 +10,7 @@ declare const AccordionTrigger: {
10
10
  ({ children, ...triggerProps }: AccordionTriggerProps): React.JSX.Element;
11
11
  displayName: string;
12
12
  };
13
- interface AccordionContentProps extends React.HTMLAttributes<HTMLDivElement> {
13
+ interface AccordionContentProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onToggle'> {
14
14
  children: React.ReactNode | React.ReactNode[];
15
15
  className?: string;
16
16
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { type ActionListSelectionType, type onActionCallbackFunction } from './ActionListContext';
3
- interface ActionListProps extends React.HTMLAttributes<HTMLUListElement> {
3
+ interface ActionListProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'defaultValue' | 'onSelect'> {
4
4
  children: React.ReactNode;
5
5
  /** Limits the amount of selections that can be made within an action list */
6
6
  selectionType?: ActionListSelectionType | null;
@@ -1,13 +1,19 @@
1
1
  import React from 'react';
2
+ import type { onActionCallbackFunction } from '../ActionList/ActionListContext';
3
+ interface ActionMenuListProps {
4
+ ref?: React.Ref<HTMLElement>;
5
+ onAction?: onActionCallbackFunction;
6
+ [key: string]: unknown;
7
+ }
2
8
  type ActionMenuTriggerProps = Pick<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'onClick' | 'onKeyDown' | 'aria-expanded' | 'aria-haspopup' | 'aria-controls'> & {
3
- ref: React.RefObject<HTMLButtonElement>;
9
+ ref: React.RefObject<HTMLButtonElement | null>;
4
10
  };
5
11
  type ActionMenuTriggerFunction = (props: ActionMenuTriggerProps, open: boolean) => React.ReactElement;
6
12
  declare const ActionMenu: React.ForwardRefExoticComponent<{
7
- children: React.ReactElement;
13
+ children: React.ReactElement<ActionMenuListProps>;
8
14
  trigger: React.ReactElement | ActionMenuTriggerFunction;
9
15
  /** Render the action menu in a different location in the dom. */
10
- portal?: HTMLElement | React.RefObject<HTMLElement> | undefined;
16
+ portal?: HTMLElement | React.RefObject<HTMLElement | null> | undefined;
11
17
  /**
12
18
  * Controls whether the menu should render as a child of the trigger, as opposed to
13
19
  * rendering as a sibling. Intended for use with nested menu patterns, for example
@@ -17,7 +23,7 @@ declare const ActionMenu: React.ForwardRefExoticComponent<{
17
23
  */
18
24
  renderInTrigger?: boolean | undefined;
19
25
  } & Pick<{
20
- target: HTMLElement | React.RefObject<HTMLElement> | React.MutableRefObject<HTMLElement>;
26
+ target: HTMLElement | React.RefObject<HTMLElement | null> | React.MutableRefObject<HTMLElement | null>;
21
27
  placement?: "auto" | import("@floating-ui/utils").Placement | "auto-start" | "auto-end" | undefined;
22
28
  open?: boolean | undefined;
23
29
  onOpenChange?: ((open: boolean) => void) | undefined;
@@ -31,7 +37,7 @@ declare const ActionMenu: React.ForwardRefExoticComponent<{
31
37
  returnFocus?: boolean | undefined;
32
38
  returnFocusElement?: import("../../types").ElementOrRef<HTMLElement> | undefined;
33
39
  } | undefined;
34
- portal?: HTMLElement | React.RefObject<HTMLElement> | undefined;
40
+ portal?: HTMLElement | React.RefObject<HTMLElement | null> | undefined;
35
41
  children?: React.ReactNode;
36
42
  } & React.HTMLAttributes<HTMLElement> & {
37
43
  as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import useFocusTrap from '../../utils/useFocusTrap';
4
4
  declare const AnchoredOverlay: React.ForwardRefExoticComponent<{
5
5
  /** A target element or ref to attach the overlay anchor element. */
6
- target: HTMLElement | React.RefObject<HTMLElement> | React.MutableRefObject<HTMLElement>;
6
+ target: HTMLElement | React.RefObject<HTMLElement | null> | React.MutableRefObject<HTMLElement | null>;
7
7
  /** Positional placement value to anchor the overlay element relative to its anchored target. */
8
8
  placement?: "auto" | Placement | "auto-start" | "auto-end" | undefined;
9
9
  /** Determines if the overlay anchor is currently visible. */
@@ -21,7 +21,7 @@ declare const AnchoredOverlay: React.ForwardRefExoticComponent<{
21
21
  /** When `focusTrap` is true, optional arguments to configure the focus trap. */
22
22
  focusTrapOptions?: Parameters<typeof useFocusTrap>[1];
23
23
  /** Render the anchored overlay in a different location in the dom. */
24
- portal?: HTMLElement | React.RefObject<HTMLElement> | undefined;
24
+ portal?: HTMLElement | React.RefObject<HTMLElement | null> | undefined;
25
25
  children?: React.ReactNode;
26
26
  } & React.HTMLAttributes<HTMLElement> & {
27
27
  as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
@@ -4,7 +4,7 @@ export interface ClickOutsideListenerProps<T extends HTMLElement = HTMLElement>
4
4
  onClickOutside: (e: MouseEvent | TouchEvent) => void;
5
5
  mouseEvent?: 'mousedown' | 'click' | 'mouseup' | false;
6
6
  touchEvent?: 'touchstart' | 'touchend' | false;
7
- target?: T | React.RefObject<T> | React.MutableRefObject<T>;
7
+ target?: T | React.RefObject<T | null> | React.MutableRefObject<T | null>;
8
8
  }
9
9
  declare const _default: React.ForwardRefExoticComponent<ClickOutsideListenerProps<HTMLElement> & React.RefAttributes<HTMLElement>>;
10
10
  export default _default;
@@ -19,7 +19,7 @@ interface BaseComboboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
19
19
  autocomplete?: 'none' | 'manual' | 'automatic';
20
20
  onActiveChange?: (option: ListboxOption) => void;
21
21
  renderNoResults?: (() => React.JSX.Element) | React.ReactElement;
22
- portal?: React.RefObject<HTMLElement> | HTMLElement;
22
+ portal?: React.RefObject<HTMLElement | null> | HTMLElement;
23
23
  inputRef?: React.Ref<HTMLInputElement>;
24
24
  description?: React.ReactNode;
25
25
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  interface DialogContextValue {
3
3
  headingId: string;
4
- headingRef: React.RefObject<HTMLHeadingElement>;
4
+ headingRef: React.RefObject<HTMLHeadingElement | null>;
5
5
  headingLevel: number;
6
6
  onClose: () => void;
7
7
  forceAction: boolean;
@@ -11,7 +11,7 @@ export interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {
11
11
  level: number | undefined;
12
12
  };
13
13
  closeButtonText?: string;
14
- portal?: React.RefObject<HTMLElement> | HTMLElement;
14
+ portal?: React.RefObject<HTMLElement | null> | HTMLElement;
15
15
  scrollable?: boolean;
16
16
  }
17
17
  declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<HTMLDivElement>>;
@@ -10,7 +10,7 @@ export interface DrawerProps<T extends HTMLElement = HTMLElement> extends React.
10
10
  returnFocus?: ElementOrRef<T>;
11
11
  };
12
12
  onClose?: () => void;
13
- portal?: React.RefObject<HTMLElement> | HTMLElement;
13
+ portal?: React.RefObject<HTMLElement | null> | HTMLElement;
14
14
  }
15
15
  declare const Drawer: React.ForwardRefExoticComponent<DrawerProps<HTMLElement> & React.RefAttributes<HTMLDivElement>>;
16
16
  export default Drawer;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export interface ExpandCollapsePanelProps extends React.HTMLAttributes<HTMLDivElement> {
2
+ export interface ExpandCollapsePanelProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onToggle'> {
3
3
  open?: boolean;
4
4
  children: React.ReactNode;
5
5
  animationTiming?: number | boolean;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { ListboxOption } from './ListboxContext';
3
3
  import type { ListboxValue } from './ListboxOption';
4
- import type { PolymorphicProps, PolymorphicComponent } from '../../utils/polymorphicComponent';
4
+ import type { PolymorphicProps, PolymorphicComponentProps } from '../../utils/polymorphicComponent';
5
5
  interface BaseListboxProps extends PolymorphicProps<Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'defaultValue'>> {
6
6
  navigation?: 'cycle' | 'bound';
7
7
  focusStrategy?: 'lastSelected' | 'first' | 'last';
@@ -30,5 +30,10 @@ interface MultiSelectListboxProps extends BaseListboxProps {
30
30
  value: ListboxValue[];
31
31
  }) => void;
32
32
  }
33
- declare const Listbox: PolymorphicComponent<SingleSelectListboxProps | MultiSelectListboxProps>;
33
+ type ListboxComponent = Omit<React.ForwardRefExoticComponent<SingleSelectListboxProps | MultiSelectListboxProps>, keyof CallableFunction> & {
34
+ <T extends React.ElementType = React.ElementType>(props: PolymorphicComponentProps<MultiSelectListboxProps, T>): React.ReactElement | null;
35
+ <T extends React.ElementType = React.ElementType>(props: PolymorphicComponentProps<SingleSelectListboxProps, T>): React.ReactElement | null;
36
+ <T extends React.ElementType = React.ElementType>(props: PolymorphicComponentProps<SingleSelectListboxProps | MultiSelectListboxProps, T>): React.ReactElement | null;
37
+ };
38
+ declare const Listbox: ListboxComponent;
34
39
  export default Listbox;
@@ -12,6 +12,7 @@ export default class TopBar extends React.Component<MenuBarProps, MenuBarState>
12
12
  thin: boolean;
13
13
  hasTrigger: boolean;
14
14
  };
15
+ private menuBarRef;
15
16
  constructor(props: MenuBarProps);
16
17
  componentDidMount(): void;
17
18
  componentWillUnmount(): void;
@@ -3,13 +3,13 @@ import { Cauldron } from '../../types';
3
3
  import AnchoredOverlay from '../AnchoredOverlay';
4
4
  export type PopoverVariant = 'prompt' | 'custom';
5
5
  type BaseProps = React.HTMLAttributes<HTMLDivElement> & {
6
- target: React.RefObject<HTMLElement> | HTMLElement;
6
+ target: React.RefObject<HTMLElement | null> | HTMLElement;
7
7
  variant?: PopoverVariant;
8
8
  show: boolean;
9
9
  onClose: () => void;
10
10
  placement?: React.ComponentProps<typeof AnchoredOverlay>['placement'];
11
11
  /** Render the popover in a different location in the dom. */
12
- portal?: React.RefObject<HTMLElement> | HTMLElement;
12
+ portal?: React.RefObject<HTMLElement | null> | HTMLElement;
13
13
  };
14
14
  type CustomProps = BaseProps & {
15
15
  variant: 'custom';
@@ -10,6 +10,6 @@ type TableProvider = {
10
10
  columns: Array<Column>;
11
11
  };
12
12
  declare const TableContext: React.Context<TableContext>;
13
- declare function TableProvider({ children, layout, columns }: TableProvider): JSX.Element;
13
+ declare function TableProvider({ children, layout, columns }: TableProvider): React.JSX.Element;
14
14
  declare function useTable(): TableContext;
15
15
  export { TableProvider, useTable };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  interface TabProps extends React.HTMLAttributes<HTMLLIElement> {
3
- target: React.RefObject<HTMLDivElement> | HTMLElement;
3
+ target: React.RefObject<HTMLDivElement | null> | HTMLElement;
4
4
  id?: string;
5
5
  children?: React.ReactNode;
6
6
  }
@@ -3,14 +3,14 @@ import AnchoredOverlay from '../AnchoredOverlay';
3
3
  export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {
4
4
  children: React.ReactNode;
5
5
  className?: string;
6
- target: React.RefObject<HTMLElement> | HTMLElement;
6
+ target: React.RefObject<HTMLElement | null> | HTMLElement;
7
7
  variant?: 'text' | 'info' | 'big';
8
8
  association?: 'aria-labelledby' | 'aria-describedby' | 'none';
9
9
  show?: boolean | undefined;
10
10
  defaultShow?: boolean;
11
11
  placement?: React.ComponentProps<typeof AnchoredOverlay>['placement'];
12
12
  /** Render the tooltip in a different location in the dom. */
13
- portal?: React.RefObject<HTMLElement> | HTMLElement;
13
+ portal?: React.RefObject<HTMLElement | null> | HTMLElement;
14
14
  hideElementOnHidden?: boolean;
15
15
  }
16
16
  declare function Tooltip({ id: propId, placement: initialPlacement, children, portal, target, association, variant, show: showProp, defaultShow, hideElementOnHidden, className, ...props }: TooltipProps): React.JSX.Element;
package/lib/index.js CHANGED
@@ -495,24 +495,25 @@ var Accordion = function (_a) {
495
495
  var childrenArray = React__default["default"].Children.toArray(children);
496
496
  var trigger = childrenArray.find(function (child) {
497
497
  return typeof child === 'string' ||
498
- child.type === AccordionTrigger;
498
+ (React__default["default"].isValidElement(child) && child.type === AccordionTrigger);
499
499
  });
500
500
  var panelElement = childrenArray.find(function (child) {
501
501
  return typeof child === 'string' ||
502
- child.type === AccordionContent;
502
+ (React__default["default"].isValidElement(child) && child.type === AccordionContent);
503
503
  });
504
- var isValid = !!(React__default["default"].isValidElement(trigger) && React__default["default"].isValidElement(panelElement));
505
- if (!isValid) {
504
+ if (!React__default["default"].isValidElement(trigger) ||
505
+ !React__default["default"].isValidElement(panelElement)) {
506
506
  console.warn('Must provide <AccordionTrigger /> and <AccordionContent /> element(s). You provided:', {
507
507
  trigger: trigger,
508
508
  panelElement: panelElement,
509
- isValid: isValid
509
+ isValid: false
510
510
  });
511
511
  return null;
512
512
  }
513
+ var panelProps = panelElement.props;
513
514
  return (React__default["default"].createElement("div", tslib.__assign({ className: "Accordion" }, props),
514
- React__default["default"].createElement(ExpandCollapsePanel, tslib.__assign({ id: panelElement.props.id || "".concat(elementId, "-panel"), open: open, onToggle: onToggle, animationTiming: animationTiming }, panelElement.props),
515
- React__default["default"].createElement(PanelTrigger$1, tslib.__assign({ iconCollapsed: "triangle-right", iconExpanded: "triangle-down", className: classNames__default["default"]('Accordion__trigger', trigger.props.className), "aria-controls": panelElement.props.id || "".concat(elementId, "-panel"), heading: trigger.props.heading }, trigger.props), trigger),
515
+ React__default["default"].createElement(ExpandCollapsePanel, tslib.__assign({ id: panelProps.id || "".concat(elementId, "-panel"), open: open, onToggle: onToggle, animationTiming: animationTiming }, panelProps),
516
+ React__default["default"].createElement(PanelTrigger$1, tslib.__assign({ iconCollapsed: "triangle-right", iconExpanded: "triangle-down", className: classNames__default["default"]('Accordion__trigger', trigger.props.className), "aria-controls": panelProps.id || "".concat(elementId, "-panel"), heading: trigger.props.heading }, trigger.props), trigger),
516
517
  panelElement)));
517
518
  };
518
519
  Accordion.displayName = 'Accordion';
@@ -578,7 +579,9 @@ var Scrim = /** @class */ (function (_super) {
578
579
  if (destroy) {
579
580
  return null;
580
581
  }
581
- return (React__default["default"].createElement("div", { ref: function (el) { return (_this.el = el); }, className: "Scrim ".concat(animationClass) }));
582
+ return (React__default["default"].createElement("div", { ref: function (el) {
583
+ _this.el = el;
584
+ }, className: "Scrim ".concat(animationClass) }));
582
585
  };
583
586
  return Scrim;
584
587
  }(React__default["default"].Component));
@@ -672,6 +675,7 @@ var TopBar$1 = /** @class */ (function (_super) {
672
675
  tslib.__extends(TopBar, _super);
673
676
  function TopBar(props) {
674
677
  var _this = _super.call(this, props) || this;
678
+ _this.menuBarRef = React__default["default"].createRef();
675
679
  _this.onResize = function () {
676
680
  var wide = isWide();
677
681
  if (wide === _this.state.wide) {
@@ -720,10 +724,10 @@ var TopBar$1 = /** @class */ (function (_super) {
720
724
  };
721
725
  TopBar.prototype.onKeyDown = function (e) {
722
726
  var key = keyname__default["default"](e.which);
723
- // This is a temporary workaround until have an opportunity to refactor or replace menubar
724
- // see: https://github.com/dequelabs/cauldron/issues/1934
725
- // eslint-disable-next-line react/no-find-dom-node
726
- var menuBarElement = reactDom.findDOMNode(this);
727
+ var menuBarElement = this.menuBarRef.current;
728
+ if (!menuBarElement) {
729
+ return;
730
+ }
727
731
  var menuItems = Array.from(menuBarElement.children);
728
732
  // account for hidden side bar trigger (hamburger)
729
733
  if (this.state.wide && this.props.hasTrigger) {
@@ -750,7 +754,7 @@ var TopBar$1 = /** @class */ (function (_super) {
750
754
  // disabling no-unused-vars to prevent thin/hasTrigger from being passed through to div
751
755
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
752
756
  var _a = this.props, children = _a.children, className = _a.className; _a.thin; _a.hasTrigger; tslib.__rest(_a, ["children", "className", "thin", "hasTrigger"]);
753
- return (React__default["default"].createElement("ul", { role: "menubar", onKeyDown: this.onKeyDown, className: className }, React.Children.map(children, this.renderChild)));
757
+ return (React__default["default"].createElement("ul", { role: "menubar", onKeyDown: this.onKeyDown, className: className, ref: this.menuBarRef }, React.Children.map(children, this.renderChild)));
754
758
  };
755
759
  TopBar.defaultProps = {
756
760
  thin: false,
@@ -806,9 +810,16 @@ function resolveElement(elementOrRef) {
806
810
  return null;
807
811
  }
808
812
 
813
+ function getChildRef(child, version) {
814
+ if (version === void 0) { version = React__default["default"].version; }
815
+ return parseInt(version, 10) >= 19
816
+ ? child.props.ref
817
+ : child.ref;
818
+ }
819
+
809
820
  function ClickOutsideListener(_a, ref) {
810
821
  var children = _a.children, _b = _a.mouseEvent, mouseEvent = _b === void 0 ? 'click' : _b, _c = _a.touchEvent, touchEvent = _c === void 0 ? 'touchend' : _c, target = _a.target, _d = _a.onClickOutside, onClickOutside = _d === void 0 ? function () { return null; } : _d;
811
- var childElementRef = React.useRef();
822
+ var childElementRef = React.useRef(null);
812
823
  var handleEvent = function (event) {
813
824
  if (event.defaultPrevented) {
814
825
  return;
@@ -831,9 +842,8 @@ function ClickOutsideListener(_a, ref) {
831
842
  childElementRef.current = node;
832
843
  // Ref for this component should pass-through to the child node
833
844
  setRef(ref, node);
834
- // If child has its own ref, we want to update
835
- // its ref with the newly cloned node
836
- var childRef = children.ref;
845
+ // Forward the child's own ref. In React 19 ref lives in props; in 16–18 it's element.ref.
846
+ var childRef = getChildRef(children);
837
847
  setRef(childRef, node);
838
848
  };
839
849
  React.useEffect(function () {
@@ -1342,7 +1352,7 @@ var AriaIsolate = /** @class */ (function () {
1342
1352
 
1343
1353
  /**
1344
1354
  * When a component needs to track an internal ref on a component that has a
1345
- * forwarded ref, useSharedRef will return a MutableRefObject<T> that will
1355
+ * forwarded ref, useSharedRef will return a RefObject<T | null> that will
1346
1356
  * correctly invoke the parent ref as well providing an internal ref.
1347
1357
  *
1348
1358
  * @example
@@ -1355,7 +1365,7 @@ var AriaIsolate = /** @class */ (function () {
1355
1365
  * })
1356
1366
  */
1357
1367
  function useSharedRef(ref) {
1358
- var internalRef = React.useRef();
1368
+ var internalRef = React.useRef(null);
1359
1369
  React.useEffect(function () {
1360
1370
  setRef(ref, internalRef.current);
1361
1371
  return function () { return setRef(ref, null); };
@@ -1488,7 +1498,7 @@ function useFocusTrap(target, options) {
1488
1498
  if (options === void 0) { options = {}; }
1489
1499
  var _a = options.disabled, disabled = _a === void 0 ? false : _a, _b = options.returnFocus, returnFocus = _b === void 0 ? true : _b, initialFocusElementOrRef = options.initialFocusElement, returnFocusElement = options.returnFocusElement;
1490
1500
  var focusTrap = React.useRef(null);
1491
- var returnFocusElementRef = React.useRef();
1501
+ var returnFocusElementRef = React.useRef(null);
1492
1502
  function restoreFocusToReturnFocusElement() {
1493
1503
  var _a;
1494
1504
  var resolvedReturnFocusElement = resolveElement(returnFocusElement);
@@ -1538,7 +1548,7 @@ var Dialog = React.forwardRef(function (_a, ref) {
1538
1548
  var dialogRef = useSharedRef(dialogRefProp || ref);
1539
1549
  var _g = tslib.__read(nextId.useId(1, 'dialog-title-'), 1), headingId = _g[0];
1540
1550
  var headingRef = React.useRef(null);
1541
- var isolatorRef = React.useRef();
1551
+ var isolatorRef = React.useRef(null);
1542
1552
  var headingLevel = typeof heading === 'object' && 'level' in heading && heading.level
1543
1553
  ? heading.level
1544
1554
  : 2;
@@ -2133,7 +2143,7 @@ var looksLikeLink = function (props) {
2133
2143
  };
2134
2144
  var IconButton = React.forwardRef(function (_a, ref) {
2135
2145
  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"]);
2136
- var internalRef = React.useRef();
2146
+ var internalRef = React.useRef(null);
2137
2147
  React.useImperativeHandle(ref, function () { return internalRef.current; });
2138
2148
  // Configure additional properties based on the type of the Component
2139
2149
  // for accessibility
@@ -2695,7 +2705,7 @@ Checkbox.displayName = 'Checkbox';
2695
2705
  */
2696
2706
  function TooltipTabstop(_a) {
2697
2707
  var children = _a.children, className = _a.className, tooltip = _a.tooltip, variant = _a.variant, association = _a.association, show = _a.show, placement = _a.placement, portal = _a.portal, hideElementOnHidden = _a.hideElementOnHidden, buttonProps = tslib.__rest(_a, ["children", "className", "tooltip", "variant", "association", "show", "placement", "portal", "hideElementOnHidden"]);
2698
- var buttonRef = React.useRef();
2708
+ var buttonRef = React.useRef(null);
2699
2709
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
2700
2710
  React__default["default"].createElement("button", tslib.__assign({ type: "button", ref: buttonRef, "aria-disabled": "true", className: classNames__default["default"]('TooltipTabstop', className) }, buttonProps), children),
2701
2711
  React__default["default"].createElement(Tooltip, { target: buttonRef, variant: variant, association: association, show: show, placement: placement, portal: portal, hideElementOnHidden: hideElementOnHidden }, tooltip)));
@@ -3539,7 +3549,7 @@ var TwoColumnPanel = React.forwardRef(function (_a, ref) {
3539
3549
  var closeButtonRef = React.useRef(null);
3540
3550
  var columnLeftRef = React.useRef(null);
3541
3551
  var columnRightRef = React.useRef(null);
3542
- var columnLeft = React__default["default"].Children.toArray(children).find(function (child) { return child.type === ColumnLeft; });
3552
+ var columnLeft = React__default["default"].Children.toArray(children).find(function (child) { return React__default["default"].isValidElement(child) && child.type === ColumnLeft; });
3543
3553
  var togglePanel = function () {
3544
3554
  var prefersReducedMotion = 'matchMedia' in window &&
3545
3555
  typeof matchMedia === 'function' &&
@@ -3572,16 +3582,17 @@ var TwoColumnPanel = React.forwardRef(function (_a, ref) {
3572
3582
  var ColumnLeftComponent;
3573
3583
  var columnLeftId;
3574
3584
  if (React.isValidElement(columnLeft)) {
3575
- var ref_1 = columnLeft.props.ref || columnLeftRef;
3585
+ var columnLeftProps = columnLeft.props;
3586
+ var ref_1 = columnLeftProps.ref || columnLeftRef;
3576
3587
  var id = (columnLeftId =
3577
- columnLeft.props.id || nextId.useId(undefined, 'sidebar-')[0]);
3588
+ columnLeftProps.id || nextId.useId(undefined, 'sidebar-')[0]);
3578
3589
  var CloseButton = (React__default["default"].createElement("div", { className: "TwoColumnPanel__Close" },
3579
3590
  React__default["default"].createElement("button", { type: "button", onClick: togglePanel, ref: closeButtonRef, "aria-label": hideCollapsedPanelLabel },
3580
3591
  React__default["default"].createElement(Icon, { type: "close" })),
3581
3592
  React__default["default"].createElement(Tooltip, { target: closeButtonRef, association: "aria-labelledby", hideElementOnHidden: true }, hideCollapsedPanelLabel)));
3582
3593
  var children_1 = tslib.__spreadArray([
3583
3594
  CloseButton
3584
- ], tslib.__read(React__default["default"].Children.toArray(columnLeft.props.children)), false);
3595
+ ], tslib.__read(React__default["default"].Children.toArray(columnLeftProps.children)), false);
3585
3596
  ColumnLeftComponent = React.cloneElement(columnLeft, { id: id, ref: ref_1, tabIndex: -1 }, children_1.map(function (child, index) {
3586
3597
  return React.cloneElement(child, {
3587
3598
  key: child.key
@@ -3590,17 +3601,18 @@ var TwoColumnPanel = React.forwardRef(function (_a, ref) {
3590
3601
  });
3591
3602
  }));
3592
3603
  }
3593
- var columnRight = React__default["default"].Children.toArray(children).find(function (child) { return child.type === ColumnRight; });
3604
+ var columnRight = React__default["default"].Children.toArray(children).find(function (child) { return React__default["default"].isValidElement(child) && child.type === ColumnRight; });
3594
3605
  var ColumnRightComponent;
3595
3606
  if (React.isValidElement(columnRight)) {
3596
- var ref_2 = columnRight.props.ref || columnRightRef;
3607
+ var columnRightProps = columnRight.props;
3608
+ var ref_2 = columnRightProps.ref || columnRightRef;
3597
3609
  var ToggleButton = (React__default["default"].createElement("div", { className: "TwoColumnPanel__ButtonToggle" },
3598
3610
  React__default["default"].createElement("button", { type: "button", onClick: togglePanel, ref: toggleButtonRef, "aria-label": !isCollapsed ? hideCollapsedPanelLabel : showCollapsedPanelLabel, "aria-expanded": !isCollapsed, "aria-controls": columnLeftId },
3599
3611
  React__default["default"].createElement(Icon, { type: !isCollapsed ? 'chevron-double-left' : 'chevron-double-right' })),
3600
3612
  React__default["default"].createElement(Tooltip, { target: toggleButtonRef, association: "aria-labelledby", hideElementOnHidden: true }, !isCollapsed ? hideCollapsedPanelLabel : showCollapsedPanelLabel)));
3601
3613
  var children_2 = tslib.__spreadArray([
3602
3614
  ToggleButton
3603
- ], tslib.__read(React__default["default"].Children.toArray(columnRight.props.children)), false);
3615
+ ], tslib.__read(React__default["default"].Children.toArray(columnRightProps.children)), false);
3604
3616
  ColumnRightComponent = React.cloneElement(columnRight, { ref: ref_2, tabIndex: -1 }, children_2.map(function (child, index) {
3605
3617
  return React.cloneElement(child, {
3606
3618
  key: child.key
@@ -3932,11 +3944,11 @@ function isElementPreceding(a, b) {
3932
3944
  }
3933
3945
  var ListboxOption = React.forwardRef(function (_a, ref) {
3934
3946
  var _b;
3935
- var _c;
3936
- var propId = _a.id, className = _a.className, _d = _a.as, Component = _d === void 0 ? 'li' : _d, children = _a.children, value = _a.value, disabled = _a.disabled, selectedProp = _a.selected, _e = _a.activeClass, activeClass = _e === void 0 ? 'ListboxOption--active' : _e, onClick = _a.onClick, props = tslib.__rest(_a, ["id", "className", "as", "children", "value", "disabled", "selected", "activeClass", "onClick"]);
3937
- var _f = useListboxContext(), active = _f.active, selected = _f.selected, setOptions = _f.setOptions, onSelect = _f.onSelect;
3947
+ var _c, _d;
3948
+ var propId = _a.id, className = _a.className, _e = _a.as, Component = _e === void 0 ? 'li' : _e, children = _a.children, value = _a.value, disabled = _a.disabled, selectedProp = _a.selected, _f = _a.activeClass, activeClass = _f === void 0 ? 'ListboxOption--active' : _f, onClick = _a.onClick, props = tslib.__rest(_a, ["id", "className", "as", "children", "value", "disabled", "selected", "activeClass", "onClick"]);
3949
+ var _g = useListboxContext(), active = _g.active, selected = _g.selected, setOptions = _g.setOptions, onSelect = _g.onSelect;
3938
3950
  var listboxOptionRef = useSharedRef(ref);
3939
- var _g = tslib.__read(propId ? [propId] : nextId.useId(1, 'listbox-option'), 1), id = _g[0];
3951
+ var _h = tslib.__read(propId ? [propId] : nextId.useId(1, 'listbox-option'), 1), id = _h[0];
3940
3952
  var isActive = (active === null || active === void 0 ? void 0 : active.element) === listboxOptionRef.current;
3941
3953
  var isSelected = typeof selectedProp === 'boolean'
3942
3954
  ? selectedProp
@@ -3944,15 +3956,15 @@ var ListboxOption = React.forwardRef(function (_a, ref) {
3944
3956
  !!selected.find(function (option) { return option.element === listboxOptionRef.current; });
3945
3957
  var optionValue = typeof value !== 'undefined'
3946
3958
  ? value
3947
- : (_c = listboxOptionRef.current) === null || _c === void 0 ? void 0 : _c.innerText;
3959
+ : ((_d = (_c = listboxOptionRef.current) === null || _c === void 0 ? void 0 : _c.textContent) !== null && _d !== void 0 ? _d : undefined);
3948
3960
  React.useEffect(function () {
3949
3961
  var element = listboxOptionRef.current;
3950
3962
  setOptions(function (options) {
3951
3963
  var e_1, _a;
3952
- var option = { element: element, value: optionValue };
3953
3964
  // istanbul ignore next
3954
3965
  if (!element)
3955
3966
  return options;
3967
+ var option = { element: element, value: optionValue };
3956
3968
  // Elements are frequently appended, so check to see if the newly rendered
3957
3969
  // element follows the last element first before any other checks
3958
3970
  if (!options.length ||
@@ -3989,7 +4001,7 @@ var ListboxOption = React.forwardRef(function (_a, ref) {
3989
4001
  if (disabled) {
3990
4002
  return;
3991
4003
  }
3992
- onSelect({ element: listboxOptionRef.current, value: optionValue });
4004
+ onSelect({ element: event.target, value: optionValue });
3993
4005
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
3994
4006
  }, [optionValue, onSelect, onClick, disabled]);
3995
4007
  return (React__default["default"].createElement(Component, tslib.__assign({ id: id, className: classNames__default["default"](className, (_b = {},
@@ -4139,7 +4151,7 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
4139
4151
  // istanbul ignore next
4140
4152
  React.useLayoutEffect(function () {
4141
4153
  var intersectionEntry = intersectionRef.current;
4142
- if (!intersectionEntry || !isActive) {
4154
+ if (!intersectionEntry || !isActive || !comboboxOptionRef.current) {
4143
4155
  return;
4144
4156
  }
4145
4157
  var rect = comboboxOptionRef.current.getBoundingClientRect();
@@ -4155,10 +4167,10 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
4155
4167
  }
4156
4168
  }, [isActive]);
4157
4169
  React.useEffect(function () {
4158
- var _a;
4170
+ var _a, _b;
4159
4171
  var comboboxValue = typeof propValue !== 'undefined'
4160
4172
  ? propValue
4161
- : (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.innerText;
4173
+ : ((_b = (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : undefined);
4162
4174
  var value = typeof formValue === 'undefined' ? comboboxValue : formValue;
4163
4175
  setFormValues(function (prev) {
4164
4176
  var formValues = prev.filter(function (fv) { return fv !== value; });
@@ -4177,12 +4189,14 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
4177
4189
  });
4178
4190
  }, [selectedValues, formValue]);
4179
4191
  React.useEffect(function () {
4180
- var _a;
4192
+ var _a, _b;
4181
4193
  if (isMatching) {
4182
4194
  var comboboxValue_1 = typeof propValue !== 'undefined'
4183
4195
  ? propValue
4184
- : (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.innerText;
4196
+ : ((_b = (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : undefined);
4185
4197
  setMatchingOptions(function (options) {
4198
+ if (!comboboxOptionRef.current)
4199
+ return options;
4186
4200
  return new Map(options.set(comboboxOptionRef.current, {
4187
4201
  value: comboboxValue_1,
4188
4202
  displayValue: children,
@@ -4322,6 +4336,17 @@ var Combobox = React.forwardRef(function (_a, ref) {
4322
4336
  return value === lastSelectedValue;
4323
4337
  }) || [], 2), element = _a[0], option = _a[1];
4324
4338
  if (autocomplete === 'manual') {
4339
+ // In multiselect, the listbox manages its own active option via
4340
+ // keyboard navigation. When the last-selected value no longer
4341
+ // matches any option (e.g. after deselecting the only selected
4342
+ // option), preserve the existing active descendant so the next
4343
+ // Enter keypress can re-toggle the highlighted option.
4344
+ if (multiselect &&
4345
+ !element &&
4346
+ activeDescendant &&
4347
+ matchingOptions.has(activeDescendant.element)) {
4348
+ return;
4349
+ }
4325
4350
  setActiveDescendant(!element ? null : tslib.__assign({ element: element }, option));
4326
4351
  }
4327
4352
  else if (autocomplete === 'automatic' &&
@@ -4501,6 +4526,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
4501
4526
  });
4502
4527
  }, [disabled, selectedValues, onSelectionChange]);
4503
4528
  var handlePillKeyDown = React.useCallback(function (event) {
4529
+ var _a, _b;
4504
4530
  if (!PillKeys.includes(event.key)) {
4505
4531
  return;
4506
4532
  }
@@ -4518,7 +4544,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
4518
4544
  handleRemovePill(pillsRef.current[focusedIndex], selectedValues[focusedIndex]);
4519
4545
  var nextIndex = focusedIndex + 1;
4520
4546
  if (nextIndex == pillsLength) {
4521
- inputRef.current.focus();
4547
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
4522
4548
  }
4523
4549
  else {
4524
4550
  pillsRef.current[nextIndex].focus();
@@ -4527,7 +4553,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
4527
4553
  else if (isArrowLeft || isArrowRight) {
4528
4554
  var nextIndex = Math.max(focusedIndex + (isArrowLeft ? -1 : 1), 0);
4529
4555
  if (isArrowRight && nextIndex === pillsLength) {
4530
- inputRef.current.focus();
4556
+ (_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
4531
4557
  }
4532
4558
  else {
4533
4559
  pillsRef.current[nextIndex].focus();
@@ -4815,10 +4841,12 @@ var TextEllipsis = React__default["default"].forwardRef(function (_a, ref) {
4815
4841
  : overflowElement.clientWidth < overflowElement.scrollWidth);
4816
4842
  });
4817
4843
  };
4844
+ if (!sharedRef.current)
4845
+ return;
4818
4846
  var observer = new ResizeObserver(listener);
4819
4847
  observer.observe(sharedRef.current);
4820
4848
  return function () {
4821
- observer === null || observer === void 0 ? void 0 : observer.disconnect();
4849
+ observer.disconnect();
4822
4850
  };
4823
4851
  }, []);
4824
4852
  React.useEffect(function () {
@@ -4863,7 +4891,7 @@ var Drawer = React.forwardRef(function (_a, ref) {
4863
4891
  openRef.current = open;
4864
4892
  }, [open, setIsTransitioning]);
4865
4893
  React.useEffect(function () {
4866
- if (!isModal) {
4894
+ if (!isModal || !drawerRef.current) {
4867
4895
  return;
4868
4896
  }
4869
4897
  var isolator = new AriaIsolate(drawerRef.current);
@@ -5044,7 +5072,7 @@ function getActiveElement(root) {
5044
5072
  */
5045
5073
  function useMnemonics(_a) {
5046
5074
  var elementOrRef = _a.elementOrRef, matchingElementsSelector = _a.matchingElementsSelector, onMatch = _a.onMatch, _b = _a.enabled, enabled = _b === void 0 ? true : _b;
5047
- var containerRef = React.useRef();
5075
+ var containerRef = React.useRef(null);
5048
5076
  React.useEffect(function () {
5049
5077
  if (elementOrRef instanceof HTMLElement) {
5050
5078
  containerRef.current = elementOrRef;
@@ -5054,7 +5082,8 @@ function useMnemonics(_a) {
5054
5082
  }
5055
5083
  }, [elementOrRef]);
5056
5084
  React.useEffect(function () {
5057
- if (!enabled || !containerRef.current) {
5085
+ var listenerTarget = containerRef.current;
5086
+ if (!enabled || !listenerTarget) {
5058
5087
  return;
5059
5088
  }
5060
5089
  var keyboardHandler = function (event) {
@@ -5067,14 +5096,14 @@ function useMnemonics(_a) {
5067
5096
  if (event.key.length !== 1 || !/[a-z\d]/i.test(event.key)) {
5068
5097
  return;
5069
5098
  }
5070
- var container = containerRef.current;
5071
- if (!container) {
5099
+ var currentContainer = containerRef.current;
5100
+ if (!currentContainer) {
5072
5101
  return;
5073
5102
  }
5074
5103
  // Prevent default behavior and stop propagation for mnemonic keys
5075
5104
  event.preventDefault();
5076
5105
  event.stopPropagation();
5077
- var elements = Array.from(container.querySelectorAll(matchingElementsSelector !== null && matchingElementsSelector !== void 0 ? matchingElementsSelector : focusable__default["default"]));
5106
+ var elements = Array.from(currentContainer.querySelectorAll(matchingElementsSelector !== null && matchingElementsSelector !== void 0 ? matchingElementsSelector : focusable__default["default"]));
5078
5107
  var matchingElements = elements.filter(function (element) {
5079
5108
  return getAccessibleLabel(element).toLowerCase()[0] ===
5080
5109
  event.key.toLowerCase();
@@ -5082,7 +5111,7 @@ function useMnemonics(_a) {
5082
5111
  if (!matchingElements.length) {
5083
5112
  return;
5084
5113
  }
5085
- var currentActiveElement = getActiveElement(containerRef.current);
5114
+ var currentActiveElement = getActiveElement(currentContainer);
5086
5115
  var nextActiveElement = null;
5087
5116
  if (currentActiveElement) {
5088
5117
  nextActiveElement = matchingElements.find(function (element) {
@@ -5096,17 +5125,15 @@ function useMnemonics(_a) {
5096
5125
  onMatch(nextActiveElement !== null && nextActiveElement !== void 0 ? nextActiveElement : matchingElements[0]);
5097
5126
  }
5098
5127
  };
5099
- var container = containerRef.current;
5100
- container.addEventListener('keydown', keyboardHandler);
5101
- return function () { return container.removeEventListener('keydown', keyboardHandler); };
5128
+ listenerTarget.addEventListener('keydown', keyboardHandler);
5129
+ return function () { return listenerTarget.removeEventListener('keydown', keyboardHandler); };
5102
5130
  }, [enabled, containerRef, matchingElementsSelector, onMatch]);
5103
5131
  return containerRef;
5104
5132
  }
5105
5133
 
5106
5134
  var ActionList = React.forwardRef(function (_a, ref) {
5107
5135
  var _b = _a.selectionType, selectionType = _b === void 0 ? null : _b, onAction = _a.onAction, className = _a.className, children = _a.children, props = tslib.__rest(_a, ["selectionType", "onAction", "className", "children"]);
5108
- var actionListContext = useActionListContext();
5109
- var activeElement = React.useRef();
5136
+ var activeElement = React.useRef(null);
5110
5137
  var _c = tslib.__read(React.useState(), 2), activeOption = _c[0], setActiveOption = _c[1];
5111
5138
  var handleActiveChange = React.useCallback(function (value) {
5112
5139
  activeElement.current = value === null || value === void 0 ? void 0 : value.element;
@@ -5127,12 +5154,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
5127
5154
  ? '[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio]'
5128
5155
  : '[role=option]'
5129
5156
  });
5130
- return (
5131
- // Note: we should be able to use listbox without passing a prop
5132
- // value for "multiselect"
5133
- // see: https://github.com/dequelabs/cauldron/issues/1890
5134
- // @ts-expect-error this should be allowed
5135
- React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
5157
+ return (React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
5136
5158
  if (ref) {
5137
5159
  setRef(ref, element);
5138
5160
  }
@@ -5141,7 +5163,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
5141
5163
  /* Listbox comes with an explicit role of "listbox", but we want to either
5142
5164
  * use the role from props, or default to the intrinsic role */
5143
5165
  // eslint-disable-next-line jsx-a11y/aria-role
5144
- role: undefined, "aria-multiselectable": actionListContext.role === 'listbox' ? undefined : null, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, { onActiveChange: handleActiveChange, navigation: "bound" }),
5166
+ role: undefined, "aria-multiselectable": undefined, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, { onActiveChange: handleActiveChange, navigation: "bound" }),
5145
5167
  React__default["default"].createElement(ActionListProvider, { role: props.role || 'list', onAction: handleAction, selectionType: selectionType }, children)));
5146
5168
  });
5147
5169
  ActionList.displayName = 'ActionList';
@@ -5159,7 +5181,7 @@ var ActionListItem = React.forwardRef(function (_a, ref) {
5159
5181
  });
5160
5182
  var isActive = !!(active === null || active === void 0 ? void 0 : active.element) && active.element === actionListItemRef.current;
5161
5183
  var handleAction = React.useCallback(function (event) {
5162
- var _a;
5184
+ var _a, _b;
5163
5185
  if (event.defaultPrevented) {
5164
5186
  return;
5165
5187
  }
@@ -5172,7 +5194,7 @@ var ActionListItem = React.forwardRef(function (_a, ref) {
5172
5194
  }
5173
5195
  // istanbul ignore else
5174
5196
  if (typeof onActionListAction === 'function') {
5175
- onActionListAction(actionKey || ((_a = labelRef === null || labelRef === void 0 ? void 0 : labelRef.current) === null || _a === void 0 ? void 0 : _a.innerText.trim()) || '', event);
5197
+ onActionListAction(actionKey || ((_b = (_a = labelRef.current) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '', event);
5176
5198
  }
5177
5199
  }, [onAction, onActionListAction, selectionType, actionKey]);
5178
5200
  var listItemRole = undefined;
@@ -5196,7 +5218,7 @@ var ActionListItem = React.forwardRef(function (_a, ref) {
5196
5218
  // istanbul ignore next
5197
5219
  React.useLayoutEffect(function () {
5198
5220
  var intersectionEntry = intersectionRef.current;
5199
- if (!intersectionEntry || !isActive) {
5221
+ if (!intersectionEntry || !isActive || !actionListItemRef.current) {
5200
5222
  return;
5201
5223
  }
5202
5224
  var rect = actionListItemRef.current.getBoundingClientRect();
@@ -5295,9 +5317,10 @@ var ActionMenu = React.forwardRef(function (_a, ref) {
5295
5317
  var _e = tslib.__read(React.useState('first'), 2), focusStrategy = _e[0], setFocusStrategy = _e[1];
5296
5318
  var triggerRef = React.useRef(null);
5297
5319
  var actionMenuRef = useSharedRef(ref);
5298
- var actionMenuListRef = useSharedRef(actionMenuList.props.ref);
5299
- var _f = tslib.__read(nextId.useId(1, 'menu-trigger'), 1), triggerId = _f[0];
5300
- var _g = tslib.__read(nextId.useId(1, 'menu'), 1), menuId = _g[0];
5320
+ var _f = actionMenuList.props, actionListRef = _f.ref, actionListOnAction = _f.onAction;
5321
+ var actionMenuListRef = useSharedRef(actionListRef !== null && actionListRef !== void 0 ? actionListRef : null);
5322
+ var _g = tslib.__read(nextId.useId(1, 'menu-trigger'), 1), triggerId = _g[0];
5323
+ var _h = tslib.__read(nextId.useId(1, 'menu'), 1), menuId = _h[0];
5301
5324
  var handleTriggerClick = React.useCallback(function (event) {
5302
5325
  // istanbul ignore else
5303
5326
  if (!event.defaultPrevented) {
@@ -5344,11 +5367,10 @@ var ActionMenu = React.forwardRef(function (_a, ref) {
5344
5367
  if (!event.defaultPrevented) {
5345
5368
  setOpen(false);
5346
5369
  }
5347
- var onAction = actionMenuList.props.onAction;
5348
- if (typeof onAction === 'function') {
5349
- onAction(key, event);
5370
+ if (typeof actionListOnAction === 'function') {
5371
+ actionListOnAction(key, event);
5350
5372
  }
5351
- }, [actionMenuList.props.onAction]);
5373
+ }, [actionListOnAction]);
5352
5374
  React.useEffect(function () {
5353
5375
  var _a, _b;
5354
5376
  if (open) {
package/lib/types.d.ts CHANGED
@@ -11,4 +11,4 @@ export declare namespace Cauldron {
11
11
  * Explicit equivalent of Exclude<ReactNode, boolean | null | undefined>
12
12
  */
13
13
  export type ContentNode = string | number | ReactPortal | ReactElement;
14
- export type ElementOrRef<E extends Element> = E | React.RefObject<E> | React.MutableRefObject<E>;
14
+ export type ElementOrRef<E extends Element> = E | React.RefObject<E | null> | React.MutableRefObject<E | null>;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare function getChildRef(child: React.ReactElement, version?: string): React.Ref<HTMLElement> | null | undefined;
@@ -3,7 +3,7 @@ type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2;
3
3
  export type PolymorphicProps<Props = {}, ElementType extends React.ElementType = React.ElementType> = Props & {
4
4
  as?: ElementType;
5
5
  };
6
- export type PolymorphicComponentProps<Props = {}, ElementType extends React.ElementType = React.ElementType> = Merge<ElementType extends keyof JSX.IntrinsicElements ? React.PropsWithRef<JSX.IntrinsicElements[ElementType]> : ElementType extends React.ElementType ? React.ComponentPropsWithRef<ElementType> : never, PolymorphicProps<Props, ElementType>>;
6
+ export type PolymorphicComponentProps<Props = {}, ElementType extends React.ElementType = React.ElementType> = Merge<ElementType extends keyof React.JSX.IntrinsicElements ? React.PropsWithRef<React.JSX.IntrinsicElements[ElementType]> : ElementType extends React.ElementType ? React.ComponentPropsWithRef<ElementType> : never, PolymorphicProps<Props, ElementType>>;
7
7
  export type PolymorphicComponent<Props = {}, ElementType extends React.ElementType = React.ElementType> = Merge<React.ForwardRefExoticComponent<Props>, {
8
8
  <T extends React.ElementType = ElementType>(props: PolymorphicComponentProps<Props, T>): React.ReactElement | null;
9
9
  }>;
@@ -30,5 +30,5 @@ export default function useFocusTrap<TargetElement extends Element = Element, Fo
30
30
  * can be provided to override the default active element behavior.
31
31
  */
32
32
  returnFocusElement?: ElementOrRef<FocusElement>;
33
- }): React.RefObject<Readonly<FocusTrap>>;
33
+ }): React.RefObject<Readonly<FocusTrap> | null>;
34
34
  export {};
@@ -1,4 +1,4 @@
1
- import type { RefObject } from 'react';
1
+ import type { MutableRefObject } from 'react';
2
2
  import type { ElementOrRef } from '../types';
3
3
  type useMnemonicsOptions = {
4
4
  /**
@@ -19,7 +19,7 @@ type useMnemonicsOptions = {
19
19
  */
20
20
  enabled?: boolean;
21
21
  };
22
- type useMnemonicsResults<T extends HTMLElement> = RefObject<T>;
22
+ type useMnemonicsResults<T extends HTMLElement> = MutableRefObject<T | null>;
23
23
  /**
24
24
  * A hook that provides mnemonic navigation for keyboard users.
25
25
  *
@@ -1,7 +1,7 @@
1
- import { MutableRefObject, Ref } from 'react';
1
+ import { RefObject, Ref } from 'react';
2
2
  /**
3
3
  * When a component needs to track an internal ref on a component that has a
4
- * forwarded ref, useSharedRef will return a MutableRefObject<T> that will
4
+ * forwarded ref, useSharedRef will return a RefObject<T | null> that will
5
5
  * correctly invoke the parent ref as well providing an internal ref.
6
6
  *
7
7
  * @example
@@ -13,4 +13,4 @@ import { MutableRefObject, Ref } from 'react';
13
13
  * return (<div ref={internalRef}>...</div>)
14
14
  * })
15
15
  */
16
- export default function useSharedRef<T>(ref: Ref<T>): MutableRefObject<T>;
16
+ export default function useSharedRef<T>(ref: Ref<T>): RefObject<T | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "7.1.0-canary.733aecb0",
3
+ "version": "7.1.0-canary.7bc21991",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",
@@ -18,6 +18,7 @@
18
18
  "prebuild:lib": "node scripts/buildIconTypes.js",
19
19
  "build:lib": "rollup -c",
20
20
  "build:css": "postcss --output=lib/cauldron.css src/index.css",
21
+ "typecheck": "tsc --noEmit --skipLibCheck",
21
22
  "dev": "concurrently 'yarn build:css --watch' 'rollup -c --watch'",
22
23
  "prepublishOnly": "NODE_ENV=production yarn build",
23
24
  "test": "jest --maxWorkers=1 --coverage",
@@ -26,6 +27,7 @@
26
27
  "figma:publish:dry-run": "figma connect publish --dry-run"
27
28
  },
28
29
  "dependencies": {
30
+ "@floating-ui/dom": "^1.0.0",
29
31
  "@floating-ui/react-dom": "^2.1.2",
30
32
  "classnames": "^2.2.6",
31
33
  "focusable": "^2.3.0",
@@ -41,7 +43,7 @@
41
43
  "@babel/preset-env": "^7.22.10",
42
44
  "@babel/preset-react": "^7.22.5",
43
45
  "@babel/preset-typescript": "^7.22.5",
44
- "@figma/code-connect": "^1.4.4",
46
+ "@figma/code-connect": "^1.4.5",
45
47
  "@rollup/plugin-commonjs": "^14.0.0",
46
48
  "@rollup/plugin-dynamic-import-vars": "^1.4.2",
47
49
  "@rollup/plugin-typescript": "^11.1.2",
@@ -54,8 +56,8 @@
54
56
  "@types/jest": "^29.5.11",
55
57
  "@types/jest-axe": "^3.5.4",
56
58
  "@types/node": "^17.0.42",
57
- "@types/react": "^18.0.12",
58
- "@types/react-dom": "^18.0.5",
59
+ "@types/react": "^19.0.0",
60
+ "@types/react-dom": "^19.0.0",
59
61
  "@types/react-syntax-highlighter": "^15.5.13",
60
62
  "@types/sinon": "^10",
61
63
  "autoprefixer": "^9.7.6",
@@ -70,8 +72,8 @@
70
72
  "postcss-import": "^12.0.1",
71
73
  "postcss-loader": "^3.0.0",
72
74
  "prop-types": "^15.8.1",
73
- "react": "^18",
74
- "react-dom": "^18",
75
+ "react": "^19",
76
+ "react-dom": "^19",
75
77
  "rollup": "^2.23.0",
76
78
  "sinon": "^10.0.0",
77
79
  "ts-node": "^10.9.2",
@@ -82,7 +84,7 @@
82
84
  "url": "git+https://github.com/dequelabs/cauldron.git"
83
85
  },
84
86
  "peerDependencies": {
85
- "react": ">=16.6 <= 18",
86
- "react-dom": ">=16.6 <= 18"
87
+ "react": ">=16.6 <20",
88
+ "react-dom": ">=16.6 <20"
87
89
  }
88
90
  }