@react-md/core 1.0.0-next.14 → 1.0.0-next.15
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/.eslintrc.cjs +8 -0
- package/.turbo/turbo-build.log +22 -22
- package/.turbo/turbo-lint.log +3 -3
- package/.turbo/turbo-test.log +4000 -3982
- package/.turbo/turbo-typecheck.log +1 -23
- package/CHANGELOG.md +13 -0
- package/coverage/clover.xml +477 -410
- package/coverage/coverage-final.json +5 -4
- package/coverage/lcov-report/autocomplete/Autocomplete.tsx.html +81 -15
- package/coverage/lcov-report/autocomplete/AutocompleteClearButton.tsx.html +262 -0
- package/coverage/lcov-report/autocomplete/FilterAutocompleteOptions.tsx.html +364 -0
- package/coverage/lcov-report/autocomplete/index.html +48 -18
- package/coverage/lcov-report/card/Card.tsx.html +349 -0
- package/coverage/lcov-report/card/CardSubtitle.tsx.html +265 -0
- package/coverage/lcov-report/card/index.html +146 -0
- package/coverage/lcov-report/card/styles.ts.html +682 -0
- package/coverage/lcov-report/form/Option.tsx.html +727 -0
- package/coverage/lcov-report/form/index.html +131 -0
- package/coverage/lcov-report/form/useListboxProvider.ts.html +253 -0
- package/coverage/lcov-report/index.html +22 -37
- package/coverage/lcov-report/src/card/Card.tsx.html +349 -0
- package/coverage/lcov-report/src/card/CardSubtitle.tsx.html +277 -0
- package/coverage/lcov-report/src/card/index.html +146 -0
- package/coverage/lcov-report/src/card/styles.ts.html +682 -0
- package/coverage/lcov-report/src/cssUtils.ts.html +787 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/transition/index.html +116 -0
- package/coverage/lcov-report/src/transition/useCSSTransition.ts.html +766 -0
- package/coverage/lcov-report/transition/index.html +116 -0
- package/coverage/lcov-report/transition/useCSSTransition.ts.html +766 -0
- package/coverage/lcov.info +572 -456
- package/dist/CoreProviders.js.map +1 -1
- package/dist/NoSsr.js.map +1 -1
- package/dist/RootHtml.js.map +1 -1
- package/dist/SsrProvider.js.map +1 -1
- package/dist/app-bar/AppBar.js.map +1 -1
- package/dist/app-bar/AppBarTitle.d.ts +8 -4
- package/dist/app-bar/AppBarTitle.js +3 -2
- package/dist/app-bar/AppBarTitle.js.map +1 -1
- package/dist/autocomplete/Autocomplete.js.map +1 -1
- package/dist/autocomplete/AutocompleteCircularProgress.js.map +1 -1
- package/dist/autocomplete/AutocompleteDropdownButton.js.map +1 -1
- package/dist/autocomplete/FilterAutocompleteOptions.js.map +1 -1
- package/dist/autocomplete/autocompleteStyles.js.map +1 -1
- package/dist/autocomplete/defaults.d.ts +2 -2
- package/dist/autocomplete/defaults.js +3 -3
- package/dist/autocomplete/defaults.js.map +1 -1
- package/dist/autocomplete/types.js.map +1 -1
- package/dist/avatar/Avatar.d.ts +1 -2
- package/dist/avatar/Avatar.js +1 -2
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/avatar/styles.js.map +1 -1
- package/dist/badge/Badge.js.map +1 -1
- package/dist/box/Box.js.map +1 -1
- package/dist/box/styles.js.map +1 -1
- package/dist/button/AsyncButton.js.map +1 -1
- package/dist/button/Button.js.map +1 -1
- package/dist/button/ButtonUnstyled.js.map +1 -1
- package/dist/button/FloatingActionButton.js.map +1 -1
- package/dist/button/TooltippedButton.js.map +1 -1
- package/dist/button/buttonStyles.js.map +1 -1
- package/dist/button/buttonUnstyledStyles.js.map +1 -1
- package/dist/card/Card.d.ts +2 -1
- package/dist/card/Card.js.map +1 -1
- package/dist/card/CardContent.js.map +1 -1
- package/dist/card/CardFooter.js.map +1 -1
- package/dist/card/CardHeader.js.map +1 -1
- package/dist/card/CardSubtitle.d.ts +6 -0
- package/dist/card/CardSubtitle.js +2 -1
- package/dist/card/CardSubtitle.js.map +1 -1
- package/dist/card/CardTitle.js.map +1 -1
- package/dist/card/ClickableCard.js.map +1 -1
- package/dist/card/styles.js +2 -4
- package/dist/card/styles.js.map +1 -1
- package/dist/chip/Chip.js.map +1 -1
- package/dist/chip/styles.js.map +1 -1
- package/dist/cssUtils.d.ts +1 -1
- package/dist/cssUtils.js.map +1 -1
- package/dist/delegateEvent.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/dialog/DialogHeader.js.map +1 -1
- package/dist/dialog/DialogTitle.js.map +1 -1
- package/dist/dialog/FixedDialog.js.map +1 -1
- package/dist/dialog/NestedDialogProvider.js.map +1 -1
- package/dist/dialog/styles.js.map +1 -1
- package/dist/divider/Divider.js.map +1 -1
- package/dist/divider/styles.js.map +1 -1
- package/dist/draggable/useDraggable.js.map +1 -1
- package/dist/draggable/utils.js.map +1 -1
- package/dist/expansion-panel/ExpansionList.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
- package/dist/expansion-panel/useExpansionList.js.map +1 -1
- package/dist/expansion-panel/useExpansionPanels.js.map +1 -1
- package/dist/focus/useFocusContainer.js.map +1 -1
- package/dist/focus/utils.js.map +1 -1
- package/dist/form/Checkbox.js.map +1 -1
- package/dist/form/Fieldset.js.map +1 -1
- package/dist/form/FileInput.js.map +1 -1
- package/dist/form/Form.js.map +1 -1
- package/dist/form/FormMessage.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/InputToggleIcon.js.map +1 -1
- package/dist/form/Label.js.map +1 -1
- package/dist/form/Legend.js.map +1 -1
- package/dist/form/MenuItemCheckbox.js.map +1 -1
- package/dist/form/MenuItemFileInput.js.map +1 -1
- package/dist/form/MenuItemInputToggle.js.map +1 -1
- package/dist/form/MenuItemRadio.js.map +1 -1
- package/dist/form/MenuItemSwitch.js.map +1 -1
- package/dist/form/MenuItemTextField.js.map +1 -1
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/OptGroup.js.map +1 -1
- package/dist/form/Option.js.map +1 -1
- package/dist/form/Password.js.map +1 -1
- package/dist/form/Radio.js.map +1 -1
- package/dist/form/ResizingTextAreaWrapper.js.map +1 -1
- package/dist/form/Select.js.map +1 -1
- package/dist/form/SelectedOption.js.map +1 -1
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/SliderContainer.js.map +1 -1
- package/dist/form/SliderMark.js.map +1 -1
- package/dist/form/SliderMarkLabel.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/SliderValueTooltip.js.map +1 -1
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/SwitchTrack.js.map +1 -1
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/TextFieldAddon.js.map +1 -1
- package/dist/form/TextFieldContainer.js.map +1 -1
- package/dist/form/fileUtils.js.map +1 -1
- package/dist/form/formConfig.js.map +1 -1
- package/dist/form/formMessageStyles.js.map +1 -1
- package/dist/form/inputToggleStyles.js.map +1 -1
- package/dist/form/menuItemInputToggleStyles.js.map +1 -1
- package/dist/form/nativeSelectStyles.js.map +1 -1
- package/dist/form/optionStyles.js.map +1 -1
- package/dist/form/passwordStyles.js.map +1 -1
- package/dist/form/selectStyles.js.map +1 -1
- package/dist/form/selectUtils.js.map +1 -1
- package/dist/form/sliderUtils.js.map +1 -1
- package/dist/form/switchStyles.js.map +1 -1
- package/dist/form/textAreaStyles.js.map +1 -1
- package/dist/form/textFieldContainerStyles.js.map +1 -1
- package/dist/form/textFieldStyles.js.map +1 -1
- 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/useEditableCombobox.js.map +1 -1
- package/dist/form/useFileUpload.js.map +1 -1
- package/dist/form/useFormReset.js.map +1 -1
- package/dist/form/useListboxProvider.js.map +1 -1
- package/dist/form/useNumberField.js.map +1 -1
- package/dist/form/useRadioGroup.js.map +1 -1
- package/dist/form/useRangeSlider.js.map +1 -1
- package/dist/form/useResizingTextArea.js.map +1 -1
- package/dist/form/useSelectCombobox.js.map +1 -1
- package/dist/form/useSlider.js.map +1 -1
- package/dist/form/useTextField.js.map +1 -1
- package/dist/form/useTextFieldContainerAddons.js.map +1 -1
- package/dist/form/utils.js.map +1 -1
- package/dist/form/validation.js.map +1 -1
- package/dist/hoverMode/useHoverMode.js.map +1 -1
- package/dist/hoverMode/useHoverModeProvider.js.map +1 -1
- package/dist/icon/FontIcon.d.ts +10 -6
- package/dist/icon/FontIcon.js +1 -5
- package/dist/icon/FontIcon.js.map +1 -1
- package/dist/icon/IconRotator.js.map +1 -1
- package/dist/icon/MaterialIcon.d.ts +19 -2
- package/dist/icon/MaterialIcon.js +14 -2
- package/dist/icon/MaterialIcon.js.map +1 -1
- package/dist/icon/MaterialSymbol.js.map +1 -1
- package/dist/icon/SVGIcon.d.ts +3 -0
- package/dist/icon/SVGIcon.js.map +1 -1
- package/dist/icon/TextIconSpacing.js.map +1 -1
- package/dist/icon/iconConfig.d.ts +1 -0
- package/dist/icon/iconConfig.js +1 -0
- package/dist/icon/iconConfig.js.map +1 -1
- package/dist/icon/material.d.ts +1 -1
- package/dist/icon/material.js.map +1 -1
- package/dist/icon/materialConfig.js.map +1 -1
- package/dist/icon/styles.js.map +1 -1
- package/dist/interaction/Ripple.js.map +1 -1
- package/dist/interaction/RippleContainer.js.map +1 -1
- package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
- package/dist/interaction/config.js.map +1 -1
- package/dist/interaction/types.js.map +1 -1
- package/dist/interaction/useElementInteraction.js.map +1 -1
- package/dist/interaction/useHigherContrastChildren.js.map +1 -1
- package/dist/interaction/utils.js.map +1 -1
- 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/layoutNavStyles.js.map +1 -1
- package/dist/layout/layoutWindowSplitterStyles.js.map +1 -1
- package/dist/layout/mainStyles.js.map +1 -1
- package/dist/layout/useExpandableLayout.js.map +1 -1
- package/dist/layout/useHorizontalLayoutTransition.js.map +1 -1
- package/dist/layout/useLayoutAppBarHeight.js.map +1 -1
- package/dist/layout/useLayoutTree.js.map +1 -1
- package/dist/layout/useLayoutWindowSplitter.js.map +1 -1
- package/dist/layout/useMainTabIndex.js.map +1 -1
- package/dist/layout/useResizableLayout.js.map +1 -1
- package/dist/layout/useTemporaryLayout.js.map +1 -1
- package/dist/link/Link.d.ts +2 -4
- package/dist/link/Link.js +1 -2
- package/dist/link/Link.js.map +1 -1
- package/dist/link/SkipToMainContent.d.ts +10 -3
- package/dist/link/SkipToMainContent.js +4 -1
- package/dist/link/SkipToMainContent.js.map +1 -1
- package/dist/link/styles.d.ts +2 -2
- package/dist/link/styles.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/ListItemChildren.js.map +1 -1
- package/dist/list/ListItemLink.js.map +1 -1
- package/dist/list/ListItemText.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.js.map +1 -1
- package/dist/media-queries/appSize.js.map +1 -1
- package/dist/media-queries/useMediaQuery.js.map +1 -1
- package/dist/menu/DropdownMenu.js.map +1 -1
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuBar.js.map +1 -1
- package/dist/menu/MenuButton.js.map +1 -1
- package/dist/menu/MenuConfigurationProvider.js.map +1 -1
- package/dist/menu/MenuItem.js.map +1 -1
- package/dist/menu/MenuItemButton.js.map +1 -1
- package/dist/menu/MenuItemCircularProgress.js.map +1 -1
- package/dist/menu/MenuItemGroup.js.map +1 -1
- package/dist/menu/MenuItemSeparator.js.map +1 -1
- package/dist/menu/MenuSheet.js.map +1 -1
- package/dist/menu/MenuVisibilityProvider.js.map +1 -1
- package/dist/menu/MenuWidget.js.map +1 -1
- package/dist/menu/MenuWidgetKeyboardProvider.js.map +1 -1
- package/dist/menu/useContextMenu.js.map +1 -1
- package/dist/menu/useMenuBarProvider.js.map +1 -1
- package/dist/menu/utils.js.map +1 -1
- package/dist/movement/constants.js.map +1 -1
- package/dist/movement/findMatchIndex.js.map +1 -1
- package/dist/movement/types.js.map +1 -1
- package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
- package/dist/movement/utils.js.map +1 -1
- package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
- package/dist/navigation/DefaultNavigationRenderer.js.map +1 -1
- package/dist/navigation/NavGroup.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/NavSubheader.js.map +1 -1
- package/dist/navigation/Navigation.js.map +1 -1
- package/dist/navigation/getHrefFromParents.js.map +1 -1
- package/dist/navigation/navGroupStyles.js.map +1 -1
- package/dist/navigation/navItemStyles.js.map +1 -1
- package/dist/navigation/types.js.map +1 -1
- package/dist/navigation/useActiveHeadingId.js.map +1 -1
- package/dist/overlay/Overlay.d.ts +1 -0
- package/dist/overlay/Overlay.js.map +1 -1
- package/dist/overlay/overlayStyles.js.map +1 -1
- package/dist/portal/Portal.d.ts +4 -0
- package/dist/portal/Portal.js.map +1 -1
- package/dist/portal/PortalContainerProvider.d.ts +8 -3
- package/dist/portal/PortalContainerProvider.js +1 -0
- package/dist/portal/PortalContainerProvider.js.map +1 -1
- package/dist/positioning/constants.js.map +1 -1
- package/dist/positioning/createHorizontalPosition.js.map +1 -1
- package/dist/positioning/createVerticalPosition.js.map +1 -1
- package/dist/positioning/getFixedPosition.js.map +1 -1
- package/dist/positioning/types.js.map +1 -1
- package/dist/positioning/useFixedPositioning.js.map +1 -1
- package/dist/positioning/utils.js.map +1 -1
- package/dist/progress/CircularProgress.d.ts +5 -4
- package/dist/progress/CircularProgress.js.map +1 -1
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/getProgressA11y.js.map +1 -1
- package/dist/progress/types.js.map +1 -1
- package/dist/responsive-item/ResponsiveItemContainer.js.map +1 -1
- package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
- package/dist/responsive-item/styles.js.map +1 -1
- package/dist/scroll/ScrollLock.js.map +1 -1
- package/dist/scroll/getScrollbarWidth.js.map +1 -1
- package/dist/scroll/useScrollLock.js.map +1 -1
- package/dist/searching/caseInsensitive.js.map +1 -1
- package/dist/searching/fuzzy.js.map +1 -1
- package/dist/searching/toSearchQuery.js.map +1 -1
- package/dist/searching/types.js.map +1 -1
- package/dist/searching/useFuzzyMatch.js.map +1 -1
- package/dist/searching/utils.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/segmentedButtonContainerStyles.js.map +1 -1
- package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
- package/dist/sheet/Sheet.js.map +1 -1
- package/dist/sheet/styles.js.map +1 -1
- package/dist/snackbar/DefaultToastRenderer.js.map +1 -1
- package/dist/snackbar/Snackbar.js.map +1 -1
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/snackbar/ToastActionButton.js.map +1 -1
- package/dist/snackbar/ToastCloseButton.js.map +1 -1
- package/dist/snackbar/ToastContent.js.map +1 -1
- package/dist/snackbar/ToastManager.js.map +1 -1
- package/dist/snackbar/ToastManagerProvider.js.map +1 -1
- package/dist/snackbar/snackbarStyles.js.map +1 -1
- package/dist/snackbar/toastContentStyles.js.map +1 -1
- package/dist/snackbar/toastStyles.js.map +1 -1
- package/dist/snackbar/useCurrentToastActions.js.map +1 -1
- package/dist/suspense/CircularProgressSuspense.js.map +1 -1
- package/dist/suspense/NullSuspense.js.map +1 -1
- package/dist/table/StickyTableSection.d.ts +23 -0
- package/dist/table/StickyTableSection.js +56 -0
- package/dist/table/StickyTableSection.js.map +1 -0
- package/dist/table/Table.d.ts +1 -1
- package/dist/table/Table.js.map +1 -1
- package/dist/table/TableBody.d.ts +1 -1
- package/dist/table/TableBody.js.map +1 -1
- package/dist/table/TableCell.d.ts +3 -2
- package/dist/table/TableCell.js.map +1 -1
- package/dist/table/TableCellContent.d.ts +1 -2
- package/dist/table/TableCellContent.js.map +1 -1
- package/dist/table/TableCheckbox.js.map +1 -1
- package/dist/table/TableConfigurationProvider.d.ts +1 -73
- package/dist/table/TableConfigurationProvider.js.map +1 -1
- package/dist/table/TableContainer.js.map +1 -1
- package/dist/table/TableContainerProvider.js.map +1 -1
- package/dist/table/TableFooter.d.ts +8 -17
- package/dist/table/TableFooter.js +17 -80
- package/dist/table/TableFooter.js.map +1 -1
- package/dist/table/TableHeader.d.ts +8 -17
- package/dist/table/TableHeader.js +20 -87
- package/dist/table/TableHeader.js.map +1 -1
- package/dist/table/TableRadio.js.map +1 -1
- package/dist/table/TableRow.d.ts +1 -1
- package/dist/table/TableRow.js.map +1 -1
- package/dist/table/tableCellStyles.d.ts +1 -1
- package/dist/table/tableCellStyles.js.map +1 -1
- package/dist/table/tableContainerStyles.js.map +1 -1
- package/dist/table/tableFooterStyles.js.map +1 -1
- package/dist/table/tableHeaderStyles.js.map +1 -1
- package/dist/table/tableRowStyles.js.map +1 -1
- package/dist/table/tableStyles.js.map +1 -1
- package/dist/table/types.d.ts +89 -9
- package/dist/table/types.js.map +1 -1
- package/dist/table/useStickyTableSection.d.ts +27 -0
- package/dist/table/useStickyTableSection.js +84 -0
- package/dist/table/useStickyTableSection.js.map +1 -0
- package/dist/table/useTableSectionConfig.d.ts +13 -0
- package/dist/table/useTableSectionConfig.js +33 -0
- package/dist/table/useTableSectionConfig.js.map +1 -0
- 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/tabIndicatorStyles.js.map +1 -1
- package/dist/tabs/tabListScrollButtonStyles.js.map +1 -1
- package/dist/tabs/tabListStyles.js.map +1 -1
- package/dist/tabs/tabStyles.js.map +1 -1
- package/dist/tabs/useTabList.js.map +1 -1
- package/dist/tabs/useTabs.js.map +1 -1
- package/dist/tabs/utils.js.map +1 -1
- package/dist/test-utils/IntersectionObserver.js.map +1 -1
- package/dist/test-utils/ResizeObserver.js.map +1 -1
- package/dist/test-utils/data-testid.js.map +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/jest-setup.js.map +1 -1
- package/dist/test-utils/matchMedia.js.map +1 -1
- package/dist/test-utils/polyfills/IntersectionObserver.js.map +1 -1
- package/dist/test-utils/polyfills/ResizeObserver.js.map +1 -1
- package/dist/test-utils/polyfills/TextDecoder.js.map +1 -1
- package/dist/test-utils/polyfills/TextEncoder.js.map +1 -1
- package/dist/test-utils/polyfills/index.js.map +1 -1
- package/dist/test-utils/polyfills/matchMedia.js.map +1 -1
- package/dist/test-utils/polyfills/offsetParent.js.map +1 -1
- package/dist/test-utils/polyfills/scrollIntoView.js.map +1 -1
- package/dist/test-utils/render.js.map +1 -1
- package/dist/test-utils/timers.js.map +1 -1
- package/dist/theme/LocalStorageColorSchemeProvider.js.map +1 -1
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/_theme.scss +2 -1
- package/dist/theme/colors.js.map +1 -1
- package/dist/theme/cssVars.js.map +1 -1
- package/dist/theme/types.js.map +1 -1
- package/dist/theme/useCSSVariables.js.map +1 -1
- package/dist/theme/useColorScheme.js.map +1 -1
- package/dist/theme/useColorSchemeMetaTag.js.map +1 -1
- package/dist/theme/useColorSchemeProvider.js.map +1 -1
- package/dist/theme/usePrefersColorScheme.js.map +1 -1
- package/dist/theme/utils.js.map +1 -1
- package/dist/tooltip/Tooltip.d.ts +20 -9
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/TooltipHoverModeProvider.js.map +1 -1
- package/dist/tooltip/constants.js.map +1 -1
- package/dist/tooltip/tooltipStyles.js.map +1 -1
- package/dist/tooltip/useTooltip.d.ts +30 -16
- package/dist/tooltip/useTooltip.js.map +1 -1
- package/dist/tooltip/useTooltipPosition.d.ts +2 -4
- package/dist/tooltip/useTooltipPosition.js.map +1 -1
- package/dist/tooltip/utils.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/collapseStyles.js.map +1 -1
- package/dist/transition/config.js.map +1 -1
- package/dist/transition/maxWidthTransition.js.map +1 -1
- package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
- package/dist/transition/types.d.ts +19 -24
- package/dist/transition/types.js.map +1 -1
- package/dist/transition/useCSSTransition.js.map +1 -1
- package/dist/transition/useCarousel.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/transition/useSlideTransition.js.map +1 -1
- package/dist/transition/useTransition.d.ts +1 -0
- package/dist/transition/useTransition.js +1 -0
- package/dist/transition/useTransition.js.map +1 -1
- package/dist/transition/utils.js.map +1 -1
- package/dist/tree/DefaultTreeItemRenderer.js.map +1 -1
- package/dist/tree/Tree.js.map +1 -1
- package/dist/tree/TreeGroup.js.map +1 -1
- package/dist/tree/TreeItem.js.map +1 -1
- package/dist/tree/TreeItemExpander.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/useTree.d.ts +3 -3
- package/dist/tree/useTree.js.map +1 -1
- package/dist/tree/useTreeExpansion.js.map +1 -1
- package/dist/tree/useTreeItems.js.map +1 -1
- package/dist/tree/useTreeMovement.js.map +1 -1
- package/dist/tree/useTreeSelection.js.map +1 -1
- package/dist/tree/utils.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/typography/SrOnly.js.map +1 -1
- package/dist/typography/TextContainer.d.ts +4 -0
- package/dist/typography/TextContainer.js +2 -0
- package/dist/typography/TextContainer.js.map +1 -1
- package/dist/typography/Typography.d.ts +10 -0
- package/dist/typography/Typography.js +3 -0
- package/dist/typography/Typography.js.map +1 -1
- package/dist/typography/WritingDirectionProvider.js.map +1 -1
- package/dist/typography/textContainerStyles.js.map +1 -1
- package/dist/typography/typographyStyles.js.map +1 -1
- package/dist/useAsyncFunction.js.map +1 -1
- package/dist/useDebouncedFunction.js.map +1 -1
- package/dist/useDropzone.js.map +1 -1
- package/dist/useElementSize.js.map +1 -1
- package/dist/useEnsuredId.js.map +1 -1
- package/dist/useEnsuredRef.js.map +1 -1
- package/dist/useEnsuredState.js.map +1 -1
- package/dist/useHtmlClassName.js.map +1 -1
- package/dist/useIntersectionObserver.js.map +1 -1
- package/dist/useIsomorphicLayoutEffect.js.map +1 -1
- package/dist/useLocalStorage.js.map +1 -1
- package/dist/useMutationObserver.js.map +1 -1
- package/dist/useOrientation.js.map +1 -1
- package/dist/usePageInactive.js.map +1 -1
- package/dist/useResizeListener.js.map +1 -1
- package/dist/useResizeObserver.js.map +1 -1
- package/dist/useThrottledFunction.js.map +1 -1
- package/dist/useToggle.js.map +1 -1
- package/dist/useUnmounted.js.map +1 -1
- package/dist/useWindowSize.js.map +1 -1
- package/dist/utils/RenderRecursively.js.map +1 -1
- package/dist/utils/alphaNumericSort.js.map +1 -1
- package/dist/utils/applyRef.js.map +1 -1
- package/dist/utils/bem.js.map +1 -1
- package/dist/utils/getClientPosition.js.map +1 -1
- package/dist/utils/getMiddleOfRange.js.map +1 -1
- package/dist/utils/getPercentage.js.map +1 -1
- package/dist/utils/getRangeDefaultValue.js.map +1 -1
- package/dist/utils/getRangeSteps.js.map +1 -1
- package/dist/utils/identity.js.map +1 -1
- package/dist/utils/isElementVisible.js.map +1 -1
- package/dist/utils/loop.js.map +1 -1
- package/dist/utils/nearest.js.map +1 -1
- package/dist/utils/parseCssLengthUnit.js.map +1 -1
- package/dist/utils/randomInt.js.map +1 -1
- package/dist/utils/wait.js.map +1 -1
- package/dist/utils/withinRange.js.map +1 -1
- package/dist/window-splitter/WindowSplitter.js.map +1 -1
- package/dist/window-splitter/useWindowSplitter.js.map +1 -1
- package/package.json +21 -20
- package/scripts/getExportMap.ts +66 -0
- package/scripts/tsconfig.json +1 -1
- package/src/app-bar/AppBarTitle.tsx +8 -4
- package/src/autocomplete/defaults.ts +3 -3
- package/src/avatar/Avatar.tsx +1 -2
- package/src/card/Card.tsx +2 -1
- package/src/card/CardSubtitle.tsx +9 -0
- package/src/card/__tests__/__snapshots__/CardHeader.tsx.snap +1 -1
- package/src/card/__tests__/__snapshots__/CardSubtitle.tsx.snap +2 -2
- package/src/card/__tests__/__snapshots__/styles.ts.snap +1 -1
- package/src/card/styles.ts +2 -6
- package/src/cssUtils.ts +1 -1
- package/src/icon/FontIcon.tsx +19 -9
- package/src/icon/MaterialIcon.tsx +23 -4
- package/src/icon/SVGIcon.tsx +3 -0
- package/src/icon/iconConfig.tsx +1 -0
- package/src/icon/material.ts +276 -19
- package/src/link/Link.tsx +2 -4
- package/src/link/SkipToMainContent.tsx +11 -4
- package/src/link/styles.ts +2 -2
- package/src/overlay/Overlay.tsx +1 -0
- package/src/portal/Portal.tsx +5 -0
- package/src/portal/PortalContainerProvider.tsx +16 -7
- package/src/progress/CircularProgress.tsx +5 -4
- package/src/table/StickyTableSection.tsx +91 -0
- package/src/table/Table.tsx +2 -5
- package/src/table/TableBody.tsx +1 -2
- package/src/table/TableCell.tsx +3 -5
- package/src/table/TableCellContent.tsx +1 -3
- package/src/table/TableConfigurationProvider.tsx +1 -86
- package/src/table/TableFooter.tsx +19 -116
- package/src/table/TableHeader.tsx +20 -118
- package/src/table/TableRow.tsx +2 -4
- package/src/table/__tests__/Table.tsx +9 -8
- package/src/table/tableCellStyles.ts +1 -1
- package/src/table/types.ts +105 -10
- package/src/table/useStickyTableSection.tsx +126 -0
- package/src/table/useTableSectionConfig.ts +45 -0
- package/src/theme/_theme.scss +2 -1
- package/src/tooltip/Tooltip.tsx +24 -8
- package/src/tooltip/useTooltip.ts +52 -27
- package/src/tooltip/useTooltipPosition.ts +2 -4
- package/src/transition/types.ts +23 -27
- package/src/transition/useTransition.ts +1 -0
- package/src/tree/useTree.ts +3 -5
- package/src/typography/TextContainer.tsx +4 -0
- package/src/typography/Typography.tsx +10 -0
- package/src/useResizeListener.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/menu/MenuSheet.tsx"],"sourcesContent":["\"use client\";\nimport { type CSSProperties, type ReactElement, type ReactNode } from \"react\";\nimport { Sheet, type BaseSheetProps } from \"../sheet/Sheet.js\";\nimport { type LabelRequiredForA11y, type PropsWithRef } from \"../types.js\";\nimport { type RenderMenuAsSheet } from \"./MenuConfigurationProvider.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type MenuSheetConfigurableProps = Omit<\n BaseSheetProps,\n \"visible\" | \"onRequestClose\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface MenuSheetConvenienceProps {\n /**\n * This can be used to apply additional props to the `Sheet` component when\n * the `Menu` is being rendered as a `Sheet`.\n *\n * Note: You can override the `style` and `className` using\n * {@link sheetStyle} and {@link sheetClassName} instead for convenience.\n *\n * @example\n * ```tsx\n * <Menu\n * {...props}\n * sheetProps={{\n * style: {\n * // custom inline style\n * },\n * className: \"come-class-name\",\n * horizontalSize: \"touch\",\n * }}\n * />\n * ```\n */\n sheetProps?: PropsWithRef<MenuSheetConfigurableProps, HTMLDivElement>;\n\n /**\n * Convenience prop to apply custom style to the `Sheet` component when the\n * `Menu` is being rendered as a `Sheet`.\n */\n sheetStyle?: CSSProperties;\n\n /**\n * Convenience prop to apply custom class name to the `Sheet` component when\n * the `Menu` is being rendered as a `Sheet`.\n */\n sheetClassName?: string;\n}\n\n/**\n * @internal\n * @since 5.0.0\n * @since 6.0.0 Updated to use the latest menu API.\n */\nexport interface MenuSheetProps extends BaseSheetProps {\n /** {@inheritDoc MenuConfiguration.sheetHeader} */\n header?: ReactNode;\n /** {@inheritDoc MenuConfiguration.sheetFooter} */\n footer?: ReactNode;\n children: ReactNode;\n\n /** @since 6.0.0 */\n enabled: RenderMenuAsSheet;\n}\n\n/**\n * **Client Component**\n *\n * Implements a `Menu` using the `Sheet` component that probably shouldn't\n * really be used externally.\n *\n * @internal\n * @since 5.0.0\n * @since 6.0.0 Added the `enabled` prop and does not render a custom `Menu`\n * implementation.\n */\nexport function MenuSheet(\n props: LabelRequiredForA11y<MenuSheetProps>\n): ReactElement {\n const {\n header,\n footer,\n children,\n onClick = noop,\n overlayProps,\n enabled,\n ...remaining\n } = props;\n const { onRequestClose } = props;\n\n if (!enabled) {\n return <>{children}</>;\n }\n\n return (\n <Sheet\n {...remaining}\n onClick={(event) => {\n onClick(event);\n\n // Prevent closing parent sheet/menus if an element in the header or\n // footer is clicked\n if (\n !(event.target instanceof HTMLElement) ||\n event.target\n .closest('.rmd-menu,[role=\"dialog\"]')\n ?.getAttribute(\"role\") === \"dialog\"\n ) {\n event.stopPropagation();\n }\n }}\n overlayProps={{\n ...overlayProps,\n onClick: (event) => {\n overlayProps?.onClick?.(event);\n\n // prevent closing parent menus if the overlay element is clicked.\n event.stopPropagation();\n onRequestClose();\n },\n }}\n >\n {header}\n {children}\n {footer}\n </Sheet>\n );\n}\n"],"names":["Sheet","noop","MenuSheet","props","header","footer","children","onClick","overlayProps","enabled","remaining","onRequestClose","event","target","HTMLElement","closest","getAttribute","stopPropagation"],"
|
|
1
|
+
{"version":3,"sources":["../../src/menu/MenuSheet.tsx"],"sourcesContent":["\"use client\";\nimport { type CSSProperties, type ReactElement, type ReactNode } from \"react\";\nimport { Sheet, type BaseSheetProps } from \"../sheet/Sheet.js\";\nimport { type LabelRequiredForA11y, type PropsWithRef } from \"../types.js\";\nimport { type RenderMenuAsSheet } from \"./MenuConfigurationProvider.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type MenuSheetConfigurableProps = Omit<\n BaseSheetProps,\n \"visible\" | \"onRequestClose\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface MenuSheetConvenienceProps {\n /**\n * This can be used to apply additional props to the `Sheet` component when\n * the `Menu` is being rendered as a `Sheet`.\n *\n * Note: You can override the `style` and `className` using\n * {@link sheetStyle} and {@link sheetClassName} instead for convenience.\n *\n * @example\n * ```tsx\n * <Menu\n * {...props}\n * sheetProps={{\n * style: {\n * // custom inline style\n * },\n * className: \"come-class-name\",\n * horizontalSize: \"touch\",\n * }}\n * />\n * ```\n */\n sheetProps?: PropsWithRef<MenuSheetConfigurableProps, HTMLDivElement>;\n\n /**\n * Convenience prop to apply custom style to the `Sheet` component when the\n * `Menu` is being rendered as a `Sheet`.\n */\n sheetStyle?: CSSProperties;\n\n /**\n * Convenience prop to apply custom class name to the `Sheet` component when\n * the `Menu` is being rendered as a `Sheet`.\n */\n sheetClassName?: string;\n}\n\n/**\n * @internal\n * @since 5.0.0\n * @since 6.0.0 Updated to use the latest menu API.\n */\nexport interface MenuSheetProps extends BaseSheetProps {\n /** {@inheritDoc MenuConfiguration.sheetHeader} */\n header?: ReactNode;\n /** {@inheritDoc MenuConfiguration.sheetFooter} */\n footer?: ReactNode;\n children: ReactNode;\n\n /** @since 6.0.0 */\n enabled: RenderMenuAsSheet;\n}\n\n/**\n * **Client Component**\n *\n * Implements a `Menu` using the `Sheet` component that probably shouldn't\n * really be used externally.\n *\n * @internal\n * @since 5.0.0\n * @since 6.0.0 Added the `enabled` prop and does not render a custom `Menu`\n * implementation.\n */\nexport function MenuSheet(\n props: LabelRequiredForA11y<MenuSheetProps>\n): ReactElement {\n const {\n header,\n footer,\n children,\n onClick = noop,\n overlayProps,\n enabled,\n ...remaining\n } = props;\n const { onRequestClose } = props;\n\n if (!enabled) {\n return <>{children}</>;\n }\n\n return (\n <Sheet\n {...remaining}\n onClick={(event) => {\n onClick(event);\n\n // Prevent closing parent sheet/menus if an element in the header or\n // footer is clicked\n if (\n !(event.target instanceof HTMLElement) ||\n event.target\n .closest('.rmd-menu,[role=\"dialog\"]')\n ?.getAttribute(\"role\") === \"dialog\"\n ) {\n event.stopPropagation();\n }\n }}\n overlayProps={{\n ...overlayProps,\n onClick: (event) => {\n overlayProps?.onClick?.(event);\n\n // prevent closing parent menus if the overlay element is clicked.\n event.stopPropagation();\n onRequestClose();\n },\n }}\n >\n {header}\n {children}\n {footer}\n </Sheet>\n );\n}\n"],"names":["Sheet","noop","MenuSheet","props","header","footer","children","onClick","overlayProps","enabled","remaining","onRequestClose","event","target","HTMLElement","closest","getAttribute","stopPropagation"],"mappings":"AAAA;;AAEA,SAASA,KAAK,QAA6B,oBAAoB;AAI/D,MAAMC,OAAO;AACX,aAAa;AACf;AAkEA;;;;;;;;;;CAUC,GACD,OAAO,SAASC,UACdC,KAA2C;IAE3C,MAAM,EACJC,MAAM,EACNC,MAAM,EACNC,QAAQ,EACRC,UAAUN,IAAI,EACdO,YAAY,EACZC,OAAO,EACP,GAAGC,WACJ,GAAGP;IACJ,MAAM,EAAEQ,cAAc,EAAE,GAAGR;IAE3B,IAAI,CAACM,SAAS;QACZ,qBAAO;sBAAGH;;IACZ;IAEA,qBACE,MAACN;QACE,GAAGU,SAAS;QACbH,SAAS,CAACK;YACRL,QAAQK;YAER,oEAAoE;YACpE,oBAAoB;YACpB,IACE,CAAEA,CAAAA,MAAMC,MAAM,YAAYC,WAAU,KACpCF,MAAMC,MAAM,CACTE,OAAO,CAAC,8BACPC,aAAa,YAAY,UAC7B;gBACAJ,MAAMK,eAAe;YACvB;QACF;QACAT,cAAc;YACZ,GAAGA,YAAY;YACfD,SAAS,CAACK;gBACRJ,cAAcD,UAAUK;gBAExB,kEAAkE;gBAClEA,MAAMK,eAAe;gBACrBN;YACF;QACF;;YAECP;YACAE;YACAD;;;AAGP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/menu/MenuVisibilityProvider.tsx"],"sourcesContent":["\"use client\";\nimport {\n createContext,\n useContext,\n useMemo,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { type NonNullMutableRef, type UseStateObject } from \"../types.js\";\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Added the `defaultFocusIndex` ref.\n */\nexport interface MenuVisibilityContext\n extends UseStateObject<\"visible\", boolean> {\n defaultFocusIndex: NonNullMutableRef<number>;\n}\n\n/**\n * @internal\n * @since 5.0.0\n */\nconst context = createContext<MenuVisibilityContext>({\n visible: false,\n setVisible() {\n throw new Error('\"MenuVisibilityProvider\" must be a parent component');\n },\n defaultFocusIndex: { current: 0 },\n});\ncontext.displayName = \"MenuVisibility\";\n\n/**\n * @internal\n * @since 5.0.0\n */\nconst { Provider } = context;\n\n/**\n * This hook allows you control the visibility of a parent menu. The main\n * use-case for this hook is adding a custom sheet header/footer.\n *\n * @example Simple Example\n * ```tsx\n * function SheetFooter(): ReactElement {\n * const { setVisible } = useMenuVisibility();\n *\n * return (\n * <DialogFooter>\n * <Button onClick={() => setVisible(false)}>Cancel</Button>\n * </DialogFooter>\n * );\n * }\n * ```\n *\n * @returns the {@link MenuVisibilityContext}\n * @since 5.0.0\n */\nexport function useMenuVisibility(): Readonly<MenuVisibilityContext> {\n return useContext(context);\n}\n\n/**\n * @internal\n * @since 5.0.0\n */\nexport interface MenuVisibilityProviderProps extends MenuVisibilityContext {\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @internal\n * @since 5.0.0\n */\nexport function MenuVisibilityProvider({\n visible,\n setVisible,\n defaultFocusIndex,\n children,\n}: MenuVisibilityProviderProps): ReactElement {\n const value = useMemo<MenuVisibilityContext>(\n () => ({\n visible,\n setVisible,\n defaultFocusIndex,\n }),\n [visible, setVisible, defaultFocusIndex]\n );\n\n return <Provider value={value}>{children}</Provider>;\n}\n"],"names":["createContext","useContext","useMemo","context","visible","setVisible","Error","defaultFocusIndex","current","displayName","Provider","useMenuVisibility","MenuVisibilityProvider","children","value"],"
|
|
1
|
+
{"version":3,"sources":["../../src/menu/MenuVisibilityProvider.tsx"],"sourcesContent":["\"use client\";\nimport {\n createContext,\n useContext,\n useMemo,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { type NonNullMutableRef, type UseStateObject } from \"../types.js\";\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Added the `defaultFocusIndex` ref.\n */\nexport interface MenuVisibilityContext\n extends UseStateObject<\"visible\", boolean> {\n defaultFocusIndex: NonNullMutableRef<number>;\n}\n\n/**\n * @internal\n * @since 5.0.0\n */\nconst context = createContext<MenuVisibilityContext>({\n visible: false,\n setVisible() {\n throw new Error('\"MenuVisibilityProvider\" must be a parent component');\n },\n defaultFocusIndex: { current: 0 },\n});\ncontext.displayName = \"MenuVisibility\";\n\n/**\n * @internal\n * @since 5.0.0\n */\nconst { Provider } = context;\n\n/**\n * This hook allows you control the visibility of a parent menu. The main\n * use-case for this hook is adding a custom sheet header/footer.\n *\n * @example Simple Example\n * ```tsx\n * function SheetFooter(): ReactElement {\n * const { setVisible } = useMenuVisibility();\n *\n * return (\n * <DialogFooter>\n * <Button onClick={() => setVisible(false)}>Cancel</Button>\n * </DialogFooter>\n * );\n * }\n * ```\n *\n * @returns the {@link MenuVisibilityContext}\n * @since 5.0.0\n */\nexport function useMenuVisibility(): Readonly<MenuVisibilityContext> {\n return useContext(context);\n}\n\n/**\n * @internal\n * @since 5.0.0\n */\nexport interface MenuVisibilityProviderProps extends MenuVisibilityContext {\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @internal\n * @since 5.0.0\n */\nexport function MenuVisibilityProvider({\n visible,\n setVisible,\n defaultFocusIndex,\n children,\n}: MenuVisibilityProviderProps): ReactElement {\n const value = useMemo<MenuVisibilityContext>(\n () => ({\n visible,\n setVisible,\n defaultFocusIndex,\n }),\n [visible, setVisible, defaultFocusIndex]\n );\n\n return <Provider value={value}>{children}</Provider>;\n}\n"],"names":["createContext","useContext","useMemo","context","visible","setVisible","Error","defaultFocusIndex","current","displayName","Provider","useMenuVisibility","MenuVisibilityProvider","children","value"],"mappings":"AAAA;;AACA,SACEA,aAAa,EACbC,UAAU,EACVC,OAAO,QAGF,QAAQ;AAYf;;;CAGC,GACD,MAAMC,wBAAUH,cAAqC;IACnDI,SAAS;IACTC;QACE,MAAM,IAAIC,MAAM;IAClB;IACAC,mBAAmB;QAAEC,SAAS;IAAE;AAClC;AACAL,QAAQM,WAAW,GAAG;AAEtB;;;CAGC,GACD,MAAM,EAAEC,QAAQ,EAAE,GAAGP;AAErB;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASQ;IACd,OAAOV,WAAWE;AACpB;AAUA;;;;;CAKC,GACD,OAAO,SAASS,uBAAuB,EACrCR,OAAO,EACPC,UAAU,EACVE,iBAAiB,EACjBM,QAAQ,EACoB;IAC5B,MAAMC,QAAQZ,QACZ,IAAO,CAAA;YACLE;YACAC;YACAE;QACF,CAAA,GACA;QAACH;QAASC;QAAYE;KAAkB;IAG1C,qBAAO,KAACG;QAASI,OAAOA;kBAAQD;;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/menu/MenuWidget.tsx"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport { forwardRef, useRef, useState, type HTMLAttributes } from \"react\";\nimport { List } from \"../list/List.js\";\nimport { type GetDefaultFocusedIndex } from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { type NonNullMutableRef } from \"../types.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { type MenuListConvenienceProps } from \"./Menu.js\";\nimport { MenuWidgetKeyboardProvider } from \"./MenuWidgetKeyboardProvider.js\";\nimport {\n MenuBarProvider,\n useMenuBarContext,\n useMenuBarProvider,\n} from \"./useMenuBarProvider.js\";\n\nconst styles = bem(\"rmd-menu\");\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport interface MenuClassNameOptions {\n className?: string;\n horizontal?: boolean;\n elevated?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function menu(options: MenuClassNameOptions = {}): string {\n const { className, horizontal, elevated } = options;\n\n return cnb(styles({ horizontal, elevated }), className);\n}\n\n/**\n * @internal\n */\nexport interface MenuWidgetProps\n extends HTMLAttributes<HTMLDivElement>,\n MenuListConvenienceProps {\n isSheet: boolean;\n horizontal: boolean;\n disableElevation?: boolean;\n cancelUnmountFocus: NonNullMutableRef<boolean>;\n getDefaultFocusedIndex?: GetDefaultFocusedIndex;\n}\n\n/**\n * **Client Component**\n *\n * This component was added to support the listbox role and the `useId()` hook.\n * If the `temporary` prop is set, the `MenuItem`'s ids will not be the same the\n * next time the menu opens, so the aria-activedescendant will point to a\n * non-existing id\n *\n * @internal\n */\nexport const MenuWidget = forwardRef<HTMLDivElement, MenuWidgetProps>(\n function MenuWidget(props, ref) {\n const {\n id,\n role = \"menu\",\n className,\n listStyle,\n listClassName,\n listProps,\n children,\n onClick,\n onBlur = noop,\n onFocus = noop,\n onKeyDown = noop,\n tabIndex = -1,\n isSheet,\n horizontal,\n disableElevation,\n cancelUnmountFocus,\n getDefaultFocusedIndex,\n ...remaining\n } = props;\n const isListbox = role === \"listbox\";\n const { menubar } = useMenuBarContext();\n\n // Since there is the possibility of other tab focusable elements within the\n // sheet and the menu items are programmatically focused, the menu's\n // tabIndex needs to be set to `-1` while one of the child menu items are\n // focused. This allows Shift+Tab correctly focuses the previous focusable\n // element within the sheet. Since `onFocus` and `onBlur` will be bubbled up\n // to the menu widget each time a new MenuItem is focused, only disable the\n // focused state if the blur event is fired without another focus event\n // within an animation frame.\n const [sheetMenuFocused, setSheetMenuFocused] = useState(false);\n const sheetBlurredFame = useRef(0);\n const menuBarContext = useMenuBarProvider({\n root: false,\n menubar,\n hoverTimeout: menubar ? 0 : undefined,\n defaultActiveId: id,\n });\n const { movementProps, movementContext } = useKeyboardMovementProvider({\n onClick,\n onFocus(event) {\n onFocus(event);\n\n if (!isSheet) {\n return;\n }\n\n window.cancelAnimationFrame(sheetBlurredFame.current);\n setSheetMenuFocused(true);\n },\n onKeyDown,\n horizontal,\n loopable: true,\n searchable: true,\n programmatic: true,\n includeDisabled: true,\n getDefaultFocusedIndex,\n });\n\n return (\n <MenuWidgetKeyboardProvider disabled={isListbox} value={movementContext}>\n <MenuBarProvider value={menuBarContext}>\n <div\n aria-orientation={horizontal ? \"horizontal\" : undefined}\n {...remaining}\n {...(isListbox ? { onClick, onFocus, onKeyDown } : movementProps)}\n id={id}\n ref={ref}\n role={role}\n className={menu({\n className,\n elevated: !disableElevation && !isSheet,\n horizontal,\n })}\n tabIndex={isSheet && !sheetMenuFocused ? 0 : tabIndex}\n onBlur={(event) => {\n onBlur(event);\n if (!isSheet) {\n return;\n }\n\n sheetBlurredFame.current = window.requestAnimationFrame(() => {\n setSheetMenuFocused(false);\n });\n }}\n >\n <List\n {...listProps}\n style={listStyle ?? listProps?.style}\n className={listClassName || listProps?.className}\n horizontal={horizontal}\n onClick={(event) => {\n listProps?.onClick?.(event);\n\n // this makes it so you can click on the menu/list without\n // closing the menu\n if (event.target === event.currentTarget) {\n event.stopPropagation();\n }\n\n // This might be a test only workaround since clicking links move focus\n // somewhere else\n if (event.target instanceof HTMLElement) {\n cancelUnmountFocus.current = event.currentTarget.contains(\n event.target.closest(\"a\")\n );\n }\n }}\n >\n {children}\n </List>\n </div>\n </MenuBarProvider>\n </MenuWidgetKeyboardProvider>\n );\n }\n);\n"],"names":["cnb","forwardRef","useRef","useState","List","useKeyboardMovementProvider","bem","MenuWidgetKeyboardProvider","MenuBarProvider","useMenuBarContext","useMenuBarProvider","styles","noop","menu","options","className","horizontal","elevated","MenuWidget","props","ref","id","role","listStyle","listClassName","listProps","children","onClick","onBlur","onFocus","onKeyDown","tabIndex","isSheet","disableElevation","cancelUnmountFocus","getDefaultFocusedIndex","remaining","isListbox","menubar","sheetMenuFocused","setSheetMenuFocused","sheetBlurredFame","menuBarContext","root","hoverTimeout","undefined","defaultActiveId","movementProps","movementContext","event","window","cancelAnimationFrame","current","loopable","searchable","programmatic","includeDisabled","disabled","value","div","aria-orientation","requestAnimationFrame","style","target","currentTarget","stopPropagation","HTMLElement","contains","closest"],"
|
|
1
|
+
{"version":3,"sources":["../../src/menu/MenuWidget.tsx"],"sourcesContent":["\"use client\";\nimport { cnb } from \"cnbuilder\";\nimport { forwardRef, useRef, useState, type HTMLAttributes } from \"react\";\nimport { List } from \"../list/List.js\";\nimport { type GetDefaultFocusedIndex } from \"../movement/types.js\";\nimport { useKeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\nimport { type NonNullMutableRef } from \"../types.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { type MenuListConvenienceProps } from \"./Menu.js\";\nimport { MenuWidgetKeyboardProvider } from \"./MenuWidgetKeyboardProvider.js\";\nimport {\n MenuBarProvider,\n useMenuBarContext,\n useMenuBarProvider,\n} from \"./useMenuBarProvider.js\";\n\nconst styles = bem(\"rmd-menu\");\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport interface MenuClassNameOptions {\n className?: string;\n horizontal?: boolean;\n elevated?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function menu(options: MenuClassNameOptions = {}): string {\n const { className, horizontal, elevated } = options;\n\n return cnb(styles({ horizontal, elevated }), className);\n}\n\n/**\n * @internal\n */\nexport interface MenuWidgetProps\n extends HTMLAttributes<HTMLDivElement>,\n MenuListConvenienceProps {\n isSheet: boolean;\n horizontal: boolean;\n disableElevation?: boolean;\n cancelUnmountFocus: NonNullMutableRef<boolean>;\n getDefaultFocusedIndex?: GetDefaultFocusedIndex;\n}\n\n/**\n * **Client Component**\n *\n * This component was added to support the listbox role and the `useId()` hook.\n * If the `temporary` prop is set, the `MenuItem`'s ids will not be the same the\n * next time the menu opens, so the aria-activedescendant will point to a\n * non-existing id\n *\n * @internal\n */\nexport const MenuWidget = forwardRef<HTMLDivElement, MenuWidgetProps>(\n function MenuWidget(props, ref) {\n const {\n id,\n role = \"menu\",\n className,\n listStyle,\n listClassName,\n listProps,\n children,\n onClick,\n onBlur = noop,\n onFocus = noop,\n onKeyDown = noop,\n tabIndex = -1,\n isSheet,\n horizontal,\n disableElevation,\n cancelUnmountFocus,\n getDefaultFocusedIndex,\n ...remaining\n } = props;\n const isListbox = role === \"listbox\";\n const { menubar } = useMenuBarContext();\n\n // Since there is the possibility of other tab focusable elements within the\n // sheet and the menu items are programmatically focused, the menu's\n // tabIndex needs to be set to `-1` while one of the child menu items are\n // focused. This allows Shift+Tab correctly focuses the previous focusable\n // element within the sheet. Since `onFocus` and `onBlur` will be bubbled up\n // to the menu widget each time a new MenuItem is focused, only disable the\n // focused state if the blur event is fired without another focus event\n // within an animation frame.\n const [sheetMenuFocused, setSheetMenuFocused] = useState(false);\n const sheetBlurredFame = useRef(0);\n const menuBarContext = useMenuBarProvider({\n root: false,\n menubar,\n hoverTimeout: menubar ? 0 : undefined,\n defaultActiveId: id,\n });\n const { movementProps, movementContext } = useKeyboardMovementProvider({\n onClick,\n onFocus(event) {\n onFocus(event);\n\n if (!isSheet) {\n return;\n }\n\n window.cancelAnimationFrame(sheetBlurredFame.current);\n setSheetMenuFocused(true);\n },\n onKeyDown,\n horizontal,\n loopable: true,\n searchable: true,\n programmatic: true,\n includeDisabled: true,\n getDefaultFocusedIndex,\n });\n\n return (\n <MenuWidgetKeyboardProvider disabled={isListbox} value={movementContext}>\n <MenuBarProvider value={menuBarContext}>\n <div\n aria-orientation={horizontal ? \"horizontal\" : undefined}\n {...remaining}\n {...(isListbox ? { onClick, onFocus, onKeyDown } : movementProps)}\n id={id}\n ref={ref}\n role={role}\n className={menu({\n className,\n elevated: !disableElevation && !isSheet,\n horizontal,\n })}\n tabIndex={isSheet && !sheetMenuFocused ? 0 : tabIndex}\n onBlur={(event) => {\n onBlur(event);\n if (!isSheet) {\n return;\n }\n\n sheetBlurredFame.current = window.requestAnimationFrame(() => {\n setSheetMenuFocused(false);\n });\n }}\n >\n <List\n {...listProps}\n style={listStyle ?? listProps?.style}\n className={listClassName || listProps?.className}\n horizontal={horizontal}\n onClick={(event) => {\n listProps?.onClick?.(event);\n\n // this makes it so you can click on the menu/list without\n // closing the menu\n if (event.target === event.currentTarget) {\n event.stopPropagation();\n }\n\n // This might be a test only workaround since clicking links move focus\n // somewhere else\n if (event.target instanceof HTMLElement) {\n cancelUnmountFocus.current = event.currentTarget.contains(\n event.target.closest(\"a\")\n );\n }\n }}\n >\n {children}\n </List>\n </div>\n </MenuBarProvider>\n </MenuWidgetKeyboardProvider>\n );\n }\n);\n"],"names":["cnb","forwardRef","useRef","useState","List","useKeyboardMovementProvider","bem","MenuWidgetKeyboardProvider","MenuBarProvider","useMenuBarContext","useMenuBarProvider","styles","noop","menu","options","className","horizontal","elevated","MenuWidget","props","ref","id","role","listStyle","listClassName","listProps","children","onClick","onBlur","onFocus","onKeyDown","tabIndex","isSheet","disableElevation","cancelUnmountFocus","getDefaultFocusedIndex","remaining","isListbox","menubar","sheetMenuFocused","setSheetMenuFocused","sheetBlurredFame","menuBarContext","root","hoverTimeout","undefined","defaultActiveId","movementProps","movementContext","event","window","cancelAnimationFrame","current","loopable","searchable","programmatic","includeDisabled","disabled","value","div","aria-orientation","requestAnimationFrame","style","target","currentTarget","stopPropagation","HTMLElement","contains","closest"],"mappings":"AAAA;;AACA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,UAAU,EAAEC,MAAM,EA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ACvChC,mBAAmBkB,OAAO,GAAGH,MAAMe,aAAa,CAACG,QAAQ,CACvDlB,MAAMc,MAAM,CAACK,OAAO,CAAC;wBAEzB;oBACF;8BAEC1C;;;;;AAMb,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/menu/MenuWidgetKeyboardProvider.tsx"],"sourcesContent":["\"use client\";\nimport { type ReactElement, type ReactNode } from \"react\";\nimport { type KeyboardMovementContext } from \"../movement/types.js\";\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface MenuWidgetKeyboardProviderProps {\n value: Readonly<KeyboardMovementContext>;\n disabled: boolean;\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @since 6.0.0\n * @internal\n */\nexport function MenuWidgetKeyboardProvider(\n props: MenuWidgetKeyboardProviderProps\n): ReactElement {\n const { value, disabled, children } = props;\n if (disabled) {\n return <>{children}</>;\n }\n\n return (\n <KeyboardMovementProvider value={value}>\n {children}\n </KeyboardMovementProvider>\n );\n}\n"],"names":["KeyboardMovementProvider","MenuWidgetKeyboardProvider","props","value","disabled","children"],"
|
|
1
|
+
{"version":3,"sources":["../../src/menu/MenuWidgetKeyboardProvider.tsx"],"sourcesContent":["\"use client\";\nimport { type ReactElement, type ReactNode } from \"react\";\nimport { type KeyboardMovementContext } from \"../movement/types.js\";\nimport { KeyboardMovementProvider } from \"../movement/useKeyboardMovementProvider.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface MenuWidgetKeyboardProviderProps {\n value: Readonly<KeyboardMovementContext>;\n disabled: boolean;\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * @since 6.0.0\n * @internal\n */\nexport function MenuWidgetKeyboardProvider(\n props: MenuWidgetKeyboardProviderProps\n): ReactElement {\n const { value, disabled, children } = props;\n if (disabled) {\n return <>{children}</>;\n }\n\n return (\n <KeyboardMovementProvider value={value}>\n {children}\n </KeyboardMovementProvider>\n );\n}\n"],"names":["KeyboardMovementProvider","MenuWidgetKeyboardProvider","props","value","disabled","children"],"mappings":"AAAA;;AAGA,SAASA,wBAAwB,QAAQ,6CAA6C;AAYtF;;;;;CAKC,GACD,OAAO,SAASC,2BACdC,KAAsC;IAEtC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGH;IACtC,IAAIE,UAAU;QACZ,qBAAO;sBAAGC;;IACZ;IAEA,qBACE,KAACL;QAAyBG,OAAOA;kBAC9BE;;AAGP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/menu/useContextMenu.ts"],"sourcesContent":["\"use client\";\nimport type { MouseEvent, RefObject } from \"react\";\nimport { useCallback, useRef, useState } from \"react\";\nimport { BELOW_INNER_LEFT_ANCHOR } from \"../positioning/constants.js\";\nimport type { InitialCoords, PositionAnchor } from \"../positioning/types.js\";\nimport type { UseStateObject } from \"../types.js\";\n\n/** @since 6.0.0 */\nexport interface ContextMenuProps extends InitialCoords {\n \"aria-label\": string;\n anchor: PositionAnchor;\n fixedTo: RefObject<HTMLElement>;\n visible: boolean;\n preventScroll: boolean;\n onRequestClose(): void;\n}\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Dropped most options since they are no longer required for the\n * context menu to work. Apply any `Menu` props directly to the `Menu` component\n * instead.\n */\nexport interface ContextMenuHookOptions {\n /**\n * @defaultValue `BELOW_INNER_LEFT_ANCHOR`\n * @see {@link BELOW_INNER_LEFT_ANCHOR}\n */\n anchor?: PositionAnchor;\n\n /**\n * @defaultValue `\"Context Menu\"`\n */\n menuLabel?: string;\n\n /**\n * @defaultValue `true`\n */\n preventScroll?: boolean;\n onContextMenu?<E extends HTMLElement>(event: MouseEvent<E>): void;\n}\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Renamed from `ContextMenuHookReturnValue` to\n * `ContextMenuImplementation` and dropped the `menuRef` and `menuNodeRef`\n * fields.\n */\nexport interface ContextMenuImplementation\n extends UseStateObject<\"visible\", boolean> {\n menuProps: ContextMenuProps;\n onContextMenu<E extends HTMLElement>(event: MouseEvent<E>): void;\n}\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * This hook controls the visibility and positioning for a context menu.\n *\n * @example Simple Example\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import [ Menu, MenuItem, useContextMenu ] from \"@react-md/core\":\n *\n * function Example(): ReactElement {\n * const { menuProps, onContextMenu } = useContextMenu();\n *\n * return (\n * <>\n * <textarea onContextMenu={onContextMenu} />\n * <Menu {...menuProps}>\n * <MenuItem>Cut</MenuItem>\n * <MenuItem>Copy</MenuItem>\n * <MenuItem>Paste</MenuItem>\n * <MenuItem>Undo</MenuItem>\n * </Menu>\n * </>\n * );\n * }\n * ```\n *\n * @since 5.0.0\n * @since 6.0.0 No longer supports overriding most of the `Menu` props. The\n * props must be passed to the `Menu` component manually.\n */\nexport function useContextMenu(\n options: ContextMenuHookOptions = {}\n): ContextMenuImplementation {\n const {\n anchor = BELOW_INNER_LEFT_ANCHOR,\n menuLabel = \"Context Menu\",\n onContextMenu = noop,\n preventScroll = true,\n } = options;\n const [coords, setCoords] = useState<InitialCoords>({});\n const [visible, setVisible] = useState(false);\n const fixedTo = useRef<HTMLElement>(null);\n const onRequestClose = useCallback(() => {\n setVisible(false);\n }, []);\n\n return {\n visible,\n setVisible,\n menuProps: {\n \"aria-label\": menuLabel,\n anchor,\n ...coords,\n fixedTo,\n visible,\n onRequestClose,\n preventScroll,\n },\n onContextMenu(event) {\n onContextMenu(event);\n if (event.isPropagationStopped()) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n setCoords({\n initialX: event.clientX,\n initialY: event.clientY,\n });\n setVisible(true);\n },\n };\n}\n"],"names":["useCallback","useRef","useState","BELOW_INNER_LEFT_ANCHOR","noop","useContextMenu","options","anchor","menuLabel","onContextMenu","preventScroll","coords","setCoords","visible","setVisible","fixedTo","onRequestClose","menuProps","event","isPropagationStopped","preventDefault","stopPropagation","initialX","clientX","initialY","clientY"],"
|
|
1
|
+
{"version":3,"sources":["../../src/menu/useContextMenu.ts"],"sourcesContent":["\"use client\";\nimport type { MouseEvent, RefObject } from \"react\";\nimport { useCallback, useRef, useState } from \"react\";\nimport { BELOW_INNER_LEFT_ANCHOR } from \"../positioning/constants.js\";\nimport type { InitialCoords, PositionAnchor } from \"../positioning/types.js\";\nimport type { UseStateObject } from \"../types.js\";\n\n/** @since 6.0.0 */\nexport interface ContextMenuProps extends InitialCoords {\n \"aria-label\": string;\n anchor: PositionAnchor;\n fixedTo: RefObject<HTMLElement>;\n visible: boolean;\n preventScroll: boolean;\n onRequestClose(): void;\n}\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Dropped most options since they are no longer required for the\n * context menu to work. Apply any `Menu` props directly to the `Menu` component\n * instead.\n */\nexport interface ContextMenuHookOptions {\n /**\n * @defaultValue `BELOW_INNER_LEFT_ANCHOR`\n * @see {@link BELOW_INNER_LEFT_ANCHOR}\n */\n anchor?: PositionAnchor;\n\n /**\n * @defaultValue `\"Context Menu\"`\n */\n menuLabel?: string;\n\n /**\n * @defaultValue `true`\n */\n preventScroll?: boolean;\n onContextMenu?<E extends HTMLElement>(event: MouseEvent<E>): void;\n}\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Renamed from `ContextMenuHookReturnValue` to\n * `ContextMenuImplementation` and dropped the `menuRef` and `menuNodeRef`\n * fields.\n */\nexport interface ContextMenuImplementation\n extends UseStateObject<\"visible\", boolean> {\n menuProps: ContextMenuProps;\n onContextMenu<E extends HTMLElement>(event: MouseEvent<E>): void;\n}\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * This hook controls the visibility and positioning for a context menu.\n *\n * @example Simple Example\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import [ Menu, MenuItem, useContextMenu ] from \"@react-md/core\":\n *\n * function Example(): ReactElement {\n * const { menuProps, onContextMenu } = useContextMenu();\n *\n * return (\n * <>\n * <textarea onContextMenu={onContextMenu} />\n * <Menu {...menuProps}>\n * <MenuItem>Cut</MenuItem>\n * <MenuItem>Copy</MenuItem>\n * <MenuItem>Paste</MenuItem>\n * <MenuItem>Undo</MenuItem>\n * </Menu>\n * </>\n * );\n * }\n * ```\n *\n * @since 5.0.0\n * @since 6.0.0 No longer supports overriding most of the `Menu` props. The\n * props must be passed to the `Menu` component manually.\n */\nexport function useContextMenu(\n options: ContextMenuHookOptions = {}\n): ContextMenuImplementation {\n const {\n anchor = BELOW_INNER_LEFT_ANCHOR,\n menuLabel = \"Context Menu\",\n onContextMenu = noop,\n preventScroll = true,\n } = options;\n const [coords, setCoords] = useState<InitialCoords>({});\n const [visible, setVisible] = useState(false);\n const fixedTo = useRef<HTMLElement>(null);\n const onRequestClose = useCallback(() => {\n setVisible(false);\n }, []);\n\n return {\n visible,\n setVisible,\n menuProps: {\n \"aria-label\": menuLabel,\n anchor,\n ...coords,\n fixedTo,\n visible,\n onRequestClose,\n preventScroll,\n },\n onContextMenu(event) {\n onContextMenu(event);\n if (event.isPropagationStopped()) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n setCoords({\n initialX: event.clientX,\n initialY: event.clientY,\n });\n setVisible(true);\n },\n };\n}\n"],"names":["useCallback","useRef","useState","BELOW_INNER_LEFT_ANCHOR","noop","useContextMenu","options","anchor","menuLabel","onContextMenu","preventScroll","coords","setCoords","visible","setVisible","fixedTo","onRequestClose","menuProps","event","isPropagationStopped","preventDefault","stopPropagation","initialX","clientX","initialY","clientY"],"mappings":"AAAA;AAEA,SAASA,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AACtD,SAASC,uBAAuB,QAAQ,8BAA8B;AAmDtE,MAAMC,OAAO;AACX,aAAa;AACf;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GACD,OAAO,SAASC,eACdC,UAAkC,CAAC,CAAC;IAEpC,MAAM,EACJC,SAASJ,uBAAuB,EAChCK,YAAY,cAAc,EAC1BC,gBAAgBL,IAAI,EACpBM,gBAAgB,IAAI,EACrB,GAAGJ;IACJ,MAAM,CAACK,QAAQC,UAAU,GAAGV,SAAwB,CAAC;IACrD,MAAM,CAACW,SAASC,WAAW,GAAGZ,SAAS;IACvC,MAAMa,UAAUd,OAAoB;IACpC,MAAMe,iBAAiBhB,YAAY;QACjCc,WAAW;IACb,GAAG,EAAE;IAEL,OAAO;QACLD;QACAC;QACAG,WAAW;YACT,cAAcT;YACdD;YACA,GAAGI,MAAM;YACTI;YACAF;YACAG;YACAN;QACF;QACAD,eAAcS,KAAK;YACjBT,cAAcS;YACd,IAAIA,MAAMC,oBAAoB,IAAI;gBAChC;YACF;YAEAD,MAAME,cAAc;YACpBF,MAAMG,eAAe;YACrBT,UAAU;gBACRU,UAAUJ,MAAMK,OAAO;gBACvBC,UAAUN,MAAMO,OAAO;YACzB;YACAX,WAAW;QACb;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/menu/useMenuBarProvider.ts"],"sourcesContent":["\"use client\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport type { HoverModeContext } from \"../hoverMode/useHoverModeProvider.js\";\nimport {\n createHoverModeContext,\n useHoverModeProvider,\n} from \"../hoverMode/useHoverModeProvider.js\";\n\n/**\n * @internal\n * @since 5.0.0\n * @since 6.0.0 Updated to use the new `HoverModeContext` behavior.\n */\nexport interface MenuBarContext extends HoverModeContext {\n root: boolean;\n menubar: boolean;\n menuitem: boolean;\n}\n\nconst context = createContext<MenuBarContext>({\n ...createHoverModeContext(),\n root: false,\n menubar: false,\n menuitem: false,\n});\ncontext.displayName = \"MenuBar\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport const { Provider: MenuBarProvider } = context;\n\n/**\n * @internal\n * @since 5.0.0\n */\nexport function useMenuBarContext(): Readonly<MenuBarContext> {\n return useContext(context);\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface MenuBarProviderOptions {\n root: boolean;\n menubar: boolean;\n hoverTimeout: number | undefined;\n\n /** @defaultValue `\"\"` */\n defaultActiveId?: string;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function useMenuBarProvider(\n options: MenuBarProviderOptions\n): Readonly<MenuBarContext> {\n const { hoverTimeout, root, menubar, defaultActiveId = \"\" } = options;\n\n const hoverMode = useHoverModeProvider({\n hoverTimeout,\n forceRerender: true,\n defaultActiveId,\n });\n\n if (defaultActiveId) {\n // without this \"fix\", first-level nested dropdown menus will only disable\n // the animation the first time they are shown.\n hoverMode.animatedOnceRef.current = true;\n }\n\n return useMemo<MenuBarContext>(\n () => ({\n // when not within a menubar, disable all the hover mode functionality by\n // creating an empty hover mode context. This makes it so nested dropdown\n // menus don't trigger the hover mode timeouts and behavior\n ...(menubar ? hoverMode : createHoverModeContext()),\n root,\n menubar,\n menuitem: true,\n }),\n [hoverMode, menubar, root]\n );\n}\n"],"names":["createContext","useContext","useMemo","createHoverModeContext","useHoverModeProvider","context","root","menubar","menuitem","displayName","Provider","MenuBarProvider","useMenuBarContext","useMenuBarProvider","options","hoverTimeout","defaultActiveId","hoverMode","forceRerender","animatedOnceRef","current"],"
|
|
1
|
+
{"version":3,"sources":["../../src/menu/useMenuBarProvider.ts"],"sourcesContent":["\"use client\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport type { HoverModeContext } from \"../hoverMode/useHoverModeProvider.js\";\nimport {\n createHoverModeContext,\n useHoverModeProvider,\n} from \"../hoverMode/useHoverModeProvider.js\";\n\n/**\n * @internal\n * @since 5.0.0\n * @since 6.0.0 Updated to use the new `HoverModeContext` behavior.\n */\nexport interface MenuBarContext extends HoverModeContext {\n root: boolean;\n menubar: boolean;\n menuitem: boolean;\n}\n\nconst context = createContext<MenuBarContext>({\n ...createHoverModeContext(),\n root: false,\n menubar: false,\n menuitem: false,\n});\ncontext.displayName = \"MenuBar\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport const { Provider: MenuBarProvider } = context;\n\n/**\n * @internal\n * @since 5.0.0\n */\nexport function useMenuBarContext(): Readonly<MenuBarContext> {\n return useContext(context);\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface MenuBarProviderOptions {\n root: boolean;\n menubar: boolean;\n hoverTimeout: number | undefined;\n\n /** @defaultValue `\"\"` */\n defaultActiveId?: string;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport function useMenuBarProvider(\n options: MenuBarProviderOptions\n): Readonly<MenuBarContext> {\n const { hoverTimeout, root, menubar, defaultActiveId = \"\" } = options;\n\n const hoverMode = useHoverModeProvider({\n hoverTimeout,\n forceRerender: true,\n defaultActiveId,\n });\n\n if (defaultActiveId) {\n // without this \"fix\", first-level nested dropdown menus will only disable\n // the animation the first time they are shown.\n hoverMode.animatedOnceRef.current = true;\n }\n\n return useMemo<MenuBarContext>(\n () => ({\n // when not within a menubar, disable all the hover mode functionality by\n // creating an empty hover mode context. This makes it so nested dropdown\n // menus don't trigger the hover mode timeouts and behavior\n ...(menubar ? hoverMode : createHoverModeContext()),\n root,\n menubar,\n menuitem: true,\n }),\n [hoverMode, menubar, root]\n );\n}\n"],"names":["createContext","useContext","useMemo","createHoverModeContext","useHoverModeProvider","context","root","menubar","menuitem","displayName","Provider","MenuBarProvider","useMenuBarContext","useMenuBarProvider","options","hoverTimeout","defaultActiveId","hoverMode","forceRerender","animatedOnceRef","current"],"mappings":"AAAA;AACA,SAASA,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AAE3D,SACEC,sBAAsB,EACtBC,oBAAoB,QACf,uCAAuC;AAa9C,MAAMC,UAAUL,cAA8B;IAC5C,GAAGG,wBAAwB;IAC3BG,MAAM;IACNC,SAAS;IACTC,UAAU;AACZ;AACAH,QAAQI,WAAW,GAAG;AAEtB;;;CAGC,GACD,OAAO,MAAM,EAAEC,UAAUC,eAAe,EAAE,GAAGN,QAAQ;AAErD;;;CAGC,GACD,OAAO,SAASO;IACd,OAAOX,WAAWI;AACpB;AAeA;;;CAGC,GACD,OAAO,SAASQ,mBACdC,OAA+B;IAE/B,MAAM,EAAEC,YAAY,EAAET,IAAI,EAAEC,OAAO,EAAES,kBAAkB,EAAE,EAAE,GAAGF;IAE9D,MAAMG,YAAYb,qBAAqB;QACrCW;QACAG,eAAe;QACfF;IACF;IAEA,IAAIA,iBAAiB;QACnB,0EAA0E;QAC1E,+CAA+C;QAC/CC,UAAUE,eAAe,CAACC,OAAO,GAAG;IACtC;IAEA,OAAOlB,QACL,IAAO,CAAA;YACL,yEAAyE;YACzE,yEAAyE;YACzE,2DAA2D;YAC3D,GAAIK,UAAUU,YAAYd,wBAAwB;YAClDG;YACAC;YACAC,UAAU;QACZ,CAAA,GACA;QAACS;QAAWV;QAASD;KAAK;AAE9B"}
|
package/dist/menu/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/menu/utils.ts"],"sourcesContent":["import type { FloatingActionButtonPosition } from \"../button/FloatingActionButton.js\";\nimport {\n BELOW_CENTER_ANCHOR,\n BELOW_INNER_LEFT_ANCHOR,\n BOTTOM_INNER_LEFT_ANCHOR,\n BOTTOM_INNER_RIGHT_ANCHOR,\n CENTER_RIGHT_ANCHOR,\n TOP_INNER_LEFT_ANCHOR,\n TOP_INNER_RIGHT_ANCHOR,\n TOP_RIGHT_ANCHOR,\n} from \"../positioning/constants.js\";\nimport type { PositionAnchor } from \"../positioning/types.js\";\n\n/**\n * @since 5.0.0\n * @internal\n */\ninterface DefaultAnchorOptions {\n anchor?: PositionAnchor;\n menubar: boolean;\n menuitem: boolean;\n floating?: FloatingActionButtonPosition;\n horizontal: boolean;\n}\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport const getDefaultAnchor = (\n options: DefaultAnchorOptions\n): PositionAnchor => {\n const { anchor, menubar, menuitem, floating, horizontal } = options;\n if (anchor) {\n return anchor;\n }\n\n switch (floating) {\n case \"bottom-left\":\n return BOTTOM_INNER_LEFT_ANCHOR;\n case \"bottom-right\":\n return BOTTOM_INNER_RIGHT_ANCHOR;\n case \"top-left\":\n return TOP_INNER_LEFT_ANCHOR;\n case \"top-right\":\n return TOP_INNER_RIGHT_ANCHOR;\n }\n\n if (menubar) {\n return menuitem ? CENTER_RIGHT_ANCHOR : BELOW_INNER_LEFT_ANCHOR;\n }\n\n if (horizontal) {\n return BELOW_CENTER_ANCHOR;\n }\n\n if (menuitem) {\n return TOP_RIGHT_ANCHOR;\n }\n\n return TOP_INNER_RIGHT_ANCHOR;\n};\n"],"names":["BELOW_CENTER_ANCHOR","BELOW_INNER_LEFT_ANCHOR","BOTTOM_INNER_LEFT_ANCHOR","BOTTOM_INNER_RIGHT_ANCHOR","CENTER_RIGHT_ANCHOR","TOP_INNER_LEFT_ANCHOR","TOP_INNER_RIGHT_ANCHOR","TOP_RIGHT_ANCHOR","getDefaultAnchor","options","anchor","menubar","menuitem","floating","horizontal"],"
|
|
1
|
+
{"version":3,"sources":["../../src/menu/utils.ts"],"sourcesContent":["import type { FloatingActionButtonPosition } from \"../button/FloatingActionButton.js\";\nimport {\n BELOW_CENTER_ANCHOR,\n BELOW_INNER_LEFT_ANCHOR,\n BOTTOM_INNER_LEFT_ANCHOR,\n BOTTOM_INNER_RIGHT_ANCHOR,\n CENTER_RIGHT_ANCHOR,\n TOP_INNER_LEFT_ANCHOR,\n TOP_INNER_RIGHT_ANCHOR,\n TOP_RIGHT_ANCHOR,\n} from \"../positioning/constants.js\";\nimport type { PositionAnchor } from \"../positioning/types.js\";\n\n/**\n * @since 5.0.0\n * @internal\n */\ninterface DefaultAnchorOptions {\n anchor?: PositionAnchor;\n menubar: boolean;\n menuitem: boolean;\n floating?: FloatingActionButtonPosition;\n horizontal: boolean;\n}\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport const getDefaultAnchor = (\n options: DefaultAnchorOptions\n): PositionAnchor => {\n const { anchor, menubar, menuitem, floating, horizontal } = options;\n if (anchor) {\n return anchor;\n }\n\n switch (floating) {\n case \"bottom-left\":\n return BOTTOM_INNER_LEFT_ANCHOR;\n case \"bottom-right\":\n return BOTTOM_INNER_RIGHT_ANCHOR;\n case \"top-left\":\n return TOP_INNER_LEFT_ANCHOR;\n case \"top-right\":\n return TOP_INNER_RIGHT_ANCHOR;\n }\n\n if (menubar) {\n return menuitem ? CENTER_RIGHT_ANCHOR : BELOW_INNER_LEFT_ANCHOR;\n }\n\n if (horizontal) {\n return BELOW_CENTER_ANCHOR;\n }\n\n if (menuitem) {\n return TOP_RIGHT_ANCHOR;\n }\n\n return TOP_INNER_RIGHT_ANCHOR;\n};\n"],"names":["BELOW_CENTER_ANCHOR","BELOW_INNER_LEFT_ANCHOR","BOTTOM_INNER_LEFT_ANCHOR","BOTTOM_INNER_RIGHT_ANCHOR","CENTER_RIGHT_ANCHOR","TOP_INNER_LEFT_ANCHOR","TOP_INNER_RIGHT_ANCHOR","TOP_RIGHT_ANCHOR","getDefaultAnchor","options","anchor","menubar","menuitem","floating","horizontal"],"mappings":"AACA,SACEA,mBAAmB,EACnBC,uBAAuB,EACvBC,wBAAwB,EACxBC,yBAAyB,EACzBC,mBAAmB,EACnBC,qBAAqB,EACrBC,sBAAsB,EACtBC,gBAAgB,QACX,8BAA8B;AAerC;;;CAGC,GACD,OAAO,MAAMC,mBAAmB,CAC9BC;IAEA,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,EAAE,GAAGL;IAC5D,IAAIC,QAAQ;QACV,OAAOA;IACT;IAEA,OAAQG;QACN,KAAK;YACH,OAAOX;QACT,KAAK;YACH,OAAOC;QACT,KAAK;YACH,OAAOE;QACT,KAAK;YACH,OAAOC;IACX;IAEA,IAAIK,SAAS;QACX,OAAOC,WAAWR,sBAAsBH;IAC1C;IAEA,IAAIa,YAAY;QACd,OAAOd;IACT;IAEA,IAAIY,UAAU;QACZ,OAAOL;IACT;IAEA,OAAOD;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/movement/constants.ts"],"sourcesContent":["import type { KeyboardMovementConfig } from \"./types.js\";\n\n/**\n * Most custom keyboard functionality use these keys.\n *\n * @since 5.0.0\n * @internal\n */\nexport const DEFAULT_KEYBOARD_MOVEMENT: Readonly<KeyboardMovementConfig> = {\n incrementKeys: [\"ArrowDown\"],\n decrementKeys: [\"ArrowUp\"],\n jumpToFirstKeys: [\"Home\"],\n jumpToLastKeys: [\"End\"],\n};\n\n/**\n * @since 5.1.2\n * @internal\n */\nexport const DEFAULT_LTR_KEYBOARD_MOVEMENT: Readonly<KeyboardMovementConfig> = {\n incrementKeys: [\"ArrowRight\"],\n decrementKeys: [\"ArrowLeft\"],\n jumpToFirstKeys: [\"Home\"],\n jumpToLastKeys: [\"End\"],\n};\n\n/**\n * @since 5.1.2\n * @internal\n */\nexport const DEFAULT_RTL_KEYBOARD_MOVEMENT: Readonly<KeyboardMovementConfig> = {\n incrementKeys: [\"ArrowLeft\"],\n decrementKeys: [\"ArrowRight\"],\n jumpToFirstKeys: [\"Home\"],\n jumpToLastKeys: [\"End\"],\n};\n"],"names":["DEFAULT_KEYBOARD_MOVEMENT","incrementKeys","decrementKeys","jumpToFirstKeys","jumpToLastKeys","DEFAULT_LTR_KEYBOARD_MOVEMENT","DEFAULT_RTL_KEYBOARD_MOVEMENT"],"
|
|
1
|
+
{"version":3,"sources":["../../src/movement/constants.ts"],"sourcesContent":["import type { KeyboardMovementConfig } from \"./types.js\";\n\n/**\n * Most custom keyboard functionality use these keys.\n *\n * @since 5.0.0\n * @internal\n */\nexport const DEFAULT_KEYBOARD_MOVEMENT: Readonly<KeyboardMovementConfig> = {\n incrementKeys: [\"ArrowDown\"],\n decrementKeys: [\"ArrowUp\"],\n jumpToFirstKeys: [\"Home\"],\n jumpToLastKeys: [\"End\"],\n};\n\n/**\n * @since 5.1.2\n * @internal\n */\nexport const DEFAULT_LTR_KEYBOARD_MOVEMENT: Readonly<KeyboardMovementConfig> = {\n incrementKeys: [\"ArrowRight\"],\n decrementKeys: [\"ArrowLeft\"],\n jumpToFirstKeys: [\"Home\"],\n jumpToLastKeys: [\"End\"],\n};\n\n/**\n * @since 5.1.2\n * @internal\n */\nexport const DEFAULT_RTL_KEYBOARD_MOVEMENT: Readonly<KeyboardMovementConfig> = {\n incrementKeys: [\"ArrowLeft\"],\n decrementKeys: [\"ArrowRight\"],\n jumpToFirstKeys: [\"Home\"],\n jumpToLastKeys: [\"End\"],\n};\n"],"names":["DEFAULT_KEYBOARD_MOVEMENT","incrementKeys","decrementKeys","jumpToFirstKeys","jumpToLastKeys","DEFAULT_LTR_KEYBOARD_MOVEMENT","DEFAULT_RTL_KEYBOARD_MOVEMENT"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,MAAMA,4BAA8D;IACzEC,eAAe;QAAC;KAAY;IAC5BC,eAAe;QAAC;KAAU;IAC1BC,iBAAiB;QAAC;KAAO;IACzBC,gBAAgB;QAAC;KAAM;AACzB,EAAE;AAEF;;;CAGC,GACD,OAAO,MAAMC,gCAAkE;IAC7EJ,eAAe;QAAC;KAAa;IAC7BC,eAAe;QAAC;KAAY;IAC5BC,iBAAiB;QAAC;KAAO;IACzBC,gBAAgB;QAAC;KAAM;AACzB,EAAE;AAEF;;;CAGC,GACD,OAAO,MAAME,gCAAkE;IAC7EL,eAAe;QAAC;KAAY;IAC5BC,eAAe;QAAC;KAAa;IAC7BC,iBAAiB;QAAC;KAAO;IACzBC,gBAAgB;QAAC;KAAM;AACzB,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/movement/findMatchIndex.ts"],"sourcesContent":["/** @internal */\nexport interface BaseOptions {\n /**\n * The current query string to find within the values\n */\n value: string;\n\n /**\n * The list of values to search within\n */\n values: readonly string[];\n\n /**\n * The start index for the search\n */\n startIndex: number;\n}\n\n/** @internal */\nexport interface MatchInRangeOptions extends BaseOptions {\n /**\n * The end index for the search\n */\n endIndex: number;\n}\n\n/**\n * Attempts to find the first match index for a list of values that starts with\n * the provided query string and is within the start and end indexes. If no\n * matches are found, -1 will be returned instead.\n *\n * Since this is normally coming from a keydown event, the query *must* be a\n * string of all capital letters to work as each value will be converted to\n * uppercase before checking.\n * @internal\n */\nexport function findMatchInRange(options: MatchInRangeOptions): number {\n const { values, startIndex, endIndex } = options;\n if (!values.length) {\n return -1;\n }\n\n const value = options.value.toUpperCase();\n\n for (let i = startIndex; i < endIndex; i += 1) {\n const content = values[i];\n if (content.toUpperCase().indexOf(value) === 0) {\n return i;\n }\n }\n\n return -1;\n}\n\n/** @internal */\nexport interface MatchIndexOptions extends BaseOptions {\n /**\n * Boolean if the current index can be included in the search\n *\n * @defaultValue `true`\n */\n isSelfMatchable?: boolean;\n}\n\n/**\n * A function that is used to find the next match index within a list of values\n * by comparing the start values ignoring case.\n *\n * If a match can not be found from the search string, `-1` will be returned.\n * The search value is self-matchable by default, but it can be omitted by\n * disabling the `isSelfMatchable` argument. This will make a self-match return\n * `-1`.\n *\n * @internal\n */\nexport function findMatchIndex(options: MatchIndexOptions): number {\n const { value, values, startIndex, isSelfMatchable = true } = options;\n // this was added to support comboboxes when there are no options available\n if (!values.length) {\n return -1;\n }\n\n let index = findMatchInRange({\n value,\n values,\n startIndex: startIndex + 1,\n endIndex: values.length,\n });\n if (index === -1) {\n const endIndex = startIndex + (isSelfMatchable ? 1 : 0);\n index = findMatchInRange({\n value,\n values,\n startIndex: 0,\n endIndex,\n });\n }\n\n return index;\n}\n"],"names":["findMatchInRange","options","values","startIndex","endIndex","length","value","toUpperCase","i","content","indexOf","findMatchIndex","isSelfMatchable","index"],"
|
|
1
|
+
{"version":3,"sources":["../../src/movement/findMatchIndex.ts"],"sourcesContent":["/** @internal */\nexport interface BaseOptions {\n /**\n * The current query string to find within the values\n */\n value: string;\n\n /**\n * The list of values to search within\n */\n values: readonly string[];\n\n /**\n * The start index for the search\n */\n startIndex: number;\n}\n\n/** @internal */\nexport interface MatchInRangeOptions extends BaseOptions {\n /**\n * The end index for the search\n */\n endIndex: number;\n}\n\n/**\n * Attempts to find the first match index for a list of values that starts with\n * the provided query string and is within the start and end indexes. If no\n * matches are found, -1 will be returned instead.\n *\n * Since this is normally coming from a keydown event, the query *must* be a\n * string of all capital letters to work as each value will be converted to\n * uppercase before checking.\n * @internal\n */\nexport function findMatchInRange(options: MatchInRangeOptions): number {\n const { values, startIndex, endIndex } = options;\n if (!values.length) {\n return -1;\n }\n\n const value = options.value.toUpperCase();\n\n for (let i = startIndex; i < endIndex; i += 1) {\n const content = values[i];\n if (content.toUpperCase().indexOf(value) === 0) {\n return i;\n }\n }\n\n return -1;\n}\n\n/** @internal */\nexport interface MatchIndexOptions extends BaseOptions {\n /**\n * Boolean if the current index can be included in the search\n *\n * @defaultValue `true`\n */\n isSelfMatchable?: boolean;\n}\n\n/**\n * A function that is used to find the next match index within a list of values\n * by comparing the start values ignoring case.\n *\n * If a match can not be found from the search string, `-1` will be returned.\n * The search value is self-matchable by default, but it can be omitted by\n * disabling the `isSelfMatchable` argument. This will make a self-match return\n * `-1`.\n *\n * @internal\n */\nexport function findMatchIndex(options: MatchIndexOptions): number {\n const { value, values, startIndex, isSelfMatchable = true } = options;\n // this was added to support comboboxes when there are no options available\n if (!values.length) {\n return -1;\n }\n\n let index = findMatchInRange({\n value,\n values,\n startIndex: startIndex + 1,\n endIndex: values.length,\n });\n if (index === -1) {\n const endIndex = startIndex + (isSelfMatchable ? 1 : 0);\n index = findMatchInRange({\n value,\n values,\n startIndex: 0,\n endIndex,\n });\n }\n\n return index;\n}\n"],"names":["findMatchInRange","options","values","startIndex","endIndex","length","value","toUpperCase","i","content","indexOf","findMatchIndex","isSelfMatchable","index"],"mappings":"AAAA,cAAc,GA0Bd;;;;;;;;;CASC,GACD,OAAO,SAASA,iBAAiBC,OAA4B;IAC3D,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGH;IACzC,IAAI,CAACC,OAAOG,MAAM,EAAE;QAClB,OAAO,CAAC;IACV;IAEA,MAAMC,QAAQL,QAAQK,KAAK,CAACC,WAAW;IAEvC,IAAK,IAAIC,IAAIL,YAAYK,IAAIJ,UAAUI,KAAK,EAAG;QAC7C,MAAMC,UAAUP,MAAM,CAACM,EAAE;QACzB,IAAIC,QAAQF,WAAW,GAAGG,OAAO,CAACJ,WAAW,GAAG;YAC9C,OAAOE;QACT;IACF;IAEA,OAAO,CAAC;AACV;AAYA;;;;;;;;;;CAUC,GACD,OAAO,SAASG,eAAeV,OAA0B;IACvD,MAAM,EAAEK,KAAK,EAAEJ,MAAM,EAAEC,UAAU,EAAES,kBAAkB,IAAI,EAAE,GAAGX;IAC9D,2EAA2E;IAC3E,IAAI,CAACC,OAAOG,MAAM,EAAE;QAClB,OAAO,CAAC;IACV;IAEA,IAAIQ,QAAQb,iBAAiB;QAC3BM;QACAJ;QACAC,YAAYA,aAAa;QACzBC,UAAUF,OAAOG,MAAM;IACzB;IACA,IAAIQ,UAAU,CAAC,GAAG;QAChB,MAAMT,WAAWD,aAAcS,CAAAA,kBAAkB,IAAI,CAAA;QACrDC,QAAQb,iBAAiB;YACvBM;YACAJ;YACAC,YAAY;YACZC;QACF;IACF;IAEA,OAAOS;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/movement/types.ts"],"sourcesContent":["import type {\n FocusEvent,\n FocusEventHandler,\n KeyboardEvent,\n KeyboardEventHandler,\n MouseEvent,\n MouseEventHandler,\n} from \"react\";\nimport type {\n NonNullMutableRef,\n NonNullRef,\n UseStateSetter,\n} from \"../types.js\";\n\n/**\n * Set this to `\"roving\"` when:\n * - there are a group of focusable elements that have a `tabIndex={-1}`\n * - the container element defaults to having a `tabIndex={0}`\n * - if the container is focused, it should no longer be included in the normal\n * tab flow. Instead, the current focused element should be included instead\n * by changing its `tabIndex` from `-1` to `0`\n *\n * Set this to `\"virtual\"` when:\n * - the container element should never lose focus\n * - the \"focused\" element only gains focus styles instead of being focused\n * - the container element specifies an `aria-activedescendant` pointing to one\n * of the ids for the child \"focusable\" elements\n *\n * @since 6.0.0\n */\nexport type TabIndexBehavior = \"roving\" | \"virtual\";\n\n/**\n * This should be used for specific widgets that should not include all\n * focusable elements and instead only specific elements.\n *\n * @example\n * ```ts\n * const getExpansionPanelsOnly: GetFocusableElements = (container) =>\n * [...container.querySelectorAll(\".rmd-expansion-panel__button\")];\n *\n * const getTreeItemsOnly: GetFocusableElements = (container) =>\n * [...container.querySelectorAll(\"[role='treeitem']\")];\n * ```\n *\n * @defaultValue `getFocusableElements`\n * @see the default `getFocusableElements` function.\n */\nexport type GetFocusableElements = (\n container: HTMLElement,\n programmatic: boolean\n) => readonly HTMLElement[];\n\n/**\n * @since 5.0.0\n */\nexport interface KeyboardMovementConfiguration {\n /**\n * A list of keys that will attempt to increment the focus index by 1.\n *\n * @defaultValue `[\"ArrowDown\"]`\n */\n incrementKeys?: readonly string[];\n\n /**\n * A list of keys that will attempt to decrement the focus index by 1.\n *\n * @defaultValue `[\"ArrowUp\"]`\n */\n decrementKeys?: readonly string[];\n\n /**\n * A list of keys that will set the focus index to `0`.\n *\n * @defaultValue `[\"Home\"]`\n */\n jumpToFirstKeys?: readonly string[];\n\n /**\n * A list of keys that will set the focus index to the last focusable index.\n *\n * @defaultValue `[\"End\"]`\n */\n jumpToLastKeys?: readonly string[];\n}\n\n/**\n * The defined {@link KeyboardMovementConfiguration} that should be used for\n * custom keyboard focus behavior.\n *\n * @since 5.0.0\n */\nexport type KeyboardMovementConfig = Required<KeyboardMovementConfiguration>;\n\n/**\n * @since 5.0.0\n */\nexport interface KeyboardMovementBehavior {\n /**\n * Boolean if pressing a letter will focus the next item in the\n * {@link KeyboardMovementProvider} that starts with the same letter.\n *\n * @defaultValue `false`\n */\n searchable?: boolean;\n\n /**\n * Boolean if the {@link KeyboardMovementProvider} should allow the focus behavior\n * to loop from the first to last or last to first item instead of preventing\n * any new focus behavior. In other words... if the last item is focused and\n * the user presses a key that should advance the focus to the next focusable\n * element, should the focus stay on the current element or loop back and\n * focus the first focusable item.\n *\n * @defaultValue `false`\n */\n loopable?: boolean;\n\n /**\n * Boolean if elements that are `aria-disabled` or `disabled` should still be\n * able to gain focus.\n *\n * @defaultValue `false`\n */\n includeDisabled?: boolean;\n\n /**\n * Boolean if the keyboard movement is horizontal instead of vertical. This\n * updates the default keyboard config to use `ArrowRight` and `ArrowLeft`\n * instead of `ArrowDown` and `ArrowUp`,\n *\n * @since 5.1.2\n * @defaultValue `false`\n */\n horizontal?: boolean;\n}\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Removed `attach`, `detach` and `watching`\n * @internal\n */\nexport interface KeyboardMovementContext\n extends Required<KeyboardMovementBehavior> {\n /** {@inheritDoc KeyboardMovementConfig} */\n config: NonNullRef<KeyboardMovementConfig>;\n\n /** @see {@link TabIndexBehavior} */\n tabIndexBehavior: TabIndexBehavior | undefined;\n\n /**\n * Note: This will only update if the {@link KeyboardMovementProviderOptions.tabIndexBehavior}\n * has been set to `\"roving\"` or `\"virtual\"`.\n */\n activeDescendantId: string;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface FocusableIndexOptions {\n focusables: readonly HTMLElement[];\n includeDisabled: boolean;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type GetDefaultFocusedIndex = (options: FocusableIndexOptions) => number;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type ExtendKeyDown<E extends HTMLElement> = (\n movementData: KeyboardMovementExtensionData<E>\n) => void;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface KeyboardMovementFocusChangeEvent {\n index: number;\n element: HTMLElement;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type KeyboardMovementFocusChangeEventHandler = (\n event: KeyboardMovementFocusChangeEvent\n) => void;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface KeyboardMovementExtensionData<E extends HTMLElement>\n extends KeyboardMovementContext {\n event: KeyboardEvent<E>;\n currentFocusIndex: NonNullMutableRef<number>;\n setFocusIndex(index: number, focusables: readonly HTMLElement[]): void;\n setActiveDescendantId(id: string): void;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface KeyboardMovementProviderOptions<E extends HTMLElement>\n extends KeyboardMovementBehavior,\n KeyboardMovementConfiguration {\n /** @see {@link TabIndexBehavior} */\n tabIndexBehavior?: TabIndexBehavior;\n\n onClick?(event: MouseEvent<E>): void;\n onFocus?(event: FocusEvent<E>): void;\n onKeyDown?(event: KeyboardEvent<E>): void;\n\n /** @defaultValue `false` */\n disabled?: boolean;\n\n /**\n * This is used to implement custom keyboard movement for the `keydown` event.\n */\n extendKeyDown?: ExtendKeyDown<E>;\n\n /**\n * Triggered whenever the focus changes.\n */\n onFocusChange?: KeyboardMovementFocusChangeEventHandler;\n\n /**\n * From what I've understood so far, programmatically focusable elements\n * should only be included when disabled elements via `aria-disabled` are\n * allowed.\n *\n * @defaultValue `includeDisabled`\n */\n programmatic?: boolean;\n\n /** @see {@link GetFocusableElements} */\n getFocusableElements?: GetFocusableElements;\n\n /**\n * This can be used to set the initial focus index whenever the container\n * element is first focused or the focus index is `-1` on other focus events.\n */\n getDefaultFocusedIndex?: GetDefaultFocusedIndex;\n\n /**\n * This was added to support editable combobox behavior. As the user types or\n * uses native input keyboard behavior, the focus index should be reset to\n * `-1` so that the next \"ArrowDown\" event focuses the first option again\n * instead of the last selected one.\n *\n * @defaultValue `false`\n */\n isNegativeOneAllowed?: boolean;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface KeyboardMovementProps<E extends HTMLElement> {\n /**\n * This will only be provided if the {@link KeyboardMovementContext.tabIndexBehavior}\n * is set to `\"virtual\"`.\n */\n \"aria-activedescendant\"?: string;\n\n /**\n * This will not be provided if the {@link KeyboardMovementContext.tabIndexBehavior}\n * is `undefined`. Otherwise:\n * - `0` when `\"virtual\"`\n * - `0` when `\"roving\"` and the container element has not been focused at\n * least once\n * - `-1` when `\"roving\"` and the container has been focused at least once\n * - a child element **should** have a `tabIndex={0}` instead\n */\n tabIndex?: number;\n onClick: MouseEventHandler<E>;\n onFocus: FocusEventHandler<E>;\n onKeyDown: KeyboardEventHandler<E>;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface KeyboardMovementProviderImplementation<E extends HTMLElement> {\n movementProps: Readonly<KeyboardMovementProps<E>>;\n movementContext: Readonly<KeyboardMovementContext>;\n currentFocusIndex: NonNullMutableRef<number>;\n activeDescendantId: string;\n setActiveDescendantId: UseStateSetter<string>;\n}\n"],"names":[],"
|
|
1
|
+
{"version":3,"sources":["../../src/movement/types.ts"],"sourcesContent":["import type {\n FocusEvent,\n FocusEventHandler,\n KeyboardEvent,\n KeyboardEventHandler,\n MouseEvent,\n MouseEventHandler,\n} from \"react\";\nimport type {\n NonNullMutableRef,\n NonNullRef,\n UseStateSetter,\n} from \"../types.js\";\n\n/**\n * Set this to `\"roving\"` when:\n * - there are a group of focusable elements that have a `tabIndex={-1}`\n * - the container element defaults to having a `tabIndex={0}`\n * - if the container is focused, it should no longer be included in the normal\n * tab flow. Instead, the current focused element should be included instead\n * by changing its `tabIndex` from `-1` to `0`\n *\n * Set this to `\"virtual\"` when:\n * - the container element should never lose focus\n * - the \"focused\" element only gains focus styles instead of being focused\n * - the container element specifies an `aria-activedescendant` pointing to one\n * of the ids for the child \"focusable\" elements\n *\n * @since 6.0.0\n */\nexport type TabIndexBehavior = \"roving\" | \"virtual\";\n\n/**\n * This should be used for specific widgets that should not include all\n * focusable elements and instead only specific elements.\n *\n * @example\n * ```ts\n * const getExpansionPanelsOnly: GetFocusableElements = (container) =>\n * [...container.querySelectorAll(\".rmd-expansion-panel__button\")];\n *\n * const getTreeItemsOnly: GetFocusableElements = (container) =>\n * [...container.querySelectorAll(\"[role='treeitem']\")];\n * ```\n *\n * @defaultValue `getFocusableElements`\n * @see the default `getFocusableElements` function.\n */\nexport type GetFocusableElements = (\n container: HTMLElement,\n programmatic: boolean\n) => readonly HTMLElement[];\n\n/**\n * @since 5.0.0\n */\nexport interface KeyboardMovementConfiguration {\n /**\n * A list of keys that will attempt to increment the focus index by 1.\n *\n * @defaultValue `[\"ArrowDown\"]`\n */\n incrementKeys?: readonly string[];\n\n /**\n * A list of keys that will attempt to decrement the focus index by 1.\n *\n * @defaultValue `[\"ArrowUp\"]`\n */\n decrementKeys?: readonly string[];\n\n /**\n * A list of keys that will set the focus index to `0`.\n *\n * @defaultValue `[\"Home\"]`\n */\n jumpToFirstKeys?: readonly string[];\n\n /**\n * A list of keys that will set the focus index to the last focusable index.\n *\n * @defaultValue `[\"End\"]`\n */\n jumpToLastKeys?: readonly string[];\n}\n\n/**\n * The defined {@link KeyboardMovementConfiguration} that should be used for\n * custom keyboard focus behavior.\n *\n * @since 5.0.0\n */\nexport type KeyboardMovementConfig = Required<KeyboardMovementConfiguration>;\n\n/**\n * @since 5.0.0\n */\nexport interface KeyboardMovementBehavior {\n /**\n * Boolean if pressing a letter will focus the next item in the\n * {@link KeyboardMovementProvider} that starts with the same letter.\n *\n * @defaultValue `false`\n */\n searchable?: boolean;\n\n /**\n * Boolean if the {@link KeyboardMovementProvider} should allow the focus behavior\n * to loop from the first to last or last to first item instead of preventing\n * any new focus behavior. In other words... if the last item is focused and\n * the user presses a key that should advance the focus to the next focusable\n * element, should the focus stay on the current element or loop back and\n * focus the first focusable item.\n *\n * @defaultValue `false`\n */\n loopable?: boolean;\n\n /**\n * Boolean if elements that are `aria-disabled` or `disabled` should still be\n * able to gain focus.\n *\n * @defaultValue `false`\n */\n includeDisabled?: boolean;\n\n /**\n * Boolean if the keyboard movement is horizontal instead of vertical. This\n * updates the default keyboard config to use `ArrowRight` and `ArrowLeft`\n * instead of `ArrowDown` and `ArrowUp`,\n *\n * @since 5.1.2\n * @defaultValue `false`\n */\n horizontal?: boolean;\n}\n\n/**\n * @since 5.0.0\n * @since 6.0.0 Removed `attach`, `detach` and `watching`\n * @internal\n */\nexport interface KeyboardMovementContext\n extends Required<KeyboardMovementBehavior> {\n /** {@inheritDoc KeyboardMovementConfig} */\n config: NonNullRef<KeyboardMovementConfig>;\n\n /** @see {@link TabIndexBehavior} */\n tabIndexBehavior: TabIndexBehavior | undefined;\n\n /**\n * Note: This will only update if the {@link KeyboardMovementProviderOptions.tabIndexBehavior}\n * has been set to `\"roving\"` or `\"virtual\"`.\n */\n activeDescendantId: string;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface FocusableIndexOptions {\n focusables: readonly HTMLElement[];\n includeDisabled: boolean;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type GetDefaultFocusedIndex = (options: FocusableIndexOptions) => number;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type ExtendKeyDown<E extends HTMLElement> = (\n movementData: KeyboardMovementExtensionData<E>\n) => void;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface KeyboardMovementFocusChangeEvent {\n index: number;\n element: HTMLElement;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type KeyboardMovementFocusChangeEventHandler = (\n event: KeyboardMovementFocusChangeEvent\n) => void;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface KeyboardMovementExtensionData<E extends HTMLElement>\n extends KeyboardMovementContext {\n event: KeyboardEvent<E>;\n currentFocusIndex: NonNullMutableRef<number>;\n setFocusIndex(index: number, focusables: readonly HTMLElement[]): void;\n setActiveDescendantId(id: string): void;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface KeyboardMovementProviderOptions<E extends HTMLElement>\n extends KeyboardMovementBehavior,\n KeyboardMovementConfiguration {\n /** @see {@link TabIndexBehavior} */\n tabIndexBehavior?: TabIndexBehavior;\n\n onClick?(event: MouseEvent<E>): void;\n onFocus?(event: FocusEvent<E>): void;\n onKeyDown?(event: KeyboardEvent<E>): void;\n\n /** @defaultValue `false` */\n disabled?: boolean;\n\n /**\n * This is used to implement custom keyboard movement for the `keydown` event.\n */\n extendKeyDown?: ExtendKeyDown<E>;\n\n /**\n * Triggered whenever the focus changes.\n */\n onFocusChange?: KeyboardMovementFocusChangeEventHandler;\n\n /**\n * From what I've understood so far, programmatically focusable elements\n * should only be included when disabled elements via `aria-disabled` are\n * allowed.\n *\n * @defaultValue `includeDisabled`\n */\n programmatic?: boolean;\n\n /** @see {@link GetFocusableElements} */\n getFocusableElements?: GetFocusableElements;\n\n /**\n * This can be used to set the initial focus index whenever the container\n * element is first focused or the focus index is `-1` on other focus events.\n */\n getDefaultFocusedIndex?: GetDefaultFocusedIndex;\n\n /**\n * This was added to support editable combobox behavior. As the user types or\n * uses native input keyboard behavior, the focus index should be reset to\n * `-1` so that the next \"ArrowDown\" event focuses the first option again\n * instead of the last selected one.\n *\n * @defaultValue `false`\n */\n isNegativeOneAllowed?: boolean;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface KeyboardMovementProps<E extends HTMLElement> {\n /**\n * This will only be provided if the {@link KeyboardMovementContext.tabIndexBehavior}\n * is set to `\"virtual\"`.\n */\n \"aria-activedescendant\"?: string;\n\n /**\n * This will not be provided if the {@link KeyboardMovementContext.tabIndexBehavior}\n * is `undefined`. Otherwise:\n * - `0` when `\"virtual\"`\n * - `0` when `\"roving\"` and the container element has not been focused at\n * least once\n * - `-1` when `\"roving\"` and the container has been focused at least once\n * - a child element **should** have a `tabIndex={0}` instead\n */\n tabIndex?: number;\n onClick: MouseEventHandler<E>;\n onFocus: FocusEventHandler<E>;\n onKeyDown: KeyboardEventHandler<E>;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface KeyboardMovementProviderImplementation<E extends HTMLElement> {\n movementProps: Readonly<KeyboardMovementProps<E>>;\n movementContext: Readonly<KeyboardMovementContext>;\n currentFocusIndex: NonNullMutableRef<number>;\n activeDescendantId: string;\n setActiveDescendantId: UseStateSetter<string>;\n}\n"],"names":[],"mappings":"AAmSA;;;CAGC,GACD,WAMC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/movement/useKeyboardMovementProvider.ts"],"sourcesContent":["\"use client\";\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { getFocusableElements as defaultGetFocusableElements } from \"../focus/utils.js\";\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { useDir } from \"../typography/WritingDirectionProvider.js\";\nimport { useIsomorphicLayoutEffect } from \"../useIsomorphicLayoutEffect.js\";\nimport {\n DEFAULT_KEYBOARD_MOVEMENT,\n DEFAULT_LTR_KEYBOARD_MOVEMENT,\n DEFAULT_RTL_KEYBOARD_MOVEMENT,\n} from \"./constants.js\";\nimport { findMatchIndex } from \"./findMatchIndex.js\";\nimport type {\n KeyboardMovementConfig,\n KeyboardMovementConfiguration,\n KeyboardMovementContext,\n KeyboardMovementProviderImplementation,\n KeyboardMovementProviderOptions,\n} from \"./types.js\";\nimport {\n getFirstFocusableIndex,\n getLastFocusableIndex,\n getNextFocusableIndex,\n getSearchText,\n getVirtualFocusDefaultIndex,\n isElementDisabled,\n isNotFocusable,\n isSearchableEvent,\n recalculateFocusIndex,\n} from \"./utils.js\";\n\n/**\n * @since 5.0.0\n * @internal\n */\nconst context = createContext<KeyboardMovementContext>({\n config: { current: DEFAULT_KEYBOARD_MOVEMENT },\n loopable: false,\n searchable: false,\n horizontal: false,\n includeDisabled: false,\n tabIndexBehavior: undefined,\n activeDescendantId: \"\",\n});\ncontext.displayName = \"KeyboardMovement\";\nexport const { Provider: KeyboardMovementProvider } = context;\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport function useKeyboardMovementContext(): Readonly<KeyboardMovementContext> {\n return useContext(context);\n}\n\nconst noop = (): void => {\n // do nothing\n};\n\nconst returnNegative1 = (): number => -1;\n\n/**\n * Implements the custom keyboard movement behavior throughout react-md. Using\n * the \"Find References\" will be the best way to see example usage.\n *\n * @example Default Keyboard Movement for any Focusable Element\n * ```tsx\n * import {\n * KeyboardMovementProvider,\n * useKeyboardMovementProvider,\n * } from \"@react-md/core\";\n * import type { ReactElement, ReactNode } from \"react\";\n *\n * function Example({ children }: { children: ReactNode }): ReactElement {\n * const { movementContext, movementProps } = useKeyboardMovementProvider();\n *\n * // any focusable element child can be focused with the arrow , home, and\n * // end keys\n * return (\n * <KeyboardMovementProvider value={movementContext}>\n * <div {...movementProps}>\n * {children}\n * </div>\n * </KeyboardMovementProvider>\n * );\n * }\n * ```\n *\n * @example Active Descendant Movement\n * ```tsx\n * import {\n * KeyboardMovementProvider,\n * useKeyboardMovementContext,\n * useKeyboardMovementProvider,\n * } from \"@react-md/core\";\n * import type { ReactElement, ReactNode } from \"react\";\n * import { useId } from \"react\";\n *\n * function Child(): ReactElement {\n * const id = useId()\n * const { activeDescendantId } = useKeyboardMovementContext();\n *\n * return (\n * <div\n * {...props}\n * id={id}\n * className={cnb(id === activeDescendantId && \"focused-class-name\")}\n * >\n * Some Content\n * </div>\n * );\n * }\n *\n * function Example({ children }: { children: ReactNode }): ReactElement {\n * const { movementContext, movementProps } = useKeyboardMovementProvider({\n * loopable: true,\n * searchable: true,\n * tabIndexBehavior: \"virtual\",\n * });\n *\n * // any focusable element child can be focused with the arrow , home, and\n * // end keys\n * return (\n * <KeyboardMovementProvider value={movementContext}>\n * <div {...movementProps}>\n * <Child />\n * <Child />\n * <Child />\n * </div>\n * </KeyboardMovementProvider>\n * );\n * }\n * ```\n *\n * @example Roving Tab Index\n * ```tsx\n * import {\n * KeyboardMovementProvider,\n * useKeyboardMovementContext,\n * useKeyboardMovementProvider,\n * } from \"@react-md/core\";\n * import type { ReactElement, ReactNode } from \"react\";\n * import { useId } from \"react\";\n *\n * function Child(): ReactElement {\n * const id = useId()\n * const { activeDescendantId } = useKeyboardMovementContext();\n *\n * return (\n * <div\n * {...props}\n * id={id}\n * tabIndex={id === activeDescendantId ? 0 : -1}\n * >\n * Some Content\n * </div>\n * );\n * }\n *\n * function Example({ children }: { children: ReactNode }): ReactElement {\n * const { movementContext, movementProps } = useKeyboardMovementProvider({\n * loopable: true,\n * searchable: true,\n * tabIndexBehavior: \"roving\",\n * });\n *\n * // any focusable element child can be focused with the arrow , home, and\n * // end keys\n * return (\n * <KeyboardMovementProvider value={movementContext}>\n * <div {...movementProps}>\n * <Child />\n * <Child />\n * <Child />\n * </div>\n * </KeyboardMovementProvider>\n * );\n * }\n * ```\n * @since 6.0.0\n * @internal\n */\nexport function useKeyboardMovementProvider<E extends HTMLElement>(\n options: KeyboardMovementProviderOptions<E> = {}\n): KeyboardMovementProviderImplementation<E> {\n const {\n onClick = noop,\n onFocus = noop,\n onKeyDown = noop,\n loopable = false,\n disabled,\n searchable = false,\n horizontal = false,\n includeDisabled = false,\n tabIndexBehavior,\n extendKeyDown = noop,\n onFocusChange = noop,\n programmatic = includeDisabled,\n incrementKeys: propIncrementKeys,\n decrementKeys: propDecrementKeys,\n jumpToFirstKeys: propJumpToFirstKeys,\n jumpToLastKeys: propJumpToLastKeys,\n getFocusableElements = defaultGetFocusableElements,\n getDefaultFocusedIndex = returnNegative1,\n isNegativeOneAllowed = false,\n } = options;\n\n const isRTL = useDir().dir === \"rtl\";\n let defaults: Readonly<Required<KeyboardMovementConfiguration>>;\n if (horizontal) {\n defaults = isRTL\n ? DEFAULT_RTL_KEYBOARD_MOVEMENT\n : DEFAULT_LTR_KEYBOARD_MOVEMENT;\n } else {\n defaults = DEFAULT_KEYBOARD_MOVEMENT;\n }\n\n const incrementKeys = propIncrementKeys || defaults.incrementKeys;\n const decrementKeys = propDecrementKeys || defaults.decrementKeys;\n const jumpToFirstKeys = propJumpToFirstKeys || defaults.jumpToFirstKeys;\n const jumpToLastKeys = propJumpToLastKeys || defaults.jumpToLastKeys;\n\n const configuration: KeyboardMovementConfig = {\n incrementKeys,\n decrementKeys,\n jumpToFirstKeys,\n jumpToLastKeys,\n };\n const config = useRef(configuration);\n useIsomorphicLayoutEffect(() => {\n config.current = configuration;\n });\n\n const [activeDescendantId, setActiveDescendantId] = useState(\"\");\n const movementContext = useMemo<KeyboardMovementContext>(\n () => ({\n config,\n loopable,\n searchable,\n horizontal,\n includeDisabled,\n tabIndexBehavior,\n activeDescendantId,\n }),\n [\n activeDescendantId,\n horizontal,\n includeDisabled,\n loopable,\n searchable,\n tabIndexBehavior,\n ]\n );\n const currentFocusIndex = useRef(-1);\n const mode = useUserInteractionMode();\n const refocus = useRef(false);\n\n if (process.env.NODE_ENV !== \"production\") {\n // this fixes issues during hot reloading and using the `useId()` hook\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n return () => {\n setActiveDescendantId(\"\");\n };\n }, []);\n }\n\n let tabIndex: number | undefined;\n if (tabIndexBehavior) {\n tabIndex =\n disabled || (tabIndexBehavior === \"roving\" && activeDescendantId)\n ? -1\n : 0;\n }\n\n return {\n movementProps: {\n \"aria-activedescendant\":\n tabIndexBehavior === \"virtual\" ? activeDescendantId : undefined,\n tabIndex,\n\n // Note: This used to be on the `onFocus` event, but this causes issues in\n // Chromium browsers for drag and drop behavior\n onClick(event) {\n onClick(event);\n if (disabled) {\n return;\n }\n\n // This makes it so you can click an element with a mouse and then\n // keyboard navigate from that element instead of the last keyboard focus\n // element\n const { currentTarget, target } = event;\n if (target === currentTarget || !(target instanceof HTMLElement)) {\n return;\n }\n\n const focusables = getFocusableElements(currentTarget, programmatic);\n const focusedIndex = focusables.findIndex(\n (element) => element === target || element.contains(target)\n );\n if (focusedIndex === -1 || !focusables.length) {\n return;\n }\n\n currentFocusIndex.current = focusedIndex;\n const focused = focusables[focusedIndex];\n if (tabIndexBehavior) {\n setActiveDescendantId(focused.id);\n }\n\n // need to force focus back to the container element when using\n // aria activedescendant\n if (tabIndexBehavior === \"virtual\") {\n refocus.current = true;\n currentTarget.focus();\n }\n\n onFocusChange({\n index: focusedIndex,\n element: focused,\n });\n },\n onFocus(event) {\n onFocus(event);\n if (event.isPropagationStopped() || refocus.current) {\n refocus.current = false;\n return;\n }\n\n if (\n (mode !== \"keyboard\" && tabIndexBehavior !== \"virtual\") ||\n event.target !== event.currentTarget\n ) {\n return;\n }\n\n const focusables = getFocusableElements(\n event.currentTarget,\n programmatic\n );\n if (!focusables.length) {\n return;\n }\n\n let defaultFocusIndex = getDefaultFocusedIndex({\n focusables,\n includeDisabled,\n });\n\n // This allows my custom `getDefaultFocusedIndex` implementations to\n // have a nice fallback without having to re-implement the \"focus\n // first\" behavior\n if (!isNegativeOneAllowed && defaultFocusIndex === -1) {\n if (tabIndexBehavior === \"virtual\") {\n // virtual keyboard navigation **must** always focus at least one element\n defaultFocusIndex = getVirtualFocusDefaultIndex({\n focusables,\n includeDisabled,\n activeDescendantId,\n });\n } else {\n defaultFocusIndex = getFirstFocusableIndex({\n focusables,\n includeDisabled,\n });\n }\n }\n\n if (defaultFocusIndex === -1) {\n return;\n }\n\n currentFocusIndex.current = defaultFocusIndex;\n const focused = focusables[defaultFocusIndex];\n if (tabIndexBehavior) {\n setActiveDescendantId(focused.id);\n }\n\n if (tabIndexBehavior !== \"virtual\") {\n focused.focus();\n } else {\n focused.scrollIntoView({ block: \"nearest\" });\n }\n\n onFocusChange({\n index: defaultFocusIndex,\n element: focused,\n });\n },\n onKeyDown(event) {\n onKeyDown(event);\n if (disabled) {\n return;\n }\n\n const { currentTarget } = event;\n\n const setFocusIndex = (\n index: number,\n focusables: readonly HTMLElement[]\n ): void => {\n event.preventDefault();\n event.stopPropagation();\n if (currentFocusIndex.current === index || index === -1) {\n return;\n }\n\n currentFocusIndex.current = index;\n const focused = focusables[index];\n if (tabIndexBehavior) {\n focused.scrollIntoView({\n block: \"nearest\",\n inline: \"nearest\",\n });\n setActiveDescendantId(focused.id);\n }\n\n if (tabIndexBehavior !== \"virtual\") {\n focused.focus();\n }\n\n onFocusChange({\n index,\n element: focused,\n });\n };\n\n extendKeyDown({\n event,\n setFocusIndex,\n currentFocusIndex,\n setActiveDescendantId,\n ...movementContext,\n });\n\n if (event.isPropagationStopped()) {\n return;\n }\n\n // TODO: Figure this part out. This is currently required for the tree\n // movement when the asterisk key is pressed. There might be other cases\n // as well.\n if (!isNegativeOneAllowed && currentFocusIndex.current === -1) {\n currentFocusIndex.current = recalculateFocusIndex({\n focusables: getFocusableElements(currentTarget, programmatic),\n includeDisabled,\n tabIndexBehavior,\n activeDescendantId,\n });\n }\n\n const { key, shiftKey } = event;\n if (\n tabIndexBehavior === \"virtual\" &&\n activeDescendantId &&\n (key === \" \" || key === \"Enter\")\n ) {\n if (key === \" \") {\n event.preventDefault();\n }\n\n const focusables = getFocusableElements(currentTarget, programmatic);\n const activeElement = focusables[currentFocusIndex.current];\n if (!activeElement || isElementDisabled(activeElement)) {\n return;\n }\n\n activeElement.click();\n return;\n }\n\n const {\n incrementKeys,\n decrementKeys,\n jumpToFirstKeys,\n jumpToLastKeys,\n } = config.current;\n\n if (searchable && isSearchableEvent(event)) {\n const focusables = getFocusableElements(currentTarget, programmatic);\n const index = findMatchIndex({\n value: key,\n values: focusables.map((element) =>\n getSearchText(element, !isNotFocusable(element, includeDisabled))\n ),\n startIndex: shiftKey ? -1 : currentFocusIndex.current,\n });\n setFocusIndex(index, focusables);\n return;\n }\n\n const jumpToFirst = jumpToFirstKeys.includes(key);\n const jumpToLast = !jumpToFirst && jumpToLastKeys.includes(key);\n const increment =\n !jumpToFirst && !jumpToLast && incrementKeys.includes(key);\n const decrement =\n !jumpToFirst &&\n !jumpToLast &&\n !increment &&\n decrementKeys.includes(key);\n\n if (!jumpToFirst && !jumpToLast && !increment && !decrement) {\n return;\n }\n const focusables = getFocusableElements(currentTarget, programmatic);\n\n let index: number;\n if (jumpToFirst) {\n index = getFirstFocusableIndex({\n focusables,\n includeDisabled,\n });\n } else if (jumpToLast) {\n index = getLastFocusableIndex({\n focusables,\n includeDisabled,\n });\n } else {\n index = getNextFocusableIndex({\n loopable,\n increment,\n focusables,\n includeDisabled,\n currentFocusIndex: currentFocusIndex.current,\n });\n }\n\n setFocusIndex(index, focusables);\n },\n },\n movementContext,\n currentFocusIndex,\n activeDescendantId,\n setActiveDescendantId,\n };\n}\n"],"names":["createContext","useContext","useEffect","useMemo","useRef","useState","getFocusableElements","defaultGetFocusableElements","useUserInteractionMode","useDir","useIsomorphicLayoutEffect","DEFAULT_KEYBOARD_MOVEMENT","DEFAULT_LTR_KEYBOARD_MOVEMENT","DEFAULT_RTL_KEYBOARD_MOVEMENT","findMatchIndex","getFirstFocusableIndex","getLastFocusableIndex","getNextFocusableIndex","getSearchText","getVirtualFocusDefaultIndex","isElementDisabled","isNotFocusable","isSearchableEvent","recalculateFocusIndex","context","config","current","loopable","searchable","horizontal","includeDisabled","tabIndexBehavior","undefined","activeDescendantId","displayName","Provider","KeyboardMovementProvider","useKeyboardMovementContext","noop","returnNegative1","useKeyboardMovementProvider","options","onClick","onFocus","onKeyDown","disabled","extendKeyDown","onFocusChange","programmatic","incrementKeys","propIncrementKeys","decrementKeys","propDecrementKeys","jumpToFirstKeys","propJumpToFirstKeys","jumpToLastKeys","propJumpToLastKeys","getDefaultFocusedIndex","isNegativeOneAllowed","isRTL","dir","defaults","configuration","setActiveDescendantId","movementContext","currentFocusIndex","mode","refocus","process","env","NODE_ENV","tabIndex","movementProps","event","currentTarget","target","HTMLElement","focusables","focusedIndex","findIndex","element","contains","length","focused","id","focus","index","isPropagationStopped","defaultFocusIndex","scrollIntoView","block","setFocusIndex","preventDefault","stopPropagation","inline","key","shiftKey","activeElement","click","value","values","map","startIndex","jumpToFirst","includes","jumpToLast","increment","decrement"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,SAAS,CAAC3D,eAAe2D,SAASlD;wBAElDwE,YAAYN,WAAW,CAAC,IAAI/B,kBAAkBvC,OAAO;oBACvD;oBACAiE,cAAcL,OAAOT;oBACrB;gBACF;gBAEA,MAAM0B,cAAclD,gBAAgBmD,QAAQ,CAACT;gBAC7C,MAAMU,aAAa,CAACF,eAAehD,eAAeiD,QAAQ,CAACT;gBAC3D,MAAMW,YACJ,CAACH,eAAe,CAACE,cAAcxD,cAAcuD,QAAQ,CAACT;gBACxD,MAAMY,YACJ,CAACJ,eACD,CAACE,cACD,CAACC,aACDvD,cAAcqD,QAAQ,CAACT;gBAEzB,IAAI,CAACQ,eAAe,CAACE,cAAc,CAACC,aAAa,CAACC,WAAW;oBAC3D;gBACF;gBACA,MAAM9B,aAAavE,qBAAqBoE,eAAe1B;gBAEvD,IAAIsC;gBACJ,IAAIiB,aAAa;oBACfjB,QAAQvE,uBAAuB;wBAC7B8D;wBACA/C;oBACF;gBACF,OAAO,IAAI2E,YAAY;oBACrBnB,QAAQtE,sBAAsB;wBAC5B6D;wBACA/C;oBACF;gBACF,OAAO;oBACLwD,QAAQrE,sBAAsB;wBAC5BU;wBACA+E;wBACA7B;wBACA/C;wBACAmC,mBAAmBA,kBAAkBvC,OAAO;oBAC9C;gBACF;gBAEAiE,cAAcL,OAAOT;YACvB;QACF;QACAb;QACAC;QACAhC;QACA8B;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/movement/useKeyboardMovementProvider.ts"],"sourcesContent":["\"use client\";\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { getFocusableElements as defaultGetFocusableElements } from \"../focus/utils.js\";\nimport { useUserInteractionMode } from \"../interaction/UserInteractionModeProvider.js\";\nimport { useDir } from \"../typography/WritingDirectionProvider.js\";\nimport { useIsomorphicLayoutEffect } from \"../useIsomorphicLayoutEffect.js\";\nimport {\n DEFAULT_KEYBOARD_MOVEMENT,\n DEFAULT_LTR_KEYBOARD_MOVEMENT,\n DEFAULT_RTL_KEYBOARD_MOVEMENT,\n} from \"./constants.js\";\nimport { findMatchIndex } from \"./findMatchIndex.js\";\nimport type {\n KeyboardMovementConfig,\n KeyboardMovementConfiguration,\n KeyboardMovementContext,\n KeyboardMovementProviderImplementation,\n KeyboardMovementProviderOptions,\n} from \"./types.js\";\nimport {\n getFirstFocusableIndex,\n getLastFocusableIndex,\n getNextFocusableIndex,\n getSearchText,\n getVirtualFocusDefaultIndex,\n isElementDisabled,\n isNotFocusable,\n isSearchableEvent,\n recalculateFocusIndex,\n} from \"./utils.js\";\n\n/**\n * @since 5.0.0\n * @internal\n */\nconst context = createContext<KeyboardMovementContext>({\n config: { current: DEFAULT_KEYBOARD_MOVEMENT },\n loopable: false,\n searchable: false,\n horizontal: false,\n includeDisabled: false,\n tabIndexBehavior: undefined,\n activeDescendantId: \"\",\n});\ncontext.displayName = \"KeyboardMovement\";\nexport const { Provider: KeyboardMovementProvider } = context;\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport function useKeyboardMovementContext(): Readonly<KeyboardMovementContext> {\n return useContext(context);\n}\n\nconst noop = (): void => {\n // do nothing\n};\n\nconst returnNegative1 = (): number => -1;\n\n/**\n * Implements the custom keyboard movement behavior throughout react-md. Using\n * the \"Find References\" will be the best way to see example usage.\n *\n * @example Default Keyboard Movement for any Focusable Element\n * ```tsx\n * import {\n * KeyboardMovementProvider,\n * useKeyboardMovementProvider,\n * } from \"@react-md/core\";\n * import type { ReactElement, ReactNode } from \"react\";\n *\n * function Example({ children }: { children: ReactNode }): ReactElement {\n * const { movementContext, movementProps } = useKeyboardMovementProvider();\n *\n * // any focusable element child can be focused with the arrow , home, and\n * // end keys\n * return (\n * <KeyboardMovementProvider value={movementContext}>\n * <div {...movementProps}>\n * {children}\n * </div>\n * </KeyboardMovementProvider>\n * );\n * }\n * ```\n *\n * @example Active Descendant Movement\n * ```tsx\n * import {\n * KeyboardMovementProvider,\n * useKeyboardMovementContext,\n * useKeyboardMovementProvider,\n * } from \"@react-md/core\";\n * import type { ReactElement, ReactNode } from \"react\";\n * import { useId } from \"react\";\n *\n * function Child(): ReactElement {\n * const id = useId()\n * const { activeDescendantId } = useKeyboardMovementContext();\n *\n * return (\n * <div\n * {...props}\n * id={id}\n * className={cnb(id === activeDescendantId && \"focused-class-name\")}\n * >\n * Some Content\n * </div>\n * );\n * }\n *\n * function Example({ children }: { children: ReactNode }): ReactElement {\n * const { movementContext, movementProps } = useKeyboardMovementProvider({\n * loopable: true,\n * searchable: true,\n * tabIndexBehavior: \"virtual\",\n * });\n *\n * // any focusable element child can be focused with the arrow , home, and\n * // end keys\n * return (\n * <KeyboardMovementProvider value={movementContext}>\n * <div {...movementProps}>\n * <Child />\n * <Child />\n * <Child />\n * </div>\n * </KeyboardMovementProvider>\n * );\n * }\n * ```\n *\n * @example Roving Tab Index\n * ```tsx\n * import {\n * KeyboardMovementProvider,\n * useKeyboardMovementContext,\n * useKeyboardMovementProvider,\n * } from \"@react-md/core\";\n * import type { ReactElement, ReactNode } from \"react\";\n * import { useId } from \"react\";\n *\n * function Child(): ReactElement {\n * const id = useId()\n * const { activeDescendantId } = useKeyboardMovementContext();\n *\n * return (\n * <div\n * {...props}\n * id={id}\n * tabIndex={id === activeDescendantId ? 0 : -1}\n * >\n * Some Content\n * </div>\n * );\n * }\n *\n * function Example({ children }: { children: ReactNode }): ReactElement {\n * const { movementContext, movementProps } = useKeyboardMovementProvider({\n * loopable: true,\n * searchable: true,\n * tabIndexBehavior: \"roving\",\n * });\n *\n * // any focusable element child can be focused with the arrow , home, and\n * // end keys\n * return (\n * <KeyboardMovementProvider value={movementContext}>\n * <div {...movementProps}>\n * <Child />\n * <Child />\n * <Child />\n * </div>\n * </KeyboardMovementProvider>\n * );\n * }\n * ```\n * @since 6.0.0\n * @internal\n */\nexport function useKeyboardMovementProvider<E extends HTMLElement>(\n options: KeyboardMovementProviderOptions<E> = {}\n): KeyboardMovementProviderImplementation<E> {\n const {\n onClick = noop,\n onFocus = noop,\n onKeyDown = noop,\n loopable = false,\n disabled,\n searchable = false,\n horizontal = false,\n includeDisabled = false,\n tabIndexBehavior,\n extendKeyDown = noop,\n onFocusChange = noop,\n programmatic = includeDisabled,\n incrementKeys: propIncrementKeys,\n decrementKeys: propDecrementKeys,\n jumpToFirstKeys: propJumpToFirstKeys,\n jumpToLastKeys: propJumpToLastKeys,\n getFocusableElements = defaultGetFocusableElements,\n getDefaultFocusedIndex = returnNegative1,\n isNegativeOneAllowed = false,\n } = options;\n\n const isRTL = useDir().dir === \"rtl\";\n let defaults: Readonly<Required<KeyboardMovementConfiguration>>;\n if (horizontal) {\n defaults = isRTL\n ? DEFAULT_RTL_KEYBOARD_MOVEMENT\n : DEFAULT_LTR_KEYBOARD_MOVEMENT;\n } else {\n defaults = DEFAULT_KEYBOARD_MOVEMENT;\n }\n\n const incrementKeys = propIncrementKeys || defaults.incrementKeys;\n const decrementKeys = propDecrementKeys || defaults.decrementKeys;\n const jumpToFirstKeys = propJumpToFirstKeys || defaults.jumpToFirstKeys;\n const jumpToLastKeys = propJumpToLastKeys || defaults.jumpToLastKeys;\n\n const configuration: KeyboardMovementConfig = {\n incrementKeys,\n decrementKeys,\n jumpToFirstKeys,\n jumpToLastKeys,\n };\n const config = useRef(configuration);\n useIsomorphicLayoutEffect(() => {\n config.current = configuration;\n });\n\n const [activeDescendantId, setActiveDescendantId] = useState(\"\");\n const movementContext = useMemo<KeyboardMovementContext>(\n () => ({\n config,\n loopable,\n searchable,\n horizontal,\n includeDisabled,\n tabIndexBehavior,\n activeDescendantId,\n }),\n [\n activeDescendantId,\n horizontal,\n includeDisabled,\n loopable,\n searchable,\n tabIndexBehavior,\n ]\n );\n const currentFocusIndex = useRef(-1);\n const mode = useUserInteractionMode();\n const refocus = useRef(false);\n\n if (process.env.NODE_ENV !== \"production\") {\n // this fixes issues during hot reloading and using the `useId()` hook\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n return () => {\n setActiveDescendantId(\"\");\n };\n }, []);\n }\n\n let tabIndex: number | undefined;\n if (tabIndexBehavior) {\n tabIndex =\n disabled || (tabIndexBehavior === \"roving\" && activeDescendantId)\n ? -1\n : 0;\n }\n\n return {\n movementProps: {\n \"aria-activedescendant\":\n tabIndexBehavior === \"virtual\" ? activeDescendantId : undefined,\n tabIndex,\n\n // Note: This used to be on the `onFocus` event, but this causes issues in\n // Chromium browsers for drag and drop behavior\n onClick(event) {\n onClick(event);\n if (disabled) {\n return;\n }\n\n // This makes it so you can click an element with a mouse and then\n // keyboard navigate from that element instead of the last keyboard focus\n // element\n const { currentTarget, target } = event;\n if (target === currentTarget || !(target instanceof HTMLElement)) {\n return;\n }\n\n const focusables = getFocusableElements(currentTarget, programmatic);\n const focusedIndex = focusables.findIndex(\n (element) => element === target || element.contains(target)\n );\n if (focusedIndex === -1 || !focusables.length) {\n return;\n }\n\n currentFocusIndex.current = focusedIndex;\n const focused = focusables[focusedIndex];\n if (tabIndexBehavior) {\n setActiveDescendantId(focused.id);\n }\n\n // need to force focus back to the container element when using\n // aria activedescendant\n if (tabIndexBehavior === \"virtual\") {\n refocus.current = true;\n currentTarget.focus();\n }\n\n onFocusChange({\n index: focusedIndex,\n element: focused,\n });\n },\n onFocus(event) {\n onFocus(event);\n if (event.isPropagationStopped() || refocus.current) {\n refocus.current = false;\n return;\n }\n\n if (\n (mode !== \"keyboard\" && tabIndexBehavior !== \"virtual\") ||\n event.target !== event.currentTarget\n ) {\n return;\n }\n\n const focusables = getFocusableElements(\n event.currentTarget,\n programmatic\n );\n if (!focusables.length) {\n return;\n }\n\n let defaultFocusIndex = getDefaultFocusedIndex({\n focusables,\n includeDisabled,\n });\n\n // This allows my custom `getDefaultFocusedIndex` implementations to\n // have a nice fallback without having to re-implement the \"focus\n // first\" behavior\n if (!isNegativeOneAllowed && defaultFocusIndex === -1) {\n if (tabIndexBehavior === \"virtual\") {\n // virtual keyboard navigation **must** always focus at least one element\n defaultFocusIndex = getVirtualFocusDefaultIndex({\n focusables,\n includeDisabled,\n activeDescendantId,\n });\n } else {\n defaultFocusIndex = getFirstFocusableIndex({\n focusables,\n includeDisabled,\n });\n }\n }\n\n if (defaultFocusIndex === -1) {\n return;\n }\n\n currentFocusIndex.current = defaultFocusIndex;\n const focused = focusables[defaultFocusIndex];\n if (tabIndexBehavior) {\n setActiveDescendantId(focused.id);\n }\n\n if (tabIndexBehavior !== \"virtual\") {\n focused.focus();\n } else {\n focused.scrollIntoView({ block: \"nearest\" });\n }\n\n onFocusChange({\n index: defaultFocusIndex,\n element: focused,\n });\n },\n onKeyDown(event) {\n onKeyDown(event);\n if (disabled) {\n return;\n }\n\n const { currentTarget } = event;\n\n const setFocusIndex = (\n index: number,\n focusables: readonly HTMLElement[]\n ): void => {\n event.preventDefault();\n event.stopPropagation();\n if (currentFocusIndex.current === index || index === -1) {\n return;\n }\n\n currentFocusIndex.current = index;\n const focused = focusables[index];\n if (tabIndexBehavior) {\n focused.scrollIntoView({\n block: \"nearest\",\n inline: \"nearest\",\n });\n setActiveDescendantId(focused.id);\n }\n\n if (tabIndexBehavior !== \"virtual\") {\n focused.focus();\n }\n\n onFocusChange({\n index,\n element: focused,\n });\n };\n\n extendKeyDown({\n event,\n setFocusIndex,\n currentFocusIndex,\n setActiveDescendantId,\n ...movementContext,\n });\n\n if (event.isPropagationStopped()) {\n return;\n }\n\n // TODO: Figure this part out. This is currently required for the tree\n // movement when the asterisk key is pressed. There might be other cases\n // as well.\n if (!isNegativeOneAllowed && currentFocusIndex.current === -1) {\n currentFocusIndex.current = recalculateFocusIndex({\n focusables: getFocusableElements(currentTarget, programmatic),\n includeDisabled,\n tabIndexBehavior,\n activeDescendantId,\n });\n }\n\n const { key, shiftKey } = event;\n if (\n tabIndexBehavior === \"virtual\" &&\n activeDescendantId &&\n (key === \" \" || key === \"Enter\")\n ) {\n if (key === \" \") {\n event.preventDefault();\n }\n\n const focusables = getFocusableElements(currentTarget, programmatic);\n const activeElement = focusables[currentFocusIndex.current];\n if (!activeElement || isElementDisabled(activeElement)) {\n return;\n }\n\n activeElement.click();\n return;\n }\n\n const {\n incrementKeys,\n decrementKeys,\n jumpToFirstKeys,\n jumpToLastKeys,\n } = config.current;\n\n if (searchable && isSearchableEvent(event)) {\n const focusables = getFocusableElements(currentTarget, programmatic);\n const index = findMatchIndex({\n value: key,\n values: focusables.map((element) =>\n getSearchText(element, !isNotFocusable(element, includeDisabled))\n ),\n startIndex: shiftKey ? -1 : currentFocusIndex.current,\n });\n setFocusIndex(index, focusables);\n return;\n }\n\n const jumpToFirst = jumpToFirstKeys.includes(key);\n const jumpToLast = !jumpToFirst && jumpToLastKeys.includes(key);\n const increment =\n !jumpToFirst && !jumpToLast && incrementKeys.includes(key);\n const decrement =\n !jumpToFirst &&\n !jumpToLast &&\n !increment &&\n decrementKeys.includes(key);\n\n if (!jumpToFirst && !jumpToLast && !increment && !decrement) {\n return;\n }\n const focusables = getFocusableElements(currentTarget, programmatic);\n\n let index: number;\n if (jumpToFirst) {\n index = getFirstFocusableIndex({\n focusables,\n includeDisabled,\n });\n } else if (jumpToLast) {\n index = getLastFocusableIndex({\n focusables,\n includeDisabled,\n });\n } else {\n index = getNextFocusableIndex({\n loopable,\n increment,\n focusables,\n includeDisabled,\n currentFocusIndex: currentFocusIndex.current,\n });\n }\n\n setFocusIndex(index, focusables);\n },\n },\n movementContext,\n currentFocusIndex,\n activeDescendantId,\n setActiveDescendantId,\n };\n}\n"],"names":["createContext","useContext","useEffect","useMemo","useRef","useState","getFocusableElements","defaultGetFocusableElements","useUserInteractionMode","useDir","useIsomorphicLayoutEffect","DEFAULT_KEYBOARD_MOVEMENT","DEFAULT_LTR_KEYBOARD_MOVEMENT","DEFAULT_RTL_KEYBOARD_MOVEMENT","findMatchIndex","getFirstFocusableIndex","getLastFocusableIndex","getNextFocusableIndex","getSearchText","getVirtualFocusDefaultIndex","isElementDisabled","isNotFocusable","isSearchableEvent","recalculateFocusIndex","context","config","current","loopable","searchable","horizontal","includeDisabled","tabIndexBehavior","undefined","activeDescendantId","displayName","Provider","KeyboardMovementProvider","useKeyboardMovementContext","noop","returnNegative1","useKeyboardMovementProvider","options","onClick","onFocus","onKeyDown","disabled","extendKeyDown","onFocusChange","programmatic","incrementKeys","propIncrementKeys","decrementKeys","propDecrementKeys","jumpToFirstKeys","propJumpToFirstKeys","jumpToLastKeys","propJumpToLastKeys","getDefaultFocusedIndex","isNegativeOneAllowed","isRTL","dir","defaults","configuration","setActiveDescendantId","movementContext","currentFocusIndex","mode","refocus","process","env","NODE_ENV","tabIndex","movementProps","event","currentTarget","target","HTMLElement","focusables","focusedIndex","findIndex","element","contains","length","focused","id","focus","index","isPropagationStopped","defaultFocusIndex","scrollIntoView","block","setFocusIndex","preventDefault","stopPropagation","inline","key","shiftKey","activeElement","click","value","values","map","startIndex","jumpToFirst","includes","jumpToLast","increment","decrement"],"mappings":"AAAA;AACA,SACEA,aAAa,EACbC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,QAAQ;AACf,SAASC,wBAAwBC,2BAA2B,QAAQ,oBAAoB;AACxF,SAASC,sBAAsB,QAAQ,gDAAgD;AACvF,SAASC,MAAM,QAAQ,4CAA4C;AACnE,SAASC,yBAAyB,QAAQ,kCAAkC;AAC5E,SACEC,yBAAyB,EACzBC,6BAA6B,EAC7BC,6BAA6B,QACxB,iBAAiB;AACxB,SAASC,cAAc,QAAQ,sBAAsB;AAQrD,SACEC,sBAAsB,EACtBC,qBAAqB,EACrBC,qBAAqB,EACrBC,aAAa,EACbC,2BAA2B,EAC3BC,iBAAiB,EACjBC,cAAc,EACdC,iBAAiB,EACjBC,qBAAqB,QAChB,aAAa;AAEpB;;;CAGC,GACD,MAAMC,UAAUxB,cAAuC;IACrDyB,QAAQ;QAAEC,SAASf;IAA0B;IAC7CgB,UAAU;IACVC,YAAY;IACZC,YAAY;IACZC,iBAAiB;IACjBC,kBAAkBC;IAClBC,oBAAoB;AACtB;AACAT,QAAQU,WAAW,GAA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9C;gBACF;gBAEAiE,cAAcL,OAAOT;YACvB;QACF;QACAb;QACAC;QACAhC;QACA8B;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/movement/utils.ts"],"sourcesContent":["import { type KeyboardEvent } from \"react\";\nimport { loop } from \"../utils/loop.js\";\nimport { type FocusableIndexOptions, type TabIndexBehavior } from \"./types.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const isElementDisabled = (element: HTMLElement): boolean =>\n element.getAttribute(\"disabled\") !== null ||\n element.getAttribute(\"aria-disabled\") === \"true\";\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport const isNotFocusable = (\n element: HTMLElement | undefined,\n includeDisabled: boolean\n): boolean => {\n if (!element) {\n return true;\n }\n\n if (includeDisabled) {\n return false;\n }\n\n return isElementDisabled(element);\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface VirtualFocusableIndexOptions {\n focusables: readonly HTMLElement[];\n includeDisabled: boolean;\n activeDescendantId: string;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const getVirtualFocusDefaultIndex = (\n options: VirtualFocusableIndexOptions\n): number => {\n const { focusables, includeDisabled, activeDescendantId } = options;\n if (!focusables.length || (!activeDescendantId && includeDisabled)) {\n return 0;\n }\n\n const activeIndex = focusables.findIndex((element) => {\n if (activeDescendantId) {\n return element.id === activeDescendantId;\n }\n\n return !isElementDisabled(element);\n });\n return Math.max(0, activeIndex);\n};\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport const getFirstFocusableIndex = (\n options: FocusableIndexOptions\n): number => {\n const { focusables, includeDisabled } = options;\n\n if (!focusables.length) {\n return -1;\n }\n\n let firstIndex = 0;\n while (\n firstIndex < focusables.length - 1 &&\n isNotFocusable(focusables[firstIndex], includeDisabled)\n ) {\n firstIndex += 1;\n }\n\n if (isNotFocusable(focusables[firstIndex], includeDisabled)) {\n return -1;\n }\n\n return firstIndex;\n};\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport const getLastFocusableIndex = (\n options: FocusableIndexOptions\n): number => {\n const { focusables, includeDisabled } = options;\n\n if (!focusables.length) {\n return -1;\n }\n\n let lastIndex = focusables.length - 1;\n while (\n lastIndex > 0 &&\n isNotFocusable(focusables[lastIndex], includeDisabled)\n ) {\n lastIndex -= 1;\n }\n\n if (isNotFocusable(focusables[lastIndex], includeDisabled)) {\n return -1;\n }\n\n return lastIndex;\n};\n\n/**\n * @since 5.0.0\n * @internal\n */\ninterface NextFocusableIndexOptions extends FocusableIndexOptions {\n loopable: boolean;\n increment: boolean;\n currentFocusIndex: number;\n}\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport const getNextFocusableIndex = (\n options: NextFocusableIndexOptions\n): number => {\n const {\n loopable,\n increment,\n focusables,\n includeDisabled,\n currentFocusIndex,\n } = options;\n if (!focusables.length) {\n return currentFocusIndex;\n }\n\n const min = getFirstFocusableIndex({ focusables, includeDisabled });\n const max = getLastFocusableIndex({ focusables, includeDisabled });\n let nextIndex = loop({\n min,\n max,\n value: currentFocusIndex,\n minmax: !loopable,\n increment,\n });\n while (\n isNotFocusable(focusables[nextIndex], includeDisabled) &&\n (loopable || nextIndex !== (increment ? max : min))\n ) {\n nextIndex = loop({\n min,\n max,\n value: nextIndex,\n minmax: !loopable,\n increment,\n });\n }\n\n // Since the `min` and `max` values are \"safely\" set, I don't need to verify\n // the nextIndex is still focusable\n return nextIndex;\n};\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport function getSearchText(\n element: HTMLElement,\n searchable: boolean\n): string {\n if (!searchable) {\n return \"\";\n }\n\n const cloned = element.cloneNode(true) as HTMLElement;\n cloned\n .querySelectorAll(\n // Note: do not include DISPLAY_NONE_CLASS since it is presentational only\n \".rmd-icon--font,[aria-hidden=true],[hidden],[role=presentation]\"\n )\n .forEach((element) => {\n element.parentNode?.removeChild(element);\n });\n\n // Note: It would be good to use `cloned.innerText` (maybe?) at some point,\n // but it returns `undefined` in jsdom. It also does cause a reflow, so maybe\n // this is fine?\n // https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#differences_from_innertext\n return (cloned.textContent || \"\")[0].toUpperCase();\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface RecalculateOptions {\n focusables: readonly HTMLElement[];\n includeDisabled: boolean;\n tabIndexBehavior: TabIndexBehavior | undefined;\n activeDescendantId: string;\n}\n\n/**\n * This was added to help with specific widgets that cause focus index to change\n * between renders (i.e. expanding all tree items on the same level with `*`).\n * There might be a better way to handle this in the future.\n *\n * @since 6.0.0\n * @internal\n */\nexport function recalculateFocusIndex(options: RecalculateOptions): number {\n const { focusables, includeDisabled, tabIndexBehavior, activeDescendantId } =\n options;\n if (tabIndexBehavior === \"virtual\") {\n return getVirtualFocusDefaultIndex({\n focusables,\n includeDisabled,\n activeDescendantId,\n });\n }\n\n const { activeElement } = document;\n return focusables.findIndex((element) => element === activeElement);\n}\n\n/**\n * Checks if a keyboard event can trigger a search through focusable elements\n * by:\n *\n * - checking if the key is a single letter that is not the space key\n * - checking that the alt, ctrl, and meta keys are not being held\n *\n * The shift key **is allowed** because holding shift means \"search from the\n * beginning\" instead of \"search from current location\".\n *\n * @since 6.0.0\n * @internal\n */\nexport function isSearchableEvent(event: KeyboardEvent): boolean {\n const { key, altKey, ctrlKey, metaKey } = event;\n\n return (\n key.length === 1 &&\n // can't search with space since it is generally a click event\n key !== \" \" &&\n !altKey &&\n !ctrlKey &&\n !metaKey\n );\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function isTypeEvent(event: KeyboardEvent): boolean {\n return (\n isSearchableEvent(event) || [\"Backspace\", \"Delete\", \" \"].includes(event.key)\n );\n}\n"],"names":["loop","isElementDisabled","element","getAttribute","isNotFocusable","includeDisabled","getVirtualFocusDefaultIndex","options","focusables","activeDescendantId","length","activeIndex","findIndex","id","Math","max","getFirstFocusableIndex","firstIndex","getLastFocusableIndex","lastIndex","getNextFocusableIndex","loopable","increment","currentFocusIndex","min","nextIndex","value","minmax","getSearchText","searchable","cloned","cloneNode","querySelectorAll","forEach","parentNode","removeChild","textContent","toUpperCase","recalculateFocusIndex","tabIndexBehavior","activeElement","document","isSearchableEvent","event","key","altKey","ctrlKey","metaKey","isTypeEvent","includes"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,IAAI,QAAQ,mBAAmB;AAGxC;;;CAGC,GACD,OAAO,MAAMC,oBAAoB,CAACC,UAChCA,QAAQC,YAAY,CAAC,gBAAgB,QACrCD,QAAQC,YAAY,CAAC,qBAAqB,OAAO;AAEnD;;;CAGC,GACD,OAAO,MAAMC,iBAAiB,CAC5BF,SACAG;IAEA,IAAI,CAACH,SAAS;QACZ,OAAO;IACT;IAEA,IAAIG,iBAAiB;QACnB,OAAO;IACT;IAEA,OAAOJ,kBAAkBC;AAC3B,EAAE;AAYF;;;CAGC,GACD,OAAO,MAAMI,8BAA8B,CACzCC;IAEA,MAAM,EAAEC,UAAU,EAAEH,eAAe,EAAEI,kBAAkB,EAAE,GAAGF;IAC5D,IAAI,CAACC,WAAWE,MAAM,IAAK,CAACD,sBAAsBJ,iBAAkB;QAClE,OAAO;IACT;IAEA,MAAMM,cAAcH,WAAWI,SAAS,CAAC,CAACV;QACxC,IAAIO,oBAAoB;YACtB,OAAOP,QAAQW,EAAE,KAAKJ;QACxB;QAEA,OAAO,CAACR,kBAAkBC;IAC5B;IACA,OAAOY,KAAKC,GAAG,CAAC,GAAGJ;AACrB,EAAE;AAEF;;;CAGC,GACD,OAAO,MAAMK,yBAAyB,CACpCT;IAEA,MAAM,EAAEC,UAAU,EAAEH,eAAe,EAAE,GAAGE;IAExC,IAAI,CAACC,WAAWE,MAAM,EAAE;QACtB,OA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;IACnC,OAAOG;AACT,EAAE;AAEF;;;CAGC,GACD,OAAO,SAASG,cACd1B,OAAoB,EACpB2B,UAAmB;IAEnB,IAAI,CAACA,YAAY;QACf,OAAO;IACT;IAEA,MAAMC,SAAS5B,QAAQ6B,SAAS,CAAC;IACjCD,OACGE,gBAAgB,CACf,0EAA0E;IAC1E,mEAEDC,OAAO,CAAC,CAAC/B;QACRA,QAAQgC,UAAU,EAAEC,YAAYjC;IAClC;IAEF,2EAA2E;IAC3E,6EAA6E;IAC7E,gBAAgB;IAChB,+FAA+F;IAC/F,OAAO,AAAC4B,CAAAA,OAAOM,WAAW,IAAI,EAAC,CAAE,CAAC,EAAE,CAACC,WAAW;AAClD;AAaA;;;;;;;CAOC,GACD,OAAO,SAASC,sBAAsB/B,OAA2B;IAC/D,MAAM,EAAEC,UAAU,EAAEH,eAAe,EAAEkC,gBAAgB,EAAE9B,kBAAkB,EAAE,GACzEF;IACF,IAAIgC,qBAAqB,WAAW;QAClC,OAAOjC,4BAA4B;YACjCE;YACAH;YACAI;QACF;IACF;IAEA,MAAM,EAAE+B,aAAa,EAAE,GAAGC;IAC1B,OAAOjC,WAAWI,SAAS,CAAC,CAACV,UAAYA,YAAYsC;AACvD;AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASE,kBAAkBC,KAAoB;IACpD,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGJ;IAE1C,OACEC,IAAIlC,MAAM,KAAK,KACf,8DAA8D;IAC9DkC,QAAQ,OACR,CAACC,UACD,CAACC,WACD,CAACC;AAEL;AAEA;;;CAGC,GACD,OAAO,SAASC,YAAYL,KAAoB;IAC9C,OACED,kBAAkBC,UAAU;QAAC;QAAa;QAAU;KAAI,CAACM,QAAQ,CAACN,MAAMC,GAAG;AAE/E"}
|
|
1
|
+
{"version":3,"sources":["../../src/movement/utils.ts"],"sourcesContent":["import { type KeyboardEvent } from \"react\";\nimport { loop } from \"../utils/loop.js\";\nimport { type FocusableIndexOptions, type TabIndexBehavior } from \"./types.js\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const isElementDisabled = (element: HTMLElement): boolean =>\n element.getAttribute(\"disabled\") !== null ||\n element.getAttribute(\"aria-disabled\") === \"true\";\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport const isNotFocusable = (\n element: HTMLElement | undefined,\n includeDisabled: boolean\n): boolean => {\n if (!element) {\n return true;\n }\n\n if (includeDisabled) {\n return false;\n }\n\n return isElementDisabled(element);\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface VirtualFocusableIndexOptions {\n focusables: readonly HTMLElement[];\n includeDisabled: boolean;\n activeDescendantId: string;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const getVirtualFocusDefaultIndex = (\n options: VirtualFocusableIndexOptions\n): number => {\n const { focusables, includeDisabled, activeDescendantId } = options;\n if (!focusables.length || (!activeDescendantId && includeDisabled)) {\n return 0;\n }\n\n const activeIndex = focusables.findIndex((element) => {\n if (activeDescendantId) {\n return element.id === activeDescendantId;\n }\n\n return !isElementDisabled(element);\n });\n return Math.max(0, activeIndex);\n};\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport const getFirstFocusableIndex = (\n options: FocusableIndexOptions\n): number => {\n const { focusables, includeDisabled } = options;\n\n if (!focusables.length) {\n return -1;\n }\n\n let firstIndex = 0;\n while (\n firstIndex < focusables.length - 1 &&\n isNotFocusable(focusables[firstIndex], includeDisabled)\n ) {\n firstIndex += 1;\n }\n\n if (isNotFocusable(focusables[firstIndex], includeDisabled)) {\n return -1;\n }\n\n return firstIndex;\n};\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport const getLastFocusableIndex = (\n options: FocusableIndexOptions\n): number => {\n const { focusables, includeDisabled } = options;\n\n if (!focusables.length) {\n return -1;\n }\n\n let lastIndex = focusables.length - 1;\n while (\n lastIndex > 0 &&\n isNotFocusable(focusables[lastIndex], includeDisabled)\n ) {\n lastIndex -= 1;\n }\n\n if (isNotFocusable(focusables[lastIndex], includeDisabled)) {\n return -1;\n }\n\n return lastIndex;\n};\n\n/**\n * @since 5.0.0\n * @internal\n */\ninterface NextFocusableIndexOptions extends FocusableIndexOptions {\n loopable: boolean;\n increment: boolean;\n currentFocusIndex: number;\n}\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport const getNextFocusableIndex = (\n options: NextFocusableIndexOptions\n): number => {\n const {\n loopable,\n increment,\n focusables,\n includeDisabled,\n currentFocusIndex,\n } = options;\n if (!focusables.length) {\n return currentFocusIndex;\n }\n\n const min = getFirstFocusableIndex({ focusables, includeDisabled });\n const max = getLastFocusableIndex({ focusables, includeDisabled });\n let nextIndex = loop({\n min,\n max,\n value: currentFocusIndex,\n minmax: !loopable,\n increment,\n });\n while (\n isNotFocusable(focusables[nextIndex], includeDisabled) &&\n (loopable || nextIndex !== (increment ? max : min))\n ) {\n nextIndex = loop({\n min,\n max,\n value: nextIndex,\n minmax: !loopable,\n increment,\n });\n }\n\n // Since the `min` and `max` values are \"safely\" set, I don't need to verify\n // the nextIndex is still focusable\n return nextIndex;\n};\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport function getSearchText(\n element: HTMLElement,\n searchable: boolean\n): string {\n if (!searchable) {\n return \"\";\n }\n\n const cloned = element.cloneNode(true) as HTMLElement;\n cloned\n .querySelectorAll(\n // Note: do not include DISPLAY_NONE_CLASS since it is presentational only\n \".rmd-icon--font,[aria-hidden=true],[hidden],[role=presentation]\"\n )\n .forEach((element) => {\n element.parentNode?.removeChild(element);\n });\n\n // Note: It would be good to use `cloned.innerText` (maybe?) at some point,\n // but it returns `undefined` in jsdom. It also does cause a reflow, so maybe\n // this is fine?\n // https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#differences_from_innertext\n return (cloned.textContent || \"\")[0].toUpperCase();\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface RecalculateOptions {\n focusables: readonly HTMLElement[];\n includeDisabled: boolean;\n tabIndexBehavior: TabIndexBehavior | undefined;\n activeDescendantId: string;\n}\n\n/**\n * This was added to help with specific widgets that cause focus index to change\n * between renders (i.e. expanding all tree items on the same level with `*`).\n * There might be a better way to handle this in the future.\n *\n * @since 6.0.0\n * @internal\n */\nexport function recalculateFocusIndex(options: RecalculateOptions): number {\n const { focusables, includeDisabled, tabIndexBehavior, activeDescendantId } =\n options;\n if (tabIndexBehavior === \"virtual\") {\n return getVirtualFocusDefaultIndex({\n focusables,\n includeDisabled,\n activeDescendantId,\n });\n }\n\n const { activeElement } = document;\n return focusables.findIndex((element) => element === activeElement);\n}\n\n/**\n * Checks if a keyboard event can trigger a search through focusable elements\n * by:\n *\n * - checking if the key is a single letter that is not the space key\n * - checking that the alt, ctrl, and meta keys are not being held\n *\n * The shift key **is allowed** because holding shift means \"search from the\n * beginning\" instead of \"search from current location\".\n *\n * @since 6.0.0\n * @internal\n */\nexport function isSearchableEvent(event: KeyboardEvent): boolean {\n const { key, altKey, ctrlKey, metaKey } = event;\n\n return (\n key.length === 1 &&\n // can't search with space since it is generally a click event\n key !== \" \" &&\n !altKey &&\n !ctrlKey &&\n !metaKey\n );\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport function isTypeEvent(event: KeyboardEvent): boolean {\n return (\n isSearchableEvent(event) || [\"Backspace\", \"Delete\", \" \"].includes(event.key)\n );\n}\n"],"names":["loop","isElementDisabled","element","getAttribute","isNotFocusable","includeDisabled","getVirtualFocusDefaultIndex","options","focusables","activeDescendantId","length","activeIndex","findIndex","id","Math","max","getFirstFocusableIndex","firstIndex","getLastFocusableIndex","lastIndex","getNextFocusableIndex","loopable","increment","currentFocusIndex","min","nextIndex","value","minmax","getSearchText","searchable","cloned","cloneNode","querySelectorAll","forEach","parentNode","removeChild","textContent","toUpperCase","recalculateFocusIndex","tabIndexBehavior","activeElement","document","isSearchableEvent","event","key","altKey","ctrlKey","metaKey","isTypeEvent","includes"],"mappings":"AACA,SAASA,IAAI,QAAQ,mBAAmB;AAGxC;;;C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,EAAE,CAACC,WAAW;AAClD;AAaA;;;;;;;CAOC,GACD,OAAO,SAASC,sBAAsB/B,OAA2B;IAC/D,MAAM,EAAEC,UAAU,EAAEH,eAAe,EAAEkC,gBAAgB,EAAE9B,kBAAkB,EAAE,GACzEF;IACF,IAAIgC,qBAAqB,WAAW;QAClC,OAAOjC,4BAA4B;YACjCE;YACAH;YACAI;QACF;IACF;IAEA,MAAM,EAAE+B,aAAa,EAAE,GAAGC;IAC1B,OAAOjC,WAAWI,SAAS,CAAC,CAACV,UAAYA,YAAYsC;AACvD;AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASE,kBAAkBC,KAAoB;IACpD,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGJ;IAE1C,OACEC,IAAIlC,MAAM,KAAK,KACf,8DAA8D;IAC9DkC,QAAQ,OACR,CAACC,UACD,CAACC,WACD,CAACC;AAEL;AAEA;;;CAGC,GACD,OAAO,SAASC,YAAYL,KAAoB;IAC9C,OACED,kBAAkBC,UAAU;QAAC;QAAa;QAAU;KAAI,CAACM,QAAQ,CAACN,MAAMC,GAAG;AAE/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/navigation/CollapsibleNavGroup.tsx"],"sourcesContent":["\"use client\";\nimport { forwardRef, type LiHTMLAttributes, type ReactNode } from \"react\";\nimport { type ButtonProps } from \"../button/Button.js\";\nimport { useCollapseTransition } from \"../transition/useCollapseTransition.js\";\nimport { type PropsWithRef, type UseStateInitializer } from \"../types.js\";\nimport { useToggle } from \"../useToggle.js\";\nimport { NavGroup, type NavGroupProps } from \"./NavGroup.js\";\nimport { NavItem } from \"./NavItem.js\";\nimport {\n NavItemButton,\n type NavItemButtonRotatorProps,\n} from \"./NavItemButton.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport interface CollapsibleNavGroupProps\n extends NavGroupProps,\n NavItemButtonRotatorProps {\n liProps?: PropsWithRef<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;\n buttonProps?: PropsWithRef<ButtonProps, HTMLButtonElement>;\n\n /**\n * The children to render in the {@link NavItemButton} that toggles the\n * collapsed state\n */\n buttonChildren: ReactNode;\n\n /**\n * The content that should be rendered in the non-collapsed {@link NavGroup}.\n */\n children: ReactNode;\n\n /** @defaultValue `false` */\n defaultCollapsed?: UseStateInitializer<boolean>;\n}\n\n/**\n * **Client Component**\n *\n * @since 6.0.0\n */\nexport const CollapsibleNavGroup = forwardRef<\n HTMLUListElement,\n CollapsibleNavGroupProps\n>(function CollapsibleNavGroup(props, ref) {\n const {\n liProps,\n buttonProps,\n buttonChildren,\n icon,\n iconRotatorProps,\n disableIconRotator,\n className,\n children,\n defaultCollapsed,\n ...remaining\n } = props;\n\n const { toggled: collapsed, toggle } = useToggle(defaultCollapsed);\n const { rendered, elementProps } = useCollapseTransition({\n nodeRef: ref,\n className,\n transitionIn: !collapsed,\n });\n const onButtonClick = buttonProps?.onClick ?? noop;\n\n return (\n <NavItem {...liProps}>\n <NavItemButton\n {...buttonProps}\n onClick={(event) => {\n onButtonClick(event);\n toggle();\n }}\n collapsed={collapsed}\n icon={icon}\n iconRotatorProps={iconRotatorProps}\n disableIconRotator={disableIconRotator}\n >\n {buttonChildren}\n </NavItemButton>\n {rendered && (\n <NavGroup {...remaining} {...elementProps}>\n {children}\n </NavGroup>\n )}\n </NavItem>\n );\n});\n"],"names":["forwardRef","useCollapseTransition","useToggle","NavGroup","NavItem","NavItemButton","noop","CollapsibleNavGroup","props","ref","liProps","buttonProps","buttonChildren","icon","iconRotatorProps","disableIconRotator","className","children","defaultCollapsed","remaining","toggled","collapsed","toggle","rendered","elementProps","nodeRef","transitionIn","onButtonClick","onClick","event"],"
|
|
1
|
+
{"version":3,"sources":["../../src/navigation/CollapsibleNavGroup.tsx"],"sourcesContent":["\"use client\";\nimport { forwardRef, type LiHTMLAttributes, type ReactNode } from \"react\";\nimport { type ButtonProps } from \"../button/Button.js\";\nimport { useCollapseTransition } from \"../transition/useCollapseTransition.js\";\nimport { type PropsWithRef, type UseStateInitializer } from \"../types.js\";\nimport { useToggle } from \"../useToggle.js\";\nimport { NavGroup, type NavGroupProps } from \"./NavGroup.js\";\nimport { NavItem } from \"./NavItem.js\";\nimport {\n NavItemButton,\n type NavItemButtonRotatorProps,\n} from \"./NavItemButton.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport interface CollapsibleNavGroupProps\n extends NavGroupProps,\n NavItemButtonRotatorProps {\n liProps?: PropsWithRef<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;\n buttonProps?: PropsWithRef<ButtonProps, HTMLButtonElement>;\n\n /**\n * The children to render in the {@link NavItemButton} that toggles the\n * collapsed state\n */\n buttonChildren: ReactNode;\n\n /**\n * The content that should be rendered in the non-collapsed {@link NavGroup}.\n */\n children: ReactNode;\n\n /** @defaultValue `false` */\n defaultCollapsed?: UseStateInitializer<boolean>;\n}\n\n/**\n * **Client Component**\n *\n * @since 6.0.0\n */\nexport const CollapsibleNavGroup = forwardRef<\n HTMLUListElement,\n CollapsibleNavGroupProps\n>(function CollapsibleNavGroup(props, ref) {\n const {\n liProps,\n buttonProps,\n buttonChildren,\n icon,\n iconRotatorProps,\n disableIconRotator,\n className,\n children,\n defaultCollapsed,\n ...remaining\n } = props;\n\n const { toggled: collapsed, toggle } = useToggle(defaultCollapsed);\n const { rendered, elementProps } = useCollapseTransition({\n nodeRef: ref,\n className,\n transitionIn: !collapsed,\n });\n const onButtonClick = buttonProps?.onClick ?? noop;\n\n return (\n <NavItem {...liProps}>\n <NavItemButton\n {...buttonProps}\n onClick={(event) => {\n onButtonClick(event);\n toggle();\n }}\n collapsed={collapsed}\n icon={icon}\n iconRotatorProps={iconRotatorProps}\n disableIconRotator={disableIconRotator}\n >\n {buttonChildren}\n </NavItemButton>\n {rendered && (\n <NavGroup {...remaining} {...elementProps}>\n {children}\n </NavGroup>\n )}\n </NavItem>\n );\n});\n"],"names":["forwardRef","useCollapseTransition","useToggle","NavGroup","NavItem","NavItemButton","noop","CollapsibleNavGroup","props","ref","liProps","buttonProps","buttonChildren","icon","iconRotatorProps","disableIconRotator","className","children","defaultCollapsed","remaining","toggled","collapsed","toggle","rendered","elementProps","nodeRef","transitionIn","onButtonClick","onClick","event"],"mappings":"AAAA;;AACA,SAASA,UAAU,QAA+C,QAAQ;AAE1E,SAASC,qBAAqB,QAAQ,yCAAyC;AAE/E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,QAAQ,QAA4B,gBAAgB;AAC7D,SAASC,OAAO,QAAQ,eAAe;AACvC,SACEC,aAAa,QAER,qBAAqB;AAE5B,MAAMC,OAAO;AACX,aAAa;AACf;AA0BA;;;;CAIC,GACD,OAAO,MAAMC,oCAAsBP,WAGjC,SAASO,oBAAoBC,KAAK,EAAEC,GAAG;IACvC,MAAM,EACJC,OAAO,EACPC,WAAW,EACXC,cAAc,EACdC,IAAI,EACJC,gBAAgB,EAChBC,kBAAkB,EAClBC,SAAS,EACTC,QAAQ,EACRC,gBAAgB,EAChB,GAAGC,WACJ,GAAGX;IAEJ,MAAM,EAAEY,SAASC,SAAS,EAAEC,MAAM,EAAE,GAAGpB,UAAUgB;IACjD,MAAM,EAAEK,QAAQ,EAAEC,YAAY,EAAE,GAAGvB,sBAAsB;QACvDwB,SAAShB;QACTO;QACAU,cAAc,CAACL;IACjB;IACA,MAAMM,gBAAgBhB,aAAaiB,WAAWtB;IAE9C,qBACE,MAACF;QAAS,GAAGM,OAAO;;0BAClB,KAACL;gBACE,GAAGM,WAAW;gBACfiB,SAAS,CAACC;oBACRF,cAAcE;oBACdP;gBACF;gBACAD,WAAWA;gBACXR,MAAMA;gBACNC,kBAAkBA;gBAClBC,oBAAoBA;0BAEnBH;;YAEFW,0BACC,KAACpB;gBAAU,GAAGgB,SAAS;gBAAG,GAAGK,YAAY;0BACtCP;;;;AAKX,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/navigation/DefaultNavigationRenderer.tsx"],"sourcesContent":["import { type ReactElement } from \"react\";\nimport { Divider } from \"../divider/Divider.js\";\nimport { type RenderRecursiveItemsProps } from \"../utils/RenderRecursively.js\";\nimport { CollapsibleNavGroup } from \"./CollapsibleNavGroup.js\";\nimport { NavItemLink } from \"./NavItemLink.js\";\nimport { NavSubheader } from \"./NavSubheader.js\";\nimport { getHrefFromParents } from \"./getHrefFromParents.js\";\nimport { type NavigationItem, type NavigationRenderData } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface DefaultNavigationRendererProps<\n Item extends NavigationItem = NavigationItem,\n Data extends NavigationRenderData = NavigationRenderData,\n> extends RenderRecursiveItemsProps<Item, Data> {}\n\n/**\n * **Client Component**\n *\n * The default behavior is attempt to render in order:\n * - `const { type, items, ...props } = item`\n * - `type === \"divider\"` - `<Divider {...props} />`\n * - `type === \"subheader\"` - `<NavSubheader {...props} />`\n * - `type === \"group\"` - `<><NavSubheader {...props} />{children}</>`\n * - `!!items` - `<CollapsibleNavGroup />`\n * - `<NavItemLink {...item} as={linkComponent} active={pathname === href} />`\n *\n * @since 6.0.0\n */\nexport function DefaultNavigationRenderer<\n Item extends NavigationItem,\n Data extends NavigationRenderData,\n>(props: DefaultNavigationRendererProps<Item, Data>): ReactElement {\n const { item, data, children, parents } = props;\n switch (item.type) {\n case \"divider\": {\n const { type: _type, items: _items, ...divider } = item;\n return <Divider {...divider} />;\n }\n case \"subheader\": {\n const { type: _type, items: _items, ...subheader } = item;\n return <NavSubheader {...subheader} />;\n }\n }\n\n if (item.items) {\n const nextParents = [item, ...parents];\n return (\n <CollapsibleNavGroup\n depth={nextParents.length}\n defaultCollapsed={() =>\n !data?.pathname.includes(getHrefFromParents(nextParents))\n }\n buttonChildren={item.children}\n >\n {children}\n </CollapsibleNavGroup>\n );\n }\n\n const href = `${getHrefFromParents(parents)}${item.href}`;\n return (\n <NavItemLink\n {...item}\n as={data?.linkComponent}\n active={(\"active\" in item && !!item.active) || data?.pathname === href}\n href={href}\n />\n );\n}\n"],"names":["Divider","CollapsibleNavGroup","NavItemLink","NavSubheader","getHrefFromParents","DefaultNavigationRenderer","props","item","data","children","parents","type","_type","items","_items","divider","subheader","nextParents","depth","length","defaultCollapsed","pathname","includes","buttonChildren","href","as","linkComponent","active"],"
|
|
1
|
+
{"version":3,"sources":["../../src/navigation/DefaultNavigationRenderer.tsx"],"sourcesContent":["import { type ReactElement } from \"react\";\nimport { Divider } from \"../divider/Divider.js\";\nimport { type RenderRecursiveItemsProps } from \"../utils/RenderRecursively.js\";\nimport { CollapsibleNavGroup } from \"./CollapsibleNavGroup.js\";\nimport { NavItemLink } from \"./NavItemLink.js\";\nimport { NavSubheader } from \"./NavSubheader.js\";\nimport { getHrefFromParents } from \"./getHrefFromParents.js\";\nimport { type NavigationItem, type NavigationRenderData } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface DefaultNavigationRendererProps<\n Item extends NavigationItem = NavigationItem,\n Data extends NavigationRenderData = NavigationRenderData,\n> extends RenderRecursiveItemsProps<Item, Data> {}\n\n/**\n * **Client Component**\n *\n * The default behavior is attempt to render in order:\n * - `const { type, items, ...props } = item`\n * - `type === \"divider\"` - `<Divider {...props} />`\n * - `type === \"subheader\"` - `<NavSubheader {...props} />`\n * - `type === \"group\"` - `<><NavSubheader {...props} />{children}</>`\n * - `!!items` - `<CollapsibleNavGroup />`\n * - `<NavItemLink {...item} as={linkComponent} active={pathname === href} />`\n *\n * @since 6.0.0\n */\nexport function DefaultNavigationRenderer<\n Item extends NavigationItem,\n Data extends NavigationRenderData,\n>(props: DefaultNavigationRendererProps<Item, Data>): ReactElement {\n const { item, data, children, parents } = props;\n switch (item.type) {\n case \"divider\": {\n const { type: _type, items: _items, ...divider } = item;\n return <Divider {...divider} />;\n }\n case \"subheader\": {\n const { type: _type, items: _items, ...subheader } = item;\n return <NavSubheader {...subheader} />;\n }\n }\n\n if (item.items) {\n const nextParents = [item, ...parents];\n return (\n <CollapsibleNavGroup\n depth={nextParents.length}\n defaultCollapsed={() =>\n !data?.pathname.includes(getHrefFromParents(nextParents))\n }\n buttonChildren={item.children}\n >\n {children}\n </CollapsibleNavGroup>\n );\n }\n\n const href = `${getHrefFromParents(parents)}${item.href}`;\n return (\n <NavItemLink\n {...item}\n as={data?.linkComponent}\n active={(\"active\" in item && !!item.active) || data?.pathname === href}\n href={href}\n />\n );\n}\n"],"names":["Divider","CollapsibleNavGroup","NavItemLink","NavSubheader","getHrefFromParents","DefaultNavigationRenderer","props","item","data","children","parents","type","_type","items","_items","divider","subheader","nextParents","depth","length","defaultCollapsed","pathname","includes","buttonChildren","href","as","linkComponent","active"],"mappings":";AACA,SAASA,OAAO,QAAQ,wBAAwB;AAEhD,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,kBAAkB,QAAQ,0BAA0B;AAW7D;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,0BAGdC,KAAiD;IACjD,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAE,GAAGJ;IAC1C,OAAQC,KAAKI,IAAI;QACf,KAAK;YAAW;gBACd,MAAM,EAAEA,MAAMC,KAAK,EAAEC,OAAOC,MAAM,EAAE,GAAGC,SAAS,GAAGR;gBACnD,qBAAO,KAACP;oBAAS,GAAGe,OAAO;;YAC7B;QACA,KAAK;YAAa;gBAChB,MAAM,EAAEJ,MAAMC,KAAK,EAAEC,OAAOC,MAAM,EAAE,GAAGE,WAAW,GAAGT;gBACrD,qBAAO,KAACJ;oBAAc,GAAGa,SAAS;;YACpC;IACF;IAEA,IAAIT,KAAKM,KAAK,EAAE;QACd,MAAMI,cAAc;YAACV;eAASG;SAAQ;QACtC,qBACE,KAACT;YACCiB,OAAOD,YAAYE,MAAM;YACzBC,kBAAkB,IAChB,CAACZ,MAAMa,SAASC,SAASlB,mBAAmBa;YAE9CM,gBAAgBhB,KAAKE,QAAQ;sBAE5BA;;IAGP;IAEA,MAAMe,OAAO,CAAC,EAAEpB,mBAAmBM,SAAS,EAAEH,KAAKiB,IAAI,CAAC,CAAC;IACzD,qBACE,KAACtB;QACE,GAAGK,IAAI;QACRkB,IAAIjB,MAAMkB;QACVC,QAAQ,AAAC,YAAYpB,QAAQ,CAAC,CAACA,KAAKoB,MAAM,IAAKnB,MAAMa,aAAaG;QAClEA,MAAMA;;AAGZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/navigation/NavGroup.tsx"],"sourcesContent":["import { forwardRef, type ReactNode } from \"react\";\nimport { List, type ListProps } from \"../list/List.js\";\nimport { navGroup } from \"./navGroupStyles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface NavGroupProps extends ListProps {\n depth: number;\n children: ReactNode;\n}\n\n/**\n * **Server Component**\n *\n * A simple wrapper around the {@link Link} component that ads the\n * `--rmd-tree-depth: depth` custom property to allow for incremented padding.\n *\n * @since 6.0.0\n */\nexport const NavGroup = forwardRef<HTMLUListElement, NavGroupProps>(\n function NavGroup(props, ref) {\n const { style, depth, className, children, ...remaining } = props;\n\n return (\n <List\n {...remaining}\n ref={ref}\n style={{ ...style, \"--rmd-tree-depth\": depth }}\n className={navGroup({\n className,\n disablePadding: depth > 0,\n })}\n >\n {children}\n </List>\n );\n }\n);\n"],"names":["forwardRef","List","navGroup","NavGroup","props","ref","style","depth","className","children","remaining","disablePadding"],"
|
|
1
|
+
{"version":3,"sources":["../../src/navigation/NavGroup.tsx"],"sourcesContent":["import { forwardRef, type ReactNode } from \"react\";\nimport { List, type ListProps } from \"../list/List.js\";\nimport { navGroup } from \"./navGroupStyles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface NavGroupProps extends ListProps {\n depth: number;\n children: ReactNode;\n}\n\n/**\n * **Server Component**\n *\n * A simple wrapper around the {@link Link} component that ads the\n * `--rmd-tree-depth: depth` custom property to allow for incremented padding.\n *\n * @since 6.0.0\n */\nexport const NavGroup = forwardRef<HTMLUListElement, NavGroupProps>(\n function NavGroup(props, ref) {\n const { style, depth, className, children, ...remaining } = props;\n\n return (\n <List\n {...remaining}\n ref={ref}\n style={{ ...style, \"--rmd-tree-depth\": depth }}\n className={navGroup({\n className,\n disablePadding: depth > 0,\n })}\n >\n {children}\n </List>\n );\n }\n);\n"],"names":["forwardRef","List","navGroup","NavGroup","props","ref","style","depth","className","children","remaining","disablePadding"],"mappings":";AAAA,SAASA,UAAU,QAAwB,QAAQ;AACnD,SAASC,IAAI,QAAwB,kBAAkB;AACvD,SAASC,QAAQ,QAAQ,sBAAsB;AAU/C;;;;;;;CAOC,GACD,OAAO,MAAMC,yBAAWH,WACtB,SAASG,SAASC,KAAK,EAAEC,GAAG;IAC1B,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGN;IAE5D,qBACE,KAACH;QACE,GAAGS,SAAS;QACbL,KAAKA;QACLC,OAAO;YAAE,GAAGA,KAAK;YAAE,oBAAoBC;QAAM;QAC7CC,WAAWN,SAAS;YAClBM;YACAG,gBAAgBJ,QAAQ;QAC1B;kBAECE;;AAGP,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/navigation/NavItem.tsx"],"sourcesContent":["import { forwardRef, type LiHTMLAttributes, type ReactNode } from \"react\";\nimport { navItem } from \"./navItemStyles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface NavItemProps extends LiHTMLAttributes<HTMLLIElement> {\n children: ReactNode;\n}\n\n/**\n * **Server Component**\n *\n * This component is just used to add padding based on the depth of the nav item\n * and should not be used on its own. See the `CollapsibleNavGroup` and\n * `NavItemLink` instead.\n *\n * @since 6.0.0\n */\nexport const NavItem = forwardRef<HTMLLIElement, NavItemProps>(\n function NavItem(props, ref) {\n const { className, children, ...remaining } = props;\n return (\n <li {...remaining} ref={ref} className={navItem({ className })}>\n {children}\n </li>\n );\n }\n);\n"],"names":["forwardRef","navItem","NavItem","props","ref","className","children","remaining","li"],"
|
|
1
|
+
{"version":3,"sources":["../../src/navigation/NavItem.tsx"],"sourcesContent":["import { forwardRef, type LiHTMLAttributes, type ReactNode } from \"react\";\nimport { navItem } from \"./navItemStyles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface NavItemProps extends LiHTMLAttributes<HTMLLIElement> {\n children: ReactNode;\n}\n\n/**\n * **Server Component**\n *\n * This component is just used to add padding based on the depth of the nav item\n * and should not be used on its own. See the `CollapsibleNavGroup` and\n * `NavItemLink` instead.\n *\n * @since 6.0.0\n */\nexport const NavItem = forwardRef<HTMLLIElement, NavItemProps>(\n function NavItem(props, ref) {\n const { className, children, ...remaining } = props;\n return (\n <li {...remaining} ref={ref} className={navItem({ className })}>\n {children}\n </li>\n );\n }\n);\n"],"names":["forwardRef","navItem","NavItem","props","ref","className","children","remaining","li"],"mappings":";AAAA,SAASA,UAAU,QAA+C,QAAQ;AAC1E,SAASC,OAAO,QAAQ,qBAAqB;AAS7C;;;;;;;;CAQC,GACD,OAAO,MAAMC,wBAAUF,WACrB,SAASE,QAAQC,KAAK,EAAEC,GAAG;IACzB,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IAC9C,qBACE,KAACK;QAAI,GAAGD,SAAS;QAAEH,KAAKA;QAAKC,WAAWJ,QAAQ;YAAEI;QAAU;kBACzDC;;AAGP,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/navigation/NavItemButton.tsx"],"sourcesContent":["\"use client\";\nimport { forwardRef, type MouseEventHandler, type ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"../button/Button.js\";\nimport { cssUtils } from \"../cssUtils.js\";\nimport { IconRotator, type IconRotatorBaseProps } from \"../icon/IconRotator.js\";\nimport { getIcon } from \"../icon/iconConfig.js\";\nimport { Tooltip } from \"../tooltip/Tooltip.js\";\nimport { useTooltip } from \"../tooltip/useTooltip.js\";\nimport { navItemContent } from \"./navItemStyles.js\";\nimport { type NavItemContentProps } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface NavItemButtonRotatorProps {\n /** @defaultValue `getIcon(\"dropdown\")` */\n icon?: ReactNode;\n iconRotatorProps?: IconRotatorBaseProps;\n disableIconRotator?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface NavItemButtonProps\n extends Omit<ButtonProps, \"children\">,\n NavItemButtonRotatorProps,\n NavItemContentProps {\n onClick: MouseEventHandler<HTMLButtonElement>;\n collapsed: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @since 6.0.0\n */\nexport const NavItemButton = forwardRef<HTMLButtonElement, NavItemButtonProps>(\n function NavItemButton(props, ref) {\n const {\n className,\n collapsed,\n icon,\n iconRotatorProps,\n disableIconRotator,\n children,\n beforeAddon,\n afterAddon,\n spanProps,\n onBlur,\n onContextMenu,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchEnd,\n onTouchStart,\n tooltipOptions,\n ...remaining\n } = props;\n\n const { elementProps, tooltipProps, overflowRef } = useTooltip({\n overflowOnly: true,\n defaultPosition: \"right\",\n ...tooltipOptions,\n onBlur,\n onContextMenu,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchEnd,\n onTouchStart,\n });\n\n return (\n <>\n <Button\n {...remaining}\n {...elementProps}\n ref={ref}\n className={navItemContent({ className })}\n >\n {beforeAddon}\n <span\n {...spanProps}\n ref={overflowRef}\n className={cssUtils({\n className: spanProps?.className,\n textOverflow: \"ellipsis\",\n })}\n >\n {children}\n </span>\n {afterAddon}\n {!disableIconRotator && (\n <IconRotator {...iconRotatorProps} rotated={!collapsed}>\n {getIcon(\"dropdown\", icon)}\n </IconRotator>\n )}\n </Button>\n <Tooltip {...tooltipProps}>{children}</Tooltip>\n </>\n );\n }\n);\n"],"names":["forwardRef","Button","cssUtils","IconRotator","getIcon","Tooltip","useTooltip","navItemContent","NavItemButton","props","ref","className","collapsed","icon","iconRotatorProps","disableIconRotator","children","beforeAddon","afterAddon","spanProps","onBlur","onContextMenu","onFocus","onMouseEnter","onMouseLeave","onTouchEnd","onTouchStart","tooltipOptions","remaining","elementProps","tooltipProps","overflowRef","overflowOnly","defaultPosition","span","textOverflow","rotated"],"
|
|
1
|
+
{"version":3,"sources":["../../src/navigation/NavItemButton.tsx"],"sourcesContent":["\"use client\";\nimport { forwardRef, type MouseEventHandler, type ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"../button/Button.js\";\nimport { cssUtils } from \"../cssUtils.js\";\nimport { IconRotator, type IconRotatorBaseProps } from \"../icon/IconRotator.js\";\nimport { getIcon } from \"../icon/iconConfig.js\";\nimport { Tooltip } from \"../tooltip/Tooltip.js\";\nimport { useTooltip } from \"../tooltip/useTooltip.js\";\nimport { navItemContent } from \"./navItemStyles.js\";\nimport { type NavItemContentProps } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface NavItemButtonRotatorProps {\n /** @defaultValue `getIcon(\"dropdown\")` */\n icon?: ReactNode;\n iconRotatorProps?: IconRotatorBaseProps;\n disableIconRotator?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface NavItemButtonProps\n extends Omit<ButtonProps, \"children\">,\n NavItemButtonRotatorProps,\n NavItemContentProps {\n onClick: MouseEventHandler<HTMLButtonElement>;\n collapsed: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @since 6.0.0\n */\nexport const NavItemButton = forwardRef<HTMLButtonElement, NavItemButtonProps>(\n function NavItemButton(props, ref) {\n const {\n className,\n collapsed,\n icon,\n iconRotatorProps,\n disableIconRotator,\n children,\n beforeAddon,\n afterAddon,\n spanProps,\n onBlur,\n onContextMenu,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchEnd,\n onTouchStart,\n tooltipOptions,\n ...remaining\n } = props;\n\n const { elementProps, tooltipProps, overflowRef } = useTooltip({\n overflowOnly: true,\n defaultPosition: \"right\",\n ...tooltipOptions,\n onBlur,\n onContextMenu,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchEnd,\n onTouchStart,\n });\n\n return (\n <>\n <Button\n {...remaining}\n {...elementProps}\n ref={ref}\n className={navItemContent({ className })}\n >\n {beforeAddon}\n <span\n {...spanProps}\n ref={overflowRef}\n className={cssUtils({\n className: spanProps?.className,\n textOverflow: \"ellipsis\",\n })}\n >\n {children}\n </span>\n {afterAddon}\n {!disableIconRotator && (\n <IconRotator {...iconRotatorProps} rotated={!collapsed}>\n {getIcon(\"dropdown\", icon)}\n </IconRotator>\n )}\n </Button>\n <Tooltip {...tooltipProps}>{children}</Tooltip>\n </>\n );\n }\n);\n"],"names":["forwardRef","Button","cssUtils","IconRotator","getIcon","Tooltip","useTooltip","navItemContent","NavItemButton","props","ref","className","collapsed","icon","iconRotatorProps","disableIconRotator","children","beforeAddon","afterAddon","spanProps","onBlur","onContextMenu","onFocus","onMouseEnter","onMouseLeave","onTouchEnd","onTouchStart","tooltipOptions","remaining","elementProps","tooltipProps","overflowRef","overflowOnly","defaultPosition","span","textOverflow","rotated"],"mappings":"AAAA;;AACA,SAASA,UAAU,QAAgD,QAAQ;AAC3E,SAASC,MAAM,QAA0B,sBAAsB;AAC/D,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,WAAW,QAAmC,yBAAyB;AAChF,SAASC,OAAO,QAAQ,wBAAwB;AAChD,SAASC,OAAO,QAAQ,wBAAwB;AAChD,SAASC,UAAU,QAAQ,2BAA2B;AACtD,SAASC,cAAc,QAAQ,qBAAqB;AAwBpD;;;;CAIC,GACD,OAAO,MAAMC,8BAAgBR,WAC3B,SAASQ,cAAcC,KAAK,EAAEC,GAAG;IAC/B,MAAM,EACJC,SAAS,EACTC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,kBAAkB,EAClBC,QAAQ,EACRC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,aAAa,EACbC,OAAO,EACPC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,YAAY,EACZC,cAAc,EACd,GAAGC,WACJ,GAAGnB;IAEJ,MAAM,EAAEoB,YAAY,EAAEC,YAAY,EAAEC,WAAW,EAAE,GAAGzB,WAAW;QAC7D0B,cAAc;QACdC,iBAAiB;QACjB,GAAGN,cAAc;QACjBP;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,qBACE;;0BACE,MAACzB;gBACE,GAAG2B,SAAS;gBACZ,GAAGC,YAAY;gBAChBnB,KAAKA;gBACLC,WAAWJ,eAAe;oBAAEI;gBAAU;;oBAErCM;kCACD,KAACiB;wBACE,GAAGf,SAAS;wBACbT,KAAKqB;wBACLpB,WAAWT,SAAS;4BAClBS,WAAWQ,WAAWR;4BACtBwB,cAAc;wBAChB;kCAECnB;;oBAEFE;oBACA,CAACH,oCACA,KAACZ;wBAAa,GAAGW,gBAAgB;wBAAEsB,SAAS,CAACxB;kCAC1CR,QAAQ,YAAYS;;;;0BAI3B,KAACR;gBAAS,GAAGyB,YAAY;0BAAGd;;;;AAGlC,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/navigation/NavItemLink.tsx"],"sourcesContent":["\"use client\";\nimport {\n forwardRef,\n useEffect,\n type AnchorHTMLAttributes,\n type LiHTMLAttributes,\n} from \"react\";\nimport { cssUtils } from \"../cssUtils.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { Tooltip } from \"../tooltip/Tooltip.js\";\nimport { useTooltip } from \"../tooltip/useTooltip.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { NavItem } from \"./NavItem.js\";\nimport { navItemLink } from \"./navItemStyles.js\";\nimport {\n type NavItemContentProps,\n type NavigationLinkComponent,\n} from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface NavItemLinkProps\n extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, \"children\">,\n NavItemContentProps {\n /** @defaultValue `\"a\"` */\n as?: NavigationLinkComponent;\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<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;\n\n /**\n * Set this to `true` if the link matches the current `pathname`. This will\n * enable `aria-current=\"true\"` and apply active styling.\n */\n active: boolean;\n\n /** @defaultValue `cssUtils({ fontWeight: \"bold\" })` */\n activeClassName?: string;\n\n /** @defaultValue `!to && !href` */\n disabled?: boolean;\n\n /**\n * Set this to `true` to prevent this item from scrolling into view when it\n * becomes active. It is generally recommended to keep this `true` unless a\n * custom implementation has been added so that when the temporary navigation\n * will show the active route.\n *\n * @defaultValue `false`\n */\n disableScrollIntoView?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @since 6.0.0\n */\nexport const NavItemLink = forwardRef<HTMLAnchorElement, NavItemLinkProps>(\n function NavItemLink(props, propRef) {\n const {\n as: Component = \"a\",\n href,\n active,\n activeClassName,\n beforeAddon,\n afterAddon,\n className,\n children,\n liProps,\n spanProps,\n disabled = !href,\n onClick,\n onBlur,\n onDragStart,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseLeave,\n onMouseUp,\n onTouchMove,\n onTouchEnd,\n onTouchStart,\n tooltipOptions,\n disableScrollIntoView,\n ...remaining\n } = props;\n\n const [linkRef, linkRefCallback] = useEnsuredRef(propRef);\n const { handlers, ripples } = useElementInteraction({\n disabled,\n onClick,\n onBlur,\n onDragStart,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseLeave,\n onMouseUp,\n onTouchMove,\n onTouchEnd,\n onTouchStart,\n });\n\n const { elementProps, tooltipProps, overflowRef } = useTooltip({\n overflowOnly: true,\n defaultPosition: \"right\",\n ...tooltipOptions,\n ...handlers,\n });\n useEffect(() => {\n const link = linkRef.current;\n if (\n !active ||\n !link ||\n disableScrollIntoView ||\n document.activeElement === link\n ) {\n return;\n }\n\n link.scrollIntoView({ block: \"center\" });\n }, [active, disableScrollIntoView, linkRef]);\n\n return (\n <NavItem {...liProps}>\n <Component\n {...remaining}\n {...handlers}\n {...elementProps}\n ref={linkRefCallback}\n href={href}\n className={navItemLink({\n active,\n activeClassName,\n className,\n })}\n >\n {beforeAddon}\n <span\n {...spanProps}\n ref={overflowRef}\n className={cssUtils({\n className: spanProps?.className,\n textOverflow: \"ellipsis\",\n })}\n >\n {children}\n </span>\n {afterAddon}\n {ripples}\n </Component>\n <Tooltip {...tooltipProps}>{children}</Tooltip>\n </NavItem>\n );\n }\n);\n"],"names":["forwardRef","useEffect","cssUtils","useElementInteraction","Tooltip","useTooltip","useEnsuredRef","NavItem","navItemLink","NavItemLink","props","propRef","as","Component","href","active","activeClassName","beforeAddon","afterAddon","className","children","liProps","spanProps","disabled","onClick","onBlur","onDragStart","onKeyDown","onKeyUp","onMouseDown","onMouseLeave","onMouseUp","onTouchMove","onTouchEnd","onTouchStart","tooltipOptions","disableScrollIntoView","remaining","linkRef","linkRefCallback","handlers","ripples","elementProps","tooltipProps","overflowRef","overflowOnly","defaultPosition","link","current","document","activeElement","scrollIntoView","block","ref","span","textOverflow"],"
|
|
1
|
+
{"version":3,"sources":["../../src/navigation/NavItemLink.tsx"],"sourcesContent":["\"use client\";\nimport {\n forwardRef,\n useEffect,\n type AnchorHTMLAttributes,\n type LiHTMLAttributes,\n} from \"react\";\nimport { cssUtils } from \"../cssUtils.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { Tooltip } from \"../tooltip/Tooltip.js\";\nimport { useTooltip } from \"../tooltip/useTooltip.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredRef } from \"../useEnsuredRef.js\";\nimport { NavItem } from \"./NavItem.js\";\nimport { navItemLink } from \"./navItemStyles.js\";\nimport {\n type NavItemContentProps,\n type NavigationLinkComponent,\n} from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface NavItemLinkProps\n extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, \"children\">,\n NavItemContentProps {\n /** @defaultValue `\"a\"` */\n as?: NavigationLinkComponent;\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<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;\n\n /**\n * Set this to `true` if the link matches the current `pathname`. This will\n * enable `aria-current=\"true\"` and apply active styling.\n */\n active: boolean;\n\n /** @defaultValue `cssUtils({ fontWeight: \"bold\" })` */\n activeClassName?: string;\n\n /** @defaultValue `!to && !href` */\n disabled?: boolean;\n\n /**\n * Set this to `true` to prevent this item from scrolling into view when it\n * becomes active. It is generally recommended to keep this `true` unless a\n * custom implementation has been added so that when the temporary navigation\n * will show the active route.\n *\n * @defaultValue `false`\n */\n disableScrollIntoView?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @since 6.0.0\n */\nexport const NavItemLink = forwardRef<HTMLAnchorElement, NavItemLinkProps>(\n function NavItemLink(props, propRef) {\n const {\n as: Component = \"a\",\n href,\n active,\n activeClassName,\n beforeAddon,\n afterAddon,\n className,\n children,\n liProps,\n spanProps,\n disabled = !href,\n onClick,\n onBlur,\n onDragStart,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseLeave,\n onMouseUp,\n onTouchMove,\n onTouchEnd,\n onTouchStart,\n tooltipOptions,\n disableScrollIntoView,\n ...remaining\n } = props;\n\n const [linkRef, linkRefCallback] = useEnsuredRef(propRef);\n const { handlers, ripples } = useElementInteraction({\n disabled,\n onClick,\n onBlur,\n onDragStart,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseLeave,\n onMouseUp,\n onTouchMove,\n onTouchEnd,\n onTouchStart,\n });\n\n const { elementProps, tooltipProps, overflowRef } = useTooltip({\n overflowOnly: true,\n defaultPosition: \"right\",\n ...tooltipOptions,\n ...handlers,\n });\n useEffect(() => {\n const link = linkRef.current;\n if (\n !active ||\n !link ||\n disableScrollIntoView ||\n document.activeElement === link\n ) {\n return;\n }\n\n link.scrollIntoView({ block: \"center\" });\n }, [active, disableScrollIntoView, linkRef]);\n\n return (\n <NavItem {...liProps}>\n <Component\n {...remaining}\n {...handlers}\n {...elementProps}\n ref={linkRefCallback}\n href={href}\n className={navItemLink({\n active,\n activeClassName,\n className,\n })}\n >\n {beforeAddon}\n <span\n {...spanProps}\n ref={overflowRef}\n className={cssUtils({\n className: spanProps?.className,\n textOverflow: \"ellipsis\",\n })}\n >\n {children}\n </span>\n {afterAddon}\n {ripples}\n </Component>\n <Tooltip {...tooltipProps}>{children}</Tooltip>\n </NavItem>\n );\n }\n);\n"],"names":["forwardRef","useEffect","cssUtils","useElementInteraction","Tooltip","useTooltip","useEnsuredRef","NavItem","navItemLink","NavItemLink","props","propRef","as","Component","href","active","activeClassName","beforeAddon","afterAddon","className","children","liProps","spanProps","disabled","onClick","onBlur","onDragStart","onKeyDown","onKeyUp","onMouseDown","onMouseLeave","onMouseUp","onTouchMove","onTouchEnd","onTouchStart","tooltipOptions","disableScrollIntoView","remaining","linkRef","linkRefCallback","handlers","ripples","elementProps","tooltipProps","overflowRef","overflowOnly","defaultPosition","link","current","document","activeElement","scrollIntoView","block","ref","span","textOverflow"],"mappings":"AAAA;;AACA,SACEA,UAAU,EACVC,SAAS,QAGJ,QAAQ;AACf,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,qBAAqB,QAAQ,0CAA0C;AAChF,SAASC,OAAO,QAAQ,wBAAwB;AAChD,SAASC,UAAU,QAAQ,2BAA2B;AAEtD,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,WAAW,QAAQ,qBAAqB;AA6CjD;;;;CAIC,GACD,OAAO,MAAMC,4BAAcT,WACzB,SAASS,YAAYC,KAAK,EAAEC,OAAO;IACjC,MAAM,EACJC,IAAIC,YAAY,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BACAuB;;;0BAEH,KAACrC;gBAAS,GAAGuC,YAAY;0BAAGvB;;;;AAGlC,GACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/navigation/NavSubheader.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport {\n ListSubheader,\n type ListSubheaderProps,\n} from \"../list/ListSubheader.js\";\nimport { navItem } from \"./navItemStyles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface NavSubheaderProps extends ListSubheaderProps {}\n\n/**\n * **Server Component**\n *\n * A simple wrapper around the {@Link ListSubheader} that updates the padding\n * based on the current navigation item depth to match the other items.\n *\n * @since 6.0.0\n */\nexport const NavSubheader = forwardRef<HTMLLIElement, NavSubheaderProps>(\n function NavSubheader(props, ref) {\n const { textProps, ...remaining } = props;\n\n return (\n <ListSubheader\n {...remaining}\n ref={ref}\n textProps={{\n ...textProps,\n className: navItem({ className: textProps?.className }),\n }}\n />\n );\n }\n);\n"],"names":["forwardRef","ListSubheader","navItem","NavSubheader","props","ref","textProps","remaining","className"],"
|
|
1
|
+
{"version":3,"sources":["../../src/navigation/NavSubheader.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport {\n ListSubheader,\n type ListSubheaderProps,\n} from \"../list/ListSubheader.js\";\nimport { navItem } from \"./navItemStyles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface NavSubheaderProps extends ListSubheaderProps {}\n\n/**\n * **Server Component**\n *\n * A simple wrapper around the {@Link ListSubheader} that updates the padding\n * based on the current navigation item depth to match the other items.\n *\n * @since 6.0.0\n */\nexport const NavSubheader = forwardRef<HTMLLIElement, NavSubheaderProps>(\n function NavSubheader(props, ref) {\n const { textProps, ...remaining } = props;\n\n return (\n <ListSubheader\n {...remaining}\n ref={ref}\n textProps={{\n ...textProps,\n className: navItem({ className: textProps?.className }),\n }}\n />\n );\n }\n);\n"],"names":["forwardRef","ListSubheader","navItem","NavSubheader","props","ref","textProps","remaining","className"],"mappings":";AAAA,SAASA,UAAU,QAAQ,QAAQ;AACnC,SACEC,aAAa,QAER,2BAA2B;AAClC,SAASC,OAAO,QAAQ,qBAAqB;AAO7C;;;;;;;CAOC,GACD,OAAO,MAAMC,6BAAeH,WAC1B,SAASG,aAAaC,KAAK,EAAEC,GAAG;IAC9B,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAW,GAAGH;IAEpC,qBACE,KAACH;QACE,GAAGM,SAAS;QACbF,KAAKA;QACLC,WAAW;YACT,GAAGA,SAAS;YACZE,WAAWN,QAAQ;gBAAEM,WAAWF,WAAWE;YAAU;QACvD;;AAGN,GACA"}
|