{"version":3,"file":"SettingsToggle.cjs","names":[],"sources":["../../../../../src/components/Form/Controls/SettingsToggle/SettingsToggle.tsx"],"sourcesContent":["/*\nCopyright 2025 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport {\n  type ComponentProps,\n  type ComponentRef,\n  forwardRef,\n  type PropsWithChildren,\n  useId,\n} from \"react\";\nimport { ToggleInput } from \"../Toggle\";\nimport { Label } from \"../../Label\";\nimport { HelpMessage } from \"../../Message\";\nimport { InlineField } from \"../../InlineField\";\nimport React from \"react\";\nimport { Control } from \"@radix-ui/react-form\";\n\ntype SettingsToggleProps = {\n  /**\n   * The CSS class name for the containing field.\n   */\n  className?: string;\n  /**\n   * The field name.\n   */\n  name: string;\n  label: string;\n  /**\n   * Optional help text to display below the setting.\n   */\n  helpMessage?: string;\n  /**\n   * Optional help text to display below the setting.\n   */\n  disabledMessage?: string;\n} & Omit<ComponentProps<typeof ToggleInput>, \"type\">;\n\n/**\n * A toggle component.\n */\nexport const SettingsToggleInput = forwardRef<\n  HTMLInputElement,\n  PropsWithChildren<SettingsToggleProps>\n>(function Toggle(\n  { className, label, helpMessage, disabledMessage, name, ...props },\n  ref,\n) {\n  const generatedId = useId();\n  const id = props.id ?? generatedId;\n  const content = (\n    <InlineField\n      className={className}\n      name={name}\n      control={<ToggleInput id={id} ref={ref} {...props} />}\n    >\n      <Label htmlFor={id}>{label}</Label>\n      {helpMessage && <HelpMessage>{helpMessage}</HelpMessage>}\n      {disabledMessage && props.disabled && (\n        <HelpMessage>{disabledMessage}</HelpMessage>\n      )}\n    </InlineField>\n  );\n  return content;\n});\n\n/**\n * A styled checkbox input wrapped in a `Control` component, for use in Radix forms.\n */\nexport const SettingsToggleControl = forwardRef<\n  ComponentRef<typeof SettingsToggleInput>,\n  ComponentProps<typeof SettingsToggleInput>\n>(function ToggleControl(props, ref) {\n  return (\n    <Control asChild>\n      <SettingsToggleInput ref={ref} {...props} />\n    </Control>\n  );\n});\n"],"mappings":";;;;;;;;;;;;;AA4CA,IAAa,uBAAA,GAAA,MAAA,YAGX,SAAS,OACT,EAAE,WAAW,OAAO,aAAa,iBAAiB,MAAM,GAAG,SAC3D,KACA;CACA,MAAM,eAAA,GAAA,MAAA,QAAqB;CAC3B,MAAM,KAAK,MAAM,MAAM;AAcvB,QAZE,iBAAA,GAAA,kBAAA,MAAC,oBAAA,aAAD;EACa;EACL;EACN,SAAS,iBAAA,GAAA,kBAAA,KAAC,eAAA,aAAD;GAAiB;GAAS;GAAK,GAAI;GAAS,CAAA;YAHvD;GAKE,iBAAA,GAAA,kBAAA,KAAC,cAAA,OAAD;IAAO,SAAS;cAAK;IAAc,CAAA;GAClC,eAAe,iBAAA,GAAA,kBAAA,KAAC,gBAAA,aAAD,EAAA,UAAc,aAA0B,CAAA;GACvD,mBAAmB,MAAM,YACxB,iBAAA,GAAA,kBAAA,KAAC,gBAAA,aAAD,EAAA,UAAc,iBAA8B,CAAA;GAElC;;EAGhB;;;;AAKF,IAAa,yBAAA,GAAA,MAAA,YAGX,SAAS,cAAc,OAAO,KAAK;AACnC,QACE,iBAAA,GAAA,kBAAA,KAAC,qBAAA,SAAD;EAAS,SAAA;YACP,iBAAA,GAAA,kBAAA,KAAC,qBAAD;GAA0B;GAAK,GAAI;GAAS,CAAA;EACpC,CAAA;EAEZ"}