Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.179/page_editor/app/components/fragment_configuration_fields/ItemSelectorField",["module","exports","require","@frontend-taglib-clay$clayui/form","@liferay/frontend-js-react-web","frontend-js-components-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../common/components/ItemSelector","../../../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 l=(0,o.useContext)(i.CollectionItemContext),{typeOptions:a={}}=e,f=l.collectionItem,u=null!==f,{className:d,classPK:p,externalReferenceCode:m}=u?f:r;return o.default.createElement(o.default.Fragment,null,o.default.createElement(c.default,{helpText:e.description,itemSelectorURL:a.infoItemSelectorURL,label:e.label,modalProps:{height:"60vh",size:a.modalSize},onItemSelect:r=>{t(e.name,r)},selectedItem:u?_objectSpread(_objectSpread({},f),{},{title:f.title||Liferay.Language.get("collection-item")}):r,showEditControls:!u,transformValueCallback:s.default}),a.enableSelectTemplate&&d&&o.default.createElement(n.default.Group,{small:!0},o.default.createElement(TemplateSelector,{className:d,classPK:p,externalReferenceCode:m,onTemplateSelect:n=>{t(e.name,_objectSpread(_objectSpread({},r),{},{template:n}))},selectedTemplate:r.template})))};var n=_interopRequireDefault(r("@frontend-taglib-clay$clayui/form")),l=r("@liferay/frontend-js-react-web"),a=r("frontend-js-components-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={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var a=n?Object.getOwnPropertyDescriptor(e,l):null;a&&(a.get||a.set)?Object.defineProperty(r,l,a):r[l]=e[l]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"))),c=_interopRequireDefault(r("../../../common/components/ItemSelector")),i=(r("../../../prop_types/index"),r("../../contexts/CollectionItemContext")),f=r("../../contexts/StoreContext"),u=_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 n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}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:c,selectedTemplate:i})=>{const s=(0,f.useDispatch)(),[d,p]=(0,o.useState)([]),m=(0,l.useIsMounted)(),y=(0,a.useId)();return(0,o.useEffect)((()=>{m()&&u.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(n.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=>{c(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