@linzjs/step-ag-grid 1.5.4 → 2.0.1
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/README.md +117 -2
- package/{src/components → dist}/GridTheme.scss +37 -23
- package/dist/index.css +351 -0
- package/dist/index.js +625 -332
- package/dist/index.js.map +1 -1
- package/dist/src/components/ComponentLoadingWrapper.d.ts +1 -0
- package/dist/src/components/Grid.d.ts +0 -2
- package/dist/src/components/GridCell.d.ts +21 -27
- package/dist/src/components/GridPopoverHook.d.ts +5 -2
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +10 -4
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +5 -5
- package/dist/src/components/gridForm/GridFormMessage.d.ts +4 -5
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +5 -4
- package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -3
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +5 -270
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +3 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +3 -2
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +4 -5
- package/dist/src/contexts/GridContext.d.ts +1 -1
- package/dist/src/contexts/GridPopoverContext.d.ts +17 -0
- package/dist/src/contexts/GridPopoverContextProvider.d.ts +6 -0
- package/dist/src/contexts/{UpdatingContext.d.ts → GridUpdatingContext.d.ts} +2 -2
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +7 -0
- package/dist/src/index.d.ts +31 -0
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -21
- package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +7 -0
- package/dist/src/react-menu3/contexts/HoverItemContext.d.ts +2 -0
- package/dist/src/react-menu3/contexts/ItemSettingsContext.d.ts +5 -0
- package/dist/src/react-menu3/contexts/MenuListContext.d.ts +9 -0
- package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +11 -0
- package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +7 -0
- package/dist/src/react-menu3/contexts/SettingsContext.d.ts +20 -0
- package/dist/src/react-menu3/index.d.ts +0 -1
- package/dist/src/react-menu3/utils/constants.d.ts +1 -50
- package/dist/step-ag-grid.esm.js +622 -312
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +39 -26
- package/src/components/ComponentLoadingWrapper.tsx +2 -1
- package/src/components/Grid.tsx +3 -8
- package/src/components/GridCell.tsx +62 -79
- package/src/components/GridLoadableCell.tsx +0 -1
- package/src/components/GridPopoverHook.tsx +18 -16
- package/src/components/gridForm/GridFormDropDown.tsx +47 -32
- package/src/components/gridForm/GridFormEditBearing.tsx +14 -14
- package/src/components/gridForm/GridFormMessage.tsx +11 -17
- package/src/components/gridForm/GridFormMultiSelect.tsx +89 -79
- package/src/components/gridForm/GridFormPopoutMenu.tsx +10 -11
- package/src/components/gridForm/GridFormTextArea.tsx +16 -17
- package/src/components/gridForm/GridFormTextInput.tsx +17 -17
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +20 -15
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +53 -45
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +21 -15
- package/src/components/gridPopoverEdit/GridPopoverMenu.scss +4 -4
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +21 -23
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +18 -16
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +12 -16
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +15 -15
- package/src/components/gridRender/GridRenderGenericCell.tsx +5 -6
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +2 -2
- package/src/contexts/GridContext.tsx +1 -1
- package/src/contexts/GridContextProvider.tsx +3 -5
- package/src/contexts/GridPopoverContext.tsx +26 -0
- package/src/contexts/GridPopoverContextProvider.tsx +54 -0
- package/src/contexts/{UpdatingContext.tsx → GridUpdatingContext.tsx} +2 -2
- package/src/contexts/{UpdatingContextProvider.tsx → GridUpdatingContextProvider.tsx} +8 -6
- package/src/index.ts +38 -0
- package/src/lui/TextInputFormatted.scss +1 -1
- package/src/react-menu3/README.md +66 -0
- package/src/react-menu3/components/ControlledMenu.tsx +9 -17
- package/src/react-menu3/components/FocusableItem.tsx +2 -9
- package/src/react-menu3/components/MenuGroup.tsx +2 -1
- package/src/react-menu3/components/MenuItem.tsx +3 -12
- package/src/react-menu3/components/MenuList.tsx +4 -4
- package/src/react-menu3/components/MenuRadioGroup.tsx +3 -22
- package/src/react-menu3/components/SubMenu.tsx +4 -4
- package/src/react-menu3/contexts/EventHandlersContext.ts +11 -0
- package/src/react-menu3/contexts/HoverItemContext.ts +3 -0
- package/src/react-menu3/contexts/ItemSettingsContext.ts +6 -0
- package/src/react-menu3/contexts/MenuListContext.ts +10 -0
- package/src/react-menu3/contexts/MenuListItemContext.ts +16 -0
- package/src/react-menu3/contexts/RadioGroupContext.ts +8 -0
- package/src/react-menu3/contexts/SettingsContext.ts +20 -0
- package/src/react-menu3/hooks/useItemState.ts +3 -1
- package/src/react-menu3/index.ts +0 -1
- package/src/react-menu3/styles/_var.scss +4 -4
- package/src/react-menu3/styles/core.scss +6 -6
- package/src/react-menu3/styles/index.scss +10 -7
- package/src/react-menu3/styles/theme-dark.scss +4 -2
- package/src/react-menu3/styles/transitions/slide.scss +8 -8
- package/src/react-menu3/utils/constants.ts +1 -74
- package/src/react-menu3/utils/withHovering.tsx +1 -1
- package/src/stories/components/FormTest.scss +1 -2
- package/src/stories/components/FormTest.tsx +4 -3
- package/src/stories/components/GridPopoutBearing.stories.tsx +30 -26
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +94 -51
- package/src/stories/components/GridPopoutEditGeneric.stories.tsx +18 -14
- package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +78 -62
- package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +60 -52
- package/src/stories/components/GridReadOnly.stories.tsx +77 -64
- package/src/stories/components/ReactMenu.stories.tsx +0 -4
- package/src/{components → styles}/Grid.scss +9 -6
- package/src/styles/GridFormDropDown.scss +18 -0
- package/src/{components/gridForm → styles}/GridFormEditBearing.scss +0 -0
- package/src/styles/GridFormMultiSelect.scss +18 -0
- package/src/styles/GridRenderGenericCell.scss +15 -0
- package/src/styles/GridTheme.scss +108 -0
- package/src/styles/index.scss +2 -0
- package/src/styles/lui-overrides.scss +49 -0
- package/src/styles/react-menu-customisations.scss +135 -0
- package/dist/index.d.ts +0 -38
- package/dist/src/contexts/UpdatingContextProvider.d.ts +0 -7
- package/dist/src/stories/components/FormTest.d.ts +0 -13
- package/dist/src/stories/components/GridPopoutBearing.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditDropDown.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditGeneric.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditGenericTextArea.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditMultiSelect.stories.d.ts +0 -9
- package/dist/src/stories/components/GridReadOnly.stories.d.ts +0 -9
- package/dist/src/stories/components/ReactMenu.stories.d.ts +0 -8
- package/src/components/gridRender/GridRenderGenericCell.scss +0 -15
- package/src/lui-overrides.scss +0 -163
- package/src/react-menu3/style-utils.d.ts +0 -110
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# React-Menu
|
|
2
|
+
|
|
3
|
+
> This is a fork of @szhsin/react-menu. v3.2.0
|
|
4
|
+
|
|
5
|
+
> An accessible and keyboard-friendly React menu library.
|
|
6
|
+
|
|
7
|
+
**[Live examples and docs](https://szhsin.github.io/react-menu/)**
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- React menu components for easy and fast web development.
|
|
12
|
+
- Unlimited levels of submenu.
|
|
13
|
+
- Supports dropdown or context menu.
|
|
14
|
+
- Supports radio and checkbox menu items.
|
|
15
|
+
- Flexible menu positioning.
|
|
16
|
+
- Comprehensive keyboard interactions.
|
|
17
|
+
- Unstyled components and easy [customisation](https://szhsin.github.io/react-menu/#styling).
|
|
18
|
+
- [Optimal level support](https://github.com/reactwg/react-18/discussions/70) (level 3) of **React 18** concurrent rendering.
|
|
19
|
+
- Works in major browsers without polyfills.
|
|
20
|
+
- [WAI-ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/menu/) compliant.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
with npm
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @szhsin/react-menu
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
or with Yarn
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
yarn add @szhsin/react-menu
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
import { Menu, MenuItem, MenuButton, SubMenu } from "@szhsin/react-menu";
|
|
40
|
+
|
|
41
|
+
export default function App() {
|
|
42
|
+
return (
|
|
43
|
+
<Menu menuButton={<MenuButton>Open menu</MenuButton>}>
|
|
44
|
+
<MenuItem>New File</MenuItem>
|
|
45
|
+
<MenuItem>Save</MenuItem>
|
|
46
|
+
<SubMenu label="Edit">
|
|
47
|
+
<MenuItem>Cut</MenuItem>
|
|
48
|
+
<MenuItem>Copy</MenuItem>
|
|
49
|
+
<MenuItem>Paste</MenuItem>
|
|
50
|
+
</SubMenu>
|
|
51
|
+
<MenuItem>Print...</MenuItem>
|
|
52
|
+
</Menu>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**[Edit on CodeSandbox](https://codesandbox.io/s/react-menu-starter-3ez3c)**<br>
|
|
58
|
+
**[Visit more examples and docs](https://szhsin.github.io/react-menu/)**<br><br>
|
|
59
|
+
[Migration from v2 to v3](https://github.com/szhsin/react-menu/wiki/Migration-from-v2-to-v3)<br>
|
|
60
|
+
[Migration from v1 to v2](https://github.com/szhsin/react-menu/wiki/Migration-from-v1-to-v2)
|
|
61
|
+
|
|
62
|
+
_Please note that React-Menu v3 requires React 16.14.0 or higher. If you are not able to upgrade React, you could install v2/v1 which requires React 16.8.0._
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
[MIT](https://github.com/szhsin/react-menu/blob/master/LICENSE) Licensed.
|
|
@@ -12,20 +12,12 @@ import {
|
|
|
12
12
|
import { createPortal } from "react-dom";
|
|
13
13
|
import { MenuList } from "./MenuList";
|
|
14
14
|
import { useBEM } from "../hooks";
|
|
15
|
-
import {
|
|
16
|
-
menuContainerClass,
|
|
17
|
-
mergeProps,
|
|
18
|
-
safeCall,
|
|
19
|
-
isMenuOpen,
|
|
20
|
-
getTransition,
|
|
21
|
-
CloseReason,
|
|
22
|
-
Keys,
|
|
23
|
-
EventHandlersContext,
|
|
24
|
-
SettingsContext,
|
|
25
|
-
ItemSettingsContext,
|
|
26
|
-
} from "../utils";
|
|
15
|
+
import { menuContainerClass, mergeProps, safeCall, isMenuOpen, getTransition, CloseReason, Keys } from "../utils";
|
|
27
16
|
import { hasParentClass } from "@utils/util";
|
|
28
17
|
import { ControlledMenuProps, PortalFieldType, RadioChangeEvent } from "../types";
|
|
18
|
+
import { ItemSettingsContext } from "../contexts/ItemSettingsContext";
|
|
19
|
+
import { SettingsContext } from "../contexts/SettingsContext";
|
|
20
|
+
import { EventHandlersContext, EventHandlersContextType } from "../contexts/EventHandlersContext";
|
|
29
21
|
|
|
30
22
|
export const ControlledMenuFr = (
|
|
31
23
|
{
|
|
@@ -128,13 +120,13 @@ export const ControlledMenuFr = (
|
|
|
128
120
|
useEffect(() => {
|
|
129
121
|
if (isMenuOpen(state)) {
|
|
130
122
|
const thisDocument = anchorRef?.current ? anchorRef?.current.ownerDocument : document;
|
|
131
|
-
thisDocument.addEventListener("mousedown",
|
|
132
|
-
thisDocument.addEventListener("mouseup",
|
|
123
|
+
thisDocument.addEventListener("mousedown", handleScreenEventForSave, true);
|
|
124
|
+
thisDocument.addEventListener("mouseup", handleScreenEventForCancel, true);
|
|
133
125
|
thisDocument.addEventListener("click", handleScreenEventForCancel, true);
|
|
134
126
|
thisDocument.addEventListener("dblclick", handleScreenEventForCancel, true);
|
|
135
127
|
return () => {
|
|
136
|
-
thisDocument.removeEventListener("mousedown",
|
|
137
|
-
thisDocument.removeEventListener("mouseup",
|
|
128
|
+
thisDocument.removeEventListener("mousedown", handleScreenEventForSave, true);
|
|
129
|
+
thisDocument.removeEventListener("mouseup", handleScreenEventForCancel, true);
|
|
138
130
|
thisDocument.removeEventListener("click", handleScreenEventForCancel, true);
|
|
139
131
|
thisDocument.removeEventListener("dblclick", handleScreenEventForCancel, true);
|
|
140
132
|
};
|
|
@@ -151,7 +143,7 @@ export const ControlledMenuFr = (
|
|
|
151
143
|
);
|
|
152
144
|
|
|
153
145
|
const eventHandlers = useMemo(
|
|
154
|
-
() => ({
|
|
146
|
+
(): EventHandlersContextType => ({
|
|
155
147
|
handleClick(event: RadioChangeEvent, isCheckOrRadio: boolean) {
|
|
156
148
|
if (!event.stopPropagation) safeCall(onItemClick, event);
|
|
157
149
|
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { LegacyRef, useContext, useMemo, useRef } from "react";
|
|
2
2
|
import { useBEM, useCombinedRef, useItemState } from "../hooks";
|
|
3
|
-
import {
|
|
4
|
-
mergeProps,
|
|
5
|
-
commonProps,
|
|
6
|
-
safeCall,
|
|
7
|
-
menuClass,
|
|
8
|
-
menuItemClass,
|
|
9
|
-
withHovering,
|
|
10
|
-
EventHandlersContext,
|
|
11
|
-
} from "../utils";
|
|
3
|
+
import { mergeProps, commonProps, safeCall, menuClass, menuItemClass, withHovering } from "../utils";
|
|
12
4
|
import { BaseProps } from "../types";
|
|
13
5
|
import { withHoveringResultProps } from "../utils/withHovering";
|
|
6
|
+
import { EventHandlersContext } from "../contexts/EventHandlersContext";
|
|
14
7
|
|
|
15
8
|
export interface FocusableItemProps extends BaseProps, withHoveringResultProps {
|
|
16
9
|
disabled?: boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ForwardedRef, forwardRef, ReactNode, useContext, useRef, useState } from "react";
|
|
2
2
|
import { useBEM, useLayoutEffect, useCombinedRef } from "../hooks";
|
|
3
|
-
import { menuClass, menuGroupClass
|
|
3
|
+
import { menuClass, menuGroupClass } from "../utils";
|
|
4
4
|
import { BaseProps, MenuOverflow } from "../types";
|
|
5
|
+
import { MenuListContext } from "../contexts/MenuListContext";
|
|
5
6
|
|
|
6
7
|
export interface MenuGroupProps extends BaseProps {
|
|
7
8
|
children?: ReactNode;
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { Ref, useContext, useMemo } from "react";
|
|
2
2
|
import { useBEM, useItemState, useCombinedRef } from "../hooks";
|
|
3
|
-
import {
|
|
4
|
-
mergeProps,
|
|
5
|
-
commonProps,
|
|
6
|
-
safeCall,
|
|
7
|
-
menuClass,
|
|
8
|
-
menuItemClass,
|
|
9
|
-
withHovering,
|
|
10
|
-
EventHandlersContext,
|
|
11
|
-
RadioGroupContext,
|
|
12
|
-
Keys,
|
|
13
|
-
RMEvent,
|
|
14
|
-
} from "../utils";
|
|
3
|
+
import { mergeProps, commonProps, safeCall, menuClass, menuItemClass, withHovering, Keys, RMEvent } from "../utils";
|
|
15
4
|
import { BaseProps, ClickEvent, EventHandler, Hoverable, MenuItemTypeProp, RenderProp } from "../types";
|
|
16
5
|
import { withHoveringResultProps } from "../utils/withHovering";
|
|
6
|
+
import { EventHandlersContext } from "../contexts/EventHandlersContext";
|
|
7
|
+
import { RadioGroupContext } from "../contexts/RadioGroupContext";
|
|
17
8
|
|
|
18
9
|
//
|
|
19
10
|
// MenuItem
|
|
@@ -17,12 +17,12 @@ import {
|
|
|
17
17
|
Keys,
|
|
18
18
|
FocusPositions,
|
|
19
19
|
HoverActionTypes,
|
|
20
|
-
SettingsContext,
|
|
21
|
-
MenuListContext,
|
|
22
|
-
MenuListItemContext,
|
|
23
|
-
HoverItemContext,
|
|
24
20
|
} from "../utils";
|
|
25
21
|
import { ControlledMenuProps, MenuDirection } from "../types";
|
|
22
|
+
import { MenuListItemContext } from "../contexts/MenuListItemContext";
|
|
23
|
+
import { HoverItemContext } from "../contexts/HoverItemContext";
|
|
24
|
+
import { MenuListContext } from "../contexts/MenuListContext";
|
|
25
|
+
import { SettingsContext } from "../contexts/SettingsContext";
|
|
26
26
|
|
|
27
27
|
export const MenuList = ({
|
|
28
28
|
ariaLabel,
|
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
import { ForwardedRef, forwardRef, ReactNode, useMemo } from "react";
|
|
2
2
|
import { useBEM } from "../hooks";
|
|
3
|
-
import { menuClass, radioGroupClass
|
|
4
|
-
import { BaseProps,
|
|
5
|
-
|
|
6
|
-
export interface RadioChangeEvent extends Event {
|
|
7
|
-
/**
|
|
8
|
-
* The `name` prop passed to the `MenuRadioGroup` when the menu item is in a radio group.
|
|
9
|
-
*/
|
|
10
|
-
name?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Set this property on event object to control whether to keep menu open after menu item is activated.
|
|
13
|
-
* Leaving it `undefined` will behave in accordance with WAI-ARIA Authoring Practices.
|
|
14
|
-
*/
|
|
15
|
-
keepOpen?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Setting this property on event object to `true` will skip `onItemClick` event on root menu component.
|
|
18
|
-
*/
|
|
19
|
-
stopPropagation?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* DOM event object (React synthetic event)
|
|
22
|
-
*/
|
|
23
|
-
syntheticEvent: MouseEvent | KeyboardEvent;
|
|
24
|
-
}
|
|
3
|
+
import { menuClass, radioGroupClass } from "../utils";
|
|
4
|
+
import { BaseProps, EventHandler, RadioChangeEvent } from "../types";
|
|
5
|
+
import { RadioGroupContext } from "../contexts/RadioGroupContext";
|
|
25
6
|
|
|
26
7
|
//
|
|
27
8
|
// MenuRadioGroup
|
|
@@ -21,10 +21,6 @@ import {
|
|
|
21
21
|
menuItemClass,
|
|
22
22
|
isMenuOpen,
|
|
23
23
|
withHovering,
|
|
24
|
-
SettingsContext,
|
|
25
|
-
ItemSettingsContext,
|
|
26
|
-
MenuListContext,
|
|
27
|
-
MenuListItemContext,
|
|
28
24
|
Keys,
|
|
29
25
|
HoverActionTypes,
|
|
30
26
|
FocusPositions,
|
|
@@ -43,6 +39,10 @@ import {
|
|
|
43
39
|
UncontrolledMenuProps,
|
|
44
40
|
} from "../types";
|
|
45
41
|
import { withHoveringResultProps } from "../utils/withHovering";
|
|
42
|
+
import { MenuListItemContext } from "../contexts/MenuListItemContext";
|
|
43
|
+
import { MenuListContext } from "../contexts/MenuListContext";
|
|
44
|
+
import { SettingsContext } from "../contexts/SettingsContext";
|
|
45
|
+
import { ItemSettingsContext } from "../contexts/ItemSettingsContext";
|
|
46
46
|
|
|
47
47
|
//
|
|
48
48
|
// SubMenu
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
import { RMEvent } from "../utils";
|
|
3
|
+
|
|
4
|
+
export interface EventHandlersContextType {
|
|
5
|
+
handleClose?: () => void;
|
|
6
|
+
handleClick: (event: RMEvent, checked: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const EventHandlersContext = createContext<EventHandlersContextType>({
|
|
10
|
+
handleClick: () => {},
|
|
11
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, MutableRefObject } from "react";
|
|
2
|
+
import { MenuDirection, MenuOverflow } from "../types";
|
|
3
|
+
|
|
4
|
+
export const MenuListContext = createContext<{
|
|
5
|
+
overflow?: MenuOverflow;
|
|
6
|
+
overflowAmt?: number;
|
|
7
|
+
parentMenuRef?: MutableRefObject<any>;
|
|
8
|
+
parentDir?: MenuDirection;
|
|
9
|
+
reposSubmenu?: boolean;
|
|
10
|
+
}>({});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FocusPosition } from "../types";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
|
|
4
|
+
interface MenuListItemContextType {
|
|
5
|
+
isParentOpen?: boolean;
|
|
6
|
+
isSubmenuOpen?: boolean;
|
|
7
|
+
dispatch: (actionType: number, item: any, nextIndex: FocusPosition) => void;
|
|
8
|
+
updateItems: (item: any, isMounted?: boolean) => void;
|
|
9
|
+
setOpenSubmenuCount: (fn: (count: number) => number) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const MenuListItemContext = createContext<MenuListItemContextType>({
|
|
13
|
+
dispatch: () => {},
|
|
14
|
+
updateItems: () => {},
|
|
15
|
+
setOpenSubmenuCount: () => 0,
|
|
16
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// FIXME hacking a default context in here is probably bad
|
|
2
|
+
import { createContext, MutableRefObject, RefObject } from "react";
|
|
3
|
+
import { ControlledMenuProps, MenuReposition, MenuViewScroll, RectElement, TransitionFieldType } from "../types";
|
|
4
|
+
|
|
5
|
+
interface SettingsContextType extends ControlledMenuProps {
|
|
6
|
+
rootMenuRef?: MutableRefObject<any>;
|
|
7
|
+
rootAnchorRef?: MutableRefObject<any>;
|
|
8
|
+
scrollNodesRef: MutableRefObject<{ anchors?: Element[]; menu?: any }>;
|
|
9
|
+
|
|
10
|
+
initialMounted?: boolean;
|
|
11
|
+
unmountOnClose?: boolean;
|
|
12
|
+
transition?: TransitionFieldType;
|
|
13
|
+
transitionTimeout?: number;
|
|
14
|
+
boundingBoxRef?: RefObject<Element | RectElement>;
|
|
15
|
+
boundingBoxPadding?: string;
|
|
16
|
+
reposition?: MenuReposition;
|
|
17
|
+
viewScroll?: MenuViewScroll;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const SettingsContext = createContext<SettingsContextType>({} as SettingsContextType);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useRef, useContext, useEffect, FocusEvent, MutableRefObject } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { HoverActionTypes } from "../utils";
|
|
3
3
|
import { useItemEffect } from "./useItemEffect";
|
|
4
|
+
import { MenuListItemContext } from "../contexts/MenuListItemContext";
|
|
5
|
+
import { ItemSettingsContext } from "../contexts/ItemSettingsContext";
|
|
4
6
|
|
|
5
7
|
// This hook includes some common stateful logic in MenuItem and FocusableItem
|
|
6
8
|
export const useItemState = (
|
package/src/react-menu3/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@use
|
|
1
|
+
@use "sass:math";
|
|
2
2
|
|
|
3
3
|
$color: #212529;
|
|
4
4
|
$color-dark: #cad1d8;
|
|
@@ -6,9 +6,9 @@ $color-disabled: #aaa;
|
|
|
6
6
|
$color-disabled-dark: #666;
|
|
7
7
|
|
|
8
8
|
$header-color: #888;
|
|
9
|
-
$divider-color:
|
|
9
|
+
$divider-color: rgb(0 0 0 / 12%);
|
|
10
10
|
$divider-color-dark: #3a3a3a;
|
|
11
|
-
$border-color:
|
|
11
|
+
$border-color: rgb(0 0 0 / 10%);
|
|
12
12
|
$border-color-dark: #333;
|
|
13
13
|
|
|
14
14
|
$background-color: #fff;
|
|
@@ -17,4 +17,4 @@ $background-color-hover: #ebebeb;
|
|
|
17
17
|
$background-color-hover-dark: #31363c;
|
|
18
18
|
|
|
19
19
|
$arrow-size: 0.75rem;
|
|
20
|
-
$arrow-pos:
|
|
20
|
+
$arrow-pos: (math.div($arrow-size, 2));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
@use
|
|
2
|
-
@use
|
|
1
|
+
@use "var";
|
|
2
|
+
@use "mixins";
|
|
3
3
|
|
|
4
4
|
.szh-menu {
|
|
5
|
-
@include mixins.reset-list;
|
|
6
|
-
@include mixins.remove-focus;
|
|
5
|
+
@include mixins.reset-list ();
|
|
6
|
+
@include mixins.remove-focus ();
|
|
7
7
|
box-sizing: border-box;
|
|
8
8
|
width: max-content;
|
|
9
9
|
z-index: 100;
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
&__item {
|
|
45
|
-
@include mixins.remove-focus;
|
|
45
|
+
@include mixins.remove-focus ();
|
|
46
46
|
cursor: pointer;
|
|
47
47
|
|
|
48
48
|
&--hover {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
&__radio-group {
|
|
68
|
-
@include mixins.reset-list;
|
|
68
|
+
@include mixins.reset-list ();
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
&__divider {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
@use
|
|
2
|
-
@use
|
|
1
|
+
@use "var";
|
|
2
|
+
@use "core";
|
|
3
3
|
|
|
4
4
|
.szh-menu {
|
|
5
5
|
user-select: none;
|
|
6
6
|
color: var.$color;
|
|
7
7
|
border: none;
|
|
8
8
|
border-radius: 0.25rem;
|
|
9
|
-
box-shadow: 0 3px 7px
|
|
9
|
+
box-shadow: 0 3px 7px rgb(0 0 0 / 13.3%), 0 0.6px 2px rgb(0 0 0 / 10%);
|
|
10
10
|
min-width: 10rem;
|
|
11
11
|
padding: 0.5rem 0;
|
|
12
12
|
|
|
@@ -26,8 +26,9 @@
|
|
|
26
26
|
|
|
27
27
|
&--type-radio {
|
|
28
28
|
padding-left: 2.2rem;
|
|
29
|
+
|
|
29
30
|
&::before {
|
|
30
|
-
content:
|
|
31
|
+
content: "\25cb";
|
|
31
32
|
position: absolute;
|
|
32
33
|
left: 0.8rem;
|
|
33
34
|
top: 0.55rem;
|
|
@@ -36,11 +37,12 @@
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
&--type-radio#{&}--checked::before {
|
|
39
|
-
content:
|
|
40
|
+
content: "\25cf";
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
&--type-checkbox {
|
|
43
44
|
padding-left: 2.2rem;
|
|
45
|
+
|
|
44
46
|
&::before {
|
|
45
47
|
position: absolute;
|
|
46
48
|
left: 0.8rem;
|
|
@@ -48,14 +50,15 @@
|
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
&--type-checkbox#{&}--checked::before {
|
|
51
|
-
content:
|
|
53
|
+
content: "\2714";
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
&__submenu > .szh-menu__item {
|
|
56
58
|
padding-right: 2.5rem;
|
|
59
|
+
|
|
57
60
|
&::after {
|
|
58
|
-
content:
|
|
61
|
+
content: "\276f";
|
|
59
62
|
position: absolute;
|
|
60
63
|
right: 1rem;
|
|
61
64
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
@use
|
|
1
|
+
@use "var";
|
|
2
2
|
|
|
3
3
|
.szh-menu-container--theme-dark .szh-menu {
|
|
4
4
|
color: var.$color-dark;
|
|
5
5
|
background-color: var.$background-color-dark;
|
|
6
6
|
border: 1px solid var.$border-color-dark;
|
|
7
|
-
box-shadow: 0 2px 9px 3px
|
|
7
|
+
box-shadow: 0 2px 9px 3px rgb(0 0 0 / 25%);
|
|
8
8
|
|
|
9
9
|
&__arrow {
|
|
10
10
|
background-color: var.$background-color-dark;
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
&--hover {
|
|
17
17
|
background-color: var.$background-color-hover-dark;
|
|
18
18
|
}
|
|
19
|
+
|
|
19
20
|
&--focusable {
|
|
20
21
|
background-color: inherit;
|
|
21
22
|
}
|
|
23
|
+
|
|
22
24
|
&--disabled {
|
|
23
25
|
color: var.$color-disabled-dark;
|
|
24
26
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
@use
|
|
2
|
-
@use
|
|
1
|
+
@use "sass:list";
|
|
2
|
+
@use "sass:map";
|
|
3
3
|
|
|
4
|
-
$menu:
|
|
4
|
+
$menu: "szh-menu";
|
|
5
5
|
$duration: 0.15s;
|
|
6
6
|
$directions: (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
"left": "X" 1,
|
|
8
|
+
"right": "X" -1,
|
|
9
|
+
"top": "Y" 1,
|
|
10
|
+
"bottom": "Y" -1,
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
@mixin animation($name, $dir) {
|
|
@@ -43,5 +43,5 @@ $directions: (
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
@each $dir in map.keys($directions) {
|
|
46
|
-
@include animation(
|
|
46
|
+
@include animation("slide", $dir);
|
|
47
47
|
}
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
ControlledMenuProps,
|
|
4
|
-
EventHandler,
|
|
5
|
-
FocusPosition,
|
|
6
|
-
MenuDirection,
|
|
7
|
-
MenuOverflow,
|
|
8
|
-
MenuReposition,
|
|
9
|
-
MenuState,
|
|
10
|
-
MenuViewScroll,
|
|
11
|
-
RectElement,
|
|
12
|
-
TransitionFieldType,
|
|
13
|
-
} from "../types";
|
|
14
|
-
import { RadioChangeEvent } from "../components/MenuRadioGroup";
|
|
1
|
+
import { MenuState } from "../types";
|
|
15
2
|
|
|
16
3
|
export const menuContainerClass = "szh-menu-container";
|
|
17
4
|
export const menuClass = "szh-menu";
|
|
@@ -24,30 +11,6 @@ export const menuGroupClass = "group";
|
|
|
24
11
|
export const subMenuClass = "submenu";
|
|
25
12
|
export const radioGroupClass = "radio-group";
|
|
26
13
|
|
|
27
|
-
export const HoverItemContext = createContext(undefined);
|
|
28
|
-
|
|
29
|
-
interface MenuListItemContextType {
|
|
30
|
-
isParentOpen?: boolean;
|
|
31
|
-
isSubmenuOpen?: boolean;
|
|
32
|
-
dispatch: (actionType: number, item: any, nextIndex: FocusPosition) => void;
|
|
33
|
-
updateItems: (item: any, isMounted?: boolean) => void;
|
|
34
|
-
setOpenSubmenuCount: (fn: (count: number) => number) => void;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const MenuListItemContext = createContext<MenuListItemContextType>({
|
|
38
|
-
dispatch: () => {},
|
|
39
|
-
updateItems: () => {},
|
|
40
|
-
setOpenSubmenuCount: () => 0,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export const MenuListContext = createContext<{
|
|
44
|
-
overflow?: MenuOverflow;
|
|
45
|
-
overflowAmt?: number;
|
|
46
|
-
parentMenuRef?: MutableRefObject<any>;
|
|
47
|
-
parentDir?: MenuDirection;
|
|
48
|
-
reposSubmenu?: boolean;
|
|
49
|
-
}>({});
|
|
50
|
-
|
|
51
14
|
export interface RMEvent {
|
|
52
15
|
value: any;
|
|
53
16
|
syntheticEvent: any;
|
|
@@ -56,42 +19,6 @@ export interface RMEvent {
|
|
|
56
19
|
key?: string;
|
|
57
20
|
}
|
|
58
21
|
|
|
59
|
-
export const EventHandlersContext = createContext<{
|
|
60
|
-
handleClose?: () => void;
|
|
61
|
-
handleClick: (event: RMEvent, checked: boolean) => void;
|
|
62
|
-
}>({
|
|
63
|
-
handleClick: () => {},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export const RadioGroupContext = createContext<{
|
|
67
|
-
value?: any;
|
|
68
|
-
name?: string;
|
|
69
|
-
onRadioChange?: EventHandler<RadioChangeEvent>;
|
|
70
|
-
}>({});
|
|
71
|
-
|
|
72
|
-
interface SettingsContextType extends ControlledMenuProps {
|
|
73
|
-
rootMenuRef?: MutableRefObject<any>;
|
|
74
|
-
rootAnchorRef?: MutableRefObject<any>;
|
|
75
|
-
scrollNodesRef: MutableRefObject<{ anchors?: Element[]; menu?: any }>;
|
|
76
|
-
|
|
77
|
-
initialMounted?: boolean;
|
|
78
|
-
unmountOnClose?: boolean;
|
|
79
|
-
transition?: TransitionFieldType;
|
|
80
|
-
transitionTimeout?: number;
|
|
81
|
-
boundingBoxRef?: RefObject<Element | RectElement>;
|
|
82
|
-
boundingBoxPadding?: string;
|
|
83
|
-
reposition?: MenuReposition;
|
|
84
|
-
viewScroll?: MenuViewScroll;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// FIXME hacking a default context in here is probably bad
|
|
88
|
-
export const SettingsContext = createContext<SettingsContextType>({} as SettingsContextType);
|
|
89
|
-
|
|
90
|
-
export const ItemSettingsContext = createContext<{ submenuCloseDelay: number; submenuOpenDelay: number }>({
|
|
91
|
-
submenuOpenDelay: 0,
|
|
92
|
-
submenuCloseDelay: 0,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
22
|
export const Keys = Object.freeze({
|
|
96
23
|
ENTER: "Enter",
|
|
97
24
|
ESC: "Escape",
|
|
@@ -3,7 +3,7 @@ import "./FormTest.scss";
|
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
import { LuiTextInput } from "@linzjs/lui";
|
|
5
5
|
import { wait } from "@utils/util";
|
|
6
|
-
import {
|
|
6
|
+
import { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
7
7
|
import { useGridPopoverHook } from "@components/GridPopoverHook";
|
|
8
8
|
import { GridBaseRow } from "@components/Grid";
|
|
9
9
|
|
|
@@ -16,7 +16,8 @@ export interface IFormTestRow {
|
|
|
16
16
|
distance: number | null;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const FormTest = <RowType extends GridBaseRow>(
|
|
19
|
+
export const FormTest = <RowType extends GridBaseRow>(_props: CellEditorCommon): JSX.Element => {
|
|
20
|
+
const props = _props as CellParams<RowType>;
|
|
20
21
|
const [v1, v2, ...v3] = props.value.split(" ");
|
|
21
22
|
|
|
22
23
|
const [nameType, setNameType] = useState(v1);
|
|
@@ -34,7 +35,7 @@ export const FormTest = <RowType extends GridBaseRow>(props: GridFormProps<RowTy
|
|
|
34
35
|
// Close form
|
|
35
36
|
return true;
|
|
36
37
|
}, [nameType, numba, plan, props.selectedRows]);
|
|
37
|
-
const { popoverWrapper } = useGridPopoverHook(
|
|
38
|
+
const { popoverWrapper } = useGridPopoverHook({ className: _props.className, save });
|
|
38
39
|
|
|
39
40
|
return popoverWrapper(
|
|
40
41
|
<div style={{ display: "flex", flexDirection: "row" }} className={"FormTest Grid-popoverContainer"}>
|