Liferay.Loader.define("segments-web@3.0.68/js/components/title_editor/LocalizedDropdown.es",["module","exports","require","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../utils/key-constants.es"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(a("@frontend-taglib-clay$clayui/icon")),l=(r(a("liferay!frontend-js-react-web$prop-types")),r(a("liferay!frontend-js-react-web$react"))),s=a("../../utils/key-constants.es");function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class e extends l.default.Component{constructor(e){super(e),o(this,"_handleButtonClick",(()=>{this.setState((e=>({open:!e.open})))})),o(this,"_handleButtonBlur",(()=>{this.state.open&&(this.timer=setTimeout((()=>{this.setState((()=>({open:!1})))}),200))})),o(this,"_changeLanguage",(e=>{this.setState({currentLangKey:i(e),currentLangTag:i(e,!1),open:!1},(()=>this.props.onLanguageChange(e)))})),o(this,"_handleItemFocus",(()=>{clearTimeout(this.timer)})),o(this,"_handleLanguageClick",(e=>()=>this._changeLanguage(e))),o(this,"_handleLanguageKeyboard",(e=>t=>{t.keyCode===s.ENTER&&this._changeLanguage(e)}));const{initialLang:t,initialOpen:a}=e;this.state={currentLangKey:i(t),currentLangTag:i(t,!1),open:a}}render(){const{currentLangKey:e,currentLangTag:t,open:a}=this.state,{availableLanguages:s,defaultLang:r}=this.props;return l.default.createElement("div",{className:"dropdown postion-relative lfr-icon-menu ".concat(a?"open":"")},l.default.createElement("button",{"aria-expanded":"false","aria-haspopup":"true",className:"btn btn-monospaced btn-secondary dropdown-toggle","data-testid":"localized-dropdown-button",onBlur:this._handleButtonBlur,onClick:this._handleButtonClick,role:"button",title:"",type:"button"},l.default.createElement("span",{className:"inline-item"},l.default.createElement(n.default,{key:e,symbol:e})),l.default.createElement("span",{className:"btn-section"},t)),a&&l.default.createElement("ul",{className:"d-block dropdown-menu",role:"menu"},s.map((e=>{const{hasValue:t,key:a}=e;return l.default.createElement("li",{key:a,onBlur:this._handleButtonBlur,onClick:this._handleLanguageClick(a),onFocus:this._handleItemFocus,onKeyDown:this._handleLanguageKeyboard(a),role:"presentation"},l.default.createElement("span",{className:"dropdown-item lfr-icon-item palette-item taglib-icon",role:"menuitem",tabIndex:"0",target:"_self"},l.default.createElement("span",{className:"inline-item inline-item-before"},l.default.createElement(n.default,{symbol:i(a)})),l.default.createElement("span",{className:"taglib-text-icon"},i(a,!1),r===a&&l.default.createElement("span",{className:"label label-info ml-1"},Liferay.Language.get("default-value")),r!==a&&(t?l.default.createElement("span",{className:"label label-success ml-1"},Liferay.Language.get("translated")):l.default.createElement("span",{className:"label label-warning ml-1"},Liferay.Language.get("untranslated"))))))}))))}}function i(e="",t=!0){let a=e.replace(/_/g,"-");return t&&(a=a.toLowerCase()),a}o(e,"defaultProps",{availableLanguages:[]});var u=e;t.default=u}}));
//# sourceMappingURL=LocalizedDropdown.es.js.map