-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cdk, core):
TuiMonthPipe
move from cdk to core, add i18n
BREAKING CHANGE: import it from @taiga-ui/core library and use with async pipe
- Loading branch information
1 parent
4e75649
commit 59474d2
Showing
13 changed files
with
35 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from '@taiga-ui/cdk/pipes/filter'; | ||
export * from '@taiga-ui/cdk/pipes/mapper'; | ||
export * from '@taiga-ui/cdk/pipes/month'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from '@taiga-ui/core/pipes/format-number'; | ||
export * from '@taiga-ui/core/pipes/format-phone'; | ||
export * from '@taiga-ui/core/pipes/month'; | ||
export * from '@taiga-ui/core/pipes/pluralize'; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {Inject, Pipe, PipeTransform} from '@angular/core'; | ||
import {TuiMonth} from '@taiga-ui/cdk/date-time'; | ||
import {TUI_MONTHS} from '@taiga-ui/core/tokens'; | ||
import {Observable} from 'rxjs'; | ||
import {map} from 'rxjs/operators'; | ||
|
||
// @dynamic | ||
@Pipe({name: 'tuiMonth'}) | ||
export class TuiMonthPipe implements PipeTransform { | ||
constructor(@Inject(TUI_MONTHS) private readonly months$: Observable<string[]>) {} | ||
|
||
transform({month}: TuiMonth): Observable<string> { | ||
return this.months$.pipe(map(months => months[month])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
"entryFile": "index.ts" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,29 @@ | ||
import {InjectionToken} from '@angular/core'; | ||
import {extractI18n} from '@taiga-ui/i18n'; | ||
|
||
export const TUI_CLOSE_WORD = new InjectionToken<string>(`i18n 'close' word`, { | ||
factory: () => 'Close', | ||
export const TUI_MONTHS = new InjectionToken('Localized months names', { | ||
factory: extractI18n('months'), | ||
}); | ||
|
||
export const TUI_NOTHING_FOUND_MESSAGE = new InjectionToken<string>( | ||
export const TUI_CLOSE_WORD = new InjectionToken(`i18n 'close' word`, { | ||
factory: extractI18n('close'), | ||
}); | ||
|
||
export const TUI_NOTHING_FOUND_MESSAGE = new InjectionToken( | ||
`i18n 'Nothing found' message`, | ||
{ | ||
factory: () => 'Nothing found', | ||
factory: extractI18n('nothingFoundMessage'), | ||
}, | ||
); | ||
|
||
export const TUI_DEFAULT_ERROR_MESSAGE = new InjectionToken<string>( | ||
`i18n of error message`, | ||
{ | ||
factory: () => 'Value is invalid', | ||
}, | ||
); | ||
export const TUI_DEFAULT_ERROR_MESSAGE = new InjectionToken(`i18n of error message`, { | ||
factory: extractI18n('defaultErrorMessage'), | ||
}); | ||
|
||
/** | ||
* Works with a tuple | ||
* [@string word 'previous', @string word 'next'] | ||
*/ | ||
export const TUI_SPIN_TEXTS = new InjectionToken<[string, string]>('spin i18n texts', { | ||
factory: () => ['Previous', 'Next'], | ||
export const TUI_SPIN_TEXTS = new InjectionToken('spin i18n texts', { | ||
factory: extractI18n('spinTexts'), | ||
}); | ||
|
||
/** | ||
* Tuple with short days of week | ||
* starts with Mon (Monday) | ||
*/ | ||
export const TUI_SHORT_WEEK_DAYS = new InjectionToken< | ||
[string, string, string, string, string, string, string] | ||
>('calendars i18n texts', { | ||
factory: () => ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], | ||
export const TUI_SHORT_WEEK_DAYS = new InjectionToken('calendars i18n texts', { | ||
factory: extractI18n('shortWeekDays'), | ||
}); |