import { useWidgetShallow } from './widget-store-registry' import type { WidgetState } from './types' /** * Reactive read of a single transform's `enabled` flag from the * per-widget store. Returns `false` if the transform hasn't been * registered yet (i.e., the action component hasn't mounted) — safe * default for "the feature is off". * * Used by widget composers that want to react to an action's on/off * cycle without having the widget primitive import the action. For * example, the `CategoryWidget` storybook composer wires the * SearcherToggle's open state into `` * so the library primitive stays renderer-agnostic. * * Magic-string `transformId` is intentional — it lives at the composer * layer where the action is already imported by JSX, so the string * appears alongside the same name in the toolbox. */ export function useTransformEnabled(id: string, transformId: string): boolean { return useWidgetShallow( id, (s: WidgetState) => s.transformStates?.[transformId]?.enabled === true, ) }