@react-spectrum/datepicker 3.0.0-alpha.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/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/main.css +2 -0
- package/dist/main.css.map +1 -0
- package/dist/main.js +877 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +783 -0
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +70 -0
- package/src/.DS_Store +0 -0
- package/src/DateField.tsx +83 -0
- package/src/DatePicker.tsx +181 -0
- package/src/DatePickerField.tsx +59 -0
- package/src/DatePickerSegment.tsx +90 -0
- package/src/DateRangePicker.tsx +226 -0
- package/src/Input.tsx +129 -0
- package/src/TimeField.tsx +74 -0
- package/src/index.css +161 -0
- package/src/index.ts +18 -0
- package/src/utils.ts +62 -0
package/dist/module.js
ADDED
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
import { Flex } from "@react-spectrum/layout";
|
|
2
|
+
import { useProviderProps, useProvider } from "@react-spectrum/provider";
|
|
3
|
+
import { mergeProps, useEvent, useLayoutEffect, useResizeObserver } from "@react-aria/utils";
|
|
4
|
+
import _spectrumIconsUiCheckmarkMedium from "@spectrum-icons/ui/CheckmarkMedium";
|
|
5
|
+
import _spectrumIconsUiAlertMedium from "@spectrum-icons/ui/AlertMedium";
|
|
6
|
+
import { FieldButton } from "@react-spectrum/button";
|
|
7
|
+
import { Field } from "@react-spectrum/label";
|
|
8
|
+
import { Dialog, DialogTrigger } from "@react-spectrum/dialog";
|
|
9
|
+
import { useDatePickerFieldState, useTimeFieldState, useDatePickerState, useDateRangePickerState } from "@react-stately/datepicker";
|
|
10
|
+
import { usePress, useHover } from "@react-aria/interactions";
|
|
11
|
+
import { useLocale, useDateFormatter } from "@react-aria/i18n";
|
|
12
|
+
import { useFocusManager, FocusRing, FocusScope, useFocusRing } from "@react-aria/focus";
|
|
13
|
+
import { useDateSegment, useDateField, useDatePicker, useDisplayNames, useDateRangePicker } from "@react-aria/datepicker";
|
|
14
|
+
import _react, { useMemo, useRef, useCallback, useState } from "react";
|
|
15
|
+
import { NumberParser } from "@internationalized/number";
|
|
16
|
+
import _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
17
|
+
import { createCalendar } from "@internationalized/date";
|
|
18
|
+
import { Content } from "@react-spectrum/view";
|
|
19
|
+
import { classNames, useValueEffect, useStyleProps } from "@react-spectrum/utils";
|
|
20
|
+
import _spectrumIconsWorkflowCalendar from "@spectrum-icons/workflow/Calendar";
|
|
21
|
+
import { Calendar, RangeCalendar } from "@react-spectrum/calendar";
|
|
22
|
+
import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
|
|
23
|
+
import "./main.css";
|
|
24
|
+
|
|
25
|
+
function $parcel$interopDefault(a) {
|
|
26
|
+
return a && a.__esModule ? a.default : a;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-spectrum/datepicker/src/index.css
|
|
30
|
+
var $fc5c1aaa653a82d8278e64c777eca$exports = {};
|
|
31
|
+
$fc5c1aaa653a82d8278e64c777eca$exports = {
|
|
32
|
+
"react-spectrum-Datepicker-fieldWrapper": "_react-spectrum-Datepicker-fieldWrapper_ce051",
|
|
33
|
+
"react-spectrum-Datepicker-startField": "_react-spectrum-Datepicker-startField_ce051",
|
|
34
|
+
"react-spectrum-Datepicker-endField": "_react-spectrum-Datepicker-endField_ce051",
|
|
35
|
+
"react-spectrum-Datepicker-field": "_react-spectrum-Datepicker-field_ce051",
|
|
36
|
+
"react-spectrum-Datepicker-input": "_react-spectrum-Datepicker-input_ce051",
|
|
37
|
+
"react-spectrum-DateField": "_react-spectrum-DateField_ce051",
|
|
38
|
+
"react-spectrum-TimeField": "_react-spectrum-TimeField_ce051",
|
|
39
|
+
"react-spectrum-TimeField-fieldWrapper": "_react-spectrum-TimeField-fieldWrapper_ce051",
|
|
40
|
+
"react-spectrum-Datepicker-inputContents": "_react-spectrum-Datepicker-inputContents_ce051",
|
|
41
|
+
"react-spectrum-Datepicker-rangeDash": "_react-spectrum-Datepicker-rangeDash_ce051",
|
|
42
|
+
"react-spectrum-Datepicker-segments": "_react-spectrum-Datepicker-segments_ce051",
|
|
43
|
+
"react-spectrum-Datepicker-literal": "_react-spectrum-Datepicker-literal_ce051",
|
|
44
|
+
"react-spectrum-DatePicker-cell": "_react-spectrum-DatePicker-cell_ce051",
|
|
45
|
+
"is-placeholder": "_is-placeholder_ce051",
|
|
46
|
+
"is-read-only": "_is-read-only_ce051",
|
|
47
|
+
"react-spectrum-Datepicker-dialog": "_react-spectrum-Datepicker-dialog_ce051",
|
|
48
|
+
"react-spectrum-Datepicker-dialogContent": "_react-spectrum-Datepicker-dialogContent_ce051",
|
|
49
|
+
"react-spectrum-Datepicker-timeFields": "_react-spectrum-Datepicker-timeFields_ce051"
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function $d90fc87ed39803c47c775d8a63e9b3ac$export$DatePickerSegment(_ref) {
|
|
53
|
+
let {
|
|
54
|
+
segment,
|
|
55
|
+
state
|
|
56
|
+
} = _ref,
|
|
57
|
+
otherProps = _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose(_ref, ["segment", "state"]);
|
|
58
|
+
|
|
59
|
+
switch (segment.type) {
|
|
60
|
+
// A separator, e.g. punctuation
|
|
61
|
+
case 'literal':
|
|
62
|
+
return /*#__PURE__*/_react.createElement($d90fc87ed39803c47c775d8a63e9b3ac$var$LiteralSegment, {
|
|
63
|
+
segment: segment
|
|
64
|
+
});
|
|
65
|
+
// Editable segment
|
|
66
|
+
|
|
67
|
+
default:
|
|
68
|
+
return /*#__PURE__*/_react.createElement($d90fc87ed39803c47c775d8a63e9b3ac$var$EditableSegment, _babelRuntimeHelpersEsmExtends({
|
|
69
|
+
segment: segment,
|
|
70
|
+
state: state
|
|
71
|
+
}, otherProps));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var $fc5c1aaa653a82d8278e64c777eca$$interop$default = $parcel$interopDefault($fc5c1aaa653a82d8278e64c777eca$exports);
|
|
76
|
+
|
|
77
|
+
function $d90fc87ed39803c47c775d8a63e9b3ac$var$LiteralSegment(_ref2) {
|
|
78
|
+
let {
|
|
79
|
+
segment
|
|
80
|
+
} = _ref2;
|
|
81
|
+
let focusManager = useFocusManager();
|
|
82
|
+
let {
|
|
83
|
+
pressProps
|
|
84
|
+
} = usePress({
|
|
85
|
+
onPressStart: e => {
|
|
86
|
+
if (e.pointerType === 'mouse') {
|
|
87
|
+
let res = focusManager.focusNext({
|
|
88
|
+
from: e.target
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
if (!res) {
|
|
92
|
+
focusManager.focusPrevious({
|
|
93
|
+
from: e.target
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return /*#__PURE__*/_react.createElement("span", _babelRuntimeHelpersEsmExtends({
|
|
100
|
+
"aria-hidden": "true",
|
|
101
|
+
className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-literal')
|
|
102
|
+
}, pressProps), segment.text);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function $d90fc87ed39803c47c775d8a63e9b3ac$var$EditableSegment(_ref3) {
|
|
106
|
+
let {
|
|
107
|
+
segment,
|
|
108
|
+
state
|
|
109
|
+
} = _ref3,
|
|
110
|
+
otherProps = _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose(_ref3, ["segment", "state"]);
|
|
111
|
+
|
|
112
|
+
let ref = useRef();
|
|
113
|
+
let {
|
|
114
|
+
segmentProps
|
|
115
|
+
} = useDateSegment(otherProps, segment, state, ref);
|
|
116
|
+
let {
|
|
117
|
+
locale
|
|
118
|
+
} = useLocale();
|
|
119
|
+
let parser = useMemo(() => new NumberParser(locale), [locale]);
|
|
120
|
+
let isNumeric = useMemo(() => parser.isValidPartialNumber(segment.text), [segment.text, parser]);
|
|
121
|
+
return /*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersEsmExtends({
|
|
122
|
+
ref: ref,
|
|
123
|
+
className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-DatePicker-cell', {
|
|
124
|
+
'is-placeholder': segment.isPlaceholder,
|
|
125
|
+
'is-read-only': !segment.isEditable
|
|
126
|
+
}),
|
|
127
|
+
style: {
|
|
128
|
+
minWidth: !isNumeric ? null : String(segment.maxValue).length + 'ch'
|
|
129
|
+
}
|
|
130
|
+
}, segmentProps), segment.isPlaceholder ? '' : segment.text);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function $f89a664b25735c9291b8addecfd59013$export$DatePickerField(props) {
|
|
134
|
+
let {
|
|
135
|
+
isDisabled,
|
|
136
|
+
isReadOnly,
|
|
137
|
+
isRequired,
|
|
138
|
+
inputClassName
|
|
139
|
+
} = props;
|
|
140
|
+
let ref = useRef();
|
|
141
|
+
let {
|
|
142
|
+
locale
|
|
143
|
+
} = useLocale();
|
|
144
|
+
let state = useDatePickerFieldState(_babelRuntimeHelpersEsmExtends({}, props, {
|
|
145
|
+
locale,
|
|
146
|
+
createCalendar
|
|
147
|
+
}));
|
|
148
|
+
let {
|
|
149
|
+
fieldProps
|
|
150
|
+
} = useDateField(props, state, ref);
|
|
151
|
+
return /*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersEsmExtends({}, fieldProps, {
|
|
152
|
+
className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-segments', inputClassName),
|
|
153
|
+
ref: ref
|
|
154
|
+
}), state.segments.map((segment, i) => /*#__PURE__*/_react.createElement($d90fc87ed39803c47c775d8a63e9b3ac$export$DatePickerSegment, {
|
|
155
|
+
key: i,
|
|
156
|
+
segment: segment,
|
|
157
|
+
state: state,
|
|
158
|
+
isDisabled: isDisabled,
|
|
159
|
+
isReadOnly: isReadOnly,
|
|
160
|
+
isRequired: isRequired
|
|
161
|
+
})));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ASSET: /Users/govett/dev/react-spectrum-v3/node_modules/@adobe/spectrum-css-temp/components/textfield/vars.css
|
|
165
|
+
var $aa1c742e7a2a16aa7981ca9e2f4a89$exports = {};
|
|
166
|
+
$aa1c742e7a2a16aa7981ca9e2f4a89$exports = {
|
|
167
|
+
"spectrum-Textfield": "_spectrum-Textfield_61339",
|
|
168
|
+
"spectrum-Textfield--quiet": "_spectrum-Textfield--quiet_61339",
|
|
169
|
+
"spectrum-Textfield--multiline": "_spectrum-Textfield--multiline_61339",
|
|
170
|
+
"spectrum-Textfield-input": "_spectrum-Textfield-input_61339",
|
|
171
|
+
"is-placeholder": "_is-placeholder_61339",
|
|
172
|
+
"is-hovered": "_is-hovered_61339",
|
|
173
|
+
"spectrum-Textfield--valid": "_spectrum-Textfield--valid_61339",
|
|
174
|
+
"spectrum-Textfield--invalid": "_spectrum-Textfield--invalid_61339",
|
|
175
|
+
"spectrum-Textfield--loadable": "_spectrum-Textfield--loadable_61339",
|
|
176
|
+
"spectrum-Textfield-validationIcon": "_spectrum-Textfield-validationIcon_61339",
|
|
177
|
+
"spectrum-Textfield-icon": "_spectrum-Textfield-icon_61339",
|
|
178
|
+
"spectrum-Textfield-inputIcon": "_spectrum-Textfield-inputIcon_61339",
|
|
179
|
+
"spectrum-Textfield-circleLoader": "_spectrum-Textfield-circleLoader_61339",
|
|
180
|
+
"is-focused": "_is-focused_61339",
|
|
181
|
+
"focus-ring": "_focus-ring_61339",
|
|
182
|
+
"is-disabled": "_is-disabled_61339"
|
|
183
|
+
};
|
|
184
|
+
var $aa1c742e7a2a16aa7981ca9e2f4a89$$interop$default = $parcel$interopDefault($aa1c742e7a2a16aa7981ca9e2f4a89$exports);
|
|
185
|
+
|
|
186
|
+
function $f7a3dc9c77601846b3cceddb1f68b1a$export$Input(props) {
|
|
187
|
+
let defaultRef = useRef();
|
|
188
|
+
let {
|
|
189
|
+
isDisabled,
|
|
190
|
+
isQuiet,
|
|
191
|
+
inputClassName,
|
|
192
|
+
validationState,
|
|
193
|
+
children,
|
|
194
|
+
fieldProps,
|
|
195
|
+
inputRef = defaultRef,
|
|
196
|
+
className,
|
|
197
|
+
autoFocus,
|
|
198
|
+
style
|
|
199
|
+
} = props; // Reserve padding for the error icon when the width of the input is unconstrained.
|
|
200
|
+
// When constrained, don't reserve space because adding it only when invalid will
|
|
201
|
+
// not cause a layout shift.
|
|
202
|
+
|
|
203
|
+
let [reservePadding, setReservePadding] = useValueEffect(false);
|
|
204
|
+
let onResize = useCallback(() => setReservePadding(function* (reservePadding) {
|
|
205
|
+
if (reservePadding) {
|
|
206
|
+
// Try to collapse padding if the content is clipped.
|
|
207
|
+
if (inputRef.current.scrollWidth > inputRef.current.offsetWidth) {
|
|
208
|
+
let width = inputRef.current.parentElement.offsetWidth;
|
|
209
|
+
yield false; // If removing padding causes a layout shift, add it back.
|
|
210
|
+
|
|
211
|
+
if (inputRef.current.parentElement.offsetWidth !== width) {
|
|
212
|
+
yield true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
// Try to add padding if the content is not clipped.
|
|
217
|
+
if (inputRef.current.offsetWidth >= inputRef.current.scrollWidth) {
|
|
218
|
+
let width = inputRef.current.parentElement.offsetWidth;
|
|
219
|
+
yield true; // If adding padding does not change the width (i.e. width is constrained), remove it again.
|
|
220
|
+
|
|
221
|
+
if (inputRef.current.parentElement.offsetWidth === width) {
|
|
222
|
+
yield false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}), [inputRef, setReservePadding]);
|
|
227
|
+
useLayoutEffect(onResize, [onResize]);
|
|
228
|
+
useResizeObserver({
|
|
229
|
+
ref: inputRef,
|
|
230
|
+
onResize
|
|
231
|
+
}); // We also need to listen for resize events of the window so we can detect
|
|
232
|
+
// when there is enough space for the padding to be re-added. Ideally we'd
|
|
233
|
+
// use a resize observer on a parent element, but it's hard to know _what_
|
|
234
|
+
// parent element.
|
|
235
|
+
|
|
236
|
+
useEvent(useRef(window), 'resize', onResize);
|
|
237
|
+
let isInvalid = validationState === 'invalid';
|
|
238
|
+
let textfieldClass = classNames($aa1c742e7a2a16aa7981ca9e2f4a89$$interop$default, 'spectrum-Textfield', {
|
|
239
|
+
'spectrum-Textfield--invalid': isInvalid,
|
|
240
|
+
'spectrum-Textfield--valid': validationState === 'valid',
|
|
241
|
+
'spectrum-Textfield--quiet': isQuiet
|
|
242
|
+
}, classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-field'), className);
|
|
243
|
+
let inputClass = classNames($aa1c742e7a2a16aa7981ca9e2f4a89$$interop$default, 'spectrum-Textfield-input', {
|
|
244
|
+
'is-disabled': isDisabled,
|
|
245
|
+
'is-invalid': isInvalid
|
|
246
|
+
}, reservePadding && classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-input'), inputClassName);
|
|
247
|
+
let iconClass = classNames($aa1c742e7a2a16aa7981ca9e2f4a89$$interop$default, 'spectrum-Textfield-validationIcon');
|
|
248
|
+
let validationIcon = null;
|
|
249
|
+
|
|
250
|
+
if (validationState === 'invalid') {
|
|
251
|
+
validationIcon = /*#__PURE__*/_react.createElement(_spectrumIconsUiAlertMedium, {
|
|
252
|
+
UNSAFE_className: iconClass
|
|
253
|
+
});
|
|
254
|
+
} else if (validationState === 'valid') {
|
|
255
|
+
validationIcon = /*#__PURE__*/_react.createElement(_spectrumIconsUiCheckmarkMedium, {
|
|
256
|
+
UNSAFE_className: iconClass
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return /*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersEsmExtends({}, mergeProps(fieldProps), {
|
|
261
|
+
className: textfieldClass,
|
|
262
|
+
style: style
|
|
263
|
+
}), /*#__PURE__*/_react.createElement(FocusRing, {
|
|
264
|
+
focusClass: classNames($aa1c742e7a2a16aa7981ca9e2f4a89$$interop$default, 'is-focused'),
|
|
265
|
+
focusRingClass: classNames($aa1c742e7a2a16aa7981ca9e2f4a89$$interop$default, 'focus-ring'),
|
|
266
|
+
isTextInput: true,
|
|
267
|
+
within: true
|
|
268
|
+
}, /*#__PURE__*/_react.createElement("div", {
|
|
269
|
+
role: "presentation",
|
|
270
|
+
className: inputClass
|
|
271
|
+
}, /*#__PURE__*/_react.createElement("div", {
|
|
272
|
+
role: "presentation",
|
|
273
|
+
className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-inputContents'),
|
|
274
|
+
ref: inputRef
|
|
275
|
+
}, /*#__PURE__*/_react.createElement(FocusScope, {
|
|
276
|
+
autoFocus: autoFocus
|
|
277
|
+
}, children)))), validationIcon);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ASSET: /Users/govett/dev/react-spectrum-v3/node_modules/@adobe/spectrum-css-temp/components/inputgroup/vars.css
|
|
281
|
+
var $ed163f34af6780259e0266609fb62099$exports = {};
|
|
282
|
+
$ed163f34af6780259e0266609fb62099$exports = {
|
|
283
|
+
"spectrum-InputGroup": "_spectrum-InputGroup_d053e",
|
|
284
|
+
"spectrum-FieldButton": "_spectrum-FieldButton_d053e",
|
|
285
|
+
"is-disabled": "_is-disabled_d053e",
|
|
286
|
+
"spectrum-InputGroup--invalid": "_spectrum-InputGroup--invalid_d053e",
|
|
287
|
+
"spectrum-InputGroup--quiet": "_spectrum-InputGroup--quiet_d053e",
|
|
288
|
+
"spectrum-InputGroup-field": "_spectrum-InputGroup-field_d053e",
|
|
289
|
+
"spectrum-InputGroup-input-validationIcon": "_spectrum-InputGroup-input-validationIcon_d053e",
|
|
290
|
+
"spectrum-InputGroup-input-circleLoader": "_spectrum-InputGroup-input-circleLoader_d053e",
|
|
291
|
+
"spectrum-InputGroup-input": "_spectrum-InputGroup-input_d053e",
|
|
292
|
+
"spectrum-InputGroup-icon": "_spectrum-InputGroup-icon_d053e",
|
|
293
|
+
"spectrum-InputGroup-popover--quiet": "_spectrum-InputGroup-popover--quiet_d053e",
|
|
294
|
+
"spectrum-Datepicker--range": "_spectrum-Datepicker--range_d053e",
|
|
295
|
+
"spectrum-Datepicker--datetimeRange": "_spectrum-Datepicker--datetimeRange_d053e",
|
|
296
|
+
"spectrum-Datepicker-startField": "_spectrum-Datepicker-startField_d053e",
|
|
297
|
+
"spectrum-Datepicker-endField": "_spectrum-Datepicker-endField_d053e",
|
|
298
|
+
"spectrum-Datepicker--rangeDash": "_spectrum-Datepicker--rangeDash_d053e",
|
|
299
|
+
"is-focused": "_is-focused_d053e",
|
|
300
|
+
"spectrum-Datepicker-focusRing": "_spectrum-Datepicker-focusRing_d053e",
|
|
301
|
+
"is-hovered": "_is-hovered_d053e",
|
|
302
|
+
"focus-ring": "_focus-ring_d053e",
|
|
303
|
+
"is-selected": "_is-selected_d053e",
|
|
304
|
+
"spectrum-FieldButton--invalid": "_spectrum-FieldButton--invalid_d053e"
|
|
305
|
+
};
|
|
306
|
+
export function TimeField(props) {
|
|
307
|
+
props = useProviderProps(props);
|
|
308
|
+
let {
|
|
309
|
+
autoFocus,
|
|
310
|
+
isDisabled,
|
|
311
|
+
isReadOnly,
|
|
312
|
+
isRequired,
|
|
313
|
+
isQuiet
|
|
314
|
+
} = props;
|
|
315
|
+
let ref = useRef();
|
|
316
|
+
let {
|
|
317
|
+
locale
|
|
318
|
+
} = useLocale();
|
|
319
|
+
let state = useTimeFieldState(_babelRuntimeHelpersEsmExtends({}, props, {
|
|
320
|
+
locale,
|
|
321
|
+
createCalendar
|
|
322
|
+
}));
|
|
323
|
+
let {
|
|
324
|
+
labelProps,
|
|
325
|
+
fieldProps,
|
|
326
|
+
descriptionProps,
|
|
327
|
+
errorMessageProps
|
|
328
|
+
} = useDateField(props, state, ref);
|
|
329
|
+
return /*#__PURE__*/_react.createElement(Field, _babelRuntimeHelpersEsmExtends({}, props, {
|
|
330
|
+
labelProps: labelProps,
|
|
331
|
+
descriptionProps: descriptionProps,
|
|
332
|
+
errorMessageProps: errorMessageProps,
|
|
333
|
+
validationState: state.validationState,
|
|
334
|
+
UNSAFE_className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-TimeField-fieldWrapper')
|
|
335
|
+
}), /*#__PURE__*/_react.createElement($f7a3dc9c77601846b3cceddb1f68b1a$export$Input, {
|
|
336
|
+
fieldProps: fieldProps,
|
|
337
|
+
isDisabled: isDisabled,
|
|
338
|
+
isQuiet: isQuiet,
|
|
339
|
+
autoFocus: autoFocus,
|
|
340
|
+
validationState: state.validationState,
|
|
341
|
+
inputRef: ref,
|
|
342
|
+
className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-TimeField')
|
|
343
|
+
}, state.segments.map((segment, i) => /*#__PURE__*/_react.createElement($d90fc87ed39803c47c775d8a63e9b3ac$export$DatePickerSegment, {
|
|
344
|
+
key: i,
|
|
345
|
+
segment: segment,
|
|
346
|
+
state: state,
|
|
347
|
+
isDisabled: isDisabled,
|
|
348
|
+
isReadOnly: isReadOnly,
|
|
349
|
+
isRequired: isRequired
|
|
350
|
+
}))));
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function $fceb515efc46c02b9fa71489a5fd9a8$export$useFormatHelpText(props) {
|
|
354
|
+
let formatter = useDateFormatter({
|
|
355
|
+
dateStyle: 'short'
|
|
356
|
+
});
|
|
357
|
+
let displayNames = useDisplayNames();
|
|
358
|
+
return useMemo(() => {
|
|
359
|
+
if (props.description) {
|
|
360
|
+
return props.description;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (props.showFormatHelpText) {
|
|
364
|
+
return formatter.formatToParts(new Date()).map(s => {
|
|
365
|
+
if (s.type === 'literal') {
|
|
366
|
+
return s.value;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return displayNames.of(s.type);
|
|
370
|
+
}).join(' ');
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return '';
|
|
374
|
+
}, [props.description, props.showFormatHelpText, formatter, displayNames]);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function $fceb515efc46c02b9fa71489a5fd9a8$export$useVisibleMonths(maxVisibleMonths) {
|
|
378
|
+
let {
|
|
379
|
+
scale
|
|
380
|
+
} = useProvider();
|
|
381
|
+
let [visibleMonths, setVisibleMonths] = useState($fceb515efc46c02b9fa71489a5fd9a8$var$getVisibleMonths(scale));
|
|
382
|
+
useLayoutEffect(() => {
|
|
383
|
+
let onResize = () => setVisibleMonths($fceb515efc46c02b9fa71489a5fd9a8$var$getVisibleMonths(scale));
|
|
384
|
+
|
|
385
|
+
onResize();
|
|
386
|
+
window.addEventListener('resize', onResize);
|
|
387
|
+
return () => {
|
|
388
|
+
window.removeEventListener('resize', onResize);
|
|
389
|
+
};
|
|
390
|
+
}, [scale]);
|
|
391
|
+
return Math.max(1, Math.min(visibleMonths, maxVisibleMonths, 3));
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function $fceb515efc46c02b9fa71489a5fd9a8$var$getVisibleMonths(scale) {
|
|
395
|
+
let monthWidth = scale === 'large' ? 336 : 280;
|
|
396
|
+
let gap = scale === 'large' ? 30 : 24;
|
|
397
|
+
let popoverPadding = scale === 'large' ? 32 : 48;
|
|
398
|
+
return Math.floor((window.innerWidth - popoverPadding * 2) / (monthWidth + gap));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
var $ed163f34af6780259e0266609fb62099$$interop$default = $parcel$interopDefault($ed163f34af6780259e0266609fb62099$exports);
|
|
402
|
+
export function DatePicker(props) {
|
|
403
|
+
props = useProviderProps(props);
|
|
404
|
+
let {
|
|
405
|
+
autoFocus,
|
|
406
|
+
isQuiet,
|
|
407
|
+
isDisabled,
|
|
408
|
+
isReadOnly,
|
|
409
|
+
isRequired,
|
|
410
|
+
placeholderValue,
|
|
411
|
+
maxVisibleMonths = 1
|
|
412
|
+
} = props;
|
|
413
|
+
let {
|
|
414
|
+
hoverProps,
|
|
415
|
+
isHovered
|
|
416
|
+
} = useHover({
|
|
417
|
+
isDisabled
|
|
418
|
+
});
|
|
419
|
+
let targetRef = useRef();
|
|
420
|
+
let state = useDatePickerState(props);
|
|
421
|
+
let {
|
|
422
|
+
groupProps,
|
|
423
|
+
labelProps,
|
|
424
|
+
fieldProps,
|
|
425
|
+
descriptionProps,
|
|
426
|
+
errorMessageProps,
|
|
427
|
+
buttonProps,
|
|
428
|
+
dialogProps
|
|
429
|
+
} = useDatePicker(props, state, targetRef);
|
|
430
|
+
let {
|
|
431
|
+
value,
|
|
432
|
+
setValue,
|
|
433
|
+
isOpen,
|
|
434
|
+
setOpen
|
|
435
|
+
} = state;
|
|
436
|
+
let {
|
|
437
|
+
direction
|
|
438
|
+
} = useLocale();
|
|
439
|
+
let {
|
|
440
|
+
isFocused,
|
|
441
|
+
isFocusVisible,
|
|
442
|
+
focusProps
|
|
443
|
+
} = useFocusRing({
|
|
444
|
+
within: true,
|
|
445
|
+
isTextInput: true,
|
|
446
|
+
autoFocus
|
|
447
|
+
});
|
|
448
|
+
let className = classNames($ed163f34af6780259e0266609fb62099$$interop$default, 'spectrum-InputGroup', {
|
|
449
|
+
'spectrum-InputGroup--quiet': isQuiet,
|
|
450
|
+
'spectrum-InputGroup--invalid': state.validationState === 'invalid',
|
|
451
|
+
'is-disabled': isDisabled,
|
|
452
|
+
'is-hovered': isHovered,
|
|
453
|
+
'is-focused': isFocused,
|
|
454
|
+
'focus-ring': isFocusVisible
|
|
455
|
+
});
|
|
456
|
+
let fieldClassName = classNames($ed163f34af6780259e0266609fb62099$$interop$default, 'spectrum-InputGroup-input', {
|
|
457
|
+
'is-disabled': isDisabled,
|
|
458
|
+
'is-invalid': state.validationState === 'invalid'
|
|
459
|
+
}); // Note: this description is intentionally not passed to useDatePicker.
|
|
460
|
+
// The format help text is unnecessary for screen reader users because each segment already has a label.
|
|
461
|
+
|
|
462
|
+
let description = $fceb515efc46c02b9fa71489a5fd9a8$export$useFormatHelpText(props);
|
|
463
|
+
|
|
464
|
+
if (description && !props.description) {
|
|
465
|
+
descriptionProps.id = null;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
let placeholder = placeholderValue;
|
|
469
|
+
let timePlaceholder = placeholder && 'hour' in placeholder ? placeholder : null;
|
|
470
|
+
let timeMinValue = props.minValue && 'hour' in props.minValue ? props.minValue : null;
|
|
471
|
+
let timeMaxValue = props.maxValue && 'hour' in props.maxValue ? props.maxValue : null;
|
|
472
|
+
let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' || state.granularity === 'millisecond' ? state.granularity : null;
|
|
473
|
+
let showTimeField = !!timeGranularity;
|
|
474
|
+
let visibleMonths = $fceb515efc46c02b9fa71489a5fd9a8$export$useVisibleMonths(maxVisibleMonths);
|
|
475
|
+
return /*#__PURE__*/_react.createElement(Field, _babelRuntimeHelpersEsmExtends({}, props, {
|
|
476
|
+
ref: targetRef,
|
|
477
|
+
description: description,
|
|
478
|
+
labelProps: labelProps,
|
|
479
|
+
descriptionProps: descriptionProps,
|
|
480
|
+
errorMessageProps: errorMessageProps,
|
|
481
|
+
validationState: state.validationState,
|
|
482
|
+
UNSAFE_className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-fieldWrapper')
|
|
483
|
+
}), /*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersEsmExtends({}, mergeProps(groupProps, hoverProps, focusProps), {
|
|
484
|
+
className: className
|
|
485
|
+
}), /*#__PURE__*/_react.createElement($f7a3dc9c77601846b3cceddb1f68b1a$export$Input, {
|
|
486
|
+
isDisabled: isDisabled,
|
|
487
|
+
isQuiet: isQuiet,
|
|
488
|
+
validationState: state.validationState,
|
|
489
|
+
autoFocus: autoFocus,
|
|
490
|
+
className: classNames($ed163f34af6780259e0266609fb62099$$interop$default, 'spectrum-InputGroup-field'),
|
|
491
|
+
inputClassName: fieldClassName
|
|
492
|
+
}, /*#__PURE__*/_react.createElement($f89a664b25735c9291b8addecfd59013$export$DatePickerField, _babelRuntimeHelpersEsmExtends({}, fieldProps, {
|
|
493
|
+
isQuiet: isQuiet,
|
|
494
|
+
validationState: state.validationState,
|
|
495
|
+
value: value,
|
|
496
|
+
onChange: setValue,
|
|
497
|
+
placeholderValue: placeholderValue,
|
|
498
|
+
isDisabled: isDisabled,
|
|
499
|
+
isReadOnly: isReadOnly,
|
|
500
|
+
isRequired: isRequired,
|
|
501
|
+
granularity: props.granularity,
|
|
502
|
+
hourCycle: props.hourCycle,
|
|
503
|
+
inputClassName: fieldClassName,
|
|
504
|
+
hideTimeZone: props.hideTimeZone
|
|
505
|
+
}))), /*#__PURE__*/_react.createElement(DialogTrigger, {
|
|
506
|
+
type: "popover",
|
|
507
|
+
mobileType: "tray",
|
|
508
|
+
placement: direction === 'rtl' ? 'bottom right' : 'bottom left',
|
|
509
|
+
targetRef: targetRef,
|
|
510
|
+
hideArrow: true,
|
|
511
|
+
isOpen: isOpen,
|
|
512
|
+
onOpenChange: setOpen
|
|
513
|
+
}, /*#__PURE__*/_react.createElement(FieldButton, _babelRuntimeHelpersEsmExtends({}, buttonProps, {
|
|
514
|
+
UNSAFE_className: classNames($ed163f34af6780259e0266609fb62099$$interop$default, 'spectrum-FieldButton'),
|
|
515
|
+
isQuiet: isQuiet,
|
|
516
|
+
validationState: state.validationState,
|
|
517
|
+
isDisabled: isDisabled || isReadOnly
|
|
518
|
+
}), /*#__PURE__*/_react.createElement(_spectrumIconsWorkflowCalendar, null)), /*#__PURE__*/_react.createElement(Dialog, _babelRuntimeHelpersEsmExtends({
|
|
519
|
+
UNSAFE_className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-dialog')
|
|
520
|
+
}, dialogProps), /*#__PURE__*/_react.createElement(Content, {
|
|
521
|
+
UNSAFE_className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-dialogContent')
|
|
522
|
+
}, /*#__PURE__*/_react.createElement(Calendar, {
|
|
523
|
+
autoFocus: true,
|
|
524
|
+
value: state.dateValue,
|
|
525
|
+
onChange: state.setDateValue,
|
|
526
|
+
visibleMonths: visibleMonths,
|
|
527
|
+
minValue: props.minValue,
|
|
528
|
+
maxValue: props.maxValue
|
|
529
|
+
}), showTimeField && /*#__PURE__*/_react.createElement("div", {
|
|
530
|
+
className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-timeFields')
|
|
531
|
+
}, /*#__PURE__*/_react.createElement(TimeField, {
|
|
532
|
+
label: "Time",
|
|
533
|
+
value: state.timeValue,
|
|
534
|
+
onChange: state.setTimeValue,
|
|
535
|
+
placeholderValue: timePlaceholder,
|
|
536
|
+
granularity: timeGranularity,
|
|
537
|
+
minValue: timeMinValue,
|
|
538
|
+
maxValue: timeMaxValue,
|
|
539
|
+
hourCycle: props.hourCycle,
|
|
540
|
+
hideTimeZone: props.hideTimeZone,
|
|
541
|
+
marginTop: "size-100"
|
|
542
|
+
})))))));
|
|
543
|
+
}
|
|
544
|
+
export function DateRangePicker(props) {
|
|
545
|
+
var _state$timeRange, _state$timeRange2;
|
|
546
|
+
|
|
547
|
+
props = useProviderProps(props);
|
|
548
|
+
|
|
549
|
+
let {
|
|
550
|
+
isQuiet,
|
|
551
|
+
isDisabled,
|
|
552
|
+
isReadOnly,
|
|
553
|
+
isRequired,
|
|
554
|
+
autoFocus,
|
|
555
|
+
placeholderValue,
|
|
556
|
+
maxVisibleMonths = 1
|
|
557
|
+
} = props,
|
|
558
|
+
otherProps = _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose(props, ["isQuiet", "isDisabled", "isReadOnly", "isRequired", "autoFocus", "placeholderValue", "maxVisibleMonths"]);
|
|
559
|
+
|
|
560
|
+
let {
|
|
561
|
+
styleProps
|
|
562
|
+
} = useStyleProps(otherProps);
|
|
563
|
+
let {
|
|
564
|
+
hoverProps,
|
|
565
|
+
isHovered
|
|
566
|
+
} = useHover({
|
|
567
|
+
isDisabled
|
|
568
|
+
});
|
|
569
|
+
let targetRef = useRef();
|
|
570
|
+
let state = useDateRangePickerState(props);
|
|
571
|
+
let {
|
|
572
|
+
labelProps,
|
|
573
|
+
groupProps,
|
|
574
|
+
buttonProps,
|
|
575
|
+
dialogProps,
|
|
576
|
+
startFieldProps,
|
|
577
|
+
endFieldProps,
|
|
578
|
+
descriptionProps,
|
|
579
|
+
errorMessageProps
|
|
580
|
+
} = useDateRangePicker(props, state, targetRef);
|
|
581
|
+
let {
|
|
582
|
+
value,
|
|
583
|
+
isOpen,
|
|
584
|
+
setOpen
|
|
585
|
+
} = state;
|
|
586
|
+
let {
|
|
587
|
+
direction
|
|
588
|
+
} = useLocale();
|
|
589
|
+
let {
|
|
590
|
+
isFocused,
|
|
591
|
+
isFocusVisible,
|
|
592
|
+
focusProps
|
|
593
|
+
} = useFocusRing({
|
|
594
|
+
within: true,
|
|
595
|
+
isTextInput: true,
|
|
596
|
+
autoFocus
|
|
597
|
+
});
|
|
598
|
+
let className = classNames($ed163f34af6780259e0266609fb62099$$interop$default, 'spectrum-InputGroup', {
|
|
599
|
+
'spectrum-InputGroup--quiet': isQuiet,
|
|
600
|
+
'spectrum-InputGroup--invalid': state.validationState === 'invalid',
|
|
601
|
+
'is-disabled': isDisabled,
|
|
602
|
+
'is-hovered': isHovered,
|
|
603
|
+
'is-focused': isFocused,
|
|
604
|
+
'focus-ring': isFocusVisible
|
|
605
|
+
}, styleProps.className);
|
|
606
|
+
let fieldClassName = classNames($ed163f34af6780259e0266609fb62099$$interop$default, 'spectrum-InputGroup-input', {
|
|
607
|
+
'is-disabled': isDisabled,
|
|
608
|
+
'is-invalid': state.validationState === 'invalid'
|
|
609
|
+
}); // Note: this description is intentionally not passed to useDatePicker.
|
|
610
|
+
// The format help text is unnecessary for screen reader users because each segment already has a label.
|
|
611
|
+
|
|
612
|
+
let description = $fceb515efc46c02b9fa71489a5fd9a8$export$useFormatHelpText(props);
|
|
613
|
+
|
|
614
|
+
if (description && !props.description) {
|
|
615
|
+
descriptionProps.id = null;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
let placeholder = placeholderValue;
|
|
619
|
+
let timePlaceholder = placeholder && 'hour' in placeholder ? placeholder : null;
|
|
620
|
+
let timeMinValue = props.minValue && 'hour' in props.minValue ? props.minValue : null;
|
|
621
|
+
let timeMaxValue = props.maxValue && 'hour' in props.maxValue ? props.maxValue : null;
|
|
622
|
+
let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' || state.granularity === 'millisecond' ? state.granularity : null;
|
|
623
|
+
let showTimeField = !!timeGranularity;
|
|
624
|
+
let visibleMonths = $fceb515efc46c02b9fa71489a5fd9a8$export$useVisibleMonths(maxVisibleMonths);
|
|
625
|
+
return /*#__PURE__*/_react.createElement(Field, _babelRuntimeHelpersEsmExtends({}, props, {
|
|
626
|
+
ref: targetRef,
|
|
627
|
+
description: description,
|
|
628
|
+
labelProps: labelProps,
|
|
629
|
+
descriptionProps: descriptionProps,
|
|
630
|
+
errorMessageProps: errorMessageProps,
|
|
631
|
+
validationState: state.validationState,
|
|
632
|
+
UNSAFE_className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-fieldWrapper')
|
|
633
|
+
}), /*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersEsmExtends({}, styleProps, mergeProps(groupProps, hoverProps, focusProps), {
|
|
634
|
+
className: className
|
|
635
|
+
}), /*#__PURE__*/_react.createElement($f7a3dc9c77601846b3cceddb1f68b1a$export$Input, {
|
|
636
|
+
isDisabled: isDisabled,
|
|
637
|
+
isQuiet: isQuiet,
|
|
638
|
+
validationState: state.validationState,
|
|
639
|
+
autoFocus: autoFocus,
|
|
640
|
+
className: classNames($ed163f34af6780259e0266609fb62099$$interop$default, 'spectrum-InputGroup-field'),
|
|
641
|
+
inputClassName: fieldClassName
|
|
642
|
+
}, /*#__PURE__*/_react.createElement($f89a664b25735c9291b8addecfd59013$export$DatePickerField, _babelRuntimeHelpersEsmExtends({}, startFieldProps, {
|
|
643
|
+
isQuiet: props.isQuiet,
|
|
644
|
+
isDisabled: isDisabled,
|
|
645
|
+
isReadOnly: isReadOnly,
|
|
646
|
+
isRequired: isRequired,
|
|
647
|
+
validationState: state.validationState,
|
|
648
|
+
placeholderValue: placeholderValue,
|
|
649
|
+
value: (value == null ? void 0 : value.start) || null,
|
|
650
|
+
defaultValue: null,
|
|
651
|
+
onChange: start => state.setDateTime('start', start),
|
|
652
|
+
granularity: props.granularity,
|
|
653
|
+
hourCycle: props.hourCycle,
|
|
654
|
+
inputClassName: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-startField')
|
|
655
|
+
})), /*#__PURE__*/_react.createElement($f52d33e8ff443414997ed587ce7ed905$var$DateRangeDash, null), /*#__PURE__*/_react.createElement($f89a664b25735c9291b8addecfd59013$export$DatePickerField, _babelRuntimeHelpersEsmExtends({}, endFieldProps, {
|
|
656
|
+
isQuiet: props.isQuiet,
|
|
657
|
+
isDisabled: isDisabled,
|
|
658
|
+
isReadOnly: isReadOnly,
|
|
659
|
+
isRequired: isRequired,
|
|
660
|
+
validationState: state.validationState,
|
|
661
|
+
placeholderValue: placeholderValue,
|
|
662
|
+
value: (value == null ? void 0 : value.end) || null,
|
|
663
|
+
defaultValue: null,
|
|
664
|
+
onChange: end => state.setDateTime('end', end),
|
|
665
|
+
granularity: props.granularity,
|
|
666
|
+
hourCycle: props.hourCycle,
|
|
667
|
+
inputClassName: classNames($ed163f34af6780259e0266609fb62099$$interop$default, 'spectrum-Datepicker-endField', classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-endField'))
|
|
668
|
+
}))), /*#__PURE__*/_react.createElement(DialogTrigger, {
|
|
669
|
+
type: "popover",
|
|
670
|
+
mobileType: "tray",
|
|
671
|
+
placement: direction === 'rtl' ? 'bottom right' : 'bottom left',
|
|
672
|
+
targetRef: targetRef,
|
|
673
|
+
hideArrow: true,
|
|
674
|
+
isOpen: isOpen,
|
|
675
|
+
onOpenChange: setOpen
|
|
676
|
+
}, /*#__PURE__*/_react.createElement(FieldButton, _babelRuntimeHelpersEsmExtends({}, buttonProps, {
|
|
677
|
+
UNSAFE_className: classNames($ed163f34af6780259e0266609fb62099$$interop$default, 'spectrum-FieldButton'),
|
|
678
|
+
isQuiet: isQuiet,
|
|
679
|
+
validationState: state.validationState,
|
|
680
|
+
isDisabled: isDisabled || isReadOnly
|
|
681
|
+
}), /*#__PURE__*/_react.createElement(_spectrumIconsWorkflowCalendar, null)), /*#__PURE__*/_react.createElement(Dialog, _babelRuntimeHelpersEsmExtends({
|
|
682
|
+
UNSAFE_className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-dialog')
|
|
683
|
+
}, dialogProps), /*#__PURE__*/_react.createElement(Content, {
|
|
684
|
+
UNSAFE_className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-dialogContent')
|
|
685
|
+
}, /*#__PURE__*/_react.createElement(RangeCalendar, {
|
|
686
|
+
autoFocus: true,
|
|
687
|
+
value: state.dateRange,
|
|
688
|
+
onChange: state.setDateRange,
|
|
689
|
+
visibleMonths: visibleMonths,
|
|
690
|
+
minValue: props.minValue,
|
|
691
|
+
maxValue: props.maxValue
|
|
692
|
+
}), showTimeField && /*#__PURE__*/_react.createElement(Flex, {
|
|
693
|
+
gap: "size-100",
|
|
694
|
+
marginTop: "size-100",
|
|
695
|
+
UNSAFE_className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-timeFields')
|
|
696
|
+
}, /*#__PURE__*/_react.createElement(TimeField, {
|
|
697
|
+
label: "Start time",
|
|
698
|
+
value: ((_state$timeRange = state.timeRange) == null ? void 0 : _state$timeRange.start) || null,
|
|
699
|
+
onChange: v => state.setTime('start', v),
|
|
700
|
+
placeholderValue: timePlaceholder,
|
|
701
|
+
granularity: timeGranularity,
|
|
702
|
+
minValue: timeMinValue,
|
|
703
|
+
maxValue: timeMaxValue,
|
|
704
|
+
hourCycle: props.hourCycle,
|
|
705
|
+
hideTimeZone: props.hideTimeZone,
|
|
706
|
+
flex: true
|
|
707
|
+
}), /*#__PURE__*/_react.createElement(TimeField, {
|
|
708
|
+
label: "End time",
|
|
709
|
+
value: ((_state$timeRange2 = state.timeRange) == null ? void 0 : _state$timeRange2.end) || null,
|
|
710
|
+
onChange: v => state.setTime('end', v),
|
|
711
|
+
placeholderValue: timePlaceholder,
|
|
712
|
+
granularity: timeGranularity,
|
|
713
|
+
minValue: timeMinValue,
|
|
714
|
+
maxValue: timeMaxValue,
|
|
715
|
+
hourCycle: props.hourCycle,
|
|
716
|
+
hideTimeZone: props.hideTimeZone,
|
|
717
|
+
flex: true
|
|
718
|
+
})))))));
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function $f52d33e8ff443414997ed587ce7ed905$var$DateRangeDash() {
|
|
722
|
+
return /*#__PURE__*/_react.createElement("div", {
|
|
723
|
+
"aria-hidden": "true",
|
|
724
|
+
className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-rangeDash')
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
export function DateField(props) {
|
|
729
|
+
props = useProviderProps(props);
|
|
730
|
+
let {
|
|
731
|
+
autoFocus,
|
|
732
|
+
isDisabled,
|
|
733
|
+
isReadOnly,
|
|
734
|
+
isRequired,
|
|
735
|
+
isQuiet
|
|
736
|
+
} = props;
|
|
737
|
+
let ref = useRef();
|
|
738
|
+
let {
|
|
739
|
+
locale
|
|
740
|
+
} = useLocale();
|
|
741
|
+
let state = useDatePickerFieldState(_babelRuntimeHelpersEsmExtends({}, props, {
|
|
742
|
+
locale,
|
|
743
|
+
createCalendar
|
|
744
|
+
}));
|
|
745
|
+
let {
|
|
746
|
+
labelProps,
|
|
747
|
+
fieldProps,
|
|
748
|
+
descriptionProps,
|
|
749
|
+
errorMessageProps
|
|
750
|
+
} = useDateField(props, state, ref); // Note: this description is intentionally not passed to useDatePicker.
|
|
751
|
+
// The format help text is unnecessary for screen reader users because each segment already has a label.
|
|
752
|
+
|
|
753
|
+
let description = $fceb515efc46c02b9fa71489a5fd9a8$export$useFormatHelpText(props);
|
|
754
|
+
|
|
755
|
+
if (description && !props.description) {
|
|
756
|
+
descriptionProps.id = null;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
return /*#__PURE__*/_react.createElement(Field, _babelRuntimeHelpersEsmExtends({}, props, {
|
|
760
|
+
description: description,
|
|
761
|
+
labelProps: labelProps,
|
|
762
|
+
descriptionProps: descriptionProps,
|
|
763
|
+
errorMessageProps: errorMessageProps,
|
|
764
|
+
validationState: state.validationState,
|
|
765
|
+
UNSAFE_className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-Datepicker-fieldWrapper')
|
|
766
|
+
}), /*#__PURE__*/_react.createElement($f7a3dc9c77601846b3cceddb1f68b1a$export$Input, {
|
|
767
|
+
fieldProps: fieldProps,
|
|
768
|
+
isDisabled: isDisabled,
|
|
769
|
+
isQuiet: isQuiet,
|
|
770
|
+
autoFocus: autoFocus,
|
|
771
|
+
validationState: state.validationState,
|
|
772
|
+
inputRef: ref,
|
|
773
|
+
className: classNames($fc5c1aaa653a82d8278e64c777eca$$interop$default, 'react-spectrum-DateField')
|
|
774
|
+
}, state.segments.map((segment, i) => /*#__PURE__*/_react.createElement($d90fc87ed39803c47c775d8a63e9b3ac$export$DatePickerSegment, {
|
|
775
|
+
key: i,
|
|
776
|
+
segment: segment,
|
|
777
|
+
state: state,
|
|
778
|
+
isDisabled: isDisabled,
|
|
779
|
+
isReadOnly: isReadOnly,
|
|
780
|
+
isRequired: isRequired
|
|
781
|
+
}))));
|
|
782
|
+
}
|
|
783
|
+
//# sourceMappingURL=module.js.map
|