@blocklet/pages-kit 0.2.386 → 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.
@@ -10,10 +10,15 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  }
11
11
  return t;
12
12
  };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
13
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ const react_1 = require("react");
14
18
  const jsx_runtime_1 = require("react/jsx-runtime");
15
19
  const material_1 = require("@mui/material");
16
- const react_1 = require("react");
20
+ const pick_1 = __importDefault(require("lodash/pick"));
21
+ const react_2 = require("react");
17
22
  const locale_1 = require("../../../../locale");
18
23
  const languages_1 = require("../../utils/languages");
19
24
  const filter = (options, state) => {
@@ -25,16 +30,18 @@ const filter = (options, state) => {
25
30
  return true;
26
31
  });
27
32
  };
28
- const LanguageField = (0, react_1.forwardRef)((_a, ref) => {
33
+ const LanguageField = (0, react_2.forwardRef)((_a, ref) => {
29
34
  var { readOnly, parameter, onChange } = _a, props = __rest(_a, ["readOnly", "parameter", "onChange"]);
30
35
  const { locale } = (0, locale_1.useLocaleContext)();
31
36
  const value = (props === null || props === void 0 ? void 0 : props.value) ? languages_1.languages.find((o) => o.en === props.value) : null;
32
- return ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, { size: "small", ref: ref, renderInput: (params) => ((0, jsx_runtime_1.jsx)(material_1.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_1.languages, getOptionKey: (i) => i.en, getOptionLabel: (o) => {
37
+ return ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, Object.assign({ size: "small", ref: ref }, (0, pick_1.default)(props, 'autoFocus', 'fullWidth', 'sx', 'className', 'style'), { renderInput: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, (0, pick_1.default)(props, 'inputRef', 'size', 'hiddenLabel', 'helperText', 'error', 'placeholder', 'InputProps', 'inputProps'), params))), options: languages_1.languages, getOptionKey: (i) => i.en, getOptionLabel: (o) => {
33
38
  return locale === 'zh' ? o.cn : o.en;
34
- }, value: value, filterOptions: filter, onChange: (_e, newValue) => {
39
+ }, autoHighlight: true, value: value, filterOptions: filter, onChange: (_e, newValue) => {
35
40
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue === null || newValue === void 0 ? void 0 : newValue.en);
36
41
  }, renderOption: (props, option) => {
37
- return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({}, props, { children: (0, jsx_runtime_1.jsxs)(material_1.ListItem, { sx: { py: 0 }, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(option.flag, {}) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: `${option.name} ${locale === 'zh' ? option.cn : option.en} (${option.abbr})` })] }) })));
38
- } }));
42
+ return ((0, react_1.createElement)(material_1.MenuItem, Object.assign({}, props, { key: option.name }),
43
+ (0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(option.flag, {}) }),
44
+ (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: `${option.name} ${locale === 'zh' ? option.cn : option.en} (${option.abbr})` })));
45
+ } })));
39
46
  });
40
47
  exports.default = LanguageField;
@@ -88,7 +88,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
88
88
  : undefined,
89
89
  }, render: ({ field, fieldState }) => {
90
90
  var _a;
91
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "form-item", children: [parameter.label && (0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: parameter.label }), (0, jsx_runtime_1.jsx)(AgentInputField_1.default, { 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
91
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "form-item", children: [parameter.label && (0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: parameter.label }), (0, jsx_runtime_1.jsx)(AgentInputField_1.default, { 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
92
92
  ? {
93
93
  endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { "data-testid": "runtime-submit-button", ref: submitRef, type: "submit", variant: "contained", loading: running, disabled: submitDisabled, sx: { borderRadius: 1.5 }, children: submitText }) })),
94
94
  }
@@ -73,7 +73,7 @@ const AgentList = (0, react_1.memo)((_a) => {
73
73
  const children = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = (0, runtime_output_schema_1.getOutputVariableInitialValue)(runtimeAgent, types_1.RuntimeOutputVariable.children)) === null || _a === void 0 ? void 0 : _a.agents) === null || _b === void 0 ? void 0 : _b.filter((i) => !!i.id); }, [runtimeAgent]);
74
74
  if (!(children === null || children === void 0 ? void 0 : children.length) || children.length <= 1)
75
75
  return null;
76
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ direction: "row", gap: 2, py: 1, overflow: "auto" }, props, { children: children === null || children === void 0 ? void 0 : children.map((child) => ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: child.id, children: (0, jsx_runtime_1.jsx)(AgentAvatar, { selected: activeAgentId === child.id, onClick: () => setActiveAgentId(child.id) }) }))) })));
76
+ return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ direction: "row", gap: 2, py: 1, overflow: "auto" }, props, { children: children === null || children === void 0 ? void 0 : children.map((child) => ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: child.id, children: (0, jsx_runtime_1.jsx)(AgentAvatar, { selected: activeAgentId === child.id, onClick: () => setActiveAgentId(child.id) }) }, child.id))) })));
77
77
  });
78
78
  function AgentAvatar(_a) {
79
79
  var _b;
@@ -39,11 +39,12 @@ const state_1 = require("./state");
39
39
  __exportStar(require("./state"), exports);
40
40
  const MAXIMUM_RENDER_STACK_SIZE = 20;
41
41
  function CustomComponentRenderer(_a) {
42
- var _b;
42
+ var _b, _c, _d;
43
43
  var { dev } = _a, props = __rest(_a, ["dev"]);
44
44
  const inheritedDev = (0, DevProvider_1.useDev)();
45
45
  const BuiltinComponent = BuiltinComponents[props.componentId];
46
- return ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: (props === null || props === void 0 ? void 0 : props.fallbackRender) || ErrorView, children: (0, jsx_runtime_1.jsx)(DevProvider_1.DevProvider, { dev: dev !== null && dev !== void 0 ? dev : inheritedDev, children: BuiltinComponent ? ((0, jsx_runtime_1.jsx)(BuiltinComponent, Object.assign({}, props))) : ((0, jsx_runtime_1.jsx)(ComponentRenderer, Object.assign({}, props, { instanceId: (_b = props.instanceId) !== null && _b !== void 0 ? _b : props.componentId }))) }) }));
46
+ 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;
47
+ return ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: (props === null || props === void 0 ? void 0 : props.fallbackRender) || ErrorView, resetKeys: [renderer && 'script' in renderer ? renderer.script : undefined], children: (0, jsx_runtime_1.jsx)(DevProvider_1.DevProvider, { dev: dev !== null && dev !== void 0 ? dev : inheritedDev, children: BuiltinComponent ? ((0, jsx_runtime_1.jsx)(BuiltinComponent, Object.assign({}, props))) : ((0, jsx_runtime_1.jsx)(ComponentRenderer, Object.assign({}, props, { instanceId: (_d = props.instanceId) !== null && _d !== void 0 ? _d : props.componentId }))) }) }));
47
48
  }
48
49
  const BuiltinComponents = {
49
50
  'blocklet-react-component': BlockletReactComponentRenderer_1.default,