Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/alpha' into angular-fetch-data-s…
Browse files Browse the repository at this point in the history
…sr-example
  • Loading branch information
riccardoperra committed Feb 10, 2025
2 parents 5b514b4 + 2a41a7e commit e125d1c
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,24 @@ 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 { makeData } from './makeData'
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,
columnResizingFeature
columnResizingFeature,
})

const defaultColumns: Array<
ColumnDef<
typeof _features,
Person
>
> = [
const defaultColumns: Array<ColumnDef<typeof _features, Person>> = [
{
header: 'Name',
footer: (props) => props.column.id,
Expand Down
18 changes: 12 additions & 6 deletions examples/angular/expanding/src/app/expandable-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ExpandableHeaderCell<T extends RowData> {
readonly context = injectFlexRenderContext<
HeaderContext<
{
rowExpandingFeature: typeof rowExpandingFeature,
rowExpandingFeature: typeof rowExpandingFeature
rowSelectionFeature: typeof rowSelectionFeature
},
T,
Expand All @@ -43,7 +43,7 @@ export class ExpandableHeaderCell<T extends RowData> {
readonly label = input.required<string>()

get table() {
return this.context.table;
return this.context.table
}
}

Expand Down Expand Up @@ -83,10 +83,16 @@ export class ExpandableHeaderCell<T extends RowData> {
`,
})
export class ExpandableCell<T extends RowData> {
readonly context = injectFlexRenderContext<CellContext<{
rowExpandingFeature: typeof rowExpandingFeature,
rowSelectionFeature: typeof rowSelectionFeature
}, T, unknown>>()
readonly context = injectFlexRenderContext<
CellContext<
{
rowExpandingFeature: typeof rowExpandingFeature
rowSelectionFeature: typeof rowSelectionFeature
},
T,
unknown
>
>()

get row() {
return this.context.row
Expand Down
13 changes: 3 additions & 10 deletions examples/angular/remote-data/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@
"outputPath": "dist/remote-data",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
},
"configurations": {
Expand Down
21 changes: 9 additions & 12 deletions examples/angular/remote-data/src/app/app.config.server.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { mergeApplicationConfig } from '@angular/core';
import { provideServerRendering } from '@angular/platform-server';
import { provideServerRouting } from '@angular/ssr';
import { appConfig } from './app.config';
import { serverRoutes } from './app.routes.server';
import type { ApplicationConfig } from '@angular/core';
import { mergeApplicationConfig } from '@angular/core'
import { provideServerRendering } from '@angular/platform-server'
import { provideServerRouting } from '@angular/ssr'
import { appConfig } from './app.config'
import { serverRoutes } from './app.routes.server'
import type { ApplicationConfig } from '@angular/core'

const serverConfig: ApplicationConfig = {
providers: [
provideServerRendering(),
provideServerRouting(serverRoutes)
]
};
providers: [provideServerRendering(), provideServerRouting(serverRoutes)],
}

export const config = mergeApplicationConfig(appConfig, serverConfig);
export const config = mergeApplicationConfig(appConfig, serverConfig)
10 changes: 5 additions & 5 deletions examples/angular/remote-data/src/main.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { config } from './app/app.config.server';
import { bootstrapApplication } from '@angular/platform-browser'
import { AppComponent } from './app/app.component'
import { config } from './app/app.config.server'

const bootstrap = () => bootstrapApplication(AppComponent, config);
const bootstrap = () => bootstrapApplication(AppComponent, config)

export default bootstrap;
export default bootstrap
30 changes: 15 additions & 15 deletions examples/angular/remote-data/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import {
createNodeRequestHandler,
isMainModule,
writeResponseToNodeResponse,
} from '@angular/ssr/node';
import express from 'express';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
} from '@angular/ssr/node'
import express from 'express'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'

const serverDistFolder = dirname(fileURLToPath(import.meta.url));
const browserDistFolder = resolve(serverDistFolder, '../browser');
const serverDistFolder = dirname(fileURLToPath(import.meta.url))
const browserDistFolder = resolve(serverDistFolder, '../browser')

const app = express();
const angularApp = new AngularNodeAppEngine();
const app = express()
const angularApp = new AngularNodeAppEngine()

/**
* Example Express Rest API endpoints can be defined here.
Expand All @@ -35,7 +35,7 @@ app.use(
index: false,
redirect: false,
}),
);
)

/**
* Handle all other requests by rendering the Angular application.
Expand All @@ -46,21 +46,21 @@ app.use('/**', (req, res, next) => {
.then((response) =>
response ? writeResponseToNodeResponse(response, res) : next(),
)
.catch(next);
});
.catch(next)
})

/**
* Start the server if this module is the main entry point.
* The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
*/
if (isMainModule(import.meta.url)) {
const port = process.env['PORT'] || 4000;
const port = process.env['PORT'] || 4000
app.listen(port, () => {
console.log(`Node Express server listening on http://localhost:${port}`);
});
console.log(`Node Express server listening on http://localhost:${port}`)
})
}

