Skip to content

Commit

Permalink
refactor: member ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Sep 1, 2024
1 parent fe0962d commit fe76bd1
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 44 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = {
rules: {
'@taiga-ui/experience/strict-tui-doc-example': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/member-ordering': 'off',
'consistent-return': 'off',
'@typescript-eslint/consistent-return': 'off',
'react/display-name': 'off',
Expand Down
30 changes: 15 additions & 15 deletions projects/core/src/lib/mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,6 @@ export class Maskito extends MaskHistory {
});
}

private get elementState(): ElementState {
const {value, selectionStart, selectionEnd} = this.element;

return {
value,
selection: [selectionStart ?? 0, selectionEnd ?? 0],
};
}

private get maxLength(): number {
const {maxLength} = this.element;

return maxLength === -1 ? Infinity : maxLength;
}

public destroy(): void {
this.eventListener.destroy();
this.teardowns.forEach((teardown) => teardown?.());
Expand All @@ -184,6 +169,21 @@ export class Maskito extends MaskHistory {
}
}

private get elementState(): ElementState {
const {value, selectionStart, selectionEnd} = this.element;

return {
value,
selection: [selectionStart ?? 0, selectionEnd ?? 0],
};
}

private get maxLength(): number {
const {maxLength} = this.element;

return maxLength === -1 ? Infinity : maxLength;
}

private updateSelectionRange([from, to]: SelectionRange): void {
const {element} = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export class TestPipe4 implements PipeTransform {
export class MultiTestComponent {
protected value = '1 year';

protected get parsedValue(): number {
return maskitoParseNumber(this.value);
}

protected readonly pluralize = {
one: ' year',
few: ' years',
many: ' years',
other: ' years',
};

protected get parsedValue(): number {
return maskitoParseNumber(this.value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,14 @@ export default class DateRangeMaskDocComponent implements GeneratorOptions {

protected minStr: string = this.minMaxOptions[0];
protected maxStr: string = this.minMaxOptions[1];

public mode: MaskitoDateMode = this.modeOptions[0];
public min = new Date(this.minStr);
public max = new Date(this.maxStr);
public minLength: Partial<MaskitoDateSegments<number>> = {};
public maxLength: Partial<MaskitoDateSegments<number>> = {};
public dateSeparator = '.';
public rangeSeparator = ' – ';

protected maskitoOptions: MaskitoOptions = maskitoDateRangeOptionsGenerator(this);
public maskitoOptions: MaskitoOptions = maskitoDateRangeOptionsGenerator(this);

@tuiPure
protected getPlaceholder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,14 @@ export default class DateTimeMaskDocComponent implements GeneratorOptions {

protected minStr: string = this.minMaxOptions[0];
protected maxStr: string = this.minMaxOptions[1];

public dateMode: MaskitoDateMode = this.dateModeOptions[0];
public timeMode: MaskitoTimeMode = this.timeModeOptions[0];
public dateTimeSeparator = ', ';
public dateSeparator = '.';
public min = new Date(this.minStr);
public max = new Date(this.maxStr);
public timeStep = 0;

protected maskitoOptions: MaskitoOptions = maskitoDateTimeOptionsGenerator(this);
public maskitoOptions: MaskitoOptions = maskitoDateTimeOptionsGenerator(this);

@tuiPure
protected getPlaceholder(
Expand Down
5 changes: 1 addition & 4 deletions projects/demo/src/pages/kit/date/date-mask-doc.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,11 @@ export default class DateMaskDocComponent implements GeneratorOptions {

protected minStr: string = this.minMaxOptions[0];
protected maxStr: string = this.minMaxOptions[1];

public mode: MaskitoDateMode = this.modeOptions[0];
public separator: string = this.separatorOptions[0];

public min = new Date(this.minStr);
public max = new Date(this.maxStr);

protected maskitoOptions: MaskitoOptions = maskitoDateOptionsGenerator(this);
public maskitoOptions: MaskitoOptions = maskitoDateOptionsGenerator(this);

protected updateDate(): void {
this.min = new Date(this.minStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ export default class NumberMaskDocComponent implements GeneratorOptions {
public prefix = '';
public postfix = '';
public minusSign = CHAR_MINUS;

protected maskitoOptions: MaskitoOptions = this.calculateMask(this);
public maskitoOptions: MaskitoOptions = this.calculateMask(this);

protected updateOptions(): void {
this.maskitoOptions = this.calculateMask(this);
Expand Down
3 changes: 1 addition & 2 deletions projects/demo/src/pages/kit/time/time-mask-doc.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ export default class TimeMaskDocComponent implements GeneratorOptions {
this.timeSegmentMaxValuesOptions[0];

public step = 0;

protected maskitoOptions: MaskitoOptions = maskitoTimeOptionsGenerator(this);
public maskitoOptions: MaskitoOptions = maskitoTimeOptionsGenerator(this);

protected updateOptions(): void {
this.maskitoOptions = maskitoTimeOptionsGenerator(this);
Expand Down
15 changes: 5 additions & 10 deletions projects/demo/src/pages/phone/phone-doc.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,14 @@ export default class PhoneDocComponent implements GeneratorOptions {
),
};

public strict = true;
public countryIsoCode: CountryCode = 'RU';
public separator = '-';

protected metadataVariants = Object.keys(metadataSets) as readonly MetadataName[];

protected selectedMetadata: MetadataName = this.metadataVariants[0]!;

protected countryCodeVariants = getCountries(this.metadata);

protected selectedMetadata: MetadataName = this.metadataVariants[0]!;
protected separatorVariants = ['-', ' '];

protected maskitoOptions = this.computeOptions();
public strict = true;
public countryIsoCode: CountryCode = 'RU';
public separator = '-';
public maskitoOptions = this.computeOptions();

public get metadata(): MetadataJson {
return metadataSets[this.selectedMetadata];
Expand Down

0 comments on commit fe76bd1

Please sign in to comment.