@pushwoosh/dumb-components 1.1.24 → 1.1.26

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.
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { AlertProps } from './types';
3
+ export declare const Alert: ({ isExpandedDefault, title, type, children }: AlertProps) => React.JSX.Element;
package/Alert/Alert.js ADDED
@@ -0,0 +1,45 @@
1
+ import React, { useState } from 'react';
2
+ import { ShapeRadius } from '@pushwoosh/kit-constants';
3
+ import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
4
+ import { ChevronIcon } from '@pushwoosh/kit-icons';
5
+ import { AlertTypeMap } from './maps';
6
+ import { AccordionHeader, Container } from './styles';
7
+ export const Alert = ({
8
+ isExpandedDefault,
9
+ title,
10
+ type,
11
+ children
12
+ }) => {
13
+ const [isExpanded, setIsExpanded] = useState(isExpandedDefault);
14
+ const canCollapse = !!children;
15
+ const {
16
+ icon: Icon,
17
+ iconColor,
18
+ bgColor
19
+ } = AlertTypeMap[type];
20
+ return React.createElement(Container, {
21
+ "$borderRadius": ShapeRadius.SECTION,
22
+ "$bgColor": bgColor
23
+ }, React.createElement(AccordionHeader, {
24
+ onClick: () => canCollapse && setIsExpanded(!isExpanded),
25
+ "$canCollapse": canCollapse,
26
+ "$justifyContent": "space-between",
27
+ "$alignItems": "center",
28
+ "$gap": 8,
29
+ "$padding": "8px 12px 8px 16px"
30
+ }, React.createElement(Horizontal, {
31
+ "$gap": 8
32
+ }, React.createElement(Icon, {
33
+ size: "small",
34
+ view: "lined",
35
+ color: iconColor
36
+ }), title), canCollapse && React.createElement(Horizontal, {
37
+ "$justifyContent": "center"
38
+ }, React.createElement(ChevronIcon, {
39
+ size: "small",
40
+ direction: isExpanded ? 'up' : 'down',
41
+ color: iconColor
42
+ }))), isExpanded && React.createElement(Vertical, {
43
+ "$padding": "0 16px 16px"
44
+ }, children));
45
+ };
@@ -0,0 +1,2 @@
1
+ export { Alert } from './Alert';
2
+ export type { AlertProps } from './types';
package/Alert/index.js ADDED
@@ -0,0 +1 @@
1
+ export { Alert } from './Alert';
@@ -0,0 +1,10 @@
1
+ import { Color } from '@pushwoosh/kit-constants';
2
+ import { type DangerTriangleIconProps, type InfoRoundIconProps, type WarningRoundIconProps } from '@pushwoosh/kit-icons';
3
+ import { type AlertType } from './types';
4
+ type AlertData = {
5
+ icon: React.FC<InfoRoundIconProps | WarningRoundIconProps | DangerTriangleIconProps>;
6
+ iconColor: Color;
7
+ bgColor: Color;
8
+ };
9
+ export declare const AlertTypeMap: Record<AlertType, AlertData>;
10
+ export {};
package/Alert/maps.js ADDED
@@ -0,0 +1,19 @@
1
+ import { Color } from '@pushwoosh/kit-constants';
2
+ import { DangerTriangleIcon, InfoRoundIcon, WarningRoundIcon } from '@pushwoosh/kit-icons';
3
+ export const AlertTypeMap = {
4
+ info: {
5
+ icon: InfoRoundIcon,
6
+ iconColor: Color.BRIGHT,
7
+ bgColor: Color.BRIGHT_LIGHT
8
+ },
9
+ warning: {
10
+ icon: WarningRoundIcon,
11
+ iconColor: Color.WARNING,
12
+ bgColor: Color.WARNING_LIGHT
13
+ },
14
+ error: {
15
+ icon: DangerTriangleIcon,
16
+ iconColor: Color.DANGER,
17
+ bgColor: Color.DANGER_LIGHT
18
+ }
19
+ };
@@ -0,0 +1,114 @@
1
+ export declare const AccordionHeader: import("styled-components").StyledComponent<"div", any, {
2
+ $alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
3
+ $alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
4
+ $bgColor?: string | undefined;
5
+ $border?: string | ({
6
+ top?: string | undefined;
7
+ right?: string | undefined;
8
+ bottom?: string | undefined;
9
+ left?: string | undefined;
10
+ } | {
11
+ horizontal: string;
12
+ top?: string | undefined;
13
+ bottom?: string | undefined;
14
+ } | {
15
+ vertical: string;
16
+ right?: string | undefined;
17
+ left?: string | undefined;
18
+ }) | undefined;
19
+ $borderRadius?: (string | number) | undefined;
20
+ $boxShadow?: string | undefined;
21
+ $gap?: (string | number) | undefined;
22
+ $gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
23
+ $justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
24
+ $justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
25
+ $margin?: (string | number) | ({
26
+ top?: (string | number) | undefined;
27
+ right?: (string | number) | undefined;
28
+ bottom?: (string | number) | undefined;
29
+ left?: (string | number) | undefined;
30
+ } | {
31
+ horizontal: string | number;
32
+ top?: (string | number) | undefined;
33
+ bottom?: (string | number) | undefined;
34
+ } | {
35
+ vertical: string | number;
36
+ right?: (string | number) | undefined;
37
+ left?: (string | number) | undefined;
38
+ }) | undefined;
39
+ $padding?: (string | number) | ({
40
+ top?: (string | number) | undefined;
41
+ right?: (string | number) | undefined;
42
+ bottom?: (string | number) | undefined;
43
+ left?: (string | number) | undefined;
44
+ } | {
45
+ horizontal: string | number;
46
+ top?: (string | number) | undefined;
47
+ bottom?: (string | number) | undefined;
48
+ } | {
49
+ vertical: string | number;
50
+ right?: (string | number) | undefined;
51
+ left?: (string | number) | undefined;
52
+ }) | undefined;
53
+ $placeItems?: "end" | "start" | "center" | "stretch" | undefined;
54
+ } & {
55
+ $gridAutoFlow: string;
56
+ } & {
57
+ $canCollapse?: boolean;
58
+ }, "$gridAutoFlow">;
59
+ export declare const Container: import("styled-components").StyledComponent<"div", any, {
60
+ $alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
61
+ $alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
62
+ $bgColor?: string | undefined;
63
+ $border?: string | ({
64
+ top?: string | undefined;
65
+ right?: string | undefined;
66
+ bottom?: string | undefined;
67
+ left?: string | undefined;
68
+ } | {
69
+ horizontal: string;
70
+ top?: string | undefined;
71
+ bottom?: string | undefined;
72
+ } | {
73
+ vertical: string;
74
+ right?: string | undefined;
75
+ left?: string | undefined;
76
+ }) | undefined;
77
+ $borderRadius?: (string | number) | undefined;
78
+ $boxShadow?: string | undefined;
79
+ $gap?: (string | number) | undefined;
80
+ $gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
81
+ $justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
82
+ $justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
83
+ $margin?: (string | number) | ({
84
+ top?: (string | number) | undefined;
85
+ right?: (string | number) | undefined;
86
+ bottom?: (string | number) | undefined;
87
+ left?: (string | number) | undefined;
88
+ } | {
89
+ horizontal: string | number;
90
+ top?: (string | number) | undefined;
91
+ bottom?: (string | number) | undefined;
92
+ } | {
93
+ vertical: string | number;
94
+ right?: (string | number) | undefined;
95
+ left?: (string | number) | undefined;
96
+ }) | undefined;
97
+ $padding?: (string | number) | ({
98
+ top?: (string | number) | undefined;
99
+ right?: (string | number) | undefined;
100
+ bottom?: (string | number) | undefined;
101
+ left?: (string | number) | undefined;
102
+ } | {
103
+ horizontal: string | number;
104
+ top?: (string | number) | undefined;
105
+ bottom?: (string | number) | undefined;
106
+ } | {
107
+ vertical: string | number;
108
+ right?: (string | number) | undefined;
109
+ left?: (string | number) | undefined;
110
+ }) | undefined;
111
+ $placeItems?: "end" | "start" | "center" | "stretch" | undefined;
112
+ } & {
113
+ $gridAutoFlow: string;
114
+ }, "$gridAutoFlow">;
@@ -0,0 +1,12 @@
1
+ import styled from 'styled-components';
2
+ import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
3
+ export const AccordionHeader = styled(Horizontal).withConfig({
4
+ displayName: "AccordionHeader",
5
+ componentId: "sc-fpiqkp-0"
6
+ })(["cursor:", ";"], ({
7
+ $canCollapse
8
+ }) => $canCollapse ? 'pointer' : 'initial');
9
+ export const Container = styled(Vertical).withConfig({
10
+ displayName: "Container",
11
+ componentId: "sc-fpiqkp-1"
12
+ })(["width:100%;min-width:200px;"]);
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from 'react';
2
+ export type AlertType = 'info' | 'warning' | 'error';
3
+ export type AlertProps = {
4
+ title: ReactNode;
5
+ type: AlertType;
6
+ isExpandedDefault?: boolean;
7
+ readonly children?: ReactNode;
8
+ };
package/Alert/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -55,8 +55,7 @@ export function Checkbox(props) {
55
55
  }, checkboxMarkup, React.createElement(TooltipTrigger, {
56
56
  content: tooltip,
57
57
  padding: "4px 0",
58
- view: "question",
59
- color: Color.PHANTOM
58
+ view: "question"
60
59
  }));
