{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "control-group",
  "title": "Control Group",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/control-group/ControlGroup.tsx",
      "content": "import * as React from 'react'\nimport { View, type ViewProps } from 'react-native'\nimport { cn } from '@/lib/utils'\n\nexport type ControlGroupOrientation = 'horizontal' | 'vertical'\nexport type ControlGroupItemPosition = 'first' | 'middle' | 'last' | 'only'\n\nexport interface ControlGroupContextValue {\n  orientation: ControlGroupOrientation\n  disabled: boolean\n}\n\nexport interface ControlGroupItemContextValue {\n  position: ControlGroupItemPosition\n  orientation: ControlGroupOrientation\n  disabled: boolean\n}\n\nconst ControlGroupContext = React.createContext<ControlGroupContextValue>({\n  orientation: 'horizontal',\n  disabled: false,\n})\n\nconst ControlGroupItemContext = React.createContext<ControlGroupItemContextValue>({\n  position: 'only',\n  orientation: 'horizontal',\n  disabled: false,\n})\n\nexport function useControlGroup(): ControlGroupContextValue {\n  return React.useContext(ControlGroupContext)\n}\n\nexport function useControlGroupItem(): ControlGroupItemContextValue {\n  return React.useContext(ControlGroupItemContext)\n}\n\nfunction cornerClassFor(position: ControlGroupItemPosition, orientation: ControlGroupOrientation): string {\n  if (position === 'only') return 'rounded-md'\n  if (position === 'middle') return 'rounded-none'\n  if (orientation === 'horizontal') {\n    return position === 'first' ? 'rounded-l-md rounded-r-none' : 'rounded-r-md rounded-l-none'\n  }\n  return position === 'first' ? 'rounded-t-md rounded-b-none' : 'rounded-b-md rounded-t-none'\n}\n\nexport interface ControlGroupProps extends ViewProps {\n  orientation?: ControlGroupOrientation\n  /** Disables all items inside the group without imposing selection semantics. */\n  disabled?: boolean\n  /** Renders hairline dividers between adjacent items. Defaults to `true`. */\n  dividers?: boolean\n  className?: string\n}\n\nconst ControlGroup = React.forwardRef<React.ComponentRef<typeof View>, ControlGroupProps>(\n  ({ orientation = 'horizontal', disabled = false, dividers = true, className, children, ...props }, ref) => {\n    const validChildren = React.Children.toArray(children).filter(React.isValidElement)\n    const count = validChildren.length\n\n    const groupContext = React.useMemo<ControlGroupContextValue>(\n      () => ({ orientation, disabled }),\n      [orientation, disabled],\n    )\n\n    return (\n      <ControlGroupContext.Provider value={groupContext}>\n        <View\n          ref={ref}\n          className={cn(\n            'overflow-hidden rounded-md border border-border',\n            orientation === 'horizontal' ? 'flex-row items-stretch' : 'flex-col',\n            disabled && 'opacity-50',\n            className,\n          )}\n          {...props}\n        >\n          {validChildren.map((child, index) => {\n            const position: ControlGroupItemPosition =\n              count <= 1 ? 'only' : index === 0 ? 'first' : index === count - 1 ? 'last' : 'middle'\n            const itemKey = child.key ?? index\n\n            return (\n              <React.Fragment key={itemKey}>\n                {dividers && index > 0 ? (\n                  <View\n                    aria-hidden\n                    accessibilityElementsHidden\n                    importantForAccessibility=\"no-hide-descendants\"\n                    className={cn(\n                      'shrink-0 bg-border',\n                      orientation === 'horizontal' ? 'w-px self-stretch' : 'h-px w-full',\n                    )}\n                  />\n                ) : null}\n                <ControlGroupItemContext.Provider value={{ position, orientation, disabled }}>\n                  {child}\n                </ControlGroupItemContext.Provider>\n              </React.Fragment>\n            )\n          })}\n        </View>\n      </ControlGroupContext.Provider>\n    )\n  },\n)\nControlGroup.displayName = 'ControlGroup'\n\nexport interface ControlGroupItemProps extends ViewProps {\n  disabled?: boolean\n  className?: string\n}\n\nconst ControlGroupItem = React.forwardRef<React.ComponentRef<typeof View>, ControlGroupItemProps>(\n  ({ disabled, className, children, ...props }, ref) => {\n    const group = useControlGroup()\n    const item = useControlGroupItem()\n    const effectiveDisabled = Boolean(group.disabled || disabled)\n\n    const mergedContext = React.useMemo<ControlGroupItemContextValue>(\n      () => ({\n        position: item.position,\n        orientation: item.orientation,\n        disabled: effectiveDisabled,\n      }),\n      [item.position, item.orientation, effectiveDisabled],\n    )\n\n    const resolvedChildren = React.useMemo(() => {\n      if (React.isValidElement<{ disabled?: boolean }>(children) && children.type !== React.Fragment) {\n        const mergedDisabled = Boolean(effectiveDisabled || children.props.disabled)\n        if (mergedDisabled || 'disabled' in children.props) {\n          return React.cloneElement(children, { disabled: mergedDisabled })\n        }\n      }\n      return children\n    }, [children, effectiveDisabled])\n\n    return (\n      <ControlGroupItemContext.Provider value={mergedContext}>\n        <View\n          ref={ref}\n          className={cn(\n            'overflow-hidden',\n            cornerClassFor(item.position, item.orientation),\n            !group.disabled && effectiveDisabled && 'opacity-50',\n            className,\n          )}\n          {...props}\n        >\n          {resolvedChildren}\n        </View>\n      </ControlGroupItemContext.Provider>\n    )\n  },\n)\nControlGroupItem.displayName = 'ControlGroupItem'\n\nexport { ControlGroup, ControlGroupItem }\n",
      "type": "registry:ui",
      "target": "~/components/ui/control-group/ControlGroup.tsx"
    },
    {
      "path": "packages/registry-native/components/control-group/index.ts",
      "content": "export {\n  ControlGroup,\n  ControlGroupItem,\n  useControlGroup,\n  useControlGroupItem,\n  type ControlGroupContextValue,\n  type ControlGroupItemContextValue,\n  type ControlGroupItemPosition,\n  type ControlGroupItemProps,\n  type ControlGroupOrientation,\n  type ControlGroupProps,\n} from './ControlGroup'\n",
      "type": "registry:ui",
      "target": "~/components/ui/control-group/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "Structural connected control group with corner-radius ownership, optional hairline dividers, and shared disabled propagation without imposing selection semantics.",
  "categories": [
    "layout",
    "control"
  ]
}