all-purpose-table 1.0.10 → 1.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # All Purpose Table
2
2
 
3
- A production-grade, plug-and-play React table component with TypeScript support and zero dependencies.
3
+ Plug-and-play React table component with TypeScript support and zero dependencies.
4
4
 
5
5
  Demos can be found at: https://apt-demos.vercel.app/
6
6
 
@@ -73,6 +73,11 @@ function App() {
73
73
  | `renderFullRow` | `(row) => ReactNode` | `undefined` | Render function for custom full-width rows (can be used as header/dropdown row) |
74
74
  | `mobileAutoSizeOnHeaderClick` | `boolean` | `false` | Enable mobile auto-sizing on header click |
75
75
  | `mobileBreakpoint` | `number` | `768` | Mobile breakpoint in pixels |
76
+ | `filterable` | `boolean` | `false` | Enable the Excel-style filter dropdown on every column (opt-in) |
77
+ | `striped` | `boolean` | `false` | Zebra striping — every other row gets a subtle darker background |
78
+ | `dividers` | `boolean` | `false` | Horizontal divider line beneath each row |
79
+ | `bordered` | `boolean` | `false` | Vertical divider lines between columns (grid look) |
80
+ | `density` | `"default" \| "compact"` | `"default"` | Row/cell padding density |
76
81
 
77
82
  ### TableHeader Interface
78
83
 
@@ -81,6 +86,7 @@ interface TableHeader {
81
86
  accessor: string; // Key to access data in row object
82
87
  label: string; // Display label for column
83
88
  isSortable?: boolean; // Enable sorting for this column
89
+ isFilterable?: boolean; // Override the table `filterable` prop for this column
84
90
  width?: string | number; // Initial column width
85
91
  minWidth?: string | number; // Minimum column width
86
92
  cellRenderer?: (args: {
@@ -91,6 +97,31 @@ interface TableHeader {
91
97
  }
92
98
  ```
93
99
 
100
+ ### Column Filtering
101
+
102
+ Set `filterable` on the table to add an Excel-style filter dropdown to every column. Each dropdown offers sort (asc/desc), a search box, and a checklist of the column's distinct values:
103
+
104
+ ```tsx
105
+ <Table manualHeaders={headers} manualRowData={data} filterable />
106
+ ```
107
+
108
+ The search box does double duty: it filters the rows by substring **and** narrows the value checklist. `isFilterable` on an individual column overrides the table-level default (set it to `false` to exclude a column, or `true` to enable just one column while `filterable` is off).
109
+
110
+ ### Style Options
111
+
112
+ Base styling is professional by default; these boolean props toggle common variations (they compose freely):
113
+
114
+ ```tsx
115
+ <Table
116
+ manualHeaders={headers}
117
+ manualRowData={data}
118
+ striped // alternating row backgrounds
119
+ dividers // horizontal line under each row
120
+ bordered // vertical lines between columns
121
+ density="compact" // tighter padding
122
+ />
123
+ ```
124
+
94
125
  ## 🔩 Advanced Usage
95
126
 
96
127
  ### Custom Cell Renderers
package/dist/index.d.mts CHANGED
@@ -2,6 +2,11 @@ interface TableHeader {
2
2
  accessor: string;
3
3
  label: string;
4
4
  isSortable?: boolean;
5
+ /**
6
+ * Enable the Excel-style filter dropdown for this column. When omitted, the
7
+ * column inherits the table-level `filterable` prop.
8
+ */
9
+ isFilterable?: boolean;
5
10
  width?: string | number;
6
11
  minWidth?: string | number;
7
12
  cellRenderer?: (args: {
@@ -13,6 +18,7 @@ interface SortConfig {
13
18
  key: string;
14
19
  direction: "asc" | "desc";
15
20
  }
21
+ type TableDensity = "default" | "compact";
16
22
  interface TableProps {
17
23
  manualHeaders: TableHeader[];
18
24
  manualRowData: Record<string, any>[];
@@ -32,6 +38,16 @@ interface TableProps {
32
38
  expandedRowId?: string | null;
33
39
  renderExpandedRow?: (row: any) => React.ReactNode;
34
40
  renderFullRow?: (row: any) => React.ReactNode;
41
+ /** Enable Excel-style per-column filtering on every column (opt-in). */
42
+ filterable?: boolean;
43
+ /** Zebra striping: give every other row a subtle darker background. */
44
+ striped?: boolean;
45
+ /** Draw a horizontal divider line beneath each row. */
46
+ dividers?: boolean;
47
+ /** Draw vertical divider lines between columns (grid look). */
48
+ bordered?: boolean;
49
+ /** Row/cell density. `"compact"` tightens padding for dense data. */
50
+ density?: TableDensity;
35
51
  }
36
52
  declare const Table: React.FC<TableProps>;
37
53
 
@@ -47,4 +63,18 @@ interface ColumnVisibilityToggleProps {
47
63
  }
48
64
  declare const ColumnVisibilityToggle: React.FC<ColumnVisibilityToggleProps>;
49
65
 
50
- export { type ColumnDefinition, ColumnVisibilityToggle, type ColumnVisibilityToggleProps, type SortConfig, Table, type TableHeader, type TableProps };
66
+ interface ColumnFilterProps {
67
+ columnKey: string;
68
+ label: string;
69
+ distinctValues: string[];
70
+ search: string;
71
+ excluded: Set<string>;
72
+ sortConfig: SortConfig | null;
73
+ isSortable?: boolean;
74
+ onSort: (direction: "asc" | "desc") => void;
75
+ onSearchChange: (value: string) => void;
76
+ onExcludedChange: (next: Set<string>) => void;
77
+ onClear: () => void;
78
+ }
79
+
80
+ export { type ColumnDefinition, type ColumnFilterProps, ColumnVisibilityToggle, type ColumnVisibilityToggleProps, type SortConfig, Table, type TableDensity, type TableHeader, type TableProps };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,11 @@ interface TableHeader {
2
2
  accessor: string;
3
3
  label: string;
4
4
  isSortable?: boolean;
5
+ /**
6
+ * Enable the Excel-style filter dropdown for this column. When omitted, the
7
+ * column inherits the table-level `filterable` prop.
8
+ */
9
+ isFilterable?: boolean;
5
10
  width?: string | number;
6
11
  minWidth?: string | number;
7
12
  cellRenderer?: (args: {
@@ -13,6 +18,7 @@ interface SortConfig {
13
18
  key: string;
14
19
  direction: "asc" | "desc";
15
20
  }
21
+ type TableDensity = "default" | "compact";
16
22
  interface TableProps {
17
23
  manualHeaders: TableHeader[];
18
24
  manualRowData: Record<string, any>[];
@@ -32,6 +38,16 @@ interface TableProps {
32
38
  expandedRowId?: string | null;
33
39
  renderExpandedRow?: (row: any) => React.ReactNode;
34
40
  renderFullRow?: (row: any) => React.ReactNode;
41
+ /** Enable Excel-style per-column filtering on every column (opt-in). */
42
+ filterable?: boolean;
43
+ /** Zebra striping: give every other row a subtle darker background. */
44
+ striped?: boolean;
45
+ /** Draw a horizontal divider line beneath each row. */
46
+ dividers?: boolean;
47
+ /** Draw vertical divider lines between columns (grid look). */
48
+ bordered?: boolean;
49
+ /** Row/cell density. `"compact"` tightens padding for dense data. */
50
+ density?: TableDensity;
35
51
  }
36
52
  declare const Table: React.FC<TableProps>;
37
53
 
@@ -47,4 +63,18 @@ interface ColumnVisibilityToggleProps {
47
63
  }
48
64
  declare const ColumnVisibilityToggle: React.FC<ColumnVisibilityToggleProps>;
49
65
 
50
- export { type ColumnDefinition, ColumnVisibilityToggle, type ColumnVisibilityToggleProps, type SortConfig, Table, type TableHeader, type TableProps };
66
+ interface ColumnFilterProps {
67
+ columnKey: string;
68
+ label: string;
69
+ distinctValues: string[];
70
+ search: string;
71
+ excluded: Set<string>;
72
+ sortConfig: SortConfig | null;
73
+ isSortable?: boolean;
74
+ onSort: (direction: "asc" | "desc") => void;
75
+ onSearchChange: (value: string) => void;
76
+ onExcludedChange: (next: Set<string>) => void;
77
+ onClear: () => void;
78
+ }
79
+
80
+ export { type ColumnDefinition, type ColumnFilterProps, ColumnVisibilityToggle, type ColumnVisibilityToggleProps, type SortConfig, Table, type TableDensity, type TableHeader, type TableProps };