@bolttech/molecules-calendar

中文文档
0.29.6发布于 2026/07/02TypeScriptCommonJS近 30 天下载 2317

The Calendar component is a React component designed to display a calendar interface for selecting dates. It allows you to choose a date within a specified range and provides options for confirming or canceling the selection.

原始使用文档
文档目录6 节
  1. Table of Contents
  2. Installation
  3. Usage
  4. Props
  5. Example
  6. Contributing

Calendar Component

The Calendar component is a React component designed to display a calendar interface for selecting dates. It allows you to choose a date within a specified range and provides options for confirming or canceling the selection.

Table of Contents

Installation

To use the Calendar component in your React application, follow these steps:

npm install @bolttech/frontend-foundations @bolttech/molecules-calendar

or

yarn add @bolttech/frontend-foundations @bolttech/molecules-calendar

Once you have the required dependencies installed, you can start using the Calendar component in your React application.

Usage

The Calendar component provides a user-friendly calendar interface for date selection. It allows you to choose a date within a specified range. You can customize the locale, minimum and maximum dates, and more using its props.

To use the component, import it and include it in your JSX:

import React, { useState } from 'react';
import { Calendar } from '@bolttech/molecules-calendar';
import { bolttechTheme, BolttechThemeProvider } from '@bolttech/frontend-foundations'; // You can import your Calendar component here

function App() {
  const [selectedDate, setSelectedDate] = useState('');

  const handleDateChange = (date) => {
    setSelectedDate(date);
  };

  return (
    <BolttechThemeProvider theme={bolttechTheme}>
      <Calendar value={selectedDate} onChange={handleDateChange} min="2023-01-01" max="2023-12-31" />
      <p>Selected Date: {selectedDate}</p>
    </BolttechThemeProvider>
  );
}

export default App;

Props

The Calendar component accepts the following props:

PropTypeDescription
idstringThe ID attribute for the calendar container.
dataTestIdstringThe data-testid attribute for testing purposes.
localestringThe locale used for month and day names. Default is 'en'.
showOtherMonthsDaysbooleanBoolean representing if the calendar should display the days of the previous and next month on empty slots
minstringThe minimum selectable date (ISO 8601 format, e.g., '2023-01-01').
maxstringThe maximum selectable date (ISO 8601 format, e.g., '2023-12-31').
valuestringThe currently selected date (ISO 8601 format).
typestringThe type of the calendar, if it should be single date or a range.
yearOrderstringThe order to show each year, ascending or descending, default is descending.
cancelstringThe text for the cancel button. Default is 'Cancel'.
confirmstringThe text for the confirm button. Default is 'Confirm'.
onCancelfunctionThe callback function triggered when the cancel button is clicked.
onChangefunctionThe callback function triggered when a date is selected.

Example

Here's an example of using the Calendar component:

<Calendar value={selectedDate} onChange={handleDateChange} min="2023-01-01" max="2023-12-31" />

This will render a calendar interface with selectable dates between January 1, 2023, and December 31, 2023.

Contributing

Contributions to the Calendar component are welcome. If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on the project's Bitbucket repository.

版本与发布记录

@bolttech/molecules-calendar 共发布 48 个版本,首次发布于 2023/06/01;过去 12 个月发布了 10 个版本。

版本发布日期距今
0.29.6latest2026/07/024 个月前
0.29.52026/06/164 个月前
0.29.42026/06/084 个月前
0.29.32026/05/215 个月前
0.29.22026/04/146 个月前
0.29.02026/04/096 个月前

关于 @bolttech/molecules-calendar 的常见问题

@bolttech/molecules-calendar 是什么?

The Calendar component is a React component designed to display a calendar interface for selecting dates. It allows you to choose a date within a specified range and provides options for confirming or canceling the selection.

如何安装 @bolttech/molecules-calendar?

在项目目录运行 npm install @bolttech/molecules-calendar,或使用 pnpm add / yarn add / bun add。

@bolttech/molecules-calendar 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bolttech/molecules-calendar 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@bolttech/molecules-calendar 可以商用吗?

@bolttech/molecules-calendar 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@bolttech/molecules-calendar 的下载量有多少?

根据 npm 官方下载统计,@bolttech/molecules-calendar 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,317 次,日均约 77 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bolttech/molecules-calendar 还在维护吗?

最新版本 0.29.6 发布于 2026/07/02(4 个月前);至今共发布 48 个版本,其中过去 12 个月发布了 10 个;首次发布于 2023/06/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。