-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: reconcile menu into base class & reuse few fn
- Loading branch information
1 parent
4243ead
commit 5bda236
Showing
32 changed files
with
1,002 additions
and
1,154 deletions.
There are no files selected for viewing
204 changes: 104 additions & 100 deletions
204
packages/common/src/controls/__tests__/gridMenuControl.spec.ts
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/common/src/interfaces/gridMenuCommandItemCallbackArgs.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,16 @@ | ||
import { Column } from './column.interface'; | ||
import { GridMenuCommandItemCallbackArgs } from './gridMenuCommandItemCallbackArgs.interface'; | ||
import { SlickGrid } from './slickGrid.interface'; | ||
|
||
export interface GridMenuItem { | ||
/** A command identifier to be passed to the onCommand event callback handlers. */ | ||
command: string; | ||
|
||
/** A CSS class to be added to the menu item container. */ | ||
cssClass?: string; | ||
|
||
/** Defaults to false, whether the item/command is disabled. */ | ||
disabled?: boolean; | ||
|
||
/** Defaults to false, whether the item/command is hidden. */ | ||
hidden?: boolean; | ||
|
||
/** Defaults to false, whether the command is actually a divider (separator). */ | ||
divider?: boolean; | ||
|
||
/** CSS class to be added to the menu item icon. */ | ||
iconCssClass?: string; | ||
|
||
/** | ||
* @deprecated @use `iconCssClass` | ||
* URL pointing to the icon image. | ||
*/ | ||
iconImage?: string; | ||
|
||
/** position order in the list, a lower number will make it on top of the list. Internal commands starts at 50. */ | ||
positionOrder?: number; | ||
|
||
/** CSS class to be added to the menu item text. */ | ||
textCssClass?: string; | ||
|
||
/** Menu item text to show in the list. */ | ||
title?: string; | ||
|
||
/** Same as "title", except that it's a translation key which can be used on page load and/or when switching locale */ | ||
titleKey?: string; | ||
|
||
/** Item tooltip to show while hovering the command. */ | ||
tooltip?: string; | ||
import { GridMenuCallbackArgs, GridMenuCommandItemCallbackArgs } from './gridMenuCommandItemCallbackArgs.interface'; | ||
import { MenuCommandItem } from './menuCommandItem.interface'; | ||
|
||
export interface GridMenuItem extends MenuCommandItem<GridMenuCommandItemCallbackArgs, GridMenuCallbackArgs> { | ||
// -- | ||
// action/override callbacks | ||
|
||
/** Optionally define a callback function that gets executed when item is chosen (and/or use the onCommand event) */ | ||
action?: (event: Event, callbackArgs: GridMenuCommandItemCallbackArgs) => void; | ||
|
||
/** Callback method that user can override the default behavior of showing/hiding an item from the list. */ | ||
itemVisibilityOverride?: (args: { grid: SlickGrid; menu: any; columns: Column[]; visibleColumns: Column[] }) => boolean; | ||
itemVisibilityOverride?: (args: GridMenuCallbackArgs) => boolean; | ||
|
||
/** Callback method that user can override the default behavior of enabling/disabling an item from the list. */ | ||
itemUsabilityOverride?: (args: { grid: SlickGrid; menu: any; columns: Column[]; visibleColumns: Column[] }) => boolean; | ||
itemUsabilityOverride?: (args: GridMenuCallbackArgs) => boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import { MenuItem } from './menuItem.interface'; | ||
import { MenuCommandItemCallbackArgs } from './menuCommandItemCallbackArgs.interface'; | ||
import { SlickEventData } from './slickEventData.interface'; | ||
import { MenuCallbackArgs } from './menuCallbackArgs.interface'; | ||
|
||
export interface MenuCommandItem extends MenuItem { | ||
export interface MenuCommandItem<A = MenuCommandItemCallbackArgs, R = MenuCallbackArgs> extends MenuItem<R> { | ||
/** A command identifier to be passed to the onCommand event callback handler (when using "commandItems"). */ | ||
command: string; | ||
|
||
// -- | ||
// action/override callbacks | ||
|
||
/** Optionally define a callback function that gets executed when item is chosen (and/or use the onCommand event) */ | ||
action?: (event: SlickEventData | Event, callbackArgs: MenuCommandItemCallbackArgs) => void; | ||
action?: (event: SlickEventData | Event, callbackArgs: A) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.