simple-table-core 4.1.0 → 4.1.1
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.
- package/dist/cjs/index.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.es.js +1 -1
- package/dist/types/GetRowClass.d.ts +15 -0
- package/dist/types/SimpleTableConfig.d.ts +3 -0
- package/dist/types/SimpleTableProps.d.ts +6 -0
- package/dist/utils/bodyCell/expansion.d.ts +8 -1
- package/dist/utils/bodyCell/types.d.ts +3 -0
- package/dist/utils/columnEditor/columnEditorUtils.d.ts +9 -0
- package/dist/utils/columnEditor/createCheckbox.d.ts +2 -2
- package/dist/utils/columnEditor/createColumnEditorRow.d.ts +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Row from "./Row";
|
|
2
|
+
import type { RowData } from "./Row";
|
|
3
|
+
export interface GetRowClassParams<TData extends RowData = Row> {
|
|
4
|
+
row: TData;
|
|
5
|
+
/** Table identity string for the row. Prefer matching on `row` for business ids. */
|
|
6
|
+
rowId: string;
|
|
7
|
+
/** 0-based index of the row in the table. */
|
|
8
|
+
position: number;
|
|
9
|
+
depth: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Return CSS class name(s) for the row, or `undefined` / `null` for default styling.
|
|
13
|
+
* Classes are applied to each body cell — style with `.st-cell.yourClass`.
|
|
14
|
+
*/
|
|
15
|
+
export type GetRowClass<TData extends RowData = Row> = (params: GetRowClassParams<TData>) => string | string[] | undefined | null;
|
|
@@ -18,6 +18,7 @@ import { RowButton } from "./RowButton";
|
|
|
18
18
|
import Theme from "./Theme";
|
|
19
19
|
import { CustomThemeProps } from "./CustomTheme";
|
|
20
20
|
import { GetRowId } from "./GetRowId";
|
|
21
|
+
import { GetRowClass } from "./GetRowClass";
|
|
21
22
|
import { ColumnEditorConfig } from "./ColumnEditorConfig";
|
|
22
23
|
import { VanillaIconsConfig } from "./IconsConfig";
|
|
23
24
|
import { QuickFilterConfig } from "./QuickFilterTypes";
|
|
@@ -137,6 +138,8 @@ export interface SimpleTableConfig<TData extends RowData = Row> {
|
|
|
137
138
|
*/
|
|
138
139
|
rowGrouping?: Accessor<TData>[];
|
|
139
140
|
getRowId?: GetRowId<TData>;
|
|
141
|
+
/** @see SimpleTableProps.getRowClass */
|
|
142
|
+
getRowClass?: GetRowClass<TData>;
|
|
140
143
|
rows: TData[];
|
|
141
144
|
rowsPerPage?: number;
|
|
142
145
|
scrollParent?: HTMLElement | "window" | (() => HTMLElement | null);
|
|
@@ -18,6 +18,7 @@ import { RowButton } from "./RowButton";
|
|
|
18
18
|
import Theme from "./Theme";
|
|
19
19
|
import { CustomThemeProps } from "./CustomTheme";
|
|
20
20
|
import { GetRowId } from "./GetRowId";
|
|
21
|
+
import { GetRowClass } from "./GetRowClass";
|
|
21
22
|
import { ColumnEditorConfig } from "./ColumnEditorConfig";
|
|
22
23
|
import { IconsConfig } from "./IconsConfig";
|
|
23
24
|
import { QuickFilterConfig } from "./QuickFilterTypes";
|
|
@@ -137,6 +138,11 @@ export interface SimpleTableProps<TData extends RowData = Row> {
|
|
|
137
138
|
*/
|
|
138
139
|
rowGrouping?: Accessor<TData>[];
|
|
139
140
|
getRowId?: GetRowId<TData>;
|
|
141
|
+
/**
|
|
142
|
+
* Return CSS class name(s) for the row. Applied to each body cell — style with
|
|
143
|
+
* `.st-cell.yourClass`. Return null/undefined for default styling.
|
|
144
|
+
*/
|
|
145
|
+
getRowClass?: GetRowClass<TData>;
|
|
140
146
|
rows: TData[];
|
|
141
147
|
rowsPerPage?: number;
|
|
142
148
|
scrollParent?: HTMLElement | "window" | (() => HTMLElement | null);
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { AbsoluteBodyCell, CellRenderContext } from "./types";
|
|
2
|
-
export
|
|
2
|
+
export type CreateExpandIconOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Invisible spacer that reserves the same width as a real expand caret.
|
|
5
|
+
* Used so leaf / non-expandable rows align with expandable siblings.
|
|
6
|
+
*/
|
|
7
|
+
placeholder?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const createExpandIcon: (cell: AbsoluteBodyCell, context: CellRenderContext, isExpanded: boolean, options?: CreateExpandIconOptions) => HTMLElement;
|
|
3
10
|
export type UpdateExpandIconStateOptions = {
|
|
4
11
|
/** aria-label when the group is expanded (chevron shows collapse action). */
|
|
5
12
|
ariaLabelWhenExpanded?: string;
|
|
@@ -7,6 +7,7 @@ import type TableRow from "../../types/TableRow";
|
|
|
7
7
|
import type RowState from "../../types/RowState";
|
|
8
8
|
import type { RowButton } from "../../types/RowButton";
|
|
9
9
|
import type { CustomTheme } from "../../types/CustomTheme";
|
|
10
|
+
import type { GetRowClass } from "../../types/GetRowClass";
|
|
10
11
|
import type { HeightOffsets } from "../infiniteScrollUtils";
|
|
11
12
|
import type { AccordionAxis } from "../accordionAnimation";
|
|
12
13
|
import type { VanillaEmptyStateRenderer, VanillaErrorStateRenderer, VanillaLoadingStateRenderer } from "../../types/RowStateRendererProps";
|
|
@@ -80,6 +81,8 @@ export interface CellRenderContext {
|
|
|
80
81
|
*/
|
|
81
82
|
hoverScopeId: string;
|
|
82
83
|
oddEvenRowBackground?: boolean;
|
|
84
|
+
/** Optional callback that returns CSS class name(s) for every body cell in a row. */
|
|
85
|
+
getRowClass?: GetRowClass;
|
|
83
86
|
rowGrouping?: string[];
|
|
84
87
|
headers: ColumnDef[];
|
|
85
88
|
/**
|
|
@@ -22,6 +22,15 @@ export declare const areAllChildrenVisible: (children: ColumnDef[]) => boolean;
|
|
|
22
22
|
export declare const showAllDescendants: (children: ColumnDef[]) => void;
|
|
23
23
|
export declare const updateParentHeaders: (headers: ColumnDef[]) => void;
|
|
24
24
|
export declare const buildColumnVisibilityState: (headers: ColumnDef[]) => ColumnVisibilityState;
|
|
25
|
+
/** Find a header node by accessor anywhere in the tree. */
|
|
26
|
+
export declare const findHeaderByAccessor: (headers: ColumnDef[], accessor: Accessor) => ColumnDef | null;
|
|
27
|
+
/**
|
|
28
|
+
* Tri-state checkbox values for a column-editor row (matches createColumnEditorRow).
|
|
29
|
+
*/
|
|
30
|
+
export declare const getColumnEditorCheckboxState: (header: ColumnDef) => {
|
|
31
|
+
checked: boolean;
|
|
32
|
+
indeterminate: boolean;
|
|
33
|
+
};
|
|
25
34
|
export declare const findClosestValidSeparatorIndex: ({ flattenedHeaders, draggingRow, hoveredRowIndex, isTopHalfOfRow, }: {
|
|
26
35
|
flattenedHeaders: FlattenedHeader[];
|
|
27
36
|
draggingRow: FlattenedHeader;
|
|
@@ -15,10 +15,10 @@ export declare const createMinusSVG: () => SVGSVGElement;
|
|
|
15
15
|
/**
|
|
16
16
|
* Updates an existing checkbox DOM (created by createCheckbox) to match the given checked state.
|
|
17
17
|
* Use when the checkbox element is reused (e.g. from cache) and selection state changed.
|
|
18
|
-
* Clears any indeterminate state.
|
|
18
|
+
* Clears any indeterminate state unless `indeterminate` is passed as true.
|
|
19
19
|
* @param container - Element that contains .st-checkbox-input and .st-checkbox-custom (the label or a parent)
|
|
20
20
|
*/
|
|
21
|
-
export declare const updateCheckboxElement: (container: HTMLElement, checked: boolean) => void;
|
|
21
|
+
export declare const updateCheckboxElement: (container: HTMLElement, checked: boolean, indeterminate?: boolean) => void;
|
|
22
22
|
export declare const createCheckbox: ({ checked, indeterminate, onChange, ariaLabel, }: CreateCheckboxOptions) => {
|
|
23
23
|
element: HTMLLabelElement;
|
|
24
24
|
update: (newChecked: boolean, newIndeterminate?: boolean) => void;
|
|
@@ -27,6 +27,12 @@ export interface CreateColumnEditorRowOptions {
|
|
|
27
27
|
icons?: IconsConfig;
|
|
28
28
|
essentialAccessors?: ReadonlySet<string>;
|
|
29
29
|
headers: ColumnDef[];
|
|
30
|
+
/**
|
|
31
|
+
* When set, visibility toggles read the latest header tree from here so the
|
|
32
|
+
* popout can keep row DOM across setHeaders (in-place checkbox sync) without
|
|
33
|
+
* stale closures overwriting newer hide flags.
|
|
34
|
+
*/
|
|
35
|
+
getHeaders?: () => ColumnDef[];
|
|
30
36
|
setHeaders: (headers: ColumnDef[]) => void;
|
|
31
37
|
onColumnVisibilityChange?: (state: ColumnVisibilityState) => void;
|
|
32
38
|
onColumnOrderChange?: (headers: ColumnDef[]) => void;
|