UNPKG

vantui-edit

Version:

一套适用于Taro3及React的vantui组件库

109 lines (101 loc) 5.06 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["show", "duration", "closeOnClickOverlay", "safeAreaInsetBottom", "overlay", "zIndex", "overlayStyle", "title", "cancelText", "description", "options", "renderDescription", "renderTitle", "onClickOverlay", "onSelect", "onClose", "onCancel"]; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } import { View, Button } from '@tarojs/components'; import { useCallback } from 'react'; import * as computed from './wxs'; import Options from './options'; import VanPopup from './../popup'; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; import { Fragment as _Fragment } from "react/jsx-runtime"; export function ShareSheet(props) { var show = props.show, _props$duration = props.duration, duration = _props$duration === void 0 ? 300 : _props$duration, _props$closeOnClickOv = props.closeOnClickOverlay, closeOnClickOverlay = _props$closeOnClickOv === void 0 ? true : _props$closeOnClickOv, _props$safeAreaInsetB = props.safeAreaInsetBottom, safeAreaInsetBottom = _props$safeAreaInsetB === void 0 ? true : _props$safeAreaInsetB, _props$overlay = props.overlay, overlay = _props$overlay === void 0 ? true : _props$overlay, zIndex = props.zIndex, overlayStyle = props.overlayStyle, title = props.title, _props$cancelText = props.cancelText, cancelText = _props$cancelText === void 0 ? '取消' : _props$cancelText, description = props.description, _props$options = props.options, options = _props$options === void 0 ? [] : _props$options, renderDescription = props.renderDescription, renderTitle = props.renderTitle, onClickOverlay = props.onClickOverlay, onSelect = props.onSelect, onClose = props.onClose, onCancel = props.onCancel, others = _objectWithoutProperties(props, _excluded); var _onClickOverlay = useCallback(function () { onClickOverlay === null || onClickOverlay === void 0 ? void 0 : onClickOverlay(); }, [onClickOverlay]); var _onSelect = useCallback(function (option) { onSelect === null || onSelect === void 0 ? void 0 : onSelect({ detail: option }); }, [onSelect]); var _onClose = useCallback(function () { onClose === null || onClose === void 0 ? void 0 : onClose(); }, [onClose]); var _onCancel = useCallback(function () { onClose === null || onClose === void 0 ? void 0 : onClose(); onCancel === null || onCancel === void 0 ? void 0 : onCancel(); }, [onCancel, onClose]); return /*#__PURE__*/_jsxs(VanPopup, _objectSpread(_objectSpread({ round: true, className: "van-share-sheet", show: show, position: "bottom", overlay: overlay, duration: duration, zIndex: zIndex, overlayStyle: overlayStyle, closeOnClickOverlay: closeOnClickOverlay, safeAreaInsetBottom: safeAreaInsetBottom, onClose: _onClose, onClickOverlay: _onClickOverlay }, others), {}, { children: [/*#__PURE__*/_jsxs(View, { className: "van-share-sheet__header", children: [/*#__PURE__*/_jsx(View, { className: "van-share-sheet__title", children: renderTitle }), title && /*#__PURE__*/_jsx(View, { className: "van-share-sheet__title", children: title }), /*#__PURE__*/_jsx(View, { className: "van-share-sheet__description", children: renderDescription }), description && /*#__PURE__*/_jsx(View, { className: "van-share-sheet__description", children: description })] }), computed.isMulti(options) ? /*#__PURE__*/_jsx(_Fragment, { children: options.map(function (item, index) { return /*#__PURE__*/_jsx(Options, { showBorder: index !== 0, options: item, onSelect: _onSelect }, index); }) }) : /*#__PURE__*/_jsx(Options, { options: options, onSelect: _onSelect }), /*#__PURE__*/_jsx(Button, { className: "van-share-sheet__cancel", onClick: _onCancel, children: cancelText })] })); } export default ShareSheet;