@algolia/satellite 1.0.0-beta.160 → 1.0.0-beta.161

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.
Files changed (80) hide show
  1. package/cjs/AutoComplete/AutoComplete.tailwind.js +4 -1
  2. package/cjs/Button/PolymorphicIconButton.d.ts +1 -1
  3. package/cjs/Button/PolymorphicIconButton.js +4 -4
  4. package/cjs/Checkbox/Checkbox.js +3 -3
  5. package/cjs/Checkbox/Checkbox.tailwind.js +1 -1
  6. package/cjs/HelpUnderline/HelpUnderline.d.ts +3 -4
  7. package/cjs/HelpUnderline/HelpUnderline.js +13 -10
  8. package/cjs/Input/Input.tailwind.js +28 -4
  9. package/cjs/RadioGroup/RadioButton.tailwind.js +4 -1
  10. package/cjs/RangeSlider/RangeSlider.js +2 -2
  11. package/cjs/Satellite/Satellite.d.ts +0 -1
  12. package/cjs/Satellite/Satellite.js +12 -17
  13. package/cjs/Satellite/SatelliteContext.d.ts +1 -1
  14. package/cjs/Satellite/SatelliteContext.js +2 -1
  15. package/cjs/Select/Select.tailwind.js +2 -2
  16. package/cjs/Separator/Separator.d.ts +8 -0
  17. package/cjs/Separator/Separator.js +29 -0
  18. package/cjs/Separator/Separator.tailwind.d.ts +5 -0
  19. package/cjs/Separator/Separator.tailwind.js +25 -0
  20. package/cjs/Separator/index.d.ts +2 -0
  21. package/cjs/Separator/index.js +27 -0
  22. package/cjs/Sidebar/SidebarButtonLink.js +8 -14
  23. package/cjs/Tag/Tag.js +7 -7
  24. package/cjs/Toggle/Toggle.js +3 -13
  25. package/cjs/Toggle/Toggle.tailwind.js +8 -2
  26. package/cjs/Tooltip/OverflowTooltipWrapper.d.ts +2 -5
  27. package/cjs/Tooltip/OverflowTooltipWrapper.js +20 -78
  28. package/cjs/Tooltip/Tooltip.d.ts +6 -6
  29. package/cjs/Tooltip/Tooltip.js +6 -6
  30. package/cjs/Tooltip/Tooltip.tailwind.js +85 -62
  31. package/cjs/Tooltip/TooltipWrapper.d.ts +8 -21
  32. package/cjs/Tooltip/TooltipWrapper.js +49 -158
  33. package/cjs/Tooltip/types.d.ts +57 -6
  34. package/cjs/Tooltip/utils.d.ts +1 -0
  35. package/cjs/Tooltip/utils.js +10 -0
  36. package/cjs/index.d.ts +2 -1
  37. package/cjs/index.js +20 -8
  38. package/cjs/styles/tailwind.config.js +1 -1
  39. package/cjs/types.d.ts +6 -6
  40. package/esm/AutoComplete/AutoComplete.tailwind.js +4 -1
  41. package/esm/Button/PolymorphicIconButton.d.ts +1 -1
  42. package/esm/Button/PolymorphicIconButton.js +4 -4
  43. package/esm/Checkbox/Checkbox.js +3 -3
  44. package/esm/Checkbox/Checkbox.tailwind.js +1 -1
  45. package/esm/HelpUnderline/HelpUnderline.d.ts +3 -4
  46. package/esm/HelpUnderline/HelpUnderline.js +13 -10
  47. package/esm/Input/Input.tailwind.js +28 -4
  48. package/esm/RadioGroup/RadioButton.tailwind.js +4 -1
  49. package/esm/RangeSlider/RangeSlider.js +2 -2
  50. package/esm/Satellite/Satellite.d.ts +0 -1
  51. package/esm/Satellite/Satellite.js +13 -16
  52. package/esm/Satellite/SatelliteContext.d.ts +1 -1
  53. package/esm/Satellite/SatelliteContext.js +2 -1
  54. package/esm/Select/Select.tailwind.js +2 -2
  55. package/esm/Separator/Separator.d.ts +8 -0
  56. package/esm/Separator/Separator.js +17 -0
  57. package/esm/Separator/Separator.tailwind.d.ts +5 -0
  58. package/esm/Separator/Separator.tailwind.js +24 -0
  59. package/esm/Separator/index.d.ts +2 -0
  60. package/esm/Separator/index.js +2 -0
  61. package/esm/Sidebar/SidebarButtonLink.js +8 -14
  62. package/esm/Tag/Tag.js +7 -7
  63. package/esm/Toggle/Toggle.js +3 -13
  64. package/esm/Toggle/Toggle.tailwind.js +8 -2
  65. package/esm/Tooltip/OverflowTooltipWrapper.d.ts +2 -5
  66. package/esm/Tooltip/OverflowTooltipWrapper.js +20 -78
  67. package/esm/Tooltip/Tooltip.d.ts +6 -6
  68. package/esm/Tooltip/Tooltip.js +6 -6
  69. package/esm/Tooltip/Tooltip.tailwind.js +84 -62
  70. package/esm/Tooltip/TooltipWrapper.d.ts +8 -21
  71. package/esm/Tooltip/TooltipWrapper.js +47 -157
  72. package/esm/Tooltip/types.d.ts +57 -6
  73. package/esm/Tooltip/utils.d.ts +1 -0
  74. package/esm/Tooltip/utils.js +3 -0
  75. package/esm/index.d.ts +2 -1
  76. package/esm/index.js +2 -1
  77. package/esm/styles/tailwind.config.js +1 -1
  78. package/esm/types.d.ts +6 -6
  79. package/package.json +3 -1
  80. package/satellite.min.css +1 -1
