Liferay.Loader.define("fragment-web@4.0.70/js/AddFragmentModal",["module","exports","require","@frontend-taglib-clay$clayui/card","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/modal","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./MultiStepFormModal","./fragment-editor/FieldTypeSelector"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function AddFragmentModal({addFragmentEntryURL:e,fieldTypes:t,fragmentTypes:a,namespace:l}){const[f,s]=(0,c.useState)(""),[m,p]=(0,c.useState)(a[0]),[y,g]=(0,c.useState)(null),[b,E]=(0,c.useState)([]),[F,v]=(0,c.useState)(!0),{observer:h,onClose:w}=(0,i.useModal)({onClose:()=>v(!1)});return F&&c.default.createElement(u.MultiStepFormModal,{className:"add-fragment-modal",observer:h,onClose:w,onFormError:g,submitLabel:Liferay.Language.get("add"),submitURL:e,title:Liferay.Language.get("add-fragment")},c.default.createElement(u.MultiStepFormModalStep,null,c.default.createElement("p",{className:"font-weight-semi-bold mb-4 text-secondary"},Liferay.Language.get("select-fragment-type")),c.default.createElement("div",{className:"d-flex"},a.map((e=>c.default.createElement(FragmentTypeCard,{active:m.key===e.key,fragmentType:e,key:e.key,onSelect:p})))),c.default.createElement("input",{name:getFieldName(l,"type"),readOnly:!0,required:!0,type:"hidden",value:m.key})),c.default.createElement(u.MultiStepFormModalStep,null,c.default.createElement(r.default.Group,{className:(0,d.default)({"has-error":y})},c.default.createElement("label",{htmlFor:getFieldName(l,"name")},Liferay.Language.get("name"),c.default.createElement(n.default,{className:"reference-mark",symbol:"asterisk"})),c.default.createElement(r.ClayInput,{id:getFieldName(l,"name"),name:getFieldName(l,"name"),onChange:e=>s(e.target.value),required:!0,type:"text",value:f}),y&&c.default.createElement(r.default.FeedbackGroup,null,c.default.createElement(r.default.FeedbackItem,null,y))),"form"===m.name&&c.default.createElement(o.FieldTypeSelector,{availableFieldTypes:t,description:Liferay.Language.get("specify-which-field-types-this-fragment-will-support.-you-can-change-this-configuration-later"),fieldTypes:b,onChangeFieldTypes:E,portletNamespace:l,small:!0,title:Liferay.Language.get("select-supported-field-types")})))};var l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/card")),r=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/form")),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),i=a("@frontend-taglib-clay$clayui/modal"),d=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),c=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),_interopRequireWildcard(a("liferay!frontend-js-react-web$react"))),u=a("./MultiStepFormModal"),o=a("./fragment-editor/FieldTypeSelector");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}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={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=l?Object.getOwnPropertyDescriptor(e,r):null;n&&(n.get||n.set)?Object.defineProperty(a,r,n):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function getFieldName(e,t){return e.concat(t)}function FragmentTypeCard({active:e,fragmentType:t,onSelect:a}){const{description:r,name:i,symbol:d,title:u}=t;return c.default.createElement(l.default,{active:e,className:"fragment-type-card mb-0 fragment-type-card-".concat(i),onClick:()=>a(t),selectable:!0},c.default.createElement(l.default.AspectRatio,{className:"card-item-first"},c.default.createElement("div",{className:"aspect-ratio-item aspect-ratio-item-center-middle card-type-asset-icon"},c.default.createElement(n.default,{className:"text-white",symbol:d}))),c.default.createElement(l.default.Body,null,c.default.createElement(l.default.Row,null,c.default.createElement("div",{className:"autofit-col autofit-col-expand"},c.default.createElement("section",{className:"autofit-section"},c.default.createElement(l.default.Description,{displayType:"title"},u),c.default.createElement(l.default.Description,{className:"text-dark",displayType:"subtitle",truncate:!1},r))))))}}}));
//# sourceMappingURL=AddFragmentModal.js.map