@blocklet/pages-kit 0.2.369 → 0.2.371

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.
Files changed (26) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/LanguageField.js +18 -33
  2. package/lib/cjs/builtin/async/ai-runtime/hooks/use-header-menu.js +2 -2
  3. package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +6 -2
  4. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +3 -2
  5. package/lib/cjs/builtin/async/ai-runtime/utils/languages.js +36 -0
  6. package/lib/cjs/builtin/components.js +8 -0
  7. package/lib/cjs/builtin/mui/material.js +3 -2
  8. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  9. package/lib/cjs/utils/builtin.js +1 -0
  10. package/lib/cjs/utils/inject-global-components.js +2 -0
  11. package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/LanguageField.js +20 -35
  12. package/lib/esm/builtin/async/ai-runtime/hooks/use-header-menu.js +2 -2
  13. package/lib/esm/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +6 -2
  14. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +3 -2
  15. package/lib/esm/builtin/async/ai-runtime/utils/languages.js +33 -0
  16. package/lib/esm/builtin/components.js +1 -0
  17. package/lib/esm/builtin/mui/material.js +1 -1
  18. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  19. package/lib/esm/utils/builtin.js +1 -0
  20. package/lib/esm/utils/inject-global-components.js +2 -0
  21. package/lib/types/builtin/async/ai-runtime/utils/languages.d.ts +8 -0
  22. package/lib/types/builtin/components.d.ts +1 -0
  23. package/lib/types/builtin/mui/material.d.ts +1 -1
  24. package/lib/types/tsconfig.tsbuildinfo +1 -1
  25. package/lib/types/utils/builtin.d.ts +1 -0
  26. package/package.json +3 -2
@@ -63,6 +63,7 @@ exports.BuiltinModules = {
63
63
  // The following packages are lazy loading
64
64
  '@blocklet/pages-kit/builtin/async/react-scroll-to-bottom': reactScrollToBottom,
65
65
  // The following packages are ignored at server side
66
+ '@blocklet/pages-kit/builtin/components': {},
66
67
  '@blocklet/pages-kit/builtin/session': {},
67
68
  '@blocklet/pages-kit/builtin/locale': {},
68
69
  '@blocklet/pages-kit/builtin/page/header': {},
@@ -34,6 +34,7 @@ const reactMarkdown = __importStar(require("../builtin/async/react-markdown"));
34
34
  const reactScrollToBottom = __importStar(require("../builtin/async/react-scroll-to-bottom"));
35
35
  const reactSyntaxHighlighter = __importStar(require("../builtin/async/react-syntax-highlighter"));
36
36
  const call = __importStar(require("../builtin/call"));
37
+ const components = __importStar(require("../builtin/components"));
37
38
  const dayjs = __importStar(require("../builtin/dayjs"));
38
39
  const emotionCss = __importStar(require("../builtin/emotion/css"));
39
40
  const iconifyReact = __importStar(require("../builtin/iconify/react"));
@@ -79,6 +80,7 @@ function injectGlobalComponents() {
79
80
  '@blocklet/pages-kit/builtin/react-router-dom': reactRouterDOM,
80
81
  '@blocklet/pages-kit/builtin/arcblock/ux': arcblockUx,
81
82
  '@blocklet/pages-kit/builtin/page/header': pageHeader,
83
+ '@blocklet/pages-kit/builtin/components': components,
82
84
  // The following packages are lazy loading
83
85
  '@blocklet/pages-kit/builtin/async/react-scroll-to-bottom': reactScrollToBottom,
84
86
  '@blocklet/pages-kit/builtin/async/react-markdown': reactMarkdown,
@@ -9,45 +9,30 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { MenuItem, TextField } from '@mui/material';
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Autocomplete, ListItem, ListItemIcon, ListItemText, MenuItem, TextField } from '@mui/material';
14
14
  import { forwardRef } from 'react';
15
15
  import { useLocaleContext } from '../../../../locale';
16
+ import { languages } from '../../utils/languages';
17
+ const filter = (options, state) => {
18
+ return options.filter((o) => {
19
+ if (state.inputValue) {
20
+ return (o.en.toLowerCase().includes(state.inputValue.toLowerCase()) ||
21
+ o.name.toLowerCase().includes(state.inputValue.toLowerCase()));
22
+ }
23
+ return true;
24
+ });
25
+ };
16
26
  const LanguageField = forwardRef((_a, ref) => {
17
27
  var { readOnly, parameter, onChange } = _a, props = __rest(_a, ["readOnly", "parameter", "onChange"]);
18
28
  const { locale } = useLocaleContext();
19
- return (_jsx(TextField, Object.assign({ ref: ref, select: true, onChange: (e) => onChange(e.target.value) }, props, { InputProps: Object.assign(Object.assign({}, props.InputProps), { readOnly }), children: languages.map((option) => (_jsx(MenuItem, { value: option.en, children: locale === 'zh' ? option.cn : option.en }, option.en))) })));
29
+ const value = (props === null || props === void 0 ? void 0 : props.value) ? languages.find((o) => o.en === props.value) : null;
30
+ return (_jsx(Autocomplete, { size: "small", ref: ref, renderInput: (params) => (_jsx(TextField, Object.assign({}, params, { inputRef: props.inputRef, required: parameter === null || parameter === void 0 ? void 0 : parameter.required, placeholder: parameter === null || parameter === void 0 ? void 0 : parameter.placeholder, helperText: parameter === null || parameter === void 0 ? void 0 : parameter.helper }))), options: languages, getOptionKey: (i) => i.en, getOptionLabel: (o) => {
31
+ return locale === 'zh' ? o.cn : o.en;
32
+ }, value: value, filterOptions: filter, onChange: (_e, newValue) => {
33
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue === null || newValue === void 0 ? void 0 : newValue.en);
34
+ }, renderOption: (props, option) => {
35
+ return (_jsx(MenuItem, Object.assign({}, props, { children: _jsxs(ListItem, { sx: { py: 0 }, children: [_jsx(ListItemIcon, { children: _jsx(option.flag, {}) }), _jsx(ListItemText, { primary: `${option.name} ${locale === 'zh' ? option.cn : option.en} (${option.abbr})` })] }) })));
36
+ } }));
20
37
  });
