@deque/cauldron-react 7.1.0-canary.ec0e4309 → 7.1.0-canary.ec8ea670
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
|
@@ -5117,7 +5117,6 @@ function useMnemonics(_a) {
|
|
|
5117
5117
|
|
|
5118
5118
|
var ActionList = React.forwardRef(function (_a, ref) {
|
|
5119
5119
|
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 actionListContext = useActionListContext();
|
|
5121
5120
|
var activeElement = React.useRef();
|
|
5122
5121
|
var _c = tslib.__read(React.useState(), 2), activeOption = _c[0], setActiveOption = _c[1];
|
|
5123
5122
|
var handleActiveChange = React.useCallback(function (value) {
|
|
@@ -5139,12 +5138,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
|
|
|
5139
5138
|
? '[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio]'
|
|
5140
5139
|
: '[role=option]'
|
|
5141
5140
|
});
|
|
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) {
|
|
5141
|
+
return (React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
|
|
5148
5142
|
if (ref) {
|
|
5149
5143
|
setRef(ref, element);
|
|
5150
5144
|
}
|
|
@@ -5153,7 +5147,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
|
|
|
5153
5147
|
/* Listbox comes with an explicit role of "listbox", but we want to either
|
|
5154
5148
|
* use the role from props, or default to the intrinsic role */
|
|
5155
5149
|
// eslint-disable-next-line jsx-a11y/aria-role
|
|
5156
|
-
role: undefined, "aria-multiselectable":
|
|
5150
|
+
role: undefined, "aria-multiselectable": undefined, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, { onActiveChange: handleActiveChange, navigation: "bound" }),
|
|
5157
5151
|
React__default["default"].createElement(ActionListProvider, { role: props.role || 'list', onAction: handleAction, selectionType: selectionType }, children)));
|
|
5158
5152
|
});
|
|
5159
5153
|
ActionList.displayName = 'ActionList';
|
package/package.json
CHANGED