{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "select",
  "title": "Select",
  "description": "A labelled trigger that opens a list of options to choose from.",
  "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/select.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Field, FieldDescription, FieldError, FieldLabel } from \"@ui-sdk/react/field\"\nimport {\n  Select as SdkSelect,\n  SelectContent,\n  SelectGroup,\n  SelectGroupLabel,\n  SelectItem,\n  SelectItemIndicator,\n  SelectSeparator,\n  SelectTrigger,\n  SelectValue,\n  type ListData,\n  type SelectProps,\n} from \"@ui-sdk/react/select\"\nimport { Check, ChevronDown } from \"lucide-react\"\nimport \"@/registry/cyber/ui/cyber/select.css\"\n\ntype SelectOption = { value: string; label: string; code?: string; disabled?: boolean }\ntype SelectOptionGroup = { label: string; options: SelectOption[] }\n\nconst isGroup = (entry: SelectOption | SelectOptionGroup): entry is SelectOptionGroup => \"options\" in entry\n\n// A labelled picker: the trigger sits in the shared control frame, with a\n// chevron that turns as the list opens, and the options float in the shared\n// popup. An option's `code` (a sector, a serial) prints beside it in the\n// list, and beside the chosen value in the trigger, as a readout.\n//\n// - `options` are flat, or grouped as `{ label, options }`; groups are ruled\n//   off from each other.\n// - `hint` sits under the control. `error` is the message shown, in yellow,\n//   while the field is invalid; pass `invalid` to show it from your own code.\n// - Everything else goes to the SDK's Select: `value`, `defaultValue`,\n//   `onValueChange`, `name`, `required`, `disabled`, `controller`.\nfunction Select({\n  label,\n  options,\n  hint,\n  error,\n  invalid,\n  placeholder = \"Select\",\n  ...props\n}: Omit<Extract<SelectProps<string>, { multiple?: false }>, \"children\" | \"items\" | \"multiple\"> & {\n  label: string\n  options: (SelectOption | SelectOptionGroup)[]\n  hint?: string\n  error?: string\n  invalid?: boolean\n}) {\n  const flat = options.flatMap((entry) => (isGroup(entry) ? entry.options : [entry]))\n  const codeOf = (value: unknown) => flat.find((option) => option.value === value)?.code\n\n  // The same options as data on the root, so the trigger can show a label,\n  // typing can find one, and an agent can read the choices, all before the\n  // list has ever opened.\n  const items: ListData<string> = options.map((entry) =>\n    isGroup(entry)\n      ? { type: \"group\", label: entry.label, items: entry.options.map(({ value, label, disabled }) => ({ value, label, disabled })) }\n      : { value: entry.value, label: entry.label, disabled: entry.disabled },\n  )\n\n  // A row takes real focus as the keys move, and its highlighted look (the\n  // lit fill and the signal bar) is the focus indicator, so it asks for no\n  // second ring around it.\n  const row = (option: SelectOption) => (\n    <SelectItem key={option.value} value={option.value} disabled={option.disabled} data-kit=\"popup-item\" data-focus-quiet=\"\">\n      <span data-kit=\"select-item-text\">{option.label}</span>\n      {option.code && (\n        <span data-kit=\"select-item-code\" aria-hidden>\n          {option.code}\n        </span>\n      )}\n      <span data-kit=\"select-item-mark\">\n        <SelectItemIndicator data-kit=\"popup-indicator\">\n          <Check aria-hidden />\n        </SelectItemIndicator>\n      </span>\n    </SelectItem>\n  )\n\n  return (\n    <Field data-kit=\"field\" invalid={invalid}>\n      <FieldLabel data-kit=\"label\">{label}</FieldLabel>\n      <SdkSelect items={items} placeholder={placeholder} {...props}>\n        <SelectTrigger data-kit=\"control\" data-frame=\"br\">\n          <SelectValue data-kit=\"select-value\">\n            {(state) => (\n              <>\n                <span data-kit=\"select-value-text\">{state.placeholder ? placeholder : state.label}</span>\n                {codeOf(state.value) && (\n                  <span data-kit=\"select-value-code\" aria-hidden>\n                    {codeOf(state.value)}\n                  </span>\n                )}\n              </>\n            )}\n          </SelectValue>\n          <span data-kit=\"select-chevron\" aria-hidden>\n            <ChevronDown />\n          </span>\n        </SelectTrigger>\n        <SelectContent data-kit=\"popup\" data-frame=\"tr bl\" sideOffset={4}>\n          {options.map((entry, index) =>\n            isGroup(entry) ? (\n              <React.Fragment key={entry.label}>\n                {index > 0 && <SelectSeparator data-kit=\"popup-separator\" />}\n                <SelectGroup data-kit=\"select-group\">\n                  <SelectGroupLabel data-kit=\"popup-label\">{entry.label}</SelectGroupLabel>\n                  {entry.options.map(row)}\n                </SelectGroup>\n              </React.Fragment>\n            ) : (\n              row(entry)\n            ),\n          )}\n        </SelectContent>\n      </SdkSelect>\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 { Select }\nexport type { SelectOption, SelectOptionGroup }\n",
      "type": "registry:ui",
      "target": "@ui/select.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/select.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n/* The trigger is the shared control frame and the list is the shared popup\n   (field.css, popup.css); this is only what a select adds to them. */\n@layer cyber.ui {\n  /* What the trigger reads: the chosen label, then its code as a readout. */\n  [data-skin=\"cyber\"] [data-kit=\"select-value\"] {\n    flex: 1;\n    display: flex;\n    align-items: baseline;\n    gap: 8px;\n    min-width: 0;\n    font-weight: 600;\n    letter-spacing: var(--cy-track);\n    text-transform: uppercase;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"select-value-text\"] {\n    flex: 1;\n    min-width: 0;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n  }\n\n  [data-skin=\"cyber\"] :is([data-kit=\"select-value-code\"], [data-kit=\"select-item-code\"]) {\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-signal);\n  }\n\n  /* The chevron turns over, in steps, as the list opens. */\n  [data-skin=\"cyber\"] [data-kit=\"select-chevron\"] {\n    flex: none;\n    display: grid;\n    place-items: center;\n    color: var(--cy-ink);\n    transition: rotate var(--cy-t) var(--cy-ease-step);\n\n    & svg {\n      width: 16px;\n      height: 16px;\n    }\n\n    [data-open] > & {\n      rotate: 180deg;\n      color: var(--cy-ink-hi);\n    }\n\n    [data-disabled] > & {\n      color: var(--cy-ink-mute);\n    }\n  }\n\n  /* A row: the name takes the room, the code and the mark keep their own\n     columns, so codes line up whether or not a row is the chosen one. */\n  [data-skin=\"cyber\"] [data-kit=\"select-item-text\"] {\n    flex: 1;\n    min-width: 0;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"select-item-code\"] {\n    color: var(--cy-ink-mute);\n\n    [data-selected] > & {\n      color: var(--cy-signal);\n    }\n    [data-highlighted] > & {\n      color: var(--cy-ink-hi);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"select-item-mark\"] {\n    flex: none;\n    display: grid;\n    place-items: center;\n    width: 14px;\n    height: 14px;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"select-group\"] {\n    display: grid;\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/select.css"
    }
  ],
  "type": "registry:ui"
}
