{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toggle-group",
  "title": "Toggle group",
  "description": "Toggles that share one value, one or several at a time.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json",
    "https://www.cyberspec.dev/r/toggle.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/toggle-group.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ToggleGroup as SdkToggleGroup } from \"@ui-sdk/react/toggle\"\nimport { Toggle, type ToggleSize } from \"@/registry/cyber/ui/toggle\"\nimport \"@/registry/cyber/ui/cyber/toggle-group.css\"\n\ntype ToggleOption<T extends string = string> = {\n  value: T\n  label: string\n  icon?: React.ReactNode\n  /** Shows only the icon; the label becomes the key's name. */\n  iconOnly?: boolean\n  disabled?: boolean\n}\n\n// The cuts of a strip sit on its far side: under a row, and at the two ends\n// of a column.\nfunction frameAt(index: number, count: number, vertical: boolean) {\n  if (count === 1) return \"notch br\"\n  if (index === 0) return vertical ? \"tl\" : \"bl\"\n  return index === count - 1 ? \"br\" : \"mid\"\n}\n\nconst two = (n: number) => String(n).padStart(2, \"0\")\n\n// Toggles in one strip, sharing one value: the modes of a weapon, the layers\n// of a scan. One tab stop; the arrow keys move along it, and Space or Enter\n// presses.\n//\n// - `label` is printed over the strip and names the group.\n// - By default one option is pressed at a time, and pressing it again\n//   clears it; `deselectable={false}` keeps one pressed.\n// - `multiple` lets several stay pressed, and prints how many are (02/04)\n//   beside the label.\n// - `orientation=\"vertical\"` stacks the options as rows.\n//\n// The value is always an array, as ui-sdk's ToggleGroup has it; the rest of\n// its props (`value`, `defaultValue`, `onValueChange`, `disabled`, `loop`,\n// `controller`) pass through.\nfunction ToggleGroup<T extends string = string>({\n  label,\n  options,\n  size = \"md\",\n  multiple,\n  orientation,\n  ...props\n}: Omit<React.ComponentProps<typeof SdkToggleGroup<T>>, \"children\"> & {\n  label: string\n  options: ToggleOption<T>[]\n  size?: ToggleSize\n}) {\n  const id = React.useId()\n  const vertical = orientation === \"vertical\"\n  return (\n    <SdkToggleGroup<T> data-kit=\"toggle-group\" aria-labelledby={id} multiple={multiple} orientation={orientation} {...props}>\n      {(state) => (\n        <>\n          <span id={id} data-kit=\"toggle-group-label\">\n            {label}\n          </span>\n          {/* Decoration: each toggle already says whether it's pressed. */}\n          {multiple && (\n            <span data-kit=\"toggle-group-count\" aria-hidden>\n              {two(state.value.length)}/{two(options.length)}\n            </span>\n          )}\n          <div data-kit=\"toggle-group-keys\">\n            {options.map((option, index) => (\n              <Toggle\n                key={option.value}\n                value={option.value}\n                size={size}\n                icon={option.icon}\n                disabled={option.disabled}\n                aria-label={option.iconOnly ? option.label : undefined}\n                data-frame={frameAt(index, options.length, vertical)}\n                data-joined=\"\"\n              >\n                {option.iconOnly ? undefined : option.label}\n              </Toggle>\n            ))}\n          </div>\n        </>\n      )}\n    </SdkToggleGroup>\n  )\n}\n\nexport { ToggleGroup }\nexport type { ToggleOption }\n",
      "type": "registry:ui",
      "target": "@ui/toggle-group.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/toggle-group.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n@layer cyber.ui {\n  /* A caption over a strip of toggles: the label at the leading end, the\n     count of what's on at the other. The toggles are toggle.css's; this only\n     joins them. */\n  [data-skin=\"cyber\"] [data-kit=\"toggle-group\"] {\n    display: inline-grid;\n    grid-template-columns: 1fr auto;\n    align-items: baseline;\n    gap: 5px 12px;\n    max-width: 100%;\n    min-width: 0;\n    text-align: start;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"toggle-group-label\"] {\n    grid-column: 1;\n    font-size: var(--cy-text-sm);\n    font-weight: 600;\n    line-height: 1.2;\n    letter-spacing: var(--cy-track);\n    text-transform: uppercase;\n    color: var(--cy-ink);\n\n    [data-disabled] > & {\n      color: var(--cy-ink-mute);\n    }\n  }\n\n  /* How many are on, of how many: a readout, so it's in the signal color. */\n  [data-skin=\"cyber\"] [data-kit=\"toggle-group-count\"] {\n    grid-column: 2;\n    font-family: var(--cy-mono);\n    font-size: var(--cy-text-xs);\n    line-height: 1.2;\n    color: var(--cy-signal);\n\n    [data-disabled] > & {\n      color: var(--cy-ink-mute);\n    }\n  }\n\n  /* The strip. Each cell keeps its own frame, laid edge over edge with the\n     next, so neighbours share one line. */\n  [data-skin=\"cyber\"] [data-kit=\"toggle-group-keys\"] {\n    grid-column: 1 / -1;\n    display: flex;\n    min-width: 0;\n    /* The cells restack as they light, and that stays inside the strip. */\n    isolation: isolate;\n\n    & > * {\n      flex: 1 1 auto;\n    }\n\n    & > * + * {\n      margin-inline-start: -1px;\n    }\n\n    /* The shared line belongs to whichever cell is hot: pressed cells come\n       forward, the one under the pointer or the keyboard further still, and\n       a dead one drops back. */\n    & > [data-pressed] {\n      z-index: 1;\n    }\n    & > :is(:hover, :active, :focus-visible) {\n      z-index: 2;\n    }\n    & > [data-disabled] {\n      z-index: -1;\n    }\n\n    [data-orientation=\"vertical\"] > & {\n      flex-direction: column;\n\n      & > * + * {\n        margin-inline-start: 0;\n        margin-block-start: -1px;\n      }\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/toggle-group.css"
    }
  ],
  "type": "registry:ui"
}
