@universal-ember/table 3.2.0 → 3.4.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/declarations/-private/column.d.ts.map +1 -1
- package/declarations/-private/interfaces/table.d.ts +13 -0
- package/declarations/-private/interfaces/table.d.ts.map +1 -1
- package/declarations/plugins/column-reordering/helpers.d.ts +20 -1
- package/declarations/plugins/column-reordering/helpers.d.ts.map +1 -1
- package/declarations/plugins/column-reordering/plugin.d.ts +12 -12
- package/declarations/plugins/column-reordering/plugin.d.ts.map +1 -1
- package/declarations/plugins/column-resizing/helpers.d.ts +5 -0
- package/declarations/plugins/column-resizing/helpers.d.ts.map +1 -1
- package/declarations/plugins/column-resizing/plugin.d.ts.map +1 -1
- package/dist/-private/column.js +4 -4
- package/dist/-private/column.js.map +1 -1
- package/dist/plugins/column-reordering/helpers.js +33 -2
- package/dist/plugins/column-reordering/helpers.js.map +1 -1
- package/dist/plugins/column-reordering/index.js +1 -1
- package/dist/plugins/column-reordering/plugin.js +7 -2
- package/dist/plugins/column-reordering/plugin.js.map +1 -1
- package/dist/plugins/column-resizing/helpers.js +7 -1
- package/dist/plugins/column-resizing/helpers.js.map +1 -1
- package/dist/plugins/column-resizing/index.js +1 -1
- package/dist/plugins/column-resizing/plugin.js +19 -5
- package/dist/plugins/column-resizing/plugin.js.map +1 -1
- package/package.json +1 -1
- package/src/-private/column.ts +5 -1
- package/src/-private/interfaces/table.ts +14 -0
- package/src/plugins/column-reordering/helpers.ts +42 -3
- package/src/plugins/column-reordering/plugin.ts +28 -32
- package/src/plugins/column-resizing/helpers.ts +7 -0
- package/src/plugins/column-resizing/plugin.ts +23 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../../src/-private/column.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE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OAAO,CAAC,eAAe;IAKvB,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;;;CAY7B"}
|
|
@@ -77,6 +77,19 @@ export interface TableConfig<DataType> {
|
|
|
77
77
|
onRowSelectionChange?: (selection: DataType | undefined) => void;
|
|
78
78
|
meta?: TableMeta;
|
|
79
79
|
pagination?: Pagination;
|
|
80
|
+
/**
|
|
81
|
+
* Default value to display in cells when the data is empty/missing.
|
|
82
|
+
* If not specified, defaults to '--'.
|
|
83
|
+
*
|
|
84
|
+
* Can be overridden per-column via the column's options.defaultValue.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```js
|
|
88
|
+
* defaultCellValue: '' // show empty string instead of '--'
|
|
89
|
+
* defaultCellValue: 'N/A' // show 'N/A'
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
defaultCellValue?: string;
|
|
80
93
|
/**
|
|
81
94
|
* Foundational to tables is how to store settings within them.
|
|
82
95
|
* The `key` is meant to identify a particular kind of table. For example, if
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/-private/interfaces/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,SAAS;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,WAAW,CAAC,QAAQ;IACnC;;;;OAIG;IACH,OAAO,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC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E,CAAC;IACxC;;;;;;;OAOG;IACH,IAAI,EAAE,MAAM,QAAQ,EAAE,CAAC;IAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAKlB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAI/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,QAAQ,CAAC;IAC9B,oBAAoB,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IAGjE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE;QACZ;;;;;;;WAOG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;;;;;;WAOG;QACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;KAC9B,CAAC;CACH"}
|
|
@@ -13,7 +13,7 @@ export declare const moveRight: <DataType = unknown>(column: Column<DataType>) =
|
|
|
13
13
|
/**
|
|
14
14
|
* Override all column positions at once.
|
|
15
15
|
*/
|
|
16
|
-
export declare const setColumnOrder: <DataType = unknown>(table: Table<DataType>, order: ColumnOrder) => void;
|
|
16
|
+
export declare const setColumnOrder: <DataType = unknown>(table: Table<DataType>, order: ColumnOrder<DataType>) => void;
|
|
17
17
|
/**
|
|
18
18
|
* Ask if the column cannot move to the left
|
|
19
19
|
*/
|
|
@@ -32,4 +32,23 @@ export declare const canMoveLeft: <DataType = unknown>(column: Column<DataType>)
|
|
|
32
32
|
* (If your plugin doesn't expose `canMoveRight`, use `!cannotMoveRight`.)
|
|
33
33
|
*/
|
|
34
34
|
export declare const canMoveRight: <DataType = unknown>(column: Column<DataType>) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get the columns in their current display order.
|
|
37
|
+
*
|
|
38
|
+
* This returns an array of columns sorted according to any reordering
|
|
39
|
+
* that has been applied via the ColumnReordering plugin. If no reordering
|
|
40
|
+
* has been applied, columns are returned in their original order.
|
|
41
|
+
*
|
|
42
|
+
* @param table - The table instance to get ordered columns from
|
|
43
|
+
* @returns Array of columns in their current display order
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { orderedColumnsFor } from '@universal-ember/table/plugins/column-reordering';
|
|
48
|
+
*
|
|
49
|
+
* const columns = orderedColumnsFor(table);
|
|
50
|
+
* // Use the ordered columns for rendering or other operations
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const orderedColumnsFor: <DataType = unknown>(table: Table<DataType>) => Column<DataType>[];
|
|
35
54
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/plugins/column-reordering/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/plugins/column-reordering/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,QAAQ,GAAG,OAAO,EAAE,QAAQ,MAAM,CAAC,QAAQ,CAAC,SAChB,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,GAAG,OAAO,EAAE,QAAQ,MAAM,CAAC,QAAQ,CAAC,SAChB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,GAAG,OAAO,EAC/C,OAAO,KAAK,CAAC,QAAQ,CAAC,EACtB,OAAO,WAAW,CAAC,QAAQ,CAAC,SAS7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,GAAG,OAAO,EAAE,QAAQ,MAAM,CAAC,QAAQ,CAAC,YAClB,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,GAAG,OAAO,EAAE,QAAQ,MAAM,CAAC,QAAQ,CAAC,YAClB,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,GAAG,OAAO,EAAE,QAAQ,MAAM,CAAC,QAAQ,CAAC,YAGd,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,GAAG,OAAO,EAAE,QAAQ,MAAM,CAAC,QAAQ,CAAC,YAGd,CAAC;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,GAAG,OAAO,EAClD,OAAO,KAAK,CAAC,QAAQ,CAAC,KACrB,MAAM,CAAC,QAAQ,CAAC,EASlB,CAAC"}
|
|
@@ -29,10 +29,10 @@ export declare class ColumnReordering extends BasePlugin<Signature> {
|
|
|
29
29
|
reset(): void;
|
|
30
30
|
get columns(): Column<unknown>[];
|
|
31
31
|
}
|
|
32
|
-
export declare class ColumnMeta {
|
|
32
|
+
export declare class ColumnMeta<DataType = unknown> {
|
|
33
33
|
#private;
|
|
34
34
|
private column;
|
|
35
|
-
constructor(column: Column);
|
|
35
|
+
constructor(column: Column<DataType>);
|
|
36
36
|
get position(): number;
|
|
37
37
|
set position(value: number);
|
|
38
38
|
get canMoveLeft(): boolean;
|
|
@@ -48,9 +48,9 @@ export declare class ColumnMeta {
|
|
|
48
48
|
*/
|
|
49
49
|
moveRight: () => void;
|
|
50
50
|
}
|
|
51
|
-
export declare class TableMeta {
|
|
51
|
+
export declare class TableMeta<DataType = unknown> {
|
|
52
52
|
private table;
|
|
53
|
-
constructor(table: Table);
|
|
53
|
+
constructor(table: Table<DataType>);
|
|
54
54
|
/**
|
|
55
55
|
* @private
|
|
56
56
|
*
|
|
@@ -59,19 +59,19 @@ export declare class TableMeta {
|
|
|
59
59
|
* When they do this, we want to maintain the order of the table, best we can.
|
|
60
60
|
* This is also why the order of the columns is maintained via column key
|
|
61
61
|
*/
|
|
62
|
-
columnOrder: ColumnOrder
|
|
62
|
+
columnOrder: ColumnOrder<DataType>;
|
|
63
63
|
/**
|
|
64
64
|
* Get the curret order/position of a column
|
|
65
65
|
*/
|
|
66
|
-
getPosition
|
|
66
|
+
getPosition(column: Column<DataType>): number;
|
|
67
67
|
/**
|
|
68
68
|
* Swap the column with the column at `newPosition`
|
|
69
69
|
*/
|
|
70
|
-
setPosition
|
|
70
|
+
setPosition(column: Column<DataType>, newPosition: number): false | undefined;
|
|
71
71
|
/**
|
|
72
72
|
* Using a `ColumnOrder` instance, set the order of all columns
|
|
73
73
|
*/
|
|
74
|
-
setOrder: (order: ColumnOrder) => void;
|
|
74
|
+
setOrder: (order: ColumnOrder<DataType>) => void;
|
|
75
75
|
/**
|
|
76
76
|
* Revert to default config, delete preferences,
|
|
77
77
|
* and clear the columnOrder
|
|
@@ -85,7 +85,7 @@ export declare class TableMeta {
|
|
|
85
85
|
* @private
|
|
86
86
|
*/
|
|
87
87
|
private read;
|
|
88
|
-
get columns(): Column<
|
|
88
|
+
get columns(): Column<DataType>[];
|
|
89
89
|
/**
|
|
90
90
|
* @private
|
|
91
91
|
* This isn't our data to expose, but it is useful to alias
|
|
@@ -97,7 +97,7 @@ export declare class TableMeta {
|
|
|
97
97
|
* @private
|
|
98
98
|
* Used for keeping track of and updating column order
|
|
99
99
|
*/
|
|
100
|
-
export declare class ColumnOrder {
|
|
100
|
+
export declare class ColumnOrder<DataType = unknown> {
|
|
101
101
|
private args;
|
|
102
102
|
/**
|
|
103
103
|
* This map will be empty until we re-order something.
|
|
@@ -116,7 +116,7 @@ export declare class ColumnOrder {
|
|
|
116
116
|
* - Provide `visibleColumns` to indicate which are visible
|
|
117
117
|
* - Hidden columns maintain their position when toggled
|
|
118
118
|
*/
|
|
119
|
-
columns: () => Column[];
|
|
119
|
+
columns: () => Column<DataType>[];
|
|
120
120
|
/**
|
|
121
121
|
* Optional: Record of which columns are currently visible.
|
|
122
122
|
* When provided, moveLeft/moveRight will skip over hidden columns.
|
|
@@ -171,7 +171,7 @@ export declare class ColumnOrder {
|
|
|
171
171
|
* The same as this.map, but with all the columns' information
|
|
172
172
|
*/
|
|
173
173
|
get orderedMap(): ReadonlyMap<string, number>;
|
|
174
|
-
get orderedColumns(): Column[];
|
|
174
|
+
get orderedColumns(): Column<DataType>[];
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
177
|
* @private
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/column-reordering/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,EAAE,UAAU,EAAiB,MAAM,qBAAqB,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEpD,UAAU,2BAA4B,SAAQ,iBAAiB;IAC7D,KAAK,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;CACH;AAED,OAAO,QAAQ,gCAAgC,CAAC;IAC9C,UAAU,QAAQ;QAChB,gBAAgB,CAAC,EAAE,2BAA2B,CAAC;QAC/C,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;KACnD;CACF;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE;QACJ,MAAM,EAAE,UAAU,CAAC;QACnB,KAAK,EAAE,SAAS,CAAC;KAClB,CAAC;CACH;AAED,q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AAM,CAAC,KAAK,IAAI,CAAC;QAC5C;;WAEG;QACH,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACrC;IAeH;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAezB;;;;;;OAMG;IAEH,QAAQ,CAAC,GAAG,EAAE,MAAM;IAsCpB,MAAM,GAAI,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,UAahC;IAEF;;;;;;OAMG;IAEH,SAAS,CAAC,GAAG,EAAE,MAAM;IAkCrB;;OAEG;IAEH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IA0EtC,GAAG,CAAC,GAAG,EAAE,MAAM;IAYf;;OAEG;IACH,IACI,UAAU,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAE5C;IAED,IACI,cAAc,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CA4BvC;CACF;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CACrB,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,EAC1B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBrB"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { htmlSafe } from '@ember/template';
|
|
2
2
|
import type { Column } from '../../index.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Is the column resizable?
|
|
5
|
+
* This checks if resizing is enabled for this specific column,
|
|
6
|
+
*/
|
|
7
|
+
export declare const isResizable: <DataType = unknown>(column: Column<DataType>) => boolean;
|
|
3
8
|
/**
|
|
4
9
|
* The column actively being resized by the user.
|
|
5
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/plugins/column-resizing/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,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SAAS,gBAEZ;IAED,IAAI,YAAY,WAEf;IAED,IAAI,WAAW,YAEd;IAED,IAAI,eAAe,YAgBlB;IAED,IAAI,KAAK,WAYR;IAED,IAAI,KAAK,CAAC,KAAK,QAAA,EAEd;IAED,IAAI,KAAK,6DAOR;IAGD,MAAM,CAAC,KAAK,EAAE,MAAM;IAKpB,IAAI;CAGL;AAkCD;;;;GAIG;AACH,qBAAa,SAAS;;IACR,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,KAAK;IAEvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAEvC,IAAI,OAAO,0BAEV;IAED,IAAI,WAAW,YAEd;IAED,IAAI,kBAAkB,uBAOrB;IAMD,IAAI,kBAAkB,iBAIrB;IAED,IAAI,wBAAwB,WAK3B;IAED,IAAI,0BAA0B,iBAE7B;IAED,IAAI,wBAAwB,WAK3B;IAGD,aAAa,CAAC,kBAAkB,EAAE,UAAU,EAAE;IAc9C,KAAK;IASL,aAAa,CAAC,KAAK,EAAE,mBAAmB;IAyBxC,YAAY,CAAC,QAAQ,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM;CAkGzE;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,cAQzD"}
|
package/dist/-private/column.js
CHANGED
|
@@ -5,9 +5,6 @@ import { isEmpty } from '@ember/utils';
|
|
|
5
5
|
var _class;
|
|
6
6
|
const DEFAULT_VALUE = '--';
|
|
7
7
|
const DEFAULT_VALUE_KEY = 'defaultValue';
|
|
8
|
-
const DEFAULT_OPTIONS = {
|
|
9
|
-
[DEFAULT_VALUE_KEY]: DEFAULT_VALUE
|
|
10
|
-
};
|
|
11
8
|
let Column = (_class = class Column {
|
|
12
9
|
get Cell() {
|
|
13
10
|
return this.config.Cell;
|
|
@@ -47,7 +44,10 @@ let Column = (_class = class Column {
|
|
|
47
44
|
return this.getOptionsForRow(row)[DEFAULT_VALUE_KEY];
|
|
48
45
|
}
|
|
49
46
|
getOptionsForRow(row) {
|
|
50
|
-
const
|
|
47
|
+
const configuredDefault = this.table.config.defaultCellValue;
|
|
48
|
+
const defaults = {
|
|
49
|
+
[DEFAULT_VALUE_KEY]: configuredDefault !== undefined ? configuredDefault : DEFAULT_VALUE
|
|
50
|
+
};
|
|
51
51
|
return {
|
|
52
52
|
...defaults,
|
|
53
53
|
...this.config.options?.({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column.js","sources":["../../src/-private/column.ts"],"sourcesContent":["import { action, get } from '@ember/object';\nimport { isEmpty } from '@ember/utils';\n\nimport type { Row } from './row';\nimport type { Table } from './table';\nimport type { ContentValue } from '@glint/template';\nimport type { ColumnConfig } from './interfaces';\n\nconst DEFAULT_VALUE = '--';\nconst DEFAULT_VALUE_KEY = 'defaultValue';\nconst DEFAULT_OPTIONS = {\n [DEFAULT_VALUE_KEY]: DEFAULT_VALUE,\n};\n\nexport class Column<T = unknown> {\n get Cell() {\n return this.config.Cell;\n }\n\n get key() {\n return this.config.key;\n }\n\n get name() {\n return this.config.name;\n }\n\n constructor(\n public table: Table<T>,\n public config: ColumnConfig<T>,\n ) {}\n\n @action\n getValueForRow(row: Row<T>): ContentValue {\n if (this.config.value) {\n return this.config.value({ column: this, row });\n }\n\n // Cast here, because ember get's types do not support nested keys\n // even though the real implementation does\n const value = get(row.data, this.config.key);\n\n if (isEmpty(value)) {\n return this.getDefaultValue(row);\n }\n\n /**\n * UNSAFE: casting to ContentValue is incorrect, because we have not\n * properly constrained the type of value, (isEmpty doesn't narrow types either)\n */\n return value as ContentValue;\n }\n\n private getDefaultValue(row: Row<T>) {\n return this.getOptionsForRow(row)[DEFAULT_VALUE_KEY];\n }\n\n @action\n getOptionsForRow(row: Row<T>) {\n const defaults =
|
|
1
|
+
{"version":3,"file":"column.js","sources":["../../src/-private/column.ts"],"sourcesContent":["import { action, get } from '@ember/object';\nimport { isEmpty } from '@ember/utils';\n\nimport type { Row } from './row';\nimport type { Table } from './table';\nimport type { ContentValue } from '@glint/template';\nimport type { ColumnConfig } from './interfaces';\n\nconst DEFAULT_VALUE = '--';\nconst DEFAULT_VALUE_KEY = 'defaultValue';\nconst DEFAULT_OPTIONS = {\n [DEFAULT_VALUE_KEY]: DEFAULT_VALUE,\n};\n\nexport class Column<T = unknown> {\n get Cell() {\n return this.config.Cell;\n }\n\n get key() {\n return this.config.key;\n }\n\n get name() {\n return this.config.name;\n }\n\n constructor(\n public table: Table<T>,\n public config: ColumnConfig<T>,\n ) {}\n\n @action\n getValueForRow(row: Row<T>): ContentValue {\n if (this.config.value) {\n return this.config.value({ column: this, row });\n }\n\n // Cast here, because ember get's types do not support nested keys\n // even though the real implementation does\n const value = get(row.data, this.config.key);\n\n if (isEmpty(value)) {\n return this.getDefaultValue(row);\n }\n\n /**\n * UNSAFE: casting to ContentValue is incorrect, because we have not\n * properly constrained the type of value, (isEmpty doesn't narrow types either)\n */\n return value as ContentValue;\n }\n\n private getDefaultValue(row: Row<T>) {\n return this.getOptionsForRow(row)[DEFAULT_VALUE_KEY];\n }\n\n @action\n getOptionsForRow(row: Row<T>) {\n const configuredDefault = this.table.config.defaultCellValue;\n const defaults = {\n [DEFAULT_VALUE_KEY]:\n configuredDefault !== undefined ? configuredDefault : DEFAULT_VALUE,\n };\n\n return {\n ...defaults,\n ...this.config.options?.({ column: this, row }),\n };\n }\n}\n"],"names":["DEFAULT_VALUE","DEFAULT_VALUE_KEY","Column","_class","Cell","config","key","name","constructor","table","getValueForRow","row","value","column","get","data","isEmpty","getDefaultValue","getOptionsForRow","configuredDefault","defaultCellValue","defaults","undefined","options","_applyDecoratedDescriptor","prototype","action","Object","getOwnPropertyDescriptor"],"mappings":";;;;;AAQA,MAAMA,aAAa,GAAG,IAAI;AAC1B,MAAMC,iBAAiB,GAAG,cAAc;AAKxC,IAAaC,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S,GAAGH,iBAAiB,GAAGnB;KACzD;IAED,OAAO;AACL,MAAA,GAAGqB,QAAQ;AACX,MAAA,GAAG,IAAI,CAAChB,MAAM,CAACkB,OAAO,GAAG;AAAEV,QAAAA,MAAM,EAAE,IAAI;AAAEF,QAAAA;OAAK;KAC/C;AACH;AACF,CAAC,EAAAa,yBAAA,CAAArB,MAAA,CAAAsB,SAAA,qBAtCEC,MAAM,CAAA,EAAAC,MAAA,CAAAC,wBAAA,CAAAzB,MAAA,CAAAsB,SAAA,EAAA,gBAAA,CAAA,EAAAtB,MAAA,CAAAsB,SAAA,CAAAD,EAAAA,yBAAA,CAAArB,MAAA,CAAAsB,SAAA,EAyBNC,kBAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAzB,MAAA,CAAAsB,SAAA,EAAA,kBAAA,CAAA,EAAAtB,MAAA,CAAAsB,SAAA,GAAAtB,MAAA;;;;"}
|
|
@@ -16,7 +16,12 @@ const moveRight = column => meta.forColumn(column, ColumnReordering).moveRight()
|
|
|
16
16
|
/**
|
|
17
17
|
* Override all column positions at once.
|
|
18
18
|
*/
|
|
19
|
-
const setColumnOrder = (table, order) =>
|
|
19
|
+
const setColumnOrder = (table, order) => {
|
|
20
|
+
// Note: The meta.forTable API doesn't preserve the DataType generic from the table parameter.
|
|
21
|
+
// We use a type assertion here to match the expected types.
|
|
22
|
+
const tableMeta = meta.forTable(table, ColumnReordering);
|
|
23
|
+
return tableMeta.setOrder(order);
|
|
24
|
+
};
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
27
|
* Ask if the column cannot move to the left
|
|
@@ -46,5 +51,31 @@ const canMoveRight = column =>
|
|
|
46
51
|
// meta.forColumn(column, ColumnReordering).canMoveRight
|
|
47
52
|
!meta.forColumn(column, ColumnReordering).cannotMoveRight;
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Get the columns in their current display order.
|
|
56
|
+
*
|
|
57
|
+
* This returns an array of columns sorted according to any reordering
|
|
58
|
+
* that has been applied via the ColumnReordering plugin. If no reordering
|
|
59
|
+
* has been applied, columns are returned in their original order.
|
|
60
|
+
*
|
|
61
|
+
* @param table - The table instance to get ordered columns from
|
|
62
|
+
* @returns Array of columns in their current display order
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { orderedColumnsFor } from '@universal-ember/table/plugins/column-reordering';
|
|
67
|
+
*
|
|
68
|
+
* const columns = orderedColumnsFor(table);
|
|
69
|
+
* // Use the ordered columns for rendering or other operations
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
const orderedColumnsFor = table => {
|
|
73
|
+
// Note: The meta.forTable API doesn't preserve the DataType generic from the table parameter.
|
|
74
|
+
// This is a limitation of the current plugin meta system architecture.
|
|
75
|
+
// We use a type assertion here because we know the columns come from the same table.
|
|
76
|
+
const tableMeta = meta.forTable(table, ColumnReordering);
|
|
77
|
+
return tableMeta.columnOrder.orderedColumns;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight, orderedColumnsFor, setColumnOrder };
|
|
50
81
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/column-reordering/helpers.ts"],"sourcesContent":["import { meta } from '../-private/base.ts';\nimport { ColumnReordering } from './plugin.ts';\n\nimport type { ColumnOrder } from './plugin.ts';\nimport type { Column, Table } from '../../index.ts';\n\n/**\n * Move the column one position to the left.\n * If the column is first, nothing will happen.\n */\nexport const moveLeft = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnReordering).moveLeft();\n\n/**\n * Move the column one position to the right.\n * If the column is last, nothing will happen.\n */\nexport const moveRight = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnReordering).moveRight();\n\n/**\n * Override all column positions at once.\n */\nexport const setColumnOrder = <DataType = unknown>(\n table: Table<DataType>,\n order: ColumnOrder
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/column-reordering/helpers.ts"],"sourcesContent":["import { meta } from '../-private/base.ts';\nimport { ColumnReordering } from './plugin.ts';\n\nimport type { ColumnOrder, TableMeta } from './plugin.ts';\nimport type { Column, Table } from '../../index.ts';\n\n/**\n * Move the column one position to the left.\n * If the column is first, nothing will happen.\n */\nexport const moveLeft = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnReordering).moveLeft();\n\n/**\n * Move the column one position to the right.\n * If the column is last, nothing will happen.\n */\nexport const moveRight = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnReordering).moveRight();\n\n/**\n * Override all column positions at once.\n */\nexport const setColumnOrder = <DataType = unknown>(\n table: Table<DataType>,\n order: ColumnOrder<DataType>,\n) => {\n // Note: The meta.forTable API doesn't preserve the DataType generic from the table parameter.\n // We use a type assertion here to match the expected types.\n const tableMeta = meta.forTable(\n table,\n ColumnReordering,\n ) as TableMeta<DataType>;\n return tableMeta.setOrder(order);\n};\n\n/**\n * Ask if the column cannot move to the left\n */\nexport const cannotMoveLeft = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnReordering).cannotMoveLeft;\n\n/**\n * Ask if the column cannot move to the right\n */\nexport const cannotMoveRight = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnReordering).cannotMoveRight;\n\n/**\n * Ask if the column can move to the left\n * (If your plugin doesn't expose `canMoveLeft`, use `!cannotMoveLeft`.)\n */\nexport const canMoveLeft = <DataType = unknown>(column: Column<DataType>) =>\n // Prefer this if available:\n // meta.forColumn(column, ColumnReordering).canMoveLeft\n !meta.forColumn(column, ColumnReordering).cannotMoveLeft;\n\n/**\n * Ask if the column can move to the right\n * (If your plugin doesn't expose `canMoveRight`, use `!cannotMoveRight`.)\n */\nexport const canMoveRight = <DataType = unknown>(column: Column<DataType>) =>\n // Prefer this if available:\n // meta.forColumn(column, ColumnReordering).canMoveRight\n !meta.forColumn(column, ColumnReordering).cannotMoveRight;\n\n/**\n * Get the columns in their current display order.\n *\n * This returns an array of columns sorted according to any reordering\n * that has been applied via the ColumnReordering plugin. If no reordering\n * has been applied, columns are returned in their original order.\n *\n * @param table - The table instance to get ordered columns from\n * @returns Array of columns in their current display order\n *\n * @example\n * ```ts\n * import { orderedColumnsFor } from '@universal-ember/table/plugins/column-reordering';\n *\n * const columns = orderedColumnsFor(table);\n * // Use the ordered columns for rendering or other operations\n * ```\n */\nexport const orderedColumnsFor = <DataType = unknown>(\n table: Table<DataType>,\n): Column<DataType>[] => {\n // Note: The meta.forTable API doesn't preserve the DataType generic from the table parameter.\n // This is a limitation of the current plugin meta system architecture.\n // We use a type assertion here because we know the columns come from the same table.\n const tableMeta = meta.forTable(\n table,\n ColumnReordering,\n ) as TableMeta<DataType>;\n return tableMeta.columnOrder.orderedColumns;\n};\n"],"names":["moveLeft","column","meta","forColumn","ColumnReordering","moveRight","setColumnOrder","table","order","tableMeta","forTable","setOrder","cannotMoveLeft","cannotMoveRight","canMoveLeft","canMoveRight","orderedColumnsFor","columnOrder","orderedColumns"],"mappings":";;;AAMA;AACA;AACA;AACA;MACaA,QAAQ,GAAwBC,MAAwB,IACnEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACJ,QAAQ;;AAEnD;AACA;AACA;AACA;MACaK,SAAS,GAAwBJ,MAAwB,IACpEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACC,SAAS;;AAEpD;AACA;AACA;MACaC,cAAc,GAAGA,CAC5BC,KAAsB,EACtBC,KAA4B,KACzB;AACH;AACA;EACA,MAAMC,SAAS,GAAGP,IAAI,CAACQ,QAAQ,CAC7BH,KAAK,EACLH,gBACF,CAAwB;AACxB,EAAA,OAAOK,SAAS,CAACE,QAAQ,CAACH,KAAK,CAAC;AAClC;;AAEA;AACA;AACA;AACaI,MAAAA,cAAc,GAAwBX,MAAwB,IACzEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACQ;;AAE3C;AACA;AACA;AACaC,MAAAA,eAAe,GAAwBZ,MAAwB,IAC1EC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACS;;AAE3C;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAwBb,MAAwB;AACtE;AACA;AACA,CAACC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACQ;;AAE5C;AACA;AACA;AACA;AACO,MAAMG,YAAY,GAAwBd,MAAwB;AACvE;AACA;AACA,CAACC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,gBAAgB,CAAC,CAACS;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaG,MAAAA,iBAAiB,GAC5BT,KAAsB,IACC;AACvB;AACA;AACA;EACA,MAAME,SAAS,GAAGP,IAAI,CAACQ,QAAQ,CAC7BH,KAAK,EACLH,gBACF,CAAwB;AACxB,EAAA,OAAOK,SAAS,CAACQ,WAAW,CAACC,cAAc;AAC7C;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight, setColumnOrder } from './helpers.js';
|
|
1
|
+
export { canMoveLeft, canMoveRight, cannotMoveLeft, cannotMoveRight, moveLeft, moveRight, orderedColumnsFor, setColumnOrder } from './helpers.js';
|
|
2
2
|
export { ColumnOrder, ColumnReordering, ColumnReordering as Plugin, orderOf } from './plugin.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -354,10 +354,15 @@ let ColumnOrder = (_class2 = class ColumnOrder {
|
|
|
354
354
|
});
|
|
355
355
|
for (const [key, position] of mergedOrder.entries()) {
|
|
356
356
|
const column = columnsByKey[key];
|
|
357
|
-
|
|
357
|
+
|
|
358
|
+
// Skip columns that no longer exist (they've been removed from the columns array)
|
|
359
|
+
if (!column) {
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
358
362
|
result[position] = column;
|
|
359
363
|
}
|
|
360
|
-
|
|
364
|
+
|
|
365
|
+
// Filter out undefined entries (from removed columns or gaps in positions)
|
|
361
366
|
return result.filter(Boolean);
|
|
362
367
|
}
|
|
363
368
|
}, _applyDecoratedDescriptor(_class2.prototype, "moveLeft", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "moveLeft"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "moveRight", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "moveRight"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "swapWith", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "swapWith"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "get", [action], Object.getOwnPropertyDescriptor(_class2.prototype, "get"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "orderedMap", [cached], Object.getOwnPropertyDescriptor(_class2.prototype, "orderedMap"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "orderedColumns", [cached], Object.getOwnPropertyDescriptor(_class2.prototype, "orderedColumns"), _class2.prototype), _class2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/column-reordering/plugin.ts"],"sourcesContent":["import { cached, tracked } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { action } from '@ember/object';\n\nimport { TrackedMap } from 'tracked-built-ins';\n\nimport { preferences } from '../../plugins/index.ts';\n\nimport { BasePlugin, columns, meta } from '../-private/base.ts';\n\nimport type { PluginPreferences } from '../../plugins/index.ts';\nimport type { Column, Table } from '../../index.ts';\n\ninterface ColumnReorderingPreferences extends PluginPreferences {\n table: {\n order?: Record<string, number>;\n };\n}\n\ndeclare module '@universal-ember/table/plugins' {\n interface Registry {\n ColumnReordering?: ColumnReorderingPreferences;\n 'column-reordering'?: ColumnReorderingPreferences;\n }\n}\n\nexport interface Signature {\n Meta: {\n Column: ColumnMeta;\n Table: TableMeta;\n };\n}\n\nexport class ColumnReordering extends BasePlugin<Signature> {\n name = 'column-reordering';\n static features = ['columnOrder'];\n\n meta = {\n column: ColumnMeta,\n table: TableMeta,\n } as const;\n\n reset() {\n const tableMeta = meta.forTable(this.table, ColumnReordering);\n\n tableMeta.reset();\n }\n\n get columns() {\n return meta.forTable(this.table, ColumnReordering).columns;\n }\n}\n\nexport class ColumnMeta {\n constructor(private column: Column) {}\n\n get #tableMeta() {\n return meta.forTable(this.column.table, ColumnReordering);\n }\n\n get position() {\n return this.#tableMeta.getPosition(this.column);\n }\n\n // Swaps this column with the column in the new position\n set position(value: number) {\n this.#tableMeta.setPosition(this.column, value);\n }\n\n get canMoveLeft() {\n return this.#tableMeta.getPosition(this.column) !== 0;\n }\n\n get canMoveRight() {\n return (\n this.#tableMeta.getPosition(this.column) !==\n this.#tableMeta.columns.length - 1\n );\n }\n\n get cannotMoveLeft() {\n return !this.canMoveLeft;\n }\n\n get cannotMoveRight() {\n return !this.canMoveRight;\n }\n\n /**\n * Move the column one spot to the left\n */\n moveLeft = () => {\n this.#tableMeta.columnOrder.moveLeft(this.column.key);\n };\n\n /**\n * Move the column one spot to the right\n */\n moveRight = () => {\n this.#tableMeta.columnOrder.moveRight(this.column.key);\n };\n}\n\nexport class TableMeta {\n constructor(private table: Table) {}\n\n /**\n * @private\n *\n * We want to maintain the instance of this ColumnOrder class because\n * we allow the consumer of the table to swap out columns at any time.\n * When they do this, we want to maintain the order of the table, best we can.\n * This is also why the order of the columns is maintained via column key\n */\n @tracked\n columnOrder = new ColumnOrder({\n columns: () => this.allColumns,\n visibleColumns: () => this.visibleColumns,\n save: this.save,\n existingOrder: this.read(),\n });\n\n /**\n * Get the curret order/position of a column\n */\n @action\n getPosition<DataType = unknown>(column: Column<DataType>) {\n return this.columnOrder.get(column.key);\n }\n\n /**\n * Swap the column with the column at `newPosition`\n */\n @action\n setPosition<DataType = unknown>(\n column: Column<DataType>,\n newPosition: number,\n ) {\n return this.columnOrder.swapWith(column.key, newPosition);\n }\n\n /**\n * Using a `ColumnOrder` instance, set the order of all columns\n */\n setOrder = (order: ColumnOrder) => {\n this.columnOrder.setAll(order.map);\n };\n\n /**\n * Revert to default config, delete preferences,\n * and clear the columnOrder\n */\n @action\n reset() {\n preferences.forTable(this.table, ColumnReordering).delete('order');\n this.columnOrder = new ColumnOrder({\n columns: () => this.allColumns,\n visibleColumns: () => this.visibleColumns,\n save: this.save,\n });\n }\n\n /**\n * @private\n */\n @action\n save(map: Map<string, number>) {\n const order: Record<string, number> = {};\n\n for (const [key, position] of map.entries()) {\n order[key] = position;\n }\n\n preferences.forTable(this.table, ColumnReordering).set('order', order);\n }\n\n /**\n * @private\n */\n @action\n private read() {\n const order = preferences\n .forTable(this.table, ColumnReordering)\n .get('order');\n\n if (!order) return;\n\n return new Map<string, number>(Object.entries(order));\n }\n\n get columns() {\n return this.columnOrder.orderedColumns.filter(\n (column) => this.visibleColumns[column.key],\n );\n }\n\n /**\n * @private\n * This isn't our data to expose, but it is useful to alias\n */\n private get visibleColumns() {\n return columns\n .for(this.table, ColumnReordering)\n .reduce<Record<string, boolean>>((acc, column) => {\n acc[column.key] = true;\n\n return acc;\n }, {});\n }\n\n private get allColumns() {\n return this.table.columns.values();\n }\n}\n\n/**\n * @private\n * Used for keeping track of and updating column order\n */\nexport class ColumnOrder {\n /**\n * This map will be empty until we re-order something.\n */\n map = new TrackedMap<string, number>();\n\n constructor(\n private args: {\n /**\n * All columns to track in the ordering.\n *\n * Backwards compatible usage (without ColumnVisibility):\n * - Pass only the columns you want to display\n * - All columns are treated as visible\n *\n * New usage (with ColumnVisibility):\n * - Pass ALL columns (including hidden ones)\n * - Provide `visibleColumns` to indicate which are visible\n * - Hidden columns maintain their position when toggled\n */\n columns: () => Column[];\n /**\n * Optional: Record of which columns are currently visible.\n * When provided, moveLeft/moveRight will skip over hidden columns.\n * When omitted, all columns from `columns` are treated as visible (backwards compatible).\n *\n * Example when using ColumnVisibility:\n * ```ts\n * visibleColumns: () => columns.reduce((acc, col) => {\n * acc[col.key] = meta(col).ColumnVisibility?.isVisible !== false;\n * return acc;\n * }, {})\n * ```\n */\n visibleColumns?: () => Record<string, boolean>;\n /**\n * Optional: Callback to persist the column order (e.g., to localStorage).\n */\n save?: (order: Map<string, number>) => void;\n /**\n * Optional: Previously saved column order to restore.\n */\n existingOrder?: Map<string, number>;\n },\n ) {\n let allColumns = this.args.columns();\n\n if (args.existingOrder) {\n let newOrder = new Map(args.existingOrder.entries());\n\n addMissingColumnsToMap(allColumns, newOrder);\n removeExtraColumnsFromMap(allColumns, newOrder);\n this.map = new TrackedMap(newOrder);\n } else {\n this.map = new TrackedMap(allColumns.map((column, i) => [column.key, i]));\n }\n }\n\n /**\n * @private\n * Helper to get visible columns, defaulting to all columns if not specified\n */\n private getVisibleColumns(): Record<string, boolean> {\n if (this.args.visibleColumns) {\n return this.args.visibleColumns();\n }\n\n // Default: all columns are visible\n return this.args.columns().reduce(\n (acc, col) => {\n acc[col.key] = true;\n return acc;\n },\n {} as Record<string, boolean>,\n );\n }\n\n /**\n * To account for columnVisibilty, we need to:\n * - get the list of visible columns\n * - get the column order (which preserves the order of hidden columns)\n * - skip over non-visible columns when determining the previous \"index\"\n * - set the position to whatever that is.\n */\n @action\n moveLeft(key: string) {\n const orderedColumns = this.orderedColumns;\n if (this.map.get(key) === 0) {\n return;\n }\n\n let found = false;\n\n for (const column of orderedColumns.reverse()) {\n if (found) {\n // Shift moved column left\n let currentPosition = this.map.get(key);\n\n assert('current key must exist in map', currentPosition !== undefined);\n this.map.set(key, currentPosition - 1);\n\n // Shift displayed column right\n let displayedColumnPosition = this.map.get(column.key);\n\n assert(\n 'displaced key must exist in map',\n displayedColumnPosition !== undefined,\n );\n this.map.set(column.key, displayedColumnPosition + 1);\n\n if (this.getVisibleColumns()[column.key]) {\n break;\n }\n }\n\n if (column.key === key) {\n found = true;\n }\n }\n\n this.args.save?.(this.map);\n }\n\n setAll = (map: Map<string, number>) => {\n let allColumns = this.args.columns();\n\n addMissingColumnsToMap(allColumns, map);\n removeExtraColumnsFromMap(allColumns, map);\n\n this.map.clear();\n\n for (const [key, value] of map.entries()) {\n this.map.set(key, value);\n }\n\n this.args.save?.(map);\n };\n\n /**\n * To account for columnVisibilty, we need to:\n * - get the list of visible columns\n * - get the column order (which preserves the order of hidden columns)\n * - skip over non-visible columns when determining the next \"index\"\n * - set the position to whatever that is.\n */\n @action\n moveRight(key: string) {\n const orderedColumns = this.orderedColumns;\n let found = false;\n\n for (const column of orderedColumns) {\n if (found) {\n // Shift moved column right\n let currentPosition = this.map.get(key);\n\n assert('current key must exist in map', currentPosition !== undefined);\n this.map.set(key, currentPosition + 1);\n\n // Shift displaced column left\n let displayedColumnPosition = this.map.get(column.key);\n\n assert(\n 'displaced key must exist in map',\n displayedColumnPosition !== undefined,\n );\n this.map.set(column.key, displayedColumnPosition - 1);\n\n if (this.getVisibleColumns()[column.key]) {\n break;\n }\n }\n\n if (column.key === key) {\n found = true;\n }\n }\n\n this.args.save?.(this.map);\n }\n\n /**\n * Performs a swap of the column's position with the column at position\n */\n @action\n swapWith(key: string, position: number) {\n const validPositions = [...this.orderedMap.values()];\n\n /**\n * Position to swap to must exist\n */\n if (!validPositions.includes(position)) {\n return;\n }\n\n /**\n * Where did this column `key` come from? we can find out\n * by reading orderedMap\n */\n const currentPosition = this.orderedMap.get(key);\n\n assert(\n `Pre-existing position for ${key} could not be found. Does the column exist? ` +\n `The current positions are: ` +\n [...this.orderedMap.entries()]\n .map((entry) => entry.join(' => '))\n .join(', ') +\n ` and the visibleColumns are: ` +\n Object.keys(this.getVisibleColumns()).join(', ') +\n ` and current \"map\" (${this.map.size}) is: ` +\n [...this.map.entries()].map((entry) => entry.join(' => ')).join(', '),\n undefined !== currentPosition,\n );\n\n /**\n * No need to change anything if the position is the same\n * This helps reduce @tracked invalidations, which in turn reduces DOM thrashing.\n */\n if (currentPosition === position) {\n return false;\n }\n\n const keyByPosition = new Map<number, string>(\n [...this.orderedMap.entries()].map(\n (entry) => entry.reverse() as [number, string],\n ),\n );\n\n for (const [existingPosition, key] of keyByPosition.entries()) {\n if (existingPosition === position) {\n /**\n * We swap positions because the positions are not incremental\n * meaning we can have gaps, intentionally, due to hidden columns\n */\n this.map.set(key, currentPosition);\n\n break;\n }\n }\n\n /**\n * Finally, set the position for the requested column\n */\n this.map.set(key, position);\n\n /**\n * Now that we've set the value for one column,\n * we need to make sure that all columns have a recorded position.\n */\n for (const [key, position] of this.orderedMap.entries()) {\n if (this.map.has(key)) continue;\n\n this.map.set(key, position);\n }\n\n this.args.save?.(this.map);\n }\n\n @action\n get(key: string) {\n const result = this.orderedMap.get(key);\n\n assert(\n `No position found for ${key}. Is the column used within this table?`,\n /* 0 is falsey, but it's a valid value for position */\n undefined !== result,\n );\n\n return result;\n }\n\n /**\n * The same as this.map, but with all the columns' information\n */\n @cached\n get orderedMap(): ReadonlyMap<string, number> {\n return orderOf(this.args.columns(), this.map);\n }\n\n @cached\n get orderedColumns(): Column[] {\n const allColumns = this.args.columns();\n const columnsByKey = allColumns.reduce(\n (keyMap, column) => {\n keyMap[column.key] = column;\n return keyMap;\n },\n {} as Record<string, Column>,\n );\n const mergedOrder = orderOf(allColumns, this.map);\n\n const result: Column[] = Array.from({ length: allColumns.length });\n\n for (const [key, position] of mergedOrder.entries()) {\n const column = columnsByKey[key];\n\n assert(`Could not find column for pair: ${key} @ @{position}`, column);\n result[position] = column;\n }\n\n assert(\n `Generated orderedColumns' length (${result.filter(Boolean).length}) ` +\n `does not match the length of all columns (${allColumns.length}). ` +\n `orderedColumns: ${result\n .filter(Boolean)\n .map((c) => c.key)\n .join(', ')} -- ` +\n `all columns: ${allColumns.map((c) => c.key).join(', ')}`,\n result.filter(Boolean).length === allColumns.length,\n );\n\n return result.filter(Boolean);\n }\n}\n\n/**\n * @private\n *\n * Utility for helping determine the percieved order of a set of columns\n * given the original (default) ordering, and then user-configurations.\n *\n * This function adds missing columns but preserves extra columns in the map\n * (they might be hidden, not deleted).\n */\nexport function orderOf(\n columns: { key: string }[],\n currentOrder: Map<string, number>,\n): Map<string, number> {\n // Create a copy to avoid mutating the input\n let workingOrder = new Map(currentOrder);\n\n // Add any missing columns to the end\n addMissingColumnsToMap(columns, workingOrder);\n\n // DON'T remove extra columns - they might be hidden columns, not deleted ones\n // The ColumnOrder constructor handles removal of truly deleted columns\n\n // Ensure positions are consecutive and zero based\n let inOrder = Array.from(workingOrder.entries()).sort(\n ([_keyA, positionA], [_keyB, positionB]) => positionA - positionB,\n );\n\n let orderedColumns = new Map<string, number>();\n\n let position = 0;\n\n for (let [key] of inOrder) {\n orderedColumns.set(key, position++);\n }\n\n return orderedColumns;\n}\n\n/**\n * @private\n *\n * Utility to add any missing columns to the position map. By calling this whenever\n * data is passed in to the system we can simplify the code within the system because\n * we know we are dealing with a full set of positions.\n *\n * @param columns - A list of all columns available to the table\n * @param map - A Map of `key` to position (as a zero based integer)\n */\nfunction addMissingColumnsToMap(\n columns: { key: string }[],\n map: Map<string, number>,\n): void {\n if (map.size < columns.length) {\n let maxAssignedColumn = Math.max(...map.values());\n\n for (let column of columns) {\n if (map.get(column.key) === undefined) {\n map.set(column.key, ++maxAssignedColumn);\n }\n }\n }\n}\n\n/**\n * @private\n *\n * Utility to remove any extra columns from the position map. By calling this whenever\n * data is passed in to the system we can simplify the code within the system because\n * we know we are dealing with a full set of positions.\n *\n * @param columns - A list of all columns available to the table\n * @param map - A Map of `key` to position (as a zero based integer)\n */\nfunction removeExtraColumnsFromMap(\n columns: { key: string }[],\n map: Map<string, number>,\n): void {\n let columnsLookup = columns.reduce(\n function (acc, { key }) {\n acc[key] = true;\n\n return acc;\n },\n {} as Record<string, boolean>,\n );\n\n for (let key of map.keys()) {\n if (!columnsLookup[key]) {\n map.delete(key);\n }\n }\n}\n"],"names":["ColumnReordering","BasePlugin","constructor","args","_defineProperty","column","ColumnMeta","table","TableMeta","reset","tableMeta","meta","forTable","columns","_ColumnMeta_brand","WeakSet","_classPrivateMethodInitSpec","_classPrivateGetter","_get_tableMeta","columnOrder","moveLeft","key","moveRight","position","getPosition","value","setPosition","canMoveLeft","canMoveRight","length","cannotMoveLeft","cannotMoveRight","_this","_class","_initializerDefineProperty","_descriptor","order","setAll","map","get","newPosition","swapWith","preferences","delete","ColumnOrder","allColumns","visibleColumns","save","entries","set","read","Map","Object","orderedColumns","filter","for","reduce","acc","values","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","existingOrder","action","getOwnPropertyDescriptor","_class2","TrackedMap","addMissingColumnsToMap","removeExtraColumnsFromMap","clear","newOrder","i","getVisibleColumns","col","found","reverse","currentPosition","assert","undefined","displayedColumnPosition","validPositions","orderedMap","includes","entry","join","keys","size","keyByPosition","existingPosition","has","result","orderOf","columnsByKey","keyMap","mergedOrder","Array","from","Boolean","c","cached","currentOrder","workingOrder","inOrder","sort","_keyA","positionA","_keyB","positionB","maxAssignedColumn","Math","max","columnsLookup"],"mappings":";;;;;;;;AAiCO,MAAMA,gBAAgB,SAASC,UAAU,CAAY;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;AAAAC,IAAAA,eAAA,eACnD,mBAAmB,CAAA;AAAAA,IAAAA,eAAA,CAGnB,IAAA,EAAA,MAAA,EAAA;AACLC,MAAAA,MAAM,EAAEC,UAAU;AAClBC,MAAAA,KAAK,EAAEC;KACR,CAAA;AAAA;AAEDC,EAAAA,KAAKA,GAAG;IACN,MAAMC,SAAS,GAAGC,IAAI,CAACC,QAAQ,CAAC,IAAI,CAACL,KAAK,EAAEP,gBAAgB,CAAC;IAE7DU,SAAS,CAACD,KAAK,EAAE;AACnB;EAEA,IAAII,OAAOA,GAAG;IACZ,OAAOF,IAAI,CAACC,QAAQ,CAAC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CAACpC,GAAG,CAAC,GAAG,IAAI;AAEf,IAAA,OAAOoC,GAAG;GACX,EACD,EACF,CAAC;EAED,KAAK,IAAIpC,GAAG,IAAIiB,GAAG,CAACmD,IAAI,EAAE,EAAE;AAC1B,IAAA,IAAI,CAAC0B,aAAa,CAAC9F,GAAG,CAAC,EAAE;AACvBiB,MAAAA,GAAG,CAACK,MAAM,CAACtB,GAAG,CAAC;AACjB;AACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/column-reordering/plugin.ts"],"sourcesContent":["import { cached, tracked } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { action } from '@ember/object';\n\nimport { TrackedMap } from 'tracked-built-ins';\n\nimport { preferences } from '../../plugins/index.ts';\n\nimport { BasePlugin, columns, meta } from '../-private/base.ts';\n\nimport type { PluginPreferences } from '../../plugins/index.ts';\nimport type { Column, Table } from '../../index.ts';\n\ninterface ColumnReorderingPreferences extends PluginPreferences {\n table: {\n order?: Record<string, number>;\n };\n}\n\ndeclare module '@universal-ember/table/plugins' {\n interface Registry {\n ColumnReordering?: ColumnReorderingPreferences;\n 'column-reordering'?: ColumnReorderingPreferences;\n }\n}\n\nexport interface Signature {\n Meta: {\n Column: ColumnMeta;\n Table: TableMeta;\n };\n}\n\nexport class ColumnReordering extends BasePlugin<Signature> {\n name = 'column-reordering';\n static features = ['columnOrder'];\n\n meta = {\n column: ColumnMeta,\n table: TableMeta,\n } as const;\n\n reset() {\n const tableMeta = meta.forTable(this.table, ColumnReordering);\n\n tableMeta.reset();\n }\n\n get columns() {\n return meta.forTable(this.table, ColumnReordering).columns;\n }\n}\n\nexport class ColumnMeta<DataType = unknown> {\n constructor(private column: Column<DataType>) {}\n\n get #tableMeta(): TableMeta<DataType> {\n return meta.forTable(\n this.column.table,\n ColumnReordering,\n ) as TableMeta<DataType>;\n }\n\n get position() {\n return this.#tableMeta.getPosition(this.column);\n }\n\n // Swaps this column with the column in the new position\n set position(value: number) {\n this.#tableMeta.setPosition(this.column, value);\n }\n\n get canMoveLeft() {\n return this.#tableMeta.getPosition(this.column) !== 0;\n }\n\n get canMoveRight() {\n return (\n this.#tableMeta.getPosition(this.column) !==\n this.#tableMeta.columns.length - 1\n );\n }\n\n get cannotMoveLeft() {\n return !this.canMoveLeft;\n }\n\n get cannotMoveRight() {\n return !this.canMoveRight;\n }\n\n /**\n * Move the column one spot to the left\n */\n moveLeft = () => {\n this.#tableMeta.columnOrder.moveLeft(this.column.key);\n };\n\n /**\n * Move the column one spot to the right\n */\n moveRight = () => {\n this.#tableMeta.columnOrder.moveRight(this.column.key);\n };\n}\n\nexport class TableMeta<DataType = unknown> {\n constructor(private table: Table<DataType>) {}\n\n /**\n * @private\n *\n * We want to maintain the instance of this ColumnOrder class because\n * we allow the consumer of the table to swap out columns at any time.\n * When they do this, we want to maintain the order of the table, best we can.\n * This is also why the order of the columns is maintained via column key\n */\n @tracked\n columnOrder = new ColumnOrder<DataType>({\n columns: () => this.allColumns,\n visibleColumns: () => this.visibleColumns,\n save: this.save,\n existingOrder: this.read(),\n });\n\n /**\n * Get the curret order/position of a column\n */\n @action\n getPosition(column: Column<DataType>) {\n return this.columnOrder.get(column.key);\n }\n\n /**\n * Swap the column with the column at `newPosition`\n */\n @action\n setPosition(column: Column<DataType>, newPosition: number) {\n return this.columnOrder.swapWith(column.key, newPosition);\n }\n\n /**\n * Using a `ColumnOrder` instance, set the order of all columns\n */\n setOrder = (order: ColumnOrder<DataType>) => {\n this.columnOrder.setAll(order.map);\n };\n\n /**\n * Revert to default config, delete preferences,\n * and clear the columnOrder\n */\n @action\n reset() {\n preferences.forTable(this.table, ColumnReordering).delete('order');\n this.columnOrder = new ColumnOrder<DataType>({\n columns: () => this.allColumns,\n visibleColumns: () => this.visibleColumns,\n save: this.save,\n });\n }\n\n /**\n * @private\n */\n @action\n save(map: Map<string, number>) {\n const order: Record<string, number> = {};\n\n for (const [key, position] of map.entries()) {\n order[key] = position;\n }\n\n preferences.forTable(this.table, ColumnReordering).set('order', order);\n }\n\n /**\n * @private\n */\n @action\n private read() {\n const order = preferences\n .forTable(this.table, ColumnReordering)\n .get('order');\n\n if (!order) return;\n\n return new Map<string, number>(Object.entries(order));\n }\n\n get columns() {\n return this.columnOrder.orderedColumns.filter(\n (column) => this.visibleColumns[column.key],\n );\n }\n\n /**\n * @private\n * This isn't our data to expose, but it is useful to alias\n */\n private get visibleColumns() {\n return columns\n .for(this.table, ColumnReordering)\n .reduce<Record<string, boolean>>((acc, column) => {\n acc[column.key] = true;\n\n return acc;\n }, {});\n }\n\n private get allColumns() {\n return this.table.columns.values();\n }\n}\n\n/**\n * @private\n * Used for keeping track of and updating column order\n */\nexport class ColumnOrder<DataType = unknown> {\n /**\n * This map will be empty until we re-order something.\n */\n map = new TrackedMap<string, number>();\n\n constructor(\n private args: {\n /**\n * All columns to track in the ordering.\n *\n * Backwards compatible usage (without ColumnVisibility):\n * - Pass only the columns you want to display\n * - All columns are treated as visible\n *\n * New usage (with ColumnVisibility):\n * - Pass ALL columns (including hidden ones)\n * - Provide `visibleColumns` to indicate which are visible\n * - Hidden columns maintain their position when toggled\n */\n columns: () => Column<DataType>[];\n /**\n * Optional: Record of which columns are currently visible.\n * When provided, moveLeft/moveRight will skip over hidden columns.\n * When omitted, all columns from `columns` are treated as visible (backwards compatible).\n *\n * Example when using ColumnVisibility:\n * ```ts\n * visibleColumns: () => columns.reduce((acc, col) => {\n * acc[col.key] = meta(col).ColumnVisibility?.isVisible !== false;\n * return acc;\n * }, {})\n * ```\n */\n visibleColumns?: () => Record<string, boolean>;\n /**\n * Optional: Callback to persist the column order (e.g., to localStorage).\n */\n save?: (order: Map<string, number>) => void;\n /**\n * Optional: Previously saved column order to restore.\n */\n existingOrder?: Map<string, number>;\n },\n ) {\n let allColumns = this.args.columns();\n\n if (args.existingOrder) {\n let newOrder = new Map(args.existingOrder.entries());\n\n addMissingColumnsToMap(allColumns, newOrder);\n removeExtraColumnsFromMap(allColumns, newOrder);\n this.map = new TrackedMap(newOrder);\n } else {\n this.map = new TrackedMap(allColumns.map((column, i) => [column.key, i]));\n }\n }\n\n /**\n * @private\n * Helper to get visible columns, defaulting to all columns if not specified\n */\n private getVisibleColumns(): Record<string, boolean> {\n if (this.args.visibleColumns) {\n return this.args.visibleColumns();\n }\n\n // Default: all columns are visible\n return this.args.columns().reduce(\n (acc, col) => {\n acc[col.key] = true;\n return acc;\n },\n {} as Record<string, boolean>,\n );\n }\n\n /**\n * To account for columnVisibilty, we need to:\n * - get the list of visible columns\n * - get the column order (which preserves the order of hidden columns)\n * - skip over non-visible columns when determining the previous \"index\"\n * - set the position to whatever that is.\n */\n @action\n moveLeft(key: string) {\n const orderedColumns = this.orderedColumns;\n if (this.map.get(key) === 0) {\n return;\n }\n\n let found = false;\n\n for (const column of orderedColumns.reverse()) {\n if (found) {\n // Shift moved column left\n let currentPosition = this.map.get(key);\n\n assert('current key must exist in map', currentPosition !== undefined);\n this.map.set(key, currentPosition - 1);\n\n // Shift displayed column right\n let displayedColumnPosition = this.map.get(column.key);\n\n assert(\n 'displaced key must exist in map',\n displayedColumnPosition !== undefined,\n );\n this.map.set(column.key, displayedColumnPosition + 1);\n\n if (this.getVisibleColumns()[column.key]) {\n break;\n }\n }\n\n if (column.key === key) {\n found = true;\n }\n }\n\n this.args.save?.(this.map);\n }\n\n setAll = (map: Map<string, number>) => {\n let allColumns = this.args.columns();\n\n addMissingColumnsToMap(allColumns, map);\n removeExtraColumnsFromMap(allColumns, map);\n\n this.map.clear();\n\n for (const [key, value] of map.entries()) {\n this.map.set(key, value);\n }\n\n this.args.save?.(map);\n };\n\n /**\n * To account for columnVisibilty, we need to:\n * - get the list of visible columns\n * - get the column order (which preserves the order of hidden columns)\n * - skip over non-visible columns when determining the next \"index\"\n * - set the position to whatever that is.\n */\n @action\n moveRight(key: string) {\n const orderedColumns = this.orderedColumns;\n let found = false;\n\n for (const column of orderedColumns) {\n if (found) {\n // Shift moved column right\n let currentPosition = this.map.get(key);\n\n assert('current key must exist in map', currentPosition !== undefined);\n this.map.set(key, currentPosition + 1);\n\n // Shift displaced column left\n let displayedColumnPosition = this.map.get(column.key);\n\n assert(\n 'displaced key must exist in map',\n displayedColumnPosition !== undefined,\n );\n this.map.set(column.key, displayedColumnPosition - 1);\n\n if (this.getVisibleColumns()[column.key]) {\n break;\n }\n }\n\n if (column.key === key) {\n found = true;\n }\n }\n\n this.args.save?.(this.map);\n }\n\n /**\n * Performs a swap of the column's position with the column at position\n */\n @action\n swapWith(key: string, position: number) {\n const validPositions = [...this.orderedMap.values()];\n\n /**\n * Position to swap to must exist\n */\n if (!validPositions.includes(position)) {\n return;\n }\n\n /**\n * Where did this column `key` come from? we can find out\n * by reading orderedMap\n */\n const currentPosition = this.orderedMap.get(key);\n\n assert(\n `Pre-existing position for ${key} could not be found. Does the column exist? ` +\n `The current positions are: ` +\n [...this.orderedMap.entries()]\n .map((entry) => entry.join(' => '))\n .join(', ') +\n ` and the visibleColumns are: ` +\n Object.keys(this.getVisibleColumns()).join(', ') +\n ` and current \"map\" (${this.map.size}) is: ` +\n [...this.map.entries()].map((entry) => entry.join(' => ')).join(', '),\n undefined !== currentPosition,\n );\n\n /**\n * No need to change anything if the position is the same\n * This helps reduce @tracked invalidations, which in turn reduces DOM thrashing.\n */\n if (currentPosition === position) {\n return false;\n }\n\n const keyByPosition = new Map<number, string>(\n [...this.orderedMap.entries()].map(\n (entry) => entry.reverse() as [number, string],\n ),\n );\n\n for (const [existingPosition, key] of keyByPosition.entries()) {\n if (existingPosition === position) {\n /**\n * We swap positions because the positions are not incremental\n * meaning we can have gaps, intentionally, due to hidden columns\n */\n this.map.set(key, currentPosition);\n\n break;\n }\n }\n\n /**\n * Finally, set the position for the requested column\n */\n this.map.set(key, position);\n\n /**\n * Now that we've set the value for one column,\n * we need to make sure that all columns have a recorded position.\n */\n for (const [key, position] of this.orderedMap.entries()) {\n if (this.map.has(key)) continue;\n\n this.map.set(key, position);\n }\n\n this.args.save?.(this.map);\n }\n\n @action\n get(key: string) {\n const result = this.orderedMap.get(key);\n\n assert(\n `No position found for ${key}. Is the column used within this table?`,\n /* 0 is falsey, but it's a valid value for position */\n undefined !== result,\n );\n\n return result;\n }\n\n /**\n * The same as this.map, but with all the columns' information\n */\n @cached\n get orderedMap(): ReadonlyMap<string, number> {\n return orderOf(this.args.columns(), this.map);\n }\n\n @cached\n get orderedColumns(): Column<DataType>[] {\n const allColumns = this.args.columns();\n const columnsByKey = allColumns.reduce(\n (keyMap, column) => {\n keyMap[column.key] = column;\n return keyMap;\n },\n {} as Record<string, Column<DataType>>,\n );\n const mergedOrder = orderOf(allColumns, this.map);\n\n const result: Column<DataType>[] = Array.from({\n length: allColumns.length,\n });\n\n for (const [key, position] of mergedOrder.entries()) {\n const column = columnsByKey[key];\n\n // Skip columns that no longer exist (they've been removed from the columns array)\n if (!column) {\n continue;\n }\n\n result[position] = column;\n }\n\n // Filter out undefined entries (from removed columns or gaps in positions)\n return result.filter(Boolean);\n }\n}\n\n/**\n * @private\n *\n * Utility for helping determine the percieved order of a set of columns\n * given the original (default) ordering, and then user-configurations.\n *\n * This function adds missing columns but preserves extra columns in the map\n * (they might be hidden, not deleted).\n */\nexport function orderOf(\n columns: { key: string }[],\n currentOrder: Map<string, number>,\n): Map<string, number> {\n // Create a copy to avoid mutating the input\n let workingOrder = new Map(currentOrder);\n\n // Add any missing columns to the end\n addMissingColumnsToMap(columns, workingOrder);\n\n // DON'T remove extra columns - they might be hidden columns, not deleted ones\n // The ColumnOrder constructor handles removal of truly deleted columns\n\n // Ensure positions are consecutive and zero based\n let inOrder = Array.from(workingOrder.entries()).sort(\n ([_keyA, positionA], [_keyB, positionB]) => positionA - positionB,\n );\n\n let orderedColumns = new Map<string, number>();\n\n let position = 0;\n\n for (let [key] of inOrder) {\n orderedColumns.set(key, position++);\n }\n\n return orderedColumns;\n}\n\n/**\n * @private\n *\n * Utility to add any missing columns to the position map. By calling this whenever\n * data is passed in to the system we can simplify the code within the system because\n * we know we are dealing with a full set of positions.\n *\n * @param columns - A list of all columns available to the table\n * @param map - A Map of `key` to position (as a zero based integer)\n */\nfunction addMissingColumnsToMap(\n columns: { key: string }[],\n map: Map<string, number>,\n): void {\n if (map.size < columns.length) {\n let maxAssignedColumn = Math.max(...map.values());\n\n for (let column of columns) {\n if (map.get(column.key) === undefined) {\n map.set(column.key, ++maxAssignedColumn);\n }\n }\n }\n}\n\n/**\n * @private\n *\n * Utility to remove any extra columns from the position map. By calling this whenever\n * data is passed in to the system we can simplify the code within the system because\n * we know we are dealing with a full set of positions.\n *\n * @param columns - A list of all columns available to the table\n * @param map - A Map of `key` to position (as a zero based integer)\n */\nfunction removeExtraColumnsFromMap(\n columns: { key: string }[],\n map: Map<string, number>,\n): void {\n let columnsLookup = columns.reduce(\n function (acc, { key }) {\n acc[key] = true;\n\n return acc;\n },\n {} as Record<string, boolean>,\n );\n\n for (let key of map.keys()) {\n if (!columnsLookup[key]) {\n map.delete(key);\n }\n }\n}\n"],"names":["ColumnReordering","BasePlugin","constructor","args","_defineProperty","column","ColumnMeta","table","TableMeta","reset","tableMeta","meta","forTable","columns","_ColumnMeta_brand","WeakSet","_classPrivateMethodInitSpec","_classPrivateGetter","_get_tableMeta","columnOrder","moveLeft","key","moveRight","position","getPosition","value","setPosition","canMoveLeft","canMoveRight","length","cannotMoveLeft","cannotMoveRight","_this","_class","_initializerDefineProperty","_descriptor","order","setAll","map","get","newPosition","swapWith","preferences","delete","ColumnOrder","allColumns","visibleColumns","save","entries","set","read","Map","Object","orderedColumns","filter","for","reduce","acc","values","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","existingOrder","action","getOwnPropertyDescriptor","_class2","TrackedMap","addMissingColumnsToMap","removeExtraColumnsFromMap","clear","newOrder","i","getVisibleColumns","col","found","reverse","currentPosition","assert","undefined","displayedColumnPosition","validPositions","orderedMap","includes","entry","join","keys","size","keyByPosition","existingPosition","has","result","orderOf","columnsByKey","keyMap","mergedOrder","Array","from","Boolean","cached","currentOrder","workingOrder","inOrder","sort","_keyA","positionA","_keyB","positionB","maxAssignedColumn","Math","max","columnsLookup"],"mappings":";;;;;;;;AAiCO,MAAMA,gBAAgB,SAASC,UAAU,CAAY;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;AAAAC,IAAAA,eAAA,eACnD,mBAAmB,CAAA;AAAAA,IAAAA,eAAA,CAGnB,IAAA,EAAA,MAAA,EAAA;AACLC,MAAAA,MAAM,EAAEC,UAAU;AAClBC,MAAAA,KAAK,EAAEC;KACR,CAAA;AAAA;AAEDC,EAAAA,KAAKA,GAAG;IACN,MAAMC,SAAS,GAAGC,IAAI,CAACC,QAAQ,CAAC,IAAI,CAACL,KAAK,EAAEP,gBAAgB,CAAC;IAE7DU,SAAS,CAACD,KAAK,EAAE;AACnB;EAEA,IAAII,OAAOA,GAAG;IACZ,OAAOF,IAAI,CAACC,QAAQ,CAAC,IAAI,CAACL,KAAK,EAAEP,gBAAgB,CAAC,CAACa,OAAO;AAC5D;AACF;AAACT,eAAA,CAlBYJ,gBAAgB,EAET,UAAA,EAAA,CAAC,aAAa,CAAC,CAAA;AAAA,IAAAc,iBAAA,oBAAAC,OAAA,EAAA;AAkB5B,MAAMT,UAAU,CAAqB;EAC1CJ,WAAWA,CAASG,MAAwB,EAAE;AAAAW,IAAAA,2BAAA,OAAAF,iBAAA,CAAA;AAqC9C;AACF;AACA;AAFEV,IAAAA,eAAA,mBAGW,MAAM;AACfa,MAAAA,mBAAA,CAAAH,iBAAA,EAAA,IAAI,EAACI,cAAS,CAAC,CAACC,WAAW,CAACC,QAAQ,CAAC,IAAI,CAACf,MAAM,CAACgB,GAAG,CAAC;KACtD,CAAA;AAED;AACF;AACA;AAFEjB,IAAAA,eAAA,oBAGY,MAAM;AAChBa,MAAAA,mBAAA,CAAAH,iBAAA,EAAA,IAAI,EAACI,cAAS,CAAC,CAACC,WAAW,CAACG,SAAS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,CAACpC,GAAG,CAAC,GAAG,IAAI;AAEf,IAAA,OAAOoC,GAAG;GACX,EACD,EACF,CAAC;EAED,KAAK,IAAIpC,GAAG,IAAIiB,GAAG,CAACmD,IAAI,EAAE,EAAE;AAC1B,IAAA,IAAI,CAACyB,aAAa,CAAC7F,GAAG,CAAC,EAAE;AACvBiB,MAAAA,GAAG,CAACK,MAAM,CAACtB,GAAG,CAAC;AACjB;AACF;AACF;;;;"}
|
|
@@ -2,6 +2,12 @@ import { htmlSafe } from '@ember/template';
|
|
|
2
2
|
import { meta } from '../-private/base.js';
|
|
3
3
|
import { ColumnResizing } from './plugin.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Is the column resizable?
|
|
7
|
+
* This checks if resizing is enabled for this specific column,
|
|
8
|
+
*/
|
|
9
|
+
const isResizable = column => meta.forColumn(column, ColumnResizing).isResizable;
|
|
10
|
+
|
|
5
11
|
/**
|
|
6
12
|
* The column actively being resized by the user.
|
|
7
13
|
*
|
|
@@ -67,5 +73,5 @@ const toStyle = key => {
|
|
|
67
73
|
}
|
|
68
74
|
};
|
|
69
75
|
|
|
70
|
-
export { canShrink, hasResizeHandle, isResizing, styleStringFor };
|
|
76
|
+
export { canShrink, hasResizeHandle, isResizable, isResizing, styleStringFor };
|
|
71
77
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/column-resizing/helpers.ts"],"sourcesContent":["import { htmlSafe } from '@ember/template';\n\nimport { meta } from '../-private/base.ts';\nimport { ColumnResizing } from './plugin.ts';\n\nimport type { Column } from '../../index.ts';\n\n/**\n * The column actively being resized by the user.\n *\n * Note that during resizing, multiple columns are resized at once,\n * dependending on the boundaries of the resize events.\n *\n * The other columns being resized as a consequence of \"this\" column will not\n * be marked as isResizing, because this is a user-scoped question:\n * \"Is the user directly resizing this column?\"\n */\nexport const isResizing = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnResizing).isResizing;\n\n/**\n * Does the column have room to shrink?\n */\nexport const canShrink = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnResizing).canShrink;\n\n/**\n * Does the column have a resize handle?\n * The return value of this function can be determined by\n * - if resizing is enabled for the column\n * - if resizing is enabled for the whole table\n * - or if we're asking about the first column (resize handles may only be \"between\" columns)\n */\nexport const hasResizeHandle = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnResizing).hasResizeHandle;\n\n/**\n * In this plugin (by default), styles are only applied to the headers automatically.\n * in <Table> UIs, the header cells control the widths of all cells in that column.\n * There are other kinds of tabular-like markup that may want to grab the widths of columns,\n * because The Platform does not manage that automatically (like if divs and roles were used manually)\n *\n * This utility is meant to be applied to the `style` attribute of a particular td-like element.\n */\nexport const styleStringFor = <DataType = unknown>(\n column: Column<DataType>,\n): ReturnType<typeof htmlSafe> => {\n const columnMeta = meta.forColumn(column, ColumnResizing);\n\n let result = '';\n\n /**\n * Styles are applied regardless of the \"table\" being resizable or not\n * because in non-<table> UIs, we need to ensure that all cells in a column\n * have the same width\n */\n for (const [key, value] of Object.entries(columnMeta.style)) {\n result += `${toStyle(key)}:${value};`;\n }\n\n result = ';' + result;\n\n return htmlSafe(result);\n};\n\n/**\n * the JS API for styles is camel case,\n * but CSS is kebab-case. To save on complexity and\n * amount of code, we have a super small conversion function\n * for only the properties relevant to the sticky plugin.\n */\nconst toStyle = (key: string): string => {\n switch (key) {\n case 'minWidth':\n return 'min-width';\n default:\n return key;\n }\n};\n"],"names":["
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../src/plugins/column-resizing/helpers.ts"],"sourcesContent":["import { htmlSafe } from '@ember/template';\n\nimport { meta } from '../-private/base.ts';\nimport { ColumnResizing } from './plugin.ts';\n\nimport type { Column } from '../../index.ts';\n\n/**\n * Is the column resizable?\n * This checks if resizing is enabled for this specific column,\n */\nexport const isResizable = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnResizing).isResizable;\n\n/**\n * The column actively being resized by the user.\n *\n * Note that during resizing, multiple columns are resized at once,\n * dependending on the boundaries of the resize events.\n *\n * The other columns being resized as a consequence of \"this\" column will not\n * be marked as isResizing, because this is a user-scoped question:\n * \"Is the user directly resizing this column?\"\n */\nexport const isResizing = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnResizing).isResizing;\n\n/**\n * Does the column have room to shrink?\n */\nexport const canShrink = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnResizing).canShrink;\n\n/**\n * Does the column have a resize handle?\n * The return value of this function can be determined by\n * - if resizing is enabled for the column\n * - if resizing is enabled for the whole table\n * - or if we're asking about the first column (resize handles may only be \"between\" columns)\n */\nexport const hasResizeHandle = <DataType = unknown>(column: Column<DataType>) =>\n meta.forColumn(column, ColumnResizing).hasResizeHandle;\n\n/**\n * In this plugin (by default), styles are only applied to the headers automatically.\n * in <Table> UIs, the header cells control the widths of all cells in that column.\n * There are other kinds of tabular-like markup that may want to grab the widths of columns,\n * because The Platform does not manage that automatically (like if divs and roles were used manually)\n *\n * This utility is meant to be applied to the `style` attribute of a particular td-like element.\n */\nexport const styleStringFor = <DataType = unknown>(\n column: Column<DataType>,\n): ReturnType<typeof htmlSafe> => {\n const columnMeta = meta.forColumn(column, ColumnResizing);\n\n let result = '';\n\n /**\n * Styles are applied regardless of the \"table\" being resizable or not\n * because in non-<table> UIs, we need to ensure that all cells in a column\n * have the same width\n */\n for (const [key, value] of Object.entries(columnMeta.style)) {\n result += `${toStyle(key)}:${value};`;\n }\n\n result = ';' + result;\n\n return htmlSafe(result);\n};\n\n/**\n * the JS API for styles is camel case,\n * but CSS is kebab-case. To save on complexity and\n * amount of code, we have a super small conversion function\n * for only the properties relevant to the sticky plugin.\n */\nconst toStyle = (key: string): string => {\n switch (key) {\n case 'minWidth':\n return 'min-width';\n default:\n return key;\n }\n};\n"],"names":["isResizable","column","meta","forColumn","ColumnResizing","isResizing","canShrink","hasResizeHandle","styleStringFor","columnMeta","result","key","value","Object","entries","style","toStyle","htmlSafe"],"mappings":";;;;AAOA;AACA;AACA;AACA;AACaA,MAAAA,WAAW,GAAwBC,MAAwB,IACtEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,cAAc,CAAC,CAACJ;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaK,MAAAA,UAAU,GAAwBJ,MAAwB,IACrEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,cAAc,CAAC,CAACC;;AAEzC;AACA;AACA;AACaC,MAAAA,SAAS,GAAwBL,MAAwB,IACpEC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,cAAc,CAAC,CAACE;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,eAAe,GAAwBN,MAAwB,IAC1EC,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,cAAc,CAAC,CAACG;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,cAAc,GACzBP,MAAwB,IACQ;EAChC,MAAMQ,UAAU,GAAGP,IAAI,CAACC,SAAS,CAACF,MAAM,EAAEG,cAAc,CAAC;EAEzD,IAAIM,MAAM,GAAG,EAAE;;AAEf;AACF;AACA;AACA;AACA;AACE,EAAA,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,UAAU,CAACM,KAAK,CAAC,EAAE;IAC3DL,MAAM,IAAI,GAAGM,OAAO,CAACL,GAAG,CAAC,CAAA,CAAA,EAAIC,KAAK,CAAG,CAAA,CAAA;AACvC;EAEAF,MAAM,GAAG,GAAG,GAAGA,MAAM;EAErB,OAAOO,QAAQ,CAACP,MAAM,CAAC;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,OAAO,GAAIL,GAAW,IAAa;AACvC,EAAA,QAAQA,GAAG;AACT,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,WAAW;AACpB,IAAA;AACE,MAAA,OAAOA,GAAG;AACd;AACF,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { resizeHandle } from './handle.js';
|
|
2
|
-
export { canShrink, hasResizeHandle, isResizing, styleStringFor } from './helpers.js';
|
|
2
|
+
export { canShrink, hasResizeHandle, isResizable, isResizing, styleStringFor } from './helpers.js';
|
|
3
3
|
export { ColumnResizing, ColumnResizing as Plugin } from './plugin.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -101,9 +101,16 @@ let ColumnMeta = (_class = class ColumnMeta {
|
|
|
101
101
|
return this.options.isResizable ?? this.tableMeta.isResizable;
|
|
102
102
|
}
|
|
103
103
|
get hasResizeHandle() {
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
|
|
104
|
+
const position = this.tableMeta.options?.handlePosition ?? 'left';
|
|
105
|
+
if (position === 'right') {
|
|
106
|
+
const next = columns.next(this.column);
|
|
107
|
+
if (!next) return false;
|
|
108
|
+
return this.isResizable && meta.forColumn(next, ColumnResizing).isResizable;
|
|
109
|
+
} else {
|
|
110
|
+
const previous = columns.previous(this.column);
|
|
111
|
+
if (!previous) return false;
|
|
112
|
+
return this.isResizable && meta.forColumn(previous, ColumnResizing).isResizable;
|
|
113
|
+
}
|
|
107
114
|
}
|
|
108
115
|
get width() {
|
|
109
116
|
let width = this._width ?? this.initialWidth;
|
|
@@ -156,7 +163,9 @@ let ColumnMeta = (_class = class ColumnMeta {
|
|
|
156
163
|
* Otherwise the table will infinitely resize itself
|
|
157
164
|
*/
|
|
158
165
|
function distributeDelta(delta, visibleColumns) {
|
|
159
|
-
|
|
166
|
+
// Use a tolerance threshold to prevent infinite resize loops from subpixel rounding
|
|
167
|
+
// at different zoom levels. Treat deltas smaller than 0.5px as zero.
|
|
168
|
+
if (Math.abs(delta) < 0.5) return;
|
|
160
169
|
const metas = visibleColumns.map(column => meta.forColumn(column, ColumnResizing));
|
|
161
170
|
const resizableMetas = metas.filter(meta => meta.isResizable && (delta < 0 ? meta.canShrink : true));
|
|
162
171
|
const columnDelta = delta / resizableMetas.length;
|
|
@@ -217,6 +226,11 @@ let TableMeta = (_class2 = (_TableMeta_brand = /*#__PURE__*/new WeakSet(), class
|
|
|
217
226
|
}
|
|
218
227
|
onTableResize(entry) {
|
|
219
228
|
assert('scroll container element must be an HTMLElement', entry.target instanceof HTMLElement);
|
|
229
|
+
|
|
230
|
+
// For fixed layout, columns have explicit widths and should not be auto-redistributed
|
|
231
|
+
if (this.options?.tableLayout === 'fixed') {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
220
234
|
this.scrollContainerWidth = getAccurateClientWidth(entry.target);
|
|
221
235
|
this.scrollContainerHeight = getAccurateClientHeight(entry.target);
|
|
222
236
|
|
|
@@ -300,7 +314,7 @@ function _resizeColumnAuto(column, delta) {
|
|
|
300
314
|
const position = this.options?.handlePosition ?? 'left';
|
|
301
315
|
let growingColumn;
|
|
302
316
|
if (position === 'right') {
|
|
303
|
-
growingColumn = isDraggingRight ? columns.next(column)
|
|
317
|
+
growingColumn = isDraggingRight ? column : columns.next(column);
|
|
304
318
|
} else {
|
|
305
319
|
growingColumn = isDraggingRight ? columns.previous(column) : column;
|
|
306
320
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/column-resizing/plugin.ts"],"sourcesContent":["import { cached, tracked } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { isDestroyed, isDestroying } from '@ember/destroyable';\nimport { action } from '@ember/object';\n\nimport { preferences } from '../../plugins/index.ts';\n\nimport { BasePlugin, columns, meta, options } from '../-private/base.ts';\nimport { applyStyles } from '../-private/utils.ts';\nimport {\n getAccurateClientHeight,\n getAccurateClientWidth,\n totalGapOf,\n} from './utils.ts';\n\nimport type { ColumnApi, PluginPreferences } from '../../plugins/index.ts';\nimport type { Column, Table } from '../../index.ts';\n\ninterface ColumnResizePreferences extends PluginPreferences {\n columns: {\n [columnKey: string]: {\n width?: number;\n };\n };\n}\n\ndeclare module '@universal-ember/table/plugins' {\n interface Registry {\n ColumnResizing?: ColumnResizePreferences;\n }\n}\n\nexport interface ColumnOptions {\n /**\n * Force a starting width\n * This may not be less than the minWidth\n */\n width?: number;\n /**\n * Default: 128px\n */\n minWidth?: number;\n /**\n * Flip if the column is resizable or not.\n * The default is whatever the table's plugin option is set to\n * (and then yet again true, if not set at all)\n */\n isResizable?: boolean;\n}\n\nexport interface TableOptions {\n /**\n * Toggle whether the table is able to be resized at all\n *\n * default :true\n */\n enabled?: boolean;\n\n /**\n * By default, each column's \"handle\" position is on the\n * left-hand side of the column.\n *\n * If, for style-reasons, you want to move it to the right,\n * this option should reflect that so that the calculations can be\n * updated to match the expected behavior of which column(s) grow/shrink\n *\n * Valid values are 'left' or 'right'\n */\n handlePosition?: string;\n\n /**\n * Specify the table layout strategy for column resizing.\n *\n * - 'auto': Uses complex redistribution logic where resizing one column\n * affects neighboring columns (default, preserves existing behavior)\n * - 'fixed': Simple per-column resizing suitable for CSS table-layout: fixed\n *\n * Valid values are 'auto' or 'fixed'\n *\n * default: 'auto'\n */\n tableLayout?: string;\n}\n\ninterface Signature {\n Meta: {\n Column: ColumnMeta;\n Table: TableMeta;\n };\n Options: {\n Plugin: TableOptions;\n Column: ColumnOptions;\n };\n}\n\n/**\n * One instance of a plugin exists per table\n * but a plugin can have a \"Meta\" for each column\n */\nexport class ColumnResizing extends BasePlugin<Signature> {\n name = 'column-resizing';\n static features = ['columnWidth'];\n\n meta = {\n column: ColumnMeta,\n table: TableMeta,\n };\n\n headerCellModifier = (element: HTMLElement, { column }: ColumnApi) => {\n const columnMeta = meta.forColumn(column, ColumnResizing);\n\n element.setAttribute('data-test-is-resizable', `${columnMeta.isResizable}`);\n\n applyStyles(element, columnMeta.style);\n };\n\n /**\n * This is what ends up calling resize when the browser changes\n * (assuming that the containing element's styles stretch to fill the space)\n *\n * Later, when container queries are more broadly supported, we'll want to watch\n * the container instead of the window to prevent unneeded updates (as a window can change\n * size without the container changing size)\n */\n containerModifier = resizeObserver;\n\n reset() {\n preferences.forAllColumns(this.table, ColumnResizing).delete('width');\n }\n}\n\nconst DEFAULT_COLUMN_OPTIONS = {\n minWidth: 128,\n};\n\nconst ALLOWED_COLUMN_OPTIONS = ['minWidth', 'width', 'isResizable'];\n\n/**\n * @private\n *\n * Contains resizable information for a particular column\n */\nexport class ColumnMeta {\n constructor(private column: Column) {}\n\n @tracked _width?: number;\n @tracked isResizing = false;\n\n get tableMeta() {\n return meta.forTable(this.column.table, ColumnResizing);\n }\n\n @cached\n get options() {\n const columnOptions = options.forColumn(this.column, ColumnResizing);\n const filteredOptions = Object.entries(columnOptions || {}).reduce(\n (result, [k, v]) => {\n if (ALLOWED_COLUMN_OPTIONS.includes(k)) {\n result[k] = v;\n }\n\n return result;\n },\n {} as Record<string, unknown>,\n ) as ColumnOptions;\n\n return {\n ...DEFAULT_COLUMN_OPTIONS,\n ...filteredOptions,\n };\n }\n\n get key() {\n return this.column.key;\n }\n\n get minWidth() {\n return this.options.minWidth;\n }\n\n get initialWidth() {\n const savedWidth = preferences\n .forColumn(this.column, ColumnResizing)\n .get('width');\n\n if (!savedWidth) {\n return this.options.width;\n }\n\n if (typeof savedWidth !== 'string') {\n assert(\n 'saved width must be a number or string',\n typeof savedWidth === 'number',\n );\n return savedWidth;\n }\n\n return parseInt(savedWidth, 10);\n }\n\n get canShrink() {\n return this.width && this.width > this.minWidth;\n }\n\n get roomToShrink() {\n return this.width ? this.width - this.minWidth : 0;\n }\n\n get isResizable() {\n return this.options.isResizable ?? this.tableMeta.isResizable;\n }\n\n get hasResizeHandle() {\n const previous = columns.previous(this.column);\n\n if (!previous) return false;\n\n return (\n this.isResizable && meta.forColumn(previous, ColumnResizing).isResizable\n );\n }\n\n get width() {\n let width = this._width ?? this.initialWidth;\n\n if (!width) {\n const { defaultColumnWidth } = this.tableMeta;\n\n width = defaultColumnWidth\n ? Math.max(defaultColumnWidth, this.minWidth)\n : this.minWidth;\n }\n\n return width;\n }\n\n set width(value) {\n this._width = value;\n }\n\n get style() {\n const styles: Partial<Pick<CSSStyleDeclaration, 'width' | 'minWidth'>> = {};\n\n if (this.width) styles.width = `${this.width}px`;\n if (this.minWidth) styles.minWidth = `${this.minWidth}px`;\n\n return styles;\n }\n\n @action\n resize(delta: number) {\n this.tableMeta.resizeColumn(this.column, delta);\n }\n\n @action\n save() {\n this.tableMeta.saveColWidths(this.tableMeta.visibleColumnMetas);\n }\n}\n\n/**\n * @private\n *\n * individual column width must exclude:\n * - padding\n * - margin\n * - gap (partial)\n * - any other positioning offsets\n *\n * Otherwise the table will infinitely resize itself\n */\nfunction distributeDelta(delta: number, visibleColumns: Column[]) {\n if (delta === 0) return;\n\n const metas = visibleColumns.map((column) =>\n meta.forColumn(column, ColumnResizing),\n );\n\n const resizableMetas = metas.filter(\n (meta) => meta.isResizable && (delta < 0 ? meta.canShrink : true),\n );\n\n const columnDelta = delta / resizableMetas.length;\n\n for (const meta of resizableMetas) {\n assert('cannot resize a column that does not have a width', meta.width);\n meta.width = Math.max(meta.width + columnDelta, meta.minWidth);\n }\n}\n\n/**\n * @private\n *\n * Contains resizable and width information regarding the table as a whole\n */\nexport class TableMeta {\n constructor(private table: Table) {}\n\n @tracked scrollContainerHeight?: number;\n @tracked scrollContainerWidth?: number;\n\n get options() {\n return options.forTable(this.table, ColumnResizing);\n }\n\n get isResizable() {\n return this.options?.enabled ?? true;\n }\n\n get defaultColumnWidth() {\n if (!this.scrollContainerWidth) return;\n\n return (\n (this.scrollContainerWidth - this.totalInitialColumnWidths) /\n this.columnsWithoutInitialWidth.length\n );\n }\n\n get #availableColumns() {\n return columns.for(this.table, ColumnResizing);\n }\n\n get visibleColumnMetas() {\n return this.#availableColumns.map((column) =>\n meta.forColumn(column, ColumnResizing),\n );\n }\n\n get totalInitialColumnWidths() {\n return this.visibleColumnMetas.reduce(\n (acc, meta) => (acc += meta.initialWidth ?? 0),\n 0,\n );\n }\n\n get columnsWithoutInitialWidth() {\n return this.visibleColumnMetas.filter((meta) => !meta.initialWidth);\n }\n\n get totalVisibleColumnsWidth() {\n return this.visibleColumnMetas.reduce(\n (acc, column) => (acc += column.width ?? 0),\n 0,\n );\n }\n\n @action\n saveColWidths(visibleColumnMetas: ColumnMeta[]) {\n const tablePrefs = this.table.preferences;\n\n for (const column of visibleColumnMetas) {\n const existing = tablePrefs.storage.forPlugin('ColumnResizing');\n const columnPrefs = existing.forColumn(column.key);\n\n columnPrefs.set('width', column.width.toString());\n }\n\n tablePrefs.persist();\n }\n\n @action\n reset() {\n if (!this.scrollContainerWidth) return;\n\n for (const column of this.visibleColumnMetas) {\n column._width = undefined;\n }\n }\n\n @action\n onTableResize(entry: ResizeObserverEntry) {\n assert(\n 'scroll container element must be an HTMLElement',\n entry.target instanceof HTMLElement,\n );\n\n this.scrollContainerWidth = getAccurateClientWidth(entry.target);\n this.scrollContainerHeight = getAccurateClientHeight(entry.target);\n\n // TODO: extract this to card-list and remove it from the plugin\n // card-list will provide its own column-resizing plugin\n // by sub-classing this one, and defining its own way of calculating the \"diff\"\n const totalGap = totalGapOf(entry.target.querySelector('[role=\"row\"]'));\n const diff =\n this.scrollContainerWidth - this.totalVisibleColumnsWidth - totalGap;\n\n distributeDelta(diff, this.#availableColumns);\n }\n\n @action\n resizeColumn<DataType = unknown>(column: Column<DataType>, delta: number) {\n if (delta === 0) return;\n\n const tableLayout = this.options?.tableLayout ?? 'auto';\n\n if (tableLayout === 'fixed') {\n this.#resizeColumnFixed(column, delta);\n } else {\n this.#resizeColumnAuto(column, delta);\n }\n }\n\n /**\n * Simple column resizing for table-layout: fixed\n * Only affects the target column and respects minimum width\n */\n #resizeColumnFixed<DataType = unknown>(\n column: Column<DataType>,\n delta: number,\n ) {\n const columnMeta = meta.forColumn(column, ColumnResizing);\n const newWidth = columnMeta.width + delta;\n\n if (newWidth >= columnMeta.minWidth) {\n columnMeta.width = newWidth;\n }\n }\n\n /**\n * Complex column resizing with redistribution logic\n * Preserves existing behavior for table-layout: auto\n */\n #resizeColumnAuto<DataType = unknown>(\n column: Column<DataType>,\n delta: number,\n ) {\n /**\n * When the delta is negative, we are dragging to the next\n * when positive, we are dragging to the right\n * when dragging to the right, we want to grow the column\n * when dragging to the left, we grow the \"next\" column,\n * which shrinks the column we're dragging\n *\n * This assumes the resize handle for any column is on the right-hand\n * side of the column header\n *\n * If the resize handle were on the left-hand side of the column header\n * we'd want the column.next to be column.previous\n *\n * This is CSS dependent, and can be configured in plugin\n * options\n */\n const isDraggingRight = delta > 0;\n const position = this.options?.handlePosition ?? 'left';\n\n let growingColumn: Column<DataType> | null | undefined;\n\n if (position === 'right') {\n growingColumn = isDraggingRight ? columns.next(column) : column;\n } else {\n growingColumn = isDraggingRight ? columns.previous(column) : column;\n }\n\n if (!growingColumn) return;\n\n const growingColumnMeta = meta.forColumn(growingColumn, ColumnResizing);\n\n assert(\n 'cannot resize a column that does not have a width',\n growingColumnMeta.width,\n );\n\n const shrinkableColumns =\n delta > 0\n ? columns.after(growingColumn)\n : columns.before(growingColumn).reverse();\n\n const shrinkableColumnsMetas = shrinkableColumns\n .map((column) => meta.forColumn(column, ColumnResizing))\n .filter((meta) => meta.canShrink);\n\n let remainder = Math.abs(delta);\n\n while (shrinkableColumnsMetas.length > 0) {\n const shrinkingColumnMeta = shrinkableColumnsMetas.shift();\n\n assert(\n 'cannot resize a column that does not have a width',\n shrinkingColumnMeta?.width,\n );\n\n const actualDelta = Math.min(remainder, shrinkingColumnMeta.roomToShrink);\n\n growingColumnMeta.width += actualDelta;\n shrinkingColumnMeta.width -= actualDelta;\n remainder -= actualDelta;\n }\n }\n}\n\n/**\n * @private\n * included in the same file as the plugin due to circular dependency\n *\n * This goes on the containing element\n *\n * @example\n * ```hbs\n * <div {{resizeObserver @table}}>\n * <table>\n * ```\n */\nfunction resizeObserver(element: HTMLElement, table: Table) {\n const observer = getObserver(element, table);\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n };\n}\n\nconst CACHE = new WeakMap<HTMLElement, ResizeObserver>();\n\n/**\n * This is technically \"inefficient\" as you don't want too many resize\n * observers on a page, but tables are so big, that I don't see too many use cases\n * where you'd have 10+ tables on a page\n */\nfunction getObserver(element: HTMLElement, table: Table): ResizeObserver {\n let existing = CACHE.get(element);\n\n if (existing) return existing;\n\n existing = new ResizeObserver((entries: ResizeObserverEntry[]) => {\n if (isDestroyed(table) || isDestroying(table)) {\n return;\n }\n\n for (const entry of entries) {\n meta.forTable(table, ColumnResizing).onTableResize(entry);\n }\n });\n\n return existing;\n}\n"],"names":["ColumnResizing","BasePlugin","constructor","args","_defineProperty","column","ColumnMeta","table","TableMeta","element","columnMeta","meta","forColumn","setAttribute","isResizable","applyStyles","style","resizeObserver","reset","preferences","forAllColumns","delete","DEFAULT_COLUMN_OPTIONS","minWidth","ALLOWED_COLUMN_OPTIONS","_class","_initializerDefineProperty","_descriptor","_descriptor2","tableMeta","forTable","options","columnOptions","filteredOptions","Object","entries","reduce","result","k","v","includes","key","initialWidth","savedWidth","get","width","assert","parseInt","canShrink","roomToShrink","hasResizeHandle","previous","columns","_width","defaultColumnWidth","Math","max","value","styles","resize","delta","resizeColumn","save","saveColWidths","visibleColumnMetas","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","cached","getOwnPropertyDescriptor","action","distributeDelta","visibleColumns","metas","map","resizableMetas","filter","columnDelta","length","_class2","_TableMeta_brand","WeakSet","_classPrivateMethodInitSpec","_descriptor3","_descriptor4","enabled","scrollContainerWidth","totalInitialColumnWidths","columnsWithoutInitialWidth","_classPrivateGetter","_get_availableColumns","acc","totalVisibleColumnsWidth","tablePrefs","existing","storage","forPlugin","columnPrefs","set","toString","persist","undefined","onTableResize","entry","target","HTMLElement","getAccurateClientWidth","scrollContainerHeight","getAccurateClientHeight","totalGap","totalGapOf","querySelector","diff","tableLayout","_assertClassBrand","_resizeColumnFixed","call","_resizeColumnAuto","_this","for","newWidth","isDraggingRight","position","handlePosition","growingColumn","next","growingColumnMeta","shrinkableColumns","after","before","reverse","shrinkableColumnsMetas","remainder","abs","shrinkingColumnMeta","shift","actualDelta","min","observer","getObserver","observe","unobserve","CACHE","WeakMap","ResizeObserver","isDestroyed","isDestroying"],"mappings":";;;;;;;;;;AA+FA;AACA;AACA;AACA;AACO,MAAMA,cAAc,SAASC,UAAU,CAAY;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;AAAAC,IAAAA,eAAA,eACjD,iBAAiB,CAAA;AAAAA,IAAAA,eAAA,CAGjB,IAAA,EAAA,MAAA,EAAA;AACLC,MAAAA,MAAM,EAAEC,UAAU;AAClBC,MAAAA,KAAK,EAAEC;KACR,CAAA;IAAAJ,eAAA,CAAA,IAAA,EAAA,oBAAA,EAEoB,CAACK,OAAoB,EAAE;AAAEJ,MAAAA;AAAkB,KAAC,KAAK;MACpE,MAAMK,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACP,MAAM,EAAEL,cAAc,CAAC;MAEzDS,OAAO,CAACI,YAAY,CAAC,wBAAwB,EAAE,GAAGH,UAAU,CAACI,WAAW,CAAA,CAAE,CAAC;AAE3EC,MAAAA,WAAW,CAACN,OAAO,EAAEC,UAAU,CAACM,KAAK,CAAC;KACvC,CAAA;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEZ,IAAAA,eAAA,4BAQoBa,cAAc,CAAA;AAAA;AAElCC,EAAAA,KAAKA,GAAG;AACNC,IAAAA,WAAW,CAACC,aAAa,CAAC,IAAI,CAACb,KAAK,EAAEP,cAAc,CAAC,CAACqB,MAAM,CAAC,OAAO,CAAC;AACvE;AACF;AAACjB,eAAA,CA9BYJ,cAAc,EAEP,UAAA,EAAA,CAAC,aAAa,CAAC,CAAA;AA8BnC,MAAMsB,sBAAsB,GAAG;AAC7BC,EAAAA,QAAQ,EAAE;AACZ,CAAC;AAED,MA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IAAIxE,OAAO,EAAE;MAC3BxB,IAAI,CAACmB,QAAQ,CAACvB,KAAK,EAAEP,cAAc,CAAC,CAAC0G,aAAa,CAACC,KAAK,CAAC;AAC3D;AACF,GAAC,CAAC;AAEF,EAAA,OAAOT,QAAQ;AACjB;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../src/plugins/column-resizing/plugin.ts"],"sourcesContent":["import { cached, tracked } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { isDestroyed, isDestroying } from '@ember/destroyable';\nimport { action } from '@ember/object';\n\nimport { preferences } from '../../plugins/index.ts';\n\nimport { BasePlugin, columns, meta, options } from '../-private/base.ts';\nimport { applyStyles } from '../-private/utils.ts';\nimport {\n getAccurateClientHeight,\n getAccurateClientWidth,\n totalGapOf,\n} from './utils.ts';\n\nimport type { ColumnApi, PluginPreferences } from '../../plugins/index.ts';\nimport type { Column, Table } from '../../index.ts';\n\ninterface ColumnResizePreferences extends PluginPreferences {\n columns: {\n [columnKey: string]: {\n width?: number;\n };\n };\n}\n\ndeclare module '@universal-ember/table/plugins' {\n interface Registry {\n ColumnResizing?: ColumnResizePreferences;\n }\n}\n\nexport interface ColumnOptions {\n /**\n * Force a starting width\n * This may not be less than the minWidth\n */\n width?: number;\n /**\n * Default: 128px\n */\n minWidth?: number;\n /**\n * Flip if the column is resizable or not.\n * The default is whatever the table's plugin option is set to\n * (and then yet again true, if not set at all)\n */\n isResizable?: boolean;\n}\n\nexport interface TableOptions {\n /**\n * Toggle whether the table is able to be resized at all\n *\n * default :true\n */\n enabled?: boolean;\n\n /**\n * By default, each column's \"handle\" position is on the\n * left-hand side of the column.\n *\n * If, for style-reasons, you want to move it to the right,\n * this option should reflect that so that the calculations can be\n * updated to match the expected behavior of which column(s) grow/shrink\n *\n * Valid values are 'left' or 'right'\n */\n handlePosition?: string;\n\n /**\n * Specify the table layout strategy for column resizing.\n *\n * - 'auto': Uses complex redistribution logic where resizing one column\n * affects neighboring columns (default, preserves existing behavior)\n * - 'fixed': Simple per-column resizing suitable for CSS table-layout: fixed\n *\n * Valid values are 'auto' or 'fixed'\n *\n * default: 'auto'\n */\n tableLayout?: string;\n}\n\ninterface Signature {\n Meta: {\n Column: ColumnMeta;\n Table: TableMeta;\n };\n Options: {\n Plugin: TableOptions;\n Column: ColumnOptions;\n };\n}\n\n/**\n * One instance of a plugin exists per table\n * but a plugin can have a \"Meta\" for each column\n */\nexport class ColumnResizing extends BasePlugin<Signature> {\n name = 'column-resizing';\n static features = ['columnWidth'];\n\n meta = {\n column: ColumnMeta,\n table: TableMeta,\n };\n\n headerCellModifier = (element: HTMLElement, { column }: ColumnApi) => {\n const columnMeta = meta.forColumn(column, ColumnResizing);\n\n element.setAttribute('data-test-is-resizable', `${columnMeta.isResizable}`);\n\n applyStyles(element, columnMeta.style);\n };\n\n /**\n * This is what ends up calling resize when the browser changes\n * (assuming that the containing element's styles stretch to fill the space)\n *\n * Later, when container queries are more broadly supported, we'll want to watch\n * the container instead of the window to prevent unneeded updates (as a window can change\n * size without the container changing size)\n */\n containerModifier = resizeObserver;\n\n reset() {\n preferences.forAllColumns(this.table, ColumnResizing).delete('width');\n }\n}\n\nconst DEFAULT_COLUMN_OPTIONS = {\n minWidth: 128,\n};\n\nconst ALLOWED_COLUMN_OPTIONS = ['minWidth', 'width', 'isResizable'];\n\n/**\n * @private\n *\n * Contains resizable information for a particular column\n */\nexport class ColumnMeta {\n constructor(private column: Column) {}\n\n @tracked _width?: number;\n @tracked isResizing = false;\n\n get tableMeta() {\n return meta.forTable(this.column.table, ColumnResizing);\n }\n\n @cached\n get options() {\n const columnOptions = options.forColumn(this.column, ColumnResizing);\n const filteredOptions = Object.entries(columnOptions || {}).reduce(\n (result, [k, v]) => {\n if (ALLOWED_COLUMN_OPTIONS.includes(k)) {\n result[k] = v;\n }\n\n return result;\n },\n {} as Record<string, unknown>,\n ) as ColumnOptions;\n\n return {\n ...DEFAULT_COLUMN_OPTIONS,\n ...filteredOptions,\n };\n }\n\n get key() {\n return this.column.key;\n }\n\n get minWidth() {\n return this.options.minWidth;\n }\n\n get initialWidth() {\n const savedWidth = preferences\n .forColumn(this.column, ColumnResizing)\n .get('width');\n\n if (!savedWidth) {\n return this.options.width;\n }\n\n if (typeof savedWidth !== 'string') {\n assert(\n 'saved width must be a number or string',\n typeof savedWidth === 'number',\n );\n return savedWidth;\n }\n\n return parseInt(savedWidth, 10);\n }\n\n get canShrink() {\n return this.width && this.width > this.minWidth;\n }\n\n get roomToShrink() {\n return this.width ? this.width - this.minWidth : 0;\n }\n\n get isResizable() {\n return this.options.isResizable ?? this.tableMeta.isResizable;\n }\n\n get hasResizeHandle() {\n const position = this.tableMeta.options?.handlePosition ?? 'left';\n\n if (position === 'right') {\n const next = columns.next(this.column);\n if (!next) return false;\n return (\n this.isResizable && meta.forColumn(next, ColumnResizing).isResizable\n );\n } else {\n const previous = columns.previous(this.column);\n if (!previous) return false;\n return (\n this.isResizable && meta.forColumn(previous, ColumnResizing).isResizable\n );\n }\n }\n\n get width() {\n let width = this._width ?? this.initialWidth;\n\n if (!width) {\n const { defaultColumnWidth } = this.tableMeta;\n\n width = defaultColumnWidth\n ? Math.max(defaultColumnWidth, this.minWidth)\n : this.minWidth;\n }\n\n return width;\n }\n\n set width(value) {\n this._width = value;\n }\n\n get style() {\n const styles: Partial<Pick<CSSStyleDeclaration, 'width' | 'minWidth'>> = {};\n\n if (this.width) styles.width = `${this.width}px`;\n if (this.minWidth) styles.minWidth = `${this.minWidth}px`;\n\n return styles;\n }\n\n @action\n resize(delta: number) {\n this.tableMeta.resizeColumn(this.column, delta);\n }\n\n @action\n save() {\n this.tableMeta.saveColWidths(this.tableMeta.visibleColumnMetas);\n }\n}\n\n/**\n * @private\n *\n * individual column width must exclude:\n * - padding\n * - margin\n * - gap (partial)\n * - any other positioning offsets\n *\n * Otherwise the table will infinitely resize itself\n */\nfunction distributeDelta(delta: number, visibleColumns: Column[]) {\n // Use a tolerance threshold to prevent infinite resize loops from subpixel rounding\n // at different zoom levels. Treat deltas smaller than 0.5px as zero.\n if (Math.abs(delta) < 0.5) return;\n\n const metas = visibleColumns.map((column) =>\n meta.forColumn(column, ColumnResizing),\n );\n\n const resizableMetas = metas.filter(\n (meta) => meta.isResizable && (delta < 0 ? meta.canShrink : true),\n );\n\n const columnDelta = delta / resizableMetas.length;\n\n for (const meta of resizableMetas) {\n assert('cannot resize a column that does not have a width', meta.width);\n meta.width = Math.max(meta.width + columnDelta, meta.minWidth);\n }\n}\n\n/**\n * @private\n *\n * Contains resizable and width information regarding the table as a whole\n */\nexport class TableMeta {\n constructor(private table: Table) {}\n\n @tracked scrollContainerHeight?: number;\n @tracked scrollContainerWidth?: number;\n\n get options() {\n return options.forTable(this.table, ColumnResizing);\n }\n\n get isResizable() {\n return this.options?.enabled ?? true;\n }\n\n get defaultColumnWidth() {\n if (!this.scrollContainerWidth) return;\n\n return (\n (this.scrollContainerWidth - this.totalInitialColumnWidths) /\n this.columnsWithoutInitialWidth.length\n );\n }\n\n get #availableColumns() {\n return columns.for(this.table, ColumnResizing);\n }\n\n get visibleColumnMetas() {\n return this.#availableColumns.map((column) =>\n meta.forColumn(column, ColumnResizing),\n );\n }\n\n get totalInitialColumnWidths() {\n return this.visibleColumnMetas.reduce(\n (acc, meta) => (acc += meta.initialWidth ?? 0),\n 0,\n );\n }\n\n get columnsWithoutInitialWidth() {\n return this.visibleColumnMetas.filter((meta) => !meta.initialWidth);\n }\n\n get totalVisibleColumnsWidth() {\n return this.visibleColumnMetas.reduce(\n (acc, column) => (acc += column.width ?? 0),\n 0,\n );\n }\n\n @action\n saveColWidths(visibleColumnMetas: ColumnMeta[]) {\n const tablePrefs = this.table.preferences;\n\n for (const column of visibleColumnMetas) {\n const existing = tablePrefs.storage.forPlugin('ColumnResizing');\n const columnPrefs = existing.forColumn(column.key);\n\n columnPrefs.set('width', column.width.toString());\n }\n\n tablePrefs.persist();\n }\n\n @action\n reset() {\n if (!this.scrollContainerWidth) return;\n\n for (const column of this.visibleColumnMetas) {\n column._width = undefined;\n }\n }\n\n @action\n onTableResize(entry: ResizeObserverEntry) {\n assert(\n 'scroll container element must be an HTMLElement',\n entry.target instanceof HTMLElement,\n );\n\n // For fixed layout, columns have explicit widths and should not be auto-redistributed\n if (this.options?.tableLayout === 'fixed') {\n return;\n }\n\n this.scrollContainerWidth = getAccurateClientWidth(entry.target);\n this.scrollContainerHeight = getAccurateClientHeight(entry.target);\n\n // TODO: extract this to card-list and remove it from the plugin\n // card-list will provide its own column-resizing plugin\n // by sub-classing this one, and defining its own way of calculating the \"diff\"\n const totalGap = totalGapOf(entry.target.querySelector('[role=\"row\"]'));\n const diff =\n this.scrollContainerWidth - this.totalVisibleColumnsWidth - totalGap;\n\n distributeDelta(diff, this.#availableColumns);\n }\n\n @action\n resizeColumn<DataType = unknown>(column: Column<DataType>, delta: number) {\n if (delta === 0) return;\n\n const tableLayout = this.options?.tableLayout ?? 'auto';\n\n if (tableLayout === 'fixed') {\n this.#resizeColumnFixed(column, delta);\n } else {\n this.#resizeColumnAuto(column, delta);\n }\n }\n\n /**\n * Simple column resizing for table-layout: fixed\n * Only affects the target column and respects minimum width\n */\n #resizeColumnFixed<DataType = unknown>(\n column: Column<DataType>,\n delta: number,\n ) {\n const columnMeta = meta.forColumn(column, ColumnResizing);\n const newWidth = columnMeta.width + delta;\n\n if (newWidth >= columnMeta.minWidth) {\n columnMeta.width = newWidth;\n }\n }\n\n /**\n * Complex column resizing with redistribution logic\n * Preserves existing behavior for table-layout: auto\n */\n #resizeColumnAuto<DataType = unknown>(\n column: Column<DataType>,\n delta: number,\n ) {\n /**\n * When the delta is negative, we are dragging to the next\n * when positive, we are dragging to the right\n * when dragging to the right, we want to grow the column\n * when dragging to the left, we grow the \"next\" column,\n * which shrinks the column we're dragging\n *\n * This assumes the resize handle for any column is on the right-hand\n * side of the column header\n *\n * If the resize handle were on the left-hand side of the column header\n * we'd want the column.next to be column.previous\n *\n * This is CSS dependent, and can be configured in plugin\n * options\n */\n const isDraggingRight = delta > 0;\n const position = this.options?.handlePosition ?? 'left';\n\n let growingColumn: Column<DataType> | null | undefined;\n\n if (position === 'right') {\n growingColumn = isDraggingRight ? column : columns.next(column);\n } else {\n growingColumn = isDraggingRight ? columns.previous(column) : column;\n }\n\n if (!growingColumn) return;\n\n const growingColumnMeta = meta.forColumn(growingColumn, ColumnResizing);\n\n assert(\n 'cannot resize a column that does not have a width',\n growingColumnMeta.width,\n );\n\n const shrinkableColumns =\n delta > 0\n ? columns.after(growingColumn)\n : columns.before(growingColumn).reverse();\n\n const shrinkableColumnsMetas = shrinkableColumns\n .map((column) => meta.forColumn(column, ColumnResizing))\n .filter((meta) => meta.canShrink);\n\n let remainder = Math.abs(delta);\n\n while (shrinkableColumnsMetas.length > 0) {\n const shrinkingColumnMeta = shrinkableColumnsMetas.shift();\n\n assert(\n 'cannot resize a column that does not have a width',\n shrinkingColumnMeta?.width,\n );\n\n const actualDelta = Math.min(remainder, shrinkingColumnMeta.roomToShrink);\n\n growingColumnMeta.width += actualDelta;\n shrinkingColumnMeta.width -= actualDelta;\n remainder -= actualDelta;\n }\n }\n}\n\n/**\n * @private\n * included in the same file as the plugin due to circular dependency\n *\n * This goes on the containing element\n *\n * @example\n * ```hbs\n * <div {{resizeObserver @table}}>\n * <table>\n * ```\n */\nfunction resizeObserver(element: HTMLElement, table: Table) {\n const observer = getObserver(element, table);\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n };\n}\n\nconst CACHE = new WeakMap<HTMLElement, ResizeObserver>();\n\n/**\n * This is technically \"inefficient\" as you don't want too many resize\n * observers on a page, but tables are so big, that I don't see too many use cases\n * where you'd have 10+ tables on a page\n */\nfunction getObserver(element: HTMLElement, table: Table): ResizeObserver {\n let existing = CACHE.get(element);\n\n if (existing) return existing;\n\n existing = new ResizeObserver((entries: ResizeObserverEntry[]) => {\n if (isDestroyed(table) || isDestroying(table)) {\n return;\n }\n\n for (const entry of entries) {\n meta.forTable(table, ColumnResizing).onTableResize(entry);\n }\n });\n\n return existing;\n}\n"],"names":["ColumnResizing","BasePlugin","constructor","args","_defineProperty","column","ColumnMeta","table","TableMeta","element","columnMeta","meta","forColumn","setAttribute","isResizable","applyStyles","style","resizeObserver","reset","preferences","forAllColumns","delete","DEFAULT_COLUMN_OPTIONS","minWidth","ALLOWED_COLUMN_OPTIONS","_class","_initializerDefineProperty","_descriptor","_descriptor2","tableMeta","forTable","options","columnOptions","filteredOptions","Object","entries","reduce","result","k","v","includes","key","initialWidth","savedWidth","get","width","assert","parseInt","canShrink","roomToShrink","hasResizeHandle","position","handlePosition","next","columns","previous","_width","defaultColumnWidth","Math","max","value","styles","resize","delta","resizeColumn","save","saveColWidths","visibleColumnMetas","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","cached","getOwnPropertyDescriptor","action","distributeDelta","visibleColumns","abs","metas","map","resizableMetas","filter","columnDelta","length","_class2","_TableMeta_brand","WeakSet","_classPrivateMethodInitSpec","_descriptor3","_descriptor4","enabled","scrollContainerWidth","totalInitialColumnWidths","columnsWithoutInitialWidth","_classPrivateGetter","_get_availableColumns","acc","totalVisibleColumnsWidth","tablePrefs","existing","storage","forPlugin","columnPrefs","set","toString","persist","undefined","onTableResize","entry","target","HTMLElement","tableLayout","getAccurateClientWidth","scrollContainerHeight","getAccurateClientHeight","totalGap","totalGapOf","querySelector","diff","_assertClassBrand","_resizeColumnFixed","call","_resizeColumnAuto","_this","for","newWidth","isDraggingRight","growingColumn","growingColumnMeta","shrinkableColumns","after","before","reverse","shrinkableColumnsMetas","remainder","shrinkingColumnMeta","shift","actualDelta","min","observer","getObserver","observe","unobserve","CACHE","WeakMap","ResizeObserver","isDestroyed","isDestroying"],"mappings":";;;;;;;;;;AA+FA;AACA;AACA;AACA;AACO,MAAMA,cAAc,SAASC,UAAU,CAAY;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;AAAAC,IAAAA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C,cAAc,CAAEjH,OAA8B,IAAK;IAChE,IAAIkH,WAAW,CAAC9I,KAAK,CAAC,IAAI+I,YAAY,CAAC/I,KAAK,CAAC,EAAE;AAC7C,MAAA;AACF;AAEA,IAAA,KAAK,MAAMwG,KAAK,IAAI5E,OAAO,EAAE;MAC3BxB,IAAI,CAACmB,QAAQ,CAACvB,KAAK,EAAEP,cAAc,CAAC,CAAC8G,aAAa,CAACC,KAAK,CAAC;AAC3D;AACF,GAAC,CAAC;AAEF,EAAA,OAAOT,QAAQ;AACjB;;;;"}
|
package/package.json
CHANGED
package/src/-private/column.ts
CHANGED
|
@@ -57,7 +57,11 @@ export class Column<T = unknown> {
|
|
|
57
57
|
|
|
58
58
|
@action
|
|
59
59
|
getOptionsForRow(row: Row<T>) {
|
|
60
|
-
const
|
|
60
|
+
const configuredDefault = this.table.config.defaultCellValue;
|
|
61
|
+
const defaults = {
|
|
62
|
+
[DEFAULT_VALUE_KEY]:
|
|
63
|
+
configuredDefault !== undefined ? configuredDefault : DEFAULT_VALUE,
|
|
64
|
+
};
|
|
61
65
|
|
|
62
66
|
return {
|
|
63
67
|
...defaults,
|
|
@@ -90,6 +90,20 @@ export interface TableConfig<DataType> {
|
|
|
90
90
|
meta?: TableMeta;
|
|
91
91
|
pagination?: Pagination;
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Default value to display in cells when the data is empty/missing.
|
|
95
|
+
* If not specified, defaults to '--'.
|
|
96
|
+
*
|
|
97
|
+
* Can be overridden per-column via the column's options.defaultValue.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```js
|
|
101
|
+
* defaultCellValue: '' // show empty string instead of '--'
|
|
102
|
+
* defaultCellValue: 'N/A' // show 'N/A'
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
defaultCellValue?: string;
|
|
106
|
+
|
|
93
107
|
/**
|
|
94
108
|
* Foundational to tables is how to store settings within them.
|
|
95
109
|
* The `key` is meant to identify a particular kind of table. For example, if
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { meta } from '../-private/base.ts';
|
|
2
2
|
import { ColumnReordering } from './plugin.ts';
|
|
3
3
|
|
|
4
|
-
import type { ColumnOrder } from './plugin.ts';
|
|
4
|
+
import type { ColumnOrder, TableMeta } from './plugin.ts';
|
|
5
5
|
import type { Column, Table } from '../../index.ts';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -23,8 +23,16 @@ export const moveRight = <DataType = unknown>(column: Column<DataType>) =>
|
|
|
23
23
|
*/
|
|
24
24
|
export const setColumnOrder = <DataType = unknown>(
|
|
25
25
|
table: Table<DataType>,
|
|
26
|
-
order: ColumnOrder
|
|
27
|
-
) =>
|
|
26
|
+
order: ColumnOrder<DataType>,
|
|
27
|
+
) => {
|
|
28
|
+
// Note: The meta.forTable API doesn't preserve the DataType generic from the table parameter.
|
|
29
|
+
// We use a type assertion here to match the expected types.
|
|
30
|
+
const tableMeta = meta.forTable(
|
|
31
|
+
table,
|
|
32
|
+
ColumnReordering,
|
|
33
|
+
) as TableMeta<DataType>;
|
|
34
|
+
return tableMeta.setOrder(order);
|
|
35
|
+
};
|
|
28
36
|
|
|
29
37
|
/**
|
|
30
38
|
* Ask if the column cannot move to the left
|
|
@@ -55,3 +63,34 @@ export const canMoveRight = <DataType = unknown>(column: Column<DataType>) =>
|
|
|
55
63
|
// Prefer this if available:
|
|
56
64
|
// meta.forColumn(column, ColumnReordering).canMoveRight
|
|
57
65
|
!meta.forColumn(column, ColumnReordering).cannotMoveRight;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get the columns in their current display order.
|
|
69
|
+
*
|
|
70
|
+
* This returns an array of columns sorted according to any reordering
|
|
71
|
+
* that has been applied via the ColumnReordering plugin. If no reordering
|
|
72
|
+
* has been applied, columns are returned in their original order.
|
|
73
|
+
*
|
|
74
|
+
* @param table - The table instance to get ordered columns from
|
|
75
|
+
* @returns Array of columns in their current display order
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { orderedColumnsFor } from '@universal-ember/table/plugins/column-reordering';
|
|
80
|
+
*
|
|
81
|
+
* const columns = orderedColumnsFor(table);
|
|
82
|
+
* // Use the ordered columns for rendering or other operations
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export const orderedColumnsFor = <DataType = unknown>(
|
|
86
|
+
table: Table<DataType>,
|
|
87
|
+
): Column<DataType>[] => {
|
|
88
|
+
// Note: The meta.forTable API doesn't preserve the DataType generic from the table parameter.
|
|
89
|
+
// This is a limitation of the current plugin meta system architecture.
|
|
90
|
+
// We use a type assertion here because we know the columns come from the same table.
|
|
91
|
+
const tableMeta = meta.forTable(
|
|
92
|
+
table,
|
|
93
|
+
ColumnReordering,
|
|
94
|
+
) as TableMeta<DataType>;
|
|
95
|
+
return tableMeta.columnOrder.orderedColumns;
|
|
96
|
+
};
|
|
@@ -51,11 +51,14 @@ export class ColumnReordering extends BasePlugin<Signature> {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export class ColumnMeta {
|
|
55
|
-
constructor(private column: Column) {}
|
|
56
|
-
|
|
57
|
-
get #tableMeta() {
|
|
58
|
-
return meta.forTable(
|
|
54
|
+
export class ColumnMeta<DataType = unknown> {
|
|
55
|
+
constructor(private column: Column<DataType>) {}
|
|
56
|
+
|
|
57
|
+
get #tableMeta(): TableMeta<DataType> {
|
|
58
|
+
return meta.forTable(
|
|
59
|
+
this.column.table,
|
|
60
|
+
ColumnReordering,
|
|
61
|
+
) as TableMeta<DataType>;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
get position() {
|
|
@@ -101,8 +104,8 @@ export class ColumnMeta {
|
|
|
101
104
|
};
|
|
102
105
|
}
|
|
103
106
|
|
|
104
|
-
export class TableMeta {
|
|
105
|
-
constructor(private table: Table) {}
|
|
107
|
+
export class TableMeta<DataType = unknown> {
|
|
108
|
+
constructor(private table: Table<DataType>) {}
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
111
|
* @private
|
|
@@ -113,7 +116,7 @@ export class TableMeta {
|
|
|
113
116
|
* This is also why the order of the columns is maintained via column key
|
|
114
117
|
*/
|
|
115
118
|
@tracked
|
|
116
|
-
columnOrder = new ColumnOrder({
|
|
119
|
+
columnOrder = new ColumnOrder<DataType>({
|
|
117
120
|
columns: () => this.allColumns,
|
|
118
121
|
visibleColumns: () => this.visibleColumns,
|
|
119
122
|
save: this.save,
|
|
@@ -124,7 +127,7 @@ export class TableMeta {
|
|
|
124
127
|
* Get the curret order/position of a column
|
|
125
128
|
*/
|
|
126
129
|
@action
|
|
127
|
-
getPosition
|
|
130
|
+
getPosition(column: Column<DataType>) {
|
|
128
131
|
return this.columnOrder.get(column.key);
|
|
129
132
|
}
|
|
130
133
|
|
|
@@ -132,17 +135,14 @@ export class TableMeta {
|
|
|
132
135
|
* Swap the column with the column at `newPosition`
|
|
133
136
|
*/
|
|
134
137
|
@action
|
|
135
|
-
setPosition<DataType
|
|
136
|
-
column: Column<DataType>,
|
|
137
|
-
newPosition: number,
|
|
138
|
-
) {
|
|
138
|
+
setPosition(column: Column<DataType>, newPosition: number) {
|
|
139
139
|
return this.columnOrder.swapWith(column.key, newPosition);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* Using a `ColumnOrder` instance, set the order of all columns
|
|
144
144
|
*/
|
|
145
|
-
setOrder = (order: ColumnOrder) => {
|
|
145
|
+
setOrder = (order: ColumnOrder<DataType>) => {
|
|
146
146
|
this.columnOrder.setAll(order.map);
|
|
147
147
|
};
|
|
148
148
|
|
|
@@ -153,7 +153,7 @@ export class TableMeta {
|
|
|
153
153
|
@action
|
|
154
154
|
reset() {
|
|
155
155
|
preferences.forTable(this.table, ColumnReordering).delete('order');
|
|
156
|
-
this.columnOrder = new ColumnOrder({
|
|
156
|
+
this.columnOrder = new ColumnOrder<DataType>({
|
|
157
157
|
columns: () => this.allColumns,
|
|
158
158
|
visibleColumns: () => this.visibleColumns,
|
|
159
159
|
save: this.save,
|
|
@@ -217,7 +217,7 @@ export class TableMeta {
|
|
|
217
217
|
* @private
|
|
218
218
|
* Used for keeping track of and updating column order
|
|
219
219
|
*/
|
|
220
|
-
export class ColumnOrder {
|
|
220
|
+
export class ColumnOrder<DataType = unknown> {
|
|
221
221
|
/**
|
|
222
222
|
* This map will be empty until we re-order something.
|
|
223
223
|
*/
|
|
@@ -237,7 +237,7 @@ export class ColumnOrder {
|
|
|
237
237
|
* - Provide `visibleColumns` to indicate which are visible
|
|
238
238
|
* - Hidden columns maintain their position when toggled
|
|
239
239
|
*/
|
|
240
|
-
columns: () => Column[];
|
|
240
|
+
columns: () => Column<DataType>[];
|
|
241
241
|
/**
|
|
242
242
|
* Optional: Record of which columns are currently visible.
|
|
243
243
|
* When provided, moveLeft/moveRight will skip over hidden columns.
|
|
@@ -496,37 +496,33 @@ export class ColumnOrder {
|
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
@cached
|
|
499
|
-
get orderedColumns(): Column[] {
|
|
499
|
+
get orderedColumns(): Column<DataType>[] {
|
|
500
500
|
const allColumns = this.args.columns();
|
|
501
501
|
const columnsByKey = allColumns.reduce(
|
|
502
502
|
(keyMap, column) => {
|
|
503
503
|
keyMap[column.key] = column;
|
|
504
504
|
return keyMap;
|
|
505
505
|
},
|
|
506
|
-
{} as Record<string, Column
|
|
506
|
+
{} as Record<string, Column<DataType>>,
|
|
507
507
|
);
|
|
508
508
|
const mergedOrder = orderOf(allColumns, this.map);
|
|
509
509
|
|
|
510
|
-
const result: Column[] = Array.from({
|
|
510
|
+
const result: Column<DataType>[] = Array.from({
|
|
511
|
+
length: allColumns.length,
|
|
512
|
+
});
|
|
511
513
|
|
|
512
514
|
for (const [key, position] of mergedOrder.entries()) {
|
|
513
515
|
const column = columnsByKey[key];
|
|
514
516
|
|
|
515
|
-
|
|
517
|
+
// Skip columns that no longer exist (they've been removed from the columns array)
|
|
518
|
+
if (!column) {
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
|
|
516
522
|
result[position] = column;
|
|
517
523
|
}
|
|
518
524
|
|
|
519
|
-
|
|
520
|
-
`Generated orderedColumns' length (${result.filter(Boolean).length}) ` +
|
|
521
|
-
`does not match the length of all columns (${allColumns.length}). ` +
|
|
522
|
-
`orderedColumns: ${result
|
|
523
|
-
.filter(Boolean)
|
|
524
|
-
.map((c) => c.key)
|
|
525
|
-
.join(', ')} -- ` +
|
|
526
|
-
`all columns: ${allColumns.map((c) => c.key).join(', ')}`,
|
|
527
|
-
result.filter(Boolean).length === allColumns.length,
|
|
528
|
-
);
|
|
529
|
-
|
|
525
|
+
// Filter out undefined entries (from removed columns or gaps in positions)
|
|
530
526
|
return result.filter(Boolean);
|
|
531
527
|
}
|
|
532
528
|
}
|
|
@@ -5,6 +5,13 @@ import { ColumnResizing } from './plugin.ts';
|
|
|
5
5
|
|
|
6
6
|
import type { Column } from '../../index.ts';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Is the column resizable?
|
|
10
|
+
* This checks if resizing is enabled for this specific column,
|
|
11
|
+
*/
|
|
12
|
+
export const isResizable = <DataType = unknown>(column: Column<DataType>) =>
|
|
13
|
+
meta.forColumn(column, ColumnResizing).isResizable;
|
|
14
|
+
|
|
8
15
|
/**
|
|
9
16
|
* The column actively being resized by the user.
|
|
10
17
|
*
|
|
@@ -211,13 +211,21 @@ export class ColumnMeta {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
get hasResizeHandle() {
|
|
214
|
-
const
|
|
214
|
+
const position = this.tableMeta.options?.handlePosition ?? 'left';
|
|
215
215
|
|
|
216
|
-
if (
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
216
|
+
if (position === 'right') {
|
|
217
|
+
const next = columns.next(this.column);
|
|
218
|
+
if (!next) return false;
|
|
219
|
+
return (
|
|
220
|
+
this.isResizable && meta.forColumn(next, ColumnResizing).isResizable
|
|
221
|
+
);
|
|
222
|
+
} else {
|
|
223
|
+
const previous = columns.previous(this.column);
|
|
224
|
+
if (!previous) return false;
|
|
225
|
+
return (
|
|
226
|
+
this.isResizable && meta.forColumn(previous, ColumnResizing).isResizable
|
|
227
|
+
);
|
|
228
|
+
}
|
|
221
229
|
}
|
|
222
230
|
|
|
223
231
|
get width() {
|
|
@@ -270,7 +278,9 @@ export class ColumnMeta {
|
|
|
270
278
|
* Otherwise the table will infinitely resize itself
|
|
271
279
|
*/
|
|
272
280
|
function distributeDelta(delta: number, visibleColumns: Column[]) {
|
|
273
|
-
|
|
281
|
+
// Use a tolerance threshold to prevent infinite resize loops from subpixel rounding
|
|
282
|
+
// at different zoom levels. Treat deltas smaller than 0.5px as zero.
|
|
283
|
+
if (Math.abs(delta) < 0.5) return;
|
|
274
284
|
|
|
275
285
|
const metas = visibleColumns.map((column) =>
|
|
276
286
|
meta.forColumn(column, ColumnResizing),
|
|
@@ -374,6 +384,11 @@ export class TableMeta {
|
|
|
374
384
|
entry.target instanceof HTMLElement,
|
|
375
385
|
);
|
|
376
386
|
|
|
387
|
+
// For fixed layout, columns have explicit widths and should not be auto-redistributed
|
|
388
|
+
if (this.options?.tableLayout === 'fixed') {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
|
|
377
392
|
this.scrollContainerWidth = getAccurateClientWidth(entry.target);
|
|
378
393
|
this.scrollContainerHeight = getAccurateClientHeight(entry.target);
|
|
379
394
|
|
|
@@ -446,7 +461,7 @@ export class TableMeta {
|
|
|
446
461
|
let growingColumn: Column<DataType> | null | undefined;
|
|
447
462
|
|
|
448
463
|
if (position === 'right') {
|
|
449
|
-
growingColumn = isDraggingRight ? columns.next(column)
|
|
464
|
+
growingColumn = isDraggingRight ? column : columns.next(column);
|
|
450
465
|
} else {
|
|
451
466
|
growingColumn = isDraggingRight ? columns.previous(column) : column;
|
|
452
467
|
}
|