// Copyright (c) Meta Platforms, Inc. and affiliates. 'use client'; /** * @file useIndicator.ts * @input Indicator name * @output Exports useIndicator hook for theme-aware indicator components * @position Client hook used by controls that render a selection visual */ import { useThemeName } from "../theme/useTheme.js"; import { getIndicator, type CoreIndicatorName } from "./indicatorRegistry.js"; import type { IndicatorComponent, IndicatorMap, IndicatorName } from "./types.js"; /** * Resolve an indicator component from the nearest ``. * * A core indicator always resolves. A name contributed by augmentation * resolves only if a theme supplies it, so that overload returns * `| undefined` — see {@link getIndicator}. * * @example * ``` * const Checkbox = useIndicator('checkbox'); * return ; * ``` */ export function useIndicator(name: N): IndicatorComponent; export function useIndicator(name: N): IndicatorComponent | undefined; export function useIndicator(name: IndicatorName): IndicatorComponent | undefined { return getIndicator(name, useThemeName()); }