{"version":3,"file":"/Users/anthonygubler/development/dojo-org/widgets/src/title-pane/index.tsx","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,OAAO,KAAK,MAAM,uCAAuC,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,mCAAmC,CAAC;AACzD,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAC;AAwBtD,MAAM,OAAO,GAAG,MAAM,CAAC;IACtB,UAAU;IACV,KAAK;IACL,MAAM,EAAE,sBAAsB,EAAmB;IACjD,KAAK;CACL,CAAC,CAAC,UAAU,EAAuB,CAAC;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,SAAS,CAAC,EACnD,EAAE,EACF,QAAQ,EACR,UAAU,EACV,UAAU,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAChD;IACA,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,EACL,SAAS,GAAG,IAAI,EAChB,YAAY,EACZ,WAAW,EACX,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EAAE,SAAS,EAChB,OAAO,EACP,OAAO,EACP,GAAG,UAAU,EAAE,CAAC;IACjB,IAAI,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,CAAC;IAE5B,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;IACrD,IAAI,IAAI,KAAK,SAAS,EAAE;QACvB,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CA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IAAI,EAAE;wBACT,OAAO,IAAI,OAAO,EAAE,CAAC;qBACrB;yBAAM;wBACN,MAAM,IAAI,MAAM,EAAE,CAAC;qBACnB;gBACF,CAAC,EACD,IAAI,EAAC,QAAQ;gBAEb,cAAM,OAAO,EAAE,QAAQ,CAAC,KAAK;oBAC5B,IAAC,IAAI,IACJ,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,EACrC,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACf,CACI;gBACN,IAAI,CACG,CACJ;QACN,4BACc,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,qBACrB,GAAG,EAAE,QAAQ,EAC9B,OAAO,EAAE;gBACR,QAAQ,CAAC,OAAO;gBAChB,CAAC,WAAW,IAAI,QAAQ,CAAC,iBAAiB;gBAC1C,QAAQ,CAAC,YAAY;aACrB,EACD,EAAE,EAAE,GAAG,EAAE,UAAU,EACnB,GAAG,EAAC,SAAS,EACb,MAAM,EAAE;gBACP,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI;aACzE,IAEA,QAAQ,EAAE,CACN,CACD,CACN,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC","sourcesContent":["import dimensions from '@dojo/framework/core/middleware/dimensions';\nimport focus from '@dojo/framework/core/middleware/focus';\nimport { createICacheMiddleware } from '@dojo/framework/core/middleware/icache';\nimport { create, tsx } from '@dojo/framework/core/vdom';\n\nimport Icon from '../icon';\nimport theme from '../middleware/theme';\nimport * as css from '../theme/default/title-pane.m.css';\nimport * as fixedCss from './styles/title-pane.m.css';\n\nexport interface TitlePaneProperties {\n\t/** If false the pane will not collapse in response to clicking the title */\n\tcloseable?: boolean;\n\t/** 'aria-level' for the title's DOM node */\n\theadingLevel?: number;\n\t/** If true the pane is opened and content is visible initially */\n\tinitialOpen?: boolean;\n\t/** Explicitly control TitlePane */\n\topen?: boolean;\n\t/** Called when the title of a closed pane is clicked */\n\tonClose?(): void;\n\t/** Called when the title of an open pane is clicked */\n\tonOpen?(): void;\n\t/** The displayed title name for this pane */\n\tname: string;\n}\n\nexport interface TitlePaneICache {\n\tinitialOpen?: boolean;\n\topen?: boolean;\n}\n\nconst factory = create({\n\tdimensions,\n\tfocus,\n\ticache: createICacheMiddleware<TitlePaneICache>(),\n\ttheme\n}).properties<TitlePaneProperties>();\n\nexport const TitlePane = factory(function TitlePane({\n\tid,\n\tchildren,\n\tproperties,\n\tmiddleware: { dimensions, focus, icache, theme }\n}) {\n\tconst themeCss = theme.classes(css);\n\tconst {\n\t\tcloseable = true,\n\t\theadingLevel,\n\t\tinitialOpen,\n\t\tonClose,\n\t\tonOpen,\n\t\tname,\n\t\ttheme: themeProp,\n\t\tclasses,\n\t\tvariant\n\t} = properties();\n\tlet { open } = properties();\n\n\tconst firstRender = icache.get('open') === undefined;\n\tif (open === undefined) {\n\t\topen = icache.get('open');\n\t\tconst existingInitialOpen = icache.get('initialOpen');\n\n\t\tif (initialOpen !== existingInitialOpen) {\n\t\t\ticache.set('open', initialOpen);\n\t\t\ticache.set('initialOpen', initialOpen);\n\t\t\topen = initialOpen;\n\t\t}\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclasses={[\n\t\t\t\ttheme.variant(),\n\t\t\t\tthemeCss.root,\n\t\t\t\topen ? themeCss.open : null,\n\t\t\t\tfixedCss.rootFixed\n\t\t\t]}\n\t\t>\n\t\t\t<div\n\t\t\t\taria-level={headingLevel ? `${headingLevel}` : undefined}\n\t\t\t\tclasses={[\n\t\t\t\t\tthemeCss.title,\n\t\t\t\t\tcloseable ? themeCss.closeable : null,\n\t\t\t\t\tfixedCss.titleFixed,\n\t\t\t\t\tcloseable ? fixedCss.closeableFixed : null\n\t\t\t\t]}\n\t\t\t\trole=\"heading\"\n\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\taria-controls={`${id}-content`}\n\t\t\t\t\taria-expanded={open ? 'true' : 'false'}\n\t\t\t\t\tdisabled={!closeable}\n\t\t\t\t\tclasses={[fixedCss.titleButtonFixed, themeCss.titleButton]}\n\t\t\t\t\tfocus={focus.isFocused('title-button')}\n\t\t\t\t\tkey=\"title-button\"\n\t\t\t\t\tonclick={(event: MouseEvent) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\ticache.set('open', !open);\n\t\t\t\t\t\tif (open) {\n\t\t\t\t\t\t\tonClose && onClose();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonOpen && onOpen();\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t>\n\t\t\t\t\t<span classes={themeCss.arrow}>\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\ttype={open ? 'downIcon' : 'rightIcon'}\n\t\t\t\t\t\t\ttheme={themeProp}\n\t\t\t\t\t\t\tclasses={classes}\n\t\t\t\t\t\t\tvariant={variant}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</span>\n\t\t\t\t\t{name}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\taria-hidden={open ? undefined : 'true'}\n\t\t\t\taria-labelledby={`${id}-title`}\n\t\t\t\tclasses={[\n\t\t\t\t\tthemeCss.content,\n\t\t\t\t\t!firstRender && themeCss.contentTransition,\n\t\t\t\t\tfixedCss.contentFixed\n\t\t\t\t]}\n\t\t\t\tid={`${id}-content`}\n\t\t\t\tkey=\"content\"\n\t\t\t\tstyles={{\n\t\t\t\t\tmarginTop: open ? '0px' : `-${dimensions.get('content').offset.height}px`\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{children()}\n\t\t\t</div>\n\t\t</div>\n\t);\n});\n\nexport default TitlePane;\n"]}