@pushwoosh/dumb-components 1.1.155 → 1.1.156

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.
@@ -40,7 +40,6 @@ export function Tooltip({
40
40
  position,
41
41
  offset,
42
42
  arrowOffset,
43
- maxWidth,
44
43
  isOpen
45
44
  });
46
45
  const {
package/Tooltip/maps.d.ts CHANGED
@@ -5,7 +5,6 @@ import { type TooltipTriggerView } from './TooltipTrigger';
5
5
  import type { TooltipPosition } from './types';
6
6
  export declare const TooltipPositionToFloatingPlacementMap: Record<TooltipPosition, Placement>;
7
7
  export declare const TooltipPositionToOffsetMap: Record<TooltipPosition, [number, number]>;
8
- export declare const TooltipPositionToArrowOffsetMap: Record<TooltipPosition, string>;
9
8
  export declare const TooltipTriggerViewMap: Record<TooltipTriggerView, {
10
9
  color: Color;
11
10
  hoverColor: Color;
package/Tooltip/maps.js CHANGED
@@ -28,20 +28,6 @@ export const TooltipPositionToOffsetMap = {
28
28
  'left-middle': [0, 8],
29
29
  'left-end': [6, 8]
30
30
  };
31
- export const TooltipPositionToArrowOffsetMap = {
32
- 'top-start': '24px',
33
- 'top-middle': '50%',
34
- 'top-end': '24px',
35
- 'right-start': '24px',
36
- 'right-middle': '50%',
37
- 'right-end': '24px',
38
- 'bottom-start': '24px',
39
- 'bottom-middle': '50%',
40
- 'bottom-end': '24px',
41
- 'left-start': '24px',
42
- 'left-middle': '50%',
43
- 'left-end': '24px'
44
- };
45
31
  export const TooltipTriggerViewMap = {
46
32
  info: {
47
33
  color: Color.LOCKED,
@@ -9,7 +9,7 @@ export type TooltipProps = {
9
9
  readonly position?: TooltipPosition;
10
10
  /** `[skidding, distance]` offset from the anchor; defaults per position. */
11
11
  readonly offset?: [number, number];
12
- /** Min distance the arrow keeps from the tooltip corners `px` or `%` of `maxWidth`. */
12
+ /** Min gap (px) the arrow keeps from the tooltip corners; arrow points at the anchor (default `12`). */
13
13
  readonly arrowOffset?: string;
14
14
  /** Max width in pixels, or `'none'` (default `240`). */
15
15
  readonly maxWidth?: number | 'none';
@@ -4,15 +4,15 @@ type Args = {
4
4
  position: TooltipPosition;
5
5
  offset?: [number, number] | undefined;
6
6
  arrowOffset?: string | undefined;
7
- maxWidth?: number | 'none' | undefined;
8
7
  isOpen: boolean;
9
8
  };
10
9
  /**
11
10
  * Positions the tooltip relative to its anchor via floating-ui: `flip`/`shift` pick a
12
- * fallback placement when the requested one overflows the viewport, and `arrow` keeps
13
- * the arrow pointing at the anchor. Repositions on scroll/resize while open.
11
+ * fallback placement when the requested one overflows the viewport, and `arrow` keeps the
12
+ * arrow pointing at the anchor's center. `arrowOffset` only sets the minimum gap (px) the
13
+ * arrow keeps from the tooltip corners. Repositions on scroll/resize while open.
14
14
  */
15
- export declare function useTooltipPosition({ position, offset: offsetProp, arrowOffset, maxWidth, isOpen, }: Args): {
15
+ export declare function useTooltipPosition({ position, offset: offsetProp, arrowOffset, isOpen, }: Args): {
16
16
  refs: {
17
17
  reference: import("react").MutableRefObject<import("@floating-ui/react-dom").ReferenceType | null>;
18
18
  floating: React.MutableRefObject<HTMLElement | null>;
@@ -1,7 +1,7 @@
1
1
  import { arrow, autoUpdate, flip, offset, shift, useFloating } from '@floating-ui/react-dom';
2
2
  import { useRef } from 'react';
3
- import { parseArrowPadding } from './helpers';
4
- import { TooltipPositionToArrowOffsetMap, TooltipPositionToFloatingPlacementMap, TooltipPositionToOffsetMap } from './maps';
3
+ import { DEFAULT_ARROW_PADDING } from './constants';
4
+ import { TooltipPositionToFloatingPlacementMap, TooltipPositionToOffsetMap } from './maps';
5
5
  const ArrowStaticSideMap = {
6
6
  top: 'bottom',
7
7
  right: 'left',
@@ -10,19 +10,20 @@ const ArrowStaticSideMap = {
10
10
  };
11
11
  /**
12
12
  * Positions the tooltip relative to its anchor via floating-ui: `flip`/`shift` pick a
13
- * fallback placement when the requested one overflows the viewport, and `arrow` keeps
14
- * the arrow pointing at the anchor. Repositions on scroll/resize while open.
13
+ * fallback placement when the requested one overflows the viewport, and `arrow` keeps the
14
+ * arrow pointing at the anchor's center. `arrowOffset` only sets the minimum gap (px) the
15
+ * arrow keeps from the tooltip corners. Repositions on scroll/resize while open.
15
16
  */
16
17
  export function useTooltipPosition({
17
18
  position,
18
19
  offset: offsetProp,
19
20
  arrowOffset,
20
- maxWidth,
21
21
  isOpen
22
22
  }) {
23
23
  const arrowRef = useRef(null);
24
24
  const [skidding, distance] = offsetProp ?? TooltipPositionToOffsetMap[position];
25
- const arrowPadding = parseArrowPadding(arrowOffset ?? TooltipPositionToArrowOffsetMap[position], maxWidth);
25
+ const parsedPadding = arrowOffset != null ? parseFloat(arrowOffset) : NaN;
26
+ const arrowPadding = Number.isFinite(parsedPadding) ? parsedPadding : DEFAULT_ARROW_PADDING;
26
27
  const {
27
28
  refs,
28
29
  floatingStyles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.155",
3
+ "version": "1.1.156",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -1,7 +0,0 @@
1
- /**
2
- * Resolve the legacy `arrowOffset` CSS string into an `arrow()` padding in px — the
3
- * minimum distance the arrow keeps from the tooltip corners. Accepts `px` values as-is
4
- * and `%` values relative to the tooltip's max cross size (`maxWidth`, or the default
5
- * when unbounded), so both forms used with the old tippy tooltip keep working.
6
- */
7
- export declare function parseArrowPadding(arrowOffset: string | undefined, maxWidth: number | 'none' | undefined): number;
@@ -1,21 +0,0 @@
1
- import { DEFAULT_ARROW_PADDING, DEFAULT_MAX_WIDTH } from './constants';
2
- /**
3
- * Resolve the legacy `arrowOffset` CSS string into an `arrow()` padding in px — the
4
- * minimum distance the arrow keeps from the tooltip corners. Accepts `px` values as-is
5
- * and `%` values relative to the tooltip's max cross size (`maxWidth`, or the default
6
- * when unbounded), so both forms used with the old tippy tooltip keep working.
7
- */
8
- export function parseArrowPadding(arrowOffset, maxWidth) {
9
- if (!arrowOffset) {
10
- return DEFAULT_ARROW_PADDING;
11
- }
12
- const value = parseFloat(arrowOffset);
13
- if (Number.isNaN(value)) {
14
- return DEFAULT_ARROW_PADDING;
15
- }
16
- if (arrowOffset.trim().endsWith('%')) {
17
- const base = typeof maxWidth === 'number' ? maxWidth : DEFAULT_MAX_WIDTH;
18
- return value / 100 * base;
19
- }
20
- return value;
21
- }