@@ -18,18 +18,18 @@ var VARIANT_CLASSNAMES = {
18
18
  * Tooltips are floating labels that briefly explain the function of a user interface element. They can be triggered when merchants hover, focus, tap, or click.
19
19
  *
20
20
  * Use tooltips to identify or add a small amount of information to an element. Typically, tooltips are used to help users understand the meaning or purpose of icons, showing the full version of truncated text, or displaying the alt text for an image. Tooltips do not receive input focus.
21
- * When writing tooltips, be short and concise.. When you need to add more than a single line of extra information, consider using inline dialogs instead.
21
+ * When writing tooltips, be short and concise. When you need to add more than a single line of extra information, consider using inline dialogs instead.
22
22
  *
23
23
  * The position of tooltips is flexible and will change depending on how close the element is to the edge of the screen.
24
24
  *
25
25
  * ## Best practices
26
26
  * Tooltips should:
27
27
  *
28
- * - Provide useful, additional information or clarification
29
- * - Succinctly describe or expand on the element they point to
30
- * - Not be used to communicate critical information, including errors in forms or other interaction feedback
31
- * - Not contain any links or buttons
32
- * - Be used sparingly. If you're building something that requires a lot of tooltips, work on clarifying the design and the language in the experience
28
+ * - Provide useful, additional information or clarification.
29
+ * - Succinctly describe or expand on the element they point to.
30
+ * - Not be used to communicate critical information, including errors in forms or other interaction feedback.
31
+ * - Not contain any links, inputs, or buttons.
32
+ * - Be used sparingly. If you're building something that requires a lot of tooltips, work on clarifying the design and the language in the experience.
33
33
  */
34
34
  export var Tooltip = /*#__PURE__*/forwardRef(function (_ref, ref) {
35
35
  var className = _ref.className,
@@ -4,12 +4,12 @@ var plugin = _plugin;
4
4
  var tooltipPlugin = plugin(function (_ref) {
5
5
  var addComponents = _ref.addComponents,
6
6
  theme = _ref.theme;
7
- var arrowSize = 4;
8
-
9
7
  /** @type {string} */
10
8
  var tooltipDarkBackground = theme("colors.grey.900");
11
9
  /** @type {string} */
12
10
  var tooltipLightBackground = theme("colors.white");
11
+ var animationDuration = "100ms";
12
+ var animationEasing = "cubic-bezier(.17,.61,.4,.95)";
13
13
  addComponents({
14
14
  ".tooltip": {
15
15
  padding: "".concat(theme("spacing.1"), " ").concat(theme("spacing.2")),
@@ -38,76 +38,98 @@ var tooltipPlugin = plugin(function (_ref) {
38
38
  }
39
39
  });
40
40
  addComponents({
41
- ".tooltip-wrapper": {
42
- display: "inline-block",
43
- lineHeight: "0",
44
- outline: "0px"
45
- },
46
- ".tooltip-wrapper-popper": {
47
- zIndex: theme("zIndex.tooltip"),
48
- userSelect: "none",
49
- maxWidth: theme("spacing.64")
50
- },
51
- ".tooltip-wrapper-arrow": {
52
- position: "absolute",
53
- display: "block",
54
- width: "".concat(arrowSize, "px"),
55
- height: "".concat(arrowSize, "px"),
56
- border: "".concat(arrowSize, "px solid transparent"),
57
- color: tooltipDarkBackground,
58
- '[data-popper-placement^="right"] > &': {
59
- left: "".concat(-arrowSize, "px"),
60
- borderLeft: "none",
61
- borderRightColor: "currentColor"
62
- },
63
- '[data-popper-placement^="left"] > &': {
64
- right: "".concat(-arrowSize, "px"),
65
- borderRight: "none",
66
- borderLeftColor: "currentColor"
41
+ /* eslint-disable @algolia/satellite/prefer-stl-helper */
42
+ "@keyframes stl-tooltip-slide-down-and-fade": {
43
+ from: {
44
+ opacity: "0",
45
+ transform: "translateY(-2px)"
67
46
  },
68
- '[data-popper-placement^="top"] > &': {
69
- top: "100%",
70
- borderBottom: "none",
71
- borderTopColor: "currentColor"
47
+ to: {
48
+ opacity: "1",
49
+ transform: "translateY(0)"
50
+ }
51
+ },
52
+ "@keyframes stl-tooltip-slide-left-and-fade": {
53
+ from: {
54
+ opacity: "0",
55
+ transform: "translateX(2px)"
72
56
  },
73
- '[data-popper-placement^="bottom"] > &': {
74
- top: "".concat(-arrowSize, "px"),
75
- borderTop: "none",
76
- borderBottomColor: "currentColor"
57
+ to: {
58
+ opacity: "1",
59
+ transform: "translateX(0)"
77
60
  }
78
61
  },
79
- ".tooltip-wrapper-arrow-light": {
80
- color: theme("colors.shadow.10"),
81
- "&::after": {
82
- position: "absolute",
83
- content: '" "',
84
- border: "".concat(arrowSize - 1, "px solid transparent")
62
+ "@keyframes stl-tooltip-slide-up-and-fade": {
63
+ from: {
64
+ opacity: "0",
65
+ transform: "translateY(2px)"
85
66
  },
86
- '[data-popper-placement^="left"] > &::after': {
87
- right: "1px",
88
- transform: "translate(0, -50%)",
89
- borderRight: "none",
90
- borderLeftColor: tooltipLightBackground
67
+ to: {
68
+ opacity: "1",
69
+ transform: "translateY(0)"
70
+ }
71
+ },
72
+ "@keyframes stl-tooltip-slide-right-and-fade": {
73
+ from: {
74
+ opacity: "0",
75
+ transform: "translateX(-2px)"
91
76
  },
92
- '[data-popper-placement^="right"] > &::after': {
93
- left: "1px",
94
- transform: "translate(0, -50%)",
95
- borderLeft: "none",
96
- borderRightColor: tooltipLightBackground
77
+ to: {
78
+ opacity: "1",
79
+ transform: "translateX(0)"
80
+ }
81
+ },
82
+ "@keyframes stl-tooltip-fade-out": {
83
+ from: {
84
+ opacity: "1"
97
85
  },
98
- '[data-popper-placement^="top"] > &::after': {
99
- bottom: "1px",
100
- transform: "translate(-50%, 0)",
101
- borderBottom: "none",
102
- borderTopColor: tooltipLightBackground
86
+ to: {
87
+ opacity: "0"
88
+ }
89
+ },
90
+ ".tooltip-content": {
91
+ zIndex: theme("zIndex.tooltip"),
92
+ userSelect: "none",
93
+ maxWidth: theme("spacing.64"),
94
+ // Even if the user has enabled reduced motion or animate is `false`,
95
+ // we still need to keep this animation to handle the hide delay
96
+ '&[data-state="closed"]': {
97
+ animation: "stl-tooltip-fade-out 0ms linear var(--tooltip-hide-delay)"
103
98
  },
104
- '[data-popper-placement^="bottom"] > &::after': {
105
- top: "1px",
106
- transform: "translate(-50%, 0)",
107
- borderTop: "none",
108
- borderBottomColor: tooltipLightBackground
99
+ "@media (prefers-reduced-motion: no-preference)": {
100
+ willChange: "transform, opacity",
101
+ '&[data-state="delayed-open"]': {
102
+ '&[data-side="top"]': {
103
+ animation: "stl-tooltip-slide-down-and-fade ".concat(animationDuration, " ").concat(animationEasing)
104
+ },
105
+ '&[data-side="right"]': {
106
+ animation: "stl-tooltip-slide-left-and-fade ".concat(animationDuration, " ").concat(animationEasing)
107
+ },
108
+ '&[data-side="left"]': {
109
+ animation: "stl-tooltip-slide-right-and-fade ".concat(animationDuration, " ").concat(animationEasing)
110
+ },
111
+ '&[data-side="bottom"]': {
112
+ animation: "stl-tooltip-slide-up-and-fade ".concat(animationDuration, " ").concat(animationEasing)
113
+ }
114
+ },
115
+ '&[data-state="closed"]': {
116
+ animation: "stl-tooltip-fade-out ".concat(animationDuration, " ").concat(animationEasing, " var(--tooltip-hide-delay)")
117
+ }
109
118
  }
119
+ },
120
+ ".tooltip-arrow-dark": {
121
+ fill: tooltipDarkBackground
122
+ },
123
+ // Since Radix relies on a SVG for the arrow, we use the stroke property
124
+ // with a dash array/offset to create a border around the arrow.
125
+ ".tooltip-arrow-light": {
126
+ fill: tooltipLightBackground,
127
+ stroke: theme("colors.shadow.10"),
128
+ strokeWidth: "3px",
129
+ strokeDasharray: "36",
130
+ strokeDashoffset: "-30"
110
131
  }
132
+ /* eslint-enable @algolia/satellite/prefer-stl-helper */
111
133
  });
112
134
  });
113
135
  export default tooltipPlugin;
@@ -1,28 +1,15 @@
1
- import type { FunctionComponent, ReactNode } from "react";
2
- import { StrictModifier } from "react-popper";
1
+ import { ReactElement, ReactNode, ReactText } from "react";
3
2
  import type { TooltipWrapperBaseProps } from "./types";
4
- export declare const DEFAULT_TOOLTIP_POPPER_MODIFIERS: StrictModifier[];
5
3
  export interface TooltipWrapperProps extends TooltipWrapperBaseProps {
6
- show?: boolean;
7
- /**
8
- * Controls how long you should hover the wrapped element before displaying the tooltip (in ms)
9
- * @default 0
10
- * */
11
- delay?: number;
12
4
  /**
13
- * Controls how long the tooltip should stay displayed when leaving the wrapped element (in ms)
14
- * @default 500
15
- * */
16
- hideDelay?: number;
5
+ * Defines whether the tooltip should be displayed or not.
6
+ * @default undefined
7
+ */
8
+ show?: boolean;
17
9
  /**
18
- * Indicates whether the tooltip itself should be considered when computing the tooltip target.
19
- * Useful when the tooltip itself contains selectable text or interactive elements, and thus
20
- * shouldn't be dismissed when the mouse hovers it
21
- * @default true
10
+ * Defines the content of the tooltip.
22
11
  */
23
- interactive?: boolean;
24
12
  content: ReactNode;
25
- children: ReactNode;
13
+ children: ReactElement | ReactText;
26
14
  }
27
- export declare const TooltipWrapper: FunctionComponent<TooltipWrapperProps>;
28
- export default TooltipWrapper;
15
+ export declare const TooltipWrapper: ({ show, delay, hideDelay, content: tooltipContent, side, sideOffset, align, alignOffset, tooltipVariant, tooltipClassName, children, noArrow, interactive, avoidCollisions, }: TooltipWrapperProps) => JSX.Element;
@@ -1,183 +1,73 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
2
  var _templateObject, _templateObject2, _templateObject3;
6
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ import * as Tooltip from "@radix-ui/react-tooltip";
8
4
  import cx from "clsx";
9
- import throttle from "lodash/throttle";
10
- import { useCallback, useEffect, useRef, useState } from "react";
11
- import { usePopper } from "react-popper";
5
+ import { Fragment } from "react";
12
6
  import { useCreatePortal } from "../Satellite";
13
7
  import stl from "../styles/helpers/satellitePrefixer";
14
- import Tooltip from "./Tooltip";
8
+ import TooltipInternal from "./Tooltip";
15
9
  import { Fragment as _Fragment } from "react/jsx-runtime";
16
10
  import { jsx as _jsx } from "react/jsx-runtime";
17
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
- export var DEFAULT_TOOLTIP_POPPER_MODIFIERS = [{
19
- name: "offset",
20
- options: {
21
- offset: [0, 8]
22
- }
23
- }];
24
12
  export var TooltipWrapper = function TooltipWrapper(_ref) {
25
13
  var show = _ref.show,
26
14
  _ref$delay = _ref.delay,
27
- delay = _ref$delay === void 0 ? 0 : _ref$delay,
15
+ delay = _ref$delay === void 0 ? 250 : _ref$delay,
28
16
  _ref$hideDelay = _ref.hideDelay,
29
17
  hideDelay = _ref$hideDelay === void 0 ? 500 : _ref$hideDelay,
30
18
  tooltipContent = _ref.content,
31
- _ref$placement = _ref.placement,
32
- placement = _ref$placement === void 0 ? "bottom" : _ref$placement,
19
+ _ref$side = _ref.side,
20
+ side = _ref$side === void 0 ? "bottom" : _ref$side,
21
+ _ref$sideOffset = _ref.sideOffset,
22
+ sideOffset = _ref$sideOffset === void 0 ? 0 : _ref$sideOffset,
23
+ _ref$align = _ref.align,
24
+ align = _ref$align === void 0 ? "center" : _ref$align,
25
+ _ref$alignOffset = _ref.alignOffset,
26
+ alignOffset = _ref$alignOffset === void 0 ? 0 : _ref$alignOffset,
33
27
  _ref$tooltipVariant = _ref.tooltipVariant,
34
28
  tooltipVariant = _ref$tooltipVariant === void 0 ? "dark" : _ref$tooltipVariant,
35
- wrapperClassName = _ref.wrapperClassName,
36
29
  tooltipClassName = _ref.tooltipClassName,
37
30
  children = _ref.children,
38
- _ref$modifiers = _ref.modifiers,
39
- modifiers = _ref$modifiers === void 0 ? [] : _ref$modifiers,
40
31
  _ref$noArrow = _ref.noArrow,
41
32
  noArrow = _ref$noArrow === void 0 ? false : _ref$noArrow,
42
33
  _ref$interactive = _ref.interactive,
43
- interactive = _ref$interactive === void 0 ? true : _ref$interactive;
34
+ interactive = _ref$interactive === void 0 ? true : _ref$interactive,
35
+ _ref$avoidCollisions = _ref.avoidCollisions,
36
+ avoidCollisions = _ref$avoidCollisions === void 0 ? true : _ref$avoidCollisions;
44
37
  var createPortal = useCreatePortal();
45
- var isControlled = typeof show === "boolean";
46
- var _useState = useState(!!show),
47
- _useState2 = _slicedToArray(_useState, 2),
48
- internalShow = _useState2[0],
49
- setInternalShow = _useState2[1];
50
- var transitioning = useRef(undefined);
51
- useEffect(function () {
52
- if (!isControlled) return;
53
- setInternalShow(show);
54
- transitioning.current = undefined;
55
- }, [isControlled, show]);
56
- var _useState3 = useState(null),
57
- _useState4 = _slicedToArray(_useState3, 2),
58
- targetEl = _useState4[0],
59
- setTargetEl = _useState4[1];
60
- var _useState5 = useState(null),
61
- _useState6 = _slicedToArray(_useState5, 2),
62
- popperEl = _useState6[0],
63
- setPopperEl = _useState6[1];
64
- var _useState7 = useState(null),
65
- _useState8 = _slicedToArray(_useState7, 2),
66
- arrowEl = _useState8[0],
67
- setArrowEl = _useState8[1];
68
- var _usePopper = usePopper(targetEl, popperEl, {
69
- placement: placement,
70
- strategy: "fixed",
71
- modifiers: [].concat(DEFAULT_TOOLTIP_POPPER_MODIFIERS, [{
72
- name: "arrow",
73
- options: {
74
- element: arrowEl
75
- }
76
- }], _toConsumableArray(modifiers))
77
- }),
78
- styles = _usePopper.styles,
79
- attributes = _usePopper.attributes,
80
- update = _usePopper.update;
81
- var showTooltip = Boolean(internalShow && targetEl);
82
- var transitionTimeoutId = useRef();
83
- var scheduleTransition = useCallback(function (show, delay) {
84
- transitioning.current = show ? "will-show" : "will-hide";
85
- transitionTimeoutId.current = setTimeout(function () {
86
- transitioning.current = undefined;
87
- setInternalShow(show);
88
- }, delay);
89
- }, []);
90
- var cancelTransition = useCallback(function () {
91
- transitioning.current = undefined;
92
- if (transitionTimeoutId.current) {
93
- clearTimeout(transitionTimeoutId.current);
94
- transitionTimeoutId.current = undefined;
95
- }
96
- }, []);
97
- useEffect(function () {
98
- return function () {
99
- return cancelTransition();
100
- };
101
- }, [cancelTransition]);
102
- var scheduleShowTooltip = useCallback(function () {
103
- if (transitioning.current === "will-show") return;
104
- cancelTransition();
105
- if (internalShow) return;
106
- scheduleTransition(true, delay);
107
- }, [cancelTransition, delay, internalShow, scheduleTransition]);
108
- var scheduleHideTooltip = useCallback(function () {
109
- if (transitioning.current === "will-hide") return;
110
- cancelTransition();
111
- if (!internalShow) return;
112
- scheduleTransition(false, hideDelay);
113
- }, [cancelTransition, hideDelay, internalShow, scheduleTransition]);
114
- useEffect(function () {
115
- if (isControlled || !showTooltip) return;
116
- var handleMouseMove = throttle(function (evt) {
117
- var target = evt.target;
118
- var isWithinBounds = [targetEl, interactive ? popperEl : null].some(function (ref) {
119
- return Boolean(ref && (ref === target || ref.contains(target)));
120
- });
121
- if (isWithinBounds) {
122
- scheduleShowTooltip();
123
- } else {
124
- scheduleHideTooltip();
125
- }
126
- }, 16, {
127
- leading: true
128
- });
129
- document.addEventListener("mousemove", handleMouseMove);
130
- return function () {
131
- handleMouseMove.cancel();
132
- document.removeEventListener("mousemove", handleMouseMove);
133
- };
134
- }, [isControlled, popperEl, scheduleHideTooltip, scheduleShowTooltip, showTooltip, targetEl, interactive]);
135
-
136
- /**
137
- * Workaround:
138
- * When the tooltip content size changes, popper doesn't necessarily update the tooltip positionning correctly.
139
- * It's going to trigger some unnecessary updates, but it shouldn't be terribly expensive as update() is intended for "high-frequency updates"
140
- */
141
- useEffect(function () {
142
- update === null || update === void 0 ? void 0 : update();
143
- }, [children, update]);
144
38
  if (!tooltipContent) return /*#__PURE__*/_jsx(_Fragment, {
145
39
  children: children
146
40
  });
147
- return /*#__PURE__*/_jsxs(_Fragment, {
148
- children: [/*#__PURE__*/_jsx("span", _objectSpread(_objectSpread({
149
- className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["tooltip-wrapper"]))), wrapperClassName),
150
- ref: setTargetEl
151
- }, isControlled ? {} : {
152
- onMouseEnter: function onMouseEnter() {
153
- return scheduleShowTooltip();
154
- },
155
- onFocus: function onFocus() {
156
- return scheduleShowTooltip();
157
- },
158
- onMouseLeave: function onMouseLeave() {
159
- return scheduleHideTooltip();
160
- },
161
- onBlur: function onBlur(evt) {
162
- if (evt.relatedTarget === null || !interactive || !(popperEl !== null && popperEl !== void 0 && popperEl.contains(evt.relatedTarget))) {
163
- scheduleHideTooltip();
164
- }
165
- }
166
- }), {}, {
167
- children: children
168
- })), showTooltip && createPortal( /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, attributes.popper), {}, {
169
- style: styles.popper,
170
- className: cx(stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["tooltip-wrapper-popper"]))), tooltipClassName),
171
- ref: setPopperEl,
172
- children: [!noArrow && /*#__PURE__*/_jsx("div", {
173
- ref: setArrowEl,
174
- style: styles.arrow,
175
- className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["tooltip-wrapper-arrow ", ""])), tooltipVariant === "light" && "tooltip-wrapper-arrow-light")
176
- }), /*#__PURE__*/_jsx(Tooltip, {
177
- variant: tooltipVariant,
178
- children: tooltipContent
179
- })]
180
- })))]
41
+ var isReactText = typeof children === "string" || typeof children === "number";
42
+ if (!isReactText && children.type === Fragment) throw new Error("TooltipWrapper component doesn't accept a Fragment as a child.");
43
+ return /*#__PURE__*/_jsx(Tooltip.Provider, {
44
+ delayDuration: delay,
45
+ skipDelayDuration: 300,
46
+ disableHoverableContent: !interactive,
47
+ children: /*#__PURE__*/_jsxs(Tooltip.Root, {
48
+ open: show,
49
+ children: [/*#__PURE__*/_jsx(Tooltip.Trigger, {
50
+ asChild: !isReactText,
51
+ children: children
52
+ }), createPortal( /*#__PURE__*/_jsxs(Tooltip.Content, {
53
+ className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["tooltip-content"]))), tooltipClassName),
54
+ style: {
55
+ "--tooltip-hide-delay": "".concat(hideDelay, "ms")
56
+ },
57
+ side: side,
58
+ sideOffset: (noArrow ? 8 : 4) + sideOffset,
59
+ align: align,
60
+ alignOffset: alignOffset,
61
+ avoidCollisions: avoidCollisions,
62
+ children: [/*#__PURE__*/_jsx(TooltipInternal, {
63
+ variant: tooltipVariant,
64
+ children: tooltipContent
65
+ }), !noArrow && /*#__PURE__*/_jsx(Tooltip.Arrow, {
66
+ width: 8,
67
+ height: 4,
68
+ className: cx(tooltipVariant === "light" ? stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["tooltip-arrow-light"]))) : stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["tooltip-arrow-dark"]))))
69
+ })]
70
+ }))]
71
+ })
181
72
  });
