@ithouse-bd/ngx-table 0.0.0-stage → 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/CHANGELOG.md +132 -0
- package/DOCUMENTATION.md +877 -0
- package/LICENSE +21 -0
- package/README.md +370 -2
- package/THEMING.md +272 -0
- package/docs/images/table-dark.svg +136 -0
- package/docs/images/table-overview.svg +140 -0
- package/docs/images/table-selection.svg +164 -0
- package/fesm2022/ithouse-bd-ngx-table.mjs +1988 -0
- package/fesm2022/ithouse-bd-ngx-table.mjs.map +1 -0
- package/index.d.ts +783 -0
- package/index.d.ts.map +1 -0
- package/package.json +51 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 iTHouse
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,371 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ithouse-bd/ngx-table
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@ithouse-bd/ngx-table)
|
|
4
|
+
[](https://www.npmjs.com/package/@ithouse-bd/ngx-table)
|
|
5
|
+
[](https://github.com/ithouse-bd/angular-libs/blob/main/libs/ngx-table/LICENSE)
|
|
6
|
+
[](https://angular.dev)
|
|
7
|
+
|
|
8
|
+
A generic, fully themeable data table for Angular. Bring your own row type and column
|
|
9
|
+
configuration — the table handles sorting, global search, per-column filters, pagination,
|
|
10
|
+
row selection, row actions and custom templates, for both client-side arrays and
|
|
11
|
+
API-driven (server) data.
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<ith-table title="Students" [data]="students" [columns]="columns" selectionMode="multi">
|
|
17
|
+
</ith-table>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Generic** — `TableColumn<T>` typed against your own row interface; dot-paths for nested data
|
|
23
|
+
- **Sorting** — click a header to cycle `asc → desc → unsorted`, custom comparators per column
|
|
24
|
+
- **Search** — global search box plus a filter row that covers **every column**: text,
|
|
25
|
+
number, date or select controls, per-column placeholders, custom `filterPredicate`, or
|
|
26
|
+
your own filter template
|
|
27
|
+
- **Pagination** — page window, first/last/prev/next, rows-per-page selector and range summary
|
|
28
|
+
- **Selection** — single or multi, select-all for the page or all filtered rows, keep keys across pages
|
|
29
|
+
- **Row actions** — declarative action buttons with icons, classes, disabled/hidden rules, or your own template
|
|
30
|
+
- **Custom templates** — cell, header, row actions, toolbar, footer and empty state
|
|
31
|
+
- **Server mode** — the table emits sort/search/filter/page changes; you supply one page of rows
|
|
32
|
+
- **Copy** — hover a cell (or press Ctrl/Cmd+C on a focused cell) or copy a whole row
|
|
33
|
+
- **Context menu** — right-click / `Shift+F10` emits `rowContextMenu` and renders your
|
|
34
|
+
`ithTableRowMenu` template in a floating panel at the pointer
|
|
35
|
+
- **Layout control** — Columns popover, per-column header menu (sort, pin, fit, hide),
|
|
36
|
+
drag-to-reorder headers and drag-to-resize edges; hidden columns, order, widths, pinning and
|
|
37
|
+
density are saved in `localStorage` through `storageKey`, plus named views
|
|
38
|
+
- **Filter chips** — the active search term and every column filter shown as removable chips
|
|
39
|
+
- **Selection bar** — bulk actions appear as soon as rows are selected
|
|
40
|
+
- **CSV & Excel export** — one toolbar menu with a real `.xlsx` (built without dependencies)
|
|
41
|
+
and `.csv`, plus `toCsv()` / `toExcel()` / `downloadCsv()` / `downloadExcel()`
|
|
42
|
+
- **Row detail** — an `#ithTableRowDetail` template expands underneath the row
|
|
43
|
+
- **Footer totals** — `sum`, `avg`, `min`, `max` and `count` per column
|
|
44
|
+
- **Keyboard grid** — one tab stop, arrow keys / Home / End / PageUp / PageDown, Space selects
|
|
45
|
+
- **Sticky columns** — stick the checkbox and actions columns, or pin any column at runtime
|
|
46
|
+
- **Cell tooltips** — full value on hover for truncated cells, opt out per column
|
|
47
|
+
- **Stable height** — `minRows` keeps the empty body space when a page returns fewer rows,
|
|
48
|
+
so a one-row result never collapses into a single line
|
|
49
|
+
- **Skeleton loading** — placeholder rows instead of a blank table, plus a toolbar
|
|
50
|
+
comfortable/compact density toggle
|
|
51
|
+
- **Presentation** — striped, bordered, dense, hover, sticky header, fixed max height, loading overlay
|
|
52
|
+
- **Theming** — CSS variables with light, dark and system (`auto`) modes; zero style-framework dependency
|
|
53
|
+
- **Signals everywhere** — `input()`, `model()`, `output()`, standalone component, zoneless-safe
|
|
54
|
+
- **No runtime dependencies** except `tslib`
|
|
55
|
+
|
|
56
|
+
## Compatibility
|
|
57
|
+
|
|
58
|
+
| | Supported |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| Angular 20 and newer | ✅ |
|
|
61
|
+
| Angular 17, 18, 19 | ❌ not supported (`>=20.0.0` peer range) |
|
|
62
|
+
| Standalone components | ✅ required |
|
|
63
|
+
| `NgModule` wrappers | ❌ removed (import the standalone components directly) |
|
|
64
|
+
| Zoneless change detection | ✅ (signals throughout) |
|
|
65
|
+
| SSR / prerendering | ✅ no direct DOM access |
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm install @ithouse-bd/ngx-table
|
|
71
|
+
# or
|
|
72
|
+
yarn add @ithouse-bd/ngx-table
|
|
73
|
+
# or
|
|
74
|
+
pnpm add @ithouse-bd/ngx-table
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Angular 20 or newer is required.** `@angular/common` and `@angular/core` are peer
|
|
78
|
+
dependencies.
|
|
79
|
+
|
|
80
|
+
## Quick start
|
|
81
|
+
|
|
82
|
+
### 1. Describe your rows
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { TableColumn } from '@ithouse-bd/ngx-table';
|
|
86
|
+
|
|
87
|
+
interface Student {
|
|
88
|
+
id: number;
|
|
89
|
+
name: string;
|
|
90
|
+
email: string;
|
|
91
|
+
roll: number;
|
|
92
|
+
active: boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
readonly columns: TableColumn<Student>[] = [
|
|
96
|
+
{ key: 'roll', header: 'Roll', width: '80px', align: 'center' },
|
|
97
|
+
{ key: 'name', header: 'Name', minWidth: '180px' },
|
|
98
|
+
{ key: 'email', header: 'Email' },
|
|
99
|
+
{
|
|
100
|
+
key: 'active',
|
|
101
|
+
header: 'Status',
|
|
102
|
+
formatter: (value) => (value ? 'Active' : 'Inactive'),
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 2. Render the table
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { Component } from '@angular/core';
|
|
111
|
+
import { TableComponent } from '@ithouse-bd/ngx-table';
|
|
112
|
+
|
|
113
|
+
@Component({
|
|
114
|
+
selector: 'app-students',
|
|
115
|
+
imports: [TableComponent],
|
|
116
|
+
template: `
|
|
117
|
+
<ith-table
|
|
118
|
+
title="Student List"
|
|
119
|
+
[data]="students"
|
|
120
|
+
[columns]="columns"
|
|
121
|
+
selectionMode="multi"
|
|
122
|
+
[pageSize]="10"
|
|
123
|
+
(rowClick)="openStudent($event.row)">
|
|
124
|
+
</ith-table>
|
|
125
|
+
`,
|
|
126
|
+
})
|
|
127
|
+
export class StudentsComponent {}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The `keyField` defaults to `'id'`; set `[keyField]="'studentId'"` when your rows use another
|
|
131
|
+
unique field.
|
|
132
|
+
|
|
133
|
+
## Custom cell templates
|
|
134
|
+
|
|
135
|
+
Add `ithTableCell` templates for any column key. The context exposes `$implicit` (the row),
|
|
136
|
+
`row`, `column`, `value` and `index`:
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<ith-table [data]="students" [columns]="columns">
|
|
140
|
+
<ng-template ithTableCell="name" let-row let-index="index">
|
|
141
|
+
<strong>{{ index + 1 }}. {{ row.name }}</strong>
|
|
142
|
+
</ng-template>
|
|
143
|
+
|
|
144
|
+
<ng-template ithTableCell="active" let-value="value">
|
|
145
|
+
<span [class.text-success]="value" [class.text-muted]="!value">
|
|
146
|
+
{{ value ? 'Active' : 'Inactive' }}
|
|
147
|
+
</span>
|
|
148
|
+
</ng-template>
|
|
149
|
+
</ith-table>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Import the directive next to the table:
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import { TableCellDirective, TableComponent } from '@ithouse-bd/ngx-table';
|
|
156
|
+
|
|
157
|
+
@Component({ imports: [TableComponent, TableCellDirective], /* … */ })
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Other slots: `ithTableHeader="key"`, `ithTableFilter="key"`, `ithTableRowActions`,
|
|
161
|
+
`ithTableToolbar`, `ithTableFooter`, `ithTableEmpty`, `ithTableRowMenu`.
|
|
162
|
+
|
|
163
|
+
## Copy, context menu & column preset
|
|
164
|
+
|
|
165
|
+
```html
|
|
166
|
+
<ith-table
|
|
167
|
+
[data]="students"
|
|
168
|
+
[columns]="columns"
|
|
169
|
+
[copyable]="true"
|
|
170
|
+
[showColumnPicker]="true"
|
|
171
|
+
[showDensityToggle]="true"
|
|
172
|
+
storageKey="students-table"
|
|
173
|
+
[stickySelection]="true"
|
|
174
|
+
[stickyActions]="true"
|
|
175
|
+
(cellCopy)="onCopy($event)">
|
|
176
|
+
|
|
177
|
+
<ng-template ithTableRowMenu let-row>
|
|
178
|
+
<button type="button" (click)="open(row)">Open</button>
|
|
179
|
+
<button type="button" (click)="remove(row)">Delete</button>
|
|
180
|
+
</ng-template>
|
|
181
|
+
</ith-table>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
- `copyable` adds a hover copy button per cell and lets Ctrl/Cmd+C copy the focused cell;
|
|
185
|
+
`(cellCopy)` reports `{ value, row, index, column }`.
|
|
186
|
+
- Right-clicking a row (or `Shift+F10` / the context-menu key) emits `rowContextMenu` with the
|
|
187
|
+
pointer position and renders the `ithTableRowMenu` template in a fixed panel that closes on
|
|
188
|
+
outside click or `Escape`.
|
|
189
|
+
- `showColumnPicker` renders a "Columns" popover; the choice and the density toggle are
|
|
190
|
+
persisted under `storageKey`, so a returning user gets the same layout.
|
|
191
|
+
- `stickySelection` / `stickyActions` keep the first and last columns visible while scrolling
|
|
192
|
+
horizontally; `TableColumn.sticky` does the same for any other column (give it a `width`).
|
|
193
|
+
- `TableColumn.tooltip` (default `true`) puts the full text in the native `title`, which is
|
|
194
|
+
what makes truncated cells readable on hover.
|
|
195
|
+
|
|
196
|
+

|
|
197
|
+
|
|
198
|
+
## Layout control, export & row detail
|
|
199
|
+
|
|
200
|
+
```html
|
|
201
|
+
<ith-table
|
|
202
|
+
[data]="students"
|
|
203
|
+
[columns]="columns"
|
|
204
|
+
[showColumnPicker]="true"
|
|
205
|
+
[resizable]="true"
|
|
206
|
+
[reorderable]="true"
|
|
207
|
+
[showViews]="true"
|
|
208
|
+
[showExport]="true"
|
|
209
|
+
[showFilters]="true"
|
|
210
|
+
storageKey="students-table"
|
|
211
|
+
[selectionActions]="bulkActions"
|
|
212
|
+
(selectionAction)="bulk($event)"
|
|
213
|
+
(columnStateChange)="saveLayout($event)">
|
|
214
|
+
|
|
215
|
+
<ng-template ithTableRowDetail let-row>
|
|
216
|
+
<p>{{ row.email }} — {{ row.guardianMobile }}</p>
|
|
217
|
+
</ng-template>
|
|
218
|
+
</ith-table>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
- **Header menu** — hovering a header shows a `⋮` button with sort asc/desc, pin left/right,
|
|
222
|
+
unpin, fit to content and hide. `showColumnMenu` (default `true`) turns it off.
|
|
223
|
+
- **Resize & reorder** — `resizable` drags the column edge (minimum 56 px), `reorderable`
|
|
224
|
+
drags a header onto another. Both changes are stored in the preset.
|
|
225
|
+
- **Named views** — `showViews` adds a Views menu: save the current layout under a name and
|
|
226
|
+
apply it later. The layout itself is still restored automatically through `storageKey`.
|
|
227
|
+
- **Filter chips** — with an active search or filter the toolbar shows removable chips plus
|
|
228
|
+
"Clear all". `showFilterChips` (default `true`) hides them.
|
|
229
|
+
- **Selection bar** — pass `selectionActions` and the bar appears whenever rows are selected;
|
|
230
|
+
`(selectionAction)` emits `{ action, rows }`.
|
|
231
|
+
- **Row detail** — with an `#ithTableRowDetail` template each row gets a chevron
|
|
232
|
+
(`rowDetailTrigger="button"`), or expands on row click (`"row"`).
|
|
233
|
+
- **CSV & Excel export** — `showExport` renders the button with a two-item menu:
|
|
234
|
+
`.xlsx` (a real workbook with a bold frozen header row, autofilter and column widths,
|
|
235
|
+
generated in the browser without any dependency) and `.csv` (UTF-8 with BOM).
|
|
236
|
+
`toCsv()` / `toExcel()` return the data and `downloadCsv()` / `downloadExcel()` save it;
|
|
237
|
+
selected rows win over the whole filtered set.
|
|
238
|
+
- **Footer totals** — add `aggregate: 'sum'` (or `avg`/`min`/`max`/`count`) to a column, or
|
|
239
|
+
`aggregate: { type: 'avg', label: 'Average', format: (n) => n.toFixed(1) }`.
|
|
240
|
+
- **Keyboard** — the grid has a single tab stop: arrows move, `Home`/`End` jump within a row,
|
|
241
|
+
`Ctrl+Home`/`Ctrl+End` to the corners, `PageUp`/`PageDown` move a page, `Space` selects the
|
|
242
|
+
row and `Ctrl/Cmd+C` copies the focused cell.
|
|
243
|
+
|
|
244
|
+
## Row actions
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
readonly actions: TableRowAction<Student>[] = [
|
|
248
|
+
{ id: 'edit', label: 'Edit', icon: '✎' },
|
|
249
|
+
{
|
|
250
|
+
id: 'delete',
|
|
251
|
+
label: 'Delete',
|
|
252
|
+
class: 'is-danger',
|
|
253
|
+
disabled: (row) => row.active,
|
|
254
|
+
},
|
|
255
|
+
];
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
```html
|
|
259
|
+
<ith-table
|
|
260
|
+
[data]="students"
|
|
261
|
+
[columns]="columns"
|
|
262
|
+
[rowActions]="actions"
|
|
263
|
+
(actionClick)="handleAction($event)">
|
|
264
|
+
</ith-table>
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
`$event` is `{ action, row, index }`. Use `#ithTableRowActions` for a completely custom
|
|
268
|
+
actions column.
|
|
269
|
+
|
|
270
|
+
## Server-side mode
|
|
271
|
+
|
|
272
|
+
```html
|
|
273
|
+
<ith-table
|
|
274
|
+
mode="server"
|
|
275
|
+
[data]="pageRows()"
|
|
276
|
+
[total]="total()"
|
|
277
|
+
[loading]="loading()"
|
|
278
|
+
[columns]="columns"
|
|
279
|
+
[page]="page()"
|
|
280
|
+
[pageSize]="pageSize()"
|
|
281
|
+
[sort]="sort()"
|
|
282
|
+
[search]="search()"
|
|
283
|
+
(pageChange)="onPage($event)"
|
|
284
|
+
(pageSizeChange)="onPageSize($event)"
|
|
285
|
+
(sortChange)="onSort($event)"
|
|
286
|
+
(searchChange)="onSearch($event)"
|
|
287
|
+
(filterChange)="onFilters($event)">
|
|
288
|
+
</ith-table>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
In server mode the table does **not** re-sort, search or slice the array — it renders
|
|
292
|
+
exactly the rows you pass, asks for the rest through outputs, and uses `[total]` for the
|
|
293
|
+
pager. See the [full documentation](https://github.com/ithouse-bd/angular-libs/blob/main/libs/ngx-table/DOCUMENTATION.md)
|
|
294
|
+
for a complete example.
|
|
295
|
+
|
|
296
|
+
## Theming
|
|
297
|
+
|
|
298
|
+
One token adopts your application's brand colour — header, hover, selected rows, filters,
|
|
299
|
+
footer, focus ring and toolbar buttons all derive from it (light and dark):
|
|
300
|
+
|
|
301
|
+
```css
|
|
302
|
+
:root {
|
|
303
|
+
--ith-table-brand: #0f766e;
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Individual tokens are still available for finer control:
|
|
308
|
+
|
|
309
|
+
```css
|
|
310
|
+
.my-table {
|
|
311
|
+
--ith-table-brand: #2563eb;
|
|
312
|
+
--ith-table-header-text: #e2e8f0;
|
|
313
|
+
--ith-table-radius: 8px;
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Light/dark/auto follows the same convention as `@ithouse-bd/ngx-dropdown`: set
|
|
318
|
+
`data-theme="light" | "dark" | "auto"` on `<html>` or `<body>`. All variables are listed
|
|
319
|
+
in the [theming guide](https://github.com/ithouse-bd/angular-libs/blob/main/libs/ngx-table/THEMING.md).
|
|
320
|
+
|
|
321
|
+
The component ships ~36 kB of scoped CSS (~6 kB gzipped). If your `angular.json` keeps the
|
|
322
|
+
Angular default `anyComponentStyle` budget (8 kB error), raise it to `32kb`/`40kb`.
|
|
323
|
+
|
|
324
|
+
## API at a glance
|
|
325
|
+
|
|
326
|
+
| Input | Type | Default | Description |
|
|
327
|
+
| --- | --- | --- | --- |
|
|
328
|
+
| `data` | `T[]` | `[]` | Rows to render (current page in server mode) |
|
|
329
|
+
| `columns` | `TableColumn<T>[]` | `[]` | Column configuration |
|
|
330
|
+
| `keyField` | `string` | `'id'` | Unique key path used for selection and tracking |
|
|
331
|
+
| `mode` | `'client' \| 'server'` | `'client'` | Local or API-driven data |
|
|
332
|
+
| `total` | `number` | `0` | Total row count (server mode) |
|
|
333
|
+
| `selectionMode` | `'none' \| 'single' \| 'multi'` | `'none'` | Row selection |
|
|
334
|
+
| `selectAllScope` | `'page' \| 'all'` | `'page'` | What the header checkbox selects |
|
|
335
|
+
| `selected` | `T[]` | `[]` | Two-way bindable selection |
|
|
336
|
+
| `rowActions` | `TableRowAction<T>[]` | `[]` | Action buttons per row |
|
|
337
|
+
| `page` / `pageSize` | `number` | `1` / `10` | Two-way bindable pager state |
|
|
338
|
+
| `search` | `string` | `''` | Two-way bindable global search |
|
|
339
|
+
| `sort` | `TableSort \| null` | `null` | Two-way bindable sort state |
|
|
340
|
+
| `pageSizeOptions` | `number[]` | `[10, 20, 50, 100]` | Rows-per-page choices |
|
|
341
|
+
| `showFilters` | `boolean` | `false` | Per-column filter row (text / number / date / select) |
|
|
342
|
+
| `loading` | `boolean` | `false` | Loading overlay |
|
|
343
|
+
| `striped` / `bordered` / `dense` / `hoverable` | `boolean` | `false` / `false` / `false` / `true` | Presentation modifiers |
|
|
344
|
+
| `stickyHeader` / `maxHeight` | `boolean` / `string` | `false` / `''` | Scroll container behaviour |
|
|
345
|
+
| `minRows` | `number` | `4` | Empty body space kept when there are fewer rows |
|
|
346
|
+
| `showColumnMenu` | `boolean` | `true` | Header `⋮` menu (sort, pin, fit, hide) |
|
|
347
|
+
| `resizable` / `reorderable` | `boolean` | `false` | Drag to resize / reorder columns |
|
|
348
|
+
| `showViews` | `boolean` | `false` | Named-layout menu |
|
|
349
|
+
| `showExport` / `exportFileName` | `boolean` / `string` | `false` / `'table'` | CSV export button |
|
|
350
|
+
| `showFilterChips` | `boolean` | `true` | Removable chips for active filters |
|
|
351
|
+
| `selectionActions` | `TableSelectionAction<T>[]` | `[]` | Bulk actions in the selection bar |
|
|
352
|
+
| `rowDetailTrigger` | `'button' \| 'row' \| 'none'` | `'button'` | How `#ithTableRowDetail` expands |
|
|
353
|
+
| `keyboardNavigation` | `boolean` | `true` | Single tab stop + arrow keys |
|
|
354
|
+
|
|
355
|
+
Outputs: `sortChange`, `searchChange`, `filterChange`, `pageChange`, `pageSizeChange`,
|
|
356
|
+
`selectedChange`, `actionClick`, `rowClick`, `cellCopy`, `rowContextMenu`, `columnsChange`,
|
|
357
|
+
`densityChange`, `columnStateChange`, `selectionAction`, `csvExport`, `exportFile`.
|
|
358
|
+
|
|
359
|
+
Full reference, every template context and recipes:
|
|
360
|
+
**[DOCUMENTATION.md](https://github.com/ithouse-bd/angular-libs/blob/main/libs/ngx-table/DOCUMENTATION.md)**.
|
|
361
|
+
|
|
362
|
+
## Development
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
npx nx build ngx-table # build the package into dist/libs/ngx-table
|
|
366
|
+
npx nx serve demo-app # run the demo (client + server table examples)
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
## License
|
|
370
|
+
|
|
371
|
+
MIT © iTHouse
|
package/THEMING.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Theming `<ith-table>`
|
|
2
|
+
|
|
3
|
+
The table is styled with scoped CSS and a single set of custom properties. Override the
|
|
4
|
+
properties on the component or on any ancestor to restyle everything — no selectors, no
|
|
5
|
+
`!important`, no CSS framework required.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [Theme modes](#theme-modes)
|
|
10
|
+
- [Quick start](#quick-start)
|
|
11
|
+
- [Variable reference](#variable-reference)
|
|
12
|
+
- [Ready-made themes](#ready-made-themes)
|
|
13
|
+
- [Presentation modifiers](#presentation-modifiers)
|
|
14
|
+
- [Scoping a theme](#scoping-a-theme)
|
|
15
|
+
- [Accessibility](#accessibility)
|
|
16
|
+
|
|
17
|
+
## Theme modes
|
|
18
|
+
|
|
19
|
+
The component follows the same convention as `@ithouse-bd/ngx-dropdown`:
|
|
20
|
+
|
|
21
|
+
| Attribute | Result |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| `data-theme="light"` (default) | Light palette |
|
|
24
|
+
| `data-theme="dark"` or `class="dark"` | Dark palette |
|
|
25
|
+
| `data-theme="auto"` | Follows `prefers-color-scheme` |
|
|
26
|
+
|
|
27
|
+
Set the attribute on `<html>` or `<body>` so the component can pick it up with
|
|
28
|
+
`:host-context()`:
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<html data-theme="dark">
|
|
32
|
+
<body>
|
|
33
|
+
<ith-table [data]="rows" [columns]="columns"></ith-table>
|
|
34
|
+
</body>
|
|
35
|
+
</html>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
Switching themes at runtime is a single attribute change:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
document.documentElement.setAttribute('data-theme', 'dark');
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## One token = your app's brand
|
|
47
|
+
|
|
48
|
+
Set a single brand colour and every accent surface (header, hover, selected rows, filters,
|
|
49
|
+
footer, focus ring, copy/column buttons) is derived from it with `color-mix()`. This is the
|
|
50
|
+
recommended way to adapt the table to an existing application palette:
|
|
51
|
+
|
|
52
|
+
```css
|
|
53
|
+
:root {
|
|
54
|
+
--ith-table-brand: #0f766e; /* your primary colour */
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
That is enough for light **and** dark mode — dark mode derives its own shades from the same
|
|
59
|
+
token. The default is `#5b21b6` (violet). A runtime theme (e.g. the user picks a colour in
|
|
60
|
+
settings) can set the same variable on the element:
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<ith-table [style.--ith-table-brand]="userBrandColor()" [data]="rows" [columns]="cols"></ith-table>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
> Needs `color-mix()` (all evergreen browsers since 2023). Every derived token can still be
|
|
67
|
+
> overridden individually, which is what the rest of this guide documents.
|
|
68
|
+
|
|
69
|
+
## Quick start
|
|
70
|
+
|
|
71
|
+
```css
|
|
72
|
+
/* app-wide */
|
|
73
|
+
ith-table {
|
|
74
|
+
--ith-table-brand: #2563eb;
|
|
75
|
+
--ith-table-header-text: #e2e8f0;
|
|
76
|
+
--ith-table-radius: 8px;
|
|
77
|
+
--ith-table-cell-padding: 10px 14px;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<ith-table class="orders-table" [data]="orders" [columns]="columns"></ith-table>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```css
|
|
86
|
+
.orders-table {
|
|
87
|
+
--ith-table-header-bg: #166534;
|
|
88
|
+
--ith-table-accent: #16a34a;
|
|
89
|
+
--ith-table-accent-soft: #dcfce7;
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Variable reference
|
|
94
|
+
|
|
95
|
+
These are public tokens: set them on `:root`, any ancestor, or the `ith-table` element itself.
|
|
96
|
+
They resolve on the component host with the light-mode defaults shown below.
|
|
97
|
+
|
|
98
|
+
### Surfaces & text
|
|
99
|
+
|
|
100
|
+
| Variable | Light | Dark | Description |
|
|
101
|
+
| --- | --- | --- | --- |
|
|
102
|
+
| `--ith-table-bg` | `#ffffff` | `#161826` | Card and row background |
|
|
103
|
+
| `--ith-table-text` | `#1f2937` | `#e7e9f3` | Cell and header-row text |
|
|
104
|
+
| `--ith-table-muted` | `#6b7280` | `#9aa0b5` | Footer text, placeholders, icons |
|
|
105
|
+
| `--ith-table-border` | `#e8eaf0` | `#2a2e42` | Borders and separators |
|
|
106
|
+
| `--ith-table-footer-bg` | brand 2% + `#fff` | brand 4% + `#12141f` | Footer background |
|
|
107
|
+
| `--ith-table-filter-bg` | brand 3% + `#fff` | brand 6% + `#161826` | Filter row background |
|
|
108
|
+
|
|
109
|
+
### Header
|
|
110
|
+
|
|
111
|
+
| Variable | Light | Dark | Description |
|
|
112
|
+
| --- | --- | --- | --- |
|
|
113
|
+
| `--ith-table-header-bg` | `var(--ith-table-brand)` | brand 42% + `#0b0d16` | Header bar background |
|
|
114
|
+
| `--ith-table-header-text` | `#ffffff` | `#f3eeff` | Header text and sort icons |
|
|
115
|
+
|
|
116
|
+
The header is a solid colour so it works with `stickyHeader`; use any CSS colour
|
|
117
|
+
(`#fff`, `rgb(...)`, `var(--brand)`). By default it *is* the brand colour (dark mode darkens it).
|
|
118
|
+
|
|
119
|
+
### Accent & interaction
|
|
120
|
+
|
|
121
|
+
| Variable | Light | Dark | Description |
|
|
122
|
+
| --- | --- | --- | --- |
|
|
123
|
+
| `--ith-table-brand` | `#5b21b6` | `#7c3aed` | Base colour — every accent surface below derives from it |
|
|
124
|
+
| `--ith-table-accent` | `var(--ith-table-brand)` | brand 55% + `#fff` | Active page, checkboxes, links, action text |
|
|
125
|
+
| `--ith-table-accent-soft` | brand 12% + `#fff` | brand 26% + `#161826` | Badges, hover backgrounds |
|
|
126
|
+
| `--ith-table-hover` | brand 6% + `#fff` | brand 10% + `#161826` | Row hover |
|
|
127
|
+
| `--ith-table-selected-bg` | brand 10% + `#fff` | brand 20% + `#161826` | Selected row background |
|
|
128
|
+
| `--ith-table-striped-bg` | brand 2% + `#fff` | brand 4% + `#161826` | Zebra rows (`striped`) |
|
|
129
|
+
| `--ith-table-focus` | brand 25% + `transparent` | brand 38% + `transparent` | Focus ring (box-shadow) |
|
|
130
|
+
|
|
131
|
+
`brand X% + colour` means `color-mix(in srgb, var(--ith-table-brand) X%, colour)`: the brand is
|
|
132
|
+
mixed into that colour, so all of these follow a single `--ith-table-brand` change. Set any of
|
|
133
|
+
them individually to opt out of the derivation.
|
|
134
|
+
|
|
135
|
+
### Inputs
|
|
136
|
+
|
|
137
|
+
| Variable | Light | Dark | Description |
|
|
138
|
+
| --- | --- | --- | --- |
|
|
139
|
+
| `--ith-table-input-bg` | `#ffffff` | `#1b1e30` | Search and filter input background |
|
|
140
|
+
| `--ith-table-input-border` | `#dfe3ec` | `#343a52` | Input border |
|
|
141
|
+
| `--ith-table-overlay` | `rgba(255,255,255,.72)` | `rgba(17,19,30,.72)` | Loading overlay |
|
|
142
|
+
|
|
143
|
+
### Shape & spacing
|
|
144
|
+
|
|
145
|
+
| Variable | Default | Description |
|
|
146
|
+
| --- | --- | --- |
|
|
147
|
+
| `--ith-table-radius` | `14px` | Card border radius |
|
|
148
|
+
| `--ith-table-shadow` | soft shadow | Card shadow (`none` to remove) |
|
|
149
|
+
| `--ith-table-cell-padding` | `12px 16px` | Body cell padding |
|
|
150
|
+
| `--ith-table-font-size` | `14px` | Body font size |
|
|
151
|
+
| `--ith-table-header-font-size` | `13px` | Header font size |
|
|
152
|
+
| `--ith-table-row-height` | `46px` | Row height used for sticky offsets and the `minRows` floor |
|
|
153
|
+
| `--ith-table-head-height` | `45px` | Header height used for the `minRows` floor |
|
|
154
|
+
|
|
155
|
+
## Ready-made themes
|
|
156
|
+
|
|
157
|
+
### Compact admin
|
|
158
|
+
|
|
159
|
+
```css
|
|
160
|
+
.admin-table {
|
|
161
|
+
--ith-table-header-bg: #0f172a;
|
|
162
|
+
--ith-table-header-text: #e2e8f0;
|
|
163
|
+
--ith-table-accent: #2563eb;
|
|
164
|
+
--ith-table-accent-soft: #dbeafe;
|
|
165
|
+
--ith-table-hover: #f1f5f9;
|
|
166
|
+
--ith-table-selected-bg: #e0ecff;
|
|
167
|
+
--ith-table-radius: 8px;
|
|
168
|
+
--ith-table-cell-padding: 8px 12px;
|
|
169
|
+
--ith-table-font-size: 13px;
|
|
170
|
+
--ith-table-shadow: none;
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Bootstrap-friendly
|
|
175
|
+
|
|
176
|
+
```css
|
|
177
|
+
[data-theme='bootstrap'] ith-table {
|
|
178
|
+
--ith-table-header-bg: #f8f9fa;
|
|
179
|
+
--ith-table-header-text: #212529;
|
|
180
|
+
--ith-table-accent: #0d6efd;
|
|
181
|
+
--ith-table-accent-soft: #cfe2ff;
|
|
182
|
+
--ith-table-hover: #f8f9fa;
|
|
183
|
+
--ith-table-selected-bg: #e7f1ff;
|
|
184
|
+
--ith-table-border: #dee2e6;
|
|
185
|
+
--ith-table-radius: 6px;
|
|
186
|
+
--ith-table-shadow: none;
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Soft purple (default look)
|
|
191
|
+
|
|
192
|
+
```css
|
|
193
|
+
ith-table {
|
|
194
|
+
--ith-table-header-bg: #5b21b6;
|
|
195
|
+
--ith-table-accent: #6d28d9;
|
|
196
|
+
--ith-table-accent-soft: #ede9fe;
|
|
197
|
+
--ith-table-radius: 14px;
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Minimal
|
|
202
|
+
|
|
203
|
+
```css
|
|
204
|
+
.minimal-table {
|
|
205
|
+
--ith-table-header-bg: #ffffff;
|
|
206
|
+
--ith-table-header-text: #111827;
|
|
207
|
+
--ith-table-border: #f1f5f9;
|
|
208
|
+
--ith-table-accent: #111827;
|
|
209
|
+
--ith-table-accent-soft: #f3f4f6;
|
|
210
|
+
--ith-table-radius: 0;
|
|
211
|
+
--ith-table-shadow: none;
|
|
212
|
+
--ith-table-cell-padding: 10px 0;
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Presentation modifiers
|
|
217
|
+
|
|
218
|
+
Toggle these inputs instead of writing CSS:
|
|
219
|
+
|
|
220
|
+
| Input | Effect |
|
|
221
|
+
| --- | --- |
|
|
222
|
+
| `[striped]="true"` | Zebra rows |
|
|
223
|
+
| `[bordered]="true"` | Vertical cell borders |
|
|
224
|
+
| `[dense]="true"` | Tighter padding and smaller type |
|
|
225
|
+
| `[hoverable]="false"` | Disable row hover |
|
|
226
|
+
| `[stickyHeader]="true"` | Keep the header visible while scrolling |
|
|
227
|
+
| `[maxHeight]="'480px'"` | Scroll inside the table instead of the page |
|
|
228
|
+
|
|
229
|
+
```html
|
|
230
|
+
<ith-table
|
|
231
|
+
[data]="rows"
|
|
232
|
+
[columns]="columns"
|
|
233
|
+
[dense]="true"
|
|
234
|
+
[striped]="true"
|
|
235
|
+
[stickyHeader]="true"
|
|
236
|
+
maxHeight="480px">
|
|
237
|
+
</ith-table>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Default (light) rendering:
|
|
241
|
+
|
|
242
|
+

|
|
243
|
+
|
|
244
|
+
## Scoping a theme
|
|
245
|
+
|
|
246
|
+
Because the variables inherit, you can theme a single table (or a whole section):
|
|
247
|
+
|
|
248
|
+
```html
|
|
249
|
+
<section class="finance">
|
|
250
|
+
<ith-table [data]="invoices" [columns]="columns"></ith-table>
|
|
251
|
+
</section>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
```css
|
|
255
|
+
.finance ith-table {
|
|
256
|
+
--ith-table-accent: #047857;
|
|
257
|
+
--ith-table-accent-soft: #d1fae5;
|
|
258
|
+
--ith-table-header-bg: #064e3b;
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Keep the `ith-table` element `display: block` (its default) and give it a width; the
|
|
263
|
+
internal scroll container handles overflow on narrow screens.
|
|
264
|
+
|
|
265
|
+
## Accessibility
|
|
266
|
+
|
|
267
|
+
- Keep text/background contrast at WCAG AA. A dark header with light text and light rows
|
|
268
|
+
with dark text is the safest combination.
|
|
269
|
+
- Do not remove focus rings: `--ith-table-focus` is used for inputs, buttons and pagination.
|
|
270
|
+
- Meaning conveyed by `--ith-table-accent` (selected rows, active page) is also available
|
|
271
|
+
through checkboxes and `aria-current`, so colour is never the only signal.
|
|
272
|
+
- Respect `prefers-reduced-motion`; the component already disables transitions where needed.
|