UNPKG

@fruits-chain/react-native-xiaoshu

Version:
58 lines (51 loc) • 2.01 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React, { memo } from 'react'; import Portal from '../portal'; import PickerView from './picker'; import PickerMethodView from './picker-method'; /** * 选择器 */ const Picker = opts => { return new Promise(resolve => { const key = Portal.add( /*#__PURE__*/React.createElement(PickerMethodView, _extends({}, opts, { onCancel: (v, c) => { var _opts$onCancel; (_opts$onCancel = opts.onCancel) === null || _opts$onCancel === void 0 ? void 0 : _opts$onCancel.call(opts, v, c); resolve({ action: 'cancel', values: v, columns: c }); }, onConfirm: (v, c) => { var _opts$onConfirm; (_opts$onConfirm = opts.onConfirm) === null || _opts$onConfirm === void 0 ? void 0 : _opts$onConfirm.call(opts, v, c); resolve({ action: 'confirm', values: v, columns: c }); }, onPressOverlay: (v, c) => { var _opts$onPressOverlay; (_opts$onPressOverlay = opts.onPressOverlay) === null || _opts$onPressOverlay === void 0 ? void 0 : _opts$onPressOverlay.call(opts, v, c); resolve({ action: 'overlay', values: v, columns: c }); }, onClosed: () => { var _opts$onClosed; (_opts$onClosed = opts.onClosed) === null || _opts$onClosed === void 0 ? void 0 : _opts$onClosed.call(opts); Portal.remove(key); } }))); }); }; Picker.Component = /*#__PURE__*/memo(props => { return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(PickerView, props)); }); export default Picker; //# sourceMappingURL=index.js.map