@mastra/playground-ui 4.0.0-alpha.5 → 4.0.0-alpha.7

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.
Files changed (47) hide show
  1. package/dist/components/dynamic-form/index.d.ts +2 -2
  2. package/dist/components/dynamic-form/utils.d.ts +0 -4
  3. package/dist/components/ui/alert.d.ts +8 -0
  4. package/dist/components/ui/autoform/AutoForm.d.ts +13 -0
  5. package/dist/components/ui/autoform/components/ArrayElementWrapper.d.ts +4 -0
  6. package/dist/components/ui/autoform/components/ArrayWrapper.d.ts +4 -0
  7. package/dist/components/ui/autoform/components/BooleanField.d.ts +4 -0
  8. package/dist/components/ui/autoform/components/DateField.d.ts +4 -0
  9. package/dist/components/ui/autoform/components/ErrorMessage.d.ts +5 -0
  10. package/dist/components/ui/autoform/components/FieldWrapper.d.ts +4 -0
  11. package/dist/components/ui/autoform/components/Form.d.ts +3 -0
  12. package/dist/components/ui/autoform/components/NumberField.d.ts +4 -0
  13. package/dist/components/ui/autoform/components/ObjectWrapper.d.ts +4 -0
  14. package/dist/components/ui/autoform/components/RecordField.d.ts +4 -0
  15. package/dist/components/ui/autoform/components/SelectField.d.ts +4 -0
  16. package/dist/components/ui/autoform/components/StringField.d.ts +4 -0
  17. package/dist/components/ui/autoform/components/SubmitButton.d.ts +5 -0
  18. package/dist/components/ui/autoform/index.d.ts +4 -0
  19. package/dist/components/ui/autoform/types.d.ts +5 -0
  20. package/dist/components/ui/autoform/utils.d.ts +1 -0
  21. package/dist/components/ui/autoform/zodProvider/field-type-inference.d.ts +4 -0
  22. package/dist/components/ui/autoform/zodProvider/index.d.ts +9 -0
  23. package/dist/components/ui/card.d.ts +8 -0
  24. package/dist/components/ui/checkbox.d.ts +4 -0
  25. package/dist/components/ui/date-picker.d.ts +2 -2
  26. package/dist/components/ui/form.d.ts +23 -0
  27. package/dist/components/ui/toggle.d.ts +12 -0
  28. package/dist/hooks/use-workflows.d.ts +0 -4
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.es.js +354 -897
  31. package/dist/index.es.js.map +1 -1
  32. package/package.json +12 -7
  33. package/dist/components/dynamic-form/default-field-map.d.ts +0 -16
  34. package/dist/components/dynamic-form/fields/array-field.d.ts +0 -17
  35. package/dist/components/dynamic-form/fields/boolean-field.d.ts +0 -12
  36. package/dist/components/dynamic-form/fields/creatable-field.d.ts +0 -17
  37. package/dist/components/dynamic-form/fields/date-field.d.ts +0 -12
  38. package/dist/components/dynamic-form/fields/enum-field.d.ts +0 -16
  39. package/dist/components/dynamic-form/fields/index.d.ts +0 -10
  40. package/dist/components/dynamic-form/fields/number-field.d.ts +0 -12
  41. package/dist/components/dynamic-form/fields/object-field.d.ts +0 -27
  42. package/dist/components/dynamic-form/fields/record-field.d.ts +0 -14
  43. package/dist/components/dynamic-form/fields/string-field.d.ts +0 -14
  44. package/dist/components/dynamic-form/fields/union-field.d.ts +0 -28
  45. package/dist/components/dynamic-form/resolvers/index.d.ts +0 -4
  46. package/dist/components/dynamic-form/schema-resolver.d.ts +0 -21
  47. package/dist/components/dynamic-form/schema.d.ts +0 -70
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { MessagePrimitive, ActionBarPrimitive, BranchPickerPrimitive, ThreadPrimitive, ComposerPrimitive, useExternalStoreRuntime, AssistantRuntimeProvider } from '@assistant-ui/react';
3
- import { CheckIcon, CopyIcon, ChevronUpIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, Braces, Clock1, ChevronDown, XIcon, Check, LoaderCircle, ExternalLinkIcon, X, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, Plus, CalendarIcon, Loader2 } from 'lucide-react';
3
+ import { CheckIcon, CopyIcon, ChevronUpIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, Braces, Clock1, ChevronDown, XIcon, Check, LoaderCircle, ExternalLinkIcon, X, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, PlusIcon, TrashIcon, Plus, Loader2 } from 'lucide-react';
4
4
  import * as React from 'react';
5
5
  import React__default, { forwardRef, memo, useState, useRef, useEffect, createContext, useContext, useMemo, useCallback, Suspense, Fragment as Fragment$1 } from 'react';
6
6
  import { Slot } from '@radix-ui/react-slot';
@@ -32,18 +32,16 @@ import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
32
32
  import * as DialogPrimitive from '@radix-ui/react-dialog';
33
33
  import jsonSchemaToZod from 'json-schema-to-zod';
34
34
  import { parse } from 'superjson';
35
- import * as z from 'zod';
36
- import { z as z$1, ZodNumber, ZodBoolean, ZodDate, ZodLiteral, ZodEnum, ZodArray, ZodUnion } from 'zod';
37
- import { zodResolver } from '@hookform/resolvers/zod';
38
- import { useFieldArray, Controller, useWatch, useForm } from 'react-hook-form';
39
- import * as SwitchPrimitives from '@radix-ui/react-switch';
40
- import { Command as Command$1 } from 'cmdk';
41
- import * as PopoverPrimitive from '@radix-ui/react-popover';
35
+ import z$1, { z } from 'zod';
36
+ import { AutoForm as AutoForm$1, buildZodFieldConfig } from '@autoform/react';
37
+ import * as LabelPrimitive from '@radix-ui/react-label';
38
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
42
39
  import { useDebouncedCallback } from 'use-debounce';
43
40
  import { DayPicker } from 'react-day-picker';
41
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
44
42
  import * as SelectPrimitive from '@radix-ui/react-select';
45
- import * as LabelPrimitive from '@radix-ui/react-label';
46
43
  import { v4 } from '@lukeed/uuid';
44
+ import { ZodProvider, getFieldConfigInZodStack, getDefaultValueInZodStack } from '@autoform/zod';
47
45
  import { CodeBlock as CodeBlock$1 } from 'react-code-block';
48
46
 
49
47
  import './index.css';function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
