@deque/cauldron-react 6.9.0 → 6.10.0
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,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export interface OptionsMenuAlignmentProps {
|
|
3
3
|
align?: 'left' | 'right';
|
|
4
4
|
}
|
|
@@ -19,21 +19,6 @@ export interface OptionsMenuProps extends OptionsMenuAlignmentProps {
|
|
|
19
19
|
show?: boolean;
|
|
20
20
|
children: React.ReactNode;
|
|
21
21
|
}
|
|
22
|
-
interface OptionsMenuState {
|
|
23
|
-
show: boolean;
|
|
24
|
-
}
|
|
25
22
|
type AllOptionsMenuProps = OptionsMenuProps & React.HTMLAttributes<HTMLLIElement>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
onClose: () => void;
|
|
29
|
-
onSelect: () => void;
|
|
30
|
-
align: string;
|
|
31
|
-
};
|
|
32
|
-
private triggerRef;
|
|
33
|
-
constructor(props: AllOptionsMenuProps);
|
|
34
|
-
toggleMenu: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
35
|
-
handleClose: () => void;
|
|
36
|
-
handleTriggerKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
37
|
-
render(): React.JSX.Element;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
|
23
|
+
declare const OptionsMenu: ({ children, className, closeOnSelect, menuRef, trigger, align, onClose, onSelect, ...other }: AllOptionsMenuProps) => React.JSX.Element;
|
|
24
|
+
export default OptionsMenu;
|
|
@@ -5,5 +5,5 @@ export interface OptionsMenuItemProps extends Pick<React.HTMLAttributes<HTMLLIEl
|
|
|
5
5
|
menuItemRef?: React.Ref<HTMLLIElement>;
|
|
6
6
|
onSelect: (e: React.MouseEvent<HTMLElement>) => void;
|
|
7
7
|
}
|
|
8
|
-
declare const
|
|
9
|
-
export default
|
|
8
|
+
declare const OptionsMenuItem: React.ForwardRefExoticComponent<OptionsMenuItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
9
|
+
export default OptionsMenuItem;
|
|
@@ -3,24 +3,5 @@ import { OptionsMenuProps } from './OptionsMenu';
|
|
|
3
3
|
export interface OptionsMenuListProps extends Omit<OptionsMenuProps, 'trigger'> {
|
|
4
4
|
className?: string;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export default class OptionsMenuList extends React.Component<OptionsMenuListProps, OptionsMenuListState> {
|
|
10
|
-
static defaultProps: {
|
|
11
|
-
closeOnSelect: boolean;
|
|
12
|
-
onSelect: () => void;
|
|
13
|
-
onClose: () => void;
|
|
14
|
-
};
|
|
15
|
-
private itemRefs;
|
|
16
|
-
private menuRef;
|
|
17
|
-
constructor(props: OptionsMenuProps);
|
|
18
|
-
componentDidUpdate(prevProps: OptionsMenuProps, prevState: OptionsMenuListState): void;
|
|
19
|
-
private handleKeyDown;
|
|
20
|
-
private handleClick;
|
|
21
|
-
private handleClickOutside;
|
|
22
|
-
componentDidMount(): void;
|
|
23
|
-
componentWillUnmount(): void;
|
|
24
|
-
render(): React.JSX.Element;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
|
6
|
+
declare const OptionsMenuList: ({ children, menuRef, show, className, onClose, onSelect, closeOnSelect, ...other }: OptionsMenuListProps) => React.JSX.Element;
|
|
7
|
+
export default OptionsMenuList;
|
package/lib/index.js
CHANGED
|
@@ -841,14 +841,14 @@ function ClickOutsideListener(_a, ref) {
|
|
|
841
841
|
};
|
|
842
842
|
React.useEffect(function () {
|
|
843
843
|
typeof mouseEvent === 'string' &&
|
|
844
|
-
document.addEventListener(mouseEvent, handleEvent);
|
|
844
|
+
document.addEventListener(mouseEvent, handleEvent, true);
|
|
845
845
|
typeof touchEvent === 'string' &&
|
|
846
|
-
document.addEventListener(touchEvent, handleEvent);
|
|
846
|
+
document.addEventListener(touchEvent, handleEvent, true);
|
|
847
847
|
return function () {
|
|
848
848
|
typeof mouseEvent === 'string' &&
|
|
849
|
-
document.removeEventListener(mouseEvent, handleEvent);
|
|
849
|
+
document.removeEventListener(mouseEvent, handleEvent, true);
|
|
850
850
|
typeof touchEvent === 'string' &&
|
|
851
|
-
document.removeEventListener(touchEvent, handleEvent);
|
|
851
|
+
document.removeEventListener(touchEvent, handleEvent, true);
|
|
852
852
|
};
|
|
853
853
|
}, [mouseEvent, touchEvent]);
|
|
854
854
|
return !children
|
|
@@ -859,216 +859,174 @@ ClickOutsideListener.displayName = 'ClickOutsideListener';
|
|
|
859
859
|
var ClickOutsideListener$1 = React__default["default"].forwardRef(ClickOutsideListener);
|
|
860
860
|
|
|
861
861
|
var _a$2 = tslib.__read([38, 40, 9, 13, 32, 27], 6), up = _a$2[0], down$1 = _a$2[1], tab = _a$2[2], enter = _a$2[3], space = _a$2[4], esc = _a$2[5];
|
|
862
|
-
var OptionsMenuList =
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
862
|
+
var OptionsMenuList = function (_a) {
|
|
863
|
+
var children = _a.children, menuRef = _a.menuRef, show = _a.show, className = _a.className, _b = _a.onClose, onClose = _b === void 0 ? function () { } : _b, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
864
|
+
_c = _a.onSelect, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
865
|
+
onSelect = _c === void 0 ? function () { } : _c, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
866
|
+
_d = _a.closeOnSelect, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
867
|
+
closeOnSelect = _d === void 0 ? true : _d, other = tslib.__rest(_a, ["children", "menuRef", "show", "className", "onClose", "onSelect", "closeOnSelect"]);
|
|
868
|
+
var _e = tslib.__read(React.useState(0), 2), itemIndex = _e[0], setItemIndex = _e[1];
|
|
869
|
+
var itemRefs = React.useRef([]);
|
|
870
|
+
var menuRefInternal = React.useRef(null);
|
|
871
|
+
var triggerRef = React.useRef(null);
|
|
872
|
+
React.useEffect(function () {
|
|
873
|
+
var _a;
|
|
874
|
+
if (show && itemRefs.current.length) {
|
|
875
|
+
// handles opens
|
|
876
|
+
triggerRef.current = document.activeElement;
|
|
877
|
+
(_a = itemRefs.current[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
878
|
+
setItemIndex(0);
|
|
879
|
+
}
|
|
880
|
+
if (!show) {
|
|
881
|
+
triggerRef.current = null;
|
|
882
|
+
}
|
|
883
|
+
}, [show]);
|
|
884
|
+
React.useEffect(function () {
|
|
885
|
+
var _a;
|
|
886
|
+
(_a = itemRefs.current[itemIndex]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
887
|
+
}, [itemIndex]);
|
|
888
|
+
var handleKeyDown = function (e) {
|
|
889
|
+
var which = e.which, target = e.target;
|
|
890
|
+
switch (which) {
|
|
891
|
+
case up:
|
|
892
|
+
case down$1: {
|
|
893
|
+
var itemCount = itemRefs.current.length;
|
|
894
|
+
var newIndex = which === 38 ? itemIndex - 1 : itemIndex + 1;
|
|
895
|
+
// circularity
|
|
896
|
+
if (newIndex === -1) {
|
|
897
|
+
newIndex = itemCount - 1;
|
|
887
898
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
break;
|
|
891
|
-
case enter:
|
|
892
|
-
case space:
|
|
893
|
-
e.preventDefault();
|
|
894
|
-
target.click();
|
|
895
|
-
break;
|
|
896
|
-
case tab:
|
|
897
|
-
e.preventDefault();
|
|
898
|
-
onClose();
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
_this.handleClick = function (e) {
|
|
902
|
-
var _a = _this, menuRef = _a.menuRef, props = _a.props;
|
|
903
|
-
var onSelect = props.onSelect, _b = props.onClose, onClose = _b === void 0 ? OptionsMenuList.defaultProps.onClose : _b;
|
|
904
|
-
if (menuRef && menuRef.contains(e.target)) {
|
|
905
|
-
if (!e.defaultPrevented && props.closeOnSelect) {
|
|
906
|
-
onClose();
|
|
899
|
+
else if (newIndex === itemCount) {
|
|
900
|
+
newIndex = 0;
|
|
907
901
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
if (link) {
|
|
912
|
-
link.click();
|
|
902
|
+
e.preventDefault();
|
|
903
|
+
setItemIndex(newIndex);
|
|
904
|
+
break;
|
|
913
905
|
}
|
|
906
|
+
case esc:
|
|
907
|
+
onClose();
|
|
908
|
+
break;
|
|
909
|
+
case enter:
|
|
910
|
+
case space:
|
|
911
|
+
e.preventDefault();
|
|
912
|
+
target.click();
|
|
913
|
+
break;
|
|
914
|
+
case tab:
|
|
915
|
+
e.preventDefault();
|
|
916
|
+
onClose();
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
React.useEffect(function () {
|
|
920
|
+
var currentMenuRef = menuRefInternal.current;
|
|
921
|
+
currentMenuRef === null || currentMenuRef === void 0 ? void 0 : currentMenuRef.addEventListener('keydown', handleKeyDown);
|
|
922
|
+
return function () {
|
|
923
|
+
currentMenuRef === null || currentMenuRef === void 0 ? void 0 : currentMenuRef.removeEventListener('keydown', handleKeyDown);
|
|
914
924
|
};
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
925
|
+
}, [handleKeyDown]);
|
|
926
|
+
var handleClick = function (e) {
|
|
927
|
+
if (menuRefInternal.current &&
|
|
928
|
+
menuRefInternal.current.contains(e.target)) {
|
|
929
|
+
if (!e.defaultPrevented && closeOnSelect) {
|
|
918
930
|
onClose();
|
|
919
931
|
}
|
|
920
|
-
|
|
921
|
-
_this.itemRefs = [];
|
|
922
|
-
_this.state = { itemIndex: 0 };
|
|
923
|
-
return _this;
|
|
924
|
-
}
|
|
925
|
-
OptionsMenuList.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
926
|
-
var _a, _b;
|
|
927
|
-
var itemIndex = this.state.itemIndex;
|
|
928
|
-
var show = this.props.show;
|
|
929
|
-
if (!prevProps.show && show && this.itemRefs.length) {
|
|
930
|
-
// handles opens
|
|
931
|
-
(_a = this.itemRefs[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
932
|
-
this.setState({ itemIndex: 0 });
|
|
932
|
+
onSelect(e);
|
|
933
933
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
934
|
+
var link = e.target.querySelector('a');
|
|
935
|
+
if (link) {
|
|
936
|
+
link.click();
|
|
937
937
|
}
|
|
938
938
|
};
|
|
939
|
-
|
|
940
|
-
var
|
|
941
|
-
|
|
942
|
-
(
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
var _this = this;
|
|
950
|
-
var _a = this, props = _a.props, handleClick = _a.handleClick;
|
|
951
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
952
|
-
var children = props.children, menuRef = props.menuRef, show = props.show, className = props.className; props.onClose; props.onSelect; props.closeOnSelect; var other = tslib.__rest(props, ["children", "menuRef", "show", "className", "onClose", "onSelect", "closeOnSelect"]);
|
|
953
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
954
|
-
var items = React__default["default"].Children.toArray(children).map(function (child, i) {
|
|
955
|
-
var _a = child.props, className = _a.className, other = tslib.__rest(_a, ["className"]);
|
|
956
|
-
return React__default["default"].cloneElement(child, tslib.__assign({ key: "list-item-".concat(i), className: classNames__default["default"]('OptionsMenu__list-item', className), tabIndex: -1, role: 'menuitem', ref: function (el) { return (_this.itemRefs[i] = el); } }, other));
|
|
957
|
-
});
|
|
958
|
-
// This allows the ClickOutsideListener to only be activated when the menu is
|
|
959
|
-
// currently open. This prevents an obscure behavior where the activation of a
|
|
960
|
-
// different menu would cause all menus to close
|
|
961
|
-
var clickOutsideEventActive = !show ? false : undefined;
|
|
962
|
-
// Key event is being handled in componentDidMount
|
|
963
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
964
|
-
/* eslint-disable jsx-a11y/role-supports-aria-props */
|
|
965
|
-
return (React__default["default"].createElement(ClickOutsideListener$1, { onClickOutside: this.handleClickOutside, mouseEvent: clickOutsideEventActive, touchEvent: clickOutsideEventActive },
|
|
966
|
-
React__default["default"].createElement("ul", tslib.__assign({}, other, { className: classNames__default["default"]('OptionsMenu__list', className), "aria-expanded": show, role: "menu", onClick: handleClick, ref: function (el) {
|
|
967
|
-
_this.menuRef = el;
|
|
968
|
-
if (menuRef) {
|
|
969
|
-
setRef(menuRef, el);
|
|
970
|
-
}
|
|
971
|
-
} }), items)));
|
|
972
|
-
/* eslint-enable jsx-a11y/click-events-have-key-events */
|
|
973
|
-
};
|
|
974
|
-
OptionsMenuList.defaultProps = {
|
|
975
|
-
closeOnSelect: true,
|
|
976
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
977
|
-
onSelect: function () { },
|
|
978
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
979
|
-
onClose: function () { }
|
|
939
|
+
var handleClickOutside = function (e) {
|
|
940
|
+
var target = e.target;
|
|
941
|
+
var triggerElement = triggerRef.current;
|
|
942
|
+
if (target === triggerElement || (triggerElement === null || triggerElement === void 0 ? void 0 : triggerElement.contains(target))) {
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
if (show) {
|
|
946
|
+
e.preventDefault();
|
|
947
|
+
onClose();
|
|
948
|
+
}
|
|
980
949
|
};
|
|
981
|
-
|
|
982
|
-
|
|
950
|
+
var items = React__default["default"].Children.toArray(children).map(function (child, i) {
|
|
951
|
+
var _a = child.props, childClassName = _a.className, childProps = tslib.__rest(_a, ["className"]);
|
|
952
|
+
return React__default["default"].cloneElement(child, tslib.__assign({ key: "list-item-".concat(i), className: classNames__default["default"]('OptionsMenu__list-item', childClassName), tabIndex: -1, role: 'menuitem', ref: function (el) { return (itemRefs.current[i] = el); } }, childProps));
|
|
953
|
+
});
|
|
954
|
+
// This allows the ClickOutsideListener to only be activated when the menu is
|
|
955
|
+
// currently open. This prevents an obscure behavior where the activation of a
|
|
956
|
+
// different menu would cause all menus to close
|
|
957
|
+
var clickOutsideEventActive = !show ? false : undefined;
|
|
958
|
+
// Key event is being handled in the useEffect above
|
|
959
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
960
|
+
/* eslint-disable jsx-a11y/role-supports-aria-props */
|
|
961
|
+
return (React__default["default"].createElement(ClickOutsideListener$1, { onClickOutside: handleClickOutside, mouseEvent: clickOutsideEventActive, touchEvent: clickOutsideEventActive },
|
|
962
|
+
React__default["default"].createElement("ul", tslib.__assign({}, other, { className: classNames__default["default"]('OptionsMenu__list', className), "aria-expanded": show, role: "menu", onClick: handleClick, ref: function (el) {
|
|
963
|
+
menuRefInternal.current = el;
|
|
964
|
+
if (menuRef) {
|
|
965
|
+
setRef(menuRef, el);
|
|
966
|
+
}
|
|
967
|
+
} }), items)));
|
|
968
|
+
};
|
|
983
969
|
|
|
984
970
|
var _a$1 = tslib.__read([40], 1), down = _a$1[0];
|
|
985
|
-
var OptionsMenu =
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
var _b = _this.props.onClose, onClose = _b === void 0 ? OptionsMenu.defaultProps.onClose : _b;
|
|
998
|
-
_this.setState({ show: false });
|
|
999
|
-
onClose();
|
|
1000
|
-
(_a = _this.triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1001
|
-
};
|
|
1002
|
-
_this.handleTriggerKeyDown = function (event) {
|
|
1003
|
-
var which = event.which, target = event.target;
|
|
1004
|
-
if (which === down) {
|
|
1005
|
-
event.preventDefault();
|
|
1006
|
-
target.click();
|
|
1007
|
-
}
|
|
1008
|
-
};
|
|
1009
|
-
_this.state = { show: false };
|
|
1010
|
-
_this.triggerRef = React__default["default"].createRef();
|
|
1011
|
-
return _this;
|
|
1012
|
-
}
|
|
1013
|
-
OptionsMenu.prototype.render = function () {
|
|
1014
|
-
var _a = this, toggleMenu = _a.toggleMenu, triggerRef = _a.triggerRef, handleTriggerKeyDown = _a.handleTriggerKeyDown;
|
|
1015
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1016
|
-
var _b = this.props, children = _b.children, className = _b.className; _b.closeOnSelect; var menuRef = _b.menuRef, trigger = _b.trigger, align = _b.align; _b.onClose; var other = tslib.__rest(_b, ["children", "className", "closeOnSelect", "menuRef", "trigger", "align", "onClose"]);
|
|
1017
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
1018
|
-
var show = this.state.show;
|
|
1019
|
-
return (React__default["default"].createElement(OptionsMenuWrapper, { align: align, className: className },
|
|
1020
|
-
trigger &&
|
|
1021
|
-
trigger({
|
|
1022
|
-
onClick: toggleMenu,
|
|
1023
|
-
'aria-expanded': show,
|
|
1024
|
-
ref: triggerRef,
|
|
1025
|
-
onKeyDown: handleTriggerKeyDown
|
|
1026
|
-
}),
|
|
1027
|
-
React__default["default"].createElement(OptionsMenuList, tslib.__assign({ show: show, menuRef: function (el) {
|
|
1028
|
-
if (menuRef) {
|
|
1029
|
-
setRef(menuRef, el);
|
|
1030
|
-
}
|
|
1031
|
-
}, onClose: this.handleClose }, other), children)));
|
|
971
|
+
var OptionsMenu = function (_a) {
|
|
972
|
+
var children = _a.children, className = _a.className; _a.closeOnSelect; var menuRef = _a.menuRef, trigger = _a.trigger, _b = _a.align, align = _b === void 0 ? 'right' : _b, _c = _a.onClose, onClose = _c === void 0 ? function () { } : _c, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
973
|
+
_d = _a.onSelect, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
974
|
+
onSelect = _d === void 0 ? function () { } : _d, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
975
|
+
other = tslib.__rest(_a, ["children", "className", "closeOnSelect", "menuRef", "trigger", "align", "onClose", "onSelect"]);
|
|
976
|
+
var _e = tslib.__read(React.useState(false), 2), show = _e[0], setShow = _e[1];
|
|
977
|
+
var triggerRef = React.useRef(null);
|
|
978
|
+
var toggleMenu = function (e) {
|
|
979
|
+
if (e.defaultPrevented) {
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
setShow(!show);
|
|
1032
983
|
};
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
align: 'right'
|
|
984
|
+
var handleClose = function () {
|
|
985
|
+
var _a;
|
|
986
|
+
setShow(false);
|
|
987
|
+
onClose();
|
|
988
|
+
(_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1039
989
|
};
|
|
1040
|
-
|
|
1041
|
-
|
|
990
|
+
var handleTriggerKeyDown = function (event) {
|
|
991
|
+
var which = event.which, target = event.target;
|
|
992
|
+
if (which === down) {
|
|
993
|
+
event.preventDefault();
|
|
994
|
+
target.click();
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
return (React__default["default"].createElement(OptionsMenuWrapper, { align: align, className: className },
|
|
998
|
+
trigger &&
|
|
999
|
+
trigger({
|
|
1000
|
+
onClick: toggleMenu,
|
|
1001
|
+
'aria-expanded': show,
|
|
1002
|
+
ref: triggerRef,
|
|
1003
|
+
onKeyDown: handleTriggerKeyDown
|
|
1004
|
+
}),
|
|
1005
|
+
React__default["default"].createElement(OptionsMenuList, tslib.__assign({ show: show, menuRef: function (el) {
|
|
1006
|
+
if (menuRef) {
|
|
1007
|
+
setRef(menuRef, el);
|
|
1008
|
+
}
|
|
1009
|
+
}, onClose: handleClose, onSelect: onSelect }, other), children)));
|
|
1010
|
+
};
|
|
1042
1011
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
onSelect(event);
|
|
1051
|
-
}
|
|
1052
|
-
};
|
|
1053
|
-
return _this;
|
|
1012
|
+
function OptionsMenuItemComponent(_a) {
|
|
1013
|
+
var disabled = _a.disabled, className = _a.className, menuItemRef = _a.menuItemRef, _b = _a.onSelect, onSelect = _b === void 0 ? function () { } : _b, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
1014
|
+
other = tslib.__rest(_a, ["disabled", "className", "menuItemRef", "onSelect"]);
|
|
1015
|
+
function handleClick(event) {
|
|
1016
|
+
if (!disabled) {
|
|
1017
|
+
onSelect(event);
|
|
1018
|
+
}
|
|
1054
1019
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
};
|
|
1063
|
-
OptionsMenuItemComponent.defaultProps = {
|
|
1064
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1065
|
-
onSelect: function () { }
|
|
1066
|
-
};
|
|
1067
|
-
return OptionsMenuItemComponent;
|
|
1068
|
-
}(React__default["default"].Component));
|
|
1069
|
-
var OptionsMenuItem = React__default["default"].forwardRef(function OptionsMenuItem(props, ref) {
|
|
1070
|
-
return React__default["default"].createElement(OptionsMenuItemComponent, tslib.__assign({ menuItemRef: ref }, props));
|
|
1020
|
+
return (
|
|
1021
|
+
// keydown happens in OptionsMenu which proxies to click
|
|
1022
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
1023
|
+
React__default["default"].createElement("li", tslib.__assign({ role: "menuitem", ref: menuItemRef, "aria-disabled": disabled, onClick: handleClick, className: className }, other)));
|
|
1024
|
+
}
|
|
1025
|
+
var OptionsMenuItem = React.forwardRef(function (_a, ref) {
|
|
1026
|
+
var props = tslib.__rest(_a, []);
|
|
1027
|
+
return (React__default["default"].createElement(OptionsMenuItemComponent, tslib.__assign({ menuItemRef: ref }, props)));
|
|
1071
1028
|
});
|
|
1029
|
+
OptionsMenuItem.displayName = 'OptionsMenuItem';
|
|
1072
1030
|
|
|
1073
1031
|
/**
|
|
1074
1032
|
* The trigger button component to be used as the default component
|
|
@@ -4112,7 +4070,10 @@ var Popover = React.forwardRef(function (_a, ref) {
|
|
|
4112
4070
|
targetElement === null || targetElement === void 0 ? void 0 : targetElement.setAttribute('aria-haspopup', 'true');
|
|
4113
4071
|
}
|
|
4114
4072
|
}, [targetElement, id, show]);
|
|
4115
|
-
var handleClickOutside = function () {
|
|
4073
|
+
var handleClickOutside = function (e) {
|
|
4074
|
+
if (e.target === targetElement) {
|
|
4075
|
+
return;
|
|
4076
|
+
}
|
|
4116
4077
|
if (show) {
|
|
4117
4078
|
handleClosePopover();
|
|
4118
4079
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deque/cauldron-react",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Fully accessible react components library for Deque Cauldron",
|
|
6
6
|
"homepage": "https://cauldron.dequelabs.com/",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@popperjs/core": "^2.5.4",
|
|
27
27
|
"classnames": "^2.2.6",
|
|
28
|
-
"focus-trap-react": "
|
|
28
|
+
"focus-trap-react": "^10.2.3",
|
|
29
29
|
"focusable": "^2.3.0",
|
|
30
30
|
"keyname": "^0.1.0",
|
|
31
31
|
"react-id-generator": "^3.0.1",
|
|
@@ -65,8 +65,9 @@
|
|
|
65
65
|
"postcss-cli": "^7.1.1",
|
|
66
66
|
"postcss-import": "^12.0.1",
|
|
67
67
|
"postcss-loader": "^3.0.0",
|
|
68
|
-
"
|
|
69
|
-
"react
|
|
68
|
+
"prop-types": "^15.8.1",
|
|
69
|
+
"react": "^17",
|
|
70
|
+
"react-dom": "^17",
|
|
70
71
|
"rollup": "^2.23.0",
|
|
71
72
|
"sinon": "^10.0.0",
|
|
72
73
|
"ts-node": "^10.9.2",
|