@savvycal/calendar 0.10.3 → 0.11.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/README.md +187 -20
- package/dist/components/day-grid-view/AllDayEventChip.d.ts.map +1 -1
- package/dist/components/day-grid-view/AllDayEventChip.js +49 -49
- package/dist/components/day-grid-view/AllDaySection.d.ts +15 -0
- package/dist/components/day-grid-view/AllDaySection.d.ts.map +1 -1
- package/dist/components/day-grid-view/AllDaySection.js +93 -29
- package/dist/components/day-grid-view/BackgroundEventLayer.d.ts +19 -0
- package/dist/components/day-grid-view/BackgroundEventLayer.d.ts.map +1 -0
- package/dist/components/day-grid-view/BackgroundEventLayer.js +55 -0
- package/dist/components/day-grid-view/DayGridView.d.ts +1 -1
- package/dist/components/day-grid-view/DayGridView.d.ts.map +1 -1
- package/dist/components/day-grid-view/DayGridView.js +375 -263
- package/dist/components/day-grid-view/defaults.d.ts.map +1 -1
- package/dist/components/day-grid-view/defaults.js +2 -2
- package/dist/components/month-view/MonthEventItem.d.ts +22 -0
- package/dist/components/month-view/MonthEventItem.d.ts.map +1 -0
- package/dist/components/month-view/MonthEventItem.js +95 -0
- package/dist/components/month-view/MonthMoreButton.d.ts +22 -0
- package/dist/components/month-view/MonthMoreButton.d.ts.map +1 -0
- package/dist/components/month-view/MonthMoreButton.js +122 -0
- package/dist/components/month-view/MonthView.d.ts +3 -0
- package/dist/components/month-view/MonthView.d.ts.map +1 -0
- package/dist/components/month-view/MonthView.js +281 -0
- package/dist/components/month-view/MonthWeekRow.d.ts +40 -0
- package/dist/components/month-view/MonthWeekRow.d.ts.map +1 -0
- package/dist/components/month-view/MonthWeekRow.js +192 -0
- package/dist/components/month-view/defaults.d.ts +3 -0
- package/dist/components/month-view/defaults.d.ts.map +1 -0
- package/dist/components/month-view/defaults.js +32 -0
- package/dist/components/month-view/index.d.ts +3 -0
- package/dist/components/month-view/index.d.ts.map +1 -0
- package/dist/components/resource-grid-view/ResourceGridView.d.ts +1 -1
- package/dist/components/resource-grid-view/ResourceGridView.d.ts.map +1 -1
- package/dist/components/resource-grid-view/ResourceGridView.js +163 -155
- package/dist/components/resource-grid-view/defaults.js +1 -1
- package/dist/components/shared/AnchoredPopover.d.ts +35 -0
- package/dist/components/shared/AnchoredPopover.d.ts.map +1 -0
- package/dist/components/shared/AnchoredPopover.js +91 -0
- package/dist/components/shared/EventChip.d.ts.map +1 -1
- package/dist/components/shared/EventChip.js +58 -64
- package/dist/components/shared/OverflowChip.d.ts.map +1 -1
- package/dist/components/shared/OverflowChip.js +67 -89
- package/dist/components/shared/SelectionOverlay.d.ts +1 -0
- package/dist/components/shared/SelectionOverlay.d.ts.map +1 -1
- package/dist/components/shared/SelectionOverlay.js +28 -27
- package/dist/components/shared/SlotInteractionLayer.d.ts +27 -5
- package/dist/components/shared/SlotInteractionLayer.d.ts.map +1 -1
- package/dist/components/shared/SlotInteractionLayer.js +186 -145
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -10
- package/dist/lib/accessibility.d.ts +8 -0
- package/dist/lib/accessibility.d.ts.map +1 -1
- package/dist/lib/accessibility.js +31 -4
- package/dist/lib/lanes.d.ts +25 -0
- package/dist/lib/lanes.d.ts.map +1 -0
- package/dist/lib/lanes.js +32 -0
- package/dist/lib/month.d.ts +64 -0
- package/dist/lib/month.d.ts.map +1 -0
- package/dist/lib/month.js +110 -0
- package/dist/lib/overlap.d.ts.map +1 -1
- package/dist/lib/overlap.js +157 -179
- package/dist/lib/time.d.ts +4 -0
- package/dist/lib/time.d.ts.map +1 -1
- package/dist/lib/time.js +20 -12
- package/dist/types/calendar.d.ts +164 -0
- package/dist/types/calendar.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @savvycal/calendar
|
|
2
2
|
|
|
3
|
-
A fully-featured calendar component library built with React, Tailwind CSS v4, and the Temporal API. Includes a resource grid view (resources as columns)
|
|
3
|
+
A fully-featured calendar component library built with React, Tailwind CSS v4, and the Temporal API. Includes a resource grid view (resources as columns), a day grid view (days as columns), and a month view.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -126,11 +126,12 @@ function App() {
|
|
|
126
126
|
|
|
127
127
|
### Render props
|
|
128
128
|
|
|
129
|
-
| Prop
|
|
130
|
-
|
|
|
131
|
-
| `renderHeader`
|
|
132
|
-
| `renderEvent`
|
|
133
|
-
| `renderCorner`
|
|
129
|
+
| Prop | Type | Description |
|
|
130
|
+
| ------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
131
|
+
| `renderHeader` | `(props: { resource: CalendarResource }) => ReactNode` | Custom renderer for resource column headers. |
|
|
132
|
+
| `renderEvent` | `(props: { event: TimedCalendarEvent, position: PositionedEvent }) => ReactNode` | Custom renderer for timed events. |
|
|
133
|
+
| `renderCorner` | `() => ReactNode` | Custom renderer for the top-left corner cell (e.g. time zone label). |
|
|
134
|
+
| `formatGutterLabel` | `(time: Temporal.PlainTime) => string` | Formats the time gutter labels. Return `""` to hide a label. Default: 12-hour labels such as "9 am". |
|
|
134
135
|
|
|
135
136
|
## DayGridView
|
|
136
137
|
|
|
@@ -192,25 +193,42 @@ The following props work identically to `ResourceGridView`: `timeAxis`, `initial
|
|
|
192
193
|
|
|
193
194
|
#### Selection
|
|
194
195
|
|
|
195
|
-
| Prop
|
|
196
|
-
|
|
|
197
|
-
| `selectedRange`
|
|
198
|
-
| `onSelect`
|
|
199
|
-
| `selectionRef`
|
|
196
|
+
| Prop | Type | Description |
|
|
197
|
+
| ------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
198
|
+
| `selectedRange` | `DayGridSelectedRange \| null` | The currently selected time range (controlled). |
|
|
199
|
+
| `onSelect` | `(range: DayGridSelectedRange \| null) => void` | Called when the user selects or clears a range. |
|
|
200
|
+
| `selectionRef` | `Ref<HTMLDivElement>` | Ref attached to the selection overlay element (the first day of a multi-day selection). |
|
|
201
|
+
| `multiDaySelection` | `boolean` | Let a drag span several days. Dragging across day columns repeats the time window on each day; dragging across the all-day row selects whole days (`allDay: true`), drawn in the all-day row. The range reports its last day in `endDate`. |
|
|
202
|
+
| `selectionLingerMs` | `number` | How long (ms) the selection stays in the DOM after clearing, so popover close transitions keep their reference. Default: `0`. |
|
|
203
|
+
|
|
204
|
+
#### Background events
|
|
205
|
+
|
|
206
|
+
| Prop | Type | Description |
|
|
207
|
+
| ----------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------- |
|
|
208
|
+
| `backgroundEvents` | `BackgroundEvent[]` | Blocks of time drawn across the full width of their day columns. They ignore the pointer. |
|
|
209
|
+
| `renderBackgroundEvent` | `(props: { event: BackgroundEvent, height: number }) => ReactNode` | Renders the content of a background event inside its positioned block. |
|
|
210
|
+
|
|
211
|
+
#### Scrolling
|
|
212
|
+
|
|
213
|
+
| Prop | Type | Description |
|
|
214
|
+
| ----------- | -------- | ------------------------------------------------------------------------------------- |
|
|
215
|
+
| `scrollKey` | `string` | Re-applies `initialScrollHour` when it changes, as a change of the active range does. |
|
|
200
216
|
|
|
201
217
|
#### Slot click
|
|
202
218
|
|
|
203
|
-
| Prop | Type
|
|
204
|
-
| ------------- |
|
|
205
|
-
| `onSlotClick` | `(info: { date, startTime, endTime }) => void`
|
|
219
|
+
| Prop | Type | Description |
|
|
220
|
+
| ------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- |
|
|
221
|
+
| `onSlotClick` | `(info: { date, startTime, endTime }) => void` | Called when an empty time slot is clicked. Receives the `date` (PlainDate) and time range. |
|
|
222
|
+
| `onSlotHover` | `(info: { date, startTime, endTime } \| null) => void` | Called when the hovered slot changes, and with `null` when the pointer leaves. Requires `snapDuration`. |
|
|
206
223
|
|
|
207
224
|
#### Render props
|
|
208
225
|
|
|
209
|
-
| Prop
|
|
210
|
-
|
|
|
211
|
-
| `renderHeader`
|
|
212
|
-
| `renderEvent`
|
|
213
|
-
| `renderCorner`
|
|
226
|
+
| Prop | Type | Description |
|
|
227
|
+
| ------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
228
|
+
| `renderHeader` | `(props: { date: PlainDate, isToday: boolean }) => ReactNode` | Custom renderer for day column headers. |
|
|
229
|
+
| `renderEvent` | `(props: { event: TimedCalendarEvent, position: PositionedEvent }) => ReactNode` | Custom renderer for timed events. |
|
|
230
|
+
| `renderCorner` | `(props: { timeZone: string }) => ReactNode` | Custom renderer for the top-left corner cell (e.g. time zone label). |
|
|
231
|
+
| `formatGutterLabel` | `(time: Temporal.PlainTime) => string` | Formats the time gutter labels. Return `""` to hide a label. |
|
|
214
232
|
|
|
215
233
|
### DayGridSelectedRange
|
|
216
234
|
|
|
@@ -218,6 +236,24 @@ The following props work identically to `ResourceGridView`: `timeAxis`, `initial
|
|
|
218
236
|
interface DayGridSelectedRange {
|
|
219
237
|
startTime: Temporal.ZonedDateTime;
|
|
220
238
|
endTime: Temporal.ZonedDateTime;
|
|
239
|
+
// Last selected day (inclusive) of a multi-day selection, which repeats the
|
|
240
|
+
// startTime–endTime window on each day. Omitted for one day.
|
|
241
|
+
endDate?: Temporal.PlainDate;
|
|
242
|
+
// True for whole days selected along the all-day row. startTime and endTime
|
|
243
|
+
// then span the first day, midnight to midnight.
|
|
244
|
+
allDay?: boolean;
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### BackgroundEvent
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
interface BackgroundEvent {
|
|
252
|
+
id: string;
|
|
253
|
+
startTime: Temporal.ZonedDateTime;
|
|
254
|
+
endTime: Temporal.ZonedDateTime;
|
|
255
|
+
layer?: 'below' | 'above'; // Beneath timed events (default) or above them.
|
|
256
|
+
className?: string; // Applied to the positioned block.
|
|
221
257
|
}
|
|
222
258
|
```
|
|
223
259
|
|
|
@@ -233,6 +269,126 @@ Extends `GridViewClassNames` with day-specific keys:
|
|
|
233
269
|
|
|
234
270
|
All shared keys from `GridViewClassNames` (root, grid, event, etc.) also apply.
|
|
235
271
|
|
|
272
|
+
## MonthView
|
|
273
|
+
|
|
274
|
+
A month grid that works like Google Calendar's month view:
|
|
275
|
+
|
|
276
|
+
- All-day events and events spanning more than one day (including overnight timed events) render as bars that wrap across week rows.
|
|
277
|
+
- Single-day timed events render as a colored dot, start time, and title.
|
|
278
|
+
- Each day shows as many event rows as its cell height allows. When a day needs more, its last row becomes a "+N more" button that opens a popover listing every event on that day. A multi-day bar is hidden in a week if it doesn't fit on every day it covers, and it's counted in "+N more" on each of those days.
|
|
279
|
+
- Leading and trailing days from adjacent months are shown (muted) along with their events.
|
|
280
|
+
|
|
281
|
+
### Quick start
|
|
282
|
+
|
|
283
|
+
```tsx
|
|
284
|
+
import { MonthView, Temporal } from '@savvycal/calendar';
|
|
285
|
+
|
|
286
|
+
const month = Temporal.Now.plainDateISO().toPlainYearMonth();
|
|
287
|
+
|
|
288
|
+
function App() {
|
|
289
|
+
return (
|
|
290
|
+
<div style={{ height: 720 }}>
|
|
291
|
+
<MonthView
|
|
292
|
+
month={month}
|
|
293
|
+
timeZone="America/Chicago"
|
|
294
|
+
events={events}
|
|
295
|
+
className="h-full"
|
|
296
|
+
/>
|
|
297
|
+
</div>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Week rows stretch to fill the root element's height, so give it a height (e.g. `className="h-full"` inside a sized container). Without one, rows render at `minWeekHeight`.
|
|
303
|
+
|
|
304
|
+
### MonthView props
|
|
305
|
+
|
|
306
|
+
#### Required
|
|
307
|
+
|
|
308
|
+
| Prop | Type | Description |
|
|
309
|
+
| ---------- | ------------------------- | ----------------------------------------------------- |
|
|
310
|
+
| `month` | `Temporal.PlainYearMonth` | The month to display. |
|
|
311
|
+
| `timeZone` | `string` | IANA time zone identifier (e.g. `"America/Chicago"`). |
|
|
312
|
+
| `events` | `CalendarEvent[]` | Array of timed and/or all-day events. |
|
|
313
|
+
|
|
314
|
+
#### Layout
|
|
315
|
+
|
|
316
|
+
| Prop | Type | Default | Description |
|
|
317
|
+
| ---------------- | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
|
|
318
|
+
| `weekStartsOn` | `number` | `7` | First day of the week, using Temporal's numbering (`1` = Monday … `7` = Sunday). |
|
|
319
|
+
| `fixedWeekCount` | `boolean` | `false` | Always render six week rows, so the grid height doesn't change between months. |
|
|
320
|
+
| `minWeekHeight` | `number` | `100` | Minimum height in pixels for each week row. When the container is shorter, the grid scrolls. |
|
|
321
|
+
| `eventHeight` | `number` | `20` | Height in pixels of each event row inside a day cell. |
|
|
322
|
+
| `maxEventRows` | `number` | — | Hard cap on event rows per day (including the "+N more" row). Omit to fit as many as the cell height allows. |
|
|
323
|
+
| `className` | `string` | — | Class name applied to the root element. |
|
|
324
|
+
| `classNames` | `MonthViewClassNames` | — | Override default class names for internal elements. See [MonthViewClassNames](#monthviewclassnames). |
|
|
325
|
+
|
|
326
|
+
#### Events & interaction
|
|
327
|
+
|
|
328
|
+
| Prop | Type | Description |
|
|
329
|
+
| ----------------------- | ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
330
|
+
| `onEventClick` | `(event: CalendarEvent) => void` | Called when an event is clicked (in a cell or in the "+N more" popover). |
|
|
331
|
+
| `onDayNumberClick` | `(date: Temporal.PlainDate) => void` | Called when a day number is clicked (e.g. to navigate to a day view). Day numbers render as buttons only when this is set. |
|
|
332
|
+
| `selectedEventId` | `string \| null` | ID of the currently selected event (controlled). |
|
|
333
|
+
| `selectedEventRef` | `Ref<HTMLElement>` | Ref attached to the selected event's first visible segment. If the event is hidden, it attaches to the "+N more" button instead. |
|
|
334
|
+
| `onOverflowClick` | `(info: MonthOverflowClickInfo) => void` | Called when a "+N more" button opens. `info.events` is every event on `info.date`; `info.anchor` is the button. |
|
|
335
|
+
| `renderOverflowPopover` | `(props: MonthOverflowPopoverRenderProps) => ReactNode` | Replace the built-in "+N more" popover content. The button still handles open/close and positioning. |
|
|
336
|
+
| `renderHeader` | `(props: { dayOfWeek, date }) => ReactNode` | Custom renderer for weekday header cells. `date` is the first displayed date for that column. |
|
|
337
|
+
|
|
338
|
+
#### Selection
|
|
339
|
+
|
|
340
|
+
Clicking empty space in a day selects that day; dragging across days selects a range. Press Escape to clear. By default the selection renders like Google Calendar's quick-create chip: a placeholder bar titled "(No title)" pinned to the top of each selected day, so `selectionRef` can anchor a create popover beside it.
|
|
341
|
+
|
|
342
|
+
| Prop | Type | Description |
|
|
343
|
+
| --------------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
344
|
+
| `selectedRange` | `MonthSelectedRange \| null` | The currently selected date range (controlled). |
|
|
345
|
+
| `onSelect` | `(range: MonthSelectedRange \| null) => void` | Called when the user selects or clears a range. Selection is disabled when omitted. |
|
|
346
|
+
| `selectionRef` | `Ref<HTMLDivElement>` | Ref attached to the selection (placeholder bar or highlight) in the last selected week. |
|
|
347
|
+
| `selectionAppearance` | `SelectionAppearance` | Default `{ style: 'event' }` renders the placeholder bar; set `eventData` to change its title or color. `'highlight'` tints the selected day cells instead. |
|
|
348
|
+
|
|
349
|
+
### MonthSelectedRange
|
|
350
|
+
|
|
351
|
+
```ts
|
|
352
|
+
interface MonthSelectedRange {
|
|
353
|
+
startDate: Temporal.PlainDate;
|
|
354
|
+
endDate: Temporal.PlainDate; // inclusive
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### MonthViewClassNames
|
|
359
|
+
|
|
360
|
+
| Key | Description |
|
|
361
|
+
| ---------------------- | -------------------------------------------------------- |
|
|
362
|
+
| `root` | Outermost wrapper (scroll container). |
|
|
363
|
+
| `grid` | The CSS grid element. |
|
|
364
|
+
| `headerCell` | Weekday header cell (sticky). |
|
|
365
|
+
| `week` | A week row. |
|
|
366
|
+
| `dayCell` | Day cell background (borders). |
|
|
367
|
+
| `dayCellOutside` | Additional classes for days outside the displayed month. |
|
|
368
|
+
| `dayNumber` | Day number label. |
|
|
369
|
+
| `dayNumberToday` | Additional classes for today's day number. |
|
|
370
|
+
| `dayNumberOutside` | Additional classes for day numbers outside the month. |
|
|
371
|
+
| `dayNumberButton` | Additional classes when the day number is clickable. |
|
|
372
|
+
| `event` | All-day / multi-day event bar. |
|
|
373
|
+
| `eventSelected` | Additional classes for a selected bar. |
|
|
374
|
+
| `eventColorBar` | Color bar on the left edge of a bar. |
|
|
375
|
+
| `eventTitle` | Bar title text. |
|
|
376
|
+
| `eventTime` | Start time shown on multi-day timed bars. |
|
|
377
|
+
| `timedEvent` | Single-day timed event item. |
|
|
378
|
+
| `timedEventSelected` | Additional classes for a selected timed item. |
|
|
379
|
+
| `timedEventDot` | Colored dot on a timed item. |
|
|
380
|
+
| `timedEventTime` | Start time on a timed item. |
|
|
381
|
+
| `timedEventTitle` | Title on a timed item. |
|
|
382
|
+
| `moreButton` | "+N more" button. |
|
|
383
|
+
| `selectionHighlight` | Selected day range highlight. |
|
|
384
|
+
| `morePopover` | "+N more" popover panel. |
|
|
385
|
+
| `morePopoverHeader` | Popover date header. |
|
|
386
|
+
| `morePopoverWeekday` | Weekday label in the popover header. |
|
|
387
|
+
| `morePopoverDayNumber` | Day number in the popover header. |
|
|
388
|
+
| `morePopoverEvents` | Event list inside the popover. |
|
|
389
|
+
|
|
390
|
+
The library exports `monthViewDefaults` with the default classes for every key, for use with `cn()` (see [`resourceGridViewDefaults`](#resourcegridviewdefaults)).
|
|
391
|
+
|
|
236
392
|
## Data types
|
|
237
393
|
|
|
238
394
|
### CalendarResource
|
|
@@ -263,6 +419,7 @@ interface TimedCalendarEvent {
|
|
|
263
419
|
status?: 'confirmed' | 'canceled' | 'tentative';
|
|
264
420
|
ariaLabel?: string;
|
|
265
421
|
priority?: number;
|
|
422
|
+
interactive?: boolean;
|
|
266
423
|
metadata?: Record<string, unknown>;
|
|
267
424
|
}
|
|
268
425
|
|
|
@@ -278,12 +435,15 @@ interface AllDayCalendarEvent {
|
|
|
278
435
|
status?: 'confirmed' | 'canceled' | 'tentative';
|
|
279
436
|
ariaLabel?: string;
|
|
280
437
|
priority?: number;
|
|
438
|
+
interactive?: boolean;
|
|
281
439
|
metadata?: Record<string, unknown>;
|
|
282
440
|
}
|
|
283
441
|
```
|
|
284
442
|
|
|
285
443
|
The optional `ariaLabel` field provides a plain-text label used for `aria-label` attributes and screen reader announcements. When `title` or `clientName` are React elements (not plain strings), set `ariaLabel` to avoid `"[object Object]"` in accessible labels.
|
|
286
444
|
|
|
445
|
+
Set `interactive: false` for a display-only event: it ignores clicks and the pointer, so clicks, hovers, and drags reach the time slot beneath it.
|
|
446
|
+
|
|
287
447
|
`priority` controls overlap packing. Higher values are placed in earlier columns, so they stay visible when `eventMaxStack` or `eventMinWidth` caps how many overlapping events are shown. Omit it (or use `0`) for the default. Use this to keep product appointments on the grid ahead of connected-calendar events.
|
|
288
448
|
|
|
289
449
|
### AvailabilityRange
|
|
@@ -548,11 +708,12 @@ const { refs, floatingStyles } = useFloating({
|
|
|
548
708
|
|
|
549
709
|
```ts
|
|
550
710
|
// Components
|
|
551
|
-
export { ResourceGridView, DayGridView } from '@savvycal/calendar';
|
|
711
|
+
export { ResourceGridView, DayGridView, MonthView } from '@savvycal/calendar';
|
|
552
712
|
// Defaults
|
|
553
713
|
export {
|
|
554
714
|
resourceGridViewDefaults,
|
|
555
715
|
dayGridViewDefaults,
|
|
716
|
+
monthViewDefaults,
|
|
556
717
|
} from '@savvycal/calendar';
|
|
557
718
|
|
|
558
719
|
// Temporal polyfill
|
|
@@ -569,6 +730,7 @@ export type {
|
|
|
569
730
|
AllDayCalendarEvent,
|
|
570
731
|
TimeSlot,
|
|
571
732
|
AvailabilityRange,
|
|
733
|
+
BackgroundEvent,
|
|
572
734
|
TimeAxisConfig,
|
|
573
735
|
ResourceGridViewProps,
|
|
574
736
|
ResourceGridViewClassNames,
|
|
@@ -581,6 +743,11 @@ export type {
|
|
|
581
743
|
SelectionAppearance,
|
|
582
744
|
SelectionEventData,
|
|
583
745
|
EventLayout,
|
|
746
|
+
MonthViewProps,
|
|
747
|
+
MonthViewClassNames,
|
|
748
|
+
MonthSelectedRange,
|
|
749
|
+
MonthOverflowClickInfo,
|
|
750
|
+
MonthOverflowPopoverRenderProps,
|
|
584
751
|
} from '@savvycal/calendar';
|
|
585
752
|
```
|
|
586
753
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AllDayEventChip.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/AllDayEventChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,UAAU,oBAAoB;IAC5B,UAAU,EAAE,qBAAqB,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,qBAAqB,KAAK,MAAM,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"AllDayEventChip.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/AllDayEventChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,UAAU,oBAAoB;IAC5B,UAAU,EAAE,qBAAqB,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,qBAAqB,KAAK,MAAM,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,eAAe,4DAyG1B,CAAC"}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { jsxs as D, Fragment as
|
|
1
|
+
import { jsxs as D, Fragment as x, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { memo as L } from "react";
|
|
3
|
-
import { cn as
|
|
4
|
-
import { getEventLabel as
|
|
5
|
-
const
|
|
6
|
-
positioned:
|
|
7
|
-
laneOffset:
|
|
3
|
+
import { cn as s } from "../../lib/utils.js";
|
|
4
|
+
import { getEventLabel as N, getClientNameLabel as S } from "../../lib/accessibility.js";
|
|
5
|
+
const w = L(function({
|
|
6
|
+
positioned: p,
|
|
7
|
+
laneOffset: f,
|
|
8
8
|
cls: t,
|
|
9
|
-
onEventClick:
|
|
10
|
-
selectedEventId:
|
|
11
|
-
selectedEventRef:
|
|
9
|
+
onEventClick: c,
|
|
10
|
+
selectedEventId: u,
|
|
11
|
+
selectedEventRef: y
|
|
12
12
|
}) {
|
|
13
13
|
const {
|
|
14
14
|
event: e,
|
|
15
|
-
gridColumnStart:
|
|
16
|
-
gridColumnSpan:
|
|
17
|
-
lane:
|
|
18
|
-
continuesBefore:
|
|
19
|
-
continuesAfter:
|
|
20
|
-
} =
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
...
|
|
15
|
+
gridColumnStart: g,
|
|
16
|
+
gridColumnSpan: v,
|
|
17
|
+
lane: b,
|
|
18
|
+
continuesBefore: i,
|
|
19
|
+
continuesAfter: d
|
|
20
|
+
} = p, h = e.id === u, C = b + 1 + f, l = [N(e), "all day"], m = S(e);
|
|
21
|
+
m && l.push(m);
|
|
22
|
+
const E = i ? 2 : 4, R = d ? 2 : 4, a = {
|
|
23
|
+
...i ? {
|
|
24
24
|
borderTopLeftRadius: 0,
|
|
25
25
|
borderBottomLeftRadius: 0,
|
|
26
26
|
paddingLeft: 4
|
|
27
27
|
} : {},
|
|
28
|
-
...
|
|
29
|
-
},
|
|
30
|
-
e.color && !
|
|
28
|
+
...d ? { borderTopRightRadius: 0, borderBottomRightRadius: 0 } : {}
|
|
29
|
+
}, o = /* @__PURE__ */ D(x, { children: [
|
|
30
|
+
e.color && !i && /* @__PURE__ */ n(
|
|
31
31
|
"div",
|
|
32
32
|
{
|
|
33
33
|
className: t("allDayEventColorBar"),
|
|
@@ -35,32 +35,38 @@ const T = L(function({
|
|
|
35
35
|
}
|
|
36
36
|
),
|
|
37
37
|
/* @__PURE__ */ n("span", { className: t("allDayEventTitle"), children: e.title })
|
|
38
|
-
] })
|
|
39
|
-
|
|
38
|
+
] }), r = {
|
|
39
|
+
gridColumn: `${g} / span ${v}`,
|
|
40
|
+
gridRow: C,
|
|
41
|
+
marginLeft: E,
|
|
42
|
+
marginRight: R,
|
|
43
|
+
contain: "inline-size"
|
|
44
|
+
};
|
|
45
|
+
return e.interactive === !1 ? /* @__PURE__ */ n(
|
|
40
46
|
"div",
|
|
41
47
|
{
|
|
42
|
-
|
|
43
|
-
style: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
48
|
+
className: s(t("allDayEvent"), "relative flex items-center gap-1"),
|
|
49
|
+
style: { ...r, ...a, pointerEvents: "none" },
|
|
50
|
+
children: o
|
|
51
|
+
}
|
|
52
|
+
) : h ? /* @__PURE__ */ n(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
ref: y,
|
|
56
|
+
style: { ...r, display: "flex", minWidth: 0 },
|
|
51
57
|
children: /* @__PURE__ */ n(
|
|
52
58
|
"button",
|
|
53
59
|
{
|
|
54
60
|
type: "button",
|
|
55
|
-
"aria-label":
|
|
56
|
-
className:
|
|
61
|
+
"aria-label": l.join(", "),
|
|
62
|
+
className: s(
|
|
57
63
|
t("allDayEvent"),
|
|
58
64
|
t("allDayEventSelected"),
|
|
59
65
|
"relative flex items-center gap-1 w-full"
|
|
60
66
|
),
|
|
61
|
-
style:
|
|
62
|
-
onClick: () =>
|
|
63
|
-
children:
|
|
67
|
+
style: a,
|
|
68
|
+
onClick: () => c?.(e),
|
|
69
|
+
children: o
|
|
64
70
|
}
|
|
65
71
|
)
|
|
66
72
|
}
|
|
@@ -68,20 +74,14 @@ const T = L(function({
|
|
|
68
74
|
"button",
|
|
69
75
|
{
|
|
70
76
|
type: "button",
|
|
71
|
-
"aria-label":
|
|
72
|
-
className:
|
|
73
|
-
style: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
marginLeft: m,
|
|
77
|
-
marginRight: p,
|
|
78
|
-
...u
|
|
79
|
-
},
|
|
80
|
-
onClick: () => a?.(e),
|
|
81
|
-
children: f
|
|
77
|
+
"aria-label": l.join(", "),
|
|
78
|
+
className: s(t("allDayEvent"), "relative flex items-center gap-1"),
|
|
79
|
+
style: { ...r, ...a },
|
|
80
|
+
onClick: () => c?.(e),
|
|
81
|
+
children: o
|
|
82
82
|
}
|
|
83
83
|
);
|
|
84
84
|
});
|
|
85
85
|
export {
|
|
86
|
-
|
|
86
|
+
w as AllDayEventChip
|
|
87
87
|
};
|
|
@@ -2,6 +2,10 @@ import { Ref } from 'react';
|
|
|
2
2
|
import { Temporal } from 'temporal-polyfill';
|
|
3
3
|
import { CalendarEvent, DayGridViewClassNames } from '../../types/calendar';
|
|
4
4
|
import { PositionedAllDayEvent } from '../../lib/overlap';
|
|
5
|
+
interface DaySpan {
|
|
6
|
+
startDate: Temporal.PlainDate;
|
|
7
|
+
endDate: Temporal.PlainDate;
|
|
8
|
+
}
|
|
5
9
|
interface AllDaySectionProps {
|
|
6
10
|
positioned: PositionedAllDayEvent[];
|
|
7
11
|
dates: Temporal.PlainDate[];
|
|
@@ -10,6 +14,17 @@ interface AllDaySectionProps {
|
|
|
10
14
|
onEventClick?: (event: CalendarEvent) => void;
|
|
11
15
|
selectedEventId?: string | null;
|
|
12
16
|
selectedEventRef?: Ref<HTMLDivElement>;
|
|
17
|
+
/**
|
|
18
|
+
* Enables drag selection of whole days across the row. Called with `null`
|
|
19
|
+
* when a drag starts, then with the selected days when it ends.
|
|
20
|
+
*/
|
|
21
|
+
onSelectDays?: (days: DaySpan | null) => void;
|
|
22
|
+
/** Finds the date (as a string) of the day column under the pointer. */
|
|
23
|
+
resolveColumnId?: (clientX: number) => string | null;
|
|
24
|
+
/** Whole days to highlight as the current selection. */
|
|
25
|
+
selectedDays?: DaySpan | null;
|
|
26
|
+
/** Ref attached to the selected days' highlight. */
|
|
27
|
+
selectionRef?: Ref<HTMLDivElement>;
|
|
13
28
|
}
|
|
14
29
|
export declare const AllDaySection: import('react').NamedExoticComponent<AllDaySectionProps>;
|
|
15
30
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AllDaySection.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/AllDaySection.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AllDaySection.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/AllDaySection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAI3D,UAAU,OAAO;IACf,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC;IAC9B,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC;CAC7B;AAED,UAAU,kBAAkB;IAC1B,UAAU,EAAE,qBAAqB,EAAE,CAAC;IACpC,KAAK,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,qBAAqB,KAAK,MAAM,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACvC;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9C,wEAAwE;IACxE,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACrD,wDAAwD;IACxD,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,oDAAoD;IACpD,YAAY,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CACpC;AAED,eAAO,MAAM,aAAa,0DA8JxB,CAAC"}
|
|
@@ -1,53 +1,117 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { memo as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { jsxs as k, jsx as M } from "react/jsx-runtime";
|
|
2
|
+
import { memo as O, useState as _, useRef as l, useEffect as w, useCallback as C } from "react";
|
|
3
|
+
import { DISMISS_ONLY_ATTR as z } from "../shared/AnchoredPopover.js";
|
|
4
|
+
import { AllDayEventChip as H } from "./AllDayEventChip.js";
|
|
5
|
+
const F = O(function({
|
|
6
|
+
positioned: c,
|
|
7
|
+
dates: e,
|
|
8
|
+
headerHeight: L,
|
|
9
|
+
cls: m,
|
|
10
|
+
onEventClick: b,
|
|
11
|
+
selectedEventId: y,
|
|
12
|
+
selectedEventRef: I,
|
|
13
|
+
onSelectDays: r,
|
|
14
|
+
resolveColumnId: R,
|
|
15
|
+
selectedDays: d,
|
|
16
|
+
selectionRef: $
|
|
12
17
|
}) {
|
|
13
|
-
const
|
|
14
|
-
|
|
18
|
+
const [o, A] = _(
|
|
19
|
+
null
|
|
20
|
+
), h = l(o), i = l(e), x = l(r), E = l(R);
|
|
21
|
+
w(() => {
|
|
22
|
+
i.current = e, x.current = r, E.current = R;
|
|
23
|
+
});
|
|
24
|
+
const f = (t) => {
|
|
25
|
+
h.current = t, A(t);
|
|
26
|
+
}, u = C((t) => {
|
|
27
|
+
const n = h.current, s = E.current?.(t.clientX);
|
|
28
|
+
if (!n || !s) return;
|
|
29
|
+
const v = i.current.findIndex((j) => j.toString() === s);
|
|
30
|
+
v !== -1 && v !== n.current && f({ ...n, current: v });
|
|
31
|
+
}, []), g = C(() => {
|
|
32
|
+
document.removeEventListener("mousemove", u);
|
|
33
|
+
const t = h.current;
|
|
34
|
+
if (f(null), !t) return;
|
|
35
|
+
const n = Math.min(t.anchor, t.current), s = Math.max(t.anchor, t.current);
|
|
36
|
+
x.current?.({
|
|
37
|
+
startDate: i.current[n],
|
|
38
|
+
endDate: i.current[s]
|
|
39
|
+
});
|
|
40
|
+
}, [u]);
|
|
41
|
+
w(() => () => {
|
|
42
|
+
document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", g);
|
|
43
|
+
}, [u, g]);
|
|
44
|
+
const N = (t) => (n) => {
|
|
45
|
+
n.button === 0 && (n.preventDefault(), r?.(null), f({ anchor: t, current: t }), document.addEventListener("mousemove", u), document.addEventListener("mouseup", g, { once: !0 }));
|
|
46
|
+
};
|
|
47
|
+
let a = null;
|
|
48
|
+
if (o)
|
|
49
|
+
a = {
|
|
50
|
+
first: Math.min(o.anchor, o.current),
|
|
51
|
+
last: Math.max(o.anchor, o.current)
|
|
52
|
+
};
|
|
53
|
+
else if (d && e.length > 0) {
|
|
54
|
+
const t = Math.max(0, e[0].until(d.startDate).days), n = Math.min(
|
|
55
|
+
e.length - 1,
|
|
56
|
+
e[0].until(d.endDate).days
|
|
57
|
+
);
|
|
58
|
+
t <= n && (a = { first: t, last: n });
|
|
59
|
+
}
|
|
60
|
+
const S = c.length > 0 ? Math.max(...c.map((t) => t.lane)) + 1 : 0, p = c.length > 0, D = p ? "4px" : "0px", T = p ? `${D} repeat(${S}, auto) ${D}` : "auto";
|
|
61
|
+
return /* @__PURE__ */ k(
|
|
15
62
|
"div",
|
|
16
63
|
{
|
|
17
|
-
className:
|
|
64
|
+
className: m("allDayLane"),
|
|
18
65
|
style: {
|
|
19
66
|
gridRow: 2,
|
|
20
67
|
gridColumn: "2 / -1",
|
|
21
68
|
display: "grid",
|
|
22
69
|
gridTemplateColumns: "subgrid",
|
|
23
|
-
gridTemplateRows:
|
|
70
|
+
gridTemplateRows: T,
|
|
24
71
|
position: "sticky",
|
|
25
|
-
top:
|
|
72
|
+
top: L,
|
|
26
73
|
zIndex: 20,
|
|
27
74
|
gap: "2px 0"
|
|
28
75
|
},
|
|
29
76
|
children: [
|
|
30
|
-
|
|
77
|
+
e.map((t, n) => /* @__PURE__ */ M(
|
|
31
78
|
"div",
|
|
32
79
|
{
|
|
33
|
-
className:
|
|
80
|
+
className: n < e.length - 1 ? "border-r border-cal-border" : void 0,
|
|
34
81
|
style: {
|
|
35
|
-
gridColumn:
|
|
82
|
+
gridColumn: n + 1,
|
|
36
83
|
gridRow: "1 / -1",
|
|
37
|
-
pointerEvents: "none"
|
|
38
|
-
|
|
84
|
+
pointerEvents: r ? "auto" : "none",
|
|
85
|
+
cursor: r ? "pointer" : void 0
|
|
86
|
+
},
|
|
87
|
+
"data-day-column": t.toString(),
|
|
88
|
+
...r ? { [z]: "" } : {},
|
|
89
|
+
onMouseDown: r ? N(n) : void 0
|
|
39
90
|
},
|
|
40
91
|
t.toString()
|
|
41
92
|
)),
|
|
42
|
-
|
|
43
|
-
|
|
93
|
+
a && /* @__PURE__ */ M(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
ref: o ? void 0 : $,
|
|
97
|
+
"aria-hidden": "true",
|
|
98
|
+
className: m("selectionHighlight"),
|
|
99
|
+
style: {
|
|
100
|
+
gridColumn: `${a.first + 1} / ${a.last + 2}`,
|
|
101
|
+
gridRow: "1 / -1",
|
|
102
|
+
pointerEvents: "none"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
c.map((t) => /* @__PURE__ */ M(
|
|
107
|
+
H,
|
|
44
108
|
{
|
|
45
109
|
positioned: t,
|
|
46
|
-
laneOffset:
|
|
47
|
-
cls:
|
|
48
|
-
onEventClick:
|
|
49
|
-
selectedEventId:
|
|
50
|
-
selectedEventRef:
|
|
110
|
+
laneOffset: p ? 1 : 0,
|
|
111
|
+
cls: m,
|
|
112
|
+
onEventClick: b,
|
|
113
|
+
selectedEventId: y,
|
|
114
|
+
selectedEventRef: I
|
|
51
115
|
},
|
|
52
116
|
t.event.id
|
|
53
117
|
))
|
|
@@ -56,5 +120,5 @@ const C = x(function({
|
|
|
56
120
|
);
|
|
57
121
|
});
|
|
58
122
|
export {
|
|
59
|
-
|
|
123
|
+
F as AllDaySection
|
|
60
124
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Temporal } from 'temporal-polyfill';
|
|
3
|
+
import { BackgroundEvent } from '../../types/calendar';
|
|
4
|
+
interface BackgroundEventLayerProps {
|
|
5
|
+
events: BackgroundEvent[];
|
|
6
|
+
date: Temporal.PlainDate;
|
|
7
|
+
column: number;
|
|
8
|
+
timeZone: string;
|
|
9
|
+
startHour: number;
|
|
10
|
+
endHour: number;
|
|
11
|
+
hourHeight: number;
|
|
12
|
+
renderBackgroundEvent?: (props: {
|
|
13
|
+
event: BackgroundEvent;
|
|
14
|
+
height: number;
|
|
15
|
+
}) => ReactNode;
|
|
16
|
+
}
|
|
17
|
+
export declare const BackgroundEventLayer: import('react').NamedExoticComponent<BackgroundEventLayerProps>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=BackgroundEventLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BackgroundEventLayer.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/BackgroundEventLayer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD,UAAU,yBAAyB;IACjC,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE;QAC9B,KAAK,EAAE,eAAe,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,KAAK,SAAS,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB,iEAyD/B,CAAC"}
|