@react-aria/datepicker 3.0.0-nightly.3113 → 3.0.0-nightly.3114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ar-AE.main.js +21 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +23 -0
- package/dist/ar-AE.module.js +23 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +21 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +23 -0
- package/dist/bg-BG.module.js +23 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/cs-CZ.main.js +21 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +23 -0
- package/dist/cs-CZ.module.js +23 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +21 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +23 -0
- package/dist/da-DK.module.js +23 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +21 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +23 -0
- package/dist/de-DE.module.js +23 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +21 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +23 -0
- package/dist/el-GR.module.js +23 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +21 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +23 -0
- package/dist/en-US.module.js +23 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +21 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +23 -0
- package/dist/es-ES.module.js +23 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +21 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +23 -0
- package/dist/et-EE.module.js +23 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +21 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +23 -0
- package/dist/fi-FI.module.js +23 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +21 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +23 -0
- package/dist/fr-FR.module.js +23 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +21 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +23 -0
- package/dist/he-IL.module.js +23 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +21 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +23 -0
- package/dist/hr-HR.module.js +23 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +21 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +23 -0
- package/dist/hu-HU.module.js +23 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +25 -0
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.main.js +21 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +23 -0
- package/dist/it-IT.module.js +23 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +21 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +23 -0
- package/dist/ja-JP.module.js +23 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +21 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +23 -0
- package/dist/ko-KR.module.js +23 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +21 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +23 -0
- package/dist/lt-LT.module.js +23 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +21 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +23 -0
- package/dist/lv-LV.module.js +23 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +22 -759
- package/dist/main.js.map +1 -1
- package/dist/module.js +17 -744
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.main.js +21 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +23 -0
- package/dist/nb-NO.module.js +23 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +21 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +23 -0
- package/dist/nl-NL.module.js +23 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +21 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +23 -0
- package/dist/pl-PL.module.js +23 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +21 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +23 -0
- package/dist/pt-BR.module.js +23 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +21 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +23 -0
- package/dist/pt-PT.module.js +23 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +21 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +23 -0
- package/dist/ro-RO.module.js +23 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +21 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +23 -0
- package/dist/ru-RU.module.js +23 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +21 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +23 -0
- package/dist/sk-SK.module.js +23 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +21 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +23 -0
- package/dist/sl-SI.module.js +23 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +21 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +23 -0
- package/dist/sr-SP.module.js +23 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +21 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +23 -0
- package/dist/sv-SE.module.js +23 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +21 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +23 -0
- package/dist/tr-TR.module.js +23 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +88 -37
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js +21 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +23 -0
- package/dist/uk-UA.module.js +23 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/useDateField.main.js +177 -0
- package/dist/useDateField.main.js.map +1 -0
- package/dist/useDateField.mjs +168 -0
- package/dist/useDateField.module.js +168 -0
- package/dist/useDateField.module.js.map +1 -0
- package/dist/useDatePicker.main.js +158 -0
- package/dist/useDatePicker.main.js.map +1 -0
- package/dist/useDatePicker.mjs +153 -0
- package/dist/useDatePicker.module.js +153 -0
- package/dist/useDatePicker.module.js.map +1 -0
- package/dist/useDatePickerGroup.main.js +91 -0
- package/dist/useDatePickerGroup.main.js.map +1 -0
- package/dist/useDatePickerGroup.mjs +86 -0
- package/dist/useDatePickerGroup.module.js +86 -0
- package/dist/useDatePickerGroup.module.js.map +1 -0
- package/dist/useDateRangePicker.main.js +201 -0
- package/dist/useDateRangePicker.main.js.map +1 -0
- package/dist/useDateRangePicker.mjs +196 -0
- package/dist/useDateRangePicker.module.js +196 -0
- package/dist/useDateRangePicker.module.js.map +1 -0
- package/dist/useDateSegment.main.js +373 -0
- package/dist/useDateSegment.main.js.map +1 -0
- package/dist/useDateSegment.mjs +364 -0
- package/dist/useDateSegment.module.js +364 -0
- package/dist/useDateSegment.module.js.map +1 -0
- package/dist/useDisplayNames.main.js +59 -0
- package/dist/useDisplayNames.main.js.map +1 -0
- package/dist/useDisplayNames.mjs +54 -0
- package/dist/useDisplayNames.module.js +54 -0
- package/dist/useDisplayNames.module.js.map +1 -0
- package/dist/zh-CN.main.js +21 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +23 -0
- package/dist/zh-CN.module.js +23 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +21 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +23 -0
- package/dist/zh-TW.module.js +23 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +27 -18
- package/src/index.ts +12 -5
- package/src/useDateField.ts +163 -32
- package/src/useDatePicker.ts +113 -26
- package/src/useDatePickerGroup.ts +71 -13
- package/src/useDateRangePicker.ts +149 -38
- package/src/useDateSegment.ts +145 -91
- package/src/useDisplayNames.ts +10 -8
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var $51078838e1b16cd7$exports = {};
|
|
2
|
+
$51078838e1b16cd7$exports = {
|
|
3
|
+
"calendar": `\u{65E5}\u{5386}`,
|
|
4
|
+
"day": `\u{65E5}`,
|
|
5
|
+
"dayPeriod": `\u{4E0A}\u{5348}/\u{4E0B}\u{5348}`,
|
|
6
|
+
"endDate": `\u{7ED3}\u{675F}\u{65E5}\u{671F}`,
|
|
7
|
+
"era": `\u{7EAA}\u{5143}`,
|
|
8
|
+
"hour": `\u{5C0F}\u{65F6}`,
|
|
9
|
+
"minute": `\u{5206}\u{949F}`,
|
|
10
|
+
"month": `\u{6708}`,
|
|
11
|
+
"second": `\u{79D2}`,
|
|
12
|
+
"selectedDateDescription": (args)=>`\u{9009}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${args.date}`,
|
|
13
|
+
"selectedRangeDescription": (args)=>`\u{9009}\u{5B9A}\u{7684}\u{8303}\u{56F4}\u{FF1A}${args.startDate} \u{81F3} ${args.endDate}`,
|
|
14
|
+
"selectedTimeDescription": (args)=>`\u{9009}\u{5B9A}\u{7684}\u{65F6}\u{95F4}\u{FF1A}${args.time}`,
|
|
15
|
+
"startDate": `\u{5F00}\u{59CB}\u{65E5}\u{671F}`,
|
|
16
|
+
"timeZoneName": `\u{65F6}\u{533A}`,
|
|
17
|
+
"weekday": `\u{5DE5}\u{4F5C}\u{65E5}`,
|
|
18
|
+
"year": `\u{5E74}`
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export {$51078838e1b16cd7$exports as default};
|
|
23
|
+
//# sourceMappingURL=zh-CN.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,YAAY,CAAC,gBAAE,CAAC;IAClC,OAAO,CAAC,QAAC,CAAC;IACV,aAAa,CAAC,iCAAK,CAAC;IACpB,WAAW,CAAC,gCAAI,CAAC;IACjB,OAAO,CAAC,gBAAE,CAAC;IACX,QAAQ,CAAC,gBAAE,CAAC;IACZ,UAAU,CAAC,gBAAE,CAAC;IACd,SAAS,CAAC,QAAC,CAAC;IACZ,UAAU,CAAC,QAAC,CAAC;IACb,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,CAAC,CAAC;IACjF,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;IACzD,aAAa,CAAC,gCAAI,CAAC;IACnB,gBAAgB,CAAC,gBAAE,CAAC;IACpB,WAAW,CAAC,wBAAG,CAAC;IAChB,QAAQ,CAAC,QAAC,CAAC;AACb","sources":["packages/@react-aria/datepicker/intl/zh-CN.json"],"sourcesContent":["{\n \"calendar\": \"日历\",\n \"day\": \"日\",\n \"dayPeriod\": \"上午/下午\",\n \"endDate\": \"结束日期\",\n \"era\": \"纪元\",\n \"hour\": \"小时\",\n \"minute\": \"分钟\",\n \"month\": \"月\",\n \"second\": \"秒\",\n \"selectedDateDescription\": \"选定的日期:{date}\",\n \"selectedRangeDescription\": \"选定的范围:{startDate} 至 {endDate}\",\n \"selectedTimeDescription\": \"选定的时间:{time}\",\n \"startDate\": \"开始日期\",\n \"timeZoneName\": \"时区\",\n \"weekday\": \"工作日\",\n \"year\": \"年\"\n}\n"],"names":[],"version":3,"file":"zh-CN.module.js.map"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"calendar": `\u{65E5}\u{66C6}`,
|
|
3
|
+
"day": `\u{65E5}`,
|
|
4
|
+
"dayPeriod": `\u{4E0A}\u{5348}/\u{4E0B}\u{5348}`,
|
|
5
|
+
"endDate": `\u{7D50}\u{675F}\u{65E5}\u{671F}`,
|
|
6
|
+
"era": `\u{7EAA}\u{5143}`,
|
|
7
|
+
"hour": `\u{5C0F}\u{65F6}`,
|
|
8
|
+
"minute": `\u{5206}\u{949F}`,
|
|
9
|
+
"month": `\u{6708}`,
|
|
10
|
+
"second": `\u{79D2}`,
|
|
11
|
+
"selectedDateDescription": (args)=>`\u{9078}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${args.date}`,
|
|
12
|
+
"selectedRangeDescription": (args)=>`\u{9078}\u{5B9A}\u{7684}\u{7BC4}\u{570D}\u{FF1A}${args.startDate} \u{81F3} ${args.endDate}`,
|
|
13
|
+
"selectedTimeDescription": (args)=>`\u{9078}\u{5B9A}\u{7684}\u{6642}\u{9593}\u{FF1A}${args.time}`,
|
|
14
|
+
"startDate": `\u{958B}\u{59CB}\u{65E5}\u{671F}`,
|
|
15
|
+
"timeZoneName": `\u{65F6}\u{533A}`,
|
|
16
|
+
"weekday": `\u{5DE5}\u{4F5C}\u{65E5}`,
|
|
17
|
+
"year": `\u{5E74}`
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=zh-TW.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,YAAY,CAAC,gBAAE,CAAC;IAClC,OAAO,CAAC,QAAC,CAAC;IACV,aAAa,CAAC,iCAAK,CAAC;IACpB,WAAW,CAAC,gCAAI,CAAC;IACjB,OAAO,CAAC,gBAAE,CAAC;IACX,QAAQ,CAAC,gBAAE,CAAC;IACZ,UAAU,CAAC,gBAAE,CAAC;IACd,SAAS,CAAC,QAAC,CAAC;IACZ,UAAU,CAAC,QAAC,CAAC;IACb,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,CAAC,CAAC;IACjF,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;IACzD,aAAa,CAAC,gCAAI,CAAC;IACnB,gBAAgB,CAAC,gBAAE,CAAC;IACpB,WAAW,CAAC,wBAAG,CAAC;IAChB,QAAQ,CAAC,QAAC,CAAC;AACb","sources":["packages/@react-aria/datepicker/intl/zh-TW.json"],"sourcesContent":["{\n \"calendar\": \"日曆\",\n \"day\": \"日\",\n \"dayPeriod\": \"上午/下午\",\n \"endDate\": \"結束日期\",\n \"era\": \"纪元\",\n \"hour\": \"小时\",\n \"minute\": \"分钟\",\n \"month\": \"月\",\n \"second\": \"秒\",\n \"selectedDateDescription\": \"選定的日期:{date}\",\n \"selectedRangeDescription\": \"選定的範圍:{startDate} 至 {endDate}\",\n \"selectedTimeDescription\": \"選定的時間:{time}\",\n \"startDate\": \"開始日期\",\n \"timeZoneName\": \"时区\",\n \"weekday\": \"工作日\",\n \"year\": \"年\"\n}\n"],"names":[],"version":3,"file":"zh-TW.main.js.map"}
|
package/dist/zh-TW.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var $33fab8219207655a$exports = {};
|
|
2
|
+
$33fab8219207655a$exports = {
|
|
3
|
+
"calendar": `\u{65E5}\u{66C6}`,
|
|
4
|
+
"day": `\u{65E5}`,
|
|
5
|
+
"dayPeriod": `\u{4E0A}\u{5348}/\u{4E0B}\u{5348}`,
|
|
6
|
+
"endDate": `\u{7D50}\u{675F}\u{65E5}\u{671F}`,
|
|
7
|
+
"era": `\u{7EAA}\u{5143}`,
|
|
8
|
+
"hour": `\u{5C0F}\u{65F6}`,
|
|
9
|
+
"minute": `\u{5206}\u{949F}`,
|
|
10
|
+
"month": `\u{6708}`,
|
|
11
|
+
"second": `\u{79D2}`,
|
|
12
|
+
"selectedDateDescription": (args)=>`\u{9078}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${args.date}`,
|
|
13
|
+
"selectedRangeDescription": (args)=>`\u{9078}\u{5B9A}\u{7684}\u{7BC4}\u{570D}\u{FF1A}${args.startDate} \u{81F3} ${args.endDate}`,
|
|
14
|
+
"selectedTimeDescription": (args)=>`\u{9078}\u{5B9A}\u{7684}\u{6642}\u{9593}\u{FF1A}${args.time}`,
|
|
15
|
+
"startDate": `\u{958B}\u{59CB}\u{65E5}\u{671F}`,
|
|
16
|
+
"timeZoneName": `\u{65F6}\u{533A}`,
|
|
17
|
+
"weekday": `\u{5DE5}\u{4F5C}\u{65E5}`,
|
|
18
|
+
"year": `\u{5E74}`
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export {$33fab8219207655a$exports as default};
|
|
23
|
+
//# sourceMappingURL=zh-TW.module.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var $33fab8219207655a$exports = {};
|
|
2
|
+
$33fab8219207655a$exports = {
|
|
3
|
+
"calendar": `\u{65E5}\u{66C6}`,
|
|
4
|
+
"day": `\u{65E5}`,
|
|
5
|
+
"dayPeriod": `\u{4E0A}\u{5348}/\u{4E0B}\u{5348}`,
|
|
6
|
+
"endDate": `\u{7D50}\u{675F}\u{65E5}\u{671F}`,
|
|
7
|
+
"era": `\u{7EAA}\u{5143}`,
|
|
8
|
+
"hour": `\u{5C0F}\u{65F6}`,
|
|
9
|
+
"minute": `\u{5206}\u{949F}`,
|
|
10
|
+
"month": `\u{6708}`,
|
|
11
|
+
"second": `\u{79D2}`,
|
|
12
|
+
"selectedDateDescription": (args)=>`\u{9078}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${args.date}`,
|
|
13
|
+
"selectedRangeDescription": (args)=>`\u{9078}\u{5B9A}\u{7684}\u{7BC4}\u{570D}\u{FF1A}${args.startDate} \u{81F3} ${args.endDate}`,
|
|
14
|
+
"selectedTimeDescription": (args)=>`\u{9078}\u{5B9A}\u{7684}\u{6642}\u{9593}\u{FF1A}${args.time}`,
|
|
15
|
+
"startDate": `\u{958B}\u{59CB}\u{65E5}\u{671F}`,
|
|
16
|
+
"timeZoneName": `\u{65F6}\u{533A}`,
|
|
17
|
+
"weekday": `\u{5DE5}\u{4F5C}\u{65E5}`,
|
|
18
|
+
"year": `\u{5E74}`
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export {$33fab8219207655a$exports as default};
|
|
23
|
+
//# sourceMappingURL=zh-TW.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,YAAY,CAAC,gBAAE,CAAC;IAClC,OAAO,CAAC,QAAC,CAAC;IACV,aAAa,CAAC,iCAAK,CAAC;IACpB,WAAW,CAAC,gCAAI,CAAC;IACjB,OAAO,CAAC,gBAAE,CAAC;IACX,QAAQ,CAAC,gBAAE,CAAC;IACZ,UAAU,CAAC,gBAAE,CAAC;IACd,SAAS,CAAC,QAAC,CAAC;IACZ,UAAU,CAAC,QAAC,CAAC;IACb,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,CAAC,CAAC;IACjF,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;IACzD,aAAa,CAAC,gCAAI,CAAC;IACnB,gBAAgB,CAAC,gBAAE,CAAC;IACpB,WAAW,CAAC,wBAAG,CAAC;IAChB,QAAQ,CAAC,QAAC,CAAC;AACb","sources":["packages/@react-aria/datepicker/intl/zh-TW.json"],"sourcesContent":["{\n \"calendar\": \"日曆\",\n \"day\": \"日\",\n \"dayPeriod\": \"上午/下午\",\n \"endDate\": \"結束日期\",\n \"era\": \"纪元\",\n \"hour\": \"小时\",\n \"minute\": \"分钟\",\n \"month\": \"月\",\n \"second\": \"秒\",\n \"selectedDateDescription\": \"選定的日期:{date}\",\n \"selectedRangeDescription\": \"選定的範圍:{startDate} 至 {endDate}\",\n \"selectedTimeDescription\": \"選定的時間:{time}\",\n \"startDate\": \"開始日期\",\n \"timeZoneName\": \"时区\",\n \"weekday\": \"工作日\",\n \"year\": \"年\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/datepicker",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.3114+68403fe55",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
8
13
|
"types": "dist/types.d.ts",
|
|
9
14
|
"source": "src/index.ts",
|
|
10
15
|
"files": [
|
|
@@ -17,27 +22,31 @@
|
|
|
17
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
18
23
|
},
|
|
19
24
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@internationalized/
|
|
22
|
-
"@internationalized/
|
|
23
|
-
"@react-aria/focus": "3.0.0-nightly.
|
|
24
|
-
"@react-aria/
|
|
25
|
-
"@react-aria/
|
|
26
|
-
"@react-aria/
|
|
27
|
-
"@react-aria/
|
|
28
|
-
"@react-aria/
|
|
29
|
-
"@react-
|
|
30
|
-
"@react-
|
|
31
|
-
"@react-
|
|
32
|
-
"@react-types/
|
|
33
|
-
"@react-types/
|
|
25
|
+
"@internationalized/date": "3.5.6-nightly.5042+68403fe55",
|
|
26
|
+
"@internationalized/number": "3.5.4-nightly.5042+68403fe55",
|
|
27
|
+
"@internationalized/string": "3.2.4-nightly.5042+68403fe55",
|
|
28
|
+
"@react-aria/focus": "3.0.0-nightly.3114+68403fe55",
|
|
29
|
+
"@react-aria/form": "3.0.9-nightly.5042+68403fe55",
|
|
30
|
+
"@react-aria/i18n": "3.0.0-nightly.3114+68403fe55",
|
|
31
|
+
"@react-aria/interactions": "3.0.0-nightly.3114+68403fe55",
|
|
32
|
+
"@react-aria/label": "3.0.0-nightly.3114+68403fe55",
|
|
33
|
+
"@react-aria/spinbutton": "3.0.0-nightly.3114+68403fe55",
|
|
34
|
+
"@react-aria/utils": "3.0.0-nightly.3114+68403fe55",
|
|
35
|
+
"@react-stately/datepicker": "3.0.0-nightly.3114+68403fe55",
|
|
36
|
+
"@react-stately/form": "3.0.6-nightly.5042+68403fe55",
|
|
37
|
+
"@react-types/button": "3.9.7-nightly.5042+68403fe55",
|
|
38
|
+
"@react-types/calendar": "3.0.0-nightly.3114+68403fe55",
|
|
39
|
+
"@react-types/datepicker": "3.0.0-nightly.3114+68403fe55",
|
|
40
|
+
"@react-types/dialog": "3.5.13-nightly.5042+68403fe55",
|
|
41
|
+
"@react-types/shared": "3.0.0-nightly.3114+68403fe55",
|
|
42
|
+
"@swc/helpers": "^0.5.0"
|
|
34
43
|
},
|
|
35
44
|
"peerDependencies": {
|
|
36
|
-
"react": "^16.8.0 || ^17.0.0-rc.1",
|
|
37
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1"
|
|
45
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
46
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
38
47
|
},
|
|
39
48
|
"publishConfig": {
|
|
40
49
|
"access": "public"
|
|
41
50
|
},
|
|
42
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "68403fe55489dce3de1b3094c957d598ad719861"
|
|
43
52
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,8 +10,15 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
13
|
+
export {useDatePicker} from './useDatePicker';
|
|
14
|
+
export {useDateSegment} from './useDateSegment';
|
|
15
|
+
export {useDateField, useTimeField} from './useDateField';
|
|
16
|
+
export {useDateRangePicker} from './useDateRangePicker';
|
|
17
|
+
export {useDisplayNames} from './useDisplayNames';
|
|
18
|
+
|
|
19
|
+
export type {AriaDateFieldProps, AriaDatePickerProps, AriaDateRangePickerProps, DateRange, DateValue, TimeValue} from '@react-types/datepicker';
|
|
20
|
+
export type {AriaDateFieldOptions, DateFieldAria} from './useDateField';
|
|
21
|
+
export type {DatePickerAria} from './useDatePicker';
|
|
22
|
+
export type {DateRangePickerAria} from './useDateRangePicker';
|
|
23
|
+
export type {DateSegmentAria} from './useDateSegment';
|
|
24
|
+
export type {AriaTimeFieldProps} from '@react-types/datepicker';
|
package/src/useDateField.ts
CHANGED
|
@@ -10,69 +10,200 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import {createFocusManager} from '@react-aria/focus';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {mergeProps, useDescription} from '@react-aria/utils';
|
|
18
|
-
import {
|
|
13
|
+
import {AriaDateFieldProps as AriaDateFieldPropsBase, AriaTimeFieldProps, DateValue, TimeValue} from '@react-types/datepicker';
|
|
14
|
+
import {createFocusManager, FocusManager} from '@react-aria/focus';
|
|
15
|
+
import {DateFieldState, TimeFieldState} from '@react-stately/datepicker';
|
|
16
|
+
import {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';
|
|
17
|
+
import {filterDOMProps, mergeProps, useDescription, useFormReset} from '@react-aria/utils';
|
|
18
|
+
import {InputHTMLAttributes, useEffect, useMemo, useRef} from 'react';
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
import intlMessages from '../intl/*.json';
|
|
19
21
|
import {useDatePickerGroup} from './useDatePickerGroup';
|
|
20
22
|
import {useField} from '@react-aria/label';
|
|
21
23
|
import {useFocusWithin} from '@react-aria/interactions';
|
|
24
|
+
import {useFormValidation} from '@react-aria/form';
|
|
25
|
+
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
22
26
|
|
|
23
27
|
// Allows this hook to also be used with TimeField
|
|
24
|
-
interface
|
|
28
|
+
export interface AriaDateFieldOptions<T extends DateValue> extends Omit<AriaDateFieldPropsBase<T>, 'value' | 'defaultValue' | 'onChange' | 'minValue' | 'maxValue' | 'placeholderValue' | 'validate'> {
|
|
29
|
+
/** A ref for the hidden input element for HTML form submission. */
|
|
30
|
+
inputRef?: RefObject<HTMLInputElement | null>
|
|
31
|
+
}
|
|
25
32
|
|
|
26
|
-
interface DateFieldAria {
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
export interface DateFieldAria extends ValidationResult {
|
|
34
|
+
/** Props for the field's visible label element, if any. */
|
|
35
|
+
labelProps: DOMAttributes,
|
|
36
|
+
/** Props for the field grouping element. */
|
|
37
|
+
fieldProps: GroupDOMAttributes,
|
|
38
|
+
/** Props for the hidden input element for HTML form submission. */
|
|
39
|
+
inputProps: InputHTMLAttributes<HTMLInputElement>,
|
|
29
40
|
/** Props for the description element, if any. */
|
|
30
|
-
descriptionProps:
|
|
41
|
+
descriptionProps: DOMAttributes,
|
|
31
42
|
/** Props for the error message element, if any. */
|
|
32
|
-
errorMessageProps:
|
|
43
|
+
errorMessageProps: DOMAttributes
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Data that is passed between useDateField and useDateSegment.
|
|
47
|
+
interface HookData {
|
|
48
|
+
ariaLabel: string,
|
|
49
|
+
ariaLabelledBy: string,
|
|
50
|
+
ariaDescribedBy: string,
|
|
51
|
+
focusManager: FocusManager
|
|
33
52
|
}
|
|
34
53
|
|
|
35
|
-
export const
|
|
54
|
+
export const hookData = new WeakMap<DateFieldState, HookData>();
|
|
55
|
+
|
|
56
|
+
// Private props that we pass from useDatePicker/useDateRangePicker.
|
|
57
|
+
// Ideally we'd use a Symbol for this, but React doesn't support them: https://github.com/facebook/react/issues/7552
|
|
58
|
+
export const roleSymbol = '__role_' + Date.now();
|
|
59
|
+
export const focusManagerSymbol = '__focusManager_' + Date.now();
|
|
36
60
|
|
|
37
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Provides the behavior and accessibility implementation for a date field component.
|
|
63
|
+
* A date field allows users to enter and edit date and time values using a keyboard.
|
|
64
|
+
* Each part of a date value is displayed in an individually editable segment.
|
|
65
|
+
*/
|
|
66
|
+
export function useDateField<T extends DateValue>(props: AriaDateFieldOptions<T>, state: DateFieldState, ref: RefObject<Element | null>): DateFieldAria {
|
|
67
|
+
let {isInvalid, validationErrors, validationDetails} = state.displayValidation;
|
|
38
68
|
let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
|
|
39
69
|
...props,
|
|
40
|
-
labelElementType: 'span'
|
|
70
|
+
labelElementType: 'span',
|
|
71
|
+
isInvalid,
|
|
72
|
+
errorMessage: props.errorMessage || validationErrors
|
|
41
73
|
});
|
|
42
74
|
|
|
43
|
-
let
|
|
44
|
-
|
|
75
|
+
let valueOnFocus = useRef<DateValue | null>(null);
|
|
45
76
|
let {focusWithinProps} = useFocusWithin({
|
|
46
|
-
|
|
77
|
+
...props,
|
|
78
|
+
onFocusWithin(e) {
|
|
79
|
+
valueOnFocus.current = state.value;
|
|
80
|
+
props.onFocus?.(e);
|
|
81
|
+
},
|
|
82
|
+
onBlurWithin: (e) => {
|
|
47
83
|
state.confirmPlaceholder();
|
|
48
|
-
|
|
84
|
+
if (state.value !== valueOnFocus.current) {
|
|
85
|
+
state.commitValidation();
|
|
86
|
+
}
|
|
87
|
+
props.onBlur?.(e);
|
|
88
|
+
},
|
|
89
|
+
onFocusWithinChange: props.onFocusChange
|
|
49
90
|
});
|
|
50
91
|
|
|
51
|
-
let
|
|
52
|
-
let
|
|
92
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');
|
|
93
|
+
let message = state.maxGranularity === 'hour' ? 'selectedTimeDescription' : 'selectedDateDescription';
|
|
94
|
+
let field = state.maxGranularity === 'hour' ? 'time' : 'date';
|
|
95
|
+
let description = state.value ? stringFormatter.format(message, {[field]: state.formatValue({month: 'long'})}) : '';
|
|
96
|
+
let descProps = useDescription(description);
|
|
53
97
|
|
|
54
|
-
|
|
55
|
-
|
|
98
|
+
// If within a date picker or date range picker, the date field will have role="presentation" and an aria-describedby
|
|
99
|
+
// will be passed in that references the value (e.g. entire range). Otherwise, add the field's value description.
|
|
100
|
+
let describedBy = props[roleSymbol] === 'presentation'
|
|
101
|
+
? fieldProps['aria-describedby']
|
|
102
|
+
: [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;
|
|
103
|
+
let propsFocusManager = props[focusManagerSymbol];
|
|
104
|
+
let focusManager = useMemo(() => propsFocusManager || createFocusManager(ref), [propsFocusManager, ref]);
|
|
105
|
+
let groupProps = useDatePickerGroup(state, ref, props[roleSymbol] === 'presentation');
|
|
56
106
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
107
|
+
// Pass labels and other information to segments.
|
|
108
|
+
hookData.set(state, {
|
|
109
|
+
ariaLabel: props['aria-label'],
|
|
110
|
+
ariaLabelledBy: [labelProps.id, props['aria-labelledby']].filter(Boolean).join(' ') || undefined,
|
|
111
|
+
ariaDescribedBy: describedBy,
|
|
112
|
+
focusManager
|
|
60
113
|
});
|
|
61
114
|
|
|
115
|
+
let autoFocusRef = useRef(props.autoFocus);
|
|
116
|
+
|
|
117
|
+
// When used within a date picker or date range picker, the field gets role="presentation"
|
|
118
|
+
// rather than role="group". Since the date picker/date range picker already has a role="group"
|
|
119
|
+
// with a label and description, and the segments are already labeled by this as well, this
|
|
120
|
+
// avoids very verbose duplicate announcements.
|
|
121
|
+
let fieldDOMProps: GroupDOMAttributes;
|
|
122
|
+
if (props[roleSymbol] === 'presentation') {
|
|
123
|
+
fieldDOMProps = {
|
|
124
|
+
role: 'presentation'
|
|
125
|
+
};
|
|
126
|
+
} else {
|
|
127
|
+
fieldDOMProps = mergeProps(fieldProps, {
|
|
128
|
+
role: 'group' as const,
|
|
129
|
+
'aria-disabled': props.isDisabled || undefined,
|
|
130
|
+
'aria-describedby': describedBy
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (autoFocusRef.current) {
|
|
136
|
+
focusManager.focusFirst();
|
|
137
|
+
}
|
|
138
|
+
autoFocusRef.current = false;
|
|
139
|
+
}, [focusManager]);
|
|
140
|
+
|
|
141
|
+
useFormReset(props.inputRef, state.value, state.setValue);
|
|
142
|
+
useFormValidation({
|
|
143
|
+
...props,
|
|
144
|
+
focus() {
|
|
145
|
+
focusManager.focusFirst();
|
|
146
|
+
}
|
|
147
|
+
}, state, props.inputRef);
|
|
148
|
+
|
|
149
|
+
let inputProps: InputHTMLAttributes<HTMLInputElement> = {
|
|
150
|
+
type: 'hidden',
|
|
151
|
+
name: props.name,
|
|
152
|
+
value: state.value?.toString() || '',
|
|
153
|
+
disabled: props.isDisabled
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
if (props.validationBehavior === 'native') {
|
|
157
|
+
// Use a hidden <input type="text"> rather than <input type="hidden">
|
|
158
|
+
// so that an empty value blocks HTML form submission when the field is required.
|
|
159
|
+
inputProps.type = 'text';
|
|
160
|
+
inputProps.hidden = true;
|
|
161
|
+
inputProps.required = props.isRequired;
|
|
162
|
+
// Ignore react warning.
|
|
163
|
+
inputProps.onChange = () => {};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let domProps = filterDOMProps(props);
|
|
62
167
|
return {
|
|
63
168
|
labelProps: {
|
|
64
169
|
...labelProps,
|
|
65
170
|
onClick: () => {
|
|
66
|
-
let focusManager = createFocusManager(ref);
|
|
67
171
|
focusManager.focusFirst();
|
|
68
172
|
}
|
|
69
173
|
},
|
|
70
|
-
fieldProps: mergeProps(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
174
|
+
fieldProps: mergeProps(domProps, fieldDOMProps, groupProps, focusWithinProps, {
|
|
175
|
+
onKeyDown(e: KeyboardEvent) {
|
|
176
|
+
if (props.onKeyDown) {
|
|
177
|
+
props.onKeyDown(e);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
onKeyUp(e: KeyboardEvent) {
|
|
181
|
+
if (props.onKeyUp) {
|
|
182
|
+
props.onKeyUp(e);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
74
185
|
}),
|
|
186
|
+
inputProps,
|
|
75
187
|
descriptionProps,
|
|
76
|
-
errorMessageProps
|
|
188
|
+
errorMessageProps,
|
|
189
|
+
isInvalid,
|
|
190
|
+
validationErrors,
|
|
191
|
+
validationDetails
|
|
77
192
|
};
|
|
78
193
|
}
|
|
194
|
+
|
|
195
|
+
export interface AriaTimeFieldOptions<T extends TimeValue> extends AriaTimeFieldProps<T> {
|
|
196
|
+
/** A ref for the hidden input element for HTML form submission. */
|
|
197
|
+
inputRef?: RefObject<HTMLInputElement | null>
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Provides the behavior and accessibility implementation for a time field component.
|
|
202
|
+
* A time field allows users to enter and edit time values using a keyboard.
|
|
203
|
+
* Each part of a time value is displayed in an individually editable segment.
|
|
204
|
+
*/
|
|
205
|
+
export function useTimeField<T extends TimeValue>(props: AriaTimeFieldOptions<T>, state: TimeFieldState, ref: RefObject<Element | null>): DateFieldAria {
|
|
206
|
+
let res = useDateField(props, state, ref);
|
|
207
|
+
res.inputProps.value = state.timeValue?.toString() || '';
|
|
208
|
+
return res;
|
|
209
|
+
}
|
package/src/useDatePicker.ts
CHANGED
|
@@ -13,36 +13,56 @@
|
|
|
13
13
|
import {AriaButtonProps} from '@react-types/button';
|
|
14
14
|
import {AriaDatePickerProps, DateValue} from '@react-types/datepicker';
|
|
15
15
|
import {AriaDialogProps} from '@react-types/dialog';
|
|
16
|
+
import {CalendarProps} from '@react-types/calendar';
|
|
16
17
|
import {createFocusManager} from '@react-aria/focus';
|
|
17
18
|
import {DatePickerState} from '@react-stately/datepicker';
|
|
18
|
-
import {
|
|
19
|
+
import {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';
|
|
20
|
+
import {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';
|
|
19
21
|
// @ts-ignore
|
|
20
22
|
import intlMessages from '../intl/*.json';
|
|
21
|
-
import {
|
|
23
|
+
import {privateValidationStateProp} from '@react-stately/form';
|
|
24
|
+
import {roleSymbol} from './useDateField';
|
|
22
25
|
import {useDatePickerGroup} from './useDatePickerGroup';
|
|
23
26
|
import {useField} from '@react-aria/label';
|
|
24
|
-
import {
|
|
27
|
+
import {useFocusWithin} from '@react-aria/interactions';
|
|
28
|
+
import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
29
|
+
import {useMemo} from 'react';
|
|
25
30
|
|
|
26
|
-
interface DatePickerAria
|
|
27
|
-
|
|
28
|
-
labelProps:
|
|
29
|
-
|
|
31
|
+
export interface DatePickerAria extends ValidationResult {
|
|
32
|
+
/** Props for the date picker's visible label element, if any. */
|
|
33
|
+
labelProps: DOMAttributes,
|
|
34
|
+
/** Props for the grouping element containing the date field and button. */
|
|
35
|
+
groupProps: GroupDOMAttributes,
|
|
36
|
+
/** Props for the date field. */
|
|
37
|
+
fieldProps: AriaDatePickerProps<DateValue>,
|
|
38
|
+
/** Props for the popover trigger button. */
|
|
39
|
+
buttonProps: AriaButtonProps,
|
|
30
40
|
/** Props for the description element, if any. */
|
|
31
|
-
descriptionProps:
|
|
41
|
+
descriptionProps: DOMAttributes,
|
|
32
42
|
/** Props for the error message element, if any. */
|
|
33
|
-
errorMessageProps:
|
|
34
|
-
|
|
35
|
-
dialogProps: AriaDialogProps
|
|
43
|
+
errorMessageProps: DOMAttributes,
|
|
44
|
+
/** Props for the popover dialog. */
|
|
45
|
+
dialogProps: AriaDialogProps,
|
|
46
|
+
/** Props for the calendar within the popover dialog. */
|
|
47
|
+
calendarProps: CalendarProps<DateValue>
|
|
36
48
|
}
|
|
37
49
|
|
|
38
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Provides the behavior and accessibility implementation for a date picker component.
|
|
52
|
+
* A date picker combines a DateField and a Calendar popover to allow users to enter or select a date and time value.
|
|
53
|
+
*/
|
|
54
|
+
export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element | null>): DatePickerAria {
|
|
39
55
|
let buttonId = useId();
|
|
40
56
|
let dialogId = useId();
|
|
41
|
-
let
|
|
57
|
+
let fieldId = useId();
|
|
58
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');
|
|
42
59
|
|
|
60
|
+
let {isInvalid, validationErrors, validationDetails} = state.displayValidation;
|
|
43
61
|
let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
|
|
44
62
|
...props,
|
|
45
|
-
labelElementType: 'span'
|
|
63
|
+
labelElementType: 'span',
|
|
64
|
+
isInvalid,
|
|
65
|
+
errorMessage: props.errorMessage || validationErrors
|
|
46
66
|
});
|
|
47
67
|
|
|
48
68
|
let groupProps = useDatePickerGroup(state, ref);
|
|
@@ -50,38 +70,105 @@ export function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>
|
|
|
50
70
|
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
51
71
|
|
|
52
72
|
let {locale} = useLocale();
|
|
53
|
-
let
|
|
73
|
+
let date = state.formatValue(locale, {month: 'long'});
|
|
74
|
+
let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';
|
|
75
|
+
let descProps = useDescription(description);
|
|
54
76
|
let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;
|
|
77
|
+
let domProps = filterDOMProps(props);
|
|
78
|
+
let focusManager = useMemo(() => createFocusManager(ref), [ref]);
|
|
79
|
+
|
|
80
|
+
let {focusWithinProps} = useFocusWithin({
|
|
81
|
+
...props,
|
|
82
|
+
isDisabled: state.isOpen,
|
|
83
|
+
onBlurWithin: props.onBlur,
|
|
84
|
+
onFocusWithin: props.onFocus,
|
|
85
|
+
onFocusWithinChange: props.onFocusChange
|
|
86
|
+
});
|
|
55
87
|
|
|
56
88
|
return {
|
|
57
|
-
groupProps: mergeProps(groupProps, descProps, {
|
|
58
|
-
role: 'group',
|
|
89
|
+
groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
|
|
90
|
+
role: 'group' as const,
|
|
59
91
|
'aria-disabled': props.isDisabled || null,
|
|
60
92
|
'aria-labelledby': labelledBy,
|
|
61
|
-
'aria-describedby': ariaDescribedBy
|
|
93
|
+
'aria-describedby': ariaDescribedBy,
|
|
94
|
+
onKeyDown(e: KeyboardEvent) {
|
|
95
|
+
if (state.isOpen) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (props.onKeyDown) {
|
|
100
|
+
props.onKeyDown(e);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
onKeyUp(e: KeyboardEvent) {
|
|
104
|
+
if (state.isOpen) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (props.onKeyUp) {
|
|
109
|
+
props.onKeyUp(e);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
62
112
|
}),
|
|
63
113
|
labelProps: {
|
|
64
114
|
...labelProps,
|
|
65
115
|
onClick: () => {
|
|
66
|
-
let focusManager = createFocusManager(ref);
|
|
67
116
|
focusManager.focusFirst();
|
|
68
117
|
}
|
|
69
118
|
},
|
|
70
|
-
fieldProps
|
|
119
|
+
fieldProps: {
|
|
120
|
+
...fieldProps,
|
|
121
|
+
id: fieldId,
|
|
122
|
+
[roleSymbol]: 'presentation',
|
|
123
|
+
'aria-describedby': ariaDescribedBy,
|
|
124
|
+
value: state.value,
|
|
125
|
+
onChange: state.setValue,
|
|
126
|
+
placeholderValue: props.placeholderValue,
|
|
127
|
+
hideTimeZone: props.hideTimeZone,
|
|
128
|
+
hourCycle: props.hourCycle,
|
|
129
|
+
shouldForceLeadingZeros: props.shouldForceLeadingZeros,
|
|
130
|
+
granularity: props.granularity,
|
|
131
|
+
isDisabled: props.isDisabled,
|
|
132
|
+
isReadOnly: props.isReadOnly,
|
|
133
|
+
isRequired: props.isRequired,
|
|
134
|
+
validationBehavior: props.validationBehavior,
|
|
135
|
+
// DatePicker owns the validation state for the date field.
|
|
136
|
+
[privateValidationStateProp]: state,
|
|
137
|
+
autoFocus: props.autoFocus,
|
|
138
|
+
name: props.name
|
|
139
|
+
},
|
|
71
140
|
descriptionProps,
|
|
72
141
|
errorMessageProps,
|
|
73
142
|
buttonProps: {
|
|
74
143
|
...descProps,
|
|
75
144
|
id: buttonId,
|
|
76
|
-
excludeFromTabOrder: true,
|
|
77
145
|
'aria-haspopup': 'dialog',
|
|
78
|
-
'aria-label':
|
|
79
|
-
'aria-labelledby': `${
|
|
80
|
-
'aria-describedby': ariaDescribedBy
|
|
146
|
+
'aria-label': stringFormatter.format('calendar'),
|
|
147
|
+
'aria-labelledby': `${buttonId} ${labelledBy}`,
|
|
148
|
+
'aria-describedby': ariaDescribedBy,
|
|
149
|
+
'aria-expanded': state.isOpen,
|
|
150
|
+
isDisabled: props.isDisabled || props.isReadOnly,
|
|
151
|
+
onPress: () => state.setOpen(true)
|
|
81
152
|
},
|
|
82
153
|
dialogProps: {
|
|
83
154
|
id: dialogId,
|
|
84
|
-
'aria-labelledby': `${
|
|
85
|
-
}
|
|
155
|
+
'aria-labelledby': `${buttonId} ${labelledBy}`
|
|
156
|
+
},
|
|
157
|
+
calendarProps: {
|
|
158
|
+
autoFocus: true,
|
|
159
|
+
value: state.dateValue,
|
|
160
|
+
onChange: state.setDateValue,
|
|
161
|
+
minValue: props.minValue,
|
|
162
|
+
maxValue: props.maxValue,
|
|
163
|
+
isDisabled: props.isDisabled,
|
|
164
|
+
isReadOnly: props.isReadOnly,
|
|
165
|
+
isDateUnavailable: props.isDateUnavailable,
|
|
166
|
+
defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
|
|
167
|
+
isInvalid: state.isInvalid,
|
|
168
|
+
errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' '))
|
|
169
|
+
},
|
|
170
|
+
isInvalid,
|
|
171
|
+
validationErrors,
|
|
172
|
+
validationDetails
|
|
86
173
|
};
|
|
87
174
|
}
|