/**
* The request handler used by the Angular CLI (dev-server and during build).
*/
export const reqHandler = createNodeRequestHandler(app);
export const reqHandler = createNodeRequestHandler(app)
10 changes: 2 additions & 8 deletions examples/angular/remote-data/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": [
"node"
]
"types": ["node"]
},
"files": [
"src/main.ts",
"src/main.server.ts",
"src/server.ts"
],
"files": ["src/main.ts", "src/main.server.ts", "src/server.ts"],
"include": ["src/**/*.d.ts"]
}
6 changes: 3 additions & 3 deletions examples/angular/row-dnd/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const defaultColumns: Array<
ColumnDef<
{
rowPaginationFeature: typeof rowPaginationFeature
columnSizingFeature: typeof columnSizingFeature,
columnVisibilityFeature: typeof columnVisibilityFeature,
columnSizingFeature: typeof columnSizingFeature
columnVisibilityFeature: typeof columnVisibilityFeature
},
Person
>
Expand Down Expand Up @@ -79,7 +79,7 @@ export class AppComponent {
_features: {
rowPaginationFeature,
columnSizingFeature,
columnVisibilityFeature
columnVisibilityFeature,
},
_rowModels: {
paginatedRowModel: createPaginatedRowModel(),
Expand Down
32 changes: 15 additions & 17 deletions examples/angular/sub-components/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ChangeDetectionStrategy,
Component,
signal,
} from '@angular/core'
import { ChangeDetectionStrategy, Component, signal } from '@angular/core'
import {
FlexRenderDirective,
columnVisibilityFeature,
Expand All @@ -13,18 +9,20 @@ import {
} from '@tanstack/angular-table'
import { ReactiveFormsModule } from '@angular/forms'
import { JsonPipe, NgTemplateOutlet } from '@angular/common'
import { makeData } from './makeData'
import { makeData } from './makeData'
import { ExpandableCell, ExpanderCell } from './expandable-cell'
import type {Person} from './makeData';
import type {
ColumnDef,
ExpandedState,
} from '@tanstack/angular-table'
import type { Person } from './makeData'
import type { ColumnDef, ExpandedState } from '@tanstack/angular-table'

const columns: Array<ColumnDef<{
rowExpandingFeature: typeof rowExpandingFeature,
columnVisibilityFeature: typeof columnVisibilityFeature
}, Person>> = [
const columns: Array<
ColumnDef<
{
rowExpandingFeature: typeof rowExpandingFeature
columnVisibilityFeature: typeof columnVisibilityFeature
},
Person
>
> = [
{
header: 'Name',
footer: (props) => props.column.id,
Expand Down Expand Up @@ -107,12 +105,12 @@ const columns: Array<ColumnDef<{
})
export class AppComponent {
readonly data = signal<Array<Person>>(makeData(10))
readonly expanded = signal<ExpandedState>({});
readonly expanded = signal<ExpandedState>({})

tableHelper = createTableHelper({
_features: {
rowExpandingFeature: rowExpandingFeature,
columnVisibilityFeature: columnVisibilityFeature
columnVisibilityFeature: columnVisibilityFeature,
},
_rowModels: {
expandedRowModel: createExpandedRowModel(),
Expand Down

0 comments on commit e125d1c

Please sign in to comment.