@linzjs/step-ag-grid 23.0.1 → 25.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/GridTheme.scss +1 -1
- package/dist/index.css +0 -13
- 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 +19 -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/{src/utils → dist/src/utils/__tests__}/storybookTestUtil.ts +2 -2
- package/{src/utils → dist/src/utils/__tests__}/testQuick.ts +15 -14
- package/{src/utils → dist/src/utils/__tests__}/testUtil.ts +31 -36
- package/dist/src/utils/__tests__/vitestUtil.ts +295 -0
- package/dist/src/utils/textValidator.d.ts +2 -2
- package/dist/{step-ag-grid.cjs.js → step-ag-grid.cjs} +969 -955
- package/dist/step-ag-grid.cjs.map +1 -0
- package/dist/step-ag-grid.esm.js +970 -958
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/dist/vite.config.d.ts +1 -1
- package/package.json +38 -57
- package/src/components/ComponentLoadingWrapper.tsx +5 -6
- package/src/components/Grid.tsx +85 -83
- package/src/components/GridCell.test.tsx +17 -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 +15 -14
- package/src/contexts/GridContextProvider.tsx +42 -42
- 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 +19 -21
- package/src/lui/ActionButton.scss +2 -2
- package/src/lui/ActionButton.tsx +42 -41
- package/src/lui/FormError.scss +3 -4
- package/src/lui/FormError.tsx +4 -4
- package/src/lui/TextAreaInput.tsx +9 -9
- package/src/lui/TextInputFormatted.scss +1 -1
- package/src/lui/TextInputFormatted.tsx +11 -11
- package/src/lui/reactUtils.test.tsx +9 -8
- package/src/lui/reactUtils.tsx +2 -2
- package/src/lui/stateDeferredHook.tsx +3 -5
- package/src/lui/timeoutHook.test.tsx +12 -11
- 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/styles/Grid.scss +9 -9
- package/src/styles/GridIcon.scss +6 -6
- package/src/styles/GridPopoverMenu.scss +3 -3
- package/src/styles/GridTheme.scss +1 -1
- package/src/styles/react-menu-customisations.scss +26 -41
- package/src/utils/__tests__/storybookTestUtil.ts +4 -0
- package/src/utils/__tests__/testQuick.ts +157 -0
- package/src/utils/__tests__/testUtil.ts +294 -0
- package/src/utils/__tests__/vitestUtil.ts +295 -0
- package/src/utils/bearing.test.ts +47 -45
- package/src/utils/bearing.ts +20 -20
- package/src/utils/deferredPromise.ts +1 -1
- package/src/utils/textMatcher.test.ts +10 -9
- package/src/utils/textMatcher.ts +8 -8
- package/src/utils/textValidator.test.ts +61 -62
- package/src/utils/textValidator.ts +11 -11
- package/src/utils/util.test.ts +21 -20
- package/src/utils/util.ts +7 -7
- package/dist/src/utils/storybookTestUtil.d.ts +0 -3
- package/dist/src/utils/testQuick.d.ts +0 -62
- package/dist/src/utils/testUtil.d.ts +0 -46
- package/dist/step-ag-grid.cjs.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defer } from
|
|
2
|
-
import { MutableRefObject, useCallback, useRef, useState } from
|
|
1
|
+
import { defer } from 'lodash-es';
|
|
2
|
+
import { MutableRefObject, useCallback, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
|
-
import { FocusPosition } from
|
|
5
|
-
import {
|
|
4
|
+
import { FocusPosition } from '../types';
|
|
5
|
+
import { focusFirstInput, HoverActionTypes, indexOfNode } from '../utils';
|
|
6
6
|
|
|
7
7
|
export const useItems = (menuRef: MutableRefObject<any>, focusRef: MutableRefObject<any> | undefined) => {
|
|
8
8
|
const [hoverItem, setHoverItem] = useState<
|
|
@@ -46,7 +46,7 @@ export const useItems = (menuRef: MutableRefObject<any>, focusRef: MutableRefObj
|
|
|
46
46
|
const { items, hoverIndex } = mutableState;
|
|
47
47
|
const sortItems = () => {
|
|
48
48
|
if (mutableState.sorted) return;
|
|
49
|
-
const orderedNodes = menuRef.current.querySelectorAll(
|
|
49
|
+
const orderedNodes = menuRef.current.querySelectorAll('.szh-menu__item');
|
|
50
50
|
items.sort((a, b) => indexOfNode(orderedNodes, a) - indexOfNode(orderedNodes, b));
|
|
51
51
|
mutableState.sorted = true;
|
|
52
52
|
};
|
|
@@ -81,12 +81,12 @@ export const useItems = (menuRef: MutableRefObject<any>, focusRef: MutableRefObj
|
|
|
81
81
|
break;
|
|
82
82
|
|
|
83
83
|
case HoverActionTypes.SET_INDEX:
|
|
84
|
-
if (typeof nextIndex !==
|
|
84
|
+
if (typeof nextIndex !== 'number') break;
|
|
85
85
|
sortItems();
|
|
86
86
|
index = nextIndex;
|
|
87
87
|
newItem = items[index];
|
|
88
88
|
defer(() =>
|
|
89
|
-
(newItem as HTMLElement).scrollIntoView({ behavior:
|
|
89
|
+
(newItem as HTMLElement).scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' }),
|
|
90
90
|
);
|
|
91
91
|
break;
|
|
92
92
|
|
|
@@ -112,7 +112,7 @@ export const useItems = (menuRef: MutableRefObject<any>, focusRef: MutableRefObj
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
default:
|
|
115
|
-
if (process.env.NODE_ENV !==
|
|
115
|
+
if (process.env.NODE_ENV !== 'production')
|
|
116
116
|
throw new Error(`[React-Menu] Unknown hover action type: ${actionType}`);
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useEffect, useRef } from
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
2
|
|
|
3
|
-
import { EventHandler, MenuChangeEvent } from
|
|
4
|
-
import { safeCall } from
|
|
3
|
+
import { EventHandler, MenuChangeEvent } from '../types';
|
|
4
|
+
import { safeCall } from '../utils';
|
|
5
5
|
|
|
6
6
|
export const useMenuChange = (onMenuChange?: EventHandler<MenuChangeEvent>, isOpen?: boolean) => {
|
|
7
7
|
const prevOpen = useRef(isOpen);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useTransition } from
|
|
1
|
+
import { useTransition } from 'react-transition-state';
|
|
2
2
|
|
|
3
|
-
import { MenuState, MenuStateOptions } from
|
|
4
|
-
import {
|
|
3
|
+
import { MenuState, MenuStateOptions } from '../types';
|
|
4
|
+
import { getTransition, MenuStateMap } from '../utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A custom Hook which helps manage the states of `ControlledMenu`.
|
|
@@ -35,8 +35,8 @@ export const useMenuState = (
|
|
|
35
35
|
mountOnEnter: !initialMounted,
|
|
36
36
|
unmountOnExit: unmountOnClose,
|
|
37
37
|
timeout: transitionTimeout ?? 500,
|
|
38
|
-
enter: getTransition(transition,
|
|
39
|
-
exit: getTransition(transition,
|
|
38
|
+
enter: getTransition(transition, 'open'),
|
|
39
|
+
exit: getTransition(transition, 'close'),
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
return [{ state: MenuStateMap[state.status], endTransition }, toggleMenu];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useState } from
|
|
1
|
+
import { useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { ControlledMenuProps, FocusPosition, MenuStateOptions } from
|
|
4
|
-
import { useMenuState } from
|
|
3
|
+
import { ControlledMenuProps, FocusPosition, MenuStateOptions } from '../types';
|
|
4
|
+
import { useMenuState } from './useMenuState';
|
|
5
5
|
|
|
6
6
|
export const useMenuStateAndFocus = (
|
|
7
7
|
options: MenuStateOptions,
|
|
8
8
|
): [any, (open?: boolean) => void, (position?: FocusPosition, alwaysUpdate?: boolean) => void] => {
|
|
9
9
|
const [menuProps, toggleMenu] = useMenuState(options);
|
|
10
|
-
const [menuItemFocus, setMenuItemFocus] = useState<ControlledMenuProps[
|
|
10
|
+
const [menuItemFocus, setMenuItemFocus] = useState<ControlledMenuProps['menuItemFocus']>();
|
|
11
11
|
|
|
12
12
|
const openMenu = (position?: FocusPosition, alwaysUpdate?: boolean) => {
|
|
13
13
|
setMenuItemFocus({ position, alwaysUpdate });
|
package/src/react-menu3/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { Menu } from
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
1
|
+
export { ControlledMenu } from './components/ControlledMenu';
|
|
2
|
+
export { FocusableItem } from './components/FocusableItem';
|
|
3
|
+
export { Menu } from './components/Menu';
|
|
4
|
+
export { MenuButton } from './components/MenuButton';
|
|
5
|
+
export { MenuDivider } from './components/MenuDivider';
|
|
6
|
+
export { MenuGroup } from './components/MenuGroup';
|
|
7
|
+
export { MenuHeader } from './components/MenuHeader';
|
|
8
|
+
export { MenuItem } from './components/MenuItem';
|
|
9
|
+
export { MenuRadioGroup } from './components/MenuRadioGroup';
|
|
10
|
+
export { SubMenu } from './components/SubMenu';
|
|
11
|
+
export { useMenuState } from './hooks';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MutableRefObject } from
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
2
|
|
|
3
|
-
import { parsePadding } from
|
|
3
|
+
import { parsePadding } from '../utils';
|
|
4
4
|
|
|
5
5
|
export const getPositionHelpers = (
|
|
6
6
|
containerRef: MutableRefObject<HTMLElement | undefined>,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { getPositionHelpers } from
|
|
2
|
-
export { positionContextMenu } from
|
|
3
|
-
export { positionMenu } from
|
|
1
|
+
export { getPositionHelpers } from './getPositionHelpers';
|
|
2
|
+
export { positionContextMenu } from './positionContextMenu';
|
|
3
|
+
export { positionMenu } from './positionMenu';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MutableRefObject } from
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
2
|
|
|
3
|
-
import { MenuDirection } from
|
|
4
|
-
import { getPositionHelpers } from
|
|
5
|
-
import { placeArrowVertical } from
|
|
3
|
+
import { MenuDirection } from '../types';
|
|
4
|
+
import { getPositionHelpers } from './getPositionHelpers';
|
|
5
|
+
import { placeArrowVertical } from './placeArrowVertical';
|
|
6
6
|
|
|
7
7
|
export interface placeLeftorRightParams {
|
|
8
8
|
anchorRect: DOMRect;
|
|
@@ -12,7 +12,7 @@ export interface placeLeftorRightParams {
|
|
|
12
12
|
arrowRef: MutableRefObject<HTMLElement | null>;
|
|
13
13
|
arrow?: boolean;
|
|
14
14
|
direction: MenuDirection;
|
|
15
|
-
position:
|
|
15
|
+
position: 'auto' | 'anchor' | 'initial';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const placeLeftorRight = (
|
|
@@ -36,9 +36,9 @@ export const placeLeftorRight = (
|
|
|
36
36
|
} = props;
|
|
37
37
|
let computedDirection = direction;
|
|
38
38
|
let y = placeLeftorRightY;
|
|
39
|
-
if (position !==
|
|
39
|
+
if (position !== 'initial') {
|
|
40
40
|
y = confineVertically(y);
|
|
41
|
-
if (position ===
|
|
41
|
+
if (position === 'anchor') {
|
|
42
42
|
// restrict menu to the edge of anchor element
|
|
43
43
|
y = Math.min(y, anchorRect.bottom - containerRect.top);
|
|
44
44
|
y = Math.max(y, anchorRect.top - containerRect.top - menuRect.height);
|
|
@@ -46,10 +46,10 @@ export const placeLeftorRight = (
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
let x, leftOverflow, rightOverflow;
|
|
49
|
-
if (computedDirection ===
|
|
49
|
+
if (computedDirection === 'left') {
|
|
50
50
|
x = placeLeftX;
|
|
51
51
|
|
|
52
|
-
if (position !==
|
|
52
|
+
if (position !== 'initial') {
|
|
53
53
|
// if menu overflows to the left,
|
|
54
54
|
// try to reposition it to the right of the anchor.
|
|
55
55
|
leftOverflow = getLeftOverflow(x);
|
|
@@ -59,7 +59,7 @@ export const placeLeftorRight = (
|
|
|
59
59
|
rightOverflow = getRightOverflow(placeRightX);
|
|
60
60
|
if (rightOverflow <= 0 || -leftOverflow > rightOverflow) {
|
|
61
61
|
x = placeRightX;
|
|
62
|
-
computedDirection =
|
|
62
|
+
computedDirection = 'right';
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -67,19 +67,19 @@ export const placeLeftorRight = (
|
|
|
67
67
|
// Opposite logic to the 'left' direction above
|
|
68
68
|
x = placeRightX;
|
|
69
69
|
|
|
70
|
-
if (position !==
|
|
70
|
+
if (position !== 'initial') {
|
|
71
71
|
rightOverflow = getRightOverflow(x);
|
|
72
72
|
if (rightOverflow > 0) {
|
|
73
73
|
leftOverflow = getLeftOverflow(placeLeftX);
|
|
74
74
|
if (leftOverflow >= 0 || -leftOverflow < rightOverflow) {
|
|
75
75
|
x = placeLeftX;
|
|
76
|
-
computedDirection =
|
|
76
|
+
computedDirection = 'left';
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
if (position ===
|
|
82
|
+
if (position === 'auto') x = confineHorizontally(x);
|
|
83
83
|
const arrowY = arrow
|
|
84
84
|
? placeArrowVertical({
|
|
85
85
|
menuY: y,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MutableRefObject } from
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
2
|
|
|
3
|
-
import { MenuDirection } from
|
|
4
|
-
import { getPositionHelpers } from
|
|
5
|
-
import { placeArrowHorizontal } from
|
|
3
|
+
import { MenuDirection } from '../types';
|
|
4
|
+
import { getPositionHelpers } from './getPositionHelpers';
|
|
5
|
+
import { placeArrowHorizontal } from './placeArrowHorizontal';
|
|
6
6
|
|
|
7
7
|
export interface placeToporBottomParams {
|
|
8
8
|
anchorRect: DOMRect;
|
|
@@ -11,8 +11,8 @@ export interface placeToporBottomParams {
|
|
|
11
11
|
placeBottomY: number;
|
|
12
12
|
arrowRef: MutableRefObject<HTMLElement | null>;
|
|
13
13
|
arrow?: boolean;
|
|
14
|
-
direction:
|
|
15
|
-
position:
|
|
14
|
+
direction: 'left' | 'right' | 'top' | 'bottom';
|
|
15
|
+
position: 'auto' | 'anchor' | 'initial';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const placeToporBottom = (
|
|
@@ -35,11 +35,11 @@ export const placeToporBottom = (
|
|
|
35
35
|
position,
|
|
36
36
|
} = props;
|
|
37
37
|
// make sure invalid direction is treated as 'bottom'
|
|
38
|
-
let computedDirection: MenuDirection = direction ===
|
|
38
|
+
let computedDirection: MenuDirection = direction === 'top' ? 'top' : 'bottom';
|
|
39
39
|
let x = placeToporBottomX;
|
|
40
|
-
if (position !==
|
|
40
|
+
if (position !== 'initial') {
|
|
41
41
|
x = confineHorizontally(x);
|
|
42
|
-
if (position ===
|
|
42
|
+
if (position === 'anchor') {
|
|
43
43
|
// restrict menu to the edge of anchor element
|
|
44
44
|
x = Math.min(x, anchorRect.right - containerRect.left);
|
|
45
45
|
x = Math.max(x, anchorRect.left - containerRect.left - menuRect.width);
|
|
@@ -47,10 +47,10 @@ export const placeToporBottom = (
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
let y, topOverflow, bottomOverflow;
|
|
50
|
-
if (computedDirection ===
|
|
50
|
+
if (computedDirection === 'top') {
|
|
51
51
|
y = placeTopY;
|
|
52
52
|
|
|
53
|
-
if (position !==
|
|
53
|
+
if (position !== 'initial') {
|
|
54
54
|
// if menu overflows to the top,
|
|
55
55
|
// try to reposition it to the bottom of the anchor.
|
|
56
56
|
topOverflow = getTopOverflow(y);
|
|
@@ -60,7 +60,7 @@ export const placeToporBottom = (
|
|
|
60
60
|
bottomOverflow = getBottomOverflow(placeBottomY);
|
|
61
61
|
if (bottomOverflow <= 0 || -topOverflow > bottomOverflow) {
|
|
62
62
|
y = placeBottomY;
|
|
63
|
-
computedDirection =
|
|
63
|
+
computedDirection = 'bottom';
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -68,19 +68,19 @@ export const placeToporBottom = (
|
|
|
68
68
|
// Opposite logic to the 'top' direction above
|
|
69
69
|
y = placeBottomY;
|
|
70
70
|
|
|
71
|
-
if (position !==
|
|
71
|
+
if (position !== 'initial') {
|
|
72
72
|
bottomOverflow = getBottomOverflow(y);
|
|
73
73
|
if (bottomOverflow > 0) {
|
|
74
74
|
topOverflow = getTopOverflow(placeTopY);
|
|
75
75
|
if (topOverflow >= 0 || -topOverflow < bottomOverflow) {
|
|
76
76
|
y = placeTopY;
|
|
77
|
-
computedDirection =
|
|
77
|
+
computedDirection = 'top';
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
if (position ===
|
|
83
|
+
if (position === 'auto') y = confineVertically(y);
|
|
84
84
|
const arrowX = arrow
|
|
85
85
|
? placeArrowHorizontal({
|
|
86
86
|
menuX: x,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MenuDirection } from
|
|
2
|
-
import { getPositionHelpers } from
|
|
1
|
+
import { MenuDirection } from '../types';
|
|
2
|
+
import { getPositionHelpers } from './getPositionHelpers';
|
|
3
3
|
|
|
4
4
|
export const positionContextMenu = ({
|
|
5
5
|
positionHelpers,
|
|
@@ -45,14 +45,14 @@ export const positionContextMenu = ({
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// Similar logic to the left and right side above.
|
|
48
|
-
let computedDirection: MenuDirection =
|
|
48
|
+
let computedDirection: MenuDirection = 'bottom';
|
|
49
49
|
const bottomOverflow = getBottomOverflow(y);
|
|
50
50
|
if (bottomOverflow > 0) {
|
|
51
51
|
const adjustedY = y - menuRect.height;
|
|
52
52
|
const topOverflow = getTopOverflow(adjustedY);
|
|
53
53
|
if (topOverflow >= 0 || -topOverflow < bottomOverflow) {
|
|
54
54
|
y = adjustedY;
|
|
55
|
-
computedDirection =
|
|
55
|
+
computedDirection = 'top';
|
|
56
56
|
}
|
|
57
57
|
y = confineVertically(y);
|
|
58
58
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { MutableRefObject } from
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
2
|
|
|
3
|
-
import { MenuDirection } from
|
|
4
|
-
import { getPositionHelpers } from
|
|
5
|
-
import { placeLeftorRight } from
|
|
6
|
-
import { placeToporBottom } from
|
|
3
|
+
import { MenuDirection } from '../types';
|
|
4
|
+
import { getPositionHelpers } from './getPositionHelpers';
|
|
5
|
+
import { placeLeftorRight } from './placeLeftorRight';
|
|
6
|
+
import { placeToporBottom } from './placeToporBottom';
|
|
7
7
|
|
|
8
8
|
interface positionMenuProps {
|
|
9
9
|
offsetX: number;
|
|
@@ -12,8 +12,8 @@ interface positionMenuProps {
|
|
|
12
12
|
anchorRef: MutableRefObject<Element | null>;
|
|
13
13
|
arrow?: boolean;
|
|
14
14
|
direction: MenuDirection;
|
|
15
|
-
position:
|
|
16
|
-
align:
|
|
15
|
+
position: 'auto' | 'anchor' | 'initial';
|
|
16
|
+
align: 'start' | 'center' | 'end';
|
|
17
17
|
positionHelpers: ReturnType<typeof getPositionHelpers>;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -24,7 +24,7 @@ export const positionMenu = (props: positionMenuProps) => {
|
|
|
24
24
|
let horizontalOffset = offsetX;
|
|
25
25
|
let verticalOffset = offsetY;
|
|
26
26
|
if (arrow && arrowRef.current) {
|
|
27
|
-
if (direction ===
|
|
27
|
+
if (direction === 'left' || direction === 'right') {
|
|
28
28
|
horizontalOffset += arrowRef.current.offsetWidth;
|
|
29
29
|
} else {
|
|
30
30
|
verticalOffset += arrowRef.current.offsetHeight;
|
|
@@ -40,10 +40,10 @@ export const positionMenu = (props: positionMenuProps) => {
|
|
|
40
40
|
const placeBottomY = anchorRect.bottom - containerRect.top + verticalOffset;
|
|
41
41
|
|
|
42
42
|
let placeToporBottomX, placeLeftorRightY;
|
|
43
|
-
if (align ===
|
|
43
|
+
if (align === 'end') {
|
|
44
44
|
placeToporBottomX = anchorRect.right - containerRect.left - menuRect.width;
|
|
45
45
|
placeLeftorRightY = anchorRect.bottom - containerRect.top - menuRect.height;
|
|
46
|
-
} else if (align ===
|
|
46
|
+
} else if (align === 'center') {
|
|
47
47
|
placeToporBottomX = anchorRect.left - containerRect.left - (menuRect.width - anchorRect.width) / 2;
|
|
48
48
|
placeLeftorRightY = anchorRect.top - containerRect.top - (menuRect.height - anchorRect.height) / 2;
|
|
49
49
|
} else {
|
|
@@ -69,12 +69,12 @@ export const positionMenu = (props: positionMenuProps) => {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
switch (direction) {
|
|
72
|
-
case
|
|
73
|
-
case
|
|
72
|
+
case 'left':
|
|
73
|
+
case 'right':
|
|
74
74
|
return placeLeftorRight(options);
|
|
75
75
|
|
|
76
|
-
case
|
|
77
|
-
case
|
|
76
|
+
case 'top':
|
|
77
|
+
case 'bottom':
|
|
78
78
|
default:
|
|
79
79
|
return placeToporBottom(options);
|
|
80
80
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
menuItemClass,
|
|
10
10
|
radioGroupClass,
|
|
11
11
|
subMenuClass,
|
|
12
|
-
} from
|
|
12
|
+
} from '../utils';
|
|
13
13
|
|
|
14
14
|
const bem =
|
|
15
15
|
(block: string) =>
|
|
@@ -23,13 +23,13 @@ const bem =
|
|
|
23
23
|
|
|
24
24
|
const createSelector = (blockElement: (modifier?: string) => string, modifiers: string[] = []) => {
|
|
25
25
|
const selectorObj = {};
|
|
26
|
-
Object.defineProperty(selectorObj,
|
|
26
|
+
Object.defineProperty(selectorObj, 'name', {
|
|
27
27
|
value: blockElement(),
|
|
28
28
|
enumerable: true,
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
modifiers.forEach((modifier) => {
|
|
32
|
-
const selector = modifier.split(
|
|
32
|
+
const selector = modifier.split('-').reduce((prev, curr) => `${prev}${curr[0].toUpperCase()}${curr.slice(1)}`);
|
|
33
33
|
Object.defineProperty(selectorObj, selector, {
|
|
34
34
|
value: blockElement(modifier),
|
|
35
35
|
enumerable: true,
|
|
@@ -39,26 +39,26 @@ const createSelector = (blockElement: (modifier?: string) => string, modifiers:
|
|
|
39
39
|
return selectorObj;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
const directions = [
|
|
42
|
+
const directions = ['dir-left', 'dir-right', 'dir-top', 'dir-bottom'];
|
|
43
43
|
const menuBlock = bem(menuClass);
|
|
44
44
|
const menuSelector = createSelector(menuBlock(), [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
'state-opening',
|
|
46
|
+
'state-open',
|
|
47
|
+
'state-closing',
|
|
48
|
+
'state-closed',
|
|
49
49
|
...directions,
|
|
50
50
|
]);
|
|
51
51
|
const menuArrowSelector = createSelector(menuBlock(menuArrowClass), directions);
|
|
52
52
|
const menuItemSelector = createSelector(menuBlock(menuItemClass), [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
'hover',
|
|
54
|
+
'disabled',
|
|
55
|
+
'anchor',
|
|
56
|
+
'checked',
|
|
57
|
+
'open',
|
|
58
|
+
'submenu',
|
|
59
|
+
'focusable',
|
|
60
|
+
'type-radio',
|
|
61
|
+
'type-checkbox',
|
|
62
62
|
]);
|
|
63
63
|
|
|
64
64
|
const menuDividerSelector = createSelector(menuBlock(menuDividerClass));
|
|
@@ -66,18 +66,18 @@ const menuHeaderSelector = createSelector(menuBlock(menuHeaderClass));
|
|
|
66
66
|
const menuGroupSelector = createSelector(menuBlock(menuGroupClass));
|
|
67
67
|
const radioGroupSelector = createSelector(menuBlock(radioGroupClass));
|
|
68
68
|
const submenuSelector = createSelector(menuBlock(subMenuClass));
|
|
69
|
-
const menuContainerSelector = createSelector(bem(menuContainerClass)(), [
|
|
70
|
-
const menuButtonSelector = createSelector(bem(menuButtonClass)(), [
|
|
69
|
+
const menuContainerSelector = createSelector(bem(menuContainerClass)(), ['itemTransition']);
|
|
70
|
+
const menuButtonSelector = createSelector(bem(menuButtonClass)(), ['open']);
|
|
71
71
|
|
|
72
72
|
export {
|
|
73
|
-
menuContainerSelector,
|
|
74
|
-
menuButtonSelector,
|
|
75
|
-
menuSelector,
|
|
76
73
|
menuArrowSelector,
|
|
77
|
-
|
|
74
|
+
menuButtonSelector,
|
|
75
|
+
menuContainerSelector,
|
|
78
76
|
menuDividerSelector,
|
|
79
|
-
menuHeaderSelector,
|
|
80
77
|
menuGroupSelector,
|
|
78
|
+
menuHeaderSelector,
|
|
79
|
+
menuItemSelector,
|
|
80
|
+
menuSelector,
|
|
81
81
|
radioGroupSelector,
|
|
82
82
|
submenuSelector,
|
|
83
83
|
};
|
package/src/react-menu3/types.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
//
|
|
2
2
|
// base types
|
|
3
3
|
// ----------------------------------------------------------------------
|
|
4
|
-
import { ForwardedRef, MutableRefObject } from
|
|
4
|
+
import { ForwardedRef, MutableRefObject } from 'react';
|
|
5
5
|
|
|
6
|
-
export type MenuState =
|
|
7
|
-
export type MenuAlign =
|
|
8
|
-
export type MenuDirection =
|
|
9
|
-
export type MenuPosition =
|
|
10
|
-
export type MenuOverflow =
|
|
11
|
-
export type MenuReposition =
|
|
12
|
-
export type MenuViewScroll =
|
|
13
|
-
export type MenuItemTypeProp =
|
|
14
|
-
export type CloseReason =
|
|
6
|
+
export type MenuState = 'opening' | 'open' | 'closing' | 'closed';
|
|
7
|
+
export type MenuAlign = 'start' | 'center' | 'end';
|
|
8
|
+
export type MenuDirection = 'left' | 'right' | 'top' | 'bottom';
|
|
9
|
+
export type MenuPosition = 'auto' | 'anchor' | 'initial';
|
|
10
|
+
export type MenuOverflow = 'auto' | 'visible' | 'hidden';
|
|
11
|
+
export type MenuReposition = 'auto' | 'initial';
|
|
12
|
+
export type MenuViewScroll = 'auto' | 'close' | 'initial';
|
|
13
|
+
export type MenuItemTypeProp = 'checkbox' | 'radio';
|
|
14
|
+
export type CloseReason = 'click' | 'cancel' | 'blur' | 'scroll';
|
|
15
15
|
/**
|
|
16
16
|
* - `'first'` focus the first item in the menu.
|
|
17
17
|
* - `'last'` focus the last item in the menu.
|
|
18
18
|
* - `number` focus item at the specific position (zero-based).
|
|
19
19
|
*/
|
|
20
|
-
export type FocusPosition =
|
|
20
|
+
export type FocusPosition = 'first' | 'last' | number;
|
|
21
21
|
|
|
22
22
|
export type ClassNameProp<M = undefined> = string | ((modifiers: M) => string);
|
|
23
23
|
|
|
24
24
|
export type RenderProp<M, R = React.ReactNode> = R | ((modifiers: M) => R);
|
|
25
25
|
|
|
26
|
-
export interface BaseProps<M = undefined> extends Omit<React.HTMLAttributes<HTMLElement>,
|
|
26
|
+
export interface BaseProps<M = undefined> extends Omit<React.HTMLAttributes<HTMLElement>, 'className' | 'children'> {
|
|
27
27
|
ref?: React.Ref<any>;
|
|
28
28
|
/**
|
|
29
29
|
* Can be a string or a function which receives a modifier object and returns a CSS `class` string.
|
|
@@ -31,7 +31,7 @@ export interface BaseProps<M = undefined> extends Omit<React.HTMLAttributes<HTML
|
|
|
31
31
|
className?: ClassNameProp<M>;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export interface BasePropsWithChildren<M = undefined> extends Omit<React.HTMLAttributes<HTMLElement>,
|
|
34
|
+
export interface BasePropsWithChildren<M = undefined> extends Omit<React.HTMLAttributes<HTMLElement>, 'className'> {
|
|
35
35
|
ref?: React.Ref<any>;
|
|
36
36
|
/**
|
|
37
37
|
* Can be a string or a function which receives a modifier object and returns a CSS `class` string.
|
|
@@ -157,7 +157,7 @@ export interface Hoverable {
|
|
|
157
157
|
/**
|
|
158
158
|
* Common props for `Menu`, `SubMenu` and `ControlledMenu`
|
|
159
159
|
*/
|
|
160
|
-
interface BaseMenuProps extends Omit<BaseProps,
|
|
160
|
+
interface BaseMenuProps extends Omit<BaseProps, 'style'> {
|
|
161
161
|
/**
|
|
162
162
|
* Can be a string or a function which receives a modifier object and returns a CSS `class` string.
|
|
163
163
|
*/
|
|
@@ -310,7 +310,7 @@ export interface RootMenuProps extends BaseMenuProps, MenuStateOptions {
|
|
|
310
310
|
/**
|
|
311
311
|
* Properties of this object are spread to the root DOM element containing the menu.
|
|
312
312
|
*/
|
|
313
|
-
containerProps?: Omit<React.HTMLAttributes<HTMLElement>,
|
|
313
|
+
containerProps?: Omit<React.HTMLAttributes<HTMLElement>, 'className'>;
|
|
314
314
|
/**
|
|
315
315
|
* A ref object attached to a DOM element within which menu will be positioned.
|
|
316
316
|
* If not provided, the nearest ancestor which has CSS `overflow` set to a value
|