@@ -2811,7 +2809,7 @@ const buttonVariants = cva(
2811
2809
  variant: {
2812
2810
  default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
2813
2811
  destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
2814
- outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
2812
+ outline: "border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground",
2815
2813
  secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
2816
2814
  ghost: "hover:bg-accent hover:text-accent-foreground",
2817
2815
  link: "text-primary underline-offset-4 hover:underline"
@@ -5854,18 +5852,6 @@ const useExecuteWorkflow = (baseUrl) => {
5854
5852
  const client = new MastraClient({
5855
5853
  baseUrl: baseUrl || ""
5856
5854
  });
5857
- const executeWorkflow = async ({ workflowId, input }) => {
5858
- try {
5859
- setIsExecutingWorkflow(true);
5860
- const response = await client.getWorkflow(workflowId).execute(input || {});
5861
- return response;
5862
- } catch (error) {
5863
- console.error("Error executing workflow:", error);
5864
- throw error;
5865
- } finally {
5866
- setIsExecutingWorkflow(false);
5867
- }
5868
- };
5869
5855
  const createWorkflowRun = async ({ workflowId, prevRunId }) => {
5870
5856
  try {
5871
5857
  const workflow = client.getWorkflow(workflowId);
@@ -5885,7 +5871,7 @@ const useExecuteWorkflow = (baseUrl) => {
5885
5871
  throw error;
5886
5872
  }
5887
5873
  };
5888
- return { executeWorkflow, startWorkflowRun, createWorkflowRun, isExecutingWorkflow };
5874
+ return { startWorkflowRun, createWorkflowRun, isExecutingWorkflow };
5889
5875
  };
5890
5876
  const useWatchWorkflow = (baseUrl) => {
5891
5877
  const [isWatchingWorkflow, setIsWatchingWorkflow] = useState(false);
@@ -5897,7 +5883,7 @@ const useWatchWorkflow = (baseUrl) => {
5897
5883
  baseUrl
5898
5884
  });
5899
5885
  const workflow = client.getWorkflow(workflowId);
5900
- workflow.watch({ runId }, (record) => {
5886
+ await workflow.watch({ runId }, (record) => {
5901
5887
  setWatchResult(record);
5902
5888
  });
5903
5889
  } catch (error) {
@@ -6703,9 +6689,6 @@ const lodashTitleCase = (str) => {
6703
6689
  const camelCased = str.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "").replace(/^(.)/, (char) => char.toLowerCase());
6704
6690
  return camelCased.replace(/([A-Z])/g, " $1").replace(/^./, (str2) => str2.toUpperCase()).trim();
6705
6691
  };
6706
- const toTitleCase = (str, splitChar = " ") => {
6707
- return str.split(splitChar).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
6708
- };
6709
6692
 
6710
6693
  function WorkflowGraph({ workflowId, baseUrl }) {
6711
6694
  const { workflow, isLoading } = useWorkflow(workflowId, baseUrl);
@@ -6770,249 +6753,130 @@ const WorkflowsTable = ({
6770
6753
  );
6771
6754
  };
6772
6755
 
6773
- const transformToNestObject = (error) => {
6774
- const fieldErrors = {};
6775
- error.errors.forEach((err) => {
6776
- if (err.path.length > 0) {
6777
- const path = err.path.join(".");
6778
- fieldErrors[path] = {
6779
- type: "validation",
6780
- message: err.message
6781
- };
6782
- }
6783
- });
6784
- return fieldErrors;
6785
- };
6786
- function resolveSerializedZodOutput(obj) {
6787
- return Function("z", `"use strict";return (${obj});`)(z$1);
6788
- }
6756
+ const Form = React__default.forwardRef(({ children, ...props }, ref) => {
6757
+ return /* @__PURE__ */ jsx("form", { ref, className: "space-y-4", ...props, children });
6758
+ });
6789
6759
 
6790
- const customZodUnionResolver = (schemaUnion, discriminator) => {
6791
- return async (values) => {
6792
- const schema = schemaUnion?._def?.options?.find(
6793
- (option) => option?.shape?.[discriminator]?._def?.value === values[discriminator]
6794
- ) || z$1.object({ [discriminator]: z$1.string() });
6795
- const filteredValues = Object.fromEntries(Object.entries(values).filter(([key]) => schema?.shape?.[key]));
6796
- const result = schema.safeParse(filteredValues);
6797
- if (result.success) {
6798
- return { values: result.data, errors: {} };
6799
- } else {
6800
- const errors = transformToNestObject(result.error);
6801
- return { values: {}, errors };
6802
- }
6803
- };
6804
- };
6760
+ const labelVariants = cva("text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
6761
+ const Label = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(LabelPrimitive.Root, { ref, className: cn(labelVariants(), className), ...props }));
6762
+ Label.displayName = LabelPrimitive.Root.displayName;
6805
6763
 
6806
- function ArrayField({ name, control, renderField, isStringField }) {
6807
- const { fields, append, remove } = useFieldArray({
6808
- control,
6809
- name
6810
- });
6811
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2 w-full", children: [
6812
- fields.map((field, index) => /* @__PURE__ */ jsxs("div", { className: "relative w-full flex items-center gap-2", children: [
6813
- renderField({ fieldName: `${name}.${index}`, index }),
6814
- /* @__PURE__ */ jsx(
6815
- Button,
6816
- {
6817
- type: "button",
6818
- variant: "ghost",
6819
- size: "icon",
6820
- className: "absolute -right-2 -top-2",
6821
- onClick: () => remove(index),
6822
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
6823
- }
6824
- )
6825
- ] }, field.id)),
6826
- /* @__PURE__ */ jsxs(
6827
- Button,
6828
- {
6829
- type: "button",
6830
- variant: "outline",
6831
- size: "sm",
6832
- className: "w-full",
6833
- onClick: () => append(isStringField ? { root: "" } : {}),
6834
- children: [
6835
- /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
6836
- "Add Item"
6837
- ]
6838
- }
6839
- )
6764
+ const DISABLED_LABELS = ["boolean", "object", "array"];
6765
+ const FieldWrapper = ({ label, children, id, field, error }) => {
6766
+ const isDisabled = DISABLED_LABELS.includes(field.type);
6767
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
6768
+ !isDisabled && /* @__PURE__ */ jsxs(Label, { htmlFor: id, children: [
6769
+ label,
6770
+ field.required && /* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
6771
+ ] }),
6772
+ children,
6773
+ field.fieldConfig?.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: field.fieldConfig.description }),
6774
+ error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error })
6840
6775
  ] });
6841
- }
6776
+ };
6842
6777
 
6843
- const Switch = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
6844
- SwitchPrimitives.Root,
6778
+ const alertVariants = cva(
6779
+ "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
6845
6780
  {
6846
- className: cn(
6847
- "peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-mastra-bg-7 data-[state=unchecked]:bg-input",
6848
- className
6849
- ),
6850
- ...props,
6851
- ref,
6852
- children: /* @__PURE__ */ jsx(
6853
- SwitchPrimitives.Thumb,
6854
- {
6855
- className: cn(
6856
- "pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
6857
- )
6781
+ variants: {
6782
+ variant: {
6783
+ default: "bg-background text-foreground",
6784
+ destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"
6858
6785
  }
6859
- )
6786
+ },
6787
+ defaultVariants: {
6788
+ variant: "default"
6789
+ }
6860
6790
  }
6861
- ));
6862
- Switch.displayName = SwitchPrimitives.Root.displayName;
6791
+ );
6792
+ const Alert = React.forwardRef(({ className, variant, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, role: "alert", className: cn(alertVariants({ variant }), className), ...props }));
6793
+ Alert.displayName = "Alert";
6794
+ const AlertTitle = React.forwardRef(
6795
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("h5", { ref, className: cn("mb-1 font-medium leading-none tracking-tight", className), ...props })
6796
+ );
6797
+ AlertTitle.displayName = "AlertTitle";
6798
+ const AlertDescription = React.forwardRef(
6799
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("text-sm [&_p]:leading-relaxed", className), ...props })
6800
+ );
6801
+ AlertDescription.displayName = "AlertDescription";
6863
6802
 
6864
- function BooleanField({ name, control, handleFieldChange }) {
6803
+ const ErrorMessage = ({ error }) => /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
6804
+ /* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
6805
+ /* @__PURE__ */ jsx(AlertTitle, { children: error })
6806
+ ] });
6807
+
6808
+ const SubmitButton = ({ children }) => /* @__PURE__ */ jsx(Button, { type: "submit", children });
6809
+
6810
+ const StringField = ({ inputProps, error, id }) => {
6811
+ const { key, ...props } = inputProps;
6812
+ return /* @__PURE__ */ jsx(Input, { id, className: error ? "border-destructive" : "", ...props });
6813
+ };
6814
+
6815
+ const NumberField = ({ inputProps, error, id }) => {
6816
+ const { key, ...props } = inputProps;
6865
6817
  return /* @__PURE__ */ jsx(
6866
- Controller,
6818
+ Input,
6867
6819
  {
6868
- name,
6869
- control,
6870
- render: ({ field }) => /* @__PURE__ */ jsx(
6871
- Switch,
6872
- {
6873
- checked: field.value,
6874
- onCheckedChange: (checked) => {
6875
- field.onChange(checked);
6876
- handleFieldChange?.({ key: name, value: checked });
6877
- }
6820
+ id,
6821
+ type: "number",
6822
+ className: error ? "border-destructive" : "",
6823
+ ...props,
6824
+ onChange: (e) => {
6825
+ const value = e.target.value;
6826
+ if (value !== "" && !isNaN(Number(value))) {
6827
+ props.onChange({
6828
+ target: { value, name: inputProps.name }
6829
+ });
6878
6830
  }
6879
- )
6831
+ },
6832
+ onBlur: (e) => {
6833
+ const value = e.target.value;
6834
+ if (value !== "" && !isNaN(Number(value))) {
6835
+ props.onChange({
6836
+ target: { value: Number(value), name: inputProps.name }
6837
+ });
6838
+ }
6839
+ }
6880
6840
  }
6881
6841
  );
6882
- }
6842
+ };
6883
6843
 
6884
- const Command = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
6885
- Command$1,
6886
- {
6887
- ref,
6888
- className: cn(
6889
- "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
6890
- className
6891
- ),
6892
- ...props
6893
- }
6894
- ));
6895
- Command.displayName = Command$1.displayName;
6896
- const CommandInput = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: [
6897
- /* @__PURE__ */ jsx(Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
6898
- /* @__PURE__ */ jsx(
6899
- Command$1.Input,
6900
- {
6901
- ref,
6902
- className: cn(
6903
- "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
6904
- className
6905
- ),
6906
- ...props
6907
- }
6908
- )
6909
- ] }));
6910
- CommandInput.displayName = Command$1.Input.displayName;
6911
- const CommandList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
6912
- Command$1.List,
6913
- {
6914
- ref,
6915
- className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className),
6916
- ...props
6917
- }
6918
- ));
6919
- CommandList.displayName = Command$1.List.displayName;
6920
- const CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(Command$1.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
6921
- CommandEmpty.displayName = Command$1.Empty.displayName;
6922
- const CommandGroup = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
6923
- Command$1.Group,
6844
+ const Checkbox = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
6845
+ CheckboxPrimitive.Root,
6924
6846
  {
6925
6847
  ref,
6926
6848
  className: cn(
6927
- "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
6849
+ "peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
6928
6850
  className
6929
6851
  ),
6930
- ...props
6931
- }
6932
- ));
6933
- CommandGroup.displayName = Command$1.Group.displayName;
6934
- const CommandSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Command$1.Separator, { ref, className: cn("-mx-1 h-px bg-border", className), ...props }));
6935
- CommandSeparator.displayName = Command$1.Separator.displayName;
6936
- const CommandItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
6937
- Command$1.Item,
6938
- {
6939
- ref,
6940
- className: cn(
6941
- "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
6942
- className
6943
- ),
6944
- ...props
6852
+ ...props,
6853
+ children: /* @__PURE__ */ jsx(CheckboxPrimitive.Indicator, { className: cn("flex items-center justify-center text-current"), children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) })
6945
6854
  }
