diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27618e9f21c6..44a488fd5052 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,14 @@ jobs: run: npm ci # End of setup - run: | - npm run build:cdk - npm run build:core - npm run build:kit + npm run build cdk + npm run build core + npm run build kit + npm run build addon-charts + npm run build addon-commerce + npm run build addon-mobile + npm run build addon-doc + npm run build addon-editor + npm run build addon-table + npm run build addon-tablebars + diff --git a/package.json b/package.json index 0f69c725cf03..f819a9a81590 100644 --- a/package.json +++ b/package.json @@ -19,21 +19,12 @@ "clear": "prettier --write '**/projects/**/*.{js,ts,html,md,less,json}' && tslint '**/projects/**/*.ts' --fix", "typecheck": "tsc --noEmit --skipLibCheck", "*** build **": "use package=name command to build a package", - "build": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng run $package:build --configuration=production", - "build:cdk": "package=cdk npm run build", - "build:core": "package=core npm run build", - "build:kit": "package=kit npm run build", - "build:addon-charts": "package=addon-charts npm run build", - "build:addon-commerce": "package=addon-commerce npm run build", - "build:addon-doc": "package=addon-doc npm run build", - "build:addon-mobile": "package=addon-mobile npm run build", - "build:addon-table": "package=addon-table npm run build", - "build:addon-tablebars": "package=addon-tablebars npm run build", + "build": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --configuration=production", "build:tools": "ng build cypress-testing && ng build testing", "*** Icons ***": "", "compile:icons": "ts-node --project ./tsconfig.compiler.json scripts/compileIcons.ts", "prebuild:icons": "npm run compile:icons projects/icons", - "build:icons": "ng run icons:build", + "build:icons": "ng run icons:build --configuration=production", "postbuild:icons": "node projects/icons/scripts/copy-icons.js", "*** Release ***": "", "release": "standard-version", diff --git a/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts b/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts index 7257fd72ef8f..9b5f225ae42c 100644 --- a/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts +++ b/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts @@ -24,6 +24,10 @@ import { tuiIconVisa, } from '@taiga-ui/addon-commerce/icons'; import {TuiCard} from '@taiga-ui/addon-commerce/interfaces'; +import { + TUI_CARD_EXPIRY_TEXTS, + TUI_CARD_NUMBER_TEXTS, +} from '@taiga-ui/addon-commerce/tokens'; import { getPaymentSystem, isCardLengthValid, @@ -161,6 +165,8 @@ export class TuiInputCardGroupedComponent @Optional() @Inject(TuiModeDirective) private readonly modeDirective: TuiModeDirective | null, + @Inject(TUI_CARD_NUMBER_TEXTS) readonly cardNumberTexts: [string, string], + @Inject(TUI_CARD_EXPIRY_TEXTS) readonly cardExpiryTexts: [string, string], ) { super(control, changeDetectorRef); diff --git a/projects/addon-commerce/components/input-card-grouped/input-card-grouped.template.html b/projects/addon-commerce/components/input-card-grouped/input-card-grouped.template.html index f55710d658ff..af4f7a3d7a6b 100644 --- a/projects/addon-commerce/components/input-card-grouped/input-card-grouped.template.html +++ b/projects/addon-commerce/components/input-card-grouped/input-card-grouped.template.html @@ -24,8 +24,7 @@ class="placeholder" [class.placeholder_raised]="placeholderRaised" > - - {{isMobile ? 'Номер' : 'Номер карты'}} + {{isMobile ? cardNumberTexts[0] : cardNumberTexts[1]}} ( + `nubmer and card number i18n`, + { + factory: () => ['Number', 'Card number'], + }, +); + +export const TUI_CARD_EXPIRY_TEXTS = new InjectionToken<[string, string]>( + `Expiry and card expiry i18n`, + { + factory: () => ['Expiry', 'Card expiry'], + }, +); diff --git a/projects/addon-commerce/tokens/index.ts b/projects/addon-commerce/tokens/index.ts new file mode 100644 index 000000000000..e82230f1bf13 --- /dev/null +++ b/projects/addon-commerce/tokens/index.ts @@ -0,0 +1 @@ +export * from './i18n'; diff --git a/projects/addon-commerce/tokens/package.json b/projects/addon-commerce/tokens/package.json new file mode 100644 index 000000000000..289d2d373a50 --- /dev/null +++ b/projects/addon-commerce/tokens/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "index.ts" + } + } +} diff --git a/projects/addon-commerce/validators/luhn.validator.ts b/projects/addon-commerce/validators/luhn.validator.ts index 5d09be2d84bc..b6ae70f1c4f0 100644 --- a/projects/addon-commerce/validators/luhn.validator.ts +++ b/projects/addon-commerce/validators/luhn.validator.ts @@ -4,12 +4,7 @@ import {TuiValidationError} from '@taiga-ui/cdk'; import {TUI_NON_DIGITS_REGEXP} from '@taiga-ui/core'; import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; -// TODO: i18n -const error = 'Неверный формат карты'; - -export function tuiCreateLuhnValidator( - message: PolymorpheusContent = error, -): ValidatorFn { +export function tuiCreateLuhnValidator(message: PolymorpheusContent): ValidatorFn { return ({value}: AbstractControl) => { const cardNumber = String(value).replace(TUI_NON_DIGITS_REGEXP, ''); diff --git a/projects/addon-commerce/validators/test/luhn.validator.spec.ts b/projects/addon-commerce/validators/test/luhn.validator.spec.ts index 1dea45db506c..0f02f5de54df 100644 --- a/projects/addon-commerce/validators/test/luhn.validator.spec.ts +++ b/projects/addon-commerce/validators/test/luhn.validator.spec.ts @@ -3,9 +3,8 @@ import {TuiValidationError} from '@taiga-ui/cdk'; import {tuiCreateLuhnValidator} from '../luhn.validator'; describe('tuiCreateLuhnValidator', () => { - const control = new FormControl('', tuiCreateLuhnValidator()); - const controlCustom = new FormControl('', tuiCreateLuhnValidator('ошибка')); - const error = {luhn: new TuiValidationError('Неверный формат карты')}; + const control = new FormControl('', tuiCreateLuhnValidator('error')); + const error = {luhn: new TuiValidationError('error')}; it('Валидный номер карты валиден, проверка 1', () => { control.setValue('4111 1111 1111 1111'); @@ -48,11 +47,4 @@ describe('tuiCreateLuhnValidator', () => { expect(control.errors).toEqual(error); }); - - it('Кастомный текст ошибки', () => { - controlCustom.setValue('2345 7823 4095 8723'); - controlCustom.updateValueAndValidity(); - - expect(controlCustom.errors).toEqual({luhn: new TuiValidationError('ошибка')}); - }); }); diff --git a/projects/addon-editor/components/color-selector/color-selector.component.ts b/projects/addon-editor/components/color-selector/color-selector.component.ts index b9deb12dbdf0..a22cff71fd68 100644 --- a/projects/addon-editor/components/color-selector/color-selector.component.ts +++ b/projects/addon-editor/components/color-selector/color-selector.component.ts @@ -7,6 +7,7 @@ import { Output, } from '@angular/core'; import {DomSanitizer, SafeStyle} from '@angular/platform-browser'; +import {TUI_EDITOR_COLOR_SELECTOR_MODE_NAMES} from '@taiga-ui/addon-editor/tokens'; import {TuiGradientDirection} from '@taiga-ui/addon-editor/types'; import {getGradientData, parseColor, parseGradient} from '@taiga-ui/addon-editor/utils'; import {tuiDefaultProp, tuiPure, tuiRequiredSetter} from '@taiga-ui/cdk'; @@ -29,6 +30,7 @@ const ICONS: Record = { 'to top': 'tuiIconArrowLongUp', }; +// @dynamic @Component({ selector: 'tui-color-selector', templateUrl: './color-selector.template.html', @@ -52,9 +54,6 @@ export class TuiColorSelectorComponent { color: [number, number, number, number] = [0, 0, 0, 1]; - // TODO: i18n - readonly modes = ['Сплошной цвет', 'Градиент']; - currentMode = this.modes[0]; readonly buttons: ReadonlyArray = [ @@ -74,7 +73,10 @@ export class TuiColorSelectorComponent { private direction: TuiGradientDirection = 'to bottom'; - constructor(@Inject(DomSanitizer) private readonly sanitizer: DomSanitizer) {} + constructor( + @Inject(DomSanitizer) private readonly sanitizer: DomSanitizer, + @Inject(TUI_EDITOR_COLOR_SELECTOR_MODE_NAMES) readonly modes: [string, string], + ) {} get palette(): Map { return this.filterPalette(this.colors, this.isGradient); diff --git a/projects/addon-editor/components/toolbar/toolbar.component.ts b/projects/addon-editor/components/toolbar/toolbar.component.ts index 804b27762b36..79498c10ea01 100644 --- a/projects/addon-editor/components/toolbar/toolbar.component.ts +++ b/projects/addon-editor/components/toolbar/toolbar.component.ts @@ -18,7 +18,11 @@ import {USER_AGENT} from '@ng-web-apis/common'; import {defaultEditorTools} from '@taiga-ui/addon-editor/constants'; import {TuiEditorTool} from '@taiga-ui/addon-editor/enums'; import {TuiEditorFontOption} from '@taiga-ui/addon-editor/interfaces'; -import {TUI_IMAGE_LOADER} from '@taiga-ui/addon-editor/tokens'; +import { + EditorToolbarTexts, + TUI_EDITOR_TOOLBAR_TEXTS, + TUI_IMAGE_LOADER, +} from '@taiga-ui/addon-editor/tokens'; import {isSelectionIn, tuiInsertHtml} from '@taiga-ui/addon-editor/utils'; import { EMPTY_QUERY, @@ -36,10 +40,9 @@ import { TuiButtonComponent, TuiHostedDropdownComponent, } from '@taiga-ui/core'; -import {LEFT_ALIGNED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/kit/providers'; +import {LEFT_ALIGNED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/kit'; import {merge, Observable} from 'rxjs'; import {take, takeUntil} from 'rxjs/operators'; -import {TUI_CANCEL_WORD} from '../../../kit'; const DEFAULT_FONT = 'haas, helvetica, arial, sans-serif'; const MONOSPACE_FONT = 'Courier'; @@ -145,7 +148,8 @@ export class TuiToolbarComponent { @Inject(TUI_IMAGE_LOADER) private readonly imageLoader: TuiHandler>, @Inject(USER_AGENT) private readonly userAgent: string, - @Inject(TUI_CANCEL_WORD) readonly cancelWord: string, + @Inject(TUI_EDITOR_TOOLBAR_TEXTS) + readonly texts: Record, ) { this.documentRef = shadowRootRef || documentRef; diff --git a/projects/addon-editor/components/toolbar/toolbar.template.html b/projects/addon-editor/components/toolbar/toolbar.template.html index c96f8e0b4a42..3f817cd3cae1 100644 --- a/projects/addon-editor/components/toolbar/toolbar.template.html +++ b/projects/addon-editor/components/toolbar/toolbar.template.html @@ -12,7 +12,7 @@ class="button button_margin" appearance="icon" tuiHintDirection="top-left" - [tuiHint]="cancelWord" + [tuiHint]="texts.undo" [tuiHintId]="undoBtn.id" [tuiDescribedBy]="undoBtn.id" [disabled]="undoDisabled" @@ -31,7 +31,7 @@ class="button button_margin" appearance="icon" tuiHintDirection="top-left" - tuiHint="Повторить" + [tuiHint]="texts.redo" [tuiHintId]="redoBtn.id" [tuiDescribedBy]="redoBtn.id" [disabled]="redoDisabled" @@ -53,7 +53,7 @@ class="button" icon="tuiIconToolbarFont" tuiHintDirection="top-left" - tuiHint="Шрифт" + [tuiHint]="texts.font" [tuiHintId]="fontsBtn.id" [tuiDescribedBy]="fontsBtn.id" [pseudoPressed]="fonts.open" @@ -94,7 +94,7 @@ appearance="icon" class="button" tuiHintDirection="top-left" - tuiHint="Стиль шрифта" + [tuiHint]="texts.fontStyle" [tuiHintId]="formatBtn.id" [tuiDescribedBy]="formatBtn.id" [pseudoPressed]="format.open || bold || italic || underline || strikeThrough" @@ -109,10 +109,10 @@ tuiIconButton type="button" size="s" - tuiHint="Полужирный" icon="tuiIconToolbarBold" appearance="icon" class="button button_margin" + [tuiHint]="texts.bold" [pseudoPressed]="bold" (click)="toggleBold()" > @@ -121,10 +121,10 @@ tuiIconButton type="button" size="s" - tuiHint="Курсив" icon="tuiIconToolbarItalic" appearance="icon" class="button button_margin" + [tuiHint]="texts.italic" [pseudoPressed]="italic" (click)="toggleItalic()" > @@ -133,10 +133,10 @@ tuiIconButton type="button" size="s" - tuiHint="Подчеркнутый" icon="tuiIconToolbarUnderline" appearance="icon" class="button button_margin" + [tuiHint]="texts.underline" [pseudoPressed]="underline" (click)="toggleUnderline()" > @@ -145,10 +145,10 @@ tuiIconButton type="button" size="s" - tuiHint="Зачеркнутый" icon="tuiIconToolbarStrikeThrough" appearance="icon" class="button button_margin" + [tuiHint]="texts.strikeThrough" [pseudoPressed]="strikeThrough" (click)="toggleStrikeThrough()" > @@ -172,7 +172,7 @@ appearance="icon" class="button" tuiHintDirection="top-left" - tuiHint="Выравнивание" + [tuiHint]="texts.justify" [tuiHintId]="alignBtn.id" [tuiDescribedBy]="alignBtn.id" [pseudoPressed]="align.open" @@ -186,40 +186,40 @@ tuiIconButton type="button" size="s" - tuiHint="Выровнять текст по левому краю" icon="tuiIconToolbarJustifyLeft" class="button button_margin" appearance="icon" + [tuiHint]="texts.justifyLeft" (click)="onAlign('justifyLeft')" > @@ -242,7 +242,7 @@ class="button" appearance="icon" tuiHintDirection="top-left" - tuiHint="Списки" + [tuiHint]="texts.list" [tuiHintId]="listBtn.id" [tuiDescribedBy]="listBtn.id" [pseudoPressed]="list.open || unorderedList || orderedList" @@ -256,10 +256,10 @@ tuiIconButton type="button" size="s" - tuiHint="Маркированный список" icon="tuiIconToolbarUL" appearance="icon" class="button button_margin" + [tuiHint]="texts.unorderedList" [pseudoPressed]="unorderedList" (click)="toggleUnorderedList()" > @@ -267,10 +267,10 @@ tuiIconButton type="button" size="s" - tuiHint="Нумерованный список" icon="tuiIconToolbarOL" appearance="icon" class="button button_margin" + [tuiHint]="texts.orderedList" [pseudoPressed]="orderedList" (click)="toggleOrderedList()" > @@ -278,10 +278,10 @@ tuiIconButton type="button" size="s" - tuiHint="Уменьшить отступ" icon="tuiIconToolbarIndent" class="button button_margin" appearance="icon" + [tuiHint]="texts.indent" [disabled]="!unorderedList && !orderedList" (click)="indent()" > @@ -289,10 +289,10 @@ tuiIconButton type="button" size="s" - tuiHint="Увеличить отступ" icon="tuiIconToolbarOutdent" class="button button_margin" appearance="icon" + [tuiHint]="texts.outdent" [disabled]="!unorderedList && !orderedList" (click)="outdent()" > @@ -310,7 +310,7 @@ appearance="icon" class="button button_margin" tuiHintDirection="top-left" - tuiHint="Цитата" + [tuiHint]="texts.quote" [tuiHintId]="quoteBtn.id" [tuiDescribedBy]="quoteBtn.id" [pseudoPressed]="blockquote" @@ -337,7 +337,7 @@ appearance="icon" class="button" tuiHintDirection="top-left" - tuiHint="Ссылка" + [tuiHint]="texts.link" [tuiHintId]="linkBtn.id" [tuiDescribedBy]="linkBtn.id" [pseudoPressed]="link.open || a" @@ -365,7 +365,7 @@ class="button button_margin" appearance="icon" tuiHintDirection="top-left" - tuiHint="Вставить файл" + [tuiHint]="texts.attach" [tuiHintId]="attachBtn.id" [tuiDescribedBy]="attachBtn.id" [focusable]="false" @@ -389,7 +389,7 @@ appearance="icon" class="button button_margin" tuiHintDirection="top-left" - tuiHint="Подстрочный" + [tuiHint]="texts.subscript" [tuiHintId]="subBtn.id" [tuiDescribedBy]="subBtn.id" [pseudoPressed]="subscript" @@ -409,7 +409,7 @@ appearance="icon" class="button button_margin" tuiHintDirection="top-left" - tuiHint="Надстрочный" + [tuiHint]="texts.superscript" [tuiHintId]="supBtn.id" [tuiDescribedBy]="supBtn.id" [pseudoPressed]="superscript" @@ -423,6 +423,7 @@ *ngIf="enabled(TuiEditorTool.Color) || enabled(TuiEditorTool.Hilite)" class="block" > + ( + `tui-color-selector i18n`, + { + factory: () => ['Solid color', 'Gradient'], + }, +); + +export type EditorToolbarTexts = + | TuiEditorTool + | 'redo' + | 'font' + | 'fontStyle' + | 'justifyLeft' + | 'justifyCenter' + | 'justifyRight' + | 'justifyFull' + | 'unorderedList' + | 'orderedList' + | 'indent' + | 'outdent' + | 'backColor'; + +export const TUI_EDITOR_TOOLBAR_TEXTS = new InjectionToken< + Record +>(`tui-color-selector i18n`, { + factory: () => ({ + undo: 'Undo', + redo: 'Redo', + font: 'Font', + fontStyle: 'Font style', + fontSize: 'fontSize', + bold: 'Bold', + italic: 'Italic', + underline: 'Underline', + strikeThrough: 'Strike Through', + justify: 'Justify', + justifyLeft: 'Justify left', + justifyCenter: 'Justify center', + justifyRight: 'Justify right', + justifyFull: 'Justify full', + list: 'List', + indent: 'Indent', + outdent: 'Outdent', + unorderedList: 'Unordered list', + orderedList: 'Ordered list', + quote: 'Quote', + foreColor: 'Color', + backColor: 'Background color', + hiliteColor: 'hiliteColor', + clear: 'Clear', + link: 'Link', + attach: 'Attach file', + tex: 'Insert TeX', + code: 'Code', + image: 'Insert image', + insertHorizontalRule: 'Insert horizontal rule', + superscript: 'Superscript', + subscript: 'Subscript', + }), +}); diff --git a/projects/addon-editor/tokens/index.ts b/projects/addon-editor/tokens/index.ts index 6f4736ac8c28..fa33b072125e 100644 --- a/projects/addon-editor/tokens/index.ts +++ b/projects/addon-editor/tokens/index.ts @@ -1,2 +1,3 @@ +export * from './i18n'; export * from './image-loader'; export * from './editor-styles'; diff --git a/projects/addon-table/components/reorder/reorder.component.ts b/projects/addon-table/components/reorder/reorder.component.ts index 6e5de1140294..aec119e32b8f 100644 --- a/projects/addon-table/components/reorder/reorder.component.ts +++ b/projects/addon-table/components/reorder/reorder.component.ts @@ -1,5 +1,6 @@ import {CdkDragDrop, moveItemInArray} from '@angular/cdk/drag-drop'; -import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, Inject, Input, Output} from '@angular/core'; +import {TUI_TABLE_SHOW_HIDE_MESSAGE} from '@taiga-ui/addon-table/tokens'; import {tuiDefaultProp} from '@taiga-ui/cdk'; @Component({ @@ -22,6 +23,8 @@ export class TuiReorderComponent { @Output() readonly enabledChange = new EventEmitter>(); + constructor(@Inject(TUI_TABLE_SHOW_HIDE_MESSAGE) readonly showHideText: string) {} + isEnabled(item: T): boolean { return this.enabled.indexOf(item) !== -1; } diff --git a/projects/addon-table/components/reorder/reorder.template.html b/projects/addon-table/components/reorder/reorder.template.html index 129f3e1befe8..19bcba54d43d 100644 --- a/projects/addon-table/components/reorder/reorder.template.html +++ b/projects/addon-table/components/reorder/reorder.template.html @@ -2,14 +2,13 @@
{{item}} - diff --git a/projects/addon-table/components/table-pagination/table-pagination.component.ts b/projects/addon-table/components/table-pagination/table-pagination.component.ts index 0b99bb1f35cc..52313b8b4b10 100644 --- a/projects/addon-table/components/table-pagination/table-pagination.component.ts +++ b/projects/addon-table/components/table-pagination/table-pagination.component.ts @@ -1,6 +1,9 @@ -import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {Component, EventEmitter, Inject, Input, Output} from '@angular/core'; +import {TUI_TABLE_PAGINATION_TEXTS} from '@taiga-ui/addon-table/tokens'; import {tuiDefaultProp} from '@taiga-ui/cdk'; +import {TUI_SPIN_TEXTS} from '@taiga-ui/core'; +// @dynamic @Component({ selector: 'tui-table-pagination', templateUrl: './table-pagination.template.html', @@ -31,6 +34,12 @@ export class TuiTablePaginationComponent { open = false; + constructor( + @Inject(TUI_SPIN_TEXTS) readonly spinTexts: [string, string], + @Inject(TUI_TABLE_PAGINATION_TEXTS) + readonly texts: Record<'pages' | 'linesPerPage' | 'of', string>, + ) {} + get pages(): number { return Math.ceil(this.total / this.size); } diff --git a/projects/addon-table/components/table-pagination/table-pagination.template.html b/projects/addon-table/components/table-pagination/table-pagination.template.html index 60e0b1b869ca..9556bdce37b9 100644 --- a/projects/addon-table/components/table-pagination/table-pagination.template.html +++ b/projects/addon-table/components/table-pagination/table-pagination.template.html @@ -1,7 +1,8 @@ - -Страниц: {{pages}} +{{texts.pages}} {{pages}} - Строк на страницу + {{texts.linesPerPage}} diff --git a/projects/addon-table/index.ts b/projects/addon-table/index.ts index d255ad2c24e2..04360124fcda 100644 --- a/projects/addon-table/index.ts +++ b/projects/addon-table/index.ts @@ -1 +1,2 @@ export * from '@taiga-ui/addon-table/components'; +export * from '@taiga-ui/addon-table/tokens'; diff --git a/projects/addon-table/tokens/i18n.ts b/projects/addon-table/tokens/i18n.ts new file mode 100644 index 000000000000..b52db802f069 --- /dev/null +++ b/projects/addon-table/tokens/i18n.ts @@ -0,0 +1,18 @@ +import {InjectionToken} from '@angular/core'; + +export const TUI_TABLE_SHOW_HIDE_MESSAGE = new InjectionToken( + `tui-reorder i18n button`, + { + factory: () => 'Show/hide', + }, +); + +export const TUI_TABLE_PAGINATION_TEXTS = new InjectionToken< + Record<'pages' | 'linesPerPage' | 'of', string> +>('tui-table-pagination i18n texts', { + factory: () => ({ + pages: 'Pages', + linesPerPage: 'Lines per page', + of: 'of', + }), +}); diff --git a/projects/addon-table/tokens/index.ts b/projects/addon-table/tokens/index.ts new file mode 100644 index 000000000000..e82230f1bf13 --- /dev/null +++ b/projects/addon-table/tokens/index.ts @@ -0,0 +1 @@ +export * from './i18n'; diff --git a/projects/addon-table/tokens/package.json b/projects/addon-table/tokens/package.json new file mode 100644 index 000000000000..289d2d373a50 --- /dev/null +++ b/projects/addon-table/tokens/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "index.ts" + } + } +} diff --git a/projects/addon-tablebars/components/table-bars-host/table-bars-host.component.ts b/projects/addon-tablebars/components/table-bars-host/table-bars-host.component.ts index 548ae892a42d..c645c46befac 100644 --- a/projects/addon-tablebars/components/table-bars-host/table-bars-host.component.ts +++ b/projects/addon-tablebars/components/table-bars-host/table-bars-host.component.ts @@ -1,6 +1,6 @@ import {ChangeDetectionStrategy, Component, Inject} from '@angular/core'; import {TuiContextWithImplicit} from '@taiga-ui/cdk'; -import {TuiBrightness, tuiSlideInTop} from '@taiga-ui/core'; +import {TUI_CLOSE_WORD, TuiBrightness, tuiSlideInTop} from '@taiga-ui/core'; import {BehaviorSubject, Subscription} from 'rxjs'; import {TableBar} from '../../classes/table-bar'; import {TuiTableBarsService} from '../../services/table-bars.service'; @@ -19,7 +19,10 @@ export class TuiTableBarsHostComponent { private readonly subscription: Subscription; - constructor(@Inject(TuiTableBarsService) service: TuiTableBarsService) { + constructor( + @Inject(TuiTableBarsService) service: TuiTableBarsService, + @Inject(TUI_CLOSE_WORD) readonly closeWord: string, + ) { this.subscription = service.open$.subscribe(item => { this.addItem(item); }); diff --git a/projects/addon-tablebars/components/table-bars-host/table-bars-host.template.html b/projects/addon-tablebars/components/table-bars-host/table-bars-host.template.html index 4b569d86bd95..3ca76e832574 100644 --- a/projects/addon-tablebars/components/table-bars-host/table-bars-host.template.html +++ b/projects/addon-tablebars/components/table-bars-host/table-bars-host.template.html @@ -17,18 +17,17 @@ [context]="getItemContext(item)" > -
diff --git a/projects/core/components/data-list/data-list.component.ts b/projects/core/components/data-list/data-list.component.ts index 30fa2453e46d..9bc785c8eb7e 100644 --- a/projects/core/components/data-list/data-list.component.ts +++ b/projects/core/components/data-list/data-list.component.ts @@ -22,7 +22,7 @@ import { tuiPure, } from '@taiga-ui/cdk'; import {TuiDataListAccessor} from '@taiga-ui/core/interfaces'; -import {TUI_DATA_LIST_ACCESSOR} from '@taiga-ui/core/tokens'; +import {TUI_DATA_LIST_ACCESSOR, TUI_NOTHING_FOUND_MESSAGE} from '@taiga-ui/core/tokens'; import {TuiDataListRole} from '@taiga-ui/core/types'; import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; import {Observable} from 'rxjs'; @@ -50,10 +50,9 @@ export class TuiDataListComponent implements TuiDataListAccessor { @tuiDefaultProp() role: TuiDataListRole = 'listbox'; - // TODO i18n @Input() @tuiDefaultProp() - emptyContent: PolymorpheusContent = 'Ничего не найдено'; + emptyContent: PolymorpheusContent = this.defaultEmptyContent; @ContentChildren(forwardRef(() => TuiOptionComponent), {descendants: true}) private readonly options: QueryList> = EMPTY_QUERY; @@ -62,6 +61,7 @@ export class TuiDataListComponent implements TuiDataListAccessor { constructor( @Inject(ElementRef) private readonly elementRef: ElementRef, + @Inject(TUI_NOTHING_FOUND_MESSAGE) private readonly defaultEmptyContent: string, ) {} @tuiPure diff --git a/projects/core/tokens/i18n.ts b/projects/core/tokens/i18n.ts index 6f364d8ec5c2..c903dae2fd88 100644 --- a/projects/core/tokens/i18n.ts +++ b/projects/core/tokens/i18n.ts @@ -4,6 +4,13 @@ export const TUI_CLOSE_WORD = new InjectionToken(`i18n 'close' word`, { factory: () => 'Close', }); +export const TUI_NOTHING_FOUND_MESSAGE = new InjectionToken( + `i18n 'Nothing found' message`, + { + factory: () => 'Nothing found', + }, +); + export const TUI_DEFAULT_ERROR_MESSAGE = new InjectionToken( `i18n of error message`, { diff --git a/projects/demo/src/assets/android-chrome-192x192.png b/projects/demo/src/assets/android-chrome-192x192.png index c7fdbb292a1e..c9993a8b8edb 100644 Binary files a/projects/demo/src/assets/android-chrome-192x192.png and b/projects/demo/src/assets/android-chrome-192x192.png differ diff --git a/projects/demo/src/assets/android-chrome-512x512.png b/projects/demo/src/assets/android-chrome-512x512.png index c448e16f3032..11648476b72a 100644 Binary files a/projects/demo/src/assets/android-chrome-512x512.png and b/projects/demo/src/assets/android-chrome-512x512.png differ diff --git a/projects/demo/src/assets/apple-touch-icon.png b/projects/demo/src/assets/apple-touch-icon.png index 1179c13e4b98..dafbbae41a5b 100644 Binary files a/projects/demo/src/assets/apple-touch-icon.png and b/projects/demo/src/assets/apple-touch-icon.png differ diff --git a/projects/demo/src/assets/browserconfig.xml b/projects/demo/src/assets/browserconfig.xml index 5cd27e3f179e..5aecc916b9ee 100644 --- a/projects/demo/src/assets/browserconfig.xml +++ b/projects/demo/src/assets/browserconfig.xml @@ -3,7 +3,7 @@ - #603cba + #00aba9 diff --git a/projects/demo/src/assets/favicon-16x16.png b/projects/demo/src/assets/favicon-16x16.png index 12fcc5fc3563..e093555a3300 100644 Binary files a/projects/demo/src/assets/favicon-16x16.png and b/projects/demo/src/assets/favicon-16x16.png differ diff --git a/projects/demo/src/assets/favicon-32x32.png b/projects/demo/src/assets/favicon-32x32.png index 1ecf73295779..0e7359dd3a02 100644 Binary files a/projects/demo/src/assets/favicon-32x32.png and b/projects/demo/src/assets/favicon-32x32.png differ diff --git a/projects/demo/src/assets/favicon.ico b/projects/demo/src/assets/favicon.ico index 6790c25d0c35..0a8fa66fa402 100644 Binary files a/projects/demo/src/assets/favicon.ico and b/projects/demo/src/assets/favicon.ico differ diff --git a/projects/demo/src/assets/images/taiga.svg b/projects/demo/src/assets/images/taiga.svg index 107db2255674..5b9347b88dc9 100644 --- a/projects/demo/src/assets/images/taiga.svg +++ b/projects/demo/src/assets/images/taiga.svg @@ -1,3 +1,3 @@ - + diff --git a/projects/demo/src/assets/mstile-144x144.png b/projects/demo/src/assets/mstile-144x144.png deleted file mode 100644 index 136a8b5c7965..000000000000 Binary files a/projects/demo/src/assets/mstile-144x144.png and /dev/null differ diff --git a/projects/demo/src/assets/mstile-150x150.png b/projects/demo/src/assets/mstile-150x150.png index 3cfbc25d1e7a..af568dc21e63 100644 Binary files a/projects/demo/src/assets/mstile-150x150.png and b/projects/demo/src/assets/mstile-150x150.png differ diff --git a/projects/demo/src/assets/mstile-310x150.png b/projects/demo/src/assets/mstile-310x150.png deleted file mode 100644 index 2cb0dce2df2b..000000000000 Binary files a/projects/demo/src/assets/mstile-310x150.png and /dev/null differ diff --git a/projects/demo/src/assets/mstile-310x310.png b/projects/demo/src/assets/mstile-310x310.png deleted file mode 100644 index 0ea625219b7d..000000000000 Binary files a/projects/demo/src/assets/mstile-310x310.png and /dev/null differ diff --git a/projects/demo/src/assets/mstile-70x70.png b/projects/demo/src/assets/mstile-70x70.png deleted file mode 100644 index 418b9f573546..000000000000 Binary files a/projects/demo/src/assets/mstile-70x70.png and /dev/null differ diff --git a/projects/demo/src/assets/safari-pinned-tab.svg b/projects/demo/src/assets/safari-pinned-tab.svg index e600f9aea4ff..72326ecf7950 100644 --- a/projects/demo/src/assets/safari-pinned-tab.svg +++ b/projects/demo/src/assets/safari-pinned-tab.svg @@ -2,34 +2,119 @@ Created by potrace 1.11, written by Peter Selinger 2001-2013 - - + diff --git a/projects/demo/src/index.html b/projects/demo/src/index.html index a197266ba54b..4858a7a3c7ec 100644 --- a/projects/demo/src/index.html +++ b/projects/demo/src/index.html @@ -30,9 +30,9 @@ - + Taiga UI diff --git a/projects/demo/src/modules/components/input-card/input-card.component.ts b/projects/demo/src/modules/components/input-card/input-card.component.ts index d83990b09e7c..91b04591eb16 100644 --- a/projects/demo/src/modules/components/input-card/input-card.component.ts +++ b/projects/demo/src/modules/components/input-card/input-card.component.ts @@ -86,7 +86,10 @@ export class ExampleTuiInputCardComponent extends AbstractExampleTuiReactiveFiel autocompleteEnabledExpire = false; control = new FormGroup({ - card: new FormControl('', [Validators.required, tuiCreateLuhnValidator()]), + card: new FormControl('', [ + Validators.required, + tuiCreateLuhnValidator('Invalid card number'), + ]), expire: new FormControl('', Validators.required), cvc: new FormControl('', Validators.required), }); diff --git a/projects/icons/ng-package.json b/projects/icons/ng-package.json index 9f89e3ce4efe..f62b94fb1f88 100644 --- a/projects/icons/ng-package.json +++ b/projects/icons/ng-package.json @@ -1,6 +1,6 @@ { "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", - "dest": "../../dist/angular-icons", + "dest": "../../dist/icons", "lib": { "entryFile": "src/public-api.ts" } diff --git a/projects/icons/scripts/copy-icons.js b/projects/icons/scripts/copy-icons.js index 5300da6e8894..30357620f94b 100644 --- a/projects/icons/scripts/copy-icons.js +++ b/projects/icons/scripts/copy-icons.js @@ -1,4 +1,4 @@ const fs = require('fs-extra'); const {resolve} = require('path'); -fs.copy(resolve(__dirname, '..', 'src/icons/src'), './dist/angular-icons/src'); +fs.copy(resolve(__dirname, '..', 'src/icons/src'), './dist/icons/src'); diff --git a/projects/kit/components/calendar-range/calendar-range.component.ts b/projects/kit/components/calendar-range/calendar-range.component.ts index 38d9c2c4d975..5baf81c2a49d 100644 --- a/projects/kit/components/calendar-range/calendar-range.component.ts +++ b/projects/kit/components/calendar-range/calendar-range.component.ts @@ -35,7 +35,7 @@ import { MAX_DAY_RANGE_LENGTH_MAPPER, maxDayAssertion, } from '@taiga-ui/kit/constants'; -import {TUI_CALENDAR_DATA_STREAM} from '@taiga-ui/kit/tokens'; +import {TUI_CALENDAR_DATA_STREAM, TUI_OTHER_DATE_TEXT} from '@taiga-ui/kit/tokens'; import {Observable} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; @@ -100,8 +100,7 @@ export class TuiCalendarRangeComponent implements TuiWithOptionalMinMax item.range.to.daySameOrAfter(min) && (max === null || item.range.from.daySameOrBefore(max)), ), - // TODO: i18n - 'Другая дата...', + this.otherDateText, ]; constructor( @@ -110,6 +109,7 @@ export class TuiCalendarRangeComponent implements TuiWithOptionalMinMax valueChanges: Observable | null, @Inject(ChangeDetectorRef) changeDetectorRef: ChangeDetectorRef, @Inject(TuiDestroyService) destroy$: TuiDestroyService, + @Inject(TUI_OTHER_DATE_TEXT) private readonly otherDateText: string, ) { if (!valueChanges) { return; diff --git a/projects/kit/components/calendar-range/test/range-calendar.component.spec.ts b/projects/kit/components/calendar-range/test/range-calendar.component.spec.ts index 0003ea3cc624..a5eb0245fb4e 100644 --- a/projects/kit/components/calendar-range/test/range-calendar.component.spec.ts +++ b/projects/kit/components/calendar-range/test/range-calendar.component.spec.ts @@ -114,13 +114,6 @@ describe('rangeCalendarComponent', () => { const items = getItems(); expect(items.length).toBe(7); - expect(items[0].nativeElement.textContent.trim()).toBe('За все время'); - expect(items[1].nativeElement.textContent.trim()).toBe('Сегодня'); - expect(items[2].nativeElement.textContent.trim()).toBe('Вчера'); - expect(items[3].nativeElement.textContent.trim()).toBe('Текущая неделя'); - expect(items[4].nativeElement.textContent.trim()).toBe('Текущий месяц'); - expect(items[5].nativeElement.textContent.trim()).toBe('Прошлый месяц'); - expect(items[6].nativeElement.textContent.trim()).toBe('Другая дата...'); }); it('Если значение не подходит ни под один диапазон — галочка у "Другая дата..."', () => { @@ -163,8 +156,8 @@ describe('rangeCalendarComponent', () => { const items = getItems().map(item => item.nativeElement.textContent.trim()); - expect(items.some(item => item === 'Вчера')).toBe(true); - expect(items.some(item => item === 'Сегодня')).toBe(false); + expect(items.some(item => item === 'Yesterday')).toBe(true); + expect(items.some(item => item === 'Today')).toBe(false); }); it('При переопределении интервалов в списке всегда есть "Другая дата..."', () => { @@ -181,7 +174,7 @@ describe('rangeCalendarComponent', () => { expect(items.length).toBe(2); expect(items[0].nativeElement.textContent.trim()).toBe(title); - expect(items[1].nativeElement.textContent.trim()).toBe('Другая дата...'); + expect(items[1].nativeElement.textContent.trim()).toBe('Other date...'); }); }); diff --git a/projects/kit/components/data-list-wrapper/data-list-wrapper.component.ts b/projects/kit/components/data-list-wrapper/data-list-wrapper.component.ts index 81de4ef305f2..0d7f88d6d51a 100644 --- a/projects/kit/components/data-list-wrapper/data-list-wrapper.component.ts +++ b/projects/kit/components/data-list-wrapper/data-list-wrapper.component.ts @@ -3,6 +3,7 @@ import { Component, ElementRef, forwardRef, + Inject, Input, QueryList, ViewChildren, @@ -18,6 +19,7 @@ import { } from '@taiga-ui/cdk'; import { TUI_DATA_LIST_ACCESSOR, + TUI_NOTHING_FOUND_MESSAGE, TuiDataListAccessor, TuiOptionComponent, TuiSizeL, @@ -47,10 +49,9 @@ export class TuiDataListWrapperComponent implements TuiDataListAccessor { @tuiDefaultProp() disabledItemHandler: TuiBooleanHandler = ALWAYS_FALSE_HANDLER; - // TODO i18n @Input() @tuiDefaultProp() - emptyContent: PolymorpheusContent = 'Ничего не найдено'; + emptyContent: PolymorpheusContent = this.defaultEmptyContent; @Input() @tuiDefaultProp() @@ -64,6 +65,10 @@ export class TuiDataListWrapperComponent implements TuiDataListAccessor { @ViewChildren(forwardRef(() => TuiOptionComponent)) private readonly options: QueryList> = EMPTY_QUERY; + constructor( + @Inject(TUI_NOTHING_FOUND_MESSAGE) private readonly defaultEmptyContent: string, + ) {} + getContext( $implicit: T, {nativeElement}: ElementRef, diff --git a/projects/kit/components/input-file/file/file.component.ts b/projects/kit/components/input-file/file/file.component.ts index 0b32c85be5da..2aed7710dcac 100644 --- a/projects/kit/components/input-file/file/file.component.ts +++ b/projects/kit/components/input-file/file/file.component.ts @@ -53,7 +53,8 @@ export class TuiFileComponent { constructor( @Inject(TUI_IS_MOBILE) readonly isMobile: boolean, @Inject(DomSanitizer) private readonly sanitizer: DomSanitizer, - @Inject(TUI_FILE_TEXTS) readonly fileTexts: Record, + @Inject(TUI_FILE_TEXTS) + readonly fileTexts: Record<'loadingError' | 'preview' | 'remove', string>, @Inject(TUI_DIGITAL_INFORMATION_UNITS) private readonly units: [string, string, string], ) {} diff --git a/projects/kit/components/input-file/input-file.component.ts b/projects/kit/components/input-file/input-file.component.ts index 73bf5be2fde5..2f7708f7ee97 100644 --- a/projects/kit/components/input-file/input-file.component.ts +++ b/projects/kit/components/input-file/input-file.component.ts @@ -103,7 +103,18 @@ export class TuiInputFileComponent changeDetectorRef: ChangeDetectorRef, @Inject(TUI_IS_MOBILE) isMobile: boolean, - @Inject(TUI_INPUT_FILE_TEXTS) readonly inputFileTexts: Record, + @Inject(TUI_INPUT_FILE_TEXTS) + readonly inputFileTexts: Record< + | 'defaultLabelSingle' + | 'defaultLabelMultiple' + | 'defaultLinkSingle' + | 'defaultLinkMultiple' + | 'maxSizeRejectionReason' + | 'formatRejectionReason' + | 'drop' + | 'dropMultiple', + string + >, @Inject(TUI_DIGITAL_INFORMATION_UNITS) private readonly units: [string, string, string], ) { diff --git a/projects/kit/directives/unfinished-validator/unfinished-validator.directive.ts b/projects/kit/directives/unfinished-validator/unfinished-validator.directive.ts index 04a65f4349bf..07004e871321 100644 --- a/projects/kit/directives/unfinished-validator/unfinished-validator.directive.ts +++ b/projects/kit/directives/unfinished-validator/unfinished-validator.directive.ts @@ -1,6 +1,7 @@ import {Attribute, Directive, Inject, Injector} from '@angular/core'; import {NG_VALIDATORS, Validator} from '@angular/forms'; import {TUI_FOCUSABLE_ITEM_ACCESSOR} from '@taiga-ui/cdk'; +import {TUI_UNFINISHED_TEXT} from '@taiga-ui/kit/tokens'; import {tuiCreateUnfinishedValidator} from '@taiga-ui/kit/validators'; @Directive({ @@ -16,7 +17,7 @@ import {tuiCreateUnfinishedValidator} from '@taiga-ui/kit/validators'; export class TuiUnfinishedValidatorDirective implements Validator { readonly validate = tuiCreateUnfinishedValidator( () => this.injector.get(TUI_FOCUSABLE_ITEM_ACCESSOR), - this.message || undefined, + this.message || this.defaultMessage, ); constructor( @@ -24,5 +25,6 @@ export class TuiUnfinishedValidatorDirective implements Validator { private readonly injector: Injector, @Attribute('tuiUnfinishedValidator') private readonly message: string | null, + @Inject(TUI_UNFINISHED_TEXT) private readonly defaultMessage: string, ) {} } diff --git a/projects/kit/tokens/i18n.ts b/projects/kit/tokens/i18n.ts index ad2472900146..795637eead1a 100644 --- a/projects/kit/tokens/i18n.ts +++ b/projects/kit/tokens/i18n.ts @@ -13,6 +13,17 @@ export const TUI_MORE_WORD = new InjectionToken(`i18n 'more' word`, { factory: () => 'More', }); +export const TUI_OTHER_DATE_TEXT = new InjectionToken(`i18n 'Other date' text`, { + factory: () => 'Other date...', +}); + +export const TUI_UNFINISHED_TEXT = new InjectionToken( + `i18n unfinished validator text`, + { + factory: () => 'Finish filling the field', + }, +); + /** * Works with a tuple * [@string 'choose day', @param 'choose range'] @@ -82,16 +93,15 @@ export const TUI_CALENDAR_MONTHS = new InjectionToken>( }, ); -export const TUI_FILE_TEXTS = new InjectionToken>( - 'file i18n texts', - { - factory: () => ({ - loadingError: 'Loading error', - preview: 'Preview', - remove: 'Remove', - }), - }, -); +export const TUI_FILE_TEXTS = new InjectionToken< + Record<'loadingError' | 'preview' | 'remove', string> +>('file i18n texts', { + factory: () => ({ + loadingError: 'Loading error', + preview: 'Preview', + remove: 'Remove', + }), +}); export const TUI_PAGINATION_TEXTS = new InjectionToken<[string, string]>( 'pagination i18n texts', @@ -100,18 +110,27 @@ export const TUI_PAGINATION_TEXTS = new InjectionToken<[string, string]>( }, ); -export const TUI_INPUT_FILE_TEXTS = new InjectionToken>( - 'tui-input-file i18n texts', - { - factory: () => ({ - defaultLabelSingle: 'or drag\u00A0it\u00A0here', - defaultLabelMultiple: 'or drag\u00A0them\u00A0here', - defaultLinkSingle: 'Choose a file', - defaultLinkMultiple: 'Choose files', - maxSizeRejectionReason: 'File exceeds size ', - formatRejectionReason: 'Wrong file format', - drop: 'Drop file here', - dropMultiple: 'Drop files here', - }), - }, -); +export const TUI_INPUT_FILE_TEXTS = new InjectionToken< + Record< + | 'defaultLabelSingle' + | 'defaultLabelMultiple' + | 'defaultLinkSingle' + | 'defaultLinkMultiple' + | 'maxSizeRejectionReason' + | 'formatRejectionReason' + | 'drop' + | 'dropMultiple', + string + > +>('tui-input-file i18n texts', { + factory: () => ({ + defaultLabelSingle: 'or drag\u00A0it\u00A0here', + defaultLabelMultiple: 'or drag\u00A0them\u00A0here', + defaultLinkSingle: 'Choose a file', + defaultLinkMultiple: 'Choose files', + maxSizeRejectionReason: 'File exceeds size ', + formatRejectionReason: 'Wrong file format', + drop: 'Drop file here', + dropMultiple: 'Drop files here', + }), +}); diff --git a/projects/kit/utils/miscellaneous/create-default-day-range-periods.ts b/projects/kit/utils/miscellaneous/create-default-day-range-periods.ts index c0165340169b..76cb8259f63c 100644 --- a/projects/kit/utils/miscellaneous/create-default-day-range-periods.ts +++ b/projects/kit/utils/miscellaneous/create-default-day-range-periods.ts @@ -1,7 +1,16 @@ import {TUI_FIRST_DAY, TuiDay, TuiDayRange} from '@taiga-ui/cdk'; import {TuiDayRangePeriod} from '@taiga-ui/kit/classes'; -export function tuiCreateDefaultDayRangePeriods(): ReadonlyArray { +export function tuiCreateDefaultDayRangePeriods( + periodTitles: [string, string, string, string, string, string] = [ + 'For all the time', + 'Today', + 'Yesterday', + 'Current week', + 'Current month', + 'Previous month', + ], +): ReadonlyArray { const today = TuiDay.currentLocal(); const yesterday = today.append({day: -1}); const startOfWeek = today.append({day: -today.dayOfWeek()}); @@ -10,16 +19,15 @@ export function tuiCreateDefaultDayRangePeriods(): ReadonlyArray TuiFocusableElementAccessor, - message: PolymorpheusContent = error, + message: PolymorpheusContent, ): ValidatorFn { return ({ value,