@universal-ember/table 3.0.3 → 3.1.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.
Files changed (53) hide show
  1. package/declarations/plugins/column-reordering/helpers.d.ts +9 -7
  2. package/declarations/plugins/column-reordering/helpers.d.ts.map +1 -1
  3. package/declarations/plugins/column-reordering/plugin.d.ts +2 -2
  4. package/declarations/plugins/column-reordering/plugin.d.ts.map +1 -1
  5. package/declarations/plugins/column-resizing/handle.d.ts +4 -4
  6. package/declarations/plugins/column-resizing/handle.d.ts.map +1 -1
  7. package/declarations/plugins/column-resizing/helpers.d.ts +3 -3
  8. package/declarations/plugins/column-resizing/helpers.d.ts.map +1 -1
  9. package/declarations/plugins/column-resizing/plugin.d.ts +13 -1
  10. package/declarations/plugins/column-resizing/plugin.d.ts.map +1 -1
  11. package/declarations/plugins/column-visibility/helpers.d.ts +4 -4
  12. package/declarations/plugins/column-visibility/helpers.d.ts.map +1 -1
  13. package/declarations/plugins/data-sorting/helpers.d.ts +8 -8
  14. package/declarations/plugins/data-sorting/helpers.d.ts.map +1 -1
  15. package/declarations/plugins/data-sorting/plugin.d.ts +3 -3
  16. package/declarations/plugins/data-sorting/plugin.d.ts.map +1 -1
  17. package/dist/-private/-type-tests/plugin-properties.test.js +1 -1
  18. package/dist/-private/-type-tests/plugins-accessors.test.js +1 -1
  19. package/dist/-private/-type-tests/table-config.test.js +1 -1
  20. package/dist/-private/column.js +1 -1
  21. package/dist/-private/preferences.js +1 -1
  22. package/dist/-private/row.js +1 -1
  23. package/dist/-private/table.js +1 -1
  24. package/dist/{_rollupPluginBabelHelpers-BpiaYhlf.js → _rollupPluginBabelHelpers-CjaRjJZX.js} +2 -2
  25. package/dist/_rollupPluginBabelHelpers-CjaRjJZX.js.map +1 -0
  26. package/dist/plugins/-private/base.js +1 -1
  27. package/dist/plugins/column-reordering/helpers.js +11 -5
  28. package/dist/plugins/column-reordering/helpers.js.map +1 -1
  29. package/dist/plugins/column-reordering/plugin.js +1 -1
  30. package/dist/plugins/column-reordering/plugin.js.map +1 -1
  31. package/dist/plugins/column-resizing/handle.js +1 -1
  32. package/dist/plugins/column-resizing/handle.js.map +1 -1
  33. package/dist/plugins/column-resizing/helpers.js.map +1 -1
  34. package/dist/plugins/column-resizing/plugin.js +61 -38
  35. package/dist/plugins/column-resizing/plugin.js.map +1 -1
  36. package/dist/plugins/column-visibility/helpers.js.map +1 -1
  37. package/dist/plugins/column-visibility/plugin.js +1 -1
  38. package/dist/plugins/data-sorting/helpers.js.map +1 -1
  39. package/dist/plugins/data-sorting/plugin.js +1 -1
  40. package/dist/plugins/data-sorting/plugin.js.map +1 -1
  41. package/dist/plugins/metadata/plugin.js +1 -1
  42. package/dist/plugins/row-selection/plugin.js +1 -1
  43. package/dist/plugins/sticky-columns/plugin.js +1 -1
  44. package/package.json +1 -1
  45. package/src/plugins/column-reordering/helpers.ts +18 -11
  46. package/src/plugins/column-reordering/plugin.ts +5 -2
  47. package/src/plugins/column-resizing/handle.ts +6 -4
  48. package/src/plugins/column-resizing/helpers.ts +3 -3
  49. package/src/plugins/column-resizing/plugin.ts +48 -2
  50. package/src/plugins/column-visibility/helpers.ts +4 -4
  51. package/src/plugins/data-sorting/helpers.ts +8 -8
  52. package/src/plugins/data-sorting/plugin.ts +3 -3
  53. package/dist/_rollupPluginBabelHelpers-BpiaYhlf.js.map +0 -1
@@ -15,13 +15,13 @@ import type { Column } from '../../index.ts';
15
15
  * be marked as isResizing, because this is a user-scoped question:
16
16
  * "Is the user directly resizing this column?"
17
17
  */
