Used for keeping track of and updating column order

Constructors

  • Parameters

    • args: {
          columns: () => Column<unknown>[];
          existingOrder?: Map<string, number>;
          save?: (order: Map<string, number>) => void;
          visibleColumns?: () => Record<string, boolean>;
      }
      • columns: () => Column<unknown>[]

        All columns to track in the ordering.

        Backwards compatible usage (without ColumnVisibility):

        • Pass only the columns you want to display
        • All columns are treated as visible

        New usage (with ColumnVisibility):

        • Pass ALL columns (including hidden ones)
        • Provide visibleColumns to indicate which are visible
        • Hidden columns maintain their position when toggled
      • OptionalexistingOrder?: Map<string, number>

        Optional: Previously saved column order to restore.

      • Optionalsave?: (order: Map<string, number>) => void

        Optional: Callback to persist the column order (e.g., to localStorage).

      • OptionalvisibleColumns?: () => Record<string, boolean>

        Optional: Record of which columns are currently visible. When provided, moveLeft/moveRight will skip over hidden columns. When omitted, all columns from columns are treated as visible (backwards compatible).

        Example when using ColumnVisibility:

        visibleColumns: () => columns.reduce((acc, col) => {
        acc[col.key] = meta(col).ColumnVisibility?.isVisible !== false;
        return acc;
        }, {})

    Returns ColumnOrder

Properties

args: {
    columns: () => Column<unknown>[];
    existingOrder?: Map<string, number>;
    save?: (order: Map<string, number>) => void;
    visibleColumns?: () => Record<string, boolean>;
}

Type declaration

  • columns: () => Column<unknown>[]

    All columns to track in the ordering.

    Backwards compatible usage (without ColumnVisibility):

    • Pass only the columns you want to display
    • All columns are treated as visible

    New usage (with ColumnVisibility):

    • Pass ALL columns (including hidden ones)
    • Provide visibleColumns to indicate which are visible
    • Hidden columns maintain their position when toggled
  • OptionalexistingOrder?: Map<string, number>

    Optional: Previously saved column order to restore.

  • Optionalsave?: (order: Map<string, number>) => void

    Optional: Callback to persist the column order (e.g., to localStorage).

  • OptionalvisibleColumns?: () => Record<string, boolean>

    Optional: Record of which columns are currently visible. When provided, moveLeft/moveRight will skip over hidden columns. When omitted, all columns from columns are treated as visible (backwards compatible).

    Example when using ColumnVisibility:

    visibleColumns: () => columns.reduce((acc, col) => {
    acc[col.key] = meta(col).ColumnVisibility?.isVisible !== false;
    return acc;
    }, {})
map: TrackedMap<string, number> = ...

This map will be empty until we re-order something.

Accessors

Methods

  • To account for columnVisibilty, we need to:

    • get the list of visible columns
    • get the column order (which preserves the order of hidden columns)
    • skip over non-visible columns when determining the previous "index"
    • set the position to whatever that is.

    Parameters

    • key: string

    Returns void

  • To account for columnVisibilty, we need to:

    • get the list of visible columns
    • get the column order (which preserves the order of hidden columns)
    • skip over non-visible columns when determining the next "index"
    • set the position to whatever that is.

    Parameters

    • key: string

    Returns void

  • Performs a swap of the column's position with the column at position

    Parameters

    • key: string
    • position: number

    Returns undefined | false