182
- };
183
- export default TooltipWrapper;
73
+ };
@@ -1,14 +1,65 @@
1
- import type { Placement, StrictModifiers } from "@popperjs/core";
1
+ import type { TooltipContentProps } from "@radix-ui/react-tooltip";
2
2
  import type { ReactNode } from "react";
3
3
  import type { TooltipVariant } from "./Tooltip";
4
4
  export interface TooltipWrapperBaseProps {
5
- /** Defines where to open the menu */
6
- placement?: Placement;
5
+ /**
6
+ * Defines how long you should hover the wrapped element before displaying the tooltip (in ms).
7
+ * @default 250
8
+ */
9
+ delay?: number;
10
+ /**
11
+ * Defines how long the tooltip should stay displayed when leaving the wrapped element (in ms).
12
+ * @default 500
13
+ */
14
+ hideDelay?: number;
15
+ /**
16
+ * Defines the side of the trigger element where the tooltip should be displayed.
17
+ * Will be reversed when collisions occur and `avoidCollisions` is enabled.
18
+ * @default "bottom"
19
+ */
20
+ side?: TooltipContentProps["side"];
21
+ /**
22
+ * Defines the offset in pixels of the tooltip from the trigger element.
23
+ * @default 0
24
+ */
25
+ sideOffset?: TooltipContentProps["sideOffset"];
26
+ /**
27
+ * Defines the preferred alignment of the tooltip against the trigger element.
28
+ * May change when collisions occur.
29
+ * @default "center"
30
+ */
31
+ align?: TooltipContentProps["align"];
32
+ /**
33
+ * Defines the offset in pixels of the tooltip along the trigger element.
34
+ * It only works when the `align` option is set to "start" or "end".
35
+ * @default 0
36
+ */
37
+ alignOffset?: TooltipContentProps["alignOffset"];
38
+ /**
39
+ * Defines the variant of the tooltip.
40
+ * @default "dark"
41
+ */
7
42
  tooltipVariant?: TooltipVariant;
43
+ /**
44
+ * Defines the CSS class to be applied to the tooltip element.
45
+ */
8
46
  tooltipClassName?: string;
9
- wrapperClassName?: string;
10
- /** Modifiers for the Popper menu */
11
- modifiers?: StrictModifiers[];
47
+ /**
48
+ * Defines if the tooltip arrow should be hidden.
49
+ * @default false
50
+ */
12
51
  noArrow?: boolean;
52
+ /**
53
+ * Defines whether the tooltip itself should be considered when computing the tooltip target.
54
+ * Useful when the tooltip itself contains selectable text or interactive elements, and thus
55
+ * shouldn't be dismissed when the mouse hovers it.
56
+ * @default true
57
+ */
58
+ interactive?: boolean;
59
+ /**
60
+ * Defines whether the tooltip should avoid collisions with the viewport.
61
+ * @default true
62
+ */
63
+ avoidCollisions?: boolean;
13
64
  children: ReactNode;
14
65
  }
