{"version":3,"sources":["webpack:///./js/react/CustomContainerBuilder.ts","webpack:///./js/react/CustomDomFactory.tsx","webpack:///./js/react/registrations.ts","webpack:///./js/react/index.ts","webpack:///./js/react/shared/HabitatContext.tsx"],"names":["CustomContainerBuilder","operator","key","components","Array","from","document","querySelectorAll","length","this","registerAsync","as","ContainerBuilder","CustomDomFactory","module","props","target","element","React","createElement","HabitatProvider","habitat","render","unmountComponentAtNode","registrations","name","component","MyApp","containerBuilder","factory","forEach","registration","registerIfPresent","setContainer","build","Bootstrapper","HabitatContext","createContext","children","otherProps","proxy","Provider","value","useHabitat","useContext"],"mappings":"y5CACqBA,E,mXAECC,EAAUC,GACxB,IAAMC,EAAaC,MAAMC,KAAKC,SAASC,iBAAT,2BAA8CL,EAA9C,QACzBC,GAAeA,EAAWK,QAG/BC,KAAKC,cAAcT,GAAUU,GAAGT,Q,8BAPYU,oB,8MCgBrCC,E,oLAZJC,EAAQC,EAAOC,GAClB,GAAIA,EAAQ,CACR,IAAMC,EAAWC,IAAMC,cAAcC,IAAiB,CAAEC,QAASN,GAASG,IAAMC,cAAcL,EAAQC,IACtGO,iBAAOL,EAASD,M,8BAGhBA,GACAA,GACAO,iCAAuBP,Q,gCCcpBQ,EA1BO,CAKlB,CACIC,KAAM,aACNC,UAAW,kBAAM,uDAErB,CACID,KAAM,gBACNC,UAAW,kBAAM,uDAErB,CACID,KAAM,qBACNC,UAAW,kBAAM,8DAErB,CACID,KAAM,kBACNC,UAAW,kBAAM,uDAErB,CACID,KAAM,eACNC,UAAW,kBAAM,wD,uiCCpBnBC,E,gQACF,aAAc,O,4FAAA,SACV,eAEA,IAAMC,EAAmB,IAAI5B,EAHnB,OAKV4B,EAAiBC,QAAU,IAAIhB,EAE/BW,EAAcM,SAAQ,SAAAC,GAClBH,EAAiBI,kBAAkBD,EAAaL,UAAWK,EAAaN,SAG5E,EAAKQ,aAAaL,EAAiBM,SAXzB,E,UADEC,gBAgBL,cAAIR,G,+eClBnB,IAAMS,EAAiBC,wBAAc,IAKxBjB,EAAkB,SAAC,GAA0B,IAAxBkB,EAAwB,EAAxBA,SAAUjB,EAAc,EAAdA,QAEtBkB,GAAelB,EAAzBmB,MAF8C,EAErBnB,EAFqB,YAGtD,OAAOH,IAAMC,cAAciB,EAAeK,SAAU,CAAEC,MAAOH,GAAcD,IAKxE,SAASK,IACZ,OAAOC,qBAAWR","file":"app-b248e708a877a4c2c77b.js","sourcesContent":["import { ContainerBuilder } from 'react-habitat';\r\nexport default class CustomContainerBuilder extends ContainerBuilder {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n registerIfPresent(operator, key) {\r\n const components = Array.from(document.querySelectorAll(`[data-component=\"${key}\"]`));\r\n if (!components || !components.length) {\r\n return;\r\n }\r\n this.registerAsync(operator).as(key);\r\n }\r\n}\r\n","import React from 'react';\r\nimport { render, unmountComponentAtNode } from 'react-dom';\r\nimport { HabitatProvider } from './shared/HabitatContext';\r\nclass CustomDomFactory {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n inject(module, props, target) {\r\n if (target) {\r\n const element = (React.createElement(HabitatProvider, { habitat: props }, React.createElement(module, props)));\r\n render(element, target);\r\n }\r\n }\r\n dispose(target) {\r\n if (target) {\r\n unmountComponentAtNode(target);\r\n }\r\n }\r\n}\r\nexport default CustomDomFactory;\r\n","/* eslint-disable @typescript-eslint/explicit-function-return-type */\r\nconst registrations = [\r\n // {\r\n // name: 'example',\r\n // component: () => import(/* webpackChunkName: example */ './example/ExampleRoot'),\r\n // },\r\n {\r\n name: 'FAQListing',\r\n component: () => import(/* webpackChunkName: faqListing */ './FAQs/FAQListingRoot'),\r\n },\r\n {\r\n name: 'AwardsListing',\r\n component: () => import(/* webpackChunkName: awardsListing */ './Awards/AwardsListingRoot'),\r\n },\r\n {\r\n name: 'EligibilityChecker',\r\n component: () => import(/* webpackChunkName: eligibilityChecker */ './Eligibility/EligibilityRoot'),\r\n },\r\n {\r\n name: 'ResourceListing',\r\n component: () => import(/* webpackChunkName: resourceListing */ './Resource/ResourceListingRoot'),\r\n },\r\n {\r\n name: 'ToolsListing',\r\n component: () => import(/* webpackChunkName: toolsListing */ './Tools/ToolsListingRoot'),\r\n },\r\n];\r\nexport default registrations;\r\n","import { Bootstrapper } from 'react-habitat';\r\nimport CustomContainerBuilder from './CustomContainerBuilder';\r\nimport CustomDomFactory from './CustomDomFactory';\r\nimport registrations from './registrations';\r\nclass MyApp extends Bootstrapper {\r\n constructor() {\r\n super();\r\n // Create container builder instance.\r\n const containerBuilder = new CustomContainerBuilder();\r\n // Set a custom factory to handle any context providers.\r\n containerBuilder.factory = new CustomDomFactory();\r\n // Register components - async allows for code splitting.\r\n registrations.forEach(registration => {\r\n containerBuilder.registerIfPresent(registration.component, registration.name);\r\n });\r\n // Finally, set the container.\r\n this.setContainer(containerBuilder.build());\r\n }\r\n}\r\n// Always export a 'new' instance so it immediately evokes\r\nexport default new MyApp();\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport React, { createContext, useContext } from 'react';\r\nconst HabitatContext = createContext({});\r\n/**\r\n * Component to provide access to habitat props.\r\n * @param props\r\n */\r\nexport const HabitatProvider = ({ children, habitat }) => {\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n const { proxy, ...otherProps } = habitat;\r\n return React.createElement(HabitatContext.Provider, { value: otherProps }, children);\r\n};\r\n/**\r\n * Hook to provide access to habitat props.\r\n */\r\nexport function useHabitat() {\r\n return useContext(HabitatContext);\r\n}\r\n/**\r\n * HOC to provide access to habitat props.\r\n */\r\nexport function withHabitat(WrappedComponent) {\r\n const WithHabitat = (props) => (React.createElement(HabitatContext.Consumer, null, (habitat) => React.createElement(WrappedComponent, Object.assign({}, habitat, props))));\r\n WithHabitat.displayName = getDisplayName(WrappedComponent);\r\n return WithHabitat;\r\n}\r\n/** Get the display name for the component. */\r\nfunction getDisplayName(WrappedComponent) {\r\n return WrappedComponent.displayName || WrappedComponent.name || 'Component';\r\n}\r\n"],"sourceRoot":""}