react-glide-table 1.1.1 → 1.1.3

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.
@@ -0,0 +1,220 @@
1
+ import { ColumnDef, RowSelectionState, Updater, Row } from '@tanstack/react-table';
2
+ import { ReactNode, ComponentType } from 'react';
3
+
4
+ type DataTableLabels = {
5
+ empty: string;
6
+ loading: string;
7
+ selection: (selectedCount: number) => ReactNode;
8
+ expandRow: string;
9
+ collapseRow: string;
10
+ };
11
+ /** Default copy. Override via the `labels` option. */
12
+ declare const DEFAULT_DATA_TABLE_LABELS: DataTableLabels;
13
+ declare function resolveDataTableLabels(partial?: Partial<DataTableLabels>): DataTableLabels;
14
+
15
+ type RowSelectionMode = "none" | "single" | "multi";
16
+ type CellEditType = "text" | "number";
17
+
18
+ declare module "@tanstack/react-table" {
19
+ interface ColumnMeta<TData, TValue> {
20
+ /** Whether this column participates in vertical row spanning */
21
+ rowSpan?: boolean;
22
+ /** Merge key field. Falls back to the column id when omitted */
23
+ rowSpanKey?: string;
24
+ align?: "left" | "center" | "right";
25
+ className?: string;
26
+ headerClassName?: string;
27
+ /** When true, double-click starts inline editing */
28
+ editable?: boolean;
29
+ /** Inline editor input type. Defaults to text */
30
+ editType?: CellEditType;
31
+ }
32
+ }
33
+ type DataTableProps<T extends Record<string, unknown>> = {
34
+ data: T[];
35
+ columns: ColumnDef<T, unknown>[];
36
+ rowSelectionMode?: RowSelectionMode;
37
+ rowSelection?: RowSelectionState;
38
+ onRowSelectionChange?: (updater: Updater<RowSelectionState>) => void;
39
+ /** Total row count before filtering */
40
+ totalCount?: number;
41
+ /** Visible row count after filtering */
42
+ filteredCount?: number;
43
+ /** Left-side summary slot */
44
+ summary?: ReactNode;
45
+ /** Right-side action slot */
46
+ toolbar?: ReactNode;
47
+ /**
48
+ * UI copy overrides.
49
+ * Takes precedence over `emptyText` / `selectionLabel`.
50
+ */
51
+ labels?: Partial<DataTableLabels>;
52
+ /** @deprecated Prefer `labels.selection` */
53
+ selectionLabel?: (selectedCount: number) => ReactNode;
54
+ isPending?: boolean;
55
+ /** @deprecated Prefer `labels.empty` */
56
+ emptyText?: string;
57
+ /** @deprecated Prefer `labels.loading` */
58
+ loadingText?: string;
59
+ enableRowSpan?: boolean;
60
+ getRowId?: (row: T, index: number) => string;
61
+ onRowClick?: (row: T, index: number) => void;
62
+ preserveRowSelection?: boolean;
63
+ getRowClassName?: (row: T, index: number) => string | undefined;
64
+ /** Return false to make the row unselectable (row click and checkbox) */
65
+ getRowCanSelect?: (row: T, index: number) => boolean;
66
+ /** When false, row click does not toggle selection (checkbox-only) */
67
+ selectOnRowClick?: boolean;
68
+ /**
69
+ * Enable cell drag selection and fill handle. Defaults to true.
70
+ * When false, browser text selection is allowed and cell selection UI is off.
71
+ */
72
+ enableCellSelection?: boolean;
73
+ /**
74
+ * @deprecated Combining with paged/tree-transformed data can corrupt the source.
75
+ * Prefer onCellChange / onBatchChange.
76
+ */
77
+ onDataChange?: (data: T[]) => void;
78
+ /** Single-cell change (edit commit). Takes precedence over onDataChange */
79
+ onCellChange?: (rowId: string, columnId: string, value: unknown) => void;
80
+ /** Multi-cell change (fill handle, etc.). Takes precedence over onDataChange */
81
+ onBatchChange?: (changes: Array<{
82
+ rowId: string;
83
+ columnId: string;
84
+ value: unknown;
85
+ }>) => void;
86
+ /**
87
+ * Root className hook (combined with `DataTableJSX`).
88
+ * The package ships no CSS — style these hooks yourself or leave unstyled.
89
+ */
90
+ className?: string;
91
+ /**
92
+ * Per-part class hooks for Tailwind / utility CSS.
93
+ * Combined with semantic hooks (`DataTableJSX`, `data-table-cell`, …).
94
+ * Prefer `data-*` state variants, e.g. `row: "data-[selected]:bg-blue-600"`.
95
+ */
96
+ classNames?: DataTableClassNames;
97
+ /** Expand key field. Enables tree conversion / expand UI when set. Default `id` */
98
+ toggleField?: string;
99
+ /** Child → parent reference field. Default `parentId` */
100
+ childField?: string;
101
+ /** Nested children array field. Default `children` */
102
+ flattenField?: string;
103
+ /** Parent quantity field used for parentCount. Default `qty` */
104
+ qtyField?: string;
105
+ /** Expanded row key set (controlled) */
106
+ expandedRows?: Set<string>;
107
+ onExpandedRowsChange?: (next: Set<string>) => void;
108
+ /** When true, expand is disabled (children always visible) */
109
+ preventExpand?: boolean;
110
+ /**
111
+ * Enable row virtualization. Defaults to true.
112
+ * Forced off when enableRowSpan is true to preserve merges
113
+ * (HTML table + spacer rows; no absolute/translateY positioning).
114
+ */
115
+ enableVirtualization?: boolean;
116
+ /** Estimated virtual row height in px. Default 44; refined via measureElement */
117
+ estimateRowHeight?: number;
118
+ /** Virtualization overscan row count. Default 8 */
119
+ virtualOverscan?: number;
120
+ /**
121
+ * Optional UI part replacements for the unstyled DataTable renderer.
122
+ * Use with `createTable` / `Table.Column`, or pass columns directly to `DataTable`.
123
+ */
124
+ slots?: DataTableSlots<T>;
125
+ };
126
+ /**
127
+ * Named class hooks for the default DataTable shell.
128
+ * Pass Tailwind utilities directly without writing a separate CSS mapping file.
129
+ */
130
+ type DataTableClassNames = {
131
+ root?: string;
132
+ pending?: string;
133
+ loadingText?: string;
134
+ toolbar?: string;
135
+ toolbarLeft?: string;
136
+ toolbarRight?: string;
137
+ toolbarCount?: string;
138
+ toolbarSelection?: string;
139
+ toolbarActions?: string;
140
+ scroll?: string;
141
+ table?: string;
142
+ head?: string;
143
+ headRow?: string;
144
+ headCell?: string;
145
+ body?: string;
146
+ emptyCell?: string;
147
+ virtualSpacer?: string;
148
+ virtualSpacerCell?: string;
149
+ row?: string;
150
+ cell?: string;
151
+ cellEditInput?: string;
152
+ expandCell?: string;
153
+ expandCellContent?: string;
154
+ expandCellIndent?: string;
155
+ expandCellValue?: string;
156
+ expandToggle?: string;
157
+ expandToggleIcon?: string;
158
+ fillHandle?: string;
159
+ };
160
+ type DataTableToolbarSlotProps = {
161
+ filteredCount?: number;
162
+ totalCount?: number;
163
+ summary?: ReactNode;
164
+ selectedCount: number;
165
+ selectionLabel?: (selectedCount: number) => ReactNode;
166
+ toolbar?: ReactNode;
167
+ className?: string;
168
+ classNames?: Pick<DataTableClassNames, "toolbar" | "toolbarLeft" | "toolbarRight" | "toolbarCount" | "toolbarSelection" | "toolbarActions">;
169
+ };
170
+ type DataTableRowSlotProps<T extends Record<string, unknown>> = {
171
+ row: Row<T>;
172
+ onToggleSelect: () => void;
173
+ virtualIndex?: number;
174
+ measureElement?: (node: Element | null) => void;
175
+ };
176
+ /**
177
+ * Slot replacements for the default DataTable shell (semantic HTML + behavior only).
178
+ * Row-level custom UI → `Row`; cell content → `Table.Column` / column `render`.
179
+ * Header/Cell are not split into separate slots in this contract.
180
+ */
181
+ type DataTableSlots<T extends Record<string, unknown>> = {
182
+ /** Top summary / actions region */
183
+ Toolbar?: ComponentType<DataTableToolbarSlotProps>;
184
+ /** Full row replacement (cells, selection, edit UI) */
185
+ Row?: ComponentType<DataTableRowSlotProps<T>>;
186
+ /** Replace the pending state view */
187
+ Pending?: ComponentType<{
188
+ loadingText: string;
189
+ className?: string;
190
+ classNames?: Pick<DataTableClassNames, "pending" | "loadingText" | "root">;
191
+ }>;
192
+ /** Replace the empty-state cell content */
193
+ Empty?: ComponentType<{
194
+ emptyText: string;
195
+ columnCount: number;
196
+ classNames?: Pick<DataTableClassNames, "emptyCell">;
197
+ }>;
198
+ };
199
+ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyof T & string> = {
200
+ /** Column id: data field name, or an arbitrary id for virtual columns */
201
+ field: K;
202
+ /** When true, uses id only (no accessorKey) — e.g. checkbox / No. columns */
203
+ virtual?: boolean;
204
+ children?: ReactNode;
205
+ sortable?: boolean;
206
+ width?: number;
207
+ align?: "left" | "center" | "right";
208
+ rowSpan?: boolean;
209
+ rowSpanKey?: string;
210
+ editable?: boolean;
211
+ editType?: CellEditType;
212
+ className?: string;
213
+ headerClassName?: string;
214
+ render?: (value: K extends keyof T ? T[K] : unknown, row: Row<T>, index: number) => ReactNode;
215
+ };
216
+ type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "columns"> & {
217
+ children: ReactNode;
218
+ };
219
+
220
+ export { type CellEditType as C, DEFAULT_DATA_TABLE_LABELS as D, type RowSelectionMode as R, type TableColumnProps as T, type DataTableClassNames as a, type DataTableLabels as b, type DataTableProps as c, type DataTableSlots as d, type TableProps as e, resolveDataTableLabels as r };
@@ -0,0 +1,220 @@
1
+ import { ColumnDef, RowSelectionState, Updater, Row } from '@tanstack/react-table';
2
+ import { ReactNode, ComponentType } from 'react';
3
+
4
+ type DataTableLabels = {
5
+ empty: string;
6
+ loading: string;
7
+ selection: (selectedCount: number) => ReactNode;
8
+ expandRow: string;
9
+ collapseRow: string;
10
+ };
11
+ /** Default copy. Override via the `labels` option. */
12
+ declare const DEFAULT_DATA_TABLE_LABELS: DataTableLabels;
13
+ declare function resolveDataTableLabels(partial?: Partial<DataTableLabels>): DataTableLabels;
14
+
15
+ type RowSelectionMode = "none" | "single" | "multi";
16
+ type CellEditType = "text" | "number";
17
+
18
+ declare module "@tanstack/react-table" {
19
+ interface ColumnMeta<TData, TValue> {
20
+ /** Whether this column participates in vertical row spanning */
21
+ rowSpan?: boolean;
22
+ /** Merge key field. Falls back to the column id when omitted */
23
+ rowSpanKey?: string;
24
+ align?: "left" | "center" | "right";
25
+ className?: string;
26
+ headerClassName?: string;
27
+ /** When true, double-click starts inline editing */
28
+ editable?: boolean;
29
+ /** Inline editor input type. Defaults to text */
30
+ editType?: CellEditType;
31
+ }
32
+ }
33
+ type DataTableProps<T extends Record<string, unknown>> = {
34
+ data: T[];
35
+ columns: ColumnDef<T, unknown>[];
36
+ rowSelectionMode?: RowSelectionMode;
37
+ rowSelection?: RowSelectionState;
38
+ onRowSelectionChange?: (updater: Updater<RowSelectionState>) => void;
39
+ /** Total row count before filtering */
40
+ totalCount?: number;
41
+ /** Visible row count after filtering */
42
+ filteredCount?: number;
43
+ /** Left-side summary slot */
44
+ summary?: ReactNode;
45
+ /** Right-side action slot */
46
+ toolbar?: ReactNode;
47
+ /**
48
+ * UI copy overrides.
49
+ * Takes precedence over `emptyText` / `selectionLabel`.
50
+ */
51
+ labels?: Partial<DataTableLabels>;
52
+ /** @deprecated Prefer `labels.selection` */
53
+ selectionLabel?: (selectedCount: number) => ReactNode;
54
+ isPending?: boolean;
55
+ /** @deprecated Prefer `labels.empty` */
56
+ emptyText?: string;
57
+ /** @deprecated Prefer `labels.loading` */
58
+ loadingText?: string;
59
+ enableRowSpan?: boolean;
60
+ getRowId?: (row: T, index: number) => string;
61
+ onRowClick?: (row: T, index: number) => void;
62
+ preserveRowSelection?: boolean;
63
+ getRowClassName?: (row: T, index: number) => string | undefined;
64
+ /** Return false to make the row unselectable (row click and checkbox) */
65
+ getRowCanSelect?: (row: T, index: number) => boolean;
66
+ /** When false, row click does not toggle selection (checkbox-only) */
67
+ selectOnRowClick?: boolean;
68
+ /**
69
+ * Enable cell drag selection and fill handle. Defaults to true.
70
+ * When false, browser text selection is allowed and cell selection UI is off.
71
+ */
72
+ enableCellSelection?: boolean;
73
+ /**
74
+ * @deprecated Combining with paged/tree-transformed data can corrupt the source.
75
+ * Prefer onCellChange / onBatchChange.
76
+ */
77
+ onDataChange?: (data: T[]) => void;
78
+ /** Single-cell change (edit commit). Takes precedence over onDataChange */
79
+ onCellChange?: (rowId: string, columnId: string, value: unknown) => void;
80
+ /** Multi-cell change (fill handle, etc.). Takes precedence over onDataChange */
81
+ onBatchChange?: (changes: Array<{
82
+ rowId: string;
83
+ columnId: string;
84
+ value: unknown;
85
+ }>) => void;
86
+ /**
87
+ * Root className hook (combined with `DataTableJSX`).
88
+ * The package ships no CSS — style these hooks yourself or leave unstyled.
89
+ */
90
+ className?: string;
91
+ /**
92
+ * Per-part class hooks for Tailwind / utility CSS.
93
+ * Combined with semantic hooks (`DataTableJSX`, `data-table-cell`, …).
94
+ * Prefer `data-*` state variants, e.g. `row: "data-[selected]:bg-blue-600"`.
95
+ */
96
+ classNames?: DataTableClassNames;
97
+ /** Expand key field. Enables tree conversion / expand UI when set. Default `id` */
98
+ toggleField?: string;
99
+ /** Child → parent reference field. Default `parentId` */
100
+ childField?: string;
101
+ /** Nested children array field. Default `children` */
102
+ flattenField?: string;
103
+ /** Parent quantity field used for parentCount. Default `qty` */
104
+ qtyField?: string;
105
+ /** Expanded row key set (controlled) */
106
+ expandedRows?: Set<string>;
107
+ onExpandedRowsChange?: (next: Set<string>) => void;
108
+ /** When true, expand is disabled (children always visible) */
109
+ preventExpand?: boolean;
110
+ /**
111
+ * Enable row virtualization. Defaults to true.
112
+ * Forced off when enableRowSpan is true to preserve merges
113
+ * (HTML table + spacer rows; no absolute/translateY positioning).
114
+ */
115
+ enableVirtualization?: boolean;
116
+ /** Estimated virtual row height in px. Default 44; refined via measureElement */
117
+ estimateRowHeight?: number;
118
+ /** Virtualization overscan row count. Default 8 */
119
+ virtualOverscan?: number;
120
+ /**
121
+ * Optional UI part replacements for the unstyled DataTable renderer.
122
+ * Use with `createTable` / `Table.Column`, or pass columns directly to `DataTable`.
123
+ */
124
+ slots?: DataTableSlots<T>;
125
+ };
126
+ /**
127
+ * Named class hooks for the default DataTable shell.
128
+ * Pass Tailwind utilities directly without writing a separate CSS mapping file.
129
+ */
130
+ type DataTableClassNames = {
131
+ root?: string;
132
+ pending?: string;
133
+ loadingText?: string;
134
+ toolbar?: string;
135
+ toolbarLeft?: string;
136
+ toolbarRight?: string;
137
+ toolbarCount?: string;
138
+ toolbarSelection?: string;
139
+ toolbarActions?: string;
140
+ scroll?: string;
141
+ table?: string;
142
+ head?: string;
143
+ headRow?: string;
144
+ headCell?: string;
145
+ body?: string;
146
+ emptyCell?: string;
147
+ virtualSpacer?: string;
148
+ virtualSpacerCell?: string;
149
+ row?: string;
150
+ cell?: string;
151
+ cellEditInput?: string;
152
+ expandCell?: string;
153
+ expandCellContent?: string;
154
+ expandCellIndent?: string;
155
+ expandCellValue?: string;
156
+ expandToggle?: string;
157
+ expandToggleIcon?: string;
158
+ fillHandle?: string;
159
+ };
160
+ type DataTableToolbarSlotProps = {
161
+ filteredCount?: number;
162
+ totalCount?: number;
163
+ summary?: ReactNode;
164
+ selectedCount: number;
165
+ selectionLabel?: (selectedCount: number) => ReactNode;
166
+ toolbar?: ReactNode;
167
+ className?: string;
168
+ classNames?: Pick<DataTableClassNames, "toolbar" | "toolbarLeft" | "toolbarRight" | "toolbarCount" | "toolbarSelection" | "toolbarActions">;
169
+ };
170
+ type DataTableRowSlotProps<T extends Record<string, unknown>> = {
171
+ row: Row<T>;
172
+ onToggleSelect: () => void;
173
+ virtualIndex?: number;
174
+ measureElement?: (node: Element | null) => void;
175
+ };
176
+ /**
177
+ * Slot replacements for the default DataTable shell (semantic HTML + behavior only).
178
+ * Row-level custom UI → `Row`; cell content → `Table.Column` / column `render`.
179
+ * Header/Cell are not split into separate slots in this contract.
180
+ */
181
+ type DataTableSlots<T extends Record<string, unknown>> = {
182
+ /** Top summary / actions region */
183
+ Toolbar?: ComponentType<DataTableToolbarSlotProps>;
184
+ /** Full row replacement (cells, selection, edit UI) */
185
+ Row?: ComponentType<DataTableRowSlotProps<T>>;
186
+ /** Replace the pending state view */
187
+ Pending?: ComponentType<{
188
+ loadingText: string;
189
+ className?: string;
190
+ classNames?: Pick<DataTableClassNames, "pending" | "loadingText" | "root">;
191
+ }>;
192
+ /** Replace the empty-state cell content */
193
+ Empty?: ComponentType<{
194
+ emptyText: string;
195
+ columnCount: number;
196
+ classNames?: Pick<DataTableClassNames, "emptyCell">;
197
+ }>;
198
+ };
199
+ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyof T & string> = {
200
+ /** Column id: data field name, or an arbitrary id for virtual columns */
201
+ field: K;
202
+ /** When true, uses id only (no accessorKey) — e.g. checkbox / No. columns */
203
+ virtual?: boolean;
204
+ children?: ReactNode;
205
+ sortable?: boolean;
206
+ width?: number;
207
+ align?: "left" | "center" | "right";
208
+ rowSpan?: boolean;
209
+ rowSpanKey?: string;
210
+ editable?: boolean;
211
+ editType?: CellEditType;
212
+ className?: string;
213
+ headerClassName?: string;
214
+ render?: (value: K extends keyof T ? T[K] : unknown, row: Row<T>, index: number) => ReactNode;
215
+ };
216
+ type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "columns"> & {
217
+ children: ReactNode;
218
+ };
219
+
220
+ export { type CellEditType as C, DEFAULT_DATA_TABLE_LABELS as D, type RowSelectionMode as R, type TableColumnProps as T, type DataTableClassNames as a, type DataTableLabels as b, type DataTableProps as c, type DataTableSlots as d, type TableProps as e, resolveDataTableLabels as r };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-glide-table",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/zpxlffjrm/react-glide-table.git"
@@ -11,6 +11,7 @@
11
11
  "homepage": "https://github.com/zpxlffjrm/react-glide-table#readme",
12
12
  "type": "module",
13
13
  "license": "MIT",
14
+ "sideEffects": false,
14
15
  "engines": {
15
16
  "node": "^20.19.0 || >=22.12.0"
16
17
  },
@@ -22,6 +23,16 @@
22
23
  "types": "./dist/index.d.ts",
23
24
  "import": "./dist/index.js",
24
25
  "require": "./dist/index.cjs"
26
+ },
27
+ "./core": {
28
+ "types": "./dist/core.d.ts",
29
+ "import": "./dist/core.js",
30
+ "require": "./dist/core.cjs"
31
+ },
32
+ "./compound": {
33
+ "types": "./dist/compound.d.ts",
34
+ "import": "./dist/compound.js",
35
+ "require": "./dist/compound.cjs"
25
36
  }
26
37
  },
27
38
  "files": [