@molecule/app-class-schedule-react 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +213 -0
  2. package/package.json +15 -8
package/README.md ADDED
@@ -0,0 +1,213 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T01:50:16.815Z
7
+ -->
8
+
9
+ # @molecule/app-class-schedule-react
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ Weekly class-schedule grid.
16
+
17
+ Renders a 7-day × N-hour time grid with absolutely positioned event
18
+ tiles inside each day column. Overlapping events on the same weekday
19
+ are split into side-by-side lanes. Click handlers fire separately for
20
+ event tiles and empty time slots.
21
+
22
+ Designed for school timetables, virtual classroom schedules, gym /
23
+ studio class calendars, conference tracks, and any other weekly
24
+ recurring time-of-day grid.
25
+
26
+ ## Quick Start
27
+
28
+ ```tsx
29
+ import { ClassSchedule } from '@molecule/app-class-schedule-react'
30
+
31
+ ;<ClassSchedule
32
+ events={[
33
+ { id: 'math', weekday: 1, start: 9 * 60, end: 10 * 60, title: 'Math 101', subtitle: 'Room 4B' },
34
+ { id: 'eng', weekday: 3, start: 11 * 60, end: 12 * 60, title: 'English', subtitle: 'Room 12' },
35
+ ]}
36
+ onEventClick={(e) => console.log('clicked', e.id)}
37
+ onSlotClick={(s) => console.log('empty slot', s)}
38
+ />
39
+ ```
40
+
41
+ ## Type
42
+
43
+ `feature`
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ npm install @molecule/app-class-schedule-react @molecule/app-react @molecule/app-ui react
49
+ npm install -D @types/react
50
+ ```
51
+
52
+ ## API
53
+
54
+ ### Interfaces
55
+
56
+ #### `ClassScheduleProps`
57
+
58
+ Props for the {@link ClassSchedule} weekly timetable component.
59
+
60
+ ```typescript
61
+ interface ClassScheduleProps {
62
+ /** Events to render. */
63
+ events: ScheduleEvent[]
64
+ /** First day-of-week (`0` = Sunday, `1` = Monday). Defaults to `1`. */
65
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6
66
+ /** Visible hour range as `[startHour, endHour]` in 24-hour clock. Defaults to `[8, 18]`. */
67
+ dayHours?: [number, number]
68
+ /** Pixel height of one hour row. Defaults to `60`. */
69
+ cellHeight?: number
70
+ /** Whether to show Saturday + Sunday columns. Defaults to `true`. */
71
+ showWeekendCols?: boolean
72
+ /** Locale for weekday name formatting (passes through to `Intl.DateTimeFormat`). */
73
+ locale?: string
74
+ /** Called when an event tile is clicked. */
75
+ onEventClick?: (event: ScheduleEvent) => void
76
+ /** Called when an empty grid cell is clicked. */
77
+ onSlotClick?: (slot: ScheduleSlot) => void
78
+ /** Extra classes for the root container. */
79
+ className?: string
80
+ }
81
+ ```
82
+
83
+ #### `ScheduleEvent`
84
+
85
+ A single event on the weekly schedule grid.
86
+
87
+ `start` and `end` are minute offsets from midnight (`0`–`1440`). For
88
+ example a class running 09:00–10:30 is `{ start: 540, end: 630 }`.
89
+
90
+ ```typescript
91
+ interface ScheduleEvent {
92
+ /** Stable identifier (used as React key + passed to click handlers). */
93
+ id: string
94
+ /** ISO weekday: `0` = Sunday, `1` = Monday … `6` = Saturday. */
95
+ weekday: 0 | 1 | 2 | 3 | 4 | 5 | 6
96
+ /** Start time in minutes from midnight (e.g. `540` = 09:00). */
97
+ start: number
98
+ /** End time in minutes from midnight (e.g. `630` = 10:30). */
99
+ end: number
100
+ /** Primary label rendered inside the event tile. */
101
+ title: ReactNode
102
+ /** Secondary line — typically room or location. */
103
+ subtitle?: ReactNode
104
+ /** Tertiary line — typically teacher or instructor. */
105
+ meta?: ReactNode
106
+ /** Optional accent color applied as a left border on the tile. */
107
+ accentColor?: string
108
+ }
109
+ ```
110
+
111
+ #### `ScheduleSlot`
112
+
113
+ Empty-slot click payload — `weekday` plus the start of the clicked hour
114
+ (in minutes from midnight, snapped down to the row).
115
+
116
+ ```typescript
117
+ interface ScheduleSlot {
118
+ weekday: 0 | 1 | 2 | 3 | 4 | 5 | 6
119
+ /** Hour-of-day boundary in minutes (e.g. `540` for the 09:00 row). */
120
+ start: number
121
+ }
122
+ ```
123
+
124
+ ### Functions
125
+
126
+ #### `assignLanes(events)`
127
+
128
+ Lay out events that share a weekday into non-overlapping side-by-side
129
+ lanes. Each event gets a `lane` index (0…N) and a `lanes` count for the
130
+ group it belongs to so the caller can compute width/left as
131
+ `width = (1/lanes) * 100%` / `left = (lane/lanes) * 100%`.
132
+
133
+ ```typescript
134
+ function assignLanes(events: E[]): { event: E; lane: number; lanes: number }[]
135
+ ```
136
+
137
+ - `events` — Events occurring on a single weekday.
138
+
139
+ **Returns:** Array of `{ event, lane, lanes }` records, in input order.
140
+
141
+ #### `ClassSchedule(props)`
142
+
143
+ Weekly class-schedule grid. Renders a 7-column (or 5-column when
144
+ `showWeekendCols` is `false`) timetable with hour rows down the left
145
+ and absolutely positioned event tiles inside each day column. Events
146
+ that overlap on the same weekday are split into side-by-side lanes.
147
+
148
+ Suitable for school timetables, virtual-classroom schedules, gym
149
+ class calendars, conference tracks, or any weekly recurring time
150
+ grid.
151
+
152
+ ```typescript
153
+ function ClassSchedule({
154
+ events,
155
+ weekStartsOn = 1,
156
+ dayHours = [8, 18],
157
+ cellHeight = 60,
158
+ showWeekendCols = true,
159
+ locale,
160
+ onEventClick,
161
+ onSlotClick,
162
+ className,
163
+ }: ClassScheduleProps): ReactElement<unknown, string | JSXElementConstructor<any>>
164
+ ```
165
+
166
+ - `props` — Component props.
167
+ - `props.events` — Events to render.
168
+ - `props.weekStartsOn` — First day-of-week (`0` Sun, `1` Mon).
169
+ - `props.dayHours` — Visible hour range `[start, end]`.
170
+ - `props.cellHeight` — Pixel height per hour row.
171
+ - `props.showWeekendCols` — Hide Sat + Sun when `false`.
172
+ - `props.locale` — Locale for weekday names.
173
+ - `props.onEventClick` — Click handler for event tiles.
174
+ - `props.onSlotClick` — Click handler for empty grid cells.
175
+ - `props.className` — Extra classes for the root container.
176
+
177
+ **Returns:** The rendered schedule grid.
178
+
179
+ #### `formatHourLabel(minutes)`
180
+
181
+ Format a minute-of-day value (0–1440) as `HH:MM` 24-hour clock.
182
+
183
+ ```typescript
184
+ function formatHourLabel(minutes: number): string
185
+ ```
186
+
187
+ - `minutes` — Minutes from midnight.
188
+
189
+ **Returns:** Zero-padded `HH:MM` string.
190
+
191
+ ## Injection Notes
192
+
193
+ ### Requirements
194
+
195
+ Peer dependencies:
196
+
197
+ - `@molecule/app-react` ^1.0.1
198
+ - `@molecule/app-ui` ^1.0.1
199
+ - `react` ^18.0.0 || ^19.0.0
200
+
201
+ ### Runtime Dependencies
202
+
203
+ - `@molecule/app-react`
204
+ - `@molecule/app-ui`
205
+ - `react`
206
+
207
+ Pair with `@molecule/app-locales-class-schedule` for translations
208
+ in 79 languages. All styling routes through `getClassMap()`; all
209
+ user-facing text routes through `t()`.
210
+
211
+ ## Translations
212
+
213
+ Translation strings are provided by `@molecule/app-locales-class-schedule`.
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@molecule/app-class-schedule-react",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Weekly class-schedule grid — 7-day × N-hour time grid with absolutely positioned events, click-event vs click-empty-slot dispatch, side-by-side stacking for overlaps",
5
+ "homepage": "https://www.molecule.dev/packages/app-class-schedule-react",
5
6
  "type": "module",
6
7
  "main": "dist/index.js",
7
8
  "types": "dist/index.d.ts",
@@ -17,7 +18,8 @@
17
18
  }
18
19
  },
19
20
  "files": [
20
- "dist"
21
+ "dist",
22
+ "README.md"
21
23
  ],
22
24
  "keywords": [
23
25
  "molecule",
@@ -27,15 +29,20 @@
27
29
  "react"
28
30
  ],
29
31
  "license": "Apache-2.0",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/molecule-dev/molecule.git",
35
+ "directory": "packages/app/features/class-schedule-react"
36
+ },
30
37
  "peerDependencies": {
31
- "@molecule/app-react": "^1.0.0",
32
- "@molecule/app-ui": "^1.0.0",
38
+ "@molecule/app-react": "^1.0.1",
39
+ "@molecule/app-ui": "^1.0.1",
33
40
  "react": "^18.0.0 || ^19.0.0"
34
41
  },
35
42
  "devDependencies": {
36
- "@molecule/app-i18n": "1.0.0",
37
- "@molecule/app-react": "1.0.0",
38
- "@molecule/app-ui": "1.0.0",
43
+ "@molecule/app-i18n": "1.0.2",
44
+ "@molecule/app-react": "1.5.1",
45
+ "@molecule/app-ui": "1.1.1",
39
46
  "@testing-library/react": "16.3.2",
40
47
  "@types/node": "26.1.2",
41
48
  "@types/react": "19.2.17",
@@ -43,6 +50,6 @@
43
50
  "react": "19.2.8",
44
51
  "react-dom": "19.2.8",
45
52
  "typescript": "6.0.3",
46
- "vitest": "4.1.10"
53
+ "vitest": "4.1.11"
47
54
  }
48
55
  }