@blocklet/pages-kit 0.2.322 → 0.2.324
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/runtime-components/V0/Input.js +1 -6
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +29 -9
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +34 -4
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +5 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +1 -6
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +29 -9
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +13 -3
- package/lib/esm/builtin/async/ai-runtime/state/session.js +5 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -32,7 +32,7 @@ export default function V0Input({ submitText, inlineLabel, autoFillLastForm = fa
|
|
|
32
32
|
const opening = useOpeningQuestions();
|
|
33
33
|
const { execute } = useRuntimeState();
|
|
34
34
|
const { running } = useCurrentSessionState((s) => s) || {};
|
|
35
|
-
const {
|
|
35
|
+
const { currentSessionId } = useSessionState((s) => s) || {};
|
|
36
36
|
const { setCurrentMessageTaskId } = useV0RuntimeContext();
|
|
37
37
|
const parameters = useMemo(() => {
|
|
38
38
|
var _a;
|
|
@@ -54,11 +54,6 @@ export default function V0Input({ submitText, inlineLabel, autoFillLastForm = fa
|
|
|
54
54
|
if (!(parameters === null || parameters === void 0 ? void 0 : parameters.question))
|
|
55
55
|
return;
|
|
56
56
|
setExecuteLoading(true);
|
|
57
|
-
if (!currentSessionId) {
|
|
58
|
-
yield createSession({
|
|
59
|
-
name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
57
|
// in session page, send message
|
|
63
58
|
yield execute({
|
|
64
59
|
aid,
|
|
@@ -35,7 +35,10 @@ export default function V0Output() {
|
|
|
35
35
|
const { propertiesValueMap, setPropertiesValueMap, isMobile } = useV0RuntimeContext();
|
|
36
36
|
const [code, setCode] = useState('');
|
|
37
37
|
const { t, locale } = useLocaleContext();
|
|
38
|
-
const [
|
|
38
|
+
const [codePreviewExtraProps, setCodePreviewExtraProps] = useState({
|
|
39
|
+
sx: DEFAULT_DESKTOP_SX,
|
|
40
|
+
key: 'Desktop',
|
|
41
|
+
});
|
|
39
42
|
const objects = (_a = message.result) === null || _a === void 0 ? void 0 : _a.objects;
|
|
40
43
|
const { taskId, parameters } = message;
|
|
41
44
|
const isMessageLoading = (message.loading || !message.result) && !message.error;
|
|
@@ -43,14 +46,23 @@ export default function V0Output() {
|
|
|
43
46
|
const responsiveSx = {
|
|
44
47
|
backgroundColor: 'white',
|
|
45
48
|
borderColor: 'rgba(0, 0, 0, 0.1) !important',
|
|
49
|
+
// rewrite disabled style
|
|
50
|
+
'&.Mui-disabled': {
|
|
51
|
+
backgroundColor: 'primary.main',
|
|
52
|
+
color: 'white',
|
|
53
|
+
},
|
|
46
54
|
};
|
|
47
55
|
const tooltipOptions = [
|
|
48
56
|
!isMobile && {
|
|
49
57
|
key: 'Desktop',
|
|
50
58
|
icon: 'tabler:device-desktop',
|
|
51
59
|
props: {
|
|
60
|
+
disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Desktop',
|
|
52
61
|
sx: Object.assign({}, responsiveSx),
|
|
53
|
-
onClick: () =>
|
|
62
|
+
onClick: () => setCodePreviewExtraProps({
|
|
63
|
+
sx: DEFAULT_DESKTOP_SX,
|
|
64
|
+
key: 'Desktop',
|
|
65
|
+
}),
|
|
54
66
|
},
|
|
55
67
|
group: 'responsive',
|
|
56
68
|
},
|
|
@@ -58,10 +70,14 @@ export default function V0Output() {
|
|
|
58
70
|
key: 'Tablet',
|
|
59
71
|
icon: 'tabler:device-tablet',
|
|
60
72
|
props: {
|
|
73
|
+
disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Tablet',
|
|
61
74
|
sx: Object.assign({}, responsiveSx),
|
|
62
|
-
onClick: () =>
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
onClick: () => setCodePreviewExtraProps({
|
|
76
|
+
sx: {
|
|
77
|
+
width: '768px',
|
|
78
|
+
height: '1024px',
|
|
79
|
+
},
|
|
80
|
+
key: 'Tablet',
|
|
65
81
|
}),
|
|
66
82
|
},
|
|
67
83
|
group: 'responsive',
|
|
@@ -70,10 +86,14 @@ export default function V0Output() {
|
|
|
70
86
|
key: 'Mobile',
|
|
71
87
|
icon: 'tabler:device-mobile',
|
|
72
88
|
props: {
|
|
89
|
+
disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Mobile',
|
|
73
90
|
sx: Object.assign({}, responsiveSx),
|
|
74
|
-
onClick: () =>
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
onClick: () => setCodePreviewExtraProps({
|
|
92
|
+
sx: {
|
|
93
|
+
width: '375px',
|
|
94
|
+
height: '667px',
|
|
95
|
+
},
|
|
96
|
+
key: 'Mobile',
|
|
77
97
|
}),
|
|
78
98
|
},
|
|
79
99
|
group: 'responsive',
|
|
@@ -197,7 +217,7 @@ export default function V0Output() {
|
|
|
197
217
|
const { icon, key, props, buttonText } = option;
|
|
198
218
|
return (_jsxs(Button, Object.assign({ "data-taskId": taskId }, props, { children: [_jsx(Icon, { icon: icon, fontSize: 22 }), buttonText && _jsx(Box, { sx: { ml: 1 }, children: buttonText })] }), key));
|
|
199
219
|
}) }, group));
|
|
200
|
-
}) })] }), _jsx(Box, { sx: Object.assign({ display: 'flex', justifyContent: 'center', overflow: 'hidden', backgroundColor: 'white', borderRadius: 1 },
|
|
220
|
+
}) })] }), _jsx(Box, { sx: Object.assign({ display: 'flex', justifyContent: 'center', overflow: 'hidden', backgroundColor: 'white', borderRadius: 1 }, codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.sx), children: _jsx(CodeRenderByMessage, { message: message, zoom: 1, sx: {
|
|
201
221
|
overflowX: 'auto',
|
|
202
222
|
overflowY: 'auto',
|
|
203
223
|
scrollbarWidth: 'thin',
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import ClickToCopy from '@arcblock/ux/lib/ClickToCopy';
|
|
3
|
-
import { Box, Typography } from '@mui/material';
|
|
2
|
+
import ClickToCopy, { CopyButton } from '@arcblock/ux/lib/ClickToCopy';
|
|
3
|
+
import { Box, Tooltip, Typography } from '@mui/material';
|
|
4
4
|
import { Avatar } from '../../../../../arcblock/ux';
|
|
5
5
|
import { useLocaleContext } from '../../../../../locale';
|
|
6
6
|
import { useSessionContext } from '../../../../../session';
|
|
7
7
|
import { getLineClamp } from '../utils';
|
|
8
|
+
const BASE_QUESTION_SX = {
|
|
9
|
+
fontWeight: 500,
|
|
10
|
+
fontSize: 13,
|
|
11
|
+
lineHeight: 1.6,
|
|
12
|
+
};
|
|
8
13
|
export default function UserQuestion({ question }) {
|
|
9
14
|
var _a;
|
|
10
15
|
const { session: authSession } = useSessionContext();
|
|
@@ -22,5 +27,10 @@ export default function UserQuestion({ question }) {
|
|
|
22
27
|
borderRadius: 1,
|
|
23
28
|
// borderTopLeftRadius: 0,
|
|
24
29
|
backgroundColor: 'grey.200',
|
|
25
|
-
|
|
30
|
+
maxWidth: 300,
|
|
31
|
+
}, children: _jsx(CopyButton, { locale: locale, unstyled: true, render: ({ copyButton, containerRef }) => {
|
|
32
|
+
return (_jsx(Box, { ref: containerRef, display: "flex", alignItems: "center", sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'textColor' }), children: _jsx(ClickToCopy, { locale: locale, unstyled: true, disableHoverListener: true, disableFocusListener: true, disableTouchListener: true, children: _jsx(Tooltip, { placement: "bottom", arrow: true, title: _jsx(Box, { children: _jsxs(Typography, { sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'white' }), children: [question, _jsx(Box, { id: "copy-button-wrapper", component: "span", sx: {
|
|
33
|
+
ml: 0.5,
|
|
34
|
+
}, children: copyButton })] }) }), children: _jsx(Typography, { sx: Object.assign(Object.assign(Object.assign({}, BASE_QUESTION_SX), { textAlign: 'left', alignItems: 'center' }), getLineClamp(1)), children: question }) }) }) }));
|
|
35
|
+
} }) })] }));
|
|
26
36
|
}
|
|
@@ -244,7 +244,11 @@ export const createSessionState = ({ aid }) => {
|
|
|
244
244
|
execute: (_g) => __awaiter(void 0, void 0, void 0, function* () {
|
|
245
245
|
var _h, e_1, _j, _k;
|
|
246
246
|
var { aid, working, parameters, onResponseStart } = _g, args = __rest(_g, ["aid", "working", "parameters", "onResponseStart"]);
|
|
247
|
-
const sessionId = args.sessionId ||
|
|
247
|
+
const sessionId = args.sessionId ||
|
|
248
|
+
get().currentSessionId ||
|
|
249
|
+
(yield get().createSession({
|
|
250
|
+
name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
|
|
251
|
+
})).id;
|
|
248
252
|
const identity = parseIdentity(aid, { rejectWhenError: true });
|
|
249
253
|
let message;
|
|
250
254
|
set((state) => {
|