@deque/cauldron-react 7.5.0 → 7.6.0-canary.f34365cc
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/index.js +68 -14
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -1659,7 +1659,11 @@ var DialogContent = function (_a) {
|
|
|
1659
1659
|
'text--align-left': align === 'left',
|
|
1660
1660
|
'text--align-center': align === 'center',
|
|
1661
1661
|
'text--align-right': align === 'right'
|
|
1662
|
-
}),
|
|
1662
|
+
}),
|
|
1663
|
+
// A keyboard user can only scroll this region if it is tabbable (WCAG
|
|
1664
|
+
// 2.1.1). The rule allows that on role="tabpanel" only. See #680.
|
|
1665
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
1666
|
+
tabIndex: (context === null || context === void 0 ? void 0 : context.scrollable) ? 0 : undefined }, other), children));
|
|
1663
1667
|
};
|
|
1664
1668
|
DialogContent.displayName = 'DialogContent';
|
|
1665
1669
|
var DialogFooter = function (_a) {
|
|
@@ -1882,6 +1886,12 @@ var preventTopOverflowMiddleware = {
|
|
|
1882
1886
|
});
|
|
1883
1887
|
}
|
|
1884
1888
|
};
|
|
1889
|
+
// Element-resize tracking is split out of `whileElementsMounted` so it can be
|
|
1890
|
+
// scoped to the open state. This function's identity must stay stable:
|
|
1891
|
+
// floating-ui keys its positioning effect on whether one was passed, and a
|
|
1892
|
+
// re-run calls `update()` again, which on close pulls focus back out of the
|
|
1893
|
+
// trigger.
|
|
1894
|
+
var autoUpdateWithoutElementResize = function (reference, floating, update) { return dom.autoUpdate(reference, floating, update, { elementResize: false }); };
|
|
1885
1895
|
var AnchoredOverlay = React.forwardRef(function (_a, refProp) {
|
|
1886
1896
|
var _b, _c;
|
|
1887
1897
|
var as = _a.as, _d = _a.placement, initialPlacement = _d === void 0 ? 'auto' : _d, target = _a.target, children = _a.children, style = _a.style, _e = _a.open, open = _e === void 0 ? false : _e, offset = _a.offset, focusTrap = _a.focusTrap, focusTrapOptions = _a.focusTrapOptions, onOpenChange = _a.onOpenChange, onPlacementChange = _a.onPlacementChange, onShiftChange = _a.onShiftChange, portal = _a.portal, props = tslib.__rest(_a, ["as", "placement", "target", "children", "style", "open", "offset", "focusTrap", "focusTrapOptions", "onOpenChange", "onPlacementChange", "onShiftChange", "portal"]);
|
|
@@ -1910,8 +1920,35 @@ var AnchoredOverlay = React.forwardRef(function (_a, refProp) {
|
|
|
1910
1920
|
elements: {
|
|
1911
1921
|
reference: resolveElement(target)
|
|
1912
1922
|
},
|
|
1913
|
-
whileElementsMounted:
|
|
1914
|
-
}), refs = _f.refs, floatingStyles = _f.floatingStyles, placement = _f.placement, middlewareData = _f.middlewareData;
|
|
1923
|
+
whileElementsMounted: autoUpdateWithoutElementResize
|
|
1924
|
+
}), refs = _f.refs, floatingStyles = _f.floatingStyles, placement = _f.placement, middlewareData = _f.middlewareData, update = _f.update, elements = _f.elements;
|
|
1925
|
+
// Observing the target while the overlay is closed measures it for the
|
|
1926
|
+
// first time mid-layout, which leaves a ResizeObserver notification
|
|
1927
|
+
// undelivered and has the browser report an uncaught error.
|
|
1928
|
+
React.useEffect(function () {
|
|
1929
|
+
var reference = elements.reference, floating = elements.floating;
|
|
1930
|
+
if (!open ||
|
|
1931
|
+
!reference ||
|
|
1932
|
+
!floating ||
|
|
1933
|
+
typeof ResizeObserver !== 'function') {
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
// Deferred a task: starting it re-positions, and a render in the middle
|
|
1937
|
+
// of the open sequence loses the overlay's initial focus target.
|
|
1938
|
+
var stopObserving;
|
|
1939
|
+
var timeout = setTimeout(function () {
|
|
1940
|
+
stopObserving = dom.autoUpdate(reference, floating, update, {
|
|
1941
|
+
ancestorScroll: false,
|
|
1942
|
+
ancestorResize: false,
|
|
1943
|
+
layoutShift: false,
|
|
1944
|
+
elementResize: true
|
|
1945
|
+
});
|
|
1946
|
+
});
|
|
1947
|
+
return function () {
|
|
1948
|
+
clearTimeout(timeout);
|
|
1949
|
+
stopObserving === null || stopObserving === void 0 ? void 0 : stopObserving();
|
|
1950
|
+
};
|
|
1951
|
+
}, [open, elements, update]);
|
|
1915
1952
|
useEscapeKey({
|
|
1916
1953
|
active: open,
|
|
1917
1954
|
capture: true,
|
|
@@ -3783,6 +3820,20 @@ var Listbox = React.forwardRef(function (_a, ref) {
|
|
|
3783
3820
|
var listboxRef = useSharedRef(ref);
|
|
3784
3821
|
var isControlled = typeof value !== 'undefined';
|
|
3785
3822
|
var isActiveControlled = typeof controlledActiveOption !== 'undefined';
|
|
3823
|
+
var hasActiveChangeHandler = typeof onActiveChange === 'function';
|
|
3824
|
+
React.useEffect(function () {
|
|
3825
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
3826
|
+
isActiveControlled &&
|
|
3827
|
+
hasActiveChangeHandler) {
|
|
3828
|
+
console.warn('Listbox received both `activeOption` and `onActiveChange`. Do not ' +
|
|
3829
|
+
'write the option reported by `onActiveChange` back into ' +
|
|
3830
|
+
'`activeOption`: the two copies then race, and a stale downward ' +
|
|
3831
|
+
'sync can revert a newer value and re-render without settling. ' +
|
|
3832
|
+
'Let Listbox own the active option, or use `activeOption` only as ' +
|
|
3833
|
+
'a one-shot request. ' +
|
|
3834
|
+
'See https://github.com/dequelabs/cauldron/issues/2512');
|
|
3835
|
+
}
|
|
3836
|
+
}, [isActiveControlled, hasActiveChangeHandler]);
|
|
3786
3837
|
React.useLayoutEffect(function () {
|
|
3787
3838
|
if (!isControlled && selectedOptions.length > 0) {
|
|
3788
3839
|
return;
|
|
@@ -3924,7 +3975,7 @@ var Listbox = React.forwardRef(function (_a, ref) {
|
|
|
3924
3975
|
var firstOption = !focusDisabledOptions
|
|
3925
3976
|
? options.find(function (option) { return !isDisabledOption(option); })
|
|
3926
3977
|
: options[0];
|
|
3927
|
-
if (firstOption) {
|
|
3978
|
+
if (firstOption && firstOption.element !== (activeOption === null || activeOption === void 0 ? void 0 : activeOption.element)) {
|
|
3928
3979
|
setActiveOption(firstOption);
|
|
3929
3980
|
}
|
|
3930
3981
|
return;
|
|
@@ -3933,7 +3984,7 @@ var Listbox = React.forwardRef(function (_a, ref) {
|
|
|
3933
3984
|
var lastOption = !focusDisabledOptions
|
|
3934
3985
|
? tslib.__spreadArray([], tslib.__read(options), false).reverse().find(function (option) { return !isDisabledOption(option); })
|
|
3935
3986
|
: options[options.length - 1];
|
|
3936
|
-
if (lastOption) {
|
|
3987
|
+
if (lastOption && lastOption.element !== (activeOption === null || activeOption === void 0 ? void 0 : activeOption.element)) {
|
|
3937
3988
|
setActiveOption(lastOption);
|
|
3938
3989
|
}
|
|
3939
3990
|
return;
|
|
@@ -5154,21 +5205,24 @@ function useMnemonics(_a) {
|
|
|
5154
5205
|
|
|
5155
5206
|
var ActionList = React.forwardRef(function (_a, ref) {
|
|
5156
5207
|
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"]);
|
|
5157
|
-
|
|
5208
|
+
// Listbox owns the active option. ActionList must not mirror it back down
|
|
5209
|
+
// as a controlled prop: the two copies then race, and a downward sync
|
|
5210
|
+
// carrying an already-stale value can revert a newer one and oscillate.
|
|
5211
|
+
// `activeOption` below is only a one-shot mnemonic request, never a
|
|
5212
|
+
// mirror. See cauldron#2512; cauldron#2522 tracks making `activeOption`
|
|
5213
|
+
// properly controlled so this constraint lives in the interface instead.
|
|
5158
5214
|
var _c = tslib.__read(React.useState(), 2), activeOption = _c[0], setActiveOption = _c[1];
|
|
5159
|
-
var handleActiveChange = React.useCallback(function (value) {
|
|
5160
|
-
activeElement.current = value === null || value === void 0 ? void 0 : value.element;
|
|
5161
|
-
setActiveOption(value);
|
|
5162
|
-
}, []);
|
|
5163
5215
|
var handleAction = React.useCallback(function (key, event) {
|
|
5164
5216
|
if (typeof onAction === 'function') {
|
|
5165
5217
|
onAction(key, event);
|
|
5166
5218
|
}
|
|
5167
5219
|
}, [onAction]);
|
|
5220
|
+
// A new object every match, even for the same element: this is a one-shot
|
|
5221
|
+
// request to Listbox rather than a mirror of its state, so re-using the
|
|
5222
|
+
// previous object would leave the controlled prop unchanged and the
|
|
5223
|
+
// request would never reach Listbox.
|
|
5168
5224
|
var handleMnemonicMatch = React.useCallback(function (element) {
|
|
5169
|
-
setActiveOption(
|
|
5170
|
-
return (prev === null || prev === void 0 ? void 0 : prev.element) === element ? prev : { element: element };
|
|
5171
|
-
});
|
|
5225
|
+
setActiveOption({ element: element });
|
|
5172
5226
|
}, []);
|
|
5173
5227
|
var containerRef = useMnemonics({
|
|
5174
5228
|
onMatch: handleMnemonicMatch,
|
|
@@ -5185,7 +5239,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
|
|
|
5185
5239
|
/* Listbox comes with an explicit role of "listbox", but we want to either
|
|
5186
5240
|
* use the role from props, or default to the intrinsic role */
|
|
5187
5241
|
// eslint-disable-next-line jsx-a11y/aria-role
|
|
5188
|
-
role: undefined, "aria-multiselectable": undefined, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, {
|
|
5242
|
+
role: undefined, "aria-multiselectable": undefined, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, { navigation: "bound" }),
|
|
5189
5243
|
React__default["default"].createElement(ActionListProvider, { role: props.role || 'list', onAction: handleAction, selectionType: selectionType }, children)));
|
|
5190
5244
|
});
|
|
5191
5245
|
ActionList.displayName = 'ActionList';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deque/cauldron-react",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0-canary.f34365cc",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Fully accessible react components library for Deque Cauldron",
|
|
6
6
|
"homepage": "https://cauldron.dequelabs.com/",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"classnames": "^2.2.6",
|
|
20
20
|
"focusable": "^2.3.0",
|
|
21
21
|
"keyname": "^0.1.0",
|
|
22
|
-
"react-aria-components": "^1.
|
|
22
|
+
"react-aria-components": "^1.19.0",
|
|
23
23
|
"react-id-generator": "^3.0.1",
|
|
24
24
|
"react-syntax-highlighter": "^16.1.1",
|
|
25
25
|
"tslib": "^2.4.0"
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@rollup/plugin-typescript": "^11.1.2",
|
|
38
38
|
"@svgr/rollup": "^6.1.2",
|
|
39
39
|
"@testing-library/dom": "^10.4.0",
|
|
40
|
-
"@testing-library/jest-dom": "^
|
|
40
|
+
"@testing-library/jest-dom": "^7.0.0",
|
|
41
41
|
"@testing-library/react": "^16.0.1",
|
|
42
|
-
"@testing-library/user-event": "^14.
|
|
42
|
+
"@testing-library/user-event": "^14.6.7",
|
|
43
43
|
"@types/classnames": "^2.2.10",
|
|
44
44
|
"@types/jest": "^29.5.11",
|
|
45
45
|
"@types/jest-axe": "^3.5.4",
|