@react-aria/datepicker 3.9.2 → 3.10.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.
Files changed (213) hide show
  1. package/dist/ar-AE.main.js +21 -0
  2. package/dist/ar-AE.main.js.map +1 -0
  3. package/dist/ar-AE.mjs +23 -0
  4. package/dist/ar-AE.module.js +23 -0
  5. package/dist/ar-AE.module.js.map +1 -0
  6. package/dist/bg-BG.main.js +21 -0
  7. package/dist/bg-BG.main.js.map +1 -0
  8. package/dist/bg-BG.mjs +23 -0
  9. package/dist/bg-BG.module.js +23 -0
  10. package/dist/bg-BG.module.js.map +1 -0
  11. package/dist/cs-CZ.main.js +21 -0
  12. package/dist/cs-CZ.main.js.map +1 -0
  13. package/dist/cs-CZ.mjs +23 -0
  14. package/dist/cs-CZ.module.js +23 -0
  15. package/dist/cs-CZ.module.js.map +1 -0
  16. package/dist/da-DK.main.js +21 -0
  17. package/dist/da-DK.main.js.map +1 -0
  18. package/dist/da-DK.mjs +23 -0
  19. package/dist/da-DK.module.js +23 -0
  20. package/dist/da-DK.module.js.map +1 -0
  21. package/dist/de-DE.main.js +21 -0
  22. package/dist/de-DE.main.js.map +1 -0
  23. package/dist/de-DE.mjs +23 -0
  24. package/dist/de-DE.module.js +23 -0
  25. package/dist/de-DE.module.js.map +1 -0
  26. package/dist/el-GR.main.js +21 -0
  27. package/dist/el-GR.main.js.map +1 -0
  28. package/dist/el-GR.mjs +23 -0
  29. package/dist/el-GR.module.js +23 -0
  30. package/dist/el-GR.module.js.map +1 -0
  31. package/dist/en-US.main.js +21 -0
  32. package/dist/en-US.main.js.map +1 -0
  33. package/dist/en-US.mjs +23 -0
  34. package/dist/en-US.module.js +23 -0
  35. package/dist/en-US.module.js.map +1 -0
  36. package/dist/es-ES.main.js +21 -0
  37. package/dist/es-ES.main.js.map +1 -0
  38. package/dist/es-ES.mjs +23 -0
  39. package/dist/es-ES.module.js +23 -0
  40. package/dist/es-ES.module.js.map +1 -0
  41. package/dist/et-EE.main.js +21 -0
  42. package/dist/et-EE.main.js.map +1 -0
  43. package/dist/et-EE.mjs +23 -0
  44. package/dist/et-EE.module.js +23 -0
  45. package/dist/et-EE.module.js.map +1 -0
  46. package/dist/fi-FI.main.js +21 -0
  47. package/dist/fi-FI.main.js.map +1 -0
  48. package/dist/fi-FI.mjs +23 -0
  49. package/dist/fi-FI.module.js +23 -0
  50. package/dist/fi-FI.module.js.map +1 -0
  51. package/dist/fr-FR.main.js +21 -0
  52. package/dist/fr-FR.main.js.map +1 -0
  53. package/dist/fr-FR.mjs +23 -0
  54. package/dist/fr-FR.module.js +23 -0
  55. package/dist/fr-FR.module.js.map +1 -0
  56. package/dist/he-IL.main.js +21 -0
  57. package/dist/he-IL.main.js.map +1 -0
  58. package/dist/he-IL.mjs +23 -0
  59. package/dist/he-IL.module.js +23 -0
  60. package/dist/he-IL.module.js.map +1 -0
  61. package/dist/hr-HR.main.js +21 -0
  62. package/dist/hr-HR.main.js.map +1 -0
  63. package/dist/hr-HR.mjs +23 -0
  64. package/dist/hr-HR.module.js +23 -0
  65. package/dist/hr-HR.module.js.map +1 -0
  66. package/dist/hu-HU.main.js +21 -0
  67. package/dist/hu-HU.main.js.map +1 -0
  68. package/dist/hu-HU.mjs +23 -0
  69. package/dist/hu-HU.module.js +23 -0
  70. package/dist/hu-HU.module.js.map +1 -0
  71. package/dist/import.mjs +5 -1693
  72. package/dist/intlStrings.main.js +108 -0
  73. package/dist/intlStrings.main.js.map +1 -0
  74. package/dist/intlStrings.mjs +110 -0
  75. package/dist/intlStrings.module.js +110 -0
  76. package/dist/intlStrings.module.js.map +1 -0
  77. package/dist/it-IT.main.js +21 -0
  78. package/dist/it-IT.main.js.map +1 -0
  79. package/dist/it-IT.mjs +23 -0
  80. package/dist/it-IT.module.js +23 -0
  81. package/dist/it-IT.module.js.map +1 -0
  82. package/dist/ja-JP.main.js +21 -0
  83. package/dist/ja-JP.main.js.map +1 -0
  84. package/dist/ja-JP.mjs +23 -0
  85. package/dist/ja-JP.module.js +23 -0
  86. package/dist/ja-JP.module.js.map +1 -0
  87. package/dist/ko-KR.main.js +21 -0
  88. package/dist/ko-KR.main.js.map +1 -0
  89. package/dist/ko-KR.mjs +23 -0
  90. package/dist/ko-KR.module.js +23 -0
  91. package/dist/ko-KR.module.js.map +1 -0
  92. package/dist/lt-LT.main.js +21 -0
  93. package/dist/lt-LT.main.js.map +1 -0
  94. package/dist/lt-LT.mjs +23 -0
  95. package/dist/lt-LT.module.js +23 -0
  96. package/dist/lt-LT.module.js.map +1 -0
  97. package/dist/lv-LV.main.js +21 -0
  98. package/dist/lv-LV.main.js.map +1 -0
  99. package/dist/lv-LV.mjs +23 -0
  100. package/dist/lv-LV.module.js +23 -0
  101. package/dist/lv-LV.module.js.map +1 -0
  102. package/dist/main.js +11 -1699
  103. package/dist/main.js.map +1 -1
  104. package/dist/module.js +5 -1693
  105. package/dist/module.js.map +1 -1
  106. package/dist/nb-NO.main.js +21 -0
  107. package/dist/nb-NO.main.js.map +1 -0
  108. package/dist/nb-NO.mjs +23 -0
  109. package/dist/nb-NO.module.js +23 -0
  110. package/dist/nb-NO.module.js.map +1 -0
  111. package/dist/nl-NL.main.js +21 -0
  112. package/dist/nl-NL.main.js.map +1 -0
  113. package/dist/nl-NL.mjs +23 -0
  114. package/dist/nl-NL.module.js +23 -0
  115. package/dist/nl-NL.module.js.map +1 -0
  116. package/dist/pl-PL.main.js +21 -0
  117. package/dist/pl-PL.main.js.map +1 -0
  118. package/dist/pl-PL.mjs +23 -0
  119. package/dist/pl-PL.module.js +23 -0
  120. package/dist/pl-PL.module.js.map +1 -0
  121. package/dist/pt-BR.main.js +21 -0
  122. package/dist/pt-BR.main.js.map +1 -0
  123. package/dist/pt-BR.mjs +23 -0
  124. package/dist/pt-BR.module.js +23 -0
  125. package/dist/pt-BR.module.js.map +1 -0
  126. package/dist/pt-PT.main.js +21 -0
  127. package/dist/pt-PT.main.js.map +1 -0
  128. package/dist/pt-PT.mjs +23 -0
  129. package/dist/pt-PT.module.js +23 -0
  130. package/dist/pt-PT.module.js.map +1 -0
  131. package/dist/ro-RO.main.js +21 -0
  132. package/dist/ro-RO.main.js.map +1 -0
  133. package/dist/ro-RO.mjs +23 -0
  134. package/dist/ro-RO.module.js +23 -0
  135. package/dist/ro-RO.module.js.map +1 -0
  136. package/dist/ru-RU.main.js +21 -0
  137. package/dist/ru-RU.main.js.map +1 -0
  138. package/dist/ru-RU.mjs +23 -0
  139. package/dist/ru-RU.module.js +23 -0
  140. package/dist/ru-RU.module.js.map +1 -0
  141. package/dist/sk-SK.main.js +21 -0
  142. package/dist/sk-SK.main.js.map +1 -0
  143. package/dist/sk-SK.mjs +23 -0
  144. package/dist/sk-SK.module.js +23 -0
  145. package/dist/sk-SK.module.js.map +1 -0
  146. package/dist/sl-SI.main.js +21 -0
  147. package/dist/sl-SI.main.js.map +1 -0
  148. package/dist/sl-SI.mjs +23 -0
  149. package/dist/sl-SI.module.js +23 -0
  150. package/dist/sl-SI.module.js.map +1 -0
  151. package/dist/sr-SP.main.js +21 -0
  152. package/dist/sr-SP.main.js.map +1 -0
  153. package/dist/sr-SP.mjs +23 -0
  154. package/dist/sr-SP.module.js +23 -0
  155. package/dist/sr-SP.module.js.map +1 -0
  156. package/dist/sv-SE.main.js +21 -0
  157. package/dist/sv-SE.main.js.map +1 -0
  158. package/dist/sv-SE.mjs +23 -0
  159. package/dist/sv-SE.module.js +23 -0
  160. package/dist/sv-SE.module.js.map +1 -0
  161. package/dist/tr-TR.main.js +21 -0
  162. package/dist/tr-TR.main.js.map +1 -0
  163. package/dist/tr-TR.mjs +23 -0
  164. package/dist/tr-TR.module.js +23 -0
  165. package/dist/tr-TR.module.js.map +1 -0
  166. package/dist/types.d.ts.map +1 -1
  167. package/dist/uk-UA.main.js +21 -0
  168. package/dist/uk-UA.main.js.map +1 -0
  169. package/dist/uk-UA.mjs +23 -0
  170. package/dist/uk-UA.module.js +23 -0
  171. package/dist/uk-UA.module.js.map +1 -0
  172. package/dist/useDateField.main.js +176 -0
  173. package/dist/useDateField.main.js.map +1 -0
  174. package/dist/useDateField.mjs +167 -0
  175. package/dist/useDateField.module.js +167 -0
  176. package/dist/useDateField.module.js.map +1 -0
  177. package/dist/useDatePicker.main.js +158 -0
  178. package/dist/useDatePicker.main.js.map +1 -0
  179. package/dist/useDatePicker.mjs +153 -0
  180. package/dist/useDatePicker.module.js +153 -0
  181. package/dist/useDatePicker.module.js.map +1 -0
  182. package/dist/useDatePickerGroup.main.js +91 -0
  183. package/dist/useDatePickerGroup.main.js.map +1 -0
  184. package/dist/useDatePickerGroup.mjs +86 -0
  185. package/dist/useDatePickerGroup.module.js +86 -0
  186. package/dist/useDatePickerGroup.module.js.map +1 -0
  187. package/dist/useDateRangePicker.main.js +201 -0
  188. package/dist/useDateRangePicker.main.js.map +1 -0
  189. package/dist/useDateRangePicker.mjs +196 -0
  190. package/dist/useDateRangePicker.module.js +196 -0
  191. package/dist/useDateRangePicker.module.js.map +1 -0
  192. package/dist/useDateSegment.main.js +366 -0
  193. package/dist/useDateSegment.main.js.map +1 -0
  194. package/dist/useDateSegment.mjs +357 -0
  195. package/dist/useDateSegment.module.js +357 -0
  196. package/dist/useDateSegment.module.js.map +1 -0
  197. package/dist/useDisplayNames.main.js +59 -0
  198. package/dist/useDisplayNames.main.js.map +1 -0
  199. package/dist/useDisplayNames.mjs +54 -0
  200. package/dist/useDisplayNames.module.js +54 -0
  201. package/dist/useDisplayNames.module.js.map +1 -0
  202. package/dist/zh-CN.main.js +21 -0
  203. package/dist/zh-CN.main.js.map +1 -0
  204. package/dist/zh-CN.mjs +23 -0
  205. package/dist/zh-CN.module.js +23 -0
  206. package/dist/zh-CN.module.js.map +1 -0
  207. package/dist/zh-TW.main.js +21 -0
  208. package/dist/zh-TW.main.js.map +1 -0
  209. package/dist/zh-TW.mjs +23 -0
  210. package/dist/zh-TW.module.js +23 -0
  211. package/dist/zh-TW.module.js.map +1 -0
  212. package/package.json +19 -19
  213. package/src/useDateSegment.ts +4 -0
