-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat: add date adapter for luxon #14681
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package(default_visibility=["//visibility:public"]) | ||
|
||
load("//tools:defaults.bzl", "ng_module", "ng_package", "ng_web_test_suite", "ng_test_library") | ||
load("//:packages.bzl", "ROLLUP_GLOBALS") | ||
|
||
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. @devversion this file is based on the one from the Moment adapter, but I'm not sure whether it's entirely correct. AFAIK this won't run the unit tests. 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. Can probably update this now, based on #14687 |
||
ng_module( | ||
name = "material-luxon-adapter", | ||
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]), | ||
module_name = "@angular/material-luxon-adapter", | ||
deps = [ | ||
"@angular//packages/core", | ||
"@matdeps//@types/luxon", | ||
"//src/lib/core", | ||
], | ||
) | ||
|
||
ng_test_library( | ||
name = "luxon_adapter_test_sources", | ||
srcs = glob(["**/*.spec.ts"]), | ||
deps = [ | ||
"//src/lib/core", | ||
"//src/lib/testing", | ||
"//src/cdk/platform", | ||
"@matdeps//@types/luxon", | ||
":material-luxon-adapter", | ||
], | ||
) | ||
|
||
ng_web_test_suite( | ||
name = "unit_tests", | ||
deps = [ | ||
":require-config.js", | ||
":luxon_adapter_test_sources" | ||
], | ||
# We need to load Luxon statically since it is not a named AMD module and needs to | ||
# be manually configured through "require.js" which is used by "ts_web_test_suite". | ||
static_files = [ | ||
"@matdeps//luxon", | ||
], | ||
) | ||
|
||
ng_package( | ||
name = "npm_package", | ||
srcs = ["package.json"], | ||
entry_point = "src/material-luxon-adapter/public_api.js", | ||
globals = ROLLUP_GLOBALS, | ||
deps = [":material-luxon-adapter"], | ||
# TODO(devversion): re-enable once we have set up the proper compiler for the ng_package | ||
tags = ["manual"], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {NgModule} from '@angular/core'; | ||
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core'; | ||
import {MAT_LUXON_DATE_ADAPTER_OPTIONS, LuxonDateAdapter} from './luxon-date-adapter'; | ||
import {MAT_LUXON_DATE_FORMATS} from './luxon-date-formats'; | ||
|
||
export * from './luxon-date-adapter'; | ||
export * from './luxon-date-formats'; | ||
|
||
@NgModule({ | ||
providers: [ | ||
{ | ||
provide: DateAdapter, | ||
useClass: LuxonDateAdapter, | ||
deps: [MAT_DATE_LOCALE, MAT_LUXON_DATE_ADAPTER_OPTIONS] | ||
} | ||
], | ||
}) | ||
export class LuxonDateModule {} | ||
|
||
|
||
@NgModule({ | ||
imports: [LuxonDateModule], | ||
providers: [{provide: MAT_DATE_FORMATS, useValue: MAT_LUXON_DATE_FORMATS}], | ||
}) | ||
export class MatLuxonDateModule {} |
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.
We should update this note to just say "...highly recommend using one of the alternative adapters or creating your own custom adapter"