21
38
  export default LanguageField;
22
- const languages = [
23
- { en: 'English', cn: '英语' },
24
- { en: 'Simplified Chinese', cn: '中文-简体' },
25
- { en: 'Traditional Chinese', cn: '中文-繁体' },
26
- { en: 'Spanish', cn: '西班牙语' },
27
- { en: 'French', cn: '法语' },
28
- { en: 'German', cn: '德语' },
29
- { en: 'Italian', cn: '意大利语' },
30
- { en: 'Portuguese', cn: '葡萄牙语' },
31
- { en: 'Japanese', cn: '日语' },
32
- { en: 'Korean', cn: '韩语' },
33
- { en: 'Russian', cn: '俄语' },
34
- { en: 'Polish', cn: '波兰语' },
35
- { en: 'Arabic', cn: '阿拉伯语' },
36
- { en: 'Dutch', cn: '荷兰语' },
37
- { en: 'Swedish', cn: '瑞典语' },
38
- { en: 'Finnish', cn: '芬兰语' },
39
- { en: 'Czech', cn: '捷克语' },
40
- { en: 'Danish', cn: '丹麦语' },
41
- { en: 'Greek', cn: '希腊语' },
42
- { en: 'Romanian', cn: '罗马尼亚语' },
43
- { en: 'Hungarian', cn: '匈牙利语' },
44
- { en: 'Bulgarian', cn: '保加利亚语' },
45
- { en: 'Slovak', cn: '斯洛伐克语' },
46
- { en: 'Norwegian', cn: '挪威语' },
47
- { en: 'Hebrew', cn: '希伯来语' },
48
- { en: 'Turkish', cn: '土耳其语' },
49
- { en: 'Thai', cn: '泰语' },
50
- { en: 'Indonesian', cn: '印尼语' },
51
- { en: 'Vietnamese', cn: '越南语' },
52
- { en: 'Hindi', cn: '印地语' },
53
- ];
@@ -33,11 +33,11 @@ export function useHeaderMenu() {
33
33
  ? {}
34
34
  : {
35
35
  addons: (exists) => [
36
- _jsx(PopperMenuButton, { component: IconButton, PopperProps: { placement: 'bottom-end', sx: { zIndex: 'appBar' } }, menus: [
36
+ _jsx(PopperMenuButton, { "data-testid": "aigne-runtime-header-menu-button", component: IconButton, PopperProps: { placement: 'bottom-end', sx: { zIndex: 'appBar' } }, menus: [
37
37
  hasSettings && isAdmin && (_jsxs(MenuItem, { onClick: () => settingsDialogState.getState().open(), children: [_jsx(ListItemIcon, { children: _jsx(Icon, { icon: "tabler:settings" }) }), t('settings')] }, "settings")),
38
38
  _jsxs(LoadingMenuItem, { onClick: () => __awaiter(this, void 0, void 0, function* () { return clearSession(); }), children: [_jsx(ListItemIcon, { children: _jsx(Icon, { icon: "mingcute:broom-line" }) }), t('clearSession')] }, "clearSession"),
39
39
  ], children: _jsx(Icon, { icon: "tabler:dots" }) }),
40
- _jsx(SocialShare, { content: shareContent }),
40
+ _jsx(SocialShare, { "data-testid": "aigen-runtime-header-share-button", content: shareContent }),
41
41
  ...exists,
42
42
  ],
43
43
  }, [locale, hideHeaderMenuButton]);
@@ -82,11 +82,15 @@ export default function AutoForm({ submitText, inlineLabel, autoFillLastForm = t
82
82
  : undefined,
83
83
  }, render: ({ field, fieldState }) => {
84
84
  var _a;
85
- return (_jsxs(Stack, { className: "form-item", children: [parameter.label && _jsx(FormLabel, { children: parameter.label }), _jsx(AgentInputField, { inputProps: { 'data-testid': `runtime-input-${key}` }, 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
85
+ return (_jsxs(Stack, { className: "form-item", children: [parameter.label && _jsx(FormLabel, { children: parameter.label }), _jsx(AgentInputField
86
+ // inputProps={{ 'data-testid': `runtime-input-${key}` }}
87
+ , {
88
+ // inputProps={{ 'data-testid': `runtime-input-${key}` }}
89
+ 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: Object.assign(Object.assign({}, (parameter.key === 'question' && submitInQuestionField
86
90
  ? {
87
91
  endAdornment: (_jsx(InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: _jsx(LoadingButton, { "data-testid": "runtime-submit-button", ref: submitRef, type: "submit", variant: "contained", loading: running, disabled: submitDisabled, sx: { borderRadius: 1.5 }, children: submitText }) })),
88
92
  }
89
- : undefined })] }));
93
+ : {})), ({ 'data-testid': `runtime-input-${key}` } || {})) })] }));
90
94
  } }) }, parameter.id));
