@pushwoosh/dumb-components 1.1.23 → 1.1.25

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,7 +2,7 @@ import React, { useRef, useEffect, useState } from 'react';
2
2
  import { Color } from '@pushwoosh/kit-constants';
3
3
  import { Horizontal } from '@pushwoosh/kit-helpers';
4
4
  import { NativeLabel, NativeCheckbox } from './styles';
5
- import { HelpTooltip } from '../Tooltip';
5
+ import { TooltipTrigger } from '../Tooltip';
6
6
  let counter = 0;
7
7
  export function Checkbox(props) {
8
8
  const {
@@ -52,9 +52,10 @@ export function Checkbox(props) {
52
52
  return React.createElement(Horizontal, {
53
53
  "$gap": 4,
54
54
  "$alignItems": "start"
55
- }, checkboxMarkup, React.createElement(HelpTooltip, {
55
+ }, checkboxMarkup, React.createElement(TooltipTrigger, {
56
56
  content: tooltip,
57
- "$iconPadding": "4px 0"
57
+ padding: "4px 0",
58
+ view: "question"
58
59
  }));
59
60
  }
60
61
  return checkboxMarkup;
package/Radio/Radio.js CHANGED
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
2
2
  import { Color } from '@pushwoosh/kit-constants';
3
3
  import { Horizontal } from '@pushwoosh/kit-helpers';
4
4
  import { InputContainer, NativeLabel, NativeRadio } from './styles';
5
- import { HelpTooltip } from '../Tooltip';
5
+ import { TooltipTrigger } from '../Tooltip';
6
6
  let counter = 0;
7
7
  export function Radio(props) {
8
8
  const {
@@ -49,10 +49,11 @@ export function Radio(props) {
49
49
  return React.createElement(Horizontal, {
50
50
  "$gap": 4,
51
51
  "$alignItems": "start"
52
- }, radioMarkup, React.createElement(HelpTooltip, {
52
+ }, radioMarkup, React.createElement(TooltipTrigger, {
53
53
  content: tooltip,
54
- "$iconPadding": size === 'compact' ? '0' : '4px 0',
55
- position: "top-middle"
54
+ padding: size === 'compact' ? '0' : '4px 0',
55
+ position: "top-middle",
56
+ view: "question"
56
57
  }));
57
58
  }
58
59
  return radioMarkup;
@@ -0,0 +1,10 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { TooltipProps } from './types';
3
+ export type TooltipTriggerView = 'question' | 'info' | 'warning' | 'error';
4
+ export type TooltipTriggerProps = TooltipProps & {
5
+ padding?: string | number;
6
+ size?: 'small' | 'medium';
7
+ hover?: boolean;
8
+ view: TooltipTriggerView;
9
+ };
10
+ export declare function TooltipTrigger({ padding, view, size, hover, ...tooltipProps }: TooltipTriggerProps): ReactElement;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { TooltipTriggerViewMap } from './maps';
3
+ import { HelpIconWrapper } from './styles';
4
+ import { Tooltip } from './Tooltip';
5
+ export function TooltipTrigger({
6
+ padding = 0,
7
+ view,
8
+ size = 'small',
9
+ hover = true,
10
+ ...tooltipProps
11
+ }) {
12
+ const hoverColor = hover ? TooltipTriggerViewMap[view].hoverColor : undefined;
13
+ const {
14
+ icon: Icon
15
+ } = TooltipTriggerViewMap[view];
16
+ return React.createElement(Tooltip, {
17
+ ...tooltipProps
18
+ }, React.createElement(HelpIconWrapper, {
19
+ "$padding": padding,
20
+ "$color": TooltipTriggerViewMap[view].color,
21
+ "$hoverColor": hoverColor
22
+ }, React.createElement(Icon, {
23
+ size: size,
24
+ view: "lined"
25
+ })));
26
+ }
@@ -1,3 +1,3 @@
1
1
  export { Tooltip } from './Tooltip';
2
- export { HelpTooltip } from './HelpTooltip';
2
+ export { TooltipTrigger } from './TooltipTrigger';
3
3
  export type { TooltipPosition } from './types';
package/Tooltip/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export { Tooltip } from './Tooltip';
2
- export { HelpTooltip } from './HelpTooltip';
2
+ export { TooltipTrigger } from './TooltipTrigger';
package/Tooltip/maps.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Color } from '@pushwoosh/kit-constants';
2
+ import { type TooltipTriggerView } from './TooltipTrigger';
1
3
  import type { TooltipPosition } from './types';
2
4
  export declare const TooltipPositionToTippyPlacementMap: {
3
5
  'top-start': "top-start";
@@ -33,3 +35,11 @@ export declare function getTopPosition(position: TooltipPosition, offset: string
33
35
  export declare function getRightPosition(position: TooltipPosition, offset: string): string;
34
36
  export declare function getBottomPosition(position: TooltipPosition, offset: string): string;
35
37
  export declare function getLeftPosition(position: TooltipPosition, offset: string): string;
38
+ export declare const TooltipTriggerViewMap: Record<TooltipTriggerView, {
39
+ color: Color;
40
+ hoverColor: Color;
41
+ icon: React.FC<{
42
+ size: 'small' | 'medium';
43
+ view: 'lined' | 'filled';
44
+ }>;
45
+ }>;
package/Tooltip/maps.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { Color } from '@pushwoosh/kit-constants';
2
+ import { DangerTriangleIcon, HelpRoundIcon, InfoRoundIcon, WarningRoundIcon } from '@pushwoosh/kit-icons';
1
3
  export const TooltipPositionToTippyPlacementMap = {
2
4
  'top-start': 'top-start',
3
5
  'top-middle': 'top',
@@ -158,4 +160,26 @@ export function getLeftPosition(position, offset) {
158
160
  console.error(`[Tooltip]: unknown position: ${position}!`);
159
161
  return 'auto';
160
162
  }
161
- }
163
+ }
164
+ export const TooltipTriggerViewMap = {
165
+ info: {
166
+ color: Color.PHANTOM,
167
+ hoverColor: Color.PRIMARY_HOVER,
168
+ icon: InfoRoundIcon
169
+ },
170
+ question: {
171
+ color: Color.PHANTOM,
172
+ hoverColor: Color.PRIMARY_HOVER,
173
+ icon: HelpRoundIcon
174
+ },
175
+ warning: {
176
+ color: Color.WARNING,
177
+ hoverColor: Color.WARNING_HOVER,
178
+ icon: WarningRoundIcon
179
+ },
180
+ error: {
181
+ color: Color.DANGER,
182
+ hoverColor: Color.DANGER_HOVER,
183
+ icon: DangerTriangleIcon
184
+ }
185
+ };
@@ -1,3 +1,4 @@
1
+ import { Color } from '@pushwoosh/kit-constants';
1
2
  import type { TooltipPosition } from './types';
2
3
  export declare const TooltipBox: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@tippyjs/react").TippyProps>, any, {
3
4
  $arrowOffset: string;
@@ -58,4 +59,7 @@ export declare const HelpIconWrapper: import("styled-components").StyledComponen
58
59
  $placeItems?: "end" | "start" | "center" | "stretch" | undefined;
59
60
  } & {
60
61
  $gridAutoFlow: string;
62
+ } & {
63
+ $color: Color;
64
+ $hoverColor?: Color;
61
65
  }, "$gridAutoFlow">;
package/Tooltip/styles.js CHANGED
@@ -24,4 +24,12 @@ export const TooltipBox = styled(Tippy).withConfig({
24
24
  export const HelpIconWrapper = styled(Horizontal).withConfig({
25
25
  displayName: "HelpIconWrapper",
26
26
  componentId: "sc-1hariht-1"
27
- })(["color:", ";&:hover{color:", ";cursor:pointer;}"], Color.PHANTOM, Color.PRIMARY_HOVER);
27
+ })(["color:", ";", ""], ({
28
+ $color
29
+ }) => $color, ({
30
+ $hoverColor
31
+ }) => $hoverColor && `
32
+ &:hover {
33
+ color: ${$hoverColor};
34
+ cursor: pointer;
35
+ }`);
package/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export { SortButton, type SortButtonParams } from './SortButton';
20
20
  export { Select, SelectAsync, CreatableSelect, CLASS_NAME_PREFIX, type SelectBase, type MultiSelectOptions, } from './Select';
21
21
  export { Switch } from './Switch';
22
22
  export { TextSkeleton, RectangularSkeleton, CircularSkeleton } from './Skeleton';
23
- export { Tooltip, type TooltipPosition, HelpTooltip } from './Tooltip';
23
+ export { Tooltip, type TooltipPosition, TooltipTrigger } from './Tooltip';
24
24
  export { Tab, TabBar, TabPanel, Tabs, type TabCode } from './Tabs';
25
25
  export { Link } from './Link';
26
26
  export { StatisticCard } from './StatisticCard';
package/index.js CHANGED
@@ -20,7 +20,7 @@ export { SortButton } from './SortButton';
20
20
  export { Select, SelectAsync, CreatableSelect, CLASS_NAME_PREFIX } from './Select';
21
21
  export { Switch } from './Switch';
22
22
  export { TextSkeleton, RectangularSkeleton, CircularSkeleton } from './Skeleton';
23
- export { Tooltip, HelpTooltip } from './Tooltip';
23
+ export { Tooltip, TooltipTrigger } from './Tooltip';
24
24
  export { Tab, TabBar, TabPanel, Tabs } from './Tabs';
25
25
  export { Link } from './Link';
26
26
  export { StatisticCard } from './StatisticCard';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.23",
3
+ "version": "1.1.25",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -1,6 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- import type { TooltipProps } from './types';
3
- export type HelpTooltipProps = TooltipProps & {
4
- $iconPadding?: string;
5
- };
6
- export declare function HelpTooltip({ $iconPadding, ...tooltipProps }: HelpTooltipProps): ReactElement;
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import { HelpRoundIcon } from '@pushwoosh/kit-icons';
3
- import { HelpIconWrapper } from './styles';
4
- import { Tooltip } from './Tooltip';
5
- export function HelpTooltip({
6
- $iconPadding = '0',
7
- ...tooltipProps
8
- }) {
9
- return React.createElement(Tooltip, {
10
- ...tooltipProps
11
- }, React.createElement(HelpIconWrapper, {
12
- "$padding": $iconPadding
13
- }, React.createElement(HelpRoundIcon, {
14
- size: "small",
15
- view: "lined"
16
- })));
17
- }