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AG,EAAE,CAAC,MAAM,IAAI,MAAM,EAAE,EAChC,QAAQ,EAAE,CAAC,KAAY,EAAE,EAAE;oBAC1B,KAAK,CAAC,eAAe,EAAE,CAAC;oBACxB,MAAM,KAAK,GAAG,KAAK,CAAC,MAA0B,CAAC;oBAC/C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACxB,CAAC,EACD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,IAAI,OAAO,EAAE,EACnC,cAAc,EAAE,GAAG,EAAE,CAAC,MAAM,IAAI,MAAM,EAAE,EACxC,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,KAAK,EAAE,IACrC;YACF,aAAK,OAAO,EAAE,QAAQ,CAAC,eAAe;gBACrC,aAAK,OAAO,EAAE,QAAQ,CAAC,UAAU,GAAI;gBACrC,aAAK,OAAO,EAAE,QAAQ,CAAC,UAAU,GAAI,CAChC,CACD;QACL,QAAQ,EAAE,CAAC,MAAM,GAAG,CAAC,IAAI,CACzB,IAAC,KAAK,IACL,GAAG,EAAC,OAAO,EACX,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAChC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,OAAO,IAEf,KAAK,CACC,CACR,CACI,CACN,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC","sourcesContent":["import { focus } from '@dojo/framework/core/middleware/focus';\nimport { FocusProperties } from '@dojo/framework/core/mixins/Focus';\nimport { create, tsx } from '@dojo/framework/core/vdom';\nimport { RenderResult } from '@dojo/framework/core/interfaces';\n\nimport { formatAriaProperties, isRenderResult } from '../common/util';\nimport theme, { ThemeProperties } from '../middleware/theme';\nimport * as css from '../theme/default/radio.m.css';\nimport Label from '../label';\n\nexport interface RadioProperties extends ThemeProperties, FocusProperties {\n\t/** Custom aria attributes */\n\taria?: { [key: string]: string | null };\n\t/** Checked/unchecked property of the radio */\n\tchecked: boolean;\n\t/** Set the disabled property of the control */\n\tdisabled?: boolean;\n\t/** Hides the label from view while still remaining accessible for screen readers */\n\tlabelHidden?: boolean;\n\t/** The name of the radio button */\n\tname?: string;\n\t/** Handler for when the element is blurred */\n\tonBlur?(): void;\n\t/** Handler for when the element is focused */\n\tonFocus?(): void;\n\t/** Handler for when the pointer moves out of the element */\n\tonOut?(): void;\n\t/** Handler for when the pointer moves over the element */\n\tonOver?(): void;\n\t/** Handler for when the value of the widget changes */\n\tonValue(checked: boolean): void;\n\t/** Makes the radio readonly (it may be focused but not changed) */\n\treadOnly?: boolean;\n\t/** Sets the radio input as required to complete the form */\n\trequired?: boolean;\n\t/** Toggles the invalid/valid states of the Radio affecting how it is displayed */\n\tvalid?: boolean;\n\t/** The current value */\n\tvalue?: string;\n\t/** The id used for the form input element. If not passed, one will be generated. */\n\twidgetId?: string;\n}\n\nexport interface RadioChildren {\n\t/** The label for the radio */\n\tlabel: RenderResult;\n}\n\nconst factory = create({ focus, theme })\n\t.properties<RadioProperties>()\n\t.children<RadioChildren | RenderResult | undefined>();\n\nexport const Radio = factory(function Radio({\n\tproperties,\n\tid,\n\tchildren,\n\tmiddleware: { focus, theme }\n}) {\n\tconst {\n\t\taria = {},\n\t\tchecked = false,\n\t\tclasses,\n\t\tdisabled,\n\t\tlabelHidden,\n\t\tname,\n\t\tonBlur,\n\t\tonFocus,\n\t\tonOut,\n\t\tonOver,\n\t\tonValue,\n\t\treadOnly,\n\t\trequired,\n\t\ttheme: themeProp,\n\t\tvalid,\n\t\tvalue,\n\t\tvariant,\n\t\twidgetId\n\t} = properties();\n\n\tconst themeCss = theme.classes(css);\n\tconst idBase = widgetId || `radio-${id}`;\n\tconst [labelChildren] = children();\n\tconst label = isRenderResult(labelChildren) ? labelChildren : labelChildren.label;\n\n\treturn (\n\t\t<div\n\t\t\tkey=\"root\"\n\t\t\tclasses={[\n\t\t\t\ttheme.variant(),\n\t\t\t\tthemeCss.root,\n\t\t\t\tchecked ? themeCss.checked : null,\n\t\t\t\tdisabled ? themeCss.disabled : null,\n\t\t\t\tfocus.isFocused('root') ? themeCss.focused : null,\n\t\t\t\tvalid === false ? themeCss.invalid : null,\n\t\t\t\tvalid === true ? themeCss.valid : null,\n\t\t\t\treadOnly ? themeCss.readonly : null,\n\t\t\t\trequired ? themeCss.required : null\n\t\t\t]}\n\t\t>\n\t\t\t<div classes={themeCss.inputWrapper}>\n\t\t\t\t<input\n\t\t\t\t\tid={idBase}\n\t\t\t\t\t{...formatAriaProperties(aria)}\n\t\t\t\t\tclasses={themeCss.input}\n\t\t\t\t\tchecked={checked}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tfocus={focus.shouldFocus()}\n\t\t\t\t\taria-invalid={valid === false ? 'true' : undefined}\n\t\t\t\t\tname={name}\n\t\t\t\t\treadonly={readOnly}\n\t\t\t\t\taria-readonly={readOnly === true ? 'true' : undefined}\n\t\t\t\t\trequired={required}\n\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonblur={() => onBlur && onBlur()}\n\t\t\t\t\tonchange={(event: Event) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tconst radio = event.target as HTMLInputElement;\n\t\t\t\t\t\tonValue(radio.checked);\n\t\t\t\t\t}}\n\t\t\t\t\tonfocus={() => onFocus && onFocus()}\n\t\t\t\t\tonpointerenter={() => onOver && onOver()}\n\t\t\t\t\tonpointerleave={() => onOut && onOut()}\n\t\t\t\t/>\n\t\t\t\t<div classes={themeCss.radioBackground}>\n\t\t\t\t\t<div classes={themeCss.radioOuter} />\n\t\t\t\t\t<div classes={themeCss.radioInner} />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{children().length > 0 && (\n\t\t\t\t<Label\n\t\t\t\t\tkey=\"label\"\n\t\t\t\t\tclasses={classes}\n\t\t\t\t\ttheme={themeProp}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tfocused={focus.isFocused('root')}\n\t\t\t\t\tforId={idBase}\n\t\t\t\t\tvalid={valid}\n\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\thidden={labelHidden}\n\t\t\t\t\trequired={required}\n\t\t\t\t\tsecondary={true}\n\t\t\t\t\tvariant={variant}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</Label>\n\t\t\t)}\n\t\t</div>\n\t);\n});\n\nexport default Radio;\n"]}