18
- export const isResizing = (column: Column) =>
18
+ export const isResizing = <DataType = unknown>(column: Column<DataType>) =>
19
19
  meta.forColumn(column, ColumnResizing).isResizing;
20
20
 
21
21
  /**
22
22
  * Does the column have room to shrink?
23
23
  */
24
- export const canShrink = (column: Column) =>
24
+ export const canShrink = <DataType = unknown>(column: Column<DataType>) =>
25
25
  meta.forColumn(column, ColumnResizing).canShrink;
26
26
 
27
27
  /**
@@ -31,7 +31,7 @@ export const canShrink = (column: Column) =>
31
31
  * - if resizing is enabled for the whole table
32
32
  * - or if we're asking about the first column (resize handles may only be "between" columns)
33
33
  */
34
- export const hasResizeHandle = (column: Column) =>
34
+ export const hasResizeHandle = <DataType = unknown>(column: Column<DataType>) =>
35
35
  meta.forColumn(column, ColumnResizing).hasResizeHandle;
36
36
 
37
37
  /**
@@ -67,6 +67,19 @@ export interface TableOptions {
67
67
  * Valid values are 'left' or 'right'
68
68
  */
69
69
  handlePosition?: string;
70
+
71
+ /**
72
+ * Specify the table layout strategy for column resizing.
73
+ *
74
+ * - 'auto': Uses complex redistribution logic where resizing one column
75
+ * affects neighboring columns (default, preserves existing behavior)
76
+ * - 'fixed': Simple per-column resizing suitable for CSS table-layout: fixed
77
+ *
78
+ * Valid values are 'auto' or 'fixed'
79
+ *
80
+ * default: 'auto'
81
+ */
82
+ tableLayout?: string;
70
83
  }
71
84
 
