remons-calendar 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AddScheduleModal.d.ts +3 -3
- package/dist/components/AddScheduleModal.d.ts.map +1 -1
- package/dist/components/Calendar/DayCell.d.ts +3 -3
- package/dist/components/Calendar/DayCell.d.ts.map +1 -1
- package/dist/components/Calendar/DayPanel.d.ts +3 -1
- package/dist/components/Calendar/DayPanel.d.ts.map +1 -1
- package/dist/components/Calendar/index.d.ts +2 -2
- package/dist/components/Calendar/index.d.ts.map +1 -1
- package/dist/components/Calendar/layout.d.ts +2 -2
- package/dist/components/Calendar/layout.d.ts.map +1 -1
- package/dist/components/Calendar/types.d.ts +21 -10
- package/dist/components/Calendar/types.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +435 -403
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
1
|
import type { DailySchedule } from '../types';
|
|
2
|
+
import type { IconItem } from './Calendar/types';
|
|
3
3
|
import './pickers.less';
|
|
4
4
|
export interface AddScheduleModalProps {
|
|
5
5
|
open: boolean;
|
|
6
6
|
editing: DailySchedule | null;
|
|
7
7
|
/** 新增时默认日期 */
|
|
8
8
|
initialDate?: string;
|
|
9
|
-
/**
|
|
10
|
-
icons:
|
|
9
|
+
/** 外部传入的图标列表 */
|
|
10
|
+
icons: IconItem[];
|
|
11
11
|
onClose: () => void;
|
|
12
12
|
onSave: (s: DailySchedule) => void;
|
|
13
13
|
onDelete: (id: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddScheduleModal.d.ts","sourceRoot":"","sources":["../../src/components/AddScheduleModal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AddScheduleModal.d.ts","sourceRoot":"","sources":["../../src/components/AddScheduleModal.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,gBAAgB,CAAC;AAyBxB,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,cAAc;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB;IAChB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,OAAO,EACP,WAAW,EACX,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GACT,EAAE,qBAAqB,+BA6FvB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
1
|
import type { DailySchedule } from '../../types';
|
|
2
|
+
import type { IconItem } from './types';
|
|
3
3
|
import type { HolidayDisplay } from '../../utils/holidayDisplay';
|
|
4
4
|
import './styles/day-cell.less';
|
|
5
5
|
export interface DayCellProps {
|
|
@@ -17,8 +17,8 @@ export interface DayCellProps {
|
|
|
17
17
|
selected?: boolean;
|
|
18
18
|
/** 点击选中该日 */
|
|
19
19
|
onSelect?: (dateStr: string) => void;
|
|
20
|
-
/**
|
|
21
|
-
icons?:
|
|
20
|
+
/** 图标列表 */
|
|
21
|
+
icons?: IconItem[];
|
|
22
22
|
}
|
|
23
23
|
/** 农历展示:节日 > 节气 > 当月月份名(初一)> 农历日 */
|
|
24
24
|
export declare function getLunarText(dateStr: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DayCell.d.ts","sourceRoot":"","sources":["../../../src/components/Calendar/DayCell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"DayCell.d.ts","sourceRoot":"","sources":["../../../src/components/Calendar/DayCell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,wBAAwB,CAAC;AAEhC,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,cAAc,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa;IACb,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,WAAW;IACX,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;CACpB;AAID,oCAAoC;AACpC,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYpD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,+BAwD1C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DailySchedule, TodoRange } from '../../types';
|
|
2
2
|
import type { HolidayDisplay } from '../../utils/holidayDisplay';
|
|
3
|
+
import type { IconItem } from './types';
|
|
3
4
|
import './styles/day-panel.less';
|
|
4
5
|
interface DayPanelProps {
|
|
5
6
|
/** 选中日期 YYYY-MM-DD */
|
|
@@ -14,8 +15,9 @@ interface DayPanelProps {
|
|
|
14
15
|
onAddTodo: () => void;
|
|
15
16
|
onAddSchedule: () => void;
|
|
16
17
|
isPreview?: boolean;
|
|
18
|
+
icons?: IconItem[];
|
|
17
19
|
}
|
|
18
20
|
/** 日历下方的选中日详情面板(完整展示当日待办与日程) */
|
|
19
|
-
export declare function DayPanel({ dateStr, holiday, todos, schedules, onEditTodo, onEditSchedule, onAddTodo, onAddSchedule, isPreview, }: DayPanelProps): import("react").JSX.Element;
|
|
21
|
+
export declare function DayPanel({ dateStr, holiday, todos, schedules, onEditTodo, onEditSchedule, onAddTodo, onAddSchedule, isPreview, icons, }: DayPanelProps): import("react").JSX.Element;
|
|
20
22
|
export {};
|
|
21
23
|
//# sourceMappingURL=DayPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DayPanel.d.ts","sourceRoot":"","sources":["../../../src/components/Calendar/DayPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"DayPanel.d.ts","sourceRoot":"","sources":["../../../src/components/Calendar/DayPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,yBAAyB,CAAC;AAYjC,UAAU,aAAa;IACrB,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,iBAAiB;IACjB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,eAAe;IACf,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,UAAU,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IACnC,cAAc,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAC3C,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;CACpB;AAED,gCAAgC;AAChC,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EACP,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACT,KAAK,GACN,EAAE,aAAa,+BAgFf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CalendarProps } from './types';
|
|
2
2
|
import './styles/calendar.less';
|
|
3
|
-
export type { CalendarProps, TodoSeg, ViewMode, VisibilityRange } from './types';
|
|
4
|
-
export declare function Calendar({ todos, schedules, onSaveTodo, onDeleteTodo, onSaveSchedule, onDeleteSchedule, isPreview, icons, }: CalendarProps): import("react").JSX.Element;
|
|
3
|
+
export type { CalendarProps, IconItem, TodoSeg, ViewMode, VisibilityRange } from './types';
|
|
4
|
+
export declare function Calendar({ todos: initialTodos, schedules: initialSchedules, onChange, onSaveTodo, onDeleteTodo, onSaveSchedule, onDeleteSchedule, isPreview, icons, }: CalendarProps): import("react").JSX.Element;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Calendar/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,SAAS,CAAC;AACvD,OAAO,wBAAwB,CAAC;AAEhC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Calendar/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,SAAS,CAAC;AACvD,OAAO,wBAAwB,CAAC;AAEhC,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI3F,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,KAAK,GACN,EAAE,aAAa,+BA8Pf"}
|
|
@@ -9,12 +9,12 @@ export interface VisibleWeek {
|
|
|
9
9
|
rowIndex: number;
|
|
10
10
|
}
|
|
11
11
|
/** 待办横条布局:按周行分段 + 每周独立分配泳道(感知时间:仅时间区间冲突才视为冲突) */
|
|
12
|
-
export declare function layoutTodos(
|
|
12
|
+
export declare function layoutTodos(rawTodos: TodoRange[], grid: DayItem[]): {
|
|
13
13
|
todoSegs: TodoSeg[];
|
|
14
14
|
todoLanesByDate: Record<string, number>;
|
|
15
15
|
};
|
|
16
16
|
/** "仅待办和日程"模式:计算有内容的周行范围(首~尾,中间周照常展示),无内容返回 null */
|
|
17
|
-
export declare function computeVisibilityRange(
|
|
17
|
+
export declare function computeVisibilityRange(rawTodos: TodoRange[], rawSchedules: DailySchedule[], dateIndexOf: Record<string, number>, year: number, month: number): VisibilityRange | null;
|
|
18
18
|
/** 实际渲染的周行:'all' 模式返回全部,'items' 模式按可见范围裁剪 */
|
|
19
19
|
export declare function getVisibleWeeks(weeks: WeekRow[], viewMode: ViewMode, visibilityRange: VisibilityRange | null): VisibleWeek[];
|
|
20
20
|
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/components/Calendar/layout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElE,mBAAmB;AACnB,MAAM,MAAM,OAAO,GAAG,OAAO,EAAE,CAAC;AAEhC,qCAAqC;AACrC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAmBD,iDAAiD;AACjD,wBAAgB,WAAW,CACzB,
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/components/Calendar/layout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElE,mBAAmB;AACnB,MAAM,MAAM,OAAO,GAAG,OAAO,EAAE,CAAC;AAEhC,qCAAqC;AACrC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAmBD,iDAAiD;AACjD,wBAAgB,WAAW,CACzB,QAAQ,EAAE,SAAS,EAAE,EACrB,IAAI,EAAE,OAAO,EAAE,GACd;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAqIlE;AAED,oDAAoD;AACpD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,SAAS,EAAE,EACrB,YAAY,EAAE,aAAa,EAAE,EAC7B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,eAAe,GAAG,IAAI,CA4BxB;AAED,6CAA6C;AAC7C,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,EAAE,EAChB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,GAAG,IAAI,GACtC,WAAW,EAAE,CAUf"}
|
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { DailySchedule, TodoRange } from '../../types';
|
|
3
|
+
/** 日程图标项:key 为唯一标识,icon 为渲染节点,tip 为提示文案 */
|
|
4
|
+
export interface IconItem {
|
|
5
|
+
/** 图标标识(唯一 key,存储到日程 icon 字段) */
|
|
6
|
+
key: string;
|
|
7
|
+
/** 图标节点(ReactNode:emoji 字符串 / React 元素 / DOM) */
|
|
8
|
+
icon: ReactNode;
|
|
9
|
+
/** 图标名称/提示(hover tooltip、图标选择器展示) */
|
|
10
|
+
tip: string;
|
|
11
|
+
}
|
|
3
12
|
export interface CalendarProps {
|
|
4
|
-
/**
|
|
5
|
-
todos
|
|
6
|
-
/**
|
|
7
|
-
schedules
|
|
8
|
-
/**
|
|
13
|
+
/** 初始的待办列表(仅初始化时生效,后续由组件内部状态维护) */
|
|
14
|
+
todos?: TodoRange[];
|
|
15
|
+
/** 初始的日程列表(仅初始化时生效,后续由组件内部状态维护) */
|
|
16
|
+
schedules?: DailySchedule[];
|
|
17
|
+
/** 数据变更回调:每次内部 todos/schedules 修改后调用,参数为最新值 */
|
|
18
|
+
onChange?: (todos: TodoRange[], schedules: DailySchedule[]) => void;
|
|
19
|
+
/** 兼容:保存(新增或编辑)待办 */
|
|
9
20
|
onSaveTodo?: (t: TodoRange) => void;
|
|
10
|
-
/**
|
|
21
|
+
/** 兼容:删除待办 */
|
|
11
22
|
onDeleteTodo?: (id: string) => void;
|
|
12
|
-
/**
|
|
23
|
+
/** 兼容:保存(新增或编辑)日程 */
|
|
13
24
|
onSaveSchedule?: (s: DailySchedule) => void;
|
|
14
|
-
/**
|
|
25
|
+
/** 兼容:删除日程 */
|
|
15
26
|
onDeleteSchedule?: (id: string) => void;
|
|
16
27
|
/** 是否预览模式(禁用新增/编辑操作) */
|
|
17
28
|
isPreview?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
icons?:
|
|
29
|
+
/** 日程可用图标列表 */
|
|
30
|
+
icons?: IconItem[];
|
|
20
31
|
}
|
|
21
32
|
/** 待办横条段(按周行分段渲染) */
|
|
22
33
|
export interface TodoSeg {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Calendar/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,WAAW,aAAa;IAC5B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Calendar/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D,2CAA2C;AAC3C,MAAM,WAAW,QAAQ;IACvB,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,IAAI,EAAE,SAAS,CAAC;IAChB,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;IACpB,mCAAmC;IACnC,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAC5B,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;IACpE,qBAAqB;IACrB,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IACpC,cAAc;IACd,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,qBAAqB;IACrB,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,cAAc;IACd,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,wBAAwB;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe;IACf,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;CACpB;AAED,qBAAqB;AACrB,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,6BAA6B;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,6BAA6B;IAC7B,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,iCAAiC;AACjC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;AAEvC,sBAAsB;AACtB,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),S=require("react"),c=require("antd"),g=require("dayjs"),re=require("lunar-javascript"),Q=require("@ant-design/icons"),oe="holiday_cache_v2_",le=n=>`${oe}${n}`;async function ce(n){const t=le(n),s=localStorage.getItem(t);if(s)try{return JSON.parse(s)}catch{localStorage.removeItem(t)}localStorage.removeItem(`holiday_cache_${n}`);const l=await fetch(`https://timor.tech/api/holiday/year/${n}`);if(!l.ok)throw new Error(`节假日接口请求失败: ${l.status}`);const a=await l.json(),d=(a==null?void 0:a.holiday)??(a==null?void 0:a.data)??{},o={};return Object.entries(d).forEach(([u,p])=>{if(!p||typeof p!="object")return;const[f,j]=u.split("-"),r=f==null?void 0:f.padStart(2,"0"),m=j==null?void 0:j.padStart(2,"0");!r||!m||r.length!==2||m.length!==2||(o[`${n}-${r}-${m}`]={holiday:!!p.holiday,name:String(p.name??""),target:p.target!=null?String(p.target):void 0})}),Object.keys(o).length>0?localStorage.setItem(t,JSON.stringify(o)):localStorage.removeItem(t),o}const D=n=>n.format("YYYY-MM-DD"),Z=n=>n.startTime??"00:00";function W(n){return n.startTime&&n.endTime?`${n.startTime}-${n.endTime}`:n.startTime??n.endTime??""}function ie(n,t){const l=g(`${n}-${t+1}-01`).startOf("week");return Array.from({length:42},(a,d)=>{const o=l.add(d,"day");return{date:o,inMonth:o.month()===t}})}function de(n,t){const s=new Date(`${n}T00:00:00`);s.setDate(s.getDate()+t);const l=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),d=String(s.getDate()).padStart(2,"0");return`${l}-${a}-${d}`}function me(n){const t=Object.keys(n).sort(),s=d=>n[d],l=d=>{const o=de(d,-1),u=s(o);if(u)return!u.holiday;const p=n[d].target??"";return p?!t.some(f=>{if(f>=d)return!1;const j=s(f);return!!j&&j.holiday&&(j.target??"")===p}):!0},a={};return t.forEach(d=>{const o=n[d];if(o){if(!o.holiday){a[d]={name:"",off:!1};return}a[d]={name:l(d)?o.name:"",off:!0}}}),a}function ue(n,t){const[s,l]=S.useState(()=>{try{const a=localStorage.getItem(n);return a?JSON.parse(a):t}catch{return t}});return S.useEffect(()=>{try{localStorage.setItem(n,JSON.stringify(s))}catch{}},[n,s]),[s,l]}const J=["#f5222d","#fa8c16","#fadb14","#52c41a","#13c2c2","#1677ff","#722ed1","#eb2f96"];function he({value:n=J[5],onChange:t}){return e.jsx("div",{className:"color-swatches",children:J.map(s=>e.jsx("span",{className:`swatch ${n===s?"active":""}`,style:{background:s},onClick:()=>t==null?void 0:t(s)},s))})}function fe({open:n,editing:t,initialStart:s,initialEnd:l,onClose:a,onSave:d,onDelete:o}){const[u]=c.Form.useForm(),p=!!t;S.useEffect(()=>{n&&setTimeout(()=>{t?u.setFieldsValue({name:t.name,start:g(t.start),end:g(t.end),startTime:t.startTime?g(t.startTime,"HH:mm"):null,endTime:t.endTime?g(t.endTime,"HH:mm"):null,color:t.color}):(u.setFieldsValue({color:J[5],start:s?g(s):g(),end:l?g(l):g(),startTime:null,endTime:null}),u.resetFields(["name"]))},100)},[n,t,s,l,u]);const f={validator:(y,E)=>{const h=u.getFieldValue("start");return!E||!h||!E.isBefore(h,"day")?Promise.resolve():Promise.reject(new Error("结束日期不能早于开始日期"))}},j={validator:()=>{const y=u.getFieldValue("start"),E=u.getFieldValue("end");return!y||!E?Promise.resolve():E.isSame(y,"day")?Promise.reject(new Error("待办必须跨天(结束日期需晚于开始日期);单日事件请创建日程")):Promise.resolve()}},r={validator:(y,E)=>{var H;const h=u.getFieldValue("start"),k=u.getFieldValue("end");if(!h||!k||!k.isSame(h,"day"))return Promise.resolve();const b=((H=u.getFieldValue("startTime"))==null?void 0:H.format("HH:mm"))??"00:00";return((E==null?void 0:E.format("HH:mm"))??"24:00")<b?Promise.reject(new Error("结束时间不能早于开始时间")):Promise.resolve()}},m=async()=>{const y=await u.validateFields(),E=y.startTime,h=y.endTime;d({id:(t==null?void 0:t.id)??crypto.randomUUID(),name:y.name.trim(),start:y.start.format("YYYY-MM-DD"),end:y.end.format("YYYY-MM-DD"),startTime:E?E.format("HH:mm"):void 0,endTime:h?h.format("HH:mm"):void 0,color:y.color}),a()},x=()=>{t&&o(t.id),a()};return e.jsx(c.Modal,{title:p?"编辑待办":"添加待办",open:n,onCancel:a,okText:"保存",cancelText:"取消",destroyOnClose:!0,footer:e.jsxs(c.Space,{children:[p&&e.jsx(c.Button,{danger:!0,onClick:x,children:"删除"}),e.jsx(c.Button,{onClick:a,children:"取消"}),e.jsx(c.Button,{type:"primary",onClick:m,children:"保存"})]}),children:e.jsxs(c.Form,{form:u,layout:"vertical",preserve:!1,children:[e.jsx(c.Form.Item,{label:"事件名称",name:"name",rules:[{required:!0,message:"请输入事件名称"},{max:30}],children:e.jsx(c.Input,{placeholder:"如:年度项目冲刺",maxLength:30})}),e.jsxs(c.Row,{gutter:8,children:[e.jsx(c.Col,{span:12,children:e.jsx(c.Form.Item,{label:"开始日期",name:"start",dependencies:["end"],rules:[{required:!0,message:"请选择开始日期"},j],children:e.jsx(c.DatePicker,{style:{width:"100%"},format:"YYYY-MM-DD"})})}),e.jsx(c.Col,{span:12,children:e.jsx(c.Form.Item,{label:"开始时间",name:"startTime",children:e.jsx(c.TimePicker,{style:{width:"100%"},format:"HH:mm",minuteStep:30,placeholder:"首日开始时间,可选",allowClear:!0})})})]}),e.jsxs(c.Row,{gutter:8,children:[e.jsx(c.Col,{span:12,children:e.jsx(c.Form.Item,{label:"结束日期",name:"end",dependencies:["start"],rules:[{required:!0,message:"请选择结束日期"},f,j],children:e.jsx(c.DatePicker,{style:{width:"100%"},format:"YYYY-MM-DD"})})}),e.jsx(c.Col,{span:12,children:e.jsx(c.Form.Item,{label:"结束时间",name:"endTime",rules:[r],children:e.jsx(c.TimePicker,{style:{width:"100%"},format:"HH:mm",minuteStep:30,placeholder:"末日结束时间,可选",allowClear:!0})})})]}),e.jsx(c.Form.Item,{label:"颜色标记",name:"color",initialValue:J[5],children:e.jsx(he,{})})]})})}function pe({icons:n,onChange:t}){return e.jsx("div",{className:"emoji-grid",children:Object.entries(n).map(([s,l])=>e.jsx("span",{className:"emoji-item",onClick:()=>t==null?void 0:t(s),children:l},s))})}function xe({open:n,editing:t,initialDate:s,icons:l,onClose:a,onSave:d,onDelete:o}){const[u]=c.Form.useForm(),p=!!t,f=Object.keys(l);S.useEffect(()=>{n&&setTimeout(()=>{t?u.setFieldsValue({icon:t.icon,date:g(t.date),name:t.name,timeRange:t.startTime&&t.endTime?[g(t.startTime,"HH:mm"),g(t.endTime,"HH:mm")]:null}):(u.setFieldsValue({icon:f[0],date:s?g(s):g(),timeRange:null}),u.resetFields(["name"]))},100)},[n,t,s,u,l]);const j=async()=>{const m=await u.validateFields(),x=m.timeRange;d({id:(t==null?void 0:t.id)??crypto.randomUUID(),icon:m.icon,date:m.date.format("YYYY-MM-DD"),name:m.name.trim(),startTime:x!=null&&x[0]?x[0].format("HH:mm"):void 0,endTime:x!=null&&x[1]?x[1].format("HH:mm"):void 0}),a()},r=()=>{t&&o(t.id),a()};return e.jsx(c.Modal,{title:p?"编辑日程":"添加日程",open:n,onOk:j,onCancel:a,okText:"保存",cancelText:"取消",destroyOnClose:!0,footer:e.jsxs(c.Space,{children:[p&&e.jsx(c.Button,{danger:!0,onClick:r,children:"删除"}),e.jsx(c.Button,{onClick:a,children:"取消"}),e.jsx(c.Button,{type:"primary",onClick:j,children:"保存"})]}),children:e.jsxs(c.Form,{form:u,layout:"vertical",preserve:!1,children:[e.jsx(c.Form.Item,{label:"图标",name:"icon",initialValue:f[0],rules:[{required:!0}],children:e.jsx(pe,{icons:l})}),e.jsx(c.Form.Item,{label:"日期",name:"date",rules:[{required:!0,message:"请选择日期"}],children:e.jsx(c.DatePicker,{style:{width:"100%"},format:"YYYY-MM-DD"})}),e.jsx(c.Form.Item,{label:"时间范围",name:"timeRange",children:e.jsx(c.TimePicker.RangePicker,{style:{width:"100%"},format:"HH:mm",minuteStep:30,placeholder:["开始时间","结束时间"],allowClear:!0})}),e.jsx(c.Form.Item,{label:"名称",name:"name",rules:[{required:!0,message:"请输入名称"},{max:30}],children:e.jsx(c.Input,{placeholder:"如:牙医复诊",maxLength:30})})]})})}const je=2;function se(n){try{const[t,s,l]=n.split("-").map(Number),a=re.Solar.fromYmd(t,s,l).getLunar(),d=a.getFestivals();if(d.length>0)return d[0];const o=a.getJieQi();return o||(a.getDay()===1?`${a.getMonthInChinese()}月初一`:a.getDayInChinese())}catch{return""}}function ye(n){const{dateStr:t,day:s,inMonth:l,isToday:a,isWeekend:d,holiday:o,todoLanes:u,schedules:p,onEditSchedule:f,selected:j,onSelect:r,icons:m}=n,x=["day-cell"];l||x.push("out"),a&&x.push("today"),d&&x.push("weekend"),j&&x.push("selected"),o&&x.push(o!=null&&o.off?"holiday-off":"holiday-work");const y=p.slice(0,je),E=p.length-y.length;return e.jsxs("div",{className:x.join(" "),onClick:h=>{h.stopPropagation(),r==null||r(t)},children:[e.jsxs("div",{className:"day-top",children:[e.jsx("span",{className:"day-num",children:s}),e.jsxs("span",{className:"day-lunar",children:[(o==null?void 0:o.name)||se(t),o&&e.jsx("div",{className:`day-holiday ${o.off?"off":"work"}`,children:o.off?"休":"班"})]})]}),u>0&&e.jsx("div",{className:"todo-spacer",style:{height:u*22}}),e.jsxs("div",{className:"schedule-list",children:[y.map(h=>e.jsx(c.Tooltip,{title:[h.name,W(h)].filter(Boolean).join(" "),children:e.jsxs("span",{className:"schedule-item",onClick:k=>{k.stopPropagation(),f(h,t)},children:[e.jsx("span",{className:"schedule-icon",children:m==null?void 0:m[h.icon]}),e.jsx("span",{className:"schedule-name",children:h.name})]})},h.id)),E>0&&e.jsxs("span",{className:"schedule-more",children:["+",E," 更多"]})]})]})}function ge({year:n,month:t,viewMode:s,loading:l,onViewModeChange:a,onToday:d,onPrevMonth:o,onNextMonth:u,isPreview:p}){return e.jsxs("div",{className:"calendar-header",children:[e.jsxs("span",{className:"calendar-title",children:[n,"年",t+1,"月"]}),e.jsx(c.Segmented,{size:"small",options:[{label:"日历",value:"all"},{label:"事项",value:"items"}],value:s,onChange:f=>a(f)}),!p&&e.jsxs(c.Space,{children:[e.jsx(c.Button,{shape:"circle",size:"small",onClick:d,children:"今"}),e.jsx(c.Button,{shape:"circle",size:"small",onClick:o,children:e.jsx(Q.LeftOutlined,{})}),e.jsx(c.Button,{shape:"circle",size:"small",onClick:u,children:e.jsx(Q.RightOutlined,{})}),l&&e.jsx(c.Spin,{size:"small"})]})]})}function Te({segs:n,onEditTodo:t}){return e.jsx("div",{className:"todo-lanes",children:n.map((s,l)=>{const a=s.todo,d=`${a.start}${a.startTime?` ${a.startTime}`:""} ~ ${a.end}${a.endTime?` ${a.endTime}`:""}`,o=a.start===a.end?W(a):"";return e.jsx("span",{className:`todo-bar${s.roundLeft?" round-left":""}${s.roundRight?" round-right":""}`,title:`${a.name}(${d})`,style:{top:54+s.lane*22,left:`${s.leftEdge/7*100}%`,width:`${(Math.max(s.rightEdge,s.leftEdge)-s.leftEdge)/7*100}%`,background:a.color},onClick:u=>{u.stopPropagation(),t(a)},children:s.showLabel&&e.jsx("span",{className:"todo-bar-label",children:o?`${a.name} ${o}`:a.name})},`${a.id}-${l}`)})})}const Se=["周日","周一","周二","周三","周四","周五","周六"];function ee(n,t){const s=g(n);return s.year()===t?`${s.month()+1}月${s.date()}日`:`${s.year()}年${s.month()+1}月${s.date()}日`}function Ee({dateStr:n,holiday:t,todos:s,schedules:l,onEditTodo:a,onEditSchedule:d,onAddTodo:o,onAddSchedule:u,isPreview:p}){const f=g(n),j=f.year();return e.jsxs("div",{className:"day-panel",children:[e.jsxs("div",{className:"day-panel-header",children:[e.jsxs("div",{className:"day-panel-title",children:[f.year(),"年",f.month()+1,"月",f.date(),"日 ",Se[f.day()],!p&&e.jsxs("div",{className:"day-panel-actions",children:[e.jsx(c.Button,{size:"small",onClick:o,children:"添加待办"}),e.jsx(c.Button,{size:"small",onClick:u,children:"添加日程"})]})]}),e.jsx("span",{className:"day-panel-sub",children:t!=null&&t.name?t.name:se(n)||" "})]}),!!s.length&&e.jsxs("div",{className:"day-panel-section",children:[e.jsxs("div",{className:"day-panel-subtitle",children:["待办(",s.length,")"]}),s.map(r=>e.jsxs("div",{className:"day-panel-todo",onClick:()=>a(r),title:"点击编辑",children:[e.jsx("span",{className:"day-panel-todo-dot",style:{background:r.color}}),e.jsx("span",{className:"day-panel-todo-name",children:r.name}),e.jsxs("span",{className:"day-panel-todo-range",children:[ee(r.start,j),r.startTime?` ${r.startTime}`:""," ~ ",ee(r.end,j),r.endTime?` ${r.endTime}`:""]})]},r.id))]}),!!l.length&&e.jsxs("div",{className:"day-panel-section",children:[e.jsxs("div",{className:"day-panel-subtitle",children:["日程(",l.length,")"]}),l.map(r=>e.jsxs("div",{className:"day-panel-schedule",onClick:()=>d(r),title:"点击编辑",children:[e.jsx("span",{className:"day-panel-schedule-icon",children:r.icon}),e.jsx("span",{className:"day-panel-schedule-name",children:r.name}),W(r)&&e.jsx("span",{className:"day-panel-schedule-time",children:W(r)})]},r.id))]}),l.length===0&&e.jsx(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE,description:"本月暂无待办和日程"})]})}function te(n){const[t,s]=n.split(":").map(Number);return t*60+s}function ve(n,t){const s=n.startTime?te(n.startTime):0,l=n.endTime?te(n.endTime):1440,a=D(t);return n.start===n.end?[s,l]:a===n.start?[s,1440]:a===n.end?[0,l]:[0,1440]}function Me(n,t){const s={};t.forEach((r,m)=>{s[D(r.date)]=m});const l=D(t[0].date),a=D(t[t.length-1].date),d=new Array(t.length).fill(0),o=[],p=[...n].sort((r,m)=>{if(r.start!==m.start)return r.start.localeCompare(m.start);const x=r.startTime??"00:00",y=m.startTime??"00:00";return x!==y?x.localeCompare(y):r.end!==m.end?r.end.localeCompare(m.end):(r.endTime??"23:59").localeCompare(m.endTime??"23:59")}).filter(r=>!(r.end<l||r.start>a)).map(r=>({original:r,cs:r.start<l?l:r.start,ce:r.end>a?a:r.end})).filter(r=>{const m=s[r.cs],x=s[r.ce];return m!==void 0&&x!==void 0}),f=Math.ceil(t.length/7);for(let r=0;r<f;r++){const m=r*7,x=Math.min(m+6,t.length-1),y=Array.from({length:7},()=>[[],[],[]]),E=p.filter(h=>{const k=s[h.cs];return s[h.ce]>=m&&k<=x});for(const{original:h,cs:k,ce:b}of E){const P=s[k],H=s[b],M=Math.max(P,m)-m,C=Math.min(H,x)-m,I=[];for(let T=M;T<=C;T++)I.push(ve(h,t[m+T].date));let L=-1;for(let T=0;T<3;T++){let F=!0;for(let w=M;w<=C&&F;w++){const[R,_]=I[w-M];R>=_||(F=!y[w][T].some(A=>A.s<_&&R<A.e))}if(F){L=T;break}}if(L===-1)continue;const V=P>=m&&k===h.start,N=H<=x&&b===h.end,[Y]=I[0],[,O]=I[I.length-1],q=M+(V?Y/1440:0),z=N?C+O/1440:C+1;o.push({todo:h,weekRow:r,startCol:M,endCol:C,leftEdge:q,rightEdge:z,lane:L,showLabel:V,roundLeft:V,roundRight:N});for(let T=M;T<=C;T++){const[F,w]=I[T-M];F<w&&y[T][L].push({s:F,e:w})}for(let T=M;T<=C;T++){const[F,w]=I[T-M];if(F<w){const R=m+T;d[R]<L+1&&(d[R]=L+1)}}}}const j={};return t.forEach((r,m)=>{d[m]>0&&(j[D(r.date)]=d[m])}),{todoSegs:o,todoLanesByDate:j}}function ke(n,t,s,l,a){const d=`${l}-${String(a+1).padStart(2,"0")}-01`,o=g(new Date(l,a+1,0)),u=`${o.year()}-${String(o.month()+1).padStart(2,"0")}-${String(o.date()).padStart(2,"0")}`,p=new Set;return n.forEach(f=>{const j=f.start<d?d:f.start,r=f.end>u?u:f.end;if(r<j)return;let m=g(j);for(;D(m)<=r;){const x=s[D(m)];x!==void 0&&p.add(Math.floor(x/7)),m=m.add(1,"day")}}),t.forEach(f=>{if(f.date>=d&&f.date<=u){const j=s[f.date];j!==void 0&&p.add(Math.floor(j/7))}}),p.size===0?null:{min:Math.min(...p),max:Math.max(...p)}}function Ne(n,t,s){if(t==="all")return n.map((a,d)=>({week:a,rowIndex:d}));if(!s)return[];const l=[];for(let a=s.min;a<=s.max;a++)l.push({week:n[a],rowIndex:a});return l}const $e=["日","一","二","三","四","五","六"];function we({todos:n,schedules:t,onSaveTodo:s,onDeleteTodo:l,onSaveSchedule:a,onDeleteSchedule:d,isPreview:o,icons:u}){const[p,f]=S.useState(g()),[j,r]=S.useState({}),[m,x]=S.useState(!1),[y,E]=ue("calendar_view_mode",o?"items":"all"),[h,k]=S.useState(D(g())),[b,P]=S.useState({open:!1,editing:null}),[H,M]=S.useState({open:!1,editing:null}),C=i=>{o||P({open:!0,editing:i})},I=(i,v)=>{o||M({open:!0,editing:i})},L=i=>{o||P({open:!0,editing:null,initialStart:i,initialEnd:i})},V=i=>{o||M({open:!0,editing:null,initialDate:i})},N=p.year(),Y=p.month();S.useEffect(()=>{let i=!1;return x(!0),ce(N).then(v=>{i||r(v)}).catch(()=>{i||r({})}).finally(()=>{i||x(!1)}),()=>{i=!0}},[N]);const O=S.useMemo(()=>ie(N,Y),[N,Y]),q=S.useMemo(()=>me(j),[j]),z=S.useMemo(()=>{const i={};return t.forEach(v=>{var $;(i[$=v.date]??(i[$]=[])).push(v)}),Object.values(i).forEach(v=>v.sort(($,U)=>Z($).localeCompare(Z(U)))),i},[t]),T=S.useMemo(()=>{const i=[];for(let v=0;v<O.length;v+=7)i.push(O.slice(v,v+7));return i},[O]),{todoSegs:F,todoLanesByDate:w}=S.useMemo(()=>Me(n,O),[n,O]),R=D(g()),_=S.useMemo(()=>{const i={};return O.forEach((v,$)=>{i[D(v.date)]=$}),i},[O]),A=`${N}-${String(Y+1).padStart(2,"0")}-01`;S.useEffect(()=>{if(!h||_[h]!==void 0)return;const i=R;k(_[i]!==void 0&&i.startsWith(A.slice(0,8))?i:A)},[N,Y]);const ne=i=>{k(v=>v===i?null:i)},K=S.useMemo(()=>ke(n,t,_,N,Y),[n,t,N,Y,_]),G=S.useMemo(()=>Ne(T,y,K),[T,y,K]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"calendar",children:[e.jsx(ge,{isPreview:o,year:N,month:Y,viewMode:y,loading:m,onViewModeChange:E,onToday:()=>f(g()),onPrevMonth:()=>f(p.subtract(1,"month")),onNextMonth:()=>f(p.add(1,"month"))}),e.jsx("div",{className:"week-row",children:$e.map(i=>e.jsx("div",{className:"week-cell",children:i},i))}),e.jsx("div",{className:"day-grid",children:G.length===0?e.jsx("div",{className:"calendar-empty",children:e.jsx(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE,description:"本月暂无待办和日程"})}):G.map(({week:i,rowIndex:v})=>e.jsxs("div",{className:"day-week",children:[i.map(({date:$,inMonth:U})=>{const B=D($),X=$.day(),ae=X===0||X===6;return e.jsx(ye,{dateStr:B,day:$.date(),inMonth:U,isToday:B===R,isWeekend:ae,holiday:q[B],todoLanes:w[B]??0,schedules:z[B]??[],onEditSchedule:I,icons:u,selected:h===B,onSelect:ne},B)}),e.jsx(Te,{segs:F.filter($=>$.weekRow===v),onEditTodo:C})]},v))})]}),h&&e.jsx(Ee,{dateStr:h,holiday:q[h],todos:n.filter(i=>i.start<=h&&h<=i.end),schedules:z[h]??[],onEditTodo:C,onEditSchedule:i=>I(i),onAddTodo:()=>L(h),onAddSchedule:()=>V(h),isPreview:o}),e.jsx(fe,{open:b.open,editing:b.editing,initialStart:b.initialStart,initialEnd:b.initialEnd,onClose:()=>P({open:!1,editing:null}),onSave:i=>s==null?void 0:s(i),onDelete:i=>l==null?void 0:l(i)}),e.jsx(xe,{open:H.open,editing:H.editing,initialDate:H.initialDate,icons:u??{},onClose:()=>M({open:!1,editing:null}),onSave:i=>a==null?void 0:a(i),onDelete:i=>d==null?void 0:d(i)})]})}exports.Calendar=we;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("react"),c=require("antd"),E=require("dayjs"),pe=require("lunar-javascript"),oe=require("@ant-design/icons"),xe="holiday_cache_v2_",ye=n=>`${xe}${n}`;async function je(n){const t=ye(n),s=localStorage.getItem(t);if(s)try{return JSON.parse(s)}catch{localStorage.removeItem(t)}localStorage.removeItem(`holiday_cache_${n}`);const l=await fetch(`https://timor.tech/api/holiday/year/${n}`);if(!l.ok)throw new Error(`节假日接口请求失败: ${l.status}`);const a=await l.json(),u=(a==null?void 0:a.holiday)??(a==null?void 0:a.data)??{},i={};return Object.entries(u).forEach(([d,p])=>{if(!p||typeof p!="object")return;const[x,h]=d.split("-"),j=x==null?void 0:x.padStart(2,"0"),r=h==null?void 0:h.padStart(2,"0");!j||!r||j.length!==2||r.length!==2||(i[`${n}-${j}-${r}`]={holiday:!!p.holiday,name:String(p.name??""),target:p.target!=null?String(p.target):void 0})}),Object.keys(i).length>0?localStorage.setItem(t,JSON.stringify(i)):localStorage.removeItem(t),i}const F=n=>n.format("YYYY-MM-DD"),le=n=>n.startTime??"00:00";function J(n){return n.startTime&&n.endTime?`${n.startTime}-${n.endTime}`:n.startTime??n.endTime??""}function ge(n,t){const l=E(`${n}-${t+1}-01`).startOf("week");return Array.from({length:42},(a,u)=>{const i=l.add(u,"day");return{date:i,inMonth:i.month()===t}})}function Se(n,t){const s=new Date(`${n}T00:00:00`);s.setDate(s.getDate()+t);const l=s.getFullYear(),a=String(s.getMonth()+1).padStart(2,"0"),u=String(s.getDate()).padStart(2,"0");return`${l}-${a}-${u}`}function Te(n){const t=Object.keys(n).sort(),s=u=>n[u],l=u=>{const i=Se(u,-1),d=s(i);if(d)return!d.holiday;const p=n[u].target??"";return p?!t.some(x=>{if(x>=u)return!1;const h=s(x);return!!h&&h.holiday&&(h.target??"")===p}):!0},a={};return t.forEach(u=>{const i=n[u];if(i){if(!i.holiday){a[u]={name:"",off:!1};return}a[u]={name:l(u)?i.name:"",off:!0}}}),a}function Ee(n,t){const[s,l]=v.useState(()=>{try{const a=localStorage.getItem(n);return a?JSON.parse(a):t}catch{return t}});return v.useEffect(()=>{try{localStorage.setItem(n,JSON.stringify(s))}catch{}},[n,s]),[s,l]}const U=["#f5222d","#fa8c16","#fadb14","#52c41a","#13c2c2","#1677ff","#722ed1","#eb2f96"];function ve({value:n=U[5],onChange:t}){return e.jsx("div",{className:"color-swatches",children:U.map(s=>e.jsx("span",{className:`swatch ${n===s?"active":""}`,style:{background:s},onClick:()=>t==null?void 0:t(s)},s))})}function Me({open:n,editing:t,initialStart:s,initialEnd:l,onClose:a,onSave:u,onDelete:i}){const[d]=c.Form.useForm(),p=!!t;v.useEffect(()=>{n&&setTimeout(()=>{t?d.setFieldsValue({name:t.name,start:E(t.start),end:E(t.end),startTime:t.startTime?E(t.startTime,"HH:mm"):null,endTime:t.endTime?E(t.endTime,"HH:mm"):null,color:t.color}):(d.setFieldsValue({color:U[5],start:s?E(s):E(),end:l?E(l):E().add(1,"day"),startTime:null,endTime:null}),d.resetFields(["name"]))},100)},[n,t,s,l,d]);const x={validator:(f,g)=>{const M=d.getFieldValue("start");return!g||!M||!g.isBefore(M,"day")?Promise.resolve():Promise.reject(new Error("结束日期不能早于开始日期"))}},h={validator:()=>{const f=d.getFieldValue("start"),g=d.getFieldValue("end");return!f||!g?Promise.resolve():g.isSame(f,"day")?Promise.reject(new Error("待办必须跨天(结束日期需晚于开始日期);单日事件请创建日程")):Promise.resolve()}},j={validator:(f,g)=>{var O;const M=d.getFieldValue("start"),T=d.getFieldValue("end");if(!M||!T||!T.isSame(M,"day"))return Promise.resolve();const D=((O=d.getFieldValue("startTime"))==null?void 0:O.format("HH:mm"))??"00:00";return((g==null?void 0:g.format("HH:mm"))??"24:00")<D?Promise.reject(new Error("结束时间不能早于开始时间")):Promise.resolve()}},r=async()=>{const f=await d.validateFields(),g=f.startTime,M=f.endTime;u({id:(t==null?void 0:t.id)??crypto.randomUUID(),name:f.name.trim(),start:f.start.format("YYYY-MM-DD"),end:f.end.format("YYYY-MM-DD"),startTime:g?g.format("HH:mm"):void 0,endTime:M?M.format("HH:mm"):void 0,color:f.color}),a()},m=()=>{t&&i(t.id),a()};return e.jsx(c.Modal,{title:p?"编辑待办":"添加待办",open:n,onCancel:a,okText:"保存",cancelText:"取消",destroyOnClose:!0,footer:e.jsxs(c.Space,{children:[p&&e.jsx(c.Button,{danger:!0,onClick:m,children:"删除"}),e.jsx(c.Button,{onClick:a,children:"取消"}),e.jsx(c.Button,{type:"primary",onClick:r,children:"保存"})]}),children:e.jsxs(c.Form,{form:d,layout:"vertical",preserve:!1,children:[e.jsx(c.Form.Item,{label:"事件名称",name:"name",rules:[{required:!0,message:"请输入事件名称"},{max:30}],children:e.jsx(c.Input,{placeholder:"如:年度项目冲刺",maxLength:30})}),e.jsxs(c.Row,{gutter:8,children:[e.jsx(c.Col,{span:12,children:e.jsx(c.Form.Item,{label:"开始日期",name:"start",dependencies:["end"],rules:[{required:!0,message:"请选择开始日期"},h],children:e.jsx(c.DatePicker,{style:{width:"100%"},format:"YYYY-MM-DD"})})}),e.jsx(c.Col,{span:12,children:e.jsx(c.Form.Item,{label:"开始时间",name:"startTime",children:e.jsx(c.TimePicker,{style:{width:"100%"},format:"HH:mm",minuteStep:30,placeholder:"首日开始时间,可选",allowClear:!0})})})]}),e.jsxs(c.Row,{gutter:8,children:[e.jsx(c.Col,{span:12,children:e.jsx(c.Form.Item,{label:"结束日期",name:"end",dependencies:["start"],rules:[{required:!0,message:"请选择结束日期"},x,h],children:e.jsx(c.DatePicker,{style:{width:"100%"},format:"YYYY-MM-DD"})})}),e.jsx(c.Col,{span:12,children:e.jsx(c.Form.Item,{label:"结束时间",name:"endTime",rules:[j],children:e.jsx(c.TimePicker,{style:{width:"100%"},format:"HH:mm",minuteStep:30,placeholder:"末日结束时间,可选",allowClear:!0})})})]}),e.jsx(c.Form.Item,{label:"颜色标记",name:"color",initialValue:U[5],children:e.jsx(ve,{})})]})})}function ke({icons:n,value:t,onChange:s}){return e.jsx("div",{className:"emoji-grid",children:n.map(({key:l,icon:a,tip:u})=>e.jsx("span",{className:t===l?"emoji-item active":"emoji-item",onClick:()=>s==null?void 0:s(l),title:u,children:a},l))})}function Ne({open:n,editing:t,initialDate:s,icons:l,onClose:a,onSave:u,onDelete:i}){const[d]=c.Form.useForm(),p=!!t,x=l.map(r=>r.key);v.useEffect(()=>{n&&setTimeout(()=>{t?d.setFieldsValue({icon:t.icon,date:E(t.date),name:t.name,timeRange:t.startTime&&t.endTime?[E(t.startTime,"HH:mm"),E(t.endTime,"HH:mm")]:null}):(d.setFieldsValue({icon:x[0],date:s?E(s):E(),timeRange:null}),d.resetFields(["name"]))},100)},[n,t,s,d,l]);const h=async()=>{const r=await d.validateFields(),m=r.timeRange;u({id:(t==null?void 0:t.id)??crypto.randomUUID(),icon:r.icon,date:r.date.format("YYYY-MM-DD"),name:r.name.trim(),startTime:m!=null&&m[0]?m[0].format("HH:mm"):void 0,endTime:m!=null&&m[1]?m[1].format("HH:mm"):void 0}),a()},j=()=>{t&&i(t.id),a()};return e.jsx(c.Modal,{title:p?"编辑日程":"添加日程",open:n,onOk:h,onCancel:a,okText:"保存",cancelText:"取消",destroyOnClose:!0,footer:e.jsxs(c.Space,{children:[p&&e.jsx(c.Button,{danger:!0,onClick:j,children:"删除"}),e.jsx(c.Button,{onClick:a,children:"取消"}),e.jsx(c.Button,{type:"primary",onClick:h,children:"保存"})]}),children:e.jsxs(c.Form,{form:d,layout:"vertical",preserve:!1,children:[e.jsx(c.Form.Item,{label:"图标",name:"icon",initialValue:x[0],rules:[{required:!0}],children:e.jsx(ke,{icons:l})}),e.jsx(c.Form.Item,{label:"日期",name:"date",rules:[{required:!0,message:"请选择日期"}],children:e.jsx(c.DatePicker,{style:{width:"100%"},format:"YYYY-MM-DD"})}),e.jsx(c.Form.Item,{label:"时间范围",name:"timeRange",children:e.jsx(c.TimePicker.RangePicker,{style:{width:"100%"},format:"HH:mm",minuteStep:30,placeholder:["开始时间","结束时间"],allowClear:!0})}),e.jsx(c.Form.Item,{label:"名称",name:"name",rules:[{required:!0,message:"请输入名称"},{max:30}],children:e.jsx(c.Input,{placeholder:"如:牙医复诊",maxLength:30})})]})})}const $e=2;function de(n){try{const[t,s,l]=n.split("-").map(Number),a=pe.Solar.fromYmd(t,s,l).getLunar(),u=a.getFestivals();if(u.length>0)return u[0];const i=a.getJieQi();return i||(a.getDay()===1?`${a.getMonthInChinese()}月初一`:a.getDayInChinese())}catch{return""}}function De(n){const{dateStr:t,day:s,inMonth:l,isToday:a,isWeekend:u,holiday:i,todoLanes:d,schedules:p,onEditSchedule:x,selected:h,onSelect:j,icons:r}=n,m=["day-cell"];l||m.push("out"),a&&m.push("today"),u&&m.push("weekend"),h&&m.push("selected"),i&&m.push(i!=null&&i.off?"holiday-off":"holiday-work");const f=p.slice(0,$e),g=p.length-f.length;return e.jsxs("div",{className:m.join(" "),onClick:M=>{M.stopPropagation(),j==null||j(t)},children:[e.jsxs("div",{className:"day-top",children:[e.jsx("span",{className:"day-num",children:s}),e.jsxs("span",{className:"day-lunar",children:[(i==null?void 0:i.name)||de(t),i&&e.jsx("div",{className:`day-holiday ${i.off?"off":"work"}`,children:i.off?"休":"班"})]})]}),d>0&&e.jsx("div",{className:"todo-spacer",style:{height:d*22}}),e.jsxs("div",{className:"schedule-list",children:[f.map(M=>{var T;return e.jsx(c.Tooltip,{title:[M.name,J(M)].filter(Boolean).join(" "),children:e.jsxs("span",{className:"schedule-item",onClick:D=>{D.stopPropagation(),x(M,t)},children:[e.jsx("span",{className:"schedule-icon",children:(T=r==null?void 0:r.find(D=>D.key===M.icon))==null?void 0:T.icon}),e.jsx("span",{className:"schedule-name",children:M.name})]})},M.id)}),g>0&&e.jsxs("span",{className:"schedule-more",children:["+",g," 更多"]})]})]})}function we({year:n,month:t,viewMode:s,loading:l,onViewModeChange:a,onToday:u,onPrevMonth:i,onNextMonth:d,isPreview:p}){return e.jsxs("div",{className:"calendar-header",children:[e.jsxs("span",{className:"calendar-title",children:[n,"年",t+1,"月"]}),e.jsx(c.Segmented,{size:"small",options:[{label:"日历",value:"all"},{label:"事项",value:"items"}],value:s,onChange:x=>a(x)}),!p&&e.jsxs(c.Space,{children:[e.jsx(c.Button,{shape:"circle",size:"small",onClick:u,children:"今"}),e.jsx(c.Button,{shape:"circle",size:"small",onClick:i,children:e.jsx(oe.LeftOutlined,{})}),e.jsx(c.Button,{shape:"circle",size:"small",onClick:d,children:e.jsx(oe.RightOutlined,{})}),l&&e.jsx(c.Spin,{size:"small"})]})]})}function be({segs:n,onEditTodo:t}){return e.jsx("div",{className:"todo-lanes",children:n.map((s,l)=>{const a=s.todo,u=`${a.start}${a.startTime?` ${a.startTime}`:""} ~ ${a.end}${a.endTime?` ${a.endTime}`:""}`,i=a.start===a.end?J(a):"";return e.jsx("span",{className:`todo-bar${s.roundLeft?" round-left":""}${s.roundRight?" round-right":""}`,title:`${a.name}(${u})`,style:{top:54+s.lane*22,left:`${s.leftEdge/7*100}%`,width:`${(Math.max(s.rightEdge,s.leftEdge)-s.leftEdge)/7*100}%`,background:a.color},onClick:d=>{d.stopPropagation(),t(a)},children:s.showLabel&&e.jsx("span",{className:"todo-bar-label",children:i?`${a.name} ${i}`:a.name})},`${a.id}-${l}`)})})}const Ie=["周日","周一","周二","周三","周四","周五","周六"];function ce(n,t){const s=E(n);return s.year()===t?`${s.month()+1}月${s.date()}日`:`${s.year()}年${s.month()+1}月${s.date()}日`}function Ye({dateStr:n,holiday:t,todos:s,schedules:l,onEditTodo:a,onEditSchedule:u,onAddTodo:i,onAddSchedule:d,isPreview:p,icons:x}){const h=E(n),j=h.year();return e.jsxs("div",{className:"day-panel",children:[e.jsxs("div",{className:"day-panel-header",children:[e.jsxs("div",{className:"day-panel-title",children:[h.year(),"年",h.month()+1,"月",h.date(),"日 ",Ie[h.day()],!p&&e.jsxs("div",{className:"day-panel-actions",children:[e.jsx(c.Button,{size:"small",onClick:i,children:"添加待办"}),e.jsx(c.Button,{size:"small",onClick:d,children:"添加日程"})]})]}),e.jsx("span",{className:"day-panel-sub",children:t!=null&&t.name?t.name:de(n)||" "})]}),!!(s!=null&&s.length)&&e.jsxs("div",{className:"day-panel-section",children:[e.jsxs("div",{className:"day-panel-subtitle",children:["待办(",s.length,")"]}),s.map(r=>e.jsxs("div",{className:"day-panel-todo",onClick:()=>a(r),title:"点击编辑",children:[e.jsx("span",{className:"day-panel-todo-dot",style:{background:r.color}}),e.jsx("span",{className:"day-panel-todo-name",children:r.name}),e.jsxs("span",{className:"day-panel-todo-range",children:[ce(r.start,j),r.startTime?` ${r.startTime}`:""," ~ ",ce(r.end,j),r.endTime?` ${r.endTime}`:""]})]},r.id))]}),!!l.length&&e.jsxs("div",{className:"day-panel-section",children:[e.jsxs("div",{className:"day-panel-subtitle",children:["日程(",l.length,")"]}),l.map(r=>{var m;return e.jsxs("div",{className:"day-panel-schedule",onClick:()=>u(r),title:"点击编辑",children:[e.jsx("span",{className:"day-panel-schedule-icon",children:(m=x==null?void 0:x.find(f=>f.key===r.icon))==null?void 0:m.icon}),e.jsx("span",{className:"day-panel-schedule-name",children:r.name}),J(r)&&e.jsx("span",{className:"day-panel-schedule-time",children:J(r)})]},r.id)})]}),l.length===0&&e.jsx(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE,description:"本月暂无待办和日程"})]})}function ie(n){const[t,s]=n.split(":").map(Number);return t*60+s}function Ce(n,t){const s=n.startTime?ie(n.startTime):0,l=n.endTime?ie(n.endTime):1440,a=F(t);return n.start===n.end?[s,l]:a===n.start?[s,1440]:a===n.end?[0,l]:[0,1440]}function Fe(n,t){const s={};t.forEach((r,m)=>{s[F(r.date)]=m});const l=F(t[0].date),a=F(t[t.length-1].date),u=Array.isArray(n)?n:[],i=new Array(t.length).fill(0),d=[],x=[...u].sort((r,m)=>{if(r.start!==m.start)return r.start.localeCompare(m.start);const f=r.startTime??"00:00",g=m.startTime??"00:00";return f!==g?f.localeCompare(g):r.end!==m.end?r.end.localeCompare(m.end):(r.endTime??"23:59").localeCompare(m.endTime??"23:59")}).filter(r=>!(r.end<l||r.start>a)).map(r=>({original:r,cs:r.start<l?l:r.start,ce:r.end>a?a:r.end})).filter(r=>{const m=s[r.cs],f=s[r.ce];return m!==void 0&&f!==void 0}),h=Math.ceil(t.length/7);for(let r=0;r<h;r++){const m=r*7,f=Math.min(m+6,t.length-1),g=Array.from({length:7},()=>[[],[],[]]),M=x.filter(T=>{const D=s[T.cs];return s[T.ce]>=m&&D<=f});for(const{original:T,cs:D,ce:N}of M){const O=s[D],$=s[N],I=Math.max(O,m)-m,w=Math.min($,f)-m,Y=[];for(let k=I;k<=w;k++)Y.push(Ce(T,t[m+k].date));let H=-1;for(let k=0;k<3;k++){let A=!0;for(let C=I;C<=w&&A;C++){const[P,b]=Y[C-I];P>=b||(A=!g[C][k].some(L=>L.s<b&&P<L.e))}if(A){H=k;break}}if(H===-1)continue;const R=O>=m&&D===T.start,q=$<=f&&N===T.end,[z]=Y[0],[,K]=Y[Y.length-1],G=I+(R?z/1440:0),V=q?w+K/1440:w+1;d.push({todo:T,weekRow:r,startCol:I,endCol:w,leftEdge:G,rightEdge:V,lane:H,showLabel:R,roundLeft:R,roundRight:q});for(let k=I;k<=w;k++){const[A,C]=Y[k-I];A<C&&g[k][H].push({s:A,e:C})}for(let k=I;k<=w;k++){const[A,C]=Y[k-I];if(A<C){const P=m+k;i[P]<H+1&&(i[P]=H+1)}}}}const j={};return t.forEach((r,m)=>{i[m]>0&&(j[F(r.date)]=i[m])}),{todoSegs:d,todoLanesByDate:j}}function He(n,t,s,l,a){const u=Array.isArray(n)?n:[],i=Array.isArray(t)?t:[],d=`${l}-${String(a+1).padStart(2,"0")}-01`,p=E(new Date(l,a+1,0)),x=`${p.year()}-${String(p.month()+1).padStart(2,"0")}-${String(p.date()).padStart(2,"0")}`,h=new Set;return u==null||u.forEach(j=>{const r=j.start<d?d:j.start,m=j.end>x?x:j.end;if(m<r)return;let f=E(r);for(;F(f)<=m;){const g=s[F(f)];g!==void 0&&h.add(Math.floor(g/7)),f=f.add(1,"day")}}),i.forEach(j=>{if(j.date>=d&&j.date<=x){const r=s[j.date];r!==void 0&&h.add(Math.floor(r/7))}}),h.size===0?null:{min:Math.min(...h),max:Math.max(...h)}}function Ae(n,t,s){if(t==="all")return n.map((a,u)=>({week:a,rowIndex:u}));if(!s)return[];const l=[];for(let a=s.min;a<=s.max;a++)l.push({week:n[a],rowIndex:a});return l}const Le=["日","一","二","三","四","五","六"];function Oe({todos:n,schedules:t,onChange:s,onSaveTodo:l,onDeleteTodo:a,onSaveSchedule:u,onDeleteSchedule:i,isPreview:d,icons:p}){const[x,h]=v.useState(E()),[j,r]=v.useState({}),[m,f]=v.useState(!1),[g,M]=Ee("calendar_view_mode",d?"items":"all"),[T,D]=v.useState(F(E())),[N,O]=v.useState(n??[]),[$,I]=v.useState(t??[]),[w,Y]=v.useState({open:!1,editing:null}),[H,R]=v.useState({open:!1,editing:null}),q=o=>{d||Y({open:!0,editing:o})},z=(o,y)=>{d||R({open:!0,editing:o})},K=o=>{d||Y({open:!0,editing:null,initialStart:o,initialEnd:E(o).add(1,"day").format("YYYY-MM-DD")})},G=o=>{d||R({open:!0,editing:null,initialDate:o})},V=(o,y)=>{O(o),I(y),s==null||s(o,y)},k=o=>{const y=N.some(S=>S.id===o.id)?N.map(S=>S.id===o.id?o:S):[...N,o];V(y,$),l==null||l(o)},A=o=>{const y=N.filter(S=>S.id!==o);V(y,$),a==null||a(o)},C=o=>{const y=$.some(S=>S.id===o.id)?$.map(S=>S.id===o.id?o:S):[...$,o];V(N,y),u==null||u(o)},P=o=>{const y=$.filter(S=>S.id!==o);V(N,y),i==null||i(o)},b=x.year(),L=x.month();v.useEffect(()=>{let o=!1;return f(!0),je(b).then(y=>{o||r(y)}).catch(()=>{o||r({})}).finally(()=>{o||f(!1)}),()=>{o=!0}},[b]);const _=v.useMemo(()=>ge(b,L),[b,L]),Q=v.useMemo(()=>Te(j),[j]),Z=v.useMemo(()=>{const o={};return $==null||$.forEach(y=>{var S;(o[S=y.date]??(o[S]=[])).push(y)}),Object.values(o).forEach(y=>y.sort((S,X)=>le(S).localeCompare(le(X)))),o},[$]),ee=v.useMemo(()=>{const o=[];for(let y=0;y<_.length;y+=7)o.push(_.slice(y,y+7));return o},[_]),{todoSegs:me,todoLanesByDate:ue}=v.useMemo(()=>Fe(N,_),[N,_]),te=F(E()),W=v.useMemo(()=>{const o={};return _.forEach((y,S)=>{o[F(y.date)]=S}),o},[_]),se=`${b}-${String(L+1).padStart(2,"0")}-01`;v.useEffect(()=>{if(!T||W[T]!==void 0)return;const o=te;D(W[o]!==void 0&&o.startsWith(se.slice(0,8))?o:se)},[b,L]);const he=o=>{D(y=>y===o?null:o)},ne=v.useMemo(()=>He(N,$,W,b,L),[N,$,b,L,W]),ae=v.useMemo(()=>Ae(ee,g,ne),[ee,g,ne]);return e.jsxs("div",{className:"calendar-container",children:[e.jsxs("div",{className:"calendar",children:[e.jsx(we,{isPreview:d,year:b,month:L,viewMode:g,loading:m,onViewModeChange:M,onToday:()=>h(E()),onPrevMonth:()=>h(x.subtract(1,"month")),onNextMonth:()=>h(x.add(1,"month"))}),e.jsx("div",{className:"week-row",children:Le.map(o=>e.jsx("div",{className:"week-cell",children:o},o))}),e.jsx("div",{className:"day-grid",children:ae.length===0?e.jsx("div",{className:"calendar-empty",children:e.jsx(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE,description:"本月暂无待办和日程"})}):ae.map(({week:o,rowIndex:y})=>e.jsxs("div",{className:"day-week",children:[o.map(({date:S,inMonth:X})=>{const B=F(S),re=S.day(),fe=re===0||re===6;return e.jsx(De,{dateStr:B,day:S.date(),inMonth:X,isToday:B===te,isWeekend:fe,holiday:Q[B],todoLanes:ue[B]??0,schedules:Z[B]??[],onEditSchedule:z,icons:p,selected:T===B,onSelect:he},B)}),e.jsx(be,{segs:me.filter(S=>S.weekRow===y),onEditTodo:q})]},y))})]}),T&&e.jsx(Ye,{dateStr:T,holiday:Q[T],todos:N==null?void 0:N.filter(o=>o.start<=T&&T<=o.end),schedules:Z[T]??[],onEditTodo:q,onEditSchedule:o=>z(o),onAddTodo:()=>K(T),onAddSchedule:()=>G(T),isPreview:d,icons:p}),e.jsx(Me,{open:w.open,editing:w.editing,initialStart:w.initialStart,initialEnd:w.initialEnd,onClose:()=>Y({open:!1,editing:null}),onSave:k,onDelete:A}),e.jsx(Ne,{open:H.open,editing:H.editing,initialDate:H.initialDate,icons:p||[],onClose:()=>R({open:!1,editing:null}),onSave:C,onDelete:P})]})}exports.Calendar=Oe;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* 消费方需同时引入样式:import 'remons-calendar/style.css';
|
|
5
5
|
*/
|
|
6
6
|
export { Calendar } from './components/Calendar';
|
|
7
|
-
export type { CalendarProps } from './components/Calendar';
|
|
7
|
+
export type { CalendarProps, IconItem } from './components/Calendar';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC"}
|