From 703a6288cf143228041fbd19e1ea205b59b38f63 Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 13:12:47 +0100 Subject: [PATCH 01/16] Use generic column types in Resize-handle --- ember-headless-table/src/plugins/column-resizing/handle.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ember-headless-table/src/plugins/column-resizing/handle.ts b/ember-headless-table/src/plugins/column-resizing/handle.ts index b41d20ea..1acb1c6b 100644 --- a/ember-headless-table/src/plugins/column-resizing/handle.ts +++ b/ember-headless-table/src/plugins/column-resizing/handle.ts @@ -24,9 +24,9 @@ let waiter = buildWaiter('ColumnResizing#ResizeHandle'); * */ -class ResizeHandle extends Modifier<{ Args: { Positional: [Column] } }> { +class ResizeHandle extends Modifier<{ Args: { Positional: [Column] } }> { declare dragHandle: HTMLElement; - declare column: Column; + declare column: Column; declare meta: ColumnMeta; // Pointer @@ -45,7 +45,7 @@ class ResizeHandle extends Modifier<{ Args: { Positional: [Column] } }> { token?: unknown; isSetup = false; - modify(element: Element, [column]: [Column]) { + modify(element: Element, [column]: [Column]) { this.column = column; this.meta = meta.forColumn(column, ColumnResizing); this.dragHandle = element as HTMLElement; From 08dfb57905a0130f71074037dbd4fdc10bdec9c8 Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 13:22:01 +0100 Subject: [PATCH 02/16] 247 accept generic column type for column-resizing --- ember-headless-table/src/plugins/column-resizing/helpers.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ember-headless-table/src/plugins/column-resizing/helpers.ts b/ember-headless-table/src/plugins/column-resizing/helpers.ts index 89529eac..534b9fce 100644 --- a/ember-headless-table/src/plugins/column-resizing/helpers.ts +++ b/ember-headless-table/src/plugins/column-resizing/helpers.ts @@ -15,12 +15,12 @@ import type { Column } from '[public-types]'; * be marked as isResizing, because this is a user-scoped question: * "Is the user directly resizing this column?" */ -export const isResizing = (column: Column) => meta.forColumn(column, ColumnResizing).isResizing; +export const isResizing = (column: Column) => meta.forColumn(column, ColumnResizing).isResizing; /** * Does the column have room to shrink? */ -export const canShrink = (column: Column) => meta.forColumn(column, ColumnResizing).canShrink; +export const canShrink = (column: Column) => meta.forColumn(column, ColumnResizing).canShrink; /** * Does the column have a resize handle? @@ -29,7 +29,7 @@ export const canShrink = (column: Column) => meta.forColumn(column, ColumnResizi * - if resizing is enabled for the whole table * - or if we're asking about the first column (resize handles may only be "between" columns) */ -export const hasResizeHandle = (column: Column) => +export const hasResizeHandle = (column: Column) => meta.forColumn(column, ColumnResizing).hasResizeHandle; /** From 922dae019054e7017cb605ce8a374501b9d1868d Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 13:24:25 +0100 Subject: [PATCH 03/16] Update handle.ts to use consistent type names --- ember-headless-table/src/plugins/column-resizing/handle.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ember-headless-table/src/plugins/column-resizing/handle.ts b/ember-headless-table/src/plugins/column-resizing/handle.ts index 1acb1c6b..8d74cd81 100644 --- a/ember-headless-table/src/plugins/column-resizing/handle.ts +++ b/ember-headless-table/src/plugins/column-resizing/handle.ts @@ -24,9 +24,9 @@ let waiter = buildWaiter('ColumnResizing#ResizeHandle'); * */ -class ResizeHandle extends Modifier<{ Args: { Positional: [Column] } }> { +class ResizeHandle extends Modifier<{ Args: { Positional: [Column] } }> { declare dragHandle: HTMLElement; - declare column: Column; + declare column: Column; declare meta: ColumnMeta; // Pointer @@ -45,7 +45,7 @@ class ResizeHandle extends Modifier<{ Args: { Positional: [Column] } }> { token?: unknown; isSetup = false; - modify(element: Element, [column]: [Column]) { + modify(element: Element, [column]: [Column]) { this.column = column; this.meta = meta.forColumn(column, ColumnResizing); this.dragHandle = element as HTMLElement; From 999994652cfe872a50254d3107d808f9035ae574 Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 13:31:34 +0100 Subject: [PATCH 04/16] use generic column type in data-sorting --- .../src/plugins/data-sorting/helpers.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ember-headless-table/src/plugins/data-sorting/helpers.ts b/ember-headless-table/src/plugins/data-sorting/helpers.ts index adfafb46..4d2a324f 100644 --- a/ember-headless-table/src/plugins/data-sorting/helpers.ts +++ b/ember-headless-table/src/plugins/data-sorting/helpers.ts @@ -6,27 +6,27 @@ import type { Column } from '[public-types]'; /** * Query a specific column's current sort direction */ -export const sortDirection = (column: Column) => meta.forColumn(column, Sorting).sortDirection; +export const sortDirection = (column: Column) => meta.forColumn(column, Sorting).sortDirection; /** * Ask if a column is sortable */ -export const isSortable = (column: Column) => meta.forColumn(column, Sorting).isSortable; +export const isSortable = (column: Column) => meta.forColumn(column, Sorting).isSortable; /** * Ask if a column is ascending */ -export const isAscending = (column: Column) => meta.forColumn(column, Sorting).isAscending; +export const isAscending = (column: Column) => meta.forColumn(column, Sorting).isAscending; /** * Ask if a column is sorted descending */ -export const isDescending = (column: Column) => meta.forColumn(column, Sorting).isDescending; +export const isDescending = (column: Column) => meta.forColumn(column, Sorting).isDescending; /** * Ask if a column is not sorted */ -export const isUnsorted = (column: Column) => meta.forColumn(column, Sorting).isUnsorted; +export const isUnsorted = (column: Column) => meta.forColumn(column, Sorting).isUnsorted; /** * Sort the specified column's data using a tri-toggle. @@ -35,16 +35,16 @@ export const isUnsorted = (column: Column) => meta.forColumn(column, Sorting).is * Ascending => None => Descending * ⬑ ---------- <= ---------- ↲ */ -export const sort = (column: Column) => meta.forTable(column.table, Sorting).handleSort(column); +export const sort = (column: Column) => meta.forTable(column.table, Sorting).handleSort(column); /** * Toggle a column between descending and not unsorted states */ -export const sortDescending = (column: Column) => +export const sortDescending = (column: Column) => meta.forTable(column.table, Sorting).toggleDescending(column); /** * Toggle a column between ascending and not unsorted states */ -export const sortAscending = (column: Column) => +export const sortAscending = (column: Column) => meta.forTable(column.table, Sorting).toggleAscending(column); From 3bd3d92d326304d938ad4d12f9d7479e26ff7bde Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 13:52:46 +0100 Subject: [PATCH 05/16] 247 generic data type for data-sorting --- ember-headless-table/src/plugins/data-sorting/plugin.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ember-headless-table/src/plugins/data-sorting/plugin.ts b/ember-headless-table/src/plugins/data-sorting/plugin.ts index 2002065d..0b44a225 100644 --- a/ember-headless-table/src/plugins/data-sorting/plugin.ts +++ b/ember-headless-table/src/plugins/data-sorting/plugin.ts @@ -131,8 +131,8 @@ export class ColumnMeta { } } -export class TableMeta { - constructor(private table: Table) {} +export class TTableMeta { + constructor(private table: Table) {} @cached get options() { @@ -152,7 +152,7 @@ export class TableMeta { } @action - handleSort(column: Column) { + handleSort(column: Column) { let columnMeta = meta.forColumn(column, Sorting); if (!columnMeta.sortProperty) { @@ -169,7 +169,7 @@ export class TableMeta { } @action - toggleAscending(column: Column) { + toggleAscending(column: Column) { let columnMeta = meta.forColumn(column, Sorting); if (!columnMeta.sortProperty) { From 2dc68fe69e6a81bdc5772ca2234f5cdc1820bb0d Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 13:53:48 +0100 Subject: [PATCH 06/16] 247 typo --- ember-headless-table/src/plugins/data-sorting/plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ember-headless-table/src/plugins/data-sorting/plugin.ts b/ember-headless-table/src/plugins/data-sorting/plugin.ts index 0b44a225..76cb7dde 100644 --- a/ember-headless-table/src/plugins/data-sorting/plugin.ts +++ b/ember-headless-table/src/plugins/data-sorting/plugin.ts @@ -131,7 +131,7 @@ export class ColumnMeta { } } -export class TTableMeta { +export class TableMeta { constructor(private table: Table) {} @cached From ce5c7e4004b360a08c39486c4e38093ccdf3edc8 Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 14:05:06 +0100 Subject: [PATCH 07/16] 247 generic data type for Column --- ember-headless-table/src/plugins/metadata/helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ember-headless-table/src/plugins/metadata/helpers.ts b/ember-headless-table/src/plugins/metadata/helpers.ts index aea4eefa..7aa3d464 100644 --- a/ember-headless-table/src/plugins/metadata/helpers.ts +++ b/ember-headless-table/src/plugins/metadata/helpers.ts @@ -3,10 +3,10 @@ import { Metadata } from './plugin'; import type { Column, Table } from '[public-types]'; -export const forColumn = (column: Column, key: string) => { +export const forColumn = (column: Column, key: string) => { return options.forColumn(column, Metadata)[key]; }; -export const forTable = (table: Table, key: string) => { +export const forTable = (table: Table, key: string) => { return options.forTable(table, Metadata)[key]; }; From f164b8810d6c000b19a99aef8cc3f37f6b513ad5 Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 14:25:49 +0100 Subject: [PATCH 08/16] 247 generic-column-types --- ember-headless-table/src/plugins/data-sorting/plugin.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ember-headless-table/src/plugins/data-sorting/plugin.ts b/ember-headless-table/src/plugins/data-sorting/plugin.ts index 76cb7dde..cca576dd 100644 --- a/ember-headless-table/src/plugins/data-sorting/plugin.ts +++ b/ember-headless-table/src/plugins/data-sorting/plugin.ts @@ -22,8 +22,8 @@ declare module 'ember-headless-table/plugins' { export interface Signature { Meta: { - Column: ColumnMeta; - Table: TableMeta; + Column: ColumnMeta; + Table: TableMeta; }; Options: { Plugin: Options; @@ -92,8 +92,8 @@ export class Sorting extends BasePlugin> }; } -export class ColumnMeta { - constructor(private column: Column) {} +export class ColumnMeta { + constructor(private column: Column) {} @cached get options() { From 10a9e268dc6df4e2ae12fd844b5379f74baff1b7 Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 14:56:40 +0100 Subject: [PATCH 09/16] 247 revert generic column type on sort helper until I understand why the generics aren't handled correctly in forTable `handleSort` --- ember-headless-table/src/plugins/data-sorting/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ember-headless-table/src/plugins/data-sorting/helpers.ts b/ember-headless-table/src/plugins/data-sorting/helpers.ts index 4d2a324f..409f59f8 100644 --- a/ember-headless-table/src/plugins/data-sorting/helpers.ts +++ b/ember-headless-table/src/plugins/data-sorting/helpers.ts @@ -35,7 +35,7 @@ export const isUnsorted = (column: Column) => meta * Ascending => None => Descending * ⬑ ---------- <= ---------- ↲ */ -export const sort = (column: Column) => meta.forTable(column.table, Sorting).handleSort(column); +export const sort = (column: Column) => meta.forTable(column.table, Sorting).handleSort(column); /** * Toggle a column between descending and not unsorted states From faac159a649ecd5162b2cc5b271aab73f37abff8 Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 14:59:23 +0100 Subject: [PATCH 10/16] Revert generic Column type for sortDecending and sortAscending Until I understand why the generics aren't handled by meta.forTable --- ember-headless-table/src/plugins/data-sorting/helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ember-headless-table/src/plugins/data-sorting/helpers.ts b/ember-headless-table/src/plugins/data-sorting/helpers.ts index 409f59f8..dc466fb6 100644 --- a/ember-headless-table/src/plugins/data-sorting/helpers.ts +++ b/ember-headless-table/src/plugins/data-sorting/helpers.ts @@ -40,11 +40,11 @@ export const sort = (column: Column) => meta.forTable(column.table, Sorting).han /** * Toggle a column between descending and not unsorted states */ -export const sortDescending = (column: Column) => +export const sortDescending = (column: Column) => meta.forTable(column.table, Sorting).toggleDescending(column); /** * Toggle a column between ascending and not unsorted states */ -export const sortAscending = (column: Column) => +export const sortAscending = (column: Column) => meta.forTable(column.table, Sorting).toggleAscending(column); From 7209e2843888602c215bb8d1e094799fa45e745a Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 15:03:52 +0100 Subject: [PATCH 11/16] lint --- ember-headless-table/src/plugins/column-resizing/handle.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ember-headless-table/src/plugins/column-resizing/handle.ts b/ember-headless-table/src/plugins/column-resizing/handle.ts index 8d74cd81..c8fcf602 100644 --- a/ember-headless-table/src/plugins/column-resizing/handle.ts +++ b/ember-headless-table/src/plugins/column-resizing/handle.ts @@ -24,7 +24,9 @@ let waiter = buildWaiter('ColumnResizing#ResizeHandle'); * */ -class ResizeHandle extends Modifier<{ Args: { Positional: [Column] } }> { +class ResizeHandle extends Modifier<{ + Args: { Positional: [Column] }; +}> { declare dragHandle: HTMLElement; declare column: Column; declare meta: ColumnMeta; From 30081d2ff54440bf6626d61089e30dc29fde38da Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 15:04:37 +0100 Subject: [PATCH 12/16] Update helpers.ts lint --- ember-headless-table/src/plugins/column-resizing/helpers.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ember-headless-table/src/plugins/column-resizing/helpers.ts b/ember-headless-table/src/plugins/column-resizing/helpers.ts index 534b9fce..20ed63d7 100644 --- a/ember-headless-table/src/plugins/column-resizing/helpers.ts +++ b/ember-headless-table/src/plugins/column-resizing/helpers.ts @@ -15,12 +15,14 @@ import type { Column } from '[public-types]'; * be marked as isResizing, because this is a user-scoped question: * "Is the user directly resizing this column?" */ -export const isResizing = (column: Column) => meta.forColumn(column, ColumnResizing).isResizing; +export const isResizing = (column: Column) => + meta.forColumn(column, ColumnResizing).isResizing; /** * Does the column have room to shrink? */ -export const canShrink = (column: Column) => meta.forColumn(column, ColumnResizing).canShrink; +export const canShrink = (column: Column) => + meta.forColumn(column, ColumnResizing).canShrink; /** * Does the column have a resize handle? From bf262104b14bfa4d16140b9c22411e33ccdb296e Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 15:05:22 +0100 Subject: [PATCH 13/16] Update helpers.ts lint --- .../src/plugins/data-sorting/helpers.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ember-headless-table/src/plugins/data-sorting/helpers.ts b/ember-headless-table/src/plugins/data-sorting/helpers.ts index dc466fb6..402c0ab8 100644 --- a/ember-headless-table/src/plugins/data-sorting/helpers.ts +++ b/ember-headless-table/src/plugins/data-sorting/helpers.ts @@ -6,27 +6,32 @@ import type { Column } from '[public-types]'; /** * Query a specific column's current sort direction */ -export const sortDirection = (column: Column) => meta.forColumn(column, Sorting).sortDirection; +export const sortDirection = (column: Column) => + meta.forColumn(column, Sorting).sortDirection; /** * Ask if a column is sortable */ -export const isSortable = (column: Column) => meta.forColumn(column, Sorting).isSortable; +export const isSortable = (column: Column) => + meta.forColumn(column, Sorting).isSortable; /** * Ask if a column is ascending */ -export const isAscending = (column: Column) => meta.forColumn(column, Sorting).isAscending; +export const isAscending = (column: Column) => + meta.forColumn(column, Sorting).isAscending; /** * Ask if a column is sorted descending */ -export const isDescending = (column: Column) => meta.forColumn(column, Sorting).isDescending; +export const isDescending = (column: Column) => + meta.forColumn(column, Sorting).isDescending; /** * Ask if a column is not sorted */ -export const isUnsorted = (column: Column) => meta.forColumn(column, Sorting).isUnsorted; +export const isUnsorted = (column: Column) => + meta.forColumn(column, Sorting).isUnsorted; /** * Sort the specified column's data using a tri-toggle. From b8f4af6361e49dbf9f2b49d3dbdc2f8d1ba26df6 Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 15:07:40 +0100 Subject: [PATCH 14/16] Update helpers.ts lint --- .../src/plugins/data-sorting/helpers.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ember-headless-table/src/plugins/data-sorting/helpers.ts b/ember-headless-table/src/plugins/data-sorting/helpers.ts index 402c0ab8..4a73a20e 100644 --- a/ember-headless-table/src/plugins/data-sorting/helpers.ts +++ b/ember-headless-table/src/plugins/data-sorting/helpers.ts @@ -6,31 +6,31 @@ import type { Column } from '[public-types]'; /** * Query a specific column's current sort direction */ -export const sortDirection = (column: Column) => +export const sortDirection = (column: Column) => meta.forColumn(column, Sorting).sortDirection; /** * Ask if a column is sortable */ -export const isSortable = (column: Column) => +export const isSortable = (column: Column) => meta.forColumn(column, Sorting).isSortable; /** * Ask if a column is ascending */ -export const isAscending = (column: Column) => +export const isAscending = (column: Column) => meta.forColumn(column, Sorting).isAscending; /** * Ask if a column is sorted descending */ -export const isDescending = (column: Column) => +export const isDescending = (column: Column) => meta.forColumn(column, Sorting).isDescending; /** * Ask if a column is not sorted */ -export const isUnsorted = (column: Column) => +export const isUnsorted = (column: Column) => meta.forColumn(column, Sorting).isUnsorted; /** From 6b2f6210a1b1b91d9d71a901146adaa12b797633 Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 15:08:01 +0100 Subject: [PATCH 15/16] Update helpers.ts lint --- ember-headless-table/src/plugins/column-resizing/helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ember-headless-table/src/plugins/column-resizing/helpers.ts b/ember-headless-table/src/plugins/column-resizing/helpers.ts index 20ed63d7..9553ad14 100644 --- a/ember-headless-table/src/plugins/column-resizing/helpers.ts +++ b/ember-headless-table/src/plugins/column-resizing/helpers.ts @@ -15,13 +15,13 @@ import type { Column } from '[public-types]'; * be marked as isResizing, because this is a user-scoped question: * "Is the user directly resizing this column?" */ -export const isResizing = (column: Column) => +export const isResizing = (column: Column) => meta.forColumn(column, ColumnResizing).isResizing; /** * Does the column have room to shrink? */ -export const canShrink = (column: Column) => +export const canShrink = (column: Column) => meta.forColumn(column, ColumnResizing).canShrink; /** From e26a127904874eb1dfbd3622b91b6ba25fb7285a Mon Sep 17 00:00:00 2001 From: johanrd Date: Wed, 21 Feb 2024 15:08:44 +0100 Subject: [PATCH 16/16] Update handle.ts lint --- ember-headless-table/src/plugins/column-resizing/handle.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ember-headless-table/src/plugins/column-resizing/handle.ts b/ember-headless-table/src/plugins/column-resizing/handle.ts index c8fcf602..800cf430 100644 --- a/ember-headless-table/src/plugins/column-resizing/handle.ts +++ b/ember-headless-table/src/plugins/column-resizing/handle.ts @@ -24,8 +24,8 @@ let waiter = buildWaiter('ColumnResizing#ResizeHandle'); * */ -class ResizeHandle extends Modifier<{ - Args: { Positional: [Column] }; +class ResizeHandle extends Modifier<{ + Args: { Positional: [Column] }; }> { declare dragHandle: HTMLElement; declare column: Column;