{"version":3,"sources":["PickerMacOS.macos.js"],"names":["React","processColor","StyleSheet","View","RNCPickerNativeComponent","PickerMacOSItem","props","PickerMacOS","Component","selectedIndex","items","event","onChange","onValueChange","nativeEvent","newValue","newIndex","_picker","state","setNativeProps","getDerivedStateFromProps","Children","toArray","children","forEach","child","index","value","selectedValue","push","label","textColor","color","testID","render","style","picker","styles","pickerMacOS","itemStyle","_onChange","create","height"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;AAEA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAAQC,YAAR,EAAsBC,UAAtB,EAAkCC,IAAlC,QAA6C,cAA7C;AACA,OAAOC,wBAAP,MAAqC,4BAArC;;AA0DA,MAAMC,eAAe,GAAIC,KAAD,IAA4B;AAClD,SAAO,IAAP;AACD,CAFD;;AAIA,MAAMC,WAAN,SAA0BP,KAAK,CAACQ,SAAhC,CAAwD;AAAA;AAAA;;AAAA,qCACX,IADW;;AAAA,mCAGvC;AACbC,MAAAA,aAAa,EAAE,CADF;AAEbC,MAAAA,KAAK,EAAE;AAFM,KAHuC;;AAAA,uCAgDzCC,KAAD,IAAuB;AACjC,UAAI,KAAKL,KAAL,CAAWM,QAAf,EAAyB;AACvB,aAAKN,KAAL,CAAWM,QAAX,CAAoBD,KAApB;AACD;;AACD,UAAI,KAAKL,KAAL,CAAWO,aAAf,EAA8B;AAC5B,aAAKP,KAAL,CAAWO,aAAX,CACEF,KAAK,CAACG,WAAN,CAAkBC,QADpB,EAEEJ,KAAK,CAACG,WAAN,CAAkBE,QAFpB;AAID,OATgC,CAWjC;AACA;AACA;AACA;AACA;AACA;;;AACA,UACE,KAAKC,OAAL,IACA,KAAKC,KAAL,CAAWT,aAAX,KAA6BE,KAAK,CAACG,WAAN,CAAkBE,QAFjD,EAGE;AACA,aAAKC,OAAL,CAAaE,cAAb,CAA4B;AAC1BV,UAAAA,aAAa,EAAE,KAAKS,KAAL,CA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KAAKQ,KAAL,CAAWT,aAR5B;AASE,MAAA,QAAQ,EAAE,KAAK+B;AATjB,MADF,CADF;AAeD;;AA9CqD;;gBAAlDjC,W,UAQkCF,e;;AAoExC,MAAMgC,MAAM,GAAGnC,UAAU,CAACuC,MAAX,CAAkB;AAC/BH,EAAAA,WAAW,EAAE;AACX;AACA;AACA;AACAI,IAAAA,MAAM,EAAE;AAJG;AADkB,CAAlB,CAAf;AASA,eAAenC,WAAf","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n *\n * This is a controlled component version of RNCPickerMacOS\n *\n * @format\n * @flow\n */\n\n'use strict';\n\nimport * as React from 'react';\nimport {processColor, StyleSheet, View} from 'react-native';\nimport RNCPickerNativeComponent from './RNCPickerNativeComponent';\n\nimport type {SyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes';\nimport type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheet';\nimport type {ProcessedColorValue} from 'react-native/Libraries/StyleSheet/processColor';\nimport type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {TextStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';\nimport type {Element, ElementRef, ChildrenArray} from 'react';\nimport type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';\n\ntype PickerMacOSChangeEvent = SyntheticEvent<\n $ReadOnly<{|\n newValue: number | string,\n newIndex: number,\n |}>,\n>;\n\ntype RNCPickerMacOSItemType = $ReadOnly<{|\n label: ?Label,\n value: ?(number | string),\n textColor: ?ProcessedColorValue,\n testID: ?string,\n|}>;\n\ntype RNCPickerMacOSType = HostComponent<\n $ReadOnly<{|\n items: $ReadOnlyArray,\n onChange: (event: PickerMacOSChangeEvent) => void,\n selectedIndex: number,\n style?: ?TextStyleProp,\n testID?: ?string,\n |}>,\n>;\n\ntype Label = Stringish | number;\n\ntype Props = $ReadOnly<{|\n ...ViewProps,\n // $FlowFixMe\n children: ChildrenArray>,\n itemStyle?: ?TextStyleProp,\n onChange?: ?(event: PickerMacOSChangeEvent) => mixed,\n onValueChange?: ?(itemValue: string | number, itemIndex: number) => mixed,\n selectedValue: ?(number | string),\n|}>;\n\ntype State = {|\n selectedIndex: number,\n items: $ReadOnlyArray,\n|};\n\ntype ItemProps = $ReadOnly<{|\n label: ?Label,\n value?: ?(number | string),\n color?: ?ColorValue,\n testID: ?string,\n|}>;\n\nconst PickerMacOSItem = (props: ItemProps): null => {\n return null;\n};\n\nclass PickerMacOS extends React.Component {\n _picker: ?ElementRef = null;\n\n state: State = {\n selectedIndex: 0,\n items: [],\n };\n\n static Item: typeof PickerMacOSItem = PickerMacOSItem;\n\n static getDerivedStateFromProps(props: Props): State {\n let selectedIndex = 0;\n const items = [];\n React.Children.toArray<$FlowFixMe>(props.children).forEach(function (\n child: $FlowFixMe,\n index: number,\n ) {\n if (child.props.value === props.selectedValue) {\n selectedIndex = index;\n }\n items.push({\n value: child.props.value,\n label: child.props.label,\n textColor: processColor(child.props.color),\n testID: child.props.testID,\n });\n });\n return {selectedIndex, items};\n }\n\n render(): React.Node {\n return (\n \n {\n this._picker = picker;\n }}\n testID={this.props.testID}\n style={[styles.pickerMacOS, this.props.itemStyle]}\n // $FlowFixMe\n items={this.state.items}\n selectedIndex={this.state.selectedIndex}\n onChange={this._onChange}\n />\n \n );\n }\n\n _onChange = (event: $FlowFixMe) => {\n if (this.props.onChange) {\n this.props.onChange(event);\n }\n if (this.props.onValueChange) {\n this.props.onValueChange(\n event.nativeEvent.newValue,\n event.nativeEvent.newIndex,\n );\n }\n\n // The picker is a controlled component. This means we expect the\n // on*Change handlers to be in charge of updating our\n // `selectedValue` prop. That way they can also\n // disallow/undo/mutate the selection of certain values. In other\n // words, the embedder of this component should be the source of\n // truth, not the native component.\n if (\n this._picker &&\n this.state.selectedIndex !== event.nativeEvent.newIndex\n ) {\n this._picker.setNativeProps({\n selectedIndex: this.state.selectedIndex,\n });\n }\n };\n}\n\nconst styles = StyleSheet.create({\n pickerMacOS: {\n // The picker will conform to whatever width is given, but we do\n // have to set the component's height explicitly on the\n // surrounding view to ensure it gets rendered.\n height: 24,\n },\n});\n\nexport default PickerMacOS;\n"]}