diff --git a/.eslintrc.js b/.eslintrc.js index 0d882a6a9..315f4669a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,7 +23,6 @@ module.exports = { '@taiga-ui/experience/strict-tui-doc-example': 'off', '@taiga-ui/experience/prefer-inject-decorator': 'off', '@typescript-eslint/consistent-type-assertions': 'off', - 'no-restricted-syntax': 'off', // TODO }, }, ], diff --git a/projects/core/src/lib/utils/dom/hotkey.ts b/projects/core/src/lib/utils/dom/hotkey.ts index 0e0608d22..4c64cd70e 100644 --- a/projects/core/src/lib/utils/dom/hotkey.ts +++ b/projects/core/src/lib/utils/dom/hotkey.ts @@ -1,22 +1,19 @@ -export const enum HotkeyModifier { - CTRL = 1 << 0, - ALT = 1 << 1, - SHIFT = 1 << 2, - META = 1 << 3, -} +export const HotkeyModifier = { + CTRL: 1 << 0, + ALT: 1 << 1, + SHIFT: 1 << 2, + META: 1 << 3, +} as const; // TODO add variants that can be processed correctly -export const enum HotkeyCode { - Y = 89, - Z = 90, -} +export const HotkeyCode = { + Y: 89, + Z: 90, +} as const; /** * Checks if the passed keyboard event match the required hotkey. * - * We intentionally use legacy {@link KeyboardEvent#keyCode `keyCode`} property. It is more - * "keyboard-layout"-independent than {@link KeyboardEvent#key `key`} or {@link KeyboardEvent#code `code`} properties. - * * @example * input.addEventListener('keydown', (event) => { * if (isHotkey(event, HotkeyModifier.CTRL | HotkeyModifier.SHIFT, HotkeyCode.Z)) { @@ -24,21 +21,25 @@ export const enum HotkeyCode { * } * }) * - * @see {@link https://github.com/taiga-family/maskito/issues/315 `KeyboardEvent#code` issue} - * * @return will return `true` only if the {@link HotkeyCode} matches and only the necessary * {@link HotkeyModifier modifiers} have been pressed */ export function isHotkey( event: KeyboardEvent, - modifiers: HotkeyModifier, - hotkeyCode: HotkeyCode, + modifiers: (typeof HotkeyModifier)[keyof typeof HotkeyModifier], + hotkeyCode: (typeof HotkeyCode)[keyof typeof HotkeyCode], ): boolean { return ( event.ctrlKey === !!(modifiers & HotkeyModifier.CTRL) && event.altKey === !!(modifiers & HotkeyModifier.ALT) && event.shiftKey === !!(modifiers & HotkeyModifier.SHIFT) && event.metaKey === !!(modifiers & HotkeyModifier.META) && + /** + * We intentionally use legacy {@link KeyboardEvent#keyCode `keyCode`} property. It is more + * "keyboard-layout"-independent than {@link KeyboardEvent#key `key`} or {@link KeyboardEvent#code `code`} properties. + * @see {@link https://github.com/taiga-family/maskito/issues/315 `KeyboardEvent#code` issue} + */ + // eslint-disable-next-line sonar/deprecation event.keyCode === hotkeyCode ); } diff --git a/projects/demo/src/app/constants/demo-path.ts b/projects/demo/src/app/constants/demo-path.ts index a70f59aef..5f0bd6aa2 100644 --- a/projects/demo/src/app/constants/demo-path.ts +++ b/projects/demo/src/app/constants/demo-path.ts @@ -1,30 +1,30 @@ -export const enum DemoPath { - WhatIsMaskito = 'getting-started/what-is-maskito', - MaskitoLibraries = 'getting-started/maskito-libraries', - CoreConceptsOverview = 'core-concepts/overview', - MaskExpression = 'core-concepts/mask-expression', - ElementState = 'core-concepts/element-state', - Processors = 'core-concepts/processors', - Plugins = 'core-concepts/plugins', - OverwriteMode = 'core-concepts/overwrite-mode', - Transformer = 'core-concepts/transformer', - Angular = 'frameworks/angular', - React = 'frameworks/react', - Vue = 'frameworks/vue', - Number = 'kit/number', - Time = 'kit/time', - Date = 'kit/date', - DateRange = 'kit/date-range', - DateTime = 'kit/date-time', - PhonePackage = 'addons/phone', - Card = 'recipes/card', - Phone = 'recipes/phone', - Textarea = 'recipes/textarea', - Prefix = 'recipes/prefix', - Postfix = 'recipes/postfix', - Placeholder = 'recipes/placeholder', - BrowserSupport = 'browser-support', - Changelog = 'changelog', - Stackblitz = 'stackblitz', - Cypress = 'cypress', -} +export const DemoPath = { + WhatIsMaskito: 'getting-started/what-is-maskito', + MaskitoLibraries: 'getting-started/maskito-libraries', + CoreConceptsOverview: 'core-concepts/overview', + MaskExpression: 'core-concepts/mask-expression', + ElementState: 'core-concepts/element-state', + Processors: 'core-concepts/processors', + Plugins: 'core-concepts/plugins', + OverwriteMode: 'core-concepts/overwrite-mode', + Transformer: 'core-concepts/transformer', + Angular: 'frameworks/angular', + React: 'frameworks/react', + Vue: 'frameworks/vue', + Number: 'kit/number', + Time: 'kit/time', + Date: 'kit/date', + DateRange: 'kit/date-range', + DateTime: 'kit/date-time', + PhonePackage: 'addons/phone', + Card: 'recipes/card', + Phone: 'recipes/phone', + Textarea: 'recipes/textarea', + Prefix: 'recipes/prefix', + Postfix: 'recipes/postfix', + Placeholder: 'recipes/placeholder', + BrowserSupport: 'browser-support', + Changelog: 'changelog', + Stackblitz: 'stackblitz', + Cypress: 'cypress', +} as const; diff --git a/projects/demo/src/app/constants/doc-example-primary-tab.ts b/projects/demo/src/app/constants/doc-example-primary-tab.ts index 7f4b11dec..e872ea184 100644 --- a/projects/demo/src/app/constants/doc-example-primary-tab.ts +++ b/projects/demo/src/app/constants/doc-example-primary-tab.ts @@ -1,7 +1,7 @@ -export enum DocExamplePrimaryTab { - MaskitoOptions = 'mask', - JavaScript = 'JavaScript', - Angular = 'Angular', - React = 'React', - Vue = 'Vue', -} +export const DocExamplePrimaryTab = { + MaskitoOptions: 'mask', + JavaScript: 'JavaScript', + Angular: 'Angular', + React: 'React', + Vue: 'Vue', +} as const; diff --git a/projects/demo/src/pages/frameworks/react/react-doc.component.ts b/projects/demo/src/pages/frameworks/react/react-doc.component.ts index 216a57cee..80b47e71f 100644 --- a/projects/demo/src/pages/frameworks/react/react-doc.component.ts +++ b/projects/demo/src/pages/frameworks/react/react-doc.component.ts @@ -1,6 +1,6 @@ import {ChangeDetectionStrategy, Component} from '@angular/core'; import {DemoPath} from '@demo/constants'; -import {RawLoaderContent} from '@taiga-ui/addon-doc'; +import {TuiRawLoaderContent} from '@taiga-ui/addon-doc'; const DROP_TS_NO_CHECK_REG = /\/\/\s@ts-nocheck[^\n]+\n/; @@ -15,7 +15,7 @@ export class ReactDocPageComponent { './examples/1-use-maskito-basic-usage/use-maskito-basic-usage.tsx?raw' ); - readonly elementPredicateExample: Record = { + readonly elementPredicateExample: Record = { 'index.tsx': import('./examples/2-element-predicate/index.tsx?raw').then(m => ({ // See: https://github.com/vuejs/core/issues/1033#issuecomment-1340309622 // TODO: Check if it still required after upgrade Vue to 3.4 (https://github.com/vuejs/core/pull/7958)