@react-md/core 6.3.4 → 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/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.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 +37 -29
- 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/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 +8 -3
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef,
|
|
3
|
+
import { forwardRef, useRef } from "react";
|
|
4
|
+
import { useDevEffect } from "../utils/useDevEffect.js";
|
|
4
5
|
import { Link } from "./Link.js";
|
|
5
6
|
import { skipToMainContent } from "./styles.js";
|
|
6
7
|
const noop = ()=>{
|
|
@@ -44,28 +45,25 @@ const getMainElement = (mainId)=>mainId ? document.getElementById(mainId) : docu
|
|
|
44
45
|
// want to warn the developer about missing main element in development
|
|
45
46
|
// immediately to help prevent errors, but in production this can be lazy
|
|
46
47
|
// initialized only once a keyboard user focuses and clicks this element
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
message += ` with an id of "${
|
|
56
|
-
if (foundMainId) {
|
|
57
|
-
message += ` but a main element was found with an id of "${foundMainId}".`;
|
|
58
|
-
}
|
|
48
|
+
useDevEffect(()=>{
|
|
49
|
+
mainNodeRef.current = getMainElement(mainId);
|
|
50
|
+
if (!mainNodeRef.current) {
|
|
51
|
+
const foundMainId = document.querySelector('main,[role="main"]')?.id;
|
|
52
|
+
let message = `Unable to find a main element to focus`;
|
|
53
|
+
if (mainId) {
|
|
54
|
+
message += ` with an id of "${mainId}"`;
|
|
55
|
+
if (foundMainId) {
|
|
56
|
+
message += ` but a main element was found with an id of "${foundMainId}".`;
|
|
59
57
|
}
|
|
60
|
-
if (!foundMainId) {
|
|
61
|
-
message += '. There should be at least one <main> element or an element with role="main" on the page for accessibility.';
|
|
62
|
-
}
|
|
63
|
-
throw new Error(message);
|
|
64
58
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
if (!foundMainId) {
|
|
60
|
+
message += '. There should be at least one <main> element or an element with role="main" on the page for accessibility.';
|
|
61
|
+
}
|
|
62
|
+
throw new Error(message);
|
|
63
|
+
}
|
|
64
|
+
}, [
|
|
65
|
+
mainId
|
|
66
|
+
]);
|
|
69
67
|
return /*#__PURE__*/ _jsx(Link, {
|
|
70
68
|
...remaining,
|
|
71
69
|
id: id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/link/SkipToMainContent.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, forwardRef,
|
|
1
|
+
{"version":3,"sources":["../../src/link/SkipToMainContent.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, forwardRef, useRef } from \"react\";\n\nimport { useDevEffect } from \"../utils/useDevEffect.js\";\nimport { Link, type LinkProps } from \"./Link.js\";\nimport {\n type SkipToMainContentClassNameOptions,\n skipToMainContent,\n} from \"./styles.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\nconst getMainElement = (mainId: string): HTMLElement | null =>\n mainId\n ? document.getElementById(mainId)\n : document.querySelector<HTMLElement>('main,[role=\"main\"]');\n\n/**\n * @since 6.0.0 The `mainId` is optional\n */\nexport interface SkipToMainContentProps\n extends Omit<LinkProps, \"href\">, SkipToMainContentClassNameOptions {\n /**\n * @since 6.0.0 Changed default value from `\"skip-to-main-content\"`\n * @defaultValue `\"skip-to-main\"`\n */\n id?: string;\n\n /**\n * An optional id for the main element. When this is not provided, the main\n * element will be found by:\n *\n * ```ts\n * document.querySelector('main,[role=\"main\"]');\n * ```\n */\n mainId?: string;\n\n /**\n * @defaultValue `\"Skip to main content\"`\n */\n children?: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * This component is used to allow keyboard users a quick way to skip directly\n * to the main content instead of needing to tab through all navigation items.\n *\n * This component should not be used if using the LayoutAppBar component since\n * it is already built-in.\n *\n * @example Simple Example\n * ```tsx\n * import { AppBar } from \"@react-md/core/app-bar/AppBar\";\n * import { SkipToMainContent } from \"@react-md/core/link/SkipToMainContent\";\n * import { type ReactElement } from \"react\";\n *\n * export default function SimpleSkipToMainContentExample(): ReactElement {\n * return (\n * <AppBar style={{ position: \"relative\" }}>\n * <SkipToMainContent />\n * </AppBar>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/skip-to-main-content | SkipToMainContent Demos}\n * @since 6.0.0 Changed the default `id` from `\"skip-to-main-content\"` to\n * `\"skip-to-main\"`.\n * @since 6.0.0 The `mainId` prop is optional\n * @since 6.0.0 Throws an error after rendering if no main element can be found\n * with the provided `mainId` in development mode. The previous behavior would\n * only log an error after being clicked.\n */\nexport const SkipToMainContent = forwardRef<\n HTMLAnchorElement,\n SkipToMainContentProps\n>(function SkipToMainContent(props, ref) {\n const {\n id = \"skip-to-main\",\n className,\n children = \"Skip to main content\",\n mainId = \"\",\n onClick = noop,\n unstyled,\n ...remaining\n } = props;\n\n const mainNodeRef = useRef<HTMLElement | null>(null);\n // want to warn the developer about missing main element in development\n // immediately to help prevent errors, but in production this can be lazy\n // initialized only once a keyboard user focuses and clicks this element\n useDevEffect(() => {\n mainNodeRef.current = getMainElement(mainId);\n\n if (!mainNodeRef.current) {\n const foundMainId = document.querySelector('main,[role=\"main\"]')?.id;\n let message = `Unable to find a main element to focus`;\n if (mainId) {\n message += ` with an id of \"${mainId}\"`;\n\n if (foundMainId) {\n message += ` but a main element was found with an id of \"${foundMainId}\".`;\n }\n }\n if (!foundMainId) {\n message +=\n '. There should be at least one <main> element or an element with role=\"main\" on the page for accessibility.';\n }\n\n throw new Error(message);\n }\n }, [mainId]);\n\n return (\n <Link\n {...remaining}\n id={id}\n ref={ref}\n href={`#${mainId}`}\n onClick={(event) => {\n onClick(event);\n if (event.isPropagationStopped()) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n\n // see comment above useEffect\n mainNodeRef.current ||= getMainElement(mainId);\n mainNodeRef.current?.focus();\n }}\n className={skipToMainContent({\n unstyled,\n className,\n })}\n >\n {children}\n </Link>\n );\n});\n"],"names":["forwardRef","useRef","useDevEffect","Link","skipToMainContent","noop","getMainElement","mainId","document","getElementById","querySelector","SkipToMainContent","props","ref","id","className","children","onClick","unstyled","remaining","mainNodeRef","current","foundMainId","message","Error","href","event","isPropagationStopped","preventDefault","stopPropagation","focus"],"mappings":"AAAA;;AAEA,SAAyBA,UAAU,EAAEC,MAAM,QAAQ,QAAQ;AAE3D,SAASC,YAAY,QAAQ,2BAA2B;AACxD,SAASC,IAAI,QAAwB,YAAY;AACjD,SAEEC,iBAAiB,QACZ,cAAc;AAErB,MAAMC,OAAO;AACX,aAAa;AACf;AAEA,MAAMC,iBAAiB,CAACC,SACtBA,SACIC,SAASC,cAAc,CAACF,UACxBC,SAASE,aAAa,CAAc;AA6B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GACD,OAAO,MAAMC,kCAAoBX,WAG/B,SAASW,kBAAkBC,KAAK,EAAEC,GAAG;IACrC,MAAM,EACJC,KAAK,cAAc,EACnBC,SAAS,EACTC,WAAW,sBAAsB,EACjCT,SAAS,EAAE,EACXU,UAAUZ,IAAI,EACda,QAAQ,EACR,GAAGC,WACJ,GAAGP;IAEJ,MAAMQ,cAAcnB,OAA2B;IAC/C,uEAAuE;IACvE,yEAAyE;IACzE,wEAAwE;IACxEC,aAAa;QACXkB,YAAYC,OAAO,GAAGf,eAAeC;QAErC,IAAI,CAACa,YAAYC,OAAO,EAAE;YACxB,MAAMC,cAAcd,SAASE,aAAa,CAAC,uBAAuBI;YAClE,IAAIS,UAAU,CAAC,sCAAsC,CAAC;YACtD,IAAIhB,QAAQ;gBACVgB,WAAW,CAAC,gBAAgB,EAAEhB,OAAO,CAAC,CAAC;gBAEvC,IAAIe,aAAa;oBACfC,WAAW,CAAC,6CAA6C,EAAED,YAAY,EAAE,CAAC;gBAC5E;YACF;YACA,IAAI,CAACA,aAAa;gBAChBC,WACE;YACJ;YAEA,MAAM,IAAIC,MAAMD;QAClB;IACF,GAAG;QAAChB;KAAO;IAEX,qBACE,KAACJ;QACE,GAAGgB,SAAS;QACbL,IAAIA;QACJD,KAAKA;QACLY,MAAM,CAAC,CAAC,EAAElB,QAAQ;QAClBU,SAAS,CAACS;YACRT,QAAQS;YACR,IAAIA,MAAMC,oBAAoB,IAAI;gBAChC;YACF;YAEAD,MAAME,cAAc;YACpBF,MAAMG,eAAe;YAErB,8BAA8B;YAC9BT,YAAYC,OAAO,KAAKf,eAAeC;YACvCa,YAAYC,OAAO,EAAES;QACvB;QACAf,WAAWX,kBAAkB;YAC3Bc;YACAH;QACF;kBAECC;;AAGP,GAAG"}
|
package/dist/list/List.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/list/List.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type ListClassNameOptions, list } from \"./listStyles.js\";\n\nexport type ListElement = HTMLUListElement | HTMLOListElement;\n\n/**\n * @since 6.3.1 Extends the ListClassNameOptions\n */\nexport interface ListProps\n extends HTMLAttributes<ListElement
|
|
1
|
+
{"version":3,"sources":["../../src/list/List.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type ListClassNameOptions, list } from \"./listStyles.js\";\n\nexport type ListElement = HTMLUListElement | HTMLOListElement;\n\n/**\n * @since 6.3.1 Extends the ListClassNameOptions\n */\nexport interface ListProps\n extends HTMLAttributes<ListElement>, ListClassNameOptions {\n /**\n * @defaultValue `\"none\"`\n */\n role?: HTMLAttributes<ListElement>[\"role\"];\n\n /**\n * Set this to `true` to render as `<ol>` instead of `<ul>` when the children\n * are in a specific order. For example: steps within a recipe.\n *\n * @defaultValue `false`\n */\n ordered?: boolean;\n}\n\n/**\n * The `List` component is used to render a collection of clickable actions\n * vertically or horizontally and does not include the default `ol`/`ul` styles.\n *\n * @example Simple Example\n * ```tsx\n * import { List } from \"@react-md/core/list/List\";\n * import { ListItem } from \"@react-md/core/list/ListItem\";\n * import { ListItemLink } from \"@react-md/core/list/ListItemLink\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <List>\n * <ListItem\n * onClick={() => {\n * // do something\n * }}\n * >\n * Item 1\n * </ListItem>\n * <ListItem\n * onClick={() => {\n * // do something\n * }}\n * >\n * Item 2\n * </ListItem>\n * <ListItem\n * onClick={() => {\n * // do something\n * }}\n * >\n * Item 3\n * </ListItem>\n * <ListItemLink href=\"/some-route\">Link Example</ListItemLink>\n * </List>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/list | List Demos}\n */\nexport const List = forwardRef<ListElement, ListProps>(\n function List(props, ref) {\n const {\n className,\n children,\n role = \"none\",\n dense = false,\n ordered = false,\n horizontal = false,\n ...remaining\n } = props;\n const Component = (ordered ? \"ol\" : \"ul\") as \"ul\";\n return (\n <Component\n {...remaining}\n ref={ref}\n role={role}\n className={list({\n dense,\n horizontal,\n className,\n })}\n >\n {children}\n </Component>\n );\n }\n);\n"],"names":["forwardRef","list","List","props","ref","className","children","role","dense","ordered","horizontal","remaining","Component"],"mappings":";AAAA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAAoCC,IAAI,QAAQ,kBAAkB;AAuBlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CC,GACD,OAAO,MAAMC,qBAAOF,WAClB,SAASE,KAAKC,KAAK,EAAEC,GAAG;IACtB,MAAM,EACJC,SAAS,EACTC,QAAQ,EACRC,OAAO,MAAM,EACbC,QAAQ,KAAK,EACbC,UAAU,KAAK,EACfC,aAAa,KAAK,EAClB,GAAGC,WACJ,GAAGR;IACJ,MAAMS,YAAaH,UAAU,OAAO;IACpC,qBACE,KAACG;QACE,GAAGD,SAAS;QACbP,KAAKA;QACLG,MAAMA;QACNF,WAAWJ,KAAK;YACdO;YACAE;YACAL;QACF;kBAECC;;AAGP,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/list/ListItem.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport { ListItemChildren } from \"./ListItemChildren.js\";\nimport { getListItemHeight } from \"./getListItemHeight.js\";\nimport {\n type BaseListItemClassNameOptions,\n listItem,\n} from \"./listItemStyles.js\";\nimport { type ListItemChildrenProps } from \"./types.js\";\n\n/**\n * @since 6.0.0 Renamed `threeLines` to `multiline` since it can\n * support more than three lines of text.\n * @since 6.3.1 Extends the BaseListItemClassNameOptions\n */\nexport interface ListItemProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/list/ListItem.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport { ListItemChildren } from \"./ListItemChildren.js\";\nimport { getListItemHeight } from \"./getListItemHeight.js\";\nimport {\n type BaseListItemClassNameOptions,\n listItem,\n} from \"./listItemStyles.js\";\nimport { type ListItemChildrenProps } from \"./types.js\";\n\n/**\n * @since 6.0.0 Renamed `threeLines` to `multiline` since it can\n * support more than three lines of text.\n * @since 6.3.1 Extends the BaseListItemClassNameOptions\n */\nexport interface ListItemProps\n extends\n HTMLAttributes<HTMLLIElement>,\n ListItemChildrenProps,\n BaseListItemClassNameOptions,\n ComponentWithRippleProps {\n /**\n * @defaultValue `\"button\"`\n */\n role?: HTMLAttributes<HTMLLIElement>[\"role\"];\n\n /**\n * @defaultValue `disabled ? -1 : 0`\n */\n tabIndex?: number;\n\n /**\n * Set this to `false` if the list item should not gain the interaction\n * states: hover, focus, press, etc. This is kind of like being disabled\n * without the disabled styles being applied.\n *\n * @defaultValue `role === \"presentation\"`\n */\n presentational?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * The `ListItem` is used to create a clickable/focusable button within a\n * `List` and removes the normal `<li>` styles.\n *\n * @example Simple Example\n * ```tsx\n * import { List } from \"@react-md/core/list/List\";\n * import { ListItem } from \"@react-md/core/list/ListItem\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <List>\n * <ListItem\n * onClick={() => {\n * // do something\n * }}\n * >\n * Item 1\n * </ListItem>\n * <ListItem\n * onClick={() => {\n * // do something\n * }}\n * secondaryText={<span>Some <strong>additional</strong> content.</span>}\n * >\n * Item 2\n * </ListItem>\n * </List>\n * );\n * );\n * }\n * ```\n *\n * @example Applying Addons Example\n * ```tsx\n * import { List } from \"@react-md/core/list/List\";\n * import { ListItem } from \"@react-md/core/list/ListItem\";\n * import FavoriteIcon from \"@react-md/material-icons/FavoriteIcon\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <List>\n * <ListItem leftAddon={<FavoriteIcon />}>\n * Item 1\n * </ListItem>\n * <ListItem rightAddon={<FavoriteIcon />}>\n * Item 2\n * </ListItem>\n * <ListItem\n * leftAddon={<FavoriteIcon />}\n * rightAddon={<img alt=\"\" src=\"/some-image.png\" />}\n * rightAddonType=\"media\"\n * >\n * Item 3\n * </ListItem>\n * </List>\n * );\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/list | List Demos}\n */\nexport const ListItem = forwardRef<HTMLLIElement, ListItemProps>(\n function ListItem(props, ref) {\n const {\n className,\n textProps,\n textClassName,\n secondaryTextClassName,\n primaryText,\n secondaryText,\n secondaryTextProps,\n disableTextChildren = false,\n height: propHeight,\n leftAddon,\n leftAddonType,\n leftAddonPosition,\n leftAddonClassName,\n leftAddonForceWrap,\n rightAddon,\n rightAddonType,\n rightAddonPosition,\n rightAddonClassName,\n rightAddonForceWrap,\n disableLeftAddonSpacing,\n disableLeftAddonCenteredMedia,\n disableRightAddonCenteredMedia,\n multiline = false,\n disabled = false,\n disableRipple,\n disabledOpacity = false,\n role = \"button\",\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n tabIndex: propTabIndex,\n children: propChildren,\n presentational = role === \"presentation\",\n ...remaining\n } = props;\n\n let tabIndex = propTabIndex;\n if (!presentational && typeof tabIndex === \"undefined\") {\n tabIndex = disabled ? -1 : 0;\n }\n\n const { pressedClassName, ripples, handlers } = useElementInteraction({\n mode: disableRipple ? \"none\" : undefined,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disabled: disabled || presentational,\n });\n const children = useHigherContrastChildren(\n propChildren,\n !disableTextChildren\n );\n\n const height = getListItemHeight({\n height: propHeight,\n leftAddon,\n leftAddonType,\n rightAddon,\n rightAddonType,\n secondaryText,\n });\n\n return (\n <li\n {...remaining}\n {...handlers}\n aria-disabled={disabled || undefined}\n ref={ref}\n role={role}\n tabIndex={tabIndex}\n className={listItem({\n className,\n height,\n disabled,\n disabledOpacity,\n multiline,\n clickable: !presentational,\n pressedClassName,\n })}\n >\n <ListItemChildren\n multiline={multiline}\n textClassName={textClassName}\n secondaryTextClassName={secondaryTextClassName}\n disableTextChildren={disableTextChildren}\n primaryText={primaryText}\n textProps={textProps}\n secondaryText={secondaryText}\n secondaryTextProps={secondaryTextProps}\n leftAddon={leftAddon}\n leftAddonType={leftAddonType}\n leftAddonPosition={leftAddonPosition}\n leftAddonClassName={leftAddonClassName}\n leftAddonForceWrap={leftAddonForceWrap}\n rightAddon={rightAddon}\n rightAddonType={rightAddonType}\n rightAddonPosition={rightAddonPosition}\n rightAddonClassName={rightAddonClassName}\n rightAddonForceWrap={rightAddonForceWrap}\n disableLeftAddonSpacing={disableLeftAddonSpacing}\n disableLeftAddonCenteredMedia={disableLeftAddonCenteredMedia}\n disableRightAddonCenteredMedia={disableRightAddonCenteredMedia}\n >\n {children}\n </ListItemChildren>\n {ripples}\n </li>\n );\n }\n);\n"],"names":["forwardRef","useElementInteraction","useHigherContrastChildren","ListItemChildren","getListItemHeight","listItem","ListItem","props","ref","className","textProps","textClassName","secondaryTextClassName","primaryText","secondaryText","secondaryTextProps","disableTextChildren","height","propHeight","leftAddon","leftAddonType","leftAddonPosition","leftAddonClassName","leftAddonForceWrap","rightAddon","rightAddonType","rightAddonPosition","rightAddonClassName","rightAddonForceWrap","disableLeftAddonSpacing","disableLeftAddonCenteredMedia","disableRightAddonCenteredMedia","multiline","disabled","disableRipple","disabledOpacity","role","onBlur","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave","onDragStart","onTouchStart","onTouchEnd","onTouchMove","tabIndex","propTabIndex","children","propChildren","presentational","remaining","pressedClassName","ripples","handlers","mode","undefined","li","aria-disabled","clickable"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,QAAQ,QAAQ;AAGxD,SAASC,qBAAqB,QAAQ,0CAA0C;AAChF,SAASC,yBAAyB,QAAQ,8CAA8C;AACxF,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAEEC,QAAQ,QACH,sBAAsB;AAkC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkEC,GACD,OAAO,MAAMC,yBAAWN,WACtB,SAASM,SAASC,KAAK,EAAEC,GAAG;IAC1B,MAAM,EACJC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,sBAAsB,EACtBC,WAAW,EACXC,aAAa,EACbC,kBAAkB,EAClBC,sBAAsB,KAAK,EAC3BC,QAAQC,UAAU,EAClBC,SAAS,EACTC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,kBAAkB,EAClBC,UAAU,EACVC,cAAc,EACdC,kBAAkB,EAClBC,mBAAmB,EACnBC,mBAAmB,EACnBC,uBAAuB,EACvBC,6BAA6B,EAC7BC,8BAA8B,EAC9BC,YAAY,KAAK,EACjBC,WAAW,KAAK,EAChBC,aAAa,EACbC,kBAAkB,KAAK,EACvBC,OAAO,QAAQ,EACfC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,WAAW,EACXC,SAAS,EACTC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,WAAW,EACXC,UAAUC,YAAY,EACtBC,UAAUC,YAAY,EACtBC,iBAAiBhB,SAAS,cAAc,EACxC,GAAGiB,WACJ,GAAG9C;IAEJ,IAAIyC,WAAWC;IACf,IAAI,CAACG,kBAAkB,OAAOJ,aAAa,aAAa;QACtDA,WAAWf,WAAW,CAAC,IAAI;IAC7B;IAEA,MAAM,EAAEqB,gBAAgB,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGvD,sBAAsB;QACpEwD,MAAMvB,gBAAgB,SAASwB;QAC/BrB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAd,UAAUA,YAAYmB;IACxB;IACA,MAAMF,WAAWhD,0BACfiD,cACA,CAACnC;IAGH,MAAMC,SAASb,kBAAkB;QAC/Ba,QAAQC;QACRC;QACAC;QACAI;QACAC;QACAX;IACF;IAEA,qBACE,MAAC6C;QACE,GAAGN,SAAS;QACZ,GAAGG,QAAQ;QACZI,iBAAe3B,YAAYyB;QAC3BlD,KAAKA;QACL4B,MAAMA;QACNY,UAAUA;QACVvC,WAAWJ,SAAS;YAClBI;YACAQ;YACAgB;YACAE;YACAH;YACA6B,WAAW,CAACT;YACZE;QACF;;0BAEA,KAACnD;gBACC6B,WAAWA;gBACXrB,eAAeA;gBACfC,wBAAwBA;gBACxBI,qBAAqBA;gBACrBH,aAAaA;gBACbH,WAAWA;gBACXI,eAAeA;gBACfC,oBAAoBA;gBACpBI,WAAWA;gBACXC,eAAeA;gBACfC,mBAAmBA;gBACnBC,oBAAoBA;gBACpBC,oBAAoBA;gBACpBC,YAAYA;gBACZC,gBAAgBA;gBAChBC,oBAAoBA;gBACpBC,qBAAqBA;gBACrBC,qBAAqBA;gBACrBC,yBAAyBA;gBACzBC,+BAA+BA;gBAC/BC,gCAAgCA;0BAE/BmB;;YAEFK;;;AAGP,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/list/ListItemAddon.tsx"],"sourcesContent":["import { type ReactElement, type ReactNode } from \"react\";\n\nimport {\n TextIconSpacing,\n type TextIconSpacingProps,\n} from \"../icon/TextIconSpacing.js\";\nimport {\n type ListItemAddonClassNameOptions,\n listItemAddon,\n} from \"./listItemStyles.js\";\n\nexport interface ListItemAddonProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/list/ListItemAddon.tsx"],"sourcesContent":["import { type ReactElement, type ReactNode } from \"react\";\n\nimport {\n TextIconSpacing,\n type TextIconSpacingProps,\n} from \"../icon/TextIconSpacing.js\";\nimport {\n type ListItemAddonClassNameOptions,\n listItemAddon,\n} from \"./listItemStyles.js\";\n\nexport interface ListItemAddonProps\n extends\n Omit<TextIconSpacingProps, \"icon\" | \"iconAfter\" | \"forceIconWrap\">,\n ListItemAddonClassNameOptions {\n /**\n * The addon that should be rendered.\n */\n addon: ReactNode;\n\n /**\n * @defaultValue `type === \"media\" || type === \"large-media\"`\n */\n forceAddonWrap?: boolean;\n}\n\n/**\n * The `ListItemAddon` is used to create an addon to the left or right of the\n * text/children of a `ListItem`.\n *\n * @internal\n */\nexport function ListItemAddon(props: ListItemAddonProps): ReactElement {\n const {\n className,\n children,\n addon,\n addonAfter,\n type = \"icon\",\n position,\n forceAddonWrap,\n disableCenteredMedia,\n disableBeforeSpacing,\n ...remaining\n } = props;\n\n const isMedia = type === \"media\" || type === \"large-media\";\n\n return (\n <TextIconSpacing\n {...remaining}\n icon={addon}\n forceIconWrap={forceAddonWrap ?? isMedia}\n className={listItemAddon({\n type,\n position,\n className,\n addonAfter,\n disableBeforeSpacing,\n disableCenteredMedia,\n })}\n iconAfter={addonAfter}\n >\n {children}\n </TextIconSpacing>\n );\n}\n"],"names":["TextIconSpacing","listItemAddon","ListItemAddon","props","className","children","addon","addonAfter","type","position","forceAddonWrap","disableCenteredMedia","disableBeforeSpacing","remaining","isMedia","icon","forceIconWrap","iconAfter"],"mappings":";AAEA,SACEA,eAAe,QAEV,6BAA6B;AACpC,SAEEC,aAAa,QACR,sBAAsB;AAiB7B;;;;;CAKC,GACD,OAAO,SAASC,cAAcC,KAAyB;IACrD,MAAM,EACJC,SAAS,EACTC,QAAQ,EACRC,KAAK,EACLC,UAAU,EACVC,OAAO,MAAM,EACbC,QAAQ,EACRC,cAAc,EACdC,oBAAoB,EACpBC,oBAAoB,EACpB,GAAGC,WACJ,GAAGV;IAEJ,MAAMW,UAAUN,SAAS,WAAWA,SAAS;IAE7C,qBACE,KAACR;QACE,GAAGa,SAAS;QACbE,MAAMT;QACNU,eAAeN,kBAAkBI;QACjCV,WAAWH,cAAc;YACvBO;YACAC;YACAL;YACAG;YACAK;YACAD;QACF;QACAM,WAAWV;kBAEVF;;AAGP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/list/ListItemLink.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type AnchorHTMLAttributes,\n type HTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport { type CustomLinkComponent } from \"../link/Link.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { ListItemChildren } from \"./ListItemChildren.js\";\nimport { getListItemHeight } from \"./getListItemHeight.js\";\nimport { type ListItemClassNameOptions, listItem } from \"./listItemStyles.js\";\nimport { type ListItemChildrenProps } from \"./types.js\";\n\nexport interface ListItemLinkProps\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/list/ListItemLink.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type AnchorHTMLAttributes,\n type HTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport { type CustomLinkComponent } from \"../link/Link.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { ListItemChildren } from \"./ListItemChildren.js\";\nimport { getListItemHeight } from \"./getListItemHeight.js\";\nimport { type ListItemClassNameOptions, listItem } from \"./listItemStyles.js\";\nimport { type ListItemChildrenProps } from \"./types.js\";\n\nexport interface ListItemLinkProps\n extends\n AnchorHTMLAttributes<HTMLAnchorElement>,\n ListItemClassNameOptions,\n ListItemChildrenProps,\n ComponentWithRippleProps {\n /** @defaultValue `\"a\"` */\n as?: CustomLinkComponent;\n\n /**\n * This should only be used if the {@link as} {@link CustomLinkComponent}\n * accepts a `to` prop instead of {@link href}.\n */\n to?: string;\n\n /**\n * The link's href. Either this or the {@link to} prop **should** be provided.\n */\n href?: string;\n\n /**\n * Any additional props to provide the wrapping `<li>` element such as\n * `style`, `className`, and `ref`.\n */\n liProps?: PropsWithRef<HTMLAttributes<HTMLLIElement>>;\n\n /**\n * @defaultValue `disabled ? -1 : undefined`\n */\n tabIndex?: number;\n}\n\n/**\n * **Client Component**\n *\n * The `ListItemLink` should be used to render links within the `List`, `Menu`,\n * or `DropdownMenu` components.\n *\n * @example Simple Example\n * ```tsx\n * import { List } from \"@react-md/core/list/list\";\n * import { ListItemLink } from \"@react-md/core/list/ListItemLink\";\n *\n * function Example() {\n * return (\n * <List>\n * <ListItemLink href=\"#\">Some Link</ListItemLink>\n * </List>\n * );\n * }\n * ```\n *\n * @example In Menus\n * ```tsx\n * import { ListItemLink } from \"@react-md/core/list/ListItemLink\";\n * import { DropdownMenu } from \"@react-md/core/menu/DropdownMenu\";\n *\n * function Example() {\n * return (\n * <DropdownMenu buttonChildren=\"Hello\">\n * <ListItemLink role=\"menuitem\" href=\"#\">Some Link</ListItemLink>\n * </List>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/list | List Demos}\n */\nexport const ListItemLink = forwardRef<HTMLAnchorElement, ListItemLinkProps>(\n function ListItemLink(props, ref) {\n const {\n as: Link = \"a\",\n to,\n href,\n className,\n liProps,\n textProps,\n textClassName,\n secondaryTextClassName,\n primaryText,\n secondaryText,\n secondaryTextProps,\n disableTextChildren = false,\n height: propHeight,\n leftAddon,\n leftAddonType = \"icon\",\n leftAddonPosition = \"middle\",\n leftAddonClassName,\n leftAddonForceWrap,\n rightAddon,\n rightAddonType = \"icon\",\n rightAddonPosition = \"middle\",\n rightAddonClassName,\n rightAddonForceWrap,\n disableLeftAddonCenteredMedia = false,\n disableRightAddonCenteredMedia = false,\n multiline = false,\n disabled = false,\n disabledOpacity = false,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n role,\n tabIndex = disabled || role === \"menuitem\" ? -1 : undefined,\n children: propChildren,\n disableRipple,\n ...remaining\n } = props;\n\n const { pressedClassName, ripples, handlers } = useElementInteraction({\n mode: disableRipple ? \"none\" : undefined,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disabled,\n });\n const children = useHigherContrastChildren(\n propChildren,\n !disableTextChildren\n );\n\n const height = getListItemHeight({\n height: propHeight,\n leftAddon,\n leftAddonType,\n rightAddon,\n rightAddonType,\n secondaryText,\n });\n\n return (\n <li {...liProps} role=\"none\">\n <Link\n ref={ref}\n {...remaining}\n {...handlers}\n role={role}\n className={listItem({\n className,\n link: true,\n height,\n disabled,\n disabledOpacity,\n multiline,\n pressedClassName,\n })}\n // TODO: Figure out a better type for the CustomLinkComponent to fix this\n to={to as string}\n href={href as string}\n tabIndex={tabIndex}\n >\n <ListItemChildren\n multiline={multiline}\n textClassName={textClassName}\n secondaryTextClassName={secondaryTextClassName}\n disableTextChildren={disableTextChildren}\n primaryText={primaryText}\n textProps={textProps}\n secondaryText={secondaryText}\n secondaryTextProps={secondaryTextProps}\n leftAddon={leftAddon}\n leftAddonType={leftAddonType}\n leftAddonPosition={leftAddonPosition}\n leftAddonClassName={leftAddonClassName}\n leftAddonForceWrap={leftAddonForceWrap}\n rightAddon={rightAddon}\n rightAddonType={rightAddonType}\n rightAddonPosition={rightAddonPosition}\n rightAddonClassName={rightAddonClassName}\n rightAddonForceWrap={rightAddonForceWrap}\n disableLeftAddonCenteredMedia={disableLeftAddonCenteredMedia}\n disableRightAddonCenteredMedia={disableRightAddonCenteredMedia}\n >\n {children}\n </ListItemChildren>\n {ripples}\n </Link>\n </li>\n );\n }\n);\n"],"names":["forwardRef","useElementInteraction","useHigherContrastChildren","ListItemChildren","getListItemHeight","listItem","ListItemLink","props","ref","as","Link","to","href","className","liProps","textProps","textClassName","secondaryTextClassName","primaryText","secondaryText","secondaryTextProps","disableTextChildren","height","propHeight","leftAddon","leftAddonType","leftAddonPosition","leftAddonClassName","leftAddonForceWrap","rightAddon","rightAddonType","rightAddonPosition","rightAddonClassName","rightAddonForceWrap","disableLeftAddonCenteredMedia","disableRightAddonCenteredMedia","multiline","disabled","disabledOpacity","onBlur","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave","onDragStart","onTouchStart","onTouchEnd","onTouchMove","role","tabIndex","undefined","children","propChildren","disableRipple","remaining","pressedClassName","ripples","handlers","mode","li","link"],"mappings":"AAAA;;AAEA,SAGEA,UAAU,QACL,QAAQ;AAGf,SAASC,qBAAqB,QAAQ,0CAA0C;AAChF,SAASC,yBAAyB,QAAQ,8CAA8C;AAGxF,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAAwCC,QAAQ,QAAQ,sBAAsB;AAmC9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCC,GACD,OAAO,MAAMC,6BAAeN,WAC1B,SAASM,aAAaC,KAAK,EAAEC,GAAG;IAC9B,MAAM,EACJC,IAAIC,OAAO,GAAG,EACdC,EAAE,EACFC,IAAI,EACJC,SAAS,EACTC,OAAO,EACPC,SAAS,EACTC,aAAa,EACbC,sBAAsB,EACtBC,WAAW,EACXC,aAAa,EACbC,kBAAkB,EAClBC,sBAAsB,KAAK,EAC3BC,QAAQC,UAAU,EAClBC,SAAS,EACTC,gBAAgB,MAAM,EACtBC,oBAAoB,QAAQ,EAC5BC,kBAAkB,EAClBC,kBAAkB,EAClBC,UAAU,EACVC,iBAAiB,MAAM,EACvBC,qBAAqB,QAAQ,EAC7BC,mBAAmB,EACnBC,mBAAmB,EACnBC,gCAAgC,KAAK,EACrCC,iCAAiC,KAAK,EACtCC,YAAY,KAAK,EACjBC,WAAW,KAAK,EAChBC,kBAAkB,KAAK,EACvBC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,WAAW,EACXC,SAAS,EACTC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,WAAW,EACXC,IAAI,EACJC,WAAWd,YAAYa,SAAS,aAAa,CAAC,IAAIE,SAAS,EAC3DC,UAAUC,YAAY,EACtBC,aAAa,EACb,GAAGC,WACJ,GAAGjD;IAEJ,MAAM,EAAEkD,gBAAgB,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAG1D,sBAAsB;QACpE2D,MAAML,gBAAgB,SAASH;QAC/Bb;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAZ;IACF;IACA,MAAMgB,WAAWnD,0BACfoD,cACA,CAACjC;IAGH,MAAMC,SAASlB,kBAAkB;QAC/BkB,QAAQC;QACRC;QACAC;QACAI;QACAC;QACAX;IACF;IAEA,qBACE,KAAC0C;QAAI,GAAG/C,OAAO;QAAEoC,MAAK;kBACpB,cAAA,MAACxC;YACCF,KAAKA;YACJ,GAAGgD,SAAS;YACZ,GAAGG,QAAQ;YACZT,MAAMA;YACNrC,WAAWR,SAAS;gBAClBQ;gBACAiD,MAAM;gBACNxC;gBACAe;gBACAC;gBACAF;gBACAqB;YACF;YACA,yEAAyE;YACzE9C,IAAIA;YACJC,MAAMA;YACNuC,UAAUA;;8BAEV,KAAChD;oBACCiC,WAAWA;oBACXpB,eAAeA;oBACfC,wBAAwBA;oBACxBI,qBAAqBA;oBACrBH,aAAaA;oBACbH,WAAWA;oBACXI,eAAeA;oBACfC,oBAAoBA;oBACpBI,WAAWA;oBACXC,eAAeA;oBACfC,mBAAmBA;oBACnBC,oBAAoBA;oBACpBC,oBAAoBA;oBACpBC,YAAYA;oBACZC,gBAAgBA;oBAChBC,oBAAoBA;oBACpBC,qBAAqBA;oBACrBC,qBAAqBA;oBACrBC,+BAA+BA;oBAC/BC,gCAAgCA;8BAE/BkB;;gBAEFK;;;;AAIT,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/list/ListSubheader.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { ListItemText } from \"./ListItemText.js\";\n\nconst styles = bem(\"rmd-list-subheader\");\n\n/** @since 6.0.0 */\nexport interface ListSubheaderClassNameOptions {\n className?: string;\n\n /**\n * Boolean if the subheader should be inset to match the `ListItem` text\n * keyline.\n *\n * @defaultValue `false`\n */\n inset?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function listSubheader(\n options: ListSubheaderClassNameOptions = {}\n): string {\n const { inset = false, className } = options;\n\n return cnb(styles({ inset }), className);\n}\n\n/**\n * @since 6.0.0 The `role` prop defaults to `\"presentation\"`\n */\nexport interface ListSubheaderProps\n extends HTMLAttributes<HTMLLIElement
|
|
1
|
+
{"version":3,"sources":["../../src/list/ListSubheader.tsx"],"sourcesContent":["import { cnb } from \"cnbuilder\";\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { ListItemText } from \"./ListItemText.js\";\n\nconst styles = bem(\"rmd-list-subheader\");\n\n/** @since 6.0.0 */\nexport interface ListSubheaderClassNameOptions {\n className?: string;\n\n /**\n * Boolean if the subheader should be inset to match the `ListItem` text\n * keyline.\n *\n * @defaultValue `false`\n */\n inset?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function listSubheader(\n options: ListSubheaderClassNameOptions = {}\n): string {\n const { inset = false, className } = options;\n\n return cnb(styles({ inset }), className);\n}\n\n/**\n * @since 6.0.0 The `role` prop defaults to `\"presentation\"`\n */\nexport interface ListSubheaderProps\n extends HTMLAttributes<HTMLLIElement>, ListSubheaderClassNameOptions {\n /**\n * @defaultValue `\"presentation\"`\n */\n role?: HTMLAttributes<HTMLLIElement>[\"role\"];\n\n /**\n * @since 6.0.0\n */\n textProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n}\n\n/**\n * The `ListSubheader` is a wrapper for the `<li>` element to apply subheader\n * typography styles and {@link ListItemText} layout.\n *\n * @see {@link https://react-md.dev/components/list | List Demos}\n */\nexport const ListSubheader = forwardRef<HTMLLIElement, ListSubheaderProps>(\n function ListSubheader(props, ref) {\n const {\n role = \"presentation\",\n inset = false,\n className,\n children,\n textProps,\n ...remaining\n } = props;\n\n return (\n <li\n {...remaining}\n ref={ref}\n role={role}\n className={listSubheader({\n inset,\n className,\n })}\n >\n <ListItemText {...textProps}>{children}</ListItemText>\n </li>\n );\n }\n);\n"],"names":["cnb","forwardRef","bem","ListItemText","styles","listSubheader","options","inset","className","ListSubheader","props","ref","role","children","textProps","remaining","li"],"mappings":";AAAA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAA8BC,UAAU,QAAQ,QAAQ;AAGxD,SAASC,GAAG,QAAQ,kBAAkB;AACtC,SAASC,YAAY,QAAQ,oBAAoB;AAEjD,MAAMC,SAASF,IAAI;AAenB;;CAEC,GACD,OAAO,SAASG,cACdC,UAAyC,CAAC,CAAC;IAE3C,MAAM,EAAEC,QAAQ,KAAK,EAAEC,SAAS,EAAE,GAAGF;IAErC,OAAON,IAAII,OAAO;QAAEG;IAAM,IAAIC;AAChC;AAkBA;;;;;CAKC,GACD,OAAO,MAAMC,8BAAgBR,WAC3B,SAASQ,cAAcC,KAAK,EAAEC,GAAG;IAC/B,MAAM,EACJC,OAAO,cAAc,EACrBL,QAAQ,KAAK,EACbC,SAAS,EACTK,QAAQ,EACRC,SAAS,EACT,GAAGC,WACJ,GAAGL;IAEJ,qBACE,KAACM;QACE,GAAGD,SAAS;QACbJ,KAAKA;QACLC,MAAMA;QACNJ,WAAWH,cAAc;YACvBE;YACAC;QACF;kBAEA,cAAA,KAACL;YAAc,GAAGW,SAAS;sBAAGD;;;AAGpC,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/list/getListItemHeight.ts"],"sourcesContent":["import type { ListItemChildrenProps, ListItemHeight } from \"./types.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface ListItemHeightOptions
|
|
1
|
+
{"version":3,"sources":["../../src/list/getListItemHeight.ts"],"sourcesContent":["import type { ListItemChildrenProps, ListItemHeight } from \"./types.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface ListItemHeightOptions extends Pick<\n ListItemChildrenProps,\n | \"leftAddon\"\n | \"rightAddon\"\n | \"leftAddonType\"\n | \"rightAddonType\"\n | \"secondaryText\"\n> {\n /**\n * @see {@link ListItemHeight}\n */\n height?: ListItemHeight;\n}\n\n/**\n * Gets the expected height for the `ListItem` based on the addons and\n * `secondaryText` props.\n *\n * @see {@link ListItemHeight}\n * @internal\n */\nexport function getListItemHeight(\n options: ListItemHeightOptions = {}\n): ListItemHeight {\n const {\n height,\n leftAddon,\n leftAddonType = \"icon\",\n rightAddon,\n rightAddonType = \"icon\",\n secondaryText,\n } = options;\n\n if (height) {\n return height;\n }\n\n const isIcon =\n (leftAddon && leftAddonType === \"icon\") ||\n (rightAddon && rightAddonType === \"icon\");\n const isAvatar =\n (leftAddon && leftAddonType === \"avatar\") ||\n (rightAddon && rightAddonType === \"avatar\");\n const isGraphic =\n (leftAddon &&\n (leftAddonType === \"media\" || leftAddonType === \"large-media\")) ||\n (rightAddon &&\n (rightAddonType === \"media\" || rightAddonType === \"large-media\"));\n\n // secondary text will always be extra large due to the default `line-height`\n if (isGraphic || secondaryText) {\n return \"extra-large\";\n }\n\n if (isAvatar) {\n return \"large\";\n }\n\n if (isIcon) {\n return \"medium\";\n }\n\n return \"normal\";\n}\n"],"names":["getListItemHeight","options","height","leftAddon","leftAddonType","rightAddon","rightAddonType","secondaryText","isIcon","isAvatar","isGraphic"],"mappings":"AAoBA;;;;;;CAMC,GACD,OAAO,SAASA,kBACdC,UAAiC,CAAC,CAAC;IAEnC,MAAM,EACJC,MAAM,EACNC,SAAS,EACTC,gBAAgB,MAAM,EACtBC,UAAU,EACVC,iBAAiB,MAAM,EACvBC,aAAa,EACd,GAAGN;IAEJ,IAAIC,QAAQ;QACV,OAAOA;IACT;IAEA,MAAMM,SACJ,AAACL,aAAaC,kBAAkB,UAC/BC,cAAcC,mBAAmB;IACpC,MAAMG,WACJ,AAACN,aAAaC,kBAAkB,YAC/BC,cAAcC,mBAAmB;IACpC,MAAMI,YACJ,AAACP,aACEC,CAAAA,kBAAkB,WAAWA,kBAAkB,aAAY,KAC7DC,cACEC,CAAAA,mBAAmB,WAAWA,mBAAmB,aAAY;IAElE,6EAA6E;IAC7E,IAAII,aAAaH,eAAe;QAC9B,OAAO;IACT;IAEA,IAAIE,UAAU;QACZ,OAAO;IACT;IAEA,IAAID,QAAQ;QACV,OAAO;IACT;IAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/list/listItemStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\nimport {\n type ListItemAddonPosition,\n type ListItemAddonType,\n type ListItemHeight,\n} from \"./types.js\";\n\nconst styles = bem(\"rmd-list-item\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-list-item-keyline\"?: string | number;\n \"--rmd-list-item-padding-h\"?: string | number;\n \"--rmd-list-item-padding-v\"?: string | number;\n \"--rmd-list-item-height\"?: string | number;\n \"--rmd-list-item-medium-height\"?: string | number;\n \"--rmd-list-item-large-height\"?: string | number;\n \"--rmd-list-item-extra-large-height\"?: string | number;\n \"--rmd-list-item-multiline-height\"?: string | number;\n \"--rmd-list-item-media-size\"?: string | number;\n \"--rmd-list-item-media-spacing\"?: string | number;\n \"--rmd-list-item-text-multiline-height\"?: string | number;\n \"--rmd-list-item-multiline-clamp\"?: string | number;\n }\n}\n\n/** @since 6.3.1 */\nexport interface BaseListItemClassNameOptions {\n className?: string;\n\n /**\n * @see {@link ListItemHeight}\n * @defaultValue `\"auto\"`\n */\n height?: ListItemHeight;\n\n /**\n * @defaultValue `false`\n */\n multiline?: boolean;\n\n /**\n * Note: This does nothing if the `disabled` prop is not enabled.\n *\n * @defaultValue `false`\n * @since 2.4.3\n */\n disabled?: boolean;\n\n /**\n * Note: This does nothing if the `disabled` prop is not enabled.\n *\n * @defaultValue `false`\n * @since 2.4.3\n */\n disabledOpacity?: boolean;\n}\n\n/** @since 6.0.0 */\nexport interface ListItemClassNameOptions extends BaseListItemClassNameOptions {\n /**\n * Set this to `false` if the list item should not gain the interaction\n * states: hover, focus, press, etc. This is kind of like being disabled\n * without the disabled styles being applied.\n *\n * @defaultValue `true`\n */\n clickable?: boolean;\n}\n\n/** @since 6.0.0 */\nexport interface InternalListItemClassNameOptions
|
|
1
|
+
{"version":3,"sources":["../../src/list/listItemStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\nimport {\n type ListItemAddonPosition,\n type ListItemAddonType,\n type ListItemHeight,\n} from \"./types.js\";\n\nconst styles = bem(\"rmd-list-item\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-list-item-keyline\"?: string | number;\n \"--rmd-list-item-padding-h\"?: string | number;\n \"--rmd-list-item-padding-v\"?: string | number;\n \"--rmd-list-item-height\"?: string | number;\n \"--rmd-list-item-medium-height\"?: string | number;\n \"--rmd-list-item-large-height\"?: string | number;\n \"--rmd-list-item-extra-large-height\"?: string | number;\n \"--rmd-list-item-multiline-height\"?: string | number;\n \"--rmd-list-item-media-size\"?: string | number;\n \"--rmd-list-item-media-spacing\"?: string | number;\n \"--rmd-list-item-text-multiline-height\"?: string | number;\n \"--rmd-list-item-multiline-clamp\"?: string | number;\n }\n}\n\n/** @since 6.3.1 */\nexport interface BaseListItemClassNameOptions {\n className?: string;\n\n /**\n * @see {@link ListItemHeight}\n * @defaultValue `\"auto\"`\n */\n height?: ListItemHeight;\n\n /**\n * @defaultValue `false`\n */\n multiline?: boolean;\n\n /**\n * Note: This does nothing if the `disabled` prop is not enabled.\n *\n * @defaultValue `false`\n * @since 2.4.3\n */\n disabled?: boolean;\n\n /**\n * Note: This does nothing if the `disabled` prop is not enabled.\n *\n * @defaultValue `false`\n * @since 2.4.3\n */\n disabledOpacity?: boolean;\n}\n\n/** @since 6.0.0 */\nexport interface ListItemClassNameOptions extends BaseListItemClassNameOptions {\n /**\n * Set this to `false` if the list item should not gain the interaction\n * states: hover, focus, press, etc. This is kind of like being disabled\n * without the disabled styles being applied.\n *\n * @defaultValue `true`\n */\n clickable?: boolean;\n}\n\n/** @since 6.0.0 */\nexport interface InternalListItemClassNameOptions extends ListItemClassNameOptions {\n /**\n * @defaultValue `false`\n */\n link?: boolean;\n\n /**\n * This is prop is used internally when integrating with the\n * {@link useElementInteraction} hook.\n */\n pressedClassName?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function listItem(\n options: InternalListItemClassNameOptions = {}\n): string {\n const {\n className,\n link = false,\n height = \"auto\",\n clickable = true,\n multiline = false,\n disabled = false,\n disabledOpacity = false,\n pressedClassName,\n } = options;\n\n return cnb(\n styles({\n link,\n [height]: height !== \"auto\",\n multiline,\n \"disabled-color\": disabled && !disabledOpacity,\n \"disabled-opacity\": disabled && disabledOpacity,\n }),\n cssUtils({ surface: clickable }),\n pressedClassName,\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface ListItemTextClassNameOptions {\n className?: string;\n /**\n * @defaultValue `false`\n */\n clamped?: boolean;\n\n /**\n * @defaultValue `false`\n */\n secondary?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function listItemText(\n options: ListItemTextClassNameOptions = {}\n): string {\n const { className, secondary = false, clamped = false } = options;\n\n return cnb(\n styles(\"text\", {\n clamped: secondary && clamped,\n secondary,\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface ListItemAddonClassNameOptions {\n className?: string;\n\n /**\n * The addon type that is used to adjust the spacing styles.\n *\n * @defaultValue `\"icon\"`\n */\n type?: ListItemAddonType;\n\n /**\n * The vertical position to use for the addon.\n *\n * @defaultValue `\"middle\"`\n */\n position?: ListItemAddonPosition;\n\n /**\n * Boolean if the addon should appear after the `children`.\n *\n * @defaultValue `false`\n */\n addonAfter?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableCenteredMedia?: boolean;\n\n /**\n * Set this to `true` to disable the additional spacing applied to the addons\n * that appear before the `children` and the normal `--rmd-text-icon-spacing`\n * value is used instead.\n *\n * @defaultValue `false`\n */\n disableBeforeSpacing?: boolean;\n}\n\n/**\n *\n * @since 6.0.0\n */\nexport function listItemAddon(\n options: ListItemAddonClassNameOptions = {}\n): string {\n const {\n type = \"icon\",\n position = \"middle\",\n className,\n addonAfter = false,\n disableCenteredMedia = false,\n disableBeforeSpacing = false,\n } = options;\n\n const isMedia = type === \"media\" || type === \"large-media\";\n const isAvatar = type === \"avatar\";\n\n return cnb(\n styles(\"addon\", {\n [position]: position !== \"middle\",\n before: !disableBeforeSpacing && !addonAfter,\n \"avatar-before\": !disableBeforeSpacing && !addonAfter && isAvatar,\n media: isMedia,\n \"media-large\": type === \"large-media\",\n \"media-centered\": isMedia && !disableCenteredMedia,\n }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","styles","listItem","options","className","link","height","clickable","multiline","disabled","disabledOpacity","pressedClassName","surface","listItemText","secondary","clamped","listItemAddon","type","position","addonAfter","disableCenteredMedia","disableBeforeSpacing","isMedia","isAvatar","before","media"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,GAAG,QAAQ,kBAAkB;AAOtC,MAAMC,SAASD,IAAI;AA6EnB;;CAEC,GACD,OAAO,SAASE,SACdC,UAA4C,CAAC,CAAC;IAE9C,MAAM,EACJC,SAAS,EACTC,OAAO,KAAK,EACZC,SAAS,MAAM,EACfC,YAAY,IAAI,EAChBC,YAAY,KAAK,EACjBC,WAAW,KAAK,EAChBC,kBAAkB,KAAK,EACvBC,gBAAgB,EACjB,GAAGR;IAEJ,OAAOL,IACLG,OAAO;QACLI;QACA,CAACC,OAAO,EAAEA,WAAW;QACrBE;QACA,kBAAkBC,YAAY,CAACC;QAC/B,oBAAoBD,YAAYC;IAClC,IACAX,SAAS;QAAEa,SAASL;IAAU,IAC9BI,kBACAP;AAEJ;AAgBA;;CAEC,GACD,OAAO,SAASS,aACdV,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEC,SAAS,EAAEU,YAAY,KAAK,EAAEC,UAAU,KAAK,EAAE,GAAGZ;IAE1D,OAAOL,IACLG,OAAO,QAAQ;QACbc,SAASD,aAAaC;QACtBD;IACF,IACAV;AAEJ;AAoDA;;;CAGC,GACD,OAAO,SAASY,cACdb,UAAyC,CAAC,CAAC;IAE3C,MAAM,EACJc,OAAO,MAAM,EACbC,WAAW,QAAQ,EACnBd,SAAS,EACTe,aAAa,KAAK,EAClBC,uBAAuB,KAAK,EAC5BC,uBAAuB,KAAK,EAC7B,GAAGlB;IAEJ,MAAMmB,UAAUL,SAAS,WAAWA,SAAS;IAC7C,MAAMM,WAAWN,SAAS;IAE1B,OAAOnB,IACLG,OAAO,SAAS;QACd,CAACiB,SAAS,EAAEA,aAAa;QACzBM,QAAQ,CAACH,wBAAwB,CAACF;QAClC,iBAAiB,CAACE,wBAAwB,CAACF,cAAcI;QACzDE,OAAOH;QACP,eAAeL,SAAS;QACxB,kBAAkBK,WAAW,CAACF;IAChC,IACAhB;AAEJ"}
|
package/dist/list/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/list/types.ts"],"sourcesContent":["import { type HTMLAttributes, type ReactNode } from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\n\n/**\n * The height to apply to the list item.\n *\n * Conversions:\n *\n * - height !== undefined && height !== \"auto\" -> height\n * - secondaryText or left/right addon is media/media-large -> \"extra-large\"\n * - left/right addon is avatar -> \"large\"\n * - left/right addon is icon -> \"medium\"\n * - no addons and no secondary text -> \"normal\"\n */\nexport type ListItemHeight =\n | \"auto\"\n | \"normal\"\n | \"medium\"\n | \"large\"\n | \"extra-large\";\n\nexport type ListItemAddonPosition = \"top\" | \"middle\" | \"bottom\";\nexport type ListItemAddonType = \"icon\" | \"avatar\" | \"media\" | \"large-media\";\n\n/** @since 6.0.0 */\nexport interface ListItemChildrenAddonProps {\n /**\n * An optional addon to display to the left of the `primaryText` or\n * `children` and should be used with the `leftAddonType` prop to adjust\n * spacing.\n */\n leftAddon?: ReactNode;\n\n /**\n * The type of the addon that appears to the left of the `primaryText` or\n * `children`.\n *\n * @defaultValue `\"icon\"`\n */\n leftAddonType?: ListItemAddonType;\n\n /**\n * The vertical position the left icon, avatar, media, or large media\n * should be placed.\n *\n * @defaultValue `\"middle\"`\n */\n leftAddonPosition?: ListItemAddonPosition;\n\n /**\n * @since 6.0.0\n */\n leftAddonClassName?: string;\n\n /**\n * Set this to `true` if your addon does not accept a `className` prop to\n * apply the correct styling.\n *\n * @defaultValue `leftAddonType === \"media\" || leftAddonType === \"large-media\"`\n * @since 6.0.0\n */\n leftAddonForceWrap?: boolean;\n\n /**\n * Set this to `true` to disable the additional spacing applied to the addons\n * that appear before the `children` and the normal `--rmd-text-icon-spacing`\n * value is used instead.\n *\n * @defaultValue `false`\n */\n disableLeftAddonSpacing?: boolean;\n\n /**\n * An optional addon to display to the right of the `primaryText` or\n * `children` and should be used with the `rightAddonType` prop to adjust\n * spacing.\n */\n rightAddon?: ReactNode;\n\n /**\n * The type of the addon that appears to the right of the `primaryText` or\n * `children`.\n *\n * @defaultValue `\"icon\"`\n */\n rightAddonType?: ListItemAddonType;\n\n /**\n * The vertical position the right icon, avatar, media, or large media\n * should be placed.\n *\n * @defaultValue `\"middle\"`\n */\n rightAddonPosition?: ListItemAddonPosition;\n\n /**\n * @since 6.0.0\n */\n rightAddonClassName?: string;\n\n /**\n * Set this to `true` if your addon does not accept a `className` prop to\n * apply the correct styling.\n *\n * @defaultValue `rightAddonType === \"media\" || rightAddonType === \"large-media\"`\n * @since 6.0.0\n */\n rightAddonForceWrap?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableLeftAddonCenteredMedia?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableRightAddonCenteredMedia?: boolean;\n}\n\n/**\n * Note: This interface was added since there are components that replace the\n * {@link ListItemChildrenAddonProps} with renamed versions but should still\n * support everything for rendering text.\n *\n * @since 6.0.0\n */\nexport interface ListItemChildrenTextProps {\n /**\n * The main content to display that defaults to being wrapped in the\n * `ListItemText` component. Enable the {@link disableTextChildren} prop to\n * render without the additional `ListItemText` wrapper.\n */\n children?: ReactNode;\n\n /**\n * Any additional props that should be passed to the `<span>` surrounding\n * the {@link children}, {@link primaryText}, and {@link secondaryText}.\n *\n * @since 6.0.0\n */\n textProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * An optional className to apply to the `<span>` that surrounds the\n * `primaryText` and optionally `secondaryText` within the list item.\n */\n textClassName?: string;\n\n /**\n * An optional className to apply to the `<span>` that surrounds the\n * `secondaryText` within the list item.\n */\n secondaryTextClassName?: string;\n\n /**\n * Set this to `true` if the {@link children} should not automatically be\n * wrapped in the `ListItemText` component.\n *\n * @since 6.0.0 Renamed from `textChildren` since it was defaulted on.\n * @defaultValue `false`\n */\n disableTextChildren?: boolean;\n\n /**\n * An optional element that should be rendered as the `primaryText` within the\n * list item. It is most likely easier to use the `children` prop instead, but\n * this allows you to create more complex components with the `ListItem` since\n * you can provided `children` and have the styles for the `primaryText` still\n * applied. By default, this will only allow one line of text and add ellipsis\n * for any text overflow.\n */\n primaryText?: ReactNode;\n\n /**\n * An optional element that should be rendered as the `secondaryText` within\n * the list item. By default, this will only span one line and add ellipsis\n * for overflow.\n */\n secondaryText?: ReactNode;\n\n /**\n * Any additional props that should be passed to the `<span>` surrounding\n * the {@link secondaryText}.\n *\n * @since 6.0.0\n */\n secondaryTextProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * Set this to `true` to allow the {@link secondaryText} to span multiple\n * lines and use the CSS clamp after two lines of text are visible. The number\n * of lines can be configured by `core.$list-item-multiline-clamp` or\n * `@include core.list-set-var(item-multiline-clamp, $new-value)`.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp}\n * @defaultValue `false`\n */\n multiline?: boolean;\n}\n\n/**\n * @since 6.0.0 Extends the `ListItemChildrenTextProps` and\n * `ListItemChildrenAddonProps` interfaces.\n * @since 6.0.0 Added `textProps` and `secondaryTextClassName`\n * @since 6.0.0 Renamed `textChildren` to `disableTextChildren`\n */\nexport interface ListItemChildrenProps\n extends ListItemChildrenTextProps
|
|
1
|
+
{"version":3,"sources":["../../src/list/types.ts"],"sourcesContent":["import { type HTMLAttributes, type ReactNode } from \"react\";\n\nimport { type PropsWithRef } from \"../types.js\";\n\n/**\n * The height to apply to the list item.\n *\n * Conversions:\n *\n * - height !== undefined && height !== \"auto\" -> height\n * - secondaryText or left/right addon is media/media-large -> \"extra-large\"\n * - left/right addon is avatar -> \"large\"\n * - left/right addon is icon -> \"medium\"\n * - no addons and no secondary text -> \"normal\"\n */\nexport type ListItemHeight =\n | \"auto\"\n | \"normal\"\n | \"medium\"\n | \"large\"\n | \"extra-large\";\n\nexport type ListItemAddonPosition = \"top\" | \"middle\" | \"bottom\";\nexport type ListItemAddonType = \"icon\" | \"avatar\" | \"media\" | \"large-media\";\n\n/** @since 6.0.0 */\nexport interface ListItemChildrenAddonProps {\n /**\n * An optional addon to display to the left of the `primaryText` or\n * `children` and should be used with the `leftAddonType` prop to adjust\n * spacing.\n */\n leftAddon?: ReactNode;\n\n /**\n * The type of the addon that appears to the left of the `primaryText` or\n * `children`.\n *\n * @defaultValue `\"icon\"`\n */\n leftAddonType?: ListItemAddonType;\n\n /**\n * The vertical position the left icon, avatar, media, or large media\n * should be placed.\n *\n * @defaultValue `\"middle\"`\n */\n leftAddonPosition?: ListItemAddonPosition;\n\n /**\n * @since 6.0.0\n */\n leftAddonClassName?: string;\n\n /**\n * Set this to `true` if your addon does not accept a `className` prop to\n * apply the correct styling.\n *\n * @defaultValue `leftAddonType === \"media\" || leftAddonType === \"large-media\"`\n * @since 6.0.0\n */\n leftAddonForceWrap?: boolean;\n\n /**\n * Set this to `true` to disable the additional spacing applied to the addons\n * that appear before the `children` and the normal `--rmd-text-icon-spacing`\n * value is used instead.\n *\n * @defaultValue `false`\n */\n disableLeftAddonSpacing?: boolean;\n\n /**\n * An optional addon to display to the right of the `primaryText` or\n * `children` and should be used with the `rightAddonType` prop to adjust\n * spacing.\n */\n rightAddon?: ReactNode;\n\n /**\n * The type of the addon that appears to the right of the `primaryText` or\n * `children`.\n *\n * @defaultValue `\"icon\"`\n */\n rightAddonType?: ListItemAddonType;\n\n /**\n * The vertical position the right icon, avatar, media, or large media\n * should be placed.\n *\n * @defaultValue `\"middle\"`\n */\n rightAddonPosition?: ListItemAddonPosition;\n\n /**\n * @since 6.0.0\n */\n rightAddonClassName?: string;\n\n /**\n * Set this to `true` if your addon does not accept a `className` prop to\n * apply the correct styling.\n *\n * @defaultValue `rightAddonType === \"media\" || rightAddonType === \"large-media\"`\n * @since 6.0.0\n */\n rightAddonForceWrap?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableLeftAddonCenteredMedia?: boolean;\n\n /**\n * The media items are centered by default using:\n * ```scss\n * align-items: center;\n * display: flex;\n * justify-content: center;\n * ```\n *\n * When this is set to `true`, the flex styles will not be applied.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n disableRightAddonCenteredMedia?: boolean;\n}\n\n/**\n * Note: This interface was added since there are components that replace the\n * {@link ListItemChildrenAddonProps} with renamed versions but should still\n * support everything for rendering text.\n *\n * @since 6.0.0\n */\nexport interface ListItemChildrenTextProps {\n /**\n * The main content to display that defaults to being wrapped in the\n * `ListItemText` component. Enable the {@link disableTextChildren} prop to\n * render without the additional `ListItemText` wrapper.\n */\n children?: ReactNode;\n\n /**\n * Any additional props that should be passed to the `<span>` surrounding\n * the {@link children}, {@link primaryText}, and {@link secondaryText}.\n *\n * @since 6.0.0\n */\n textProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * An optional className to apply to the `<span>` that surrounds the\n * `primaryText` and optionally `secondaryText` within the list item.\n */\n textClassName?: string;\n\n /**\n * An optional className to apply to the `<span>` that surrounds the\n * `secondaryText` within the list item.\n */\n secondaryTextClassName?: string;\n\n /**\n * Set this to `true` if the {@link children} should not automatically be\n * wrapped in the `ListItemText` component.\n *\n * @since 6.0.0 Renamed from `textChildren` since it was defaulted on.\n * @defaultValue `false`\n */\n disableTextChildren?: boolean;\n\n /**\n * An optional element that should be rendered as the `primaryText` within the\n * list item. It is most likely easier to use the `children` prop instead, but\n * this allows you to create more complex components with the `ListItem` since\n * you can provided `children` and have the styles for the `primaryText` still\n * applied. By default, this will only allow one line of text and add ellipsis\n * for any text overflow.\n */\n primaryText?: ReactNode;\n\n /**\n * An optional element that should be rendered as the `secondaryText` within\n * the list item. By default, this will only span one line and add ellipsis\n * for overflow.\n */\n secondaryText?: ReactNode;\n\n /**\n * Any additional props that should be passed to the `<span>` surrounding\n * the {@link secondaryText}.\n *\n * @since 6.0.0\n */\n secondaryTextProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * Set this to `true` to allow the {@link secondaryText} to span multiple\n * lines and use the CSS clamp after two lines of text are visible. The number\n * of lines can be configured by `core.$list-item-multiline-clamp` or\n * `@include core.list-set-var(item-multiline-clamp, $new-value)`.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp}\n * @defaultValue `false`\n */\n multiline?: boolean;\n}\n\n/**\n * @since 6.0.0 Extends the `ListItemChildrenTextProps` and\n * `ListItemChildrenAddonProps` interfaces.\n * @since 6.0.0 Added `textProps` and `secondaryTextClassName`\n * @since 6.0.0 Renamed `textChildren` to `disableTextChildren`\n */\nexport interface ListItemChildrenProps\n extends ListItemChildrenTextProps, ListItemChildrenAddonProps {}\n"],"names":[],"mappings":"AA8NA;;;;;CAKC,GACD,WACkE"}
|
|
@@ -25,6 +25,8 @@ export declare function useAppSize(): Readonly<AppSize>;
|
|
|
25
25
|
* @since 6.0.0 Renamed from `AppSizeListenerProps`.
|
|
26
26
|
* @since 6.0.0 Removed the `onChange` prop
|
|
27
27
|
* @since 6.0.0 Renamed `defaultSize` to `ssrSize`
|
|
28
|
+
* @since 6.4.0 Deprecated the `AppSizeQueries` in favor
|
|
29
|
+
* of the `MEDIA_QUERY_CONFIG`
|
|
28
30
|
*/
|
|
29
31
|
export interface AppSizeProviderProps extends AppSizeQueries {
|
|
30
32
|
/**
|
|
@@ -3,7 +3,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { createContext, useContext, useMemo } from "react";
|
|
4
4
|
import { useSsr } from "../SsrProvider.js";
|
|
5
5
|
import { useOrientation } from "../useOrientation.js";
|
|
6
|
-
import { DEFAULT_APP_SIZE
|
|
6
|
+
import { DEFAULT_APP_SIZE } from "./appSize.js";
|
|
7
|
+
import { MEDIA_QUERY_CONFIG } from "./config.js";
|
|
7
8
|
import { useMediaQuery } from "./useMediaQuery.js";
|
|
8
9
|
const context = /*#__PURE__*/ createContext({
|
|
9
10
|
__root: false,
|
|
@@ -51,7 +52,7 @@ const { Provider } = context;
|
|
|
51
52
|
* @see {@link https://react-md.dev/components/app-size-provider | AppSizeProvider Demos}
|
|
52
53
|
* @since 6.0.0 Renamed from `AppSizeListener`
|
|
53
54
|
*/ export function AppSizeProvider(props) {
|
|
54
|
-
const { ssrSize = DEFAULT_APP_SIZE, phoneMaxWidth =
|
|
55
|
+
const { ssrSize = DEFAULT_APP_SIZE, phoneMaxWidth = MEDIA_QUERY_CONFIG.phoneMaxWidth, tabletMinWidth = MEDIA_QUERY_CONFIG.tabletMinWidth, tabletMaxWidth = MEDIA_QUERY_CONFIG.tabletMaxWidth, desktopMinWidth = MEDIA_QUERY_CONFIG.desktopMinWidth, desktopLargeMinWidth = MEDIA_QUERY_CONFIG.desktopLargeMinWidth, children } = props;
|
|
55
56
|
const { __root } = useContext(context);
|
|
56
57
|
if (__root) {
|
|
57
58
|
throw new Error("The `AppSizeProvider` cannot be mounted multiple times.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/media-queries/AppSizeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n createContext,\n useContext,\n useMemo,\n} from \"react\";\n\nimport { useSsr } from \"../SsrProvider.js\";\nimport { useOrientation } from \"../useOrientation.js\";\nimport {\n type AppSize,\n type AppSizeQueries,\n DEFAULT_APP_SIZE,\n
|
|
1
|
+
{"version":3,"sources":["../../src/media-queries/AppSizeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n createContext,\n useContext,\n useMemo,\n} from \"react\";\n\nimport { useSsr } from \"../SsrProvider.js\";\nimport { useOrientation } from \"../useOrientation.js\";\nimport {\n type AppSize,\n type AppSizeQueries,\n DEFAULT_APP_SIZE,\n} from \"./appSize.js\";\nimport { MEDIA_QUERY_CONFIG } from \"./config.js\";\nimport { useMediaQuery } from \"./useMediaQuery.js\";\n\n/** @internal */\ninterface AppSizeContext extends AppSize {\n __root: boolean;\n}\n\nconst context = createContext<AppSizeContext>({\n __root: false,\n isPhone: false,\n isTablet: false,\n isDesktop: true,\n isLargeDesktop: false,\n isLandscape: true,\n});\ncontext.displayName = \"AppSize\";\nconst { Provider } = context;\n\n/**\n * **Note**: The app size object returned by this hook will **not** be equal\n * between renders.\n *\n * @example Simple Example\n * ```tsx\n * import { useAppSize } from \"@react-md/core/media-queries/AppSizeProvider\";\n *\n * function Example() {\n * const { isPhone, isTablet, isDesktop, isLargeDesktop, isLandscape } =\n * useAppSize()\n *\n * // do something based on the app size\n * return null;\n * }\n * ```\n *\n * @returns the current app size.\n * @throws \"The `AppSizeProvider` has not been mounted.\"\n */\nexport function useAppSize(): Readonly<AppSize> {\n const { __root, ...appSize } = useContext(context);\n if (!__root) {\n throw new Error(\"The `AppSizeProvider` has not been mounted.\");\n }\n\n return appSize;\n}\n\n/**\n * @since 6.0.0 Renamed from `AppSizeListenerProps`.\n * @since 6.0.0 Removed the `onChange` prop\n * @since 6.0.0 Renamed `defaultSize` to `ssrSize`\n * @since 6.4.0 Deprecated the `AppSizeQueries` in favor\n * of the `MEDIA_QUERY_CONFIG`\n */\nexport interface AppSizeProviderProps extends AppSizeQueries {\n /**\n * @defaultValue `DEFAULT_APP_SIZE`\n * @see {@link DEFAULT_APP_SIZE}\n * @since 6.0.0\n */\n ssrSize?: Readonly<AppSize>;\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * This component should be mounted near the root of your app to determine the\n * current app size based on different media queries.\n *\n * @see {@link https://react-md.dev/components/core-providers | CoreProviders Demos}\n * @see {@link https://react-md.dev/components/app-size-provider | AppSizeProvider Demos}\n * @since 6.0.0 Renamed from `AppSizeListener`\n */\nexport function AppSizeProvider(props: AppSizeProviderProps): ReactElement {\n const {\n ssrSize = DEFAULT_APP_SIZE,\n phoneMaxWidth = MEDIA_QUERY_CONFIG.phoneMaxWidth,\n tabletMinWidth = MEDIA_QUERY_CONFIG.tabletMinWidth,\n tabletMaxWidth = MEDIA_QUERY_CONFIG.tabletMaxWidth,\n desktopMinWidth = MEDIA_QUERY_CONFIG.desktopMinWidth,\n desktopLargeMinWidth = MEDIA_QUERY_CONFIG.desktopLargeMinWidth,\n children,\n } = props;\n const { __root } = useContext(context);\n if (__root) {\n throw new Error(\"The `AppSizeProvider` cannot be mounted multiple times.\");\n }\n\n const ssr = useSsr();\n const matchesDesktop = useMediaQuery(\n `screen and (min-width: ${desktopMinWidth})`\n );\n const matchesLargeDesktop = useMediaQuery(\n `screen and (min-width: ${desktopLargeMinWidth})`\n );\n const matchesTablet = useMediaQuery(\n `screen and (min-width: ${tabletMinWidth}) and (max-width: ${tabletMaxWidth})`\n );\n const matchesPhone = useMediaQuery(\n `screen and (max-width: ${phoneMaxWidth})`\n );\n const isDesktop = matchesDesktop;\n const isTablet = !matchesDesktop && matchesTablet;\n const isPhone = !isTablet && !isDesktop && matchesPhone;\n const isLandscape = useOrientation().includes(\"landscape\");\n const isLargeDesktop = matchesLargeDesktop;\n\n const appSize = useMemo<AppSizeContext>(\n () => ({\n __root: true,\n isPhone,\n isTablet,\n isDesktop,\n isLargeDesktop,\n isLandscape,\n }),\n [isDesktop, isLandscape, isLargeDesktop, isPhone, isTablet]\n );\n\n let value = appSize;\n if (ssr || typeof window === \"undefined\") {\n value = {\n __root: true,\n ...ssrSize,\n };\n }\n\n return <Provider value={value}>{children}</Provider>;\n}\n"],"names":["createContext","useContext","useMemo","useSsr","useOrientation","DEFAULT_APP_SIZE","MEDIA_QUERY_CONFIG","useMediaQuery","context","__root","isPhone","isTablet","isDesktop","isLargeDesktop","isLandscape","displayName","Provider","useAppSize","appSize","Error","AppSizeProvider","props","ssrSize","phoneMaxWidth","tabletMinWidth","tabletMaxWidth","desktopMinWidth","desktopLargeMinWidth","children","ssr","matchesDesktop","matchesLargeDesktop","matchesTablet","matchesPhone","includes","value","window"],"mappings":"AAAA;;AAEA,SAGEA,aAAa,EACbC,UAAU,EACVC,OAAO,QACF,QAAQ;AAEf,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAGEC,gBAAgB,QACX,eAAe;AACtB,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SAASC,aAAa,QAAQ,qBAAqB;AAOnD,MAAMC,wBAAUR,cAA8B;IAC5CS,QAAQ;IACRC,SAAS;IACTC,UAAU;IACVC,WAAW;IACXC,gBAAgB;IAChBC,aAAa;AACf;AACAN,QAAQO,WAAW,GAAG;AACtB,MAAM,EAAEC,QAAQ,EAAE,GAAGR;AAErB;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASS;IACd,MAAM,EAAER,MAAM,EAAE,GAAGS,SAAS,GAAGjB,WAAWO;IAC1C,IAAI,CAACC,QAAQ;QACX,MAAM,IAAIU,MAAM;IAClB;IAEA,OAAOD;AACT;AAmBA;;;;;;;;;CASC,GACD,OAAO,SAASE,gBAAgBC,KAA2B;IACzD,MAAM,EACJC,UAAUjB,gBAAgB,EAC1BkB,gBAAgBjB,mBAAmBiB,aAAa,EAChDC,iBAAiBlB,mBAAmBkB,cAAc,EAClDC,iBAAiBnB,mBAAmBmB,cAAc,EAClDC,kBAAkBpB,mBAAmBoB,eAAe,EACpDC,uBAAuBrB,mBAAmBqB,oBAAoB,EAC9DC,QAAQ,EACT,GAAGP;IACJ,MAAM,EAAEZ,MAAM,EAAE,GAAGR,WAAWO;IAC9B,IAAIC,QAAQ;QACV,MAAM,IAAIU,MAAM;IAClB;IAEA,MAAMU,MAAM1B;IACZ,MAAM2B,iBAAiBvB,cACrB,CAAC,uBAAuB,EAAEmB,gBAAgB,CAAC,CAAC;IAE9C,MAAMK,sBAAsBxB,cAC1B,CAAC,uBAAuB,EAAEoB,qBAAqB,CAAC,CAAC;IAEnD,MAAMK,gBAAgBzB,cACpB,CAAC,uBAAuB,EAAEiB,eAAe,kBAAkB,EAAEC,eAAe,CAAC,CAAC;IAEhF,MAAMQ,eAAe1B,cACnB,CAAC,uBAAuB,EAAEgB,cAAc,CAAC,CAAC;IAE5C,MAAMX,YAAYkB;IAClB,MAAMnB,WAAW,CAACmB,kBAAkBE;IACpC,MAAMtB,UAAU,CAACC,YAAY,CAACC,aAAaqB;IAC3C,MAAMnB,cAAcV,iBAAiB8B,QAAQ,CAAC;IAC9C,MAAMrB,iBAAiBkB;IAEvB,MAAMb,UAAUhB,QACd,IAAO,CAAA;YACLO,QAAQ;YACRC;YACAC;YACAC;YACAC;YACAC;QACF,CAAA,GACA;QAACF;QAAWE;QAAaD;QAAgBH;QAASC;KAAS;IAG7D,IAAIwB,QAAQjB;IACZ,IAAIW,OAAO,OAAOO,WAAW,aAAa;QACxCD,QAAQ;YACN1B,QAAQ;YACR,GAAGa,OAAO;QACZ;IACF;IAEA,qBAAO,KAACN;QAASmB,OAAOA;kBAAQP;;AAClC"}
|
|
@@ -49,6 +49,9 @@ export interface AppSizeQueries {
|
|
|
49
49
|
*/
|
|
50
50
|
desktopLargeMinWidth?: QuerySize;
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Use `MEDIA_QUERY_CONFIG` instead.
|
|
54
|
+
*/
|
|
52
55
|
export declare const DEFAULT_APP_SIZE_QUERIES: Readonly<AppSizeQueries>;
|
|
53
56
|
/**
|
|
54
57
|
* The current size for your application. This should work both server side and
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
/** @defaultValue `64em` */ export const DEFAULT_TABLET_MAX_WIDTH = `${1024 / 16}em`;
|
|
4
4
|
/** @defaultValue `64.0625em` */ export const DEFAULT_DESKTOP_MIN_WIDTH = `${1025 / 16}em`;
|
|
5
5
|
/** @defaultValue `80em` */ export const DEFAULT_DESKTOP_LARGE_MIN_WIDTH = `${1280 / 16}em`;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `MEDIA_QUERY_CONFIG` instead.
|
|
8
|
+
*/ export const DEFAULT_APP_SIZE_QUERIES = {
|
|
7
9
|
phoneMaxWidth: DEFAULT_PHONE_MAX_WIDTH,
|
|
8
10
|
tabletMinWidth: DEFAULT_TABLET_MIN_WIDTH,
|
|
9
11
|
tabletMaxWidth: DEFAULT_TABLET_MAX_WIDTH,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/media-queries/appSize.ts"],"sourcesContent":["export type QuerySize = number | `${number}${string}`;\n\n/** @defaultValue `47.9375em` */\nexport const DEFAULT_PHONE_MAX_WIDTH = `${767 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `48em` */\nexport const DEFAULT_TABLET_MIN_WIDTH = `${768 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `64em` */\nexport const DEFAULT_TABLET_MAX_WIDTH = `${1024 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `64.0625em` */\nexport const DEFAULT_DESKTOP_MIN_WIDTH = `${1025 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `80em` */\nexport const DEFAULT_DESKTOP_LARGE_MIN_WIDTH = `${\n 1280 / 16\n}em` satisfies QuerySize;\n\nexport interface AppSizeQueries {\n /**\n * The max width to use for phones. This one is a max width unlike the others\n * since everything from 0 to this value will be considered a phone.\n *\n * @defaultValue `47.9375em`\n * @see {@link DEFAULT_PHONE_MAX_WIDTH}\n */\n phoneMaxWidth?: QuerySize;\n\n /**\n * The min width for a tablet device.\n *\n * @defaultValue `48em`\n * @see {@link DEFAULT_TABLET_MIN_WIDTH}\n */\n tabletMinWidth?: QuerySize;\n\n /**\n * The max width for a tablet device. This should normally be `1px` less than\n * the `desktopMinWidth`, but it can be any value if needed. The tablet has a\n * range of min to max so that you can have a bit more control.\n *\n * @defaultValue `64em`\n * @see {@link DEFAULT_TABLET_MAX_WIDTH}\n */\n tabletMaxWidth?: QuerySize;\n\n /**\n * The min width for a desktop screen.\n *\n * @defaultValue `64.0625em`\n * @see {@link DEFAULT_DESKTOP_MIN_WIDTH}\n */\n desktopMinWidth?: QuerySize;\n\n /**\n * The min width for a large (1440p, 4k, etc) desktop screen.\n *\n * @defaultValue `80em`\n * @see {@link DEFAULT_DESKTOP_LARGE_MIN_WIDTH}\n */\n desktopLargeMinWidth?: QuerySize;\n}\n\nexport const DEFAULT_APP_SIZE_QUERIES: Readonly<AppSizeQueries> = {\n phoneMaxWidth: DEFAULT_PHONE_MAX_WIDTH,\n tabletMinWidth: DEFAULT_TABLET_MIN_WIDTH,\n tabletMaxWidth: DEFAULT_TABLET_MAX_WIDTH,\n desktopMinWidth: DEFAULT_DESKTOP_MIN_WIDTH,\n desktopLargeMinWidth: DEFAULT_DESKTOP_LARGE_MIN_WIDTH,\n};\n\n/**\n * The current size for your application. This should work both server side and\n * client side, but you will have much better results client side.\n */\nexport interface AppSize {\n /**\n * Boolean if currently matching a phone by comparing the max width of the\n * device.\n */\n isPhone: boolean;\n\n /**\n * Boolean if currently matching a tablet by comparing the max width of the\n * device.\n */\n isTablet: boolean;\n\n /**\n * Boolean if currently matching a desktop screen by comparing the max width\n * of the device.\n */\n isDesktop: boolean;\n\n /**\n * Boolean if currently matching a large desktop screen by comparing the max\n * width of the device.\n */\n isLargeDesktop: boolean;\n\n /**\n * Boolean if the app is considered to be in landscape mode. This will just\n * verify that the window width is greater than the window height.\n *\n * NOTE: This might not be super accurate on Android devices since the soft\n * keyboard will change the dimensions of the viewport when it appears. It is\n * recommended to use the `useOrientation` hook as well if you'd like to get\n * the current orientation type.\n */\n isLandscape: boolean;\n}\n\nexport const DEFAULT_APP_SIZE: AppSize = {\n isPhone: false,\n isTablet: false,\n isDesktop: true,\n isLargeDesktop: false,\n isLandscape: true,\n};\n"],"names":["DEFAULT_PHONE_MAX_WIDTH","DEFAULT_TABLET_MIN_WIDTH","DEFAULT_TABLET_MAX_WIDTH","DEFAULT_DESKTOP_MIN_WIDTH","DEFAULT_DESKTOP_LARGE_MIN_WIDTH","DEFAULT_APP_SIZE_QUERIES","phoneMaxWidth","tabletMinWidth","tabletMaxWidth","desktopMinWidth","desktopLargeMinWidth","DEFAULT_APP_SIZE","isPhone","isTablet","isDesktop","isLargeDesktop","isLandscape"],"mappings":"AAEA,8BAA8B,GAC9B,OAAO,MAAMA,0BAA0B,GAAG,MAAM,GAAG,EAAE,CAAC,CAAqB;AAE3E,yBAAyB,GACzB,OAAO,MAAMC,2BAA2B,GAAG,MAAM,GAAG,EAAE,CAAC,CAAqB;AAE5E,yBAAyB,GACzB,OAAO,MAAMC,2BAA2B,GAAG,OAAO,GAAG,EAAE,CAAC,CAAqB;AAE7E,8BAA8B,GAC9B,OAAO,MAAMC,4BAA4B,GAAG,OAAO,GAAG,EAAE,CAAC,CAAqB;AAE9E,yBAAyB,GACzB,OAAO,MAAMC,kCAAkC,GAC7C,OAAO,GACR,EAAE,CAAC,CAAqB;AA+CzB,OAAO,MAAMC,2BAAqD;IAChEC,eAAeN;IACfO,gBAAgBN;IAChBO,gBAAgBN;IAChBO,iBAAiBN;IACjBO,sBAAsBN;AACxB,EAAE;AA2CF,OAAO,MAAMO,mBAA4B;IACvCC,SAAS;IACTC,UAAU;IACVC,WAAW;IACXC,gBAAgB;IAChBC,aAAa;AACf,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/media-queries/appSize.ts"],"sourcesContent":["export type QuerySize = number | `${number}${string}`;\n\n/** @defaultValue `47.9375em` */\nexport const DEFAULT_PHONE_MAX_WIDTH = `${767 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `48em` */\nexport const DEFAULT_TABLET_MIN_WIDTH = `${768 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `64em` */\nexport const DEFAULT_TABLET_MAX_WIDTH = `${1024 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `64.0625em` */\nexport const DEFAULT_DESKTOP_MIN_WIDTH = `${1025 / 16}em` satisfies QuerySize;\n\n/** @defaultValue `80em` */\nexport const DEFAULT_DESKTOP_LARGE_MIN_WIDTH = `${\n 1280 / 16\n}em` satisfies QuerySize;\n\nexport interface AppSizeQueries {\n /**\n * The max width to use for phones. This one is a max width unlike the others\n * since everything from 0 to this value will be considered a phone.\n *\n * @defaultValue `47.9375em`\n * @see {@link DEFAULT_PHONE_MAX_WIDTH}\n */\n phoneMaxWidth?: QuerySize;\n\n /**\n * The min width for a tablet device.\n *\n * @defaultValue `48em`\n * @see {@link DEFAULT_TABLET_MIN_WIDTH}\n */\n tabletMinWidth?: QuerySize;\n\n /**\n * The max width for a tablet device. This should normally be `1px` less than\n * the `desktopMinWidth`, but it can be any value if needed. The tablet has a\n * range of min to max so that you can have a bit more control.\n *\n * @defaultValue `64em`\n * @see {@link DEFAULT_TABLET_MAX_WIDTH}\n */\n tabletMaxWidth?: QuerySize;\n\n /**\n * The min width for a desktop screen.\n *\n * @defaultValue `64.0625em`\n * @see {@link DEFAULT_DESKTOP_MIN_WIDTH}\n */\n desktopMinWidth?: QuerySize;\n\n /**\n * The min width for a large (1440p, 4k, etc) desktop screen.\n *\n * @defaultValue `80em`\n * @see {@link DEFAULT_DESKTOP_LARGE_MIN_WIDTH}\n */\n desktopLargeMinWidth?: QuerySize;\n}\n\n/**\n * @deprecated Use `MEDIA_QUERY_CONFIG` instead.\n */\nexport const DEFAULT_APP_SIZE_QUERIES: Readonly<AppSizeQueries> = {\n phoneMaxWidth: DEFAULT_PHONE_MAX_WIDTH,\n tabletMinWidth: DEFAULT_TABLET_MIN_WIDTH,\n tabletMaxWidth: DEFAULT_TABLET_MAX_WIDTH,\n desktopMinWidth: DEFAULT_DESKTOP_MIN_WIDTH,\n desktopLargeMinWidth: DEFAULT_DESKTOP_LARGE_MIN_WIDTH,\n};\n\n/**\n * The current size for your application. This should work both server side and\n * client side, but you will have much better results client side.\n */\nexport interface AppSize {\n /**\n * Boolean if currently matching a phone by comparing the max width of the\n * device.\n */\n isPhone: boolean;\n\n /**\n * Boolean if currently matching a tablet by comparing the max width of the\n * device.\n */\n isTablet: boolean;\n\n /**\n * Boolean if currently matching a desktop screen by comparing the max width\n * of the device.\n */\n isDesktop: boolean;\n\n /**\n * Boolean if currently matching a large desktop screen by comparing the max\n * width of the device.\n */\n isLargeDesktop: boolean;\n\n /**\n * Boolean if the app is considered to be in landscape mode. This will just\n * verify that the window width is greater than the window height.\n *\n * NOTE: This might not be super accurate on Android devices since the soft\n * keyboard will change the dimensions of the viewport when it appears. It is\n * recommended to use the `useOrientation` hook as well if you'd like to get\n * the current orientation type.\n */\n isLandscape: boolean;\n}\n\nexport const DEFAULT_APP_SIZE: AppSize = {\n isPhone: false,\n isTablet: false,\n isDesktop: true,\n isLargeDesktop: false,\n isLandscape: true,\n};\n"],"names":["DEFAULT_PHONE_MAX_WIDTH","DEFAULT_TABLET_MIN_WIDTH","DEFAULT_TABLET_MAX_WIDTH","DEFAULT_DESKTOP_MIN_WIDTH","DEFAULT_DESKTOP_LARGE_MIN_WIDTH","DEFAULT_APP_SIZE_QUERIES","phoneMaxWidth","tabletMinWidth","tabletMaxWidth","desktopMinWidth","desktopLargeMinWidth","DEFAULT_APP_SIZE","isPhone","isTablet","isDesktop","isLargeDesktop","isLandscape"],"mappings":"AAEA,8BAA8B,GAC9B,OAAO,MAAMA,0BAA0B,GAAG,MAAM,GAAG,EAAE,CAAC,CAAqB;AAE3E,yBAAyB,GACzB,OAAO,MAAMC,2BAA2B,GAAG,MAAM,GAAG,EAAE,CAAC,CAAqB;AAE5E,yBAAyB,GACzB,OAAO,MAAMC,2BAA2B,GAAG,OAAO,GAAG,EAAE,CAAC,CAAqB;AAE7E,8BAA8B,GAC9B,OAAO,MAAMC,4BAA4B,GAAG,OAAO,GAAG,EAAE,CAAC,CAAqB;AAE9E,yBAAyB,GACzB,OAAO,MAAMC,kCAAkC,GAC7C,OAAO,GACR,EAAE,CAAC,CAAqB;AA+CzB;;CAEC,GACD,OAAO,MAAMC,2BAAqD;IAChEC,eAAeN;IACfO,gBAAgBN;IAChBO,gBAAgBN;IAChBO,iBAAiBN;IACjBO,sBAAsBN;AACxB,EAAE;AA2CF,OAAO,MAAMO,mBAA4B;IACvCC,SAAS;IACTC,UAAU;IACVC,WAAW;IACXC,gBAAgB;IAChBC,aAAa;AACf,EAAE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AppSizeQueries } from "./appSize.js";
|
|
2
|
+
/** @since 6.4.0 */
|
|
3
|
+
export type MediaQueryConfig = Required<AppSizeQueries>;
|
|
4
|
+
/**
|
|
5
|
+
* @since 6.4.0
|
|
6
|
+
*/
|
|
7
|
+
export declare const MEDIA_QUERY_CONFIG: MediaQueryConfig;
|
|
8
|
+
/**
|
|
9
|
+
* @since 6.4.0
|
|
10
|
+
*/
|
|
11
|
+
export declare function configureMediaQueries(queries: Readonly<Partial<MediaQueryConfig>>): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DEFAULT_DESKTOP_LARGE_MIN_WIDTH, DEFAULT_DESKTOP_MIN_WIDTH, DEFAULT_PHONE_MAX_WIDTH, DEFAULT_TABLET_MAX_WIDTH, DEFAULT_TABLET_MIN_WIDTH } from "./appSize.js";
|
|
2
|
+
/**
|
|
3
|
+
* @since 6.4.0
|
|
4
|
+
*/ export const MEDIA_QUERY_CONFIG = {
|
|
5
|
+
phoneMaxWidth: DEFAULT_PHONE_MAX_WIDTH,
|
|
6
|
+
tabletMinWidth: DEFAULT_TABLET_MIN_WIDTH,
|
|
7
|
+
tabletMaxWidth: DEFAULT_TABLET_MAX_WIDTH,
|
|
8
|
+
desktopMinWidth: DEFAULT_DESKTOP_MIN_WIDTH,
|
|
9
|
+
desktopLargeMinWidth: DEFAULT_DESKTOP_LARGE_MIN_WIDTH
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* @since 6.4.0
|
|
13
|
+
*/ export function configureMediaQueries(queries) {
|
|
14
|
+
if (process.env.NODE_ENV !== "production") {
|
|
15
|
+
Object.entries(queries).forEach(([name, value])=>{
|
|
16
|
+
if (!(name in MEDIA_QUERY_CONFIG)) {
|
|
17
|
+
throw new Error(`${name} is an invalid react-md media query.`);
|
|
18
|
+
}
|
|
19
|
+
MEDIA_QUERY_CONFIG[name] = value;
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
Object.assign(MEDIA_QUERY_CONFIG, queries);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/media-queries/config.ts"],"sourcesContent":["import {\n type AppSizeQueries,\n DEFAULT_DESKTOP_LARGE_MIN_WIDTH,\n DEFAULT_DESKTOP_MIN_WIDTH,\n DEFAULT_PHONE_MAX_WIDTH,\n DEFAULT_TABLET_MAX_WIDTH,\n DEFAULT_TABLET_MIN_WIDTH,\n} from \"./appSize.js\";\n\n/** @since 6.4.0 */\nexport type MediaQueryConfig = Required<AppSizeQueries>;\n\n/**\n * @since 6.4.0\n */\nexport const MEDIA_QUERY_CONFIG: MediaQueryConfig = {\n phoneMaxWidth: DEFAULT_PHONE_MAX_WIDTH,\n tabletMinWidth: DEFAULT_TABLET_MIN_WIDTH,\n tabletMaxWidth: DEFAULT_TABLET_MAX_WIDTH,\n desktopMinWidth: DEFAULT_DESKTOP_MIN_WIDTH,\n desktopLargeMinWidth: DEFAULT_DESKTOP_LARGE_MIN_WIDTH,\n};\n\n/**\n * @since 6.4.0\n */\nexport function configureMediaQueries(\n queries: Readonly<Partial<MediaQueryConfig>>\n): void {\n if (process.env.NODE_ENV !== \"production\") {\n Object.entries(queries).forEach(([name, value]) => {\n if (!(name in MEDIA_QUERY_CONFIG)) {\n throw new Error(`${name} is an invalid react-md media query.`);\n }\n\n MEDIA_QUERY_CONFIG[name as keyof MediaQueryConfig] = value;\n });\n } else {\n Object.assign(MEDIA_QUERY_CONFIG, queries);\n }\n}\n"],"names":["DEFAULT_DESKTOP_LARGE_MIN_WIDTH","DEFAULT_DESKTOP_MIN_WIDTH","DEFAULT_PHONE_MAX_WIDTH","DEFAULT_TABLET_MAX_WIDTH","DEFAULT_TABLET_MIN_WIDTH","MEDIA_QUERY_CONFIG","phoneMaxWidth","tabletMinWidth","tabletMaxWidth","desktopMinWidth","desktopLargeMinWidth","configureMediaQueries","queries","process","env","NODE_ENV","Object","entries","forEach","name","value","Error","assign"],"mappings":"AAAA,SAEEA,+BAA+B,EAC/BC,yBAAyB,EACzBC,uBAAuB,EACvBC,wBAAwB,EACxBC,wBAAwB,QACnB,eAAe;AAKtB;;CAEC,GACD,OAAO,MAAMC,qBAAuC;IAClDC,eAAeJ;IACfK,gBAAgBH;IAChBI,gBAAgBL;IAChBM,iBAAiBR;IACjBS,sBAAsBV;AACxB,EAAE;AAEF;;CAEC,GACD,OAAO,SAASW,sBACdC,OAA4C;IAE5C,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzCC,OAAOC,OAAO,CAACL,SAASM,OAAO,CAAC,CAAC,CAACC,MAAMC,MAAM;YAC5C,IAAI,CAAED,CAAAA,QAAQd,kBAAiB,GAAI;gBACjC,MAAM,IAAIgB,MAAM,GAAGF,KAAK,oCAAoC,CAAC;YAC/D;YAEAd,kBAAkB,CAACc,KAA+B,GAAGC;QACvD;IACF,OAAO;QACLJ,OAAOM,MAAM,CAACjB,oBAAoBO;IACpC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/menu/DropdownMenu.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n type RefObject,\n useCallback,\n useRef,\n} from \"react\";\n\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { getLastFocusableIndex } from \"../movement/utils.js\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useEnsuredState } from \"../useEnsuredState.js\";\nimport {\n Menu,\n type MenuConvenienceProps,\n type MenuListConvenienceProps,\n} from \"./Menu.js\";\nimport { MenuButton, type MenuButtonProps } from \"./MenuButton.js\";\nimport {\n type MenuConfiguration,\n MenuConfigurationProvider,\n} from \"./MenuConfigurationProvider.js\";\nimport { MenuItemButton, type MenuItemButtonProps } from \"./MenuItemButton.js\";\nimport { type MenuSheetConvenienceProps } from \"./MenuSheet.js\";\nimport { MenuVisibilityProvider } from \"./MenuVisibilityProvider.js\";\nimport { useMenuBarContext } from \"./useMenuBarProvider.js\";\n\nexport interface BaseDropdownMenuProps\n extends MenuConfiguration,\n MenuListConvenienceProps,\n MenuSheetConvenienceProps,\n MenuConvenienceProps {\n buttonChildren: ReactNode;\n}\n\nexport interface DropdownMenuButtonProps\n extends MenuButtonProps,\n BaseDropdownMenuProps {}\n\nexport interface DropdownMenuItemButtonProps\n extends MenuItemButtonProps,\n BaseDropdownMenuProps {}\n\n/**\n * @since 6.0.0\n */\nexport interface DropdownMenuStateProps {\n visible: boolean;\n setVisible: UseStateSetter<boolean>;\n}\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Updated to use an `&` instead of `|` to allow autocompletion to\n * work better by default. It's up to the user to make sure they don't provide\n * incorrect props.\n */\nexport type DropdownMenuProps = DropdownMenuButtonProps &\n DropdownMenuItemButtonProps &\n (DropdownMenuStateProps | { visible?: never; setVisible?: never });\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { DropdownMenu } from \"@react-md/core/menu/DropdownMenu\";\n * import { MenuItem } from \"@react-md/core/menu/MenuItem\";\n *\n * function Example() {\n * return (\n * <DropdownMenu buttonChildren=\"Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Item 2\n * </MenuItem>\n * </DropdownMenu>\n * );\n * }\n * ```\n *\n * @example Nested Dropdown Menus\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { DropdownMenu } from \"@react-md/core/menu/DropdownMenu\";\n * import { MenuItem } from \"@react-md/core/menu/MenuItem\";\n *\n * function Example() {\n * return (\n * <DropdownMenu buttonChildren=\"Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Item 2\n * </MenuItem>\n * <DropdownMenu buttonChildren=\"Nested Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Nested Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Nested Item 2\n * </MenuItem>\n * </DropdownMenu>\n * </DropdownMenu>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/menu | Menu Demos}\n * @since 5.0.0\n * @since 6.0.0 Updated to use the latest menu API.\n */\nexport function DropdownMenu(props: DropdownMenuProps): ReactElement {\n const {\n id: propId,\n horizontal,\n sheetHeader,\n sheetFooter,\n renderAsSheet,\n sheetPosition,\n sheetVerticalSize,\n buttonChildren,\n iconRotatorProps: propIconRotatorProps,\n disableTransition: propDisableTransition,\n floating,\n anchor,\n vwMargin,\n vhMargin,\n xMargin,\n yMargin,\n initialX,\n initialY,\n width,\n transformOrigin,\n preventOverlap,\n disableSwapping,\n disableVHBounds,\n preventScroll,\n closeOnResize,\n closeOnScroll,\n getFixedPositionOptions,\n children,\n temporary,\n disablePortal,\n disableElevation,\n menuProps,\n menuStyle,\n menuClassName,\n sheetProps,\n sheetStyle,\n sheetClassName,\n visible: propVisible,\n setVisible: propSetVisible,\n ...remaining\n } = props;\n\n const fixedTo = useRef<HTMLElement | HTMLButtonElement>(null);\n const defaultFocusIndex = useRef(0);\n const [visible, setVisible] = useEnsuredState({\n name: \"visible\",\n value: propVisible,\n setValue: propSetVisible,\n defaultValue: false,\n });\n const { menubar, menuitem, activeIdRef, animatedOnceRef } =\n useMenuBarContext();\n const id = useEnsuredId(propId, `menu${menuitem ? \"item\" : \"button\"}`);\n const mode = useUserInteractionMode();\n const mouse = mode === \"mouse\";\n const keyboard = mode === \"keyboard\";\n const disableTransition =\n propDisableTransition ??\n (animatedOnceRef.current &&\n menubar &&\n !!activeIdRef.current &&\n (mouse || keyboard));\n\n const onRequestClose = useCallback(() => {\n setVisible(false);\n }, [setVisible]);\n\n let iconRotatorProps = propIconRotatorProps;\n if (disableTransition) {\n iconRotatorProps = {\n disableTransition,\n ...propIconRotatorProps,\n };\n }\n\n let toggle: ReactElement;\n if (menuitem) {\n toggle = (\n <MenuItemButton\n {...(remaining as DropdownMenuItemButtonProps)}\n id={id}\n ref={fixedTo as RefObject<HTMLLIElement>}\n iconRotatorProps={iconRotatorProps}\n >\n {buttonChildren}\n </MenuItemButton>\n );\n } else {\n toggle = (\n <MenuButton\n {...(remaining as DropdownMenuButtonProps)}\n id={id}\n ref={fixedTo as RefObject<HTMLButtonElement>}\n floating={floating}\n iconRotatorProps={iconRotatorProps}\n >\n {buttonChildren}\n </MenuButton>\n );\n }\n\n return (\n <MenuVisibilityProvider\n visible={visible}\n setVisible={setVisible}\n defaultFocusIndex={defaultFocusIndex}\n >\n <MenuConfigurationProvider\n horizontal={horizontal}\n renderAsSheet={renderAsSheet}\n sheetFooter={sheetFooter}\n sheetHeader={sheetHeader}\n sheetPosition={sheetPosition}\n sheetVerticalSize={sheetVerticalSize}\n >\n {toggle}\n </MenuConfigurationProvider>\n <Menu\n aria-labelledby={(menuProps?.[\"aria-label\"] ? undefined : id) as string}\n style={menuStyle}\n className={menuClassName}\n sheetProps={sheetProps}\n sheetStyle={sheetStyle}\n sheetClassName={sheetClassName}\n temporary={temporary}\n disablePortal={disablePortal}\n disableElevation={disableElevation}\n disableTransition={disableTransition}\n floating={floating}\n anchor={anchor}\n vwMargin={vwMargin}\n vhMargin={vhMargin}\n xMargin={xMargin}\n yMargin={yMargin}\n initialX={initialX}\n initialY={initialY}\n width={width}\n transformOrigin={transformOrigin}\n preventOverlap={preventOverlap}\n disableSwapping={disableSwapping}\n disableVHBounds={disableVHBounds}\n preventScroll={preventScroll}\n closeOnResize={closeOnResize}\n closeOnScroll={closeOnScroll}\n getFixedPositionOptions={getFixedPositionOptions}\n horizontal={horizontal}\n sheetHeader={sheetHeader}\n sheetFooter={sheetFooter}\n renderAsSheet={renderAsSheet}\n sheetPosition={sheetPosition}\n sheetVerticalSize={sheetVerticalSize}\n {...menuProps}\n fixedTo={fixedTo}\n visible={visible}\n getDefaultFocusedIndex={(options) => {\n const defaultIndex = defaultFocusIndex.current;\n if (defaultIndex < 0) {\n return getLastFocusableIndex(options);\n }\n\n return defaultIndex;\n }}\n onRequestClose={onRequestClose}\n onEntered={(appearing) => {\n menuProps?.onEntered?.(appearing);\n // this will be called before `getDefaultFocusedIndex`\n if (disableTransition) {\n return;\n }\n\n defaultFocusIndex.current = 0;\n }}\n >\n {children}\n </Menu>\n </MenuVisibilityProvider>\n );\n}\n"],"names":["useCallback","useRef","useUserInteractionMode","getLastFocusableIndex","useEnsuredId","useEnsuredState","Menu","MenuButton","MenuConfigurationProvider","MenuItemButton","MenuVisibilityProvider","useMenuBarContext","DropdownMenu","props","id","propId","horizontal","sheetHeader","sheetFooter","renderAsSheet","sheetPosition","sheetVerticalSize","buttonChildren","iconRotatorProps","propIconRotatorProps","disableTransition","propDisableTransition","floating","anchor","vwMargin","vhMargin","xMargin","yMargin","initialX","initialY","width","transformOrigin","preventOverlap","disableSwapping","disableVHBounds","preventScroll","closeOnResize","closeOnScroll","getFixedPositionOptions","children","temporary","disablePortal","disableElevation","menuProps","menuStyle","menuClassName","sheetProps","sheetStyle","sheetClassName","visible","propVisible","setVisible","propSetVisible","remaining","fixedTo","defaultFocusIndex","name","value","setValue","defaultValue","menubar","menuitem","activeIdRef","animatedOnceRef","mode","mouse","keyboard","current","onRequestClose","toggle","ref","aria-labelledby","undefined","style","className","getDefaultFocusedIndex","options","defaultIndex","onEntered","appearing"],"mappings":"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"}
|
|
1
|
+
{"version":3,"sources":["../../src/menu/DropdownMenu.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n type RefObject,\n useCallback,\n useRef,\n} from \"react\";\n\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { getLastFocusableIndex } from \"../movement/utils.js\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { useEnsuredState } from \"../useEnsuredState.js\";\nimport {\n Menu,\n type MenuConvenienceProps,\n type MenuListConvenienceProps,\n} from \"./Menu.js\";\nimport { MenuButton, type MenuButtonProps } from \"./MenuButton.js\";\nimport {\n type MenuConfiguration,\n MenuConfigurationProvider,\n} from \"./MenuConfigurationProvider.js\";\nimport { MenuItemButton, type MenuItemButtonProps } from \"./MenuItemButton.js\";\nimport { type MenuSheetConvenienceProps } from \"./MenuSheet.js\";\nimport { MenuVisibilityProvider } from \"./MenuVisibilityProvider.js\";\nimport { useMenuBarContext } from \"./useMenuBarProvider.js\";\n\nexport interface BaseDropdownMenuProps\n extends\n MenuConfiguration,\n MenuListConvenienceProps,\n MenuSheetConvenienceProps,\n MenuConvenienceProps {\n buttonChildren: ReactNode;\n}\n\nexport interface DropdownMenuButtonProps\n extends MenuButtonProps, BaseDropdownMenuProps {}\n\nexport interface DropdownMenuItemButtonProps\n extends MenuItemButtonProps, BaseDropdownMenuProps {}\n\n/**\n * @since 6.0.0\n */\nexport interface DropdownMenuStateProps {\n visible: boolean;\n setVisible: UseStateSetter<boolean>;\n}\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Updated to use an `&` instead of `|` to allow autocompletion to\n * work better by default. It's up to the user to make sure they don't provide\n * incorrect props.\n */\nexport type DropdownMenuProps = DropdownMenuButtonProps &\n DropdownMenuItemButtonProps &\n (DropdownMenuStateProps | { visible?: never; setVisible?: never });\n\n/**\n * **Client Component**\n *\n * @example Simple Example\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { DropdownMenu } from \"@react-md/core/menu/DropdownMenu\";\n * import { MenuItem } from \"@react-md/core/menu/MenuItem\";\n *\n * function Example() {\n * return (\n * <DropdownMenu buttonChildren=\"Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Item 2\n * </MenuItem>\n * </DropdownMenu>\n * );\n * }\n * ```\n *\n * @example Nested Dropdown Menus\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { DropdownMenu } from \"@react-md/core/menu/DropdownMenu\";\n * import { MenuItem } from \"@react-md/core/menu/MenuItem\";\n *\n * function Example() {\n * return (\n * <DropdownMenu buttonChildren=\"Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Item 2\n * </MenuItem>\n * <DropdownMenu buttonChildren=\"Nested Dropdown\">\n * <MenuItem onClick={() => console.log('Clicked Item 1')}>\n * Nested Item 1\n * </MenuItem>\n * <MenuItem onClick={() => console.log('Clicked Item 2')}>\n * Nested Item 2\n * </MenuItem>\n * </DropdownMenu>\n * </DropdownMenu>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/menu | Menu Demos}\n * @since 5.0.0\n * @since 6.0.0 Updated to use the latest menu API.\n */\nexport function DropdownMenu(props: DropdownMenuProps): ReactElement {\n const {\n id: propId,\n horizontal,\n sheetHeader,\n sheetFooter,\n renderAsSheet,\n sheetPosition,\n sheetVerticalSize,\n buttonChildren,\n iconRotatorProps: propIconRotatorProps,\n disableTransition: propDisableTransition,\n floating,\n anchor,\n vwMargin,\n vhMargin,\n xMargin,\n yMargin,\n initialX,\n initialY,\n width,\n transformOrigin,\n preventOverlap,\n disableSwapping,\n disableVHBounds,\n preventScroll,\n closeOnResize,\n closeOnScroll,\n getFixedPositionOptions,\n children,\n temporary,\n disablePortal,\n disableElevation,\n menuProps,\n menuStyle,\n menuClassName,\n sheetProps,\n sheetStyle,\n sheetClassName,\n visible: propVisible,\n setVisible: propSetVisible,\n ...remaining\n } = props;\n\n const fixedTo = useRef<HTMLElement | HTMLButtonElement>(null);\n const defaultFocusIndex = useRef(0);\n const [visible, setVisible] = useEnsuredState({\n name: \"visible\",\n value: propVisible,\n setValue: propSetVisible,\n defaultValue: false,\n });\n const { menubar, menuitem, activeIdRef, animatedOnceRef } =\n useMenuBarContext();\n const id = useEnsuredId(propId, `menu${menuitem ? \"item\" : \"button\"}`);\n const mode = useUserInteractionMode();\n const mouse = mode === \"mouse\";\n const keyboard = mode === \"keyboard\";\n const disableTransition =\n propDisableTransition ??\n (animatedOnceRef.current &&\n menubar &&\n !!activeIdRef.current &&\n (mouse || keyboard));\n\n const onRequestClose = useCallback(() => {\n setVisible(false);\n }, [setVisible]);\n\n let iconRotatorProps = propIconRotatorProps;\n if (disableTransition) {\n iconRotatorProps = {\n disableTransition,\n ...propIconRotatorProps,\n };\n }\n\n let toggle: ReactElement;\n if (menuitem) {\n toggle = (\n <MenuItemButton\n {...(remaining as DropdownMenuItemButtonProps)}\n id={id}\n ref={fixedTo as RefObject<HTMLLIElement>}\n iconRotatorProps={iconRotatorProps}\n >\n {buttonChildren}\n </MenuItemButton>\n );\n } else {\n toggle = (\n <MenuButton\n {...(remaining as DropdownMenuButtonProps)}\n id={id}\n ref={fixedTo as RefObject<HTMLButtonElement>}\n floating={floating}\n iconRotatorProps={iconRotatorProps}\n >\n {buttonChildren}\n </MenuButton>\n );\n }\n\n return (\n <MenuVisibilityProvider\n visible={visible}\n setVisible={setVisible}\n defaultFocusIndex={defaultFocusIndex}\n >\n <MenuConfigurationProvider\n horizontal={horizontal}\n renderAsSheet={renderAsSheet}\n sheetFooter={sheetFooter}\n sheetHeader={sheetHeader}\n sheetPosition={sheetPosition}\n sheetVerticalSize={sheetVerticalSize}\n >\n {toggle}\n </MenuConfigurationProvider>\n <Menu\n aria-labelledby={(menuProps?.[\"aria-label\"] ? undefined : id) as string}\n style={menuStyle}\n className={menuClassName}\n sheetProps={sheetProps}\n sheetStyle={sheetStyle}\n sheetClassName={sheetClassName}\n temporary={temporary}\n disablePortal={disablePortal}\n disableElevation={disableElevation}\n disableTransition={disableTransition}\n floating={floating}\n anchor={anchor}\n vwMargin={vwMargin}\n vhMargin={vhMargin}\n xMargin={xMargin}\n yMargin={yMargin}\n initialX={initialX}\n initialY={initialY}\n width={width}\n transformOrigin={transformOrigin}\n preventOverlap={preventOverlap}\n disableSwapping={disableSwapping}\n disableVHBounds={disableVHBounds}\n preventScroll={preventScroll}\n closeOnResize={closeOnResize}\n closeOnScroll={closeOnScroll}\n getFixedPositionOptions={getFixedPositionOptions}\n horizontal={horizontal}\n sheetHeader={sheetHeader}\n sheetFooter={sheetFooter}\n renderAsSheet={renderAsSheet}\n sheetPosition={sheetPosition}\n sheetVerticalSize={sheetVerticalSize}\n {...menuProps}\n fixedTo={fixedTo}\n visible={visible}\n getDefaultFocusedIndex={(options) => {\n const defaultIndex = defaultFocusIndex.current;\n if (defaultIndex < 0) {\n return getLastFocusableIndex(options);\n }\n\n return defaultIndex;\n }}\n onRequestClose={onRequestClose}\n onEntered={(appearing) => {\n menuProps?.onEntered?.(appearing);\n // this will be called before `getDefaultFocusedIndex`\n if (disableTransition) {\n return;\n }\n\n defaultFocusIndex.current = 0;\n }}\n >\n {children}\n </Menu>\n </MenuVisibilityProvider>\n );\n}\n"],"names":["useCallback","useRef","useUserInteractionMode","getLastFocusableIndex","useEnsuredId","useEnsuredState","Menu","MenuButton","MenuConfigurationProvider","MenuItemButton","MenuVisibilityProvider","useMenuBarContext","DropdownMenu","props","id","propId","horizontal","sheetHeader","sheetFooter","renderAsSheet","sheetPosition","sheetVerticalSize","buttonChildren","iconRotatorProps","propIconRotatorProps","disableTransition","propDisableTransition","floating","anchor","vwMargin","vhMargin","xMargin","yMargin","initialX","initialY","width","transformOrigin","preventOverlap","disableSwapping","disableVHBounds","preventScroll","closeOnResize","closeOnScroll","getFixedPositionOptions","children","temporary","disablePortal","disableElevation","menuProps","menuStyle","menuClassName","sheetProps","sheetStyle","sheetClassName","visible","propVisible","setVisible","propSetVisible","remaining","fixedTo","defaultFocusIndex","name","value","setValue","defaultValue","menubar","menuitem","activeIdRef","animatedOnceRef","mode","mouse","keyboard","current","onRequestClose","toggle","ref","aria-labelledby","undefined","style","className","getDefaultFocusedIndex","options","defaultIndex","onEntered","appearing"],"mappings":"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"}
|