@blocklet/pages-kit 0.2.363 → 0.2.364

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.
@@ -42,6 +42,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
42
42
  }, [agent.parameters]);
43
43
  const defaultForm = useInitialFormValues();
44
44
  const form = (0, react_hook_form_1.useForm)({ defaultValues: defaultForm });
45
+ const submitDisabled = !form.formState.isValid;
45
46
  (0, react_1.useEffect)(() => {
46
47
  if (autoFillLastForm && !form.formState.isSubmitted && !form.formState.isSubmitting) {
47
48
  form.reset(chatMode ? (0, omit_1.default)(defaultForm, 'question') : defaultForm);
@@ -62,7 +63,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
62
63
  return ((0, jsx_runtime_1.jsxs)(Form, { component: "form", className: (0, css_1.cx)('form', `label-position-${inlineLabel ? 'start' : 'top'}`), onSubmit: form.handleSubmit(onSubmit), children: [parameters === null || parameters === void 0 ? void 0 : parameters.map((parameter, index) => {
63
64
  const { key, required } = parameter !== null && parameter !== void 0 ? parameter : {};
64
65
  return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: form.control, name: key, rules: {
65
- required,
66
+ required: required || key === 'question',
66
67
  min: parameter.type === 'number' && typeof parameter.min === 'number'
67
68
  ? { value: parameter.min, message: '' }
68
69
  : undefined,
@@ -79,11 +80,11 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
79
80
  var _a;
80
81
  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, { 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
81
82
  ? {
82
- 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, { ref: submitRef, type: "submit", variant: "contained", loading: running, sx: { borderRadius: 1.5 }, children: submitText }) })),
83
+ 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, { ref: submitRef, type: "submit", variant: "contained", loading: running, disabled: submitDisabled, sx: { borderRadius: 1.5 }, children: submitText }) })),
83
84
  }
84
85
  : undefined })] }));
85
86
  } }) }, parameter.id));
86
- }), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { ref: submitRef, type: "submit", variant: "contained", loading: running, sx: { height: 40 }, children: submitText || t('generate') }))] }));
87
+ }), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { ref: submitRef, type: "submit", variant: "contained", loading: running, disabled: submitDisabled, sx: { height: 40 }, children: submitText || t('generate') }))] }));
87
88
  }
88
89
  function useInitialFormValues() {
89
90
  const { agent } = (0, CurrentAgent_1.useCurrentAgent)();