@toolbox-web/grid 1.1.2 → 1.3.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/README.md +80 -22
- package/all.d.ts +1 -0
- package/all.d.ts.map +1 -1
- package/all.js +557 -365
- package/all.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +903 -769
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +102 -3
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/row-animation.d.ts +37 -0
- package/lib/core/internal/row-animation.d.ts.map +1 -0
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +65 -3
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/index.d.ts +1 -1
- package/lib/core/plugin/index.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +25 -1
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +62 -0
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +64 -1
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +73 -69
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +1 -0
- package/lib/plugins/clipboard/types.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +69 -40
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +14 -12
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/RowReorderPlugin.d.ts +155 -0
- package/lib/plugins/row-reorder/RowReorderPlugin.d.ts.map +1 -0
- package/lib/plugins/row-reorder/index.d.ts +9 -0
- package/lib/plugins/row-reorder/index.d.ts.map +1 -0
- package/lib/plugins/row-reorder/index.js +597 -0
- package/lib/plugins/row-reorder/index.js.map +1 -0
- package/lib/plugins/row-reorder/types.d.ts +80 -0
- package/lib/plugins/row-reorder/types.d.ts.map +1 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts +13 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.d.ts +1 -1
- package/lib/plugins/selection/index.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +95 -64
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +50 -6
- package/lib/plugins/selection/types.d.ts.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +21 -4
- package/public.d.ts +15 -2
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +23 -23
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -15
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +5 -5
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/row-reorder.umd.js +2 -0
- package/umd/plugins/row-reorder.umd.js.map +1 -0
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { BaseGridPlugin } from '../../core/plugin/base-plugin';
|
|
2
|
+
import { ColumnConfig } from '../../core/types';
|
|
3
|
+
import { RowReorderConfig } from './types';
|
|
4
|
+
/** Field name for the drag handle column */
|
|
5
|
+
export declare const ROW_DRAG_HANDLE_FIELD = "__tbw_row_drag";
|
|
6
|
+
/**
|
|
7
|
+
* Row Reorder Plugin for tbw-grid
|
|
8
|
+
*
|
|
9
|
+
* Enables row reordering via keyboard shortcuts (Ctrl+Up/Down) and drag-drop.
|
|
10
|
+
* Supports validation callbacks and debounced keyboard moves.
|
|
11
|
+
*
|
|
12
|
+
* ## Installation
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { RowReorderPlugin } from '@toolbox-web/grid/plugins/row-reorder';
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* ## Configuration Options
|
|
19
|
+
*
|
|
20
|
+
* | Option | Type | Default | Description |
|
|
21
|
+
* |--------|------|---------|-------------|
|
|
22
|
+
* | `enableKeyboard` | `boolean` | `true` | Enable Ctrl+Up/Down shortcuts |
|
|
23
|
+
* | `showDragHandle` | `boolean` | `true` | Show drag handle column |
|
|
24
|
+
* | `dragHandlePosition` | `'left' \| 'right'` | `'left'` | Drag handle column position |
|
|
25
|
+
* | `dragHandleWidth` | `number` | `40` | Drag handle column width |
|
|
26
|
+
* | `canMove` | `function` | - | Validation callback |
|
|
27
|
+
* | `debounceMs` | `number` | `300` | Debounce time for keyboard moves |
|
|
28
|
+
* | `animation` | `false \| 'flip'` | `'flip'` | Animation for row moves |
|
|
29
|
+
*
|
|
30
|
+
* ## Keyboard Shortcuts
|
|
31
|
+
*
|
|
32
|
+
* | Key | Action |
|
|
33
|
+
* |-----|--------|
|
|
34
|
+
* | `Ctrl + ↑` | Move focused row up |
|
|
35
|
+
* | `Ctrl + ↓` | Move focused row down |
|
|
36
|
+
*
|
|
37
|
+
* ## Events
|
|
38
|
+
*
|
|
39
|
+
* | Event | Detail | Cancelable | Description |
|
|
40
|
+
* |-------|--------|------------|-------------|
|
|
41
|
+
* | `row-move` | `RowMoveDetail` | Yes | Fired when a row move is attempted |
|
|
42
|
+
*
|
|
43
|
+
* @example Basic Row Reordering
|
|
44
|
+
* ```ts
|
|
45
|
+
* import '@toolbox-web/grid';
|
|
46
|
+
* import { RowReorderPlugin } from '@toolbox-web/grid/plugins/row-reorder';
|
|
47
|
+
*
|
|
48
|
+
* const grid = document.querySelector('tbw-grid');
|
|
49
|
+
* grid.gridConfig = {
|
|
50
|
+
* columns: [
|
|
51
|
+
* { field: 'id', header: 'ID' },
|
|
52
|
+
* { field: 'name', header: 'Name' },
|
|
53
|
+
* ],
|
|
54
|
+
* plugins: [new RowReorderPlugin()],
|
|
55
|
+
* };
|
|
56
|
+
*
|
|
57
|
+
* grid.addEventListener('row-move', (e) => {
|
|
58
|
+
* console.log('Row moved from', e.detail.fromIndex, 'to', e.detail.toIndex);
|
|
59
|
+
* });
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @example With Validation
|
|
63
|
+
* ```ts
|
|
64
|
+
* new RowReorderPlugin({
|
|
65
|
+
* canMove: (row, fromIndex, toIndex, direction) => {
|
|
66
|
+
* // Prevent moving locked rows
|
|
67
|
+
* return !row.locked;
|
|
68
|
+
* },
|
|
69
|
+
* })
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @see {@link RowReorderConfig} for all configuration options
|
|
73
|
+
* @see {@link RowMoveDetail} for the event detail structure
|
|
74
|
+
*/
|
|
75
|
+
export declare class RowReorderPlugin extends BaseGridPlugin<RowReorderConfig> {
|
|
76
|
+
/** @internal */
|
|
77
|
+
readonly name = "rowReorder";
|
|
78
|
+
/** @internal */
|
|
79
|
+
readonly styles: string;
|
|
80
|
+
/** @internal */
|
|
81
|
+
protected get defaultConfig(): Partial<RowReorderConfig>;
|
|
82
|
+
private isDragging;
|
|
83
|
+
private draggedRowIndex;
|
|
84
|
+
private dropRowIndex;
|
|
85
|
+
private pendingMove;
|
|
86
|
+
private debounceTimer;
|
|
87
|
+
/** Column index to use when flushing pending move */
|
|
88
|
+
private lastFocusCol;
|
|
89
|
+
/** @internal */
|
|
90
|
+
detach(): void;
|
|
91
|
+
/** @internal */
|
|
92
|
+
processColumns(columns: readonly ColumnConfig[]): ColumnConfig[];
|
|
93
|
+
/** @internal */
|
|
94
|
+
afterRender(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Handle Ctrl+Arrow keyboard shortcuts for row reordering.
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
onKeyDown(event: KeyboardEvent): boolean | void;
|
|
100
|
+
/**
|
|
101
|
+
* Flush pending keyboard moves when user clicks a cell.
|
|
102
|
+
* This commits the move immediately so focus works correctly.
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
onCellClick(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Move a row to a new position programmatically.
|
|
108
|
+
* @param fromIndex - Current index of the row
|
|
109
|
+
* @param toIndex - Target index
|
|
110
|
+
*/
|
|
111
|
+
moveRow(fromIndex: number, toIndex: number): void;
|
|
112
|
+
/**
|
|
113
|
+
* Check if a row can be moved to a position.
|
|
114
|
+
* @param fromIndex - Current index of the row
|
|
115
|
+
* @param toIndex - Target index
|
|
116
|
+
*/
|
|
117
|
+
canMoveRow(fromIndex: number, toIndex: number): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Set up drag start/end listeners on the drag handle element.
|
|
120
|
+
*/
|
|
121
|
+
private setupHandleDragListeners;
|
|
122
|
+
/**
|
|
123
|
+
* Set up drop target listeners on a row element.
|
|
124
|
+
* All rows are valid drop targets during drag operations.
|
|
125
|
+
*/
|
|
126
|
+
private setupRowDropListeners;
|
|
127
|
+
/**
|
|
128
|
+
* Handle debounced keyboard moves.
|
|
129
|
+
* Rows move immediately for visual feedback, but the event emission is debounced.
|
|
130
|
+
*/
|
|
131
|
+
private handleKeyboardMove;
|
|
132
|
+
/**
|
|
133
|
+
* Flush the pending move by emitting the event.
|
|
134
|
+
* Called when debounce timer fires or user clicks elsewhere.
|
|
135
|
+
*/
|
|
136
|
+
private flushPendingMove;
|
|
137
|
+
/**
|
|
138
|
+
* Execute a row move and emit the event.
|
|
139
|
+
*/
|
|
140
|
+
private executeMove;
|
|
141
|
+
/**
|
|
142
|
+
* Get the row index from a row element by checking data-row attribute on cells.
|
|
143
|
+
* This is consistent with how other plugins retrieve row indices.
|
|
144
|
+
*/
|
|
145
|
+
private getRowIndex;
|
|
146
|
+
/**
|
|
147
|
+
* Clear all drag-related classes from rows.
|
|
148
|
+
*/
|
|
149
|
+
private clearDragClasses;
|
|
150
|
+
/**
|
|
151
|
+
* Clear the debounce timer.
|
|
152
|
+
*/
|
|
153
|
+
private clearDebounceTimer;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=RowReorderPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowReorderPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/row-reorder/RowReorderPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,kBAAkB,CAAC;AAEnE,OAAO,KAAK,EAA8B,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE5E,4CAA4C;AAC5C,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,gBAAiB,SAAQ,cAAc,CAAC,gBAAgB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|
|
3
|
+
* Re-exports plugin class and types for tree-shakeable imports.
|
|
4
|
+
*
|
|
5
|
+
* @module Plugins/Row-Reorder
|
|
6
|
+
*/
|
|
7
|
+
export { ROW_DRAG_HANDLE_FIELD, RowReorderPlugin } from './RowReorderPlugin';
|
|
8
|
+
export type { PendingMove, RowMoveDetail, RowReorderConfig } from './types';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/row-reorder/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|