@antscorp/antsomi-ui 1.3.6-beta.71 → 1.3.6-beta.73

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.
@@ -11,7 +11,7 @@ import { AccountSharing } from '@antscorp/antsomi-ui/es/components/organism/Acco
11
11
  import { Help } from '@antscorp/antsomi-ui/es/components/organism/Help';
12
12
  import { Notification } from '@antscorp/antsomi-ui/es/components/organism/Notification';
13
13
  // Constants
14
- import { APP_CODES, APP_PERMISSION_DOMAIN, CDP_API, IAM_API, ISSUE_API, PERMISSION_API, PLATFORM_API, PORTALS_IDS, SOCKET_API, } from '@antscorp/antsomi-ui/es/constants';
14
+ import { APP_CODES, APP_PERMISSION_DOMAIN, CDP_API, IAM_API, ISSUE_API, PERMISSION_API, PLATFORM_API, PORTALS_IDS, SOCKET_API, MEDIA_TEMPLATE_API, } from '@antscorp/antsomi-ui/es/constants';
15
15
  import { useContextSelector } from 'use-context-selector';
16
16
  import { AppConfigContext } from '@antscorp/antsomi-ui/es/providers/AppConfigProvider';
17
17
  import { isNil } from 'lodash';
@@ -74,6 +74,7 @@ export const HeaderV2 = memo(props => {
74
74
  domain: CDP_API[env],
75
75
  domainTicket: ISSUE_API[env],
76
76
  domainPlatform: PLATFORM_API,
77
+ domainUpload: MEDIA_TEMPLATE_API[env],
77
78
  config: {
78
79
  ...configs.config,
79
80
  user_language: language,
@@ -20,6 +20,7 @@ import { getMediaSrc, getWhatsappComponentCls, isShowMedia } from '../utils';
20
20
  const { MARGIN_MESSAGE, PADDING_MESSAGE } = BASE.OFFSET;
21
21
  const headerStyle = { padding: PADDING_MESSAGE, paddingBottom: 0 };
22
22
  const bodyStyle = { padding: PADDING_MESSAGE };
23
+ const mediaStyle = { minWidth: BASE.LARGE.WIDTH };
23
24
  const cls = getWhatsappComponentCls();
24
25
  export default React.memo((props) => {
25
26
  const { carousel, body, messageIndex } = props;
@@ -60,6 +61,7 @@ export default React.memo((props) => {
60
61
  return (_jsx(SwiperSlideItem, { virtualIndex: cardIdx, children: _jsx(SkeletonMessage, { size: "large", messagePadding: 0, styles: {
61
62
  header: headerStyle,
62
63
  body: bodyStyle,
64
+ media: mediaStyle,
63
65
  }, media: isShowMedia(header?.format) ? (_jsx(MediaMessage, { src: getMediaSrc(header), format: header?.format })) : null, header: isHeaderTxt || isDoc ? _jsx(HeaderMessage, { ...header }) : null, body: _jsx(BodyMessage, { ...body }), footer: _jsx(FooterMessage, { buttons: buttons }) }) }, cardIdx));
64
66
  }) })] }));
65
67
  }, []);
@@ -1,6 +1,7 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable jsx-a11y/media-has-caption */
2
3
  // Libraries
3
- import { memo, useMemo } from 'react';
4
+ import { memo, useMemo, useState } from 'react';
4
5
  // Assets
5
6
  import AntLogo from '@antscorp/antsomi-ui/es/assets/images/logo/antsomi_logo.png';
6
7
  import MediaUnavailable from '@antscorp/antsomi-ui/es/assets/images/previews/media-unavailable.png';
@@ -10,6 +11,7 @@ import { Image } from 'antd';
10
11
  import { BASE } from '../../constants';
11
12
  export default memo((props) => {
12
13
  const { src, format } = props;
14
+ const [isVideoFails, setIsVideoFails] = useState(false);
13
15
  const { padding, objectFit, backgroundColor } = useMemo(() => {
14
16
  const isDoc = format === 'DOCUMENT';
15
17
  let [pd, bg, objFit] = [0, '#F7F8FC', 'cover'];
@@ -27,6 +29,18 @@ export default memo((props) => {
27
29
  objectFit: objFit,
28
30
  };
29
31
  }, [format, src]);
32
+ if (format === 'VIDEO') {
33
+ if (!src || isVideoFails) {
34
+ return (_jsx(Image, { src: isVideoFails ? MediaUnavailable : AntLogo, alt: "media message header", width: "100%", height: BASE.MEDIA.MAX_HEIGHT, style: {
35
+ objectFit,
36
+ padding,
37
+ backgroundColor,
38
+ }, fallback: MediaUnavailable }));
39
+ }
40
+ return (_jsxs("video", { width: "100%", height: BASE.MEDIA.MAX_HEIGHT, controls: true, autoPlay: false, onError: () => {
41
+ setIsVideoFails(true);
42
+ }, children: [_jsx("source", { src: src, type: "video/mp4" }), "Your browser does not support the video tag."] }));
43
+ }
30
44
  return (_jsx(Image, { src: src || AntLogo, alt: "media message header", width: "100%", height: BASE.MEDIA.MAX_HEIGHT, style: {
31
45
  objectFit,
32
46
  padding,
@@ -33,6 +33,22 @@ export const SAMPLE_PREVIEW = {
33
33
  },
34
34
  buttons: [{ type: 'URL', text: 'Grab the offer', url: 'https://test.com.vn' }],
35
35
  },
36
+ {
37
+ type: 'MEDIA',
38
+ header: {
39
+ format: 'VIDEO',
40
+ videoURL: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
41
+ },
42
+ body: {
43
+ text: `Hey {{1}}, we have an exclusive deal waiting for you! 🎉
44
+
45
+ Get {{2}}% OFF on your next purchase when you shop before {{3}}. Don't miss out on this special offer!
46
+
47
+ Use code: {{4}} at checkout.
48
+ `,
49
+ },
50
+ buttons: [{ type: 'URL', text: 'Shop now', url: 'https://test.com.vn' }],
51
+ },
36
52
  {
37
53
  type: 'MEDIA',
38
54
  header: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.6-beta.71",
3
+ "version": "1.3.6-beta.73",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",