# @super-calendar/core 中文文档

规范地址：https://npmcn.com/package/%40super-calendar/core/

版本：2\.15\.0
npm 元数据更新时间：2026-11-02T13:57:18.132Z
中文译文更新时间：2026-11-02T14:54:13.551Z
软件包许可：MIT

本文由上游 README 机器翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40super-calendar/core
原文对照：https://npmcn.com/package/%40super-calendar/core/?lang=original
项目主页：https://super-calendar.afonsojramos.me/
源码仓库：https://github.com/afonsojramos/super-calendar

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：345 kB，24 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react \>=18，date-fns \>=3
- 首次发布：2026-06-29T12:15:24.401Z
- 最新版本发布：2026-11-02T13:57:17.533Z
- 已发布版本数：28（近 12 个月 28 个）

## 中文简介

超级日历的渲染无关核心：日期数学、选择模型、事件布局、月网格生成器、无头钩子和中性主题令牌。没有渲染器。

## 安装

```sh
npm install @super-calendar/core
```

也可以使用：`pnpm add @super-calendar/core`、`yarn add @super-calendar/core`、`bun add @super-calendar/core`

## README

# @super-calendar /核心

[![npm](https://img.shields.io/npm/v/@super-calendar/core?style=flat-square&color=1F6FEB)](https://www.npmjs.com/package/@super-calendar/core) [![JSR](https://img.shields.io/jsr/v/@super-calendar/core?style=flat-square&label=JSR&color=F7DF1E)](https://jsr.io/@super-calendar/core) [![npmx](https://img.shields.io/badge/npmx-view-8A2BE2?style=flat-square)](https://npmx.dev/package/@super-calendar/core)

的渲染不可知论核心 [super-calendar](https://github.com/afonsojramos/super-calendar)日期数学、选择模型、事件布局、月网格生成器、无头钩子和中性主题标记。

它没有从React Native、React -dom、Reanimated、Gesture Handler或Legend List中导入任何东西，所以它可以绑定到任何渲染器中。使用它来驱动您自己的UI，或将其与 [`@super-calendar/dom`](https://www.npmjs.com/package/@super-calendar/dom) (react-dom)或 [`@super-calendar/native`](https://www.npmjs.com/package/@super-calendar/native) (本机)反应。

## 安装

```sh
npm install @super-calendar/core
```

也在 [JSR](https://jsr.io/@super-calendar/core)： `deno add jsr:@super-calendar/core`.

同行依赖性: `date-fns` (> = 3) `react` (> = 19)。

## 使用

从headless构建一个完全自定义的月网格 `useMonthGrid` 钩。它返回周、工作日头和每天的状态，供您按照自己的喜好呈现。

```tsx
import { useMonthGrid } from "@super-calendar/core";

function MyGrid({ month }: { month: Date }) {
  const { weeks, weekdays } = useMonthGrid(month, { weekStartsOn: 1 });

  return weeks.map((week) =>
    week.days.map((day) => (
      // day carries isToday / isSelected / isInRange / isDisabled / isCurrentMonth
      <DayCell key={day.date.toISOString()} day={day} />
    )),
  );
}
```

管理单个、多个或范围选择 `useDateRange`：

```ts
import { useDateRange } from "@super-calendar/core";

const range = useDateRange({ mode: "range" });
```

对于自定义时间网格拖动， `clampMoveStartMinutes` 保留已移动的事件 从可见的小时窗口内开始，同时允许其持续时间不变 把结尾拖过午夜：

```ts
import { clampMoveStartMinutes } from "@super-calendar/core";

const startMinutes = clampMoveStartMinutes(rawStartMinutes, minHour, maxHour, snapMinutes);
```

在时间网格上定位你自己的标记， `wallClockHours(date, dayStart, nextDayStart)` 返回分式时钟小时，固定到一天。它匹配 `layoutDayEvents`， 哪些事件按时钟时间排列，以便它们与时钟上的小时标签对齐 夏令时改日。 `clockHoursBetween(from, to)` 返回a的行数 跨度覆盖。

使用 `resolveDraggedBounds` 移动或调整大小相等的开始和结束增量 移动事件的同时保留经过的持续时间，包括日光 保存更改。对于调整大小，将想要保持固定的边缘设置为0。

`CalendarEvent<T>` 包含可选的 `dragHandleColor: string` 对于本地人来说 渲染器的时间网格和资源时间轴调整手柄大小。当省略时， 掌握使用 `theme.colors.eventText`． Core保留字段而不解释它。

## 文档

看到 [完整的文档](https://super-calendar.afonsojramos.me/) 和 [API参考](https://super-calendar.afonsojramos.me/reference/api).

## 许可证

麻省理工学院

## 常见问题

### @super-calendar/core 是什么？

超级日历的渲染无关核心：日期数学、选择模型、事件布局、月网格生成器、无头钩子和中性主题令牌。没有渲染器。

### 如何安装 @super-calendar/core？

在项目目录运行 npm install @super-calendar/core，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\>=18）、date-fns（\>=3）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @super-calendar/core 支持 TypeScript 吗？

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

### @super-calendar/core 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @super-calendar/core 可以商用吗？

@super-calendar/core 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @super-calendar/core 还在维护吗？

最新版本 2\.15\.0 发布于 2026/11/02（今天）；至今共发布 28 个版本，其中过去 12 个月发布了 28 个；首次发布于 2026/06/29。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

