@blocklet/pages-kit 0.2.370 → 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.
@@ -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
- ];
@@ -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
  }
@@ -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';