Skip to content

Commit

Permalink
feat: migrate RowMoveManager Plugins to TypeScript (#817)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Jul 20, 2023
1 parent 40df1fd commit 8ad65ca
Show file tree
Hide file tree
Showing 9 changed files with 657 additions and 582 deletions.
4 changes: 4 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ import type { SlickCellExternalCopyManager } from './plugins/slick.cellexternalc
import type { SlickCellRangeDecorator } from './plugins/slick.cellrangedecorator';
import type { SlickCellRangeSelector } from './plugins/slick.cellrangeselector';
import type { SlickCellSelectionModel } from './plugins/slick.cellselectionmodel';
import type { SlickCrossGridRowMoveManager } from './plugins/slick.crossgridrowmovemanager';
import type { SlickDraggableGrouping } from './plugins/slick.draggablegrouping';
import type { SlickRowSelectionModel } from './plugins/slick.rowselectionmodel';
import type { SlickResizer } from './plugins/slick.resizer';
import type { SlickRowMoveManager } from './plugins/slick.rowmovemanager';
import type { SlickState } from './plugins/slick.state';
import type { SlickGroupItemMetadataProvider } from './slick.groupitemmetadataprovider';
import type { Draggable, MouseWheel, Resizable } from './slick.interactions';
Expand Down Expand Up @@ -66,6 +68,7 @@ declare global {
GridMenu: typeof SlickGridMenu,
Pager: typeof SlickGridPager
},
CrossGridRowMoveManager: SlickCrossGridRowMoveManager,
Data: {
Aggregators: typeof Aggregators,
DataView: typeof SlickDataView,
Expand Down Expand Up @@ -94,6 +97,7 @@ declare global {
preClickClassName: typeof preClickClassName,
Range: typeof SlickRange,
Resizable: typeof Resizable,
RowMoveManager: typeof SlickRowMoveManager,
RowSelectionMode: typeof RowSelectionMode,
RowSelectionModel: typeof SlickRowSelectionModel,
State: typeof SlickState,
Expand Down
1 change: 1 addition & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export * from './pagingInfo.interface';
export * from './plugin.interface';
export * from './positionMethod.type';
export * from './resizerOption.interface';
export * from './rowMoveManagerOption.interface';
export * from './rowSelectionModelOption.interface';
export * from './selectableOverrideCallback.interface';
export * from './singleColumnSort.interface';
Expand Down
67 changes: 67 additions & 0 deletions src/models/rowMoveManagerOption.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import type { SlickCellRangeSelector } from '../plugins/slick.cellrangeselector';
import type { UsabilityOverrideFn } from './usabilityOverrideFn.type';
import type { SlickGrid } from '../slick.grid';

export interface RowMoveManagerOption {
/**
* Defaults to True, do we want to disable auto-scroll feature (which comes from CellRangeSelector).
* NOTE: this flag has no effect when a `cellRangeSelector` is provided, you could however turn `autoScroll: false` inside the `cellRangeSelector`
*/
autoScrollWhenDrag?: boolean;

/** Defaults to false, option to cancel editing while dragging a row */
cancelEditOnDrag?: boolean;

/**
* Optional Cell Range Selector.
* NOTE: for an even simpler approach, we could use `enableCellRangeSelector` which the lib will take care of creating the instance by itself.
*/
cellRangeSelector?: SlickCellRangeSelector;

/** A CSS class to be added to the menu item container. */
cssClass?: string;

/** Column definition id(defaults to "_move") */
columnId?: string;

/**
* Defaults to 0, the column index position in the grid by default it will show as the first column (index 0).
* Also note that the index position might vary if you use other extensions, after each extension is created,
* it will add an offset to take into consideration (1.CheckboxSelector, 2.RowDetail, 3.RowMove)
*/
columnIndexPosition?: number;

/** Defaults to False, do we want to disable the row selection? */
disableRowSelection?: boolean;

/** Defaults to False, should we select when dragging? */
dragToSelect?: boolean;

/** Defaults to True, do we want to hide the row move shadow of what we're dragging? */
hideRowMoveShadow?: boolean;

/** Defaults to 0, optional left margin of the row move shadown element when enabled */
rowMoveShadowMarginLeft?: number | string;

/** Defaults to 0, optional top margin of the row move shadown element when enabled */
rowMoveShadowMarginTop?: number | string;

/** Defaults to 0.9, opacity of row move shadow element (requires shadow to be shown via option: `hideRowMoveShadow: false`) */
rowMoveShadowOpacity?: number | string;

/** Defaults to 0.75, scale size of row move shadow element (requires shadow to be shown via option: `hideRowMoveShadow: false`) */
rowMoveShadowScale?: number | string;

/** Defaults to False, do we want a single row move? Setting this to false means that 1 or more rows can be selected to move together. */
singleRowMove?: boolean;

/** Width of the column in pixels (must be a number) */
width?: number;

/** Override the logic for showing (or not) the move icon (use case example: only every 2nd row is moveable) */
usabilityOverride?: UsabilityOverrideFn;
}

export interface CrossGridRowMoveManagerOption extends RowMoveManagerOption {
toGrid: SlickGrid;
}
Loading

0 comments on commit 8ad65ca

Please sign in to comment.