@@ -0,0 +1 @@
1
+ export declare const isOverflowing: (element: HTMLElement) => boolean;
@@ -0,0 +1,3 @@
1
+ export var isOverflowing = function isOverflowing(element) {
2
+ return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
3
+ };
package/esm/index.d.ts CHANGED
@@ -34,9 +34,10 @@ export * from "./ProgressBar";
34
34
  export * from "./ProgressSpinner";
35
35
  export * from "./RadioGroup";
36
36
  export * from "./RangeSlider";
37
- export * from "./ScrollIndicator";
38
37
  export * from "./Satellite";
38
+ export * from "./ScrollIndicator";
39
39
  export * from "./Select";
40
+ export * from "./Separator";
40
41
  export * from "./Sidebar";
41
42
  export * from "./Switch";
42
43
  export * from "./Tables";
package/esm/index.js CHANGED
@@ -34,9 +34,10 @@ export * from "./ProgressBar";
34
34
  export * from "./ProgressSpinner";
35
35
  export * from "./RadioGroup";
36
36
  export * from "./RangeSlider";
37
- export * from "./ScrollIndicator";
38
37
  export * from "./Satellite";
38
+ export * from "./ScrollIndicator";
39
39
  export * from "./Select";
40
+ export * from "./Separator";
40
41
  export * from "./Sidebar";
