{"version":3,"sources":["Components/SmallPrint.js","Components/InputField.js","Components/TextAreaField.js","Components/OptionField.js","Components/CheckboxField.js","Components/SubmitButton.js","UmbracoForm.js","serviceWorker.js","index.js"],"names":["SmallPrint","props","this","text","React","Component","InputField","className","key","index","htmlFor","field","name","label","id","type","value","required","placeholder","autoComplete","description","TextAreaField","OptionField","options","split","map","x","y","CheckboxField","SubmitButton","disabled","isDisabled","UmbracoForm","handleSubmit","bind","nodeId","document","querySelector","dataset","node","constants","response","LOADING","state","formFields","submitButton","token","isLoading","setState","fetch","then","json","data","fields","submitText","event","formData","FormData","target","preventDefault","arrayData","entries","push","body","JSON","stringify","headers","method","responseType","length","submitDisabled","onSubmit","undefined","redirectUrl","window","location","href","message","Boolean","hostname","match","ReactDOM","render","StrictMode","getElementById","navigator","serviceWorker","ready","registration","unregister","catch","error","console"],"mappings":"wQAiBeA,E,kDAdb,WAAYC,GAAQ,IAAD,8BACjB,cAAMA,IACDA,MAAQA,EAFI,E,qDAMjB,OAAIC,KAAKD,MAAME,KAEX,+BAAQD,KAAKD,MAAME,MAGhB,O,GAZcC,IAAMC,WC0BhBC,E,kDAxBb,WAAYL,GAAQ,IAAD,8BACjB,cAAMA,IACDA,MAAQA,EAFI,E,qDAMjB,OACE,yBAAKM,UAAU,cACb,2BAAOC,IAAKN,KAAKD,MAAMQ,MAAOC,QAASR,KAAKD,MAAMU,MAAMC,KAAO,IAAMV,KAAKD,MAAMQ,OAC7EP,KAAKD,MAAMU,MAAME,OAEpB,2BAAON,UAAU,eAAeO,GAAIZ,KAAKD,MAAMU,MAAMC,KAAO,IAAMV,KAAKD,MAAMQ,MAC7EM,KAAMb,KAAKD,MAAMU,MAAMI,KACvBC,MAAOd,KAAKD,MAAMU,MAAMK,MACxBJ,KAAMV,KAAKD,MAAMU,MAAMC,KACvBK,SAAUf,KAAKD,MAAMU,MAAMM,SAC3BC,YAAahB,KAAKD,MAAMU,MAAMO,YAC9BC,aAAa,QAEb,kBAAC,EAAD,CAAY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,MAAOA,EAAOE,MAAOA,IAExC,aAAfA,EAAMI,KACC,kBAAC,EAAD,CAAaP,IAAKC,EAAOA,MAAOA,EAAOE,MAAOA,IAEtC,aAAfA,EAAMI,KACC,kBAAC,EAAD,CAAeP,IAAKC,EAAOA,MAAOA,EAAOE,MAAOA,IAElD,kBAAC,EAAD,CAAYH,IAAKC,EAAOA,MAAOA,EAAOE,MAAOA,OAEvD,kBAAC,EAAD,CAAcR,KAAM0C,EAAcd,WAAYuC,KAKpD,OACE,+GAGJ,YAA4BE,IAAzB/B,EAASgC,aAAsD,KAAzBhC,EAASgC,YACzCC,OAAOC,SAASC,KAAOnC,EAASgC,YAGvC,2BAAIhC,EAASoC,a,GAtGOzE,IAAMC,WCIZyE,QACW,cAA7BJ,OAAOC,SAASI,UAEe,UAA7BL,OAAOC,SAASI,UAEhBL,OAAOC,SAASI,SAASC,MACvB,2DCZNC,IAASC,OACP,kBAAC,IAAMC,WAAP,KACE,kBAAC,EAAD,OAEF/C,SAASgD,eAAe,uBDyHpB,kBAAmBC,WACrBA,UAAUC,cAAcC,MACrBrC,MAAK,SAAAsC,GACJA,EAAaC,gBAEdC,OAAM,SAAAC,GACLC,QAAQD,MAAMA,EAAMd,c","file":"static/js/main.078bc64d.chunk.js","sourcesContent":["import React from 'react';\r\n\r\nclass SmallPrint extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.props = props;\r\n }\r\n\r\n render() {\r\n if (this.props.text) {\r\n return (\r\n {this.props.text}\r\n )\r\n }\r\n return(\"\");\r\n }\r\n}\r\nexport default SmallPrint;","import React from 'react';\r\nimport SmallPrint from \"./SmallPrint\";\r\n\r\nclass InputField extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.props = props;\r\n }\r\n\r\n render() {\r\n return (\r\n
\r\n \r\n \r\n \r\n
\r\n );\r\n }\r\n}\r\nexport default InputField;","import React from 'react';\r\nimport SmallPrint from \"./SmallPrint\";\r\n\r\nclass TextAreaField extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.props = props;\r\n\r\n }\r\n\r\n render() {\r\n return (\r\n
\r\n \r\n \r\n \r\n
\r\n );\r\n }\r\n}\r\nexport default TextAreaField;","import React from 'react';\r\nimport SmallPrint from \"./SmallPrint\";\r\n\r\nclass OptionField extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.props = props;\r\n this.options = this.props.field.options.split(\"\\n\");\r\n }\r\n\r\n render() {\r\n return (\r\n
\r\n \r\n \r\n \r\n
\r\n );\r\n }\r\n}\r\nexport default OptionField;","import React from 'react';\r\nimport SmallPrint from \"./SmallPrint\";\r\n\r\nclass CheckboxField extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.props = props;\r\n this.options = this.props.field.options.split(\"\\n\");\r\n }\r\n\r\n render() {\r\n return (\r\n
\r\n \r\n

