@undevy-org/tablewright 0.2.1 → 0.3.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.
- package/dist/es/hooks/table-orchestration/use-column-filter-stats.js +38 -0
- package/dist/es/hooks/table-orchestration/use-column-gaps.js +31 -0
- package/dist/es/hooks/table-orchestration/use-filtered-rows.js +32 -0
- package/dist/es/hooks/table-orchestration/use-orchestration-actions.js +182 -0
- package/dist/es/hooks/table-orchestration/use-responsive-columns.js +35 -0
- package/dist/es/hooks/useTableOrchestration.js +69 -264
- package/dist/es/index.js +2 -1
- package/dist/es/lib/column-gaps.js +5 -1
- package/dist/tablewright.cjs +390 -289
- package/dist/types/hooks/table-orchestration/use-column-filter-stats.d.ts +6 -0
- package/dist/types/hooks/table-orchestration/use-column-gaps.d.ts +15 -0
- package/dist/types/hooks/table-orchestration/use-filtered-rows.d.ts +15 -0
- package/dist/types/hooks/table-orchestration/use-orchestration-actions.d.ts +49 -0
- package/dist/types/hooks/table-orchestration/use-responsive-columns.d.ts +10 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/column-gaps.d.ts +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ColumnFilterConfig, FilterStatsSlice } from "../../components/data-table/filter-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* `all` stats come from every row; `filtered` from the filtered rows, or
|
|
4
|
+
* `null` while no column filter or search is applied.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useColumnFilterStats<TRow extends object>(rows: TRow[], filteredRows: TRow[], filterConfigs: Record<string, ColumnFilterConfig>, isFiltered: boolean): Record<string, FilterStatsSlice>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { VisibilityState } from "@tanstack/react-table";
|
|
2
|
+
import type { ColumnGap, ColumnGroup } from "../../components/data-table/filter-types.js";
|
|
3
|
+
import type { ColumnMetaDef } from "../../components/data-table/types.js";
|
|
4
|
+
/** Gap indicators for hidden columns, plus column meta/widths extended with the gap columns. */
|
|
5
|
+
export declare function useColumnGaps({ columnGroups, toggleableColumnIds, columnVisibility, columnMeta, widths, }: {
|
|
6
|
+
columnGroups: ColumnGroup[] | undefined;
|
|
7
|
+
toggleableColumnIds: readonly string[];
|
|
8
|
+
columnVisibility: VisibilityState;
|
|
9
|
+
columnMeta: Record<string, ColumnMetaDef>;
|
|
10
|
+
widths: Record<string, number>;
|
|
11
|
+
}): {
|
|
12
|
+
columnGaps: ColumnGap[];
|
|
13
|
+
extendedColumnMeta: Record<string, ColumnMetaDef>;
|
|
14
|
+
extendedWidths: Record<string, number>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ActiveFilter, ViewPreset } from "../../components/data-table/filter-types.js";
|
|
2
|
+
/** Rows after the preset's custom filter, the submitted search and column filters, then sorted. */
|
|
3
|
+
export declare function useFilteredRows<TRow extends object, TViewKey extends string>({ rows, activePreset, searchQuery, columnFilters, currentSort, filterRow, getSearchText, getSortValue, }: {
|
|
4
|
+
rows: TRow[];
|
|
5
|
+
activePreset: ViewPreset<TRow, TViewKey>;
|
|
6
|
+
searchQuery: string;
|
|
7
|
+
columnFilters: ActiveFilter[];
|
|
8
|
+
currentSort: {
|
|
9
|
+
columnId: string;
|
|
10
|
+
direction: "asc" | "desc";
|
|
11
|
+
} | null;
|
|
12
|
+
filterRow: (row: TRow, filter: ActiveFilter) => boolean;
|
|
13
|
+
getSearchText: (row: TRow) => string;
|
|
14
|
+
getSortValue: (row: TRow, columnId: string) => string | number;
|
|
15
|
+
}): TRow[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { VisibilityState } from "@tanstack/react-table";
|
|
2
|
+
import type { ActiveFilterValue, ColumnFilterConfig, ViewPreset } from "../../components/data-table/filter-types.js";
|
|
3
|
+
import type { ColumnMetaDef } from "../../components/data-table/types.js";
|
|
4
|
+
import { type TableOrchestrationStoreApi } from "../table-orchestration-store.js";
|
|
5
|
+
/**
|
|
6
|
+
* Store actions bound into stable callbacks with the hook's public signatures
|
|
7
|
+
* (`handleX` / React-style setters). Each callback's deps are exactly what it
|
|
8
|
+
* reads, so identities only change when those inputs do.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useOrchestrationActions<TRow extends object, TViewKey extends string>({ store, viewPresets, filterConfigs, columnMeta, setWidths, defaultViewKey, paginatedRows, allOnPageSelected, getRowId, }: {
|
|
11
|
+
store: TableOrchestrationStoreApi<TViewKey>;
|
|
12
|
+
viewPresets: ViewPreset<TRow, TViewKey>[];
|
|
13
|
+
filterConfigs: Record<string, ColumnFilterConfig>;
|
|
14
|
+
columnMeta: Record<string, ColumnMetaDef>;
|
|
15
|
+
setWidths: (updater: (prev: Record<string, number>) => Record<string, number>) => void;
|
|
16
|
+
defaultViewKey: TViewKey;
|
|
17
|
+
paginatedRows: TRow[];
|
|
18
|
+
allOnPageSelected: boolean;
|
|
19
|
+
getRowId: (row: TRow) => string;
|
|
20
|
+
}): {
|
|
21
|
+
handleSearchSubmit: (e: React.FormEvent) => void;
|
|
22
|
+
handleHeaderSort: (columnId: string, direction: "asc" | "desc") => void;
|
|
23
|
+
handleViewChange: (key: TViewKey) => void;
|
|
24
|
+
handleAddColumnFilter: (columnId: string) => void;
|
|
25
|
+
handleOpenExistingFilter: (columnId: string) => void;
|
|
26
|
+
handleRequestOpenHandled: () => void;
|
|
27
|
+
handleRemoveColumnFilter: (columnId: string) => void;
|
|
28
|
+
handleChangeColumnFilter: (columnId: string, value: ActiveFilterValue) => void;
|
|
29
|
+
handleSetColumnFilter: (columnId: string, value: ActiveFilterValue) => void;
|
|
30
|
+
handleHeaderFilterClick: (columnId: string) => void;
|
|
31
|
+
handleHideColumn: (columnId: string) => void;
|
|
32
|
+
handleResetColumns: () => void;
|
|
33
|
+
handleRemoveSort: () => void;
|
|
34
|
+
handleRemoveCustomFilter: () => void;
|
|
35
|
+
handleClearAll: () => void;
|
|
36
|
+
handleRefresh: () => void;
|
|
37
|
+
handleToggleRowSelection: (id: string) => void;
|
|
38
|
+
handleToggleHeaderCheck: () => void;
|
|
39
|
+
handleExpandRow: (row: TRow, e: React.MouseEvent) => void;
|
|
40
|
+
handleExpandGap: (hiddenIds: string[]) => void;
|
|
41
|
+
handlePageChange: (p: number) => void;
|
|
42
|
+
handleRowsPerPageChange: (value: number) => void;
|
|
43
|
+
setSearchInput: (v: string) => void;
|
|
44
|
+
setColumnVisibility: import("react").Dispatch<import("react").SetStateAction<VisibilityState>>;
|
|
45
|
+
setDensity: (v: "normal" | "dense") => void;
|
|
46
|
+
setSelectedIds: import("react").Dispatch<import("react").SetStateAction<Set<string>>>;
|
|
47
|
+
setColumnsMenuOpen: (v: boolean) => void;
|
|
48
|
+
setSelectedRowId: (v: string | null) => void;
|
|
49
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Responsive column collapse (P1/P2/P3). Only P3 columns collapse below
|
|
3
|
+
* `wideBreakpoint`; `isCompact` flips below `compactBreakpoint` so consumers
|
|
4
|
+
* can switch to a card layout. Both start at their "wide" values so the first
|
|
5
|
+
* client render matches server HTML.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useResponsiveColumns(columnPriorities: Record<string, 2 | 3> | undefined, wideBreakpoint: number, compactBreakpoint: number): {
|
|
8
|
+
responsiveHiddenColumnIds: ReadonlySet<string>;
|
|
9
|
+
isCompact: boolean;
|
|
10
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -96,7 +96,7 @@ export { createTableOrchestrationStore, defaultValueForFilter, } from "./hooks/t
|
|
|
96
96
|
export type { TableOrchestrationState, TableOrchestrationActions, TableOrchestrationStore, TableOrchestrationStoreApi, } from "./hooks/table-orchestration-store.js";
|
|
97
97
|
export { useRowDragOverride } from "./hooks/useRowDragOverride.js";
|
|
98
98
|
export type { UseRowDragOverrideResult } from "./hooks/useRowDragOverride.js";
|
|
99
|
-
export { computeColumnGaps } from "./lib/column-gaps.js";
|
|
99
|
+
export { computeColumnGaps, gapColumnId } from "./lib/column-gaps.js";
|
|
100
100
|
export { computeColumnStats } from "./lib/filter-stats.js";
|
|
101
101
|
export { formatEnumLabel } from "./lib/format-enum.js";
|
|
102
102
|
export { formatDateParts, parsePossibleTimestamp, formatLiveTimestamp, displayTimeZone, } from "./lib/format-timestamp.js";
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { VisibilityState } from "@tanstack/react-table";
|
|
2
2
|
import type { ColumnGap } from "../components/data-table/filter-types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Column id of the gap indicator column placed after `afterColumnId` (`null` =
|
|
5
|
+
* at the start). `useTableOrchestration` keys `extendedColumnMeta` /
|
|
6
|
+
* `extendedWidths` by it, so gap columns you define must use the same id.
|
|
7
|
+
*/
|
|
8
|
+
export declare function gapColumnId(afterColumnId: string | null): string;
|
|
3
9
|
export declare function computeColumnGaps(orderedColumnIds: readonly string[], columnVisibility: VisibilityState): ColumnGap[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@undevy-org/tablewright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React data-table and application-shell components: filters, drawers, row controls, sortable and resizable columns, built on Radix UI and TanStack Table.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|