61
60
  }
62
61
  return checkboxMarkup;
package/Radio/Radio.js CHANGED
@@ -53,8 +53,7 @@ export function Radio(props) {
53
53
  content: tooltip,
54
54
  padding: size === 'compact' ? '0' : '4px 0',
55
55
  position: "top-middle",
56
- view: "question",
57
- color: Color.PHANTOM
56
+ view: "question"
58
57
  }));
59
58
  }
60
59
  return radioMarkup;
@@ -1,19 +1,10 @@
1
1
  import { type ReactElement } from 'react';
2
- import { type Color } from '@pushwoosh/kit-constants';
3
2
  import type { TooltipProps } from './types';
4
3
  export type TooltipTriggerView = 'question' | 'info' | 'warning' | 'error';
5
- type TooltipBaseProps = TooltipProps & {
4
+ export type TooltipTriggerProps = TooltipProps & {
6
5
  padding?: string | number;
7
6
  size?: 'small' | 'medium';
8
7
  hover?: boolean;
8
+ view: TooltipTriggerView;
9
9
  };
10
- type TooltipTriggerWithColor = TooltipBaseProps & {
11
- view: 'question' | 'info';
12
- color: Color.MAIN | Color.PHANTOM;
13
- };
14
- type TooltipTriggerWithoutColor = TooltipBaseProps & {
15
- view: 'warning' | 'error';
16
- };
17
- export type TooltipTriggerProps = TooltipTriggerWithColor | TooltipTriggerWithoutColor;
18
10
  export declare function TooltipTrigger({ padding, view, size, hover, ...tooltipProps }: TooltipTriggerProps): ReactElement;
19
- export {};
@@ -9,7 +9,6 @@ export function TooltipTrigger({
9
9
  hover = true,
10
10
  ...tooltipProps
11
11
  }) {
12
- const color = view === 'error' || view === 'warning' ? TooltipTriggerViewMap[view].color : tooltipProps.color;
13
12
  const hoverColor = hover ? TooltipTriggerViewMap[view].hoverColor : undefined;
14
13
  const {
15
14
  icon: Icon
@@ -18,7 +17,7 @@ export function TooltipTrigger({
18
17
  ...tooltipProps
19
18
  }, React.createElement(HelpIconWrapper, {
20
19
  "$padding": padding,
21
- "$color": color,
20
+ "$color": TooltipTriggerViewMap[view].color,
22
21
  "$hoverColor": hoverColor
23
22
  }, React.createElement(Icon, {
24
23
  size: size,
package/Tooltip/maps.js CHANGED
@@ -163,12 +163,12 @@ export function getLeftPosition(position, offset) {
163
163
  }
164
164
  export const TooltipTriggerViewMap = {
165
165
  info: {
166
- color: Color.MAIN,
166
+ color: Color.PHANTOM,
167
167
  hoverColor: Color.PRIMARY_HOVER,
168
168
  icon: InfoRoundIcon
169
169
  },
170
170
  question: {
171
- color: Color.MAIN,
171
+ color: Color.PHANTOM,
172
172
  hoverColor: Color.PRIMARY_HOVER,
173
173
  icon: HelpRoundIcon
174
174
  },
package/index.d.ts CHANGED
@@ -37,3 +37,4 @@ export { CodeEditor } from './CodeEditor';
37
37
  export { EnhancedInput, SearchInput } from './EnhancedInput';
38
38
  export { Chip } from './Chip';
39
39
  export { RichMessageEditor, RichMessageViewer, type DynamicContent } from './RichMessageEditor';
40
+ export { Alert } from './Alert';
package/index.js CHANGED
@@ -36,4 +36,5 @@ export { NumberPicker } from './NumberPicker';
36
36
  export { CodeEditor } from './CodeEditor';
37
37
  export { EnhancedInput, SearchInput } from './EnhancedInput';
38
38
  export { Chip } from './Chip';
39
- export { RichMessageEditor, RichMessageViewer } from './RichMessageEditor';
39
+ export { RichMessageEditor, RichMessageViewer } from './RichMessageEditor';
40
+ export { Alert } from './Alert';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",