91
95
  }), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && (_jsx(LoadingButton, { "data-testid": "runtime-submit-button", ref: submitRef, type: "submit", variant: "contained", loading: running, disabled: submitDisabled, sx: { height: 40 }, children: submitText || t('generate') }))] }));
92
96
  }
@@ -10,6 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { cx } from '@emotion/css';
13
14
  import { Box, Stack } from '@mui/material';
14
15
  import { Suspense, memo } from 'react';
15
16
  import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
@@ -35,7 +36,7 @@ const MessageView = memo(({ message }) => {
35
36
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
36
37
  return null;
37
38
  const agentMessage = (_jsx(MessageBodyContainer, { messageRole: "assistant", children: _jsx(Suspense, { children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorView }, message.id) }) }));
38
- return (_jsx(CurrentAgentProvider, { agentId: message.agentId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsxs(Stack, { gap: 2, children: [!hideUserInputs && (_jsx(Box, { children: _jsx(UserInfo, { name: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, did: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.did, avatar: getAssetUrl({ filename: (_e = authSession.user) === null || _e === void 0 ? void 0 : _e.avatar, preset: 'avatar' }), time: message.createdAt, reverse: true, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: _jsx(Stack, { sx: { alignItems: 'flex-end' }, children: _jsx(MessageBodyContainer, { messageRole: "user", children: _jsx(AgentErrorBoundary, { children: _jsx(Suspense, { children: _jsx(UserMessageView, {}) }) }) }) }) }) })), _jsx(Box, { children: !hideAgentAvatar ? (_jsx(UserInfo, { name: profile.name, did: (_f = globalThis.blocklet) === null || _f === void 0 ? void 0 : _f.appId, avatar: getAssetUrl({ blockletDid, aid, filename: profile.avatar, preset: 'avatar' }), time: message.createdAt, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: agentMessage })) : (agentMessage) })] }) }) }));
39
+ return (_jsx(CurrentAgentProvider, { agentId: message.agentId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsxs(Stack, { gap: 2, className: "message-item", "data-testid": `message-${message.id}`, children: [!hideUserInputs && (_jsx(Box, { children: _jsx(UserInfo, { name: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, did: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.did, avatar: getAssetUrl({ filename: (_e = authSession.user) === null || _e === void 0 ? void 0 : _e.avatar, preset: 'avatar' }), time: message.createdAt, reverse: true, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: _jsx(Stack, { sx: { alignItems: 'flex-end' }, children: _jsx(MessageBodyContainer, { messageRole: "user", children: _jsx(AgentErrorBoundary, { children: _jsx(Suspense, { children: _jsx(UserMessageView, {}) }) }) }) }) }) })), _jsx(Box, { children: !hideAgentAvatar ? (_jsx(UserInfo, { name: profile.name, did: (_f = globalThis.blocklet) === null || _f === void 0 ? void 0 : _f.appId, avatar: getAssetUrl({ blockletDid, aid, filename: profile.avatar, preset: 'avatar' }), time: message.createdAt, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: agentMessage })) : (agentMessage) })] }) }) }));
39
40
  });
