@fluentui/react-datepicker-compat 0.0.0-nightly-20250423-0405.1 → 0.0.0-nightly-20250423-1415.1
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/CHANGELOG.md +19 -19
- package/dist/index.d.ts +245 -0
- package/lib/DatePicker.js +1 -0
- package/lib/DatePicker.js.map +1 -0
- package/lib/components/DatePicker/DatePicker.js +10 -0
- package/lib/components/DatePicker/DatePicker.js.map +1 -0
- package/lib/components/DatePicker/DatePicker.types.js +3 -0
- package/lib/components/DatePicker/DatePicker.types.js.map +1 -0
- package/lib/components/DatePicker/defaults.js +14 -0
- package/lib/components/DatePicker/defaults.js.map +1 -0
- package/lib/components/DatePicker/index.js +5 -0
- package/lib/components/DatePicker/index.js.map +1 -0
- package/lib/components/DatePicker/renderDatePicker.js +22 -0
- package/lib/components/DatePicker/renderDatePicker.js.map +1 -0
- package/lib/components/DatePicker/useDatePicker.js +451 -0
- package/lib/components/DatePicker/useDatePicker.js.map +1 -0
- package/lib/components/DatePicker/useDatePickerStyles.styles.js +43 -0
- package/lib/components/DatePicker/useDatePickerStyles.styles.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/usePopupPositioning.js +21 -0
- package/lib/utils/usePopupPositioning.js.map +1 -0
- package/lib-commonjs/DatePicker.js +34 -0
- package/lib-commonjs/DatePicker.js.map +1 -0
- package/lib-commonjs/components/DatePicker/DatePicker.js +21 -0
- package/lib-commonjs/components/DatePicker/DatePicker.js.map +1 -0
- package/lib-commonjs/components/DatePicker/DatePicker.types.js +6 -0
- package/lib-commonjs/components/DatePicker/DatePicker.types.js.map +1 -0
- package/lib-commonjs/components/DatePicker/defaults.js +32 -0
- package/lib-commonjs/components/DatePicker/defaults.js.map +1 -0
- package/lib-commonjs/components/DatePicker/index.js +38 -0
- package/lib-commonjs/components/DatePicker/index.js.map +1 -0
- package/lib-commonjs/components/DatePicker/renderDatePicker.js +30 -0
- package/lib-commonjs/components/DatePicker/renderDatePicker.js.map +1 -0
- package/lib-commonjs/components/DatePicker/useDatePicker.js +451 -0
- package/lib-commonjs/components/DatePicker/useDatePicker.js.map +1 -0
- package/lib-commonjs/components/DatePicker/useDatePickerStyles.styles.js +62 -0
- package/lib-commonjs/components/DatePicker/useDatePickerStyles.styles.js.map +1 -0
- package/lib-commonjs/index.js +34 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/utils/usePopupPositioning.js +26 -0
- package/lib-commonjs/utils/usePopupPositioning.js.map +1 -0
- package/package.json +16 -16
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ArrowDown, Enter, Escape } from '@fluentui/keyboard-keys';
|
|
3
|
+
import { Calendar, compareDatePart, DayOfWeek, FirstWeekOfYear } from '@fluentui/react-calendar-compat';
|
|
4
|
+
import { CalendarMonthRegular } from '@fluentui/react-icons';
|
|
5
|
+
import { defaultDatePickerStrings } from './defaults';
|
|
6
|
+
import { Input } from '@fluentui/react-input';
|
|
7
|
+
import { mergeCallbacks, useControllableState, useEventCallback, useId, useMergedRefs, useOnClickOutside, useOnScrollOutside, slot } from '@fluentui/react-utilities';
|
|
8
|
+
import { useFieldContext_unstable as useFieldContext } from '@fluentui/react-field';
|
|
9
|
+
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
10
|
+
import { useModalAttributes } from '@fluentui/react-tabster';
|
|
11
|
+
import { usePopupPositioning } from '../../utils/usePopupPositioning';
|
|
12
|
+
function isDateOutOfBounds(date, minDate, maxDate) {
|
|
13
|
+
return !!minDate && compareDatePart(minDate, date) > 0 || !!maxDate && compareDatePart(maxDate, date) < 0;
|
|
14
|
+
}
|
|
15
|
+
function useFocusLogic() {
|
|
16
|
+
const inputRef = React.useRef(null);
|
|
17
|
+
const preventFocusOpeningPicker = React.useRef(false);
|
|
18
|
+
const focus = React.useCallback(()=>{
|
|
19
|
+
var _inputRef_current_focus, _inputRef_current;
|
|
20
|
+
(_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : (_inputRef_current_focus = _inputRef_current.focus) === null || _inputRef_current_focus === void 0 ? void 0 : _inputRef_current_focus.call(_inputRef_current);
|
|
21
|
+
}, []);
|
|
22
|
+
const preventNextFocusOpeningPicker = React.useCallback(()=>{
|
|
23
|
+
preventFocusOpeningPicker.current = true;
|
|
24
|
+
}, []);
|
|
25
|
+
return [
|
|
26
|
+
focus,
|
|
27
|
+
inputRef,
|
|
28
|
+
preventFocusOpeningPicker,
|
|
29
|
+
preventNextFocusOpeningPicker
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
function usePopupVisibility(props) {
|
|
33
|
+
'use no memo';
|
|
34
|
+
const [open, setOpen] = useControllableState({
|
|
35
|
+
initialState: false,
|
|
36
|
+
defaultState: props.defaultOpen,
|
|
37
|
+
state: props.open
|
|
38
|
+
});
|
|
39
|
+
const isMounted = React.useRef(false);
|
|
40
|
+
React.useEffect(()=>{
|
|
41
|
+
if (isMounted.current && !open) {
|
|
42
|
+
var // If DatePicker's menu (Calendar) is closed, run onAfterMenuDismiss
|
|
43
|
+
_props_onOpenChange;
|
|
44
|
+
(_props_onOpenChange = props.onOpenChange) === null || _props_onOpenChange === void 0 ? void 0 : _props_onOpenChange.call(props, false);
|
|
45
|
+
}
|
|
46
|
+
isMounted.current = true;
|
|
47
|
+
}, // Should only run on allowTextInput or open change
|
|
48
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
+
[
|
|
50
|
+
props.allowTextInput,
|
|
51
|
+
open
|
|
52
|
+
]);
|
|
53
|
+
return [
|
|
54
|
+
open,
|
|
55
|
+
setOpen
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
function useSelectedDate({ formatDate, onSelectDate, value }) {
|
|
59
|
+
const [selectedDate, setSelectedDateState] = useControllableState({
|
|
60
|
+
initialState: null,
|
|
61
|
+
state: value
|
|
62
|
+
});
|
|
63
|
+
const [formattedDate, setFormattedDate] = React.useState(()=>value && formatDate ? formatDate(value) : '');
|
|
64
|
+
const setSelectedDate = (newDate)=>{
|
|
65
|
+
onSelectDate === null || onSelectDate === void 0 ? void 0 : onSelectDate(newDate);
|
|
66
|
+
setSelectedDateState(newDate);
|
|
67
|
+
setFormattedDate(newDate && formatDate ? formatDate(newDate) : '');
|
|
68
|
+
};
|
|
69
|
+
React.useEffect(()=>{
|
|
70
|
+
setFormattedDate(value && formatDate ? formatDate(value) : '');
|
|
71
|
+
}, [
|
|
72
|
+
formatDate,
|
|
73
|
+
value
|
|
74
|
+
]);
|
|
75
|
+
return [
|
|
76
|
+
selectedDate,
|
|
77
|
+
formattedDate,
|
|
78
|
+
setSelectedDate,
|
|
79
|
+
setFormattedDate
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
const defaultFormatDate = (date)=>date ? date.toDateString() : '';
|
|
83
|
+
const defaultParseDateFromString = (dateStr)=>{
|
|
84
|
+
const date = Date.parse(dateStr);
|
|
85
|
+
return date ? new Date(date) : null;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Create the state required to render DatePicker.
|
|
89
|
+
*
|
|
90
|
+
* The returned state can be modified with hooks such as useDatePickerStyles_unstable,
|
|
91
|
+
* before being passed to renderDatePicker_unstable.
|
|
92
|
+
*
|
|
93
|
+
* @param props - props from this instance of DatePicker
|
|
94
|
+
* @param ref - reference to root Input slot
|
|
95
|
+
*/ export const useDatePicker_unstable = (props, ref)=>{
|
|
96
|
+
'use no memo';
|
|
97
|
+
const { allowTextInput = false, allFocusable = false, borderless = false, dateTimeFormatter, defaultOpen = false, disableAutoFocus = true, firstDayOfWeek = DayOfWeek.Sunday, firstWeekOfYear = FirstWeekOfYear.FirstDay, formatDate = defaultFormatDate, highlightCurrentMonth = false, highlightSelectedMonth = false, initialPickerDate: initialPickerDateProp, inlinePopup = false, isMonthPickerVisible = true, maxDate, minDate, mountNode, onOpenChange, onSelectDate: onUserSelectDate, openOnClick = true, onValidationResult, parseDateFromString = defaultParseDateFromString, showCloseButton = false, showGoToToday = true, showMonthPickerAsOverlay = false, showWeekNumbers = false, strings = defaultDatePickerStrings, today, underlined = false, value, ...restOfProps } = props;
|
|
98
|
+
const initialPickerDate = React.useMemo(()=>initialPickerDateProp !== null && initialPickerDateProp !== void 0 ? initialPickerDateProp : new Date(), [
|
|
99
|
+
initialPickerDateProp
|
|
100
|
+
]);
|
|
101
|
+
const calendar = React.useRef(null);
|
|
102
|
+
const [focus, rootRef, preventFocusOpeningPicker, preventNextFocusOpeningPicker] = useFocusLogic();
|
|
103
|
+
const [selectedDate, formattedDate, setSelectedDate, setFormattedDate] = useSelectedDate({
|
|
104
|
+
formatDate,
|
|
105
|
+
onSelectDate: onUserSelectDate,
|
|
106
|
+
value
|
|
107
|
+
});
|
|
108
|
+
const [open, setOpenState] = usePopupVisibility(props);
|
|
109
|
+
const fieldContext = useFieldContext();
|
|
110
|
+
var _fieldContext_required;
|
|
111
|
+
const required = (_fieldContext_required = fieldContext === null || fieldContext === void 0 ? void 0 : fieldContext.required) !== null && _fieldContext_required !== void 0 ? _fieldContext_required : props.required;
|
|
112
|
+
const defaultId = useId('datePicker-input');
|
|
113
|
+
const popupSurfaceId = useId('datePicker-popupSurface');
|
|
114
|
+
const validateTextInput = React.useCallback((date = null)=>{
|
|
115
|
+
let error;
|
|
116
|
+
if (allowTextInput) {
|
|
117
|
+
if (formattedDate || date) {
|
|
118
|
+
// Don't parse if the selected date has the same formatted string as what we're about to parse.
|
|
119
|
+
// The formatted string might be ambiguous (ex: "1/2/3" or "New Year Eve") and the parser might
|
|
120
|
+
// not be able to come up with the exact same date.
|
|
121
|
+
if (selectedDate && formatDate && formatDate(date !== null && date !== void 0 ? date : selectedDate) === formattedDate) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
date = date || parseDateFromString(formattedDate);
|
|
125
|
+
// Check if date is null or date is an invalid date
|
|
126
|
+
if (!date || isNaN(date.getTime())) {
|
|
127
|
+
// Reset input if formatting is available
|
|
128
|
+
setSelectedDate(selectedDate);
|
|
129
|
+
error = 'invalid-input';
|
|
130
|
+
} else {
|
|
131
|
+
if (isDateOutOfBounds(date, minDate, maxDate)) {
|
|
132
|
+
error = 'out-of-bounds';
|
|
133
|
+
} else {
|
|
134
|
+
setSelectedDate(date);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
if (required) {
|
|
139
|
+
error = 'required-input';
|
|
140
|
+
}
|
|
141
|
+
onUserSelectDate === null || onUserSelectDate === void 0 ? void 0 : onUserSelectDate(date);
|
|
142
|
+
}
|
|
143
|
+
} else if (required && !formattedDate) {
|
|
144
|
+
error = 'required-input';
|
|
145
|
+
}
|
|
146
|
+
onValidationResult === null || onValidationResult === void 0 ? void 0 : onValidationResult({
|
|
147
|
+
error
|
|
148
|
+
});
|
|
149
|
+
}, [
|
|
150
|
+
allowTextInput,
|
|
151
|
+
formatDate,
|
|
152
|
+
formattedDate,
|
|
153
|
+
maxDate,
|
|
154
|
+
minDate,
|
|
155
|
+
onUserSelectDate,
|
|
156
|
+
onValidationResult,
|
|
157
|
+
parseDateFromString,
|
|
158
|
+
required,
|
|
159
|
+
selectedDate,
|
|
160
|
+
setSelectedDate
|
|
161
|
+
]);
|
|
162
|
+
const setOpen = React.useCallback((newState)=>{
|
|
163
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(newState);
|
|
164
|
+
setOpenState(newState);
|
|
165
|
+
if (!open && !props.disabled) {
|
|
166
|
+
focus();
|
|
167
|
+
}
|
|
168
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
169
|
+
[
|
|
170
|
+
focus,
|
|
171
|
+
onOpenChange,
|
|
172
|
+
props.disabled,
|
|
173
|
+
setOpenState
|
|
174
|
+
]);
|
|
175
|
+
const dismissDatePickerPopup = React.useCallback((newlySelectedDate)=>{
|
|
176
|
+
if (open) {
|
|
177
|
+
setOpen(false);
|
|
178
|
+
validateTextInput(newlySelectedDate);
|
|
179
|
+
if (!allowTextInput && newlySelectedDate) {
|
|
180
|
+
setSelectedDate(newlySelectedDate);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}, [
|
|
184
|
+
allowTextInput,
|
|
185
|
+
open,
|
|
186
|
+
setOpen,
|
|
187
|
+
setSelectedDate,
|
|
188
|
+
validateTextInput
|
|
189
|
+
]);
|
|
190
|
+
const showDatePickerPopup = React.useCallback(()=>{
|
|
191
|
+
if (!open) {
|
|
192
|
+
preventNextFocusOpeningPicker();
|
|
193
|
+
setOpen(true);
|
|
194
|
+
}
|
|
195
|
+
}, [
|
|
196
|
+
open,
|
|
197
|
+
preventNextFocusOpeningPicker,
|
|
198
|
+
setOpen
|
|
199
|
+
]);
|
|
200
|
+
/**
|
|
201
|
+
* Callback for closing the calendar callout
|
|
202
|
+
*/ const calendarDismissed = React.useCallback((newlySelectedDate)=>{
|
|
203
|
+
preventNextFocusOpeningPicker();
|
|
204
|
+
dismissDatePickerPopup(newlySelectedDate);
|
|
205
|
+
}, [
|
|
206
|
+
dismissDatePickerPopup,
|
|
207
|
+
preventNextFocusOpeningPicker
|
|
208
|
+
]);
|
|
209
|
+
const onInputChange = React.useCallback((_, data)=>{
|
|
210
|
+
const { value: newValue } = data;
|
|
211
|
+
if (allowTextInput) {
|
|
212
|
+
if (open) {
|
|
213
|
+
dismissDatePickerPopup();
|
|
214
|
+
}
|
|
215
|
+
setFormattedDate(newValue);
|
|
216
|
+
}
|
|
217
|
+
}, [
|
|
218
|
+
allowTextInput,
|
|
219
|
+
dismissDatePickerPopup,
|
|
220
|
+
open,
|
|
221
|
+
setFormattedDate
|
|
222
|
+
]);
|
|
223
|
+
const onInputBlur = React.useCallback(()=>{
|
|
224
|
+
validateTextInput();
|
|
225
|
+
}, [
|
|
226
|
+
validateTextInput
|
|
227
|
+
]);
|
|
228
|
+
const onInputKeyDown = React.useCallback((ev)=>{
|
|
229
|
+
switch(ev.key){
|
|
230
|
+
case Enter:
|
|
231
|
+
ev.preventDefault();
|
|
232
|
+
ev.stopPropagation();
|
|
233
|
+
if (!open) {
|
|
234
|
+
validateTextInput();
|
|
235
|
+
showDatePickerPopup();
|
|
236
|
+
} else {
|
|
237
|
+
// When DatePicker allows input date string directly,
|
|
238
|
+
// it is expected to hit another enter to close the popup
|
|
239
|
+
if (props.allowTextInput) {
|
|
240
|
+
dismissDatePickerPopup();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
case Escape:
|
|
245
|
+
ev.stopPropagation();
|
|
246
|
+
ev.preventDefault();
|
|
247
|
+
if (open) {
|
|
248
|
+
calendarDismissed();
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
case ArrowDown:
|
|
252
|
+
ev.preventDefault();
|
|
253
|
+
if (!open) {
|
|
254
|
+
showDatePickerPopup();
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
default:
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}, [
|
|
261
|
+
calendarDismissed,
|
|
262
|
+
dismissDatePickerPopup,
|
|
263
|
+
open,
|
|
264
|
+
props.allowTextInput,
|
|
265
|
+
showDatePickerPopup,
|
|
266
|
+
validateTextInput
|
|
267
|
+
]);
|
|
268
|
+
const onInputFocus = React.useCallback(()=>{
|
|
269
|
+
if (disableAutoFocus) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (!allowTextInput) {
|
|
273
|
+
if (!preventFocusOpeningPicker.current) {
|
|
274
|
+
showDatePickerPopup();
|
|
275
|
+
}
|
|
276
|
+
preventFocusOpeningPicker.current = false;
|
|
277
|
+
}
|
|
278
|
+
}, [
|
|
279
|
+
allowTextInput,
|
|
280
|
+
disableAutoFocus,
|
|
281
|
+
preventFocusOpeningPicker,
|
|
282
|
+
showDatePickerPopup
|
|
283
|
+
]);
|
|
284
|
+
const onInputClick = React.useCallback(()=>{
|
|
285
|
+
// default openOnClick to !props.disableAutoFocus for legacy support of disableAutoFocus behavior
|
|
286
|
+
if ((props.openOnClick || !props.disableAutoFocus) && !open && !props.disabled) {
|
|
287
|
+
showDatePickerPopup();
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (allowTextInput) {
|
|
291
|
+
dismissDatePickerPopup();
|
|
292
|
+
}
|
|
293
|
+
}, [
|
|
294
|
+
allowTextInput,
|
|
295
|
+
dismissDatePickerPopup,
|
|
296
|
+
open,
|
|
297
|
+
props.disabled,
|
|
298
|
+
props.disableAutoFocus,
|
|
299
|
+
props.openOnClick,
|
|
300
|
+
showDatePickerPopup
|
|
301
|
+
]);
|
|
302
|
+
const onIconClick = (ev)=>{
|
|
303
|
+
ev.stopPropagation();
|
|
304
|
+
if (!open && !props.disabled) {
|
|
305
|
+
showDatePickerPopup();
|
|
306
|
+
} else if (props.allowTextInput) {
|
|
307
|
+
dismissDatePickerPopup();
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
const inputAppearance = underlined ? 'underline' : borderless ? 'filled-lighter' : 'outline';
|
|
311
|
+
const [triggerWrapperRef, popupRef] = usePopupPositioning(props);
|
|
312
|
+
const inputRoot = slot.always(props.root, {
|
|
313
|
+
defaultProps: {
|
|
314
|
+
ref: triggerWrapperRef
|
|
315
|
+
},
|
|
316
|
+
elementType: 'span'
|
|
317
|
+
});
|
|
318
|
+
inputRoot.ref = useMergedRefs(inputRoot.ref, triggerWrapperRef);
|
|
319
|
+
const input = slot.always(props.input, {
|
|
320
|
+
elementType: 'input'
|
|
321
|
+
});
|
|
322
|
+
input.ref = useMergedRefs(input.ref, ref, rootRef);
|
|
323
|
+
// Props to create a semantic but non-focusable button on the element with the click-to-open handler
|
|
324
|
+
// Used for voice control and touch screen reader accessibility
|
|
325
|
+
const inputLabelledBy = props['aria-labelledby'];
|
|
326
|
+
var _props_id;
|
|
327
|
+
const inputId = (_props_id = props.id) !== null && _props_id !== void 0 ? _props_id : defaultId;
|
|
328
|
+
const iconA11yProps = React.useMemo(()=>({
|
|
329
|
+
role: 'button',
|
|
330
|
+
'aria-expanded': open,
|
|
331
|
+
'aria-labelledby': inputLabelledBy !== null && inputLabelledBy !== void 0 ? inputLabelledBy : inputId
|
|
332
|
+
}), [
|
|
333
|
+
open,
|
|
334
|
+
inputLabelledBy,
|
|
335
|
+
inputId
|
|
336
|
+
]);
|
|
337
|
+
const contentAfter = slot.always(props.contentAfter || {}, {
|
|
338
|
+
defaultProps: {
|
|
339
|
+
children: /*#__PURE__*/ React.createElement(CalendarMonthRegular, null),
|
|
340
|
+
...iconA11yProps
|
|
341
|
+
},
|
|
342
|
+
elementType: 'span'
|
|
343
|
+
});
|
|
344
|
+
contentAfter.onClick = useEventCallback(mergeCallbacks(contentAfter.onClick, onIconClick));
|
|
345
|
+
const root = slot.always(restOfProps, {
|
|
346
|
+
defaultProps: {
|
|
347
|
+
appearance: inputAppearance,
|
|
348
|
+
'aria-controls': open ? popupSurfaceId : undefined,
|
|
349
|
+
'aria-expanded': open,
|
|
350
|
+
'aria-haspopup': 'dialog',
|
|
351
|
+
readOnly: !allowTextInput,
|
|
352
|
+
role: 'combobox',
|
|
353
|
+
id: inputId
|
|
354
|
+
},
|
|
355
|
+
elementType: Input
|
|
356
|
+
});
|
|
357
|
+
root.root = inputRoot;
|
|
358
|
+
root.input = input;
|
|
359
|
+
root.contentAfter = contentAfter;
|
|
360
|
+
root.onChange = useEventCallback(mergeCallbacks(root.onChange, onInputChange));
|
|
361
|
+
root.onBlur = useEventCallback(mergeCallbacks(root.onBlur, onInputBlur));
|
|
362
|
+
root.onKeyDown = useEventCallback(mergeCallbacks(root.onKeyDown, onInputKeyDown));
|
|
363
|
+
root.onFocus = useEventCallback(mergeCallbacks(root.onFocus, onInputFocus));
|
|
364
|
+
root.onClick = useEventCallback(mergeCallbacks(root.onClick, onInputClick));
|
|
365
|
+
const { modalAttributes } = useModalAttributes({
|
|
366
|
+
trapFocus: true,
|
|
367
|
+
alwaysFocusable: true,
|
|
368
|
+
legacyTrapFocus: true
|
|
369
|
+
});
|
|
370
|
+
const popupSurface = open ? slot.optional(props.popupSurface, {
|
|
371
|
+
renderByDefault: true,
|
|
372
|
+
defaultProps: {
|
|
373
|
+
'aria-label': 'Calendar',
|
|
374
|
+
'aria-modal': true,
|
|
375
|
+
id: popupSurfaceId,
|
|
376
|
+
role: 'dialog',
|
|
377
|
+
ref: popupRef,
|
|
378
|
+
...modalAttributes
|
|
379
|
+
},
|
|
380
|
+
elementType: 'div'
|
|
381
|
+
}) : undefined;
|
|
382
|
+
const { targetDocument } = useFluent();
|
|
383
|
+
useOnClickOutside({
|
|
384
|
+
element: targetDocument,
|
|
385
|
+
callback: (ev)=>dismissDatePickerPopup(),
|
|
386
|
+
refs: [
|
|
387
|
+
triggerWrapperRef,
|
|
388
|
+
popupRef
|
|
389
|
+
],
|
|
390
|
+
disabled: !open
|
|
391
|
+
});
|
|
392
|
+
useOnScrollOutside({
|
|
393
|
+
element: targetDocument,
|
|
394
|
+
callback: (ev)=>dismissDatePickerPopup(),
|
|
395
|
+
refs: [
|
|
396
|
+
triggerWrapperRef,
|
|
397
|
+
popupRef
|
|
398
|
+
],
|
|
399
|
+
disabled: !open
|
|
400
|
+
}); // When the popup is opened, focus should go to the calendar.
|
|
401
|
+
// In v8 this was done by focusing after the callout was positioned, but in v9 this can be simulated by using a
|
|
402
|
+
// useEffect hook.
|
|
403
|
+
React.useEffect(()=>{
|
|
404
|
+
if (open && !props.disabled && calendar.current) {
|
|
405
|
+
calendar.current.focus();
|
|
406
|
+
}
|
|
407
|
+
}, [
|
|
408
|
+
disableAutoFocus,
|
|
409
|
+
open,
|
|
410
|
+
props.disabled
|
|
411
|
+
]);
|
|
412
|
+
const calendarShorthand = slot.always(props.calendar, {
|
|
413
|
+
defaultProps: {
|
|
414
|
+
allFocusable,
|
|
415
|
+
componentRef: calendar,
|
|
416
|
+
dateTimeFormatter,
|
|
417
|
+
firstDayOfWeek,
|
|
418
|
+
firstWeekOfYear,
|
|
419
|
+
highlightCurrentMonth,
|
|
420
|
+
highlightSelectedMonth,
|
|
421
|
+
isMonthPickerVisible,
|
|
422
|
+
maxDate,
|
|
423
|
+
minDate,
|
|
424
|
+
showCloseButton,
|
|
425
|
+
showGoToToday,
|
|
426
|
+
showMonthPickerAsOverlay,
|
|
427
|
+
showWeekNumbers,
|
|
428
|
+
strings,
|
|
429
|
+
today,
|
|
430
|
+
value: selectedDate || initialPickerDate
|
|
431
|
+
},
|
|
432
|
+
elementType: Calendar
|
|
433
|
+
});
|
|
434
|
+
calendarShorthand.onDismiss = useEventCallback(mergeCallbacks(calendarShorthand.onDismiss, calendarDismissed));
|
|
435
|
+
calendarShorthand.onSelectDate = useEventCallback(mergeCallbacks(calendarShorthand.onSelectDate, calendarDismissed));
|
|
436
|
+
const state = {
|
|
437
|
+
disabled: !!props.disabled,
|
|
438
|
+
inlinePopup,
|
|
439
|
+
components: {
|
|
440
|
+
root: Input,
|
|
441
|
+
calendar: Calendar,
|
|
442
|
+
popupSurface: 'div'
|
|
443
|
+
},
|
|
444
|
+
calendar: calendarShorthand,
|
|
445
|
+
mountNode,
|
|
446
|
+
root,
|
|
447
|
+
popupSurface
|
|
448
|
+
};
|
|
449
|
+
state.root.value = formattedDate;
|
|
450
|
+
return state;
|
|
451
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/DatePicker/useDatePicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ArrowDown, Enter, Escape } from '@fluentui/keyboard-keys';\nimport { Calendar, compareDatePart, DayOfWeek, FirstWeekOfYear } from '@fluentui/react-calendar-compat';\nimport { CalendarMonthRegular } from '@fluentui/react-icons';\nimport { defaultDatePickerStrings } from './defaults';\nimport { Input } from '@fluentui/react-input';\nimport {\n mergeCallbacks,\n useControllableState,\n useEventCallback,\n useId,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n slot,\n} from '@fluentui/react-utilities';\nimport { useFieldContext_unstable as useFieldContext } from '@fluentui/react-field';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopupPositioning } from '../../utils/usePopupPositioning';\nimport type { CalendarProps, ICalendar } from '@fluentui/react-calendar-compat';\nimport type { DatePickerProps, DatePickerState, DatePickerValidationResultData } from './DatePicker.types';\nimport type { InputProps, InputOnChangeData } from '@fluentui/react-input';\n\nfunction isDateOutOfBounds(date: Date, minDate?: Date, maxDate?: Date): boolean {\n return (!!minDate && compareDatePart(minDate!, date) > 0) || (!!maxDate && compareDatePart(maxDate!, date) < 0);\n}\n\nfunction useFocusLogic() {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const preventFocusOpeningPicker = React.useRef(false);\n\n const focus = React.useCallback(() => {\n inputRef.current?.focus?.();\n }, []);\n\n const preventNextFocusOpeningPicker = React.useCallback(() => {\n preventFocusOpeningPicker.current = true;\n }, []);\n\n return [focus, inputRef, preventFocusOpeningPicker, preventNextFocusOpeningPicker] as const;\n}\n\nfunction usePopupVisibility(props: DatePickerProps) {\n 'use no memo';\n\n const [open, setOpen] = useControllableState({\n initialState: false,\n defaultState: props.defaultOpen,\n state: props.open,\n });\n const isMounted = React.useRef(false);\n\n React.useEffect(\n () => {\n if (isMounted.current && !open) {\n // If DatePicker's menu (Calendar) is closed, run onAfterMenuDismiss\n props.onOpenChange?.(false);\n }\n isMounted.current = true;\n },\n // Should only run on allowTextInput or open change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [props.allowTextInput, open],\n );\n\n return [open, setOpen] as const;\n}\n\nfunction useSelectedDate({ formatDate, onSelectDate, value }: DatePickerProps) {\n const [selectedDate, setSelectedDateState] = useControllableState<Date | null | undefined>({\n initialState: null,\n state: value,\n });\n const [formattedDate, setFormattedDate] = React.useState(() => (value && formatDate ? formatDate(value) : ''));\n\n const setSelectedDate = (newDate: Date | null | undefined) => {\n onSelectDate?.(newDate);\n setSelectedDateState(newDate);\n setFormattedDate(newDate && formatDate ? formatDate(newDate) : '');\n };\n\n React.useEffect(() => {\n setFormattedDate(value && formatDate ? formatDate(value) : '');\n }, [formatDate, value]);\n\n return [selectedDate, formattedDate, setSelectedDate, setFormattedDate] as const;\n}\n\nconst defaultFormatDate = (date?: Date) => (date ? date.toDateString() : '');\nconst defaultParseDateFromString = (dateStr: string) => {\n const date = Date.parse(dateStr);\n return date ? new Date(date) : null;\n};\n\n/**\n * Create the state required to render DatePicker.\n *\n * The returned state can be modified with hooks such as useDatePickerStyles_unstable,\n * before being passed to renderDatePicker_unstable.\n *\n * @param props - props from this instance of DatePicker\n * @param ref - reference to root Input slot\n */\nexport const useDatePicker_unstable = (props: DatePickerProps, ref: React.Ref<HTMLInputElement>): DatePickerState => {\n 'use no memo';\n\n const {\n allowTextInput = false,\n allFocusable = false,\n borderless = false,\n dateTimeFormatter,\n defaultOpen = false,\n disableAutoFocus = true,\n firstDayOfWeek = DayOfWeek.Sunday,\n firstWeekOfYear = FirstWeekOfYear.FirstDay,\n formatDate = defaultFormatDate,\n highlightCurrentMonth = false,\n highlightSelectedMonth = false,\n initialPickerDate: initialPickerDateProp,\n inlinePopup = false,\n isMonthPickerVisible = true,\n maxDate,\n minDate,\n mountNode,\n onOpenChange,\n onSelectDate: onUserSelectDate,\n openOnClick = true,\n onValidationResult,\n parseDateFromString = defaultParseDateFromString,\n showCloseButton = false,\n showGoToToday = true,\n showMonthPickerAsOverlay = false,\n showWeekNumbers = false,\n strings = defaultDatePickerStrings,\n today,\n underlined = false,\n value,\n ...restOfProps\n } = props;\n\n const initialPickerDate = React.useMemo(() => initialPickerDateProp ?? new Date(), [initialPickerDateProp]);\n\n const calendar = React.useRef<ICalendar>(null);\n const [focus, rootRef, preventFocusOpeningPicker, preventNextFocusOpeningPicker] = useFocusLogic();\n const [selectedDate, formattedDate, setSelectedDate, setFormattedDate] = useSelectedDate({\n formatDate,\n onSelectDate: onUserSelectDate,\n value,\n });\n const [open, setOpenState] = usePopupVisibility(props);\n const fieldContext = useFieldContext();\n const required = fieldContext?.required ?? props.required;\n const defaultId = useId('datePicker-input');\n const popupSurfaceId = useId('datePicker-popupSurface');\n\n const validateTextInput = React.useCallback(\n (date: Date | null = null): void => {\n let error: DatePickerValidationResultData['error'];\n\n if (allowTextInput) {\n if (formattedDate || date) {\n // Don't parse if the selected date has the same formatted string as what we're about to parse.\n // The formatted string might be ambiguous (ex: \"1/2/3\" or \"New Year Eve\") and the parser might\n // not be able to come up with the exact same date.\n if (selectedDate && formatDate && formatDate(date ?? selectedDate) === formattedDate) {\n return;\n }\n date = date || parseDateFromString!(formattedDate);\n\n // Check if date is null or date is an invalid date\n if (!date || isNaN(date.getTime())) {\n // Reset input if formatting is available\n setSelectedDate(selectedDate);\n error = 'invalid-input';\n } else {\n if (isDateOutOfBounds(date, minDate, maxDate)) {\n error = 'out-of-bounds';\n } else {\n setSelectedDate(date);\n }\n }\n } else {\n if (required) {\n error = 'required-input';\n }\n\n onUserSelectDate?.(date);\n }\n } else if (required && !formattedDate) {\n error = 'required-input';\n }\n\n onValidationResult?.({ error });\n },\n [\n allowTextInput,\n formatDate,\n formattedDate,\n maxDate,\n minDate,\n onUserSelectDate,\n onValidationResult,\n parseDateFromString,\n required,\n selectedDate,\n setSelectedDate,\n ],\n );\n\n const setOpen = React.useCallback(\n (newState: boolean) => {\n onOpenChange?.(newState);\n setOpenState(newState);\n\n if (!open && !props.disabled) {\n focus();\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [focus, onOpenChange, props.disabled, setOpenState],\n );\n\n const dismissDatePickerPopup = React.useCallback(\n (newlySelectedDate?: Date | null): void => {\n if (open) {\n setOpen(false);\n\n validateTextInput(newlySelectedDate);\n if (!allowTextInput && newlySelectedDate) {\n setSelectedDate(newlySelectedDate);\n }\n }\n },\n [allowTextInput, open, setOpen, setSelectedDate, validateTextInput],\n );\n\n const showDatePickerPopup = React.useCallback((): void => {\n if (!open) {\n preventNextFocusOpeningPicker();\n setOpen(true);\n }\n }, [open, preventNextFocusOpeningPicker, setOpen]);\n\n /**\n * Callback for closing the calendar callout\n */\n const calendarDismissed = React.useCallback(\n (newlySelectedDate?: Date): void => {\n preventNextFocusOpeningPicker();\n dismissDatePickerPopup(newlySelectedDate);\n },\n [dismissDatePickerPopup, preventNextFocusOpeningPicker],\n );\n\n const onInputChange = React.useCallback(\n (_: React.ChangeEvent<HTMLInputElement>, data: InputOnChangeData) => {\n const { value: newValue } = data;\n\n if (allowTextInput) {\n if (open) {\n dismissDatePickerPopup();\n }\n\n setFormattedDate(newValue);\n }\n },\n [allowTextInput, dismissDatePickerPopup, open, setFormattedDate],\n );\n\n const onInputBlur: React.FocusEventHandler<HTMLInputElement> = React.useCallback((): void => {\n validateTextInput();\n }, [validateTextInput]);\n\n const onInputKeyDown = React.useCallback(\n (ev: React.KeyboardEvent<HTMLElement>): void => {\n switch (ev.key) {\n case Enter:\n ev.preventDefault();\n ev.stopPropagation();\n if (!open) {\n validateTextInput();\n showDatePickerPopup();\n } else {\n // When DatePicker allows input date string directly,\n // it is expected to hit another enter to close the popup\n if (props.allowTextInput) {\n dismissDatePickerPopup();\n }\n }\n break;\n\n case Escape:\n ev.stopPropagation();\n ev.preventDefault();\n if (open) {\n calendarDismissed();\n }\n break;\n\n case ArrowDown:\n ev.preventDefault();\n if (!open) {\n showDatePickerPopup();\n }\n break;\n\n default:\n break;\n }\n },\n [calendarDismissed, dismissDatePickerPopup, open, props.allowTextInput, showDatePickerPopup, validateTextInput],\n );\n\n const onInputFocus: React.FocusEventHandler<HTMLInputElement> = React.useCallback((): void => {\n if (disableAutoFocus) {\n return;\n }\n\n if (!allowTextInput) {\n if (!preventFocusOpeningPicker.current) {\n showDatePickerPopup();\n }\n preventFocusOpeningPicker.current = false;\n }\n }, [allowTextInput, disableAutoFocus, preventFocusOpeningPicker, showDatePickerPopup]);\n\n const onInputClick: React.MouseEventHandler<HTMLInputElement> = React.useCallback((): void => {\n // default openOnClick to !props.disableAutoFocus for legacy support of disableAutoFocus behavior\n if ((props.openOnClick || !props.disableAutoFocus) && !open && !props.disabled) {\n showDatePickerPopup();\n return;\n }\n\n if (allowTextInput) {\n dismissDatePickerPopup();\n }\n }, [\n allowTextInput,\n dismissDatePickerPopup,\n open,\n props.disabled,\n props.disableAutoFocus,\n props.openOnClick,\n showDatePickerPopup,\n ]);\n\n const onIconClick = (ev: React.MouseEvent<HTMLElement>): void => {\n ev.stopPropagation();\n if (!open && !props.disabled) {\n showDatePickerPopup();\n } else if (props.allowTextInput) {\n dismissDatePickerPopup();\n }\n };\n\n const inputAppearance: InputProps['appearance'] = underlined\n ? 'underline'\n : borderless\n ? 'filled-lighter'\n : 'outline';\n\n const [triggerWrapperRef, popupRef] = usePopupPositioning(props);\n\n const inputRoot = slot.always(props.root, {\n defaultProps: {\n ref: triggerWrapperRef,\n },\n elementType: 'span',\n });\n inputRoot.ref = useMergedRefs(inputRoot.ref, triggerWrapperRef);\n\n const input = slot.always(props.input, {\n elementType: 'input',\n });\n input.ref = useMergedRefs(input.ref, ref, rootRef);\n\n // Props to create a semantic but non-focusable button on the element with the click-to-open handler\n // Used for voice control and touch screen reader accessibility\n const inputLabelledBy = props['aria-labelledby'];\n const inputId = props.id ?? defaultId;\n const iconA11yProps = React.useMemo(\n () => ({\n role: 'button',\n 'aria-expanded': open,\n 'aria-labelledby': inputLabelledBy ?? inputId,\n }),\n [open, inputLabelledBy, inputId],\n );\n\n const contentAfter = slot.always(props.contentAfter || {}, {\n defaultProps: {\n children: <CalendarMonthRegular />,\n ...iconA11yProps,\n },\n elementType: 'span',\n });\n contentAfter.onClick = useEventCallback(mergeCallbacks(contentAfter.onClick, onIconClick));\n\n const root = slot.always(restOfProps, {\n defaultProps: {\n appearance: inputAppearance,\n 'aria-controls': open ? popupSurfaceId : undefined,\n 'aria-expanded': open,\n 'aria-haspopup': 'dialog',\n readOnly: !allowTextInput,\n role: 'combobox',\n id: inputId,\n },\n elementType: Input,\n });\n root.root = inputRoot;\n root.input = input;\n root.contentAfter = contentAfter;\n root.onChange = useEventCallback(mergeCallbacks(root.onChange, onInputChange));\n root.onBlur = useEventCallback(mergeCallbacks(root.onBlur, onInputBlur));\n root.onKeyDown = useEventCallback(mergeCallbacks(root.onKeyDown, onInputKeyDown));\n root.onFocus = useEventCallback(mergeCallbacks(root.onFocus, onInputFocus));\n root.onClick = useEventCallback(mergeCallbacks(root.onClick, onInputClick));\n\n const { modalAttributes } = useModalAttributes({ trapFocus: true, alwaysFocusable: true, legacyTrapFocus: true });\n const popupSurface = open\n ? slot.optional(props.popupSurface, {\n renderByDefault: true,\n defaultProps: {\n 'aria-label': 'Calendar',\n 'aria-modal': true,\n id: popupSurfaceId,\n role: 'dialog',\n ref: popupRef,\n ...modalAttributes,\n },\n elementType: 'div',\n })\n : undefined;\n const { targetDocument } = useFluent();\n useOnClickOutside({\n element: targetDocument,\n callback: ev => dismissDatePickerPopup(),\n refs: [triggerWrapperRef, popupRef],\n disabled: !open,\n });\n useOnScrollOutside({\n element: targetDocument,\n callback: ev => dismissDatePickerPopup(),\n refs: [triggerWrapperRef, popupRef],\n disabled: !open,\n }); // When the popup is opened, focus should go to the calendar.\n // In v8 this was done by focusing after the callout was positioned, but in v9 this can be simulated by using a\n // useEffect hook.\n React.useEffect(() => {\n if (open && !props.disabled && calendar.current) {\n calendar.current.focus();\n }\n }, [disableAutoFocus, open, props.disabled]);\n const calendarShorthand = slot.always(props.calendar, {\n defaultProps: {\n allFocusable,\n componentRef: calendar,\n dateTimeFormatter,\n firstDayOfWeek,\n firstWeekOfYear,\n highlightCurrentMonth,\n highlightSelectedMonth,\n isMonthPickerVisible,\n maxDate,\n minDate,\n showCloseButton,\n showGoToToday,\n showMonthPickerAsOverlay,\n showWeekNumbers,\n strings,\n today,\n value: selectedDate || initialPickerDate,\n },\n elementType: Calendar,\n });\n calendarShorthand.onDismiss = useEventCallback(mergeCallbacks(calendarShorthand.onDismiss, calendarDismissed));\n calendarShorthand.onSelectDate = useEventCallback(mergeCallbacks(calendarShorthand.onSelectDate, calendarDismissed));\n const state: DatePickerState = {\n disabled: !!props.disabled,\n inlinePopup,\n components: { root: Input, calendar: Calendar as React.FC<Partial<CalendarProps>>, popupSurface: 'div' },\n calendar: calendarShorthand,\n mountNode,\n root,\n popupSurface,\n };\n\n state.root.value = formattedDate;\n\n return state;\n};\n"],"names":["React","ArrowDown","Enter","Escape","Calendar","compareDatePart","DayOfWeek","FirstWeekOfYear","CalendarMonthRegular","defaultDatePickerStrings","Input","mergeCallbacks","useControllableState","useEventCallback","useId","useMergedRefs","useOnClickOutside","useOnScrollOutside","slot","useFieldContext_unstable","useFieldContext","useFluent_unstable","useFluent","useModalAttributes","usePopupPositioning","isDateOutOfBounds","date","minDate","maxDate","useFocusLogic","inputRef","useRef","preventFocusOpeningPicker","focus","useCallback","current","preventNextFocusOpeningPicker","usePopupVisibility","props","open","setOpen","initialState","defaultState","defaultOpen","state","isMounted","useEffect","onOpenChange","allowTextInput","useSelectedDate","formatDate","onSelectDate","value","selectedDate","setSelectedDateState","formattedDate","setFormattedDate","useState","setSelectedDate","newDate","defaultFormatDate","toDateString","defaultParseDateFromString","dateStr","Date","parse","useDatePicker_unstable","ref","allFocusable","borderless","dateTimeFormatter","disableAutoFocus","firstDayOfWeek","Sunday","firstWeekOfYear","FirstDay","highlightCurrentMonth","highlightSelectedMonth","initialPickerDate","initialPickerDateProp","inlinePopup","isMonthPickerVisible","mountNode","onUserSelectDate","openOnClick","onValidationResult","parseDateFromString","showCloseButton","showGoToToday","showMonthPickerAsOverlay","showWeekNumbers","strings","today","underlined","restOfProps","useMemo","calendar","rootRef","setOpenState","fieldContext","required","defaultId","popupSurfaceId","validateTextInput","error","isNaN","getTime","newState","disabled","dismissDatePickerPopup","newlySelectedDate","showDatePickerPopup","calendarDismissed","onInputChange","_","data","newValue","onInputBlur","onInputKeyDown","ev","key","preventDefault","stopPropagation","onInputFocus","onInputClick","onIconClick","inputAppearance","triggerWrapperRef","popupRef","inputRoot","always","root","defaultProps","elementType","input","inputLabelledBy","inputId","id","iconA11yProps","role","contentAfter","children","onClick","appearance","undefined","readOnly","onChange","onBlur","onKeyDown","onFocus","modalAttributes","trapFocus","alwaysFocusable","legacyTrapFocus","popupSurface","optional","renderByDefault","targetDocument","element","callback","refs","calendarShorthand","componentRef","onDismiss","components"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,SAAS,EAAEC,KAAK,EAAEC,MAAM,QAAQ,0BAA0B;AACnE,SAASC,QAAQ,EAAEC,eAAe,EAAEC,SAAS,EAAEC,eAAe,QAAQ,kCAAkC;AACxG,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,wBAAwB,QAAQ,aAAa;AACtD,SAASC,KAAK,QAAQ,wBAAwB;AAC9C,SACEC,cAAc,EACdC,oBAAoB,EACpBC,gBAAgB,EAChBC,KAAK,EACLC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,IAAI,QACC,4BAA4B;AACnC,SAASC,4BAA4BC,eAAe,QAAQ,wBAAwB;AACpF,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,kBAA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YAAmBC;SAAS;QACnCpB,UAAU,CAACrE;IACb,IAAI,6DAA6D;IACjE,+GAA+G;IAC/G,kBAAkB;IAClBvC,MAAM8C,SAAS,CAAC;QACd,IAAIP,QAAQ,CAACD,MAAMsE,QAAQ,IAAIZ,SAAS7D,OAAO,EAAE;YAC/C6D,SAAS7D,OAAO,CAACF,KAAK;QACxB;IACF,GAAG;QAACsC;QAAkBhC;QAAMD,MAAMsE,QAAQ;KAAC;IAC3C,MAAMqD,oBAAoB/I,KAAKgH,MAAM,CAAC5F,MAAM0D,QAAQ,EAAE;QACpDoC,cAAc;YACZhE;YACA8F,cAAclE;YACd1B;YACAE;YACAE;YACAE;YACAC;YACAI;YACArD;YACAD;YACA4D;YACAC;YACAC;YACAC;YACAC;YACAC;YACAxC,OAAOC,gBAAgByB;QACzB;QACAuD,aAAajI;IACf;IACA6J,kBAAkBE,SAAS,GAAGtJ,iBAAiBF,eAAesJ,kBAAkBE,SAAS,EAAEnD;IAC3FiD,kBAAkB9G,YAAY,GAAGtC,iBAAiBF,eAAesJ,kBAAkB9G,YAAY,EAAE6D;IACjG,MAAMpE,QAAyB;QAC7BgE,UAAU,CAAC,CAACtE,MAAMsE,QAAQ;QAC1B5B;QACAoF,YAAY;YAAEjC,MAAMzH;YAAOsF,UAAU5F;YAA8CsJ,cAAc;QAAM;QACvG1D,UAAUiE;QACV/E;QACAiD;QACAuB;IACF;IAEA9G,MAAMuF,IAAI,CAAC/E,KAAK,GAAGG;IAEnB,OAAOX;AACT,EAAE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { __resetStyles, __styles, mergeClasses } from '@griffel/react';
|
|
2
|
+
import { tokens, typographyStyles } from '@fluentui/react-theme';
|
|
3
|
+
export const datePickerClassNames = {
|
|
4
|
+
root: 'fui-DatePicker',
|
|
5
|
+
calendar: 'fui-DatePicker__calendar',
|
|
6
|
+
popupSurface: 'fui-DatePicker__popupSurface'
|
|
7
|
+
};
|
|
8
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
9
|
+
base: {
|
|
10
|
+
qhf8xq: "f10pi13n",
|
|
11
|
+
Bceei9c: "f1k6fduh",
|
|
12
|
+
xfaavh: "faxec97"
|
|
13
|
+
},
|
|
14
|
+
disabled: {
|
|
15
|
+
Bceei9c: "f158kwzp",
|
|
16
|
+
xfaavh: "f19qwlmg"
|
|
17
|
+
},
|
|
18
|
+
inline: {
|
|
19
|
+
Bj3rh1h: "f19g0ac"
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
d: [".f10pi13n{position:relative;}", ".f1k6fduh{cursor:pointer;}", ".faxec97 input{cursor:pointer;}", ".f158kwzp{cursor:default;}", ".f19qwlmg input{cursor:default;}", ".f19g0ac{z-index:1;}"]
|
|
23
|
+
});
|
|
24
|
+
const usePopupSurfaceClassName = /*#__PURE__*/__resetStyles("r1ytv1z8", null, [".r1ytv1z8{background-color:var(--colorNeutralBackground1);box-shadow:var(--shadow16);border-radius:var(--borderRadiusMedium);border-width:1px;border-style:solid;border-color:var(--colorTransparentStroke);display:inline-flex;color:var(--colorNeutralForeground1);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase300);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase300);}"]);
|
|
25
|
+
/**
|
|
26
|
+
* Apply styling to the DatePicker slots based on the state
|
|
27
|
+
*/
|
|
28
|
+
export const useDatePickerStyles_unstable = state => {
|
|
29
|
+
'use no memo';
|
|
30
|
+
|
|
31
|
+
const styles = useStyles();
|
|
32
|
+
const popupSurfaceClassName = usePopupSurfaceClassName();
|
|
33
|
+
const {
|
|
34
|
+
disabled,
|
|
35
|
+
inlinePopup
|
|
36
|
+
} = state;
|
|
37
|
+
state.root.className = mergeClasses(datePickerClassNames.root, styles.base, disabled && styles.disabled, state.root.className);
|
|
38
|
+
if (state.popupSurface) {
|
|
39
|
+
state.popupSurface.className = mergeClasses(datePickerClassNames.popupSurface, popupSurfaceClassName, state.popupSurface.className, inlinePopup && styles.inline);
|
|
40
|
+
}
|
|
41
|
+
state.calendar.className = mergeClasses(datePickerClassNames.calendar, state.calendar.className);
|
|
42
|
+
return state;
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__resetStyles","__styles","mergeClasses","tokens","typographyStyles","datePickerClassNames","root","calendar","popupSurface","useStyles","base","qhf8xq","Bceei9c","xfaavh","disabled","inline","Bj3rh1h","d","usePopupSurfaceClassName","useDatePickerStyles_unstable","state","styles","popupSurfaceClassName","inlinePopup","className"],"sources":["useDatePickerStyles.styles.js"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nexport const datePickerClassNames = {\n root: 'fui-DatePicker',\n calendar: 'fui-DatePicker__calendar',\n popupSurface: 'fui-DatePicker__popupSurface'\n};\nconst useStyles = makeStyles({\n base: {\n position: 'relative',\n cursor: 'pointer',\n '& input': {\n cursor: 'pointer'\n }\n },\n disabled: {\n cursor: 'default',\n '& input': {\n cursor: 'default'\n }\n },\n inline: {\n // When rendering inline, the popupSurface will be rendered under relatively positioned elements such as Input.\n // This is due to the surface being positioned as absolute, therefore zIndex: 1 ensures that won't happen.\n zIndex: 1\n }\n});\nconst usePopupSurfaceClassName = makeResetStyles({\n backgroundColor: tokens.colorNeutralBackground1,\n boxShadow: tokens.shadow16,\n borderRadius: tokens.borderRadiusMedium,\n borderWidth: '1px',\n borderStyle: 'solid',\n borderColor: tokens.colorTransparentStroke,\n display: 'inline-flex',\n color: tokens.colorNeutralForeground1,\n ...typographyStyles.body1\n});\n/**\n * Apply styling to the DatePicker slots based on the state\n */ export const useDatePickerStyles_unstable = (state)=>{\n 'use no memo';\n const styles = useStyles();\n const popupSurfaceClassName = usePopupSurfaceClassName();\n const { disabled, inlinePopup } = state;\n state.root.className = mergeClasses(datePickerClassNames.root, styles.base, disabled && styles.disabled, state.root.className);\n if (state.popupSurface) {\n state.popupSurface.className = mergeClasses(datePickerClassNames.popupSurface, popupSurfaceClassName, state.popupSurface.className, inlinePopup && styles.inline);\n }\n state.calendar.className = mergeClasses(datePickerClassNames.calendar, state.calendar.className);\n return state;\n};\n"],"mappings":"AAAA,SAAAA,aAAA,EAAAC,QAAA,EAAsCC,YAAY,QAAQ,gBAAgB;AAC1E,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,uBAAuB;AAChE,OAAO,MAAMC,oBAAoB,GAAG;EAChCC,IAAI,EAAE,gBAAgB;EACtBC,QAAQ,EAAE,0BAA0B;EACpCC,YAAY,EAAE;AAClB,CAAC;AACD,MAAMC,SAAS,gBAAGR,QAAA;EAAAS,IAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAF,OAAA;IAAAC,MAAA;EAAA;EAAAE,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,CAmBjB,CAAC;AACF,MAAMC,wBAAwB,gBAAGlB,aAAA,0aAUhC,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMmB,4BAA4B,GAAIC,KAAK,IAAG;EACrD,aAAa;;EACb,MAAMC,MAAM,GAAGZ,SAAS,CAAC,CAAC;EAC1B,MAAMa,qBAAqB,GAAGJ,wBAAwB,CAAC,CAAC;EACxD,MAAM;IAAEJ,QAAQ;IAAES;EAAY,CAAC,GAAGH,KAAK;EACvCA,KAAK,CAACd,IAAI,CAACkB,SAAS,GAAGtB,YAAY,CAACG,oBAAoB,CAACC,IAAI,EAAEe,MAAM,CAACX,IAAI,EAAEI,QAAQ,IAAIO,MAAM,CAACP,QAAQ,EAAEM,KAAK,CAACd,IAAI,CAACkB,SAAS,CAAC;EAC9H,IAAIJ,KAAK,CAACZ,YAAY,EAAE;IACpBY,KAAK,CAACZ,YAAY,CAACgB,SAAS,GAAGtB,YAAY,CAACG,oBAAoB,CAACG,YAAY,EAAEc,qBAAqB,EAAEF,KAAK,CAACZ,YAAY,CAACgB,SAAS,EAAED,WAAW,IAAIF,MAAM,CAACN,MAAM,CAAC;EACrK;EACAK,KAAK,CAACb,QAAQ,CAACiB,SAAS,GAAGtB,YAAY,CAACG,oBAAoB,CAACE,QAAQ,EAAEa,KAAK,CAACb,QAAQ,CAACiB,SAAS,CAAC;EAChG,OAAOJ,KAAK;AAChB,CAAC","ignoreList":[]}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DatePicker, datePickerClassNames, defaultDatePickerErrorStrings, defaultDatePickerStrings, renderDatePicker_unstable, useDatePicker_unstable, useDatePickerStyles_unstable } from './DatePicker';
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n DatePicker,\n datePickerClassNames,\n defaultDatePickerErrorStrings,\n defaultDatePickerStrings,\n renderDatePicker_unstable,\n useDatePicker_unstable,\n useDatePickerStyles_unstable,\n} from './DatePicker';\nexport type { DatePickerErrorType, DatePickerProps, DatePickerValidationResultData } from './DatePicker';\n// Re-exporting so there's no need to add @fluentui/react-calendar-compat to dependencies just to localize.\nexport type { CalendarStrings } from '@fluentui/react-calendar-compat';\n"],"names":["DatePicker","datePickerClassNames","defaultDatePickerErrorStrings","defaultDatePickerStrings","renderDatePicker_unstable","useDatePicker_unstable","useDatePickerStyles_unstable"],"rangeMappings":"","mappings":"AAAA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,6BAA6B,EAC7BC,wBAAwB,EACxBC,yBAAyB,EACzBC,sBAAsB,EACtBC,4BAA4B,QACvB,eAAe"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';
|
|
3
|
+
/**
|
|
4
|
+
* Hook used to handle positioning of the popup.
|
|
5
|
+
*
|
|
6
|
+
* @param props - DatePicker props
|
|
7
|
+
* @returns tuple of trigger and popup refs
|
|
8
|
+
* @internal
|
|
9
|
+
*/ export function usePopupPositioning(props) {
|
|
10
|
+
const { positioning } = props;
|
|
11
|
+
const popupOptions = {
|
|
12
|
+
position: 'below',
|
|
13
|
+
align: 'start',
|
|
14
|
+
...resolvePositioningShorthand(positioning)
|
|
15
|
+
};
|
|
16
|
+
const { targetRef, containerRef } = usePositioning(popupOptions);
|
|
17
|
+
return [
|
|
18
|
+
targetRef,
|
|
19
|
+
containerRef
|
|
20
|
+
];
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/usePopupPositioning.ts"],"sourcesContent":["import * as React from 'react';\nimport { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport type { DatePickerProps } from '../DatePicker';\n\n/**\n * Hook used to handle positioning of the popup.\n *\n * @param props - DatePicker props\n * @returns tuple of trigger and popup refs\n * @internal\n */\nexport function usePopupPositioning(\n props: DatePickerProps,\n): [triggerRef: React.MutableRefObject<HTMLElement>, popupRef: React.MutableRefObject<HTMLDivElement>] {\n const { positioning } = props;\n\n const popupOptions = {\n position: 'below' as const,\n align: 'start' as const,\n ...resolvePositioningShorthand(positioning),\n };\n\n const { targetRef, containerRef } = usePositioning(popupOptions);\n\n return [targetRef, containerRef];\n}\n"],"names":["React","resolvePositioningShorthand","usePositioning","usePopupPositioning","props","positioning","popupOptions","position","align","targetRef","containerRef"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,2BAA2B,EAAEC,cAAc,QAAQ,8BAA8B;AAG1F;;;;;;CAMC,GACD,OAAO,SAASC,oBACdC,KAAsB;IAEtB,MAAM,EAAEC,WAAW,EAAE,GAAGD;IAExB,MAAME,eAAe;QACnBC,UAAU;QACVC,OAAO;QACP,GAAGP,4BAA4BI,YAAY;IAC7C;IAEA,MAAM,EAAEI,SAAS,EAAEC,YAAY,EAAE,GAAGR,eAAeI;IAEnD,OAAO;QAACG;QAAWC;KAAa;AAClC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
DatePicker: function() {
|
|
13
|
+
return _index.DatePicker;
|
|
14
|
+
},
|
|
15
|
+
datePickerClassNames: function() {
|
|
16
|
+
return _index.datePickerClassNames;
|
|
17
|
+
},
|
|
18
|
+
defaultDatePickerErrorStrings: function() {
|
|
19
|
+
return _index.defaultDatePickerErrorStrings;
|
|
20
|
+
},
|
|
21
|
+
defaultDatePickerStrings: function() {
|
|
22
|
+
return _index.defaultDatePickerStrings;
|
|
23
|
+
},
|
|
24
|
+
renderDatePicker_unstable: function() {
|
|
25
|
+
return _index.renderDatePicker_unstable;
|
|
26
|
+
},
|
|
27
|
+
useDatePickerStyles_unstable: function() {
|
|
28
|
+
return _index.useDatePickerStyles_unstable;
|
|
29
|
+
},
|
|
30
|
+
useDatePicker_unstable: function() {
|
|
31
|
+
return _index.useDatePicker_unstable;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const _index = require("./components/DatePicker/index");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/DatePicker.ts"],"sourcesContent":["export type {\n DatePickerErrorType,\n DatePickerProps,\n DatePickerSlots,\n DatePickerState,\n DatePickerValidationResultData,\n} from './components/DatePicker/index';\nexport {\n DatePicker,\n datePickerClassNames,\n defaultDatePickerErrorStrings,\n defaultDatePickerStrings,\n renderDatePicker_unstable,\n useDatePickerStyles_unstable,\n useDatePicker_unstable,\n} from './components/DatePicker/index';\n"],"names":["DatePicker","datePickerClassNames","defaultDatePickerErrorStrings","defaultDatePickerStrings","renderDatePicker_unstable","useDatePickerStyles_unstable","useDatePicker_unstable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAQEA,UAAU;eAAVA,iBAAU;;IACVC,oBAAoB;eAApBA,2BAAoB;;IACpBC,6BAA6B;eAA7BA,oCAA6B;;IAC7BC,wBAAwB;eAAxBA,+BAAwB;;IACxBC,yBAAyB;eAAzBA,gCAAyB;;IACzBC,4BAA4B;eAA5BA,mCAA4B;;IAC5BC,sBAAsB;eAAtBA,6BAAsB;;;uBACjB"}
|