Liferay.Loader.define("data-engine-taglib@3.3.26/data_layout_builder/js/components/field-sets/FieldSetList",["module","exports","require","@frontend-taglib-clay$clayui/button","data-engine-js-components-web","liferay!frontend-js-react-web$react","../../utils/lang.es","../../utils/search.es","../empty-state/EmptyState.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({searchTerm:e}){const[t,a]=(0,i.useState)({isVisible:!1}),{fieldSets:g}=(0,l.useFormState)(),{dataDefinition:y}=(0,l.useFormState)({schema:["dataDefinition"]}),m=(0,l.useForm)(),p=(0,f.default)(),L=(0,c.default)(),S=function(e,t){const a=(0,d.getSearchRegex)(t);return function(e){return e.sort(((e,t)=>{const a=(0,r.getLocalizedValue)(e.defaultLanguageId,e.name),n=(0,r.getLocalizedValue)(t.defaultLanguageId,t.name);return a.localeCompare(n)}))}(e.filter((({defaultLanguageId:e,name:t})=>a.test((0,r.getLocalizedValue)(e,t)))))}(g,e),b=new Set;y.dataDefinitionFields.forEach((({customProperties:{ddmStructureId:e},fieldType:t})=>{"fieldset"===t&&b.add(parseInt(e,10))}));const E=e=>{a((({isVisible:t})=>({fieldSet:e,isVisible:!t})))},D=()=>i.default.createElement(n.default,{block:!0,className:"add-fieldset",displayType:"secondary",onClick:()=>E()},Liferay.Language.get("create-new-fieldset"));return i.default.createElement(i.default.Fragment,null,S.length?i.default.createElement(i.default.Fragment,null,i.default.createElement(D,null),i.default.createElement("div",{className:"mt-3"},S.map((e=>{const t=[{action:()=>E(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,r.getPluralMessage)(Liferay.Language.get("x-field"),Liferay.Language.get("x-fields"),e.dataDefinitionFields.length),n=b.has(e.id),d=(0,r.getLocalizedValue)(e.defaultLanguageId,e.name);return i.default.createElement(u.default,{actions:t,description:a,disabled:n,dragType:l.DRAG_TYPES.DRAG_FIELDSET_ADD,fieldSet:e,icon:"forms",key:e.dataDefinitionKey,label:d,onDoubleClick:()=>{m({payload:{fieldSet:e},type:l.EVENT_TYPES.FIELD_SET.ADD})}})})))):i.default.createElement("div",{className:"mt-2"},i.default.createElement(s.default,{emptyState:{button:D,description:Liferay.Language.get("there-are-no-fieldsets-description"),title:Liferay.Language.get("there-are-no-fieldsets")},keywords:e,small:!0})),t.isVisible&&i.default.createElement(o.default,{fieldSet:t.fieldSet,onClose:E}))};var n=y(a("@frontend-taglib-clay$clayui/button")),l=a("data-engine-js-components-web"),i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=g();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var i=n?Object.getOwnPropertyDescriptor(e,l):null;i&&(i.get||i.set)?Object.defineProperty(a,l,i):a[l]=e[l]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),r=a("../../utils/lang.es"),d=a("../../utils/search.es"),s=y(a("../empty-state/EmptyState.es")),u=y(a("../field-types/FieldType.es")),o=y(a("./FieldSetModal")),f=y(a("./actions/useDeleteFieldSet.es")),c=y(a("./actions/usePropagateFieldSet.es"));function g(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return g=function(){return e},e}function y(e){return e&&e.__esModule?e:{default:e}}}}));
//# sourceMappingURL=FieldSetList.js.map