@calenderjs/react 0.3.1 → 0.4.0
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/LICENSE +21 -0
- package/dist/Calendar.d.ts +79 -0
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/index.cjs +118 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +118 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CalenderJS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/Calendar.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ declare global {
|
|
|
7
7
|
"wsx-calendar": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
|
|
8
8
|
view?: "month" | "week" | "day";
|
|
9
9
|
date?: string;
|
|
10
|
+
mode?: "readonly" | "editable";
|
|
10
11
|
}, HTMLElement> & {
|
|
11
12
|
events?: Event[];
|
|
12
13
|
user?: User;
|
|
@@ -34,6 +35,15 @@ export interface CalendarProps {
|
|
|
34
35
|
* 当前用户
|
|
35
36
|
*/
|
|
36
37
|
user?: User;
|
|
38
|
+
/**
|
|
39
|
+
* Event DSL 定义(文本或 AST)
|
|
40
|
+
*/
|
|
41
|
+
eventTypeDefinitions?: string | any;
|
|
42
|
+
/**
|
|
43
|
+
* 编辑模式(readonly | editable,默认 editable)
|
|
44
|
+
* readonly 时短路所有拖拽/resize/keyboard 更新请求
|
|
45
|
+
*/
|
|
46
|
+
mode?: "readonly" | "editable";
|
|
37
47
|
/**
|
|
38
48
|
* 日期变化时的回调
|
|
39
49
|
*/
|
|
@@ -52,12 +62,63 @@ export interface CalendarProps {
|
|
|
52
62
|
onEventClick?: (event: CustomEvent<{
|
|
53
63
|
event: Event;
|
|
54
64
|
}>) => void;
|
|
65
|
+
/**
|
|
66
|
+
* 请求编辑事件时的回调(双击,或聚焦后按 Enter/Space)
|
|
67
|
+
*/
|
|
68
|
+
onEventEditRequest?: (event: CustomEvent<{
|
|
69
|
+
event: Event;
|
|
70
|
+
}>) => void;
|
|
55
71
|
/**
|
|
56
72
|
* 日期双击时的回调
|
|
57
73
|
*/
|
|
58
74
|
onDateDoubleClick?: (event: CustomEvent<{
|
|
59
75
|
date: Date;
|
|
60
76
|
}>) => void;
|
|
77
|
+
/**
|
|
78
|
+
* 事件创建回调
|
|
79
|
+
*/
|
|
80
|
+
onEventCreate?: (event: CustomEvent<{
|
|
81
|
+
event: Event;
|
|
82
|
+
}>) => void;
|
|
83
|
+
/**
|
|
84
|
+
* 事件更新回调
|
|
85
|
+
*/
|
|
86
|
+
onEventUpdate?: (event: CustomEvent<{
|
|
87
|
+
event: Event;
|
|
88
|
+
}>) => void;
|
|
89
|
+
/**
|
|
90
|
+
* 事件更新被权限拒绝时的回调
|
|
91
|
+
*/
|
|
92
|
+
onEventUpdateDenied?: (event: CustomEvent<{
|
|
93
|
+
event: Event;
|
|
94
|
+
}>) => void;
|
|
95
|
+
/**
|
|
96
|
+
* 事件更新未通过 DSL 校验时的回调
|
|
97
|
+
*/
|
|
98
|
+
onEventUpdateError?: (event: CustomEvent<{
|
|
99
|
+
event: Event;
|
|
100
|
+
errors: string[];
|
|
101
|
+
}>) => void;
|
|
102
|
+
/**
|
|
103
|
+
* 事件删除回调
|
|
104
|
+
*/
|
|
105
|
+
onEventDelete?: (event: CustomEvent<{
|
|
106
|
+
event: Event;
|
|
107
|
+
}>) => void;
|
|
108
|
+
/**
|
|
109
|
+
* 动作被权限拒绝时的回调 (RFC-0018)
|
|
110
|
+
*/
|
|
111
|
+
onEventActionDenied?: (event: CustomEvent<{
|
|
112
|
+
action: "edit" | "delete";
|
|
113
|
+
event: Event;
|
|
114
|
+
}>) => void;
|
|
115
|
+
/**
|
|
116
|
+
* 时间槽点击回调
|
|
117
|
+
*/
|
|
118
|
+
onSlotClick?: (event: CustomEvent<{
|
|
119
|
+
date: Date;
|
|
120
|
+
hour: number;
|
|
121
|
+
}>) => void;
|
|
61
122
|
/**
|
|
62
123
|
* 其他 HTML 属性
|
|
63
124
|
*/
|
|
@@ -85,6 +146,24 @@ export interface CalendarRef {
|
|
|
85
146
|
* 跳转到今天
|
|
86
147
|
*/
|
|
87
148
|
goToToday: () => void;
|
|
149
|
+
/**
|
|
150
|
+
* 获取所有事件
|
|
151
|
+
*/
|
|
152
|
+
getEvents: () => Event[];
|
|
153
|
+
/**
|
|
154
|
+
* 获取当前 Event DSL / 类型定义
|
|
155
|
+
*/
|
|
156
|
+
getEventDSL: () => string | any | null;
|
|
157
|
+
/**
|
|
158
|
+
* 手动添加事件
|
|
159
|
+
*/
|
|
160
|
+
addEvent: (event: Event) => boolean;
|
|
161
|
+
/**
|
|
162
|
+
* 提议更新事件;成功只表示组件已派发 event-update
|
|
163
|
+
*/
|
|
164
|
+
proposeEventUpdate: (event: Event) => boolean;
|
|
165
|
+
/** 查询底层 Calendar 对事件动作的当前权限 */
|
|
166
|
+
canPerformAction: (action: string, event: Event) => boolean;
|
|
88
167
|
}
|
|
89
168
|
/**
|
|
90
169
|
* Calendar React 组件
|
package/dist/Calendar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../src/Calendar.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAa7C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,cAAc,EAAE,KAAK,CAAC,iBAAiB,CACrC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,GAAG;gBAClC,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;gBAChC,IAAI,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../src/Calendar.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAa7C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,cAAc,EAAE,KAAK,CAAC,iBAAiB,CACrC,KAAK,CAAC,cAAc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Aa,CAAC;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,UAAU,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC;IAElD;;OAEG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,KAAK,IAAI,CAAC;IAEvC;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB;;OAEG;IACH,SAAS,EAAE,MAAM,KAAK,EAAE,CAAC;IAEzB;;OAEG;IACH,WAAW,EAAE,MAAM,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC;IAEvC;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IAEpC;;OAEG;IACH,kBAAkB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IAE9C,+BAA+B;IAC/B,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;CAC7D;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,gGAwRpB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -37,10 +37,20 @@ const Calendar = react.forwardRef(
|
|
|
37
37
|
date,
|
|
38
38
|
events,
|
|
39
39
|
user,
|
|
40
|
+
eventTypeDefinitions,
|
|
41
|
+
mode,
|
|
40
42
|
onDateChange,
|
|
41
43
|
onViewChange,
|
|
42
44
|
onEventClick,
|
|
45
|
+
onEventEditRequest,
|
|
43
46
|
onDateDoubleClick,
|
|
47
|
+
onEventCreate,
|
|
48
|
+
onEventUpdate,
|
|
49
|
+
onEventUpdateDenied,
|
|
50
|
+
onEventUpdateError,
|
|
51
|
+
onEventDelete,
|
|
52
|
+
onEventActionDenied,
|
|
53
|
+
onSlotClick,
|
|
44
54
|
className,
|
|
45
55
|
style,
|
|
46
56
|
...rest
|
|
@@ -68,10 +78,38 @@ const Calendar = react.forwardRef(
|
|
|
68
78
|
if (calendarRef.current) {
|
|
69
79
|
calendarRef.current.date = /* @__PURE__ */ new Date();
|
|
70
80
|
}
|
|
81
|
+
},
|
|
82
|
+
getEvents: () => {
|
|
83
|
+
if (calendarRef.current && typeof calendarRef.current.getEvents === "function") {
|
|
84
|
+
return calendarRef.current.getEvents();
|
|
85
|
+
}
|
|
86
|
+
return calendarRef.current?.events || [];
|
|
87
|
+
},
|
|
88
|
+
getEventDSL: () => {
|
|
89
|
+
if (calendarRef.current && typeof calendarRef.current.getEventDSL === "function") {
|
|
90
|
+
return calendarRef.current.getEventDSL();
|
|
91
|
+
}
|
|
92
|
+
return calendarRef.current?.eventTypeDefinitions ?? calendarRef.current?.eventDSL ?? null;
|
|
93
|
+
},
|
|
94
|
+
addEvent: (newEvent) => {
|
|
95
|
+
if (calendarRef.current && typeof calendarRef.current.addEvent === "function") {
|
|
96
|
+
return calendarRef.current.addEvent(newEvent);
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
},
|
|
100
|
+
proposeEventUpdate: (updatedEvent) => {
|
|
101
|
+
const element = calendarRef.current;
|
|
102
|
+
if (typeof element?.proposeEventUpdate !== "function") return false;
|
|
103
|
+
return element.proposeEventUpdate(updatedEvent);
|
|
104
|
+
},
|
|
105
|
+
canPerformAction: (action, event) => {
|
|
106
|
+
const element = calendarRef.current;
|
|
107
|
+
if (typeof element?.canPerformAction !== "function") return false;
|
|
108
|
+
return element.canPerformAction(action, event);
|
|
71
109
|
}
|
|
72
110
|
}));
|
|
73
111
|
react.useEffect(() => {
|
|
74
|
-
if (!calendarRef.current) return;
|
|
112
|
+
if (!isClient || !calendarRef.current) return;
|
|
75
113
|
const element = calendarRef.current;
|
|
76
114
|
if (view !== void 0) {
|
|
77
115
|
element.view = view;
|
|
@@ -85,9 +123,15 @@ const Calendar = react.forwardRef(
|
|
|
85
123
|
if (user !== void 0) {
|
|
86
124
|
element.user = user;
|
|
87
125
|
}
|
|
88
|
-
|
|
126
|
+
if (eventTypeDefinitions !== void 0) {
|
|
127
|
+
element.eventTypeDefinitions = eventTypeDefinitions;
|
|
128
|
+
}
|
|
129
|
+
if (mode !== void 0) {
|
|
130
|
+
element.mode = mode;
|
|
131
|
+
}
|
|
132
|
+
}, [isClient, view, date, events, user, eventTypeDefinitions, mode]);
|
|
89
133
|
react.useEffect(() => {
|
|
90
|
-
if (!calendarRef.current) return;
|
|
134
|
+
if (!isClient || !calendarRef.current) return;
|
|
91
135
|
const element = calendarRef.current;
|
|
92
136
|
const handleDateChange = (e) => {
|
|
93
137
|
onDateChange?.(e);
|
|
@@ -98,20 +142,90 @@ const Calendar = react.forwardRef(
|
|
|
98
142
|
const handleEventClick = (e) => {
|
|
99
143
|
onEventClick?.(e);
|
|
100
144
|
};
|
|
145
|
+
const handleEventEditRequest = (e) => {
|
|
146
|
+
onEventEditRequest?.(e);
|
|
147
|
+
};
|
|
101
148
|
const handleDateDoubleClick = (e) => {
|
|
102
149
|
onDateDoubleClick?.(e);
|
|
103
150
|
};
|
|
151
|
+
const handleEventCreate = (e) => {
|
|
152
|
+
onEventCreate?.(e);
|
|
153
|
+
};
|
|
154
|
+
const handleEventUpdate = (e) => {
|
|
155
|
+
onEventUpdate?.(e);
|
|
156
|
+
};
|
|
157
|
+
const handleEventUpdateDenied = (e) => {
|
|
158
|
+
onEventUpdateDenied?.(e);
|
|
159
|
+
};
|
|
160
|
+
const handleEventUpdateError = (e) => {
|
|
161
|
+
onEventUpdateError?.(
|
|
162
|
+
e
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
const handleEventDelete = (e) => {
|
|
166
|
+
onEventDelete?.(e);
|
|
167
|
+
};
|
|
168
|
+
const handleEventActionDenied = (e) => {
|
|
169
|
+
onEventActionDenied?.(
|
|
170
|
+
e
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
const handleSlotClick = (e) => {
|
|
174
|
+
onSlotClick?.(e);
|
|
175
|
+
};
|
|
104
176
|
element.addEventListener("date-change", handleDateChange);
|
|
105
177
|
element.addEventListener("view-change", handleViewChange);
|
|
106
178
|
element.addEventListener("event-click", handleEventClick);
|
|
179
|
+
element.addEventListener("event-edit-request", handleEventEditRequest);
|
|
107
180
|
element.addEventListener("date-double-click", handleDateDoubleClick);
|
|
181
|
+
element.addEventListener("event-create", handleEventCreate);
|
|
182
|
+
element.addEventListener("event-update", handleEventUpdate);
|
|
183
|
+
element.addEventListener("event-update-denied", handleEventUpdateDenied);
|
|
184
|
+
element.addEventListener("event-update-error", handleEventUpdateError);
|
|
185
|
+
element.addEventListener("event-delete", handleEventDelete);
|
|
186
|
+
element.addEventListener("event-action-denied", handleEventActionDenied);
|
|
187
|
+
element.addEventListener("slot-click", handleSlotClick);
|
|
108
188
|
return () => {
|
|
109
189
|
element.removeEventListener("date-change", handleDateChange);
|
|
110
190
|
element.removeEventListener("view-change", handleViewChange);
|
|
111
191
|
element.removeEventListener("event-click", handleEventClick);
|
|
192
|
+
element.removeEventListener(
|
|
193
|
+
"event-edit-request",
|
|
194
|
+
handleEventEditRequest
|
|
195
|
+
);
|
|
112
196
|
element.removeEventListener("date-double-click", handleDateDoubleClick);
|
|
197
|
+
element.removeEventListener("event-create", handleEventCreate);
|
|
198
|
+
element.removeEventListener("event-update", handleEventUpdate);
|
|
199
|
+
element.removeEventListener(
|
|
200
|
+
"event-update-denied",
|
|
201
|
+
handleEventUpdateDenied
|
|
202
|
+
);
|
|
203
|
+
element.removeEventListener(
|
|
204
|
+
"event-update-error",
|
|
205
|
+
handleEventUpdateError
|
|
206
|
+
);
|
|
207
|
+
element.removeEventListener("event-delete", handleEventDelete);
|
|
208
|
+
element.removeEventListener(
|
|
209
|
+
"event-action-denied",
|
|
210
|
+
handleEventActionDenied
|
|
211
|
+
);
|
|
212
|
+
element.removeEventListener("slot-click", handleSlotClick);
|
|
113
213
|
};
|
|
114
|
-
}, [
|
|
214
|
+
}, [
|
|
215
|
+
isClient,
|
|
216
|
+
onDateChange,
|
|
217
|
+
onViewChange,
|
|
218
|
+
onEventClick,
|
|
219
|
+
onEventEditRequest,
|
|
220
|
+
onDateDoubleClick,
|
|
221
|
+
onEventCreate,
|
|
222
|
+
onEventUpdate,
|
|
223
|
+
onEventUpdateDenied,
|
|
224
|
+
onEventUpdateError,
|
|
225
|
+
onEventDelete,
|
|
226
|
+
onEventActionDenied,
|
|
227
|
+
onSlotClick
|
|
228
|
+
]);
|
|
115
229
|
if (!isClient) {
|
|
116
230
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
117
231
|
"div",
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/Calendar.tsx","../src/components/ResizableSplitter.tsx"],"sourcesContent":["/**\n * React wrapper for wsx-calendar Web Component\n *\n * 使用方式:\n * ```tsx\n * import { Calendar } from '@calenderjs/react';\n *\n * <Calendar\n * view=\"month\"\n * date=\"2024-12-30\"\n * onDateChange={(e) => console.log('Date changed:', e.detail.date)}\n * onViewChange={(e) => console.log('View changed:', e.detail.view)}\n * />\n * ```\n */\n\nimport React, {\n useRef,\n useEffect,\n useImperativeHandle,\n forwardRef,\n useState,\n} from \"react\";\nimport type { Event } from \"@calenderjs/event-model\";\nimport type { User } from \"@calenderjs/core\";\n\n// 延迟加载 Web Component,只在客户端注册\n// 避免在服务器端执行(HTMLElement 不存在)\nlet calendarRegistered = false;\nconst registerCalendar = () => {\n if (typeof window !== \"undefined\" && !calendarRegistered) {\n import(\"@calenderjs/calendar\");\n calendarRegistered = true;\n }\n};\n\n// 声明 wsx-calendar 元素类型\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n \"wsx-calendar\": React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement> & {\n view?: \"month\" | \"week\" | \"day\";\n date?: string;\n },\n HTMLElement\n > & {\n events?: Event[];\n user?: User;\n };\n }\n }\n}\n\n/**\n * Calendar 组件的属性\n */\nexport interface CalendarProps {\n /**\n * 初始视图(month | week | day)\n */\n view?: \"month\" | \"week\" | \"day\";\n\n /**\n * 初始日期(ISO 8601 字符串或 Date 对象)\n */\n date?: string | Date;\n\n /**\n * 事件列表(数据模型)\n */\n events?: Event[];\n\n /**\n * 当前用户\n */\n user?: User;\n\n /**\n * 日期变化时的回调\n */\n onDateChange?: (event: CustomEvent<{ date: Date }>) => void;\n\n /**\n * 视图切换时的回调\n */\n onViewChange?: (\n event: CustomEvent<{ view: \"month\" | \"week\" | \"day\" }>,\n ) => void;\n\n /**\n * 事件点击时的回调\n */\n onEventClick?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 日期双击时的回调\n */\n onDateDoubleClick?: (event: CustomEvent<{ date: Date }>) => void;\n\n /**\n * 其他 HTML 属性\n */\n className?: string;\n style?: React.CSSProperties;\n [key: string]: any;\n}\n\n/**\n * Calendar 组件的引用类型\n */\nexport interface CalendarRef {\n /**\n * 获取底层的 Web Component 实例\n */\n getElement: () => HTMLElement | null;\n\n /**\n * 设置当前视图\n */\n setView: (view: \"month\" | \"week\" | \"day\") => void;\n\n /**\n * 设置当前日期\n */\n setDate: (date: Date | string) => void;\n\n /**\n * 跳转到今天\n */\n goToToday: () => void;\n}\n\n/**\n * Calendar React 组件\n */\nexport const Calendar = forwardRef<CalendarRef, CalendarProps>(\n (\n {\n view = \"month\",\n date,\n events,\n user,\n onDateChange,\n onViewChange,\n onEventClick,\n onDateDoubleClick,\n className,\n style,\n ...rest\n }: CalendarProps,\n ref: React.ForwardedRef<CalendarRef>,\n ) => {\n const calendarRef = useRef<\n | (HTMLElement & {\n view?: \"month\" | \"week\" | \"day\";\n date?: Date | string;\n events?: Event[];\n user?: User;\n })\n | null\n >(null);\n const [isClient, setIsClient] = useState(false);\n\n // 只在客户端注册 Web Component\n useEffect(() => {\n setIsClient(true);\n registerCalendar();\n }, []);\n\n // 暴露方法给父组件\n useImperativeHandle(ref, () => ({\n getElement: () => calendarRef.current,\n setView: (newView: \"month\" | \"week\" | \"day\") => {\n if (calendarRef.current) {\n (calendarRef.current as any).view = newView;\n }\n },\n setDate: (newDate: Date | string) => {\n if (calendarRef.current) {\n const date =\n typeof newDate === \"string\" ? new Date(newDate) : newDate;\n (calendarRef.current as any).date = date;\n }\n },\n goToToday: () => {\n if (calendarRef.current) {\n (calendarRef.current as any).date = new Date();\n }\n },\n }));\n\n // 处理属性变化\n useEffect(() => {\n if (!calendarRef.current) return;\n\n const element = calendarRef.current as any;\n\n // 所有属性都通过 property 设置\n if (view !== undefined) {\n element.view = view;\n }\n\n if (date !== undefined) {\n element.date = date instanceof Date ? date : new Date(date);\n }\n\n if (events !== undefined) {\n element.events = events;\n }\n\n if (user !== undefined) {\n element.user = user;\n }\n }, [view, date, events, user]);\n\n // 绑定事件监听器\n useEffect(() => {\n if (!calendarRef.current) return;\n\n const element = calendarRef.current;\n\n const handleDateChange = (e: globalThis.Event) => {\n onDateChange?.(e as CustomEvent<{ date: Date }>);\n };\n\n const handleViewChange = (e: globalThis.Event) => {\n onViewChange?.(e as CustomEvent<{ view: \"month\" | \"week\" | \"day\" }>);\n };\n\n const handleEventClick = (e: globalThis.Event) => {\n onEventClick?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleDateDoubleClick = (e: globalThis.Event) => {\n onDateDoubleClick?.(e as CustomEvent<{ date: Date }>);\n };\n\n element.addEventListener(\"date-change\", handleDateChange);\n element.addEventListener(\"view-change\", handleViewChange);\n element.addEventListener(\"event-click\", handleEventClick);\n element.addEventListener(\"date-double-click\", handleDateDoubleClick);\n\n return () => {\n element.removeEventListener(\"date-change\", handleDateChange);\n element.removeEventListener(\"view-change\", handleViewChange);\n element.removeEventListener(\"event-click\", handleEventClick);\n element.removeEventListener(\"date-double-click\", handleDateDoubleClick);\n };\n }, [onDateChange, onViewChange, onEventClick, onDateDoubleClick]);\n\n // 服务器端渲染时返回占位符\n if (!isClient) {\n return (\n <div\n className={className}\n style={{\n ...style,\n minHeight: \"600px\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n {...rest}\n >\n <div>加载中...</div>\n </div>\n );\n }\n\n return (\n <wsx-calendar\n ref={calendarRef}\n className={className}\n style={style}\n {...rest}\n />\n );\n },\n);\n\nCalendar.displayName = \"Calendar\";\n","\"use client\";\n\nimport { useState, useRef, useEffect, useCallback } from \"react\";\n\nexport interface ResizableSplitterProps {\n /** 左侧面板内容 */\n left: React.ReactNode;\n /** 右侧面板内容 */\n right: React.ReactNode;\n /** 初始左侧面板宽度(百分比,0-100) */\n initialLeftWidth?: number;\n /** 左侧面板最小宽度(百分比) */\n minLeftWidth?: number;\n /** 左侧面板最大宽度(百分比) */\n maxLeftWidth?: number;\n /** 自定义 CSS 类名 */\n className?: string;\n}\n\n/**\n * ResizableSplitter - 可调整大小的分割面板组件\n *\n * 提供一个可拖拽的分割器,允许用户调整左右两个面板的宽度。\n *\n * @example\n * ```tsx\n * import { ResizableSplitter } from '@calenderjs/react';\n *\n * function App() {\n * return (\n * <ResizableSplitter\n * left={<div>左侧内容</div>}\n * right={<div>右侧内容</div>}\n * initialLeftWidth={40}\n * minLeftWidth={20}\n * maxLeftWidth={80}\n * />\n * );\n * }\n * ```\n */\nexport default function ResizableSplitter({\n left,\n right,\n initialLeftWidth = 40,\n minLeftWidth = 20,\n maxLeftWidth = 80,\n className = \"\",\n}: ResizableSplitterProps) {\n const [leftWidth, setLeftWidth] = useState(initialLeftWidth);\n const [isDragging, setIsDragging] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const splitterRef = useRef<HTMLDivElement>(null);\n\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n setIsDragging(true);\n }, []);\n\n const handleMouseMove = useCallback(\n (e: MouseEvent) => {\n if (!isDragging || !containerRef.current) return;\n\n const containerRect = containerRef.current.getBoundingClientRect();\n const newLeftWidth =\n ((e.clientX - containerRect.left) / containerRect.width) * 100;\n\n // 限制在最小和最大宽度之间\n const clampedWidth = Math.max(\n minLeftWidth,\n Math.min(maxLeftWidth, newLeftWidth),\n );\n\n setLeftWidth(clampedWidth);\n },\n [isDragging, minLeftWidth, maxLeftWidth],\n );\n\n const handleMouseUp = useCallback(() => {\n setIsDragging(false);\n }, []);\n\n useEffect(() => {\n if (isDragging) {\n document.addEventListener(\"mousemove\", handleMouseMove);\n document.addEventListener(\"mouseup\", handleMouseUp);\n document.body.style.cursor = \"col-resize\";\n document.body.style.userSelect = \"none\";\n\n return () => {\n document.removeEventListener(\"mousemove\", handleMouseMove);\n document.removeEventListener(\"mouseup\", handleMouseUp);\n document.body.style.cursor = \"\";\n document.body.style.userSelect = \"\";\n };\n }\n }, [isDragging, handleMouseMove, handleMouseUp]);\n\n return (\n <div\n ref={containerRef}\n className={`resizable-splitter ${className}`}\n style={{\n display: \"flex\",\n width: \"100%\",\n height: \"100%\",\n position: \"relative\",\n }}\n >\n {/* Left Panel */}\n <div\n style={{\n width: `${leftWidth}%`,\n height: \"100%\",\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n }}\n >\n {left}\n </div>\n\n {/* Splitter */}\n <div\n ref={splitterRef}\n onMouseDown={handleMouseDown}\n style={{\n width: \"var(--resizable-splitter-width, 4px)\",\n height: \"100%\",\n cursor: \"col-resize\",\n backgroundColor: \"var(--resizable-splitter-bg-color, #ddd)\",\n position: \"relative\",\n flexShrink: 0,\n transition: isDragging\n ? \"none\"\n : \"var(--resizable-splitter-transition, background-color 0.2s)\",\n }}\n onMouseEnter={(e) => {\n if (!isDragging) {\n e.currentTarget.style.backgroundColor =\n \"var(--resizable-splitter-hover-bg-color, #bbb)\";\n }\n }}\n onMouseLeave={(e) => {\n if (!isDragging) {\n e.currentTarget.style.backgroundColor =\n \"var(--resizable-splitter-bg-color, #ddd)\";\n }\n }}\n >\n {/* Splitter Handle */}\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n width: \"var(--resizable-splitter-handle-width, 20px)\",\n height: \"var(--resizable-splitter-handle-height, 40px)\",\n borderRadius: \"var(--resizable-splitter-handle-border-radius, 4px)\",\n backgroundColor:\n \"var(--resizable-splitter-handle-bg-color, rgba(0,0,0,0.1))\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"var(--resizable-splitter-dot-gap, 2px)\",\n }}\n >\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n </div>\n </div>\n </div>\n\n {/* Right Panel */}\n <div\n style={{\n flex: 1,\n height: \"100%\",\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n }}\n >\n {right}\n </div>\n </div>\n );\n}\n"],"names":["forwardRef","useRef","useState","useEffect","useImperativeHandle","date","jsx","useCallback","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAI,qBAAqB;AACzB,MAAM,mBAAmB,MAAM;AAC7B,MAAI,OAAO,WAAW,eAAe,CAAC,oBAAoB;AACxD,WAAO,sBAAsB;AAC7B,yBAAqB;AAAA,EACvB;AACF;AAsGO,MAAM,WAAWA,MAAAA;AAAAA,EACtB,CACE;AAAA,I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AC;AAAA,kBAAA;AAAA,oBACC,OAAO;AAAA,sBACL,SAAS;AAAA,sBACT,eAAe;AAAA,sBACf,KAAK;AAAA,oBAAA;AAAA,oBAGP,UAAA;AAAA,sBAAAF,2BAAAA;AAAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,OAAO;AAAA,4BACL,OAAO;AAAA,4BACP,QAAQ;AAAA,4BACR,cAAc;AAAA,4BACd,iBAAiB;AAAA,0BAAA;AAAA,wBACnB;AAAA,sBAAA;AAAA,sBAEFA,2BAAAA;AAAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,OAAO;AAAA,4BACL,OAAO;AAAA,4BACP,QAAQ;AAAA,4BACR,cAAc;AAAA,4BACd,iBAAiB;AAAA,0BAAA;AAAA,wBACnB;AAAA,sBAAA;AAAA,sBAEFA,2BAAAA;AAAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,OAAO;AAAA,4BACL,OAAO;AAAA,4BACP,QAAQ;AAAA,4BACR,cAAc;AAAA,4BACd,iBAAiB;AAAA,0BAAA;AAAA,wBACnB;AAAA,sBAAA;AAAA,oBACF;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,QAIFA,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,MAAM;AAAA,cACN,QAAQ;AAAA,cACR,UAAU;AAAA,cACV,SAAS;AAAA,cACT,eAAe;AAAA,YAAA;AAAA,YAGhB,UAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAGN;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/Calendar.tsx","../src/components/ResizableSplitter.tsx"],"sourcesContent":["/**\n * React wrapper for wsx-calendar Web Component\n *\n * 使用方式:\n * ```tsx\n * import { Calendar } from '@calenderjs/react';\n *\n * <Calendar\n * view=\"month\"\n * date=\"2024-12-30\"\n * onDateChange={(e) => console.log('Date changed:', e.detail.date)}\n * onViewChange={(e) => console.log('View changed:', e.detail.view)}\n * />\n * ```\n */\n\nimport React, {\n useRef,\n useEffect,\n useImperativeHandle,\n forwardRef,\n useState,\n} from \"react\";\nimport type { Event } from \"@calenderjs/event-model\";\nimport type { User } from \"@calenderjs/core\";\n\n// 延迟加载 Web Component,只在客户端注册\n// 避免在服务器端执行(HTMLElement 不存在)\nlet calendarRegistered = false;\nconst registerCalendar = () => {\n if (typeof window !== \"undefined\" && !calendarRegistered) {\n import(\"@calenderjs/calendar\");\n calendarRegistered = true;\n }\n};\n\n// 声明 wsx-calendar 元素类型\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n \"wsx-calendar\": React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement> & {\n view?: \"month\" | \"week\" | \"day\";\n date?: string;\n mode?: \"readonly\" | \"editable\";\n },\n HTMLElement\n > & {\n events?: Event[];\n user?: User;\n };\n }\n }\n}\n\n/**\n * Calendar 组件的属性\n */\nexport interface CalendarProps {\n /**\n * 初始视图(month | week | day)\n */\n view?: \"month\" | \"week\" | \"day\";\n\n /**\n * 初始日期(ISO 8601 字符串或 Date 对象)\n */\n date?: string | Date;\n\n /**\n * 事件列表(数据模型)\n */\n events?: Event[];\n\n /**\n * 当前用户\n */\n user?: User;\n\n /**\n * Event DSL 定义(文本或 AST)\n */\n eventTypeDefinitions?: string | any;\n\n /**\n * 编辑模式(readonly | editable,默认 editable)\n * readonly 时短路所有拖拽/resize/keyboard 更新请求\n */\n mode?: \"readonly\" | \"editable\";\n\n /**\n * 日期变化时的回调\n */\n onDateChange?: (event: CustomEvent<{ date: Date }>) => void;\n\n /**\n * 视图切换时的回调\n */\n onViewChange?: (\n event: CustomEvent<{ view: \"month\" | \"week\" | \"day\" }>,\n ) => void;\n\n /**\n * 事件点击时的回调\n */\n onEventClick?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 请求编辑事件时的回调(双击,或聚焦后按 Enter/Space)\n */\n onEventEditRequest?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 日期双击时的回调\n */\n onDateDoubleClick?: (event: CustomEvent<{ date: Date }>) => void;\n\n /**\n * 事件创建回调\n */\n onEventCreate?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 事件更新回调\n */\n onEventUpdate?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 事件更新被权限拒绝时的回调\n */\n onEventUpdateDenied?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 事件更新未通过 DSL 校验时的回调\n */\n onEventUpdateError?: (\n event: CustomEvent<{ event: Event; errors: string[] }>,\n ) => void;\n\n /**\n * 事件删除回调\n */\n onEventDelete?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 动作被权限拒绝时的回调 (RFC-0018)\n */\n onEventActionDenied?: (\n event: CustomEvent<{ action: \"edit\" | \"delete\"; event: Event }>,\n ) => void;\n\n /**\n * 时间槽点击回调\n */\n onSlotClick?: (event: CustomEvent<{ date: Date; hour: number }>) => void;\n\n /**\n * 其他 HTML 属性\n */\n className?: string;\n style?: React.CSSProperties;\n [key: string]: any;\n}\n\n/**\n * Calendar 组件的引用类型\n */\nexport interface CalendarRef {\n /**\n * 获取底层的 Web Component 实例\n */\n getElement: () => HTMLElement | null;\n\n /**\n * 设置当前视图\n */\n setView: (view: \"month\" | \"week\" | \"day\") => void;\n\n /**\n * 设置当前日期\n */\n setDate: (date: Date | string) => void;\n\n /**\n * 跳转到今天\n */\n goToToday: () => void;\n\n /**\n * 获取所有事件\n */\n getEvents: () => Event[];\n\n /**\n * 获取当前 Event DSL / 类型定义\n */\n getEventDSL: () => string | any | null;\n\n /**\n * 手动添加事件\n */\n addEvent: (event: Event) => boolean;\n\n /**\n * 提议更新事件;成功只表示组件已派发 event-update\n */\n proposeEventUpdate: (event: Event) => boolean;\n\n /** 查询底层 Calendar 对事件动作的当前权限 */\n canPerformAction: (action: string, event: Event) => boolean;\n}\n\n/**\n * Calendar React 组件\n */\nexport const Calendar = forwardRef<CalendarRef, CalendarProps>(\n (\n {\n view = \"month\",\n date,\n events,\n user,\n eventTypeDefinitions,\n mode,\n onDateChange,\n onViewChange,\n onEventClick,\n onEventEditRequest,\n onDateDoubleClick,\n onEventCreate,\n onEventUpdate,\n onEventUpdateDenied,\n onEventUpdateError,\n onEventDelete,\n onEventActionDenied,\n onSlotClick,\n className,\n style,\n ...rest\n }: CalendarProps,\n ref: React.ForwardedRef<CalendarRef>,\n ) => {\n const calendarRef = useRef<\n | (HTMLElement & {\n view?: \"month\" | \"week\" | \"day\";\n date?: Date | string;\n events?: Event[];\n user?: User;\n })\n | null\n >(null);\n const [isClient, setIsClient] = useState(false);\n\n // 只在客户端注册 Web Component\n useEffect(() => {\n setIsClient(true);\n registerCalendar();\n }, []);\n\n // 暴露方法给父组件\n useImperativeHandle(ref, () => ({\n getElement: () => calendarRef.current,\n setView: (newView: \"month\" | \"week\" | \"day\") => {\n if (calendarRef.current) {\n (calendarRef.current as any).view = newView;\n }\n },\n setDate: (newDate: Date | string) => {\n if (calendarRef.current) {\n const date =\n typeof newDate === \"string\" ? new Date(newDate) : newDate;\n (calendarRef.current as any).date = date;\n }\n },\n goToToday: () => {\n if (calendarRef.current) {\n (calendarRef.current as any).date = new Date();\n }\n },\n getEvents: () => {\n if (\n calendarRef.current &&\n typeof (calendarRef.current as any).getEvents === \"function\"\n ) {\n return (calendarRef.current as any).getEvents();\n }\n return (calendarRef.current as any)?.events || [];\n },\n getEventDSL: () => {\n if (\n calendarRef.current &&\n typeof (calendarRef.current as any).getEventDSL === \"function\"\n ) {\n return (calendarRef.current as any).getEventDSL();\n }\n return (\n (calendarRef.current as any)?.eventTypeDefinitions ??\n (calendarRef.current as any)?.eventDSL ??\n null\n );\n },\n addEvent: (newEvent: Event) => {\n if (\n calendarRef.current &&\n typeof (calendarRef.current as any).addEvent === \"function\"\n ) {\n return (calendarRef.current as any).addEvent(newEvent);\n }\n return false;\n },\n proposeEventUpdate: (updatedEvent: Event) => {\n const element = calendarRef.current as any;\n if (typeof element?.proposeEventUpdate !== \"function\") return false;\n return element.proposeEventUpdate(updatedEvent);\n },\n canPerformAction: (action: string, event: Event) => {\n const element = calendarRef.current as any;\n if (typeof element?.canPerformAction !== \"function\") return false;\n return element.canPerformAction(action, event);\n },\n }));\n\n // 处理属性变化。isClient 必须入依赖:占位阶段 ref 为空,客户端元素出现后需补写初始 props。\n useEffect(() => {\n if (!isClient || !calendarRef.current) return;\n\n const element = calendarRef.current as any;\n\n // 所有属性都通过 property 设置\n if (view !== undefined) {\n element.view = view;\n }\n\n if (date !== undefined) {\n element.date = date instanceof Date ? date : new Date(date);\n }\n\n if (events !== undefined) {\n element.events = events;\n }\n\n if (user !== undefined) {\n element.user = user;\n }\n\n if (eventTypeDefinitions !== undefined) {\n element.eventTypeDefinitions = eventTypeDefinitions;\n }\n\n if (mode !== undefined) {\n element.mode = mode;\n }\n }, [isClient, view, date, events, user, eventTypeDefinitions, mode]);\n\n // 绑定事件监听器。同 props:客户端 wsx-calendar 出现后再挂载,避免冷启动漏绑。\n useEffect(() => {\n if (!isClient || !calendarRef.current) return;\n\n const element = calendarRef.current;\n\n const handleDateChange = (e: globalThis.Event) => {\n onDateChange?.(e as CustomEvent<{ date: Date }>);\n };\n\n const handleViewChange = (e: globalThis.Event) => {\n onViewChange?.(e as CustomEvent<{ view: \"month\" | \"week\" | \"day\" }>);\n };\n\n const handleEventClick = (e: globalThis.Event) => {\n onEventClick?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleEventEditRequest = (e: globalThis.Event) => {\n onEventEditRequest?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleDateDoubleClick = (e: globalThis.Event) => {\n onDateDoubleClick?.(e as CustomEvent<{ date: Date }>);\n };\n\n const handleEventCreate = (e: globalThis.Event) => {\n onEventCreate?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleEventUpdate = (e: globalThis.Event) => {\n onEventUpdate?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleEventUpdateDenied = (e: globalThis.Event) => {\n onEventUpdateDenied?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleEventUpdateError = (e: globalThis.Event) => {\n onEventUpdateError?.(\n e as CustomEvent<{ event: Event; errors: string[] }>,\n );\n };\n\n const handleEventDelete = (e: globalThis.Event) => {\n onEventDelete?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleEventActionDenied = (e: globalThis.Event) => {\n onEventActionDenied?.(\n e as CustomEvent<{ action: \"edit\" | \"delete\"; event: Event }>,\n );\n };\n\n const handleSlotClick = (e: globalThis.Event) => {\n onSlotClick?.(e as CustomEvent<{ date: Date; hour: number }>);\n };\n\n element.addEventListener(\"date-change\", handleDateChange);\n element.addEventListener(\"view-change\", handleViewChange);\n element.addEventListener(\"event-click\", handleEventClick);\n element.addEventListener(\"event-edit-request\", handleEventEditRequest);\n element.addEventListener(\"date-double-click\", handleDateDoubleClick);\n element.addEventListener(\"event-create\", handleEventCreate);\n element.addEventListener(\"event-update\", handleEventUpdate);\n element.addEventListener(\"event-update-denied\", handleEventUpdateDenied);\n element.addEventListener(\"event-update-error\", handleEventUpdateError);\n element.addEventListener(\"event-delete\", handleEventDelete);\n element.addEventListener(\"event-action-denied\", handleEventActionDenied);\n element.addEventListener(\"slot-click\", handleSlotClick);\n\n return () => {\n element.removeEventListener(\"date-change\", handleDateChange);\n element.removeEventListener(\"view-change\", handleViewChange);\n element.removeEventListener(\"event-click\", handleEventClick);\n element.removeEventListener(\n \"event-edit-request\",\n handleEventEditRequest,\n );\n element.removeEventListener(\"date-double-click\", handleDateDoubleClick);\n element.removeEventListener(\"event-create\", handleEventCreate);\n element.removeEventListener(\"event-update\", handleEventUpdate);\n element.removeEventListener(\n \"event-update-denied\",\n handleEventUpdateDenied,\n );\n element.removeEventListener(\n \"event-update-error\",\n handleEventUpdateError,\n );\n element.removeEventListener(\"event-delete\", handleEventDelete);\n element.removeEventListener(\n \"event-action-denied\",\n handleEventActionDenied,\n );\n element.removeEventListener(\"slot-click\", handleSlotClick);\n };\n }, [\n isClient,\n onDateChange,\n onViewChange,\n onEventClick,\n onEventEditRequest,\n onDateDoubleClick,\n onEventCreate,\n onEventUpdate,\n onEventUpdateDenied,\n onEventUpdateError,\n onEventDelete,\n onEventActionDenied,\n onSlotClick,\n ]);\n\n // 服务器端渲染时返回占位符\n if (!isClient) {\n return (\n <div\n className={className}\n style={{\n ...style,\n minHeight: \"600px\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n {...rest}\n >\n <div>加载中...</div>\n </div>\n );\n }\n\n return (\n <wsx-calendar\n ref={calendarRef}\n className={className}\n style={style}\n {...rest}\n />\n );\n },\n);\n\nCalendar.displayName = \"Calendar\";\n","\"use client\";\n\nimport { useState, useRef, useEffect, useCallback } from \"react\";\n\nexport interface ResizableSplitterProps {\n /** 左侧面板内容 */\n left: React.ReactNode;\n /** 右侧面板内容 */\n right: React.ReactNode;\n /** 初始左侧面板宽度(百分比,0-100) */\n initialLeftWidth?: number;\n /** 左侧面板最小宽度(百分比) */\n minLeftWidth?: number;\n /** 左侧面板最大宽度(百分比) */\n maxLeftWidth?: number;\n /** 自定义 CSS 类名 */\n className?: string;\n}\n\n/**\n * ResizableSplitter - 可调整大小的分割面板组件\n *\n * 提供一个可拖拽的分割器,允许用户调整左右两个面板的宽度。\n *\n * @example\n * ```tsx\n * import { ResizableSplitter } from '@calenderjs/react';\n *\n * function App() {\n * return (\n * <ResizableSplitter\n * left={<div>左侧内容</div>}\n * right={<div>右侧内容</div>}\n * initialLeftWidth={40}\n * minLeftWidth={20}\n * maxLeftWidth={80}\n * />\n * );\n * }\n * ```\n */\nexport default function ResizableSplitter({\n left,\n right,\n initialLeftWidth = 40,\n minLeftWidth = 20,\n maxLeftWidth = 80,\n className = \"\",\n}: ResizableSplitterProps) {\n const [leftWidth, setLeftWidth] = useState(initialLeftWidth);\n const [isDragging, setIsDragging] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const splitterRef = useRef<HTMLDivElement>(null);\n\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n setIsDragging(true);\n }, []);\n\n const handleMouseMove = useCallback(\n (e: MouseEvent) => {\n if (!isDragging || !containerRef.current) return;\n\n const containerRect = containerRef.current.getBoundingClientRect();\n const newLeftWidth =\n ((e.clientX - containerRect.left) / containerRect.width) * 100;\n\n // 限制在最小和最大宽度之间\n const clampedWidth = Math.max(\n minLeftWidth,\n Math.min(maxLeftWidth, newLeftWidth),\n );\n\n setLeftWidth(clampedWidth);\n },\n [isDragging, minLeftWidth, maxLeftWidth],\n );\n\n const handleMouseUp = useCallback(() => {\n setIsDragging(false);\n }, []);\n\n useEffect(() => {\n if (isDragging) {\n document.addEventListener(\"mousemove\", handleMouseMove);\n document.addEventListener(\"mouseup\", handleMouseUp);\n document.body.style.cursor = \"col-resize\";\n document.body.style.userSelect = \"none\";\n\n return () => {\n document.removeEventListener(\"mousemove\", handleMouseMove);\n document.removeEventListener(\"mouseup\", handleMouseUp);\n document.body.style.cursor = \"\";\n document.body.style.userSelect = \"\";\n };\n }\n }, [isDragging, handleMouseMove, handleMouseUp]);\n\n return (\n <div\n ref={containerRef}\n className={`resizable-splitter ${className}`}\n style={{\n display: \"flex\",\n width: \"100%\",\n height: \"100%\",\n position: \"relative\",\n }}\n >\n {/* Left Panel */}\n <div\n style={{\n width: `${leftWidth}%`,\n height: \"100%\",\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n }}\n >\n {left}\n </div>\n\n {/* Splitter */}\n <div\n ref={splitterRef}\n onMouseDown={handleMouseDown}\n style={{\n width: \"var(--resizable-splitter-width, 4px)\",\n height: \"100%\",\n cursor: \"col-resize\",\n backgroundColor: \"var(--resizable-splitter-bg-color, #ddd)\",\n position: \"relative\",\n flexShrink: 0,\n transition: isDragging\n ? \"none\"\n : \"var(--resizable-splitter-transition, background-color 0.2s)\",\n }}\n onMouseEnter={(e) => {\n if (!isDragging) {\n e.currentTarget.style.backgroundColor =\n \"var(--resizable-splitter-hover-bg-color, #bbb)\";\n }\n }}\n onMouseLeave={(e) => {\n if (!isDragging) {\n e.currentTarget.style.backgroundColor =\n \"var(--resizable-splitter-bg-color, #ddd)\";\n }\n }}\n >\n {/* Splitter Handle */}\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n width: \"var(--resizable-splitter-handle-width, 20px)\",\n height: \"var(--resizable-splitter-handle-height, 40px)\",\n borderRadius: \"var(--resizable-splitter-handle-border-radius, 4px)\",\n backgroundColor:\n \"var(--resizable-splitter-handle-bg-color, rgba(0,0,0,0.1))\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"var(--resizable-splitter-dot-gap, 2px)\",\n }}\n >\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n </div>\n </div>\n </div>\n\n {/* Right Panel */}\n <div\n style={{\n flex: 1,\n height: \"100%\",\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n }}\n >\n {right}\n </div>\n </div>\n );\n}\n"],"names":["forwardRef","useRef","useState","useEffect","useImperativeHandle","date","jsx","useCallback","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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@@ const Calendar = forwardRef(
|
|
|
13
13
|
date,
|
|
14
14
|
events,
|
|
15
15
|
user,
|
|
16
|
+
eventTypeDefinitions,
|
|
17
|
+
mode,
|
|
16
18
|
onDateChange,
|
|
17
19
|
onViewChange,
|
|
18
20
|
onEventClick,
|
|
21
|
+
onEventEditRequest,
|
|
19
22
|
onDateDoubleClick,
|
|
23
|
+
onEventCreate,
|
|
24
|
+
onEventUpdate,
|
|
25
|
+
onEventUpdateDenied,
|
|
26
|
+
onEventUpdateError,
|
|
27
|
+
onEventDelete,
|
|
28
|
+
onEventActionDenied,
|
|
29
|
+
onSlotClick,
|
|
20
30
|
className,
|
|
21
31
|
style,
|
|
22
32
|
...rest
|
|
@@ -44,10 +54,38 @@ const Calendar = forwardRef(
|
|
|
44
54
|
if (calendarRef.current) {
|
|
45
55
|
calendarRef.current.date = /* @__PURE__ */ new Date();
|
|
46
56
|
}
|
|
57
|
+
},
|
|
58
|
+
getEvents: () => {
|
|
59
|
+
if (calendarRef.current && typeof calendarRef.current.getEvents === "function") {
|
|
60
|
+
return calendarRef.current.getEvents();
|
|
61
|
+
}
|
|
62
|
+
return calendarRef.current?.events || [];
|
|
63
|
+
},
|
|
64
|
+
getEventDSL: () => {
|
|
65
|
+
if (calendarRef.current && typeof calendarRef.current.getEventDSL === "function") {
|
|
66
|
+
return calendarRef.current.getEventDSL();
|
|
67
|
+
}
|
|
68
|
+
return calendarRef.current?.eventTypeDefinitions ?? calendarRef.current?.eventDSL ?? null;
|
|
69
|
+
},
|
|
70
|
+
addEvent: (newEvent) => {
|
|
71
|
+
if (calendarRef.current && typeof calendarRef.current.addEvent === "function") {
|
|
72
|
+
return calendarRef.current.addEvent(newEvent);
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
},
|
|
76
|
+
proposeEventUpdate: (updatedEvent) => {
|
|
77
|
+
const element = calendarRef.current;
|
|
78
|
+
if (typeof element?.proposeEventUpdate !== "function") return false;
|
|
79
|
+
return element.proposeEventUpdate(updatedEvent);
|
|
80
|
+
},
|
|
81
|
+
canPerformAction: (action, event) => {
|
|
82
|
+
const element = calendarRef.current;
|
|
83
|
+
if (typeof element?.canPerformAction !== "function") return false;
|
|
84
|
+
return element.canPerformAction(action, event);
|
|
47
85
|
}
|
|
48
86
|
}));
|
|
49
87
|
useEffect(() => {
|
|
50
|
-
if (!calendarRef.current) return;
|
|
88
|
+
if (!isClient || !calendarRef.current) return;
|
|
51
89
|
const element = calendarRef.current;
|
|
52
90
|
if (view !== void 0) {
|
|
53
91
|
element.view = view;
|
|
@@ -61,9 +99,15 @@ const Calendar = forwardRef(
|
|
|
61
99
|
if (user !== void 0) {
|
|
62
100
|
element.user = user;
|
|
63
101
|
}
|
|
64
|
-
|
|
102
|
+
if (eventTypeDefinitions !== void 0) {
|
|
103
|
+
element.eventTypeDefinitions = eventTypeDefinitions;
|
|
104
|
+
}
|
|
105
|
+
if (mode !== void 0) {
|
|
106
|
+
element.mode = mode;
|
|
107
|
+
}
|
|
108
|
+
}, [isClient, view, date, events, user, eventTypeDefinitions, mode]);
|
|
65
109
|
useEffect(() => {
|
|
66
|
-
if (!calendarRef.current) return;
|
|
110
|
+
if (!isClient || !calendarRef.current) return;
|
|
67
111
|
const element = calendarRef.current;
|
|
68
112
|
const handleDateChange = (e) => {
|
|
69
113
|
onDateChange?.(e);
|
|
@@ -74,20 +118,90 @@ const Calendar = forwardRef(
|
|
|
74
118
|
const handleEventClick = (e) => {
|
|
75
119
|
onEventClick?.(e);
|
|
76
120
|
};
|
|
121
|
+
const handleEventEditRequest = (e) => {
|
|
122
|
+
onEventEditRequest?.(e);
|
|
123
|
+
};
|
|
77
124
|
const handleDateDoubleClick = (e) => {
|
|
78
125
|
onDateDoubleClick?.(e);
|
|
79
126
|
};
|
|
127
|
+
const handleEventCreate = (e) => {
|
|
128
|
+
onEventCreate?.(e);
|
|
129
|
+
};
|
|
130
|
+
const handleEventUpdate = (e) => {
|
|
131
|
+
onEventUpdate?.(e);
|
|
132
|
+
};
|
|
133
|
+
const handleEventUpdateDenied = (e) => {
|
|
134
|
+
onEventUpdateDenied?.(e);
|
|
135
|
+
};
|
|
136
|
+
const handleEventUpdateError = (e) => {
|
|
137
|
+
onEventUpdateError?.(
|
|
138
|
+
e
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
const handleEventDelete = (e) => {
|
|
142
|
+
onEventDelete?.(e);
|
|
143
|
+
};
|
|
144
|
+
const handleEventActionDenied = (e) => {
|
|
145
|
+
onEventActionDenied?.(
|
|
146
|
+
e
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
const handleSlotClick = (e) => {
|
|
150
|
+
onSlotClick?.(e);
|
|
151
|
+
};
|
|
80
152
|
element.addEventListener("date-change", handleDateChange);
|
|
81
153
|
element.addEventListener("view-change", handleViewChange);
|
|
82
154
|
element.addEventListener("event-click", handleEventClick);
|
|
155
|
+
element.addEventListener("event-edit-request", handleEventEditRequest);
|
|
83
156
|
element.addEventListener("date-double-click", handleDateDoubleClick);
|
|
157
|
+
element.addEventListener("event-create", handleEventCreate);
|
|
158
|
+
element.addEventListener("event-update", handleEventUpdate);
|
|
159
|
+
element.addEventListener("event-update-denied", handleEventUpdateDenied);
|
|
160
|
+
element.addEventListener("event-update-error", handleEventUpdateError);
|
|
161
|
+
element.addEventListener("event-delete", handleEventDelete);
|
|
162
|
+
element.addEventListener("event-action-denied", handleEventActionDenied);
|
|
163
|
+
element.addEventListener("slot-click", handleSlotClick);
|
|
84
164
|
return () => {
|
|
85
165
|
element.removeEventListener("date-change", handleDateChange);
|
|
86
166
|
element.removeEventListener("view-change", handleViewChange);
|
|
87
167
|
element.removeEventListener("event-click", handleEventClick);
|
|
168
|
+
element.removeEventListener(
|
|
169
|
+
"event-edit-request",
|
|
170
|
+
handleEventEditRequest
|
|
171
|
+
);
|
|
88
172
|
element.removeEventListener("date-double-click", handleDateDoubleClick);
|
|
173
|
+
element.removeEventListener("event-create", handleEventCreate);
|
|
174
|
+
element.removeEventListener("event-update", handleEventUpdate);
|
|
175
|
+
element.removeEventListener(
|
|
176
|
+
"event-update-denied",
|
|
177
|
+
handleEventUpdateDenied
|
|
178
|
+
);
|
|
179
|
+
element.removeEventListener(
|
|
180
|
+
"event-update-error",
|
|
181
|
+
handleEventUpdateError
|
|
182
|
+
);
|
|
183
|
+
element.removeEventListener("event-delete", handleEventDelete);
|
|
184
|
+
element.removeEventListener(
|
|
185
|
+
"event-action-denied",
|
|
186
|
+
handleEventActionDenied
|
|
187
|
+
);
|
|
188
|
+
element.removeEventListener("slot-click", handleSlotClick);
|
|
89
189
|
};
|
|
90
|
-
}, [
|
|
190
|
+
}, [
|
|
191
|
+
isClient,
|
|
192
|
+
onDateChange,
|
|
193
|
+
onViewChange,
|
|
194
|
+
onEventClick,
|
|
195
|
+
onEventEditRequest,
|
|
196
|
+
onDateDoubleClick,
|
|
197
|
+
onEventCreate,
|
|
198
|
+
onEventUpdate,
|
|
199
|
+
onEventUpdateDenied,
|
|
200
|
+
onEventUpdateError,
|
|
201
|
+
onEventDelete,
|
|
202
|
+
onEventActionDenied,
|
|
203
|
+
onSlotClick
|
|
204
|
+
]);
|
|
91
205
|
if (!isClient) {
|
|
92
206
|
return /* @__PURE__ */ jsx(
|
|
93
207
|
"div",
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/Calendar.tsx","../src/components/ResizableSplitter.tsx"],"sourcesContent":["/**\n * React wrapper for wsx-calendar Web Component\n *\n * 使用方式:\n * ```tsx\n * import { Calendar } from '@calenderjs/react';\n *\n * <Calendar\n * view=\"month\"\n * date=\"2024-12-30\"\n * onDateChange={(e) => console.log('Date changed:', e.detail.date)}\n * onViewChange={(e) => console.log('View changed:', e.detail.view)}\n * />\n * ```\n */\n\nimport React, {\n useRef,\n useEffect,\n useImperativeHandle,\n forwardRef,\n useState,\n} from \"react\";\nimport type { Event } from \"@calenderjs/event-model\";\nimport type { User } from \"@calenderjs/core\";\n\n// 延迟加载 Web Component,只在客户端注册\n// 避免在服务器端执行(HTMLElement 不存在)\nlet calendarRegistered = false;\nconst registerCalendar = () => {\n if (typeof window !== \"undefined\" && !calendarRegistered) {\n import(\"@calenderjs/calendar\");\n calendarRegistered = true;\n }\n};\n\n// 声明 wsx-calendar 元素类型\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n \"wsx-calendar\": React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement> & {\n view?: \"month\" | \"week\" | \"day\";\n date?: string;\n },\n HTMLElement\n > & {\n events?: Event[];\n user?: User;\n };\n }\n }\n}\n\n/**\n * Calendar 组件的属性\n */\nexport interface CalendarProps {\n /**\n * 初始视图(month | week | day)\n */\n view?: \"month\" | \"week\" | \"day\";\n\n /**\n * 初始日期(ISO 8601 字符串或 Date 对象)\n */\n date?: string | Date;\n\n /**\n * 事件列表(数据模型)\n */\n events?: Event[];\n\n /**\n * 当前用户\n */\n user?: User;\n\n /**\n * 日期变化时的回调\n */\n onDateChange?: (event: CustomEvent<{ date: Date }>) => void;\n\n /**\n * 视图切换时的回调\n */\n onViewChange?: (\n event: CustomEvent<{ view: \"month\" | \"week\" | \"day\" }>,\n ) => void;\n\n /**\n * 事件点击时的回调\n */\n onEventClick?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 日期双击时的回调\n */\n onDateDoubleClick?: (event: CustomEvent<{ date: Date }>) => void;\n\n /**\n * 其他 HTML 属性\n */\n className?: string;\n style?: React.CSSProperties;\n [key: string]: any;\n}\n\n/**\n * Calendar 组件的引用类型\n */\nexport interface CalendarRef {\n /**\n * 获取底层的 Web Component 实例\n */\n getElement: () => HTMLElement | null;\n\n /**\n * 设置当前视图\n */\n setView: (view: \"month\" | \"week\" | \"day\") => void;\n\n /**\n * 设置当前日期\n */\n setDate: (date: Date | string) => void;\n\n /**\n * 跳转到今天\n */\n goToToday: () => void;\n}\n\n/**\n * Calendar React 组件\n */\nexport const Calendar = forwardRef<CalendarRef, CalendarProps>(\n (\n {\n view = \"month\",\n date,\n events,\n user,\n onDateChange,\n onViewChange,\n onEventClick,\n onDateDoubleClick,\n className,\n style,\n ...rest\n }: CalendarProps,\n ref: React.ForwardedRef<CalendarRef>,\n ) => {\n const calendarRef = useRef<\n | (HTMLElement & {\n view?: \"month\" | \"week\" | \"day\";\n date?: Date | string;\n events?: Event[];\n user?: User;\n })\n | null\n >(null);\n const [isClient, setIsClient] = useState(false);\n\n // 只在客户端注册 Web Component\n useEffect(() => {\n setIsClient(true);\n registerCalendar();\n }, []);\n\n // 暴露方法给父组件\n useImperativeHandle(ref, () => ({\n getElement: () => calendarRef.current,\n setView: (newView: \"month\" | \"week\" | \"day\") => {\n if (calendarRef.current) {\n (calendarRef.current as any).view = newView;\n }\n },\n setDate: (newDate: Date | string) => {\n if (calendarRef.current) {\n const date =\n typeof newDate === \"string\" ? new Date(newDate) : newDate;\n (calendarRef.current as any).date = date;\n }\n },\n goToToday: () => {\n if (calendarRef.current) {\n (calendarRef.current as any).date = new Date();\n }\n },\n }));\n\n // 处理属性变化\n useEffect(() => {\n if (!calendarRef.current) return;\n\n const element = calendarRef.current as any;\n\n // 所有属性都通过 property 设置\n if (view !== undefined) {\n element.view = view;\n }\n\n if (date !== undefined) {\n element.date = date instanceof Date ? date : new Date(date);\n }\n\n if (events !== undefined) {\n element.events = events;\n }\n\n if (user !== undefined) {\n element.user = user;\n }\n }, [view, date, events, user]);\n\n // 绑定事件监听器\n useEffect(() => {\n if (!calendarRef.current) return;\n\n const element = calendarRef.current;\n\n const handleDateChange = (e: globalThis.Event) => {\n onDateChange?.(e as CustomEvent<{ date: Date }>);\n };\n\n const handleViewChange = (e: globalThis.Event) => {\n onViewChange?.(e as CustomEvent<{ view: \"month\" | \"week\" | \"day\" }>);\n };\n\n const handleEventClick = (e: globalThis.Event) => {\n onEventClick?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleDateDoubleClick = (e: globalThis.Event) => {\n onDateDoubleClick?.(e as CustomEvent<{ date: Date }>);\n };\n\n element.addEventListener(\"date-change\", handleDateChange);\n element.addEventListener(\"view-change\", handleViewChange);\n element.addEventListener(\"event-click\", handleEventClick);\n element.addEventListener(\"date-double-click\", handleDateDoubleClick);\n\n return () => {\n element.removeEventListener(\"date-change\", handleDateChange);\n element.removeEventListener(\"view-change\", handleViewChange);\n element.removeEventListener(\"event-click\", handleEventClick);\n element.removeEventListener(\"date-double-click\", handleDateDoubleClick);\n };\n }, [onDateChange, onViewChange, onEventClick, onDateDoubleClick]);\n\n // 服务器端渲染时返回占位符\n if (!isClient) {\n return (\n <div\n className={className}\n style={{\n ...style,\n minHeight: \"600px\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n {...rest}\n >\n <div>加载中...</div>\n </div>\n );\n }\n\n return (\n <wsx-calendar\n ref={calendarRef}\n className={className}\n style={style}\n {...rest}\n />\n );\n },\n);\n\nCalendar.displayName = \"Calendar\";\n","\"use client\";\n\nimport { useState, useRef, useEffect, useCallback } from \"react\";\n\nexport interface ResizableSplitterProps {\n /** 左侧面板内容 */\n left: React.ReactNode;\n /** 右侧面板内容 */\n right: React.ReactNode;\n /** 初始左侧面板宽度(百分比,0-100) */\n initialLeftWidth?: number;\n /** 左侧面板最小宽度(百分比) */\n minLeftWidth?: number;\n /** 左侧面板最大宽度(百分比) */\n maxLeftWidth?: number;\n /** 自定义 CSS 类名 */\n className?: string;\n}\n\n/**\n * ResizableSplitter - 可调整大小的分割面板组件\n *\n * 提供一个可拖拽的分割器,允许用户调整左右两个面板的宽度。\n *\n * @example\n * ```tsx\n * import { ResizableSplitter } from '@calenderjs/react';\n *\n * function App() {\n * return (\n * <ResizableSplitter\n * left={<div>左侧内容</div>}\n * right={<div>右侧内容</div>}\n * initialLeftWidth={40}\n * minLeftWidth={20}\n * maxLeftWidth={80}\n * />\n * );\n * }\n * ```\n */\nexport default function ResizableSplitter({\n left,\n right,\n initialLeftWidth = 40,\n minLeftWidth = 20,\n maxLeftWidth = 80,\n className = \"\",\n}: ResizableSplitterProps) {\n const [leftWidth, setLeftWidth] = useState(initialLeftWidth);\n const [isDragging, setIsDragging] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const splitterRef = useRef<HTMLDivElement>(null);\n\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n setIsDragging(true);\n }, []);\n\n const handleMouseMove = useCallback(\n (e: MouseEvent) => {\n if (!isDragging || !containerRef.current) return;\n\n const containerRect = containerRef.current.getBoundingClientRect();\n const newLeftWidth =\n ((e.clientX - containerRect.left) / containerRect.width) * 100;\n\n // 限制在最小和最大宽度之间\n const clampedWidth = Math.max(\n minLeftWidth,\n Math.min(maxLeftWidth, newLeftWidth),\n );\n\n setLeftWidth(clampedWidth);\n },\n [isDragging, minLeftWidth, maxLeftWidth],\n );\n\n const handleMouseUp = useCallback(() => {\n setIsDragging(false);\n }, []);\n\n useEffect(() => {\n if (isDragging) {\n document.addEventListener(\"mousemove\", handleMouseMove);\n document.addEventListener(\"mouseup\", handleMouseUp);\n document.body.style.cursor = \"col-resize\";\n document.body.style.userSelect = \"none\";\n\n return () => {\n document.removeEventListener(\"mousemove\", handleMouseMove);\n document.removeEventListener(\"mouseup\", handleMouseUp);\n document.body.style.cursor = \"\";\n document.body.style.userSelect = \"\";\n };\n }\n }, [isDragging, handleMouseMove, handleMouseUp]);\n\n return (\n <div\n ref={containerRef}\n className={`resizable-splitter ${className}`}\n style={{\n display: \"flex\",\n width: \"100%\",\n height: \"100%\",\n position: \"relative\",\n }}\n >\n {/* Left Panel */}\n <div\n style={{\n width: `${leftWidth}%`,\n height: \"100%\",\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n }}\n >\n {left}\n </div>\n\n {/* Splitter */}\n <div\n ref={splitterRef}\n onMouseDown={handleMouseDown}\n style={{\n width: \"var(--resizable-splitter-width, 4px)\",\n height: \"100%\",\n cursor: \"col-resize\",\n backgroundColor: \"var(--resizable-splitter-bg-color, #ddd)\",\n position: \"relative\",\n flexShrink: 0,\n transition: isDragging\n ? \"none\"\n : \"var(--resizable-splitter-transition, background-color 0.2s)\",\n }}\n onMouseEnter={(e) => {\n if (!isDragging) {\n e.currentTarget.style.backgroundColor =\n \"var(--resizable-splitter-hover-bg-color, #bbb)\";\n }\n }}\n onMouseLeave={(e) => {\n if (!isDragging) {\n e.currentTarget.style.backgroundColor =\n \"var(--resizable-splitter-bg-color, #ddd)\";\n }\n }}\n >\n {/* Splitter Handle */}\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n width: \"var(--resizable-splitter-handle-width, 20px)\",\n height: \"var(--resizable-splitter-handle-height, 40px)\",\n borderRadius: \"var(--resizable-splitter-handle-border-radius, 4px)\",\n backgroundColor:\n \"var(--resizable-splitter-handle-bg-color, rgba(0,0,0,0.1))\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"var(--resizable-splitter-dot-gap, 2px)\",\n }}\n >\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n </div>\n </div>\n </div>\n\n {/* Right Panel */}\n <div\n style={{\n flex: 1,\n height: \"100%\",\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\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e;AAAA,gBAAA;AAAA,gBAGjB,UAAA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,OAAO;AAAA,sBACL,SAAS;AAAA,sBACT,eAAe;AAAA,sBACf,KAAK;AAAA,oBAAA;AAAA,oBAGP,UAAA;AAAA,sBAAA;AAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,OAAO;AAAA,4BACL,OAAO;AAAA,4BACP,QAAQ;AAAA,4BACR,cAAc;AAAA,4BACd,iBAAiB;AAAA,0BAAA;AAAA,wBACnB;AAAA,sBAAA;AAAA,sBAEF;AAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,OAAO;AAAA,4BACL,OAAO;AAAA,4BACP,QAAQ;AAAA,4BACR,cAAc;AAAA,4BACd,iBAAiB;AAAA,0BAAA;AAAA,wBACnB;AAAA,sBAAA;AAAA,sBAEF;AAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,OAAO;AAAA,4BACL,OAAO;AAAA,4BACP,QAAQ;AAAA,4BACR,cAAc;AAAA,4BACd,iBAAiB;AAAA,0BAAA;AAAA,wBACnB;AAAA,sBAAA;AAAA,oBACF;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,QAIF;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,MAAM;AAAA,cACN,QAAQ;AAAA,cACR,UAAU;AAAA,cACV,SAAS;AAAA,cACT,eAAe;AAAA,YAAA;AAAA,YAGhB,UAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/Calendar.tsx","../src/components/ResizableSplitter.tsx"],"sourcesContent":["/**\n * React wrapper for wsx-calendar Web Component\n *\n * 使用方式:\n * ```tsx\n * import { Calendar } from '@calenderjs/react';\n *\n * <Calendar\n * view=\"month\"\n * date=\"2024-12-30\"\n * onDateChange={(e) => console.log('Date changed:', e.detail.date)}\n * onViewChange={(e) => console.log('View changed:', e.detail.view)}\n * />\n * ```\n */\n\nimport React, {\n useRef,\n useEffect,\n useImperativeHandle,\n forwardRef,\n useState,\n} from \"react\";\nimport type { Event } from \"@calenderjs/event-model\";\nimport type { User } from \"@calenderjs/core\";\n\n// 延迟加载 Web Component,只在客户端注册\n// 避免在服务器端执行(HTMLElement 不存在)\nlet calendarRegistered = false;\nconst registerCalendar = () => {\n if (typeof window !== \"undefined\" && !calendarRegistered) {\n import(\"@calenderjs/calendar\");\n calendarRegistered = true;\n }\n};\n\n// 声明 wsx-calendar 元素类型\ndeclare global {\n namespace JSX {\n interface IntrinsicElements {\n \"wsx-calendar\": React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement> & {\n view?: \"month\" | \"week\" | \"day\";\n date?: string;\n mode?: \"readonly\" | \"editable\";\n },\n HTMLElement\n > & {\n events?: Event[];\n user?: User;\n };\n }\n }\n}\n\n/**\n * Calendar 组件的属性\n */\nexport interface CalendarProps {\n /**\n * 初始视图(month | week | day)\n */\n view?: \"month\" | \"week\" | \"day\";\n\n /**\n * 初始日期(ISO 8601 字符串或 Date 对象)\n */\n date?: string | Date;\n\n /**\n * 事件列表(数据模型)\n */\n events?: Event[];\n\n /**\n * 当前用户\n */\n user?: User;\n\n /**\n * Event DSL 定义(文本或 AST)\n */\n eventTypeDefinitions?: string | any;\n\n /**\n * 编辑模式(readonly | editable,默认 editable)\n * readonly 时短路所有拖拽/resize/keyboard 更新请求\n */\n mode?: \"readonly\" | \"editable\";\n\n /**\n * 日期变化时的回调\n */\n onDateChange?: (event: CustomEvent<{ date: Date }>) => void;\n\n /**\n * 视图切换时的回调\n */\n onViewChange?: (\n event: CustomEvent<{ view: \"month\" | \"week\" | \"day\" }>,\n ) => void;\n\n /**\n * 事件点击时的回调\n */\n onEventClick?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 请求编辑事件时的回调(双击,或聚焦后按 Enter/Space)\n */\n onEventEditRequest?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 日期双击时的回调\n */\n onDateDoubleClick?: (event: CustomEvent<{ date: Date }>) => void;\n\n /**\n * 事件创建回调\n */\n onEventCreate?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 事件更新回调\n */\n onEventUpdate?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 事件更新被权限拒绝时的回调\n */\n onEventUpdateDenied?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 事件更新未通过 DSL 校验时的回调\n */\n onEventUpdateError?: (\n event: CustomEvent<{ event: Event; errors: string[] }>,\n ) => void;\n\n /**\n * 事件删除回调\n */\n onEventDelete?: (event: CustomEvent<{ event: Event }>) => void;\n\n /**\n * 动作被权限拒绝时的回调 (RFC-0018)\n */\n onEventActionDenied?: (\n event: CustomEvent<{ action: \"edit\" | \"delete\"; event: Event }>,\n ) => void;\n\n /**\n * 时间槽点击回调\n */\n onSlotClick?: (event: CustomEvent<{ date: Date; hour: number }>) => void;\n\n /**\n * 其他 HTML 属性\n */\n className?: string;\n style?: React.CSSProperties;\n [key: string]: any;\n}\n\n/**\n * Calendar 组件的引用类型\n */\nexport interface CalendarRef {\n /**\n * 获取底层的 Web Component 实例\n */\n getElement: () => HTMLElement | null;\n\n /**\n * 设置当前视图\n */\n setView: (view: \"month\" | \"week\" | \"day\") => void;\n\n /**\n * 设置当前日期\n */\n setDate: (date: Date | string) => void;\n\n /**\n * 跳转到今天\n */\n goToToday: () => void;\n\n /**\n * 获取所有事件\n */\n getEvents: () => Event[];\n\n /**\n * 获取当前 Event DSL / 类型定义\n */\n getEventDSL: () => string | any | null;\n\n /**\n * 手动添加事件\n */\n addEvent: (event: Event) => boolean;\n\n /**\n * 提议更新事件;成功只表示组件已派发 event-update\n */\n proposeEventUpdate: (event: Event) => boolean;\n\n /** 查询底层 Calendar 对事件动作的当前权限 */\n canPerformAction: (action: string, event: Event) => boolean;\n}\n\n/**\n * Calendar React 组件\n */\nexport const Calendar = forwardRef<CalendarRef, CalendarProps>(\n (\n {\n view = \"month\",\n date,\n events,\n user,\n eventTypeDefinitions,\n mode,\n onDateChange,\n onViewChange,\n onEventClick,\n onEventEditRequest,\n onDateDoubleClick,\n onEventCreate,\n onEventUpdate,\n onEventUpdateDenied,\n onEventUpdateError,\n onEventDelete,\n onEventActionDenied,\n onSlotClick,\n className,\n style,\n ...rest\n }: CalendarProps,\n ref: React.ForwardedRef<CalendarRef>,\n ) => {\n const calendarRef = useRef<\n | (HTMLElement & {\n view?: \"month\" | \"week\" | \"day\";\n date?: Date | string;\n events?: Event[];\n user?: User;\n })\n | null\n >(null);\n const [isClient, setIsClient] = useState(false);\n\n // 只在客户端注册 Web Component\n useEffect(() => {\n setIsClient(true);\n registerCalendar();\n }, []);\n\n // 暴露方法给父组件\n useImperativeHandle(ref, () => ({\n getElement: () => calendarRef.current,\n setView: (newView: \"month\" | \"week\" | \"day\") => {\n if (calendarRef.current) {\n (calendarRef.current as any).view = newView;\n }\n },\n setDate: (newDate: Date | string) => {\n if (calendarRef.current) {\n const date =\n typeof newDate === \"string\" ? new Date(newDate) : newDate;\n (calendarRef.current as any).date = date;\n }\n },\n goToToday: () => {\n if (calendarRef.current) {\n (calendarRef.current as any).date = new Date();\n }\n },\n getEvents: () => {\n if (\n calendarRef.current &&\n typeof (calendarRef.current as any).getEvents === \"function\"\n ) {\n return (calendarRef.current as any).getEvents();\n }\n return (calendarRef.current as any)?.events || [];\n },\n getEventDSL: () => {\n if (\n calendarRef.current &&\n typeof (calendarRef.current as any).getEventDSL === \"function\"\n ) {\n return (calendarRef.current as any).getEventDSL();\n }\n return (\n (calendarRef.current as any)?.eventTypeDefinitions ??\n (calendarRef.current as any)?.eventDSL ??\n null\n );\n },\n addEvent: (newEvent: Event) => {\n if (\n calendarRef.current &&\n typeof (calendarRef.current as any).addEvent === \"function\"\n ) {\n return (calendarRef.current as any).addEvent(newEvent);\n }\n return false;\n },\n proposeEventUpdate: (updatedEvent: Event) => {\n const element = calendarRef.current as any;\n if (typeof element?.proposeEventUpdate !== \"function\") return false;\n return element.proposeEventUpdate(updatedEvent);\n },\n canPerformAction: (action: string, event: Event) => {\n const element = calendarRef.current as any;\n if (typeof element?.canPerformAction !== \"function\") return false;\n return element.canPerformAction(action, event);\n },\n }));\n\n // 处理属性变化。isClient 必须入依赖:占位阶段 ref 为空,客户端元素出现后需补写初始 props。\n useEffect(() => {\n if (!isClient || !calendarRef.current) return;\n\n const element = calendarRef.current as any;\n\n // 所有属性都通过 property 设置\n if (view !== undefined) {\n element.view = view;\n }\n\n if (date !== undefined) {\n element.date = date instanceof Date ? date : new Date(date);\n }\n\n if (events !== undefined) {\n element.events = events;\n }\n\n if (user !== undefined) {\n element.user = user;\n }\n\n if (eventTypeDefinitions !== undefined) {\n element.eventTypeDefinitions = eventTypeDefinitions;\n }\n\n if (mode !== undefined) {\n element.mode = mode;\n }\n }, [isClient, view, date, events, user, eventTypeDefinitions, mode]);\n\n // 绑定事件监听器。同 props:客户端 wsx-calendar 出现后再挂载,避免冷启动漏绑。\n useEffect(() => {\n if (!isClient || !calendarRef.current) return;\n\n const element = calendarRef.current;\n\n const handleDateChange = (e: globalThis.Event) => {\n onDateChange?.(e as CustomEvent<{ date: Date }>);\n };\n\n const handleViewChange = (e: globalThis.Event) => {\n onViewChange?.(e as CustomEvent<{ view: \"month\" | \"week\" | \"day\" }>);\n };\n\n const handleEventClick = (e: globalThis.Event) => {\n onEventClick?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleEventEditRequest = (e: globalThis.Event) => {\n onEventEditRequest?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleDateDoubleClick = (e: globalThis.Event) => {\n onDateDoubleClick?.(e as CustomEvent<{ date: Date }>);\n };\n\n const handleEventCreate = (e: globalThis.Event) => {\n onEventCreate?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleEventUpdate = (e: globalThis.Event) => {\n onEventUpdate?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleEventUpdateDenied = (e: globalThis.Event) => {\n onEventUpdateDenied?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleEventUpdateError = (e: globalThis.Event) => {\n onEventUpdateError?.(\n e as CustomEvent<{ event: Event; errors: string[] }>,\n );\n };\n\n const handleEventDelete = (e: globalThis.Event) => {\n onEventDelete?.(e as CustomEvent<{ event: Event }>);\n };\n\n const handleEventActionDenied = (e: globalThis.Event) => {\n onEventActionDenied?.(\n e as CustomEvent<{ action: \"edit\" | \"delete\"; event: Event }>,\n );\n };\n\n const handleSlotClick = (e: globalThis.Event) => {\n onSlotClick?.(e as CustomEvent<{ date: Date; hour: number }>);\n };\n\n element.addEventListener(\"date-change\", handleDateChange);\n element.addEventListener(\"view-change\", handleViewChange);\n element.addEventListener(\"event-click\", handleEventClick);\n element.addEventListener(\"event-edit-request\", handleEventEditRequest);\n element.addEventListener(\"date-double-click\", handleDateDoubleClick);\n element.addEventListener(\"event-create\", handleEventCreate);\n element.addEventListener(\"event-update\", handleEventUpdate);\n element.addEventListener(\"event-update-denied\", handleEventUpdateDenied);\n element.addEventListener(\"event-update-error\", handleEventUpdateError);\n element.addEventListener(\"event-delete\", handleEventDelete);\n element.addEventListener(\"event-action-denied\", handleEventActionDenied);\n element.addEventListener(\"slot-click\", handleSlotClick);\n\n return () => {\n element.removeEventListener(\"date-change\", handleDateChange);\n element.removeEventListener(\"view-change\", handleViewChange);\n element.removeEventListener(\"event-click\", handleEventClick);\n element.removeEventListener(\n \"event-edit-request\",\n handleEventEditRequest,\n );\n element.removeEventListener(\"date-double-click\", handleDateDoubleClick);\n element.removeEventListener(\"event-create\", handleEventCreate);\n element.removeEventListener(\"event-update\", handleEventUpdate);\n element.removeEventListener(\n \"event-update-denied\",\n handleEventUpdateDenied,\n );\n element.removeEventListener(\n \"event-update-error\",\n handleEventUpdateError,\n );\n element.removeEventListener(\"event-delete\", handleEventDelete);\n element.removeEventListener(\n \"event-action-denied\",\n handleEventActionDenied,\n );\n element.removeEventListener(\"slot-click\", handleSlotClick);\n };\n }, [\n isClient,\n onDateChange,\n onViewChange,\n onEventClick,\n onEventEditRequest,\n onDateDoubleClick,\n onEventCreate,\n onEventUpdate,\n onEventUpdateDenied,\n onEventUpdateError,\n onEventDelete,\n onEventActionDenied,\n onSlotClick,\n ]);\n\n // 服务器端渲染时返回占位符\n if (!isClient) {\n return (\n <div\n className={className}\n style={{\n ...style,\n minHeight: \"600px\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n {...rest}\n >\n <div>加载中...</div>\n </div>\n );\n }\n\n return (\n <wsx-calendar\n ref={calendarRef}\n className={className}\n style={style}\n {...rest}\n />\n );\n },\n);\n\nCalendar.displayName = \"Calendar\";\n","\"use client\";\n\nimport { useState, useRef, useEffect, useCallback } from \"react\";\n\nexport interface ResizableSplitterProps {\n /** 左侧面板内容 */\n left: React.ReactNode;\n /** 右侧面板内容 */\n right: React.ReactNode;\n /** 初始左侧面板宽度(百分比,0-100) */\n initialLeftWidth?: number;\n /** 左侧面板最小宽度(百分比) */\n minLeftWidth?: number;\n /** 左侧面板最大宽度(百分比) */\n maxLeftWidth?: number;\n /** 自定义 CSS 类名 */\n className?: string;\n}\n\n/**\n * ResizableSplitter - 可调整大小的分割面板组件\n *\n * 提供一个可拖拽的分割器,允许用户调整左右两个面板的宽度。\n *\n * @example\n * ```tsx\n * import { ResizableSplitter } from '@calenderjs/react';\n *\n * function App() {\n * return (\n * <ResizableSplitter\n * left={<div>左侧内容</div>}\n * right={<div>右侧内容</div>}\n * initialLeftWidth={40}\n * minLeftWidth={20}\n * maxLeftWidth={80}\n * />\n * );\n * }\n * ```\n */\nexport default function ResizableSplitter({\n left,\n right,\n initialLeftWidth = 40,\n minLeftWidth = 20,\n maxLeftWidth = 80,\n className = \"\",\n}: ResizableSplitterProps) {\n const [leftWidth, setLeftWidth] = useState(initialLeftWidth);\n const [isDragging, setIsDragging] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const splitterRef = useRef<HTMLDivElement>(null);\n\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n setIsDragging(true);\n }, []);\n\n const handleMouseMove = useCallback(\n (e: MouseEvent) => {\n if (!isDragging || !containerRef.current) return;\n\n const containerRect = containerRef.current.getBoundingClientRect();\n const newLeftWidth =\n ((e.clientX - containerRect.left) / containerRect.width) * 100;\n\n // 限制在最小和最大宽度之间\n const clampedWidth = Math.max(\n minLeftWidth,\n Math.min(maxLeftWidth, newLeftWidth),\n );\n\n setLeftWidth(clampedWidth);\n },\n [isDragging, minLeftWidth, maxLeftWidth],\n );\n\n const handleMouseUp = useCallback(() => {\n setIsDragging(false);\n }, []);\n\n useEffect(() => {\n if (isDragging) {\n document.addEventListener(\"mousemove\", handleMouseMove);\n document.addEventListener(\"mouseup\", handleMouseUp);\n document.body.style.cursor = \"col-resize\";\n document.body.style.userSelect = \"none\";\n\n return () => {\n document.removeEventListener(\"mousemove\", handleMouseMove);\n document.removeEventListener(\"mouseup\", handleMouseUp);\n document.body.style.cursor = \"\";\n document.body.style.userSelect = \"\";\n };\n }\n }, [isDragging, handleMouseMove, handleMouseUp]);\n\n return (\n <div\n ref={containerRef}\n className={`resizable-splitter ${className}`}\n style={{\n display: \"flex\",\n width: \"100%\",\n height: \"100%\",\n position: \"relative\",\n }}\n >\n {/* Left Panel */}\n <div\n style={{\n width: `${leftWidth}%`,\n height: \"100%\",\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n }}\n >\n {left}\n </div>\n\n {/* Splitter */}\n <div\n ref={splitterRef}\n onMouseDown={handleMouseDown}\n style={{\n width: \"var(--resizable-splitter-width, 4px)\",\n height: \"100%\",\n cursor: \"col-resize\",\n backgroundColor: \"var(--resizable-splitter-bg-color, #ddd)\",\n position: \"relative\",\n flexShrink: 0,\n transition: isDragging\n ? \"none\"\n : \"var(--resizable-splitter-transition, background-color 0.2s)\",\n }}\n onMouseEnter={(e) => {\n if (!isDragging) {\n e.currentTarget.style.backgroundColor =\n \"var(--resizable-splitter-hover-bg-color, #bbb)\";\n }\n }}\n onMouseLeave={(e) => {\n if (!isDragging) {\n e.currentTarget.style.backgroundColor =\n \"var(--resizable-splitter-bg-color, #ddd)\";\n }\n }}\n >\n {/* Splitter Handle */}\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n width: \"var(--resizable-splitter-handle-width, 20px)\",\n height: \"var(--resizable-splitter-handle-height, 40px)\",\n borderRadius: \"var(--resizable-splitter-handle-border-radius, 4px)\",\n backgroundColor:\n \"var(--resizable-splitter-handle-bg-color, rgba(0,0,0,0.1))\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"var(--resizable-splitter-dot-gap, 2px)\",\n }}\n >\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n <div\n style={{\n width: \"var(--resizable-splitter-dot-size, 3px)\",\n height: \"var(--resizable-splitter-dot-size, 3px)\",\n borderRadius: \"50%\",\n backgroundColor: \"var(--resizable-splitter-dot-color, #999)\",\n }}\n />\n </div>\n </div>\n </div>\n\n {/* Right Panel */}\n <div\n style={{\n flex: 1,\n height: \"100%\",\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n }}\n >\n {right}\n </div>\n </div>\n );\n}\n"],"names":["date"],"mappings":";;AA4BA,IAAI,qBAAqB;AACzB,MAAM,mBAAmB,MAAM;AAC7B,MAAI,OAAO,WAAW,eA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AA,oBAGP,UAAA;AAAA,sBAAA;AAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,OAAO;AAAA,4BACL,OAAO;AAAA,4BACP,QAAQ;AAAA,4BACR,cAAc;AAAA,4BACd,iBAAiB;AAAA,0BAAA;AAAA,wBACnB;AAAA,sBAAA;AAAA,sBAEF;AAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,OAAO;AAAA,4BACL,OAAO;AAAA,4BACP,QAAQ;AAAA,4BACR,cAAc;AAAA,4BACd,iBAAiB;AAAA,0BAAA;AAAA,wBACnB;AAAA,sBAAA;AAAA,sBAEF;AAAA,wBAAC;AAAA,wBAAA;AAAA,0BACC,OAAO;AAAA,4BACL,OAAO;AAAA,4BACP,QAAQ;AAAA,4BACR,cAAc;AAAA,4BACd,iBAAiB;AAAA,0BAAA;AAAA,wBACnB;AAAA,sBAAA;AAAA,oBACF;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,QAIF;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO;AAAA,cACL,MAAM;AAAA,cACN,QAAQ;AAAA,cACR,UAAU;AAAA,cACV,SAAS;AAAA,cACT,eAAe;AAAA,YAAA;AAAA,YAGhB,UAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calenderjs/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "React wrapper for @calenderjs/calendar Web Component",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/calenderjs/calenderjs.git",
|
|
9
|
+
"directory": "packages/react"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/calenderjs/calenderjs/tree/main/packages/react#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/calenderjs/calenderjs/issues"
|
|
14
|
+
},
|
|
5
15
|
"type": "module",
|
|
6
16
|
"main": "./dist/index.cjs",
|
|
7
17
|
"module": "./dist/index.mjs",
|
|
@@ -25,9 +35,9 @@
|
|
|
25
35
|
"access": "public"
|
|
26
36
|
},
|
|
27
37
|
"dependencies": {
|
|
28
|
-
"@calenderjs/calendar": "0.
|
|
29
|
-
"@calenderjs/core": "0.
|
|
30
|
-
"@calenderjs/event-model": "0.
|
|
38
|
+
"@calenderjs/calendar": "0.4.0",
|
|
39
|
+
"@calenderjs/core": "0.4.0",
|
|
40
|
+
"@calenderjs/event-model": "0.4.0"
|
|
31
41
|
},
|
|
32
42
|
"peerDependencies": {
|
|
33
43
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -37,10 +47,11 @@
|
|
|
37
47
|
"@types/node": "^20.19.27",
|
|
38
48
|
"@types/react": "^18.3.27",
|
|
39
49
|
"@types/react-dom": "^18.3.7",
|
|
50
|
+
"happy-dom": "^20.0.11",
|
|
40
51
|
"react": "^18.3.1",
|
|
41
52
|
"react-dom": "^18.3.1",
|
|
42
53
|
"typescript": "^5.9.3",
|
|
43
|
-
"vite": "^7.3.
|
|
54
|
+
"vite": "^7.3.8",
|
|
44
55
|
"vite-plugin-dts": "^4.5.4",
|
|
45
56
|
"vitest": "^2.1.9"
|
|
46
57
|
},
|