@salt-ds/core 1.47.5 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/css/salt-core.css +178 -4
- package/dist-cjs/accordion/Accordion.js.map +1 -1
- package/dist-cjs/accordion/AccordionContext.js.map +1 -1
- package/dist-cjs/accordion/AccordionGroup.js.map +1 -1
- package/dist-cjs/accordion/AccordionHeader.js.map +1 -1
- package/dist-cjs/accordion/AccordionPanel.js.map +1 -1
- package/dist-cjs/aria-announcer/AriaAnnounce.js.map +1 -1
- package/dist-cjs/aria-announcer/AriaAnnouncerContext.js.map +1 -1
- package/dist-cjs/aria-announcer/AriaAnnouncerProvider.js.map +1 -1
- package/dist-cjs/aria-announcer/useAriaAnnouncer.js.map +1 -1
- package/dist-cjs/avatar/Avatar.js.map +1 -1
- package/dist-cjs/avatar/useAvatarImage.js +46 -18
- package/dist-cjs/avatar/useAvatarImage.js.map +1 -1
- package/dist-cjs/avatar/useIsHydrated.js +18 -0
- package/dist-cjs/avatar/useIsHydrated.js.map +1 -0
- package/dist-cjs/badge/Badge.js.map +1 -1
- package/dist-cjs/banner/Banner.css.js +1 -1
- package/dist-cjs/banner/Banner.js.map +1 -1
- package/dist-cjs/banner/BannerActions.js.map +1 -1
- package/dist-cjs/banner/BannerContent.js.map +1 -1
- package/dist-cjs/border-item/BorderItem.js.map +1 -1
- package/dist-cjs/border-layout/BorderLayout.js.map +1 -1
- package/dist-cjs/breakpoints/BreakpointProvider.js.map +1 -1
- package/dist-cjs/breakpoints/Breakpoints.js.map +1 -1
- package/dist-cjs/button/Button.js.map +1 -1
- package/dist-cjs/button/useButton.js.map +1 -1
- package/dist-cjs/card/Card.js.map +1 -1
- package/dist-cjs/checkbox/Checkbox.css.js +1 -1
- package/dist-cjs/checkbox/Checkbox.js.map +1 -1
- package/dist-cjs/checkbox/CheckboxGroup.js.map +1 -1
- package/dist-cjs/checkbox/CheckboxIcon.js.map +1 -1
- package/dist-cjs/checkbox/internal/CheckboxGroupContext.js.map +1 -1
- package/dist-cjs/checkbox/internal/useCheckboxGroup.js.map +1 -1
- package/dist-cjs/collapsible/Collapsible.js +52 -0
- package/dist-cjs/collapsible/Collapsible.js.map +1 -0
- package/dist-cjs/collapsible/CollapsibleContext.js +29 -0
- package/dist-cjs/collapsible/CollapsibleContext.js.map +1 -0
- package/dist-cjs/collapsible/CollapsiblePanel.css.js +6 -0
- package/dist-cjs/collapsible/CollapsiblePanel.css.js.map +1 -0
- package/dist-cjs/collapsible/CollapsiblePanel.js +47 -0
- package/dist-cjs/collapsible/CollapsiblePanel.js.map +1 -0
- package/dist-cjs/collapsible/CollapsibleTrigger.js +40 -0
- package/dist-cjs/collapsible/CollapsibleTrigger.js.map +1 -0
- package/dist-cjs/combo-box/ComboBox.js.map +1 -1
- package/dist-cjs/combo-box/useComboBox.js.map +1 -1
- package/dist-cjs/dialog/Dialog.js.map +1 -1
- package/dist-cjs/dialog/DialogActions.js.map +1 -1
- package/dist-cjs/dialog/DialogCloseButton.js.map +1 -1
- package/dist-cjs/dialog/DialogContent.css.js +1 -1
- package/dist-cjs/dialog/DialogContent.js.map +1 -1
- package/dist-cjs/dialog/DialogContext.js.map +1 -1
- package/dist-cjs/dialog/DialogHeader.js.map +1 -1
- package/dist-cjs/divider/Divider.js.map +1 -1
- package/dist-cjs/drawer/Drawer.js.map +1 -1
- package/dist-cjs/drawer/DrawerCloseButton.js.map +1 -1
- package/dist-cjs/dropdown/Dropdown.js.map +1 -1
- package/dist-cjs/file-drop-zone/FileDropZone.css.js +1 -1
- package/dist-cjs/file-drop-zone/FileDropZone.js.map +1 -1
- package/dist-cjs/file-drop-zone/FileDropZoneIcon.js.map +1 -1
- package/dist-cjs/file-drop-zone/FileDropZoneTrigger.js +1 -1
- package/dist-cjs/file-drop-zone/FileDropZoneTrigger.js.map +1 -1
- package/dist-cjs/file-drop-zone/internal/utils.js.map +1 -1
- package/dist-cjs/flex-item/FlexItem.js.map +1 -1
- package/dist-cjs/flex-layout/FlexLayout.js.map +1 -1
- package/dist-cjs/flex-layout/parseSpacing.js.map +1 -1
- package/dist-cjs/flow-layout/FlowLayout.js.map +1 -1
- package/dist-cjs/form-field/FormField.js.map +1 -1
- package/dist-cjs/form-field/FormFieldHelperText.js.map +1 -1
- package/dist-cjs/form-field/FormFieldLabel.css.js +1 -1
- package/dist-cjs/form-field/FormFieldLabel.js.map +1 -1
- package/dist-cjs/form-field-context/FormFieldContext.js.map +1 -1
- package/dist-cjs/form-field-context/useFormFieldProps.js.map +1 -1
- package/dist-cjs/grid-item/GridItem.js.map +1 -1
- package/dist-cjs/grid-layout/GridLayout.js.map +1 -1
- package/dist-cjs/index.js +21 -0
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/input/Input.js.map +1 -1
- package/dist-cjs/interactable-card/InteractableCard.js.map +1 -1
- package/dist-cjs/interactable-card/InteractableCardGroup.js.map +1 -1
- package/dist-cjs/interactable-card/InteractableCardGroupContext.js.map +1 -1
- package/dist-cjs/interactable-card/useInteractableCard.js.map +1 -1
- package/dist-cjs/link/Link.js.map +1 -1
- package/dist-cjs/link/LinkAction.js.map +1 -1
- package/dist-cjs/link-card/LinkCard.js.map +1 -1
- package/dist-cjs/list-box/ListBox.js.map +1 -1
- package/dist-cjs/list-control/ListControlContext.js.map +1 -1
- package/dist-cjs/list-control/ListControlState.js.map +1 -1
- package/dist-cjs/menu/Menu.js.map +1 -1
- package/dist-cjs/menu/MenuBase.js.map +1 -1
- package/dist-cjs/menu/MenuContext.js.map +1 -1
- package/dist-cjs/menu/MenuGroup.js.map +1 -1
- package/dist-cjs/menu/MenuItem.js.map +1 -1
- package/dist-cjs/menu/MenuPanel.js.map +1 -1
- package/dist-cjs/menu/MenuPanelBase.js.map +1 -1
- package/dist-cjs/menu/MenuPanelContext.js.map +1 -1
- package/dist-cjs/menu/MenuTrigger.js.map +1 -1
- package/dist-cjs/menu/MenuTriggerContext.js.map +1 -1
- package/dist-cjs/multiline-input/MultilineInput.js.map +1 -1
- package/dist-cjs/navigation-item/ExpansionIcon.js.map +1 -1
- package/dist-cjs/navigation-item/NavigationItem.js.map +1 -1
- package/dist-cjs/navigation-item/NavigationItemAction.js.map +1 -1
- package/dist-cjs/option/Option.js.map +1 -1
- package/dist-cjs/option/OptionGroup.js.map +1 -1
- package/dist-cjs/option/OptionList.js.map +1 -1
- package/dist-cjs/option/OptionListBase.js.map +1 -1
- package/dist-cjs/overlay/Overlay.js.map +1 -1
- package/dist-cjs/overlay/OverlayContext.js.map +1 -1
- package/dist-cjs/overlay/OverlayHeader.js.map +1 -1
- package/dist-cjs/overlay/OverlayPanel.js.map +1 -1
- package/dist-cjs/overlay/OverlayPanelCloseButton.js.map +1 -1
- package/dist-cjs/overlay/OverlayPanelContent.js.map +1 -1
- package/dist-cjs/overlay/OverlayTrigger.js.map +1 -1
- package/dist-cjs/pagination/CompactInput.js.map +1 -1
- package/dist-cjs/pagination/CompactPaginator.js.map +1 -1
- package/dist-cjs/pagination/GoToInput.js.map +1 -1
- package/dist-cjs/pagination/PageButton.js.map +1 -1
- package/dist-cjs/pagination/PageRanges.js.map +1 -1
- package/dist-cjs/pagination/Pagination.js.map +1 -1
- package/dist-cjs/pagination/PaginationContext.js.map +1 -1
- package/dist-cjs/pagination/Paginator.js.map +1 -1
- package/dist-cjs/pagination/usePagination.js.map +1 -1
- package/dist-cjs/pagination/usePaginationContext.js.map +1 -1
- package/dist-cjs/panel/Panel.js.map +1 -1
- package/dist-cjs/parent-child-layout/ParentChildLayout.js.map +1 -1
- package/dist-cjs/parent-child-layout/useIsViewportLargerThanBreakpoint.js.map +1 -1
- package/dist-cjs/pill/Pill.js.map +1 -1
- package/dist-cjs/pill-input/PillInput.js.map +1 -1
- package/dist-cjs/pill-input/useTruncatePills.js.map +1 -1
- package/dist-cjs/progress/CircularProgress/CircularProgress.js.map +1 -1
- package/dist-cjs/progress/LinearProgress/LinearProgress.js.map +1 -1
- package/dist-cjs/radio-button/RadioButton.css.js +1 -1
- package/dist-cjs/radio-button/RadioButton.js.map +1 -1
- package/dist-cjs/radio-button/RadioButtonGroup.js.map +1 -1
- package/dist-cjs/radio-button/RadioButtonIcon.js.map +1 -1
- package/dist-cjs/radio-button/internal/RadioGroupContext.js.map +1 -1
- package/dist-cjs/radio-button/internal/useRadioGroup.js.map +1 -1
- package/dist-cjs/salt-provider/SaltProvider.js.map +1 -1
- package/dist-cjs/scrim/Scrim.js.map +1 -1
- package/dist-cjs/segmented-button-group/SegmentedButtonGroup.js.map +1 -1
- package/dist-cjs/semantic-icon-provider/SemanticIconProvider.js.map +1 -1
- package/dist-cjs/skip-link/SkipLink.js.map +1 -1
- package/dist-cjs/skip-link/internal/useManageFocusOnTarget.js.map +1 -1
- package/dist-cjs/slider/RangeSlider.js.map +1 -1
- package/dist-cjs/slider/Slider.js.map +1 -1
- package/dist-cjs/slider/internal/SliderThumb.js.map +1 -1
- package/dist-cjs/slider/internal/SliderTooltip.js.map +1 -1
- package/dist-cjs/slider/internal/SliderTrack.js.map +1 -1
- package/dist-cjs/slider/internal/useRangeSliderThumb.js.map +1 -1
- package/dist-cjs/slider/internal/useSliderThumb.js.map +1 -1
- package/dist-cjs/slider/internal/utils.js.map +1 -1
- package/dist-cjs/spinner/Spinner.js.map +1 -1
- package/dist-cjs/spinner/svgSpinners/SpinnerSVG.js.map +1 -1
- package/dist-cjs/split-layout/SplitLayout.js.map +1 -1
- package/dist-cjs/stack-layout/StackLayout.js.map +1 -1
- package/dist-cjs/status-adornment/ErrorAdornment.js.map +1 -1
- package/dist-cjs/status-adornment/StatusAdornment.js.map +1 -1
- package/dist-cjs/status-adornment/SuccessAdornment.js.map +1 -1
- package/dist-cjs/status-adornment/WarningAdornment.js.map +1 -1
- package/dist-cjs/status-indicator/StatusIndicator.js.map +1 -1
- package/dist-cjs/status-indicator/ValidationStatus.js.map +1 -1
- package/dist-cjs/stepper/Step.js.map +1 -1
- package/dist-cjs/stepper/Stepper.js.map +1 -1
- package/dist-cjs/stepper/internal/StepConnector.js.map +1 -1
- package/dist-cjs/stepper/internal/StepExpandTrigger.js.map +1 -1
- package/dist-cjs/stepper/internal/StepIcon.js.map +1 -1
- package/dist-cjs/stepper/internal/StepScreenReaderOnly.js.map +1 -1
- package/dist-cjs/stepper/internal/StepText.js.map +1 -1
- package/dist-cjs/stepper/internal/StepperProvider.js.map +1 -1
- package/dist-cjs/switch/Switch.css.js +1 -1
- package/dist-cjs/switch/Switch.js.map +1 -1
- package/dist-cjs/tag/Tag.js.map +1 -1
- package/dist-cjs/text/Code.js.map +1 -1
- package/dist-cjs/text/Display.js.map +1 -1
- package/dist-cjs/text/Headings.js.map +1 -1
- package/dist-cjs/text/Label.js.map +1 -1
- package/dist-cjs/text/Text.js.map +1 -1
- package/dist-cjs/text/TextAction.js.map +1 -1
- package/dist-cjs/text/TextNotation.js.map +1 -1
- package/dist-cjs/theme/Accent.js.map +1 -1
- package/dist-cjs/theme/ActionFont.js.map +1 -1
- package/dist-cjs/theme/Corner.js.map +1 -1
- package/dist-cjs/theme/Density.js.map +1 -1
- package/dist-cjs/theme/HeadingFont.js.map +1 -1
- package/dist-cjs/theme/Mode.js.map +1 -1
- package/dist-cjs/theme/Theme.js.map +1 -1
- package/dist-cjs/toast/Toast.js.map +1 -1
- package/dist-cjs/toast/ToastContent.js.map +1 -1
- package/dist-cjs/toggle-button/ToggleButton.js.map +1 -1
- package/dist-cjs/toggle-button-group/ToggleButtonGroup.js.map +1 -1
- package/dist-cjs/toggle-button-group/ToggleButtonGroupContext.js.map +1 -1
- package/dist-cjs/tooltip/Tooltip.js.map +1 -1
- package/dist-cjs/tooltip/TooltipBase.js.map +1 -1
- package/dist-cjs/tooltip/useAriaAnnounce.js.map +1 -1
- package/dist-cjs/tooltip/useTooltip.js.map +1 -1
- package/dist-cjs/utils/capitalize.js.map +1 -1
- package/dist-cjs/utils/createChainedFunction.js.map +1 -1
- package/dist-cjs/utils/createContext.js.map +1 -1
- package/dist-cjs/utils/debounce.js.map +1 -1
- package/dist-cjs/utils/getRefFromChildren.js.map +1 -1
- package/dist-cjs/utils/makePrefixer.js.map +1 -1
- package/dist-cjs/utils/marginMiddleware.js.map +1 -1
- package/dist-cjs/utils/mergeProps.js.map +1 -1
- package/dist-cjs/utils/ownerDocument.js.map +1 -1
- package/dist-cjs/utils/ownerWindow.js.map +1 -1
- package/dist-cjs/utils/renderProps.js.map +1 -1
- package/dist-cjs/utils/setRef.js.map +1 -1
- package/dist-cjs/utils/useControlled.js.map +1 -1
- package/dist-cjs/utils/useEventCallback.js.map +1 -1
- package/dist-cjs/utils/useFloatingUI/useFloatingUI.js.map +1 -1
- package/dist-cjs/utils/useForkRef.js.map +1 -1
- package/dist-cjs/utils/useId.js.map +1 -1
- package/dist-cjs/utils/useIsFocusVisible.js.map +1 -1
- package/dist-cjs/utils/useIsomorphicLayoutEffect.js.map +1 -1
- package/dist-cjs/utils/usePreventScroll.js.map +1 -1
- package/dist-cjs/utils/usePrevious.js.map +1 -1
- package/dist-cjs/utils/useResizeObserver.js.map +1 -1
- package/dist-cjs/utils/useResponsiveProp.js.map +1 -1
- package/dist-cjs/utils/useValueEffect.js.map +1 -1
- package/dist-cjs/vertical-navigation/SubMenuContext.js +39 -0
- package/dist-cjs/vertical-navigation/SubMenuContext.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigation.css.js +6 -0
- package/dist-cjs/vertical-navigation/VerticalNavigation.css.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigation.js +38 -0
- package/dist-cjs/vertical-navigation/VerticalNavigation.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItem.js +53 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItem.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemContent.css.js +6 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemContent.css.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemContent.js +88 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemContent.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemExpansionIcon.js +35 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemExpansionIcon.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemLabel.css.js +6 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemLabel.css.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemLabel.js +28 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemLabel.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemTrigger.css.js +6 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemTrigger.css.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemTrigger.js +74 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationItemTrigger.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationSubMenu.css.js +6 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationSubMenu.css.js.map +1 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationSubMenu.js +39 -0
- package/dist-cjs/vertical-navigation/VerticalNavigationSubMenu.js.map +1 -0
- package/dist-cjs/viewport/ViewportProvider.js.map +1 -1
- package/dist-es/accordion/Accordion.js.map +1 -1
- package/dist-es/accordion/AccordionContext.js.map +1 -1
- package/dist-es/accordion/AccordionGroup.js.map +1 -1
- package/dist-es/accordion/AccordionHeader.js.map +1 -1
- package/dist-es/accordion/AccordionPanel.js.map +1 -1
- package/dist-es/aria-announcer/AriaAnnounce.js.map +1 -1
- package/dist-es/aria-announcer/AriaAnnouncerContext.js.map +1 -1
- package/dist-es/aria-announcer/AriaAnnouncerProvider.js.map +1 -1
- package/dist-es/aria-announcer/useAriaAnnouncer.js.map +1 -1
- package/dist-es/avatar/Avatar.js.map +1 -1
- package/dist-es/avatar/useAvatarImage.js +47 -19
- package/dist-es/avatar/useAvatarImage.js.map +1 -1
- package/dist-es/avatar/useIsHydrated.js +16 -0
- package/dist-es/avatar/useIsHydrated.js.map +1 -0
- package/dist-es/badge/Badge.js.map +1 -1
- package/dist-es/banner/Banner.css.js +1 -1
- package/dist-es/banner/Banner.js.map +1 -1
- package/dist-es/banner/BannerActions.js.map +1 -1
- package/dist-es/banner/BannerContent.js.map +1 -1
- package/dist-es/border-item/BorderItem.js.map +1 -1
- package/dist-es/border-layout/BorderLayout.js.map +1 -1
- package/dist-es/breakpoints/BreakpointProvider.js.map +1 -1
- package/dist-es/breakpoints/Breakpoints.js.map +1 -1
- package/dist-es/button/Button.js.map +1 -1
- package/dist-es/button/useButton.js.map +1 -1
- package/dist-es/card/Card.js.map +1 -1
- package/dist-es/checkbox/Checkbox.css.js +1 -1
- package/dist-es/checkbox/Checkbox.js.map +1 -1
- package/dist-es/checkbox/CheckboxGroup.js.map +1 -1
- package/dist-es/checkbox/CheckboxIcon.js.map +1 -1
- package/dist-es/checkbox/internal/CheckboxGroupContext.js.map +1 -1
- package/dist-es/checkbox/internal/useCheckboxGroup.js.map +1 -1
- package/dist-es/collapsible/Collapsible.js +50 -0
- package/dist-es/collapsible/Collapsible.js.map +1 -0
- package/dist-es/collapsible/CollapsibleContext.js +26 -0
- package/dist-es/collapsible/CollapsibleContext.js.map +1 -0
- package/dist-es/collapsible/CollapsiblePanel.css.js +4 -0
- package/dist-es/collapsible/CollapsiblePanel.css.js.map +1 -0
- package/dist-es/collapsible/CollapsiblePanel.js +45 -0
- package/dist-es/collapsible/CollapsiblePanel.js.map +1 -0
- package/dist-es/collapsible/CollapsibleTrigger.js +38 -0
- package/dist-es/collapsible/CollapsibleTrigger.js.map +1 -0
- package/dist-es/combo-box/ComboBox.js.map +1 -1
- package/dist-es/combo-box/useComboBox.js.map +1 -1
- package/dist-es/dialog/Dialog.js.map +1 -1
- package/dist-es/dialog/DialogActions.js.map +1 -1
- package/dist-es/dialog/DialogCloseButton.js.map +1 -1
- package/dist-es/dialog/DialogContent.css.js +1 -1
- package/dist-es/dialog/DialogContent.js.map +1 -1
- package/dist-es/dialog/DialogContext.js.map +1 -1
- package/dist-es/dialog/DialogHeader.js.map +1 -1
- package/dist-es/divider/Divider.js.map +1 -1
- package/dist-es/drawer/Drawer.js.map +1 -1
- package/dist-es/drawer/DrawerCloseButton.js.map +1 -1
- package/dist-es/dropdown/Dropdown.js.map +1 -1
- package/dist-es/file-drop-zone/FileDropZone.css.js +1 -1
- package/dist-es/file-drop-zone/FileDropZone.js.map +1 -1
- package/dist-es/file-drop-zone/FileDropZoneIcon.js.map +1 -1
- package/dist-es/file-drop-zone/FileDropZoneTrigger.js +1 -1
- package/dist-es/file-drop-zone/FileDropZoneTrigger.js.map +1 -1
- package/dist-es/file-drop-zone/internal/utils.js.map +1 -1
- package/dist-es/flex-item/FlexItem.js.map +1 -1
- package/dist-es/flex-layout/FlexLayout.js.map +1 -1
- package/dist-es/flex-layout/parseSpacing.js.map +1 -1
- package/dist-es/flow-layout/FlowLayout.js.map +1 -1
- package/dist-es/form-field/FormField.js.map +1 -1
- package/dist-es/form-field/FormFieldHelperText.js.map +1 -1
- package/dist-es/form-field/FormFieldLabel.css.js +1 -1
- package/dist-es/form-field/FormFieldLabel.js.map +1 -1
- package/dist-es/form-field-context/FormFieldContext.js.map +1 -1
- package/dist-es/form-field-context/useFormFieldProps.js.map +1 -1
- package/dist-es/grid-item/GridItem.js.map +1 -1
- package/dist-es/grid-layout/GridLayout.js.map +1 -1
- package/dist-es/index.js +10 -0
- package/dist-es/index.js.map +1 -1
- package/dist-es/input/Input.js.map +1 -1
- package/dist-es/interactable-card/InteractableCard.js.map +1 -1
- package/dist-es/interactable-card/InteractableCardGroup.js.map +1 -1
- package/dist-es/interactable-card/InteractableCardGroupContext.js.map +1 -1
- package/dist-es/interactable-card/useInteractableCard.js.map +1 -1
- package/dist-es/link/Link.js.map +1 -1
- package/dist-es/link/LinkAction.js.map +1 -1
- package/dist-es/link-card/LinkCard.js.map +1 -1
- package/dist-es/list-box/ListBox.js.map +1 -1
- package/dist-es/list-control/ListControlContext.js.map +1 -1
- package/dist-es/list-control/ListControlState.js.map +1 -1
- package/dist-es/menu/Menu.js.map +1 -1
- package/dist-es/menu/MenuBase.js.map +1 -1
- package/dist-es/menu/MenuContext.js.map +1 -1
- package/dist-es/menu/MenuGroup.js.map +1 -1
- package/dist-es/menu/MenuItem.js.map +1 -1
- package/dist-es/menu/MenuPanel.js.map +1 -1
- package/dist-es/menu/MenuPanelBase.js.map +1 -1
- package/dist-es/menu/MenuPanelContext.js.map +1 -1
- package/dist-es/menu/MenuTrigger.js.map +1 -1
- package/dist-es/menu/MenuTriggerContext.js.map +1 -1
- package/dist-es/multiline-input/MultilineInput.js.map +1 -1
- package/dist-es/navigation-item/ExpansionIcon.js.map +1 -1
- package/dist-es/navigation-item/NavigationItem.js.map +1 -1
- package/dist-es/navigation-item/NavigationItemAction.js.map +1 -1
- package/dist-es/option/Option.js.map +1 -1
- package/dist-es/option/OptionGroup.js.map +1 -1
- package/dist-es/option/OptionList.js.map +1 -1
- package/dist-es/option/OptionListBase.js.map +1 -1
- package/dist-es/overlay/Overlay.js.map +1 -1
- package/dist-es/overlay/OverlayContext.js.map +1 -1
- package/dist-es/overlay/OverlayHeader.js.map +1 -1
- package/dist-es/overlay/OverlayPanel.js.map +1 -1
- package/dist-es/overlay/OverlayPanelCloseButton.js.map +1 -1
- package/dist-es/overlay/OverlayPanelContent.js.map +1 -1
- package/dist-es/overlay/OverlayTrigger.js.map +1 -1
- package/dist-es/pagination/CompactInput.js.map +1 -1
- package/dist-es/pagination/CompactPaginator.js.map +1 -1
- package/dist-es/pagination/GoToInput.js.map +1 -1
- package/dist-es/pagination/PageButton.js.map +1 -1
- package/dist-es/pagination/PageRanges.js.map +1 -1
- package/dist-es/pagination/Pagination.js.map +1 -1
- package/dist-es/pagination/PaginationContext.js.map +1 -1
- package/dist-es/pagination/Paginator.js.map +1 -1
- package/dist-es/pagination/usePagination.js.map +1 -1
- package/dist-es/pagination/usePaginationContext.js.map +1 -1
- package/dist-es/panel/Panel.js.map +1 -1
- package/dist-es/parent-child-layout/ParentChildLayout.js.map +1 -1
- package/dist-es/parent-child-layout/useIsViewportLargerThanBreakpoint.js.map +1 -1
- package/dist-es/pill/Pill.js.map +1 -1
- package/dist-es/pill-input/PillInput.js.map +1 -1
- package/dist-es/pill-input/useTruncatePills.js.map +1 -1
- package/dist-es/progress/CircularProgress/CircularProgress.js.map +1 -1
- package/dist-es/progress/LinearProgress/LinearProgress.js.map +1 -1
- package/dist-es/radio-button/RadioButton.css.js +1 -1
- package/dist-es/radio-button/RadioButton.js.map +1 -1
- package/dist-es/radio-button/RadioButtonGroup.js.map +1 -1
- package/dist-es/radio-button/RadioButtonIcon.js.map +1 -1
- package/dist-es/radio-button/internal/RadioGroupContext.js.map +1 -1
- package/dist-es/radio-button/internal/useRadioGroup.js.map +1 -1
- package/dist-es/salt-provider/SaltProvider.js.map +1 -1
- package/dist-es/scrim/Scrim.js.map +1 -1
- package/dist-es/segmented-button-group/SegmentedButtonGroup.js.map +1 -1
- package/dist-es/semantic-icon-provider/SemanticIconProvider.js.map +1 -1
- package/dist-es/skip-link/SkipLink.js.map +1 -1
- package/dist-es/skip-link/internal/useManageFocusOnTarget.js.map +1 -1
- package/dist-es/slider/RangeSlider.js.map +1 -1
- package/dist-es/slider/Slider.js.map +1 -1
- package/dist-es/slider/internal/SliderThumb.js.map +1 -1
- package/dist-es/slider/internal/SliderTooltip.js.map +1 -1
- package/dist-es/slider/internal/SliderTrack.js.map +1 -1
- package/dist-es/slider/internal/useRangeSliderThumb.js.map +1 -1
- package/dist-es/slider/internal/useSliderThumb.js.map +1 -1
- package/dist-es/slider/internal/utils.js.map +1 -1
- package/dist-es/spinner/Spinner.js.map +1 -1
- package/dist-es/spinner/svgSpinners/SpinnerSVG.js.map +1 -1
- package/dist-es/split-layout/SplitLayout.js.map +1 -1
- package/dist-es/stack-layout/StackLayout.js.map +1 -1
- package/dist-es/status-adornment/ErrorAdornment.js.map +1 -1
- package/dist-es/status-adornment/StatusAdornment.js.map +1 -1
- package/dist-es/status-adornment/SuccessAdornment.js.map +1 -1
- package/dist-es/status-adornment/WarningAdornment.js.map +1 -1
- package/dist-es/status-indicator/StatusIndicator.js.map +1 -1
- package/dist-es/status-indicator/ValidationStatus.js.map +1 -1
- package/dist-es/stepper/Step.js.map +1 -1
- package/dist-es/stepper/Stepper.js.map +1 -1
- package/dist-es/stepper/internal/StepConnector.js.map +1 -1
- package/dist-es/stepper/internal/StepExpandTrigger.js.map +1 -1
- package/dist-es/stepper/internal/StepIcon.js.map +1 -1
- package/dist-es/stepper/internal/StepScreenReaderOnly.js.map +1 -1
- package/dist-es/stepper/internal/StepText.js.map +1 -1
- package/dist-es/stepper/internal/StepperProvider.js.map +1 -1
- package/dist-es/switch/Switch.css.js +1 -1
- package/dist-es/switch/Switch.js.map +1 -1
- package/dist-es/tag/Tag.js.map +1 -1
- package/dist-es/text/Code.js.map +1 -1
- package/dist-es/text/Display.js.map +1 -1
- package/dist-es/text/Headings.js.map +1 -1
- package/dist-es/text/Label.js.map +1 -1
- package/dist-es/text/Text.js.map +1 -1
- package/dist-es/text/TextAction.js.map +1 -1
- package/dist-es/text/TextNotation.js.map +1 -1
- package/dist-es/theme/Accent.js.map +1 -1
- package/dist-es/theme/ActionFont.js.map +1 -1
- package/dist-es/theme/Corner.js.map +1 -1
- package/dist-es/theme/Density.js.map +1 -1
- package/dist-es/theme/HeadingFont.js.map +1 -1
- package/dist-es/theme/Mode.js.map +1 -1
- package/dist-es/theme/Theme.js.map +1 -1
- package/dist-es/toast/Toast.js.map +1 -1
- package/dist-es/toast/ToastContent.js.map +1 -1
- package/dist-es/toggle-button/ToggleButton.js.map +1 -1
- package/dist-es/toggle-button-group/ToggleButtonGroup.js.map +1 -1
- package/dist-es/toggle-button-group/ToggleButtonGroupContext.js.map +1 -1
- package/dist-es/tooltip/Tooltip.js.map +1 -1
- package/dist-es/tooltip/TooltipBase.js.map +1 -1
- package/dist-es/tooltip/useAriaAnnounce.js.map +1 -1
- package/dist-es/tooltip/useTooltip.js.map +1 -1
- package/dist-es/utils/capitalize.js.map +1 -1
- package/dist-es/utils/createChainedFunction.js.map +1 -1
- package/dist-es/utils/createContext.js.map +1 -1
- package/dist-es/utils/debounce.js.map +1 -1
- package/dist-es/utils/getRefFromChildren.js.map +1 -1
- package/dist-es/utils/makePrefixer.js.map +1 -1
- package/dist-es/utils/marginMiddleware.js.map +1 -1
- package/dist-es/utils/mergeProps.js.map +1 -1
- package/dist-es/utils/ownerDocument.js.map +1 -1
- package/dist-es/utils/ownerWindow.js.map +1 -1
- package/dist-es/utils/renderProps.js.map +1 -1
- package/dist-es/utils/setRef.js.map +1 -1
- package/dist-es/utils/useControlled.js.map +1 -1
- package/dist-es/utils/useEventCallback.js.map +1 -1
- package/dist-es/utils/useFloatingUI/useFloatingUI.js.map +1 -1
- package/dist-es/utils/useForkRef.js.map +1 -1
- package/dist-es/utils/useId.js.map +1 -1
- package/dist-es/utils/useIsFocusVisible.js.map +1 -1
- package/dist-es/utils/useIsomorphicLayoutEffect.js.map +1 -1
- package/dist-es/utils/usePreventScroll.js.map +1 -1
- package/dist-es/utils/usePrevious.js.map +1 -1
- package/dist-es/utils/useResizeObserver.js.map +1 -1
- package/dist-es/utils/useResponsiveProp.js.map +1 -1
- package/dist-es/utils/useValueEffect.js.map +1 -1
- package/dist-es/vertical-navigation/SubMenuContext.js +35 -0
- package/dist-es/vertical-navigation/SubMenuContext.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigation.css.js +4 -0
- package/dist-es/vertical-navigation/VerticalNavigation.css.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigation.js +36 -0
- package/dist-es/vertical-navigation/VerticalNavigation.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigationItem.js +50 -0
- package/dist-es/vertical-navigation/VerticalNavigationItem.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemContent.css.js +4 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemContent.css.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemContent.js +86 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemContent.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemExpansionIcon.js +33 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemExpansionIcon.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemLabel.css.js +4 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemLabel.css.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemLabel.js +26 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemLabel.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemTrigger.css.js +4 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemTrigger.css.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemTrigger.js +72 -0
- package/dist-es/vertical-navigation/VerticalNavigationItemTrigger.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigationSubMenu.css.js +4 -0
- package/dist-es/vertical-navigation/VerticalNavigationSubMenu.css.js.map +1 -0
- package/dist-es/vertical-navigation/VerticalNavigationSubMenu.js +37 -0
- package/dist-es/vertical-navigation/VerticalNavigationSubMenu.js.map +1 -0
- package/dist-es/viewport/ViewportProvider.js.map +1 -1
- package/dist-types/avatar/useAvatarImage.d.ts +3 -1
- package/dist-types/avatar/useIsHydrated.d.ts +1 -0
- package/dist-types/collapsible/Collapsible.d.ts +16 -0
- package/dist-types/collapsible/CollapsibleContext.d.ts +9 -0
- package/dist-types/collapsible/CollapsiblePanel.d.ts +4 -0
- package/dist-types/collapsible/CollapsibleTrigger.d.ts +5 -0
- package/dist-types/collapsible/index.d.ts +3 -0
- package/dist-types/file-drop-zone/FileDropZone.d.ts +1 -1
- package/dist-types/flex-layout/FlexLayout.d.ts +1 -1
- package/dist-types/index.d.ts +2 -0
- package/dist-types/vertical-navigation/SubMenuContext.d.ts +14 -0
- package/dist-types/vertical-navigation/VerticalNavigation.d.ts +8 -0
- package/dist-types/vertical-navigation/VerticalNavigationItem.d.ts +12 -0
- package/dist-types/vertical-navigation/VerticalNavigationItemContent.d.ts +4 -0
- package/dist-types/vertical-navigation/VerticalNavigationItemExpansionIcon.d.ts +2 -0
- package/dist-types/vertical-navigation/VerticalNavigationItemLabel.d.ts +4 -0
- package/dist-types/vertical-navigation/VerticalNavigationItemTrigger.d.ts +6 -0
- package/dist-types/vertical-navigation/VerticalNavigationSubMenu.d.ts +4 -0
- package/dist-types/vertical-navigation/index.d.ts +7 -0
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setRef.js","sources":["../src/utils/setRef.ts"],"sourcesContent":["import type { MutableRefObject } from \"react\";\n\nexport function setRef<T>(\n ref:\n | MutableRefObject<T | null>\n | ((instance: T | null) => void)\n | null\n | undefined,\n value: T | null,\n): void {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n}\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"setRef.js","sources":["../src/utils/setRef.ts"],"sourcesContent":["import type { MutableRefObject } from \"react\";\n\nexport function setRef<T>(\n ref:\n | MutableRefObject<T | null>\n | ((instance: T | null) => void)\n | null\n | undefined,\n value: T | null,\n): void {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n}\n"],"names":[],"mappings":";;AAEO,SAAS,MAAA,CACd,KAKA,KAAA,EACM;AACN,EAAA,IAAI,OAAO,QAAQ,UAAA,EAAY;AAC7B,IAAA,GAAA,CAAI,KAAK,CAAA;AAAA,EACX,WAAW,GAAA,EAAK;AACd,IAAA,GAAA,CAAI,OAAA,GAAU,KAAA;AAAA,EAChB;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useControlled.js","sources":["../src/utils/useControlled.ts"],"sourcesContent":["import {\n type Dispatch,\n isValidElement,\n type SetStateAction,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nexport interface UseControlledProps<T> {\n /**\n * Holds the component value when it's controlled.\n */\n controlled?: T;\n /**\n * The default value when uncontrolled.\n */\n default: T;\n /**\n * The component name displayed in warnings.\n */\n name: string;\n /**\n * The name of the state variable displayed in warnings.\n */\n state?: string;\n}\n\n/**\n * Copied from MUI (v5) useControlled hook with one additional returned value\n * @see https://github.com/mui-org/material-ui/blob/0979e6a54ba47c278d1f535953c0520a86349811/packages/material-ui-utils/src/useControlled.js\n */\nexport function useControlled<S>({\n controlled,\n default: defaultProp,\n name,\n state = \"value\",\n}: UseControlledProps<S>): [S, Dispatch<SetStateAction<S>>, boolean] {\n const { current: isControlled } = useRef(controlled !== undefined);\n const [valueState, setValue] = useState<S>(defaultProp);\n const value = controlled !== undefined ? controlled : valueState;\n const { current: defaultValue } = useRef(defaultProp);\n\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\") {\n if (isControlled !== (controlled !== undefined)) {\n console.error(\n [\n `Salt: A component is changing the ${\n isControlled ? \"\" : \"un\"\n }controlled ${state} state of ${name} to be ${\n isControlled ? \"un\" : \"\"\n }controlled.`,\n \"Elements should not switch from uncontrolled to controlled (or vice versa).\",\n `Decide between using a controlled or uncontrolled ${name} element for the lifetime of the component.`,\n \"The nature of the state is determined during the first render, it's considered controlled if the value is not `undefined`.\",\n \"More info: https://reactjs.org/link/controlled-components\",\n ].join(\"\\n\"),\n );\n }\n }\n return undefined;\n }, [state, name, controlled]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: uses JSON.stringify to compare defaultProp\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\") {\n if (!isControlled && defaultValue !== defaultProp) {\n console.error(\n [\n `Salt: A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. ` +\n `To suppress this warning opt to use a controlled ${name}.`,\n ].join(\"\\n\"),\n );\n }\n }\n return undefined;\n }, [JSON.stringify(defaultProp, ignoreReactElements)]);\n\n const setValueIfUncontrolled: Dispatch<SetStateAction<S>> = useCallback(\n (newValue) => {\n if (!isControlled) {\n setValue(newValue);\n }\n },\n [],\n );\n\n return [value, setValueIfUncontrolled, isControlled];\n}\n\n// Ignore ReactElements in JSON, they contain circular refs\nfunction ignoreReactElements<T>(_key: string, value: T): T | null {\n return isValidElement(value) ? null : value;\n}\n"],"names":["useRef","useState","useEffect","useCallback","isValidElement"],"mappings":";;;;AAiCO,SAAS,
|
|
1
|
+
{"version":3,"file":"useControlled.js","sources":["../src/utils/useControlled.ts"],"sourcesContent":["import {\n type Dispatch,\n isValidElement,\n type SetStateAction,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nexport interface UseControlledProps<T> {\n /**\n * Holds the component value when it's controlled.\n */\n controlled?: T;\n /**\n * The default value when uncontrolled.\n */\n default: T;\n /**\n * The component name displayed in warnings.\n */\n name: string;\n /**\n * The name of the state variable displayed in warnings.\n */\n state?: string;\n}\n\n/**\n * Copied from MUI (v5) useControlled hook with one additional returned value\n * @see https://github.com/mui-org/material-ui/blob/0979e6a54ba47c278d1f535953c0520a86349811/packages/material-ui-utils/src/useControlled.js\n */\nexport function useControlled<S>({\n controlled,\n default: defaultProp,\n name,\n state = \"value\",\n}: UseControlledProps<S>): [S, Dispatch<SetStateAction<S>>, boolean] {\n const { current: isControlled } = useRef(controlled !== undefined);\n const [valueState, setValue] = useState<S>(defaultProp);\n const value = controlled !== undefined ? controlled : valueState;\n const { current: defaultValue } = useRef(defaultProp);\n\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\") {\n if (isControlled !== (controlled !== undefined)) {\n console.error(\n [\n `Salt: A component is changing the ${\n isControlled ? \"\" : \"un\"\n }controlled ${state} state of ${name} to be ${\n isControlled ? \"un\" : \"\"\n }controlled.`,\n \"Elements should not switch from uncontrolled to controlled (or vice versa).\",\n `Decide between using a controlled or uncontrolled ${name} element for the lifetime of the component.`,\n \"The nature of the state is determined during the first render, it's considered controlled if the value is not `undefined`.\",\n \"More info: https://reactjs.org/link/controlled-components\",\n ].join(\"\\n\"),\n );\n }\n }\n return undefined;\n }, [state, name, controlled]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: uses JSON.stringify to compare defaultProp\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\") {\n if (!isControlled && defaultValue !== defaultProp) {\n console.error(\n [\n `Salt: A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. ` +\n `To suppress this warning opt to use a controlled ${name}.`,\n ].join(\"\\n\"),\n );\n }\n }\n return undefined;\n }, [JSON.stringify(defaultProp, ignoreReactElements)]);\n\n const setValueIfUncontrolled: Dispatch<SetStateAction<S>> = useCallback(\n (newValue) => {\n if (!isControlled) {\n setValue(newValue);\n }\n },\n [],\n );\n\n return [value, setValueIfUncontrolled, isControlled];\n}\n\n// Ignore ReactElements in JSON, they contain circular refs\nfunction ignoreReactElements<T>(_key: string, value: T): T | null {\n return isValidElement(value) ? null : value;\n}\n"],"names":["useRef","useState","useEffect","useCallback","isValidElement"],"mappings":";;;;AAiCO,SAAS,aAAA,CAAiB;AAAA,EAC/B,UAAA;AAAA,EACA,OAAA,EAAS,WAAA;AAAA,EACT,IAAA;AAAA,EACA,KAAA,GAAQ;AACV,CAAA,EAAqE;AACnE,EAAA,MAAM,EAAE,OAAA,EAAS,YAAA,EAAa,GAAIA,YAAA,CAAO,eAAe,MAAS,CAAA;AACjE,EAAA,MAAM,CAAC,UAAA,EAAY,QAAQ,CAAA,GAAIC,eAAY,WAAW,CAAA;AACtD,EAAA,MAAM,KAAA,GAAQ,UAAA,KAAe,MAAA,GAAY,UAAA,GAAa,UAAA;AACtD,EAAA,MAAM,EAAE,OAAA,EAAS,YAAA,EAAa,GAAID,aAAO,WAAW,CAAA;AAEpD,EAAAE,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,EAAc;AACzC,MAAA,IAAI,YAAA,MAAkB,eAAe,MAAA,CAAA,EAAY;AAC/C,QAAA,OAAA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OC,oBAAA,CAAe,KAAK,CAAA,GAAI,IAAA,GAAO,KAAA;AACxC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEventCallback.js","sources":["../src/utils/useEventCallback.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\n/**\n * https://github.com/facebook/react/issues/14099#issuecomment-440013892\n */\nexport function useEventCallback<Args extends unknown[], Return>(\n fn: (...args: Args) => Return,\n): (...args: Args) => Return {\n const ref = useRef(fn);\n useIsomorphicLayoutEffect(() => {\n ref.current = fn;\n });\n // biome-ignore lint/complexity/noCommaOperator: This is a valid use case for the comma operator\n return useCallback((...args: Args) => (void 0, ref.current)(...args), []);\n}\n"],"names":["useRef","useIsomorphicLayoutEffect","useCallback"],"mappings":";;;;;AAMO,SAAS,iBACd,EAC2B
|
|
1
|
+
{"version":3,"file":"useEventCallback.js","sources":["../src/utils/useEventCallback.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\n/**\n * https://github.com/facebook/react/issues/14099#issuecomment-440013892\n */\nexport function useEventCallback<Args extends unknown[], Return>(\n fn: (...args: Args) => Return,\n): (...args: Args) => Return {\n const ref = useRef(fn);\n useIsomorphicLayoutEffect(() => {\n ref.current = fn;\n });\n // biome-ignore lint/complexity/noCommaOperator: This is a valid use case for the comma operator\n return useCallback((...args: Args) => (void 0, ref.current)(...args), []);\n}\n"],"names":["useRef","useIsomorphicLayoutEffect","useCallback"],"mappings":";;;;;AAMO,SAAS,iBACd,EAAA,EAC2B;AAC3B,EAAA,MAAM,GAAA,GAAMA,aAAO,EAAE,CAAA;AACrB,EAAAC,mDAAA,CAA0B,MAAM;AAC9B,IAAA,GAAA,CAAI,OAAA,GAAU,EAAA;AAAA,EAChB,CAAC,CAAA;AAED,EAAA,OAAOC,iBAAA,CAAY,CAAA,GAAI,IAAA,KAAA,IAAwB,GAAA,CAAI,SAAS,GAAG,IAAI,CAAA,EAAG,EAAE,CAAA;AAC1E;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFloatingUI.js","sources":["../src/utils/useFloatingUI/useFloatingUI.tsx"],"sourcesContent":["import {\n autoUpdate,\n FloatingFocusManager,\n type FloatingFocusManagerProps,\n FloatingPortal,\n flip,\n limitShift,\n type Middleware,\n type Platform,\n platform,\n type Strategy,\n shift,\n type UseFloatingOptions,\n useFloating,\n} from \"@floating-ui/react\";\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n forwardRef,\n type ReactNode,\n useContext,\n useMemo,\n} from \"react\";\nimport { SaltProvider, SaltProviderNext, useTheme } from \"../../salt-provider\";\nimport { usePreventScroll } from \"../usePreventScroll\";\n\nexport interface FloatingComponentProps\n extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Whether the floating component is open (used for determining whether to show the component)\n * We pass this as a prop rather than not rendering the component to allow more advanced use-cases e.g.\n * for caching windows and reusing them, rather than always spawning a new one\n */\n open: boolean;\n /**\n * Use this prop when `FloatingFocusManager` is needed for floating component\n */\n focusManagerProps?: Omit<FloatingFocusManagerProps, \"children\">;\n /**\n * Position and sizing optional props for the floating component. `top`, `left`, and `position` for floating elements where they aren't positioned with relative to the trigger.\n * `width` and `height` are used to define the size of the floating element.\n *\n */\n top?: number;\n left?: number;\n width?: number;\n height?: number;\n position?: Strategy;\n /**\n * Makes the page unscrollable when the floating component is open.\n */\n lockScroll?: boolean;\n}\n\nconst DefaultFloatingComponent = forwardRef<\n HTMLDivElement,\n FloatingComponentProps\n>(function DefaultFloatingComponent(props, ref) {\n const {\n open,\n top,\n left,\n position,\n width: _width,\n height: _height,\n focusManagerProps,\n lockScroll,\n ...rest\n } = props;\n const style = {\n top,\n left,\n position,\n };\n\n const { themeNext } = useTheme();\n usePreventScroll({ isDisabled: !lockScroll || !open });\n\n const ChosenSaltProvider = themeNext ? SaltProviderNext : SaltProvider;\n\n if (focusManagerProps && open) {\n return (\n <FloatingPortal>\n <ChosenSaltProvider applyClassesTo=\"scope\">\n <FloatingFocusManager {...focusManagerProps}>\n <div style={style} {...rest} ref={ref} />\n </FloatingFocusManager>\n </ChosenSaltProvider>\n </FloatingPortal>\n );\n }\n\n return open ? (\n <FloatingPortal>\n <ChosenSaltProvider applyClassesTo=\"scope\">\n <div style={style} {...rest} ref={ref} />\n </ChosenSaltProvider>\n </FloatingPortal>\n ) : null;\n});\n\nexport interface FloatingComponentContextType {\n Component: typeof DefaultFloatingComponent;\n}\n\nconst FloatingComponentContext = createContext<FloatingComponentContextType>({\n Component: DefaultFloatingComponent,\n});\n\nif (process.env.NODE_ENV !== \"production\") {\n FloatingComponentContext.displayName = \"FloatingComponentContext\";\n}\n\nexport interface FloatingComponentProviderProps\n extends FloatingComponentContextType {\n children: ReactNode;\n}\n\nexport function FloatingComponentProvider(\n props: FloatingComponentProviderProps,\n) {\n const { Component, children } = props;\n const value = useMemo(() => ({ Component }), [Component]);\n\n return (\n <FloatingComponentContext.Provider value={value}>\n {children}\n </FloatingComponentContext.Provider>\n );\n}\n\nexport function useFloatingComponent() {\n return useContext(FloatingComponentContext);\n}\n\nexport interface UseFloatingUIProps\n extends Pick<\n UseFloatingOptions,\n \"placement\" | \"strategy\" | \"open\" | \"onOpenChange\" | \"nodeId\"\n > {\n /**\n * Function to update the default middleware used to extend or replace it\n */\n middleware?: Middleware[];\n}\n\ntype GetMiddleware = (middleware: Middleware[]) => Middleware[];\n\nconst defaultGetMiddleware: GetMiddleware = (defaultMiddleware) =>\n defaultMiddleware;\n\ninterface FloatingPlatformContextType {\n platform: Platform;\n middleware: GetMiddleware;\n animationFrame: boolean;\n}\n\nconst defaultFloatingPlaform: FloatingPlatformContextType = {\n platform,\n middleware: defaultGetMiddleware,\n animationFrame: false,\n};\n\nconst FloatingPlatformContext = createContext<FloatingPlatformContextType>(\n defaultFloatingPlaform,\n);\n\nexport interface FloatingPlatformProviderProps {\n platform?: Platform;\n middleware?: GetMiddleware;\n children: ReactNode;\n animationFrame?: boolean;\n}\n\nexport function FloatingPlatformProvider(props: FloatingPlatformProviderProps) {\n const {\n platform: platformProp,\n middleware,\n animationFrame,\n children,\n } = props;\n\n const floatingPlatformContextValue = useMemo<FloatingPlatformContextType>(\n () => ({\n platform: platformProp ?? platform,\n middleware: middleware ?? defaultGetMiddleware,\n animationFrame: animationFrame || false,\n }),\n [platformProp, middleware, animationFrame],\n );\n\n return (\n <FloatingPlatformContext.Provider value={floatingPlatformContextValue}>\n {children}\n </FloatingPlatformContext.Provider>\n );\n}\n\nexport function useFloatingPlatform() {\n return useContext(FloatingPlatformContext);\n}\n\nexport const DEFAULT_FLOATING_UI_MIDDLEWARE = [\n flip(),\n shift({ limiter: limitShift() }),\n];\n\ntype UseFloatingRefs = ReturnType<typeof useFloating>[\"refs\"];\n\nexport interface UseFloatingUIReturn extends ReturnType<typeof useFloating> {\n reference: UseFloatingRefs[\"setReference\"];\n floating: UseFloatingRefs[\"setFloating\"];\n}\n\nexport function useFloatingUI(props: UseFloatingUIProps): UseFloatingUIReturn {\n const {\n middleware = DEFAULT_FLOATING_UI_MIDDLEWARE,\n open = false,\n onOpenChange,\n ...other\n } = props;\n\n const handleOpenChange: UseFloatingUIProps[\"onOpenChange\"] = (\n open,\n boolean,\n reason,\n ) => {\n update();\n onOpenChange?.(open, boolean, reason);\n };\n\n const {\n platform: contextPlatform,\n middleware: contextMiddleware,\n animationFrame,\n } = useFloatingPlatform();\n\n const { refs, update, ...rest } = useFloating({\n ...other,\n middleware: contextMiddleware(middleware),\n open,\n onOpenChange: handleOpenChange,\n whileElementsMounted: (...args) => {\n const cleanup = autoUpdate(...args, { animationFrame });\n\n return cleanup;\n },\n platform: contextPlatform,\n });\n\n return {\n reference: refs.setReference,\n floating: refs.setFloating,\n refs,\n update,\n ...rest,\n };\n}\n"],"names":["forwardRef","DefaultFloatingComponent","useTheme","usePreventScroll","SaltProviderNext","SaltProvider","FloatingPortal","jsx","FloatingFocusManager","createContext","useMemo","useContext","platform","flip","shift","limitShift","open","useFloating","autoUpdate"],"mappings":";;;;;;;;AAsDA,MAAM,wBAA2B,GAAAA,gBAAA,CAG/B,SAASC,yBAAAA,CAAyB,OAAO,GAAK,EAAA;AAC9C,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,GAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAO,EAAA,MAAA;AAAA,IACP,MAAQ,EAAA,OAAA;AAAA,IACR,iBAAA;AAAA,IACA,UAAA;AAAA,IACA,GAAG;AAAA,GACD,GAAA,KAAA;AACJ,EAAA,MAAM,KAAQ,GAAA;AAAA,IACZ,GAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAM,MAAA,EAAE,SAAU,EAAA,GAAIC,qBAAS,EAAA;AAC/B,EAAAC,iCAAA,CAAiB,EAAE,UAAY,EAAA,CAAC,UAAc,IAAA,CAAC,MAAM,CAAA;AAErD,EAAM,MAAA,kBAAA,GAAqB,YAAYC,6BAAmB,GAAAC,yBAAA;AAE1D,EAAA,IAAI,qBAAqB,IAAM,EAAA;AAC7B,IAAA,sCACGC,oBACC,EAAA,EAAA,QAAA,kBAAAC,cAAA,CAAC,sBAAmB,cAAe,EAAA,OAAA,EACjC,yCAACC,0BAAsB,EAAA,EAAA,GAAG,iBACxB,EAAA,QAAA,kBAAAD,cAAA,CAAC,SAAI,KAAe,EAAA,GAAG,MAAM,GAAU,EAAA,CAAA,EACzC,GACF,CACF,EAAA,CAAA;AAAA;AAIJ,EAAA,OAAO,IACL,mBAAAA,cAAA,CAACD,oBACC,EAAA,EAAA,QAAA,kBAAAC,cAAA,CAAC,sBAAmB,cAAe,EAAA,OAAA,EACjC,QAAC,kBAAAA,cAAA,CAAA,KAAA,EAAA,EAAI,OAAe,GAAG,IAAA,EAAM,GAAU,EAAA,CAAA,EACzC,GACF,CACE,GAAA,IAAA;AACN,CAAC,CAAA;AAM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AA,GACL;AACF;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"useFloatingUI.js","sources":["../src/utils/useFloatingUI/useFloatingUI.tsx"],"sourcesContent":["import {\n autoUpdate,\n FloatingFocusManager,\n type FloatingFocusManagerProps,\n FloatingPortal,\n flip,\n limitShift,\n type Middleware,\n type Platform,\n platform,\n type Strategy,\n shift,\n type UseFloatingOptions,\n useFloating,\n} from \"@floating-ui/react\";\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n forwardRef,\n type ReactNode,\n useContext,\n useMemo,\n} from \"react\";\nimport { SaltProvider, SaltProviderNext, useTheme } from \"../../salt-provider\";\nimport { usePreventScroll } from \"../usePreventScroll\";\n\nexport interface FloatingComponentProps\n extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Whether the floating component is open (used for determining whether to show the component)\n * We pass this as a prop rather than not rendering the component to allow more advanced use-cases e.g.\n * for caching windows and reusing them, rather than always spawning a new one\n */\n open: boolean;\n /**\n * Use this prop when `FloatingFocusManager` is needed for floating component\n */\n focusManagerProps?: Omit<FloatingFocusManagerProps, \"children\">;\n /**\n * Position and sizing optional props for the floating component. `top`, `left`, and `position` for floating elements where they aren't positioned with relative to the trigger.\n * `width` and `height` are used to define the size of the floating element.\n *\n */\n top?: number;\n left?: number;\n width?: number;\n height?: number;\n position?: Strategy;\n /**\n * Makes the page unscrollable when the floating component is open.\n */\n lockScroll?: boolean;\n}\n\nconst DefaultFloatingComponent = forwardRef<\n HTMLDivElement,\n FloatingComponentProps\n>(function DefaultFloatingComponent(props, ref) {\n const {\n open,\n top,\n left,\n position,\n width: _width,\n height: _height,\n focusManagerProps,\n lockScroll,\n ...rest\n } = props;\n const style = {\n top,\n left,\n position,\n };\n\n const { themeNext } = useTheme();\n usePreventScroll({ isDisabled: !lockScroll || !open });\n\n const ChosenSaltProvider = themeNext ? SaltProviderNext : SaltProvider;\n\n if (focusManagerProps && open) {\n return (\n <FloatingPortal>\n <ChosenSaltProvider applyClassesTo=\"scope\">\n <FloatingFocusManager {...focusManagerProps}>\n <div style={style} {...rest} ref={ref} />\n </FloatingFocusManager>\n </ChosenSaltProvider>\n </FloatingPortal>\n );\n }\n\n return open ? (\n <FloatingPortal>\n <ChosenSaltProvider applyClassesTo=\"scope\">\n <div style={style} {...rest} ref={ref} />\n </ChosenSaltProvider>\n </FloatingPortal>\n ) : null;\n});\n\nexport interface FloatingComponentContextType {\n Component: typeof DefaultFloatingComponent;\n}\n\nconst FloatingComponentContext = createContext<FloatingComponentContextType>({\n Component: DefaultFloatingComponent,\n});\n\nif (process.env.NODE_ENV !== \"production\") {\n FloatingComponentContext.displayName = \"FloatingComponentContext\";\n}\n\nexport interface FloatingComponentProviderProps\n extends FloatingComponentContextType {\n children: ReactNode;\n}\n\nexport function FloatingComponentProvider(\n props: FloatingComponentProviderProps,\n) {\n const { Component, children } = props;\n const value = useMemo(() => ({ Component }), [Component]);\n\n return (\n <FloatingComponentContext.Provider value={value}>\n {children}\n </FloatingComponentContext.Provider>\n );\n}\n\nexport function useFloatingComponent() {\n return useContext(FloatingComponentContext);\n}\n\nexport interface UseFloatingUIProps\n extends Pick<\n UseFloatingOptions,\n \"placement\" | \"strategy\" | \"open\" | \"onOpenChange\" | \"nodeId\"\n > {\n /**\n * Function to update the default middleware used to extend or replace it\n */\n middleware?: Middleware[];\n}\n\ntype GetMiddleware = (middleware: Middleware[]) => Middleware[];\n\nconst defaultGetMiddleware: GetMiddleware = (defaultMiddleware) =>\n defaultMiddleware;\n\ninterface FloatingPlatformContextType {\n platform: Platform;\n middleware: GetMiddleware;\n animationFrame: boolean;\n}\n\nconst defaultFloatingPlaform: FloatingPlatformContextType = {\n platform,\n middleware: defaultGetMiddleware,\n animationFrame: false,\n};\n\nconst FloatingPlatformContext = createContext<FloatingPlatformContextType>(\n defaultFloatingPlaform,\n);\n\nexport interface FloatingPlatformProviderProps {\n platform?: Platform;\n middleware?: GetMiddleware;\n children: ReactNode;\n animationFrame?: boolean;\n}\n\nexport function FloatingPlatformProvider(props: FloatingPlatformProviderProps) {\n const {\n platform: platformProp,\n middleware,\n animationFrame,\n children,\n } = props;\n\n const floatingPlatformContextValue = useMemo<FloatingPlatformContextType>(\n () => ({\n platform: platformProp ?? platform,\n middleware: middleware ?? defaultGetMiddleware,\n animationFrame: animationFrame || false,\n }),\n [platformProp, middleware, animationFrame],\n );\n\n return (\n <FloatingPlatformContext.Provider value={floatingPlatformContextValue}>\n {children}\n </FloatingPlatformContext.Provider>\n );\n}\n\nexport function useFloatingPlatform() {\n return useContext(FloatingPlatformContext);\n}\n\nexport const DEFAULT_FLOATING_UI_MIDDLEWARE = [\n flip(),\n shift({ limiter: limitShift() }),\n];\n\ntype UseFloatingRefs = ReturnType<typeof useFloating>[\"refs\"];\n\nexport interface UseFloatingUIReturn extends ReturnType<typeof useFloating> {\n reference: UseFloatingRefs[\"setReference\"];\n floating: UseFloatingRefs[\"setFloating\"];\n}\n\nexport function useFloatingUI(props: UseFloatingUIProps): UseFloatingUIReturn {\n const {\n middleware = DEFAULT_FLOATING_UI_MIDDLEWARE,\n open = false,\n onOpenChange,\n ...other\n } = props;\n\n const handleOpenChange: UseFloatingUIProps[\"onOpenChange\"] = (\n open,\n boolean,\n reason,\n ) => {\n update();\n onOpenChange?.(open, boolean, reason);\n };\n\n const {\n platform: contextPlatform,\n middleware: contextMiddleware,\n animationFrame,\n } = useFloatingPlatform();\n\n const { refs, update, ...rest } = useFloating({\n ...other,\n middleware: contextMiddleware(middleware),\n open,\n onOpenChange: handleOpenChange,\n whileElementsMounted: (...args) => {\n const cleanup = autoUpdate(...args, { animationFrame });\n\n return cleanup;\n },\n platform: contextPlatform,\n });\n\n return {\n reference: refs.setReference,\n floating: refs.setFloating,\n refs,\n update,\n ...rest,\n };\n}\n"],"names":["forwardRef","DefaultFloatingComponent","useTheme","usePreventScroll","SaltProviderNext","SaltProvider","FloatingPortal","jsx","FloatingFocusManager","createContext","useMemo","useContext","platform","flip","shift","limitShift","open","useFloating","autoUpdate"],"mappings":";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version":3,"file":"useForkRef.js","sources":["../src/utils/useForkRef.ts"],"sourcesContent":["import { type Ref, useMemo } from \"react\";\nimport { setRef } from \"./setRef\";\n\nexport function useForkRef<Instance>(\n refA: Ref<Instance> | null | undefined,\n refB: Ref<Instance> | null | undefined,\n): Ref<Instance> | null {\n /**\n * This will create a new function if the ref props change and are defined.\n * This means React will call the old forkRef with `null` and the new forkRef\n * with the ref. Cleanup naturally emerges from this behavior\n */\n return useMemo(() => {\n if (refA == null && refB == null) {\n return () => null;\n }\n return (refValue) => {\n setRef(refA, refValue);\n setRef(refB, refValue);\n };\n }, [refA, refB]);\n}\n"],"names":["useMemo","setRef"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"useForkRef.js","sources":["../src/utils/useForkRef.ts"],"sourcesContent":["import { type Ref, useMemo } from \"react\";\nimport { setRef } from \"./setRef\";\n\nexport function useForkRef<Instance>(\n refA: Ref<Instance> | null | undefined,\n refB: Ref<Instance> | null | undefined,\n): Ref<Instance> | null {\n /**\n * This will create a new function if the ref props change and are defined.\n * This means React will call the old forkRef with `null` and the new forkRef\n * with the ref. Cleanup naturally emerges from this behavior\n */\n return useMemo(() => {\n if (refA == null && refB == null) {\n return () => null;\n }\n return (refValue) => {\n setRef(refA, refValue);\n setRef(refB, refValue);\n };\n }, [refA, refB]);\n}\n"],"names":["useMemo","setRef"],"mappings":";;;;;AAGO,SAAS,UAAA,CACd,MACA,IAAA,EACsB;AAMtB,EAAA,OAAOA,cAAQ,MAAM;AACnB,IAAA,IAAI,IAAA,IAAQ,IAAA,IAAQ,IAAA,IAAQ,IAAA,EAAM;AAChC,MAAA,OAAO,MAAM,IAAA;AAAA,IACf;AACA,IAAA,OAAO,CAAC,QAAA,KAAa;AACnB,MAAAC,aAAA,CAAO,MAAM,QAAQ,CAAA;AACrB,MAAAA,aAAA,CAAO,MAAM,QAAQ,CAAA;AAAA,IACvB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,IAAA,EAAM,IAAI,CAAC,CAAA;AACjB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useId.js","sources":["../src/utils/useId.ts"],"sourcesContent":["/** biome-ignore-all lint/correctness/useHookAtTopLevel: `React.useId` is invariant at runtime. */\nimport * as React from \"react\";\n\n// Workaround for https://github.com/webpack/webpack/issues/14814#issuecomment-1536757985\n// Without `toString()`, downstream library using webpack to re-bundle will error\nconst maybeReactUseId: undefined | (() => string) = (React as any)[\n \"useId\".toString()\n];\n\nlet globalId = BigInt(0);\nfunction useIdLegacy(idOverride?: string): string | undefined {\n const [defaultId, setDefaultId] = React.useState(idOverride);\n const id = idOverride || defaultId;\n React.useEffect(() => {\n if (defaultId == null) {\n setDefaultId(`salt-${++globalId}`);\n }\n }, [defaultId]);\n return id;\n}\n\nexport function useId(idOverride?: string): string | undefined {\n if (maybeReactUseId !== undefined) {\n const reactId = maybeReactUseId();\n return idOverride ?? reactId;\n }\n return useIdLegacy(idOverride);\n}\n\n// Note: Some usages require that an id is returned on first call, not only post-first-render\n// (as with the useEffect solution). This can go away once we totally move to React 18\nexport function useIdMemo(idOverride?: string): string {\n return React.useMemo(() => {\n return idOverride ?? `salt-${++globalId}`;\n }, [idOverride]);\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,
|
|
1
|
+
{"version":3,"file":"useId.js","sources":["../src/utils/useId.ts"],"sourcesContent":["/** biome-ignore-all lint/correctness/useHookAtTopLevel: `React.useId` is invariant at runtime. */\nimport * as React from \"react\";\n\n// Workaround for https://github.com/webpack/webpack/issues/14814#issuecomment-1536757985\n// Without `toString()`, downstream library using webpack to re-bundle will error\nconst maybeReactUseId: undefined | (() => string) = (React as any)[\n \"useId\".toString()\n];\n\nlet globalId = BigInt(0);\nfunction useIdLegacy(idOverride?: string): string | undefined {\n const [defaultId, setDefaultId] = React.useState(idOverride);\n const id = idOverride || defaultId;\n React.useEffect(() => {\n if (defaultId == null) {\n setDefaultId(`salt-${++globalId}`);\n }\n }, [defaultId]);\n return id;\n}\n\nexport function useId(idOverride?: string): string | undefined {\n if (maybeReactUseId !== undefined) {\n const reactId = maybeReactUseId();\n return idOverride ?? reactId;\n }\n return useIdLegacy(idOverride);\n}\n\n// Note: Some usages require that an id is returned on first call, not only post-first-render\n// (as with the useEffect solution). This can go away once we totally move to React 18\nexport function useIdMemo(idOverride?: string): string {\n return React.useMemo(() => {\n return idOverride ?? `salt-${++globalId}`;\n }, [idOverride]);\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,eAAA,GAA+CA,gBAAA,CACnD,OAAA,CAAQ,QAAA,EACV,CAAA;AAEA,IAAI,QAAA,GAAW,OAAO,CAAC,CAAA;AACvB,SAAS,YAAY,UAAA,EAAyC;AAC5D,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAIA,gBAAA,CAAM,SAAS,UAAU,CAAA;AAC3D,EAAA,MAAM,KAAK,UAAA,IAAc,SAAA;AACzB,EAAAA,gBAAA,CAAM,UAAU,MAAM;AACpB,IAAA,IAAI,aAAa,IAAA,EAAM;AACrB,MAAA,YAAA,CAAa,CAAA,KAAA,EAAQ,EAAE,QAAQ,CAAA,CAAE,CAAA;AAAA,IACnC;AAAA,EACF,CAAA,EAAG,CAAC,SAAS,CAAC,CAAA;AACd,EAAA,OAAO,EAAA;AACT;AAEO,SAAS,MAAM,UAAA,EAAyC;AAC7D,EAAA,IAAI,oBAAoB,MAAA,EAAW;AACjC,IAAA,MAAM,UAAU,eAAA,EAAgB;AAChC,IAAA,OAAO,UAAA,IAAc,OAAA;AAAA,EACvB;AACA,EAAA,OAAO,YAAY,UAAU,CAAA;AAC/B;AAIO,SAAS,UAAU,UAAA,EAA6B;AACrD,EAAA,OAAOA,gBAAA,CAAM,QAAQ,MAAM;AACzB,IAAA,OAAO,UAAA,IAAc,CAAA,KAAA,EAAQ,EAAE,QAAQ,CAAA,CAAA;AAAA,EACzC,CAAA,EAAG,CAAC,UAAU,CAAC,CAAA;AACjB;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFocusVisible.js","sources":["../src/utils/useIsFocusVisible.ts"],"sourcesContent":["// based on https://github.com/WICG/focus-visible/blob/v4.1.5/src/focus-visible.js\nimport {\n type FocusEvent,\n type MutableRefObject,\n type Ref,\n useCallback,\n useRef,\n} from \"react\";\n\nlet hadKeyboardEvent = true;\nlet hadFocusVisibleRecently = false;\nlet hadFocusVisibleRecentlyTimeout: number;\n\nconst inputTypesWhitelist: Record<string, boolean> = {\n text: true,\n search: true,\n url: true,\n tel: true,\n email: true,\n password: true,\n number: true,\n date: true,\n month: true,\n week: true,\n time: true,\n datetime: true,\n \"datetime-local\": true,\n};\n\n/**\n * Computes whether the given element should automatically trigger the\n * `focus-visible` class being added, i.e. whether it should always match\n * `:focus-visible` when focused.\n * @param {Element} node\n * @returns {boolean}\n */\nfunction focusTriggersKeyboardModality(node: HTMLElement) {\n if (\n node.tagName === \"INPUT\" &&\n inputTypesWhitelist[(node as HTMLInputElement).type] &&\n !(node as HTMLInputElement).readOnly\n ) {\n return true;\n }\n\n if (node.tagName === \"TEXTAREA\" && !(node as HTMLInputElement).readOnly) {\n return true;\n }\n\n return node.isContentEditable;\n}\n\n/**\n * Keep track of our keyboard modality state with `hadKeyboardEvent`.\n * If the most recent user interaction was via the keyboard;\n * and the key press did not include a meta, alt/option, or control key;\n * then the modality is keyboard. Otherwise, the modality is not keyboard.\n * @param {KeyboardEvent} event\n */\nfunction handleKeyDown(event: KeyboardEvent) {\n if (event.metaKey || event.altKey || event.ctrlKey) {\n return;\n }\n hadKeyboardEvent = true;\n}\n\n/**\n * If at any point a user clicks with a pointing device, ensure that we change\n * the modality away from keyboard.\n * This avoids the situation where a user presses a key on an already focused\n * element, and then clicks on a different element, focusing it with a\n * pointing device, while we still think we're in keyboard modality.\n */\nfunction handlePointerDown() {\n hadKeyboardEvent = false;\n}\n\nfunction handleVisibilityChange(this: Document) {\n if (this.visibilityState === \"hidden\") {\n // If the tab becomes active again, the browser will handle calling focus\n // on the element (Safari actually calls it twice).\n // If this tab change caused a blur on an element with focus-visible,\n // re-apply the class when the user switches back to the tab.\n if (hadFocusVisibleRecently) {\n hadKeyboardEvent = true;\n }\n }\n}\n\nfunction prepare(doc: Document) {\n doc.addEventListener(\"keydown\", handleKeyDown, true);\n doc.addEventListener(\"mousedown\", handlePointerDown, true);\n doc.addEventListener(\"pointerdown\", handlePointerDown, true);\n doc.addEventListener(\"touchstart\", handlePointerDown, true);\n doc.addEventListener(\"visibilitychange\", handleVisibilityChange, true);\n}\n\nexport function teardown(doc: Document): void {\n doc.removeEventListener(\"keydown\", handleKeyDown, true);\n doc.removeEventListener(\"mousedown\", handlePointerDown, true);\n doc.removeEventListener(\"pointerdown\", handlePointerDown, true);\n doc.removeEventListener(\"touchstart\", handlePointerDown, true);\n doc.removeEventListener(\"visibilitychange\", handleVisibilityChange, true);\n}\n\nfunction isFocusVisible(event: FocusEvent<HTMLElement>) {\n const { target } = event;\n try {\n return target.matches(\":focus-visible\");\n } catch {\n // Browsers not implementing :focus-visible will throw a SyntaxError.\n // We use our own heuristic for those browsers.\n // Rethrow might be better if it's not the expected error but do we really\n // want to crash if focus-visible malfunctioned?\n }\n\n // No need for validFocusTarget check. The user does that by attaching it to\n // focused events only.\n return hadKeyboardEvent || focusTriggersKeyboardModality(target);\n}\n\nexport function useIsFocusVisible<T extends HTMLElement = HTMLElement>(): {\n isFocusVisibleRef: MutableRefObject<boolean>;\n onBlur: () => void;\n onFocus: (event: FocusEvent<T>) => void;\n ref: Ref<T>;\n} {\n const ref = useCallback((node: T | null) => {\n if (node != null) {\n prepare(node.ownerDocument);\n }\n }, []);\n\n const isFocusVisibleRef = useRef(false);\n\n /**\n * Should be called if a blur event is fired\n */\n function handleBlurVisible() {\n // checking against potential state variable does not suffice if we focus and blur synchronously.\n // React wouldn't have time to trigger a re-render so `focusVisible` would be stale.\n // Ideally we would adjust `isFocusVisible(event)` to look at `relatedTarget` for blur events.\n // This doesn't work in IE11 due to https://github.com/facebook/react/issues/3751\n // TODO: check again if React releases their internal changes to focus event handling (https://github.com/facebook/react/pull/19186).\n if (isFocusVisibleRef.current) {\n // To detect a tab/window switch, we look for a blur event followed\n // rapidly by a visibility change.\n // If we don't see a visibility change within 100ms, it's probably a\n // regular focus change.\n hadFocusVisibleRecently = true;\n window.clearTimeout(hadFocusVisibleRecentlyTimeout);\n hadFocusVisibleRecentlyTimeout = window.setTimeout(() => {\n hadFocusVisibleRecently = false;\n }, 100);\n\n isFocusVisibleRef.current = false;\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Should be called if a blur event is fired\n */\n function handleFocusVisible(event: FocusEvent<HTMLElement>) {\n if (isFocusVisible(event)) {\n isFocusVisibleRef.current = true;\n return true;\n }\n return false;\n }\n\n return {\n isFocusVisibleRef,\n onFocus: handleFocusVisible,\n onBlur: handleBlurVisible,\n ref,\n };\n}\n"],"names":["useCallback","useRef"],"mappings":";;;;AASA,IAAI,
|
|
1
|
+
{"version":3,"file":"useIsFocusVisible.js","sources":["../src/utils/useIsFocusVisible.ts"],"sourcesContent":["// based on https://github.com/WICG/focus-visible/blob/v4.1.5/src/focus-visible.js\nimport {\n type FocusEvent,\n type MutableRefObject,\n type Ref,\n useCallback,\n useRef,\n} from \"react\";\n\nlet hadKeyboardEvent = true;\nlet hadFocusVisibleRecently = false;\nlet hadFocusVisibleRecentlyTimeout: number;\n\nconst inputTypesWhitelist: Record<string, boolean> = {\n text: true,\n search: true,\n url: true,\n tel: true,\n email: true,\n password: true,\n number: true,\n date: true,\n month: true,\n week: true,\n time: true,\n datetime: true,\n \"datetime-local\": true,\n};\n\n/**\n * Computes whether the given element should automatically trigger the\n * `focus-visible` class being added, i.e. whether it should always match\n * `:focus-visible` when focused.\n * @param {Element} node\n * @returns {boolean}\n */\nfunction focusTriggersKeyboardModality(node: HTMLElement) {\n if (\n node.tagName === \"INPUT\" &&\n inputTypesWhitelist[(node as HTMLInputElement).type] &&\n !(node as HTMLInputElement).readOnly\n ) {\n return true;\n }\n\n if (node.tagName === \"TEXTAREA\" && !(node as HTMLInputElement).readOnly) {\n return true;\n }\n\n return node.isContentEditable;\n}\n\n/**\n * Keep track of our keyboard modality state with `hadKeyboardEvent`.\n * If the most recent user interaction was via the keyboard;\n * and the key press did not include a meta, alt/option, or control key;\n * then the modality is keyboard. Otherwise, the modality is not keyboard.\n * @param {KeyboardEvent} event\n */\nfunction handleKeyDown(event: KeyboardEvent) {\n if (event.metaKey || event.altKey || event.ctrlKey) {\n return;\n }\n hadKeyboardEvent = true;\n}\n\n/**\n * If at any point a user clicks with a pointing device, ensure that we change\n * the modality away from keyboard.\n * This avoids the situation where a user presses a key on an already focused\n * element, and then clicks on a different element, focusing it with a\n * pointing device, while we still think we're in keyboard modality.\n */\nfunction handlePointerDown() {\n hadKeyboardEvent = false;\n}\n\nfunction handleVisibilityChange(this: Document) {\n if (this.visibilityState === \"hidden\") {\n // If the tab becomes active again, the browser will handle calling focus\n // on the element (Safari actually calls it twice).\n // If this tab change caused a blur on an element with focus-visible,\n // re-apply the class when the user switches back to the tab.\n if (hadFocusVisibleRecently) {\n hadKeyboardEvent = true;\n }\n }\n}\n\nfunction prepare(doc: Document) {\n doc.addEventListener(\"keydown\", handleKeyDown, true);\n doc.addEventListener(\"mousedown\", handlePointerDown, true);\n doc.addEventListener(\"pointerdown\", handlePointerDown, true);\n doc.addEventListener(\"touchstart\", handlePointerDown, true);\n doc.addEventListener(\"visibilitychange\", handleVisibilityChange, true);\n}\n\nexport function teardown(doc: Document): void {\n doc.removeEventListener(\"keydown\", handleKeyDown, true);\n doc.removeEventListener(\"mousedown\", handlePointerDown, true);\n doc.removeEventListener(\"pointerdown\", handlePointerDown, true);\n doc.removeEventListener(\"touchstart\", handlePointerDown, true);\n doc.removeEventListener(\"visibilitychange\", handleVisibilityChange, true);\n}\n\nfunction isFocusVisible(event: FocusEvent<HTMLElement>) {\n const { target } = event;\n try {\n return target.matches(\":focus-visible\");\n } catch {\n // Browsers not implementing :focus-visible will throw a SyntaxError.\n // We use our own heuristic for those browsers.\n // Rethrow might be better if it's not the expected error but do we really\n // want to crash if focus-visible malfunctioned?\n }\n\n // No need for validFocusTarget check. The user does that by attaching it to\n // focused events only.\n return hadKeyboardEvent || focusTriggersKeyboardModality(target);\n}\n\nexport function useIsFocusVisible<T extends HTMLElement = HTMLElement>(): {\n isFocusVisibleRef: MutableRefObject<boolean>;\n onBlur: () => void;\n onFocus: (event: FocusEvent<T>) => void;\n ref: Ref<T>;\n} {\n const ref = useCallback((node: T | null) => {\n if (node != null) {\n prepare(node.ownerDocument);\n }\n }, []);\n\n const isFocusVisibleRef = useRef(false);\n\n /**\n * Should be called if a blur event is fired\n */\n function handleBlurVisible() {\n // checking against potential state variable does not suffice if we focus and blur synchronously.\n // React wouldn't have time to trigger a re-render so `focusVisible` would be stale.\n // Ideally we would adjust `isFocusVisible(event)` to look at `relatedTarget` for blur events.\n // This doesn't work in IE11 due to https://github.com/facebook/react/issues/3751\n // TODO: check again if React releases their internal changes to focus event handling (https://github.com/facebook/react/pull/19186).\n if (isFocusVisibleRef.current) {\n // To detect a tab/window switch, we look for a blur event followed\n // rapidly by a visibility change.\n // If we don't see a visibility change within 100ms, it's probably a\n // regular focus change.\n hadFocusVisibleRecently = true;\n window.clearTimeout(hadFocusVisibleRecentlyTimeout);\n hadFocusVisibleRecentlyTimeout = window.setTimeout(() => {\n hadFocusVisibleRecently = false;\n }, 100);\n\n isFocusVisibleRef.current = false;\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Should be called if a blur event is fired\n */\n function handleFocusVisible(event: FocusEvent<HTMLElement>) {\n if (isFocusVisible(event)) {\n isFocusVisibleRef.current = true;\n return true;\n }\n return false;\n }\n\n return {\n isFocusVisibleRef,\n onFocus: handleFocusVisible,\n onBlur: handleBlurVisible,\n ref,\n };\n}\n"],"names":["useCallback","useRef"],"mappings":";;;;AASA,IAAI,gBAAA,GAAmB,I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,OAAA,CAAQ,KAAK,aAAa,CAAA;AAAA,IAC5B;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,iBAAA,GAAoBC,aAAO,KAAK,CAAA;AAKtC,EAAA,SAAS,iBAAA,GAAoB;AAM3B,IAAA,IAAI,kBAAkB,OAAA,EAAS;AAK7B,MAAA,uBAAA,GAA0B,IAAA;AAC1B,MAAA,MAAA,CAAO,aAAa,8BAA8B,CAAA;AAClD,MAAA,8BAAA,GAAiC,MAAA,CAAO,WAAW,MAAM;AACvD,QAAA,uBAAA,GAA0B,KAAA;AAAA,MAC5B,GAAG,GAAG,CAAA;AAEN,MAAA,iBAAA,CAAkB,OAAA,GAAU,KAAA;AAE5B,MAAA,OAAO,IAAA;AAAA,IACT;AAEA,IAAA,OAAO,KAAA;AAAA,EACT;AAKA,EAAA,SAAS,mBAAmB,KAAA,EAAgC;AAC1D,IAAA,IAAI,cAAA,CAAe,KAAK,CAAA,EAAG;AACzB,MAAA,iBAAA,CAAkB,OAAA,GAAU,IAAA;AAC5B,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO;AAAA,IACL,iBAAA;AAAA,IACA,OAAA,EAAS,kBAAA;AAAA,IACT,MAAA,EAAQ,iBAAA;AAAA,IACR;AAAA,GACF;AACF;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsomorphicLayoutEffect.js","sources":["../src/utils/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from \"react\";\n\n// React currently throws a warning when using useLayoutEffect on the server.\n// To get around it, we can conditionally useEffect on the server (no-op) and\n// useLayoutEffect in the browser. We need useLayoutEffect because we want\n// `connect` to perform sync updates to a ref to save the latest props after\n// a render is actually committed to the DOM.\nexport const useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" &&\n typeof window.document !== \"undefined\" &&\n typeof window.document.createElement !== \"undefined\"\n ? useLayoutEffect\n : useEffect;\n"],"names":["useLayoutEffect","useEffect"],"mappings":";;;;AAOO,MAAM,
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.js","sources":["../src/utils/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from \"react\";\n\n// React currently throws a warning when using useLayoutEffect on the server.\n// To get around it, we can conditionally useEffect on the server (no-op) and\n// useLayoutEffect in the browser. We need useLayoutEffect because we want\n// `connect` to perform sync updates to a ref to save the latest props after\n// a render is actually committed to the DOM.\nexport const useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" &&\n typeof window.document !== \"undefined\" &&\n typeof window.document.createElement !== \"undefined\"\n ? useLayoutEffect\n : useEffect;\n"],"names":["useLayoutEffect","useEffect"],"mappings":";;;;AAOO,MAAM,yBAAA,GACX,OAAO,MAAA,KAAW,WAAA,IAClB,OAAO,MAAA,CAAO,QAAA,KAAa,WAAA,IAC3B,OAAO,MAAA,CAAO,QAAA,CAAS,aAAA,KAAkB,cACrCA,qBAAA,GACAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreventScroll.js","sources":["../src/utils/usePreventScroll.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Taken from https://github.com/adobe/react-spectrum/blob/cc08a8dbc95d3648eee47bc9b8e0ed48448e0da2/packages/%40react-aria/overlays/src/usePreventScroll.ts#L44 but refactored.\n * This hook currently doesn't use `useWindow` because in a desktop environment the main window is only the window they typically want locked.\n * If we need to in the future we can add an option to specify which window should be affected.\n */\n\nimport { createChainedFunction } from \"./createChainedFunction\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\ninterface PreventScrollOptions {\n /** Whether the scroll lock is disabled. */\n isDisabled?: boolean;\n}\n\nconst visualViewport = typeof document !== \"undefined\" && window.visualViewport;\n\n// HTML input types that do not cause the software keyboard to appear.\nconst nonTextInputTypes = new Set([\n \"checkbox\",\n \"radio\",\n \"range\",\n \"color\",\n \"file\",\n \"image\",\n \"button\",\n \"submit\",\n \"reset\",\n]);\n\n// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position\nlet preventScrollCount = 0;\nlet restore: () => void;\n\n/**\n * Prevents scrolling on the document body on mount, and\n * restores it on unmount. Also ensures that content does not\n * shift due to the scrollbars disappearing.\n */\nexport function usePreventScroll(options: PreventScrollOptions = {}) {\n const { isDisabled } = options;\n\n useIsomorphicLayoutEffect(() => {\n if (isDisabled) {\n return;\n }\n\n preventScrollCount++;\n if (preventScrollCount === 1) {\n if (isIOS()) {\n restore = preventScrollMobileSafari();\n } else {\n restore = preventScrollStandard();\n }\n }\n\n return () => {\n preventScrollCount--;\n if (preventScrollCount === 0) {\n restore();\n }\n };\n }, [isDisabled]);\n}\n\n// For most browsers, all we need to do is set `overflow: hidden` on the root element, and\n// add some padding to prevent the page from shifting when the scrollbar is hidden.\nfunction preventScrollStandard() {\n return createChainedFunction(\n setStyle(\n document.documentElement,\n \"paddingRight\",\n `${window.innerWidth - document.documentElement.clientWidth}px`,\n ),\n setStyle(document.documentElement, \"overflow\", \"hidden\"),\n );\n}\n\n// Mobile Safari is a whole different beast. Even with overflow: hidden,\n// it still scrolls the page in many situations:\n//\n// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.\n// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of\n// it, so it becomes scrollable.\n// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.\n// This may cause even fixed position elements to scroll off the screen.\n// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always\n// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.\n//\n// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:\n//\n// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling\n// on the window.\n// 2. Set `overscroll-behavior: contain` on nested scrollable regions so they do not scroll the page when at\n// the top or bottom. Work around a bug where this does not work when the element does not actually overflow\n// by preventing default in a `touchmove` event.\n// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.\n// 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top\n// of the page, which prevents it from scrolling the page. After the input is focused, scroll the element\n// into view ourselves, without scrolling the whole page.\n// 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the\n// same visually, but makes the actual scroll position always zero. This is required to make all of the\n// above work or Safari will still try to scroll the page when focusing an input.\n// 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting\n// to navigate to an input with the next/previous buttons that's outside a modal.\nfunction preventScrollMobileSafari() {\n let scrollable: Element;\n let restoreScrollableStyles: () => void;\n const onTouchStart = (e: TouchEvent) => {\n // Store the nearest scrollable parent element from the element that the user touched.\n scrollable = getScrollParent(e.target as Element, true);\n if (\n scrollable === document.documentElement &&\n scrollable === document.body\n ) {\n return;\n }\n\n // Prevent scrolling up when at the top and scrolling down when at the bottom\n // of a nested scrollable area, otherwise mobile Safari will start scrolling\n // the window instead.\n if (\n scrollable instanceof HTMLElement &&\n window.getComputedStyle(scrollable).overscrollBehavior === \"auto\"\n ) {\n restoreScrollableStyles = setStyle(\n scrollable,\n \"overscrollBehavior\",\n \"contain\",\n );\n }\n };\n\n const onTouchMove = (e: TouchEvent) => {\n // Prevent scrolling the window.\n if (\n !scrollable ||\n scrollable === document.documentElement ||\n scrollable === document.body\n ) {\n e.preventDefault();\n return;\n }\n\n // overscroll-behavior should prevent scroll chaining, but currently does not\n // if the element doesn't actually overflow. https://bugs.webkit.org/show_bug.cgi?id=243452\n // This checks that both the width and height do not overflow, otherwise we might\n // block horizontal scrolling too. In that case, adding `touch-action: pan-x` to\n // the element will prevent vertical page scrolling. We can't add that automatically\n // because it must be set before the touchstart event.\n if (\n scrollable.scrollHeight === scrollable.clientHeight &&\n scrollable.scrollWidth === scrollable.clientWidth\n ) {\n e.preventDefault();\n }\n };\n\n const onTouchEnd = () => {\n if (restoreScrollableStyles) {\n restoreScrollableStyles();\n }\n };\n\n const onFocus = (e: FocusEvent) => {\n const target = e.target as HTMLElement;\n if (willOpenKeyboard(target)) {\n setupStyles();\n\n // Apply a transform to trick Safari into thinking the input is at the top of the page\n // so it doesn't try to scroll it into view.\n target.style.transform = \"translateY(-2000px)\";\n requestAnimationFrame(() => {\n target.style.transform = \"\";\n\n // This will have prevented the browser from scrolling the focused element into view,\n // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.\n if (visualViewport) {\n if (visualViewport.height < window.innerHeight) {\n // If the keyboard is already visible, do this after one additional frame\n // to wait for the transform to be removed.\n requestAnimationFrame(() => {\n scrollIntoView(target);\n });\n } else {\n // Otherwise, wait for the visual viewport to resize before scrolling so we can\n // measure the correct position to scroll to.\n visualViewport.addEventListener(\n \"resize\",\n () => scrollIntoView(target),\n { once: true },\n );\n }\n }\n });\n }\n };\n\n let restoreStyles: null | (() => void) = null;\n const setupStyles = () => {\n if (restoreStyles) {\n return;\n }\n\n const onWindowScroll = () => {\n // Last resort. If the window scrolled, scroll it back to the top.\n // It should always be at the top because the body will have a negative margin (see below).\n window.scrollTo(0, 0);\n };\n\n // Record the original scroll position so we can restore it.\n // Then apply a negative margin to the body to offset it by the scroll position. This will\n // enable us to scroll the window to the top, which is required for the rest of this to work.\n const scrollX = window.pageXOffset;\n const scrollY = window.pageYOffset;\n\n restoreStyles = createChainedFunction(\n addEvent(window, \"scroll\", onWindowScroll),\n setStyle(\n document.documentElement,\n \"paddingRight\",\n `${window.innerWidth - document.documentElement.clientWidth}px`,\n ),\n setStyle(document.documentElement, \"overflow\", \"hidden\"),\n setStyle(document.body, \"marginTop\", `-${scrollY}px`),\n () => {\n window.scrollTo(scrollX, scrollY);\n },\n );\n\n // Scroll to the top. The negative margin on the body will make this appear the same.\n window.scrollTo(0, 0);\n };\n\n const removeEvents = createChainedFunction(\n addEvent(document, \"touchstart\", onTouchStart, {\n passive: false,\n capture: true,\n }),\n addEvent(document, \"touchmove\", onTouchMove, {\n passive: false,\n capture: true,\n }),\n addEvent(document, \"touchend\", onTouchEnd, {\n passive: false,\n capture: true,\n }),\n addEvent(document, \"focus\", onFocus, true),\n );\n\n return () => {\n // Restore styles and scroll the page back to where it was.\n restoreScrollableStyles?.();\n restoreStyles?.();\n removeEvents();\n };\n}\n\n// Sets a CSS property on an element, and returns a function to revert it to the previous value.\nfunction setStyle(element: HTMLElement, style: string, value: string) {\n const cur = element.style[style as any];\n element.style[style as any] = value;\n\n return () => {\n element.style[style as any] = cur;\n };\n}\n\n// Adds an event listener to an element, and returns a function to remove it.\nfunction addEvent<K extends keyof GlobalEventHandlersEventMap>(\n target: Document | Window,\n event: K,\n handler: (this: Document | Window, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions,\n) {\n // internal function, so it's ok to ignore the difficult to fix type error\n // @ts-expect-error\n target.addEventListener(event, handler, options);\n return () => {\n // @ts-expect-error\n target.removeEventListener(event, handler, options);\n };\n}\n\nfunction scrollIntoView(target: Element) {\n const root = document.scrollingElement || document.documentElement;\n let nextTarget: Element | null = target;\n while (nextTarget && nextTarget !== root) {\n // Find the parent scrollable element and adjust the scroll position if the target is not already in view.\n const scrollable = getScrollParent(nextTarget);\n if (\n scrollable !== document.documentElement &&\n scrollable !== document.body &&\n scrollable !== nextTarget\n ) {\n const scrollableTop = scrollable.getBoundingClientRect().top;\n const targetTop = nextTarget.getBoundingClientRect().top;\n if (targetTop > scrollableTop + nextTarget.clientHeight) {\n scrollable.scrollTop += targetTop - scrollableTop;\n }\n }\n\n nextTarget = scrollable.parentElement;\n }\n}\n\nfunction willOpenKeyboard(target: Element) {\n return (\n (target instanceof HTMLInputElement &&\n !nonTextInputTypes.has(target.type)) ||\n target instanceof HTMLTextAreaElement ||\n (target instanceof HTMLElement && target.isContentEditable)\n );\n}\n\nfunction isScrollable(\n node: Element | null,\n checkForOverflow?: boolean,\n): boolean {\n if (!node) {\n return false;\n }\n const style = window.getComputedStyle(node);\n let isScrollable = /(auto|scroll)/.test(\n style.overflow + style.overflowX + style.overflowY,\n );\n\n if (isScrollable && checkForOverflow) {\n isScrollable =\n node.scrollHeight !== node.clientHeight ||\n node.scrollWidth !== node.clientWidth;\n }\n\n return isScrollable;\n}\n\nfunction getScrollParent(node: Element, checkForOverflow?: boolean): Element {\n let scrollableNode: Element | null = node;\n if (isScrollable(scrollableNode, checkForOverflow)) {\n scrollableNode = scrollableNode.parentElement;\n }\n\n while (scrollableNode && !isScrollable(scrollableNode, checkForOverflow)) {\n scrollableNode = scrollableNode.parentElement;\n }\n\n return (\n scrollableNode || document.scrollingElement || document.documentElement\n );\n}\n\nfunction testPlatform(re: RegExp) {\n return typeof window !== \"undefined\" && window.navigator != null\n ? re.test(\n // @ts-expect-error userAgentData is only supported in Chrome 90+\n window.navigator.userAgentData?.platform || window.navigator.platform,\n )\n : false;\n}\n\nfunction cached(fn: () => boolean) {\n if (process.env.NODE_ENV === \"test\") {\n return fn;\n }\n\n let res: boolean | null = null;\n return () => {\n if (res == null) {\n res = fn();\n }\n return res;\n };\n}\n\nconst isMac = cached(() => testPlatform(/^Mac/i));\n\nconst isIPhone = cached(() => testPlatform(/^iPhone/i));\n\nconst isIPad = cached(\n () =>\n testPlatform(/^iPad/i) ||\n // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.\n (isMac() && navigator.maxTouchPoints > 1),\n);\n\nconst isIOS = cached(() => isIPhone() || isIPad());\n"],"names":["useIsomorphicLayoutEffect","createChainedFunction","isScrollable"],"mappings":";;;;;AA0BA,MAAM,cAAiB,GAAA,OAAO,QAAa,KAAA,WAAA,IA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MAAM,YAAA,CAAa,UAAU,CAAC,CAAA;AAEtD,MAAM,MAAS,GAAA,MAAA;AAAA,EACb,MACE,aAAa,QAAQ,CAAA;AAAA,EAEpB,KAAA,EAAW,IAAA,SAAA,CAAU,cAAiB,GAAA;AAC3C,CAAA;AAEA,MAAM,QAAQ,MAAO,CAAA,MAAM,QAAS,EAAA,IAAK,QAAQ,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"usePreventScroll.js","sources":["../src/utils/usePreventScroll.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Taken from https://github.com/adobe/react-spectrum/blob/cc08a8dbc95d3648eee47bc9b8e0ed48448e0da2/packages/%40react-aria/overlays/src/usePreventScroll.ts#L44 but refactored.\n * This hook currently doesn't use `useWindow` because in a desktop environment the main window is only the window they typically want locked.\n * If we need to in the future we can add an option to specify which window should be affected.\n */\n\nimport { createChainedFunction } from \"./createChainedFunction\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\ninterface PreventScrollOptions {\n /** Whether the scroll lock is disabled. */\n isDisabled?: boolean;\n}\n\nconst visualViewport = typeof document !== \"undefined\" && window.visualViewport;\n\n// HTML input types that do not cause the software keyboard to appear.\nconst nonTextInputTypes = new Set([\n \"checkbox\",\n \"radio\",\n \"range\",\n \"color\",\n \"file\",\n \"image\",\n \"button\",\n \"submit\",\n \"reset\",\n]);\n\n// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position\nlet preventScrollCount = 0;\nlet restore: () => void;\n\n/**\n * Prevents scrolling on the document body on mount, and\n * restores it on unmount. Also ensures that content does not\n * shift due to the scrollbars disappearing.\n */\nexport function usePreventScroll(options: PreventScrollOptions = {}) {\n const { isDisabled } = options;\n\n useIsomorphicLayoutEffect(() => {\n if (isDisabled) {\n return;\n }\n\n preventScrollCount++;\n if (preventScrollCount === 1) {\n if (isIOS()) {\n restore = preventScrollMobileSafari();\n } else {\n restore = preventScrollStandard();\n }\n }\n\n return () => {\n preventScrollCount--;\n if (preventScrollCount === 0) {\n restore();\n }\n };\n }, [isDisabled]);\n}\n\n// For most browsers, all we need to do is set `overflow: hidden` on the root element, and\n// add some padding to prevent the page from shifting when the scrollbar is hidden.\nfunction preventScrollStandard() {\n return createChainedFunction(\n setStyle(\n document.documentElement,\n \"paddingRight\",\n `${window.innerWidth - document.documentElement.clientWidth}px`,\n ),\n setStyle(document.documentElement, \"overflow\", \"hidden\"),\n );\n}\n\n// Mobile Safari is a whole different beast. Even with overflow: hidden,\n// it still scrolls the page in many situations:\n//\n// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.\n// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of\n// it, so it becomes scrollable.\n// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.\n// This may cause even fixed position elements to scroll off the screen.\n// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always\n// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.\n//\n// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:\n//\n// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling\n// on the window.\n// 2. Set `overscroll-behavior: contain` on nested scrollable regions so they do not scroll the page when at\n// the top or bottom. Work around a bug where this does not work when the element does not actually overflow\n// by preventing default in a `touchmove` event.\n// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.\n// 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top\n// of the page, which prevents it from scrolling the page. After the input is focused, scroll the element\n// into view ourselves, without scrolling the whole page.\n// 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the\n// same visually, but makes the actual scroll position always zero. This is required to make all of the\n// above work or Safari will still try to scroll the page when focusing an input.\n// 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting\n// to navigate to an input with the next/previous buttons that's outside a modal.\nfunction preventScrollMobileSafari() {\n let scrollable: Element;\n let restoreScrollableStyles: () => void;\n const onTouchStart = (e: TouchEvent) => {\n // Store the nearest scrollable parent element from the element that the user touched.\n scrollable = getScrollParent(e.target as Element, true);\n if (\n scrollable === document.documentElement &&\n scrollable === document.body\n ) {\n return;\n }\n\n // Prevent scrolling up when at the top and scrolling down when at the bottom\n // of a nested scrollable area, otherwise mobile Safari will start scrolling\n // the window instead.\n if (\n scrollable instanceof HTMLElement &&\n window.getComputedStyle(scrollable).overscrollBehavior === \"auto\"\n ) {\n restoreScrollableStyles = setStyle(\n scrollable,\n \"overscrollBehavior\",\n \"contain\",\n );\n }\n };\n\n const onTouchMove = (e: TouchEvent) => {\n // Prevent scrolling the window.\n if (\n !scrollable ||\n scrollable === document.documentElement ||\n scrollable === document.body\n ) {\n e.preventDefault();\n return;\n }\n\n // overscroll-behavior should prevent scroll chaining, but currently does not\n // if the element doesn't actually overflow. https://bugs.webkit.org/show_bug.cgi?id=243452\n // This checks that both the width and height do not overflow, otherwise we might\n // block horizontal scrolling too. In that case, adding `touch-action: pan-x` to\n // the element will prevent vertical page scrolling. We can't add that automatically\n // because it must be set before the touchstart event.\n if (\n scrollable.scrollHeight === scrollable.clientHeight &&\n scrollable.scrollWidth === scrollable.clientWidth\n ) {\n e.preventDefault();\n }\n };\n\n const onTouchEnd = () => {\n if (restoreScrollableStyles) {\n restoreScrollableStyles();\n }\n };\n\n const onFocus = (e: FocusEvent) => {\n const target = e.target as HTMLElement;\n if (willOpenKeyboard(target)) {\n setupStyles();\n\n // Apply a transform to trick Safari into thinking the input is at the top of the page\n // so it doesn't try to scroll it into view.\n target.style.transform = \"translateY(-2000px)\";\n requestAnimationFrame(() => {\n target.style.transform = \"\";\n\n // This will have prevented the browser from scrolling the focused element into view,\n // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.\n if (visualViewport) {\n if (visualViewport.height < window.innerHeight) {\n // If the keyboard is already visible, do this after one additional frame\n // to wait for the transform to be removed.\n requestAnimationFrame(() => {\n scrollIntoView(target);\n });\n } else {\n // Otherwise, wait for the visual viewport to resize before scrolling so we can\n // measure the correct position to scroll to.\n visualViewport.addEventListener(\n \"resize\",\n () => scrollIntoView(target),\n { once: true },\n );\n }\n }\n });\n }\n };\n\n let restoreStyles: null | (() => void) = null;\n const setupStyles = () => {\n if (restoreStyles) {\n return;\n }\n\n const onWindowScroll = () => {\n // Last resort. If the window scrolled, scroll it back to the top.\n // It should always be at the top because the body will have a negative margin (see below).\n window.scrollTo(0, 0);\n };\n\n // Record the original scroll position so we can restore it.\n // Then apply a negative margin to the body to offset it by the scroll position. This will\n // enable us to scroll the window to the top, which is required for the rest of this to work.\n const scrollX = window.pageXOffset;\n const scrollY = window.pageYOffset;\n\n restoreStyles = createChainedFunction(\n addEvent(window, \"scroll\", onWindowScroll),\n setStyle(\n document.documentElement,\n \"paddingRight\",\n `${window.innerWidth - document.documentElement.clientWidth}px`,\n ),\n setStyle(document.documentElement, \"overflow\", \"hidden\"),\n setStyle(document.body, \"marginTop\", `-${scrollY}px`),\n () => {\n window.scrollTo(scrollX, scrollY);\n },\n );\n\n // Scroll to the top. The negative margin on the body will make this appear the same.\n window.scrollTo(0, 0);\n };\n\n const removeEvents = createChainedFunction(\n addEvent(document, \"touchstart\", onTouchStart, {\n passive: false,\n capture: true,\n }),\n addEvent(document, \"touchmove\", onTouchMove, {\n passive: false,\n capture: true,\n }),\n addEvent(document, \"touchend\", onTouchEnd, {\n passive: false,\n capture: true,\n }),\n addEvent(document, \"focus\", onFocus, true),\n );\n\n return () => {\n // Restore styles and scroll the page back to where it was.\n restoreScrollableStyles?.();\n restoreStyles?.();\n removeEvents();\n };\n}\n\n// Sets a CSS property on an element, and returns a function to revert it to the previous value.\nfunction setStyle(element: HTMLElement, style: string, value: string) {\n const cur = element.style[style as any];\n element.style[style as any] = value;\n\n return () => {\n element.style[style as any] = cur;\n };\n}\n\n// Adds an event listener to an element, and returns a function to remove it.\nfunction addEvent<K extends keyof GlobalEventHandlersEventMap>(\n target: Document | Window,\n event: K,\n handler: (this: Document | Window, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions,\n) {\n // internal function, so it's ok to ignore the difficult to fix type error\n // @ts-expect-error\n target.addEventListener(event, handler, options);\n return () => {\n // @ts-expect-error\n target.removeEventListener(event, handler, options);\n };\n}\n\nfunction scrollIntoView(target: Element) {\n const root = document.scrollingElement || document.documentElement;\n let nextTarget: Element | null = target;\n while (nextTarget && nextTarget !== root) {\n // Find the parent scrollable element and adjust the scroll position if the target is not already in view.\n const scrollable = getScrollParent(nextTarget);\n if (\n scrollable !== document.documentElement &&\n scrollable !== document.body &&\n scrollable !== nextTarget\n ) {\n const scrollableTop = scrollable.getBoundingClientRect().top;\n const targetTop = nextTarget.getBoundingClientRect().top;\n if (targetTop > scrollableTop + nextTarget.clientHeight) {\n scrollable.scrollTop += targetTop - scrollableTop;\n }\n }\n\n nextTarget = scrollable.parentElement;\n }\n}\n\nfunction willOpenKeyboard(target: Element) {\n return (\n (target instanceof HTMLInputElement &&\n !nonTextInputTypes.has(target.type)) ||\n target instanceof HTMLTextAreaElement ||\n (target instanceof HTMLElement && target.isContentEditable)\n );\n}\n\nfunction isScrollable(\n node: Element | null,\n checkForOverflow?: boolean,\n): boolean {\n if (!node) {\n return false;\n }\n const style = window.getComputedStyle(node);\n let isScrollable = /(auto|scroll)/.test(\n style.overflow + style.overflowX + style.overflowY,\n );\n\n if (isScrollable && checkForOverflow) {\n isScrollable =\n node.scrollHeight !== node.clientHeight ||\n node.scrollWidth !== node.clientWidth;\n }\n\n return isScrollable;\n}\n\nfunction getScrollParent(node: Element, checkForOverflow?: boolean): Element {\n let scrollableNode: Element | null = node;\n if (isScrollable(scrollableNode, checkForOverflow)) {\n scrollableNode = scrollableNode.parentElement;\n }\n\n while (scrollableNode && !isScrollable(scrollableNode, checkForOverflow)) {\n scrollableNode = scrollableNode.parentElement;\n }\n\n return (\n scrollableNode || document.scrollingElement || document.documentElement\n );\n}\n\nfunction testPlatform(re: RegExp) {\n return typeof window !== \"undefined\" && window.navigator != null\n ? re.test(\n // @ts-expect-error userAgentData is only supported in Chrome 90+\n window.navigator.userAgentData?.platform || window.navigator.platform,\n )\n : false;\n}\n\nfunction cached(fn: () => boolean) {\n if (process.env.NODE_ENV === \"test\") {\n return fn;\n }\n\n let res: boolean | null = null;\n return () => {\n if (res == null) {\n res = fn();\n }\n return res;\n };\n}\n\nconst isMac = cached(() => testPlatform(/^Mac/i));\n\nconst isIPhone = cached(() => testPlatform(/^iPhone/i));\n\nconst isIPad = cached(\n () =>\n testPlatform(/^iPad/i) ||\n // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.\n (isMac() && navigator.maxTouchPoints > 1),\n);\n\nconst isIOS = cached(() => isIPhone() || isIPad());\n"],"names":["useIsomorphicLayoutEffect","createChainedFunction","isScrollable"],"mappings":";;;;;AA0BA,MAAM,cAAA,GAAiB,OAAO,QAAA,KAAa,WAAA,IAAe,MAAA,CAAO,cAAA;AAGjE,MAAM,iBAAA,uBAAwB,GAAA,CAAI;AAAA,EAChC,UAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGD,IAAI,kBAAA,GAAqB,CAAA;AACzB,IAAI,OAAA;AAOG,SAAS,gBAAA,CAAiB,OAAA,GAAgC,EAAC,EAAG;AACnE,EAAA,MAAM,EAAE,YAAW,GAAI,OAAA;AAEvB,EAAAA,mDAAA,CAA0B,MAAM;AAC9B,IAAA,IAAI,UAAA,EAAY;A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IAAK,QAAQ,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrevious.js","sources":["../src/utils/usePrevious.ts"],"sourcesContent":["import { type DependencyList, useEffect, useRef } from \"react\";\n\nexport function usePrevious<T>(\n value: T,\n deps: DependencyList = [],\n initialValue?: T,\n): T | undefined {\n const ref = useRef<T | undefined>(initialValue);\n\n useEffect(() => {\n ref.current = value;\n // biome-ignore lint/correctness/useExhaustiveDependencies: usePrevious is takes a dependency list to control when it updates, so we don't need to include value in the deps array.\n }, deps);\n return ref.current;\n}\n"],"names":["useRef","useEffect"],"mappings":";;;;AAEO,SAAS,
|
|
1
|
+
{"version":3,"file":"usePrevious.js","sources":["../src/utils/usePrevious.ts"],"sourcesContent":["import { type DependencyList, useEffect, useRef } from \"react\";\n\nexport function usePrevious<T>(\n value: T,\n deps: DependencyList = [],\n initialValue?: T,\n): T | undefined {\n const ref = useRef<T | undefined>(initialValue);\n\n useEffect(() => {\n ref.current = value;\n // biome-ignore lint/correctness/useExhaustiveDependencies: usePrevious is takes a dependency list to control when it updates, so we don't need to include value in the deps array.\n }, deps);\n return ref.current;\n}\n"],"names":["useRef","useEffect"],"mappings":";;;;AAEO,SAAS,WAAA,CACd,KAAA,EACA,IAAA,GAAuB,IACvB,YAAA,EACe;AACf,EAAA,MAAM,GAAA,GAAMA,aAAsB,YAAY,CAAA;AAE9C,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,GAAA,CAAI,OAAA,GAAU,KAAA;AAAA,EAEhB,GAAG,IAAI,CAAA;AACP,EAAA,OAAO,GAAA,CAAI,OAAA;AACb;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizeObserver.js","sources":["../src/utils/useResizeObserver.ts"],"sourcesContent":["import { type RefObject, useEffect } from \"react\";\nimport { ownerWindow } from \"./ownerWindow\";\n\nexport interface UseResizeObserverProps {\n ref: RefObject<HTMLElement>;\n onResize: () => void;\n}\n\nexport function useResizeObserver({ ref, onResize }: UseResizeObserverProps) {\n useEffect(() => {\n const element = ref?.current;\n if (!element) return;\n\n const win = ownerWindow(element);\n\n const resizeObserver = new win.ResizeObserver((entries) => {\n requestAnimationFrame(() => {\n if (entries.length === 0) return;\n\n onResize();\n });\n });\n resizeObserver.observe(element);\n\n return () => {\n if (element) {\n resizeObserver.unobserve(element);\n }\n };\n }, [ref, onResize]);\n}\n"],"names":["useEffect","ownerWindow"],"mappings":";;;;;AAQO,SAAS,
|
|
1
|
+
{"version":3,"file":"useResizeObserver.js","sources":["../src/utils/useResizeObserver.ts"],"sourcesContent":["import { type RefObject, useEffect } from \"react\";\nimport { ownerWindow } from \"./ownerWindow\";\n\nexport interface UseResizeObserverProps {\n ref: RefObject<HTMLElement>;\n onResize: () => void;\n}\n\nexport function useResizeObserver({ ref, onResize }: UseResizeObserverProps) {\n useEffect(() => {\n const element = ref?.current;\n if (!element) return;\n\n const win = ownerWindow(element);\n\n const resizeObserver = new win.ResizeObserver((entries) => {\n requestAnimationFrame(() => {\n if (entries.length === 0) return;\n\n onResize();\n });\n });\n resizeObserver.observe(element);\n\n return () => {\n if (element) {\n resizeObserver.unobserve(element);\n }\n };\n }, [ref, onResize]);\n}\n"],"names":["useEffect","ownerWindow"],"mappings":";;;;;AAQO,SAAS,iBAAA,CAAkB,EAAE,GAAA,EAAK,QAAA,EAAS,EAA2B;AAC3E,EAAAA,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAU,GAAA,IAAA,IAAA,GAAA,MAAA,GAAA,GAAA,CAAK,OAAA;AACrB,IAAA,IAAI,CAAC,OAAA,EAAS;AAEd,IAAA,MAAM,GAAA,GAAMC,wBAAY,OAAO,CAAA;AAE/B,IAAA,MAAM,cAAA,GAAiB,IAAI,GAAA,CAAI,cAAA,CAAe,CAAC,OAAA,KAAY;AACzD,MAAA,qBAAA,CAAsB,MAAM;AAC1B,QAAA,IAAI,OAAA,CAAQ,WAAW,CAAA,EAAG;AAE1B,QAAA,QAAA,EAAS;AAAA,MACX,CAAC,CAAA;AAAA,IACH,CAAC,CAAA;AACD,IAAA,cAAA,CAAe,QAAQ,OAAO,CAAA;AAE9B,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,OAAA,EAAS;AACX,QAAA,cAAA,CAAe,UAAU,OAAO,CAAA;AAAA,MAClC;AAAA,IACF,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,GAAA,EAAK,QAAQ,CAAC,CAAA;AACpB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResponsiveProp.js","sources":["../src/utils/useResponsiveProp.ts"],"sourcesContent":["import type { Breakpoints } from \"../breakpoints\";\nimport { useBreakpoints } from \"../salt-provider\";\nimport { useViewport } from \"../viewport\";\n\ntype BreakpointProp<T> = {\n [K in keyof Breakpoints]?: T;\n};\n\nexport type ResponsiveProp<T> = T | BreakpointProp<T>;\n\nexport const getCurrentBreakpoint = (\n breakpoints: Breakpoints,\n width: number,\n) => {\n const breakpointList = Object.entries(breakpoints).sort(\n ([, a], [, b]) => a - b,\n );\n const [currentBreakpoint] = (\n breakpointList as [keyof Breakpoints, number][]\n ).reduce(\n (acc, val) => {\n const [, accWidth] = acc;\n const [breakpoint, breakpointWidth] = val;\n if (breakpointWidth <= width && breakpointWidth > accWidth) {\n return [breakpoint, breakpointWidth];\n }\n return acc;\n },\n breakpointList[0] as [keyof Breakpoints, number],\n );\n\n return currentBreakpoint;\n};\n\nexport const useCurrentBreakpoint = () => {\n const viewport = useViewport();\n\n const breakpoints = useBreakpoints();\n\n return getCurrentBreakpoint(breakpoints, viewport);\n};\n\nexport const useOrderedBreakpoints = () => {\n const breakpoints = useBreakpoints();\n\n return Object.entries(breakpoints)\n .sort(([, a], [, b]) => a - b)\n .map(([key]) => key);\n};\n\nconst isObject = <T>(\n value: T,\n): value is Record<string | number | symbol, any> => {\n const type = typeof value;\n return value !== null && (type === \"object\" || type === \"function\");\n};\n\nconst hasBreakpointValues = <T>(\n value: ResponsiveProp<T>,\n breakpoints: Breakpoints,\n): value is BreakpointProp<T> => {\n return (\n isObject(value) && Object.keys(value).every((key) => key in breakpoints)\n );\n};\n\nconst getResponsiveValue = <T>(\n breakpointValues: BreakpointProp<T>,\n breakpoints: Breakpoints,\n viewport: keyof Breakpoints,\n defaultValue: T,\n) => {\n return Object.entries(breakpointValues).reduce<[number, T]>(\n (acc, val) => {\n const [accWidth] = acc;\n const [breakpoint, breakpointValue] = val;\n\n const breakpointWidth =\n breakpoints[breakpoint as keyof typeof breakpoints];\n\n if (\n breakpointWidth >= accWidth &&\n breakpointWidth <= breakpoints[viewport]\n ) {\n return [breakpointWidth, breakpointValue];\n }\n\n return acc;\n },\n [0, defaultValue],\n )[1];\n};\n\nexport const useResponsiveProp = <T>(\n value: ResponsiveProp<T>,\n defaultValue: T,\n) => {\n const breakpoints = useBreakpoints();\n const viewport = useViewport();\n // return early if the values are the same\n if (value === defaultValue) return defaultValue;\n\n const currentViewport = getCurrentBreakpoint(breakpoints, viewport);\n if (hasBreakpointValues(value, breakpoints)) {\n return getResponsiveValue(\n value,\n breakpoints,\n currentViewport,\n defaultValue,\n );\n }\n return value;\n};\n\nfunction isBreakpointProp<T>(\n value: ResponsiveProp<T>,\n): value is BreakpointProp<T> {\n return typeof value === \"object\" && !Array.isArray(value);\n}\n\nexport function resolveResponsiveValue<Value>(\n value: ResponsiveProp<Value>,\n matchedBreakpoints: (keyof Breakpoints)[],\n) {\n if (value && isBreakpointProp(value)) {\n for (const breakpoint of matchedBreakpoints) {\n if (value[breakpoint] != null) {\n return value[breakpoint];\n }\n }\n return undefined;\n }\n return value;\n}\n"],"names":["useViewport","useBreakpoints"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"useResponsiveProp.js","sources":["../src/utils/useResponsiveProp.ts"],"sourcesContent":["import type { Breakpoints } from \"../breakpoints\";\nimport { useBreakpoints } from \"../salt-provider\";\nimport { useViewport } from \"../viewport\";\n\ntype BreakpointProp<T> = {\n [K in keyof Breakpoints]?: T;\n};\n\nexport type ResponsiveProp<T> = T | BreakpointProp<T>;\n\nexport const getCurrentBreakpoint = (\n breakpoints: Breakpoints,\n width: number,\n) => {\n const breakpointList = Object.entries(breakpoints).sort(\n ([, a], [, b]) => a - b,\n );\n const [currentBreakpoint] = (\n breakpointList as [keyof Breakpoints, number][]\n ).reduce(\n (acc, val) => {\n const [, accWidth] = acc;\n const [breakpoint, breakpointWidth] = val;\n if (breakpointWidth <= width && breakpointWidth > accWidth) {\n return [breakpoint, breakpointWidth];\n }\n return acc;\n },\n breakpointList[0] as [keyof Breakpoints, number],\n );\n\n return currentBreakpoint;\n};\n\nexport const useCurrentBreakpoint = () => {\n const viewport = useViewport();\n\n const breakpoints = useBreakpoints();\n\n return getCurrentBreakpoint(breakpoints, viewport);\n};\n\nexport const useOrderedBreakpoints = () => {\n const breakpoints = useBreakpoints();\n\n return Object.entries(breakpoints)\n .sort(([, a], [, b]) => a - b)\n .map(([key]) => key);\n};\n\nconst isObject = <T>(\n value: T,\n): value is Record<string | number | symbol, any> => {\n const type = typeof value;\n return value !== null && (type === \"object\" || type === \"function\");\n};\n\nconst hasBreakpointValues = <T>(\n value: ResponsiveProp<T>,\n breakpoints: Breakpoints,\n): value is BreakpointProp<T> => {\n return (\n isObject(value) && Object.keys(value).every((key) => key in breakpoints)\n );\n};\n\nconst getResponsiveValue = <T>(\n breakpointValues: BreakpointProp<T>,\n breakpoints: Breakpoints,\n viewport: keyof Breakpoints,\n defaultValue: T,\n) => {\n return Object.entries(breakpointValues).reduce<[number, T]>(\n (acc, val) => {\n const [accWidth] = acc;\n const [breakpoint, breakpointValue] = val;\n\n const breakpointWidth =\n breakpoints[breakpoint as keyof typeof breakpoints];\n\n if (\n breakpointWidth >= accWidth &&\n breakpointWidth <= breakpoints[viewport]\n ) {\n return [breakpointWidth, breakpointValue];\n }\n\n return acc;\n },\n [0, defaultValue],\n )[1];\n};\n\nexport const useResponsiveProp = <T>(\n value: ResponsiveProp<T>,\n defaultValue: T,\n) => {\n const breakpoints = useBreakpoints();\n const viewport = useViewport();\n // return early if the values are the same\n if (value === defaultValue) return defaultValue;\n\n const currentViewport = getCurrentBreakpoint(breakpoints, viewport);\n if (hasBreakpointValues(value, breakpoints)) {\n return getResponsiveValue(\n value,\n breakpoints,\n currentViewport,\n defaultValue,\n );\n }\n return value;\n};\n\nfunction isBreakpointProp<T>(\n value: ResponsiveProp<T>,\n): value is BreakpointProp<T> {\n return typeof value === \"object\" && !Array.isArray(value);\n}\n\nexport function resolveResponsiveValue<Value>(\n value: ResponsiveProp<Value>,\n matchedBreakpoints: (keyof Breakpoints)[],\n) {\n if (value && isBreakpointProp(value)) {\n for (const breakpoint of matchedBreakpoints) {\n if (value[breakpoint] != null) {\n return value[breakpoint];\n }\n }\n return undefined;\n }\n return value;\n}\n"],"names":["useViewport","useBreakpoints"],"mappings":";;;;;AAUO,MAAM,oBAAA,GAAuB,CAClC,WAAA,EACA,KAAA,KACG;AACH,EAAA,MAAM,cAAA,GAAiB,MAAA,CAAO,OAAA,CAAQ,WAAW,CAAA,CAAE,IAAA;AAAA,IACjD,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA,KAAM,CAAA,GAAI;AAAA,GACxB;AACA,EAAA,MAAM,CAAC,iBAAiB,CAAA,GACtB,cAAA,CACA,MAAA;AAAA,IACA,CAAC,KAAK,GAAA,KAAQ;AACZ,MAAA,MAAM,GAAG,QAAQ,CAAA,GAAI,GAAA;AACrB,MAAA,MAAM,CAAC,UAAA,EAAY,eAAe,CAAA,GAAI,GAAA;AACtC,MAAA,IAAI,eAAA,IAAmB,KAAA,IAAS,eAAA,GAAkB,QAAA,EAAU;AAC1D,QAAA,OAAO,CAAC,YAAY,eAAe,CAAA;AAAA,MACrC;AACA,MAAA,OAAO,GAAA;AAAA,IACT,CAAA;AAAA,IACA,eAAe,CAAC;AAAA,GAClB;AAEA,EAAA,OAAO,iBAAA;AACT;AAEO,MAAM,uBAAuB,MAAM;AACxC,EAAA,MAAM,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B,eAAe,CAAA;AAAA,MAC1C;AAEA,MAAA,OAAO,GAAA;AAAA,IACT,CAAA;AAAA,IACA,CAAC,GAAG,YAAY;AAAA,IAChB,CAAC,CAAA;AACL,CAAA;AAEO,MAAM,iBAAA,GAAoB,CAC/B,KAAA,EACA,YAAA,KACG;AACH,EAAA,MAAM,cAAcA,2BAAA,EAAe;AACnC,EAAA,MAAM,WAAWD,4BAAA,EAAY;AAE7B,EAAA,IAAI,KAAA,KAAU,cAAc,OAAO,YAAA;AAEnC,EAAA,MAAM,eAAA,GAAkB,oBAAA,CAAqB,WAAA,EAAa,QAAQ,CAAA;AAClE,EAAA,IAAI,mBAAA,CAAoB,KAAA,EAAO,WAAW,CAAA,EAAG;AAC3C,IAAA,OAAO,kBAAA;AAAA,MACL,KAAA;AAAA,MACA,WAAA;AAAA,MACA,eAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,iBACP,KAAA,EAC4B;AAC5B,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC1D;AAEO,SAAS,sBAAA,CACd,OACA,kBAAA,EACA;AACA,EAAA,IAAI,KAAA,IAAS,gBAAA,CAAiB,KAAK,CAAA,EAAG;AACpC,IAAA,KAAA,MAAW,cAAc,kBAAA,EAAoB;AAC3C,MAAA,IAAI,KAAA,CAAM,UAAU,CAAA,IAAK,IAAA,EAAM;AAC7B,QAAA,OAAO,MAAM,UAAU,CAAA;AAAA,MACzB;AAAA,IACF;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA;AACT;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useValueEffect.js","sources":["../src/utils/useValueEffect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type Dispatch, type MutableRefObject, useRef, useState } from \"react\";\nimport { useEventCallback } from \"./useEventCallback\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\ntype SetValueAction<S> = (prev: S) => Generator<any, void, unknown>;\n\n// This hook works like `useState`, but when setting the value, you pass a generator function\n// that can yield multiple values. Each yielded value updates the state and waits for the next\n// layout effect, then continues the generator. This allows sequential updates to state to be\n// written linearly.\nexport function useValueEffect<S>(\n defaultValue: S | (() => S),\n): [S, Dispatch<SetValueAction<S>>] {\n const [value, setValue] = useState(defaultValue);\n const effect: MutableRefObject<Generator<S> | null> =\n useRef<Generator<S> | null>(null);\n\n // Store the function in a ref so we can always access the current version\n // which has the proper `value` in scope.\n const nextRef = useEventCallback(() => {\n if (!effect.current) {\n return;\n }\n // Run the generator to the next yield.\n const newValue = effect.current.next();\n\n // If the generator is done, reset the effect.\n if (newValue.done) {\n effect.current = null;\n return;\n }\n\n // If the value is the same as the current value,\n // then continue to the next yield. Otherwise,\n // set the value in state and wait for the next layout effect.\n if (value === newValue.value) {\n nextRef();\n } else {\n setValue(newValue.value);\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n // If there is an effect currently running, continue to the next yield.\n if (effect.current) {\n nextRef();\n }\n });\n\n const queue: Dispatch<SetValueAction<S>> = useEventCallback((fn) => {\n effect.current = fn(value);\n nextRef();\n });\n\n return [value, queue];\n}\n"],"names":["useState","useRef","useEventCallback","useIsomorphicLayoutEffect"],"mappings":";;;;;;AAsBO,SAAS,eACd,
|
|
1
|
+
{"version":3,"file":"useValueEffect.js","sources":["../src/utils/useValueEffect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type Dispatch, type MutableRefObject, useRef, useState } from \"react\";\nimport { useEventCallback } from \"./useEventCallback\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\ntype SetValueAction<S> = (prev: S) => Generator<any, void, unknown>;\n\n// This hook works like `useState`, but when setting the value, you pass a generator function\n// that can yield multiple values. Each yielded value updates the state and waits for the next\n// layout effect, then continues the generator. This allows sequential updates to state to be\n// written linearly.\nexport function useValueEffect<S>(\n defaultValue: S | (() => S),\n): [S, Dispatch<SetValueAction<S>>] {\n const [value, setValue] = useState(defaultValue);\n const effect: MutableRefObject<Generator<S> | null> =\n useRef<Generator<S> | null>(null);\n\n // Store the function in a ref so we can always access the current version\n // which has the proper `value` in scope.\n const nextRef = useEventCallback(() => {\n if (!effect.current) {\n return;\n }\n // Run the generator to the next yield.\n const newValue = effect.current.next();\n\n // If the generator is done, reset the effect.\n if (newValue.done) {\n effect.current = null;\n return;\n }\n\n // If the value is the same as the current value,\n // then continue to the next yield. Otherwise,\n // set the value in state and wait for the next layout effect.\n if (value === newValue.value) {\n nextRef();\n } else {\n setValue(newValue.value);\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n // If there is an effect currently running, continue to the next yield.\n if (effect.current) {\n nextRef();\n }\n });\n\n const queue: Dispatch<SetValueAction<S>> = useEventCallback((fn) => {\n effect.current = fn(value);\n nextRef();\n });\n\n return [value, queue];\n}\n"],"names":["useState","useRef","useEventCallback","useIsomorphicLayoutEffect"],"mappings":";;;;;;AAsBO,SAAS,eACd,YAAA,EACkC;AAClC,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,eAAS,YAAY,CAAA;AAC/C,EAAA,MAAM,MAAA,GACJC,aAA4B,IAAI,CAAA;AAIlC,EAAA,MAAM,OAAA,GAAUC,kCAAiB,MAAM;AACrC,IAAA,IAAI,CAAC,OAAO,OAAA,EAAS;AACnB,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAK;AAGrC,IAAA,IAAI,SAAS,IAAA,EAAM;AACjB,MAAA,MAAA,CAAO,OAAA,GAAU,IAAA;AACjB,MAAA;AAAA,IACF;AAKA,IAAA,IAAI,KAAA,KAAU,SAAS,KAAA,EAAO;AAC5B,MAAA,OAAA,EAAQ;AAAA,IACV,CAAA,MAAO;AACL,MAAA,QAAA,CAAS,SAAS,KAAK,CAAA;AAAA,IACzB;AAAA,EACF,CAAC,CAAA;AAED,EAAAC,mDAAA,CAA0B,MAAM;AAE9B,IAAA,IAAI,OAAO,OAAA,EAAS;AAClB,MAAA,OAAA,EAAQ;AAAA,IACV;AAAA,EACF,CAAC,CAAA;AAED,EAAA,MAAM,KAAA,GAAqCD,iCAAA,CAAiB,CAAC,EAAA,KAAO;AAClE,IAAA,MAAA,CAAO,OAAA,GAAU,GAAG,KAAK,CAAA;AACzB,IAAA,OAAA,EAAQ;AAAA,EACV,CAAC,CAAA;AAED,EAAA,OAAO,CAAC,OAAO,KAAK,CAAA;AACtB;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var createContext = require('../utils/createContext.js');
|
|
6
|
+
require('clsx');
|
|
7
|
+
require('../utils/useFloatingUI/useFloatingUI.js');
|
|
8
|
+
require('../utils/useId.js');
|
|
9
|
+
require('../salt-provider/SaltProvider.js');
|
|
10
|
+
require('../viewport/ViewportProvider.js');
|
|
11
|
+
|
|
12
|
+
const SubMenuContext = createContext.createContext(
|
|
13
|
+
"SubMenuContext",
|
|
14
|
+
{ depth: -1, iconPaddingCount: 0 }
|
|
15
|
+
);
|
|
16
|
+
const useSubMenuContext = () => {
|
|
17
|
+
return React.useContext(SubMenuContext);
|
|
18
|
+
};
|
|
19
|
+
function SubMenuProvider({
|
|
20
|
+
children,
|
|
21
|
+
directIcons,
|
|
22
|
+
setDirectIcons
|
|
23
|
+
}) {
|
|
24
|
+
const { depth, iconPaddingCount } = useSubMenuContext();
|
|
25
|
+
const context = React.useMemo(
|
|
26
|
+
() => ({
|
|
27
|
+
depth: depth + 1,
|
|
28
|
+
iconPaddingCount: iconPaddingCount + (directIcons.length > 0 ? 1 : 0),
|
|
29
|
+
setDirectIcons
|
|
30
|
+
}),
|
|
31
|
+
[depth, iconPaddingCount, directIcons, setDirectIcons]
|
|
32
|
+
);
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SubMenuContext.Provider, { value: context, children });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.SubMenuContext = SubMenuContext;
|
|
37
|
+
exports.SubMenuProvider = SubMenuProvider;
|
|
38
|
+
exports.useSubMenuContext = useSubMenuContext;
|
|
39
|
+
//# sourceMappingURL=SubMenuContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubMenuContext.js","sources":["../src/vertical-navigation/SubMenuContext.tsx"],"sourcesContent":["import {\n type Dispatch,\n type ReactNode,\n type SetStateAction,\n useContext,\n useMemo,\n} from \"react\";\nimport { createContext } from \"../utils\";\n\ntype SubMenuContextValue = {\n depth: number;\n iconPaddingCount: number;\n setDirectIcons?: Dispatch<SetStateAction<string[]>>;\n};\n\nexport const SubMenuContext = createContext<SubMenuContextValue>(\n \"SubMenuContext\",\n { depth: -1, iconPaddingCount: 0 },\n);\n\nexport const useSubMenuContext = () => {\n return useContext(SubMenuContext);\n};\n\nexport function SubMenuProvider({\n children,\n directIcons,\n setDirectIcons,\n}: {\n children: ReactNode;\n directIcons: string[];\n setDirectIcons?: Dispatch<SetStateAction<string[]>>;\n}) {\n const { depth, iconPaddingCount } = useSubMenuContext();\n\n const context = useMemo(\n () => ({\n depth: depth + 1,\n iconPaddingCount: iconPaddingCount + (directIcons.length > 0 ? 1 : 0),\n setDirectIcons,\n }),\n [depth, iconPaddingCount, directIcons, setDirectIcons],\n );\n\n return (\n <SubMenuContext.Provider value={context}>\n {children}\n </SubMenuContext.Provider>\n );\n}\n"],"names":["createContext","useContext","useMemo"],"mappings":";;;;;;;;;;;AAeO,MAAM,cAAA,GAAiBA,2BAAA;AAAA,EAC5B,gBAAA;AAAA,EACA,EAAE,KAAA,EAAO,EAAA,EAAI,gBAAA,EAAkB,CAAA;AACjC;AAEO,MAAM,oBAAoB,MAAM;AACrC,EAAA,OAAOC,iBAAW,cAAc,CAAA;AAClC;AAEO,SAAS,eAAA,CAAgB;AAAA,EAC9B,QAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAA,EAIG;AACD,EAAA,MAAM,EAAE,KAAA,EAAO,gBAAA,EAAiB,GAAI,iBAAA,EAAkB;AAEtD,EAAA,MAAM,OAAA,GAAUC,aAAA;AAAA,IACd,OAAO;AAAA,MACL,OAAO,KAAA,GAAQ,CAAA;AAAA,MACf,gBAAA,EAAkB,gBAAA,IAAoB,WAAA,CAAY,MAAA,GAAS,IAAI,CAAA,GAAI,CAAA,CAAA;AAAA,MACnE;AAAA,KACF,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,gBAAA,EAAkB,WAAA,EAAa,cAAc;AAAA,GACvD;AAEA,EAAA,sCACG,cAAA,CAAe,QAAA,EAAf,EAAwB,KAAA,EAAO,SAC7B,QAAA,EACH,CAAA;AAEJ;;;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".saltVerticalNavigation ol {\n display: flex;\n flex-direction: column;\n gap: var(--salt-spacing-fixed-100);\n list-style: none;\n padding: 0;\n margin: 0;\n position: relative;\n}\n\n.saltVerticalNavigationSubMenu > .saltDivider-horizontal,\n.saltVerticalNavigationItem > .saltDivider-horizontal,\n.saltVerticalNavigation ol > .saltDivider-horizontal {\n margin-bottom: calc(var(--salt-size-fixed-100) * -1);\n}\n\n.saltVerticalNavigation [data-has-direct-icons=\"false\"] .saltCollapsiblePanel-inner {\n margin-bottom: calc(var(--salt-size-fixed-100) * -1);\n}\n\n.saltVerticalNavigation [data-has-direct-icons=\"false\"] .saltCollapsiblePanel-inner .saltVerticalNavigationSubMenu {\n border-bottom: var(--salt-size-fixed-100) var(--salt-borderStyle-solid) var(--salt-separable-tertiary-borderColor);\n}\n\n/* Only show border at the top-level */\n\n.saltVerticalNavigation .saltCollapsiblePanel-inner .saltCollapsiblePanel-inner,\n.saltVerticalNavigation .saltCollapsiblePanel[aria-hidden=\"true\"] .saltCollapsiblePanel-inner {\n margin-bottom: 0;\n}\n\n.saltVerticalNavigation .saltCollapsiblePanel-inner .saltCollapsiblePanel-inner .saltVerticalNavigationSubMenu,\n.saltVerticalNavigation .saltCollapsiblePanel[aria-hidden=\"true\"] .saltCollapsiblePanel-inner .saltVerticalNavigationSubMenu {\n border-bottom: none;\n}\n";
|
|
4
|
+
|
|
5
|
+
module.exports = css_248z;
|
|
6
|
+
//# sourceMappingURL=VerticalNavigation.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VerticalNavigation.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var styles = require('@salt-ds/styles');
|
|
5
|
+
var window = require('@salt-ds/window');
|
|
6
|
+
var clsx = require('clsx');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var makePrefixer = require('../utils/makePrefixer.js');
|
|
9
|
+
require('../utils/useFloatingUI/useFloatingUI.js');
|
|
10
|
+
require('../utils/useId.js');
|
|
11
|
+
require('../salt-provider/SaltProvider.js');
|
|
12
|
+
require('../viewport/ViewportProvider.js');
|
|
13
|
+
var SubMenuContext = require('./SubMenuContext.js');
|
|
14
|
+
var VerticalNavigation$1 = require('./VerticalNavigation.css.js');
|
|
15
|
+
|
|
16
|
+
const withBaseName = makePrefixer.makePrefixer("saltVerticalNavigation");
|
|
17
|
+
const VerticalNavigation = React.forwardRef(function VerticalNavigation2(props, ref) {
|
|
18
|
+
const { appearance = "bordered", children, className, ...rest } = props;
|
|
19
|
+
const targetWindow = window.useWindow();
|
|
20
|
+
styles.useComponentCssInjection({
|
|
21
|
+
testId: "salt-vertical-navigation",
|
|
22
|
+
css: VerticalNavigation$1,
|
|
23
|
+
window: targetWindow
|
|
24
|
+
});
|
|
25
|
+
const [directIcons, setDirectIcons] = React.useState([]);
|
|
26
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SubMenuContext.SubMenuProvider, { directIcons, setDirectIcons, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
|
+
"nav",
|
|
28
|
+
{
|
|
29
|
+
ref,
|
|
30
|
+
className: clsx.clsx(withBaseName(), withBaseName(appearance), className),
|
|
31
|
+
...rest,
|
|
32
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("ol", { "data-has-direct-icons": directIcons.length > 0, children })
|
|
33
|
+
}
|
|
34
|
+
) });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
exports.VerticalNavigation = VerticalNavigation;
|
|
38
|
+
//# sourceMappingURL=VerticalNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VerticalNavigation.js","sources":["../src/vertical-navigation/VerticalNavigation.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport { type ComponentPropsWithoutRef, forwardRef, useState } from \"react\";\nimport { makePrefixer } from \"../utils\";\nimport { SubMenuProvider } from \"./SubMenuContext\";\nimport verticalNavigationCss from \"./VerticalNavigation.css\";\n\nexport interface VerticalNavigationProps\n extends ComponentPropsWithoutRef<\"nav\"> {\n /**\n * The appearance of the tabs. Defaults to \"bordered\".\n */\n appearance?: \"indicator\" | \"bordered\";\n}\n\nconst withBaseName = makePrefixer(\"saltVerticalNavigation\");\n\nexport const VerticalNavigation = forwardRef<\n HTMLElement,\n VerticalNavigationProps\n>(function VerticalNavigation(props, ref) {\n const { appearance = \"bordered\", children, className, ...rest } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-vertical-navigation\",\n css: verticalNavigationCss,\n window: targetWindow,\n });\n\n const [directIcons, setDirectIcons] = useState<string[]>([]);\n\n return (\n <SubMenuProvider directIcons={directIcons} setDirectIcons={setDirectIcons}>\n <nav\n ref={ref}\n className={clsx(withBaseName(), withBaseName(appearance), className)}\n {...rest}\n >\n <ol data-has-direct-icons={directIcons.length > 0}>{children}</ol>\n </nav>\n </SubMenuProvider>\n );\n});\n"],"names":["makePrefixer","forwardRef","VerticalNavigation","useWindow","useComponentCssInjection","verticalNavigationCss","useState","jsx","SubMenuProvider","clsx"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAM,YAAA,GAAeA,0BAAa,wBAAwB,CAAA;AAEnD,MAAM,kBAAA,GAAqBC,gBAAA,CAGhC,SAASC,mBAAAA,CAAmB,OAAO,GAAA,EAAK;AACxC,EAAA,MAAM,EAAE,UAAA,GAAa,UAAA,EAAY,UAAU,SAAA,EAAW,GAAG,MAAK,GAAI,KAAA;AAElE,EAAA,MAAM,eAAeC,gBAAA,EAAU;AAC/B,EAAAC,+BAAA,CAAyB;AAAA,IACvB,MAAA,EAAQ,0BAAA;AAAA,IACR,GAAA,EAAKC,oBAAA;AAAA,IACL,MAAA,EAAQ;AAAA,GACT,CAAA;AAED,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAIC,cAAA,CAAmB,EAAE,CAAA;AAE3D,EAAA,uBACEC,cAAA,CAACC,8BAAA,EAAA,EAAgB,WAAA,EAA0B,cAAA,EACzC,QAAA,kBAAAD,cAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAWE,SAAA,CAAK,YAAA,IAAgB,YAAA,CAAa,UAAU,GAAG,SAAS,CAAA;AAAA,MAClE,GAAG,IAAA;AAAA,MAEJ,yCAAC,IAAA,EAAA,EAAG,uBAAA,EAAuB,WAAA,CAAY,MAAA,GAAS,GAAI,QAAA,EAAS;AAAA;AAAA,GAC/D,EACF,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var createContext = require('../utils/createContext.js');
|
|
7
|
+
var makePrefixer = require('../utils/makePrefixer.js');
|
|
8
|
+
require('../utils/useFloatingUI/useFloatingUI.js');
|
|
9
|
+
require('../utils/useId.js');
|
|
10
|
+
require('../salt-provider/SaltProvider.js');
|
|
11
|
+
require('../viewport/ViewportProvider.js');
|
|
12
|
+
var SubMenuContext = require('./SubMenuContext.js');
|
|
13
|
+
|
|
14
|
+
const withBaseName = makePrefixer.makePrefixer("saltVerticalNavigationItem");
|
|
15
|
+
const VerticalNavigationItemContext = createContext.createContext(
|
|
16
|
+
"saltVerticalNavigationItemContext",
|
|
17
|
+
{
|
|
18
|
+
active: false,
|
|
19
|
+
focusVisible: false,
|
|
20
|
+
setFocusVisible: () => {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
function useVerticalNavigationItem() {
|
|
25
|
+
return React.useContext(VerticalNavigationItemContext);
|
|
26
|
+
}
|
|
27
|
+
const VerticalNavigationItem = React.forwardRef(function VerticalNavigationItem2(props, ref) {
|
|
28
|
+
const { children, className, active = false, style, ...rest } = props;
|
|
29
|
+
const { depth } = SubMenuContext.useSubMenuContext();
|
|
30
|
+
const [focusVisible, setFocusVisible] = React.useState(false);
|
|
31
|
+
const context = React.useMemo(
|
|
32
|
+
() => ({
|
|
33
|
+
active,
|
|
34
|
+
focusVisible,
|
|
35
|
+
setFocusVisible
|
|
36
|
+
}),
|
|
37
|
+
[active, focusVisible]
|
|
38
|
+
);
|
|
39
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VerticalNavigationItemContext.Provider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
40
|
+
"li",
|
|
41
|
+
{
|
|
42
|
+
ref,
|
|
43
|
+
className: clsx.clsx(withBaseName(), className),
|
|
44
|
+
style: { "--verticalNavigationItem-depth": depth, ...style },
|
|
45
|
+
...rest,
|
|
46
|
+
children
|
|
47
|
+
}
|
|
48
|
+
) });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
exports.VerticalNavigationItem = VerticalNavigationItem;
|
|
52
|
+
exports.useVerticalNavigationItem = useVerticalNavigationItem;
|
|
53
|
+
//# sourceMappingURL=VerticalNavigationItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VerticalNavigationItem.js","sources":["../src/vertical-navigation/VerticalNavigationItem.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport {\n type ComponentPropsWithoutRef,\n type CSSProperties,\n type Dispatch,\n forwardRef,\n type SetStateAction,\n useContext,\n useMemo,\n useState,\n} from \"react\";\nimport { createContext, makePrefixer } from \"../utils\";\nimport { useSubMenuContext } from \"./SubMenuContext\";\n\nexport interface VerticalNavigationItemProps\n extends ComponentPropsWithoutRef<\"li\"> {\n active?: boolean;\n}\n\nconst withBaseName = makePrefixer(\"saltVerticalNavigationItem\");\n\ntype VerticalNavigationItemContextType = {\n active: boolean;\n focusVisible: boolean;\n setFocusVisible: Dispatch<SetStateAction<boolean>>;\n};\n\nconst VerticalNavigationItemContext =\n createContext<VerticalNavigationItemContextType>(\n \"saltVerticalNavigationItemContext\",\n {\n active: false,\n focusVisible: false,\n setFocusVisible: () => {},\n },\n );\n\nexport function useVerticalNavigationItem() {\n return useContext(VerticalNavigationItemContext);\n}\n\nexport const VerticalNavigationItem = forwardRef<\n HTMLLIElement,\n VerticalNavigationItemProps\n>(function VerticalNavigationItem(props, ref) {\n const { children, className, active = false, style, ...rest } = props;\n\n const { depth } = useSubMenuContext();\n const [focusVisible, setFocusVisible] = useState(false);\n\n const context = useMemo(\n () => ({\n active,\n focusVisible,\n setFocusVisible,\n }),\n [active, focusVisible],\n );\n\n return (\n <VerticalNavigationItemContext.Provider value={context}>\n <li\n ref={ref}\n className={clsx(withBaseName(), className)}\n style={\n { \"--verticalNavigationItem-depth\": depth, ...style } as CSSProperties\n }\n {...rest}\n >\n {children}\n </li>\n </VerticalNavigationItemContext.Provider>\n );\n});\n"],"names":["makePrefixer","createContext","useContext","forwardRef","VerticalNavigationItem","useSubMenuContext","useState","useMemo","jsx","clsx"],"mappings":";;;;;;;;;;;;;AAmBA,MAAM,YAAA,GAAeA,0BAAa,4BAA4B,CAAA;AAQ9D,MAAM,6BAAA,GACJC,2BAAA;AAAA,EACE,mCAAA;AAAA,EACA;AAAA,IACE,MAAA,EAAQ,KAAA;AAAA,IACR,YAAA,EAAc,KAAA;AAAA,IACd,iBAAiB,MAAM;AAAA,IAAC;AAAA;AAE5B,CAAA;AAEK,SAAS,yBAAA,GAA4B;AAC1C,EAAA,OAAOC,iBAAW,6BAA6B,CAAA;AACjD;AAEO,MAAM,sBAAA,GAAyBC,gBAAA,CAGpC,SAASC,uBAAAA,CAAuB,OAAO,GAAA,EAAK;AAC5C,EAAA,MAAM,EAAE,UAAU,SAAA,EAAW,MAAA,GAAS,OAAO,KAAA,EAAO,GAAG,MAAK,GAAI,KAAA;AAEhE,EAAA,MAAM,EAAE,KAAA,EAAM,GAAIC,gCAAA,EAAkB;AACpC,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAIC,eAAS,KAAK,CAAA;AAEtD,EAAA,MAAM,OAAA,GAAUC,aAAA;AAAA,IACd,OAAO;AAAA,MACL,MAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,QAAQ,YAAY;AAAA,GACvB;AAEA,EAAA,uBACEC,cAAA,CAAC,6BAAA,CAA8B,QAAA,EAA9B,EAAuC,OAAO,OAAA,EAC7C,QAAA,kBAAAA,cAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,SAAA,EAAWC,SAAA,CAAK,YAAA,EAAa,EAAG,SAAS,CAAA;AAAA,MACzC,KAAA,EACE,EAAE,gCAAA,EAAkC,KAAA,EAAO,GAAG,KAAA,EAAM;AAAA,MAErD,GAAG,IAAA;AAAA,MAEH;AAAA;AAAA,GACH,EACF,CAAA;AAEJ,CAAC;;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".saltVerticalNavigationItemContent {\n --verticalNavigationItem-iconPadding: calc(var(--saltVerticalNavigationItem-iconPaddingMultiplier, 0) * (var(--salt-size-icon) + var(--salt-spacing-100)));\n --verticalNavigationItem-depthPadding: calc(var(--salt-spacing-100) * max(0, calc(var(--verticalNavigationItem-depth, 0) - 1)));\n}\n\n.saltVerticalNavigation-indicator .saltVerticalNavigationItemContent {\n --verticalNavigationItem-paddingLeft: calc(var(--salt-spacing-150) + var(--salt-size-indicator) + var(--verticalNavigationItem-depthPadding) + var(--verticalNavigationItem-iconPadding));\n --verticalNavigationItem-paddingBlock: var(--salt-spacing-50);\n}\n\n.saltVerticalNavigation-bordered .saltVerticalNavigationItemContent {\n --verticalNavigationItem-paddingLeft: calc(var(--salt-spacing-100) + var(--verticalNavigationItem-depthPadding) + var(--verticalNavigationItem-iconPadding));\n --verticalNavigationItem-paddingBlock: calc(var(--salt-spacing-50) - var(--salt-size-fixed-100));\n}\n\n.saltVerticalNavigationItemContent {\n display: flex;\n flex-direction: row;\n gap: var(--salt-spacing-100);\n appearance: none;\n -webkit-appearance: none;\n min-height: calc(var(--salt-size-base) + var(--salt-spacing-100));\n min-width: 4em;\n padding: var(--verticalNavigationItem-paddingBlock) var(--salt-spacing-100) var(--verticalNavigationItem-paddingBlock) var(--verticalNavigationItem-paddingLeft);\n position: relative;\n flex-shrink: 0;\n box-sizing: border-box;\n border-radius: var(--salt-palette-corner-weak, 0);\n overflow: hidden;\n\n cursor: var(--salt-cursor-hover);\n color: var(--salt-content-primary-foreground);\n font-weight: var(--salt-text-h4-fontWeight);\n font-family: var(--salt-text-h4-fontFamily);\n text-align: var(--salt-text-textAlign);\n letter-spacing: var(--salt-text-letterSpacing);\n line-height: var(--salt-text-h4-lineHeight);\n font-size: var(--salt-text-h4-fontSize);\n}\n\n.saltVerticalNavigation-indicator .saltVerticalNavigationItemContent-active,\n.saltVerticalNavigation-indicator .saltVerticalNavigationItemContent-active:hover {\n background: var(--salt-navigable-accent-background-active);\n}\n\n.saltVerticalNavigation-indicator .saltVerticalNavigationItemContent::before {\n left: var(--salt-spacing-50);\n content: \"\";\n position: absolute;\n height: var(--salt-size-base);\n border-radius: var(--salt-palette-corner-strongest);\n width: var(--salt-size-indicator);\n}\n\n.saltVerticalNavigation-indicator .saltVerticalNavigationItemContent-active::before {\n background: var(--salt-navigable-accent-indicator-active);\n}\n\n.saltVerticalNavigation-bordered .saltVerticalNavigationItemContent {\n border: var(--salt-size-fixed-100) var(--salt-borderStyle-solid) transparent;\n}\n\n.saltVerticalNavigation-bordered .saltVerticalNavigationItemContent-active,\n.saltVerticalNavigation-bordered .saltVerticalNavigationItemContent-active:hover {\n background: var(--salt-navigable-accent-background-active);\n border-color: var(--salt-navigable-accent-borderColor-active);\n}\n\n.saltVerticalNavigationItemContent .saltIcon,\n.saltVerticalNavigationItemContent .saltBadge {\n min-height: var(--salt-text-lineHeight);\n}\n\n.saltVerticalNavigationItemContent-focused {\n outline: var(--salt-focused-outline);\n outline-offset: calc(var(--salt-size-fixed-100) * -2);\n z-index: 1;\n}\n\n.saltVerticalNavigationItemContent:hover {\n background: var(--salt-overlayable-background-hover);\n}\n\n.saltVerticalNavigation .saltVerticalNavigationItemContent-active,\n.saltVerticalNavigation .saltVerticalNavigationSubMenu .saltVerticalNavigationItemContent-active {\n font-weight: var(--salt-text-h4-fontWeight);\n}\n\n@supports selector(:has(*)) {\n .saltVerticalNavigationItemContent-active:hover:has(.saltVerticalNavigationItemTrigger[aria-controls]) {\n background: linear-gradient(var(--salt-overlayable-background-hover), var(--salt-overlayable-background-hover)) var(--salt-navigable-accent-background-active);\n }\n}\n";
|
|
4
|
+
|
|
5
|
+
module.exports = css_248z;
|
|
6
|
+
//# sourceMappingURL=VerticalNavigationItemContent.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VerticalNavigationItemContent.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|