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patternlib-language-picker/patternlib-language-picker.scss?tag=patternlib-language-picker&encapsulation=shadow","./src/components/patternlib-language-picker/patternlib-language-picker.tsx"],"sourcesContent":[":host {\n display: inline-block;\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Listen, Prop, State, Watch } from '@stencil/core';\n\nimport { LhLanguageSelectEvent } from '../../utils/events/select';\nimport { ClassNames } from '../../utils/interfaces';\nimport { returnScreenSize } from '../../utils/screen';\nimport { observeRootChange } from '../../utils/utils';\n\nexport interface OptionItem {\n label: string;\n value: string;\n detail: string;\n}\n\n@Component({\n tag: 'patternlib-language-picker',\n styleUrl: 'patternlib-language-picker.scss',\n shadow: true,\n})\nexport class PatternlibLanguagePicker {\n private _optionData: OptionItem[] | null = null;\n private observer: MutationObserver;\n\n @Element() hostElement: HTMLPatternlibLanguagePickerElement;\n\n /**\n * Set the LanguagePicker select options\n */\n @Prop() options: OptionItem[] | string;\n\n /**\n * Set the LanguagePicker default selected value\n */\n @Prop() selected: string;\n\n /**\n * Set the width of the Flyoutmenu in px\n */\n @Prop() width = '256px';\n\n /**\n * Show the Flyoutmenu\n */\n @Prop() show?: boolean = false;\n\n /**\n * Set the flyout position of the Flyoutmenu\n */\n @Prop() flyoutPosition: 'top' | 'bottom' | 'auto' = 'auto';\n\n /**\n * Internal state to memorize if Flyoutmenu is open\n **/\n @State() isOpen: boolean = this.show;\n\n @State() mobile = false;\n\n /**\n * Internal state to save available option items\n */\n @State() languages: OptionItem[] = [];\n\n /**\n * Internal state to save current selected option item\n */\n @State() selectedLanguage: OptionItem | null = null;\n\n /**\n * Monitoring the options data\n */\n @Watch('options')\n arrayDataWatcher(newValue: OptionItem[] | string) {\n if (typeof newValue === 'string') {\n this._optionData = JSON.parse(newValue);\n } else {\n this._optionData = newValue;\n }\n this.languages = this._optionData;\n this.stringDataWatcher(this.selected);\n }\n\n /**\n * Monitoring the selected data\n */\n @Watch('selected')\n stringDataWatcher(defaultValue: OptionItem[] | string) {\n if (typeof defaultValue === 'string' && defaultValue != '' && this._optionData !== null && this._optionData.length > 0) {\n const defaultSelectedItem = this._optionData.filter(item => item.value === defaultValue);\n this.selectedLanguage = defaultSelectedItem[0];\n }\n }\n\n /**\n * Set the LanguagePicker event for other components to listen to the selected option item\n */\n @Event({ eventName: 'lhSelect' }) select: EventEmitter;\n\n constructor() {\n this.selectItemClick = this.selectItemClick.bind(this);\n this.openFlyoutmenu = this.openFlyoutmenu.bind(this);\n this.onFlyoutClosed = this.onFlyoutClosed.bind(this);\n }\n\n componentWillLoad() {\n this.arrayDataWatcher(this.options);\n this.stringDataWatcher(this.selected);\n const screen = returnScreenSize();\n if (screen === 'isMobile') {\n this.mobile = true;\n }\n }\n\n connectedCallback() {\n const target = document.documentElement;\n const attribute = 'breakpoint';\n const options = {\n attributes: true,\n };\n\n const callback = e => {\n const screen = observeRootChange(attribute, e);\n if (screen !== null) {\n this.mobile = screen === 'isMobile';\n }\n };\n\n this.observer = new MutationObserver(callback);\n this.observer.observe(target, options);\n }\n\n disconnectedCallback() {\n this.observer.disconnect();\n }\n\n /**\n * Provide a method to monitor if the component gets clicked outside\n */\n @Listen('click', { target: 'window' })\n handleWindowClick(e) {\n if (this.isOpen) {\n if (e.target != this.hostElement) {\n this.isOpen = false;\n }\n }\n }\n\n private async openFlyoutmenu(e: MouseEvent) {\n this.isOpen = !this.isOpen;\n\n /* IE11 fix without it would also trigger handleWindowClick and set isOpen to false again */\n e.stopPropagation();\n e.preventDefault();\n }\n\n private selectItemClick(item: OptionItem) {\n return (_: MouseEvent) => {\n this.stringDataWatcher(item.value);\n this.select.emit({ selected: item.value });\n this.isOpen = false;\n };\n }\n\n private onFlyoutClosed() {\n this.isOpen = false;\n }\n\n render() {\n const flyoutmenuContentClasses: ClassNames = {\n 'grid py-4 px-0 w-full box-border': true,\n };\n\n return (\n \n \n \n \n \n
\n {this.languages?.map(item => {\n return ;\n })}\n
\n
\n
\n );\n }\n}\n"],"version":3}