{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "components-color-swatches",
  "type": "registry:component",
  "title": "Color swatches",
  "description": "One colour chosen from a fixed row",
  "author": "sudo-kw <https://github.com/sudo-kw>",
  "dependencies": [
    "@gpuix/native@0.11.0",
    "@gpuix/react@0.11.0",
    "effect@4.1.2",
    "react@^19.2.4"
  ],
  "registryDependencies": [
    "https://gpuixui.sudokw.com/gpuix-primitives.json",
    "https://gpuixui.sudokw.com/gpuix-tokens.json"
  ],
  "files": [
    {
      "path": "packages/components/src/color-swatches.tsx",
      "target": "@ui/gpuixui/components/color-swatches.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { Props } from \"@gpuix/react\";\nimport * as Arr from \"effect/Array\";\nimport type { ReactNode } from \"react\";\nimport { Button as Action } from \"../primitives/button.js\";\nimport { useTheme } from \"./internal/theme.js\";\n\nexport interface ColorSwatchesProps extends Omit<Props, \"children\"> {\n  readonly label: string;\n\n  readonly colors: ReadonlyArray<string>;\n\n  readonly value?: string;\n\n  readonly onValueChange?: (color: string) => void;\n\n  readonly size?: number;\n}\n\nexport const ColorSwatches = ({\n  label,\n  colors,\n  value,\n  onValueChange,\n  size = 16,\n  testId,\n  style,\n  ...rest\n}: ColorSwatchesProps): ReactNode => {\n  const theme = useTheme();\n  const ring = size + 8;\n  return (\n    <div\n      role=\"radiogroup\"\n      aria-label={label}\n      testId={testId}\n      {...rest}\n      style={{\n        display: \"flex\",\n        flexDirection: \"row\",\n        alignItems: \"center\",\n        gap: 6,\n        ...style,\n      }}\n    >\n      {Arr.map(colors, (color) => {\n        const selected = color === value;\n        return (\n          <Action\n            key={color}\n            variant=\"ghost\"\n            label={color}\n            tabIndex={selected ? 0 : -1}\n            aria-checked={selected}\n            {...(testId === undefined ? {} : { testId: `${testId}-${color}` })}\n            onActivate={() => onValueChange?.(color)}\n            style={{\n              width: ring,\n              height: ring,\n              minWidth: ring,\n              flexShrink: 0,\n              paddingLeft: 0,\n              paddingRight: 0,\n              borderRadius: ring / 2,\n              borderWidth: selected ? theme.borderWidth.strong : 0,\n              borderColor: color,\n            }}\n          >\n            <div\n              style={{\n                width: size,\n                height: size,\n                borderRadius: size / 2,\n                flexShrink: 0,\n                pointerEvents: \"none\",\n                backgroundColor: color,\n              }}\n            />\n          </Action>\n        );\n      })}\n    </div>\n  );\n};\n\nexport const colorSwatchesMeta = {\n  name: \"Color swatches\",\n  tier: 2,\n  status: \"done\",\n  gpuixSupport: \"yes\",\n  limitations: [],\n  docs: \"docs/color-swatches.mdx\",\n  example: \"examples/color-swatches.example.tsx\",\n  testFile: \"src/behaviour/color-swatches.test.tsx\",\n} as const;\n"
    },
    {
      "path": "packages/components/src/internal/theme.ts",
      "target": "@ui/gpuixui/components/internal/theme.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport * as Schema from \"effect/Schema\";\nimport {\n  alpha,\n  avatarPixels,\n  avatarSize,\n  brandTextOn,\n  controlFocusRing,\n  controlHeight,\n  controlPaddingX,\n  currentPlatform,\n  darkTheme,\n  disabledAction,\n  disabledOpacity,\n  elevationShadow,\n  filledHover,\n  filledPressed,\n  findHighlight,\n  focusRing,\n  keyboardFocusRing,\n  lightTheme,\n  nativeTextTheme,\n  pointerWash,\n  selectionOn,\n  statusTone,\n  syntaxColors,\n  targetSize,\n  textStyle,\n  type BoxShadow,\n  type ElevationLevel,\n  type FindHighlightSource,\n  type NativeTextFill,\n  type PlatformName,\n  type PointerWashSurface,\n  type StatusTone,\n  type SyntaxColors,\n  type SyntaxRole,\n  type TextRole,\n  type Theme,\n  type ThemeColors,\n} from \"../../tokens/index.js\";\n\nexport {\n  alpha,\n  avatarPixels,\n  avatarSize,\n  controlFocusRing,\n  controlHeight,\n  controlPaddingX,\n  currentPlatform,\n  darkTheme,\n  disabledAction,\n  disabledOpacity,\n  elevationShadow,\n  filledHover,\n  filledPressed,\n  findHighlight,\n  focusRing,\n  keyboardFocusRing,\n  lightTheme,\n  nativeTextTheme,\n  statusTone,\n  syntaxColors,\n  targetSize,\n  textStyle,\n};\nexport type {\n  BoxShadow,\n  ElevationLevel,\n  FindHighlightSource,\n  NativeTextFill,\n  PlatformName,\n  StatusTone,\n  SyntaxColors,\n  SyntaxRole,\n  TextRole,\n  Theme,\n};\nexport { ThemeProvider, useTheme } from \"../../tokens/react.js\";\n\nexport const keyboardRing = (theme: Theme, invalid = false): StyleDesc =>\n  controlFocusRing(theme, { invalid }) ?? {};\n\nexport interface ControlRingState {\n  readonly disabled?: boolean;\n\n  readonly invalid?: boolean;\n}\n\nexport const controlRing = (\n  theme: Theme,\n  state: ControlRingState = {},\n): StyleDesc => controlFocusRing(theme, state) ?? {};\n\nexport const pressWash = (theme: Theme, replaced: PointerWashSurface): string =>\n  pointerWash(theme, \"active\", replaced) ?? theme.colors.active;\n\nexport const selectionWash = (theme: Theme): StyleDesc => ({\n  selectionColor: theme.colors.selection,\n});\n\nexport const keepContent: StyleDesc = { keyboardFocusDim: false };\n\nexport const disabledFade = (\n  disabled: boolean,\n): { readonly opacity: number } | undefined =>\n  disabled ? { opacity: disabledOpacity } : undefined;\n\nconst Tones = Schema.Literals([\"info\", \"success\", \"warning\", \"danger\"]);\n\nexport type Tone = typeof Tones.Type;\n\nexport const toneOf = (value: unknown): Tone =>\n  Schema.is(Tones)(value) ? value : \"info\";\n\nexport interface ToneStyle {\n  readonly fg: string;\n  readonly bg: string;\n  readonly border: string;\n}\n\nconst TOKEN_TONE: Readonly<Record<Tone, StatusTone>> = {\n  info: \"info\",\n  success: \"success\",\n  warning: \"warning\",\n  danger: \"destructive\",\n};\n\nexport const tone = (theme: Theme, value: Tone): ToneStyle => {\n  const { background, border, foreground } = statusTone(\n    theme,\n    TOKEN_TONE[value],\n  );\n  return { bg: background, border, fg: foreground };\n};\n\nconst softRoles: Readonly<Record<Tone, keyof ThemeColors>> = {\n  info: \"infoSoft\",\n  success: \"successSoft\",\n  warning: \"warningSoft\",\n  danger: \"destructiveSoft\",\n};\n\nexport const messageLink = (theme: Theme, value: Tone): string =>\n  brandTextOn(theme, softRoles[value]);\n\nexport const messageSelection = (theme: Theme, value: Tone): string =>\n  selectionOn(theme, softRoles[value]);\n\nexport const toneSurface = (theme: Theme, value: Tone): StyleDesc => {\n  const { bg, border, fg } = tone(theme, value);\n  return {\n    backgroundColor: bg,\n    color: fg,\n    borderWidth: theme.borderWidth.thin,\n    borderColor: border,\n  };\n};\n"
    }
  ],
  "docs": "[Color swatches](https://gpuixui.sudokw.com/components/color-swatches) — These are GPUix native components: the files render through GPUix's reconciler against `@gpuix/react`, not the DOM, and need the per-platform `@gpuix/native` binding. The CLI installs the `@gpuixui/*` runtime the components import as registry items, so the copied tree resolves on its own; wrap it in `ThemeProvider` before it renders.",
  "meta": {
    "url": "/components/color-swatches",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}