@blocklet/pages-kit 0.2.320 → 0.2.322
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.
- package/lib/cjs/builtin/async/ai-runtime/components/RuntimeCommonProvider.js +1 -4
- package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +32 -58
- package/lib/cjs/builtin/async/ai-runtime/locales/index.js +4 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +2 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +2 -20
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +2 -20
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +2 -20
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Input.js +29 -17
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +36 -17
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +84 -77
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/Loading.js +7 -5
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +4 -4
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.js +4 -1
- package/lib/cjs/builtin/iconify/react.js +8 -2
- package/lib/cjs/components/CustomComponentRenderer/state.js +14 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/inject-global-components-dump-json.js +8 -3
- package/lib/esm/builtin/async/ai-runtime/components/RuntimeCommonProvider.js +2 -5
- package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +31 -60
- package/lib/esm/builtin/async/ai-runtime/locales/index.js +4 -0
- package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +2 -1
- package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +4 -22
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +4 -22
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +4 -22
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +29 -17
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +36 -17
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +84 -78
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/Loading.js +7 -5
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +4 -4
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.js +4 -1
- package/lib/esm/builtin/iconify/react.js +7 -1
- package/lib/esm/components/CustomComponentRenderer/state.js +11 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/inject-global-components-dump-json.js +8 -3
- package/lib/types/builtin/async/ai-runtime/api/agent.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +1 -3
- package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.d.ts +1 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +1 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimplePage/index.d.ts +1 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Page.d.ts +1 -5
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.d.ts +1 -0
- package/lib/types/builtin/iconify/react.d.ts +2 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ import RelativeTime from '@arcblock/ux/lib/RelativeTime';
|
|
|
25
25
|
import { Icon } from '@iconify/react';
|
|
26
26
|
import { Masonry } from '@mui/lab';
|
|
27
27
|
import { Box, Button, Chip, Container, IconButton, Stack, ThemeProvider, Tooltip, Typography, createTheme, useTheme, } from '@mui/material';
|
|
28
|
-
import { Suspense, useEffect, useMemo, useRef } from 'react';
|
|
28
|
+
import { Suspense, useEffect, useMemo, useRef, useState } from 'react';
|
|
29
29
|
import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
|
|
30
30
|
import { useLocaleContext } from '../../../../locale';
|
|
31
31
|
import { useActiveAgent } from '../../contexts/ActiveAgent';
|
|
@@ -40,7 +40,7 @@ import UserQuestion from './components/UserQuestion';
|
|
|
40
40
|
import { V0RuntimeProvider, useV0RuntimeContext } from './contexts/V0Runtime';
|
|
41
41
|
import { getLineClamp } from './utils';
|
|
42
42
|
const sliderWidth = 200;
|
|
43
|
-
function V0Page({ textColor = '#333', primaryColor }) {
|
|
43
|
+
function V0Page({ textColor = '#333', primaryColor = '#333' }) {
|
|
44
44
|
const inheritedTheme = useTheme();
|
|
45
45
|
const theme = useMemo(() => {
|
|
46
46
|
let { primary } = inheritedTheme.palette;
|
|
@@ -53,7 +53,7 @@ function V0Page({ textColor = '#333', primaryColor }) {
|
|
|
53
53
|
console.error('augment primary color error', { error });
|
|
54
54
|
}
|
|
55
55
|
return createTheme(inheritedTheme, {
|
|
56
|
-
palette: { primary, textColor, background: { block: '#
|
|
56
|
+
palette: { primary, textColor, background: { block: '#f6f6f6' } },
|
|
57
57
|
shape: {
|
|
58
58
|
borderRadius: 8,
|
|
59
59
|
},
|
|
@@ -64,30 +64,35 @@ function V0Page({ textColor = '#333', primaryColor }) {
|
|
|
64
64
|
});
|
|
65
65
|
const { currentSessionId } = useSessionState((s) => s) || {};
|
|
66
66
|
const { activeAgentId } = useActiveAgent();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
67
|
+
const { isMobile } = useV0RuntimeContext();
|
|
68
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(CurrentAgentProvider, { agentId: activeAgentId, children: _jsx(Box, { flex: 1, children: _jsxs(Container, { sx: {
|
|
69
|
+
height: 'calc(100vh - 64px - 1px)',
|
|
70
|
+
textAlign: 'center',
|
|
71
|
+
pt: 3,
|
|
72
|
+
gap: 2,
|
|
73
|
+
display: 'flex',
|
|
74
|
+
flexDirection: 'column',
|
|
75
|
+
position: 'relative',
|
|
76
|
+
'.code-preview-wrapper': {},
|
|
77
|
+
}, children: [_jsx(Box, { sx: {
|
|
78
|
+
flex: 1,
|
|
79
|
+
height: !isMobile && currentSessionId ? 'calc(100% - 48px - 16px - 16px)' : 'unset',
|
|
80
|
+
}, children: currentSessionId ? _jsx(V0DetailRender, {}) : _jsx(V0ListRender, {}) }), _jsx(Box, { sx: {
|
|
81
|
+
position: 'sticky',
|
|
82
|
+
bottom: 0,
|
|
83
|
+
backgroundColor: 'white',
|
|
84
|
+
py: 2,
|
|
85
|
+
pt: currentSessionId ? 0 : 2,
|
|
86
|
+
zIndex: 1100,
|
|
87
|
+
}, children: _jsx(AgentInputRender, {}) })] }) }) }) }));
|
|
88
|
+
}
|
|
89
|
+
export default function Page() {
|
|
90
|
+
return (_jsx(V0RuntimeProvider, { children: _jsx(V0Page, {}) }));
|
|
86
91
|
}
|
|
87
|
-
export default V0Page;
|
|
88
92
|
function V0ListRender() {
|
|
89
93
|
const ConfirmDialogRef = useRef();
|
|
90
94
|
const { sessions: sessionsList, setCurrentSessionId, loadLatestMessagesForAllSessions, sessionMap, deleteSession, loading, } = useSessionState((s) => s) || {};
|
|
95
|
+
const { isMobile } = useV0RuntimeContext();
|
|
91
96
|
const { t } = useLocaleContext();
|
|
92
97
|
useEffect(() => {
|
|
93
98
|
const loadData = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -97,13 +102,16 @@ function V0ListRender() {
|
|
|
97
102
|
});
|
|
98
103
|
loadData();
|
|
99
104
|
}, [sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length]);
|
|
100
|
-
return (_jsxs(Box, { flex: 1, children: [_jsx(Typography, { variant: "h2", color: "textColor", sx: { fontWeight: 'bold', mt: 6 }, children: t('v0.title') }), _jsx(Typography, { variant: "h5", color: "textColor", sx: Object.assign(Object.assign({}, getLineClamp(5)), { mt: 2 }), children: t('v0.description') }), loading ? (_jsx(Loading, { sx: {
|
|
105
|
+
return (_jsxs(Box, { flex: 1, children: [_jsx(Typography, { variant: "h2", color: "textColor", sx: { fontWeight: 'bold', mt: isMobile ? 3 : 6 }, children: t('v0.title') }), _jsx(Typography, { variant: "h5", color: "textColor", sx: Object.assign(Object.assign({}, getLineClamp(5)), { mt: 2 }), children: t('v0.description') }), loading ? (_jsx(Loading, { sx: {
|
|
101
106
|
position: 'relative',
|
|
102
107
|
height: '40vh',
|
|
103
108
|
width: '100%',
|
|
104
109
|
} })) : (_jsxs(Box, { sx: {
|
|
105
|
-
mt: 8,
|
|
106
|
-
|
|
110
|
+
mt: isMobile ? 4 : 8,
|
|
111
|
+
display: 'flex',
|
|
112
|
+
alignContent: 'center',
|
|
113
|
+
justifyContent: 'center',
|
|
114
|
+
}, children: [(sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length) ? (_jsx(Masonry, { columns: { xs: 1, sm: 2, md: 4, lg: 4 }, sequential: true, spacing: 2, children: sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.map((item) => {
|
|
107
115
|
var _a, _b;
|
|
108
116
|
const { name, id } = item;
|
|
109
117
|
const latestMessage = (_b = (_a = sessionMap === null || sessionMap === void 0 ? void 0 : sessionMap[id]) === null || _a === void 0 ? void 0 : _a.messages) === null || _b === void 0 ? void 0 : _b.at(-1);
|
|
@@ -123,8 +131,9 @@ function V0ListRender() {
|
|
|
123
131
|
cursor: 'pointer',
|
|
124
132
|
transition: 'all 0.3s',
|
|
125
133
|
overflow: 'hidden',
|
|
126
|
-
minHeight: sliderWidth,
|
|
127
|
-
maxHeight: '50vh',
|
|
134
|
+
// minHeight: sliderWidth,
|
|
135
|
+
// maxHeight: '50vh',
|
|
136
|
+
height: 300,
|
|
128
137
|
'&:hover': {
|
|
129
138
|
borderColor: 'primary.main',
|
|
130
139
|
},
|
|
@@ -163,7 +172,8 @@ function V0ListRender() {
|
|
|
163
172
|
function V0DetailRender() {
|
|
164
173
|
const { setCurrentSessionId } = useSessionState((s) => s) || {};
|
|
165
174
|
const { messages: messagesList, loading } = useCurrentSessionState((s) => s) || {};
|
|
166
|
-
const { currentMessageTaskId, setCurrentMessageTaskId, propertiesValueMap } = useV0RuntimeContext();
|
|
175
|
+
const { currentMessageTaskId, setCurrentMessageTaskId, propertiesValueMap, isMobile } = useV0RuntimeContext();
|
|
176
|
+
const [sliderOpenInMobile, setSliderOpenInMobile] = useState(!isMobile);
|
|
167
177
|
const { t } = useLocaleContext();
|
|
168
178
|
const currentMessage = messagesList === null || messagesList === void 0 ? void 0 : messagesList.find((item) => item.taskId === currentMessageTaskId);
|
|
169
179
|
useEffect(() => {
|
|
@@ -176,48 +186,48 @@ function V0DetailRender() {
|
|
|
176
186
|
}
|
|
177
187
|
}
|
|
178
188
|
}, [messagesList, currentMessageTaskId]);
|
|
189
|
+
const sliderOpen = isMobile ? sliderOpenInMobile : true;
|
|
190
|
+
const sliderWrapperSx = {
|
|
191
|
+
height: isMobile ? 'unset' : '100%',
|
|
192
|
+
backgroundColor: 'background.block',
|
|
193
|
+
borderRadius: 1,
|
|
194
|
+
p: 2,
|
|
195
|
+
position: 'relative',
|
|
196
|
+
};
|
|
179
197
|
return (_jsxs(Box, { flex: 1, sx: {
|
|
180
198
|
display: 'flex',
|
|
181
199
|
gap: 2,
|
|
182
200
|
height: '100%',
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
right: 0,
|
|
206
|
-
bottom: 0,
|
|
207
|
-
margin: 'auto',
|
|
208
|
-
background: 'rgba(255, 255, 255, 0.8)',
|
|
209
|
-
opacity: 0.8,
|
|
210
|
-
borderRadius: 1,
|
|
211
|
-
boxShadow: '0 0 10px rgba(0, 0, 0, 0.1)',
|
|
212
|
-
} })), _jsx(Stack, { spacing: 2, sx: {
|
|
201
|
+
flexDirection: isMobile ? 'column' : 'row',
|
|
202
|
+
}, children: [_jsxs(Box, { sx: Object.assign({ width: isMobile ? '100%' : sliderWidth, gap: 2, display: 'flex', flexDirection: 'column' }, (isMobile ? {} : Object.assign({}, sliderWrapperSx))), children: [_jsxs(Box, { sx: {
|
|
203
|
+
display: 'flex',
|
|
204
|
+
justifyContent: 'space-between',
|
|
205
|
+
alignItems: 'center',
|
|
206
|
+
gap: 2,
|
|
207
|
+
}, children: [_jsx(Button, { variant: "outlined", size: "small", startIcon: _jsx(Icon, { icon: "tabler:chevron-left" }), onClick: () => {
|
|
208
|
+
setCurrentMessageTaskId(undefined);
|
|
209
|
+
setCurrentSessionId('');
|
|
210
|
+
}, sx: {
|
|
211
|
+
backgroundColor: 'white',
|
|
212
|
+
width: isMobile ? 'auto' : '100%',
|
|
213
|
+
}, children: t('back') }), isMobile ? (_jsx(Button, { startIcon: _jsx(Icon, { icon: sliderOpenInMobile ? 'tabler:chevron-up' : 'tabler:chevron-down' }), size: "small", onClick: () => setSliderOpenInMobile(!sliderOpenInMobile), children: sliderOpenInMobile ? t('v0.hideSlider') : t('v0.showSlider') })) : null, loading && (_jsx(Loading, { sx: Object.assign({ position: 'absolute', zIndex: 99999, top: 0, left: 0, right: 0, bottom: 0, margin: 'auto', background: 'rgba(255, 255, 255, 0.8)', opacity: 0.8, borderRadius: 1, boxShadow: '0 0 10px rgba(0, 0, 0, 0.1)' }, (isMobile
|
|
214
|
+
? {
|
|
215
|
+
width: '40px',
|
|
216
|
+
height: '40px',
|
|
217
|
+
}
|
|
218
|
+
: {
|
|
219
|
+
width: '80px',
|
|
220
|
+
height: '80px',
|
|
221
|
+
})) }))] }), sliderOpen && (_jsx(Stack, { spacing: 2, direction: isMobile ? 'row' : 'column', sx: Object.assign(Object.assign({}, (isMobile
|
|
222
|
+
? Object.assign({ overflowY: 'hidden', overflowX: 'auto' }, sliderWrapperSx) : {
|
|
213
223
|
overflowY: 'auto',
|
|
214
224
|
overflowX: 'hidden',
|
|
225
|
+
})), {
|
|
215
226
|
// scrollbarWidth: 'thin',
|
|
216
227
|
// scrollbarColor: 'grey transparent',
|
|
217
228
|
'&::-webkit-scrollbar': {
|
|
218
229
|
display: 'none',
|
|
219
|
-
},
|
|
220
|
-
}, children: messagesList === null || messagesList === void 0 ? void 0 : messagesList.map((item, i) => {
|
|
230
|
+
} }), children: messagesList === null || messagesList === void 0 ? void 0 : messagesList.map((item, i) => {
|
|
221
231
|
const { parameters, taskId, updatedAt } = item;
|
|
222
232
|
const isCurrent = taskId === (currentMessageTaskId || undefined);
|
|
223
233
|
return (_jsx(Box, { sx: {
|
|
@@ -228,21 +238,17 @@ function V0DetailRender() {
|
|
|
228
238
|
}, children: _jsxs(Box, { onClick: () => {
|
|
229
239
|
// @ts-ignore
|
|
230
240
|
setCurrentMessageTaskId(item.taskId);
|
|
231
|
-
}, sx: {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
},
|
|
243
|
-
minHeight: sliderWidth / 2,
|
|
244
|
-
maxHeight: '50vh',
|
|
245
|
-
}, children: [_jsx(CodeRenderByMessage, { zoom: 0.25, message: item, sx: {
|
|
241
|
+
}, sx: Object.assign({ cursor: 'pointer', color: 'textColor', borderRadius: 1, border: 1, borderColor: isCurrent ? 'primary.main' : 'background.block', backgroundColor: 'white', position: 'relative', transition: 'all 0.3s', '&:hover': {
|
|
242
|
+
borderColor: 'primary.main',
|
|
243
|
+
} }, (isMobile
|
|
244
|
+
? {
|
|
245
|
+
width: sliderWidth / 2,
|
|
246
|
+
height: sliderWidth / 2,
|
|
247
|
+
}
|
|
248
|
+
: {
|
|
249
|
+
minHeight: sliderWidth / 2,
|
|
250
|
+
maxHeight: '50vh',
|
|
251
|
+
})), children: [_jsx(CodeRenderByMessage, { zoom: 0.25, message: item, sx: {
|
|
246
252
|
pointerEvents: 'none',
|
|
247
253
|
}, propertiesValueMap: propertiesValueMap }), _jsx(Tooltip, { placement: "right", arrow: true, PopperProps: {
|
|
248
254
|
// disablePortal: true,
|
|
@@ -271,11 +277,11 @@ function V0DetailRender() {
|
|
|
271
277
|
color: isCurrent ? 'primary.main' : 'textColor',
|
|
272
278
|
borderRadius: 1,
|
|
273
279
|
} }) }, taskId)] }, taskId) }, taskId));
|
|
274
|
-
}) })] }, "slider"), _jsx(Box, { sx: {
|
|
280
|
+
}) }))] }, "slider"), _jsx(Box, { sx: {
|
|
275
281
|
borderRadius: 1,
|
|
276
282
|
backgroundColor: 'background.block',
|
|
277
283
|
flex: 1,
|
|
278
|
-
maxWidth: `calc(100% - ${sliderWidth}px - 16px)`,
|
|
284
|
+
maxWidth: isMobile ? '100%' : `calc(100% - ${sliderWidth}px - 16px)`,
|
|
279
285
|
}, children: _jsx(AgentOutputRender, { message: currentMessage }) })] }));
|
|
280
286
|
}
|
|
281
287
|
function AgentInputRender(_a) {
|
|
@@ -72,11 +72,11 @@ export function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, proper
|
|
|
72
72
|
} }) }));
|
|
73
73
|
}
|
|
74
74
|
return (_d = (_c = message === null || message === void 0 ? void 0 : message.result) === null || _c === void 0 ? void 0 : _c.objects) === null || _d === void 0 ? void 0 : _d.map((item) => {
|
|
75
|
-
var _a, _b;
|
|
75
|
+
var _a, _b, _c;
|
|
76
76
|
const { taskId } = item;
|
|
77
77
|
// @ts-ignore
|
|
78
78
|
const code = (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a[codeField];
|
|
79
|
-
return (_jsx(CodePreviewMemo, { componentId: `code-preview-${taskId}`, code: code, propertiesValue: (_b = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _b === void 0 ? void 0 : _b[locale] }, item.taskId));
|
|
79
|
+
return (_jsx(CodePreviewMemo, { componentId: `code-preview-${taskId}`, code: code, propertiesValue: ((_b = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _b === void 0 ? void 0 : _b[locale]) || ((_c = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _c === void 0 ? void 0 : _c.en) || {} }, item.taskId));
|
|
80
80
|
});
|
|
81
81
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
82
82
|
}, [isMessageLoading, (_a = message === null || message === void 0 ? void 0 : message.result) === null || _a === void 0 ? void 0 : _a.objects, propertiesValueMap, locale]);
|
|
@@ -74,29 +74,31 @@ export function AIRunningLoading(props) {
|
|
|
74
74
|
backgroundColor: 'grey.200',
|
|
75
75
|
} }),
|
|
76
76
|
_jsx(Skeleton, { variant: "rectangular", sx: {
|
|
77
|
-
width:
|
|
77
|
+
width: 90,
|
|
78
78
|
height: 50,
|
|
79
79
|
borderRadius: 1,
|
|
80
80
|
backgroundColor: 'grey.200',
|
|
81
81
|
} }),
|
|
82
82
|
_jsx(Skeleton, { variant: "rectangular", sx: {
|
|
83
|
-
width:
|
|
83
|
+
width: 120,
|
|
84
84
|
height: 50,
|
|
85
85
|
borderRadius: 1,
|
|
86
86
|
backgroundColor: 'grey.200',
|
|
87
87
|
} }),
|
|
88
88
|
],
|
|
89
89
|
sx: {
|
|
90
|
-
|
|
90
|
+
px: 2,
|
|
91
|
+
py: 1,
|
|
91
92
|
display: 'flex',
|
|
92
93
|
gap: 1.5,
|
|
93
94
|
justifyContent: 'space-between',
|
|
95
|
+
overflow: 'hidden',
|
|
94
96
|
},
|
|
95
97
|
},
|
|
96
98
|
},
|
|
97
99
|
{
|
|
98
100
|
time: 60,
|
|
99
|
-
width:
|
|
101
|
+
width: 290,
|
|
100
102
|
height: 150,
|
|
101
103
|
extraProps: {
|
|
102
104
|
sx: {
|
|
@@ -105,7 +107,7 @@ export function AIRunningLoading(props) {
|
|
|
105
107
|
},
|
|
106
108
|
},
|
|
107
109
|
];
|
|
108
|
-
return (_jsx(Box, Object.assign({ sx: Object.assign({ flex: 1, display: 'inline-flex', justifyContent: 'center', alignItems: 'center', backgroundColor: 'white', flexDirection: 'column', gap: 1.5, '@keyframes loading': {
|
|
110
|
+
return (_jsx(Box, Object.assign({ sx: Object.assign({ flex: 1, display: 'inline-flex', justifyContent: 'center', alignItems: 'center', backgroundColor: 'white', flexDirection: 'column', gap: 1.5, width: '100%', overflow: 'hidden', '@keyframes loading': {
|
|
109
111
|
'0%': {
|
|
110
112
|
transform: 'translateY(-8px) scaleX(1.3)',
|
|
111
113
|
opacity: 0,
|
|
@@ -14,13 +14,13 @@ export default function UserQuestion({ question }) {
|
|
|
14
14
|
display: 'flex',
|
|
15
15
|
alignItems: 'center',
|
|
16
16
|
gap: 1,
|
|
17
|
-
}, children: [((_a = authSession === null || authSession === void 0 ? void 0 : authSession.user) === null || _a === void 0 ? void 0 : _a.did) && (_jsx(Box, { sx: {
|
|
17
|
+
}, children: [((_a = authSession === null || authSession === void 0 ? void 0 : authSession.user) === null || _a === void 0 ? void 0 : _a.did) && (_jsx(Box, { className: "user", sx: {
|
|
18
18
|
width: 30,
|
|
19
19
|
height: 30,
|
|
20
|
-
}, children: _jsx(Avatar, { size: 30, did: user === null || user === void 0 ? void 0 : user.did, variant: "circle", shape: "circle", src: user === null || user === void 0 ? void 0 : user.avatar }) })), _jsx(Box, { sx: {
|
|
21
|
-
padding: '6px
|
|
20
|
+
}, children: _jsx(Avatar, { size: 30, did: user === null || user === void 0 ? void 0 : user.did, variant: "circle", shape: "circle", src: user === null || user === void 0 ? void 0 : user.avatar }) })), _jsx(Box, { className: "question", sx: {
|
|
21
|
+
padding: '6px 12px',
|
|
22
22
|
borderRadius: 1,
|
|
23
23
|
// borderTopLeftRadius: 0,
|
|
24
24
|
backgroundColor: 'grey.200',
|
|
25
|
-
}, children: _jsx(ClickToCopy, { locale: locale, unstyled: true, children: _jsx(Typography, { sx: Object.assign({ fontWeight: 500, fontSize: 13, maxWidth: 300, color: 'textColor' }, getLineClamp(1)), children: question }) }) })] }));
|
|
25
|
+
}, children: _jsx(ClickToCopy, { locale: locale, unstyled: true, children: _jsx(Typography, { sx: Object.assign({ fontWeight: 500, fontSize: 13, maxWidth: 300, color: 'textColor', textAlign: 'left' }, getLineClamp(1)), children: question }) }) })] }));
|
|
26
26
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMediaQuery } from '@mui/material';
|
|
2
3
|
import { createContext, useContext, useMemo, useState } from 'react';
|
|
3
4
|
const context = createContext(undefined);
|
|
4
5
|
let cancelAutoScrollTimer;
|
|
5
6
|
export function V0RuntimeProvider({ children }) {
|
|
6
7
|
const [currentMessageTaskId, setCurrentMessageTaskId] = useState();
|
|
7
8
|
const [propertiesValueMap, setPropertiesValueMap] = useState({});
|
|
9
|
+
const isMobile = useMediaQuery((theme) => theme.breakpoints.down('sm'));
|
|
8
10
|
const state = useMemo(() => ({
|
|
9
11
|
setCurrentMessageTaskId: (taskId) => {
|
|
10
12
|
setCurrentMessageTaskId(taskId);
|
|
@@ -37,7 +39,8 @@ export function V0RuntimeProvider({ children }) {
|
|
|
37
39
|
setPropertiesValueMap: (valueMap) => {
|
|
38
40
|
setPropertiesValueMap(Object.assign(Object.assign({}, propertiesValueMap), valueMap));
|
|
39
41
|
},
|
|
40
|
-
|
|
42
|
+
isMobile,
|
|
43
|
+
}), [setCurrentMessageTaskId, currentMessageTaskId, propertiesValueMap, setPropertiesValueMap, isMobile]);
|
|
41
44
|
return _jsx(context.Provider, { value: state, children: children });
|
|
42
45
|
}
|
|
43
46
|
export function useV0RuntimeContext() {
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon as IconifyIcon } from '@iconify/react';
|
|
3
|
+
import { Box } from '@mui/material';
|
|
4
|
+
export function Icon(props) {
|
|
5
|
+
return _jsx(Box, Object.assign({ component: IconifyIcon }, props));
|
|
6
|
+
}
|
|
7
|
+
export default Icon;
|
|
@@ -18,6 +18,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
18
18
|
}
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
|
+
import set from 'lodash/set';
|
|
21
22
|
import { useDeferredValue, useEffect, useRef, useState } from 'react';
|
|
22
23
|
import { create } from 'zustand';
|
|
23
24
|
import { immer } from 'zustand/middleware/immer';
|
|
@@ -175,6 +176,16 @@ function useTranspileComponent({ componentId, locale, properties, dev: { default
|
|
|
175
176
|
if (typeof (m === null || m === void 0 ? void 0 : m.PROPERTIES_SCHEMA) === 'object' && (m === null || m === void 0 ? void 0 : m.PROPERTIES_SCHEMA.length)) {
|
|
176
177
|
propertiesFromCode = {};
|
|
177
178
|
m.PROPERTIES_SCHEMA.forEach((data, index) => {
|
|
179
|
+
var _a, _b, _c;
|
|
180
|
+
// @ts-ignore
|
|
181
|
+
(_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.blocklet) === null || _a === void 0 ? void 0 : _a.languages) === null || _b === void 0 ? void 0 : _b.forEach) === null || _c === void 0 ? void 0 : _c.call(_b, (item) => {
|
|
182
|
+
var _a, _b;
|
|
183
|
+
const { code: localKey } = item;
|
|
184
|
+
if (!((_a = data === null || data === void 0 ? void 0 : data.locales) === null || _a === void 0 ? void 0 : _a[localKey])) {
|
|
185
|
+
// fallback to en
|
|
186
|
+
set(data, `locales.${localKey}`, (_b = data.locales) === null || _b === void 0 ? void 0 : _b.en);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
178
189
|
propertiesFromCode[data.id] = {
|
|
179
190
|
index,
|
|
180
191
|
data,
|