Skip to content

Commit eab972f

Browse files
committed
fix: drawer
1 parent 6c6afc5 commit eab972f

File tree

6 files changed

+25
-18
lines changed

6 files changed

+25
-18
lines changed

.changeset/stale-dots-speak.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
---
44

55
- fix(drawer): no default config when using component mode
6+
- feat(drawer): template context support contentParams as $implicit

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"zone.js": "^0.13.1"
107107
},
108108
"resolutions": {
109-
"prettier": "~2.7.1"
109+
"prettier": "~2.8.8"
110110
},
111111
"publishConfig": {
112112
"access": "public",

src/drawer/component/internal/internal.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<ng-container
2121
*ngIf="isTemplateRef(options.title); else normal"
2222
[ngTemplateOutlet]="options.title"
23-
[ngTemplateOutletContext]="options.contentParams"
23+
[ngTemplateOutletContext]="context"
2424
></ng-container>
2525
<ng-template #normal>
2626
{{ options.title }}
@@ -42,7 +42,7 @@
4242
<ng-container
4343
*ngIf="isTemplateRef(options.content)"
4444
[ngTemplateOutlet]="options.content"
45-
[ngTemplateOutletContext]="options.contentParams"
45+
[ngTemplateOutletContext]="context"
4646
>
4747
</ng-container>
4848
</div>
@@ -54,7 +54,7 @@
5454
<ng-container
5555
*ngIf="isTemplateRef(options.footer); else normal"
5656
[ngTemplateOutlet]="options.footer"
57-
[ngTemplateOutletContext]="options.contentParams"
57+
[ngTemplateOutletContext]="context"
5858
></ng-container>
5959
<ng-template #normal>
6060
{{ options.footer }}

src/drawer/component/internal/internal.component.ts

+7
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ export class DrawerInternalComponent<T = unknown, C extends object = object> {
119119
);
120120
}
121121

122+
get context() {
123+
return {
124+
$implicit: this.options.contentParams,
125+
...this.options.contentParams,
126+
};
127+
}
128+
122129
isTemplateRef = isTemplateRef;
123130

124131
constructor(private readonly injector: Injector) {}

src/drawer/drawer.service.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import { DrawerRef } from './drawer-ref';
88
import { DrawerOptions, DrawerSize } from './types';
99

1010
const DRAWER_OVERLAY_CLASS = 'aui-drawer-overlay';
11+
const DEFAULT_OPTIONS = {
12+
size: DrawerSize.Medium,
13+
offsetY: '0',
14+
showClose: true,
15+
hideOnClickOutside: false,
16+
divider: true,
17+
disposeWhenHide: true,
18+
} as const satisfies DrawerOptions;
1119

1220
@Injectable()
1321
export class DrawerService<
@@ -23,15 +31,6 @@ export class DrawerService<
2331
DrawerInternalComponent<T, C>
2432
>;
2533

26-
private readonly DEFAULT_OPTIONS: DrawerOptions<T, C> = {
27-
size: DrawerSize.Medium,
28-
offsetY: '0',
29-
showClose: true,
30-
hideOnClickOutside: false,
31-
divider: true,
32-
disposeWhenHide: true,
33-
};
34-
3534
constructor(private readonly overlay: Overlay) {}
3635

3736
open(options: DrawerOptions<T, C>) {
@@ -47,7 +46,7 @@ export class DrawerService<
4746
}
4847

4948
updateOptions(options: DrawerOptions<T, C>): void {
50-
this.options = merge<DrawerOptions<T, C>>(this.DEFAULT_OPTIONS, options);
49+
this.options = merge<DrawerOptions<T, C>>(DEFAULT_OPTIONS, options);
5150
}
5251

5352
private createOverlay() {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -15238,10 +15238,10 @@ prettier-plugin-toml@^0.3.1:
1523815238
"@toml-tools/parser" "^0.3.1"
1523915239
prettier "^1.16.0"
1524015240

15241-
prettier@>=2.3, prettier@>=2.3.0, prettier@>=2.4.0, prettier@^1.16.0, prettier@^2.7.1, prettier@^2.8.0, prettier@^2.8.8, prettier@~2.7.1:
15242-
version "2.7.1"
15243-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64"
15244-
integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==
15241+
prettier@>=2.3, prettier@>=2.3.0, prettier@>=2.4.0, prettier@^1.16.0, prettier@^2.7.1, prettier@^2.8.0, prettier@^2.8.8, prettier@~2.8.8:
15242+
version "2.8.8"
15243+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
15244+
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
1524515245

1524615246
pretty-bytes@^5.3.0:
1524715247
version "5.6.0"

0 commit comments

Comments
 (0)