72
85
  interface Signature {
@@ -375,9 +388,42 @@ export class TableMeta {
375
388
  }
376
389
 
377
390
  @action
378
- resizeColumn(column: Column, delta: number) {
391
+ resizeColumn<DataType = unknown>(column: Column<DataType>, delta: number) {
379
392
  if (delta === 0) return;
380
393
 
394
+ const tableLayout = this.options?.tableLayout ?? 'auto';
395
+
396
+ if (tableLayout === 'fixed') {
397
+ this.#resizeColumnFixed(column, delta);
398
+ } else {
399
+ this.#resizeColumnAuto(column, delta);
400
+ }
401
+ }
402
+
403
+ /**
404
+ * Simple column resizing for table-layout: fixed
405
+ * Only affects the target column and respects minimum width
406
+ */
407
+ #resizeColumnFixed<DataType = unknown>(
408
+ column: Column<DataType>,
409
+ delta: number,
410
+ ) {
411
+ const columnMeta = meta.forColumn(column, ColumnResizing);
412
+ const newWidth = columnMeta.width + delta;
413
+
414
+ if (newWidth >= columnMeta.minWidth) {
415
+ columnMeta.width = newWidth;
416
+ }
417
+ }
418
+
419
+ /**
420
+ * Complex column resizing with redistribution logic
421
+ * Preserves existing behavior for table-layout: auto
422
+ */
423
+ #resizeColumnAuto<DataType = unknown>(
424
+ column: Column<DataType>,
425
+ delta: number,
426
+ ) {
381
427
  /**
382
428
  * When the delta is negative, we are dragging to the next
383
429
  * when positive, we are dragging to the right
@@ -397,7 +443,7 @@ export class TableMeta {
397
443
  const isDraggingRight = delta > 0;
398
444
  const position = this.options?.handlePosition ?? 'left';
399
445
 
400
- let growingColumn: Column | null | undefined;
446
+ let growingColumn: Column<DataType> | null | undefined;
401
447
 
402
448
  if (position === 'right') {
403
449
  growingColumn = isDraggingRight ? columns.next(column) : column;
@@ -6,23 +6,23 @@ import type { Column } from '../../index.ts';
6
6
  /**
7
7
  * Hide a column
8
8
  */
9
- export const hide = (column: Column) =>
9
+ export const hide = <DataType = unknown>(column: Column<DataType>) =>
10
10
  meta.forColumn(column, ColumnVisibility).hide();
11
11
 
12
12
  /**
13
13
  * Show a column
14
14
  */
15
- export const show = (column: Column) =>
15
+ export const show = <DataType = unknown>(column: Column<DataType>) =>
16
16
  meta.forColumn(column, ColumnVisibility).show();
17
17
 
18
18
  /**
19
19
  * Ask if a column is presently supposed to be visible
20
20
  */
21
- export const isVisible = (column: Column) =>
21
+ export const isVisible = <DataType = unknown>(column: Column<DataType>) =>
22
22
  meta.forColumn(column, ColumnVisibility).isVisible;
23
23
 
24
24
  /**
25
25
  * Ask if a column is presently supposed to be hidden
26
26
  */
27
- export const isHidden = (column: Column) =>
27
+ export const isHidden = <DataType = unknown>(column: Column<DataType>) =>
28
28
  meta.forColumn(column, ColumnVisibility).isHidden;
@@ -6,31 +6,31 @@ import type { Column } from '../../index.ts';
6
6
  /**
7
7
  * Query a specific column's current sort direction
8
8
  */
9
- export const sortDirection = (column: Column) =>
9
+ export const sortDirection = <DataType = unknown>(column: Column<DataType>) =>
10
10
  meta.forColumn(column, Sorting).sortDirection;
11
11
 
12
12
  /**
13
13
  * Ask if a column is sortable
14
14
  */
15
- export const isSortable = (column: Column) =>
15
+ export const isSortable = <DataType = unknown>(column: Column<DataType>) =>
16
16
  meta.forColumn(column, Sorting).isSortable;
17
17
 
18
18
  /**
19
19
  * Ask if a column is ascending
20
20
  */
21
- export const isAscending = (column: Column) =>
21
+ export const isAscending = <DataType = unknown>(column: Column<DataType>) =>
22
22
  meta.forColumn(column, Sorting).isAscending;
23
23
 
24
24
  /**
25
25
  * Ask if a column is sorted descending
26
26
  */
27
- export const isDescending = (column: Column) =>
27
+ export const isDescending = <DataType = unknown>(column: Column<DataType>) =>
28
28
  meta.forColumn(column, Sorting).isDescending;
29
29
 
30
30
  /**
31
31
  * Ask if a column is not sorted
32
32
  */
33
- export const isUnsorted = (column: Column) =>
33
+ export const isUnsorted = <DataType = unknown>(column: Column<DataType>) =>
34
34
  meta.forColumn(column, Sorting).isUnsorted;
35
35
 
36
36
  /**
@@ -40,17 +40,17 @@ export const isUnsorted = (column: Column) =>
40
40
  * Ascending => None => Descending
41
41
  * ⬑ ---------- <= ---------- ↲
42
42
  */
43
- export const sort = (column: Column) =>
43
+ export const sort = <DataType = unknown>(column: Column<DataType>) =>
44
44
  meta.forTable(column.table, Sorting).handleSort(column);
45
45
 
46
46
  /**
47
47
  * Toggle a column between descending and not unsorted states
48
48
  */
49
- export const sortDescending = (column: Column) =>
49
+ export const sortDescending = <DataType = unknown>(column: Column<DataType>) =>
50
50
  meta.forTable(column.table, Sorting).toggleDescending(column);
51
51
 
52
52
  /**
53
53
  * Toggle a column between ascending and not unsorted states
54
54
  */
55
- export const sortAscending = (column: Column) =>
55
+ export const sortAscending = <DataType = unknown>(column: Column<DataType>) =>
56
56
  meta.forTable(column.table, Sorting).toggleAscending(column);
@@ -157,7 +157,7 @@ export class TableMeta {
157
157
  }
158
158
 
159
159
  @action
160
- handleSort(column: Column) {
160
+ handleSort<DataType = unknown>(column: Column<DataType>) {
161
161
  const columnMeta = meta.forColumn(column, Sorting);
162
162
 
163
163
  if (!columnMeta.sortProperty) {
@@ -184,7 +184,7 @@ export class TableMeta {
184
184
  }
185
185
 
186
186
  @action
187
- toggleAscending(column: Column) {
187
+ toggleAscending<DataType = unknown>(column: Column<DataType>) {
188
188
  const columnMeta = meta.forColumn(column, Sorting);
189
189
 
190
190
  if (!columnMeta.sortProperty) {
@@ -201,7 +201,7 @@ export class TableMeta {
201
201
  }
202
202
 
203
203
  @action
204
- toggleDescending(column: Column) {
204
+ toggleDescending<DataType = unknown>(column: Column<DataType>) {
205
205
  const columnMeta = meta.forColumn(column, Sorting);
206
206
 
207
207
  if (!columnMeta.sortProperty) {
@@ -1 +0,0 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers-BpiaYhlf.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}