@dxos/react-ui-calendar 0.8.4-main.548089c → 0.8.4-main.59c2e9b
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 +194 -201
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +194 -201
- 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 +4 -4
- 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 +4 -4
- package/src/components/Calendar/Calendar.tsx +41 -17
- package/src/translations.ts +1 -1
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// src/components/Calendar/Calendar.tsx
|
|
4
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
5
4
|
import { createContext } from "@radix-ui/react-context";
|
|
6
5
|
import { addDays, differenceInWeeks, format, startOfWeek } from "date-fns";
|
|
7
6
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
8
7
|
import { useResizeDetector } from "react-resize-detector";
|
|
9
8
|
import { List } from "react-virtualized";
|
|
10
9
|
import { Event } from "@dxos/async";
|
|
11
|
-
import { IconButton, useTranslation } from "@dxos/react-ui";
|
|
12
|
-
import { mx } from "@dxos/
|
|
10
|
+
import { Icon, IconButton, useTranslation } from "@dxos/react-ui";
|
|
11
|
+
import { mx } from "@dxos/ui-theme";
|
|
13
12
|
|
|
14
13
|
// src/translations.ts
|
|
15
|
-
var translationKey = "react-ui-calendar";
|
|
14
|
+
var translationKey = "@dxos/react-ui-calendar";
|
|
16
15
|
var translations = [
|
|
17
16
|
{
|
|
18
17
|
"en-US": {
|
|
@@ -42,223 +41,217 @@ var size = 48;
|
|
|
42
41
|
var defaultWidth = 7 * size;
|
|
43
42
|
var [CalendarContextProvider, useCalendarContext] = createContext("Calendar");
|
|
44
43
|
var CalendarRoot = /* @__PURE__ */ forwardRef(({ children, weekStartsOn = 1 }, forwardedRef) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
setSelected
|
|
67
|
-
}, children);
|
|
68
|
-
} finally {
|
|
69
|
-
_effect.f();
|
|
70
|
-
}
|
|
44
|
+
const event = useMemo(() => new Event(), []);
|
|
45
|
+
const [selected, setSelected] = useState();
|
|
46
|
+
const [index, setIndex] = useState();
|
|
47
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
48
|
+
scrollTo: (date) => {
|
|
49
|
+
event.emit({
|
|
50
|
+
type: "scroll",
|
|
51
|
+
date
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}), [
|
|
55
|
+
event
|
|
56
|
+
]);
|
|
57
|
+
return /* @__PURE__ */ React.createElement(CalendarContextProvider, {
|
|
58
|
+
weekStartsOn,
|
|
59
|
+
event,
|
|
60
|
+
index,
|
|
61
|
+
setIndex,
|
|
62
|
+
selected,
|
|
63
|
+
setSelected
|
|
64
|
+
}, children);
|
|
71
65
|
});
|
|
72
66
|
var CalendarViewport = ({ children, classNames }) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
className: mx("flex flex-col items-center overflow-hidden bg-inputSurface", classNames)
|
|
78
|
-
}, children);
|
|
79
|
-
} finally {
|
|
80
|
-
_effect.f();
|
|
81
|
-
}
|
|
67
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
68
|
+
role: "none",
|
|
69
|
+
className: mx("flex flex-col items-center overflow-hidden bg-inputSurface", classNames)
|
|
70
|
+
}, children);
|
|
82
71
|
};
|
|
83
72
|
CalendarViewport.displayName = "CalendarContent";
|
|
84
|
-
var
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
className: "flex justify-end p-2"
|
|
124
|
-
}, (selected ?? top).getFullYear()));
|
|
125
|
-
} finally {
|
|
126
|
-
_effect.f();
|
|
127
|
-
}
|
|
73
|
+
var CalendarToolbar = ({ classNames }) => {
|
|
74
|
+
const { t } = useTranslation(translationKey);
|
|
75
|
+
const { weekStartsOn, event, index, selected } = useCalendarContext(CalendarToolbar.displayName);
|
|
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()));
|
|
128
112
|
};
|
|
129
|
-
|
|
113
|
+
CalendarToolbar.displayName = "CalendarHeader";
|
|
130
114
|
var CalendarGrid = ({ classNames, rows, onSelect }) => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
listRef.current?.scrollToRow(index);
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}, [
|
|
158
|
-
event
|
|
159
|
-
]);
|
|
160
|
-
const days = useMemo(() => {
|
|
161
|
-
const weekStart = startOfWeek(/* @__PURE__ */ new Date(), {
|
|
162
|
-
weekStartsOn
|
|
163
|
-
});
|
|
164
|
-
return Array.from({
|
|
165
|
-
length: 7
|
|
166
|
-
}, (_, i) => {
|
|
167
|
-
const day = addDays(weekStart, i);
|
|
168
|
-
return format(day, "EEE");
|
|
169
|
-
});
|
|
170
|
-
}, []);
|
|
171
|
-
const handleDaySelect = useCallback((date) => {
|
|
172
|
-
setSelected((current) => isSameDay(date, current) ? void 0 : date);
|
|
173
|
-
onSelect?.({
|
|
174
|
-
date
|
|
175
|
-
});
|
|
176
|
-
}, [
|
|
177
|
-
onSelect
|
|
178
|
-
]);
|
|
179
|
-
const handleScroll = useCallback((info) => {
|
|
180
|
-
setIndex(Math.round(info.scrollTop / size));
|
|
181
|
-
}, []);
|
|
182
|
-
const rowRenderer = useCallback(({ key, index, style }) => {
|
|
183
|
-
const getBgColor = (date) => date.getMonth() % 2 === 0 && "bg-modalSurface";
|
|
184
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
185
|
-
key,
|
|
186
|
-
style,
|
|
187
|
-
className: "is-full grid grid-cols-[1fr_max-content_1fr] snap-center"
|
|
188
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
189
|
-
className: mx(getBgColor(getDate(start, index, 0, weekStartsOn)))
|
|
190
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
191
|
-
className: "grid grid-cols-7",
|
|
192
|
-
style: {
|
|
193
|
-
gridTemplateColumns: `repeat(7, ${size}px)`
|
|
115
|
+
const { weekStartsOn, event, setIndex, selected, setSelected } = useCalendarContext(CalendarGrid.displayName);
|
|
116
|
+
const { ref: containerRef, width = 0, height = 0 } = useResizeDetector();
|
|
117
|
+
const maxHeight = rows ? rows * size : void 0;
|
|
118
|
+
const listRef = useRef(null);
|
|
119
|
+
const today = useMemo(() => /* @__PURE__ */ new Date(), []);
|
|
120
|
+
const [initialized, setInitialized] = useState(false);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
const index = differenceInWeeks(today, start);
|
|
123
|
+
listRef.current?.scrollToRow(index);
|
|
124
|
+
}, [
|
|
125
|
+
initialized,
|
|
126
|
+
start,
|
|
127
|
+
today
|
|
128
|
+
]);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
return event.on((event2) => {
|
|
131
|
+
switch (event2.type) {
|
|
132
|
+
case "scroll": {
|
|
133
|
+
const index = differenceInWeeks(event2.date, start);
|
|
134
|
+
listRef.current?.scrollToRow(index);
|
|
135
|
+
break;
|
|
194
136
|
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
className: mx("relative flex justify-center items-center cursor-pointer", getBgColor(date)),
|
|
203
|
-
onClick: () => handleDaySelect(date)
|
|
204
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
205
|
-
className: "text-description"
|
|
206
|
-
}, date.getDate()), !border && date.getDate() === 1 && /* @__PURE__ */ React.createElement("span", {
|
|
207
|
-
className: "absolute top-0 text-xs text-description"
|
|
208
|
-
}, format(date, "MMM")), border && /* @__PURE__ */ React.createElement("div", {
|
|
209
|
-
className: mx("absolute top-0 left-0 is-full bs-full border-2 rounded-full", border)
|
|
210
|
-
}));
|
|
211
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
212
|
-
className: mx(getBgColor(getDate(start, index, 6, weekStartsOn)))
|
|
213
|
-
}));
|
|
214
|
-
}, [
|
|
215
|
-
handleDaySelect,
|
|
216
|
-
selected,
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}, [
|
|
140
|
+
event
|
|
141
|
+
]);
|
|
142
|
+
const days = useMemo(() => {
|
|
143
|
+
const weekStart = startOfWeek(/* @__PURE__ */ new Date(), {
|
|
217
144
|
weekStartsOn
|
|
218
|
-
|
|
145
|
+
});
|
|
146
|
+
return Array.from({
|
|
147
|
+
length: 7
|
|
148
|
+
}, (_, i) => {
|
|
149
|
+
const day = addDays(weekStart, i);
|
|
150
|
+
return format(day, "EEE");
|
|
151
|
+
});
|
|
152
|
+
}, []);
|
|
153
|
+
const getNumAppointments = useCallback((_date) => {
|
|
154
|
+
return 0;
|
|
155
|
+
}, []);
|
|
156
|
+
const handleDaySelect = useCallback((date) => {
|
|
157
|
+
setSelected((current) => isSameDay(date, current) ? void 0 : date);
|
|
158
|
+
onSelect?.({
|
|
159
|
+
date
|
|
160
|
+
});
|
|
161
|
+
}, [
|
|
162
|
+
onSelect
|
|
163
|
+
]);
|
|
164
|
+
const handleScroll = useCallback((info) => {
|
|
165
|
+
setIndex(Math.round(info.scrollTop / size));
|
|
166
|
+
}, []);
|
|
167
|
+
const rowRenderer = useCallback(({ key, index, style }) => {
|
|
168
|
+
const getBgColor = (date) => date.getMonth() % 2 === 0 && "bg-modalSurface";
|
|
219
169
|
return /* @__PURE__ */ React.createElement("div", {
|
|
170
|
+
key,
|
|
220
171
|
role: "none",
|
|
221
|
-
|
|
172
|
+
style,
|
|
173
|
+
className: "is-full grid grid-cols-[1fr_max-content_1fr] snap-center"
|
|
222
174
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
223
175
|
role: "none",
|
|
224
|
-
className:
|
|
225
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
176
|
+
className: mx(getBgColor(getDate(start, index, 0, weekStartsOn)))
|
|
177
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
226
178
|
role: "none",
|
|
227
|
-
className: "
|
|
179
|
+
className: "grid grid-cols-7",
|
|
228
180
|
style: {
|
|
229
|
-
|
|
181
|
+
gridTemplateColumns: `repeat(7, ${size}px)`
|
|
230
182
|
}
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
183
|
+
}, Array.from({
|
|
184
|
+
length: 7
|
|
185
|
+
}).map((_, i) => {
|
|
186
|
+
const date = getDate(start, index, i, weekStartsOn);
|
|
187
|
+
const num = getNumAppointments(date);
|
|
188
|
+
const border = isSameDay(date, selected) ? "border-primary-500" : isSameDay(date, today) ? "border-amber-500" : void 0;
|
|
189
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
190
|
+
key: i,
|
|
191
|
+
role: "none",
|
|
192
|
+
className: mx("relative flex justify-center items-center cursor-pointer", getBgColor(date)),
|
|
193
|
+
onClick: () => handleDaySelect(date)
|
|
194
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
195
|
+
className: "text-description"
|
|
196
|
+
}, date.getDate()), !border && date.getDate() === 1 && /* @__PURE__ */ React.createElement("span", {
|
|
197
|
+
className: "absolute top-0 text-xs text-description"
|
|
198
|
+
}, format(date, "MMM")), border && /* @__PURE__ */ React.createElement("div", {
|
|
199
|
+
role: "none",
|
|
200
|
+
className: mx("absolute top-0 left-0 is-full bs-full border-2 rounded-full", border)
|
|
201
|
+
}), num > 0 && /* @__PURE__ */ React.createElement(Icon, {
|
|
202
|
+
classNames: "absolute bottom-0",
|
|
203
|
+
icon: num > 3 ? "ph--dots-three--regular" : "ph--dot--regular",
|
|
204
|
+
size: 5
|
|
205
|
+
}));
|
|
206
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
207
|
+
className: mx(getBgColor(getDate(start, index, 6, weekStartsOn)))
|
|
208
|
+
}));
|
|
209
|
+
}, [
|
|
210
|
+
handleDaySelect,
|
|
211
|
+
getNumAppointments,
|
|
212
|
+
selected,
|
|
213
|
+
weekStartsOn
|
|
214
|
+
]);
|
|
215
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
216
|
+
role: "none",
|
|
217
|
+
className: mx("flex flex-col bs-full is-full justify-center overflow-hidden", classNames)
|
|
218
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
219
|
+
role: "none",
|
|
220
|
+
className: "flex justify-center bg-groupSurface"
|
|
221
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
222
|
+
role: "none",
|
|
223
|
+
className: "flex is-full grid grid-cols-7",
|
|
224
|
+
style: {
|
|
225
|
+
width: defaultWidth
|
|
226
|
+
}
|
|
227
|
+
}, days.map((date, i) => /* @__PURE__ */ React.createElement("div", {
|
|
228
|
+
key: i,
|
|
229
|
+
role: "none",
|
|
230
|
+
className: "flex justify-center p-2 text-sm font-thin"
|
|
231
|
+
}, date)))), /* @__PURE__ */ React.createElement("div", {
|
|
232
|
+
role: "none",
|
|
233
|
+
className: "flex flex-col bs-full is-full justify-center overflow-hidden",
|
|
234
|
+
ref: containerRef
|
|
235
|
+
}, /* @__PURE__ */ React.createElement(List, {
|
|
236
|
+
ref: listRef,
|
|
237
|
+
role: "none",
|
|
238
|
+
// TODO(burdon): Snap isn't working.
|
|
239
|
+
className: "[&>div]:snap-y scrollbar-none outline-none",
|
|
240
|
+
width,
|
|
241
|
+
height: maxHeight ?? height,
|
|
242
|
+
rowCount: maxRows,
|
|
243
|
+
rowHeight: size,
|
|
244
|
+
rowRenderer,
|
|
245
|
+
scrollToAlignment: "start",
|
|
246
|
+
onScroll: handleScroll,
|
|
247
|
+
onRowsRendered: () => setInitialized(true)
|
|
248
|
+
})));
|
|
256
249
|
};
|
|
257
250
|
CalendarGrid.displayName = "CalendarGrid";
|
|
258
251
|
var Calendar = {
|
|
259
252
|
Root: CalendarRoot,
|
|
260
253
|
Viewport: CalendarViewport,
|
|
261
|
-
|
|
254
|
+
Toolbar: CalendarToolbar,
|
|
262
255
|
Grid: CalendarGrid
|
|
263
256
|
};
|
|
264
257
|
export {
|
|
@@ -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 { 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 CalendarHeaderProps = ThemedClassName;\n\nconst CalendarHeader = ({ classNames }: CalendarHeaderProps) => {\n const { t } = useTranslation(translationKey);\n const { weekStartsOn, event, index, selected } = useCalendarContext(CalendarHeader.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 role='none' className={mx('shink-0 is-full grid grid-cols-3', classNames)} style={{ width: defaultWidth }}>\n <div className='flex justify-start'>\n <IconButton\n variant='ghost'\n size={6}\n icon='ph--calendar--regular'\n iconOnly\n classNames='aspect-square'\n label={t('today button')}\n onClick={handleToday}\n />\n </div>\n <span className='flex justify-center p-2'>{format(selected ?? top, 'MMMM')}</span>\n <span className='flex justify-end p-2'>{(selected ?? top).getFullYear()}</span>\n </div>\n );\n};\n\nCalendarHeader.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 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} style={style} className='is-full grid grid-cols-[1fr_max-content_1fr] snap-center'>\n <div className={mx(getBgColor(getDate(start, index, 0, weekStartsOn)))} />\n <div 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 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 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 className={mx('absolute top-0 left-0 is-full bs-full border-2 rounded-full', border)} />\n )}\n </div>\n );\n })}\n </div>\n <div className={mx(getBgColor(getDate(start, index, 6, weekStartsOn)))} />\n </div>\n );\n },\n [handleDaySelect, 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 {/* 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 Header: CalendarHeader,\n Grid: CalendarGrid,\n};\n\nexport type { CalendarController, CalendarRootProps, CalendarViewportProps, CalendarHeaderProps, 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", "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", "
|
|
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\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 = '@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;;;AFQA,IAAMgB,UAAU,KAAK;AACrB,IAAMC,QAAQ,oBAAIC,KAAK,YAAA;AACvB,IAAMC,OAAO;AACb,IAAMC,eAAe,IAAID;AAoBzB,IAAM,CAACE,yBAAyBC,kBAAAA,IAAsBC,cAAoC,UAAA;AAgB1F,IAAMC,eAAeC,2BACnB,CAAC,EAAEC,UAAUC,eAAe,E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AAAA,CAAAA,CAAAA,GAOT,sBAAA,cAACK,OAAAA;IAAIC,MAAK;IAAOC,WAAU;IAA+DyB,KAAKC;KAC7F,sBAAA,cAAC2C,MAAAA;IACC5C,KAAKM;IACLhC,MAAK;;IAELC,WAAU;IACVa;IACAc,QAAQE,aAAaF;IACrB2C,UAAUpG;IACVqG,WAAWlG;IACXsF;IACAa,mBAAkB;IAClBC,UAAUnB;IACVoB,gBAAgB,MAAMxC,eAAe,IAAA;;AAK/C;AAEAZ,aAAapB,cAAc;AAMpB,IAAMyE,WAAW;EACtBC,MAAMlG;EACNmG,UAAUjF;EACVkF,SAAS3E;EACT4E,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", "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"]
|
|
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":30821,"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/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18560},"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}],"exports":["Calendar"],"entryPoint":"src/index.ts","inputs":{"src/components/Calendar/Calendar.tsx":{"bytesInOutput":7905},"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":8881}}}
|
|
@@ -19,7 +19,7 @@ type CalendarController = {
|
|
|
19
19
|
};
|
|
20
20
|
type CalendarRootProps = PropsWithChildren<Partial<Pick<CalendarContextValue, 'weekStartsOn'>>>;
|
|
21
21
|
type CalendarViewportProps = PropsWithChildren<ThemedClassName>;
|
|
22
|
-
type
|
|
22
|
+
type CalendarToolbarProps = ThemedClassName;
|
|
23
23
|
type CalendarGridProps = ThemedClassName<{
|
|
24
24
|
rows?: number;
|
|
25
25
|
onSelect?: (event: {
|
|
@@ -34,8 +34,8 @@ export declare const Calendar: {
|
|
|
34
34
|
({ children, classNames }: CalendarViewportProps): React.JSX.Element;
|
|
35
35
|
displayName: string;
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
({ classNames }:
|
|
37
|
+
Toolbar: {
|
|
38
|
+
({ classNames }: CalendarToolbarProps): React.JSX.Element;
|
|
39
39
|
displayName: string;
|
|
40
40
|
};
|
|
41
41
|
Grid: {
|
|
@@ -43,5 +43,5 @@ export declare const Calendar: {
|
|
|
43
43
|
displayName: string;
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
|
-
export type { CalendarController, CalendarRootProps, CalendarViewportProps,
|
|
46
|
+
export type { CalendarController, CalendarRootProps, CalendarViewportProps, CalendarToolbarProps, CalendarGridProps };
|
|
47
47
|
//# sourceMappingURL=Calendar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../../../src/components/Calendar/Calendar.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,GAAG,EAAmD,MAAM,UAAU,CAAC;AACrF,OAAO,KAAK,EAAE,EACZ,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAQpB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../../../src/components/Calendar/Calendar.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,GAAG,EAAmD,MAAM,UAAU,CAAC;AACrF,OAAO,KAAK,EAAE,EACZ,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAQpB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAoB,KAAK,eAAe,EAAkB,MAAM,gBAAgB,CAAC;AAgBxF,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,YAAY,EAAE,GAAG,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACvD,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,QAAQ,CAAC,cAAc,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC;CACzD,CAAC;AAQF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CAAC;AAMF,KAAK,iBAAiB,GAAG,iBAA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