UNPKG

@fruits-chain/react-native-xiaoshu

Version:
35 lines (31 loc) • 1.37 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 ActionSheetView from './action-sheet'; import ActionSheetMethodView from './action-sheet-method'; const ActionSheet = opts => { return new Promise((resolve, reject) => { const key = Portal.add( /*#__PURE__*/React.createElement(ActionSheetMethodView, _extends({}, opts, { onClosed: () => { var _opts$onClosed; Portal.remove(key); (_opts$onClosed = opts.onClosed) === null || _opts$onClosed === void 0 ? void 0 : _opts$onClosed.call(opts); }, callback: (action, item, index) => { if (action === 'item' && item && (index || index === 0)) { resolve({ item, index }); } else { reject(action); } } }))); }); }; ActionSheet.Component = /*#__PURE__*/memo(props => { return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(ActionSheetView, props)); }); export default ActionSheet; //# sourceMappingURL=index.js.map