@gilav21/shadcn-angular-data-table 0.1.1
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 +152 -0
- package/fesm2022/gilav21-shadcn-angular-data-table.mjs +18203 -0
- package/fesm2022/gilav21-shadcn-angular-data-table.mjs.map +1 -0
- package/package.json +45 -0
- package/theme.css +159 -0
- package/types/gilav21-shadcn-angular-data-table.d.ts +3110 -0
- package/types/gilav21-shadcn-angular-data-table.d.ts.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# @gilav21/shadcn-angular-data-table
|
|
2
|
+
|
|
3
|
+
The shadcn-angular data table, compiled and published as a normal npm package:
|
|
4
|
+
the base table plus the context-menu, export and pivot addons.
|
|
5
|
+
|
|
6
|
+
Same `ui-*` selectors, the same inputs and the same behaviour as the CLI copy
|
|
7
|
+
model — but nothing lands in your source tree, and `npm update` brings the
|
|
8
|
+
fixes.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
|
|
12
|
+
- **Angular 20 or 21** (peer `>=20.0.0 <22.0.0`). Both majors are covered by
|
|
13
|
+
the e2e suite, which installs this package's real tarball into a pristine
|
|
14
|
+
Angular 20 app and a pristine Angular 21 app and builds both.
|
|
15
|
+
- **Tailwind CSS v4**.
|
|
16
|
+
- Works in zoneless apps.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @gilav21/shadcn-angular-data-table
|
|
22
|
+
npm install -D tailwindcss @tailwindcss/postcss postcss
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If you do not already have Tailwind wired up, add `.postcssrc.json`:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{ "plugins": { "@tailwindcss/postcss": {} } }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Styles
|
|
32
|
+
|
|
33
|
+
Add these three lines to your global stylesheet:
|
|
34
|
+
|
|
35
|
+
```css
|
|
36
|
+
@import "tailwindcss";
|
|
37
|
+
@source "../node_modules/@gilav21/shadcn-angular-data-table";
|
|
38
|
+
@import "@gilav21/shadcn-angular-data-table/theme.css";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- The `@source` line is **required**. Tailwind v4 does not scan `node_modules`
|
|
42
|
+
by default, so without it none of the table's utility classes are generated
|
|
43
|
+
and the table renders unstyled.
|
|
44
|
+
- The `theme.css` import ships the design tokens (`:root` / `.dark` custom
|
|
45
|
+
properties, `@theme inline`, base layer). **Skip it if your app is already
|
|
46
|
+
CLI-initialised** (`npx shadcn-angular init` wrote the same tokens into your
|
|
47
|
+
own stylesheet, and importing both duplicates the `:root` block).
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { Component } from '@angular/core';
|
|
53
|
+
import {
|
|
54
|
+
DataTableComponent,
|
|
55
|
+
DataTableContextMenuDirective,
|
|
56
|
+
DataTableExportDirective,
|
|
57
|
+
DataTablePivotDirective,
|
|
58
|
+
type ColumnDef,
|
|
59
|
+
} from '@gilav21/shadcn-angular-data-table';
|
|
60
|
+
|
|
61
|
+
interface Row { name: string; team: string; score: number; }
|
|
62
|
+
|
|
63
|
+
@Component({
|
|
64
|
+
selector: 'app-sales',
|
|
65
|
+
imports: [
|
|
66
|
+
DataTableComponent,
|
|
67
|
+
DataTableContextMenuDirective,
|
|
68
|
+
DataTableExportDirective,
|
|
69
|
+
DataTablePivotDirective,
|
|
70
|
+
],
|
|
71
|
+
template: `
|
|
72
|
+
<ui-data-table
|
|
73
|
+
uiDtContextMenu uiDtExport uiDtPivot #pv="uiDtPivot"
|
|
74
|
+
[data]="rows" [columns]="columns" />
|
|
75
|
+
`,
|
|
76
|
+
})
|
|
77
|
+
export class SalesComponent {
|
|
78
|
+
readonly rows: Row[] = [
|
|
79
|
+
{ name: 'Alice', team: 'A', score: 50 },
|
|
80
|
+
{ name: 'Bob', team: 'B', score: 40 },
|
|
81
|
+
{ name: 'Charlie', team: 'A', score: 30 },
|
|
82
|
+
];
|
|
83
|
+
readonly columns: ColumnDef<Row>[] = [
|
|
84
|
+
{ key: 'name', header: 'Name' },
|
|
85
|
+
{ key: 'team', header: 'Team' },
|
|
86
|
+
{ key: 'score', header: 'Score' },
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Addons
|
|
92
|
+
|
|
93
|
+
| Directive | Attribute | What it adds |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| `DataTableContextMenuDirective` | `uiDtContextMenu` | Row action menu (⋮ button, right-click, long-press) |
|
|
96
|
+
| `DataTableExportDirective` | `uiDtExport` | CSV / clipboard export of the current view |
|
|
97
|
+
| `DataTablePivotDirective` | `uiDtPivot` | Grouping and aggregation (`getPivot()`) |
|
|
98
|
+
|
|
99
|
+
Each is optional — add only the attributes you want.
|
|
100
|
+
|
|
101
|
+
## Locale, RTL and density
|
|
102
|
+
|
|
103
|
+
`[locale]` is set per table instance, and RTL follows the document direction.
|
|
104
|
+
Density is driven by the CSS custom properties in `theme.css`; override
|
|
105
|
+
`--density` (or `--density-data-table`) in your own stylesheet to scale row
|
|
106
|
+
height and padding.
|
|
107
|
+
|
|
108
|
+
## Selectors are fixed
|
|
109
|
+
|
|
110
|
+
The CLI's `--prefix` flag has no equivalent here. Compiled components carry the
|
|
111
|
+
selectors they were built with, so the tag is always `ui-data-table` and the
|
|
112
|
+
addon attributes are always `uiDt*`.
|
|
113
|
+
|
|
114
|
+
## Configuration is inputs-only
|
|
115
|
+
|
|
116
|
+
There is no provider or injection-token configuration API. Everything is
|
|
117
|
+
configured through component inputs — the same as the copy model.
|
|
118
|
+
|
|
119
|
+
## Mixing with CLI-copied components
|
|
120
|
+
|
|
121
|
+
You can use this package and CLI-copied components in the same app. Selectors
|
|
122
|
+
coexist, and both render fine.
|
|
123
|
+
|
|
124
|
+
One thing to know: the package carries **its own** singletons. A service or
|
|
125
|
+
i18n token instance from your copied `src/components/ui/**` is *not* the same
|
|
126
|
+
instance the package's table uses, so `[locale]` must be set on the package
|
|
127
|
+
table itself rather than inherited from a copied component.
|
|
128
|
+
|
|
129
|
+
## Troubleshooting
|
|
130
|
+
|
|
131
|
+
**Nothing is styled.** The `@source` line is missing or points at the wrong
|
|
132
|
+
path. It must resolve, from the stylesheet's own location, to this package
|
|
133
|
+
inside `node_modules`.
|
|
134
|
+
|
|
135
|
+
**Colours are missing / everything is transparent.** `theme.css` was not
|
|
136
|
+
imported and your app has no shadcn token block of its own. Add the third CSS
|
|
137
|
+
line.
|
|
138
|
+
|
|
139
|
+
**`npm install` fails with a peer error on `@angular/core`.** This package
|
|
140
|
+
supports Angular 20 and 21. On Angular 19 or older, use the CLI copy model
|
|
141
|
+
instead — `npx shadcn-angular add data-table`.
|
|
142
|
+
|
|
143
|
+
## Versioning
|
|
144
|
+
|
|
145
|
+
This package versions independently of the `shadcn-angular` CLI. A component fix
|
|
146
|
+
reaches CLI users when it lands on `master`, but reaches package users only in
|
|
147
|
+
the next package release. Angular major upgrades require a rebuild and a new
|
|
148
|
+
major.
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT
|