UNPKG

@wordpress/components

Version:
33 lines (31 loc) 1.05 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = BottomSheetCyclePickerCell; var _cell = _interopRequireDefault(require("./cell")); var _jsxRuntime = require("react/jsx-runtime"); /** * Internal dependencies */ function BottomSheetCyclePickerCell(props) { const { value, options, onChangeValue, ...cellProps } = props; const nextOptionValue = () => { return options[(selectedOptionIndex + 1) % options.length].value; }; const selectedOptionIndex = options.findIndex(option => option.value === value); const optionsContainsValue = options.length > 0 && selectedOptionIndex !== -1; return /*#__PURE__*/(0, _jsxRuntime.jsx)(_cell.default, { onPress: () => optionsContainsValue && onChangeValue(nextOptionValue()), editable: false, value: optionsContainsValue && options[selectedOptionIndex].name, ...cellProps }); } //# sourceMappingURL=cycle-picker-cell.native.js.map