41
42
  export * from "./Switch";
42
43
  export * from "./Tables";
@@ -141,5 +141,5 @@ export default {
141
141
  }
142
142
  }
143
143
  },
144
- plugins: [require("./base.tailwind"), require("../utilities/utilities.tailwind"), require("../Typography/Typography.tailwind"), require("../FlexGrid/FlexGrid.tailwind"), require("../AutoComplete/AutoComplete.tailwind"), require("../Button/Button.tailwind"), require("../Card/Card.tailwind"), require("../Checkbox/Checkbox.tailwind"), require("../EmptyState/EmptyState.tailwind"), require("../Flag/Flag.tailwind"), require("../HelpUnderline/HelpUnderline.tailwind"), require("../Input/Input.tailwind"), require("../InstantSearch/InstantSearch.tailwind"), require("../KeyboardKey/KeyboardKey.tailwind"), require("../Medallion/Medallion.tailwind"), require("../Modal/Modal.tailwind"), require("../ProgressBar/ProgressBar.tailwind"), require("../ProgressSpinner/ProgressSpinner.tailwind"), require("../RadioGroup/RadioButton.tailwind"), require("../ScrollIndicator/ScrollIndicator.tailwind"), require("../Select/Select.tailwind"), require("../Switch/Switch.tailwind"), require("../Tabs/Tabs.tailwind"), require("../Tables/DataTable/DataTable.tailwind"), require("../Tables/Table/Table.tailwind"), require("../Tag/Tag.tailwind"), require("../TextArea/TextArea.tailwind"), require("../Toggle/Toggle.tailwind"), require("../Tooltip/Tooltip.tailwind"), require("../UserContent/UserContent.tailwind"), require("../DatePicker/DatePicker.tailwind")]
144
+ plugins: [require("./base.tailwind"), require("../utilities/utilities.tailwind"), require("../Typography/Typography.tailwind"), require("../FlexGrid/FlexGrid.tailwind"), require("../AutoComplete/AutoComplete.tailwind"), require("../Button/Button.tailwind"), require("../Card/Card.tailwind"), require("../Checkbox/Checkbox.tailwind"), require("../EmptyState/EmptyState.tailwind"), require("../Flag/Flag.tailwind"), require("../HelpUnderline/HelpUnderline.tailwind"), require("../Input/Input.tailwind"), require("../InstantSearch/InstantSearch.tailwind"), require("../KeyboardKey/KeyboardKey.tailwind"), require("../Medallion/Medallion.tailwind"), require("../Modal/Modal.tailwind"), require("../ProgressBar/ProgressBar.tailwind"), require("../ProgressSpinner/ProgressSpinner.tailwind"), require("../RadioGroup/RadioButton.tailwind"), require("../ScrollIndicator/ScrollIndicator.tailwind"), require("../Select/Select.tailwind"), require("../Separator/Separator.tailwind"), require("../Switch/Switch.tailwind"), require("../Tabs/Tabs.tailwind"), require("../Tables/DataTable/DataTable.tailwind"), require("../Tables/Table/Table.tailwind"), require("../Tag/Tag.tailwind"), require("../TextArea/TextArea.tailwind"), require("../Toggle/Toggle.tailwind"), require("../Tooltip/Tooltip.tailwind"), require("../UserContent/UserContent.tailwind"), require("../DatePicker/DatePicker.tailwind")]
145
145
  };
