react-miui 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.json +12 -0
- package/.claude/settings.local.json +5 -1
- package/.storybook/preview.tsx +10 -4
- package/CHANGELOG.md +22 -0
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/index.js +1 -0
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/form/input/Input.d.ts.map +1 -1
- package/dist/components/form/input/Input.js +9 -5
- package/dist/components/form/input/Input.js.map +1 -1
- package/dist/components/form/timepicker/TimePicker.css.d.ts +99 -0
- package/dist/components/form/timepicker/TimePicker.css.d.ts.map +1 -0
- package/dist/components/form/timepicker/TimePicker.css.js +116 -0
- package/dist/components/form/timepicker/TimePicker.css.js.map +1 -0
- package/dist/components/form/timepicker/TimePicker.d.ts +22 -0
- package/dist/components/form/timepicker/TimePicker.d.ts.map +1 -0
- package/dist/components/form/timepicker/TimePicker.js +141 -0
- package/dist/components/form/timepicker/TimePicker.js.map +1 -0
- package/dist/components/form/timepicker/TimePicker.styled.d.ts +936 -0
- package/dist/components/form/timepicker/TimePicker.styled.d.ts.map +1 -0
- package/dist/components/form/timepicker/TimePicker.styled.js +29 -0
- package/dist/components/form/timepicker/TimePicker.styled.js.map +1 -0
- package/dist/components/form/timepicker/TimePickerModal.d.ts +17 -0
- package/dist/components/form/timepicker/TimePickerModal.d.ts.map +1 -0
- package/dist/components/form/timepicker/TimePickerModal.js +92 -0
- package/dist/components/form/timepicker/TimePickerModal.js.map +1 -0
- package/dist/components/form/timepicker/Wheel.d.ts +12 -0
- package/dist/components/form/timepicker/Wheel.d.ts.map +1 -0
- package/dist/components/form/timepicker/Wheel.js +187 -0
- package/dist/components/form/timepicker/Wheel.js.map +1 -0
- package/dist/components/form/timepicker/utils.d.ts +4 -0
- package/dist/components/form/timepicker/utils.d.ts.map +1 -0
- package/dist/components/form/timepicker/utils.js +62 -0
- package/dist/components/form/timepicker/utils.js.map +1 -0
- package/dist/components/icons/Clock.d.ts +7 -0
- package/dist/components/icons/Clock.d.ts.map +1 -0
- package/dist/components/icons/Clock.js +45 -0
- package/dist/components/icons/Clock.js.map +1 -0
- package/dist/components/icons/Icon.d.ts +2 -1
- package/dist/components/icons/Icon.d.ts.map +1 -1
- package/dist/components/icons/Icon.js +3 -0
- package/dist/components/icons/Icon.js.map +1 -1
- package/dist/components/ui/drawer/Drawer.d.ts +10 -1
- package/dist/components/ui/drawer/Drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer/Drawer.js +135 -15
- package/dist/components/ui/drawer/Drawer.js.map +1 -1
- package/dist/components/ui/drawer/Drawer.styled.d.ts +86 -1
- package/dist/components/ui/drawer/Drawer.styled.d.ts.map +1 -1
- package/dist/components/ui/drawer/Drawer.styled.js +13 -1
- package/dist/components/ui/drawer/Drawer.styled.js.map +1 -1
- package/dist/components/ui/modal/Modal.d.ts +1 -2
- package/dist/components/ui/modal/Modal.d.ts.map +1 -1
- package/dist/components/ui/modal/Modal.js +114 -42
- package/dist/components/ui/modal/Modal.js.map +1 -1
- package/dist/components/ui/modal/Modal.styled.d.ts +1 -1
- package/dist/components/ui/modal/Modal.styled.d.ts.map +1 -1
- package/dist/components/ui/modal/Modal.styled.js +40 -25
- package/dist/components/ui/modal/Modal.styled.js.map +1 -1
- package/dist/components/ui/toaster/Toaster.d.ts.map +1 -1
- package/dist/components/ui/toaster/Toaster.js +7 -1
- package/dist/components/ui/toaster/Toaster.js.map +1 -1
- package/dist/components/ui/tooltip/Tooltip.d.ts +30 -0
- package/dist/components/ui/tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip/Tooltip.js +81 -0
- package/dist/components/ui/tooltip/Tooltip.js.map +1 -0
- package/dist/components/ui/tooltip/Tooltip.styled.d.ts +173 -0
- package/dist/components/ui/tooltip/Tooltip.styled.d.ts.map +1 -0
- package/dist/components/ui/tooltip/Tooltip.styled.js +65 -0
- package/dist/components/ui/tooltip/Tooltip.styled.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/theme.css-global.d.ts.map +1 -1
- package/dist/theme.css-global.js +0 -1
- package/dist/theme.css-global.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/useNativeValidity.d.ts +11 -0
- package/dist/utils/useNativeValidity.d.ts.map +1 -0
- package/dist/utils/useNativeValidity.js +32 -0
- package/dist/utils/useNativeValidity.js.map +1 -0
- package/docs/assets/highlight.css +7 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/index.Pop.html +7 -7
- package/docs/documents/Test.html +2 -2
- package/docs/enums/index.ICON.html +3 -2
- package/docs/functions/index.Action.html +3 -3
- package/docs/functions/index.Button.html +4 -4
- package/docs/functions/index.Card.html +3 -3
- package/docs/functions/index.Checkbox.html +3 -3
- package/docs/functions/index.Choice.html +2 -2
- package/docs/functions/index.ColorPicker.html +3 -3
- package/docs/functions/index.CoveringLoader.html +3 -3
- package/docs/functions/index.DirectionPad.html +2 -2
- package/docs/functions/index.Drawer.html +2 -2
- package/docs/functions/index.EqualActions.html +2 -2
- package/docs/functions/index.FullLoader.html +3 -3
- package/docs/functions/index.Gap.html +3 -3
- package/docs/functions/index.HandleEsc.html +3 -3
- package/docs/functions/index.Header.html +3 -3
- package/docs/functions/index.HeaderIconAction.html +3 -3
- package/docs/functions/index.Icon-1.html +2 -2
- package/docs/functions/index.If.html +3 -3
- package/docs/functions/index.Input.html +1 -1
- package/docs/functions/index.KeyValue.html +2 -2
- package/docs/functions/index.Label.html +2 -2
- package/docs/functions/index.Line.html +4 -4
- package/docs/functions/index.List.html +2 -2
- package/docs/functions/index.Loader.html +3 -3
- package/docs/functions/index.Loading.html +3 -3
- package/docs/functions/index.Message.html +4 -4
- package/docs/functions/index.Modal.html +2 -2
- package/docs/functions/index.ModalButtons.html +3 -3
- package/docs/functions/index.PopLoader.html +3 -3
- package/docs/functions/index.PopOption.html +2 -2
- package/docs/functions/index.Progress.html +2 -2
- package/docs/functions/index.SearchContainer.html +3 -3
- package/docs/functions/index.Section.html +4 -4
- package/docs/functions/index.Select.html +3 -3
- package/docs/functions/index.Selector.html +2 -2
- package/docs/functions/index.Spacer.html +3 -3
- package/docs/functions/index.Stats.html +2 -2
- package/docs/functions/index.StickyHeader.html +4 -4
- package/docs/functions/index.Table.html +3 -3
- package/docs/functions/index.TextArea.html +2 -2
- package/docs/functions/index.TimePicker.html +10 -0
- package/docs/functions/index.ToasterProvider.html +3 -3
- package/docs/functions/index.Toggle.html +3 -3
- package/docs/functions/index.ToolButton.html +4 -4
- package/docs/functions/index.Tooltip.html +18 -0
- package/docs/functions/index.TooltipProvider.html +6 -0
- package/docs/functions/index.borderPxToRem.html +1 -1
- package/docs/functions/index.createTheme.html +1 -1
- package/docs/functions/index.css.html +1 -1
- package/docs/functions/index.dimensionsPxToRem.html +1 -1
- package/docs/functions/index.fontPxToRem.html +1 -1
- package/docs/functions/index.getCssText.html +1 -1
- package/docs/functions/index.globalCss.html +2 -2
- package/docs/functions/index.injectGlobalStyles.html +1 -1
- package/docs/functions/index.keyframes.html +1 -1
- package/docs/functions/index.pxToRem.html +1 -1
- package/docs/functions/index.styled.html +1 -1
- package/docs/functions/index.toast.html +2 -2
- package/docs/functions/index.useToaster.html +1 -1
- package/docs/index.html +2 -2
- package/docs/interfaces/index.IconProps.html +2 -2
- package/docs/interfaces/index.InputCustomProps.html +3 -3
- package/docs/interfaces/index.LoaderProps.html +6 -6
- package/docs/interfaces/index.StickyHeaderProps.html +4 -4
- package/docs/interfaces/index.ToasterProviderProps.html +3 -3
- package/docs/interfaces/index.TooltipProps.html +36 -0
- package/docs/interfaces/index.TooltipProviderProps.html +13 -0
- package/docs/modules/index.html +1 -1
- package/docs/modules.html +1 -1
- package/docs/types/index.ActionProps.html +1 -1
- package/docs/types/index.CardProps.html +1 -1
- package/docs/types/index.CheckboxProps.html +2 -2
- package/docs/types/index.ChoiceProps.html +1 -1
- package/docs/types/index.ColorPickerProps.html +1 -1
- package/docs/types/index.DirectionPadProps.html +1 -1
- package/docs/types/index.DrawerFrom.html +1 -0
- package/docs/types/index.DrawerProps.html +28 -1
- package/docs/types/index.EqualActionsProps.html +1 -1
- package/docs/types/index.HeaderProps.html +1 -1
- package/docs/types/index.InputProps.html +1 -1
- package/docs/types/index.KeyValueProps.html +1 -1
- package/docs/types/index.LabelProps.html +1 -1
- package/docs/types/index.OverwriteProps.html +1 -1
- package/docs/types/index.ProgressProps.html +2 -2
- package/docs/types/index.SelectProps.html +1 -1
- package/docs/types/index.SelectorProps.html +1 -1
- package/docs/types/index.Stat.html +1 -1
- package/docs/types/index.StatsProps.html +1 -1
- package/docs/types/index.TextAreaProps.html +1 -1
- package/docs/types/index.ThemeCSS.html +1 -1
- package/docs/types/index.TimePickerProps.html +1 -0
- package/docs/types/index.ToggleProps.html +2 -2
- package/docs/variables/index.ActionBadgeSelector.html +1 -1
- package/docs/variables/index.ActionCircleSelector.html +1 -1
- package/docs/variables/index.CheckboxCheckmarkWrapperSelector.html +1 -1
- package/docs/variables/index.CheckboxTextLabelSelector.html +1 -1
- package/docs/variables/index.ChoiceItemSelector.html +1 -1
- package/docs/variables/index.ColorPickerColorDisplaySelector.html +1 -1
- package/docs/variables/index.DirectionPadButtonDotSelector.html +1 -1
- package/docs/variables/index.DirectionPadButtonSelector.html +1 -1
- package/docs/variables/index.DirectionPadLineSelector.html +1 -1
- package/docs/variables/index.DirectionPadMiddleSelector.html +1 -1
- package/docs/variables/index.DrawerContentSelector.html +1 -1
- package/docs/variables/index.HeaderAfterSelector.html +1 -1
- package/docs/variables/index.HeaderBeforeSelector.html +1 -1
- package/docs/variables/index.HeaderContentsSelector.html +1 -1
- package/docs/variables/index.HeaderIconActionIconSelector.html +1 -1
- package/docs/variables/index.InputContainerSelector.html +1 -1
- package/docs/variables/index.InputInputSelector.html +1 -1
- package/docs/variables/index.InputLabelSelector.html +1 -1
- package/docs/variables/index.InputPrefixSelector.html +1 -1
- package/docs/variables/index.InputSuffixSelector.html +1 -1
- package/docs/variables/index.KeyValueIconSelector.html +1 -1
- package/docs/variables/index.KeyValueItemSelector.html +1 -1
- package/docs/variables/index.KeyValueKeySelector.html +1 -1
- package/docs/variables/index.KeyValuePairSelector.html +1 -1
- package/docs/variables/index.KeyValueValueSelector.html +1 -1
- package/docs/variables/index.LabelTextSelector.html +1 -1
- package/docs/variables/index.ListItemInnerContainerClassNameSelector.html +1 -1
- package/docs/variables/index.ModalContainerSelector.html +1 -1
- package/docs/variables/index.ModalRemovePaddingSelector.html +1 -1
- package/docs/variables/index.ModalTitleSelector.html +1 -1
- package/docs/variables/index.PopListSelector.html +1 -1
- package/docs/variables/index.PopOptionButtonSelector.html +1 -1
- package/docs/variables/index.PopOptionIconSelector.html +1 -1
- package/docs/variables/index.PopOverlaySelector.html +1 -1
- package/docs/variables/index.ProgressBackgroundSelector.html +1 -1
- package/docs/variables/index.ProgressValueSelector.html +1 -1
- package/docs/variables/index.SelectorItemSelector.html +1 -1
- package/docs/variables/index.StatsItemSelector.html +1 -1
- package/docs/variables/index.StatsLabelSelector.html +1 -1
- package/docs/variables/index.StatsSeparatorSelector.html +1 -1
- package/docs/variables/index.StatsValueSelector.html +1 -1
- package/docs/variables/index.TextAreaLabelSelector.html +1 -1
- package/docs/variables/index.TextAreaTextAreaSelector.html +1 -1
- package/docs/variables/index.TextAreaWrapperSelector.html +1 -1
- package/docs/variables/index.ToggleStyledToggleSelector.html +1 -1
- package/docs/variables/index.TooltipContentSelector.html +1 -0
- package/docs/variables/index.config.html +1 -1
- package/docs/variables/index.cssReset.html +2 -2
- package/docs/variables/index.darkTheme.html +1 -1
- package/docs/variables/index.miuiScrollbars.html +1 -1
- package/docs/variables/index.theme.html +1 -1
- package/esm/components/form/index.d.ts +1 -0
- package/esm/components/form/index.d.ts.map +1 -1
- package/esm/components/form/index.js +1 -0
- package/esm/components/form/index.js.map +1 -1
- package/esm/components/form/input/Input.d.ts.map +1 -1
- package/esm/components/form/input/Input.js +9 -5
- package/esm/components/form/input/Input.js.map +1 -1
- package/esm/components/form/timepicker/TimePicker.css.d.ts +99 -0
- package/esm/components/form/timepicker/TimePicker.css.d.ts.map +1 -0
- package/esm/components/form/timepicker/TimePicker.css.js +102 -0
- package/esm/components/form/timepicker/TimePicker.css.js.map +1 -0
- package/esm/components/form/timepicker/TimePicker.d.ts +22 -0
- package/esm/components/form/timepicker/TimePicker.d.ts.map +1 -0
- package/esm/components/form/timepicker/TimePicker.js +93 -0
- package/esm/components/form/timepicker/TimePicker.js.map +1 -0
- package/esm/components/form/timepicker/TimePicker.styled.d.ts +936 -0
- package/esm/components/form/timepicker/TimePicker.styled.d.ts.map +1 -0
- package/esm/components/form/timepicker/TimePicker.styled.js +20 -0
- package/esm/components/form/timepicker/TimePicker.styled.js.map +1 -0
- package/esm/components/form/timepicker/TimePickerModal.d.ts +17 -0
- package/esm/components/form/timepicker/TimePickerModal.d.ts.map +1 -0
- package/esm/components/form/timepicker/TimePickerModal.js +56 -0
- package/esm/components/form/timepicker/TimePickerModal.js.map +1 -0
- package/esm/components/form/timepicker/Wheel.d.ts +12 -0
- package/esm/components/form/timepicker/Wheel.d.ts.map +1 -0
- package/esm/components/form/timepicker/Wheel.js +151 -0
- package/esm/components/form/timepicker/Wheel.js.map +1 -0
- package/esm/components/form/timepicker/utils.d.ts +4 -0
- package/esm/components/form/timepicker/utils.d.ts.map +1 -0
- package/esm/components/form/timepicker/utils.js +58 -0
- package/esm/components/form/timepicker/utils.js.map +1 -0
- package/esm/components/icons/Clock.d.ts +7 -0
- package/esm/components/icons/Clock.d.ts.map +1 -0
- package/esm/components/icons/Clock.js +9 -0
- package/esm/components/icons/Clock.js.map +1 -0
- package/esm/components/icons/Icon.d.ts +2 -1
- package/esm/components/icons/Icon.d.ts.map +1 -1
- package/esm/components/icons/Icon.js +3 -0
- package/esm/components/icons/Icon.js.map +1 -1
- package/esm/components/ui/drawer/Drawer.d.ts +10 -1
- package/esm/components/ui/drawer/Drawer.d.ts.map +1 -1
- package/esm/components/ui/drawer/Drawer.js +139 -15
- package/esm/components/ui/drawer/Drawer.js.map +1 -1
- package/esm/components/ui/drawer/Drawer.styled.d.ts +86 -1
- package/esm/components/ui/drawer/Drawer.styled.d.ts.map +1 -1
- package/esm/components/ui/drawer/Drawer.styled.js +12 -1
- package/esm/components/ui/drawer/Drawer.styled.js.map +1 -1
- package/esm/components/ui/modal/Modal.d.ts +1 -2
- package/esm/components/ui/modal/Modal.d.ts.map +1 -1
- package/esm/components/ui/modal/Modal.js +103 -43
- package/esm/components/ui/modal/Modal.js.map +1 -1
- package/esm/components/ui/modal/Modal.styled.d.ts +1 -1
- package/esm/components/ui/modal/Modal.styled.d.ts.map +1 -1
- package/esm/components/ui/modal/Modal.styled.js +40 -25
- package/esm/components/ui/modal/Modal.styled.js.map +1 -1
- package/esm/components/ui/toaster/Toaster.d.ts.map +1 -1
- package/esm/components/ui/toaster/Toaster.js +8 -2
- package/esm/components/ui/toaster/Toaster.js.map +1 -1
- package/esm/components/ui/tooltip/Tooltip.d.ts +30 -0
- package/esm/components/ui/tooltip/Tooltip.d.ts.map +1 -0
- package/esm/components/ui/tooltip/Tooltip.js +43 -0
- package/esm/components/ui/tooltip/Tooltip.js.map +1 -0
- package/esm/components/ui/tooltip/Tooltip.styled.d.ts +173 -0
- package/esm/components/ui/tooltip/Tooltip.styled.d.ts.map +1 -0
- package/esm/components/ui/tooltip/Tooltip.styled.js +28 -0
- package/esm/components/ui/tooltip/Tooltip.styled.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/theme.css-global.d.ts.map +1 -1
- package/esm/theme.css-global.js +0 -1
- package/esm/theme.css-global.js.map +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/useNativeValidity.d.ts +11 -0
- package/esm/utils/useNativeValidity.d.ts.map +1 -0
- package/esm/utils/useNativeValidity.js +29 -0
- package/esm/utils/useNativeValidity.js.map +1 -0
- package/package.json +2 -1
- package/pnpm-workspace.yaml +3 -0
- package/src/bugfixes/ToastsFromModal.stories.tsx +59 -0
- package/src/components/form/index.ts +1 -0
- package/src/components/form/input/Input.stories.tsx +47 -1
- package/src/components/form/input/Input.tsx +11 -5
- package/src/components/form/timepicker/TimePicker.css.ts +132 -0
- package/src/components/form/timepicker/TimePicker.stories.tsx +107 -0
- package/src/components/form/timepicker/TimePicker.styled.ts +52 -0
- package/src/components/form/timepicker/TimePicker.tsx +229 -0
- package/src/components/form/timepicker/TimePickerModal.tsx +131 -0
- package/src/components/form/timepicker/Wheel.tsx +201 -0
- package/src/components/form/timepicker/utils.ts +66 -0
- package/src/components/icons/Clock.tsx +38 -0
- package/src/components/icons/Icon.tsx +3 -0
- package/src/components/ui/drawer/Drawer.stories.tsx +143 -59
- package/src/components/ui/drawer/Drawer.styled.ts +13 -0
- package/src/components/ui/drawer/Drawer.tsx +214 -20
- package/src/components/ui/modal/Modal.stories.tsx +43 -7
- package/src/components/ui/modal/Modal.styled.ts +46 -25
- package/src/components/ui/modal/Modal.tsx +135 -52
- package/src/components/ui/toaster/Toaster.tsx +12 -2
- package/src/components/ui/tooltip/Tooltip.stories.tsx +285 -0
- package/src/components/ui/tooltip/Tooltip.styled.ts +36 -0
- package/src/components/ui/tooltip/Tooltip.tsx +195 -0
- package/src/index.ts +1 -0
- package/src/theme.css-global.ts +0 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/useNativeValidity.ts +57 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as RadixTooltip from "@radix-ui/react-tooltip";
|
|
2
|
+
|
|
3
|
+
import { dimensionsPxToRem, fontPxToRem, keyframes, pxToRem, styled } from "../../../theme";
|
|
4
|
+
|
|
5
|
+
const fadeIn = keyframes({
|
|
6
|
+
from: { opacity: 0, transform: "scale(0.96)" },
|
|
7
|
+
to: { opacity: 1, transform: "scale(1)" },
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const StyledContent = styled(RadixTooltip.Content, {
|
|
11
|
+
"zIndex": 10,
|
|
12
|
+
"background": "$text2",
|
|
13
|
+
"color": "$background",
|
|
14
|
+
"padding": `${dimensionsPxToRem(18)} ${dimensionsPxToRem(36)}`,
|
|
15
|
+
"borderRadius": dimensionsPxToRem(12),
|
|
16
|
+
"fontSize": fontPxToRem(24),
|
|
17
|
+
"lineHeight": 1.3,
|
|
18
|
+
"maxWidth": pxToRem(280),
|
|
19
|
+
"boxShadow": `0 ${pxToRem(2)} ${pxToRem(8)} rgba(0, 0, 0, 0.18)`,
|
|
20
|
+
"userSelect": "none",
|
|
21
|
+
"transformOrigin": "var(--radix-tooltip-content-transform-origin)",
|
|
22
|
+
"animation": `${fadeIn.toString()} 120ms ease-out`,
|
|
23
|
+
|
|
24
|
+
"&[data-state=\"closed\"]": {
|
|
25
|
+
animationDirection: "reverse",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const StyledArrow = styled(RadixTooltip.Arrow, {
|
|
30
|
+
fill: "$text2",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
StyledContent,
|
|
35
|
+
StyledArrow,
|
|
36
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import * as RadixTooltip from "@radix-ui/react-tooltip";
|
|
4
|
+
|
|
5
|
+
import { StyledArrow, StyledContent } from "./Tooltip.styled";
|
|
6
|
+
|
|
7
|
+
type Side = "top" | "right" | "bottom" | "left";
|
|
8
|
+
type Align = "start" | "center" | "end";
|
|
9
|
+
|
|
10
|
+
interface TooltipProviderProps {
|
|
11
|
+
/**
|
|
12
|
+
* The duration from when the pointer enters the trigger until the tooltip opens, in milliseconds.
|
|
13
|
+
* Default: `500`.
|
|
14
|
+
*/
|
|
15
|
+
delayDuration?: number;
|
|
16
|
+
/**
|
|
17
|
+
* If a tooltip has opened, the duration during which other tooltips open instantly
|
|
18
|
+
* (without waiting for `delayDuration`), in milliseconds.
|
|
19
|
+
* Default: `300`.
|
|
20
|
+
*/
|
|
21
|
+
skipDelayDuration?: number;
|
|
22
|
+
/**
|
|
23
|
+
* When `true`, the tooltip content stays open while the pointer is over it.
|
|
24
|
+
* Set to `false` for stricter "hover the trigger only" behavior.
|
|
25
|
+
* Default: `true`.
|
|
26
|
+
*/
|
|
27
|
+
disableHoverableContent?: boolean;
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Required wrapper for `<Tooltip>`. Render it once near the root of your app — usually
|
|
33
|
+
* around (or just inside) your top-level layout. It enables group-delay behavior via
|
|
34
|
+
* `skipDelayDuration`: once one tooltip in the subtree has been seen, the next ones
|
|
35
|
+
* open without waiting for `delayDuration`.
|
|
36
|
+
*
|
|
37
|
+
* A single `<Tooltip>` without a `<TooltipProvider>` ancestor will throw at runtime.
|
|
38
|
+
*/
|
|
39
|
+
const TooltipProvider = (props: TooltipProviderProps) => {
|
|
40
|
+
const radixProps: Omit<React.ComponentProps<typeof RadixTooltip.Provider>, "children"> = {};
|
|
41
|
+
if (props.delayDuration !== undefined) { radixProps.delayDuration = props.delayDuration; }
|
|
42
|
+
if (props.skipDelayDuration !== undefined) { radixProps.skipDelayDuration = props.skipDelayDuration; }
|
|
43
|
+
if (props.disableHoverableContent !== undefined) {
|
|
44
|
+
radixProps.disableHoverableContent = props.disableHoverableContent;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<RadixTooltip.Provider {...radixProps}>
|
|
49
|
+
{props.children}
|
|
50
|
+
</RadixTooltip.Provider>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
interface TooltipProps {
|
|
55
|
+
/**
|
|
56
|
+
* The content to render inside the tooltip.
|
|
57
|
+
*/
|
|
58
|
+
content: React.ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* Preferred side of the trigger to render the tooltip against. Will be flipped
|
|
61
|
+
* automatically on collision unless `avoidCollisions` is `false`.
|
|
62
|
+
* Default: `"top"`.
|
|
63
|
+
*/
|
|
64
|
+
side?: Side;
|
|
65
|
+
/**
|
|
66
|
+
* Distance in pixels between the trigger and the tooltip.
|
|
67
|
+
* Default: `6`.
|
|
68
|
+
*/
|
|
69
|
+
sideOffset?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Alignment along the chosen side.
|
|
72
|
+
* Default: `"center"`.
|
|
73
|
+
*/
|
|
74
|
+
align?: Align;
|
|
75
|
+
/**
|
|
76
|
+
* Offset in pixels from the `align` edge.
|
|
77
|
+
* Default: `0`.
|
|
78
|
+
*/
|
|
79
|
+
alignOffset?: number;
|
|
80
|
+
/**
|
|
81
|
+
* The duration from when the pointer enters the trigger until the tooltip opens.
|
|
82
|
+
* Overrides the provider's `delayDuration` for this tooltip only.
|
|
83
|
+
*/
|
|
84
|
+
delayDuration?: number;
|
|
85
|
+
/**
|
|
86
|
+
* When `true`, the tooltip will not flip to the opposite side on collision.
|
|
87
|
+
* Default: `true` (collisions are avoided).
|
|
88
|
+
*/
|
|
89
|
+
avoidCollisions?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* When `true`, renders an arrow pointing at the trigger.
|
|
92
|
+
* Default: `true`.
|
|
93
|
+
*/
|
|
94
|
+
arrow?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Controlled open state. If omitted, the tooltip is uncontrolled.
|
|
97
|
+
*/
|
|
98
|
+
open?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Initial open state for the uncontrolled mode.
|
|
101
|
+
*/
|
|
102
|
+
defaultOpen?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Called when the open state changes.
|
|
105
|
+
*/
|
|
106
|
+
onOpenChange?: (open: boolean) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Additional class name applied to the tooltip content.
|
|
109
|
+
*/
|
|
110
|
+
className?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The element that triggers the tooltip on hover/focus. Must be a single React element
|
|
113
|
+
* that can receive a ref and event handlers (a DOM element or a component using forwardRef).
|
|
114
|
+
*/
|
|
115
|
+
children: React.ReactElement;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* A tooltip that appears on hover or keyboard focus of its child trigger.
|
|
120
|
+
*
|
|
121
|
+
* Powered by Radix UI under the hood, so accessibility (ARIA, focus, escape, group delay)
|
|
122
|
+
* is handled. The content is portalled to `document.body`, so it escapes stacking contexts
|
|
123
|
+
* and renders above modals/drawers.
|
|
124
|
+
*
|
|
125
|
+
* Requires a `<TooltipProvider>` somewhere up the tree.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```tsx
|
|
129
|
+
* <TooltipProvider>
|
|
130
|
+
* <Tooltip content="Save changes" side="bottom">
|
|
131
|
+
* <Button>Save</Button>
|
|
132
|
+
* </Tooltip>
|
|
133
|
+
* </TooltipProvider>
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
// eslint-disable-next-line react/no-multi-comp
|
|
137
|
+
const Tooltip = forwardRef<HTMLDivElement, TooltipProps>((props, ref) => {
|
|
138
|
+
const {
|
|
139
|
+
content,
|
|
140
|
+
side = "top",
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
142
|
+
sideOffset = 6,
|
|
143
|
+
align = "center",
|
|
144
|
+
alignOffset = 0,
|
|
145
|
+
delayDuration,
|
|
146
|
+
avoidCollisions = true,
|
|
147
|
+
arrow = true,
|
|
148
|
+
open,
|
|
149
|
+
defaultOpen,
|
|
150
|
+
onOpenChange,
|
|
151
|
+
className,
|
|
152
|
+
children,
|
|
153
|
+
} = props;
|
|
154
|
+
|
|
155
|
+
const rootProps: React.ComponentProps<typeof RadixTooltip.Root> = {};
|
|
156
|
+
if (open !== undefined) { rootProps.open = open; }
|
|
157
|
+
if (defaultOpen !== undefined) { rootProps.defaultOpen = defaultOpen; }
|
|
158
|
+
if (onOpenChange !== undefined) { rootProps.onOpenChange = onOpenChange; }
|
|
159
|
+
if (delayDuration !== undefined) { rootProps.delayDuration = delayDuration; }
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<RadixTooltip.Root {...rootProps}>
|
|
163
|
+
<RadixTooltip.Trigger asChild={true}>
|
|
164
|
+
{children}
|
|
165
|
+
</RadixTooltip.Trigger>
|
|
166
|
+
<RadixTooltip.Portal>
|
|
167
|
+
<StyledContent
|
|
168
|
+
ref={ref}
|
|
169
|
+
side={side}
|
|
170
|
+
sideOffset={sideOffset}
|
|
171
|
+
align={align}
|
|
172
|
+
alignOffset={alignOffset}
|
|
173
|
+
avoidCollisions={avoidCollisions}
|
|
174
|
+
className={className}
|
|
175
|
+
>
|
|
176
|
+
{content}
|
|
177
|
+
{/* eslint-disable-next-line react/jsx-no-leaked-render */}
|
|
178
|
+
{arrow && <StyledArrow width={10} height={5} />}
|
|
179
|
+
</StyledContent>
|
|
180
|
+
</RadixTooltip.Portal>
|
|
181
|
+
</RadixTooltip.Root>
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
Tooltip.displayName = "Tooltip";
|
|
186
|
+
Tooltip.toString = () => StyledContent.toString();
|
|
187
|
+
|
|
188
|
+
const TooltipContentSelector = StyledContent.toString();
|
|
189
|
+
|
|
190
|
+
export {
|
|
191
|
+
Tooltip,
|
|
192
|
+
TooltipProvider,
|
|
193
|
+
TooltipContentSelector,
|
|
194
|
+
};
|
|
195
|
+
export type { TooltipProps, TooltipProviderProps };
|
package/src/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ export * from "./components/ui/stats/Stats";
|
|
|
42
42
|
export * from "./components/ui/tabs/Selector";
|
|
43
43
|
export * from "./components/ui/toaster/Toaster";
|
|
44
44
|
export * from "./components/ui/toolButton/ToolButton";
|
|
45
|
+
export * from "./components/ui/tooltip/Tooltip";
|
|
45
46
|
|
|
46
47
|
export * from "./components/utils/Gap";
|
|
47
48
|
export * from "./components/utils/HandleEsc";
|
package/src/theme.css-global.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import type React from "react";
|
|
4
|
+
|
|
5
|
+
interface UseNativeValidityResult {
|
|
6
|
+
/** Combined: the explicit `error` prop OR the input's native invalid state. Pass to your `error`/styling. */
|
|
7
|
+
finalError: boolean;
|
|
8
|
+
/** Re-checks validity. Call from your `onBlur`. */
|
|
9
|
+
onBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
10
|
+
/** Clears the invalid flag if the value just became valid. Call from your `onChange`. */
|
|
11
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
|
+
/** Fires when the form tries to submit an invalid value. Call from your `onInvalid`. */
|
|
13
|
+
onInvalid: () => void;
|
|
14
|
+
/** Clears the invalid flag if the input is currently valid. Useful after programmatic value changes. */
|
|
15
|
+
revalidate: (input: HTMLInputElement | null) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Tracks native HTML5 validity (pattern, required, type=email/url, etc.) and surfaces it
|
|
20
|
+
* as an `error` boolean — the rule mirrors the CSS `:user-invalid` pseudo-class:
|
|
21
|
+
* invalid is sticky after blur or a failed submit, and clears as soon as the value becomes valid.
|
|
22
|
+
*
|
|
23
|
+
* Compose the returned handlers with your component's own `onBlur` / `onChange` / `onInvalid`.
|
|
24
|
+
*/
|
|
25
|
+
const useNativeValidity = (error: boolean | undefined): UseNativeValidityResult => {
|
|
26
|
+
const [nativeInvalid, setNativeInvalid] = useState(false);
|
|
27
|
+
|
|
28
|
+
const onBlur = useCallback((e: React.FocusEvent<HTMLInputElement>) => {
|
|
29
|
+
setNativeInvalid(!e.currentTarget.checkValidity());
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
const onChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
33
|
+
if (e.currentTarget.checkValidity()) {
|
|
34
|
+
setNativeInvalid(false);
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
const onInvalid = useCallback(() => {
|
|
39
|
+
setNativeInvalid(true);
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
const revalidate = useCallback((input: HTMLInputElement | null) => {
|
|
43
|
+
if (input?.checkValidity()) {
|
|
44
|
+
setNativeInvalid(false);
|
|
45
|
+
}
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
finalError: Boolean(error) || nativeInvalid,
|
|
50
|
+
onBlur,
|
|
51
|
+
onChange,
|
|
52
|
+
onInvalid,
|
|
53
|
+
revalidate,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { useNativeValidity };
|