@pushwoosh/dumb-components 1.0.48 → 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.
@@ -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.48",
3
+ "version": "1.0.49",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",