@blocklet/pages-kit 0.2.323 → 0.2.325

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.
@@ -35,9 +35,9 @@ function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQu
35
35
  const { aid, agent } = (0, CurrentAgent_1.useCurrentAgent)();
36
36
  const [executeLoading, setExecuteLoading] = (0, react_2.useState)(false);
37
37
  const opening = (0, use_appearances_1.useOpeningQuestions)();
38
- const { execute, checkLoginState } = (0, runtime_1.useRuntimeState)();
38
+ const { execute } = (0, runtime_1.useRuntimeState)();
39
39
  const { running } = (0, session_1.useCurrentSessionState)((s) => s) || {};
40
- const { createSession, currentSessionId } = (0, session_1.useSessionState)((s) => s) || {};
40
+ const { currentSessionId } = (0, session_1.useSessionState)((s) => s) || {};
41
41
  const { setCurrentMessageTaskId } = (0, V0Runtime_1.useV0RuntimeContext)();
42
42
  const parameters = (0, react_2.useMemo)(() => {
43
43
  var _a;
@@ -56,15 +56,9 @@ function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQu
56
56
  }, [defaultForm, autoFillLastForm, form, chatMode]);
57
57
  const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
58
58
  try {
59
- yield checkLoginState();
60
59
  if (!(parameters === null || parameters === void 0 ? void 0 : parameters.question))
61
60
  return;
62
61
  setExecuteLoading(true);
63
- if (!currentSessionId) {
64
- yield createSession({
65
- name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
66
- });
67
- }
68
62
  // in session page, send message
69
63
  yield execute({
70
64
  aid,
@@ -40,7 +40,10 @@ function V0Output() {
40
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
- const [codePreviewExtraSx, setCodePreviewExtraSx] = (0, react_2.useState)(DEFAULT_DESKTOP_SX);
43
+ const [codePreviewExtraProps, setCodePreviewExtraProps] = (0, react_2.useState)({
44
+ sx: DEFAULT_DESKTOP_SX,
45
+ key: 'Desktop',
46
+ });
44
47
  const objects = (_a = message.result) === null || _a === void 0 ? void 0 : _a.objects;
45
48
  const { taskId, parameters } = message;
46
49
  const isMessageLoading = (message.loading || !message.result) && !message.error;
@@ -48,14 +51,24 @@ function V0Output() {
48
51
  const responsiveSx = {
49
52
  backgroundColor: 'white',
50
53
  borderColor: 'rgba(0, 0, 0, 0.1) !important',
54
+ // rewrite disabled style
55
+ '&.frame-button.Mui-disabled': {
56
+ backgroundColor: 'primary.main',
57
+ color: 'white',
58
+ },
51
59
  };
52
60
  const tooltipOptions = [
53
61
  !isMobile && {
54
62
  key: 'Desktop',
55
63
  icon: 'tabler:device-desktop',
56
64
  props: {
65
+ className: 'frame-button',
66
+ disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Desktop',
57
67
  sx: Object.assign({}, responsiveSx),
58
- onClick: () => setCodePreviewExtraSx(DEFAULT_DESKTOP_SX),
68
+ onClick: () => setCodePreviewExtraProps({
69
+ sx: DEFAULT_DESKTOP_SX,
70
+ key: 'Desktop',
71
+ }),
59
72
  },
60
73
  group: 'responsive',
61
74
  },
@@ -63,10 +76,15 @@ function V0Output() {
63
76
  key: 'Tablet',
64
77
  icon: 'tabler:device-tablet',
65
78
  props: {
79
+ className: 'frame-button',
80
+ disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Tablet',
66
81
  sx: Object.assign({}, responsiveSx),
67
- onClick: () => setCodePreviewExtraSx({
68
- width: '768px',
69
- height: '1024px',
82
+ onClick: () => setCodePreviewExtraProps({
83
+ sx: {
84
+ width: '768px',
85
+ height: '1024px',
86
+ },
87
+ key: 'Tablet',
70
88
  }),
71
89
  },
72
90
  group: 'responsive',
@@ -75,10 +93,15 @@ function V0Output() {
75
93
  key: 'Mobile',
76
94
  icon: 'tabler:device-mobile',
77
95
  props: {
96
+ className: 'frame-button',
97
+ disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Mobile',
78
98
  sx: Object.assign({}, responsiveSx),
79
- onClick: () => setCodePreviewExtraSx({
80
- width: '375px',
81
- height: '667px',
99
+ onClick: () => setCodePreviewExtraProps({
100
+ sx: {
101
+ width: '375px',
102
+ height: '667px',
103
+ },
104
+ key: 'Mobile',
82
105
  }),
83
106
  },
84
107
  group: 'responsive',
@@ -202,7 +225,7 @@ function V0Output() {
202
225
  const { icon, key, props, buttonText } = option;
203
226
  return ((0, jsx_runtime_1.jsxs)(material_1.Button, Object.assign({ "data-taskId": taskId }, props, { children: [(0, jsx_runtime_1.jsx)(react_1.Icon, { icon: icon, fontSize: 22 }), buttonText && (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { ml: 1 }, children: buttonText })] }), key));
204
227
  }) }, group));
205
- }) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: Object.assign({ display: 'flex', justifyContent: 'center', overflow: 'hidden', backgroundColor: 'white', borderRadius: 1 }, codePreviewExtraSx), children: (0, jsx_runtime_1.jsx)(CodePreview_1.CodeRenderByMessageMemo, { message: message, zoom: 1, sx: {
228
+ }) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: Object.assign({ display: 'flex', justifyContent: 'center', overflow: 'hidden', backgroundColor: 'white', borderRadius: 1 }, codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.sx), children: (0, jsx_runtime_1.jsx)(CodePreview_1.CodeRenderByMessageMemo, { message: message, zoom: 1, sx: {
206
229
  overflowX: 'auto',
207
230
  overflowY: 'auto',
208
231
  scrollbarWidth: 'thin',
@@ -33,6 +33,7 @@ const utils_1 = require("../utils");
33
33
  const BASE_QUESTION_SX = {
34
34
  fontWeight: 500,
35
35
  fontSize: 13,
36
+ lineHeight: 1.6,
36
37
  };
37
38
  function UserQuestion({ question }) {
38
39
  var _a;
@@ -52,6 +53,10 @@ function UserQuestion({ question }) {
52
53
  // borderTopLeftRadius: 0,
53
54
  backgroundColor: 'grey.200',
54
55
  maxWidth: 300,
55
- }, children: (0, jsx_runtime_1.jsx)(ClickToCopy_1.CopyButton, { locale: locale, unstyled: true, render: ({ containerRef }) => ((0, jsx_runtime_1.jsx)(material_1.Box, { ref: containerRef, display: "flex", alignItems: "center", sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'textColor' }), children: (0, jsx_runtime_1.jsx)(ClickToCopy_1.default, { locale: locale, unstyled: true, children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'white' }), children: question }) }), children: (0, jsx_runtime_1.jsx)(material_1.Typography, { sx: Object.assign(Object.assign(Object.assign({}, BASE_QUESTION_SX), { textAlign: 'left', alignItems: 'center' }), (0, utils_1.getLineClamp)(1)), children: question }) }) }) })) }) })] }));
56
+ }, children: (0, jsx_runtime_1.jsx)(ClickToCopy_1.CopyButton, { locale: locale, unstyled: true, render: ({ copyButton, containerRef }) => {
57
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { ref: containerRef, display: "flex", alignItems: "center", sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'textColor' }), children: (0, jsx_runtime_1.jsx)(ClickToCopy_1.default, { locale: locale, unstyled: true, disableHoverListener: true, disableFocusListener: true, disableTouchListener: true, children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, { placement: "bottom", arrow: true, title: (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, { sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'white' }), children: [question, (0, jsx_runtime_1.jsx)(material_1.Box, { id: "copy-button-wrapper", component: "span", sx: {
58
+ ml: 0.5,
59
+ }, children: copyButton })] }) }), children: (0, jsx_runtime_1.jsx)(material_1.Typography, { sx: Object.assign(Object.assign(Object.assign({}, BASE_QUESTION_SX), { textAlign: 'left', alignItems: 'center' }), (0, utils_1.getLineClamp)(1)), children: question }) }) }) }));
60
+ } }) })] }));
56
61
  }
