@mirohq/design-system-calendar 1.0.0 → 1.1.1
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 +9 -6
package/dist/main.js
CHANGED
|
@@ -20,6 +20,8 @@ var reactUseControllableState = require('@radix-ui/react-use-controllable-state'
|
|
|
20
20
|
var reactStately = require('react-stately');
|
|
21
21
|
var date = require('@internationalized/date');
|
|
22
22
|
var designSystemFlex = require('@mirohq/design-system-flex');
|
|
23
|
+
var designSystemTypography = require('@mirohq/design-system-typography');
|
|
24
|
+
var designSystemIconButton = require('@mirohq/design-system-icon-button');
|
|
23
25
|
var designSystemButton = require('@mirohq/design-system-button');
|
|
24
26
|
|
|
25
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -52,6 +54,12 @@ const StyledPlaceholder = designSystemStitches.styled(designSystemPrimitive.Prim
|
|
|
52
54
|
const StyledValue$1 = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
53
55
|
padding: "0 $50"
|
|
54
56
|
});
|
|
57
|
+
const StyledIconContainer = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
58
|
+
display: "flex",
|
|
59
|
+
justifyContent: "center",
|
|
60
|
+
padding: "6px",
|
|
61
|
+
color: "$text-neutrals-subtle"
|
|
62
|
+
});
|
|
55
63
|
const StyledTrigger = designSystemStitches.styled(designSystemBaseButton.BaseButton, {
|
|
56
64
|
display: "inline-flex",
|
|
57
65
|
gap: "$50",
|
|
@@ -61,11 +69,11 @@ const StyledTrigger = designSystemStitches.styled(designSystemBaseButton.BaseBut
|
|
|
61
69
|
padding: "0 $100",
|
|
62
70
|
minWidth: "230px",
|
|
63
71
|
...designSystemBaseTextField.textFieldStyles.variants.idle,
|
|
64
|
-
"& svg": {
|
|
65
|
-
color: "$text-neutrals-subtle",
|
|
66
|
-
square: "22px"
|
|
67
|
-
},
|
|
68
72
|
_hover: designSystemBaseTextField.textFieldStyles.variants.hovered,
|
|
73
|
+
'&:disabled, &[aria-disabled="true"]': {
|
|
74
|
+
...designSystemBaseTextField.textFieldStyles.variants.disabled,
|
|
75
|
+
color: "$text-neutrals-disabled"
|
|
76
|
+
},
|
|
69
77
|
variants: {
|
|
70
78
|
v1: {
|
|
71
79
|
true: {
|
|
@@ -100,7 +108,10 @@ const StyledClearAction = designSystemStitches.styled(designSystemBaseButton.Bas
|
|
|
100
108
|
right: "calc($100 + 1px)",
|
|
101
109
|
// to compensate border width
|
|
102
110
|
margin: "auto",
|
|
103
|
-
...designSystemBaseTextField.actionButtonStyles
|
|
111
|
+
...designSystemBaseTextField.actionButtonStyles,
|
|
112
|
+
'&:disabled, &[aria-disabled="true"]': {
|
|
113
|
+
color: "$icon-neutrals-disabled"
|
|
114
|
+
}
|
|
104
115
|
});
|
|
105
116
|
|
|
106
117
|
const ClearAction = React__default["default"].forwardRef(({ "aria-label": ariaLabel, label, ...restProps }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsxs(designSystemTooltip.Tooltip, { children: [
|
|
@@ -204,7 +215,7 @@ const Trigger = React__default["default"].forwardRef(
|
|
|
204
215
|
...restProps
|
|
205
216
|
}, forwardRef) => {
|
|
206
217
|
const [v1] = designSystemExperiments.useNewDesignLanguage();
|
|
207
|
-
const { value, setValue } = useCalendarContext();
|
|
218
|
+
const { value, setValue, disabled, ariaDisabled } = useCalendarContext();
|
|
208
219
|
const { formElementId, ariaDescribedBy: formFieldContextDescribedBy } = designSystemBaseForm.useFormFieldContext();
|
|
209
220
|
if (asChild) {
|
|
210
221
|
return /* @__PURE__ */ jsxRuntime.jsx(RadixPopover.Trigger, { ref: forwardRef, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(StyledCustomTrigger, { asChild: true, ...restProps, children }) });
|
|
@@ -227,47 +238,40 @@ const Trigger = React__default["default"].forwardRef(
|
|
|
227
238
|
),
|
|
228
239
|
v1,
|
|
229
240
|
withClearButton: clearButtonVisible,
|
|
241
|
+
disabled,
|
|
242
|
+
"aria-disabled": ariaDisabled,
|
|
230
243
|
...restProps,
|
|
231
244
|
children: [
|
|
232
245
|
value != null ? /* @__PURE__ */ jsxRuntime.jsx(StyledValue$1, { children }) : /* @__PURE__ */ jsxRuntime.jsx(StyledPlaceholder, { children: placeholder }),
|
|
233
|
-
!clearButtonVisible && /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconCalendarBlank, { weight: "thin" })
|
|
246
|
+
!clearButtonVisible && /* @__PURE__ */ jsxRuntime.jsx(StyledIconContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconCalendarBlank, { weight: "thin", size: "small" }) })
|
|
234
247
|
]
|
|
235
248
|
}
|
|
236
249
|
) }),
|
|
237
|
-
clearButtonVisible && /* @__PURE__ */ jsxRuntime.jsx(
|
|
250
|
+
clearButtonVisible && /* @__PURE__ */ jsxRuntime.jsx(
|
|
251
|
+
ClearAction,
|
|
252
|
+
{
|
|
253
|
+
label: clearLabel,
|
|
254
|
+
onPress: onClearHandler,
|
|
255
|
+
disabled: disabled != null ? disabled : designSystemUtils.booleanify(ariaDisabled)
|
|
256
|
+
}
|
|
257
|
+
)
|
|
238
258
|
] });
|
|
239
259
|
}
|
|
240
260
|
);
|
|
241
261
|
|
|
242
262
|
const StyledContent = designSystemStitches.styled(RadixPopover.Content, {
|
|
243
263
|
zIndex: "$calendar",
|
|
244
|
-
display: "inline-block",
|
|
245
|
-
background: "$background-neutrals"
|
|
246
|
-
});
|
|
247
|
-
const StyledBodyContent = designSystemStitches.styled(designSystemFlex.Flex, {
|
|
248
|
-
margin: "0 auto",
|
|
249
|
-
boxShadow: "$100",
|
|
250
264
|
background: "$background-neutrals",
|
|
251
|
-
borderRadius: "$100"
|
|
265
|
+
borderRadius: "$100",
|
|
266
|
+
boxShadow: "$100"
|
|
252
267
|
});
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
"& [data-left-calendar]": {
|
|
256
|
-
paddingLeft: "$200",
|
|
257
|
-
paddingRight: "$100"
|
|
258
|
-
},
|
|
259
|
-
"& [data-right-calendar]": {
|
|
260
|
-
paddingLeft: "$100",
|
|
261
|
-
paddingRight: "$200"
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
const StyledBodyContentLeft = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
265
|
-
paddingLeft: "$200",
|
|
266
|
-
paddingRight: "$100"
|
|
268
|
+
const StyledCalendarBody = designSystemStitches.styled(designSystemFlex.Flex, {
|
|
269
|
+
padding: "$200"
|
|
267
270
|
});
|
|
271
|
+
const StyledGridContent = designSystemStitches.styled(designSystemFlex.Flex, {});
|
|
272
|
+
const StyledBodyContentLeft = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {});
|
|
268
273
|
const StyledBodyContentRight = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
269
|
-
paddingLeft: "$
|
|
270
|
-
paddingRight: "$200"
|
|
274
|
+
paddingLeft: "$200"
|
|
271
275
|
});
|
|
272
276
|
const StyledClearContent = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
273
277
|
display: "flex",
|
|
@@ -276,40 +280,33 @@ const StyledClearContent = designSystemStitches.styled(designSystemPrimitive.Pri
|
|
|
276
280
|
borderTop: "1px solid $border-neutrals"
|
|
277
281
|
});
|
|
278
282
|
|
|
279
|
-
const StyledHeaderTitle = designSystemStitches.styled(
|
|
280
|
-
|
|
281
|
-
flex: "
|
|
282
|
-
|
|
283
|
+
const StyledHeaderTitle = designSystemStitches.styled(designSystemTypography.Heading, {
|
|
284
|
+
margin: 0,
|
|
285
|
+
flex: "2",
|
|
286
|
+
textAlign: "center"
|
|
283
287
|
});
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
288
|
+
const StyledHeaderPlaceholder = designSystemStitches.styled("div", {
|
|
289
|
+
height: "$8",
|
|
290
|
+
// to compensate icon buttons' width and space between 2 calendars
|
|
291
|
+
width: "calc($8 * 2 + $space$200)"
|
|
287
292
|
});
|
|
288
|
-
|
|
289
|
-
const StyledHeaderButton = designSystemStitches.styled(designSystemPrimitive.Primitive.button, {
|
|
290
|
-
padding: "0",
|
|
291
|
-
backgroundColor: "$transparent",
|
|
292
|
-
border: "none",
|
|
293
|
-
cursor: "pointer",
|
|
293
|
+
const StyledHeader = designSystemStitches.styled(designSystemFlex.Flex, {
|
|
294
294
|
color: "$text-neutrals",
|
|
295
|
-
"
|
|
296
|
-
|
|
297
|
-
|
|
295
|
+
height: "$8",
|
|
296
|
+
alignItems: "center",
|
|
297
|
+
justifyContent: "space-between"
|
|
298
298
|
});
|
|
299
299
|
|
|
300
|
-
const HeaderButton = React__default["default"].forwardRef((
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
);
|
|
312
|
-
});
|
|
300
|
+
const HeaderButton = React__default["default"].forwardRef(({ isDisabled, children, ...restProps }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
301
|
+
designSystemIconButton.IconButton,
|
|
302
|
+
{
|
|
303
|
+
...restProps,
|
|
304
|
+
size: "medium",
|
|
305
|
+
disabled: isDisabled,
|
|
306
|
+
ref: forwardRef,
|
|
307
|
+
children
|
|
308
|
+
}
|
|
309
|
+
));
|
|
313
310
|
|
|
314
311
|
const Header = ({
|
|
315
312
|
state,
|
|
@@ -324,77 +321,93 @@ const Header = ({
|
|
|
324
321
|
});
|
|
325
322
|
return /* @__PURE__ */ jsxRuntime.jsxs(StyledHeader, { children: [
|
|
326
323
|
/* @__PURE__ */ jsxRuntime.jsx(HeaderButton, { ...prevButtonProps, children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconChevronLeft, {}) }),
|
|
327
|
-
/* @__PURE__ */ jsxRuntime.jsx(StyledHeaderTitle, {
|
|
324
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledHeaderTitle, { level: 2, styledAs: "h3", children: monthDateFormatter.format(
|
|
328
325
|
state.visibleRange.start.toDate(state.timeZone)
|
|
329
|
-
) })
|
|
330
|
-
visibleMonths === 2 && /* @__PURE__ */ jsxRuntime.
|
|
331
|
-
|
|
332
|
-
|
|
326
|
+
) }),
|
|
327
|
+
visibleMonths === 2 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
328
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledHeaderPlaceholder, {}),
|
|
329
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledHeaderTitle, { level: 2, styledAs: "h3", children: monthDateFormatter.format(
|
|
330
|
+
state.visibleRange.start.add({ months: 1 }).toDate(state.timeZone)
|
|
331
|
+
) })
|
|
332
|
+
] }),
|
|
333
333
|
/* @__PURE__ */ jsxRuntime.jsx(HeaderButton, { ...nextButtonProps, children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconChevronRight, {}) })
|
|
334
334
|
] });
|
|
335
335
|
};
|
|
336
336
|
|
|
337
|
+
const StyledCell = designSystemStitches.styled(designSystemPrimitive.Primitive.td, {
|
|
338
|
+
square: "$10",
|
|
339
|
+
marginTop: "$50",
|
|
340
|
+
position: "relative"
|
|
341
|
+
});
|
|
337
342
|
const StyledCellContent = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
338
|
-
|
|
343
|
+
cursor: "pointer",
|
|
344
|
+
square: "$10",
|
|
339
345
|
display: "flex",
|
|
340
346
|
alignItems: "center",
|
|
341
347
|
justifyContent: "center",
|
|
342
348
|
borderRadius: "$50",
|
|
343
349
|
color: "$text-neutrals",
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
"&[data-selection]": {
|
|
354
|
-
borderRadius: "$50",
|
|
355
|
-
background: "$background-primary-prominent-selected",
|
|
356
|
-
color: "$text-primary-inverted",
|
|
357
|
-
fontWeight: "600"
|
|
358
|
-
},
|
|
359
|
-
"&[data-disabled]": {
|
|
350
|
+
...designSystemStyles.focus.css({
|
|
351
|
+
top: "0",
|
|
352
|
+
left: "0",
|
|
353
|
+
position: "absolute",
|
|
354
|
+
zIndex: "1",
|
|
355
|
+
boxShadow: "$focus-v1",
|
|
356
|
+
outline: "1px solid transparent"
|
|
357
|
+
}),
|
|
358
|
+
'&[aria-disabled="true"]': {
|
|
360
359
|
textDecoration: "line-through",
|
|
361
|
-
color: "$text-neutrals-disabled"
|
|
362
|
-
|
|
363
|
-
});
|
|
364
|
-
const StyledCell = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
365
|
-
square: "36px",
|
|
366
|
-
cursor: "pointer",
|
|
367
|
-
display: "flex",
|
|
368
|
-
alignItems: "center",
|
|
369
|
-
justifyContent: "center",
|
|
370
|
-
"&:hover": {
|
|
371
|
-
background: "$background-primary-subtle-hover",
|
|
372
|
-
["& ".concat(StyledCellContent)]: {
|
|
373
|
-
background: "$background-primary-prominent-hover",
|
|
374
|
-
color: "$text-primary-inverted"
|
|
375
|
-
}
|
|
360
|
+
color: "$text-neutrals-disabled",
|
|
361
|
+
cursor: "default"
|
|
376
362
|
},
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
borderTopLeftRadius: "$lg"
|
|
383
|
-
},
|
|
384
|
-
"&[data-selection-end]": {
|
|
385
|
-
borderBottomRightRadius: "$lg",
|
|
386
|
-
borderTopRightRadius: "$lg"
|
|
387
|
-
},
|
|
388
|
-
"&[data-hidden]": {
|
|
389
|
-
display: "none"
|
|
363
|
+
'&:not([aria-disabled="true"])': {
|
|
364
|
+
_hover: {
|
|
365
|
+
backgroundColor: "$background-neutrals-subtle-hover",
|
|
366
|
+
color: "$text-neutrals"
|
|
367
|
+
}
|
|
390
368
|
},
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
369
|
+
variants: {
|
|
370
|
+
today: {
|
|
371
|
+
true: {
|
|
372
|
+
backgroundColor: "$background-neutrals-subtle-hover",
|
|
373
|
+
color: "$text-neutrals"
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
selected: {
|
|
377
|
+
true: {
|
|
378
|
+
backgroundColor: "$background-primary-prominent-selected",
|
|
379
|
+
color: "$text-neutrals-inverted",
|
|
380
|
+
'&:not([aria-disabled="true"])': {
|
|
381
|
+
_hover: {
|
|
382
|
+
backgroundColor: "$background-primary-prominent-hover",
|
|
383
|
+
color: "$text-neutrals-inverted"
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
range: {
|
|
389
|
+
middle: {
|
|
390
|
+
backgroundColor: "$background-primary-subtle-selected",
|
|
391
|
+
color: "$text-neutrals",
|
|
392
|
+
borderRadius: 0,
|
|
393
|
+
'&:not([aria-disabled="true"])': {
|
|
394
|
+
_hover: {
|
|
395
|
+
backgroundColor: "$background-primary-subtle-hover"
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
start: {
|
|
400
|
+
borderTopRightRadius: 0,
|
|
401
|
+
borderBottomRightRadius: 0
|
|
402
|
+
},
|
|
403
|
+
end: {
|
|
404
|
+
borderTopLeftRadius: 0,
|
|
405
|
+
borderBottomLeftRadius: 0
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
hidden: {
|
|
409
|
+
true: {
|
|
410
|
+
display: "none"
|
|
398
411
|
}
|
|
399
412
|
}
|
|
400
413
|
}
|
|
@@ -403,37 +416,27 @@ const StyledCell = designSystemStitches.styled(designSystemPrimitive.Primitive.d
|
|
|
403
416
|
const Cell = (props) => {
|
|
404
417
|
const { state, date: date$1, currentMonth } = props;
|
|
405
418
|
const ref = React.useRef(null);
|
|
406
|
-
const { cellProps, buttonProps, isSelected,
|
|
419
|
+
const { cellProps, buttonProps, isSelected, formattedDate } = reactAria.useCalendarCell(
|
|
420
|
+
{ date: date$1 },
|
|
421
|
+
state,
|
|
422
|
+
ref
|
|
423
|
+
);
|
|
407
424
|
const isOutsideMonth = !date.isSameMonth(currentMonth, date$1);
|
|
408
425
|
const isSelectionStart = state.highlightedRange !== void 0 && state.highlightedRange !== null ? date.isSameDay(date$1, state.highlightedRange.start) : isSelected;
|
|
409
426
|
const isSelectionEnd = state.highlightedRange !== void 0 && state.highlightedRange !== null ? date.isSameDay(date$1, state.highlightedRange.end) : isSelected;
|
|
410
|
-
const { locale } = reactAria.useLocale();
|
|
411
|
-
const dayOfWeek = date.getDayOfWeek(date$1, locale);
|
|
412
|
-
const isWeekendDay = date.isWeekend(date$1, locale);
|
|
413
|
-
const isRoundedLeft = isSelected && (isSelectionStart || dayOfWeek === 0 || date$1.day === 1);
|
|
414
|
-
const isRoundedRight = isSelected && (isSelectionEnd || dayOfWeek === 6 || date$1.day === date$1.calendar.getDaysInMonth(date$1));
|
|
415
427
|
const { focusProps } = reactAria.useFocusRing();
|
|
416
|
-
|
|
417
|
-
|
|
428
|
+
const isRange = isSelected && (!isSelectionStart || !isSelectionEnd);
|
|
429
|
+
const rangeVariant = isRange ? isSelectionStart ? "start" : isSelectionEnd ? "end" : "middle" : void 0;
|
|
430
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledCell, { ...cellProps, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
431
|
+
StyledCellContent,
|
|
418
432
|
{
|
|
419
433
|
...reactAria.mergeProps(buttonProps, focusProps),
|
|
420
434
|
ref,
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
427
|
-
StyledCellContent,
|
|
428
|
-
{
|
|
429
|
-
"data-selected-middle": isSelected && !(isSelectionStart || isSelectionEnd) ? "" : void 0,
|
|
430
|
-
"data-selection": isSelectionStart || isSelectionEnd ? "" : void 0,
|
|
431
|
-
"data-disabled": isDisabled ? "" : void 0,
|
|
432
|
-
"data-today": date.isToday(date$1, date.getLocalTimeZone()) ? "" : void 0,
|
|
433
|
-
"data-weekend": isWeekendDay ? "" : void 0,
|
|
434
|
-
children: formattedDate
|
|
435
|
-
}
|
|
436
|
-
)
|
|
435
|
+
selected: isSelected && (isSelectionStart || isSelectionEnd),
|
|
436
|
+
today: date.isToday(date$1, date.getLocalTimeZone()),
|
|
437
|
+
range: rangeVariant,
|
|
438
|
+
hidden: isOutsideMonth,
|
|
439
|
+
children: formattedDate
|
|
437
440
|
}
|
|
438
441
|
) });
|
|
439
442
|
};
|
|
@@ -443,8 +446,10 @@ const StyledGrid = designSystemStitches.styled(designSystemPrimitive.Primitive.t
|
|
|
443
446
|
borderSpacing: " 0 $50"
|
|
444
447
|
});
|
|
445
448
|
const StyledDays = designSystemStitches.styled(designSystemPrimitive.Primitive.th, {
|
|
446
|
-
|
|
447
|
-
color: "$text-neutrals"
|
|
449
|
+
height: "$10",
|
|
450
|
+
color: "$text-neutrals-subtle",
|
|
451
|
+
fontWeight: "$regular",
|
|
452
|
+
paddingTop: "$50"
|
|
448
453
|
});
|
|
449
454
|
|
|
450
455
|
const Grid = React__default["default"].forwardRef(
|
|
@@ -476,27 +481,34 @@ const Grid = React__default["default"].forwardRef(
|
|
|
476
481
|
|
|
477
482
|
const CONTENT_OFFSET = parseInt(designSystemStitches.theme.space[50]);
|
|
478
483
|
const SharedContent = React__default["default"].forwardRef(
|
|
479
|
-
({ calendarProps, prevButtonProps, nextButtonProps,
|
|
484
|
+
({ calendarProps, prevButtonProps, nextButtonProps, state }, forwardRef) => {
|
|
480
485
|
const { visibleDuration } = useCalendarContext();
|
|
481
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
486
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
487
|
+
StyledCalendarBody,
|
|
488
|
+
{
|
|
489
|
+
direction: "column",
|
|
490
|
+
...calendarProps,
|
|
491
|
+
ref: forwardRef,
|
|
492
|
+
children: [
|
|
493
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
494
|
+
Header,
|
|
495
|
+
{
|
|
496
|
+
state,
|
|
497
|
+
prevButtonProps,
|
|
498
|
+
nextButtonProps,
|
|
499
|
+
visibleMonths: visibleDuration.months
|
|
500
|
+
}
|
|
501
|
+
),
|
|
502
|
+
/* @__PURE__ */ jsxRuntime.jsxs(StyledGridContent, { children: [
|
|
503
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledBodyContentLeft, { children: /* @__PURE__ */ jsxRuntime.jsx(Grid, { state }) }),
|
|
504
|
+
visibleDuration.months === 2 && /* @__PURE__ */ jsxRuntime.jsx(StyledBodyContentRight, { children: /* @__PURE__ */ jsxRuntime.jsx(Grid, { state, offset: { months: 1 } }) })
|
|
505
|
+
] })
|
|
506
|
+
]
|
|
507
|
+
}
|
|
508
|
+
);
|
|
497
509
|
}
|
|
498
510
|
);
|
|
499
|
-
const DatePickerContent = (
|
|
511
|
+
const DatePickerContent = () => {
|
|
500
512
|
const { locale } = reactAria.useLocale();
|
|
501
513
|
const {
|
|
502
514
|
calendarValue,
|
|
@@ -525,12 +537,11 @@ const DatePickerContent = ({ children }) => {
|
|
|
525
537
|
calendarProps,
|
|
526
538
|
prevButtonProps,
|
|
527
539
|
nextButtonProps,
|
|
528
|
-
state
|
|
529
|
-
children
|
|
540
|
+
state
|
|
530
541
|
}
|
|
531
542
|
);
|
|
532
543
|
};
|
|
533
|
-
const RangePickerContent = (
|
|
544
|
+
const RangePickerContent = () => {
|
|
534
545
|
const { locale } = reactAria.useLocale();
|
|
535
546
|
const {
|
|
536
547
|
calendarValue,
|
|
@@ -562,8 +573,7 @@ const RangePickerContent = ({ children }) => {
|
|
|
562
573
|
calendarProps,
|
|
563
574
|
prevButtonProps,
|
|
564
575
|
nextButtonProps,
|
|
565
|
-
state
|
|
566
|
-
children
|
|
576
|
+
state
|
|
567
577
|
}
|
|
568
578
|
);
|
|
569
579
|
};
|
|
@@ -597,7 +607,10 @@ const Content = React__default["default"].forwardRef(
|
|
|
597
607
|
avoidCollisions,
|
|
598
608
|
sticky,
|
|
599
609
|
hideWhenDetached,
|
|
600
|
-
children:
|
|
610
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystemFlex.Flex, { direction: "column", children: [
|
|
611
|
+
picker === "single" ? /* @__PURE__ */ jsxRuntime.jsx(DatePickerContent, {}) : /* @__PURE__ */ jsxRuntime.jsx(RangePickerContent, {}),
|
|
612
|
+
children != null && /* @__PURE__ */ jsxRuntime.jsx(StyledClearContent, { children })
|
|
613
|
+
] })
|
|
601
614
|
}
|
|
602
615
|
);
|
|
603
616
|
}
|
|
@@ -610,11 +623,10 @@ const DEFAULT_FORMAT = {
|
|
|
610
623
|
month: "short",
|
|
611
624
|
year: "numeric"
|
|
612
625
|
};
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
return formatter.format(date.toDate(DEFAULT_TIMEZONE));
|
|
626
|
+
function formatDate(date, formatter, timeZone) {
|
|
627
|
+
return formatter.format(date.toDate(timeZone));
|
|
616
628
|
}
|
|
617
|
-
function formatValue(value, formatter) {
|
|
629
|
+
function formatValue(value, formatter, timeZone) {
|
|
618
630
|
if (value == null) {
|
|
619
631
|
return void 0;
|
|
620
632
|
}
|
|
@@ -622,21 +634,23 @@ function formatValue(value, formatter) {
|
|
|
622
634
|
if (value.start == null || value.end == null) {
|
|
623
635
|
return void 0;
|
|
624
636
|
}
|
|
625
|
-
return "".concat(formatDate(value.start, formatter), " - ").concat(formatDate(
|
|
637
|
+
return "".concat(formatDate(value.start, formatter, timeZone), " - ").concat(formatDate(
|
|
626
638
|
value.end,
|
|
627
|
-
formatter
|
|
639
|
+
formatter,
|
|
640
|
+
timeZone
|
|
628
641
|
));
|
|
629
642
|
}
|
|
630
|
-
return formatDate(value, formatter);
|
|
643
|
+
return formatDate(value, formatter, timeZone);
|
|
631
644
|
}
|
|
632
645
|
const Value = React__default["default"].forwardRef(({ format = DEFAULT_FORMAT, ...restProps }, forwardRef) => {
|
|
633
646
|
const { value } = useCalendarContext();
|
|
647
|
+
const timeZone = React.useMemo(date.getLocalTimeZone, [format]);
|
|
634
648
|
const formatWithTimeZone = React.useMemo(
|
|
635
|
-
() => ({ ...format,
|
|
636
|
-
[format]
|
|
649
|
+
() => ({ ...format, timeZone }),
|
|
650
|
+
[format, timeZone]
|
|
637
651
|
);
|
|
638
652
|
const dateFormatter = reactAria.useDateFormatter(formatWithTimeZone);
|
|
639
|
-
const valueToDisplay = formatValue(value, dateFormatter);
|
|
653
|
+
const valueToDisplay = formatValue(value, dateFormatter, timeZone);
|
|
640
654
|
return /* @__PURE__ */ jsxRuntime.jsx(StyledValue, { ref: forwardRef, ...restProps, children: valueToDisplay });
|
|
641
655
|
});
|
|
642
656
|
|
|
@@ -713,6 +727,8 @@ const Calendar = React__default["default"].forwardRef(
|
|
|
713
727
|
visibleMonths,
|
|
714
728
|
minDate,
|
|
715
729
|
maxDate,
|
|
730
|
+
disabled,
|
|
731
|
+
"aria-disabled": ariaDisabled,
|
|
716
732
|
children,
|
|
717
733
|
...props
|
|
718
734
|
}, forwardRef) => {
|
|
@@ -727,7 +743,9 @@ const Calendar = React__default["default"].forwardRef(
|
|
|
727
743
|
defaultOpen,
|
|
728
744
|
open,
|
|
729
745
|
onClose,
|
|
730
|
-
onOpen
|
|
746
|
+
onOpen,
|
|
747
|
+
disabled,
|
|
748
|
+
ariaDisabled
|
|
731
749
|
};
|
|
732
750
|
return /* @__PURE__ */ jsxRuntime.jsx(reactAria.I18nProvider, { locale, children: /* @__PURE__ */ jsxRuntime.jsx(CalendarProvider, { ...providerProps, children: /* @__PURE__ */ jsxRuntime.jsx(Root, { ...props, ref: forwardRef, children }) }) });
|
|
733
751
|
}
|