@astryxdesign/core 0.7.9-canary.e2b522f → 0.7.9-canary.e657e2e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BottomSheet/BottomSheet.js +2 -2
- package/dist/BottomSheet/bottomSheetStack.d.ts.map +1 -1
- package/dist/BottomSheet/bottomSheetStack.js +4 -3
- package/dist/BottomSheet/useSheetGestures.js +2 -2
- package/dist/CheckboxInput/CheckboxInput.d.ts +2 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +29 -16
- package/dist/CheckboxInput/CheckboxRowPressContext.d.ts +2 -0
- package/dist/CheckboxInput/CheckboxRowPressContext.d.ts.map +1 -0
- package/dist/CheckboxInput/CheckboxRowPressContext.js +20 -0
- package/dist/CheckboxList/CheckboxListItem.d.ts +2 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +40 -14
- package/dist/DateInput/DateInput.d.ts +37 -6
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +96 -127
- package/dist/DateInput/MonthScroller.d.ts +5 -2
- package/dist/DateInput/MonthScroller.d.ts.map +1 -1
- package/dist/DateInput/MonthScroller.js +26 -29
- package/dist/DateInput/MonthYearWheels.d.ts +10 -1
- package/dist/DateInput/MonthYearWheels.d.ts.map +1 -1
- package/dist/DateInput/MonthYearWheels.js +54 -42
- package/dist/DateInput/TouchDateField.d.ts +1 -1
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +26 -21
- package/dist/DateInput/monthGeometry.d.ts +42 -8
- package/dist/DateInput/monthGeometry.d.ts.map +1 -1
- package/dist/DateInput/monthGeometry.js +81 -7
- package/dist/DateInput/useCalendarPresentation.d.ts +10 -0
- package/dist/DateInput/useCalendarPresentation.d.ts.map +1 -0
- package/dist/DateInput/useCalendarPresentation.js +32 -0
- package/dist/DateInput/useTypedDate.d.ts +92 -0
- package/dist/DateInput/useTypedDate.d.ts.map +1 -0
- package/dist/DateInput/useTypedDate.js +269 -0
- package/dist/DateRangeInput/DateRangeInput.d.ts +17 -1
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +15 -11
- package/dist/DateTimeInput/DateTimeInput.d.ts +26 -3
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +91 -91
- package/dist/DateTimeInput/TouchDateTimeField.d.ts +1 -1
- package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
- package/dist/DateTimeInput/TouchDateTimeField.js +26 -20
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +2 -2
- package/dist/DropdownMenu/DropdownMenu.js +2 -4
- package/dist/InfoTip/InfoTip.d.ts.map +1 -1
- package/dist/InfoTip/InfoTip.js +5 -18
- package/dist/Item/Item.d.ts +18 -0
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +70 -25
- package/dist/Item/ItemListRowContext.d.ts +2 -0
- package/dist/Item/ItemListRowContext.d.ts.map +1 -0
- package/dist/Item/ItemListRowContext.js +16 -0
- package/dist/Layout/LayoutPanel.d.ts +10 -10
- package/dist/Layout/LayoutPanel.d.ts.map +1 -1
- package/dist/Layout/LayoutPanel.js +59 -7
- package/dist/List/List.d.ts.map +1 -1
- package/dist/List/List.js +1 -0
- package/dist/List/ListItem.d.ts +5 -4
- package/dist/List/ListItem.d.ts.map +1 -1
- package/dist/List/ListItem.js +45 -9
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +6 -9
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +5 -10
- package/dist/Resizable/ResizeHandle.d.ts +5 -5
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +44 -5
- package/dist/Resizable/resizablePane.d.ts +60 -0
- package/dist/Resizable/resizablePane.d.ts.map +1 -0
- package/dist/Resizable/resizablePane.js +142 -0
- package/dist/Resizable/useResizable.d.ts +7 -0
- package/dist/Resizable/useResizable.d.ts.map +1 -1
- package/dist/Resizable/useResizable.js +13 -0
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +32 -8
- package/dist/SideNav/SideNav.d.ts +9 -3
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +47 -10
- package/dist/astryx.css +344 -334
- package/dist/hooks/computeOverflow.d.ts +2 -0
- package/dist/hooks/computeOverflow.d.ts.map +1 -1
- package/dist/hooks/computeOverflow.js +1 -1
- package/dist/hooks/useClickableContainer.d.ts +10 -3
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +23 -10
- package/dist/hooks/useKeyboardHighlight.d.ts +17 -0
- package/dist/hooks/useKeyboardHighlight.d.ts.map +1 -0
- package/dist/hooks/useKeyboardHighlight.js +38 -0
- package/dist/hooks/useMediaQuery.d.ts +2 -1
- package/dist/hooks/useMediaQuery.d.ts.map +1 -1
- package/dist/hooks/useMediaQuery.js +37 -12
- package/dist/hooks/useOverflow.d.ts.map +1 -1
- package/dist/hooks/useOverflow.js +190 -21
- package/dist/i18n/InternationalizationProvider.d.ts +2 -1
- package/dist/i18n/InternationalizationProvider.d.ts.map +1 -1
- package/dist/i18n/generated-english/DateInput/DateInput.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/DateInput/DateInput.generated.js +0 -1
- package/dist/i18n/generated-english/DateInput/useTypedDate.generated.d.ts +8 -0
- package/dist/i18n/generated-english/DateInput/useTypedDate.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/DateInput/useTypedDate.generated.js +16 -0
- package/dist/i18n/generated-english/DateTimeInput/DateTimeInput.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/DateTimeInput/DateTimeInput.generated.js +0 -1
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +4 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +4 -0
- package/dist/privateAttributes/press.stylex.d.ts +14 -11
- package/dist/privateAttributes/press.stylex.d.ts.map +1 -1
- package/dist/privateAttributes/press.stylex.js +15 -11
- package/dist/utils/calendarDateParser.d.ts +3 -1
- package/dist/utils/calendarDateParser.d.ts.map +1 -1
- package/dist/utils/calendarDateParser.js +105 -17
- package/dist/utils/calendarSystem.d.ts +49 -3
- package/dist/utils/calendarSystem.d.ts.map +1 -1
- package/dist/utils/calendarSystem.js +129 -5
- package/dist/utils/coarsePointer.d.ts +5 -0
- package/dist/utils/coarsePointer.d.ts.map +1 -1
- package/dist/utils/coarsePointer.js +22 -13
- package/dist/utils/focusReturn.d.ts +10 -2
- package/dist/utils/focusReturn.d.ts.map +1 -1
- package/dist/utils/focusReturn.js +16 -3
- package/dist/utils/hitArea.d.ts +8 -1
- package/dist/utils/hitArea.d.ts.map +1 -1
- package/dist/utils/hitArea.js +17 -4
- package/dist/utils/inputPresentation.d.ts +9 -1
- package/dist/utils/inputPresentation.d.ts.map +1 -1
- package/dist/utils/inputPresentation.js +15 -1
- package/dist/utils/touchHitArea.d.ts +30 -0
- package/dist/utils/touchHitArea.d.ts.map +1 -0
- package/dist/utils/touchHitArea.js +167 -0
- package/dist/utils/touchHitArea.stylex.d.ts +6 -3
- package/dist/utils/touchHitArea.stylex.d.ts.map +1 -1
- package/dist/utils/touchHitArea.stylex.js +19 -3
- package/locales/en.json +17 -1
- package/locales/pseudo.json +12 -0
- package/package.json +4 -4
- package/src/BottomSheet/BottomSheet.tsx +2 -2
- package/src/BottomSheet/bottomSheetStack.ts +4 -3
- package/src/BottomSheet/useSheetGestures.ts +2 -2
- package/src/CheckboxInput/CheckboxInput.doc.mjs +2 -2
- package/src/CheckboxInput/CheckboxInput.tsx +46 -23
- package/src/CheckboxInput/CheckboxRowPressContext.ts +22 -0
- package/src/CheckboxList/CheckboxList.doc.mjs +9 -0
- package/src/CheckboxList/CheckboxListItem.doc.mjs +3 -3
- package/src/CheckboxList/CheckboxListItem.tsx +35 -14
- package/src/DateInput/DateInput.doc.mjs +45 -12
- package/src/DateInput/DateInput.tsx +163 -181
- package/src/DateInput/MonthScroller.tsx +39 -37
- package/src/DateInput/MonthYearWheels.tsx +68 -47
- package/src/DateInput/TouchDateField.tsx +45 -17
- package/src/DateInput/monthGeometry.ts +110 -8
- package/src/DateInput/useCalendarPresentation.ts +64 -0
- package/src/DateInput/useTypedDate.ts +469 -0
- package/src/DateRangeInput/DateRangeInput.doc.mjs +9 -0
- package/src/DateRangeInput/DateRangeInput.tsx +42 -10
- package/src/DateTimeInput/DateTimeInput.doc.mjs +42 -9
- package/src/DateTimeInput/DateTimeInput.tsx +136 -150
- package/src/DateTimeInput/TouchDateTimeField.tsx +31 -16
- package/src/Dialog/Dialog.tsx +2 -1
- package/src/DropdownMenu/DropdownMenu.tsx +2 -2
- package/src/InfoTip/InfoTip.tsx +5 -27
- package/src/Item/Item.tsx +92 -30
- package/src/Item/ItemListRowContext.tsx +18 -0
- package/src/Layout/LayoutPanel.doc.mjs +8 -8
- package/src/Layout/LayoutPanel.tsx +89 -13
- package/src/List/List.doc.mjs +10 -1
- package/src/List/List.tsx +5 -0
- package/src/List/ListItem.tsx +63 -8
- package/src/MultiSelector/MultiSelector.tsx +7 -17
- package/src/PowerSearch/PowerSearch.doc.mjs +3 -3
- package/src/RadioList/RadioListItem.tsx +5 -13
- package/src/Resizable/Resizable.doc.mjs +40 -12
- package/src/Resizable/ResizeHandle.tsx +68 -6
- package/src/Resizable/resizablePane.ts +188 -0
- package/src/Resizable/useResizable.ts +15 -0
- package/src/Selector/Selector.tsx +49 -5
- package/src/SideNav/SideNav.doc.mjs +2 -2
- package/src/SideNav/SideNav.tsx +88 -12
- package/src/hooks/computeOverflow.ts +1 -1
- package/src/hooks/useClickableContainer.ts +22 -10
- package/src/hooks/useKeyboardHighlight.ts +71 -0
- package/src/hooks/useMediaQuery.ts +41 -12
- package/src/hooks/useOverflow.ts +297 -73
- package/src/i18n/InternationalizationProvider.doc.mjs +3 -3
- package/src/i18n/InternationalizationProvider.tsx +2 -1
- package/src/i18n/generated-english/DateInput/DateInput.generated.ts +0 -1
- package/src/i18n/generated-english/DateInput/useTypedDate.generated.ts +17 -0
- package/src/i18n/generated-english/DateTimeInput/DateTimeInput.generated.ts +0 -1
- package/src/i18n/generated-locales/en.generated.ts +6 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +6 -0
- package/src/privateAttributes/press.stylex.ts +29 -11
- package/src/utils/calendarDateParser.ts +108 -18
- package/src/utils/calendarSystem.ts +212 -3
- package/src/utils/coarsePointer.ts +27 -14
- package/src/utils/focusReturn.ts +17 -3
- package/src/utils/hitArea.ts +31 -4
- package/src/utils/inputPresentation.ts +21 -1
- package/src/utils/touchHitArea.stylex.ts +18 -3
- package/src/utils/touchHitArea.ts +177 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file DateInput.tsx
|
|
7
|
-
* @input Uses React, useId,
|
|
7
|
+
* @input Uses React, useId, useCallback, useRef, useTypedDateField, Field, Icon, Calendar, usePopover, InputGroupContext
|
|
8
8
|
* @output Exports DateInput component, DateInputProps
|
|
9
9
|
* @position Core implementation; consumed by index.ts, tested by DateInput.test.tsx
|
|
10
10
|
*
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - /apps/storybook/stories/DateInput.stories.tsx (storybook stories)
|
|
16
16
|
* - /packages/cli/assets/templates/blocks/components/DateInput/ (showcase blocks)
|
|
17
17
|
*/
|
|
18
|
-
import { use, useId,
|
|
18
|
+
import { use, useId, useCallback, useRef, useOptimistic, useTransition } from 'react';
|
|
19
19
|
import * as stylex from '@stylexjs/stylex';
|
|
20
20
|
import { inputDisabledFocusStyles } from "../Field/inputDisabledFocus.js";
|
|
21
21
|
import "../theme/tokens.stylex.js";
|
|
@@ -39,10 +39,12 @@ import { isFocusInsideOwnedLayer, isPressInsideOwnedLayer, useOutsidePress } fro
|
|
|
39
39
|
import { NativeDateField } from "./NativeDateField.js";
|
|
40
40
|
import { TouchDateField } from "./TouchDateField.js";
|
|
41
41
|
import { useTooltip } from "../Tooltip/index.js";
|
|
42
|
-
import { getInputARIA, isImeKeyEvent
|
|
42
|
+
import { getInputARIA, isImeKeyEvent } from "../utils/index.js";
|
|
43
43
|
import { chainEventHandlers } from "../utils/chainEventHandlers.js";
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
44
|
+
import { isRenderable } from "../utils/isRenderable.js";
|
|
45
|
+
import { useTypedDateField } from "./useTypedDate.js";
|
|
46
|
+
import { resolvePickerPresentation } from "../utils/inputPresentation.js";
|
|
47
|
+
import { useCalendarPresentation } from "./useCalendarPresentation.js";
|
|
46
48
|
import { useDevWarning } from "../hooks/useDevWarning.js";
|
|
47
49
|
const styles = {
|
|
48
50
|
iconButton: {
|
|
@@ -115,7 +117,6 @@ import { joinAriaIDs } from "../utils/inputAria.js";
|
|
|
115
117
|
import { useFieldInputStyling } from "../Field/fieldParts.js";
|
|
116
118
|
import { themeProps } from "../utils/themeProps.js";
|
|
117
119
|
import { focusOutlineStyles } from "../utils/focusOutline.stylex.js";
|
|
118
|
-
import { useLocale } from "../i18n/index.js";
|
|
119
120
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
120
121
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
121
122
|
import english from "../i18n/generated-english/DateInput/DateInput.generated.js";
|
|
@@ -178,6 +179,7 @@ function PointerDateField({
|
|
|
178
179
|
numberOfMonths = 1,
|
|
179
180
|
weekStartsOn,
|
|
180
181
|
format = 'date_long',
|
|
182
|
+
calendar,
|
|
181
183
|
width,
|
|
182
184
|
containerXstyle,
|
|
183
185
|
containerClassName,
|
|
@@ -202,11 +204,11 @@ function PointerDateField({
|
|
|
202
204
|
'aria-labelledby': ariaLabelledByProp,
|
|
203
205
|
onBlur: onBlurProp,
|
|
204
206
|
onClick: onClickProp,
|
|
207
|
+
onFocus: onFocusProp,
|
|
205
208
|
onKeyDown: onKeyDownProp,
|
|
206
209
|
...controlProps
|
|
207
210
|
} = rest;
|
|
208
211
|
const t = useComponentTranslator();
|
|
209
|
-
const locale = useLocale();
|
|
210
212
|
const isEffectivelyRequired = useResolvedRequired({
|
|
211
213
|
isRequired,
|
|
212
214
|
isOptional
|
|
@@ -219,9 +221,9 @@ function PointerDateField({
|
|
|
219
221
|
const inputLabelID = useId();
|
|
220
222
|
const descriptionID = useId();
|
|
221
223
|
const statusMessageID = useId();
|
|
224
|
+
const calendarDescriptionID = useId();
|
|
222
225
|
const inputRef = useRef(null);
|
|
223
226
|
const calendarRef = useRef(null);
|
|
224
|
-
const lastFiredValueRef = useRef(undefined);
|
|
225
227
|
const inputGroup = useInputGroup();
|
|
226
228
|
const [, startTransition] = useTransition();
|
|
227
229
|
const [optimisticValue, setOptimisticValue] = useOptimistic(value);
|
|
@@ -255,51 +257,71 @@ function PointerDateField({
|
|
|
255
257
|
max,
|
|
256
258
|
dateConstraints
|
|
257
259
|
});
|
|
260
|
+
const fireChange = useCallback(newValue => {
|
|
261
|
+
if (isEffectivelyDisabled) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
onChange?.(newValue);
|
|
265
|
+
if (changeAction) {
|
|
266
|
+
startTransition(async () => {
|
|
267
|
+
setOptimisticValue(newValue);
|
|
268
|
+
await changeAction(newValue);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}, [isEffectivelyDisabled, onChange, changeAction, startTransition, setOptimisticValue]);
|
|
272
|
+
const clearTypedDate = useCallback(() => {
|
|
273
|
+
if (value !== undefined) {
|
|
274
|
+
fireChange(undefined);
|
|
275
|
+
}
|
|
276
|
+
}, [value, fireChange]);
|
|
277
|
+
const navigateToTypedDate = useCallback(date => {
|
|
278
|
+
calendarRef.current?.navigateTo(date);
|
|
279
|
+
}, []);
|
|
280
|
+
const {
|
|
281
|
+
typedDate,
|
|
282
|
+
displayValue,
|
|
283
|
+
formatHint,
|
|
284
|
+
isPending,
|
|
285
|
+
isInvalid,
|
|
286
|
+
fieldStatus,
|
|
287
|
+
alertMessage,
|
|
288
|
+
handleChange: handleTypedChange,
|
|
289
|
+
commit: commitPendingInput,
|
|
290
|
+
handleFocus,
|
|
291
|
+
handleBlur,
|
|
292
|
+
reset: resetTypedInput
|
|
293
|
+
} = useTypedDateField({
|
|
294
|
+
source: 'DateInput',
|
|
295
|
+
calendar,
|
|
296
|
+
format,
|
|
297
|
+
min,
|
|
298
|
+
max,
|
|
299
|
+
isDateDisabled,
|
|
300
|
+
value,
|
|
301
|
+
shownValue: optimisticValue,
|
|
302
|
+
onChange: fireChange,
|
|
303
|
+
onClear: clearTypedDate,
|
|
304
|
+
onTypedDate: navigateToTypedDate,
|
|
305
|
+
isDisabled: isEffectivelyDisabled,
|
|
306
|
+
status,
|
|
307
|
+
isStatusAnnounced: !inputGroup,
|
|
308
|
+
hasPlaceholder: placeholderFromProps != null
|
|
309
|
+
});
|
|
258
310
|
const {
|
|
259
311
|
statusIcon,
|
|
260
312
|
describedBy: statusTooltipDescribedBy
|
|
261
313
|
} = useInputStatusIcon({
|
|
262
|
-
status,
|
|
314
|
+
status: fieldStatus,
|
|
263
315
|
statusVariant,
|
|
264
316
|
isInGroup: !!inputGroup
|
|
265
317
|
});
|
|
266
318
|
const {
|
|
267
319
|
ariaLabelledBy,
|
|
268
320
|
ariaDescribedBy
|
|
269
|
-
} = getInputARIA(inputLabelID, [description ? descriptionID : null, statusVariant !== 'tooltip' &&
|
|
321
|
+
} = getInputARIA(inputLabelID, [description ? descriptionID : null, typedDate.calendarDescription != null ? calendarDescriptionID : null, statusVariant !== 'tooltip' && fieldStatus?.message ? statusMessageID : null,
|
|
270
322
|
// The tooltip variant renders no message box; describe the input by the
|
|
271
323
|
// tooltip's content instead so the status is still announced.
|
|
272
324
|
statusTooltipDescribedBy, showsDisabledMessage ? disabledMessageTooltip.describedBy : null, ariaDescribedByProp], inputGroup);
|
|
273
|
-
|
|
274
|
-
// Pending input while user is typing (null = show formatted value)
|
|
275
|
-
const [pendingInput, setPendingInput] = useState(null);
|
|
276
|
-
|
|
277
|
-
// Clear pending input when value changes externally (computed during render
|
|
278
|
-
// via prev-value ref instead of useEffect to avoid an extra render cycle)
|
|
279
|
-
const prevValueRef = useRef(value);
|
|
280
|
-
if (value !== prevValueRef.current) {
|
|
281
|
-
prevValueRef.current = value;
|
|
282
|
-
if (value !== lastFiredValueRef.current) {
|
|
283
|
-
lastFiredValueRef.current = undefined;
|
|
284
|
-
if (pendingInput !== null) {
|
|
285
|
-
setPendingInput(null);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Format a committed ISO value for display. The default `date_long` renders
|
|
291
|
-
// the long-month shape (byte-identical to the historical hardcoded
|
|
292
|
-
// DATE_FORMAT_LONG rendering, so still non-breaking); a function is called
|
|
293
|
-
// with the ISO value; every other named member reuses Timestamp's shared
|
|
294
|
-
// date mapping. Applies ONLY to the committed value, never to in-progress
|
|
295
|
-
// typed input.
|
|
296
|
-
const formatCommittedValue = useCallback(iso => typeof format === 'function' ? format(iso) : formatSharedDate(plainDateFromISO(iso), format, locale), [format, locale]);
|
|
297
|
-
|
|
298
|
-
// Display value: pending input if typing, otherwise formatted value
|
|
299
|
-
const displayValue = pendingInput !== null ? pendingInput : optimisticValue && /^\d{4}-\d{2}-\d{2}$/.test(optimisticValue) ? formatCommittedValue(optimisticValue) : '';
|
|
300
|
-
|
|
301
|
-
// Check if current input is valid (for styling purposes)
|
|
302
|
-
const isInputValid = pendingInput === null || !pendingInput.trim() ? true : parseDateInput(pendingInput, locale) !== null;
|
|
303
325
|
const fieldElementRef = useRef(null);
|
|
304
326
|
// Set just before a close that focus already left the field for, so onHide
|
|
305
327
|
// does not pull focus back to the input.
|
|
@@ -359,20 +381,6 @@ function PointerDateField({
|
|
|
359
381
|
}
|
|
360
382
|
}, [isEffectivelyDisabled, popover]);
|
|
361
383
|
|
|
362
|
-
// Unified change handler that fires both onChange and changeAction
|
|
363
|
-
const fireChange = useCallback(newValue => {
|
|
364
|
-
if (isEffectivelyDisabled) {
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
onChange?.(newValue);
|
|
368
|
-
if (changeAction) {
|
|
369
|
-
startTransition(async () => {
|
|
370
|
-
setOptimisticValue(newValue);
|
|
371
|
-
await changeAction(newValue);
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
}, [isEffectivelyDisabled, onChange, changeAction, startTransition, setOptimisticValue]);
|
|
375
|
-
|
|
376
384
|
// Handle clear button click
|
|
377
385
|
const handleClear = useCallback(e => {
|
|
378
386
|
fireChange(undefined);
|
|
@@ -397,62 +405,12 @@ function PointerDateField({
|
|
|
397
405
|
return;
|
|
398
406
|
}
|
|
399
407
|
fireChange(selectedDate);
|
|
400
|
-
|
|
408
|
+
resetTypedInput();
|
|
401
409
|
popover.hide();
|
|
402
|
-
}, [isDisabled, fireChange, popover]);
|
|
403
|
-
|
|
404
|
-
// Handle input text change - update immediately if valid and allowed
|
|
410
|
+
}, [isDisabled, fireChange, resetTypedInput, popover]);
|
|
405
411
|
const handleInputChange = useCallback(e => {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (isEffectivelyDisabled) {
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
const newValue = e.target.value;
|
|
412
|
-
setPendingInput(newValue);
|
|
413
|
-
|
|
414
|
-
// If the input is valid and passes constraints, update immediately
|
|
415
|
-
const parsed = parseDateInput(newValue, locale);
|
|
416
|
-
if (parsed && plainDateToISO(parsed) !== value && !isDateDisabled(parsed)) {
|
|
417
|
-
const parsedISO = plainDateToISO(parsed);
|
|
418
|
-
lastFiredValueRef.current = parsedISO;
|
|
419
|
-
fireChange(parsedISO);
|
|
420
|
-
// Navigate calendar to show the parsed date's month
|
|
421
|
-
calendarRef.current?.navigateTo(parsedISO);
|
|
422
|
-
}
|
|
423
|
-
}, [value, fireChange, isDateDisabled, isEffectivelyDisabled, locale]);
|
|
424
|
-
|
|
425
|
-
// Commit pending input (shared by blur and Enter key)
|
|
426
|
-
const commitPendingInput = useCallback(() => {
|
|
427
|
-
if (pendingInput === null) {
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
// Disabled or busy: keep the value, drop the draft (spec:AST-085 FR2).
|
|
431
|
-
if (isEffectivelyDisabled) {
|
|
432
|
-
setPendingInput(null);
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
if (!pendingInput.trim()) {
|
|
436
|
-
if (value !== undefined) {
|
|
437
|
-
fireChange(undefined);
|
|
438
|
-
}
|
|
439
|
-
setPendingInput(null);
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
const parsed = parseDateInput(pendingInput, locale);
|
|
443
|
-
if (parsed && !isDateDisabled(parsed)) {
|
|
444
|
-
const parsedISO = plainDateToISO(parsed);
|
|
445
|
-
if (parsedISO !== value) {
|
|
446
|
-
fireChange(parsedISO);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
setPendingInput(null);
|
|
450
|
-
}, [pendingInput, isEffectivelyDisabled, value, fireChange, isDateDisabled, locale]);
|
|
451
|
-
|
|
452
|
-
// Handle blur - validate, check constraints, and clear pending input.
|
|
453
|
-
const handleBlur = useCallback(() => {
|
|
454
|
-
commitPendingInput();
|
|
455
|
-
}, [commitPendingInput]);
|
|
412
|
+
handleTypedChange(e.target.value);
|
|
413
|
+
}, [handleTypedChange]);
|
|
456
414
|
|
|
457
415
|
// A manual popover has no auto-popover exclusivity, so without this close
|
|
458
416
|
// the next field's calendar would open beside this one. Focus going nowhere
|
|
@@ -488,14 +446,14 @@ function PointerDateField({
|
|
|
488
446
|
skipAutoFocus: true
|
|
489
447
|
});
|
|
490
448
|
}
|
|
491
|
-
} else if (e.key === 'Enter' && (
|
|
449
|
+
} else if (e.key === 'Enter' && (isPending || isEffectivelyDisabled)) {
|
|
492
450
|
// Typed text holds Enter back, or a form would submit the value from
|
|
493
451
|
// before the commit. A disabled or busy field must not submit its
|
|
494
452
|
// form either. Otherwise Enter keeps its default, as in any text field.
|
|
495
453
|
e.preventDefault();
|
|
496
454
|
commitPendingInput();
|
|
497
455
|
}
|
|
498
|
-
}, [popover, commitPendingInput, isEffectivelyDisabled,
|
|
456
|
+
}, [popover, commitPendingInput, isEffectivelyDisabled, isPending]);
|
|
499
457
|
const inputWrapper = /*#__PURE__*/_jsxs("div", {
|
|
500
458
|
ref: el => {
|
|
501
459
|
fieldElementRef.current = el;
|
|
@@ -509,13 +467,13 @@ function PointerDateField({
|
|
|
509
467
|
...(inputGroup ? inputGroupItemProps : undefined),
|
|
510
468
|
...mergeProps(themeProps('date-input', {
|
|
511
469
|
size,
|
|
512
|
-
status:
|
|
470
|
+
status: fieldStatus?.type ?? null,
|
|
513
471
|
disabled: isDisabled ? 'disabled' : null
|
|
514
472
|
}), stylex.props(inputWrapperStyles.base, sizeStyles[size],
|
|
515
473
|
// Disabled paint belongs to the disabled state only; a busy field
|
|
516
474
|
// keeps its ordinary paint and shows the Spinner (spec:AST-085
|
|
517
475
|
// FR6, family:buttons FR4).
|
|
518
|
-
isDisabled && inputWrapperStyles.disabled, isEffectivelyDisabled && inputDisabledFocusStyles.inputFocusRing,
|
|
476
|
+
isDisabled && inputWrapperStyles.disabled, isEffectivelyDisabled && inputDisabledFocusStyles.inputFocusRing, fieldStatus && inputStatusBorderStyles[fieldStatus.type], fieldStatus && !isEffectivelyDisabled && inputStatusHoverShadowStyles[fieldStatus.type], fieldStatus && inputStatusFocusWithinStyles[fieldStatus.type], inputGroup && groupStyles.inGroup, controlXstyle), controlClassName, controlStyle),
|
|
519
477
|
children: [inputGroup && /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
520
478
|
id: inputLabelID,
|
|
521
479
|
children: label
|
|
@@ -552,15 +510,16 @@ function PointerDateField({
|
|
|
552
510
|
value: displayValue,
|
|
553
511
|
onChange: handleInputChange,
|
|
554
512
|
onBlur: chainEventHandlers(handleBlur, onBlurProp),
|
|
513
|
+
onFocus: chainEventHandlers(handleFocus, onFocusProp),
|
|
555
514
|
onClick: isEffectivelyDisabled ? undefined : chainEventHandlers(handleInputClick, onClickProp),
|
|
556
515
|
onKeyDown: chainEventHandlers(handleInputKeyDown, onKeyDownProp),
|
|
557
|
-
placeholder: placeholder,
|
|
516
|
+
placeholder: formatHint ?? placeholder,
|
|
558
517
|
"aria-disabled": isEffectivelyDisabled ? 'true' : undefined,
|
|
559
518
|
readOnly: isEffectivelyDisabled || undefined,
|
|
560
519
|
"aria-labelledby": ariaLabelledByProp != null ? joinAriaIDs(ariaLabelledBy ?? fieldLabelID, ariaLabelledByProp) : ariaLabelledBy,
|
|
561
520
|
"aria-describedby": ariaDescribedBy,
|
|
562
521
|
"aria-required": isEffectivelyRequired ? 'true' : undefined,
|
|
563
|
-
"aria-invalid":
|
|
522
|
+
"aria-invalid": fieldStatus?.type === 'error' || isInvalid ? 'true' : undefined,
|
|
564
523
|
"aria-busy": isBusy || undefined,
|
|
565
524
|
"aria-expanded": popover.isOpen,
|
|
566
525
|
"aria-haspopup": "dialog",
|
|
@@ -580,12 +539,15 @@ function PointerDateField({
|
|
|
580
539
|
3: {
|
|
581
540
|
className: "x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 xf9zqsd xw6l6zx xjbqb8w x1a2a7pz xeyghm5 xt0e3qv xv1l7n4"
|
|
582
541
|
}
|
|
583
|
-
}[!!isEffectivelyDisabled << 1 |
|
|
542
|
+
}[!!isEffectivelyDisabled << 1 | !!isInvalid << 0]
|
|
584
543
|
}), /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
585
544
|
as: "div",
|
|
586
545
|
role: "alert",
|
|
587
546
|
"aria-live": "assertive",
|
|
588
|
-
children:
|
|
547
|
+
children: alertMessage
|
|
548
|
+
}), isRenderable(typedDate.calendarDescription) && /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
549
|
+
id: calendarDescriptionID,
|
|
550
|
+
children: typedDate.calendarDescription
|
|
589
551
|
}), hasClear && value !== undefined && !isEffectivelyDisabled && /*#__PURE__*/_jsx(InputClearButton, {
|
|
590
552
|
label: t('@astryx.dateInput.clear', {
|
|
591
553
|
label
|
|
@@ -597,11 +559,9 @@ function PointerDateField({
|
|
|
597
559
|
}), statusIcon, popover.render(
|
|
598
560
|
// The layer renders its children open or closed, so mount the
|
|
599
561
|
// calendar only while it is open; it opens on the current value.
|
|
600
|
-
!popover.isOpen ? null : /*#__PURE__*/_jsx(Calendar
|
|
601
|
-
// The field text is Gregorian, so the popover calendar is too.
|
|
602
|
-
, {
|
|
603
|
-
calendar: "gregory",
|
|
562
|
+
!popover.isOpen ? null : /*#__PURE__*/_jsx(Calendar, {
|
|
604
563
|
handleRef: calendarRef,
|
|
564
|
+
calendar: typedDate.calendar,
|
|
605
565
|
mode: "single",
|
|
606
566
|
value: optimisticValue ?? null,
|
|
607
567
|
onChange: handleDateSelect,
|
|
@@ -629,10 +589,10 @@ function PointerDateField({
|
|
|
629
589
|
isOptional: isOptional,
|
|
630
590
|
isRequired: isRequired,
|
|
631
591
|
isDisabled: isDisabled,
|
|
632
|
-
status:
|
|
633
|
-
type:
|
|
634
|
-
message:
|
|
635
|
-
messageID:
|
|
592
|
+
status: fieldStatus ? {
|
|
593
|
+
type: fieldStatus.type,
|
|
594
|
+
message: fieldStatus.message,
|
|
595
|
+
messageID: fieldStatus.message ? statusMessageID : undefined
|
|
636
596
|
} : undefined,
|
|
637
597
|
statusVariant: statusVariant,
|
|
638
598
|
labelTooltip: labelTooltip,
|
|
@@ -693,10 +653,15 @@ export function DateInput(props) {
|
|
|
693
653
|
const isDisabled = props.isDisabled || inputGroupState.isDisabled;
|
|
694
654
|
const isTouch = useMediaQuery(TOUCH_POINTER_QUERY);
|
|
695
655
|
useDevWarning('DateInput', '`nativePicker` is deprecated; use `presentation` instead (`touch` → `adaptive-native`, `always` → `native`, `never` → `adaptive-bottom-sheet`). `presentation` wins when both are set.', props.nativePicker !== undefined);
|
|
696
|
-
const
|
|
656
|
+
const {
|
|
657
|
+
calendar,
|
|
658
|
+
presentation
|
|
659
|
+
} = useCalendarPresentation('DateInput', props.calendar, props.presentation, props.nativePicker);
|
|
660
|
+
const surface = resolvePickerPresentation(presentation, isTouch);
|
|
697
661
|
const {
|
|
698
662
|
presentation: _presentation,
|
|
699
663
|
nativePicker: _nativePicker,
|
|
664
|
+
calendar: _calendar,
|
|
700
665
|
...rest
|
|
701
666
|
} = props;
|
|
702
667
|
switch (surface) {
|
|
@@ -706,13 +671,17 @@ export function DateInput(props) {
|
|
|
706
671
|
isDisabled: isDisabled
|
|
707
672
|
});
|
|
708
673
|
case 'sheet':
|
|
709
|
-
return /*#__PURE__*/_jsx(TouchDateField
|
|
674
|
+
return /*#__PURE__*/_jsx(TouchDateField
|
|
675
|
+
// Month indexes depend on the calendar. A new calendar remounts the sheet.
|
|
676
|
+
, {
|
|
710
677
|
...rest,
|
|
678
|
+
calendar: calendar,
|
|
711
679
|
isDisabled: isDisabled
|
|
712
|
-
});
|
|
680
|
+
}, calendar);
|
|
713
681
|
case 'desktop':
|
|
714
682
|
return /*#__PURE__*/_jsx(PointerDateField, {
|
|
715
683
|
...rest,
|
|
684
|
+
calendar: calendar,
|
|
716
685
|
isDisabled: isDisabled
|
|
717
686
|
});
|
|
718
687
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DayOfWeek, ISODateString, PlainDate } from '../utils/dateTypes.js';
|
|
2
|
+
import { type MonthModel } from './monthGeometry.js';
|
|
2
3
|
export interface MonthScrollerHandle {
|
|
3
4
|
/** Bring a month to rest at the top of the scrollport. */
|
|
4
5
|
scrollToMonth: (monthIndex: number, behavior?: ScrollBehavior) => void;
|
|
@@ -6,6 +7,8 @@ export interface MonthScrollerHandle {
|
|
|
6
7
|
export interface MonthScrollerProps {
|
|
7
8
|
/** Imperative handle for programmatic navigation (Today, the wheels). */
|
|
8
9
|
handleRef?: React.RefObject<MonthScrollerHandle | null>;
|
|
10
|
+
/** The calendar's months, by index. */
|
|
11
|
+
monthModel: MonthModel;
|
|
9
12
|
/** First reachable month, as a month index. */
|
|
10
13
|
minMonthIndex: number;
|
|
11
14
|
/** Last reachable month, as a month index. */
|
|
@@ -28,7 +31,7 @@ export interface MonthScrollerProps {
|
|
|
28
31
|
/**
|
|
29
32
|
* A vertically continuous, snap-paged run of month grids.
|
|
30
33
|
*/
|
|
31
|
-
export declare function MonthScroller({ handleRef, minMonthIndex, maxMonthIndex, initialMonthIndex, onVisibleMonthChange, selectedDate, today, isDateDisabled, weekStartsOn, onSelect, }: MonthScrollerProps): import("react").JSX.Element;
|
|
34
|
+
export declare function MonthScroller({ handleRef, monthModel, minMonthIndex, maxMonthIndex, initialMonthIndex, onVisibleMonthChange, selectedDate, today, isDateDisabled, weekStartsOn, onSelect, }: MonthScrollerProps): import("react").JSX.Element;
|
|
32
35
|
export declare namespace MonthScroller {
|
|
33
36
|
var displayName: string;
|
|
34
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthScroller.d.ts","sourceRoot":"","sources":["../../src/DateInput/MonthScroller.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MonthScroller.d.ts","sourceRoot":"","sources":["../../src/DateInput/MonthScroller.tsx"],"names":[],"mappings":"AAwDA,OAAO,KAAK,EAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAuB5E,OAAO,EACL,KAAK,UAAU,EAKhB,MAAM,iBAAiB,CAAC;AAqMzB,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;CACxE;AAED,MAAM,WAAW,kBAAkB;IACjC,yEAAyE;IACzE,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACxD,uCAAuC;IACvC,UAAU,EAAE,UAAU,CAAC;IACvB,+CAA+C;IAC/C,aAAa,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,oBAAoB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,+BAA+B;IAC/B,YAAY,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B,4CAA4C;IAC5C,KAAK,EAAE,SAAS,CAAC;IACjB,2DAA2D;IAC3D,cAAc,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC;IAC7C,gCAAgC;IAChC,YAAY,EAAE,SAAS,CAAC;IACxB,kCAAkC;IAClC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,UAAU,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,KAAK,EACL,cAAc,EACd,YAAY,EACZ,QAAQ,GACT,EAAE,kBAAkB,+BA8iBpB;yBA1jBe,aAAa"}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file MonthScroller.tsx
|
|
7
|
-
* @input
|
|
7
|
+
* @input A calendar's month model, month bounds, selected value, constraints,
|
|
8
|
+
* week start
|
|
8
9
|
* @output Exports MonthScroller and MonthScrollerHandle
|
|
9
10
|
* @position Internal component; consumed by TouchDateField.tsx
|
|
10
11
|
*
|
|
@@ -29,22 +30,23 @@
|
|
|
29
30
|
* - /packages/core/src/DateInput/DateInput.doc.mjs
|
|
30
31
|
* - /packages/core/src/DateInput/DateInputTouch.test.tsx
|
|
31
32
|
*/
|
|
32
|
-
import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
|
|
33
|
+
import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useMemo, useState } from 'react';
|
|
33
34
|
import { flushSync } from 'react-dom';
|
|
34
35
|
import * as stylex from '@stylexjs/stylex';
|
|
35
|
-
import { useCalendarDays } from "../Calendar/
|
|
36
|
-
import { useDirection
|
|
36
|
+
import { useCalendarDays } from "../Calendar/hooks/useCalendarDays.js";
|
|
37
|
+
import { useDirection } from "../i18n/useDirection.js";
|
|
38
|
+
import { useLocale } from "../i18n/useLocale.js";
|
|
37
39
|
import "../theme/tokens.stylex.js";
|
|
38
40
|
import { colorVars, radiusVars, fontWeightVars, typeScaleVars, durationVars, borderVars } from "../theme/tokens.stylex.js";
|
|
39
|
-
import { focusOutlineStyles } from "../utils/
|
|
40
|
-
import { plainDateFormatDayNumber,
|
|
41
|
-
import { plainDateAddDays, plainDateDayOfWeek, plainDateFormat, plainDateIsEqual, plainDateToISO, DATE_FORMAT_WITH_WEEKDAY } from "../utils/index.js";
|
|
41
|
+
import { focusOutlineStyles } from "../utils/focusOutline.stylex.js";
|
|
42
|
+
import { plainDateAddDays, plainDateDayOfWeek, plainDateFormatDayNumber, plainDateIsEqual, plainDateToISO, DATE_FORMAT_WITH_WEEKDAY } from "../utils/plainDate.js";
|
|
42
43
|
import { playReducedMotionDip, reducedMotionFade } from "../motion/reducedMotion.js";
|
|
44
|
+
import { calendarYearMonthOf, formatCalendarDate, formatCalendarMonthLabel, isInCalendarMonth } from "../utils/calendarSystem.js";
|
|
43
45
|
import "./tokens.stylex.js";
|
|
44
46
|
import { dateInputTouchSizes, dateInputTouchGeometry } from "./tokens.stylex.js";
|
|
45
47
|
import { useOwnScrollGesture } from "./useOwnScrollGesture.js";
|
|
46
48
|
import { useScrollSettle } from "./useScrollSettle.js";
|
|
47
|
-
import {
|
|
49
|
+
import { paneWindow, rowAtScrollOffset, rowsIn, scrollOffsetForRow } from "./monthGeometry.js";
|
|
48
50
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
51
|
const DAY_SIZE = dateInputTouchSizes.daySize;
|
|
50
52
|
|
|
@@ -131,6 +133,7 @@ const dynamic = {
|
|
|
131
133
|
*/
|
|
132
134
|
export function MonthScroller({
|
|
133
135
|
handleRef,
|
|
136
|
+
monthModel,
|
|
134
137
|
minMonthIndex,
|
|
135
138
|
maxMonthIndex,
|
|
136
139
|
initialMonthIndex,
|
|
@@ -570,16 +573,16 @@ export function MonthScroller({
|
|
|
570
573
|
// by month is PageUp/PageDown; everything else is the APG grid vocabulary.
|
|
571
574
|
const moveFocus = useCallback((from, deltaDays) => {
|
|
572
575
|
const next = plainDateAddDays(from, deltaDays);
|
|
573
|
-
const nextIndex =
|
|
576
|
+
const nextIndex = monthModel.indexOf(next);
|
|
574
577
|
if (nextIndex < minMonthIndex || nextIndex > maxMonthIndex) {
|
|
575
578
|
return;
|
|
576
579
|
}
|
|
577
580
|
shouldRestoreFocusRef.current = true;
|
|
578
581
|
setFocusedDate(next);
|
|
579
|
-
if (nextIndex !==
|
|
582
|
+
if (nextIndex !== monthModel.indexOf(from)) {
|
|
580
583
|
scrollToMonth(nextIndex, 'smooth');
|
|
581
584
|
}
|
|
582
|
-
}, [minMonthIndex, maxMonthIndex, scrollToMonth]);
|
|
585
|
+
}, [monthModel, minMonthIndex, maxMonthIndex, scrollToMonth]);
|
|
583
586
|
const handleKeyDown = useCallback((event, date) => {
|
|
584
587
|
// Column within the displayed week, which is what Home/End move to —
|
|
585
588
|
// not the day of the month.
|
|
@@ -656,6 +659,7 @@ export function MonthScroller({
|
|
|
656
659
|
children: /*#__PURE__*/_jsx("div", {
|
|
657
660
|
...stylex.props(styles.spacer, dynamic.spacer(rowCount * paneSize)),
|
|
658
661
|
children: paneSize > 0 && rowsIn(visibleRows).map(row => /*#__PURE__*/_jsx(MonthPane, {
|
|
662
|
+
monthModel: monthModel,
|
|
659
663
|
monthIndex: minMonthIndex + row,
|
|
660
664
|
insetInlineStart: row * paneSize,
|
|
661
665
|
inlineSize: paneSize,
|
|
@@ -680,6 +684,7 @@ MonthScroller.displayName = 'MonthScroller';
|
|
|
680
684
|
* so each day instead carries its weekday in its accessible name.
|
|
681
685
|
*/
|
|
682
686
|
function MonthPane({
|
|
687
|
+
monthModel,
|
|
683
688
|
monthIndex,
|
|
684
689
|
insetInlineStart,
|
|
685
690
|
inlineSize,
|
|
@@ -694,40 +699,32 @@ function MonthPane({
|
|
|
694
699
|
}) {
|
|
695
700
|
const locale = useLocale();
|
|
696
701
|
const {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
702
|
+
calendar
|
|
703
|
+
} = monthModel;
|
|
704
|
+
const month = useMemo(() => monthModel.monthAt(monthIndex), [monthModel, monthIndex]);
|
|
700
705
|
const {
|
|
701
706
|
weeks
|
|
702
707
|
} = useCalendarDays({
|
|
703
|
-
|
|
704
|
-
|
|
708
|
+
...calendarYearMonthOf(calendar, month),
|
|
709
|
+
calendar,
|
|
705
710
|
weekStartsOn,
|
|
706
711
|
// Always six rows: a variable grid would make pane heights differ, and
|
|
707
712
|
// with them every snap offset below this month.
|
|
708
713
|
hasVariableRowCount: false
|
|
709
714
|
});
|
|
710
|
-
const monthLabel =
|
|
711
|
-
year,
|
|
712
|
-
month,
|
|
713
|
-
day: 1
|
|
714
|
-
}, locale);
|
|
715
|
+
const monthLabel = formatCalendarMonthLabel(calendar, month, locale);
|
|
715
716
|
|
|
716
717
|
// Exactly one day per pane is tab-reachable, so Tab moves through the
|
|
717
718
|
// picker rather than through 42 buttons: the focused day if the keyboard
|
|
718
719
|
// owns one, else the selection, else the first of the month.
|
|
719
720
|
const tabbableISO = (() => {
|
|
720
|
-
if (focusedDate != null && focusedDate
|
|
721
|
+
if (focusedDate != null && isInCalendarMonth(focusedDate, month)) {
|
|
721
722
|
return plainDateToISO(focusedDate);
|
|
722
723
|
}
|
|
723
|
-
if (selectedDate != null && selectedDate
|
|
724
|
+
if (selectedDate != null && isInCalendarMonth(selectedDate, month)) {
|
|
724
725
|
return plainDateToISO(selectedDate);
|
|
725
726
|
}
|
|
726
|
-
return plainDateToISO(
|
|
727
|
-
year,
|
|
728
|
-
month,
|
|
729
|
-
day: 1
|
|
730
|
-
});
|
|
727
|
+
return plainDateToISO(month.start);
|
|
731
728
|
})();
|
|
732
729
|
return /*#__PURE__*/_jsx("div", {
|
|
733
730
|
role: "grid",
|
|
@@ -759,7 +756,7 @@ function MonthPane({
|
|
|
759
756
|
"data-date": day.iso,
|
|
760
757
|
"data-outside": day.isOutside ? '' : undefined,
|
|
761
758
|
tabIndex: day.iso === tabbableISO ? 0 : -1,
|
|
762
|
-
"aria-label":
|
|
759
|
+
"aria-label": formatCalendarDate(calendar, day.date, DATE_FORMAT_WITH_WEEKDAY, locale),
|
|
763
760
|
"aria-disabled": isDisabled || undefined,
|
|
764
761
|
"aria-current": isToday ? 'date' : undefined,
|
|
765
762
|
onClick: () => {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { type MonthModel } from './monthGeometry.js';
|
|
1
2
|
export interface MonthYearWheelsProps {
|
|
3
|
+
/** The calendar's months, by index. */
|
|
4
|
+
monthModel: MonthModel;
|
|
2
5
|
/** The month the wheels currently show. */
|
|
3
6
|
monthIndex: number;
|
|
4
7
|
/** First reachable month. */
|
|
@@ -13,11 +16,17 @@ export interface MonthYearWheelsProps {
|
|
|
13
16
|
yearLabel: string;
|
|
14
17
|
/** False while the panel is hidden. */
|
|
15
18
|
isActive?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The day of the month the picker keeps, such as the selected date's. A year
|
|
21
|
+
* that spans an era change is labeled with the era of this day in the
|
|
22
|
+
* selected month. The first day of the month applies when it is absent.
|
|
23
|
+
*/
|
|
24
|
+
keptDay?: number;
|
|
16
25
|
}
|
|
17
26
|
/**
|
|
18
27
|
* Month and year wheels, bounded by the same range as the scroller.
|
|
19
28
|
*/
|
|
20
|
-
export declare function MonthYearWheels({ monthIndex, minMonthIndex, maxMonthIndex, onChange, monthLabel, yearLabel, isActive, }: MonthYearWheelsProps): import("react").JSX.Element;
|
|
29
|
+
export declare function MonthYearWheels({ monthModel, monthIndex, minMonthIndex, maxMonthIndex, onChange, monthLabel, yearLabel, isActive, keptDay, }: MonthYearWheelsProps): import("react").JSX.Element;
|
|
21
30
|
export declare namespace MonthYearWheels {
|
|
22
31
|
var displayName: string;
|
|
23
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthYearWheels.d.ts","sourceRoot":"","sources":["../../src/DateInput/MonthYearWheels.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MonthYearWheels.d.ts","sourceRoot":"","sources":["../../src/DateInput/MonthYearWheels.tsx"],"names":[],"mappings":"AAqCA,OAAO,EAAa,KAAK,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAU5D,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,UAAU,EAAE,UAAU,CAAC;IACvB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,4BAA4B;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,QAAQ,EACR,UAAU,EACV,SAAS,EACT,QAAe,EACf,OAAW,GACZ,EAAE,oBAAoB,+BAmFtB;yBA7Fe,eAAe"}
|