From 9dd6abe54d5370f06a1a5b65fe291c2e8bf9055d Mon Sep 17 00:00:00 2001 From: tianwenjie Date: Mon, 18 Dec 2023 18:26:35 +0800 Subject: [PATCH 1/4] fix: drawer --- .changeset/stale-dots-speak.md | 5 +++++ src/drawer/drawer.service.ts | 37 +++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 .changeset/stale-dots-speak.md diff --git a/.changeset/stale-dots-speak.md b/.changeset/stale-dots-speak.md new file mode 100644 index 000000000..ced2862e8 --- /dev/null +++ b/.changeset/stale-dots-speak.md @@ -0,0 +1,5 @@ +--- +'@alauda/ui': patch +--- + +- fix: no default config for using component mode diff --git a/src/drawer/drawer.service.ts b/src/drawer/drawer.service.ts index fada83d1e..caf19aa1b 100644 --- a/src/drawer/drawer.service.ts +++ b/src/drawer/drawer.service.ts @@ -8,14 +8,6 @@ import { DrawerRef } from './drawer-ref'; import { DrawerOptions, DrawerSize } from './types'; const DRAWER_OVERLAY_CLASS = 'aui-drawer-overlay'; -const DEFAULT_OPTIONS: DrawerOptions = { - size: DrawerSize.Medium, - offsetY: '0', - showClose: true, - hideOnClickOutside: false, - divider: true, - disposeWhenHide: true, -}; @Injectable() export class DrawerService< @@ -31,6 +23,15 @@ export class DrawerService< DrawerInternalComponent >; + private readonly DEFAULT_OPTIONS: DrawerOptions = { + size: DrawerSize.Medium, + offsetY: '0', + showClose: true, + hideOnClickOutside: false, + divider: true, + disposeWhenHide: true, + }; + constructor(private readonly overlay: Overlay) {} open(options: DrawerOptions) { @@ -46,10 +47,7 @@ export class DrawerService< } updateOptions(options: DrawerOptions): void { - this.options = { - ...(DEFAULT_OPTIONS as DrawerOptions), - ...options, - }; + this.options = merge>(this.DEFAULT_OPTIONS, options); } private createOverlay() { @@ -135,3 +133,18 @@ export class DrawerService< this.dispose(); } } + +function merge(target: T, source: T) { + return Object.keys(source).reduce( + (acc, _key) => { + const key = _key as keyof T; + if (source[key] !== undefined) { + acc[key] = source[key]; + } + return acc; + }, + { + ...target, + }, + ); +} From eb9b4dd7ad6c3903812a72c7ef76c0891021cf68 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 19 Dec 2023 10:41:23 +0800 Subject: [PATCH 2/4] Update stale-dots-speak.md --- .changeset/stale-dots-speak.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/stale-dots-speak.md b/.changeset/stale-dots-speak.md index ced2862e8..9f3fbf40a 100644 --- a/.changeset/stale-dots-speak.md +++ b/.changeset/stale-dots-speak.md @@ -2,4 +2,4 @@ '@alauda/ui': patch --- -- fix: no default config for using component mode +- fix(drawer): no default config for using component mode From 6c6afc51b64d342b57ed91066d35cff4cf8dd680 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 19 Dec 2023 10:41:59 +0800 Subject: [PATCH 3/4] Update .changeset/stale-dots-speak.md --- .changeset/stale-dots-speak.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/stale-dots-speak.md b/.changeset/stale-dots-speak.md index 9f3fbf40a..1379cd0a4 100644 --- a/.changeset/stale-dots-speak.md +++ b/.changeset/stale-dots-speak.md @@ -2,4 +2,4 @@ '@alauda/ui': patch --- -- fix(drawer): no default config for using component mode +- fix(drawer): no default config when using component mode From 2d83f717b6dabe6156158aa0a62642876f22154d Mon Sep 17 00:00:00 2001 From: tianwenjie Date: Tue, 19 Dec 2023 11:55:29 +0800 Subject: [PATCH 4/4] fix: drawer --- .changeset/stale-dots-speak.md | 1 + package.json | 2 +- .../calendar/range-picker-panel/template.html | 2 +- .../internal/internal.component.html | 6 +++--- .../component/internal/internal.component.ts | 7 +++++++ src/drawer/drawer.service.ts | 19 +++++++++---------- src/tabs/tab-group.component.ts | 3 ++- src/time-picker/panel/panel.template.html | 6 +++--- yarn.lock | 8 ++++---- 9 files changed, 31 insertions(+), 23 deletions(-) diff --git a/.changeset/stale-dots-speak.md b/.changeset/stale-dots-speak.md index 1379cd0a4..44a13b6ae 100644 --- a/.changeset/stale-dots-speak.md +++ b/.changeset/stale-dots-speak.md @@ -3,3 +3,4 @@ --- - fix(drawer): no default config when using component mode +- feat(drawer): template context support contentParams as $implicit diff --git a/package.json b/package.json index ebf2d3c97..d5f2574f1 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "zone.js": "^0.13.1" }, "resolutions": { - "prettier": "~2.7.1" + "prettier": "~2.8.8" }, "publishConfig": { "access": "public", diff --git a/src/date-picker/calendar/range-picker-panel/template.html b/src/date-picker/calendar/range-picker-panel/template.html index 4adc11d19..f6b3a4f75 100644 --- a/src/date-picker/calendar/range-picker-panel/template.html +++ b/src/date-picker/calendar/range-picker-panel/template.html @@ -113,6 +113,6 @@ {{ value | date: FOOTER_DATE_FORMAT }}{{ value | date : FOOTER_DATE_FORMAT }} diff --git a/src/drawer/component/internal/internal.component.html b/src/drawer/component/internal/internal.component.html index 008d70265..64dcbf039 100644 --- a/src/drawer/component/internal/internal.component.html +++ b/src/drawer/component/internal/internal.component.html @@ -20,7 +20,7 @@ {{ options.title }} @@ -42,7 +42,7 @@ @@ -54,7 +54,7 @@ {{ options.footer }} diff --git a/src/drawer/component/internal/internal.component.ts b/src/drawer/component/internal/internal.component.ts index f706d4922..8d3e10735 100644 --- a/src/drawer/component/internal/internal.component.ts +++ b/src/drawer/component/internal/internal.component.ts @@ -119,6 +119,13 @@ export class DrawerInternalComponent { ); } + get context() { + return { + $implicit: this.options.contentParams, + ...this.options.contentParams, + }; + } + isTemplateRef = isTemplateRef; constructor(private readonly injector: Injector) {} diff --git a/src/drawer/drawer.service.ts b/src/drawer/drawer.service.ts index caf19aa1b..7fae8ed64 100644 --- a/src/drawer/drawer.service.ts +++ b/src/drawer/drawer.service.ts @@ -8,6 +8,14 @@ import { DrawerRef } from './drawer-ref'; import { DrawerOptions, DrawerSize } from './types'; const DRAWER_OVERLAY_CLASS = 'aui-drawer-overlay'; +const DEFAULT_OPTIONS = { + size: DrawerSize.Medium, + offsetY: '0', + showClose: true, + hideOnClickOutside: false, + divider: true, + disposeWhenHide: true, +} as const satisfies DrawerOptions; @Injectable() export class DrawerService< @@ -23,15 +31,6 @@ export class DrawerService< DrawerInternalComponent >; - private readonly DEFAULT_OPTIONS: DrawerOptions = { - size: DrawerSize.Medium, - offsetY: '0', - showClose: true, - hideOnClickOutside: false, - divider: true, - disposeWhenHide: true, - }; - constructor(private readonly overlay: Overlay) {} open(options: DrawerOptions) { @@ -47,7 +46,7 @@ export class DrawerService< } updateOptions(options: DrawerOptions): void { - this.options = merge>(this.DEFAULT_OPTIONS, options); + this.options = merge>(DEFAULT_OPTIONS, options); } private createOverlay() { diff --git a/src/tabs/tab-group.component.ts b/src/tabs/tab-group.component.ts index 14ce20617..96417bf39 100644 --- a/src/tabs/tab-group.component.ts +++ b/src/tabs/tab-group.component.ts @@ -186,7 +186,8 @@ export class TabGroupComponent /** Event emitted when focus has changed within a tab group. */ @Output() - readonly focusChange: EventEmitter = new EventEmitter(); + readonly focusChange: EventEmitter = + new EventEmitter(); constructor(private readonly _changeDetectorRef: ChangeDetectorRef) {} diff --git a/src/time-picker/panel/panel.template.html b/src/time-picker/panel/panel.template.html index e74ed5cd6..ddf988eb3 100644 --- a/src/time-picker/panel/panel.template.html +++ b/src/time-picker/panel/panel.template.html @@ -20,7 +20,7 @@ }" (click)="selectValue(item, TimePickerControlType.Hour)" > - {{ item | number: '2.0-0' }} + {{ item | number : '2.0-0' }}
@@ -44,7 +44,7 @@ }" (click)="selectValue(item, TimePickerControlType.Minute)" > - {{ item | number: '2.0-0' }} + {{ item | number : '2.0-0' }}
@@ -67,7 +67,7 @@ }" (click)="selectValue(item, TimePickerControlType.Second)" > - {{ item | number: '2.0-0' }} + {{ item | number : '2.0-0' }}
diff --git a/yarn.lock b/yarn.lock index 1a5a67d73..c9f11f013 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15238,10 +15238,10 @@ prettier-plugin-toml@^0.3.1: "@toml-tools/parser" "^0.3.1" prettier "^1.16.0" -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: - version "2.7.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" - integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== +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: + version "2.8.8" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" + integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== pretty-bytes@^5.3.0: version "5.6.0"