{"version":3,"file":"form-field-group-context.mjs","names":[],"sources":["../../../../src/_common/form-control/form-field-group-context.ts"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport type React from 'react';\nimport { createContext, useContext } from 'react';\n\ntype FormFieldGroupControlType = 'checkbox' | 'radio';\n\ntype FormFieldGroupContextValue = {\n  controlType: FormFieldGroupControlType;\n  name?: string;\n  isDisabled: boolean;\n  isRequired: boolean;\n  hasError: boolean;\n  /** Selected radio value when the group is controlled. `null` means no selection. */\n  value?: string | null;\n  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n};\n\nconst FormFieldGroupContext = createContext<FormFieldGroupContextValue | null>(\n  null,\n);\n\nconst useFormFieldGroup = (controlType: FormFieldGroupControlType) => {\n  const context = useContext(FormFieldGroupContext);\n\n  return context?.controlType === controlType ? context : undefined;\n};\n\nexport {\n  FormFieldGroupContext,\n  type FormFieldGroupContextValue,\n  useFormFieldGroup,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,wBAAwB,cAC5B,IACF;AAEA,MAAM,qBAAqB,gBAA2C;CACpE,MAAM,UAAU,WAAW,qBAAqB;CAEhD,QAAA,YAAA,QAAA,YAAA,KAAA,IAAA,KAAA,IAAO,QAAS,iBAAgB,cAAc,UAAU,KAAA;AAC1D"}