@deque/cauldron-react 7.1.0-canary.3dc1ee55 → 7.1.0-canary.3e2a4099
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/components/Accordion/Accordion.d.ts +1 -1
- package/lib/components/ActionList/ActionList.d.ts +1 -1
- package/lib/components/ActionMenu/ActionMenu.d.ts +11 -5
- package/lib/components/AnchoredOverlay/index.d.ts +2 -2
- package/lib/components/ClickOutsideListener/index.d.ts +1 -1
- package/lib/components/Combobox/Combobox.d.ts +1 -1
- package/lib/components/Dialog/DialogContext.d.ts +1 -1
- package/lib/components/Dialog/index.d.ts +1 -1
- package/lib/components/Drawer/index.d.ts +1 -1
- package/lib/components/ExpandCollapsePanel/ExpandCollapsePanel.d.ts +1 -1
- package/lib/components/Listbox/Listbox.d.ts +7 -2
- package/lib/components/MenuBar/index.d.ts +1 -0
- package/lib/components/Popover/index.d.ts +2 -2
- package/lib/components/Table/TableContext.d.ts +1 -1
- package/lib/components/Tabs/Tab.d.ts +1 -1
- package/lib/components/Toast/index.d.ts +4 -4
- package/lib/components/Tooltip/index.d.ts +2 -2
- package/lib/index.js +107 -77
- package/lib/types.d.ts +1 -1
- package/lib/utils/getChildRef.d.ts +2 -0
- package/lib/utils/useFocusTrap.d.ts +1 -1
- package/lib/utils/useMnemonics.d.ts +2 -2
- package/lib/utils/useSharedRef.d.ts +3 -3
- package/package.json +8 -8
|
@@ -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
|
}
|
|
@@ -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,
|
|
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
|
-
|
|
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;
|
|
@@ -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 };
|
|
@@ -3,6 +3,9 @@ export interface ToastProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
3
3
|
type: 'confirmation' | 'caution' | 'error' | 'action-needed' | 'info';
|
|
4
4
|
onDismiss?: () => void;
|
|
5
5
|
dismissText?: string;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use the forwarded `ref` instead. Will be removed in the next major version.
|
|
8
|
+
*/
|
|
6
9
|
toastRef?: React.Ref<HTMLDivElement>;
|
|
7
10
|
focus?: boolean;
|
|
8
11
|
show?: boolean;
|
|
@@ -12,8 +15,5 @@ export interface ToastProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
12
15
|
/**
|
|
13
16
|
* The cauldron toast notification component
|
|
14
17
|
*/
|
|
15
|
-
declare const Toast:
|
|
16
|
-
({ type, children, onDismiss, dismissText, toastRef, focus, show, dismissible, className, ...otherProps }: ToastProps): React.JSX.Element;
|
|
17
|
-
displayName: string;
|
|
18
|
-
};
|
|
18
|
+
declare const Toast: React.ForwardRefExoticComponent<ToastProps & React.RefAttributes<HTMLDivElement>>;
|
|
19
19
|
export default Toast;
|
|
@@ -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
|
-
|
|
505
|
-
|
|
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:
|
|
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:
|
|
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":
|
|
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) {
|
|
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
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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
|
-
//
|
|
835
|
-
|
|
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
|
|
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
|
|
@@ -2243,14 +2253,22 @@ var useDidUpdate = function (effect, dependencies) {
|
|
|
2243
2253
|
/**
|
|
2244
2254
|
* The cauldron toast notification component
|
|
2245
2255
|
*/
|
|
2246
|
-
var Toast = function (_a) {
|
|
2256
|
+
var Toast = React.forwardRef(function (_a, ref) {
|
|
2247
2257
|
var type = _a.type, children = _a.children, _b = _a.onDismiss, onDismiss = _b === void 0 ? function () {
|
|
2248
2258
|
// noop
|
|
2249
2259
|
} : _b, _c = _a.dismissText, dismissText = _c === void 0 ? 'Dismiss' : _c, toastRef = _a.toastRef, _d = _a.focus, focus = _d === void 0 ? true : _d, _e = _a.show, show = _e === void 0 ? false : _e, _f = _a.dismissible, dismissible = _f === void 0 ? true : _f, className = _a.className, otherProps = tslib.__rest(_a, ["type", "children", "onDismiss", "dismissText", "toastRef", "focus", "show", "dismissible", "className"]);
|
|
2250
|
-
var elRef = useSharedRef(
|
|
2260
|
+
var elRef = useSharedRef(ref);
|
|
2251
2261
|
var isolatorRef = React.useRef(null);
|
|
2252
2262
|
var timeoutsRef = React.useRef(new Set());
|
|
2253
2263
|
var _g = tslib.__read(React.useState(show ? 'FadeIn--flex' : 'is--hidden'), 2), animationClass = _g[0], setAnimationClass = _g[1];
|
|
2264
|
+
// Backwards-compat: propagate to the deprecated toastRef prop as well
|
|
2265
|
+
React.useEffect(function () {
|
|
2266
|
+
var _a;
|
|
2267
|
+
if (!toastRef)
|
|
2268
|
+
return;
|
|
2269
|
+
setRef(toastRef, (_a = elRef.current) !== null && _a !== void 0 ? _a : null);
|
|
2270
|
+
return function () { return setRef(toastRef, null); };
|
|
2271
|
+
}, [toastRef]);
|
|
2254
2272
|
// Timeout because CSS display: none/block and opacity:
|
|
2255
2273
|
// 0/1 properties cannot be toggled in the same tick
|
|
2256
2274
|
// see: https://codepen.io/isnerms/pen/eyQaLP
|
|
@@ -2324,7 +2342,7 @@ var Toast = function (_a) {
|
|
|
2324
2342
|
type !== 'action-needed' && dismissible && (React__default["default"].createElement("button", { type: "button", className: "Toast__dismiss", "aria-label": dismissText, onClick: dismissToast },
|
|
2325
2343
|
React__default["default"].createElement(Icon, { type: "close" })))),
|
|
2326
2344
|
scrim));
|
|
2327
|
-
};
|
|
2345
|
+
});
|
|
2328
2346
|
Toast.displayName = 'Toast';
|
|
2329
2347
|
|
|
2330
2348
|
var Link = React.forwardRef(function (_a, ref) {
|
|
@@ -2687,7 +2705,7 @@ Checkbox.displayName = 'Checkbox';
|
|
|
2687
2705
|
*/
|
|
2688
2706
|
function TooltipTabstop(_a) {
|
|
2689
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"]);
|
|
2690
|
-
var buttonRef = React.useRef();
|
|
2708
|
+
var buttonRef = React.useRef(null);
|
|
2691
2709
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2692
2710
|
React__default["default"].createElement("button", tslib.__assign({ type: "button", ref: buttonRef, "aria-disabled": "true", className: classNames__default["default"]('TooltipTabstop', className) }, buttonProps), children),
|
|
2693
2711
|
React__default["default"].createElement(Tooltip, { target: buttonRef, variant: variant, association: association, show: show, placement: placement, portal: portal, hideElementOnHidden: hideElementOnHidden }, tooltip)));
|
|
@@ -3531,7 +3549,7 @@ var TwoColumnPanel = React.forwardRef(function (_a, ref) {
|
|
|
3531
3549
|
var closeButtonRef = React.useRef(null);
|
|
3532
3550
|
var columnLeftRef = React.useRef(null);
|
|
3533
3551
|
var columnRightRef = React.useRef(null);
|
|
3534
|
-
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; });
|
|
3535
3553
|
var togglePanel = function () {
|
|
3536
3554
|
var prefersReducedMotion = 'matchMedia' in window &&
|
|
3537
3555
|
typeof matchMedia === 'function' &&
|
|
@@ -3564,16 +3582,17 @@ var TwoColumnPanel = React.forwardRef(function (_a, ref) {
|
|
|
3564
3582
|
var ColumnLeftComponent;
|
|
3565
3583
|
var columnLeftId;
|
|
3566
3584
|
if (React.isValidElement(columnLeft)) {
|
|
3567
|
-
var
|
|
3585
|
+
var columnLeftProps = columnLeft.props;
|
|
3586
|
+
var ref_1 = columnLeftProps.ref || columnLeftRef;
|
|
3568
3587
|
var id = (columnLeftId =
|
|
3569
|
-
|
|
3588
|
+
columnLeftProps.id || nextId.useId(undefined, 'sidebar-')[0]);
|
|
3570
3589
|
var CloseButton = (React__default["default"].createElement("div", { className: "TwoColumnPanel__Close" },
|
|
3571
3590
|
React__default["default"].createElement("button", { type: "button", onClick: togglePanel, ref: closeButtonRef, "aria-label": hideCollapsedPanelLabel },
|
|
3572
3591
|
React__default["default"].createElement(Icon, { type: "close" })),
|
|
3573
3592
|
React__default["default"].createElement(Tooltip, { target: closeButtonRef, association: "aria-labelledby", hideElementOnHidden: true }, hideCollapsedPanelLabel)));
|
|
3574
3593
|
var children_1 = tslib.__spreadArray([
|
|
3575
3594
|
CloseButton
|
|
3576
|
-
], tslib.__read(React__default["default"].Children.toArray(
|
|
3595
|
+
], tslib.__read(React__default["default"].Children.toArray(columnLeftProps.children)), false);
|
|
3577
3596
|
ColumnLeftComponent = React.cloneElement(columnLeft, { id: id, ref: ref_1, tabIndex: -1 }, children_1.map(function (child, index) {
|
|
3578
3597
|
return React.cloneElement(child, {
|
|
3579
3598
|
key: child.key
|
|
@@ -3582,17 +3601,18 @@ var TwoColumnPanel = React.forwardRef(function (_a, ref) {
|
|
|
3582
3601
|
});
|
|
3583
3602
|
}));
|
|
3584
3603
|
}
|
|
3585
|
-
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; });
|
|
3586
3605
|
var ColumnRightComponent;
|
|
3587
3606
|
if (React.isValidElement(columnRight)) {
|
|
3588
|
-
var
|
|
3607
|
+
var columnRightProps = columnRight.props;
|
|
3608
|
+
var ref_2 = columnRightProps.ref || columnRightRef;
|
|
3589
3609
|
var ToggleButton = (React__default["default"].createElement("div", { className: "TwoColumnPanel__ButtonToggle" },
|
|
3590
3610
|
React__default["default"].createElement("button", { type: "button", onClick: togglePanel, ref: toggleButtonRef, "aria-label": !isCollapsed ? hideCollapsedPanelLabel : showCollapsedPanelLabel, "aria-expanded": !isCollapsed, "aria-controls": columnLeftId },
|
|
3591
3611
|
React__default["default"].createElement(Icon, { type: !isCollapsed ? 'chevron-double-left' : 'chevron-double-right' })),
|
|
3592
3612
|
React__default["default"].createElement(Tooltip, { target: toggleButtonRef, association: "aria-labelledby", hideElementOnHidden: true }, !isCollapsed ? hideCollapsedPanelLabel : showCollapsedPanelLabel)));
|
|
3593
3613
|
var children_2 = tslib.__spreadArray([
|
|
3594
3614
|
ToggleButton
|
|
3595
|
-
], tslib.__read(React__default["default"].Children.toArray(
|
|
3615
|
+
], tslib.__read(React__default["default"].Children.toArray(columnRightProps.children)), false);
|
|
3596
3616
|
ColumnRightComponent = React.cloneElement(columnRight, { ref: ref_2, tabIndex: -1 }, children_2.map(function (child, index) {
|
|
3597
3617
|
return React.cloneElement(child, {
|
|
3598
3618
|
key: child.key
|
|
@@ -3924,11 +3944,11 @@ function isElementPreceding(a, b) {
|
|
|
3924
3944
|
}
|
|
3925
3945
|
var ListboxOption = React.forwardRef(function (_a, ref) {
|
|
3926
3946
|
var _b;
|
|
3927
|
-
var _c;
|
|
3928
|
-
var propId = _a.id, className = _a.className,
|
|
3929
|
-
var
|
|
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;
|
|
3930
3950
|
var listboxOptionRef = useSharedRef(ref);
|
|
3931
|
-
var
|
|
3951
|
+
var _h = tslib.__read(propId ? [propId] : nextId.useId(1, 'listbox-option'), 1), id = _h[0];
|
|
3932
3952
|
var isActive = (active === null || active === void 0 ? void 0 : active.element) === listboxOptionRef.current;
|
|
3933
3953
|
var isSelected = typeof selectedProp === 'boolean'
|
|
3934
3954
|
? selectedProp
|
|
@@ -3936,15 +3956,15 @@ var ListboxOption = React.forwardRef(function (_a, ref) {
|
|
|
3936
3956
|
!!selected.find(function (option) { return option.element === listboxOptionRef.current; });
|
|
3937
3957
|
var optionValue = typeof value !== 'undefined'
|
|
3938
3958
|
? value
|
|
3939
|
-
: (_c = listboxOptionRef.current) === null || _c === void 0 ? void 0 : _c.
|
|
3959
|
+
: ((_d = (_c = listboxOptionRef.current) === null || _c === void 0 ? void 0 : _c.textContent) !== null && _d !== void 0 ? _d : undefined);
|
|
3940
3960
|
React.useEffect(function () {
|
|
3941
3961
|
var element = listboxOptionRef.current;
|
|
3942
3962
|
setOptions(function (options) {
|
|
3943
3963
|
var e_1, _a;
|
|
3944
|
-
var option = { element: element, value: optionValue };
|
|
3945
3964
|
// istanbul ignore next
|
|
3946
3965
|
if (!element)
|
|
3947
3966
|
return options;
|
|
3967
|
+
var option = { element: element, value: optionValue };
|
|
3948
3968
|
// Elements are frequently appended, so check to see if the newly rendered
|
|
3949
3969
|
// element follows the last element first before any other checks
|
|
3950
3970
|
if (!options.length ||
|
|
@@ -3981,7 +4001,7 @@ var ListboxOption = React.forwardRef(function (_a, ref) {
|
|
|
3981
4001
|
if (disabled) {
|
|
3982
4002
|
return;
|
|
3983
4003
|
}
|
|
3984
|
-
onSelect({ element:
|
|
4004
|
+
onSelect({ element: event.target, value: optionValue });
|
|
3985
4005
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
3986
4006
|
}, [optionValue, onSelect, onClick, disabled]);
|
|
3987
4007
|
return (React__default["default"].createElement(Component, tslib.__assign({ id: id, className: classNames__default["default"](className, (_b = {},
|
|
@@ -4131,7 +4151,7 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
|
|
|
4131
4151
|
// istanbul ignore next
|
|
4132
4152
|
React.useLayoutEffect(function () {
|
|
4133
4153
|
var intersectionEntry = intersectionRef.current;
|
|
4134
|
-
if (!intersectionEntry || !isActive) {
|
|
4154
|
+
if (!intersectionEntry || !isActive || !comboboxOptionRef.current) {
|
|
4135
4155
|
return;
|
|
4136
4156
|
}
|
|
4137
4157
|
var rect = comboboxOptionRef.current.getBoundingClientRect();
|
|
@@ -4147,10 +4167,10 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
|
|
|
4147
4167
|
}
|
|
4148
4168
|
}, [isActive]);
|
|
4149
4169
|
React.useEffect(function () {
|
|
4150
|
-
var _a;
|
|
4170
|
+
var _a, _b;
|
|
4151
4171
|
var comboboxValue = typeof propValue !== 'undefined'
|
|
4152
4172
|
? propValue
|
|
4153
|
-
: (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.
|
|
4173
|
+
: ((_b = (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : undefined);
|
|
4154
4174
|
var value = typeof formValue === 'undefined' ? comboboxValue : formValue;
|
|
4155
4175
|
setFormValues(function (prev) {
|
|
4156
4176
|
var formValues = prev.filter(function (fv) { return fv !== value; });
|
|
@@ -4169,12 +4189,14 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
|
|
|
4169
4189
|
});
|
|
4170
4190
|
}, [selectedValues, formValue]);
|
|
4171
4191
|
React.useEffect(function () {
|
|
4172
|
-
var _a;
|
|
4192
|
+
var _a, _b;
|
|
4173
4193
|
if (isMatching) {
|
|
4174
4194
|
var comboboxValue_1 = typeof propValue !== 'undefined'
|
|
4175
4195
|
? propValue
|
|
4176
|
-
: (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.
|
|
4196
|
+
: ((_b = (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : undefined);
|
|
4177
4197
|
setMatchingOptions(function (options) {
|
|
4198
|
+
if (!comboboxOptionRef.current)
|
|
4199
|
+
return options;
|
|
4178
4200
|
return new Map(options.set(comboboxOptionRef.current, {
|
|
4179
4201
|
value: comboboxValue_1,
|
|
4180
4202
|
displayValue: children,
|
|
@@ -4314,6 +4336,17 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4314
4336
|
return value === lastSelectedValue;
|
|
4315
4337
|
}) || [], 2), element = _a[0], option = _a[1];
|
|
4316
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
|
+
}
|
|
4317
4350
|
setActiveDescendant(!element ? null : tslib.__assign({ element: element }, option));
|
|
4318
4351
|
}
|
|
4319
4352
|
else if (autocomplete === 'automatic' &&
|
|
@@ -4493,6 +4526,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4493
4526
|
});
|
|
4494
4527
|
}, [disabled, selectedValues, onSelectionChange]);
|
|
4495
4528
|
var handlePillKeyDown = React.useCallback(function (event) {
|
|
4529
|
+
var _a, _b;
|
|
4496
4530
|
if (!PillKeys.includes(event.key)) {
|
|
4497
4531
|
return;
|
|
4498
4532
|
}
|
|
@@ -4510,7 +4544,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4510
4544
|
handleRemovePill(pillsRef.current[focusedIndex], selectedValues[focusedIndex]);
|
|
4511
4545
|
var nextIndex = focusedIndex + 1;
|
|
4512
4546
|
if (nextIndex == pillsLength) {
|
|
4513
|
-
inputRef.current.focus();
|
|
4547
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
4514
4548
|
}
|
|
4515
4549
|
else {
|
|
4516
4550
|
pillsRef.current[nextIndex].focus();
|
|
@@ -4519,7 +4553,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4519
4553
|
else if (isArrowLeft || isArrowRight) {
|
|
4520
4554
|
var nextIndex = Math.max(focusedIndex + (isArrowLeft ? -1 : 1), 0);
|
|
4521
4555
|
if (isArrowRight && nextIndex === pillsLength) {
|
|
4522
|
-
inputRef.current.focus();
|
|
4556
|
+
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
4523
4557
|
}
|
|
4524
4558
|
else {
|
|
4525
4559
|
pillsRef.current[nextIndex].focus();
|
|
@@ -4807,10 +4841,12 @@ var TextEllipsis = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
4807
4841
|
: overflowElement.clientWidth < overflowElement.scrollWidth);
|
|
4808
4842
|
});
|
|
4809
4843
|
};
|
|
4844
|
+
if (!sharedRef.current)
|
|
4845
|
+
return;
|
|
4810
4846
|
var observer = new ResizeObserver(listener);
|
|
4811
4847
|
observer.observe(sharedRef.current);
|
|
4812
4848
|
return function () {
|
|
4813
|
-
observer
|
|
4849
|
+
observer.disconnect();
|
|
4814
4850
|
};
|
|
4815
4851
|
}, []);
|
|
4816
4852
|
React.useEffect(function () {
|
|
@@ -4855,7 +4891,7 @@ var Drawer = React.forwardRef(function (_a, ref) {
|
|
|
4855
4891
|
openRef.current = open;
|
|
4856
4892
|
}, [open, setIsTransitioning]);
|
|
4857
4893
|
React.useEffect(function () {
|
|
4858
|
-
if (!isModal) {
|
|
4894
|
+
if (!isModal || !drawerRef.current) {
|
|
4859
4895
|
return;
|
|
4860
4896
|
}
|
|
4861
4897
|
var isolator = new AriaIsolate(drawerRef.current);
|
|
@@ -5036,7 +5072,7 @@ function getActiveElement(root) {
|
|
|
5036
5072
|
*/
|
|
5037
5073
|
function useMnemonics(_a) {
|
|
5038
5074
|
var elementOrRef = _a.elementOrRef, matchingElementsSelector = _a.matchingElementsSelector, onMatch = _a.onMatch, _b = _a.enabled, enabled = _b === void 0 ? true : _b;
|
|
5039
|
-
var containerRef = React.useRef();
|
|
5075
|
+
var containerRef = React.useRef(null);
|
|
5040
5076
|
React.useEffect(function () {
|
|
5041
5077
|
if (elementOrRef instanceof HTMLElement) {
|
|
5042
5078
|
containerRef.current = elementOrRef;
|
|
@@ -5046,7 +5082,8 @@ function useMnemonics(_a) {
|
|
|
5046
5082
|
}
|
|
5047
5083
|
}, [elementOrRef]);
|
|
5048
5084
|
React.useEffect(function () {
|
|
5049
|
-
|
|
5085
|
+
var listenerTarget = containerRef.current;
|
|
5086
|
+
if (!enabled || !listenerTarget) {
|
|
5050
5087
|
return;
|
|
5051
5088
|
}
|
|
5052
5089
|
var keyboardHandler = function (event) {
|
|
@@ -5059,14 +5096,14 @@ function useMnemonics(_a) {
|
|
|
5059
5096
|
if (event.key.length !== 1 || !/[a-z\d]/i.test(event.key)) {
|
|
5060
5097
|
return;
|
|
5061
5098
|
}
|
|
5062
|
-
var
|
|
5063
|
-
if (!
|
|
5099
|
+
var currentContainer = containerRef.current;
|
|
5100
|
+
if (!currentContainer) {
|
|
5064
5101
|
return;
|
|
5065
5102
|
}
|
|
5066
5103
|
// Prevent default behavior and stop propagation for mnemonic keys
|
|
5067
5104
|
event.preventDefault();
|
|
5068
5105
|
event.stopPropagation();
|
|
5069
|
-
var elements = Array.from(
|
|
5106
|
+
var elements = Array.from(currentContainer.querySelectorAll(matchingElementsSelector !== null && matchingElementsSelector !== void 0 ? matchingElementsSelector : focusable__default["default"]));
|
|
5070
5107
|
var matchingElements = elements.filter(function (element) {
|
|
5071
5108
|
return getAccessibleLabel(element).toLowerCase()[0] ===
|
|
5072
5109
|
event.key.toLowerCase();
|
|
@@ -5074,7 +5111,7 @@ function useMnemonics(_a) {
|
|
|
5074
5111
|
if (!matchingElements.length) {
|
|
5075
5112
|
return;
|
|
5076
5113
|
}
|
|
5077
|
-
var currentActiveElement = getActiveElement(
|
|
5114
|
+
var currentActiveElement = getActiveElement(currentContainer);
|
|
5078
5115
|
var nextActiveElement = null;
|
|
5079
5116
|
if (currentActiveElement) {
|
|
5080
5117
|
nextActiveElement = matchingElements.find(function (element) {
|
|
@@ -5088,17 +5125,15 @@ function useMnemonics(_a) {
|
|
|
5088
5125
|
onMatch(nextActiveElement !== null && nextActiveElement !== void 0 ? nextActiveElement : matchingElements[0]);
|
|
5089
5126
|
}
|
|
5090
5127
|
};
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
return function () { return container.removeEventListener('keydown', keyboardHandler); };
|
|
5128
|
+
listenerTarget.addEventListener('keydown', keyboardHandler);
|
|
5129
|
+
return function () { return listenerTarget.removeEventListener('keydown', keyboardHandler); };
|
|
5094
5130
|
}, [enabled, containerRef, matchingElementsSelector, onMatch]);
|
|
5095
5131
|
return containerRef;
|
|
5096
5132
|
}
|
|
5097
5133
|
|
|
5098
5134
|
var ActionList = React.forwardRef(function (_a, ref) {
|
|
5099
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"]);
|
|
5100
|
-
var
|
|
5101
|
-
var activeElement = React.useRef();
|
|
5136
|
+
var activeElement = React.useRef(null);
|
|
5102
5137
|
var _c = tslib.__read(React.useState(), 2), activeOption = _c[0], setActiveOption = _c[1];
|
|
5103
5138
|
var handleActiveChange = React.useCallback(function (value) {
|
|
5104
5139
|
activeElement.current = value === null || value === void 0 ? void 0 : value.element;
|
|
@@ -5119,12 +5154,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
|
|
|
5119
5154
|
? '[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio]'
|
|
5120
5155
|
: '[role=option]'
|
|
5121
5156
|
});
|
|
5122
|
-
return (
|
|
5123
|
-
// Note: we should be able to use listbox without passing a prop
|
|
5124
|
-
// value for "multiselect"
|
|
5125
|
-
// see: https://github.com/dequelabs/cauldron/issues/1890
|
|
5126
|
-
// @ts-expect-error this should be allowed
|
|
5127
|
-
React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
|
|
5157
|
+
return (React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
|
|
5128
5158
|
if (ref) {
|
|
5129
5159
|
setRef(ref, element);
|
|
5130
5160
|
}
|
|
@@ -5133,7 +5163,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
|
|
|
5133
5163
|
/* Listbox comes with an explicit role of "listbox", but we want to either
|
|
5134
5164
|
* use the role from props, or default to the intrinsic role */
|
|
5135
5165
|
// eslint-disable-next-line jsx-a11y/aria-role
|
|
5136
|
-
role: undefined, "aria-multiselectable":
|
|
5166
|
+
role: undefined, "aria-multiselectable": undefined, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, { onActiveChange: handleActiveChange, navigation: "bound" }),
|
|
5137
5167
|
React__default["default"].createElement(ActionListProvider, { role: props.role || 'list', onAction: handleAction, selectionType: selectionType }, children)));
|
|
5138
5168
|
});
|
|
5139
5169
|
ActionList.displayName = 'ActionList';
|
|
@@ -5151,7 +5181,7 @@ var ActionListItem = React.forwardRef(function (_a, ref) {
|
|
|
5151
5181
|
});
|
|
5152
5182
|
var isActive = !!(active === null || active === void 0 ? void 0 : active.element) && active.element === actionListItemRef.current;
|
|
5153
5183
|
var handleAction = React.useCallback(function (event) {
|
|
5154
|
-
var _a;
|
|
5184
|
+
var _a, _b;
|
|
5155
5185
|
if (event.defaultPrevented) {
|
|
5156
5186
|
return;
|
|
5157
5187
|
}
|
|
@@ -5164,7 +5194,7 @@ var ActionListItem = React.forwardRef(function (_a, ref) {
|
|
|
5164
5194
|
}
|
|
5165
5195
|
// istanbul ignore else
|
|
5166
5196
|
if (typeof onActionListAction === 'function') {
|
|
5167
|
-
onActionListAction(actionKey || ((_a = labelRef === null ||
|
|
5197
|
+
onActionListAction(actionKey || ((_b = (_a = labelRef.current) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '', event);
|
|
5168
5198
|
}
|
|
5169
5199
|
}, [onAction, onActionListAction, selectionType, actionKey]);
|
|
5170
5200
|
var listItemRole = undefined;
|
|
@@ -5188,7 +5218,7 @@ var ActionListItem = React.forwardRef(function (_a, ref) {
|
|
|
5188
5218
|
// istanbul ignore next
|
|
5189
5219
|
React.useLayoutEffect(function () {
|
|
5190
5220
|
var intersectionEntry = intersectionRef.current;
|
|
5191
|
-
if (!intersectionEntry || !isActive) {
|
|
5221
|
+
if (!intersectionEntry || !isActive || !actionListItemRef.current) {
|
|
5192
5222
|
return;
|
|
5193
5223
|
}
|
|
5194
5224
|
var rect = actionListItemRef.current.getBoundingClientRect();
|
|
@@ -5287,9 +5317,10 @@ var ActionMenu = React.forwardRef(function (_a, ref) {
|
|
|
5287
5317
|
var _e = tslib.__read(React.useState('first'), 2), focusStrategy = _e[0], setFocusStrategy = _e[1];
|
|
5288
5318
|
var triggerRef = React.useRef(null);
|
|
5289
5319
|
var actionMenuRef = useSharedRef(ref);
|
|
5290
|
-
var
|
|
5291
|
-
var
|
|
5292
|
-
var _g = tslib.__read(nextId.useId(1, 'menu'), 1),
|
|
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];
|
|
5293
5324
|
var handleTriggerClick = React.useCallback(function (event) {
|
|
5294
5325
|
// istanbul ignore else
|
|
5295
5326
|
if (!event.defaultPrevented) {
|
|
@@ -5336,11 +5367,10 @@ var ActionMenu = React.forwardRef(function (_a, ref) {
|
|
|
5336
5367
|
if (!event.defaultPrevented) {
|
|
5337
5368
|
setOpen(false);
|
|
5338
5369
|
}
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
onAction(key, event);
|
|
5370
|
+
if (typeof actionListOnAction === 'function') {
|
|
5371
|
+
actionListOnAction(key, event);
|
|
5342
5372
|
}
|
|
5343
|
-
}, [
|
|
5373
|
+
}, [actionListOnAction]);
|
|
5344
5374
|
React.useEffect(function () {
|
|
5345
5375
|
var _a, _b;
|
|
5346
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>;
|
|
@@ -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 {
|
|
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> =
|
|
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 {
|
|
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
|
|
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>):
|
|
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.
|
|
3
|
+
"version": "7.1.0-canary.3e2a4099",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Fully accessible react components library for Deque Cauldron",
|
|
6
6
|
"homepage": "https://cauldron.dequelabs.com/",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@babel/preset-env": "^7.22.10",
|
|
42
42
|
"@babel/preset-react": "^7.22.5",
|
|
43
43
|
"@babel/preset-typescript": "^7.22.5",
|
|
44
|
-
"@figma/code-connect": "^1.4.
|
|
44
|
+
"@figma/code-connect": "^1.4.5",
|
|
45
45
|
"@rollup/plugin-commonjs": "^14.0.0",
|
|
46
46
|
"@rollup/plugin-dynamic-import-vars": "^1.4.2",
|
|
47
47
|
"@rollup/plugin-typescript": "^11.1.2",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@types/jest": "^29.5.11",
|
|
55
55
|
"@types/jest-axe": "^3.5.4",
|
|
56
56
|
"@types/node": "^17.0.42",
|
|
57
|
-
"@types/react": "^
|
|
58
|
-
"@types/react-dom": "^
|
|
57
|
+
"@types/react": "^19.0.0",
|
|
58
|
+
"@types/react-dom": "^19.0.0",
|
|
59
59
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
60
60
|
"@types/sinon": "^10",
|
|
61
61
|
"autoprefixer": "^9.7.6",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"postcss-import": "^12.0.1",
|
|
71
71
|
"postcss-loader": "^3.0.0",
|
|
72
72
|
"prop-types": "^15.8.1",
|
|
73
|
-
"react": "^
|
|
74
|
-
"react-dom": "^
|
|
73
|
+
"react": "^19",
|
|
74
|
+
"react-dom": "^19",
|
|
75
75
|
"rollup": "^2.23.0",
|
|
76
76
|
"sinon": "^10.0.0",
|
|
77
77
|
"ts-node": "^10.9.2",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"url": "git+https://github.com/dequelabs/cauldron.git"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
|
-
"react": ">=16.6
|
|
86
|
-
"react-dom": ">=16.6
|
|
85
|
+
"react": ">=16.6 <20",
|
|
86
|
+
"react-dom": ">=16.6 <20"
|
|
87
87
|
}
|
|
88
88
|
}
|