Skip to content

Commit e8dd070

Browse files
authored
feat(material-date-fns-adapter): add date adapter for date-fns (#23262)
* feat(material-date-fns-adapter): add date adapter for date-fns Adds a new date adapter that supports the `date-fns` library. * fixup! feat(material-date-fns-adapter): add date adapter for date-fns Fix saucelabs unit tests and the integration test for partial compilation. * fixup! feat(material-date-fns-adapter): add date adapter for date-fns
1 parent 769996e commit e8dd070

36 files changed

+925
-16
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
# Date adapters
9292
/src/material-moment-adapter/** @mmalerba
9393
/src/material-luxon-adapter/** @crisbeto
94+
/src/material-date-fns-adapter/** @crisbeto
9495

9596
# Material experimental package
9697
/src/material-experimental/* @jelbourn

.ng-dev/commit-message.ts

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export const commitMessage: CommitMessageConfig = {
7272
'material-experimental/popover-edit',
7373
'material-experimental/selection',
7474
'material-moment-adapter',
75+
'material-date-fns-adapter',
7576
'material-luxon-adapter',
7677
'material/autocomplete',
7778
'material/badge',

WORKSPACE

+4
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ load(
9696
)
9797

9898
_dev_infra_browser_repositories()
99+
100+
load("@npm//@bazel/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
101+
102+
esbuild_repositories()

angular-tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"node_modules/@angular/material-experimental/**",
3939
"node_modules/@angular/material-moment-adapter/**",
4040
"node_modules/@angular/material-luxon-adapter/**",
41+
"node_modules/@angular/material-date-fns-adapter/**",
4142
"node_modules/@angular/youtube-player/**"
4243
]
4344
}

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"@bazel/bazelisk": "1.9.0",
8989
"@bazel/buildifier": "4.0.1",
9090
"@bazel/concatjs": "4.0.0-beta.0",
91+
"@bazel/esbuild": "4.0.0-beta.0",
9192
"@bazel/ibazel": "0.15.10",
9293
"@bazel/jasmine": "4.0.0-beta.0",
9394
"@bazel/protractor": "4.0.0-beta.0",
@@ -171,6 +172,7 @@
171172
"chalk": "^4.1.0",
172173
"codelyzer": "^6.0.2",
173174
"conventional-changelog": "^3.0.5",
175+
"date-fns": "^2.23.0",
174176
"dgeni": "^0.4.11",
175177
"dgeni-packages": "^0.28.4",
176178
"diff": "^5.0.0",
@@ -195,13 +197,13 @@
195197
"karma-requirejs": "^1.1.0",
196198
"karma-sauce-launcher": "^4.3.6",
197199
"karma-sourcemap-loader": "^0.3.7",
200+
"luxon": "^2.0.0",
198201
"madge": "^4.0.0",
199202
"marked": "^2.0.0",
200203
"merge2": "^1.2.3",
201204
"minimatch": "^3.0.4",
202205
"minimist": "^1.2.0",
203206
"moment": "^2.18.1",
204-
"luxon": "^2.0.0",
205207
"node-fetch": "^2.6.0",
206208
"parse5": "^6.0.1",
207209
"postcss": "^8.2.1",

rollup-globals.bzl

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ ROLLUP_GLOBALS = {
3636
"@angular/material-experimental": "ng.materialExperimental",
3737
"@angular/material-moment-adapter": "ng.materialMomentAdapter",
3838
"@angular/material-luxon-adapter": "ng.materialLuxonAdapter",
39+
"@angular/material-date-fns-adapter": "ng.materialDateFnsAdapter",
3940
"@angular/youtube-player": "ng.youtubePlayer",
4041

4142
# This UMD module name would not match with anything that MDC provides, but we just
@@ -48,6 +49,7 @@ ROLLUP_GLOBALS = {
4849
"moment/locale/fr": "moment.locale.fr",
4950
"moment/locale/ja": "moment.locale.ja",
5051
"luxon": "luxon",
52+
"date-fns": "dateFns",
5153
"protractor": "protractor",
5254
"rxjs": "rxjs",
5355
"rxjs/operators": "rxjs.operators",

scripts/deploy/publish-build-artifacts.sh

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ PACKAGES=(
2323
material-experimental
2424
material-moment-adapter
2525
# material-luxon-adapter TODO(crisbeto): enable this once we have a builds repo
26+
# material-date-fns-adapter TODO(crisbeto): enable this once we have a builds repo
2627
google-maps
2728
youtube-player
2829
)

src/components-examples/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"@angular/material": "0.0.0-PLACEHOLDER",
2727
"@angular/material-experimental": "0.0.0-PLACEHOLDER",
2828
"@angular/material-moment-adapter": "0.0.0-PLACEHOLDER",
29-
"@angular/material-luxon-adapter": "0.0.0-PLACEHOLDER"
29+
"@angular/material-luxon-adapter": "0.0.0-PLACEHOLDER",
30+
"@angular/material-date-fns-adapter": "0.0.0-PLACEHOLDER"
3031
},
3132
"dependencies": {
3233
"tslib": "0.0.0-TSLIB"

src/components-examples/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"@angular/material/*": ["../material/*"],
1313
"@angular/material-experimental/*": ["../material-experimental/*"],
1414
"@angular/material-moment-adapter": ["../material-moment-adapter/public-api.ts"],
15-
"@angular/material-luxon-adapter": ["../material-luxon-adapter/public-api.ts"]
15+
"@angular/material-luxon-adapter": ["../material-luxon-adapter/public-api.ts"],
16+
"@angular/material-date-fns-adapter": ["../material-date-fns-adapter/public-api.ts"]
1617
}
1718
},
1819
"include": ["./**/*.ts"]

src/dev-app/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@angular/cdk-experimental": ["../cdk-experimental"],
1616
"@angular/material-moment-adapter": ["../material-moment-adapter/public-api.ts"],
1717
"@angular/material-luxon-adapter": ["../material-luxon-adapter/public-api.ts"],
18+
"@angular/material-date-fns-adapter": ["../material-date-fns-adapter/public-api.ts"],
1819
"@angular/google-maps": ["../google-maps"],
1920
"@angular/components-examples": ["../components-examples"],
2021
"@angular/components-examples/*": ["../components-examples/*"],

src/e2e-app/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@angular/cdk-experimental": ["../cdk-experimental/"],
1414
"@angular/material-moment-adapter": ["../material-moment-adapter/"],
1515
"@angular/material-luxon-adapter": ["../material-luxon-adapter/"],
16+
"@angular/material-date-fns-adapter": ["../material-date-fns-adapter/"],
1617
"@angular/components-examples": ["../components-examples/"],
1718
"@angular/components-examples/*": ["../components-examples/*"]
1819
}
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
load("//tools:defaults.bzl", "ng_module", "ng_package", "ng_test_library", "ng_web_test_suite")
2+
load(":esbuild-amd.bzl", "esbuild_amd")
3+
4+
package(default_visibility = ["//visibility:public"])
5+
6+
ng_module(
7+
name = "material-date-fns-adapter",
8+
srcs = glob(
9+
["**/*.ts"],
10+
exclude = ["**/*.spec.ts"],
11+
),
12+
deps = [
13+
"//src:dev_mode_types",
14+
"//src/material/core",
15+
"@npm//@angular/core",
16+
"@npm//date-fns",
17+
],
18+
)
19+
20+
ng_test_library(
21+
name = "unit_test_sources",
22+
srcs = glob(
23+
["**/*.spec.ts"],
24+
exclude = ["**/*.e2e.spec.ts"],
25+
),
26+
deps = [
27+
":material-date-fns-adapter",
28+
"//src/material/core",
29+
"@npm//date-fns",
30+
],
31+
)
32+
33+
ng_web_test_suite(
34+
name = "unit_tests",
35+
deps = [
36+
":amd_date_fns",
37+
":amd_date_fns_locales",
38+
":unit_test_sources",
39+
],
40+
)
41+
42+
esbuild_amd(
43+
name = "amd_date_fns",
44+
testonly = True,
45+
entry_point = "@npm//:node_modules/date-fns/esm/index.js",
46+
module_name = "date-fns",
47+
deps = ["@npm//date-fns"],
48+
)
49+
50+
esbuild_amd(
51+
name = "amd_date_fns_locales",
52+
testonly = True,
53+
entry_point = "@npm//:node_modules/date-fns/esm/locale/index.js",
54+
module_name = "date-fns/locale",
55+
deps = ["@npm//date-fns"],
56+
)
57+
58+
ng_package(
59+
name = "npm_package",
60+
srcs = ["package.json"],
61+
entry_point = ":public-api.ts",
62+
tags = ["release-package"],
63+
deps = [":material-date-fns-adapter"],
64+
)

0 commit comments

Comments
 (0)