{"version":3,"file":"render.mjs","sources":["src/common.mjs","src/render.mjs"],"sourcesContent":["// Common Utilities Class\nexport default class {\n\tconstructor(objContext) {\n\t\tthis.sectionLayoutData = objContext.sectionLayoutData\n\t\tthis.renderMode = objContext.renderMode || false\n\t\tthis.HTML = objContext.DOMNode || false\n\t\tthis.customSettings = this.sectionLayoutData.customSettingsData || {}\n\t}\n\n\tcreateElement = (element) => {\n\t\treturn this.HTML ?\n\t\t\tnew this.HTML(element, {}, '') :\n\t\t\tdocument.createElement(element)\n\t}\n\n\tshapeData(parentObj) {\n\t\ttry {\n\t\t\tconst self = this\n\n\t\t\t// Set up the elements\n\t\t\tconst rootDiv = self.createElement('div')\n\t\t\trootDiv.classList.add('two-col-section')\n\n\t\t\t// Add the dropzones\n\t\t\tif (self.renderMode && self.renderMode === SCSRenderAPI.RENDER_MODE_EDIT && self.sectionLayoutData.components.length == 0) {\n\t\t\t\tconst getComponentGroup = () => SCSRenderAPI.addComponentToPageModel({\n\t\t\t\t\ttype: 'scs-componentgroup',\n\t\t\t\t\tid: 'scs-componentgroup',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tcomponents: [],\n\t\t\t\t\t\tgrid: ''\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t\n\t\t\t\tconst componentGroupLeft = getComponentGroup()\n\t\t\t\tconst componentGroupRight = getComponentGroup()\n\t\t\t\t\n\t\t\t\tself.sectionLayoutData.components = [componentGroupLeft, componentGroupRight]\n\t\t\t}\n\n\t\t\tthis.setLayoutClasses(rootDiv)\n\n\t\t\t// Append elements to the DOM\n\t\t\tparentObj.appendChild(rootDiv)\n\n\t\t\t// Add dropped components to the dropzones\n\t\t\tconst addComponentToColumn = (componentGroupId, headElement) => {\t\n\t\t\t\tconst elDropzoneDiv = self.createElement('div')\n\t\t\t\telDropzoneDiv.setAttribute('id', componentGroupId)\n\t\t\t\t\n\t\t\t\theadElement.appendChild(elDropzoneDiv)\n\t\t\t}\n\t\t\t\n\t\t\t// Loop through the components and call addComponentToColumn\n\t\t\tself.sectionLayoutData.components.forEach(componentId => {\n\t\t\t\taddComponentToColumn(componentId, rootDiv)\t\n\t\t\t})\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t}\n\t}\n\n\tsetLayoutClasses(element) {\n const arClasses = []\n\t\tif (this.customSettings.alignment) {\n\t\t\tif (this.customSettings.alignment == \"left\") {\n\t\t\t\tarClasses.push(\"horizontal\", \"left\")\n\t\t\t}\n\t\t\tif (this.customSettings.alignment == \"right\") {\n\t\t\t\tarClasses.push(\"horizontal\", \"right\")\n\t\t\t}\n\t\t\tif (this.customSettings.alignment == \"top\") {\n\t\t\t\tarClasses.push(\"vertical\", \"top\")\n\t\t\t}\n\t\t\tif (this.customSettings.alignment == \"bottom\") {\n\t\t\t\tarClasses.push(\"vertical\", \"bottom\")\n\t\t\t}\n\t\t\tif (arClasses.length == 0) arClasses.push(\"horizontal\", \"left\")\n\t\t\tarClasses.forEach((className) => element.classList.add(className))\n\t\t}\n\t\tif (this.customSettings.backgroundColor) {\n\t\t\telement.setAttribute(\"style\", `--background-color: ${this.customSettings.backgroundColor}`)\n\t\t\tif (this.customSettings.backgroundColor == \"#ffffff\") {\n\t\t\t\telement.setAttribute(\"style\", `--background-color: var(--color-white);--bottom-border: none;`)\n\t\t\t}\n\t\t} else {\n\t\t\telement.setAttribute(\"style\", `--background-color: #ffffff`)\n\t\t}\n }\n\n\t// Only do this in non-Node environments. This will get called on hydration.\n\taddListeners() {\n\t\tdocument.querySelectorAll('details').forEach((el) => {\n\t\t\tnew commonUtils(el);\n\t\t});\n\t}\n}","/* globals SCSRenderAPI */\nimport common from './common'\nexport default class {\n\n constructor(params) {\n // store the args\n this.sectionLayoutData = params.sectionLayoutData || {};\n this.renderMode = params.renderMode || SCSRenderAPI.getRenderMode();\n \n if (Array.isArray(this.sectionLayoutData.components)) {\n this.sectionLayoutData.components = this.sectionLayoutData.components.splice(0, 2)\n }\n\n // store the path to the /assets folder\n this.assetsPath =\n import.meta.url.replace('/render.mjs', '');\n\n // get any OCM environment resources \n this.$ = SCSRenderAPI.getJQuery();\n\n // load up the component's CSS\n SCSRenderAPI.importCSS(this.assetsPath + '/styles/layout.css');\n\n this.common = new common({\n sectionLayoutData: this.sectionLayoutData,\n renderMode: this.renderMode,\n DOMNode: false\n });\n }\n\n createComponentDiv(componentId) {\n return '
';\n }\n\n\n render(parentObj) {\n this.common.shapeData(parentObj);\n return;\n var html = '';\n var maxItems = 0;\n var emptyClass;\n var components = this.sectionLayoutData.components || [];\n\n if (this.sectionLayoutData.customSettingsData &&\n (typeof this.sectionLayoutData.customSettingsData.maxItems === 'number') &&\n (this.sectionLayoutData.customSettingsData.maxItems > 0)) {\n maxItems = this.sectionLayoutData.customSettingsData.maxItems;\n }\n\n try {\n // Add the child components to the section layout. For each of the child \n // components, add a
to the page. The child components will be \n // rendered into these
s.\n components.forEach((value, index) => {\n if (!maxItems || (index < maxItems)) {\n html += this.createComponentDiv(value);\n }\n });\n\n // Add a drop zone to the section layout in edit mode, if applicable\n if ((this.renderMode === SCSRenderAPI.RENDER_MODE_EDIT) &&\n ((maxItems === 0) || (components.length < maxItems))) {\n emptyClass = (components.length > 0) ? '' : 'sl-empty';\n this.$(parentObj).append('
Add Item
');\n }\n\n if (html) {\n this.$(parentObj).append(html);\n }\n } catch (e) {\n console.error(e);\n }\n }\n\n // dynamic API for adding additional components through \"load more\" when used in a Content List\n addComponent(parentObj, component) {\n // create the component div and add it to the parent object\n this.$(parentObj).append(this.createComponentDiv(component));\n }\n};"],"names":["common","constructor","objContext","element","HTML","this","document","createElement","sectionLayoutData","renderMode","DOMNode","customSettings","customSettingsData","shapeData","parentObj","self","rootDiv","classList","add","SCSRenderAPI","RENDER_MODE_EDIT","components","length","addComponentToPageModel","type","id","data","grid","componentGroupLeft","getComponentGroup","componentGroupRight","setLayoutClasses","appendChild","addComponentToColumn","componentGroupId","headElement","elDropzoneDiv","setAttribute","forEach","componentId","e","console","error","alignment","arClasses","push","className","backgroundColor","concat","addListeners","querySelectorAll","el","commonUtils","render","params","getRenderMode","Array","isArray","splice","assetsPath","import","meta","url","replace","$","getJQuery","importCSS","createComponentDiv","addComponent","component","append"],"mappings":"MACqBA,EACpBC,YAAYC,eAOKC,GACJC,KAAAA,KACX,IAAIC,KAAKD,KAAKD,EAAS,CAAA,EAAI,IAC3BG,SAASC,cAAcJ,MAHRA,qBAAAA,4FANhBE,KAAKG,kBAAoBN,EAAWM,kBACpCH,KAAKI,WAAaP,EAAWO,aAAc,EAC3CJ,KAAKD,KAAOF,EAAWQ,UAAW,EAClCL,KAAKM,eAAiBN,KAAKG,kBAAkBI,oBAAsB,EACnE,CAQDC,UAAUC,GACT,IACC,MAAUC,EAAGV,OAGGU,EAAKR,cAAc,OAInC,GAHAS,EAAQC,UAAUC,IAAI,mBAGlBH,EAAKN,YAAcM,EAAKN,aAAeU,aAAaC,kBAAgE,GAA5CL,EAAKP,kBAAkBa,WAAWC,OAAa,CAC1H,QAA0B,IAAMH,aAAaI,wBAAwB,CACpEC,KAAM,qBACNC,GAAI,qBACJC,KAAM,CACLL,WAAY,GACZM,KAAM,MAIgBC,EAAGC,IACFC,EAAGD,IAE5Bd,EAAKP,kBAAkBa,WAAa,CAACO,EAAoBE,EACzD,CAEDzB,KAAK0B,iBAAiBf,GAGtBF,EAAUkB,YAAYhB,GAGtB,MAA0BiB,EAAG,CAACC,EAAkBC,KAC/C,MAAmBC,EAAGrB,EAAKR,cAAc,OACzC6B,EAAcC,aAAa,KAAMH,GAEjCC,EAAYH,YAAYI,EAAxB,EAIDrB,EAAKP,kBAAkBa,WAAWiB,SAAQC,IACzCN,EAAqBM,EAAavB,EAAlC,GAID,CAFC,MAAOwB,GACRC,QAAQC,MAAMF,EACd,CACD,CAEDT,iBAAiB5B,GACV,QAAkB,GACpBE,KAAKM,eAAegC,YACc,QAAjCtC,KAAKM,eAAegC,WACvBC,EAAUC,KAAK,aAAc,QAEO,SAAjCxC,KAAKM,eAAegC,WACvBC,E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