@dxos/react-ui-calendar 0.8.4-main.03d5cd7b56

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 (38) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +1 -0
  3. package/dist/lib/browser/index.mjs +234 -0
  4. package/dist/lib/browser/index.mjs.map +7 -0
  5. package/dist/lib/browser/meta.json +1 -0
  6. package/dist/lib/browser/translations.mjs +16 -0
  7. package/dist/lib/browser/translations.mjs.map +7 -0
  8. package/dist/lib/node-esm/index.mjs +236 -0
  9. package/dist/lib/node-esm/index.mjs.map +7 -0
  10. package/dist/lib/node-esm/meta.json +1 -0
  11. package/dist/lib/node-esm/translations.mjs +18 -0
  12. package/dist/lib/node-esm/translations.mjs.map +7 -0
  13. package/dist/types/src/components/Calendar/Calendar.d.ts +41 -0
  14. package/dist/types/src/components/Calendar/Calendar.d.ts.map +1 -0
  15. package/dist/types/src/components/Calendar/Calendar.stories.d.ts +22 -0
  16. package/dist/types/src/components/Calendar/Calendar.stories.d.ts.map +1 -0
  17. package/dist/types/src/components/Calendar/index.d.ts +2 -0
  18. package/dist/types/src/components/Calendar/index.d.ts.map +1 -0
  19. package/dist/types/src/components/Calendar/util.d.ts +4 -0
  20. package/dist/types/src/components/Calendar/util.d.ts.map +1 -0
  21. package/dist/types/src/components/index.d.ts +2 -0
  22. package/dist/types/src/components/index.d.ts.map +1 -0
  23. package/dist/types/src/index.d.ts +2 -0
  24. package/dist/types/src/index.d.ts.map +1 -0
  25. package/dist/types/src/translations.d.ts +9 -0
  26. package/dist/types/src/translations.d.ts.map +1 -0
  27. package/dist/types/src/types.d.ts +175 -0
  28. package/dist/types/src/types.d.ts.map +1 -0
  29. package/dist/types/tsconfig.tsbuildinfo +1 -0
  30. package/package.json +71 -0
  31. package/src/components/Calendar/Calendar.stories.tsx +51 -0
  32. package/src/components/Calendar/Calendar.tsx +300 -0
  33. package/src/components/Calendar/index.ts +5 -0
  34. package/src/components/Calendar/util.ts +22 -0
  35. package/src/components/index.ts +5 -0
  36. package/src/index.ts +5 -0
  37. package/src/translations.ts +17 -0
  38. package/src/types.ts +193 -0
