@astryxdesign/core 0.4.5 → 0.4.6-canary.cea9ecd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +134 -0
- package/dist/Avatar/Avatar.d.ts +10 -5
- package/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +139 -30
- package/dist/Avatar/AvatarStatusDot.d.ts +2 -1
- package/dist/Avatar/AvatarStatusDot.d.ts.map +1 -1
- package/dist/Avatar/AvatarStatusDot.js +30 -4
- package/dist/Avatar/AvatarStatusLabelContext.d.ts +39 -0
- package/dist/Avatar/AvatarStatusLabelContext.d.ts.map +1 -0
- package/dist/Avatar/AvatarStatusLabelContext.js +41 -0
- package/dist/AvatarGroup/AvatarGroup.d.ts +3 -1
- package/dist/AvatarGroup/AvatarGroup.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroupOverflow.d.ts.map +1 -1
- package/dist/AvatarGroup/AvatarGroupOverflow.js +15 -9
- package/dist/Blockquote/Blockquote.d.ts +4 -3
- package/dist/Blockquote/Blockquote.d.ts.map +1 -1
- package/dist/Blockquote/Blockquote.js +9 -10
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +21 -5
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +47 -34
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +7 -7
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +21 -12
- package/dist/Calendar/hooks/useCalendarNavigation.d.ts.map +1 -1
- package/dist/Calendar/hooks/useCalendarNavigation.js +8 -4
- package/dist/Calendar/styles.d.ts +2 -2
- package/dist/Calendar/styles.d.ts.map +1 -1
- package/dist/Calendar/styles.js +5 -5
- package/dist/Center/Center.d.ts +23 -1
- package/dist/Center/Center.d.ts.map +1 -1
- package/dist/Center/Center.js +12 -6
- package/dist/Chat/ChatComposer.d.ts.map +1 -1
- package/dist/Chat/ChatComposer.js +3 -3
- package/dist/Chat/ChatComposerDrawer.d.ts.map +1 -1
- package/dist/Chat/ChatComposerDrawer.js +2 -2
- package/dist/Chat/ChatToolCalls.d.ts.map +1 -1
- package/dist/Chat/ChatToolCalls.js +2 -2
- package/dist/Chat/useChatDictation.d.ts +1 -1
- package/dist/Chat/useChatDictation.d.ts.map +1 -1
- package/dist/Chat/useSpeechRecognition.d.ts +1 -1
- package/dist/Chat/useSpeechRecognition.d.ts.map +1 -1
- package/dist/Chat/useSpeechRecognition.js +4 -3
- package/dist/Chat/useTriggerMenu.d.ts.map +1 -1
- package/dist/Chat/useTriggerMenu.js +2 -2
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +2 -2
- package/dist/Citation/Citation.d.ts.map +1 -1
- package/dist/Citation/Citation.js +5 -5
- package/dist/ClickableCard/ClickableCard.d.ts.map +1 -1
- package/dist/ClickableCard/ClickableCard.js +4 -4
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +1 -1
- package/dist/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.js +2 -2
- package/dist/CommandPalette/CommandPaletteItem.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPaletteItem.js +3 -3
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +6 -6
- package/dist/DateInput/DateInput.d.ts +31 -2
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +90 -22
- package/dist/DateInput/MonthScroller.d.ts +35 -0
- package/dist/DateInput/MonthScroller.d.ts.map +1 -0
- package/dist/DateInput/MonthScroller.js +658 -0
- package/dist/DateInput/MonthYearWheels.d.ts +24 -0
- package/dist/DateInput/MonthYearWheels.d.ts.map +1 -0
- package/dist/DateInput/MonthYearWheels.js +114 -0
- package/dist/DateInput/TouchDateField.d.ts +10 -0
- package/dist/DateInput/TouchDateField.d.ts.map +1 -0
- package/dist/DateInput/TouchDateField.js +810 -0
- package/dist/DateInput/Wheel.d.ts +41 -0
- package/dist/DateInput/Wheel.d.ts.map +1 -0
- package/dist/DateInput/Wheel.js +315 -0
- package/dist/DateInput/monthGeometry.d.ts +65 -0
- package/dist/DateInput/monthGeometry.d.ts.map +1 -0
- package/dist/DateInput/monthGeometry.js +98 -0
- package/dist/DateInput/tokens.stylex.d.ts +63 -0
- package/dist/DateInput/tokens.stylex.d.ts.map +1 -0
- package/dist/DateInput/tokens.stylex.js +74 -0
- package/dist/DateInput/useOwnScrollGesture.d.ts +41 -0
- package/dist/DateInput/useOwnScrollGesture.d.ts.map +1 -0
- package/dist/DateInput/useOwnScrollGesture.js +202 -0
- package/dist/DateInput/usePointerDragScroll.d.ts +15 -0
- package/dist/DateInput/usePointerDragScroll.d.ts.map +1 -0
- package/dist/DateInput/usePointerDragScroll.js +216 -0
- package/dist/DateInput/useScrollSettle.d.ts +26 -0
- package/dist/DateInput/useScrollSettle.d.ts.map +1 -0
- package/dist/DateInput/useScrollSettle.js +149 -0
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +17 -14
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +17 -14
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +3 -3
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuCheckboxItem.js +2 -2
- package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuItem.js +2 -2
- package/dist/DropdownMenu/DropdownMenuRadioItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioItem.js +2 -2
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +2 -2
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +4 -4
- package/dist/Field/InputClearButton.d.ts.map +1 -1
- package/dist/Field/InputClearButton.js +6 -0
- package/dist/Field/inputStyles.stylex.d.ts +1 -1
- package/dist/Field/inputStyles.stylex.d.ts.map +1 -1
- package/dist/Field/inputStyles.stylex.js +5 -5
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +6 -6
- package/dist/HoverCard/HoverCard.d.ts +13 -3
- package/dist/HoverCard/HoverCard.d.ts.map +1 -1
- package/dist/HoverCard/HoverCard.js +2 -0
- package/dist/HoverCard/index.d.ts +1 -1
- package/dist/HoverCard/index.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.d.ts +17 -2
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +78 -9
- package/dist/InputGroup/InputGroup.js +1 -1
- package/dist/Item/Item.d.ts +9 -1
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +52 -14
- package/dist/Layer/index.d.ts +4 -2
- package/dist/Layer/index.d.ts.map +1 -1
- package/dist/Layer/index.js +2 -0
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +3 -2
- package/dist/Layer/useTouchTrigger.d.ts +113 -0
- package/dist/Layer/useTouchTrigger.d.ts.map +1 -0
- package/dist/Layer/useTouchTrigger.js +241 -0
- package/dist/Layout/container.stylex.d.ts +4 -2
- package/dist/Layout/container.stylex.d.ts.map +1 -1
- package/dist/Layout/container.stylex.js +19 -11
- package/dist/Layout/index.d.ts +1 -0
- package/dist/Layout/index.d.ts.map +1 -1
- package/dist/Layout/index.js +4 -0
- package/dist/Layout/padding.stylex.d.ts +315 -12
- package/dist/Layout/padding.stylex.d.ts.map +1 -1
- package/dist/Layout/padding.stylex.js +389 -12
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +5 -4
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +6 -6
- package/dist/MetadataList/MetadataList.d.ts.map +1 -1
- package/dist/MetadataList/MetadataList.js +1 -1
- package/dist/MobileNav/MobileNav.d.ts +1 -0
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +24 -6
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +8 -8
- package/dist/NavItem/navItemStyles.stylex.d.ts +4 -4
- package/dist/NavItem/navItemStyles.stylex.d.ts.map +1 -1
- package/dist/NavItem/navItemStyles.stylex.js +4 -4
- package/dist/NavMenu/NavHeadingMenuItem.d.ts.map +1 -1
- package/dist/NavMenu/NavHeadingMenuItem.js +3 -3
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +36 -8
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +3 -3
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +2 -2
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +11 -12
- package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchToken.js +3 -1
- package/dist/PowerSearch/formatFilterValue.d.ts +11 -2
- package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
- package/dist/PowerSearch/formatFilterValue.js +23 -8
- package/dist/RadioList/RadioListItem.d.ts +2 -2
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +70 -40
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +7 -7
- package/dist/Section/Section.d.ts +36 -1
- package/dist/Section/Section.d.ts.map +1 -1
- package/dist/Section/Section.js +12 -2
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +7 -2
- package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
- package/dist/SelectableCard/SelectableCard.js +3 -3
- package/dist/Selector/Selector.d.ts +26 -1
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +93 -20
- package/dist/Selector/SelectorOption.d.ts +14 -1
- package/dist/Selector/SelectorOption.d.ts.map +1 -1
- package/dist/Selector/SelectorOption.js +6 -0
- package/dist/Selector/SelectorRowLayoutContext.d.ts +8 -0
- package/dist/Selector/SelectorRowLayoutContext.d.ts.map +1 -0
- package/dist/Selector/SelectorRowLayoutContext.js +27 -0
- package/dist/Selector/types.d.ts +1 -0
- package/dist/Selector/types.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.js +4 -4
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +3 -3
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +7 -7
- package/dist/Stack/Stack.d.ts +23 -1
- package/dist/Stack/Stack.d.ts.map +1 -1
- package/dist/Stack/Stack.js +12 -6
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +2 -2
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +1 -1
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +3 -3
- package/dist/Table/TableRow.js +4 -4
- package/dist/Table/plugins/columnResize/useTableColumnResize.d.ts.map +1 -1
- package/dist/Table/plugins/columnResize/useTableColumnResize.js +1 -1
- package/dist/Table/plugins/filtering/useTableFiltering.d.ts.map +1 -1
- package/dist/Table/plugins/filtering/useTableFiltering.js +2 -2
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.d.ts.map +1 -1
- package/dist/Table/plugins/groupedRows/useTableGroupedRows.js +2 -2
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
- package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +2 -2
- package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortable.js +1 -1
- package/dist/Table/plugins/sortable/useTableSortableState.d.ts +5 -3
- package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortableState.js +12 -9
- package/dist/Table/plugins/tree/useTableTreeData.d.ts.map +1 -1
- package/dist/Table/plugins/tree/useTableTreeData.js +3 -3
- package/dist/TextArea/TextArea.js +1 -1
- package/dist/TextInput/TextInput.js +1 -1
- package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
- package/dist/Thumbnail/Thumbnail.js +3 -3
- package/dist/TimeInput/TimeInput.js +2 -2
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +6 -4
- package/dist/Timestamp/formatInstant.d.ts +3 -2
- package/dist/Timestamp/formatInstant.d.ts.map +1 -1
- package/dist/Timestamp/formatInstant.js +8 -8
- package/dist/Timestamp/tooltipEntries.d.ts +2 -1
- package/dist/Timestamp/tooltipEntries.d.ts.map +1 -1
- package/dist/Timestamp/tooltipEntries.js +5 -3
- package/dist/Toast/Toast.d.ts +4 -3
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +10 -7
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +6 -6
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +1 -1
- package/dist/Tooltip/Tooltip.d.ts +16 -3
- package/dist/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip/Tooltip.js +2 -0
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.d.ts +21 -2
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +71 -13
- package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
- package/dist/TopNav/TopNavHeading.js +4 -4
- package/dist/TopNav/TopNavItem.d.ts.map +1 -1
- package/dist/TopNav/TopNavItem.js +3 -3
- package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenu.js +2 -2
- package/dist/TopNav/TopNavMegaMenuItem.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenuItem.js +2 -2
- package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMenu.js +4 -4
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +7 -7
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +2 -2
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +1 -1
- package/dist/astryx.css +124 -62
- package/dist/hooks/containerReveal.stylex.d.ts.map +1 -1
- package/dist/hooks/containerReveal.stylex.js +18 -18
- package/dist/hooks/scrollbarGutter.d.ts +28 -0
- package/dist/hooks/scrollbarGutter.d.ts.map +1 -0
- package/dist/hooks/scrollbarGutter.js +103 -0
- package/dist/hooks/useAutoMediaMode.d.ts +31 -0
- package/dist/hooks/useAutoMediaMode.d.ts.map +1 -0
- package/dist/hooks/useAutoMediaMode.js +201 -0
- package/dist/hooks/useInputStatusIcon.d.ts.map +1 -1
- package/dist/hooks/useInputStatusIcon.js +1 -1
- package/dist/hooks/useListFocus.d.ts +5 -2
- package/dist/hooks/useListFocus.d.ts.map +1 -1
- package/dist/hooks/useListFocus.js +12 -6
- package/dist/hooks/useScrollLock.d.ts +4 -0
- package/dist/hooks/useScrollLock.d.ts.map +1 -1
- package/dist/hooks/useScrollLock.js +13 -1
- package/dist/i18n/InternationalizationContext.d.ts.map +1 -1
- package/dist/i18n/InternationalizationContext.js +2 -0
- package/dist/i18n/index.d.ts +6 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +6 -0
- package/dist/i18n/useCollator.d.ts +12 -0
- package/dist/i18n/useCollator.d.ts.map +1 -0
- package/dist/i18n/useCollator.js +40 -0
- package/dist/i18n/useLocale.d.ts +3 -0
- package/dist/i18n/useLocale.d.ts.map +1 -0
- package/dist/i18n/useLocale.js +31 -0
- package/dist/theme/MediaTheme.d.ts +25 -5
- package/dist/theme/MediaTheme.d.ts.map +1 -1
- package/dist/theme/MediaTheme.js +31 -6
- package/dist/theme/defineTheme.d.ts +5 -0
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/theme/defineTheme.js +5 -0
- package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
- package/dist/theme/derivedVarRegistry.js +7 -0
- package/dist/theme/generateThemeRules.d.ts.map +1 -1
- package/dist/theme/generateThemeRules.js +66 -5
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/syntax/index.d.ts +6 -0
- package/dist/theme/syntax/index.d.ts.map +1 -1
- package/dist/theme/syntax/index.js +7 -2
- package/dist/utils/dateParser.d.ts +4 -3
- package/dist/utils/dateParser.d.ts.map +1 -1
- package/dist/utils/dateParser.js +8 -8
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/plainDate.d.ts +5 -2
- package/dist/utils/plainDate.d.ts.map +1 -1
- package/dist/utils/plainDate.js +20 -4
- package/locales/en.json +28 -0
- package/locales/pseudo.json +21 -0
- package/package.json +3 -3
- package/src/Avatar/Avatar.doc.mjs +10 -6
- package/src/Avatar/Avatar.test.tsx +219 -1
- package/src/Avatar/Avatar.tsx +179 -37
- package/src/Avatar/AvatarStatusDot.tsx +30 -4
- package/src/Avatar/AvatarStatusLabelContext.ts +47 -0
- package/src/AvatarGroup/AvatarGroup.doc.mjs +10 -6
- package/src/AvatarGroup/AvatarGroup.test.tsx +62 -0
- package/src/AvatarGroup/AvatarGroup.tsx +3 -1
- package/src/AvatarGroup/AvatarGroupOverflow.tsx +31 -8
- package/src/Banner/Banner.doc.mjs +2 -0
- package/src/Blockquote/Blockquote.doc.mjs +30 -7
- package/src/Blockquote/Blockquote.test.tsx +34 -3
- package/src/Blockquote/Blockquote.tsx +11 -9
- package/src/BottomSheet/BottomSheet.doc.mjs +3 -3
- package/src/BottomSheet/BottomSheet.test.tsx +24 -0
- package/src/BottomSheet/BottomSheetPanel.test.tsx +91 -0
- package/src/BottomSheet/BottomSheetPanel.tsx +58 -3
- package/src/Breadcrumbs/BreadcrumbItem.tsx +36 -23
- package/src/Breadcrumbs/Breadcrumbs.doc.mjs +26 -2
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +31 -0
- package/src/Button/Button.tsx +12 -9
- package/src/Calendar/Calendar.tsx +15 -9
- package/src/Calendar/hooks/useCalendarNavigation.ts +6 -4
- package/src/Calendar/styles.ts +8 -5
- package/src/Center/Center.doc.mjs +48 -0
- package/src/Center/Center.test.tsx +158 -0
- package/src/Center/Center.tsx +50 -9
- package/src/Chat/ChatComposer.tsx +11 -5
- package/src/Chat/ChatComposerDrawer.tsx +4 -1
- package/src/Chat/ChatToolCalls.tsx +13 -4
- package/src/Chat/{useChatDictation.test.ts → useChatDictation.test.tsx} +29 -14
- package/src/Chat/useChatDictation.ts +1 -1
- package/src/Chat/useSpeechRecognition.ts +5 -3
- package/src/Chat/useTriggerMenu.tsx +4 -1
- package/src/CheckboxInput/CheckboxInput.tsx +5 -2
- package/src/Citation/Citation.test.tsx +6 -1
- package/src/Citation/Citation.tsx +11 -5
- package/src/ClickableCard/ClickableCard.tsx +7 -4
- package/src/CodeBlock/CodeBlock.tsx +4 -1
- package/src/Collapsible/Collapsible.tsx +5 -2
- package/src/CommandPalette/CommandPaletteItem.tsx +6 -3
- package/src/ComplexSelector/ComplexSelector.doc.mjs +10 -0
- package/src/ComplexSelector/ComplexSelector.tsx +14 -7
- package/src/DateInput/DateInput.test.tsx +17 -1
- package/src/DateInput/DateInput.tsx +93 -21
- package/src/DateInput/DateInputTouch.test.tsx +2582 -0
- package/src/DateInput/MonthScroller.tsx +878 -0
- package/src/DateInput/MonthYearWheels.tsx +147 -0
- package/src/DateInput/TouchDateField.tsx +1223 -0
- package/src/DateInput/Wheel.tsx +473 -0
- package/src/DateInput/monthGeometry.ts +118 -0
- package/src/DateInput/tokens.stylex.ts +99 -0
- package/src/DateInput/useOwnScrollGesture.ts +227 -0
- package/src/DateInput/usePointerDragScroll.ts +220 -0
- package/src/DateInput/useScrollSettle.ts +164 -0
- package/src/DateRangeInput/DateRangeInput.doc.mjs +1 -1
- package/src/DateRangeInput/DateRangeInput.tsx +31 -13
- package/src/DateTimeInput/DateTimeInput.tsx +25 -9
- package/src/Dialog/Dialog.test.tsx +24 -0
- package/src/Dialog/Dialog.tsx +3 -0
- package/src/DropdownMenu/DropdownMenuCheckboxItem.tsx +5 -2
- package/src/DropdownMenu/DropdownMenuItem.tsx +5 -2
- package/src/DropdownMenu/DropdownMenuRadioItem.tsx +5 -2
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +5 -2
- package/src/Field/Field.doc.mjs +2 -0
- package/src/Field/FieldLabel.tsx +9 -3
- package/src/Field/InputClearButton.test.tsx +110 -3
- package/src/Field/InputClearButton.tsx +38 -0
- package/src/Field/inputStyles.stylex.ts +17 -13
- package/src/FileInput/FileInput.tsx +15 -8
- package/src/FormLayout/FormLayout.doc.mjs +1 -1
- package/src/HoverCard/HoverCard.doc.mjs +18 -0
- package/src/HoverCard/HoverCard.test.tsx +189 -0
- package/src/HoverCard/HoverCard.tsx +22 -2
- package/src/HoverCard/index.ts +1 -0
- package/src/HoverCard/useHoverCard.doc.mjs +2 -0
- package/src/HoverCard/useHoverCard.tsx +103 -7
- package/src/InputGroup/InputGroup.tsx +1 -1
- package/src/Item/Item.doc.mjs +1 -0
- package/src/Item/Item.test.tsx +50 -0
- package/src/Item/Item.tsx +54 -6
- package/src/Layer/index.ts +10 -0
- package/src/Layer/useLayer.tsx +13 -2
- package/src/Layer/useTouchTrigger.test.ts +70 -0
- package/src/Layer/useTouchTrigger.ts +366 -0
- package/src/Layout/Layout.doc.mjs +18 -0
- package/src/Layout/container.stylex.ts +11 -3
- package/src/Layout/index.ts +4 -0
- package/src/Layout/overlayPaddingReset.test.tsx +222 -0
- package/src/Layout/padding.stylex.ts +192 -12
- package/src/Lightbox/Lightbox.tsx +11 -3
- package/src/Link/Link.tsx +9 -6
- package/src/MetadataList/MetadataList.tsx +4 -1
- package/src/MobileNav/MobileNav.tsx +61 -5
- package/src/MobileNav/MobileNavEntryAnimation.test.tsx +212 -0
- package/src/MobileNav/MobileNavScrollbarGutter.test.tsx +109 -0
- package/src/MultiSelector/MultiSelector.test.tsx +1 -1
- package/src/MultiSelector/MultiSelector.tsx +26 -10
- package/src/NavItem/navItemStyles.stylex.ts +7 -4
- package/src/NavMenu/NavHeadingMenuItem.tsx +6 -3
- package/src/NumberInput/NumberInput.doc.mjs +24 -0
- package/src/NumberInput/NumberInput.test.tsx +138 -0
- package/src/NumberInput/NumberInput.tsx +47 -8
- package/src/Outline/Outline.tsx +5 -2
- package/src/Pagination/Pagination.tsx +5 -2
- package/src/Popover/Popover.test.tsx +27 -1
- package/src/PowerSearch/PowerSearch.tsx +17 -8
- package/src/PowerSearch/PowerSearchToken.tsx +3 -0
- package/src/PowerSearch/formatFilterValue.test.ts +22 -2
- package/src/PowerSearch/formatFilterValue.ts +31 -6
- package/src/RadioList/RadioList.doc.mjs +1 -1
- package/src/RadioList/RadioList.test.tsx +170 -2
- package/src/RadioList/RadioListItem.tsx +88 -53
- package/src/Resizable/ResizeHandle.test.tsx +22 -0
- package/src/Resizable/ResizeHandle.tsx +25 -7
- package/src/Section/Section.doc.mjs +55 -0
- package/src/Section/Section.test.tsx +201 -4
- package/src/Section/Section.tsx +69 -0
- package/src/SegmentedControl/SegmentedControl.test.tsx +31 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +15 -3
- package/src/SelectableCard/SelectableCard.tsx +6 -3
- package/src/Selector/Selector.doc.mjs +16 -2
- package/src/Selector/Selector.test.tsx +525 -1
- package/src/Selector/Selector.tsx +180 -25
- package/src/Selector/SelectorOption.doc.mjs +7 -0
- package/src/Selector/SelectorOption.tsx +21 -0
- package/src/Selector/SelectorRowLayoutContext.ts +32 -0
- package/src/Selector/types.ts +4 -4
- package/src/SideNav/SideNavHeading.tsx +14 -5
- package/src/SideNav/SideNavItem.tsx +9 -3
- package/src/Slider/Slider.tsx +25 -6
- package/src/Stack/Stack.doc.mjs +72 -0
- package/src/Stack/Stack.test.tsx +156 -0
- package/src/Stack/Stack.tsx +50 -8
- package/src/Switch/Switch.tsx +5 -2
- package/src/TabList/Tab.tsx +4 -1
- package/src/TabList/TabMenu.tsx +9 -3
- package/src/Table/TableRow.tsx +4 -4
- package/src/Table/plugins/columnResize/useTableColumnResize.tsx +6 -2
- package/src/Table/plugins/filtering/useTableFiltering.tsx +4 -1
- package/src/Table/plugins/groupedRows/useTableGroupedRows.tsx +10 -3
- package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +6 -3
- package/src/Table/plugins/sortable/useTableSortable.tsx +4 -1
- package/src/Table/plugins/sortable/useTableSortableState.test.tsx +34 -0
- package/src/Table/plugins/sortable/useTableSortableState.tsx +26 -23
- package/src/Table/plugins/tree/useTableTreeData.tsx +10 -4
- package/src/TextArea/TextArea.doc.mjs +1 -1
- package/src/TextArea/TextArea.tsx +1 -1
- package/src/TextInput/TextInput.tsx +1 -1
- package/src/Thumbnail/Thumbnail.tsx +9 -3
- package/src/TimeInput/TimeInput.tsx +1 -1
- package/src/Timestamp/Timestamp.test.tsx +27 -7
- package/src/Timestamp/Timestamp.tsx +8 -4
- package/src/Timestamp/formatInstant.ts +9 -7
- package/src/Timestamp/tooltipEntries.test.ts +11 -6
- package/src/Timestamp/tooltipEntries.ts +6 -2
- package/src/Toast/Toast.tsx +9 -7
- package/src/Token/Token.tsx +14 -5
- package/src/Tokenizer/Tokenizer.tsx +4 -1
- package/src/Tooltip/Tooltip.doc.mjs +18 -0
- package/src/Tooltip/Tooltip.test.tsx +254 -1
- package/src/Tooltip/Tooltip.tsx +22 -2
- package/src/Tooltip/index.ts +1 -0
- package/src/Tooltip/useTooltip.doc.mjs +2 -0
- package/src/Tooltip/useTooltip.tsx +99 -21
- package/src/TopNav/TopNavHeading.tsx +13 -4
- package/src/TopNav/TopNavItem.tsx +6 -3
- package/src/TopNav/TopNavMegaMenu.tsx +5 -2
- package/src/TopNav/TopNavMegaMenuItem.tsx +5 -2
- package/src/TopNav/TopNavMenu.tsx +10 -4
- package/src/TreeList/TreeListItem.tsx +22 -7
- package/src/Typeahead/BaseTypeahead.tsx +5 -2
- package/src/Typeahead/Typeahead.tsx +4 -1
- package/src/hooks/containerReveal.stylex.ts +54 -18
- package/src/hooks/scrollbarGutter.test.ts +167 -0
- package/src/hooks/scrollbarGutter.ts +121 -0
- package/src/hooks/useAutoMediaMode.test.ts +109 -0
- package/src/hooks/useAutoMediaMode.ts +233 -0
- package/src/hooks/useInputStatusIcon.tsx +4 -1
- package/src/hooks/useListFocus.doc.mjs +2 -2
- package/src/hooks/useListFocus.test.tsx +65 -3
- package/src/hooks/useListFocus.ts +15 -7
- package/src/hooks/useScrollLock.doc.mjs +4 -4
- package/src/hooks/useScrollLock.test.ts +73 -0
- package/src/hooks/useScrollLock.ts +14 -0
- package/src/i18n/InternationalizationContext.ts +2 -0
- package/src/i18n/__tests__/e2e-powersearch.test.tsx +37 -1
- package/src/i18n/__tests__/useCollator.test.tsx +115 -0
- package/src/i18n/__tests__/useLocale.test.tsx +52 -0
- package/src/i18n/index.ts +6 -0
- package/src/i18n/useCollator.doc.mjs +84 -0
- package/src/i18n/useCollator.ts +44 -0
- package/src/i18n/useLocale.doc.mjs +70 -0
- package/src/i18n/useLocale.ts +34 -0
- package/src/i18n/useTranslator.doc.mjs +1 -1
- package/src/reset.css +9 -2
- package/src/reset.test.ts +22 -0
- package/src/theme/MediaTheme.doc.mjs +23 -4
- package/src/theme/MediaTheme.dom.test.tsx +97 -0
- package/src/theme/MediaTheme.tsx +42 -7
- package/src/theme/defineTheme.test.ts +9 -3
- package/src/theme/defineTheme.ts +5 -0
- package/src/theme/derivedVarRegistry.test.ts +19 -5
- package/src/theme/derivedVarRegistry.ts +4 -0
- package/src/theme/generateThemeRules.test.ts +118 -0
- package/src/theme/generateThemeRules.ts +83 -5
- package/src/theme/index.ts +1 -1
- package/src/theme/syntax/index.ts +6 -2
- package/src/theme/syntax/serverSafeSyntax.test.ts +68 -0
- package/src/utils/dateParser.test.ts +20 -0
- package/src/utils/dateParser.ts +14 -7
- package/src/utils/index.ts +2 -0
- package/src/utils/plainDate.test.ts +6 -0
- package/src/utils/plainDate.ts +21 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface WheelOption {
|
|
2
|
+
/** Stable numeric identity of the row (a month 1-12, or a year). */
|
|
3
|
+
value: number;
|
|
4
|
+
/** Row text. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Rows outside min/max stay visible but cannot be committed. */
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface WheelProps {
|
|
10
|
+
/** Accessible name for the column, e.g. "Month". */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Rows, top to bottom. */
|
|
13
|
+
options: ReadonlyArray<WheelOption>;
|
|
14
|
+
/** Committed value; must match one option's `value`. */
|
|
15
|
+
value: number;
|
|
16
|
+
/** Fired when the wheel comes to rest on a different, enabled row. */
|
|
17
|
+
onChange: (value: number) => void;
|
|
18
|
+
/**
|
|
19
|
+
* False while the wheel is hidden — scroll offsets of a display:none
|
|
20
|
+
* scroller are meaningless, so listeners and the initial scroll wait.
|
|
21
|
+
*/
|
|
22
|
+
isActive?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* One snap-scrolling picker column.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```
|
|
29
|
+
* <Wheel
|
|
30
|
+
* label="Month"
|
|
31
|
+
* options={monthOptions}
|
|
32
|
+
* value={month}
|
|
33
|
+
* onChange={setMonth}
|
|
34
|
+
* />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function Wheel({ label, options, value, onChange, isActive, }: WheelProps): import("react").JSX.Element;
|
|
38
|
+
export declare namespace Wheel {
|
|
39
|
+
var displayName: string;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=Wheel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wheel.d.ts","sourceRoot":"","sources":["../../src/DateInput/Wheel.tsx"],"names":[],"mappings":"AA0MA,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACpC,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAe,GAChB,EAAE,UAAU,+BAgOZ;yBAtOe,KAAK"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file Wheel.tsx
|
|
7
|
+
* @input Option list, selected value, change callback
|
|
8
|
+
* @output Exports Wheel — a snap-scrolling picker column
|
|
9
|
+
* @position Internal component; consumed by MonthYearWheels.tsx
|
|
10
|
+
*
|
|
11
|
+
* A wheel is a scroll container, not a custom gesture surface. Momentum,
|
|
12
|
+
* rubber-banding, and the settle animation are the platform's; all this adds
|
|
13
|
+
* is `scroll-snap-align: center` on each option, half a viewport of padding at
|
|
14
|
+
* each end so the first and last option can reach the middle, and a commit
|
|
15
|
+
* when the scrolling stops.
|
|
16
|
+
*
|
|
17
|
+
* The falloff (rows fading and tipping away from the centre) is a CSS
|
|
18
|
+
* scroll-driven animation on a `view()` timeline — the browser interpolates it
|
|
19
|
+
* against each row's own position in the scrollport, so it stays glued to the
|
|
20
|
+
* finger with no JS in the frame loop. It is guarded by `@supports`, because a
|
|
21
|
+
* browser that does not understand `animation-timeline` would otherwise run
|
|
22
|
+
* the same keyframes on the document timeline and simply play them once.
|
|
23
|
+
*
|
|
24
|
+
* Accessibility: this is a listbox, not a novel widget. It is one tab stop
|
|
25
|
+
* with arrow/Home/End/PageUp/PageDown keys, `aria-activedescendant` tracking
|
|
26
|
+
* the active row, and every row reachable by tap — none of which depends on
|
|
27
|
+
* the scroll-driven decoration.
|
|
28
|
+
*
|
|
29
|
+
* SYNC: When modified, update:
|
|
30
|
+
* - /packages/core/src/DateInput/TouchDateField.tsx
|
|
31
|
+
* - /packages/core/src/DateInput/DateInput.doc.mjs
|
|
32
|
+
* - /packages/core/src/DateInput/DateInputTouch.test.tsx
|
|
33
|
+
*/
|
|
34
|
+
import { useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
35
|
+
import * as stylex from '@stylexjs/stylex';
|
|
36
|
+
import "../theme/tokens.stylex.js";
|
|
37
|
+
import { colorVars, radiusVars, fontWeightVars, typeScaleVars, spacingVars, durationVars } from "../theme/tokens.stylex.js";
|
|
38
|
+
import { focusOutlineStyles } from "../utils/index.js";
|
|
39
|
+
import "./tokens.stylex.js";
|
|
40
|
+
import { dateInputTouchSizes, dateInputTouchGeometry } from "./tokens.stylex.js";
|
|
41
|
+
import { useOwnScrollGesture } from "./useOwnScrollGesture.js";
|
|
42
|
+
import { usePointerDragScroll } from "./usePointerDragScroll.js";
|
|
43
|
+
import { useScrollSettle } from "./useScrollSettle.js";
|
|
44
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
45
|
+
const ITEM_BLOCK_SIZE = dateInputTouchSizes.wheelItemSize;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Rows tip away from the centre of the wheel. 0% is a row just entering at the
|
|
49
|
+
* bottom of the scrollport, 50% is a row centred in it, 100% is a row leaving
|
|
50
|
+
* at the top — which is what a `view()` timeline over the `cover` range means,
|
|
51
|
+
* and why this reads as a cylinder rotating under the finger.
|
|
52
|
+
*/
|
|
53
|
+
const falloff = "x1tut0r7-B";
|
|
54
|
+
|
|
55
|
+
/** Motion-free equivalent: the depth cue survives as opacity alone. */
|
|
56
|
+
const fadeOnly = "xuvekqa-B";
|
|
57
|
+
const styles = {
|
|
58
|
+
scroller: {
|
|
59
|
+
kZKoxP: "xm8gem",
|
|
60
|
+
kB7OPa: "x9f619",
|
|
61
|
+
kORKVm: "x1odjw0f",
|
|
62
|
+
kXHlph: "x6ikm8r",
|
|
63
|
+
kc424l: "x168l2et",
|
|
64
|
+
kZeWKH: "xish69e",
|
|
65
|
+
k8WAf4: "x1uameg1",
|
|
66
|
+
kwFjlL: "x201tam",
|
|
67
|
+
kmaZ5I: "x1oyok0e",
|
|
68
|
+
k5wCbM: "x1rohswg",
|
|
69
|
+
kI3sdo: "x1a2a7pz",
|
|
70
|
+
kFalU9: "xx69xxh",
|
|
71
|
+
$$css: true
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* One snap-scrolling picker column.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```
|
|
79
|
+
* <Wheel
|
|
80
|
+
* label="Month"
|
|
81
|
+
* options={monthOptions}
|
|
82
|
+
* value={month}
|
|
83
|
+
* onChange={setMonth}
|
|
84
|
+
* />
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function Wheel({
|
|
88
|
+
label,
|
|
89
|
+
options,
|
|
90
|
+
value,
|
|
91
|
+
onChange,
|
|
92
|
+
isActive = true
|
|
93
|
+
}) {
|
|
94
|
+
const id = useId();
|
|
95
|
+
const scrollerRef = useRef(null);
|
|
96
|
+
const selectedIndex = Math.max(0, options.findIndex(option => option.value === value));
|
|
97
|
+
// Which row is under the band right now. Tracks the finger during a scroll;
|
|
98
|
+
// `selectedIndex` only catches up when the wheel settles.
|
|
99
|
+
const [activeIndex, setActiveIndex] = useState(selectedIndex);
|
|
100
|
+
|
|
101
|
+
// Row height in px, read from layout rather than assumed, so a theme that
|
|
102
|
+
// retunes --date-input-touch-wheel-item-size still lands on the right row.
|
|
103
|
+
const itemBlockSize = useCallback(() => {
|
|
104
|
+
const first = scrollerRef.current?.firstElementChild;
|
|
105
|
+
return first instanceof HTMLElement && first.offsetHeight > 0 ? first.offsetHeight : 0;
|
|
106
|
+
}, []);
|
|
107
|
+
const scrollToIndex = useCallback((index, behavior) => {
|
|
108
|
+
const scroller = scrollerRef.current;
|
|
109
|
+
const size = itemBlockSize();
|
|
110
|
+
if (scroller == null || size === 0) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
scroller.scrollTo({
|
|
114
|
+
top: index * size,
|
|
115
|
+
behavior
|
|
116
|
+
});
|
|
117
|
+
}, [itemBlockSize]);
|
|
118
|
+
|
|
119
|
+
// Commit on rest. A disabled row is bounced back to the committed one
|
|
120
|
+
// rather than silently keeping a value the wheel is not showing.
|
|
121
|
+
//
|
|
122
|
+
// Declared here, above the park effect, because that effect consults the
|
|
123
|
+
// `isAtRestRef` this returns before it repositions anything.
|
|
124
|
+
const {
|
|
125
|
+
isAtRestRef
|
|
126
|
+
} = useScrollSettle(scrollerRef, scroller => {
|
|
127
|
+
const size = itemBlockSize();
|
|
128
|
+
if (size === 0) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const index = Math.min(options.length - 1, Math.max(0, Math.round(scroller.scrollTop / size)));
|
|
132
|
+
const option = options[index];
|
|
133
|
+
if (option == null || option.isDisabled) {
|
|
134
|
+
scrollToIndex(selectedIndex, 'smooth');
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (option.value !== value) {
|
|
138
|
+
onChange(option.value);
|
|
139
|
+
}
|
|
140
|
+
}, isActive);
|
|
141
|
+
|
|
142
|
+
// Park the committed row under the band whenever the wheel is shown, or the
|
|
143
|
+
// value is changed from outside (the calendar scrolled to another month).
|
|
144
|
+
//
|
|
145
|
+
// NEVER while the wheel is still moving. A scroller that is mid-gesture or
|
|
146
|
+
// still carrying momentum is the user's, and repositioning it does not stop
|
|
147
|
+
// the momentum — on iOS it feeds a cycle where the scroll this causes reads
|
|
148
|
+
// as a new settle, commits the next row along, and parks again. See
|
|
149
|
+
// useScrollSettle. The settle handler re-checks the position afterwards, so
|
|
150
|
+
// a correction that is genuinely needed still happens, just at rest.
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (!isActive || !isAtRestRef.current) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const size = itemBlockSize();
|
|
156
|
+
const scroller = scrollerRef.current;
|
|
157
|
+
if (scroller == null || size === 0) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (Math.round(scroller.scrollTop / size) !== selectedIndex) {
|
|
161
|
+
scroller.scrollTo({
|
|
162
|
+
top: selectedIndex * size,
|
|
163
|
+
behavior: 'auto'
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
// eslint-disable-next-line @eslint-react/set-state-in-effect -- the highlight follows a scroll position, which only exists after layout
|
|
167
|
+
setActiveIndex(selectedIndex);
|
|
168
|
+
}, [isActive, selectedIndex, itemBlockSize, isAtRestRef]);
|
|
169
|
+
|
|
170
|
+
// Highlight follows the finger. rAF-throttled: a scroll can fire far more
|
|
171
|
+
// often than the display refreshes, and this only feeds a repaint.
|
|
172
|
+
const frameRef = useRef(undefined);
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
const scroller = scrollerRef.current;
|
|
175
|
+
if (scroller == null || !isActive) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const onScroll = () => {
|
|
179
|
+
if (frameRef.current != null) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
frameRef.current = requestAnimationFrame(() => {
|
|
183
|
+
frameRef.current = undefined;
|
|
184
|
+
const size = itemBlockSize();
|
|
185
|
+
if (size === 0) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const index = Math.min(options.length - 1, Math.max(0, Math.round(scroller.scrollTop / size)));
|
|
189
|
+
setActiveIndex(index);
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
scroller.addEventListener('scroll', onScroll, {
|
|
193
|
+
passive: true
|
|
194
|
+
});
|
|
195
|
+
return () => {
|
|
196
|
+
scroller.removeEventListener('scroll', onScroll);
|
|
197
|
+
if (frameRef.current != null) {
|
|
198
|
+
cancelAnimationFrame(frameRef.current);
|
|
199
|
+
frameRef.current = undefined;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}, [isActive, options.length, itemBlockSize]);
|
|
203
|
+
|
|
204
|
+
// Keep the finger. Inside a BottomSheet the sheet would otherwise read a
|
|
205
|
+
// downward drag here as swipe-to-dismiss; see useOwnScrollGesture. Gated on
|
|
206
|
+
// isActive because the hidden panel keeps its layout box.
|
|
207
|
+
// 'all': a wheel scrolls vertically, the same axis the sheet wants, so
|
|
208
|
+
// there is no way to share — it takes every touch that lands on it.
|
|
209
|
+
useOwnScrollGesture(scrollerRef, 'all', {
|
|
210
|
+
isEnabled: isActive
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// A mouse cannot drag a scroll container, so without this the wheel ignores
|
|
214
|
+
// the one gesture its shape invites. Touch is untouched — it pans natively,
|
|
215
|
+
// with momentum this could not match. See usePointerDragScroll.
|
|
216
|
+
usePointerDragScroll(scrollerRef, isActive);
|
|
217
|
+
const moveBy = useCallback(delta => {
|
|
218
|
+
const next = Math.min(options.length - 1, Math.max(0, activeIndex + delta));
|
|
219
|
+
const option = options[next];
|
|
220
|
+
if (option == null || option.isDisabled) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
setActiveIndex(next);
|
|
224
|
+
scrollToIndex(next, 'smooth');
|
|
225
|
+
if (option.value !== value) {
|
|
226
|
+
onChange(option.value);
|
|
227
|
+
}
|
|
228
|
+
}, [activeIndex, options, scrollToIndex, value, onChange]);
|
|
229
|
+
const handleKeyDown = useCallback(event => {
|
|
230
|
+
switch (event.key) {
|
|
231
|
+
case 'ArrowDown':
|
|
232
|
+
event.preventDefault();
|
|
233
|
+
moveBy(1);
|
|
234
|
+
break;
|
|
235
|
+
case 'ArrowUp':
|
|
236
|
+
event.preventDefault();
|
|
237
|
+
moveBy(-1);
|
|
238
|
+
break;
|
|
239
|
+
case 'PageDown':
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
moveBy(10);
|
|
242
|
+
break;
|
|
243
|
+
case 'PageUp':
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
moveBy(-10);
|
|
246
|
+
break;
|
|
247
|
+
case 'Home':
|
|
248
|
+
event.preventDefault();
|
|
249
|
+
moveBy(-activeIndex);
|
|
250
|
+
break;
|
|
251
|
+
case 'End':
|
|
252
|
+
event.preventDefault();
|
|
253
|
+
moveBy(options.length - 1 - activeIndex);
|
|
254
|
+
break;
|
|
255
|
+
default:
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
}, [moveBy, activeIndex, options.length]);
|
|
259
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
260
|
+
...{
|
|
261
|
+
className: "x1n2onr6 x1cqoux5 xeuugli"
|
|
262
|
+
},
|
|
263
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
264
|
+
"aria-hidden": "true",
|
|
265
|
+
...{
|
|
266
|
+
className: "x10l6tqk x17y0mx6 x7rbydg x6hpsvf xh6dtrn x17x4s8c x47corl"
|
|
267
|
+
}
|
|
268
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
269
|
+
ref: scrollerRef,
|
|
270
|
+
role: "listbox",
|
|
271
|
+
"aria-label": label,
|
|
272
|
+
"aria-activedescendant": `${id}-${options[activeIndex]?.value}`,
|
|
273
|
+
tabIndex: 0,
|
|
274
|
+
onKeyDown: handleKeyDown,
|
|
275
|
+
...stylex.props(styles.scroller, focusOutlineStyles.focusVisible),
|
|
276
|
+
children: options.map((option, index) => /*#__PURE__*/_jsx("div", {
|
|
277
|
+
id: `${id}-${option.value}`,
|
|
278
|
+
role: "option",
|
|
279
|
+
"aria-selected": option.value === value,
|
|
280
|
+
"aria-disabled": option.isDisabled || undefined,
|
|
281
|
+
onClick: () => {
|
|
282
|
+
if (option.isDisabled) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
setActiveIndex(index);
|
|
286
|
+
scrollToIndex(index, 'smooth');
|
|
287
|
+
if (option.value !== value) {
|
|
288
|
+
onChange(option.value);
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
...{
|
|
292
|
+
0: {
|
|
293
|
+
className: "x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla x1tgivj0 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6"
|
|
294
|
+
},
|
|
295
|
+
2: {
|
|
296
|
+
className: "x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 xuxw1ft x1ypdohk x16khyan x87ps6o x1jbe559 xuedmi6 xjse4m1 x2mo6ok"
|
|
297
|
+
},
|
|
298
|
+
1: {
|
|
299
|
+
className: "x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 x1sodnla xuxw1ft x87ps6o x1jbe559 xuedmi6 xnbbluu xt0e3qv"
|
|
300
|
+
},
|
|
301
|
+
3: {
|
|
302
|
+
className: "x78zum5 x6s0dn4 xl56j7k x6hpsvf xf314gf x1hdbdi8 xc342km xng3xce xjbqb8w x18juvz8 xuxw1ft x87ps6o x1jbe559 xuedmi6 x2mo6ok xnbbluu xt0e3qv"
|
|
303
|
+
}
|
|
304
|
+
}[!!(index === activeIndex) << 1 | !!option.isDisabled << 0],
|
|
305
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
306
|
+
...{
|
|
307
|
+
className: "x78zum5 x6s0dn4 xl56j7k xh8yej3 x5yr21d xb3r6kr xlyipyv x1iu2jvn xk3h8ob x190lv1 xg8s4dl x1u6ievf xwms9i0 x1esw782 xlp1x4z"
|
|
308
|
+
},
|
|
309
|
+
children: option.label
|
|
310
|
+
})
|
|
311
|
+
}, option.value))
|
|
312
|
+
})]
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
Wheel.displayName = 'Wheel';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file monthGeometry.ts
|
|
3
|
+
* @input PlainDate values, scroll offsets, pane heights
|
|
4
|
+
* @output Pure month-index arithmetic and the virtualized pane window
|
|
5
|
+
* @position Internal helper; consumed by MonthScroller.tsx and DateInput.tsx
|
|
6
|
+
*
|
|
7
|
+
* A "month index" is a single integer that totally orders calendar months:
|
|
8
|
+
* `year * 12 + (month - 1)`. The scroller is a list of equal-width panes, so
|
|
9
|
+
* one integer converts freely between a month, a row in that list, and a
|
|
10
|
+
* scroll offset — which is the whole trick behind continuous scrolling.
|
|
11
|
+
*
|
|
12
|
+
* These are pure functions on purpose: the scroll math is the part most likely
|
|
13
|
+
* to be wrong, and it is testable without a layout engine.
|
|
14
|
+
*
|
|
15
|
+
* SYNC: When modified, update DateInputTouch.test.tsx.
|
|
16
|
+
*/
|
|
17
|
+
import type { PlainDate } from '../utils';
|
|
18
|
+
/** How many months are reachable in either direction when unbounded. */
|
|
19
|
+
export declare const DEFAULT_MONTH_REACH = 600;
|
|
20
|
+
/** `year * 12 + (month - 1)`, for a 1-based month. */
|
|
21
|
+
export declare function toMonthIndex(year: number, month: number): number;
|
|
22
|
+
/** The month index of a PlainDate. */
|
|
23
|
+
export declare function monthIndexOf(date: PlainDate): number;
|
|
24
|
+
/** Inverse of {@link toMonthIndex}; month comes back 1-based. */
|
|
25
|
+
export declare function fromMonthIndex(index: number): {
|
|
26
|
+
year: number;
|
|
27
|
+
month: number;
|
|
28
|
+
};
|
|
29
|
+
/** `value` limited to `[min, max]`. */
|
|
30
|
+
export declare function clampIndex(value: number, min: number, max: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* The month a scrollport is resting on (or nearest to, mid-scroll).
|
|
33
|
+
*
|
|
34
|
+
* Returns a row offset from the start of the list, not a month index — add
|
|
35
|
+
* `minMonthIndex` for that.
|
|
36
|
+
*
|
|
37
|
+
* `scrollOffset` is `scrollLeft` for the horizontal scroller. Under RTL that
|
|
38
|
+
* is NEGATIVE — the spec has the inline start at 0 and scrolling run down
|
|
39
|
+
* from there — so the sign is normalized away here rather than at each call
|
|
40
|
+
* site, where forgetting it would silently pin the calendar to month zero.
|
|
41
|
+
*/
|
|
42
|
+
export declare function rowAtScrollOffset(scrollOffset: number, paneSize: number, rowCount: number, isRTL?: boolean): number;
|
|
43
|
+
/**
|
|
44
|
+
* The scroll offset that brings `row` to rest, ready for `scrollTo`. The
|
|
45
|
+
* inverse of {@link rowAtScrollOffset}, including its RTL sign.
|
|
46
|
+
*/
|
|
47
|
+
export declare function scrollOffsetForRow(row: number, paneSize: number, isRTL?: boolean): number;
|
|
48
|
+
export interface PaneWindow {
|
|
49
|
+
/** First rendered row, inclusive. */
|
|
50
|
+
start: number;
|
|
51
|
+
/** Last rendered row, inclusive. */
|
|
52
|
+
end: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The slice of rows to actually mount around `centerRow`.
|
|
56
|
+
*
|
|
57
|
+
* Only a handful of panes exist in the DOM at a time; the rest of the list is
|
|
58
|
+
* a spacer. `overscan` is how many extra panes ride along on each side so a
|
|
59
|
+
* fast fling never lands on an unmounted one — which under `scroll-snap-type:
|
|
60
|
+
* mandatory` would be visible as a jump.
|
|
61
|
+
*/
|
|
62
|
+
export declare function paneWindow(centerRow: number, rowCount: number, overscan: number): PaneWindow;
|
|
63
|
+
/** `[start, end]` inclusive, as an array of rows. */
|
|
64
|
+
export declare function rowsIn({ start, end }: PaneWindow): number[];
|
|
65
|
+
//# sourceMappingURL=monthGeometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monthGeometry.d.ts","sourceRoot":"","sources":["../../src/DateInput/monthGeometry.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AAExC,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,sCAAsC;AACtC,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAEpD;AAED,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAK3E;AAED,uCAAuC;AACvC,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,OAAe,GACrB,MAAM,CAMR;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,OAAe,GACrB,MAAM,CAGR;AAED,MAAM,WAAW,UAAU;IACzB,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,UAAU,CAKZ;AAED,qDAAqD;AACrD,wBAAgB,MAAM,CAAC,EAAC,KAAK,EAAE,GAAG,EAAC,EAAE,UAAU,GAAG,MAAM,EAAE,CAMzD"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file monthGeometry.ts
|
|
5
|
+
* @input PlainDate values, scroll offsets, pane heights
|
|
6
|
+
* @output Pure month-index arithmetic and the virtualized pane window
|
|
7
|
+
* @position Internal helper; consumed by MonthScroller.tsx and DateInput.tsx
|
|
8
|
+
*
|
|
9
|
+
* A "month index" is a single integer that totally orders calendar months:
|
|
10
|
+
* `year * 12 + (month - 1)`. The scroller is a list of equal-width panes, so
|
|
11
|
+
* one integer converts freely between a month, a row in that list, and a
|
|
12
|
+
* scroll offset — which is the whole trick behind continuous scrolling.
|
|
13
|
+
*
|
|
14
|
+
* These are pure functions on purpose: the scroll math is the part most likely
|
|
15
|
+
* to be wrong, and it is testable without a layout engine.
|
|
16
|
+
*
|
|
17
|
+
* SYNC: When modified, update DateInputTouch.test.tsx.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** How many months are reachable in either direction when unbounded. */
|
|
21
|
+
export const DEFAULT_MONTH_REACH = 600;
|
|
22
|
+
|
|
23
|
+
/** `year * 12 + (month - 1)`, for a 1-based month. */
|
|
24
|
+
export function toMonthIndex(year, month) {
|
|
25
|
+
return year * 12 + (month - 1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The month index of a PlainDate. */
|
|
29
|
+
export function monthIndexOf(date) {
|
|
30
|
+
return toMonthIndex(date.year, date.month);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Inverse of {@link toMonthIndex}; month comes back 1-based. */
|
|
34
|
+
export function fromMonthIndex(index) {
|
|
35
|
+
return {
|
|
36
|
+
year: Math.floor(index / 12),
|
|
37
|
+
month: (index % 12 + 12) % 12 + 1
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** `value` limited to `[min, max]`. */
|
|
42
|
+
export function clampIndex(value, min, max) {
|
|
43
|
+
return Math.min(Math.max(value, min), max);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The month a scrollport is resting on (or nearest to, mid-scroll).
|
|
48
|
+
*
|
|
49
|
+
* Returns a row offset from the start of the list, not a month index — add
|
|
50
|
+
* `minMonthIndex` for that.
|
|
51
|
+
*
|
|
52
|
+
* `scrollOffset` is `scrollLeft` for the horizontal scroller. Under RTL that
|
|
53
|
+
* is NEGATIVE — the spec has the inline start at 0 and scrolling run down
|
|
54
|
+
* from there — so the sign is normalized away here rather than at each call
|
|
55
|
+
* site, where forgetting it would silently pin the calendar to month zero.
|
|
56
|
+
*/
|
|
57
|
+
export function rowAtScrollOffset(scrollOffset, paneSize, rowCount, isRTL = false) {
|
|
58
|
+
if (paneSize <= 0) {
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
const distance = isRTL ? -scrollOffset : scrollOffset;
|
|
62
|
+
return clampIndex(Math.round(distance / paneSize), 0, rowCount - 1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The scroll offset that brings `row` to rest, ready for `scrollTo`. The
|
|
67
|
+
* inverse of {@link rowAtScrollOffset}, including its RTL sign.
|
|
68
|
+
*/
|
|
69
|
+
export function scrollOffsetForRow(row, paneSize, isRTL = false) {
|
|
70
|
+
const distance = row * paneSize;
|
|
71
|
+
return isRTL ? -distance : distance;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The slice of rows to actually mount around `centerRow`.
|
|
75
|
+
*
|
|
76
|
+
* Only a handful of panes exist in the DOM at a time; the rest of the list is
|
|
77
|
+
* a spacer. `overscan` is how many extra panes ride along on each side so a
|
|
78
|
+
* fast fling never lands on an unmounted one — which under `scroll-snap-type:
|
|
79
|
+
* mandatory` would be visible as a jump.
|
|
80
|
+
*/
|
|
81
|
+
export function paneWindow(centerRow, rowCount, overscan) {
|
|
82
|
+
return {
|
|
83
|
+
start: Math.max(0, centerRow - overscan),
|
|
84
|
+
end: Math.min(rowCount - 1, centerRow + overscan)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** `[start, end]` inclusive, as an array of rows. */
|
|
89
|
+
export function rowsIn({
|
|
90
|
+
start,
|
|
91
|
+
end
|
|
92
|
+
}) {
|
|
93
|
+
const rows = [];
|
|
94
|
+
for (let row = start; row <= end; row++) {
|
|
95
|
+
rows.push(row);
|
|
96
|
+
}
|
|
97
|
+
return rows;
|
|
98
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Week rows per month pane. Fixed at 6 — the most any month needs — so every
|
|
3
|
+
* pane is identical in height and no snap offset ever shifts. Not a themeable
|
|
4
|
+
* variable: it is a fact about the Gregorian calendar, and `repeat()` cannot
|
|
5
|
+
* take a custom property as its count.
|
|
6
|
+
*/
|
|
7
|
+
export declare const WEEKS_PER_PANE = 6;
|
|
8
|
+
/**
|
|
9
|
+
* The picker's two size inputs.
|
|
10
|
+
*
|
|
11
|
+
* `defineConsts`, not `defineVars`: these are inlined at build time and emit
|
|
12
|
+
* no CSS custom property, so they are internal geometry rather than public
|
|
13
|
+
* theming API. That is deliberate for both of them.
|
|
14
|
+
*
|
|
15
|
+
* The day size is an accessibility floor — 44px is the comfortable minimum
|
|
16
|
+
* tap target on iOS and Android, and every other target in the sheet is held
|
|
17
|
+
* to it. Exposing it as a variable would let a theme quietly lower the floor,
|
|
18
|
+
* which is not a knob a design system should hand out.
|
|
19
|
+
*
|
|
20
|
+
* The wheel row height is only meaningful against the day size (see below),
|
|
21
|
+
* so tuning one without the other produces a picker whose panes no longer
|
|
22
|
+
* agree — a variable that is only safe to change in lockstep with another is
|
|
23
|
+
* not really a variable.
|
|
24
|
+
*
|
|
25
|
+
* If a real need to theme either appears, promoting a const to a var is an
|
|
26
|
+
* additive change; removing a var that consumers have started setting is not.
|
|
27
|
+
*/
|
|
28
|
+
export declare const dateInputTouchSizes: {
|
|
29
|
+
/**
|
|
30
|
+
* Height of one day row, and the minimum touch target of a day. 44px is the
|
|
31
|
+
* comfortable minimum tap target on both iOS and Android.
|
|
32
|
+
*/
|
|
33
|
+
daySize: string;
|
|
34
|
+
/**
|
|
35
|
+
* Height of one wheel option row, and so the spacing between options and
|
|
36
|
+
* the height of the selection band.
|
|
37
|
+
*
|
|
38
|
+
* 28px against a day's 44px: a wheel row is scroll-first — a value is
|
|
39
|
+
* chosen by bringing it under the band, and tapping one is a shortcut
|
|
40
|
+
* rather than the mechanism — so it does not carry a day cell's tap-target
|
|
41
|
+
* duty, and a mis-tap costs nothing, because the neighbouring rows are the
|
|
42
|
+
* same control and the result is visible immediately.
|
|
43
|
+
*
|
|
44
|
+
* The row is deliberately close to the text it holds (17px), the way a
|
|
45
|
+
* platform picker packs them: the list should read as one continuous
|
|
46
|
+
* column of values, not as a stack of buttons with air between them. At
|
|
47
|
+
* this height ~9 options are on screen.
|
|
48
|
+
*/
|
|
49
|
+
wheelItemSize: string;
|
|
50
|
+
};
|
|
51
|
+
/** Geometry derived from the sizes above, shared across the component. */
|
|
52
|
+
export declare const dateInputTouchGeometry: {
|
|
53
|
+
/** One month pane — and therefore the scrollport, and the wheel body. */
|
|
54
|
+
paneBlockSize: string;
|
|
55
|
+
/** The six equal week rows inside a pane. */
|
|
56
|
+
paneRows: string;
|
|
57
|
+
/**
|
|
58
|
+
* Padding above the first and below the last wheel option, so either end
|
|
59
|
+
* can come to rest under the centered selection band.
|
|
60
|
+
*/
|
|
61
|
+
wheelEdgePadding: string;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=tokens.stylex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.stylex.d.ts","sourceRoot":"","sources":["../../src/DateInput/tokens.stylex.ts"],"names":[],"mappings":"AA4BA;;;;;GAKG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,mBAAmB;IAC9B;;;OAGG;;IAEH;;;;;;;;;;;;;;OAcG;;CAEH,CAAC;AASH,0EAA0E;AAC1E,eAAO,MAAM,sBAAsB;IACjC,yEAAyE;;IAEzE,6CAA6C;;IAE7C;;;OAGG;;CAEH,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file tokens.stylex.ts
|
|
5
|
+
* @input StyleX variable and constant definitions
|
|
6
|
+
* @output Exports DateInput layout constants and derived geometry
|
|
7
|
+
* @position Lab component tokens consumed by DateInput.tsx, MonthScroller.tsx, Wheel.tsx, MonthYearWheels.tsx
|
|
8
|
+
*
|
|
9
|
+
* The picker's whole geometry derives from two numbers, which is what makes
|
|
10
|
+
* the fixed height and the scroll snapping exact:
|
|
11
|
+
*
|
|
12
|
+
* pane height = weeks x day size (one month, always 6 rows)
|
|
13
|
+
* body height = pane height (calendar body AND wheel body)
|
|
14
|
+
* wheel pad = (body height - item) / 2 (so row 0 can rest centered)
|
|
15
|
+
*
|
|
16
|
+
* Every month pane is the same height as the scrollport, so `scroll-snap-align:
|
|
17
|
+
* start` produces a paged scroller with no partial rest positions, and the
|
|
18
|
+
* wheel overlay swaps in without the component changing size.
|
|
19
|
+
*
|
|
20
|
+
* The derived values are `defineConsts`, not plain exported strings: StyleX
|
|
21
|
+
* inlines a constant at build time only through `defineVars`/`defineConsts`
|
|
22
|
+
* from a `.stylex.ts` file. A plain `export const` fails the build with
|
|
23
|
+
* "a style value can only contain an array, string or number".
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import * as stylex from '@stylexjs/stylex';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Week rows per month pane. Fixed at 6 — the most any month needs — so every
|
|
31
|
+
* pane is identical in height and no snap offset ever shifts. Not a themeable
|
|
32
|
+
* variable: it is a fact about the Gregorian calendar, and `repeat()` cannot
|
|
33
|
+
* take a custom property as its count.
|
|
34
|
+
*/
|
|
35
|
+
export const WEEKS_PER_PANE = 6;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The picker's two size inputs.
|
|
39
|
+
*
|
|
40
|
+
* `defineConsts`, not `defineVars`: these are inlined at build time and emit
|
|
41
|
+
* no CSS custom property, so they are internal geometry rather than public
|
|
42
|
+
* theming API. That is deliberate for both of them.
|
|
43
|
+
*
|
|
44
|
+
* The day size is an accessibility floor — 44px is the comfortable minimum
|
|
45
|
+
* tap target on iOS and Android, and every other target in the sheet is held
|
|
46
|
+
* to it. Exposing it as a variable would let a theme quietly lower the floor,
|
|
47
|
+
* which is not a knob a design system should hand out.
|
|
48
|
+
*
|
|
49
|
+
* The wheel row height is only meaningful against the day size (see below),
|
|
50
|
+
* so tuning one without the other produces a picker whose panes no longer
|
|
51
|
+
* agree — a variable that is only safe to change in lockstep with another is
|
|
52
|
+
* not really a variable.
|
|
53
|
+
*
|
|
54
|
+
* If a real need to theme either appears, promoting a const to a var is an
|
|
55
|
+
* additive change; removing a var that consumers have started setting is not.
|
|
56
|
+
*/
|
|
57
|
+
export const dateInputTouchSizes = {
|
|
58
|
+
daySize: "44px",
|
|
59
|
+
wheelItemSize: "28px"
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Local aliases for the derived values below. StyleX resolves a `defineConsts`
|
|
63
|
+
// member through an import, so consumers read `dateInputTouchSizes.*` directly
|
|
64
|
+
// rather than a re-exported plain const, which its static analysis cannot
|
|
65
|
+
// follow across files.
|
|
66
|
+
const DAY_SIZE = dateInputTouchSizes.daySize;
|
|
67
|
+
const WHEEL_ITEM_SIZE = dateInputTouchSizes.wheelItemSize;
|
|
68
|
+
|
|
69
|
+
/** Geometry derived from the sizes above, shared across the component. */
|
|
70
|
+
export const dateInputTouchGeometry = {
|
|
71
|
+
paneBlockSize: "calc(6 * 44px)",
|
|
72
|
+
paneRows: "repeat(6, 1fr)",
|
|
73
|
+
wheelEdgePadding: "calc((6 * 44px - 28px) / 2)"
|
|
74
|
+
};
|