@mastra/playground-ui 5.1.6-alpha.0 → 5.1.6-alpha.2

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.
package/dist/index.cjs.js CHANGED
@@ -8638,7 +8638,8 @@ const BooleanField = ({ field, label, id, inputProps, value }) => /* @__PURE__ *
8638
8638
  };
8639
8639
  inputProps.onChange(event);
8640
8640
  },
8641
- defaultChecked: field.default
8641
+ defaultChecked: field.default,
8642
+ disabled: inputProps.disabled || inputProps.readOnly
8642
8643
  }
8643
8644
  ),
8644
8645
  /* @__PURE__ */ jsxRuntime.jsxs(Txt, { as: "label", variant: "ui-sm", className: "text-icon3", htmlFor: id, children: [
@@ -9140,21 +9141,26 @@ const ShadcnUIComponents = {
9140
9141
  ArrayWrapper,
9141
9142
  ArrayElementWrapper
9142
9143
  };
9143
- const ShadcnAutoFormFieldComponents = {
9144
- string: StringField,
9145
- number: NumberField,
9146
- boolean: BooleanField,
9147
- date: DateField,
9148
- select: SelectField,
9149
- record: RecordField
9150
- };
9151
- function AutoForm({ uiComponents, formComponents, ...props }) {
9144
+ function AutoForm({
9145
+ uiComponents,
9146
+ formComponents,
9147
+ readOnly,
9148
+ ...props
9149
+ }) {
9152
9150
  return /* @__PURE__ */ jsxRuntime.jsx(
9153
9151
  react$3.AutoForm,
9154
9152
  {
9155
9153
  ...props,
9156
9154
  uiComponents: { ...ShadcnUIComponents, ...uiComponents },
9157
- formComponents: { ...ShadcnAutoFormFieldComponents, ...formComponents }
9155
+ formComponents: {
9156
+ string: (props2) => /* @__PURE__ */ jsxRuntime.jsx(StringField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
9157
+ number: (props2) => /* @__PURE__ */ jsxRuntime.jsx(NumberField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
9158
+ boolean: (props2) => /* @__PURE__ */ jsxRuntime.jsx(BooleanField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
9159
+ date: (props2) => /* @__PURE__ */ jsxRuntime.jsx(DateField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
9160
+ select: (props2) => /* @__PURE__ */ jsxRuntime.jsx(SelectField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
9161
+ record: (props2) => /* @__PURE__ */ jsxRuntime.jsx(RecordField, { ...props2, inputProps: { ...props2.inputProps, readOnly } }),
9162
+ ...formComponents
9163
+ }
9158
9164
  }
9159
9165
  );
9160
9166
  }
@@ -9251,7 +9257,8 @@ function DynamicForm({
9251
9257
  defaultValues,
9252
9258
  isSubmitLoading,
9253
9259
  submitButtonLabel,
9254
- className
9260
+ className,
9261
+ readOnly
9255
9262
  }) {
9256
9263
  if (!schema) {
9257
9264
  console.error("no form schema found");
@@ -9283,7 +9290,7 @@ function DynamicForm({
9283
9290
  },
9284
9291
  withSubmit: true
9285
9292
  };
9286
- return /* @__PURE__ */ jsxRuntime.jsx(AutoForm, { ...formProps });
9293
+ return /* @__PURE__ */ jsxRuntime.jsx(AutoForm, { ...formProps, readOnly });
9287
9294
  }
9288
9295
 
9289
9296
  function resolveSerializedZodOutput(obj) {
@@ -9962,9 +9969,55 @@ function WorkflowTrigger({
9962
9969
  ] });
9963
9970
  })
9964
9971
  ] }),
9965
- result && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-5 border-b-sm border-border1", children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowJsonDialog, { result: restResult }) })
9972
+ result && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-5 border-b-sm border-border1", children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowJsonDialog, { result: restResult }) }),
9973
+ result && /* @__PURE__ */ jsxRuntime.jsx(WorkflowResultSection, { result, workflow })
9966
9974
  ] });
9967
9975
  }
9976
+ const WorkflowResultSection = ({ result, workflow }) => {
9977
+ const workflowState = result.payload.workflowState;
9978
+ const hasResult = Object.keys(workflowState.steps || {}).length > 0;
9979
+ if (!hasResult) return null;
9980
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-5", children: [
9981
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3", children: "Final Output" }),
9982
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "pt-4", children: Object.entries(workflowState.steps || {}).map(([stepId, stepResult]) => {
9983
+ const stepDefinition = workflow.steps[stepId];
9984
+ if (!stepDefinition) return null;
9985
+ return /* @__PURE__ */ jsxRuntime.jsx(
9986
+ "li",
9987
+ {
9988
+ className: "border-b-sm border-dashed border-border1 last:border-b-0 py-4 first:pt-0 last:pb-0",
9989
+ children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowResultFinishedStep, { stepResult: stepResult.output, stepDefinition })
9990
+ },
9991
+ stepId
9992
+ );
9993
+ }) })
9994
+ ] });
9995
+ };
9996
+ const WorkflowResultFinishedStep = ({ stepResult, stepDefinition }) => {
9997
+ const id = React.useId();
9998
+ try {
9999
+ const zodObjectSchema = resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(stepDefinition.outputSchema)));
10000
+ if (zodObjectSchema?._def?.typeName === "ZodString") {
10001
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
10002
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10003
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Footprints, { className: "text-icon3" }) }),
10004
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "label", htmlFor: id, variant: "ui-sm", className: "text-icon3", children: stepDefinition.description || stepDefinition.id })
10005
+ ] }),
10006
+ /* @__PURE__ */ jsxRuntime.jsx(Input, { id, defaultValue: stepResult, readOnly: true })
10007
+ ] });
10008
+ }
10009
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10010
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 pb-2", children: [
10011
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Footprints, { className: "text-icon3" }) }),
10012
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3", children: stepDefinition.description || stepDefinition.id })
10013
+ ] }),
10014
+ /* @__PURE__ */ jsxRuntime.jsx(DynamicForm, { schema: zodObjectSchema, defaultValues: stepResult, readOnly: true })
10015
+ ] });
10016
+ } catch (err) {
10017
+ console.error("Error parsing output schema", err);
10018
+ return /* @__PURE__ */ jsxRuntime.jsx(Txt, { children: "An error occured. Please open an issue on GitHub." });
10019
+ }
10020
+ };
9968
10021
  const WorkflowJsonDialog = ({ result }) => {
9969
10022
  const [open, setOpen] = React.useState(false);
9970
10023
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [