Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(angular): add remote data with ssr example #5914

Merged
merged 26 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
05ecd5e
feat(angular-table): Refactor Flex render implementation - Zoneless, …
riccardoperra Jan 20, 2025
0caf695
release: v8.21.0
tannerlinsley Jan 20, 2025
0baabdd
docs(angular): add editable, row-dnd and performant column resizing e…
riccardoperra Jan 21, 2025
190c669
docs(angular): add missing faker-js deps (#5883)
riccardoperra Jan 21, 2025
9763877
fix(lit-table): dynamic data updates in the Lit Table Adapter (#5884)
lschierer Jan 27, 2025
8d6e19f
docs: add experimental virtualization example (#5895)
KevinVandy Feb 3, 2025
64e10bc
release: v8.21.1
tannerlinsley Feb 3, 2025
57703a4
docs: example name
KevinVandy Feb 3, 2025
099e1a4
docs(angular): add expanding and sub components examples (#5898)
riccardoperra Feb 3, 2025
067792f
Merge remote-tracking branch 'origin/main' into alpha_merge_latest_main
riccardoperra Feb 3, 2025
e35226e
fix conflicts in lit package
riccardoperra Feb 3, 2025
849a7cb
remove angular package non-fesm export
riccardoperra Feb 3, 2025
9e6987d
docs: exp virtual - remeasure when table state changes
KevinVandy Feb 4, 2025
827b098
docs: virtualizer tbody from onchange
KevinVandy Feb 4, 2025
9774cf4
update all angular examples
riccardoperra Feb 5, 2025
462d94f
Merge remote-tracking branch 'origin/main' into alpha_merge_latest_main
riccardoperra Feb 5, 2025
3bacaa5
fix conflicts in examples/react
riccardoperra Feb 5, 2025
fdf1336
ci: apply automated fixes
autofix-ci[bot] Feb 5, 2025
d2fc9c1
fix tests
riccardoperra Feb 5, 2025
d391407
ci: apply automated fixes
autofix-ci[bot] Feb 5, 2025
6f13e13
fix tests
riccardoperra Feb 5, 2025
eaed1b9
ci: apply automated fixes
autofix-ci[bot] Feb 5, 2025
fdfca13
angular: update vite config to support vitest workspaces
riccardoperra Feb 5, 2025
a04e39e
docs(angular): fix examples
riccardoperra Feb 8, 2025
5b514b4
docs(angular): add remote data with ssr example
riccardoperra Feb 8, 2025
e125d1c
Merge remote-tracking branch 'origin/alpha' into angular-fetch-data-s…
riccardoperra Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@
{
"to": "framework/angular/examples/column-resizing-performant",
"label": "Performant Column Resizing"
},
{
"to": "framework/angular/examples/remote-data",
"label": "Remote data (optional SSR)"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import {
signal,
untracked,
} from '@angular/core'
import type { ColumnDef, ColumnResizeMode } from '@tanstack/angular-table'
import {
FlexRenderDirective,
columnResizingFeature,
columnSizingFeature,
FlexRenderDirective,
injectTable,
tableFeatures,
} from '@tanstack/angular-table'
import type { Person } from './makeData'
import { makeData } from './makeData'
import { TableResizableCell, TableResizableHeader } from './resizable-cell'
import type { Person } from './makeData'
import type { ColumnDef, ColumnResizeMode } from '@tanstack/angular-table'

const _features = tableFeatures({
columnSizingFeature,
Expand Down
4 changes: 4 additions & 0 deletions examples/angular/remote-data/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Node.js",
"image": "mcr.microsoft.com/devcontainers/javascript-node:18"
}
16 changes: 16 additions & 0 deletions examples/angular/remote-data/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
42 changes: 42 additions & 0 deletions examples/angular/remote-data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
27 changes: 27 additions & 0 deletions examples/angular/remote-data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Basic

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.1.2.

## Development server

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.

## Code scaffolding

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`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

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.

## Further help

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.
102 changes: 102 additions & 0 deletions examples/angular/remote-data/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"remote-data": {
"cli": {
"cache": {
"enabled": false
}
},
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/remote-data",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [],
"outputHashing": "all",
"outputMode": "server",
"server": "src/main.server.ts",
"ssr": {
"entry": "src/server.ts"
}
},
"no-ssr": {
"budgets": [],
"outputHashing": "all",
"prerender": false,
"ssr": false
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true,
"outputMode": "server",
"server": "src/main.server.ts",
"ssr": {
"entry": "src/server.ts"
}
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "remote-data:build:production"
},
"no-ssr": {
"buildTarget": "remote-data:build:no-ssr"
},
"development": {
"buildTarget": "remote-data:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "remote-data:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
}
}
}
}
},
"cli": {
"analytics": false
}
}
39 changes: 39 additions & 0 deletions examples/angular/remote-data/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "tanstack-table-example-angular-remote-data",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"start:no-ssr": "ng serve --configuration=no-ssr",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"serve:ssr:remote-data": "node dist/remote-data/server/server.mjs"
},
"private": true,
"dependencies": {
"@angular/animations": "^19.1.4",
"@angular/common": "^19.1.4",
"@angular/compiler": "^19.1.4",
"@angular/core": "^19.1.4",
"@angular/forms": "^19.1.4",
"@angular/platform-browser": "^19.1.4",
"@angular/platform-browser-dynamic": "^19.1.4",
"@angular/platform-server": "^19.1.4",
"@angular/router": "^19.1.4",
"@angular/ssr": "^19.1.5",
"@tanstack/angular-table": "^9.0.0-alpha.10",
"express": "^4.18.2",
"rxjs": "~7.8.1",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^19.1.5",
"@angular/cli": "^19.1.5",
"@angular/compiler-cli": "^19.1.4",
"@types/express": "^4.17.17",
"@types/node": "^18.18.0",
"tslib": "^2.6.2",
"typescript": "5.7.3"
}
}
130 changes: 130 additions & 0 deletions examples/angular/remote-data/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<div class="p-2">
<div>
<input
(change)="table.setGlobalFilter($any($event.currentTarget).value)"
placeholder="Search..."
/>
</div>

<div class="overflow-x-auto">
<table>
<thead>
@for (headerGroup of table.getHeaderGroups(); track headerGroup.id) {
<tr>
@for (header of headerGroup.headers; track header.id) {
<th
[colSpan]="header.colSpan"
(click)="header.column.getToggleSortingHandler()?.($event)"
>
@if (!header.isPlaceholder) {
<div
[class.cursor-pointer]="header.column.getCanSort()"
class="flex gap-2"
>
<ng-container
*flexRender="
header.column.columnDef.header;
props: header.getContext();
let header
"
>
<div [innerHTML]="header"></div>
</ng-container>

@if (header.column.getIsSorted() === 'asc') {
<span>🔼</span>
}
@if (header.column.getIsSorted() === 'desc') {
<span>🔽</span>
}
</div>
}
</th>
}
</tr>
}
</thead>
<tbody>
@for (row of table.getRowModel().rows; track row.id) {
<!-- first row is a normal row -->
<tr>
@for (cell of row.getAllCells(); track cell.id) {
<td>
<ng-container
*flexRender="
cell.column.columnDef.cell;
props: cell.getContext();
let cell
"
>
<div [innerHTML]="cell"></div>
</ng-container>
</td>
}
</tr>
}
</tbody>
</table>
</div>

@if (data.isLoading()) {
Loading...
}
</div>

<div class="h-2"></div>
<div class="flex items-center gap-2">
<button
class="border rounded p-1"
(click)="table.setPageIndex(0)"
[disabled]="!table.getCanPreviousPage()"
>
<<
</button>
<button
class="border rounded p-1"
(click)="table.previousPage()"
[disabled]="!table.getCanPreviousPage()"
>
<
</button>
<button
class="border rounded p-1"
(click)="table.nextPage()"
[disabled]="!table.getCanNextPage()"
>
>
</button>
<button
class="border rounded p-1"
(click)="table.setPageIndex(table.getPageCount() - 1)"
[disabled]="!table.getCanNextPage()"
>
>>
</button>
<span class="flex items-center gap-1">
<div>Page</div>
<strong>
{{ table.getState().pagination.pageIndex + 1 }} of
{{ table.getPageCount() }}
</strong>
</span>
<span class="flex items-center gap-1">
| Go to page:
<input
type="number"
[value]="table.getState().pagination.pageIndex + 1"
(input)="onPageInputChange($event)"
class="border p-1 rounded w-16"
/>
</span>

<select
[value]="table.getState().pagination.pageSize"
(change)="onPageSizeChange($event)"
>
@for (pageSize of [10, 20, 30, 40, 50]; track pageSize) {
<option [value]="pageSize">Show {{ pageSize }}</option>
}
</select>
</div>
Loading
Loading