package/esm/types.d.ts CHANGED
@@ -7,9 +7,9 @@ export declare type ColorVariant = "accent" | "grey" | "green" | "blue" | "orang
7
7
  * Ensures at least one type is required
8
8
  * See https://stackoverflow.com/a/48244432/5903923
9
9
  */
10
- export declare type AtLeastOne<T, U = {
11
- [K in keyof T]: Pick<T, K>;
12
- }> = Partial<T> & U[keyof U];
10
+ export declare type AtLeastOne<Type, Union = {
11
+ [Key in keyof Type]: Pick<Type, Key>;
12
+ }> = Partial<Type> & Union[keyof Union];
13
13
  /**
14
14
  * Makes an optional property required
15
15
  * See https://bobbyhadz.com/blog/typescript-make-property-required
@@ -17,12 +17,12 @@ export declare type AtLeastOne<T, U = {
17
17
  export declare type WithRequiredProperty<Type, Key extends keyof Type> = Type & {
18
18
  [Property in Key]-?: Type[Property];
19
19
  };
20
- declare type Without<T, U> = {
21
- [P in Exclude<keyof T, keyof U>]?: never;
20
+ declare type Without<Type, Union> = {
21
+ [Property in Exclude<keyof Type, keyof Union>]?: never;
22
22
  };
23
23
  /**
24
24
  * Makes two types mutually exclusive
25
25
  * https://stackoverflow.com/questions/42123407/does-typescript-support-mutually-exclusive-types
26
26
  */
27
- export declare type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
27
+ export declare type XOR<Type, Union> = Type | Union extends object ? (Without<Type, Union> & Union) | (Without<Union, Type> & Type) : Type | Union;
28
28
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/satellite",
3
- "version": "1.0.0-beta.160",
3
+ "version": "1.0.0-beta.161",
4
4
  "description": "Algolia design system React components",
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",
@@ -72,8 +72,10 @@
72
72
  "@popperjs/core": "^2.4.4",
73
73
  "@radix-ui/react-avatar": "^1.0.3",
74
74
  "@radix-ui/react-dialog": "^1.0.4",
75
+ "@radix-ui/react-separator": "^1.0.3",
75
76
  "@radix-ui/react-slider": "^1.1.2",
76
77
  "@radix-ui/react-tabs": "^1.0.4",
78
+ "@radix-ui/react-tooltip": "^1.0.6",
77
79
  "clsx": "^1.2.1",
78
80
  "color": "^4.2.3",
79
81
  "date-fns": "^2.29.3",