{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "combobox",
  "title": "Combobox",
  "description": "A text control that filters a list of options as you type.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5",
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/combobox.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  Combobox as SdkCombobox,\n  ComboboxClear,\n  ComboboxContent,\n  ComboboxEmpty,\n  ComboboxInput,\n  ComboboxItem,\n  ComboboxItemIndicator,\n  ComboboxItemText,\n  ComboboxList,\n  ComboboxStatus,\n  ComboboxTrigger,\n  type ComboboxProps,\n} from \"@ui-sdk/react/combobox\"\nimport { Field, FieldDescription, FieldError, FieldLabel } from \"@ui-sdk/react/field\"\nimport { Check, ChevronDown, Search, X } from \"lucide-react\"\nimport \"@/registry/cyber/ui/cyber/combobox.css\"\n\ntype ComboboxOption = { value: string; label: string; meta?: string; keywords?: string[]; disabled?: boolean }\n\n// A search field over a list: type to narrow it, and the letters that\n// matched light in the signal color. The popup's heading counts what's left\n// and says so to a screen reader; when nothing is, it says that instead.\n//\n// - `options`: each a `value` and a `label`, with an optional `meta` printed\n//   beside it (a role, a unit) that typing matches too.\n// - `empty` is the line shown when nothing matches.\n// - `hint`, `error` and `invalid` work as they do on Select.\n// - Everything else goes to the SDK's Combobox: `value`, `defaultValue`,\n//   `onValueChange`, `name`, `required`, `disabled`, `autoHighlight`.\nfunction Combobox({\n  label,\n  options,\n  placeholder = \"Search\",\n  empty = \"No match.\",\n  hint,\n  error,\n  invalid,\n  ...props\n}: Omit<Extract<ComboboxProps<string>, { multiple?: false }>, \"children\" | \"items\" | \"multiple\"> & {\n  label: string\n  options: ComboboxOption[]\n  placeholder?: string\n  empty?: string\n  hint?: string\n  error?: string\n  invalid?: boolean\n}) {\n  // The popup hangs from the whole framed control, not the bare input in it.\n  const [control, setControl] = React.useState<HTMLDivElement | null>(null)\n  const byValue = new Map(options.map((option) => [option.value, option]))\n\n  // The options as data on the root: the SDK filters them without rendering\n  // every row, and an agent can read the choices while the list is closed.\n  const items = options.map(({ value, label, meta, keywords, disabled }) => ({\n    value,\n    label,\n    keywords: meta ? [meta, ...(keywords ?? [])] : keywords,\n    disabled,\n  }))\n\n  return (\n    <Field data-kit=\"field\" invalid={invalid}>\n      <FieldLabel data-kit=\"label\">{label}</FieldLabel>\n      <SdkCombobox items={items} autoHighlight {...props}>\n        <div ref={setControl} data-kit=\"control\" data-frame=\"br\" data-frame-focus=\"within\">\n          <span data-kit=\"control-icon\" aria-hidden>\n            <Search />\n          </span>\n          {/* The frame lights for whichever of these has focus, so none of\n              them draws a ring of its own. */}\n          <ComboboxInput placeholder={placeholder} data-focus-quiet=\"\" />\n          <ComboboxClear data-kit=\"combobox-clear\" data-focus-quiet=\"\" aria-label={`Clear ${label}`}>\n            <X aria-hidden />\n          </ComboboxClear>\n          <ComboboxTrigger data-kit=\"combobox-trigger\" data-focus-quiet=\"\" aria-label={`Show ${label} options`}>\n            <ChevronDown aria-hidden />\n          </ComboboxTrigger>\n        </div>\n        <ComboboxContent data-kit=\"popup\" data-frame=\"tr bl\" anchor={control} sideOffset={4}>\n          <ComboboxStatus data-kit=\"combobox-status\">\n            {(state) =>\n              state.count > 0 && (\n                <>\n                  <span data-kit=\"value\">{state.count}</span> {state.count === 1 ? \"match\" : \"matches\"}\n                </>\n              )\n            }\n          </ComboboxStatus>\n          {/* The empty part is a live region that stays in the popup, so the\n              padded line goes inside it and takes no room until it shows. */}\n          <ComboboxEmpty data-kit=\"combobox-empty\">\n            <div data-kit=\"popup-empty\">{empty}</div>\n          </ComboboxEmpty>\n          <ComboboxList data-kit=\"combobox-list\">\n            {(state) =>\n              state.items.map((entry) => {\n                // Only plain items are passed in, so anything else here is\n                // not ours to draw.\n                const option = typeof entry === \"object\" && \"value\" in entry ? byValue.get(String(entry.value)) : undefined\n                if (!option) return null\n                return (\n                  <ComboboxItem\n                    key={option.value}\n                    value={option.value}\n                    label={option.label}\n                    disabled={option.disabled}\n                    data-kit=\"popup-item\"\n                    data-focus-quiet=\"\"\n                  >\n                    <ComboboxItemText data-kit=\"combobox-item-text\">\n                      {(text) =>\n                        text.segments.map((segment, index) =>\n                          segment.match ? (\n                            <mark key={index} data-kit=\"combobox-match\">\n                              {segment.text}\n                            </mark>\n                          ) : (\n                            segment.text\n                          ),\n                        )\n                      }\n                    </ComboboxItemText>\n                    {option.meta && <span data-kit=\"combobox-item-meta\">{option.meta}</span>}\n                    <span data-kit=\"combobox-item-mark\">\n                      <ComboboxItemIndicator data-kit=\"popup-indicator\">\n                        <Check aria-hidden />\n                      </ComboboxItemIndicator>\n                    </span>\n                  </ComboboxItem>\n                )\n              })\n            }\n          </ComboboxList>\n        </ComboboxContent>\n      </SdkCombobox>\n      {hint && <FieldDescription data-kit=\"hint\">{hint}</FieldDescription>}\n      <FieldError data-kit=\"field-error\" match={invalid ? true : undefined}>\n        {error}\n      </FieldError>\n    </Field>\n  )\n}\n\nexport { Combobox }\nexport type { ComboboxOption }\n",
      "type": "registry:ui",
      "target": "@ui/combobox.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/combobox.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n/* The input sits in the shared control frame and the results in the shared\n   popup (field.css, popup.css); this is only what a combobox adds to them. */\n@layer cyber.ui {\n  /* The two keys at the end of the control: clear, and show the list. They\n     sit inside the frame, which lights for whichever of its children has\n     focus, so each also marks itself when it's the one. */\n  [data-skin=\"cyber\"] :is([data-kit=\"combobox-clear\"], [data-kit=\"combobox-trigger\"]) {\n    flex: none;\n    display: grid;\n    place-items: center;\n    width: 24px;\n    height: 24px;\n    margin-inline-end: -4px;\n    padding: 0;\n    border: 0;\n    background: none;\n    color: var(--cy-ink);\n    cursor: pointer;\n    transition:\n      color var(--cy-t-fast) linear,\n      background-color var(--cy-t-fast) linear;\n\n    @media (pointer: coarse) {\n      width: 36px;\n      height: 36px;\n    }\n\n    & svg {\n      width: 16px;\n      height: 16px;\n    }\n\n    @media (hover: hover) {\n      &:hover:not([data-disabled]) {\n        color: var(--cy-ink-hi);\n        background: var(--cy-fill-hover);\n      }\n    }\n\n    &:focus-visible {\n      color: var(--cy-on-solid);\n      background: var(--cy-signal);\n    }\n\n    &[data-disabled] {\n      color: var(--cy-ink-mute);\n      cursor: not-allowed;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"combobox-clear\"] svg {\n    width: 14px;\n    height: 14px;\n  }\n\n  /* The chevron turns over, in steps, as the list opens. */\n  [data-skin=\"cyber\"] [data-kit=\"combobox-trigger\"] {\n    & svg {\n      transition: rotate var(--cy-t) var(--cy-ease-step);\n    }\n\n    &[data-open] {\n      color: var(--cy-ink-hi);\n\n      & svg {\n        rotate: 180deg;\n      }\n    }\n  }\n\n  /* The popup's heading: how many are left. A live region, so it's said as\n     well as shown. Nothing left is the empty line's to say. */\n  [data-skin=\"cyber\"] [data-kit=\"combobox-status\"] {\n    padding: 6px 12px 4px;\n    font-family: var(--cy-mono);\n    font-size: 10px;\n    letter-spacing: 0.08em;\n    text-transform: uppercase;\n    color: var(--cy-ink-mute);\n\n    &:empty {\n      display: none;\n    }\n\n    & [data-kit=\"value\"] {\n      font-size: inherit;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"combobox-list\"] {\n    display: grid;\n  }\n\n  /* A row: the name takes the room; the meta and the mark keep their own\n     columns, so they line up down the list. */\n  [data-skin=\"cyber\"] [data-kit=\"combobox-item-text\"] {\n    flex: 1;\n    min-width: 0;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n  }\n\n  /* The letters that matched: the signal color, and underlined, so the\n     emphasis doesn't rest on color. */\n  [data-skin=\"cyber\"] [data-kit=\"combobox-match\"] {\n    background: none;\n    color: var(--cy-signal);\n    text-decoration: underline;\n    text-decoration-thickness: 1px;\n    text-underline-offset: 3px;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"combobox-item-meta\"] {\n    flex: none;\n    font-family: var(--cy-mono);\n    font-size: 10px;\n    font-weight: 400;\n    letter-spacing: 0;\n    color: var(--cy-ink-mute);\n\n    [data-highlighted] > & {\n      color: var(--cy-ink-hi);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"combobox-item-mark\"] {\n    flex: none;\n    display: grid;\n    place-items: center;\n    width: 14px;\n    height: 14px;\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/combobox.css"
    }
  ],
  "type": "registry:ui"
}
