Skip to content

Commit

Permalink
refactor: fix ordering (#6930)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Mar 1, 2024
1 parent 8ce28bf commit e838776
Show file tree
Hide file tree
Showing 210 changed files with 3,451 additions and 3,427 deletions.
2,018 changes: 1,021 additions & 997 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@
"plugin:@taiga-ui/experience/all",
"plugin:@taiga-ui/experience/taiga-naming"
],
"rules": {
"@typescript-eslint/member-ordering": "off"
},
"root": true
},
"stylelint": {
Expand Down Expand Up @@ -119,7 +116,7 @@
"@taiga-ui/browserslist-config": "0.5.0",
"@taiga-ui/commitlint-config": "0.5.6",
"@taiga-ui/cspell-config": "0.34.0",
"@taiga-ui/eslint-plugin-experience": "0.60.0",
"@taiga-ui/eslint-plugin-experience": "0.62.0",
"@taiga-ui/prettier-config": "0.8.4",
"@taiga-ui/stylelint-config": "0.18.0",
"@taiga-ui/tsconfig": "0.16.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ export class TuiArcChartComponent {
private readonly sanitizer = inject(DomSanitizer);
private readonly arcs$ = new ReplaySubject<QueryList<ElementRef<SVGElement>>>(1);

@ViewChildren('arc')
protected set arcs(arcs: QueryList<ElementRef<SVGElement>>) {
this.arcs$.next(arcs);
}

@Input()
public value: readonly number[] = [];

Expand Down Expand Up @@ -115,6 +110,11 @@ export class TuiArcChartComponent {
});
}

@ViewChildren('arc')
protected set arcs(arcs: QueryList<ElementRef<SVGElement>>) {
this.arcs$.next(arcs);
}