package/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ MIT License
2
+ Copyright (c) 2022 DXOS
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @dxos/react-ui-calendar
@@ -0,0 +1,234 @@
1
+ // src/components/Calendar/Calendar.tsx
2
+ import { createContext } from "@radix-ui/react-context";
3
+ import { addDays, differenceInWeeks, format, startOfDay, startOfWeek } from "date-fns";
4
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
5
+ import { useResizeDetector } from "react-resize-detector";
6
+ import { List } from "react-virtualized";
7
+ import { Event } from "@dxos/async";
8
+ import { IconButton, useTranslation } from "@dxos/react-ui";
9
+ import { composable, composableProps, mx } from "@dxos/ui-theme";
10
+ import { translationKey } from "#translations";
11
+
12
+ // src/components/Calendar/util.ts
13
+ var getDate = (start2, weekNumber, dayOfWeek, weekStartsOn) => {
14
+ const result = new Date(start2);
15
+ const startDayOfWeek = start2.getDay();
16
+ const adjustedStartDay = (startDayOfWeek === 0 ? 7 : startDayOfWeek) - weekStartsOn;
17
+ result.setDate(start2.getDate() - adjustedStartDay + weekNumber * 7 + dayOfWeek);
18
+ return result;
19
+ };
20
+ var isSameDay = (date1, date2) => {
21
+ return !!date2 && date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate();
22
+ };
23
+
24
+ // src/components/Calendar/Calendar.tsx
25
+ var maxRows = 50 * 100;
26
+ var start = /* @__PURE__ */ new Date("1970-01-01");
27
+ var size = 48;
28
+ var defaultWidth = 7 * size;
29
+ var [CalendarContextProvider, useCalendarContext] = createContext("Calendar");
30
+ var CalendarRoot = /* @__PURE__ */ forwardRef(({ children, weekStartsOn = 1 }, forwardedRef) => {
31
+ const event = useMemo(() => new Event(), []);
32
+ const [selected, setSelected] = useState();
33
+ const [index, setIndex] = useState();
34
+ useImperativeHandle(forwardedRef, () => ({
35
+ scrollTo: (date) => {
36
+ event.emit({
37
+ type: "scroll",
38
+ date
39
+ });
40
+ }
41
+ }), [
42
+ event
43
+ ]);
44
+ return /* @__PURE__ */ React.createElement(CalendarContextProvider, {
45
+ weekStartsOn,
46
+ event,
47
+ index,
48
+ setIndex,
49
+ selected,
50
+ setSelected
51
+ }, children);
52
+ });
53
+ var CALENDAR_TOOLBAR_NAME = "CalendarHeader";
54
+ var CalendarToolbar = composable(({ classNames, ...props }, forwardedRef) => {
55
+ const { t } = useTranslation(translationKey);
56
+ const { weekStartsOn, event, index, selected } = useCalendarContext(CALENDAR_TOOLBAR_NAME);
57
+ const top = useMemo(() => getDate(start, index ?? 0, 6, weekStartsOn), [
58
+ index,
59
+ weekStartsOn
60
+ ]);
61
+ const today = useMemo(() => /* @__PURE__ */ new Date(), []);
62
+ const handleToday = useCallback(() => {
63
+ event.emit({
64
+ type: "scroll",
65
+ date: today
66
+ });
67
+ }, [
68
+ event,
69
+ start,
70
+ today
71
+ ]);
72
+ return /* @__PURE__ */ React.createElement("div", {
73
+ ...composableProps(props, {
74
+ role: "none",
75
+ classNames: [
76
+ "shrink-0 grid! grid-cols-3 items-center bg-toolbar-surface",
77
+ classNames
78
+ ]
79
+ }),
80
+ ref: forwardedRef,
81
+ style: {
82
+ width: defaultWidth
83
+ }
84
+ }, /* @__PURE__ */ React.createElement("div", {
85
+ className: "flex justify-start"
86
+ }, /* @__PURE__ */ React.createElement(IconButton, {
87
+ variant: "ghost",
88
+ icon: "ph--calendar--regular",
89
+ iconOnly: true,
90
+ classNames: "aspect-square",
91
+ label: t("today.button"),
92
+ onClick: handleToday
93
+ })), /* @__PURE__ */ React.createElement("div", {
94
+ className: "flex justify-center p-2 text-description"
95
+ }, format(selected ?? top, "MMMM")), /* @__PURE__ */ React.createElement("div", {
96
+ className: "flex justify-end p-2 text-description"
97
+ }, (selected ?? top).getFullYear()));
98
+ });
99
+ CalendarToolbar.displayName = CALENDAR_TOOLBAR_NAME;
100
+ var CALENDAR_GRID_NAME = "CalendarGrid";
101
+ var CalendarGrid = composable(({ classNames, rows, dates = [], onSelect, ...props }, forwardedRef) => {
102
+ const { weekStartsOn, event, setIndex, selected, setSelected } = useCalendarContext(CALENDAR_GRID_NAME);
103
+ const { ref: containerRef, width = 0, height = 0 } = useResizeDetector();
104
+ const maxHeight = rows ? rows * size : void 0;
105
+ const listRef = useRef(null);
106
+ const today = useMemo(() => /* @__PURE__ */ new Date(), []);
107
+ const dateSet = useMemo(() => new Set(dates.map((date) => startOfDay(date).toISOString())), [
108
+ dates
109
+ ]);
110
+ const hasDate = useCallback((date) => dateSet.has(startOfDay(date).toISOString()), [
111
+ dateSet
112
+ ]);
113
+ const [initialized, setInitialized] = useState(false);
114
+ useEffect(() => {
115
+ const index = differenceInWeeks(today, start);
116
+ listRef.current?.scrollToRow(index);
117
+ }, [
118
+ initialized,
119
+ start,
120
+ today
121
+ ]);
122
+ useEffect(() => {
123
+ return event.on((event2) => {
124
+ switch (event2.type) {
125
+ case "scroll": {
126
+ const index = differenceInWeeks(event2.date, start);
127
+ listRef.current?.scrollToRow(index);
128
+ break;
129
+ }
130
+ }
131
+ });
132
+ }, [
133
+ event
134
+ ]);
135
+ const days = useMemo(() => {
136
+ const weekStart = startOfWeek(/* @__PURE__ */ new Date(), {
137
+ weekStartsOn
138
+ });
139
+ return Array.from({
140
+ length: 7
141
+ }, (_, i) => {
142
+ const day = addDays(weekStart, i);
143
+ return format(day, "EEE");
144
+ });
145
+ }, []);
146
+ const handleDaySelect = useCallback((date) => {
147
+ setSelected((current) => isSameDay(date, current) ? void 0 : date);
148
+ onSelect?.({
149
+ date
150
+ });
151
+ }, [
152
+ onSelect
153
+ ]);
154
+ const handleScroll = useCallback((info) => {
155
+ setIndex(Math.round(info.scrollTop / size));
156
+ }, []);
157
+ const rowRenderer = useCallback(({ key, index, style }) => {
158
+ const getBgColor = (date) => date.getMonth() % 2 === 0 && "bg-modal-surface";
159
+ return /* @__PURE__ */ React.createElement("div", {
160
+ key,
161
+ style,
162
+ className: "grid"
163
+ }, /* @__PURE__ */ React.createElement("div", {
164
+ className: "grid grid-cols-7 bg-input-surface",
165
+ style: {
166
+ gridTemplateColumns: `repeat(7, ${size}px)`
167
+ }
168
+ }, Array.from({
169
+ length: 7
170
+ }).map((_, i) => {
171
+ const date = getDate(start, index, i, weekStartsOn);
172
+ const border = isSameDay(date, selected) ? "border-primary-500" : isSameDay(date, today) ? "border-amber-500" : hasDate(date) ? "border-neutral-700 border-dashed" : void 0;
173
+ return /* @__PURE__ */ React.createElement("div", {
174
+ key: i,
175
+ className: mx("relative flex justify-center items-center cursor-pointer", getBgColor(date)),
176
+ onClick: () => handleDaySelect(date)
177
+ }, /* @__PURE__ */ React.createElement("span", {
178
+ className: "text-description"
179
+ }, date.getDate()), !border && date.getDate() === 1 && /* @__PURE__ */ React.createElement("span", {
180
+ className: "absolute top-0 text-xs text-description"
181
+ }, format(date, "MMM")), border && /* @__PURE__ */ React.createElement("div", {
182
+ className: mx("absolute inset-1 border-2 rounded-full", border)
183
+ }));
184
+ })));
185
+ }, [
186
+ handleDaySelect,
187
+ hasDate,
188
+ selected,
189
+ weekStartsOn
190
+ ]);
191
+ return /* @__PURE__ */ React.createElement("div", {
192
+ ...composableProps(props, {
193
+ role: "none",
194
+ classNames: [
195
+ "flex flex-col h-full w-full justify-center overflow-hidden",
196
+ classNames
197
+ ]
198
+ }),
199
+ ref: forwardedRef
200
+ }, /* @__PURE__ */ React.createElement("div", {
201
+ className: "grid w-full grid-cols-7",
202
+ style: {
203
+ width: defaultWidth
204
+ }
205
+ }, days.map((date, i) => /* @__PURE__ */ React.createElement("div", {
206
+ key: i,
207
+ className: "flex justify-center p-2 text-sm font-thin"
208
+ }, date))), /* @__PURE__ */ React.createElement("div", {
209
+ className: "flex flex-col h-full w-full justify-center overflow-hidden",
210
+ ref: containerRef
211
+ }, /* @__PURE__ */ React.createElement(List, {
212
+ ref: listRef,
213
+ role: "none",
214
+ className: "scrollbar-none outline-hidden",
215
+ width,
216
+ height: maxHeight ?? height,
217
+ rowCount: maxRows,
218
+ rowHeight: size,
219
+ rowRenderer,
220
+ scrollToAlignment: "start",
221
+ onScroll: handleScroll,
222
+ onRowsRendered: () => setInitialized(true)
223
+ })));
224
+ });
225
+ CalendarGrid.displayName = CALENDAR_GRID_NAME;
226
+ var Calendar = {
227
+ Root: CalendarRoot,
228
+ Toolbar: CalendarToolbar,
229
+ Grid: CalendarGrid
230
+ };
231
+ export {
232
+ Calendar
233
+ };
234
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Calendar/Calendar.tsx", "../../../src/components/Calendar/util.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext } from '@radix-ui/react-context';\nimport { type Day, addDays, differenceInWeeks, format, startOfDay, startOfWeek } from 'date-fns';\nimport React, {\n type Dispatch,\n type PropsWithChildren,\n type SetStateAction,\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\nimport { List, type ListProps, type ListRowRenderer } from 'react-virtualized';\n\nimport { Event } from '@dxos/async';\nimport { IconButton, useTranslation } from '@dxos/react-ui';\nimport { composable, composableProps, mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport { getDate, isSameDay } from './util';\n\nconst maxRows = 50 * 100;\nconst start = new Date('1970-01-01');\nconst size = 48;\nconst defaultWidth = 7 * size;\n\n//\n// Context\n//\n\ntype CalendarEvent = {\n type: 'scroll';\n date: Date;\n};\n\ntype CalendarContextValue = {\n weekStartsOn: Day;\n event: Event<CalendarEvent>;\n index: number | undefined;\n setIndex: Dispatch<SetStateAction<number | undefined>>;\n selected: Date | undefined;\n setSelected: Dispatch<SetStateAction<Date | undefined>>;\n};\n\nconst [CalendarContextProvider, useCalendarContext] = createContext<CalendarContextValue>('Calendar');\n\n//\n// Controller\n//\n\ntype CalendarController = {\n scrollTo: (date: Date) => void;\n};\n\n//\n// Root\n//\n\ntype CalendarRootProps = PropsWithChildren<Partial<Pick<CalendarContextValue, 'weekStartsOn'>>>;\n\nconst CalendarRoot = forwardRef<CalendarController, CalendarRootProps>(\n ({ children, weekStartsOn = 1 }, forwardedRef) => {\n const event = useMemo(() => new Event<CalendarEvent>(), []);\n const [selected, setSelected] = useState<Date | undefined>();\n const [index, setIndex] = useState<number | undefined>();\n\n useImperativeHandle(\n forwardedRef,\n () => ({\n scrollTo: (date: Date) => {\n event.emit({ type: 'scroll', date });\n },\n }),\n [event],\n );\n\n return (\n <CalendarContextProvider\n weekStartsOn={weekStartsOn}\n event={event}\n index={index}\n setIndex={setIndex}\n selected={selected}\n setSelected={setSelected}\n >\n {children}\n </CalendarContextProvider>\n );\n },\n);\n\n//\n// Header\n//\n\nconst CALENDAR_TOOLBAR_NAME = 'CalendarHeader';\n\ntype CalendarToolbarProps = {};\n\nconst CalendarToolbar = composable<HTMLDivElement, CalendarToolbarProps>(({ classNames, ...props }, forwardedRef) => {\n const { t } = useTranslation(translationKey);\n const { weekStartsOn, event, index, selected } = useCalendarContext(CALENDAR_TOOLBAR_NAME);\n const top = useMemo(() => getDate(start, index ?? 0, 6, weekStartsOn), [index, weekStartsOn]);\n const today = useMemo(() => new Date(), []);\n\n const handleToday = useCallback(() => {\n event.emit({ type: 'scroll', date: today });\n }, [event, start, today]);\n\n return (\n <div\n {...composableProps(props, {\n role: 'none',\n classNames: ['shrink-0 grid! grid-cols-3 items-center bg-toolbar-surface', classNames],\n })}\n ref={forwardedRef}\n style={{ width: defaultWidth }}\n >\n <div className='flex justify-start'>\n <IconButton\n variant='ghost'\n icon='ph--calendar--regular'\n iconOnly\n classNames='aspect-square'\n label={t('today.button')}\n onClick={handleToday}\n />\n </div>\n <div className='flex justify-center p-2 text-description'>{format(selected ?? top, 'MMMM')}</div>\n <div className='flex justify-end p-2 text-description'>{(selected ?? top).getFullYear()}</div>\n </div>\n );\n});\n\nCalendarToolbar.displayName = CALENDAR_TOOLBAR_NAME;\n\n//\n// Grid\n// TODO(burdon): Key nav.\n// TODO(burdon): Drag range.\n//\n\nconst CALENDAR_GRID_NAME = 'CalendarGrid';\n\ntype CalendarGridProps = {\n rows?: number;\n /** Dates to highlight on the grid. Each date that appears in this array receives a border indicator. */\n dates?: Date[];\n onSelect?: (event: { date: Date }) => void;\n};\n\nconst CalendarGrid = composable<HTMLDivElement, CalendarGridProps>(\n ({ classNames, rows, dates = [], onSelect, ...props }, forwardedRef) => {\n const { weekStartsOn, event, setIndex, selected, setSelected } = useCalendarContext(CALENDAR_GRID_NAME);\n const { ref: containerRef, width = 0, height = 0 } = useResizeDetector();\n const maxHeight = rows ? rows * size : undefined;\n const listRef = useRef<List>(null);\n const today = useMemo(() => new Date(), []);\n\n // Build a set of ISO date strings (YYYY-MM-DD) for O(1) per-cell lookup.\n const dateSet = useMemo(() => new Set(dates.map((date) => startOfDay(date).toISOString())), [dates]);\n\n const hasDate = useCallback((date: Date) => dateSet.has(startOfDay(date).toISOString()), [dateSet]);\n\n const [initialized, setInitialized] = useState(false);\n useEffect(() => {\n const index = differenceInWeeks(today, start);\n listRef.current?.scrollToRow(index);\n }, [initialized, start, today]);\n\n useEffect(() => {\n return event.on((event) => {\n switch (event.type) {\n case 'scroll': {\n const index = differenceInWeeks(event.date, start);\n listRef.current?.scrollToRow(index);\n break;\n }\n }\n });\n }, [event]);\n\n const days = useMemo(() => {\n const weekStart = startOfWeek(new Date(), { weekStartsOn });\n return Array.from({ length: 7 }, (_, i) => {\n const day = addDays(weekStart, i);\n return format(day, 'EEE'); // Short day name (Mon, Tue, etc.)\n });\n }, []);\n\n // TODO(burdon): Get info by range.\n\n const handleDaySelect = useCallback(\n (date: Date) => {\n setSelected((current) => (isSameDay(date, current) ? undefined : date));\n onSelect?.({ date });\n },\n [onSelect],\n );\n\n const handleScroll = useCallback<NonNullable<ListProps['onScroll']>>((info) => {\n setIndex(Math.round(info.scrollTop / size));\n }, []);\n\n const rowRenderer = useCallback<ListRowRenderer>(\n ({ key, index, style }) => {\n const getBgColor = (date: Date) => date.getMonth() % 2 === 0 && 'bg-modal-surface';\n return (\n <div key={key} style={style} className='grid'>\n <div className='grid grid-cols-7 bg-input-surface' style={{ gridTemplateColumns: `repeat(7, ${size}px)` }}>\n {Array.from({ length: 7 }).map((_, i) => {\n const date = getDate(start, index, i, weekStartsOn);\n const border = isSameDay(date, selected)\n ? 'border-primary-500'\n : isSameDay(date, today)\n ? 'border-amber-500'\n : hasDate(date)\n ? 'border-neutral-700 border-dashed'\n : undefined;\n\n return (\n <div\n key={i}\n className={mx('relative flex justify-center items-center cursor-pointer', getBgColor(date))}\n onClick={() => handleDaySelect(date)}\n >\n <span className='text-description'>{date.getDate()}</span>\n {!border && date.getDate() === 1 && (\n <span className='absolute top-0 text-xs text-description'>{format(date, 'MMM')}</span>\n )}\n {border && <div className={mx('absolute inset-1 border-2 rounded-full', border)} />}\n </div>\n );\n })}\n </div>\n </div>\n );\n },\n [handleDaySelect, hasDate, selected, weekStartsOn],\n );\n\n return (\n <div\n {...composableProps(props, {\n role: 'none',\n classNames: ['flex flex-col h-full w-full justify-center overflow-hidden', classNames],\n })}\n ref={forwardedRef}\n >\n {/* Day of week labels */}\n <div className='grid w-full grid-cols-7' style={{ width: defaultWidth }}>\n {days.map((date, i) => (\n <div key={i} className='flex justify-center p-2 text-sm font-thin'>\n {date}\n </div>\n ))}\n </div>\n\n {/* Grid */}\n <div className='flex flex-col h-full w-full justify-center overflow-hidden' ref={containerRef}>\n <List\n ref={listRef}\n role='none'\n className='scrollbar-none outline-hidden'\n width={width}\n height={maxHeight ?? height}\n rowCount={maxRows}\n rowHeight={size}\n rowRenderer={rowRenderer}\n scrollToAlignment='start'\n onScroll={handleScroll}\n onRowsRendered={() => setInitialized(true)}\n />\n </div>\n </div>\n );\n },\n);\n\nCalendarGrid.displayName = CALENDAR_GRID_NAME;\n\n//\n// Calendar\n//\n\nexport const Calendar = {\n Root: CalendarRoot,\n Toolbar: CalendarToolbar,\n Grid: CalendarGrid,\n};\n\nexport type { CalendarController, CalendarRootProps, CalendarToolbarProps, CalendarGridProps };\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Day } from 'date-fns';\n\nexport const getDate = (start: Date, weekNumber: number, dayOfWeek: number, weekStartsOn: Day): Date => {\n const result = new Date(start);\n const startDayOfWeek = start.getDay(); // 0 = Sunday, 1 = Monday, etc.\n const adjustedStartDay = (startDayOfWeek === 0 ? 7 : startDayOfWeek) - weekStartsOn; // Adjust for weekStartsOn.\n result.setDate(start.getDate() - adjustedStartDay + weekNumber * 7 + dayOfWeek);\n return result;\n};\n\nexport const isSameDay = (date1: Date, date2: Date | undefined): boolean => {\n return (\n !!date2 &&\n date1.getFullYear() === date2.getFullYear() &&\n date1.getMonth() === date2.getMonth() &&\n date1.getDate() === date2.getDate()\n );\n};\n"],
5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4B,SAAS,MAAMwC,gBAAgBpE,IAAAA;SAE/B,sBAAA,cAACkF,QAAAA;QAAK5D,WAAU;SAAoBtB,KAAKY,QAAO,CAAA,GAC/C,CAACoE,UAAUhF,KAAKY,QAAO,MAAO,KAC7B,sBAAA,cAACsE,QAAAA;QAAK5D,WAAU;SAA2CO,OAAO7B,MAAM,KAAA,CAAA,GAEzEgF,UAAU,sBAAA,cAAChE,OAAAA;QAAIM,WAAW2D,GAAG,0CAA0CD,MAAAA;;IAG9E,CAAA,CAAA,CAAA;EAIR,GACA;IAACZ;IAAiBnB;IAASxD;IAAUL;GAAa;AAGpD,SACE,sBAAA,cAAC4B,OAAAA;IACE,GAAGC,gBAAgBV,OAAO;MACzBW,MAAM;MACNZ,YAAY;QAAC;QAA8DA;;IAC7E,CAAA;IACAa,KAAK9B;KAGL,sBAAA,cAAC2B,OAAAA;IAAIM,WAAU;IAA0BF,OAAO;MAAEC,OAAOxC;IAAa;KACnE6E,KAAKZ,IAAI,CAAC9C,MAAMiE,MACf,sBAAA,cAACjD,OAAAA;IAAI4D,KAAKX;IAAG3C,WAAU;KACpBtB,IAAAA,CAAAA,CAAAA,GAMP,sBAAA,cAACgB,OAAAA;IAAIM,WAAU;IAA6DH,KAAKkB;KAC/E,sBAAA,cAAC8C,MAAAA;IACChE,KAAKuB;IACLxB,MAAK;IACLI,WAAU;IACVD;IACAiB,QAAQE,aAAaF;IACrB8C,UAAU3G;IACV4G,WAAWzG;IACX+F;IACAW,mBAAkB;IAClBC,UAAUjB;IACVkB,gBAAgB,MAAMpC,eAAe,IAAA;;AAK/C,CAAA;AAGFnB,aAAaF,cAAcC;AAMpB,IAAMyD,WAAW;EACtBC,MAAMzG;EACN0G,SAASvF;EACTwF,MAAM3D;AACR;",
6
+ "names": ["createContext", "addDays", "differenceInWeeks", "format", "startOfDay", "startOfWeek", "React", "forwardRef", "useCallback", "useEffect", "useImperativeHandle", "useMemo", "useRef", "useState", "useResizeDetector", "List", "Event", "IconButton", "useTranslation", "composable", "composableProps", "mx", "translationKey", "getDate", "start", "weekNumber", "dayOfWeek", "weekStartsOn", "result", "Date", "startDayOfWeek", "getDay", "adjustedStartDay", "setDate", "isSameDay", "date1", "date2", "getFullYear", "getMonth", "maxRows", "start", "Date", "size", "defaultWidth", "CalendarContextProvider", "useCalendarContext", "createContext", "CalendarRoot", "forwardRef", "children", "weekStartsOn", "forwardedRef", "event", "useMemo", "Event", "selected", "setSelected", "useState", "index", "setIndex", "useImperativeHandle", "scrollTo", "date", "emit", "type", "CALENDAR_TOOLBAR_NAME", "CalendarToolbar", "composable", "classNames", "props", "t", "useTranslation", "translationKey", "top", "getDate", "today", "handleToday", "useCallback", "div", "composableProps", "role", "ref", "style", "width", "className", "IconButton", "variant", "icon", "iconOnly", "label", "onClick", "format", "getFullYear", "displayName", "CALENDAR_GRID_NAME", "CalendarGrid", "rows", "dates", "onSelect", "containerRef", "height", "useResizeDetector", "maxHeight", "undefined", "listRef", "useRef", "dateSet", "Set", "map", "startOfDay", "toISOString", "hasDate", "has", "initialized", "setInitialized", "useEffect", "differenceInWeeks", "current", "scrollToRow", "on", "days", "weekStart", "startOfWeek", "Array", "from", "length", "_", "i", "day", "addDays", "handleDaySelect", "isSameDay", "handleScroll", "info", "Math", "round", "scrollTop", "rowRenderer", "key", "getBgColor", "getMonth", "gridTemplateColumns", "border", "mx", "span", "List", "rowCount", "rowHeight", "scrollToAlignment", "onScroll", "onRowsRendered", "Calendar", "Root", "Toolbar", "Grid"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"src/components/Calendar/util.ts":{"bytes":2699,"imports":[],"format":"esm"},"src/components/Calendar/Calendar.tsx":{"bytes":29347,"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"date-fns","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"react-virtualized","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true},{"path":"src/components/Calendar/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/components/Calendar/index.ts":{"bytes":376,"imports":[{"path":"src/components/Calendar/Calendar.tsx","kind":"import-statement","original":"./Calendar"}],"format":"esm"},"src/components/index.ts":{"bytes":376,"imports":[{"path":"src/components/Calendar/index.ts","kind":"import-statement","original":"./Calendar"}],"format":"esm"},"src/index.ts":{"bytes":382,"imports":[{"path":"src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"},"src/translations.ts":{"bytes":1105,"imports":[],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17459},"dist/lib/browser/index.mjs":{"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"date-fns","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"react-virtualized","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true}],"exports":["Calendar"],"entryPoint":"src/index.ts","inputs":{"src/components/Calendar/Calendar.tsx":{"bytesInOutput":7296},"src/components/Calendar/util.ts":{"bytesInOutput":517},"src/components/Calendar/index.ts":{"bytesInOutput":0},"src/components/index.ts":{"bytesInOutput":0},"src/index.ts":{"bytesInOutput":0}},"bytes":7988},"dist/lib/browser/translations.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":582},"dist/lib/browser/translations.mjs":{"imports":[],"exports":["translationKey","translations"],"entryPoint":"src/translations.ts","inputs":{"src/translations.ts":{"bytesInOutput":167}},"bytes":277}}}
@@ -0,0 +1,16 @@
1
+ // src/translations.ts
2
+ var translationKey = "@dxos/react-ui-calendar";
3
+ var translations = [
4
+ {
5
+ "en-US": {
6
+ [translationKey]: {
7
+ "today.button": "Today"
8
+ }
9
+ }
10
+ }
11
+ ];
12
+ export {
13
+ translationKey,
14
+ translations
15
+ };
16
+ //# sourceMappingURL=translations.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/translations.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nexport const translationKey = '@dxos/react-ui-calendar';\n\nexport const translations = [\n {\n 'en-US': {\n [translationKey]: {\n 'today.button': 'Today',\n },\n },\n },\n] as const satisfies Resource[];\n"],
5
+ "mappings": ";AAMO,IAAMA,iBAAiB;AAEvB,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACD,cAAAA,GAAiB;QAChB,gBAAgB;MAClB;IACF;EACF;;",
6
+ "names": ["translationKey", "translations"]
7
+ }
@@ -0,0 +1,236 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // src/components/Calendar/Calendar.tsx
4
+ import { createContext } from "@radix-ui/react-context";
5
+ import { addDays, differenceInWeeks, format, startOfDay, startOfWeek } from "date-fns";
6
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
7
+ import { useResizeDetector } from "react-resize-detector";
8
+ import { List } from "react-virtualized";
9
+ import { Event } from "@dxos/async";
10
+ import { IconButton, useTranslation } from "@dxos/react-ui";
11
+ import { composable, composableProps, mx } from "@dxos/ui-theme";
12
+ import { translationKey } from "#translations";
13
+
14
+ // src/components/Calendar/util.ts
15
+ var getDate = (start2, weekNumber, dayOfWeek, weekStartsOn) => {
16
+ const result = new Date(start2);
17
+ const startDayOfWeek = start2.getDay();
18
+ const adjustedStartDay = (startDayOfWeek === 0 ? 7 : startDayOfWeek) - weekStartsOn;
19
+ result.setDate(start2.getDate() - adjustedStartDay + weekNumber * 7 + dayOfWeek);
20
+ return result;
21
+ };
22
+ var isSameDay = (date1, date2) => {
23
+ return !!date2 && date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate();
24
+ };
25
+
26
+ // src/components/Calendar/Calendar.tsx
27
+ var maxRows = 50 * 100;
28
+ var start = /* @__PURE__ */ new Date("1970-01-01");
29
+ var size = 48;
30
+ var defaultWidth = 7 * size;
31
+ var [CalendarContextProvider, useCalendarContext] = createContext("Calendar");
32
+ var CalendarRoot = /* @__PURE__ */ forwardRef(({ children, weekStartsOn = 1 }, forwardedRef) => {
33
+ const event = useMemo(() => new Event(), []);
34
+ const [selected, setSelected] = useState();
35
+ const [index, setIndex] = useState();
36
+ useImperativeHandle(forwardedRef, () => ({
37
+ scrollTo: (date) => {
38
+ event.emit({
39
+ type: "scroll",
40
+ date
41
+ });
42
+ }
43
+ }), [
44
+ event
45
+ ]);
46
+ return /* @__PURE__ */ React.createElement(CalendarContextProvider, {
47
+ weekStartsOn,
48
+ event,
49
+ index,
50
+ setIndex,
51
+ selected,
52
+ setSelected
53
+ }, children);
54
+ });
55
+ var CALENDAR_TOOLBAR_NAME = "CalendarHeader";
56
+ var CalendarToolbar = composable(({ classNames, ...props }, forwardedRef) => {
57
+ const { t } = useTranslation(translationKey);
58
+ const { weekStartsOn, event, index, selected } = useCalendarContext(CALENDAR_TOOLBAR_NAME);
59
+ const top = useMemo(() => getDate(start, index ?? 0, 6, weekStartsOn), [
60
+ index,
61
+ weekStartsOn
62
+ ]);
63
+ const today = useMemo(() => /* @__PURE__ */ new Date(), []);
64
+ const handleToday = useCallback(() => {
65
+ event.emit({
66
+ type: "scroll",
67
+ date: today
68
+ });
69
+ }, [
70
+ event,
71
+ start,
72
+ today
73
+ ]);
74
+ return /* @__PURE__ */ React.createElement("div", {
75
+ ...composableProps(props, {
76
+ role: "none",
77
+ classNames: [
78
+ "shrink-0 grid! grid-cols-3 items-center bg-toolbar-surface",
79
+ classNames
80
+ ]
81
+ }),
82
+ ref: forwardedRef,
83
+ style: {
84
+ width: defaultWidth
85
+ }
86
+ }, /* @__PURE__ */ React.createElement("div", {
87
+ className: "flex justify-start"
88
+ }, /* @__PURE__ */ React.createElement(IconButton, {
89
+ variant: "ghost",
90
+ icon: "ph--calendar--regular",
91
+ iconOnly: true,
92
+ classNames: "aspect-square",
93
+ label: t("today.button"),
94
+ onClick: handleToday
95
+ })), /* @__PURE__ */ React.createElement("div", {
96
+ className: "flex justify-center p-2 text-description"
97
+ }, format(selected ?? top, "MMMM")), /* @__PURE__ */ React.createElement("div", {
98
+ className: "flex justify-end p-2 text-description"
99
+ }, (selected ?? top).getFullYear()));
100
+ });
101
+ CalendarToolbar.displayName = CALENDAR_TOOLBAR_NAME;
102
+ var CALENDAR_GRID_NAME = "CalendarGrid";
103
+ var CalendarGrid = composable(({ classNames, rows, dates = [], onSelect, ...props }, forwardedRef) => {
104
+ const { weekStartsOn, event, setIndex, selected, setSelected } = useCalendarContext(CALENDAR_GRID_NAME);
105
+ const { ref: containerRef, width = 0, height = 0 } = useResizeDetector();
106
+ const maxHeight = rows ? rows * size : void 0;
107
+ const listRef = useRef(null);
108
+ const today = useMemo(() => /* @__PURE__ */ new Date(), []);
109
+ const dateSet = useMemo(() => new Set(dates.map((date) => startOfDay(date).toISOString())), [
110
+ dates
111
+ ]);
112
+ const hasDate = useCallback((date) => dateSet.has(startOfDay(date).toISOString()), [
113
+ dateSet
114
+ ]);
115
+ const [initialized, setInitialized] = useState(false);
116
+ useEffect(() => {
117
+ const index = differenceInWeeks(today, start);
118
+ listRef.current?.scrollToRow(index);
119
+ }, [
120
+ initialized,
121
+ start,
122
+ today
123
+ ]);
124
+ useEffect(() => {
125
+ return event.on((event2) => {
126
+ switch (event2.type) {
127
+ case "scroll": {
128
+ const index = differenceInWeeks(event2.date, start);
129
+ listRef.current?.scrollToRow(index);
130
+ break;
131
+ }
132
+ }
133
+ });
134
+ }, [
135
+ event
136
+ ]);
137
+ const days = useMemo(() => {
138
+ const weekStart = startOfWeek(/* @__PURE__ */ new Date(), {
139
+ weekStartsOn
140
+ });
141
+ return Array.from({
142
+ length: 7
143
+ }, (_, i) => {
144
+ const day = addDays(weekStart, i);
145
+ return format(day, "EEE");
146
+ });
147
+ }, []);
148
+ const handleDaySelect = useCallback((date) => {
149
+ setSelected((current) => isSameDay(date, current) ? void 0 : date);
150
+ onSelect?.({
151
+ date
152
+ });
153
+ }, [
154
+ onSelect
155
+ ]);
156
+ const handleScroll = useCallback((info) => {
157
+ setIndex(Math.round(info.scrollTop / size));
158
+ }, []);
159
+ const rowRenderer = useCallback(({ key, index, style }) => {
160
+ const getBgColor = (date) => date.getMonth() % 2 === 0 && "bg-modal-surface";
161
+ return /* @__PURE__ */ React.createElement("div", {
162
+ key,
163
+ style,
164
+ className: "grid"
165
+ }, /* @__PURE__ */ React.createElement("div", {
166
+ className: "grid grid-cols-7 bg-input-surface",
167
+ style: {
168
+ gridTemplateColumns: `repeat(7, ${size}px)`
169
+ }
170
+ }, Array.from({
171
+ length: 7
172
+ }).map((_, i) => {
173
+ const date = getDate(start, index, i, weekStartsOn);
174
+ const border = isSameDay(date, selected) ? "border-primary-500" : isSameDay(date, today) ? "border-amber-500" : hasDate(date) ? "border-neutral-700 border-dashed" : void 0;
175
+ return /* @__PURE__ */ React.createElement("div", {
176
+ key: i,
177
+ className: mx("relative flex justify-center items-center cursor-pointer", getBgColor(date)),
178
+ onClick: () => handleDaySelect(date)
179
+ }, /* @__PURE__ */ React.createElement("span", {
180
+ className: "text-description"
181
+ }, date.getDate()), !border && date.getDate() === 1 && /* @__PURE__ */ React.createElement("span", {
182
+ className: "absolute top-0 text-xs text-description"
183
+ }, format(date, "MMM")), border && /* @__PURE__ */ React.createElement("div", {
184
+ className: mx("absolute inset-1 border-2 rounded-full", border)
185
+ }));
186
+ })));
187
+ }, [
188
+ handleDaySelect,
189
+ hasDate,
190
+ selected,
191
+ weekStartsOn
192
+ ]);
193
+ return /* @__PURE__ */ React.createElement("div", {
194
+ ...composableProps(props, {
195
+ role: "none",
196
+ classNames: [
197
+ "flex flex-col h-full w-full justify-center overflow-hidden",
198
+ classNames
199
+ ]
200
+ }),
201
+ ref: forwardedRef
202
+ }, /* @__PURE__ */ React.createElement("div", {
203
+ className: "grid w-full grid-cols-7",
204
+ style: {
205
+ width: defaultWidth
206
+ }
207
+ }, days.map((date, i) => /* @__PURE__ */ React.createElement("div", {
208
+ key: i,
209
+ className: "flex justify-center p-2 text-sm font-thin"
210
+ }, date))), /* @__PURE__ */ React.createElement("div", {
211
+ className: "flex flex-col h-full w-full justify-center overflow-hidden",
212
+ ref: containerRef
213
+ }, /* @__PURE__ */ React.createElement(List, {
214
+ ref: listRef,
215
+ role: "none",
216
+ className: "scrollbar-none outline-hidden",
217
+ width,
218
+ height: maxHeight ?? height,
219
+ rowCount: maxRows,
220
+ rowHeight: size,
221
+ rowRenderer,
222
+ scrollToAlignment: "start",
223
+ onScroll: handleScroll,
224
+ onRowsRendered: () => setInitialized(true)
225
+ })));
226
+ });
227
+ CalendarGrid.displayName = CALENDAR_GRID_NAME;
228
+ var Calendar = {
229
+ Root: CalendarRoot,
230
+ Toolbar: CalendarToolbar,
231
+ Grid: CalendarGrid
232
+ };
233
+ export {
234
+ Calendar
235
+ };
236
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Calendar/Calendar.tsx", "../../../src/components/Calendar/util.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext } from '@radix-ui/react-context';\nimport { type Day, addDays, differenceInWeeks, format, startOfDay, startOfWeek } from 'date-fns';\nimport React, {\n type Dispatch,\n type PropsWithChildren,\n type SetStateAction,\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\nimport { List, type ListProps, type ListRowRenderer } from 'react-virtualized';\n\nimport { Event } from '@dxos/async';\nimport { IconButton, useTranslation } from '@dxos/react-ui';\nimport { composable, composableProps, mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport { getDate, isSameDay } from './util';\n\nconst maxRows = 50 * 100;\nconst start = new Date('1970-01-01');\nconst size = 48;\nconst defaultWidth = 7 * size;\n\n//\n// Context\n//\n\ntype CalendarEvent = {\n type: 'scroll';\n date: Date;\n};\n\ntype CalendarContextValue = {\n weekStartsOn: Day;\n event: Event<CalendarEvent>;\n index: number | undefined;\n setIndex: Dispatch<SetStateAction<number | undefined>>;\n selected: Date | undefined;\n setSelected: Dispatch<SetStateAction<Date | undefined>>;\n};\n\nconst [CalendarContextProvider, useCalendarContext] = createContext<CalendarContextValue>('Calendar');\n\n//\n// Controller\n//\n\ntype CalendarController = {\n scrollTo: (date: Date) => void;\n};\n\n//\n// Root\n//\n\ntype CalendarRootProps = PropsWithChildren<Partial<Pick<CalendarContextValue, 'weekStartsOn'>>>;\n\nconst CalendarRoot = forwardRef<CalendarController, CalendarRootProps>(\n ({ children, weekStartsOn = 1 }, forwardedRef) => {\n const event = useMemo(() => new Event<CalendarEvent>(), []);\n const [selected, setSelected] = useState<Date | undefined>();\n const [index, setIndex] = useState<number | undefined>();\n\n useImperativeHandle(\n forwardedRef,\n () => ({\n scrollTo: (date: Date) => {\n event.emit({ type: 'scroll', date });\n },\n }),\n [event],\n );\n\n return (\n <CalendarContextProvider\n weekStartsOn={weekStartsOn}\n event={event}\n index={index}\n setIndex={setIndex}\n selected={selected}\n setSelected={setSelected}\n >\n {children}\n </CalendarContextProvider>\n );\n },\n);\n\n//\n// Header\n//\n\nconst CALENDAR_TOOLBAR_NAME = 'CalendarHeader';\n\ntype CalendarToolbarProps = {};\n\nconst CalendarToolbar = composable<HTMLDivElement, CalendarToolbarProps>(({ classNames, ...props }, forwardedRef) => {\n const { t } = useTranslation(translationKey);\n const { weekStartsOn, event, index, selected } = useCalendarContext(CALENDAR_TOOLBAR_NAME);\n const top = useMemo(() => getDate(start, index ?? 0, 6, weekStartsOn), [index, weekStartsOn]);\n const today = useMemo(() => new Date(), []);\n\n const handleToday = useCallback(() => {\n event.emit({ type: 'scroll', date: today });\n }, [event, start, today]);\n\n return (\n <div\n {...composableProps(props, {\n role: 'none',\n classNames: ['shrink-0 grid! grid-cols-3 items-center bg-toolbar-surface', classNames],\n })}\n ref={forwardedRef}\n style={{ width: defaultWidth }}\n >\n <div className='flex justify-start'>\n <IconButton\n variant='ghost'\n icon='ph--calendar--regular'\n iconOnly\n classNames='aspect-square'\n label={t('today.button')}\n onClick={handleToday}\n />\n </div>\n <div className='flex justify-center p-2 text-description'>{format(selected ?? top, 'MMMM')}</div>\n <div className='flex justify-end p-2 text-description'>{(selected ?? top).getFullYear()}</div>\n </div>\n );\n});\n\nCalendarToolbar.displayName = CALENDAR_TOOLBAR_NAME;\n\n//\n// Grid\n// TODO(burdon): Key nav.\n// TODO(burdon): Drag range.\n//\n\nconst CALENDAR_GRID_NAME = 'CalendarGrid';\n\ntype CalendarGridProps = {\n rows?: number;\n /** Dates to highlight on the grid. Each date that appears in this array receives a border indicator. */\n dates?: Date[];\n onSelect?: (event: { date: Date }) => void;\n};\n\nconst CalendarGrid = composable<HTMLDivElement, CalendarGridProps>(\n ({ classNames, rows, dates = [], onSelect, ...props }, forwardedRef) => {\n const { weekStartsOn, event, setIndex, selected, setSelected } = useCalendarContext(CALENDAR_GRID_NAME);\n const { ref: containerRef, width = 0, height = 0 } = useResizeDetector();\n const maxHeight = rows ? rows * size : undefined;\n const listRef = useRef<List>(null);\n const today = useMemo(() => new Date(), []);\n\n // Build a set of ISO date strings (YYYY-MM-DD) for O(1) per-cell lookup.\n const dateSet = useMemo(() => new Set(dates.map((date) => startOfDay(date).toISOString())), [dates]);\n\n const hasDate = useCallback((date: Date) => dateSet.has(startOfDay(date).toISOString()), [dateSet]);\n\n const [initialized, setInitialized] = useState(false);\n useEffect(() => {\n const index = differenceInWeeks(today, start);\n listRef.current?.scrollToRow(index);\n }, [initialized, start, today]);\n\n useEffect(() => {\n return event.on((event) => {\n switch (event.type) {\n case 'scroll': {\n const index = differenceInWeeks(event.date, start);\n listRef.current?.scrollToRow(index);\n break;\n }\n }\n });\n }, [event]);\n\n const days = useMemo(() => {\n const weekStart = startOfWeek(new Date(), { weekStartsOn });\n return Array.from({ length: 7 }, (_, i) => {\n const day = addDays(weekStart, i);\n return format(day, 'EEE'); // Short day name (Mon, Tue, etc.)\n });\n }, []);\n\n // TODO(burdon): Get info by range.\n\n const handleDaySelect = useCallback(\n (date: Date) => {\n setSelected((current) => (isSameDay(date, current) ? undefined : date));\n onSelect?.({ date });\n },\n [onSelect],\n );\n\n const handleScroll = useCallback<NonNullable<ListProps['onScroll']>>((info) => {\n setIndex(Math.round(info.scrollTop / size));\n }, []);\n\n const rowRenderer = useCallback<ListRowRenderer>(\n ({ key, index, style }) => {\n const getBgColor = (date: Date) => date.getMonth() % 2 === 0 && 'bg-modal-surface';\n return (\n <div key={key} style={style} className='grid'>\n <div className='grid grid-cols-7 bg-input-surface' style={{ gridTemplateColumns: `repeat(7, ${size}px)` }}>\n {Array.from({ length: 7 }).map((_, i) => {\n const date = getDate(start, index, i, weekStartsOn);\n const border = isSameDay(date, selected)\n ? 'border-primary-500'\n : isSameDay(date, today)\n ? 'border-amber-500'\n : hasDate(date)\n ? 'border-neutral-700 border-dashed'\n : undefined;\n\n return (\n <div\n key={i}\n className={mx('relative flex justify-center items-center cursor-pointer', getBgColor(date))}\n onClick={() => handleDaySelect(date)}\n >\n <span className='text-description'>{date.getDate()}</span>\n {!border && date.getDate() === 1 && (\n <span className='absolute top-0 text-xs text-description'>{format(date, 'MMM')}</span>\n )}\n {border && <div className={mx('absolute inset-1 border-2 rounded-full', border)} />}\n </div>\n );\n })}\n </div>\n </div>\n );\n },\n [handleDaySelect, hasDate, selected, weekStartsOn],\n );\n\n return (\n <div\n {...composableProps(props, {\n role: 'none',\n classNames: ['flex flex-col h-full w-full justify-center overflow-hidden', classNames],\n })}\n ref={forwardedRef}\n >\n {/* Day of week labels */}\n <div className='grid w-full grid-cols-7' style={{ width: defaultWidth }}>\n {days.map((date, i) => (\n <div key={i} className='flex justify-center p-2 text-sm font-thin'>\n {date}\n </div>\n ))}\n </div>\n\n {/* Grid */}\n <div className='flex flex-col h-full w-full justify-center overflow-hidden' ref={containerRef}>\n <List\n ref={listRef}\n role='none'\n className='scrollbar-none outline-hidden'\n width={width}\n height={maxHeight ?? height}\n rowCount={maxRows}\n rowHeight={size}\n rowRenderer={rowRenderer}\n scrollToAlignment='start'\n onScroll={handleScroll}\n onRowsRendered={() => setInitialized(true)}\n />\n </div>\n </div>\n );\n },\n);\n\nCalendarGrid.displayName = CALENDAR_GRID_NAME;\n\n//\n// Calendar\n//\n\nexport const Calendar = {\n Root: CalendarRoot,\n Toolbar: CalendarToolbar,\n Grid: CalendarGrid,\n};\n\nexport type { CalendarController, CalendarRootProps, CalendarToolbarProps, CalendarGridProps };\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Day } from 'date-fns';\n\nexport const getDate = (start: Date, weekNumber: number, dayOfWeek: number, weekStartsOn: Day): Date => {\n const result = new Date(start);\n const startDayOfWeek = start.getDay(); // 0 = Sunday, 1 = Monday, etc.\n const adjustedStartDay = (startDayOfWeek === 0 ? 7 : startDayOfWeek) - weekStartsOn; // Adjust for weekStartsOn.\n result.setDate(start.getDate() - adjustedStartDay + weekNumber * 7 + dayOfWeek);\n return result;\n};\n\nexport const isSameDay = (date1: Date, date2: Date | undefined): boolean => {\n return (\n !!date2 &&\n date1.getFullYear() === date2.getFullYear() &&\n date1.getMonth() === date2.getMonth() &&\n date1.getDate() === date2.getDate()\n );\n};\n"],
5
+ "mappings": ";;;AAIA,SAASA,qBAAqB;AAC9B,SAAmBC,SAASC,mBAAmBC,QAAQC,YAAYC,mBAAmB;AACtF,OAAOC,SAILC,YACAC,aACAC,WACAC,qBACAC,SACAC,QACAC,gBACK;AACP,SAASC,yBAAyB;AAClC,SAASC,YAAkD;AAE3D,SAAS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CO,OAAO7B,MAAM,KAAA,CAAA,GAEzEgF,UAAU,sBAAA,cAAChE,OAAAA;QAAIM,WAAW2D,GAAG,0CAA0CD,MAAAA;;IAG9E,CAAA,CAAA,CAAA;EAIR,GACA;IAACZ;IAAiBnB;IAASxD;IAAUL;GAAa;AAGpD,SACE,sBAAA,cAAC4B,OAAAA;IACE,GAAGC,gBAAgBV,OAAO;MACzBW,MAAM;MACNZ,YAAY;QAAC;QAA8DA;;IAC7E,CAAA;IACAa,KAAK9B;KAGL,sBAAA,cAAC2B,OAAAA;IAAIM,WAAU;IAA0BF,OAAO;MAAEC,OAAOxC;IAAa;KACnE6E,KAAKZ,IAAI,CAAC9C,MAAMiE,MACf,sBAAA,cAACjD,OAAAA;IAAI4D,KAAKX;IAAG3C,WAAU;KACpBtB,IAAAA,CAAAA,CAAAA,GAMP,sBAAA,cAACgB,OAAAA;IAAIM,WAAU;IAA6DH,KAAKkB;KAC/E,sBAAA,cAAC8C,MAAAA;IACChE,KAAKuB;IACLxB,MAAK;IACLI,WAAU;IACVD;IACAiB,QAAQE,aAAaF;IACrB8C,UAAU3G;IACV4G,WAAWzG;IACX+F;IACAW,mBAAkB;IAClBC,UAAUjB;IACVkB,gBAAgB,MAAMpC,eAAe,IAAA;;AAK/C,CAAA;AAGFnB,aAAaF,cAAcC;AAMpB,IAAMyD,WAAW;EACtBC,MAAMzG;EACN0G,SAASvF;EACTwF,MAAM3D;AACR;",
6
+ "names": ["createContext", "addDays", "differenceInWeeks", "format", "startOfDay", "startOfWeek", "React", "forwardRef", "useCallback", "useEffect", "useImperativeHandle", "useMemo", "useRef", "useState", "useResizeDetector", "List", "Event", "IconButton", "useTranslation", "composable", "composableProps", "mx", "translationKey", "getDate", "start", "weekNumber", "dayOfWeek", "weekStartsOn", "result", "Date", "startDayOfWeek", "getDay", "adjustedStartDay", "setDate", "isSameDay", "date1", "date2", "getFullYear", "getMonth", "maxRows", "start", "Date", "size", "defaultWidth", "CalendarContextProvider", "useCalendarContext", "createContext", "CalendarRoot", "forwardRef", "children", "weekStartsOn", "forwardedRef", "event", "useMemo", "Event", "selected", "setSelected", "useState", "index", "setIndex", "useImperativeHandle", "scrollTo", "date", "emit", "type", "CALENDAR_TOOLBAR_NAME", "CalendarToolbar", "composable", "classNames", "props", "t", "useTranslation", "translationKey", "top", "getDate", "today", "handleToday", "useCallback", "div", "composableProps", "role", "ref", "style", "width", "className", "IconButton", "variant", "icon", "iconOnly", "label", "onClick", "format", "getFullYear", "displayName", "CALENDAR_GRID_NAME", "CalendarGrid", "rows", "dates", "onSelect", "containerRef", "height", "useResizeDetector", "maxHeight", "undefined", "listRef", "useRef", "dateSet", "Set", "map", "startOfDay", "toISOString", "hasDate", "has", "initialized", "setInitialized", "useEffect", "differenceInWeeks", "current", "scrollToRow", "on", "days", "weekStart", "startOfWeek", "Array", "from", "length", "_", "i", "day", "addDays", "handleDaySelect", "isSameDay", "handleScroll", "info", "Math", "round", "scrollTop", "rowRenderer", "key", "getBgColor", "getMonth", "gridTemplateColumns", "border", "mx", "span", "List", "rowCount", "rowHeight", "scrollToAlignment", "onScroll", "onRowsRendered", "Calendar", "Root", "Toolbar", "Grid"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"src/components/Calendar/util.ts":{"bytes":2699,"imports":[],"format":"esm"},"src/components/Calendar/Calendar.tsx":{"bytes":29347,"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"date-fns","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"react-virtualized","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true},{"path":"src/components/Calendar/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/components/Calendar/index.ts":{"bytes":376,"imports":[{"path":"src/components/Calendar/Calendar.tsx","kind":"import-statement","original":"./Calendar"}],"format":"esm"},"src/components/index.ts":{"bytes":376,"imports":[{"path":"src/components/Calendar/index.ts","kind":"import-statement","original":"./Calendar"}],"format":"esm"},"src/index.ts":{"bytes":382,"imports":[{"path":"src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"},"src/translations.ts":{"bytes":1105,"imports":[],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17461},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"date-fns","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"react-virtualized","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true}],"exports":["Calendar"],"entryPoint":"src/index.ts","inputs":{"src/components/Calendar/Calendar.tsx":{"bytesInOutput":7296},"src/components/Calendar/util.ts":{"bytesInOutput":517},"src/components/Calendar/index.ts":{"bytesInOutput":0},"src/components/index.ts":{"bytesInOutput":0},"src/index.ts":{"bytesInOutput":0}},"bytes":8081},"dist/lib/node-esm/translations.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":584},"dist/lib/node-esm/translations.mjs":{"imports":[],"exports":["translationKey","translations"],"entryPoint":"src/translations.ts","inputs":{"src/translations.ts":{"bytesInOutput":167}},"bytes":370}}}
@@ -0,0 +1,18 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // src/translations.ts
4
+ var translationKey = "@dxos/react-ui-calendar";
5
+ var translations = [
6
+ {
7
+ "en-US": {
8
+ [translationKey]: {
9
+ "today.button": "Today"
10
+ }
11
+ }
12
+ }
13
+ ];
14
+ export {
15
+ translationKey,
16
+ translations
17
+ };
18
+ //# sourceMappingURL=translations.mjs.map