@ray-js/t-agent-ui-ray 0.0.5-beta-1

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.
Files changed (116) hide show
  1. package/LICENSE.md +21 -0
  2. package/README-zh_CN.md +14 -0
  3. package/README.md +14 -0
  4. package/dist/ChatContainer/index.d.ts +9 -0
  5. package/dist/ChatContainer/index.js +124 -0
  6. package/dist/ChatContainer/index.less +10 -0
  7. package/dist/CustomCardRender/index.d.ts +8 -0
  8. package/dist/CustomCardRender/index.js +21 -0
  9. package/dist/CustomCardRender/index.less +2 -0
  10. package/dist/EchartsBlockRender/index.js +73 -0
  11. package/dist/EchartsBlockRender/index.json +3 -0
  12. package/dist/EchartsBlockRender/index.less +26 -0
  13. package/dist/EchartsBlockRender/index.rjs +15 -0
  14. package/dist/EchartsBlockRender/index.tyml +12 -0
  15. package/dist/EchartsBlockRender/loading.svg +1 -0
  16. package/dist/LowCodeCardRender/index.d.ts +8 -0
  17. package/dist/LowCodeCardRender/index.js +14 -0
  18. package/dist/LowCodeCardRender/index.less +2 -0
  19. package/dist/MarkdownRender/BlockParser.d.ts +18 -0
  20. package/dist/MarkdownRender/BlockParser.js +261 -0
  21. package/dist/MarkdownRender/index.d.ts +14 -0
  22. package/dist/MarkdownRender/index.js +72 -0
  23. package/dist/MarkdownRender/index.less +417 -0
  24. package/dist/MarkdownRender/theme/dark.less +65 -0
  25. package/dist/MarkdownRender/theme/light.less +64 -0
  26. package/dist/MessageInput/AsrInput.d.ts +14 -0
  27. package/dist/MessageInput/AsrInput.js +78 -0
  28. package/dist/MessageInput/icons/close-circle.svg +1 -0
  29. package/dist/MessageInput/icons/image.svg +1 -0
  30. package/dist/MessageInput/icons/loading.svg +1 -0
  31. package/dist/MessageInput/icons/plus.svg +1 -0
  32. package/dist/MessageInput/icons/send.svg +1 -0
  33. package/dist/MessageInput/icons/text.svg +11 -0
  34. package/dist/MessageInput/icons/video.svg +1 -0
  35. package/dist/MessageInput/icons/voice-active.svg +9 -0
  36. package/dist/MessageInput/icons/voice.svg +1 -0
  37. package/dist/MessageInput/index.d.ts +9 -0
  38. package/dist/MessageInput/index.js +246 -0
  39. package/dist/MessageInput/index.less +289 -0
  40. package/dist/MessageList/index.d.ts +12 -0
  41. package/dist/MessageList/index.js +61 -0
  42. package/dist/MessageList/index.less +19 -0
  43. package/dist/MessageRender/index.d.ts +10 -0
  44. package/dist/MessageRender/index.js +34 -0
  45. package/dist/MessageRender/index.less +14 -0
  46. package/dist/PrivateImage/index.d.ts +8 -0
  47. package/dist/PrivateImage/index.js +113 -0
  48. package/dist/TileRender/index.d.ts +11 -0
  49. package/dist/TileRender/index.js +32 -0
  50. package/dist/TileRender/index.less +4 -0
  51. package/dist/cards/WorkflowReplyCard/index.d.ts +11 -0
  52. package/dist/cards/WorkflowReplyCard/index.js +67 -0
  53. package/dist/cards/WorkflowReplyCard/index.less +37 -0
  54. package/dist/cards/map.d.ts +5 -0
  55. package/dist/cards/map.js +4 -0
  56. package/dist/contexts.d.ts +11 -0
  57. package/dist/contexts.js +16 -0
  58. package/dist/global.d.ts +19 -0
  59. package/dist/hooks/context.d.ts +11 -0
  60. package/dist/hooks/context.js +40 -0
  61. package/dist/hooks/index.d.ts +3 -0
  62. package/dist/hooks/index.js +3 -0
  63. package/dist/hooks/useAsrInput.d.ts +38 -0
  64. package/dist/hooks/useAsrInput.js +111 -0
  65. package/dist/hooks/useBlockInput.d.ts +18 -0
  66. package/dist/hooks/useBlockInput.js +148 -0
  67. package/dist/index.d.ts +14 -0
  68. package/dist/index.js +14 -0
  69. package/dist/logger.d.ts +2 -0
  70. package/dist/logger.js +3 -0
  71. package/dist/renderOption.d.ts +2 -0
  72. package/dist/renderOption.js +76 -0
  73. package/dist/tiles/BubbleTile/Feedback.d.ts +8 -0
  74. package/dist/tiles/BubbleTile/Feedback.js +39 -0
  75. package/dist/tiles/BubbleTile/feedback.less +35 -0
  76. package/dist/tiles/BubbleTile/index.d.ts +6 -0
  77. package/dist/tiles/BubbleTile/index.js +123 -0
  78. package/dist/tiles/BubbleTile/index.less +56 -0
  79. package/dist/tiles/BubbleTile/notice.svg +1 -0
  80. package/dist/tiles/BubbleTile/thumb-down-empty.svg +1 -0
  81. package/dist/tiles/BubbleTile/thumb-up-fill.svg +1 -0
  82. package/dist/tiles/ButtonsTile/index.d.ts +5 -0
  83. package/dist/tiles/ButtonsTile/index.js +18 -0
  84. package/dist/tiles/ButtonsTile/index.less +25 -0
  85. package/dist/tiles/CardTile/index.d.ts +6 -0
  86. package/dist/tiles/CardTile/index.js +20 -0
  87. package/dist/tiles/CardTile/index.less +3 -0
  88. package/dist/tiles/DocumentsTile/index.d.ts +5 -0
  89. package/dist/tiles/DocumentsTile/index.js +23 -0
  90. package/dist/tiles/DocumentsTile/index.less +13 -0
  91. package/dist/tiles/ImageTile/index.d.ts +5 -0
  92. package/dist/tiles/ImageTile/index.js +37 -0
  93. package/dist/tiles/ImageTile/index.less +9 -0
  94. package/dist/tiles/RecommendationsTile/index.d.ts +5 -0
  95. package/dist/tiles/RecommendationsTile/index.js +31 -0
  96. package/dist/tiles/RecommendationsTile/index.less +13 -0
  97. package/dist/tiles/TextTile/index.d.ts +9 -0
  98. package/dist/tiles/TextTile/index.js +27 -0
  99. package/dist/tiles/TextTile/index.less +3 -0
  100. package/dist/tiles/TimeTile/index.d.ts +5 -0
  101. package/dist/tiles/TimeTile/index.js +35 -0
  102. package/dist/tiles/TimeTile/index.less +10 -0
  103. package/dist/tiles/TipTile/index.d.ts +6 -0
  104. package/dist/tiles/TipTile/index.js +12 -0
  105. package/dist/tiles/TipTile/index.less +9 -0
  106. package/dist/tiles/VideoTile/index.d.ts +5 -0
  107. package/dist/tiles/VideoTile/index.js +49 -0
  108. package/dist/tiles/VideoTile/index.less +37 -0
  109. package/dist/tiles/WorkflowTile/index.d.ts +11 -0
  110. package/dist/tiles/WorkflowTile/index.js +30 -0
  111. package/dist/tiles/WorkflowTile/index.less +31 -0
  112. package/dist/tiles/map.d.ts +3 -0
  113. package/dist/tiles/map.js +24 -0
  114. package/dist/types.d.ts +26 -0
  115. package/dist/types.js +1 -0
  116. package/package.json +45 -0
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="13.3499755859375" height="13.29052734375" viewBox="0 0 13.3499755859375 13.29052734375"><g transform="matrix(1,0,0,-1,0,26.5810546875)"><path d="M11.4633,17.447487343749998L8.53345,17.447487343749998L8.53345,15.71415734375Q8.53345,14.86999734375,8.01726,14.20399334375Q7.51058,13.55027034375,6.71584,13.33393224375Q6.23674,13.20351514375,5.80143,13.46495734375Q5.44056,13.68169034375,5.26207,14.08328534375L3.26313,18.58089734375L2.06467,18.58089734375Q1.28851,18.56706734375,0.684763,19.12544734375Q0.109831,19.65717734375,0.00601715,20.42463734375L0,20.46911734375L0,24.758927343750003L0.00601637,24.80332734375Q0.110686,25.57722734375,0.703201,26.085827343749997Q1.29572,26.594327343750003,2.07646,26.58052734375L3.00012,26.580627343750002L3.00012,26.580827343750002L10.6388,26.580827343750002Q11.3293,26.588627343749998,11.8613,26.13652734375Q12.3933,25.68432734375,12.4979,24.99412734375L13.3258,19.59519734375Q13.4555,18.74066734375,12.889,18.08921734375Q12.3238,17.43927734375,11.4633,17.447487343749998ZM7.20012,18.78081734375L11.4668,18.78081734375L11.4744,18.78077734375Q11.721,18.77797734375,11.8828,18.964087343750002Q12.0447,19.15022734375,12.0078,19.39311734375L11.1797,24.794227343750002Q11.1101,25.25272734375,10.6388,25.24752734375L4.33346,25.24752734375L4.33346,19.45562734375L6.46786,14.65320734375Q6.7636,14.763007343750001,6.96341,15.02079734375Q7.20012,15.32621734375,7.20012,15.71415734375L7.20012,18.78081734375ZM3,25.247427343749997L3,19.91423734375L2.06467,19.91423734375Q1.80054,19.90966734375,1.59008,20.10431734375Q1.38161,20.29711734375,1.33333,20.565157343750002L1.33333,24.66242734375Q1.37862,24.908327343750003,1.57164,25.07402734375Q1.77928,25.25232734375,2.05288,25.247427343749997L3,25.247427343749997Z" fill-rule="evenodd" fill="#000000" fill-opacity="0.30000001192092896"/></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="13.3499755859375" height="13.29052734375" viewBox="0 0 13.3499755859375 13.29052734375"><g><path d="M11.4633,4.15696L8.53345,4.15696L8.53345,2.42363Q8.53345,1.57947,8.01726,0.913466Q7.51058,0.259743,6.71584,0.0434049Q6.23674,-0.0870122,5.80143,0.17443Q5.44056,0.391163,5.26207,0.792758L3.26313,5.29037L2.06467,5.29037Q1.28851,5.27654,0.684763,5.83492Q0.109831,6.36665,0.00601715,7.13411L0,7.17859L0,11.4684L0.00601637,11.5128Q0.110686,12.2867,0.703201,12.7953Q1.29572,13.3038,2.07646,13.29L3.00012,13.2901L3.00012,13.2903L10.6388,13.2903Q11.3293,13.2981,11.8613,12.846Q12.3933,12.3938,12.4979,11.7036L13.3258,6.30467Q13.4555,5.45014,12.889,4.79869Q12.3238,4.14875,11.4633,4.15696Z" fill-rule="evenodd" fill="#FFC323" fill-opacity="1"/></g></svg>
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import { ButtonsTileData } from '@ray-js/t-agent';
4
+ import { TileProps } from '../../types';
5
+ export default function ButtonsTile(props: TileProps<ButtonsTileData>): React.JSX.Element | null;
@@ -0,0 +1,18 @@
1
+ import "core-js/modules/esnext.iterator.map.js";
2
+ import { Button, View } from '@ray-js/components';
3
+ import React from 'react';
4
+ import './index.less';
5
+ export default function ButtonsTile(props) {
6
+ if (props.tile.locked) {
7
+ return null;
8
+ }
9
+ return /*#__PURE__*/React.createElement(View, {
10
+ className: "t-agent-buttons-tile"
11
+ }, props.tile.data.buttons.map(item => /*#__PURE__*/React.createElement(Button, {
12
+ key: "".concat(item.text, "-").concat(item.type || ''),
13
+ className: "t-agent-buttons-tile-button ".concat(item.type ? "t-agent-buttons-tile-button-".concat(item.type) : ''),
14
+ onClick: () => {
15
+ item.clickPayload && props.emitEvent(item.clickPayload);
16
+ }
17
+ }, item.text)));
18
+ }
@@ -0,0 +1,25 @@
1
+ .t-agent-buttons-tile {
2
+ display: flex;
3
+ flex-direction: column;
4
+ align-items: center;
5
+ justify-content: center;
6
+ margin: 16rpx 0;
7
+ }
8
+
9
+ .t-agent-buttons-tile > :not([hidden])~:not([hidden]) {
10
+ margin-top: 16rpx;
11
+ margin-bottom: 0;
12
+ }
13
+
14
+ .t-agent-buttons-tile-button {
15
+ padding: 20rpx 12rpx;
16
+ background: var(--app-B1);
17
+ color: var(--app-B1-N1);
18
+ width: 100%;
19
+ border-radius: 16rpx;
20
+ }
21
+
22
+ .t-agent-buttons-tile-button-primary {
23
+ background: var(--app-M1);
24
+ color: var(--app-M1-N1);
25
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import { CardTileData } from '@ray-js/t-agent';
4
+ import { TileProps } from '../../types';
5
+ declare const _default: React.MemoExoticComponent<(props: TileProps<CardTileData, any>) => React.JSX.Element | null>;
6
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { View } from '@ray-js/components';
3
+ import './index.less';
4
+ import { useRenderOptions } from '../../hooks';
5
+ const CardTile = props => {
6
+ const {
7
+ card
8
+ } = props.tile.data;
9
+ const {
10
+ renderCardAs
11
+ } = useRenderOptions();
12
+ const node = renderCardAs(card);
13
+ if (!node) {
14
+ return null;
15
+ }
16
+ return /*#__PURE__*/React.createElement(View, {
17
+ className: "t-agent-card-tile"
18
+ }, node);
19
+ };
20
+ export default /*#__PURE__*/React.memo(CardTile);
@@ -0,0 +1,3 @@
1
+ .t-agent-card-tile {
2
+
3
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import { DocumentsTileData } from '@ray-js/t-agent';
4
+ import { TileProps } from '../../types';
5
+ export default function DocumentsTile(props: TileProps<DocumentsTileData>): React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ import "core-js/modules/esnext.iterator.map.js";
2
+ import { View } from '@ray-js/components';
3
+ import React from 'react';
4
+ import './index.less';
5
+ import { useSendAction } from '../../hooks';
6
+ export default function DocumentsTile(props) {
7
+ const {
8
+ documents
9
+ } = props.tile.data;
10
+ const sendAction = useSendAction();
11
+ return /*#__PURE__*/React.createElement(View, {
12
+ className: "t-agent-documents-tile"
13
+ }, documents.map((item, index) => /*#__PURE__*/React.createElement(View, {
14
+ key: "".concat(item.url, "-").concat(item.title),
15
+ className: "t-agent-documents-tile-item",
16
+ onClick: () => {
17
+ sendAction({
18
+ type: 'openH5',
19
+ url: item.url
20
+ });
21
+ }
22
+ }, index + 1, ". ", item.title)));
23
+ }
@@ -0,0 +1,13 @@
1
+ .t-agent-documents-tile {
2
+ margin-top: 24rpx;
3
+ padding-top: 16rpx;
4
+ font-size: 26rpx;
5
+ border-top: 2rpx solid var(--app-B3-N7);
6
+ }
7
+
8
+ .t-agent-documents-tile-item {
9
+ color: var(--app-M4);
10
+ overflow: hidden;
11
+ text-overflow: ellipsis;
12
+ white-space: nowrap;
13
+ }
@@ -0,0 +1,5 @@
1
+ import './index.less';
2
+ import React from 'react';
3
+ import { ImageTileData } from '@ray-js/t-agent';
4
+ import { TileProps } from '../../types';
5
+ export default function ImageTile(props: TileProps<ImageTileData>): React.JSX.Element;
@@ -0,0 +1,37 @@
1
+ import "core-js/modules/web.dom-collections.iterator.js";
2
+ import './index.less';
3
+ import { View } from '@ray-js/components';
4
+ import React from 'react';
5
+ import PrivateImage from '../../PrivateImage';
6
+ import { useRenderOptions } from '../../hooks';
7
+ export default function ImageTile(props) {
8
+ const {
9
+ src
10
+ } = props.tile.data;
11
+ const {
12
+ getStaticResourceBizType
13
+ } = useRenderOptions();
14
+ const bizType = getStaticResourceBizType(src, 'image:view');
15
+ const [url, setUrl] = React.useState('');
16
+ return /*#__PURE__*/React.createElement(View, {
17
+ className: "t-agent-image-tile",
18
+ onClick: async () => {
19
+ // if (!u) {
20
+ // u = await downloadSign(src, bizType);
21
+ // setUrl(u);
22
+ // }
23
+ ty.previewImage({
24
+ current: 0,
25
+ urls: [url]
26
+ });
27
+ }
28
+ }, /*#__PURE__*/React.createElement(PrivateImage, {
29
+ bizType: bizType,
30
+ className: "t-agent-image-tile-image",
31
+ mode: "widthFix",
32
+ src: src,
33
+ onLoad: () => {
34
+ // emitEvent('followLatestMessage')
35
+ }
36
+ }));
37
+ }
@@ -0,0 +1,9 @@
1
+ .t-agent-image-tile {
2
+ margin-top: 16rpx;
3
+ width: 300rpx;
4
+ }
5
+
6
+ .t-agent-image-tile-image {
7
+ width: 100%;
8
+ border-radius: 16rpx;
9
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import { RecommendationsTileData } from '@ray-js/t-agent';
4
+ import { TileProps } from '../../types';
5
+ export default function RecommendationsTile(props: TileProps<RecommendationsTileData>): React.JSX.Element;
@@ -0,0 +1,31 @@
1
+ import "core-js/modules/es.array.sort.js";
2
+ import "core-js/modules/esnext.iterator.map.js";
3
+ import { View } from '@ray-js/components';
4
+ import React, { useMemo } from 'react';
5
+ import './index.less';
6
+ import { shuffleWithSeed } from '@ray-js/t-agent';
7
+ export default function RecommendationsTile(props) {
8
+ const {
9
+ id
10
+ } = props.tile;
11
+ const {
12
+ sort,
13
+ size,
14
+ recommendations
15
+ } = props.tile.data;
16
+ const items = useMemo(() => {
17
+ if (sort === 'random') {
18
+ return shuffleWithSeed(recommendations, id).slice(0, size);
19
+ }
20
+ return recommendations.slice(0, size);
21
+ }, [id, sort, size, recommendations]);
22
+ return /*#__PURE__*/React.createElement(View, {
23
+ className: "t-agent-recommendations-tile"
24
+ }, items.map(item => /*#__PURE__*/React.createElement(View, {
25
+ key: "".concat(item.text),
26
+ className: "t-agent-recommendations-tile-item",
27
+ onClick: () => {
28
+ item.clickPayload && props.emitEvent(item.clickPayload);
29
+ }
30
+ }, "\u2192 ", item.text)));
31
+ }
@@ -0,0 +1,13 @@
1
+ .t-agent-recommendations-tile {
2
+ margin-top: 24rpx;
3
+ padding-top: 16rpx;
4
+ font-size: 26rpx;
5
+ border-top: 2rpx solid var(--app-B3-N7);
6
+ }
7
+
8
+ .t-agent-recommendations-tile-item {
9
+ color: var(--app-M4);
10
+ overflow: hidden;
11
+ text-overflow: ellipsis;
12
+ white-space: nowrap;
13
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import { TileProps } from '../../types';
4
+ interface TileData {
5
+ text: string;
6
+ markdown?: boolean;
7
+ }
8
+ declare const _default: React.MemoExoticComponent<(props: TileProps<TileData, any>) => React.JSX.Element>;
9
+ export default _default;
@@ -0,0 +1,27 @@
1
+ import React, { useMemo } from 'react';
2
+ import { View } from '@ray-js/components';
3
+ import './index.less';
4
+ import { getSystemInfoSync } from '@ray-js/ray';
5
+ import MarkdownRender from '../../MarkdownRender';
6
+ import { useRenderOptions } from '../../hooks';
7
+ const TextTile = props => {
8
+ const {
9
+ text,
10
+ markdown
11
+ } = props.tile.data;
12
+ const {
13
+ renderCustomBlockAs,
14
+ customBlockTypes
15
+ } = useRenderOptions();
16
+ const theme = useMemo(() => getSystemInfoSync().theme, []);
17
+ return markdown ? /*#__PURE__*/React.createElement(MarkdownRender, {
18
+ theme: theme,
19
+ text: text,
20
+ prefix: props.tile.id,
21
+ customBlockTypes: customBlockTypes,
22
+ renderBlock: renderCustomBlockAs
23
+ }) : /*#__PURE__*/React.createElement(View, {
24
+ className: "t-agent-text-tile"
25
+ }, text);
26
+ };
27
+ export default /*#__PURE__*/React.memo(TextTile);
@@ -0,0 +1,3 @@
1
+ .t-agent-text-tile {
2
+ display: inline;
3
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { TimeTileData } from '@ray-js/t-agent';
3
+ import './index.less';
4
+ import { TileProps } from '../../types';
5
+ export default function TimeTile(props: TileProps<TimeTileData>): React.JSX.Element;
@@ -0,0 +1,35 @@
1
+ import "core-js/modules/web.dom-collections.iterator.js";
2
+ import { View } from '@ray-js/components';
3
+ import React, { useEffect, useMemo, useState } from 'react';
4
+ import dayjs from 'dayjs';
5
+ import './index.less';
6
+ export default function TimeTile(props) {
7
+ const {
8
+ tile
9
+ } = props;
10
+ const {
11
+ timestamp
12
+ } = tile.data;
13
+ const [date, setDate] = useState(() => {
14
+ return dayjs(timestamp).format('YYYY-MM-DD');
15
+ });
16
+ useEffect(() => {
17
+ // 在当天结束时更新一下
18
+ const timer = setTimeout(() => {
19
+ setDate(dayjs(timestamp).format('YYYY-MM-DD'));
20
+ }, dayjs(timestamp).endOf('day').diff(Date.now()));
21
+ return () => {
22
+ clearTimeout(timer);
23
+ };
24
+ }, []);
25
+ const time = useMemo(() => {
26
+ // 当天的时间只显示时间,其他显示日期和时间
27
+ if (date === dayjs(Date.now()).format('YYYY-MM-DD')) {
28
+ return dayjs(timestamp).format('HH:mm');
29
+ }
30
+ return dayjs(timestamp).format('YYYY-MM-DD HH:mm');
31
+ }, [timestamp, date]);
32
+ return /*#__PURE__*/React.createElement(View, {
33
+ className: "t-agent-time-tile"
34
+ }, time);
35
+ }
@@ -0,0 +1,10 @@
1
+ .t-agent-time-tile {
2
+ font-size: 26rpx;
3
+ color: var(--app-B1-N1);
4
+ line-height: 36rpx;
5
+ text-align: center;
6
+ opacity: 0.5;
7
+ font-weight: 400;
8
+ width: 100%;
9
+ margin-bottom: var(--t-agent-y-gap);
10
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import { TipTileData } from '@ray-js/t-agent';
4
+ import { TileProps } from '../../types';
5
+ declare const _default: React.MemoExoticComponent<(props: TileProps<TipTileData, any>) => React.JSX.Element>;
6
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { View } from '@ray-js/components';
3
+ import './index.less';
4
+ const TipTile = props => {
5
+ const {
6
+ text
7
+ } = props.tile.data;
8
+ return /*#__PURE__*/React.createElement(View, {
9
+ className: "t-agent-tip-tile"
10
+ }, text);
11
+ };
12
+ export default /*#__PURE__*/React.memo(TipTile);
@@ -0,0 +1,9 @@
1
+ .t-agent-tip-tile {
2
+ font-size: 26rpx;
3
+ color: var(--app-B1-N1);
4
+ line-height: 36rpx;
5
+ text-align: center;
6
+ opacity: 0.5;
7
+ font-weight: 400;
8
+ width: 100%;
9
+ }
@@ -0,0 +1,5 @@
1
+ import './index.less';
2
+ import React from 'react';
3
+ import { VideoTileData } from '@ray-js/t-agent';
4
+ import { TileProps } from '../../types';
5
+ export default function VideoTile(props: TileProps<VideoTileData>): React.JSX.Element;
@@ -0,0 +1,49 @@
1
+ import "core-js/modules/web.dom-collections.iterator.js";
2
+ import './index.less';
3
+ import { View, Video } from '@ray-js/components';
4
+ import React from 'react';
5
+ import PrivateImage from '../../PrivateImage';
6
+ import { useRenderOptions } from '../../hooks';
7
+ export default function VideoTile(props) {
8
+ const {
9
+ tile,
10
+ agent
11
+ } = props;
12
+ const {
13
+ src,
14
+ thumbUrl
15
+ } = tile.data;
16
+ const [url, setUrl] = React.useState('');
17
+ const [preview, setPreview] = React.useState(false);
18
+ const {
19
+ getStaticResourceBizType
20
+ } = useRenderOptions();
21
+ const bizType = getStaticResourceBizType(thumbUrl, 'videoThumb:view');
22
+ return /*#__PURE__*/React.createElement(View, {
23
+ className: "t-agent-video-tile"
24
+ }, /*#__PURE__*/React.createElement(PrivateImage, {
25
+ bizType: bizType,
26
+ className: "t-agent-video-tile-video",
27
+ mode: "widthFix",
28
+ src: thumbUrl,
29
+ onClick: async () => {
30
+ // if (!u) {
31
+ // u = await downloadSign(src, getStaticResourceBizType(url, 'video:view'));
32
+ // setUrl(u);
33
+ // }
34
+ setPreview(true);
35
+ }
36
+ }), preview && /*#__PURE__*/React.createElement(View, {
37
+ className: "t-agent-video-tile-video-preview"
38
+ }, /*#__PURE__*/React.createElement(View, {
39
+ className: "t-agent-video-tile-backdrop",
40
+ onClick: () => setPreview(false)
41
+ }), /*#__PURE__*/React.createElement(Video
42
+ // @ts-ignore
43
+ , {
44
+ showCenterPlayBtn: false,
45
+ className: "t-agent-video-tile-video-player",
46
+ autoplay: true,
47
+ src: url
48
+ })));
49
+ }
@@ -0,0 +1,37 @@
1
+ .t-agent-video-tile {
2
+ margin-top: 16rpx;
3
+ width: 300rpx;
4
+ }
5
+
6
+ .t-agent-video-tile-video {
7
+ width: 100%;
8
+ border-radius: 16rpx;
9
+ }
10
+
11
+ .t-agent-video-tile-video-preview {
12
+ z-index: 10;
13
+ position: fixed;
14
+ top: 0;
15
+ left: 0;
16
+ bottom: 0;
17
+ right: 0;
18
+ }
19
+
20
+ .t-agent-video-tile-backdrop {
21
+ position: absolute;
22
+ top: 0;
23
+ left: 0;
24
+ bottom: 0;
25
+ right: 0;
26
+ background: rgba(0, 0, 0, 0.8);
27
+ }
28
+
29
+ .t-agent-video-tile-video-player {
30
+ position: absolute;
31
+ width: 100%;
32
+ height: auto;
33
+ max-height: 90vh;
34
+ top: 50%;
35
+ transform: translateY(-50%);
36
+ background: white;
37
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import { WorkflowOption } from '@ray-js/t-agent-plugin-assistant';
4
+ import { TileProps } from '../../types';
5
+ export default function WorkflowTile(props: TileProps<{
6
+ selected: number | null;
7
+ options: WorkflowOption[];
8
+ }, {
9
+ option: WorkflowOption;
10
+ selected: number;
11
+ }>): React.JSX.Element;
@@ -0,0 +1,30 @@
1
+ import "core-js/modules/esnext.iterator.map.js";
2
+ import { Button, View } from '@ray-js/components';
3
+ import React from 'react';
4
+ import './index.less';
5
+ import cx from 'clsx';
6
+ export default function WorkflowTile(props) {
7
+ const {
8
+ options,
9
+ selected
10
+ } = props.tile.data;
11
+ const isLatest = props.isLatestMessage;
12
+ return /*#__PURE__*/React.createElement(View, {
13
+ className: "t-agent-workflow-tile"
14
+ }, options.map((item, index) => /*#__PURE__*/React.createElement(Button, {
15
+ key: "".concat(item.name),
16
+ className: cx({
17
+ 't-agent-workflow-tile-option': true,
18
+ 't-agent-workflow-tile-option-locked': selected != null && selected !== index || !isLatest,
19
+ 't-agent-workflow-tile-option-selected': selected === index
20
+ }),
21
+ onClick: () => {
22
+ if (isLatest && selected == null) {
23
+ props.emitEvent({
24
+ option: item,
25
+ selected: index
26
+ });
27
+ }
28
+ }
29
+ }, item.name)));
30
+ }
@@ -0,0 +1,31 @@
1
+ .t-agent-workflow-tile {
2
+ margin-top: var(--t-agent-y-gap);
3
+ }
4
+
5
+ .t-agent-workflow-tile > :not([hidden])~:not([hidden]) {
6
+ margin-top: 16rpx;
7
+ margin-bottom: 0;
8
+ }
9
+
10
+ .t-agent-workflow-tile-option {
11
+ display: flex;
12
+ align-items: center;
13
+ padding: 36rpx;
14
+ min-width: 564rpx;
15
+ height: 96rpx;
16
+ margin-top: 24rpx;
17
+ font-size: 32rpx;
18
+ background: var(--app-B1);
19
+ border-radius: var(--app-C1_1);
20
+ font-weight: normal;
21
+ color: var(--app-B3-N1);
22
+ }
23
+
24
+ .t-agent-workflow-tile-option-locked {
25
+ opacity: 0.5;
26
+ }
27
+
28
+ .t-agent-workflow-tile-option-selected {
29
+ background: var(--app-B3-N9);
30
+ color: var(--app-M1);
31
+ }
@@ -0,0 +1,3 @@
1
+ import { ComponentType } from 'react';
2
+ import { TileProps } from '../types';
3
+ export declare const tileMap: Record<string, ComponentType<TileProps>>;
@@ -0,0 +1,24 @@
1
+ import BubbleTile from './BubbleTile';
2
+ import ImageTile from './ImageTile';
3
+ import TextTile from './TextTile';
4
+ import TimeTile from './TimeTile';
5
+ import TipTile from './TipTile';
6
+ import VideoTile from './VideoTile';
7
+ import ButtonGroupTile from './ButtonsTile';
8
+ import RecommendationsTile from './RecommendationsTile';
9
+ import CardTile from './CardTile';
10
+ import WorkflowTile from './WorkflowTile';
11
+ import DocumentsTile from './DocumentsTile';
12
+ export const tileMap = {
13
+ bubble: BubbleTile,
14
+ image: ImageTile,
15
+ video: VideoTile,
16
+ text: TextTile,
17
+ time: TimeTile,
18
+ tip: TipTile,
19
+ buttons: ButtonGroupTile,
20
+ recommendations: RecommendationsTile,
21
+ card: CardTile,
22
+ workflow: WorkflowTile,
23
+ documents: DocumentsTile
24
+ };
@@ -0,0 +1,26 @@
1
+ import type { ChatAgent, ChatCardObject, ChatMessageObject, ChatTileObject } from '@ray-js/t-agent';
2
+ import React from 'react';
3
+ export interface TileProps<T = any, P = any> {
4
+ side: 'start' | 'end';
5
+ message: ChatMessageObject;
6
+ tile: ChatTileObject<T>;
7
+ emitEvent: (payload: P) => void;
8
+ isLatestMessage?: boolean;
9
+ agent: ChatAgent<any>;
10
+ }
11
+ export interface MarkdownBlock {
12
+ id: string;
13
+ type: string;
14
+ children: string;
15
+ map: [number, number];
16
+ }
17
+ export interface RenderOptions {
18
+ renderTileAs: (props: TileProps) => React.ReactNode;
19
+ renderCustomBlockAs: (block: MarkdownBlock) => React.ReactNode;
20
+ renderCardAs: (card: ChatCardObject) => React.ReactNode;
21
+ customBlockTypes: string[];
22
+ customCardMap: Record<string, React.ComponentType<{
23
+ card: ChatCardObject;
24
+ }>>;
25
+ getStaticResourceBizType: (src: string, scene?: string, data?: any) => string;
26
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@ray-js/t-agent-ui-ray",
3
+ "version": "0.0.5-beta-1",
4
+ "author": "Tuya.inc",
5
+ "license": "MIT",
6
+ "private": false,
7
+ "main": "dist/index.js",
8
+ "typings": "dist/index.d.ts",
9
+ "maintainers": [
10
+ "tuya_npm",
11
+ "tuyafe"
12
+ ],
13
+ "files": [
14
+ "dist",
15
+ "README.md",
16
+ "README-zh_CN.md"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "dev": "ray start --type=component --output dist --emit-declaration-dev",
23
+ "build": "ray build --type=component --output dist",
24
+ "clean": "rimraf ./dist"
25
+ },
26
+ "dependencies": {
27
+ "clsx": "^1.2.1",
28
+ "dayjs": "^1.10.4",
29
+ "echarts": "^5.5.0",
30
+ "markdown-it": "^14.1.0",
31
+ "markdown-it-emoji": "^3.0.0",
32
+ "markdown-it-footnote": "^4.0.0"
33
+ },
34
+ "peerDependencies": {
35
+ "@ray-js/ray": ">=1.6.8",
36
+ "@ray-js/t-agent": "*",
37
+ "@ray-js/t-agent-plugin-assistant": "*"
38
+ },
39
+ "devDependencies": {
40
+ "@tuya-miniapp/api-types": "^1.1.22",
41
+ "@types/echarts": "^4.9.22",
42
+ "@types/markdown-it": "^14.1.1"
43
+ },
44
+ "gitHead": "c2f10c94fb4031e1c375864e70a69adb3bbadd2d"
45
+ }