@genesislcap/grid-pro 15.71.1-alpha-71cb16e4d3.0 → 15.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +495 -350
- package/dist/dts/context-menu/context-menu.d.ts +69 -0
- package/dist/dts/context-menu/context-menu.d.ts.map +1 -0
- package/dist/dts/context-menu/index.d.ts +2 -0
- package/dist/dts/context-menu/index.d.ts.map +1 -0
- package/dist/dts/grid-pro.d.ts +39 -2
- package/dist/dts/grid-pro.d.ts.map +1 -1
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/react.d.ts +9 -9
- package/dist/esm/context-menu/context-menu.js +379 -0
- package/dist/esm/context-menu/index.js +1 -0
- package/dist/esm/grid-pro.js +81 -3
- package/dist/esm/index.js +1 -0
- package/dist/grid-pro.api.json +401 -1
- package/dist/grid-pro.d.ts +80 -3
- package/dist/react.cjs +6 -6
- package/dist/react.mjs +5 -5
- package/package.json +12 -12
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { CellContextMenuEvent } from 'ag-grid-community';
|
|
2
|
+
/**
|
|
3
|
+
* One entry in grid-pro's right-click menu.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface GridProContextMenuItem {
|
|
8
|
+
name: string;
|
|
9
|
+
/** Drawn to the right of the name, for example a key combination. */
|
|
10
|
+
shortcut?: string;
|
|
11
|
+
/** Shown on hover, including while the item is disabled — say why it cannot be chosen. */
|
|
12
|
+
tooltip?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Set to `true` or `false` to make the item a checkbox; leave unset for a plain item. */
|
|
15
|
+
checked?: boolean;
|
|
16
|
+
action?: () => void;
|
|
17
|
+
subMenu?: GridProContextMenuEntry[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An item, or `'separator'` for a dividing line between groups of items.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export type GridProContextMenuEntry = GridProContextMenuItem | 'separator';
|
|
25
|
+
/**
|
|
26
|
+
* Builds the right-click menu for one cell. Return an empty list to show the browser's menu.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export type GridProContextMenuItems = (event: CellContextMenuEvent) => GridProContextMenuEntry[];
|
|
31
|
+
/**
|
|
32
|
+
* A CSV Export item, using AG Grid's community CSV export. Assign it to `contextMenuItems` as the
|
|
33
|
+
* whole menu, or spread its result into a menu of your own. Empty when the grid sets
|
|
34
|
+
* `suppressCsvExport`.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare function defaultGridContextMenuItems(event: CellContextMenuEvent): GridProContextMenuItem[];
|
|
39
|
+
/**
|
|
40
|
+
* Where and how {@link openGridContextMenu} draws the menu.
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export interface GridContextMenuOptions {
|
|
45
|
+
/** Design-system prefix: the menu is built from `${prefix}-menu` and `${prefix}-menu-item`. */
|
|
46
|
+
prefix: string;
|
|
47
|
+
/** Viewport coordinates of the pointer. */
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
items: readonly GridProContextMenuEntry[];
|
|
51
|
+
/**
|
|
52
|
+
* Node the menu is attached to. Use one inside the grid's own tree, so a grid in a modal dialog
|
|
53
|
+
* does not render its menu inert. Defaults to `document.body`.
|
|
54
|
+
*/
|
|
55
|
+
container?: Node;
|
|
56
|
+
/** Element the theme variables are read from, and focus returns to on keyboard close. */
|
|
57
|
+
themeSource?: Element | null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Opens a design-system menu at the pointer and returns a function that removes it, or
|
|
61
|
+
* `undefined` when the design system has not registered the menu components.
|
|
62
|
+
*
|
|
63
|
+
* A pointer press outside, a scroll outside, a window resize, Escape or Tab closes it. Choosing an item runs its
|
|
64
|
+
* action and closes it; an item with a submenu opens the submenu instead.
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export declare function openGridContextMenu(options: GridContextMenuOptions): (() => void) | undefined;
|
|
69
|
+
//# sourceMappingURL=context-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../../../src/context-menu/context-menu.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AA2L9D;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACrC;AAED;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,GAAG,WAAW,CAAC;AAE3E;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,oBAAoB,KAAK,uBAAuB,EAAE,CAAC;AAEjG;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,oBAAoB,GAAG,sBAAsB,EAAE,CAUjG;AAmBD;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,+FAA+F;IAC/F,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,SAAS,uBAAuB,EAAE,CAAC;IAC1C;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,yFAAyF;IACzF,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CA4E7F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context-menu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,gBAAgB,CAAC"}
|
package/dist/dts/grid-pro.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ViewTemplate } from '@microsoft/fast-element';
|
|
2
2
|
import { FoundationElement } from '@microsoft/fast-foundation';
|
|
3
|
-
import type { ColDef, ColumnState, GridApi, GridOptions, GridParams, IStatusPanelComp } from 'ag-grid-community';
|
|
3
|
+
import type { CellContextMenuEvent, ColDef, ColumnState, GridApi, GridOptions, GridParams, IStatusPanelComp } from 'ag-grid-community';
|
|
4
4
|
import { type GridProColumnDragBridge } from './column-selection/grid-pro-column-drag-bridge';
|
|
5
|
+
import { type GridProContextMenuItems } from './context-menu/context-menu';
|
|
5
6
|
import { GridProBaseDatasource } from './datasource/base.datasource';
|
|
6
7
|
import type { GridComponents, GridProCaseType, GridProErrorEvent, GridProErrorItem, GridProEventsAndCallbacks } from './grid-pro.types';
|
|
7
8
|
import { GridOptionsConfig, GridProStatusBarConfig, GridProStatusBarLabelConfig } from './grid-pro.types';
|
|
@@ -503,6 +504,23 @@ export declare class GridPro extends GridPro_base {
|
|
|
503
504
|
* @internal
|
|
504
505
|
*/
|
|
505
506
|
get statusBar(): GridProStatusBar | undefined;
|
|
507
|
+
/**
|
|
508
|
+
* Opts the grid into its own right-click menu, built from these items for each cell. It needs no
|
|
509
|
+
* AG Grid Enterprise module, and replaces AG Grid's context menu while set. Assign
|
|
510
|
+
* {@link defaultGridContextMenuItems} for a CSV Export menu, or return an empty list to show the
|
|
511
|
+
* browser's menu for that cell.
|
|
512
|
+
*
|
|
513
|
+
* Unset, right-click is left alone: AG Grid's menu when its `ContextMenu` module is registered,
|
|
514
|
+
* otherwise the browser's.
|
|
515
|
+
*
|
|
516
|
+
* @public
|
|
517
|
+
*/
|
|
518
|
+
contextMenuItems?: GridProContextMenuItems;
|
|
519
|
+
contextMenuItemsChanged(): void;
|
|
520
|
+
/** Removes the open right-click menu, if there is one. */
|
|
521
|
+
private closeContextMenu?;
|
|
522
|
+
/** Whether the AG grid instance was created with its own context menu suppressed. */
|
|
523
|
+
private gridCreatedWithMenuSuppressed;
|
|
506
524
|
/**
|
|
507
525
|
* Shows a Columns side panel on the trailing edge of the grid.
|
|
508
526
|
* @public
|
|
@@ -536,6 +554,11 @@ export declare class GridPro extends GridPro_base {
|
|
|
536
554
|
private luminanceSubscription?;
|
|
537
555
|
private visibilityObserverCleanup?;
|
|
538
556
|
private readonly boundGlobalEventListener;
|
|
557
|
+
/**
|
|
558
|
+
* `globalListener` runs on a timeout, which is too late to cancel the browser menu.
|
|
559
|
+
* This one runs inside the right-click event.
|
|
560
|
+
*/
|
|
561
|
+
private readonly boundContextMenuListener;
|
|
539
562
|
private _filterConfig;
|
|
540
563
|
getfilterModel(): Promise<{
|
|
541
564
|
[key: string]: any;
|
|
@@ -878,7 +901,7 @@ export declare class GridPro extends GridPro_base {
|
|
|
878
901
|
onCellValueChanged?: ((event: import("@ag-grid-community/core").NewValueParams<any>) => void) | ((event: import("ag-grid-community").NewValueParams<any, any, any>) => void);
|
|
879
902
|
onCellClicked?: ((event: import("@ag-grid-community/core").CellClickedEvent<any, any>) => void) | ((event: import("ag-grid-community").CellClickedEvent<any, any, any>) => void);
|
|
880
903
|
onCellDoubleClicked?: ((event: import("@ag-grid-community/core").CellDoubleClickedEvent<any, any>) => void) | ((event: import("ag-grid-community").CellDoubleClickedEvent<any, any, any>) => void);
|
|
881
|
-
onCellContextMenu?: ((event: import("@ag-grid-community/core").CellContextMenuEvent<any, any>) => void) | ((event:
|
|
904
|
+
onCellContextMenu?: ((event: import("@ag-grid-community/core").CellContextMenuEvent<any, any>) => void) | ((event: CellContextMenuEvent<any, any, any>) => void);
|
|
882
905
|
getQuickFilterText?: ((params: import("@ag-grid-community/core").GetQuickFilterTextParams<any, any>) => string) | import("ag-grid-community").GetQuickFilterText<any, any, any>;
|
|
883
906
|
filterValueGetter?: string | import("@ag-grid-community/core").ValueGetterFunc<any> | import("ag-grid-community").ValueGetterFunc<any, any, any>;
|
|
884
907
|
floatingFilter?: boolean;
|
|
@@ -1019,6 +1042,20 @@ export declare class GridPro extends GridPro_base {
|
|
|
1019
1042
|
protected setupStatusBar(gridOptions: GridOptions): void;
|
|
1020
1043
|
get observedAttributes(): string[];
|
|
1021
1044
|
agAttributeChangedCallback(attName: any, oldValue: any, newValue: any): void;
|
|
1045
|
+
/**
|
|
1046
|
+
* AG Grid draws its own menu when `ContextMenu` is registered, so it is suppressed while
|
|
1047
|
+
* `contextMenuItems` is set and the app's own `suppressContextMenu` restored when it is cleared.
|
|
1048
|
+
* The suppression goes to AG Grid only, never into `agGridOptions`: that object is what the
|
|
1049
|
+
* `gridOptions` getter returns, and an app re-applying it would otherwise adopt the setting.
|
|
1050
|
+
* @internal
|
|
1051
|
+
*/
|
|
1052
|
+
private syncContextMenuSuppression;
|
|
1053
|
+
/**
|
|
1054
|
+
* Opens the grid's right-click menu for a cell. Called from the synchronous grid listener so
|
|
1055
|
+
* `preventDefault` still cancels the browser menu.
|
|
1056
|
+
* @internal
|
|
1057
|
+
*/
|
|
1058
|
+
private showContextMenu;
|
|
1022
1059
|
globalEventListener(eventType: any, event: any): void;
|
|
1023
1060
|
}
|
|
1024
1061
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-pro.d.ts","sourceRoot":"","sources":["../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ED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;kBAwC5B,CAAC"}
|
package/dist/dts/index.d.ts
CHANGED
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
package/dist/dts/react.d.ts
CHANGED
|
@@ -83,6 +83,15 @@ export declare const GridPro: React.ForwardRefExoticComponent<
|
|
|
83
83
|
>;
|
|
84
84
|
export type GridProRef = GridProWC;
|
|
85
85
|
|
|
86
|
+
export declare const GridProCell: React.ForwardRefExoticComponent<
|
|
87
|
+
React.PropsWithChildren<
|
|
88
|
+
Omit<PublicOf<GridProCellWC>, 'children' | 'style'> &
|
|
89
|
+
HTMLWCProps & {
|
|
90
|
+
}
|
|
91
|
+
> & React.RefAttributes<GridProCellWC>
|
|
92
|
+
>;
|
|
93
|
+
export type GridProCellRef = GridProCellWC;
|
|
94
|
+
|
|
86
95
|
export declare const DateEditor: React.ForwardRefExoticComponent<
|
|
87
96
|
React.PropsWithChildren<
|
|
88
97
|
Omit<PublicOf<DateEditorWC>, 'children' | 'style'> &
|
|
@@ -128,15 +137,6 @@ export declare const StringEditor: React.ForwardRefExoticComponent<
|
|
|
128
137
|
>;
|
|
129
138
|
export type StringEditorRef = StringEditorWC;
|
|
130
139
|
|
|
131
|
-
export declare const GridProCell: React.ForwardRefExoticComponent<
|
|
132
|
-
React.PropsWithChildren<
|
|
133
|
-
Omit<PublicOf<GridProCellWC>, 'children' | 'style'> &
|
|
134
|
-
HTMLWCProps & {
|
|
135
|
-
}
|
|
136
|
-
> & React.RefAttributes<GridProCellWC>
|
|
137
|
-
>;
|
|
138
|
-
export type GridProCellRef = GridProCellWC;
|
|
139
|
-
|
|
140
140
|
export declare const ActionRenderer: React.ForwardRefExoticComponent<
|
|
141
141
|
React.PropsWithChildren<
|
|
142
142
|
Omit<PublicOf<ActionRendererWC>, 'children' | 'style'> &
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { css, DOM } from '@microsoft/fast-element';
|
|
2
|
+
import { logger } from '../utils/logger';
|
|
3
|
+
/**
|
|
4
|
+
* Same surface as the vertical actions menu: AG Grid's context-menu variables, with design-system
|
|
5
|
+
* tokens when those variables are not set. The menu is drawn in the top layer, outside the themed
|
|
6
|
+
* grid element, so the values are copied from the cell that was clicked.
|
|
7
|
+
*/
|
|
8
|
+
const contextMenuStyles = css `
|
|
9
|
+
:host {
|
|
10
|
+
display: block;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host > .grid-context-menu,
|
|
14
|
+
.grid-context-menu-item > .grid-context-menu {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
margin: 0;
|
|
19
|
+
padding: var(--ag-spacing, 4px) 0;
|
|
20
|
+
max-width: 368px;
|
|
21
|
+
min-width: 64px;
|
|
22
|
+
background-color: var(--ag-menu-background-color, var(--fill-color));
|
|
23
|
+
border: var(
|
|
24
|
+
--ag-menu-border,
|
|
25
|
+
calc(var(--stroke-width, 1) * 1px) solid var(--neutral-stroke-rest, transparent)
|
|
26
|
+
);
|
|
27
|
+
border-radius: var(--ag-border-radius, calc(var(--control-corner-radius, 2) * 1px));
|
|
28
|
+
box-shadow: var(--ag-menu-shadow, var(--ag-popup-shadow, 0 2px 8px rgb(0 0 0 / 30%)));
|
|
29
|
+
color: var(--ag-menu-text-color, var(--neutral-foreground-rest));
|
|
30
|
+
font-family: var(--ag-font-family, var(--body-font));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.grid-context-menu > .grid-context-menu-item {
|
|
34
|
+
display: flex;
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
align-items: center;
|
|
37
|
+
height: calc(var(--ag-icon-size, 16px) + (var(--ag-spacing, 4px) + 2px) * 2);
|
|
38
|
+
margin: 0;
|
|
39
|
+
background: transparent;
|
|
40
|
+
border: none;
|
|
41
|
+
border-radius: 0;
|
|
42
|
+
color: inherit;
|
|
43
|
+
font-family: inherit;
|
|
44
|
+
font-size: var(--ag-font-size, var(--type-ramp-base-font-size));
|
|
45
|
+
font-weight: 500;
|
|
46
|
+
user-select: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.grid-context-menu > .grid-context-menu-separator {
|
|
50
|
+
margin: var(--ag-spacing, 4px) 0;
|
|
51
|
+
border-top: var(
|
|
52
|
+
--ag-menu-border,
|
|
53
|
+
calc(var(--stroke-width, 1) * 1px) solid var(--neutral-stroke-rest, currentColor)
|
|
54
|
+
);
|
|
55
|
+
opacity: 50%;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.grid-context-menu > .grid-context-menu-item:hover,
|
|
59
|
+
.grid-context-menu > .grid-context-menu-item:focus {
|
|
60
|
+
background: var(--ag-row-hover-color, var(--neutral-fill-stealth-hover));
|
|
61
|
+
border: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.grid-context-menu > .grid-context-menu-item[disabled] {
|
|
65
|
+
background: transparent;
|
|
66
|
+
cursor: default;
|
|
67
|
+
opacity: 50%;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.grid-context-menu > .grid-context-menu-item::part(content) {
|
|
71
|
+
flex: 1;
|
|
72
|
+
margin-inline: 0;
|
|
73
|
+
padding-inline: calc(var(--ag-spacing, 4px) * 2) calc(var(--ag-spacing, 4px) * 4);
|
|
74
|
+
line-height: var(--ag-icon-size, 16px);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* A plain item in a menu with checkboxes lines its text up with theirs. */
|
|
78
|
+
.grid-context-menu
|
|
79
|
+
> .grid-context-menu-item.indent-1:not([role='menuitemcheckbox'])::part(content) {
|
|
80
|
+
padding-inline-start: calc(var(--ag-spacing, 4px) * 4 + var(--ag-icon-size, 16px));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.grid-context-menu > .grid-context-menu-item::part(end) {
|
|
84
|
+
padding-inline-end: calc(var(--ag-spacing, 4px) * 2);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.grid-context-menu > .grid-context-menu-item [slot='end'] {
|
|
88
|
+
white-space: nowrap;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* The menu item's own boxed, accent-filled checkbox and wide chevron, reduced to AG Grid's
|
|
92
|
+
icon column: a bare tick and a small arrow at the grid's icon size. */
|
|
93
|
+
.grid-context-menu > .grid-context-menu-item::part(input-container) {
|
|
94
|
+
margin: 0;
|
|
95
|
+
padding-inline-start: calc(var(--ag-spacing, 4px) * 2);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.grid-context-menu > .grid-context-menu-item::part(checkbox),
|
|
99
|
+
.grid-context-menu > .grid-context-menu-item[aria-checked='true']::part(checkbox) {
|
|
100
|
+
width: var(--ag-icon-size, 16px);
|
|
101
|
+
height: var(--ag-icon-size, 16px);
|
|
102
|
+
margin: 0;
|
|
103
|
+
background: transparent;
|
|
104
|
+
border: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.grid-context-menu > .grid-context-menu-item::part(expand-collapse-glyph-container) {
|
|
108
|
+
margin: 0;
|
|
109
|
+
padding-inline-end: calc(var(--ag-spacing, 4px) * 2);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.grid-context-menu > .grid-context-menu-item::part(expand-collapse) {
|
|
113
|
+
width: var(--ag-icon-size, 16px);
|
|
114
|
+
height: var(--ag-icon-size, 16px);
|
|
115
|
+
margin: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.grid-context-menu-icon {
|
|
119
|
+
display: inline-flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
width: var(--ag-icon-size, 16px);
|
|
123
|
+
height: var(--ag-icon-size, 16px);
|
|
124
|
+
font-size: var(--ag-icon-size, 16px);
|
|
125
|
+
color: inherit;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* Font Awesome's chevron fills its box; the check does not, so the arrow is drawn smaller. */
|
|
129
|
+
.grid-context-menu-icon.chevron {
|
|
130
|
+
font-size: calc(var(--ag-icon-size, 16px) * 0.75);
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
/** The design-system icon (`${prefix}-icon`), which draws Font Awesome. */
|
|
134
|
+
function menuIcon(prefix, slot, name, variant) {
|
|
135
|
+
const icon = document.createElement(`${prefix}-icon`);
|
|
136
|
+
icon.slot = slot;
|
|
137
|
+
icon.classList.add('grid-context-menu-icon');
|
|
138
|
+
if (variant) {
|
|
139
|
+
icon.classList.add(variant);
|
|
140
|
+
}
|
|
141
|
+
icon.setAttribute('name', name);
|
|
142
|
+
icon.setAttribute('size', '1x');
|
|
143
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
144
|
+
return icon;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Custom properties the menu reads. AG Grid sets its theme on its wrapper element, which is not an
|
|
148
|
+
* ancestor of the menu, so they are copied from the clicked cell.
|
|
149
|
+
*/
|
|
150
|
+
const MENU_THEME_PROPERTIES = [
|
|
151
|
+
'--ag-spacing',
|
|
152
|
+
'--ag-icon-size',
|
|
153
|
+
'--ag-font-size',
|
|
154
|
+
'--ag-font-family',
|
|
155
|
+
'--ag-menu-background-color',
|
|
156
|
+
'--ag-menu-border',
|
|
157
|
+
'--ag-menu-text-color',
|
|
158
|
+
'--ag-menu-shadow',
|
|
159
|
+
'--ag-popup-shadow',
|
|
160
|
+
'--ag-border-radius',
|
|
161
|
+
'--ag-row-hover-color',
|
|
162
|
+
'--fill-color',
|
|
163
|
+
'--neutral-stroke-rest',
|
|
164
|
+
'--neutral-foreground-rest',
|
|
165
|
+
'--neutral-fill-stealth-hover',
|
|
166
|
+
'--body-font',
|
|
167
|
+
'--type-ramp-base-font-size',
|
|
168
|
+
'--stroke-width',
|
|
169
|
+
'--control-corner-radius',
|
|
170
|
+
];
|
|
171
|
+
function applyMenuTheme(host, source) {
|
|
172
|
+
if (!source) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const computed = getComputedStyle(source);
|
|
176
|
+
for (const name of MENU_THEME_PROPERTIES) {
|
|
177
|
+
const value = computed.getPropertyValue(name).trim();
|
|
178
|
+
if (value) {
|
|
179
|
+
host.style.setProperty(name, value);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* A CSV Export item, using AG Grid's community CSV export. Assign it to `contextMenuItems` as the
|
|
185
|
+
* whole menu, or spread its result into a menu of your own. Empty when the grid sets
|
|
186
|
+
* `suppressCsvExport`.
|
|
187
|
+
*
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
export function defaultGridContextMenuItems(event) {
|
|
191
|
+
var _a;
|
|
192
|
+
if ((_a = event.api) === null || _a === void 0 ? void 0 : _a.getGridOption('suppressCsvExport')) {
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
return [
|
|
196
|
+
{
|
|
197
|
+
name: 'CSV Export',
|
|
198
|
+
action: () => { var _a; return (_a = event.api) === null || _a === void 0 ? void 0 : _a.exportDataAsCsv(); },
|
|
199
|
+
},
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
/** Each prefix is reported once, not on every right-click. */
|
|
203
|
+
const prefixesReportedMissing = new Set();
|
|
204
|
+
function menuComponentsRegistered(prefix) {
|
|
205
|
+
if (customElements.get(`${prefix}-menu`) && customElements.get(`${prefix}-menu-item`)) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
if (!prefixesReportedMissing.has(prefix)) {
|
|
209
|
+
prefixesReportedMissing.add(prefix);
|
|
210
|
+
logger.warn(`Grid Pro: the right-click menu needs <${prefix}-menu> and <${prefix}-menu-item> registered ` +
|
|
211
|
+
'in the design system. The browser menu is shown instead.');
|
|
212
|
+
}
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Opens a design-system menu at the pointer and returns a function that removes it, or
|
|
217
|
+
* `undefined` when the design system has not registered the menu components.
|
|
218
|
+
*
|
|
219
|
+
* A pointer press outside, a scroll outside, a window resize, Escape or Tab closes it. Choosing an item runs its
|
|
220
|
+
* action and closes it; an item with a submenu opens the submenu instead.
|
|
221
|
+
*
|
|
222
|
+
* @internal
|
|
223
|
+
*/
|
|
224
|
+
export function openGridContextMenu(options) {
|
|
225
|
+
var _a, _b;
|
|
226
|
+
const { prefix, x, y, items, themeSource } = options;
|
|
227
|
+
if (!menuComponentsRegistered(prefix)) {
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
const host = document.createElement('div');
|
|
231
|
+
host.classList.add('grid-context-menu-host');
|
|
232
|
+
host.style.cssText = MENU_HOST_STYLE;
|
|
233
|
+
applyMenuTheme(host, themeSource);
|
|
234
|
+
host.addEventListener('mousedown', (event) => event.stopPropagation());
|
|
235
|
+
const shadow = host.attachShadow({ mode: 'open' });
|
|
236
|
+
contextMenuStyles.addStylesTo(shadow);
|
|
237
|
+
const container = (_a = options.container) !== null && _a !== void 0 ? _a : document.body;
|
|
238
|
+
const containerRoot = container.getRootNode();
|
|
239
|
+
const returnFocusTo = (_b = themeSource === null || themeSource === void 0 ? void 0 : themeSource.closest('.ag-cell')) !== null && _b !== void 0 ? _b : null;
|
|
240
|
+
let closed = false;
|
|
241
|
+
const close = (restoreFocus = false) => {
|
|
242
|
+
if (closed) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
closed = true;
|
|
246
|
+
const focusWasInMenu = host.matches(':focus-within');
|
|
247
|
+
host.remove();
|
|
248
|
+
window.removeEventListener('mousedown', onPointerDownOutside);
|
|
249
|
+
window.removeEventListener('resize', onResize);
|
|
250
|
+
window.removeEventListener('scroll', onScroll, true);
|
|
251
|
+
if (containerRoot instanceof ShadowRoot) {
|
|
252
|
+
containerRoot.removeEventListener('scroll', onScroll, true);
|
|
253
|
+
}
|
|
254
|
+
window.removeEventListener('keydown', onKeyDown, true);
|
|
255
|
+
if (restoreFocus && focusWasInMenu) {
|
|
256
|
+
returnFocusTo === null || returnFocusTo === void 0 ? void 0 : returnFocusTo.focus({ preventScroll: true });
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const onPointerDownOutside = () => close();
|
|
260
|
+
const onResize = () => close();
|
|
261
|
+
// Scroll does not cross shadow roots, so a grid in a shadow root is watched there as well.
|
|
262
|
+
const onScroll = (event) => {
|
|
263
|
+
if (!event.composedPath().includes(host)) {
|
|
264
|
+
close();
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
const onKeyDown = (event) => {
|
|
268
|
+
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
269
|
+
event.preventDefault();
|
|
270
|
+
event.stopPropagation();
|
|
271
|
+
close(true);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
const menu = document.createElement(`${prefix}-menu`);
|
|
275
|
+
menu.classList.add('grid-context-menu');
|
|
276
|
+
appendMenuItems(prefix, menu, items, () => close(true));
|
|
277
|
+
shadow.append(menu);
|
|
278
|
+
container.appendChild(host);
|
|
279
|
+
showInTopLayer(host);
|
|
280
|
+
placeWithinViewport(host, x, y);
|
|
281
|
+
window.addEventListener('mousedown', onPointerDownOutside);
|
|
282
|
+
window.addEventListener('resize', onResize);
|
|
283
|
+
window.addEventListener('scroll', onScroll, true);
|
|
284
|
+
if (containerRoot instanceof ShadowRoot) {
|
|
285
|
+
containerRoot.addEventListener('scroll', onScroll, true);
|
|
286
|
+
}
|
|
287
|
+
window.addEventListener('keydown', onKeyDown, true);
|
|
288
|
+
// The menu collects its items on the next update; focusing it before then does nothing.
|
|
289
|
+
DOM.queueUpdate(() => {
|
|
290
|
+
if (!closed) {
|
|
291
|
+
menu.focus();
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
return () => close();
|
|
295
|
+
}
|
|
296
|
+
/** Overrides the user-agent popover box; `z-index` only matters where popovers are unsupported. */
|
|
297
|
+
const MENU_HOST_STYLE = 'position: fixed; inset: auto; margin: 0; padding: 0; border: 0; overflow: visible; ' +
|
|
298
|
+
'background: transparent; color: inherit; z-index: 10000;';
|
|
299
|
+
/**
|
|
300
|
+
* The top layer keeps the menu above dialogs and clear of transformed or clipping ancestors.
|
|
301
|
+
* Browsers without popovers fall back to the fixed, high z-index of {@link MENU_HOST_STYLE}.
|
|
302
|
+
*/
|
|
303
|
+
function showInTopLayer(host) {
|
|
304
|
+
if (typeof host.showPopover === 'function') {
|
|
305
|
+
host.popover = 'manual';
|
|
306
|
+
host.showPopover();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/** Opens at the pointer, flipping left or up where the menu would leave the viewport. */
|
|
310
|
+
function placeWithinViewport(host, x, y) {
|
|
311
|
+
host.style.left = `${x}px`;
|
|
312
|
+
host.style.top = `${y}px`;
|
|
313
|
+
const { width, height } = host.getBoundingClientRect();
|
|
314
|
+
if (x + width > window.innerWidth) {
|
|
315
|
+
host.style.left = `${Math.max(0, x - width)}px`;
|
|
316
|
+
}
|
|
317
|
+
if (y + height > window.innerHeight) {
|
|
318
|
+
host.style.top = `${Math.max(0, y - height)}px`;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function appendMenuItems(prefix, menu, items, close) {
|
|
322
|
+
var _a;
|
|
323
|
+
// Separators only go between items, so an empty spread does not leave a stray line.
|
|
324
|
+
const entries = items.filter((item, index) => item !== 'separator' || (index > 0 && items[index - 1] !== 'separator'));
|
|
325
|
+
while (entries[0] === 'separator')
|
|
326
|
+
entries.shift();
|
|
327
|
+
while (entries.at(-1) === 'separator')
|
|
328
|
+
entries.pop();
|
|
329
|
+
for (const item of entries) {
|
|
330
|
+
if (item === 'separator') {
|
|
331
|
+
const separator = document.createElement('div');
|
|
332
|
+
separator.setAttribute('role', 'separator');
|
|
333
|
+
separator.classList.add('grid-context-menu-separator');
|
|
334
|
+
menu.append(separator);
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
const menuItem = document.createElement(`${prefix}-menu-item`);
|
|
338
|
+
menuItem.classList.add('grid-context-menu-item');
|
|
339
|
+
menuItem.textContent = item.name;
|
|
340
|
+
if (item.tooltip) {
|
|
341
|
+
menuItem.title = item.tooltip;
|
|
342
|
+
}
|
|
343
|
+
if (item.checked !== undefined) {
|
|
344
|
+
menuItem.setAttribute('role', 'menuitemcheckbox');
|
|
345
|
+
if (item.checked) {
|
|
346
|
+
menuItem.setAttribute('checked', '');
|
|
347
|
+
// Neither design system draws a checkbox glyph of its own.
|
|
348
|
+
menuItem.append(menuIcon(prefix, 'checkbox-indicator', 'check'));
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (item.shortcut) {
|
|
352
|
+
const shortcut = document.createElement('span');
|
|
353
|
+
shortcut.slot = 'end';
|
|
354
|
+
shortcut.textContent = item.shortcut;
|
|
355
|
+
menuItem.append(shortcut);
|
|
356
|
+
}
|
|
357
|
+
if (item.disabled) {
|
|
358
|
+
menuItem.setAttribute('disabled', '');
|
|
359
|
+
}
|
|
360
|
+
const hasSubMenu = !!((_a = item.subMenu) === null || _a === void 0 ? void 0 : _a.length);
|
|
361
|
+
if (hasSubMenu) {
|
|
362
|
+
const subMenu = document.createElement(`${prefix}-menu`);
|
|
363
|
+
subMenu.slot = 'submenu';
|
|
364
|
+
subMenu.classList.add('grid-context-menu');
|
|
365
|
+
appendMenuItems(prefix, subMenu, item.subMenu, close);
|
|
366
|
+
menuItem.append(menuIcon(prefix, 'expand-collapse-indicator', 'chevron-right', 'chevron'), subMenu);
|
|
367
|
+
}
|
|
368
|
+
// `change` is what the menu item emits for a click, Enter or Space alike.
|
|
369
|
+
menuItem.addEventListener('change', (event) => {
|
|
370
|
+
var _a;
|
|
371
|
+
if (event.target !== menuItem || hasSubMenu || item.disabled) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
(_a = item.action) === null || _a === void 0 ? void 0 : _a.call(item);
|
|
375
|
+
close();
|
|
376
|
+
});
|
|
377
|
+
menu.append(menuItem);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defaultGridContextMenuItems, } from './context-menu';
|