{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "time-field-validation-preskok-demo",
  "dependencies": [
    "@internationalized/date"
  ],
  "registryDependencies": [
    "https://ui-three-mu.vercel.app/r/time-field.json",
    "https://ui-three-mu.vercel.app/r/date-field.json",
    "https://ui-three-mu.vercel.app/r/field.json",
    "https://ui-three-mu.vercel.app/r/form.json",
    "https://ui-three-mu.vercel.app/r/button.json"
  ],
  "files": [
    {
      "path": "registry/preskok/examples/time-field-validation-preskok-demo.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport { Time } from \"@internationalized/date\"\n\nimport { Button } from \"@/components/ui/preskok-ui/button\"\nimport { DateInput } from \"@/components/ui/preskok-ui/date-field\"\nimport {\n  Description,\n  FieldError,\n  Label,\n} from \"@/components/ui/preskok-ui/field\"\nimport { Form } from \"@/components/ui/preskok-ui/form\"\nimport { Switch, SwitchLabel } from \"@/components/ui/preskok-ui/switch\"\nimport { TimeField } from \"@/components/ui/preskok-ui/time-field\"\n\nexport default function TimeFieldValidationPreskokDemo() {\n  const [hourCycle, setHourCycle] = useState<12 | 24>(12)\n  const openingTime = new Time(9, 0)\n  const closingTime = new Time(17, 30)\n\n  return (\n    <Form onSubmit={(e) => e.preventDefault()} className=\"max-w-xs space-y-4\">\n      <Switch\n        isSelected={hourCycle === 12}\n        onChange={() =>\n          setHourCycle((prevHourCycle) => (prevHourCycle === 12 ? 24 : 12))\n        }\n      >\n        <SwitchLabel>{hourCycle} hour format</SwitchLabel>\n      </Switch>\n\n      <TimeField\n        isRequired\n        hourCycle={hourCycle}\n        defaultValue={new Time(10, 30)}\n        minValue={openingTime}\n        maxValue={closingTime}\n        validate={(value) => {\n          if (!value) {\n            return \"Please choose an appointment time.\"\n          }\n\n          if (value.hour === 12 && value.minute > 30) {\n            return \"12:30 PM to 1:00 PM is unavailable.\"\n          }\n\n          return null\n        }}\n      >\n        <Label>Service appointment</Label>\n        <Description>\n          {hourCycle === 12\n            ? \"Pick a time between 9:00 AM and 5:30 PM.\"\n            : \"Pick a time between 09:00 and 17:30.\"}\n        </Description>\n        <DateInput />\n        <FieldError />\n      </TimeField>\n      <Button type=\"submit\">Book appointment</Button>\n    </Form>\n  )\n}\n",
      "type": "registry:example"
    }
  ],
  "type": "registry:example"
}