UNPKG

@antmjs/vantui

Version:

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

63 lines 3 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; 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; } /* eslint-disable import/no-named-as-default */ import { View } from '@tarojs/components'; import { useState } from 'react'; import Swiper from '../swiper'; import SwiperItem from '../swiper-item'; import Overlay from '../overlay'; import Image from '../image'; import { get } from '../default-props'; import { close } from './trigger'; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; var preCls = 'van-image-viewer'; export function ImageViewer(props) { var _useState = useState(get().ImageViewer), _useState2 = _slicedToArray(_useState, 1), d = _useState2[0]; var _d$props = _objectSpread(_objectSpread({}, d), props), _d$props$list = _d$props.list, list = _d$props$list === void 0 ? [] : _d$props$list, _d$props$currentIndex = _d$props.currentIndex, currentIndex = _d$props$currentIndex === void 0 ? 0 : _d$props$currentIndex; var _useState3 = useState(currentIndex), _useState4 = _slicedToArray(_useState3, 2), current = _useState4[0], setCurrent = _useState4[1]; return /*#__PURE__*/_jsxs(View, { className: preCls, onClick: close, children: [/*#__PURE__*/_jsx(Overlay, { show: true }), /*#__PURE__*/_jsx(View, { className: "".concat(preCls, "-main"), children: /*#__PURE__*/_jsx(Swiper // width={375} , { initPage: current, autoPlay: 0, onChange: function onChange(v) { return setCurrent(v); }, pageContent: /*#__PURE__*/_jsxs(View, { className: "page-desc", children: [current + 1, "/", list.length] }), children: list.map(function (item, index) { return /*#__PURE__*/_jsx(SwiperItem, { children: /*#__PURE__*/_jsx(Image, { src: item, fit: "widthFix", width: "100%", height: "100%" }) }, "ImageViewer#".concat(index)); }) }) })] }); } export default ImageViewer;