Skip to content

Commit

Permalink
chore: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Jan 20, 2024
1 parent 56326c1 commit 712cf0a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions packages/abc/se/se-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ import { SEErrorRefresh, SELayout } from './se.types';
standalone: true
})
export class SETitleComponent implements OnInit {
private readonly parent = inject(SEContainerComponent, { host: true, optional: true });
private readonly parentComp = inject(SEContainerComponent, { host: true, optional: true });
private readonly el: HTMLElement = inject(ElementRef).nativeElement;
private readonly ren = inject(Renderer2);
constructor() {
if (parent == null) {
if (this.parentComp == null) {
throw new Error(`[se-title] must include 'se-container' component`);
}
}

private setClass(): void {
const { el } = this;
const gutter = this.parent!.gutter as number;
const gutter = this.parentComp!.gutter as number;
this.ren.setStyle(el, 'padding-left', `${gutter / 2}px`);
this.ren.setStyle(el, 'padding-right', `${gutter / 2}px`);
}
Expand Down
16 changes: 8 additions & 8 deletions packages/abc/se/se.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let nextUniqueId = 0;
imports: [NgClass, NzStringTemplateOutletDirective, NzTooltipDirective, NzIconDirective, CdkObserveContent]
})
export class SEComponent implements OnChanges, AfterContentInit, AfterViewInit {
private readonly parent = inject(SEContainerComponent, { host: true, optional: true })!;
private readonly parentComp = inject(SEContainerComponent, { host: true, optional: true })!;
private readonly el: HTMLElement = inject(ElementRef).nativeElement;
private readonly rep = inject(ResponsiveService);
private readonly ren = inject(Renderer2);
Expand Down Expand Up @@ -111,26 +111,26 @@ export class SEComponent implements OnChanges, AfterContentInit, AfterViewInit {
// #endregion

get paddingValue(): number {
return (this.parent.gutter as number) / 2;
return (this.parentComp.gutter as number) / 2;
}

get showErr(): boolean {
return this.invalid && !!this._error && !this.compact;
}

get compact(): boolean {
return this.parent.size === 'compact';
return this.parentComp.size === 'compact';
}

private get ngControl(): NgModel | FormControlName | null | undefined {
return this.ngModel || this.formControlName;
}

constructor() {
if (this.parent == null) {
if (this.parentComp == null) {
throw new Error(`[se] must include 'se-container' component`);
}
this.parent.errorNotify
this.parentComp.errorNotify
.pipe(
takeUntilDestroyed(),
filter(w => this.inited && this.ngControl != null && this.ngControl.name === w.name)
Expand All @@ -142,7 +142,7 @@ export class SEComponent implements OnChanges, AfterContentInit, AfterViewInit {
}

private setClass(): this {
const { el, ren, clsMap, col, parent, cdr, line, labelWidth, rep, noColon } = this;
const { el, ren, clsMap, col, parentComp: parent, cdr, line, labelWidth, rep, noColon } = this;
this._noColon = noColon != null ? noColon : parent.noColon;
this._labelWidth = parent.nzLayout === 'horizontal' ? (labelWidth != null ? labelWidth : parent.labelWidth) : null;
clsMap.forEach(cls => ren.removeClass(el, cls));
Expand Down Expand Up @@ -193,7 +193,7 @@ export class SEComponent implements OnChanges, AfterContentInit, AfterViewInit {
return;
}
this.invalid =
!this.onceFlag && invalid && this.parent.ingoreDirty === false && !this.ngControl?.dirty ? false : invalid;
!this.onceFlag && invalid && this.parentComp.ingoreDirty === false && !this.ngControl?.dirty ? false : invalid;
const errors = this.ngControl?.errors;
if (errors != null && Object.keys(errors).length > 0) {
const key = Object.keys(errors)[0] || '';
Expand Down Expand Up @@ -221,7 +221,7 @@ export class SEComponent implements OnChanges, AfterContentInit, AfterViewInit {
}

ngOnChanges(): void {
this.onceFlag = this.parent.firstVisual;
this.onceFlag = this.parentComp.firstVisual;
if (this.inited) {
this.setClass().bindModel();
}
Expand Down
8 changes: 4 additions & 4 deletions packages/abc/sg/sg.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ export class SGComponent implements OnChanges, AfterViewInit {
private readonly el: HTMLElement = inject(ElementRef).nativeElement;
private readonly ren = inject(Renderer2);
private readonly rep = inject(ResponsiveService);
private readonly parent = inject(SGContainerComponent, { host: true, optional: true })!;
private readonly parentComp = inject(SGContainerComponent, { host: true, optional: true })!;

private clsMap: string[] = [];
private inited = false;

@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) }) col: number | null = null;

get paddingValue(): number {
return this.parent.gutter / 2;
return this.parentComp.gutter / 2;
}

constructor() {
if (parent == null) {
if (this.parentComp == null) {
throw new Error(`[sg] must include 'sg-container' component`);
}
}

private setClass(): this {
const { el, ren, clsMap, col, parent } = this;
const { el, ren, clsMap, col, parentComp: parent } = this;
clsMap.forEach(cls => ren.removeClass(el, cls));
clsMap.length = 0;
const parentCol = parent.colInCon || parent.col;
Expand Down
6 changes: 3 additions & 3 deletions packages/abc/sv/sv-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ import { NzStringTemplateOutletDirective } from 'ng-zorro-antd/core/outlet';
})
export class SVTitleComponent implements OnInit {
private readonly el: HTMLElement = inject(ElementRef).nativeElement;
private readonly parent = inject(SVContainerComponent, { host: true, optional: true });
private readonly parentComp = inject(SVContainerComponent, { host: true, optional: true });
private readonly ren = inject(Renderer2);

constructor() {
if (this.parent == null) {
if (this.parentComp == null) {
throw new Error(`[sv-title] must include 'sv-container' component`);
}
}

private setClass(): void {
const gutter = this.parent!.gutter;
const gutter = this.parentComp!.gutter;
const el = this.el;
this.ren.setStyle(el, 'padding-left', `${gutter / 2}px`);
this.ren.setStyle(el, 'padding-right', `${gutter / 2}px`);
Expand Down
14 changes: 7 additions & 7 deletions packages/abc/sv/sv.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const prefixCls = `sv`;
})
export class SVComponent implements AfterViewInit, OnChanges {
private readonly el: HTMLElement = inject(ElementRef).nativeElement;
private readonly parent = inject(SVContainerComponent, { host: true, optional: true });
private readonly parentComp = inject(SVContainerComponent, { host: true, optional: true });
private readonly rep = inject(ResponsiveService);
private readonly ren = inject(Renderer2);

Expand All @@ -66,24 +66,24 @@ export class SVComponent implements AfterViewInit, OnChanges {
// #endregion

get paddingValue(): number | null {
if (this.parent!.bordered) return null;
return this.parent!.gutter / 2;
if (this.parentComp!.bordered) return null;
return this.parentComp!.gutter / 2;
}

get labelWidth(): number | null | undefined {
const { labelWidth, layout } = this.parent!;
const { labelWidth, layout } = this.parentComp!;
return layout === 'horizontal' ? labelWidth : null;
}

constructor() {
if (this.parent == null) {
if (this.parentComp == null) {
throw new Error(`[sv] must include 'sv-container' component`);
}
}

private setClass(): void {
const { ren, col, clsMap, type, rep, noColon } = this;
const parent = this.parent!;
const parent = this.parentComp!;
const el = this.el;
this._noColon = parent.bordered ? true : noColon != null ? noColon : parent.noColon;
clsMap.forEach(cls => ren.removeClass(el, cls));
Expand All @@ -108,7 +108,7 @@ export class SVComponent implements AfterViewInit, OnChanges {
checkContent(): void {
const { conEl } = this;
const def = this.default;
if (!(def != null ? def : this.parent?.default)) {
if (!(def != null ? def : this.parentComp?.default)) {
return;
}
const el = conEl.nativeElement as HTMLElement;
Expand Down

0 comments on commit 712cf0a

Please sign in to comment.