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'@dojo/framework/core/middleware/dimensions';\nimport { create, tsx } from '@dojo/framework/core/vdom';\nimport { RenderResult } from '@dojo/framework/core/interfaces';\nimport Popup, { PopupPosition, BasePopupProperties } from '../popup';\nimport * as fixedCss from './trigger-popup.m.css';\nimport theme from '../middleware/theme';\nimport { createICacheMiddleware } from '@dojo/framework/core/middleware/icache';\n\nexport interface TriggerPopupProperties extends BasePopupProperties {\n\t/** If the popup wrapper should match the trigger width (defaults to true) */\n\tmatchWidth?: boolean;\n\t/** Callback when the menu is opened  */\n\tonOpen?(): void;\n\t/** Position of popup that is triggered  */\n\tposition?: PopupPosition;\n}\n\nexport interface TriggerPopupChildren {\n\ttrigger: (toggleOpen: () => void) => RenderResult;\n\tcontent: (close: () => void, position: PopupPosition) => RenderResult;\n}\n\ninterface TriggerPopupICache {\n\topen: boolean;\n}\n\nconst icache = createICacheMiddleware<TriggerPopupICache>();\n\nconst factory = create({ dimensions, icache, theme })\n\t.properties<TriggerPopupProperties>()\n\t.children<TriggerPopupChildren>();\n\nexport const TriggerPopup = factory(function TriggerPopup({\n\tproperties,\n\tchildren,\n\tmiddleware: { dimensions, icache, theme }\n}) {\n\tconst { matchWidth = true, onOpen, classes, ...otherProperties } = properties();\n\n\tconst { position: triggerPosition, size: triggerSize } = dimensions.get('trigger');\n\tconst triggerTop = triggerPosition.top + document.documentElement.scrollTop;\n\tconst triggerBottom = triggerTop + triggerSize.height;\n\n\tconst themedCss = theme.classes(fixedCss);\n\n\tconst wrapperStyles = {\n\t\twidth: matchWidth ? `${triggerSize.width}px` : 'auto'\n\t};\n\n\tconst { trigger, content } = children()[0];\n\tconst close = () => {\n\t\tconst { onClose } = properties();\n\t\ticache.set('open', false);\n\t\tonClose && onClose();\n\t};\n\n\treturn (\n\t\t<virtual classes={[themedCss.root]}>\n\t\t\t<span key=\"trigger\" classes={fixedCss.trigger}>\n\t\t\t\t{trigger(() => {\n\t\t\t\t\tconst { onOpen } = properties();\n\t\t\t\t\ticache.set('open', !icache.get('open'));\n\t\t\t\t\tonOpen && onOpen();\n\t\t\t\t})}\n\t\t\t</span>\n\t\t\t<Popup\n\t\t\t\tkey=\"popup\"\n\t\t\t\t{...otherProperties}\n\t\t\t\tclasses={classes}\n\t\t\t\tyTop={triggerBottom}\n\t\t\t\tyBottom={triggerTop}\n\t\t\t\txLeft={triggerPosition.left}\n\t\t\t\txRight={triggerPosition.right}\n\t\t\t\tonClose={close}\n\t\t\t\topen={icache.get('open')}\n\t\t\t>\n\t\t\t\t{(position) => (\n\t\t\t\t\t<div key=\"trigger-wrapper\" styles={wrapperStyles}>\n\t\t\t\t\t\t{content(close, position)}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</Popup>\n\t\t</virtual>\n\t);\n});\n\nexport default TriggerPopup;\n"]}