-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
feat(angular-table): adds Angular adapter for tanstack/table #5326
feat(angular-table): adds Angular adapter for tanstack/table #5326
Conversation
# Conflicts: # .gitignore # pnpm-lock.yaml
so how does this adapter work? I just see config files. Could a basic example using the adapter be created in the examples dir? |
Sure, definately |
@crutchcorn , I'm not really well-versed in how the Angular ecosystem works. Would you be able to help with this? FYI @lachlancollins too |
Thanks for your work @jrgokavalsa . Going to bring in more help polishing this and getting more docs ready before we ship. Your continued involvement will still be appreciated. |
@jrgokavalsa, I noticed the lib directory that is being referenced in the |
Yeah, that's what I was confused about. It seems the actual adapter is not in this PR yet. |
Yeah he might have to change the folder name to something else |
hi 👋 do I see correctly that the actual adapter ( packages/angular-table/src/public-api.ts:
|
<tr> | ||
@for (header of headerGroup.headers; track header.id) { | ||
<th [attr.colSpan]="header.colSpan"> | ||
@if (!header.isPlaceholder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Why not a single @if
block ?
> | ||
{{ aggregatedCell }} | ||
</ng-container> | ||
} @else if (cell.getIsPlaceholder()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Would be interesting to know why this is empty.
export * from './lib/flexrender.directive' | ||
export * from './lib/index' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are those files ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually got messed up by this commit : 91117bc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KevinVandy @JeanMeche @Lord-AY
export * from './lib/flexrender.directive'
export * from './lib/index'
moved above files from lib folder to src folder, updated examples
standalone: true, | ||
}) | ||
export class FlexRenderDirective implements OnInit { | ||
// private vcr = inject(ViewContainerRef) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove the commented code.
// private vcr = inject(ViewContainerRef) | ||
// private templateRef = inject(TemplateRef) | ||
|
||
private _flexRender: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably do better than any
private _flexRender: any | |
private _flexRender: string|() => any|null |
Maybe we could make the function a generic one, so that we can reuse the generic for flexRenderProps
.
private _flexRenderProps: any | ||
|
||
@Input({ required: true }) | ||
set flexRender(render: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, let add constraints on the input type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this looks good or any suggestions
type FlexRenderType = string | null | (() => any) | ((props: any) => any)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried changing the type getting the following error
Type 'ColumnDefTemplate<HeaderContext<Person, unknown>> | undefined' is not assignable to type 'FlexRenderType'.
I moved back to any
# Conflicts: # package.json # pnpm-lock.yaml
@JeanMeche Updated the library with selection example and moved flexrender.directive to index.ts file |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 3955792. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution
Sent with 💌 from NxCloud. |
packages/angular-table/package.json
Outdated
"build:types": "tsc --emitDeclarationOnly" | ||
}, | ||
"dependencies": { | ||
"tslib": "^2.3.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is tslib a package dependency? Maybe this should just be in the root package.json? Or a devDep here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we can move it root package.json
"test": "ng test" | ||
}, | ||
"private": true, | ||
"dependencies": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a dumb question, but would using Vite with Angular be better or worse for these examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're wanting to consolidate on Vite as our build tooling for both examples and script packaging - might not be a bad idea to switch both over
// This ensures that if the 'flexRender' input is set before the directive initializes, | ||
// the component will be rendered when ngOnInit is called. | ||
if (this._flexRender) { | ||
this.renderComponent() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code overall LGTM, but I thought ngOnInit
doesn't have access to @Input
props - how does this code ever run?
/** properties to render */ | ||
private _flexRenderProps: any | ||
|
||
@Input({ required: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that was a question for me. If using Angular 17 as the minimum peerDep, should this use signals? Or should we support much lower versions of Angular?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming initial version will be experimental like Angular tanstack query so its safe to use latest angular as minimum version I think 17.3 (currently in rc) could be used as minimum if output api is needed, and later it can be changed to 18 too, if this adapter stays as experimental until May 24.
@imaksp @crutchcorn @jrgokavalsa @Lord-AY @JeanMeche I think that today I will solve merge conflicts, and then merge this into a branch off of main. That way, anyone can work off of the work of the adapter and make a PR to get this over the finish line. I think there might be some work left to do before shipping this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging into the feat-angular-table branch where work will continue.
* feat(angular-table): adds Angular adapter for tanstack/table (#5326) * Angular adapter for tanstack table initial * build with: ng packagr * Add angular examples basic grouping * Add angular examples basic grouping * Update angular examples basic grouping * Add angular example selection * regen lock file * package upgrades, angular table docs * prettier * move around some deps * removed unused dependency from angular package * fix deps --------- Co-authored-by: Kevin Van Cott <[email protected]> * docs config cleanup * feat: signal angular table adapter implementation * update demo * feat: table proxy detect memoized fns * fix proxy property returning value * feat: improve naming * save new reference of table signal on every update * computed trap proxy for fns with 1 argument * update pnpm-lock.yaml * refactor proxy implementation * fix dependencies * cleanup imports * refactor basic example * fix build * run prettier * add grouping example, fix ci * add grouping example, fix ci * add row selection example * add column visibility example * update examples add signal input required example * improve angular table impl, fix flex-render change detection issues * fix build * feat(angular-table): improve adapter implementation (#5524) * feat(angular-table): support render dynamic components and templateRefs in table * update row selection example using dynamic rendered components * support change detection on push with flex render * add column ordering example * fix flexRender change detection issues * rename properties * fix prettier and adjust example budget options * update basic example * add again support for table signal * add column-pinning example * add column pinning example * add filters example * cleanup code * example cleanup * update lock file * feat(angular-table): added injector optional parameter for more flexibility (#5525) * feat(angular-table): improve adapter implementation (#5524) * Added optional injector for more flexibility * Replace runInInjectionContext with injector in effect * feat(angular-table): Added proxifyTable back * feat(angular-table): adding back notifier signal for table changed * feat(angular-table): Improve logic in setting table options *set table options inside computed before returning the table instance *remove redundant signals and effect *remove injector as it no longer required *update Grouping example to show how to pass signal when creating table * update angular adapter and state docs * prettier * update docs config with angular examples * update angular table state docs (#5545) * Angular examples and dependencies improvements (#5546) * tslib should be a dependency, see: https://angular.io/guide/angular-package-format#tslib * ensure angular examples are run as web container on code sandbox * update lock file --------- Co-authored-by: Kevin Vandy <[email protected]> * docs(angular-table): Add documentation for FlexRenderDirective (#5543) * add flexRender documentation * fix docs * fix rendering component section heading * remove double build package.json from angular build * update link name * docs pass * update esm exports in package.json * update flexrender types --------- Co-authored-by: jrgokavalsa <[email protected]> Co-authored-by: riccardoperra <[email protected]> Co-authored-by: Riccardo Perra <[email protected]> Co-authored-by: mamerto-g <[email protected]> Co-authored-by: Arnoud <[email protected]>
Adds angular adapter for tanstack/table