6946
6855
  ));
6947
- CommandItem.displayName = Command$1.Item.displayName;
6856
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName;
6948
6857
 
6949
- const Popover = PopoverPrimitive.Root;
6950
- const PopoverTrigger = PopoverPrimitive.Trigger;
6951
- const PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
6952
- PopoverPrimitive.Content,
6953
- {
6954
- ref,
6955
- align,
6956
- sideOffset,
6957
- className: cn(
6958
- "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
6959
- className
6960
- ),
6961
- ...props
6962
- }
6963
- ) }));
6964
- PopoverContent.displayName = PopoverPrimitive.Content.displayName;
6965
-
6966
- function CreatableField({ name, control, options = [], handleFieldChange, placeholder }) {
6967
- const [openPopover, setOpenPopover] = React.useState(false);
6968
- const [inputValue, setInputValue] = React.useState("");
6969
- return /* @__PURE__ */ jsx(
6970
- Controller,
6858
+ const BooleanField = ({ field, label, id, inputProps }) => /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
6859
+ /* @__PURE__ */ jsx(
6860
+ Checkbox,
6971
6861
  {
6972
- name,
6973
- control,
6974
- render: ({ field }) => {
6975
- const selectedValues = field.value || [];
6976
- const removeValue = (valueToRemove) => {
6977
- const newValues = selectedValues.filter((v) => v !== valueToRemove);
6978
- field.onChange(newValues);
6979
- handleFieldChange?.({ key: name, value: newValues });
6980
- };
6981
- const addValue = (value) => {
6982
- if (!value) return;
6983
- const newValues = [...selectedValues, value];
6984
- field.onChange(newValues);
6985
- handleFieldChange?.({ key: name, value: newValues });
6986
- setInputValue("");
6987
- setOpenPopover(false);
6862
+ id,
6863
+ onCheckedChange: (checked) => {
6864
+ const event = {
6865
+ target: {
6866
+ name: field.key,
6867
+ value: checked
6868
+ }
6988
6869
  };
6989
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
6990
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: selectedValues.map((value) => /* @__PURE__ */ jsxs(Badge, { className: "flex items-center gap-1", children: [
6991
- value,
6992
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-4 w-4 p-0", onClick: () => removeValue(value), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
6993
- ] }, value)) }),
6994
- /* @__PURE__ */ jsxs(Popover, { open: openPopover, onOpenChange: setOpenPopover, children: [
6995
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "w-full justify-start", children: [
6996
- /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
6997
- placeholder || "Add item"
6998
- ] }) }),
6999
- /* @__PURE__ */ jsx(PopoverContent, { className: "p-0", align: "start", children: /* @__PURE__ */ jsxs(Command, { children: [
7000
- /* @__PURE__ */ jsx(CommandInput, { placeholder: "Enter value...", value: inputValue, onValueChange: setInputValue }),
7001
- /* @__PURE__ */ jsx(CommandList, { children: /* @__PURE__ */ jsxs(CommandGroup, { children: [
7002
- options.filter((opt) => !selectedValues.includes(opt.value)).map((option) => /* @__PURE__ */ jsx(CommandItem, { onSelect: () => addValue(option.value), children: option.label }, option.value)),
7003
- inputValue && /* @__PURE__ */ jsxs(CommandItem, { onSelect: () => addValue(inputValue), children: [
7004
- 'Create "',
7005
- inputValue,
7006
- '"'
7007
- ] })
7008
- ] }) })
7009
- ] }) })
7010
- ] })
7011
- ] });
7012
- }
6870
+ inputProps.onChange(event);
6871
+ },
6872
+ checked: inputProps.value
7013
6873
  }
