{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "calendar",
  "title": "Calendar",
  "description": "A month grid with today marked and the chosen day lit.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5",
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json",
    "https://www.cyberspec.dev/r/button.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/calendar.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  Calendar as SdkCalendar,\n  CalendarDay,\n  CalendarGrid,\n  CalendarHeading,\n  CalendarNext,\n  CalendarPrevious,\n  CalendarWeekday,\n  CalendarWeekdays,\n  CalendarWeeks,\n  type CalendarMode,\n  type CalendarValue,\n} from \"@ui-sdk/react/calendar\"\nimport { ChevronLeft, ChevronRight } from \"lucide-react\"\nimport \"@/registry/cyber/ui/cyber/button.css\"\nimport \"@/registry/cyber/ui/cyber/calendar.css\"\n\n// What the foot prints for a value: the date as the machine holds it, both\n// ends of a range, or how many dates a multiple selection has.\nfunction readout(value: CalendarValue, mode: CalendarMode) {\n  const dotted = (date: string) => date.split(\"-\").join(\".\")\n  if (!value || value.length === 0) return \"----.--.--\"\n  if (typeof value === \"string\") return dotted(value)\n  if (mode === \"range\" && value.length === 2) return `${dotted(value[0].slice(5))} > ${dotted(value[1].slice(5))}`\n  return value.length === 1 ? dotted(value[0]) : `${value.length} dates`\n}\n\n// The month a calendar shows: its heading between the two keys that turn\n// it, and the grid of days. It's the inside of `Calendar`, and of a date\n// picker's popup, where the SDK's calendar parts work the same way.\nfunction CalendarView() {\n  return (\n    <>\n      <div data-kit=\"calendar-head\">\n        <CalendarPrevious data-kit=\"button\" data-frame=\"br\" data-press-flash=\"\" data-tone=\"secondary\" data-size=\"sm\" data-icon=\"\">\n          <ChevronLeft aria-hidden />\n        </CalendarPrevious>\n        <CalendarHeading data-kit=\"calendar-heading\">\n          {/* The year, like every numeral in the kit, reads in the signal\n              color; the words around it stay a label. */}\n          {(state) =>\n            state.label.split(/(\\d{4})/).map((part, index) =>\n              /^\\d{4}$/.test(part) ? (\n                <span key={index} data-kit=\"calendar-year\">\n                  {part}\n                </span>\n              ) : (\n                part\n              ),\n            )\n          }\n        </CalendarHeading>\n        <CalendarNext data-kit=\"button\" data-frame=\"br\" data-press-flash=\"\" data-tone=\"secondary\" data-size=\"sm\" data-icon=\"\">\n          <ChevronRight aria-hidden />\n        </CalendarNext>\n      </div>\n      <CalendarGrid data-kit=\"calendar-grid\">\n        <CalendarWeekdays data-kit=\"calendar-weekdays\">\n          {(index) => <CalendarWeekday index={index} data-kit=\"calendar-weekday\" />}\n        </CalendarWeekdays>\n        <CalendarWeeks data-kit=\"calendar-weeks\">\n          {(cell) => (\n            // A day takes real focus. Its face draws the ring, inside\n            // itself, so the cell asks for none around it, where it would\n            // run into its neighbours.\n            <CalendarDay value={cell.date} data-kit=\"calendar-day\" data-press-flash=\"\" data-focus-quiet=\"\">\n              {(state) => <span data-kit=\"calendar-day-face\">{state.label}</span>}\n            </CalendarDay>\n          )}\n        </CalendarWeeks>\n      </CalendarGrid>\n    </>\n  )\n}\n\n// A month on a panel. Today carries a corner flag and an edge, the chosen\n// day is a solid signal block, days outside the month are muted, and days\n// that can't be picked are hatched and struck. The foot prints the value.\n//\n// Everything goes to the SDK's Calendar: `value`, `defaultValue`,\n// `onValueChange`, `mode` (\"single\", \"multiple\" or \"range\"), `min`, `max`,\n// `unavailable`, `today`, `disabled`, `readOnly`, `controller`.\nfunction Calendar({ code = \"CS-28 // DATE\", ...props }: Omit<React.ComponentProps<typeof SdkCalendar>, \"children\"> & { code?: string }) {\n  return (\n    <SdkCalendar data-kit=\"calendar\" data-frame=\"tr bl\" {...props}>\n      {(state) => (\n        <>\n          <CalendarView />\n          <div data-kit=\"calendar-foot\" aria-hidden>\n            <span data-kit=\"calendar-readout\">\n              SEL <span data-kit=\"value\">{readout(state.value, state.mode)}</span>\n            </span>\n            <span data-micro>{code}</span>\n          </div>\n        </>\n      )}\n    </SdkCalendar>\n  )\n}\n\nexport { Calendar, CalendarView }\n",
      "type": "registry:ui",
      "target": "@ui/calendar.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/calendar.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n/* The month's head, grid and days are styled on their own, not under the\n   calendar's frame, so a date picker's popup can hold the same parts. The\n   two keys in the head are the shared button (button.css). */\n@layer cyber.ui {\n  /* The panel a calendar sits on when it stands alone. Seven columns fit a\n     256px stage; on a touch screen the days grow toward a finger's width. */\n  [data-skin=\"cyber\"] [data-kit=\"calendar\"] {\n    --frame-cut: var(--cy-cut);\n    --frame-line: var(--cy-line-deco);\n    --frame-fill: var(--cy-panel);\n\n    display: grid;\n    gap: 8px;\n    width: min(100%, 264px);\n    padding: 10px;\n    text-align: start;\n\n    @media (pointer: coarse) {\n      width: min(100%, 344px);\n    }\n  }\n\n  /* Previous, the month, next. */\n  [data-skin=\"cyber\"] [data-kit=\"calendar-head\"] {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 8px;\n\n    /* The chevrons point the way the months turn. */\n    & svg:dir(rtl) {\n      scale: -1 1;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"calendar-heading\"] {\n    flex: 1;\n    min-width: 0;\n    font-size: var(--cy-text-md);\n    font-weight: 600;\n    line-height: 1.1;\n    letter-spacing: var(--cy-track);\n    text-align: center;\n    text-transform: uppercase;\n    white-space: nowrap;\n    color: var(--cy-ink);\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"calendar-year\"] {\n    color: var(--cy-signal);\n  }\n\n  /* The grid is a table. Its cells share the width, with a hairline of\n     space between them that the negative margin takes back at the edges. */\n  [data-skin=\"cyber\"] [data-kit=\"calendar-grid\"] {\n    --day: 30px;\n\n    width: calc(100% + 4px);\n    margin: -2px;\n    table-layout: fixed;\n    border-collapse: separate;\n    border-spacing: 2px;\n\n    @media (pointer: coarse) {\n      --day: 40px;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"calendar-weekday\"] {\n    height: 20px;\n    padding: 0;\n    font-family: var(--cy-mono);\n    font-size: 9px;\n    font-weight: 400;\n    letter-spacing: 0.06em;\n    text-align: center;\n    text-transform: uppercase;\n    color: var(--cy-ink-mute);\n  }\n\n  /* A day is the cell, which takes focus and the press; its face is what\n     shows. */\n  [data-skin=\"cyber\"] [data-kit=\"calendar-day\"] {\n    padding: 0;\n    cursor: pointer;\n    user-select: none;\n\n    &[data-disabled] {\n      cursor: not-allowed;\n    }\n\n    [data-readonly] &,\n    [data-readonly] &[data-disabled] {\n      cursor: default;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"calendar-day-face\"] {\n    --cut: 7px;\n\n    position: relative;\n    display: grid;\n    place-items: center;\n    height: var(--day);\n    font-size: var(--cy-text-sm);\n    font-weight: 600;\n    line-height: 1;\n    color: var(--cy-ink);\n    transition:\n      background-color var(--cy-t-fast) linear,\n      color var(--cy-t-fast) linear;\n\n    @media (hover: hover) {\n      [data-kit=\"calendar-day\"]:hover:not([data-disabled], [data-selected]) > & {\n        background: var(--cy-fill-hover);\n        box-shadow: inset 0 0 0 1px var(--cy-line-hot);\n      }\n    }\n\n    /* Days of the months either side: there, and pickable, but quiet. */\n    [data-outside] > & {\n      font-weight: 500;\n      color: var(--cy-ink-mute);\n    }\n\n    /* Today: an edge all round and a flag in its corner, so it's marked by\n       shape and not only by a brighter numeral. */\n    [data-today] > & {\n      box-shadow: inset 0 0 0 1px var(--cy-line-ctl);\n      color: var(--cy-ink-hi);\n\n      &::after {\n        content: \"\";\n        position: absolute;\n        inset-block-start: 0;\n        inset-inline-end: 0;\n        width: 8px;\n        height: 8px;\n        background: var(--cy-accent);\n        clip-path: polygon(0 0, 100% 0, 100% 100%);\n      }\n\n      &:dir(rtl)::after {\n        clip-path: polygon(0 0, 100% 0, 0 100%);\n      }\n    }\n\n    /* Can't be picked: hatched and struck through. */\n    [data-disabled] > & {\n      background-image: repeating-linear-gradient(135deg, transparent 0 4px, var(--cy-line-deco) 4px 5px);\n      font-weight: 500;\n      text-decoration: line-through;\n      color: var(--cy-ink-mute);\n    }\n\n    /* The chosen day: a solid signal block, dark ink, its corner cut. */\n    [data-selected] > & {\n      background: var(--cy-signal);\n      box-shadow: none;\n      font-weight: 700;\n      color: var(--cy-on-solid);\n      clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%);\n\n      &:dir(rtl) {\n        clip-path: polygon(0 0, 100% 0, 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));\n      }\n\n      &::after {\n        background: var(--cy-on-solid);\n      }\n\n      @media (hover: hover) {\n        [data-kit=\"calendar-day\"]:hover:not([data-disabled]) > & {\n          background: color-mix(in srgb, var(--cy-signal) 84%, white);\n        }\n      }\n    }\n\n    /* A chosen day that can no longer be picked keeps its shape, dimmed. */\n    [data-selected][data-disabled] > & {\n      background-color: var(--cy-signal-dim);\n      color: var(--cy-ink-hi);\n    }\n\n    /* A range: solid at both ends, and a quieter band between them, also\n       while its end is still being picked. */\n    :is([data-range-middle], [data-preview]:not([data-range-start], [data-range-end])) > & {\n      background: var(--cy-signal-fill);\n      box-shadow: inset 0 1px 0 var(--cy-signal-dim), inset 0 -1px 0 var(--cy-signal-dim);\n      font-weight: 600;\n      color: var(--cy-signal);\n      clip-path: none;\n\n      &::after {\n        background: var(--cy-signal);\n      }\n    }\n\n    /* Keyboard focus belongs to the cell; the face draws the ring inside\n       itself, dark on the solid block. */\n    [data-kit=\"calendar-day\"]:focus-visible > & {\n      outline: 2px solid var(--cy-signal);\n      outline-offset: -2px;\n    }\n\n    [data-kit=\"calendar-day\"][data-selected]:not([data-range-middle]):focus-visible > & {\n      outline-color: var(--cy-on-solid);\n      outline-offset: -4px;\n    }\n  }\n\n  /* The foot: what's selected, as the machine holds it. */\n  [data-skin=\"cyber\"] [data-kit=\"calendar-foot\"] {\n    display: flex;\n    align-items: baseline;\n    justify-content: space-between;\n    gap: 8px;\n    padding-block-start: 7px;\n    border-block-start: 1px solid var(--cy-line-deco);\n\n    /* In a tight column the print gives way before the readout does. */\n    & [data-micro] {\n      min-width: 0;\n      overflow: hidden;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"calendar-readout\"] {\n    font-family: var(--cy-mono);\n    font-size: 10px;\n    letter-spacing: 0.08em;\n    text-transform: uppercase;\n    flex: none;\n    white-space: nowrap;\n    color: var(--cy-ink-mute);\n\n    & [data-kit=\"value\"] {\n      font-size: inherit;\n    }\n\n    [data-disabled] > * > & [data-kit=\"value\"] {\n      color: var(--cy-ink-mute);\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/calendar.css"
    }
  ],
  "type": "registry:ui"
}
