@dxos/react-ui-calendar 0.8.4-main.bc674ce → 0.8.4-main.c85a9c8dae

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-calendar",
3
- "version": "0.8.4-main.bc674ce",
3
+ "version": "0.8.4-main.c85a9c8dae",
4
4
  "description": "A calendar component.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -33,32 +33,31 @@
33
33
  "react-resize-detector": "^11.0.1",
34
34
  "react-virtualized": "^9.22.6",
35
35
  "react-window": "^2.2.3",
36
- "@dxos/debug": "0.8.4-main.bc674ce",
37
- "@dxos/async": "0.8.4-main.bc674ce",
38
- "@dxos/invariant": "0.8.4-main.bc674ce",
39
- "@dxos/log": "0.8.4-main.bc674ce",
40
- "@dxos/util": "0.8.4-main.bc674ce"
36
+ "@dxos/debug": "0.8.4-main.c85a9c8dae",
37
+ "@dxos/invariant": "0.8.4-main.c85a9c8dae",
38
+ "@dxos/log": "0.8.4-main.c85a9c8dae",
39
+ "@dxos/util": "0.8.4-main.c85a9c8dae",
40
+ "@dxos/async": "0.8.4-main.c85a9c8dae"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/react": "~19.2.7",
44
44
  "@types/react-dom": "~19.2.3",
45
45
  "@types/react-virtualized": "^9.22.3",
46
- "@types/react-window": "^2.0.0",
47
- "effect": "3.19.11",
46
+ "effect": "3.19.16",
48
47
  "react": "~19.2.3",
49
48
  "react-dom": "~19.2.3",
50
- "vite": "7.1.9",
51
- "@dxos/random": "0.8.4-main.bc674ce",
52
- "@dxos/react-ui": "0.8.4-main.bc674ce",
53
- "@dxos/storybook-utils": "0.8.4-main.bc674ce",
54
- "@dxos/ui-theme": "0.8.4-main.bc674ce"
49
+ "vite": "^7.1.11",
50
+ "@dxos/random": "0.8.4-main.c85a9c8dae",
51
+ "@dxos/react-ui": "0.8.4-main.c85a9c8dae",
52
+ "@dxos/ui-theme": "0.8.4-main.c85a9c8dae",
53
+ "@dxos/storybook-utils": "0.8.4-main.c85a9c8dae"
55
54
  },
56
55
  "peerDependencies": {
57
- "effect": "3.19.11",
56
+ "effect": "3.19.16",
58
57
  "react": "~19.2.3",
59
58
  "react-dom": "~19.2.3",
60
- "@dxos/react-ui": "0.8.4-main.bc674ce",
61
- "@dxos/ui-theme": "0.8.4-main.bc674ce"
59
+ "@dxos/ui-theme": "0.8.4-main.c85a9c8dae",
60
+ "@dxos/react-ui": "0.8.4-main.c85a9c8dae"
62
61
  },
63
62
  "publishConfig": {
64
63
  "access": "public"
@@ -5,7 +5,8 @@
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React from 'react';
7
7
 
8
- import { withTheme } from '@dxos/react-ui/testing';
8
+ import { Panel } from '@dxos/react-ui';
9
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
9
10
 
10
11
  import { translations } from '../../translations';
11
12
 
@@ -14,9 +15,7 @@ import { Calendar } from './Calendar';
14
15
  const meta = {
15
16
  title: 'ui/react-ui-calendar/Calendar',
16
17
  component: Calendar.Grid,
17
- decorators: [withTheme],
18
18
  parameters: {
19
- layout: 'centered',
20
19
  translations,
21
20
  },
22
21
  } satisfies Meta<typeof Calendar.Grid>;
@@ -26,51 +25,27 @@ export default meta;
26
25
  type Story = StoryObj<typeof meta>;
27
26
 
28
27
  export const Default: Story = {
28
+ decorators: [withTheme(), withLayout({ layout: 'centered' })],
29
29
  render: () => (
30
30
  <Calendar.Root>
31
- <Calendar.Viewport>
32
- <Calendar.Toolbar />
33
- <Calendar.Grid rows={6} />
34
- </Calendar.Viewport>
35
- </Calendar.Root>
36
- ),
37
- };
38
-
39
- export const Border: Story = {
40
- render: () => (
41
- <Calendar.Root>
42
- <Calendar.Viewport classNames='bg-modalSurface border border-separator rounded'>
43
- <Calendar.Toolbar />
44
- <Calendar.Grid rows={6} />
45
- </Calendar.Viewport>
31
+ <Calendar.Toolbar />
32
+ <Calendar.Grid rows={6} />
46
33
  </Calendar.Root>
47
34
  ),
48
35
  };
49
36
 
50
37
  export const Column: Story = {
38
+ decorators: [withTheme(), withLayout({ layout: 'column' })],
51
39
  render: () => (
52
- <div className='absolute inset-0 flex bs-full justify-center'>
53
- <Calendar.Root>
54
- <Calendar.Viewport>
40
+ <Calendar.Root>
41
+ <Panel.Root>
42
+ <Panel.Toolbar asChild>
55
43
  <Calendar.Toolbar />
44
+ </Panel.Toolbar>
45
+ <Panel.Content asChild>
56
46
  <Calendar.Grid />
57
- </Calendar.Viewport>
58
- </Calendar.Root>
59
- </div>
60
- ),
61
- };
62
-
63
- export const Mobile: Story = {
64
- render: () => (
65
- <div className='absolute inset-0 flex bs-full justify-center'>
66
- <div className='flex bs-full is-[400px] justify-center'>
67
- <Calendar.Root>
68
- <Calendar.Viewport classNames='is-full'>
69
- <Calendar.Toolbar />
70
- <Calendar.Grid />
71
- </Calendar.Viewport>
72
- </Calendar.Root>
73
- </div>
74
- </div>
47
+ </Panel.Content>
48
+ </Panel.Root>
49
+ </Calendar.Root>
75
50
  ),
76
51
  };
@@ -97,31 +97,17 @@ const CalendarRoot = forwardRef<CalendarController, CalendarRootProps>(
97
97
  },
98
98
  );
