@wordpress/components
Version:
UI components for WordPress.
41 lines (37 loc) • 963 B
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import { createElement } from "@wordpress/element";
/**
* Internal dependencies
*/
import Cell from './cell';
import Picker from '../picker';
export default function BottomSheetPickerCell(props) {
const {
options,
hideCancelButton,
onChangeValue,
value,
...cellProps
} = props;
let picker;
const onCellPress = () => {
picker.presentPicker();
};
const onChange = newValue => {
onChangeValue(newValue);
};
const option = options.find(opt => opt.value === value);
const label = option ? option.label : value;
return createElement(Cell, _extends({
onPress: onCellPress,
editable: false,
value: label
}, cellProps), createElement(Picker, {
leftAlign: true,
hideCancelButton: hideCancelButton,
ref: instance => picker = instance,
options: options,
onChange: onChange
}));
}
//# sourceMappingURL=picker-cell.native.js.map