{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-field",
  "type": "registry:item",
  "title": "Text Field",
  "description": "A labelled text field on a native <input> (or <textarea> with `rows`), so it submits under its `name`, autofills, and validates as the browser's own (`required`, `type=\"email\"`, `minlength`, `pattern`). The message shows after the field is left, or when the form is submitted, and is linked to the field for screen readers. `value` is two-way.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "input"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/text-field.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/text-field.js",
      "content": "// Generated by zubra from text-field.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { id } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"text-field\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: \"\", required: false, model: true },\n    \"label\": { attribute: \"label\", default: \"\", required: false },\n    \"description\": { attribute: \"description\", default: \"\", required: false },\n    \"error\": { attribute: \"error\", default: \"\", required: false },\n    \"name\": { attribute: \"name\", default: \"\", required: false },\n    \"type\": { attribute: \"type\", default: \"text\", required: false },\n    \"placeholder\": { attribute: \"placeholder\", default: \"\", required: false },\n    \"autocomplete\": { attribute: \"autocomplete\", default: \"\", required: false },\n    \"inputmode\": { attribute: \"inputmode\", default: \"\", required: false },\n    \"required\": { attribute: \"required\", default: false, required: false },\n    \"disabled\": { attribute: \"disabled\", default: false, required: false },\n    \"readonly\": { attribute: \"readonly\", default: false, required: false },\n    \"minlength\": { attribute: \"minlength\", default: null, required: false },\n    \"maxlength\": { attribute: \"maxlength\", default: null, required: false },\n    \"pattern\": { attribute: \"pattern\", default: \"\", required: false },\n    \"rows\": { attribute: \"rows\", default: 0, required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [\"valuechange\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (text-field) to ([data-zb-slotted=\\\"text-field\\\"]) {\\n  :scope { display: block; }\\n  .field-stack { display: grid; gap: 0.4rem; }\\n  label { font-weight: 600; font-size: 0.925rem; }\\n  .field-optional { font-weight: 400; color: color-mix(in oklab, var(--muted-foreground, #71717a) 75%, var(--foreground, #18181b)); }\\n  .field-help { margin: 0; font-size: 0.85rem; color: color-mix(in oklab, var(--muted-foreground, #71717a) 75%, var(--foreground, #18181b)); }\\n  .field-control { width: 100%; box-sizing: border-box; padding: 0.55rem 0.75rem; border: 1px solid var(--input, #e4e4e7); border-radius: calc(var(--radius, 0.625rem) - 2px); background: var(--background, #fff); color: var(--foreground, #18181b); font: inherit; transition: border-color var(--duration-fast, 150ms), box-shadow var(--duration-fast, 150ms); }\\n  textarea.field-control { resize: vertical; min-height: 4.5rem; }\\n  .field-control::placeholder { color: var(--muted-foreground, #71717a); }\\n  .field-control:focus-visible { outline: none; border-color: var(--ring, #a1a1aa); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring, #a1a1aa) 40%, transparent); }\\n  .field-control[aria-invalid=true], .field-control[aria-invalid=true]:focus-visible { border-color: var(--destructive, #dc2626); }\\n  .field-control:disabled { opacity: 0.55; cursor: not-allowed; }\\n  .field-error { margin: 0; font-size: 0.85rem; color: var(--destructive, #dc2626); }\\n  .field-error:empty { display: none; }\\n  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; } }\\n}\\n}\\n\",\n  template: \"\\n  <div class=\\\"field-stack\\\">\\n    <label><!----><!--[--><!--]--></label>\\n    <!--[--><!--]-->\\n    <!--[--><!--]-->\\n    <p class=\\\"field-error\\\" aria-live=\\\"polite\\\"></p>\\n  </div>\\n\",\n  setup($p, $emit) {\nfunction __zubraAssign(signal, value) { signal.set(value); return value }\nfunction __zubraUpdate(signal, delta, prefix) { const old = signal.get(); signal.set(old + delta); return prefix ? old + delta : old }\n                                     \n\n  const inputId = id()\n  const helpId = id()\n  const errorId = id()\n  const field = __zubraState(null)\n  // The browser's own message (or `error`, which wins), shown once the visitor has left the field.\n  const message = __zubraState(\"\")\n  const shown = __zubraComputed(() => ($p.error || message.get()))\n\n  function check() {\n    __zubraAssign(message, field.get() ? field.get().validationMessage : \"\")\n  }\n  function input(event) {\n    $p.value = event.target.value\n    if (message.get()) check()\n  }\n    return [\n      { path: [0, 0], attribute: \"for\", value: () => $r(inputId) },\n      { path: [0, 0, 0], anchor: () => $t($p.label) + \" \" },\n      { path: [0, 0, 1], when: () => !($p.required), blocks: [{ template: \"<span class=\\\"field-optional\\\">(optional)</span>\", parts: () => [] }, null] },\n      { path: [0, 1], when: () => $p.description, blocks: [{ template: \"<p class=\\\"field-help\\\"></p>\", parts: () => [{ path: [0], attribute: \"id\", value: () => $r(helpId) }, { path: [0], text: () => $t($p.description) }] }, null] },\n      { path: [0, 2], when: () => ($p.rows > 0), blocks: [{ template: \"<textarea class=\\\"field-control\\\"></textarea>\", parts: () => [{ path: [0], ref: () => (($el) => (__zubraAssign(field, $el))) }, { path: [0], attribute: \"id\", value: () => $r(inputId) }, { path: [0], attribute: \"name\", value: () => ($p.name || null) }, { path: [0], attribute: \"rows\", value: () => $p.rows }, { path: [0], attribute: \"placeholder\", value: () => ($p.placeholder || null) }, { path: [0], attribute: \"required\", boolean: true, value: () => $p.required }, { path: [0], attribute: \"disabled\", boolean: true, value: () => $p.disabled }, { path: [0], attribute: \"readonly\", boolean: true, value: () => $p.readonly }, { path: [0], attribute: \"minlength\", value: () => $p.minlength }, { path: [0], attribute: \"maxlength\", value: () => $p.maxlength }, { path: [0], attribute: \"aria-invalid\", value: () => ($r(shown) ? \"true\" : \"false\") }, { path: [0], attribute: \"aria-describedby\", value: () => ([$p.description ? helpId : \"\", shown.get() ? errorId : \"\"].join(\" \").trim() || null) }, { path: [0], attribute: \"value\", value: () => $p.value }, { path: [0], on: \"input\", handler: () => $r(input) }, { path: [0], on: \"blur\", handler: () => $r(check) }, { path: [0], on: \"invalid\", handler: () => $r(check) }] }, { template: \"<input class=\\\"field-control\\\">\", parts: () => [{ path: [0], ref: () => (($el) => (__zubraAssign(field, $el))) }, { path: [0], attribute: \"id\", value: () => $r(inputId) }, { path: [0], attribute: \"name\", value: () => ($p.name || null) }, { path: [0], attribute: \"type\", value: () => $p.type }, { path: [0], attribute: \"placeholder\", value: () => ($p.placeholder || null) }, { path: [0], attribute: \"autocomplete\", value: () => ($p.autocomplete || null) }, { path: [0], attribute: \"inputmode\", value: () => ($p.inputmode || null) }, { path: [0], attribute: \"required\", boolean: true, value: () => $p.required }, { path: [0], attribute: \"disabled\", boolean: true, value: () => $p.disabled }, { path: [0], attribute: \"readonly\", boolean: true, value: () => $p.readonly }, { path: [0], attribute: \"minlength\", value: () => $p.minlength }, { path: [0], attribute: \"maxlength\", value: () => $p.maxlength }, { path: [0], attribute: \"pattern\", value: () => ($p.pattern || null) }, { path: [0], attribute: \"aria-invalid\", value: () => ($r(shown) ? \"true\" : \"false\") }, { path: [0], attribute: \"aria-describedby\", value: () => ([$p.description ? helpId : \"\", shown.get() ? errorId : \"\"].join(\" \").trim() || null) }, { path: [0], attribute: \"value\", value: () => $p.value }, { path: [0], on: \"input\", handler: () => $r(input) }, { path: [0], on: \"blur\", handler: () => $r(check) }, { path: [0], on: \"invalid\", handler: () => $r(check) }] }] },\n      { path: [0, 3], attribute: \"id\", value: () => $r(errorId) },\n      { path: [0, 3], text: () => $t($r(shown)) },\n    ];\n  },\n});\n"
    }
  ]
}
