-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cdk): i18n for date fillers (#43)
- Loading branch information
1 parent
499e9f3
commit a5011ba
Showing
5 changed files
with
62 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {inject, InjectionToken} from '@angular/core'; | ||
import {RANGE_SEPARATOR_CHAR} from './date-time'; | ||
|
||
// TODO: think about yyyy.mm.dd format | ||
export const TUI_DATE_FILLER = new InjectionToken<string>('date filler for Taiga UI', { | ||
factory: () => `dd.mm.yyyy`, | ||
}); | ||
|
||
export const TUI_DATE_RANGE_FILLER = new InjectionToken<string>( | ||
'date range filler for Taiga UI', | ||
{ | ||
factory: () => { | ||
const dateFiller = inject(TUI_DATE_FILLER); | ||
|
||
return `${dateFiller}${RANGE_SEPARATOR_CHAR}${dateFiller}`; | ||
}, | ||
}, | ||
); |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {TestBed} from '@angular/core/testing'; | ||
import {TUI_DATE_FILLER, TUI_DATE_RANGE_FILLER} from '../date-fillers'; | ||
import {RANGE_SEPARATOR_CHAR} from '../date-time'; | ||
|
||
describe('Date Fillers', () => { | ||
it('TUI_DATE_FILLER is a global token with default value', () => { | ||
TestBed.configureTestingModule({}); | ||
|
||
const result = TestBed.get(TUI_DATE_FILLER); | ||
|
||
expect(result).toBe('dd.mm.yyyy'); | ||
}); | ||
|
||
it('TUI_DATE_RANGE_FILLER is a global token with default value', () => { | ||
TestBed.configureTestingModule({}); | ||
|
||
const result = TestBed.get(TUI_DATE_RANGE_FILLER); | ||
|
||
expect(result).toBe('dd.mm.yyyy' + RANGE_SEPARATOR_CHAR + 'dd.mm.yyyy'); | ||
}); | ||
}); |
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