UNPKG

@hashicorp/design-system-components

Version:
91 lines (90 loc) 4.04 kB
/** * Copyright (c) HashiCorp, Inc. * SPDX-License-Identifier: MPL-2.0 */ import Component from '@glimmer/component'; import type { ComponentLike } from '@glint/template'; import type HdsIntlService from '../../../services/hds-intl.ts'; import { HdsTableDensityValues, HdsTableThSortOrderValues, HdsTableVerticalAlignmentValues } from './types.ts'; import type { HdsTableColumn, HdsTableDensities, HdsTableHorizontalAlignment, HdsTableOnSelectionChangeSignature, HdsTableSortingFunction, HdsTableThSortOrder, HdsTableVerticalAlignment, HdsTableModel } from './types'; import type { HdsFormCheckboxBaseSignature } from '../form/checkbox/base'; import type { HdsTableTdSignature } from './td.ts'; import type { HdsTableThSignature } from './th.ts'; import type { HdsTableThSortSignature } from './th-sort.ts'; import type { HdsTableTrSignature } from './tr.ts'; import type Owner from '@ember/owner'; export declare const DENSITIES: HdsTableDensities[]; export declare const DEFAULT_DENSITY = HdsTableDensityValues.Medium; export declare const VALIGNMENTS: HdsTableVerticalAlignment[]; export declare const DEFAULT_VALIGN = HdsTableVerticalAlignmentValues.Top; export interface HdsTableSignature<T = HdsTableModel> { Args: { align?: HdsTableHorizontalAlignment; caption?: string; columns?: HdsTableColumn[]; density?: HdsTableDensities; identityKey?: string; isFixedLayout?: boolean; isSelectable?: boolean; isStriped?: boolean; model?: T[]; onSelectionChange?: (selection: HdsTableOnSelectionChangeSignature) => void; onSort?: (sortBy: string, sortOrder: HdsTableThSortOrder) => void; selectionAriaLabelSuffix?: string; sortBy?: string; selectableColumnKey?: string; sortedMessageText?: string; sortOrder?: HdsTableThSortOrder; valign?: HdsTableVerticalAlignment; }; Blocks: { head?: [ { Tr?: ComponentLike<HdsTableTrSignature>; Th?: ComponentLike<HdsTableThSignature>; ThSort?: ComponentLike<HdsTableThSortSignature>; sortBy?: string; sortOrder?: HdsTableThSortOrder; setSortBy?: (column: string) => void; } ]; body?: [ { Td?: ComponentLike<HdsTableTdSignature>; Tr?: ComponentLike<HdsTableTrSignature>; Th?: ComponentLike<HdsTableThSignature>; data?: T; rowIndex?: number; sortBy?: string; sortOrder?: HdsTableThSortOrder; } ]; }; Element: HTMLTableElement; } export default class HdsTable<T = HdsTableModel> extends Component<HdsTableSignature<T>> { hdsIntl: HdsIntlService; sortBy: string | undefined; sortOrder: "desc" | "asc" | HdsTableThSortOrderValues; private _selectAllCheckbox?; private _selectableRows; private _isSelectAllCheckboxSelected?; constructor(owner: Owner, args: HdsTableSignature<T>['Args']); get getSortCriteria(): string | HdsTableSortingFunction<unknown>; get identityKey(): string | undefined; get sortedMessageText(): string; get isStriped(): boolean; get isFixedLayout(): boolean; get density(): HdsTableDensities; get valign(): HdsTableVerticalAlignment; get classNames(): string; setSortBy(column: string): void; onSelectionChangeCallback(checkbox?: HdsFormCheckboxBaseSignature['Element'], selectionKey?: string): void; onSelectionAllChange(): void; onSelectionRowChange(checkbox?: HdsFormCheckboxBaseSignature['Element'], selectionKey?: string): void; didInsertSelectAllCheckbox(checkbox: HdsFormCheckboxBaseSignature['Element']): void; willDestroySelectAllCheckbox(): void; didInsertRowCheckbox(checkbox: HdsFormCheckboxBaseSignature['Element'], selectionKey?: string): void; willDestroyRowCheckbox(selectionKey?: string): void; setSelectAllState(): void; }