{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "aspect-ratio", "type": "registry:ui", "title": "Aspect Ratio", "description": "Aspect Ratio from @pitsi-ui/native for native projects.", "dependencies": [], "registryDependencies": [], "files": [ { "path": "registry/native-ui/src/components/aspect-ratio/aspect-ratio.tsx", "content": "import { forwardRef, type ReactNode } from \"react\";\nimport { View, type ViewProps, type ViewStyle } from \"react-native\";\n\nexport interface AspectRatioRootProps extends ViewProps {\n children?: ReactNode;\n className?: string;\n ratio?: number | string;\n}\n\nfunction resolveAspectRatio(ratio: number | string | undefined) {\n if (typeof ratio === \"number\" && Number.isFinite(ratio) && ratio > 0) {\n return ratio;\n }\n\n if (typeof ratio === \"string\") {\n const parts = ratio.split(\"/\");\n const width = Number(parts[0]?.trim());\n const height = Number(parts[1]?.trim());\n\n if (Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0) {\n return width / height;\n }\n\n const parsed = Number(ratio);\n\n if (Number.isFinite(parsed) && parsed > 0) {\n return parsed;\n }\n }\n\n return 1;\n}\n\nconst AspectRatioRoot = forwardRef(\n ({ children, className, ratio, style, ...props }, ref) => {\n const aspectRatio = resolveAspectRatio(ratio);\n const ratioStyle: ViewStyle = { aspectRatio };\n\n return (\n \n {children}\n \n );\n },\n);\n\nAspectRatioRoot.displayName = \"PitsiUINative.AspectRatio\";\n\nexport { AspectRatioRoot };\n", "type": "registry:ui", "target": "@components/pitsi-ui/native-ui/src/components/aspect-ratio/aspect-ratio.tsx" }, { "path": "registry/native-ui/src/components/aspect-ratio/index.ts", "content": "import type { ComponentProps } from \"react\";\n\nimport { AspectRatioRoot } from \"./aspect-ratio\";\n\nexport const AspectRatio = Object.assign(AspectRatioRoot, {\n Root: AspectRatioRoot,\n});\n\nexport type AspectRatio = {\n Props: ComponentProps;\n RootProps: ComponentProps;\n};\n\nexport type {\n AspectRatioRootProps,\n AspectRatioRootProps as AspectRatioProps,\n} from \"./aspect-ratio\";\nexport { AspectRatioRoot };\n", "type": "registry:ui", "target": "@components/pitsi-ui/native-ui/src/components/aspect-ratio/index.ts" } ], "categories": [ "native", "react-native", "ui" ], "meta": { "package": "@pitsi-ui/native", "packageSlug": "native-ui", "platform": "native" } }