Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit c6091f5

Browse files
authored
feat: update Aurelia 2 Beta 24 (#1348)
* feat: update Aurelia 2 Beta 24 * chore: update missed Au2 dep * chore: try to enhance aurelia components * fix: delete custom element from `$au` in order to upgrade to Au2.Beta.24
1 parent 1d740b6 commit c6091f5

File tree

12 files changed

+343
-356
lines changed

12 files changed

+343
-356
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
},
4242
"devDependencies": {
4343
"@4tw/cypress-drag-drop": "^2.3.0",
44-
"@aurelia/fetch-client": "^2.0.0-beta.23",
45-
"@aurelia/i18n": "^2.0.0-beta.23",
46-
"@aurelia/platform": "^2.0.0-beta.23",
47-
"@aurelia/platform-browser": "^2.0.0-beta.23",
44+
"@aurelia/fetch-client": "^2.0.0-beta.24",
45+
"@aurelia/i18n": "^2.0.0-beta.24",
46+
"@aurelia/platform": "^2.0.0-beta.24",
47+
"@aurelia/platform-browser": "^2.0.0-beta.24",
4848
"@formkit/tempo": "^0.1.2",
4949
"@jest/types": "^29.6.3",
5050
"@lerna-lite/cli": "^4.0.0",

packages/aurelia-slickgrid/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
"pack": "npm pack"
4747
},
4848
"peerDependencies": {
49-
"aurelia": "^2.0.0-beta.23"
49+
"aurelia": "^2.0.0-beta.24"
5050
},
5151
"dependencies": {
52-
"@aurelia/i18n": "^2.0.0-beta.23",
53-
"@aurelia/runtime": "^2.0.0-beta.23",
54-
"@aurelia/runtime-html": "^2.0.0-beta.23",
52+
"@aurelia/i18n": "^2.0.0-beta.24",
53+
"@aurelia/runtime": "^2.0.0-beta.24",
54+
"@aurelia/runtime-html": "^2.0.0-beta.24",
5555
"@formkit/tempo": "^0.1.2",
5656
"@slickgrid-universal/common": "~5.14.0",
5757
"@slickgrid-universal/custom-footer-component": "~5.14.0",

packages/aurelia-slickgrid/src/custom-elements/aurelia-slickgrid.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export class AureliaSlickgridCustomElement {
125125
extensionUtility: ExtensionUtility;
126126
filterFactory!: FilterFactory;
127127
filterService: FilterService;
128+
gridContainer!: HTMLDivElement;
128129
gridEventService: GridEventService;
129130
gridService: GridService;
130131
gridStateService: GridStateService;
@@ -135,7 +136,6 @@ export class AureliaSlickgridCustomElement {
135136
sharedService: SharedService;
136137
sortService: SortService;
137138
treeDataService: TreeDataService;
138-
gridContainer!: HTMLDivElement;
139139

140140
@bindable({ mode: BindingMode.twoWay }) columnDefinitions: Column[] = [];
141141
@bindable({ mode: BindingMode.twoWay }) element!: Element;
@@ -358,8 +358,7 @@ export class AureliaSlickgridCustomElement {
358358
}
359359

360360
// build SlickGrid Grid, also user might optionally pass a custom dataview (e.g. remote model)
361-
this.grid = new SlickGrid(this.gridContainer, this.customDataView || this.dataview, this._columnDefinitions, this.gridOptions, this._eventPubSubService);
362-
this.sharedService.dataView = this.dataview;
361+
this.grid = new SlickGrid(this.gridContainer, this.customDataView || this.dataview, this._columnDefinitions, this.gridOptions, this._eventPubSubService); this.sharedService.dataView = this.dataview;
363362
this.sharedService.slickGrid = this.grid;
364363
this.sharedService.gridContainerElement = this.elm as HTMLDivElement;
365364
if (this.groupItemMetadataProvider) {

packages/aurelia-slickgrid/src/extensions/slickRowDetailView.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,12 @@ import { SlickRowDetailView as UniversalSlickRowDetailView } from '@slickgrid-un
1414
import type { ICustomElementController } from '@aurelia/runtime-html';
1515
import { type Constructable, resolve, transient } from 'aurelia';
1616

17-
import type { AureliaViewOutput, GridOption, RowDetailView, ViewModelBindableInputData } from '../models/index';
17+
import type { CreatedView, GridOption, RowDetailView, ViewModelBindableInputData } from '../models/index';
1818
import { AureliaUtilService } from '../services/aureliaUtil.service';
1919

2020
const ROW_DETAIL_CONTAINER_PREFIX = 'container_';
2121
const PRELOAD_CONTAINER_PREFIX = 'container_loading';
2222

23-
export interface CreatedView extends AureliaViewOutput {
24-
id: string | number;
25-
dataContext: any;
26-
}
27-
2823
@transient()
2924
export class SlickRowDetailView extends UniversalSlickRowDetailView {
3025
protected _preloadViewModel?: Constructable;

packages/aurelia-slickgrid/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export { AureliaSlickgridCustomElement } from './custom-elements/aurelia-slickgr
2323
import type {
2424
AureliaGridInstance,
2525
AureliaViewOutput,
26+
CreatedView,
2627
GridOption,
2728
RowDetailView,
2829
ViewModelBindableData,
@@ -33,6 +34,7 @@ import type {
3334
export {
3435
type AureliaGridInstance,
3536
type AureliaViewOutput,
37+
type CreatedView,
3638
type GridOption,
3739
type RowDetailView,
3840
type ViewModelBindableData,
@@ -46,4 +48,4 @@ export {
4648
TranslaterService,
4749
disposeAllSubscriptions
4850
} from './services/index';
49-
export { SlickRowDetailView } from './extensions/slickRowDetailView'
51+
export { SlickRowDetailView } from './extensions/slickRowDetailView';
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import type { ICustomElementController } from '@aurelia/runtime-html';
1+
import type { IAppRoot, ICustomElementController } from '@aurelia/runtime-html';
22

33
export interface AureliaViewOutput {
4+
root?: IAppRoot<object>;
45
controller?: ICustomElementController<any>;
56
}

packages/aurelia-slickgrid/src/models/rowDetailView.interface.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { RowDetailView as UniversalRowDetailView } from '@slickgrid-universal/common';
22
import type { Constructable } from 'aurelia';
3+
import type { AureliaViewOutput } from './aureliaViewOutput.interface';
34

45
export interface RowDetailView extends UniversalRowDetailView {
56
/**
@@ -14,3 +15,8 @@ export interface RowDetailView extends UniversalRowDetailView {
1415
/** View Model template that will be loaded once the async function finishes */
1516
viewModel?: Constructable;
1617
}
18+
19+
export interface CreatedView extends AureliaViewOutput {
20+
id: string | number;
21+
dataContext: any;
22+
}

packages/aurelia-slickgrid/src/services/aureliaUtil.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import { AppTask, type Constructable, CustomElement, IAurelia, resolve, singleton } from 'aurelia';
1+
import { AppTask, type Constructable, CustomElement, type IAppRoot, IAurelia, resolve, singleton } from 'aurelia';
22

3-
import type { AureliaViewOutput, ViewModelBindableInputData } from '../models/index';
3+
import type { ViewModelBindableInputData } from '../models/index';
44

55
@singleton()
66
export class AureliaUtilService {
77
constructor(private readonly au: IAurelia = resolve(IAurelia)) { }
88

9-
async createAureliaViewModelAddToSlot(viewModel: Constructable, bindableData?: ViewModelBindableInputData, targetElement?: HTMLElement): Promise<AureliaViewOutput | null> {
9+
async createAureliaViewModelAddToSlot(viewModel: Constructable, bindableData?: ViewModelBindableInputData, targetElement?: HTMLElement): Promise<IAppRoot | null> {
1010
if (targetElement) {
1111
const def = CustomElement.getDefinition(viewModel);
1212
const addonBindable = bindableData?.addon ? 'addon.bind="bindableData.addon"' : '';
1313
const gridBindable = bindableData?.grid ? 'grid.bind="bindableData.grid"' : '';
1414
const dataViewBindable = bindableData?.dataView ? 'data-view.bind="bindableData.dataView"' : '';
1515
const parentBindable = bindableData?.parent ? 'parent.bind="bindableData.parent"' : '';
16-
16+
1717
targetElement.innerHTML = `<${def.name} model.bind="bindableData.model" ${addonBindable} ${gridBindable} ${dataViewBindable} ${parentBindable}></${def.name}>`.trim();
18-
18+
delete (targetElement as any)['$au']?.['au:resource:custom-element'];
19+
1920
return await this.au.enhance({
2021
host: targetElement,
2122
component: { bindableData },

packages/aurelia-slickgrid/src/services/translater.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import type { TranslaterService as UniversalTranslateService } from '@slickgrid-universal/common';
22
import { I18N } from '@aurelia/i18n';
3-
import { optional, resolve } from 'aurelia';
3+
import { inject, optional } from 'aurelia';
44

55
/**
66
* This is a Translate Service Wrapper for Slickgrid-Universal monorepo lib to work properly,
77
* it must implement Slickgrid-Universal TranslaterService interface to work properly
88
*/
9+
@inject(optional(I18N))
910
export class TranslaterService implements UniversalTranslateService {
10-
constructor(private readonly i18n: I18N | undefined = resolve(optional(I18N))) { }
11+
constructor(private readonly i18n: I18N) { }
1112

1213
/**
1314
* Method to return the current language used by the App

packages/demo/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
"serve:demo": "vite preview"
3232
},
3333
"dependencies": {
34-
"@aurelia/fetch-client": "^2.0.0-beta.23",
35-
"@aurelia/i18n": "^2.0.0-beta.23",
36-
"@aurelia/kernel": "^2.0.0-beta.23",
37-
"@aurelia/metadata": "^2.0.0-beta.23",
38-
"@aurelia/router": "^2.0.0-beta.23",
39-
"@aurelia/router-lite": "^2.0.0-beta.23",
40-
"@aurelia/runtime": "^2.0.0-beta.23",
41-
"@aurelia/runtime-html": "^2.0.0-beta.23",
34+
"@aurelia/fetch-client": "^2.0.0-beta.24",
35+
"@aurelia/i18n": "^2.0.0-beta.24",
36+
"@aurelia/kernel": "^2.0.0-beta.24",
37+
"@aurelia/metadata": "^2.0.0-beta.24",
38+
"@aurelia/router": "^2.0.0-beta.24",
39+
"@aurelia/router-lite": "^2.0.0-beta.24",
40+
"@aurelia/runtime": "^2.0.0-beta.24",
41+
"@aurelia/runtime-html": "^2.0.0-beta.24",
4242
"@faker-js/faker": "^9.7.0",
4343
"@fnando/sparkline": "^0.3.10",
4444
"@formkit/tempo": "^0.1.2",
@@ -52,17 +52,17 @@
5252
"@slickgrid-universal/row-detail-view-plugin": "^5.14.0",
5353
"@slickgrid-universal/rxjs-observable": "^5.14.0",
5454
"@slickgrid-universal/text-export": "^5.14.0",
55-
"aurelia": "^2.0.0-beta.23",
55+
"aurelia": "^2.0.0-beta.24",
5656
"aurelia-slickgrid": "workspace:*",
5757
"bootstrap": "^5.3.5",
5858
"i18next": "^23.16.8",
5959
"i18next-fetch-backend": "^6.0.0",
6060
"rxjs": "^7.8.2"
6161
},
6262
"devDependencies": {
63-
"@aurelia/testing": "^2.0.0-beta.23",
64-
"@aurelia/ts-jest": "^2.0.0-beta.23",
65-
"@aurelia/vite-plugin": "2.0.0-beta.23",
63+
"@aurelia/testing": "^2.0.0-beta.24",
64+
"@aurelia/ts-jest": "^2.0.0-beta.24",
65+
"@aurelia/vite-plugin": "^2.0.0-beta.24",
6666
"@types/fnando__sparkline": "^0.3.7",
6767
"@types/jest": "^29.5.14",
6868
"@types/node": "^22.15.2",

packages/demo/src/examples/slickgrid/example26.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
type AureliaGridInstance,
44
AureliaUtilService,
55
type Column,
6+
type CreatedView,
67
type EditCommand,
78
Editors,
89
FieldType,
@@ -45,6 +46,7 @@ export class Example26 {
4546
</ul>
4647
`;
4748
private _commandQueue: EditCommand[] = [];
49+
private _slots: CreatedView[] = [];
4850
aureliaGrid!: AureliaGridInstance;
4951
gridOptions!: GridOption;
5052
columnDefinitions: Column[] = [];
@@ -332,13 +334,28 @@ export class Example26 {
332334
return true;
333335
}
334336

335-
renderAureliaComponent(cellNode: HTMLElement, _row: number, dataContext: any, colDef: Column) {
337+
async renderAureliaComponent(cellNode: HTMLElement, _row: number, dataContext: any, colDef: Column) {
336338
if (colDef.params.viewModel && cellNode) {
337339
const bindableData = {
338340
model: dataContext,
339341
grid: this.aureliaGrid.slickGrid,
340342
} as ViewModelBindableInputData;
341-
this.aureliaUtilService.createAureliaViewModelAddToSlot(colDef.params.viewModel, bindableData, cellNode);
343+
const slotIdx = this._slots.findIndex(obj => obj.id === dataContext.id);
344+
const slotObj = this._slots[slotIdx];
345+
if (slotObj?.controller) {
346+
await slotObj.controller.deactivate(slotObj.controller, slotObj?.controller.parent ?? null);
347+
this._slots.slice(slotIdx, 1);
348+
}
349+
const comp = await this.aureliaUtilService.createAureliaViewModelAddToSlot(colDef.params.viewModel, bindableData, cellNode);
350+
if (!slotObj) {
351+
const viewInfo: CreatedView = {
352+
id: dataContext.id,
353+
dataContext,
354+
root: comp,
355+
controller: comp.controller
356+
};
357+
this._slots.push(viewInfo);
358+
}
342359
}
343360
}
344361

0 commit comments

Comments
 (0)