@astryxdesign/core 0.7.8 → 0.7.9-canary.0200dfe
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/AppShell/observeMainOverflow.d.ts.map +1 -1
- package/dist/AppShell/observeMainOverflow.js +9 -6
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +37 -3
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +40 -8
- package/dist/BottomSheet/bottomSheetStack.d.ts.map +1 -1
- package/dist/BottomSheet/bottomSheetStack.js +4 -3
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +61 -21
- package/dist/Calendar/Calendar.d.ts +14 -2
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +63 -74
- package/dist/Calendar/getInitialFocusDate.d.ts +4 -1
- package/dist/Calendar/getInitialFocusDate.d.ts.map +1 -1
- package/dist/Calendar/getInitialFocusDate.js +7 -5
- package/dist/Calendar/hooks/useCalendarDays.d.ts +19 -2
- package/dist/Calendar/hooks/useCalendarDays.d.ts.map +1 -1
- package/dist/Calendar/hooks/useCalendarDays.js +57 -64
- package/dist/Calendar/hooks/useCalendarNavigation.d.ts +28 -3
- package/dist/Calendar/hooks/useCalendarNavigation.d.ts.map +1 -1
- package/dist/Calendar/hooks/useCalendarNavigation.js +33 -22
- package/dist/Calendar/styles.d.ts +1 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts +2 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +74 -18
- 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/ClickableCard/ClickableCard.d.ts +1 -1
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +5 -1
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +2 -0
- package/dist/DateInput/DateInput.d.ts +37 -6
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +97 -124
- 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/PickerWheel.d.ts.map +1 -1
- package/dist/DateInput/PickerWheel.js +7 -1
- 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/DateInput/wheelStrip.js +2 -2
- package/dist/DateRangeInput/DateRangeInput.d.ts +17 -1
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +15 -8
- package/dist/DateTimeInput/DateTimeInput.d.ts +26 -3
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +92 -88
- 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 +2 -1
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +14 -3
- package/dist/Drawer/useDrawerDialogPresence.d.ts +2 -1
- package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
- package/dist/Drawer/useDrawerDialogPresence.js +11 -2
- package/dist/DropdownMenu/DropdownMenu.d.ts +9 -1
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +11 -8
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +3 -2
- package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuItem.js +3 -2
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioItem.js +3 -2
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +3 -2
- package/dist/Field/inputDisabledFocus.d.ts +4 -4
- package/dist/Field/inputStyles.stylex.d.ts +1 -1
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +16 -2
- package/dist/HoverCard/useHoverCard.d.ts +3 -1
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/Icon/Icon.d.ts +1 -1
- package/dist/InfoTip/InfoTip.d.ts +1 -0
- package/dist/InfoTip/InfoTip.d.ts.map +1 -1
- package/dist/InfoTip/InfoTip.js +6 -18
- package/dist/InputGroup/InputGroup.d.ts +4 -3
- package/dist/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/InputGroup/InputGroup.js +2 -2
- package/dist/InputGroup/InputGroupText.d.ts +2 -1
- package/dist/InputGroup/InputGroupText.d.ts.map +1 -1
- package/dist/InputGroup/InputGroupText.js +2 -1
- package/dist/InputGroup/groupStyles.d.ts +1 -1
- package/dist/InputGroup/groupStyles.d.ts.map +1 -1
- package/dist/InputGroup/groupStyles.js +1 -1
- package/dist/Item/Item.d.ts +20 -1
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +97 -29
- 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/Layer/holdEntranceInput.d.ts +24 -0
- package/dist/Layer/holdEntranceInput.d.ts.map +1 -0
- package/dist/Layer/holdEntranceInput.js +65 -0
- package/dist/Layer/inputHold.d.ts +49 -0
- package/dist/Layer/inputHold.d.ts.map +1 -0
- package/dist/Layer/inputHold.js +636 -0
- package/dist/Layer/outsidePress.d.ts +4 -0
- package/dist/Layer/outsidePress.d.ts.map +1 -1
- package/dist/Layer/outsidePress.js +18 -1
- package/dist/Layer/preserveAnimations.d.ts +1 -5
- package/dist/Layer/preserveAnimations.d.ts.map +1 -1
- package/dist/Layer/preserveAnimations.js +12 -214
- package/dist/Layer/useBackdropPress.d.ts +8 -0
- package/dist/Layer/useBackdropPress.d.ts.map +1 -1
- package/dist/Layer/useBackdropPress.js +31 -2
- package/dist/Layer/useLayer.d.ts +3 -1
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +64 -4
- package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
- package/dist/Layer/useTouchTrigger.js +4 -0
- package/dist/Layout/LayoutContent.d.ts +3 -1
- package/dist/Layout/LayoutContent.d.ts.map +1 -1
- package/dist/Layout/LayoutContent.js +12 -4
- package/dist/Layout/LayoutPanel.d.ts +13 -10
- package/dist/Layout/LayoutPanel.d.ts.map +1 -1
- package/dist/Layout/LayoutPanel.js +81 -11
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +4 -0
- 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/Markdown/parser.d.ts.map +1 -1
- package/dist/Markdown/parser.js +56 -39
- package/dist/MetadataList/MetadataList.js +1 -1
- package/dist/MobileNav/MobileNav.d.ts +11 -1
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +39 -1
- package/dist/MoreMenu/MoreMenu.d.ts +5 -3
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +6 -9
- package/dist/NumberInput/NumberInput.d.ts +4 -2
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +244 -11
- package/dist/OverflowList/OverflowList.d.ts.map +1 -1
- package/dist/OverflowList/OverflowList.js +7 -2
- package/dist/Popover/usePopover.d.ts +1 -0
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +12 -5
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchBottomSheet.js +4 -2
- package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchToken.js +3 -1
- package/dist/PowerSearch/formatFilterValue.d.ts +9 -3
- package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
- package/dist/PowerSearch/formatFilterValue.js +14 -11
- package/dist/PowerSearch/formatTokenValue.d.ts +6 -2
- package/dist/PowerSearch/formatTokenValue.d.ts.map +1 -1
- package/dist/PowerSearch/formatTokenValue.js +6 -3
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +16 -3
- 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 +58 -0
- package/dist/Resizable/resizablePane.d.ts.map +1 -0
- package/dist/Resizable/resizablePane.js +137 -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/SegmentedControl/useSegmentedSelectionMotion.js +3 -3
- package/dist/SelectableCard/SelectableCard.d.ts +1 -1
- package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.js +5 -1
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +51 -10
- package/dist/SideNav/SideNav.d.ts +9 -3
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +45 -10
- package/dist/Slider/sliderTouchController.js +2 -2
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +14 -71
- package/dist/Spinner/index.d.ts +1 -1
- package/dist/Spinner/index.d.ts.map +1 -1
- package/dist/Spinner/spinnerRotor.d.ts +28 -0
- package/dist/Spinner/spinnerRotor.d.ts.map +1 -0
- package/dist/Spinner/spinnerRotor.js +98 -0
- package/dist/Stack/StackItem.d.ts +8 -4
- package/dist/Stack/StackItem.d.ts.map +1 -1
- package/dist/Stack/StackItem.js +17 -4
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +13 -10
- package/dist/Switch/useSwitchTouch.js +4 -4
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +5 -1
- package/dist/Table/plugins/sortable/useTableSortable.js +1 -1
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +14 -8
- package/dist/Timestamp/formatInstant.d.ts +10 -1
- package/dist/Timestamp/formatInstant.d.ts.map +1 -1
- package/dist/Timestamp/formatInstant.js +13 -27
- package/dist/Timestamp/tooltipEntries.d.ts +5 -3
- package/dist/Timestamp/tooltipEntries.d.ts.map +1 -1
- package/dist/Timestamp/tooltipEntries.js +6 -4
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +9 -0
- package/dist/Token/TokenLink.d.ts +1 -1
- package/dist/Token/TokenLink.d.ts.map +1 -1
- package/dist/Token/TokenLink.js +4 -1
- package/dist/Tokenizer/Tokenizer.d.ts +14 -10
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +189 -89
- package/dist/Tooltip/useTooltip.d.ts +3 -1
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +164 -59
- package/dist/TreeList/TreeListItem.d.ts +2 -1
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +27 -3
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +2 -1
- package/dist/animator/createAnimator.js +2 -2
- package/dist/astryx.css +362 -325
- package/dist/gestures/GestureHost.d.ts +2 -2
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +21 -6
- package/dist/gestures/PanGestureRecognizer.d.ts +11 -1
- package/dist/gestures/PanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/PanGestureRecognizer.js +15 -1
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +6 -1
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -1
- package/dist/gestures/nativeScroll.d.ts +3 -6
- package/dist/gestures/nativeScroll.d.ts.map +1 -1
- package/dist/gestures/nativeScroll.js +7 -52
- package/dist/gestures/wheelSegmenter.d.ts +68 -1
- package/dist/gestures/wheelSegmenter.d.ts.map +1 -1
- package/dist/gestures/wheelSegmenter.js +199 -10
- package/dist/hooks/StackItemScrollRegion.d.ts +31 -0
- package/dist/hooks/StackItemScrollRegion.d.ts.map +1 -0
- package/dist/hooks/StackItemScrollRegion.js +40 -0
- 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/menuPressGesture.d.ts +133 -21
- package/dist/hooks/menuPressGesture.d.ts.map +1 -1
- package/dist/hooks/menuPressGesture.js +155 -30
- package/dist/hooks/menuPressValues.d.ts +16 -0
- package/dist/hooks/menuPressValues.d.ts.map +1 -0
- package/dist/hooks/menuPressValues.js +18 -0
- package/dist/hooks/useClickableContainer.d.ts +36 -7
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +63 -14
- package/dist/hooks/useFocusTrap.d.ts +10 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +225 -132
- 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/useMenuPress.d.ts +34 -1
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +93 -5
- package/dist/hooks/useOverflow.d.ts +10 -0
- package/dist/hooks/useOverflow.d.ts.map +1 -1
- package/dist/hooks/useOverflow.js +214 -23
- package/dist/hooks/usePressFeedback.d.ts +6 -6
- package/dist/hooks/usePressFeedback.js +6 -6
- package/dist/hooks/useScrollRegionProps.d.ts +35 -0
- package/dist/hooks/useScrollRegionProps.d.ts.map +1 -0
- package/dist/hooks/useScrollRegionProps.js +51 -0
- package/dist/i18n/InternationalizationContext.d.ts +6 -0
- package/dist/i18n/InternationalizationContext.d.ts.map +1 -1
- package/dist/i18n/InternationalizationProvider.d.ts +23 -3
- package/dist/i18n/InternationalizationProvider.d.ts.map +1 -1
- package/dist/i18n/InternationalizationProvider.js +8 -3
- 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-english/hooks/useScrollRegionProps.generated.d.ts +8 -0
- package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/hooks/useScrollRegionProps.generated.js +12 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +5 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +5 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/useCalendarSystem.d.ts +19 -0
- package/dist/i18n/useCalendarSystem.d.ts.map +1 -0
- package/dist/i18n/useCalendarSystem.js +61 -0
- package/dist/internal/calendar-system.d.ts +18 -0
- package/dist/internal/calendar-system.d.ts.map +1 -0
- package/dist/internal/calendar-system.js +19 -0
- package/dist/internal/spinner-rotor.d.ts +16 -0
- package/dist/internal/spinner-rotor.d.ts.map +1 -0
- package/dist/internal/spinner-rotor.js +16 -0
- package/dist/internal/touch.d.ts +20 -2
- package/dist/internal/touch.d.ts.map +1 -1
- package/dist/internal/touch.js +29 -3
- package/dist/motion/animator.d.ts +5 -5
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +7 -6
- package/dist/motion/carryAnimations.d.ts +58 -0
- package/dist/motion/carryAnimations.d.ts.map +1 -0
- package/dist/motion/carryAnimations.js +305 -0
- package/dist/motion/transientCopy.d.ts +4 -2
- package/dist/motion/transientCopy.d.ts.map +1 -1
- package/dist/motion/transientCopy.js +34 -5
- package/dist/motion/uikit/gestures.d.ts +41 -0
- package/dist/motion/uikit/gestures.d.ts.map +1 -1
- package/dist/motion/uikit/gestures.js +25 -0
- package/dist/motion/uikit/index.d.ts +1 -1
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +1 -1
- package/dist/motion/uikit/timing.d.ts +14 -10
- package/dist/motion/uikit/timing.d.ts.map +1 -1
- package/dist/motion/uikit/timing.js +7 -5
- package/dist/privateAttributes/menuPressLit.stylex.d.ts +52 -0
- package/dist/privateAttributes/menuPressLit.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/menuPressLit.stylex.js +99 -0
- package/dist/privateAttributes/press.stylex.d.ts +142 -0
- package/dist/privateAttributes/press.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/press.stylex.js +101 -0
- package/dist/theme/themeMotion.d.ts +3 -2
- package/dist/theme/themeMotion.d.ts.map +1 -1
- package/dist/theme/themeMotion.js +3 -2
- package/dist/theme/tokens.stylex.d.ts +2 -2
- package/dist/theme/tokens.stylex.js +1 -1
- package/dist/utils/calendarDateParser.d.ts +110 -0
- package/dist/utils/calendarDateParser.d.ts.map +1 -0
- package/dist/utils/calendarDateParser.js +1225 -0
- package/dist/utils/calendarSystem.d.ts +176 -0
- package/dist/utils/calendarSystem.d.ts.map +1 -0
- package/dist/utils/calendarSystem.js +569 -0
- 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/flatTree.d.ts +6 -3
- package/dist/utils/flatTree.d.ts.map +1 -1
- package/dist/utils/flatTree.js +13 -3
- package/dist/utils/focusReturn.d.ts +34 -13
- package/dist/utils/focusReturn.d.ts.map +1 -1
- package/dist/utils/focusReturn.js +64 -17
- package/dist/utils/hitArea.d.ts +8 -1
- package/dist/utils/hitArea.d.ts.map +1 -1
- package/dist/utils/hitArea.js +99 -9
- 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/inputStream.d.ts +14 -1
- package/dist/utils/inputStream.d.ts.map +1 -1
- package/dist/utils/inputStream.js +40 -9
- package/dist/utils/interactionOverlay.stylex.d.ts +5 -9
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +29 -31
- package/dist/utils/plainDate.d.ts +38 -7
- package/dist/utils/plainDate.d.ts.map +1 -1
- package/dist/utils/plainDate.js +92 -18
- package/dist/utils/pressFeedback.d.ts +10 -2
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +40 -15
- package/dist/utils/pressGesture.d.ts +12 -6
- package/dist/utils/pressGesture.d.ts.map +1 -1
- package/dist/utils/pressGesture.js +26 -8
- package/dist/utils/scrollView.d.ts +25 -0
- package/dist/utils/scrollView.d.ts.map +1 -0
- package/dist/utils/scrollView.js +108 -0
- package/dist/utils/selectionLock.d.ts.map +1 -1
- package/dist/utils/selectionLock.js +1 -10
- 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 +38 -0
- package/dist/utils/touchHitArea.stylex.d.ts.map +1 -0
- package/dist/utils/touchHitArea.stylex.js +48 -0
- package/dist/utils/triggerFocus.d.ts +5 -0
- package/dist/utils/triggerFocus.d.ts.map +1 -1
- package/dist/utils/triggerFocus.js +9 -2
- package/locales/en.json +21 -1
- package/locales/pseudo.json +15 -0
- package/package.json +15 -4
- package/src/AppShell/observeMainOverflow.ts +9 -6
- package/src/BottomSheet/BottomSheet.tsx +45 -3
- package/src/BottomSheet/BottomSheetPanel.tsx +64 -7
- package/src/BottomSheet/bottomSheetStack.ts +4 -3
- package/src/BottomSheet/useSheetGestures.ts +83 -20
- package/src/Calendar/Calendar.doc.mjs +76 -6
- package/src/Calendar/Calendar.tsx +123 -104
- package/src/Calendar/getInitialFocusDate.ts +22 -8
- package/src/Calendar/hooks/useCalendarDays.ts +89 -63
- package/src/Calendar/hooks/useCalendarNavigation.ts +68 -26
- package/src/CheckboxInput/CheckboxInput.doc.mjs +5 -4
- package/src/CheckboxInput/CheckboxInput.tsx +105 -20
- 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/ClickableCard/ClickableCard.tsx +8 -1
- package/src/ContextMenu/ContextMenu.tsx +2 -0
- package/src/DateInput/DateInput.doc.mjs +45 -12
- package/src/DateInput/DateInput.tsx +165 -179
- package/src/DateInput/MonthScroller.tsx +39 -37
- package/src/DateInput/MonthYearWheels.tsx +68 -47
- package/src/DateInput/PickerWheel.tsx +7 -2
- 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/DateInput/wheelStrip.ts +2 -2
- package/src/DateRangeInput/DateRangeInput.doc.mjs +9 -0
- package/src/DateRangeInput/DateRangeInput.tsx +43 -9
- package/src/DateTimeInput/DateTimeInput.doc.mjs +42 -9
- package/src/DateTimeInput/DateTimeInput.tsx +138 -148
- package/src/DateTimeInput/TouchDateTimeField.tsx +31 -16
- package/src/Dialog/Dialog.doc.mjs +1 -1
- package/src/Dialog/Dialog.tsx +14 -2
- package/src/Drawer/Drawer.doc.mjs +1 -1
- package/src/Drawer/useDrawerDialogPresence.ts +9 -2
- package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -2
- package/src/DropdownMenu/DropdownMenu.tsx +31 -7
- package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +5 -1
- package/src/DropdownMenu/DropdownMenuItem.tsx +8 -4
- package/src/DropdownMenu/DropdownMenuRadioItem.tsx +5 -1
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +5 -1
- package/src/FileInput/FileInput.tsx +16 -2
- package/src/HoverCard/useHoverCard.tsx +3 -1
- package/src/Icon/useIcon.doc.mjs +94 -0
- package/src/InfoTip/InfoTip.doc.mjs +26 -2
- package/src/InfoTip/InfoTip.tsx +6 -27
- package/src/InputGroup/InputGroup.doc.mjs +4 -3
- package/src/InputGroup/InputGroup.tsx +4 -3
- package/src/InputGroup/InputGroupText.doc.mjs +45 -3
- package/src/InputGroup/InputGroupText.tsx +2 -1
- package/src/InputGroup/groupStyles.ts +3 -1
- package/src/Item/Item.tsx +139 -35
- package/src/Item/ItemListRowContext.tsx +18 -0
- package/src/Layer/holdEntranceInput.ts +84 -0
- package/src/Layer/inputHold.ts +734 -0
- package/src/Layer/outsidePress.ts +18 -1
- package/src/Layer/preserveAnimations.ts +12 -275
- package/src/Layer/useBackdropPress.ts +41 -1
- package/src/Layer/useLayer.tsx +77 -4
- package/src/Layer/useTouchTrigger.ts +4 -0
- package/src/Layout/LayoutContent.doc.mjs +6 -3
- package/src/Layout/LayoutContent.tsx +10 -4
- package/src/Layout/LayoutPanel.doc.mjs +14 -11
- package/src/Layout/LayoutPanel.tsx +113 -16
- package/src/Lightbox/Lightbox.tsx +4 -0
- package/src/List/List.doc.mjs +10 -1
- package/src/List/List.tsx +5 -0
- package/src/List/ListItem.tsx +63 -8
- package/src/Markdown/parser.ts +65 -42
- package/src/MetadataList/MetadataList.tsx +1 -1
- package/src/MobileNav/MobileNav.doc.mjs +3 -3
- package/src/MobileNav/MobileNav.tsx +39 -1
- package/src/MoreMenu/MoreMenu.doc.mjs +2 -4
- package/src/MoreMenu/MoreMenu.tsx +5 -3
- package/src/MultiSelector/MultiSelector.tsx +7 -17
- package/src/NumberInput/NumberInput.doc.mjs +1 -1
- package/src/NumberInput/NumberInput.tsx +259 -11
- package/src/OverflowList/OverflowList.tsx +15 -9
- package/src/Popover/usePopover.tsx +1 -0
- package/src/PowerSearch/PowerSearch.doc.mjs +3 -3
- package/src/PowerSearch/PowerSearch.tsx +20 -3
- package/src/PowerSearch/PowerSearchBottomSheet.tsx +4 -1
- package/src/PowerSearch/PowerSearchToken.tsx +3 -0
- package/src/PowerSearch/formatFilterValue.ts +21 -11
- package/src/PowerSearch/formatTokenValue.ts +7 -1
- package/src/RadioList/RadioListItem.doc.mjs +3 -2
- package/src/RadioList/RadioListItem.tsx +16 -6
- package/src/Resizable/Resizable.doc.mjs +40 -12
- package/src/Resizable/ResizeHandle.tsx +68 -6
- package/src/Resizable/resizablePane.ts +179 -0
- package/src/Resizable/useResizable.ts +15 -0
- package/src/SegmentedControl/useSegmentedSelectionMotion.ts +3 -3
- package/src/SelectableCard/SelectableCard.tsx +8 -1
- package/src/Selector/Selector.tsx +83 -8
- package/src/SideNav/SideNav.doc.mjs +2 -2
- package/src/SideNav/SideNav.tsx +87 -12
- package/src/Slider/sliderTouchController.ts +2 -2
- package/src/Spinner/Spinner.tsx +7 -89
- package/src/Spinner/index.ts +1 -5
- package/src/Spinner/spinnerRotor.ts +113 -0
- package/src/Stack/Stack.doc.mjs +1 -1
- package/src/Stack/StackItem.tsx +27 -13
- package/src/Switch/Switch.tsx +7 -6
- package/src/Switch/useSwitchTouch.ts +4 -4
- package/src/TabList/Tab.tsx +5 -1
- package/src/Table/plugins/sortable/useTableSortable.tsx +1 -1
- package/src/Timestamp/Timestamp.doc.mjs +3 -3
- package/src/Timestamp/Timestamp.tsx +13 -8
- package/src/Timestamp/formatInstant.ts +49 -28
- package/src/Timestamp/tooltipEntries.ts +7 -3
- package/src/Token/Token.tsx +18 -1
- package/src/Token/TokenLink.tsx +7 -1
- package/src/Tokenizer/Tokenizer.doc.mjs +3 -3
- package/src/Tokenizer/Tokenizer.tsx +252 -115
- package/src/Tooltip/useTooltip.tsx +180 -80
- package/src/TreeList/TreeListItem.tsx +36 -2
- package/src/Typeahead/BaseTypeahead.tsx +2 -0
- package/src/animator/createAnimator.ts +3 -3
- package/src/gestures/GestureHost.ts +21 -5
- package/src/gestures/PanGestureRecognizer.ts +19 -2
- package/src/gestures/README.md +14 -5
- package/src/gestures/ScreenEdgePanGestureRecognizer.ts +6 -1
- package/src/gestures/nativeScroll.ts +12 -68
- package/src/gestures/wheelSegmenter.ts +243 -10
- package/src/hooks/StackItemScrollRegion.tsx +57 -0
- package/src/hooks/computeOverflow.ts +1 -1
- package/src/hooks/menuPressGesture.ts +244 -38
- package/src/hooks/menuPressValues.ts +18 -0
- package/src/hooks/useClickableContainer.doc.mjs +8 -2
- package/src/hooks/useClickableContainer.ts +93 -15
- package/src/hooks/useFocusTrap.ts +268 -151
- package/src/hooks/useKeyboardHighlight.ts +71 -0
- package/src/hooks/useMediaQuery.ts +41 -12
- package/src/hooks/useMenuPress.ts +118 -11
- package/src/hooks/useOverflow.ts +321 -75
- package/src/hooks/usePressFeedback.doc.mjs +3 -3
- package/src/hooks/usePressFeedback.ts +6 -6
- package/src/hooks/useScrollRegionProps.ts +76 -0
- package/src/i18n/InternationalizationContext.ts +6 -0
- package/src/i18n/InternationalizationProvider.doc.mjs +29 -1
- package/src/i18n/InternationalizationProvider.tsx +35 -3
- 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-english/hooks/useScrollRegionProps.generated.ts +13 -0
- package/src/i18n/generated-locales/en.generated.ts +7 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +7 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/useCalendarSystem.ts +95 -0
- package/src/internal/calendar-system.ts +26 -0
- package/src/internal/spinner-rotor.ts +20 -0
- package/src/internal/touch.ts +43 -2
- package/src/motion/MEASUREMENTS.md +11 -0
- package/src/motion/README.md +3 -3
- package/src/motion/animator.ts +7 -7
- package/src/motion/carryAnimations.ts +389 -0
- package/src/motion/transientCopy.ts +45 -5
- package/src/motion/uikit/gestures.ts +22 -0
- package/src/motion/uikit/index.ts +1 -0
- package/src/motion/uikit/timing.ts +7 -5
- package/src/privateAttributes/menuPressLit.stylex.ts +104 -0
- package/src/privateAttributes/press.stylex.ts +261 -0
- package/src/theme/themeMotion.ts +3 -2
- package/src/theme/tokens.stylex.ts +1 -1
- package/src/utils/calendarDateParser.ts +1385 -0
- package/src/utils/calendarSystem.ts +832 -0
- package/src/utils/coarsePointer.ts +27 -14
- package/src/utils/flatTree.ts +15 -3
- package/src/utils/focusReturn.ts +78 -18
- package/src/utils/hitArea.ts +138 -9
- package/src/utils/inputPresentation.ts +21 -1
- package/src/utils/inputStream.ts +47 -10
- package/src/utils/interactionOverlay.stylex.ts +19 -22
- package/src/utils/plainDate.ts +130 -19
- package/src/utils/pressFeedback.ts +46 -14
- package/src/utils/pressGesture.ts +35 -9
- package/src/utils/scrollView.ts +135 -0
- package/src/utils/selectionLock.ts +5 -10
- package/src/utils/touchHitArea.stylex.ts +56 -0
- package/src/utils/touchHitArea.ts +177 -0
- package/src/utils/triggerFocus.ts +17 -4
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file monthGeometry.ts
|
|
5
|
-
* @input PlainDate values, scroll offsets, pane heights
|
|
6
|
-
* @output
|
|
7
|
-
* @position Internal helper; consumed by
|
|
5
|
+
* @input PlainDate values, a calendar system, scroll offsets, pane heights
|
|
6
|
+
* @output Month-index arithmetic for a calendar and the virtualized pane window
|
|
7
|
+
* @position Internal helper; consumed by the touch date surfaces
|
|
8
8
|
*
|
|
9
|
-
* A "month index" is a single integer that totally orders calendar months
|
|
10
|
-
* `year * 12 + (month - 1)
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* A "month index" is a single integer that totally orders calendar months. In
|
|
10
|
+
* the Gregorian-aligned calendars it is `year * 12 + (month - 1)`; in the
|
|
11
|
+
* others it counts calendar months from a fixed month, because their years
|
|
12
|
+
* have 12 or 13 months. The scroller is a list of equal-width panes, so one
|
|
13
|
+
* integer converts freely between a month, a row in that list, and a scroll
|
|
14
|
+
* offset — which is the whole trick behind continuous scrolling.
|
|
13
15
|
*
|
|
14
16
|
* These are pure functions on purpose: the scroll math is the part most likely
|
|
15
17
|
* to be wrong, and it is testable without a layout engine.
|
|
@@ -17,6 +19,8 @@
|
|
|
17
19
|
* SYNC: When modified, update DateInputTouch.test.tsx.
|
|
18
20
|
*/
|
|
19
21
|
|
|
22
|
+
import { calendarAddMonths, calendarMonthOf, calendarMonthOfYear, calendarMonthsBetween, calendarMonthsInCalendarYear, calendarShiftYears, calendarYearMonthOf, isGregorianAligned } from "../utils/calendarSystem.js";
|
|
23
|
+
|
|
20
24
|
/** How many months are reachable in either direction when unbounded. */
|
|
21
25
|
export const DEFAULT_MONTH_REACH = 600;
|
|
22
26
|
|
|
@@ -95,4 +99,74 @@ export function rowsIn({
|
|
|
95
99
|
rows.push(row);
|
|
96
100
|
}
|
|
97
101
|
return rows;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Month indexes for one calendar. Years and month positions are the ones
|
|
106
|
+
* `calendarMonthOfYear` counts.
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
const GREGORIAN_MONTH_MODELS = new Map();
|
|
110
|
+
function gregorianMonthModel(calendar) {
|
|
111
|
+
let model = GREGORIAN_MONTH_MODELS.get(calendar);
|
|
112
|
+
if (model == null) {
|
|
113
|
+
model = {
|
|
114
|
+
calendar,
|
|
115
|
+
indexOf: monthIndexOf,
|
|
116
|
+
monthAt: index => {
|
|
117
|
+
const {
|
|
118
|
+
year,
|
|
119
|
+
month
|
|
120
|
+
} = fromMonthIndex(index);
|
|
121
|
+
return calendarMonthOfYear(calendar, year, month);
|
|
122
|
+
},
|
|
123
|
+
yearMonthAt: fromMonthIndex,
|
|
124
|
+
indexOfYearMonth: toMonthIndex,
|
|
125
|
+
monthsInYear: () => 12,
|
|
126
|
+
shiftYears: (index, years) => index + years * 12
|
|
127
|
+
};
|
|
128
|
+
GREGORIAN_MONTH_MODELS.set(calendar, model);
|
|
129
|
+
}
|
|
130
|
+
return model;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// The month that holds EPOCH is index 0. Any fixed month works; a recent one
|
|
134
|
+
// keeps the indexes of nearby months small.
|
|
135
|
+
const EPOCH = {
|
|
136
|
+
year: 2000,
|
|
137
|
+
month: 1,
|
|
138
|
+
day: 1
|
|
139
|
+
};
|
|
140
|
+
function temporalMonthModel(calendar) {
|
|
141
|
+
const epoch = calendarMonthOf(calendar, EPOCH);
|
|
142
|
+
// Temporal arithmetic is slow next to a render. The panes and the wheels ask
|
|
143
|
+
// for the same months on every render.
|
|
144
|
+
const months = new Map();
|
|
145
|
+
const monthAt = index => {
|
|
146
|
+
let month = months.get(index);
|
|
147
|
+
if (month == null) {
|
|
148
|
+
month = calendarAddMonths(calendar, epoch, index);
|
|
149
|
+
months.set(index, month);
|
|
150
|
+
}
|
|
151
|
+
return month;
|
|
152
|
+
};
|
|
153
|
+
const indexOf = date => calendarMonthsBetween(calendar, epoch, calendarMonthOf(calendar, date));
|
|
154
|
+
return {
|
|
155
|
+
calendar,
|
|
156
|
+
indexOf,
|
|
157
|
+
monthAt,
|
|
158
|
+
yearMonthAt: index => calendarYearMonthOf(calendar, monthAt(index)),
|
|
159
|
+
indexOfYearMonth: (year, month) => indexOf(calendarMonthOfYear(calendar, year, month).start),
|
|
160
|
+
monthsInYear: year => calendarMonthsInCalendarYear(calendar, year),
|
|
161
|
+
shiftYears: (index, years) => indexOf(calendarShiftYears(calendar, monthAt(index).start, years))
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The month model of a calendar. A calendar that needs Temporal must be
|
|
167
|
+
* available in this runtime; `useCalendarSystem` resolves one that is not to
|
|
168
|
+
* `gregory`.
|
|
169
|
+
*/
|
|
170
|
+
export function createMonthModel(calendar) {
|
|
171
|
+
return isGregorianAligned(calendar) ? gregorianMonthModel(calendar) : temporalMonthModel(calendar);
|
|
98
172
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type CalendarSystem } from '../utils/calendarSystem.js';
|
|
2
|
+
import { type LegacyNativePicker, type PickerPresentation } from '../utils/inputPresentation.js';
|
|
3
|
+
export interface CalendarPresentation {
|
|
4
|
+
/** The calendar the component shows. */
|
|
5
|
+
calendar: CalendarSystem;
|
|
6
|
+
/** The presentation policy, with native surfaces replaced in a calendar the native control cannot show. */
|
|
7
|
+
presentation: PickerPresentation;
|
|
8
|
+
}
|
|
9
|
+
export declare function useCalendarPresentation(source: string, calendarProp: CalendarSystem | undefined, presentation: PickerPresentation | undefined, nativePicker: LegacyNativePicker | undefined): CalendarPresentation;
|
|
10
|
+
//# sourceMappingURL=useCalendarPresentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCalendarPresentation.d.ts","sourceRoot":"","sources":["../../src/DateInput/useCalendarPresentation.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAGxB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,QAAQ,EAAE,cAAc,CAAC;IACzB,2GAA2G;IAC3G,YAAY,EAAE,kBAAkB,CAAC;CAClC;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,cAAc,GAAG,SAAS,EACxC,YAAY,EAAE,kBAAkB,GAAG,SAAS,EAC5C,YAAY,EAAE,kBAAkB,GAAG,SAAS,GAC3C,oBAAoB,CAyBtB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file useCalendarPresentation.ts
|
|
7
|
+
* @input A date component's `calendar`, `presentation`, and `nativePicker`
|
|
8
|
+
* @output The resolved calendar and the presentation policy it allows
|
|
9
|
+
* @position DateInput helper hook; used by DateInput and DateTimeInput to
|
|
10
|
+
* choose a surface. Warns once when an explicit `native` cannot apply.
|
|
11
|
+
*/
|
|
12
|
+
import { useEffect } from 'react';
|
|
13
|
+
import { useCalendarSystem } from "../i18n/useCalendarSystem.js";
|
|
14
|
+
import { isGregorianCalendar } from "../utils/calendarSystem.js";
|
|
15
|
+
import { warnOnce } from "../utils/devWarning.js";
|
|
16
|
+
import { calendarPickerPresentation, effectivePickerPresentation } from "../utils/inputPresentation.js";
|
|
17
|
+
export function useCalendarPresentation(source, calendarProp, presentation, nativePicker) {
|
|
18
|
+
const calendar = useCalendarSystem(calendarProp, source);
|
|
19
|
+
const isNativeCalendar = isGregorianCalendar(calendar);
|
|
20
|
+
const isNativeOverridden = presentation === 'native' && !isNativeCalendar;
|
|
21
|
+
// Synchronizes the development console. The key is the component and
|
|
22
|
+
// calendar, so a replay or a second field does not warn again.
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (isNativeOverridden) {
|
|
25
|
+
warnOnce(`presentation-native-calendar:${source}:${calendar}`, source, `presentation="native" shows the Astryx picker in the "${calendar}" ` + 'calendar, because the native date control shows only Gregorian ' + 'dates: the popover on a fine pointer and the bottom sheet on a ' + 'coarse pointer.');
|
|
26
|
+
}
|
|
27
|
+
}, [isNativeOverridden, source, calendar]);
|
|
28
|
+
return {
|
|
29
|
+
calendar,
|
|
30
|
+
presentation: calendarPickerPresentation(effectivePickerPresentation(presentation, nativePicker), isNativeCalendar)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { InputStatus } from '../Field/types.js';
|
|
2
|
+
import { type CalendarSystem } from '../utils/calendarSystem.js';
|
|
3
|
+
import { type CalendarDateParseResult } from '../utils/calendarDateParser.js';
|
|
4
|
+
import type { ISODateString, PlainDate } from '../utils/dateTypes.js';
|
|
5
|
+
import { type SharedDateFormat } from '../utils/plainDate.js';
|
|
6
|
+
/** A rejected typed date, by the message it announces. */
|
|
7
|
+
export type TypedDateError = 'unreadable' | 'nonexistent' | 'outOfRange';
|
|
8
|
+
export interface UseTypedDateOptions {
|
|
9
|
+
/** The component that names itself in development warnings. */
|
|
10
|
+
source: string;
|
|
11
|
+
/** The field's own calendar; the provider's calendar applies otherwise. */
|
|
12
|
+
calendar?: CalendarSystem;
|
|
13
|
+
/** The committed display format. */
|
|
14
|
+
format: SharedDateFormat | ((value: ISODateString) => string);
|
|
15
|
+
min?: ISODateString;
|
|
16
|
+
max?: ISODateString;
|
|
17
|
+
isDateDisabled: (date: PlainDate) => boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface TypedDate {
|
|
20
|
+
/** The resolved calendar, for the field's Calendar. */
|
|
21
|
+
calendar: CalendarSystem;
|
|
22
|
+
/** Builds the lexicon ahead of the first keystroke. */
|
|
23
|
+
prepare: () => void;
|
|
24
|
+
parse: (text: string) => CalendarDateParseResult;
|
|
25
|
+
formatCommitted: (value: ISODateString) => string;
|
|
26
|
+
/**
|
|
27
|
+
* An example date for an empty focused field, or null for Gregorian. The
|
|
28
|
+
* example is today when the field accepts it, else the nearest date it
|
|
29
|
+
* accepts.
|
|
30
|
+
*/
|
|
31
|
+
getFormatHint: () => string | null;
|
|
32
|
+
/** Names the calendar, or null when it is the provider's calendar. */
|
|
33
|
+
calendarDescription: string | null;
|
|
34
|
+
/** The message for a rejected result. */
|
|
35
|
+
errorMessage: (result: CalendarDateParseResult) => string;
|
|
36
|
+
}
|
|
37
|
+
/** The rejection a result shows: errors of complete text, or of committed text. */
|
|
38
|
+
export declare function typedDateError(result: CalendarDateParseResult | null, isCommitted: boolean): TypedDateError | null;
|
|
39
|
+
/**
|
|
40
|
+
* Typed entry for a date text field in the active calendar. Values stay
|
|
41
|
+
* Gregorian; the calendar changes only what people type and read.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useTypedDate({ source, calendar: calendarProp, format, min, max, isDateDisabled, }: UseTypedDateOptions): TypedDate;
|
|
44
|
+
export interface UseTypedDateFieldOptions extends UseTypedDateOptions {
|
|
45
|
+
/** The committed date. */
|
|
46
|
+
value: ISODateString | undefined;
|
|
47
|
+
/** The date the field shows, which leads `value` while a commit is in flight. */
|
|
48
|
+
shownValue: ISODateString | undefined;
|
|
49
|
+
/** Reports a typed date. */
|
|
50
|
+
onChange: (value: ISODateString) => void;
|
|
51
|
+
/** Runs when Enter or blur commits emptied text. */
|
|
52
|
+
onClear: () => void;
|
|
53
|
+
/** Runs when typing completes a new date, such as to show its month. */
|
|
54
|
+
onTypedDate?: (value: ISODateString) => void;
|
|
55
|
+
/**
|
|
56
|
+
* A disabled or busy field ignores typing, Enter and blur, and hides a typed
|
|
57
|
+
* rejection. Typed text stays until the next Enter or blur once the field is
|
|
58
|
+
* editable, or until `value` changes. Once the field is editable, text whose
|
|
59
|
+
* date typing already reported gives way to the field's value.
|
|
60
|
+
*/
|
|
61
|
+
isDisabled: boolean;
|
|
62
|
+
/** The caller's status. Rejected text that stays shows its own error instead. */
|
|
63
|
+
status?: InputStatus;
|
|
64
|
+
/** Whether the shown status announces itself, as Field's status does. */
|
|
65
|
+
isStatusAnnounced: boolean;
|
|
66
|
+
/** Whether the caller gave a placeholder, which replaces the format hint. */
|
|
67
|
+
hasPlaceholder: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface TypedDateField {
|
|
70
|
+
typedDate: TypedDate;
|
|
71
|
+
/** The text the input shows. */
|
|
72
|
+
displayValue: string;
|
|
73
|
+
/** The format hint for an empty focused field. */
|
|
74
|
+
formatHint: string | null;
|
|
75
|
+
/** Whether typed text waits to commit. */
|
|
76
|
+
isPending: boolean;
|
|
77
|
+
isInvalid: boolean;
|
|
78
|
+
/** The status the field shows. */
|
|
79
|
+
fieldStatus: InputStatus | undefined;
|
|
80
|
+
/** A typed rejection that the field status does not announce. */
|
|
81
|
+
alertMessage: string;
|
|
82
|
+
handleChange: (text: string) => void;
|
|
83
|
+
/** Commits typed text, on Enter or blur. */
|
|
84
|
+
commit: () => void;
|
|
85
|
+
handleFocus: () => void;
|
|
86
|
+
handleBlur: () => void;
|
|
87
|
+
/** Drops typed text after a date is picked another way. */
|
|
88
|
+
reset: () => void;
|
|
89
|
+
}
|
|
90
|
+
/** The typed entry of a date text field: its text, rejections, and commits. */
|
|
91
|
+
export declare function useTypedDateField({ value, shownValue, onChange, onClear, onTypedDate, isDisabled, status, isStatusAnnounced, hasPlaceholder, ...options }: UseTypedDateFieldOptions): TypedDateField;
|
|
92
|
+
//# sourceMappingURL=useTypedDate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTypedDate.d.ts","sourceRoot":"","sources":["../../src/DateInput/useTypedDate.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAQhD,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,uBAAuB,EAM7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAC,aAAa,EAAE,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EACL,KAAK,gBAAgB,EAOtB,MAAM,oBAAoB,CAAC;AAI5B,0DAA0D;AAC1D,MAAM,MAAM,cAAc,GAAG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AG,cAAc,CAsK3C"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file useTypedDate.ts
|
|
7
|
+
* @input Provider locale and calendar, a field's format, bounds and constraints;
|
|
8
|
+
* calendarDateParser, and parseDateInput for other Gregorian text
|
|
9
|
+
* @output Typed-date reading, committed text, the format hint, the calendar
|
|
10
|
+
* description and rejection messages for a date text field, and the typed
|
|
11
|
+
* entry state that DateInput and DateTimeInput share
|
|
12
|
+
* @position DateInput helper hook; used by DateInput and DateTimeInput
|
|
13
|
+
*/
|
|
14
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
15
|
+
import { useLocale } from "../i18n/useLocale.js";
|
|
16
|
+
import { useCalendarSystem } from "../i18n/useCalendarSystem.js";
|
|
17
|
+
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
18
|
+
import english from "../i18n/generated-english/DateInput/useTypedDate.generated.js";
|
|
19
|
+
import { isGregorianCalendar } from "../utils/calendarSystem.js";
|
|
20
|
+
import { calendarDisplayName, formatCalendarDateText, formatCalendarDateHint, getCalendarDateLexicon, parseCalendarDate } from "../utils/calendarDateParser.js";
|
|
21
|
+
import { parseDateInput } from "../utils/dateParser.js";
|
|
22
|
+
import { nearestAcceptedDate, plainDateFromISO, plainDateIsAfter, plainDateIsBefore, plainDateToISO, plainDateToday } from "../utils/plainDate.js";
|
|
23
|
+
registerEnglishFallback(english);
|
|
24
|
+
|
|
25
|
+
/** A rejected typed date, by the message it announces. */
|
|
26
|
+
|
|
27
|
+
/** The rejection a result shows: errors of complete text, or of committed text. */
|
|
28
|
+
export function typedDateError(result, isCommitted) {
|
|
29
|
+
if (result == null) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (result.kind === 'unreadable' || result.kind === 'incomplete' && isCommitted) {
|
|
33
|
+
return 'unreadable';
|
|
34
|
+
}
|
|
35
|
+
if ((result.kind === 'nonexistent' || result.kind === 'outOfRange') && (result.isComplete || isCommitted)) {
|
|
36
|
+
return result.kind;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Typed entry for a date text field in the active calendar. Values stay
|
|
43
|
+
* Gregorian; the calendar changes only what people type and read.
|
|
44
|
+
*/
|
|
45
|
+
export function useTypedDate({
|
|
46
|
+
source,
|
|
47
|
+
calendar: calendarProp,
|
|
48
|
+
format,
|
|
49
|
+
min,
|
|
50
|
+
max,
|
|
51
|
+
isDateDisabled
|
|
52
|
+
}) {
|
|
53
|
+
const t = useComponentTranslator();
|
|
54
|
+
const locale = useLocale();
|
|
55
|
+
const calendar = useCalendarSystem(calendarProp, source);
|
|
56
|
+
const providerCalendar = useCalendarSystem(undefined, source);
|
|
57
|
+
const isGregorian = isGregorianCalendar(calendar);
|
|
58
|
+
const prepare = useCallback(() => {
|
|
59
|
+
getCalendarDateLexicon(locale, calendar);
|
|
60
|
+
}, [locale, calendar]);
|
|
61
|
+
const parse = useCallback(text => {
|
|
62
|
+
const result = parseCalendarDate(text, getCalendarDateLexicon(locale, calendar), {
|
|
63
|
+
isoIsGregorian: format === 'system_date',
|
|
64
|
+
isDateDisabled
|
|
65
|
+
});
|
|
66
|
+
if (!isGregorian || result.kind !== 'unreadable' && result.kind !== 'nonexistent') {
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
// Gregorian text that only parseDateInput reads still commits, on Enter
|
|
70
|
+
// or blur only: it is never complete while the person types. This
|
|
71
|
+
// includes a day-first date in a month-first locale, which
|
|
72
|
+
// parseDateInput reads by swapping the order.
|
|
73
|
+
const date = parseDateInput(text, locale);
|
|
74
|
+
if (date == null) {
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
return isDateDisabled(date) ? {
|
|
78
|
+
kind: 'outOfRange',
|
|
79
|
+
date,
|
|
80
|
+
isComplete: false
|
|
81
|
+
} : {
|
|
82
|
+
kind: 'value',
|
|
83
|
+
date,
|
|
84
|
+
isComplete: false
|
|
85
|
+
};
|
|
86
|
+
}, [locale, calendar, format, isDateDisabled, isGregorian]);
|
|
87
|
+
const formatCommitted = useCallback(value => typeof format === 'function' ? format(value) : formatCalendarDateText(plainDateFromISO(value), format, locale, calendar), [format, locale, calendar]);
|
|
88
|
+
const getFormatHint = useCallback(() => {
|
|
89
|
+
if (isGregorian) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const example = nearestAcceptedDate(plainDateToday(), {
|
|
93
|
+
min: min != null ? plainDateFromISO(min) : null,
|
|
94
|
+
max: max != null ? plainDateFromISO(max) : null,
|
|
95
|
+
isDateDisabled
|
|
96
|
+
});
|
|
97
|
+
return t('@astryx.dateInput.formatHint', {
|
|
98
|
+
example: formatCalendarDateHint(example, locale, calendar)
|
|
99
|
+
});
|
|
100
|
+
}, [isGregorian, t, locale, calendar, min, max, isDateDisabled]);
|
|
101
|
+
const calendarName = useMemo(() => calendarDisplayName(calendar, locale), [calendar, locale]);
|
|
102
|
+
const errorMessage = useCallback(result => {
|
|
103
|
+
if (result.kind === 'nonexistent') {
|
|
104
|
+
return t('@astryx.dateInput.nonexistentDate', {
|
|
105
|
+
calendar: calendarName
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (result.kind === 'outOfRange') {
|
|
109
|
+
const boundFormat = typeof format === 'function' ? 'date_long' : format;
|
|
110
|
+
const writeBound = bound => formatCalendarDateText(plainDateFromISO(bound), boundFormat, locale, calendar);
|
|
111
|
+
const isBeforeMin = min != null && plainDateIsBefore(result.date, plainDateFromISO(min));
|
|
112
|
+
const isAfterMax = max != null && plainDateIsAfter(result.date, plainDateFromISO(max));
|
|
113
|
+
const bounds = !isBeforeMin && !isAfterMax ? 'none' : min != null && max != null ? 'both' : min != null ? 'min' : 'max';
|
|
114
|
+
return t('@astryx.dateInput.outOfRangeDate', {
|
|
115
|
+
bounds,
|
|
116
|
+
min: min != null ? writeBound(min) : '',
|
|
117
|
+
max: max != null ? writeBound(max) : ''
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return t('@astryx.dateInput.invalidDate');
|
|
121
|
+
}, [t, calendarName, format, locale, calendar, min, max]);
|
|
122
|
+
const isProviderCalendar = isGregorian ? isGregorianCalendar(providerCalendar) : calendar === providerCalendar;
|
|
123
|
+
return {
|
|
124
|
+
calendar,
|
|
125
|
+
prepare,
|
|
126
|
+
parse,
|
|
127
|
+
formatCommitted,
|
|
128
|
+
getFormatHint,
|
|
129
|
+
calendarDescription: isProviderCalendar ? null : t('@astryx.dateInput.calendarDescription', {
|
|
130
|
+
calendar: calendarName
|
|
131
|
+
}),
|
|
132
|
+
errorMessage
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/** The typed entry of a date text field: its text, rejections, and commits. */
|
|
136
|
+
export function useTypedDateField({
|
|
137
|
+
value,
|
|
138
|
+
shownValue,
|
|
139
|
+
onChange,
|
|
140
|
+
onClear,
|
|
141
|
+
onTypedDate,
|
|
142
|
+
isDisabled,
|
|
143
|
+
status,
|
|
144
|
+
isStatusAnnounced,
|
|
145
|
+
hasPlaceholder,
|
|
146
|
+
...options
|
|
147
|
+
}) {
|
|
148
|
+
const typedDate = useTypedDate(options);
|
|
149
|
+
// Typed text, or null when the field shows the committed value.
|
|
150
|
+
const [pendingInput, setPendingInput] = useState(null);
|
|
151
|
+
// Set when Enter or blur keeps rejected text so the person can correct it.
|
|
152
|
+
const [isRejectionCommitted, setIsRejectionCommitted] = useState(false);
|
|
153
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
154
|
+
// The date that typing last reported, so one typing session reports each
|
|
155
|
+
// date once.
|
|
156
|
+
const lastFiredRef = useRef(undefined);
|
|
157
|
+
const typedResult = pendingInput !== null && pendingInput.trim() ? typedDate.parse(pendingInput) : null;
|
|
158
|
+
// A locked field hides the rejection but keeps its state, so the rejection
|
|
159
|
+
// shows again once the field is editable.
|
|
160
|
+
const typedError = isDisabled ? null : typedDateError(typedResult, isRejectionCommitted);
|
|
161
|
+
const errorMessage = typedError != null && typedResult != null ? typedDate.errorMessage(typedResult) : null;
|
|
162
|
+
// Text that stays in the field shows its reason as well as announcing it.
|
|
163
|
+
const isErrorShown = typedError === 'nonexistent' || typedError === 'outOfRange' || typedError === 'unreadable' && isRejectionCommitted;
|
|
164
|
+
const typedStatus = isErrorShown && errorMessage != null ? {
|
|
165
|
+
type: 'error',
|
|
166
|
+
message: errorMessage
|
|
167
|
+
} : undefined;
|
|
168
|
+
const fieldStatus = typedStatus ?? status;
|
|
169
|
+
const reset = useCallback(() => {
|
|
170
|
+
setPendingInput(null);
|
|
171
|
+
setIsRejectionCommitted(false);
|
|
172
|
+
}, []);
|
|
173
|
+
|
|
174
|
+
// A value from outside drops typed text. Computed during render, so it
|
|
175
|
+
// takes no extra render.
|
|
176
|
+
const prevValueRef = useRef(value);
|
|
177
|
+
if (value !== prevValueRef.current) {
|
|
178
|
+
prevValueRef.current = value;
|
|
179
|
+
if (value !== lastFiredRef.current) {
|
|
180
|
+
lastFiredRef.current = undefined;
|
|
181
|
+
if (pendingInput !== null) {
|
|
182
|
+
setPendingInput(null);
|
|
183
|
+
setIsRejectionCommitted(false);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Typing already reported this date through `onChange`. Once the field is
|
|
189
|
+
// editable, it shows its value. A retyped date then reports again. A focused
|
|
190
|
+
// field keeps the text until Enter or blur, which end the typing session.
|
|
191
|
+
const wasDisabledRef = useRef(isDisabled);
|
|
192
|
+
if (isDisabled !== wasDisabledRef.current) {
|
|
193
|
+
wasDisabledRef.current = isDisabled;
|
|
194
|
+
if (!isDisabled && !isFocused && typedResult?.kind === 'value' && plainDateToISO(typedResult.date) === lastFiredRef.current) {
|
|
195
|
+
lastFiredRef.current = undefined;
|
|
196
|
+
setPendingInput(null);
|
|
197
|
+
setIsRejectionCommitted(false);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const report = useCallback(date => {
|
|
201
|
+
if (date === value || date === lastFiredRef.current) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
lastFiredRef.current = date;
|
|
205
|
+
onChange(date);
|
|
206
|
+
return true;
|
|
207
|
+
}, [value, onChange]);
|
|
208
|
+
const handleChange = useCallback(text => {
|
|
209
|
+
if (isDisabled) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
setPendingInput(text);
|
|
213
|
+
setIsRejectionCommitted(false);
|
|
214
|
+
// Report a date only once more typing cannot change it.
|
|
215
|
+
const result = typedDate.parse(text);
|
|
216
|
+
if (result.kind === 'value' && result.isComplete) {
|
|
217
|
+
const date = plainDateToISO(result.date);
|
|
218
|
+
if (report(date)) {
|
|
219
|
+
onTypedDate?.(date);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}, [isDisabled, typedDate, report, onTypedDate]);
|
|
223
|
+
const commit = useCallback(() => {
|
|
224
|
+
if (pendingInput === null || isDisabled) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (!pendingInput.trim()) {
|
|
228
|
+
onClear();
|
|
229
|
+
reset();
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const result = typedDate.parse(pendingInput);
|
|
233
|
+
if (result.kind === 'incomplete' || result.kind === 'nonexistent' || result.kind === 'outOfRange') {
|
|
234
|
+
// Keep the text and show why it cannot commit; never finish or adjust
|
|
235
|
+
// the date.
|
|
236
|
+
setIsRejectionCommitted(true);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (result.kind === 'value') {
|
|
240
|
+
report(plainDateToISO(result.date));
|
|
241
|
+
}
|
|
242
|
+
// A new typing session reports a retyped date again.
|
|
243
|
+
lastFiredRef.current = undefined;
|
|
244
|
+
reset();
|
|
245
|
+
}, [pendingInput, isDisabled, onClear, typedDate, report, reset]);
|
|
246
|
+
const handleFocus = useCallback(() => {
|
|
247
|
+
setIsFocused(true);
|
|
248
|
+
typedDate.prepare();
|
|
249
|
+
}, [typedDate]);
|
|
250
|
+
const handleBlur = useCallback(() => {
|
|
251
|
+
setIsFocused(false);
|
|
252
|
+
commit();
|
|
253
|
+
}, [commit]);
|
|
254
|
+
const displayValue = pendingInput !== null ? pendingInput : shownValue != null && /^\d{4}-\d{2}-\d{2}$/.test(shownValue) ? typedDate.formatCommitted(shownValue) : '';
|
|
255
|
+
return {
|
|
256
|
+
typedDate,
|
|
257
|
+
displayValue,
|
|
258
|
+
formatHint: !hasPlaceholder && isFocused && !displayValue ? typedDate.getFormatHint() : null,
|
|
259
|
+
isPending: pendingInput !== null,
|
|
260
|
+
isInvalid: typedError != null,
|
|
261
|
+
fieldStatus,
|
|
262
|
+
alertMessage: isStatusAnnounced && typedStatus != null ? '' : errorMessage ?? '',
|
|
263
|
+
handleChange,
|
|
264
|
+
commit,
|
|
265
|
+
handleFocus,
|
|
266
|
+
handleBlur,
|
|
267
|
+
reset
|
|
268
|
+
};
|
|
269
|
+
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { canVibrate, playHaptic } from "../gestures/haptics.js";
|
|
19
|
-
import {
|
|
19
|
+
import { createMotionEngine } from "../motion/animator.js";
|
|
20
20
|
import { reducedMotionFade } from "../motion/reducedMotion.js";
|
|
21
21
|
import { picker } from "../motion/uikit/picker.js";
|
|
22
22
|
import { nearestIndex, reachesRow, tickTimes } from "./wheelPhysics.js";
|
|
@@ -55,7 +55,7 @@ function now() {
|
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
57
|
export function createWheelStrip(initialLayout) {
|
|
58
|
-
const animator =
|
|
58
|
+
const animator = createMotionEngine(null);
|
|
59
59
|
let layout = initialLayout;
|
|
60
60
|
let running = null;
|
|
61
61
|
let nearestListener = null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CalendarSystem } from '../utils/calendarSystem.js';
|
|
1
2
|
import { type InputStatus } from '../Field/index.js';
|
|
2
3
|
import { type ISODateString, type DateRange, type DayOfWeek, type DayOfWeekName } from '../Calendar/index.js';
|
|
3
4
|
import { type FieldInputBaseProps } from '../Field/fieldParts.js';
|
|
@@ -167,6 +168,21 @@ export interface DateRangeInputProps extends Omit<FieldInputBaseProps<HTMLButton
|
|
|
167
168
|
* @default 2
|
|
168
169
|
*/
|
|
169
170
|
numberOfMonths?: 1 | 2;
|
|
171
|
+
/**
|
|
172
|
+
* The calendar the trigger text and the popover calendar show, such as
|
|
173
|
+
* `'persian'`, `'hebrew'`, or `'buddhist'`. `value`, `onChange`, `min`,
|
|
174
|
+
* `max`, and presets stay Gregorian ISO dates in every calendar. Calendars
|
|
175
|
+
* other than `gregory`, `iso8601`, `buddhist`, `roc`, and `japanese` need
|
|
176
|
+
* `Temporal`, native or a polyfill the application loads; without it the
|
|
177
|
+
* field shows Gregorian dates.
|
|
178
|
+
*
|
|
179
|
+
* @default the InternationalizationProvider's calendar, else `'gregory'`
|
|
180
|
+
* @example
|
|
181
|
+
* ```
|
|
182
|
+
* <DateRangeInput label="Stay" calendar="persian" value={range} onChange={setRange} />
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
calendar?: CalendarSystem;
|
|
170
186
|
/**
|
|
171
187
|
* First day of week in the calendar. Accepts a number
|
|
172
188
|
* (0 = Sunday … 6 = Saturday) or a three-letter day name ('sun'–'sat',
|
|
@@ -196,7 +212,7 @@ export interface DateRangeInputProps extends Omit<FieldInputBaseProps<HTMLButton
|
|
|
196
212
|
* />
|
|
197
213
|
* ```
|
|
198
214
|
*/
|
|
199
|
-
export declare function DateRangeInput({ label, isLabelHidden, description, isOptional, isRequired, isDisabled, disabledMessage, value, onChange, changeAction, isLoading, min, max, dateConstraints, maxRangeSpan, minRangeSpan, presets, hasClear, placeholder: placeholderFromProps, size: sizeProp, status, statusVariant, labelTooltip, numberOfMonths, weekStartsOn, width, containerXstyle, containerClassName, containerStyle, controlXstyle, controlClassName, controlStyle, ref, ...restProps }: DateRangeInputProps): import("react").JSX.Element;
|
|
215
|
+
export declare function DateRangeInput({ label, isLabelHidden, description, isOptional, isRequired, isDisabled, disabledMessage, value, onChange, changeAction, isLoading, min, max, dateConstraints, maxRangeSpan, minRangeSpan, presets, hasClear, placeholder: placeholderFromProps, size: sizeProp, status, statusVariant, labelTooltip, numberOfMonths, weekStartsOn, calendar: calendarProp, width, containerXstyle, containerClassName, containerStyle, controlXstyle, controlClassName, controlStyle, ref, ...restProps }: DateRangeInputProps): import("react").JSX.Element;
|
|
200
216
|
export declare namespace DateRangeInput {
|
|
201
217
|
var displayName: string;
|
|
202
218
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangeInput.d.ts","sourceRoot":"","sources":["../../src/DateRangeInput/DateRangeInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateRangeInput.d.ts","sourceRoot":"","sources":["../../src/DateRangeInput/DateRangeInput.tsx"],"names":[],"mappings":"AAqCA,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AAWjC,OAAO,EAGL,KAAK,WAAW,EAKjB,MAAM,UAAU,CAAC;AAIlB,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAOrB,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAU9C,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,+BAA+B,CAAC;AAUxE,YAAY,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,SAAS,CAAC;CAC3B;AAED,MA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