Liferay.Loader.define("data-engine-taglib@3.3.50/data_layout_builder/js/components/field-types/FieldTypeList.es",["module","exports","require","@frontend-taglib-clay$clayui/empty-state","liferay!frontend-js-react-web$classnames","data-engine-js-components-web","liferay!frontend-js-react-web$react","../../utils/lang.es","../../utils/search.es","../collapsable-panel/CollapsablePanel.es","./FieldType.es"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/empty-state")),n=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),l=a("data-engine-js-components-web"),i=_interopRequireDefault(a("liferay!frontend-js-react-web$react")),o=a("../../utils/lang.es"),s=a("../../utils/search.es"),d=_interopRequireDefault(a("../collapsable-panel/CollapsablePanel.es")),c=_interopRequireDefault(a("./FieldType.es"));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 a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e}).apply(this,arguments)}function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function _objectWithoutProperties(e,t){if(null==e)return{};var a,r,n=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var a,r,n={},l=Object.keys(e);for(r=0;r<l.length;r++)a=l[r],t.indexOf(a)>=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)a=l[r],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}const FieldTypeWrapper=e=>{let{expanded:t,fieldType:a,fieldTypes:r,showArrows:n}=e,o=_objectWithoutProperties(e,["expanded","fieldType","fieldTypes","showArrows"]);const s=(0,l.useForm)(),{activePage:d,pages:p}=(0,l.useFormState)();return i.default.createElement(c.default,_extends({},o,a,{icon:n?t?"angle-down":"angle-right":a.icon,onDoubleClick:({name:e})=>{s({payload:{fieldType:_objectSpread(_objectSpread({},r.find((({name:t})=>t===e))),{},{editable:!0}),indexes:{columnIndex:0,pageIndex:d,rowIndex:p[d].rows.length}},type:l.EVENT_TYPES.FIELD.ADD})}}))},FieldTypeList=({dataDefinition:e,deleteLabel:t,keywords:a,onClick:c,onDelete:p,showEmptyState:f=!0})=>{const{fieldTypes:u}=(0,l.useConfig)(),y=(0,s.getSearchRegex)(a),b=u.filter((({description:e,label:t,system:r})=>!r&&(!a||(y.test(e)||y.test(t))))).sort((({displayOrder:e},{displayOrder:t})=>e-t));return f&&!b.length?i.default.createElement(r.default,{description:(0,o.sub)(Liferay.Language.get("there-are-no-results-for-x"),[a]),imgSrc:"".concat(themeDisplay.getPathThemeImages(),"/states/search_state.gif"),small:!0,title:Liferay.Language.get("no-results-found")}):b.map(((a,r)=>{const{isFieldSet:l,nestedDataDefinitionFields:o=[]}=a,handleOnClick=e=>{!a.disabled&&c&&c(e)};return o.length?i.default.createElement("div",{className:"field-type-list",key:r},i.default.createElement(d.default,{Header:({expanded:r,setExpanded:n})=>i.default.createElement(FieldTypeWrapper,{dataDefinition:e,deleteLabel:t,expanded:r,fieldType:_objectSpread(_objectSpread({},a),{},{className:"".concat(a.className," field-type-header")}),fieldTypes:b,onClick:e=>{n(!r),handleOnClick(e)},onDelete:p,setExpanded:n,showArrows:!0}),className:(0,n.default)({"field-type-fieldgroup":!l,"field-type-fieldset":l})},i.default.createElement("div",{className:"field-type-item position-relative"},o.map((t=>i.default.createElement(FieldTypeWrapper,{dataDefinition:e,draggable:!1,fieldType:_objectSpread(_objectSpread({},t),{},{disabled:a.disabled}),fieldTypes:b,key:"".concat(t.name,"_").concat(r)})))))):i.default.createElement(FieldTypeWrapper,{dataDefinition:e,deleteLabel:t,fieldType:a,fieldTypes:b,key:r,onClick:handleOnClick,onDelete:p})}))};FieldTypeList.displayName="FieldTypeList";var p=FieldTypeList;t.default=p}}));
//# sourceMappingURL=FieldTypeList.es.js.map