@dxos/react-ui-calendar 0.8.4-main.e8ec1fe → 0.8.4-main.ef1bc66f44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +196 -214
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +196 -214
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Calendar/Calendar.d.ts.map +1 -1
- package/dist/types/src/components/Calendar/Calendar.stories.d.ts +1 -1
- package/dist/types/src/translations.d.ts +2 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -22
- package/src/components/Calendar/Calendar.stories.tsx +1 -1
- package/src/components/Calendar/Calendar.tsx +12 -6
- package/src/translations.ts +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/components/Calendar/Calendar.tsx
|
|
2
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
3
2
|
import { createContext } from "@radix-ui/react-context";
|
|
4
3
|
import { addDays, differenceInWeeks, format, startOfWeek } from "date-fns";
|
|
5
4
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
@@ -7,10 +6,10 @@ import { useResizeDetector } from "react-resize-detector";
|
|
|
7
6
|
import { List } from "react-virtualized";
|
|
8
7
|
import { Event } from "@dxos/async";
|
|
9
8
|
import { Icon, IconButton, useTranslation } from "@dxos/react-ui";
|
|
10
|
-
import { mx } from "@dxos/
|
|
9
|
+
import { mx } from "@dxos/ui-theme";
|
|
11
10
|
|
|
12
11
|
// src/translations.ts
|
|
13
|
-
var translationKey = "react-ui-calendar";
|
|
12
|
+
var translationKey = "@dxos/react-ui-calendar";
|
|
14
13
|
var translations = [
|
|
15
14
|
{
|
|
16
15
|
"en-US": {
|
|
@@ -40,233 +39,216 @@ var size = 48;
|
|
|
40
39
|
var defaultWidth = 7 * size;
|
|
41
40
|
var [CalendarContextProvider, useCalendarContext] = createContext("Calendar");
|
|
42
41
|
var CalendarRoot = /* @__PURE__ */ forwardRef(({ children, weekStartsOn = 1 }, forwardedRef) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
setSelected
|
|
65
|
-
}, children);
|
|
66
|
-
} finally {
|
|
67
|
-
_effect.f();
|
|
68
|
-
}
|
|
42
|
+
const event = useMemo(() => new Event(), []);
|
|
43
|
+
const [selected, setSelected] = useState();
|
|
44
|
+
const [index, setIndex] = useState();
|
|
45
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
46
|
+
scrollTo: (date) => {
|
|
47
|
+
event.emit({
|
|
48
|
+
type: "scroll",
|
|
49
|
+
date
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}), [
|
|
53
|
+
event
|
|
54
|
+
]);
|
|
55
|
+
return /* @__PURE__ */ React.createElement(CalendarContextProvider, {
|
|
56
|
+
weekStartsOn,
|
|
57
|
+
event,
|
|
58
|
+
index,
|
|
59
|
+
setIndex,
|
|
60
|
+
selected,
|
|
61
|
+
setSelected
|
|
62
|
+
}, children);
|
|
69
63
|
});
|
|
64
|
+
var CALENDAR_VIEWPORT_NAME = "CalendarContent";
|
|
70
65
|
var CalendarViewport = ({ children, classNames }) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
className: mx("flex flex-col items-center overflow-hidden bg-inputSurface", classNames)
|
|
76
|
-
}, children);
|
|
77
|
-
} finally {
|
|
78
|
-
_effect.f();
|
|
79
|
-
}
|
|
66
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
67
|
+
role: "none",
|
|
68
|
+
className: mx("flex flex-col items-center overflow-hidden bg-inputSurface", classNames)
|
|
69
|
+
}, children);
|
|
80
70
|
};
|
|
81
|
-
CalendarViewport.displayName =
|
|
71
|
+
CalendarViewport.displayName = CALENDAR_VIEWPORT_NAME;
|
|
72
|
+
var CALENDAR_TOOLBAR_NAME = "CalendarHeader";
|
|
82
73
|
var CalendarToolbar = ({ classNames }) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
className: "flex justify-end p-2 text-description"
|
|
122
|
-
}, (selected ?? top).getFullYear()));
|
|
123
|
-
} finally {
|
|
124
|
-
_effect.f();
|
|
125
|
-
}
|
|
74
|
+
const { t } = useTranslation(translationKey);
|
|
75
|
+
const { weekStartsOn, event, index, selected } = useCalendarContext(CALENDAR_TOOLBAR_NAME);
|
|
76
|
+
const top = useMemo(() => getDate(start, index ?? 0, 6, weekStartsOn), [
|
|
77
|
+
index,
|
|
78
|
+
weekStartsOn
|
|
79
|
+
]);
|
|
80
|
+
const today = useMemo(() => /* @__PURE__ */ new Date(), []);
|
|
81
|
+
const handleToday = useCallback(() => {
|
|
82
|
+
event.emit({
|
|
83
|
+
type: "scroll",
|
|
84
|
+
date: today
|
|
85
|
+
});
|
|
86
|
+
}, [
|
|
87
|
+
event,
|
|
88
|
+
start,
|
|
89
|
+
today
|
|
90
|
+
]);
|
|
91
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
92
|
+
role: "none",
|
|
93
|
+
className: mx("shink-0 is-full grid grid-cols-3 items-center bg-barSurface", classNames),
|
|
94
|
+
style: {
|
|
95
|
+
width: defaultWidth
|
|
96
|
+
}
|
|
97
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
98
|
+
className: "flex justify-start"
|
|
99
|
+
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
100
|
+
variant: "ghost",
|
|
101
|
+
size: 5,
|
|
102
|
+
icon: "ph--calendar--regular",
|
|
103
|
+
iconOnly: true,
|
|
104
|
+
classNames: "aspect-square",
|
|
105
|
+
label: t("today button"),
|
|
106
|
+
onClick: handleToday
|
|
107
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
108
|
+
className: "flex justify-center p-2 text-description"
|
|
109
|
+
}, format(selected ?? top, "MMMM")), /* @__PURE__ */ React.createElement("div", {
|
|
110
|
+
className: "flex justify-end p-2 text-description"
|
|
111
|
+
}, (selected ?? top).getFullYear()));
|
|
126
112
|
};
|
|
127
|
-
CalendarToolbar.displayName =
|
|
113
|
+
CalendarToolbar.displayName = CALENDAR_TOOLBAR_NAME;
|
|
114
|
+
var CALENDAR_GRID_NAME = "CalendarGrid";
|
|
128
115
|
var CalendarGrid = ({ classNames, rows, onSelect }) => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
listRef.current?.scrollToRow(index);
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
116
|
+
const { weekStartsOn, event, setIndex, selected, setSelected } = useCalendarContext(CALENDAR_GRID_NAME);
|
|
117
|
+
const { ref: containerRef, width = 0, height = 0 } = useResizeDetector();
|
|
118
|
+
const maxHeight = rows ? rows * size : void 0;
|
|
119
|
+
const listRef = useRef(null);
|
|
120
|
+
const today = useMemo(() => /* @__PURE__ */ new Date(), []);
|
|
121
|
+
const [initialized, setInitialized] = useState(false);
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
const index = differenceInWeeks(today, start);
|
|
124
|
+
listRef.current?.scrollToRow(index);
|
|
125
|
+
}, [
|
|
126
|
+
initialized,
|
|
127
|
+
start,
|
|
128
|
+
today
|
|
129
|
+
]);
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
return event.on((event2) => {
|
|
132
|
+
switch (event2.type) {
|
|
133
|
+
case "scroll": {
|
|
134
|
+
const index = differenceInWeeks(event2.date, start);
|
|
135
|
+
listRef.current?.scrollToRow(index);
|
|
136
|
+
break;
|
|
153
137
|
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
});
|
|
162
|
-
return Array.from({
|
|
163
|
-
length: 7
|
|
164
|
-
}, (_, i) => {
|
|
165
|
-
const day = addDays(weekStart, i);
|
|
166
|
-
return format(day, "EEE");
|
|
167
|
-
});
|
|
168
|
-
}, []);
|
|
169
|
-
const getNumAppointments = useCallback((_date) => {
|
|
170
|
-
return 0;
|
|
171
|
-
}, []);
|
|
172
|
-
const handleDaySelect = useCallback((date) => {
|
|
173
|
-
setSelected((current) => isSameDay(date, current) ? void 0 : date);
|
|
174
|
-
onSelect?.({
|
|
175
|
-
date
|
|
176
|
-
});
|
|
177
|
-
}, [
|
|
178
|
-
onSelect
|
|
179
|
-
]);
|
|
180
|
-
const handleScroll = useCallback((info) => {
|
|
181
|
-
setIndex(Math.round(info.scrollTop / size));
|
|
182
|
-
}, []);
|
|
183
|
-
const rowRenderer = useCallback(({ key, index, style }) => {
|
|
184
|
-
const getBgColor = (date) => date.getMonth() % 2 === 0 && "bg-modalSurface";
|
|
185
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
186
|
-
key,
|
|
187
|
-
role: "none",
|
|
188
|
-
style,
|
|
189
|
-
className: "is-full grid grid-cols-[1fr_max-content_1fr] snap-center"
|
|
190
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
191
|
-
role: "none",
|
|
192
|
-
className: mx(getBgColor(getDate(start, index, 0, weekStartsOn)))
|
|
193
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
194
|
-
role: "none",
|
|
195
|
-
className: "grid grid-cols-7",
|
|
196
|
-
style: {
|
|
197
|
-
gridTemplateColumns: `repeat(7, ${size}px)`
|
|
198
|
-
}
|
|
199
|
-
}, Array.from({
|
|
200
|
-
length: 7
|
|
201
|
-
}).map((_, i) => {
|
|
202
|
-
const date = getDate(start, index, i, weekStartsOn);
|
|
203
|
-
const num = getNumAppointments(date);
|
|
204
|
-
const border = isSameDay(date, selected) ? "border-primary-500" : isSameDay(date, today) ? "border-amber-500" : void 0;
|
|
205
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
206
|
-
key: i,
|
|
207
|
-
role: "none",
|
|
208
|
-
className: mx("relative flex justify-center items-center cursor-pointer", getBgColor(date)),
|
|
209
|
-
onClick: () => handleDaySelect(date)
|
|
210
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
211
|
-
className: "text-description"
|
|
212
|
-
}, date.getDate()), !border && date.getDate() === 1 && /* @__PURE__ */ React.createElement("span", {
|
|
213
|
-
className: "absolute top-0 text-xs text-description"
|
|
214
|
-
}, format(date, "MMM")), border && /* @__PURE__ */ React.createElement("div", {
|
|
215
|
-
role: "none",
|
|
216
|
-
className: mx("absolute top-0 left-0 is-full bs-full border-2 rounded-full", border)
|
|
217
|
-
}), num > 0 && /* @__PURE__ */ React.createElement(Icon, {
|
|
218
|
-
classNames: "absolute bottom-0",
|
|
219
|
-
icon: num > 3 ? "ph--dots-three--regular" : "ph--dot--regular",
|
|
220
|
-
size: 5
|
|
221
|
-
}));
|
|
222
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
223
|
-
className: mx(getBgColor(getDate(start, index, 6, weekStartsOn)))
|
|
224
|
-
}));
|
|
225
|
-
}, [
|
|
226
|
-
handleDaySelect,
|
|
227
|
-
getNumAppointments,
|
|
228
|
-
selected,
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}, [
|
|
141
|
+
event
|
|
142
|
+
]);
|
|
143
|
+
const days = useMemo(() => {
|
|
144
|
+
const weekStart = startOfWeek(/* @__PURE__ */ new Date(), {
|
|
229
145
|
weekStartsOn
|
|
230
|
-
|
|
146
|
+
});
|
|
147
|
+
return Array.from({
|
|
148
|
+
length: 7
|
|
149
|
+
}, (_, i) => {
|
|
150
|
+
const day = addDays(weekStart, i);
|
|
151
|
+
return format(day, "EEE");
|
|
152
|
+
});
|
|
153
|
+
}, []);
|
|
154
|
+
const getNumAppointments = useCallback((_date) => {
|
|
155
|
+
return 0;
|
|
156
|
+
}, []);
|
|
157
|
+
const handleDaySelect = useCallback((date) => {
|
|
158
|
+
setSelected((current) => isSameDay(date, current) ? void 0 : date);
|
|
159
|
+
onSelect?.({
|
|
160
|
+
date
|
|
161
|
+
});
|
|
162
|
+
}, [
|
|
163
|
+
onSelect
|
|
164
|
+
]);
|
|
165
|
+
const handleScroll = useCallback((info) => {
|
|
166
|
+
setIndex(Math.round(info.scrollTop / size));
|
|
167
|
+
}, []);
|
|
168
|
+
const rowRenderer = useCallback(({ key, index, style }) => {
|
|
169
|
+
const getBgColor = (date) => date.getMonth() % 2 === 0 && "bg-modalSurface";
|
|
231
170
|
return /* @__PURE__ */ React.createElement("div", {
|
|
171
|
+
key,
|
|
232
172
|
role: "none",
|
|
233
|
-
|
|
173
|
+
style,
|
|
174
|
+
className: "is-full grid grid-cols-[1fr_max-content_1fr] snap-center"
|
|
234
175
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
235
176
|
role: "none",
|
|
236
|
-
className:
|
|
237
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
177
|
+
className: mx(getBgColor(getDate(start, index, 0, weekStartsOn)))
|
|
178
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
238
179
|
role: "none",
|
|
239
|
-
className: "
|
|
180
|
+
className: "grid grid-cols-7",
|
|
240
181
|
style: {
|
|
241
|
-
|
|
182
|
+
gridTemplateColumns: `repeat(7, ${size}px)`
|
|
242
183
|
}
|
|
243
|
-
},
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
184
|
+
}, Array.from({
|
|
185
|
+
length: 7
|
|
186
|
+
}).map((_, i) => {
|
|
187
|
+
const date = getDate(start, index, i, weekStartsOn);
|
|
188
|
+
const num = getNumAppointments(date);
|
|
189
|
+
const border = isSameDay(date, selected) ? "border-primary-500" : isSameDay(date, today) ? "border-amber-500" : void 0;
|
|
190
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
191
|
+
key: i,
|
|
192
|
+
role: "none",
|
|
193
|
+
className: mx("relative flex justify-center items-center cursor-pointer", getBgColor(date)),
|
|
194
|
+
onClick: () => handleDaySelect(date)
|
|
195
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
196
|
+
className: "text-description"
|
|
197
|
+
}, date.getDate()), !border && date.getDate() === 1 && /* @__PURE__ */ React.createElement("span", {
|
|
198
|
+
className: "absolute top-0 text-xs text-description"
|
|
199
|
+
}, format(date, "MMM")), border && /* @__PURE__ */ React.createElement("div", {
|
|
200
|
+
role: "none",
|
|
201
|
+
className: mx("absolute top-0 left-0 is-full bs-full border-2 rounded-full", border)
|
|
202
|
+
}), num > 0 && /* @__PURE__ */ React.createElement(Icon, {
|
|
203
|
+
classNames: "absolute bottom-0",
|
|
204
|
+
icon: num > 3 ? "ph--dots-three--regular" : "ph--dot--regular",
|
|
205
|
+
size: 5
|
|
206
|
+
}));
|
|
207
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
208
|
+
className: mx(getBgColor(getDate(start, index, 6, weekStartsOn)))
|
|
209
|
+
}));
|
|
210
|
+
}, [
|
|
211
|
+
handleDaySelect,
|
|
212
|
+
getNumAppointments,
|
|
213
|
+
selected,
|
|
214
|
+
weekStartsOn
|
|
215
|
+
]);
|
|
216
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
217
|
+
role: "none",
|
|
218
|
+
className: mx("flex flex-col bs-full is-full justify-center overflow-hidden", classNames)
|
|
219
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
220
|
+
role: "none",
|
|
221
|
+
className: "flex justify-center bg-groupSurface"
|
|
222
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
223
|
+
role: "none",
|
|
224
|
+
className: "flex is-full grid grid-cols-7",
|
|
225
|
+
style: {
|
|
226
|
+
width: defaultWidth
|
|
227
|
+
}
|
|
228
|
+
}, days.map((date, i) => /* @__PURE__ */ React.createElement("div", {
|
|
229
|
+
key: i,
|
|
230
|
+
role: "none",
|
|
231
|
+
className: "flex justify-center p-2 text-sm font-thin"
|
|
232
|
+
}, date)))), /* @__PURE__ */ React.createElement("div", {
|
|
233
|
+
role: "none",
|
|
234
|
+
className: "flex flex-col bs-full is-full justify-center overflow-hidden",
|
|
235
|
+
ref: containerRef
|
|
236
|
+
}, /* @__PURE__ */ React.createElement(List, {
|
|
237
|
+
ref: listRef,
|
|
238
|
+
role: "none",
|
|
239
|
+
// TODO(burdon): Snap isn't working.
|
|
240
|
+
className: "[&>div]:snap-y scrollbar-none outline-none",
|
|
241
|
+
width,
|
|
242
|
+
height: maxHeight ?? height,
|
|
243
|
+
rowCount: maxRows,
|
|
244
|
+
rowHeight: size,
|
|
245
|
+
rowRenderer,
|
|
246
|
+
scrollToAlignment: "start",
|
|
247
|
+
onScroll: handleScroll,
|
|
248
|
+
onRowsRendered: () => setInitialized(true)
|
|
249
|
+
})));
|
|
268
250
|
};
|
|
269
|
-
CalendarGrid.displayName =
|
|
251
|
+
CalendarGrid.displayName = CALENDAR_GRID_NAME;
|
|
270
252
|
var Calendar = {
|
|
271
253
|
Root: CalendarRoot,
|
|
272
254
|
Viewport: CalendarViewport,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Calendar/Calendar.tsx", "../../../src/translations.ts", "../../../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, 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 { Icon, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-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// Viewport\n//\n\ntype CalendarViewportProps = PropsWithChildren<ThemedClassName>;\n\nconst CalendarViewport = ({ children, classNames }: CalendarViewportProps) => {\n return (\n <div role='none' className={mx('flex flex-col items-center overflow-hidden bg-inputSurface', classNames)}>\n {children}\n </div>\n );\n};\n\nCalendarViewport.displayName = 'CalendarContent';\n\n//\n// Header\n//\n\ntype CalendarToolbarProps = ThemedClassName;\n\nconst CalendarToolbar = ({ classNames }: CalendarToolbarProps) => {\n const { t } = useTranslation(translationKey);\n const { weekStartsOn, event, index, selected } = useCalendarContext(CalendarToolbar.displayName);\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 role='none'\n className={mx('shink-0 is-full grid grid-cols-3 items-center bg-barSurface', classNames)}\n style={{ width: defaultWidth }}\n >\n <div className='flex justify-start'>\n <IconButton\n variant='ghost'\n size={5}\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 = 'CalendarHeader';\n\n//\n// Grid\n// TODO(burdon): Key nav.\n// TODO(burdon): Drag range.\n//\n\ntype CalendarGridProps = ThemedClassName<{\n rows?: number;\n onSelect?: (event: { date: Date }) => void;\n}>;\n\nconst CalendarGrid = ({ classNames, rows, onSelect }: CalendarGridProps) => {\n const { weekStartsOn, event, setIndex, selected, setSelected } = useCalendarContext(CalendarGrid.displayName);\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 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 // TODO(burdon): Border marker for \"all day events?\"\n const getNumAppointments = useCallback((_date: Date) => {\n // return Math.floor(Math.random() * 10);\n return 0;\n }, []);\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-modalSurface';\n return (\n <div key={key} role='none' style={style} className='is-full grid grid-cols-[1fr_max-content_1fr] snap-center'>\n <div role='none' className={mx(getBgColor(getDate(start, index, 0, weekStartsOn)))} />\n <div role='none' className='grid grid-cols-7' style={{ gridTemplateColumns: `repeat(7, ${size}px)` }}>\n {Array.from({ length: 7 }).map((_, i) => {\n const date = getDate(start, index, i, weekStartsOn);\n const num = getNumAppointments(date);\n const border = isSameDay(date, selected)\n ? 'border-primary-500'\n : isSameDay(date, today)\n ? 'border-amber-500'\n : undefined;\n\n return (\n <div\n key={i}\n role='none'\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 && (\n <div\n role='none'\n className={mx('absolute top-0 left-0 is-full bs-full border-2 rounded-full', border)}\n />\n )}\n {num > 0 && (\n <Icon\n classNames='absolute bottom-0'\n icon={num > 3 ? 'ph--dots-three--regular' : 'ph--dot--regular'}\n size={5}\n />\n )}\n </div>\n );\n })}\n </div>\n <div className={mx(getBgColor(getDate(start, index, 6, weekStartsOn)))} />\n </div>\n );\n },\n [handleDaySelect, getNumAppointments, selected, weekStartsOn],\n );\n\n return (\n <div role='none' className={mx('flex flex-col bs-full is-full justify-center overflow-hidden', classNames)}>\n {/* Day labels */}\n <div role='none' className='flex justify-center bg-groupSurface'>\n <div role='none' className='flex is-full grid grid-cols-7' style={{ width: defaultWidth }}>\n {days.map((date, i) => (\n <div key={i} role='none' className='flex justify-center p-2 text-sm font-thin'>\n {date}\n </div>\n ))}\n </div>\n </div>\n\n {/* Grid */}\n <div role='none' className='flex flex-col bs-full is-full justify-center overflow-hidden' ref={containerRef}>\n <List\n ref={listRef}\n role='none'\n // TODO(burdon): Snap isn't working.\n className='[&>div]:snap-y scrollbar-none outline-none'\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\nCalendarGrid.displayName = 'CalendarGrid';\n\n//\n// Calendar\n//\n\nexport const Calendar = {\n Root: CalendarRoot,\n Viewport: CalendarViewport,\n Toolbar: CalendarToolbar,\n Grid: CalendarGrid,\n};\n\nexport type { CalendarController, CalendarRootProps, CalendarViewportProps, CalendarToolbarProps, CalendarGridProps };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nexport const translationKey = '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", "//\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": "
|
|
6
|
-
"names": ["createContext", "addDays", "differenceInWeeks", "format", "startOfWeek", "React", "forwardRef", "useCallback", "useEffect", "useImperativeHandle", "useMemo", "useRef", "useState", "useResizeDetector", "List", "Event", "Icon", "IconButton", "useTranslation", "mx", "translationKey", "translations", "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", "CalendarViewport", "classNames", "div", "role", "className", "mx", "displayName", "CalendarToolbar", "t", "useTranslation", "translationKey", "top", "getDate", "today", "handleToday", "useCallback", "style", "width", "IconButton", "variant", "icon", "iconOnly", "label", "onClick", "format", "getFullYear", "CalendarGrid", "rows", "onSelect", "ref", "containerRef", "height", "useResizeDetector", "maxHeight", "undefined", "listRef", "useRef", "initialized", "setInitialized", "useEffect", "differenceInWeeks", "current", "scrollToRow", "on", "days", "weekStart", "startOfWeek", "Array", "from", "length", "_", "i", "day", "addDays", "getNumAppointments", "_date", "handleDaySelect", "isSameDay", "handleScroll", "info", "Math", "round", "scrollTop", "rowRenderer", "key", "getBgColor", "getMonth", "gridTemplateColumns", "map", "num", "border", "span", "Icon", "List", "rowCount", "rowHeight", "scrollToAlignment", "onScroll", "onRowsRendered", "Calendar", "Root", "Viewport", "Toolbar", "Grid"]
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext } from '@radix-ui/react-context';\nimport { type Day, addDays, differenceInWeeks, format, 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 { Icon, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { 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// Viewport\n//\n\nconst CALENDAR_VIEWPORT_NAME = 'CalendarContent';\n\ntype CalendarViewportProps = PropsWithChildren<ThemedClassName>;\n\nconst CalendarViewport = ({ children, classNames }: CalendarViewportProps) => {\n return (\n <div role='none' className={mx('flex flex-col items-center overflow-hidden bg-inputSurface', classNames)}>\n {children}\n </div>\n );\n};\n\nCalendarViewport.displayName = CALENDAR_VIEWPORT_NAME;\n\n//\n// Header\n//\n\nconst CALENDAR_TOOLBAR_NAME = 'CalendarHeader';\n\ntype CalendarToolbarProps = ThemedClassName;\n\nconst CalendarToolbar = ({ classNames }: CalendarToolbarProps) => {\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 role='none'\n className={mx('shink-0 is-full grid grid-cols-3 items-center bg-barSurface', classNames)}\n style={{ width: defaultWidth }}\n >\n <div className='flex justify-start'>\n <IconButton\n variant='ghost'\n size={5}\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 = ThemedClassName<{\n rows?: number;\n onSelect?: (event: { date: Date }) => void;\n}>;\n\nconst CalendarGrid = ({ classNames, rows, onSelect }: CalendarGridProps) => {\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 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 // TODO(burdon): Border marker for \"all day events?\"\n const getNumAppointments = useCallback((_date: Date) => {\n // return Math.floor(Math.random() * 10);\n return 0;\n }, []);\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-modalSurface';\n return (\n <div key={key} role='none' style={style} className='is-full grid grid-cols-[1fr_max-content_1fr] snap-center'>\n <div role='none' className={mx(getBgColor(getDate(start, index, 0, weekStartsOn)))} />\n <div role='none' className='grid grid-cols-7' style={{ gridTemplateColumns: `repeat(7, ${size}px)` }}>\n {Array.from({ length: 7 }).map((_, i) => {\n const date = getDate(start, index, i, weekStartsOn);\n const num = getNumAppointments(date);\n const border = isSameDay(date, selected)\n ? 'border-primary-500'\n : isSameDay(date, today)\n ? 'border-amber-500'\n : undefined;\n\n return (\n <div\n key={i}\n role='none'\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 && (\n <div\n role='none'\n className={mx('absolute top-0 left-0 is-full bs-full border-2 rounded-full', border)}\n />\n )}\n {num > 0 && (\n <Icon\n classNames='absolute bottom-0'\n icon={num > 3 ? 'ph--dots-three--regular' : 'ph--dot--regular'}\n size={5}\n />\n )}\n </div>\n );\n })}\n </div>\n <div className={mx(getBgColor(getDate(start, index, 6, weekStartsOn)))} />\n </div>\n );\n },\n [handleDaySelect, getNumAppointments, selected, weekStartsOn],\n );\n\n return (\n <div role='none' className={mx('flex flex-col bs-full is-full justify-center overflow-hidden', classNames)}>\n {/* Day labels */}\n <div role='none' className='flex justify-center bg-groupSurface'>\n <div role='none' className='flex is-full grid grid-cols-7' style={{ width: defaultWidth }}>\n {days.map((date, i) => (\n <div key={i} role='none' className='flex justify-center p-2 text-sm font-thin'>\n {date}\n </div>\n ))}\n </div>\n </div>\n\n {/* Grid */}\n <div role='none' className='flex flex-col bs-full is-full justify-center overflow-hidden' ref={containerRef}>\n <List\n ref={listRef}\n role='none'\n // TODO(burdon): Snap isn't working.\n className='[&>div]:snap-y scrollbar-none outline-none'\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\nCalendarGrid.displayName = CALENDAR_GRID_NAME;\n\n//\n// Calendar\n//\n\nexport const Calendar = {\n Root: CalendarRoot,\n Viewport: CalendarViewport,\n Toolbar: CalendarToolbar,\n Grid: CalendarGrid,\n};\n\nexport type { CalendarController, CalendarRootProps, CalendarViewportProps, CalendarToolbarProps, CalendarGridProps };\n", "//\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", "//\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,mBAAmB;AAC1E,OAAOC,SAILC,YACAC,aACAC,WACAC,qBACAC,SACAC,QACAC,gBACK;AACP,SAASC,yBAAyB;AAClC,SAASC,YAAkD;AAE3D,SAASC,aAAa;AACtB,SAASC,MAAMC,YAAkCC,sBAAsB;AACvE,SAASC,UAAU;;;ACjBZ,IAAMC,iBAAiB;AAEvB,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACD,cAAAA,GAAiB;QAChB,gBAAgB;MAClB;IACF;EACF;;;;ACTK,IAAME,UAAU,CAACC,QAAaC,YAAoBC,WAAmBC,iBAAAA;AAC1E,QAAMC,SAAS,IAAIC,KAAKL,MAAAA;AACxB,QAAMM,iBAAiBN,OAAMO,OAAM;AACnC,QAAMC,oBAAoBF,mBAAmB,IAAI,IAAIA,kBAAkBH;AACvEC,SAAOK,QAAQT,OAAMD,QAAO,IAAKS,mBAAmBP,aAAa,IAAIC,SAAAA;AACrE,SAAOE;AACT;AAEO,IAAMM,YAAY,CAACC,OAAaC,UAAAA;AACrC,SACE,CAAC,CAACA,SACFD,MAAME,YAAW,MAAOD,MAAMC,YAAW,KACzCF,MAAMG,SAAQ,MAAOF,MAAME,SAAQ,KACnCH,MAAMZ,QAAO,MAAOa,MAAMb,QAAO;AAErC;;;A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AAG,gEAAgEJ,UAAAA;KAE7F,sBAAA,cAACC,OAAAA;IAAIC,MAAK;IAAOC,WAAU;KACzB,sBAAA,cAACF,OAAAA;IAAIC,MAAK;IAAOC,WAAU;IAAgCa,OAAO;MAAEC,OAAOzC;IAAa;KACrFqE,KAAKwB,IAAI,CAAC1E,MAAMyD,MACf,sBAAA,cAACnD,OAAAA;IAAIgE,KAAKb;IAAGlD,MAAK;IAAOC,WAAU;KAChCR,IAAAA,CAAAA,CAAAA,CAAAA,GAOT,sBAAA,cAACM,OAAAA;IAAIC,MAAK;IAAOC,WAAU;IAA+D2B,KAAKC;KAC7F,sBAAA,cAAC2C,MAAAA;IACC5C,KAAKM;IACLlC,MAAK;;IAELC,WAAU;IACVc;IACAe,QAAQE,aAAaF;IACrB2C,UAAUvG;IACVwG,WAAWrG;IACXyF;IACAa,mBAAkB;IAClBC,UAAUnB;IACVoB,gBAAgB,MAAMxC,eAAe,IAAA;;AAK/C;AAEAZ,aAAatB,cAAcqB;AAMpB,IAAMsD,WAAW;EACtBC,MAAMrG;EACNsG,UAAUnF;EACVoF,SAAS5E;EACT6E,MAAMzD;AACR;",
|
|
6
|
+
"names": ["createContext", "addDays", "differenceInWeeks", "format", "startOfWeek", "React", "forwardRef", "useCallback", "useEffect", "useImperativeHandle", "useMemo", "useRef", "useState", "useResizeDetector", "List", "Event", "Icon", "IconButton", "useTranslation", "mx", "translationKey", "translations", "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_VIEWPORT_NAME", "CalendarViewport", "classNames", "div", "role", "className", "mx", "displayName", "CALENDAR_TOOLBAR_NAME", "CalendarToolbar", "t", "useTranslation", "translationKey", "top", "getDate", "today", "handleToday", "useCallback", "style", "width", "IconButton", "variant", "icon", "iconOnly", "label", "onClick", "format", "getFullYear", "CALENDAR_GRID_NAME", "CalendarGrid", "rows", "onSelect", "ref", "containerRef", "height", "useResizeDetector", "maxHeight", "undefined", "listRef", "useRef", "initialized", "setInitialized", "useEffect", "differenceInWeeks", "current", "scrollToRow", "on", "days", "weekStart", "startOfWeek", "Array", "from", "length", "_", "i", "day", "addDays", "getNumAppointments", "_date", "handleDaySelect", "isSameDay", "handleScroll", "info", "Math", "round", "scrollTop", "rowRenderer", "key", "getBgColor", "getMonth", "gridTemplateColumns", "map", "num", "border", "span", "Icon", "List", "rowCount", "rowHeight", "scrollToAlignment", "onScroll", "onRowsRendered", "Calendar", "Root", "Viewport", "Toolbar", "Grid"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/translations.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/translations.ts":{"bytes":1196,"imports":[],"format":"esm"},"src/components/Calendar/util.ts":{"bytes":2802,"imports":[],"format":"esm"},"src/components/Calendar/Calendar.tsx":{"bytes":31567,"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":"src/translations.ts","kind":"import-statement","original":"../../translations"},{"path":"src/components/Calendar/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/components/Calendar/index.ts":{"bytes":476,"imports":[{"path":"src/components/Calendar/Calendar.tsx","kind":"import-statement","original":"./Calendar"}],"format":"esm"},"src/components/index.ts":{"bytes":467,"imports":[{"path":"src/components/Calendar/index.ts","kind":"import-statement","original":"./Calendar"}],"format":"esm"},"src/index.ts":{"bytes":462,"imports":[{"path":"src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18836},"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}],"exports":["Calendar"],"entryPoint":"src/index.ts","inputs":{"src/components/Calendar/Calendar.tsx":{"bytesInOutput":8042},"src/translations.ts":{"bytesInOutput":167},"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":8925}}}
|