{"version":3,"file":"/Users/anthonygubler/development/dojo-org/widgets/src/checkbox/index.tsx","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,uCAAuC,CAAC;AAC1D,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,iCAAiC,CAAC;AAmCvD,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;KACtC,UAAU,EAAsB;KAChC,QAAQ,EAA4B,CAAC;AAEvC,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,QAAQ,CAAC,EACjD,QAAQ,EACR,UAAU,EACV,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAC5B;IACA,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC;IACrB,MAAM,EACL,IAAI,GAAG,EAAE,EACT,OAAO,GAAG,KAAK,EACf,OAAO,EACP,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,MAAM,EACN,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAK,EAAE,SAAS,EAChB,OAAO,EACP,KAAK,EACL,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,GAAG,UAAU,EAAE,CAAC;IAEjB,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEpC,OAAO,CACN,aACC,GAAG,EAAC,MAAM,EACV,OAAO,EAAE;YACR,KAAK,CAAC,OAAO,EAAE;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,eAAe,EAAE,CAAC;oBACxB,MAAM,QAAQ,GAAG,KAAK,CAAC,MAA0B,CAAC;oBAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;gBAC3B,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,UAAU,GAAI,CAChC;QACL,KAAK,IAAI,CACT,IAAC,KAAK,IACL,GAAG,EAAC,OAAO,EACX,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAChC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,IAAI,IAEd,KAAK,CACC,CACR,CACI,CACN,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { RenderResult } from '@dojo/framework/core/interfaces';\nimport focus from '@dojo/framework/core/middleware/focus';\nimport theme from '../middleware/theme';\nimport { uuid } from '@dojo/framework/core/util';\nimport { tsx, create } from '@dojo/framework/core/vdom';\n\nimport { formatAriaProperties } from '../common/util';\nimport Label from '../label/index';\nimport * as css from '../theme/default/checkbox.m.css';\n\nexport interface CheckboxProperties {\n\t/** Custom aria attributes */\n\taria?: { [key: string]: string | null };\n\t/**  Checked/unchecked property of the control */\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 checkbox */\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 checkbox readonly (it may be focused but not changed) */\n\treadOnly?: boolean;\n\t/** Sets the checkbox input as required to complete the form */\n\trequired?: boolean;\n\t/** Toggles the invalid/valid states of the Checkbox 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 */\n\twidgetId?: string;\n}\n\nconst factory = create({ theme, focus })\n\t.properties<CheckboxProperties>()\n\t.children<RenderResult | undefined>();\n\nexport const Checkbox = factory(function Checkbox({\n\tchildren,\n\tproperties,\n\tmiddleware: { theme, focus }\n}) {\n\tconst _uuid = uuid();\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\tonValue,\n\t\tonOut,\n\t\tonOver,\n\t\treadOnly,\n\t\trequired,\n\t\ttheme: themeProp,\n\t\tvariant,\n\t\tvalid,\n\t\tvalue,\n\t\twidgetId = _uuid\n\t} = properties();\n\n\tconst [label] = children();\n\tconst themeCss = theme.classes(css);\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={widgetId}\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=\"checkbox\"\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 checkbox = event.target as HTMLInputElement;\n\t\t\t\t\t\tonValue(checkbox.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.background} />\n\t\t\t</div>\n\t\t\t{label && (\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\tvariant={variant}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tfocused={focus.isFocused('root')}\n\t\t\t\t\tvalid={valid}\n\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\trequired={required}\n\t\t\t\t\thidden={labelHidden}\n\t\t\t\t\tforId={widgetId}\n\t\t\t\t\tsecondary={true}\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 Checkbox;\n"]}