@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
|
@@ -414,7 +414,7 @@ export default function FormDemo() {
|
|
|
414
414
|
// '@blocklet/pages-kit/builtin/iconify/react'
|
|
415
415
|
{
|
|
416
416
|
name: '@blocklet/pages-kit/builtin/iconify/react',
|
|
417
|
-
description: 'A iconify/react component for pages-kit builtin package, all icons
|
|
417
|
+
description: 'A iconify/react component for pages-kit builtin package, all used icons are imported from this package (based on iconify)',
|
|
418
418
|
docs: {
|
|
419
419
|
components: ['Icon'],
|
|
420
420
|
import: 'import { Icon } from "@blocklet/pages-kit/builtin/iconify/react"',
|
|
@@ -425,8 +425,13 @@ export default function FormDemo() {
|
|
|
425
425
|
code: `
|
|
426
426
|
import { Icon } from '@blocklet/pages-kit/builtin/iconify/react';
|
|
427
427
|
|
|
428
|
+
|
|
428
429
|
export default function TablerSuccessIcon() {
|
|
429
|
-
return <Icon icon="tabler:check"
|
|
430
|
+
return <Icon icon="tabler:check" sx={{
|
|
431
|
+
mr: 1,
|
|
432
|
+
fontSize: 24,
|
|
433
|
+
color: 'success.main'
|
|
434
|
+
}}/>
|
|
430
435
|
}
|
|
431
436
|
`,
|
|
432
437
|
},
|
|
@@ -1112,7 +1117,7 @@ export default function LocalCustomComponentRendererDemo({ code }) {
|
|
|
1112
1117
|
];
|
|
1113
1118
|
// set dumpJSON to AI Studio knowledge
|
|
1114
1119
|
const shouldUpdateKnowledge = true;
|
|
1115
|
-
const cookie = 'CookieConsent=true; _ga=GA1.2.1343579140.1705048750; _ga_B1V5Y6VTCW=GS1.2.1705048750.1.1.1705049433.0.0.0; __stripe_mid=b799e3a9-894f-4069-aa7b-731906316d4b34cd93; nf_lang=
|
|
1120
|
+
const cookie = 'CookieConsent=true; _ga=GA1.2.1343579140.1705048750; _ga_B1V5Y6VTCW=GS1.2.1705048750.1.1.1705049433.0.0.0; __stripe_mid=b799e3a9-894f-4069-aa7b-731906316d4b34cd93; nf_lang=en; login_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoidXNlciIsImRpZCI6InoxVENDb21nQ0pOSGJIV2V0VFdHZGhQQjZOWVoyUmVEakx1Iiwicm9sZSI6Im93bmVyIiwicHJvdmlkZXIiOiJ3YWxsZXQiLCJ3YWxsZXRPUyI6IndlYiIsInBhc3Nwb3J0Ijp7ImlkIjoiejJpVHkyWkRUdENIamJLNEh6ZXQ5U25aR2pjRnRYODFHTjk4ViJ9LCJmdWxsTmFtZSI6Illvbmd6aHVvIExpYW5nIiwiaWF0IjoxNzE2NjkyMTQyLCJleHAiOjE3MTY2OTU3NDJ9.DuUCAOo7j-5w7eMQgd4FWWpPwD9OTebSAHavbSkuRx4';
|
|
1116
1121
|
const aiStudioUrl = 'https://bbqa2t5pfyfroyobmzknmktshckzto4btkfagxyjqwy.did.abtnet.io/ai-studio';
|
|
1117
1122
|
const datasetId = '443696818363039744';
|
|
1118
1123
|
if (cookie && shouldUpdateKnowledge && aiStudioUrl && datasetId) {
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import { CircularProgress, Stack } from '@mui/material';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
5
4
|
import { Result } from '../../../arcblock/ux';
|
|
6
5
|
import { LocaleProvider, useLocaleContext } from '../../../locale';
|
|
7
6
|
import { translations } from '../locales';
|
|
8
|
-
import GlobalLoading from './GlobalLoading';
|
|
9
|
-
import ThemeProvider from './ThemeProvider';
|
|
10
7
|
export default function RuntimeCommonProvider({ children }) {
|
|
11
|
-
return (_jsx(RuntimeLocaleProvider, { children: _jsx(
|
|
8
|
+
return (_jsx(RuntimeLocaleProvider, { children: _jsx(ErrorBoundary, { FallbackComponent: ErrorRender, children: _jsx(React.Suspense, { children: children }) }) }));
|
|
12
9
|
}
|
|
13
10
|
function ErrorRender({ error }) {
|
|
14
11
|
return (_jsx(Result, { status: error.status || 'error', description: error.message, sx: { bgcolor: 'transparent', mt: '20%' } }));
|
|
@@ -11,35 +11,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { ArrowDropDownRounded } from '@mui/icons-material';
|
|
14
|
-
import { GlobalStyles, ThemeProvider as MuiThemeProvider, alpha, createTheme, inputBaseClasses, useTheme, } from '@mui/material';
|
|
15
|
-
import { useMemo } from 'react';
|
|
16
|
-
|
|
14
|
+
import { CircularProgress, GlobalStyles, ThemeProvider as MuiThemeProvider, Stack, alpha, createTheme, inputBaseClasses, useTheme, } from '@mui/material';
|
|
15
|
+
import { Suspense, useMemo } from 'react';
|
|
16
|
+
import { useRuntimeState } from '../state/runtime';
|
|
17
|
+
import GlobalLoading from './GlobalLoading';
|
|
18
|
+
export default function ThemeProvider({ children }) {
|
|
19
|
+
const { primaryColor } = useRuntimeState().agent.project;
|
|
17
20
|
const theme = useTheme();
|
|
18
|
-
const colors = {
|
|
19
|
-
default: {
|
|
20
|
-
color: undefined,
|
|
21
|
-
bg: '#ffffff',
|
|
22
|
-
// primary: '#333843',
|
|
23
|
-
primary: '#3B82F6',
|
|
24
|
-
},
|
|
25
|
-
blue: {
|
|
26
|
-
color: 'white',
|
|
27
|
-
bg: 'linear-gradient(180deg, #0D60FF 0%, #E2EDFE 100%)',
|
|
28
|
-
primary: '#0D60FF',
|
|
29
|
-
},
|
|
30
|
-
red: {
|
|
31
|
-
color: 'white',
|
|
32
|
-
bg: 'linear-gradient(180deg, #F65F84 0%, #817DE6 100%), linear-gradient(180deg, #9300FF 0%, #D900FF 100%)',
|
|
33
|
-
primary: '#F65F84',
|
|
34
|
-
},
|
|
35
|
-
green: {
|
|
36
|
-
color: 'white',
|
|
37
|
-
bg: 'linear-gradient(180deg, #149E8C 0%, #35E77D 100%)',
|
|
38
|
-
primary: '#149E8C',
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
const color = colors[template] || colors.default;
|
|
42
21
|
const newTheme = useMemo(() => {
|
|
22
|
+
let { primary } = theme.palette;
|
|
23
|
+
try {
|
|
24
|
+
if (primaryColor) {
|
|
25
|
+
primary = theme.palette.augmentColor({ color: { main: primaryColor } });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error('augment primary color error', { error });
|
|
30
|
+
}
|
|
43
31
|
const themeOptions = {
|
|
44
32
|
components: {
|
|
45
33
|
MuiSelect: {
|
|
@@ -52,15 +40,22 @@ export default function ThemeProvider({ children, template, transparentHeaderBg,
|
|
|
52
40
|
style: ({ theme }) => theme.unstable_sx({
|
|
53
41
|
'.MuiInputBase-root': {
|
|
54
42
|
fieldset: { borderColor: 'rgba(229, 231, 235, 1)' },
|
|
55
|
-
[
|
|
43
|
+
[`&.Mui-focused, :not(.${inputBaseClasses.disabled}):hover`]: {
|
|
56
44
|
fieldset: {
|
|
57
45
|
border: 'none',
|
|
58
46
|
boxShadow: `0px 0px 0px 4px ${alpha(theme.palette.primary.main, 0.2)}, 0px 0px 0px 1px ${theme.palette.primary.main}`,
|
|
59
47
|
},
|
|
60
48
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
},
|
|
50
|
+
'.MuiInputLabel-root': {
|
|
51
|
+
[`&.Mui-focused, :not(.${inputBaseClasses.disabled}):hover, &.MuiFormLabel-filled`]: {
|
|
52
|
+
backgroundColor: `${theme.palette.primary.main}`,
|
|
53
|
+
color: 'white',
|
|
54
|
+
px: 1,
|
|
55
|
+
ml: -0.8,
|
|
56
|
+
py: 0.2,
|
|
57
|
+
mt: -0.1,
|
|
58
|
+
borderRadius: 4,
|
|
64
59
|
},
|
|
65
60
|
},
|
|
66
61
|
}),
|
|
@@ -100,9 +95,7 @@ export default function ThemeProvider({ children, template, transparentHeaderBg,
|
|
|
100
95
|
};
|
|
101
96
|
const paletteTheme = createTheme({
|
|
102
97
|
palette: {
|
|
103
|
-
primary
|
|
104
|
-
main: color.primary,
|
|
105
|
-
},
|
|
98
|
+
primary,
|
|
106
99
|
secondary: {
|
|
107
100
|
main: '#010714',
|
|
108
101
|
},
|
|
@@ -125,7 +118,7 @@ export default function ThemeProvider({ children, template, transparentHeaderBg,
|
|
|
125
118
|
// @ts-ignore
|
|
126
119
|
black: paletteTheme.palette.black,
|
|
127
120
|
background: {
|
|
128
|
-
default:
|
|
121
|
+
default: '#ffffff',
|
|
129
122
|
},
|
|
130
123
|
},
|
|
131
124
|
shape: {
|
|
@@ -140,30 +133,8 @@ export default function ThemeProvider({ children, template, transparentHeaderBg,
|
|
|
140
133
|
});
|
|
141
134
|
}, [theme]);
|
|
142
135
|
return (_jsxs(MuiThemeProvider, { theme: newTheme, children: [_jsx(GlobalStyles, { styles: {
|
|
143
|
-
'.page-header':
|
|
144
|
-
|
|
145
|
-
backgroundColor: 'transparent !important',
|
|
146
|
-
color: color.color,
|
|
147
|
-
button: {
|
|
148
|
-
color: color.color,
|
|
149
|
-
},
|
|
150
|
-
}
|
|
151
|
-
: {
|
|
152
|
-
// with border bottom
|
|
153
|
-
borderBottom: '1px solid rgba(229, 231, 235, 1)',
|
|
154
|
-
},
|
|
155
|
-
body: {
|
|
156
|
-
background: 'transparent !important',
|
|
157
|
-
'&:before': {
|
|
158
|
-
content: '""',
|
|
159
|
-
position: 'fixed',
|
|
160
|
-
left: 0,
|
|
161
|
-
top: 0,
|
|
162
|
-
right: 0,
|
|
163
|
-
bottom: 0,
|
|
164
|
-
background: color.bg,
|
|
165
|
-
zIndex: -1,
|
|
166
|
-
},
|
|
136
|
+
'.page-header': {
|
|
137
|
+
borderBottom: '1px solid rgba(229, 231, 235, 1)',
|
|
167
138
|
},
|
|
168
139
|
'.white-tooltip .MuiTooltip-tooltip': {
|
|
169
140
|
background: 'white !important',
|
|
@@ -171,5 +142,5 @@ export default function ThemeProvider({ children, template, transparentHeaderBg,
|
|
|
171
142
|
border: '1px solid rgba(229, 231, 235, 1)',
|
|
172
143
|
padding: 4,
|
|
173
144
|
},
|
|
174
|
-
} }), children] }));
|
|
145
|
+
} }), _jsx(GlobalLoading, { sx: { position: 'fixed', left: 0, top: 0, width: '100%', zIndex: 'snackbar' } }), _jsx(Suspense, { fallback: _jsx(Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: _jsx(CircularProgress, { size: 24 }) }), children: children })] }));
|
|
175
146
|
}
|
|
@@ -104,6 +104,8 @@ export const translations = {
|
|
|
104
104
|
cannotSetPropertiesTip: 'Failed to parse PROPERTIES_SCHEMA, this code cannot be set properties',
|
|
105
105
|
codePreview: 'Code Preview',
|
|
106
106
|
codePreviewTip: 'Here is the code preview, you can view the generated code, and editing is not supported yet.',
|
|
107
|
+
hideSlider: 'Hide Versions',
|
|
108
|
+
showSlider: 'Show Versions',
|
|
107
109
|
},
|
|
108
110
|
},
|
|
109
111
|
zh: {
|
|
@@ -211,6 +213,8 @@ export const translations = {
|
|
|
211
213
|
cannotSetPropertiesTip: '解析 PROPERTIES_SCHEMA 失败,此代码无法进行属性设置',
|
|
212
214
|
codePreview: '代码预览',
|
|
213
215
|
codePreviewTip: '以下是代码预览,您可以查看生成的代码,目前还不支持编辑。',
|
|
216
|
+
hideSlider: '隐藏版本历史',
|
|
217
|
+
showSlider: '显示版本历史',
|
|
214
218
|
},
|
|
215
219
|
},
|
|
216
220
|
};
|
|
@@ -19,6 +19,7 @@ import PopperMenuButton from '../../components/PopperMenuButton';
|
|
|
19
19
|
import LoadingMenuItem from '../../components/PopperMenuButton/LoadingMenuItem';
|
|
20
20
|
import RuntimeCommonProvider from '../../components/RuntimeCommonProvider';
|
|
21
21
|
import ScrollView from '../../components/ScrollView';
|
|
22
|
+
import ThemeProvider from '../../components/ThemeProvider';
|
|
22
23
|
import { DEFAULT_PAGE_COMPONENT_ID } from '../../constants';
|
|
23
24
|
import ActiveAgentProvider from '../../contexts/ActiveAgent';
|
|
24
25
|
import RuntimeProvider from '../../contexts/Runtime';
|
|
@@ -26,7 +27,7 @@ import useAppearances, { useProfile } from '../../hooks/use-appearances';
|
|
|
26
27
|
import { useRuntimeState } from '../../state/runtime';
|
|
27
28
|
import { useAutoLoadSessionState, useSessionState } from '../../state/session';
|
|
28
29
|
export default function ChatBotButton({ aid, working }) {
|
|
29
|
-
return (_jsx(RuntimeCommonProvider, { children: _jsx(RuntimeProvider, { aid: aid, working: working, children: _jsx(ActiveAgentProvider, { children: _jsx(ChatBotContent, {}) }) }) }));
|
|
30
|
+
return (_jsx(RuntimeCommonProvider, { children: _jsx(RuntimeProvider, { aid: aid, working: working, children: _jsx(ThemeProvider, { children: _jsx(ActiveAgentProvider, { children: _jsx(ChatBotContent, {}) }) }) }) }));
|
|
30
31
|
}
|
|
31
32
|
function ChatBotContent() {
|
|
32
33
|
var _a, _b;
|
|
@@ -9,6 +9,7 @@ import { useHeader } from '../../../../page/header';
|
|
|
9
9
|
import { getComponentMountPoint } from '../../../../utils';
|
|
10
10
|
import RuntimeCommonProvider, { RuntimeLocaleProvider } from '../../components/RuntimeCommonProvider';
|
|
11
11
|
import SocialShare from '../../components/SocialShare';
|
|
12
|
+
import ThemeProvider from '../../components/ThemeProvider';
|
|
12
13
|
import { AI_STUDIO_DID, DEFAULT_PAGE_COMPONENT_ID } from '../../constants';
|
|
13
14
|
import ActiveAgentProvider from '../../contexts/ActiveAgent';
|
|
14
15
|
import RuntimeProvider, { RuntimeProviderFromUrl } from '../../contexts/Runtime';
|
|
@@ -20,7 +21,7 @@ function AgentCreatedBy({ did }) {
|
|
|
20
21
|
return (_jsxs(_Fragment, { children: [t('by'), " ", _jsx(Box, { component: DID, did: did, copyable: false, responsive: true })] }));
|
|
21
22
|
}
|
|
22
23
|
export default function Runtime({ aid, working }) {
|
|
23
|
-
const children = (_jsx(ActiveAgentProvider, { children: _jsx(RuntimeView, {}) }));
|
|
24
|
+
const children = (_jsx(ThemeProvider, { children: _jsx(ActiveAgentProvider, { children: _jsx(RuntimeView, {}) }) }));
|
|
24
25
|
return (_jsx(RuntimeCommonProvider, { children: aid ? (_jsx(RuntimeProvider, { aid: aid, working: working, children: children })) : (_jsx(RuntimeProviderFromUrl, { children: children })) }));
|
|
25
26
|
}
|
|
26
27
|
function RuntimeView() {
|
|
@@ -11,8 +11,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { Masonry } from '@mui/lab';
|
|
14
|
-
import { Box, Skeleton, Stack,
|
|
15
|
-
import { Suspense, memo,
|
|
14
|
+
import { Box, Skeleton, Stack, Typography } from '@mui/material';
|
|
15
|
+
import { Suspense, memo, useRef } from 'react';
|
|
16
16
|
import Balancer from 'react-wrap-balancer';
|
|
17
17
|
import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
|
|
18
18
|
import { useLocaleContext } from '../../../../locale';
|
|
@@ -24,28 +24,10 @@ import CurrentMessageProvider from '../../contexts/CurrentMessage';
|
|
|
24
24
|
import useAppearances from '../../hooks/use-appearances';
|
|
25
25
|
import { useAutoLoadSessionState, useCurrentSessionState, useSessionState } from '../../state/session';
|
|
26
26
|
import mapRight from '../../utils/map-right';
|
|
27
|
-
export default function PhotoGallery({ resultTitle
|
|
27
|
+
export default function PhotoGallery({ resultTitle }) {
|
|
28
28
|
const { activeAgentId } = useActiveAgent();
|
|
29
29
|
useAutoLoadSessionState();
|
|
30
|
-
|
|
31
|
-
const theme = useMemo(() => {
|
|
32
|
-
let { primary } = inheritedTheme.palette;
|
|
33
|
-
try {
|
|
34
|
-
if (primaryColor) {
|
|
35
|
-
primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
console.error('augment primary color error', { error });
|
|
40
|
-
}
|
|
41
|
-
return createTheme(inheritedTheme, {
|
|
42
|
-
palette: { primary },
|
|
43
|
-
shape: {
|
|
44
|
-
borderRadius: 8,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
}, [inheritedTheme, primaryColor]);
|
|
48
|
-
return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Stack, { className: "aigne-layout aigne-photo-wall-layout", children: [_jsx(SimpleHeader, { TitleProps: { fontSize: 48 }, DescriptionProps: { fontSize: 20 }, maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }), _jsx(CurrentAgentProvider, { agentId: activeAgentId, children: _jsx(AgentInputRender, { className: "aigne-inputs aigne-photo-wall-inputs", maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }) }), _jsx(OutputView, { resultTitle: resultTitle, className: "aigne-outputs aigne-photo-wall-outputs", gap: 2 })] }) }));
|
|
30
|
+
return (_jsxs(Stack, { className: "aigne-layout aigne-photo-wall-layout", children: [_jsx(SimpleHeader, { TitleProps: { fontSize: 48 }, DescriptionProps: { fontSize: 20 }, maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }), _jsx(CurrentAgentProvider, { agentId: activeAgentId, children: _jsx(AgentInputRender, { className: "aigne-inputs aigne-photo-wall-inputs", maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }) }), _jsx(OutputView, { resultTitle: resultTitle, className: "aigne-outputs aigne-photo-wall-outputs", gap: 2 })] }));
|
|
49
31
|
}
|
|
50
32
|
function AgentInputRender(_a) {
|
|
51
33
|
var props = __rest(_a, []);
|
|
@@ -10,8 +10,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
-
import { Box, CircularProgress,
|
|
14
|
-
import { useEffect
|
|
13
|
+
import { Box, CircularProgress, alpha } from '@mui/material';
|
|
14
|
+
import { useEffect } from 'react';
|
|
15
15
|
import { useScrollToBottom } from 'react-scroll-to-bottom';
|
|
16
16
|
import SimpleHeader from '../../components/Header/SimpleHeader';
|
|
17
17
|
import SimpleLayout from '../../components/Layout/SimpleLayout';
|
|
@@ -25,27 +25,9 @@ import BackgroundImage from './BackgroundImage';
|
|
|
25
25
|
import InputsView from './InputsView';
|
|
26
26
|
import MessagesView from './MessagesView';
|
|
27
27
|
export default function SimpleChat(_a) {
|
|
28
|
-
var {
|
|
28
|
+
var { scrollViewProps = { scroll: 'window', initialScrollBehavior: 'auto' } } = _a, preferences = __rest(_a, ["scrollViewProps"]);
|
|
29
29
|
useAutoLoadSessionState();
|
|
30
|
-
|
|
31
|
-
const theme = useMemo(() => {
|
|
32
|
-
let { primary } = inheritedTheme.palette;
|
|
33
|
-
try {
|
|
34
|
-
if (primaryColor) {
|
|
35
|
-
primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
console.error('augment primary color error', { error });
|
|
40
|
-
}
|
|
41
|
-
return createTheme(inheritedTheme, {
|
|
42
|
-
palette: { primary },
|
|
43
|
-
shape: {
|
|
44
|
-
borderRadius: 8,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
}, [inheritedTheme, primaryColor]);
|
|
48
|
-
return (_jsx(ComponentPreferencesProvider, Object.assign({}, preferences, { children: _jsx(ScrollView, Object.assign({}, scrollViewProps, { children: _jsxs(ThemeProvider, { theme: theme, children: [_jsx(BackgroundImage, {}), _jsx(SimpleChatView, {})] }) })) })));
|
|
30
|
+
return (_jsx(ComponentPreferencesProvider, Object.assign({}, preferences, { children: _jsxs(ScrollView, Object.assign({}, scrollViewProps, { children: [_jsx(BackgroundImage, {}), _jsx(SimpleChatView, {})] })) })));
|
|
49
31
|
}
|
|
50
32
|
function SimpleChatView() {
|
|
51
33
|
const { activeAgentId } = useActiveAgent();
|
|
@@ -10,8 +10,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
-
import { Stack,
|
|
14
|
-
import { Suspense, memo
|
|
13
|
+
import { Stack, Typography } from '@mui/material';
|
|
14
|
+
import { Suspense, memo } from 'react';
|
|
15
15
|
import Balancer from 'react-wrap-balancer';
|
|
16
16
|
import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
|
|
17
17
|
import SimpleHeader from '../../components/Header/SimpleHeader';
|
|
@@ -21,28 +21,10 @@ import CurrentAgentProvider from '../../contexts/CurrentAgent';
|
|
|
21
21
|
import CurrentMessageProvider from '../../contexts/CurrentMessage';
|
|
22
22
|
import useAppearances from '../../hooks/use-appearances';
|
|
23
23
|
import { useAutoLoadSessionState, useCurrentSessionState } from '../../state/session';
|
|
24
|
-
export default function SimplePage({ resultTitle
|
|
24
|
+
export default function SimplePage({ resultTitle }) {
|
|
25
25
|
const { activeAgentId } = useActiveAgent();
|
|
26
26
|
useAutoLoadSessionState();
|
|
27
|
-
|
|
28
|
-
const theme = useMemo(() => {
|
|
29
|
-
let { primary } = inheritedTheme.palette;
|
|
30
|
-
try {
|
|
31
|
-
if (primaryColor) {
|
|
32
|
-
primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
console.error('augment primary color error', { error });
|
|
37
|
-
}
|
|
38
|
-
return createTheme(inheritedTheme, {
|
|
39
|
-
palette: { primary },
|
|
40
|
-
shape: {
|
|
41
|
-
borderRadius: 8,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
}, [inheritedTheme, primaryColor]);
|
|
45
|
-
return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(SimpleLayout, { pb: 4, children: [_jsx(SimpleHeader, {}), _jsx(CurrentAgentProvider, { agentId: activeAgentId, children: _jsx(AgentInputRender, { className: "aigne-inputs aigne-simple-page-inputs" }) }), _jsx(OutputView, { className: "aigne-outputs aigne-simple-page-outputs", resultTitle: resultTitle })] }) }));
|
|
27
|
+
return (_jsxs(SimpleLayout, { pb: 4, children: [_jsx(SimpleHeader, {}), _jsx(CurrentAgentProvider, { agentId: activeAgentId, children: _jsx(AgentInputRender, { className: "aigne-inputs aigne-simple-page-inputs" }) }), _jsx(OutputView, { className: "aigne-outputs aigne-simple-page-outputs", resultTitle: resultTitle })] }));
|
|
46
28
|
}
|
|
47
29
|
function AgentInputRender(_a) {
|
|
48
30
|
var props = __rest(_a, []);
|
|
@@ -28,6 +28,7 @@ export default function V0Input({ submitText, inlineLabel, autoFillLastForm = fa
|
|
|
28
28
|
var _a, _b;
|
|
29
29
|
const { t } = useLocaleContext();
|
|
30
30
|
const { aid, agent } = useCurrentAgent();
|
|
31
|
+
const [executeLoading, setExecuteLoading] = useState(false);
|
|
31
32
|
const opening = useOpeningQuestions();
|
|
32
33
|
const { execute } = useRuntimeState();
|
|
33
34
|
const { running } = useCurrentSessionState((s) => s) || {};
|
|
@@ -49,28 +50,38 @@ export default function V0Input({ submitText, inlineLabel, autoFillLastForm = fa
|
|
|
49
50
|
}
|
|
50
51
|
}, [defaultForm, autoFillLastForm, form, chatMode]);
|
|
51
52
|
const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
try {
|
|
54
|
+
if (!(parameters === null || parameters === void 0 ? void 0 : parameters.question))
|
|
55
|
+
return;
|
|
56
|
+
setExecuteLoading(true);
|
|
57
|
+
if (!currentSessionId) {
|
|
58
|
+
yield createSession({
|
|
59
|
+
name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// in session page, send message
|
|
63
|
+
yield execute({
|
|
64
|
+
aid,
|
|
65
|
+
parameters,
|
|
66
|
+
onResponseStart: () => {
|
|
67
|
+
setCurrentMessageTaskId(undefined);
|
|
68
|
+
if (chatMode)
|
|
69
|
+
form.resetField('question', { defaultValue: '' });
|
|
70
|
+
},
|
|
57
71
|
});
|
|
58
72
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (chatMode)
|
|
66
|
-
form.resetField('question', { defaultValue: '' });
|
|
67
|
-
},
|
|
68
|
-
});
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error(error);
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
setExecuteLoading(false);
|
|
78
|
+
}
|
|
69
79
|
});
|
|
70
80
|
return (_jsxs(ThemeProvider, { theme: theme, children: [!currentSessionId && ((_a = opening === null || opening === void 0 ? void 0 : opening.questions) === null || _a === void 0 ? void 0 : _a.length) && (_jsx(Stack, { sx: {
|
|
71
81
|
flexDirection: 'row',
|
|
72
82
|
gap: 1,
|
|
73
83
|
mb: 1,
|
|
84
|
+
flexWrap: 'wrap',
|
|
74
85
|
}, children: (_b = opening === null || opening === void 0 ? void 0 : opening.questions) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
75
86
|
const { title, parameters, id } = item;
|
|
76
87
|
const question = (parameters === null || parameters === void 0 ? void 0 : parameters.questions) || title;
|
|
@@ -78,7 +89,8 @@ export default function V0Input({ submitText, inlineLabel, autoFillLastForm = fa
|
|
|
78
89
|
marginLeft: -4,
|
|
79
90
|
} }), onClick: () => {
|
|
80
91
|
form.reset(Object.assign({}, parameters));
|
|
81
|
-
|
|
92
|
+
// auto execute message
|
|
93
|
+
// onSubmit({ ...parameters });
|
|
82
94
|
}, children: question }, id));
|
|
83
95
|
}) })), _jsxs(Form, { id: "v0-input", component: "form", className: cx('form', `label-position-${inlineLabel ? 'start' : 'top'}`), onSubmit: form.handleSubmit(onSubmit), children: [parameters === null || parameters === void 0 ? void 0 : parameters.map((parameter, index) => {
|
|
84
96
|
const { key, required } = parameter !== null && parameter !== void 0 ? parameter : {};
|
|
@@ -104,7 +116,7 @@ export default function V0Input({ submitText, inlineLabel, autoFillLastForm = fa
|
|
|
104
116
|
}
|
|
105
117
|
: undefined })] }));
|
|
106
118
|
} }) }, parameter.id));
|
|
107
|
-
}), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && (_jsx(LoadingButton, { type: "submit", variant: "contained", loading: running, sx: { height: 40 }, children: submitText || t('generate') }))] })] }));
|
|
119
|
+
}), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && (_jsx(LoadingButton, { type: "submit", variant: "contained", loading: executeLoading || running, sx: { height: 40 }, children: submitText || t('generate') }))] })] }));
|
|
108
120
|
}
|
|
109
121
|
const autoSetLastParameters = false;
|
|
110
122
|
function useInitialFormValues() {
|
|
@@ -32,7 +32,7 @@ export default function V0Output() {
|
|
|
32
32
|
var _a, _b;
|
|
33
33
|
const { message } = useCurrentMessage();
|
|
34
34
|
const propertiesSettingRef = useRef(null);
|
|
35
|
-
const { propertiesValueMap, setPropertiesValueMap } = useV0RuntimeContext();
|
|
35
|
+
const { propertiesValueMap, setPropertiesValueMap, isMobile } = useV0RuntimeContext();
|
|
36
36
|
const [code, setCode] = useState('');
|
|
37
37
|
const { t, locale } = useLocaleContext();
|
|
38
38
|
const [codePreviewExtraSx, setCodePreviewExtraSx] = useState(DEFAULT_DESKTOP_SX);
|
|
@@ -45,7 +45,7 @@ export default function V0Output() {
|
|
|
45
45
|
borderColor: 'rgba(0, 0, 0, 0.1) !important',
|
|
46
46
|
};
|
|
47
47
|
const tooltipOptions = [
|
|
48
|
-
{
|
|
48
|
+
!isMobile && {
|
|
49
49
|
key: 'Desktop',
|
|
50
50
|
icon: 'tabler:device-desktop',
|
|
51
51
|
props: {
|
|
@@ -54,7 +54,7 @@ export default function V0Output() {
|
|
|
54
54
|
},
|
|
55
55
|
group: 'responsive',
|
|
56
56
|
},
|
|
57
|
-
{
|
|
57
|
+
!isMobile && {
|
|
58
58
|
key: 'Tablet',
|
|
59
59
|
icon: 'tabler:device-tablet',
|
|
60
60
|
props: {
|
|
@@ -66,7 +66,7 @@ export default function V0Output() {
|
|
|
66
66
|
},
|
|
67
67
|
group: 'responsive',
|
|
68
68
|
},
|
|
69
|
-
{
|
|
69
|
+
!isMobile && {
|
|
70
70
|
key: 'Mobile',
|
|
71
71
|
icon: 'tabler:device-mobile',
|
|
72
72
|
props: {
|
|
@@ -91,14 +91,14 @@ export default function V0Output() {
|
|
|
91
91
|
const currentCode = getCurrentCodeByTaskId(message, taskId);
|
|
92
92
|
try {
|
|
93
93
|
yield transpileAndLoadScript(currentCode).then((m) => {
|
|
94
|
-
var _a, _b;
|
|
94
|
+
var _a, _b, _c;
|
|
95
95
|
if (typeof (m === null || m === void 0 ? void 0 : m.PROPERTIES_SCHEMA) === 'object' && (m === null || m === void 0 ? void 0 : m.PROPERTIES_SCHEMA.length)) {
|
|
96
96
|
const schemaDefaultValues = Object.fromEntries(m.PROPERTIES_SCHEMA.map((item) => {
|
|
97
97
|
const { key, locales } = item;
|
|
98
98
|
const currentLocale = (locales === null || locales === void 0 ? void 0 : locales[locale]) || (locales === null || locales === void 0 ? void 0 : locales.en);
|
|
99
99
|
return [key, currentLocale === null || currentLocale === void 0 ? void 0 : currentLocale.defaultValue];
|
|
100
100
|
}));
|
|
101
|
-
const defaultValues = Object.assign(Object.assign({}, schemaDefaultValues), (_a = propertiesValueMap[taskId]) === null || _a === void 0 ? void 0 : _a[locale]);
|
|
101
|
+
const defaultValues = Object.assign(Object.assign({}, schemaDefaultValues), (((_a = propertiesValueMap[taskId]) === null || _a === void 0 ? void 0 : _a[locale]) || ((_b = propertiesValueMap[taskId]) === null || _b === void 0 ? void 0 : _b.en) || {}));
|
|
102
102
|
// format default values
|
|
103
103
|
m.PROPERTIES_SCHEMA.forEach((item) => {
|
|
104
104
|
const { key, type } = item;
|
|
@@ -112,7 +112,7 @@ export default function V0Output() {
|
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
// @ts-ignore
|
|
115
|
-
(
|
|
115
|
+
(_c = propertiesSettingRef.current) === null || _c === void 0 ? void 0 : _c.open({
|
|
116
116
|
schema: m.PROPERTIES_SCHEMA,
|
|
117
117
|
onSubmit: (values) => {
|
|
118
118
|
const realValues = {};
|
|
@@ -150,7 +150,7 @@ export default function V0Output() {
|
|
|
150
150
|
{
|
|
151
151
|
key: 'CodePreview',
|
|
152
152
|
icon: code ? 'tabler:layout-board' : 'tabler:code',
|
|
153
|
-
buttonText: code ? 'Canvas' : 'Code',
|
|
153
|
+
buttonText: !isMobile && (code ? 'Canvas' : 'Code'),
|
|
154
154
|
props: {
|
|
155
155
|
disabled,
|
|
156
156
|
variant: 'contained',
|
|
@@ -163,7 +163,8 @@ export default function V0Output() {
|
|
|
163
163
|
},
|
|
164
164
|
group: 'codePreview',
|
|
165
165
|
},
|
|
166
|
-
];
|
|
166
|
+
].filter(Boolean);
|
|
167
|
+
const onCloseCode = () => setCode('');
|
|
167
168
|
return (_jsxs(Stack, { sx: {
|
|
168
169
|
p: 2,
|
|
169
170
|
gap: 2,
|
|
@@ -179,10 +180,15 @@ export default function V0Output() {
|
|
|
179
180
|
width: '100%',
|
|
180
181
|
gap: 1.5,
|
|
181
182
|
flexDirection: 'row',
|
|
183
|
+
'.question': {
|
|
184
|
+
backgroundColor: 'white',
|
|
185
|
+
border: 1,
|
|
186
|
+
borderColor: 'rgba(0, 0, 0, 0.1) !important',
|
|
187
|
+
},
|
|
182
188
|
}, children: [_jsx(UserQuestion, { question: parameters === null || parameters === void 0 ? void 0 : parameters.question }), _jsx(Box, { sx: {
|
|
183
189
|
display: 'flex',
|
|
184
190
|
alignItems: 'center',
|
|
185
|
-
gap: 1
|
|
191
|
+
gap: 1,
|
|
186
192
|
}, children: Object.entries(groupBy(tooltipOptions, 'group')).map(([group, options]) => {
|
|
187
193
|
return (_jsx(ButtonGroup, { variant: "text", color: "inherit", size: "small", sx: {
|
|
188
194
|
borderColor: 'rgba(0, 0, 0, 0.1) !important',
|
|
@@ -196,11 +202,24 @@ export default function V0Output() {
|
|
|
196
202
|
overflowY: 'auto',
|
|
197
203
|
scrollbarWidth: 'thin',
|
|
198
204
|
scrollbarColor: 'grey transparent',
|
|
199
|
-
}, propertiesValueMap: propertiesValueMap }) }), objects === null || objects === void 0 ? void 0 : objects.map((item, index) => _jsx(MessageMetadataRenderer, { object: item.data }, index)), !isMessageLoading && ((_b = message.result) === null || _b === void 0 ? void 0 : _b.content) && (_jsx(ShareActions, { direction: "row", justifyContent: "flex-end", sx: { mt: 2 } })), _jsxs(Suspense, { fallback: _jsx(Loading, {}), children: [_jsx(Drawer, { anchor:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
}, propertiesValueMap: propertiesValueMap }) }), objects === null || objects === void 0 ? void 0 : objects.map((item, index) => _jsx(MessageMetadataRenderer, { object: item.data }, index)), !isMessageLoading && ((_b = message.result) === null || _b === void 0 ? void 0 : _b.content) && (_jsx(ShareActions, { direction: "row", justifyContent: "flex-end", sx: { mt: 2 } })), _jsxs(Suspense, { fallback: _jsx(Loading, {}), children: [_jsx(Drawer, { anchor: isMobile ? 'bottom' : 'right', open: !!code, onClose: onCloseCode, children: _jsxs(Box, { sx: Object.assign({ p: 2, pt: 0 }, (isMobile ? { maxHeight: '70vh' } : { maxWidth: '70vw' })), children: [_jsxs(Box, { sx: {
|
|
206
|
+
py: 2,
|
|
207
|
+
position: 'sticky',
|
|
208
|
+
top: 0,
|
|
209
|
+
left: 0,
|
|
210
|
+
backgroundColor: 'white',
|
|
211
|
+
zIndex: 9999,
|
|
212
|
+
display: 'flex',
|
|
213
|
+
justifyContent: 'space-between',
|
|
214
|
+
alignItems: 'center',
|
|
215
|
+
}, children: [_jsx(Typography, { variant: "h6", sx: {
|
|
216
|
+
lineHeight: 1,
|
|
217
|
+
}, children: t('v0.codePreview') }), _jsx(Button, { onClick: onCloseCode,
|
|
218
|
+
// variant="text"
|
|
219
|
+
color: "inherit", disableElevation: true, sx: {
|
|
220
|
+
minWidth: 32,
|
|
221
|
+
minHeight: 32,
|
|
222
|
+
p: 0,
|
|
223
|
+
fontSize: 22,
|
|
224
|
+
}, children: _jsx(Icon, { icon: "tabler:x" }) })] }), _jsx(Alert, { severity: "info", sx: { mb: 2 }, children: t('v0.codePreviewTip') }), _jsx(MarkdownRenderer, { children: `\`\`\`typescript\n${code}\n\`\`\`` })] }) }), _jsx(PropertiesSetting, { ref: propertiesSettingRef })] })] }));
|
|
206
225
|
}
|