@blocklet/pages-kit 0.2.385 → 0.2.387

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.
@@ -9,8 +9,10 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { Autocomplete, ListItem, ListItemIcon, ListItemText, MenuItem, TextField } from '@mui/material';
12
+ import { createElement as _createElement } from "react";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { Autocomplete, ListItemIcon, ListItemText, MenuItem, TextField } from '@mui/material';
15
+ import pick from 'lodash/pick';
14
16
  import { forwardRef } from 'react';
15
17
  import { useLocaleContext } from '../../../../locale';
16
18
  import { languages } from '../../utils/languages';
@@ -27,12 +29,14 @@ const LanguageField = forwardRef((_a, ref) => {
27
29
  var { readOnly, parameter, onChange } = _a, props = __rest(_a, ["readOnly", "parameter", "onChange"]);
28
30
  const { locale } = useLocaleContext();
29
31
  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) => {
32
+ return (_jsx(Autocomplete, Object.assign({ size: "small", ref: ref }, pick(props, 'autoFocus', 'fullWidth', 'sx', 'className', 'style'), { renderInput: (params) => (_jsx(TextField, Object.assign({}, pick(props, 'inputRef', 'size', 'hiddenLabel', 'helperText', 'error', 'placeholder', 'InputProps', 'inputProps'), params))), options: languages, getOptionKey: (i) => i.en, getOptionLabel: (o) => {
31
33
  return locale === 'zh' ? o.cn : o.en;
32
- }, value: value, filterOptions: filter, onChange: (_e, newValue) => {
34
+ }, autoHighlight: true, value: value, filterOptions: filter, onChange: (_e, newValue) => {
33
35
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue === null || newValue === void 0 ? void 0 : newValue.en);
34
36
  }, 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
- } }));
37
+ return (_createElement(MenuItem, Object.assign({}, props, { key: option.name }),
38
+ _jsx(ListItemIcon, { children: _jsx(option.flag, {}) }),
39
+ _jsx(ListItemText, { primary: `${option.name} ${locale === 'zh' ? option.cn : option.en} (${option.abbr})` })));
40
+ } })));
37
41
  });
38
42
  export default LanguageField;
