@mirohq/design-system-calendar 1.0.0 → 1.1.0
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/main.js +196 -178
- package/dist/main.js.map +1 -1
- package/dist/module.js +199 -181
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/package.json +8 -5
package/dist/module.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import React, { createContext, useState, useMemo, useCallback, useContext, useRef, useEffect } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useDateFormatter, useCalendarCell, useFocusRing, mergeProps, useLocale, useCalendarGrid, useCalendar, useRangeCalendar, I18nProvider } from 'react-aria';
|
|
4
4
|
import * as RadixPopover from '@radix-ui/react-popover';
|
|
5
5
|
import { Trigger as Trigger$1, Content as Content$1 } from '@radix-ui/react-popover';
|
|
6
6
|
import { useFormFieldContext, FloatingLabel } from '@mirohq/design-system-base-form';
|
|
7
7
|
import { IconCross, IconCalendarBlank, IconChevronLeft, IconChevronRight } from '@mirohq/design-system-icons';
|
|
8
8
|
import { useNewDesignLanguage } from '@mirohq/design-system-experiments';
|
|
9
|
-
import { stringAttrValue } from '@mirohq/design-system-utils';
|
|
9
|
+
import { stringAttrValue, booleanify } from '@mirohq/design-system-utils';
|
|
10
10
|
import { Primitive } from '@mirohq/design-system-primitive';
|
|
11
11
|
import { styled, theme } from '@mirohq/design-system-stitches';
|
|
12
12
|
import { textFieldStyles, actionButtonStyles } from '@mirohq/design-system-base-text-field';
|
|
@@ -15,8 +15,10 @@ import { BaseButton } from '@mirohq/design-system-base-button';
|
|
|
15
15
|
import { Tooltip } from '@mirohq/design-system-tooltip';
|
|
16
16
|
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
17
17
|
import { useCalendarState, useRangeCalendarState } from 'react-stately';
|
|
18
|
-
import { isSameMonth, isSameDay,
|
|
18
|
+
import { isSameMonth, isSameDay, isToday, getLocalTimeZone, getWeeksInMonth, createCalendar } from '@internationalized/date';
|
|
19
19
|
import { Flex } from '@mirohq/design-system-flex';
|
|
20
|
+
import { Heading } from '@mirohq/design-system-typography';
|
|
21
|
+
import { IconButton } from '@mirohq/design-system-icon-button';
|
|
20
22
|
import { Button } from '@mirohq/design-system-button';
|
|
21
23
|
|
|
22
24
|
const StyledPlaceholder = styled(Primitive.span, {
|
|
@@ -26,6 +28,12 @@ const StyledPlaceholder = styled(Primitive.span, {
|
|
|
26
28
|
const StyledValue$1 = styled(Primitive.span, {
|
|
27
29
|
padding: "0 $50"
|
|
28
30
|
});
|
|
31
|
+
const StyledIconContainer = styled(Primitive.span, {
|
|
32
|
+
display: "flex",
|
|
33
|
+
justifyContent: "center",
|
|
34
|
+
padding: "6px",
|
|
35
|
+
color: "$text-neutrals-subtle"
|
|
36
|
+
});
|
|
29
37
|
const StyledTrigger = styled(BaseButton, {
|
|
30
38
|
display: "inline-flex",
|
|
31
39
|
gap: "$50",
|
|
@@ -35,11 +43,11 @@ const StyledTrigger = styled(BaseButton, {
|
|
|
35
43
|
padding: "0 $100",
|
|
36
44
|
minWidth: "230px",
|
|
37
45
|
...textFieldStyles.variants.idle,
|
|
38
|
-
"& svg": {
|
|
39
|
-
color: "$text-neutrals-subtle",
|
|
40
|
-
square: "22px"
|
|
41
|
-
},
|
|
42
46
|
_hover: textFieldStyles.variants.hovered,
|
|
47
|
+
'&:disabled, &[aria-disabled="true"]': {
|
|
48
|
+
...textFieldStyles.variants.disabled,
|
|
49
|
+
color: "$text-neutrals-disabled"
|
|
50
|
+
},
|
|
43
51
|
variants: {
|
|
44
52
|
v1: {
|
|
45
53
|
true: {
|
|
@@ -74,7 +82,10 @@ const StyledClearAction = styled(BaseButton, {
|
|
|
74
82
|
right: "calc($100 + 1px)",
|
|
75
83
|
// to compensate border width
|
|
76
84
|
margin: "auto",
|
|
77
|
-
...actionButtonStyles
|
|
85
|
+
...actionButtonStyles,
|
|
86
|
+
'&:disabled, &[aria-disabled="true"]': {
|
|
87
|
+
color: "$icon-neutrals-disabled"
|
|
88
|
+
}
|
|
78
89
|
});
|
|
79
90
|
|
|
80
91
|
const ClearAction = React.forwardRef(({ "aria-label": ariaLabel, label, ...restProps }, forwardRef) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
@@ -178,7 +189,7 @@ const Trigger = React.forwardRef(
|
|
|
178
189
|
...restProps
|
|
179
190
|
}, forwardRef) => {
|
|
180
191
|
const [v1] = useNewDesignLanguage();
|
|
181
|
-
const { value, setValue } = useCalendarContext();
|
|
192
|
+
const { value, setValue, disabled, ariaDisabled } = useCalendarContext();
|
|
182
193
|
const { formElementId, ariaDescribedBy: formFieldContextDescribedBy } = useFormFieldContext();
|
|
183
194
|
if (asChild) {
|
|
184
195
|
return /* @__PURE__ */ jsx(Trigger$1, { ref: forwardRef, asChild: true, children: /* @__PURE__ */ jsx(StyledCustomTrigger, { asChild: true, ...restProps, children }) });
|
|
@@ -201,47 +212,40 @@ const Trigger = React.forwardRef(
|
|
|
201
212
|
),
|
|
202
213
|
v1,
|
|
203
214
|
withClearButton: clearButtonVisible,
|
|
215
|
+
disabled,
|
|
216
|
+
"aria-disabled": ariaDisabled,
|
|
204
217
|
...restProps,
|
|
205
218
|
children: [
|
|
206
219
|
value != null ? /* @__PURE__ */ jsx(StyledValue$1, { children }) : /* @__PURE__ */ jsx(StyledPlaceholder, { children: placeholder }),
|
|
207
|
-
!clearButtonVisible && /* @__PURE__ */ jsx(IconCalendarBlank, { weight: "thin" })
|
|
220
|
+
!clearButtonVisible && /* @__PURE__ */ jsx(StyledIconContainer, { children: /* @__PURE__ */ jsx(IconCalendarBlank, { weight: "thin", size: "small" }) })
|
|
208
221
|
]
|
|
209
222
|
}
|
|
210
223
|
) }),
|
|
211
|
-
clearButtonVisible && /* @__PURE__ */ jsx(
|
|
224
|
+
clearButtonVisible && /* @__PURE__ */ jsx(
|
|
225
|
+
ClearAction,
|
|
226
|
+
{
|
|
227
|
+
label: clearLabel,
|
|
228
|
+
onPress: onClearHandler,
|
|
229
|
+
disabled: disabled != null ? disabled : booleanify(ariaDisabled)
|
|
230
|
+
}
|
|
231
|
+
)
|
|
212
232
|
] });
|
|
213
233
|
}
|
|
214
234
|
);
|
|
215
235
|
|
|
216
236
|
const StyledContent = styled(Content$1, {
|
|
217
237
|
zIndex: "$calendar",
|
|
218
|
-
display: "inline-block",
|
|
219
|
-
background: "$background-neutrals"
|
|
220
|
-
});
|
|
221
|
-
const StyledBodyContent = styled(Flex, {
|
|
222
|
-
margin: "0 auto",
|
|
223
|
-
boxShadow: "$100",
|
|
224
238
|
background: "$background-neutrals",
|
|
225
|
-
borderRadius: "$100"
|
|
239
|
+
borderRadius: "$100",
|
|
240
|
+
boxShadow: "$100"
|
|
226
241
|
});
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
"& [data-left-calendar]": {
|
|
230
|
-
paddingLeft: "$200",
|
|
231
|
-
paddingRight: "$100"
|
|
232
|
-
},
|
|
233
|
-
"& [data-right-calendar]": {
|
|
234
|
-
paddingLeft: "$100",
|
|
235
|
-
paddingRight: "$200"
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
const StyledBodyContentLeft = styled(Primitive.div, {
|
|
239
|
-
paddingLeft: "$200",
|
|
240
|
-
paddingRight: "$100"
|
|
242
|
+
const StyledCalendarBody = styled(Flex, {
|
|
243
|
+
padding: "$200"
|
|
241
244
|
});
|
|
245
|
+
const StyledGridContent = styled(Flex, {});
|
|
246
|
+
const StyledBodyContentLeft = styled(Primitive.div, {});
|
|
242
247
|
const StyledBodyContentRight = styled(Primitive.div, {
|
|
243
|
-
paddingLeft: "$
|
|
244
|
-
paddingRight: "$200"
|
|
248
|
+
paddingLeft: "$200"
|
|
245
249
|
});
|
|
246
250
|
const StyledClearContent = styled(Primitive.div, {
|
|
247
251
|
display: "flex",
|
|
@@ -250,40 +254,33 @@ const StyledClearContent = styled(Primitive.div, {
|
|
|
250
254
|
borderTop: "1px solid $border-neutrals"
|
|
251
255
|
});
|
|
252
256
|
|
|
253
|
-
const StyledHeaderTitle = styled(
|
|
254
|
-
|
|
255
|
-
flex: "
|
|
256
|
-
|
|
257
|
+
const StyledHeaderTitle = styled(Heading, {
|
|
258
|
+
margin: 0,
|
|
259
|
+
flex: "2",
|
|
260
|
+
textAlign: "center"
|
|
257
261
|
});
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
262
|
+
const StyledHeaderPlaceholder = styled("div", {
|
|
263
|
+
height: "$8",
|
|
264
|
+
// to compensate icon buttons' width and space between 2 calendars
|
|
265
|
+
width: "calc($8 * 2 + $space$200)"
|
|
261
266
|
});
|
|
262
|
-
|
|
263
|
-
const StyledHeaderButton = styled(Primitive.button, {
|
|
264
|
-
padding: "0",
|
|
265
|
-
backgroundColor: "$transparent",
|
|
266
|
-
border: "none",
|
|
267
|
-
cursor: "pointer",
|
|
267
|
+
const StyledHeader = styled(Flex, {
|
|
268
268
|
color: "$text-neutrals",
|
|
269
|
-
"
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
height: "$8",
|
|
270
|
+
alignItems: "center",
|
|
271
|
+
justifyContent: "space-between"
|
|
272
272
|
});
|
|
273
273
|
|
|
274
|
-
const HeaderButton = React.forwardRef((
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
);
|
|
286
|
-
});
|
|
274
|
+
const HeaderButton = React.forwardRef(({ isDisabled, children, ...restProps }, forwardRef) => /* @__PURE__ */ jsx(
|
|
275
|
+
IconButton,
|
|
276
|
+
{
|
|
277
|
+
...restProps,
|
|
278
|
+
size: "medium",
|
|
279
|
+
disabled: isDisabled,
|
|
280
|
+
ref: forwardRef,
|
|
281
|
+
children
|
|
282
|
+
}
|
|
283
|
+
));
|
|
287
284
|
|
|
288
285
|
const Header = ({
|
|
289
286
|
state,
|
|
@@ -298,77 +295,93 @@ const Header = ({
|
|
|
298
295
|
});
|
|
299
296
|
return /* @__PURE__ */ jsxs(StyledHeader, { children: [
|
|
300
297
|
/* @__PURE__ */ jsx(HeaderButton, { ...prevButtonProps, children: /* @__PURE__ */ jsx(IconChevronLeft, {}) }),
|
|
301
|
-
/* @__PURE__ */ jsx(StyledHeaderTitle, {
|
|
298
|
+
/* @__PURE__ */ jsx(StyledHeaderTitle, { level: 2, styledAs: "h3", children: monthDateFormatter.format(
|
|
302
299
|
state.visibleRange.start.toDate(state.timeZone)
|
|
303
|
-
) })
|
|
304
|
-
visibleMonths === 2 && /* @__PURE__ */
|
|
305
|
-
|
|
306
|
-
|
|
300
|
+
) }),
|
|
301
|
+
visibleMonths === 2 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
302
|
+
/* @__PURE__ */ jsx(StyledHeaderPlaceholder, {}),
|
|
303
|
+
/* @__PURE__ */ jsx(StyledHeaderTitle, { level: 2, styledAs: "h3", children: monthDateFormatter.format(
|
|
304
|
+
state.visibleRange.start.add({ months: 1 }).toDate(state.timeZone)
|
|
305
|
+
) })
|
|
306
|
+
] }),
|
|
307
307
|
/* @__PURE__ */ jsx(HeaderButton, { ...nextButtonProps, children: /* @__PURE__ */ jsx(IconChevronRight, {}) })
|
|
308
308
|
] });
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
+
const StyledCell = styled(Primitive.td, {
|
|
312
|
+
square: "$10",
|
|
313
|
+
marginTop: "$50",
|
|
314
|
+
position: "relative"
|
|
315
|
+
});
|
|
311
316
|
const StyledCellContent = styled(Primitive.div, {
|
|
312
|
-
|
|
317
|
+
cursor: "pointer",
|
|
318
|
+
square: "$10",
|
|
313
319
|
display: "flex",
|
|
314
320
|
alignItems: "center",
|
|
315
321
|
justifyContent: "center",
|
|
316
322
|
borderRadius: "$50",
|
|
317
323
|
color: "$text-neutrals",
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
"&[data-selection]": {
|
|
328
|
-
borderRadius: "$50",
|
|
329
|
-
background: "$background-primary-prominent-selected",
|
|
330
|
-
color: "$text-primary-inverted",
|
|
331
|
-
fontWeight: "600"
|
|
332
|
-
},
|
|
333
|
-
"&[data-disabled]": {
|
|
324
|
+
...focus.css({
|
|
325
|
+
top: "0",
|
|
326
|
+
left: "0",
|
|
327
|
+
position: "absolute",
|
|
328
|
+
zIndex: "1",
|
|
329
|
+
boxShadow: "$focus-v1",
|
|
330
|
+
outline: "1px solid transparent"
|
|
331
|
+
}),
|
|
332
|
+
'&[aria-disabled="true"]': {
|
|
334
333
|
textDecoration: "line-through",
|
|
335
|
-
color: "$text-neutrals-disabled"
|
|
336
|
-
|
|
337
|
-
});
|
|
338
|
-
const StyledCell = styled(Primitive.div, {
|
|
339
|
-
square: "36px",
|
|
340
|
-
cursor: "pointer",
|
|
341
|
-
display: "flex",
|
|
342
|
-
alignItems: "center",
|
|
343
|
-
justifyContent: "center",
|
|
344
|
-
"&:hover": {
|
|
345
|
-
background: "$background-primary-subtle-hover",
|
|
346
|
-
["& ".concat(StyledCellContent)]: {
|
|
347
|
-
background: "$background-primary-prominent-hover",
|
|
348
|
-
color: "$text-primary-inverted"
|
|
349
|
-
}
|
|
334
|
+
color: "$text-neutrals-disabled",
|
|
335
|
+
cursor: "default"
|
|
350
336
|
},
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
borderTopLeftRadius: "$lg"
|
|
357
|
-
},
|
|
358
|
-
"&[data-selection-end]": {
|
|
359
|
-
borderBottomRightRadius: "$lg",
|
|
360
|
-
borderTopRightRadius: "$lg"
|
|
361
|
-
},
|
|
362
|
-
"&[data-hidden]": {
|
|
363
|
-
display: "none"
|
|
337
|
+
'&:not([aria-disabled="true"])': {
|
|
338
|
+
_hover: {
|
|
339
|
+
backgroundColor: "$background-neutrals-subtle-hover",
|
|
340
|
+
color: "$text-neutrals"
|
|
341
|
+
}
|
|
364
342
|
},
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
343
|
+
variants: {
|
|
344
|
+
today: {
|
|
345
|
+
true: {
|
|
346
|
+
backgroundColor: "$background-neutrals-subtle-hover",
|
|
347
|
+
color: "$text-neutrals"
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
selected: {
|
|
351
|
+
true: {
|
|
352
|
+
backgroundColor: "$background-primary-prominent-selected",
|
|
353
|
+
color: "$text-neutrals-inverted",
|
|
354
|
+
'&:not([aria-disabled="true"])': {
|
|
355
|
+
_hover: {
|
|
356
|
+
backgroundColor: "$background-primary-prominent-hover",
|
|
357
|
+
color: "$text-neutrals-inverted"
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
range: {
|
|
363
|
+
middle: {
|
|
364
|
+
backgroundColor: "$background-primary-subtle-selected",
|
|
365
|
+
color: "$text-neutrals",
|
|
366
|
+
borderRadius: 0,
|
|
367
|
+
'&:not([aria-disabled="true"])': {
|
|
368
|
+
_hover: {
|
|
369
|
+
backgroundColor: "$background-primary-subtle-hover"
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
start: {
|
|
374
|
+
borderTopRightRadius: 0,
|
|
375
|
+
borderBottomRightRadius: 0
|
|
376
|
+
},
|
|
377
|
+
end: {
|
|
378
|
+
borderTopLeftRadius: 0,
|
|
379
|
+
borderBottomLeftRadius: 0
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
hidden: {
|
|
383
|
+
true: {
|
|
384
|
+
display: "none"
|
|
372
385
|
}
|
|
373
386
|
}
|
|
374
387
|
}
|
|
@@ -377,37 +390,27 @@ const StyledCell = styled(Primitive.div, {
|
|
|
377
390
|
const Cell = (props) => {
|
|
378
391
|
const { state, date, currentMonth } = props;
|
|
379
392
|
const ref = useRef(null);
|
|
380
|
-
const { cellProps, buttonProps, isSelected,
|
|
393
|
+
const { cellProps, buttonProps, isSelected, formattedDate } = useCalendarCell(
|
|
394
|
+
{ date },
|
|
395
|
+
state,
|
|
396
|
+
ref
|
|
397
|
+
);
|
|
381
398
|
const isOutsideMonth = !isSameMonth(currentMonth, date);
|
|
382
399
|
const isSelectionStart = state.highlightedRange !== void 0 && state.highlightedRange !== null ? isSameDay(date, state.highlightedRange.start) : isSelected;
|
|
383
400
|
const isSelectionEnd = state.highlightedRange !== void 0 && state.highlightedRange !== null ? isSameDay(date, state.highlightedRange.end) : isSelected;
|
|
384
|
-
const { locale } = useLocale();
|
|
385
|
-
const dayOfWeek = getDayOfWeek(date, locale);
|
|
386
|
-
const isWeekendDay = isWeekend(date, locale);
|
|
387
|
-
const isRoundedLeft = isSelected && (isSelectionStart || dayOfWeek === 0 || date.day === 1);
|
|
388
|
-
const isRoundedRight = isSelected && (isSelectionEnd || dayOfWeek === 6 || date.day === date.calendar.getDaysInMonth(date));
|
|
389
401
|
const { focusProps } = useFocusRing();
|
|
390
|
-
|
|
391
|
-
|
|
402
|
+
const isRange = isSelected && (!isSelectionStart || !isSelectionEnd);
|
|
403
|
+
const rangeVariant = isRange ? isSelectionStart ? "start" : isSelectionEnd ? "end" : "middle" : void 0;
|
|
404
|
+
return /* @__PURE__ */ jsx(StyledCell, { ...cellProps, children: /* @__PURE__ */ jsx(
|
|
405
|
+
StyledCellContent,
|
|
392
406
|
{
|
|
393
407
|
...mergeProps(buttonProps, focusProps),
|
|
394
408
|
ref,
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
children: /* @__PURE__ */ jsx(
|
|
401
|
-
StyledCellContent,
|
|
402
|
-
{
|
|
403
|
-
"data-selected-middle": isSelected && !(isSelectionStart || isSelectionEnd) ? "" : void 0,
|
|
404
|
-
"data-selection": isSelectionStart || isSelectionEnd ? "" : void 0,
|
|
405
|
-
"data-disabled": isDisabled ? "" : void 0,
|
|
406
|
-
"data-today": isToday(date, getLocalTimeZone()) ? "" : void 0,
|
|
407
|
-
"data-weekend": isWeekendDay ? "" : void 0,
|
|
408
|
-
children: formattedDate
|
|
409
|
-
}
|
|
410
|
-
)
|
|
409
|
+
selected: isSelected && (isSelectionStart || isSelectionEnd),
|
|
410
|
+
today: isToday(date, getLocalTimeZone()),
|
|
411
|
+
range: rangeVariant,
|
|
412
|
+
hidden: isOutsideMonth,
|
|
413
|
+
children: formattedDate
|
|
411
414
|
}
|
|
412
415
|
) });
|
|
413
416
|
};
|
|
@@ -417,8 +420,10 @@ const StyledGrid = styled(Primitive.table, {
|
|
|
417
420
|
borderSpacing: " 0 $50"
|
|
418
421
|
});
|
|
419
422
|
const StyledDays = styled(Primitive.th, {
|
|
420
|
-
|
|
421
|
-
color: "$text-neutrals"
|
|
423
|
+
height: "$10",
|
|
424
|
+
color: "$text-neutrals-subtle",
|
|
425
|
+
fontWeight: "$regular",
|
|
426
|
+
paddingTop: "$50"
|
|
422
427
|
});
|
|
423
428
|
|
|
424
429
|
const Grid = React.forwardRef(
|
|
@@ -450,27 +455,34 @@ const Grid = React.forwardRef(
|
|
|
450
455
|
|
|
451
456
|
const CONTENT_OFFSET = parseInt(theme.space[50]);
|
|
452
457
|
const SharedContent = React.forwardRef(
|
|
453
|
-
({ calendarProps, prevButtonProps, nextButtonProps,
|
|
458
|
+
({ calendarProps, prevButtonProps, nextButtonProps, state }, forwardRef) => {
|
|
454
459
|
const { visibleDuration } = useCalendarContext();
|
|
455
|
-
return /* @__PURE__ */
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
460
|
+
return /* @__PURE__ */ jsxs(
|
|
461
|
+
StyledCalendarBody,
|
|
462
|
+
{
|
|
463
|
+
direction: "column",
|
|
464
|
+
...calendarProps,
|
|
465
|
+
ref: forwardRef,
|
|
466
|
+
children: [
|
|
467
|
+
/* @__PURE__ */ jsx(
|
|
468
|
+
Header,
|
|
469
|
+
{
|
|
470
|
+
state,
|
|
471
|
+
prevButtonProps,
|
|
472
|
+
nextButtonProps,
|
|
473
|
+
visibleMonths: visibleDuration.months
|
|
474
|
+
}
|
|
475
|
+
),
|
|
476
|
+
/* @__PURE__ */ jsxs(StyledGridContent, { children: [
|
|
477
|
+
/* @__PURE__ */ jsx(StyledBodyContentLeft, { children: /* @__PURE__ */ jsx(Grid, { state }) }),
|
|
478
|
+
visibleDuration.months === 2 && /* @__PURE__ */ jsx(StyledBodyContentRight, { children: /* @__PURE__ */ jsx(Grid, { state, offset: { months: 1 } }) })
|
|
479
|
+
] })
|
|
480
|
+
]
|
|
481
|
+
}
|
|
482
|
+
);
|
|
471
483
|
}
|
|
472
484
|
);
|
|
473
|
-
const DatePickerContent = (
|
|
485
|
+
const DatePickerContent = () => {
|
|
474
486
|
const { locale } = useLocale();
|
|
475
487
|
const {
|
|
476
488
|
calendarValue,
|
|
@@ -499,12 +511,11 @@ const DatePickerContent = ({ children }) => {
|
|
|
499
511
|
calendarProps,
|
|
500
512
|
prevButtonProps,
|
|
501
513
|
nextButtonProps,
|
|
502
|
-
state
|
|
503
|
-
children
|
|
514
|
+
state
|
|
504
515
|
}
|
|
505
516
|
);
|
|
506
517
|
};
|
|
507
|
-
const RangePickerContent = (
|
|
518
|
+
const RangePickerContent = () => {
|
|
508
519
|
const { locale } = useLocale();
|
|
509
520
|
const {
|
|
510
521
|
calendarValue,
|
|
@@ -536,8 +547,7 @@ const RangePickerContent = ({ children }) => {
|
|
|
536
547
|
calendarProps,
|
|
537
548
|
prevButtonProps,
|
|
538
549
|
nextButtonProps,
|
|
539
|
-
state
|
|
540
|
-
children
|
|
550
|
+
state
|
|
541
551
|
}
|
|
542
552
|
);
|
|
543
553
|
};
|
|
@@ -571,7 +581,10 @@ const Content = React.forwardRef(
|
|
|
571
581
|
avoidCollisions,
|
|
572
582
|
sticky,
|
|
573
583
|
hideWhenDetached,
|
|
574
|
-
children:
|
|
584
|
+
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", children: [
|
|
585
|
+
picker === "single" ? /* @__PURE__ */ jsx(DatePickerContent, {}) : /* @__PURE__ */ jsx(RangePickerContent, {}),
|
|
586
|
+
children != null && /* @__PURE__ */ jsx(StyledClearContent, { children })
|
|
587
|
+
] })
|
|
575
588
|
}
|
|
576
589
|
);
|
|
577
590
|
}
|
|
@@ -584,11 +597,10 @@ const DEFAULT_FORMAT = {
|
|
|
584
597
|
month: "short",
|
|
585
598
|
year: "numeric"
|
|
586
599
|
};
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
return formatter.format(date.toDate(DEFAULT_TIMEZONE));
|
|
600
|
+
function formatDate(date, formatter, timeZone) {
|
|
601
|
+
return formatter.format(date.toDate(timeZone));
|
|
590
602
|
}
|
|
591
|
-
function formatValue(value, formatter) {
|
|
603
|
+
function formatValue(value, formatter, timeZone) {
|
|
592
604
|
if (value == null) {
|
|
593
605
|
return void 0;
|
|
594
606
|
}
|
|
@@ -596,21 +608,23 @@ function formatValue(value, formatter) {
|
|
|
596
608
|
if (value.start == null || value.end == null) {
|
|
597
609
|
return void 0;
|
|
598
610
|
}
|
|
599
|
-
return "".concat(formatDate(value.start, formatter), " - ").concat(formatDate(
|
|
611
|
+
return "".concat(formatDate(value.start, formatter, timeZone), " - ").concat(formatDate(
|
|
600
612
|
value.end,
|
|
601
|
-
formatter
|
|
613
|
+
formatter,
|
|
614
|
+
timeZone
|
|
602
615
|
));
|
|
603
616
|
}
|
|
604
|
-
return formatDate(value, formatter);
|
|
617
|
+
return formatDate(value, formatter, timeZone);
|
|
605
618
|
}
|
|
606
619
|
const Value = React.forwardRef(({ format = DEFAULT_FORMAT, ...restProps }, forwardRef) => {
|
|
607
620
|
const { value } = useCalendarContext();
|
|
621
|
+
const timeZone = useMemo(getLocalTimeZone, [format]);
|
|
608
622
|
const formatWithTimeZone = useMemo(
|
|
609
|
-
() => ({ ...format,
|
|
610
|
-
[format]
|
|
623
|
+
() => ({ ...format, timeZone }),
|
|
624
|
+
[format, timeZone]
|
|
611
625
|
);
|
|
612
626
|
const dateFormatter = useDateFormatter(formatWithTimeZone);
|
|
613
|
-
const valueToDisplay = formatValue(value, dateFormatter);
|
|
627
|
+
const valueToDisplay = formatValue(value, dateFormatter, timeZone);
|
|
614
628
|
return /* @__PURE__ */ jsx(StyledValue, { ref: forwardRef, ...restProps, children: valueToDisplay });
|
|
615
629
|
});
|
|
616
630
|
|
|
@@ -687,6 +701,8 @@ const Calendar = React.forwardRef(
|
|
|
687
701
|
visibleMonths,
|
|
688
702
|
minDate,
|
|
689
703
|
maxDate,
|
|
704
|
+
disabled,
|
|
705
|
+
"aria-disabled": ariaDisabled,
|
|
690
706
|
children,
|
|
691
707
|
...props
|
|
692
708
|
}, forwardRef) => {
|
|
@@ -701,7 +717,9 @@ const Calendar = React.forwardRef(
|
|
|
701
717
|
defaultOpen,
|
|
702
718
|
open,
|
|
703
719
|
onClose,
|
|
704
|
-
onOpen
|
|
720
|
+
onOpen,
|
|
721
|
+
disabled,
|
|
722
|
+
ariaDisabled
|
|
705
723
|
};
|
|
706
724
|
return /* @__PURE__ */ jsx(I18nProvider, { locale, children: /* @__PURE__ */ jsx(CalendarProvider, { ...providerProps, children: /* @__PURE__ */ jsx(Root, { ...props, ref: forwardRef, children }) }) });
|
|
707
725
|
}
|