"use client" import * as React from "react" import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui" import { cn } from "../../lib/utils" /** * `ToggleGroupControl` and `ToggleGroupControlOption` replace * `@wordpress/components`' `__experimentalToggleGroupControl` / `...Option` - **1 import**, two * usages in `QuestionnairePage`, built on Radix's ToggleGroup. * * AN ADAPTER, NOT A RENAME, AND THE ONE THAT WOULD HAVE BITTEN IS DESELECTION. A Radix single * ToggleGroup lets you click the ACTIVE item to turn it off, and reports `""`. WordPress's control * does not - the current segment stays chosen. Passing that `""` through would set * `segment` to an empty string and the page would render neither the details tab nor the items tab. * The empty value is swallowed here, which is what keeps the swap safe. * * `onChange` hands back the VALUE, which is both WP's contract and Radix's, so the two call sites * (`setSegment` and a react-hook-form `field.onChange`) survive untouched. * * `isBlock` is WP's "share the width equally". Options always flex; `isBlock` is what makes the * track full width rather than content width. * * `__nextHasNoMarginBottom` and `__next40pxDefaultSize` are deliberately not accepted. Call sites * drop them. */ export interface ToggleGroupControlProps { label?: React.ReactNode help?: React.ReactNode value?: string /** WP's contract: the VALUE. Never fires with an empty string. */ onChange?: (value: string) => void /** Fill the available width and share it between the options. */ isBlock?: boolean disabled?: boolean className?: string children: React.ReactNode } function ToggleGroupControl({ label, help, value, onChange, isBlock = false, disabled, className, children, }: ToggleGroupControlProps) { // The group is labelled by its own text rather than a `