@react-aria/datepicker 3.16.0 → 3.17.0
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/import.mjs +6 -6
- package/dist/main.js +11 -11
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -6
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +12 -0
- package/package.json +16 -28
- package/src/index.ts +13 -11
- package/dist/ar-AE.main.js +0 -21
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -23
- package/dist/ar-AE.module.js +0 -23
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -21
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -23
- package/dist/bg-BG.module.js +0 -23
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -21
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -23
- package/dist/cs-CZ.module.js +0 -23
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -21
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -23
- package/dist/da-DK.module.js +0 -23
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -21
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -23
- package/dist/de-DE.module.js +0 -23
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -21
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -23
- package/dist/el-GR.module.js +0 -23
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -21
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -23
- package/dist/en-US.module.js +0 -23
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -21
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -23
- package/dist/es-ES.module.js +0 -23
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -21
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -23
- package/dist/et-EE.module.js +0 -23
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -21
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -23
- package/dist/fi-FI.module.js +0 -23
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -21
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -23
- package/dist/fr-FR.module.js +0 -23
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -21
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -23
- package/dist/he-IL.module.js +0 -23
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -21
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -23
- package/dist/hr-HR.module.js +0 -23
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -21
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -23
- package/dist/hu-HU.module.js +0 -23
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -21
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -23
- package/dist/it-IT.module.js +0 -23
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -21
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -23
- package/dist/ja-JP.module.js +0 -23
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -21
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -23
- package/dist/ko-KR.module.js +0 -23
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -21
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -23
- package/dist/lt-LT.module.js +0 -23
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -21
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -23
- package/dist/lv-LV.module.js +0 -23
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -21
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -23
- package/dist/nb-NO.module.js +0 -23
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -21
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -23
- package/dist/nl-NL.module.js +0 -23
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -21
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -23
- package/dist/pl-PL.module.js +0 -23
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -21
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -23
- package/dist/pt-BR.module.js +0 -23
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -21
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -23
- package/dist/pt-PT.module.js +0 -23
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -21
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -23
- package/dist/ro-RO.module.js +0 -23
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -21
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -23
- package/dist/ru-RU.module.js +0 -23
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -21
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -23
- package/dist/sk-SK.module.js +0 -23
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -21
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -23
- package/dist/sl-SI.module.js +0 -23
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -21
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -23
- package/dist/sr-SP.module.js +0 -23
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -21
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -23
- package/dist/sv-SE.module.js +0 -23
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -21
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -23
- package/dist/tr-TR.module.js +0 -23
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -108
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -21
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -23
- package/dist/uk-UA.module.js +0 -23
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/useDateField.main.js +0 -181
- package/dist/useDateField.main.js.map +0 -1
- package/dist/useDateField.mjs +0 -172
- package/dist/useDateField.module.js +0 -172
- package/dist/useDateField.module.js.map +0 -1
- package/dist/useDatePicker.main.js +0 -178
- package/dist/useDatePicker.main.js.map +0 -1
- package/dist/useDatePicker.mjs +0 -173
- package/dist/useDatePicker.module.js +0 -173
- package/dist/useDatePicker.module.js.map +0 -1
- package/dist/useDatePickerGroup.main.js +0 -121
- package/dist/useDatePickerGroup.main.js.map +0 -1
- package/dist/useDatePickerGroup.mjs +0 -116
- package/dist/useDatePickerGroup.module.js +0 -116
- package/dist/useDatePickerGroup.module.js.map +0 -1
- package/dist/useDateRangePicker.main.js +0 -224
- package/dist/useDateRangePicker.main.js.map +0 -1
- package/dist/useDateRangePicker.mjs +0 -219
- package/dist/useDateRangePicker.module.js +0 -219
- package/dist/useDateRangePicker.module.js.map +0 -1
- package/dist/useDateSegment.main.js +0 -370
- package/dist/useDateSegment.main.js.map +0 -1
- package/dist/useDateSegment.mjs +0 -361
- package/dist/useDateSegment.module.js +0 -361
- package/dist/useDateSegment.module.js.map +0 -1
- package/dist/useDisplayNames.main.js +0 -58
- package/dist/useDisplayNames.main.js.map +0 -1
- package/dist/useDisplayNames.mjs +0 -53
- package/dist/useDisplayNames.module.js +0 -53
- package/dist/useDisplayNames.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -21
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -23
- package/dist/zh-CN.module.js +0 -23
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -21
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -23
- package/dist/zh-TW.module.js +0 -23
- package/dist/zh-TW.module.js.map +0 -1
- package/src/useDateField.ts +0 -213
- package/src/useDatePicker.ts +0 -192
- package/src/useDatePickerGroup.ts +0 -138
- package/src/useDateRangePicker.ts +0 -243
- package/src/useDateSegment.ts +0 -413
- package/src/useDisplayNames.ts +0 -51
package/dist/zh-CN.module.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
package/dist/zh-CN.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EAAE;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,EAAE;IACjF,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,EAAE;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"}
|
package/dist/zh-TW.main.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
package/dist/zh-TW.main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EAAE;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,EAAE;IACjF,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,EAAE;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
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
package/dist/zh-TW.module.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
package/dist/zh-TW.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EAAE;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,EAAE;IACjF,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,EAAE;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/src/useDateField.ts
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
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';
|
|
21
|
-
import {useDatePickerGroup} from './useDatePickerGroup';
|
|
22
|
-
import {useField} from '@react-aria/label';
|
|
23
|
-
import {useFocusWithin} from '@react-aria/interactions';
|
|
24
|
-
import {useFormValidation} from '@react-aria/form';
|
|
25
|
-
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
26
|
-
|
|
27
|
-
// Allows this hook to also be used with TimeField
|
|
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
|
-
}
|
|
32
|
-
|
|
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>,
|
|
40
|
-
/** Props for the description element, if any. */
|
|
41
|
-
descriptionProps: DOMAttributes,
|
|
42
|
-
/** Props for the error message element, if any. */
|
|
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
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const hookData: WeakMap<DateFieldState, 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: string = '__role_' + Date.now();
|
|
59
|
-
export const focusManagerSymbol: string = '__focusManager_' + Date.now();
|
|
60
|
-
|
|
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;
|
|
68
|
-
let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
|
|
69
|
-
...props,
|
|
70
|
-
labelElementType: 'span',
|
|
71
|
-
isInvalid,
|
|
72
|
-
errorMessage: props.errorMessage || validationErrors
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
let valueOnFocus = useRef<DateValue | null>(null);
|
|
76
|
-
let {focusWithinProps} = useFocusWithin({
|
|
77
|
-
...props,
|
|
78
|
-
onFocusWithin(e) {
|
|
79
|
-
valueOnFocus.current = state.value;
|
|
80
|
-
props.onFocus?.(e);
|
|
81
|
-
},
|
|
82
|
-
onBlurWithin: (e) => {
|
|
83
|
-
state.confirmPlaceholder();
|
|
84
|
-
if (state.value !== valueOnFocus.current) {
|
|
85
|
-
state.commitValidation();
|
|
86
|
-
}
|
|
87
|
-
props.onBlur?.(e);
|
|
88
|
-
},
|
|
89
|
-
onFocusWithinChange: props.onFocusChange
|
|
90
|
-
});
|
|
91
|
-
|
|
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);
|
|
97
|
-
|
|
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');
|
|
106
|
-
|
|
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
|
|
113
|
-
});
|
|
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.defaultValue, 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
|
-
form: props.form,
|
|
153
|
-
value: state.value?.toString() || '',
|
|
154
|
-
disabled: props.isDisabled
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
if (props.validationBehavior === 'native') {
|
|
158
|
-
// Use a hidden <input type="text"> rather than <input type="hidden">
|
|
159
|
-
// so that an empty value blocks HTML form submission when the field is required.
|
|
160
|
-
inputProps.type = 'text';
|
|
161
|
-
inputProps.hidden = true;
|
|
162
|
-
inputProps.required = props.isRequired;
|
|
163
|
-
// Ignore react warning.
|
|
164
|
-
inputProps.onChange = () => {};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
let domProps = filterDOMProps(props);
|
|
168
|
-
return {
|
|
169
|
-
labelProps: {
|
|
170
|
-
...labelProps,
|
|
171
|
-
onClick: () => {
|
|
172
|
-
focusManager.focusFirst();
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
fieldProps: mergeProps(domProps, fieldDOMProps, groupProps, focusWithinProps, {
|
|
176
|
-
onKeyDown(e: KeyboardEvent) {
|
|
177
|
-
if (props.onKeyDown) {
|
|
178
|
-
props.onKeyDown(e);
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
onKeyUp(e: KeyboardEvent) {
|
|
182
|
-
if (props.onKeyUp) {
|
|
183
|
-
props.onKeyUp(e);
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
style: {
|
|
187
|
-
unicodeBidi: 'isolate'
|
|
188
|
-
}
|
|
189
|
-
}),
|
|
190
|
-
inputProps,
|
|
191
|
-
descriptionProps,
|
|
192
|
-
errorMessageProps,
|
|
193
|
-
isInvalid,
|
|
194
|
-
validationErrors,
|
|
195
|
-
validationDetails
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export interface AriaTimeFieldOptions<T extends TimeValue> extends AriaTimeFieldProps<T> {
|
|
200
|
-
/** A ref for the hidden input element for HTML form submission. */
|
|
201
|
-
inputRef?: RefObject<HTMLInputElement | null>
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Provides the behavior and accessibility implementation for a time field component.
|
|
206
|
-
* A time field allows users to enter and edit time values using a keyboard.
|
|
207
|
-
* Each part of a time value is displayed in an individually editable segment.
|
|
208
|
-
*/
|
|
209
|
-
export function useTimeField<T extends TimeValue>(props: AriaTimeFieldOptions<T>, state: TimeFieldState, ref: RefObject<Element | null>): DateFieldAria {
|
|
210
|
-
let res = useDateField(props, state, ref);
|
|
211
|
-
res.inputProps.value = state.timeValue?.toString() || '';
|
|
212
|
-
return res;
|
|
213
|
-
}
|
package/src/useDatePicker.ts
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {AriaButtonProps} from '@react-types/button';
|
|
14
|
-
import {AriaDatePickerProps, DateValue} from '@react-types/datepicker';
|
|
15
|
-
import {AriaDialogProps} from '@react-types/dialog';
|
|
16
|
-
import {CalendarProps} from '@react-types/calendar';
|
|
17
|
-
import {createFocusManager} from '@react-aria/focus';
|
|
18
|
-
import {DatePickerState} from '@react-stately/datepicker';
|
|
19
|
-
import {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';
|
|
20
|
-
import {filterDOMProps, mergeProps, nodeContains, useDescription, useId} from '@react-aria/utils';
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
import intlMessages from '../intl/*.json';
|
|
23
|
-
import {privateValidationStateProp} from '@react-stately/form';
|
|
24
|
-
import {roleSymbol} from './useDateField';
|
|
25
|
-
import {useDatePickerGroup} from './useDatePickerGroup';
|
|
26
|
-
import {useField} from '@react-aria/label';
|
|
27
|
-
import {useFocusWithin} from '@react-aria/interactions';
|
|
28
|
-
import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
29
|
-
import {useMemo, useRef} from 'react';
|
|
30
|
-
|
|
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,
|
|
40
|
-
/** Props for the description element, if any. */
|
|
41
|
-
descriptionProps: DOMAttributes,
|
|
42
|
-
/** Props for the error message element, if any. */
|
|
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>
|
|
48
|
-
}
|
|
49
|
-
|
|
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 {
|
|
55
|
-
let buttonId = useId();
|
|
56
|
-
let dialogId = useId();
|
|
57
|
-
let fieldId = useId();
|
|
58
|
-
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');
|
|
59
|
-
|
|
60
|
-
let {isInvalid, validationErrors, validationDetails} = state.displayValidation;
|
|
61
|
-
let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({
|
|
62
|
-
...props,
|
|
63
|
-
labelElementType: 'span',
|
|
64
|
-
isInvalid,
|
|
65
|
-
errorMessage: props.errorMessage || validationErrors
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
let groupProps = useDatePickerGroup(state, ref);
|
|
69
|
-
|
|
70
|
-
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
71
|
-
|
|
72
|
-
let {locale} = useLocale();
|
|
73
|
-
let date = state.formatValue(locale, {month: 'long'});
|
|
74
|
-
let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';
|
|
75
|
-
let descProps = useDescription(description);
|
|
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 isFocused = useRef(false);
|
|
81
|
-
let {focusWithinProps} = useFocusWithin({
|
|
82
|
-
...props,
|
|
83
|
-
isDisabled: state.isOpen,
|
|
84
|
-
onBlurWithin: e => {
|
|
85
|
-
// Ignore when focus moves into the popover.
|
|
86
|
-
let dialog = document.getElementById(dialogId);
|
|
87
|
-
if (!nodeContains(dialog, e.relatedTarget)) {
|
|
88
|
-
isFocused.current = false;
|
|
89
|
-
props.onBlur?.(e);
|
|
90
|
-
props.onFocusChange?.(false);
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
onFocusWithin: e => {
|
|
94
|
-
if (!isFocused.current) {
|
|
95
|
-
isFocused.current = true;
|
|
96
|
-
props.onFocus?.(e);
|
|
97
|
-
props.onFocusChange?.(true);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
|
|
104
|
-
role: 'group' as const,
|
|
105
|
-
'aria-disabled': props.isDisabled || null,
|
|
106
|
-
'aria-labelledby': labelledBy,
|
|
107
|
-
'aria-describedby': ariaDescribedBy,
|
|
108
|
-
onKeyDown(e: KeyboardEvent) {
|
|
109
|
-
if (state.isOpen) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (props.onKeyDown) {
|
|
114
|
-
props.onKeyDown(e);
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
onKeyUp(e: KeyboardEvent) {
|
|
118
|
-
if (state.isOpen) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (props.onKeyUp) {
|
|
123
|
-
props.onKeyUp(e);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}),
|
|
127
|
-
labelProps: {
|
|
128
|
-
...labelProps,
|
|
129
|
-
onClick: () => {
|
|
130
|
-
focusManager.focusFirst();
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
fieldProps: {
|
|
134
|
-
...fieldProps,
|
|
135
|
-
id: fieldId,
|
|
136
|
-
[roleSymbol]: 'presentation',
|
|
137
|
-
'aria-describedby': ariaDescribedBy,
|
|
138
|
-
value: state.value,
|
|
139
|
-
defaultValue: state.defaultValue,
|
|
140
|
-
onChange: state.setValue,
|
|
141
|
-
placeholderValue: props.placeholderValue,
|
|
142
|
-
hideTimeZone: props.hideTimeZone,
|
|
143
|
-
hourCycle: props.hourCycle,
|
|
144
|
-
shouldForceLeadingZeros: props.shouldForceLeadingZeros,
|
|
145
|
-
granularity: props.granularity,
|
|
146
|
-
isDisabled: props.isDisabled,
|
|
147
|
-
isReadOnly: props.isReadOnly,
|
|
148
|
-
isRequired: props.isRequired,
|
|
149
|
-
validationBehavior: props.validationBehavior,
|
|
150
|
-
// DatePicker owns the validation state for the date field.
|
|
151
|
-
[privateValidationStateProp]: state,
|
|
152
|
-
autoFocus: props.autoFocus,
|
|
153
|
-
name: props.name,
|
|
154
|
-
form: props.form
|
|
155
|
-
},
|
|
156
|
-
descriptionProps,
|
|
157
|
-
errorMessageProps,
|
|
158
|
-
buttonProps: {
|
|
159
|
-
...descProps,
|
|
160
|
-
id: buttonId,
|
|
161
|
-
'aria-haspopup': 'dialog',
|
|
162
|
-
'aria-label': stringFormatter.format('calendar'),
|
|
163
|
-
'aria-labelledby': `${buttonId} ${labelledBy}`,
|
|
164
|
-
'aria-describedby': ariaDescribedBy,
|
|
165
|
-
'aria-expanded': state.isOpen,
|
|
166
|
-
isDisabled: props.isDisabled || props.isReadOnly,
|
|
167
|
-
onPress: () => state.setOpen(true)
|
|
168
|
-
},
|
|
169
|
-
dialogProps: {
|
|
170
|
-
id: dialogId,
|
|
171
|
-
'aria-labelledby': `${buttonId} ${labelledBy}`
|
|
172
|
-
},
|
|
173
|
-
calendarProps: {
|
|
174
|
-
autoFocus: true,
|
|
175
|
-
value: state.dateValue,
|
|
176
|
-
onChange: state.setDateValue,
|
|
177
|
-
minValue: props.minValue,
|
|
178
|
-
maxValue: props.maxValue,
|
|
179
|
-
isDisabled: props.isDisabled,
|
|
180
|
-
isReadOnly: props.isReadOnly,
|
|
181
|
-
isDateUnavailable: props.isDateUnavailable,
|
|
182
|
-
defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
|
|
183
|
-
isInvalid: state.isInvalid,
|
|
184
|
-
errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' ')),
|
|
185
|
-
firstDayOfWeek: props.firstDayOfWeek,
|
|
186
|
-
pageBehavior: props.pageBehavior
|
|
187
|
-
},
|
|
188
|
-
isInvalid,
|
|
189
|
-
validationErrors,
|
|
190
|
-
validationDetails
|
|
191
|
-
};
|
|
192
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import {createFocusManager, getFocusableTreeWalker} from '@react-aria/focus';
|
|
2
|
-
import {DateFieldState, DatePickerState, DateRangePickerState} from '@react-stately/datepicker';
|
|
3
|
-
import {DOMAttributes, FocusableElement, KeyboardEvent, RefObject} from '@react-types/shared';
|
|
4
|
-
import {mergeProps, nodeContains} from '@react-aria/utils';
|
|
5
|
-
import {useLocale} from '@react-aria/i18n';
|
|
6
|
-
import {useMemo} from 'react';
|
|
7
|
-
import {usePress} from '@react-aria/interactions';
|
|
8
|
-
|
|
9
|
-
export function useDatePickerGroup(state: DatePickerState | DateRangePickerState | DateFieldState, ref: RefObject<Element | null>, disableArrowNavigation?: boolean): DOMAttributes<FocusableElement> {
|
|
10
|
-
let {direction} = useLocale();
|
|
11
|
-
let focusManager = useMemo(() => createFocusManager(ref), [ref]);
|
|
12
|
-
|
|
13
|
-
// Open the popover on alt + arrow down
|
|
14
|
-
let onKeyDown = (e: KeyboardEvent) => {
|
|
15
|
-
if (!nodeContains(e.currentTarget, e.target as Element)) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp') && 'setOpen' in state) {
|
|
20
|
-
e.preventDefault();
|
|
21
|
-
e.stopPropagation();
|
|
22
|
-
state.setOpen(true);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (disableArrowNavigation) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
switch (e.key) {
|
|
30
|
-
case 'ArrowLeft':
|
|
31
|
-
e.preventDefault();
|
|
32
|
-
e.stopPropagation();
|
|
33
|
-
if (direction === 'rtl') {
|
|
34
|
-
if (ref.current) {
|
|
35
|
-
let target = e.target as FocusableElement;
|
|
36
|
-
let prev = findNextSegment(ref.current, target.getBoundingClientRect().left, -1);
|
|
37
|
-
|
|
38
|
-
if (prev) {
|
|
39
|
-
prev.focus();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
focusManager.focusPrevious();
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
case 'ArrowRight':
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
e.stopPropagation();
|
|
49
|
-
if (direction === 'rtl') {
|
|
50
|
-
if (ref.current) {
|
|
51
|
-
let target = e.target as FocusableElement;
|
|
52
|
-
let next = findNextSegment(ref.current, target.getBoundingClientRect().left, 1);
|
|
53
|
-
|
|
54
|
-
if (next) {
|
|
55
|
-
next.focus();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
focusManager.focusNext();
|
|
60
|
-
}
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// Focus the first placeholder segment from the end on mouse down/touch up in the field.
|
|
66
|
-
let focusLast = () => {
|
|
67
|
-
if (!ref.current) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
// Try to find the segment prior to the element that was clicked on.
|
|
71
|
-
let target = window.event?.target as FocusableElement;
|
|
72
|
-
let walker = getFocusableTreeWalker(ref.current, {tabbable: true});
|
|
73
|
-
if (target) {
|
|
74
|
-
walker.currentNode = target;
|
|
75
|
-
target = walker.previousNode() as FocusableElement;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// If no target found, find the last element from the end.
|
|
79
|
-
if (!target) {
|
|
80
|
-
let last: FocusableElement;
|
|
81
|
-
do {
|
|
82
|
-
last = walker.lastChild() as FocusableElement;
|
|
83
|
-
if (last) {
|
|
84
|
-
target = last;
|
|
85
|
-
}
|
|
86
|
-
} while (last);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Now go backwards until we find an element that is not a placeholder.
|
|
90
|
-
while (target?.hasAttribute('data-placeholder')) {
|
|
91
|
-
let prev = walker.previousNode() as FocusableElement;
|
|
92
|
-
if (prev && prev.hasAttribute('data-placeholder')) {
|
|
93
|
-
target = prev;
|
|
94
|
-
} else {
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (target) {
|
|
100
|
-
target.focus();
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
let {pressProps} = usePress({
|
|
105
|
-
preventFocusOnPress: true,
|
|
106
|
-
allowTextSelectionOnPress: true,
|
|
107
|
-
onPressStart(e) {
|
|
108
|
-
if (e.pointerType === 'mouse') {
|
|
109
|
-
focusLast();
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
onPress(e) {
|
|
113
|
-
if (e.pointerType === 'touch' || e.pointerType === 'pen') {
|
|
114
|
-
focusLast();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
return mergeProps(pressProps, {onKeyDown});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function findNextSegment(group: Element, fromX: number, direction: number) {
|
|
123
|
-
let walker = getFocusableTreeWalker(group, {tabbable: true});
|
|
124
|
-
let node = walker.nextNode();
|
|
125
|
-
let closest: FocusableElement | null = null;
|
|
126
|
-
let closestDistance = Infinity;
|
|
127
|
-
while (node) {
|
|
128
|
-
let x = (node as Element).getBoundingClientRect().left;
|
|
129
|
-
let distance = x - fromX;
|
|
130
|
-
let absoluteDistance = Math.abs(distance);
|
|
131
|
-
if (Math.sign(distance) === direction && absoluteDistance < closestDistance) {
|
|
132
|
-
closest = node as FocusableElement;
|
|
133
|
-
closestDistance = absoluteDistance;
|
|
134
|
-
}
|
|
135
|
-
node = walker.nextNode();
|
|
136
|
-
}
|
|
137
|
-
return closest;
|
|
138
|
-
}
|