@basic-ui/material 1.0.0-alpha.1 → 1.0.0-alpha.12
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/build/cjs/index.js +1372 -1306
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Alert/Alert.d.ts +1 -1
- package/build/esm/Alert/Alert.js +3 -2
- package/build/esm/Alert/Alert.js.map +1 -1
- package/build/esm/Alert/index.d.ts +0 -0
- package/build/esm/Alert/index.js +0 -0
- package/build/esm/Alert/index.js.map +1 -1
- package/build/esm/AppBar/AppBar.d.ts +3 -3
- package/build/esm/AppBar/AppBar.js +6 -5
- package/build/esm/AppBar/AppBar.js.map +1 -1
- package/build/esm/AppBar/AppBarButton.d.ts +1 -1
- package/build/esm/AppBar/AppBarButton.js +2 -1
- package/build/esm/AppBar/AppBarButton.js.map +1 -1
- package/build/esm/AppBar/context.d.ts +0 -0
- package/build/esm/AppBar/context.js +0 -0
- package/build/esm/AppBar/context.js.map +1 -1
- package/build/esm/AppBar/index.d.ts +0 -0
- package/build/esm/AppBar/index.js +0 -0
- package/build/esm/AppBar/index.js.map +1 -1
- package/build/esm/Badge/Badge.d.ts +1 -1
- package/build/esm/Badge/Badge.js +0 -0
- package/build/esm/Badge/Badge.js.map +1 -1
- package/build/esm/Badge/index.d.ts +0 -0
- package/build/esm/Badge/index.js +0 -0
- package/build/esm/Badge/index.js.map +1 -1
- package/build/esm/BaseLine/BaseLine.d.ts +0 -0
- package/build/esm/BaseLine/BaseLine.js +0 -0
- package/build/esm/BaseLine/BaseLine.js.map +1 -1
- package/build/esm/BaseLine/index.d.ts +0 -0
- package/build/esm/BaseLine/index.js +0 -0
- package/build/esm/BaseLine/index.js.map +1 -1
- package/build/esm/BottomSheet/BottomSheet.d.ts +1 -1
- package/build/esm/BottomSheet/BottomSheet.js +2 -1
- package/build/esm/BottomSheet/BottomSheet.js.map +1 -1
- package/build/esm/BottomSheet/BottomSheetSurface.d.ts +2 -2
- package/build/esm/BottomSheet/BottomSheetSurface.js +4 -3
- package/build/esm/BottomSheet/BottomSheetSurface.js.map +1 -1
- package/build/esm/BottomSheet/index.d.ts +0 -0
- package/build/esm/BottomSheet/index.js +0 -0
- package/build/esm/BottomSheet/index.js.map +1 -1
- package/build/esm/Box/Box.d.ts +4 -4
- package/build/esm/Box/Box.js +1 -2
- package/build/esm/Box/Box.js.map +1 -1
- package/build/esm/Box/index.d.ts +0 -0
- package/build/esm/Box/index.js +0 -0
- package/build/esm/Box/index.js.map +1 -1
- package/build/esm/Button/BaseButton.d.ts +3 -3
- package/build/esm/Button/BaseButton.js +5 -5
- package/build/esm/Button/BaseButton.js.map +1 -1
- package/build/esm/Button/Button.d.ts +4 -4
- package/build/esm/Button/Button.js +6 -6
- package/build/esm/Button/Button.js.map +1 -1
- package/build/esm/Button/ButtonGroup.d.ts +2 -2
- package/build/esm/Button/ButtonGroup.js +3 -2
- package/build/esm/Button/ButtonGroup.js.map +1 -1
- package/build/esm/Button/FilledButton.d.ts +1 -1
- package/build/esm/Button/FilledButton.js +6 -8
- package/build/esm/Button/FilledButton.js.map +1 -1
- package/build/esm/Button/FloatingActionButton.d.ts +0 -0
- package/build/esm/Button/FloatingActionButton.js +1 -1
- package/build/esm/Button/FloatingActionButton.js.map +1 -1
- package/build/esm/Button/IconButton.d.ts +0 -0
- package/build/esm/Button/IconButton.js +1 -1
- package/build/esm/Button/IconButton.js.map +1 -1
- package/build/esm/Button/OutlinedButton.d.ts +1 -1
- package/build/esm/Button/OutlinedButton.js +0 -0
- package/build/esm/Button/OutlinedButton.js.map +1 -1
- package/build/esm/Button/TransparentButton.d.ts +1 -1
- package/build/esm/Button/TransparentButton.js +0 -0
- package/build/esm/Button/TransparentButton.js.map +1 -1
- package/build/esm/Button/context.d.ts +0 -0
- package/build/esm/Button/context.js +0 -0
- package/build/esm/Button/context.js.map +1 -1
- package/build/esm/Button/index.d.ts +0 -0
- package/build/esm/Button/index.js +0 -0
- package/build/esm/Button/index.js.map +1 -1
- package/build/esm/CheckBox/CheckBox.d.ts +5 -5
- package/build/esm/CheckBox/CheckBox.js +6 -5
- package/build/esm/CheckBox/CheckBox.js.map +1 -1
- package/build/esm/CheckBox/CheckBoxIcon.d.ts +4 -4
- package/build/esm/CheckBox/CheckBoxIcon.js +6 -5
- package/build/esm/CheckBox/CheckBoxIcon.js.map +1 -1
- package/build/esm/CheckBox/CheckPath.d.ts +0 -1
- package/build/esm/CheckBox/CheckPath.js +0 -0
- package/build/esm/CheckBox/CheckPath.js.map +1 -1
- package/build/esm/CheckBox/IndeterminatePath.d.ts +0 -1
- package/build/esm/CheckBox/IndeterminatePath.js +0 -0
- package/build/esm/CheckBox/IndeterminatePath.js.map +1 -1
- package/build/esm/CheckBox/index.d.ts +0 -0
- package/build/esm/CheckBox/index.js +0 -0
- package/build/esm/CheckBox/index.js.map +1 -1
- package/build/esm/Chip/ButtonChip.d.ts +4 -4
- package/build/esm/Chip/ButtonChip.js +4 -4
- package/build/esm/Chip/ButtonChip.js.map +1 -1
- package/build/esm/Chip/Chip.d.ts +0 -0
- package/build/esm/Chip/Chip.js +0 -0
- package/build/esm/Chip/Chip.js.map +1 -1
- package/build/esm/Chip/ChipBase.d.ts +3 -3
- package/build/esm/Chip/ChipBase.js +10 -10
- package/build/esm/Chip/ChipBase.js.map +1 -1
- package/build/esm/Chip/ChoiceChip.d.ts +5 -5
- package/build/esm/Chip/ChoiceChip.js +6 -5
- package/build/esm/Chip/ChoiceChip.js.map +1 -1
- package/build/esm/Chip/index.d.ts +0 -0
- package/build/esm/Chip/index.js +0 -0
- package/build/esm/Chip/index.js.map +1 -1
- package/build/esm/Combobox/Combobox.d.ts +13 -13
- package/build/esm/Combobox/Combobox.js +21 -13
- package/build/esm/Combobox/Combobox.js.map +1 -1
- package/build/esm/Combobox/index.d.ts +0 -0
- package/build/esm/Combobox/index.js +0 -0
- package/build/esm/Combobox/index.js.map +1 -1
- package/build/esm/Dialog/Dialog.d.ts +1 -1
- package/build/esm/Dialog/Dialog.js +6 -5
- package/build/esm/Dialog/Dialog.js.map +1 -1
- package/build/esm/Dialog/DialogBackdrop.d.ts +2 -2
- package/build/esm/Dialog/DialogBackdrop.js +2 -2
- package/build/esm/Dialog/DialogBackdrop.js.map +1 -1
- package/build/esm/Dialog/DialogContainer.d.ts +1 -1
- package/build/esm/Dialog/DialogContainer.js +2 -1
- package/build/esm/Dialog/DialogContainer.js.map +1 -1
- package/build/esm/Dialog/DialogSurface.d.ts +2 -2
- package/build/esm/Dialog/DialogSurface.js +4 -4
- package/build/esm/Dialog/DialogSurface.js.map +1 -1
- package/build/esm/Dialog/Scrim.d.ts +1 -1
- package/build/esm/Dialog/Scrim.js +2 -1
- package/build/esm/Dialog/Scrim.js.map +1 -1
- package/build/esm/Dialog/index.d.ts +0 -0
- package/build/esm/Dialog/index.js +1 -0
- package/build/esm/Dialog/index.js.map +1 -1
- package/build/esm/Dialog/useDialogAnimation.d.ts +0 -0
- package/build/esm/Dialog/useDialogAnimation.js +6 -4
- package/build/esm/Dialog/useDialogAnimation.js.map +1 -1
- package/build/esm/Divider/Divider.d.ts +3 -3
- package/build/esm/Divider/Divider.js +7 -7
- package/build/esm/Divider/Divider.js.map +1 -1
- package/build/esm/Divider/index.d.ts +0 -0
- package/build/esm/Divider/index.js +0 -0
- package/build/esm/Divider/index.js.map +1 -1
- package/build/esm/FloatingLabel/FloatingLabel.d.ts +4 -4
- package/build/esm/FloatingLabel/FloatingLabel.js +7 -6
- package/build/esm/FloatingLabel/FloatingLabel.js.map +1 -1
- package/build/esm/FloatingLabel/index.d.ts +0 -0
- package/build/esm/FloatingLabel/index.js +0 -0
- package/build/esm/FloatingLabel/index.js.map +1 -1
- package/build/esm/LineRipple/LineRipple.d.ts +3 -3
- package/build/esm/LineRipple/LineRipple.js +5 -4
- package/build/esm/LineRipple/LineRipple.js.map +1 -1
- package/build/esm/LineRipple/index.d.ts +0 -0
- package/build/esm/LineRipple/index.js +0 -0
- package/build/esm/LineRipple/index.js.map +1 -1
- package/build/esm/Link/Link.d.ts +3 -3
- package/build/esm/Link/Link.js +2 -2
- package/build/esm/Link/Link.js.map +1 -1
- package/build/esm/Link/index.d.ts +0 -0
- package/build/esm/Link/index.js +0 -0
- package/build/esm/Link/index.js.map +1 -1
- package/build/esm/List/List.d.ts +5 -5
- package/build/esm/List/List.js +2 -2
- package/build/esm/List/List.js.map +1 -1
- package/build/esm/List/index.d.ts +0 -0
- package/build/esm/List/index.js +0 -0
- package/build/esm/List/index.js.map +1 -1
- package/build/esm/ListItem/ListItem.d.ts +5 -5
- package/build/esm/ListItem/ListItem.js +7 -6
- package/build/esm/ListItem/ListItem.js.map +1 -1
- package/build/esm/ListItem/ListItemText.d.ts +6 -6
- package/build/esm/ListItem/ListItemText.js +5 -5
- package/build/esm/ListItem/ListItemText.js.map +1 -1
- package/build/esm/ListItem/index.d.ts +0 -0
- package/build/esm/ListItem/index.js +0 -0
- package/build/esm/ListItem/index.js.map +1 -1
- package/build/esm/Menu/Menu.d.ts +6 -6
- package/build/esm/Menu/Menu.js +13 -7
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/animation.d.ts +0 -0
- package/build/esm/Menu/animation.js +0 -0
- package/build/esm/Menu/animation.js.map +1 -1
- package/build/esm/Menu/index.d.ts +0 -0
- package/build/esm/Menu/index.js +0 -0
- package/build/esm/Menu/index.js.map +1 -1
- package/build/esm/NavRail/NavRailItem.d.ts +15 -0
- package/build/esm/NavRail/NavRailItem.js +150 -0
- package/build/esm/NavRail/NavRailItem.js.map +1 -0
- package/build/esm/NavRail/index.d.ts +1 -0
- package/build/esm/NavRail/index.js +2 -0
- package/build/esm/NavRail/index.js.map +1 -0
- package/build/esm/NotchedOutline/NotchedOutline.d.ts +5 -5
- package/build/esm/NotchedOutline/NotchedOutline.js +4 -4
- package/build/esm/NotchedOutline/NotchedOutline.js.map +1 -1
- package/build/esm/NotchedOutline/context.d.ts +0 -0
- package/build/esm/NotchedOutline/context.js +0 -0
- package/build/esm/NotchedOutline/context.js.map +1 -1
- package/build/esm/NotchedOutline/index.d.ts +0 -0
- package/build/esm/NotchedOutline/index.js +0 -0
- package/build/esm/NotchedOutline/index.js.map +1 -1
- package/build/esm/NotchedOutline/styledComponents.d.ts +114 -28
- package/build/esm/NotchedOutline/styledComponents.js +3 -2
- package/build/esm/NotchedOutline/styledComponents.js.map +1 -1
- package/build/esm/Paper/Paper.d.ts +4 -4
- package/build/esm/Paper/Paper.js +6 -6
- package/build/esm/Paper/Paper.js.map +1 -1
- package/build/esm/Paper/index.d.ts +0 -0
- package/build/esm/Paper/index.js +0 -0
- package/build/esm/Paper/index.js.map +1 -1
- package/build/esm/ProgressSpinner/ProgressSpinner.d.ts +1 -1
- package/build/esm/ProgressSpinner/ProgressSpinner.js +14 -14
- package/build/esm/ProgressSpinner/ProgressSpinner.js.map +1 -1
- package/build/esm/ProgressSpinner/index.d.ts +0 -0
- package/build/esm/ProgressSpinner/index.js +0 -0
- package/build/esm/ProgressSpinner/index.js.map +1 -1
- package/build/esm/RadioButton/RadioButton.d.ts +0 -0
- package/build/esm/RadioButton/RadioButton.js +4 -2
- package/build/esm/RadioButton/RadioButton.js.map +1 -1
- package/build/esm/RadioButton/RadioButtonIcon.d.ts +3 -3
- package/build/esm/RadioButton/RadioButtonIcon.js +6 -5
- package/build/esm/RadioButton/RadioButtonIcon.js.map +1 -1
- package/build/esm/RadioButton/RadioGroup.d.ts +1 -1
- package/build/esm/RadioButton/RadioGroup.js +2 -1
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/index.d.ts +0 -0
- package/build/esm/RadioButton/index.js +0 -0
- package/build/esm/RadioButton/index.js.map +1 -1
- package/build/esm/Ripple/Ripple.d.ts +0 -0
- package/build/esm/Ripple/Ripple.js +0 -0
- package/build/esm/Ripple/Ripple.js.map +1 -1
- package/build/esm/Ripple/RippleBox.d.ts +1 -2
- package/build/esm/Ripple/RippleBox.js +7 -6
- package/build/esm/Ripple/RippleBox.js.map +1 -1
- package/build/esm/Ripple/constants.d.ts +0 -0
- package/build/esm/Ripple/constants.js +0 -0
- package/build/esm/Ripple/constants.js.map +1 -1
- package/build/esm/Ripple/index.d.ts +0 -0
- package/build/esm/Ripple/index.js +0 -0
- package/build/esm/Ripple/index.js.map +1 -1
- package/build/esm/Ripple/keyframes.d.ts +0 -0
- package/build/esm/Ripple/keyframes.js +0 -0
- package/build/esm/Ripple/keyframes.js.map +1 -1
- package/build/esm/Ripple/useRipple.d.ts +0 -0
- package/build/esm/Ripple/useRipple.js +2 -2
- package/build/esm/Ripple/useRipple.js.map +1 -1
- package/build/esm/Ripple/useRippleHandlers.d.ts +3 -3
- package/build/esm/Ripple/useRippleHandlers.js +2 -1
- package/build/esm/Ripple/useRippleHandlers.js.map +1 -1
- package/build/esm/Ripple/useRippleSurface.d.ts +5 -5
- package/build/esm/Ripple/useRippleSurface.js +64 -60
- package/build/esm/Ripple/useRippleSurface.js.map +1 -1
- package/build/esm/Select/Select.d.ts +6 -6
- package/build/esm/Select/Select.js +5 -5
- package/build/esm/Select/Select.js.map +1 -1
- package/build/esm/Select/SelectIcon.d.ts +3 -3
- package/build/esm/Select/SelectIcon.js +6 -5
- package/build/esm/Select/SelectIcon.js.map +1 -1
- package/build/esm/Select/context.d.ts +2 -2
- package/build/esm/Select/context.js +0 -0
- package/build/esm/Select/context.js.map +1 -1
- package/build/esm/Select/defaultRender.d.ts +2 -1
- package/build/esm/Select/defaultRender.js +0 -0
- package/build/esm/Select/defaultRender.js.map +1 -1
- package/build/esm/Select/index.d.ts +0 -0
- package/build/esm/Select/index.js +0 -0
- package/build/esm/Select/index.js.map +1 -1
- package/build/esm/Select/styledComponents.d.ts +9 -9
- package/build/esm/Select/styledComponents.js +8 -6
- package/build/esm/Select/styledComponents.js.map +1 -1
- package/build/esm/SelectItem/SelectItem.d.ts +1 -1
- package/build/esm/SelectItem/SelectItem.js +6 -5
- package/build/esm/SelectItem/SelectItem.js.map +1 -1
- package/build/esm/SelectItem/index.d.ts +0 -0
- package/build/esm/SelectItem/index.js +0 -0
- package/build/esm/SelectItem/index.js.map +1 -1
- package/build/esm/SelectionControl/SelectionControlLabel.d.ts +5 -5
- package/build/esm/SelectionControl/SelectionControlLabel.js +2 -2
- package/build/esm/SelectionControl/SelectionControlLabel.js.map +1 -1
- package/build/esm/SelectionControl/SelectionControlText.d.ts +4 -4
- package/build/esm/SelectionControl/SelectionControlText.js +4 -4
- package/build/esm/SelectionControl/SelectionControlText.js.map +1 -1
- package/build/esm/SelectionControl/index.d.ts +0 -0
- package/build/esm/SelectionControl/index.js +0 -0
- package/build/esm/SelectionControl/index.js.map +1 -1
- package/build/esm/Skeleton/DelayAppearance.d.ts +3 -3
- package/build/esm/Skeleton/DelayAppearance.js +2 -2
- package/build/esm/Skeleton/DelayAppearance.js.map +1 -1
- package/build/esm/Skeleton/Skeleton.d.ts +6 -6
- package/build/esm/Skeleton/Skeleton.js +4 -4
- package/build/esm/Skeleton/Skeleton.js.map +1 -1
- package/build/esm/Skeleton/animation.d.ts +0 -0
- package/build/esm/Skeleton/animation.js +0 -0
- package/build/esm/Skeleton/animation.js.map +1 -1
- package/build/esm/Skeleton/index.d.ts +0 -0
- package/build/esm/Skeleton/index.js +0 -0
- package/build/esm/Skeleton/index.js.map +1 -1
- package/build/esm/Snackbar/Snackbar.d.ts +3 -3
- package/build/esm/Snackbar/Snackbar.js +9 -9
- package/build/esm/Snackbar/Snackbar.js.map +1 -1
- package/build/esm/Snackbar/Stack.d.ts +2 -3
- package/build/esm/Snackbar/Stack.js +4 -3
- package/build/esm/Snackbar/Stack.js.map +1 -1
- package/build/esm/Snackbar/index.d.ts +0 -0
- package/build/esm/Snackbar/index.js +0 -0
- package/build/esm/Snackbar/index.js.map +1 -1
- package/build/esm/Snackbar/useSnackbarAnimation.d.ts +2 -2
- package/build/esm/Snackbar/useSnackbarAnimation.js +8 -7
- package/build/esm/Snackbar/useSnackbarAnimation.js.map +1 -1
- package/build/esm/Switch/Switch.d.ts +4 -5
- package/build/esm/Switch/Switch.js +6 -5
- package/build/esm/Switch/Switch.js.map +1 -1
- package/build/esm/Switch/index.d.ts +0 -0
- package/build/esm/Switch/index.js +0 -0
- package/build/esm/Switch/index.js.map +1 -1
- package/build/esm/Switch/styledComponents.d.ts +0 -0
- package/build/esm/Switch/styledComponents.js +8 -4
- package/build/esm/Switch/styledComponents.js.map +1 -1
- package/build/esm/Tab/Tab.d.ts +3 -3
- package/build/esm/Tab/Tab.js +8 -7
- package/build/esm/Tab/Tab.js.map +1 -1
- package/build/esm/Tab/TabList.d.ts +1 -1
- package/build/esm/Tab/TabList.js +4 -2
- package/build/esm/Tab/TabList.js.map +1 -1
- package/build/esm/Tab/TabPanel.d.ts +1 -1
- package/build/esm/Tab/TabPanel.js +4 -2
- package/build/esm/Tab/TabPanel.js.map +1 -1
- package/build/esm/Tab/TabPanels.d.ts +0 -0
- package/build/esm/Tab/TabPanels.js +0 -0
- package/build/esm/Tab/TabPanels.js.map +1 -1
- package/build/esm/Tab/Tabs.d.ts +0 -0
- package/build/esm/Tab/Tabs.js +0 -0
- package/build/esm/Tab/Tabs.js.map +1 -1
- package/build/esm/Tab/context.d.ts +0 -0
- package/build/esm/Tab/context.js +0 -0
- package/build/esm/Tab/context.js.map +1 -1
- package/build/esm/Tab/index.d.ts +0 -0
- package/build/esm/Tab/index.js +0 -0
- package/build/esm/Tab/index.js.map +1 -1
- package/build/esm/TabIndicator/TabIndicator.d.ts +1 -1
- package/build/esm/TabIndicator/TabIndicator.js +4 -2
- package/build/esm/TabIndicator/TabIndicator.js.map +1 -1
- package/build/esm/TabIndicator/context.d.ts +2 -2
- package/build/esm/TabIndicator/context.js +0 -0
- package/build/esm/TabIndicator/context.js.map +1 -1
- package/build/esm/TabIndicator/index.d.ts +0 -0
- package/build/esm/TabIndicator/index.js +0 -0
- package/build/esm/TabIndicator/index.js.map +1 -1
- package/build/esm/Table/Table.d.ts +1 -1
- package/build/esm/Table/Table.js +4 -3
- package/build/esm/Table/Table.js.map +1 -1
- package/build/esm/Table/TableBody.d.ts +1 -1
- package/build/esm/Table/TableBody.js +4 -3
- package/build/esm/Table/TableBody.js.map +1 -1
- package/build/esm/Table/TableCell.d.ts +1 -1
- package/build/esm/Table/TableCell.js +4 -3
- package/build/esm/Table/TableCell.js.map +1 -1
- package/build/esm/Table/TableHead.d.ts +1 -1
- package/build/esm/Table/TableHead.js +4 -3
- package/build/esm/Table/TableHead.js.map +1 -1
- package/build/esm/Table/TableRow.d.ts +1 -1
- package/build/esm/Table/TableRow.js +5 -4
- package/build/esm/Table/TableRow.js.map +1 -1
- package/build/esm/Table/context.d.ts +0 -0
- package/build/esm/Table/context.js +0 -0
- package/build/esm/Table/context.js.map +1 -1
- package/build/esm/Table/index.d.ts +0 -0
- package/build/esm/Table/index.js +0 -0
- package/build/esm/Table/index.js.map +1 -1
- package/build/esm/Text/LoremIpsum.d.ts +0 -0
- package/build/esm/Text/LoremIpsum.js +1 -1
- package/build/esm/Text/LoremIpsum.js.map +1 -1
- package/build/esm/Text/Text.d.ts +8 -4
- package/build/esm/Text/Text.js +7 -3
- package/build/esm/Text/Text.js.map +1 -1
- package/build/esm/Text/index.d.ts +0 -0
- package/build/esm/Text/index.js +0 -0
- package/build/esm/Text/index.js.map +1 -1
- package/build/esm/TextField/FilledContainer.d.ts +4 -4
- package/build/esm/TextField/FilledContainer.js +6 -6
- package/build/esm/TextField/FilledContainer.js.map +1 -1
- package/build/esm/TextField/HelperText.d.ts +5 -5
- package/build/esm/TextField/HelperText.js +5 -5
- package/build/esm/TextField/HelperText.js.map +1 -1
- package/build/esm/TextField/IconContainer.d.ts +2 -3
- package/build/esm/TextField/IconContainer.js +0 -1
- package/build/esm/TextField/IconContainer.js.map +1 -1
- package/build/esm/TextField/Input.d.ts +4 -4
- package/build/esm/TextField/Input.js +11 -9
- package/build/esm/TextField/Input.js.map +1 -1
- package/build/esm/TextField/OutlinedContainer.d.ts +4 -4
- package/build/esm/TextField/OutlinedContainer.js +5 -5
- package/build/esm/TextField/OutlinedContainer.js.map +1 -1
- package/build/esm/TextField/TextField.d.ts +5 -5
- package/build/esm/TextField/TextField.js +4 -4
- package/build/esm/TextField/TextField.js.map +1 -1
- package/build/esm/TextField/consts.d.ts +0 -0
- package/build/esm/TextField/consts.js +0 -0
- package/build/esm/TextField/consts.js.map +1 -1
- package/build/esm/TextField/index.d.ts +0 -0
- package/build/esm/TextField/index.js +0 -0
- package/build/esm/TextField/index.js.map +1 -1
- package/build/esm/ThemeExplorer/ColorPicker.d.ts +0 -0
- package/build/esm/ThemeExplorer/ColorPicker.js +4 -3
- package/build/esm/ThemeExplorer/ColorPicker.js.map +1 -1
- package/build/esm/ThemeExplorer/TextFieldColorPicker.d.ts +0 -0
- package/build/esm/ThemeExplorer/TextFieldColorPicker.js +4 -3
- package/build/esm/ThemeExplorer/TextFieldColorPicker.js.map +1 -1
- package/build/esm/ThemeExplorer/ThemeBuilder.d.ts +9 -0
- package/build/esm/ThemeExplorer/ThemeBuilder.js +244 -0
- package/build/esm/ThemeExplorer/ThemeBuilder.js.map +1 -0
- package/build/esm/ThemeExplorer/ThemeColors.d.ts +2 -2
- package/build/esm/ThemeExplorer/ThemeColors.js +1 -1
- package/build/esm/ThemeExplorer/ThemeColors.js.map +1 -1
- package/build/esm/ThemeExplorer/components.d.ts +6 -7
- package/build/esm/ThemeExplorer/components.js +24 -20
- package/build/esm/ThemeExplorer/components.js.map +1 -1
- package/build/esm/ThemeExplorer/index.d.ts +1 -0
- package/build/esm/ThemeExplorer/index.js +2 -0
- package/build/esm/ThemeExplorer/index.js.map +1 -0
- package/build/esm/ThemeExplorer/makeColorScheme.d.ts +0 -0
- package/build/esm/ThemeExplorer/makeColorScheme.js +0 -0
- package/build/esm/ThemeExplorer/makeColorScheme.js.map +1 -1
- package/build/esm/ThemeExplorer/useDeferredColor.d.ts +0 -0
- package/build/esm/ThemeExplorer/useDeferredColor.js +4 -5
- package/build/esm/ThemeExplorer/useDeferredColor.js.map +1 -1
- package/build/esm/ThemeExplorer/useLocalStorageCachedState.d.ts +1 -1
- package/build/esm/ThemeExplorer/useLocalStorageCachedState.js +1 -1
- package/build/esm/ThemeExplorer/useLocalStorageCachedState.js.map +1 -1
- package/build/esm/Tooltip/Tooltip.d.ts +3 -3
- package/build/esm/Tooltip/Tooltip.js +7 -9
- package/build/esm/Tooltip/Tooltip.js.map +1 -1
- package/build/esm/Tooltip/index.d.ts +0 -0
- package/build/esm/Tooltip/index.js +0 -0
- package/build/esm/Tooltip/index.js.map +1 -1
- package/build/esm/color.d.ts +2 -0
- package/build/esm/color.js +9 -4
- package/build/esm/color.js.map +1 -1
- package/build/esm/css.d.ts +0 -0
- package/build/esm/css.js +0 -0
- package/build/esm/css.js.map +1 -1
- package/build/esm/hooks/useAnimation.d.ts +0 -0
- package/build/esm/hooks/useAnimation.js +3 -3
- package/build/esm/hooks/useAnimation.js.map +1 -1
- package/build/esm/index.d.ts +2 -1
- package/build/esm/index.js +2 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/motion.d.ts +7 -0
- package/build/esm/motion.js +8 -0
- package/build/esm/motion.js.map +1 -0
- package/build/esm/theme/index.d.ts +0 -0
- package/build/esm/theme/index.js +0 -0
- package/build/esm/theme/index.js.map +1 -1
- package/build/esm/theme/theme.d.ts +114 -28
- package/build/esm/theme/theme.js +46 -38
- package/build/esm/theme/theme.js.map +1 -1
- package/build/esm/theme/typography-raleway.d.ts +0 -0
- package/build/esm/theme/typography-raleway.js +0 -0
- package/build/esm/theme/typography-raleway.js.map +1 -1
- package/build/esm/theme/typography-roboto.d.ts +0 -0
- package/build/esm/theme/typography-roboto.js +0 -0
- package/build/esm/theme/typography-roboto.js.map +1 -1
- package/build/esm/theme/useTheme.d.ts +557 -1
- package/build/esm/theme/useTheme.js +0 -0
- package/build/esm/theme/useTheme.js.map +1 -1
- package/build/tsconfig-build.tsbuildinfo +1 -0
- package/package.json +8 -8
- package/src/Alert/Alert.tsx +1 -1
- package/src/AppBar/AppBar.tsx +4 -3
- package/src/BottomSheet/BottomSheetSurface.tsx +5 -4
- package/src/Box/Box.tsx +6 -8
- package/src/Button/BaseButton.tsx +3 -11
- package/src/Button/Button.story.tsx +21 -4
- package/src/Button/Button.tsx +4 -4
- package/src/Button/ButtonGroup.tsx +1 -1
- package/src/Button/FilledButton.tsx +4 -9
- package/src/Button/SpinnerButton.story.tsx +1 -1
- package/src/CheckBox/CheckBox.story.tsx +7 -6
- package/src/CheckBox/CheckBox.tsx +6 -10
- package/src/CheckBox/CheckBoxIcon.tsx +5 -5
- package/src/Chip/ButtonChip.tsx +3 -3
- package/src/Chip/Chip.story.tsx +1 -1
- package/src/Chip/ChipBase.tsx +2 -2
- package/src/Chip/ChoiceChip.tsx +7 -7
- package/src/Combobox/Combobox.story.tsx +3 -3
- package/src/Combobox/Combobox.tsx +9 -10
- package/src/Dialog/DialogBackdrop.tsx +3 -3
- package/src/Dialog/DialogSurface.tsx +2 -4
- package/src/Dialog/useDialogAnimation.tsx +3 -4
- package/src/Divider/Divider.tsx +2 -2
- package/src/FloatingLabel/FloatingLabel.tsx +7 -6
- package/src/LineRipple/LineRipple.story.tsx +1 -1
- package/src/LineRipple/LineRipple.tsx +4 -4
- package/src/Link/Link.tsx +2 -5
- package/src/List/List.tsx +4 -4
- package/src/ListItem/ListItem.tsx +6 -6
- package/src/ListItem/ListItemText.tsx +6 -7
- package/src/Menu/Menu.tsx +5 -5
- package/src/NavRail/NavRail.story.tsx +190 -0
- package/src/NavRail/NavRailItem.tsx +176 -0
- package/src/NavRail/index.ts +1 -0
- package/src/NotchedOutline/NotchedOutline.tsx +4 -5
- package/src/NotchedOutline/styledComponents.ts +2 -1
- package/src/Paper/Paper.story.tsx +3 -3
- package/src/Paper/Paper.tsx +3 -3
- package/src/ProgressSpinner/ProgressSpinner.tsx +9 -9
- package/src/RadioButton/RadioButton.story.tsx +2 -2
- package/src/RadioButton/RadioButton.tsx +1 -1
- package/src/RadioButton/RadioButtonIcon.tsx +4 -5
- package/src/Ripple/Ripple.story.tsx +1 -1
- package/src/Ripple/RippleBox.tsx +1 -2
- package/src/Ripple/useRippleHandlers.ts +3 -3
- package/src/Ripple/useRippleSurface.ts +77 -61
- package/src/Select/Select.tsx +11 -6
- package/src/Select/SelectIcon.tsx +3 -4
- package/src/Select/context.ts +2 -1
- package/src/Select/defaultRender.ts +2 -1
- package/src/Select/styledComponents.tsx +13 -11
- package/src/SelectionControl/SelectionControlLabel.tsx +4 -8
- package/src/SelectionControl/SelectionControlText.tsx +3 -3
- package/src/Skeleton/DelayAppearance.tsx +2 -2
- package/src/Skeleton/Skeleton.story.tsx +2 -2
- package/src/Skeleton/Skeleton.tsx +6 -6
- package/src/Snackbar/Snackbar.tsx +6 -6
- package/src/Snackbar/Stack.tsx +6 -9
- package/src/Snackbar/useSnackbarAnimation.ts +4 -3
- package/src/Switch/Switch.tsx +6 -10
- package/src/Switch/styledComponents.tsx +2 -2
- package/src/Tab/Tab.tsx +3 -7
- package/src/TabIndicator/TabIndicator.tsx +2 -1
- package/src/TabIndicator/context.ts +2 -1
- package/src/Table/TableRow.tsx +1 -1
- package/src/Text/LoremIpsum.tsx +1 -1
- package/src/Text/Text.story.tsx +42 -7
- package/src/Text/Text.tsx +25 -5
- package/src/TextField/FilledContainer.tsx +3 -3
- package/src/TextField/HelperText.tsx +5 -5
- package/src/TextField/IconContainer.tsx +2 -3
- package/src/TextField/Input.tsx +5 -4
- package/src/TextField/OutlinedContainer.tsx +3 -3
- package/src/TextField/TextField.tsx +4 -4
- package/src/ThemeExplorer/ThemeBuilder.story.tsx +1 -159
- package/src/ThemeExplorer/ThemeBuilder.tsx +198 -0
- package/src/ThemeExplorer/ThemeColors.tsx +1 -1
- package/src/ThemeExplorer/components.tsx +24 -16
- package/src/ThemeExplorer/index.ts +1 -0
- package/src/ThemeExplorer/useDeferredColor.tsx +2 -3
- package/src/ThemeExplorer/useLocalStorageCachedState.ts +2 -2
- package/src/Tooltip/Tooltip.story.tsx +2 -2
- package/src/Tooltip/Tooltip.tsx +9 -11
- package/src/color.ts +26 -5
- package/src/index.ts +2 -1
- package/src/motion.ts +7 -0
- package/src/theme/theme.ts +51 -37
- package/build/esm/ColorMode/ColorModeProvider.d.ts +0 -7
- package/build/esm/ColorMode/ColorModeProvider.js +0 -92
- package/build/esm/ColorMode/ColorModeProvider.js.map +0 -1
- package/build/esm/ColorMode/color-mode.d.ts +0 -8
- package/build/esm/ColorMode/color-mode.js +0 -11
- package/build/esm/ColorMode/color-mode.js.map +0 -1
- package/build/esm/ColorMode/color-vars.d.ts +0 -4
- package/build/esm/ColorMode/color-vars.js +0 -58
- package/build/esm/ColorMode/color-vars.js.map +0 -1
- package/build/esm/ColorMode/constants.d.ts +0 -3
- package/build/esm/ColorMode/constants.js +0 -5
- package/build/esm/ColorMode/constants.js.map +0 -1
- package/build/esm/ColorMode/index.d.ts +0 -4
- package/build/esm/ColorMode/index.js +0 -5
- package/build/esm/ColorMode/index.js.map +0 -1
- package/build/esm/ListItem/context.d.ts +0 -7
- package/build/esm/ListItem/context.js +0 -10
- package/build/esm/ListItem/context.js.map +0 -1
- package/build/tsconfig.tsbuildinfo +0 -1
- package/src/ColorMode/ColorModeProvider.tsx +0 -97
- package/src/ColorMode/color-mode.ts +0 -20
- package/src/ColorMode/color-vars.ts +0 -56
- package/src/ColorMode/constants.ts +0 -5
- package/src/ColorMode/index.ts +0 -4
- package/src/ColorMode/tests/color-vars.test.ts +0 -9
- package/src/ThemeExplorer/ThemeExplorer.story.tsx +0 -43
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"RippleBox.js","names":["forwardRef","useRippleSurface","Box","RippleBox","props","forwardedRef","as","__css","onKeyDown","onPointerDown","baseOpacity","hoverOpacity","focusOpacity","pressedOpacity","rippleColor","center","disabled","rippleEnabled","style","otherProps","rippleCss","rippleProps"],"sources":["../../../src/Ripple/RippleBox.tsx"],"sourcesContent":["import type { HTMLAttributes } from 'react';\nimport { forwardRef } from 'react';\n\nimport type { UseRippleSurfaceOptions } from './useRippleSurface';\nimport { useRippleSurface } from './useRippleSurface';\nimport type { BoxProps } from '../Box';\nimport { Box } from '../Box';\n\nexport type RippleBoxProps<\n H extends HTMLElement = HTMLDivElement,\n Attr = HTMLAttributes<H>\n> = BoxProps<H, Attr> & UseRippleSurfaceOptions<H>;\n\nexport const RippleBox: <\n Props = RippleBoxProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>>\n>(\n props: Props\n) => JSX.Element = forwardRef<HTMLDivElement, RippleBoxProps>(\n function RippleBox(props, forwardedRef) {\n const {\n as = 'div',\n __css,\n // Cherry picking the ripple props to prevent it from falling down to\n // the Box component\n onKeyDown, // eslint-disable-line @typescript-eslint/no-unused-vars\n onPointerDown, // eslint-disable-line @typescript-eslint/no-unused-vars\n baseOpacity, // eslint-disable-line @typescript-eslint/no-unused-vars\n hoverOpacity, // eslint-disable-line @typescript-eslint/no-unused-vars\n focusOpacity, // eslint-disable-line @typescript-eslint/no-unused-vars\n pressedOpacity, // eslint-disable-line @typescript-eslint/no-unused-vars\n rippleColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n center, // eslint-disable-line @typescript-eslint/no-unused-vars\n disabled, // eslint-disable-line @typescript-eslint/no-unused-vars\n rippleEnabled, // eslint-disable-line @typescript-eslint/no-unused-vars\n style, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...otherProps\n } = props;\n\n const { __css: rippleCss, ...rippleProps } = useRippleSurface(props);\n\n return (\n <Box\n as={as}\n ref={forwardedRef}\n __css={{ ...rippleCss, ...__css }}\n {...{ disabled }}\n {...otherProps}\n {...rippleProps}\n />\n );\n }\n) as any;\n"],"mappings":";;;;AACA,SAASA,UAAT,QAA2B,OAA3B;AAGA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA,SAASC,GAAT,QAAoB,QAApB;;AAOA,OAAO,IAAMC,SAIG,gBAAGH,UAAU,CAC3B,SAASG,SAAT,CAAmBC,KAAnB,EAA0BC,YAA1B,EAAwC;EACtC,gBAiBID,KAjBJ,CACEE,EADF;EAAA,IACEA,EADF,0BACO,KADP;EAAA,IAEEC,KAFF,GAiBIH,KAjBJ,CAEEG,KAFF;EAAA,IAKEC,SALF,GAiBIJ,KAjBJ,CAKEI,SALF;EAAA,IAMEC,aANF,GAiBIL,KAjBJ,CAMEK,aANF;EAAA,IAOEC,WAPF,GAiBIN,KAjBJ,CAOEM,WAPF;EAAA,IAQEC,YARF,GAiBIP,KAjBJ,CAQEO,YARF;EAAA,IASEC,YATF,GAiBIR,KAjBJ,CASEQ,YATF;EAAA,IAUEC,cAVF,GAiBIT,KAjBJ,CAUES,cAVF;EAAA,IAWEC,WAXF,GAiBIV,KAjBJ,CAWEU,WAXF;EAAA,IAYEC,MAZF,GAiBIX,KAjBJ,CAYEW,MAZF;EAAA,IAaEC,QAbF,GAiBIZ,KAjBJ,CAaEY,QAbF;EAAA,IAcEC,aAdF,GAiBIb,KAjBJ,CAcEa,aAdF;EAAA,IAeEC,KAfF,GAiBId,KAjBJ,CAeEc,KAfF;EAAA,IAgBKC,UAhBL,4BAiBIf,KAjBJ;;EAmBA,wBAA6CH,gBAAgB,CAACG,KAAD,CAA7D;EAAA,IAAegB,SAAf,qBAAQb,KAAR;EAAA,IAA6Bc,WAA7B;;EAEA,oBACE,KAAC,GAAD;IACE,EAAE,EAAEf,EADN;IAEE,GAAG,EAAED,YAFP;IAGE,KAAK,wBAAOe,SAAP,GAAqBb,KAArB,CAHP;IAIQS,QAAQ,EAARA;EAJR,GAKMG,UALN,GAMME,WANN,EADF;AAUD,CAjC0B,CAJtB"}
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"constants.js","names":["hash","RIPPLE_BACKGROUND_COLOR","RIPPLE_TRANSLATE_START","RIPPLE_TRANSLATE_END","RIPPLE_SCALE_END","RIPPLE_OPACITY_END","RIPPLE_SIZE","RIPPLE_POSITION"],"sources":["../../../src/Ripple/constants.ts"],"sourcesContent":["import hash from '@emotion/hash';\n\nexport const RIPPLE_BACKGROUND_COLOR = `--css-${hash(\n 'basic-ui-ripple-fg-bg-color'\n)}`;\nexport const RIPPLE_TRANSLATE_START = `--css-${hash(\n 'basic-ui-ripple-fg-translate-start'\n)}`;\nexport const RIPPLE_TRANSLATE_END = `--css-${hash(\n 'basic-ui-ripple-fg-translate-end'\n)}`;\nexport const RIPPLE_SCALE_END = `--css-${hash('basic-ui-ripple-fg-scale')}`;\nexport const RIPPLE_OPACITY_END = `--css-${hash('basic-ui-ripple-fg-opacity')}`;\nexport const RIPPLE_SIZE = `--css-${hash('basic-ui-ripple-fg-size')}`;\nexport const RIPPLE_POSITION = `--css-${hash('basic-ui-ripple-fg-position')}`;\n"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,eAAjB;AAEA,OAAO,IAAMC,uBAAuB,mBAAYD,IAAI,CAClD,6BADkD,CAAhB,CAA7B;AAGP,OAAO,IAAME,sBAAsB,mBAAYF,IAAI,CACjD,oCADiD,CAAhB,CAA5B;AAGP,OAAO,IAAMG,oBAAoB,mBAAYH,IAAI,CAC/C,kCAD+C,CAAhB,CAA1B;AAGP,OAAO,IAAMI,gBAAgB,mBAAYJ,IAAI,CAAC,0BAAD,CAAhB,CAAtB;AACP,OAAO,IAAMK,kBAAkB,mBAAYL,IAAI,CAAC,4BAAD,CAAhB,CAAxB;AACP,OAAO,IAAMM,WAAW,mBAAYN,IAAI,CAAC,yBAAD,CAAhB,CAAjB;AACP,OAAO,IAAMO,eAAe,mBAAYP,IAAI,CAAC,6BAAD,CAAhB,CAArB"}
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/Ripple/index.ts"],"sourcesContent":["export * from './Ripple';\nexport * from './RippleBox';\nexport * from './useRipple';\nexport * from './useRippleHandlers';\nexport * from './useRippleSurface';\n"],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,aAAd;AACA,cAAc,aAAd;AACA,cAAc,qBAAd;AACA,cAAc,oBAAd"}
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"keyframes.js","names":["keyframes","RIPPLE_TRANSLATE_START","RIPPLE_TRANSLATE_END","RIPPLE_OPACITY_END","RIPPLE_SCALE_END","radiusIn","from","transform","to","opacityIn","opacity","opacityOut"],"sources":["../../../src/Ripple/keyframes.ts"],"sourcesContent":["import { keyframes } from '@emotion/react';\nimport type { Keyframes } from '@emotion/serialize';\n\nimport {\n RIPPLE_TRANSLATE_START,\n RIPPLE_TRANSLATE_END,\n RIPPLE_OPACITY_END,\n RIPPLE_SCALE_END,\n} from './constants';\n\nexport const radiusIn: Keyframes = keyframes({\n from: {\n transform: `translate(var(${RIPPLE_TRANSLATE_START}, 0)) scale(1)`,\n },\n to: {\n transform: `translate(var(${RIPPLE_TRANSLATE_END}, 0)) scale(var(${RIPPLE_SCALE_END}, 1))`,\n },\n});\n\nexport const opacityIn: Keyframes = keyframes({\n from: {\n opacity: '0',\n },\n to: {\n opacity: `var(${RIPPLE_OPACITY_END})`,\n },\n});\n\nexport const opacityOut: Keyframes = keyframes({\n from: {\n opacity: `var(${RIPPLE_OPACITY_END})`,\n },\n to: {\n opacity: '0',\n },\n});\n"],"mappings":"AAAA,SAASA,SAAT,QAA0B,gBAA1B;AAGA,SACEC,sBADF,EAEEC,oBAFF,EAGEC,kBAHF,EAIEC,gBAJF,QAKO,aALP;AAOA,OAAO,IAAMC,QAAmB,GAAGL,SAAS,CAAC;EAC3CM,IAAI,EAAE;IACJC,SAAS,0BAAmBN,sBAAnB;EADL,CADqC;EAI3CO,EAAE,EAAE;IACFD,SAAS,0BAAmBL,oBAAnB,6BAA0DE,gBAA1D;EADP;AAJuC,CAAD,CAArC;AASP,OAAO,IAAMK,SAAoB,GAAGT,SAAS,CAAC;EAC5CM,IAAI,EAAE;IACJI,OAAO,EAAE;EADL,CADsC;EAI5CF,EAAE,EAAE;IACFE,OAAO,gBAASP,kBAAT;EADL;AAJwC,CAAD,CAAtC;AASP,OAAO,IAAMQ,UAAqB,GAAGX,SAAS,CAAC;EAC7CM,IAAI,EAAE;IACJI,OAAO,gBAASP,kBAAT;EADH,CADuC;EAI7CK,EAAE,EAAE;IACFE,OAAO,EAAE;EADP;AAJyC,CAAD,CAAvC"}
|
|
File without changes
|
|
@@ -47,9 +47,9 @@ function calculateRipplePosition(rect, clientX, clientY) {
|
|
|
47
47
|
x: clientX - rect.left,
|
|
48
48
|
y: clientY - rect.top
|
|
49
49
|
};
|
|
50
|
-
return _extends({
|
|
50
|
+
return _extends(_extends({
|
|
51
51
|
state: 'entering'
|
|
52
|
-
}, rippleStart, getScale(rect));
|
|
52
|
+
}, rippleStart), getScale(rect));
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export var useRipple = function useRipple(opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Ripple/useRipple.ts"],"names":["useState","useRef","useEffect","radiusIn","opacityIn","opacityOut","RIPPLE_TRANSLATE_START","RIPPLE_TRANSLATE_END","RIPPLE_OPACITY_END","RIPPLE_SCALE_END","RIPPLE_SIZE","RIPPLE_BACKGROUND_COLOR","RIPPLE_POSITION","defaultRipple","x","y","size","scale","centerX","centerY","getBoundedRadius","rect","padding","hypotenuse","Math","sqrt","pow","width","height","getScale","maxDim","max","initialOriginScale","maxRadius","initialSize","floor","calculateRipplePosition","clientX","clientY","center","rippleStart","left","top","state","useRipple","opts","opacity","backgroundColor","enterDuration","leaveDuration","rippleState","ripple","setRipple","leavingTimeout","enteringTimeout","restartTimeout","shouldLeave","current","cancelAnimationFrame","clearTimeout","setLeft","setLeaving","window","setTimeout","setEntered","deactivate","activate","requestAnimationFrame","animation","undefined","style"],"mappings":";;;AAAA,SAASA,QAAT,EAAmBC,MAAnB,EAA2BC,SAA3B,Q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ADtB,kCAEFJ,eAFE,YAEmB,CAACuC,MAAM,CAACnC,IAAR,GAAe,CAFlC,kCAGFL,uBAHE,EAGwBoC,eAHxB,2BAIFzC,sBAJE,YAI0B6C,MAAM,CAACrC,CAJjC,iBAIyCqC,MAAM,CAACpC,CAJhD,kCAKFR,oBALE,YAKwB4C,MAAM,CAACjC,OAL/B,iBAK6CiC,MAAM,CAAChC,OALpD,kCAMFX,kBANE,EAMmBsC,OANnB,2BAOFrC,gBAPE,YAOoB0C,MAAM,CAAClC,KAP3B,WAAL;AASA;AAbJ;;AAgBA,SAAO;AACLiD,IAAAA,QAAQ,EAARA,QADK;AAELD,IAAAA,UAAU,EAAVA,UAFK;AAGLK,IAAAA,KAAK,EAALA,KAHK;AAILF,IAAAA,SAAS,EAATA,SAJK,CAKL;;AALK,GAAP;AAOD,CA5HM","sourcesContent":["import { useState, useRef, useEffect } from 'react';\n\nimport { radiusIn, opacityIn, opacityOut } from './keyframes';\nimport {\n RIPPLE_TRANSLATE_START,\n RIPPLE_TRANSLATE_END,\n RIPPLE_OPACITY_END,\n RIPPLE_SCALE_END,\n RIPPLE_SIZE,\n RIPPLE_BACKGROUND_COLOR,\n RIPPLE_POSITION,\n} from './constants';\n\nconst defaultRipple = {\n x: 0,\n y: 0,\n size: 0,\n scale: 0,\n centerX: 0,\n centerY: 0,\n};\n\n// Surface diameter is treated differently for unbounded vs. bounded ripples.\n// Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately\n// to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically\n// square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter\n// (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via\n// `overflow: hidden`.\nconst getBoundedRadius = (rect: ClientRect, padding: number) => {\n const hypotenuse = Math.sqrt(\n Math.pow(rect.width, 2) + Math.pow(rect.height, 2)\n );\n return hypotenuse + padding;\n};\n\nfunction getScale(rect: ClientRect) {\n const maxDim = Math.max(rect.height, rect.width);\n const padding = 10;\n const initialOriginScale = 0.6;\n const maxRadius = getBoundedRadius(rect, padding);\n\n // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform\n const initialSize = Math.floor(maxDim * initialOriginScale);\n\n return {\n size: initialSize,\n scale: maxRadius / initialSize,\n centerX: rect.width / 2,\n centerY: rect.height / 2,\n };\n}\n\nfunction calculateRipplePosition(\n rect: ClientRect,\n clientX: number,\n clientY: number,\n center = false\n) {\n const rippleStart = center\n ? {\n x: rect.width / 2,\n y: rect.height / 2,\n }\n : {\n x: clientX - rect.left,\n y: clientY - rect.top,\n };\n\n return {\n state: 'entering' as const,\n ...rippleStart,\n ...getScale(rect),\n };\n}\n\nexport interface RippleOptions {\n opacity: number;\n backgroundColor: string;\n enterDuration?: number;\n leaveDuration?: number;\n center?: boolean;\n disabled?: boolean;\n}\n\nexport const useRipple = (opts: RippleOptions) => {\n const {\n opacity,\n backgroundColor,\n enterDuration = 225,\n leaveDuration = 150,\n } = opts;\n\n // rippleState must be a ref, because it accesses the current value\n // inside closures... if we use state, it's gonna recapture\n // the state variable and won't work correctly\n const rippleState = useRef(\n 'left' as 'entering' | 'entered' | 'leaving' | 'left' | 'restart'\n );\n const [ripple, setRipple] = useState(defaultRipple);\n const leavingTimeout = useRef<number>();\n const enteringTimeout = useRef<number>();\n const restartTimeout = useRef<number>();\n\n const shouldLeave = useRef(false);\n\n // clear timeouts to avoid setting state on unmounted component\n useEffect(() => {\n return () => {\n restartTimeout.current && cancelAnimationFrame(restartTimeout.current);\n clearTimeout(enteringTimeout.current);\n clearTimeout(leavingTimeout.current);\n };\n }, []);\n\n // State handling\n const setLeft = () => {\n rippleState.current = 'left';\n setRipple({ ...defaultRipple });\n };\n\n const setLeaving = () => {\n clearTimeout(enteringTimeout.current);\n rippleState.current = 'leaving';\n setRipple((ripple) => ({\n ...ripple,\n }));\n\n leavingTimeout.current = window.setTimeout(setLeft, leaveDuration);\n };\n\n const setEntered = () => {\n rippleState.current = 'entered';\n setRipple((ripple) => ({\n ...ripple,\n }));\n\n if (shouldLeave.current) {\n setLeaving();\n }\n };\n\n const deactivate = () => {\n shouldLeave.current = true;\n if (rippleState.current === 'entered') {\n setLeaving();\n }\n };\n\n const activate = (\n rect: ClientRect,\n clientX: number,\n clientY: number,\n center = false\n ) => {\n clearTimeout(leavingTimeout.current);\n clearTimeout(enteringTimeout.current);\n shouldLeave.current = false;\n\n rippleState.current = 'restart';\n setRipple({ ...defaultRipple });\n restartTimeout.current = requestAnimationFrame(() => {\n rippleState.current = 'entering';\n setRipple(calculateRipplePosition(rect, clientX, clientY, center));\n\n enteringTimeout.current = window.setTimeout(setEntered, enterDuration);\n });\n };\n\n // Styling\n let animation: string | undefined = undefined;\n switch (rippleState.current) {\n case 'entering':\n case 'entered':\n animation =\n `${radiusIn} ${enterDuration}ms forwards,` +\n `${opacityIn} ${enterDuration / 3}ms forwards`;\n break;\n case 'leaving':\n animation =\n `${radiusIn} ${enterDuration}ms forwards,` +\n `${opacityOut} ${leaveDuration}ms forwards`;\n break;\n }\n\n let style = {};\n switch (rippleState.current) {\n case 'entering':\n case 'entered':\n case 'leaving':\n style = {\n [RIPPLE_SIZE]: `${ripple.size}px`,\n [RIPPLE_POSITION]: `${-ripple.size / 2}px`,\n [RIPPLE_BACKGROUND_COLOR]: backgroundColor,\n [RIPPLE_TRANSLATE_START]: `${ripple.x}px, ${ripple.y}px`,\n [RIPPLE_TRANSLATE_END]: `${ripple.centerX}px, ${ripple.centerY}px`,\n [RIPPLE_OPACITY_END]: opacity,\n [RIPPLE_SCALE_END]: `${ripple.scale}`,\n };\n break;\n }\n\n return {\n activate,\n deactivate,\n style,\n animation,\n // key: counter,\n };\n};\n"],"file":"useRipple.js"}
|
|
1
|
+
{"version":3,"file":"useRipple.js","names":["useState","useRef","useEffect","radiusIn","opacityIn","opacityOut","RIPPLE_TRANSLATE_START","RIPPLE_TRANSLATE_END","RIPPLE_OPACITY_END","RIPPLE_SCALE_END","RIPPLE_SIZE","RIPPLE_BACKGROUND_COLOR","RIPPLE_POSITION","defaultRipple","x","y","size","scale","centerX","centerY","getBoundedRadius","rect","padding","hypotenuse","Math","sqrt","pow","width","height","getScale","maxDim","max","initialOriginScale","maxRadius","initialSize","floor","calculateRipplePosition","clientX","clientY","center","rippleStart","left","top","state","useRipple","opts","opacity","backgroundColor","enterDuration","leaveDuration","rippleState","ripple","setRipple","leavingTimeout","enteringTimeout","restartTimeout","shouldLeave","current","cancelAnimationFrame","clearTimeout","setLeft","setLeaving","window","setTimeout","setEntered","deactivate","activate","requestAnimationFrame","animation","undefined","style"],"sources":["../../../src/Ripple/useRipple.ts"],"sourcesContent":["import { useState, useRef, useEffect } from 'react';\n\nimport { radiusIn, opacityIn, opacityOut } from './keyframes';\nimport {\n RIPPLE_TRANSLATE_START,\n RIPPLE_TRANSLATE_END,\n RIPPLE_OPACITY_END,\n RIPPLE_SCALE_END,\n RIPPLE_SIZE,\n RIPPLE_BACKGROUND_COLOR,\n RIPPLE_POSITION,\n} from './constants';\n\nconst defaultRipple = {\n x: 0,\n y: 0,\n size: 0,\n scale: 0,\n centerX: 0,\n centerY: 0,\n};\n\n// Surface diameter is treated differently for unbounded vs. bounded ripples.\n// Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately\n// to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically\n// square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter\n// (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via\n// `overflow: hidden`.\nconst getBoundedRadius = (rect: ClientRect, padding: number) => {\n const hypotenuse = Math.sqrt(\n Math.pow(rect.width, 2) + Math.pow(rect.height, 2)\n );\n return hypotenuse + padding;\n};\n\nfunction getScale(rect: ClientRect) {\n const maxDim = Math.max(rect.height, rect.width);\n const padding = 10;\n const initialOriginScale = 0.6;\n const maxRadius = getBoundedRadius(rect, padding);\n\n // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform\n const initialSize = Math.floor(maxDim * initialOriginScale);\n\n return {\n size: initialSize,\n scale: maxRadius / initialSize,\n centerX: rect.width / 2,\n centerY: rect.height / 2,\n };\n}\n\nfunction calculateRipplePosition(\n rect: ClientRect,\n clientX: number,\n clientY: number,\n center = false\n) {\n const rippleStart = center\n ? {\n x: rect.width / 2,\n y: rect.height / 2,\n }\n : {\n x: clientX - rect.left,\n y: clientY - rect.top,\n };\n\n return {\n state: 'entering' as const,\n ...rippleStart,\n ...getScale(rect),\n };\n}\n\nexport interface RippleOptions {\n opacity: number;\n backgroundColor: string;\n enterDuration?: number;\n leaveDuration?: number;\n center?: boolean;\n disabled?: boolean;\n}\n\nexport const useRipple = (opts: RippleOptions) => {\n const {\n opacity,\n backgroundColor,\n enterDuration = 225,\n leaveDuration = 150,\n } = opts;\n\n // rippleState must be a ref, because it accesses the current value\n // inside closures... if we use state, it's gonna recapture\n // the state variable and won't work correctly\n const rippleState = useRef(\n 'left' as 'entering' | 'entered' | 'leaving' | 'left' | 'restart'\n );\n const [ripple, setRipple] = useState(defaultRipple);\n const leavingTimeout = useRef<number>();\n const enteringTimeout = useRef<number>();\n const restartTimeout = useRef<number>();\n\n const shouldLeave = useRef(false);\n\n // clear timeouts to avoid setting state on unmounted component\n useEffect(() => {\n return () => {\n restartTimeout.current && cancelAnimationFrame(restartTimeout.current);\n clearTimeout(enteringTimeout.current);\n clearTimeout(leavingTimeout.current);\n };\n }, []);\n\n // State handling\n const setLeft = () => {\n rippleState.current = 'left';\n setRipple({ ...defaultRipple });\n };\n\n const setLeaving = () => {\n clearTimeout(enteringTimeout.current);\n rippleState.current = 'leaving';\n setRipple((ripple) => ({\n ...ripple,\n }));\n\n leavingTimeout.current = window.setTimeout(setLeft, leaveDuration);\n };\n\n const setEntered = () => {\n rippleState.current = 'entered';\n setRipple((ripple) => ({\n ...ripple,\n }));\n\n if (shouldLeave.current) {\n setLeaving();\n }\n };\n\n const deactivate = () => {\n shouldLeave.current = true;\n if (rippleState.current === 'entered') {\n setLeaving();\n }\n };\n\n const activate = (\n rect: ClientRect,\n clientX: number,\n clientY: number,\n center = false\n ) => {\n clearTimeout(leavingTimeout.current);\n clearTimeout(enteringTimeout.current);\n shouldLeave.current = false;\n\n rippleState.current = 'restart';\n setRipple({ ...defaultRipple });\n restartTimeout.current = requestAnimationFrame(() => {\n rippleState.current = 'entering';\n setRipple(calculateRipplePosition(rect, clientX, clientY, center));\n\n enteringTimeout.current = window.setTimeout(setEntered, enterDuration);\n });\n };\n\n // Styling\n let animation: string | undefined = undefined;\n switch (rippleState.current) {\n case 'entering':\n case 'entered':\n animation =\n `${radiusIn} ${enterDuration}ms forwards,` +\n `${opacityIn} ${enterDuration / 3}ms forwards`;\n break;\n case 'leaving':\n animation =\n `${radiusIn} ${enterDuration}ms forwards,` +\n `${opacityOut} ${leaveDuration}ms forwards`;\n break;\n }\n\n let style = {};\n switch (rippleState.current) {\n case 'entering':\n case 'entered':\n case 'leaving':\n style = {\n [RIPPLE_SIZE]: `${ripple.size}px`,\n [RIPPLE_POSITION]: `${-ripple.size / 2}px`,\n [RIPPLE_BACKGROUND_COLOR]: backgroundColor,\n [RIPPLE_TRANSLATE_START]: `${ripple.x}px, ${ripple.y}px`,\n [RIPPLE_TRANSLATE_END]: `${ripple.centerX}px, ${ripple.centerY}px`,\n [RIPPLE_OPACITY_END]: opacity,\n [RIPPLE_SCALE_END]: `${ripple.scale}`,\n };\n break;\n }\n\n return {\n activate,\n deactivate,\n style,\n animation,\n // key: counter,\n };\n};\n"],"mappings":";;;AAAA,SAASA,QAAT,EAAmBC,MAAnB,EAA2BC,SAA3B,QAA4C,OAA5C;AAEA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,UAA9B,QAAgD,aAAhD;AACA,SACEC,sBADF,EAEEC,oBAFF,EAGEC,kBAHF,EAIEC,gBAJF,EAKEC,WALF,EAMEC,uBANF,EAOEC,eAPF,QAQO,aARP;AAUA,IAAMC,aAAa,GAAG;EACpBC,CAAC,EAAE,CADiB;EAEp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vent } from 'react';
|
|
2
2
|
import type { RippleOptions } from './useRipple';
|
|
3
3
|
export declare function useRippleHandlers<T extends HTMLElement>(opts: RippleOptions): {
|
|
4
4
|
style: {};
|
|
5
5
|
animation: string | undefined;
|
|
6
|
-
handleKeyDown: (e:
|
|
7
|
-
handlePointerDown: (e:
|
|
6
|
+
handleKeyDown: (e: ReactKeyboardEvent<T>) => void;
|
|
7
|
+
handlePointerDown: (e: PointerEvent<T>) => void;
|
|
8
8
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["activate", "deactivate"];
|
|
3
4
|
import { useRef } from 'react';
|
|
4
5
|
import { useRipple } from './useRipple';
|
|
5
6
|
|
|
@@ -11,7 +12,7 @@ export function useRippleHandlers(opts) {
|
|
|
11
12
|
var _useRipple = useRipple(opts),
|
|
12
13
|
activate = _useRipple.activate,
|
|
13
14
|
deactivate = _useRipple.deactivate,
|
|
14
|
-
rest = _objectWithoutProperties(_useRipple,
|
|
15
|
+
rest = _objectWithoutProperties(_useRipple, _excluded); // Pointer activation
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
var handlePointerUp = function handlePointerUp() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useRippleHandlers.js","names":["useRef","useRipple","disabledHandler","useRippleHandlers","opts","activate","deactivate","rest","handlePointerUp","window","removeEventListener","handlePointerDown","e","rect","currentTarget","getBoundingClientRect","clientX","clientY","center","addEventListener","keyReleased","handleKeyUp","key","current","handleKeyDown","disabled"],"sources":["../../../src/Ripple/useRippleHandlers.ts"],"sourcesContent":["import type { KeyboardEvent as ReactKeyboardEvent, PointerEvent } from 'react';\nimport { useRef } from 'react';\n\nimport type { RippleOptions } from './useRipple';\nimport { useRipple } from './useRipple';\n\nconst disabledHandler = () => {\n /* When disabled, we don't wanna handle neither keyDown, nor pointerDown */\n};\n\nexport function useRippleHandlers<T extends HTMLElement>(opts: RippleOptions) {\n const { activate, deactivate, ...rest } = useRipple(opts);\n\n // Pointer activation\n const handlePointerUp = () => {\n window.removeEventListener('pointerup', handlePointerUp);\n window.removeEventListener('pointercancel', handlePointerUp);\n deactivate();\n };\n\n const handlePointerDown = (e: PointerEvent<T>) => {\n const rect = e.currentTarget.getBoundingClientRect();\n activate(rect, e.clientX, e.clientY, opts.center);\n window.addEventListener('pointerup', handlePointerUp);\n window.addEventListener('pointercancel', handlePointerUp);\n };\n\n // Keyboard activation\n const keyReleased = useRef(true);\n const handleKeyUp = (e: KeyboardEvent) => {\n if (e.key !== ' ') {\n return;\n }\n window.removeEventListener('keyup', handleKeyUp);\n keyReleased.current = true;\n deactivate();\n };\n\n const handleKeyDown = (e: ReactKeyboardEvent<T>) => {\n if (e.key !== ' ' || !keyReleased.current) {\n return;\n }\n const rect = e.currentTarget.getBoundingClientRect();\n keyReleased.current = false;\n activate(rect, 0, 0, true);\n window.addEventListener('keyup', handleKeyUp);\n };\n\n return {\n handleKeyDown: opts.disabled ? disabledHandler : handleKeyDown,\n handlePointerDown: opts.disabled ? disabledHandler : handlePointerDown,\n ...rest,\n };\n}\n"],"mappings":";;;AACA,SAASA,MAAT,QAAuB,OAAvB;AAGA,SAASC,SAAT,QAA0B,aAA1B;;AAEA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,GAAM;EAC5B;AACD,CAFD;;AAIA,OAAO,SAASC,iBAAT,CAAkDC,IAAlD,EAAuE;EAC5E,iBAA0CH,SAAS,CAACG,IAAD,CAAnD;EAAA,IAAQC,QAAR,cAAQA,QAAR;EAAA,IAAkBC,UAAlB,cAAkBA,UAAlB;EAAA,IAAiCC,IAAjC,mDAD4E,CAG5E;;;EACA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,GAAM;IAC5BC,MAAM,CAACC,mBAAP,CAA2B,WAA3B,EAAwCF,eAAxC;IACAC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,iBAAiB,EAAEP,IAAI,CAACqB,QAAL,GAAgBvB,eAAhB,GAAkCS;EAFvD,GAGKJ,IAHL;AAKD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSProperties } from 'react';
|
|
1
|
+
import type { CSSProperties, KeyboardEventHandler, PointerEventHandler } from 'react';
|
|
2
2
|
export interface UseRippleSurfaceOptions<T extends HTMLElement> {
|
|
3
3
|
baseOpacity?: number;
|
|
4
4
|
hoverOpacity?: number;
|
|
@@ -9,10 +9,10 @@ export interface UseRippleSurfaceOptions<T extends HTMLElement> {
|
|
|
9
9
|
center?: boolean;
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
style?: CSSProperties;
|
|
12
|
-
onPointerDown?:
|
|
13
|
-
onKeyDown?:
|
|
12
|
+
onPointerDown?: PointerEventHandler<T>;
|
|
13
|
+
onKeyDown?: KeyboardEventHandler<T>;
|
|
14
14
|
}
|
|
15
|
-
export declare function useRippleSurface<T extends HTMLElement>(opts
|
|
15
|
+
export declare function useRippleSurface<T extends HTMLElement>(opts?: UseRippleSurfaceOptions<T>): {
|
|
16
16
|
style: {
|
|
17
17
|
alignContent?: import("csstype").Property.AlignContent | undefined;
|
|
18
18
|
alignItems?: import("csstype").Property.AlignItems | undefined;
|
|
@@ -782,5 +782,5 @@ export declare function useRippleSurface<T extends HTMLElement>(opts: UseRippleS
|
|
|
782
782
|
};
|
|
783
783
|
onKeyDown: import("@basic-ui/core").CustomEventHandler<import("react").KeyboardEvent<T>, []>;
|
|
784
784
|
onPointerDown: import("@basic-ui/core").CustomEventHandler<import("react").PointerEvent<T>, []>;
|
|
785
|
-
__css: Record<string, import("@styled-system/css").SystemStyleObject | import("@styled-system/css").ResponsiveStyleValue<string | number> | Record<string, import("@styled-system/css").SystemStyleObject | import("@styled-system/css").ResponsiveStyleValue<string | number>>>;
|
|
785
|
+
__css: import("@styled-system/css").SystemCssProperties | Record<string, import("@styled-system/css").SystemStyleObject | import("@styled-system/css").ResponsiveStyleValue<string | number> | Record<string, import("@styled-system/css").SystemStyleObject | import("@styled-system/css").ResponsiveStyleValue<string | number>>>;
|
|
786
786
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["onKeyDown", "onPointerDown", "style", "disabled", "rippleEnabled"];
|
|
5
|
+
import { useMemo } from 'react';
|
|
4
6
|
import { get } from '@styled-system/css';
|
|
5
7
|
import { wrapEvent } from '@basic-ui/core';
|
|
6
8
|
import { useTheme } from '../theme';
|
|
7
9
|
import { rippleStyle } from './Ripple';
|
|
8
10
|
import { useRippleHandlers } from './useRippleHandlers';
|
|
9
|
-
export function useRippleSurface(
|
|
10
|
-
var
|
|
11
|
-
|
|
11
|
+
export function useRippleSurface() {
|
|
12
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
12
13
|
var _opts$baseOpacity = opts.baseOpacity,
|
|
13
14
|
baseOpacity = _opts$baseOpacity === void 0 ? 0 : _opts$baseOpacity,
|
|
14
15
|
_opts$hoverOpacity = opts.hoverOpacity,
|
|
@@ -27,7 +28,7 @@ export function useRippleSurface(opts) {
|
|
|
27
28
|
disabled = opts.disabled,
|
|
28
29
|
_opts$rippleEnabled = opts.rippleEnabled,
|
|
29
30
|
rippleEnabled = _opts$rippleEnabled === void 0 ? true : _opts$rippleEnabled,
|
|
30
|
-
rippleProps = _objectWithoutProperties(opts,
|
|
31
|
+
rippleProps = _objectWithoutProperties(opts, _excluded);
|
|
31
32
|
|
|
32
33
|
var theme = useTheme();
|
|
33
34
|
rippleColor = get(theme, "colors.".concat(rippleColor)) || rippleColor;
|
|
@@ -48,64 +49,67 @@ export function useRippleSurface(opts) {
|
|
|
48
49
|
animationStyle = _useRippleHandlers.style,
|
|
49
50
|
animation = _useRippleHandlers.animation;
|
|
50
51
|
|
|
51
|
-
var css =
|
|
52
|
-
|
|
53
|
-
position: 'relative',
|
|
54
|
-
cursor: 'pointer',
|
|
55
|
-
// fix overflow: hidden + borderRadius in Safari
|
|
56
|
-
// https://gist.github.com/ayamflow/b602ab436ac9f05660d9c15190f4fd7b#gistcomment-2359479
|
|
57
|
-
willChange: 'transform,opacity',
|
|
58
|
-
WebkitTapHighlightColor: 'transparent',
|
|
59
|
-
// ripple overlay
|
|
60
|
-
'&::before': {
|
|
61
|
-
backgroundColor: rippleColor,
|
|
62
|
-
boxSizing: 'content-box',
|
|
63
|
-
position: 'absolute',
|
|
64
|
-
content: '""',
|
|
65
|
-
opacity: baseOpacity,
|
|
66
|
-
pointerEvents: 'none',
|
|
67
|
-
top: '0',
|
|
68
|
-
left: '0',
|
|
69
|
-
width: '100%',
|
|
70
|
-
height: '100%',
|
|
71
|
-
transition: 'opacity 75ms linear'
|
|
72
|
-
},
|
|
73
|
-
'&:hover::before': {
|
|
74
|
-
opacity: hoverOpacity
|
|
75
|
-
},
|
|
76
|
-
'&:focus-visible::before': {
|
|
77
|
-
opacity: focusOpacity
|
|
78
|
-
}
|
|
79
|
-
}, !rippleEnabled && {
|
|
80
|
-
'&:active::before': {
|
|
81
|
-
opacity: pressedOpacity
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
'&[aria-pressed="true"]::before': {
|
|
85
|
-
opacity: baseOpacity + pressedOpacity
|
|
86
|
-
},
|
|
87
|
-
'&[aria-pressed="true"]:hover::before': {
|
|
88
|
-
opacity: pressedOpacity + hoverOpacity
|
|
89
|
-
},
|
|
90
|
-
'&[aria-pressed="true"]:focus-visible::before': {
|
|
91
|
-
opacity: pressedOpacity + focusOpacity
|
|
92
|
-
}
|
|
93
|
-
}, !rippleEnabled && {
|
|
94
|
-
'&[aria-pressed="true"]:active::before': {
|
|
95
|
-
opacity: pressedOpacity + pressedOpacity
|
|
96
|
-
}
|
|
97
|
-
}, (_extends2 = {}, _defineProperty(_extends2, '&:disabled::before,&:disabled:hover::before,&:disabled:focus::before,&:disabled:active::before,' + '&[data-disabled]::before,&[data-disabled]:hover::before,&[data-disabled]:focus::before,' + '&[data-disabled]:active::before,&:disabled[aria-pressed="true"]::before', {
|
|
98
|
-
opacity: 0
|
|
99
|
-
}), _defineProperty(_extends2, '&:disabled,&[data-disabled]', {
|
|
100
|
-
cursor: 'default'
|
|
101
|
-
}), _extends2), rippleEnabled && {
|
|
102
|
-
'&::after': _extends({}, rippleStyle({
|
|
103
|
-
animation: animation
|
|
104
|
-
}))
|
|
105
|
-
});
|
|
52
|
+
var css = useMemo(function () {
|
|
53
|
+
var _extends2;
|
|
106
54
|
|
|
55
|
+
return _extends(_extends(_extends({
|
|
56
|
+
overflow: 'hidden',
|
|
57
|
+
position: 'relative',
|
|
58
|
+
cursor: 'pointer',
|
|
59
|
+
// fix overflow: hidden + borderRadius in Safari
|
|
60
|
+
// https://gist.github.com/ayamflow/b602ab436ac9f05660d9c15190f4fd7b#gistcomment-2359479
|
|
61
|
+
willChange: 'transform,opacity',
|
|
62
|
+
WebkitTapHighlightColor: 'transparent',
|
|
63
|
+
// ripple overlay
|
|
64
|
+
'&::before': {
|
|
65
|
+
backgroundColor: rippleColor,
|
|
66
|
+
boxSizing: 'content-box',
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
content: '""',
|
|
69
|
+
opacity: baseOpacity,
|
|
70
|
+
pointerEvents: 'none',
|
|
71
|
+
top: '0',
|
|
72
|
+
left: '0',
|
|
73
|
+
width: '100%',
|
|
74
|
+
height: '100%',
|
|
75
|
+
transition: 'opacity 75ms linear'
|
|
76
|
+
},
|
|
77
|
+
'&:hover::before': {
|
|
78
|
+
opacity: hoverOpacity
|
|
79
|
+
},
|
|
80
|
+
'&:focus-visible::before': {
|
|
81
|
+
opacity: focusOpacity
|
|
82
|
+
}
|
|
83
|
+
}, !rippleEnabled && {
|
|
84
|
+
'&:active::before': {
|
|
85
|
+
opacity: pressedOpacity
|
|
86
|
+
}
|
|
87
|
+
}), {}, {
|
|
88
|
+
'&[aria-pressed="true"]::before': {
|
|
89
|
+
opacity: baseOpacity + pressedOpacity
|
|
90
|
+
},
|
|
91
|
+
'&[aria-pressed="true"]:hover::before': {
|
|
92
|
+
opacity: pressedOpacity + hoverOpacity
|
|
93
|
+
},
|
|
94
|
+
'&[aria-pressed="true"]:focus-visible::before': {
|
|
95
|
+
opacity: pressedOpacity + focusOpacity
|
|
96
|
+
}
|
|
97
|
+
}, !rippleEnabled && {
|
|
98
|
+
'&[aria-pressed="true"]:active::before': {
|
|
99
|
+
opacity: pressedOpacity + pressedOpacity
|
|
100
|
+
}
|
|
101
|
+
}), {}, (_extends2 = {}, _defineProperty(_extends2, '&:disabled::before,&:disabled:hover::before,&:disabled:focus::before,&:disabled:active::before,' + '&[data-disabled]::before,&[data-disabled]:hover::before,&[data-disabled]:focus::before,' + '&[data-disabled]:active::before,&:disabled[aria-pressed="true"]::before', {
|
|
102
|
+
opacity: 0
|
|
103
|
+
}), _defineProperty(_extends2, '&:disabled,&[data-disabled]', {
|
|
104
|
+
cursor: 'default'
|
|
105
|
+
}), _extends2), rippleEnabled && {
|
|
106
|
+
'&::after': _extends({}, rippleStyle({
|
|
107
|
+
animation: animation
|
|
108
|
+
}))
|
|
109
|
+
});
|
|
110
|
+
}, [animation, baseOpacity, focusOpacity, hoverOpacity, pressedOpacity, rippleColor, rippleEnabled]);
|
|
107
111
|
return {
|
|
108
|
-
style: _extends({}, animationStyle, style),
|
|
112
|
+
style: _extends(_extends({}, animationStyle), style),
|
|
109
113
|
onKeyDown: wrapEvent(onKeyDown, handleKeyDown),
|
|
110
114
|
onPointerDown: wrapEvent(onPointerDown, handlePointerDown),
|
|
111
115
|
__css: css
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useRippleSurface.js","names":["useMemo","get","wrapEvent","useTheme","rippleStyle","useRippleHandlers","useRippleSurface","opts","baseOpacity","hoverOpacity","focusOpacity","pressedOpacity","rippleColor","onKeyDown","onPointerDown","style","disabled","rippleEnabled","rippleProps","theme","opacity","Number","backgroundColor","handleKeyDown","handlePointerDown","animationStyle","animation","css","overflow","position","cursor","willChange","WebkitTapHighlightColor","boxSizing","content","pointerEvents","top","left","width","height","transition","__css"],"sources":["../../../src/Ripple/useRippleSurface.ts"],"sourcesContent":["import type {\n CSSProperties,\n KeyboardEventHandler,\n PointerEventHandler,\n} from 'react';\nimport { useMemo } from 'react';\nimport { get } from '@styled-system/css';\nimport { wrapEvent } from '@basic-ui/core';\n\nimport { useTheme } from '../theme';\nimport { rippleStyle } from './Ripple';\nimport { useRippleHandlers } from './useRippleHandlers';\nimport type { SxStyleProp } from '../Box';\n\nexport interface UseRippleSurfaceOptions<T extends HTMLElement> {\n baseOpacity?: number;\n hoverOpacity?: number;\n focusOpacity?: number;\n pressedOpacity?: number;\n rippleColor?: string;\n rippleEnabled?: boolean;\n center?: boolean;\n disabled?: boolean;\n style?: CSSProperties;\n onPointerDown?: PointerEventHandler<T>;\n onKeyDown?: KeyboardEventHandler<T>;\n}\n\nexport function useRippleSurface<T extends HTMLElement>(\n opts: UseRippleSurfaceOptions<T> = {}\n) {\n let {\n // eslint-disable-next-line prefer-const\n baseOpacity = 0,\n hoverOpacity = 0.04,\n focusOpacity = 0.12,\n pressedOpacity = 0.12,\n rippleColor = 'on.surface',\n } = opts;\n const {\n onKeyDown,\n onPointerDown,\n style = {},\n disabled,\n rippleEnabled = true,\n ...rippleProps\n } = opts;\n\n const theme = useTheme();\n rippleColor = get(theme, `colors.${rippleColor}`) || rippleColor;\n\n if (disabled) {\n hoverOpacity = baseOpacity;\n focusOpacity = baseOpacity;\n pressedOpacity = baseOpacity;\n }\n\n const {\n handleKeyDown,\n handlePointerDown,\n style: animationStyle,\n animation,\n } = useRippleHandlers({\n opacity: Number(pressedOpacity),\n backgroundColor: rippleColor,\n disabled,\n ...rippleProps,\n });\n\n const css: SxStyleProp = useMemo(\n () => ({\n overflow: 'hidden',\n position: 'relative',\n cursor: 'pointer',\n // fix overflow: hidden + borderRadius in Safari\n // https://gist.github.com/ayamflow/b602ab436ac9f05660d9c15190f4fd7b#gistcomment-2359479\n willChange: 'transform,opacity',\n WebkitTapHighlightColor: 'transparent',\n // ripple overlay\n '&::before': {\n backgroundColor: rippleColor,\n boxSizing: 'content-box',\n position: 'absolute',\n content: '\"\"',\n opacity: baseOpacity,\n pointerEvents: 'none',\n top: '0',\n left: '0',\n width: '100%',\n height: '100%',\n transition: 'opacity 75ms linear',\n },\n '&:hover::before': {\n opacity: hoverOpacity,\n },\n '&:focus-visible::before': {\n opacity: focusOpacity,\n },\n ...(!rippleEnabled && {\n '&:active::before': {\n opacity: pressedOpacity,\n },\n }),\n '&[aria-pressed=\"true\"]::before': {\n opacity: baseOpacity + pressedOpacity,\n },\n '&[aria-pressed=\"true\"]:hover::before': {\n opacity: pressedOpacity + hoverOpacity,\n },\n '&[aria-pressed=\"true\"]:focus-visible::before': {\n opacity: pressedOpacity + focusOpacity,\n },\n ...(!rippleEnabled && {\n '&[aria-pressed=\"true\"]:active::before': {\n opacity: pressedOpacity + pressedOpacity,\n },\n }),\n ['&:disabled::before,&:disabled:hover::before,&:disabled:focus::before,&:disabled:active::before,' +\n '&[data-disabled]::before,&[data-disabled]:hover::before,&[data-disabled]:focus::before,' +\n '&[data-disabled]:active::before,&:disabled[aria-pressed=\"true\"]::before']:\n {\n opacity: 0,\n },\n '&:disabled,&[data-disabled]': {\n cursor: 'default',\n },\n // ripple\n ...(rippleEnabled && {\n '&::after': { ...rippleStyle({ animation }) },\n }),\n }),\n [\n animation,\n baseOpacity,\n focusOpacity,\n hoverOpacity,\n pressedOpacity,\n rippleColor,\n rippleEnabled,\n ]\n );\n\n return {\n style: { ...animationStyle, ...style },\n onKeyDown: wrapEvent(onKeyDown, handleKeyDown),\n onPointerDown: wrapEvent(onPointerDown, handlePointerDown),\n __css: css,\n };\n}\n"],"mappings":";;;;AAKA,S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M,EAAE;IADqB,CArDjC,eAyDMb,aAAa,IAAI;MACnB,yBAAiBb,WAAW,CAAC;QAAEsB,SAAS,EAATA;MAAF,CAAD,CAA5B;IADmB,CAzDvB;EAAA,CAD8B,EA8D9B,CACEA,SADF,EAEElB,WAFF,EAGEE,YAHF,EAIED,YAJF,EAKEE,cALF,EAMEC,WANF,EAOEK,aAPF,CA9D8B,CAAhC;EAyEA,OAAO;IACLF,KAAK,wBAAOU,cAAP,GAA0BV,KAA1B,CADA;IAELF,SAAS,EAAEX,SAAS,CAACW,SAAD,EAAYU,aAAZ,CAFf;IAGLT,aAAa,EAAEZ,SAAS,CAACY,aAAD,EAAgBU,iBAAhB,CAHnB;IAILiB,KAAK,EAAEd;EAJF,CAAP;AAMD"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { SelectHTMLAttributes, ReactNode, ChangeEvent } from 'react';
|
|
2
2
|
import type { Theme } from '../theme';
|
|
3
3
|
import type { BoxProps } from '../Box';
|
|
4
|
-
export interface SelectProps extends Omit<BoxProps<HTMLSelectElement,
|
|
4
|
+
export interface SelectProps extends Omit<BoxProps<HTMLSelectElement, SelectHTMLAttributes<HTMLSelectElement>>, 'value' | 'defaultValue' | 'onChange'> {
|
|
5
5
|
variant?: 'outlined' | 'filled';
|
|
6
6
|
color?: 'primary' | 'secondary';
|
|
7
|
-
label?:
|
|
7
|
+
label?: ReactNode;
|
|
8
8
|
helperText?: string;
|
|
9
9
|
defaultValue?: string;
|
|
10
10
|
value?: string;
|
|
11
11
|
native?: boolean;
|
|
12
12
|
theme?: Theme;
|
|
13
13
|
error?: boolean | string;
|
|
14
|
-
onChange?: (e:
|
|
14
|
+
onChange?: (e: ChangeEvent<HTMLSelectElement>, value: string) => void;
|
|
15
15
|
renderValue?: (value?: string) => string | undefined;
|
|
16
|
-
leadingIcon?:
|
|
16
|
+
leadingIcon?: ReactNode;
|
|
17
17
|
}
|
|
18
|
-
export declare const Select:
|
|
18
|
+
export declare const Select: import("react").ForwardRefExoticComponent<Pick<SelectProps, "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "backgroundImage" | "backgroundPosition" | "backgroundRepeat" | "backgroundSize" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "bottom" | "color" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "textAlign" | "textShadow" | "top" | "translate" | "verticalAlign" | "width" | "background" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "flex" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bg" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "variant" | "size" | "hidden" | "as" | "sx" | "__css" | "tx" | "theme" | "borderX" | "borderY" | "gridGap" | "gridColumnGap" | "gridRowGap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "value" | "form" | "label" | "error" | "autoFocus" | "disabled" | "name" | "multiple" | "autoComplete" | "required" | "leadingIcon" | "helperText" | "native" | "renderValue"> & import("react").RefAttributes<HTMLButtonElement | HTMLSelectElement>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["id", "variant", "color", "value", "defaultValue", "disabled", "error", "label", "placeholder", "helperText", "onChange", "onFocus", "onBlur", "native", "children", "renderValue", "leadingIcon"];
|
|
4
5
|
import { forwardRef, useState, useRef, useEffect, useId } from 'react';
|
|
5
|
-
import * as React from 'react';
|
|
6
6
|
import { wrapEvent, assignMultipleRefs, useControlledState } from '@basic-ui/core';
|
|
7
7
|
import { useTheme } from '../theme';
|
|
8
8
|
import { Select as SelectComp, SelectButton } from './styledComponents';
|
|
@@ -48,7 +48,7 @@ export var Select = /*#__PURE__*/forwardRef(function Select(props, forwardedRef)
|
|
|
48
48
|
renderValueProp = props.renderValue,
|
|
49
49
|
_props$leadingIcon = props.leadingIcon,
|
|
50
50
|
leadingIcon = _props$leadingIcon === void 0 ? null : _props$leadingIcon,
|
|
51
|
-
otherProps = _objectWithoutProperties(props,
|
|
51
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
52
52
|
|
|
53
53
|
var _useControlledState = useControlledState(valueProp, onChangeProp, defaultValue, function (setState) {
|
|
54
54
|
return function (e, v) {
|
|
@@ -135,7 +135,7 @@ export var Select = /*#__PURE__*/forwardRef(function Select(props, forwardedRef)
|
|
|
135
135
|
children: [leadingIcon && /*#__PURE__*/_jsx(IconContainer, {
|
|
136
136
|
position: "start",
|
|
137
137
|
children: leadingIcon
|
|
138
|
-
}), /*#__PURE__*/_jsx(Comp, _extends({
|
|
138
|
+
}), /*#__PURE__*/_jsx(Comp, _extends(_extends({
|
|
139
139
|
ref: assignMultipleRefs(forwardedRef, buttonRef),
|
|
140
140
|
variant: variant,
|
|
141
141
|
id: inputId,
|
|
@@ -151,14 +151,14 @@ export var Select = /*#__PURE__*/forwardRef(function Select(props, forwardedRef)
|
|
|
151
151
|
hasLabel: !!label,
|
|
152
152
|
leadingIcon: Boolean(leadingIcon),
|
|
153
153
|
trailingIcon: true
|
|
154
|
-
}, otherProps, {
|
|
154
|
+
}, otherProps), {}, {
|
|
155
155
|
children: native ? children : renderValue(value)
|
|
156
156
|
})), !native && /*#__PURE__*/_jsx(MenuPopover, {
|
|
157
157
|
usePortal: true,
|
|
158
158
|
children: /*#__PURE__*/_jsx(MenuList, {
|
|
159
159
|
defaultActiveItemValue: value,
|
|
160
160
|
style: {
|
|
161
|
-
minWidth: buttonRef
|
|
161
|
+
minWidth: buttonRef === null || buttonRef === void 0 ? void 0 : (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.offsetWidth
|
|
162
162
|
},
|
|
163
163
|
role: "listbox",
|
|
164
164
|
children: children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Select/Select.tsx"],"names":["forwardRef","useState","useRef","useEffect","useId","React","wrapEvent","assignMultipleRefs","useControlledState","useTheme","Select","SelectComp","SelectButton","FilledContainer","HelperText","OutlinedContainer","SelectProvider","Menu","MenuPopover","MenuList","SelectIcon","makeDefaultRender","Box","IconContainer","componentMap","outlined","filled","props","forwardedRef","idProp","id","variant","color","valueProp","value","defaultValue","disabled","error","label","placeholder","helperTextProp","helperText","onChangeProp","onChange","onFocus","onBlur","native","children","renderValueProp","renderValue","leadingIcon","otherProps","setState","e","v","hasFocus","setHasFocus","buttonRef","open","setOpen","fallbackId","theme","Container","handleFocus","handleBlur","handleToggle","isOpen","handleOnChange","target","currentTarget","dataset","hasError","Boolean","inputId","helperTextId","undefined","labelIsFloating","Comp","current","onSelect","minWidth","offsetWidth"],"mappings":";;;AAAA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,MAA/B,EAAuCC,SAAvC,EAAkDC,KAAlD,QAA+D,OAA/D;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SACEC,SADF,EAEEC,kBAFF,EAGEC,kBAHF,QAIO,gBAJP;AAOA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,MAAM,IAAIC,UAAnB,EAA+BC,YAA/B,QAAmD,oBAAnD;AACA,SAASC,eAAT,QAAgC,8BAAhC;AACA,SAASC,UAAT,QAA2B,yBAA3B;AACA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,IAAT,EAAeC,WAAf,EAA4BC,QAA5B,QAA4C,SAA5C;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,iBAAT,QAAkC,iBAAlC;AAEA,SAASC,GAAT,QAAoB,QAApB;AACA,SAASC,aAAT,QAA8B,4BAA9B;;;AAEA,IAAMC,YAAY,GAAG;AACnBC,EAAAA,QAAQ,EAAEV,iBADS;AAEnBW,EAAAA,MAAM,EAAEb;AAFW,CAArB;AAwBA,OAAO,IAAMH,MAAM,gBAAGV,UAAU,CAG9B,SAASU,MAAT,CAAgBiB,KAAhB,EAAuBC,YAAvB,EAAqC;AAAA;;AAAA,MAE/BC,MAF+B,GAoBjCF,KApBiC,CAEnCG,EAFmC;AAAA,uBAoBjCH,KApBiC,CAGnCI,OAHmC;AAAA,MAGnCA,OAHmC,+BAGzB,UAHyB;AAAA,qBAoBjCJ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;AAAA,wBAOGlC;AAPH;AADF,YAzBJ;AAAA,UAZF,eAkDE,KAAC,UAAD;AAAY,UAAA,IAAI,EAAEW;AAAlB,UAlDF;AAAA,QADF,eAsDE,KAAC,UAAD;AACE,QAAA,QAAQ,EAAEtB,QADZ;AAEE,QAAA,EAAE,EAAEsC,YAFN;AAGE,QAAA,QAAQ,EAAEjC,UAHZ;AAIE,QAAA,KAAK,EAAE8B;AAJT,QAtDF;AAAA;AADF,IADF;AAiED,CAtJ+B,CAAzB","sourcesContent":["import { forwardRef, useState, useRef, useEffect, useId } from 'react';\nimport * as React from 'react';\nimport {\n wrapEvent,\n assignMultipleRefs,\n useControlledState,\n} from '@basic-ui/core';\n\nimport type { Theme } from '../theme';\nimport { useTheme } from '../theme';\nimport { Select as SelectComp, SelectButton } from './styledComponents';\nimport { FilledContainer } from '../TextField/FilledContainer';\nimport { HelperText } from '../TextField/HelperText';\nimport { OutlinedContainer } from '../TextField/OutlinedContainer';\nimport { SelectProvider } from './context';\nimport { Menu, MenuPopover, MenuList } from '../Menu';\nimport { SelectIcon } from './SelectIcon';\nimport { makeDefaultRender } from './defaultRender';\nimport type { BoxProps } from '../Box';\nimport { Box } from '../Box';\nimport { IconContainer } from '../TextField/IconContainer';\n\nconst componentMap = {\n outlined: OutlinedContainer,\n filled: FilledContainer,\n};\n\nexport interface SelectProps\n extends Omit<\n BoxProps<HTMLSelectElement, React.SelectHTMLAttributes<HTMLSelectElement>>,\n 'value' | 'defaultValue' | 'onChange'\n > {\n variant?: 'outlined' | 'filled';\n color?: 'primary' | 'secondary';\n label?: React.ReactNode;\n helperText?: string;\n defaultValue?: string;\n value?: string;\n native?: boolean;\n theme?: Theme;\n error?: boolean | string;\n onChange?: (e: React.ChangeEvent<HTMLSelectElement>, value: string) => void;\n renderValue?: (value?: string) => string | undefined;\n leadingIcon?: React.ReactNode;\n}\n\nexport const Select = forwardRef<\n HTMLSelectElement | HTMLButtonElement,\n SelectProps\n>(function Select(props, forwardedRef) {\n const {\n id: idProp,\n variant = 'outlined',\n color = 'primary',\n value: valueProp,\n defaultValue = '',\n disabled,\n error = false,\n label = null,\n placeholder,\n helperText: helperTextProp,\n onChange: onChangeProp,\n onFocus,\n onBlur,\n native = false,\n children,\n renderValue: renderValueProp,\n leadingIcon = null,\n ...otherProps\n } = props;\n const [value, onChange] = useControlledState(\n valueProp,\n onChangeProp,\n defaultValue,\n (setState) => (e, v) => {\n setState(v);\n }\n );\n const [hasFocus, setHasFocus] = useState(false);\n const buttonRef = useRef<HTMLButtonElement | HTMLSelectElement>();\n const [open, setOpen] = useState(false);\n const fallbackId = useId();\n const theme = useTheme();\n\n const Container = componentMap[variant] || OutlinedContainer;\n\n const handleFocus = () => {\n setHasFocus(true);\n };\n\n const handleBlur = () => {\n setHasFocus(false);\n };\n\n const handleToggle = (e: unknown, isOpen: boolean) => {\n setOpen(isOpen);\n };\n\n const handleOnChange = (e: any) => {\n onChange &&\n onChange(\n e as any,\n native ? e.target.value : e.currentTarget.dataset.value\n );\n };\n\n const hasError = Boolean(error);\n const helperText = typeof error === 'string' ? error : helperTextProp;\n\n const id = idProp || fallbackId;\n const inputId = `${id}-text-field`;\n const helperTextId = helperText ? `${id}-helper-text` : undefined;\n\n const renderValue = renderValueProp || makeDefaultRender(children);\n\n const labelIsFloating = hasFocus || open || renderValue(value) !== undefined;\n\n const Comp: React.ComponentType<any> = native\n ? (SelectComp as any)\n : (SelectButton as any);\n\n useEffect(() => {\n // right after mounting, if the default value in the select element\n // is different than the value we have stored in state we need to\n // update our state to reflect that.\n if (native && buttonRef.current && buttonRef.current.value !== value) {\n onChange && onChange({} as any, buttonRef.current.value);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <SelectProvider value={{ native, onSelect: handleOnChange, value }}>\n <Box display=\"inline-flex\" flexDirection=\"column\" width=\"100%\">\n <Container\n theme={theme}\n label={label}\n color={color}\n labelIsFloating={labelIsFloating}\n inputId={inputId}\n hasFocus={hasFocus}\n disabled={disabled}\n forceActive={open}\n error={hasError}\n leadingIcon={Boolean(leadingIcon)}\n >\n <Menu onChange={handleToggle} open={open}>\n {leadingIcon && (\n <IconContainer position=\"start\">{leadingIcon}</IconContainer>\n )}\n <Comp\n ref={assignMultipleRefs(forwardedRef, buttonRef)}\n variant={variant}\n id={inputId}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n onChange={native ? handleOnChange : undefined}\n value={native ? value : undefined}\n theme={theme}\n placeholder={placeholder}\n disabled={disabled}\n aria-disabled={disabled ? 'true' : undefined}\n aria-describedby={helperTextId}\n hasLabel={!!label}\n leadingIcon={Boolean(leadingIcon)}\n trailingIcon={true}\n {...otherProps}\n >\n {native ? children : renderValue(value)}\n </Comp>\n {!native && (\n <MenuPopover usePortal>\n <MenuList\n defaultActiveItemValue={value}\n style={{\n minWidth: buttonRef?.current?.offsetWidth,\n }}\n role=\"listbox\"\n >\n {children}\n </MenuList>\n </MenuPopover>\n )}\n </Menu>\n <SelectIcon open={open} />\n </Container>\n\n <HelperText\n disabled={disabled}\n id={helperTextId}\n leftSide={helperText}\n error={hasError}\n />\n </Box>\n </SelectProvider>\n );\n});\n"],"file":"Select.js"}
|
|
1
|
+
{"version":3,"file":"Select.js","names":["forwardRef","useState","useRef","useEffect","useId","wrapEvent","assignMultipleRefs","useControlledState","useTheme","Select","SelectComp","SelectButton","FilledContainer","HelperText","OutlinedContainer","SelectProvider","Menu","MenuPopover","MenuList","SelectIcon","makeDefaultRender","Box","IconContainer","componentMap","outlined","filled","props","forwardedRef","idProp","id","variant","color","valueProp","value","defaultValue","disabled","error","label","placeholder","helperTextProp","helperText","onChangeProp","onChange","onFocus","onBlur","native","children","renderValueProp","renderValue","leadingIcon","otherProps","setState","e","v","hasFocus","setHasFocus","buttonRef","open","setOpen","fallbackId","theme","Container","handleFocus","handleBlur","handleToggle","isOpen","handleOnChange","target","currentTarget","dataset","hasError","Boolean","inputId","helperTextId","undefined","labelIsFloating","Comp","current","onSelect","minWidth","offsetWidth"],"sources":["../../../src/Select/Select.tsx"],"sourcesContent":["import type {\n SelectHTMLAttributes,\n ReactNode,\n ChangeEvent,\n ComponentType,\n} from 'react';\nimport { forwardRef, useState, useRef, useEffect, useId } from 'react';\nimport {\n wrapEvent,\n assignMultipleRefs,\n useControlledState,\n} from '@basic-ui/core';\n\nimport type { Theme } from '../theme';\nimport { useTheme } from '../theme';\nimport { Select as SelectComp, SelectButton } from './styledComponents';\nimport { FilledContainer } from '../TextField/FilledContainer';\nimport { HelperText } from '../TextField/HelperText';\nimport { OutlinedContainer } from '../TextField/OutlinedContainer';\nimport { SelectProvider } from './context';\nimport { Menu, MenuPopover, MenuList } from '../Menu';\nimport { SelectIcon } from './SelectIcon';\nimport { makeDefaultRender } from './defaultRender';\nimport type { BoxProps } from '../Box';\nimport { Box } from '../Box';\nimport { IconContainer } from '../TextField/IconContainer';\n\nconst componentMap = {\n outlined: OutlinedContainer,\n filled: FilledContainer,\n};\n\nexport interface SelectProps\n extends Omit<\n BoxProps<HTMLSelectElement, SelectHTMLAttributes<HTMLSelectElement>>,\n 'value' | 'defaultValue' | 'onChange'\n > {\n variant?: 'outlined' | 'filled';\n color?: 'primary' | 'secondary';\n label?: ReactNode;\n helperText?: string;\n defaultValue?: string;\n value?: string;\n native?: boolean;\n theme?: Theme;\n error?: boolean | string;\n onChange?: (e: ChangeEvent<HTMLSelectElement>, value: string) => void;\n renderValue?: (value?: string) => string | undefined;\n leadingIcon?: ReactNode;\n}\n\nexport const Select = forwardRef<\n HTMLSelectElement | HTMLButtonElement,\n SelectProps\n>(function Select(props, forwardedRef) {\n const {\n id: idProp,\n variant = 'outlined',\n color = 'primary',\n value: valueProp,\n defaultValue = '',\n disabled,\n error = false,\n label = null,\n placeholder,\n helperText: helperTextProp,\n onChange: onChangeProp,\n onFocus,\n onBlur,\n native = false,\n children,\n renderValue: renderValueProp,\n leadingIcon = null,\n ...otherProps\n } = props;\n const [value, onChange] = useControlledState(\n valueProp,\n onChangeProp,\n defaultValue,\n (setState) => (e, v) => {\n setState(v);\n }\n );\n const [hasFocus, setHasFocus] = useState(false);\n const buttonRef = useRef<HTMLButtonElement | HTMLSelectElement>();\n const [open, setOpen] = useState(false);\n const fallbackId = useId();\n const theme = useTheme();\n\n const Container = componentMap[variant] || OutlinedContainer;\n\n const handleFocus = () => {\n setHasFocus(true);\n };\n\n const handleBlur = () => {\n setHasFocus(false);\n };\n\n const handleToggle = (e: unknown, isOpen: boolean) => {\n setOpen(isOpen);\n };\n\n const handleOnChange = (e: any) => {\n onChange &&\n onChange(\n e as any,\n native ? e.target.value : e.currentTarget.dataset.value\n );\n };\n\n const hasError = Boolean(error);\n const helperText = typeof error === 'string' ? error : helperTextProp;\n\n const id = idProp || fallbackId;\n const inputId = `${id}-text-field`;\n const helperTextId = helperText ? `${id}-helper-text` : undefined;\n\n const renderValue = renderValueProp || makeDefaultRender(children);\n\n const labelIsFloating = hasFocus || open || renderValue(value) !== undefined;\n\n const Comp: ComponentType<any> = native\n ? (SelectComp as any)\n : (SelectButton as any);\n\n useEffect(() => {\n // right after mounting, if the default value in the select element\n // is different than the value we have stored in state we need to\n // update our state to reflect that.\n if (native && buttonRef.current && buttonRef.current.value !== value) {\n onChange && onChange({} as any, buttonRef.current.value);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <SelectProvider value={{ native, onSelect: handleOnChange, value }}>\n <Box display=\"inline-flex\" flexDirection=\"column\" width=\"100%\">\n <Container\n theme={theme}\n label={label}\n color={color}\n labelIsFloating={labelIsFloating}\n inputId={inputId}\n hasFocus={hasFocus}\n disabled={disabled}\n forceActive={open}\n error={hasError}\n leadingIcon={Boolean(leadingIcon)}\n >\n <Menu onChange={handleToggle} open={open}>\n {leadingIcon && (\n <IconContainer position=\"start\">{leadingIcon}</IconContainer>\n )}\n <Comp\n ref={assignMultipleRefs(forwardedRef, buttonRef)}\n variant={variant}\n id={inputId}\n onFocus={wrapEvent(onFocus, handleFocus)}\n onBlur={wrapEvent(onBlur, handleBlur)}\n onChange={native ? handleOnChange : undefined}\n value={native ? value : undefined}\n theme={theme}\n placeholder={placeholder}\n disabled={disabled}\n aria-disabled={disabled ? 'true' : undefined}\n aria-describedby={helperTextId}\n hasLabel={!!label}\n leadingIcon={Boolean(leadingIcon)}\n trailingIcon={true}\n {...otherProps}\n >\n {native ? children : renderValue(value)}\n </Comp>\n {!native && (\n <MenuPopover usePortal>\n <MenuList\n defaultActiveItemValue={value}\n style={{\n minWidth: buttonRef?.current?.offsetWidth,\n }}\n role=\"listbox\"\n >\n {children}\n </MenuList>\n </MenuPopover>\n )}\n </Menu>\n <SelectIcon open={open} />\n </Container>\n\n <HelperText\n disabled={disabled}\n id={helperTextId}\n leftSide={helperText}\n error={hasError}\n />\n </Box>\n </SelectProvider>\n );\n});\n"],"mappings":";;;;AAMA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,MAA/B,EAAuCC,SAAvC,EAAkDC,KAAlD,QAA+D,OAA/D;AACA,SACEC,SADF,EAEEC,kBAFF,EAGEC,kBAHF,QAIO,gBAJP;AAOA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,MAAM,IAAIC,UAAnB,EAA+BC,YAA/B,QAAmD,oBAAnD;AACA,SAASC,eAAT,QAAgC,8BAAhC;AACA,SAASC,UAAT,QAA2B,yBAA3B;AACA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,SAASC,cAAT,QAA+B,WAA/B;AACA,SAASC,IAAT,EAAeC,WAAf,EAA4BC,QAA5B,QAA4C,SAA5C;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,iBAAT,QAAkC,iBAAlC;AAEA,SAASC,GAAT,QAAoB,QAApB;AACA,SAASC,aAAT,QAA8B,4BAA9B;;;AAEA,IAAMC,YAAY,GAAG;EACnBC,QAAQ,EAAEV,iBADS;EAEnBW,MAAM,EAAEb;AAFW,CAArB;AAwBA,OAAO,IAAMH,MAAM,gBAAGT,UA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