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AK,IAAI,KAAK,EAAE,EACtC,aAAa,EAAE,GAAG,EAAE,CAAC,MAAM,IAAI,MAAM,EAAE,EACvC,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,IAAI,EAAE,IAC7B,oBAAoB,CAAC,IAAI,CAAC;QAE7B,IAAI,IAAI,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QACxD,KAAK,CAAC,CAAC,CAAC,cAAM,OAAO,EAAE,QAAQ,CAAC,KAAK,IAAG,KAAK,CAAQ,CAAC,CAAC,CAAC,SAAS;QACjE,IAAI,IAAI,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAChD,CACT,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC","sourcesContent":["import { focus } from '@dojo/framework/core/middleware/focus';\nimport { create, tsx } from '@dojo/framework/core/vdom';\n\nimport { formatAriaProperties, isRenderResult } from '../common/util';\nimport { theme } from '../middleware/theme';\nimport * as css from '../theme/default/button.m.css';\nimport { RenderResult } from '@dojo/framework/core/interfaces';\n\nexport interface ButtonProperties {\n\t/** Custom aria attributes */\n\taria?: { [key: string]: string | null };\n\t/** Whether the button is disabled or clickable */\n\tdisabled?: boolean;\n\t/** The name of the button */\n\tname?: string;\n\t/** Handler for events triggered by button losing focus */\n\tonBlur?(): void;\n\t/** Handler for events triggered by a button click */\n\tonClick?(): void;\n\t/** Handler for events triggered by \"on down\" */\n\tonDown?(): void;\n\t/** Handler for events triggered by \"on focus\" */\n\tonFocus?(): void;\n\t/** Handler for events triggered by \"on out\" */\n\tonOut?(): void;\n\t/** Handler for events triggered by \"on over\" */\n\tonOver?(): void;\n\t/** Handler for events triggered by \"on up\" */\n\tonUp?(): void;\n\t/** Button type can be \"submit\", \"reset\", \"button\", or \"menu\" */\n\ttype?: 'submit' | 'reset' | 'button' | 'menu';\n\t/**  Defines a value for the button submitted with form data */\n\tvalue?: string;\n\t/** `id` set on the root button DOM node */\n\twidgetId?: string;\n\t/** The title text for the button node */\n\ttitle?: string;\n\t/** The kind of button */\n\tkind?: 'contained' | 'outlined' | 'text';\n\t/** Where to add the icon. Default to \"before\" */\n\ticonPosition?: 'before' | 'after';\n}\nexport interface ButtonChildren {\n\t/** The icon for the button */\n\ticon?: RenderResult;\n\t/** The label for the button */\n\tlabel?: RenderResult;\n}\n\nconst factory = create({ focus, theme })\n\t.properties<ButtonProperties>()\n\t// [ButtonChildren] is needed for variant buttons to type correctly\n\t.children<ButtonChildren | [ButtonChildren] | RenderResult | RenderResult[]>();\n\nexport const Button = factory(function Button({\n\tchildren,\n\tid,\n\tmiddleware: { focus, theme },\n\tproperties\n}) {\n\tconst {\n\t\taria = {},\n\t\tdisabled,\n\t\twidgetId,\n\t\tname,\n\t\ttype = 'button',\n\t\tvalue,\n\t\tonClick,\n\t\tonOut,\n\t\tonOver,\n\t\tonDown,\n\t\tonUp,\n\t\tonBlur,\n\t\tonFocus,\n\t\ttitle,\n\t\tkind = 'contained',\n\t\ticonPosition = 'before'\n\t} = properties();\n\n\tconst themeCss = theme.classes(css);\n\tconst idBase = widgetId || `button-${id}`;\n\n\tconst [labelChild] = children();\n\tconst { label, icon = undefined } = isRenderResult(labelChild)\n\t\t? { label: children() }\n\t\t: labelChild;\n\tconst iconOnly = icon && !label;\n\tconst iconSpan = <span classes={themeCss.icon}>{icon}</span>;\n\n\treturn (\n\t\t<button\n\t\t\tclasses={[\n\t\t\t\ttheme.variant(),\n\t\t\t\tthemeCss.root,\n\t\t\t\tdisabled ? themeCss.disabled : null,\n\t\t\t\tkind === 'text' ? themeCss.text : null,\n\t\t\t\tkind === 'contained' ? themeCss.contained : null,\n\t\t\t\tkind === 'outlined' ? themeCss.outlined : null,\n\t\t\t\ticonOnly ? themeCss.iconOnly : null\n\t\t\t]}\n\t\t\ttitle={title}\n\t\t\tdisabled={disabled}\n\t\t\tid={idBase}\n\t\t\tfocus={focus.shouldFocus()}\n\t\t\tname={name}\n\t\t\ttype={type}\n\t\t\tvalue={value}\n\t\t\tonblur={() => onBlur && onBlur()}\n\t\t\tonclick={(event: MouseEvent) => {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tonClick && onClick();\n\t\t\t}}\n\t\t\tonfocus={() => onFocus && onFocus()}\n\t\t\tonpointerenter={() => onOver && onOver()}\n\t\t\tonpointerleave={() => onOut && onOut()}\n\t\t\tonpointerdown={() => onDown && onDown()}\n\t\t\tonpointerup={() => onUp && onUp()}\n\t\t\t{...formatAriaProperties(aria)}\n\t\t>\n\t\t\t{icon && iconPosition === 'before' ? iconSpan : undefined}\n\t\t\t{label ? <span classes={themeCss.label}>{label}</span> : undefined}\n\t\t\t{icon && iconPosition === 'after' ? iconSpan : undefined}\n\t\t</button>\n\t);\n});\n\nexport default Button;\n"]}