57
62
  exports.default = UserQuestion;
@@ -16,7 +16,7 @@ const Runtime_1 = require("../contexts/Runtime");
16
16
  const agent_1 = require("./agent");
17
17
  const session_2 = require("./session");
18
18
  function useRuntimeState() {
19
- var _a, _b;
19
+ var _a;
20
20
  const { aid, working } = (0, Runtime_1.useRuntimeContext)();
21
21
  const [agent] = (0, agent_1.useAgentState)({ aid, working });
22
22
  const { session: authSession } = (0, session_1.useSessionContext)();
@@ -41,12 +41,6 @@ function useRuntimeState() {
41
41
  }
42
42
  return exec(Object.assign(Object.assign({}, args), { working }));
43
43
  }), [authSession.user, exec, working, login]);
44
- const checkLoginState = (0, react_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
45
- var _c;
46
- if (!((_c = authSession.user) === null || _c === void 0 ? void 0 : _c.did)) {
47
- yield login();
48
- }
49
- }), [!((_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did)]);
50
- return { aid, working, agent, execute, checkLoginState };
44
+ return { aid, working, agent, execute };
51
45
  }
52
46
  exports.useRuntimeState = useRuntimeState;
@@ -247,7 +247,11 @@ const createSessionState = ({ aid }) => {
247
247
  execute: (_g) => __awaiter(void 0, void 0, void 0, function* () {
248
248
  var _h, e_1, _j, _k;
249
249
  var { aid, working, parameters, onResponseStart } = _g, args = __rest(_g, ["aid", "working", "parameters", "onResponseStart"]);
250
- const sessionId = args.sessionId || get().currentSessionId || (yield get().createSession()).id;
250
+ const sessionId = args.sessionId ||
251
+ get().currentSessionId ||
252
+ (yield get().createSession({
253
+ name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
254
+ })).id;
251
255
  const identity = (0, aid_1.parseIdentity)(aid, { rejectWhenError: true });
252
256
  let message;
253
257
  set((state) => {