@blocklet/pages-kit 0.2.360 → 0.2.362
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/ThemeProvider.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +5 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/DrawerOpenCloseIcon.js +42 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +23 -4
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +2 -4
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +6 -3
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/DrawerOpenCloseIcon.js +39 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +25 -6
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +2 -4
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/DrawerOpenCloseIcon.d.ts +4 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -58,7 +58,7 @@ export default function ThemeProvider({ children }) {
|
|
|
58
58
|
props: {},
|
|
59
59
|
style: ({ theme }) => theme.unstable_sx({
|
|
60
60
|
'.MuiInputBase-root': {
|
|
61
|
-
fieldset: { borderColor: '
|
|
61
|
+
fieldset: { borderColor: 'grey.400' },
|
|
62
62
|
[`&.Mui-focused, :not(.${inputBaseClasses.disabled}):hover`]: {
|
|
63
63
|
fieldset: {
|
|
64
64
|
border: 'none',
|
|
@@ -12,7 +12,7 @@ import { cx } from '@emotion/css';
|
|
|
12
12
|
import { Box, FormLabel, InputAdornment, Stack, formLabelClasses, styled } from '@mui/material';
|
|
13
13
|
import isEmpty from 'lodash/isEmpty';
|
|
14
14
|
import omit from 'lodash/omit';
|
|
15
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
15
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
16
16
|
import { Controller, useForm } from 'react-hook-form';
|
|
17
17
|
import { useLocaleContext } from '../../../../locale';
|
|
18
18
|
import AgentInputField from '../../components/AgentInputField';
|
|
@@ -22,6 +22,7 @@ import { useRuntimeState } from '../../state/runtime';
|
|
|
22
22
|
import { useCurrentSessionState } from '../../state/session';
|
|
23
23
|
import { isValidInput } from '../../utils/agent-inputs';
|
|
24
24
|
export default function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQuestionField, chatMode, }) {
|
|
25
|
+
const submitRef = useRef(null);
|
|
25
26
|
const { t } = useLocaleContext();
|
|
26
27
|
const { aid, agent } = useCurrentAgent();
|
|
27
28
|
const { execute } = useRuntimeState();
|
|
@@ -41,6 +42,8 @@ export default function AutoForm({ submitText, inlineLabel, autoFillLastForm = t
|
|
|
41
42
|
}
|
|
42
43
|
}, [defaultForm, autoFillLastForm, form, chatMode]);
|
|
43
44
|
const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: 'center' });
|
|
44
47
|
yield execute({
|
|
45
48
|
aid,
|
|
46
49
|
parameters,
|
|
@@ -70,11 +73,11 @@ export default function AutoForm({ submitText, inlineLabel, autoFillLastForm = t
|
|
|
70
73
|
var _a;
|
|
71
74
|
return (_jsxs(Stack, { className: "form-item", children: [parameter.label && _jsx(FormLabel, { children: parameter.label }), _jsx(AgentInputField, { inputRef: field.ref, autoFocus: index === 0, size: "small", hiddenLabel: true, fullWidth: true, label: undefined, parameter: parameter, maxRows: !(parameter === null || parameter === void 0 ? void 0 : parameter.type) || (parameter === null || parameter === void 0 ? void 0 : parameter.type) === 'string' ? 5 : undefined, value: field.value || '', onChange: (value) => field.onChange({ target: { value } }), error: Boolean(fieldState.error), helperText: ((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || (parameter === null || parameter === void 0 ? void 0 : parameter.helper), InputProps: parameter.key === 'question' && submitInQuestionField
|
|
72
75
|
? {
|
|
73
|
-
endAdornment: (_jsx(InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: _jsx(LoadingButton, { type: "submit", variant: "contained", loading: running, sx: { borderRadius: 1.5 }, children: submitText }) })),
|
|
76
|
+
endAdornment: (_jsx(InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: _jsx(LoadingButton, { ref: submitRef, type: "submit", variant: "contained", loading: running, sx: { borderRadius: 1.5 }, children: submitText }) })),
|
|
74
77
|
}
|
|
75
78
|
: undefined })] }));
|
|
76
79
|
} }) }, parameter.id));
|
|
77
|
-
}), !(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') }))] }));
|
|
80
|
+
}), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && (_jsx(LoadingButton, { ref: submitRef, type: "submit", variant: "contained", loading: running, sx: { height: 40 }, children: submitText || t('generate') }))] }));
|
|
78
81
|
}
|
|
79
82
|
function useInitialFormValues() {
|
|
80
83
|
const { agent } = useCurrentAgent();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { cx } from '@emotion/css';
|
|
14
|
+
import { Stack } from '@mui/material';
|
|
15
|
+
export default function DrawerOpenCloseIcon(_a) {
|
|
16
|
+
var { arrowDirection } = _a, props = __rest(_a, ["arrowDirection"]);
|
|
17
|
+
return (_jsx(Stack, Object.assign({ direction: "row", position: "relative" }, props, { className: cx(props.className, `drawer-open-close-icon-${arrowDirection || 'up'}`), sx: Object.assign({ p: 1, cursor: 'pointer', ':hover': {
|
|
18
|
+
opacity: 0.7,
|
|
19
|
+
}, ':before,:after': {
|
|
20
|
+
content: '""',
|
|
21
|
+
display: 'block',
|
|
22
|
+
bgcolor: 'currentColor',
|
|
23
|
+
width: 22,
|
|
24
|
+
height: 6,
|
|
25
|
+
borderRadius: 100,
|
|
26
|
+
position: 'relative',
|
|
27
|
+
}, ':before': {
|
|
28
|
+
transform: 'translateX(2px) rotateZ(-8deg)',
|
|
29
|
+
}, ':after': {
|
|
30
|
+
transform: 'translateX(-2px) rotateZ(8deg)',
|
|
31
|
+
}, '&.drawer-open-close-icon-down': {
|
|
32
|
+
':before': {
|
|
33
|
+
transform: 'translateX(2px) rotateZ(8deg)',
|
|
34
|
+
},
|
|
35
|
+
':after': {
|
|
36
|
+
transform: 'translateX(-2px) rotateZ(-8deg)',
|
|
37
|
+
},
|
|
38
|
+
} }, props.sx) })));
|
|
39
|
+
}
|
|
@@ -11,22 +11,41 @@ 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 { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
|
|
14
|
-
import { Avatar, IconButton, Stack } from '@mui/material';
|
|
15
|
-
import { useMemo } from 'react';
|
|
14
|
+
import { Avatar, Collapse, IconButton, Stack } from '@mui/material';
|
|
15
|
+
import { memo, useMemo, useState } from 'react';
|
|
16
16
|
import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
|
|
17
17
|
import { getAssetUrl } from '../../api/asset';
|
|
18
18
|
import { useActiveAgent } from '../../contexts/ActiveAgent';
|
|
19
19
|
import CurrentAgentProvider, { useCurrentAgent } from '../../contexts/CurrentAgent';
|
|
20
20
|
import useAppearances, { useProfile } from '../../hooks/use-appearances';
|
|
21
21
|
import { useRuntimeState } from '../../state/runtime';
|
|
22
|
+
import { isValidInput } from '../../utils/agent-inputs';
|
|
22
23
|
import { getOutputVariableInitialValue } from '../../utils/runtime-output-schema';
|
|
24
|
+
import DrawerOpenCloseIcon from './DrawerOpenCloseIcon';
|
|
25
|
+
const COLLAPSED_SIZE = 80;
|
|
23
26
|
export default function InputsView(_a) {
|
|
24
27
|
var props = __rest(_a, []);
|
|
25
|
-
const { activeAgentId
|
|
26
|
-
const { agent } =
|
|
27
|
-
const
|
|
28
|
-
|
|
28
|
+
const { activeAgentId } = useActiveAgent();
|
|
29
|
+
const { agent } = useCurrentAgent({ agentId: activeAgentId });
|
|
30
|
+
const inputs = useMemo(() => { var _a; return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(isValidInput); }, [agent]);
|
|
31
|
+
const enableCollapse = !!inputs && inputs.length > 1;
|
|
32
|
+
const [open, setOpen] = useState(true);
|
|
33
|
+
return (_jsxs(Stack, Object.assign({ gap: 1, py: 1 }, props, { children: [enableCollapse && (_jsx(Stack, { direction: "row", justifyContent: "center", onClick: () => setOpen(!open), mb: -1, children: _jsx(DrawerOpenCloseIcon, { color: "grey.500", arrowDirection: open ? 'down' : 'up' }) })), _jsx(AgentList, { sx: { px: { xs: 2, sm: 3 } } }), _jsx(Collapse, { in: !enableCollapse || open, orientation: "vertical", collapsedSize: enableCollapse ? COLLAPSED_SIZE : 0, sx: {
|
|
34
|
+
py: 1,
|
|
35
|
+
maxHeight: '40vh',
|
|
36
|
+
px: { xs: 2, sm: 3 },
|
|
37
|
+
overflow: 'auto',
|
|
38
|
+
}, children: _jsx(CurrentAgentProvider, { agentId: activeAgentId, children: _jsx(AgentInput, {}) }) }, inputs === null || inputs === void 0 ? void 0 : inputs.length)] })));
|
|
29
39
|
}
|
|
40
|
+
const AgentList = memo((_a) => {
|
|
41
|
+
var props = __rest(_a, []);
|
|
42
|
+
const { activeAgentId, setActiveAgentId } = useActiveAgent();
|
|
43
|
+
const { agent: runtimeAgent } = useRuntimeState();
|
|
44
|
+
const children = useMemo(() => { var _a, _b; return (_b = (_a = getOutputVariableInitialValue(runtimeAgent, RuntimeOutputVariable.children)) === null || _a === void 0 ? void 0 : _a.agents) === null || _b === void 0 ? void 0 : _b.filter((i) => !!i.id); }, [runtimeAgent]);
|
|
45
|
+
if (!(children === null || children === void 0 ? void 0 : children.length) || children.length <= 1)
|
|
46
|
+
return null;
|
|
47
|
+
return (_jsx(Stack, Object.assign({ direction: "row", gap: 2, py: 1, overflow: "auto" }, props, { children: children === null || children === void 0 ? void 0 : children.map((child) => (_jsx(CurrentAgentProvider, { agentId: child.id, children: _jsx(AgentAvatar, { selected: activeAgentId === child.id, onClick: () => setActiveAgentId(child.id) }) }))) })));
|
|
48
|
+
});
|
|
30
49
|
function AgentAvatar(_a) {
|
|
31
50
|
var _b;
|
|
32
51
|
var { selected } = _a, props = __rest(_a, ["selected"]);
|
|
@@ -45,11 +45,9 @@ function SimpleChatView() {
|
|
|
45
45
|
return (_jsxs(SimpleLayout, { px: 0, children: [_jsx(SimpleHeader, { px: 4, sx: { color: hasBg ? 'white' : undefined } }), loading ? (_jsx(Box, { textAlign: "center", my: 10, children: _jsx(CircularProgress, { size: 24 }) })) : (_jsxs(_Fragment, { children: [_jsx(CurrentAgentProvider, { agentId: activeAgentId, children: _jsx(MessagesView, { className: "aigne-outputs aigne-simple-chat-outputs", flexGrow: 1, pb: 10, px: { xs: 2, sm: 3 } }) }), _jsx(CurrentAgentProvider, { agentId: activeAgentId, children: _jsx(InputsView, { className: "aigne-inputs aigne-simple-chat-inputs", sx: {
|
|
46
46
|
position: 'sticky',
|
|
47
47
|
bottom: 0,
|
|
48
|
-
py: 2,
|
|
49
|
-
px: { xs: 2, sm: 3 },
|
|
50
48
|
zIndex: 10,
|
|
51
49
|
borderRadius: 1,
|
|
52
|
-
bgcolor: (theme) => alpha(theme.palette.background.paper, 0.
|
|
53
|
-
backdropFilter: 'blur(
|
|
50
|
+
bgcolor: (theme) => alpha(theme.palette.background.paper, 0.8),
|
|
51
|
+
backdropFilter: 'blur(16px)',
|
|
54
52
|
} }) })] }))] }));
|
|
55
53
|
}
|