mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-03-07 13:48:31 +08:00
fix(calendar): fix calendar date month error (#56)
* fix(calendar): fix calendar date calc error * fix(calendar): optimize code * docs(changelog): delete Feats info * Update CHANGELOG.zh-CN.md Co-authored-by: 07akioni <07akioni2@gmail.com>
This commit is contained in:
parent
21204a508e
commit
bcb52b14ec
@ -7,6 +7,7 @@
|
||||
- Fix `n-popover` sometimes won't sync position in manual mode.
|
||||
- Fix `n-transfer`'s empty icon is no toggling transition.
|
||||
- Fix `n-message` API option is not optional.
|
||||
- Fix `n-calendar` date calculate incorrectly
|
||||
- Fix `n-input` missing the `password` type declaration.
|
||||
- Fix `n-menu` the type definition of `extra` property of menu and submenu.
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
- 修复 `n-popover` 有时在手动模式不会同步位置
|
||||
- 修复 `n-transfer` 的无数据 Icon 没有开关动画
|
||||
- 修复 `n-message` API 的 option 不是可选的
|
||||
- 修复 `n-calendar` 展示日期计算错误
|
||||
- 修复 `n-input` 缺失 `password` 的声明
|
||||
- 修复 `n-menu` 的菜单和子菜单的 `extra` 属性的类型定义
|
||||
|
||||
|
@ -9,15 +9,7 @@ import {
|
||||
toRef,
|
||||
renderSlot
|
||||
} from 'vue'
|
||||
import {
|
||||
getDate,
|
||||
format,
|
||||
getYear,
|
||||
addMonths,
|
||||
startOfDay,
|
||||
startOfMonth,
|
||||
getMonth
|
||||
} from 'date-fns'
|
||||
import { format, getYear, addMonths, startOfDay, startOfMonth } from 'date-fns'
|
||||
import { useMergedState } from 'vooks'
|
||||
import { dateArray } from '../../date-picker/src/utils'
|
||||
import { ChevronLeftIcon, ChevronRightIcon } from '../../_internal/icons'
|
||||
@ -187,7 +179,6 @@ export default defineComponent({
|
||||
} = this
|
||||
const normalizedValue = mergedValue && startOfDay(mergedValue).valueOf()
|
||||
const localeMonth = format(monthTs, 'MMMM', { locale })
|
||||
const month = getMonth(monthTs)
|
||||
const year = getYear(monthTs)
|
||||
const title = monthBeforeYear
|
||||
? `${localeMonth} ${year}`
|
||||
@ -254,10 +245,10 @@ export default defineComponent({
|
||||
</div>
|
||||
<div class={`${mergedClsPrefix}-calendar-dates`}>
|
||||
{this.dateItems.map(
|
||||
({ ts, inCurrentMonth, isCurrentDate }, index) => {
|
||||
({ dateObject, ts, inCurrentMonth, isCurrentDate }, index) => {
|
||||
const { year, month, date } = dateObject
|
||||
const disabled = !inCurrentMonth || isDateDisabled?.(ts) === true
|
||||
const selected = normalizedValue === startOfDay(ts).valueOf()
|
||||
const date = getDate(ts)
|
||||
return (
|
||||
<div
|
||||
key={isCurrentDate ? 'current' : index}
|
||||
@ -271,7 +262,7 @@ export default defineComponent({
|
||||
onClick={() => {
|
||||
this.doUpdateValue(ts, {
|
||||
year,
|
||||
month,
|
||||
month: month + 1,
|
||||
date
|
||||
})
|
||||
this.monthTs = startOfMonth(ts).valueOf()
|
||||
@ -303,7 +294,7 @@ export default defineComponent({
|
||||
</div>
|
||||
{renderSlot(this.$slots, 'default', {
|
||||
year,
|
||||
month,
|
||||
month: month + 1,
|
||||
date
|
||||
})}
|
||||
<div
|
||||
|
Loading…
Reference in New Issue
Block a user