@super-calendar/core

中文文档
2.15.0发布于 2026/11/02MITTypeScriptESM + CJS零依赖构建来源已验证

Render-agnostic core for super-calendar: date math, selection model, event layout, the month-grid builder, headless hooks, and neutral theme tokens. No renderer.

原始使用文档
文档目录4 节
  1. Install
  2. Usage
  3. Documentation
  4. License

@super-calendar/core

npm JSR npmx

The render-agnostic core of super-calendar: date math, the selection model, event layout, the month-grid builder, the headless hooks, and the neutral theme tokens.

It imports nothing from React Native, react-dom, Reanimated, Gesture Handler, or Legend List, so it bundles into any renderer. Use it to drive your own UI, or pair it with @super-calendar/dom (react-dom) or @super-calendar/native (React Native).

Install

npm install @super-calendar/core

Also on JSR: deno add jsr:@super-calendar/core.

Peer dependencies: date-fns (>=3) and react (>=19).

Usage

Build a fully custom month grid from the headless useMonthGrid hook. It returns the weeks, the weekday headers, and per-day state for you to render however you like.

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} />
    )),
  );
}

Manage single, multiple, or range selection with useDateRange:

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

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

For a custom time-grid drag, clampMoveStartMinutes keeps the moved event's start inside the visible hour window while allowing its unchanged duration to carry the end past midnight:

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

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

To position your own marks on a time grid, wallClockHours(date, dayStart, nextDayStart) returns the fractional clock hour, clamped to the day. It matches layoutDayEvents, which places events by clock time so they line up with the hour labels on a daylight saving change day. clockHoursBetween(from, to) returns how many rows a span covers.

Use resolveDraggedBounds to commit a move or resize. Equal start and end deltas move the event while preserving elapsed duration, including across daylight saving changes. For a resize, pass zero for the edge you want to keep fixed.

CalendarEvent<T> includes an optional dragHandleColor: string for the native renderer's time-grid and resource-timeline resize grips. When omitted, those grips use theme.colors.eventText. Core preserves the field without interpreting it.

Documentation

See the full documentation and the API reference.

License

MIT

版本与发布记录

@super-calendar/core 共发布 28 个版本,首次发布于 2026/06/29;过去 12 个月发布了 28 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.15.0latest2026/11/02今天
2.14.22026/10/2410 天前
2.14.12026/10/2113 天前
2.14.02026/10/1420 天前
2.13.02026/10/1024 天前
2.12.12026/10/0826 天前

关于 @super-calendar/core 的常见问题

@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 和提交记录判断。