Gathering detailed insights and metrics for @uiw/react-calendar
Gathering detailed insights and metrics for @uiw/react-calendar
Gathering detailed insights and metrics for @uiw/react-calendar
Gathering detailed insights and metrics for @uiw/react-calendar
⚛️ @uiwjs A high quality UI Toolkit, A Component Library for React 16+.
npm install @uiw/react-calendar
Typescript
Module System
Node Version
NPM Version
TypeScript (78.99%)
Less (20.49%)
JavaScript (0.38%)
HTML (0.12%)
Shell (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
736 Stars
3,301 Commits
121 Forks
31 Watchers
15 Branches
25 Contributors
Updated on Jul 03, 2025
Latest Version
4.22.3
Package Id
@uiw/react-calendar@4.22.3
Unpacked Size
38.08 kB
Size
7.53 kB
File Count
17
NPM Version
9.8.1
Node Version
18.18.2
Published on
Nov 29, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
按照日历形式展示数据的容器。
1import { Calendar } from 'uiw'; 2// or 3import Calendar from '@uiw/react-calendar';
下面是基础使用方法,可以设置日历通知事项,在日历渲染单元格时,会根据 data 内容来渲染单元格通知事项。
1import React from 'react'; 2import { Calendar, Badge } from 'uiw'; 3 4const data = [ 5 { type: 'default', date: '8', label: '中国电动车初创公司蔚来据称考虑明年赴美上市。' }, 6 { type: 'success', date: '8', label: '苹果收购一批新专利 或用于iPhone 3D摄像头' }, 7 { type: 'default', date: '8', label: '高通再诉iPhone侵犯专利 苹果正面反驳' }, 8 { type: 'error', date: '8', label: '谷歌安全团队报告macOS文件系统高危漏洞' }, 9 { type: 'default', date: '8', label: 'iPhone销量下滑使富士康工人待遇降低' }, 10 { type: 'default', date: '8', label: 'Flutter 1.0重磅发布,它还想做桌面和Web开发' }, 11 { type: 'warning', date: '15', label: '月圆的日子?', style: { color: 'red' } }, 12 { type: 'success', date: '1/1', label: '元旦节' }, 13 { type: 'error', date: '3/12', label: '植树节' }, 14 { type: 'info', date: '3/5', label: '学雷锋日' }, 15 { type: 'default', date: '3/8', label: '妇女节' }, 16 { type: 'success', date: '2019/3/8', label: '2019植树节' }, 17 { type: 'warning', date: '5/1', label: '劳动节' }, 18 { type: 'default', date: '5/4', label: '青年节' }, 19 { type: 'success', date: '6/1', label: '儿童节' }, 20 { type: 'warning', date: '7/1', label: '建党节' }, 21 { type: 'success', date: '8/1', label: '建军节' }, 22 { type: 'warning', date: '9/10', label: '教师节' }, 23 { type: 'default', date: '10/1', label: '国庆节' }, 24] 25function filterData(dt) { 26 return dt.map((item) => { 27 let color = ''; 28 switch (item.type) { 29 case 'success': color = '#28a745'; break; 30 case 'error': color = '#dc3545'; break; 31 case 'warning': color = '#F95C2B'; break; 32 case 'default': color = '#393E48'; break; 33 case 'info': color = '#008EF0'; break; 34 } 35 item.label = <Badge color={color}>{item.label}</Badge>; 36 return item; 37 }); 38} 39 40export default function Demo() { 41 return( 42 <div> 43 <Calendar 44 onSelectDay={(date, dateSource) => { 45 console.log('date:', date, dateSource); 46 }} 47 data={filterData(data)} 48 /> 49 </div> 50 ); 51}
在日历面板上面添加通知事件,还可以通过设置 disabledDate
来禁止部分日期点击,如下实例每月12号不能点击。
1import React from 'react'; 2import { Calendar, Badge } from 'uiw'; 3 4const data = [ 5 { type: 'default', date: '8', label: '中国电动车初创公司蔚来据称考虑明年赴美上市。' }, 6 { type: 'success', date: '8', label: '苹果收购一批新专利 或用于iPhone 3D摄像头' }, 7 { type: 'default', date: '8', label: '高通再诉iPhone侵犯专利 苹果正面反驳' }, 8 { type: 'error', date: '8', label: '谷歌安全团队报告macOS文件系统高危漏洞' }, 9 { type: 'default', date: '8', label: 'iPhone销量下滑使富士康工人待遇降低' }, 10 { type: 'default', date: '8', label: 'Flutter 1.0重磅发布,它还想做桌面和Web开发' }, 11 { type: 'warning', date: '15', label: '月圆的日子?', style: { color: 'red' } }, 12 { type: 'success', date: '1/1', label: '元旦节' }, 13 { type: 'error', date: '3/12', label: '植树节' }, 14 { type: 'info', date: '3/5', label: '学雷锋日' }, 15 { type: 'default', date: '3/8', label: '妇女节' }, 16 { type: 'success', date: '2019/3/8', label: '2019植树节' }, 17 { type: 'warning', date: '5/1', label: '劳动节' }, 18 { type: 'default', date: '5/4', label: '青年节' }, 19 { type: 'success', date: '6/1', label: '儿童节' }, 20 { type: 'warning', date: '7/1', label: '建党节' }, 21 { type: 'success', date: '8/1', label: '建军节' }, 22 { type: 'warning', date: '9/10', label: '教师节' }, 23 { type: 'default', date: '10/1', label: '国庆节' }, 24] 25function filterData(dt) { 26 return dt.map((item) => { 27 let color = ''; 28 switch (item.type) { 29 case 'success': color = '#28a745'; break; 30 case 'error': color = '#dc3545'; break; 31 case 'warning': color = '#F95C2B'; break; 32 case 'default': color = '#393E48'; break; 33 case 'info': color = '#008EF0'; break; 34 default: color = '#008EF0'; break; 35 } 36 item.label = <Badge color={color}>{item.label}</Badge>; 37 return item; 38 }); 39} 40function disabledDate(currentDate, props) { 41 const day = currentDate.getDay(); 42 // 禁用周末,只能点击当月工作日 43 if (day === 6 || day === 0 || props.next || props.prev) { 44 return true; 45 } 46 // 今天和今天之前不能选择 47 // return currentDate && currentDate.valueOf() < Date.now(); 48} 49 50export default function Demo() { 51 return( 52 <div> 53 <Calendar 54 onSelectDay={(date, dateSource) => { 55 console.log('date:', date, dateSource); 56 }} 57 disabledDate={disabledDate} 58 data={filterData(data)} 59 /> 60 </div> 61 ); 62}
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
data | 在日历面板上面添加通知,数组中的对象可以设置 ElementProps,如:style , onClick 等属性。 | Array[{ date: YYYY/MM/DD, label: String/ReactNode }] | - |
date<DatePicker> | 选中的日期 | Date | - |
titleFormat | 设置日历面板上面的日期标题。 | String | YYYY年MM月 |
today<DatePicker> | 默认高亮当天日期 | Function(currentDate) | - |
todayLabel | “今天”按钮的文本设置 | String | - |
panelDate<DatePicker> | 日历面板默认展示哪一页 | Date | new Date |
disabledDate<DatePicker> | 不可选择的日期,函数返回 true 当前日期被禁用无法选择。end : 周末,prev : 上个月,next :下个月 | Function(currentDate, { end: bool, prev: bool, next: bool }) | - |
weekTitle<DatePicker> | 星期显示文本提示 | Array | [星期天 , 星期一 , 星期二 , 星期三 , 星期四 , 星期五 , 星期六 ] |
weekday<DatePicker> | 星期显示文本 | Array | [日 , 一 , 二 , 三 , 四 , 五 , 六 ] |
onSelectDay @3.0.0+ | 点击选择日期回调 | Function | function(date?: Date, dateSource: { day?: number, month?: number, year?: number }) |
monthLabel<DatePicker> | 月份显示文本 | Array | [一月 , 二月 , 三月 , 四月 , 五月 , 六月 , 七月 , 八月 , 九月 , 十月 , 十一月 , 十二月 ] |
onPaging | 翻页触发事件 | Function(type: 'prev' | 'next' | 'today', month: number, date?: Date) | - |
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 1/26 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More