UNPKG

@wordpress/components

Version:
33 lines (29 loc) 924 B
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@wordpress/element"; /** * External dependencies */ import { findIndex } from 'lodash'; /** * Internal dependencies */ import Cell from './cell'; export default function BottomSheetCyclePickerCell(props) { const { value, options, onChangeValue, ...cellProps } = props; const nextOptionValue = () => { return options[(selectedOptionIndex + 1) % options.length].value; }; const selectedOptionIndex = findIndex(options, ['value', value]); const optionsContainsValue = options.length > 0 && selectedOptionIndex !== -1; return createElement(Cell, _extends({ onPress: () => optionsContainsValue && onChangeValue(nextOptionValue()), editable: false, value: optionsContainsValue && options[selectedOptionIndex].name }, cellProps)); } //# sourceMappingURL=cycle-picker-cell.native.js.map