import { reactNodeToString } from "../utils/index.js";
import { useRefWithInit } from "./useRefWithInit.js";
/**
 * Many base components (i.e. from Base UI) we use for "options" (radio buttons, select items, etc.)
 * have a required `value` prop, but we don't want to force consumers of GDS to provide one (saves
 * the mental overhead of naming something when it's not necessary). We also don't want to use an
 * empty string or `null` by default because the value has to be unique in the group the component
 * is in. We could generate a unique string with `useId`, but ideally, we want to be able to inspect
 * the value in the group's `onChange` and understand which option was selected. To achieve that,
 * this hook generates and returns a unique value from the passed `ReactNode` (often the `children`
 * prop of the component, but could be `label`, etc.). It is guaranteed to be unique even when
 * multiple options have the same label because the value is a stable object (thanks to
 * `useRefWithInit`) that contains the label as a property.
 */
export function useAutoValue(reactNode) {
    return useRefWithInit(() => ({ label: reactNodeToString(reactNode) })).current;
}
//# sourceMappingURL=useAutoValue.js.map