40
41
  export default MessageView;
41
42
  export function MessageBodyContainer(_a) {
@@ -44,6 +45,6 @@ export function MessageBodyContainer(_a) {
44
45
  const preferences = useComponentPreferences();
45
46
  const hasBg = !!((_b = preferences === null || preferences === void 0 ? void 0 : preferences.backgroundImage) === null || _b === void 0 ? void 0 : _b.url);
46
47
  const hideUserMessage = preferences === null || preferences === void 0 ? void 0 : preferences.hideUserInputs;
47
- return (_jsx(Box, Object.assign({}, props, { sx: hasBg
48
+ return (_jsx(Box, Object.assign({}, props, { className: cx(props.className, 'message-content', `${messageRole}-message-content`), sx: hasBg
48
49
  ? Object.assign({ borderRadius: 1, borderTopRightRadius: messageRole === 'user' ? 2 : undefined, borderTopLeftRadius: messageRole !== 'user' ? 2 : undefined, px: 2, py: 1, marginTop: 0.5, maxWidth: hideUserMessage ? 'unset' : 'calc(100% - 40px)', bgcolor: 'rgba(255, 255, 255, 0.8)', backdropFilter: 'blur(16px)' }, props.sx) : Object.assign({}, props.sx) })));
49
50
  }
@@ -0,0 +1,33 @@
1
+ import { Bg, Cn, Cz, De, Dk, Es, Fi, Fr, Gb, Gr, Hu, Id, Il, In, It, Jp, Kr, Nl, No, Pl, Pt, Ro, Ru, Sa, Se, Sk, Th, Tr, Tw, Vn, } from 'react-flags-select';
2
+ export const languages = [
3
+ { en: 'English', name: 'English', abbr: 'GB', flag: Gb, cn: '英语' },
4
+ { en: 'Simplified Chinese', name: '简体中文', abbr: 'CN', flag: Cn, cn: '简体中文' },
5
+ { en: 'Traditional Chinese', name: '繁体中文', abbr: 'ZH-TW', flag: Tw, cn: '繁体中文' },
6
+ { en: 'Spanish', name: 'Español', abbr: 'ES', flag: Es, cn: '西班牙语' },
7
+ { en: 'French', name: 'Français', abbr: 'FR', flag: Fr, cn: '法语' },
8
+ { en: 'German', name: 'Deutsch', abbr: 'DE', flag: De, cn: '德语' },
9
+ { en: 'Italian', name: 'Italiano', abbr: 'IT', flag: It, cn: '意大利语' },
10
+ { en: 'Portuguese', name: 'Português', abbr: 'PT', flag: Pt, cn: '葡萄牙语' },
11
+ { en: 'Japanese', name: '日本語', abbr: 'JP', flag: Jp, cn: '日语' },
12
+ { en: 'Korean', name: '한국어', abbr: 'KR', flag: Kr, cn: '韩语' },
13
+ { en: 'Russian', name: 'Русский', abbr: 'RU', flag: Ru, cn: '俄语' },
14
+ { en: 'Polish', name: 'Polski', abbr: 'PL', flag: Pl, cn: '波兰语' },
15
+ { en: 'Arabic', name: 'العربية', abbr: 'SA', flag: Sa, cn: '阿拉伯语' },
16
+ { en: 'Dutch', name: 'Nederlands', abbr: 'NL', flag: Nl, cn: '荷兰语' },
17
+ { en: 'Swedish', name: 'Svenska', abbr: 'SE', flag: Se, cn: '瑞典语' },
18
+ { en: 'Finnish', name: 'Suomi', abbr: 'FI', flag: Fi, cn: '芬兰语' },
19
+ { en: 'Czech', name: 'Čeština', abbr: 'CZ', flag: Cz, cn: '捷克语' },
20
+ { en: 'Danish', name: 'Dansk', abbr: 'DK', flag: Dk, cn: '丹麦语' },
21
+ { en: 'Greek', name: 'Ελληνικά', abbr: 'GR', flag: Gr, cn: '希腊语' },
22
+ { en: 'Romanian', name: 'Română', abbr: 'RO', flag: Ro, cn: '罗马尼亚语' },
23
+ { en: 'Hungarian', name: 'Magyar', abbr: 'HU', flag: Hu, cn: '匈牙利语' },
24
+ { en: 'Bulgarian', name: 'Български', abbr: 'BG', flag: Bg, cn: '保加利亚语' },
25
+ { en: 'Slovak', name: 'Slovenčina', abbr: 'SK', flag: Sk, cn: '斯洛伐克语' },
26
+ { en: 'Norwegian', name: 'Norsk', abbr: 'NO', flag: No, cn: '挪威语' },
27
+ { en: 'Hebrew', name: 'עברית', abbr: 'IL', flag: Il, cn: '希伯来语' },
28
+ { en: 'Turkish', name: 'Türkçe', abbr: 'TR', flag: Tr, cn: '土耳其语' },
29
+ { en: 'Thai', name: 'ไทย', abbr: 'TH', flag: Th, cn: '泰语' },
30
+ { en: 'Indonesian', name: 'Bahasa Indonesia', abbr: 'ID', flag: Id, cn: '印尼语' },
31
+ { en: 'Vietnamese', name: 'Tiếng Việt', abbr: 'VN', flag: Vn, cn: '越南语' },
32
+ { en: 'Hindi', name: 'हिन्दी', abbr: 'IN', flag: In, cn: '印地语' },
33
+ ];
@@ -0,0 +1 @@
1
+ export { default as LanguageField } from './async/ai-runtime/components/AgentInputField/LanguageField';
@@ -1 +1 @@
1
- export { Checkbox, ListItemText, Alert, AlertTitle, Autocomplete, Avatar, Box, Button, IconButton, ButtonGroup, Card, CardActionArea, CardActions, CardContent, CardHeader, CardMedia, CircularProgress, ClickAwayListener, Collapse, Container, Dialog, DialogActions, DialogContent, DialogTitle, Divider, Fade, GlobalStyles, Grid, Grow, LinearProgress, Link, List, ListItem, ListItemAvatar, ListItemButton, ListItemIcon, ListItemSecondaryAction, ListSubheader, Menu, MenuItem, MenuList, Paper, Popper, Slide, Stack, Switch, TextField, ThemeProvider, Tooltip, Typography, Zoom, alpha, createTheme, styled, useMediaQuery, useTheme, } from '@mui/material';
1
+ export { Checkbox, ListItemText, Alert, AlertTitle, Autocomplete, Avatar, Box, Button, IconButton, ButtonGroup, Card, CardActionArea, CardActions, CardContent, CardHeader, CardMedia, CircularProgress, ClickAwayListener, Collapse, Container, Dialog, DialogActions, DialogContent, DialogTitle, Divider, Fade, GlobalStyles, Grid, Grow, LinearProgress, Link, List, ListItem, ListItemAvatar, ListItemButton, ListItemIcon, ListItemSecondaryAction, ListSubheader, Menu, MenuItem, MenuList, Paper, Popper, Select, Slide, Stack, Switch, TextField, ThemeProvider, Tooltip, Typography, Zoom, alpha, createTheme, styled, useMediaQuery, useTheme, } from '@mui/material';