simple-table-core 4.0.8 → 4.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 (38) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/styles.css +1 -1
  3. package/dist/core/SimpleTableVanilla.d.ts +7 -6
  4. package/dist/icons/MinusIcon.d.ts +2 -0
  5. package/dist/icons/index.d.ts +1 -0
  6. package/dist/index.d.ts +3 -2
  7. package/dist/index.es.js +1 -1
  8. package/dist/styles.css +1 -1
  9. package/dist/types/CellChangeProps.d.ts +5 -4
  10. package/dist/types/CellClickProps.d.ts +5 -4
  11. package/dist/types/CellRendererProps.d.ts +6 -5
  12. package/dist/types/ColumnDef.d.ts +53 -32
  13. package/dist/types/FilterTypes.d.ts +7 -5
  14. package/dist/types/GenerateRowIdParams.d.ts +4 -3
  15. package/dist/types/GetRowId.d.ts +4 -3
  16. package/dist/types/HeaderRendererProps.d.ts +6 -4
  17. package/dist/types/OnRowGroupExpandProps.d.ts +4 -3
  18. package/dist/types/PivotTypes.d.ts +11 -7
  19. package/dist/types/QuickFilterTypes.d.ts +5 -4
  20. package/dist/types/Row.d.ts +6 -0
  21. package/dist/types/RowButton.d.ts +4 -3
  22. package/dist/types/RowSelectionChangeProps.d.ts +3 -2
  23. package/dist/types/RowStateRendererProps.d.ts +13 -12
  24. package/dist/types/SimpleTableConfig.d.ts +28 -22
  25. package/dist/types/SimpleTableProps.d.ts +28 -22
  26. package/dist/types/TableAPI.d.ts +24 -19
  27. package/dist/types/TableRow.d.ts +5 -4
  28. package/dist/types/UpdateCellProps.d.ts +5 -3
  29. package/dist/utils/columnEditor/columnEditorUtils.d.ts +3 -0
  30. package/dist/utils/columnEditor/createCheckbox.d.ts +7 -2
  31. package/dist/utils/normalizeConfig.d.ts +4 -1
  32. package/package.json +1 -1
  33. package/src/styles/base.css +64 -35
  34. package/src/styles/themes/dark.css +9 -0
  35. package/src/styles/themes/light.css +9 -0
  36. package/src/styles/themes/modern-dark.css +9 -0
  37. package/src/styles/themes/modern-light.css +9 -0
  38. package/src/styles/themes/neutral.css +9 -0
@@ -1,5 +1,7 @@
1
1
  import type { Accessor } from "./ColumnDef";
2
2
  import type ColumnDef from "./ColumnDef";
3
+ import type Row from "./Row";
4
+ import type { RowData } from "./Row";
3
5
  import type { IconElement } from "./IconsConfig";
