{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "date-range",
  "type": "registry:item",
  "title": "Date Range",
  "description": "A check-in and check-out date, as one value `{ start, end }` (\"YYYY-MM-DD\" strings). A form control: invalid until both are set and `end` is after `start`.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "input"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/date-range.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/date-range.js",
      "content": "// Generated by zubra from date-range.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { effect, formValue, host, validity, id } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"date-range\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: {\"start\":\"\",\"end\":\"\"}, required: false, model: true },\n    \"min\": { attribute: \"min\", default: \"\", required: false },\n    \"disabled\": { attribute: \"disabled\", default: false, required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: true,\n  slots: [],\n  events: [\"valuechange\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (date-range) to ([data-zb-slotted=\\\"date-range\\\"]) {\\n  /* Two dates and the nights side by side; on a narrow screen they wrap instead of overflowing. */\\n  :scope { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; }\\n  label { flex: 1 1 9rem; min-width: 0; }\\n  label { display: grid; gap: 0.3rem; font-size: 0.8125rem; font-weight: 600; color: var(--muted-foreground, #667); }\\n  input { box-sizing: border-box; width: 100%; min-width: 0; font: inherit; padding: 0.55rem 0.65rem; border: 1px solid var(--border, #ccd); border-radius: calc(var(--radius, 0.625rem) * 0.96); background: var(--card, #fff); color: var(--foreground, #111); }\\n  .error { flex-basis: 100%; margin: 0; color: var(--destructive, #d92d20); font-size: 0.875rem; }\\n  .error:empty { display: none; }\\n  .nights { padding: 0.55rem 0.8rem; border-radius: 999px; background: var(--chip, var(--secondary, #f4f4f5)); color: var(--chip-ink, var(--secondary-foreground, #18181b)); font-weight: 700; white-space: nowrap; }\\n}\\n}\\n\",\n  template: \"\\n  <label>Check-in\\n    <input type=\\\"date\\\" class=\\\"start\\\">\\n  </label>\\n  <label>Check-out\\n    <input type=\\\"date\\\" class=\\\"end\\\">\\n  </label>\\n  <span class=\\\"nights\\\" aria-live=\\\"polite\\\"></span>\\n  <p class=\\\"error\\\" aria-live=\\\"polite\\\"></p>\\n\",\n  setup($p, $emit) {\n                                                                        \n\n  // `disabled` set from code (el.disabled = true) also goes on the element as the attribute, which\n  // is where the browser looks: it leaves a disabled control out of the form. A disabled\n  // <fieldset> needs nothing here; the browser disables the controls inside it too.\n  const element = host()\n  effect(() => element.toggleAttribute('disabled', $p.disabled))\n\n  const startId = id()\n  const endId = id()\n  // Only plain YYYY-MM-DD days count (a date input can hold years past 9999).\n  const isDay = (day) => /^\\d{4}-\\d{2}-\\d{2}$/.test(day ?? \"\") && !isNaN(Date.parse(day))\n  const nights = __zubraComputed(() => (isDay($p.value.start) && isDay($p.value.end) ? Math.round((Date.parse($p.value.end) - Date.parse($p.value.start)) / 86400000) : 0))\n  const nextDay = (day) => {\n    if (!isDay(day)) return $p.min\n    const next = new Date(Date.parse(day) + 86400000).toISOString().slice(0, 10)\n    return isDay(next) ? next : \"\"\n  }\n  const wrongOrder = __zubraComputed(() => (Boolean($p.value.start && $p.value.end) && nights.get() < 1))\n\n  formValue(() => ($p.value.start && $p.value.end ? `${$p.value.start}/${$p.value.end}` : null))\n  validity(() => (!isDay($p.value.start) || !isDay($p.value.end) ? \"Choose both dates\" : nights.get() < 1 ? \"Check-out must be after check-in\" : \"\"))\n\n  function set(part, day) {\n    const next = { ...$p.value, [part]: day }\n    if (part === \"start\" && next.end && next.end <= day) next.end = nextDay(day)\n    if (!isDay(next.start)) next.start = \"\"\n    if (!isDay(next.end)) next.end = \"\"\n    $p.value = next\n  }\n    return [\n      { path: [0], attribute: \"for\", value: () => $r(startId) },\n      { path: [0, 0], attribute: \"id\", value: () => $r(startId) },\n      { path: [0, 0], attribute: \"min\", value: () => $p.min },\n      { path: [0, 0], attribute: \"disabled\", boolean: true, value: () => $p.disabled },\n      { path: [0, 0], attribute: \"value\", value: () => $p.value.start },\n      { path: [0, 0], on: \"change\", handler: () => ((event) => set(\"start\", event.target.value)) },\n      { path: [1], attribute: \"for\", value: () => $r(endId) },\n      { path: [1, 0], attribute: \"id\", value: () => $r(endId) },\n      { path: [1, 0], attribute: \"min\", value: () => (nextDay($p.value.start)) },\n      { path: [1, 0], attribute: \"disabled\", boolean: true, value: () => $p.disabled },\n      { path: [1, 0], attribute: \"value\", value: () => $p.value.end },\n      { path: [1, 0], on: \"change\", handler: () => ((event) => set(\"end\", event.target.value)) },\n      { path: [2], text: () => $t((nights.get() > 0 ? `${nights.get()} night${nights.get() === 1 ? \"\" : \"s\"}` : \"—\")) },\n      { path: [3], text: () => $t(($r(wrongOrder) ? \"Check-out must be after check-in\" : \"\")) },\n    ];\n  },\n});\n"
    }
  ]
}
