@linzjs/step-ag-grid 1.4.6 → 1.4.7
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.d.ts +1 -0
- package/dist/index.js +108 -88
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridCell.d.ts +4 -3
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +8 -5
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +8 -2
- package/dist/src/react-menu3/components/FocusableItem.d.ts +2 -2
- package/dist/src/react-menu3/components/Menu.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuButton.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuDivider.d.ts +3 -3
- package/dist/src/react-menu3/components/MenuGroup.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuHeader.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuItem.d.ts +2 -4
- package/dist/src/react-menu3/components/MenuList.d.ts +2 -56
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -2
- package/dist/src/react-menu3/components/SubMenu.d.ts +6 -6
- package/dist/src/react-menu3/hooks/useBEM.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useItems.d.ts +1 -1
- 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 +1 -391
- package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +1 -1
- package/dist/src/react-menu3/types.d.ts +389 -0
- package/dist/src/react-menu3/utils/constants.d.ts +12 -5
- package/dist/src/react-menu3/utils/index.d.ts +0 -1
- package/dist/src/react-menu3/utils/{propTypes.d.ts → propTypes2.d.ts} +0 -0
- package/dist/src/react-menu3/utils/utils.d.ts +2 -2
- package/dist/step-ag-grid.esm.js +99 -90
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridCell.tsx +6 -3
- package/src/components/GridPopoverHook.tsx +1 -1
- package/src/components/gridForm/GridFormMultiSelect.tsx +32 -19
- package/src/components/gridRender/GridRenderGenericCell.tsx +11 -7
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +14 -2
- package/src/contexts/GridContextProvider.tsx +3 -2
- package/src/react-menu3/components/ControlledMenu.tsx +40 -46
- package/src/react-menu3/components/FocusableItem.tsx +2 -2
- package/src/react-menu3/components/Menu.tsx +1 -1
- package/src/react-menu3/components/MenuButton.tsx +1 -1
- package/src/react-menu3/components/MenuDivider.tsx +2 -2
- package/src/react-menu3/components/MenuGroup.tsx +1 -1
- package/src/react-menu3/components/MenuHeader.tsx +1 -1
- package/src/react-menu3/components/MenuItem.tsx +2 -3
- package/src/react-menu3/components/MenuList.tsx +19 -62
- package/src/react-menu3/components/MenuRadioGroup.tsx +2 -2
- package/src/react-menu3/components/SubMenu.tsx +17 -8
- package/src/react-menu3/hooks/useBEM.ts +1 -1
- package/src/react-menu3/hooks/useItems.ts +1 -1
- package/src/react-menu3/hooks/useMenuChange.ts +1 -1
- package/src/react-menu3/hooks/useMenuState.ts +1 -1
- package/src/react-menu3/hooks/useMenuStateAndFocus.ts +1 -1
- package/src/react-menu3/index.ts +1 -431
- package/src/react-menu3/positionUtils/getPositionHelpers.ts +3 -3
- package/src/react-menu3/positionUtils/placeLeftorRight.ts +1 -1
- package/src/react-menu3/positionUtils/placeToporBottom.ts +1 -1
- package/src/react-menu3/positionUtils/positionContextMenu.ts +1 -1
- package/src/react-menu3/positionUtils/positionMenu.ts +1 -1
- package/src/react-menu3/{index.d.ts → types.ts} +106 -359
- package/src/react-menu3/utils/constants.ts +24 -5
- package/src/react-menu3/utils/index.ts +1 -1
- package/src/react-menu3/utils/{propTypes.ts → propTypes2.ts} +0 -0
- package/src/react-menu3/utils/utils.ts +2 -2
- package/src/stories/components/GridReadOnly.stories.tsx +3 -4
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import React = require("react");
|
|
3
|
-
|
|
4
1
|
//
|
|
5
2
|
// base types
|
|
6
3
|
// ----------------------------------------------------------------------
|
|
4
|
+
import { ForwardedRef, MutableRefObject } from "react";
|
|
5
|
+
|
|
7
6
|
export type MenuState = "opening" | "open" | "closing" | "closed";
|
|
8
7
|
export type MenuAlign = "start" | "center" | "end";
|
|
9
8
|
export type MenuDirection = "left" | "right" | "top" | "bottom";
|
|
@@ -20,11 +19,11 @@ export type CloseReason = "click" | "cancel" | "blur" | "scroll";
|
|
|
20
19
|
*/
|
|
21
20
|
export type FocusPosition = "first" | "last" | number;
|
|
22
21
|
|
|
23
|
-
type ClassNameProp<M = undefined> = string | ((modifiers: M) => string);
|
|
22
|
+
export type ClassNameProp<M = undefined> = string | ((modifiers: M) => string);
|
|
24
23
|
|
|
25
|
-
type RenderProp<M, R = React.ReactNode> = R | ((modifiers: M) => R);
|
|
24
|
+
export type RenderProp<M, R = React.ReactNode> = R | ((modifiers: M) => R);
|
|
26
25
|
|
|
27
|
-
interface BaseProps<M = undefined> extends Omit<React.HTMLAttributes<HTMLElement>, "className" | "children"> {
|
|
26
|
+
export interface BaseProps<M = undefined> extends Omit<React.HTMLAttributes<HTMLElement>, "className" | "children"> {
|
|
28
27
|
ref?: React.Ref<any>;
|
|
29
28
|
/**
|
|
30
29
|
* Can be a string or a function which receives a modifier object and returns a CSS `class` string.
|
|
@@ -32,7 +31,7 @@ interface BaseProps<M = undefined> extends Omit<React.HTMLAttributes<HTMLElement
|
|
|
32
31
|
className?: ClassNameProp<M>;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
interface Event {
|
|
34
|
+
export interface Event {
|
|
36
35
|
/**
|
|
37
36
|
* The `value` prop passed to the `MenuItem` being clicked.
|
|
38
37
|
* It's useful for identifying which menu item is clicked.
|
|
@@ -51,33 +50,6 @@ export interface MenuCloseEvent extends Event {
|
|
|
51
50
|
reason: CloseReason;
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
export interface RadioChangeEvent extends Event {
|
|
55
|
-
/**
|
|
56
|
-
* The `name` prop passed to the `MenuRadioGroup` when the menu item is in a radio group.
|
|
57
|
-
*/
|
|
58
|
-
name?: string;
|
|
59
|
-
/**
|
|
60
|
-
* Set this property on event object to control whether to keep menu open after menu item is activated.
|
|
61
|
-
* Leaving it `undefined` will behave in accordance with WAI-ARIA Authoring Practices.
|
|
62
|
-
*/
|
|
63
|
-
keepOpen?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Setting this property on event object to `true` will skip `onItemClick` event on root menu component.
|
|
66
|
-
*/
|
|
67
|
-
stopPropagation?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* DOM event object (React synthetic event)
|
|
70
|
-
*/
|
|
71
|
-
syntheticEvent: MouseEvent | KeyboardEvent;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface ClickEvent extends RadioChangeEvent {
|
|
75
|
-
/**
|
|
76
|
-
* Indicates if the menu item is checked, only for `MenuItem` type="checkbox".
|
|
77
|
-
*/
|
|
78
|
-
checked?: boolean;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
53
|
export interface MenuChangeEvent {
|
|
82
54
|
/**
|
|
83
55
|
* Indicates if the menu is open or closed.
|
|
@@ -85,11 +57,11 @@ export interface MenuChangeEvent {
|
|
|
85
57
|
open: boolean;
|
|
86
58
|
}
|
|
87
59
|
|
|
88
|
-
interface EventHandler<E> {
|
|
60
|
+
export interface EventHandler<E> {
|
|
89
61
|
(event: E): void;
|
|
90
62
|
}
|
|
91
63
|
|
|
92
|
-
interface RectElement {
|
|
64
|
+
export interface RectElement {
|
|
93
65
|
getBoundingClientRect(): {
|
|
94
66
|
left: number;
|
|
95
67
|
right: number;
|
|
@@ -123,6 +95,14 @@ export type MenuArrowModifiers = Readonly<{
|
|
|
123
95
|
dir: MenuDirection;
|
|
124
96
|
}>;
|
|
125
97
|
|
|
98
|
+
export type TransitionFieldType =
|
|
99
|
+
| boolean
|
|
100
|
+
| {
|
|
101
|
+
open?: boolean;
|
|
102
|
+
close?: boolean;
|
|
103
|
+
item?: boolean;
|
|
104
|
+
};
|
|
105
|
+
|
|
126
106
|
export interface MenuStateOptions {
|
|
127
107
|
/**
|
|
128
108
|
* By default menu isn't mounted into DOM until it's opened for the first time.
|
|
@@ -146,13 +126,8 @@ export interface MenuStateOptions {
|
|
|
146
126
|
*
|
|
147
127
|
* @example [CodeSandbox Demo](https://codesandbox.io/s/react-menu-sass-i1wxo)
|
|
148
128
|
*/
|
|
149
|
-
transition?:
|
|
150
|
-
|
|
151
|
-
| {
|
|
152
|
-
open?: boolean;
|
|
153
|
-
close?: boolean;
|
|
154
|
-
item?: boolean;
|
|
155
|
-
};
|
|
129
|
+
transition?: TransitionFieldType;
|
|
130
|
+
|
|
156
131
|
/**
|
|
157
132
|
* A fallback timeout in `ms` to stop transition if `onAnimationEnd` events are not fired.
|
|
158
133
|
*
|
|
@@ -164,7 +139,7 @@ export interface MenuStateOptions {
|
|
|
164
139
|
transitionTimeout?: number;
|
|
165
140
|
}
|
|
166
141
|
|
|
167
|
-
interface Hoverable {
|
|
142
|
+
export interface Hoverable {
|
|
168
143
|
disabled?: boolean;
|
|
169
144
|
index?: number;
|
|
170
145
|
}
|
|
@@ -243,10 +218,85 @@ interface BaseMenuProps extends Omit<BaseProps, "style"> {
|
|
|
243
218
|
children?: React.ReactNode;
|
|
244
219
|
}
|
|
245
220
|
|
|
221
|
+
//
|
|
222
|
+
// MenuButton
|
|
223
|
+
// ----------------------------------------------------------------------
|
|
224
|
+
export type MenuButtonModifiers = Readonly<{
|
|
225
|
+
/**
|
|
226
|
+
* Indicates if the associated menu is open.
|
|
227
|
+
*/
|
|
228
|
+
open: boolean;
|
|
229
|
+
}>;
|
|
230
|
+
|
|
231
|
+
export interface MenuInstance {
|
|
232
|
+
/**
|
|
233
|
+
* Open menu and optionally request which menu item will be hovered.
|
|
234
|
+
*/
|
|
235
|
+
openMenu: (position?: FocusPosition, alwaysUpdate?: boolean) => void;
|
|
236
|
+
/**
|
|
237
|
+
* Close menu
|
|
238
|
+
*/
|
|
239
|
+
closeMenu: () => void;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Common props for `Menu` and `SubMenu`
|
|
244
|
+
*/
|
|
245
|
+
export interface UncontrolledMenuProps {
|
|
246
|
+
/**
|
|
247
|
+
* Menu component ref which can be used to programmatically open or close menu.
|
|
248
|
+
*/
|
|
249
|
+
instanceRef?: React.Ref<MenuInstance>;
|
|
250
|
+
/**
|
|
251
|
+
* Event fired after menu is open or closed.
|
|
252
|
+
*/
|
|
253
|
+
onMenuChange?: EventHandler<MenuChangeEvent>;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface RadioChangeEvent extends Event {
|
|
257
|
+
/**
|
|
258
|
+
* The `name` prop passed to the `MenuRadioGroup` when the menu item is in a radio group.
|
|
259
|
+
*/
|
|
260
|
+
name?: string;
|
|
261
|
+
/**
|
|
262
|
+
* Set this property on event object to control whether to keep menu open after menu item is activated.
|
|
263
|
+
* Leaving it `undefined` will behave in accordance with WAI-ARIA Authoring Practices.
|
|
264
|
+
*/
|
|
265
|
+
keepOpen?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Setting this property on event object to `true` will skip `onItemClick` event on root menu component.
|
|
268
|
+
*/
|
|
269
|
+
stopPropagation?: boolean;
|
|
270
|
+
/**
|
|
271
|
+
* DOM event object (React synthetic event)
|
|
272
|
+
*/
|
|
273
|
+
syntheticEvent: MouseEvent | KeyboardEvent;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export interface ClickEvent extends RadioChangeEvent {
|
|
277
|
+
/**
|
|
278
|
+
* Indicates if the menu item is checked, only for `MenuItem` type="checkbox".
|
|
279
|
+
*/
|
|
280
|
+
checked?: boolean;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export type PortalFieldType =
|
|
284
|
+
| boolean
|
|
285
|
+
| {
|
|
286
|
+
/**
|
|
287
|
+
* A DOM node under which menu will be rendered.
|
|
288
|
+
*/
|
|
289
|
+
target?: Element | null;
|
|
290
|
+
/**
|
|
291
|
+
* When `target` is null, setting this value `true` prevents menu from rendering into the DOM hierarchy of its parent component.
|
|
292
|
+
*/
|
|
293
|
+
stablePosition?: boolean;
|
|
294
|
+
};
|
|
295
|
+
|
|
246
296
|
/**
|
|
247
297
|
* Common props for `Menu` and `ControlledMenu`
|
|
248
298
|
*/
|
|
249
|
-
interface RootMenuProps extends BaseMenuProps, MenuStateOptions {
|
|
299
|
+
export interface RootMenuProps extends BaseMenuProps, MenuStateOptions {
|
|
250
300
|
/**
|
|
251
301
|
* Properties of this object are spread to the root DOM element containing the menu.
|
|
252
302
|
*/
|
|
@@ -280,18 +330,8 @@ interface RootMenuProps extends BaseMenuProps, MenuStateOptions {
|
|
|
280
330
|
* - You have a DOM structure that creates a complex hierarchy of stacking contexts,
|
|
281
331
|
* and menu is overlapped regardless of `z-index` value.
|
|
282
332
|
*/
|
|
283
|
-
portal?:
|
|
284
|
-
|
|
285
|
-
| {
|
|
286
|
-
/**
|
|
287
|
-
* A DOM node under which menu will be rendered.
|
|
288
|
-
*/
|
|
289
|
-
target?: Element | null;
|
|
290
|
-
/**
|
|
291
|
-
* When `target` is null, setting this value `true` prevents menu from rendering into the DOM hierarchy of its parent component.
|
|
292
|
-
*/
|
|
293
|
-
stablePosition?: boolean;
|
|
294
|
-
};
|
|
333
|
+
portal?: PortalFieldType;
|
|
334
|
+
|
|
295
335
|
/**
|
|
296
336
|
* Specify when menu is repositioned:
|
|
297
337
|
* - 'initial' Don't automatically reposition menu. Set to this value when you want
|
|
@@ -331,70 +371,18 @@ interface RootMenuProps extends BaseMenuProps, MenuStateOptions {
|
|
|
331
371
|
onItemClick?: EventHandler<ClickEvent>;
|
|
332
372
|
}
|
|
333
373
|
|
|
334
|
-
export interface
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
* Close menu
|
|
341
|
-
*/
|
|
342
|
-
closeMenu: () => void;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Common props for `Menu` and `SubMenu`
|
|
347
|
-
*/
|
|
348
|
-
interface UncontrolledMenuProps {
|
|
349
|
-
/**
|
|
350
|
-
* Menu component ref which can be used to programmatically open or close menu.
|
|
351
|
-
*/
|
|
352
|
-
instanceRef?: React.Ref<MenuInstance>;
|
|
353
|
-
/**
|
|
354
|
-
* Event fired after menu is open or closed.
|
|
355
|
-
*/
|
|
356
|
-
onMenuChange?: EventHandler<MenuChangeEvent>;
|
|
374
|
+
export interface ExtraMenuProps {
|
|
375
|
+
isDisabled?: boolean;
|
|
376
|
+
ariaLabel?: string;
|
|
377
|
+
containerRef?: MutableRefObject<HTMLElement | undefined>;
|
|
378
|
+
externalRef?: ForwardedRef<HTMLUListElement>;
|
|
379
|
+
parentScrollingRef?: MutableRefObject<any>;
|
|
357
380
|
}
|
|
358
381
|
|
|
359
|
-
//
|
|
360
|
-
// MenuButton
|
|
361
|
-
// ----------------------------------------------------------------------
|
|
362
|
-
export type MenuButtonModifiers = Readonly<{
|
|
363
|
-
/**
|
|
364
|
-
* Indicates if the associated menu is open.
|
|
365
|
-
*/
|
|
366
|
-
open: boolean;
|
|
367
|
-
}>;
|
|
368
|
-
|
|
369
|
-
export interface MenuButtonProps extends BaseProps<MenuButtonModifiers> {
|
|
370
|
-
disabled?: boolean;
|
|
371
|
-
children?: React.ReactNode;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
export const MenuButton: React.NamedExoticComponent<MenuButtonProps>;
|
|
375
|
-
|
|
376
|
-
//
|
|
377
|
-
// Menu
|
|
378
|
-
// ----------------------------------------------------------------------
|
|
379
|
-
export interface MenuProps extends RootMenuProps, UncontrolledMenuProps {
|
|
380
|
-
/**
|
|
381
|
-
* Can be a `MenuButton`, a `button` element, or a React component.
|
|
382
|
-
* It also can be a render function that returns one.
|
|
383
|
-
*
|
|
384
|
-
* If a React component is provided, it needs to implement the following contracts:
|
|
385
|
-
* - Accepts a `ref` prop that is forwarded to an element to which menu will be positioned.
|
|
386
|
-
* The element should be able to receive focus.
|
|
387
|
-
* - Accepts `onClick` and `onKeyDown` event props.
|
|
388
|
-
*/
|
|
389
|
-
menuButton: RenderProp<MenuButtonModifiers, React.ReactElement>;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
export const Menu: React.NamedExoticComponent<MenuProps>;
|
|
393
|
-
|
|
394
382
|
//
|
|
395
383
|
// ControlledMenu
|
|
396
384
|
// ----------------------------------------------------------------------
|
|
397
|
-
export interface ControlledMenuProps extends RootMenuProps {
|
|
385
|
+
export interface ControlledMenuProps extends RootMenuProps, ExtraMenuProps {
|
|
398
386
|
/**
|
|
399
387
|
* Viewport coordinates to which context menu will be positioned.
|
|
400
388
|
*
|
|
@@ -409,8 +397,8 @@ export interface ControlledMenuProps extends RootMenuProps {
|
|
|
409
397
|
*
|
|
410
398
|
* *Don't set this prop for context menu*
|
|
411
399
|
*/
|
|
412
|
-
anchorRef?: React.
|
|
413
|
-
skipOpen?: React.
|
|
400
|
+
anchorRef?: React.MutableRefObject<HTMLElement>;
|
|
401
|
+
skipOpen?: React.MutableRefObject<boolean>;
|
|
414
402
|
/**
|
|
415
403
|
* If `true`, the menu list element will gain focus after menu is open.
|
|
416
404
|
* @default true
|
|
@@ -440,244 +428,3 @@ export interface ControlledMenuProps extends RootMenuProps {
|
|
|
440
428
|
*/
|
|
441
429
|
onClose?: EventHandler<MenuCloseEvent>;
|
|
442
430
|
}
|
|
443
|
-
|
|
444
|
-
export const ControlledMenu: React.NamedExoticComponent<ControlledMenuProps>;
|
|
445
|
-
|
|
446
|
-
//
|
|
447
|
-
// SubMenu
|
|
448
|
-
// ----------------------------------------------------------------------
|
|
449
|
-
export type SubMenuItemModifiers = Readonly<{
|
|
450
|
-
/**
|
|
451
|
-
* Indicates if the submenu is open.
|
|
452
|
-
*/
|
|
453
|
-
open: boolean;
|
|
454
|
-
/**
|
|
455
|
-
* Indicates if the submenu item is being hovered and has focus.
|
|
456
|
-
*/
|
|
457
|
-
hover: boolean;
|
|
458
|
-
/**
|
|
459
|
-
* Indicates if the submenu and item are disabled.
|
|
460
|
-
*/
|
|
461
|
-
disabled: boolean;
|
|
462
|
-
}>;
|
|
463
|
-
|
|
464
|
-
export interface SubMenuProps extends BaseMenuProps, Hoverable, UncontrolledMenuProps {
|
|
465
|
-
/**
|
|
466
|
-
* Properties of this object are spread to the submenu item DOM element.
|
|
467
|
-
*/
|
|
468
|
-
itemProps?: BaseProps<SubMenuItemModifiers>;
|
|
469
|
-
/**
|
|
470
|
-
* The submenu `label` can be a `string` or JSX element, or a render function that returns one.
|
|
471
|
-
*/
|
|
472
|
-
label?: RenderProp<SubMenuItemModifiers>;
|
|
473
|
-
/**
|
|
474
|
-
* - `undefined` submenu opens when the label item is hovered or clicked. This is the default behaviour.
|
|
475
|
-
* - 'clickOnly' submenu opens when the label item is clicked.
|
|
476
|
-
* - 'none' submenu doesn't open with mouse or keyboard events;
|
|
477
|
-
* you can call the `openMenu` function on `instanceRef` to open submenu programmatically.
|
|
478
|
-
*/
|
|
479
|
-
openTrigger?: "none" | "clickOnly";
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
export const SubMenu: React.NamedExoticComponent<SubMenuProps>;
|
|
483
|
-
|
|
484
|
-
//
|
|
485
|
-
// MenuItem
|
|
486
|
-
// ----------------------------------------------------------------------
|
|
487
|
-
export type MenuItemModifiers = Readonly<{
|
|
488
|
-
/**
|
|
489
|
-
* 'radio' for radio item, 'checkbox' for checkbox item, or `undefined` for other items.
|
|
490
|
-
*/
|
|
491
|
-
type?: MenuItemTypeProp;
|
|
492
|
-
/**
|
|
493
|
-
* Indicates if the menu item is disabled.
|
|
494
|
-
*/
|
|
495
|
-
disabled: boolean;
|
|
496
|
-
/**
|
|
497
|
-
* Indicates if the menu item is being hovered and has focus.
|
|
498
|
-
*/
|
|
499
|
-
hover: boolean;
|
|
500
|
-
/**
|
|
501
|
-
* Indicates if the menu item is checked when it's a radio or checkbox item.
|
|
502
|
-
*/
|
|
503
|
-
checked: boolean;
|
|
504
|
-
/**
|
|
505
|
-
* Indicates if the menu item has a URL link.
|
|
506
|
-
*/
|
|
507
|
-
anchor: boolean;
|
|
508
|
-
}>;
|
|
509
|
-
|
|
510
|
-
export interface MenuItemProps extends Omit<BaseProps<MenuItemModifiers>, "onClick">, Hoverable {
|
|
511
|
-
/**
|
|
512
|
-
* Any value provided to this prop will be available in the event object of click events.
|
|
513
|
-
*
|
|
514
|
-
* It's useful for helping identify which menu item is clicked when you
|
|
515
|
-
* listen on `onItemClick` event on root menu component.
|
|
516
|
-
*/
|
|
517
|
-
value?: any;
|
|
518
|
-
/**
|
|
519
|
-
* If provided, menu item renders an HTML `<a>` element with this `href` attribute.
|
|
520
|
-
*/
|
|
521
|
-
href?: string;
|
|
522
|
-
rel?: string;
|
|
523
|
-
target?: string;
|
|
524
|
-
/**
|
|
525
|
-
* Set this prop to make the item a checkbox or radio menu item.
|
|
526
|
-
*/
|
|
527
|
-
type?: MenuItemTypeProp;
|
|
528
|
-
/**
|
|
529
|
-
* Set `true` if a checkbox menu item is checked.
|
|
530
|
-
*
|
|
531
|
-
* *Please note radio menu item doesn't use this prop.*
|
|
532
|
-
*/
|
|
533
|
-
checked?: boolean;
|
|
534
|
-
/**
|
|
535
|
-
* Event fired when the menu item is clicked.
|
|
536
|
-
*/
|
|
537
|
-
onClick?: EventHandler<ClickEvent>;
|
|
538
|
-
/**
|
|
539
|
-
* Any valid React node or a render function that returns one.
|
|
540
|
-
*/
|
|
541
|
-
children?: RenderProp<MenuItemModifiers>;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
export const MenuItem: React.NamedExoticComponent<MenuItemProps>;
|
|
545
|
-
|
|
546
|
-
//
|
|
547
|
-
// FocusableItem
|
|
548
|
-
// ----------------------------------------------------------------------
|
|
549
|
-
export type FocusableItemModifiers = Readonly<{
|
|
550
|
-
/**
|
|
551
|
-
* Indicates if the focusable item is disabled.
|
|
552
|
-
*/
|
|
553
|
-
disabled: boolean;
|
|
554
|
-
/**
|
|
555
|
-
* Indicates if the focusable item is being hovered.
|
|
556
|
-
*/
|
|
557
|
-
hover: boolean;
|
|
558
|
-
/**
|
|
559
|
-
* Always `true` for a focusable item.
|
|
560
|
-
*/
|
|
561
|
-
focusable: true;
|
|
562
|
-
}>;
|
|
563
|
-
|
|
564
|
-
export interface FocusableItemProps extends BaseProps<FocusableItemModifiers>, Hoverable {
|
|
565
|
-
/**
|
|
566
|
-
* A render function that returns a React node.
|
|
567
|
-
*/
|
|
568
|
-
children: (modifiers: {
|
|
569
|
-
/**
|
|
570
|
-
* Indicates if the focusable item is disabled.
|
|
571
|
-
*/
|
|
572
|
-
disabled: boolean;
|
|
573
|
-
/**
|
|
574
|
-
* Indicates if the focusable item is being hovered.
|
|
575
|
-
*/
|
|
576
|
-
hover: boolean;
|
|
577
|
-
/**
|
|
578
|
-
* A ref to be attached to the element which should receive focus when this focusable item is hovered.
|
|
579
|
-
*
|
|
580
|
-
* If you render a React component, it needs to expose a `focus` method or implement ref forwarding.
|
|
581
|
-
*/
|
|
582
|
-
ref: React.RefObject<any>;
|
|
583
|
-
/**
|
|
584
|
-
* A function that requests to close the root menu.
|
|
585
|
-
* @param {string} key Indicate which key initiates the close request.
|
|
586
|
-
*/
|
|
587
|
-
closeMenu: (key?: string) => void;
|
|
588
|
-
}) => React.ReactNode;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* A component to wrap focusable element (input, button) in a menu item.
|
|
593
|
-
* It manages focus automatically among other menu items during mouse and keyboard interactions.
|
|
594
|
-
*
|
|
595
|
-
* @example https://szhsin.github.io/react-menu/#focusable-item
|
|
596
|
-
*/
|
|
597
|
-
export const FocusableItem: React.NamedExoticComponent<FocusableItemProps>;
|
|
598
|
-
|
|
599
|
-
//
|
|
600
|
-
// MenuDivider
|
|
601
|
-
// ----------------------------------------------------------------------
|
|
602
|
-
export const MenuDivider: React.NamedExoticComponent<BaseProps>;
|
|
603
|
-
|
|
604
|
-
//
|
|
605
|
-
// MenuHeader
|
|
606
|
-
// ----------------------------------------------------------------------
|
|
607
|
-
export interface MenuHeaderProps extends BaseProps {
|
|
608
|
-
children?: React.ReactNode;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
export const MenuHeader: React.NamedExoticComponent<MenuHeaderProps>;
|
|
612
|
-
|
|
613
|
-
//
|
|
614
|
-
// MenuGroup
|
|
615
|
-
// ----------------------------------------------------------------------
|
|
616
|
-
export interface MenuGroupProps extends BaseProps {
|
|
617
|
-
children?: React.ReactNode;
|
|
618
|
-
/**
|
|
619
|
-
* Set `true` to apply overflow of the parent menu to the group.
|
|
620
|
-
* Only one `MenuGroup` in a menu should set this prop as `true`.
|
|
621
|
-
*/
|
|
622
|
-
takeOverflow?: boolean;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* A component to wrap a subset related menu items and make them scrollable.
|
|
627
|
-
*
|
|
628
|
-
* @example https://szhsin.github.io/react-menu/#menu-overflow
|
|
629
|
-
*/
|
|
630
|
-
export const MenuGroup: React.NamedExoticComponent<MenuGroupProps>;
|
|
631
|
-
|
|
632
|
-
//
|
|
633
|
-
// MenuRadioGroup
|
|
634
|
-
// ----------------------------------------------------------------------
|
|
635
|
-
export interface MenuRadioGroupProps extends BaseProps {
|
|
636
|
-
/**
|
|
637
|
-
* Optionally set the radio group name.
|
|
638
|
-
*
|
|
639
|
-
* The name will be passed to the `onRadioChange` event.
|
|
640
|
-
* It's useful for identifying radio groups if you attach the same event handler to multiple groups.
|
|
641
|
-
*/
|
|
642
|
-
name?: string;
|
|
643
|
-
/**
|
|
644
|
-
* Set value of the radio group.
|
|
645
|
-
*
|
|
646
|
-
* The child menu item which has the same value (strict equality ===) as the
|
|
647
|
-
* radio group is marked as checked.
|
|
648
|
-
*/
|
|
649
|
-
value?: any;
|
|
650
|
-
children?: React.ReactNode;
|
|
651
|
-
/**
|
|
652
|
-
* Event fired when a child menu item is clicked (selected).
|
|
653
|
-
*/
|
|
654
|
-
onRadioChange?: EventHandler<RadioChangeEvent>;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
export const MenuRadioGroup: React.NamedExoticComponent<MenuRadioGroupProps>;
|
|
658
|
-
|
|
659
|
-
/**
|
|
660
|
-
* A custom Hook which helps manage the states of `ControlledMenu`.
|
|
661
|
-
*/
|
|
662
|
-
export function useMenuState(options?: MenuStateOptions): [
|
|
663
|
-
{
|
|
664
|
-
/**
|
|
665
|
-
* Menu state which should be forwarded to `ControlledMenu`.
|
|
666
|
-
*/
|
|
667
|
-
state?: MenuState;
|
|
668
|
-
/**
|
|
669
|
-
* Stop transition animation. This function value should be forwarded to `ControlledMenu`.
|
|
670
|
-
*/
|
|
671
|
-
endTransition: () => void;
|
|
672
|
-
},
|
|
673
|
-
|
|
674
|
-
/**
|
|
675
|
-
* Open or close menu.
|
|
676
|
-
*
|
|
677
|
-
* - If no parameter is supplied, this function will toggle state between open and close phases.
|
|
678
|
-
* - You can set a boolean parameter to explicitly switch into one of the two phases.
|
|
679
|
-
*/
|
|
680
|
-
(open?: boolean) => void,
|
|
681
|
-
];
|
|
682
|
-
|
|
683
|
-
export {};
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { createContext, MutableRefObject } from "react";
|
|
2
|
-
import {
|
|
1
|
+
import { createContext, MutableRefObject, RefObject } from "react";
|
|
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";
|
|
3
14
|
import { RadioChangeEvent } from "../components/MenuRadioGroup";
|
|
4
|
-
import { ControlledMenuProps } from "../components/MenuList";
|
|
5
15
|
|
|
6
16
|
export const menuContainerClass = "szh-menu-container";
|
|
7
17
|
export const menuClass = "szh-menu";
|
|
@@ -59,10 +69,19 @@ export const RadioGroupContext = createContext<{
|
|
|
59
69
|
onRadioChange?: EventHandler<RadioChangeEvent>;
|
|
60
70
|
}>({});
|
|
61
71
|
|
|
62
|
-
interface SettingsContextType extends ControlledMenuProps
|
|
72
|
+
interface SettingsContextType extends ControlledMenuProps {
|
|
63
73
|
rootMenuRef?: MutableRefObject<any>;
|
|
64
74
|
rootAnchorRef?: MutableRefObject<any>;
|
|
65
|
-
scrollNodesRef: MutableRefObject<{ anchors?: Element[]; menu
|
|
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;
|
|
66
85
|
}
|
|
67
86
|
|
|
68
87
|
// FIXME hacking a default context in here is probably bad
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { unstable_batchedUpdates } from "react-dom";
|
|
2
|
-
import { MenuState, MenuStateOptions } from "../
|
|
2
|
+
import { MenuState, MenuStateOptions } from "../types";
|
|
3
3
|
import { MenuButtonProps } from "../components/MenuButton";
|
|
4
4
|
import { findIndex } from "lodash-es";
|
|
5
5
|
|
|
@@ -32,7 +32,7 @@ export const defineName = (
|
|
|
32
32
|
component: React.ForwardRefExoticComponent<React.PropsWithoutRef<MenuButtonProps> & React.RefAttributes<unknown>>,
|
|
33
33
|
) => Object.defineProperty(component, internalKey, { value: name });
|
|
34
34
|
|
|
35
|
-
export const mergeProps = (target:
|
|
35
|
+
export const mergeProps = (target: any, source: any) => {
|
|
36
36
|
source &&
|
|
37
37
|
Object.keys(source).forEach((key) => {
|
|
38
38
|
const targetProp = target[key];
|
|
@@ -8,7 +8,6 @@ import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
|
8
8
|
import { Grid, GridProps } from "@components/Grid";
|
|
9
9
|
import { useMemo, useState } from "react";
|
|
10
10
|
import { wait } from "@utils/util";
|
|
11
|
-
import { ICellRendererParams } from "ag-grid-community";
|
|
12
11
|
import { GridPopoverMenu } from "@components/gridPopoverEdit/GridPopoverMenu";
|
|
13
12
|
import { GridPopoverMessage } from "@components/gridPopoverEdit/GridPopoverMessage";
|
|
14
13
|
import { GridCell } from "@components/GridCell";
|
|
@@ -51,14 +50,14 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
51
50
|
initialWidth: 65,
|
|
52
51
|
maxWidth: 85,
|
|
53
52
|
}),
|
|
54
|
-
GridCell({
|
|
53
|
+
GridCell<ITestRow, any>({
|
|
55
54
|
field: "position",
|
|
56
55
|
headerName: "Position",
|
|
57
56
|
initialWidth: 65,
|
|
58
57
|
maxWidth: 150,
|
|
59
58
|
cellRendererParams: {
|
|
60
|
-
warning: (props
|
|
61
|
-
info: (props
|
|
59
|
+
warning: (props) => props.value === "Tester" && "Testers are testing",
|
|
60
|
+
info: (props) => props.value === "Developer" && "Developers are awesome",
|
|
62
61
|
},
|
|
63
62
|
}),
|
|
64
63
|
GridCell({
|