7014
- );
7015
- }
6874
+ ),
6875
+ /* @__PURE__ */ jsxs(Label, { htmlFor: id, children: [
6876
+ label,
6877
+ field.required && /* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" })
6878
+ ] })
6879
+ ] });
7016
6880
 
7017
6881
  function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
7018
6882
  return /* @__PURE__ */ jsx(
@@ -7023,50 +6887,47 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
7023
6887
  classNames: {
7024
6888
  months: "flex flex-col space-y-4 sm:space-y-0",
7025
6889
  month: "space-y-4",
7026
- month_caption: "flex justify-center pt-1 relative items-center",
6890
+ // month_caption: 'flex justify-center pt-1 relative items-center',
7027
6891
  caption_label: "text-sm text-text font-medium",
7028
6892
  nav: "space-x-1 flex items-center",
7029
- button_previous: cn(
6893
+ nav_button_previous: cn(
7030
6894
  buttonVariants({ variant: "outline" }),
7031
6895
  "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
7032
6896
  "absolute left-4 top-[56px] z-10"
7033
6897
  ),
7034
- button_next: cn(
6898
+ nav_button_next: cn(
7035
6899
  buttonVariants({ variant: "outline" }),
7036
6900
  "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
7037
6901
  "absolute right-4 top-[56px] z-10"
7038
6902
  ),
7039
- month_grid: "w-full border-collapse space-y-1",
7040
- weekdays: "flex",
7041
- weekday: "text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
7042
- week: "flex w-full mt-2",
6903
+ dropdown_month: "w-full border-collapse space-y-1",
6904
+ weeknumber: "flex",
7043
6905
  day: cn(
7044
6906
  buttonVariants({ variant: "ghost" }),
7045
6907
  "relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",
7046
6908
  props.mode === "range" ? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md" : "[&:has([aria-selected])]:rounded-md",
7047
6909
  "h-8 w-8 p-0 hover:bg-lightGray-7/50 font-normal aria-selected:opacity-100"
7048
6910
  ),
7049
- range_start: "day-range-start",
7050
- range_end: "day-range-end",
7051
- selected: "!bg-primary !text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
7052
- today: "bg-lightGray-7/50 text-accent-foreground",
7053
- outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
7054
- disabled: "text-muted-foreground opacity-50",
7055
- range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
7056
- hidden: "invisible",
6911
+ day_range_start: "day-range-start",
6912
+ day_range_end: "day-range-end",
6913
+ day_selected: "!bg-primary !text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
6914
+ day_today: "bg-lightGray-7/50 text-accent-foreground",
6915
+ day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
6916
+ day_disabled: "text-muted-foreground opacity-50",
6917
+ day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
6918
+ day_hidden: "invisible",
7057
6919
  ...classNames
7058
6920
  },
7059
6921
  components: {
7060
- Chevron: ({ orientation }) => /* @__PURE__ */ jsx(
7061
- CalendarIcon,
7062
- {
7063
- className: cn("h-4 w-4", {
7064
- "rotate-180": orientation === "up",
7065
- "rotate-90": orientation === "left",
7066
- "-rotate-90": orientation === "right"
7067
- })
7068
- }
7069
- )
6922
+ // IconDropdown: ({ }) => (
6923
+ // <CalendarIcon
6924
+ // className={cn('h-4 w-4', {
6925
+ // 'rotate-180': orientation === 'up',
6926
+ // 'rotate-90': orientation === 'left',
6927
+ // '-rotate-90': orientation === 'right',
6928
+ // })}
6929
+ // />
6930
+ // ),
7070
6931
  },
7071
6932
  ...props
7072
6933
  }
@@ -7074,6 +6935,23 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
7074
6935
  }
7075
6936
  Calendar.displayName = "Calendar";
7076
6937
 
6938
+ const Popover = PopoverPrimitive.Root;
6939
+ const PopoverTrigger = PopoverPrimitive.Trigger;
6940
+ const PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
6941
+ PopoverPrimitive.Content,
6942
+ {
6943
+ ref,
6944
+ align,
6945
+ sideOffset,
6946
+ className: cn(
6947
+ "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
6948
+ className
6949
+ ),
6950
+ ...props
6951
+ }
6952
+ ) }));
6953
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
6954
+
7077
6955
  const DatePicker = ({
7078
6956
  value,
7079
6957
  setValue,
@@ -7228,26 +7106,28 @@ const DefaultButton = React.forwardRef(
7228
7106
  );
7229
7107
  DefaultButton.displayName = "DefaultButton";
7230
7108
 
7231
- function DateField({ name, control, handleFieldChange }) {
7109
+ const DateField = ({ inputProps, error, id }) => {
7110
+ const { key, ...props } = inputProps;
7111
+ const [value, setValue] = useState(null);
7232
7112
  return /* @__PURE__ */ jsx(
7233
- Controller,
7113
+ DatePicker,
7234
7114
  {
7235
- name,
7236
- control,
7237
- render: ({ field }) => /* @__PURE__ */ jsx(
7238
- DatePicker,
7239
- {
7240
- value: field.value,
7241
- setValue: (date) => {
7242
- const newDate = date ? new Date(date).toISOString() : date;
7243
- field.onChange(newDate);
7244
- handleFieldChange?.({ key: name, value: newDate });
7245
- }
7115
+ id,
7116
+ className: error ? "border-destructive" : "",
7117
+ value,
7118
+ setValue: (date) => {
7119
+ const newDate = date ? new Date(date).toISOString() : date;
7120
+ if (newDate) {
7121
+ props.onChange({
7122
+ target: { value: newDate?.toString(), name: inputProps.name }
7123
+ });
7124
+ setValue(new Date(newDate));
7246
7125
  }
7247
- )
7126
+ },
7127
+ clearable: true
7248
7128
  }
7249
7129
  );
7250
- }
7130
+ };
7251
7131
 
7252
7132
  const Select = SelectPrimitive.Root;
7253
7133
  const SelectValue = SelectPrimitive.Value;
@@ -7308,346 +7188,69 @@ const SelectItem = React.forwardRef(({ className, children, ...props }, ref) =>
7308
7188
  ));
7309
7189
  SelectItem.displayName = SelectPrimitive.Item.displayName;
7310
7190
 
7311
- function EnumField({ name, control, options, handleFieldChange }) {
7312
- return /* @__PURE__ */ jsx(
7313
- Controller,
7314
- {
7315
- name,
7316
- control,
7317
- render: ({ field }) => /* @__PURE__ */ jsxs(
7318
- Select,
7319
- {
7320
- value: field.value,
7321
- onValueChange: (value) => {
7322
- field.onChange(value);
7323
- handleFieldChange?.({ key: name, value });
7324
- },
7325
- children: [
7326
- /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select an option" }) }),
7327
- /* @__PURE__ */ jsx(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, className: "text-white", children: option.label }, option.value)) })
7328
- ]
7329
- }
7330
- )
7331
- }
7332
- );
7333
- }
7334
-
7335
- const Textarea = React.forwardRef(({ className, ...props }, ref) => {
7336
- return /* @__PURE__ */ jsx(
7337
- "textarea",
7338
- {
7339
- className: cn(
7340
- "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
7341
- className
7342
- ),
7343
- ref,
7344
- ...props
7345
- }
7346
- );
7347
- });
7348
- Textarea.displayName = "Textarea";
7349
-
7350
- function StringField({ name, control, handleFieldChange, isMultiline, placeholder }) {
7351
- const Component = isMultiline ? Textarea : Input;
7352
- return /* @__PURE__ */ jsx(
7353
- Controller,
7191
+ const SelectField = ({ field, inputProps, error, id }) => {
7192
+ const { key, ...props } = inputProps;
7193
+ return /* @__PURE__ */ jsxs(
7194
+ Select,
7354
7195
  {
7355
- name,
7356
- control,
7357
- render: ({ field }) => /* @__PURE__ */ jsx(
7358
- Component,
7359
- {
7360
- ...field,
7361
- className: "w-full",
7362
- placeholder,
7363
- onChange: (e) => {
7364
- field.onChange(e);
7365
- handleFieldChange?.({ key: name, value: e.target.value });
7196
+ ...props,
7197
+ onValueChange: (value) => {
7198
+ const syntheticEvent = {
7199
+ target: {
7200
+ value,
7201
+ name: field.key
7366
7202
  }
7367
- }
7368
- )
7203
+ };
7204
+ props.onChange(syntheticEvent);
7205
+ },
7206
+ defaultValue: field.default,
7207
+ children: [
7208
+ /* @__PURE__ */ jsx(SelectTrigger, { id, className: error ? "border-destructive" : "", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select an option" }) }),
7209
+ /* @__PURE__ */ jsx(SelectContent, { children: (field.options || []).map(([key2, label]) => /* @__PURE__ */ jsx(SelectItem, { value: key2, children: label }, key2)) })
7210
+ ]
7369
7211
  }
7370
7212
  );
7371
- }
7372
-
7373
- const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
7374
- const Label = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(LabelPrimitive.Root, { ref, className: cn(labelVariants(), className), ...props }));
7375
- Label.displayName = LabelPrimitive.Root.displayName;
7213
+ };
7376
7214
 
7377
- const getPath = (object, path) => {
7378
- if (typeof path === "string") {
7379
- path = path?.split(".");
7380
- }
7381
- return path?.reduce((obj, key) => obj && obj[key] !== void 0 ? obj[key] : void 0, object);
7215
+ const ObjectWrapper = ({ label, children }) => {
7216
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4 border p-2 rounded-md", children: [
7217
+ label === "​" ? /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsx("h3", { className: "text-sm font-medium", children: label }),
7218
+ children
7219
+ ] });
7382
7220
  };
7383
- const flattenObject = (object, endKeys = [], flattenArrayValue) => {
7384
- let newObj = {};
7385
- function recurseDip(obj, path) {
7386
- for (const [key, value] of Object.entries(obj)) {
7387
- let newPath = [...path, key];
7388
- if (value && value.constructor === Object) {
7389
- const hasOnlyEndKeys = endKeys?.length ? endKeys.every((v) => Object.keys(value).includes(v)) : false;
7390
- if (hasOnlyEndKeys) {
7391
- newObj = { ...newObj, [newPath.join(".")]: value };
7392
- } else {
7393
- recurseDip(value, newPath);
7394
- }
7395
- } else if (Array.isArray(value)) {
7396
- const contructValue = value.reduce((a, b) => ({ ...a, [value.indexOf(b)]: b }), {});
7397
- recurseDip(contructValue, newPath);
7398
- } else {
7399
- newObj = { ...newObj, [newPath.join(".")]: value };
7221
+
7222
+ const ArrayWrapper = ({ label, children, onAddItem }) => {
7223
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
7224
+ /* @__PURE__ */ jsx("h3", { className: "text-sm font-medium", children: label }),
7225
+ children,
7226
+ /* @__PURE__ */ jsx(
7227
+ Button,
7228
+ {
7229
+ className: "w-full flex items-center justify-center",
7230
+ onClick: onAddItem,
7231
+ variant: "outline",
7232
+ size: "sm",
7233
+ type: "button",
7234
+ children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4" })
7400
7235
  }
7401
- }
7402
- }
7403
- recurseDip(object, []);
7404
- return newObj;
7236
+ )
7237
+ ] });
7405
7238
  };
7406
7239
 
