-
Notifications
You must be signed in to change notification settings - Fork 8
fix(ag-grid): change theme to function and add charts export path #3816
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6a9b7f1
chore(changeset): update msal acquire-token-request default [hotfix]
odinr 0e7a8dd
fix(module-ag-grid): change theme to function for lazy evaluation
odinr d9f2bd2
feat(react-ag-grid): add charts export path
odinr d6b2dc5
test(cookbook): add theme override example
odinr 97ccc9d
refactor(cookbook): update AG Charts imports to use framework export
odinr ba0f04b
chore: update dependencies in pnpm-lock.yaml
odinr dc77275
Update .changeset/module-ag-grid_theme-function.md
odinr 0e0bfa8
refactor(ag-grid): remove unused createTheme import
odinr d8012e0
Update packages/modules/ag-grid/src/AgGridProvider.ts
odinr 9029ff6
refactor(ag-grid): update exports for ag-charts modules
odinr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@equinor/fusion-framework-cookbook-app-react-ag-grid": patch | ||
| --- | ||
|
|
||
| Add test theme override example in cookbook configuration. | ||
|
|
||
| Demonstrates how to use the theme function API with custom theme parameters. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@equinor/fusion-framework-cookbook-app-react-charts": patch | ||
| --- | ||
|
|
||
| Update AG Charts imports to use new `@equinor/fusion-framework-react-ag-grid/charts` export path. | ||
|
|
||
| Migrate from direct `ag-charts-react` imports to the framework's unified charts export. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
| "@equinor/fusion-framework-module-ag-grid": minor | ||
| --- | ||
|
|
||
| Internal: `theme` config property now expects a function `() => Theme` for lazy evaluation, but consumer APIs remain backward compatible. | ||
|
|
||
| Most consumers using `builder.setTheme()` do not need to migrate; it still accepts both `Theme` objects and functions. Only direct construction of `AgGridConfig` requires the function wrapper. | ||
|
|
||
| ```typescript | ||
| // Internal API change (rare, direct config construction) | ||
| const config: AgGridConfig = { | ||
| theme: () => myTheme | ||
| }; | ||
|
|
||
| // Builder API remains backward compatible | ||
| builder.setTheme(myTheme); // still works | ||
| builder.setTheme((theme) => theme.withParams({...})); // also works | ||
| ``` | ||
|
|
||
| Fixes: https://github.com/equinor/fusion-framework/issues/747 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| "@equinor/fusion-framework-react-ag-grid": minor | ||
| --- | ||
|
|
||
| Add new `./charts` export path for AG Charts React components and enterprise module. | ||
|
|
||
| The package now exports `AgCharts` and `AgChartsEnterpriseModule` from a dedicated `./charts` export path. This provides a cleaner separation from the enterprise exports. | ||
|
|
||
| ```typescript | ||
| import { AgCharts, AgChartsEnterpriseModule } from '@equinor/fusion-framework-react-ag-grid/charts'; | ||
| ``` | ||
|
|
||
| Note: Charts exports are still available from `./enterprise` for backward compatibility but will be removed in a future minor release. | ||
|
|
||
| Fixes: https://github.com/equinor/fusion-framework/issues/747 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,23 @@ | ||
| import { BaseConfigBuilder } from '@equinor/fusion-framework-module'; | ||
|
|
||
| import { type Theme, type Module, createTheme } from 'ag-grid-community'; | ||
| import type { Theme, Module } from 'ag-grid-community'; | ||
| import type { AgGridConfig, IAgGridConfigurator } from './AgGridConfigurator.interface'; | ||
| import { createTheme } from './themes'; | ||
|
|
||
| export class AgGridConfigurator | ||
| extends BaseConfigBuilder<AgGridConfig> | ||
| implements IAgGridConfigurator | ||
| { | ||
| // local template variables | ||
| #modules: Set<Module>; | ||
| #theme: Theme | undefined; | ||
| #theme: () => Theme; | ||
|
|
||
| constructor(args: Partial<AgGridConfig> = {}) { | ||
| super(); | ||
|
|
||
| // set default values | ||
| this.#modules = new Set(args.modules || []); | ||
| this.#theme = args.theme ?? createTheme(); | ||
| this.#theme = args.theme ?? (() => createTheme()); | ||
|
|
||
| // set config properties | ||
| this._set('modules', async () => [...this.#modules]); | ||
|
|
@@ -30,9 +31,9 @@ export class AgGridConfigurator | |
|
|
||
| setTheme(valueOrCallback: Theme | ((baseTheme: Theme) => Theme) | null): void { | ||
| if (typeof valueOrCallback === 'function') { | ||
| this.#theme = valueOrCallback(this.#theme ?? createTheme()); | ||
| this._set('theme', async () => () => valueOrCallback(this.#theme())); | ||
| } else { | ||
| this.#theme = valueOrCallback ?? undefined; | ||
| this._set('theme', async () => () => valueOrCallback as Theme); | ||
| } | ||
| } | ||
|
Comment on lines
32
to
38
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { AgChartsEnterpriseModule } from 'ag-charts-enterprise'; | ||
| export * from 'ag-charts-react'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export * from 'ag-grid-enterprise'; | ||
| // todo remove in next minor release - use ./charts instead | ||
| export { AgChartsEnterpriseModule } from 'ag-charts-enterprise'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When
valueOrCallbackisnull, this code casts it toThemeand wraps it in a function. This will result in() => null, which will cause issues when the theme is used.The handling of
nullshould either setthemetoundefinedor to a default theme function: