@linzjs/step-ag-grid 23.0.0 → 24.0.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.
- package/dist/src/components/ComponentLoadingWrapper.d.ts +1 -1
- package/dist/src/components/Grid.d.ts +17 -17
- package/dist/src/components/GridCell.d.ts +9 -9
- package/dist/src/components/GridCellFiller.d.ts +2 -2
- package/dist/src/components/GridCellMultiEditor.d.ts +6 -6
- package/dist/src/components/GridCellMultiSelectClassRules.d.ts +1 -1
- package/dist/src/components/GridIcon.d.ts +2 -2
- package/dist/src/components/GridNoRowsOverlay.d.ts +1 -1
- package/dist/src/components/GridPopoverHook.d.ts +2 -2
- package/dist/src/components/GridWrapper.d.ts +1 -1
- package/dist/src/components/PostSortRowsHook.d.ts +1 -1
- package/dist/src/components/clickInputWhenContainingCellClicked.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterButtons.d.ts +5 -5
- package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterDownloadCsvButton.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterHeaderIconButton.d.ts +2 -2
- package/dist/src/components/gridFilter/GridFilters.d.ts +1 -1
- package/dist/src/components/gridFilter/index.d.ts +7 -7
- package/dist/src/components/gridFilter/useGridFilter.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +8 -8
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormMessage.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +5 -5
- package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -3
- package/dist/src/components/gridForm/index.d.ts +10 -10
- package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +1 -1
- package/dist/src/components/gridHeader/index.d.ts +1 -1
- package/dist/src/components/gridHook/index.d.ts +1 -1
- package/dist/src/components/gridHook/useGridContextMenu.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridButton.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridEditBoolean.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/index.d.ts +11 -11
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +5 -5
- package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +1 -1
- package/dist/src/components/gridRender/index.d.ts +2 -2
- package/dist/src/components/gridUtil.d.ts +1 -1
- package/dist/src/components/index.d.ts +19 -19
- package/dist/src/contexts/GridContext.d.ts +4 -4
- package/dist/src/contexts/GridContextProvider.d.ts +3 -3
- package/dist/src/contexts/GridPopoverContext.d.ts +3 -3
- package/dist/src/contexts/GridPopoverContextProvider.d.ts +4 -4
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +1 -1
- package/dist/src/index.d.ts +17 -17
- package/dist/src/lui/ActionButton.d.ts +9 -9
- package/dist/src/lui/FormError.d.ts +2 -2
- package/dist/src/lui/TextAreaInput.d.ts +1 -1
- package/dist/src/lui/TextInputFormatted.d.ts +2 -2
- package/dist/src/lui/reactUtils.d.ts +1 -1
- package/dist/src/lui/stateDeferredHook.d.ts +1 -1
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +2 -2
- package/dist/src/react-menu3/components/FocusableItem.d.ts +3 -3
- package/dist/src/react-menu3/components/Menu.d.ts +3 -3
- package/dist/src/react-menu3/components/MenuButton.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuDivider.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuGroup.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuHeader.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuItem.d.ts +3 -3
- package/dist/src/react-menu3/components/MenuList.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -2
- package/dist/src/react-menu3/components/SubMenu.d.ts +5 -5
- package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +1 -1
- package/dist/src/react-menu3/contexts/MenuListContext.d.ts +2 -2
- package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +1 -1
- package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +1 -1
- package/dist/src/react-menu3/contexts/SettingsContext.d.ts +2 -2
- package/dist/src/react-menu3/hooks/index.d.ts +9 -9
- package/dist/src/react-menu3/hooks/useBEM.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useIsomorphicLayoutEffect.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useItemEffect.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useItemState.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useItems.d.ts +2 -2
- package/dist/src/react-menu3/hooks/useMenuChange.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useMenuState.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +1 -1
- package/dist/src/react-menu3/index.d.ts +11 -11
- package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/index.d.ts +3 -3
- package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +4 -4
- package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +5 -5
- package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +2 -2
- package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +5 -5
- package/dist/src/react-menu3/style-utils/index.d.ts +1 -1
- package/dist/src/react-menu3/types.d.ts +15 -15
- package/dist/src/react-menu3/utils/constants.d.ts +1 -1
- package/dist/src/react-menu3/utils/index.d.ts +3 -3
- package/dist/src/react-menu3/utils/utils.d.ts +5 -5
- package/dist/src/react-menu3/utils/withHovering.d.ts +1 -1
- package/dist/src/utils/testQuick.d.ts +2 -2
- package/dist/src/utils/testUtil.d.ts +2 -2
- package/dist/src/utils/textValidator.d.ts +2 -2
- package/dist/step-ag-grid.cjs.js +966 -952
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +968 -954
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +26 -41
- package/src/components/ComponentLoadingWrapper.tsx +5 -6
- package/src/components/Grid.tsx +85 -83
- package/src/components/GridCell.test.tsx +15 -15
- package/src/components/GridCell.tsx +46 -44
- package/src/components/GridCellFiller.tsx +5 -4
- package/src/components/GridCellMultiEditor.tsx +7 -7
- package/src/components/GridCellMultiSelectClassRules.tsx +3 -3
- package/src/components/GridIcon.tsx +6 -7
- package/src/components/GridLoadableCell.tsx +2 -2
- package/src/components/GridNoRowsOverlay.tsx +8 -8
- package/src/components/GridPopoverHook.tsx +16 -16
- package/src/components/GridWrapper.tsx +2 -2
- package/src/components/PostSortRowsHook.ts +11 -11
- package/src/components/clickInputWhenContainingCellClicked.tsx +5 -5
- package/src/components/gridFilter/GridFilterButtons.tsx +8 -9
- package/src/components/gridFilter/GridFilterColumnsToggle.tsx +25 -26
- package/src/components/gridFilter/GridFilterDownloadCsvButton.tsx +12 -13
- package/src/components/gridFilter/GridFilterHeaderIconButton.tsx +9 -10
- package/src/components/gridFilter/GridFilterQuick.tsx +6 -6
- package/src/components/gridFilter/GridFilters.tsx +1 -1
- package/src/components/gridFilter/index.ts +7 -7
- package/src/components/gridFilter/useGridFilter.ts +3 -3
- package/src/components/gridForm/GridFormDropDown.tsx +56 -52
- package/src/components/gridForm/GridFormEditBearing.tsx +12 -12
- package/src/components/gridForm/GridFormMessage.tsx +10 -10
- package/src/components/gridForm/GridFormMultiSelect.tsx +53 -51
- package/src/components/gridForm/GridFormMultiSelectGrid.tsx +25 -26
- package/src/components/gridForm/GridFormPopoverMenu.tsx +32 -29
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +10 -10
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +8 -8
- package/src/components/gridForm/GridFormTextArea.tsx +11 -11
- package/src/components/gridForm/GridFormTextInput.tsx +11 -11
- package/src/components/gridForm/index.ts +10 -10
- package/src/components/gridHeader/GridHeaderSelect.tsx +9 -9
- package/src/components/gridHeader/index.ts +1 -1
- package/src/components/gridHook/index.ts +1 -1
- package/src/components/gridHook/useGridContextMenu.tsx +7 -7
- package/src/components/gridPopoverEdit/GridButton.tsx +13 -12
- package/src/components/gridPopoverEdit/GridEditBoolean.tsx +19 -18
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +7 -6
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +7 -6
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +9 -9
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +8 -7
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +6 -6
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +4 -4
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +4 -4
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +4 -4
- package/src/components/gridPopoverEdit/index.ts +11 -11
- package/src/components/gridRender/GridRenderGenericCell.tsx +5 -5
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +8 -9
- package/src/components/gridRender/index.ts +2 -2
- package/src/components/gridUtil.ts +3 -3
- package/src/components/index.ts +19 -19
- package/src/contexts/GridContext.tsx +52 -46
- package/src/contexts/GridContextProvider.test.tsx +14 -14
- package/src/contexts/GridContextProvider.tsx +42 -41
- package/src/contexts/GridPopoverContext.tsx +10 -7
- package/src/contexts/GridPopoverContextProvider.tsx +12 -10
- package/src/contexts/GridSubComponentContext.ts +6 -5
- package/src/contexts/GridUpdatingContext.tsx +5 -4
- package/src/contexts/GridUpdatingContextProvider.tsx +3 -3
- package/src/index.ts +17 -21
- package/src/lui/ActionButton.tsx +42 -41
- package/src/lui/FormError.tsx +4 -4
- package/src/lui/TextAreaInput.tsx +9 -9
- package/src/lui/TextInputFormatted.tsx +11 -11
- package/src/lui/reactUtils.test.tsx +8 -8
- package/src/lui/reactUtils.tsx +2 -2
- package/src/lui/stateDeferredHook.tsx +3 -5
- package/src/lui/timeoutHook.test.tsx +5 -5
- package/src/lui/timeoutHook.tsx +1 -1
- package/src/react-app-env.d.ts +1 -1
- package/src/react-menu3/components/ControlledMenu.tsx +48 -48
- package/src/react-menu3/components/FocusableItem.tsx +7 -7
- package/src/react-menu3/components/Menu.tsx +11 -11
- package/src/react-menu3/components/MenuButton.tsx +4 -4
- package/src/react-menu3/components/MenuDivider.tsx +4 -4
- package/src/react-menu3/components/MenuGroup.tsx +5 -5
- package/src/react-menu3/components/MenuHeader.tsx +4 -4
- package/src/react-menu3/components/MenuItem.tsx +14 -14
- package/src/react-menu3/components/MenuList.tsx +55 -55
- package/src/react-menu3/components/MenuRadioGroup.tsx +7 -7
- package/src/react-menu3/components/SubMenu.tsx +24 -24
- package/src/react-menu3/contexts/EventHandlersContext.ts +2 -2
- package/src/react-menu3/contexts/HoverItemContext.ts +1 -1
- package/src/react-menu3/contexts/ItemSettingsContext.ts +1 -1
- package/src/react-menu3/contexts/MenuListContext.ts +2 -2
- package/src/react-menu3/contexts/MenuListItemContext.ts +2 -2
- package/src/react-menu3/contexts/RadioGroupContext.ts +2 -2
- package/src/react-menu3/contexts/SettingsContext.ts +2 -2
- package/src/react-menu3/hooks/index.ts +9 -9
- package/src/react-menu3/hooks/useBEM.ts +4 -4
- package/src/react-menu3/hooks/useCombinedRef.ts +2 -2
- package/src/react-menu3/hooks/useIsomorphicLayoutEffect.ts +4 -4
- package/src/react-menu3/hooks/useItemEffect.ts +3 -3
- package/src/react-menu3/hooks/useItemState.ts +5 -5
- package/src/react-menu3/hooks/useItems.ts +8 -8
- package/src/react-menu3/hooks/useMenuChange.ts +3 -3
- package/src/react-menu3/hooks/useMenuState.ts +5 -5
- package/src/react-menu3/hooks/useMenuStateAndFocus.ts +4 -4
- package/src/react-menu3/index.ts +11 -11
- package/src/react-menu3/positionUtils/getPositionHelpers.ts +2 -2
- package/src/react-menu3/positionUtils/index.ts +3 -3
- package/src/react-menu3/positionUtils/placeArrowHorizontal.ts +1 -1
- package/src/react-menu3/positionUtils/placeArrowVertical.ts +1 -1
- package/src/react-menu3/positionUtils/placeLeftorRight.ts +13 -13
- package/src/react-menu3/positionUtils/placeToporBottom.ts +15 -15
- package/src/react-menu3/positionUtils/positionContextMenu.ts +4 -4
- package/src/react-menu3/positionUtils/positionMenu.ts +14 -14
- package/src/react-menu3/style-utils/index.ts +24 -24
- package/src/react-menu3/types.ts +15 -15
- package/src/react-menu3/utils/constants.ts +33 -33
- package/src/react-menu3/utils/index.ts +3 -4
- package/src/react-menu3/utils/propTypes2.ts +10 -10
- package/src/react-menu3/utils/utils.ts +14 -14
- package/src/react-menu3/utils/withHovering.tsx +3 -3
- package/src/stories/components/ActionButton.stories.tsx +23 -24
- package/src/stories/grid/FormTest.tsx +15 -16
- package/src/stories/grid/GridDragRow.stories.tsx +33 -34
- package/src/stories/grid/GridFilterButtons.stories.tsx +32 -33
- package/src/stories/grid/GridNoRowsOverlay.stories.tsx +9 -10
- package/src/stories/grid/GridNonEditableRow.stories.tsx +40 -41
- package/src/stories/grid/GridPinnedRow.stories.tsx +25 -26
- package/src/stories/grid/GridPopoutContextMenu.stories.tsx +33 -32
- package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +21 -22
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +18 -19
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +50 -49
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +25 -26
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +93 -94
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +62 -63
- package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +28 -28
- package/src/stories/grid/GridReadOnly.stories.tsx +66 -67
- package/src/stories/grid/GridViewList.stories.tsx +37 -38
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +37 -38
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +25 -26
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +25 -26
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +31 -31
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +47 -48
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +44 -45
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +19 -20
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +21 -22
- package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +40 -41
- package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +14 -15
- package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +14 -15
- package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +10 -11
- package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +20 -21
- package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +16 -17
- package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +13 -14
- package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +13 -14
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +68 -71
- package/src/stories/react-menu/ReactMenu.stories.tsx +26 -26
- package/src/utils/bearing.test.ts +44 -44
- package/src/utils/bearing.ts +20 -20
- package/src/utils/deferredPromise.ts +1 -1
- package/src/utils/storybookTestUtil.ts +2 -2
- package/src/utils/testQuick.ts +15 -14
- package/src/utils/testUtil.ts +31 -36
- package/src/utils/textMatcher.test.ts +9 -9
- package/src/utils/textMatcher.ts +8 -8
- package/src/utils/textValidator.test.ts +56 -56
- package/src/utils/textValidator.ts +11 -11
- package/src/utils/util.test.ts +20 -20
- package/src/utils/util.ts +7 -7
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
cloneElement,
|
|
2
3
|
ForwardedRef,
|
|
4
|
+
forwardRef,
|
|
3
5
|
Fragment,
|
|
4
6
|
ReactElement,
|
|
5
|
-
cloneElement,
|
|
6
|
-
forwardRef,
|
|
7
7
|
useCallback,
|
|
8
8
|
useImperativeHandle,
|
|
9
9
|
useRef,
|
|
10
|
-
} from
|
|
10
|
+
} from 'react';
|
|
11
11
|
|
|
12
|
-
import { useCombinedRef, useMenuChange, useMenuStateAndFocus } from
|
|
13
|
-
import { MenuButtonModifiers, MenuCloseEvent, RenderProp, RootMenuProps, UncontrolledMenuProps } from
|
|
14
|
-
import { FocusPositions,
|
|
15
|
-
import { ControlledMenu } from
|
|
12
|
+
import { useCombinedRef, useMenuChange, useMenuStateAndFocus } from '../hooks';
|
|
13
|
+
import { MenuButtonModifiers, MenuCloseEvent, RenderProp, RootMenuProps, UncontrolledMenuProps } from '../types';
|
|
14
|
+
import { FocusPositions, getName, isMenuOpen, Keys, mergeProps, safeCall } from '../utils';
|
|
15
|
+
import { ControlledMenu } from './ControlledMenu';
|
|
16
16
|
|
|
17
17
|
//
|
|
18
18
|
// Menu
|
|
@@ -31,7 +31,7 @@ export interface MenuProps extends RootMenuProps, UncontrolledMenuProps {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export function MenuFr(
|
|
34
|
-
{
|
|
34
|
+
{ 'aria-label': ariaLabel, menuButton, instanceRef, onMenuChange, ...restProps }: MenuProps,
|
|
35
35
|
externalRef: ForwardedRef<ReactElement>,
|
|
36
36
|
) {
|
|
37
37
|
const [stateProps, toggleMenu, openMenu] = useMenuStateAndFocus(restProps);
|
|
@@ -72,14 +72,14 @@ export function MenuFr(
|
|
|
72
72
|
|
|
73
73
|
// Too many mixed types here to figure out what to pick for button. Bad code.
|
|
74
74
|
const button: any = safeCall(menuButton, { open: isOpen });
|
|
75
|
-
if (!button || !button.type) throw new Error(
|
|
75
|
+
if (!button || !button.type) throw new Error('Menu requires a menuButton prop.');
|
|
76
76
|
|
|
77
77
|
const buttonProps = {
|
|
78
78
|
ref: useCombinedRef(button.ref, buttonRef),
|
|
79
79
|
...mergeProps({ onClick, onKeyDown }, button.props),
|
|
80
80
|
isOpen: false,
|
|
81
81
|
};
|
|
82
|
-
if (getName(button.type) ===
|
|
82
|
+
if (getName(button.type) === 'MenuButton') {
|
|
83
83
|
buttonProps.isOpen = isOpen;
|
|
84
84
|
}
|
|
85
85
|
const renderButton = cloneElement(button, buttonProps);
|
|
@@ -97,7 +97,7 @@ export function MenuFr(
|
|
|
97
97
|
<ControlledMenu
|
|
98
98
|
{...restProps}
|
|
99
99
|
{...stateProps}
|
|
100
|
-
aria-label={ariaLabel || (typeof button.props.children ===
|
|
100
|
+
aria-label={ariaLabel || (typeof button.props.children === 'string' ? button.props.children : 'Menu')}
|
|
101
101
|
anchorRef={buttonRef}
|
|
102
102
|
ref={externalRef}
|
|
103
103
|
onClose={handleClose}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LegacyRef, ReactNode,
|
|
1
|
+
import { forwardRef, LegacyRef, ReactNode, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { useBEM } from
|
|
4
|
-
import { BaseProps, MenuButtonModifiers } from
|
|
5
|
-
import { menuButtonClass } from
|
|
3
|
+
import { useBEM } from '../hooks';
|
|
4
|
+
import { BaseProps, MenuButtonModifiers } from '../types';
|
|
5
|
+
import { menuButtonClass } from '../utils';
|
|
6
6
|
|
|
7
7
|
export interface MenuButtonProps extends BaseProps<MenuButtonModifiers> {
|
|
8
8
|
disabled?: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { forwardRef, LegacyRef, memo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { useBEM } from
|
|
4
|
-
import { BaseProps } from
|
|
5
|
-
import { menuClass, menuDividerClass } from
|
|
3
|
+
import { useBEM } from '../hooks';
|
|
4
|
+
import { BaseProps } from '../types';
|
|
5
|
+
import { menuClass, menuDividerClass } from '../utils';
|
|
6
6
|
|
|
7
7
|
const MenuDividerFr = ({ className, ...restProps }: BaseProps, externalRef: LegacyRef<HTMLLIElement>) => {
|
|
8
8
|
return (
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ForwardedRef,
|
|
1
|
+
import { ForwardedRef, forwardRef, ReactNode, useContext, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { MenuListContext } from
|
|
4
|
-
import { useBEM, useCombinedRef, useLayoutEffect } from
|
|
5
|
-
import { BaseProps, MenuOverflow } from
|
|
6
|
-
import { menuClass, menuGroupClass } from
|
|
3
|
+
import { MenuListContext } from '../contexts/MenuListContext';
|
|
4
|
+
import { useBEM, useCombinedRef, useLayoutEffect } from '../hooks';
|
|
5
|
+
import { BaseProps, MenuOverflow } from '../types';
|
|
6
|
+
import { menuClass, menuGroupClass } from '../utils';
|
|
7
7
|
|
|
8
8
|
export interface MenuGroupProps extends BaseProps {
|
|
9
9
|
children?: ReactNode;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ForwardedRef, forwardRef, memo } from
|
|
1
|
+
import { ForwardedRef, forwardRef, memo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { useBEM } from
|
|
4
|
-
import { BasePropsWithChildren } from
|
|
5
|
-
import { menuClass, menuHeaderClass } from
|
|
3
|
+
import { useBEM } from '../hooks';
|
|
4
|
+
import { BasePropsWithChildren } from '../types';
|
|
5
|
+
import { menuClass, menuHeaderClass } from '../utils';
|
|
6
6
|
|
|
7
7
|
export const MenuHeaderFr = (
|
|
8
8
|
{ className, ...restProps }: BasePropsWithChildren,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { KeyboardEvent, Ref, useContext, useMemo } from
|
|
1
|
+
import { KeyboardEvent, Ref, useContext, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { EventHandlersContext } from
|
|
4
|
-
import { RadioGroupContext } from
|
|
5
|
-
import { useBEM, useCombinedRef, useItemState } from
|
|
6
|
-
import { BaseProps, ClickEvent, EventHandler, Hoverable, MenuItemTypeProp, RenderProp } from
|
|
7
|
-
import {
|
|
8
|
-
import { withHoveringResultProps } from
|
|
3
|
+
import { EventHandlersContext } from '../contexts/EventHandlersContext';
|
|
4
|
+
import { RadioGroupContext } from '../contexts/RadioGroupContext';
|
|
5
|
+
import { useBEM, useCombinedRef, useItemState } from '../hooks';
|
|
6
|
+
import { BaseProps, ClickEvent, EventHandler, Hoverable, MenuItemTypeProp, RenderProp } from '../types';
|
|
7
|
+
import { commonProps, Keys, menuClass, menuItemClass, mergeProps, RMEvent, safeCall, withHovering } from '../utils';
|
|
8
|
+
import { withHoveringResultProps } from '../utils/withHovering';
|
|
9
9
|
|
|
10
10
|
//
|
|
11
11
|
// MenuItem
|
|
@@ -33,7 +33,7 @@ export type MenuItemModifiers = Readonly<{
|
|
|
33
33
|
anchor: boolean;
|
|
34
34
|
}>;
|
|
35
35
|
|
|
36
|
-
export interface MenuItemProps extends Omit<BaseProps<MenuItemModifiers>,
|
|
36
|
+
export interface MenuItemProps extends Omit<BaseProps<MenuItemModifiers>, 'onClick'>, Hoverable {
|
|
37
37
|
/**
|
|
38
38
|
* Any value provided to this prop will be available in the event object of click events.
|
|
39
39
|
*
|
|
@@ -85,8 +85,8 @@ const MenuItemFr = ({
|
|
|
85
85
|
const { setHover, ...restStateProps } = useItemState(menuItemRef, menuItemRef, isHovering, isDisabled);
|
|
86
86
|
const eventHandlers = useContext(EventHandlersContext);
|
|
87
87
|
const radioGroup = useContext(RadioGroupContext);
|
|
88
|
-
const isRadio = type ===
|
|
89
|
-
const isCheckBox = type ===
|
|
88
|
+
const isRadio = type === 'radio';
|
|
89
|
+
const isCheckBox = type === 'checkbox';
|
|
90
90
|
const isAnchor = !!href && !isDisabled && !isRadio && !isCheckBox;
|
|
91
91
|
const isChecked = isRadio ? radioGroup.value === value : isCheckBox ? !!checked : false;
|
|
92
92
|
|
|
@@ -122,7 +122,7 @@ const MenuItemFr = ({
|
|
|
122
122
|
|
|
123
123
|
const handleKeyDown = (e: KeyboardEvent) => {
|
|
124
124
|
// if tab is allowed the handleKeyUp event can't process the tab
|
|
125
|
-
if (e.key ===
|
|
125
|
+
if (e.key === 'Tab') {
|
|
126
126
|
e.preventDefault();
|
|
127
127
|
e.stopPropagation();
|
|
128
128
|
}
|
|
@@ -176,8 +176,8 @@ const MenuItemFr = ({
|
|
|
176
176
|
// 2. Merged outer and local props
|
|
177
177
|
// 3. ref, className
|
|
178
178
|
const menuItemProps = {
|
|
179
|
-
role: isRadio ?
|
|
180
|
-
|
|
179
|
+
role: isRadio ? 'menuitemradio' : isCheckBox ? 'menuitemcheckbox' : 'menuitem',
|
|
180
|
+
'aria-checked': isRadio || isCheckBox ? isChecked : undefined,
|
|
181
181
|
...mergedProps,
|
|
182
182
|
...commonProps(isDisabled, isHovering),
|
|
183
183
|
ref: useCombinedRef(externalRef as Ref<any>, menuItemRef),
|
|
@@ -196,4 +196,4 @@ const MenuItemFr = ({
|
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
|
|
199
|
-
export const MenuItem = withHovering(
|
|
199
|
+
export const MenuItem = withHovering('MenuItem', MenuItemFr);
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { debounce } from
|
|
2
|
-
import { useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from
|
|
3
|
-
import { flushSync } from
|
|
4
|
-
|
|
5
|
-
import { findParentWithClass } from
|
|
6
|
-
import { HoverItemContext } from
|
|
7
|
-
import { MenuListContext } from
|
|
8
|
-
import { MenuListItemContext } from
|
|
9
|
-
import { SettingsContext } from
|
|
10
|
-
import { useBEM, useCombinedRef, useItems, useLayoutEffect } from
|
|
11
|
-
import { getPositionHelpers, positionContextMenu, positionMenu } from
|
|
12
|
-
import { ControlledMenuProps, MenuDirection } from
|
|
1
|
+
import { debounce } from 'lodash-es';
|
|
2
|
+
import { useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
|
3
|
+
import { flushSync } from 'react-dom';
|
|
4
|
+
|
|
5
|
+
import { findParentWithClass } from '../../utils/util';
|
|
6
|
+
import { HoverItemContext } from '../contexts/HoverItemContext';
|
|
7
|
+
import { MenuListContext } from '../contexts/MenuListContext';
|
|
8
|
+
import { MenuListItemContext } from '../contexts/MenuListItemContext';
|
|
9
|
+
import { SettingsContext } from '../contexts/SettingsContext';
|
|
10
|
+
import { useBEM, useCombinedRef, useItems, useLayoutEffect } from '../hooks';
|
|
11
|
+
import { getPositionHelpers, positionContextMenu, positionMenu } from '../positionUtils';
|
|
12
|
+
import { ControlledMenuProps, MenuDirection } from '../types';
|
|
13
13
|
import {
|
|
14
|
-
CloseReason,
|
|
15
|
-
FocusPositions,
|
|
16
|
-
HoverActionTypes,
|
|
17
|
-
Keys,
|
|
18
14
|
batchedUpdates,
|
|
15
|
+
CloseReason,
|
|
19
16
|
commonProps,
|
|
20
17
|
floatEqual,
|
|
21
18
|
focusFirstInput,
|
|
19
|
+
FocusPositions,
|
|
22
20
|
getScrollAncestor,
|
|
23
21
|
getTransition,
|
|
22
|
+
HoverActionTypes,
|
|
24
23
|
isMenuOpen,
|
|
24
|
+
Keys,
|
|
25
25
|
menuArrowClass,
|
|
26
26
|
menuClass,
|
|
27
27
|
mergeProps,
|
|
28
28
|
safeCall,
|
|
29
|
-
} from
|
|
29
|
+
} from '../utils';
|
|
30
30
|
|
|
31
31
|
export const MenuList = ({
|
|
32
32
|
ariaLabel,
|
|
@@ -40,10 +40,10 @@ export const MenuList = ({
|
|
|
40
40
|
externalRef,
|
|
41
41
|
parentScrollingRef,
|
|
42
42
|
arrow,
|
|
43
|
-
align =
|
|
44
|
-
direction =
|
|
45
|
-
position =
|
|
46
|
-
overflow =
|
|
43
|
+
align = 'start',
|
|
44
|
+
direction = 'bottom',
|
|
45
|
+
position = 'auto',
|
|
46
|
+
overflow = 'visible',
|
|
47
47
|
setDownOverflow,
|
|
48
48
|
repositionFlag,
|
|
49
49
|
captureFocus = true,
|
|
@@ -85,8 +85,8 @@ export const MenuList = ({
|
|
|
85
85
|
const { hoverItem, dispatch, updateItems } = useItems(menuRef, focusRef);
|
|
86
86
|
|
|
87
87
|
const isOpen = isMenuOpen(state);
|
|
88
|
-
const openTransition = getTransition(transition,
|
|
89
|
-
const closeTransition = getTransition(transition,
|
|
88
|
+
const openTransition = getTransition(transition, 'open');
|
|
89
|
+
const closeTransition = getTransition(transition, 'close');
|
|
90
90
|
const scrollNodes = scrollNodesRef.current;
|
|
91
91
|
|
|
92
92
|
/**
|
|
@@ -97,8 +97,8 @@ export const MenuList = ({
|
|
|
97
97
|
if (!menuItemEl) return false;
|
|
98
98
|
|
|
99
99
|
let [best, worst]: { i: number; d: number }[] = [];
|
|
100
|
-
findParentWithClass(
|
|
101
|
-
?.querySelectorAll<HTMLLIElement>(
|
|
100
|
+
findParentWithClass('szh-menu', menuItemEl)
|
|
101
|
+
?.querySelectorAll<HTMLLIElement>('.szh-menu__item')
|
|
102
102
|
?.forEach((item, i) => {
|
|
103
103
|
// Must be at same height as currently focused menu-item
|
|
104
104
|
if (item.offsetTop === menuItemEl.offsetTop) {
|
|
@@ -111,16 +111,16 @@ export const MenuList = ({
|
|
|
111
111
|
const r = best ?? worst;
|
|
112
112
|
if (!r) return false;
|
|
113
113
|
|
|
114
|
-
dispatch(HoverActionTypes.SET_INDEX, undefined, r[
|
|
114
|
+
dispatch(HoverActionTypes.SET_INDEX, undefined, r['i']);
|
|
115
115
|
return true;
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
const onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {
|
|
119
|
-
const elementTarget = e.target instanceof HTMLElement ?
|
|
119
|
+
const elementTarget = e.target instanceof HTMLElement ? e.target : null;
|
|
120
120
|
const isTextInputTarget =
|
|
121
121
|
elementTarget &&
|
|
122
|
-
(elementTarget.nodeName ===
|
|
123
|
-
(elementTarget.nodeName ===
|
|
122
|
+
(elementTarget.nodeName === 'TEXTAREA' ||
|
|
123
|
+
(elementTarget.nodeName === 'INPUT' && elementTarget.getAttribute('type') === 'text'));
|
|
124
124
|
switch (e.key) {
|
|
125
125
|
case Keys.HOME:
|
|
126
126
|
// Don't eat home/end events on inputs
|
|
@@ -171,7 +171,7 @@ export const MenuList = ({
|
|
|
171
171
|
};
|
|
172
172
|
|
|
173
173
|
const onAnimationEnd = () => {
|
|
174
|
-
if (state ===
|
|
174
|
+
if (state === 'closing') {
|
|
175
175
|
setOverflowData(undefined); // reset overflowData after closing
|
|
176
176
|
}
|
|
177
177
|
|
|
@@ -181,7 +181,7 @@ export const MenuList = ({
|
|
|
181
181
|
const handlePosition = useCallback(
|
|
182
182
|
(noOverflowCheck?: boolean) => {
|
|
183
183
|
if (!containerRef?.current) {
|
|
184
|
-
if (process.env.NODE_ENV !==
|
|
184
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
185
185
|
console.error(
|
|
186
186
|
'[React-Menu] Menu cannot be positioned properly as container ref is null. If you need to initialise `state` prop to "open" for ControlledMenu, please see this solution: https://codesandbox.io/s/initial-open-sp10wn',
|
|
187
187
|
);
|
|
@@ -199,7 +199,7 @@ export const MenuList = ({
|
|
|
199
199
|
const positionHelpers = getPositionHelpers(containerRef, menuRef, scrollNodes.menu, boundingBoxPadding);
|
|
200
200
|
const { menuRect } = positionHelpers;
|
|
201
201
|
let results: { computedDirection: MenuDirection; arrowX?: number; arrowY?: number; x: number; y: number } = {
|
|
202
|
-
computedDirection:
|
|
202
|
+
computedDirection: 'bottom',
|
|
203
203
|
x: 0,
|
|
204
204
|
y: 0,
|
|
205
205
|
};
|
|
@@ -222,7 +222,7 @@ export const MenuList = ({
|
|
|
222
222
|
const { x, arrowX, arrowY, computedDirection } = results;
|
|
223
223
|
let menuHeight = menuRect.height;
|
|
224
224
|
|
|
225
|
-
if (!noOverflowCheck && overflow !==
|
|
225
|
+
if (!noOverflowCheck && overflow !== 'visible') {
|
|
226
226
|
const { getTopOverflow, getBottomOverflow } = positionHelpers;
|
|
227
227
|
|
|
228
228
|
let height: number | undefined, overflowAmt: number | undefined;
|
|
@@ -307,20 +307,20 @@ export const MenuList = ({
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
let scroll = viewScroll;
|
|
310
|
-
if (scrollNodes.anchors.length && scroll ===
|
|
311
|
-
if (scroll ===
|
|
310
|
+
if (scrollNodes.anchors.length && scroll === 'initial') scroll = 'auto';
|
|
311
|
+
if (scroll === 'initial') return;
|
|
312
312
|
|
|
313
313
|
const handleScroll = () => {
|
|
314
|
-
if (scroll ===
|
|
314
|
+
if (scroll === 'auto') {
|
|
315
315
|
batchedUpdates(() => handlePosition(true));
|
|
316
316
|
} else {
|
|
317
317
|
safeCall(onClose, { reason: CloseReason.SCROLL });
|
|
318
318
|
}
|
|
319
319
|
};
|
|
320
320
|
|
|
321
|
-
const scrollObservers = scrollNodes.anchors.concat(viewScroll !==
|
|
322
|
-
scrollObservers.forEach((o: any) => o.addEventListener(
|
|
323
|
-
return () => scrollObservers.forEach((o) => o.removeEventListener(
|
|
321
|
+
const scrollObservers = scrollNodes.anchors.concat(viewScroll !== 'initial' ? menuScroll : []);
|
|
322
|
+
scrollObservers.forEach((o: any) => o.addEventListener('scroll', handleScroll));
|
|
323
|
+
return () => scrollObservers.forEach((o) => o.removeEventListener('scroll', handleScroll));
|
|
324
324
|
}, [rootAnchorRef, scrollNodes, isOpen, onClose, viewScroll, handlePosition]);
|
|
325
325
|
|
|
326
326
|
const hasOverflow = !!overflowData && overflowData.overflowAmt != null && overflowData.overflowAmt > 0;
|
|
@@ -329,12 +329,12 @@ export const MenuList = ({
|
|
|
329
329
|
|
|
330
330
|
const handleScroll = () => batchedUpdates(handlePosition);
|
|
331
331
|
const parentScroll = parentScrollingRef.current;
|
|
332
|
-
parentScroll.addEventListener(
|
|
333
|
-
return () => parentScroll.removeEventListener(
|
|
332
|
+
parentScroll.addEventListener('scroll', handleScroll);
|
|
333
|
+
return () => parentScroll.removeEventListener('scroll', handleScroll);
|
|
334
334
|
}, [isOpen, hasOverflow, parentScrollingRef, handlePosition]);
|
|
335
335
|
|
|
336
336
|
useEffect(() => {
|
|
337
|
-
if (typeof ResizeObserver !==
|
|
337
|
+
if (typeof ResizeObserver !== 'function' || reposition === 'initial') return;
|
|
338
338
|
|
|
339
339
|
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
340
340
|
const { borderBoxSize, target } = entry;
|
|
@@ -359,13 +359,13 @@ export const MenuList = ({
|
|
|
359
359
|
});
|
|
360
360
|
|
|
361
361
|
const observeTarget = menuRef.current;
|
|
362
|
-
resizeObserver.observe(observeTarget, { box:
|
|
362
|
+
resizeObserver.observe(observeTarget, { box: 'border-box' });
|
|
363
363
|
return () => resizeObserver.unobserve(observeTarget);
|
|
364
364
|
}, [reposition]);
|
|
365
365
|
|
|
366
366
|
// Matt added window resize observer
|
|
367
367
|
useEffect(() => {
|
|
368
|
-
if (typeof ResizeObserver !==
|
|
368
|
+
if (typeof ResizeObserver !== 'function' || reposition === 'initial') return;
|
|
369
369
|
|
|
370
370
|
const callback = debounce(() => {
|
|
371
371
|
const { width, height } = menuRef.current.ownerDocument.body.getBoundingClientRect();
|
|
@@ -386,7 +386,7 @@ export const MenuList = ({
|
|
|
386
386
|
const resizeObserver = new ResizeObserver(callback);
|
|
387
387
|
|
|
388
388
|
const observeTarget = menuRef.current.ownerDocument.body;
|
|
389
|
-
resizeObserver.observe(observeTarget, { box:
|
|
389
|
+
resizeObserver.observe(observeTarget, { box: 'border-box' });
|
|
390
390
|
return () => {
|
|
391
391
|
callback.cancel();
|
|
392
392
|
resizeObserver.unobserve(observeTarget);
|
|
@@ -406,7 +406,7 @@ export const MenuList = ({
|
|
|
406
406
|
dispatch(HoverActionTypes.FIRST, undefined, 0);
|
|
407
407
|
} else if (position === FocusPositions.LAST) {
|
|
408
408
|
dispatch(HoverActionTypes.LAST, undefined, 0);
|
|
409
|
-
} else if (typeof position ===
|
|
409
|
+
} else if (typeof position === 'number' && position >= -1) {
|
|
410
410
|
dispatch(HoverActionTypes.SET_INDEX, undefined, position);
|
|
411
411
|
}
|
|
412
412
|
};
|
|
@@ -488,10 +488,10 @@ export const MenuList = ({
|
|
|
488
488
|
|
|
489
489
|
const dontShrinkOps = useMemo(
|
|
490
490
|
() =>
|
|
491
|
-
expandedDirection ===
|
|
491
|
+
expandedDirection === 'top' && dontShrinkIfDirectionIsTop
|
|
492
492
|
? {
|
|
493
|
-
overflowY: isSubmenuOpen ?
|
|
494
|
-
minHeight: (isSubmenuOpen ? 0 : minHeight.current) +
|
|
493
|
+
overflowY: isSubmenuOpen ? '' : 'auto',
|
|
494
|
+
minHeight: (isSubmenuOpen ? 0 : minHeight.current) + 'px',
|
|
495
495
|
}
|
|
496
496
|
: undefined,
|
|
497
497
|
[dontShrinkIfDirectionIsTop, expandedDirection, isSubmenuOpen],
|
|
@@ -510,8 +510,8 @@ export const MenuList = ({
|
|
|
510
510
|
...overflowStyle,
|
|
511
511
|
...dontShrinkOps,
|
|
512
512
|
margin: 0,
|
|
513
|
-
display: state ===
|
|
514
|
-
position:
|
|
513
|
+
display: state === 'closed' ? 'none' : undefined,
|
|
514
|
+
position: 'absolute',
|
|
515
515
|
left: menuPosition.x,
|
|
516
516
|
top: menuPosition.y,
|
|
517
517
|
}}
|
|
@@ -519,16 +519,16 @@ export const MenuList = ({
|
|
|
519
519
|
<div
|
|
520
520
|
ref={focusRef}
|
|
521
521
|
tabIndex={-1}
|
|
522
|
-
style={{ position:
|
|
522
|
+
style={{ position: 'absolute', left: 0, top: 0 }}
|
|
523
523
|
onKeyDown={(event) => {
|
|
524
|
-
if (event.key ==
|
|
524
|
+
if (event.key == 'Tab') {
|
|
525
525
|
event.preventDefault();
|
|
526
526
|
event.stopPropagation();
|
|
527
527
|
safeCall(onClose, {
|
|
528
528
|
key: event.key,
|
|
529
529
|
shiftKey: event.shiftKey,
|
|
530
530
|
reason:
|
|
531
|
-
event.key ===
|
|
531
|
+
event.key === 'Tab'
|
|
532
532
|
? event.shiftKey
|
|
533
533
|
? CloseReason.TAB_BACKWARD
|
|
534
534
|
: CloseReason.TAB_FORWARD
|
|
@@ -542,7 +542,7 @@ export const MenuList = ({
|
|
|
542
542
|
className={_arrowClass}
|
|
543
543
|
style={{
|
|
544
544
|
...arrowStyle,
|
|
545
|
-
position:
|
|
545
|
+
position: 'absolute',
|
|
546
546
|
left: arrowPosition.x,
|
|
547
547
|
top: arrowPosition.y,
|
|
548
548
|
}}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ForwardedRef,
|
|
1
|
+
import { ForwardedRef, forwardRef, ReactNode, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { RadioGroupContext } from
|
|
4
|
-
import { useBEM } from
|
|
5
|
-
import { BaseProps, EventHandler, RadioChangeEvent } from
|
|
6
|
-
import { menuClass, radioGroupClass } from
|
|
3
|
+
import { RadioGroupContext } from '../contexts/RadioGroupContext';
|
|
4
|
+
import { useBEM } from '../hooks';
|
|
5
|
+
import { BaseProps, EventHandler, RadioChangeEvent } from '../types';
|
|
6
|
+
import { menuClass, radioGroupClass } from '../utils';
|
|
7
7
|
|
|
8
8
|
//
|
|
9
9
|
// MenuRadioGroup
|
|
@@ -31,7 +31,7 @@ export interface MenuRadioGroupProps extends BaseProps {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export const MenuRadioGroupFr = (
|
|
34
|
-
{
|
|
34
|
+
{ 'aria-label': ariaLabel, className, name, value, onRadioChange, ...restProps }: MenuRadioGroupProps,
|
|
35
35
|
externalRef: ForwardedRef<HTMLUListElement>,
|
|
36
36
|
) => {
|
|
37
37
|
const contextValue = useMemo(() => ({ name, value, onRadioChange }), [name, value, onRadioChange]);
|
|
@@ -41,7 +41,7 @@ export const MenuRadioGroupFr = (
|
|
|
41
41
|
<li role="presentation">
|
|
42
42
|
<ul
|
|
43
43
|
role="group"
|
|
44
|
-
aria-label={ariaLabel || name ||
|
|
44
|
+
aria-label={ariaLabel || name || 'Radio group'}
|
|
45
45
|
{...restProps}
|
|
46
46
|
ref={externalRef}
|
|
47
47
|
className={useBEM({ block: menuClass, element: radioGroupClass, className })}
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
useImperativeHandle,
|
|
8
8
|
useMemo,
|
|
9
9
|
useRef,
|
|
10
|
-
} from
|
|
11
|
-
import { createPortal } from
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { createPortal } from 'react-dom';
|
|
12
12
|
|
|
13
|
-
import { ItemSettingsContext } from
|
|
14
|
-
import { MenuListContext } from
|
|
15
|
-
import { MenuListItemContext } from
|
|
16
|
-
import { SettingsContext } from
|
|
17
|
-
import { useBEM, useCombinedRef, useItemEffect, useMenuChange, useMenuStateAndFocus } from
|
|
13
|
+
import { ItemSettingsContext } from '../contexts/ItemSettingsContext';
|
|
14
|
+
import { MenuListContext } from '../contexts/MenuListContext';
|
|
15
|
+
import { MenuListItemContext } from '../contexts/MenuListItemContext';
|
|
16
|
+
import { SettingsContext } from '../contexts/SettingsContext';
|
|
17
|
+
import { useBEM, useCombinedRef, useItemEffect, useMenuChange, useMenuStateAndFocus } from '../hooks';
|
|
18
18
|
import {
|
|
19
19
|
BaseProps,
|
|
20
20
|
ClassNameProp,
|
|
@@ -27,23 +27,23 @@ import {
|
|
|
27
27
|
MenuPosition,
|
|
28
28
|
RenderProp,
|
|
29
29
|
UncontrolledMenuProps,
|
|
30
|
-
} from
|
|
30
|
+
} from '../types';
|
|
31
31
|
import {
|
|
32
|
-
FocusPositions,
|
|
33
|
-
HoverActionTypes,
|
|
34
|
-
Keys,
|
|
35
32
|
batchedUpdates,
|
|
36
33
|
commonProps,
|
|
34
|
+
FocusPositions,
|
|
35
|
+
HoverActionTypes,
|
|
37
36
|
isMenuOpen,
|
|
37
|
+
Keys,
|
|
38
38
|
menuClass,
|
|
39
39
|
menuItemClass,
|
|
40
40
|
mergeProps,
|
|
41
41
|
safeCall,
|
|
42
42
|
subMenuClass,
|
|
43
43
|
withHovering,
|
|
44
|
-
} from
|
|
45
|
-
import { withHoveringResultProps } from
|
|
46
|
-
import { MenuList } from
|
|
44
|
+
} from '../utils';
|
|
45
|
+
import { withHoveringResultProps } from '../utils/withHovering';
|
|
46
|
+
import { MenuList } from './MenuList';
|
|
47
47
|
|
|
48
48
|
//
|
|
49
49
|
// SubMenu
|
|
@@ -66,7 +66,7 @@ export type SubMenuItemModifiers = Readonly<{
|
|
|
66
66
|
/**
|
|
67
67
|
* Common props for `Menu`, `SubMenu` and `ControlledMenu`
|
|
68
68
|
*/
|
|
69
|
-
interface BaseMenuProps extends Omit<BaseProps,
|
|
69
|
+
interface BaseMenuProps extends Omit<BaseProps, 'style'> {
|
|
70
70
|
/**
|
|
71
71
|
* Can be a string or a function which receives a modifier object and returns a CSS `class` string.
|
|
72
72
|
*/
|
|
@@ -152,11 +152,11 @@ export interface SubMenuProps extends BaseMenuProps, Hoverable, UncontrolledMenu
|
|
|
152
152
|
* - 'none' submenu doesn't open with mouse or keyboard events;
|
|
153
153
|
* you can call the `openMenu` function on `instanceRef` to open submenu programmatically.
|
|
154
154
|
*/
|
|
155
|
-
openTrigger?:
|
|
155
|
+
openTrigger?: 'none' | 'clickOnly';
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
export const SubMenuFr = ({
|
|
159
|
-
|
|
159
|
+
'aria-label': ariaLabel,
|
|
160
160
|
className,
|
|
161
161
|
disabled,
|
|
162
162
|
direction,
|
|
@@ -174,7 +174,7 @@ export const SubMenuFr = ({
|
|
|
174
174
|
const { submenuOpenDelay, submenuCloseDelay } = useContext(ItemSettingsContext);
|
|
175
175
|
const { parentMenuRef, parentDir, overflow: parentOverflow } = useContext(MenuListContext);
|
|
176
176
|
const { isParentOpen, isSubmenuOpen, setOpenSubmenuCount, dispatch, updateItems } = useContext(MenuListItemContext);
|
|
177
|
-
const isPortal = parentOverflow !==
|
|
177
|
+
const isPortal = parentOverflow !== 'visible';
|
|
178
178
|
|
|
179
179
|
const [stateProps, toggleMenu, _openMenu] = useMenuStateAndFocus(settings);
|
|
180
180
|
|
|
@@ -251,7 +251,7 @@ export const SubMenuFr = ({
|
|
|
251
251
|
case Keys.ENTER:
|
|
252
252
|
case Keys.SPACE:
|
|
253
253
|
case Keys.RIGHT:
|
|
254
|
-
openTrigger !==
|
|
254
|
+
openTrigger !== 'none' && openMenu(FocusPositions.FIRST);
|
|
255
255
|
break;
|
|
256
256
|
}
|
|
257
257
|
};
|
|
@@ -303,7 +303,7 @@ export const SubMenuFr = ({
|
|
|
303
303
|
onPointerMove: handlePointerMove,
|
|
304
304
|
onPointerLeave: handlePointerLeave,
|
|
305
305
|
onKeyDown: handleItemKeyDown,
|
|
306
|
-
onClick: () => openTrigger !==
|
|
306
|
+
onClick: () => openTrigger !== 'none' && openMenu(),
|
|
307
307
|
},
|
|
308
308
|
restItemProps,
|
|
309
309
|
);
|
|
@@ -313,10 +313,10 @@ export const SubMenuFr = ({
|
|
|
313
313
|
<MenuList
|
|
314
314
|
{...restProps}
|
|
315
315
|
{...stateProps}
|
|
316
|
-
ariaLabel={ariaLabel || (typeof label ===
|
|
316
|
+
ariaLabel={ariaLabel || (typeof label === 'string' ? label : 'Submenu')}
|
|
317
317
|
anchorRef={menuItemRef}
|
|
318
318
|
containerRef={isPortal ? rootMenuRef : containerRef}
|
|
319
|
-
direction={direction || (parentDir ===
|
|
319
|
+
direction={direction || (parentDir === 'right' || parentDir === 'left' ? parentDir : 'right')}
|
|
320
320
|
parentScrollingRef={isPortal && parentMenuRef}
|
|
321
321
|
isDisabled={isDisabled}
|
|
322
322
|
/>
|
|
@@ -328,7 +328,7 @@ export const SubMenuFr = ({
|
|
|
328
328
|
return (
|
|
329
329
|
<li
|
|
330
330
|
className={useBEM({ block: menuClass, element: subMenuClass, className })}
|
|
331
|
-
style={{ position:
|
|
331
|
+
style={{ position: 'relative' }}
|
|
332
332
|
role="presentation"
|
|
333
333
|
ref={containerRef}
|
|
334
334
|
onKeyDown={handleKeyDown}
|
|
@@ -355,4 +355,4 @@ export const SubMenuFr = ({
|
|
|
355
355
|
);
|
|
356
356
|
};
|
|
357
357
|
|
|
358
|
-
export const SubMenu = withHovering(
|
|
358
|
+
export const SubMenu = withHovering('SubMenu', SubMenuFr);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createContext, MutableRefObject } from 'react';
|
|
2
2
|
|
|
3
|
-
import { MenuDirection, MenuOverflow } from
|
|
3
|
+
import { MenuDirection, MenuOverflow } from '../types';
|
|
4
4
|
|
|
5
5
|
export const MenuListContext = createContext<{
|
|
6
6
|
overflow?: MenuOverflow;
|