@HostBinding('style.width.rem')
@HostBinding('style.height.rem')
protected get width(): number {
Expand Down
10 changes: 5 additions & 5 deletions projects/addon-charts/components/axes/axes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ export class TuiAxesComponent {
@Input()
public verticalLinesHandler: TuiLineHandler = TUI_ALWAYS_DASHED;

@HostBinding('class._centered')
protected get centeredXLabels(): boolean {
return this.axisY === 'none';
}

protected readonly mode$ = inject(TUI_MODE);

public get hasXLabels(): boolean {
Expand All @@ -85,4 +80,9 @@ export class TuiAxesComponent {
public fallback(label: string | null): string {
return label || CHAR_NO_BREAK_SPACE;
}

@HostBinding('class._centered')
protected get centeredXLabels(): boolean {
return this.axisY === 'none';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ export class TuiBarChartComponent {
private readonly hintOptions = inject(TuiHintOptionsDirective, {optional: true});
private readonly autoIdString = inject(TuiIdService).generate();

@ViewChildren(TuiHintHoverDirective)
protected readonly drivers: QueryList<Observable<boolean>> = EMPTY_QUERY;

@Input()
public value: ReadonlyArray<readonly number[]> = [];

Expand All @@ -50,9 +47,8 @@ export class TuiBarChartComponent {
@Input()
public collapsed = false;

protected get hintContent(): PolymorpheusContent<TuiContext<number>> {
return this.hintOptions?.content || '';
}
@ViewChildren(TuiHintHoverDirective)
protected readonly drivers: QueryList<Observable<boolean>> = EMPTY_QUERY;

public get transposed(): ReadonlyArray<readonly number[]> {
return this.transpose(this.value);
Expand All @@ -68,6 +64,10 @@ export class TuiBarChartComponent {
> = (set, collapsed, max) =>
(100 * (collapsed ? tuiSum(...set) : Math.max(...set))) / max;

protected get hintContent(): PolymorpheusContent<TuiContext<number>> {
return this.hintOptions?.content || '';
}

protected getHintId(index: number): string {
return `${this.autoIdString}_${index}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ export class TuiLineChartComponent {
@ViewChildren(TuiHintHoverDirective)
public readonly drivers: QueryList<Observable<boolean>> = EMPTY_QUERY;

@Input('value')
public set valueSetter(value: readonly TuiPoint[]) {
this.value = value.filter(item => !item.some(Number.isNaN));
}

@Input()
public x = 0;

Expand Down Expand Up @@ -86,6 +81,15 @@ export class TuiLineChartComponent {

protected readonly hintOptions = inject(TuiHintOptionsDirective, {optional: true});

@Input('value')
public set valueSetter(value: readonly TuiPoint[]) {
this.value = value.filter(item => !item.some(Number.isNaN));
}

public onHovered(index: number): void {
this.hover$.next(index);
}

@tuiPure
protected get hovered$(): Observable<number> {
return this.hover$.pipe(distinctUntilChanged(), tuiZoneOptimized(this.zone));
Expand Down Expand Up @@ -189,10 +193,6 @@ export class TuiLineChartComponent {
}
}

public onHovered(index: number): void {
this.hover$.next(index);
}

private get isSinglePoint(): boolean {
return this.value.length === 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,6 @@ export class TuiLineDaysChartComponent implements AfterViewInit {
@ViewChildren(TuiLineChartComponent)
public readonly charts: QueryList<TuiLineChartComponent> = EMPTY_QUERY;

@Input('value')
public set valueSetter(value: ReadonlyArray<[TuiDay, number]>) {
if (!value.length) {
this.value = [];

return;
}

const start = value[0][0];
const mutable = [...value];
const length = TuiDay.lengthBetween(start, value[value.length - 1][0]) + 1;

this.value = Array.from({length}, (_, day) => {
const currentDay = start.append({day});
const shifted = currentDay.daySame(mutable[0][0]) ? mutable.shift() : null;
const currentValue = shifted ? shifted[1] : NaN;

return [currentDay, currentValue] as [TuiDay, number];
});
}

@Input()
public y = 0;

Expand All @@ -110,26 +89,25 @@ export class TuiLineDaysChartComponent implements AfterViewInit {

public value: ReadonlyArray<[TuiDay, number]> = [];

protected get months(): ReadonlyArray<readonly TuiPoint[]> {
return this.value.length ? this.breakMonths(this.value) : EMPTY_ARRAY;
}
@Input('value')
public set valueSetter(value: ReadonlyArray<[TuiDay, number]>) {
if (!value.length) {
this.value = [];

protected get firstWidth(): number {
return this.months.length * this.value[0][0].daysCount;
}
return;
}

protected get hint():
| PolymorpheusContent<TuiContext<[TuiDay, number]>>
| PolymorpheusContent<TuiContext<readonly TuiPoint[]>> {
return this.hintDirective?.hint ?? this.hintContent;
}
const start = value[0][0];
const mutable = [...value];
const length = TuiDay.lengthBetween(start, value[value.length - 1][0]) + 1;

@tuiPure
protected getHintContext(
x: number,
value: ReadonlyArray<[TuiDay, number]>,
): [TuiDay, number] {
return value[x - value[0][0].day + 1];
this.value = Array.from({length}, (_, day) => {
const currentDay = start.append({day});
const shifted = currentDay.daySame(mutable[0][0]) ? mutable.shift() : null;
const currentValue = shifted ? shifted[1] : NaN;

return [currentDay, currentValue] as [TuiDay, number];
});
}

public ngAfterViewInit(): void {
Expand All @@ -144,17 +122,6 @@ export class TuiLineDaysChartComponent implements AfterViewInit {
});
}

protected readonly daysStringify: TuiStringHandler<number> = index =>
this.xStringify ? this.xStringify(this.getDay(index)) : '';

protected getX(index: number): number {
const current = this.getDay(index);
const months = TuiMonth.lengthBetween(this.value[0][0], current);
const offset = months * current.daysCount;

return index - offset;
}

public onHovered(day: TuiDay | number): void {
if (tuiIsNumber(day)) {
this.charts.forEach(chart => chart.onHovered(NaN));
Expand All @@ -175,6 +142,39 @@ export class TuiLineDaysChartComponent implements AfterViewInit {
});
}

protected get months(): ReadonlyArray<readonly TuiPoint[]> {
return this.value.length ? this.breakMonths(this.value) : EMPTY_ARRAY;
}

protected get firstWidth(): number {
return this.months.length * this.value[0][0].daysCount;
}

protected get hint():
| PolymorpheusContent<TuiContext<[TuiDay, number]>>
| PolymorpheusContent<TuiContext<readonly TuiPoint[]>> {
return this.hintDirective?.hint ?? this.hintContent;
}

@tuiPure
protected getHintContext(
x: number,
value: ReadonlyArray<[TuiDay, number]>,
): [TuiDay, number] {
return value[x - value[0][0].day + 1];
}

protected readonly daysStringify: TuiStringHandler<number> = index =>
this.xStringify ? this.xStringify(this.getDay(index)) : '';

protected getX(index: number): number {
const current = this.getDay(index);
const months = TuiMonth.lengthBetween(this.value[0][0], current);
const offset = months * current.daysCount;

return index - offset;
}

protected raise(index: number, {value}: TuiLineChartComponent): void {
const x = value[index][0];
const month = this.getDay(x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import {BehaviorSubject, map, pairwise, switchMap, takeUntil, takeWhile} from 'r
export class TuiPieChartDirective {
private readonly sector$ = new BehaviorSubject<readonly [number, number]>([0, 0]);

@Input()
public set tuiPieChart(sector: readonly [number, number]) {
this.sector$.next(sector);
}

constructor() {
const el: SVGPathElement = inject(ElementRef).nativeElement;
const performance = inject(PERFORMANCE);
Expand Down Expand Up @@ -51,4 +46,9 @@ export class TuiPieChartDirective {
el.setAttribute('d', tuiDescribeSector(start, end)),
);
}

@Input()
public set tuiPieChart(sector: readonly [number, number]) {
this.sector$.next(sector);
}
}
Loading

0 comments on commit e838776

Please sign in to comment.