"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("../index-DEZRGktf.js"),t=require("lucide-react");require("react-router-dom");require("react");require("react-dom");const o=()=>{const i=`import { useFormContext } from '@e-burgos/tucu-ui';

function FormActions() {
  const {
    formState: { errors, isDirty, isValid, isSubmitting },
    reset,
    trigger,
    setValue,
    getValues,
    watch,
  } = useFormContext<FormValues>();

  // Watch specific field changes
  const nameValue = watch('name');

  // Reset to default values
  const handleReset = () => reset(defaultValues);

  // Trigger validation on all fields
  const handleValidate = async () => {
    const result = await trigger();
    console.log('All fields valid:', result);
  };

  // Set value programmatically (triggers validation)
  const handleSetValue = () => {
    setValue('name', 'John Doe', { shouldValidate: true });
  };

  // Get current values snapshot
  const handleGetValues = () => {
    const values = getValues();
    console.log('Current values:', values);
  };

  return (
    <div className="space-y-4">
      <p>Name: {nameValue}</p>
      <p>Dirty: {isDirty ? 'Yes' : 'No'}</p>
      <p>Valid: {isValid ? 'Yes' : 'No'}</p>
      <button onClick={handleReset}>Reset</button>
      <button onClick={handleValidate}>Validate</button>
      <button onClick={handleSetValue}>Set Value</button>
      <button onClick={handleGetValues}>Get Values</button>
    </div>
  );
}

// Must be inside <Form> to access context
<Form<FormValues> onSubmit={handleSubmit}>
  <FormActions />
  {/* form fields */}
</Form>`,l=[{name:"errors",description:"Object containing all field errors"},{name:"isDirty",description:"True if any field has been modified"},{name:"isValid",description:"True if form passes all validations"},{name:"isSubmitting",description:"True during async form submission"},{name:"dirtyFields",description:"Object of fields that have been modified"},{name:"touchedFields",description:"Object of fields that have been focused/blurred"}],n=[{name:"reset(values?)",description:"Reset form to defaults or provided values"},{name:"trigger(name?)",description:"Trigger validation for all fields or a specific field"},{name:"setValue(name, value, options?)",description:"Set a field value programmatically"},{name:"getValues(name?)",description:"Get current form values (all or specific field)"},{name:"watch(name?)",description:"Subscribe to field changes (causes re-render)"},{name:"setError(name, error)",description:"Manually set an error on a field"},{name:"clearErrors(name?)",description:"Clear errors for all fields or a specific field"}];return e.jsxs(e.Fragment,{children:[e.jsx(s.HeroCard,{title:"Form Methods",description:"Access react-hook-form methods via useFormContext inside any child of Form. Programmatically control values, trigger validation, and read form state.",icon:e.jsx("div",{className:"w-20 h-20 sm:w-24 sm:h-24 md:w-32 md:h-32 bg-linear-to-br from-cyan-500 via-blue-500 to-indigo-500 rounded-full flex items-center justify-center shadow-lg",children:e.jsx(t.Terminal,{className:"w-10 h-10 sm:w-12 sm:h-12 md:w-16 md:h-16 text-white filter drop-shadow-lg"})})}),e.jsxs("section",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(s.Typography,{tag:"h2",className:"mb-2",children:"useFormContext Example"}),e.jsx(s.Typography,{tag:"p",className:"text-gray-500 dark:text-gray-400 max-w-2xl mx-auto",children:"Access form state and methods from any component inside Form"})]}),e.jsx(s.CardContainer,{className:"overflow-hidden",children:e.jsx("div",{className:"w-full p-4 sm:p-6",children:e.jsx(s.CodeBlock,{language:"tsx",code:i})})})]}),e.jsxs("section",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(s.Typography,{tag:"h2",className:"mb-2",children:"API Reference"}),e.jsx(s.Typography,{tag:"p",className:"text-gray-500 dark:text-gray-400 max-w-2xl mx-auto",children:"Form state properties and available methods"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-6",children:[e.jsx(s.CardContainer,{children:e.jsxs("div",{className:"w-full p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Activity,{className:"w-5 h-5 text-brand"}),e.jsx(s.Typography,{tag:"h3",className:"font-semibold",children:"formState Properties"})]}),e.jsx("div",{className:"space-y-2",children:l.map((a,r)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(t.Circle,{className:"w-3 h-3 text-brand mt-1.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("code",{className:"text-xs text-brand font-semibold",children:a.name}),e.jsxs(s.Typography,{tag:"span",className:"text-xs text-gray-500 dark:text-gray-400 ml-2",children:["— ",a.description]})]})]},r))})]})}),e.jsx(s.CardContainer,{children:e.jsxs("div",{className:"w-full p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Wrench,{className:"w-5 h-5 text-brand"}),e.jsx(s.Typography,{tag:"h3",className:"font-semibold",children:"Methods"})]}),e.jsx("div",{className:"space-y-2",children:n.map((a,r)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(t.Circle,{className:"w-3 h-3 text-brand mt-1.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("code",{className:"text-xs text-brand font-semibold",children:a.name}),e.jsxs(s.Typography,{tag:"span",className:"text-xs text-gray-500 dark:text-gray-400 ml-2",children:["— ",a.description]})]})]},r))})]})})]})]})]})};exports.default=o;
