@pushwoosh/dumb-components 1.1.155 → 1.1.157

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 {
@@ -1,7 +1,6 @@
1
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.
2
+ * Resolve `arrowOffset` to a px gap. Accepts a number, or a numeric string like `'20px'`
3
+ * (only the leading number is used, the unit is ignored); anything unparseable falls back
4
+ * to the default.
6
5
  */
7
- export declare function parseArrowPadding(arrowOffset: string | undefined, maxWidth: number | 'none' | undefined): number;
6
+ export declare function resolveArrowPadding(arrowOffset: number | string | undefined): number;
@@ -1,21 +1,18 @@
1
- import { DEFAULT_ARROW_PADDING, DEFAULT_MAX_WIDTH } from './constants';
1
+ import { DEFAULT_ARROW_PADDING } from './constants';
2
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.
3
+ * Resolve `arrowOffset` to a px gap. Accepts a number, or a numeric string like `'20px'`
4
+ * (only the leading number is used, the unit is ignored); anything unparseable falls back
5
+ * to the default.
7
6
  */
8
- export function parseArrowPadding(arrowOffset, maxWidth) {
9
- if (!arrowOffset) {
10
- return DEFAULT_ARROW_PADDING;
7
+ export function resolveArrowPadding(arrowOffset) {
8
+ if (typeof arrowOffset === 'number') {
9
+ return arrowOffset;
11
10
  }
12
- const value = parseFloat(arrowOffset);
13
- if (Number.isNaN(value)) {
14
- return DEFAULT_ARROW_PADDING;
11
+ if (typeof arrowOffset === 'string') {
12
+ const parsed = parseFloat(arrowOffset);
13
+ if (Number.isFinite(parsed)) {
14
+ return parsed;
15
+ }
15
16
  }
16
- if (arrowOffset.trim().endsWith('%')) {
17
- const base = typeof maxWidth === 'number' ? maxWidth : DEFAULT_MAX_WIDTH;
18
- return value / 100 * base;
19
- }
20
- return value;
17
+ return DEFAULT_ARROW_PADDING;
21
18
  }
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,8 +9,8 @@ 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`. */
13
- readonly arrowOffset?: string;
12
+ /** Min gap the arrow keeps from tooltip corners: a number or numeric string like `'20px'` unit ignored, treated as px (default `12`). */
13
+ readonly arrowOffset?: number | string;
14
14
  /** Max width in pixels, or `'none'` (default `240`). */
15
15
  readonly maxWidth?: number | 'none';
16
16
  /** Stacking z-index. */
@@ -3,16 +3,16 @@ import type { TooltipPosition } from './types';
3
3
  type Args = {
4
4
  position: TooltipPosition;
5
5
  offset?: [number, number] | undefined;
6
- arrowOffset?: string | undefined;
7
- maxWidth?: number | 'none' | undefined;
6
+ arrowOffset?: number | string | 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 { resolveArrowPadding } from './helpers';
4
+ import { TooltipPositionToFloatingPlacementMap, TooltipPositionToOffsetMap } from './maps';
5
5
  const ArrowStaticSideMap = {
6
6
  top: 'bottom',
7
7
  right: 'left',
@@ -10,19 +10,19 @@ 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 arrowPadding = resolveArrowPadding(arrowOffset);
26
26
  const {
27
27
  refs,
28
28
  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.157",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",