@pushwoosh/dumb-components 2.2.1 → 2.3.1

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.
@@ -2,11 +2,11 @@ import { type ReactElement } from 'react';
2
2
  import type { TooltipProps } from './types';
3
3
  /**
4
4
  * Wraps an element and shows a contextual tooltip on hover/focus, with configurable
5
- * position and width. Positioning is handled by floating-ui, so the tooltip flips to a
6
- * fallback placement when the requested one would overflow the viewport. Use
5
+ * position, width and color. Positioning is handled by floating-ui, so the tooltip
6
+ * flips to a fallback placement when the requested one would overflow the viewport. Use
7
7
  * {@link TooltipTrigger} for a standalone help icon.
8
8
  *
9
9
  * @example
10
10
  * <Tooltip content="Copy to clipboard" position="top-middle"><IconButton /></Tooltip>
11
11
  */
12
- export declare function Tooltip({ content, position, offset, arrowOffset, maxWidth, zIndex, isDisabled, isVisible, reference, children, }: TooltipProps): ReactElement;
12
+ export declare function Tooltip({ content, color, position, offset, arrowOffset, maxWidth, zIndex, isDisabled, isVisible, reference, children, }: TooltipProps): ReactElement;
@@ -7,8 +7,8 @@ import { Arrow, TooltipBox } from './styles';
7
7
  import { useTooltipPosition } from './useTooltipPosition';
8
8
  /**
9
9
  * Wraps an element and shows a contextual tooltip on hover/focus, with configurable
10
- * position and width. Positioning is handled by floating-ui, so the tooltip flips to a
11
- * fallback placement when the requested one would overflow the viewport. Use
10
+ * position, width and color. Positioning is handled by floating-ui, so the tooltip
11
+ * flips to a fallback placement when the requested one would overflow the viewport. Use
12
12
  * {@link TooltipTrigger} for a standalone help icon.
13
13
  *
14
14
  * @example
@@ -16,6 +16,7 @@ import { useTooltipPosition } from './useTooltipPosition';
16
16
  */
17
17
  export function Tooltip({
18
18
  content,
19
+ color = 'main',
19
20
  position = 'top-start',
20
21
  offset,
21
22
  arrowOffset,
@@ -88,10 +89,12 @@ export function Tooltip({
88
89
  zIndex
89
90
  },
90
91
  "$maxWidth": maxWidth,
92
+ "$tooltipColor": color,
91
93
  "data-placement": placement,
92
94
  children: [content, _jsx(Arrow, {
93
95
  ref: arrowRef,
94
- style: arrowStyles
96
+ style: arrowStyles,
97
+ "$tooltipColor": color
95
98
  })]
96
99
  }), document.body)]
97
100
  });
@@ -1,3 +1,3 @@
1
1
  export { Tooltip } from './Tooltip';
2
2
  export { TooltipTrigger } from './TooltipTrigger';
3
- export type { TooltipPosition } from './types';
3
+ export type { TooltipPosition, TooltipColor } from './types';
@@ -1,8 +1,12 @@
1
1
  import { Color } from '@pushwoosh/kit-constants';
2
+ import type { TooltipColor } from './types';
2
3
  export declare const TooltipBox: import("styled-components").StyledComponent<"div", any, {
3
4
  $maxWidth?: number | "none";
5
+ $tooltipColor?: TooltipColor;
6
+ }, never>;
7
+ export declare const Arrow: import("styled-components").StyledComponent<"div", any, {
8
+ $tooltipColor?: TooltipColor;
4
9
  }, never>;
5
- export declare const Arrow: import("styled-components").StyledComponent<"div", any, {}, never>;
6
10
  export declare const HelpIconWrapper: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
7
11
  $alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue;
8
12
  $alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue;
