@pushwoosh/dumb-components 1.1.228 → 1.1.230
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/RichMessageEditor/RichMessageEditor.js +4 -0
- package/RichMessageEditor/RichMessageEditor.types.d.ts +4 -0
- package/RichMessageEditor/slate/SlateEditor.d.ts +2 -0
- package/RichMessageEditor/slate/SlateEditor.js +4 -0
- package/RichMessageEditor/slate/SlateEditor.styled.d.ts +1 -0
- package/RichMessageEditor/slate/SlateEditor.styled.js +4 -2
- package/WhatsAppPreview/WhatsAppPreview.js +39 -37
- package/WhatsAppPreview/constants.d.ts +2 -0
- package/WhatsAppPreview/constants.js +2 -0
- package/WhatsAppPreview/styles.d.ts +19 -0
- package/WhatsAppPreview/styles.js +21 -10
- package/package.json +1 -1
|
@@ -25,7 +25,9 @@ export const RichMessageEditor = ({
|
|
|
25
25
|
title,
|
|
26
26
|
initialValue,
|
|
27
27
|
minHeight,
|
|
28
|
+
placeholder,
|
|
28
29
|
error,
|
|
30
|
+
isErrored,
|
|
29
31
|
canUsePersonalization,
|
|
30
32
|
canUseEmoji,
|
|
31
33
|
onChange,
|
|
@@ -123,6 +125,8 @@ export const RichMessageEditor = ({
|
|
|
123
125
|
}),
|
|
124
126
|
children: [_jsx(SlateEditable, {
|
|
125
127
|
minHeight: minHeight,
|
|
128
|
+
placeholder: placeholder,
|
|
129
|
+
isErrored: isErrored || !!error,
|
|
126
130
|
onFocus: () => {
|
|
127
131
|
setIsFocused(true);
|
|
128
132
|
const {
|
|
@@ -24,8 +24,12 @@ export type RichMessageEditorProps = {
|
|
|
24
24
|
onChange: (value: string) => void;
|
|
25
25
|
/** Minimum editor height (CSS value). */
|
|
26
26
|
minHeight?: string;
|
|
27
|
+
/** Hint shown while the editor is empty. */
|
|
28
|
+
placeholder?: string;
|
|
27
29
|
/** Error message; switches the field to the error state. */
|
|
28
30
|
error?: ReactNode;
|
|
31
|
+
/** Draw the error border without an error message. */
|
|
32
|
+
isErrored?: boolean;
|
|
29
33
|
/** Enable inserting personalization (dynamic-content) tokens. */
|
|
30
34
|
canUsePersonalization?: boolean;
|
|
31
35
|
/** Enable the emoji picker. */
|
|
@@ -26,6 +26,8 @@ export const SlateEditor = ({
|
|
|
26
26
|
};
|
|
27
27
|
export const SlateEditable = ({
|
|
28
28
|
minHeight,
|
|
29
|
+
placeholder,
|
|
30
|
+
isErrored,
|
|
29
31
|
onFocus,
|
|
30
32
|
onDelete
|
|
31
33
|
}) => {
|
|
@@ -34,6 +36,8 @@ export const SlateEditable = ({
|
|
|
34
36
|
});
|
|
35
37
|
return _jsx(EditableStyled, {
|
|
36
38
|
"$minHeight": minHeight,
|
|
39
|
+
"$isErrored": isErrored,
|
|
40
|
+
placeholder: placeholder,
|
|
37
41
|
renderElement: renderElementPersistent,
|
|
38
42
|
onFocus: onFocus
|
|
39
43
|
});
|
|
@@ -15,4 +15,5 @@ export declare const EditableStyled: import("styled-components").StyledComponent
|
|
|
15
15
|
disableDefaultStyles?: boolean | undefined;
|
|
16
16
|
} & import("react").TextareaHTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>, any, {
|
|
17
17
|
$minHeight?: string;
|
|
18
|
+
$isErrored?: boolean;
|
|
18
19
|
}, never>;
|
|
@@ -4,6 +4,8 @@ import { Color, FontSize, FontWeight, ShapeRadius } from '@pushwoosh/kit-constan
|
|
|
4
4
|
export const EditableStyled = styled(Editable).withConfig({
|
|
5
5
|
displayName: "EditableStyled",
|
|
6
6
|
componentId: "sc-1frhl1f-0"
|
|
7
|
-
})(["font-weight:", ";font-size:", ";line-height:140%;padding:8px;color:", ";background:", ";caret-color:", ";border:1px solid ", ";border-radius:", ";overflow-x:auto;", " &:focus{border-color:", ";outline:none;}& > p{margin:4px 0;&:first-child{margin-top:0;}&:last-child{margin-bottom:0;}}"], FontWeight.REGULAR, FontSize.REGULAR, Color.MAIN, Color.CLEAR, Color.BRIGHT,
|
|
7
|
+
})(["font-weight:", ";font-size:", ";line-height:140%;padding:8px;color:", ";background:", ";caret-color:", ";border:1px solid ", ";border-radius:", ";overflow-x:auto;", " & [data-slate-placeholder='true']{color:", ";opacity:1 !important;}&:focus{border-color:", ";outline:none;}& > p{position:relative;margin:4px 0;&:first-child{margin-top:0;}&:last-child{margin-bottom:0;}}"], FontWeight.REGULAR, FontSize.REGULAR, Color.MAIN, Color.CLEAR, Color.BRIGHT, ({
|
|
8
|
+
$isErrored
|
|
9
|
+
}) => $isErrored ? Color.DANGER : Color.FORM, ShapeRadius.CONTROL, ({
|
|
8
10
|
$minHeight
|
|
9
|
-
}) => $minHeight && `min-height: ${$minHeight};`, Color.BRIGHT);
|
|
11
|
+
}) => $minHeight && `min-height: ${$minHeight};`, Color.PHANTOM, Color.BRIGHT);
|
|
@@ -6,7 +6,7 @@ import { WhatsAppMessageContent } from './components/WhatsAppMessageContent';
|
|
|
6
6
|
import { WHATSAPP_CARD_PADDING } from './constants';
|
|
7
7
|
import { isMessageDrawable } from './helpers';
|
|
8
8
|
import { Lang } from './polyglot';
|
|
9
|
-
import { AppBar, AppName, Card, MissedGlyph, MissedHint, MissedRow, MissedTitle, PreviewText } from './styles';
|
|
9
|
+
import { AppBar, AppName, Backdrop, Card, MissedGlyph, MissedHint, MissedRow, MissedTitle, PreviewText } from './styles';
|
|
10
10
|
import { Spinner } from '../Spinner';
|
|
11
11
|
/** Renders a WhatsApp message the way the recipient sees it, WhatsApp markup and attachments included. */
|
|
12
12
|
export function WhatsAppPreview(props) {
|
|
@@ -18,46 +18,48 @@ export function WhatsAppPreview(props) {
|
|
|
18
18
|
isContentMissing = false
|
|
19
19
|
} = props;
|
|
20
20
|
const isDrawable = !isContentMissing && message !== undefined && isMessageDrawable(message);
|
|
21
|
-
return
|
|
22
|
-
children:
|
|
23
|
-
children: [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
}), !isLoading && isContentMissing && _jsxs(MissedRow, {
|
|
38
|
-
children: [_jsx(MissedGlyph, {
|
|
39
|
-
children: _jsx(CloseIcon, {
|
|
21
|
+
return _jsx(Backdrop, {
|
|
22
|
+
children: _jsxs(Card, {
|
|
23
|
+
children: [applicationName && _jsxs(AppBar, {
|
|
24
|
+
children: [_jsx(WhatsappIcon, {
|
|
25
|
+
size: "small",
|
|
26
|
+
view: "filled"
|
|
27
|
+
}), _jsx(AppName, {
|
|
28
|
+
children: applicationName
|
|
29
|
+
})]
|
|
30
|
+
}), isLoading && _jsx(Horizontal, {
|
|
31
|
+
"$alignItems": "center",
|
|
32
|
+
"$justifyContent": "center",
|
|
33
|
+
"$padding": WHATSAPP_CARD_PADDING,
|
|
34
|
+
children: _jsx(Spinner, {
|
|
35
|
+
color: Color.LOCKED,
|
|
40
36
|
size: "medium"
|
|
41
37
|
})
|
|
42
|
-
}), _jsxs(
|
|
43
|
-
children: [_jsx(
|
|
44
|
-
children: _jsx(
|
|
45
|
-
|
|
46
|
-
})
|
|
47
|
-
}), _jsx(MissedHint, {
|
|
48
|
-
children: _jsx(Lang, {
|
|
49
|
-
message: "DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT"
|
|
38
|
+
}), !isLoading && isContentMissing && _jsxs(MissedRow, {
|
|
39
|
+
children: [_jsx(MissedGlyph, {
|
|
40
|
+
children: _jsx(CloseIcon, {
|
|
41
|
+
size: "medium"
|
|
50
42
|
})
|
|
43
|
+
}), _jsxs(Vertical, {
|
|
44
|
+
children: [_jsx(MissedTitle, {
|
|
45
|
+
children: _jsx(Lang, {
|
|
46
|
+
message: "DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE"
|
|
47
|
+
})
|
|
48
|
+
}), _jsx(MissedHint, {
|
|
49
|
+
children: _jsx(Lang, {
|
|
50
|
+
message: "DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT"
|
|
51
|
+
})
|
|
52
|
+
})]
|
|
51
53
|
})]
|
|
54
|
+
}), !isLoading && !isContentMissing && !isDrawable && _jsx(PreviewText, {
|
|
55
|
+
"$color": Color.LOCKED,
|
|
56
|
+
"$ellipsis": true,
|
|
57
|
+
children: emptyText ?? _jsx(Lang, {
|
|
58
|
+
message: "DUMB.WHATSAPP_PREVIEW.EMPTY"
|
|
59
|
+
})
|
|
60
|
+
}), !isLoading && isDrawable && _jsx(WhatsAppMessageContent, {
|
|
61
|
+
message: message
|
|
52
62
|
})]
|
|
53
|
-
})
|
|
54
|
-
"$color": Color.LOCKED,
|
|
55
|
-
"$ellipsis": true,
|
|
56
|
-
children: emptyText ?? _jsx(Lang, {
|
|
57
|
-
message: "DUMB.WHATSAPP_PREVIEW.EMPTY"
|
|
58
|
-
})
|
|
59
|
-
}), !isLoading && isDrawable && _jsx(WhatsAppMessageContent, {
|
|
60
|
-
message: message
|
|
61
|
-
})]
|
|
63
|
+
})
|
|
62
64
|
});
|
|
63
65
|
}
|
|
@@ -13,6 +13,8 @@ export declare const WHATSAPP_COLOR: {
|
|
|
13
13
|
/** Card geometry from the design: 280px of content inside a 12px padding and a 1px border, border-box. */
|
|
14
14
|
export declare const WHATSAPP_CARD_WIDTH = 306;
|
|
15
15
|
export declare const WHATSAPP_CARD_PADDING = 12;
|
|
16
|
+
export declare const WHATSAPP_BACKDROP_PADDING = 24;
|
|
17
|
+
export declare const WHATSAPP_BACKDROP_WIDTH: number;
|
|
16
18
|
export declare const WHATSAPP_APP_BAR_GAP = 6;
|
|
17
19
|
export declare const WHATSAPP_APP_BAR_PADDING: {
|
|
18
20
|
vertical: number;
|
|
@@ -13,6 +13,8 @@ export const WHATSAPP_COLOR = {
|
|
|
13
13
|
/** Card geometry from the design: 280px of content inside a 12px padding and a 1px border, border-box. */
|
|
14
14
|
export const WHATSAPP_CARD_WIDTH = 306;
|
|
15
15
|
export const WHATSAPP_CARD_PADDING = 12;
|
|
16
|
+
export const WHATSAPP_BACKDROP_PADDING = 24;
|
|
17
|
+
export const WHATSAPP_BACKDROP_WIDTH = WHATSAPP_CARD_WIDTH + WHATSAPP_BACKDROP_PADDING * 2;
|
|
16
18
|
export const WHATSAPP_APP_BAR_GAP = 6;
|
|
17
19
|
export const WHATSAPP_APP_BAR_PADDING = {
|
|
18
20
|
vertical: 8,
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import { Color, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
2
|
+
export declare const Backdrop: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
3
|
+
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
4
|
+
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
5
|
+
$gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
|
|
6
|
+
$justifyContent?: import("@pushwoosh/kit-helpers/styled-helpers").JustifyContentValue | undefined;
|
|
7
|
+
} & {
|
|
8
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
9
|
+
$justifyItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
10
|
+
$placeItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
$gridAutoFlow: string;
|
|
13
|
+
} & {
|
|
14
|
+
$alignContent: string;
|
|
15
|
+
$justifyItems: string;
|
|
16
|
+
$bgColor: Color;
|
|
17
|
+
$borderRadius: ShapeRadius;
|
|
18
|
+
$padding: number;
|
|
19
|
+
$width: number;
|
|
20
|
+
}, "$gridAutoFlow" | "$bgColor" | "$borderRadius" | "$padding" | "$width" | "$alignContent" | "$justifyItems">;
|
|
2
21
|
export declare const Card: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
3
22
|
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
4
23
|
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
@@ -2,7 +2,18 @@ import styled from 'styled-components';
|
|
|
2
2
|
import { Color, FontFamily, FontSize, FontWeight, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
3
3
|
import { Columns, Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
4
|
import { Text } from '@pushwoosh/kit-typography';
|
|
5
|
-
import { WHATSAPP_APP_BAR_GAP, WHATSAPP_APP_BAR_PADDING, WHATSAPP_CARD_PADDING, WHATSAPP_CARD_WIDTH, WHATSAPP_MISSED_GAP, WHATSAPP_MISSED_GLYPH_SIZE } from './constants';
|
|
5
|
+
import { WHATSAPP_APP_BAR_GAP, WHATSAPP_BACKDROP_PADDING, WHATSAPP_BACKDROP_WIDTH, WHATSAPP_APP_BAR_PADDING, WHATSAPP_CARD_PADDING, WHATSAPP_CARD_WIDTH, WHATSAPP_MISSED_GAP, WHATSAPP_MISSED_GLYPH_SIZE } from './constants';
|
|
6
|
+
export const Backdrop = styled(Vertical).attrs({
|
|
7
|
+
$alignContent: 'start',
|
|
8
|
+
$justifyItems: 'center',
|
|
9
|
+
$bgColor: Color.SOFT_LIGHT,
|
|
10
|
+
$borderRadius: ShapeRadius.SECTION,
|
|
11
|
+
$padding: WHATSAPP_BACKDROP_PADDING,
|
|
12
|
+
$width: WHATSAPP_BACKDROP_WIDTH
|
|
13
|
+
}).withConfig({
|
|
14
|
+
displayName: "Backdrop",
|
|
15
|
+
componentId: "sc-15y0kbp-0"
|
|
16
|
+
})(["-webkit-font-smoothing:antialiased;&,*{box-sizing:border-box;}"]);
|
|
6
17
|
export const Card = styled(Vertical).attrs({
|
|
7
18
|
$alignContent: 'start',
|
|
8
19
|
$bgColor: Color.CLEAR,
|
|
@@ -13,8 +24,8 @@ export const Card = styled(Vertical).attrs({
|
|
|
13
24
|
$width: WHATSAPP_CARD_WIDTH
|
|
14
25
|
}).withConfig({
|
|
15
26
|
displayName: "Card",
|
|
16
|
-
componentId: "sc-15y0kbp-
|
|
17
|
-
})(["
|
|
27
|
+
componentId: "sc-15y0kbp-1"
|
|
28
|
+
})(["box-shadow:", ";overflow-wrap:anywhere;"], Shadow.LARGE);
|
|
18
29
|
// styled-components merges attrs OVER incoming props, so a plain object here would
|
|
19
30
|
// silently clobber every call-site `$color`; the callback keeps MAIN as a default only.
|
|
20
31
|
export const PreviewText = styled(Text).attrs(props => ({
|
|
@@ -22,7 +33,7 @@ export const PreviewText = styled(Text).attrs(props => ({
|
|
|
22
33
|
$color: props.$color ?? Color.MAIN
|
|
23
34
|
})).withConfig({
|
|
24
35
|
displayName: "PreviewText",
|
|
25
|
-
componentId: "sc-15y0kbp-
|
|
36
|
+
componentId: "sc-15y0kbp-2"
|
|
26
37
|
})(["overflow:hidden;line-height:18px;text-overflow:ellipsis;"]);
|
|
27
38
|
export const AppBar = styled(Horizontal).attrs({
|
|
28
39
|
$alignItems: 'center',
|
|
@@ -31,14 +42,14 @@ export const AppBar = styled(Horizontal).attrs({
|
|
|
31
42
|
$padding: WHATSAPP_APP_BAR_PADDING
|
|
32
43
|
}).withConfig({
|
|
33
44
|
displayName: "AppBar",
|
|
34
|
-
componentId: "sc-15y0kbp-
|
|
45
|
+
componentId: "sc-15y0kbp-3"
|
|
35
46
|
})(["margin:-", "px -", "px 0;border-bottom:1px solid ", ";color:", ";svg{display:block;}"], WHATSAPP_CARD_PADDING, WHATSAPP_CARD_PADDING, Color.DIVIDER, Color.SUCCESS);
|
|
36
47
|
export const AppName = styled(Text).attrs({
|
|
37
48
|
$color: Color.MAIN,
|
|
38
49
|
$ellipsis: true
|
|
39
50
|
}).withConfig({
|
|
40
51
|
displayName: "AppName",
|
|
41
|
-
componentId: "sc-15y0kbp-
|
|
52
|
+
componentId: "sc-15y0kbp-4"
|
|
42
53
|
})(["overflow:hidden;font-family:", ";font-size:", ";font-style:normal;font-weight:", ";line-height:18px;text-overflow:ellipsis;"], FontFamily.MAIN, FontSize.SMALL, FontWeight.MEDIUM);
|
|
43
54
|
export const MissedRow = styled(Columns).attrs({
|
|
44
55
|
$alignItems: 'center',
|
|
@@ -46,7 +57,7 @@ export const MissedRow = styled(Columns).attrs({
|
|
|
46
57
|
$sizes: `${WHATSAPP_MISSED_GLYPH_SIZE}px minmax(0, 1fr)`
|
|
47
58
|
}).withConfig({
|
|
48
59
|
displayName: "MissedRow",
|
|
49
|
-
componentId: "sc-15y0kbp-
|
|
60
|
+
componentId: "sc-15y0kbp-5"
|
|
50
61
|
})([""]);
|
|
51
62
|
export const MissedGlyph = styled(Horizontal).attrs({
|
|
52
63
|
$alignItems: 'center',
|
|
@@ -57,18 +68,18 @@ export const MissedGlyph = styled(Horizontal).attrs({
|
|
|
57
68
|
$height: WHATSAPP_MISSED_GLYPH_SIZE
|
|
58
69
|
}).withConfig({
|
|
59
70
|
displayName: "MissedGlyph",
|
|
60
|
-
componentId: "sc-15y0kbp-
|
|
71
|
+
componentId: "sc-15y0kbp-6"
|
|
61
72
|
})(["color:", ";svg{display:block;}"], Color.LOCKED);
|
|
62
73
|
export const MissedTitle = styled(Text).attrs({
|
|
63
74
|
$color: Color.MAIN,
|
|
64
75
|
$ellipsis: true
|
|
65
76
|
}).withConfig({
|
|
66
77
|
displayName: "MissedTitle",
|
|
67
|
-
componentId: "sc-15y0kbp-
|
|
78
|
+
componentId: "sc-15y0kbp-7"
|
|
68
79
|
})(["overflow:hidden;font-family:", ";font-size:", ";font-weight:", ";line-height:18px;text-overflow:ellipsis;"], FontFamily.MAIN, FontSize.SMALL, FontWeight.MEDIUM);
|
|
69
80
|
export const MissedHint = styled(Text).attrs({
|
|
70
81
|
$color: Color.LOCKED
|
|
71
82
|
}).withConfig({
|
|
72
83
|
displayName: "MissedHint",
|
|
73
|
-
componentId: "sc-15y0kbp-
|
|
84
|
+
componentId: "sc-15y0kbp-8"
|
|
74
85
|
})(["font-family:", ";font-size:", ";font-weight:", ";line-height:18px;"], FontFamily.MAIN, FontSize.SMALL, FontWeight.REGULAR);
|