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AAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE;YACvC,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YACjC,OAAO,CACN,IAAC,KAAK,IACL,OAAO,EAAE,OAAO,EAAE,EAClB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,IAEjB,KAAK,IAAI,KAAK,CACR,CACR,CAAC;QACH,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,CACN,kBAAU,GAAG,EAAC,MAAM,EAAC,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI;QAC/D,KAAK,IAAI,gBAAQ,OAAO,EAAE,MAAM,IAAG,KAAK,CAAU;QAClD,YAAY,EAAE,CACL,CACX,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import * as css from '../theme/default/radio-group.m.css';\nimport theme from '../middleware/theme';\nimport { Radio } from '../radio/index';\nimport { RenderResult } from '@dojo/framework/core/interfaces';\nimport { create, tsx } from '@dojo/framework/core/vdom';\nimport { radioGroup } from './middleware';\n\ntype RadioOptions = { value: string; label?: string }[];\n\nexport interface RadioGroupProperties {\n\t/** Initial value of the radio group */\n\tinitialValue?: string;\n\t/** Controlled value property */\n\tvalue?: string;\n\t/** The name attribute for this form group */\n\tname: string;\n\t/** Callback for the current value */\n\tonValue(value: string): void;\n\t/** Object containing the values / labels to create radios for */\n\toptions: RadioOptions;\n\t/** Disabled all inputs within this group */\n\tdisabled?: boolean;\n}\n\nexport interface RadioGroupChildren {\n\t/** Custom renderer for the radios, receives the radio group middleware and options */\n\tradios?(\n\t\tname: string,\n\t\tmiddleware: ReturnType<ReturnType<typeof radioGroup>['api']>,\n\t\toptions: RadioOptions,\n\t\tdisabled: boolean\n\t): RenderResult;\n\tlabel?: RenderResult;\n}\n\nconst factory = create({ radioGroup, theme })\n\t.properties<RadioGroupProperties>()\n\t.children<RadioGroupChildren | undefined>();\n\nexport const RadioGroup = factory(function RadioGroup({\n\tchildren,\n\tproperties,\n\tmiddleware: { radioGroup, theme }\n}) {\n\tconst {\n\t\tname,\n\t\toptions,\n\t\tonValue,\n\t\tvalue,\n\t\tinitialValue,\n\t\ttheme: themeCss,\n\t\tclasses,\n\t\tvariant,\n\t\tdisabled\n\t} = properties();\n\tconst [{ radios, label } = { radios: undefined, label: undefined }] = children();\n\tconst radio = radioGroup(onValue, initialValue || '', value);\n\tconst { root, legend } = theme.classes(css);\n\n\tfunction renderRadios() {\n\t\tif (radios) {\n\t\t\treturn radios(name, radio, options, !!disabled);\n\t\t}\n\t\treturn options.map(({ value, label }) => {\n\t\t\tconst { checked } = radio(value);\n\t\t\treturn (\n\t\t\t\t<Radio\n\t\t\t\t\tchecked={checked()}\n\t\t\t\t\tname={name}\n\t\t\t\t\tonValue={checked}\n\t\t\t\t\tvalue={value}\n\t\t\t\t\ttheme={themeCss}\n\t\t\t\t\tclasses={classes}\n\t\t\t\t\tvariant={variant}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t>\n\t\t\t\t\t{label || value}\n\t\t\t\t</Radio>\n\t\t\t);\n\t\t});\n\t}\n\n\treturn (\n\t\t<fieldset key=\"root\" classes={[theme.variant(), root]} name={name}>\n\t\t\t{label && <legend classes={legend}>{label}</legend>}\n\t\t\t{renderRadios()}\n\t\t</fieldset>\n\t);\n});\n\nexport default RadioGroup;\n"]}