@react-md/core 6.3.3 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CoreProviders.d.ts +1 -0
- package/dist/CoreProviders.js.map +1 -1
- package/dist/_base.scss +3 -0
- package/dist/_core.scss +1 -0
- package/dist/_utils.scss +15 -7
- package/dist/app-bar/AppBar.js.map +1 -1
- package/dist/app-bar/AppBarTitle.js.map +1 -1
- package/dist/autocomplete/AutocompleteListboxChildren.js.map +1 -1
- package/dist/autocomplete/types.js.map +1 -1
- package/dist/autocomplete/utils.js.map +1 -1
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/box/_box.scss +20 -1
- package/dist/box/styles.d.ts +39 -0
- package/dist/box/styles.js +39 -0
- package/dist/box/styles.js.map +1 -1
- package/dist/button/Button.js.map +1 -1
- package/dist/button/FloatingActionButton.js.map +1 -1
- package/dist/card/Card.js.map +1 -1
- package/dist/card/CardContent.js.map +1 -1
- package/dist/card/ClickableCard.js.map +1 -1
- package/dist/chip/Chip.js.map +1 -1
- package/dist/datetime/NativeDateField.js.map +1 -1
- package/dist/datetime/NativeTimeField.js.map +1 -1
- package/dist/datetime/useDateField.js.map +1 -1
- package/dist/datetime/useTimeField.js.map +1 -1
- package/dist/dialog/Dialog.js.map +1 -1
- package/dist/dialog/DialogContainer.js.map +1 -1
- package/dist/dialog/DialogContent.js.map +1 -1
- package/dist/dialog/DialogFooter.js.map +1 -1
- package/dist/divider/Divider.js.map +1 -1
- package/dist/draggable/useDraggable.js.map +1 -1
- package/dist/draggable/utils.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
- package/dist/files/FileInput.js.map +1 -1
- package/dist/files/useFileUpload.js.map +1 -1
- package/dist/files/validation.js.map +1 -1
- package/dist/focus/useFocusContainer.js.map +1 -1
- package/dist/form/Fieldset.d.ts +19 -0
- package/dist/form/Fieldset.js +22 -2
- package/dist/form/Fieldset.js.map +1 -1
- package/dist/form/FormMessageContainer.js.map +1 -1
- package/dist/form/FormMessageCounter.js.map +1 -1
- package/dist/form/InputToggle.js.map +1 -1
- package/dist/form/Legend.d.ts +27 -5
- package/dist/form/Legend.js +39 -6
- package/dist/form/Legend.js.map +1 -1
- package/dist/form/Listbox.js.map +1 -1
- package/dist/form/ListboxProvider.js.map +1 -1
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/Password.js.map +1 -1
- package/dist/form/ResizingTextAreaWrapper.js.map +1 -1
- package/dist/form/Select.js.map +1 -1
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/SliderContainer.js.map +1 -1
- package/dist/form/SliderThumb.js.map +1 -1
- package/dist/form/SliderTrack.js.map +1 -1
- package/dist/form/SliderValueMarks.js.map +1 -1
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/TextFieldContainer.js.map +1 -1
- package/dist/form/_fieldset.scss +7 -0
- package/dist/form/_legend.scss +68 -0
- package/dist/form/_text-field.scss +39 -4
- package/dist/form/fieldsetStyles.d.ts +6 -1
- package/dist/form/fieldsetStyles.js +3 -2
- package/dist/form/fieldsetStyles.js.map +1 -1
- package/dist/form/inputToggleStyles.js.map +1 -1
- package/dist/form/labelStyles.d.ts +1 -1
- package/dist/form/labelStyles.js +1 -1
- package/dist/form/labelStyles.js.map +1 -1
- package/dist/form/legendStyles.d.ts +83 -0
- package/dist/form/legendStyles.js +25 -0
- package/dist/form/legendStyles.js.map +1 -0
- package/dist/form/selectUtils.js.map +1 -1
- package/dist/form/textFieldContainerStyles.js.map +1 -1
- package/dist/form/types.d.ts +28 -6
- package/dist/form/types.js.map +1 -1
- package/dist/form/useCheckboxGroup.js.map +1 -1
- package/dist/form/useCombobox.js.map +1 -1
- package/dist/form/useNumberField.js +16 -19
- package/dist/form/useNumberField.js.map +1 -1
- package/dist/form/useRangeSlider.js.map +1 -1
- package/dist/form/useSlider.js.map +1 -1
- package/dist/form/useTextField.d.ts +1 -1
- package/dist/form/useTextField.js.map +1 -1
- package/dist/hoverMode/useHoverMode.js.map +1 -1
- package/dist/icon/FontIcon.js.map +1 -1
- package/dist/icon/IconRotator.js.map +1 -1
- package/dist/icon/MaterialIcon.js.map +1 -1
- package/dist/icon/MaterialSymbol.js.map +1 -1
- package/dist/icon/SVGIcon.js.map +1 -1
- package/dist/icon/config.d.ts +0 -1
- package/dist/icon/config.js +10 -7
- package/dist/icon/config.js.map +1 -1
- package/dist/icon/materialConfig.js.map +1 -1
- package/dist/icon/styles.js.map +1 -1
- package/dist/interaction/UserInteractionModeProvider.js +6 -4
- package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
- package/dist/interaction/types.js.map +1 -1
- package/dist/interaction/useElementInteraction.js.map +1 -1
- package/dist/layout/LayoutAppBar.d.ts +6 -6
- package/dist/layout/LayoutAppBar.js +6 -6
- package/dist/layout/LayoutAppBar.js.map +1 -1
- package/dist/layout/LayoutNav.js.map +1 -1
- package/dist/layout/LayoutWindowSplitter.js.map +1 -1
- package/dist/layout/Main.js.map +1 -1
- package/dist/layout/useExpandableLayout.js +43 -0
- package/dist/layout/useExpandableLayout.js.map +1 -1
- package/dist/layout/useHorizontalLayoutTransition.js.map +1 -1
- package/dist/layout/useLayoutTree.js.map +1 -1
- package/dist/layout/useLayoutWindowSplitter.js.map +1 -1
- package/dist/layout/useResizableLayout.js.map +1 -1
- package/dist/link/Link.js.map +1 -1
- package/dist/link/SkipToMainContent.js +19 -21
- package/dist/link/SkipToMainContent.js.map +1 -1
- package/dist/list/List.js.map +1 -1
- package/dist/list/ListItem.js.map +1 -1
- package/dist/list/ListItemAddon.js.map +1 -1
- package/dist/list/ListItemLink.js.map +1 -1
- package/dist/list/ListSubheader.js.map +1 -1
- package/dist/list/getListItemHeight.js.map +1 -1
- package/dist/list/listItemStyles.js.map +1 -1
- package/dist/list/types.js.map +1 -1
- package/dist/media-queries/AppSizeProvider.d.ts +2 -0
- package/dist/media-queries/AppSizeProvider.js +3 -2
- package/dist/media-queries/AppSizeProvider.js.map +1 -1
- package/dist/media-queries/appSize.d.ts +3 -0
- package/dist/media-queries/appSize.js +3 -1
- package/dist/media-queries/appSize.js.map +1 -1
- package/dist/media-queries/config.d.ts +11 -0
- package/dist/media-queries/config.js +26 -0
- package/dist/media-queries/config.js.map +1 -0
- package/dist/menu/DropdownMenu.js.map +1 -1
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuItemButton.js.map +1 -1
- package/dist/menu/MenuItemFileInput.js.map +1 -1
- package/dist/menu/MenuItemInputToggle.js.map +1 -1
- package/dist/menu/MenuItemSeparator.js.map +1 -1
- package/dist/menu/MenuVisibilityProvider.js.map +1 -1
- package/dist/menu/MenuWidget.js.map +1 -1
- package/dist/menu/useContextMenu.js.map +1 -1
- package/dist/movement/types.d.ts +28 -3
- package/dist/movement/types.js.map +1 -1
- package/dist/movement/useKeyboardMovementProvider.js +96 -47
- package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
- package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
- package/dist/navigation/NavItem.js.map +1 -1
- package/dist/navigation/NavItemButton.js.map +1 -1
- package/dist/navigation/NavItemLink.js.map +1 -1
- package/dist/navigation/getTableOfContentsHeadings.js.map +1 -1
- package/dist/navigation/types.js.map +1 -1
- package/dist/overlay/Overlay.js.map +1 -1
- package/dist/positioning/createHorizontalPosition.js.map +1 -1
- package/dist/positioning/createVerticalPosition.js.map +1 -1
- package/dist/positioning/useFixedPositioning.js.map +1 -1
- package/dist/progress/CircularProgress.js.map +1 -1
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/linearProgressStyles.js.map +1 -1
- package/dist/responsive-item/ResponsiveItem.js.map +1 -1
- package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
- package/dist/searching/caseInsensitive.js.map +1 -1
- package/dist/segmented-button/SegmentedButton.js.map +1 -1
- package/dist/segmented-button/SegmentedButtonContainer.js.map +1 -1
- package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
- package/dist/sheet/Sheet.js.map +1 -1
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/spinbutton/SpinButton.d.ts +16 -0
- package/dist/spinbutton/SpinButton.js +55 -0
- package/dist/spinbutton/SpinButton.js.map +1 -0
- package/dist/spinbutton/SpinButtonGroupProvider.d.ts +17 -0
- package/dist/spinbutton/SpinButtonGroupProvider.js +19 -0
- package/dist/spinbutton/SpinButtonGroupProvider.js.map +1 -0
- package/dist/spinbutton/defaults.d.ts +9 -0
- package/dist/spinbutton/defaults.js +25 -0
- package/dist/spinbutton/defaults.js.map +1 -0
- package/dist/spinbutton/types.d.ts +324 -0
- package/dist/spinbutton/types.js +5 -0
- package/dist/spinbutton/types.js.map +1 -0
- package/dist/spinbutton/useSpinButton.d.ts +5 -0
- package/dist/spinbutton/useSpinButton.js +260 -0
- package/dist/spinbutton/useSpinButton.js.map +1 -0
- package/dist/spinbutton/useSpinButtonGroupProvider.d.ts +27 -0
- package/dist/spinbutton/useSpinButtonGroupProvider.js +49 -0
- package/dist/spinbutton/useSpinButtonGroupProvider.js.map +1 -0
- package/dist/spinbutton/utils/deselectNode.d.ts +5 -0
- package/dist/spinbutton/utils/deselectNode.js +17 -0
- package/dist/spinbutton/utils/deselectNode.js.map +1 -0
- package/dist/spinbutton/utils/resolveInputEvent.d.ts +30 -0
- package/dist/spinbutton/utils/resolveInputEvent.js +53 -0
- package/dist/spinbutton/utils/resolveInputEvent.js.map +1 -0
- package/dist/spinbutton/utils/selectNode.d.ts +5 -0
- package/dist/spinbutton/utils/selectNode.js +15 -0
- package/dist/spinbutton/utils/selectNode.js.map +1 -0
- package/dist/table/StickyTableSection.js.map +1 -1
- package/dist/table/Table.js.map +1 -1
- package/dist/table/TableBody.js.map +1 -1
- package/dist/table/TableCellContent.js.map +1 -1
- package/dist/table/TableCheckbox.js.map +1 -1
- package/dist/table/TableFooter.js.map +1 -1
- package/dist/table/TableHeader.js.map +1 -1
- package/dist/table/TableRadio.js.map +1 -1
- package/dist/table/TableRow.js.map +1 -1
- package/dist/table/useStickyTableSection.js.map +1 -1
- package/dist/tabs/SimpleTabPanel.js.map +1 -1
- package/dist/tabs/SimpleTabPanels.js.map +1 -1
- package/dist/tabs/Tab.js.map +1 -1
- package/dist/tabs/TabList.js.map +1 -1
- package/dist/tabs/TabListScrollButton.js.map +1 -1
- package/dist/tabs/useMaxTabPanelHeight.js.map +1 -1
- package/dist/test-utils/data-testid.js.map +1 -1
- package/dist/test-utils/mocks/match-media.js +5 -5
- package/dist/test-utils/mocks/match-media.js.map +1 -1
- package/dist/test-utils/vitest/timers.d.ts +1 -1
- package/dist/test-utils/vitest/timers.js +1 -1
- package/dist/test-utils/vitest/timers.js.map +1 -1
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/TooltipHoverModeProvider.js.map +1 -1
- package/dist/tooltip/useTooltip.js.map +1 -1
- package/dist/transition/CSSTransition.js.map +1 -1
- package/dist/transition/Collapse.js.map +1 -1
- package/dist/transition/CrossFade.js.map +1 -1
- package/dist/transition/ScaleTransition.js.map +1 -1
- package/dist/transition/SkeletonPlaceholder.js.map +1 -1
- package/dist/transition/Slide.js.map +1 -1
- package/dist/transition/SlideContainer.js.map +1 -1
- package/dist/transition/types.js.map +1 -1
- package/dist/transition/useCollapseTransition.js.map +1 -1
- package/dist/transition/useCrossFadeTransition.js.map +1 -1
- package/dist/transition/useMaxWidthTransition.js.map +1 -1
- package/dist/transition/useScaleTransition.js.map +1 -1
- package/dist/transition/useSkeletonPlaceholder.js.map +1 -1
- package/dist/tree/Tree.js.map +1 -1
- package/dist/tree/TreeItem.js.map +1 -1
- package/dist/tree/TreeProvider.js.map +1 -1
- package/dist/tree/styles.js.map +1 -1
- package/dist/tree/types.js.map +1 -1
- package/dist/tree/useTreeMovement.js.map +1 -1
- package/dist/typography/HighlightTextMark.js.map +1 -1
- package/dist/typography/Mark.js.map +1 -1
- package/dist/typography/TextContainer.js.map +1 -1
- package/dist/typography/Typography.js.map +1 -1
- package/dist/typography/_typography.scss +0 -1
- package/dist/useElementSize.js.map +1 -1
- package/dist/useIntersectionObserver.js.map +1 -1
- package/dist/useMutationObserver.js.map +1 -1
- package/dist/useWindowSize.js.map +1 -1
- package/dist/utils/getNumberOfDigits.d.ts +7 -0
- package/dist/utils/getNumberOfDigits.js +11 -0
- package/dist/utils/getNumberOfDigits.js.map +1 -0
- package/dist/utils/nearest.js +2 -1
- package/dist/utils/nearest.js.map +1 -1
- package/dist/utils/useDevEffect.d.ts +7 -0
- package/dist/utils/useDevEffect.js +8 -0
- package/dist/utils/useDevEffect.js.map +1 -0
- package/dist/window-splitter/WindowSplitter.js +3 -2
- package/dist/window-splitter/WindowSplitter.js.map +1 -1
- package/dist/window-splitter/_window-splitter.scss +60 -12
- package/dist/window-splitter/styles.d.ts +9 -0
- package/dist/window-splitter/styles.js +3 -2
- package/dist/window-splitter/styles.js.map +1 -1
- package/dist/window-splitter/useWindowSplitter.js.map +1 -1
- package/package.json +38 -30
- package/src/CoreProviders.tsx +1 -0
- package/src/app-bar/AppBar.tsx +1 -2
- package/src/app-bar/AppBarTitle.tsx +1 -2
- package/src/autocomplete/AutocompleteListboxChildren.tsx +3 -1
- package/src/autocomplete/types.ts +24 -19
- package/src/autocomplete/utils.ts +9 -6
- package/src/avatar/Avatar.tsx +2 -1
- package/src/box/styles.ts +39 -0
- package/src/button/Button.tsx +2 -1
- package/src/button/FloatingActionButton.tsx +2 -1
- package/src/card/Card.tsx +2 -1
- package/src/card/CardContent.tsx +1 -2
- package/src/card/ClickableCard.tsx +1 -2
- package/src/chip/Chip.tsx +2 -1
- package/src/datetime/NativeDateField.tsx +2 -1
- package/src/datetime/NativeTimeField.tsx +2 -1
- package/src/datetime/useDateField.ts +13 -8
- package/src/datetime/useTimeField.ts +13 -8
- package/src/dialog/Dialog.tsx +2 -1
- package/src/dialog/DialogContainer.tsx +1 -2
- package/src/dialog/DialogContent.tsx +1 -2
- package/src/dialog/DialogFooter.tsx +1 -2
- package/src/divider/Divider.tsx +1 -2
- package/src/draggable/useDraggable.ts +4 -4
- package/src/draggable/utils.ts +4 -2
- package/src/expansion-panel/ExpansionPanelHeader.tsx +1 -2
- package/src/files/FileInput.tsx +2 -1
- package/src/files/useFileUpload.ts +6 -6
- package/src/files/validation.ts +1 -2
- package/src/focus/useFocusContainer.ts +4 -4
- package/src/form/Fieldset.tsx +25 -3
- package/src/form/FormMessageContainer.tsx +1 -2
- package/src/form/FormMessageCounter.tsx +1 -2
- package/src/form/InputToggle.tsx +3 -3
- package/src/form/Legend.tsx +55 -10
- package/src/form/Listbox.tsx +1 -2
- package/src/form/ListboxProvider.ts +3 -2
- package/src/form/NativeSelect.tsx +2 -1
- package/src/form/Password.tsx +4 -2
- package/src/form/ResizingTextAreaWrapper.tsx +1 -2
- package/src/form/Select.tsx +2 -1
- package/src/form/Slider.tsx +2 -1
- package/src/form/SliderContainer.tsx +1 -2
- package/src/form/SliderThumb.tsx +6 -3
- package/src/form/SliderTrack.tsx +2 -1
- package/src/form/SliderValueMarks.tsx +1 -2
- package/src/form/Switch.tsx +2 -1
- package/src/form/TextArea.tsx +1 -2
- package/src/form/TextField.tsx +2 -1
- package/src/form/TextFieldContainer.tsx +1 -2
- package/src/form/fieldsetStyles.ts +18 -3
- package/src/form/inputToggleStyles.ts +4 -2
- package/src/form/labelStyles.ts +1 -1
- package/src/form/legendStyles.ts +132 -0
- package/src/form/selectUtils.ts +3 -2
- package/src/form/textFieldContainerStyles.ts +1 -2
- package/src/form/types.ts +35 -17
- package/src/form/useCheckboxGroup.ts +3 -2
- package/src/form/useCombobox.ts +8 -3
- package/src/form/useNumberField.ts +36 -35
- package/src/form/useRangeSlider.ts +1 -2
- package/src/form/useSlider.ts +1 -2
- package/src/form/useTextField.ts +9 -4
- package/src/hoverMode/useHoverMode.ts +4 -8
- package/src/icon/FontIcon.tsx +1 -2
- package/src/icon/IconRotator.tsx +1 -2
- package/src/icon/MaterialIcon.tsx +2 -1
- package/src/icon/MaterialSymbol.tsx +2 -1
- package/src/icon/SVGIcon.tsx +1 -2
- package/src/icon/config.tsx +10 -7
- package/src/icon/materialConfig.ts +1 -2
- package/src/icon/styles.ts +1 -2
- package/src/interaction/UserInteractionModeProvider.tsx +9 -4
- package/src/interaction/types.ts +1 -2
- package/src/interaction/useElementInteraction.tsx +3 -2
- package/src/layout/LayoutAppBar.tsx +6 -6
- package/src/layout/LayoutNav.tsx +2 -1
- package/src/layout/LayoutWindowSplitter.tsx +2 -1
- package/src/layout/Main.tsx +1 -2
- package/src/layout/useExpandableLayout.ts +63 -5
- package/src/layout/useHorizontalLayoutTransition.ts +1 -2
- package/src/layout/useLayoutTree.ts +2 -2
- package/src/layout/useLayoutWindowSplitter.ts +6 -6
- package/src/layout/useResizableLayout.ts +3 -6
- package/src/link/Link.tsx +1 -2
- package/src/link/SkipToMainContent.tsx +20 -23
- package/src/list/List.tsx +1 -2
- package/src/list/ListItem.tsx +2 -1
- package/src/list/ListItemAddon.tsx +2 -1
- package/src/list/ListItemLink.tsx +2 -1
- package/src/list/ListSubheader.tsx +1 -2
- package/src/list/getListItemHeight.ts +8 -9
- package/src/list/listItemStyles.ts +1 -2
- package/src/list/types.ts +1 -2
- package/src/media-queries/AppSizeProvider.tsx +8 -10
- package/src/media-queries/appSize.ts +3 -0
- package/src/media-queries/config.ts +41 -0
- package/src/menu/DropdownMenu.tsx +4 -5
- package/src/menu/Menu.tsx +2 -1
- package/src/menu/MenuItemButton.tsx +1 -2
- package/src/menu/MenuItemFileInput.tsx +2 -1
- package/src/menu/MenuItemInputToggle.tsx +3 -3
- package/src/menu/MenuItemSeparator.tsx +2 -1
- package/src/menu/MenuVisibilityProvider.tsx +4 -2
- package/src/menu/MenuWidget.tsx +1 -2
- package/src/menu/useContextMenu.ts +4 -2
- package/src/movement/types.ts +52 -13
- package/src/movement/useKeyboardMovementProvider.ts +77 -38
- package/src/navigation/CollapsibleNavGroup.tsx +1 -2
- package/src/navigation/NavItem.tsx +1 -2
- package/src/navigation/NavItemButton.tsx +2 -1
- package/src/navigation/NavItemLink.tsx +2 -1
- package/src/navigation/getTableOfContentsHeadings.ts +1 -2
- package/src/navigation/types.ts +1 -2
- package/src/overlay/Overlay.tsx +2 -1
- package/src/positioning/createHorizontalPosition.ts +10 -12
- package/src/positioning/createVerticalPosition.ts +10 -11
- package/src/positioning/useFixedPositioning.ts +6 -3
- package/src/progress/CircularProgress.tsx +2 -1
- package/src/progress/LinearProgress.tsx +2 -1
- package/src/progress/linearProgressStyles.ts +1 -2
- package/src/responsive-item/ResponsiveItem.tsx +1 -2
- package/src/responsive-item/ResponsiveItemOverlay.tsx +2 -1
- package/src/searching/caseInsensitive.ts +2 -4
- package/src/segmented-button/SegmentedButton.tsx +2 -1
- package/src/segmented-button/SegmentedButtonContainer.tsx +2 -1
- package/src/segmented-button/segmentedButtonStyles.ts +1 -2
- package/src/sheet/Sheet.tsx +1 -2
- package/src/snackbar/Toast.tsx +2 -1
- package/src/spinbutton/SpinButton.tsx +98 -0
- package/src/spinbutton/SpinButtonGroupProvider.tsx +32 -0
- package/src/spinbutton/defaults.ts +45 -0
- package/src/spinbutton/types.ts +413 -0
- package/src/spinbutton/useSpinButton.ts +311 -0
- package/src/spinbutton/useSpinButtonGroupProvider.ts +104 -0
- package/src/spinbutton/utils/deselectNode.ts +17 -0
- package/src/spinbutton/utils/resolveInputEvent.ts +112 -0
- package/src/spinbutton/utils/selectNode.ts +15 -0
- package/src/table/StickyTableSection.tsx +2 -1
- package/src/table/Table.tsx +1 -2
- package/src/table/TableBody.tsx +2 -1
- package/src/table/TableCellContent.tsx +1 -2
- package/src/table/TableCheckbox.tsx +1 -2
- package/src/table/TableFooter.tsx +1 -2
- package/src/table/TableHeader.tsx +1 -2
- package/src/table/TableRadio.tsx +1 -2
- package/src/table/TableRow.tsx +1 -2
- package/src/table/useStickyTableSection.tsx +1 -2
- package/src/tabs/SimpleTabPanel.tsx +2 -1
- package/src/tabs/SimpleTabPanels.tsx +2 -1
- package/src/tabs/Tab.tsx +3 -6
- package/src/tabs/TabList.tsx +2 -1
- package/src/tabs/TabListScrollButton.tsx +1 -2
- package/src/tabs/useMaxTabPanelHeight.ts +7 -4
- package/src/test-utils/data-testid.ts +1 -2
- package/src/test-utils/mocks/match-media.ts +5 -10
- package/src/test-utils/vitest/timers.ts +1 -1
- package/src/tooltip/Tooltip.tsx +2 -1
- package/src/tooltip/TooltipHoverModeProvider.tsx +1 -2
- package/src/tooltip/useTooltip.ts +9 -5
- package/src/transition/CSSTransition.tsx +2 -1
- package/src/transition/Collapse.tsx +4 -2
- package/src/transition/CrossFade.tsx +2 -1
- package/src/transition/ScaleTransition.tsx +2 -1
- package/src/transition/SkeletonPlaceholder.tsx +1 -2
- package/src/transition/Slide.tsx +2 -1
- package/src/transition/SlideContainer.tsx +1 -2
- package/src/transition/types.ts +15 -16
- package/src/transition/useCollapseTransition.ts +6 -5
- package/src/transition/useCrossFadeTransition.ts +3 -2
- package/src/transition/useMaxWidthTransition.ts +1 -2
- package/src/transition/useScaleTransition.ts +3 -2
- package/src/transition/useSkeletonPlaceholder.ts +1 -2
- package/src/tree/Tree.tsx +2 -1
- package/src/tree/TreeItem.tsx +2 -1
- package/src/tree/TreeProvider.tsx +4 -4
- package/src/tree/styles.ts +1 -2
- package/src/tree/types.ts +1 -2
- package/src/tree/useTreeMovement.ts +1 -2
- package/src/typography/HighlightTextMark.tsx +1 -2
- package/src/typography/Mark.tsx +1 -2
- package/src/typography/TextContainer.tsx +1 -2
- package/src/typography/Typography.tsx +1 -2
- package/src/useElementSize.ts +7 -4
- package/src/useIntersectionObserver.ts +3 -2
- package/src/useMutationObserver.ts +3 -2
- package/src/useWindowSize.ts +4 -2
- package/src/utils/getNumberOfDigits.ts +18 -0
- package/src/utils/nearest.ts +2 -1
- package/src/utils/useDevEffect.ts +9 -0
- package/src/window-splitter/WindowSplitter.tsx +5 -2
- package/src/window-splitter/styles.ts +13 -2
- package/src/window-splitter/useWindowSplitter.ts +3 -1
|
@@ -62,8 +62,7 @@ export interface CaseInsensitiveStartsWithOptions {
|
|
|
62
62
|
/**
|
|
63
63
|
* @since 6.0.0
|
|
64
64
|
*/
|
|
65
|
-
export interface IsCaseInsensitiveMatchOptions
|
|
66
|
-
extends CaseInsensitiveStartsWithOptions {
|
|
65
|
+
export interface IsCaseInsensitiveMatchOptions extends CaseInsensitiveStartsWithOptions {
|
|
67
66
|
/**
|
|
68
67
|
* The current search query.
|
|
69
68
|
*/
|
|
@@ -94,8 +93,7 @@ export function isCaseInsensitiveMatch(
|
|
|
94
93
|
* @since 6.0.0
|
|
95
94
|
*/
|
|
96
95
|
export interface CaseInsensitiveOptions<T>
|
|
97
|
-
extends BaseSearchOptions<T>,
|
|
98
|
-
CaseInsensitiveStartsWithOptions {}
|
|
96
|
+
extends BaseSearchOptions<T>, CaseInsensitiveStartsWithOptions {}
|
|
99
97
|
|
|
100
98
|
/**
|
|
101
99
|
* @example String list
|
|
@@ -23,7 +23,8 @@ import {
|
|
|
23
23
|
* module augmentation.
|
|
24
24
|
*/
|
|
25
25
|
export interface SegmentedButtonProps
|
|
26
|
-
extends
|
|
26
|
+
extends
|
|
27
|
+
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
27
28
|
BaseMaxWidthTransitionOptions,
|
|
28
29
|
BaseSegmentedButtonClassNameOptions,
|
|
29
30
|
ComponentWithRippleProps {
|
|
@@ -42,8 +42,7 @@ export interface BaseSegmentedButtonClassNameOptions {
|
|
|
42
42
|
* @since 6.0.0
|
|
43
43
|
* @since 6.3.1 Extends BaseSegmentedButtonClassNameOptions
|
|
44
44
|
*/
|
|
45
|
-
export interface SegmentedButtonClassNameOptions
|
|
46
|
-
extends BaseSegmentedButtonClassNameOptions {
|
|
45
|
+
export interface SegmentedButtonClassNameOptions extends BaseSegmentedButtonClassNameOptions {
|
|
47
46
|
/** @internal */
|
|
48
47
|
pressedClassName?: string;
|
|
49
48
|
}
|
package/src/sheet/Sheet.tsx
CHANGED
|
@@ -21,8 +21,7 @@ export type SheetDialogProps = Omit<BaseDialogProps, "role" | "type" | "modal">;
|
|
|
21
21
|
* and exports the `SheetDialogProps`.
|
|
22
22
|
*/
|
|
23
23
|
export interface BaseSheetProps
|
|
24
|
-
extends SheetDialogProps,
|
|
25
|
-
BaseSheetClassNameOptions {
|
|
24
|
+
extends SheetDialogProps, BaseSheetClassNameOptions {
|
|
26
25
|
/**
|
|
27
26
|
* @defaultValue `"dialog"`
|
|
28
27
|
*/
|
package/src/snackbar/Toast.tsx
CHANGED
|
@@ -27,7 +27,8 @@ import { type BaseToastClasNameOptions, toast } from "./toastStyles.js";
|
|
|
27
27
|
* @since 6.0.0
|
|
28
28
|
*/
|
|
29
29
|
export interface ConfigurableToastProps
|
|
30
|
-
extends
|
|
30
|
+
extends
|
|
31
|
+
HTMLAttributes<HTMLDivElement>,
|
|
31
32
|
BaseToastClasNameOptions,
|
|
32
33
|
TransitionCallbacks {
|
|
33
34
|
/**
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { type HTMLAttributes, forwardRef } from "react";
|
|
4
|
+
|
|
5
|
+
import { type LabelRequiredForA11y } from "../types.js";
|
|
6
|
+
import { defaultGetSpinButtonTextContent } from "./defaults.js";
|
|
7
|
+
import {
|
|
8
|
+
type SpinButtonOptions,
|
|
9
|
+
type SpinButtonUncontrolledValueOptions,
|
|
10
|
+
type SpinButtonValueOptions,
|
|
11
|
+
} from "./types.js";
|
|
12
|
+
import { useSpinButton } from "./useSpinButton.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @since 6.4.0
|
|
16
|
+
*/
|
|
17
|
+
export interface SpinButtonProps
|
|
18
|
+
extends
|
|
19
|
+
Omit<HTMLAttributes<HTMLDivElement>, keyof SpinButtonOptions>,
|
|
20
|
+
Omit<SpinButtonOptions<HTMLDivElement>, "ref" | "children"> {}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The `SpinButton` component can be used as a simple wrapper around the
|
|
24
|
+
* {@link useSpinButton} hook if it should be rendered within a `<div>` and
|
|
25
|
+
* only the rendering behavior is required.
|
|
26
|
+
*
|
|
27
|
+
* @since 6.4.0
|
|
28
|
+
*/
|
|
29
|
+
export const SpinButton = forwardRef<
|
|
30
|
+
HTMLDivElement,
|
|
31
|
+
LabelRequiredForA11y<SpinButtonProps> & SpinButtonValueOptions
|
|
32
|
+
>(function SpinButton(props, ref) {
|
|
33
|
+
const {
|
|
34
|
+
id,
|
|
35
|
+
min,
|
|
36
|
+
max,
|
|
37
|
+
minDigits,
|
|
38
|
+
maxDigits,
|
|
39
|
+
step,
|
|
40
|
+
form,
|
|
41
|
+
error,
|
|
42
|
+
disabled,
|
|
43
|
+
readOnly,
|
|
44
|
+
required,
|
|
45
|
+
fallback,
|
|
46
|
+
mappings,
|
|
47
|
+
value,
|
|
48
|
+
defaultValue,
|
|
49
|
+
onValueChange,
|
|
50
|
+
getValueText,
|
|
51
|
+
getTextContent = defaultGetSpinButtonTextContent,
|
|
52
|
+
placeholderChar,
|
|
53
|
+
defaultKeyboardValue,
|
|
54
|
+
...remaining
|
|
55
|
+
} = props;
|
|
56
|
+
|
|
57
|
+
const valueProps = {
|
|
58
|
+
value,
|
|
59
|
+
defaultValue,
|
|
60
|
+
} as SpinButtonUncontrolledValueOptions<HTMLDivElement>;
|
|
61
|
+
|
|
62
|
+
const { value: currentValue, spinButtonProps } = useSpinButton({
|
|
63
|
+
id,
|
|
64
|
+
ref,
|
|
65
|
+
min,
|
|
66
|
+
max,
|
|
67
|
+
minDigits,
|
|
68
|
+
maxDigits,
|
|
69
|
+
step,
|
|
70
|
+
form,
|
|
71
|
+
fallback,
|
|
72
|
+
mappings,
|
|
73
|
+
error,
|
|
74
|
+
disabled,
|
|
75
|
+
readOnly,
|
|
76
|
+
required,
|
|
77
|
+
...valueProps,
|
|
78
|
+
onValueChange,
|
|
79
|
+
getValueText,
|
|
80
|
+
getTextContent,
|
|
81
|
+
placeholderChar,
|
|
82
|
+
defaultKeyboardValue,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div {...remaining} {...spinButtonProps}>
|
|
87
|
+
{getTextContent({
|
|
88
|
+
min,
|
|
89
|
+
max,
|
|
90
|
+
minDigits,
|
|
91
|
+
maxDigits,
|
|
92
|
+
value: currentValue,
|
|
93
|
+
fallback,
|
|
94
|
+
placeholderChar,
|
|
95
|
+
})}
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
|
|
5
|
+
import { type KeyboardMovementContext } from "../movement/types.js";
|
|
6
|
+
import { DEFAULT_KEYBOARD_MOVEMENT_CONTEXT } from "../movement/useKeyboardMovementProvider.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @since 6.4.0
|
|
10
|
+
*/
|
|
11
|
+
export type SpinButtonGroupContext = KeyboardMovementContext;
|
|
12
|
+
|
|
13
|
+
const context = createContext<SpinButtonGroupContext>(
|
|
14
|
+
DEFAULT_KEYBOARD_MOVEMENT_CONTEXT
|
|
15
|
+
);
|
|
16
|
+
context.displayName = "SpinButtonGroup";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This should be used along with the `useSpinButtonGroupProvider` to link
|
|
20
|
+
* `SpinButton` components together. The next `SpinButton` will be focused as
|
|
21
|
+
* an value is typed to completion.
|
|
22
|
+
*
|
|
23
|
+
* @since 6.4.0
|
|
24
|
+
*/
|
|
25
|
+
export const { Provider: SpinButtonGroupProvider } = context;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @since 6.4.0
|
|
29
|
+
*/
|
|
30
|
+
export function useSpinButtonGroup(): Readonly<SpinButtonGroupContext> {
|
|
31
|
+
return useContext(context);
|
|
32
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getNumberOfDigits } from "../utils/getNumberOfDigits.js";
|
|
2
|
+
import {
|
|
3
|
+
type GetSpinButtonTextContentOptions,
|
|
4
|
+
type SpinButtonGetValueText,
|
|
5
|
+
} from "./types.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @since 6.4.0
|
|
9
|
+
*/
|
|
10
|
+
export const defaultSpinButtonGetValueText: SpinButtonGetValueText = (value) =>
|
|
11
|
+
value === null ? "No value selected" : undefined;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @since 6.4.0
|
|
15
|
+
*/
|
|
16
|
+
export function defaultGetSpinButtonTextContent(
|
|
17
|
+
options: GetSpinButtonTextContentOptions
|
|
18
|
+
): string {
|
|
19
|
+
const {
|
|
20
|
+
min,
|
|
21
|
+
value,
|
|
22
|
+
fallback,
|
|
23
|
+
placeholderChar = "0",
|
|
24
|
+
minDigits = fallback?.length ?? getNumberOfDigits(min),
|
|
25
|
+
} = options;
|
|
26
|
+
|
|
27
|
+
if (value === null) {
|
|
28
|
+
if (typeof fallback === "string") {
|
|
29
|
+
return fallback;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!minDigits) {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return "-".repeat(minDigits);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let text = `${value}`;
|
|
40
|
+
if (minDigits) {
|
|
41
|
+
text = text.padStart(minDigits, placeholderChar);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return text;
|
|
45
|
+
}
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AriaAttributes,
|
|
3
|
+
type FocusEvent,
|
|
4
|
+
type FormEvent,
|
|
5
|
+
type HTMLAttributes,
|
|
6
|
+
type KeyboardEvent,
|
|
7
|
+
type Ref,
|
|
8
|
+
type RefObject,
|
|
9
|
+
} from "react";
|
|
10
|
+
|
|
11
|
+
import { type FormComponentStates } from "../form/types.js";
|
|
12
|
+
import { type MinMaxRange, type UseStateInitializer } from "../types.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @since 6.4.0
|
|
16
|
+
*/
|
|
17
|
+
export type SpinButtonEventHandlers<E extends HTMLElement = HTMLDivElement> =
|
|
18
|
+
Pick<
|
|
19
|
+
HTMLAttributes<E>,
|
|
20
|
+
"onInput" | "onClick" | "onFocus" | "onBlur" | "onKeyDown"
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @since 6.4.0
|
|
25
|
+
*/
|
|
26
|
+
export type SpinButtonAriaAttributes = Pick<
|
|
27
|
+
AriaAttributes,
|
|
28
|
+
| "aria-required"
|
|
29
|
+
| "aria-invalid"
|
|
30
|
+
| "aria-readonly"
|
|
31
|
+
| "aria-disabled"
|
|
32
|
+
| "aria-valuemin"
|
|
33
|
+
| "aria-valuemax"
|
|
34
|
+
| "aria-valuenow"
|
|
35
|
+
| "aria-valuetext"
|
|
36
|
+
>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* This is a way to map a single character to a value within a spinbutton and
|
|
40
|
+
* was mostly added to support time inputs. The main example is:
|
|
41
|
+
*
|
|
42
|
+
* @example Day Period Mapping
|
|
43
|
+
* ```ts
|
|
44
|
+
* const AM_PM: SpinButtonCharacterValueMap = {
|
|
45
|
+
* a: 0,
|
|
46
|
+
* p: 1,
|
|
47
|
+
* };
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* **If the mapping is provided, all other input events are ignored**.
|
|
51
|
+
*
|
|
52
|
+
* @since 6.4.0
|
|
53
|
+
*/
|
|
54
|
+
export type SpinButtonCharacterValueMap = Readonly<Record<string, number>>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @since 6.4.0
|
|
58
|
+
*/
|
|
59
|
+
export type SpinButtonValue = number | null;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @since 6.4.0
|
|
63
|
+
*/
|
|
64
|
+
export type SpinButtonGetValueText = (
|
|
65
|
+
value: SpinButtonValue
|
|
66
|
+
) => string | undefined;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @since 6.4.0
|
|
70
|
+
*/
|
|
71
|
+
export type SpinButtonChangeEvent<E extends HTMLElement = HTMLDivElement> =
|
|
72
|
+
| FormEvent<E>
|
|
73
|
+
| KeyboardEvent<E>
|
|
74
|
+
| FocusEvent<E>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @since 6.4.0
|
|
78
|
+
*/
|
|
79
|
+
export type SpinButtonChangeReason =
|
|
80
|
+
| "change"
|
|
81
|
+
| "type"
|
|
82
|
+
| "typed-to-completion"
|
|
83
|
+
| "cleared";
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @since 6.4.0
|
|
87
|
+
*/
|
|
88
|
+
export interface SpinButtonChangeEventOptions<
|
|
89
|
+
E extends HTMLElement = HTMLDivElement,
|
|
90
|
+
> {
|
|
91
|
+
event: SpinButtonChangeEvent<E>;
|
|
92
|
+
value: SpinButtonValue;
|
|
93
|
+
reason: SpinButtonChangeReason;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* This callback will be fired whenever the spinbutton value has changed.
|
|
98
|
+
*
|
|
99
|
+
* The `reason` will be "typed-to-completion"` when:
|
|
100
|
+
* - the `value` is not `null` and:
|
|
101
|
+
* - the user uses the `ArrowUp`, `ArrowDown`, `Home`, `End`, `PageUp`, or
|
|
102
|
+
* `PageDown` keys to change the value
|
|
103
|
+
* - the user has typed the max amount of digits based on the `max` value
|
|
104
|
+
*
|
|
105
|
+
* Examples with: `min=0` and `max=12`
|
|
106
|
+
* - `1` -> (1, false)
|
|
107
|
+
* - `Tab` or blur (1, true)
|
|
108
|
+
* - `1` -> (11, true)
|
|
109
|
+
* - `0` - (1, false)
|
|
110
|
+
* - `Tab` or blur (0, true)
|
|
111
|
+
* - `3` (3, true)
|
|
112
|
+
* - `3` -> (3, true)
|
|
113
|
+
* - there are no more characters that could have been typed
|
|
114
|
+
*
|
|
115
|
+
*
|
|
116
|
+
* @since 6.4.0
|
|
117
|
+
*/
|
|
118
|
+
export type SpinButtonValueChange<E extends HTMLElement = HTMLDivElement> = (
|
|
119
|
+
options: SpinButtonChangeEventOptions<E>
|
|
120
|
+
) => void;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @since 6.4.0
|
|
124
|
+
*/
|
|
125
|
+
export interface SpinButtonUnknownValueOptions<
|
|
126
|
+
E extends HTMLElement = HTMLDivElement,
|
|
127
|
+
> {
|
|
128
|
+
value?: SpinButtonValue;
|
|
129
|
+
defaultValue?: UseStateInitializer<SpinButtonValue>;
|
|
130
|
+
onValueChange?: SpinButtonValueChange<E>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @since 6.4.0
|
|
135
|
+
*/
|
|
136
|
+
export interface SpinButtonControlledValueOptions<
|
|
137
|
+
E extends HTMLElement = HTMLDivElement,
|
|
138
|
+
> {
|
|
139
|
+
value: SpinButtonValue;
|
|
140
|
+
defaultValue?: never;
|
|
141
|
+
onValueChange: SpinButtonValueChange<E>;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @since 6.4.0
|
|
146
|
+
*/
|
|
147
|
+
export interface SpinButtonUncontrolledValueOptions<
|
|
148
|
+
E extends HTMLElement = HTMLDivElement,
|
|
149
|
+
> {
|
|
150
|
+
value?: never;
|
|
151
|
+
defaultValue?: UseStateInitializer<SpinButtonValue>;
|
|
152
|
+
onValueChange?: SpinButtonValueChange<E>;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @since 6.4.0
|
|
157
|
+
*/
|
|
158
|
+
export type SpinButtonValueOptions<E extends HTMLElement = HTMLDivElement> =
|
|
159
|
+
| SpinButtonControlledValueOptions<E>
|
|
160
|
+
| SpinButtonUncontrolledValueOptions<E>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @since 6.4.0
|
|
164
|
+
*/
|
|
165
|
+
export interface SpinButtonDigitRangeOptions {
|
|
166
|
+
/**
|
|
167
|
+
* This is the minimum number of digits that should be shown in the spin
|
|
168
|
+
* button as the user is typing. If the current value is less than this
|
|
169
|
+
* value, the {@link placeholderChar} will be used as a `padStart` value.
|
|
170
|
+
*
|
|
171
|
+
* @example Get Text Content Example
|
|
172
|
+
* ```ts
|
|
173
|
+
* const textContent1 = getTextContent({
|
|
174
|
+
* value: null,
|
|
175
|
+
* fallback: "HH",
|
|
176
|
+
* placeholderChar: "0",
|
|
177
|
+
* });
|
|
178
|
+
* // ^ textContent1 === "HH"
|
|
179
|
+
*
|
|
180
|
+
* const textContent2 = getTextContent({
|
|
181
|
+
* value: 3,
|
|
182
|
+
* fallback: "HH",
|
|
183
|
+
* placeholderChar: "0",
|
|
184
|
+
* });
|
|
185
|
+
* // ^ textContent2 === "03"
|
|
186
|
+
*
|
|
187
|
+
* const textContent3 = getTextContent({
|
|
188
|
+
* value: 12,
|
|
189
|
+
* fallback: "HH",
|
|
190
|
+
* placeholderChar: "0",
|
|
191
|
+
* });
|
|
192
|
+
* // ^ textContent3 === "12"
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @example Year Example
|
|
196
|
+
* ```ts
|
|
197
|
+
* const textContent1 = getTextContent({
|
|
198
|
+
* value: null,
|
|
199
|
+
* fallback: "YYYY",
|
|
200
|
+
* minDigits: 4,
|
|
201
|
+
* });
|
|
202
|
+
* // ^ textContent1 === "YYYY"
|
|
203
|
+
*
|
|
204
|
+
* const textContent2 = getTextContent({
|
|
205
|
+
* value: 2,
|
|
206
|
+
* fallback: "YYYY",
|
|
207
|
+
* minDigits: 4,
|
|
208
|
+
* });
|
|
209
|
+
* // ^ textContent2 === "0002"
|
|
210
|
+
*
|
|
211
|
+
* const textContent3 = getTextContent({
|
|
212
|
+
* value: 200,
|
|
213
|
+
* fallback: "YYYY",
|
|
214
|
+
* minDigits: 4,
|
|
215
|
+
* });
|
|
216
|
+
* // ^ textContent3 === "0200"
|
|
217
|
+
*
|
|
218
|
+
* const textContent4 = getTextContent({
|
|
219
|
+
* value: 2025,
|
|
220
|
+
* fallback: "YYYY",
|
|
221
|
+
* minDigits: 4,
|
|
222
|
+
* });
|
|
223
|
+
* // ^ textContent4 === "2025"
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* @see {@link SpinButtonTextPlaceholderOptions.placeholderChar}
|
|
227
|
+
* @defaultValue `fallback?.length ?? getNumberOfDigits(min)`
|
|
228
|
+
*/
|
|
229
|
+
minDigits?: number;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* This is the maximum number of digits that should be shown in the spin
|
|
233
|
+
* button as the user is typing and is used to determine if the user has
|
|
234
|
+
* `"typed-to-completion"`.
|
|
235
|
+
*
|
|
236
|
+
* @example Year Example
|
|
237
|
+
* ```tsx
|
|
238
|
+
* // this _could_ also be 9999
|
|
239
|
+
* const max = undefined;
|
|
240
|
+
* const maxDigits = 4;
|
|
241
|
+
*
|
|
242
|
+
* // if the current value is `null` and the user types `2`
|
|
243
|
+
* onValueChange({
|
|
244
|
+
* event,
|
|
245
|
+
* reason: "change",
|
|
246
|
+
* nextValue: 2,
|
|
247
|
+
* });
|
|
248
|
+
*
|
|
249
|
+
* // if the current value is `2` and the user types `0`
|
|
250
|
+
* onValueChange({
|
|
251
|
+
* event,
|
|
252
|
+
* reason: "change",
|
|
253
|
+
* nextValue: 20,
|
|
254
|
+
* });
|
|
255
|
+
*
|
|
256
|
+
* // if the current value is `20` and the user types `2`
|
|
257
|
+
* onValueChange({
|
|
258
|
+
* event,
|
|
259
|
+
* reason: "change",
|
|
260
|
+
* nextValue: 202,
|
|
261
|
+
* });
|
|
262
|
+
*
|
|
263
|
+
* // if the current value is `202` and the user types `5`:
|
|
264
|
+
* onValueChange({
|
|
265
|
+
* event,
|
|
266
|
+
* reason: "typed-to-completion",
|
|
267
|
+
* nextValue: 2025,
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* @defaultValue `getNumberOfDigits(max)`
|
|
272
|
+
*/
|
|
273
|
+
maxDigits?: number;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @since 6.4.0
|
|
278
|
+
*/
|
|
279
|
+
export interface SpinButtonRangeOptions
|
|
280
|
+
extends Partial<MinMaxRange>, SpinButtonDigitRangeOptions {}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @since 6.4.0
|
|
284
|
+
*/
|
|
285
|
+
export interface SpinButtonTextPlaceholderOptions extends SpinButtonRangeOptions {
|
|
286
|
+
/**
|
|
287
|
+
* An optional fallback value to display when the spin button's value is
|
|
288
|
+
* `null`. For example: if the spin button is used to set the specific hour
|
|
289
|
+
* in a time field, set the fallback to `"HH"` to show that until the user
|
|
290
|
+
* has typed a value.
|
|
291
|
+
*/
|
|
292
|
+
fallback?: string;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* This is the character to use to fill the remaining number of digits to
|
|
296
|
+
* display in the spin button.
|
|
297
|
+
*
|
|
298
|
+
* @see {@link minDigits}
|
|
299
|
+
* @defaultValue `"0"`
|
|
300
|
+
*/
|
|
301
|
+
placeholderChar?: string;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @since 6.4.0
|
|
306
|
+
*/
|
|
307
|
+
export interface GetSpinButtonTextContentOptions extends SpinButtonTextPlaceholderOptions {
|
|
308
|
+
/**
|
|
309
|
+
* The current value in the spin button to convert to text. **This will be
|
|
310
|
+
* called with numbers outside of the allowed range**.
|
|
311
|
+
*/
|
|
312
|
+
value: SpinButtonValue;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @since 6.4.0
|
|
317
|
+
*/
|
|
318
|
+
export type GetSpinButtonTextContent = (
|
|
319
|
+
options: GetSpinButtonTextContentOptions
|
|
320
|
+
) => string;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* @since 6.4.0
|
|
324
|
+
*/
|
|
325
|
+
export type GetSpinButtonValueText = (
|
|
326
|
+
value: SpinButtonValue
|
|
327
|
+
) => string | undefined;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* @since 6.4.0
|
|
331
|
+
*/
|
|
332
|
+
export interface SpinButtonFormStates extends Omit<
|
|
333
|
+
FormComponentStates,
|
|
334
|
+
"active"
|
|
335
|
+
> {
|
|
336
|
+
required?: boolean;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* @since 6.4.0
|
|
341
|
+
*/
|
|
342
|
+
export interface SpinButtonOptions<E extends HTMLElement = HTMLDivElement>
|
|
343
|
+
extends
|
|
344
|
+
SpinButtonEventHandlers<E>,
|
|
345
|
+
SpinButtonUnknownValueOptions<E>,
|
|
346
|
+
SpinButtonFormStates,
|
|
347
|
+
SpinButtonTextPlaceholderOptions {
|
|
348
|
+
/**
|
|
349
|
+
* @defaultValue `"spinbutton-" + useId()`
|
|
350
|
+
*/
|
|
351
|
+
id?: string;
|
|
352
|
+
ref?: Ref<E>;
|
|
353
|
+
form?: string;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* The default value to use when the increment or decrement action is fired
|
|
357
|
+
* from the spinbutton through keyboard events before a value has been set.
|
|
358
|
+
* So when the increment action is fired, this will be
|
|
359
|
+
* `defaultKeyboardValue + 1`.
|
|
360
|
+
*
|
|
361
|
+
* @defaultValue `min ?? max ?? 0`
|
|
362
|
+
*/
|
|
363
|
+
defaultKeyboardValue?: UseStateInitializer<number>;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* NOTE: This isn't actually supported yet
|
|
367
|
+
*
|
|
368
|
+
* @defaultValue `1`
|
|
369
|
+
*/
|
|
370
|
+
step?: number;
|
|
371
|
+
|
|
372
|
+
/** @see {@link SpinButtonCharacterValueMap} */
|
|
373
|
+
mappings?: SpinButtonCharacterValueMap;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Used to provide an `aria-valuenow` string for a specific value in the
|
|
377
|
+
* `SpinButton`.
|
|
378
|
+
*
|
|
379
|
+
* @defaultValue `(value) => value === null ? "No value selected" : undefined`
|
|
380
|
+
*/
|
|
381
|
+
getValueText?: GetSpinButtonValueText;
|
|
382
|
+
|
|
383
|
+
getTextContent?: GetSpinButtonTextContent;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* @since 6.4.0
|
|
388
|
+
*/
|
|
389
|
+
export interface ProvidedSpinButtonProps<E extends HTMLElement = HTMLDivElement>
|
|
390
|
+
extends Required<SpinButtonEventHandlers<E>>, SpinButtonAriaAttributes {
|
|
391
|
+
id: string;
|
|
392
|
+
ref: Ref<E>;
|
|
393
|
+
role: "spinbutton";
|
|
394
|
+
inputMode: "numeric";
|
|
395
|
+
spellCheck: boolean;
|
|
396
|
+
autoCapitalize: "none";
|
|
397
|
+
autoCorrect: "off";
|
|
398
|
+
tabIndex: number | undefined;
|
|
399
|
+
contentEditable: boolean | undefined;
|
|
400
|
+
suppressContentEditableWarning: boolean;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* @since 6.4.0
|
|
405
|
+
*/
|
|
406
|
+
export interface SpinButtonImplementation<
|
|
407
|
+
E extends HTMLElement = HTMLDivElement,
|
|
408
|
+
> {
|
|
409
|
+
value: SpinButtonValue;
|
|
410
|
+
setValue: (value: SpinButtonValue) => void;
|
|
411
|
+
spinButtonRef: RefObject<E>;
|
|
412
|
+
spinButtonProps: Readonly<ProvidedSpinButtonProps<E>>;
|
|
413
|
+
}
|