@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.
@@ -37,7 +37,7 @@ function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQu
37
37
  const opening = (0, use_appearances_1.useOpeningQuestions)();
38
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;
@@ -59,11 +59,6 @@ function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQu
59
59
  if (!(parameters === null || parameters === void 0 ? void 0 : parameters.question))
60
60
  return;
61
61
  setExecuteLoading(true);
62
- if (!currentSessionId) {
63
- yield createSession({
64
- name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
65
- });
66
- }
67
62
  // in session page, send message
68
63
  yield execute({
69
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,23 @@ 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
+ '&.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
+ disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Desktop',
57
66
  sx: Object.assign({}, responsiveSx),
58
- onClick: () => setCodePreviewExtraSx(DEFAULT_DESKTOP_SX),
67
+ onClick: () => setCodePreviewExtraProps({
68
+ sx: DEFAULT_DESKTOP_SX,
69
+ key: 'Desktop',
70
+ }),
59
71
  },
60
72
  group: 'responsive',
61
73
  },
@@ -63,10 +75,14 @@ function V0Output() {
63
75
  key: 'Tablet',
64
76
  icon: 'tabler:device-tablet',
65
77
  props: {
78
+ disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Tablet',
66
79
  sx: Object.assign({}, responsiveSx),
67
- onClick: () => setCodePreviewExtraSx({
68
- width: '768px',
69
- height: '1024px',
80
+ onClick: () => setCodePreviewExtraProps({
81
+ sx: {
82
+ width: '768px',
83
+ height: '1024px',
84
+ },
85
+ key: 'Tablet',
70
86
  }),
71
87
  },
72
88
  group: 'responsive',
@@ -75,10 +91,14 @@ function V0Output() {
75
91
  key: 'Mobile',
76
92
  icon: 'tabler:device-mobile',
77
93
  props: {
94
+ disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Mobile',
78
95
  sx: Object.assign({}, responsiveSx),
79
- onClick: () => setCodePreviewExtraSx({
80
- width: '375px',
81
- height: '667px',
96
+ onClick: () => setCodePreviewExtraProps({
97
+ sx: {
98
+ width: '375px',
99
+ height: '667px',
100
+ },
101
+ key: 'Mobile',
82
102
  }),
83
103
  },
84
104
  group: 'responsive',
@@ -202,7 +222,7 @@ function V0Output() {
202
222
  const { icon, key, props, buttonText } = option;
203
223
  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
224
  }) }, 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: {
225
+ }) })] }), (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
226
  overflowX: 'auto',
207
227
  overflowY: 'auto',
208
228
  scrollbarWidth: 'thin',
@@ -1,15 +1,40 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  const jsx_runtime_1 = require("react/jsx-runtime");
7
- const ClickToCopy_1 = __importDefault(require("@arcblock/ux/lib/ClickToCopy"));
27
+ const ClickToCopy_1 = __importStar(require("@arcblock/ux/lib/ClickToCopy"));
8
28
  const material_1 = require("@mui/material");
9
29
  const ux_1 = require("../../../../../arcblock/ux");
10
30
  const locale_1 = require("../../../../../locale");
11
31
  const session_1 = require("../../../../../session");
12
32
  const utils_1 = require("../utils");
33
+ const BASE_QUESTION_SX = {
34
+ fontWeight: 500,
35
+ fontSize: 13,
36
+ lineHeight: 1.6,
37
+ };
13
38
  function UserQuestion({ question }) {
14
39
  var _a;
15
40
  const { session: authSession } = (0, session_1.useSessionContext)();
@@ -27,6 +52,11 @@ function UserQuestion({ question }) {
27
52
  borderRadius: 1,
28
53
  // borderTopLeftRadius: 0,
29
54
  backgroundColor: 'grey.200',
30
- }, children: (0, jsx_runtime_1.jsx)(ClickToCopy_1.default, { locale: locale, unstyled: true, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { sx: Object.assign({ fontWeight: 500, fontSize: 13, maxWidth: 300, color: 'textColor', textAlign: 'left' }, (0, utils_1.getLineClamp)(1)), children: question }) }) })] }));
55
+ maxWidth: 300,
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
+ } }) })] }));
31
61
  }
32
62
  exports.default = UserQuestion;
@@ -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) => {