@deque/cauldron-react 7.1.0-canary.ec0e4309 → 7.1.0-canary.ee30df17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,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,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;
|
package/lib/index.js
CHANGED
|
@@ -807,9 +807,16 @@ function resolveElement(elementOrRef) {
|
|
|
807
807
|
return null;
|
|
808
808
|
}
|
|
809
809
|
|
|
810
|
+
function getChildRef(child, version) {
|
|
811
|
+
if (version === void 0) { version = React__default["default"].version; }
|
|
812
|
+
return parseInt(version, 10) >= 19
|
|
813
|
+
? child.props.ref
|
|
814
|
+
: child.ref;
|
|
815
|
+
}
|
|
816
|
+
|
|
810
817
|
function ClickOutsideListener(_a, ref) {
|
|
811
818
|
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;
|
|
812
|
-
var childElementRef = React.useRef();
|
|
819
|
+
var childElementRef = React.useRef(null);
|
|
813
820
|
var handleEvent = function (event) {
|
|
814
821
|
if (event.defaultPrevented) {
|
|
815
822
|
return;
|
|
@@ -832,9 +839,8 @@ function ClickOutsideListener(_a, ref) {
|
|
|
832
839
|
childElementRef.current = node;
|
|
833
840
|
// Ref for this component should pass-through to the child node
|
|
834
841
|
setRef(ref, node);
|
|
835
|
-
//
|
|
836
|
-
|
|
837
|
-
var childRef = children.ref;
|
|
842
|
+
// Forward the child's own ref. In React 19 ref lives in props; in 16–18 it's element.ref.
|
|
843
|
+
var childRef = getChildRef(children);
|
|
838
844
|
setRef(childRef, node);
|
|
839
845
|
};
|
|
840
846
|
React.useEffect(function () {
|
|
@@ -1343,7 +1349,7 @@ var AriaIsolate = /** @class */ (function () {
|
|
|
1343
1349
|
|
|
1344
1350
|
/**
|
|
1345
1351
|
* When a component needs to track an internal ref on a component that has a
|
|
1346
|
-
* forwarded ref, useSharedRef will return a MutableRefObject<T> that will
|
|
1352
|
+
* forwarded ref, useSharedRef will return a MutableRefObject<T | null> that will
|
|
1347
1353
|
* correctly invoke the parent ref as well providing an internal ref.
|
|
1348
1354
|
*
|
|
1349
1355
|
* @example
|
|
@@ -1356,7 +1362,7 @@ var AriaIsolate = /** @class */ (function () {
|
|
|
1356
1362
|
* })
|
|
1357
1363
|
*/
|
|
1358
1364
|
function useSharedRef(ref) {
|
|
1359
|
-
var internalRef = React.useRef();
|
|
1365
|
+
var internalRef = React.useRef(null);
|
|
1360
1366
|
React.useEffect(function () {
|
|
1361
1367
|
setRef(ref, internalRef.current);
|
|
1362
1368
|
return function () { return setRef(ref, null); };
|
|
@@ -1489,7 +1495,7 @@ function useFocusTrap(target, options) {
|
|
|
1489
1495
|
if (options === void 0) { options = {}; }
|
|
1490
1496
|
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;
|
|
1491
1497
|
var focusTrap = React.useRef(null);
|
|
1492
|
-
var returnFocusElementRef = React.useRef();
|
|
1498
|
+
var returnFocusElementRef = React.useRef(null);
|
|
1493
1499
|
function restoreFocusToReturnFocusElement() {
|
|
1494
1500
|
var _a;
|
|
1495
1501
|
var resolvedReturnFocusElement = resolveElement(returnFocusElement);
|
|
@@ -1539,7 +1545,7 @@ var Dialog = React.forwardRef(function (_a, ref) {
|
|
|
1539
1545
|
var dialogRef = useSharedRef(dialogRefProp || ref);
|
|
1540
1546
|
var _g = tslib.__read(nextId.useId(1, 'dialog-title-'), 1), headingId = _g[0];
|
|
1541
1547
|
var headingRef = React.useRef(null);
|
|
1542
|
-
var isolatorRef = React.useRef();
|
|
1548
|
+
var isolatorRef = React.useRef(null);
|
|
1543
1549
|
var headingLevel = typeof heading === 'object' && 'level' in heading && heading.level
|
|
1544
1550
|
? heading.level
|
|
1545
1551
|
: 2;
|
|
@@ -2134,7 +2140,7 @@ var looksLikeLink = function (props) {
|
|
|
2134
2140
|
};
|
|
2135
2141
|
var IconButton = React.forwardRef(function (_a, ref) {
|
|
2136
2142
|
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"]);
|
|
2137
|
-
var internalRef = React.useRef();
|
|
2143
|
+
var internalRef = React.useRef(null);
|
|
2138
2144
|
React.useImperativeHandle(ref, function () { return internalRef.current; });
|
|
2139
2145
|
// Configure additional properties based on the type of the Component
|
|
2140
2146
|
// for accessibility
|
|
@@ -2696,7 +2702,7 @@ Checkbox.displayName = 'Checkbox';
|
|
|
2696
2702
|
*/
|
|
2697
2703
|
function TooltipTabstop(_a) {
|
|
2698
2704
|
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"]);
|
|
2699
|
-
var buttonRef = React.useRef();
|
|
2705
|
+
var buttonRef = React.useRef(null);
|
|
2700
2706
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2701
2707
|
React__default["default"].createElement("button", tslib.__assign({ type: "button", ref: buttonRef, "aria-disabled": "true", className: classNames__default["default"]('TooltipTabstop', className) }, buttonProps), children),
|
|
2702
2708
|
React__default["default"].createElement(Tooltip, { target: buttonRef, variant: variant, association: association, show: show, placement: placement, portal: portal, hideElementOnHidden: hideElementOnHidden }, tooltip)));
|
|
@@ -3933,11 +3939,11 @@ function isElementPreceding(a, b) {
|
|
|
3933
3939
|
}
|
|
3934
3940
|
var ListboxOption = React.forwardRef(function (_a, ref) {
|
|
3935
3941
|
var _b;
|
|
3936
|
-
var _c;
|
|
3937
|
-
var propId = _a.id, className = _a.className,
|
|
3938
|
-
var
|
|
3942
|
+
var _c, _d;
|
|
3943
|
+
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"]);
|
|
3944
|
+
var _g = useListboxContext(), active = _g.active, selected = _g.selected, setOptions = _g.setOptions, onSelect = _g.onSelect;
|
|
3939
3945
|
var listboxOptionRef = useSharedRef(ref);
|
|
3940
|
-
var
|
|
3946
|
+
var _h = tslib.__read(propId ? [propId] : nextId.useId(1, 'listbox-option'), 1), id = _h[0];
|
|
3941
3947
|
var isActive = (active === null || active === void 0 ? void 0 : active.element) === listboxOptionRef.current;
|
|
3942
3948
|
var isSelected = typeof selectedProp === 'boolean'
|
|
3943
3949
|
? selectedProp
|
|
@@ -3945,15 +3951,15 @@ var ListboxOption = React.forwardRef(function (_a, ref) {
|
|
|
3945
3951
|
!!selected.find(function (option) { return option.element === listboxOptionRef.current; });
|
|
3946
3952
|
var optionValue = typeof value !== 'undefined'
|
|
3947
3953
|
? value
|
|
3948
|
-
: (_c = listboxOptionRef.current) === null || _c === void 0 ? void 0 : _c.
|
|
3954
|
+
: ((_d = (_c = listboxOptionRef.current) === null || _c === void 0 ? void 0 : _c.textContent) !== null && _d !== void 0 ? _d : undefined);
|
|
3949
3955
|
React.useEffect(function () {
|
|
3950
3956
|
var element = listboxOptionRef.current;
|
|
3951
3957
|
setOptions(function (options) {
|
|
3952
3958
|
var e_1, _a;
|
|
3953
|
-
var option = { element: element, value: optionValue };
|
|
3954
3959
|
// istanbul ignore next
|
|
3955
3960
|
if (!element)
|
|
3956
3961
|
return options;
|
|
3962
|
+
var option = { element: element, value: optionValue };
|
|
3957
3963
|
// Elements are frequently appended, so check to see if the newly rendered
|
|
3958
3964
|
// element follows the last element first before any other checks
|
|
3959
3965
|
if (!options.length ||
|
|
@@ -3990,7 +3996,7 @@ var ListboxOption = React.forwardRef(function (_a, ref) {
|
|
|
3990
3996
|
if (disabled) {
|
|
3991
3997
|
return;
|
|
3992
3998
|
}
|
|
3993
|
-
onSelect({ element:
|
|
3999
|
+
onSelect({ element: event.target, value: optionValue });
|
|
3994
4000
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
3995
4001
|
}, [optionValue, onSelect, onClick, disabled]);
|
|
3996
4002
|
return (React__default["default"].createElement(Component, tslib.__assign({ id: id, className: classNames__default["default"](className, (_b = {},
|
|
@@ -4140,7 +4146,7 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
|
|
|
4140
4146
|
// istanbul ignore next
|
|
4141
4147
|
React.useLayoutEffect(function () {
|
|
4142
4148
|
var intersectionEntry = intersectionRef.current;
|
|
4143
|
-
if (!intersectionEntry || !isActive) {
|
|
4149
|
+
if (!intersectionEntry || !isActive || !comboboxOptionRef.current) {
|
|
4144
4150
|
return;
|
|
4145
4151
|
}
|
|
4146
4152
|
var rect = comboboxOptionRef.current.getBoundingClientRect();
|
|
@@ -4156,10 +4162,10 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
|
|
|
4156
4162
|
}
|
|
4157
4163
|
}, [isActive]);
|
|
4158
4164
|
React.useEffect(function () {
|
|
4159
|
-
var _a;
|
|
4165
|
+
var _a, _b;
|
|
4160
4166
|
var comboboxValue = typeof propValue !== 'undefined'
|
|
4161
4167
|
? propValue
|
|
4162
|
-
: (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.
|
|
4168
|
+
: ((_b = (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : undefined);
|
|
4163
4169
|
var value = typeof formValue === 'undefined' ? comboboxValue : formValue;
|
|
4164
4170
|
setFormValues(function (prev) {
|
|
4165
4171
|
var formValues = prev.filter(function (fv) { return fv !== value; });
|
|
@@ -4178,12 +4184,14 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
|
|
|
4178
4184
|
});
|
|
4179
4185
|
}, [selectedValues, formValue]);
|
|
4180
4186
|
React.useEffect(function () {
|
|
4181
|
-
var _a;
|
|
4187
|
+
var _a, _b;
|
|
4182
4188
|
if (isMatching) {
|
|
4183
4189
|
var comboboxValue_1 = typeof propValue !== 'undefined'
|
|
4184
4190
|
? propValue
|
|
4185
|
-
: (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.
|
|
4191
|
+
: ((_b = (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : undefined);
|
|
4186
4192
|
setMatchingOptions(function (options) {
|
|
4193
|
+
if (!comboboxOptionRef.current)
|
|
4194
|
+
return options;
|
|
4187
4195
|
return new Map(options.set(comboboxOptionRef.current, {
|
|
4188
4196
|
value: comboboxValue_1,
|
|
4189
4197
|
displayValue: children,
|
|
@@ -4513,6 +4521,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4513
4521
|
});
|
|
4514
4522
|
}, [disabled, selectedValues, onSelectionChange]);
|
|
4515
4523
|
var handlePillKeyDown = React.useCallback(function (event) {
|
|
4524
|
+
var _a, _b;
|
|
4516
4525
|
if (!PillKeys.includes(event.key)) {
|
|
4517
4526
|
return;
|
|
4518
4527
|
}
|
|
@@ -4530,7 +4539,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4530
4539
|
handleRemovePill(pillsRef.current[focusedIndex], selectedValues[focusedIndex]);
|
|
4531
4540
|
var nextIndex = focusedIndex + 1;
|
|
4532
4541
|
if (nextIndex == pillsLength) {
|
|
4533
|
-
inputRef.current.focus();
|
|
4542
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
4534
4543
|
}
|
|
4535
4544
|
else {
|
|
4536
4545
|
pillsRef.current[nextIndex].focus();
|
|
@@ -4539,7 +4548,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4539
4548
|
else if (isArrowLeft || isArrowRight) {
|
|
4540
4549
|
var nextIndex = Math.max(focusedIndex + (isArrowLeft ? -1 : 1), 0);
|
|
4541
4550
|
if (isArrowRight && nextIndex === pillsLength) {
|
|
4542
|
-
inputRef.current.focus();
|
|
4551
|
+
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
4543
4552
|
}
|
|
4544
4553
|
else {
|
|
4545
4554
|
pillsRef.current[nextIndex].focus();
|
|
@@ -4827,10 +4836,12 @@ var TextEllipsis = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
4827
4836
|
: overflowElement.clientWidth < overflowElement.scrollWidth);
|
|
4828
4837
|
});
|
|
4829
4838
|
};
|
|
4839
|
+
if (!sharedRef.current)
|
|
4840
|
+
return;
|
|
4830
4841
|
var observer = new ResizeObserver(listener);
|
|
4831
4842
|
observer.observe(sharedRef.current);
|
|
4832
4843
|
return function () {
|
|
4833
|
-
observer
|
|
4844
|
+
observer.disconnect();
|
|
4834
4845
|
};
|
|
4835
4846
|
}, []);
|
|
4836
4847
|
React.useEffect(function () {
|
|
@@ -4875,7 +4886,7 @@ var Drawer = React.forwardRef(function (_a, ref) {
|
|
|
4875
4886
|
openRef.current = open;
|
|
4876
4887
|
}, [open, setIsTransitioning]);
|
|
4877
4888
|
React.useEffect(function () {
|
|
4878
|
-
if (!isModal) {
|
|
4889
|
+
if (!isModal || !drawerRef.current) {
|
|
4879
4890
|
return;
|
|
4880
4891
|
}
|
|
4881
4892
|
var isolator = new AriaIsolate(drawerRef.current);
|
|
@@ -5056,7 +5067,7 @@ function getActiveElement(root) {
|
|
|
5056
5067
|
*/
|
|
5057
5068
|
function useMnemonics(_a) {
|
|
5058
5069
|
var elementOrRef = _a.elementOrRef, matchingElementsSelector = _a.matchingElementsSelector, onMatch = _a.onMatch, _b = _a.enabled, enabled = _b === void 0 ? true : _b;
|
|
5059
|
-
var containerRef = React.useRef();
|
|
5070
|
+
var containerRef = React.useRef(null);
|
|
5060
5071
|
React.useEffect(function () {
|
|
5061
5072
|
if (elementOrRef instanceof HTMLElement) {
|
|
5062
5073
|
containerRef.current = elementOrRef;
|
|
@@ -5066,7 +5077,8 @@ function useMnemonics(_a) {
|
|
|
5066
5077
|
}
|
|
5067
5078
|
}, [elementOrRef]);
|
|
5068
5079
|
React.useEffect(function () {
|
|
5069
|
-
|
|
5080
|
+
var listenerTarget = containerRef.current;
|
|
5081
|
+
if (!enabled || !listenerTarget) {
|
|
5070
5082
|
return;
|
|
5071
5083
|
}
|
|
5072
5084
|
var keyboardHandler = function (event) {
|
|
@@ -5079,14 +5091,14 @@ function useMnemonics(_a) {
|
|
|
5079
5091
|
if (event.key.length !== 1 || !/[a-z\d]/i.test(event.key)) {
|
|
5080
5092
|
return;
|
|
5081
5093
|
}
|
|
5082
|
-
var
|
|
5083
|
-
if (!
|
|
5094
|
+
var currentContainer = containerRef.current;
|
|
5095
|
+
if (!currentContainer) {
|
|
5084
5096
|
return;
|
|
5085
5097
|
}
|
|
5086
5098
|
// Prevent default behavior and stop propagation for mnemonic keys
|
|
5087
5099
|
event.preventDefault();
|
|
5088
5100
|
event.stopPropagation();
|
|
5089
|
-
var elements = Array.from(
|
|
5101
|
+
var elements = Array.from(currentContainer.querySelectorAll(matchingElementsSelector !== null && matchingElementsSelector !== void 0 ? matchingElementsSelector : focusable__default["default"]));
|
|
5090
5102
|
var matchingElements = elements.filter(function (element) {
|
|
5091
5103
|
return getAccessibleLabel(element).toLowerCase()[0] ===
|
|
5092
5104
|
event.key.toLowerCase();
|
|
@@ -5094,7 +5106,7 @@ function useMnemonics(_a) {
|
|
|
5094
5106
|
if (!matchingElements.length) {
|
|
5095
5107
|
return;
|
|
5096
5108
|
}
|
|
5097
|
-
var currentActiveElement = getActiveElement(
|
|
5109
|
+
var currentActiveElement = getActiveElement(currentContainer);
|
|
5098
5110
|
var nextActiveElement = null;
|
|
5099
5111
|
if (currentActiveElement) {
|
|
5100
5112
|
nextActiveElement = matchingElements.find(function (element) {
|
|
@@ -5108,17 +5120,15 @@ function useMnemonics(_a) {
|
|
|
5108
5120
|
onMatch(nextActiveElement !== null && nextActiveElement !== void 0 ? nextActiveElement : matchingElements[0]);
|
|
5109
5121
|
}
|
|
5110
5122
|
};
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
return function () { return container.removeEventListener('keydown', keyboardHandler); };
|
|
5123
|
+
listenerTarget.addEventListener('keydown', keyboardHandler);
|
|
5124
|
+
return function () { return listenerTarget.removeEventListener('keydown', keyboardHandler); };
|
|
5114
5125
|
}, [enabled, containerRef, matchingElementsSelector, onMatch]);
|
|
5115
5126
|
return containerRef;
|
|
5116
5127
|
}
|
|
5117
5128
|
|
|
5118
5129
|
var ActionList = React.forwardRef(function (_a, ref) {
|
|
5119
5130
|
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"]);
|
|
5120
|
-
var
|
|
5121
|
-
var activeElement = React.useRef();
|
|
5131
|
+
var activeElement = React.useRef(null);
|
|
5122
5132
|
var _c = tslib.__read(React.useState(), 2), activeOption = _c[0], setActiveOption = _c[1];
|
|
5123
5133
|
var handleActiveChange = React.useCallback(function (value) {
|
|
5124
5134
|
activeElement.current = value === null || value === void 0 ? void 0 : value.element;
|
|
@@ -5139,12 +5149,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
|
|
|
5139
5149
|
? '[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio]'
|
|
5140
5150
|
: '[role=option]'
|
|
5141
5151
|
});
|
|
5142
|
-
return (
|
|
5143
|
-
// Note: we should be able to use listbox without passing a prop
|
|
5144
|
-
// value for "multiselect"
|
|
5145
|
-
// see: https://github.com/dequelabs/cauldron/issues/1890
|
|
5146
|
-
// @ts-expect-error this should be allowed
|
|
5147
|
-
React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
|
|
5152
|
+
return (React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
|
|
5148
5153
|
if (ref) {
|
|
5149
5154
|
setRef(ref, element);
|
|
5150
5155
|
}
|
|
@@ -5153,7 +5158,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
|
|
|
5153
5158
|
/* Listbox comes with an explicit role of "listbox", but we want to either
|
|
5154
5159
|
* use the role from props, or default to the intrinsic role */
|
|
5155
5160
|
// eslint-disable-next-line jsx-a11y/aria-role
|
|
5156
|
-
role: undefined, "aria-multiselectable":
|
|
5161
|
+
role: undefined, "aria-multiselectable": undefined, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, { onActiveChange: handleActiveChange, navigation: "bound" }),
|
|
5157
5162
|
React__default["default"].createElement(ActionListProvider, { role: props.role || 'list', onAction: handleAction, selectionType: selectionType }, children)));
|
|
5158
5163
|
});
|
|
5159
5164
|
ActionList.displayName = 'ActionList';
|
|
@@ -5171,7 +5176,7 @@ var ActionListItem = React.forwardRef(function (_a, ref) {
|
|
|
5171
5176
|
});
|
|
5172
5177
|
var isActive = !!(active === null || active === void 0 ? void 0 : active.element) && active.element === actionListItemRef.current;
|
|
5173
5178
|
var handleAction = React.useCallback(function (event) {
|
|
5174
|
-
var _a;
|
|
5179
|
+
var _a, _b;
|
|
5175
5180
|
if (event.defaultPrevented) {
|
|
5176
5181
|
return;
|
|
5177
5182
|
}
|
|
@@ -5184,7 +5189,7 @@ var ActionListItem = React.forwardRef(function (_a, ref) {
|
|
|
5184
5189
|
}
|
|
5185
5190
|
// istanbul ignore else
|
|
5186
5191
|
if (typeof onActionListAction === 'function') {
|
|
5187
|
-
onActionListAction(actionKey || ((_a = labelRef === null ||
|
|
5192
|
+
onActionListAction(actionKey || ((_b = (_a = labelRef.current) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '', event);
|
|
5188
5193
|
}
|
|
5189
5194
|
}, [onAction, onActionListAction, selectionType, actionKey]);
|
|
5190
5195
|
var listItemRole = undefined;
|
|
@@ -5208,7 +5213,7 @@ var ActionListItem = React.forwardRef(function (_a, ref) {
|
|
|
5208
5213
|
// istanbul ignore next
|
|
5209
5214
|
React.useLayoutEffect(function () {
|
|
5210
5215
|
var intersectionEntry = intersectionRef.current;
|
|
5211
|
-
if (!intersectionEntry || !isActive) {
|
|
5216
|
+
if (!intersectionEntry || !isActive || !actionListItemRef.current) {
|
|
5212
5217
|
return;
|
|
5213
5218
|
}
|
|
5214
5219
|
var rect = actionListItemRef.current.getBoundingClientRect();
|
|
@@ -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
1
|
import { MutableRefObject, 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 MutableRefObject<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>): MutableRefObject<T | null>;
|
package/package.json
CHANGED