Liferay.Loader.define("data-engine-taglib@3.3.53/data_layout_builder/js/components/field-sets/FieldSetList",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/empty-state","data-engine-js-components-web","liferay!frontend-js-react-web$react","../../utils/lang.es","../../utils/search.es","../field-types/FieldType.es","./FieldSetModal","./actions/useDeleteFieldSet.es","./actions/usePropagateFieldSet.es"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function FieldSetList({searchTerm:e}){const[t,a]=(0,r.useState)({isVisible:!1}),{fieldSets:g}=(0,n.useFormState)(),{dataDefinition:m}=(0,n.useFormState)({schema:["dataDefinition"]}),y=(0,n.useForm)(),p=(0,f.default)(),L=(0,c.default)(),b=function getFilteredFieldsets(e,t){const a=(0,s.getSearchRegex)(t);return function getSortedFieldsets(e){return e.sort(((e,t)=>{const a=(0,d.getLocalizedValue)(e.defaultLanguageId,e.name),i=(0,d.getLocalizedValue)(t.defaultLanguageId,t.name);return a.localeCompare(i)}))}(e.filter((({defaultLanguageId:e,name:t})=>a.test((0,d.getLocalizedValue)(e,t)))))}(g,e),S=new Set;m.dataDefinitionFields.forEach((({customProperties:{ddmStructureId:e},fieldType:t})=>{"fieldset"===t&&S.add(parseInt(e,10))}));const toggleFieldSet=e=>{a((({isVisible:t})=>({fieldSet:e,isVisible:!t})))},CreateNewFieldsetButton=()=>r.default.createElement(i.default,{block:!0,className:"add-fieldset",displayType:"secondary",onClick:()=>toggleFieldSet()},Liferay.Language.get("create-new-fieldset"));return r.default.createElement(r.default.Fragment,null,b.length?r.default.createElement(r.default.Fragment,null,r.default.createElement(CreateNewFieldsetButton,null),r.default.createElement("div",{className:"mt-3"},b.map((e=>{const t=[{action:()=>toggleFieldSet(e),name:Liferay.Language.get("edit")},{action:()=>L({fieldSet:e,isDeleteAction:!0,modal:{actionMessage:Liferay.Language.get("delete"),fieldSetMessage:Liferay.Language.get("the-fieldset-will-be-deleted-permanently-from"),headerMessage:Liferay.Language.get("delete"),status:"danger",warningMessage:Liferay.Language.get("this-action-may-erase-data-permanently")},onPropagate:p}),name:Liferay.Language.get("delete")}],a=(0,d.getPluralMessage)(Liferay.Language.get("x-field"),Liferay.Language.get("x-fields"),e.dataDefinitionFields.length),i=S.has(e.id),l=(0,d.getLocalizedValue)(e.defaultLanguageId,e.name);return r.default.createElement(u.default,{actions:t,description:a,disabled:i,dragType:n.DRAG_TYPES.DRAG_FIELDSET_ADD,fieldSet:e,icon:"forms",key:e.dataDefinitionKey,label:l,onDoubleClick:()=>{y({payload:{fieldSet:e},type:n.EVENT_TYPES.FIELD_SET.ADD})}})})))):r.default.createElement("div",{className:"mt-2"},e?r.default.createElement(l.default,{description:(0,d.sub)(Liferay.Language.get("there-are-no-results-for-x"),[e]),imgSrc:"".concat(themeDisplay.getPathThemeImages(),"/states/search_state.gif"),small:!0,title:Liferay.Language.get("no-results-found")}):r.default.createElement(l.default,{description:Liferay.Language.get("there-are-no-fieldsets-description"),imgSrc:"".concat(themeDisplay.getPathThemeImages(),"/states/empty_state.gif"),small:!0,title:Liferay.Language.get("there-are-no-fieldsets")},r.default.createElement(CreateNewFieldsetButton,null))),t.isVisible&&r.default.createElement(o.default,{fieldSet:t.fieldSet,onClose:toggleFieldSet}))};var i=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/empty-state")),n=a("data-engine-js-components-web"),r=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 a={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var n=i?Object.getOwnPropertyDescriptor(e,l):null;n&&(n.get||n.set)?Object.defineProperty(a,l,n):a[l]=e[l]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),d=a("../../utils/lang.es"),s=a("../../utils/search.es"),u=_interopRequireDefault(a("../field-types/FieldType.es")),o=_interopRequireDefault(a("./FieldSetModal")),f=_interopRequireDefault(a("./actions/useDeleteFieldSet.es")),c=_interopRequireDefault(a("./actions/usePropagateFieldSet.es"));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}}}}));
//# sourceMappingURL=FieldSetList.js.map