@react-md/core 1.0.0-next.20 → 1.0.0-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CoreProviders.d.ts +1 -0
- package/dist/CoreProviders.js +1 -0
- package/dist/CoreProviders.js.map +1 -1
- package/dist/NoSsr.d.ts +3 -1
- package/dist/NoSsr.js +3 -1
- package/dist/NoSsr.js.map +1 -1
- package/dist/RootHtml.d.ts +1 -1
- package/dist/RootHtml.js +1 -1
- package/dist/RootHtml.js.map +1 -1
- package/dist/SsrProvider.d.ts +1 -0
- package/dist/SsrProvider.js +1 -0
- package/dist/SsrProvider.js.map +1 -1
- package/dist/_a11y.scss +187 -0
- package/dist/_base.scss +479 -0
- package/dist/_box-shadows.scss +80 -71
- package/dist/_colors.scss +283 -279
- package/dist/_core.scss +5 -483
- package/dist/_object-fit.scss +27 -23
- package/dist/_utils.scss +225 -225
- package/dist/app-bar/AppBar.d.ts +3 -1
- package/dist/app-bar/AppBar.js +3 -1
- package/dist/app-bar/AppBar.js.map +1 -1
- package/dist/app-bar/AppBarTitle.d.ts +2 -1
- package/dist/app-bar/AppBarTitle.js +2 -1
- package/dist/app-bar/AppBarTitle.js.map +1 -1
- package/dist/app-bar/_app-bar.scss +112 -105
- package/dist/autocomplete/Autocomplete.d.ts +81 -2
- package/dist/autocomplete/Autocomplete.js +4 -2
- package/dist/autocomplete/Autocomplete.js.map +1 -1
- package/dist/autocomplete/AutocompleteChip.d.ts +1 -0
- package/dist/autocomplete/AutocompleteChip.js +1 -0
- package/dist/autocomplete/AutocompleteChip.js.map +1 -1
- package/dist/autocomplete/AutocompleteCircularProgress.d.ts +1 -0
- package/dist/autocomplete/AutocompleteCircularProgress.js +1 -0
- package/dist/autocomplete/AutocompleteCircularProgress.js.map +1 -1
- package/dist/autocomplete/AutocompleteClearButton.d.ts +1 -0
- package/dist/autocomplete/AutocompleteClearButton.js +4 -2
- package/dist/autocomplete/AutocompleteClearButton.js.map +1 -1
- package/dist/autocomplete/AutocompleteDropdownButton.d.ts +1 -0
- package/dist/autocomplete/AutocompleteDropdownButton.js +1 -0
- package/dist/autocomplete/AutocompleteDropdownButton.js.map +1 -1
- package/dist/autocomplete/AutocompleteListboxChildren.d.ts +1 -3
- package/dist/autocomplete/AutocompleteListboxChildren.js.map +1 -1
- package/dist/autocomplete/_autocomplete.scss +125 -71
- package/dist/autocomplete/autocompleteStyles.d.ts +3 -0
- package/dist/autocomplete/autocompleteStyles.js +5 -2
- package/dist/autocomplete/autocompleteStyles.js.map +1 -1
- package/dist/autocomplete/types.d.ts +128 -82
- package/dist/autocomplete/types.js.map +1 -1
- package/dist/autocomplete/useAutocomplete.d.ts +3 -0
- package/dist/autocomplete/useAutocomplete.js +17 -17
- package/dist/autocomplete/useAutocomplete.js.map +1 -1
- package/dist/autocomplete/utils.d.ts +3 -6
- package/dist/autocomplete/utils.js.map +1 -1
- package/dist/avatar/Avatar.d.ts +2 -1
- package/dist/avatar/Avatar.js +2 -1
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/avatar/_avatar.scss +81 -77
- package/dist/badge/Badge.d.ts +8 -4
- package/dist/badge/Badge.js +8 -4
- package/dist/badge/Badge.js.map +1 -1
- package/dist/badge/_badge.scss +72 -68
- package/dist/box/Box.d.ts +4 -3
- package/dist/box/Box.js +4 -3
- package/dist/box/Box.js.map +1 -1
- package/dist/box/_box.scss +115 -119
- package/dist/button/AsyncButton.d.ts +3 -2
- package/dist/button/AsyncButton.js +4 -3
- package/dist/button/AsyncButton.js.map +1 -1
- package/dist/button/Button.d.ts +11 -9
- package/dist/button/Button.js +11 -9
- package/dist/button/Button.js.map +1 -1
- package/dist/button/ButtonUnstyled.d.ts +1 -0
- package/dist/button/ButtonUnstyled.js +2 -1
- package/dist/button/ButtonUnstyled.js.map +1 -1
- package/dist/button/TooltippedButton.d.ts +3 -2
- package/dist/button/TooltippedButton.js +2 -1
- package/dist/button/TooltippedButton.js.map +1 -1
- package/dist/button/_button.scss +128 -98
- package/dist/button/{buttonStyles.d.ts → styles.d.ts} +10 -0
- package/dist/button/{buttonStyles.js → styles.js} +9 -1
- package/dist/button/styles.js.map +1 -0
- package/dist/card/Card.d.ts +9 -10
- package/dist/card/Card.js +9 -10
- package/dist/card/Card.js.map +1 -1
- package/dist/card/CardContent.d.ts +1 -0
- package/dist/card/CardContent.js +1 -0
- package/dist/card/CardContent.js.map +1 -1
- package/dist/card/CardFooter.d.ts +1 -0
- package/dist/card/CardFooter.js +1 -0
- package/dist/card/CardFooter.js.map +1 -1
- package/dist/card/CardHeader.d.ts +1 -0
- package/dist/card/CardHeader.js +1 -0
- package/dist/card/CardHeader.js.map +1 -1
- package/dist/card/CardSubtitle.d.ts +1 -0
- package/dist/card/CardSubtitle.js +1 -0
- package/dist/card/CardSubtitle.js.map +1 -1
- package/dist/card/CardTitle.d.ts +2 -1
- package/dist/card/CardTitle.js +1 -0
- package/dist/card/CardTitle.js.map +1 -1
- package/dist/card/ClickableCard.d.ts +3 -1
- package/dist/card/ClickableCard.js +3 -1
- package/dist/card/ClickableCard.js.map +1 -1
- package/dist/card/_card.scss +76 -71
- package/dist/chip/Chip.d.ts +5 -3
- package/dist/chip/Chip.js +5 -3
- package/dist/chip/Chip.js.map +1 -1
- package/dist/chip/_chip.scss +247 -33
- package/dist/cssUtils.d.ts +1 -1
- package/dist/cssUtils.js.map +1 -1
- package/dist/dialog/Dialog.d.ts +9 -10
- package/dist/dialog/Dialog.js +9 -10
- package/dist/dialog/Dialog.js.map +1 -1
- package/dist/dialog/DialogContent.d.ts +2 -0
- package/dist/dialog/DialogContent.js +5 -2
- package/dist/dialog/DialogContent.js.map +1 -1
- package/dist/dialog/DialogFooter.d.ts +2 -0
- package/dist/dialog/DialogFooter.js +5 -2
- package/dist/dialog/DialogFooter.js.map +1 -1
- package/dist/dialog/DialogHeader.d.ts +14 -2
- package/dist/dialog/DialogHeader.js +8 -2
- package/dist/dialog/DialogHeader.js.map +1 -1
- package/dist/dialog/DialogTitle.d.ts +2 -0
- package/dist/dialog/DialogTitle.js +5 -2
- package/dist/dialog/DialogTitle.js.map +1 -1
- package/dist/dialog/FixedDialog.d.ts +11 -10
- package/dist/dialog/FixedDialog.js +13 -12
- package/dist/dialog/FixedDialog.js.map +1 -1
- package/dist/dialog/_dialog.scss +167 -22
- package/dist/dialog/styles.d.ts +12 -6
- package/dist/dialog/styles.js +11 -5
- package/dist/dialog/styles.js.map +1 -1
- package/dist/divider/Divider.d.ts +3 -1
- package/dist/divider/Divider.js +3 -1
- package/dist/divider/Divider.js.map +1 -1
- package/dist/divider/_divider.scss +68 -0
- package/dist/divider/styles.js.map +1 -1
- package/dist/draggable/_draggable.scss +16 -0
- package/dist/draggable/useDraggable.d.ts +1 -0
- package/dist/draggable/useDraggable.js +1 -0
- package/dist/draggable/useDraggable.js.map +1 -1
- package/dist/error-boundary/ErrorBoundary.d.ts +58 -0
- package/dist/error-boundary/ErrorBoundary.js +99 -0
- package/dist/error-boundary/ErrorBoundary.js.map +1 -0
- package/dist/error-boundary/context.d.ts +11 -0
- package/dist/error-boundary/context.js +12 -0
- package/dist/error-boundary/context.js.map +1 -0
- package/dist/error-boundary/types.d.ts +16 -0
- package/dist/error-boundary/types.js +7 -0
- package/dist/error-boundary/types.js.map +1 -0
- package/dist/error-boundary/useErrorBoundary.d.ts +25 -0
- package/dist/error-boundary/useErrorBoundary.js +33 -0
- package/dist/error-boundary/useErrorBoundary.js.map +1 -0
- package/dist/expansion-panel/ExpansionList.d.ts +1 -0
- package/dist/expansion-panel/ExpansionList.js +1 -0
- package/dist/expansion-panel/ExpansionList.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanel.d.ts +32 -0
- package/dist/expansion-panel/ExpansionPanel.js +32 -0
- package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.d.ts +4 -7
- package/dist/expansion-panel/ExpansionPanelHeader.js +9 -10
- package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
- package/dist/expansion-panel/_expansion-panel.scss +45 -0
- package/dist/expansion-panel/expansionPanelStyles.d.ts +20 -0
- package/dist/expansion-panel/expansionPanelStyles.js +12 -0
- package/dist/expansion-panel/expansionPanelStyles.js.map +1 -1
- package/dist/expansion-panel/useExpansionList.d.ts +7 -8
- package/dist/expansion-panel/useExpansionList.js +7 -8
- package/dist/expansion-panel/useExpansionList.js.map +1 -1
- package/dist/expansion-panel/useExpansionPanels.d.ts +7 -10
- package/dist/expansion-panel/useExpansionPanels.js +7 -10
- package/dist/expansion-panel/useExpansionPanels.js.map +1 -1
- package/dist/files/FileInput.d.ts +4 -2
- package/dist/files/FileInput.js +3 -1
- package/dist/files/FileInput.js.map +1 -1
- package/dist/files/_files.scss +9 -0
- package/dist/files/styles.d.ts +1 -1
- package/dist/files/styles.js +1 -1
- package/dist/files/styles.js.map +1 -1
- package/dist/files/useFileUpload.d.ts +2 -0
- package/dist/files/useFileUpload.js +2 -0
- package/dist/files/useFileUpload.js.map +1 -1
- package/dist/focus/useFocusContainer.js +24 -23
- package/dist/focus/useFocusContainer.js.map +1 -1
- package/dist/form/Checkbox.d.ts +3 -1
- package/dist/form/Checkbox.js +3 -1
- package/dist/form/Checkbox.js.map +1 -1
- package/dist/form/Fieldset.d.ts +6 -20
- package/dist/form/Fieldset.js +6 -13
- package/dist/form/Fieldset.js.map +1 -1
- package/dist/form/Form.d.ts +2 -0
- package/dist/form/Form.js +2 -0
- package/dist/form/Form.js.map +1 -1
- package/dist/form/FormMessage.d.ts +2 -0
- package/dist/form/FormMessage.js +2 -0
- package/dist/form/FormMessage.js.map +1 -1
- package/dist/form/FormMessageContainer.d.ts +1 -0
- package/dist/form/FormMessageContainer.js +1 -0
- package/dist/form/FormMessageContainer.js.map +1 -1
- package/dist/form/FormMessageCounter.d.ts +2 -0
- package/dist/form/FormMessageCounter.js +2 -0
- package/dist/form/FormMessageCounter.js.map +1 -1
- package/dist/form/InputToggle.d.ts +4 -2
- package/dist/form/InputToggle.js +2 -0
- package/dist/form/InputToggle.js.map +1 -1
- package/dist/form/Label.d.ts +4 -5
- package/dist/form/Label.js +4 -32
- package/dist/form/Label.js.map +1 -1
- package/dist/form/Legend.d.ts +1 -0
- package/dist/form/Legend.js +1 -0
- package/dist/form/Legend.js.map +1 -1
- package/dist/form/Listbox.d.ts +1 -1
- package/dist/form/Listbox.js.map +1 -1
- package/dist/form/MenuItemCheckbox.d.ts +3 -1
- package/dist/form/MenuItemCheckbox.js +3 -1
- package/dist/form/MenuItemCheckbox.js.map +1 -1
- package/dist/form/MenuItemFileInput.d.ts +1 -0
- package/dist/form/MenuItemFileInput.js +1 -0
- package/dist/form/MenuItemFileInput.js.map +1 -1
- package/dist/form/MenuItemInputToggle.d.ts +3 -2
- package/dist/form/MenuItemInputToggle.js +1 -0
- package/dist/form/MenuItemInputToggle.js.map +1 -1
- package/dist/form/MenuItemRadio.d.ts +8 -8
- package/dist/form/MenuItemRadio.js +8 -8
- package/dist/form/MenuItemRadio.js.map +1 -1
- package/dist/form/MenuItemSwitch.d.ts +3 -1
- package/dist/form/MenuItemSwitch.js +3 -1
- package/dist/form/MenuItemSwitch.js.map +1 -1
- package/dist/form/MenuItemTextField.d.ts +1 -0
- package/dist/form/MenuItemTextField.js +1 -0
- package/dist/form/MenuItemTextField.js.map +1 -1
- package/dist/form/NativeSelect.d.ts +2 -0
- package/dist/form/NativeSelect.js +2 -0
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/OptGroup.d.ts +4 -1
- package/dist/form/OptGroup.js +4 -1
- package/dist/form/OptGroup.js.map +1 -1
- package/dist/form/Option.d.ts +2 -1
- package/dist/form/Option.js +1 -0
- package/dist/form/Option.js.map +1 -1
- package/dist/form/Password.d.ts +3 -1
- package/dist/form/Password.js +3 -1
- package/dist/form/Password.js.map +1 -1
- package/dist/form/Radio.d.ts +2 -0
- package/dist/form/Radio.js +2 -0
- package/dist/form/Radio.js.map +1 -1
- package/dist/form/Select.d.ts +5 -28
- package/dist/form/Select.js +4 -27
- package/dist/form/Select.js.map +1 -1
- package/dist/form/Slider.d.ts +9 -2
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/SliderContainer.js +7 -11
- package/dist/form/SliderContainer.js.map +1 -1
- package/dist/form/SliderMark.js +5 -8
- package/dist/form/SliderMark.js.map +1 -1
- package/dist/form/SliderMarkLabel.js +5 -7
- package/dist/form/SliderMarkLabel.js.map +1 -1
- package/dist/form/SliderThumb.js +2 -27
- package/dist/form/SliderThumb.js.map +1 -1
- package/dist/form/SliderTrack.js +6 -12
- package/dist/form/SliderTrack.js.map +1 -1
- package/dist/form/SliderValueTooltip.js +7 -7
- package/dist/form/SliderValueTooltip.js.map +1 -1
- package/dist/form/Switch.d.ts +9 -1
- package/dist/form/Switch.js +3 -1
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/SwitchTrack.js +8 -8
- package/dist/form/SwitchTrack.js.map +1 -1
- package/dist/form/TextArea.d.ts +9 -1
- package/dist/form/TextArea.js +3 -1
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.d.ts +3 -1
- package/dist/form/TextField.js +3 -1
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/TextFieldAddon.d.ts +1 -34
- package/dist/form/TextFieldAddon.js +1 -16
- package/dist/form/TextFieldAddon.js.map +1 -1
- package/dist/form/TextFieldContainer.d.ts +13 -0
- package/dist/form/TextFieldContainer.js.map +1 -1
- package/dist/form/_form.scss +737 -10
- package/dist/form/fieldsetStyles.d.ts +19 -0
- package/dist/form/fieldsetStyles.js +14 -0
- package/dist/form/fieldsetStyles.js.map +1 -0
- package/dist/form/formConfig.js +22 -3
- package/dist/form/formConfig.js.map +1 -1
- package/dist/form/labelStyles.d.ts +5 -0
- package/dist/form/labelStyles.js +34 -0
- package/dist/form/labelStyles.js.map +1 -0
- package/dist/form/sliderStyles.d.ts +89 -0
- package/dist/form/sliderStyles.js +96 -0
- package/dist/form/sliderStyles.js.map +1 -0
- package/dist/form/switchStyles.d.ts +24 -6
- package/dist/form/switchStyles.js +18 -0
- package/dist/form/switchStyles.js.map +1 -1
- package/dist/form/textAreaStyles.d.ts +0 -6
- package/dist/form/textAreaStyles.js.map +1 -1
- package/dist/form/textFieldAddonStyles.d.ts +17 -0
- package/dist/form/textFieldAddonStyles.js +18 -0
- package/dist/form/textFieldAddonStyles.js.map +1 -0
- package/dist/form/textFieldContainerStyles.d.ts +0 -13
- package/dist/form/textFieldContainerStyles.js.map +1 -1
- package/dist/form/types.d.ts +23 -2
- package/dist/form/types.js.map +1 -1
- package/dist/form/useCheckboxGroup.d.ts +8 -0
- package/dist/form/useCheckboxGroup.js +6 -1
- package/dist/form/useCheckboxGroup.js.map +1 -1
- package/dist/form/useCombobox.d.ts +0 -1
- package/dist/form/useCombobox.js +66 -63
- package/dist/form/useCombobox.js.map +1 -1
- package/dist/form/useNumberField.d.ts +17 -7
- package/dist/form/useNumberField.js +2 -0
- package/dist/form/useNumberField.js.map +1 -1
- package/dist/form/useRadioGroup.d.ts +6 -0
- package/dist/form/useRadioGroup.js +3 -0
- package/dist/form/useRadioGroup.js.map +1 -1
- package/dist/form/useRangeSlider.d.ts +6 -1
- package/dist/form/useRangeSlider.js +6 -1
- package/dist/form/useRangeSlider.js.map +1 -1
- package/dist/form/useSlider.d.ts +4 -1
- package/dist/form/useSlider.js +4 -1
- package/dist/form/useSlider.js.map +1 -1
- package/dist/form/useTextField.d.ts +7 -1
- package/dist/form/useTextField.js +5 -1
- package/dist/form/useTextField.js.map +1 -1
- package/dist/form/validation.d.ts +1 -0
- package/dist/form/validation.js.map +1 -1
- package/dist/icon/FontIcon.d.ts +1 -0
- package/dist/icon/FontIcon.js +1 -0
- package/dist/icon/FontIcon.js.map +1 -1
- package/dist/icon/IconRotator.d.ts +2 -0
- package/dist/icon/IconRotator.js +2 -0
- package/dist/icon/IconRotator.js.map +1 -1
- package/dist/icon/MaterialIcon.d.ts +2 -0
- package/dist/icon/MaterialIcon.js +2 -0
- package/dist/icon/MaterialIcon.js.map +1 -1
- package/dist/icon/MaterialSymbol.d.ts +3 -1
- package/dist/icon/MaterialSymbol.js +3 -1
- package/dist/icon/MaterialSymbol.js.map +1 -1
- package/dist/icon/SVGIcon.d.ts +2 -0
- package/dist/icon/SVGIcon.js +2 -0
- package/dist/icon/SVGIcon.js.map +1 -1
- package/dist/icon/TextIconSpacing.d.ts +6 -2
- package/dist/icon/TextIconSpacing.js +6 -2
- package/dist/icon/TextIconSpacing.js.map +1 -1
- package/dist/icon/_icon.scss +137 -129
- package/dist/icon/config.d.ts +2 -2
- package/dist/icon/config.js +2 -2
- package/dist/icon/config.js.map +1 -1
- package/dist/icon/material.d.ts +1 -1
- package/dist/icon/material.js.map +1 -1
- package/dist/icon/styles.d.ts +2 -1
- package/dist/icon/styles.js.map +1 -1
- package/dist/interaction/Ripple.d.ts +11 -2
- package/dist/interaction/Ripple.js.map +1 -1
- package/dist/interaction/UserInteractionModeProvider.d.ts +1 -1
- package/dist/interaction/UserInteractionModeProvider.js +1 -1
- package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
- package/dist/interaction/_interaction.scss +279 -13
- package/dist/layout/LayoutAppBar.d.ts +1 -0
- package/dist/layout/LayoutAppBar.js +1 -0
- package/dist/layout/LayoutAppBar.js.map +1 -1
- package/dist/layout/LayoutNav.d.ts +9 -12
- package/dist/layout/LayoutNav.js +9 -12
- package/dist/layout/LayoutNav.js.map +1 -1
- package/dist/layout/LayoutWindowSplitter.d.ts +7 -8
- package/dist/layout/LayoutWindowSplitter.js +7 -8
- package/dist/layout/LayoutWindowSplitter.js.map +1 -1
- package/dist/layout/Main.d.ts +2 -1
- package/dist/layout/Main.js +2 -1
- package/dist/layout/Main.js.map +1 -1
- package/dist/layout/_layout.scss +106 -23
- package/dist/layout/useExpandableLayout.d.ts +1 -0
- package/dist/layout/useExpandableLayout.js +1 -0
- package/dist/layout/useExpandableLayout.js.map +1 -1
- package/dist/layout/useHorizontalLayoutTransition.d.ts +9 -6
- package/dist/layout/useHorizontalLayoutTransition.js +4 -1
- package/dist/layout/useHorizontalLayoutTransition.js.map +1 -1
- package/dist/layout/useLayoutAppBarHeight.d.ts +7 -10
- package/dist/layout/useLayoutAppBarHeight.js +7 -10
- package/dist/layout/useLayoutAppBarHeight.js.map +1 -1
- package/dist/layout/useLayoutTree.d.ts +3 -0
- package/dist/layout/useLayoutTree.js +3 -0
- package/dist/layout/useLayoutTree.js.map +1 -1
- package/dist/layout/useLayoutWindowSplitter.d.ts +4 -2
- package/dist/layout/useLayoutWindowSplitter.js +4 -2
- package/dist/layout/useLayoutWindowSplitter.js.map +1 -1
- package/dist/layout/useResizableLayout.d.ts +1 -0
- package/dist/layout/useResizableLayout.js +3 -1
- package/dist/layout/useResizableLayout.js.map +1 -1
- package/dist/layout/useTemporaryLayout.d.ts +1 -0
- package/dist/layout/useTemporaryLayout.js +1 -0
- package/dist/layout/useTemporaryLayout.js.map +1 -1
- package/dist/link/Link.d.ts +3 -1
- package/dist/link/Link.js +3 -1
- package/dist/link/Link.js.map +1 -1
- package/dist/link/SkipToMainContent.d.ts +22 -0
- package/dist/link/SkipToMainContent.js +22 -0
- package/dist/link/SkipToMainContent.js.map +1 -1
- package/dist/link/_link.scss +55 -6
- package/dist/list/List.d.ts +11 -1
- package/dist/list/List.js +5 -1
- package/dist/list/List.js.map +1 -1
- package/dist/list/ListItem.d.ts +22 -2
- package/dist/list/ListItem.js +6 -2
- package/dist/list/ListItem.js.map +1 -1
- package/dist/list/ListItemChildren.d.ts +3 -1
- package/dist/list/ListItemChildren.js +3 -1
- package/dist/list/ListItemChildren.js.map +1 -1
- package/dist/list/ListItemLink.d.ts +32 -1
- package/dist/list/ListItemLink.js +32 -1
- package/dist/list/ListItemLink.js.map +1 -1
- package/dist/list/ListSubheader.d.ts +2 -0
- package/dist/list/ListSubheader.js +2 -0
- package/dist/list/ListSubheader.js.map +1 -1
- package/dist/list/_list.scss +224 -1
- package/dist/list/listItemStyles.d.ts +0 -16
- package/dist/list/listItemStyles.js.map +1 -1
- package/dist/list/listStyles.d.ts +0 -6
- package/dist/list/listStyles.js.map +1 -1
- package/dist/media-queries/AppSizeProvider.d.ts +2 -0
- package/dist/media-queries/AppSizeProvider.js +2 -0
- package/dist/media-queries/AppSizeProvider.js.map +1 -1
- package/dist/media-queries/_media-queries.scss +111 -4
- package/dist/media-queries/useMediaQuery.d.ts +2 -0
- package/dist/media-queries/useMediaQuery.js +2 -0
- package/dist/media-queries/useMediaQuery.js.map +1 -1
- package/dist/menu/DropdownMenu.d.ts +5 -2
- package/dist/menu/DropdownMenu.js +5 -2
- package/dist/menu/DropdownMenu.js.map +1 -1
- package/dist/menu/Menu.d.ts +1 -0
- package/dist/menu/Menu.js +1 -0
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuBar.d.ts +4 -1
- package/dist/menu/MenuBar.js +4 -1
- package/dist/menu/MenuBar.js.map +1 -1
- package/dist/menu/MenuButton.d.ts +1 -0
- package/dist/menu/MenuButton.js +1 -0
- package/dist/menu/MenuButton.js.map +1 -1
- package/dist/menu/MenuItem.d.ts +1 -0
- package/dist/menu/MenuItem.js +1 -0
- package/dist/menu/MenuItem.js.map +1 -1
- package/dist/menu/MenuItemCircularProgress.d.ts +4 -6
- package/dist/menu/MenuItemCircularProgress.js +4 -6
- package/dist/menu/MenuItemCircularProgress.js.map +1 -1
- package/dist/menu/MenuItemGroup.d.ts +6 -7
- package/dist/menu/MenuItemGroup.js +6 -7
- package/dist/menu/MenuItemGroup.js.map +1 -1
- package/dist/menu/MenuItemSeparator.d.ts +1 -0
- package/dist/menu/MenuItemSeparator.js +1 -0
- package/dist/menu/MenuItemSeparator.js.map +1 -1
- package/dist/menu/MenuWidget.d.ts +0 -12
- package/dist/menu/MenuWidget.js +1 -12
- package/dist/menu/MenuWidget.js.map +1 -1
- package/dist/menu/_menu.scss +61 -0
- package/dist/menu/styles.d.ts +12 -0
- package/dist/menu/styles.js +14 -0
- package/dist/menu/styles.js.map +1 -0
- package/dist/menu/useContextMenu.d.ts +4 -1
- package/dist/menu/useContextMenu.js +4 -1
- package/dist/menu/useContextMenu.js.map +1 -1
- package/dist/movement/useKeyboardMovementProvider.d.ts +3 -3
- package/dist/movement/useKeyboardMovementProvider.js +3 -3
- package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
- package/dist/navigation/CollapsibleNavGroup.d.ts +1 -0
- package/dist/navigation/CollapsibleNavGroup.js +1 -0
- package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
- package/dist/navigation/DefaultNavigationRenderer.d.ts +1 -0
- package/dist/navigation/DefaultNavigationRenderer.js +1 -0
- package/dist/navigation/DefaultNavigationRenderer.js.map +1 -1
- package/dist/navigation/NavGroup.d.ts +1 -0
- package/dist/navigation/NavGroup.js +1 -0
- package/dist/navigation/NavGroup.js.map +1 -1
- package/dist/navigation/NavItem.d.ts +1 -0
- package/dist/navigation/NavItem.js +1 -0
- package/dist/navigation/NavItem.js.map +1 -1
- package/dist/navigation/NavItemButton.d.ts +1 -0
- package/dist/navigation/NavItemButton.js +1 -0
- package/dist/navigation/NavItemButton.js.map +1 -1
- package/dist/navigation/NavItemLink.d.ts +1 -0
- package/dist/navigation/NavItemLink.js +1 -0
- package/dist/navigation/NavItemLink.js.map +1 -1
- package/dist/navigation/NavSubheader.d.ts +1 -0
- package/dist/navigation/NavSubheader.js +1 -0
- package/dist/navigation/NavSubheader.js.map +1 -1
- package/dist/navigation/Navigation.d.ts +44 -0
- package/dist/navigation/Navigation.js +44 -0
- package/dist/navigation/Navigation.js.map +1 -1
- package/dist/navigation/_navigation.scss +47 -5
- package/dist/navigation/getTableOfContentsHeadings.d.ts +20 -0
- package/dist/navigation/getTableOfContentsHeadings.js +53 -0
- package/dist/navigation/getTableOfContentsHeadings.js.map +1 -0
- package/dist/navigation/navItemStyles.js +1 -1
- package/dist/navigation/navItemStyles.js.map +1 -1
- package/dist/navigation/types.d.ts +47 -0
- package/dist/navigation/types.js +1 -3
- package/dist/navigation/types.js.map +1 -1
- package/dist/navigation/useActiveHeadingId.d.ts +2 -12
- package/dist/navigation/useActiveHeadingId.js +1 -0
- package/dist/navigation/useActiveHeadingId.js.map +1 -1
- package/dist/navigation/useNavigationExpansion.d.ts +2 -0
- package/dist/navigation/useNavigationExpansion.js +2 -0
- package/dist/navigation/useNavigationExpansion.js.map +1 -1
- package/dist/navigation/useTableOfContentsHeadings.d.ts +3 -37
- package/dist/navigation/useTableOfContentsHeadings.js +18 -41
- package/dist/navigation/useTableOfContentsHeadings.js.map +1 -1
- package/dist/overlay/Overlay.d.ts +10 -1
- package/dist/overlay/Overlay.js +5 -2
- package/dist/overlay/Overlay.js.map +1 -1
- package/dist/overlay/_overlay.scss +35 -0
- package/dist/overlay/{overlayStyles.d.ts → styles.d.ts} +0 -6
- package/dist/overlay/{overlayStyles.js → styles.js} +1 -1
- package/dist/overlay/styles.js.map +1 -0
- package/dist/portal/Portal.d.ts +1 -0
- package/dist/portal/Portal.js +1 -0
- package/dist/portal/Portal.js.map +1 -1
- package/dist/portal/PortalContainerProvider.d.ts +1 -0
- package/dist/portal/PortalContainerProvider.js +1 -0
- package/dist/portal/PortalContainerProvider.js.map +1 -1
- package/dist/positioning/createHorizontalPosition.d.ts +6 -6
- package/dist/positioning/createHorizontalPosition.js +12 -12
- package/dist/positioning/createHorizontalPosition.js.map +1 -1
- package/dist/positioning/createVerticalPosition.d.ts +6 -6
- package/dist/positioning/createVerticalPosition.js +2 -2
- package/dist/positioning/createVerticalPosition.js.map +1 -1
- package/dist/positioning/useFixedPositioning.d.ts +1 -0
- package/dist/positioning/useFixedPositioning.js +1 -0
- package/dist/positioning/useFixedPositioning.js.map +1 -1
- package/dist/progress/CircularProgress.d.ts +3 -2
- package/dist/progress/CircularProgress.js +3 -2
- package/dist/progress/CircularProgress.js.map +1 -1
- package/dist/progress/LinearProgress.d.ts +3 -2
- package/dist/progress/LinearProgress.js +3 -2
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/_progress.scss +164 -38
- package/dist/responsive-item/ResponsiveItem.d.ts +4 -3
- package/dist/responsive-item/ResponsiveItem.js +4 -3
- package/dist/responsive-item/ResponsiveItem.js.map +1 -1
- package/dist/responsive-item/ResponsiveItemOverlay.d.ts +6 -4
- package/dist/responsive-item/ResponsiveItemOverlay.js +6 -4
- package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
- package/dist/responsive-item/_responsive-item.scss +89 -0
- package/dist/scroll/useScrollLock.d.ts +1 -0
- package/dist/scroll/useScrollLock.js +1 -0
- package/dist/scroll/useScrollLock.js.map +1 -1
- package/dist/searching/fuzzy.d.ts +2 -1
- package/dist/searching/fuzzy.js +2 -1
- package/dist/searching/fuzzy.js.map +1 -1
- package/dist/segmented-button/SegmentedButton.d.ts +3 -4
- package/dist/segmented-button/SegmentedButton.js +3 -4
- package/dist/segmented-button/SegmentedButton.js.map +1 -1
- package/dist/segmented-button/SegmentedButtonContainer.d.ts +5 -6
- package/dist/segmented-button/SegmentedButtonContainer.js +7 -8
- package/dist/segmented-button/SegmentedButtonContainer.js.map +1 -1
- package/dist/segmented-button/_segmented-button.scss +79 -33
- package/dist/segmented-button/segmentedButtonContainerStyles.d.ts +1 -1
- package/dist/segmented-button/segmentedButtonContainerStyles.js +1 -1
- package/dist/segmented-button/segmentedButtonContainerStyles.js.map +1 -1
- package/dist/sheet/Sheet.d.ts +14 -0
- package/dist/sheet/Sheet.js +2 -0
- package/dist/sheet/Sheet.js.map +1 -1
- package/dist/sheet/_sheet.scss +84 -0
- package/dist/sheet/styles.d.ts +19 -15
- package/dist/sheet/styles.js +6 -2
- package/dist/sheet/styles.js.map +1 -1
- package/dist/snackbar/DefaultToastRenderer.d.ts +1 -0
- package/dist/snackbar/DefaultToastRenderer.js +1 -0
- package/dist/snackbar/DefaultToastRenderer.js.map +1 -1
- package/dist/snackbar/Snackbar.d.ts +10 -9
- package/dist/snackbar/Snackbar.js +4 -1
- package/dist/snackbar/Snackbar.js.map +1 -1
- package/dist/snackbar/Toast.d.ts +8 -0
- package/dist/snackbar/Toast.js +1 -0
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/snackbar/ToastActionButton.d.ts +2 -1
- package/dist/snackbar/ToastActionButton.js +1 -0
- package/dist/snackbar/ToastActionButton.js.map +1 -1
- package/dist/snackbar/ToastCloseButton.d.ts +2 -1
- package/dist/snackbar/ToastCloseButton.js +1 -0
- package/dist/snackbar/ToastCloseButton.js.map +1 -1
- package/dist/snackbar/ToastContent.d.ts +1 -0
- package/dist/snackbar/ToastContent.js +1 -0
- package/dist/snackbar/ToastContent.js.map +1 -1
- package/dist/snackbar/ToastManager.d.ts +1 -1
- package/dist/snackbar/ToastManager.js +1 -1
- package/dist/snackbar/ToastManager.js.map +1 -1
- package/dist/snackbar/ToastManagerProvider.d.ts +1 -0
- package/dist/snackbar/ToastManagerProvider.js +1 -0
- package/dist/snackbar/ToastManagerProvider.js.map +1 -1
- package/dist/snackbar/_snackbar.scss +131 -3
- package/dist/snackbar/toastStyles.d.ts +0 -7
- package/dist/snackbar/toastStyles.js.map +1 -1
- package/dist/snackbar/useCurrentToastActions.d.ts +1 -0
- package/dist/snackbar/useCurrentToastActions.js +1 -0
- package/dist/snackbar/useCurrentToastActions.js.map +1 -1
- package/dist/storage/useStorage.d.ts +1 -0
- package/dist/storage/useStorage.js +1 -0
- package/dist/storage/useStorage.js.map +1 -1
- package/dist/suspense/CircularProgressSuspense.d.ts +2 -1
- package/dist/suspense/CircularProgressSuspense.js +2 -1
- package/dist/suspense/CircularProgressSuspense.js.map +1 -1
- package/dist/suspense/NullSuspense.d.ts +2 -1
- package/dist/suspense/NullSuspense.js +2 -1
- package/dist/suspense/NullSuspense.js.map +1 -1
- package/dist/table/StickyTableSection.d.ts +2 -0
- package/dist/table/StickyTableSection.js +2 -0
- package/dist/table/StickyTableSection.js.map +1 -1
- package/dist/table/Table.d.ts +8 -8
- package/dist/table/Table.js +8 -8
- package/dist/table/Table.js.map +1 -1
- package/dist/table/TableBody.d.ts +2 -0
- package/dist/table/TableBody.js +2 -0
- package/dist/table/TableBody.js.map +1 -1
- package/dist/table/TableCell.d.ts +6 -2
- package/dist/table/TableCell.js +2 -0
- package/dist/table/TableCell.js.map +1 -1
- package/dist/table/TableCheckbox.d.ts +11 -12
- package/dist/table/TableCheckbox.js +10 -11
- package/dist/table/TableCheckbox.js.map +1 -1
- package/dist/table/TableConfigurationProvider.js +1 -1
- package/dist/table/TableConfigurationProvider.js.map +1 -1
- package/dist/table/TableContainer.d.ts +2 -0
- package/dist/table/TableContainer.js +2 -0
- package/dist/table/TableContainer.js.map +1 -1
- package/dist/table/TableContainerProvider.js +1 -1
- package/dist/table/TableContainerProvider.js.map +1 -1
- package/dist/table/TableFooter.d.ts +2 -0
- package/dist/table/TableFooter.js +2 -0
- package/dist/table/TableFooter.js.map +1 -1
- package/dist/table/TableHeader.d.ts +2 -0
- package/dist/table/TableHeader.js +2 -0
- package/dist/table/TableHeader.js.map +1 -1
- package/dist/table/TableRadio.d.ts +13 -13
- package/dist/table/TableRadio.js +10 -10
- package/dist/table/TableRadio.js.map +1 -1
- package/dist/table/TableRow.d.ts +2 -0
- package/dist/table/TableRow.js +2 -0
- package/dist/table/TableRow.js.map +1 -1
- package/dist/table/_table.scss +209 -11
- package/dist/table/tableCellStyles.js +3 -2
- package/dist/table/tableCellStyles.js.map +1 -1
- package/dist/tabs/SimpleTabPanel.d.ts +2 -0
- package/dist/tabs/SimpleTabPanel.js +2 -0
- package/dist/tabs/SimpleTabPanel.js.map +1 -1
- package/dist/tabs/SimpleTabPanels.d.ts +2 -0
- package/dist/tabs/SimpleTabPanels.js +2 -0
- package/dist/tabs/SimpleTabPanels.js.map +1 -1
- package/dist/tabs/Tab.d.ts +19 -1
- package/dist/tabs/Tab.js +1 -1
- package/dist/tabs/Tab.js.map +1 -1
- package/dist/tabs/TabList.d.ts +1 -1
- package/dist/tabs/TabList.js +1 -1
- package/dist/tabs/TabList.js.map +1 -1
- package/dist/tabs/TabListScrollButton.d.ts +1 -1
- package/dist/tabs/TabListScrollButton.js.map +1 -1
- package/dist/tabs/_tabs.scss +142 -5
- package/dist/tabs/tabStyles.d.ts +0 -18
- package/dist/tabs/tabStyles.js.map +1 -1
- package/dist/tabs/useTabs.d.ts +4 -0
- package/dist/tabs/useTabs.js +3 -2
- package/dist/tabs/useTabs.js.map +1 -1
- package/dist/test-utils/jest-globals/match-media.d.ts +1 -2
- package/dist/test-utils/jest-globals/match-media.js +1 -1
- package/dist/test-utils/jest-globals/match-media.js.map +1 -1
- package/dist/test-utils/jest-globals/resize-observer.js +2 -2
- package/dist/test-utils/jest-globals/resize-observer.js.map +1 -1
- package/dist/test-utils/mocks/ResizeObserver.d.ts +7 -7
- package/dist/test-utils/mocks/ResizeObserver.js +7 -7
- package/dist/test-utils/mocks/ResizeObserver.js.map +1 -1
- package/dist/test-utils/mocks/match-media.d.ts +31 -0
- package/dist/test-utils/mocks/match-media.js.map +1 -1
- package/dist/test-utils/utils/createMatchMediaSpy.d.ts +40 -0
- package/dist/test-utils/{mocks/match-media-implementation.js → utils/createMatchMediaSpy.js} +33 -4
- package/dist/test-utils/utils/createMatchMediaSpy.js.map +1 -0
- package/dist/test-utils/vitest/match-media.d.ts +1 -2
- package/dist/test-utils/vitest/match-media.js +1 -1
- package/dist/test-utils/vitest/match-media.js.map +1 -1
- package/dist/test-utils/vitest/resize-observer.js +2 -2
- package/dist/test-utils/vitest/resize-observer.js.map +1 -1
- package/dist/theme/LocalStorageColorSchemeProvider.d.ts +6 -6
- package/dist/theme/LocalStorageColorSchemeProvider.js +6 -6
- package/dist/theme/LocalStorageColorSchemeProvider.js.map +1 -1
- package/dist/theme/ThemeProvider.d.ts +10 -11
- package/dist/theme/ThemeProvider.js +7 -9
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/_a11y.scss +62 -62
- package/dist/theme/_colors.scss +283 -279
- package/dist/theme/_theme.scss +298 -249
- package/dist/theme/colors.d.ts +2 -2
- package/dist/theme/colors.js +2 -2
- package/dist/theme/colors.js.map +1 -1
- package/dist/theme/useColorScheme.d.ts +1 -1
- package/dist/theme/useColorScheme.js +1 -1
- package/dist/theme/useColorScheme.js.map +1 -1
- package/dist/tooltip/Tooltip.d.ts +12 -1
- package/dist/tooltip/Tooltip.js +6 -2
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/TooltipHoverModeProvider.d.ts +1 -0
- package/dist/tooltip/TooltipHoverModeProvider.js +1 -0
- package/dist/tooltip/TooltipHoverModeProvider.js.map +1 -1
- package/dist/tooltip/_tooltip.scss +109 -5
- package/dist/tooltip/constants.d.ts +13 -3
- package/dist/tooltip/constants.js +4 -4
- package/dist/tooltip/constants.js.map +1 -1
- package/dist/tooltip/{tooltipStyles.d.ts → styles.d.ts} +1 -1
- package/dist/tooltip/{tooltipStyles.js → styles.js} +1 -1
- package/dist/tooltip/styles.js.map +1 -0
- package/dist/tooltip/useTooltip.d.ts +8 -15
- package/dist/tooltip/useTooltip.js +8 -8
- package/dist/tooltip/useTooltip.js.map +1 -1
- package/dist/transition/CSSTransition.d.ts +3 -1
- package/dist/transition/CSSTransition.js +3 -1
- package/dist/transition/CSSTransition.js.map +1 -1
- package/dist/transition/Collapse.d.ts +1 -0
- package/dist/transition/Collapse.js +1 -0
- package/dist/transition/Collapse.js.map +1 -1
- package/dist/transition/CrossFade.d.ts +1 -0
- package/dist/transition/CrossFade.js +1 -0
- package/dist/transition/CrossFade.js.map +1 -1
- package/dist/transition/ScaleTransition.d.ts +4 -1
- package/dist/transition/ScaleTransition.js +4 -1
- package/dist/transition/ScaleTransition.js.map +1 -1
- package/dist/transition/SkeletonPlaceholder.d.ts +3 -2
- package/dist/transition/SkeletonPlaceholder.js +3 -2
- package/dist/transition/SkeletonPlaceholder.js.map +1 -1
- package/dist/transition/Slide.d.ts +1 -0
- package/dist/transition/Slide.js +1 -0
- package/dist/transition/Slide.js.map +1 -1
- package/dist/transition/SlideContainer.d.ts +10 -7
- package/dist/transition/SlideContainer.js +12 -8
- package/dist/transition/SlideContainer.js.map +1 -1
- package/dist/transition/_transition.scss +178 -6
- package/dist/transition/getTransitionCallbacks.d.ts +76 -0
- package/dist/transition/getTransitionCallbacks.js +57 -0
- package/dist/transition/getTransitionCallbacks.js.map +1 -0
- package/dist/transition/skeletonPlaceholderUtils.d.ts +4 -1
- package/dist/transition/skeletonPlaceholderUtils.js +4 -1
- package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
- package/dist/transition/types.d.ts +26 -1
- package/dist/transition/types.js.map +1 -1
- package/dist/transition/useCSSTransition.d.ts +2 -0
- package/dist/transition/useCSSTransition.js +2 -0
- package/dist/transition/useCSSTransition.js.map +1 -1
- package/dist/transition/useCarousel.d.ts +6 -2
- package/dist/transition/useCarousel.js +11 -7
- package/dist/transition/useCarousel.js.map +1 -1
- package/dist/transition/useCollapseTransition.d.ts +7 -2
- package/dist/transition/useCollapseTransition.js +2 -0
- package/dist/transition/useCollapseTransition.js.map +1 -1
- package/dist/transition/useCrossFadeTransition.d.ts +22 -45
- package/dist/transition/useCrossFadeTransition.js +17 -49
- package/dist/transition/useCrossFadeTransition.js.map +1 -1
- package/dist/transition/useScaleTransition.d.ts +22 -16
- package/dist/transition/useScaleTransition.js +20 -14
- package/dist/transition/useScaleTransition.js.map +1 -1
- package/dist/transition/useSkeletonPlaceholder.d.ts +6 -3
- package/dist/transition/useSkeletonPlaceholder.js +3 -0
- package/dist/transition/useSkeletonPlaceholder.js.map +1 -1
- package/dist/transition/useSlideTransition.d.ts +9 -3
- package/dist/transition/useSlideTransition.js +1 -0
- package/dist/transition/useSlideTransition.js.map +1 -1
- package/dist/transition/useTransition.d.ts +1 -0
- package/dist/transition/useTransition.js +3 -2
- package/dist/transition/useTransition.js.map +1 -1
- package/dist/tree/DefaultTreeItemRenderer.d.ts +1 -0
- package/dist/tree/DefaultTreeItemRenderer.js +1 -0
- package/dist/tree/DefaultTreeItemRenderer.js.map +1 -1
- package/dist/tree/Tree.d.ts +8 -9
- package/dist/tree/Tree.js +4 -3
- package/dist/tree/Tree.js.map +1 -1
- package/dist/tree/TreeItem.d.ts +1 -0
- package/dist/tree/TreeItem.js +1 -0
- package/dist/tree/TreeItem.js.map +1 -1
- package/dist/tree/_tree.scss +71 -1
- package/dist/tree/types.d.ts +1 -1
- package/dist/tree/types.js.map +1 -1
- package/dist/tree/useTree.d.ts +4 -2
- package/dist/tree/useTree.js +4 -2
- package/dist/tree/useTree.js.map +1 -1
- package/dist/tree/useTreeExpansion.d.ts +1 -0
- package/dist/tree/useTreeExpansion.js +1 -0
- package/dist/tree/useTreeExpansion.js.map +1 -1
- package/dist/tree/useTreeItems.d.ts +1 -0
- package/dist/tree/useTreeItems.js +1 -0
- package/dist/tree/useTreeItems.js.map +1 -1
- package/dist/tree/useTreeSelection.d.ts +1 -0
- package/dist/tree/useTreeSelection.js +1 -0
- package/dist/tree/useTreeSelection.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js.map +1 -1
- package/dist/typography/HighlightText.d.ts +76 -0
- package/dist/typography/HighlightText.js +60 -0
- package/dist/typography/HighlightText.js.map +1 -0
- package/dist/typography/HighlightTextMark.d.ts +16 -0
- package/dist/typography/HighlightTextMark.js +16 -0
- package/dist/typography/HighlightTextMark.js.map +1 -0
- package/dist/typography/Mark.d.ts +27 -0
- package/dist/typography/Mark.js +34 -0
- package/dist/typography/Mark.js.map +1 -0
- package/dist/typography/SrOnly.d.ts +3 -1
- package/dist/typography/SrOnly.js +3 -1
- package/dist/typography/SrOnly.js.map +1 -1
- package/dist/typography/TextContainer.d.ts +9 -1
- package/dist/typography/TextContainer.js +3 -1
- package/dist/typography/TextContainer.js.map +1 -1
- package/dist/typography/Typography.d.ts +2 -1
- package/dist/typography/Typography.js +2 -1
- package/dist/typography/Typography.js.map +1 -1
- package/dist/typography/WritingDirectionProvider.d.ts +8 -8
- package/dist/typography/WritingDirectionProvider.js +8 -8
- package/dist/typography/WritingDirectionProvider.js.map +1 -1
- package/dist/typography/_typography.scss +392 -51
- package/dist/typography/markStyles.d.ts +10 -0
- package/dist/typography/markStyles.js +11 -0
- package/dist/typography/markStyles.js.map +1 -0
- package/dist/typography/textContainerStyles.d.ts +2 -7
- package/dist/typography/textContainerStyles.js +2 -1
- package/dist/typography/textContainerStyles.js.map +1 -1
- package/dist/typography/typographyStyles.d.ts +2 -2
- package/dist/typography/typographyStyles.js +2 -2
- package/dist/typography/typographyStyles.js.map +1 -1
- package/dist/useAsyncFunction.d.ts +10 -68
- package/dist/useAsyncFunction.js +9 -67
- package/dist/useAsyncFunction.js.map +1 -1
- package/dist/useDebouncedFunction.d.ts +3 -1
- package/dist/useDebouncedFunction.js +3 -1
- package/dist/useDebouncedFunction.js.map +1 -1
- package/dist/useDropzone.d.ts +3 -2
- package/dist/useDropzone.js +3 -2
- package/dist/useDropzone.js.map +1 -1
- package/dist/useThrottledFunction.d.ts +3 -1
- package/dist/useThrottledFunction.js +3 -1
- package/dist/useThrottledFunction.js.map +1 -1
- package/dist/useUnmounted.d.ts +1 -1
- package/dist/useUnmounted.js +1 -1
- package/dist/useUnmounted.js.map +1 -1
- package/dist/utils/RenderRecursively.d.ts +1 -0
- package/dist/utils/RenderRecursively.js +1 -0
- package/dist/utils/RenderRecursively.js.map +1 -1
- package/dist/utils/applyRef.d.ts +1 -1
- package/dist/utils/applyRef.js +1 -1
- package/dist/utils/applyRef.js.map +1 -1
- package/dist/window-splitter/WindowSplitter.d.ts +11 -0
- package/dist/window-splitter/WindowSplitter.js +1 -0
- package/dist/window-splitter/WindowSplitter.js.map +1 -1
- package/dist/window-splitter/_window-splitter.scss +46 -0
- package/dist/window-splitter/useWindowSplitter.d.ts +0 -10
- package/dist/window-splitter/useWindowSplitter.js.map +1 -1
- package/package.json +43 -17
- package/src/CoreProviders.tsx +1 -0
- package/src/NoSsr.tsx +3 -1
- package/src/RootHtml.tsx +1 -1
- package/src/SsrProvider.tsx +1 -0
- package/src/app-bar/AppBar.tsx +3 -1
- package/src/app-bar/AppBarTitle.tsx +2 -1
- package/src/autocomplete/Autocomplete.tsx +85 -3
- package/src/autocomplete/AutocompleteChip.tsx +1 -0
- package/src/autocomplete/AutocompleteCircularProgress.tsx +1 -0
- package/src/autocomplete/AutocompleteClearButton.tsx +3 -1
- package/src/autocomplete/AutocompleteDropdownButton.tsx +1 -0
- package/src/autocomplete/AutocompleteListboxChildren.tsx +2 -3
- package/src/autocomplete/autocompleteStyles.ts +11 -2
- package/src/autocomplete/types.ts +140 -86
- package/src/autocomplete/useAutocomplete.ts +21 -26
- package/src/autocomplete/utils.ts +6 -8
- package/src/avatar/Avatar.tsx +2 -1
- package/src/badge/Badge.tsx +8 -4
- package/src/box/Box.tsx +4 -3
- package/src/button/AsyncButton.tsx +4 -3
- package/src/button/Button.tsx +11 -9
- package/src/button/ButtonUnstyled.tsx +2 -1
- package/src/button/TooltippedButton.tsx +3 -2
- package/src/button/{buttonStyles.ts → styles.ts} +18 -0
- package/src/card/Card.tsx +9 -10
- package/src/card/CardContent.tsx +1 -0
- package/src/card/CardFooter.tsx +1 -0
- package/src/card/CardHeader.tsx +1 -0
- package/src/card/CardSubtitle.tsx +1 -0
- package/src/card/CardTitle.tsx +2 -1
- package/src/card/ClickableCard.tsx +3 -1
- package/src/chip/Chip.tsx +5 -3
- package/src/cssUtils.ts +1 -1
- package/src/dialog/Dialog.tsx +9 -10
- package/src/dialog/DialogContent.tsx +5 -5
- package/src/dialog/DialogFooter.tsx +5 -2
- package/src/dialog/DialogHeader.tsx +31 -5
- package/src/dialog/DialogTitle.tsx +8 -7
- package/src/dialog/FixedDialog.tsx +13 -12
- package/src/dialog/styles.ts +16 -10
- package/src/divider/Divider.tsx +3 -1
- package/src/divider/styles.ts +2 -2
- package/src/draggable/useDraggable.ts +1 -0
- package/src/error-boundary/ErrorBoundary.tsx +103 -0
- package/src/error-boundary/context.ts +16 -0
- package/src/error-boundary/types.ts +19 -0
- package/src/error-boundary/useErrorBoundary.ts +36 -0
- package/src/expansion-panel/ExpansionList.tsx +1 -0
- package/src/expansion-panel/ExpansionPanel.tsx +32 -0
- package/src/expansion-panel/ExpansionPanelHeader.tsx +10 -10
- package/src/expansion-panel/expansionPanelStyles.ts +33 -0
- package/src/expansion-panel/useExpansionList.ts +7 -8
- package/src/expansion-panel/useExpansionPanels.ts +7 -10
- package/src/files/FileInput.tsx +4 -2
- package/src/files/styles.ts +1 -1
- package/src/files/useFileUpload.ts +2 -0
- package/src/focus/useFocusContainer.ts +29 -43
- package/src/form/Checkbox.tsx +3 -1
- package/src/form/Fieldset.tsx +6 -35
- package/src/form/Form.tsx +2 -0
- package/src/form/FormMessage.tsx +2 -0
- package/src/form/FormMessageContainer.tsx +1 -0
- package/src/form/FormMessageCounter.tsx +2 -0
- package/src/form/InputToggle.tsx +4 -2
- package/src/form/Label.tsx +5 -54
- package/src/form/Legend.tsx +1 -0
- package/src/form/Listbox.tsx +1 -1
- package/src/form/MenuItemCheckbox.tsx +3 -1
- package/src/form/MenuItemFileInput.tsx +1 -0
- package/src/form/MenuItemInputToggle.tsx +3 -2
- package/src/form/MenuItemRadio.tsx +8 -8
- package/src/form/MenuItemSwitch.tsx +3 -1
- package/src/form/MenuItemTextField.tsx +1 -0
- package/src/form/NativeSelect.tsx +2 -0
- package/src/form/OptGroup.tsx +4 -1
- package/src/form/Option.tsx +2 -1
- package/src/form/Password.tsx +3 -1
- package/src/form/Radio.tsx +2 -0
- package/src/form/Select.tsx +6 -29
- package/src/form/Slider.tsx +9 -2
- package/src/form/SliderContainer.tsx +7 -15
- package/src/form/SliderMark.tsx +2 -13
- package/src/form/SliderMarkLabel.tsx +2 -5
- package/src/form/SliderThumb.tsx +2 -50
- package/src/form/SliderTrack.tsx +8 -18
- package/src/form/SliderValueTooltip.tsx +2 -10
- package/src/form/Switch.tsx +10 -1
- package/src/form/SwitchTrack.tsx +3 -6
- package/src/form/TextArea.tsx +10 -1
- package/src/form/TextField.tsx +3 -1
- package/src/form/TextFieldAddon.tsx +2 -59
- package/src/form/TextFieldContainer.tsx +14 -0
- package/src/form/fieldsetStyles.ts +35 -0
- package/src/form/formConfig.ts +29 -4
- package/src/form/labelStyles.ts +55 -0
- package/src/form/sliderStyles.ts +204 -0
- package/src/form/switchStyles.ts +36 -7
- package/src/form/textAreaStyles.ts +0 -7
- package/src/form/textFieldAddonStyles.ts +41 -0
- package/src/form/textFieldContainerStyles.ts +0 -14
- package/src/form/types.ts +25 -2
- package/src/form/useCheckboxGroup.ts +14 -0
- package/src/form/useCombobox.ts +78 -84
- package/src/form/useNumberField.ts +19 -7
- package/src/form/useRadioGroup.ts +9 -0
- package/src/form/useRangeSlider.ts +6 -1
- package/src/form/useSlider.ts +4 -1
- package/src/form/useTextField.ts +12 -1
- package/src/form/validation.ts +1 -0
- package/src/icon/FontIcon.tsx +1 -0
- package/src/icon/IconRotator.tsx +2 -0
- package/src/icon/MaterialIcon.tsx +2 -0
- package/src/icon/MaterialSymbol.tsx +3 -1
- package/src/icon/SVGIcon.tsx +2 -0
- package/src/icon/TextIconSpacing.tsx +6 -2
- package/src/icon/config.tsx +2 -2
- package/src/icon/material.ts +260 -17
- package/src/icon/styles.ts +5 -1
- package/src/interaction/Ripple.tsx +4 -4
- package/src/interaction/UserInteractionModeProvider.tsx +1 -1
- package/src/layout/LayoutAppBar.tsx +1 -0
- package/src/layout/LayoutNav.tsx +9 -12
- package/src/layout/LayoutWindowSplitter.tsx +7 -8
- package/src/layout/Main.tsx +2 -1
- package/src/layout/useExpandableLayout.ts +1 -0
- package/src/layout/useHorizontalLayoutTransition.ts +5 -2
- package/src/layout/useLayoutAppBarHeight.ts +7 -10
- package/src/layout/useLayoutTree.ts +3 -0
- package/src/layout/useLayoutWindowSplitter.ts +4 -2
- package/src/layout/useResizableLayout.ts +3 -0
- package/src/layout/useTemporaryLayout.ts +1 -0
- package/src/link/Link.tsx +3 -1
- package/src/link/SkipToMainContent.tsx +22 -0
- package/src/list/List.tsx +12 -1
- package/src/list/ListItem.tsx +23 -2
- package/src/list/ListItemChildren.tsx +3 -1
- package/src/list/ListItemLink.tsx +32 -1
- package/src/list/ListSubheader.tsx +2 -0
- package/src/list/listItemStyles.ts +0 -17
- package/src/list/listStyles.ts +0 -7
- package/src/media-queries/AppSizeProvider.tsx +2 -0
- package/src/media-queries/useMediaQuery.ts +2 -0
- package/src/menu/DropdownMenu.tsx +5 -2
- package/src/menu/Menu.tsx +1 -0
- package/src/menu/MenuBar.tsx +4 -1
- package/src/menu/MenuButton.tsx +1 -0
- package/src/menu/MenuItem.tsx +1 -0
- package/src/menu/MenuItemCircularProgress.tsx +4 -6
- package/src/menu/MenuItemGroup.tsx +6 -7
- package/src/menu/MenuItemSeparator.tsx +1 -0
- package/src/menu/MenuWidget.tsx +1 -21
- package/src/menu/styles.ts +23 -0
- package/src/menu/useContextMenu.ts +4 -1
- package/src/movement/useKeyboardMovementProvider.ts +3 -3
- package/src/navigation/CollapsibleNavGroup.tsx +1 -0
- package/src/navigation/DefaultNavigationRenderer.tsx +1 -0
- package/src/navigation/NavGroup.tsx +1 -0
- package/src/navigation/NavItem.tsx +1 -0
- package/src/navigation/NavItemButton.tsx +1 -0
- package/src/navigation/NavItemLink.tsx +1 -0
- package/src/navigation/NavSubheader.tsx +1 -0
- package/src/navigation/Navigation.tsx +44 -0
- package/src/navigation/getTableOfContentsHeadings.ts +70 -0
- package/src/navigation/navItemStyles.ts +1 -1
- package/src/navigation/types.ts +57 -0
- package/src/navigation/useActiveHeadingId.ts +3 -15
- package/src/navigation/useNavigationExpansion.ts +2 -0
- package/src/navigation/useTableOfContentsHeadings.ts +22 -89
- package/src/overlay/Overlay.tsx +12 -2
- package/src/overlay/{overlayStyles.ts → styles.ts} +1 -7
- package/src/portal/Portal.tsx +1 -0
- package/src/portal/PortalContainerProvider.tsx +1 -0
- package/src/positioning/createHorizontalPosition.ts +25 -19
- package/src/positioning/createVerticalPosition.ts +10 -8
- package/src/positioning/useFixedPositioning.ts +1 -0
- package/src/progress/CircularProgress.tsx +3 -2
- package/src/progress/LinearProgress.tsx +3 -2
- package/src/responsive-item/ResponsiveItem.tsx +4 -3
- package/src/responsive-item/ResponsiveItemOverlay.tsx +6 -4
- package/src/scroll/useScrollLock.ts +1 -0
- package/src/searching/fuzzy.ts +2 -1
- package/src/segmented-button/SegmentedButton.tsx +3 -4
- package/src/segmented-button/SegmentedButtonContainer.tsx +7 -8
- package/src/segmented-button/segmentedButtonContainerStyles.ts +1 -1
- package/src/sheet/Sheet.tsx +15 -0
- package/src/sheet/styles.ts +10 -17
- package/src/snackbar/DefaultToastRenderer.tsx +1 -0
- package/src/snackbar/Snackbar.tsx +10 -9
- package/src/snackbar/Toast.tsx +9 -0
- package/src/snackbar/ToastActionButton.tsx +2 -1
- package/src/snackbar/ToastCloseButton.tsx +2 -1
- package/src/snackbar/ToastContent.tsx +1 -0
- package/src/snackbar/{ToastManager.tsx → ToastManager.ts} +1 -1
- package/src/snackbar/ToastManagerProvider.tsx +1 -0
- package/src/snackbar/toastStyles.ts +0 -8
- package/src/snackbar/useCurrentToastActions.ts +1 -0
- package/src/storage/useStorage.ts +1 -0
- package/src/suspense/CircularProgressSuspense.tsx +2 -1
- package/src/suspense/NullSuspense.tsx +2 -1
- package/src/table/StickyTableSection.tsx +2 -0
- package/src/table/Table.tsx +8 -8
- package/src/table/TableBody.tsx +2 -0
- package/src/table/TableCell.tsx +6 -2
- package/src/table/TableCheckbox.tsx +11 -12
- package/src/table/TableContainer.tsx +2 -0
- package/src/table/TableFooter.tsx +2 -0
- package/src/table/TableHeader.tsx +2 -0
- package/src/table/TableRadio.tsx +13 -13
- package/src/table/TableRow.tsx +2 -0
- package/src/table/tableCellStyles.ts +1 -1
- package/src/tabs/SimpleTabPanel.tsx +2 -0
- package/src/tabs/SimpleTabPanels.tsx +2 -0
- package/src/tabs/Tab.tsx +21 -1
- package/src/tabs/TabList.tsx +1 -1
- package/src/tabs/TabListScrollButton.tsx +1 -1
- package/src/tabs/tabStyles.ts +0 -20
- package/src/tabs/useTabs.ts +7 -2
- package/src/test-utils/jest-globals/match-media.ts +4 -3
- package/src/test-utils/jest-globals/resize-observer.ts +2 -2
- package/src/test-utils/mocks/ResizeObserver.ts +7 -7
- package/src/test-utils/mocks/match-media.ts +32 -0
- package/src/test-utils/{mocks/match-media-implementation.ts → utils/createMatchMediaSpy.ts} +34 -36
- package/src/test-utils/vitest/match-media.ts +4 -3
- package/src/test-utils/vitest/resize-observer.ts +2 -2
- package/src/theme/LocalStorageColorSchemeProvider.tsx +6 -6
- package/src/theme/ThemeProvider.tsx +10 -11
- package/src/theme/colors.ts +2 -2
- package/src/theme/useColorScheme.ts +1 -1
- package/src/tooltip/Tooltip.tsx +14 -2
- package/src/tooltip/TooltipHoverModeProvider.tsx +1 -0
- package/src/tooltip/constants.ts +11 -11
- package/src/tooltip/{tooltipStyles.ts → styles.ts} +1 -1
- package/src/tooltip/useTooltip.ts +8 -16
- package/src/transition/CSSTransition.tsx +3 -1
- package/src/transition/Collapse.tsx +1 -0
- package/src/transition/CrossFade.tsx +1 -0
- package/src/transition/ScaleTransition.tsx +4 -1
- package/src/transition/SkeletonPlaceholder.tsx +3 -2
- package/src/transition/Slide.tsx +1 -0
- package/src/transition/SlideContainer.tsx +15 -11
- package/src/transition/getTransitionCallbacks.ts +140 -0
- package/src/transition/skeletonPlaceholderUtils.ts +4 -1
- package/src/transition/types.ts +28 -7
- package/src/transition/useCSSTransition.ts +2 -0
- package/src/transition/useCarousel.ts +11 -7
- package/src/transition/useCollapseTransition.ts +4 -3
- package/src/transition/useCrossFadeTransition.ts +23 -57
- package/src/transition/useScaleTransition.ts +27 -19
- package/src/transition/useSkeletonPlaceholder.ts +6 -3
- package/src/transition/useSlideTransition.ts +14 -13
- package/src/transition/useTransition.ts +3 -2
- package/src/tree/DefaultTreeItemRenderer.tsx +1 -0
- package/src/tree/Tree.tsx +8 -9
- package/src/tree/TreeItem.tsx +1 -0
- package/src/tree/types.ts +1 -1
- package/src/tree/useTree.ts +4 -2
- package/src/tree/useTreeExpansion.ts +1 -0
- package/src/tree/useTreeItems.ts +1 -0
- package/src/tree/useTreeSelection.ts +1 -0
- package/src/types.ts +1 -1
- package/src/typography/HighlightText.tsx +201 -0
- package/src/typography/HighlightTextMark.tsx +25 -0
- package/src/typography/Mark.tsx +41 -0
- package/src/typography/SrOnly.tsx +3 -1
- package/src/typography/TextContainer.tsx +10 -1
- package/src/typography/Typography.tsx +2 -1
- package/src/typography/WritingDirectionProvider.tsx +8 -8
- package/src/typography/markStyles.ts +20 -0
- package/src/typography/textContainerStyles.ts +2 -8
- package/src/typography/typographyStyles.ts +2 -2
- package/src/useAsyncFunction.ts +12 -68
- package/src/useDebouncedFunction.ts +3 -1
- package/src/useDropzone.ts +3 -2
- package/src/useThrottledFunction.ts +3 -1
- package/src/useUnmounted.ts +1 -1
- package/src/utils/RenderRecursively.tsx +1 -0
- package/src/utils/applyRef.ts +1 -1
- package/src/window-splitter/WindowSplitter.tsx +12 -0
- package/src/window-splitter/useWindowSplitter.ts +0 -11
- package/dist/button/buttonStyles.js.map +0 -1
- package/dist/button/buttonUnstyledStyles.d.ts +0 -10
- package/dist/button/buttonUnstyledStyles.js +0 -11
- package/dist/button/buttonUnstyledStyles.js.map +0 -1
- package/dist/overlay/overlayStyles.js.map +0 -1
- package/dist/test-utils/mocks/match-media-implementation.d.ts +0 -42
- package/dist/test-utils/mocks/match-media-implementation.js.map +0 -1
- package/dist/tooltip/tooltipStyles.js.map +0 -1
- package/src/button/buttonUnstyledStyles.ts +0 -19
- /package/src/table/{TableConfigurationProvider.tsx → TableConfigurationProvider.ts} +0 -0
- /package/src/table/{TableContainerProvider.tsx → TableContainerProvider.ts} +0 -0
|
@@ -16,6 +16,7 @@ const noop = ()=>{
|
|
|
16
16
|
* This button will automatically close the toast when clicked unless
|
|
17
17
|
* `event.stopPropagation()` is called from the `onClick` prop.
|
|
18
18
|
*
|
|
19
|
+
* @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}
|
|
19
20
|
* @since 6.0.0
|
|
20
21
|
*/ export const ToastCloseButton = /*#__PURE__*/ forwardRef(function ToastCloseButton(props, ref) {
|
|
21
22
|
const { buttonType = "icon-square", "aria-labelledby": ariaLabelledBy, "aria-label": ariaLabel = buttonType !== "text" && !ariaLabelledBy ? "Close" : undefined, children: propChildren, className, onClick = noop, reordered, ...remaining } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/snackbar/ToastCloseButton.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { forwardRef } from \"react\";\n\nimport { Button, type ButtonProps } from \"../button/Button.js\";\nimport { type ButtonType } from \"../button/
|
|
1
|
+
{"version":3,"sources":["../../src/snackbar/ToastCloseButton.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport { forwardRef } from \"react\";\n\nimport { Button, type ButtonProps } from \"../button/Button.js\";\nimport { type ButtonType } from \"../button/styles.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { useCurrentToastActions } from \"./useCurrentToastActions.js\";\n\nconst styles = bem(\"rmd-toast-x\");\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport interface ToastCloseButtonProps extends ButtonProps {\n /**\n * Note: This default value will only be used if the {@link buttonType} is not\n * `\"text\"` and an `aria-labelledby` is not provided.\n *\n * @defaultValue `\"Close\"`\n */\n \"aria-label\"?: string;\n\n /** @defaultValue `\"icon-square\"` */\n buttonType?: ButtonType;\n\n /**\n * Set this to `true` when there is a close button visible and the content is\n * stacked. This will update the styles so the button renders next to the\n * content and above the action button.\n *\n * @defaultValue `false`\n */\n reordered?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * This button will automatically close the toast when clicked unless\n * `event.stopPropagation()` is called from the `onClick` prop.\n *\n * @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}\n * @since 6.0.0\n */\nexport const ToastCloseButton = forwardRef<\n HTMLButtonElement,\n ToastCloseButtonProps\n>(function ToastCloseButton(props, ref) {\n const {\n buttonType = \"icon-square\",\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-label\": ariaLabel = buttonType !== \"text\" && !ariaLabelledBy\n ? \"Close\"\n : undefined,\n children: propChildren,\n className,\n onClick = noop,\n reordered,\n ...remaining\n } = props;\n\n const children = getIcon(\"close\", propChildren);\n const { removeToast } = useCurrentToastActions();\n\n return (\n <Button\n {...remaining}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n ref={ref}\n onClick={(event) => {\n onClick(event);\n if (event.isPropagationStopped()) {\n return;\n }\n\n removeToast(true);\n }}\n className={cnb(styles({ reordered }), className)}\n buttonType={buttonType}\n >\n {children}\n </Button>\n );\n});\n"],"names":["cnb","forwardRef","Button","getIcon","bem","useCurrentToastActions","styles","noop","ToastCloseButton","props","ref","buttonType","ariaLabelledBy","ariaLabel","undefined","children","propChildren","className","onClick","reordered","remaining","removeToast","aria-label","aria-labelledby","event","isPropagationStopped"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAASC,UAAU,QAAQ,QAAQ;AAEnC,SAASC,MAAM,QAA0B,sBAAsB;AAE/D,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,GAAG,QAAQ,kBAAkB;AACtC,SAASC,sBAAsB,QAAQ,8BAA8B;AAErE,MAAMC,SAASF,IAAI;AACnB,MAAMG,OAAO;AACX,aAAa;AACf;AA2BA;;;;;;;;CAQC,GACD,OAAO,MAAMC,iCAAmBP,WAG9B,SAASO,iBAAiBC,KAAK,EAAEC,GAAG;IACpC,MAAM,EACJC,aAAa,aAAa,EAC1B,mBAAmBC,cAAc,EACjC,cAAcC,YAAYF,eAAe,UAAU,CAACC,iBAChD,UACAE,SAAS,EACbC,UAAUC,YAAY,EACtBC,SAAS,EACTC,UAAUX,IAAI,EACdY,SAAS,EACT,GAAGC,WACJ,GAAGX;IAEJ,MAAMM,WAAWZ,QAAQ,SAASa;IAClC,MAAM,EAAEK,WAAW,EAAE,GAAGhB;IAExB,qBACE,KAACH;QACE,GAAGkB,SAAS;QACbE,cAAYT;QACZU,mBAAiBX;QACjBF,KAAKA;QACLQ,SAAS,CAACM;YACRN,QAAQM;YACR,IAAIA,MAAMC,oBAAoB,IAAI;gBAChC;YACF;YAEAJ,YAAY;QACd;QACAJ,WAAWjB,IAAIM,OAAO;YAAEa;QAAU,IAAIF;QACtCN,YAAYA;kBAEXI;;AAGP,GAAG"}
|
|
@@ -28,6 +28,7 @@ export interface ToastContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
28
28
|
/**
|
|
29
29
|
* **Client Component**
|
|
30
30
|
*
|
|
31
|
+
* @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}
|
|
31
32
|
* @since 6.0.0
|
|
32
33
|
*/
|
|
33
34
|
export declare const ToastContent: import("react").ForwardRefExoticComponent<ToastContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -6,6 +6,7 @@ import { toastContent } from "./toastContentStyles.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* **Client Component**
|
|
8
8
|
*
|
|
9
|
+
* @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}
|
|
9
10
|
* @since 6.0.0
|
|
10
11
|
*/ export const ToastContent = /*#__PURE__*/ forwardRef(function ToastContent(props, ref) {
|
|
11
12
|
const { className, children, action, stacked, multiline: propMultiline, closeButton, disableWrapper, ...remaining } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/snackbar/ToastContent.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef, useCallback, useState } from \"react\";\n\nimport { useResizeObserver } from \"../useResizeObserver.js\";\nimport { toastContent } from \"./toastContentStyles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ToastContentProps extends HTMLAttributes<HTMLDivElement> {\n /** @defaultValue `false` */\n action?: boolean;\n\n /** @defaultValue `false` */\n stacked?: boolean;\n\n /**\n * Set this to `true` if you know that the {@link children} span multiple\n * lines. When this is omitted, a `ResizeObserver` will be used to\n * automatically detect multiline content.\n */\n multiline?: boolean;\n\n /** @defaultValue `false` */\n closeButton?: boolean;\n\n /**\n * Set this to `true` if you do not want to wrap the `children` in a `<div>`\n * that applies some toast layout styles. This should really only be used for\n * custom `Toast` implementations.\n *\n * @internal\n * @defaultValue `false`\n */\n disableWrapper?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @since 6.0.0\n */\nexport const ToastContent = forwardRef<HTMLDivElement, ToastContentProps>(\n function ToastContent(props, ref) {\n const {\n className,\n children,\n action,\n stacked,\n multiline: propMultiline,\n closeButton,\n disableWrapper,\n ...remaining\n } = props;\n\n const [isMultiline, setMultiline] = useState(false);\n const nodeRef = useResizeObserver({\n ref,\n disabled: disableWrapper || typeof propMultiline === \"boolean\",\n disableWidth: true,\n onUpdate: useCallback((entry) => {\n const element = entry.target;\n const style = window.getComputedStyle(element);\n const lineHeight = parseFloat(style.lineHeight);\n if (Number.isNaN(lineHeight)) {\n return;\n }\n\n setMultiline(element.scrollHeight > lineHeight);\n }, []),\n });\n const multiline = propMultiline ?? isMultiline;\n\n if (disableWrapper) {\n return <>{children}</>;\n }\n\n return (\n <div\n {...remaining}\n ref={nodeRef}\n className={toastContent({\n action,\n stacked,\n multiline,\n closeButton,\n className,\n })}\n >\n {children}\n </div>\n );\n }\n);\n"],"names":["forwardRef","useCallback","useState","useResizeObserver","toastContent","ToastContent","props","ref","className","children","action","stacked","multiline","propMultiline","closeButton","disableWrapper","remaining","isMultiline","setMultiline","nodeRef","disabled","disableWidth","onUpdate","entry","element","target","style","window","getComputedStyle","lineHeight","parseFloat","Number","isNaN","scrollHeight","div"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAE/E,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,YAAY,QAAQ,0BAA0B;AAiCvD
|
|
1
|
+
{"version":3,"sources":["../../src/snackbar/ToastContent.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef, useCallback, useState } from \"react\";\n\nimport { useResizeObserver } from \"../useResizeObserver.js\";\nimport { toastContent } from \"./toastContentStyles.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ToastContentProps extends HTMLAttributes<HTMLDivElement> {\n /** @defaultValue `false` */\n action?: boolean;\n\n /** @defaultValue `false` */\n stacked?: boolean;\n\n /**\n * Set this to `true` if you know that the {@link children} span multiple\n * lines. When this is omitted, a `ResizeObserver` will be used to\n * automatically detect multiline content.\n */\n multiline?: boolean;\n\n /** @defaultValue `false` */\n closeButton?: boolean;\n\n /**\n * Set this to `true` if you do not want to wrap the `children` in a `<div>`\n * that applies some toast layout styles. This should really only be used for\n * custom `Toast` implementations.\n *\n * @internal\n * @defaultValue `false`\n */\n disableWrapper?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}\n * @since 6.0.0\n */\nexport const ToastContent = forwardRef<HTMLDivElement, ToastContentProps>(\n function ToastContent(props, ref) {\n const {\n className,\n children,\n action,\n stacked,\n multiline: propMultiline,\n closeButton,\n disableWrapper,\n ...remaining\n } = props;\n\n const [isMultiline, setMultiline] = useState(false);\n const nodeRef = useResizeObserver({\n ref,\n disabled: disableWrapper || typeof propMultiline === \"boolean\",\n disableWidth: true,\n onUpdate: useCallback((entry) => {\n const element = entry.target;\n const style = window.getComputedStyle(element);\n const lineHeight = parseFloat(style.lineHeight);\n if (Number.isNaN(lineHeight)) {\n return;\n }\n\n setMultiline(element.scrollHeight > lineHeight);\n }, []),\n });\n const multiline = propMultiline ?? isMultiline;\n\n if (disableWrapper) {\n return <>{children}</>;\n }\n\n return (\n <div\n {...remaining}\n ref={nodeRef}\n className={toastContent({\n action,\n stacked,\n multiline,\n closeButton,\n className,\n })}\n >\n {children}\n </div>\n );\n }\n);\n"],"names":["forwardRef","useCallback","useState","useResizeObserver","toastContent","ToastContent","props","ref","className","children","action","stacked","multiline","propMultiline","closeButton","disableWrapper","remaining","isMultiline","setMultiline","nodeRef","disabled","disableWidth","onUpdate","entry","element","target","style","window","getComputedStyle","lineHeight","parseFloat","Number","isNaN","scrollHeight","div"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAE/E,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,YAAY,QAAQ,0BAA0B;AAiCvD;;;;;CAKC,GACD,OAAO,MAAMC,6BAAeL,WAC1B,SAASK,aAAaC,KAAK,EAAEC,GAAG;IAC9B,MAAM,EACJC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACNC,OAAO,EACPC,WAAWC,aAAa,EACxBC,WAAW,EACXC,cAAc,EACd,GAAGC,WACJ,GAAGV;IAEJ,MAAM,CAACW,aAAaC,aAAa,GAAGhB,SAAS;IAC7C,MAAMiB,UAAUhB,kBAAkB;QAChCI;QACAa,UAAUL,kBAAkB,OAAOF,kBAAkB;QACrDQ,cAAc;QACdC,UAAUrB,YAAY,CAACsB;YACrB,MAAMC,UAAUD,MAAME,MAAM;YAC5B,MAAMC,QAAQC,OAAOC,gBAAgB,CAACJ;YACtC,MAAMK,aAAaC,WAAWJ,MAAMG,UAAU;YAC9C,IAAIE,OAAOC,KAAK,CAACH,aAAa;gBAC5B;YACF;YAEAX,aAAaM,QAAQS,YAAY,GAAGJ;QACtC,GAAG,EAAE;IACP;IACA,MAAMjB,YAAYC,iBAAiBI;IAEnC,IAAIF,gBAAgB;QAClB,qBAAO;sBAAGN;;IACZ;IAEA,qBACE,KAACyB;QACE,GAAGlB,SAAS;QACbT,KAAKY;QACLX,WAAWJ,aAAa;YACtBM;YACAC;YACAC;YACAE;YACAN;QACF;kBAECC;;AAGP,GACA"}
|
|
@@ -109,8 +109,8 @@ export interface ToastVisibilityTimers {
|
|
|
109
109
|
exitTimeout?: number;
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
|
+
* @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}
|
|
112
113
|
* @see {@link ToastManagerProvider}
|
|
113
|
-
*
|
|
114
114
|
* @since 6.0.0
|
|
115
115
|
*/
|
|
116
116
|
export declare class ToastManager {
|
|
@@ -63,8 +63,8 @@ var _queue = /*#__PURE__*/ new WeakMap(), _timers = /*#__PURE__*/ new WeakMap(),
|
|
|
63
63
|
* This calls `this.#emit()` if the toast was updated
|
|
64
64
|
*/ _updateToast = /*#__PURE__*/ new WeakMap();
|
|
65
65
|
/**
|
|
66
|
+
* @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}
|
|
66
67
|
* @see {@link ToastManagerProvider}
|
|
67
|
-
*
|
|
68
68
|
* @since 6.0.0
|
|
69
69
|
*/ export class ToastManager {
|
|
70
70
|
constructor(){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/snackbar/ToastManager.tsx"],"sourcesContent":["import { nanoid } from \"nanoid\";\n\nimport { type ConfigurableToastProps } from \"./Toast.js\";\n\n/**\n * @since 6.0.0\n */\nexport const DEFAULT_TOAST_VISIBLE_TIME = 5000;\n\n/**\n * - `\"normal\"` - the toast will be added to the end of the queue\n * - `\"next\"` - the toast will be inserted next-in-line in the queue, waiting\n * for the current visible toast to exit before being shown. If the toast does\n * not support duplicates, the existing toast will be moved instead and merged\n * with the toast.\n * - `\"replace\"` - if there is a currently visible toast, it will start the\n * leave transition and display the newly added toast instead.\n * - `\"immediate\"` - the same behavior as `\"replace\"` except that if there was a\n * currently visible toast, the toast will be shown again once the `\"immediate\"`\n * toast is hidden.\n *\n * @since 6.0.0 Renamed from `MessagePriority` to `ToastPriority`\n */\nexport type ToastPriority = \"normal\" | \"next\" | \"replace\" | \"immediate\";\n\n/**\n * - `\"allow\"` - toasts with the same `toastId` can be added into the queue, but\n * the leave timeout behavior might not work if multiple toasts can be shown\n * at the same time.\n * - `\"restart\"` - (default) toasts that have the same `toastId` as a toast\n * being shown will restart the exit timeout and update the toast with any\n * differences in the toast. If the toast is not currently being shown, a new\n * toast will not be added.\n * - `\"update\"` - toasts that have the same `toastId` will just update the toast\n * with the latest content while maintaining any existing timeouts\n *\n * @since 6.0.0 Renamed from `DuplicateBehavior`\n */\nexport type ToastDuplicateBehavior = \"allow\" | \"restart\" | \"update\";\n\n/**\n * @since 6.0.0\n */\nexport interface ToastMeta {\n /**\n * This will be `true` if the exit timeout has been paused either by hovering\n * the toast or the page has become inactive through blur or minimizing.\n */\n paused: boolean;\n\n /**\n * This will be `true` when the toast should be visible and `false` during the\n * exit animation.\n */\n visible: boolean;\n\n /**\n * The current toast's id which can be used with the:\n * - {@link ToastManager.removeToast}\n * - {@link ToastManager.startRemoveTimeout}\n * - {@link ToastManager.pauseRemoveTimeout}\n * - {@link ToastManager.resumeRemoveTimeout}\n */\n toastId: string;\n priority: ToastPriority;\n duplicates: ToastDuplicateBehavior;\n visibleTime: number | null;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface CreateToastOptions extends ConfigurableToastProps {\n /**\n * @defaultValue `nanoid()`\n */\n toastId?: string;\n\n /**\n * @see {@link ToastDuplicateBehavior}\n * @defaultValue `\"restart\"`\n */\n duplicates?: ToastDuplicateBehavior;\n\n /**\n * @see {@link ToastPriority}\n * @defaultValue `\"normal\"`\n */\n priority?: ToastPriority;\n\n /**\n * Set this to `null` to prevent the toast from automatically hiding,\n * otherwise set this to the number of milliseconds to remain visible.\n *\n * @see {@link DEFAULT_TOAST_VISIBLE_TIME}\n * @defaultValue `DEFAULT_TOAST_VISIBLE_TIME`\n */\n visibleTime?: number | null;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface QueuedToast extends ConfigurableToastProps, ToastMeta {}\n\n/**\n * @since 6.0.0\n */\nexport type ToastQueue = readonly Readonly<QueuedToast>[];\n\n/**\n * @since 6.0.0\n */\nexport type ToastCallback = (queue: ToastQueue) => void;\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface ToastVisibilityTimers {\n inactive: boolean;\n startTime: number;\n elapsedTime: number;\n exitTimeout?: number;\n}\n\n/**\n * @see {@link ToastManagerProvider}\n *\n * @since 6.0.0\n */\nexport class ToastManager {\n #queue: QueuedToast[];\n #timers: Map<string, ToastVisibilityTimers>;\n #listeners: ToastCallback[];\n\n constructor() {\n this.#queue = [];\n this.#timers = new Map();\n this.#listeners = [];\n\n // All of the class methods must be arrow functions to preserve the correct\n // `this` value. If they aren't arrow functions, I'd have to wrap each call\n // in an arrow function to work.\n //\n // i.e.\n // useSyncExternalStore(\n // (cb) => manager.subscribe(cb),\n // () => manager.getQueue(),\n // () => manager.getQueue(),\n // );\n }\n\n #emit = (): void => {\n // shallow clone to ensure react updates\n this.#queue = [...this.#queue];\n this.#listeners.forEach((callback) => {\n callback(this.#queue);\n });\n };\n\n #getToastIndex = (toastId: string | undefined): number => {\n if (!toastId) {\n return -1;\n }\n\n return this.#queue.findIndex((toast) => toast.toastId === toastId);\n };\n\n #getToast = (toastId: string | undefined): QueuedToast | undefined => {\n return this.#queue[this.#getToastIndex(toastId)];\n };\n\n /**\n * Starts the exit transition for the currently shown toast and adds the next\n * toast into the queue. This requires a manual call to `this.#emit()`\n * afterwards.\n */\n #addToastImmediately = (nextToast: QueuedToast): void => {\n const [current] = this.#queue;\n this.clearTimer(current.toastId);\n this.#queue[0] = {\n ...current,\n visible: false,\n };\n if (nextToast.priority === \"immediate\") {\n this.#queue.splice(1, 0, nextToast, current);\n } else {\n this.#queue.splice(1, 0, nextToast);\n }\n };\n\n /**\n * This calls `this.#emit()` if the toast was updated\n */\n #updateToast = (\n toastIdOrIndex: string | number,\n patch: Partial<QueuedToast>\n ): void => {\n const index =\n typeof toastIdOrIndex === \"number\"\n ? toastIdOrIndex\n : this.#getToastIndex(toastIdOrIndex);\n\n if (index === -1) {\n return;\n }\n\n this.#queue[index] = {\n ...this.#queue[index],\n ...patch,\n };\n this.#emit();\n };\n\n /**\n * This is just used to subscribe to changes in the {@link useToastQueue}.\n *\n * ```tsx\n * useSyncExternalStore(\n * toastManager.subscribe,\n * toastManager.getQueue,\n * toastManager.getQueue,\n * );\n * ```\n *\n * @internal\n */\n subscribe = (callback: ToastCallback): (() => void) => {\n this.#listeners.push(callback);\n\n return () => {\n this.#listeners = this.#listeners.filter((cb) => cb !== callback);\n };\n };\n\n /**\n * @see {@link subscribe}\n * @internal\n */\n getQueue = (): ToastQueue => {\n return this.#queue;\n };\n\n /**\n * Either adds the toast to the queue or updates an existing toast when using\n * an existing `toastId`.\n *\n * @example Adding toasts\n * ```tsx\n * // create a toast when the user is offline that will not disappear\n * addToast({ toastId: \"offline\", visibleTime: null });\n *\n * // add a new toast that displays `\"Toast\"` to the queue\n * addToast({ children: \"Toast!\" });\n *\n * // add an online toast notification. since these three use the same toast\n * // id, the hide timer will be reset each time\n * addToast({ toastId: \"online\" });\n * addToast({ toastId: \"online\" });\n * addToast({ toastId: \"online\" });\n *\n * // add a server error toast to the queue where the second one will be\n * // ignored\n * addToast({\n * toastId: \"ServerError\",\n * theme: \"error\",\n * duplicates: \"prevent\",\n * });\n * addToast({\n * toastId: \"ServerError\",\n * theme: \"error\",\n * duplicates: \"prevent\",\n * });\n *\n * // add a toast to the queue that has an action button that says \"Goodbye\"\n * addToast({\n * children: \"Hello, world!\",\n * action: \"Goodbye\",\n * });\n *\n * // add a toast to the queue that has an action button that says \"Goodbye\"\n * // and a custom click handler\n * addToast({\n * children: \"Hello, world!\",\n * action: {\n * onClick: () => {\n * logout();\n * },\n * children: \"Goodbye\",\n * },\n * });\n *\n * // add a toast to the queue that renders a react component in the content,\n * // a custom action button implementation (using `ToastActionButton`), and a\n * // close button\n * addToast({\n * children: <SomeCustomComponent />,\n * actionButton: <SomeCustomActionButton />,\n * closeButton: true,\n * });\n * ```\n */\n addToast = (toast: CreateToastOptions): void => {\n const {\n toastId = nanoid(),\n visibleTime = DEFAULT_TOAST_VISIBLE_TIME,\n role = visibleTime === null ? \"alert\" : \"status\",\n priority = \"normal\",\n duplicates = \"restart\",\n } = toast;\n\n const existingIndex = this.#getToastIndex(toast.toastId);\n if (existingIndex !== -1 && duplicates !== \"allow\") {\n const existingToast = this.#queue[existingIndex];\n const nextToast: QueuedToast = {\n ...existingToast,\n ...toast,\n };\n\n // reorder/move the existing toast to be the next item in the queue by:\n // - removing the toast from the queue\n // - inserting it into the next position with the updates\n if (priority === \"next\" && existingIndex > 1) {\n this.#queue.splice(existingIndex, 1);\n this.#queue.splice(1, 0, nextToast);\n this.#emit();\n return;\n }\n\n // only need to reorder the queue if it is not being shown\n if (\n (priority === \"replace\" || priority === \"immediate\") &&\n existingIndex !== 0\n ) {\n this.#queue.splice(existingIndex, 1);\n this.#addToastImmediately(nextToast);\n this.#emit();\n return;\n }\n\n const timers = this.#timers.get(toastId);\n if (existingToast.visible && duplicates === \"restart\" && timers) {\n this.#timers.set(toastId, { ...timers, elapsedTime: 0 });\n\n // wait for the next resume event instead. this _should_ only happen\n // when hovering a toast and another toast replaces it\n if (!nextToast.paused) {\n this.startRemoveTimeout(toastId);\n }\n }\n\n this.#updateToast(existingIndex, toast);\n return;\n }\n\n const nextToast: QueuedToast = {\n ...toast,\n role,\n paused: false,\n visible: true,\n toastId,\n priority,\n duplicates,\n visibleTime,\n };\n\n const queueSize = this.#queue.length;\n if (priority === \"next\" && queueSize > 1) {\n this.#queue.splice(1, 0, nextToast);\n } else if (\n (priority === \"replace\" || priority === \"immediate\") &&\n queueSize > 0\n ) {\n this.#addToastImmediately(nextToast);\n } else {\n this.#queue.push(nextToast);\n }\n\n this.#emit();\n };\n\n /**\n * Attempts to start the timeout for removing the toast when the `visibleTime`\n * is not null for a toast.\n *\n * @param toastId - The specific toastId to update\n */\n startRemoveTimeout = (toastId: string): void => {\n const toast = this.#getToast(toastId);\n if (!toast) {\n return;\n }\n\n const { visibleTime } = toast;\n if (visibleTime === null) {\n // Must manually be closed\n return;\n }\n\n const cached = this.#timers.get(toastId);\n const timers = (cached && { ...cached }) || {\n inactive: false,\n startTime: Date.now(),\n elapsedTime: 0,\n };\n window.clearTimeout(timers.exitTimeout);\n\n let duration = visibleTime;\n if (timers.elapsedTime) {\n duration -= timers.elapsedTime;\n }\n\n timers.inactive = false;\n timers.exitTimeout = window.setTimeout(() => {\n this.removeToast(toastId, true);\n }, duration);\n this.#timers.set(toastId, timers);\n };\n\n /**\n * Pauses the remove timeout for a specific toast normally with hover events\n * or the browser becoming inactive.\n *\n * @param toastId - The specific toastId to pause\n */\n pauseRemoveTimeout = (toastId: string): void => {\n const toast = this.#getToast(toastId);\n const cached = this.#timers.get(toastId);\n if (!toast || !cached || cached.inactive) {\n return;\n }\n\n window.clearTimeout(cached.exitTimeout);\n const timers = { ...cached };\n timers.inactive = true;\n timers.elapsedTime = Date.now() - timers.startTime + timers.elapsedTime;\n this.#timers.set(toastId, timers);\n this.#updateToast(toastId, { paused: true });\n };\n\n /**\n * Resumes the current remove timeout if it was paused by\n * {@link pauseRemoveTimeout}.\n *\n * @param toastId - The specific toastId to resume\n */\n resumeRemoveTimeout = (toastId: string): void => {\n const toastIndex = this.#getToastIndex(toastId);\n const timers = this.#timers.get(toastId);\n if (toastIndex === -1 || !timers?.startTime) {\n return;\n }\n\n timers.startTime = Date.now();\n this.#updateToast(toastIndex, { paused: false });\n this.startRemoveTimeout(toastId);\n };\n\n /**\n * Removes a toast by id from the queue without any exit animation.\n *\n * @param toastId - The specific {@link QueuedToast.toastId}\n * @param transition - Set this to `true` to remove the toast by the exit\n * transition instead of immediately.\n */\n removeToast = (toastId: string, transition: boolean): void => {\n const toastIndex = this.#getToastIndex(toastId);\n if (toastIndex === -1) {\n return;\n }\n\n if (transition) {\n this.clearTimer(toastId);\n this.#updateToast(toastIndex, { visible: false });\n return;\n }\n\n this.#queue.splice(toastIndex, 1);\n this.#emit();\n };\n\n /**\n * Clears any pending timers for the provided toast id. This should generally\n * be used in the `useEffect` cleanup effect for any custom toast renderer\n * implementations.\n *\n * @example\n * ```tsx\n * const { toastId } = toast;\n * const toastManager = useToastManager();\n *\n * useEffect(() => {\n * return () => {\n * toastManager.clearTimer(toastId):\n * }\n * }, [toastManager, toastId]);\n * ```\n */\n clearTimer = (toastId: string): void => {\n const timer = this.#timers.get(toastId);\n window.clearTimeout(timer?.exitTimeout);\n this.#timers.delete(toastId);\n };\n\n /**\n * Removes first toast from the queue without any exit animation. You most\n * likely want to use {@link removeToast} instead.\n */\n popToast = (): void => {\n this.#queue.pop();\n this.#emit();\n };\n\n /**\n * Removes all toasts from the queue. There will be no exit animation.\n *\n * @param disableEmit - Set this to `true` to disable emitting the empty queue.\n * Mostly used for tests.\n */\n clearToasts = (disableEmit = false): void => {\n this.#queue = [];\n this.#timers.forEach((meta) => {\n window.clearTimeout(meta.exitTimeout);\n });\n this.#timers.clear();\n if (!disableEmit) {\n this.#emit();\n }\n };\n}\n\n/**\n * The default toast manager for react-md apps that will allow toasts to be\n * added without setting up the {@link ToastManagerProvider}.\n *\n * @internal\n * @since 6.0.0\n */\nexport const toastManager = new ToastManager();\n\n/**\n * @see {@link ToastManager.addToast}\n * @since 6.0.0\n */\nexport const addToast: ToastManager[\"addToast\"] = (toast) => {\n toastManager.addToast(toast);\n};\n\n/**\n * @see {@link ToastManager.startRemoveTimeout}\n * @since 6.0.0\n */\nexport const startRemoveToastTimeout: ToastManager[\"startRemoveTimeout\"] = (\n toastId\n) => {\n toastManager.startRemoveTimeout(toastId);\n};\n\n/**\n * @see {@link ToastManager.popToast}\n * @since 6.0.0\n */\nexport const popToast: ToastManager[\"popToast\"] = () => {\n toastManager.popToast();\n};\n\n/**\n * @see {@link ToastManager.removeToast}\n * @since 6.0.0\n */\nexport const removeToast: ToastManager[\"removeToast\"] = (\n toastId,\n transition\n) => {\n toastManager.removeToast(toastId, transition);\n};\n\n/**\n * @see {@link ToastManager.clearToasts}\n * @since 6.0.0\n */\nexport const clearToasts = (): void => {\n toastManager.clearToasts();\n};\n"],"names":["nanoid","DEFAULT_TOAST_VISIBLE_TIME","ToastManager","constructor","forEach","callback","toastId","findIndex","toast","nextToast","current","clearTimer","visible","priority","splice","toastIdOrIndex","patch","index","subscribe","push","filter","cb","getQueue","addToast","visibleTime","role","duplicates","existingIndex","existingToast","timers","get","set","elapsedTime","paused","startRemoveTimeout","queueSize","length","cached","inactive","startTime","Date","now","window","clearTimeout","exitTimeout","duration","setTimeout","removeToast","pauseRemoveTimeout","resumeRemoveTimeout","toastIndex","transition","timer","delete","popToast","pop","clearToasts","disableEmit","meta","clear","Map","toastManager","startRemoveToastTimeout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,MAAM,QAAQ,SAAS;AAIhC;;CAEC,GACD,OAAO,MAAMC,6BAA6B,KAAK;IA6H7C,sCACA,uCACA,0CAmBA,qCAQA,8CAQA,yCAIA;;;;GAIC,GACD,oDAcA;;GAEC,GACD;AArEF;;;;CAIC,GACD,OAAO,MAAMC;IAKXC,aAAc;QAJd,gCAAA;;mBAAA,KAAA;;QACA,gCAAA;;mBAAA,KAAA;;QACA,gCAAA;;mBAAA,KAAA;;QAmBA,gCAAA;;mBAAQ;gBACN,wCAAwC;+CACnC,QAAS;gDAAI,IAAI,EAAC;iBAAO;gBAC9B,yBAAA,IAAI,EAAC,YAAWC,OAAO,CAAC,CAACC;oBACvBA,kCAAS,IAAI,EAAC;gBAChB;YACF;;QAEA,gCAAA;;mBAAiB,CAACC;gBAChB,IAAI,CAACA,SAAS;oBACZ,OAAO,CAAC;gBACV;gBAEA,OAAO,yBAAA,IAAI,EAAC,QAAOC,SAAS,CAAC,CAACC,QAAUA,MAAMF,OAAO,KAAKA;YAC5D;;QAEA,gCAAA;;mBAAY,CAACA;gBACX,OAAO,yBAAA,IAAI,EAAC,OAAM,CAAC,yBAAA,IAAI,EAAC,qBAAL,IAAI,EAAgBA,SAAS;YAClD;;QAOA,gCAAA;;mBAAuB,CAACG;gBACtB,MAAM,CAACC,QAAQ,4BAAG,IAAI,EAAC;gBACvB,IAAI,CAACC,UAAU,CAACD,QAAQJ,OAAO;gBAC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;AAEF;;;CAGC,GACD,OAAO,MAAMK,cAAc;IACzBK,aAAaL,WAAW;AAC1B,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/snackbar/ToastManager.ts"],"sourcesContent":["import { nanoid } from \"nanoid\";\n\nimport { type ConfigurableToastProps } from \"./Toast.js\";\n\n/**\n * @since 6.0.0\n */\nexport const DEFAULT_TOAST_VISIBLE_TIME = 5000;\n\n/**\n * - `\"normal\"` - the toast will be added to the end of the queue\n * - `\"next\"` - the toast will be inserted next-in-line in the queue, waiting\n * for the current visible toast to exit before being shown. If the toast does\n * not support duplicates, the existing toast will be moved instead and merged\n * with the toast.\n * - `\"replace\"` - if there is a currently visible toast, it will start the\n * leave transition and display the newly added toast instead.\n * - `\"immediate\"` - the same behavior as `\"replace\"` except that if there was a\n * currently visible toast, the toast will be shown again once the `\"immediate\"`\n * toast is hidden.\n *\n * @since 6.0.0 Renamed from `MessagePriority` to `ToastPriority`\n */\nexport type ToastPriority = \"normal\" | \"next\" | \"replace\" | \"immediate\";\n\n/**\n * - `\"allow\"` - toasts with the same `toastId` can be added into the queue, but\n * the leave timeout behavior might not work if multiple toasts can be shown\n * at the same time.\n * - `\"restart\"` - (default) toasts that have the same `toastId` as a toast\n * being shown will restart the exit timeout and update the toast with any\n * differences in the toast. If the toast is not currently being shown, a new\n * toast will not be added.\n * - `\"update\"` - toasts that have the same `toastId` will just update the toast\n * with the latest content while maintaining any existing timeouts\n *\n * @since 6.0.0 Renamed from `DuplicateBehavior`\n */\nexport type ToastDuplicateBehavior = \"allow\" | \"restart\" | \"update\";\n\n/**\n * @since 6.0.0\n */\nexport interface ToastMeta {\n /**\n * This will be `true` if the exit timeout has been paused either by hovering\n * the toast or the page has become inactive through blur or minimizing.\n */\n paused: boolean;\n\n /**\n * This will be `true` when the toast should be visible and `false` during the\n * exit animation.\n */\n visible: boolean;\n\n /**\n * The current toast's id which can be used with the:\n * - {@link ToastManager.removeToast}\n * - {@link ToastManager.startRemoveTimeout}\n * - {@link ToastManager.pauseRemoveTimeout}\n * - {@link ToastManager.resumeRemoveTimeout}\n */\n toastId: string;\n priority: ToastPriority;\n duplicates: ToastDuplicateBehavior;\n visibleTime: number | null;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface CreateToastOptions extends ConfigurableToastProps {\n /**\n * @defaultValue `nanoid()`\n */\n toastId?: string;\n\n /**\n * @see {@link ToastDuplicateBehavior}\n * @defaultValue `\"restart\"`\n */\n duplicates?: ToastDuplicateBehavior;\n\n /**\n * @see {@link ToastPriority}\n * @defaultValue `\"normal\"`\n */\n priority?: ToastPriority;\n\n /**\n * Set this to `null` to prevent the toast from automatically hiding,\n * otherwise set this to the number of milliseconds to remain visible.\n *\n * @see {@link DEFAULT_TOAST_VISIBLE_TIME}\n * @defaultValue `DEFAULT_TOAST_VISIBLE_TIME`\n */\n visibleTime?: number | null;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface QueuedToast extends ConfigurableToastProps, ToastMeta {}\n\n/**\n * @since 6.0.0\n */\nexport type ToastQueue = readonly Readonly<QueuedToast>[];\n\n/**\n * @since 6.0.0\n */\nexport type ToastCallback = (queue: ToastQueue) => void;\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface ToastVisibilityTimers {\n inactive: boolean;\n startTime: number;\n elapsedTime: number;\n exitTimeout?: number;\n}\n\n/**\n * @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}\n * @see {@link ToastManagerProvider}\n * @since 6.0.0\n */\nexport class ToastManager {\n #queue: QueuedToast[];\n #timers: Map<string, ToastVisibilityTimers>;\n #listeners: ToastCallback[];\n\n constructor() {\n this.#queue = [];\n this.#timers = new Map();\n this.#listeners = [];\n\n // All of the class methods must be arrow functions to preserve the correct\n // `this` value. If they aren't arrow functions, I'd have to wrap each call\n // in an arrow function to work.\n //\n // i.e.\n // useSyncExternalStore(\n // (cb) => manager.subscribe(cb),\n // () => manager.getQueue(),\n // () => manager.getQueue(),\n // );\n }\n\n #emit = (): void => {\n // shallow clone to ensure react updates\n this.#queue = [...this.#queue];\n this.#listeners.forEach((callback) => {\n callback(this.#queue);\n });\n };\n\n #getToastIndex = (toastId: string | undefined): number => {\n if (!toastId) {\n return -1;\n }\n\n return this.#queue.findIndex((toast) => toast.toastId === toastId);\n };\n\n #getToast = (toastId: string | undefined): QueuedToast | undefined => {\n return this.#queue[this.#getToastIndex(toastId)];\n };\n\n /**\n * Starts the exit transition for the currently shown toast and adds the next\n * toast into the queue. This requires a manual call to `this.#emit()`\n * afterwards.\n */\n #addToastImmediately = (nextToast: QueuedToast): void => {\n const [current] = this.#queue;\n this.clearTimer(current.toastId);\n this.#queue[0] = {\n ...current,\n visible: false,\n };\n if (nextToast.priority === \"immediate\") {\n this.#queue.splice(1, 0, nextToast, current);\n } else {\n this.#queue.splice(1, 0, nextToast);\n }\n };\n\n /**\n * This calls `this.#emit()` if the toast was updated\n */\n #updateToast = (\n toastIdOrIndex: string | number,\n patch: Partial<QueuedToast>\n ): void => {\n const index =\n typeof toastIdOrIndex === \"number\"\n ? toastIdOrIndex\n : this.#getToastIndex(toastIdOrIndex);\n\n if (index === -1) {\n return;\n }\n\n this.#queue[index] = {\n ...this.#queue[index],\n ...patch,\n };\n this.#emit();\n };\n\n /**\n * This is just used to subscribe to changes in the {@link useToastQueue}.\n *\n * ```tsx\n * useSyncExternalStore(\n * toastManager.subscribe,\n * toastManager.getQueue,\n * toastManager.getQueue,\n * );\n * ```\n *\n * @internal\n */\n subscribe = (callback: ToastCallback): (() => void) => {\n this.#listeners.push(callback);\n\n return () => {\n this.#listeners = this.#listeners.filter((cb) => cb !== callback);\n };\n };\n\n /**\n * @see {@link subscribe}\n * @internal\n */\n getQueue = (): ToastQueue => {\n return this.#queue;\n };\n\n /**\n * Either adds the toast to the queue or updates an existing toast when using\n * an existing `toastId`.\n *\n * @example Adding toasts\n * ```tsx\n * // create a toast when the user is offline that will not disappear\n * addToast({ toastId: \"offline\", visibleTime: null });\n *\n * // add a new toast that displays `\"Toast\"` to the queue\n * addToast({ children: \"Toast!\" });\n *\n * // add an online toast notification. since these three use the same toast\n * // id, the hide timer will be reset each time\n * addToast({ toastId: \"online\" });\n * addToast({ toastId: \"online\" });\n * addToast({ toastId: \"online\" });\n *\n * // add a server error toast to the queue where the second one will be\n * // ignored\n * addToast({\n * toastId: \"ServerError\",\n * theme: \"error\",\n * duplicates: \"prevent\",\n * });\n * addToast({\n * toastId: \"ServerError\",\n * theme: \"error\",\n * duplicates: \"prevent\",\n * });\n *\n * // add a toast to the queue that has an action button that says \"Goodbye\"\n * addToast({\n * children: \"Hello, world!\",\n * action: \"Goodbye\",\n * });\n *\n * // add a toast to the queue that has an action button that says \"Goodbye\"\n * // and a custom click handler\n * addToast({\n * children: \"Hello, world!\",\n * action: {\n * onClick: () => {\n * logout();\n * },\n * children: \"Goodbye\",\n * },\n * });\n *\n * // add a toast to the queue that renders a react component in the content,\n * // a custom action button implementation (using `ToastActionButton`), and a\n * // close button\n * addToast({\n * children: <SomeCustomComponent />,\n * actionButton: <SomeCustomActionButton />,\n * closeButton: true,\n * });\n * ```\n */\n addToast = (toast: CreateToastOptions): void => {\n const {\n toastId = nanoid(),\n visibleTime = DEFAULT_TOAST_VISIBLE_TIME,\n role = visibleTime === null ? \"alert\" : \"status\",\n priority = \"normal\",\n duplicates = \"restart\",\n } = toast;\n\n const existingIndex = this.#getToastIndex(toast.toastId);\n if (existingIndex !== -1 && duplicates !== \"allow\") {\n const existingToast = this.#queue[existingIndex];\n const nextToast: QueuedToast = {\n ...existingToast,\n ...toast,\n };\n\n // reorder/move the existing toast to be the next item in the queue by:\n // - removing the toast from the queue\n // - inserting it into the next position with the updates\n if (priority === \"next\" && existingIndex > 1) {\n this.#queue.splice(existingIndex, 1);\n this.#queue.splice(1, 0, nextToast);\n this.#emit();\n return;\n }\n\n // only need to reorder the queue if it is not being shown\n if (\n (priority === \"replace\" || priority === \"immediate\") &&\n existingIndex !== 0\n ) {\n this.#queue.splice(existingIndex, 1);\n this.#addToastImmediately(nextToast);\n this.#emit();\n return;\n }\n\n const timers = this.#timers.get(toastId);\n if (existingToast.visible && duplicates === \"restart\" && timers) {\n this.#timers.set(toastId, { ...timers, elapsedTime: 0 });\n\n // wait for the next resume event instead. this _should_ only happen\n // when hovering a toast and another toast replaces it\n if (!nextToast.paused) {\n this.startRemoveTimeout(toastId);\n }\n }\n\n this.#updateToast(existingIndex, toast);\n return;\n }\n\n const nextToast: QueuedToast = {\n ...toast,\n role,\n paused: false,\n visible: true,\n toastId,\n priority,\n duplicates,\n visibleTime,\n };\n\n const queueSize = this.#queue.length;\n if (priority === \"next\" && queueSize > 1) {\n this.#queue.splice(1, 0, nextToast);\n } else if (\n (priority === \"replace\" || priority === \"immediate\") &&\n queueSize > 0\n ) {\n this.#addToastImmediately(nextToast);\n } else {\n this.#queue.push(nextToast);\n }\n\n this.#emit();\n };\n\n /**\n * Attempts to start the timeout for removing the toast when the `visibleTime`\n * is not null for a toast.\n *\n * @param toastId - The specific toastId to update\n */\n startRemoveTimeout = (toastId: string): void => {\n const toast = this.#getToast(toastId);\n if (!toast) {\n return;\n }\n\n const { visibleTime } = toast;\n if (visibleTime === null) {\n // Must manually be closed\n return;\n }\n\n const cached = this.#timers.get(toastId);\n const timers = (cached && { ...cached }) || {\n inactive: false,\n startTime: Date.now(),\n elapsedTime: 0,\n };\n window.clearTimeout(timers.exitTimeout);\n\n let duration = visibleTime;\n if (timers.elapsedTime) {\n duration -= timers.elapsedTime;\n }\n\n timers.inactive = false;\n timers.exitTimeout = window.setTimeout(() => {\n this.removeToast(toastId, true);\n }, duration);\n this.#timers.set(toastId, timers);\n };\n\n /**\n * Pauses the remove timeout for a specific toast normally with hover events\n * or the browser becoming inactive.\n *\n * @param toastId - The specific toastId to pause\n */\n pauseRemoveTimeout = (toastId: string): void => {\n const toast = this.#getToast(toastId);\n const cached = this.#timers.get(toastId);\n if (!toast || !cached || cached.inactive) {\n return;\n }\n\n window.clearTimeout(cached.exitTimeout);\n const timers = { ...cached };\n timers.inactive = true;\n timers.elapsedTime = Date.now() - timers.startTime + timers.elapsedTime;\n this.#timers.set(toastId, timers);\n this.#updateToast(toastId, { paused: true });\n };\n\n /**\n * Resumes the current remove timeout if it was paused by\n * {@link pauseRemoveTimeout}.\n *\n * @param toastId - The specific toastId to resume\n */\n resumeRemoveTimeout = (toastId: string): void => {\n const toastIndex = this.#getToastIndex(toastId);\n const timers = this.#timers.get(toastId);\n if (toastIndex === -1 || !timers?.startTime) {\n return;\n }\n\n timers.startTime = Date.now();\n this.#updateToast(toastIndex, { paused: false });\n this.startRemoveTimeout(toastId);\n };\n\n /**\n * Removes a toast by id from the queue without any exit animation.\n *\n * @param toastId - The specific {@link QueuedToast.toastId}\n * @param transition - Set this to `true` to remove the toast by the exit\n * transition instead of immediately.\n */\n removeToast = (toastId: string, transition: boolean): void => {\n const toastIndex = this.#getToastIndex(toastId);\n if (toastIndex === -1) {\n return;\n }\n\n if (transition) {\n this.clearTimer(toastId);\n this.#updateToast(toastIndex, { visible: false });\n return;\n }\n\n this.#queue.splice(toastIndex, 1);\n this.#emit();\n };\n\n /**\n * Clears any pending timers for the provided toast id. This should generally\n * be used in the `useEffect` cleanup effect for any custom toast renderer\n * implementations.\n *\n * @example\n * ```tsx\n * const { toastId } = toast;\n * const toastManager = useToastManager();\n *\n * useEffect(() => {\n * return () => {\n * toastManager.clearTimer(toastId):\n * }\n * }, [toastManager, toastId]);\n * ```\n */\n clearTimer = (toastId: string): void => {\n const timer = this.#timers.get(toastId);\n window.clearTimeout(timer?.exitTimeout);\n this.#timers.delete(toastId);\n };\n\n /**\n * Removes first toast from the queue without any exit animation. You most\n * likely want to use {@link removeToast} instead.\n */\n popToast = (): void => {\n this.#queue.pop();\n this.#emit();\n };\n\n /**\n * Removes all toasts from the queue. There will be no exit animation.\n *\n * @param disableEmit - Set this to `true` to disable emitting the empty queue.\n * Mostly used for tests.\n */\n clearToasts = (disableEmit = false): void => {\n this.#queue = [];\n this.#timers.forEach((meta) => {\n window.clearTimeout(meta.exitTimeout);\n });\n this.#timers.clear();\n if (!disableEmit) {\n this.#emit();\n }\n };\n}\n\n/**\n * The default toast manager for react-md apps that will allow toasts to be\n * added without setting up the {@link ToastManagerProvider}.\n *\n * @internal\n * @since 6.0.0\n */\nexport const toastManager = new ToastManager();\n\n/**\n * @see {@link ToastManager.addToast}\n * @since 6.0.0\n */\nexport const addToast: ToastManager[\"addToast\"] = (toast) => {\n toastManager.addToast(toast);\n};\n\n/**\n * @see {@link ToastManager.startRemoveTimeout}\n * @since 6.0.0\n */\nexport const startRemoveToastTimeout: ToastManager[\"startRemoveTimeout\"] = (\n toastId\n) => {\n toastManager.startRemoveTimeout(toastId);\n};\n\n/**\n * @see {@link ToastManager.popToast}\n * @since 6.0.0\n */\nexport const popToast: ToastManager[\"popToast\"] = () => {\n toastManager.popToast();\n};\n\n/**\n * @see {@link ToastManager.removeToast}\n * @since 6.0.0\n */\nexport const removeToast: ToastManager[\"removeToast\"] = (\n toastId,\n transition\n) => {\n toastManager.removeToast(toastId, transition);\n};\n\n/**\n * @see {@link ToastManager.clearToasts}\n * @since 6.0.0\n */\nexport const clearToasts = (): void => {\n toastManager.clearToasts();\n};\n"],"names":["nanoid","DEFAULT_TOAST_VISIBLE_TIME","ToastManager","constructor","forEach","callback","toastId","findIndex","toast","nextToast","current","clearTimer","visible","priority","splice","toastIdOrIndex","patch","index","subscribe","push","filter","cb","getQueue","addToast","visibleTime","role","duplicates","existingIndex","existingToast","timers","get","set","elapsedTime","paused","startRemoveTimeout","queueSize","length","cached","inactive","startTime","Date","now","window","clearTimeout","exitTimeout","duration","setTimeout","removeToast","pauseRemoveTimeout","resumeRemoveTimeout","toastIndex","transition","timer","delete","popToast","pop","clearToasts","disableEmit","meta","clear","Map","toastManager","startRemoveToastTimeout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,MAAM,QAAQ,SAAS;AAIhC;;CAEC,GACD,OAAO,MAAM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AA,IAAI,EAAC,SAAQrD,OAAO,CAAC,CAACsD;gBACpBhB,OAAOC,YAAY,CAACe,KAAKd,WAAW;YACtC;YACA,yBAAA,IAAI,EAAC,SAAQe,KAAK;YAClB,IAAI,CAACF,aAAa;gBAChB,yBAAA,IAAI,EAAC,YAAL,IAAI;YACN;QACF;uCAxYO,QAAS,EAAE;uCACX,SAAU,IAAIG;uCACd,YAAa,EAAE;IAEpB,2EAA2E;IAC3E,2EAA2E;IAC3E,gCAAgC;IAChC,EAAE;IACF,OAAO;IACP,wBAAwB;IACxB,mCAAmC;IACnC,8BAA8B;IAC9B,8BAA8B;IAC9B,KAAK;IACP;AA2XF;AAEA;;;;;;CAMC,GACD,OAAO,MAAMC,eAAe,IAAI3D,eAAe;AAE/C;;;CAGC,GACD,OAAO,MAAMqB,WAAqC,CAACf;IACjDqD,aAAatC,QAAQ,CAACf;AACxB,EAAE;AAEF;;;CAGC,GACD,OAAO,MAAMsD,0BAA8D,CACzExD;IAEAuD,aAAa3B,kBAAkB,CAAC5B;AAClC,EAAE;AAEF;;;CAGC,GACD,OAAO,MAAMgD,WAAqC;IAChDO,aAAaP,QAAQ;AACvB,EAAE;AAEF;;;CAGC,GACD,OAAO,MAAMP,cAA2C,CACtDzC,SACA6C;IAEAU,aAAad,WAAW,CAACzC,SAAS6C;AACpC,EAAE;AAEF;;;CAGC,GACD,OAAO,MAAMK,cAAc;IACzBK,aAAaL,WAAW;AAC1B,EAAE"}
|
|
@@ -47,6 +47,7 @@ export interface ToastManagerProviderProps {
|
|
|
47
47
|
* the default {@link addToast}, {@link removeToast}, and {@link clearToasts}
|
|
48
48
|
* implementation.
|
|
49
49
|
*
|
|
50
|
+
* @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}
|
|
50
51
|
* @see {@link ToastManager} for example usage.
|
|
51
52
|
* @since 6.0.0
|
|
52
53
|
*/
|
|
@@ -56,6 +56,7 @@ const { Provider } = context;
|
|
|
56
56
|
* the default {@link addToast}, {@link removeToast}, and {@link clearToasts}
|
|
57
57
|
* implementation.
|
|
58
58
|
*
|
|
59
|
+
* @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}
|
|
59
60
|
* @see {@link ToastManager} for example usage.
|
|
60
61
|
* @since 6.0.0
|
|
61
62
|
*/ export function ToastManagerProvider(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/snackbar/ToastManagerProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n createContext,\n useContext,\n useMemo,\n useSyncExternalStore,\n} from \"react\";\n\nimport {\n type ToastManager,\n type ToastQueue,\n toastManager,\n} from \"./ToastManager.js\";\n\nconst context = createContext(toastManager);\ncontext.displayName = \"ToastManager\";\nconst { Provider } = context;\n\n/**\n * This is mostly an internal hook to implement the toast functionality but can\n * be used externally as well for custom toast behavior if the other hooks do\n * not support your needs.\n *\n * @see {@link useAddToast}\n * @see {@link useToastQueue}\n * @see {@link useRemoveToast}\n *\n * @returns The current `ToastManager` set in the `ToastManagerProvider`.\n * Defaults to {@link toastManager} if there are no parent providers.\n * @since 6.0.0\n */\nexport function useToastManager(): ToastManager {\n return useContext(context);\n}\n\n/**\n * @see {@link ToastManager.addToast}\n * @since 6.0.0\n */\nexport function useAddToast(): ToastManager[\"addToast\"] {\n return useToastManager().addToast;\n}\n\n/**\n * @see {@link ToastManager.removeToast}\n * @since 6.0.0\n */\nexport function useRemoveToast(): ToastManager[\"removeToast\"] {\n return useToastManager().removeToast;\n}\n\n/**\n * @param limit - the total number of toasts that can be visible at once.\n * @since 6.0.0\n */\nexport function useToastQueue(limit?: number): ToastQueue {\n const toastManager = useToastManager();\n\n const queue = useSyncExternalStore(\n toastManager.subscribe,\n toastManager.getQueue,\n toastManager.getQueue\n );\n\n return useMemo(() => {\n if (!limit) {\n return queue;\n }\n\n return queue.slice(0, limit);\n }, [limit, queue]);\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ToastManagerProviderProps {\n children: ReactNode;\n\n /**\n * @defaultValue `toastManager`\n */\n manager?: ToastManager;\n}\n\n/**\n * **Client Component**\n *\n * This component can be used to implement separate instances of toasts if\n * required in your app. This probably shouldn't be required for most apps with\n * the default {@link addToast}, {@link removeToast}, and {@link clearToasts}\n * implementation.\n *\n * @see {@link ToastManager} for example usage.\n * @since 6.0.0\n */\nexport function ToastManagerProvider(\n props: ToastManagerProviderProps\n): ReactElement {\n const { children, manager = toastManager } = props;\n\n return <Provider value={manager}>{children}</Provider>;\n}\n"],"names":["createContext","useContext","useMemo","useSyncExternalStore","toastManager","context","displayName","Provider","useToastManager","useAddToast","addToast","useRemoveToast","removeToast","useToastQueue","limit","queue","subscribe","getQueue","slice","ToastManagerProvider","props","children","manager","value"],"mappings":"AAAA;;AAEA,SAGEA,aAAa,EACbC,UAAU,EACVC,OAAO,EACPC,oBAAoB,QACf,QAAQ;AAEf,SAGEC,YAAY,QACP,oBAAoB;AAE3B,MAAMC,wBAAUL,cAAcI;AAC9BC,QAAQC,WAAW,GAAG;AACtB,MAAM,EAAEC,QAAQ,EAAE,GAAGF;AAErB;;;;;;;;;;;;CAYC,GACD,OAAO,SAASG;IACd,OAAOP,WAAWI;AACpB;AAEA;;;CAGC,GACD,OAAO,SAASI;IACd,OAAOD,kBAAkBE,QAAQ;AACnC;AAEA;;;CAGC,GACD,OAAO,SAASC;IACd,OAAOH,kBAAkBI,WAAW;AACtC;AAEA;;;CAGC,GACD,OAAO,SAASC,cAAcC,KAAc;IAC1C,MAAMV,eAAeI;IAErB,MAAMO,QAAQZ,qBACZC,aAAaY,SAAS,EACtBZ,aAAaa,QAAQ,EACrBb,aAAaa,QAAQ;IAGvB,OAAOf,QAAQ;QACb,IAAI,CAACY,OAAO;YACV,OAAOC;QACT;QAEA,OAAOA,MAAMG,KAAK,CAAC,GAAGJ;IACxB,GAAG;QAACA;QAAOC;KAAM;AACnB;AAcA
|
|
1
|
+
{"version":3,"sources":["../../src/snackbar/ToastManagerProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactElement,\n type ReactNode,\n createContext,\n useContext,\n useMemo,\n useSyncExternalStore,\n} from \"react\";\n\nimport {\n type ToastManager,\n type ToastQueue,\n toastManager,\n} from \"./ToastManager.js\";\n\nconst context = createContext(toastManager);\ncontext.displayName = \"ToastManager\";\nconst { Provider } = context;\n\n/**\n * This is mostly an internal hook to implement the toast functionality but can\n * be used externally as well for custom toast behavior if the other hooks do\n * not support your needs.\n *\n * @see {@link useAddToast}\n * @see {@link useToastQueue}\n * @see {@link useRemoveToast}\n *\n * @returns The current `ToastManager` set in the `ToastManagerProvider`.\n * Defaults to {@link toastManager} if there are no parent providers.\n * @since 6.0.0\n */\nexport function useToastManager(): ToastManager {\n return useContext(context);\n}\n\n/**\n * @see {@link ToastManager.addToast}\n * @since 6.0.0\n */\nexport function useAddToast(): ToastManager[\"addToast\"] {\n return useToastManager().addToast;\n}\n\n/**\n * @see {@link ToastManager.removeToast}\n * @since 6.0.0\n */\nexport function useRemoveToast(): ToastManager[\"removeToast\"] {\n return useToastManager().removeToast;\n}\n\n/**\n * @param limit - the total number of toasts that can be visible at once.\n * @since 6.0.0\n */\nexport function useToastQueue(limit?: number): ToastQueue {\n const toastManager = useToastManager();\n\n const queue = useSyncExternalStore(\n toastManager.subscribe,\n toastManager.getQueue,\n toastManager.getQueue\n );\n\n return useMemo(() => {\n if (!limit) {\n return queue;\n }\n\n return queue.slice(0, limit);\n }, [limit, queue]);\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ToastManagerProviderProps {\n children: ReactNode;\n\n /**\n * @defaultValue `toastManager`\n */\n manager?: ToastManager;\n}\n\n/**\n * **Client Component**\n *\n * This component can be used to implement separate instances of toasts if\n * required in your app. This probably shouldn't be required for most apps with\n * the default {@link addToast}, {@link removeToast}, and {@link clearToasts}\n * implementation.\n *\n * @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}\n * @see {@link ToastManager} for example usage.\n * @since 6.0.0\n */\nexport function ToastManagerProvider(\n props: ToastManagerProviderProps\n): ReactElement {\n const { children, manager = toastManager } = props;\n\n return <Provider value={manager}>{children}</Provider>;\n}\n"],"names":["createContext","useContext","useMemo","useSyncExternalStore","toastManager","context","displayName","Provider","useToastManager","useAddToast","addToast","useRemoveToast","removeToast","useToastQueue","limit","queue","subscribe","getQueue","slice","ToastManagerProvider","props","children","manager","value"],"mappings":"AAAA;;AAEA,SAGEA,aAAa,EACbC,UAAU,EACVC,OAAO,EACPC,oBAAoB,QACf,QAAQ;AAEf,SAGEC,YAAY,QACP,oBAAoB;AAE3B,MAAMC,wBAAUL,cAAcI;AAC9BC,QAAQC,WAAW,GAAG;AACtB,MAAM,EAAEC,QAAQ,EAAE,GAAGF;AAErB;;;;;;;;;;;;CAYC,GACD,OAAO,SAASG;IACd,OAAOP,WAAWI;AACpB;AAEA;;;CAGC,GACD,OAAO,SAASI;IACd,OAAOD,kBAAkBE,QAAQ;AACnC;AAEA;;;CAGC,GACD,OAAO,SAASC;IACd,OAAOH,kBAAkBI,WAAW;AACtC;AAEA;;;CAGC,GACD,OAAO,SAASC,cAAcC,KAAc;IAC1C,MAAMV,eAAeI;IAErB,MAAMO,QAAQZ,qBACZC,aAAaY,SAAS,EACtBZ,aAAaa,QAAQ,EACrBb,aAAaa,QAAQ;IAGvB,OAAOf,QAAQ;QACb,IAAI,CAACY,OAAO;YACV,OAAOC;QACT;QAEA,OAAOA,MAAMG,KAAK,CAAC,GAAGJ;IACxB,GAAG;QAACA;QAAOC;KAAM;AACnB;AAcA;;;;;;;;;;;CAWC,GACD,OAAO,SAASI,qBACdC,KAAgC;IAEhC,MAAM,EAAEC,QAAQ,EAAEC,UAAUlB,YAAY,EAAE,GAAGgB;IAE7C,qBAAO,KAACb;QAASgB,OAAOD;kBAAUD;;AACpC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
////
|
|
2
|
+
/// @group snackbar
|
|
3
|
+
////
|
|
4
|
+
|
|
1
5
|
@use "sass:map";
|
|
2
6
|
@use "../utils";
|
|
3
7
|
@use "../box-shadows";
|
|
@@ -10,59 +14,171 @@
|
|
|
10
14
|
@use "../typography/typography";
|
|
11
15
|
@use "../transition/transition";
|
|
12
16
|
|
|
17
|
+
/// Set to `true` to disable all the styles.
|
|
18
|
+
/// @type Boolean
|
|
13
19
|
$disable-everything: false !default;
|
|
20
|
+
|
|
21
|
+
/// Set to `true` if the `position: absolute` styles are not required where a
|
|
22
|
+
/// `Snackbar` is rendered within another `position: relative` container.
|
|
23
|
+
///
|
|
24
|
+
/// @type Boolean
|
|
14
25
|
$disable-absolute: false !default;
|
|
26
|
+
|
|
27
|
+
/// Set to `true` to disable the styles for a `Snackbar` positioned at the top
|
|
28
|
+
/// of the page/container.
|
|
29
|
+
/// @type Boolean
|
|
15
30
|
$disable-top: false !default;
|
|
31
|
+
|
|
32
|
+
/// Set to `true` to disable the styles for a `Snackbar` positioned at the
|
|
33
|
+
/// bottom of the page/container.
|
|
34
|
+
/// @type Boolean
|
|
16
35
|
$disable-bottom: false !default;
|
|
36
|
+
|
|
37
|
+
/// Set to `true` to disable the styles for a `Snackbar` positioned at the
|
|
38
|
+
/// top-right of the page/container.
|
|
39
|
+
/// @type Boolean
|
|
17
40
|
$disable-top-right: $disable-top !default;
|
|
41
|
+
|
|
42
|
+
/// Set to `true` to disable the styles for a `Snackbar` positioned at the
|
|
43
|
+
/// top-left of the page/container.
|
|
44
|
+
/// @type Boolean
|
|
18
45
|
$disable-top-left: $disable-top !default;
|
|
46
|
+
|
|
47
|
+
/// Set to `true` to disable the styles for a `Snackbar` positioned at the
|
|
48
|
+
/// bottom-left of the page/container.
|
|
49
|
+
/// @type Boolean
|
|
19
50
|
$disable-bottom-left: $disable-bottom !default;
|
|
51
|
+
|
|
52
|
+
/// Set to `true` to disable the styles for a `Snackbar` positioned at the
|
|
53
|
+
/// bottom-right of the page/container.
|
|
54
|
+
/// @type Boolean
|
|
20
55
|
$disable-bottom-right: $disable-bottom !default;
|
|
56
|
+
|
|
57
|
+
/// Set to `true` to disable the `ToastCloseButton` styles.
|
|
58
|
+
/// @type Boolean
|
|
21
59
|
$disable-close-button: false !default;
|
|
60
|
+
|
|
61
|
+
/// Set to `true` to disable the `ToastActionButton` styles.
|
|
62
|
+
/// @type Boolean
|
|
22
63
|
$disable-action-button: false !default;
|
|
64
|
+
|
|
65
|
+
/// Set to `true` to disable the stacked `Snackbar` styles.
|
|
66
|
+
/// @type Boolean
|
|
23
67
|
$disable-stacked: false !default;
|
|
24
68
|
|
|
69
|
+
/// The default `align-items` for a `Snackbar`.
|
|
70
|
+
/// @type String
|
|
25
71
|
$default-align-items: center !default;
|
|
72
|
+
|
|
73
|
+
/// The default `gap` for a `Snackbar`.
|
|
74
|
+
/// @type Number
|
|
26
75
|
$gap: 1rem !default;
|
|
76
|
+
|
|
77
|
+
/// The default `gap` for a `Toast`.
|
|
78
|
+
/// @type Number
|
|
27
79
|
$toast-gap: 1rem !default;
|
|
80
|
+
|
|
81
|
+
/// The default `gap` for a stacked `Toast`.
|
|
82
|
+
/// @type Number
|
|
28
83
|
$toast-gap-stacked: 0.5rem !default;
|
|
84
|
+
|
|
85
|
+
/// The default `gap` for a toast that has both a `ToastActionButton` and
|
|
86
|
+
/// `ToastCloseButton`.
|
|
87
|
+
/// @type Number
|
|
29
88
|
$toast-gap-both-buttons: 0.25rem !default;
|
|
89
|
+
|
|
90
|
+
/// The viewport margin to apply to all `Toast` rendered within the `Snackbar`.
|
|
91
|
+
/// @type Number
|
|
30
92
|
$margin: 1rem !default;
|
|
31
|
-
|
|
93
|
+
|
|
94
|
+
/// A number between 0-24 representing the box-shadow elevation for a `Toast`.
|
|
95
|
+
/// @type Number
|
|
96
|
+
$elevation: 6 !default;
|
|
97
|
+
|
|
98
|
+
/// The default border-radius for a `Toast`.
|
|
99
|
+
/// @type Number
|
|
32
100
|
$border-radius: 0.25rem !default;
|
|
101
|
+
|
|
102
|
+
/// The default vertical padding for a `Toast`.
|
|
103
|
+
/// @type Number
|
|
33
104
|
$vertical-padding: 0.75em !default;
|
|
105
|
+
|
|
106
|
+
/// The default horizontal padding for a `Toast`.
|
|
107
|
+
/// @type Number
|
|
34
108
|
$horizontal-padding: 1rem !default;
|
|
109
|
+
|
|
110
|
+
/// The default horizontal padding for a `Toast` that has an
|
|
111
|
+
/// `ToastActionButton`.
|
|
112
|
+
/// @type Number
|
|
35
113
|
$action-horizontal-padding: 0.5rem !default;
|
|
114
|
+
|
|
115
|
+
/// The default horizontal padding for a `Toast` that has an
|
|
116
|
+
/// `ToastCloseButton`.
|
|
117
|
+
/// @type Number
|
|
36
118
|
$close-button-horizontal-padding: 0 !default;
|
|
37
119
|
|
|
120
|
+
/// The min-height for a `Toast`.
|
|
121
|
+
/// @type Number
|
|
38
122
|
$min-height: 3rem !default;
|
|
123
|
+
|
|
124
|
+
/// The min-width for a `Toast` when the viewport is tablet or above.
|
|
125
|
+
/// @type Number
|
|
39
126
|
$min-width: 21.5rem !default;
|
|
127
|
+
|
|
128
|
+
/// The max-width for a `Toast`.
|
|
129
|
+
/// @type Number
|
|
40
130
|
$max-width: 35.5rem !default;
|
|
131
|
+
|
|
132
|
+
/// The default `z-index` for a `Toast`.
|
|
133
|
+
/// @type Number
|
|
41
134
|
$z-index: utils.$temporary-element-z-index + 10 !default;
|
|
42
135
|
|
|
136
|
+
/// The default `Toast` typography styles.
|
|
137
|
+
/// @type Map
|
|
43
138
|
$typography: map.merge(
|
|
44
139
|
typography.$base-font-styles,
|
|
45
140
|
typography.$subtitle-2-styles
|
|
46
141
|
) !default;
|
|
47
142
|
|
|
143
|
+
/// The background-color to use in the light theme.
|
|
144
|
+
/// @type Color
|
|
48
145
|
$light-theme-background-color: #323232 !default;
|
|
146
|
+
|
|
147
|
+
/// The text color to use in the light theme.
|
|
148
|
+
/// @type Color
|
|
49
149
|
$light-theme-color: a11y.contrast-color($light-theme-background-color) !default;
|
|
50
150
|
|
|
151
|
+
/// The background-color to use in the dark theme.
|
|
152
|
+
/// @type Color
|
|
51
153
|
$dark-theme-background-color: if(
|
|
52
154
|
theme.$disable-dark-elevation,
|
|
53
155
|
$light-theme-background-color,
|
|
54
|
-
map.get(theme.$dark-elevation-colors, $
|
|
156
|
+
map.get(theme.$dark-elevation-colors, $elevation)
|
|
55
157
|
) !default;
|
|
158
|
+
|
|
159
|
+
/// The text color to use in the dark theme.
|
|
160
|
+
/// @type Color
|
|
56
161
|
$dark-theme-color: a11y.contrast-color($dark-theme-background-color) !default;
|
|
57
162
|
|
|
163
|
+
/// The default background-color for a `Toast`.
|
|
164
|
+
/// @type Color
|
|
58
165
|
$background-color: theme.get-default-color(
|
|
59
166
|
$light-theme-background-color,
|
|
60
167
|
$dark-theme-background-color
|
|
61
168
|
) !default;
|
|
169
|
+
|
|
170
|
+
/// The default text color for a `Toast`.
|
|
171
|
+
/// @type Color
|
|
62
172
|
$color: theme.get-default-color($light-theme-color, $dark-theme-color) !default;
|
|
63
173
|
|
|
174
|
+
/// The available configurable css variables and mostly used internally for the
|
|
175
|
+
/// `get-var`, `set-var`, and `use-var` utils.
|
|
176
|
+
/// @type List
|
|
64
177
|
$variables: (background-color, color, offset);
|
|
65
178
|
|
|
179
|
+
/// @param {String} name - The supported variable name
|
|
180
|
+
/// @param {any} fallback [null] - An optional fallback value
|
|
181
|
+
/// @returns {String} a `var()` statement
|
|
66
182
|
@function get-var($name, $fallback: null) {
|
|
67
183
|
$var: utils.get-var-name($variables, $name, "snackbar");
|
|
68
184
|
@if $fallback {
|
|
@@ -72,16 +188,24 @@ $variables: (background-color, color, offset);
|
|
|
72
188
|
@return var(#{$var});
|
|
73
189
|
}
|
|
74
190
|
|
|
191
|
+
/// @param {String} name - The supported variable name
|
|
192
|
+
/// @param {any} value - The value to set the variable to. Supports `null` which
|
|
193
|
+
/// will just be a no-op.
|
|
75
194
|
@mixin set-var($name, $value) {
|
|
76
195
|
@if $value {
|
|
77
196
|
#{utils.get-var-name($variables, $name, "snackbar")}: #{$value};
|
|
78
197
|
}
|
|
79
198
|
}
|
|
80
199
|
|
|
200
|
+
/// @param {String} property - The css property to apply the variable to
|
|
201
|
+
/// @param {String} name [$property] - The supported variable name
|
|
202
|
+
/// @param {any} fallback [null] - An optional fallback value if the variable
|
|
203
|
+
/// has not been set
|
|
81
204
|
@mixin use-var($property, $name: $property, $fallback: null) {
|
|
82
205
|
#{$property}: get-var($name, $fallback);
|
|
83
206
|
}
|
|
84
207
|
|
|
208
|
+
/// Conditionally applies the css variables based on feature flags
|
|
85
209
|
@mixin variables {
|
|
86
210
|
@if not $disable-everything {
|
|
87
211
|
@include set-var(background-color, $background-color);
|
|
@@ -90,6 +214,10 @@ $variables: (background-color, color, offset);
|
|
|
90
214
|
}
|
|
91
215
|
}
|
|
92
216
|
|
|
217
|
+
/// Generates all the styles based on feature flags.
|
|
218
|
+
///
|
|
219
|
+
/// @param {Boolean} disable-layer [false] - Set this to `true` to disable the
|
|
220
|
+
/// layer behavior
|
|
93
221
|
@mixin styles($disable-layer: false) {
|
|
94
222
|
@if not $disable-everything {
|
|
95
223
|
@include utils.optional-layer(snackbar, $disable-layer) {
|
|
@@ -145,7 +273,7 @@ $variables: (background-color, color, offset);
|
|
|
145
273
|
}
|
|
146
274
|
|
|
147
275
|
.rmd-toast {
|
|
148
|
-
@include box-shadows.box-shadow($
|
|
276
|
+
@include box-shadows.box-shadow($elevation, $disable-colors: true);
|
|
149
277
|
@include utils.map-to-styles($typography);
|
|
150
278
|
@include use-var(background-color);
|
|
151
279
|
@include use-var(color);
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { type BackgroundColor } from "../cssUtils.js";
|
|
2
|
-
declare module "react" {
|
|
3
|
-
interface CSSProperties {
|
|
4
|
-
"--rmd-toast-color"?: string;
|
|
5
|
-
"--rmd-toast-background-color"?: string;
|
|
6
|
-
"--rmd-toast-offset"?: string | number;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
2
|
/** @since 6.0.0 */
|
|
10
3
|
export interface ToastClassNameOptions {
|
|
11
4
|
className?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/snackbar/toastStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { type BackgroundColor, cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\n\
|
|
1
|
+
{"version":3,"sources":["../../src/snackbar/toastStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { type BackgroundColor, cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-toast\");\n\n/** @since 6.0.0 */\nexport interface ToastClassNameOptions {\n className?: string;\n /** @defaultValue `\"surface\"` */\n theme?: BackgroundColor;\n /** @defaultValue `false` */\n action?: boolean;\n /** @defaultValue `false` */\n paused?: boolean;\n /** @defaultValue `false` */\n stacked?: boolean;\n /** @defaultValue `false` */\n reordered?: boolean;\n /** @defaultValue `false` */\n closeButton?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function toast(options: ToastClassNameOptions = {}): string {\n const {\n className,\n theme = \"surface\",\n action,\n paused,\n stacked,\n reordered,\n closeButton,\n } = options;\n\n return cnb(\n styles({\n x: closeButton,\n action,\n paused,\n \"small-gap\": closeButton && action,\n stacked,\n reordered: stacked && reordered,\n }),\n cssUtils({\n backgroundColor:\n theme !== \"surface\" && theme !== \"current-color\" ? theme : undefined,\n }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","styles","toast","options","className","theme","action","paused","stacked","reordered","closeButton","x","backgroundColor","undefined"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAA+BC,QAAQ,QAAQ,iBAAiB;AAChE,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAmBnB;;CAEC,GACD,OAAO,SAASE,MAAMC,UAAiC,CAAC,CAAC;IACvD,MAAM,EACJC,SAAS,EACTC,QAAQ,SAAS,EACjBC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,EACZ,GAAGP;IAEJ,OAAOL,IACLG,OAAO;QACLU,GAAGD;QACHJ;QACAC;QACA,aAAaG,eAAeJ;QAC5BE;QACAC,WAAWD,WAAWC;IACxB,IACAV,SAAS;QACPa,iBACEP,UAAU,aAAaA,UAAU,kBAAkBA,QAAQQ;IAC/D,IACAT;AAEJ"}
|
|
@@ -25,6 +25,7 @@ export declare const CurrentToastActionsProvider: import("react").Provider<Curre
|
|
|
25
25
|
* This is only required if you have multiple `Snackbar` implementations in your
|
|
26
26
|
* app.
|
|
27
27
|
*
|
|
28
|
+
* @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}
|
|
28
29
|
* @since 6.0.0
|
|
29
30
|
*/
|
|
30
31
|
export declare function useCurrentToastActions(): CurrentToastActions;
|
|
@@ -10,6 +10,7 @@ context.displayName = "CurrentToastActions";
|
|
|
10
10
|
* This is only required if you have multiple `Snackbar` implementations in your
|
|
11
11
|
* app.
|
|
12
12
|
*
|
|
13
|
+
* @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}
|
|
13
14
|
* @since 6.0.0
|
|
14
15
|
*/ export function useCurrentToastActions() {
|
|
15
16
|
const actions = useContext(context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/snackbar/useCurrentToastActions.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext } from \"react\";\n\n/**\n * A simplified version of the {@link ToastManager} that has the actions bound\n * to the current {@link QueuedToast.toastId}.\n *\n * @since 6.0.0\n */\nexport interface CurrentToastActions {\n /** @see {@link ToastManager.clearTimer} */\n clearTimer: () => void;\n /** @see {@link ToastManager.removeToast} */\n removeToast: (transition: boolean) => void;\n /** @see {@link ToastManager.startRemoveTimeout} */\n startRemoveTimeout: () => void;\n /** @see {@link ToastManager.pauseRemoveTimeout} */\n pauseRemoveTimeout: () => void;\n /** @see {@link ToastManager.resumeRemoveTimeout} */\n resumeRemoveTimeout: () => void;\n}\n\nconst context = createContext<CurrentToastActions | null>(null);\ncontext.displayName = \"CurrentToastActions\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const { Provider: CurrentToastActionsProvider } = context;\n\n/**\n * This is only required if you have multiple `Snackbar` implementations in your\n * app.\n *\n * @since 6.0.0\n */\nexport function useCurrentToastActions(): CurrentToastActions {\n const actions = useContext(context);\n if (!actions) {\n throw new Error(\n \"The `CurrentToastActionsProvider` has not been initialized\"\n );\n }\n\n return actions;\n}\n"],"names":["createContext","useContext","context","displayName","Provider","CurrentToastActionsProvider","useCurrentToastActions","actions","Error"],"mappings":"AAAA;AAEA,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAqBlD,MAAMC,UAAUF,cAA0C;AAC1DE,QAAQC,WAAW,GAAG;AAEtB;;;CAGC,GACD,OAAO,MAAM,EAAEC,UAAUC,2BAA2B,EAAE,GAAGH,QAAQ;AAEjE
|
|
1
|
+
{"version":3,"sources":["../../src/snackbar/useCurrentToastActions.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext } from \"react\";\n\n/**\n * A simplified version of the {@link ToastManager} that has the actions bound\n * to the current {@link QueuedToast.toastId}.\n *\n * @since 6.0.0\n */\nexport interface CurrentToastActions {\n /** @see {@link ToastManager.clearTimer} */\n clearTimer: () => void;\n /** @see {@link ToastManager.removeToast} */\n removeToast: (transition: boolean) => void;\n /** @see {@link ToastManager.startRemoveTimeout} */\n startRemoveTimeout: () => void;\n /** @see {@link ToastManager.pauseRemoveTimeout} */\n pauseRemoveTimeout: () => void;\n /** @see {@link ToastManager.resumeRemoveTimeout} */\n resumeRemoveTimeout: () => void;\n}\n\nconst context = createContext<CurrentToastActions | null>(null);\ncontext.displayName = \"CurrentToastActions\";\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const { Provider: CurrentToastActionsProvider } = context;\n\n/**\n * This is only required if you have multiple `Snackbar` implementations in your\n * app.\n *\n * @see {@link https://next.react-md.dev/components/snackbar | Snackbar Demos}\n * @since 6.0.0\n */\nexport function useCurrentToastActions(): CurrentToastActions {\n const actions = useContext(context);\n if (!actions) {\n throw new Error(\n \"The `CurrentToastActionsProvider` has not been initialized\"\n );\n }\n\n return actions;\n}\n"],"names":["createContext","useContext","context","displayName","Provider","CurrentToastActionsProvider","useCurrentToastActions","actions","Error"],"mappings":"AAAA;AAEA,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAqBlD,MAAMC,UAAUF,cAA0C;AAC1DE,QAAQC,WAAW,GAAG;AAEtB;;;CAGC,GACD,OAAO,MAAM,EAAEC,UAAUC,2BAA2B,EAAE,GAAGH,QAAQ;AAEjE;;;;;;CAMC,GACD,OAAO,SAASI;IACd,MAAMC,UAAUN,WAAWC;IAC3B,IAAI,CAACK,SAAS;QACZ,MAAM,IAAIC,MACR;IAEJ;IAEA,OAAOD;AACT"}
|
|
@@ -105,6 +105,7 @@ import { type StorageImplementation, type StorageOptions } from "./types.js";
|
|
|
105
105
|
* }
|
|
106
106
|
* ```
|
|
107
107
|
*
|
|
108
|
+
* @see {@link https://next.react-md.dev/hooks/use-storage | useStorage Demos}
|
|
108
109
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent
|
|
109
110
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
|
|
110
111
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
|
|
@@ -110,6 +110,7 @@ import { getItemFromStorage, removeItemFromStorage, setItemInStorage } from "./u
|
|
|
110
110
|
* }
|
|
111
111
|
* ```
|
|
112
112
|
*
|
|
113
|
+
* @see {@link https://next.react-md.dev/hooks/use-storage | useStorage Demos}
|
|
113
114
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent
|
|
114
115
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
|
|
115
116
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/storage/useStorage.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { useSsr } from \"../SsrProvider.js\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { useIsomorphicLayoutEffect } from \"../useIsomorphicLayoutEffect.js\";\nimport { getStorageSerializers } from \"./internalUtils.js\";\nimport { type StorageImplementation, type StorageOptions } from \"./types.js\";\nimport {\n getItemFromStorage,\n removeItemFromStorage,\n setItemInStorage,\n} from \"./utils.js\";\n\n/**\n * The `useStorage` hook can be used to read and write from `localStorage`\n * (default) or `sessionStorage`. The default behavior will automatically sync\n * the value across tabs using the `StorageEvent`.\n *\n * @example Simple Example\n * ```tsx\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import { useStorage } from \"@react-md/core/storage/useStorage\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useStorage({\n * key: \"savedSearch\",\n * defaultValue: \"\",\n * });\n *\n * return (\n * <TextField\n * label=\"Search\"\n * placeholder=\"Search...\"\n * type=\"search\"\n * value={value}\n * onChange={(event) => {\n * setValue(event.currentTarget.value)\n * }}\n * />\n * );\n * }\n * ```\n *\n * @example Type-safe Objects\n * ```tsx\n * import { useStorage } from \"@react-md/core/storage/useStorage\";\n * import { type ReactElement } from \"react\";\n *\n * interface ExpectedSchema {\n * label: string;\n * value: string;\n * // others\n * }\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useStorage<ExpectedSchema | null>({\n * key: \"someKey\",\n * defaultValue: null,\n *\n * // this is optional: you can create a custom deserializer to validate\n * // the stored value to prevent people manually updating local storage in\n * // the dev tools\n * deserializer(item) {\n * const parsed = JSON.parse(item):\n * const { label, value } = parsed;\n * if (typeof label !== 'string' || typeof value !== 'string') {\n * return null;\n * }\n *\n * return { label, value };\n * }\n * });\n *\n * // do something\n * // value will be `ExpectedSchema | null`\n * }\n * ```\n *\n * @example Manual Persistence\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Checkbox } from \"@react-md/core/form/Checkbox\";\n * import { Form } from \"@react-md/core/form/Form\";\n * import { useStorage } from \"@react-md/core/storage/useStorage\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, setValue, remove, persist } = useStorage({\n * key: \"someKey\",\n * manual: true,\n * defaultValue: false,\n * });\n *\n * return (\n * <Form\n * onSubmit={() => {\n * // current value will be saved into local storage\n * persist();\n * }}\n * onReset={() => {\n * // \"someKey\" will be removed from local storage\n * remove();\n * }}\n * >\n * <Checkbox\n * label=\"Allow cookies\"\n * checked={value}\n * onChange={(event) =>\n * setValue(event.currentTarget.checked);\n * }\n * />\n * <Button type=\"reset\">Decline</Button>\n * <Button type=\"submit\">Save</Button>\n * </Form>\n * );\n * }\n * ```\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage\n * @since 6.0.0\n */\nexport function useStorage<T>(\n options: StorageOptions<T>\n): StorageImplementation<T> {\n const {\n key,\n defaultValue,\n manual,\n storage = globalThis.localStorage,\n } = options;\n\n const [initialValue] = useState(defaultValue);\n const { serializer, deserializer } = useMemo(\n () =>\n getStorageSerializers({\n raw: options.raw,\n serializer: options.serializer,\n deserializer: options.deserializer,\n initialValue,\n }),\n [initialValue, options.deserializer, options.raw, options.serializer]\n );\n\n const ssr = useSsr();\n const [value, setStoredValue] = useState<T>(() => {\n if (ssr) {\n return initialValue;\n }\n\n return getItemFromStorage({\n key,\n storage,\n fallback: initialValue,\n deserializer,\n });\n });\n\n const config = useRef({\n key,\n value,\n manual,\n storage,\n serializer,\n deserializer,\n defaultValue: initialValue,\n } as const);\n useIsomorphicLayoutEffect(() => {\n config.current = {\n key,\n value,\n manual,\n storage,\n serializer,\n deserializer,\n defaultValue: initialValue,\n };\n });\n\n const setValue = useCallback<UseStateSetter<T>>((valueOrDispatcher) => {\n const { key, manual, storage, serializer } = config.current;\n\n setStoredValue((prevValue) => {\n const nextValue =\n valueOrDispatcher instanceof Function\n ? valueOrDispatcher(prevValue)\n : valueOrDispatcher;\n\n if (!manual && nextValue !== prevValue) {\n setItemInStorage({\n key,\n value: nextValue,\n storage,\n serializer,\n });\n }\n\n return nextValue;\n });\n }, []);\n\n const remove = useCallback(() => {\n removeItemFromStorage(config.current);\n }, []);\n\n const persist = useCallback(() => {\n setItemInStorage(config.current);\n }, []);\n\n // make sure to sync the value in local storage\n useEffect(() => {\n const { value, manual, storage, serializer } = config.current;\n if (ssr || !key || !value || manual || !storage) {\n return;\n }\n\n setItemInStorage({\n key,\n value,\n storage,\n serializer,\n });\n }, [key, ssr]);\n useEffect(() => {\n const { defaultValue, storage, deserializer, manual } = config.current;\n if (manual || !ssr) {\n return;\n }\n\n // do not want to trigger the emit behavior for rehydration\n setStoredValue(\n getItemFromStorage({\n key,\n storage,\n fallback: defaultValue,\n deserializer,\n })\n );\n }, [key, ssr]);\n\n // update the value if another tab changed the local storage value\n useEffect(() => {\n if (!key) {\n return;\n }\n\n const callback = (event: StorageEvent): void => {\n const { storage, defaultValue, deserializer } = config.current;\n if (event.key === key && event.storageArea === storage) {\n setStoredValue(\n getItemFromStorage({\n key,\n storage,\n fallback: defaultValue,\n deserializer,\n })\n );\n }\n };\n\n window.addEventListener(\"storage\", callback);\n return () => {\n window.removeEventListener(\"storage\", callback);\n };\n }, [key]);\n\n return {\n value,\n setValue,\n remove,\n persist,\n };\n}\n"],"names":["useCallback","useEffect","useMemo","useRef","useState","useSsr","useIsomorphicLayoutEffect","getStorageSerializers","getItemFromStorage","removeItemFromStorage","setItemInStorage","useStorage","options","key","defaultValue","manual","storage","globalThis","localStorage","initialValue","serializer","deserializer","raw","ssr","value","setStoredValue","fallback","config","current","setValue","valueOrDispatcher","prevValue","nextValue","Function","remove","persist","callback","event","storageArea","window","addEventListener","removeEventListener"],"mappings":"AAAA;AAEA,SAASA,WAAW,EAAEC,SAAS,EA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;YAEJ;QACF;QAEAkB,OAAOC,gBAAgB,CAAC,WAAWJ;QACnC,OAAO;YACLG,OAAOE,mBAAmB,CAAC,WAAWL;QACxC;IACF,GAAG;QAACvB;KAAI;IAER,OAAO;QACLW;QACAK;QACAK;QACAC;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/storage/useStorage.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { useSsr } from \"../SsrProvider.js\";\nimport { type UseStateSetter } from \"../types.js\";\nimport { useIsomorphicLayoutEffect } from \"../useIsomorphicLayoutEffect.js\";\nimport { getStorageSerializers } from \"./internalUtils.js\";\nimport { type StorageImplementation, type StorageOptions } from \"./types.js\";\nimport {\n getItemFromStorage,\n removeItemFromStorage,\n setItemInStorage,\n} from \"./utils.js\";\n\n/**\n * The `useStorage` hook can be used to read and write from `localStorage`\n * (default) or `sessionStorage`. The default behavior will automatically sync\n * the value across tabs using the `StorageEvent`.\n *\n * @example Simple Example\n * ```tsx\n * import { TextField } from \"@react-md/core/form/TextField\";\n * import { useStorage } from \"@react-md/core/storage/useStorage\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useStorage({\n * key: \"savedSearch\",\n * defaultValue: \"\",\n * });\n *\n * return (\n * <TextField\n * label=\"Search\"\n * placeholder=\"Search...\"\n * type=\"search\"\n * value={value}\n * onChange={(event) => {\n * setValue(event.currentTarget.value)\n * }}\n * />\n * );\n * }\n * ```\n *\n * @example Type-safe Objects\n * ```tsx\n * import { useStorage } from \"@react-md/core/storage/useStorage\";\n * import { type ReactElement } from \"react\";\n *\n * interface ExpectedSchema {\n * label: string;\n * value: string;\n * // others\n * }\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useStorage<ExpectedSchema | null>({\n * key: \"someKey\",\n * defaultValue: null,\n *\n * // this is optional: you can create a custom deserializer to validate\n * // the stored value to prevent people manually updating local storage in\n * // the dev tools\n * deserializer(item) {\n * const parsed = JSON.parse(item):\n * const { label, value } = parsed;\n * if (typeof label !== 'string' || typeof value !== 'string') {\n * return null;\n * }\n *\n * return { label, value };\n * }\n * });\n *\n * // do something\n * // value will be `ExpectedSchema | null`\n * }\n * ```\n *\n * @example Manual Persistence\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Checkbox } from \"@react-md/core/form/Checkbox\";\n * import { Form } from \"@react-md/core/form/Form\";\n * import { useStorage } from \"@react-md/core/storage/useStorage\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, setValue, remove, persist } = useStorage({\n * key: \"someKey\",\n * manual: true,\n * defaultValue: false,\n * });\n *\n * return (\n * <Form\n * onSubmit={() => {\n * // current value will be saved into local storage\n * persist();\n * }}\n * onReset={() => {\n * // \"someKey\" will be removed from local storage\n * remove();\n * }}\n * >\n * <Checkbox\n * label=\"Allow cookies\"\n * checked={value}\n * onChange={(event) =>\n * setValue(event.currentTarget.checked);\n * }\n * />\n * <Button type=\"reset\">Decline</Button>\n * <Button type=\"submit\">Save</Button>\n * </Form>\n * );\n * }\n * ```\n *\n * @see {@link https://next.react-md.dev/hooks/use-storage | useStorage Demos}\n * @see https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage\n * @since 6.0.0\n */\nexport function useStorage<T>(\n options: StorageOptions<T>\n): StorageImplementation<T> {\n const {\n key,\n defaultValue,\n manual,\n storage = globalThis.localStorage,\n } = options;\n\n const [initialValue] = useState(defaultValue);\n const { serializer, deserializer } = useMemo(\n () =>\n getStorageSerializers({\n raw: options.raw,\n serializer: options.serializer,\n deserializer: options.deserializer,\n initialValue,\n }),\n [initialValue, options.deserializer, options.raw, options.serializer]\n );\n\n const ssr = useSsr();\n const [value, setStoredValue] = useState<T>(() => {\n if (ssr) {\n return initialValue;\n }\n\n return getItemFromStorage({\n key,\n storage,\n fallback: initialValue,\n deserializer,\n });\n });\n\n const config = useRef({\n key,\n value,\n manual,\n storage,\n serializer,\n deserializer,\n defaultValue: initialValue,\n } as const);\n useIsomorphicLayoutEffect(() => {\n config.current = {\n key,\n value,\n manual,\n storage,\n serializer,\n deserializer,\n defaultValue: initialValue,\n };\n });\n\n const setValue = useCallback<UseStateSetter<T>>((valueOrDispatcher) => {\n const { key, manual, storage, serializer } = config.current;\n\n setStoredValue((prevValue) => {\n const nextValue =\n valueOrDispatcher instanceof Function\n ? valueOrDispatcher(prevValue)\n : valueOrDispatcher;\n\n if (!manual && nextValue !== prevValue) {\n setItemInStorage({\n key,\n value: nextValue,\n storage,\n serializer,\n });\n }\n\n return nextValue;\n });\n }, []);\n\n const remove = useCallback(() => {\n removeItemFromStorage(config.current);\n }, []);\n\n const persist = useCallback(() => {\n setItemInStorage(config.current);\n }, []);\n\n // make sure to sync the value in local storage\n useEffect(() => {\n const { value, manual, storage, serializer } = config.current;\n if (ssr || !key || !value || manual || !storage) {\n return;\n }\n\n setItemInStorage({\n key,\n value,\n storage,\n serializer,\n });\n }, [key, ssr]);\n useEffect(() => {\n const { defaultValue, storage, deserializer, manual } = config.current;\n if (manual || !ssr) {\n return;\n }\n\n // do not want to trigger the emit behavior for rehydration\n setStoredValue(\n getItemFromStorage({\n key,\n storage,\n fallback: defaultValue,\n deserializer,\n })\n );\n }, [key, ssr]);\n\n // update the value if another tab changed the local storage value\n useEffect(() => {\n if (!key) {\n return;\n }\n\n const callback = (event: StorageEvent): void => {\n const { storage, defaultValue, deserializer } = config.current;\n if (event.key === key && event.storageArea === storage) {\n setStoredValue(\n getItemFromStorage({\n key,\n storage,\n fallback: defaultValue,\n deserializer,\n })\n );\n }\n };\n\n window.addEventListener(\"storage\", callback);\n return () => {\n window.removeEventListener(\"storage\", callback);\n };\n }, [key]);\n\n return {\n value,\n setValue,\n remove,\n persist,\n };\n}\n"],"names":["useCallback","useEffect","useMemo","useRef","useState","useSsr","useIsomorphicLayoutEffect","getStorageSerializers","getItemFromStorage","removeItemFromStorage","setItemInStorage","useStorage","options","key","defaultValue","manual","storage","globalThis","localStorage","initialValue","serializer","deserializer","raw","ssr","value","setStoredValue","fallback","config","current","setValue","valueOrDispatcher","prevValue","nextValue","Function","remove","persist","callback","event","storageArea","window","addEventListener","removeEventListener"],"mappings":"AAAA;AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE1E,SAASC,MAAM,QAAQ,oBAAoB;AAE3C,SAASC,yBAAyB,QAAQ,kCAAkC;AAC5E,SAASC,qBAAqB,QAAQ,qBAAqB;AAE3D,SACEC,kBAAkB,EAClBC,qBAAqB,EACrBC,gBAAgB,QACX,aAAa;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+GC,GACD,OAAO,SAASC,WACdC,OAA0B;IAE1B,MAAM,EACJC,GAAG,EACHC,YAAY,EACZC,MAAM,EACNC,UAAUC,WAAWC,YAAY,EAClC,GAAGN;IAEJ,MAAM,CAACO,aAAa,GAAGf,SAASU;IAChC,MAAM,EAAEM,UAAU,EAAEC,YAAY,EAAE,GAAGnB,QACnC,IACEK,sBAAsB;YACpBe,KAAKV,QAAQU,GAAG;YAChBF,YAAYR,QAAQQ,UAAU;YAC9BC,cAAcT,QAAQS,YAAY;YAClCF;QACF,IACF;QAACA;QAAcP,QAAQS,YAAY;QAAET,QAAQU,GAAG;QAAEV,QAAQQ,UAAU;KAAC;IAGvE,MAAMG,MAAMlB;IACZ,MAAM,CAACmB,OAAOC,eAAe,GAAGrB,SAAY;QAC1C,IAAImB,KAAK;YACP,OAAOJ;QACT;QAEA,OAAOX,mBAAmB;YACxBK;YACAG;YACAU,UAAUP;YACVE;QACF;IACF;IAEA,MAAMM,SAASxB,O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