@@ -0,0 +1,167 @@
1
+ import $7Gzdi$intlStringsmodulejs from "./intlStrings.module.js";
2
+ import {useDatePickerGroup as $3dfb0f96be0d6a08$export$4a931266a3838b86} from "./useDatePickerGroup.module.js";
3
+ import {createFocusManager as $7Gzdi$createFocusManager} from "@react-aria/focus";
4
+ import {useDescription as $7Gzdi$useDescription, mergeProps as $7Gzdi$mergeProps, useFormReset as $7Gzdi$useFormReset, filterDOMProps as $7Gzdi$filterDOMProps} from "@react-aria/utils";
5
+ import {useRef as $7Gzdi$useRef, useMemo as $7Gzdi$useMemo, useEffect as $7Gzdi$useEffect} from "react";
6
+ import {useField as $7Gzdi$useField} from "@react-aria/label";
7
+ import {useFocusWithin as $7Gzdi$useFocusWithin} from "@react-aria/interactions";
8
+ import {useFormValidation as $7Gzdi$useFormValidation} from "@react-aria/form";
9
+ import {useLocalizedStringFormatter as $7Gzdi$useLocalizedStringFormatter} from "@react-aria/i18n";
10
+
11
+
12
+ function $parcel$interopDefault(a) {
13
+ return a && a.__esModule ? a.default : a;
14
+ }
15
+ /*
16
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+ const $16f0b7bb276bc17e$export$653eddfc964b0f8a = new WeakMap();
35
+ const $16f0b7bb276bc17e$export$300019f83c56d282 = "__role_" + Date.now();
36
+ const $16f0b7bb276bc17e$export$7b3062cd49e80452 = "__focusManager_" + Date.now();
37
+ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
38
+ var _state_value;
39
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
40
+ let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $7Gzdi$useField)({
41
+ ...props,
42
+ labelElementType: "span",
43
+ isInvalid: isInvalid,
44
+ errorMessage: props.errorMessage || validationErrors
45
+ });
46
+ let valueOnFocus = (0, $7Gzdi$useRef)(null);
47
+ let { focusWithinProps: focusWithinProps } = (0, $7Gzdi$useFocusWithin)({
48
+ ...props,
49
+ onFocusWithin (e) {
50
+ var _props_onFocus;
51
+ valueOnFocus.current = state.value;
52
+ (_props_onFocus = props.onFocus) === null || _props_onFocus === void 0 ? void 0 : _props_onFocus.call(props, e);
53
+ },
54
+ onBlurWithin: (e)=>{
55
+ var _props_onBlur;
56
+ state.confirmPlaceholder();
57
+ if (state.value !== valueOnFocus.current) state.commitValidation();
58
+ (_props_onBlur = props.onBlur) === null || _props_onBlur === void 0 ? void 0 : _props_onBlur.call(props, e);
59
+ },
60
+ onFocusWithinChange: props.onFocusChange
61
+ });
62
+ let stringFormatter = (0, $7Gzdi$useLocalizedStringFormatter)((0, ($parcel$interopDefault($7Gzdi$intlStringsmodulejs))), "@react-aria/datepicker");
63
+ let message = state.maxGranularity === "hour" ? "selectedTimeDescription" : "selectedDateDescription";
64
+ let field = state.maxGranularity === "hour" ? "time" : "date";
65
+ let description = state.value ? stringFormatter.format(message, {
66
+ [field]: state.formatValue({
67
+ month: "long"
68
+ })
69
+ }) : "";
70
+ let descProps = (0, $7Gzdi$useDescription)(description);
71
+ // If within a date picker or date range picker, the date field will have role="presentation" and an aria-describedby
72
+ // will be passed in that references the value (e.g. entire range). Otherwise, add the field's value description.
73
+ let describedBy = props[$16f0b7bb276bc17e$export$300019f83c56d282] === "presentation" ? fieldProps["aria-describedby"] : [
74
+ descProps["aria-describedby"],
75
+ fieldProps["aria-describedby"]
76
+ ].filter(Boolean).join(" ") || undefined;
77
+ let propsFocusManager = props[$16f0b7bb276bc17e$export$7b3062cd49e80452];
78
+ let focusManager = (0, $7Gzdi$useMemo)(()=>propsFocusManager || (0, $7Gzdi$createFocusManager)(ref), [
79
+ propsFocusManager,
80
+ ref
81
+ ]);
82
+ let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref, props[$16f0b7bb276bc17e$export$300019f83c56d282] === "presentation");
83
+ // Pass labels and other information to segments.
84
+ $16f0b7bb276bc17e$export$653eddfc964b0f8a.set(state, {
85
+ ariaLabel: props["aria-label"],
86
+ ariaLabelledBy: [
87
+ labelProps.id,
88
+ props["aria-labelledby"]
89
+ ].filter(Boolean).join(" ") || undefined,
90
+ ariaDescribedBy: describedBy,
91
+ focusManager: focusManager
92
+ });
93
+ let autoFocusRef = (0, $7Gzdi$useRef)(props.autoFocus);
94
+ // When used within a date picker or date range picker, the field gets role="presentation"
95
+ // rather than role="group". Since the date picker/date range picker already has a role="group"
96
+ // with a label and description, and the segments are already labeled by this as well, this
97
+ // avoids very verbose duplicate announcements.
98
+ let fieldDOMProps;
99
+ if (props[$16f0b7bb276bc17e$export$300019f83c56d282] === "presentation") fieldDOMProps = {
100
+ role: "presentation"
101
+ };
102
+ else fieldDOMProps = (0, $7Gzdi$mergeProps)(fieldProps, {
103
+ role: "group",
104
+ "aria-disabled": props.isDisabled || undefined,
105
+ "aria-describedby": describedBy
106
+ });
107
+ (0, $7Gzdi$useEffect)(()=>{
108
+ if (autoFocusRef.current) focusManager.focusFirst();
109
+ autoFocusRef.current = false;
110
+ }, [
111
+ focusManager
112
+ ]);
113
+ (0, $7Gzdi$useFormReset)(props.inputRef, state.value, state.setValue);
114
+ (0, $7Gzdi$useFormValidation)({
115
+ ...props,
116
+ focus () {
117
+ focusManager.focusFirst();
118
+ }
119
+ }, state, props.inputRef);
120
+ let inputProps = {
121
+ type: "hidden",
122
+ name: props.name,
123
+ value: ((_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.toString()) || ""
124
+ };
125
+ if (props.validationBehavior === "native") {
126
+ // Use a hidden <input type="text"> rather than <input type="hidden">
127
+ // so that an empty value blocks HTML form submission when the field is required.
128
+ inputProps.type = "text";
129
+ inputProps.hidden = true;
130
+ inputProps.required = props.isRequired;
131
+ // Ignore react warning.
132
+ inputProps.onChange = ()=>{};
133
+ }
134
+ let domProps = (0, $7Gzdi$filterDOMProps)(props);
135
+ return {
136
+ labelProps: {
137
+ ...labelProps,
138
+ onClick: ()=>{
139
+ focusManager.focusFirst();
140
+ }
141
+ },
142
+ fieldProps: (0, $7Gzdi$mergeProps)(domProps, fieldDOMProps, groupProps, focusWithinProps, {
143
+ onKeyDown (e) {
144
+ if (props.onKeyDown) props.onKeyDown(e);
145
+ },
146
+ onKeyUp (e) {
147
+ if (props.onKeyUp) props.onKeyUp(e);
148
+ }
149
+ }),
150
+ inputProps: inputProps,
151
+ descriptionProps: descriptionProps,
152
+ errorMessageProps: errorMessageProps,
153
+ isInvalid: isInvalid,
154
+ validationErrors: validationErrors,
155
+ validationDetails: validationDetails
156
+ };
157
+ }
158
+ function $16f0b7bb276bc17e$export$4c842f6a241dc825(props, state, ref) {
159
+ var _state_timeValue;
160
+ let res = $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref);
161
+ res.inputProps.value = ((_state_timeValue = state.timeValue) === null || _state_timeValue === void 0 ? void 0 : _state_timeValue.toString()) || "";
162
+ return res;
163
+ }
164
+
165
+
166
+ export {$16f0b7bb276bc17e$export$653eddfc964b0f8a as hookData, $16f0b7bb276bc17e$export$300019f83c56d282 as roleSymbol, $16f0b7bb276bc17e$export$7b3062cd49e80452 as focusManagerSymbol, $16f0b7bb276bc17e$export$5591b0b878c1a989 as useDateField, $16f0b7bb276bc17e$export$4c842f6a241dc825 as useTimeField};
167
+ //# sourceMappingURL=useDateField.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;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AU;QACzB;IACF,GAAG,OAAO,MAAM,QAAQ;IAExB,IAAI,aAAoD;QACtD,MAAM;QACN,MAAM,MAAM,IAAI;QAChB,OAAO,EAAA,eAAA,MAAM,KAAK,cAAX,mCAAA,aAAa,QAAQ,OAAM;IACpC;IAEA,IAAI,MAAM,kBAAkB,KAAK,UAAU;QACzC,qEAAqE;QACrE,iFAAiF;QACjF,WAAW,IAAI,GAAG;QAClB,WAAW,MAAM,GAAG;QACpB,WAAW,QAAQ,GAAG,MAAM,UAAU;QACtC,wBAAwB;QACxB,WAAW,QAAQ,GAAG,KAAO;IAC/B;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE;IAC9B,OAAO;QACL,YAAY;YACV,GAAG,UAAU;YACb,SAAS;gBACP,aAAa,UAAU;YACzB;QACF;QACA,YAAY,CAAA,GAAA,iBAAS,EAAE,UAAU,eAAe,YAAY,kBAAkB;YAC5E,WAAU,CAAgB;gBACxB,IAAI,MAAM,SAAS,EACjB,MAAM,SAAS,CAAC;YAEpB;YACA,SAAQ,CAAgB;gBACtB,IAAI,MAAM,OAAO,EACf,MAAM,OAAO,CAAC;YAElB;QACF;oBACA;0BACA;2BACA;mBACA;0BACA;2BACA;IACF;AACF;AAYO,SAAS,0CAAkC,KAA8B,EAAE,KAAqB,EAAE,GAAuB;QAEvG;IADvB,IAAI,MAAM,0CAAa,OAAO,OAAO;IACrC,IAAI,UAAU,CAAC,KAAK,GAAG,EAAA,mBAAA,MAAM,SAAS,cAAf,uCAAA,iBAAiB,QAAQ,OAAM;IACtD,OAAO;AACT","sources":["packages/@react-aria/datepicker/src/useDateField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaDateFieldProps as AriaDateFieldPropsBase, AriaTimeFieldProps, DateValue, TimeValue} from '@react-types/datepicker';\nimport {createFocusManager, FocusManager} from '@react-aria/focus';\nimport {DateFieldState, TimeFieldState} from '@react-stately/datepicker';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject, useEffect, useMemo, useRef} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useFormValidation} from '@react-aria/form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\n// Allows this hook to also be used with TimeField\nexport interface AriaDateFieldOptions<T extends DateValue> extends Omit<AriaDateFieldPropsBase<T>, 'value' | 'defaultValue' | 'onChange' | 'minValue' | 'maxValue' | 'placeholderValue' | 'validate'> {\n /** A ref for the hidden input element for HTML form submission. */\n inputRef?: RefObject<HTMLInputElement>\n}\n\nexport interface DateFieldAria extends ValidationResult {\n /** Props for the field's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the field grouping element. */\n fieldProps: GroupDOMAttributes,\n /** Props for the hidden input element for HTML form submission. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n// Data that is passed between useDateField and useDateSegment.\ninterface HookData {\n ariaLabel: string,\n ariaLabelledBy: string,\n ariaDescribedBy: string,\n focusManager: FocusManager\n}\n\nexport const hookData = new WeakMap<DateFieldState, HookData>();\n\n// Private props that we pass from useDatePicker/useDateRangePicker.\n// Ideally we'd use a Symbol for this, but React doesn't support them: https://github.com/facebook/react/issues/7552\nexport const roleSymbol = '__role_' + Date.now();\nexport const focusManagerSymbol = '__focusManager_' + Date.now();\n\n/**\n * Provides the behavior and accessibility implementation for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateField<T extends DateValue>(props: AriaDateFieldOptions<T>, state: DateFieldState, ref: RefObject<Element>): DateFieldAria {\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let valueOnFocus = useRef<DateValue | null>(null);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n onFocusWithin(e) {\n valueOnFocus.current = state.value;\n props.onFocus?.(e);\n },\n onBlurWithin: (e) => {\n state.confirmPlaceholder();\n if (state.value !== valueOnFocus.current) {\n state.commitValidation();\n }\n props.onBlur?.(e);\n },\n onFocusWithinChange: props.onFocusChange\n });\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n let message = state.maxGranularity === 'hour' ? 'selectedTimeDescription' : 'selectedDateDescription';\n let field = state.maxGranularity === 'hour' ? 'time' : 'date';\n let description = state.value ? stringFormatter.format(message, {[field]: state.formatValue({month: 'long'})}) : '';\n let descProps = useDescription(description);\n\n // If within a date picker or date range picker, the date field will have role=\"presentation\" and an aria-describedby\n // will be passed in that references the value (e.g. entire range). Otherwise, add the field's value description.\n let describedBy = props[roleSymbol] === 'presentation'\n ? fieldProps['aria-describedby']\n : [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let propsFocusManager = props[focusManagerSymbol];\n let focusManager = useMemo(() => propsFocusManager || createFocusManager(ref), [propsFocusManager, ref]);\n let groupProps = useDatePickerGroup(state, ref, props[roleSymbol] === 'presentation');\n\n // Pass labels and other information to segments.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: [labelProps.id, props['aria-labelledby']].filter(Boolean).join(' ') || undefined,\n ariaDescribedBy: describedBy,\n focusManager\n });\n\n let autoFocusRef = useRef(props.autoFocus);\n\n // When used within a date picker or date range picker, the field gets role=\"presentation\"\n // rather than role=\"group\". Since the date picker/date range picker already has a role=\"group\"\n // with a label and description, and the segments are already labeled by this as well, this\n // avoids very verbose duplicate announcements.\n let fieldDOMProps: GroupDOMAttributes;\n if (props[roleSymbol] === 'presentation') {\n fieldDOMProps = {\n role: 'presentation'\n };\n } else {\n fieldDOMProps = mergeProps(fieldProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || undefined,\n 'aria-describedby': describedBy\n });\n }\n\n useEffect(() => {\n if (autoFocusRef.current) {\n focusManager.focusFirst();\n }\n autoFocusRef.current = false;\n }, [focusManager]);\n\n useFormReset(props.inputRef, state.value, state.setValue);\n useFormValidation({\n ...props,\n focus() {\n focusManager.focusFirst();\n }\n }, state, props.inputRef);\n\n let inputProps: InputHTMLAttributes<HTMLInputElement> = {\n type: 'hidden',\n name: props.name,\n value: state.value?.toString() || ''\n };\n\n if (props.validationBehavior === 'native') {\n // Use a hidden <input type=\"text\"> rather than <input type=\"hidden\">\n // so that an empty value blocks HTML form submission when the field is required.\n inputProps.type = 'text';\n inputProps.hidden = true;\n inputProps.required = props.isRequired;\n // Ignore react warning.\n inputProps.onChange = () => {};\n }\n\n let domProps = filterDOMProps(props);\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n fieldProps: mergeProps(domProps, fieldDOMProps, groupProps, focusWithinProps, {\n onKeyDown(e: KeyboardEvent) {\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n inputProps,\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n\nexport interface AriaTimeFieldOptions<T extends TimeValue> extends AriaTimeFieldProps<T> {\n /** A ref for the hidden input element for HTML form submission. */\n inputRef?: RefObject<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a time field component.\n * A time field allows users to enter and edit time values using a keyboard.\n * Each part of a time value is displayed in an individually editable segment.\n */\nexport function useTimeField<T extends TimeValue>(props: AriaTimeFieldOptions<T>, state: TimeFieldState, ref: RefObject<Element>): DateFieldAria {\n let res = useDateField(props, state, ref);\n res.inputProps.value = state.timeValue?.toString() || '';\n return res;\n}\n"],"names":[],"version":3,"file":"useDateField.module.js.map"}
@@ -0,0 +1,158 @@
1
+ var $c1905b78f6d2f5bf$exports = require("./intlStrings.main.js");
2
+ var $4acc2f407c169e55$exports = require("./useDateField.main.js");
3
+ var $715562ad3b4cced4$exports = require("./useDatePickerGroup.main.js");
4
+ var $bxHoL$reactariafocus = require("@react-aria/focus");
5
+ var $bxHoL$reactariautils = require("@react-aria/utils");
6
+ var $bxHoL$reactstatelyform = require("@react-stately/form");
7
+ var $bxHoL$react = require("react");
8
+ var $bxHoL$reactarialabel = require("@react-aria/label");
9
+ var $bxHoL$reactariainteractions = require("@react-aria/interactions");
10
+ var $bxHoL$reactariai18n = require("@react-aria/i18n");
11
+
12
+
13
+ function $parcel$interopDefault(a) {
14
+ return a && a.__esModule ? a.default : a;
15
+ }
16
+
17
+ function $parcel$export(e, n, v, s) {
18
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
19
+ }
20
+
21
+ $parcel$export(module.exports, "useDatePicker", () => $e90ae7c26a69c6b1$export$42df105a73306d51);
22
+ /*
23
+ * Copyright 2020 Adobe. All rights reserved.
24
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
25
+ * you may not use this file except in compliance with the License. You may obtain a copy
26
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
27
+ *
28
+ * Unless required by applicable law or agreed to in writing, software distributed under
29
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30
+ * OF ANY KIND, either express or implied. See the License for the specific language
31
+ * governing permissions and limitations under the License.
32
+ */
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
43
+ let buttonId = (0, $bxHoL$reactariautils.useId)();
44
+ let dialogId = (0, $bxHoL$reactariautils.useId)();
45
+ let fieldId = (0, $bxHoL$reactariautils.useId)();
46
+ let stringFormatter = (0, $bxHoL$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($c1905b78f6d2f5bf$exports))), "@react-aria/datepicker");
47
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
48
+ let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $bxHoL$reactarialabel.useField)({
49
+ ...props,
50
+ labelElementType: "span",
51
+ isInvalid: isInvalid,
52
+ errorMessage: props.errorMessage || validationErrors
53
+ });
54
+ let groupProps = (0, $715562ad3b4cced4$exports.useDatePickerGroup)(state, ref);
55
+ let labelledBy = fieldProps["aria-labelledby"] || fieldProps.id;
56
+ let { locale: locale } = (0, $bxHoL$reactariai18n.useLocale)();
57
+ let date = state.formatValue(locale, {
58
+ month: "long"
59
+ });
60
+ let description = date ? stringFormatter.format("selectedDateDescription", {
61
+ date: date
62
+ }) : "";
63
+ let descProps = (0, $bxHoL$reactariautils.useDescription)(description);
64
+ let ariaDescribedBy = [
65
+ descProps["aria-describedby"],
66
+ fieldProps["aria-describedby"]
67
+ ].filter(Boolean).join(" ") || undefined;
68
+ let domProps = (0, $bxHoL$reactariautils.filterDOMProps)(props);
69
+ let focusManager = (0, $bxHoL$react.useMemo)(()=>(0, $bxHoL$reactariafocus.createFocusManager)(ref), [
70
+ ref
71
+ ]);
72
+ let { focusWithinProps: focusWithinProps } = (0, $bxHoL$reactariainteractions.useFocusWithin)({
73
+ ...props,
74
+ isDisabled: state.isOpen,
75
+ onBlurWithin: props.onBlur,
76
+ onFocusWithin: props.onFocus,
77
+ onFocusWithinChange: props.onFocusChange
78
+ });
79
+ return {
80
+ groupProps: (0, $bxHoL$reactariautils.mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
81
+ role: "group",
82
+ "aria-disabled": props.isDisabled || null,
83
+ "aria-labelledby": labelledBy,
84
+ "aria-describedby": ariaDescribedBy,
85
+ onKeyDown (e) {
86
+ if (state.isOpen) return;
87
+ if (props.onKeyDown) props.onKeyDown(e);
88
+ },
89
+ onKeyUp (e) {
90
+ if (state.isOpen) return;
91
+ if (props.onKeyUp) props.onKeyUp(e);
92
+ }
93
+ }),
94
+ labelProps: {
95
+ ...labelProps,
96
+ onClick: ()=>{
97
+ focusManager.focusFirst();
98
+ }
99
+ },
100
+ fieldProps: {
101
+ ...fieldProps,
102
+ id: fieldId,
103
+ [(0, $4acc2f407c169e55$exports.roleSymbol)]: "presentation",
104
+ "aria-describedby": ariaDescribedBy,
105
+ value: state.value,
106
+ onChange: state.setValue,
107
+ placeholderValue: props.placeholderValue,
108
+ hideTimeZone: props.hideTimeZone,
109
+ hourCycle: props.hourCycle,
110
+ shouldForceLeadingZeros: props.shouldForceLeadingZeros,
111
+ granularity: props.granularity,
112
+ isDisabled: props.isDisabled,
113
+ isReadOnly: props.isReadOnly,
114
+ isRequired: props.isRequired,
115
+ validationBehavior: props.validationBehavior,
116
+ // DatePicker owns the validation state for the date field.
117
+ [(0, $bxHoL$reactstatelyform.privateValidationStateProp)]: state,
118
+ autoFocus: props.autoFocus,
119
+ name: props.name
120
+ },
121
+ descriptionProps: descriptionProps,
122
+ errorMessageProps: errorMessageProps,
123
+ buttonProps: {
124
+ ...descProps,
125
+ id: buttonId,
126
+ "aria-haspopup": "dialog",
127
+ "aria-label": stringFormatter.format("calendar"),
128
+ "aria-labelledby": `${buttonId} ${labelledBy}`,
129
+ "aria-describedby": ariaDescribedBy,
130
+ "aria-expanded": state.isOpen,
131
+ isDisabled: props.isDisabled || props.isReadOnly,
132
+ onPress: ()=>state.setOpen(true)
133
+ },
134
+ dialogProps: {
135
+ id: dialogId,
136
+ "aria-labelledby": `${buttonId} ${labelledBy}`
137
+ },
138
+ calendarProps: {
139
+ autoFocus: true,
140
+ value: state.dateValue,
141
+ onChange: state.setDateValue,
142
+ minValue: props.minValue,
143
+ maxValue: props.maxValue,
144
+ isDisabled: props.isDisabled,
145
+ isReadOnly: props.isReadOnly,
146
+ isDateUnavailable: props.isDateUnavailable,
147
+ defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
148
+ isInvalid: state.isInvalid,
149
+ errorMessage: typeof props.errorMessage === "function" ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(" ")
150
+ },
151
+ isInvalid: isInvalid,
152
+ validationErrors: validationErrors,
153
+ validationDetails: validationDetails
154
+ };
155
+ }
156
+
157
+
158
+ //# sourceMappingURL=useDatePicker.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA2CM,SAAS,0CAAmC,KAA6B,EAAE,KAAsB,EAAE,GAAuB;IAC/H,IAAI,WAAW,CAAA,GAAA,2BAAI;IACnB,IAAI,WAAW,CAAA,GAAA,2BAAI;IACnB,IAAI,UAAU,CAAA,GAAA,2BAAI;IAClB,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,MAAM,iBAAiB;IAC9E,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,CAAA,GAAA,8BAAO,EAAE;QAC3E,GAAG,KAAK;QACR,kBAAkB;mBAClB;QACA,cAAc,MAAM,YAAY,IAAI;IACtC;IAEA,IAAI,aAAa,CAAA,GAAA,4CAAiB,EAAE,OAAO;IAE3C,IA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C9K;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/datepicker/src/useDatePicker.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {CalendarProps} from '@react-types/calendar';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DatePickerState} from '@react-stately/datepicker';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {RefObject, useMemo} from 'react';\nimport {roleSymbol} from './useDateField';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface DatePickerAria extends ValidationResult {\n /** Props for the date picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date field and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the date field. */\n fieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the calendar within the popover dialog. */\n calendarProps: CalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date picker combines a DateField and a Calendar popover to allow users to enter or select a date and time value.\n */\nexport function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element>): DatePickerAria {\n let buttonId = useId();\n let dialogId = useId();\n let fieldId = useId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let date = state.formatValue(locale, {month: 'long'});\n let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';\n let descProps = useDescription(description);\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let domProps = filterDOMProps(props);\n let focusManager = useMemo(() => createFocusManager(ref), [ref]);\n\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: props.onBlur,\n onFocusWithin: props.onFocus,\n onFocusWithinChange: props.onFocusChange\n });\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-labelledby': labelledBy,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n fieldProps: {\n ...fieldProps,\n id: fieldId,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n value: state.value,\n onChange: state.setValue,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n granularity: props.granularity,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior,\n // DatePicker owns the validation state for the date field.\n [privateValidationStateProp]: state,\n autoFocus: props.autoFocus,\n name: props.name\n },\n descriptionProps,\n errorMessageProps,\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n calendarProps: {\n autoFocus: true,\n value: state.dateValue,\n onChange: state.setDateValue,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' '))\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDatePicker.main.js.map"}
@@ -0,0 +1,153 @@
1
+ import $4lVjK$intlStringsmodulejs from "./intlStrings.mjs";
2
+ import {roleSymbol as $16f0b7bb276bc17e$export$300019f83c56d282} from "./useDateField.mjs";
3
+ import {useDatePickerGroup as $3dfb0f96be0d6a08$export$4a931266a3838b86} from "./useDatePickerGroup.mjs";
4
+ import {createFocusManager as $4lVjK$createFocusManager} from "@react-aria/focus";
5
+ import {useId as $4lVjK$useId, useDescription as $4lVjK$useDescription, filterDOMProps as $4lVjK$filterDOMProps, mergeProps as $4lVjK$mergeProps} from "@react-aria/utils";
6
+ import {privateValidationStateProp as $4lVjK$privateValidationStateProp} from "@react-stately/form";
7
+ import {useMemo as $4lVjK$useMemo} from "react";
8
+ import {useField as $4lVjK$useField} from "@react-aria/label";
9
+ import {useFocusWithin as $4lVjK$useFocusWithin} from "@react-aria/interactions";
10
+ import {useLocalizedStringFormatter as $4lVjK$useLocalizedStringFormatter, useLocale as $4lVjK$useLocale} from "@react-aria/i18n";
11
+
12
+
13
+ function $parcel$interopDefault(a) {
14
+ return a && a.__esModule ? a.default : a;
15
+ }
16
+ /*
17
+ * Copyright 2020 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
37
+ let buttonId = (0, $4lVjK$useId)();
38
+ let dialogId = (0, $4lVjK$useId)();
39
+ let fieldId = (0, $4lVjK$useId)();
40
+ let stringFormatter = (0, $4lVjK$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4lVjK$intlStringsmodulejs))), "@react-aria/datepicker");
41
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
42
+ let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $4lVjK$useField)({
43
+ ...props,
44
+ labelElementType: "span",
45
+ isInvalid: isInvalid,
46
+ errorMessage: props.errorMessage || validationErrors
47
+ });
48
+ let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref);
49
+ let labelledBy = fieldProps["aria-labelledby"] || fieldProps.id;
50
+ let { locale: locale } = (0, $4lVjK$useLocale)();
51
+ let date = state.formatValue(locale, {
52
+ month: "long"
53
+ });
54
+ let description = date ? stringFormatter.format("selectedDateDescription", {
55
+ date: date
56
+ }) : "";
57
+ let descProps = (0, $4lVjK$useDescription)(description);
58
+ let ariaDescribedBy = [
59
+ descProps["aria-describedby"],
60
+ fieldProps["aria-describedby"]
61
+ ].filter(Boolean).join(" ") || undefined;
62
+ let domProps = (0, $4lVjK$filterDOMProps)(props);
63
+ let focusManager = (0, $4lVjK$useMemo)(()=>(0, $4lVjK$createFocusManager)(ref), [
64
+ ref
65
+ ]);
66
+ let { focusWithinProps: focusWithinProps } = (0, $4lVjK$useFocusWithin)({
67
+ ...props,
68
+ isDisabled: state.isOpen,
69
+ onBlurWithin: props.onBlur,
70
+ onFocusWithin: props.onFocus,
71
+ onFocusWithinChange: props.onFocusChange
72
+ });
73
+ return {
74
+ groupProps: (0, $4lVjK$mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
75
+ role: "group",
76
+ "aria-disabled": props.isDisabled || null,
77
+ "aria-labelledby": labelledBy,
78
+ "aria-describedby": ariaDescribedBy,
79
+ onKeyDown (e) {
80
+ if (state.isOpen) return;
81
+ if (props.onKeyDown) props.onKeyDown(e);
82
+ },
83
+ onKeyUp (e) {
84
+ if (state.isOpen) return;
85
+ if (props.onKeyUp) props.onKeyUp(e);
86
+ }
87
+ }),
88
+ labelProps: {
89
+ ...labelProps,
90
+ onClick: ()=>{
91
+ focusManager.focusFirst();
92
+ }
93
+ },
94
+ fieldProps: {
95
+ ...fieldProps,
96
+ id: fieldId,
97
+ [(0, $16f0b7bb276bc17e$export$300019f83c56d282)]: "presentation",
98
+ "aria-describedby": ariaDescribedBy,
99
+ value: state.value,
100
+ onChange: state.setValue,
101
+ placeholderValue: props.placeholderValue,
102
+ hideTimeZone: props.hideTimeZone,
103
+ hourCycle: props.hourCycle,
104
+ shouldForceLeadingZeros: props.shouldForceLeadingZeros,
105
+ granularity: props.granularity,
106
+ isDisabled: props.isDisabled,
107
+ isReadOnly: props.isReadOnly,
108
+ isRequired: props.isRequired,
109
+ validationBehavior: props.validationBehavior,
110
+ // DatePicker owns the validation state for the date field.
111
+ [(0, $4lVjK$privateValidationStateProp)]: state,
112
+ autoFocus: props.autoFocus,
113
+ name: props.name
114
+ },
115
+ descriptionProps: descriptionProps,
116
+ errorMessageProps: errorMessageProps,
117
+ buttonProps: {
118
+ ...descProps,
119
+ id: buttonId,
120
+ "aria-haspopup": "dialog",
121
+ "aria-label": stringFormatter.format("calendar"),
122
+ "aria-labelledby": `${buttonId} ${labelledBy}`,
123
+ "aria-describedby": ariaDescribedBy,
124
+ "aria-expanded": state.isOpen,
125
+ isDisabled: props.isDisabled || props.isReadOnly,
126
+ onPress: ()=>state.setOpen(true)
127
+ },
128
+ dialogProps: {
129
+ id: dialogId,
130
+ "aria-labelledby": `${buttonId} ${labelledBy}`
131
+ },
132
+ calendarProps: {
133
+ autoFocus: true,
134
+ value: state.dateValue,
135
+ onChange: state.setDateValue,
136
+ minValue: props.minValue,
137
+ maxValue: props.maxValue,
138
+ isDisabled: props.isDisabled,
139
+ isReadOnly: props.isReadOnly,
140
+ isDateUnavailable: props.isDateUnavailable,
141
+ defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
142
+ isInvalid: state.isInvalid,
143
+ errorMessage: typeof props.errorMessage === "function" ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(" ")
144
+ },
145
+ isInvalid: isInvalid,
146
+ validationErrors: validationErrors,
147
+ validationDetails: validationDetails
148
+ };
149
+ }
150
+
151
+
152
+ export {$6057a3d2a53a12fd$export$42df105a73306d51 as useDatePicker};
153
+ //# sourceMappingURL=useDatePicker.mjs.map