|
| 1 | +## `v19` Migration Guide |
| 2 | + |
| 3 | +`v19` of `@angular-ru/cdk` and `@angular-ru/ngxs` has been updated to utilize the latest features from Angular `v20`. |
| 4 | +This includes standalone components, environment providers, component input signals, and more. Because of this, |
| 5 | +migration is slightly more involved than usual. |
| 6 | + |
| 7 | +### Standalone components, directives, and pipes |
| 8 | + |
| 9 | +All `NgModules` have been removed. Components, directives, and pipes have been made standalone and some of the suffixes |
| 10 | +(Directive, Component) have been dropped. |
| 11 | + |
| 12 | +Here is an example of code before and after the migration: |
| 13 | + |
| 14 | +**Before:** |
| 15 | + |
| 16 | +```ts |
| 17 | +import {DisableControlDirectiveModule, AmountFormatModule, InputFilterModule} from '@angular-ru/cdk/directives'; |
| 18 | +import {MutableTypePipeModule, DeepPathPipeModule} from '@angular-ru/cdk/pipes'; |
| 19 | + |
| 20 | +@Component({ |
| 21 | + //... |
| 22 | + imports: [ |
| 23 | + DisableControlDirectiveModule, |
| 24 | + AmountFormatModule, |
| 25 | + InputFilterModule, |
| 26 | + MutableTypePipeModule, |
| 27 | + DeepPathPipeModule, |
| 28 | + ], |
| 29 | +}) |
| 30 | +export class MyComponent {} |
| 31 | +``` |
| 32 | + |
| 33 | +**After:** |
| 34 | + |
| 35 | +```ts |
| 36 | +import {DisableControl, AmountFormat, InputFilter} from '@angular-ru/cdk/directives'; |
| 37 | +import {MutableTypePipe, DeepPathPipe} from '@angular-ru/cdk/pipes'; |
| 38 | + |
| 39 | +@Component({ |
| 40 | + //... |
| 41 | + imports: [DisableControl, AmountFormat, InputFilter, MutableTypePipe, DeepPathPipe], |
| 42 | +}) |
| 43 | +export class MyComponent {} |
| 44 | +``` |
| 45 | + |
| 46 | +### `FeatureModule.forRoot()` module providers have been replaced with `provideFeature()` environment providers |
| 47 | + |
| 48 | +| **Module provider** | **Environment provider** | |
| 49 | +| ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | |
| 50 | +| `InputFilterModule.forRoot()` | `provideInputFilter()` | |
| 51 | +| `AmountFormatModule.forRoot()` | `provideAmountFormat()` | |
| 52 | +| `DataHttpClientModule.forRoot()` | `provideDataHttpClientOptions()` | |
| 53 | +| `DataHttpClientModule.forFeature()` | `provideDataHttpClientClients()` | |
| 54 | +| `ExcelBuilderModule.forRoot()` | `provideExcelBuilder()` | |
| 55 | +| `EXCEL_BUILDER_NGX_TRANSLATE_FALLBACK_PROVIDER` | `provideExcelBuilderNgxTranslateFallback()` | |
| 56 | +| `LoggerModule.forRoot()` | `provideLogger()` | |
| 57 | +| `NgxsDataPluginModule.forRoot()` | `provideNgxsDataPlugin()` | |
| 58 | +| `NgxsDataPluginModule.forRoot([NGXS_DATA_STORAGE_EXTENSION, NGXS_DATA_STORAGE_CONTAINER]),` | `provideNgxsDataPlugin(withNgxsDataStorage())` | |
| 59 | +| `NgxsDataPluginModule.forRoot([MY_FIRST_EXTENSION, MY_SECOND_EXTENSION])` | `provideNgxsDataPlugin(MY_FIRST_EXTENSION, MY_SECOND_EXTENSION)` | |
| 60 | +| `TooltipModule.forRoot()` | `provideTooltip()` | |
| 61 | +| `TableBuilderModule.forRoot()` | `provideVirtualTable()` | |
| 62 | +| `DateSuggestionModule.forRoot()` | `provideDateSuggestion()` | |
| 63 | +| `PlainTableComposerModule.forRoot()` | `providePlainTableComposer()` | |
| 64 | +| `TableClipboardModule` | `provideTableClipboard()` | |
| 65 | +| `WebsocketModule.forRoot()` | `provideWebsocket()` | |
| 66 | + |
| 67 | +**Before:** |
| 68 | + |
| 69 | +```ts |
| 70 | +export const appConfig: ApplicationConfig = { |
| 71 | + providers: [importProvidersFrom(NgxsDataPluginModule.forRoot())], |
| 72 | +}; |
| 73 | +``` |
| 74 | + |
| 75 | +**After:** |
| 76 | + |
| 77 | +```ts |
| 78 | +export const appConfig: ApplicationConfig = { |
| 79 | + providers: [provideNgxsDataPlugin()], |
| 80 | +}; |
| 81 | +``` |
| 82 | + |
| 83 | +### NGXS Data Plugin Extensions |
| 84 | + |
| 85 | +All ngxs data plugin extensions now have to be environment providers. |
| 86 | + |
| 87 | +**Before:** |
| 88 | + |
| 89 | +```ts |
| 90 | +import {NgxsDataExtension} from '@angular-ru/ngxs/typings'; |
| 91 | + |
| 92 | +export const MY_FIRST_EXTENSION: NgxsDataExtension = { |
| 93 | + provide: NGXS_PLUGINS, |
| 94 | + useClass: MySuperService, |
| 95 | + multi: true, |
| 96 | +}; |
| 97 | + |
| 98 | +export const MY_SECOND_EXTENSION: NgxsDataExtension = [ |
| 99 | + { |
| 100 | + provide: NGXS_PLUGINS, |
| 101 | + useClass: FeatureService, |
| 102 | + multi: true, |
| 103 | + }, |
| 104 | + { |
| 105 | + provide: MyInjectableToken, |
| 106 | + useFactory: (): MyFactory => new MyFactory(), |
| 107 | + }, |
| 108 | +]; |
| 109 | + |
| 110 | +NgxsDataPluginModule.forRoot([MY_FIRST_EXTENSION, MY_SECOND_EXTENSION]); |
| 111 | +``` |
| 112 | + |
| 113 | +**After:** |
| 114 | + |
| 115 | +```ts |
| 116 | +import {makeEnvironmentProviders} from '@angular/core'; |
| 117 | +import {withNgxsPlugin} from '@ngxs/store'; |
| 118 | + |
| 119 | +export const MY_FIRST_EXTENSION = withNgxsPlugin(MySuperService); |
| 120 | + |
| 121 | +export const MY_SECOND_EXTENSION = makeEnvironmentProviders([ |
| 122 | + withNgxsPlugin(FeatureService), |
| 123 | + { |
| 124 | + provide: MyInjectableToken, |
| 125 | + useFactory: (): MyFactory => new MyFactory(), |
| 126 | + }, |
| 127 | +]); |
| 128 | + |
| 129 | +provideNgxsDataPlugin(MY_FIRST_EXTENSION, MY_SECOND_EXTENSION); |
| 130 | +``` |
| 131 | + |
| 132 | +### Virtual Table changes and deprecations |
| 133 | + |
| 134 | +- `TableBuilderModule.forRoot()` module provider has been replaced by `provideVirtualTable()` environment provider. |
| 135 | +- `TableBuilderModule` has been replaced by `VirtualTable` readonly array of standalone component. |
| 136 | + |
| 137 | +**Before:** |
| 138 | + |
| 139 | +```ts |
| 140 | +import {TableBuilderModule} from '@angular-ru/cdk/virtual-table'; |
| 141 | + |
| 142 | +@Component({ |
| 143 | + //... |
| 144 | + imports: [TableBuilderModule], |
| 145 | +}) |
| 146 | +export class MyComponent {} |
| 147 | +``` |
| 148 | + |
| 149 | +**After:** |
| 150 | + |
| 151 | +```ts |
| 152 | +import {VirtualTable} from '@angular-ru/cdk/virtual-table'; |
| 153 | + |
| 154 | +@Component({ |
| 155 | + //... |
| 156 | + imports: [VirtualTable], |
| 157 | +}) |
| 158 | +export class MyComponent {} |
| 159 | +``` |
| 160 | + |
| 161 | +- All decorator inputs have been replaced by signal inputs, so, to read an input value in your component, the input has |
| 162 | + to be called as a function. |
| 163 | + |
| 164 | +**Before:** |
| 165 | + |
| 166 | +```ts |
| 167 | +export class MyComponent { |
| 168 | + @ViewChild('table') |
| 169 | + table!: TableBuilder<PlainObject>; |
| 170 | + |
| 171 | + constructor() { |
| 172 | + // "source" was a normal decorated input |
| 173 | + console.log('source:', this.table.source); |
| 174 | + } |
| 175 | +} |
| 176 | +``` |
| 177 | + |
| 178 | +**After:** |
| 179 | + |
| 180 | +```ts |
| 181 | +export class MyComponent { |
| 182 | + @ViewChild('table') |
| 183 | + table!: TableBuilder<PlainObject>; |
| 184 | + |
| 185 | + constructor() { |
| 186 | + // "source" is now a signal input |
| 187 | + console.log('source:', this.table.source()); |
| 188 | + } |
| 189 | +} |
| 190 | +``` |
| 191 | + |
| 192 | +- Some deprecated properties, methods and pipes have been removed: |
| 193 | + - `table.selectionEntries` property has been removed. Use `table.selectedKeyList` instead. |
| 194 | + - `tableSelectedItems` pipe has been removed. Use `mapToTableEntries` pipe instead. |
| 195 | + |
| 196 | + **Before:** |
| 197 | + |
| 198 | + ```html |
| 199 | + <p>Selected items: {{ (table?.selectionEntries | tableSelectedItems).length }}</p> |
| 200 | + ``` |
| 201 | + |
| 202 | + **After:** |
| 203 | + |
| 204 | + ```html |
| 205 | + <p>Selected items: {{ (table?.selectedKeyList | mapToTableEntries).length }}</p> |
| 206 | + ``` |
| 207 | + |
| 208 | + - `table.selectedItems` property has been removed. Use `table.getSelectedItems()` method instead. |
0 commit comments