Liferay.Loader.define("data-engine-js-components-web@1.0.112/js/core/components/PageRenderer/WebContentVariant.es",["module","exports","require","@frontend-taglib-clay$clayui/layout","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","liferay!frontend-js-react-web$react-dnd","../../../custom/form/eventTypes","../../hooks/useForm.es","../FieldRepeatableDND","./WebContentVariant.scss"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.Column=void 0;var n=_interopRequireDefault(r("@frontend-taglib-clay$clayui/layout")),d=_interopRequireDefault(r("liferay!frontend-js-react-web$classnames")),a=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var d in e)if(Object.prototype.hasOwnProperty.call(e,d)){var a=n?Object.getOwnPropertyDescriptor(e,d):null;a&&(a.get||a.set)?Object.defineProperty(r,d,a):r[d]=e[d]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),l=r("liferay!frontend-js-react-web$react-dnd"),o=r("../../../custom/form/eventTypes"),i=r("../../hooks/useForm.es"),s=_interopRequireDefault(r("../FieldRepeatableDND"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}r("./WebContentVariant.scss");const e="com_liferay_dynamic_data_mapping_form_web_portlet_DDMFormAdminPortlet",c=(0,a.forwardRef)((({children:t,className:r,column:l,columnClassName:o,index:c,onClick:u,onMouseLeave:f,onMouseOver:m,pageIndex:p,rowIndex:y,viewMode:_},g)=>{const{portletId:b}=(0,i.useFormState)(),v=l.fields[0],x="fieldset"===(null==v?void 0:v.type),F=(null==v?void 0:v.ddmStructureId)&&x;return a.default.createElement(n.default.Col,_extends({},{"data-ddm-field-column":c,"data-ddm-field-page":p,"data-ddm-field-row":y},{className:(0,d.default)("col-ddm",o),key:c,md:l.size,onClick:u,onMouseLeave:f,onMouseOver:m,ref:g}),!!l.fields.length&&a.default.createElement("div",{className:(0,d.default)("ddm-field-container ddm-target h-100",{"ddm-fieldset":!!F,"fields-group":!!x},r),"data-field-name":v.fieldName},l.fields.map(((r,n)=>(_&&b.includes(e)&&(r.predefinedValue=""),r.repeatable?a.default.createElement(a.default.Fragment,{key:n},0===n&&a.default.createElement(Placeholder,{field:r,index:n,nestedFieldIndex:r.nestedFieldIndex}),a.default.createElement(s.default,{field:r,index:n,nestedFieldIndex:r.nestedFieldIndex},t),a.default.createElement(Placeholder,{field:r,index:n+1,nestedFieldIndex:r.nestedFieldIndex?r.nestedFieldIndex+1:r.nestedFieldIndex})):"function"==typeof t?t({field:r,index:n}):t)))))}));function Placeholder({field:e,index:t,nestedFieldIndex:r}){const n=(0,a.useRef)(null),s=(0,i.useForm)(),[{canDrop:c,overTarget:u},f]=(0,l.useDrop)({accept:e.fieldName,canDrop:()=>!0,collect:e=>({canDrop:e.canDrop(),overTarget:e.isOver({shallow:!0})}),drop:e=>{if(!n.current)return;const d=e.index,a=t,l=e.id,i=e.nestedFieldIndex;s({payload:{draggedIndex:d,sourceFieldName:l,sourceNestedFieldIndex:i,targetIndex:a,targetNestedFieldIndex:r},type:o.EVENT_TYPES.FORM_VIEW.REPEATABLE_FIELD.CHANGE_ORDER}),e.index=a}});return a.default.createElement("div",{className:(0,d.default)("lfr-forms__form-view-ddm-target",{"lfr-forms__form-view-ddm-target-over":u&&c}),droppable:"true",ref:e=>{f(e),n.current=e}},a.default.createElement("span",{droppable:"true"}))}t.Column=c,c.displayName="WebContentVariant.Column"}}));
//# sourceMappingURL=WebContentVariant.es.js.map