{ "version": 3, "sources": ["../../../views/pages/create_apron.ts"], "sourcesContent": ["// Select the form element from the document\nconst form = document.querySelector('form') as HTMLFormElement\n\n// Function to smoothly scroll to a specific fieldset in the form\nconst moveSlide = (num: number) => {\n const set = form.querySelectorAll('fieldset')[num]\n if (set) {\n set.scrollIntoView({ behavior: 'smooth' })\n }\n}\n\n// Add a click event listener to the form\nform.addEventListener('click', e => {\n // If the clicked element is an input element\n if (e.target instanceof HTMLInputElement) {\n const inputName = e.target.name\n const inputValue = e.target.value\n\n let spans: NodeListOf | HTMLSpanElement | null = null\n // Depending on the name of the input, select different span elements\n switch (inputName) {\n case 'slogan':\n spans = document.querySelectorAll('span[data-val=\"slogan\"]')\n break\n\n case 'color_text':\n spans = document.querySelectorAll('span[data-val=\"color_text\"]')\n break\n\n case 'color_fabric':\n spans = document.querySelectorAll(\n 'span[data-val=\"color_fabric\"]'\n )\n // Select the button from the document\n const btnCheckout = document.querySelector(\n 'button[data-action=\"checkout\"]'\n ) as HTMLButtonElement\n\n // Set the disabled property to false\n btnCheckout.disabled = false\n break\n }\n\n // If span elements were selected, update their text\n if (spans) {\n spans.forEach(span => {\n // If the input name is 'slogan', wrap the input value in quotes\n span.innerText =\n inputName === 'slogan' ? `\"${inputValue}\"` : inputValue\n })\n }\n }\n\n // If the clicked element is a button with a 'back' action\n if (\n e.target instanceof HTMLButtonElement &&\n e.target.dataset.action === 'back'\n ) {\n const fieldsets = Array.from(form.querySelectorAll('fieldset'))\n const currentFieldsetIndex = fieldsets.findIndex(fieldset =>\n fieldset.contains(e.target as HTMLButtonElement)\n )\n // If the current fieldset is not the first one, move back to the previous fieldset\n if (currentFieldsetIndex !== -1 && currentFieldsetIndex > 0) {\n moveSlide(currentFieldsetIndex - 1)\n }\n } else if (\n e.target instanceof HTMLInputElement &&\n e.target.type === 'radio'\n ) {\n const fieldsets = Array.from(form.querySelectorAll('fieldset'))\n const currentFieldsetIndex = fieldsets.findIndex(fieldset =>\n fieldset.contains(e.target as HTMLInputElement)\n )\n // If the current fieldset is not the last one, move to the next fieldset\n if (\n currentFieldsetIndex !== -1 &&\n currentFieldsetIndex < fieldsets.length - 1\n ) {\n moveSlide(currentFieldsetIndex + 1)\n }\n }\n})\n\n// const form = document.querySelector('form') as HTMLFormElement\n\n// const moveSlide = (num: number) => {\n// const set = form.querySelectorAll('fieldset')[num]\n// if (set) {\n// set.scrollIntoView({ behavior: 'smooth' })\n// }\n// }\n\n// form.addEventListener('click', e => {\n// if (e.target instanceof HTMLInputElement) {\n// const inputName = e.target.name\n// const inputValue = e.target.value\n\n// let spans: NodeListOf | HTMLSpanElement | null = null\n// switch (inputName) {\n// case 'slogan':\n// spans = document.querySelectorAll('span[data-val=\"slogan\"]')\n// break\n\n// case 'color_text':\n// spans = document.querySelectorAll('span[data-val=\"color_text\"]')\n// break\n\n// case 'color_fabric':\n// spans = document.querySelectorAll(\n// 'span[data-val=\"color_fabric\"]'\n// )\n// break\n// }\n\n// if (spans) {\n// spans.forEach(span => {\n// span.innerText =\n// inputName === 'slogan' ? `\"${inputValue}\"` : inputValue\n// })\n// }\n// }\n\n// if (\n// e.target instanceof HTMLButtonElement &&\n// e.target.dataset.action === 'back'\n// ) {\n// const fieldsets = Array.from(form.querySelectorAll('fieldset'))\n// const currentFieldsetIndex = fieldsets.findIndex(fieldset =>\n// fieldset.contains(e.target as HTMLButtonElement)\n// )\n// if (currentFieldsetIndex !== -1 && currentFieldsetIndex > 0) {\n// moveSlide(currentFieldsetIndex - 1)\n// }\n// } else if (\n// e.target instanceof HTMLInputElement &&\n// e.target.type === 'radio'\n// ) {\n// const fieldsets = Array.from(form.querySelectorAll('fieldset'))\n// const currentFieldsetIndex = fieldsets.findIndex(fieldset =>\n// fieldset.contains(e.target as HTMLInputElement)\n// )\n// if (\n// currentFieldsetIndex !== -1 &&\n// currentFieldsetIndex < fieldsets.length - 1\n// ) {\n// moveSlide(currentFieldsetIndex + 1)\n// }\n// }\n// })\n"], "mappings": "mBACA,IAAMA,EAAO,SAAS,cAAc,MAAM,EAGpCC,EAAaC,GAAgB,CAC/B,IAAMC,EAAMH,EAAK,iBAAiB,UAAU,EAAEE,CAAG,EAC7CC,GACAA,EAAI,eAAe,CAAE,SAAU,QAAS,CAAC,CAEjD,EAGAH,EAAK,iBAAiB,QAAS,GAAK,CAEhC,GAAI,EAAE,kBAAkB,iBAAkB,CACtC,IAAMI,EAAY,EAAE,OAAO,KACrBC,EAAa,EAAE,OAAO,MAExBC,EAA8D,KAElE,OAAQF,EAAW,CACf,IAAK,SACDE,EAAQ,SAAS,iBAAiB,yBAAyB,EAC3D,MAEJ,IAAK,aACDA,EAAQ,SAAS,iBAAiB,6BAA6B,EAC/D,MAEJ,IAAK,eACDA,EAAQ,SAAS,iBACb,+BACJ,EAEA,IAAMC,EAAc,SAAS,cACzB,gCACJ,EAGAA,EAAY,SAAW,GACvB,KACR,CAGID,GACAA,EAAM,QAAQE,GAAQ,CAElBA,EAAK,UACDJ,IAAc,SAAW,IAAIC,CAAU,IAAMA,CACrD,CAAC,CAET,CAGA,GACI,EAAE,kBAAkB,mBACpB,EAAE,OAAO,QAAQ,SAAW,OAC9B,CAEE,IAAMI,EADY,MAAM,KAAKT,EAAK,iBAAiB,UAAU,CAAC,EACvB,UAAUU,GAC7CA,EAAS,SAAS,EAAE,MAA2B,CACnD,EAEID,IAAyB,IAAMA,EAAuB,GACtDR,EAAUQ,EAAuB,CAAC,CAE1C,SACI,EAAE,kBAAkB,kBACpB,EAAE,OAAO,OAAS,QACpB,CACE,IAAME,EAAY,MAAM,KAAKX,EAAK,iBAAiB,UAAU,CAAC,EACxDS,EAAuBE,EAAU,UAAUD,GAC7CA,EAAS,SAAS,EAAE,MAA0B,CAClD,EAGID,IAAyB,IACzBA,EAAuBE,EAAU,OAAS,GAE1CV,EAAUQ,EAAuB,CAAC,CAE1C,CACJ,CAAC", "names": ["form", "moveSlide", "num", "set", "inputName", "inputValue", "spans", "btnCheckout", "span", "currentFieldsetIndex", "fieldset", "fieldsets"] }