{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "segmented-control",
  "title": "Segmented control",
  "description": "A row of segments with an indicator that slides to the choice.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/segmented-control.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Field, FieldDescription, FieldLabel } from \"@ui-sdk/react/field\"\nimport {\n  SegmentedControl as SdkSegmentedControl,\n  SegmentedControlIndicator,\n  SegmentedControlItem,\n} from \"@ui-sdk/react/segmented-control\"\nimport \"@/registry/cyber/ui/cyber/segmented-control.css\"\n\ntype Segment<T extends string = string> = {\n  value: T\n  label: string\n  icon?: React.ReactNode\n  disabled?: boolean\n}\n\n// A switch with more than two positions: a cut track, and a lit block that\n// snaps across it to the chosen segment. It's a radio group underneath, so\n// it has one tab stop and the arrow keys move the choice.\n//\n// - `options` are the segments. A bare string is both the value and the\n//   label; an object can add an `icon` or be `disabled`.\n// - `iconOnly` shows only the icons. Every option still needs its `label`,\n//   which becomes the segment's name.\n// - `fill` stretches the track across its container, in equal segments.\nfunction SegmentedControl<T extends string = string>({\n  label,\n  hint,\n  options,\n  iconOnly,\n  fill,\n  ...props\n}: Omit<React.ComponentProps<typeof SdkSegmentedControl<T>>, \"children\"> & {\n  label: string\n  hint?: string\n  options: (T | Segment<T>)[]\n  iconOnly?: boolean\n  fill?: boolean\n}) {\n  return (\n    <Field data-kit=\"field\">\n      <FieldLabel data-kit=\"label\">{label}</FieldLabel>\n      <SdkSegmentedControl<T>\n        data-kit=\"segmented-control\"\n        data-frame=\"tl br\"\n        data-fill={fill ? \"\" : undefined}\n        data-icon-only={iconOnly ? \"\" : undefined}\n        {...props}\n      >\n        <SegmentedControlIndicator data-kit=\"segmented-control-indicator\" data-frame=\"tl br\" />\n        {options.map((entry) => {\n          const option: Segment<T> = typeof entry === \"string\" ? { value: entry, label: entry } : entry\n          return (\n            <SegmentedControlItem\n              key={option.value}\n              data-kit=\"segmented-control-item\"\n              data-press-flash=\"\"\n              value={option.value}\n              disabled={option.disabled}\n              aria-label={iconOnly ? option.label : undefined}\n            >\n              {option.icon && (\n                <span data-kit=\"segmented-control-icon\" aria-hidden>\n                  {option.icon}\n                </span>\n              )}\n              {!iconOnly && option.label}\n            </SegmentedControlItem>\n          )\n        })}\n      </SdkSegmentedControl>\n      {hint && <FieldDescription data-kit=\"hint\">{hint}</FieldDescription>}\n    </Field>\n  )\n}\n\nexport { SegmentedControl }\nexport type { Segment }\n",
      "type": "registry:ui",
      "target": "@ui/segmented-control.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/segmented-control.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n@layer cyber.ui {\n  /* The track: a cut frame the segments sit in, with a little room around\n     them so the lit block reads as something inside it, like the switch's. */\n  [data-skin=\"cyber\"] [data-kit=\"segmented-control\"] {\n    --frame-cut: var(--cy-cut-sm);\n    --frame-line: var(--cy-line-ctl);\n    --frame-fill: var(--cy-panel);\n    --frame-image: none;\n\n    justify-self: start;\n    display: inline-grid;\n    grid-auto-flow: column;\n    grid-auto-columns: minmax(0, 1fr);\n    max-width: 100%;\n    padding: 3px;\n\n    &[data-fill] {\n      justify-self: stretch;\n      display: grid;\n    }\n\n    &[data-orientation=\"vertical\"] {\n      grid-auto-flow: row;\n      grid-auto-rows: minmax(0, 1fr);\n    }\n\n    &[data-disabled] {\n      --frame-line: var(--cy-line-deco);\n      --frame-image: repeating-linear-gradient(135deg, transparent 0 5px, var(--cy-line-deco) 5px 6px);\n    }\n  }\n\n  /* The lit block. The SDK measures the chosen segment and hands over its\n     box; the block is moved there with a translate, so only a transform\n     animates. Segments are equal, so its size never has to. */\n  [data-skin=\"cyber\"] [data-kit=\"segmented-control-indicator\"] {\n    --frame-cut: 5px;\n    --frame-line: var(--cy-line-hot);\n    --frame-fill: var(--cy-fill-active);\n    --frame-image: none;\n\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: var(--segmented-control-indicator-width, 0px);\n    height: var(--segmented-control-indicator-height, 0px);\n    translate: var(--segmented-control-indicator-left, 0px) var(--segmented-control-indicator-top, 0px);\n    pointer-events: none;\n    transition: translate var(--cy-t) var(--cy-ease-snap);\n\n    /* The mark that says \"this one\", in the signal color like every\n       selection mark: a tick on the block's foot. */\n    &::after {\n      content: \"\";\n      position: absolute;\n      inset: auto auto 1px 50%;\n      width: 10px;\n      height: 2px;\n      translate: -50% 0;\n      background: var(--cy-signal);\n    }\n\n    [data-disabled] > & {\n      --frame-line: var(--cy-line-deco);\n      --frame-fill: var(--cy-panel-2);\n\n      &::after {\n        background: var(--cy-ink-mute);\n      }\n    }\n\n    /* Nothing chosen: the SDK gives it no box, so there's nothing to draw. */\n    &:not([style*=\"indicator-width\"]) {\n      display: none;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"segmented-control-item\"] {\n    position: relative;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    min-width: 0;\n    height: calc(var(--cy-h) - 8px);\n    padding: 0 14px;\n    border: 0;\n    background: none;\n    font-size: var(--cy-text-sm);\n    font-weight: 600;\n    line-height: 1;\n    letter-spacing: var(--cy-track);\n    text-transform: uppercase;\n    white-space: nowrap;\n    color: var(--cy-ink);\n    cursor: pointer;\n    user-select: none;\n    transition:\n      background-color var(--cy-t-fast) linear,\n      color var(--cy-t-fast) linear;\n\n    @media (hover: hover) {\n      &:hover:not([data-checked], [data-disabled], [data-readonly]) {\n        background-color: var(--cy-fill-hover);\n        color: var(--cy-ink-hi);\n      }\n    }\n\n    &[data-checked] {\n      color: var(--cy-ink-hi);\n    }\n\n    &[data-readonly] {\n      cursor: default;\n    }\n\n    &[data-disabled] {\n      color: var(--cy-ink-mute);\n      cursor: not-allowed;\n\n      /* One segment off in a live track: hatched as well as dimmed. */\n      [data-kit=\"segmented-control\"]:not([data-disabled]) > & {\n        background-image: repeating-linear-gradient(135deg, transparent 0 5px, var(--cy-line-deco) 5px 6px);\n      }\n    }\n\n    [data-icon-only] > & {\n      min-width: calc(var(--cy-h) + 4px);\n      padding: 0 10px;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"segmented-control-icon\"] {\n    flex: none;\n    display: grid;\n    place-items: center;\n\n    & svg {\n      width: 16px;\n      height: 16px;\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/segmented-control.css"
    }
  ],
  "type": "registry:ui"
}
