@egose/shadcn-theme-ng-tw 0.5.2 → 0.6.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 +12 -11
- package/data-table/README.md +164 -0
- package/data-table/fesm2022/data-table.mjs +1449 -0
- package/data-table/package.json +25 -0
- package/data-table/types/data-table.d.ts +483 -0
- package/dropdown-menu/README.md +2 -0
- package/form-checkbox/README.md +22 -22
- package/form-text-input/fesm2022/form-text-input.mjs +1 -1
- package/form-textarea/fesm2022/form-textarea.mjs +1 -1
- package/input/README.md +7 -12
- package/input/fesm2022/input.mjs +7 -4
- package/input/types/input.d.ts +3 -1
- package/layout-simple/fesm2022/layout-simple.mjs +1 -1
- package/package.json +6 -1
- package/phone-input/fesm2022/phone-input.mjs +1 -1
- package/stepper/README.md +75 -52
- package/stepper/fesm2022/stepper.mjs +35 -5
- package/stepper/types/stepper.d.ts +22 -14
- package/table/README.md +2 -0
- package/table/fesm2022/table.mjs +12 -8
- package/table/types/table.d.ts +7 -2
package/README.md
CHANGED
|
@@ -19,16 +19,17 @@ versions; applications must keep their existing framework versions inside the su
|
|
|
19
19
|
|
|
20
20
|
### Peer dependencies
|
|
21
21
|
|
|
22
|
-
| Package
|
|
23
|
-
|
|
|
24
|
-
| `@angular/cdk`
|
|
25
|
-
| `@angular/common`
|
|
26
|
-
| `@angular/core`
|
|
27
|
-
| `@angular/forms`
|
|
28
|
-
| `@angular/router`
|
|
29
|
-
| `@ng-icons/core`
|
|
30
|
-
| `@spartan-ng/brain`
|
|
31
|
-
| `
|
|
22
|
+
| Package | Supported version | Tested version |
|
|
23
|
+
| ------------------------- | ------------------ | -------------- |
|
|
24
|
+
| `@angular/cdk` | `>=22.0.0 <23.0.0` | `22.1.3` |
|
|
25
|
+
| `@angular/common` | `>=22.0.0 <23.0.0` | `22.1.3` |
|
|
26
|
+
| `@angular/core` | `>=22.0.0 <23.0.0` | `22.1.3` |
|
|
27
|
+
| `@angular/forms` | `>=22.0.0 <23.0.0` | `22.1.3` |
|
|
28
|
+
| `@angular/router` | `>=22.0.0 <23.0.0` | `22.1.3` |
|
|
29
|
+
| `@ng-icons/core` | `>=35.0.1 <36.0.0` | `35.0.1` |
|
|
30
|
+
| `@spartan-ng/brain` | `>=1.3.2 <2.0.0` | `1.3.2` |
|
|
31
|
+
| `@tanstack/angular-table` | `>=9.1.2 <10.0.0` | `9.1.2` |
|
|
32
|
+
| `rxjs` | `>=7.8.0 <8.0.0` | `7.8.2` |
|
|
32
33
|
|
|
33
34
|
Angular and CDK must use the same major version. The tested consumer contract is Angular 22, CDK 22, and Spartan 1.3.2;
|
|
34
35
|
the ranges above are copied from the published peer metadata and validated with strict isolated installs.
|
|
@@ -138,7 +139,7 @@ Import by component name. Component `NameX` is reachable at `@egose/shadcn-theme
|
|
|
138
139
|
|
|
139
140
|
<!-- BEGIN GENERATED SUBPATHS -->
|
|
140
141
|
|
|
141
|
-
`accordion`, `alert`, `alert-dialog`, `aspect-ratio`, `autocomplete`, `avatar`, `badge`, `basic-alert`, `breadcrumb`, `button`, `button-group`, `calendar`, `card`, `carousel`, `checkbox`, `collapsible`, `combobox`, `command`, `confirmation-dialog`, `context-menu`, `date-picker`, `dialog`, `drawer`, `dropdown-menu`, `empty`, `field`, `form-autocomplete`, `form-checkbox`, `form-combobox`, `form-date-picker`, `form-date-picker-multi`, `form-date-range-picker`, `form-field`, `form-field-simple`, `form-input-otp`, `form-month-year-picker`, `form-native-select`, `form-phone-input`, `form-radio-group`, `form-searchable-multiselect`, `form-select`, `form-slider`, `form-switch`, `form-text-input`, `form-textarea`, `form-toggle`, `form-toggle-group`, `hover-card`, `icon`, `input`, `input-group`, `input-otp`, `item`, `kbd`, `label`, `layout-simple`, `menu`, `menubar`, `native-select`, `navigation-menu`, `pagination`, `phone-input`, `popover`, `progress`, `radio-group`, `resizable`, `scroll-area`, `searchable-multiselect`, `select`, `separator`, `sheet`, `sidebar`, `skeleton`, `slider`, `sonner`, `spinner`, `stepper`, `switch`, `table`, `tabs`, `textarea`, `toggle`, `toggle-group`, `tooltip`, `typography`, `utils`.
|
|
142
|
+
`accordion`, `alert`, `alert-dialog`, `aspect-ratio`, `autocomplete`, `avatar`, `badge`, `basic-alert`, `breadcrumb`, `button`, `button-group`, `calendar`, `card`, `carousel`, `checkbox`, `collapsible`, `combobox`, `command`, `confirmation-dialog`, `context-menu`, `data-table`, `date-picker`, `dialog`, `drawer`, `dropdown-menu`, `empty`, `field`, `form-autocomplete`, `form-checkbox`, `form-combobox`, `form-date-picker`, `form-date-picker-multi`, `form-date-range-picker`, `form-field`, `form-field-simple`, `form-input-otp`, `form-month-year-picker`, `form-native-select`, `form-phone-input`, `form-radio-group`, `form-searchable-multiselect`, `form-select`, `form-slider`, `form-switch`, `form-text-input`, `form-textarea`, `form-toggle`, `form-toggle-group`, `hover-card`, `icon`, `input`, `input-group`, `input-otp`, `item`, `kbd`, `label`, `layout-simple`, `menu`, `menubar`, `native-select`, `navigation-menu`, `pagination`, `phone-input`, `popover`, `progress`, `radio-group`, `resizable`, `scroll-area`, `searchable-multiselect`, `select`, `separator`, `sheet`, `sidebar`, `skeleton`, `slider`, `sonner`, `spinner`, `stepper`, `switch`, `table`, `tabs`, `textarea`, `toggle`, `toggle-group`, `tooltip`, `typography`, `utils`.
|
|
142
143
|
|
|
143
144
|
<!-- END GENERATED SUBPATHS -->
|
|
144
145
|
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Data Table (`@egose/shadcn-theme-ng/data-table`)
|
|
2
|
+
|
|
3
|
+
A generic, TanStack-powered data table with sorting, filtering, pagination, row selection, column visibility, and an optional card-grid layout — equivalent to combining [shadcn/ui Table](https://ui.shadcn.com/docs/components/table) with the [Spartan data-table guide](https://www.spartan.ng/components/data-table). The caller passes `columns` (and optionally `gridColumns`); the table owns its state internally and notifies via outputs.
|
|
4
|
+
|
|
5
|
+
> **Ships as:** `@egose/shadcn-theme-ng/data-table` and `@egose/shadcn-theme-ng-tw/data-table` (the `tw:`-prefixed Tailwind variant). See the [package README](../../README.md) for install steps, peer dependencies, Tailwind setup, and testing/release guidance. Do not publish this project directory independently.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Plain Tailwind (no prefix)
|
|
11
|
+
npm install @egose/shadcn-theme-ng @tanstack/angular-table
|
|
12
|
+
|
|
13
|
+
# Or the tw:-prefixed variant
|
|
14
|
+
npm install @egose/shadcn-theme-ng-tw @tanstack/angular-table
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`@tanstack/angular-table` (`>=9.1.2 <10.0.0`) is a peer dependency — install it alongside the theme package. See the [package README](../../README.md) for the full peer-dependency table.
|
|
18
|
+
|
|
19
|
+
## Imports
|
|
20
|
+
|
|
21
|
+
All public symbols are re-exported from `projects/data-table/src/public-api.ts`:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import {
|
|
25
|
+
EgDataTable,
|
|
26
|
+
EgDataTableColumnHeader,
|
|
27
|
+
EgDataTableImports,
|
|
28
|
+
EgDataTableModule,
|
|
29
|
+
EgDataTablePagination,
|
|
30
|
+
EgDataTableViewOptions,
|
|
31
|
+
EgSortableColumn,
|
|
32
|
+
EgTableHeadSelection,
|
|
33
|
+
EgTableRowSelection,
|
|
34
|
+
defaultEgDataTableFeatures,
|
|
35
|
+
type EgDataTableFeatures,
|
|
36
|
+
type EgDataTableLayout,
|
|
37
|
+
type EgPaginatedResponse,
|
|
38
|
+
} from '@egose/shadcn-theme-ng/data-table';
|
|
39
|
+
// tw variant: swap to '@egose/shadcn-theme-ng-tw/data-table'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Client mode
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { Component, signal } from '@angular/core';
|
|
46
|
+
import { createColumnHelper } from '@tanstack/angular-table';
|
|
47
|
+
import { EgDataTable, type EgDataTableFeatures } from '@egose/shadcn-theme-ng/data-table';
|
|
48
|
+
|
|
49
|
+
interface Payment {
|
|
50
|
+
id: string;
|
|
51
|
+
amount: number;
|
|
52
|
+
status: string;
|
|
53
|
+
email: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const helper = createColumnHelper<EgDataTableFeatures, Payment>();
|
|
57
|
+
const columns = helper.columns([
|
|
58
|
+
helper.accessor('status', { header: 'Status' }),
|
|
59
|
+
helper.accessor('email', { header: 'Email' }),
|
|
60
|
+
helper.accessor('amount', { header: 'Amount' }),
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
@Component({
|
|
64
|
+
selector: 'app-payments',
|
|
65
|
+
imports: [EgDataTable],
|
|
66
|
+
template: `<eg-data-table [columns]="columns" [data]="payments()" />`,
|
|
67
|
+
})
|
|
68
|
+
export class PaymentsComponent {
|
|
69
|
+
protected readonly payments = signal<Payment[]>([
|
|
70
|
+
{ id: '1', amount: 100, status: 'pending', email: 'm@example.com' },
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Server mode
|
|
76
|
+
|
|
77
|
+
Pass `data` as a page slice with `manualPagination` set. The slice renders as-is — sorting and filtering are not applied client-side. Page, sort and filter interactions emit `pageChange` / `pageSizeChange` / `sortingChange` / `filterChange` (`columnFiltersChange`) so the caller can fetch the next slice:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
@Component({
|
|
81
|
+
selector: 'app-server-payments',
|
|
82
|
+
imports: [EgDataTable],
|
|
83
|
+
template: `
|
|
84
|
+
<eg-data-table
|
|
85
|
+
[columns]="columns"
|
|
86
|
+
[data]="page()"
|
|
87
|
+
[manualPagination]="true"
|
|
88
|
+
[isLoading]="loading()"
|
|
89
|
+
(pageChange)="load($event)"
|
|
90
|
+
/>
|
|
91
|
+
`,
|
|
92
|
+
})
|
|
93
|
+
export class ServerPaymentsComponent {
|
|
94
|
+
protected readonly page = signal<EgPaginatedResponse<Payment> | null>(null);
|
|
95
|
+
protected readonly loading = signal(true);
|
|
96
|
+
|
|
97
|
+
load(pageIndex: number) {
|
|
98
|
+
// fetch `/api/payments?page=${pageIndex}` then `page.set(response)`
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Selection, sorting, grid layout
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
<eg-data-table
|
|
107
|
+
[columns]="columns"
|
|
108
|
+
[gridColumns]="gridColumns"
|
|
109
|
+
[data]="payments()"
|
|
110
|
+
[enableSelection]="true"
|
|
111
|
+
[(layout)]="layout"
|
|
112
|
+
(selectionChange)="onSelect($event)"
|
|
113
|
+
/>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- `enableSelection` auto-prepends a checkbox column; `selectionChange` emits the selected rows.
|
|
117
|
+
- `[(layout)]` toggles `'table' | 'grid'` (grid requires `gridColumns`). Column `meta: { hideInTable: true }` hides a column in table layout; `meta: { thumbnail: true }` renders it as the card banner.
|
|
118
|
+
- Sortable plain-string headers get an inline sort button; richer headers should use `EgDataTableColumnHeader` via `flexRenderComponent` (no type arguments needed — its `column` input accepts any TanStack column through the `EgSortableColumn` structural type):
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { flexRenderComponent } from '@tanstack/angular-table';
|
|
122
|
+
import { EgDataTableColumnHeader } from '@egose/shadcn-theme-ng/data-table';
|
|
123
|
+
|
|
124
|
+
helper.accessor('email', {
|
|
125
|
+
header: ({ column }) => flexRenderComponent(EgDataTableColumnHeader, { inputs: { column, title: 'Email' } }),
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## API reference
|
|
130
|
+
|
|
131
|
+
| Symbol | Kind |
|
|
132
|
+
| ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
133
|
+
| `EgDataTable` | Component (`eg-data-table`), generic over `TData extends RowData` |
|
|
134
|
+
| `EgDataTableColumnHeader` | Sortable/hideable header component for `flexRenderComponent` usage (non-generic; takes `EgSortableColumn`) |
|
|
135
|
+
| `EgSortableColumn` | Minimal structural column surface the header needs (any TanStack `Column` satisfies it) |
|
|
136
|
+
| `EgDataTablePagination` | Standalone pager (`[tanStackTable]` DI) with page navigation + rows-per-page selector |
|
|
137
|
+
| `EgDataTablePagination` | Standalone pager reading the table from `[tanStackTable]` DI |
|
|
138
|
+
| `EgDataTableViewOptions` | Column-visibility dropdown reading the table from `[tanStackTable]` DI |
|
|
139
|
+
| `EgTableHeadSelection` / `EgTableRowSelection` | Selection checkboxes (auto-used when `enableSelection`) |
|
|
140
|
+
| `defaultEgDataTableFeatures` / `EgDataTableFeatures` | Default TanStack feature registry + type |
|
|
141
|
+
| `EgPaginatedResponse` | Server page-slice interface |
|
|
142
|
+
| `EgDataTableLayout` | `'table' \| 'grid'` |
|
|
143
|
+
| `EgDataTableImports` / `EgDataTableModule` | Standalone imports array / NgModule |
|
|
144
|
+
|
|
145
|
+
Key `EgDataTable` inputs: `columns` (required), `gridColumns`, `data` (array, or page slice with `manualPagination`), `manualPagination`, `size` (`sm` / `default` / `lg` density for toolbar, table, and pagination; type scale untouched), `filterRows` (caller pre-filter for client rows, before built-in filtering/sorting/pagination; ignored in server mode), `features`, `isLoading`, `emptyMessage`, `enableSelection`, `hideFooter`, `layout` (model), `showLayoutToggle`, `showToolbar`, `filterColumnId`, `filterPlaceholder`, `showColumnToggle`, `defaultPageSize`, `showPageSize`, `pageSizes`, plus `initialSorting` / `initialColumnFilters` / `initialColumnVisibility` / `initialRowSelection` to seed state once at creation (later changes are ignored — subscribe to the corresponding `*Change` outputs instead).
|
|
146
|
+
|
|
147
|
+
Outputs: `selectionChange` (also fires once on init, mirroring React's mount effect), `pageChange`, `pageSizeChange`, `rowClick`, `sortingChange`, `columnFiltersChange`, `filterChange` (toolbar input string), `columnVisibilityChange`.
|
|
148
|
+
|
|
149
|
+
The toolbar (`showToolbar`) always renders the filter input: with `filterColumnId` it filters that column client-side (and `filterChange` mirrors the string); without it, keystrokes only emit `filterChange` so the caller can filter server-side. The column-visibility dropdown is opt-in via `showColumnToggle` (default `false`). `toolbarActions` takes an `ng-template` rendered on the right side of the toolbar row (built-ins stay left) — it renders the row even when `showToolbar` is false.
|
|
150
|
+
|
|
151
|
+
`size` scales spatial density one step down/up (`sm`: `h-8` headers, `p-1` cells, `h-7` buttons; `lg`: `h-12` headers, `p-3` cells, `h-9` buttons; filter input, page-size trigger, and pager meta texts follow). `EgDataTableColumnHeader` (consumer-instantiated via `flexRenderComponent`) takes the same `size` — for reactive updates put every input in `bindings` (`inputBinding('size', ...)`, plus `column`/`title`, since `bindings` cannot mix with `inputs`).
|
|
152
|
+
|
|
153
|
+
`rowClick` fires for table-row and grid-card clicks with the row's data. Clicks from nested interactive elements (buttons, links, inputs, checkboxes, selects) are ignored so selection checkboxes and row-action buttons keep working without also firing `rowClick`.
|
|
154
|
+
|
|
155
|
+
The footer pager includes a rows-per-page selector (`pageSizes`, default `[10, 20, 30, 40, 50]`; the table's current size is appended when absent). In client mode the table re-paginates immediately; in server mode the change surfaces via `pageSizeChange` so the caller can refetch with the new limit. Set `showPageSize` to `false` to hide it. `navMode` switches the navigation buttons between `icons` (default), `text` (`First`/`Previous`/`Next`/`Last`), and `both`. `EgDataTablePagination` exposes the same `showStatus` / `showPageSize` / `pageSizes` / `navMode` inputs for custom compositions.
|
|
156
|
+
|
|
157
|
+
## Related subpaths
|
|
158
|
+
|
|
159
|
+
- `@egose/shadcn-theme-ng/table` — the underlying styling directives.
|
|
160
|
+
- `@egose/shadcn-theme-ng/checkbox` — selection cells.
|
|
161
|
+
- `@egose/shadcn-theme-ng/card` — grid-layout cards.
|
|
162
|
+
- `@egose/shadcn-theme-ng/toggle-group` — layout switch.
|
|
163
|
+
- `@egose/shadcn-theme-ng/spinner` — loading indicator.
|
|
164
|
+
- `@egose/shadcn-theme-ng/pagination` — standalone paging controls for custom compositions.
|