@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
|
@@ -5,16 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RuntimeLocaleProvider = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const material_1 = require("@mui/material");
|
|
9
8
|
const react_1 = __importDefault(require("react"));
|
|
10
9
|
const react_error_boundary_1 = require("react-error-boundary");
|
|
11
10
|
const ux_1 = require("../../../arcblock/ux");
|
|
12
11
|
const locale_1 = require("../../../locale");
|
|
13
12
|
const locales_1 = require("../locales");
|
|
14
|
-
const GlobalLoading_1 = __importDefault(require("./GlobalLoading"));
|
|
15
|
-
const ThemeProvider_1 = __importDefault(require("./ThemeProvider"));
|
|
16
13
|
function RuntimeCommonProvider({ children }) {
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)(RuntimeLocaleProvider, { children: (0, jsx_runtime_1.jsx)(
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(RuntimeLocaleProvider, { children: (0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ErrorRender, children: (0, jsx_runtime_1.jsx)(react_1.default.Suspense, { children: children }) }) }));
|
|
18
15
|
}
|
|
19
16
|
exports.default = RuntimeCommonProvider;
|
|
20
17
|
function ErrorRender({ error }) {
|
|
@@ -10,38 +10,29 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
}
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
13
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
17
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
18
|
const icons_material_1 = require("@mui/icons-material");
|
|
16
19
|
const material_1 = require("@mui/material");
|
|
17
20
|
const react_1 = require("react");
|
|
18
|
-
|
|
21
|
+
const runtime_1 = require("../state/runtime");
|
|
22
|
+
const GlobalLoading_1 = __importDefault(require("./GlobalLoading"));
|
|
23
|
+
function ThemeProvider({ children }) {
|
|
24
|
+
const { primaryColor } = (0, runtime_1.useRuntimeState)().agent.project;
|
|
19
25
|
const theme = (0, material_1.useTheme)();
|
|
20
|
-
const colors = {
|
|
21
|
-
default: {
|
|
22
|
-
color: undefined,
|
|
23
|
-
bg: '#ffffff',
|
|
24
|
-
// primary: '#333843',
|
|
25
|
-
primary: '#3B82F6',
|
|
26
|
-
},
|
|
27
|
-
blue: {
|
|
28
|
-
color: 'white',
|
|
29
|
-
bg: 'linear-gradient(180deg, #0D60FF 0%, #E2EDFE 100%)',
|
|
30
|
-
primary: '#0D60FF',
|
|
31
|
-
},
|
|
32
|
-
red: {
|
|
33
|
-
color: 'white',
|
|
34
|
-
bg: 'linear-gradient(180deg, #F65F84 0%, #817DE6 100%), linear-gradient(180deg, #9300FF 0%, #D900FF 100%)',
|
|
35
|
-
primary: '#F65F84',
|
|
36
|
-
},
|
|
37
|
-
green: {
|
|
38
|
-
color: 'white',
|
|
39
|
-
bg: 'linear-gradient(180deg, #149E8C 0%, #35E77D 100%)',
|
|
40
|
-
primary: '#149E8C',
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
const color = colors[template] || colors.default;
|
|
44
26
|
const newTheme = (0, react_1.useMemo)(() => {
|
|
27
|
+
let { primary } = theme.palette;
|
|
28
|
+
try {
|
|
29
|
+
if (primaryColor) {
|
|
30
|
+
primary = theme.palette.augmentColor({ color: { main: primaryColor } });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error('augment primary color error', { error });
|
|
35
|
+
}
|
|
45
36
|
const themeOptions = {
|
|
46
37
|
components: {
|
|
47
38
|
MuiSelect: {
|
|
@@ -54,15 +45,22 @@ function ThemeProvider({ children, template, transparentHeaderBg, }) {
|
|
|
54
45
|
style: ({ theme }) => theme.unstable_sx({
|
|
55
46
|
'.MuiInputBase-root': {
|
|
56
47
|
fieldset: { borderColor: 'rgba(229, 231, 235, 1)' },
|
|
57
|
-
[
|
|
48
|
+
[`&.Mui-focused, :not(.${material_1.inputBaseClasses.disabled}):hover`]: {
|
|
58
49
|
fieldset: {
|
|
59
50
|
border: 'none',
|
|
60
51
|
boxShadow: `0px 0px 0px 4px ${(0, material_1.alpha)(theme.palette.primary.main, 0.2)}, 0px 0px 0px 1px ${theme.palette.primary.main}`,
|
|
61
52
|
},
|
|
62
53
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
},
|
|
55
|
+
'.MuiInputLabel-root': {
|
|
56
|
+
[`&.Mui-focused, :not(.${material_1.inputBaseClasses.disabled}):hover, &.MuiFormLabel-filled`]: {
|
|
57
|
+
backgroundColor: `${theme.palette.primary.main}`,
|
|
58
|
+
color: 'white',
|
|
59
|
+
px: 1,
|
|
60
|
+
ml: -0.8,
|
|
61
|
+
py: 0.2,
|
|
62
|
+
mt: -0.1,
|
|
63
|
+
borderRadius: 4,
|
|
66
64
|
},
|
|
67
65
|
},
|
|
68
66
|
}),
|
|
@@ -102,9 +100,7 @@ function ThemeProvider({ children, template, transparentHeaderBg, }) {
|
|
|
102
100
|
};
|
|
103
101
|
const paletteTheme = (0, material_1.createTheme)({
|
|
104
102
|
palette: {
|
|
105
|
-
primary
|
|
106
|
-
main: color.primary,
|
|
107
|
-
},
|
|
103
|
+
primary,
|
|
108
104
|
secondary: {
|
|
109
105
|
main: '#010714',
|
|
110
106
|
},
|
|
@@ -127,7 +123,7 @@ function ThemeProvider({ children, template, transparentHeaderBg, }) {
|
|
|
127
123
|
// @ts-ignore
|
|
128
124
|
black: paletteTheme.palette.black,
|
|
129
125
|
background: {
|
|
130
|
-
default:
|
|
126
|
+
default: '#ffffff',
|
|
131
127
|
},
|
|
132
128
|
},
|
|
133
129
|
shape: {
|
|
@@ -142,30 +138,8 @@ function ThemeProvider({ children, template, transparentHeaderBg, }) {
|
|
|
142
138
|
});
|
|
143
139
|
}, [theme]);
|
|
144
140
|
return ((0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: newTheme, children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: {
|
|
145
|
-
'.page-header':
|
|
146
|
-
|
|
147
|
-
backgroundColor: 'transparent !important',
|
|
148
|
-
color: color.color,
|
|
149
|
-
button: {
|
|
150
|
-
color: color.color,
|
|
151
|
-
},
|
|
152
|
-
}
|
|
153
|
-
: {
|
|
154
|
-
// with border bottom
|
|
155
|
-
borderBottom: '1px solid rgba(229, 231, 235, 1)',
|
|
156
|
-
},
|
|
157
|
-
body: {
|
|
158
|
-
background: 'transparent !important',
|
|
159
|
-
'&:before': {
|
|
160
|
-
content: '""',
|
|
161
|
-
position: 'fixed',
|
|
162
|
-
left: 0,
|
|
163
|
-
top: 0,
|
|
164
|
-
right: 0,
|
|
165
|
-
bottom: 0,
|
|
166
|
-
background: color.bg,
|
|
167
|
-
zIndex: -1,
|
|
168
|
-
},
|
|
141
|
+
'.page-header': {
|
|
142
|
+
borderBottom: '1px solid rgba(229, 231, 235, 1)',
|
|
169
143
|
},
|
|
170
144
|
'.white-tooltip .MuiTooltip-tooltip': {
|
|
171
145
|
background: 'white !important',
|
|
@@ -173,6 +147,6 @@ function ThemeProvider({ children, template, transparentHeaderBg, }) {
|
|
|
173
147
|
border: '1px solid rgba(229, 231, 235, 1)',
|
|
174
148
|
padding: 4,
|
|
175
149
|
},
|
|
176
|
-
} }), children] }));
|
|
150
|
+
} }), (0, jsx_runtime_1.jsx)(GlobalLoading_1.default, { sx: { position: 'fixed', left: 0, top: 0, width: '100%', zIndex: 'snackbar' } }), (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(material_1.Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) }), children: children })] }));
|
|
177
151
|
}
|
|
178
152
|
exports.default = ThemeProvider;
|
|
@@ -107,6 +107,8 @@ exports.translations = {
|
|
|
107
107
|
cannotSetPropertiesTip: 'Failed to parse PROPERTIES_SCHEMA, this code cannot be set properties',
|
|
108
108
|
codePreview: 'Code Preview',
|
|
109
109
|
codePreviewTip: 'Here is the code preview, you can view the generated code, and editing is not supported yet.',
|
|
110
|
+
hideSlider: 'Hide Versions',
|
|
111
|
+
showSlider: 'Show Versions',
|
|
110
112
|
},
|
|
111
113
|
},
|
|
112
114
|
zh: {
|
|
@@ -214,6 +216,8 @@ exports.translations = {
|
|
|
214
216
|
cannotSetPropertiesTip: '解析 PROPERTIES_SCHEMA 失败,此代码无法进行属性设置',
|
|
215
217
|
codePreview: '代码预览',
|
|
216
218
|
codePreviewTip: '以下是代码预览,您可以查看生成的代码,目前还不支持编辑。',
|
|
219
|
+
hideSlider: '隐藏版本历史',
|
|
220
|
+
showSlider: '显示版本历史',
|
|
217
221
|
},
|
|
218
222
|
},
|
|
219
223
|
};
|
|
@@ -47,6 +47,7 @@ const PopperMenuButton_1 = __importDefault(require("../../components/PopperMenuB
|
|
|
47
47
|
const LoadingMenuItem_1 = __importDefault(require("../../components/PopperMenuButton/LoadingMenuItem"));
|
|
48
48
|
const RuntimeCommonProvider_1 = __importDefault(require("../../components/RuntimeCommonProvider"));
|
|
49
49
|
const ScrollView_1 = __importDefault(require("../../components/ScrollView"));
|
|
50
|
+
const ThemeProvider_1 = __importDefault(require("../../components/ThemeProvider"));
|
|
50
51
|
const constants_1 = require("../../constants");
|
|
51
52
|
const ActiveAgent_1 = __importDefault(require("../../contexts/ActiveAgent"));
|
|
52
53
|
const Runtime_1 = __importDefault(require("../../contexts/Runtime"));
|
|
@@ -54,7 +55,7 @@ const use_appearances_1 = __importStar(require("../../hooks/use-appearances"));
|
|
|
54
55
|
const runtime_1 = require("../../state/runtime");
|
|
55
56
|
const session_1 = require("../../state/session");
|
|
56
57
|
function ChatBotButton({ aid, working }) {
|
|
57
|
-
return ((0, jsx_runtime_1.jsx)(RuntimeCommonProvider_1.default, { children: (0, jsx_runtime_1.jsx)(Runtime_1.default, { aid: aid, working: working, children: (0, jsx_runtime_1.jsx)(ActiveAgent_1.default, { children: (0, jsx_runtime_1.jsx)(ChatBotContent, {}) }) }) }));
|
|
58
|
+
return ((0, jsx_runtime_1.jsx)(RuntimeCommonProvider_1.default, { children: (0, jsx_runtime_1.jsx)(Runtime_1.default, { aid: aid, working: working, children: (0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(ActiveAgent_1.default, { children: (0, jsx_runtime_1.jsx)(ChatBotContent, {}) }) }) }) }));
|
|
58
59
|
}
|
|
59
60
|
exports.default = ChatBotButton;
|
|
60
61
|
function ChatBotContent() {
|
|
@@ -37,6 +37,7 @@ const header_1 = require("../../../../page/header");
|
|
|
37
37
|
const utils_1 = require("../../../../utils");
|
|
38
38
|
const RuntimeCommonProvider_1 = __importStar(require("../../components/RuntimeCommonProvider"));
|
|
39
39
|
const SocialShare_1 = __importDefault(require("../../components/SocialShare"));
|
|
40
|
+
const ThemeProvider_1 = __importDefault(require("../../components/ThemeProvider"));
|
|
40
41
|
const constants_1 = require("../../constants");
|
|
41
42
|
const ActiveAgent_1 = __importDefault(require("../../contexts/ActiveAgent"));
|
|
42
43
|
const Runtime_1 = __importStar(require("../../contexts/Runtime"));
|
|
@@ -48,7 +49,7 @@ function AgentCreatedBy({ did }) {
|
|
|
48
49
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [t('by'), " ", (0, jsx_runtime_1.jsx)(material_1.Box, { component: ux_1.DID, did: did, copyable: false, responsive: true })] }));
|
|
49
50
|
}
|
|
50
51
|
function Runtime({ aid, working }) {
|
|
51
|
-
const children = ((0, jsx_runtime_1.jsx)(ActiveAgent_1.default, { children: (0, jsx_runtime_1.jsx)(RuntimeView, {}) }));
|
|
52
|
+
const children = ((0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(ActiveAgent_1.default, { children: (0, jsx_runtime_1.jsx)(RuntimeView, {}) }) }));
|
|
52
53
|
return ((0, jsx_runtime_1.jsx)(RuntimeCommonProvider_1.default, { children: aid ? ((0, jsx_runtime_1.jsx)(Runtime_1.default, { aid: aid, working: working, children: children })) : ((0, jsx_runtime_1.jsx)(Runtime_1.RuntimeProviderFromUrl, { children: children })) }));
|
|
53
54
|
}
|
|
54
55
|
exports.default = Runtime;
|
|
@@ -29,28 +29,10 @@ const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"
|
|
|
29
29
|
const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
|
|
30
30
|
const session_1 = require("../../state/session");
|
|
31
31
|
const map_right_1 = __importDefault(require("../../utils/map-right"));
|
|
32
|
-
function PhotoGallery({ resultTitle
|
|
32
|
+
function PhotoGallery({ resultTitle }) {
|
|
33
33
|
const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
|
|
34
34
|
(0, session_1.useAutoLoadSessionState)();
|
|
35
|
-
|
|
36
|
-
const theme = (0, react_1.useMemo)(() => {
|
|
37
|
-
let { primary } = inheritedTheme.palette;
|
|
38
|
-
try {
|
|
39
|
-
if (primaryColor) {
|
|
40
|
-
primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
console.error('augment primary color error', { error });
|
|
45
|
-
}
|
|
46
|
-
return (0, material_1.createTheme)(inheritedTheme, {
|
|
47
|
-
palette: { primary },
|
|
48
|
-
shape: {
|
|
49
|
-
borderRadius: 8,
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}, [inheritedTheme, primaryColor]);
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "aigne-layout aigne-photo-wall-layout", children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { TitleProps: { fontSize: 48 }, DescriptionProps: { fontSize: 20 }, maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-photo-wall-inputs", maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(OutputView, { resultTitle: resultTitle, className: "aigne-outputs aigne-photo-wall-outputs", gap: 2 })] }) }));
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "aigne-layout aigne-photo-wall-layout", children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { TitleProps: { fontSize: 48 }, DescriptionProps: { fontSize: 20 }, maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-photo-wall-inputs", maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(OutputView, { resultTitle: resultTitle, className: "aigne-outputs aigne-photo-wall-outputs", gap: 2 })] }));
|
|
54
36
|
}
|
|
55
37
|
exports.default = PhotoGallery;
|
|
56
38
|
function AgentInputRender(_a) {
|
|
@@ -30,27 +30,9 @@ const BackgroundImage_1 = __importDefault(require("./BackgroundImage"));
|
|
|
30
30
|
const InputsView_1 = __importDefault(require("./InputsView"));
|
|
31
31
|
const MessagesView_1 = __importDefault(require("./MessagesView"));
|
|
32
32
|
function SimpleChat(_a) {
|
|
33
|
-
var {
|
|
33
|
+
var { scrollViewProps = { scroll: 'window', initialScrollBehavior: 'auto' } } = _a, preferences = __rest(_a, ["scrollViewProps"]);
|
|
34
34
|
(0, session_1.useAutoLoadSessionState)();
|
|
35
|
-
|
|
36
|
-
const theme = (0, react_1.useMemo)(() => {
|
|
37
|
-
let { primary } = inheritedTheme.palette;
|
|
38
|
-
try {
|
|
39
|
-
if (primaryColor) {
|
|
40
|
-
primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
console.error('augment primary color error', { error });
|
|
45
|
-
}
|
|
46
|
-
return (0, material_1.createTheme)(inheritedTheme, {
|
|
47
|
-
palette: { primary },
|
|
48
|
-
shape: {
|
|
49
|
-
borderRadius: 8,
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}, [inheritedTheme, primaryColor]);
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(ComponentPreferences_1.ComponentPreferencesProvider, Object.assign({}, preferences, { children: (0, jsx_runtime_1.jsx)(ScrollView_1.default, Object.assign({}, scrollViewProps, { children: (0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: theme, children: [(0, jsx_runtime_1.jsx)(BackgroundImage_1.default, {}), (0, jsx_runtime_1.jsx)(SimpleChatView, {})] }) })) })));
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(ComponentPreferences_1.ComponentPreferencesProvider, Object.assign({}, preferences, { children: (0, jsx_runtime_1.jsxs)(ScrollView_1.default, Object.assign({}, scrollViewProps, { children: [(0, jsx_runtime_1.jsx)(BackgroundImage_1.default, {}), (0, jsx_runtime_1.jsx)(SimpleChatView, {})] })) })));
|
|
54
36
|
}
|
|
55
37
|
exports.default = SimpleChat;
|
|
56
38
|
function SimpleChatView() {
|
|
@@ -26,28 +26,10 @@ const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
|
|
|
26
26
|
const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
|
|
27
27
|
const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
|
|
28
28
|
const session_1 = require("../../state/session");
|
|
29
|
-
function SimplePage({ resultTitle
|
|
29
|
+
function SimplePage({ resultTitle }) {
|
|
30
30
|
const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
|
|
31
31
|
(0, session_1.useAutoLoadSessionState)();
|
|
32
|
-
|
|
33
|
-
const theme = (0, react_1.useMemo)(() => {
|
|
34
|
-
let { primary } = inheritedTheme.palette;
|
|
35
|
-
try {
|
|
36
|
-
if (primaryColor) {
|
|
37
|
-
primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
console.error('augment primary color error', { error });
|
|
42
|
-
}
|
|
43
|
-
return (0, material_1.createTheme)(inheritedTheme, {
|
|
44
|
-
palette: { primary },
|
|
45
|
-
shape: {
|
|
46
|
-
borderRadius: 8,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
}, [inheritedTheme, primaryColor]);
|
|
50
|
-
return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { pb: 4, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, {}), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-simple-page-inputs" }) }), (0, jsx_runtime_1.jsx)(OutputView, { className: "aigne-outputs aigne-simple-page-outputs", resultTitle: resultTitle })] }) }));
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { pb: 4, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, {}), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-simple-page-inputs" }) }), (0, jsx_runtime_1.jsx)(OutputView, { className: "aigne-outputs aigne-simple-page-outputs", resultTitle: resultTitle })] }));
|
|
51
33
|
}
|
|
52
34
|
exports.default = SimplePage;
|
|
53
35
|
function AgentInputRender(_a) {
|
|
@@ -33,6 +33,7 @@ function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQu
|
|
|
33
33
|
var _a, _b;
|
|
34
34
|
const { t } = (0, locale_1.useLocaleContext)();
|
|
35
35
|
const { aid, agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
36
|
+
const [executeLoading, setExecuteLoading] = (0, react_2.useState)(false);
|
|
36
37
|
const opening = (0, use_appearances_1.useOpeningQuestions)();
|
|
37
38
|
const { execute } = (0, runtime_1.useRuntimeState)();
|
|
38
39
|
const { running } = (0, session_1.useCurrentSessionState)((s) => s) || {};
|
|
@@ -54,28 +55,38 @@ function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQu
|
|
|
54
55
|
}
|
|
55
56
|
}, [defaultForm, autoFillLastForm, form, chatMode]);
|
|
56
57
|
const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
try {
|
|
59
|
+
if (!(parameters === null || parameters === void 0 ? void 0 : parameters.question))
|
|
60
|
+
return;
|
|
61
|
+
setExecuteLoading(true);
|
|
62
|
+
if (!currentSessionId) {
|
|
63
|
+
yield createSession({
|
|
64
|
+
name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// in session page, send message
|
|
68
|
+
yield execute({
|
|
69
|
+
aid,
|
|
70
|
+
parameters,
|
|
71
|
+
onResponseStart: () => {
|
|
72
|
+
setCurrentMessageTaskId(undefined);
|
|
73
|
+
if (chatMode)
|
|
74
|
+
form.resetField('question', { defaultValue: '' });
|
|
75
|
+
},
|
|
62
76
|
});
|
|
63
77
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (chatMode)
|
|
71
|
-
form.resetField('question', { defaultValue: '' });
|
|
72
|
-
},
|
|
73
|
-
});
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.error(error);
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
setExecuteLoading(false);
|
|
83
|
+
}
|
|
74
84
|
});
|
|
75
85
|
return ((0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: theme, children: [!currentSessionId && ((_a = opening === null || opening === void 0 ? void 0 : opening.questions) === null || _a === void 0 ? void 0 : _a.length) && ((0, jsx_runtime_1.jsx)(material_1.Stack, { sx: {
|
|
76
86
|
flexDirection: 'row',
|
|
77
87
|
gap: 1,
|
|
78
88
|
mb: 1,
|
|
89
|
+
flexWrap: 'wrap',
|
|
79
90
|
}, children: (_b = opening === null || opening === void 0 ? void 0 : opening.questions) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
80
91
|
const { title, parameters, id } = item;
|
|
81
92
|
const question = (parameters === null || parameters === void 0 ? void 0 : parameters.questions) || title;
|
|
@@ -83,7 +94,8 @@ function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQu
|
|
|
83
94
|
marginLeft: -4,
|
|
84
95
|
} }), onClick: () => {
|
|
85
96
|
form.reset(Object.assign({}, parameters));
|
|
86
|
-
|
|
97
|
+
// auto execute message
|
|
98
|
+
// onSubmit({ ...parameters });
|
|
87
99
|
}, children: question }, id));
|
|
88
100
|
}) })), (0, jsx_runtime_1.jsxs)(Form, { id: "v0-input", component: "form", className: (0, css_1.cx)('form', `label-position-${inlineLabel ? 'start' : 'top'}`), onSubmit: form.handleSubmit(onSubmit), children: [parameters === null || parameters === void 0 ? void 0 : parameters.map((parameter, index) => {
|
|
89
101
|
const { key, required } = parameter !== null && parameter !== void 0 ? parameter : {};
|
|
@@ -109,7 +121,7 @@ function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQu
|
|
|
109
121
|
}
|
|
110
122
|
: undefined })] }));
|
|
111
123
|
} }) }, parameter.id));
|
|
112
|
-
}), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { type: "submit", variant: "contained", loading: running, sx: { height: 40 }, children: submitText || t('generate') }))] })] }));
|
|
124
|
+
}), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { type: "submit", variant: "contained", loading: executeLoading || running, sx: { height: 40 }, children: submitText || t('generate') }))] })] }));
|
|
113
125
|
}
|
|
114
126
|
exports.default = V0Input;
|
|
115
127
|
const autoSetLastParameters = false;
|
|
@@ -37,7 +37,7 @@ function V0Output() {
|
|
|
37
37
|
var _a, _b;
|
|
38
38
|
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
39
39
|
const propertiesSettingRef = (0, react_2.useRef)(null);
|
|
40
|
-
const { propertiesValueMap, setPropertiesValueMap } = (0, V0Runtime_1.useV0RuntimeContext)();
|
|
40
|
+
const { propertiesValueMap, setPropertiesValueMap, isMobile } = (0, V0Runtime_1.useV0RuntimeContext)();
|
|
41
41
|
const [code, setCode] = (0, react_2.useState)('');
|
|
42
42
|
const { t, locale } = (0, locale_1.useLocaleContext)();
|
|
43
43
|
const [codePreviewExtraSx, setCodePreviewExtraSx] = (0, react_2.useState)(DEFAULT_DESKTOP_SX);
|
|
@@ -50,7 +50,7 @@ function V0Output() {
|
|
|
50
50
|
borderColor: 'rgba(0, 0, 0, 0.1) !important',
|
|
51
51
|
};
|
|
52
52
|
const tooltipOptions = [
|
|
53
|
-
{
|
|
53
|
+
!isMobile && {
|
|
54
54
|
key: 'Desktop',
|
|
55
55
|
icon: 'tabler:device-desktop',
|
|
56
56
|
props: {
|
|
@@ -59,7 +59,7 @@ function V0Output() {
|
|
|
59
59
|
},
|
|
60
60
|
group: 'responsive',
|
|
61
61
|
},
|
|
62
|
-
{
|
|
62
|
+
!isMobile && {
|
|
63
63
|
key: 'Tablet',
|
|
64
64
|
icon: 'tabler:device-tablet',
|
|
65
65
|
props: {
|
|
@@ -71,7 +71,7 @@ function V0Output() {
|
|
|
71
71
|
},
|
|
72
72
|
group: 'responsive',
|
|
73
73
|
},
|
|
74
|
-
{
|
|
74
|
+
!isMobile && {
|
|
75
75
|
key: 'Mobile',
|
|
76
76
|
icon: 'tabler:device-mobile',
|
|
77
77
|
props: {
|
|
@@ -96,14 +96,14 @@ function V0Output() {
|
|
|
96
96
|
const currentCode = (0, CodePreview_1.getCurrentCodeByTaskId)(message, taskId);
|
|
97
97
|
try {
|
|
98
98
|
yield (0, CustomComponentRenderer_1.transpileAndLoadScript)(currentCode).then((m) => {
|
|
99
|
-
var _a, _b;
|
|
99
|
+
var _a, _b, _c;
|
|
100
100
|
if (typeof (m === null || m === void 0 ? void 0 : m.PROPERTIES_SCHEMA) === 'object' && (m === null || m === void 0 ? void 0 : m.PROPERTIES_SCHEMA.length)) {
|
|
101
101
|
const schemaDefaultValues = Object.fromEntries(m.PROPERTIES_SCHEMA.map((item) => {
|
|
102
102
|
const { key, locales } = item;
|
|
103
103
|
const currentLocale = (locales === null || locales === void 0 ? void 0 : locales[locale]) || (locales === null || locales === void 0 ? void 0 : locales.en);
|
|
104
104
|
return [key, currentLocale === null || currentLocale === void 0 ? void 0 : currentLocale.defaultValue];
|
|
105
105
|
}));
|
|
106
|
-
const defaultValues = Object.assign(Object.assign({}, schemaDefaultValues), (_a = propertiesValueMap[taskId]) === null || _a === void 0 ? void 0 : _a[locale]);
|
|
106
|
+
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) || {}));
|
|
107
107
|
// format default values
|
|
108
108
|
m.PROPERTIES_SCHEMA.forEach((item) => {
|
|
109
109
|
const { key, type } = item;
|
|
@@ -117,7 +117,7 @@ function V0Output() {
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
// @ts-ignore
|
|
120
|
-
(
|
|
120
|
+
(_c = propertiesSettingRef.current) === null || _c === void 0 ? void 0 : _c.open({
|
|
121
121
|
schema: m.PROPERTIES_SCHEMA,
|
|
122
122
|
onSubmit: (values) => {
|
|
123
123
|
const realValues = {};
|
|
@@ -155,7 +155,7 @@ function V0Output() {
|
|
|
155
155
|
{
|
|
156
156
|
key: 'CodePreview',
|
|
157
157
|
icon: code ? 'tabler:layout-board' : 'tabler:code',
|
|
158
|
-
buttonText: code ? 'Canvas' : 'Code',
|
|
158
|
+
buttonText: !isMobile && (code ? 'Canvas' : 'Code'),
|
|
159
159
|
props: {
|
|
160
160
|
disabled,
|
|
161
161
|
variant: 'contained',
|
|
@@ -168,7 +168,8 @@ function V0Output() {
|
|
|
168
168
|
},
|
|
169
169
|
group: 'codePreview',
|
|
170
170
|
},
|
|
171
|
-
];
|
|
171
|
+
].filter(Boolean);
|
|
172
|
+
const onCloseCode = () => setCode('');
|
|
172
173
|
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: {
|
|
173
174
|
p: 2,
|
|
174
175
|
gap: 2,
|
|
@@ -184,10 +185,15 @@ function V0Output() {
|
|
|
184
185
|
width: '100%',
|
|
185
186
|
gap: 1.5,
|
|
186
187
|
flexDirection: 'row',
|
|
188
|
+
'.question': {
|
|
189
|
+
backgroundColor: 'white',
|
|
190
|
+
border: 1,
|
|
191
|
+
borderColor: 'rgba(0, 0, 0, 0.1) !important',
|
|
192
|
+
},
|
|
187
193
|
}, children: [(0, jsx_runtime_1.jsx)(UserQuestion_1.default, { question: parameters === null || parameters === void 0 ? void 0 : parameters.question }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
188
194
|
display: 'flex',
|
|
189
195
|
alignItems: 'center',
|
|
190
|
-
gap: 1
|
|
196
|
+
gap: 1,
|
|
191
197
|
}, children: Object.entries((0, groupBy_1.default)(tooltipOptions, 'group')).map(([group, options]) => {
|
|
192
198
|
return ((0, jsx_runtime_1.jsx)(material_1.ButtonGroup, { variant: "text", color: "inherit", size: "small", sx: {
|
|
193
199
|
borderColor: 'rgba(0, 0, 0, 0.1) !important',
|
|
@@ -201,12 +207,25 @@ function V0Output() {
|
|
|
201
207
|
overflowY: 'auto',
|
|
202
208
|
scrollbarWidth: 'thin',
|
|
203
209
|
scrollbarColor: 'grey transparent',
|
|
204
|
-
}, propertiesValueMap: propertiesValueMap }) }), objects === null || objects === void 0 ? void 0 : objects.map((item, index) => (0, jsx_runtime_1.jsx)(MessageMetadataRenderer_1.default, { object: item.data }, index)), !isMessageLoading && ((_b = message.result) === null || _b === void 0 ? void 0 : _b.content) && ((0, jsx_runtime_1.jsx)(ShareActions_1.default, { direction: "row", justifyContent: "flex-end", sx: { mt: 2 } })), (0, jsx_runtime_1.jsxs)(react_2.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Loading_1.default, {}), children: [(0, jsx_runtime_1.jsx)(material_1.Drawer, { anchor:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
}, propertiesValueMap: propertiesValueMap }) }), objects === null || objects === void 0 ? void 0 : objects.map((item, index) => (0, jsx_runtime_1.jsx)(MessageMetadataRenderer_1.default, { object: item.data }, index)), !isMessageLoading && ((_b = message.result) === null || _b === void 0 ? void 0 : _b.content) && ((0, jsx_runtime_1.jsx)(ShareActions_1.default, { direction: "row", justifyContent: "flex-end", sx: { mt: 2 } })), (0, jsx_runtime_1.jsxs)(react_2.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Loading_1.default, {}), children: [(0, jsx_runtime_1.jsx)(material_1.Drawer, { anchor: isMobile ? 'bottom' : 'right', open: !!code, onClose: onCloseCode, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: Object.assign({ p: 2, pt: 0 }, (isMobile ? { maxHeight: '70vh' } : { maxWidth: '70vw' })), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
211
|
+
py: 2,
|
|
212
|
+
position: 'sticky',
|
|
213
|
+
top: 0,
|
|
214
|
+
left: 0,
|
|
215
|
+
backgroundColor: 'white',
|
|
216
|
+
zIndex: 9999,
|
|
217
|
+
display: 'flex',
|
|
218
|
+
justifyContent: 'space-between',
|
|
219
|
+
alignItems: 'center',
|
|
220
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", sx: {
|
|
221
|
+
lineHeight: 1,
|
|
222
|
+
}, children: t('v0.codePreview') }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: onCloseCode,
|
|
223
|
+
// variant="text"
|
|
224
|
+
color: "inherit", disableElevation: true, sx: {
|
|
225
|
+
minWidth: 32,
|
|
226
|
+
minHeight: 32,
|
|
227
|
+
p: 0,
|
|
228
|
+
fontSize: 22,
|
|
229
|
+
}, children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:x" }) })] }), (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mb: 2 }, children: t('v0.codePreviewTip') }), (0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: `\`\`\`typescript\n${code}\n\`\`\`` })] }) }), (0, jsx_runtime_1.jsx)(PropertiesSetting_1.default, { ref: propertiesSettingRef })] })] }));
|
|
211
230
|
}
|
|
212
231
|
exports.default = V0Output;
|