@pushwoosh/dumb-components 1.0.47 → 1.0.49

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.
@@ -71,47 +71,44 @@ export const RichMessageEditor = ({
71
71
  onSelectionChange: onSelectionChange
72
72
  }, ({
73
73
  editor
74
- }) => {
75
- var _getDcByPath;
76
- return React.createElement(FieldBox, {
77
- title: title,
78
- boxRef: rootRef,
79
- actions: React.createElement(Collapse, {
80
- expanded: isFocused
81
- }, React.createElement(Horizontal, {
82
- "$gap": 8
83
- }, canUsePersonalization && React.createElement(ImSpan, {
84
- onClick: () => insertDynamicContent(editor)
85
- }, React.createElement(PersonalizationIcon, null), "Personalization"), canUseEmoji && React.createElement(ImSpan, {
86
- onClick: () => showDropArea({
87
- type: 'emoji'
88
- })
89
- }, React.createElement(EmojiIcon, null), "Emoji")))
90
- }, React.createElement(SlateEditable, {
91
- minHeight: minHeight,
92
- onFocus: () => {
93
- setIsFocused(true);
94
- const {
95
- selection
96
- } = editor;
97
- if (selection) {
98
- onSelectionChange(selection);
99
- }
100
- }
101
- }), showDrop && React.createElement(DropContent, {
102
- top: showDrop.yValue,
103
- left: showDrop.xValue
104
- }, showDrop.type === 'personalization' && (renderDynamicContent === null || renderDynamicContent === void 0 ? void 0 : renderDynamicContent({
105
- dc: ((_getDcByPath = getDcByPath(editor.children, showDrop.path)) === null || _getDcByPath === void 0 ? void 0 : _getDcByPath.dc) || {},
106
- onChange: newDC => {
107
- Transforms.setNodes(editor, {
108
- dc: newDC
109
- }, {
110
- at: showDrop.path
111
- });
74
+ }) => React.createElement(FieldBox, {
75
+ title: title,
76
+ boxRef: rootRef,
77
+ actions: React.createElement(Collapse, {
78
+ expanded: isFocused
79
+ }, React.createElement(Horizontal, {
80
+ "$gap": 8
81
+ }, canUsePersonalization && React.createElement(ImSpan, {
82
+ onClick: () => insertDynamicContent(editor)
83
+ }, React.createElement(PersonalizationIcon, null), "Personalization"), canUseEmoji && React.createElement(ImSpan, {
84
+ onClick: () => showDropArea({
85
+ type: 'emoji'
86
+ })
87
+ }, React.createElement(EmojiIcon, null), "Emoji")))
88
+ }, React.createElement(SlateEditable, {
89
+ minHeight: minHeight,
90
+ onFocus: () => {
91
+ setIsFocused(true);
92
+ const {
93
+ selection
94
+ } = editor;
95
+ if (selection) {
96
+ onSelectionChange(selection);
112
97
  }
113
- })), showDrop.type === 'emoji' && React.createElement(EmojiPicker, {
114
- onEmojiSelect: s => editor.insertText(s)
115
- })));
116
- });
98
+ }
99
+ }), showDrop && React.createElement(DropContent, {
100
+ top: showDrop.yValue,
101
+ left: showDrop.xValue
102
+ }, showDrop.type === 'personalization' && getDcByPath(editor.children, showDrop.path) && (renderDynamicContent === null || renderDynamicContent === void 0 ? void 0 : renderDynamicContent({
103
+ dc: getDcByPath(editor.children, showDrop.path).dc,
104
+ onChange: newDC => {
105
+ Transforms.setNodes(editor, {
106
+ dc: newDC
107
+ }, {
108
+ at: showDrop.path
109
+ });
110
+ }
111
+ })), showDrop.type === 'emoji' && React.createElement(EmojiPicker, {
112
+ onEmojiSelect: s => editor.insertText(s)
113
+ }))));
117
114
  };
@@ -1,7 +1,6 @@
1
1
  import React, { Fragment, useMemo } from 'react';
2
2
  import { DynamicContentBracket, DynamicContentRoot } from './RichMessageViewer.styled';
3
3
  import { isElement, string2content } from './slate/helpers';
4
- const arrayJoinReact = (arr, separator) => arr.flatMap((item, index) => index ? [separator, item] : [item]);
5
4
  export const RichMessageViewer = ({
6
5
  value,
7
6
  lineBreaks
@@ -9,7 +8,8 @@ export const RichMessageViewer = ({
9
8
  const content = useMemo(() => {
10
9
  return Array.isArray(value) ? value : string2content(value);
11
10
  }, [value]);
12
- return arrayJoinReact(content.map((node, index) => {
11
+ const separator = lineBreaks ? React.createElement("br", null) : ' ';
12
+ return content.map((node, index) => {
13
13
  const children = node.children.map((child, idx) => {
14
14
  if (isElement(child) && child.type === 'dc') {
15
15
  return (
@@ -21,8 +21,11 @@ export const RichMessageViewer = ({
21
21
  }
22
22
  return child.text;
23
23
  });
24
- return React.createElement(Fragment, {
25
- key: index
26
- }, children); // eslint-disable-line react/no-array-index-key
27
- }), lineBreaks ? React.createElement("br", null) : ' ');
24
+ return (
25
+ // eslint-disable-next-line react/no-array-index-key
26
+ React.createElement(Fragment, {
27
+ key: index
28
+ }, index > 0 && separator, children)
29
+ );
30
+ });
28
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.0.47",
3
+ "version": "1.0.49",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",