@shoutem/ui 8.2.6 → 8.2.7-rc.0

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.
@@ -4,39 +4,35 @@ import PropTypes from 'prop-types';
4
4
  import { resolveDimensions } from '../services/Dimensions';
5
5
  import Image from './Image';
6
6
 
7
- const AttachmentRenderer = ({ id, type, style, attachments }) => {
8
- if (!attachments) {
7
+ const AttachmentRenderer = ({ tnode, style, attachments }) => {
8
+ if (_.isEmpty(attachments)) {
9
9
  return null;
10
10
  }
11
11
 
12
- if (type === 'image') {
13
- const image = _.find(attachments, { id });
12
+ const image = _.find(attachments, { id: tnode?.id });
14
13
 
15
- if (image && image.src) {
16
- const source = { uri: image.src };
17
- const imageSize = { width: image.width, height: image.height };
18
- const { height, width } = resolveDimensions(imageSize, style);
19
- const resolvedStyle = { alignSelf: 'center', height, width };
20
-
21
- return <Image source={source} key={id} style={resolvedStyle} />;
22
- }
14
+ if (!image || !image.src) {
15
+ return null;
23
16
  }
24
17
 
25
- return null;
18
+ const source = { uri: image.src };
19
+ const imageSize = { width: image.width, height: image.height };
20
+ const { height, width } = resolveDimensions(imageSize, style);
21
+ const resolvedStyle = { alignSelf: 'center', height, width };
22
+
23
+ return <Image source={source} key={tnode?.id} style={resolvedStyle} />;
26
24
  };
27
25
 
28
26
  AttachmentRenderer.propTypes = {
29
27
  attachments: PropTypes.oneOf([PropTypes.array, PropTypes.object]),
30
- id: PropTypes.any,
31
28
  style: PropTypes.any,
32
- type: PropTypes.any,
29
+ tnode: PropTypes.object,
33
30
  };
34
31
 
35
32
  AttachmentRenderer.defaultProps = {
36
- id: undefined,
37
- type: undefined,
38
33
  attachments: undefined,
39
34
  style: undefined,
35
+ tnode: {},
40
36
  };
41
37
 
42
38
  export default AttachmentRenderer;
@@ -13,7 +13,10 @@ import _ from 'lodash';
13
13
  import PropTypes from 'prop-types';
14
14
  import { connectStyle } from '@shoutem/theme';
15
15
  import VideoRenderer from '@shoutem/ui/html/components/VideoRenderer';
16
- import { videoModel } from '@shoutem/ui/html/services/HTMLElementModels';
16
+ import {
17
+ attachmentModel,
18
+ videoModel,
19
+ } from '@shoutem/ui/html/services/HTMLElementModels';
17
20
  import { View } from '../../components/View';
18
21
  import { resolveMaxWidth } from '../services/Dimensions';
19
22
  import { onElement } from '../services/DomVisitors';
@@ -76,7 +79,7 @@ class SimpleHtml extends PureComponent {
76
79
  table,
77
80
  attachment: props => (
78
81
  <AttachmentRenderer
79
- {...props}
82
+ tnode={props.tnode}
80
83
  attachments={attachments}
81
84
  style={style}
82
85
  />
@@ -115,6 +118,7 @@ class SimpleHtml extends PureComponent {
115
118
  table: tableModel,
116
119
  iframe: iframeModel,
117
120
  video: videoModel,
121
+ attachment: attachmentModel,
118
122
  ...customHtmlElementModels,
119
123
  },
120
124
  WebView,
@@ -5,3 +5,9 @@ export const videoModel = HTMLElementModel.fromCustomModel({
5
5
  tagName: 'video',
6
6
  isOpaque: true,
7
7
  });
8
+
9
+ export const attachmentModel = HTMLElementModel.fromCustomModel({
10
+ contentModel: HTMLContentModel.block,
11
+ tagName: 'attachment',
12
+ isOpaque: true,
13
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoutem/ui",
3
- "version": "8.2.6",
3
+ "version": "8.2.7-rc.0",
4
4
  "description": "Styleable set of components for React Native applications",
5
5
  "scripts": {
6
6
  "lint": "eslint .",