UNPKG

@antmjs/vantui

Version:

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

54 lines 2.2 kB
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; import { View } from '@tarojs/components'; import React, { useState, useCallback, useEffect } from 'react'; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; export default function Index(props) { var _props$title = props.title, title = _props$title === void 0 ? '日期选择' : _props$title, showTitle = props.showTitle, subtitle = props.subtitle, showSubtitle = props.showSubtitle, firstDayOfWeek = props.firstDayOfWeek, renderTitle = props.renderTitle, onClickSubtitle = props.onClickSubtitle, subtitleStyle = props.subtitleStyle; var _useState = useState([]), _useState2 = _slicedToArray(_useState, 2), weekdays = _useState2[0], setWeekDays = _useState2[1]; var initWeekDay = useCallback(function () { var defaultWeeks = ['日', '一', '二', '三', '四', '五', '六']; var firstDayOfWeek_ = firstDayOfWeek || 0; setWeekDays([].concat(_toConsumableArray(defaultWeeks.slice(firstDayOfWeek_, 7)), _toConsumableArray(defaultWeeks.slice(0, firstDayOfWeek_)))); }, [firstDayOfWeek]); useEffect(function () { initWeekDay(); }, [initWeekDay]); return /*#__PURE__*/_jsxs(View, { className: "van-calendar__header", children: [showTitle && /*#__PURE__*/_jsxs(View, { children: [renderTitle && /*#__PURE__*/_jsx(View, { className: "van-calendar__header-title", children: renderTitle }), /*#__PURE__*/_jsx(View, { className: "van-calendar__header-title", children: title })] }), showSubtitle && /*#__PURE__*/_jsx(View, { className: "van-calendar__header-subtitle", onClick: onClickSubtitle, style: subtitleStyle, children: subtitle }), /*#__PURE__*/_jsx(View, { className: "van-calendar__weekdays", children: weekdays.map(function (item, index) { return /*#__PURE__*/_jsx(View, { className: "van-calendar__weekday", children: item }, "van-calendar__weekdays".concat(index)); }) })] }); }