feat: migrate Toast and Table with reviewed state focus and SSR contracts

This commit is contained in:
maoyingjie
2026-10-24 07:19:26 +08:00
parent 0cfe7b6195
commit ed41af5294
95 changed files with 9358 additions and 8 deletions
@@ -0,0 +1,66 @@
import type { CollectionKey } from "../collection/keys";
import type { useTableNavigation } from "./navigation";
export type TableKey = CollectionKey;
import type { ComputedRef, InjectionKey, Ref } from "vue";
import type { tableVariants } from "@heroui-vue/styles";
export type TableSlots = ReturnType<typeof tableVariants>;
export type TableSortDirection = "ascending" | "descending" | "none";
export interface TableContextValue {
columnDefinitions?: Ref<{ id?: string; isRowHeader: boolean }[]>;
columns?: Ref<
Map<symbol, { node: HTMLElement; id?: string; isRowHeader: boolean }>
>;
navigation?: ReturnType<typeof useTableNavigation>;
slots: ComputedRef<TableSlots>;
variant: ComputedRef<string>;
selectionMode: ComputedRef<"none" | "single" | "multiple">;
selectedKeys: ComputedRef<readonly TableKey[]>;
disabledKeys: ComputedRef<readonly TableKey[]>;
sortDescriptor: ComputedRef<{
column: string;
direction: TableSortDirection;
} | null>;
expandedKeys: ComputedRef<readonly TableKey[]>;
treeColumn: ComputedRef<string | undefined>;
toggleSelect: (key: TableKey, event?: MouseEvent | KeyboardEvent) => void;
toggleExpand: (key: TableKey) => void;
isRowSelected: (key: TableKey) => boolean;
isRowDisabled: (key: TableKey) => boolean;
isRowExpanded: (key: TableKey) => boolean;
sort: (column: string) => void;
}
export const tableContextKey: InjectionKey<TableContextValue> =
Symbol("hv-table");
export interface TableRowContextValue {
nextCellIndex: () => number;
key: TableKey;
isSelected: ComputedRef<boolean>;
isDisabled: ComputedRef<boolean>;
isExpanded: ComputedRef<boolean>;
hasChildItems: boolean;
}
export const tableRowContextKey: InjectionKey<TableRowContextValue> =
Symbol("hv-table-row");
export interface TableColumnContextValue {
key: ComputedRef<string | undefined>;
allowsSorting: ComputedRef<boolean>;
sortDirection: ComputedRef<TableSortDirection>;
}
export const tableColumnContextKey: InjectionKey<TableColumnContextValue> =
Symbol("hv-table-column");
export interface TableColumnWidthContext {
minWidth: ComputedRef<number | undefined>;
maxWidth: ComputedRef<number | undefined>;
width: ComputedRef<string | number | undefined>;
setWidth: (width: number) => void;
}
export const tableColumnWidthKey: InjectionKey<TableColumnWidthContext> =
Symbol("hv-table-column-width");