package/Tooltip/styles.js CHANGED
@@ -1,17 +1,23 @@
1
- import styled from 'styled-components';
2
- import { Color, FontSize, ShapeRadius } from '@pushwoosh/kit-constants';
1
+ import styled, { css } from 'styled-components';
2
+ import { Color, FontSize, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
3
3
  import { Horizontal } from '@pushwoosh/kit-helpers';
4
4
  import { DEFAULT_MAX_WIDTH } from './constants';
5
+ const clearBox = css(["padding:16px;color:", ";background-color:", ";border:1px solid ", ";box-shadow:", ";"], Color.MAIN, Color.CLEAR, Color.FORM, Shadow.LARGE);
5
6
  export const TooltipBox = styled.div.withConfig({
6
7
  displayName: "TooltipBox",
7
8
  componentId: "sc-1hariht-0"
8
- })(["padding:12px;color:", ";background-color:", ";border-radius:", ";font-size:", ";line-height:inherit;outline:0;pointer-events:none;max-width:", ";"], Color.CLEAR, Color.MAIN, ShapeRadius.DIALOG, FontSize.REGULAR, ({
9
+ })(["padding:12px;color:", ";background-color:", ";border-radius:", ";font-size:", ";line-height:inherit;outline:0;pointer-events:none;max-width:", ";", ""], Color.CLEAR, Color.MAIN, ShapeRadius.DIALOG, FontSize.REGULAR, ({
9
10
  $maxWidth
10
- }) => $maxWidth === 'none' ? 'min(var(--pw-page-max-width, 100vw), calc(100vw - 16px))' : `min(${$maxWidth ?? DEFAULT_MAX_WIDTH}px, var(--pw-page-max-width, 100vw), calc(100vw - 16px))`);
11
+ }) => $maxWidth === 'none' ? 'min(var(--pw-page-max-width, 100vw), calc(100vw - 16px))' : `min(${$maxWidth ?? DEFAULT_MAX_WIDTH}px, var(--pw-page-max-width, 100vw), calc(100vw - 16px))`, ({
12
+ $tooltipColor
13
+ }) => $tooltipColor === 'clear' && clearBox);
14
+ const clearArrowBorder = css(["[data-placement^='top'] &{border-right:1px solid ", ";border-bottom:1px solid ", ";}[data-placement^='bottom'] &{border-top:1px solid ", ";border-left:1px solid ", ";}[data-placement^='left'] &{border-top:1px solid ", ";border-right:1px solid ", ";}[data-placement^='right'] &{border-bottom:1px solid ", ";border-left:1px solid ", ";}"], Color.FORM, Color.FORM, Color.FORM, Color.FORM, Color.FORM, Color.FORM, Color.FORM, Color.FORM);
11
15
  export const Arrow = styled.div.withConfig({
12
16
  displayName: "Arrow",
13
17
  componentId: "sc-1hariht-1"
14
- })(["position:absolute;width:10px;height:10px;border-radius:2px;background-color:", ";transform:rotate(45deg);"], Color.MAIN);
18
+ })(["position:absolute;width:10px;height:10px;border-radius:2px;background-color:", ";transform:rotate(45deg);", ""], Color.MAIN, ({
19
+ $tooltipColor
20
+ }) => $tooltipColor === 'clear' && css(["background-color:", ";", ""], Color.CLEAR, clearArrowBorder));
15
21
  export const HelpIconWrapper = styled(Horizontal).withConfig({
16
22
  displayName: "HelpIconWrapper",
17
23
  componentId: "sc-1hariht-2"
@@ -1,10 +1,14 @@
1
1
  import type { RefObject, ReactElement, ReactNode } from 'react';
2
2
  /** Placement of a {@link Tooltip} relative to its anchor (side + alignment). */
3
3
  export type TooltipPosition = 'top-start' | 'top-middle' | 'top-end' | 'right-start' | 'right-middle' | 'right-end' | 'bottom-start' | 'bottom-middle' | 'bottom-end' | 'left-start' | 'left-middle' | 'left-end';
4
+ /** Color of a {@link Tooltip}, named after the background token it uses. */
5
+ export type TooltipColor = 'main' | 'clear';
4
6
  /** Props of {@link Tooltip}. */
5
7
  export type TooltipProps = {
6
8
  /** Tooltip content. */
7
9
  readonly content: ReactNode;
10
+ /** Background color (default `main`); `clear` is a card on the page background: 16px padding, border and large shadow. */
11
+ readonly color?: TooltipColor;
8
12
  /** Placement relative to the anchor (default `top-start`). */
9
13
  readonly position?: TooltipPosition;
10
14
  /** `[skidding, distance]` offset from the anchor; defaults per position. */
package/index.d.ts CHANGED
@@ -28,7 +28,7 @@ export { Combobox, type ComboboxProps, type ComboboxChangeSource, type ComboboxC
28
28
  export { ComboboxMulti, type ComboboxMultiProps } from './ComboboxMulti';
29
29
  export { Switch } from './Switch';
30
30
  export { TextSkeleton, RectangularSkeleton, CircularSkeleton } from './Skeleton';
31
- export { Tooltip, type TooltipPosition, TooltipTrigger } from './Tooltip';
31
+ export { Tooltip, type TooltipPosition, type TooltipColor, TooltipTrigger } from './Tooltip';
32
32
  export { Tab, TabBar, TabPanel, Tabs, type TabCode } from './Tabs';
33
33
  export { Link, type LinkPropsWithoutAs, type LinkPropsWithAsTag, type LinkPropsWithAsComponent, } from './Link';
34
34
  export { StatisticCard } from './StatisticCard';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "2.2.1",
3
+ "version": "2.3.1",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -40,8 +40,8 @@
40
40
  "@codemirror/view": "^6.43.11",
41
41
  "@floating-ui/react-dom": "^2.1.2",
42
42
  "@lezer/highlight": "^1.2.1",
43
- "@pushwoosh/kit-constants": "^2.0.0",
44
- "@pushwoosh/kit-helpers": "^4.12.5",
43
+ "@pushwoosh/kit-constants": "^2.1.0",
44
+ "@pushwoosh/kit-helpers": "^4.12.7",
45
45
  "@pushwoosh/kit-icons": "^2.3.3",
46
46
  "@pushwoosh/kit-typography": "^1.8.5",
47
47
  "@tippyjs/react": "^4.2.6",