\r\n {this.options.map((x, y) => \r\n \r\n )}\r\n \r\n
\r\n );\r\n }\r\n}\r\nexport default CheckboxField;","import React from 'react';\r\n\r\nclass SubmitButton extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.props = props;\r\n }\r\n\r\n render() {\r\n return (\r\n \r\n );\r\n }\r\n}\r\nexport default SubmitButton;","import React from 'react';\r\nimport InputField from './Components/InputField'\r\nimport TextAreaField from './Components/TextAreaField'\r\nimport OptionField from './Components/OptionField'\r\nimport CheckboxField from './Components/CheckboxField'\r\nimport SubmitButton from './Components/SubmitButton'\r\n\r\n\r\nclass UmbracoForm extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.handleSubmit = this.handleSubmit.bind(this);\r\n\r\n const nodeId = document.querySelector('#react-form-umbraco').dataset.node;\r\n\r\n this.constants = {\r\n response: {\r\n LOADING: \"LOADING\",\r\n\r\n }\r\n }\r\n\r\n this.state = {\r\n formFields: [],\r\n submitButton: \"\",\r\n token: \"\",\r\n isLoading: false,\r\n nodeId: nodeId,\r\n response: \"\"\r\n };\r\n }\r\n\r\n componentDidMount() {\r\n this.setState({ isLoading: true });\r\n fetch(\"/Umbraco/Api/ReactForm/GetFormStructure?currentPageId=\" + this.state.nodeId)\r\n .then(response => response.json())\r\n .then(data => this.setState({ formFields: data.fields, submitButton: data.submitText, token: data.token, isLoading: false }));\r\n }\r\n\r\n handleSubmit(event) {\r\n\r\n this.setState({ response: this.constants.response.LOADING });\r\n\r\n const formData = new FormData(event.target);\r\n event.preventDefault();\r\n\r\n const arrayData = [];\r\n for (let [key, value] of formData.entries()) {\r\n arrayData.push({ key, value });\r\n }\r\n\r\n const body = {\r\n nodeId: this.state.nodeId,\r\n token: this.state.token,\r\n data: JSON.stringify(arrayData)\r\n }\r\n\r\n fetch('/Umbraco/Api/ReactForm/Submit', {\r\n headers: {\r\n 'Accept': 'application/json',\r\n 'Content-Type': 'application/json'\r\n },\r\n method: 'POST',\r\n body: JSON.stringify(body)\r\n })\r\n .then(response => response.json())\r\n .then(response => this.setState({ response: response }));\r\n }\r\n\r\n render() {\r\n const { formFields, submitButton, isLoading, response } = this.state;\r\n const responseType = this.constants.response;\r\n\r\n if (response === \"\" || response === responseType.LOADING) {\r\n if (isLoading) {\r\n return (\r\n

Loading...

\r\n )\r\n }\r\n\r\n if (!isLoading && formFields.length > 0) {\r\n\r\n const submitDisabled = this.state.response === responseType.LOADING;\r\n return (\r\n
\r\n {formFields.map((field, index) => {\r\n if(field.type === \"textarea\"){\r\n return ()\r\n }\r\n if(field.type === \"dropdown\"){\r\n return ()\r\n }\r\n if(field.type === \"checkbox\"){\r\n return ()\r\n }\r\n return ()\r\n })}\r\n \r\n \r\n )\r\n }\r\n\r\n return (\r\n

No data to display. It doesn't look like fields have been created for this form.

\r\n )\r\n } \r\n if(response.redirectUrl !== undefined && response.redirectUrl !== \"\"){ \r\n return window.location.href = response.redirectUrl;\r\n }\r\n return (\r\n

{response.message}

\r\n )\r\n }\r\n}\r\nexport default UmbracoForm;","// This optional code is used to register a service worker.\r\n// register() is not called by default.\r\n\r\n// This lets the app load faster on subsequent visits in production, and gives\r\n// it offline capabilities. However, it also means that developers (and users)\r\n// will only see deployed updates on subsequent visits to a page, after all the\r\n// existing tabs open on the page have been closed, since previously cached\r\n// resources are updated in the background.\r\n\r\n// To learn more about the benefits of this model and instructions on how to\r\n// opt-in, read https://bit.ly/CRA-PWA\r\n\r\nconst isLocalhost = Boolean(\r\n window.location.hostname === 'localhost' ||\r\n // [::1] is the IPv6 localhost address.\r\n window.location.hostname === '[::1]' ||\r\n // 127.0.0.0/8 are considered localhost for IPv4.\r\n window.location.hostname.match(\r\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\r\n )\r\n);\r\n\r\nexport function register(config) {\r\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\r\n // The URL constructor is available in all browsers that support SW.\r\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\r\n if (publicUrl.origin !== window.location.origin) {\r\n // Our service worker won't work if PUBLIC_URL is on a different origin\r\n // from what our page is served on. This might happen if a CDN is used to\r\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\r\n return;\r\n }\r\n\r\n window.addEventListener('load', () => {\r\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\r\n\r\n if (isLocalhost) {\r\n // This is running on localhost. Let's check if a service worker still exists or not.\r\n checkValidServiceWorker(swUrl, config);\r\n\r\n // Add some additional logging to localhost, pointing developers to the\r\n // service worker/PWA documentation.\r\n navigator.serviceWorker.ready.then(() => {\r\n console.log(\r\n 'This web app is being served cache-first by a service ' +\r\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\r\n );\r\n });\r\n } else {\r\n // Is not localhost. Just register service worker\r\n registerValidSW(swUrl, config);\r\n }\r\n });\r\n }\r\n}\r\n\r\nfunction registerValidSW(swUrl, config) {\r\n navigator.serviceWorker\r\n .register(swUrl)\r\n .then(registration => {\r\n registration.onupdatefound = () => {\r\n const installingWorker = registration.installing;\r\n if (installingWorker == null) {\r\n return;\r\n }\r\n installingWorker.onstatechange = () => {\r\n if (installingWorker.state === 'installed') {\r\n if (navigator.serviceWorker.controller) {\r\n // At this point, the updated precached content has been fetched,\r\n // but the previous service worker will still serve the older\r\n // content until all client tabs are closed.\r\n console.log(\r\n 'New content is available and will be used when all ' +\r\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\r\n );\r\n\r\n // Execute callback\r\n if (config && config.onUpdate) {\r\n config.onUpdate(registration);\r\n }\r\n } else {\r\n // At this point, everything has been precached.\r\n // It's the perfect time to display a\r\n // \"Content is cached for offline use.\" message.\r\n console.log('Content is cached for offline use.');\r\n\r\n // Execute callback\r\n if (config && config.onSuccess) {\r\n config.onSuccess(registration);\r\n }\r\n }\r\n }\r\n };\r\n };\r\n })\r\n .catch(error => {\r\n console.error('Error during service worker registration:', error);\r\n });\r\n}\r\n\r\nfunction checkValidServiceWorker(swUrl, config) {\r\n // Check if the service worker can be found. If it can't reload the page.\r\n fetch(swUrl, {\r\n headers: { 'Service-Worker': 'script' },\r\n })\r\n .then(response => {\r\n // Ensure service worker exists, and that we really are getting a JS file.\r\n const contentType = response.headers.get('content-type');\r\n if (\r\n response.status === 404 ||\r\n (contentType != null && contentType.indexOf('javascript') === -1)\r\n ) {\r\n // No service worker found. Probably a different app. Reload the page.\r\n navigator.serviceWorker.ready.then(registration => {\r\n registration.unregister().then(() => {\r\n window.location.reload();\r\n });\r\n });\r\n } else {\r\n // Service worker found. Proceed as normal.\r\n registerValidSW(swUrl, config);\r\n }\r\n })\r\n .catch(() => {\r\n console.log(\r\n 'No internet connection found. App is running in offline mode.'\r\n );\r\n });\r\n}\r\n\r\nexport function unregister() {\r\n if ('serviceWorker' in navigator) {\r\n navigator.serviceWorker.ready\r\n .then(registration => {\r\n registration.unregister();\r\n })\r\n .catch(error => {\r\n console.error(error.message);\r\n });\r\n }\r\n}\r\n","import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\n//import './index.css';\r\nimport UmbracoForm from './UmbracoForm';\r\nimport * as serviceWorker from './serviceWorker';\r\n\r\nReactDOM.render(\r\n \r\n \r\n ,\r\n document.getElementById('react-form-umbraco')\r\n);\r\n\r\n// If you want your app to work offline and load faster, you can change\r\n// unregister() to register() below. Note this comes with some pitfalls.\r\n// Learn more about service workers: https://bit.ly/CRA-PWA\r\nserviceWorker.unregister();\r\n"],"sourceRoot":""}