Skip to content

Commit 3b4e9bd

Browse files
committed
row dnd exmaple
1 parent 99488e0 commit 3b4e9bd

23 files changed

+696
-22
lines changed

docs/config.json

+4
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@
442442
{
443443
"to": "framework/angular/examples/editable",
444444
"label": "Editable data"
445+
},
446+
{
447+
"to": "framework/angular/examples/row-dnd",
448+
"label": "Row DnD"
445449
}
446450
]
447451
},

examples/angular/editable/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "tanstack-table-example-angular-basic",
2+
"name": "tanstack-table-example-angular-editable",
33
"version": "0.0.0",
44
"scripts": {
55
"ng": "ng",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Node.js",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:18"
4+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false

examples/angular/row-dnd/.gitignore

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
.history/*
30+
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
testem.log
38+
/typings
39+
40+
# System files
41+
.DS_Store
42+
Thumbs.db

examples/angular/row-dnd/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Row Dnd
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.1.2.
4+
5+
## Development server
6+
7+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
8+
9+
## Code scaffolding
10+
11+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12+
13+
## Build
14+
15+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.

examples/angular/row-dnd/angular.json

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"editable": {
7+
"cli": {
8+
"cache": {
9+
"enabled": false
10+
}
11+
},
12+
"projectType": "application",
13+
"schematics": {
14+
"@schematics/angular:component": {
15+
"style": "scss"
16+
}
17+
},
18+
"root": "",
19+
"sourceRoot": "src",
20+
"prefix": "app",
21+
"architect": {
22+
"build": {
23+
"builder": "@angular-devkit/build-angular:application",
24+
"options": {
25+
"outputPath": "dist/editable",
26+
"index": "src/index.html",
27+
"browser": "src/main.ts",
28+
"polyfills": ["zone.js"],
29+
"tsConfig": "tsconfig.app.json",
30+
"inlineStyleLanguage": "scss",
31+
"assets": ["src/favicon.ico", "src/assets"],
32+
"styles": ["src/styles.scss"],
33+
"scripts": []
34+
},
35+
"configurations": {
36+
"production": {
37+
"budgets": [
38+
{
39+
"type": "initial",
40+
"maximumWarning": "500kb",
41+
"maximumError": "1mb"
42+
},
43+
{
44+
"type": "anyComponentStyle",
45+
"maximumWarning": "2kb",
46+
"maximumError": "4kb"
47+
}
48+
],
49+
"outputHashing": "all"
50+
},
51+
"development": {
52+
"optimization": false,
53+
"extractLicenses": false,
54+
"sourceMap": true
55+
}
56+
},
57+
"defaultConfiguration": "production"
58+
},
59+
"serve": {
60+
"builder": "@angular-devkit/build-angular:dev-server",
61+
"configurations": {
62+
"production": {
63+
"buildTarget": "editable:build:production"
64+
},
65+
"development": {
66+
"buildTarget": "editable:build:development"
67+
}
68+
},
69+
"defaultConfiguration": "development"
70+
},
71+
"extract-i18n": {
72+
"builder": "@angular-devkit/build-angular:extract-i18n",
73+
"options": {
74+
"buildTarget": "editable:build"
75+
}
76+
},
77+
"test": {
78+
"builder": "@angular-devkit/build-angular:karma",
79+
"options": {
80+
"polyfills": ["zone.js", "zone.js/testing"],
81+
"tsConfig": "tsconfig.spec.json",
82+
"inlineStyleLanguage": "scss",
83+
"assets": ["src/favicon.ico", "src/assets"],
84+
"styles": ["src/styles.scss"],
85+
"scripts": []
86+
}
87+
}
88+
}
89+
}
90+
},
91+
"cli": {
92+
"analytics": false
93+
}
94+
}

examples/angular/row-dnd/package.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "tanstack-table-example-angular-row-dnd",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"start": "ng serve",
7+
"build": "ng build",
8+
"watch": "ng build --watch --configuration development",
9+
"test": "ng test"
10+
},
11+
"private": true,
12+
"dependencies": {
13+
"@angular/animations": "^17.3.9",
14+
"@angular/common": "^17.3.9",
15+
"@angular/compiler": "^17.3.9",
16+
"@angular/cdk": "^17.3.10",
17+
"@angular/core": "^17.3.9",
18+
"@angular/forms": "^17.3.9",
19+
"@angular/platform-browser": "^17.3.9",
20+
"@angular/platform-browser-dynamic": "^17.3.9",
21+
"@angular/router": "^17.3.9",
22+
"@tanstack/angular-table": "^8.21.0",
23+
"rxjs": "~7.8.1",
24+
"zone.js": "~0.14.4"
25+
},
26+
"devDependencies": {
27+
"@angular-devkit/build-angular": "^17.3.8",
28+
"@angular/cli": "^17.3.8",
29+
"@angular/compiler-cli": "^17.3.9",
30+
"@types/jasmine": "~5.1.4",
31+
"jasmine-core": "~5.1.2",
32+
"karma": "~6.4.3",
33+
"karma-chrome-launcher": "~3.2.0",
34+
"karma-coverage": "~2.2.1",
35+
"karma-jasmine": "~5.1.0",
36+
"karma-jasmine-html-reporter": "~2.1.0",
37+
"tslib": "^2.6.2",
38+
"typescript": "5.4.5"
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.cdk-drag-preview {
2+
box-sizing: border-box;
3+
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2),
4+
0 8px 10px 1px rgba(0, 0, 0, 0.14),
5+
0 3px 14px 2px rgba(0, 0, 0, 0.12);
6+
}
7+
8+
.cdk-drag-placeholder {
9+
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
10+
}
11+
12+
.cdk-drag-placeholder > td {
13+
background: #ccc;
14+
}
15+
16+
.cdk-drag-animating {
17+
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
18+
}
19+
20+
.cdk-drop-list-dragging tr[cdkdrag]:not(.cdk-drag-placeholder) {
21+
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<div class="p-2">
2+
<table>
3+
<thead>
4+
@for (headerGroup of table.getHeaderGroups(); track headerGroup.id) {
5+
<tr>
6+
@for (header of headerGroup.headers; track header.id) {
7+
@if (!header.isPlaceholder) {
8+
<th>
9+
<ng-container
10+
*flexRender="
11+
header.column.columnDef.header;
12+
props: header.getContext();
13+
let header
14+
"
15+
>
16+
<div [innerHTML]="header"></div>
17+
</ng-container>
18+
</th>
19+
}
20+
}
21+
</tr>
22+
}
23+
</thead>
24+
<tbody
25+
#boundaryElement
26+
cdkDropList
27+
[cdkDropListData]="data()"
28+
(cdkDropListDropped)="drop($event)"
29+
>
30+
@for (row of table.getRowModel().rows; track row.id) {
31+
<tr
32+
cdkDrag
33+
[cdkDragData]="row.original"
34+
[cdkDragBoundary]="boundaryElement"
35+
>
36+
@for (cell of row.getVisibleCells(); track cell.id) {
37+
<td [style.width.px]="cell.column.getSize()">
38+
<ng-container
39+
*flexRender="
40+
cell.column.columnDef.cell;
41+
props: cell.getContext();
42+
let cell
43+
"
44+
>
45+
<div [innerHTML]="cell"></div>
46+
</ng-container>
47+
</td>
48+
}
49+
</tr>
50+
}
51+
</tbody>
52+
</table>
53+
54+
<pre>{{ sortedIds() | json }}</pre>
55+
</div>

0 commit comments

Comments
 (0)