From fe76bd1db5c8dc6150e30f16d4b6cee30b4b2d0a Mon Sep 17 00:00:00 2001 From: splincode Date: Sat, 31 Aug 2024 23:36:39 +0300 Subject: [PATCH] refactor: member ordering --- .eslintrc.js | 1 - projects/core/src/lib/mask.ts | 30 +++++++++---------- .../multi-test.component.ts | 8 ++--- .../date-range-mask-doc.component.ts | 4 +-- .../date-time/date-time-mask-doc.component.ts | 4 +-- .../pages/kit/date/date-mask-doc.component.ts | 5 +--- .../kit/number/number-mask-doc.component.ts | 3 +- .../pages/kit/time/time-mask-doc.component.ts | 3 +- .../src/pages/phone/phone-doc.component.ts | 15 ++++------ 9 files changed, 29 insertions(+), 44 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 0f10df5ea..6d73d1f7b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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', diff --git a/projects/core/src/lib/mask.ts b/projects/core/src/lib/mask.ts index 57bc53e15..a133ccc5d 100644 --- a/projects/core/src/lib/mask.ts +++ b/projects/core/src/lib/mask.ts @@ -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?.()); @@ -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; diff --git a/projects/demo-integrations/src/tests/component-testing/number/runtime-postfix-changes/multi-test.component.ts b/projects/demo-integrations/src/tests/component-testing/number/runtime-postfix-changes/multi-test.component.ts index b49d8d20f..3f95abfd0 100644 --- a/projects/demo-integrations/src/tests/component-testing/number/runtime-postfix-changes/multi-test.component.ts +++ b/projects/demo-integrations/src/tests/component-testing/number/runtime-postfix-changes/multi-test.component.ts @@ -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); + } } diff --git a/projects/demo/src/pages/kit/date-range/date-range-mask-doc.component.ts b/projects/demo/src/pages/kit/date-range/date-range-mask-doc.component.ts index 7d3119bdd..fcb74d1ed 100644 --- a/projects/demo/src/pages/kit/date-range/date-range-mask-doc.component.ts +++ b/projects/demo/src/pages/kit/date-range/date-range-mask-doc.component.ts @@ -93,7 +93,6 @@ 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); @@ -101,8 +100,7 @@ export default class DateRangeMaskDocComponent implements GeneratorOptions { public maxLength: Partial> = {}; public dateSeparator = '.'; public rangeSeparator = ' – '; - - protected maskitoOptions: MaskitoOptions = maskitoDateRangeOptionsGenerator(this); + public maskitoOptions: MaskitoOptions = maskitoDateRangeOptionsGenerator(this); @tuiPure protected getPlaceholder( diff --git a/projects/demo/src/pages/kit/date-time/date-time-mask-doc.component.ts b/projects/demo/src/pages/kit/date-time/date-time-mask-doc.component.ts index 4c3596cd4..9c7f93906 100644 --- a/projects/demo/src/pages/kit/date-time/date-time-mask-doc.component.ts +++ b/projects/demo/src/pages/kit/date-time/date-time-mask-doc.component.ts @@ -85,7 +85,6 @@ 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 = ', '; @@ -93,8 +92,7 @@ export default class DateTimeMaskDocComponent implements GeneratorOptions { 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( diff --git a/projects/demo/src/pages/kit/date/date-mask-doc.component.ts b/projects/demo/src/pages/kit/date/date-mask-doc.component.ts index ef532dadc..9b1510c7c 100644 --- a/projects/demo/src/pages/kit/date/date-mask-doc.component.ts +++ b/projects/demo/src/pages/kit/date/date-mask-doc.component.ts @@ -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); diff --git a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts index 26e8dc5c5..ad906ecd6 100644 --- a/projects/demo/src/pages/kit/number/number-mask-doc.component.ts +++ b/projects/demo/src/pages/kit/number/number-mask-doc.component.ts @@ -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); diff --git a/projects/demo/src/pages/kit/time/time-mask-doc.component.ts b/projects/demo/src/pages/kit/time/time-mask-doc.component.ts index 491a47934..dd6b8e7ff 100644 --- a/projects/demo/src/pages/kit/time/time-mask-doc.component.ts +++ b/projects/demo/src/pages/kit/time/time-mask-doc.component.ts @@ -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); diff --git a/projects/demo/src/pages/phone/phone-doc.component.ts b/projects/demo/src/pages/phone/phone-doc.component.ts index 2189edd5a..e3b9c0339 100644 --- a/projects/demo/src/pages/phone/phone-doc.component.ts +++ b/projects/demo/src/pages/phone/phone-doc.component.ts @@ -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];