Liferay.Loader.define("@liferay/object-web@1.0.108/js/components/Layout/LayoutScreen/ModalAddObjectLayoutField",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/modal","@liferay/object-js-components-web","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","../objectLayoutContext","./RequiredLabel"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({boxIndex:e,observer:t,onClose:a,tabIndex:o}){const[{objectFields:f},s]=(0,i.useLayoutContext)(),[m,g]=(0,d.useState)(""),[j,p]=(0,d.useState)(),L=(0,d.useMemo)((()=>f.filter((({inLayout:e,label:t})=>(0,u.stringIncludesQuery)(t[y],m)&&!e))),[f,m]),{errors:v,handleSubmit:E,setValues:F}=(0,u.useForm)({initialValues:{objectFieldId:0,objectFieldSize:1},onSubmit:t=>{s({payload:{boxIndex:e,objectFieldId:t.objectFieldId,objectFieldSize:12/Number(t.objectFieldSize),tabIndex:o},type:i.TYPES.ADD_OBJECT_LAYOUT_FIELD}),a()},validate:e=>{const t={};return e.objectFieldId||(t.objectFieldId=Liferay.Language.get("required")),t}});return d.default.createElement(r.default,{observer:t},d.default.createElement(n.default,{onSubmit:E},d.default.createElement(r.default.Header,null,Liferay.Language.get("add-field")),d.default.createElement(r.default.Body,null,d.default.createElement(u.AutoComplete,{contentRight:d.default.createElement(c.default,{className:"label-inside-custom-select",required:null==j?void 0:j.required}),emptyStateMessage:Liferay.Language.get("there-are-no-fields-for-this-object"),error:v.objectFieldId,items:L,label:Liferay.Language.get("field"),onChangeQuery:g,onSelectItem:e=>{p(e),F({objectFieldId:e.id})},query:m,required:!0,value:null==j?void 0:j.label[y]},(({label:e,required:t})=>d.default.createElement("div",{className:"d-flex justify-content-between"},d.default.createElement("div",null,e[y]),d.default.createElement("div",null,d.default.createElement(c.default,{required:t}))))),d.default.createElement(b,{setValues:F})),d.default.createElement(r.default.Footer,{last:d.default.createElement(l.default.Group,{spaced:!0},d.default.createElement(l.default,{displayType:"secondary",onClick:a},Liferay.Language.get("cancel")),d.default.createElement(l.default,{type:"submit"},Liferay.Language.get("save")))})))};var l=s(a("@frontend-taglib-clay$clayui/button")),n=s(a("@frontend-taglib-clay$clayui/form")),r=s(a("@frontend-taglib-clay$clayui/modal")),u=a("@liferay/object-js-components-web"),o=s(a("liferay!frontend-js-react-web$classnames")),d=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var a={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=l?Object.getOwnPropertyDescriptor(e,n):null;r&&(r.get||r.set)?Object.defineProperty(a,n,r):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),i=a("../objectLayoutContext"),c=s(a("./RequiredLabel"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function s(e){return e&&e.__esModule?e:{default:e}}const e=[1,2,3],y=Liferay.ThemeDisplay.getDefaultLanguageId();function b({setValues:t}){const[a,l]=(0,d.useState)(0);return d.default.createElement("div",{className:"box-btn-columns"},e.map(((e,n)=>{const r=[];for(let t=0;t<e;t++)r.push(d.default.createElement("div",{className:"box-btn-columns__item",key:t}));return d.default.createElement("button",{className:(0,o.default)("box-btn-columns__btn",{active:a===n}),key:n,name:"objectFieldSize",onClick:()=>{l(n),t({objectFieldSize:e})},type:"button",value:e},r)})))}}}));
//# sourceMappingURL=ModalAddObjectLayoutField.js.map