7407
- var FormConfigType = /* @__PURE__ */ ((FormConfigType2) => {
7408
- FormConfigType2["STRING"] = "STRING";
7409
- FormConfigType2["NUMBER"] = "NUMBER";
7410
- FormConfigType2["DATE"] = "DATE";
7411
- FormConfigType2["ENUM"] = "ENUM";
7412
- FormConfigType2["ARRAY"] = "ARRAY";
7413
- FormConfigType2["BOOLEAN"] = "BOOLEAN";
7414
- FormConfigType2["RECORD"] = "RECORD";
7415
- FormConfigType2["OBJECT"] = "OBJECT";
7416
- FormConfigType2["UNION"] = "UNION";
7417
- FormConfigType2["CREATABLE"] = "CREATABLE";
7418
- FormConfigType2["SELECT"] = "SELECT";
7419
- FormConfigType2["MULTI_SELECT"] = "MULTI_SELECT";
7420
- return FormConfigType2;
7421
- })(FormConfigType || {});
7422
- function getFormConfigTypesFromSchemaDef({
7423
- schema,
7424
- isOptional = false
7425
- }) {
7426
- if (schema instanceof z$1.ZodObject) {
7427
- return { type: "OBJECT" /* OBJECT */, isOptional };
7428
- }
7429
- if (schema instanceof z$1.ZodString) {
7430
- if (schema instanceof z$1.ZodString && schema._def.checks.some((check) => check.kind === "datetime")) {
7431
- return { type: "DATE" /* DATE */, isOptional };
7432
- }
7433
- return { type: "STRING" /* STRING */, isOptional };
7434
- } else if (schema instanceof ZodNumber) {
7435
- return { type: "NUMBER" /* NUMBER */, isOptional };
7436
- } else if (schema instanceof ZodBoolean) {
7437
- return { type: "BOOLEAN" /* BOOLEAN */, isOptional };
7438
- } else if (schema instanceof ZodDate) {
7439
- return { type: "DATE" /* DATE */, isOptional };
7440
- } else if (schema instanceof ZodLiteral) {
7441
- return {
7442
- type: "ENUM" /* ENUM */,
7443
- isOptional,
7444
- options: [{ label: schema.value, value: schema.value }]
7445
- };
7446
- } else if (schema instanceof ZodEnum) {
7447
- return {
7448
- type: "ENUM" /* ENUM */,
7449
- isOptional,
7450
- options: schema.options.map((v) => ({ label: v, value: v }))
7451
- };
7452
- } else if (schema instanceof ZodArray) {
7453
- return {
7454
- type: "ARRAY" /* ARRAY */,
7455
- isOptional,
7456
- options: schema.element instanceof ZodEnum ? schema.element.options.map((v) => ({ label: v, value: v })) : []
7457
- };
7458
- } else if (schema instanceof z$1.ZodOptional || schema instanceof z$1.ZodDefault) {
7459
- return getFormConfigTypesFromSchemaDef({ schema: schema._def.innerType, isOptional: true });
7460
- } else if (schema instanceof z$1.ZodEffects) {
7461
- return getFormConfigTypesFromSchemaDef({ schema: schema._def.schema, isOptional });
7462
- } else if (schema instanceof z$1.ZodRecord) {
7463
- return {
7464
- type: "RECORD" /* RECORD */,
7465
- isOptional,
7466
- innerSchema: schema._def.valueType
7467
- };
7468
- } else {
7469
- return { type: "STRING" /* STRING */, isOptional };
7470
- }
7471
- }
7472
- function schemaToFormFieldRenderer({
7473
- schema,
7474
- errors,
7475
- renderFieldMap,
7476
- schemaField,
7477
- renderLabel,
7478
- control,
7479
- variables,
7480
- onFieldChange,
7481
- schemaOptions,
7482
- values,
7483
- isOptional = false,
7484
- isNullable = false
7485
- }) {
7486
- const fieldConfig = getFormConfigTypesFromSchemaDef({ schema, isOptional });
7487
- const parentFieldValue = schemaOptions?.parentField ? getPath(values, schemaOptions?.parentField) : "";
7488
- if (schemaOptions?.parentField && !parentFieldValue) {
7489
- return null;
7490
- }
7491
- if (!renderFieldMap) return;
7492
- const flattenedErrors = flattenObject(errors, ["message", "type"]);
7493
- const fieldOptions = schemaOptions?.parentField ? schemaOptions?.options?.[parentFieldValue] : schemaOptions?.options || fieldConfig.options;
7494
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 mt-3 w-full", children: [
7495
- renderLabel ? renderLabel({ isOptional: Boolean(fieldConfig.isOptional), schemaField }) : /* @__PURE__ */ jsxs(Label, { className: "flex gap-0.5 capitalize", htmlFor: schemaField, "aria-required": !fieldConfig.isOptional, children: [
7496
- !fieldConfig?.isOptional && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" }),
7497
- /* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: toTitleCase(schemaField.split(".").pop() || "") })
7498
- ] }),
7499
- renderFieldMap[fieldConfig.type]({
7500
- name: schemaField,
7501
- options: fieldOptions,
7502
- control,
7503
- variables,
7504
- innerSchema: fieldConfig.innerSchema,
7505
- handleFieldChange: onFieldChange,
7506
- isNullable
7507
- }),
7508
- flattenedErrors?.[schemaField] ? /* @__PURE__ */ jsx(Text, { size: "xs", className: "text-red-500", children: flattenedErrors[schemaField]?.message }) : null
7509
- ] }, schemaField);
7510
- }
7511
-
7512
- function UnionField({
7513
- renderDynamicForm,
7514
- schema,
7515
- handleFieldChange,
7516
- control,
7517
- formValues,
7518
- errors,
7519
- parentField,
7520
- action,
7521
- isOptional = false,
7522
- isNullable = false,
7523
- depth
7524
- }) {
7525
- const fieldConfig = getFormConfigTypesFromSchemaDef({ schema, isOptional });
7526
- if (schema instanceof ZodUnion) {
7527
- const schemaOptions = schema.options;
7528
- return /* @__PURE__ */ jsxs("div", { children: [
7529
- /* @__PURE__ */ jsxs(Label, { className: "flex gap-0.5 capitalize mb-2", htmlFor: parentField, "aria-required": !fieldConfig.isOptional, children: [
7530
- !fieldConfig?.isOptional && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" }),
7531
- /* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: toTitleCase(parentField) })
7532
- ] }),
7533
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", children: schemaOptions.map((schemaOption, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
7534
- index >= 1 && /* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3 text-center", size: "xs", children: "or" }),
7535
- /* @__PURE__ */ jsx("div", { className: "ring-1 ring-white/10 p-2 rounded-md relative", children: renderDynamicForm({
7536
- schema: schemaOption,
7537
- handleFieldChange,
7538
- control,
7539
- formValues,
7540
- errors,
7541
- parentField,
7542
- action,
7543
- isOptional,
7544
- isNullable,
7545
- depth
7546
- }) })
7547
- ] }, index)) })
7548
- ] });
7549
- }
7550
- return null;
7551
- }
7552
-
7553
- function ObjectField({
7554
- renderDynamicForm,
7555
- schema,
7556
- handleFieldChange,
7557
- control,
7558
- formValues,
7559
- errors,
7560
- parentField,
7561
- action,
7562
- isArray = false,
7563
- isOptional = false,
7564
- depth
7565
- }) {
7566
- const fieldConfig = getFormConfigTypesFromSchemaDef({ schema, isOptional });
7567
- const { fields, append, remove } = useFieldArray({
7568
- control,
7569
- name: parentField
7570
- });
7571
- function handleAddForm() {
7572
- append({});
7573
- }
7574
- return /* @__PURE__ */ jsxs("div", { children: [
7575
- /* @__PURE__ */ jsxs(Label, { className: "flex gap-0.5 capitalize mb-2", htmlFor: parentField, "aria-required": !fieldConfig.isOptional, children: [
7576
- !fieldConfig?.isOptional && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" }),
7577
- /* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: toTitleCase(parentField) })
7578
- ] }),
7579
- isArray ? /* @__PURE__ */ jsxs(Fragment, { children: [
7580
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", children: fields.map((field, index) => /* @__PURE__ */ jsxs("div", { className: "ring-1 ring-white/10 p-2 rounded-md relative", children: [
7581
- /* @__PURE__ */ jsx(
7582
- Button,
7583
- {
7584
- type: "button",
7585
- variant: "ghost",
7586
- size: "icon",
7587
- onClick: () => remove(index),
7588
- className: "absolute top-0 right-0",
7589
- children: /* @__PURE__ */ jsx(XIcon, { className: "text-icon h-3.5 w-3.5" })
7590
- }
7591
- ),
7592
- renderDynamicForm({
7593
- schema: schema instanceof ZodArray ? schema.element : schema,
7594
- handleFieldChange,
7595
- control,
7596
- formValues,
7597
- errors,
7598
- parentField: `${parentField}.${index}`,
7599
- action,
7600
- isOptional,
7601
- depth
7602
- })
7603
- ] }, field.id)) }),
7604
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", className: "w-full text-xs h-9", onClick: handleAddForm, children: [
7605
- "Add ",
7606
- toTitleCase(parentField.split(".").pop() || "")
7607
- ] }) })
7608
- ] }) : /* @__PURE__ */ jsx("div", { className: "ring-1 ring-white/10 p-2 rounded-md relative", children: renderDynamicForm({
7609
- schema,
7610
- handleFieldChange,
7611
- control,
7612
- formValues,
7613
- errors,
7614
- parentField,
7615
- action,
7616
- isOptional,
7617
- depth
7618
- }) })
7240
+ const ArrayElementWrapper = ({ children, onRemove }) => {
7241
+ return /* @__PURE__ */ jsxs("div", { className: "relative border p-4 rounded-md mt-2", children: [
7242
+ /* @__PURE__ */ jsx(Button, { onClick: onRemove, variant: "ghost", className: "absolute top-2 right-2", type: "button", children: /* @__PURE__ */ jsx(TrashIcon, { className: "h-4 w-4" }) }),
7243
+ children
7619
7244
  ] });
7620
- }
7621
-
7622
- function NumberField({ name, control, handleFieldChange }) {
7623
- return /* @__PURE__ */ jsx(
7624
- Controller,
7625
- {
7626
- name,
7627
- control,
7628
- render: ({ field }) => /* @__PURE__ */ jsx(
7629
- Input,
7630
- {
7631
- ...field,
7632
- type: "number",
7633
- onChange: (e) => {
7634
- const value = e.target.value === "" ? void 0 : Number(e.target.value);
7635
- field.onChange(value);
7636
- handleFieldChange?.({ key: name, value });
7637
- }
7638
- }
7639
- )
7640
- }
7641
- );
7642
- }
7245
+ };
7643
7246
 
