Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,45 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
||||
|
||||
import { RadioGroup as SubframeRadioGroup } from "~/ui/components/RadioGroup"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
// Subframe migration (strangler shim):
|
||||
// Keeps the original shadcn/Radix `RadioGroup` + `RadioGroupItem` API but renders the
|
||||
// Subframe design-system RadioGroup behind it.
|
||||
//
|
||||
// Notes / pitfalls:
|
||||
// - Subframe's RadioGroup is built on the SAME `@radix-ui/react-radio-group` package (it is a
|
||||
// peer dependency re-exported by `@subframe/core`), so the radio context is shared. This is
|
||||
// what lets existing consumers (e.g. `choicebox.tsx`) keep composing raw Radix
|
||||
// `RadioGroupItem` children inside this Root.
|
||||
// - Subframe's Root spreads `value`/`defaultValue`/`onValueChange` straight through to the
|
||||
// Radix Root, which natively supports both controlled and uncontrolled use — no extra state
|
||||
// shim is needed for the group itself.
|
||||
function RadioGroup({
|
||||
className,
|
||||
children,
|
||||
value,
|
||||
...props
|
||||
}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
|
||||
return (
|
||||
// Radix allows value={null}; Subframe's RadioGroup only accepts string | undefined.
|
||||
<SubframeRadioGroup className={cn("grid gap-3", className)} value={value ?? undefined} {...props}>
|
||||
{children}
|
||||
</SubframeRadioGroup>
|
||||
)
|
||||
}
|
||||
|
||||
// Maps the bare radio item onto Subframe's `RadioGroup.Option` (its `asChild` Radix Item with
|
||||
// the design-system radio markup). Public API is preserved as `React.ComponentProps<typeof
|
||||
// RadioGroupPrimitive.Item>`.
|
||||
function RadioGroupItem({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
|
||||
return <SubframeRadioGroup.Option className={cn(className)} {...props} />
|
||||
}
|
||||
|
||||
export { RadioGroup, RadioGroupItem }
|
||||
Reference in new issue
Block a user