@linzjs/step-ag-grid 1.4.4 → 1.4.5
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/index.js +1602 -3043
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridLoadableCell.d.ts +2 -0
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -1
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +1 -1
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +2 -0
- package/dist/src/react-menu3/components/FocusableItem.d.ts +1 -0
- package/dist/src/react-menu3/components/Menu.d.ts +2 -0
- package/dist/src/react-menu3/components/MenuButton.d.ts +1 -0
- package/dist/src/react-menu3/components/MenuDivider.d.ts +2 -0
- package/dist/src/react-menu3/components/MenuGroup.d.ts +2 -0
- package/dist/src/react-menu3/components/MenuHeader.d.ts +2 -0
- package/dist/src/react-menu3/components/MenuItem.d.ts +1 -0
- package/dist/src/react-menu3/components/MenuList.d.ts +30 -0
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -0
- package/dist/src/react-menu3/components/SubMenu.d.ts +1 -0
- package/dist/src/react-menu3/hooks/index.d.ts +9 -0
- package/dist/src/react-menu3/hooks/useBEM.d.ts +9 -0
- package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +2 -0
- package/dist/src/react-menu3/hooks/useIsomorphicLayoutEffect.d.ts +3 -0
- package/dist/src/react-menu3/hooks/useItemEffect.d.ts +2 -0
- package/dist/src/react-menu3/hooks/useItemState.d.ts +6 -0
- package/dist/src/react-menu3/hooks/useItems.d.ts +5 -0
- package/dist/src/react-menu3/hooks/useMenuChange.d.ts +1 -0
- package/dist/src/react-menu3/hooks/useMenuState.d.ts +11 -0
- package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +10 -0
- package/dist/src/react-menu3/index.d.ts +11 -0
- package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +10 -0
- package/dist/src/react-menu3/positionUtils/index.d.ts +3 -0
- package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +7 -0
- package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +7 -0
- package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +21 -0
- package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +21 -0
- package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +8 -0
- package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +21 -0
- package/dist/src/react-menu3/style-utils/index.d.ts +11 -0
- package/dist/src/react-menu3/utils/constants.d.ts +50 -0
- package/dist/src/react-menu3/utils/index.d.ts +4 -0
- package/dist/src/react-menu3/utils/propTypes.d.ts +55 -0
- package/dist/src/react-menu3/utils/utils.d.ts +27 -0
- package/dist/src/react-menu3/utils/withHovering.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +1513 -2953
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +18 -9
- package/src/components/GridLoadableCell.scss +4 -0
- package/src/components/GridLoadableCell.tsx +5 -1
- package/src/components/GridPopoverHook.tsx +4 -50
- package/src/components/gridForm/GridFormDropDown.tsx +2 -2
- package/src/components/gridForm/GridFormMultiSelect.tsx +4 -4
- package/src/components/gridForm/GridFormPopoutMenu.tsx +1 -1
- package/src/components/gridPopoverEdit/GridPopoverMenu.scss +6 -2
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +1 -1
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +7 -9
- package/src/react-menu3/components/ControlledMenu.tsx +260 -0
- package/src/react-menu3/components/FocusableItem.tsx +70 -0
- package/src/react-menu3/components/Menu.tsx +96 -0
- package/src/react-menu3/components/MenuButton.tsx +33 -0
- package/src/react-menu3/components/MenuDivider.tsx +21 -0
- package/src/react-menu3/components/MenuGroup.tsx +38 -0
- package/src/react-menu3/components/MenuHeader.tsx +21 -0
- package/src/react-menu3/components/MenuItem.tsx +130 -0
- package/src/react-menu3/components/MenuList.tsx +434 -0
- package/src/react-menu3/components/MenuRadioGroup.tsx +33 -0
- package/src/react-menu3/components/SubMenu.tsx +243 -0
- package/src/react-menu3/hooks/index.ts +9 -0
- package/src/react-menu3/hooks/useBEM.ts +32 -0
- package/src/react-menu3/hooks/useCombinedRef.ts +30 -0
- package/src/react-menu3/hooks/useIsomorphicLayoutEffect.ts +15 -0
- package/src/react-menu3/hooks/useItemEffect.ts +22 -0
- package/src/react-menu3/hooks/useItemState.ts +63 -0
- package/src/react-menu3/hooks/useItems.ts +110 -0
- package/src/react-menu3/hooks/useMenuChange.ts +12 -0
- package/src/react-menu3/hooks/useMenuState.ts +24 -0
- package/src/react-menu3/hooks/useMenuStateAndFocus.ts +15 -0
- package/src/react-menu3/index.d.ts +682 -0
- package/src/react-menu3/index.ts +11 -0
- package/src/react-menu3/positionUtils/getPositionHelpers.ts +76 -0
- package/src/react-menu3/positionUtils/index.ts +3 -0
- package/src/react-menu3/positionUtils/placeArrowHorizontal.ts +8 -0
- package/src/react-menu3/positionUtils/placeArrowVertical.ts +8 -0
- package/src/react-menu3/positionUtils/placeLeftorRight.ts +76 -0
- package/src/react-menu3/positionUtils/placeToporBottom.ts +77 -0
- package/src/react-menu3/positionUtils/positionContextMenu.ts +49 -0
- package/src/react-menu3/positionUtils/positionMenu.ts +73 -0
- package/src/react-menu3/style-utils/index.ts +80 -0
- package/src/react-menu3/style-utils.d.ts +110 -0
- package/src/react-menu3/styles/_mixins.scss +11 -0
- package/src/react-menu3/styles/_var.scss +20 -0
- package/src/react-menu3/styles/core.scss +80 -0
- package/src/react-menu3/styles/index.scss +70 -0
- package/src/react-menu3/styles/theme-dark.scss +30 -0
- package/src/react-menu3/styles/transitions/slide.scss +47 -0
- package/src/react-menu3/utils/constants.ts +63 -0
- package/src/react-menu3/utils/index.ts +4 -0
- package/src/react-menu3/utils/propTypes.ts +61 -0
- package/src/react-menu3/utils/utils.ts +71 -0
- package/src/react-menu3/utils/withHovering.tsx +22 -0
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +1 -3
- package/src/utils/util.ts +2 -1
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
import React = require("react");
|
|
2
|
+
|
|
3
|
+
//
|
|
4
|
+
// base types
|
|
5
|
+
// ----------------------------------------------------------------------
|
|
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
|
+
/**
|
|
16
|
+
* - `'first'` focus the first item in the menu.
|
|
17
|
+
* - `'last'` focus the last item in the menu.
|
|
18
|
+
* - `number` focus item at the specific position (zero-based).
|
|
19
|
+
*/
|
|
20
|
+
export type FocusPosition = "first" | "last" | number;
|
|
21
|
+
|
|
22
|
+
type ClassNameProp<M = undefined> = string | ((modifiers: M) => string);
|
|
23
|
+
|
|
24
|
+
type RenderProp<M, R = React.ReactNode> = R | ((modifiers: M) => R);
|
|
25
|
+
|
|
26
|
+
interface BaseProps<M = undefined> extends Omit<React.HTMLAttributes<HTMLElement>, "className" | "children"> {
|
|
27
|
+
ref?: React.Ref<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Can be a string or a function which receives a modifier object and returns a CSS `class` string.
|
|
30
|
+
*/
|
|
31
|
+
className?: ClassNameProp<M>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface Event {
|
|
35
|
+
/**
|
|
36
|
+
* The `value` prop passed to the `MenuItem` being clicked.
|
|
37
|
+
* It's useful for identifying which menu item is clicked.
|
|
38
|
+
*/
|
|
39
|
+
value?: any;
|
|
40
|
+
/**
|
|
41
|
+
* Indicates the key if the event is triggered by keyboard. Can be 'Enter', ' '(Space) or 'Escape'.
|
|
42
|
+
*/
|
|
43
|
+
key?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface MenuCloseEvent extends Event {
|
|
47
|
+
/**
|
|
48
|
+
* The reason that causes the close event.
|
|
49
|
+
*/
|
|
50
|
+
reason: CloseReason;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface RadioChangeEvent extends Event {
|
|
54
|
+
/**
|
|
55
|
+
* The `name` prop passed to the `MenuRadioGroup` when the menu item is in a radio group.
|
|
56
|
+
*/
|
|
57
|
+
name?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Set this property on event object to control whether to keep menu open after menu item is activated.
|
|
60
|
+
* Leaving it `undefined` will behave in accordance with WAI-ARIA Authoring Practices.
|
|
61
|
+
*/
|
|
62
|
+
keepOpen?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Setting this property on event object to `true` will skip `onItemClick` event on root menu component.
|
|
65
|
+
*/
|
|
66
|
+
stopPropagation?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* DOM event object (React synthetic event)
|
|
69
|
+
*/
|
|
70
|
+
syntheticEvent: MouseEvent | KeyboardEvent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ClickEvent extends RadioChangeEvent {
|
|
74
|
+
/**
|
|
75
|
+
* Indicates if the menu item is checked, only for `MenuItem` type="checkbox".
|
|
76
|
+
*/
|
|
77
|
+
checked?: boolean;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface MenuChangeEvent {
|
|
81
|
+
/**
|
|
82
|
+
* Indicates if the menu is open or closed.
|
|
83
|
+
*/
|
|
84
|
+
open: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface EventHandler<E> {
|
|
88
|
+
(event: E): void;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface RectElement {
|
|
92
|
+
getBoundingClientRect(): {
|
|
93
|
+
left: number;
|
|
94
|
+
right: number;
|
|
95
|
+
top: number;
|
|
96
|
+
bottom: number;
|
|
97
|
+
width: number;
|
|
98
|
+
height: number;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//
|
|
103
|
+
// Menu common types
|
|
104
|
+
// ----------------------------------------------------------------------
|
|
105
|
+
export type MenuModifiers = Readonly<{
|
|
106
|
+
/**
|
|
107
|
+
* Indicates the state of menu.
|
|
108
|
+
*/
|
|
109
|
+
state: MenuState;
|
|
110
|
+
/**
|
|
111
|
+
* Computed direction in which the menu expands.
|
|
112
|
+
*/
|
|
113
|
+
dir: MenuDirection;
|
|
114
|
+
}>;
|
|
115
|
+
|
|
116
|
+
export type MenuArrowModifiers = Readonly<{
|
|
117
|
+
/**
|
|
118
|
+
* Computed direction in which the menu expands.
|
|
119
|
+
*
|
|
120
|
+
* *Please note arrow points to the opposite direction of this value.*
|
|
121
|
+
*/
|
|
122
|
+
dir: MenuDirection;
|
|
123
|
+
}>;
|
|
124
|
+
|
|
125
|
+
export interface MenuStateOptions {
|
|
126
|
+
/**
|
|
127
|
+
* By default menu isn't mounted into DOM until it's opened for the first time.
|
|
128
|
+
* Setting the prop to `true` will change this behaviour,
|
|
129
|
+
* which also enables menu and its items to be server rendered.
|
|
130
|
+
*/
|
|
131
|
+
initialMounted?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* By default menu remains in DOM when it's closed.
|
|
134
|
+
* Setting the prop to `true` will change this behaviour.
|
|
135
|
+
*/
|
|
136
|
+
unmountOnClose?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Enable or disable transition effects in `Menu`, `MenuItem`, and any descendent `SubMenu`.
|
|
139
|
+
*
|
|
140
|
+
* You can set 'open', 'close' and 'item' at the same time with one boolean value or separately with an object.
|
|
141
|
+
*
|
|
142
|
+
* *If you enable transition on menu, make sure to add your own animation styles,
|
|
143
|
+
* or import `'@szhsin/react-menu/dist/transitions/slide.css'`,
|
|
144
|
+
* otherwise menu cannot be closed or have visible delay when closed.*
|
|
145
|
+
*
|
|
146
|
+
* @example [CodeSandbox Demo](https://codesandbox.io/s/react-menu-sass-i1wxo)
|
|
147
|
+
*/
|
|
148
|
+
transition?:
|
|
149
|
+
| boolean
|
|
150
|
+
| {
|
|
151
|
+
open?: boolean;
|
|
152
|
+
close?: boolean;
|
|
153
|
+
item?: boolean;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* A fallback timeout in `ms` to stop transition if `onAnimationEnd` events are not fired.
|
|
157
|
+
*
|
|
158
|
+
* *Note: this value should be greater than or equal to the duration of
|
|
159
|
+
* transition animation applied on menu.*
|
|
160
|
+
*
|
|
161
|
+
* @default 500
|
|
162
|
+
*/
|
|
163
|
+
transitionTimeout?: number;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface Hoverable {
|
|
167
|
+
disabled?: boolean;
|
|
168
|
+
index?: number;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Common props for `Menu`, `SubMenu` and `ControlledMenu`
|
|
173
|
+
*/
|
|
174
|
+
interface BaseMenuProps extends Omit<BaseProps, "style"> {
|
|
175
|
+
/**
|
|
176
|
+
* Can be a string or a function which receives a modifier object and returns a CSS `class` string.
|
|
177
|
+
*/
|
|
178
|
+
menuClassName?: ClassNameProp<MenuModifiers>;
|
|
179
|
+
/**
|
|
180
|
+
* This prop is forwarded to the `style` prop of menu DOM element.
|
|
181
|
+
*/
|
|
182
|
+
menuStyle?: React.CSSProperties;
|
|
183
|
+
/**
|
|
184
|
+
* Can be a string or a function which receives a modifier object and returns a CSS `class` string.
|
|
185
|
+
*/
|
|
186
|
+
arrowClassName?: ClassNameProp<MenuArrowModifiers>;
|
|
187
|
+
/**
|
|
188
|
+
* This prop is forwarded to the `style` prop of menu arrow DOM element.
|
|
189
|
+
*/
|
|
190
|
+
arrowStyle?: React.CSSProperties;
|
|
191
|
+
/**
|
|
192
|
+
* Set `true` to display an arrow pointing to its anchor element.
|
|
193
|
+
*/
|
|
194
|
+
arrow?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Set the horizontal distance (in pixels) between menu and its anchor element.
|
|
197
|
+
* The value can be negative.
|
|
198
|
+
* @default 0
|
|
199
|
+
*/
|
|
200
|
+
offsetX?: number;
|
|
201
|
+
/**
|
|
202
|
+
* Set the vertical distance (in pixels) between menu and its anchor element.
|
|
203
|
+
* The value can be negative.
|
|
204
|
+
* @default 0
|
|
205
|
+
*/
|
|
206
|
+
offsetY?: number;
|
|
207
|
+
/**
|
|
208
|
+
* Set alignment of menu with anchor element.
|
|
209
|
+
* @default 'start'
|
|
210
|
+
*/
|
|
211
|
+
align?: MenuAlign;
|
|
212
|
+
/**
|
|
213
|
+
* Set direction in which menu expands against anchor element.
|
|
214
|
+
* @default 'bottom'
|
|
215
|
+
*/
|
|
216
|
+
direction?: MenuDirection;
|
|
217
|
+
/**
|
|
218
|
+
* Set the position of menu related to its anchor element:
|
|
219
|
+
*
|
|
220
|
+
* - 'auto' menu position is adjusted to have it contained within the viewport,
|
|
221
|
+
* even if it will be detached from the anchor element.
|
|
222
|
+
* This option allows to display menu in the viewport as much as possible.
|
|
223
|
+
*
|
|
224
|
+
* - 'anchor' menu position is adjusted to have it contained within the viewport,
|
|
225
|
+
* but it will be kept attached to the edges of anchor element.
|
|
226
|
+
*
|
|
227
|
+
* - 'initial' menu always stays at its initial position.
|
|
228
|
+
* @default 'auto'
|
|
229
|
+
*/
|
|
230
|
+
position?: MenuPosition;
|
|
231
|
+
/**
|
|
232
|
+
* Make the menu list scrollable or hidden when there is not enough viewport space to
|
|
233
|
+
* display all menu items. The prop is similar to the CSS `overflow` property.
|
|
234
|
+
* @default 'visible'
|
|
235
|
+
*/
|
|
236
|
+
overflow?: MenuOverflow;
|
|
237
|
+
/**
|
|
238
|
+
* Set computed overflow amount down to a child `MenuGroup`.
|
|
239
|
+
* The `MenuGroup` should have `takeOverflow` prop set as `true` accordingly.
|
|
240
|
+
*/
|
|
241
|
+
setDownOverflow?: boolean;
|
|
242
|
+
children?: React.ReactNode;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Common props for `Menu` and `ControlledMenu`
|
|
247
|
+
*/
|
|
248
|
+
interface RootMenuProps extends BaseMenuProps, MenuStateOptions {
|
|
249
|
+
/**
|
|
250
|
+
* Properties of this object are spread to the root DOM element containing the menu.
|
|
251
|
+
*/
|
|
252
|
+
containerProps?: Omit<React.HTMLAttributes<HTMLElement>, "className">;
|
|
253
|
+
/**
|
|
254
|
+
* A ref object attached to a DOM element within which menu will be positioned.
|
|
255
|
+
* If not provided, the nearest ancestor which has CSS `overflow` set to a value
|
|
256
|
+
* other than 'visible' or the browser viewport will serve as the bounding box.
|
|
257
|
+
*/
|
|
258
|
+
boundingBoxRef?: React.RefObject<Element | RectElement>;
|
|
259
|
+
/**
|
|
260
|
+
* Specify bounding box padding in pixels. Use a syntax similar to the CSS
|
|
261
|
+
* `padding` property but sizing units are discarded.
|
|
262
|
+
* @example '10', '5 10', '1 2 4', or '2 5 3 1'
|
|
263
|
+
*/
|
|
264
|
+
boundingBoxPadding?: string;
|
|
265
|
+
/**
|
|
266
|
+
* Set the behaviour of menu and any of its descendent submenus when window is scrolling:
|
|
267
|
+
* - 'initial' The window scroll event is ignored and has no effect on menu.
|
|
268
|
+
* - 'auto' Menu will reposition itself based on the value of `position` prop when window is scrolling.
|
|
269
|
+
* - 'close' menu will be closed when window is scrolled.
|
|
270
|
+
* @default 'initial'
|
|
271
|
+
*/
|
|
272
|
+
viewScroll?: MenuViewScroll;
|
|
273
|
+
/**
|
|
274
|
+
* - If `true`, menu is rendered as a direct child of `document.body`,
|
|
275
|
+
* - or you can specify a target element in the DOM as menu container.
|
|
276
|
+
*
|
|
277
|
+
* Portal allows menu to visually “break out” of its container. Typical use cases may include:
|
|
278
|
+
* - An ancestor container is positioned and CSS `overflow` is set to a value other than `visible`.
|
|
279
|
+
* - You have a DOM structure that creates a complex hierarchy of stacking contexts,
|
|
280
|
+
* and menu is overlapped regardless of `z-index` value.
|
|
281
|
+
*/
|
|
282
|
+
portal?:
|
|
283
|
+
| boolean
|
|
284
|
+
| {
|
|
285
|
+
/**
|
|
286
|
+
* A DOM node under which menu will be rendered.
|
|
287
|
+
*/
|
|
288
|
+
target?: Element | null;
|
|
289
|
+
/**
|
|
290
|
+
* When `target` is null, setting this value `true` prevents menu from rendering into the DOM hierarchy of its parent component.
|
|
291
|
+
*/
|
|
292
|
+
stablePosition?: boolean;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Specify when menu is repositioned:
|
|
296
|
+
* - 'initial' Don't automatically reposition menu. Set to this value when you want
|
|
297
|
+
* to explicitly reposition menu using the `repositionFlag` prop.
|
|
298
|
+
* - 'auto' Reposition menu whenever its size has changed, using the `ResizeObserver` API.
|
|
299
|
+
* @default 'auto'
|
|
300
|
+
*/
|
|
301
|
+
reposition?: MenuReposition;
|
|
302
|
+
/**
|
|
303
|
+
* Use this prop to explicitly reposition menu. Whenever the prop has a new value,
|
|
304
|
+
* menu position will be recalculated and updated.
|
|
305
|
+
* You might use a counter and increase it every time.
|
|
306
|
+
*
|
|
307
|
+
* *Warning: don't update this prop in rapid succession,
|
|
308
|
+
* which is inefficient and might cause infinite rendering of component.
|
|
309
|
+
* E.g., don't change the value of this prop in `window` scroll event.*
|
|
310
|
+
*/
|
|
311
|
+
repositionFlag?: number | string;
|
|
312
|
+
/**
|
|
313
|
+
* Set a delay in `ms` before opening a submenu when mouse moves over it.
|
|
314
|
+
* @default 300
|
|
315
|
+
*/
|
|
316
|
+
submenuOpenDelay?: number;
|
|
317
|
+
/**
|
|
318
|
+
* Set a delay in `ms` before closing a submenu when it's open and mouse is
|
|
319
|
+
* moving over other items in the parent menu list.
|
|
320
|
+
* @default 150
|
|
321
|
+
*/
|
|
322
|
+
submenuCloseDelay?: number;
|
|
323
|
+
/**
|
|
324
|
+
* Set a CSS `class` on the container element of menu for theming purpose.
|
|
325
|
+
*/
|
|
326
|
+
theming?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Event fired when descendent menu items are clicked.
|
|
329
|
+
*/
|
|
330
|
+
onItemClick?: EventHandler<ClickEvent>;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export interface MenuInstance {
|
|
334
|
+
/**
|
|
335
|
+
* Open menu and optionally request which menu item will be hovered.
|
|
336
|
+
*/
|
|
337
|
+
openMenu: (position?: FocusPosition, alwaysUpdate?: boolean) => void;
|
|
338
|
+
/**
|
|
339
|
+
* Close menu
|
|
340
|
+
*/
|
|
341
|
+
closeMenu: () => void;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Common props for `Menu` and `SubMenu`
|
|
346
|
+
*/
|
|
347
|
+
interface UncontrolledMenuProps {
|
|
348
|
+
/**
|
|
349
|
+
* Menu component ref which can be used to programmatically open or close menu.
|
|
350
|
+
*/
|
|
351
|
+
instanceRef?: React.Ref<MenuInstance>;
|
|
352
|
+
/**
|
|
353
|
+
* Event fired after menu is open or closed.
|
|
354
|
+
*/
|
|
355
|
+
onMenuChange?: EventHandler<MenuChangeEvent>;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
//
|
|
359
|
+
// MenuButton
|
|
360
|
+
// ----------------------------------------------------------------------
|
|
361
|
+
export type MenuButtonModifiers = Readonly<{
|
|
362
|
+
/**
|
|
363
|
+
* Indicates if the associated menu is open.
|
|
364
|
+
*/
|
|
365
|
+
open: boolean;
|
|
366
|
+
}>;
|
|
367
|
+
|
|
368
|
+
export interface MenuButtonProps extends BaseProps<MenuButtonModifiers> {
|
|
369
|
+
disabled?: boolean;
|
|
370
|
+
children?: React.ReactNode;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export const MenuButton: React.NamedExoticComponent<MenuButtonProps>;
|
|
374
|
+
|
|
375
|
+
//
|
|
376
|
+
// Menu
|
|
377
|
+
// ----------------------------------------------------------------------
|
|
378
|
+
export interface MenuProps extends RootMenuProps, UncontrolledMenuProps {
|
|
379
|
+
/**
|
|
380
|
+
* Can be a `MenuButton`, a `button` element, or a React component.
|
|
381
|
+
* It also can be a render function that returns one.
|
|
382
|
+
*
|
|
383
|
+
* If a React component is provided, it needs to implement the following contracts:
|
|
384
|
+
* - Accepts a `ref` prop that is forwarded to an element to which menu will be positioned.
|
|
385
|
+
* The element should be able to receive focus.
|
|
386
|
+
* - Accepts `onClick` and `onKeyDown` event props.
|
|
387
|
+
*/
|
|
388
|
+
menuButton: RenderProp<MenuButtonModifiers, React.ReactElement>;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export const Menu: React.NamedExoticComponent<MenuProps>;
|
|
392
|
+
|
|
393
|
+
//
|
|
394
|
+
// ControlledMenu
|
|
395
|
+
// ----------------------------------------------------------------------
|
|
396
|
+
export interface ControlledMenuProps extends RootMenuProps {
|
|
397
|
+
/**
|
|
398
|
+
* Viewport coordinates to which context menu will be positioned.
|
|
399
|
+
*
|
|
400
|
+
* *Use this prop only for context menu*
|
|
401
|
+
*/
|
|
402
|
+
anchorPoint?: {
|
|
403
|
+
x: number;
|
|
404
|
+
y: number;
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* A ref object attached to a DOM element to which menu will be positioned.
|
|
408
|
+
*
|
|
409
|
+
* *Don't set this prop for context menu*
|
|
410
|
+
*/
|
|
411
|
+
anchorRef?: React.RefObject<Element | RectElement>;
|
|
412
|
+
skipOpen?: React.RefObject<boolean>;
|
|
413
|
+
/**
|
|
414
|
+
* If `true`, the menu list element will gain focus after menu is open.
|
|
415
|
+
* @default true
|
|
416
|
+
*/
|
|
417
|
+
captureFocus?: boolean;
|
|
418
|
+
/**
|
|
419
|
+
* Controls the state of menu. When the prop is `undefined`, menu will be unmounted from DOM.
|
|
420
|
+
*/
|
|
421
|
+
state?: MenuState;
|
|
422
|
+
/**
|
|
423
|
+
* Sets which menu item receives focus (hover) when menu opens.
|
|
424
|
+
* You will usually set this prop when the menu is opened by keyboard events.
|
|
425
|
+
*
|
|
426
|
+
* *Note: If you don't intend to update focus (hover) position,
|
|
427
|
+
* it's important to keep this prop's identity stable when your component re-renders.*
|
|
428
|
+
*/
|
|
429
|
+
menuItemFocus?: {
|
|
430
|
+
position?: FocusPosition;
|
|
431
|
+
alwaysUpdate?: boolean;
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* Set the return value of `useMenuState` to this prop.
|
|
435
|
+
*/
|
|
436
|
+
endTransition?: () => void;
|
|
437
|
+
/**
|
|
438
|
+
* Event fired when menu is about to close.
|
|
439
|
+
*/
|
|
440
|
+
onClose?: EventHandler<MenuCloseEvent>;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export const ControlledMenu: React.NamedExoticComponent<ControlledMenuProps>;
|
|
444
|
+
|
|
445
|
+
//
|
|
446
|
+
// SubMenu
|
|
447
|
+
// ----------------------------------------------------------------------
|
|
448
|
+
export type SubMenuItemModifiers = Readonly<{
|
|
449
|
+
/**
|
|
450
|
+
* Indicates if the submenu is open.
|
|
451
|
+
*/
|
|
452
|
+
open: boolean;
|
|
453
|
+
/**
|
|
454
|
+
* Indicates if the submenu item is being hovered and has focus.
|
|
455
|
+
*/
|
|
456
|
+
hover: boolean;
|
|
457
|
+
/**
|
|
458
|
+
* Indicates if the submenu and item are disabled.
|
|
459
|
+
*/
|
|
460
|
+
disabled: boolean;
|
|
461
|
+
}>;
|
|
462
|
+
|
|
463
|
+
export interface SubMenuProps extends BaseMenuProps, Hoverable, UncontrolledMenuProps {
|
|
464
|
+
/**
|
|
465
|
+
* Properties of this object are spread to the submenu item DOM element.
|
|
466
|
+
*/
|
|
467
|
+
itemProps?: BaseProps<SubMenuItemModifiers>;
|
|
468
|
+
/**
|
|
469
|
+
* The submenu `label` can be a `string` or JSX element, or a render function that returns one.
|
|
470
|
+
*/
|
|
471
|
+
label?: RenderProp<SubMenuItemModifiers>;
|
|
472
|
+
/**
|
|
473
|
+
* - `undefined` submenu opens when the label item is hovered or clicked. This is the default behaviour.
|
|
474
|
+
* - 'clickOnly' submenu opens when the label item is clicked.
|
|
475
|
+
* - 'none' submenu doesn't open with mouse or keyboard events;
|
|
476
|
+
* you can call the `openMenu` function on `instanceRef` to open submenu programmatically.
|
|
477
|
+
*/
|
|
478
|
+
openTrigger?: "none" | "clickOnly";
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export const SubMenu: React.NamedExoticComponent<SubMenuProps>;
|
|
482
|
+
|
|
483
|
+
//
|
|
484
|
+
// MenuItem
|
|
485
|
+
// ----------------------------------------------------------------------
|
|
486
|
+
export type MenuItemModifiers = Readonly<{
|
|
487
|
+
/**
|
|
488
|
+
* 'radio' for radio item, 'checkbox' for checkbox item, or `undefined` for other items.
|
|
489
|
+
*/
|
|
490
|
+
type?: MenuItemTypeProp;
|
|
491
|
+
/**
|
|
492
|
+
* Indicates if the menu item is disabled.
|
|
493
|
+
*/
|
|
494
|
+
disabled: boolean;
|
|
495
|
+
/**
|
|
496
|
+
* Indicates if the menu item is being hovered and has focus.
|
|
497
|
+
*/
|
|
498
|
+
hover: boolean;
|
|
499
|
+
/**
|
|
500
|
+
* Indicates if the menu item is checked when it's a radio or checkbox item.
|
|
501
|
+
*/
|
|
502
|
+
checked: boolean;
|
|
503
|
+
/**
|
|
504
|
+
* Indicates if the menu item has a URL link.
|
|
505
|
+
*/
|
|
506
|
+
anchor: boolean;
|
|
507
|
+
}>;
|
|
508
|
+
|
|
509
|
+
export interface MenuItemProps extends Omit<BaseProps<MenuItemModifiers>, "onClick">, Hoverable {
|
|
510
|
+
/**
|
|
511
|
+
* Any value provided to this prop will be available in the event object of click events.
|
|
512
|
+
*
|
|
513
|
+
* It's useful for helping identify which menu item is clicked when you
|
|
514
|
+
* listen on `onItemClick` event on root menu component.
|
|
515
|
+
*/
|
|
516
|
+
value?: any;
|
|
517
|
+
/**
|
|
518
|
+
* If provided, menu item renders an HTML `<a>` element with this `href` attribute.
|
|
519
|
+
*/
|
|
520
|
+
href?: string;
|
|
521
|
+
rel?: string;
|
|
522
|
+
target?: string;
|
|
523
|
+
/**
|
|
524
|
+
* Set this prop to make the item a checkbox or radio menu item.
|
|
525
|
+
*/
|
|
526
|
+
type?: MenuItemTypeProp;
|
|
527
|
+
/**
|
|
528
|
+
* Set `true` if a checkbox menu item is checked.
|
|
529
|
+
*
|
|
530
|
+
* *Please note radio menu item doesn't use this prop.*
|
|
531
|
+
*/
|
|
532
|
+
checked?: boolean;
|
|
533
|
+
/**
|
|
534
|
+
* Event fired when the menu item is clicked.
|
|
535
|
+
*/
|
|
536
|
+
onClick?: EventHandler<ClickEvent>;
|
|
537
|
+
/**
|
|
538
|
+
* Any valid React node or a render function that returns one.
|
|
539
|
+
*/
|
|
540
|
+
children?: RenderProp<MenuItemModifiers>;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export const MenuItem: React.NamedExoticComponent<MenuItemProps>;
|
|
544
|
+
|
|
545
|
+
//
|
|
546
|
+
// FocusableItem
|
|
547
|
+
// ----------------------------------------------------------------------
|
|
548
|
+
export type FocusableItemModifiers = Readonly<{
|
|
549
|
+
/**
|
|
550
|
+
* Indicates if the focusable item is disabled.
|
|
551
|
+
*/
|
|
552
|
+
disabled: boolean;
|
|
553
|
+
/**
|
|
554
|
+
* Indicates if the focusable item is being hovered.
|
|
555
|
+
*/
|
|
556
|
+
hover: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Always `true` for a focusable item.
|
|
559
|
+
*/
|
|
560
|
+
focusable: true;
|
|
561
|
+
}>;
|
|
562
|
+
|
|
563
|
+
export interface FocusableItemProps extends BaseProps<FocusableItemModifiers>, Hoverable {
|
|
564
|
+
/**
|
|
565
|
+
* A render function that returns a React node.
|
|
566
|
+
*/
|
|
567
|
+
children: (modifiers: {
|
|
568
|
+
/**
|
|
569
|
+
* Indicates if the focusable item is disabled.
|
|
570
|
+
*/
|
|
571
|
+
disabled: boolean;
|
|
572
|
+
/**
|
|
573
|
+
* Indicates if the focusable item is being hovered.
|
|
574
|
+
*/
|
|
575
|
+
hover: boolean;
|
|
576
|
+
/**
|
|
577
|
+
* A ref to be attached to the element which should receive focus when this focusable item is hovered.
|
|
578
|
+
*
|
|
579
|
+
* If you render a React component, it needs to expose a `focus` method or implement ref forwarding.
|
|
580
|
+
*/
|
|
581
|
+
ref: React.RefObject<any>;
|
|
582
|
+
/**
|
|
583
|
+
* A function that requests to close the root menu.
|
|
584
|
+
* @param {string} key Indicate which key initiates the close request.
|
|
585
|
+
*/
|
|
586
|
+
closeMenu: (key?: string) => void;
|
|
587
|
+
}) => React.ReactNode;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* A component to wrap focusable element (input, button) in a menu item.
|
|
592
|
+
* It manages focus automatically among other menu items during mouse and keyboard interactions.
|
|
593
|
+
*
|
|
594
|
+
* @example https://szhsin.github.io/react-menu/#focusable-item
|
|
595
|
+
*/
|
|
596
|
+
export const FocusableItem: React.NamedExoticComponent<FocusableItemProps>;
|
|
597
|
+
|
|
598
|
+
//
|
|
599
|
+
// MenuDivider
|
|
600
|
+
// ----------------------------------------------------------------------
|
|
601
|
+
export const MenuDivider: React.NamedExoticComponent<BaseProps>;
|
|
602
|
+
|
|
603
|
+
//
|
|
604
|
+
// MenuHeader
|
|
605
|
+
// ----------------------------------------------------------------------
|
|
606
|
+
export interface MenuHeaderProps extends BaseProps {
|
|
607
|
+
children?: React.ReactNode;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
export const MenuHeader: React.NamedExoticComponent<MenuHeaderProps>;
|
|
611
|
+
|
|
612
|
+
//
|
|
613
|
+
// MenuGroup
|
|
614
|
+
// ----------------------------------------------------------------------
|
|
615
|
+
export interface MenuGroupProps extends BaseProps {
|
|
616
|
+
children?: React.ReactNode;
|
|
617
|
+
/**
|
|
618
|
+
* Set `true` to apply overflow of the parent menu to the group.
|
|
619
|
+
* Only one `MenuGroup` in a menu should set this prop as `true`.
|
|
620
|
+
*/
|
|
621
|
+
takeOverflow?: boolean;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* A component to wrap a subset related menu items and make them scrollable.
|
|
626
|
+
*
|
|
627
|
+
* @example https://szhsin.github.io/react-menu/#menu-overflow
|
|
628
|
+
*/
|
|
629
|
+
export const MenuGroup: React.NamedExoticComponent<MenuGroupProps>;
|
|
630
|
+
|
|
631
|
+
//
|
|
632
|
+
// MenuRadioGroup
|
|
633
|
+
// ----------------------------------------------------------------------
|
|
634
|
+
export interface MenuRadioGroupProps extends BaseProps {
|
|
635
|
+
/**
|
|
636
|
+
* Optionally set the radio group name.
|
|
637
|
+
*
|
|
638
|
+
* The name will be passed to the `onRadioChange` event.
|
|
639
|
+
* It's useful for identifying radio groups if you attach the same event handler to multiple groups.
|
|
640
|
+
*/
|
|
641
|
+
name?: string;
|
|
642
|
+
/**
|
|
643
|
+
* Set value of the radio group.
|
|
644
|
+
*
|
|
645
|
+
* The child menu item which has the same value (strict equality ===) as the
|
|
646
|
+
* radio group is marked as checked.
|
|
647
|
+
*/
|
|
648
|
+
value?: any;
|
|
649
|
+
children?: React.ReactNode;
|
|
650
|
+
/**
|
|
651
|
+
* Event fired when a child menu item is clicked (selected).
|
|
652
|
+
*/
|
|
653
|
+
onRadioChange?: EventHandler<RadioChangeEvent>;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
export const MenuRadioGroup: React.NamedExoticComponent<MenuRadioGroupProps>;
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* A custom Hook which helps manage the states of `ControlledMenu`.
|
|
660
|
+
*/
|
|
661
|
+
export function useMenuState(options?: MenuStateOptions): [
|
|
662
|
+
{
|
|
663
|
+
/**
|
|
664
|
+
* Menu state which should be forwarded to `ControlledMenu`.
|
|
665
|
+
*/
|
|
666
|
+
state?: MenuState;
|
|
667
|
+
/**
|
|
668
|
+
* Stop transition animation. This function value should be forwarded to `ControlledMenu`.
|
|
669
|
+
*/
|
|
670
|
+
endTransition: () => void;
|
|
671
|
+
},
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Open or close menu.
|
|
675
|
+
*
|
|
676
|
+
* - If no parameter is supplied, this function will toggle state between open and close phases.
|
|
677
|
+
* - You can set a boolean parameter to explicitly switch into one of the two phases.
|
|
678
|
+
*/
|
|
679
|
+
(open?: boolean) => void,
|
|
680
|
+
];
|
|
681
|
+
|
|
682
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { useMenuState } from "./hooks";
|
|
2
|
+
export { MenuButton } from "./components/MenuButton";
|
|
3
|
+
export { Menu } from "./components/Menu";
|
|
4
|
+
export { ControlledMenu } from "./components/ControlledMenu";
|
|
5
|
+
export { SubMenu } from "./components/SubMenu";
|
|
6
|
+
export { MenuItem } from "./components/MenuItem";
|
|
7
|
+
export { FocusableItem } from "./components/FocusableItem";
|
|
8
|
+
export { MenuDivider } from "./components/MenuDivider";
|
|
9
|
+
export { MenuHeader } from "./components/MenuHeader";
|
|
10
|
+
export { MenuGroup } from "./components/MenuGroup";
|
|
11
|
+
export { MenuRadioGroup } from "./components/MenuRadioGroup";
|