@@ -182,7 +182,7 @@ function ShareCommunity({ inputs, shareAttach, }) {
182
182
  const images = (_j = (_h = (_g = (_f = (_e = message.outputs) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f.find) === null || _g === void 0 ? void 0 : _g.call(_f, (i) => { var _a; return (_a = i === null || i === void 0 ? void 0 : i[RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _h === void 0 ? void 0 : _h[RuntimeOutputVariable.images]) === null || _j === void 0 ? void 0 : _j.map((i) => i.url);
183
183
  let content = '';
184
184
  if (shareAttach.shareAttachUrl) {
185
- content += `${link}\n\n`;
185
+ content += `[[]](${link})\n\n`;
186
186
  }
187
187
  if (shareAttach.shareAttachInputs) {
188
188
  content += `> ${inputs}\n\n`;
@@ -196,6 +196,7 @@ function ShareCommunity({ inputs, shareAttach, }) {
196
196
  format: 'markdown',
197
197
  title: `${((_k = message.inputs) === null || _k === void 0 ? void 0 : _k.question) || inputs}`,
198
198
  content,
199
+ labels: 'demo',
199
200
  };
200
201
  }, [inputs, shareAttach]);
201
202
  return (_jsx(StyledActionButton, { tip: t('socialShare.shareToCommunity'), title: _jsx(CommunityIcon, {}), target: "_blank", href: withQuery('https://community.arcblock.io/discussions/add?', query) }));
@@ -82,7 +82,7 @@ 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: Object.assign({}, (parameter.key === 'question' && submitInQuestionField
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), sx: { flex: 1 }, InputProps: Object.assign({}, (parameter.key === 'question' && submitInQuestionField
86
86
  ? {
87
87
  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
88
  }
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { Divider, List, ListItemButton } from '@mui/material';
12
12
  import Joi from 'joi';
13
- import { useMemo, useState } from 'react';
13
+ import React, { useMemo, useState } from 'react';
14
14
  import OutputFieldContainer from '../../components/OutputFieldContainer';
15
15
  import { useCurrentAgent } from '../../contexts/CurrentAgent';
16
16
  import { useCurrentMessage } from '../../contexts/CurrentMessage';
@@ -42,7 +42,7 @@ export default function GoogleSearchRelatedView({ output, outputValue, onlyLastM
42
42
  return null;
43
43
  if ((!isLastMessage && onlyLastMessage) || !((_b = result === null || result === void 0 ? void 0 : result.related_questions) === null || _b === void 0 ? void 0 : _b.length))
44
44
  return null;
45
- return (_jsx(OutputFieldContainer, { output: output, children: _jsx(List, { dense: true, disablePadding: true, children: result.related_questions.map((item) => (_jsxs(_Fragment, { children: [_jsx(ListItemButton, { sx: { py: 1, px: 2 }, onClick: () => __awaiter(this, void 0, void 0, function* () {
45
+ return (_jsx(OutputFieldContainer, { output: output, children: _jsx(List, { dense: true, disablePadding: true, children: result.related_questions.map((item) => (_jsxs(React.Fragment, { children: [_jsx(ListItemButton, { sx: { py: 1, px: 2 }, onClick: () => __awaiter(this, void 0, void 0, function* () {
46
46
  if (submitting)
47
47
  return;
48
48
  setSubmitting(true);
@@ -52,5 +52,5 @@ export default function GoogleSearchRelatedView({ output, outputValue, onlyLastM
52
52
  finally {
53
53
  setSubmitting(false);
54
54
  }
55
- }), children: item.question }, item.title), _jsx(Divider, {})] }))) }) }));
55
+ }), children: item.question }), _jsx(Divider, {})] }, item.title))) }) }));
56
56
  }
@@ -44,7 +44,7 @@ const AgentList = memo((_a) => {
44
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
45
  if (!(children === null || children === void 0 ? void 0 : children.length) || children.length <= 1)
46
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) }) }))) })));
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) }) }, child.id))) })));
48
48
  });
49
49
  function AgentAvatar(_a) {
50
50
  var _b;
@@ -19,11 +19,12 @@ import { useComponent } from './state';
19
19
  export * from './state';
20
20
  const MAXIMUM_RENDER_STACK_SIZE = 20;
21
21
  export default function CustomComponentRenderer(_a) {
22
- var _b;
22
+ var _b, _c, _d;
23
23
  var { dev } = _a, props = __rest(_a, ["dev"]);
24
24
  const inheritedDev = useDev();
25
25
  const BuiltinComponent = BuiltinComponents[props.componentId];
26
- return (_jsx(ErrorBoundary, { FallbackComponent: (props === null || props === void 0 ? void 0 : props.fallbackRender) || ErrorView, children: _jsx(DevProvider, { dev: dev !== null && dev !== void 0 ? dev : inheritedDev, children: BuiltinComponent ? (_jsx(BuiltinComponent, Object.assign({}, props))) : (_jsx(ComponentRenderer, Object.assign({}, props, { instanceId: (_b = props.instanceId) !== null && _b !== void 0 ? _b : props.componentId }))) }) }));
26
+ const renderer = (_c = (_b = dev === null || dev === void 0 ? void 0 : dev.components) === null || _b === void 0 ? void 0 : _b[props.componentId]) === null || _c === void 0 ? void 0 : _c.data.renderer;
27
+ return (_jsx(ErrorBoundary, { FallbackComponent: (props === null || props === void 0 ? void 0 : props.fallbackRender) || ErrorView, resetKeys: [renderer && 'script' in renderer ? renderer.script : undefined], children: _jsx(DevProvider, { dev: dev !== null && dev !== void 0 ? dev : inheritedDev, children: BuiltinComponent ? (_jsx(BuiltinComponent, Object.assign({}, props))) : (_jsx(ComponentRenderer, Object.assign({}, props, { instanceId: (_d = props.instanceId) !== null && _d !== void 0 ? _d : props.componentId }))) }) }));
27
28
  }
28
29
  const BuiltinComponents = {
29
30
  'blocklet-react-component': BlockletReactComponentRenderer,