Liferay.Loader.define("@liferay/object-js-components-web@1.0.33/components/BuilderScreen/BuilderListItem",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/list","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","liferay!frontend-js-react-web$react-dnd","./BuilderListItem.scss"],(function(e,t,l){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=l("@frontend-taglib-clay$clayui/button"),r=_interopRequireDefault(l("@frontend-taglib-clay$clayui/drop-down")),n=_interopRequireDefault(l("@frontend-taglib-clay$clayui/icon")),i=_interopRequireDefault(l("@frontend-taglib-clay$clayui/list")),u=_interopRequireDefault(l("liferay!frontend-js-react-web$classnames")),c=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 l={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=a?Object.getOwnPropertyDescriptor(e,r):null;n&&(n.get||n.set)?Object.defineProperty(l,r,n):l[r]=e[r]}l.default=e,t&&t.set(e,l);return l}(l("liferay!frontend-js-react-web$react")),o=l("liferay!frontend-js-react-web$react-dnd");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}}l("./BuilderListItem.scss");var _default=({disableEdit:e,hasDragAndDrop:t,index:l,label:d,objectFieldName:f,onChangeColumnOrder:s,onDeleteColumn:m,onEditing:b,onEditingObjectFieldName:g,onVisibleEditModal:y,secondColumnValue:p,thirdColumnValues:j})=>{const[_,E]=(0,c.useState)(!1),w=(0,c.useRef)(null),[{isDragging:v},I]=(0,o.useDrag)({collect:e=>({isDragging:e.isDragging()}),item:{index:l,type:"FIELD"}}),[,h]=(0,o.useDrop)({accept:"FIELD",hover(e,t){if(!w.current||!s)return;const a=e.index,r=l;if(a===r)return;const n=w.current.getBoundingClientRect(),i=(n.bottom-n.top)/2,u=t.getClientOffset();if(!u)return;const c=u.y-n.top;a<r&&c<i||a>r&&c>i||(s(a,r),e.index=r)}});I(h(w));return c.default.createElement(i.default.Item,{className:(0,u.default)("lfr-object__object-custom-view-builder-item",{"lfr-object__object-custom-view-builder-item--dragging":v}),flex:!0,ref:t?w:null},t&&c.default.createElement(i.default.ItemField,null,c.default.createElement(a.ClayButtonWithIcon,{"aria-label":Liferay.Util.sub(Liferay.Language.get("drag-x"),d),displayType:null,symbol:"drag"})),c.default.createElement(i.default.ItemField,{className:(0,u.default)("lfr-object__object-builder-list-item-first-column",!t&&"lfr-object__object-builder-list-item-first-column--not-draggable"),expand:!0},c.default.createElement(i.default.ItemTitle,null,d)),c.default.createElement(i.default.ItemField,{className:(0,u.default)("lfr-object__object-builder-list-item-second-column",!t&&"lfr-object__object-builder-list-item-second-column--not-draggable"),expand:!0},c.default.createElement(i.default.ItemText,null,p)),c.default.createElement(i.default.ItemField,{className:(0,u.default)("lfr-object__object-builder-list-item-third-column",!t&&"lfr-object__object-builder-list-item-third-column--not-draggable"),expand:!0},c.default.createElement(i.default.ItemText,null,Array.isArray(j)?null==j?void 0:j.map(((e,t)=>t!==j.length-1?"".concat(e.label,", "):e.label)):j)),c.default.createElement(r.default,{active:_,menuElementAttrs:{className:"lfr-object__object-builder-list-item-dropdown"},onActiveChange:E,trigger:c.default.createElement(a.ClayButtonWithIcon,{"aria-label":Liferay.Language.get("more"),displayType:"unstyled",symbol:"ellipsis-v"})},c.default.createElement(r.default.ItemList,null,!e&&c.default.createElement(r.default.Item,{onClick:()=>(e=>{g&&g(e),b&&b(!0),y&&y(!0)})(f)},c.default.createElement(n.default,{className:"lfr-object__object-custom-view-builder-item-icon",symbol:"pencil"}),Liferay.Language.get("edit")),c.default.createElement(r.default.Item,{onClick:()=>m(f)},c.default.createElement(n.default,{className:"lfr-object__object-custom-view-builder-item-icon",symbol:"trash"}),Liferay.Language.get("delete")))))};t.default=_default}}));
//# sourceMappingURL=BuilderListItem.js.map