Skip to content

Commit e3711c9

Browse files
committed
* calendar: add btn-group import and extend CalendarHeaderProps to include navItems for enhanced navigation functionality
1 parent 30af6a9 commit e3711c9

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

lib/calendar/dev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'zui-dev';
33
import '@zui/button';
44
import '@zui/toolbar';
55
import '@zui/list';
6+
import '@zui/btn-group';
67
import '@zentao/icons';
78
import {Calendar} from './src/main';
89
import events from './dev/events-example';

lib/calendar/src/component/calendar-header.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {addDate, createDate, formatDate, isSameDay, type DateLike} from '@zui/he
55
import '@zui/css-icons/src/icons/chevron.css';
66
import type {CalendarViewMode} from '../types';
77
import type {CustomContentType} from '@zui/core/src/react';
8-
import type {ToolbarSetting, ToolbarOptions} from '@zui/toolbar';
8+
import type {ToolbarSetting, ToolbarOptions, ToolbarItemOptions} from '@zui/toolbar';
99

1010
/**
1111
* 日历头部的属性接口
@@ -32,6 +32,9 @@ export type CalendarHeaderProps = {
3232
/** 按钮尺寸,默认 'sm' */
3333
btnSize?: ToolbarOptions['size'];
3434

35+
/** 头部导航栏按钮 */
36+
navItems?: ToolbarItemOptions[];
37+
3538
/** 头部操作栏 */
3639
actions?: ToolbarSetting;
3740
};
@@ -41,7 +44,7 @@ export type CalendarHeaderProps = {
4144
*/
4245
export class CalendarHeader extends Component<CalendarHeaderProps> {
4346
protected _getNavItems = (props: CalendarHeaderProps) => {
44-
const {monthFormat = 'yyyy-MM', dateFormat = 'yyyy-MM-dd', date} = props;
47+
const {monthFormat = 'yyyy-MM', dateFormat = 'yyyy-MM-dd', date, navItems = []} = props;
4548
const current = createDate(date, true);
4649
const today = new Date();
4750
current.setHours(0, 0, 0, 0);
@@ -55,7 +58,7 @@ export class CalendarHeader extends Component<CalendarHeaderProps> {
5558
{hint: formatDate(prev, monthFormat), text: '', textClass: 'chevron-left', command: `.~switchDate/${prev.getTime()}`},
5659
{type: 'text', text: formatDate(current, monthFormat)},
5760
{hint: formatDate(next, monthFormat), text: '', textClass: 'chevron-right', command: `.~switchDate/${next.getTime()}`},
58-
61+
...navItems,
5962
];
6063
};
6164

0 commit comments

Comments
 (0)