@iyotsuba/schedule-react 0.3.1 → 0.6.1
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/index.cjs +61 -11
- package/dist/index.d.cts +86 -17
- package/dist/index.d.ts +86 -17
- package/dist/index.js +64 -14
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -31,8 +31,16 @@ var import_react2 = require("react");
|
|
|
31
31
|
|
|
32
32
|
// src/useElement.ts
|
|
33
33
|
var import_react = require("react");
|
|
34
|
-
function useElementBridge(properties, events) {
|
|
34
|
+
function useElementBridge(properties, events, forwardedRef) {
|
|
35
35
|
const ref = (0, import_react.useRef)(null);
|
|
36
|
+
const setRef = (0, import_react.useCallback)((node) => {
|
|
37
|
+
ref.current = node;
|
|
38
|
+
if (typeof forwardedRef === "function") {
|
|
39
|
+
forwardedRef(node);
|
|
40
|
+
} else if (forwardedRef) {
|
|
41
|
+
forwardedRef.current = node;
|
|
42
|
+
}
|
|
43
|
+
}, [forwardedRef]);
|
|
36
44
|
(0, import_react.useLayoutEffect)(() => {
|
|
37
45
|
const el = ref.current;
|
|
38
46
|
if (!el) {
|
|
@@ -68,12 +76,12 @@ function useElementBridge(properties, events) {
|
|
|
68
76
|
}
|
|
69
77
|
return () => disposers.forEach((dispose) => dispose());
|
|
70
78
|
});
|
|
71
|
-
return
|
|
79
|
+
return setRef;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
// src/YsSchedule.tsx
|
|
75
83
|
(0, import_schedule_elements.register)();
|
|
76
|
-
|
|
84
|
+
var YsSchedule = (0, import_react2.forwardRef)(function YsSchedule2(props, forwardedRef) {
|
|
77
85
|
const {
|
|
78
86
|
className,
|
|
79
87
|
style,
|
|
@@ -83,8 +91,21 @@ function YsSchedule(props) {
|
|
|
83
91
|
onDayTap,
|
|
84
92
|
onSwipe,
|
|
85
93
|
onWeekPickerOpen,
|
|
94
|
+
onTransitionStart,
|
|
95
|
+
onTransitionEnd,
|
|
86
96
|
onGuideStep,
|
|
87
97
|
onGuideFinish,
|
|
98
|
+
onCourseAdd,
|
|
99
|
+
onCourseUpdate,
|
|
100
|
+
onCourseRemove,
|
|
101
|
+
onCellSelect,
|
|
102
|
+
onCourseFormRequest,
|
|
103
|
+
onPlanAdd,
|
|
104
|
+
onPlanToggle,
|
|
105
|
+
onPlanRemove,
|
|
106
|
+
onBackgroundChange,
|
|
107
|
+
onCourseShare,
|
|
108
|
+
onDetailLayoutChange,
|
|
88
109
|
...properties
|
|
89
110
|
} = props;
|
|
90
111
|
const ref = useElementBridge(properties, {
|
|
@@ -94,24 +115,53 @@ function YsSchedule(props) {
|
|
|
94
115
|
"dayTap": onDayTap,
|
|
95
116
|
"swipe": onSwipe,
|
|
96
117
|
"weekPickerOpen": onWeekPickerOpen,
|
|
118
|
+
"transitionStart": onTransitionStart,
|
|
119
|
+
"transitionEnd": onTransitionEnd,
|
|
97
120
|
"guideStep": onGuideStep,
|
|
98
|
-
"guideFinish": onGuideFinish
|
|
99
|
-
|
|
121
|
+
"guideFinish": onGuideFinish,
|
|
122
|
+
"courseAdd": onCourseAdd,
|
|
123
|
+
"courseUpdate": onCourseUpdate,
|
|
124
|
+
"courseRemove": onCourseRemove,
|
|
125
|
+
"cellSelect": onCellSelect,
|
|
126
|
+
"courseFormRequest": onCourseFormRequest,
|
|
127
|
+
"planAdd": onPlanAdd,
|
|
128
|
+
"planToggle": onPlanToggle,
|
|
129
|
+
"planRemove": onPlanRemove,
|
|
130
|
+
"backgroundChange": onBackgroundChange,
|
|
131
|
+
"courseShare": onCourseShare,
|
|
132
|
+
"detailLayoutChange": onDetailLayoutChange
|
|
133
|
+
}, forwardedRef);
|
|
100
134
|
return (0, import_react2.createElement)("ys-schedule", { "ref": ref, "class": className, style });
|
|
101
|
-
}
|
|
135
|
+
});
|
|
102
136
|
|
|
103
137
|
// src/YsToday.tsx
|
|
104
138
|
var import_schedule_elements2 = require("@iyotsuba/schedule-elements");
|
|
105
139
|
var import_react3 = require("react");
|
|
106
140
|
(0, import_schedule_elements2.register)();
|
|
107
|
-
|
|
108
|
-
const {
|
|
141
|
+
var YsToday = (0, import_react3.forwardRef)(function YsToday2(props, forwardedRef) {
|
|
142
|
+
const {
|
|
143
|
+
className,
|
|
144
|
+
style,
|
|
145
|
+
onCourseTap,
|
|
146
|
+
onWidgetTap,
|
|
147
|
+
onWidgetsChange,
|
|
148
|
+
onLayoutChange,
|
|
149
|
+
onLayoutEditing,
|
|
150
|
+
onWidgetMove,
|
|
151
|
+
onWidgetResize,
|
|
152
|
+
...properties
|
|
153
|
+
} = props;
|
|
109
154
|
const ref = useElementBridge(properties, {
|
|
110
155
|
courseTap: onCourseTap,
|
|
111
|
-
widgetTap: onWidgetTap
|
|
112
|
-
|
|
156
|
+
widgetTap: onWidgetTap,
|
|
157
|
+
"update:widgets": onWidgetsChange,
|
|
158
|
+
layoutChange: onLayoutChange,
|
|
159
|
+
layoutEditing: onLayoutEditing,
|
|
160
|
+
widgetMove: onWidgetMove,
|
|
161
|
+
widgetResize: onWidgetResize
|
|
162
|
+
}, forwardedRef);
|
|
113
163
|
return (0, import_react3.createElement)("ys-today", { "ref": ref, "class": className, style });
|
|
114
|
-
}
|
|
164
|
+
});
|
|
115
165
|
// Annotate the CommonJS export names for ESM import in node:
|
|
116
166
|
0 && (module.exports = {
|
|
117
167
|
YsSchedule,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
|
-
import { Course, DayOverride, CourseTime, BuiltinTransitionName, TransitionSpec, ThemeTokens, WeatherSnapshot, GuideConfig, DisplayCourse, GuideStep } from '@iyotsuba/schedule-core';
|
|
4
|
-
export { BuiltinTransitionName, Course, CourseTime, DayOverride, DisplayCourse, GuideConfig, GuideStep, ThemeTokens, TransitionSpec, WeatherProvider, WeatherSnapshot } from '@iyotsuba/schedule-core';
|
|
3
|
+
import { DetailHero, DetailLayout, DetailField, DetailAction, Course, DayOverride, CourseTime, BuiltinTransitionName, TransitionSpec, ThemeTokens, WeatherSnapshot, GuideConfig, DayPlanMap, ScheduleDensity, PaletteName, CardEffect, WeatherCardConfig, WeekdayWeatherMode, SheetConfig, DisplayCourse, GuideStep } from '@iyotsuba/schedule-core';
|
|
4
|
+
export { BuiltinTransitionName, CardEffect, Course, CourseTime, DayOverride, DayPlan, DayPlanMap, DetailAction, DetailField, DetailHero, DetailLayout, DisplayCourse, GuideConfig, GuideMode, GuideStep, PaletteName, ScheduleDensity, SheetConfig, SheetKind, SheetPlacement, ThemeTokens, TransitionSpec, WeatherCardConfig, WeatherProvider, WeatherSnapshot, WeekModel, WeekdayWeatherMode } from '@iyotsuba/schedule-core';
|
|
5
5
|
|
|
6
|
+
interface ScheduleBackground {
|
|
7
|
+
image?: string;
|
|
8
|
+
opacity?: number;
|
|
9
|
+
blur?: number;
|
|
10
|
+
}
|
|
11
|
+
interface ScheduleDetailConfig {
|
|
12
|
+
hero?: DetailHero;
|
|
13
|
+
layout?: DetailLayout;
|
|
14
|
+
fields?: DetailField[];
|
|
15
|
+
actions?: DetailAction[];
|
|
16
|
+
adjustable?: boolean;
|
|
17
|
+
emptyText?: string;
|
|
18
|
+
emptyTexts?: Partial<Record<DetailField, string>>;
|
|
19
|
+
}
|
|
6
20
|
interface YsScheduleProps {
|
|
7
21
|
courses: Course[];
|
|
8
22
|
week?: number;
|
|
@@ -24,6 +38,20 @@ interface YsScheduleProps {
|
|
|
24
38
|
weekPicker?: 'builtin' | 'none';
|
|
25
39
|
courseDetail?: 'builtin' | 'none';
|
|
26
40
|
guide?: GuideConfig | false;
|
|
41
|
+
editable?: boolean;
|
|
42
|
+
courseForm?: 'builtin' | 'none';
|
|
43
|
+
dayPlans?: DayPlanMap;
|
|
44
|
+
dayPlanner?: 'builtin' | 'none';
|
|
45
|
+
background?: ScheduleBackground | null;
|
|
46
|
+
backgroundPicker?: 'builtin' | 'none';
|
|
47
|
+
density?: ScheduleDensity;
|
|
48
|
+
palette?: PaletteName | string[];
|
|
49
|
+
cardEffect?: CardEffect;
|
|
50
|
+
weatherCard?: WeatherCardConfig | false;
|
|
51
|
+
weekdayWeather?: WeekdayWeatherMode;
|
|
52
|
+
weatherScene?: boolean;
|
|
53
|
+
sheets?: SheetConfig;
|
|
54
|
+
detail?: ScheduleDetailConfig;
|
|
27
55
|
locale?: Record<string, unknown>;
|
|
28
56
|
onWeekChange?: (week: number, previous: number) => void;
|
|
29
57
|
/** 受控用法:配合 week 使用 */
|
|
@@ -32,40 +60,81 @@ interface YsScheduleProps {
|
|
|
32
60
|
onDayTap?: (weekday: number, date: Date | null) => void;
|
|
33
61
|
onSwipe?: (direction: 1 | -1) => void;
|
|
34
62
|
onWeekPickerOpen?: () => void;
|
|
63
|
+
onTransitionStart?: (spec: TransitionSpec) => void;
|
|
64
|
+
onTransitionEnd?: (spec: TransitionSpec) => void;
|
|
35
65
|
onGuideStep?: (step: GuideStep, index: number) => void;
|
|
36
66
|
onGuideFinish?: () => void;
|
|
67
|
+
onCourseAdd?: (course: Course) => void;
|
|
68
|
+
onCourseUpdate?: (course: Course, previousId: string) => void;
|
|
69
|
+
onCourseRemove?: (course: DisplayCourse) => void;
|
|
70
|
+
onCellSelect?: (weekday: number, startSection: number, endSection: number) => void;
|
|
71
|
+
onCourseFormRequest?: (prefill: Partial<Course>) => void;
|
|
72
|
+
onPlanAdd?: (dateKey: string, text: string) => void;
|
|
73
|
+
onPlanToggle?: (dateKey: string, id: string) => void;
|
|
74
|
+
onPlanRemove?: (dateKey: string, id: string) => void;
|
|
75
|
+
onBackgroundChange?: (dataUrl: string | null) => void;
|
|
76
|
+
onCourseShare?: (course: DisplayCourse) => void;
|
|
77
|
+
onDetailLayoutChange?: (layout: DetailLayout) => void;
|
|
37
78
|
className?: string;
|
|
38
79
|
style?: CSSProperties;
|
|
39
80
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
81
|
+
interface YsScheduleElement extends HTMLElement {
|
|
82
|
+
setWeek: (week: number) => void;
|
|
83
|
+
getWeek: () => number;
|
|
84
|
+
next: () => void;
|
|
85
|
+
previous: () => void;
|
|
86
|
+
openCourse: (courseId: string) => void;
|
|
87
|
+
openWeekPicker: () => void;
|
|
88
|
+
openCourseForm: (prefill?: Partial<Course>) => void;
|
|
89
|
+
openDayPlanner: (date?: Date) => void;
|
|
90
|
+
openBackgroundPicker: () => void;
|
|
91
|
+
closeSheets: () => void;
|
|
92
|
+
startGuide: () => void;
|
|
93
|
+
}
|
|
94
|
+
declare const YsSchedule: react.ForwardRefExoticComponent<YsScheduleProps & react.RefAttributes<YsScheduleElement>>;
|
|
45
95
|
|
|
96
|
+
type TodayWidgetSize = 'compact' | 'standard' | 'large' | '1x1' | '1x2' | '2x1' | '2x2';
|
|
97
|
+
type TodayResizeCorner = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
98
|
+
interface TodayWidgetConfig {
|
|
99
|
+
id: string;
|
|
100
|
+
enabled?: boolean;
|
|
101
|
+
size?: TodayWidgetSize;
|
|
102
|
+
}
|
|
46
103
|
interface YsTodayProps {
|
|
47
104
|
courses: Course[];
|
|
48
105
|
termStart: Date;
|
|
49
106
|
totalWeeks?: number;
|
|
50
107
|
overrides?: DayOverride[];
|
|
51
108
|
courseTimes?: CourseTime[] | 'standard';
|
|
52
|
-
widgets?:
|
|
53
|
-
id: string;
|
|
54
|
-
enabled?: boolean;
|
|
55
|
-
}>;
|
|
109
|
+
widgets?: TodayWidgetConfig[];
|
|
56
110
|
theme?: 'light' | 'dark' | Partial<ThemeTokens>;
|
|
57
111
|
weather?: WeatherSnapshot | null;
|
|
58
112
|
now?: Date;
|
|
59
113
|
title?: string;
|
|
114
|
+
dayPlans?: DayPlanMap;
|
|
115
|
+
arrangeable?: boolean;
|
|
116
|
+
weatherScene?: boolean;
|
|
117
|
+
reduceMotion?: boolean;
|
|
118
|
+
emptyText?: string;
|
|
119
|
+
emptyTexts?: Record<string, string>;
|
|
60
120
|
onCourseTap?: (course: DisplayCourse) => void;
|
|
61
121
|
onWidgetTap?: (id: string) => void;
|
|
122
|
+
onWidgetsChange?: (widgets: TodayWidgetConfig[]) => void;
|
|
123
|
+
onLayoutChange?: (widgets: TodayWidgetConfig[]) => void;
|
|
124
|
+
onLayoutEditing?: (editing: boolean) => void;
|
|
125
|
+
onWidgetMove?: (id: string, from: number, to: number) => void;
|
|
126
|
+
onWidgetResize?: (id: string, size: TodayWidgetSize, corner: TodayResizeCorner) => void;
|
|
62
127
|
className?: string;
|
|
63
128
|
style?: CSSProperties;
|
|
64
129
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
130
|
+
interface YsTodayElement extends HTMLElement {
|
|
131
|
+
setWidgets: (widgets: TodayWidgetConfig[]) => void;
|
|
132
|
+
setArranging: (value: boolean, widgetId?: string | null) => void;
|
|
133
|
+
moveWidget: (id: string, offset: -1 | 1) => void;
|
|
134
|
+
resizeWidget: (id: string) => void;
|
|
135
|
+
toggleWidget: (id: string, enabled: boolean) => void;
|
|
136
|
+
layoutReset: () => void;
|
|
137
|
+
}
|
|
138
|
+
declare const YsToday: react.ForwardRefExoticComponent<YsTodayProps & react.RefAttributes<YsTodayElement>>;
|
|
70
139
|
|
|
71
|
-
export { YsSchedule, type YsScheduleProps, YsToday, type YsTodayProps };
|
|
140
|
+
export { type ScheduleBackground, type ScheduleDetailConfig, type TodayResizeCorner, type TodayWidgetConfig, type TodayWidgetSize, YsSchedule, type YsScheduleElement, type YsScheduleProps, YsToday, type YsTodayElement, type YsTodayProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
|
-
import { Course, DayOverride, CourseTime, BuiltinTransitionName, TransitionSpec, ThemeTokens, WeatherSnapshot, GuideConfig, DisplayCourse, GuideStep } from '@iyotsuba/schedule-core';
|
|
4
|
-
export { BuiltinTransitionName, Course, CourseTime, DayOverride, DisplayCourse, GuideConfig, GuideStep, ThemeTokens, TransitionSpec, WeatherProvider, WeatherSnapshot } from '@iyotsuba/schedule-core';
|
|
3
|
+
import { DetailHero, DetailLayout, DetailField, DetailAction, Course, DayOverride, CourseTime, BuiltinTransitionName, TransitionSpec, ThemeTokens, WeatherSnapshot, GuideConfig, DayPlanMap, ScheduleDensity, PaletteName, CardEffect, WeatherCardConfig, WeekdayWeatherMode, SheetConfig, DisplayCourse, GuideStep } from '@iyotsuba/schedule-core';
|
|
4
|
+
export { BuiltinTransitionName, CardEffect, Course, CourseTime, DayOverride, DayPlan, DayPlanMap, DetailAction, DetailField, DetailHero, DetailLayout, DisplayCourse, GuideConfig, GuideMode, GuideStep, PaletteName, ScheduleDensity, SheetConfig, SheetKind, SheetPlacement, ThemeTokens, TransitionSpec, WeatherCardConfig, WeatherProvider, WeatherSnapshot, WeekModel, WeekdayWeatherMode } from '@iyotsuba/schedule-core';
|
|
5
5
|
|
|
6
|
+
interface ScheduleBackground {
|
|
7
|
+
image?: string;
|
|
8
|
+
opacity?: number;
|
|
9
|
+
blur?: number;
|
|
10
|
+
}
|
|
11
|
+
interface ScheduleDetailConfig {
|
|
12
|
+
hero?: DetailHero;
|
|
13
|
+
layout?: DetailLayout;
|
|
14
|
+
fields?: DetailField[];
|
|
15
|
+
actions?: DetailAction[];
|
|
16
|
+
adjustable?: boolean;
|
|
17
|
+
emptyText?: string;
|
|
18
|
+
emptyTexts?: Partial<Record<DetailField, string>>;
|
|
19
|
+
}
|
|
6
20
|
interface YsScheduleProps {
|
|
7
21
|
courses: Course[];
|
|
8
22
|
week?: number;
|
|
@@ -24,6 +38,20 @@ interface YsScheduleProps {
|
|
|
24
38
|
weekPicker?: 'builtin' | 'none';
|
|
25
39
|
courseDetail?: 'builtin' | 'none';
|
|
26
40
|
guide?: GuideConfig | false;
|
|
41
|
+
editable?: boolean;
|
|
42
|
+
courseForm?: 'builtin' | 'none';
|
|
43
|
+
dayPlans?: DayPlanMap;
|
|
44
|
+
dayPlanner?: 'builtin' | 'none';
|
|
45
|
+
background?: ScheduleBackground | null;
|
|
46
|
+
backgroundPicker?: 'builtin' | 'none';
|
|
47
|
+
density?: ScheduleDensity;
|
|
48
|
+
palette?: PaletteName | string[];
|
|
49
|
+
cardEffect?: CardEffect;
|
|
50
|
+
weatherCard?: WeatherCardConfig | false;
|
|
51
|
+
weekdayWeather?: WeekdayWeatherMode;
|
|
52
|
+
weatherScene?: boolean;
|
|
53
|
+
sheets?: SheetConfig;
|
|
54
|
+
detail?: ScheduleDetailConfig;
|
|
27
55
|
locale?: Record<string, unknown>;
|
|
28
56
|
onWeekChange?: (week: number, previous: number) => void;
|
|
29
57
|
/** 受控用法:配合 week 使用 */
|
|
@@ -32,40 +60,81 @@ interface YsScheduleProps {
|
|
|
32
60
|
onDayTap?: (weekday: number, date: Date | null) => void;
|
|
33
61
|
onSwipe?: (direction: 1 | -1) => void;
|
|
34
62
|
onWeekPickerOpen?: () => void;
|
|
63
|
+
onTransitionStart?: (spec: TransitionSpec) => void;
|
|
64
|
+
onTransitionEnd?: (spec: TransitionSpec) => void;
|
|
35
65
|
onGuideStep?: (step: GuideStep, index: number) => void;
|
|
36
66
|
onGuideFinish?: () => void;
|
|
67
|
+
onCourseAdd?: (course: Course) => void;
|
|
68
|
+
onCourseUpdate?: (course: Course, previousId: string) => void;
|
|
69
|
+
onCourseRemove?: (course: DisplayCourse) => void;
|
|
70
|
+
onCellSelect?: (weekday: number, startSection: number, endSection: number) => void;
|
|
71
|
+
onCourseFormRequest?: (prefill: Partial<Course>) => void;
|
|
72
|
+
onPlanAdd?: (dateKey: string, text: string) => void;
|
|
73
|
+
onPlanToggle?: (dateKey: string, id: string) => void;
|
|
74
|
+
onPlanRemove?: (dateKey: string, id: string) => void;
|
|
75
|
+
onBackgroundChange?: (dataUrl: string | null) => void;
|
|
76
|
+
onCourseShare?: (course: DisplayCourse) => void;
|
|
77
|
+
onDetailLayoutChange?: (layout: DetailLayout) => void;
|
|
37
78
|
className?: string;
|
|
38
79
|
style?: CSSProperties;
|
|
39
80
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
81
|
+
interface YsScheduleElement extends HTMLElement {
|
|
82
|
+
setWeek: (week: number) => void;
|
|
83
|
+
getWeek: () => number;
|
|
84
|
+
next: () => void;
|
|
85
|
+
previous: () => void;
|
|
86
|
+
openCourse: (courseId: string) => void;
|
|
87
|
+
openWeekPicker: () => void;
|
|
88
|
+
openCourseForm: (prefill?: Partial<Course>) => void;
|
|
89
|
+
openDayPlanner: (date?: Date) => void;
|
|
90
|
+
openBackgroundPicker: () => void;
|
|
91
|
+
closeSheets: () => void;
|
|
92
|
+
startGuide: () => void;
|
|
93
|
+
}
|
|
94
|
+
declare const YsSchedule: react.ForwardRefExoticComponent<YsScheduleProps & react.RefAttributes<YsScheduleElement>>;
|
|
45
95
|
|
|
96
|
+
type TodayWidgetSize = 'compact' | 'standard' | 'large' | '1x1' | '1x2' | '2x1' | '2x2';
|
|
97
|
+
type TodayResizeCorner = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
98
|
+
interface TodayWidgetConfig {
|
|
99
|
+
id: string;
|
|
100
|
+
enabled?: boolean;
|
|
101
|
+
size?: TodayWidgetSize;
|
|
102
|
+
}
|
|
46
103
|
interface YsTodayProps {
|
|
47
104
|
courses: Course[];
|
|
48
105
|
termStart: Date;
|
|
49
106
|
totalWeeks?: number;
|
|
50
107
|
overrides?: DayOverride[];
|
|
51
108
|
courseTimes?: CourseTime[] | 'standard';
|
|
52
|
-
widgets?:
|
|
53
|
-
id: string;
|
|
54
|
-
enabled?: boolean;
|
|
55
|
-
}>;
|
|
109
|
+
widgets?: TodayWidgetConfig[];
|
|
56
110
|
theme?: 'light' | 'dark' | Partial<ThemeTokens>;
|
|
57
111
|
weather?: WeatherSnapshot | null;
|
|
58
112
|
now?: Date;
|
|
59
113
|
title?: string;
|
|
114
|
+
dayPlans?: DayPlanMap;
|
|
115
|
+
arrangeable?: boolean;
|
|
116
|
+
weatherScene?: boolean;
|
|
117
|
+
reduceMotion?: boolean;
|
|
118
|
+
emptyText?: string;
|
|
119
|
+
emptyTexts?: Record<string, string>;
|
|
60
120
|
onCourseTap?: (course: DisplayCourse) => void;
|
|
61
121
|
onWidgetTap?: (id: string) => void;
|
|
122
|
+
onWidgetsChange?: (widgets: TodayWidgetConfig[]) => void;
|
|
123
|
+
onLayoutChange?: (widgets: TodayWidgetConfig[]) => void;
|
|
124
|
+
onLayoutEditing?: (editing: boolean) => void;
|
|
125
|
+
onWidgetMove?: (id: string, from: number, to: number) => void;
|
|
126
|
+
onWidgetResize?: (id: string, size: TodayWidgetSize, corner: TodayResizeCorner) => void;
|
|
62
127
|
className?: string;
|
|
63
128
|
style?: CSSProperties;
|
|
64
129
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
130
|
+
interface YsTodayElement extends HTMLElement {
|
|
131
|
+
setWidgets: (widgets: TodayWidgetConfig[]) => void;
|
|
132
|
+
setArranging: (value: boolean, widgetId?: string | null) => void;
|
|
133
|
+
moveWidget: (id: string, offset: -1 | 1) => void;
|
|
134
|
+
resizeWidget: (id: string) => void;
|
|
135
|
+
toggleWidget: (id: string, enabled: boolean) => void;
|
|
136
|
+
layoutReset: () => void;
|
|
137
|
+
}
|
|
138
|
+
declare const YsToday: react.ForwardRefExoticComponent<YsTodayProps & react.RefAttributes<YsTodayElement>>;
|
|
70
139
|
|
|
71
|
-
export { YsSchedule, type YsScheduleProps, YsToday, type YsTodayProps };
|
|
140
|
+
export { type ScheduleBackground, type ScheduleDetailConfig, type TodayResizeCorner, type TodayWidgetConfig, type TodayWidgetSize, YsSchedule, type YsScheduleElement, type YsScheduleProps, YsToday, type YsTodayElement, type YsTodayProps };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
// src/YsSchedule.tsx
|
|
2
2
|
import { register } from "@iyotsuba/schedule-elements";
|
|
3
|
-
import { createElement } from "react";
|
|
3
|
+
import { createElement, forwardRef } from "react";
|
|
4
4
|
|
|
5
5
|
// src/useElement.ts
|
|
6
|
-
import { useLayoutEffect, useRef } from "react";
|
|
7
|
-
function useElementBridge(properties, events) {
|
|
6
|
+
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
7
|
+
function useElementBridge(properties, events, forwardedRef) {
|
|
8
8
|
const ref = useRef(null);
|
|
9
|
+
const setRef = useCallback((node) => {
|
|
10
|
+
ref.current = node;
|
|
11
|
+
if (typeof forwardedRef === "function") {
|
|
12
|
+
forwardedRef(node);
|
|
13
|
+
} else if (forwardedRef) {
|
|
14
|
+
forwardedRef.current = node;
|
|
15
|
+
}
|
|
16
|
+
}, [forwardedRef]);
|
|
9
17
|
useLayoutEffect(() => {
|
|
10
18
|
const el = ref.current;
|
|
11
19
|
if (!el) {
|
|
@@ -41,12 +49,12 @@ function useElementBridge(properties, events) {
|
|
|
41
49
|
}
|
|
42
50
|
return () => disposers.forEach((dispose) => dispose());
|
|
43
51
|
});
|
|
44
|
-
return
|
|
52
|
+
return setRef;
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
// src/YsSchedule.tsx
|
|
48
56
|
register();
|
|
49
|
-
|
|
57
|
+
var YsSchedule = forwardRef(function YsSchedule2(props, forwardedRef) {
|
|
50
58
|
const {
|
|
51
59
|
className,
|
|
52
60
|
style,
|
|
@@ -56,8 +64,21 @@ function YsSchedule(props) {
|
|
|
56
64
|
onDayTap,
|
|
57
65
|
onSwipe,
|
|
58
66
|
onWeekPickerOpen,
|
|
67
|
+
onTransitionStart,
|
|
68
|
+
onTransitionEnd,
|
|
59
69
|
onGuideStep,
|
|
60
70
|
onGuideFinish,
|
|
71
|
+
onCourseAdd,
|
|
72
|
+
onCourseUpdate,
|
|
73
|
+
onCourseRemove,
|
|
74
|
+
onCellSelect,
|
|
75
|
+
onCourseFormRequest,
|
|
76
|
+
onPlanAdd,
|
|
77
|
+
onPlanToggle,
|
|
78
|
+
onPlanRemove,
|
|
79
|
+
onBackgroundChange,
|
|
80
|
+
onCourseShare,
|
|
81
|
+
onDetailLayoutChange,
|
|
61
82
|
...properties
|
|
62
83
|
} = props;
|
|
63
84
|
const ref = useElementBridge(properties, {
|
|
@@ -67,24 +88,53 @@ function YsSchedule(props) {
|
|
|
67
88
|
"dayTap": onDayTap,
|
|
68
89
|
"swipe": onSwipe,
|
|
69
90
|
"weekPickerOpen": onWeekPickerOpen,
|
|
91
|
+
"transitionStart": onTransitionStart,
|
|
92
|
+
"transitionEnd": onTransitionEnd,
|
|
70
93
|
"guideStep": onGuideStep,
|
|
71
|
-
"guideFinish": onGuideFinish
|
|
72
|
-
|
|
94
|
+
"guideFinish": onGuideFinish,
|
|
95
|
+
"courseAdd": onCourseAdd,
|
|
96
|
+
"courseUpdate": onCourseUpdate,
|
|
97
|
+
"courseRemove": onCourseRemove,
|
|
98
|
+
"cellSelect": onCellSelect,
|
|
99
|
+
"courseFormRequest": onCourseFormRequest,
|
|
100
|
+
"planAdd": onPlanAdd,
|
|
101
|
+
"planToggle": onPlanToggle,
|
|
102
|
+
"planRemove": onPlanRemove,
|
|
103
|
+
"backgroundChange": onBackgroundChange,
|
|
104
|
+
"courseShare": onCourseShare,
|
|
105
|
+
"detailLayoutChange": onDetailLayoutChange
|
|
106
|
+
}, forwardedRef);
|
|
73
107
|
return createElement("ys-schedule", { "ref": ref, "class": className, style });
|
|
74
|
-
}
|
|
108
|
+
});
|
|
75
109
|
|
|
76
110
|
// src/YsToday.tsx
|
|
77
111
|
import { register as register2 } from "@iyotsuba/schedule-elements";
|
|
78
|
-
import { createElement as createElement2 } from "react";
|
|
112
|
+
import { createElement as createElement2, forwardRef as forwardRef2 } from "react";
|
|
79
113
|
register2();
|
|
80
|
-
|
|
81
|
-
const {
|
|
114
|
+
var YsToday = forwardRef2(function YsToday2(props, forwardedRef) {
|
|
115
|
+
const {
|
|
116
|
+
className,
|
|
117
|
+
style,
|
|
118
|
+
onCourseTap,
|
|
119
|
+
onWidgetTap,
|
|
120
|
+
onWidgetsChange,
|
|
121
|
+
onLayoutChange,
|
|
122
|
+
onLayoutEditing,
|
|
123
|
+
onWidgetMove,
|
|
124
|
+
onWidgetResize,
|
|
125
|
+
...properties
|
|
126
|
+
} = props;
|
|
82
127
|
const ref = useElementBridge(properties, {
|
|
83
128
|
courseTap: onCourseTap,
|
|
84
|
-
widgetTap: onWidgetTap
|
|
85
|
-
|
|
129
|
+
widgetTap: onWidgetTap,
|
|
130
|
+
"update:widgets": onWidgetsChange,
|
|
131
|
+
layoutChange: onLayoutChange,
|
|
132
|
+
layoutEditing: onLayoutEditing,
|
|
133
|
+
widgetMove: onWidgetMove,
|
|
134
|
+
widgetResize: onWidgetResize
|
|
135
|
+
}, forwardedRef);
|
|
86
136
|
return createElement2("ys-today", { "ref": ref, "class": className, style });
|
|
87
|
-
}
|
|
137
|
+
});
|
|
88
138
|
export {
|
|
89
139
|
YsSchedule,
|
|
90
140
|
YsToday
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyotsuba/schedule-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Typed React bindings for the
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"description": "Typed React bindings for the complete Yotsuba schedule and Today experience over custom elements.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"react": ">=18"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@iyotsuba/schedule-
|
|
26
|
-
"@iyotsuba/schedule-
|
|
25
|
+
"@iyotsuba/schedule-elements": "^0.6.1",
|
|
26
|
+
"@iyotsuba/schedule-core": "^0.6.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@testing-library/react": "^16.1.0",
|