99
99
 
100
- //
101
- // Viewport
102
- //
103
-
104
- type CalendarViewportProps = PropsWithChildren<ThemedClassName>;
105
-
106
- const CalendarViewport = ({ children, classNames }: CalendarViewportProps) => {
107
- return (
108
- <div role='none' className={mx('flex flex-col items-center overflow-hidden bg-inputSurface', classNames)}>
109
- {children}
110
- </div>
111
- );
112
- };
113
-
114
- CalendarViewport.displayName = 'CalendarContent';
115
-
116
100
  //
117
101
  // Header
118
102
  //
119
103
 
104
+ const CALENDAR_TOOLBAR_NAME = 'CalendarHeader';
105
+
120
106
  type CalendarToolbarProps = ThemedClassName;
121
107
 
122
- const CalendarToolbar = ({ classNames }: CalendarToolbarProps) => {
108
+ const CalendarToolbar = ({ classNames, ...props }: CalendarToolbarProps) => {
123
109
  const { t } = useTranslation(translationKey);
124
- const { weekStartsOn, event, index, selected } = useCalendarContext(CalendarToolbar.displayName);
110
+ const { weekStartsOn, event, index, selected } = useCalendarContext(CALENDAR_TOOLBAR_NAME);
125
111
  const top = useMemo(() => getDate(start, index ?? 0, 6, weekStartsOn), [index, weekStartsOn]);
126
112
  const today = useMemo(() => new Date(), []);
127
113
 
@@ -131,8 +117,9 @@ const CalendarToolbar = ({ classNames }: CalendarToolbarProps) => {
131
117
 
132
118
  return (
133
119
  <div
120
+ {...props}
134
121
  role='none'
135
- className={mx('shink-0 is-full grid grid-cols-3 items-center bg-barSurface', classNames)}
122
+ className={mx('shrink-0 w-full m-auto grid grid-cols-3 items-center bg-toolbar-surface', classNames)}
136
123
  style={{ width: defaultWidth }}
137
124
  >
138
125
  <div className='flex justify-start'>
@@ -152,7 +139,7 @@ const CalendarToolbar = ({ classNames }: CalendarToolbarProps) => {
152
139
  );
153
140
  };
154
141
 
155
- CalendarToolbar.displayName = 'CalendarHeader';
142
+ CalendarToolbar.displayName = CALENDAR_TOOLBAR_NAME;
156
143
 
157
144
  //
158
145
  // Grid
@@ -160,13 +147,15 @@ CalendarToolbar.displayName = 'CalendarHeader';
160
147
  // TODO(burdon): Drag range.
161
148
  //
162
149
 
150
+ const CALENDAR_GRID_NAME = 'CalendarGrid';
151
+
163
152
  type CalendarGridProps = ThemedClassName<{
164
153
  rows?: number;
165
154
  onSelect?: (event: { date: Date }) => void;
166
155
  }>;
167
156
 
168
- const CalendarGrid = ({ classNames, rows, onSelect }: CalendarGridProps) => {
169
- const { weekStartsOn, event, setIndex, selected, setSelected } = useCalendarContext(CalendarGrid.displayName);
157
+ const CalendarGrid = ({ classNames, rows, onSelect, ...props }: CalendarGridProps) => {
158
+ const { weekStartsOn, event, setIndex, selected, setSelected } = useCalendarContext(CALENDAR_GRID_NAME);
170
159
  const { ref: containerRef, width = 0, height = 0 } = useResizeDetector();
171
160
  const maxHeight = rows ? rows * size : undefined;
172
161
  const listRef = useRef<List>(null);
@@ -219,11 +208,21 @@ const CalendarGrid = ({ classNames, rows, onSelect }: CalendarGridProps) => {
219
208
 
220
209
  const rowRenderer = useCallback<ListRowRenderer>(
221
210
  ({ key, index, style }) => {
222
- const getBgColor = (date: Date) => date.getMonth() % 2 === 0 && 'bg-modalSurface';
211
+ const getBgColor = (date: Date) => date.getMonth() % 2 === 0 && 'bg-modal-surface';
223
212
  return (
224
- <div key={key} role='none' style={style} className='is-full grid grid-cols-[1fr_max-content_1fr] snap-center'>
213
+ <div
214
+ key={key}
215
+ {...props}
216
+ role='none'
217
+ style={style}
218
+ className='w-full grid grid-cols-[1fr_max-content_1fr] snap-center'
219
+ >
225
220
  <div role='none' className={mx(getBgColor(getDate(start, index, 0, weekStartsOn)))} />
226
- <div role='none' className='grid grid-cols-7' style={{ gridTemplateColumns: `repeat(7, ${size}px)` }}>
221
+ <div
222
+ role='none'
223
+ className='grid grid-cols-7 bg-input-surface'
224
+ style={{ gridTemplateColumns: `repeat(7, ${size}px)` }}
225
+ >
227
226
  {Array.from({ length: 7 }).map((_, i) => {
228
227
  const date = getDate(start, index, i, weekStartsOn);
229
228
  const num = getNumAppointments(date);
@@ -247,7 +246,7 @@ const CalendarGrid = ({ classNames, rows, onSelect }: CalendarGridProps) => {
247
246
  {border && (
248
247
  <div
249
248
  role='none'
250
- className={mx('absolute top-0 left-0 is-full bs-full border-2 rounded-full', border)}
249
+ className={mx('absolute top-0 left-0 w-full h-full border-2 rounded-full', border)}
251
250
  />
252
251
  )}
253
252
  {num > 0 && (
@@ -269,10 +268,10 @@ const CalendarGrid = ({ classNames, rows, onSelect }: CalendarGridProps) => {
269
268
  );
270
269
 
271
270
  return (
272
- <div role='none' className={mx('flex flex-col bs-full is-full justify-center overflow-hidden', classNames)}>
271
+ <div role='none' className={mx('flex flex-col h-full w-full justify-center overflow-hidden', classNames)}>
273
272
  {/* Day labels */}
274
- <div role='none' className='flex justify-center bg-groupSurface'>
275
- <div role='none' className='flex is-full grid grid-cols-7' style={{ width: defaultWidth }}>
273
+ <div role='none' className='flex justify-center bg-group-surface'>
274
+ <div role='none' className='flex w-full grid grid-cols-7' style={{ width: defaultWidth }}>
276
275
  {days.map((date, i) => (
277
276
  <div key={i} role='none' className='flex justify-center p-2 text-sm font-thin'>
278
277
  {date}
@@ -282,12 +281,12 @@ const CalendarGrid = ({ classNames, rows, onSelect }: CalendarGridProps) => {
282
281
  </div>
283
282
 
284
283
  {/* Grid */}
285
- <div role='none' className='flex flex-col bs-full is-full justify-center overflow-hidden' ref={containerRef}>
284
+ <div role='none' className='flex flex-col h-full w-full justify-center overflow-hidden' ref={containerRef}>
286
285
  <List
287
286
  ref={listRef}
288
287
  role='none'
289
288
  // TODO(burdon): Snap isn't working.
290
- className='[&>div]:snap-y scrollbar-none outline-none'
289
+ className='[&>div]:snap-y scrollbar-none outline-hidden'
291
290
  width={width}
292
291
  height={maxHeight ?? height}
293
292
  rowCount={maxRows}
@@ -302,7 +301,7 @@ const CalendarGrid = ({ classNames, rows, onSelect }: CalendarGridProps) => {
302
301
  );
303
302
  };
304
303
 
305
- CalendarGrid.displayName = 'CalendarGrid';
304
+ CalendarGrid.displayName = CALENDAR_GRID_NAME;
306
305
 
307
306
  //
308
307
  // Calendar
@@ -310,9 +309,8 @@ CalendarGrid.displayName = 'CalendarGrid';
310
309
 
311
310
  export const Calendar = {
312
311
  Root: CalendarRoot,
313
- Viewport: CalendarViewport,
314
312
  Toolbar: CalendarToolbar,
315
313
  Grid: CalendarGrid,
316
314
  };
317
315
 
318
- export type { CalendarController, CalendarRootProps, CalendarViewportProps, CalendarToolbarProps, CalendarGridProps };
316
+ export type { CalendarController, CalendarRootProps, CalendarToolbarProps, CalendarGridProps };