@pushwoosh/dumb-components 1.1.68 → 1.1.69

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.
package/Select/styles.js CHANGED
@@ -2,15 +2,15 @@ import ReactSelect from 'react-select';
2
2
  import ReactSelectAsync from 'react-select/async';
3
3
  import ReactSelectCreatable from 'react-select/creatable';
4
4
  import styled, { css } from 'styled-components';
5
- import { Color, Spacing, FontSize, LineHeight, UnitSize } from '@pushwoosh/kit-constants';
5
+ import { Color, FontSize, LineHeight, UnitSize } from '@pushwoosh/kit-constants';
6
6
  import { CLASS_NAME_PREFIX } from './constants';
7
- const selectStyles = css([".", "__control{width:", ";min-width:", ";height:auto;min-height:", ";font-size:", ";line-height:", ";color:", ";background-color:", ";border:", ";box-sizing:border-box;}.", "__indicator{display:flex;align-items:center;justify-content:center;padding:", " ", ";}.", "__menu{width:", ";min-width:", ";font-size:", ";line-height:", ";}.", "__indicator-separator{display:none;}.", "__control--is-focused{border:1px solid ", ";box-shadow:none;}.", "__control--is-disabled{background-color:", ";}.", "__control:hover{border:", ";}.", "__control--is-focused:hover{border:1px solid ", ";box-shadow:none;}.", "__placeholder{display:flex;width:100%;color:", ";white-space:nowrap;text-overflow:clip;}.", "__multi-value{background:", ";}.", "__multi-value__label{color:", ";}.", "__multi-value__remove{color:", ";}.", "__multi-value__remove:hover{color:", ";background:", ";}"], CLASS_NAME_PREFIX, ({
7
+ const selectStyles = css([".", "__control{width:", ";min-width:", ";height:auto;min-height:", ";font-size:", ";line-height:", ";color:", ";background-color:", ";border:", ";box-sizing:border-box;}.", "__indicator{display:flex;align-items:center;justify-content:center;padding:6px 8px;}.", "__menu{width:", ";min-width:", ";font-size:", ";line-height:", ";}.", "__indicator-separator{display:none;}.", "__control--is-focused{border:1px solid ", ";box-shadow:none;}.", "__control--is-disabled{background-color:", ";}.", "__control:hover{border:", ";}.", "__control--is-focused:hover{border:1px solid ", ";box-shadow:none;}.", "__placeholder{display:flex;width:100%;color:", ";white-space:nowrap;text-overflow:clip;}.", "__multi-value{background:", ";}.", "__multi-value__label{color:", ";}.", "__multi-value__remove{color:", ";}.", "__multi-value__remove:hover{color:", ";background:", ";}"], CLASS_NAME_PREFIX, ({
8
8
  width
9
9
  }) => width || '100%', ({
10
10
  width
11
11
  }) => width || '150px', UnitSize.FIELD_HEIGHT, FontSize.REGULAR, LineHeight.REGULAR, Color.MAIN, Color.CLEAR, ({
12
12
  $isErrored
13
- }) => $isErrored ? `1px solid ${Color.DANGER}` : `1px solid ${Color.FORM}`, CLASS_NAME_PREFIX, Spacing.S2, Spacing.S3, CLASS_NAME_PREFIX, ({
13
+ }) => $isErrored ? `1px solid ${Color.DANGER}` : `1px solid ${Color.FORM}`, CLASS_NAME_PREFIX, CLASS_NAME_PREFIX, ({
14
14
  width
15
15
  }) => width || '100%', ({
16
16
  width
package/Toast/Toast.js CHANGED
@@ -2,8 +2,9 @@ import React from 'react';
2
2
  import { createPortal } from 'react-dom';
3
3
  import { InfoRoundIcon, CheckRoundIcon, WarningRoundIcon, DangerTriangleIcon, CloseIcon } from '@pushwoosh/kit-icons';
4
4
  import { H4, Paragraph } from '@pushwoosh/kit-typography';
5
+ import { Button } from '../Button';
5
6
  import { TypeColorMap } from './constants';
6
- import { RootBox, IconBox, ContentBox, CloseBox } from './styles';
7
+ import { RootBox, IconBox, ContentBox, ButtonBox, CloseBox } from './styles';
7
8
  function getIconByType(type) {
8
9
  switch (type) {
9
10
  case 'info':
@@ -49,12 +50,19 @@ export function Toast(props) {
49
50
  title,
50
51
  description,
51
52
  type,
52
- additionalContent
53
+ buttonText,
54
+ onButtonClick
53
55
  } = toast;
54
56
  return createPortal(React.createElement(RootBox, {
55
57
  open: open,
56
- type: type
57
- }, React.createElement(IconBox, null, getIconByType(type)), React.createElement(ContentBox, null, React.createElement(H4, null, title), description && React.createElement(Paragraph, null, description), additionalContent && React.createElement("div", null, additionalContent)), React.createElement(CloseBox, {
58
+ type: type,
59
+ "$hasButton": !!(buttonText && onButtonClick)
60
+ }, React.createElement(IconBox, null, getIconByType(type)), React.createElement(ContentBox, null, React.createElement(H4, null, title), description && React.createElement(Paragraph, null, description)), buttonText && onButtonClick && React.createElement(ButtonBox, null, React.createElement(Button, {
61
+ view: "ghost",
62
+ size: "compact",
63
+ color: "primary",
64
+ onClick: onButtonClick
65
+ }, buttonText)), React.createElement(CloseBox, {
58
66
  onClick: onClose
59
67
  }, React.createElement(CloseIcon, {
60
68
  size: "medium"
@@ -18,18 +18,18 @@ export const ToastProvider = ({
18
18
  title = '',
19
19
  description = '',
20
20
  duration = DEFAULT_DURATION,
21
- type = 'info',
22
- additionalContent = null
21
+ type = 'info'
23
22
  }) => {
24
23
  setOpen(true);
25
24
  setToast({
26
25
  title,
27
26
  description,
28
27
  duration,
29
- type,
30
- additionalContent
28
+ type
31
29
  });
32
- setTimeout(closeToast, duration);
30
+ if (typeof duration === 'number') {
31
+ setTimeout(closeToast, duration);
32
+ }
33
33
  }, [closeToast]);
34
34
  const contextValue = useMemo(() => ({
35
35
  openToast,
@@ -21,9 +21,8 @@ export type ToastType = 'info' | 'success' | 'warning' | 'error';
21
21
  export type ToastParams = {
22
22
  title: string;
23
23
  description?: string;
24
- duration: number;
24
+ duration: number | false;
25
25
  type: ToastType;
26
- additionalContent?: ReactNode;
27
26
  };
28
27
 
29
28
  export type OpenToastParams = {
@@ -31,7 +30,6 @@ export type OpenToastParams = {
31
30
  description?: string;
32
31
  duration?: number;
33
32
  type?: ToastType;
34
- additionalContent?: ReactNode;
35
33
  };
36
34
 
37
35
  export interface ToastContextProps {
@@ -115,12 +113,6 @@ function ComponentWithCustomToast() {
115
113
  title: 'Custom Toast',
116
114
  description: 'This toast has additional content.',
117
115
  type: 'info',
118
- additionalContent: (
119
- <div style={{ marginTop: 8 }}>
120
- <button>Action 1</button>
121
- <button>Action 2</button>
122
- </div>
123
- ),
124
116
  });
125
117
  };
126
118
 
@@ -151,7 +143,6 @@ function ComponentWithCustomToast() {
151
143
  | description | string | No | - | Optional description text |
152
144
  | duration | number | No | 3000 | Toast display duration in milliseconds |
153
145
  | type | ToastType | No | 'info' | Toast type affecting icon and color |
154
- | additionalContent | ReactNode | No | - | Custom content to display below description |
155
146
 
156
147
  ### Toast Types
157
148
 
@@ -209,7 +200,6 @@ When working with the Toast component:
209
200
  3. **Error Handling**: The hook throws an error if used outside of provider context
210
201
  4. **Duration Management**: Consider appropriate duration based on toast importance and content length
211
202
  5. **Type Selection**: Choose appropriate toast type based on user action outcome
212
- 6. **Custom Content**: Use additionalContent for action buttons or extra information
213
203
  7. **Accessibility**: Toast messages should be descriptive for screen readers
214
204
  8. **Portal Rendering**: Remember that toasts render to document.body, not inline
215
205
  9. **Single Instance**: Only one toast displays at a time; new toasts replace current ones
@@ -227,4 +217,4 @@ When working with the Toast component:
227
217
  - Use descriptions for additional context
228
218
  - Choose appropriate durations (3s for success, 5s+ for errors)
229
219
  - Provide manual close for critical messages
230
- - Test toast behavior in different viewport sizes
220
+ - Test toast behavior in different viewport sizes
package/Toast/styles.d.ts CHANGED
@@ -2,7 +2,9 @@ import type { ToastType } from './types';
2
2
  export declare const RootBox: import("styled-components").StyledComponent<"div", any, {
3
3
  open: boolean;
4
4
  type: ToastType;
5
+ $hasButton?: boolean;
5
6
  }, never>;
6
7
  export declare const IconBox: import("styled-components").StyledComponent<"div", any, {}, never>;
7
8
  export declare const ContentBox: import("styled-components").StyledComponent<"div", any, {}, never>;
9
+ export declare const ButtonBox: import("styled-components").StyledComponent<"div", any, {}, never>;
8
10
  export declare const CloseBox: import("styled-components").StyledComponent<"div", any, {}, never>;
package/Toast/styles.js CHANGED
@@ -1,23 +1,29 @@
1
1
  import styled from 'styled-components';
2
- import { Color, Spacing, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
2
+ import { Color, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
3
3
  import { TypeColorMap } from './constants';
4
4
  export const RootBox = styled.div.withConfig({
5
5
  displayName: "RootBox",
6
6
  componentId: "sc-8jll5u-0"
7
- })(["position:fixed;display:flex;align-items:flex-start;width:380px;top:", ";left:50%;transform:translateX(-50%);color:", ";padding:", " 0 ", ";border-radius:", ";border:1px solid ", ";background:", ";box-shadow:", ";transition:top 250ms;z-index:999999999;"], ({
7
+ })(["position:fixed;display:grid;grid-template-columns:", ";align-items:center;width:380px;top:", ";left:50%;transform:translateX(-50%);color:", ";padding:16px 0 16px;border-radius:", ";border:1px solid ", ";background:", ";box-shadow:", ";transition:top 250ms;z-index:999999999;"], ({
8
+ $hasButton
9
+ }) => $hasButton ? '56px 1fr auto auto' : '56px 1fr auto', ({
8
10
  open
9
- }) => open ? '50px' : '-250px', Color.MAIN, Spacing.S5, Spacing.S5, ShapeRadius.DIALOG, ({
11
+ }) => open ? '50px' : '-250px', Color.MAIN, ShapeRadius.DIALOG, ({
10
12
  type
11
13
  }) => TypeColorMap[type], Color.CLEAR, Shadow.LARGE);
12
14
  export const IconBox = styled.div.withConfig({
13
15
  displayName: "IconBox",
14
16
  componentId: "sc-8jll5u-1"
15
- })(["display:flex;align-items:center;justify-content:center;width:56px;height:100%;padding:0 ", ";box-sizing:border-box;"], Spacing.S5);
17
+ })(["display:flex;align-items:center;justify-content:center;width:56px;height:100%;padding:0 16px;box-sizing:border-box;"]);
16
18
  export const ContentBox = styled.div.withConfig({
17
19
  displayName: "ContentBox",
18
20
  componentId: "sc-8jll5u-2"
19
- })(["display:flex;flex-direction:column;justify-content:center;width:100%;min-height:24px;flex-grow:1;gap:", ";"], Spacing.S0);
21
+ })(["display:flex;flex-direction:column;justify-content:center;width:100%;min-height:24px;flex:1 1 auto;gap:2px;"]);
22
+ export const ButtonBox = styled.div.withConfig({
23
+ displayName: "ButtonBox",
24
+ componentId: "sc-8jll5u-3"
25
+ })(["display:flex;align-items:center;max-width:120px;box-sizing:border-box;"]);
20
26
  export const CloseBox = styled.div.withConfig({
21
27
  displayName: "CloseBox",
22
- componentId: "sc-8jll5u-3"
23
- })(["display:flex;padding:0 14px;cursor:pointer;"]);
28
+ componentId: "sc-8jll5u-4"
29
+ })(["display:flex;padding:0 14px 0 6px;cursor:pointer;"]);
package/Toast/types.d.ts CHANGED
@@ -3,16 +3,16 @@ export type ToastType = 'info' | 'success' | 'warning' | 'error';
3
3
  export type ToastParams = {
4
4
  title: string;
5
5
  description?: string;
6
- duration: number;
6
+ duration: number | false;
7
7
  type: ToastType;
8
- additionalContent?: ReactNode;
8
+ buttonText?: string;
9
+ onButtonClick?: () => void;
9
10
  };
10
11
  export type OpenToastParams = {
11
12
  title: string;
12
13
  description?: string;
13
- duration?: number;
14
+ duration?: number | false;
14
15
  type?: ToastType;
15
- additionalContent?: ReactNode;
16
16
  };
17
17
  export interface ToastContextProps {
18
18
  openToast: (params: OpenToastParams) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.68",
3
+ "version": "1.1.69",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",