@react-md/core 1.0.0-next.11 → 1.0.0-next.13
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +36 -0
- package/coverage/clover.xml +255 -3
- package/coverage/coverage-final.json +5 -1
- package/coverage/lcov-report/DefaultNavigationRenderer.tsx.html +298 -0
- package/coverage/lcov-report/Navigation.tsx.html +358 -0
- package/coverage/lcov-report/app-bar/AppBar.tsx.html +125 -134
- package/coverage/lcov-report/app-bar/AppBarTitle.tsx.html +54 -75
- package/coverage/lcov-report/app-bar/index.html +24 -9
- package/coverage/lcov-report/autocomplete/Autocomplete.tsx.html +34 -181
- package/coverage/lcov-report/autocomplete/AutocompleteGeneric.tsx.html +1 -1
- package/coverage/lcov-report/autocomplete/index.html +11 -11
- package/coverage/lcov-report/autocomplete/useAutocomplete.ts.html +102 -336
- package/coverage/lcov-report/autocomplete/useAutocompleteAgain.ts.html +1 -1
- package/coverage/lcov-report/autocomplete/useAutocompletev2.ts.html +1 -1
- package/coverage/lcov-report/autocomplete/useInlineAutocomplete.ts.html +31 -7
- package/coverage/lcov-report/autocomplete/useInlineSelection.ts.html +67 -4
- package/coverage/lcov-report/autocomplete/utils.ts.html +1 -1
- package/coverage/lcov-report/box/Box.tsx.html +115 -103
- package/coverage/lcov-report/box/index.html +22 -7
- package/coverage/lcov-report/box/styles.ts.html +622 -0
- package/coverage/lcov-report/button/Button.tsx.html +93 -105
- package/coverage/lcov-report/button/TooltippedButton.tsx.html +55 -67
- package/coverage/lcov-report/button/index.html +10 -10
- package/coverage/lcov-report/form/Form.tsx.html +18 -18
- package/coverage/lcov-report/form/Radio.tsx.html +8 -14
- package/coverage/lcov-report/form/index.html +35 -95
- package/coverage/lcov-report/form/useRadioGroup.ts.html +68 -80
- package/coverage/lcov-report/getHrefFromParents.ts.html +133 -0
- package/coverage/lcov-report/icon/FontIcon.tsx.html +65 -65
- package/coverage/lcov-report/icon/index.html +19 -19
- package/coverage/lcov-report/index.html +41 -11
- package/coverage/lcov-report/layout/LayoutNav.tsx.html +74 -86
- package/coverage/lcov-report/layout/Main.tsx.html +47 -38
- package/coverage/lcov-report/layout/index.html +54 -9
- package/coverage/lcov-report/layout/useExpandableLayout.ts.html +275 -89
- package/coverage/lcov-report/layout/useHorizontalLayoutTransition.ts.html +18 -18
- package/coverage/lcov-report/media-queries/AppSizeProvider.tsx.html +79 -64
- package/coverage/lcov-report/media-queries/index.html +18 -18
- package/coverage/lcov-report/navigation/CollapsibleNavGroup.tsx.html +334 -0
- package/coverage/lcov-report/navigation/DefaultNavigationRenderer.tsx.html +298 -0
- package/coverage/lcov-report/navigation/NavGroup.tsx.html +193 -0
- package/coverage/lcov-report/navigation/NavItem.tsx.html +160 -0
- package/coverage/lcov-report/navigation/NavItemButton.tsx.html +397 -0
- package/coverage/lcov-report/navigation/NavItemLink.tsx.html +574 -0
- package/coverage/lcov-report/navigation/NavSubheader.tsx.html +184 -0
- package/coverage/lcov-report/navigation/Navigation.tsx.html +358 -0
- package/coverage/lcov-report/navigation/getHrefFromParents.ts.html +130 -0
- package/coverage/lcov-report/navigation/index.html +146 -0
- package/coverage/lcov-report/navigation/navGroupStyles.ts.html +148 -0
- package/coverage/lcov-report/navigation/navItemStyles.ts.html +298 -0
- package/coverage/lcov-report/sheet/Sheet.tsx.html +50 -56
- package/coverage/lcov-report/sheet/index.html +8 -8
- package/coverage/lcov-report/snackbar/DefaultToastRenderer.tsx.html +307 -304
- package/coverage/lcov-report/snackbar/ToastManager.tsx.html +377 -356
- package/coverage/lcov-report/snackbar/index.html +16 -106
- package/coverage/lcov-report/src/autocomplete/Autocomplete.tsx.html +56 -92
- package/coverage/lcov-report/src/autocomplete/AutocompleteGeneric.tsx.html +1 -1
- package/coverage/lcov-report/src/autocomplete/index.html +11 -11
- package/coverage/lcov-report/src/autocomplete/useAutocomplete.ts.html +513 -111
- package/coverage/lcov-report/src/autocomplete/useAutocompleteAgain.ts.html +7 -7
- package/coverage/lcov-report/src/autocomplete/useAutocompletev2.ts.html +1 -1
- package/coverage/lcov-report/src/autocomplete/useInlineAutocomplete.ts.html +32 -8
- package/coverage/lcov-report/src/autocomplete/useInlineSelection.ts.html +146 -14
- package/coverage/lcov-report/src/autocomplete/utils.ts.html +1 -1
- package/coverage/lcov-report/src/divider/Divider.tsx.html +6 -9
- package/coverage/lcov-report/src/divider/index.html +8 -23
- package/coverage/lcov-report/src/icon/FontIcon.tsx.html +29 -29
- package/coverage/lcov-report/src/icon/index.html +1 -1
- package/coverage/lcov-report/src/index.html +21 -21
- package/coverage/lcov-report/src/layout/LayoutAppBar.tsx.html +33 -42
- package/coverage/lcov-report/src/layout/Main.tsx.html +33 -36
- package/coverage/lcov-report/src/layout/index.html +15 -195
- package/coverage/lcov-report/src/layout/useLayoutAppBarHeight.ts.html +37 -46
- package/coverage/lcov-report/src/list/List.tsx.html +39 -42
- package/coverage/lcov-report/src/list/index.html +10 -130
- package/coverage/lcov-report/src/navigation/CollapsibleNavGroup.tsx.html +367 -0
- package/coverage/lcov-report/src/navigation/DefaultNavigationRenderer.tsx.html +325 -0
- package/coverage/lcov-report/src/navigation/NavGroup.tsx.html +202 -0
- package/coverage/lcov-report/src/navigation/NavItem.tsx.html +172 -0
- package/coverage/lcov-report/src/navigation/NavSubheader.tsx.html +193 -0
- package/coverage/lcov-report/src/navigation/Navigation.tsx.html +358 -0
- package/coverage/lcov-report/src/navigation/index.html +191 -0
- package/coverage/lcov-report/src/tree/Tree.tsx.html +12 -24
- package/coverage/lcov-report/src/tree/index.html +18 -18
- package/coverage/lcov-report/src/useElementSize.ts.html +115 -40
- package/coverage/lcov-report/src/useMutationObserver.ts.html +310 -0
- package/coverage/lcov-report/src/utils/RenderRecursively.tsx.html +151 -52
- package/coverage/lcov-report/src/utils/index.html +10 -10
- package/coverage/lcov-report/test-utils/index.html +21 -21
- package/coverage/lcov-report/test-utils/matchMedia.ts.html +98 -95
- package/coverage/lcov-report/transition/config.ts.html +7 -7
- package/coverage/lcov-report/transition/index.html +1 -1
- package/coverage/lcov-report/useExpandableLayout.ts.html +171 -105
- package/coverage/lcov-report/useMutationObserver.ts.html +310 -0
- package/coverage/lcov-report/utils/index.html +16 -16
- package/coverage/lcov-report/utils/isElementVisible.ts.html +21 -24
- package/coverage/lcov.info +302 -0
- package/dist/CoreProviders.d.ts +3 -3
- package/dist/CoreProviders.js +1 -1
- package/dist/CoreProviders.js.map +1 -1
- package/dist/NoSsr.d.ts +3 -4
- package/dist/NoSsr.js +2 -3
- package/dist/NoSsr.js.map +1 -1
- package/dist/RootHtml.d.ts +3 -4
- package/dist/RootHtml.js +2 -3
- package/dist/RootHtml.js.map +1 -1
- package/dist/SsrProvider.d.ts +3 -3
- package/dist/SsrProvider.js +2 -2
- package/dist/SsrProvider.js.map +1 -1
- package/dist/_core.scss +5 -0
- package/dist/app-bar/AppBar.d.ts +11 -14
- package/dist/app-bar/AppBar.js +3 -5
- package/dist/app-bar/AppBar.js.map +1 -1
- package/dist/app-bar/AppBarTitle.d.ts +9 -10
- package/dist/app-bar/AppBarTitle.js +4 -6
- package/dist/app-bar/AppBarTitle.js.map +1 -1
- package/dist/avatar/Avatar.d.ts +5 -6
- package/dist/avatar/Avatar.js +2 -3
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/avatar/styles.d.ts +4 -4
- package/dist/avatar/styles.js +2 -2
- package/dist/avatar/styles.js.map +1 -1
- package/dist/badge/Badge.d.ts +4 -6
- package/dist/badge/Badge.js +3 -5
- package/dist/badge/Badge.js.map +1 -1
- package/dist/box/Box.d.ts +6 -9
- package/dist/box/Box.js +14 -9
- package/dist/box/Box.js.map +1 -1
- package/dist/box/_box.scss +1 -1
- package/dist/box/styles.d.ts +9 -9
- package/dist/box/styles.js +1 -1
- package/dist/box/styles.js.map +1 -1
- package/dist/button/AsyncButton.d.ts +5 -7
- package/dist/button/AsyncButton.js +3 -5
- package/dist/button/AsyncButton.js.map +1 -1
- package/dist/button/Button.d.ts +4 -8
- package/dist/button/Button.js +4 -8
- package/dist/button/Button.js.map +1 -1
- package/dist/button/ButtonUnstyled.d.ts +2 -2
- package/dist/button/ButtonUnstyled.js +1 -1
- package/dist/button/ButtonUnstyled.js.map +1 -1
- package/dist/button/FloatingActionButton.d.ts +5 -5
- package/dist/button/FloatingActionButton.js +2 -2
- package/dist/button/FloatingActionButton.js.map +1 -1
- package/dist/button/TooltippedButton.d.ts +2 -2
- package/dist/button/TooltippedButton.js +2 -5
- package/dist/button/TooltippedButton.js.map +1 -1
- package/dist/button/buttonStyles.d.ts +3 -3
- package/dist/button/buttonStyles.js +1 -1
- package/dist/button/buttonStyles.js.map +1 -1
- package/dist/button/buttonUnstyledStyles.d.ts +2 -2
- package/dist/button/buttonUnstyledStyles.js +1 -1
- package/dist/button/buttonUnstyledStyles.js.map +1 -1
- package/dist/card/Card.d.ts +3 -4
- package/dist/card/Card.js +2 -3
- package/dist/card/Card.js.map +1 -1
- package/dist/card/CardContent.d.ts +2 -4
- package/dist/card/CardContent.js +1 -2
- package/dist/card/CardContent.js.map +1 -1
- package/dist/card/CardFooter.d.ts +2 -2
- package/dist/card/CardFooter.js +1 -1
- package/dist/card/CardFooter.js.map +1 -1
- package/dist/card/CardHeader.d.ts +10 -12
- package/dist/card/CardHeader.js +6 -7
- package/dist/card/CardHeader.js.map +1 -1
- package/dist/card/CardSubtitle.d.ts +2 -2
- package/dist/card/CardSubtitle.js +1 -1
- package/dist/card/CardSubtitle.js.map +1 -1
- package/dist/card/CardTitle.d.ts +2 -2
- package/dist/card/CardTitle.js +1 -1
- package/dist/card/CardTitle.js.map +1 -1
- package/dist/card/ClickableCard.d.ts +3 -4
- package/dist/card/ClickableCard.js +2 -3
- package/dist/card/ClickableCard.js.map +1 -1
- package/dist/card/styles.d.ts +15 -15
- package/dist/card/styles.js +7 -7
- package/dist/card/styles.js.map +1 -1
- package/dist/chip/Chip.d.ts +10 -14
- package/dist/chip/Chip.js +4 -7
- package/dist/chip/Chip.js.map +1 -1
- package/dist/chip/styles.d.ts +4 -4
- package/dist/chip/styles.js +2 -2
- package/dist/chip/styles.js.map +1 -1
- package/dist/cssUtils.d.ts +10 -10
- package/dist/cssUtils.js +1 -1
- package/dist/cssUtils.js.map +1 -1
- package/dist/delegateEvent.js.map +1 -1
- package/dist/dialog/Dialog.d.ts +5 -6
- package/dist/dialog/Dialog.js +4 -5
- package/dist/dialog/Dialog.js.map +1 -1
- package/dist/dialog/DialogContainer.d.ts +2 -2
- package/dist/dialog/DialogContainer.js +1 -1
- package/dist/dialog/DialogContainer.js.map +1 -1
- package/dist/dialog/DialogContent.js.map +1 -1
- package/dist/dialog/DialogFooter.js.map +1 -1
- package/dist/dialog/DialogHeader.js.map +1 -1
- package/dist/dialog/DialogTitle.d.ts +3 -2
- package/dist/dialog/DialogTitle.js.map +1 -1
- package/dist/dialog/FixedDialog.d.ts +1 -2
- package/dist/dialog/FixedDialog.js +1 -2
- package/dist/dialog/FixedDialog.js.map +1 -1
- package/dist/dialog/NestedDialogProvider.js.map +1 -1
- package/dist/dialog/styles.d.ts +9 -9
- package/dist/dialog/styles.js +4 -4
- package/dist/dialog/styles.js.map +1 -1
- package/dist/divider/Divider.d.ts +2 -3
- package/dist/divider/Divider.js +1 -2
- package/dist/divider/Divider.js.map +1 -1
- package/dist/divider/styles.d.ts +2 -2
- package/dist/divider/styles.js +1 -1
- package/dist/divider/styles.js.map +1 -1
- package/dist/draggable/useDraggable.d.ts +17 -18
- package/dist/draggable/useDraggable.js +2 -2
- package/dist/draggable/useDraggable.js.map +1 -1
- package/dist/draggable/utils.d.ts +2 -2
- package/dist/draggable/utils.js +1 -1
- package/dist/draggable/utils.js.map +1 -1
- package/dist/expansion-panel/ExpansionList.d.ts +2 -2
- package/dist/expansion-panel/ExpansionList.js +1 -1
- package/dist/expansion-panel/ExpansionList.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanel.d.ts +8 -9
- package/dist/expansion-panel/ExpansionPanel.js +2 -3
- package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.d.ts +5 -5
- package/dist/expansion-panel/ExpansionPanelHeader.js +3 -4
- package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
- package/dist/expansion-panel/useExpansionList.d.ts +5 -6
- package/dist/expansion-panel/useExpansionList.js +4 -5
- package/dist/expansion-panel/useExpansionList.js.map +1 -1
- package/dist/expansion-panel/useExpansionPanels.d.ts +9 -14
- package/dist/expansion-panel/useExpansionPanels.js +3 -6
- package/dist/expansion-panel/useExpansionPanels.js.map +1 -1
- package/dist/focus/useFocusContainer.d.ts +9 -10
- package/dist/focus/useFocusContainer.js +2 -3
- package/dist/focus/useFocusContainer.js.map +1 -1
- package/dist/focus/utils.d.ts +4 -5
- package/dist/focus/utils.js +3 -4
- package/dist/focus/utils.js.map +1 -1
- package/dist/form/Checkbox.d.ts +1 -2
- package/dist/form/Checkbox.js +1 -2
- package/dist/form/Checkbox.js.map +1 -1
- package/dist/form/Fieldset.d.ts +5 -6
- package/dist/form/Fieldset.js +2 -3
- package/dist/form/Fieldset.js.map +1 -1
- package/dist/form/FileInput.d.ts +6 -7
- package/dist/form/FileInput.js +3 -4
- package/dist/form/FileInput.js.map +1 -1
- package/dist/form/Form.js.map +1 -1
- package/dist/form/FormMessage.js.map +1 -1
- package/dist/form/FormMessageContainer.d.ts +2 -2
- package/dist/form/FormMessageContainer.js +1 -1
- package/dist/form/FormMessageContainer.js.map +1 -1
- package/dist/form/FormMessageCounter.d.ts +4 -6
- package/dist/form/FormMessageCounter.js +2 -3
- package/dist/form/FormMessageCounter.js.map +1 -1
- package/dist/form/InputToggle.d.ts +11 -12
- package/dist/form/InputToggle.js +1 -1
- package/dist/form/InputToggle.js.map +1 -1
- package/dist/form/InputToggleIcon.d.ts +4 -6
- package/dist/form/InputToggleIcon.js +2 -3
- package/dist/form/InputToggleIcon.js.map +1 -1
- package/dist/form/Label.d.ts +2 -2
- package/dist/form/Label.js +2 -2
- package/dist/form/Label.js.map +1 -1
- package/dist/form/Legend.d.ts +2 -2
- package/dist/form/Legend.js +1 -1
- package/dist/form/Legend.js.map +1 -1
- package/dist/form/MenuItemCheckbox.d.ts +2 -3
- package/dist/form/MenuItemCheckbox.js +2 -3
- package/dist/form/MenuItemCheckbox.js.map +1 -1
- package/dist/form/MenuItemFileInput.d.ts +3 -5
- package/dist/form/MenuItemFileInput.js +2 -3
- package/dist/form/MenuItemFileInput.js.map +1 -1
- package/dist/form/MenuItemInputToggle.d.ts +7 -9
- package/dist/form/MenuItemInputToggle.js +1 -1
- package/dist/form/MenuItemInputToggle.js.map +1 -1
- package/dist/form/MenuItemRadio.d.ts +3 -5
- package/dist/form/MenuItemRadio.js +3 -5
- package/dist/form/MenuItemRadio.js.map +1 -1
- package/dist/form/MenuItemSwitch.d.ts +2 -3
- package/dist/form/MenuItemSwitch.js +2 -3
- package/dist/form/MenuItemSwitch.js.map +1 -1
- package/dist/form/MenuItemTextField.d.ts +2 -2
- package/dist/form/MenuItemTextField.js +1 -1
- package/dist/form/MenuItemTextField.js.map +1 -1
- package/dist/form/NativeSelect.d.ts +3 -5
- package/dist/form/NativeSelect.js +2 -4
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/OptGroup.d.ts +3 -4
- package/dist/form/OptGroup.js +2 -3
- package/dist/form/OptGroup.js.map +1 -1
- package/dist/form/Option.d.ts +5 -7
- package/dist/form/Option.js +3 -4
- package/dist/form/Option.js.map +1 -1
- package/dist/form/Password.d.ts +7 -13
- package/dist/form/Password.js +1 -2
- package/dist/form/Password.js.map +1 -1
- package/dist/form/Radio.d.ts +1 -2
- package/dist/form/Radio.js +1 -2
- package/dist/form/Radio.js.map +1 -1
- package/dist/form/ResizingTextAreaWrapper.d.ts +2 -2
- package/dist/form/ResizingTextAreaWrapper.js +1 -1
- package/dist/form/ResizingTextAreaWrapper.js.map +1 -1
- package/dist/form/Select.d.ts +6 -9
- package/dist/form/Select.js +3 -5
- package/dist/form/Select.js.map +1 -1
- package/dist/form/SelectedOption.d.ts +2 -2
- package/dist/form/SelectedOption.js +1 -1
- package/dist/form/SelectedOption.js.map +1 -1
- package/dist/form/Slider.d.ts +16 -25
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/SliderContainer.d.ts +6 -9
- package/dist/form/SliderContainer.js +2 -3
- package/dist/form/SliderContainer.js.map +1 -1
- package/dist/form/SliderMark.d.ts +2 -2
- package/dist/form/SliderMark.js +1 -1
- package/dist/form/SliderMark.js.map +1 -1
- package/dist/form/SliderMarkLabel.d.ts +5 -4
- package/dist/form/SliderMarkLabel.js +1 -1
- package/dist/form/SliderMarkLabel.js.map +1 -1
- package/dist/form/SliderThumb.d.ts +6 -8
- package/dist/form/SliderThumb.js +3 -4
- package/dist/form/SliderThumb.js.map +1 -1
- package/dist/form/SliderTrack.d.ts +4 -6
- package/dist/form/SliderTrack.js +2 -3
- package/dist/form/SliderTrack.js.map +1 -1
- package/dist/form/SliderValueMarks.d.ts +7 -9
- package/dist/form/SliderValueMarks.js +1 -1
- package/dist/form/SliderValueMarks.js.map +1 -1
- package/dist/form/SliderValueTooltip.d.ts +4 -6
- package/dist/form/SliderValueTooltip.js +2 -3
- package/dist/form/SliderValueTooltip.js.map +1 -1
- package/dist/form/Switch.d.ts +3 -4
- package/dist/form/Switch.js +2 -3
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/SwitchTrack.js.map +1 -1
- package/dist/form/TextArea.d.ts +2 -3
- package/dist/form/TextArea.js +1 -2
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.d.ts +7 -10
- package/dist/form/TextField.js +2 -4
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/TextFieldAddon.d.ts +3 -3
- package/dist/form/TextFieldAddon.js +1 -1
- package/dist/form/TextFieldAddon.js.map +1 -1
- package/dist/form/TextFieldContainer.js.map +1 -1
- package/dist/form/fileUtils.d.ts +33 -36
- package/dist/form/fileUtils.js +14 -14
- package/dist/form/fileUtils.js.map +1 -1
- package/dist/form/formConfig.d.ts +2 -2
- package/dist/form/formConfig.js +2 -2
- package/dist/form/formConfig.js.map +1 -1
- package/dist/form/formMessageStyles.d.ts +5 -5
- package/dist/form/formMessageStyles.js +3 -3
- package/dist/form/formMessageStyles.js.map +1 -1
- package/dist/form/inputToggleStyles.d.ts +3 -3
- package/dist/form/inputToggleStyles.js +1 -1
- package/dist/form/inputToggleStyles.js.map +1 -1
- package/dist/form/menuItemInputToggleStyles.d.ts +8 -8
- package/dist/form/menuItemInputToggleStyles.js +4 -4
- package/dist/form/menuItemInputToggleStyles.js.map +1 -1
- package/dist/form/nativeSelectStyles.d.ts +4 -4
- package/dist/form/nativeSelectStyles.js +2 -2
- package/dist/form/nativeSelectStyles.js.map +1 -1
- package/dist/form/optionStyles.d.ts +2 -2
- package/dist/form/optionStyles.js +1 -1
- package/dist/form/optionStyles.js.map +1 -1
- package/dist/form/passwordStyles.d.ts +4 -4
- package/dist/form/passwordStyles.js +1 -1
- package/dist/form/passwordStyles.js.map +1 -1
- package/dist/form/selectStyles.d.ts +2 -2
- package/dist/form/selectStyles.js +1 -1
- package/dist/form/selectStyles.js.map +1 -1
- package/dist/form/selectUtils.d.ts +3 -3
- package/dist/form/selectUtils.js +2 -2
- package/dist/form/selectUtils.js.map +1 -1
- package/dist/form/sliderUtils.d.ts +9 -9
- package/dist/form/sliderUtils.js +4 -4
- package/dist/form/sliderUtils.js.map +1 -1
- package/dist/form/switchStyles.d.ts +2 -2
- package/dist/form/switchStyles.js +1 -1
- package/dist/form/switchStyles.js.map +1 -1
- package/dist/form/textAreaStyles.d.ts +4 -4
- package/dist/form/textAreaStyles.js +2 -2
- package/dist/form/textAreaStyles.js.map +1 -1
- package/dist/form/textFieldContainerStyles.d.ts +2 -2
- package/dist/form/textFieldContainerStyles.js +1 -1
- package/dist/form/textFieldContainerStyles.js.map +1 -1
- package/dist/form/textFieldStyles.d.ts +2 -2
- package/dist/form/textFieldStyles.js +1 -1
- package/dist/form/textFieldStyles.js.map +1 -1
- package/dist/form/types.d.ts +10 -10
- package/dist/form/types.js.map +1 -1
- package/dist/form/useCheckboxGroup.d.ts +15 -20
- package/dist/form/useCheckboxGroup.js.map +1 -1
- package/dist/form/useCombobox.d.ts +16 -16
- package/dist/form/useCombobox.js +2 -2
- package/dist/form/useCombobox.js.map +1 -1
- package/dist/form/useEditableCombobox.d.ts +3 -3
- package/dist/form/useEditableCombobox.js +1 -1
- package/dist/form/useEditableCombobox.js.map +1 -1
- package/dist/form/useFileUpload.d.ts +7 -8
- package/dist/form/useFileUpload.js +1 -1
- package/dist/form/useFileUpload.js.map +1 -1
- package/dist/form/useFormReset.d.ts +2 -2
- package/dist/form/useFormReset.js +1 -1
- package/dist/form/useFormReset.js.map +1 -1
- package/dist/form/useListboxProvider.d.ts +3 -3
- package/dist/form/useListboxProvider.js +2 -2
- package/dist/form/useListboxProvider.js.map +1 -1
- package/dist/form/useNumberField.d.ts +17 -25
- package/dist/form/useNumberField.js.map +1 -1
- package/dist/form/useRadioGroup.d.ts +12 -15
- package/dist/form/useRadioGroup.js +2 -3
- package/dist/form/useRadioGroup.js.map +1 -1
- package/dist/form/useRangeSlider.d.ts +8 -11
- package/dist/form/useRangeSlider.js +3 -5
- package/dist/form/useRangeSlider.js.map +1 -1
- package/dist/form/useResizingTextArea.js.map +1 -1
- package/dist/form/useSelectCombobox.d.ts +3 -3
- package/dist/form/useSelectCombobox.js +1 -1
- package/dist/form/useSelectCombobox.js.map +1 -1
- package/dist/form/useSlider.d.ts +7 -9
- package/dist/form/useSlider.js +3 -5
- package/dist/form/useSlider.js.map +1 -1
- package/dist/form/useTextField.d.ts +22 -31
- package/dist/form/useTextField.js.map +1 -1
- package/dist/form/utils.d.ts +7 -8
- package/dist/form/utils.js +5 -6
- package/dist/form/utils.js.map +1 -1
- package/dist/form/validation.d.ts +16 -16
- package/dist/form/validation.js +7 -7
- package/dist/form/validation.js.map +1 -1
- package/dist/hoverMode/useHoverMode.d.ts +9 -10
- package/dist/hoverMode/useHoverMode.js.map +1 -1
- package/dist/hoverMode/useHoverModeProvider.d.ts +11 -15
- package/dist/hoverMode/useHoverModeProvider.js +3 -4
- package/dist/hoverMode/useHoverModeProvider.js.map +1 -1
- package/dist/icon/FontIcon.d.ts +1 -1
- package/dist/icon/FontIcon.js +1 -1
- package/dist/icon/FontIcon.js.map +1 -1
- package/dist/icon/IconRotator.d.ts +1 -1
- package/dist/icon/IconRotator.js.map +1 -1
- package/dist/icon/MaterialIcon.d.ts +2 -2
- package/dist/icon/MaterialIcon.js +1 -1
- package/dist/icon/MaterialIcon.js.map +1 -1
- package/dist/icon/MaterialSymbol.d.ts +3 -4
- package/dist/icon/MaterialSymbol.js +2 -3
- package/dist/icon/MaterialSymbol.js.map +1 -1
- package/dist/icon/SVGIcon.d.ts +0 -1
- package/dist/icon/SVGIcon.js.map +1 -1
- package/dist/icon/TextIconSpacing.d.ts +3 -5
- package/dist/icon/TextIconSpacing.js +2 -4
- package/dist/icon/TextIconSpacing.js.map +1 -1
- package/dist/icon/iconConfig.d.ts +14 -16
- package/dist/icon/iconConfig.js +5 -7
- package/dist/icon/iconConfig.js.map +1 -1
- package/dist/icon/material.d.ts +4 -4
- package/dist/icon/material.js +1 -1
- package/dist/icon/material.js.map +1 -1
- package/dist/icon/materialConfig.d.ts +12 -12
- package/dist/icon/materialConfig.js +2 -2
- package/dist/icon/materialConfig.js.map +1 -1
- package/dist/icon/styles.d.ts +8 -8
- package/dist/icon/styles.js +2 -2
- package/dist/icon/styles.js.map +1 -1
- package/dist/interaction/Ripple.js.map +1 -1
- package/dist/interaction/RippleContainer.js.map +1 -1
- package/dist/interaction/UserInteractionModeProvider.d.ts +1 -2
- package/dist/interaction/UserInteractionModeProvider.js +1 -2
- package/dist/interaction/UserInteractionModeProvider.js.map +1 -1
- package/dist/interaction/config.d.ts +2 -2
- package/dist/interaction/config.js +1 -1
- package/dist/interaction/config.js.map +1 -1
- package/dist/interaction/types.d.ts +8 -8
- package/dist/interaction/types.js +1 -1
- package/dist/interaction/types.js.map +1 -1
- package/dist/interaction/useElementInteraction.d.ts +6 -7
- package/dist/interaction/useElementInteraction.js +3 -4
- package/dist/interaction/useElementInteraction.js.map +1 -1
- package/dist/interaction/useHigherContrastChildren.d.ts +2 -3
- package/dist/interaction/useHigherContrastChildren.js +2 -3
- package/dist/interaction/useHigherContrastChildren.js.map +1 -1
- package/dist/interaction/utils.js.map +1 -1
- package/dist/layout/LayoutAppBar.d.ts +4 -7
- package/dist/layout/LayoutAppBar.js +3 -6
- package/dist/layout/LayoutAppBar.js.map +1 -1
- package/dist/layout/LayoutNav.d.ts +4 -6
- package/dist/layout/LayoutNav.js +3 -5
- package/dist/layout/LayoutNav.js.map +1 -1
- package/dist/layout/LayoutWindowSplitter.d.ts +3 -4
- package/dist/layout/LayoutWindowSplitter.js +2 -3
- package/dist/layout/LayoutWindowSplitter.js.map +1 -1
- package/dist/layout/Main.d.ts +4 -5
- package/dist/layout/Main.js +2 -3
- package/dist/layout/Main.js.map +1 -1
- package/dist/layout/_layout.scss +12 -1
- package/dist/layout/layoutNavStyles.d.ts +2 -2
- package/dist/layout/layoutNavStyles.js +1 -1
- package/dist/layout/layoutNavStyles.js.map +1 -1
- package/dist/layout/layoutWindowSplitterStyles.d.ts +2 -2
- package/dist/layout/layoutWindowSplitterStyles.js +1 -1
- package/dist/layout/layoutWindowSplitterStyles.js.map +1 -1
- package/dist/layout/mainStyles.d.ts +2 -2
- package/dist/layout/mainStyles.js +1 -1
- package/dist/layout/mainStyles.js.map +1 -1
- package/dist/layout/useExpandableLayout.d.ts +66 -14
- package/dist/layout/useExpandableLayout.js +50 -5
- package/dist/layout/useExpandableLayout.js.map +1 -1
- package/dist/layout/useHorizontalLayoutTransition.d.ts +4 -4
- package/dist/layout/useHorizontalLayoutTransition.js +2 -2
- package/dist/layout/useHorizontalLayoutTransition.js.map +1 -1
- package/dist/layout/useLayoutAppBarHeight.d.ts +7 -9
- package/dist/layout/useLayoutAppBarHeight.js +7 -8
- package/dist/layout/useLayoutAppBarHeight.js.map +1 -1
- package/dist/layout/useLayoutTree.d.ts +6 -6
- package/dist/layout/useLayoutTree.js +1 -1
- package/dist/layout/useLayoutTree.js.map +1 -1
- package/dist/layout/useLayoutWindowSplitter.d.ts +5 -6
- package/dist/layout/useLayoutWindowSplitter.js +2 -3
- package/dist/layout/useLayoutWindowSplitter.js.map +1 -1
- package/dist/layout/useMainTabIndex.d.ts +1 -1
- package/dist/layout/useMainTabIndex.js +1 -1
- package/dist/layout/useMainTabIndex.js.map +1 -1
- package/dist/layout/useResizableLayout.d.ts +54 -8
- package/dist/layout/useResizableLayout.js +51 -5
- package/dist/layout/useResizableLayout.js.map +1 -1
- package/dist/layout/useTemporaryLayout.d.ts +12 -12
- package/dist/layout/useTemporaryLayout.js +1 -1
- package/dist/layout/useTemporaryLayout.js.map +1 -1
- package/dist/link/Link.d.ts +10 -13
- package/dist/link/Link.js +5 -7
- package/dist/link/Link.js.map +1 -1
- package/dist/link/SkipToMainContent.d.ts +2 -4
- package/dist/link/SkipToMainContent.js +1 -2
- package/dist/link/SkipToMainContent.js.map +1 -1
- package/dist/link/styles.d.ts +4 -4
- package/dist/link/styles.js +2 -2
- package/dist/link/styles.js.map +1 -1
- package/dist/list/List.d.ts +3 -4
- package/dist/list/List.js +2 -3
- package/dist/list/List.js.map +1 -1
- package/dist/list/ListItem.d.ts +4 -6
- package/dist/list/ListItem.js +2 -4
- package/dist/list/ListItem.js.map +1 -1
- package/dist/list/ListItemAddon.js.map +1 -1
- package/dist/list/ListItemChildren.d.ts +1 -2
- package/dist/list/ListItemChildren.js +1 -2
- package/dist/list/ListItemChildren.js.map +1 -1
- package/dist/list/ListItemLink.js.map +1 -1
- package/dist/list/ListItemText.js.map +1 -1
- package/dist/list/ListSubheader.d.ts +3 -3
- package/dist/list/ListSubheader.js +1 -1
- package/dist/list/ListSubheader.js.map +1 -1
- package/dist/list/getListItemHeight.d.ts +1 -1
- package/dist/list/getListItemHeight.js.map +1 -1
- package/dist/list/listItemStyles.d.ts +9 -9
- package/dist/list/listItemStyles.js +3 -3
- package/dist/list/listItemStyles.js.map +1 -1
- package/dist/list/types.d.ts +11 -11
- package/dist/list/types.js.map +1 -1
- package/dist/media-queries/AppSizeProvider.d.ts +1 -2
- package/dist/media-queries/AppSizeProvider.js +1 -2
- package/dist/media-queries/AppSizeProvider.js.map +1 -1
- package/dist/media-queries/appSize.js.map +1 -1
- package/dist/media-queries/useMediaQuery.d.ts +2 -3
- package/dist/media-queries/useMediaQuery.js +2 -3
- package/dist/media-queries/useMediaQuery.js.map +1 -1
- package/dist/menu/DropdownMenu.d.ts +7 -11
- package/dist/menu/DropdownMenu.js +4 -7
- package/dist/menu/DropdownMenu.js.map +1 -1
- package/dist/menu/Menu.d.ts +10 -13
- package/dist/menu/Menu.js +2 -3
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuBar.d.ts +3 -4
- package/dist/menu/MenuBar.js +3 -4
- package/dist/menu/MenuBar.js.map +1 -1
- package/dist/menu/MenuButton.d.ts +8 -8
- package/dist/menu/MenuButton.js +2 -2
- package/dist/menu/MenuButton.js.map +1 -1
- package/dist/menu/MenuConfigurationProvider.d.ts +8 -8
- package/dist/menu/MenuConfigurationProvider.js +5 -5
- package/dist/menu/MenuConfigurationProvider.js.map +1 -1
- package/dist/menu/MenuItem.d.ts +2 -2
- package/dist/menu/MenuItem.js +1 -1
- package/dist/menu/MenuItem.js.map +1 -1
- package/dist/menu/MenuItemButton.d.ts +2 -2
- package/dist/menu/MenuItemButton.js +1 -1
- package/dist/menu/MenuItemButton.js.map +1 -1
- package/dist/menu/MenuItemCircularProgress.d.ts +3 -4
- package/dist/menu/MenuItemCircularProgress.js +2 -3
- package/dist/menu/MenuItemCircularProgress.js.map +1 -1
- package/dist/menu/MenuItemGroup.d.ts +3 -4
- package/dist/menu/MenuItemGroup.js +2 -3
- package/dist/menu/MenuItemGroup.js.map +1 -1
- package/dist/menu/MenuItemSeparator.d.ts +2 -2
- package/dist/menu/MenuItemSeparator.js +1 -1
- package/dist/menu/MenuItemSeparator.js.map +1 -1
- package/dist/menu/MenuSheet.d.ts +7 -9
- package/dist/menu/MenuSheet.js +2 -3
- package/dist/menu/MenuSheet.js.map +1 -1
- package/dist/menu/MenuVisibilityProvider.d.ts +6 -8
- package/dist/menu/MenuVisibilityProvider.js +5 -6
- package/dist/menu/MenuVisibilityProvider.js.map +1 -1
- package/dist/menu/MenuWidget.d.ts +2 -2
- package/dist/menu/MenuWidget.js +1 -1
- package/dist/menu/MenuWidget.js.map +1 -1
- package/dist/menu/MenuWidgetKeyboardProvider.d.ts +2 -2
- package/dist/menu/MenuWidgetKeyboardProvider.js +1 -1
- package/dist/menu/MenuWidgetKeyboardProvider.js.map +1 -1
- package/dist/menu/useContextMenu.d.ts +8 -12
- package/dist/menu/useContextMenu.js +3 -5
- package/dist/menu/useContextMenu.js.map +1 -1
- package/dist/menu/useMenuBarProvider.d.ts +6 -6
- package/dist/menu/useMenuBarProvider.js +3 -3
- package/dist/menu/useMenuBarProvider.js.map +1 -1
- package/dist/menu/utils.d.ts +2 -2
- package/dist/menu/utils.js +1 -1
- package/dist/menu/utils.js.map +1 -1
- package/dist/movement/constants.d.ts +3 -3
- package/dist/movement/constants.js +3 -3
- package/dist/movement/constants.js.map +1 -1
- package/dist/movement/findMatchIndex.js.map +1 -1
- package/dist/movement/types.d.ts +16 -17
- package/dist/movement/types.js +1 -1
- package/dist/movement/types.js.map +1 -1
- package/dist/movement/useKeyboardMovementProvider.d.ts +5 -8
- package/dist/movement/useKeyboardMovementProvider.js +6 -9
- package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
- package/dist/movement/utils.d.ts +13 -13
- package/dist/movement/utils.js +10 -10
- package/dist/movement/utils.js.map +1 -1
- package/dist/navigation/CollapsibleNavGroup.d.ts +29 -0
- package/dist/navigation/CollapsibleNavGroup.js +49 -0
- package/dist/navigation/CollapsibleNavGroup.js.map +1 -0
- package/dist/navigation/DefaultNavigationRenderer.d.ts +22 -0
- package/dist/navigation/DefaultNavigationRenderer.js +58 -0
- package/dist/navigation/DefaultNavigationRenderer.js.map +1 -0
- package/dist/navigation/NavGroup.d.ts +18 -0
- package/dist/navigation/NavGroup.js +29 -0
- package/dist/navigation/NavGroup.js.map +1 -0
- package/dist/navigation/NavItem.d.ts +17 -0
- package/dist/navigation/NavItem.js +24 -0
- package/dist/navigation/NavItem.js.map +1 -0
- package/dist/navigation/NavItemButton.d.ts +26 -0
- package/dist/navigation/NavItemButton.js +65 -0
- package/dist/navigation/NavItemButton.js.map +1 -0
- package/dist/navigation/NavItemLink.d.ts +40 -0
- package/dist/navigation/NavItemLink.js +88 -0
- package/dist/navigation/NavItemLink.js.map +1 -0
- package/dist/navigation/NavSubheader.d.ts +16 -0
- package/dist/navigation/NavSubheader.js +26 -0
- package/dist/navigation/NavSubheader.js.map +1 -0
- package/dist/navigation/Navigation.d.ts +31 -0
- package/dist/navigation/Navigation.js +46 -0
- package/dist/navigation/Navigation.js.map +1 -0
- package/dist/navigation/_navigation.scss +99 -0
- package/dist/navigation/getHrefFromParents.d.ts +5 -0
- package/dist/navigation/getHrefFromParents.js +13 -0
- package/dist/navigation/getHrefFromParents.js.map +1 -0
- package/dist/navigation/navGroupStyles.d.ts +11 -0
- package/dist/navigation/navGroupStyles.js +13 -0
- package/dist/navigation/navGroupStyles.js.map +1 -0
- package/dist/navigation/navItemStyles.d.ts +33 -0
- package/dist/navigation/navItemStyles.js +31 -0
- package/dist/navigation/navItemStyles.js.map +1 -0
- package/dist/navigation/types.d.ts +137 -0
- package/dist/navigation/types.js +5 -0
- package/dist/navigation/types.js.map +1 -0
- package/dist/navigation/useActiveHeadingId.d.ts +54 -0
- package/dist/navigation/useActiveHeadingId.js +117 -0
- package/dist/navigation/useActiveHeadingId.js.map +1 -0
- package/dist/overlay/Overlay.d.ts +5 -6
- package/dist/overlay/Overlay.js +2 -3
- package/dist/overlay/Overlay.js.map +1 -1
- package/dist/overlay/overlayStyles.d.ts +4 -4
- package/dist/overlay/overlayStyles.js +3 -3
- package/dist/overlay/overlayStyles.js.map +1 -1
- package/dist/portal/Portal.d.ts +1 -2
- package/dist/portal/Portal.js +1 -2
- package/dist/portal/Portal.js.map +1 -1
- package/dist/portal/PortalContainerProvider.d.ts +4 -4
- package/dist/portal/PortalContainerProvider.js +2 -2
- package/dist/portal/PortalContainerProvider.js.map +1 -1
- package/dist/positioning/constants.js.map +1 -1
- package/dist/positioning/createHorizontalPosition.js.map +1 -1
- package/dist/positioning/createVerticalPosition.d.ts +1 -1
- package/dist/positioning/createVerticalPosition.js.map +1 -1
- package/dist/positioning/getFixedPosition.js +1 -1
- package/dist/positioning/getFixedPosition.js.map +1 -1
- package/dist/positioning/types.d.ts +4 -4
- package/dist/positioning/types.js.map +1 -1
- package/dist/positioning/useFixedPositioning.d.ts +8 -9
- package/dist/positioning/useFixedPositioning.js +2 -3
- package/dist/positioning/useFixedPositioning.js.map +1 -1
- package/dist/positioning/utils.d.ts +3 -3
- package/dist/positioning/utils.js +1 -1
- package/dist/positioning/utils.js.map +1 -1
- package/dist/progress/CircularProgress.d.ts +7 -10
- package/dist/progress/CircularProgress.js +3 -5
- package/dist/progress/CircularProgress.js.map +1 -1
- package/dist/progress/LinearProgress.d.ts +4 -6
- package/dist/progress/LinearProgress.js +3 -5
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/getProgressA11y.js.map +1 -1
- package/dist/progress/types.d.ts +5 -5
- package/dist/progress/types.js +1 -1
- package/dist/progress/types.js.map +1 -1
- package/dist/responsive-item/ResponsiveItemContainer.d.ts +10 -15
- package/dist/responsive-item/ResponsiveItemContainer.js +5 -8
- package/dist/responsive-item/ResponsiveItemContainer.js.map +1 -1
- package/dist/responsive-item/ResponsiveItemOverlay.d.ts +6 -7
- package/dist/responsive-item/ResponsiveItemOverlay.js +3 -4
- package/dist/responsive-item/ResponsiveItemOverlay.js.map +1 -1
- package/dist/responsive-item/styles.d.ts +2 -2
- package/dist/responsive-item/styles.js +1 -1
- package/dist/responsive-item/styles.js.map +1 -1
- package/dist/scroll/ScrollLock.d.ts +1 -1
- package/dist/scroll/ScrollLock.js +1 -1
- package/dist/scroll/ScrollLock.js.map +1 -1
- package/dist/scroll/getScrollbarWidth.js.map +1 -1
- package/dist/scroll/useScrollLock.d.ts +2 -3
- package/dist/scroll/useScrollLock.js +2 -3
- package/dist/scroll/useScrollLock.js.map +1 -1
- package/dist/searching/caseInsensitive.d.ts +9 -13
- package/dist/searching/caseInsensitive.js +1 -1
- package/dist/searching/caseInsensitive.js.map +1 -1
- package/dist/searching/fuzzy.d.ts +4 -5
- package/dist/searching/fuzzy.js +1 -1
- package/dist/searching/fuzzy.js.map +1 -1
- package/dist/searching/toSearchQuery.d.ts +1 -1
- package/dist/searching/toSearchQuery.js +1 -1
- package/dist/searching/toSearchQuery.js.map +1 -1
- package/dist/searching/types.d.ts +2 -2
- package/dist/searching/types.js +1 -1
- package/dist/searching/types.js.map +1 -1
- package/dist/searching/useFuzzyMatch.d.ts +3 -3
- package/dist/searching/useFuzzyMatch.js +1 -1
- package/dist/searching/useFuzzyMatch.js.map +1 -1
- package/dist/searching/utils.d.ts +3 -3
- package/dist/searching/utils.js +2 -2
- package/dist/searching/utils.js.map +1 -1
- package/dist/segmented-button/SegmentedButton.d.ts +3 -4
- package/dist/segmented-button/SegmentedButton.js +2 -3
- package/dist/segmented-button/SegmentedButton.js.map +1 -1
- package/dist/segmented-button/SegmentedButtonContainer.d.ts +3 -4
- package/dist/segmented-button/SegmentedButtonContainer.js +2 -3
- package/dist/segmented-button/SegmentedButtonContainer.js.map +1 -1
- package/dist/segmented-button/segmentedButtonContainerStyles.d.ts +2 -2
- package/dist/segmented-button/segmentedButtonContainerStyles.js +1 -1
- package/dist/segmented-button/segmentedButtonContainerStyles.js.map +1 -1
- package/dist/segmented-button/segmentedButtonStyles.d.ts +2 -2
- package/dist/segmented-button/segmentedButtonStyles.js +1 -1
- package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
- package/dist/sheet/Sheet.d.ts +1 -1
- package/dist/sheet/Sheet.js.map +1 -1
- package/dist/sheet/styles.d.ts +3 -3
- package/dist/sheet/styles.js +1 -1
- package/dist/sheet/styles.js.map +1 -1
- package/dist/snackbar/DefaultToastRenderer.d.ts +2 -2
- package/dist/snackbar/DefaultToastRenderer.js +1 -1
- package/dist/snackbar/DefaultToastRenderer.js.map +1 -1
- package/dist/snackbar/Snackbar.d.ts +3 -4
- package/dist/snackbar/Snackbar.js +2 -3
- package/dist/snackbar/Snackbar.js.map +1 -1
- package/dist/snackbar/Toast.d.ts +3 -3
- package/dist/snackbar/Toast.js +1 -1
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/snackbar/ToastActionButton.d.ts +2 -2
- package/dist/snackbar/ToastActionButton.js +1 -1
- package/dist/snackbar/ToastActionButton.js.map +1 -1
- package/dist/snackbar/ToastCloseButton.d.ts +2 -2
- package/dist/snackbar/ToastCloseButton.js +1 -1
- package/dist/snackbar/ToastCloseButton.js.map +1 -1
- package/dist/snackbar/ToastContent.d.ts +2 -2
- package/dist/snackbar/ToastContent.js +1 -1
- package/dist/snackbar/ToastContent.js.map +1 -1
- package/dist/snackbar/ToastManager.d.ts +17 -18
- package/dist/snackbar/ToastManager.js +21 -19
- package/dist/snackbar/ToastManager.js.map +1 -1
- package/dist/snackbar/ToastManagerProvider.d.ts +6 -6
- package/dist/snackbar/ToastManagerProvider.js +5 -5
- package/dist/snackbar/ToastManagerProvider.js.map +1 -1
- package/dist/snackbar/snackbarStyles.d.ts +4 -5
- package/dist/snackbar/snackbarStyles.js +1 -1
- package/dist/snackbar/snackbarStyles.js.map +1 -1
- package/dist/snackbar/toastContentStyles.d.ts +2 -2
- package/dist/snackbar/toastContentStyles.js +1 -1
- package/dist/snackbar/toastContentStyles.js.map +1 -1
- package/dist/snackbar/toastStyles.d.ts +2 -2
- package/dist/snackbar/toastStyles.js +1 -1
- package/dist/snackbar/toastStyles.js.map +1 -1
- package/dist/snackbar/useCurrentToastActions.d.ts +3 -3
- package/dist/snackbar/useCurrentToastActions.js +2 -2
- package/dist/snackbar/useCurrentToastActions.js.map +1 -1
- package/dist/suspense/CircularProgressSuspense.d.ts +3 -4
- package/dist/suspense/CircularProgressSuspense.js +2 -3
- package/dist/suspense/CircularProgressSuspense.js.map +1 -1
- package/dist/suspense/NullSuspense.d.ts +3 -4
- package/dist/suspense/NullSuspense.js +2 -3
- package/dist/suspense/NullSuspense.js.map +1 -1
- package/dist/table/Table.d.ts +1 -2
- package/dist/table/Table.js +1 -2
- package/dist/table/Table.js.map +1 -1
- package/dist/table/TableBody.js.map +1 -1
- package/dist/table/TableCell.d.ts +7 -7
- package/dist/table/TableCell.js.map +1 -1
- package/dist/table/TableCellContent.d.ts +3 -3
- package/dist/table/TableCellContent.js.map +1 -1
- package/dist/table/TableCheckbox.d.ts +11 -15
- package/dist/table/TableCheckbox.js +4 -6
- package/dist/table/TableCheckbox.js.map +1 -1
- package/dist/table/TableConfigurationProvider.js.map +1 -1
- package/dist/table/TableContainer.js.map +1 -1
- package/dist/table/TableContainerProvider.d.ts +3 -3
- package/dist/table/TableContainerProvider.js +2 -2
- package/dist/table/TableContainerProvider.js.map +1 -1
- package/dist/table/TableFooter.d.ts +2 -2
- package/dist/table/TableFooter.js +1 -1
- package/dist/table/TableFooter.js.map +1 -1
- package/dist/table/TableHeader.d.ts +2 -2
- package/dist/table/TableHeader.js +1 -1
- package/dist/table/TableHeader.js.map +1 -1
- package/dist/table/TableRadio.d.ts +7 -9
- package/dist/table/TableRadio.js +2 -3
- package/dist/table/TableRadio.js.map +1 -1
- package/dist/table/TableRow.js.map +1 -1
- package/dist/table/tableCellStyles.d.ts +2 -2
- package/dist/table/tableCellStyles.js +1 -1
- package/dist/table/tableCellStyles.js.map +1 -1
- package/dist/table/tableContainerStyles.d.ts +2 -2
- package/dist/table/tableContainerStyles.js +1 -1
- package/dist/table/tableContainerStyles.js.map +1 -1
- package/dist/table/tableFooterStyles.d.ts +1 -1
- package/dist/table/tableFooterStyles.js.map +1 -1
- package/dist/table/tableHeaderStyles.d.ts +2 -2
- package/dist/table/tableHeaderStyles.js +1 -1
- package/dist/table/tableHeaderStyles.js.map +1 -1
- package/dist/table/tableRowStyles.d.ts +2 -2
- package/dist/table/tableRowStyles.js +1 -1
- package/dist/table/tableRowStyles.js.map +1 -1
- package/dist/table/tableStyles.d.ts +2 -2
- package/dist/table/tableStyles.js +1 -1
- package/dist/table/tableStyles.js.map +1 -1
- package/dist/table/types.d.ts +7 -9
- package/dist/table/types.js +1 -1
- package/dist/table/types.js.map +1 -1
- package/dist/tabs/Tab.d.ts +4 -4
- package/dist/tabs/Tab.js +1 -1
- package/dist/tabs/Tab.js.map +1 -1
- package/dist/tabs/TabList.d.ts +2 -2
- package/dist/tabs/TabList.js +1 -1
- package/dist/tabs/TabList.js.map +1 -1
- package/dist/tabs/TabListScrollButton.d.ts +3 -3
- package/dist/tabs/TabListScrollButton.js +1 -1
- package/dist/tabs/TabListScrollButton.js.map +1 -1
- package/dist/tabs/tabIndicatorStyles.d.ts +2 -2
- package/dist/tabs/tabIndicatorStyles.js +1 -1
- package/dist/tabs/tabIndicatorStyles.js.map +1 -1
- package/dist/tabs/tabListScrollButtonStyles.d.ts +4 -4
- package/dist/tabs/tabListScrollButtonStyles.js +2 -2
- package/dist/tabs/tabListScrollButtonStyles.js.map +1 -1
- package/dist/tabs/tabListStyles.d.ts +2 -2
- package/dist/tabs/tabListStyles.js +1 -1
- package/dist/tabs/tabListStyles.js.map +1 -1
- package/dist/tabs/tabStyles.d.ts +2 -2
- package/dist/tabs/tabStyles.js +1 -1
- package/dist/tabs/tabStyles.js.map +1 -1
- package/dist/tabs/useTabList.js.map +1 -1
- package/dist/tabs/useTabs.d.ts +15 -20
- package/dist/tabs/useTabs.js +1 -1
- package/dist/tabs/useTabs.js.map +1 -1
- package/dist/tabs/utils.d.ts +3 -3
- package/dist/tabs/utils.js +1 -1
- package/dist/tabs/utils.js.map +1 -1
- package/dist/test-utils/IntersectionObserver.js.map +1 -1
- package/dist/test-utils/ResizeObserver.d.ts +9 -11
- package/dist/test-utils/ResizeObserver.js +6 -8
- package/dist/test-utils/ResizeObserver.js.map +1 -1
- package/dist/test-utils/data-testid.js.map +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/jest-setup.js.map +1 -1
- package/dist/test-utils/matchMedia.d.ts +13 -17
- package/dist/test-utils/matchMedia.js +9 -11
- package/dist/test-utils/matchMedia.js.map +1 -1
- package/dist/test-utils/polyfills/IntersectionObserver.js.map +1 -1
- package/dist/test-utils/polyfills/ResizeObserver.js.map +1 -1
- package/dist/test-utils/polyfills/TextDecoder.js.map +1 -1
- package/dist/test-utils/polyfills/TextEncoder.js.map +1 -1
- package/dist/test-utils/polyfills/index.js.map +1 -1
- package/dist/test-utils/polyfills/matchMedia.js.map +1 -1
- package/dist/test-utils/polyfills/offsetParent.js.map +1 -1
- package/dist/test-utils/polyfills/scrollIntoView.js.map +1 -1
- package/dist/test-utils/render.d.ts +2 -2
- package/dist/test-utils/render.js +1 -1
- package/dist/test-utils/render.js.map +1 -1
- package/dist/test-utils/timers.d.ts +2 -3
- package/dist/test-utils/timers.js +2 -3
- package/dist/test-utils/timers.js.map +1 -1
- package/dist/theme/LocalStorageColorSchemeProvider.d.ts +2 -2
- package/dist/theme/LocalStorageColorSchemeProvider.js +1 -1
- package/dist/theme/LocalStorageColorSchemeProvider.js.map +1 -1
- package/dist/theme/ThemeProvider.d.ts +17 -20
- package/dist/theme/ThemeProvider.js +7 -8
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/colors.js.map +1 -1
- package/dist/theme/cssVars.js.map +1 -1
- package/dist/theme/types.d.ts +3 -3
- package/dist/theme/types.js +1 -1
- package/dist/theme/types.js.map +1 -1
- package/dist/theme/useCSSVariables.d.ts +7 -9
- package/dist/theme/useCSSVariables.js +1 -1
- package/dist/theme/useCSSVariables.js.map +1 -1
- package/dist/theme/useColorScheme.d.ts +6 -7
- package/dist/theme/useColorScheme.js +2 -3
- package/dist/theme/useColorScheme.js.map +1 -1
- package/dist/theme/useColorSchemeMetaTag.d.ts +2 -2
- package/dist/theme/useColorSchemeMetaTag.js +1 -1
- package/dist/theme/useColorSchemeMetaTag.js.map +1 -1
- package/dist/theme/useColorSchemeProvider.d.ts +2 -2
- package/dist/theme/useColorSchemeProvider.js.map +1 -1
- package/dist/theme/usePrefersColorScheme.d.ts +1 -1
- package/dist/theme/usePrefersColorScheme.js +1 -1
- package/dist/theme/usePrefersColorScheme.js.map +1 -1
- package/dist/theme/utils.d.ts +1 -1
- package/dist/theme/utils.js +1 -1
- package/dist/theme/utils.js.map +1 -1
- package/dist/tooltip/Tooltip.d.ts +3 -5
- package/dist/tooltip/Tooltip.js +1 -2
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/TooltipHoverModeProvider.d.ts +5 -6
- package/dist/tooltip/TooltipHoverModeProvider.js +3 -4
- package/dist/tooltip/TooltipHoverModeProvider.js.map +1 -1
- package/dist/tooltip/constants.d.ts +9 -9
- package/dist/tooltip/constants.js +9 -9
- package/dist/tooltip/constants.js.map +1 -1
- package/dist/tooltip/tooltipStyles.d.ts +2 -2
- package/dist/tooltip/tooltipStyles.js +1 -1
- package/dist/tooltip/tooltipStyles.js.map +1 -1
- package/dist/tooltip/useTooltip.d.ts +18 -26
- package/dist/tooltip/useTooltip.js +4 -7
- package/dist/tooltip/useTooltip.js.map +1 -1
- package/dist/tooltip/useTooltipPosition.d.ts +4 -4
- package/dist/tooltip/useTooltipPosition.js +1 -1
- package/dist/tooltip/useTooltipPosition.js.map +1 -1
- package/dist/tooltip/utils.js.map +1 -1
- package/dist/transition/CSSTransition.d.ts +3 -4
- package/dist/transition/CSSTransition.js +2 -3
- package/dist/transition/CSSTransition.js.map +1 -1
- package/dist/transition/Collapse.d.ts +5 -8
- package/dist/transition/Collapse.js +3 -5
- package/dist/transition/Collapse.js.map +1 -1
- package/dist/transition/CrossFade.d.ts +5 -8
- package/dist/transition/CrossFade.js +3 -5
- package/dist/transition/CrossFade.js.map +1 -1
- package/dist/transition/ScaleTransition.d.ts +7 -10
- package/dist/transition/ScaleTransition.js +4 -6
- package/dist/transition/ScaleTransition.js.map +1 -1
- package/dist/transition/SkeletonPlaceholder.d.ts +4 -6
- package/dist/transition/SkeletonPlaceholder.js +3 -5
- package/dist/transition/SkeletonPlaceholder.js.map +1 -1
- package/dist/transition/Slide.d.ts +2 -2
- package/dist/transition/Slide.js +1 -1
- package/dist/transition/Slide.js.map +1 -1
- package/dist/transition/SlideContainer.d.ts +9 -13
- package/dist/transition/SlideContainer.js +4 -6
- package/dist/transition/SlideContainer.js.map +1 -1
- package/dist/transition/collapseStyles.d.ts +2 -2
- package/dist/transition/collapseStyles.js +1 -1
- package/dist/transition/collapseStyles.js.map +1 -1
- package/dist/transition/config.d.ts +2 -2
- package/dist/transition/config.js +2 -2
- package/dist/transition/config.js.map +1 -1
- package/dist/transition/maxWidthTransition.js.map +1 -1
- package/dist/transition/skeletonPlaceholderUtils.d.ts +3 -3
- package/dist/transition/skeletonPlaceholderUtils.js +2 -2
- package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
- package/dist/transition/types.d.ts +34 -37
- package/dist/transition/types.js +1 -1
- package/dist/transition/types.js.map +1 -1
- package/dist/transition/useCSSTransition.d.ts +4 -7
- package/dist/transition/useCSSTransition.js +4 -7
- package/dist/transition/useCSSTransition.js.map +1 -1
- package/dist/transition/useCarousel.d.ts +6 -7
- package/dist/transition/useCarousel.js +2 -3
- package/dist/transition/useCarousel.js.map +1 -1
- package/dist/transition/useCollapseTransition.d.ts +10 -13
- package/dist/transition/useCollapseTransition.js +4 -6
- package/dist/transition/useCollapseTransition.js.map +1 -1
- package/dist/transition/useCrossFadeTransition.d.ts +5 -6
- package/dist/transition/useCrossFadeTransition.js +4 -5
- package/dist/transition/useCrossFadeTransition.js.map +1 -1
- package/dist/transition/useMaxWidthTransition.d.ts +2 -2
- package/dist/transition/useMaxWidthTransition.js +1 -1
- package/dist/transition/useMaxWidthTransition.js.map +1 -1
- package/dist/transition/useScaleTransition.d.ts +8 -11
- package/dist/transition/useScaleTransition.js +7 -10
- package/dist/transition/useScaleTransition.js.map +1 -1
- package/dist/transition/useSkeletonPlaceholder.d.ts +6 -10
- package/dist/transition/useSkeletonPlaceholder.js.map +1 -1
- package/dist/transition/useSlideTransition.d.ts +5 -6
- package/dist/transition/useSlideTransition.js +4 -5
- package/dist/transition/useSlideTransition.js.map +1 -1
- package/dist/transition/useTransition.d.ts +1 -1
- package/dist/transition/useTransition.js +1 -1
- package/dist/transition/useTransition.js.map +1 -1
- package/dist/transition/utils.d.ts +6 -6
- package/dist/transition/utils.js +3 -3
- package/dist/transition/utils.js.map +1 -1
- package/dist/tree/DefaultTreeItemRenderer.d.ts +1 -1
- package/dist/tree/DefaultTreeItemRenderer.js +1 -1
- package/dist/tree/DefaultTreeItemRenderer.js.map +1 -1
- package/dist/tree/Tree.d.ts +7 -11
- package/dist/tree/Tree.js +4 -6
- package/dist/tree/Tree.js.map +1 -1
- package/dist/tree/TreeGroup.d.ts +3 -3
- package/dist/tree/TreeGroup.js +1 -1
- package/dist/tree/TreeGroup.js.map +1 -1
- package/dist/tree/TreeItem.d.ts +3 -4
- package/dist/tree/TreeItem.js +2 -3
- package/dist/tree/TreeItem.js.map +1 -1
- package/dist/tree/TreeItemExpander.d.ts +2 -2
- package/dist/tree/TreeItemExpander.js +1 -1
- package/dist/tree/TreeItemExpander.js.map +1 -1
- package/dist/tree/TreeProvider.d.ts +6 -6
- package/dist/tree/TreeProvider.js +2 -2
- package/dist/tree/TreeProvider.js.map +1 -1
- package/dist/tree/styles.d.ts +10 -10
- package/dist/tree/styles.js +5 -5
- package/dist/tree/styles.js.map +1 -1
- package/dist/tree/types.d.ts +6 -7
- package/dist/tree/types.js.map +1 -1
- package/dist/tree/useTree.d.ts +4 -5
- package/dist/tree/useTree.js +2 -3
- package/dist/tree/useTree.js.map +1 -1
- package/dist/tree/useTreeExpansion.d.ts +2 -2
- package/dist/tree/useTreeExpansion.js +1 -1
- package/dist/tree/useTreeExpansion.js.map +1 -1
- package/dist/tree/useTreeItems.d.ts +7 -7
- package/dist/tree/useTreeItems.js +2 -2
- package/dist/tree/useTreeItems.js.map +1 -1
- package/dist/tree/useTreeMovement.d.ts +3 -3
- package/dist/tree/useTreeMovement.js +3 -3
- package/dist/tree/useTreeMovement.js.map +1 -1
- package/dist/tree/useTreeSelection.d.ts +2 -2
- package/dist/tree/useTreeSelection.js +1 -1
- package/dist/tree/useTreeSelection.js.map +1 -1
- package/dist/tree/utils.d.ts +2 -2
- package/dist/tree/utils.js +2 -2
- package/dist/tree/utils.js.map +1 -1
- package/dist/types.d.ts +14 -16
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/typography/SrOnly.d.ts +1 -2
- package/dist/typography/SrOnly.js +1 -2
- package/dist/typography/SrOnly.js.map +1 -1
- package/dist/typography/TextContainer.d.ts +4 -44
- package/dist/typography/TextContainer.js +3 -33
- package/dist/typography/TextContainer.js.map +1 -1
- package/dist/typography/Typography.d.ts +4 -116
- package/dist/typography/Typography.js +2 -91
- package/dist/typography/Typography.js.map +1 -1
- package/dist/typography/WritingDirectionProvider.d.ts +10 -13
- package/dist/typography/WritingDirectionProvider.js +6 -9
- package/dist/typography/WritingDirectionProvider.js.map +1 -1
- package/dist/typography/textContainerStyles.d.ts +39 -0
- package/dist/typography/textContainerStyles.js +31 -0
- package/dist/typography/textContainerStyles.js.map +1 -0
- package/dist/typography/typographyStyles.d.ts +110 -0
- package/dist/typography/typographyStyles.js +89 -0
- package/dist/typography/typographyStyles.js.map +1 -0
- package/dist/useAsyncAction.d.ts +7 -9
- package/dist/useAsyncAction.js +3 -5
- package/dist/useAsyncAction.js.map +1 -1
- package/dist/useDebouncedFunction.d.ts +3 -4
- package/dist/useDebouncedFunction.js +2 -3
- package/dist/useDebouncedFunction.js.map +1 -1
- package/dist/useDropzone.d.ts +9 -14
- package/dist/useDropzone.js +4 -7
- package/dist/useDropzone.js.map +1 -1
- package/dist/useElementSize.d.ts +26 -5
- package/dist/useElementSize.js +7 -5
- package/dist/useElementSize.js.map +1 -1
- package/dist/useEnsuredId.d.ts +2 -3
- package/dist/useEnsuredId.js +2 -3
- package/dist/useEnsuredId.js.map +1 -1
- package/dist/useEnsuredRef.d.ts +3 -4
- package/dist/useEnsuredRef.js +2 -3
- package/dist/useEnsuredRef.js.map +1 -1
- package/dist/useEnsuredState.d.ts +2 -2
- package/dist/useEnsuredState.js +1 -1
- package/dist/useEnsuredState.js.map +1 -1
- package/dist/useHtmlClassName.d.ts +1 -1
- package/dist/useHtmlClassName.js +1 -1
- package/dist/useHtmlClassName.js.map +1 -1
- package/dist/useIntersectionObserver.d.ts +13 -20
- package/dist/useIntersectionObserver.js +2 -3
- package/dist/useIntersectionObserver.js.map +1 -1
- package/dist/useIsomorphicLayoutEffect.js.map +1 -1
- package/dist/useLocalStorage.d.ts +17 -22
- package/dist/useLocalStorage.js +9 -13
- package/dist/useLocalStorage.js.map +1 -1
- package/dist/useOrientation.js.map +1 -1
- package/dist/usePageInactive.d.ts +3 -3
- package/dist/usePageInactive.js +1 -1
- package/dist/usePageInactive.js.map +1 -1
- package/dist/useResizeListener.d.ts +3 -4
- package/dist/useResizeListener.js +2 -3
- package/dist/useResizeListener.js.map +1 -1
- package/dist/useResizeObserver.d.ts +8 -10
- package/dist/useResizeObserver.js +4 -5
- package/dist/useResizeObserver.js.map +1 -1
- package/dist/useThrottledFunction.d.ts +3 -4
- package/dist/useThrottledFunction.js +2 -3
- package/dist/useThrottledFunction.js.map +1 -1
- package/dist/useToggle.d.ts +2 -3
- package/dist/useToggle.js +1 -2
- package/dist/useToggle.js.map +1 -1
- package/dist/useUnmounted.d.ts +2 -3
- package/dist/useUnmounted.js +2 -3
- package/dist/useUnmounted.js.map +1 -1
- package/dist/useWindowSize.d.ts +3 -4
- package/dist/useWindowSize.js +2 -3
- package/dist/useWindowSize.js.map +1 -1
- package/dist/utils/RenderRecursively.d.ts +26 -7
- package/dist/utils/RenderRecursively.js +19 -3
- package/dist/utils/RenderRecursively.js.map +1 -1
- package/dist/utils/alphaNumericSort.d.ts +6 -11
- package/dist/utils/alphaNumericSort.js +1 -1
- package/dist/utils/alphaNumericSort.js.map +1 -1
- package/dist/utils/applyRef.d.ts +1 -2
- package/dist/utils/applyRef.js +1 -2
- package/dist/utils/applyRef.js.map +1 -1
- package/dist/utils/bem.d.ts +2 -3
- package/dist/utils/bem.js +2 -3
- package/dist/utils/bem.js.map +1 -1
- package/dist/utils/getClientPosition.d.ts +4 -4
- package/dist/utils/getClientPosition.js +2 -2
- package/dist/utils/getClientPosition.js.map +1 -1
- package/dist/utils/getMiddleOfRange.d.ts +2 -2
- package/dist/utils/getMiddleOfRange.js +1 -1
- package/dist/utils/getMiddleOfRange.js.map +1 -1
- package/dist/utils/getPercentage.d.ts +3 -4
- package/dist/utils/getPercentage.js +3 -4
- package/dist/utils/getPercentage.js.map +1 -1
- package/dist/utils/getRangeDefaultValue.d.ts +2 -2
- package/dist/utils/getRangeDefaultValue.js +1 -1
- package/dist/utils/getRangeDefaultValue.js.map +1 -1
- package/dist/utils/getRangeSteps.d.ts +3 -4
- package/dist/utils/getRangeSteps.js +3 -4
- package/dist/utils/getRangeSteps.js.map +1 -1
- package/dist/utils/identity.d.ts +1 -1
- package/dist/utils/identity.js +1 -1
- package/dist/utils/identity.js.map +1 -1
- package/dist/utils/isElementVisible.d.ts +3 -4
- package/dist/utils/isElementVisible.js +3 -4
- package/dist/utils/isElementVisible.js.map +1 -1
- package/dist/utils/loop.d.ts +2 -2
- package/dist/utils/loop.js +2 -2
- package/dist/utils/loop.js.map +1 -1
- package/dist/utils/nearest.d.ts +3 -4
- package/dist/utils/nearest.js +3 -4
- package/dist/utils/nearest.js.map +1 -1
- package/dist/utils/parseCssLengthUnit.d.ts +2 -4
- package/dist/utils/parseCssLengthUnit.js +2 -4
- package/dist/utils/parseCssLengthUnit.js.map +1 -1
- package/dist/utils/randomInt.d.ts +2 -2
- package/dist/utils/randomInt.js +2 -2
- package/dist/utils/randomInt.js.map +1 -1
- package/dist/utils/wait.d.ts +2 -3
- package/dist/utils/wait.js +2 -3
- package/dist/utils/wait.js.map +1 -1
- package/dist/utils/withinRange.d.ts +3 -4
- package/dist/utils/withinRange.js +3 -4
- package/dist/utils/withinRange.js.map +1 -1
- package/dist/window-splitter/WindowSplitter.d.ts +5 -5
- package/dist/window-splitter/WindowSplitter.js +2 -2
- package/dist/window-splitter/WindowSplitter.js.map +1 -1
- package/dist/window-splitter/useWindowSplitter.d.ts +6 -7
- package/dist/window-splitter/useWindowSplitter.js +2 -3
- package/dist/window-splitter/useWindowSplitter.js.map +1 -1
- package/package.json +24 -357
- package/src/CoreProviders.tsx +3 -3
- package/src/NoSsr.tsx +3 -4
- package/src/RootHtml.tsx +3 -4
- package/src/SsrProvider.tsx +3 -3
- package/src/_core.scss +5 -0
- package/src/app-bar/AppBar.tsx +11 -14
- package/src/app-bar/AppBarTitle.tsx +9 -14
- package/src/avatar/Avatar.tsx +5 -6
- package/src/avatar/__tests__/Avatar.tsx +1 -1
- package/src/avatar/styles.ts +4 -4
- package/src/badge/Badge.tsx +4 -6
- package/src/box/Box.tsx +16 -9
- package/src/box/__tests__/Box.tsx +158 -0
- package/src/box/__tests__/__snapshots__/Box.tsx.snap +544 -0
- package/src/box/_box.scss +1 -1
- package/src/box/styles.ts +9 -9
- package/src/button/AsyncButton.tsx +5 -7
- package/src/button/Button.tsx +4 -8
- package/src/button/ButtonUnstyled.tsx +2 -2
- package/src/button/FloatingActionButton.tsx +5 -5
- package/src/button/TooltippedButton.tsx +9 -13
- package/src/button/buttonStyles.ts +3 -3
- package/src/button/buttonUnstyledStyles.ts +2 -2
- package/src/card/Card.tsx +3 -4
- package/src/card/CardContent.tsx +2 -4
- package/src/card/CardFooter.tsx +2 -2
- package/src/card/CardHeader.tsx +10 -12
- package/src/card/CardSubtitle.tsx +2 -2
- package/src/card/CardTitle.tsx +2 -2
- package/src/card/ClickableCard.tsx +3 -4
- package/src/card/styles.ts +15 -15
- package/src/chip/Chip.tsx +10 -14
- package/src/chip/styles.ts +4 -4
- package/src/cssUtils.ts +10 -10
- package/src/dialog/Dialog.tsx +5 -6
- package/src/dialog/DialogContainer.tsx +2 -2
- package/src/dialog/DialogTitle.tsx +2 -2
- package/src/dialog/FixedDialog.tsx +1 -2
- package/src/dialog/styles.ts +9 -9
- package/src/divider/Divider.tsx +2 -3
- package/src/divider/styles.ts +2 -2
- package/src/draggable/useDraggable.ts +18 -19
- package/src/draggable/utils.ts +2 -2
- package/src/expansion-panel/ExpansionList.tsx +2 -2
- package/src/expansion-panel/ExpansionPanel.tsx +8 -9
- package/src/expansion-panel/ExpansionPanelHeader.tsx +6 -10
- package/src/expansion-panel/useExpansionList.ts +6 -7
- package/src/expansion-panel/useExpansionPanels.ts +9 -14
- package/src/focus/useFocusContainer.ts +9 -10
- package/src/focus/utils.ts +4 -5
- package/src/form/Checkbox.tsx +1 -2
- package/src/form/Fieldset.tsx +5 -6
- package/src/form/FileInput.tsx +6 -7
- package/src/form/FormMessageContainer.tsx +2 -2
- package/src/form/FormMessageCounter.tsx +4 -6
- package/src/form/InputToggle.tsx +11 -12
- package/src/form/InputToggleIcon.tsx +4 -6
- package/src/form/Label.tsx +2 -2
- package/src/form/Legend.tsx +2 -2
- package/src/form/MenuItemCheckbox.tsx +2 -3
- package/src/form/MenuItemFileInput.tsx +3 -5
- package/src/form/MenuItemInputToggle.tsx +7 -9
- package/src/form/MenuItemRadio.tsx +3 -5
- package/src/form/MenuItemSwitch.tsx +2 -3
- package/src/form/MenuItemTextField.tsx +2 -2
- package/src/form/NativeSelect.tsx +3 -5
- package/src/form/OptGroup.tsx +3 -4
- package/src/form/Option.tsx +5 -7
- package/src/form/Password.tsx +7 -13
- package/src/form/Radio.tsx +1 -2
- package/src/form/ResizingTextAreaWrapper.tsx +2 -2
- package/src/form/Select.tsx +6 -9
- package/src/form/SelectedOption.tsx +2 -2
- package/src/form/Slider.tsx +16 -25
- package/src/form/SliderContainer.tsx +6 -9
- package/src/form/SliderMark.tsx +2 -2
- package/src/form/SliderMarkLabel.tsx +4 -4
- package/src/form/SliderThumb.tsx +8 -10
- package/src/form/SliderTrack.tsx +4 -6
- package/src/form/SliderValueMarks.tsx +7 -9
- package/src/form/SliderValueTooltip.tsx +4 -6
- package/src/form/Switch.tsx +3 -4
- package/src/form/TextArea.tsx +2 -3
- package/src/form/TextField.tsx +7 -10
- package/src/form/TextFieldAddon.tsx +3 -3
- package/src/form/fileUtils.ts +33 -36
- package/src/form/formConfig.ts +2 -2
- package/src/form/formMessageStyles.ts +5 -5
- package/src/form/inputToggleStyles.ts +3 -3
- package/src/form/menuItemInputToggleStyles.ts +8 -8
- package/src/form/nativeSelectStyles.ts +4 -4
- package/src/form/optionStyles.ts +2 -2
- package/src/form/passwordStyles.ts +4 -4
- package/src/form/selectStyles.ts +2 -2
- package/src/form/selectUtils.ts +4 -4
- package/src/form/sliderUtils.ts +9 -9
- package/src/form/switchStyles.ts +2 -2
- package/src/form/textAreaStyles.ts +4 -4
- package/src/form/textFieldContainerStyles.ts +2 -2
- package/src/form/textFieldStyles.ts +2 -2
- package/src/form/types.ts +10 -10
- package/src/form/useCheckboxGroup.ts +15 -20
- package/src/form/useCombobox.ts +18 -16
- package/src/form/useEditableCombobox.ts +3 -3
- package/src/form/useFileUpload.ts +7 -8
- package/src/form/useFormReset.ts +2 -2
- package/src/form/useListboxProvider.ts +3 -3
- package/src/form/useNumberField.ts +17 -25
- package/src/form/useRadioGroup.ts +14 -18
- package/src/form/useRangeSlider.ts +8 -11
- package/src/form/useSelectCombobox.ts +3 -3
- package/src/form/useSlider.ts +7 -9
- package/src/form/useTextField.ts +22 -31
- package/src/form/utils.ts +7 -8
- package/src/form/validation.ts +18 -18
- package/src/hoverMode/useHoverMode.ts +9 -10
- package/src/hoverMode/useHoverModeProvider.ts +11 -15
- package/src/icon/FontIcon.tsx +1 -1
- package/src/icon/IconRotator.tsx +1 -1
- package/src/icon/MaterialIcon.tsx +2 -2
- package/src/icon/MaterialSymbol.tsx +3 -4
- package/src/icon/SVGIcon.tsx +0 -1
- package/src/icon/TextIconSpacing.tsx +3 -5
- package/src/icon/iconConfig.tsx +14 -16
- package/src/icon/material.ts +4 -4
- package/src/icon/materialConfig.ts +12 -12
- package/src/icon/styles.ts +8 -8
- package/src/interaction/UserInteractionModeProvider.tsx +1 -2
- package/src/interaction/config.ts +2 -2
- package/src/interaction/types.ts +8 -8
- package/src/interaction/useElementInteraction.tsx +6 -7
- package/src/interaction/useHigherContrastChildren.tsx +2 -3
- package/src/layout/LayoutAppBar.tsx +4 -7
- package/src/layout/LayoutNav.tsx +4 -6
- package/src/layout/LayoutWindowSplitter.tsx +3 -4
- package/src/layout/Main.tsx +4 -5
- package/src/layout/__tests__/LayoutAppBar.tsx +23 -0
- package/src/layout/__tests__/useExpandableLayout.tsx +8 -0
- package/src/layout/_layout.scss +12 -1
- package/src/layout/layoutNavStyles.ts +2 -2
- package/src/layout/layoutWindowSplitterStyles.ts +2 -2
- package/src/layout/mainStyles.ts +2 -2
- package/src/layout/useExpandableLayout.ts +85 -23
- package/src/layout/useHorizontalLayoutTransition.ts +8 -8
- package/src/layout/useLayoutAppBarHeight.ts +10 -13
- package/src/layout/useLayoutTree.ts +10 -10
- package/src/layout/useLayoutWindowSplitter.ts +5 -6
- package/src/layout/useMainTabIndex.ts +1 -1
- package/src/layout/useResizableLayout.ts +54 -8
- package/src/layout/useTemporaryLayout.ts +12 -13
- package/src/link/Link.tsx +10 -13
- package/src/link/SkipToMainContent.tsx +2 -4
- package/src/link/styles.ts +4 -4
- package/src/list/List.tsx +3 -4
- package/src/list/ListItem.tsx +4 -6
- package/src/list/ListItemChildren.tsx +1 -2
- package/src/list/ListSubheader.tsx +3 -3
- package/src/list/getListItemHeight.ts +1 -1
- package/src/list/listItemStyles.ts +9 -9
- package/src/list/types.ts +11 -11
- package/src/media-queries/AppSizeProvider.tsx +1 -2
- package/src/media-queries/useMediaQuery.ts +2 -3
- package/src/menu/DropdownMenu.tsx +7 -11
- package/src/menu/Menu.tsx +10 -13
- package/src/menu/MenuBar.tsx +3 -4
- package/src/menu/MenuButton.tsx +8 -8
- package/src/menu/MenuConfigurationProvider.tsx +10 -10
- package/src/menu/MenuItem.tsx +2 -2
- package/src/menu/MenuItemButton.tsx +2 -2
- package/src/menu/MenuItemCircularProgress.tsx +3 -4
- package/src/menu/MenuItemGroup.tsx +3 -4
- package/src/menu/MenuItemSeparator.tsx +2 -2
- package/src/menu/MenuSheet.tsx +7 -9
- package/src/menu/MenuVisibilityProvider.tsx +8 -10
- package/src/menu/MenuWidget.tsx +2 -2
- package/src/menu/MenuWidgetKeyboardProvider.tsx +2 -2
- package/src/menu/useContextMenu.ts +8 -12
- package/src/menu/useMenuBarProvider.ts +6 -6
- package/src/menu/utils.ts +2 -2
- package/src/movement/constants.ts +3 -3
- package/src/movement/types.ts +16 -17
- package/src/movement/useKeyboardMovementProvider.ts +6 -9
- package/src/movement/utils.ts +13 -13
- package/src/navigation/CollapsibleNavGroup.tsx +94 -0
- package/src/navigation/DefaultNavigationRenderer.tsx +71 -0
- package/src/navigation/NavGroup.tsx +39 -0
- package/src/navigation/NavItem.tsx +29 -0
- package/src/navigation/NavItemButton.tsx +104 -0
- package/src/navigation/NavItemLink.tsx +163 -0
- package/src/navigation/NavSubheader.tsx +36 -0
- package/src/navigation/Navigation.tsx +91 -0
- package/src/navigation/__tests__/Navigation.tsx +97 -0
- package/src/navigation/__tests__/__snapshots__/Navigation.tsx.snap +165 -0
- package/src/navigation/_navigation.scss +99 -0
- package/src/navigation/getHrefFromParents.ts +15 -0
- package/src/navigation/navGroupStyles.ts +21 -0
- package/src/navigation/navItemStyles.ts +71 -0
- package/src/navigation/types.ts +166 -0
- package/src/navigation/useActiveHeadingId.ts +190 -0
- package/src/overlay/Overlay.tsx +5 -6
- package/src/overlay/overlayStyles.ts +4 -4
- package/src/portal/Portal.tsx +1 -2
- package/src/portal/PortalContainerProvider.tsx +4 -4
- package/src/positioning/createVerticalPosition.ts +1 -1
- package/src/positioning/getFixedPosition.ts +1 -1
- package/src/positioning/types.ts +4 -4
- package/src/positioning/useFixedPositioning.ts +8 -9
- package/src/positioning/utils.ts +3 -3
- package/src/progress/CircularProgress.tsx +7 -10
- package/src/progress/LinearProgress.tsx +4 -6
- package/src/progress/types.ts +5 -5
- package/src/responsive-item/ResponsiveItemContainer.tsx +10 -15
- package/src/responsive-item/ResponsiveItemOverlay.tsx +6 -7
- package/src/responsive-item/styles.ts +2 -2
- package/src/scroll/ScrollLock.tsx +1 -1
- package/src/scroll/useScrollLock.ts +2 -3
- package/src/searching/caseInsensitive.ts +9 -13
- package/src/searching/fuzzy.ts +4 -5
- package/src/searching/toSearchQuery.ts +1 -1
- package/src/searching/types.ts +2 -2
- package/src/searching/useFuzzyMatch.ts +3 -3
- package/src/searching/utils.ts +3 -3
- package/src/segmented-button/SegmentedButton.tsx +3 -4
- package/src/segmented-button/SegmentedButtonContainer.tsx +3 -4
- package/src/segmented-button/segmentedButtonContainerStyles.ts +2 -2
- package/src/segmented-button/segmentedButtonStyles.ts +2 -2
- package/src/sheet/Sheet.tsx +1 -1
- package/src/sheet/styles.ts +3 -3
- package/src/snackbar/DefaultToastRenderer.tsx +2 -2
- package/src/snackbar/Snackbar.tsx +3 -4
- package/src/snackbar/Toast.tsx +3 -3
- package/src/snackbar/ToastActionButton.tsx +2 -2
- package/src/snackbar/ToastCloseButton.tsx +2 -2
- package/src/snackbar/ToastContent.tsx +2 -2
- package/src/snackbar/ToastManager.tsx +30 -24
- package/src/snackbar/ToastManagerProvider.tsx +6 -6
- package/src/snackbar/__tests__/ToastManagerProvider.tsx +34 -0
- package/src/snackbar/__tests__/__snapshots__/ToastManagerProvider.tsx.snap +21 -21
- package/src/snackbar/snackbarStyles.ts +4 -5
- package/src/snackbar/toastContentStyles.ts +2 -2
- package/src/snackbar/toastStyles.ts +2 -2
- package/src/snackbar/useCurrentToastActions.ts +3 -3
- package/src/suspense/CircularProgressSuspense.tsx +3 -4
- package/src/suspense/NullSuspense.tsx +3 -4
- package/src/table/Table.tsx +1 -2
- package/src/table/TableCell.tsx +7 -7
- package/src/table/TableCellContent.tsx +3 -3
- package/src/table/TableCheckbox.tsx +11 -15
- package/src/table/TableContainerProvider.tsx +3 -3
- package/src/table/TableFooter.tsx +2 -2
- package/src/table/TableHeader.tsx +2 -2
- package/src/table/TableRadio.tsx +7 -9
- package/src/table/tableCellStyles.ts +2 -2
- package/src/table/tableContainerStyles.ts +2 -2
- package/src/table/tableFooterStyles.ts +1 -1
- package/src/table/tableHeaderStyles.ts +2 -2
- package/src/table/tableRowStyles.ts +2 -2
- package/src/table/tableStyles.ts +2 -2
- package/src/table/types.ts +7 -9
- package/src/tabs/Tab.tsx +4 -4
- package/src/tabs/TabList.tsx +2 -2
- package/src/tabs/TabListScrollButton.tsx +3 -3
- package/src/tabs/tabIndicatorStyles.ts +2 -2
- package/src/tabs/tabListScrollButtonStyles.ts +4 -4
- package/src/tabs/tabListStyles.ts +2 -2
- package/src/tabs/tabStyles.ts +2 -2
- package/src/tabs/useTabs.ts +16 -21
- package/src/tabs/utils.ts +3 -3
- package/src/test-utils/ResizeObserver.ts +9 -11
- package/src/test-utils/matchMedia.ts +13 -17
- package/src/test-utils/render.tsx +2 -2
- package/src/test-utils/timers.ts +2 -3
- package/src/theme/LocalStorageColorSchemeProvider.tsx +2 -2
- package/src/theme/ThemeProvider.tsx +18 -21
- package/src/theme/types.ts +3 -3
- package/src/theme/useCSSVariables.ts +8 -10
- package/src/theme/useColorScheme.ts +6 -7
- package/src/theme/useColorSchemeMetaTag.ts +2 -2
- package/src/theme/useColorSchemeProvider.ts +2 -2
- package/src/theme/usePrefersColorScheme.ts +1 -1
- package/src/theme/utils.ts +1 -1
- package/src/tooltip/Tooltip.tsx +3 -5
- package/src/tooltip/TooltipHoverModeProvider.tsx +5 -6
- package/src/tooltip/constants.ts +9 -9
- package/src/tooltip/tooltipStyles.ts +2 -2
- package/src/tooltip/useTooltip.ts +18 -26
- package/src/tooltip/useTooltipPosition.ts +4 -4
- package/src/transition/CSSTransition.tsx +3 -4
- package/src/transition/Collapse.tsx +5 -8
- package/src/transition/CrossFade.tsx +5 -8
- package/src/transition/ScaleTransition.tsx +7 -10
- package/src/transition/SkeletonPlaceholder.tsx +4 -6
- package/src/transition/Slide.tsx +2 -2
- package/src/transition/SlideContainer.tsx +9 -13
- package/src/transition/collapseStyles.ts +2 -2
- package/src/transition/config.ts +2 -2
- package/src/transition/skeletonPlaceholderUtils.ts +3 -3
- package/src/transition/types.ts +34 -37
- package/src/transition/useCSSTransition.ts +4 -7
- package/src/transition/useCarousel.ts +6 -7
- package/src/transition/useCollapseTransition.ts +10 -13
- package/src/transition/useCrossFadeTransition.ts +5 -6
- package/src/transition/useMaxWidthTransition.ts +2 -2
- package/src/transition/useScaleTransition.ts +8 -11
- package/src/transition/useSkeletonPlaceholder.ts +6 -10
- package/src/transition/useSlideTransition.ts +5 -6
- package/src/transition/useTransition.ts +1 -1
- package/src/transition/utils.ts +6 -6
- package/src/tree/DefaultTreeItemRenderer.tsx +1 -1
- package/src/tree/Tree.tsx +8 -12
- package/src/tree/TreeGroup.tsx +3 -3
- package/src/tree/TreeItem.tsx +3 -4
- package/src/tree/TreeItemExpander.tsx +2 -2
- package/src/tree/TreeProvider.tsx +6 -6
- package/src/tree/styles.ts +10 -10
- package/src/tree/types.ts +6 -7
- package/src/tree/useTree.ts +4 -5
- package/src/tree/useTreeExpansion.ts +2 -2
- package/src/tree/useTreeItems.ts +7 -7
- package/src/tree/useTreeMovement.ts +5 -5
- package/src/tree/useTreeSelection.ts +2 -2
- package/src/tree/utils.ts +2 -2
- package/src/types.ts +14 -16
- package/src/typography/SrOnly.tsx +1 -2
- package/src/typography/TextContainer.tsx +7 -57
- package/src/typography/Typography.tsx +8 -149
- package/src/typography/WritingDirectionProvider.tsx +10 -13
- package/src/typography/__tests__/TextContainer.tsx +2 -1
- package/src/typography/__tests__/Typography.tsx +2 -1
- package/src/typography/textContainerStyles.ts +52 -0
- package/src/typography/typographyStyles.ts +143 -0
- package/src/useAsyncAction.ts +7 -9
- package/src/useDebouncedFunction.ts +3 -4
- package/src/useDropzone.ts +9 -14
- package/src/useElementSize.ts +31 -6
- package/src/useEnsuredId.ts +2 -3
- package/src/useEnsuredRef.ts +3 -4
- package/src/useEnsuredState.ts +2 -2
- package/src/useHtmlClassName.ts +1 -1
- package/src/useIntersectionObserver.ts +13 -20
- package/src/useLocalStorage.ts +17 -22
- package/src/usePageInactive.ts +3 -3
- package/src/useResizeListener.ts +3 -4
- package/src/useResizeObserver.ts +8 -10
- package/src/useThrottledFunction.ts +3 -4
- package/src/useToggle.ts +2 -3
- package/src/useUnmounted.ts +2 -3
- package/src/useWindowSize.ts +3 -4
- package/src/utils/RenderRecursively.tsx +42 -9
- package/src/utils/__tests__/RenderRecursively.tsx +1 -1
- package/src/utils/alphaNumericSort.ts +6 -11
- package/src/utils/applyRef.ts +1 -2
- package/src/utils/bem.ts +2 -3
- package/src/utils/getClientPosition.ts +4 -4
- package/src/utils/getMiddleOfRange.ts +2 -2
- package/src/utils/getPercentage.ts +3 -4
- package/src/utils/getRangeDefaultValue.ts +2 -2
- package/src/utils/getRangeSteps.ts +3 -4
- package/src/utils/identity.ts +1 -1
- package/src/utils/isElementVisible.ts +3 -4
- package/src/utils/loop.ts +2 -2
- package/src/utils/nearest.ts +3 -4
- package/src/utils/parseCssLengthUnit.ts +2 -4
- package/src/utils/randomInt.ts +2 -2
- package/src/utils/wait.ts +2 -3
- package/src/utils/withinRange.ts +3 -4
- package/src/window-splitter/WindowSplitter.tsx +5 -5
- package/src/window-splitter/useWindowSplitter.ts +6 -7
- package/tsconfig.types.json +1 -1
- package/tsdoc.json +14 -0
- package/.turbo/turbo-typecheck.log +0 -4
- package/dist/index.d.ts +0 -344
- package/dist/index.js +0 -345
- package/dist/index.js.map +0 -1
- package/src/index.ts +0 -347
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useLocalStorage.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useSsr } from \"./SsrProvider.js\";\nimport type { UseStateInitializer, UseStateSetter } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\nimport { identity } from \"./utils/identity.js\";\n\n/** @remarks \\@since 6.0.0 */\nexport type LocalStorageSerializer<T> = (value: T) => string;\n/** @remarks \\@since 6.0.0 */\nexport type LocalStorageDeserializer<T> = (item: string) => T;\n\n/** @remarks \\@since 6.0.0 */\nexport interface LocalStorageHookOptions<T> {\n /**\n * The local storage key name to use.\n *\n * This can be set to an empty string for internal usage of conditionally\n * saving items to local storage.\n */\n key: string;\n\n /**\n * The default value to use if an item does not exist in local storage.\n */\n defaultValue: UseStateInitializer<T>;\n\n /**\n * Set this to `true` if the `value` should not persist to local storage\n * immediately whenever it changes. You will manually need to call\n * {@link LocalStorageHookReturnValue.persist} instead.\n *\n * @see {@link LocalStorageHookReturnValue.persist} for an example.\n * @defaultValue `false`\n */\n manual?: boolean;\n\n /**\n * Set this to `true` to update:\n *\n * - the default {@link serializer} to be:\n * ```\n * typeof value === \"string\" ? value : `${value}`\n * ```\n * - the default {@link deserializer} to not call `JSON.parse` if the\n * {@link defaultValue} is a string.\n *\n * @defaultValue `typeof defaultValue === 'string'`\n */\n raw?: boolean;\n\n /**\n * An optional function to serialize the `value` before storing it in local\n * storage.\n *\n * @defaultValue `JSON.stringify`\n */\n serializer?: LocalStorageSerializer<T>;\n\n /**\n * An optional function to deserialize the `value` if the item existed in\n * local storage.\n *\n * @defaultValue `JSON.parse`\n */\n deserializer?: LocalStorageDeserializer<T>;\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport const defaultLocalStorageSerializer = <T>(value: T): string =>\n typeof value === \"string\" ? value : `${value}`;\n\n/** @remarks \\@since 6.0.0 */\nexport interface GetItemFromStorageOptions<T> {\n /**\n * The storage key to use\n */\n key: string;\n\n /**\n * A value to use when the {@link key} does not exist in storage or there is\n * an error deserializing the value.\n */\n fallback: T;\n\n /** @see {@link LocalStorageHookOptions.deserializer} */\n deserializer?: LocalStorageDeserializer<T>;\n\n /** @defaultValue `localStorage` */\n storage?: Storage;\n}\n\n/**\n * You'll most likely want to use {@link useLocalStorage} instead, but this is a\n * low-level util to \"safely\" get an item from local storage.\n *\n * @example\n * ```ts\n * import { getItemFromStorage } from \"@react-md/core\";\n *\n * const values = [\"a\", \"b\", \"c\", \"d\"] as const;\n *\n * const item1 = getItemFromStorage({\n * key: \"testKey\",\n * fallback: values[0],\n * deserializer(item) {\n * if (!values.includes(item)) {\n * return values[0]\n * }\n *\n * return item;\n * },\n * });\n *\n * const item2 = getItemFromStorage({\n * key: \"anotherKey\",\n * fallback: -1,\n * });\n *\n * const item3 = getItemFromStorage({\n * key: \"anotherKey\",\n * fallback: -1,\n * storage: sessionStorage,\n * });\n * ```\n *\n * @remarks \\@since 6.0.0\n */\nexport const getItemFromStorage = <T>(\n options: GetItemFromStorageOptions<T>\n): T => {\n const {\n key,\n fallback,\n storage = localStorage,\n deserializer = JSON.parse,\n } = options;\n if (!key) {\n return fallback;\n }\n\n try {\n const value = storage.getItem(key);\n return !value ? fallback : deserializer(value);\n } catch (e) {\n return fallback;\n }\n};\n\n/** @remarks \\@since 6.0.0 */\nexport interface SetItemInStorageOptions<T> {\n key: string;\n value: T;\n /** @defaultValue `localStorage` */\n storage?: Storage;\n\n /** @see {@link LocalStorageHookOptions.serializer} */\n serializer?: LocalStorageSerializer<T>;\n}\n\n/**\n * You'll most likely want to use {@link useLocalStorage} instead, but this is a\n * low-level util to \"safely\" get an item from local storage.\n *\n * @example\n * ```ts\n * import { identity, getItemFromStorage } from \"@react-md/core\";\n *\n * const values = [\"a\", \"b\", \"c\", \"d\"] as const;\n *\n * setItemInStorage({\n * key: \"testKey\",\n * value: values[0],\n * // store string value as-is\n * serializer: identity,\n * });\n *\n * setItemInStorage({\n * key: \"anotherKey\",\n * value: 100,\n * });\n *\n * setItemInStorage({\n * key: \"anotherKey\",\n * value: 100,\n * storage: sessionStorage,\n * });\n * ```\n *\n * @remarks \\@since 6.0.0\n */\nexport const setItemInStorage = <T>(\n options: SetItemInStorageOptions<T>\n): void => {\n const {\n key,\n value,\n storage = localStorage,\n serializer = JSON.stringify,\n } = options;\n if (!key) {\n return;\n }\n\n try {\n storage.setItem(key, serializer(value));\n } catch {\n //\n }\n};\n\n/**\n * @remarks \\@since 6.0.0\n * @internal\n */\ninterface RemoveItemFromStorageOptions {\n key: string;\n\n /** @defaultValue `localStorage` */\n storage?: Storage;\n}\n\n/**\n * @remarks \\@since 6.0.0\n * @internal\n */\nexport const removeItemFromStorage = (\n options: RemoveItemFromStorageOptions\n): void => {\n const { key, storage = localStorage } = options;\n if (!key) {\n return;\n }\n\n try {\n storage.removeItem(key);\n } catch {\n // do nothing\n }\n};\n\n/** @remarks \\@since 6.0.0 */\nexport interface LocalStorageHookReturnValue<T> {\n value: T;\n\n /**\n * Updates the {@link value} in state. When the\n * {@link LocalStorageHookOptions.manual} option is `false`, the value will\n * also be updated in local storage immediately.\n */\n setValue: UseStateSetter<T>;\n\n /**\n * Remove the item from local storage.\n */\n remove(): void;\n\n /**\n * Manually persist the current {@link value} into local storage. This is only\n * useful if the {@link LocalStorageHookOptions.manual} option is `true`.\n *\n * @example\n * Manual Persisting\n * ```tsx\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, setValue, persist } = useLocalStorage({\n * key: \"someKey\",\n * manual: true,\n * defaultValue: \"\",\n * });\n *\n * return (\n * <>\n * <Button onClick={closeDialog}>\n * Cancel\n * </Button>\n * <Button\n * onClick={async () => {\n * await saveToDatabase(value);\n * persist();\n * closeDialog();\n * }}\n * >\n * Confirm\n * </Button>\n * </>\n * );\n * }\n * ```\n */\n persist(): void;\n}\n\n/**\n * @example\n * Simple Example\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { TextField, useLocalStorage } from \"@react-md/core\";\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useLocalStorage({\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\n * Type-safe Objects\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { useLocalStorage } from \"@react-md/core\";\n *\n * interface ExpectedSchema {\n * label: string;\n * value: string;\n * // others\n * }\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useLocalStorage<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\n * Manual Persistence\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { Button, Checkbox, Form, useLocalStorage } from \"@react-md/core\";\n *\n * function Example(): ReactElement {\n * const { value, setValue, remove, persist } = useLocalStorage({\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 * Note: Using the same local storage key in multiple parts in your app will not\n * update all instances with that value. The value will only be updated if it\n * was updated in a separate tab with the `\"storage\"` event. You must setup your\n * own context to share values or another state manager solution.\n *\n * @example\n * Shared Value\n * ```tsx\n * const context = createContext(null);\n * const { Provider } = context;\n *\n * export function useSomeValue(): string {\n * const value = useContext(context);\n * if (!value) {\n * throw new Error()\n * }\n *\n * return value;\n * }\n *\n * function Example({ children }: { children: ReactNode }) {\n * const { value, setValue, remove, persist } = useLocalStorage({\n * key: \"someKey\",\n * defaultValue: \"\",\n *\n * // optional\n * manual: true,\n * });\n *\n * return (\n * <Provider\n * value={useMemo(() => ({\n * value,\n * setValue,\n *\n * // remove and persist are optional\n * remove,\n * persist,\n * }), [value, setValue, remove, persist])}\n * >\n * {children}\n * </Provider>\n * );\n * }\n *\n * function SomeChildComponent() {\n * const { value, setValue } = useSomeValue();\n * // do stuff\n * }\n * ```\n *\n * @remarks \\@since 6.0.0\n */\nexport function useLocalStorage<T>(\n options: LocalStorageHookOptions<T>\n): LocalStorageHookReturnValue<T> {\n const { key, defaultValue, manual = false } = options;\n\n const [initialValue] = useState(defaultValue);\n // this allows for strings to automatically be stored as-is instead of adding\n // additional quotes around then with JSON.stringify\n const raw = options.raw ?? typeof initialValue === \"string\";\n const serializer =\n options.serializer ??\n (raw ? defaultLocalStorageSerializer : JSON.stringify);\n const deserializer =\n options.deserializer ??\n (raw && typeof initialValue === \"string\" ? identity : JSON.parse);\n\n const ssr = useSsr();\n const [value, setStoredValue] = useState<T>(() => {\n if (ssr) {\n return initialValue;\n }\n\n const value = getItemFromStorage({\n key,\n fallback: initialValue,\n deserializer,\n });\n if (!manual) {\n setItemInStorage({\n key,\n value,\n serializer,\n });\n }\n\n return value;\n });\n const config = useRef({\n key,\n value,\n manual,\n serializer,\n deserializer,\n defaultValue: initialValue,\n } as const);\n useIsomorphicLayoutEffect(() => {\n config.current = {\n key,\n value,\n manual,\n serializer,\n deserializer,\n defaultValue: initialValue,\n };\n });\n\n const setValue = useCallback<UseStateSetter<T>>((valueOrDispatcher) => {\n const { key, manual, serializer } = config.current;\n setStoredValue((prevValue) => {\n const nextValue =\n valueOrDispatcher instanceof Function\n ? valueOrDispatcher(prevValue)\n : valueOrDispatcher;\n\n if (!manual) {\n setItemInStorage({\n key,\n value: nextValue,\n serializer,\n });\n }\n\n return nextValue;\n });\n }, []);\n\n const remove = useCallback(() => {\n removeItemFromStorage({\n key: config.current.key,\n });\n }, []);\n\n const persist = useCallback(() => {\n const { key, value, serializer } = config.current;\n setItemInStorage({\n key,\n value,\n serializer,\n });\n }, []);\n\n useEffect(() => {\n const { defaultValue, deserializer, manual } = config.current;\n if (manual || !ssr) {\n return;\n }\n\n setValue(\n getItemFromStorage({\n key,\n fallback: defaultValue,\n deserializer,\n })\n );\n }, [key, ssr, setValue]);\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 { defaultValue, deserializer } = config.current;\n if (event.key === key) {\n setStoredValue(\n getItemFromStorage({\n key,\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","useRef","useState","useSsr","useIsomorphicLayoutEffect","identity","defaultLocalStorageSerializer","value","getItemFromStorage","options","key","fallback","storage","localStorage","deserializer","JSON","parse","getItem","e","setItemInStorage","serializer","stringify","setItem","removeItemFromStorage","removeItem","useLocalStorage","defaultValue","manual","initialValue","raw","ssr","setStoredValue","config","current","setValue","valueOrDispatcher","prevValue","nextValue","Function","remove","persist","callback","event","window","addEventListener","removeEventListener"],"mappings":"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"}
|
|
1
|
+
{"version":3,"sources":["../src/useLocalStorage.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useSsr } from \"./SsrProvider.js\";\nimport type { UseStateInitializer, UseStateSetter } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\nimport { identity } from \"./utils/identity.js\";\n\n/** @since 6.0.0 */\nexport type LocalStorageSerializer<T> = (value: T) => string;\n/** @since 6.0.0 */\nexport type LocalStorageDeserializer<T> = (item: string) => T;\n\n/** @since 6.0.0 */\nexport interface LocalStorageHookOptions<T> {\n /**\n * The local storage key name to use.\n *\n * This can be set to an empty string for internal usage of conditionally\n * saving items to local storage.\n */\n key: string;\n\n /**\n * The default value to use if an item does not exist in local storage.\n */\n defaultValue: UseStateInitializer<T>;\n\n /**\n * Set this to `true` if the `value` should not persist to local storage\n * immediately whenever it changes. You will manually need to call\n * {@link LocalStorageHookReturnValue.persist} instead.\n *\n * @see {@link LocalStorageHookReturnValue.persist} for an example.\n * @defaultValue `false`\n */\n manual?: boolean;\n\n /**\n * Set this to `true` to update:\n *\n * - the default {@link serializer} to be:\n * ```\n * typeof value === \"string\" ? value : `${value}`\n * ```\n * - the default {@link deserializer} to not call `JSON.parse` if the\n * {@link defaultValue} is a string.\n *\n * @defaultValue `typeof defaultValue === 'string'`\n */\n raw?: boolean;\n\n /**\n * An optional function to serialize the `value` before storing it in local\n * storage.\n *\n * @defaultValue `JSON.stringify`\n */\n serializer?: LocalStorageSerializer<T>;\n\n /**\n * An optional function to deserialize the `value` if the item existed in\n * local storage.\n *\n * @defaultValue `JSON.parse`\n */\n deserializer?: LocalStorageDeserializer<T>;\n}\n\n/**\n * @since 6.0.0\n */\nexport const defaultLocalStorageSerializer = <T>(value: T): string =>\n typeof value === \"string\" ? value : `${value}`;\n\n/** @since 6.0.0 */\nexport interface GetItemFromStorageOptions<T> {\n /**\n * The storage key to use\n */\n key: string;\n\n /**\n * A value to use when the {@link key} does not exist in storage or there is\n * an error deserializing the value.\n */\n fallback: T;\n\n /** @see {@link LocalStorageHookOptions.deserializer} */\n deserializer?: LocalStorageDeserializer<T>;\n\n /** @defaultValue `localStorage` */\n storage?: Storage;\n}\n\n/**\n * You'll most likely want to use {@link useLocalStorage} instead, but this is a\n * low-level util to \"safely\" get an item from local storage.\n *\n * @example\n * ```ts\n * import { getItemFromStorage } from \"@react-md/core\";\n *\n * const values = [\"a\", \"b\", \"c\", \"d\"] as const;\n *\n * const item1 = getItemFromStorage({\n * key: \"testKey\",\n * fallback: values[0],\n * deserializer(item) {\n * if (!values.includes(item)) {\n * return values[0]\n * }\n *\n * return item;\n * },\n * });\n *\n * const item2 = getItemFromStorage({\n * key: \"anotherKey\",\n * fallback: -1,\n * });\n *\n * const item3 = getItemFromStorage({\n * key: \"anotherKey\",\n * fallback: -1,\n * storage: sessionStorage,\n * });\n * ```\n *\n * @since 6.0.0\n */\nexport const getItemFromStorage = <T>(\n options: GetItemFromStorageOptions<T>\n): T => {\n const {\n key,\n fallback,\n storage = localStorage,\n deserializer = JSON.parse,\n } = options;\n if (!key) {\n return fallback;\n }\n\n try {\n const value = storage.getItem(key);\n return !value ? fallback : deserializer(value);\n } catch (e) {\n return fallback;\n }\n};\n\n/** @since 6.0.0 */\nexport interface SetItemInStorageOptions<T> {\n key: string;\n value: T;\n /** @defaultValue `localStorage` */\n storage?: Storage;\n\n /** @see {@link LocalStorageHookOptions.serializer} */\n serializer?: LocalStorageSerializer<T>;\n}\n\n/**\n * You'll most likely want to use {@link useLocalStorage} instead, but this is a\n * low-level util to \"safely\" get an item from local storage.\n *\n * @example\n * ```ts\n * import { identity, getItemFromStorage } from \"@react-md/core\";\n *\n * const values = [\"a\", \"b\", \"c\", \"d\"] as const;\n *\n * setItemInStorage({\n * key: \"testKey\",\n * value: values[0],\n * // store string value as-is\n * serializer: identity,\n * });\n *\n * setItemInStorage({\n * key: \"anotherKey\",\n * value: 100,\n * });\n *\n * setItemInStorage({\n * key: \"anotherKey\",\n * value: 100,\n * storage: sessionStorage,\n * });\n * ```\n *\n * @since 6.0.0\n */\nexport const setItemInStorage = <T>(\n options: SetItemInStorageOptions<T>\n): void => {\n const {\n key,\n value,\n storage = localStorage,\n serializer = JSON.stringify,\n } = options;\n if (!key) {\n return;\n }\n\n try {\n storage.setItem(key, serializer(value));\n } catch {\n //\n }\n};\n\n/**\n * @since 6.0.0\n * @internal\n */\ninterface RemoveItemFromStorageOptions {\n key: string;\n\n /** @defaultValue `localStorage` */\n storage?: Storage;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport const removeItemFromStorage = (\n options: RemoveItemFromStorageOptions\n): void => {\n const { key, storage = localStorage } = options;\n if (!key) {\n return;\n }\n\n try {\n storage.removeItem(key);\n } catch {\n // do nothing\n }\n};\n\n/** @since 6.0.0 */\nexport interface LocalStorageHookReturnValue<T> {\n value: T;\n\n /**\n * Updates the {@link value} in state. When the\n * {@link LocalStorageHookOptions.manual} option is `false`, the value will\n * also be updated in local storage immediately.\n */\n setValue: UseStateSetter<T>;\n\n /**\n * Remove the item from local storage.\n */\n remove(): void;\n\n /**\n * Manually persist the current {@link value} into local storage. This is only\n * useful if the {@link LocalStorageHookOptions.manual} option is `true`.\n *\n * @example Manual Persisting\n * ```tsx\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { value, setValue, persist } = useLocalStorage({\n * key: \"someKey\",\n * manual: true,\n * defaultValue: \"\",\n * });\n *\n * return (\n * <>\n * <Button onClick={closeDialog}>\n * Cancel\n * </Button>\n * <Button\n * onClick={async () => {\n * await saveToDatabase(value);\n * persist();\n * closeDialog();\n * }}\n * >\n * Confirm\n * </Button>\n * </>\n * );\n * }\n * ```\n */\n persist(): void;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import type { ReactElement } from \"react\";\n * import { TextField, useLocalStorage } from \"@react-md/core\";\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useLocalStorage({\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 type { ReactElement } from \"react\";\n * import { useLocalStorage } from \"@react-md/core\";\n *\n * interface ExpectedSchema {\n * label: string;\n * value: string;\n * // others\n * }\n *\n * function Example(): ReactElement {\n * const { value, setValue } = useLocalStorage<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 type { ReactElement } from \"react\";\n * import { Button, Checkbox, Form, useLocalStorage } from \"@react-md/core\";\n *\n * function Example(): ReactElement {\n * const { value, setValue, remove, persist } = useLocalStorage({\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 * Note: Using the same local storage key in multiple parts in your app will not\n * update all instances with that value. The value will only be updated if it\n * was updated in a separate tab with the `\"storage\"` event. You must setup your\n * own context to share values or another state manager solution.\n *\n * @example Shared Value\n * ```tsx\n * const context = createContext(null);\n * const { Provider } = context;\n *\n * export function useSomeValue(): string {\n * const value = useContext(context);\n * if (!value) {\n * throw new Error()\n * }\n *\n * return value;\n * }\n *\n * function Example({ children }: { children: ReactNode }) {\n * const { value, setValue, remove, persist } = useLocalStorage({\n * key: \"someKey\",\n * defaultValue: \"\",\n *\n * // optional\n * manual: true,\n * });\n *\n * return (\n * <Provider\n * value={useMemo(() => ({\n * value,\n * setValue,\n *\n * // remove and persist are optional\n * remove,\n * persist,\n * }), [value, setValue, remove, persist])}\n * >\n * {children}\n * </Provider>\n * );\n * }\n *\n * function SomeChildComponent() {\n * const { value, setValue } = useSomeValue();\n * // do stuff\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useLocalStorage<T>(\n options: LocalStorageHookOptions<T>\n): LocalStorageHookReturnValue<T> {\n const { key, defaultValue, manual = false } = options;\n\n const [initialValue] = useState(defaultValue);\n // this allows for strings to automatically be stored as-is instead of adding\n // additional quotes around then with JSON.stringify\n const raw = options.raw ?? typeof initialValue === \"string\";\n const serializer =\n options.serializer ??\n (raw ? defaultLocalStorageSerializer : JSON.stringify);\n const deserializer =\n options.deserializer ??\n (raw && typeof initialValue === \"string\" ? identity : JSON.parse);\n\n const ssr = useSsr();\n const [value, setStoredValue] = useState<T>(() => {\n if (ssr) {\n return initialValue;\n }\n\n const value = getItemFromStorage({\n key,\n fallback: initialValue,\n deserializer,\n });\n if (!manual) {\n setItemInStorage({\n key,\n value,\n serializer,\n });\n }\n\n return value;\n });\n const config = useRef({\n key,\n value,\n manual,\n serializer,\n deserializer,\n defaultValue: initialValue,\n } as const);\n useIsomorphicLayoutEffect(() => {\n config.current = {\n key,\n value,\n manual,\n serializer,\n deserializer,\n defaultValue: initialValue,\n };\n });\n\n const setValue = useCallback<UseStateSetter<T>>((valueOrDispatcher) => {\n const { key, manual, serializer } = config.current;\n setStoredValue((prevValue) => {\n const nextValue =\n valueOrDispatcher instanceof Function\n ? valueOrDispatcher(prevValue)\n : valueOrDispatcher;\n\n if (!manual) {\n setItemInStorage({\n key,\n value: nextValue,\n serializer,\n });\n }\n\n return nextValue;\n });\n }, []);\n\n const remove = useCallback(() => {\n removeItemFromStorage({\n key: config.current.key,\n });\n }, []);\n\n const persist = useCallback(() => {\n const { key, value, serializer } = config.current;\n setItemInStorage({\n key,\n value,\n serializer,\n });\n }, []);\n\n useEffect(() => {\n const { defaultValue, deserializer, manual } = config.current;\n if (manual || !ssr) {\n return;\n }\n\n setValue(\n getItemFromStorage({\n key,\n fallback: defaultValue,\n deserializer,\n })\n );\n }, [key, ssr, setValue]);\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 { defaultValue, deserializer } = config.current;\n if (event.key === key) {\n setStoredValue(\n getItemFromStorage({\n key,\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","useRef","useState","useSsr","useIsomorphicLayoutEffect","identity","defaultLocalStorageSerializer","value","getItemFromStorage","options","key","fallback","storage","localStorage","deserializer","JSON","parse","getItem","e","setItemInStorage","serializer","stringify","setItem","removeItemFromStorage","removeItem","useLocalStorage","defaultValue","manual","initialValue","raw","ssr","setStoredValue","config","current","setValue","valueOrDispatcher","prevValue","nextValue","Function","remove","persist","callback","event","window","addEventListener","removeEventListener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useOrientation.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useState } from \"react\";\n\n/**\n * An extremely simple \"polyfill\" for the `window.screen.orientation` just for\n * the `type` value that is required for the `useOrientation` hook.\n *\n * @see {@link https://caniuse.com/screen-orientation}\n * @returns the orientation type either from the `window.screen.orientation` or\n * by comparing the `availHeight` and `availWidth` on the `window.screen`\n * @internal\n */\nexport const getOrientationType = (): OrientationType => {\n if (typeof window === \"undefined\") {\n return \"landscape-primary\";\n }\n\n // Note: at the time of writing this, it looks like only Safari does not\n // support it from my list of browsers\n const screenOrientation = window.screen.orientation?.type;\n if (typeof screenOrientation === \"string\") {\n return screenOrientation;\n }\n\n const { availHeight, availWidth } = window.screen;\n\n return availHeight > availWidth ? \"portrait-primary\" : \"landscape-primary\";\n};\n\n/**\n * This hook uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation} API\n * to determine if the screen is landscape or portrait. For browsers that do not\n * support this API yet, it will polyfill that behavior using a resize handler\n * instead.\n *\n * @internal\n * @see {@link https://caniuse.com/screen-orientation}\n * @returns the current orientation type\n */\nexport function useOrientation(): OrientationType {\n const [orientation, setOrientation] = useState(getOrientationType);\n useEffect(() => {\n const handler = (): void => setOrientation(getOrientationType());\n\n const { orientation } = window.screen;\n if (orientation) {\n orientation.addEventListener(\"change\", handler);\n } else {\n window.addEventListener(\"resize\", handler);\n }\n\n return () => {\n if (orientation) {\n orientation.removeEventListener(\"change\", handler);\n } else {\n window.removeEventListener(\"resize\", handler);\n }\n };\n }, []);\n\n return orientation;\n}\n"],"names":["useEffect","useState","getOrientationType","window","screenOrientation","screen","orientation","type","availHeight","availWidth","useOrientation","setOrientation","handler","addEventListener","removeEventListener"],"mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C;;;;;;;;CAQC,GACD,OAAO,MAAMC,qBAAqB;IAChC,IAAI,OAAOC,WAAW,aAAa;QACjC,OAAO;IACT;IAEA,wEAAwE;IACxE,sCAAsC;IACtC,MAAMC,oBAAoBD,OAAOE,MAAM,CAACC,WAAW,EAAEC;IACrD,IAAI,OAAOH,sBAAsB,UAAU;QACzC,OAAOA;IACT;IAEA,MAAM,EAAEI,WAAW,EAAEC,UAAU,EAAE,GAAGN,OAAOE,MAAM;IAEjD,OAAOG,cAAcC,aAAa,qBAAqB;AACzD,EAAE;AAEF;;;;;;;;;CASC,GACD,OAAO,SAASC;IACd,MAAM,CAACJ,aAAaK,eAAe,GAAGV,SAASC;IAC/CF,UAAU;QACR,MAAMY,UAAU,IAAYD,eAAeT;QAE3C,MAAM,EAAEI,WAAW,EAAE,GAAGH,OAAOE,MAAM;QACrC,IAAIC,aAAa;YACfA,YAAYO,gBAAgB,CAAC,UAAUD;QACzC,OAAO;YACLT,OAAOU,gBAAgB,CAAC,UAAUD;QACpC;QAEA,OAAO;YACL,IAAIN,aAAa;gBACfA,YAAYQ,mBAAmB,CAAC,UAAUF;YAC5C,OAAO;gBACLT,OAAOW,mBAAmB,CAAC,UAAUF;YACvC;QACF;IACF,GAAG,EAAE;IAEL,OAAON;AACT"}
|
|
1
|
+
{"version":3,"sources":["../src/useOrientation.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useState } from \"react\";\n\n/**\n * An extremely simple \"polyfill\" for the `window.screen.orientation` just for\n * the `type` value that is required for the `useOrientation` hook.\n *\n * @see {@link https://caniuse.com/screen-orientation}\n * @returns the orientation type either from the `window.screen.orientation` or\n * by comparing the `availHeight` and `availWidth` on the `window.screen`\n * @internal\n */\nexport const getOrientationType = (): OrientationType => {\n if (typeof window === \"undefined\") {\n return \"landscape-primary\";\n }\n\n // Note: at the time of writing this, it looks like only Safari does not\n // support it from my list of browsers\n const screenOrientation = window.screen.orientation?.type;\n if (typeof screenOrientation === \"string\") {\n return screenOrientation;\n }\n\n const { availHeight, availWidth } = window.screen;\n\n return availHeight > availWidth ? \"portrait-primary\" : \"landscape-primary\";\n};\n\n/**\n * This hook uses the {@link https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation} API\n * to determine if the screen is landscape or portrait. For browsers that do not\n * support this API yet, it will polyfill that behavior using a resize handler\n * instead.\n *\n * @internal\n * @see {@link https://caniuse.com/screen-orientation}\n * @returns the current orientation type\n */\nexport function useOrientation(): OrientationType {\n const [orientation, setOrientation] = useState(getOrientationType);\n useEffect(() => {\n const handler = (): void => setOrientation(getOrientationType());\n\n const { orientation } = window.screen;\n if (orientation) {\n orientation.addEventListener(\"change\", handler);\n } else {\n window.addEventListener(\"resize\", handler);\n }\n\n return () => {\n if (orientation) {\n orientation.removeEventListener(\"change\", handler);\n } else {\n window.removeEventListener(\"resize\", handler);\n }\n };\n }, []);\n\n return orientation;\n}\n"],"names":["useEffect","useState","getOrientationType","window","screenOrientation","screen","orientation","type","availHeight","availWidth","useOrientation","setOrientation","handler","addEventListener","removeEventListener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C;;;;;;;;CAQC,GACD,OAAO,MAAMC,qBAAqB;IAChC,IAAI,OAAOC,WAAW,aAAa;QACjC,OAAO;IACT;IAEA,wEAAwE;IACxE,sCAAsC;IACtC,MAAMC,oBAAoBD,OAAOE,MAAM,CAACC,WAAW,EAAEC;IACrD,IAAI,OAAOH,sBAAsB,UAAU;QACzC,OAAOA;IACT;IAEA,MAAM,EAAEI,WAAW,EAAEC,UAAU,EAAE,GAAGN,OAAOE,MAAM;IAEjD,OAAOG,cAAcC,aAAa,qBAAqB;AACzD,EAAE;AAEF;;;;;;;;;CASC,GACD,OAAO,SAASC;IACd,MAAM,CAACJ,aAAaK,eAAe,GAAGV,SAASC;IAC/CF,UAAU;QACR,MAAMY,UAAU,IAAYD,eAAeT;QAE3C,MAAM,EAAEI,WAAW,EAAE,GAAGH,OAAOE,MAAM;QACrC,IAAIC,aAAa;YACfA,YAAYO,gBAAgB,CAAC,UAAUD;QACzC,OAAO;YACLT,OAAOU,gBAAgB,CAAC,UAAUD;QACpC;QAEA,OAAO;YACL,IAAIN,aAAa;gBACfA,YAAYQ,mBAAmB,CAAC,UAAUF;YAC5C,OAAO;gBACLT,OAAOW,mBAAmB,CAAC,UAAUF;YACvC;QACF;IACF,GAAG,EAAE;IAEL,OAAON;AACT"}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* browser is no longer partially visible or becomes partially visible.
|
|
7
7
|
*
|
|
8
8
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState
|
|
9
|
-
* @
|
|
9
|
+
* @since 6.0.0
|
|
10
10
|
*/
|
|
11
11
|
export type PageInactiveType = "focus" | "visibility";
|
|
12
12
|
/**
|
|
13
|
-
* @
|
|
13
|
+
* @since 6.0.0
|
|
14
14
|
*/
|
|
15
15
|
export interface PageInactiveOptions {
|
|
16
16
|
/**
|
|
@@ -68,6 +68,6 @@ export interface PageInactiveOptions {
|
|
|
68
68
|
* return null;
|
|
69
69
|
* }
|
|
70
70
|
* ```
|
|
71
|
-
* @
|
|
71
|
+
* @since 6.0.0
|
|
72
72
|
*/
|
|
73
73
|
export declare function usePageInactive(options: PageInactiveOptions): void;
|
package/dist/usePageInactive.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/usePageInactive.ts"],"sourcesContent":["\"use client\";\nimport { useEffect } from \"react\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * When this is set to `\"focus\"`, the change handler will be fired whenever the\n * window gains or loses focus.\n *\n * When this is set to `visibility`, the change handler will be fired when the\n * browser is no longer partially visible or becomes partially visible.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState\n * @
|
|
1
|
+
{"version":3,"sources":["../src/usePageInactive.ts"],"sourcesContent":["\"use client\";\nimport { useEffect } from \"react\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * When this is set to `\"focus\"`, the change handler will be fired whenever the\n * window gains or loses focus.\n *\n * When this is set to `visibility`, the change handler will be fired when the\n * browser is no longer partially visible or becomes partially visible.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState\n * @since 6.0.0\n */\nexport type PageInactiveType = \"focus\" | \"visibility\";\n\n/**\n * @since 6.0.0\n */\nexport interface PageInactiveOptions {\n /**\n * @see {@link PageInactiveType}\n * @defaultValue `\"focus\"`\n */\n type?: PageInactiveType;\n\n /**\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * This will be called whenever the page activity changes based on the\n * {@link PageInactiveType}.\n */\n onChange(active: boolean): void;\n\n /**\n * This will be fired whenever the {@link disabled} state is `true` which can\n * be useful for clearing pending timers or resetting state.\n *\n * Since this is passed to a `useEffect` as a dependency, you might have to\n * wrap this in a `useCallback` if unexpected re-rendering or errors occurs.\n *\n * @defaultValue `() => {}`\n */\n onDisabledCleanup?(): void;\n}\n\n/**\n * @example\n * ```ts\n * import { usePageInactive } from \"@react-md/core\";\n * import { useCallback, useEffect, useRef, useState } from \"react\";\n *\n * function Example(): null {\n * const [visible, setVisible] = useState(false);\n * const timeout = useRef<number | undefined>();\n * const startTimeout = useCallback(() => {\n * timeout.current = window.setTimeout(() => {\n * setVisible(false);\n * }, 10000);\n * }, []);\n *\n * usePageInactive({\n * onChange(active) {\n * if (!active) {\n * window.clearTimeout(timeout.current);\n * setVisible(false);\n * } else {\n * startTimeout();\n * }\n * }\n * });\n *\n * // pretend implementation\n * return null;\n * }\n * ```\n * @since 6.0.0\n */\nexport function usePageInactive(options: PageInactiveOptions): void {\n const {\n type = \"focus\",\n disabled,\n onChange,\n onDisabledCleanup = noop,\n } = options;\n useEffect(() => {\n if (disabled) {\n onDisabledCleanup();\n return;\n }\n\n const callback = (event: Event): void => {\n let active = document.visibilityState === \"visible\";\n if (event.type === \"blur\") {\n active = false;\n } else if (event.type === \"focus\") {\n active = true;\n }\n\n onChange(active);\n };\n\n document.addEventListener(\"visibilitychange\", callback);\n if (type === \"focus\") {\n window.addEventListener(\"blur\", callback);\n window.addEventListener(\"focus\", callback);\n }\n\n return () => {\n document.removeEventListener(\"visibilitychange\", callback);\n window.removeEventListener(\"blur\", callback);\n window.removeEventListener(\"focus\", callback);\n };\n }, [disabled, onChange, onDisabledCleanup, type]);\n}\n"],"names":["useEffect","noop","usePageInactive","options","type","disabled","onChange","onDisabledCleanup","callback","event","active","document","visibilityState","addEventListener","window","removeEventListener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,QAAQ;AAElC,MAAMC,OAAO;AACX,aAAa;AACf;AA+CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GACD,OAAO,SAASC,gBAAgBC,OAA4B;IAC1D,MAAM,EACJC,OAAO,OAAO,EACdC,QAAQ,EACRC,QAAQ,EACRC,oBAAoBN,IAAI,EACzB,GAAGE;IACJH,UAAU;QACR,IAAIK,UAAU;YACZE;YACA;QACF;QAEA,MAAMC,WAAW,CAACC;YAChB,IAAIC,SAASC,SAASC,eAAe,KAAK;YAC1C,IAAIH,MAAML,IAAI,KAAK,QAAQ;gBACzBM,SAAS;YACX,OAAO,IAAID,MAAML,IAAI,KAAK,SAAS;gBACjCM,SAAS;YACX;YAEAJ,SAASI;QACX;QAEAC,SAASE,gBAAgB,CAAC,oBAAoBL;QAC9C,IAAIJ,SAAS,SAAS;YACpBU,OAAOD,gBAAgB,CAAC,QAAQL;YAChCM,OAAOD,gBAAgB,CAAC,SAASL;QACnC;QAEA,OAAO;YACLG,SAASI,mBAAmB,CAAC,oBAAoBP;YACjDM,OAAOC,mBAAmB,CAAC,QAAQP;YACnCM,OAAOC,mBAAmB,CAAC,SAASP;QACtC;IACF,GAAG;QAACH;QAAUC;QAAUC;QAAmBH;KAAK;AAClD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @since 6.0.0 Updated the API
|
|
3
3
|
*/
|
|
4
4
|
export interface ResizeListenerOptions extends AddEventListenerOptions {
|
|
5
5
|
/**
|
|
@@ -26,8 +26,7 @@ export interface ResizeListenerOptions extends AddEventListenerOptions {
|
|
|
26
26
|
* observe specific elements resizing, check out the {@link useResizeObserver}
|
|
27
27
|
* hook instead.
|
|
28
28
|
*
|
|
29
|
-
* @example
|
|
30
|
-
* Simple Example
|
|
29
|
+
* @example Simple Example
|
|
31
30
|
* ```tsx
|
|
32
31
|
* import { useResizeListener } from "@react-md/core";
|
|
33
32
|
* import type { ReactElement } from "react";
|
|
@@ -57,7 +56,7 @@ export interface ResizeListenerOptions extends AddEventListenerOptions {
|
|
|
57
56
|
* }
|
|
58
57
|
* ```
|
|
59
58
|
*
|
|
60
|
-
* @
|
|
59
|
+
* @since 6.0.0 Updated the API to match the `useResizeObserver` and
|
|
61
60
|
* `useIntersectionObserver` hooks by having an `onUpdate` callback and include
|
|
62
61
|
* the `AddEventListenerOptions` as part of the hook options.
|
|
63
62
|
*/
|
|
@@ -6,8 +6,7 @@ import { delegateEvent } from "./delegateEvent.js";
|
|
|
6
6
|
* observe specific elements resizing, check out the {@link useResizeObserver}
|
|
7
7
|
* hook instead.
|
|
8
8
|
*
|
|
9
|
-
* @example
|
|
10
|
-
* Simple Example
|
|
9
|
+
* @example Simple Example
|
|
11
10
|
* ```tsx
|
|
12
11
|
* import { useResizeListener } from "@react-md/core";
|
|
13
12
|
* import type { ReactElement } from "react";
|
|
@@ -37,7 +36,7 @@ import { delegateEvent } from "./delegateEvent.js";
|
|
|
37
36
|
* }
|
|
38
37
|
* ```
|
|
39
38
|
*
|
|
40
|
-
* @
|
|
39
|
+
* @since 6.0.0 Updated the API to match the `useResizeObserver` and
|
|
41
40
|
* `useIntersectionObserver` hooks by having an `onUpdate` callback and include
|
|
42
41
|
* the `AddEventListenerOptions` as part of the hook options.
|
|
43
42
|
*/ export function useResizeListener(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useResizeListener.ts"],"sourcesContent":["\"use client\";\nimport { useEffect } from \"react\";\nimport { delegateEvent } from \"./delegateEvent.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { useResizeObserver } from \"./useResizeObserver.js\";\n\n/**\n * @
|
|
1
|
+
{"version":3,"sources":["../src/useResizeListener.ts"],"sourcesContent":["\"use client\";\nimport { useEffect } from \"react\";\nimport { delegateEvent } from \"./delegateEvent.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { useResizeObserver } from \"./useResizeObserver.js\";\n\n/**\n * @since 6.0.0 Updated the API\n */\nexport interface ResizeListenerOptions extends AddEventListenerOptions {\n /**\n * Set this to `false` to disable throttling with\n * `window.requestAnimationFrame`.\n *\n * @defaultValue `true`\n */\n throttle?: boolean;\n\n /**\n * Set this to `true` to disable attaching the resize event handler.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * This function will be called whenever the resize event is fired on the\n * `window`. This should be wrapped in `useCallback`.\n */\n onUpdate(event: Event): void;\n}\n\n/**\n * This hook can be used to listen to the entire window resizing. If you need to\n * observe specific elements resizing, check out the {@link useResizeObserver}\n * hook instead.\n *\n * @example Simple Example\n * ```tsx\n * import { useResizeListener } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * function Example(): ReactElement {\n * const [size, setSize] = useState({\n * height: window.innerHeight,\n * width: window.innerWidth,\n * }):\n *\n * useResizeListener({\n * onUpdate(event) {\n * setSize({\n * height: window.innerHeight,\n * width: window.innerWidth,\n * });\n * },\n * });\n *\n * return (\n * <>\n * The current window size:\n * <pre><code>{JSON.stringify(size, null, 2)}</code></pre>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0 Updated the API to match the `useResizeObserver` and\n * `useIntersectionObserver` hooks by having an `onUpdate` callback and include\n * the `AddEventListenerOptions` as part of the hook options.\n */\nexport function useResizeListener(options: ResizeListenerOptions): void {\n const {\n once,\n signal,\n capture,\n passive,\n throttle = true,\n disabled = false,\n onUpdate,\n } = options;\n\n useEffect(() => {\n if (disabled) {\n return;\n }\n\n const eventHandler = delegateEvent(\"resize\", window, throttle, {\n once,\n signal,\n capture,\n passive,\n });\n eventHandler.add(onUpdate);\n\n window.dispatchEvent(new Event(\"resize\"));\n return () => {\n eventHandler.remove(onUpdate);\n };\n }, [capture, disabled, onUpdate, once, passive, signal, throttle]);\n}\n"],"names":["useEffect","delegateEvent","useResizeListener","options","once","signal","capture","passive","throttle","disabled","onUpdate","eventHandler","window","add","dispatchEvent","Event","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,aAAa,QAAQ,qBAAqB;AA8BnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCC,GACD,OAAO,SAASC,kBAAkBC,OAA8B;IAC9D,MAAM,EACJC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,OAAO,EACPC,WAAW,IAAI,EACfC,WAAW,KAAK,EAChBC,QAAQ,EACT,GAAGP;IAEJH,UAAU;QACR,IAAIS,UAAU;YACZ;QACF;QAEA,MAAME,eAAeV,cAAc,UAAUW,QAAQJ,UAAU;YAC7DJ;YACAC;YACAC;YACAC;QACF;QACAI,aAAaE,GAAG,CAACH;QAEjBE,OAAOE,aAAa,CAAC,IAAIC,MAAM;QAC/B,OAAO;YACLJ,aAAaK,MAAM,CAACN;QACtB;IACF,GAAG;QAACJ;QAASG;QAAUC;QAAUN;QAAMG;QAASF;QAAQG;KAAS;AACnE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Ref, type RefCallback } from "react";
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
3
|
+
* @since 6.0.0
|
|
4
4
|
*/
|
|
5
5
|
export type ResizeObserverEntryCallback = (entry: ResizeObserverEntry) => void;
|
|
6
6
|
/** @internal */
|
|
@@ -28,7 +28,7 @@ interface SubscribeOptions {
|
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* @internal
|
|
31
|
-
* @
|
|
31
|
+
* @since 6.0.0 This was added to help with testing. The
|
|
32
32
|
* `subscriptions` and `sharedObserver` used to be module-level variables but
|
|
33
33
|
* moving to a class makes it easier to mock. Checkout the
|
|
34
34
|
* `src/tests-utils/ResizeObserver.ts`
|
|
@@ -52,13 +52,12 @@ export declare class ResizeObserverManager {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* @internal
|
|
55
|
-
* @
|
|
55
|
+
* @since 6.0.0
|
|
56
56
|
*/
|
|
57
57
|
export declare const resizeObserverManager: ResizeObserverManager;
|
|
58
58
|
/**
|
|
59
|
-
* @
|
|
60
|
-
*
|
|
61
|
-
* \@since 6.0.0 Renamed from `UseResizeObserverOptions` and added
|
|
59
|
+
* @since 2.3.0
|
|
60
|
+
* @since 6.0.0 Renamed from `UseResizeObserverOptions` and added
|
|
62
61
|
* `onUpdate`/`disabled` options.
|
|
63
62
|
*/
|
|
64
63
|
export interface ResizeObserverHookOptions<E extends HTMLElement> {
|
|
@@ -76,7 +75,7 @@ export interface ResizeObserverHookOptions<E extends HTMLElement> {
|
|
|
76
75
|
*/
|
|
77
76
|
onUpdate: ResizeObserverEntryCallback;
|
|
78
77
|
/**
|
|
79
|
-
* Set this to `true` to prevent observing the element's size changes.
|
|
78
|
+
* Set this to `true` to prevent observing the element's size changes. This is
|
|
80
79
|
* equivalent to not attaching the returned ref to any element.
|
|
81
80
|
*
|
|
82
81
|
* @defaultValue `false`
|
|
@@ -102,9 +101,8 @@ export interface ResizeObserverHookOptions<E extends HTMLElement> {
|
|
|
102
101
|
* For most cases you can use the {@link useElementSize} instead, but this hook
|
|
103
102
|
* can be used for more complex behavior with the {@link ResizeObserverEntry}.
|
|
104
103
|
*
|
|
105
|
-
* @
|
|
106
|
-
*
|
|
107
|
-
* \@since 6.0.0 The API was updated to match the `useIntersectionObserver`
|
|
104
|
+
* @since 2.3.0
|
|
105
|
+
* @since 6.0.0 The API was updated to match the `useIntersectionObserver`
|
|
108
106
|
* implementation -- accepts only a single object parameter and returns a
|
|
109
107
|
* {@link RefCallback} instead of `[nodeRef, refCallback]`
|
|
110
108
|
*/
|
|
@@ -16,7 +16,7 @@ import { useEffect } from "react";
|
|
|
16
16
|
import { useEnsuredRef } from "./useEnsuredRef.js";
|
|
17
17
|
/**
|
|
18
18
|
* @internal
|
|
19
|
-
* @
|
|
19
|
+
* @since 6.0.0 This was added to help with testing. The
|
|
20
20
|
* `subscriptions` and `sharedObserver` used to be module-level variables but
|
|
21
21
|
* moving to a class makes it easier to mock. Checkout the
|
|
22
22
|
* `src/tests-utils/ResizeObserver.ts`
|
|
@@ -92,16 +92,15 @@ import { useEnsuredRef } from "./useEnsuredRef.js";
|
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* @internal
|
|
95
|
-
* @
|
|
95
|
+
* @since 6.0.0
|
|
96
96
|
*/ export const resizeObserverManager = new ResizeObserverManager();
|
|
97
97
|
/**
|
|
98
98
|
* The resize observer is used to track the size changes of a specific element.
|
|
99
99
|
* For most cases you can use the {@link useElementSize} instead, but this hook
|
|
100
100
|
* can be used for more complex behavior with the {@link ResizeObserverEntry}.
|
|
101
101
|
*
|
|
102
|
-
* @
|
|
103
|
-
*
|
|
104
|
-
* \@since 6.0.0 The API was updated to match the `useIntersectionObserver`
|
|
102
|
+
* @since 2.3.0
|
|
103
|
+
* @since 6.0.0 The API was updated to match the `useIntersectionObserver`
|
|
105
104
|
* implementation -- accepts only a single object parameter and returns a
|
|
106
105
|
* {@link RefCallback} instead of `[nodeRef, refCallback]`
|
|
107
106
|
*/ export function useResizeObserver(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useResizeObserver.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, type Ref, type RefCallback } from \"react\";\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useElementSize } from \"./useElementSize.js\";\n\n/**\n * @
|
|
1
|
+
{"version":3,"sources":["../src/useResizeObserver.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, type Ref, type RefCallback } from \"react\";\nimport { useEnsuredRef } from \"./useEnsuredRef.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useElementSize } from \"./useElementSize.js\";\n\n/**\n * @since 6.0.0\n */\nexport type ResizeObserverEntryCallback = (entry: ResizeObserverEntry) => void;\n\n/** @internal */\ntype Unsubscribe = () => void;\n\n/** @internal */\ninterface TargetSize {\n height: number;\n width: number;\n scrollHeight: number;\n scrollWidth: number;\n}\n\n/** @internal */\ninterface TargetSubscription {\n readonly onUpdate: ResizeObserverEntryCallback;\n readonly disableHeight: boolean;\n readonly disableWidth: boolean;\n\n size?: TargetSize;\n}\n\n/** @internal */\ninterface SubscribeOptions {\n element: Element;\n onUpdate: ResizeObserverEntryCallback;\n disableHeight: boolean;\n disableWidth: boolean;\n}\n\n/**\n * @internal\n * @since 6.0.0 This was added to help with testing. The\n * `subscriptions` and `sharedObserver` used to be module-level variables but\n * moving to a class makes it easier to mock. Checkout the\n * `src/tests-utils/ResizeObserver.ts`\n */\nexport class ResizeObserverManager {\n frame: number;\n subscriptions: Map<Element, Set<TargetSubscription>>;\n\n /**\n * Why is there a single shared observer instead of multiple and a\n * \"subscription\" model?\n *\n * Note: Probably a bit of a premature optimization right now...\n *\n * @see https://github.com/WICG/resize-observer/issues/59\n * @internal\n */\n sharedObserver: ResizeObserver | undefined;\n\n constructor() {\n this.frame = 0;\n this.subscriptions = new Map();\n }\n\n subscribe = (options: SubscribeOptions): Unsubscribe => {\n const { element, onUpdate, disableHeight, disableWidth } = options;\n\n // lazy initialize the observer\n const observer =\n this.sharedObserver ||\n new ResizeObserver((entries) => {\n // this prevents the `ResizeObserver loop limit exceeded`\n window.cancelAnimationFrame(this.frame);\n this.frame = window.requestAnimationFrame(() => {\n this.handleResizeEntries(entries);\n });\n });\n this.sharedObserver = observer;\n\n const updates = this.subscriptions.get(element) || new Set();\n const subscription: TargetSubscription = {\n onUpdate,\n disableHeight,\n disableWidth,\n };\n updates.add(subscription);\n if (!this.subscriptions.has(element)) {\n this.subscriptions.set(element, updates);\n }\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n updates.delete(subscription);\n };\n };\n\n handleResizeEntries = (entries: ResizeObserverEntry[]): void => {\n for (const entry of entries) {\n const targetSubscriptions = this.subscriptions.get(entry.target);\n // shouldn't really happen\n /* c8 ignore start */\n if (!targetSubscriptions) {\n continue;\n }\n /* c8 ignore stop */\n\n const entries = targetSubscriptions.values();\n for (const subscription of entries) {\n const { height, width } = entry.contentRect;\n const { scrollHeight, scrollWidth } = entry.target;\n const { onUpdate, size, disableHeight, disableWidth } = subscription;\n const isHeightChange =\n !disableHeight &&\n (!size ||\n size.height !== height ||\n size.scrollHeight !== scrollHeight);\n const isWidthChange =\n !disableWidth &&\n (!size || size.width !== width || size.scrollWidth !== scrollWidth);\n\n subscription.size = {\n height,\n width,\n scrollHeight,\n scrollWidth,\n };\n if (isHeightChange || isWidthChange) {\n onUpdate(entry);\n }\n }\n }\n };\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport const resizeObserverManager = new ResizeObserverManager();\n\n/**\n * @since 2.3.0\n * @since 6.0.0 Renamed from `UseResizeObserverOptions` and added\n * `onUpdate`/`disabled` options.\n */\nexport interface ResizeObserverHookOptions<E extends HTMLElement> {\n /**\n * An optional ref to merge with the ref returned by this hook.\n */\n ref?: Ref<E>;\n\n /**\n * **Must be wrapped in `useCallback` to prevent re-creating the\n * ResizeObserver each render.**\n *\n * This function will be called whenever the target element resizes.\n *\n * @see {@link useResizeObserver} for an example.\n */\n onUpdate: ResizeObserverEntryCallback;\n\n /**\n * Set this to `true` to prevent observing the element's size changes. This is\n * equivalent to not attaching the returned ref to any element.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * Set this to `true` if the {@link onUpdate} should not be fired for height\n * changes.\n *\n * @defaultValue `false`\n */\n disableHeight?: boolean;\n\n /**\n * Set this to `true` if the {@link onUpdate} should not be fired for width\n * changes.\n *\n * @defaultValue `false`\n */\n disableWidth?: boolean;\n}\n\n/**\n * The resize observer is used to track the size changes of a specific element.\n * For most cases you can use the {@link useElementSize} instead, but this hook\n * can be used for more complex behavior with the {@link ResizeObserverEntry}.\n *\n * @since 2.3.0\n * @since 6.0.0 The API was updated to match the `useIntersectionObserver`\n * implementation -- accepts only a single object parameter and returns a\n * {@link RefCallback} instead of `[nodeRef, refCallback]`\n */\nexport function useResizeObserver<E extends HTMLElement>(\n options: ResizeObserverHookOptions<E>\n): RefCallback<E> {\n const {\n ref,\n onUpdate,\n disabled,\n disableHeight = false,\n disableWidth = false,\n } = options;\n\n const [targetNodeRef, refCallback] = useEnsuredRef(ref);\n useEffect(() => {\n const element = targetNodeRef.current;\n if (disabled || (disableHeight && disableWidth) || !element) {\n return;\n }\n\n const unsubscribe = resizeObserverManager.subscribe({\n element,\n onUpdate,\n disableHeight,\n disableWidth,\n });\n\n return () => {\n unsubscribe();\n };\n }, [disableHeight, disableWidth, disabled, onUpdate, targetNodeRef]);\n\n return refCallback;\n}\n"],"names":["useEffect","useEnsuredRef","ResizeObserverManager","constructor","frame","subscriptions","sharedObserver","subscribe","options","element","onUpdate","disableHeight","disableWidth","observer","ResizeObserver","entries","window","cancelAnimationFrame","requestAnimationFrame","handleResizeEntries","updates","get","Set","subscription","add","has","set","observe","unobserve","delete","entry","targetSubscriptions","target","values","height","width","contentRect","scrollHeight","scrollWidth","size","isHeightChange","isWidthChange","Map","resizeObserverManager","useResizeObserver","ref","disabled","targetNodeRef","refCallback","current","unsubscribe"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { type AnyFunction, type CancelableFunction } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
3
|
+
* @since 6.0.0
|
|
4
4
|
*/
|
|
5
5
|
export type ThrottledFunction<F extends AnyFunction> = CancelableFunction<(...args: Parameters<F>) => ReturnType<F>>;
|
|
6
6
|
/**
|
|
7
7
|
* Creates a function that will only be called once every X milliseconds.
|
|
8
8
|
*
|
|
9
|
-
* @example
|
|
10
|
-
* Throttling Search API Requests
|
|
9
|
+
* @example Throttling Search API Requests
|
|
11
10
|
* ```tsx
|
|
12
11
|
* import { TextField, useThrottledFunction, useUnmounted } from "@react-md/core";
|
|
13
12
|
* import { useState } from "react";
|
|
@@ -77,6 +76,6 @@ export type ThrottledFunction<F extends AnyFunction> = CancelableFunction<(...ar
|
|
|
77
76
|
*
|
|
78
77
|
* @see `useDebouncedFunction` for debounce behavior instead. (Call a
|
|
79
78
|
* function only if it has not been called again for X milliseconds).
|
|
80
|
-
* @
|
|
79
|
+
* @since 6.0.0
|
|
81
80
|
*/
|
|
82
81
|
export declare function useThrottledFunction<F extends AnyFunction>(func: F, wait: number): ThrottledFunction<F>;
|
|
@@ -4,8 +4,7 @@ import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates a function that will only be called once every X milliseconds.
|
|
6
6
|
*
|
|
7
|
-
* @example
|
|
8
|
-
* Throttling Search API Requests
|
|
7
|
+
* @example Throttling Search API Requests
|
|
9
8
|
* ```tsx
|
|
10
9
|
* import { TextField, useThrottledFunction, useUnmounted } from "@react-md/core";
|
|
11
10
|
* import { useState } from "react";
|
|
@@ -75,7 +74,7 @@ import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
|
|
|
75
74
|
*
|
|
76
75
|
* @see `useDebouncedFunction` for debounce behavior instead. (Call a
|
|
77
76
|
* function only if it has not been called again for X milliseconds).
|
|
78
|
-
* @
|
|
77
|
+
* @since 6.0.0
|
|
79
78
|
*/ export function useThrottledFunction(func, wait) {
|
|
80
79
|
const args = useRef();
|
|
81
80
|
const result = useRef();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useThrottledFunction.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { type AnyFunction, type CancelableFunction } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\n\n/**\n * @
|
|
1
|
+
{"version":3,"sources":["../src/useThrottledFunction.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { type AnyFunction, type CancelableFunction } from \"./types.js\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\n\n/**\n * @since 6.0.0\n */\nexport type ThrottledFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => ReturnType<F>\n>;\n\n/**\n * Creates a function that will only be called once every X milliseconds.\n *\n * @example Throttling Search API Requests\n * ```tsx\n * import { TextField, useThrottledFunction, useUnmounted } from \"@react-md/core\";\n * import { useState } from \"react\";\n * import type { ReactElement } from \"react\";\n *\n * interface State {\n * error?: unknown\n * loading: boolean;\n * results?: {\n * // pretend some search results\n * id: string;\n * name: string;\n * }[];\n * }\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState<State>({\n * loading: false,\n * });\n * // this is only required for async actions\n * const unmounted = useUnmounted();\n *\n * // A new search request will be fired once every 500ms as the user types.\n * // can't use the event here since React uses synthetic events\n * const search = useThrottledFunction(async (q: string) => {\n * setState({\n * loading: true,\n * error: undefined,\n * results: undefined,\n * });\n *\n * try {\n * const response = await fetch('/search', {\n * method: 'POST',\n * headers: {\n * 'Content-Type': 'application/json',\n * },\n * body: JSON.stringify({ q }),\n * });\n * const json = await response.json();\n *\n * if (!unmounted.current) {\n * setState({\n * loading: false,\n * results: json,\n * });\n * }\n * } catch (error) {\n * if (!unmounted.current) {\n * setState({\n * error,\n * loading: false,\n * });\n * }\n * }\n * }, 500);\n *\n * return (\n * <TextField\n * type=\"search\"\n * label=\"Search\"\n * onChange={(event) => search(event.currentTarget.value)}\n * />\n * );\n * }\n * ```\n *\n * @see `useDebouncedFunction` for debounce behavior instead. (Call a\n * function only if it has not been called again for X milliseconds).\n * @since 6.0.0\n */\nexport function useThrottledFunction<F extends AnyFunction>(\n func: F,\n wait: number\n): ThrottledFunction<F> {\n const args = useRef<Parameters<F>>();\n const result = useRef<ReturnType<F>>();\n const timeout = useRef<number | undefined>();\n const funcRef = useRef(func);\n const lastCalledTime = useRef(0);\n\n useIsomorphicLayoutEffect(() => {\n funcRef.current = func;\n });\n\n useEffect(() => {\n return () => {\n window.clearTimeout(timeout.current);\n };\n }, []);\n\n return useMemo(() => {\n const throttled: ThrottledFunction<F> = (...nextArgs) => {\n args.current = nextArgs;\n\n const now = Date.now();\n const remaining = wait - (now - lastCalledTime.current);\n if (remaining <= 0 || remaining > wait) {\n lastCalledTime.current = now;\n result.current = funcRef.current(...args.current);\n } else if (!timeout.current) {\n timeout.current = window.setTimeout(() => {\n lastCalledTime.current = Date.now();\n timeout.current = undefined;\n // should exist by this time\n result.current = funcRef.current(...(args.current as Parameters<F>));\n }, remaining);\n }\n\n return result.current as ReturnType<F>;\n };\n throttled.cancel = () => window.clearTimeout(timeout.current);\n\n return throttled;\n }, [wait]);\n}\n"],"names":["useEffect","useMemo","useRef","useIsomorphicLayoutEffect","useThrottledFunction","func","wait","args","result","timeout","funcRef","lastCalledTime","current","window","clearTimeout","throttled","nextArgs","now","Date","remaining","setTimeout","undefined","cancel"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAQ;AAEnD,SAASC,yBAAyB,QAAQ,iCAAiC;AAS3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0EC,GACD,OAAO,SAASC,qBACdC,IAAO,EACPC,IAAY;IAEZ,MAAMC,OAAOL;IACb,MAAMM,SAASN;IACf,MAAMO,UAAUP;IAChB,MAAMQ,UAAUR,OAAOG;IACvB,MAAMM,iBAAiBT,OAAO;IAE9BC,0BAA0B;QACxBO,QAAQE,OAAO,GAAGP;IACpB;IAEAL,UAAU;QACR,OAAO;YACLa,OAAOC,YAAY,CAACL,QAAQG,OAAO;QACrC;IACF,GAAG,EAAE;IAEL,OAAOX,QAAQ;QACb,MAAMc,YAAkC,CAAC,GAAGC;YAC1CT,KAAKK,OAAO,GAAGI;YAEf,MAAMC,MAAMC,KAAKD,GAAG;YACpB,MAAME,YAAYb,OAAQW,CAAAA,MAAMN,eAAeC,OAAO,AAAD;YACrD,IAAIO,aAAa,KAAKA,YAAYb,MAAM;gBACtCK,eAAeC,OAAO,GAAGK;gBACzBT,OAAOI,OAAO,GAAGF,QAAQE,OAAO,IAAIL,KAAKK,OAAO;YAClD,OAAO,IAAI,CAACH,QAAQG,OAAO,EAAE;gBAC3BH,QAAQG,OAAO,GAAGC,OAAOO,UAAU,CAAC;oBAClCT,eAAeC,OAAO,GAAGM,KAAKD,GAAG;oBACjCR,QAAQG,OAAO,GAAGS;oBAClB,4BAA4B;oBAC5Bb,OAAOI,OAAO,GAAGF,QAAQE,OAAO,IAAKL,KAAKK,OAAO;gBACnD,GAAGO;YACL;YAEA,OAAOX,OAAOI,OAAO;QACvB;QACAG,UAAUO,MAAM,GAAG,IAAMT,OAAOC,YAAY,CAACL,QAAQG,OAAO;QAE5D,OAAOG;IACT,GAAG;QAACT;KAAK;AACX"}
|
package/dist/useToggle.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UseStateInitializer, UseStateSetter } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
3
|
+
* @since 6.0.0
|
|
4
4
|
*/
|
|
5
5
|
export interface ToggleHookReturnValue {
|
|
6
6
|
toggled: boolean;
|
|
@@ -11,8 +11,7 @@ export interface ToggleHookReturnValue {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
|
-
* @example
|
|
15
|
-
* Simple Example
|
|
14
|
+
* @example Simple Example
|
|
16
15
|
* ```tsx
|
|
17
16
|
* import { Button, useToggle } from "@react-md/core";
|
|
18
17
|
* import type { ReactElement } from "react";
|
package/dist/useToggle.js
CHANGED
package/dist/useToggle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useToggle.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useState } from \"react\";\nimport type { UseStateInitializer, UseStateSetter } from \"./types.js\";\n\n/**\n * @
|
|
1
|
+
{"version":3,"sources":["../src/useToggle.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useState } from \"react\";\nimport type { UseStateInitializer, UseStateSetter } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ToggleHookReturnValue {\n toggled: boolean;\n setToggled: UseStateSetter<boolean>;\n toggle(): void;\n enable(): void;\n disable(): void;\n}\n\n/**\n *\n * @example Simple Example\n * ```tsx\n * import { Button, useToggle } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * const { toggled, toggle } = useToggle();\n *\n * return (\n * <>\n * <Button onClick=[toggle]>Toggle</Button>\n * {`Toggled: ${toggled}`}\n * </>\n * );\n * }\n * ```\n *\n * @param defaultValue - `false`\n */\nexport function useToggle(\n defaultValue: UseStateInitializer<boolean> = false\n): Readonly<ToggleHookReturnValue> {\n const [toggled, setToggled] = useState(defaultValue);\n\n return {\n toggled,\n setToggled,\n toggle: useCallback(() => {\n setToggled((prevToggled) => !prevToggled);\n }, []),\n enable: useCallback(() => {\n setToggled(true);\n }, []),\n disable: useCallback(() => {\n setToggled(false);\n }, []),\n };\n}\n"],"names":["useCallback","useState","useToggle","defaultValue","toggled","setToggled","toggle","prevToggled","enable","disable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAc9C;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASC,UACdC,eAA6C,KAAK;IAElD,MAAM,CAACC,SAASC,WAAW,GAAGJ,SAASE;IAEvC,OAAO;QACLC;QACAC;QACAC,QAAQN,YAAY;YAClBK,WAAW,CAACE,cAAgB,CAACA;QAC/B,GAAG,EAAE;QACLC,QAAQR,YAAY;YAClBK,WAAW;QACb,GAAG,EAAE;QACLI,SAAST,YAAY;YACnBK,WAAW;QACb,GAAG,EAAE;IACP;AACF"}
|
package/dist/useUnmounted.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { NonNullRef } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* @example
|
|
4
|
-
* Simple Example
|
|
3
|
+
* @example Simple Example
|
|
5
4
|
* ```tsx
|
|
6
5
|
* import { useUnmounted } from "@react-md/core";
|
|
7
6
|
* import { useEffect, useState } from "react";
|
|
@@ -26,6 +25,6 @@ import type { NonNullRef } from "./types.js";
|
|
|
26
25
|
* return null;
|
|
27
26
|
* }
|
|
28
27
|
* ```
|
|
29
|
-
* @
|
|
28
|
+
* @since 6.0.0
|
|
30
29
|
*/
|
|
31
30
|
export declare function useUnmounted(): NonNullRef<boolean>;
|
package/dist/useUnmounted.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
3
|
/**
|
|
4
|
-
* @example
|
|
5
|
-
* Simple Example
|
|
4
|
+
* @example Simple Example
|
|
6
5
|
* ```tsx
|
|
7
6
|
* import { useUnmounted } from "@react-md/core";
|
|
8
7
|
* import { useEffect, useState } from "react";
|
|
@@ -27,7 +26,7 @@ import { useEffect, useRef } from "react";
|
|
|
27
26
|
* return null;
|
|
28
27
|
* }
|
|
29
28
|
* ```
|
|
30
|
-
* @
|
|
29
|
+
* @since 6.0.0
|
|
31
30
|
*/ export function useUnmounted() {
|
|
32
31
|
const unmounted = useRef(false);
|
|
33
32
|
useEffect(()=>{
|
package/dist/useUnmounted.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useUnmounted.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport type { NonNullRef } from \"./types.js\";\n\n/**\n * @example
|
|
1
|
+
{"version":3,"sources":["../src/useUnmounted.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport type { NonNullRef } from \"./types.js\";\n\n/**\n * @example Simple Example\n * ```tsx\n * import { useUnmounted } from \"@react-md/core\";\n * import { useEffect, useState } from \"react\";\n *\n * function Example(): ReactElement {\n * const [state, setState] = useState({ loading: false });\n * const unmounted = useUnmounted();\n *\n * useEffect(() => {\n * async function load(): void {\n * const result = await fetch('/some-api');\n * const json = await response.json();\n * if (!unmounted.current) {\n * setState({ loading: false, result: json });\n * }\n * }\n *\n * setState({ loading: true });\n * load();\n * }, [unmounted]);\n *\n * return null;\n * }\n * ```\n * @since 6.0.0\n */\nexport function useUnmounted(): NonNullRef<boolean> {\n const unmounted = useRef(false);\n useEffect(() => {\n unmounted.current = false;\n return () => {\n unmounted.current = true;\n };\n }, []);\n\n return unmounted;\n}\n"],"names":["useEffect","useRef","useUnmounted","unmounted","current"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,QAAQ;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,OAAO,SAASC;IACd,MAAMC,YAAYF,OAAO;IACzBD,UAAU;QACRG,UAAUC,OAAO,GAAG;QACpB,OAAO;YACLD,UAAUC,OAAO,GAAG;QACtB;IACF,GAAG,EAAE;IAEL,OAAOD;AACT"}
|
package/dist/useWindowSize.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ElementSize } from "./types.js";
|
|
2
2
|
import { type ResizeListenerOptions } from "./useResizeListener.js";
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @since 6.0.0
|
|
5
5
|
*/
|
|
6
6
|
export interface WindowSizeOptions extends Omit<ResizeListenerOptions, "disabled" | "onUpdate"> {
|
|
7
7
|
/**
|
|
@@ -36,8 +36,7 @@ export interface WindowSizeOptions extends Omit<ResizeListenerOptions, "disabled
|
|
|
36
36
|
/**
|
|
37
37
|
* This is just a convenience wrapper around the {@link useResizeListener}.
|
|
38
38
|
*
|
|
39
|
-
* @example
|
|
40
|
-
* Simple Example
|
|
39
|
+
* @example Simple Example
|
|
41
40
|
* ```tsx
|
|
42
41
|
* import { useWindowSize } from "@react-md/core";
|
|
43
42
|
* import type { ReactElement } from "react";
|
|
@@ -55,6 +54,6 @@ export interface WindowSizeOptions extends Omit<ResizeListenerOptions, "disabled
|
|
|
55
54
|
* }
|
|
56
55
|
* ```
|
|
57
56
|
*
|
|
58
|
-
* @
|
|
57
|
+
* @since 6.0.0
|
|
59
58
|
*/
|
|
60
59
|
export declare function useWindowSize(options?: WindowSizeOptions): ElementSize;
|
package/dist/useWindowSize.js
CHANGED
|
@@ -5,8 +5,7 @@ import { useResizeListener } from "./useResizeListener.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* This is just a convenience wrapper around the {@link useResizeListener}.
|
|
7
7
|
*
|
|
8
|
-
* @example
|
|
9
|
-
* Simple Example
|
|
8
|
+
* @example Simple Example
|
|
10
9
|
* ```tsx
|
|
11
10
|
* import { useWindowSize } from "@react-md/core";
|
|
12
11
|
* import type { ReactElement } from "react";
|
|
@@ -24,7 +23,7 @@ import { useResizeListener } from "./useResizeListener.js";
|
|
|
24
23
|
* }
|
|
25
24
|
* ```
|
|
26
25
|
*
|
|
27
|
-
* @
|
|
26
|
+
* @since 6.0.0
|
|
28
27
|
*/ export function useWindowSize(options = {}) {
|
|
29
28
|
const { once, signal, capture, passive, throttle, ssrHeight = 0, ssrWidth = 0, disableWidth, disableHeight } = options;
|
|
30
29
|
const ssr = useSsr();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useWindowSize.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useState } from \"react\";\nimport { useSsr } from \"./SsrProvider.js\";\nimport { type ElementSize } from \"./types.js\";\nimport {\n useResizeListener,\n type ResizeListenerOptions,\n} from \"./useResizeListener.js\";\n\n/**\n * @
|
|
1
|
+
{"version":3,"sources":["../src/useWindowSize.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useState } from \"react\";\nimport { useSsr } from \"./SsrProvider.js\";\nimport { type ElementSize } from \"./types.js\";\nimport {\n useResizeListener,\n type ResizeListenerOptions,\n} from \"./useResizeListener.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface WindowSizeOptions\n extends Omit<ResizeListenerOptions, \"disabled\" | \"onUpdate\"> {\n /**\n * The default value to use in SSR environments for the window's height.\n *\n * @defaultValue `0`\n */\n ssrHeight?: number;\n\n /**\n * The default value to use in SSR environments for the window's width.\n *\n * @defaultValue `0`\n */\n ssrWidth?: number;\n\n /**\n * Set this to `true` to ignore resize events that only updated the height.\n * The hook can be disabled by setting this and {@link disableWidth} to\n * `true`.\n *\n * @defaultValue `false`\n */\n disableHeight?: boolean;\n\n /**\n * Set this to `true` to ignore resize events that only updated the width.\n * The hook can be disabled by setting this and {@link disableHeight} to\n * `true`.\n *\n * @defaultValue `false`\n */\n disableWidth?: boolean;\n}\n\n/**\n * This is just a convenience wrapper around the {@link useResizeListener}.\n *\n * @example Simple Example\n * ```tsx\n * import { useWindowSize } from \"@react-md/core\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * function Example(): ReactElement {\n * const { height, width } = useWindowSize();\n *\n * return (\n * <>\n * The current window size:\n * <pre><code>{JSON.stringify(size, null, 2)}</code></pre>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport function useWindowSize(options: WindowSizeOptions = {}): ElementSize {\n const {\n once,\n signal,\n capture,\n passive,\n throttle,\n ssrHeight = 0,\n ssrWidth = 0,\n disableWidth,\n disableHeight,\n } = options;\n\n const ssr = useSsr();\n const [size, setSize] = useState(() => {\n if (typeof window === \"undefined\" || ssr) {\n return {\n height: ssrHeight,\n width: ssrWidth,\n };\n }\n\n return {\n height: window.innerHeight,\n width: window.innerWidth,\n };\n });\n\n useResizeListener({\n once,\n signal,\n capture,\n passive,\n throttle,\n disabled: disableHeight && disableWidth,\n onUpdate: useCallback(() => {\n setSize((prevSize) => {\n const nextSize: ElementSize = {\n height: window.innerHeight,\n width: window.innerWidth,\n };\n\n const isHeightChange =\n !disableHeight && prevSize.height !== nextSize.height;\n const isWidthChange =\n !disableWidth && prevSize.width !== nextSize.width;\n\n return isHeightChange || isWidthChange ? nextSize : prevSize;\n });\n }, [disableHeight, disableWidth]),\n });\n\n return size;\n}\n"],"names":["useCallback","useState","useSsr","useResizeListener","useWindowSize","options","once","signal","capture","passive","throttle","ssrHeight","ssrWidth","disableWidth","disableHeight","ssr","size","setSize","window","height","width","innerHeight","innerWidth","disabled","onUpdate","prevSize","nextSize","isHeightChange","isWidthChange"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAC9C,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,SACEC,iBAAiB,QAEZ,yBAAyB;AAwChC;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,SAASC,cAAcC,UAA6B,CAAC,CAAC;IAC3D,MAAM,EACJC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,YAAY,CAAC,EACbC,WAAW,CAAC,EACZC,YAAY,EACZC,aAAa,EACd,GAAGT;IAEJ,MAAMU,MAAMb;IACZ,MAAM,CAACc,MAAMC,QAAQ,GAAGhB,SAAS;QAC/B,IAAI,OAAOiB,WAAW,eAAeH,KAAK;YACxC,OAAO;gBACLI,QAAQR;gBACRS,OAAOR;YACT;QACF;QAEA,OAAO;YACLO,QAAQD,OAAOG,WAAW;YAC1BD,OAAOF,OAAOI,UAAU;QAC1B;IACF;IAEAnB,kBAAkB;QAChBG;QACAC;QACAC;QACAC;QACAC;QACAa,UAAUT,iBAAiBD;QAC3BW,UAAUxB,YAAY;YACpBiB,QAAQ,CAACQ;gBACP,MAAMC,WAAwB;oBAC5BP,QAAQD,OAAOG,WAAW;oBAC1BD,OAAOF,OAAOI,UAAU;gBAC1B;gBAEA,MAAMK,iBACJ,CAACb,iBAAiBW,SAASN,MAAM,KAAKO,SAASP,MAAM;gBACvD,MAAMS,gBACJ,CAACf,gBAAgBY,SAASL,KAAK,KAAKM,SAASN,KAAK;gBAEpD,OAAOO,kBAAkBC,gBAAgBF,WAAWD;YACtD;QACF,GAAG;YAACX;YAAeD;SAAa;IAClC;IAEA,OAAOG;AACT"}
|