From f407579aa161df4ed8746da0127bb3f2a09ab314 Mon Sep 17 00:00:00 2001 From: gaopeng0108 Date: Mon, 22 May 2023 19:29:35 +0800 Subject: [PATCH 1/7] feat: update calendar --- src/components/calendar/calendar.en.md | 9 +- src/components/calendar/calendar.less | 67 +- src/components/calendar/calendar.tsx | 409 +- src/components/calendar/calendar.zh.md | 15 +- src/components/calendar/demos/demo1.tsx | 101 +- src/components/calendar/demos/demo2.tsx | 102 +- .../calendar/demos/{demo4.less => demo3.less} | 17 +- src/components/calendar/demos/demo3.tsx | 162 +- src/components/calendar/demos/demo4.tsx | 68 +- src/components/calendar/demos/demo5.less | 13 - src/components/calendar/demos/demo5.tsx | 25 +- .../__snapshots__/calendar.test.tsx.snap | 13555 ++++++++++------ .../calendar/tests/calendar.test.tsx | 119 +- src/locales/base.ts | 5 + src/locales/zh-CN.ts | 5 + 15 files changed, 9412 insertions(+), 5260 deletions(-) rename src/components/calendar/demos/{demo4.less => demo3.less} (89%) delete mode 100644 src/components/calendar/demos/demo5.less diff --git a/src/components/calendar/calendar.en.md b/src/components/calendar/calendar.en.md index b5d4c4974e..6c1320b8e8 100644 --- a/src/components/calendar/calendar.en.md +++ b/src/components/calendar/calendar.en.md @@ -28,15 +28,10 @@ When the user needs to enter a date, he can select it in the pop-up date panel. | defaultValue | The default selected date or date range. | Same as `value` prop. | - | | max | Maximum value of a selectable range. | `Date` | - | | min | Minimum value of a selectable range. | `Date` | - | - | -| maxPage | Maximum visible page of date. | `Page` | -| minPage | Minimum visible page of date. | `Page` | - | -| nextMonthButton | Contents of the Next Month button on the navigation pane | `React.ReactNode` | `>` | -| nextYearButton | Contents of the next Year button on the navigation pane | `React.ReactNode` | `>>` | | onChange | Trigger when selected date changes. | `(val: Date \| null) => void` when selection mode is "single". `(val: [Date, Date] \| null) => void` when selection mode is "range". | - | | onPageChange | Trigger when changed year or month. | `(year: number, month: number) => void` | - | -| prevMonthButton | Contents of the Last Month button on the navigation pane | `React.ReactNode` | `<` | -| prevYearButton | Contents of the Last year button on the navigation pane | `React.ReactNode` | `<<` | -| renderLabel | The label render function. | `(date: Date) => ReactNode \| null \| undefined` | - | +| renderTop | The top information of date render function. | `(date: Date) => ReactNode \| null \| undefined` | - | +| renderBottom | The bottom information of date render function. | `(date: Date) => ReactNode \| null \| undefined` | - | | selectionMode | The selection mode. Disable selection when this prop is not set. | `'single' \| 'range'` | - | | shouldDisableDate | Set whether the date is disable selection. The min and max Settings are ignored | `(date: Date) => boolean` | - | | value | The selected date or date range. | `Date \| null` when selection mode is "single". `[Date, Date] \| null` when selection mode is "range" | - | diff --git a/src/components/calendar/calendar.less b/src/components/calendar/calendar.less index aaaf8d2e58..8fa093283f 100644 --- a/src/components/calendar/calendar.less +++ b/src/components/calendar/calendar.less @@ -1,32 +1,35 @@ -.adm-calendar { +.adm-calendar, +.adm-calendar-popup { + & &-title { + flex: auto; + font-size: var(--adm-font-size-10); + } & &-header { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - padding-top: 4px; - a.adm-calendar-arrow-button { - padding: 4px 8px; - display: block; - flex: none; - svg { - height: 22px; - } - &.adm-calendar-arrow-button-right { - svg { - transform: rotate(180deg); - } - } - } + padding: 8px; + border-bottom: 1px solid var(--adm-color-border); .adm-calendar-title { - font-size: var(--adm-font-size-10); - flex: auto; text-align: center; } } & &-body { - display: flex; - flex-wrap: wrap; + height: 64vh; + overflow: auto; + + &::-webkit-scrollbar { + display: none; + } + .adm-calendar-title { + position: sticky; + top: 0; + padding: 12px 18px; + background-color: var(--adm-color-box); + } + } + & &-footer { + padding: 12px 18px; + .adm-button { + width: 100%; + } } &-cells { display: flex; @@ -40,7 +43,7 @@ flex: none; box-sizing: border-box; width: calc(100% / 7); - height: 48px; + min-height: 56px; margin-bottom: 4px; padding: 2px; color: var(--adm-color-text); @@ -50,6 +53,7 @@ } &&-disabled { color: var(--adm-color-light); + .adm-calendar-cell-top, .adm-calendar-cell-bottom { color: var(--adm-color-light); } @@ -59,6 +63,7 @@ background: var(--adm-color-primary); color: var(--adm-color-white); } + & .adm-calendar-cell-top, & .adm-calendar-cell-bottom { color: var(--adm-color-white); } @@ -79,16 +84,18 @@ display: flex; flex-direction: column; align-items: center; - justify-content: flex-end; - & &-top { + justify-content: center; + & &-date { flex: none; - font-size: var(--adm-font-size-10); + line-height: 22px; + font-size: var(--adm-font-size-9); } + & &-top, & &-bottom { flex: none; - font-size: var(--adm-font-size-4); - height: 12px; - line-height: 12px; + font-size: var(--adm-font-size-2); + height: 14px; + line-height: 14px; color: var(--adm-color-weak); } } diff --git a/src/components/calendar/calendar.tsx b/src/components/calendar/calendar.tsx index 2ff6d92275..6f751a3314 100644 --- a/src/components/calendar/calendar.tsx +++ b/src/components/calendar/calendar.tsx @@ -8,12 +8,13 @@ import React, { import { NativeProps, withNativeProps } from '../../utils/native-props' import dayjs from 'dayjs' import classNames from 'classnames' +import Button from '../button' +import Popup from '../popup' +import type { PopupProps } from '../popup' import { mergeProps } from '../../utils/with-default-props' -import { ArrowLeft } from './arrow-left' -import { ArrowLeftDouble } from './arrow-left-double' import { useConfig } from '../config-provider' import isoWeek from 'dayjs/plugin/isoWeek' -import { useUpdateEffect } from 'ahooks' +import isSameOrBefore from 'dayjs/plugin/isSameOrBefore' import { usePropsValue } from '../../utils/use-props-value' import { convertValueToRange, @@ -23,6 +24,7 @@ import { } from './convert' dayjs.extend(isoWeek) +dayjs.extend(isSameOrBefore) const classPrefix = 'adm-calendar' @@ -32,38 +34,39 @@ export type CalendarRef = { } export type CalendarProps = { - prevMonthButton?: React.ReactNode - prevYearButton?: React.ReactNode - nextMonthButton?: React.ReactNode - nextYearButton?: React.ReactNode - onPageChange?: (year: number, month: number) => void + title?: React.ReactNode + confirmText?: string weekStartsOn?: 'Monday' | 'Sunday' - renderLabel?: (date: Date) => React.ReactNode + renderTop?: (date: Date) => React.ReactNode renderDate?: (date: Date) => React.ReactNode + renderBottom?: (date: Date) => React.ReactNode allowClear?: boolean max?: Date min?: Date shouldDisableDate?: (date: Date) => boolean - minPage?: Page - maxPage?: Page + usePopup?: boolean + popupProps?: PopupProps } & ( | { selectionMode?: undefined value?: undefined defaultValue?: undefined onChange?: undefined + onConfirm?: undefined } | { selectionMode: 'single' value?: Date | null defaultValue?: Date | null onChange?: (val: Date | null) => void + onConfirm?: (val: Date | null) => void } | { selectionMode: 'range' value?: [Date, Date] | null defaultValue?: [Date, Date] | null onChange?: (val: [Date, Date] | null) => void + onConfirm?: (val: [Date, Date] | null) => void } ) & NativeProps @@ -72,10 +75,8 @@ const defaultProps = { weekStartsOn: 'Sunday', defaultValue: null, allowClear: true, - prevMonthButton: , - prevYearButton: , - nextMonthButton: , - nextYearButton: , + usePopup: true, + selectionMode: 'single', } export const Calendar = forwardRef((p, ref) => { @@ -109,10 +110,6 @@ export const Calendar = forwardRef((p, ref) => { dayjs(dateRange ? dateRange[0] : today).date(1) ) - useUpdateEffect(() => { - props.onPageChange?.(current.year(), current.month() + 1) - }, [current]) - useImperativeHandle(ref, () => ({ jumpTo: pageOrPageGenerator => { let page: Page @@ -131,185 +128,183 @@ export const Calendar = forwardRef((p, ref) => { }, })) - const handlePageChange = ( - action: 'subtract' | 'add', - num: number, - type: 'month' | 'year' - ) => { - const nxtCurrent = current[action](num, type) - if (action === 'subtract' && props.minPage) { - const minPage = convertPageToDayjs(props.minPage) - if (nxtCurrent.isBefore(minPage, type)) { - return - } - } - if (action === 'add' && props.maxPage) { - const maxPage = convertPageToDayjs(props.maxPage) - if (nxtCurrent.isAfter(maxPage, type)) { - return - } - } - setCurrent(nxtCurrent) - } - const header = ( ) - const maxDay = useMemo(() => props.max && dayjs(props.max), [props.max]) - const minDay = useMemo(() => props.min && dayjs(props.min), [props.min]) + const maxDay = useMemo( + () => (props.max ? dayjs(props.max) : current.add(6, 'month')), + [props.max, current] + ) + const minDay = useMemo( + () => (props.min ? dayjs(props.min) : current), + [props.min, current] + ) - function renderCells() { + function renderBody() { const cells: ReactNode[] = [] - let iterator = current.subtract(current.isoWeekday(), 'day') - if (props.weekStartsOn === 'Monday') { - iterator = iterator.add(1, 'day') - } - while (cells.length < 6 * 7) { - const d = iterator - let isSelect = false - let isBegin = false - let isEnd = false - let isSelectRowBegin = false - let isSelectRowEnd = false - if (dateRange) { - const [begin, end] = dateRange - isBegin = d.isSame(begin, 'day') - isEnd = d.isSame(end, 'day') - isSelect = - isBegin || - isEnd || - (d.isAfter(begin, 'day') && d.isBefore(end, 'day')) - if (isSelect) { - isSelectRowBegin = - (cells.length % 7 === 0 || d.isSame(d.startOf('month'), 'day')) && - !isBegin - isSelectRowEnd = - (cells.length % 7 === 6 || d.isSame(d.endOf('month'), 'day')) && - !isEnd - } - } - const inThisMonth = d.month() === current.month() - const disabled = props.shouldDisableDate - ? props.shouldDisableDate(d.toDate()) - : (maxDay && d.isAfter(maxDay, 'day')) || - (minDay && d.isBefore(minDay, 'day')) + let monthIterator = minDay + // 遍历月份 + while (monthIterator.isSameOrBefore(maxDay, 'month')) { + const year = monthIterator.year() + const month = monthIterator.month() + cells.push( -
{ - if (!props.selectionMode) return - if (disabled) return - const date = d.toDate() - if (!inThisMonth) { - setCurrent(d.clone().date(1)) - } - function shouldClear() { - if (!props.allowClear) return false - if (!dateRange) return false - const [begin, end] = dateRange - return d.isSame(begin, 'date') && d.isSame(end, 'day') - } - if (props.selectionMode === 'single') { - if (props.allowClear && shouldClear()) { - setDateRange(null) - return - } - setDateRange([date, date]) - } else if (props.selectionMode === 'range') { - if (!dateRange) { - setDateRange([date, date]) - setIntermediate(true) - return - } - if (shouldClear()) { - setDateRange(null) - setIntermediate(false) - return - } - if (intermediate) { - const another = dateRange[0] - setDateRange(another > date ? [date, another] : [another, date]) - setIntermediate(false) - } else { - setDateRange([date, date]) - setIntermediate(true) - } - } - }} - > -
- {props.renderDate ? props.renderDate(d.toDate()) : d.date()} +
+
+ {locale.Calendar.renderYearAndMonth(year, month + 1)}
-
- {props.renderLabel?.(d.toDate())} +
+ {/* 空格填充 */} + {Array( + props.weekStartsOn === 'Monday' + ? monthIterator.date(1).isoWeekday() - 1 + : monthIterator.date(1).isoWeekday() + ) + .fill(null) + .map((_, index) => ( +
+ ))} + {/* 遍历每月 */} + {Array(monthIterator.daysInMonth()) + .fill(null) + .map((_, index) => { + const d = monthIterator.date(index + 1) + let isSelect = false + let isBegin = false + let isEnd = false + let isSelectRowBegin = false + let isSelectRowEnd = false + if (dateRange) { + const [begin, end] = dateRange + isBegin = d.isSame(begin, 'day') + isEnd = d.isSame(end, 'day') + isSelect = + isBegin || + isEnd || + (d.isAfter(begin, 'day') && d.isBefore(end, 'day')) + if (isSelect) { + isSelectRowBegin = + (cells.length % 7 === 0 || + d.isSame(d.startOf('month'), 'day')) && + !isBegin + isSelectRowEnd = + (cells.length % 7 === 6 || + d.isSame(d.endOf('month'), 'day')) && + !isEnd + } + } + const disabled = props.shouldDisableDate + ? props.shouldDisableDate(d.toDate()) + : (maxDay && d.isAfter(maxDay, 'day')) || + (minDay && d.isBefore(minDay, 'day')) + + const renderTop = () => { + const top = props.renderTop?.(d.toDate()) + + if (top) { + return top + } + + if (props.selectionMode === 'range') { + if (isBegin) { + return locale.Calendar.start + } + + if (isEnd) { + return locale.Calendar.end + } + } + + if (d.isSame(today, 'day') && !isSelect) { + return locale.Calendar.today + } + } + return ( +
{ + if (!props.selectionMode) return + if (disabled) return + const date = d.toDate() + function shouldClear() { + if (!props.allowClear) return false + if (!dateRange) return false + const [begin, end] = dateRange + return d.isSame(begin, 'date') && d.isSame(end, 'day') + } + if (props.selectionMode === 'single') { + if (props.allowClear && shouldClear()) { + setDateRange(null) + return + } + setDateRange([date, date]) + } else if (props.selectionMode === 'range') { + if (!dateRange) { + setDateRange([date, date]) + setIntermediate(true) + return + } + if (shouldClear()) { + setDateRange(null) + setIntermediate(false) + return + } + if (intermediate) { + const another = dateRange[0] + setDateRange( + another > date ? [date, another] : [another, date] + ) + setIntermediate(false) + } else { + setDateRange([date, date]) + setIntermediate(true) + } + } + }} + > +
+ {renderTop()} +
+
+ {props.renderDate + ? props.renderDate(d.toDate()) + : d.date()} +
+
+ {props.renderBottom?.(d.toDate())} +
+
+ ) + })}
) - iterator = iterator.add(1, 'day') + + monthIterator = monthIterator.add(1, 'month') } + return cells } - const body =
{renderCells()}
+ const body =
{renderBody()}
const mark = (
@@ -321,12 +316,58 @@ export const Calendar = forwardRef((p, ref) => {
) + const footer = ( +
+ +
+ ) + + const { + className: popupClassName, + bodyStyle: popupBodyStyle, + ...restPopupProps + } = props.popupProps ?? {} + return withNativeProps( props,
- {header} - {mark} - {body} + {props.usePopup ? ( + + {header} + {mark} + {body} + {footer} + + ) : ( + <> + {header} + {mark} + {body} + + )}
) }) diff --git a/src/components/calendar/calendar.zh.md b/src/components/calendar/calendar.zh.md index ed01567c4a..65862c4248 100644 --- a/src/components/calendar/calendar.zh.md +++ b/src/components/calendar/calendar.zh.md @@ -25,20 +25,17 @@ | 属性 | 说明 | 类型 | 默认值 | 版本 | | --- | --- | --- | --- | --- | | allowClear | 是否允许再次点击后清除 | `boolean` | `true` | +| confirmText | 确认按钮文案 | `string` | `确认` | | defaultValue | 默认选择的日期 | 同 `value` 属性 | - | | max | 可选择范围的最大值 | `Date` | - | | min | 可选择范围的最小值 | `Date` | - | -| maxPage | 可切换到的最晚日期 | `Page` | - | -| minPage | 可切换到的最早日期 | `Page` | - | -| nextMonthButton | 导航窗格上的“下一月”按钮的内容 | `React.ReactNode` | `>` | -| nextYearButton | 导航窗格上的“下一年”按钮的内容 | `React.ReactNode` | `>>` | | onChange | 选择日期变化时触发 | 单选模式下为 `(val: Date \| null) => void`,多选模式下为 `(val: [Date, Date] \| null) => void` | - | -| onPageChange | 切换月或年时触发 | `(year: number, month: number) => void` | - | -| prevMonthButton | 导航窗格上的“上一月”按钮的内容 | `React.ReactNode` | `<` | -| prevYearButton | 导航窗格上的“上一年”按钮的内容 | `React.ReactNode` | `<<` | -| renderLabel | 标注信息的渲染函数 | `(date: Date) => ReactNode \| null \| undefined` | - | +| onConfirm | 点击确认按钮时触发 | 单选模式下为 `(val: Date \| null) => void`,多选模式下为 `(val: [Date, Date] \| null) => void` | - | +| renderTop | 日期顶部信息的渲染函数 | `(date: Date) => ReactNode \| null \| undefined` | - | +| renderBottom | 日期底部信息的渲染函数 | `(date: Date) => ReactNode \| null \| undefined` | - | | selectionMode | 选择模式,不设置的话表示不支持选择 | `'single' \| 'range'` | - | | shouldDisableDate | 判断日期是否可选,使用后会忽略 min 和 max 设置 | `(date: Date) => boolean` | - | +| title | 日期选择器的标题 | `React.ReactNode` | `日期选择` | | value | 选择的日期 | 单选模式下为 `Date \| null`,多选模式下为 `[Date, Date] \| null` | - | | weekStartsOn | 每周以周几作为第一天 | `'Monday' \| 'Sunday'` | `'Sunday'` | | renderDate | 自定义日期渲染 | `(date: Date) => ReactNode` | - | 5.28.0 | @@ -51,7 +48,7 @@ | 属性 | 说明 | 类型 | | --- | --- | --- | -| jumpTo | 跳转至指定日期的页面 | `(page: Page \| ((page: Page) => Page)) => void` | +| jumpTo | 跳转至指定日期的区间 | `(page: Page \| ((page: Page) => Page)) => void` | | jumpToToday | 跳转至今日 | `() => void` | ```ts diff --git a/src/components/calendar/demos/demo1.tsx b/src/components/calendar/demos/demo1.tsx index 19d00b9aeb..e63fb8c22f 100644 --- a/src/components/calendar/demos/demo1.tsx +++ b/src/components/calendar/demos/demo1.tsx @@ -1,50 +1,91 @@ -import React from 'react' -import { Calendar } from 'antd-mobile' -import { DemoBlock, DemoDescription } from 'demos' +import dayjs from 'dayjs' +import React, { useState } from 'react' +import { Calendar, List } from 'antd-mobile' -const defaultSingle = new Date('2022-03-09') const defaultRange: [Date, Date] = [ - new Date('2022-03-09'), - new Date('2022-03-21'), + dayjs().toDate(), + dayjs().add(2, 'day').toDate(), ] export default () => { - return ( - <> - - - - 如果你不设置 selectionMode 属性,那么日历默认是不支持进行选择操作的 - - + const [val, setVal] = useState<[Date, Date] | null>(() => [ + dayjs().subtract(2, 'day').toDate(), + dayjs().add(2, 'day').toDate(), + ]) + const [visible1, setVisible1] = useState(false) + const [visible2, setVisible2] = useState(false) + const [visible3, setVisible3] = useState(false) - - 上一月} - nextMonthButton={下一月} - prevYearButton={上一年} - nextYearButton={下一年} - /> - + const singleDate: Date = new Date('2023-06-03') - + return ( + + { + setVisible1(true) + }} + > + 选择单个日期 { + setVisible1(false) + }, + onClose: () => { + setVisible1(false) + }, + }} selectionMode='single' - defaultValue={defaultSingle} + defaultValue={singleDate} + /> + + { + setVisible2(true) + }} + > + 选择日期范围 + { + setVisible2(false) + }, + onClose: () => { + setVisible2(false) + }, + }} onChange={val => { console.log(val) }} /> - - + + { + setVisible3(true) + }} + > + 受控日期选择 { + setVisible3(false) + }, + onClose: () => { + setVisible3(false) + }, + }} onChange={val => { - console.log(val) + setVal(val) }} /> - - + + ) } diff --git a/src/components/calendar/demos/demo2.tsx b/src/components/calendar/demos/demo2.tsx index 9c4027e352..207eaa55b3 100644 --- a/src/components/calendar/demos/demo2.tsx +++ b/src/components/calendar/demos/demo2.tsx @@ -1,25 +1,97 @@ -import dayjs from 'dayjs' import React, { useState } from 'react' -import { Calendar } from 'antd-mobile' -import { DemoBlock } from 'demos' +import { Calendar, List } from 'antd-mobile' + +const min = new Date() +min.setDate(5) +const max = new Date() +max.setDate(20) export default () => { - const today = dayjs() - const [val, setVal] = useState<[Date, Date] | null>(() => [ - today.subtract(2, 'day').toDate(), - today.add(2, 'day').toDate(), - ]) + const [visible1, setVisible1] = useState(false) + const [visible2, setVisible2] = useState(false) + const [visible3, setVisible3] = useState(false) + const [visible4, setVisible4] = useState(false) + return ( - <> - + + { + setVisible1(true) + }} + > + 自定义标题 + { + setVisible1(false) + }, + onClose: () => { + setVisible1(false) + }, + }} + /> + + { + setVisible2(true) + }} + > + 自定义确认文案 + { + setVisible2(false) + }, + onClose: () => { + setVisible2(false) + }, + }} + /> + + { + setVisible3(true) + }} + > + 周一作为每周的第一天 + { + setVisible3(false) + }, + onClose: () => { + setVisible3(false) + }, + }} + /> + + { + setVisible4(true) + }} + > + 限制日期范围 { - setVal(val) + popupProps={{ + visible: visible4, + onMaskClick: () => { + setVisible4(false) + }, + onClose: () => { + setVisible4(false) + }, }} /> - - + + ) } diff --git a/src/components/calendar/demos/demo4.less b/src/components/calendar/demos/demo3.less similarity index 89% rename from src/components/calendar/demos/demo4.less rename to src/components/calendar/demos/demo3.less index f0bc9bdd99..49cf099068 100644 --- a/src/components/calendar/demos/demo4.less +++ b/src/components/calendar/demos/demo3.less @@ -1,6 +1,7 @@ @prefix: ~'adm-calendar'; -.calendar-custom { +.calendar-custom, +.calendar-popup-custom { .@{prefix}-cell { justify-content: center; height: 38px; @@ -84,3 +85,17 @@ } } } + +.custom-cell { + width: 38px; + height: 38px; + border-radius: 50%; + display: flex; + justify-content: center; + align-items: center; + + &-selected { + background: var(--adm-color-primary); + color: #fff; + } +} diff --git a/src/components/calendar/demos/demo3.tsx b/src/components/calendar/demos/demo3.tsx index 0a82f6ffd4..61ec56d965 100644 --- a/src/components/calendar/demos/demo3.tsx +++ b/src/components/calendar/demos/demo3.tsx @@ -1,52 +1,136 @@ +import classnames from 'classnames' import dayjs from 'dayjs' -import React, { useEffect, useRef } from 'react' -import { Calendar } from 'antd-mobile' -import { DemoBlock } from 'demos' -import { CalendarRef } from 'antd-mobile/es/components/calendar' - -const min = new Date() -min.setDate(5) -const max = new Date() -max.setDate(20) +import React, { useState } from 'react' +import { Calendar, List } from 'antd-mobile' +import './demo3.less' export default () => { const today = dayjs() - const calendarRef = useRef(null) - useEffect(() => { - if (calendarRef.current) { - calendarRef.current.jumpTo({ - year: 2022, - month: 4, - }) - } - }, []) + const [val, setVal] = useState<[Date, Date] | null>(() => [ + today.subtract(2, 'day').toDate(), + today.add(2, 'day').toDate(), + ]) + + const [visible1, setVisible1] = useState(false) + const [visible2, setVisible2] = useState(false) + const [visible3, setVisible3] = useState(false) + const [visible4, setVisible4] = useState(false) + return ( - <> - - - - + + { + setVisible1(true) + }} + > + 自定义日期顶部信息 + { + const map = { + 1: '初一', + 2: '初二', + 3: '初三', + } + const dates = [1, 2, 3] + const d = dayjs(date).date() as keyof typeof map + + if (dates.includes(d)) { + return map[d] + } + }} + popupProps={{ + visible: visible1, + onMaskClick: () => { + setVisible1(false) + }, + onClose: () => { + setVisible1(false) + }, + }} + /> + + { + setVisible2(true) + }} + > + 自定义日期底部信息 { - if (dayjs(date).isSame(today, 'day')) return '今天' - if (date.getDay() === 0 || date.getDay() === 6) { - return '周末' + renderBottom={date => { + const dates = [16, 17, 18, 19] + const d = dayjs(date).date() + + if (dates.includes(d)) { + return '¥100' } }} + popupProps={{ + visible: visible2, + onMaskClick: () => { + setVisible2(false) + }, + onClose: () => { + setVisible2(false) + }, + }} /> - - - - - + + { + setVisible3(true) + }} + > + 自定义日期渲染 { + const dates = [16, 17, 18, 19] + const d = dayjs(date).date() + return ( +
+ {d} +
+ ) + }} + popupProps={{ + visible: visible3, + onMaskClick: () => { + setVisible3(false) + }, + onClose: () => { + setVisible3(false) + }, + }} + /> +
+ { + setVisible4(true) + }} + > + 高级自定义样式 + { + setVal(val) + }} + popupProps={{ + className: 'calendar-popup-custom', + visible: visible4, + onMaskClick: () => { + setVisible4(false) + }, + onClose: () => { + setVisible4(false) + }, + }} /> -
- - - - + + ) } diff --git a/src/components/calendar/demos/demo4.tsx b/src/components/calendar/demos/demo4.tsx index 93adfc363d..171aa52b94 100644 --- a/src/components/calendar/demos/demo4.tsx +++ b/src/components/calendar/demos/demo4.tsx @@ -1,27 +1,57 @@ -import dayjs from 'dayjs' -import React, { useState } from 'react' -import { Calendar } from 'antd-mobile' -import { DemoBlock } from 'demos' -import './demo4.less' +import React, { useState, useRef } from 'react' +import { Calendar, List, CalendarRef } from 'antd-mobile' export default () => { - const today = dayjs() - const [val, setVal] = useState<[Date, Date] | null>(() => [ - today.subtract(2, 'day').toDate(), - today.add(2, 'day').toDate(), - ]) + const ref1 = useRef(null) + const ref2 = useRef(null) + const [visible1, setVisible1] = useState(false) + const [visible2, setVisible2] = useState(false) + return ( - <> - + + { + setVisible1(true) + ref1.current?.jumpTo({ year: 2023, month: 8 }) + }} + > + 跳转到 3 月后 + { + setVisible1(false) + }, + onClose: () => { + setVisible1(false) + }, + }} + /> + + { + setVisible2(true) + ref2.current?.jumpTo(page => ({ + year: page.year + 3, + month: page.month, + })) + }} + > + 跳转到 3 年后 { - setVal(val) + ref={ref2} + popupProps={{ + visible: visible2, + onMaskClick: () => { + setVisible2(false) + }, + onClose: () => { + setVisible2(false) + }, }} /> - - + + ) } diff --git a/src/components/calendar/demos/demo5.less b/src/components/calendar/demos/demo5.less deleted file mode 100644 index 3286137d79..0000000000 --- a/src/components/calendar/demos/demo5.less +++ /dev/null @@ -1,13 +0,0 @@ -.custom-cell { - width: 38px; - height: 38px; - border-radius: 50%; - display: flex; - justify-content: center; - align-items: center; - - &-selected { - background: var(--adm-color-primary); - color: #fff; - } -} diff --git a/src/components/calendar/demos/demo5.tsx b/src/components/calendar/demos/demo5.tsx index 7f614be14e..5a91dba357 100644 --- a/src/components/calendar/demos/demo5.tsx +++ b/src/components/calendar/demos/demo5.tsx @@ -1,30 +1,11 @@ -import dayjs from 'dayjs' import React from 'react' import { Calendar } from 'antd-mobile' import { DemoBlock } from 'demos' -import classNames from 'classnames' -import './demo5.less' export default () => { return ( - <> - - { - const dates = [16, 17, 18, 19] - const d = dayjs(date).date() - return ( -
- {d} -
- ) - }} - /> -
- + + + ) } diff --git a/src/components/calendar/tests/__snapshots__/calendar.test.tsx.snap b/src/components/calendar/tests/__snapshots__/calendar.test.tsx.snap index c33e4205dd..c05d221062 100644 --- a/src/components/calendar/tests/__snapshots__/calendar.test.tsx.snap +++ b/src/components/calendar/tests/__snapshots__/calendar.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Calendar controlled mode 1`] = ` +exports[`Calendar custom top 1`] = `
-
-
- 27 -
-
-
-
-
- 28 -
-
-
-
+
- 29 + 2023年5月
-
-
-
- 30 -
-
-
-
-
- 31 +
+
+
+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
-
- 3 -
-
-
-
-
- 4 -
-
-
-
-
- 5 -
-
- 周末 -
-
-
-
- 6 -
-
- 周末 -
-
-
-
- 7 -
-
-
-
-
- 8 -
-
-
-
-
- 9 -
-
-
-
-
- 10 -
-
-
-
-
- 11 -
-
-
-
-
- 12 -
-
- 周末 -
-
-
-
- 13 -
-
- 周末 -
-
-
-
- 14 -
-
-
-
-
- 15 -
-
-
-
-
- 16 -
-
-
-
-
- 17 -
-
-
-
-
- 18 -
-
-
-
-
- 19 -
-
- 周末 -
-
-
-
- 20 -
-
- 周末 -
-
-
-
- 21 -
-
-
-
-
- 22 -
-
- 今天 -
-
-
-
- 23 -
-
-
-
-
- 24 -
-
-
-
-
- 25 -
-
-
-
-
- 26 -
-
- 周末 -
-
-
-
- 27 -
-
- 周末 -
-
-
-
- 28 -
-
-
-
-
- 29 -
-
-
-
-
- 30 -
-
-
-
-
- 31 -
-
-
-
-
- 1 -
-
-
-
-
- 2 -
-
- 周末 -
-
-
-
- 3 -
-
- 周末 -
-
-
-
- 4 -
-
-
-
-
- 5 -
-
-
-
-
- 6 -
-
-
-
-
- 7 -
-
-
-
-
- 8 -
-
-
-
-
- 9 -
-
- 周末 -
-
-
-
-
-`; - -exports[`Calendar jump to a day 1`] = ` -
- - -
- -
-
- 日 -
-
- 一 -
-
- 二 -
-
- 三 -
-
- 四 -
-
- 五 -
-
- 六 -
-
-
-
-
- 27 -
-
-
-
-
- 28 -
-
-
-
-
- 29 -
-
-
-
-
- 30 -
-
-
-
-
- 31 -
-
-
-
-
- 1 -
-
-
-
-
- 2 -
-
-
-
-
- 3 -
-
-
-
-
- 4 -
-
-
-
-
- 5 -
-
-
-
-
- 6 -
-
-
-
-
- 7 -
-
-
-
-
- 8 -
-
-
-
-
- 9 -
-
-
-
-
- 10 -
-
-
-
-
- 11 -
-
-
-
-
- 12 -
-
-
-
-
- 13 -
-
-
-
-
- 14 -
-
-
-
-
- 15 -
-
-
-
-
- 16 -
-
-
-
-
- 17 -
-
-
-
-
- 18 -
-
-
-
-
- 19 -
-
-
-
-
- 20 -
-
-
-
-
- 21 -
-
-
-
-
- 22 -
-
-
-
-
- 23 -
-
-
-
-
- 24 -
-
-
-
-
- 25 -
-
-
-
-
- 26 -
-
-
-
-
- 27 -
-
-
-
-
- 28 -
-
-
-
-
- 29 -
-
-
-
-
- 30 -
-
-
-
-
- 31 -
-
-
-
-
- 1 -
-
-
-
-
- 2 -
-
-
-
-
- 3 -
-
-
-
-
- 4 -
-
-
-
-
- 5 -
-
-
-
-
- 6 -
-
-
-
-
-
-`; - -exports[`Calendar jump to a day 2`] = ` -
- - -
- -
-
- 日 -
-
- 一 -
-
- 二 -
-
- 三 -
-
- 四 -
-
- 五 -
-
- 六 -
-
-
-
-
- 27 -
-
-
-
-
- 28 -
-
-
-
-
- 1 -
-
-
-
-
- 2 -
-
-
-
-
- 3 -
-
-
-
-
- 4 -
-
-
-
-
- 5 -
-
-
-
-
- 6 -
-
-
-
-
- 7 -
-
-
-
-
- 8 -
-
-
-
-
- 9 -
-
-
-
-
- 10 -
-
-
-
-
- 11 -
-
-
-
-
- 12 -
-
-
-
-
- 13 -
-
-
-
-
- 14 -
-
-
-
-
- 15 -
-
-
-
-
- 16 -
-
-
-
-
- 17 -
-
-
-
-
- 18 -
-
-
-
-
- 19 -
-
-
-
-
- 20 -
-
-
-
-
- 21 -
-
-
-
-
- 22 -
-
-
-
-
- 23 -
-
-
-
-
- 24 -
-
-
-
-
- 25 -
-
-
-
-
- 26 -
-
-
-
-
- 27 -
-
-
-
-
- 28 -
-
-
-
-
- 29 -
-
-
-
-
- 30 -
-
-
-
-
- 31 -
-
-
-
-
- 1 -
-
-
-
-
- 2 -
-
-
-
-
- 3 -
-
-
-
-
- 4 -
-
-
-
-
- 5 -
-
-
-
-
- 6 -
-
-
-
-
- 7 -
-
-
-
-
- 8 -
-
-
-
-
- 9 -
-
-
-
-
-
-`; - -exports[`Calendar range mode 1`] = ` -
-
- -
-
- 日 -
-
- 一 -
-
- 二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
+
+
+
+
+ 13 +
+
+
+
+
+
+ 14 +
+
+
+
+
+
+ 15 +
+
+
+
+
+
+ 16 +
+
+
+
+
+
+ 17 +
+
+
+
+
+
+ 18 +
+
+
+
+
+
+ 19 +
+
+
+
+
+
+ 20 +
+
+
+
+
+
+ 21 +
+
+
+
+
+ 今日 +
+
+ 22 +
+
+
+
+
+
+ 23 +
+
+
+
+
+
+ 24 +
+
+
+
+
+
+ 25 +
+
+
+
+
+
+ 26 +
+
+
+
+
+
+ 27 +
+
+
+
+
+
+ 28 +
+
+
+
+
+
+ 29 +
+
+
+
+
+
+ 30 +
+
+
+
+
+
+ 31 +
+
+
-
diff --git a/src/components/calendar/tests/calendar.test.tsx b/src/components/calendar/tests/calendar.test.tsx index 231c3640d4..56c20968cd 100644 --- a/src/components/calendar/tests/calendar.test.tsx +++ b/src/components/calendar/tests/calendar.test.tsx @@ -7,10 +7,12 @@ import MockDate from 'mockdate' const classPrefix = `adm-calendar` // mock today -MockDate.set(new Date('2022-03-22')) +MockDate.set(new Date('2023-05-22')) -const singleDate: Date = new Date('2022-03-09') -const rangeDate: [Date, Date] = [new Date('2022-03-09'), new Date('2022-03-21')] +const mixDate: Date = new Date('2023-05-01') +const maxDate: Date = new Date('2023-05-31') +const singleDate: Date = new Date('2023-05-03') +const rangeDate: [Date, Date] = [new Date('2023-05-04'), new Date('2023-05-07')] describe('Calendar', () => { test('a11y', async () => { @@ -19,16 +21,19 @@ describe('Calendar', () => { test('single mode', async () => { const fn = jest.fn() - const { container, getByText } = render( + const { container, getByText, getAllByText } = render( ) expect(container).toMatchSnapshot() - const dateEl = getByText(15) + const dateEl = getAllByText(15)[0] fireEvent.click(dateEl) expect(dateEl.parentElement).toHaveClass(`${classPrefix}-cell-selected`) expect(fn).toBeCalled() @@ -37,7 +42,14 @@ describe('Calendar', () => { test('range mode', async () => { const fn = jest.fn() const { container, getByText } = render( - + ) expect(container).toMatchSnapshot() @@ -48,55 +60,11 @@ describe('Calendar', () => { document.querySelectorAll(`.${classPrefix}-cell-selected`).length ).toBe(7) expect(fn.mock.calls[1][0].map((d: Date) => d.toDateString())).toEqual([ - 'Sun Mar 20 2022', - 'Sat Mar 26 2022', + 'Sat May 20 2023', + 'Fri May 26 2023', ]) }) - test('controlled mode', async () => { - const today = dayjs('2022-05-01') - - const App = () => { - const [val, setVal] = useState<[Date, Date] | null>(() => [ - today.subtract(2, 'day').toDate(), - today.add(2, 'day').toDate(), - ]) - - return ( - { - setVal(val) - }} - /> - ) - } - - const { container, getByText } = render() - const [startEl, endEl] = [getByText(8), getByText(15)] - fireEvent.click(startEl) - fireEvent.click(endEl) - expect(container).toMatchSnapshot() - }) - - test('page change', async () => { - const fn = jest.fn() - render() - - const btns = document.querySelectorAll(`.${classPrefix}-arrow-button-right`) - const titleEl = document.querySelector(`.${classPrefix}-title`) - // month - fireEvent.click(btns[0]) - expect(titleEl?.innerHTML).toContain('4月') - expect(fn.mock.calls[0]).toEqual([2022, 4]) - - // year - fireEvent.click(btns[1]) - expect(titleEl?.innerHTML).toContain('2023') - expect(fn.mock.calls[1]).toEqual([2023, 4]) - }) - test('jump to a day', async () => { const App = () => { const ref = useRef(null) @@ -116,7 +84,7 @@ describe('Calendar', () => { > jumpToToday - + ) } @@ -130,13 +98,26 @@ describe('Calendar', () => { }) test('week start on Monday', async () => { - const { container } = render() + const { container } = render( + + ) expect(container).toMatchSnapshot() }) test(`can't allow to clear`, async () => { const { getByText } = render( - + ) const dateEl = getByText(16) @@ -145,11 +126,14 @@ describe('Calendar', () => { expect(dateEl.parentElement).toHaveClass(`${classPrefix}-cell-selected`) }) - test('custom label', async () => { + test('custom top', async () => { const today = dayjs() const { container } = render( { + min={mixDate} + max={maxDate} + usePopup={false} + renderTop={date => { if (dayjs(date).isSame(today, 'day')) return '今天' if (date.getDay() === 0 || date.getDay() === 6) { return '周末' @@ -160,14 +144,31 @@ describe('Calendar', () => { expect(container).toMatchSnapshot() }) - test('custom date render', () => { + test('custom date', () => { + render( + { + return
{dayjs(date).date()}
+ }} + /> + ) + expect(document.getElementsByClassName('custom-cell').length).toBe(31) + }) + + test('custom bottom', () => { render( { return
{dayjs(date).date()}
}} /> ) - expect(document.getElementsByClassName('custom-cell').length).toBe(42) + expect(document.getElementsByClassName('custom-cell').length).toBe(31) }) }) diff --git a/src/locales/base.ts b/src/locales/base.ts index dc22f84b23..0f062c5340 100644 --- a/src/locales/base.ts +++ b/src/locales/base.ts @@ -9,6 +9,11 @@ export const base = { close: 'Close', }, Calendar: { + title: 'Date selection', + confirm: 'Confirm', + start: 'start', + end: 'end', + today: 'today', markItems: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], renderYearAndMonth: (year: number, month: number) => `${year}/${month}`, }, diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 2721cffb4b..f7e8d38133 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -12,6 +12,11 @@ const zhCN = mergeLocale(base, { close: '关闭', }, Calendar: { + title: '日期选择', + confirm: '确认', + start: '开始', + end: '结束', + today: '今日', markItems: ['一', '二', '三', '四', '五', '六', '日'], renderYearAndMonth: (year: number, month: number) => `${year}年${month}月`, }, From 865c3fca90198993c9e18176a520c695ec637b9b Mon Sep 17 00:00:00 2001 From: gaopeng0108 Date: Sat, 24 Jun 2023 14:28:40 +0800 Subject: [PATCH 2/7] fix: update style --- src/components/calendar/calendar.less | 48 +++++++++++++++++++++------ src/components/calendar/calendar.tsx | 30 +++++++++-------- 2 files changed, 55 insertions(+), 23 deletions(-) diff --git a/src/components/calendar/calendar.less b/src/components/calendar/calendar.less index 8fa093283f..c51584a619 100644 --- a/src/components/calendar/calendar.less +++ b/src/components/calendar/calendar.less @@ -4,13 +4,16 @@ flex: auto; font-size: var(--adm-font-size-10); } + & &-header { - padding: 8px; + padding: 12px; border-bottom: 1px solid var(--adm-color-border); + .adm-calendar-title { text-align: center; } } + & &-body { height: 64vh; overflow: auto; @@ -18,60 +21,82 @@ &::-webkit-scrollbar { display: none; } + .adm-calendar-title { position: sticky; top: 0; - padding: 12px 18px; + padding: 8px 20px; background-color: var(--adm-color-box); } } + & &-footer { - padding: 12px 18px; + &-bottom { + padding: 0 20px 16px; + } + + .adm-divider { + margin-top: 0; + } + .adm-button { width: 100%; } } + &-cells { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-items: stretch; - padding: 8px 8px 4px; + padding: 4px 8px; } + &-cell { flex: none; box-sizing: border-box; width: calc(100% / 7); - min-height: 56px; + min-height: 55px; margin-bottom: 4px; padding: 2px; color: var(--adm-color-text); cursor: pointer; + &&-today { color: var(--adm-color-primary); } + &&-disabled { color: var(--adm-color-light); + .adm-calendar-cell-top, .adm-calendar-cell-bottom { color: var(--adm-color-light); } } + &&-selected { && { - background: var(--adm-color-primary); - color: var(--adm-color-white); + background: rgba(22, 119, 255, 10%); + color: var(--adm-color-text); } + & .adm-calendar-cell-top, & .adm-calendar-cell-bottom { color: var(--adm-color-white); } + &&-begin { + background: var(--adm-color-primary); + color: var(--adm-color-white); border-top-left-radius: 4px; border-bottom-left-radius: 4px; } + &&-end { + background: var(--adm-color-primary); + color: var(--adm-color-white); border-top-right-radius: 4px; border-bottom-right-radius: 4px; } @@ -85,15 +110,17 @@ flex-direction: column; align-items: center; justify-content: center; + & &-date { flex: none; line-height: 22px; - font-size: var(--adm-font-size-9); + font-size: var(--adm-font-size-8); } + & &-top, & &-bottom { flex: none; - font-size: var(--adm-font-size-2); + font-size: var(--adm-font-size-1); height: 14px; line-height: 14px; color: var(--adm-color-weak); @@ -108,8 +135,9 @@ border-bottom: solid 1px var(--adm-color-border); height: 45px; box-sizing: border-box; - font-size: var(--adm-font-size-7); + font-size: var(--adm-font-size-6); padding: 0 8px; + & &-cell { flex: 1; text-align: center; diff --git a/src/components/calendar/calendar.tsx b/src/components/calendar/calendar.tsx index 6f751a3314..85fafb9445 100644 --- a/src/components/calendar/calendar.tsx +++ b/src/components/calendar/calendar.tsx @@ -9,6 +9,7 @@ import { NativeProps, withNativeProps } from '../../utils/native-props' import dayjs from 'dayjs' import classNames from 'classnames' import Button from '../button' +import Divider from '../divider' import Popup from '../popup' import type { PopupProps } from '../popup' import { mergeProps } from '../../utils/with-default-props' @@ -318,19 +319,22 @@ export const Calendar = forwardRef((p, ref) => { const footer = (
- + +
+ +
) From 0bd85a72b0fe77bcd503474a3f6ba6ce5317d119 Mon Sep 17 00:00:00 2001 From: gaopeng0108 Date: Sat, 24 Jun 2023 14:41:45 +0800 Subject: [PATCH 3/7] fix: update test snap --- .../config-provider.test.tsx.snap | 22639 ++++------------ 1 file changed, 5927 insertions(+), 16712 deletions(-) diff --git a/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap b/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap index 08dcae1e05..300d63e5b4 100644 --- a/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap +++ b/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap @@ -4,15342 +4,2003 @@ exports[`ConfigProvider should display the text as da-DK 1`] = ` + +