7644
- function RecordField({ name, control, handleFieldChange }) {
7645
- const formValue = useWatch({ control, name }) || {};
7247
+ const RecordField = ({ inputProps, error, id }) => {
7248
+ const { key, value = {}, onChange, ...props } = inputProps;
7646
7249
  const [pairs, setPairs] = React.useState(
7647
- () => Object.entries(formValue).map(([key, value]) => ({
7648
- id: key || v4(),
7649
- key,
7650
- value
7250
+ () => Object.entries(value).map(([key2, val]) => ({
7251
+ id: key2 || v4(),
7252
+ key: key2,
7253
+ value: val
7651
7254
  }))
7652
7255
  );
7653
7256
  React.useEffect(() => {
@@ -7657,8 +7260,7 @@ function RecordField({ name, control, handleFieldChange }) {
7657
7260
  }, [pairs]);
7658
7261
  const updateForm = React.useCallback(
7659
7262
  (newPairs) => {
7660
- if (!handleFieldChange) return;
7661
- const value = newPairs.reduce(
7263
+ const newValue = newPairs.reduce(
7662
7264
  (acc, pair) => {
7663
7265
  if (pair.key) {
7664
7266
  acc[pair.key] = pair.value;
@@ -7667,12 +7269,14 @@ function RecordField({ name, control, handleFieldChange }) {
7667
7269
  },
7668
7270
  {}
7669
7271
  );
7670
- handleFieldChange({ key: name, value });
7272
+ onChange?.({
7273
+ target: { value: newValue, name: inputProps.name }
7274
+ });
7671
7275
  },
7672
- [handleFieldChange, name]
7276
+ [onChange, inputProps.name]
7673
7277
  );
7674
- const handleChange = (id, field, newValue) => {
7675
- setPairs((prev) => prev.map((pair) => pair.id === id ? { ...pair, [field]: newValue } : pair));
7278
+ const handleChange = (id2, field, newValue) => {
7279
+ setPairs((prev) => prev.map((pair) => pair.id === id2 ? { ...pair, [field]: newValue } : pair));
7676
7280
  };
7677
7281
  const handleBlur = () => {
7678
7282
  updateForm(pairs);
@@ -7682,8 +7286,8 @@ function RecordField({ name, control, handleFieldChange }) {
7682
7286
  setPairs(newPairs);
7683
7287
  updateForm(newPairs);
7684
7288
  };
7685
- const removePair = (id) => {
7686
- const newPairs = pairs.filter((p) => p.id !== id);
7289
+ const removePair = (id2) => {
7290
+ const newPairs = pairs.filter((p) => p.id !== id2);
7687
7291
  if (newPairs.length === 0) {
7688
7292
  newPairs.push({ id: v4(), key: "", value: "" });
7689
7293
  }
@@ -7700,10 +7304,10 @@ function RecordField({ name, control, handleFieldChange }) {
7700
7304
  size: "icon",
7701
7305
  className: "absolute right-2 top-2",
7702
7306
  onClick: () => removePair(pair.id),
7703
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
7307
+ children: /* @__PURE__ */ jsx(TrashIcon, { className: "h-4 w-4" })
7704
7308
  }
7705
7309
  ),
7706
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
7310
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2 pt-6", children: [
7707
7311
  /* @__PURE__ */ jsx(
7708
7312
  Input,
7709
7313
  {
@@ -7729,244 +7333,110 @@ function RecordField({ name, control, handleFieldChange }) {
7729
7333
  "Add Key-Value Pair"
7730
7334
  ] })
7731
7335
  ] });
7732
- }
7336
+ };
7733
7337
 
7734
- function getDefaultFieldMap() {
7735
- return {
7736
- [FormConfigType.STRING]: (props) => {
7737
- const { options, ...rest } = props;
7738
- if (options?.length) {
7739
- return /* @__PURE__ */ jsx(EnumField, { ...rest, options });
7740
- }
7741
- return /* @__PURE__ */ jsx(StringField, { ...rest });
7742
- },
7743
- [FormConfigType.NUMBER]: (props) => {
7744
- return /* @__PURE__ */ jsx(NumberField, { ...props });
7745
- },
7746
- [FormConfigType.BOOLEAN]: (props) => {
7747
- return /* @__PURE__ */ jsx(BooleanField, { ...props });
7748
- },
7749
- [FormConfigType.DATE]: (props) => {
7750
- return /* @__PURE__ */ jsx(DateField, { ...props });
7751
- },
7752
- [FormConfigType.ENUM]: (props) => {
7753
- const { options = [] } = props;
7754
- return /* @__PURE__ */ jsx(EnumField, { ...props, options });
7755
- },
7756
- [FormConfigType.ARRAY]: (props) => {
7757
- const renderField = ({ fieldName, index: _index }) => {
7758
- return getDefaultFieldMap()[FormConfigType.STRING]({
7759
- ...props,
7760
- name: fieldName
7761
- });
7762
- };
7763
- return /* @__PURE__ */ jsx(ArrayField, { ...props, renderField });
7764
- },
7765
- [FormConfigType.RECORD]: (props) => {
7766
- return /* @__PURE__ */ jsx(RecordField, { ...props });
7767
- },
7768
- [FormConfigType.OBJECT]: (props) => {
7769
- const { innerSchema, name, control, handleFieldChange } = props;
7770
- if (!innerSchema) return null;
7771
- return /* @__PURE__ */ jsx(
7772
- ObjectField,
7773
- {
7774
- schema: innerSchema,
7775
- control,
7776
- parentField: name,
7777
- handleFieldChange: (field, value) => handleFieldChange({ key: field, value }),
7778
- formValues: {},
7779
- errors: {},
7780
- renderDynamicForm: (props2) => resolveSchema({ ...props2, handleFieldChange })
7781
- }
7782
- );
7783
- },
7784
- [FormConfigType.UNION]: (props) => {
7785
- const { innerSchema, name, control, handleFieldChange } = props;
7786
- if (!innerSchema || !(innerSchema instanceof z.ZodUnion)) return null;
7787
- return /* @__PURE__ */ jsx(
7788
- UnionField,
7789
- {
7790
- schema: innerSchema,
7791
- control,
7792
- parentField: name,
7793
- handleFieldChange: (field, value) => handleFieldChange({ key: field, value }),
7794
- renderDynamicForm: (fieldProps) => {
7795
- const fieldType = getFormConfigTypesFromSchemaDef({ schema: fieldProps.schema });
7796
- return getDefaultFieldMap()[fieldType.type]({
7797
- ...props,
7798
- ...fieldProps,
7799
- control,
7800
- handleFieldChange
7801
- });
7802
- },
7803
- formValues: {},
7804
- errors: {}
7805
- }
7806
- );
7807
- },
7808
- [FormConfigType.CREATABLE]: (props) => {
7809
- return /* @__PURE__ */ jsx(CreatableField, { ...props });
7810
- },
7811
- [FormConfigType.SELECT]: (props) => {
7812
- const { options = [] } = props;
7813
- return /* @__PURE__ */ jsx(EnumField, { ...props, options });
7814
- },
7815
- [FormConfigType.MULTI_SELECT]: (props) => {
7816
- return /* @__PURE__ */ jsx(CreatableField, { ...props });
7338
+ const ShadcnUIComponents = {
7339
+ Form,
7340
+ FieldWrapper,
7341
+ ErrorMessage,
7342
+ SubmitButton,
7343
+ ObjectWrapper,
7344
+ ArrayWrapper,
7345
+ ArrayElementWrapper
7346
+ };
7347
+ const ShadcnAutoFormFieldComponents = {
7348
+ string: StringField,
7349
+ number: NumberField,
7350
+ boolean: BooleanField,
7351
+ date: DateField,
7352
+ select: SelectField,
7353
+ record: RecordField
7354
+ };
7355
+ function AutoForm({ uiComponents, formComponents, ...props }) {
7356
+ return /* @__PURE__ */ jsx(
7357
+ AutoForm$1,
7358
+ {
7359
+ ...props,
7360
+ uiComponents: { ...ShadcnUIComponents, ...uiComponents },
7361
+ formComponents: { ...ShadcnAutoFormFieldComponents, ...formComponents }
7817
7362
  }
7818
- };
7363
+ );
7819
7364
  }
7820
7365
 
7821
- function adaptHandleFieldChange(handler) {
7822
- return (field, value) => handler({ key: field, value });
7366
+ buildZodFieldConfig();
7367
+
7368
+ function inferFieldType(schema, fieldConfig) {
7369
+ if (fieldConfig?.fieldType) {
7370
+ return fieldConfig.fieldType;
7371
+ }
7372
+ if (schema instanceof z.ZodObject) return "object";
7373
+ if (schema instanceof z.ZodNumber) return "number";
7374
+ if (schema instanceof z.ZodBoolean) return "boolean";
7375
+ if (schema instanceof z.ZodDate || schema?.isDatetime || schema?.isDate) return "date";
7376
+ if (schema instanceof z.ZodString) return "string";
7377
+ if (schema instanceof z.ZodEnum) return "select";
7378
+ if (schema instanceof z.ZodNativeEnum) return "select";
7379
+ if (schema instanceof z.ZodArray) return "array";
7380
+ if (schema instanceof z.ZodRecord) return "record";
7381
+ return "string";
7823
7382
  }
7824
- function resolveSchema({
7825
- schema,
7826
- parentField,
7827
- control,
7828
- formValues,
7829
- errors,
7830
- handleFieldChange,
7831
- isOptional = false,
7832
- isNullable = false,
7833
- depth = 0
7834
- }) {
7835
- if (depth > 10) {
7836
- console.warn("Maximum schema resolution depth reached. Possible circular reference.");
7837
- return null;
7383
+
7384
+ function parseField(key, schema) {
7385
+ const baseSchema = getBaseSchema(schema);
7386
+ const fieldConfig = getFieldConfigInZodStack(schema);
7387
+ const type = inferFieldType(baseSchema, fieldConfig);
7388
+ const defaultValue = getDefaultValueInZodStack(schema);
7389
+ const options = baseSchema._def?.values;
7390
+ let optionValues = [];
7391
+ if (options) {
7392
+ if (!Array.isArray(options)) {
7393
+ optionValues = Object.entries(options);
7394
+ } else {
7395
+ optionValues = options.map((value) => [value, value]);
7396
+ }
7838
7397
  }
7839
- if (schema instanceof z$1.ZodObject) {
7840
- return Object.entries(schema.shape).map(([field, fieldSchema]) => {
7841
- const currentField = parentField ? `${parentField}.${field}` : field;
7842
- return resolveSchemaComponent({
7843
- schema: fieldSchema,
7844
- parentField: currentField,
7845
- control,
7846
- formValues,
7847
- errors,
7848
- handleFieldChange,
7849
- isOptional,
7850
- isNullable
7851
- });
7852
- });
7398
+ let subSchema = [];
7399
+ if (baseSchema instanceof z.ZodObject) {
7400
+ subSchema = Object.entries(baseSchema.shape).map(([key2, field]) => parseField(key2, field));
7853
7401
  }
7854
- return resolveSchemaComponent({
7855
- schema,
7856
- parentField,
7857
- control,
7858
- formValues,
7859
- errors,
7860
- handleFieldChange,
7861
- isOptional,
7862
- isNullable
7863
- });
7402
+ if (baseSchema instanceof z.ZodArray) {
7403
+ subSchema = [parseField("0", baseSchema._def.type)];
7404
+ }
7405
+ return {
7406
+ key,
7407
+ type,
7408
+ required: !schema.isOptional(),
7409
+ default: defaultValue,
7410
+ description: baseSchema.description,
7411
+ fieldConfig,
7412
+ options: optionValues,
7413
+ schema: subSchema
7414
+ };
7864
7415
  }
7865
- function resolveSchemaComponent({
7866
- schema,
7867
- parentField,
7868
- control,
7869
- formValues,
7870
- errors,
7871
- handleFieldChange,
7872
- isOptional = false,
7873
- isNullable = false
7874
- }) {
7875
- if (schema instanceof z$1.ZodDefault) return null;
7876
- if (schema instanceof z$1.ZodOptional) {
7877
- return resolveSchemaComponent({
7878
- schema: schema._def.innerType,
7879
- parentField,
7880
- control,
7881
- formValues,
7882
- errors,
7883
- handleFieldChange,
7884
- isOptional: true,
7885
- isNullable
7886
- });
7416
+ function getBaseSchema(schema) {
7417
+ if ("innerType" in schema._def) {
7418
+ return getBaseSchema(schema._def.innerType);
7887
7419
  }
7888
- if (schema instanceof z$1.ZodObject) {
7889
- return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-8 py-8 w-full", children: /* @__PURE__ */ jsx(
7890
- ObjectField,
7891
- {
7892
- schema,
7893
- control,
7894
- parentField,
7895
- handleFieldChange: (field, value) => handleFieldChange({ key: field, value }),
7896
- formValues,
7897
- errors,
7898
- isOptional,
7899
- renderDynamicForm: (props) => resolveSchema({ ...props, handleFieldChange })
7900
- }
7901
- ) }, parentField);
7420
+ if ("schema" in schema._def) {
7421
+ return getBaseSchema(schema._def.schema);
7902
7422
  }
7903
- if (schema instanceof z$1.ZodUnion) {
7904
- if (schema.options.some((s) => s instanceof z$1.ZodNull)) {
7905
- const nonNullSchema = schema.options.find((s) => !(s instanceof z$1.ZodNull));
7906
- return resolveSchemaComponent({
7907
- schema: z$1.optional(nonNullSchema),
7908
- parentField,
7909
- control,
7910
- formValues,
7911
- errors,
7912
- handleFieldChange,
7913
- isNullable: true,
7914
- isOptional
7915
- });
7916
- }
7917
- return /* @__PURE__ */ jsx(
7918
- UnionField,
7919
- {
7920
- schema,
7921
- control,
7922
- parentField,
7923
- handleFieldChange: adaptHandleFieldChange(handleFieldChange),
7924
- formValues,
7925
- errors,
7926
- isOptional,
7927
- isNullable,
7928
- renderDynamicForm: (props) => resolveSchema({
7929
- ...props,
7930
- handleFieldChange: (props2) => handleFieldChange(props2)
7931
- })
7932
- }
7933
- );
7423
+ return schema;
7424
+ }
7425
+ function parseSchema(schema) {
7426
+ const objectSchema = schema instanceof z.ZodEffects ? schema.innerType() : schema;
7427
+ const shape = objectSchema.shape;
7428
+ const fields = Object.entries(shape).map(([key, field]) => parseField(key, field));
7429
+ return { fields };
7430
+ }
7431
+ class CustomZodProvider extends ZodProvider {
7432
+ _schema;
7433
+ constructor(schema) {
7434
+ super(schema);
7435
+ this._schema = schema;
7934
7436
  }
7935
- if (schema instanceof z$1.ZodArray) {
7936
- return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-8 py-8", children: /* @__PURE__ */ jsx(
7937
- ArrayField,
7938
- {
7939
- control,
7940
- name: parentField,
7941
- isStringField: schema.element instanceof z$1.ZodString,
7942
- renderField: (props) => {
7943
- const fieldSchema = schema.element;
7944
- let currentField = props.fieldName;
7945
- if (fieldSchema instanceof z$1.ZodString) {
7946
- currentField = `${currentField}.root`;
7947
- }
7948
- return resolveSchemaComponent({
7949
- schema: fieldSchema,
7950
- parentField: currentField,
7951
- control,
7952
- formValues,
7953
- errors,
7954
- handleFieldChange
7955
- });
7956
- }
7957
- }
7958
- ) }, parentField);
7437
+ parseSchema() {
7438
+ return parseSchema(this._schema);
7959
7439
  }
7960
- return /* @__PURE__ */ jsx("div", { className: "w-full", children: schemaToFormFieldRenderer({
7961
- schema,
7962
- schemaField: parentField,
7963
- control,
7964
- values: formValues,
7965
- errors,
7966
- renderFieldMap: getDefaultFieldMap(),
7967
- onFieldChange: handleFieldChange,
7968
- isOptional
7969
- }) }, parentField);
7970
7440
  }
7971
7441
 
7972
7442
  function DynamicForm({
@@ -7976,44 +7446,38 @@ function DynamicForm({
7976
7446
  isSubmitLoading,
7977
7447
  submitButtonLabel = "Submit"
7978
7448
  }) {
7979
- const schemaTypeName = schema?._def?.typeName;
7980
- const discriminatedUnionSchemaOptions = schema?._def?.options;
7981
- const discriminatedUnionSchemaDiscriminator = schema?._def?.discriminator;
7982
- const wrappedSchema = schemaTypeName !== "ZodObject" ? z$1.object({ items: schema }) : schema;
7983
- const form = useForm({
7984
- resolver: schemaTypeName === "ZodDiscriminatedUnion" ? customZodUnionResolver(wrappedSchema, discriminatedUnionSchemaDiscriminator) : zodResolver(wrappedSchema),
7985
- defaultValues
7986
- });
7987
- const { control, handleSubmit, watch } = form;
7988
- const formValues = form.watch();
7989
- const discriminatorValue = discriminatedUnionSchemaDiscriminator ? watch(discriminatedUnionSchemaDiscriminator) : void 0;
7990
- const resolvedSchema = schemaTypeName === "ZodDiscriminatedUnion" ? discriminatedUnionSchemaOptions?.find(
7991
- (option) => option?.shape?.[discriminatedUnionSchemaDiscriminator]?._def?.value === discriminatorValue
7992
- ) || z$1.object({ [discriminatedUnionSchemaDiscriminator]: z$1.string() }) : wrappedSchema;
7993
- function handleFieldChange({ key, value }) {
7994
- if (key === discriminatedUnionSchemaDiscriminator) {
7995
- form.setValue(key, value);
7996
- } else {
7997
- form.setValue(key, value);
7998
- }
7449
+ if (!schema) {
7450
+ console.error("no form schema found");
7451
+ return null;
7999
7452
  }
8000
- const wrappedOnSubmit = (values) => {
8001
- if (schemaTypeName !== "ZodObject") {
8002
- return onSubmit(values.items);
8003
- }
8004
- return onSubmit(values);
7453
+ const normalizedSchema = (schema2) => {
7454
+ return z$1.object({
7455
+ "​": schema2
7456
+ });
8005
7457
  };
8006
- return /* @__PURE__ */ jsx(ScrollArea, { className: "h-full w-full", children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit(wrappedOnSubmit), className: "flex flex-col gap-4 p-4 w-full", children: [
8007
- resolveSchema({
8008
- schema: resolvedSchema,
8009
- parentField: "",
8010
- control,
8011
- formValues,
8012
- errors: form.formState.errors,
8013
- handleFieldChange
8014
- }),
8015
- /* @__PURE__ */ jsx(Button, { disabled: isSubmitLoading, type: "submit", children: isSubmitLoading ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : submitButtonLabel })
8016
- ] }) });
7458
+ const schemaProvider = new CustomZodProvider(normalizedSchema(schema));
7459
+ const formProps = {
7460
+ schema: schemaProvider,
7461
+ onSubmit: async (values) => {
7462
+ await onSubmit(values["​"]);
7463
+ },
7464
+ defaultValues,
7465
+ formProps: {
7466
+ className: "space-y-4 p-4"
7467
+ },
7468
+ uiComponents: {
7469
+ SubmitButton: ({ children }) => /* @__PURE__ */ jsx(Button, { className: "w-full", type: "submit", disabled: isSubmitLoading, children: isSubmitLoading ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : children || submitButtonLabel })
7470
+ },
7471
+ formComponents: {
7472
+ Label: ({ value }) => /* @__PURE__ */ jsx(Label, { className: "text-sm font-normal", children: value })
7473
+ },
7474
+ withSubmit: true
7475
+ };
7476
+ return /* @__PURE__ */ jsx(ScrollArea, { className: "h-full w-full", children: /* @__PURE__ */ jsx(AutoForm, { ...formProps }) });
7477
+ }
7478
+
7479
+ function resolveSerializedZodOutput(obj) {
7480
+ return Function("z", `"use strict";return (${obj});`)(z);
8017
7481
  }
8018
7482
 
8019
7483
  function CodeBlockDemo({
@@ -8140,7 +7604,7 @@ function WorkflowTrigger({
8140
7604
  /* @__PURE__ */ jsx(
8141
7605
  CodeBlockDemo,
8142
7606
  {
8143
- className: "w-[368px] overflow-x-auto",
7607
+ className: "w-full overflow-x-auto",
8144
7608
  code: JSON.stringify(result ?? {}, null, 2),
8145
7609
  language: "json"
8146
7610
  }
@@ -8193,7 +7657,7 @@ function WorkflowTrigger({
8193
7657
  step.suspendPayload && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
8194
7658
  CodeBlockDemo,
8195
7659
  {
8196
- className: "w-[300px] overflow-x-auto p-2",
7660
+ className: "w-full overflow-x-auto p-2",
8197
7661
  code: JSON.stringify(step.suspendPayload, null, 2),
8198
7662
  language: "json"
8199
7663
  }
@@ -8201,7 +7665,7 @@ function WorkflowTrigger({
8201
7665
  /* @__PURE__ */ jsx(
8202
7666
  DynamicForm,
8203
7667
  {
8204
- schema: z$1.record(z$1.string(), z$1.any()),
7668
+ schema: z.record(z.string(), z.any()),
8205
7669
  isSubmitLoading: isResumingWorkflow,
8206
7670
  submitButtonLabel: "Resume",
8207
7671
  onSubmit: (data) => {
@@ -8224,17 +7688,10 @@ function WorkflowTrigger({
8224
7688
  content: JSON.stringify(result, null, 2)
8225
7689
  }
8226
7690
  ) }),
8227
- /* @__PURE__ */ jsx(
8228
- CodeBlockDemo,
8229
- {
8230
- className: "w-[368px] overflow-x-auto",
8231
- code: JSON.stringify(result, null, 2),
8232
- language: "json"
8233
- }
8234
- )
7691
+ /* @__PURE__ */ jsx(CodeBlockDemo, { className: "w-full overflow-x-auto", code: JSON.stringify(result, null, 2), language: "json" })
8235
7692
  ] })
8236
7693
  ] }) });
8237
7694
  }
8238
7695
 
8239
- export { AgentChat, AgentEvals, AgentTraces, AgentsTable, MastraResizablePanel, NetworkChat, WorkflowGraph, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger, WorkflowsTable };
7696
+ export { AgentChat, AgentEvals, AgentTraces, AgentsTable, DynamicForm, MastraResizablePanel, NetworkChat, WorkflowGraph, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger, WorkflowsTable };
8240
7697
  //# sourceMappingURL=index.es.js.map