Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.174/page_editor/app/components/fragment_configuration_fields/ItemSelectorField",["module","exports","require","@frontend-taglib-clay$clayui/form","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../common/components/ItemSelector","../../../common/hooks/useId","../../../prop_types/index","../../contexts/CollectionItemContext","../../contexts/StoreContext","../../services/InfoItemService","../../utils/item_selector_value/itemSelectorValueToInfoItem"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.ItemSelectorField=function ItemSelectorField({field:e,onValueSelect:t,value:r={}}){const n=(0,o.useContext)(i.CollectionItemContext),{typeOptions:c={}}=e,u=n.collectionItem,f=null!==u,{className:d,classPK:p,externalReferenceCode:m}=f?u:r;return o.default.createElement(o.default.Fragment,null,o.default.createElement(a.default,{helpText:e.description,itemSelectorURL:c.infoItemSelectorURL,label:e.label,modalProps:{height:"60vh",size:c.modalSize},onItemSelect:r=>{t(e.name,r)},selectedItem:f?_objectSpread(_objectSpread({},u),{},{title:u.title||Liferay.Language.get("collection-item")}):r,showEditControls:!f,transformValueCallback:s.default}),c.enableSelectTemplate&&d&&o.default.createElement(l.default.Group,{small:!0},o.default.createElement(TemplateSelector,{className:d,classPK:p,externalReferenceCode:m,onTemplateSelect:l=>{t(e.name,_objectSpread(_objectSpread({},r),{},{template:l}))},selectedTemplate:r.template})))};var l=_interopRequireDefault(r("@frontend-taglib-clay$clayui/form")),n=r("@liferay/frontend-js-react-web"),o=(_interopRequireDefault(r("liferay!frontend-js-react-web$prop-types")),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 r={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var o=l?Object.getOwnPropertyDescriptor(e,n):null;o&&(o.get||o.set)?Object.defineProperty(r,n,o):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"))),a=_interopRequireDefault(r("../../../common/components/ItemSelector")),c=r("../../../common/hooks/useId"),i=(r("../../../prop_types/index"),r("../../contexts/CollectionItemContext")),u=r("../../contexts/StoreContext"),f=_interopRequireDefault(r("../../services/InfoItemService")),s=_interopRequireDefault(r("../../utils/item_selector_value/itemSelectorValueToInfoItem"));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}}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,l)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const TemplateSelector=({className:e,classPK:t,externalReferenceCode:r,onTemplateSelect:a,selectedTemplate:i})=>{const s=(0,u.useDispatch)(),[d,p]=(0,o.useState)([]),m=(0,n.useIsMounted)(),y=(0,c.useId)();return(0,o.useEffect)((()=>{m()&&f.default.getAvailableTemplates({className:e,classPK:t,externalReferenceCode:r,onNetworkStatus:s}).then((e=>{p(e)}))}),[e,t,r,s,m]),o.default.createElement(o.default.Fragment,null,o.default.createElement(l.default.Group,{small:!0},o.default.createElement("label",{htmlFor:y},Liferay.Language.get("template")),o.default.createElement("select",{className:"form-control",id:y,onChange:e=>{a(e.target.options[e.target.selectedIndex].dataset)}},d.map((e=>e.templates?o.default.createElement("optgroup",{key:e.label,label:e.label},e.templates.map((e=>o.default.createElement("option",{"data-info-item-renderer-key":e.infoItemRendererKey,"data-template-key":e.templateKey,key:e.label,selected:i&&i.infoItemRendererKey===e.infoItemRendererKey&&(!i.templateKey||i.templateKey&&i.templateKey===e.templateKey)},e.label)))):o.default.createElement("option",{"data-info-item-renderer-key":e.infoItemRendererKey,key:e.label,selected:i&&i.infoItemRendererKey===e.infoItemRendererKey},e.label))))))}}}));
//# sourceMappingURL=ItemSelectorField.js.map