-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(datepicker): merge datepicker branch into master #4404
Merged
Merged
Changes from 5 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
869d0f2
create SimpleDate and CalendarLocale objects (#2839)
mmalerba 4347689
feat(datepicker): add month & year view (#2904)
mmalerba fc34721
fixes i forgot to push before merging #2904 (#2978)
mmalerba e24f0ce
feat(datepicker): create the md-datepicker component (#3024)
mmalerba 16a16c6
feat(datepicker): make calendar responsive (#3086)
mmalerba bcff6be
feat(datepicker): add calendar component that pulls together month an…
mmalerba 58456ea
fix(datepicker): make calendar look more like mocks (#3138)
mmalerba bc4b168
add the calendar to the datepicker popup (#3178)
mmalerba 08ccf03
feat(datepicker): wire up selected value propagation (#3330)
mmalerba 4c20c5f
feat(datepicker): add md-datepicker-trigger & compatibility w/ md-inp…
mmalerba 991cdde
feat(datepicker): add aria-* attrs and keyboard bindings to datepicke…
mmalerba 4aeca6c
feat(datepicker): min & max dates + dateFilter (#3556)
mmalerba e6cf1ef
fix(datepicker): fix bug where calendar dialog could only be opened o…
mmalerba 12076e8
feat(datepicker): add keyboard support to calendar (#3655)
mmalerba 21cb164
angular 4 fixes
mmalerba dbb8387
fix(datepicker): use input's min & max properites rather than custom …
mmalerba 559880d
fix(datepicker): hide weekdays in year view (#3852)
mmalerba a85c094
fix(datepicker): calendar should update when input changes (#3824)
mmalerba 531f452
fix(datepicker): set focus properly when opening datepicker (#3839)
mmalerba 1e9dfbd
fix(datepicker): make touch UI work well on mobile (#3853)
mmalerba 776a10a
fix lint issues
mmalerba 5f39247
fix(datepicker): some misc cleanup (#4106)
mmalerba 8b6780c
refactor(datepicker): move weekdays into table header (#4129)
mmalerba f229b1b
feat(datepicker): add DateAdapter and NativeDateAdapter (#4148)
mmalerba 9ab583a
refactor(datepicker): replace SimpleDate & CalendarLocale with DateAd…
mmalerba cb8a49d
datepicker: create injectable for date formats and bundle it along wi…
mmalerba 2642715
fix lint issues
mmalerba ac706fe
fix(datepicker): make datepicker work with screen readers (#4349)
mmalerba a6428e5
docs(datepicker): update readme & demo (#4368)
mmalerba 7964052
fix(datepicker): require actual date objects for min, max, etc (#4381)
mmalerba 14b2523
feat(datepicker): input validation for min, max, and date filter (#4393)
mmalerba 7fe110a
refactor(datepicker): migrate from Renderer to Renderer2
mmalerba 361a05b
fix tests on safari 9
mmalerba 4f5ccb2
fix Edge/IE tests that fail because of different Intl implementation
mmalerba 9bbed07
strip direction characters when formatting
mmalerba 0697350
fix lint
mmalerba 3b31d7b
addressed comments
mmalerba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,31 +56,31 @@ export class NativeDateAdapter extends DateAdapter<Date> { | |
getMonthNames(style: 'long' | 'short' | 'narrow'): string[] { | ||
if (SUPPORTS_INTL_API) { | ||
let dtf = new Intl.DateTimeFormat(this.locale, {month: style}); | ||
return range(12, i => dtf.format(new Date(2017, i, 1))); | ||
return range(12, i => this._stripDirectionCharacters(dtf.format(new Date(2017, i, 1)))); | ||
} | ||
return DEFAULT_MONTH_NAMES[style]; | ||
} | ||
|
||
getDateNames(): string[] { | ||
if (SUPPORTS_INTL_API) { | ||
let dtf = new Intl.DateTimeFormat(this.locale, {day: 'numeric'}); | ||
return range(31, i => dtf.format(new Date(2017, 0, i + 1))); | ||
return range(31, i => this._stripDirectionCharacters(dtf.format(new Date(2017, 0, i + 1)))); | ||
} | ||
return DEFAULT_DATE_NAMES; | ||
} | ||
|
||
getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[] { | ||
if (SUPPORTS_INTL_API) { | ||
let dtf = new Intl.DateTimeFormat(this.locale, {weekday: style}); | ||
return range(7, i => dtf.format(new Date(2017, 0, i + 1))); | ||
return range(7, i => this._stripDirectionCharacters(dtf.format(new Date(2017, 0, i + 1)))); | ||
} | ||
return DEFAULT_DAY_OF_WEEK_NAMES[style]; | ||
} | ||
|
||
getYearName(date: Date): string { | ||
if (SUPPORTS_INTL_API) { | ||
let dtf = new Intl.DateTimeFormat(this.locale, {year: 'numeric'}); | ||
return dtf.format(date); | ||
return this._stripDirectionCharacters(dtf.format(date)); | ||
} | ||
return String(this.getYear(date)); | ||
} | ||
|
@@ -131,9 +131,9 @@ export class NativeDateAdapter extends DateAdapter<Date> { | |
format(date: Date, displayFormat: Object): string { | ||
if (SUPPORTS_INTL_API) { | ||
let dtf = new Intl.DateTimeFormat(this.locale, displayFormat); | ||
return dtf.format(date); | ||
return this._stripDirectionCharacters(dtf.format(date)); | ||
} | ||
return date.toDateString(); | ||
return this._stripDirectionCharacters(date.toDateString()); | ||
} | ||
|
||
addCalendarYears(date: Date, years: number): Date { | ||
|
@@ -188,4 +188,15 @@ export class NativeDateAdapter extends DateAdapter<Date> { | |
private _2digit(n: number) { | ||
return ('00' + n).slice(-2); | ||
} | ||
|
||
/** | ||
* Strip out unicode LTR and RTL characters. Edge and IE insert these into formatted dates while | ||
* other browsers do not. We remove them to make output consistent and because they interfere with | ||
* date parsing. | ||
* @param s The string to strip direction characters from. | ||
* @returns {string} The stripped string. | ||
*/ | ||
private _stripDirectionCharacters(s: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return s.replace(/[\u200e\u200f]/g, ''); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit return type from comment