4
6
  export interface HeaderRendererComponents {
5
7
  sortIcon?: IconElement;
@@ -7,11 +9,11 @@ export interface HeaderRendererComponents {
7
9
  collapseIcon?: IconElement;
8
10
  labelContent?: string | HTMLElement;
9
11
  }
10
- interface HeaderRendererProps {
11
- accessor: Accessor;
12
+ interface HeaderRendererProps<TData extends RowData = Row> {
13
+ accessor: Accessor<TData>;
12
14
  colIndex: number;
13
- header: ColumnDef;
15
+ header: ColumnDef<TData, any>;
14
16
  components?: HeaderRendererComponents;
15
17
  }
16
- export type HeaderRenderer = (props: HeaderRendererProps) => HTMLElement | string | null;
18
+ export type HeaderRenderer<TData extends RowData = Row> = (props: HeaderRendererProps<TData>) => HTMLElement | string | null;
17
19
  export default HeaderRendererProps;
@@ -1,14 +1,15 @@
1
1
  import Row from "./Row";
2
+ import type { RowData } from "./Row";
2
3
  import { Accessor } from "./ColumnDef";
3
- interface OnRowGroupExpandProps {
4
- row: Row;
4
+ interface OnRowGroupExpandProps<TData extends RowData = Row> {
5
+ row: TData;
5
6
  depth: number;
6
7
  event: MouseEvent | KeyboardEvent;
7
8
  groupingKey?: string;
8
9
  isExpanded: boolean;
9
10
  rowIndexPath: number[];
10
11
  rowIdPath?: (string | number)[];
11
- groupingKeys: Accessor[];
12
+ groupingKeys: Accessor<TData>[];
12
13
  setLoading: (loading: boolean) => void;
13
14
  setError: (error: string | null) => void;
14
15
  setEmpty: (isEmpty: boolean, message?: string) => void;
@@ -2,18 +2,19 @@ import { Accessor } from "./ColumnDef";
2
2
  import { AggregationConfig } from "./AggregationTypes";
3
3
  import ColumnDef from "./ColumnDef";
4
4
  import Row from "./Row";
5
- export type PivotValueConfig = {
6
- accessor: Accessor;
5
+ import type { RowData } from "./Row";
6
+ export type PivotValueConfig<TData extends RowData = Row> = {
7
+ accessor: Accessor<TData>;
7
8
  aggregation: AggregationConfig;
8
9
  label?: string;
9
10
  };
10
- export type PivotConfig = {
11
+ export type PivotConfig<TData extends RowData = Row> = {
11
12
  /** Row dimension accessors (0+). Multi-level dims become an expandable tree. */
12
- rows: Accessor[];
13
+ rows: Accessor<TData>[];
13
14
  /** Column dimension accessors (0+). Distinct values become dynamic header groups. */
14
- columns: Accessor[];
15
+ columns: Accessor<TData>[];
15
16
  /** Value/measure configs (required, length >= 1). */
16
- values: PivotValueConfig[];
17
+ values: PivotValueConfig<TData>[];
17
18
  /** Total column(s) aggregating across column dimensions. Default true. */
18
19
  showRowTotals?: boolean;
19
20
  /** Total row aggregating across row dimensions. Default true. */
@@ -32,6 +33,9 @@ export declare const PIVOT_BLANK_LABEL = "(blank)";
32
33
  export type PivotResult = {
33
34
  rows: Row[];
34
35
  headers: ColumnDef[];
35
- /** Internal rowGrouping to use while pivot is active (undefined when flat). */
36
+ /**
37
+ * Internal rowGrouping while pivot is active (undefined when flat).
38
+ * Kept as open accessors — pivot injects synthetic keys.
39
+ */
36
40
  rowGrouping?: Accessor[];
37
41
  };
@@ -1,5 +1,6 @@
1
1
  import { Accessor } from "./ColumnDef";
2
2
  import Row from "./Row";
3
+ import type { RowData } from "./Row";
3
4
  export type QuickFilterMode = "simple" | "smart";
4
5
  export interface QuickFilterConfig {
5
6
  text: string;
@@ -9,11 +10,11 @@ export interface QuickFilterConfig {
9
10
  useFormattedValue?: boolean;
10
11
  onChange?: (text: string) => void;
11
12
  }
12
- export interface QuickFilterGetterProps {
13
- row: Row;
14
- accessor: Accessor;
13
+ export interface QuickFilterGetterProps<TData extends RowData = Row> {
14
+ row: TData;
15
+ accessor: Accessor<TData>;
15
16
  }
16
- export type QuickFilterGetter = (props: QuickFilterGetterProps) => string;
17
+ export type QuickFilterGetter<TData extends RowData = Row> = (props: QuickFilterGetterProps<TData>) => string;
17
18
  export interface SmartFilterToken {
18
19
  type: "word" | "phrase" | "negation" | "columnSpecific";
19
20
  value: string;
@@ -1,3 +1,9 @@
1
1
  import CellValue from "./CellValue";
2
2
  type Row = Record<string, CellValue | Row[] | Record<string, any>>;
3
+ /**
4
+ * Constraint for consumer row shapes on generic table APIs.
5
+ * Defaults on those APIs remain {@link Row}; use a domain interface as `TData`
6
+ * (e.g. `ColumnDef<HREmployee>`) without requiring an index signature.
7
+ */
8
+ export type RowData = unknown;
3
9
  export default Row;
@@ -1,6 +1,7 @@
1
1
  import Row from "./Row";
2
- export interface RowButtonProps {
3
- row: Row;
2
+ import type { RowData } from "./Row";
3
+ export interface RowButtonProps<TData extends RowData = Row> {
4
+ row: TData;
4
5
  rowIndex: number;
5
6
  }
6
- export type RowButton = (props: RowButtonProps) => HTMLElement | null;
7
+ export type RowButton<TData extends RowData = Row> = (props: RowButtonProps<TData>) => HTMLElement | null;
@@ -1,6 +1,7 @@
1
1
  import Row from "./Row";
2
- type RowSelectionChangeProps = {
3
- row: Row;
2
+ import type { RowData } from "./Row";
3
+ type RowSelectionChangeProps<TData extends RowData = Row> = {
4
+ row: TData;
4
5
  isSelected: boolean;
5
6
  selectedRows: Set<string>;
6
7
  };
@@ -1,18 +1,19 @@
1
1
  import type Row from "./Row";
2
- export interface LoadingStateRendererProps {
3
- parentRow?: Row;
2
+ import type { RowData } from "./Row";
3
+ export interface LoadingStateRendererProps<TData extends RowData = Row> {
4
+ parentRow?: TData;
4
5
  }
5
- export interface ErrorStateRendererProps {
6
+ export interface ErrorStateRendererProps<TData extends RowData = Row> {
6
7
  error: string;
7
- parentRow?: Row;
8
+ parentRow?: TData;
8
9
  }
9
- export interface EmptyStateRendererProps {
10
+ export interface EmptyStateRendererProps<TData extends RowData = Row> {
10
11
  message?: string;
11
- parentRow?: Row;
12
+ parentRow?: TData;
12
13
  }
13
- export type VanillaLoadingStateRenderer = string | HTMLElement | ((props: LoadingStateRendererProps) => HTMLElement | string);
14
- export type VanillaErrorStateRenderer = string | HTMLElement | ((props: ErrorStateRendererProps) => HTMLElement | string);
15
- export type VanillaEmptyStateRenderer = string | HTMLElement | ((props: EmptyStateRendererProps) => HTMLElement | string);
16
- export type LoadingStateRenderer = VanillaLoadingStateRenderer;
17
- export type ErrorStateRenderer = VanillaErrorStateRenderer;
18
- export type EmptyStateRenderer = VanillaEmptyStateRenderer;
14
+ export type VanillaLoadingStateRenderer<TData extends RowData = Row> = string | HTMLElement | ((props: LoadingStateRendererProps<TData>) => HTMLElement | string);
15
+ export type VanillaErrorStateRenderer<TData extends RowData = Row> = string | HTMLElement | ((props: ErrorStateRendererProps<TData>) => HTMLElement | string);
16
+ export type VanillaEmptyStateRenderer<TData extends RowData = Row> = string | HTMLElement | ((props: EmptyStateRendererProps<TData>) => HTMLElement | string);
17
+ export type LoadingStateRenderer<TData extends RowData = Row> = VanillaLoadingStateRenderer<TData>;
18
+ export type ErrorStateRenderer<TData extends RowData = Row> = VanillaErrorStateRenderer<TData>;
19
+ export type EmptyStateRenderer<TData extends RowData = Row> = VanillaEmptyStateRenderer<TData>;
@@ -1,6 +1,7 @@
1
1
  import type ColumnDef from "./ColumnDef";
2
2
  import { Accessor } from "./ColumnDef";
3
3
  import Row from "./Row";
4
+ import type { RowData } from "./Row";
4
5
  import { VanillaEmptyStateRenderer, VanillaErrorStateRenderer, VanillaLoadingStateRenderer } from "./RowStateRendererProps";
5
6
  import FooterRendererProps from "./FooterRendererProps";
6
7
  import { VanillaHeaderDropdown } from "./HeaderDropdownProps";
@@ -27,7 +28,7 @@ import type { PivotConfig } from "./PivotTypes";
27
28
  * Canonical runtime config after {@link normalizeConfig}.
28
29
  * Preferred public prop names only (no legacy aliases).
29
30
  */
30
- export interface SimpleTableConfig {
31
+ export interface SimpleTableConfig<TData extends RowData = Row> {
31
32
  animations?: AnimationsConfig;
32
33
  /**
33
34
  * Expand-only fill: when the columns' natural widths (declared px, or
@@ -37,22 +38,22 @@ export interface SimpleTableConfig {
37
38
  * fit, the table scrolls horizontally instead.
38
39
  */
39
40
  autoExpandColumns?: boolean;
40
- canExpandRowGroup?: (row: Row) => boolean;
41
+ canExpandRowGroup?: (row: TData) => boolean;
41
42
  cellUpdateFlash?: boolean;
42
43
  className?: string;
43
44
  columnBorders?: boolean;
44
45
  columnEditorConfig?: ColumnEditorConfig;
45
46
  columnReordering?: boolean;
46
47
  columnResizing?: boolean;
47
- /** Column definitions. */
48
- columns: ColumnDef[];
48
+ /** Column definitions. Mixed per-column TValue uses `any` on the column union. */
49
+ columns: ColumnDef<TData, any>[];
49
50
  copyHeadersToClipboard?: boolean;
50
51
  customTheme?: CustomThemeProps;
51
52
  /** Show the column editor / visibility UI. */
52
53
  enableColumnEditor?: boolean;
53
54
  /** Open the column editor when the table loads. */
54
55
  enableColumnEditorInitOpen?: boolean;
55
- emptyStateRenderer?: VanillaEmptyStateRenderer;
56
+ emptyStateRenderer?: VanillaEmptyStateRenderer<TData>;
56
57
  enableHeaderEditing?: boolean;
57
58
  /** Enable client-side pagination. */
58
59
  enablePagination?: boolean;
@@ -66,7 +67,7 @@ export interface SimpleTableConfig {
66
67
  enableStickyParents?: boolean;
67
68
  /** @see SimpleTableProps.enableVirtualization */
68
69
  enableVirtualization?: boolean;
69
- errorStateRenderer?: VanillaErrorStateRenderer;
70
+ errorStateRenderer?: VanillaErrorStateRenderer<TData>;
70
71
  expandAll?: boolean;
71
72
  externalFilterHandling?: boolean;
72
73
  externalSortHandling?: boolean;
@@ -90,28 +91,28 @@ export interface SimpleTableConfig {
90
91
  initialSortColumn?: string;
91
92
  initialSortDirection?: SortDirection;
92
93
  isLoading?: boolean;
93
- loadingStateRenderer?: VanillaLoadingStateRenderer;
94
+ loadingStateRenderer?: VanillaLoadingStateRenderer<TData>;
94
95
  maxHeight?: string | number;
95
96
  /** Alternate column background. */
96
97
  oddColumnBackground?: boolean;
97
98
  /** Alternate odd/even row backgrounds. */
98
99
  oddEvenRowBackground?: boolean;
99
- onCellClick?: (props: CellClickProps) => void;
100
- onCellEdit?: (props: CellChangeProps) => void;
101
- onColumnOrderChange?: (newHeaders: ColumnDef[]) => void;
102
- onColumnSelect?: (header: ColumnDef) => void;
100
+ onCellClick?: (props: CellClickProps<TData>) => void;
101
+ onCellEdit?: (props: CellChangeProps<TData>) => void;
102
+ onColumnOrderChange?: (newHeaders: ColumnDef<TData, any>[]) => void;
103
+ onColumnSelect?: (header: ColumnDef<TData, any>) => void;
103
104
  onColumnVisibilityChange?: (visibilityState: ColumnVisibilityState) => void;
104
- onColumnWidthChange?: (headers: ColumnDef[]) => void;
105
- onFilterChange?: (filters: TableFilterState) => void;
105
+ onColumnWidthChange?: (headers: ColumnDef<TData, any>[]) => void;
106
+ onFilterChange?: (filters: TableFilterState<TData>) => void;
106
107
  /** Called once when the table is ready. */
107
108
  onTableReady?: () => void;
108
- onHeaderEdit?: (header: ColumnDef, newLabel: string) => void;
109
+ onHeaderEdit?: (header: ColumnDef<TData, any>, newLabel: string) => void;
109
110
  infiniteScrollThreshold?: number;
110
111
  onLoadMore?: () => void;
111
112
  onNextPage?: OnNextPage;
112
113
  onPageChange?: (page: number) => void | Promise<void>;
113
- onRowGroupExpand?: (props: OnRowGroupExpandProps) => void | Promise<void>;
114
- onRowSelectionChange?: (props: RowSelectionChangeProps) => void;
114
+ onRowGroupExpand?: (props: OnRowGroupExpandProps<TData>) => void | Promise<void>;
115
+ onRowSelectionChange?: (props: RowSelectionChangeProps<TData>) => void;
115
116
  /**
116
117
  * Called by the renderer immediately BEFORE it permanently discards a host
117
118
  * element that may contain async-framework renderer output (e.g. React
@@ -124,14 +125,19 @@ export interface SimpleTableConfig {
124
125
  onRendererHostDiscard?: (host: HTMLElement) => void;
125
126
  onSortChange?: (sort: SortColumn | null) => void;
126
127
  /** @see SimpleTableProps.pivot */
127
- pivot?: PivotConfig | null;
128
+ pivot?: PivotConfig<TData> | null;
128
129
  /** @see SimpleTableProps.onPivotChange */
129
- onPivotChange?: (pivot: PivotConfig | null) => void;
130
+ onPivotChange?: (pivot: PivotConfig<TData> | null) => void;
130
131
  quickFilter?: QuickFilterConfig;
131
- rowButtons?: RowButton[];
132
- rowGrouping?: Accessor[];
133
- getRowId?: GetRowId;
134
- rows: Row[];
132
+ rowButtons?: RowButton<TData>[];
133
+ /**
134
+ * Property names that define the row grouping hierarchy.
135
+ * `Accessor<TData>` keeps keyof autocomplete; the `string & {}` arm still
136
+ * allows dynamic / heterogeneous nesting keys and pivot-injected keys.
137
+ */
138
+ rowGrouping?: Accessor<TData>[];
139
+ getRowId?: GetRowId<TData>;
140
+ rows: TData[];
135
141
  rowsPerPage?: number;
136
142
  scrollParent?: HTMLElement | "window" | (() => HTMLElement | null);
137
143
  selectableCells?: boolean;
@@ -1,6 +1,7 @@
1
1
  import type ColumnDef from "./ColumnDef";
2
2
  import { Accessor } from "./ColumnDef";
3
3
  import Row from "./Row";
4
+ import type { RowData } from "./Row";
4
5
  import { EmptyStateRenderer, ErrorStateRenderer, LoadingStateRenderer } from "./RowStateRendererProps";
5
6
  import FooterRendererProps from "./FooterRendererProps";
6
7
  import { HeaderDropdown } from "./HeaderDropdownProps";
@@ -23,25 +24,25 @@ import { QuickFilterConfig } from "./QuickFilterTypes";
23
24
  import { AnimationsConfig } from "./AnimationsConfig";
24
25
  import type { FooterPosition } from "./FooterPosition";
25
26
  import type { PivotConfig } from "./PivotTypes";
26
- export interface SimpleTableProps {
27
+ export interface SimpleTableProps<TData extends RowData = Row> {
27
28
  animations?: AnimationsConfig;
28
29
  autoExpandColumns?: boolean;
29
- canExpandRowGroup?: (row: Row) => boolean;
30
+ canExpandRowGroup?: (row: TData) => boolean;
30
31
  cellUpdateFlash?: boolean;
31
32
  className?: string;
32
33
  columnBorders?: boolean;
33
34
  columnEditorConfig?: ColumnEditorConfig;
34
35
  columnReordering?: boolean;
35
36
  columnResizing?: boolean;
36
- /** Column definitions. */
37
- columns?: ColumnDef[];
37
+ /** Column definitions. Mixed per-column TValue uses `any` on the column union. */
38
+ columns?: ColumnDef<TData, any>[];
38
39
  copyHeadersToClipboard?: boolean;
39
40
  customTheme?: CustomThemeProps;
40
41
  /** Show the column editor / visibility UI. */
41
42
  enableColumnEditor?: boolean;
42
43
  /** Open the column editor when the table loads. */
43
44
  enableColumnEditorInitOpen?: boolean;
44
- emptyStateRenderer?: EmptyStateRenderer;
45
+ emptyStateRenderer?: EmptyStateRenderer<TData>;
45
46
  enableHeaderEditing?: boolean;
46
47
  /** Enable client-side pagination. */
47
48
  enablePagination?: boolean;
@@ -71,7 +72,7 @@ export interface SimpleTableProps {
71
72
  * Default true.
72
73
  */
73
74
  enableVirtualization?: boolean;
74
- errorStateRenderer?: ErrorStateRenderer;
75
+ errorStateRenderer?: ErrorStateRenderer<TData>;
75
76
  expandAll?: boolean;
76
77
  externalFilterHandling?: boolean;
77
78
  externalSortHandling?: boolean;
@@ -97,41 +98,46 @@ export interface SimpleTableProps {
97
98
  initialSortColumn?: string;
98
99
  initialSortDirection?: SortDirection;
99
100
  isLoading?: boolean;
100
- loadingStateRenderer?: LoadingStateRenderer;
101
+ loadingStateRenderer?: LoadingStateRenderer<TData>;
101
102
  maxHeight?: string | number;
102
103
  /** Alternate column background. */
103
104
  oddColumnBackground?: boolean;
104
105
  /** Alternate odd/even row backgrounds. */
105
106
  oddEvenRowBackground?: boolean;
106
- onCellClick?: (props: CellClickProps) => void;
107
- onCellEdit?: (props: CellChangeProps) => void;
108
- onColumnOrderChange?: (newHeaders: ColumnDef[]) => void;
109
- onColumnSelect?: (header: ColumnDef) => void;
107
+ onCellClick?: (props: CellClickProps<TData>) => void;
108
+ onCellEdit?: (props: CellChangeProps<TData>) => void;
109
+ onColumnOrderChange?: (newHeaders: ColumnDef<TData, any>[]) => void;
110
+ onColumnSelect?: (header: ColumnDef<TData, any>) => void;
110
111
  onColumnVisibilityChange?: (visibilityState: ColumnVisibilityState) => void;
111
- onColumnWidthChange?: (headers: ColumnDef[]) => void;
112
- onFilterChange?: (filters: TableFilterState) => void;
112
+ onColumnWidthChange?: (headers: ColumnDef<TData, any>[]) => void;
113
+ onFilterChange?: (filters: TableFilterState<TData>) => void;
113
114
  /** Called once when the table is ready. */
114
115
  onTableReady?: () => void;
115
- onHeaderEdit?: (header: ColumnDef, newLabel: string) => void;
116
+ onHeaderEdit?: (header: ColumnDef<TData, any>, newLabel: string) => void;
116
117
  infiniteScrollThreshold?: number;
117
118
  onLoadMore?: () => void;
118
119
  onNextPage?: OnNextPage;
119
120
  onPageChange?: (page: number) => void | Promise<void>;
120
- onRowGroupExpand?: (props: OnRowGroupExpandProps) => void | Promise<void>;
121
- onRowSelectionChange?: (props: RowSelectionChangeProps) => void;
121
+ onRowGroupExpand?: (props: OnRowGroupExpandProps<TData>) => void | Promise<void>;
122
+ onRowSelectionChange?: (props: RowSelectionChangeProps<TData>) => void;
122
123
  onSortChange?: (sort: SortColumn | null) => void;
123
124
  /**
124
125
  * Declarative matrix pivot. When set, flat `rows` are reshaped into a
125
126
  * pivoted grid with dynamic columns. Ignores consumer `rowGrouping` while active.
126
127
  */
127
- pivot?: PivotConfig | null;
128
+ pivot?: PivotConfig<TData> | null;
128
129
  /** Fired when pivot config changes via TableAPI.setPivot. */
129
- onPivotChange?: (pivot: PivotConfig | null) => void;
130
+ onPivotChange?: (pivot: PivotConfig<TData> | null) => void;
130
131
  quickFilter?: QuickFilterConfig;
131
- rowButtons?: RowButton[];
132
- rowGrouping?: Accessor[];
133
- getRowId?: GetRowId;
134
- rows: Row[];
132
+ rowButtons?: RowButton<TData>[];
133
+ /**
134
+ * Property names that define the row grouping hierarchy.
135
+ * `Accessor<TData>` keeps keyof autocomplete; the `string & {}` arm still
136
+ * allows dynamic / heterogeneous nesting keys and pivot-injected keys.
137
+ */
138
+ rowGrouping?: Accessor<TData>[];
139
+ getRowId?: GetRowId<TData>;
140
+ rows: TData[];
135
141
  rowsPerPage?: number;
136
142
  scrollParent?: HTMLElement | "window" | (() => HTMLElement | null);
137
143
  selectableCells?: boolean;
@@ -2,6 +2,7 @@ import UpdateDataProps from "./UpdateCellProps";
2
2
  import ColumnDef, { Accessor } from "./ColumnDef";
3
3
  import TableRow from "./TableRow";
4
4
  import Row from "./Row";
5
+ import type { RowData } from "./Row";
5
6
  import SortColumn, { SortDirection } from "./SortColumn";
6
7
  import { TableFilterState, FilterCondition } from "./FilterTypes";
7
8
  import Cell from "./Cell";
@@ -9,31 +10,31 @@ import type { PinnedSectionsState } from "./PinnedSectionsState";
9
10
  import type { PivotConfig } from "./PivotTypes";
10
11
  import type { ColumnVisibilityState } from "./ColumnVisibilityTypes";
11
12
  import type { RowId } from "./RowId";
12
- export interface SetHeaderRenameProps {
13
- accessor: Accessor;
13
+ export interface SetHeaderRenameProps<TData extends RowData = Row> {
14
+ accessor: Accessor<TData>;
14
15
  }
15
16
  export interface ExportToCSVProps {
16
17
  filename?: string;
17
18
  }
18
- export type TableAPI = {
19
- updateData: (props: UpdateDataProps) => void;
20
- setHeaderRename: (props: SetHeaderRenameProps) => void;
21
- getVisibleRows: () => TableRow[];
22
- getAllRows: () => TableRow[];
23
- getHeaders: () => ColumnDef[];
19
+ export type TableAPI<TData extends RowData = Row> = {
20
+ updateData: (props: UpdateDataProps<TData>) => void;
21
+ setHeaderRename: (props: SetHeaderRenameProps<TData>) => void;
22
+ getVisibleRows: () => TableRow<TData>[];
23
+ getAllRows: () => TableRow<TData>[];
24
+ getHeaders: () => ColumnDef<TData, any>[];
24
25
  exportToCSV: (props?: ExportToCSVProps) => void;
25
26
  getSortState: () => SortColumn | null;
26
27
  applySortState: (props?: {
27
- accessor: Accessor;
28
+ accessor: Accessor<TData>;
28
29
  direction?: SortDirection;
29
30
  }) => Promise<void>;
30
31
  /** Ordered root accessors per pin section (left, main/unpinned, right) */
31
32
  getPinnedState: () => PinnedSectionsState;
32
33
  /** Reorder root columns and set pinned flags; lists must include every root accessor exactly once. Essential order is clamped per section. */
33
34
  applyPinnedState: (state: PinnedSectionsState) => Promise<void>;
34
- getFilterState: () => TableFilterState;
35
- applyFilter: (filter: FilterCondition) => Promise<void>;
36
- clearFilter: (accessor: Accessor) => Promise<void>;
35
+ getFilterState: () => TableFilterState<TData>;
36
+ applyFilter: (filter: FilterCondition<TData>) => Promise<void>;
37
+ clearFilter: (accessor: Accessor<TData>) => Promise<void>;
37
38
  clearAllFilters: () => Promise<void>;
38
39
  getCurrentPage: () => number;
39
40
  getTotalPages: () => number;
@@ -45,8 +46,8 @@ export type TableAPI = {
45
46
  toggleDepth: (depth: number) => void;
46
47
  setExpandedDepths: (depths: Set<number>) => void;
47
48
  getExpandedDepths: () => Set<number>;
48
- getGroupingProperty: (depth: number) => Accessor | undefined;
49
- getGroupingDepth: (property: Accessor) => number;
49
+ getGroupingProperty: (depth: number) => Accessor<TData> | undefined;
50
+ getGroupingDepth: (property: Accessor<TData>) => number;
50
51
  toggleColumnEditor: (open?: boolean) => void;
51
52
  applyColumnVisibility: (visibility: ColumnVisibilityState) => Promise<void>;
52
53
  /**
@@ -67,19 +68,23 @@ export type TableAPI = {
67
68
  */
68
69
  getSelectedRows: () => Set<RowId>;
69
70
  /** Row data objects for currently selected rows (resolved from visible/current table rows). */
70
- getSelectedRowsData: () => Row[];
71
+ getSelectedRowsData: () => TData[];
71
72
  /** Look up a row by row id in the current table rows. */
72
- getRow: (rowId: RowId) => Row | undefined;
73
+ getRow: (rowId: RowId) => TData | undefined;
73
74
  selectRow: (rowId: RowId) => void;
74
75
  deselectRow: (rowId: RowId) => void;
75
76
  toggleRowSelection: (rowId: RowId) => void;
76
77
  /** Clears row selection only (does not clear cell selection). */
77
78
  clearRowSelection: () => void;
78
79
  /** Enable, update, or clear matrix pivot (`null` disables). */
79
- setPivot: (config: PivotConfig | null) => void;
80
- getPivot: () => PivotConfig | null;
80
+ setPivot: (config: PivotConfig<TData> | null) => void;
81
+ getPivot: () => PivotConfig<TData> | null;
81
82
  /** Generated headers while pivot is active; otherwise current headers. */
82
83
  getPivotHeaders: () => ColumnDef[];
83
- /** Post-pivot rows (pre-flatten) while pivot is active; otherwise source rows. */
84
+ /**
85
+ * Post-pivot rows (pre-flatten) while pivot is active; otherwise source rows.
86
+ * Always {@link Row} — pivot injects synthetic keys (e.g. `__pivotChildren`)
87
+ * that are not part of consumer `TData`.
88
+ */
84
89
  getPivotedRows: () => Row[];
85
90
  };
@@ -1,13 +1,14 @@
1
1
  import Row from "./Row";
2
+ import type { RowData } from "./Row";
2
3
  import RowState from "./RowState";
3
4
  import ColumnDef, { Accessor } from "./ColumnDef";
4
- type TableRow = {
5
+ type TableRow<TData extends RowData = Row> = {
5
6
  depth: number;
6
7
  displayPosition: number;
7
8
  groupingKey?: string;
8
9
  isLastGroupRow: boolean;
9
10
  position: number;
10
- row: Row;
11
+ row: TData;
11
12
  rowId: (string | number)[];
12
13
  /**
13
14
  * Position-independent identity for the row, used as the basis for the
@@ -23,12 +24,12 @@ type TableRow = {
23
24
  rowIndexPath?: number[];
24
25
  stateIndicator?: {
25
26
  parentRowId: string | number;
26
- parentRow: Row;
27
+ parentRow: TData;
27
28
  state: RowState;
28
29
  };
29
30
  isLoadingSkeleton?: boolean;
30
31
  nestedTable?: {
31
- parentRow: Row;
32
+ parentRow: TData;
32
33
  expandableHeader: ColumnDef;
33
34
  childAccessor: Accessor;
34
35
  calculatedHeight: number;
@@ -1,8 +1,10 @@
1
1
  import { CellValue } from "..";
2
2
  import { Accessor } from "./ColumnDef";
3
+ import type Row from "./Row";
4
+ import type { RowData } from "./Row";
3
5
  import type { RowId } from "./RowId";
4
- type UpdateDataBase = {
5
- accessor: Accessor;
6
+ type UpdateDataBase<TData extends RowData = Row> = {
7
+ accessor: Accessor<TData>;
6
8
  newValue: CellValue;
7
9
  };
8
10
  /**
@@ -10,7 +12,7 @@ type UpdateDataBase = {
10
12
  * When both are provided, `rowId` wins. `rowIndex` is the index into the
11
13
  * unsorted source `rows` array — not the sorted/visible position.
12
14
  */
13
- type UpdateDataProps = UpdateDataBase & ({
15
+ type UpdateDataProps<TData extends RowData = Row> = UpdateDataBase<TData> & ({
14
16
  rowId: RowId;
15
17
  rowIndex?: number;
16
18
  } | {
@@ -17,6 +17,9 @@ export type HoveredSeparator = {
17
17
  } | null;
18
18
  export declare const findAndMarkParentsVisible: (headers: ColumnDef[], childAccessor: Accessor, visited?: Set<string>) => void;
19
19
  export declare const areAllChildrenHidden: (children: ColumnDef[]) => boolean;
20
+ export declare const areAllChildrenVisible: (children: ColumnDef[]) => boolean;
21
+ /** Recursively marks every header in the subtree as visible. */
22
+ export declare const showAllDescendants: (children: ColumnDef[]) => void;
20
23
  export declare const updateParentHeaders: (headers: ColumnDef[]) => void;
21
24
  export declare const buildColumnVisibilityState: (headers: ColumnDef[]) => ColumnVisibilityState;
22
25
  export declare const findClosestValidSeparatorIndex: ({ flattenedHeaders, draggingRow, hoveredRowIndex, isTopHalfOfRow, }: {
@@ -3,19 +3,24 @@
3
3
  */
4
4
  export interface CreateCheckboxOptions {
5
5
  checked: boolean;
6
+ /** When true, shows a minus mark and sets aria-checked="mixed" (partial selection). */
7
+ indeterminate?: boolean;
6
8
  onChange: (checked: boolean) => void;
7
9
  ariaLabel?: string;
8
10
  }
9
11
  /** Shared checkmark SVG for checkbox custom visual (used by createCheckbox and update helpers). */
10
12
  export declare const createCheckmarkSVG: () => SVGSVGElement;
13
+ /** Shared minus SVG for indeterminate checkbox custom visual. */
14
+ export declare const createMinusSVG: () => SVGSVGElement;
11
15
  /**
12
16
  * Updates an existing checkbox DOM (created by createCheckbox) to match the given checked state.
13
17
  * Use when the checkbox element is reused (e.g. from cache) and selection state changed.
18
+ * Clears any indeterminate state.
14
19
  * @param container - Element that contains .st-checkbox-input and .st-checkbox-custom (the label or a parent)
15
20
  */
16
21
  export declare const updateCheckboxElement: (container: HTMLElement, checked: boolean) => void;
17
- export declare const createCheckbox: ({ checked, onChange, ariaLabel }: CreateCheckboxOptions) => {
22
+ export declare const createCheckbox: ({ checked, indeterminate, onChange, ariaLabel, }: CreateCheckboxOptions) => {
18
23
  element: HTMLLabelElement;
19
- update: (newChecked: boolean) => void;
24
+ update: (newChecked: boolean, newIndeterminate?: boolean) => void;
20
25
  destroy: () => void;
21
26
  };
@@ -1,14 +1,17 @@
1
1
  import type ColumnDef from "../types/ColumnDef";
2
2
  import type { SimpleTableConfig } from "../types/SimpleTableConfig";
3
+ import type Row from "../types/Row";
4
+ import type { RowData } from "../types/Row";
3
5
  /**
4
6
  * Consumer-facing config input. Preferred prop names only — no legacy aliases.
5
7
  */
6
- export type SimpleTableConfigInput = SimpleTableConfig;
8
+ export type SimpleTableConfigInput<TData extends RowData = Row> = SimpleTableConfig<TData>;
7
9
  /** Pass-through for column trees (kept for call-site stability / future transforms). */
8
10
  export declare function normalizeColumnDef(header: ColumnDef): ColumnDef;
9
11
  export declare function normalizeColumnDefs(headers: ColumnDef[]): ColumnDef[];
10
12
  /**
11
13
  * Validate and normalize config. Requires `columns`.
14
+ * Runtime always normalizes to the default {@link Row}-shaped config.
12
15
  */
13
16
  export declare function normalizeConfig(input: SimpleTableConfigInput): SimpleTableConfig;
14
17
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-table-core",
3
- "version": "4.0.8",
3
+ "version": "4.1.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",