@12-apps/ui 6.78.3 → 6.78.4
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/_internal/components/form/Calendar/Calendar.js +4 -4
- package/dist/_internal/components/form/Calendar/CalendarDay.js +1 -1
- package/dist/_internal/components/form/Calendar/CalendarDayCell.js +2 -2
- package/dist/_internal/components/form/Calendar/CalendarMonth.js +3 -3
- package/dist/_internal/components/form/DateRangePicker/DateRangePicker.js +5 -5
- package/dist/_internal/components/form/index.js +5 -5
- package/dist/_internal/components/index.js +5 -5
- package/dist/{chunk-6PU3JYVY.js → chunk-6DAIC2MG.js} +2 -2
- package/dist/{chunk-AG3DY5TH.js → chunk-HHPJXK4Z.js} +5 -4
- package/dist/chunk-HHPJXK4Z.js.map +1 -0
- package/dist/{chunk-H3AQQOTI.js → chunk-HKGKQKQT.js} +9 -2
- package/dist/chunk-HKGKQKQT.js.map +1 -0
- package/dist/{chunk-KHIUYLKY.js → chunk-MNZ6MCOK.js} +2 -2
- package/dist/{chunk-R53ZOW4B.js → chunk-NDGA7ZE6.js} +2 -2
- package/dist/form/Calendar.js +4 -4
- package/dist/form/DateRangePicker.js +5 -5
- package/dist/types/components/form/Calendar/CalendarDay.d.ts.map +1 -1
- package/dist/types/components/form/Calendar/CalendarMonth.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/form/Calendar/Calendar.md +7 -0
- package/src/components/form/Calendar/CalendarDay.tsx +13 -2
- package/src/components/form/Calendar/CalendarMonth.tsx +11 -2
- package/dist/chunk-AG3DY5TH.js.map +0 -1
- package/dist/chunk-H3AQQOTI.js.map +0 -1
- /package/dist/{chunk-6PU3JYVY.js.map → chunk-6DAIC2MG.js.map} +0 -0
- /package/dist/{chunk-KHIUYLKY.js.map → chunk-MNZ6MCOK.js.map} +0 -0
- /package/dist/{chunk-R53ZOW4B.js.map → chunk-NDGA7ZE6.js.map} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Calendar,
|
|
3
3
|
Calendar_default
|
|
4
|
-
} from "../../../../chunk-
|
|
4
|
+
} from "../../../../chunk-NDGA7ZE6.js";
|
|
5
5
|
import "../../../../chunk-2ZRZTGWP.js";
|
|
6
6
|
import "../../../../chunk-SUALMVL7.js";
|
|
7
|
-
import "../../../../chunk-
|
|
8
|
-
import "../../../../chunk-
|
|
9
|
-
import "../../../../chunk-
|
|
7
|
+
import "../../../../chunk-HHPJXK4Z.js";
|
|
8
|
+
import "../../../../chunk-6DAIC2MG.js";
|
|
9
|
+
import "../../../../chunk-HKGKQKQT.js";
|
|
10
10
|
import "../../../../chunk-E2Y7G4MP.js";
|
|
11
11
|
import "../../../../chunk-FFQ4NOJT.js";
|
|
12
12
|
import "../../../../chunk-TERT6TIS.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CalendarDayCell
|
|
3
|
-
} from "../../../../chunk-
|
|
4
|
-
import "../../../../chunk-
|
|
3
|
+
} from "../../../../chunk-6DAIC2MG.js";
|
|
4
|
+
import "../../../../chunk-HKGKQKQT.js";
|
|
5
5
|
import "../../../../chunk-E2Y7G4MP.js";
|
|
6
6
|
import "../../../../chunk-TERT6TIS.js";
|
|
7
7
|
import "../../../../chunk-YKCAJ2TN.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CalendarMonth
|
|
3
|
-
} from "../../../../chunk-
|
|
4
|
-
import "../../../../chunk-
|
|
5
|
-
import "../../../../chunk-
|
|
3
|
+
} from "../../../../chunk-HHPJXK4Z.js";
|
|
4
|
+
import "../../../../chunk-6DAIC2MG.js";
|
|
5
|
+
import "../../../../chunk-HKGKQKQT.js";
|
|
6
6
|
import "../../../../chunk-E2Y7G4MP.js";
|
|
7
7
|
import "../../../../chunk-TERT6TIS.js";
|
|
8
8
|
import "../../../../chunk-YKCAJ2TN.js";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
DateRangePicker,
|
|
4
4
|
DateRangePicker_default
|
|
5
|
-
} from "../../../../chunk-
|
|
5
|
+
} from "../../../../chunk-MNZ6MCOK.js";
|
|
6
6
|
import "../../../../chunk-QKLSHNOH.js";
|
|
7
7
|
import "../../../../chunk-AXZCCX7O.js";
|
|
8
8
|
import "../../../../chunk-6KKQHJE7.js";
|
|
@@ -10,12 +10,12 @@ import "../../../../chunk-3YLRR4JM.js";
|
|
|
10
10
|
import "../../../../chunk-NTO5DALI.js";
|
|
11
11
|
import "../../../../chunk-FRAVVI4A.js";
|
|
12
12
|
import "../../../../chunk-BO6S47KI.js";
|
|
13
|
-
import "../../../../chunk-
|
|
13
|
+
import "../../../../chunk-NDGA7ZE6.js";
|
|
14
14
|
import "../../../../chunk-2ZRZTGWP.js";
|
|
15
15
|
import "../../../../chunk-SUALMVL7.js";
|
|
16
|
-
import "../../../../chunk-
|
|
17
|
-
import "../../../../chunk-
|
|
18
|
-
import "../../../../chunk-
|
|
16
|
+
import "../../../../chunk-HHPJXK4Z.js";
|
|
17
|
+
import "../../../../chunk-6DAIC2MG.js";
|
|
18
|
+
import "../../../../chunk-HKGKQKQT.js";
|
|
19
19
|
import "../../../../chunk-E2Y7G4MP.js";
|
|
20
20
|
import "../../../../chunk-FFQ4NOJT.js";
|
|
21
21
|
import "../../../../chunk-TERT6TIS.js";
|
|
@@ -121,7 +121,7 @@ import "../../../chunk-YOKUDQIJ.js";
|
|
|
121
121
|
import "../../../chunk-BN6POCYF.js";
|
|
122
122
|
import {
|
|
123
123
|
DateRangePicker
|
|
124
|
-
} from "../../../chunk-
|
|
124
|
+
} from "../../../chunk-MNZ6MCOK.js";
|
|
125
125
|
import {
|
|
126
126
|
DEFAULT_QUICK_RANGES,
|
|
127
127
|
DEFAULT_QUICK_RANGE_LABELS,
|
|
@@ -164,12 +164,12 @@ import "../../../chunk-JXS56EW5.js";
|
|
|
164
164
|
import "../../../chunk-BO6S47KI.js";
|
|
165
165
|
import {
|
|
166
166
|
Calendar
|
|
167
|
-
} from "../../../chunk-
|
|
167
|
+
} from "../../../chunk-NDGA7ZE6.js";
|
|
168
168
|
import "../../../chunk-2ZRZTGWP.js";
|
|
169
169
|
import "../../../chunk-SUALMVL7.js";
|
|
170
|
-
import "../../../chunk-
|
|
171
|
-
import "../../../chunk-
|
|
172
|
-
import "../../../chunk-
|
|
170
|
+
import "../../../chunk-HHPJXK4Z.js";
|
|
171
|
+
import "../../../chunk-6DAIC2MG.js";
|
|
172
|
+
import "../../../chunk-HKGKQKQT.js";
|
|
173
173
|
import "../../../chunk-E2Y7G4MP.js";
|
|
174
174
|
import "../../../chunk-FFQ4NOJT.js";
|
|
175
175
|
import "../../../chunk-TERT6TIS.js";
|
|
@@ -346,7 +346,7 @@ import "../../chunk-YOKUDQIJ.js";
|
|
|
346
346
|
import "../../chunk-BN6POCYF.js";
|
|
347
347
|
import {
|
|
348
348
|
DateRangePicker
|
|
349
|
-
} from "../../chunk-
|
|
349
|
+
} from "../../chunk-MNZ6MCOK.js";
|
|
350
350
|
import {
|
|
351
351
|
DEFAULT_QUICK_RANGES,
|
|
352
352
|
DEFAULT_QUICK_RANGE_LABELS,
|
|
@@ -407,12 +407,12 @@ import "../../chunk-JXS56EW5.js";
|
|
|
407
407
|
import "../../chunk-BO6S47KI.js";
|
|
408
408
|
import {
|
|
409
409
|
Calendar
|
|
410
|
-
} from "../../chunk-
|
|
410
|
+
} from "../../chunk-NDGA7ZE6.js";
|
|
411
411
|
import "../../chunk-2ZRZTGWP.js";
|
|
412
412
|
import "../../chunk-SUALMVL7.js";
|
|
413
|
-
import "../../chunk-
|
|
414
|
-
import "../../chunk-
|
|
415
|
-
import "../../chunk-
|
|
413
|
+
import "../../chunk-HHPJXK4Z.js";
|
|
414
|
+
import "../../chunk-6DAIC2MG.js";
|
|
415
|
+
import "../../chunk-HKGKQKQT.js";
|
|
416
416
|
import "../../chunk-E2Y7G4MP.js";
|
|
417
417
|
import "../../chunk-FFQ4NOJT.js";
|
|
418
418
|
import "../../chunk-TERT6TIS.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CalendarDay
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HKGKQKQT.js";
|
|
4
4
|
import {
|
|
5
5
|
buildDayArgs
|
|
6
6
|
} from "./chunk-E2Y7G4MP.js";
|
|
@@ -40,4 +40,4 @@ var CalendarDayCell = ({
|
|
|
40
40
|
export {
|
|
41
41
|
CalendarDayCell
|
|
42
42
|
};
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-6DAIC2MG.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CalendarDayCell
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6DAIC2MG.js";
|
|
4
4
|
import {
|
|
5
5
|
getMonthName
|
|
6
6
|
} from "./chunk-TERT6TIS.js";
|
|
@@ -16,7 +16,8 @@ import IconButton from "@mui/material/IconButton/index.js";
|
|
|
16
16
|
import Typography from "@mui/material/Typography/index.js";
|
|
17
17
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
18
|
var SPACER_WIDTH = sxRem(32);
|
|
19
|
-
var GRID_SX = { display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: 0.5 };
|
|
19
|
+
var GRID_SX = { display: "grid", gridTemplateColumns: "repeat(7, minmax(0, 1fr))", gap: 0.5 };
|
|
20
|
+
var MONTH_SX = { flex: `1 1 ${sxRem(280)}`, minWidth: 0, maxWidth: sxRem(304) };
|
|
20
21
|
var MonthNavHeader = ({ title, showPrevious, showNext, onPreviousMonth, onNextMonth }) => /* @__PURE__ */ jsxs(
|
|
21
22
|
Box,
|
|
22
23
|
{
|
|
@@ -75,7 +76,7 @@ var CalendarMonth = ({
|
|
|
75
76
|
January's 5th and February's. Without a per-month hook a test can only
|
|
76
77
|
reach a day positionally, which is exactly what the flakiness gate
|
|
77
78
|
refuses. Additive: `calendar-grid` below is unchanged. */
|
|
78
|
-
/* @__PURE__ */ jsxs(Box, { sx:
|
|
79
|
+
/* @__PURE__ */ jsxs(Box, { sx: MONTH_SX, "data-testid": `calendar-month-${monthIndex}`, children: [
|
|
79
80
|
/* @__PURE__ */ jsx(
|
|
80
81
|
MonthNavHeader,
|
|
81
82
|
{
|
|
@@ -104,4 +105,4 @@ var CalendarMonth = ({
|
|
|
104
105
|
export {
|
|
105
106
|
CalendarMonth
|
|
106
107
|
};
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
108
|
+
//# sourceMappingURL=chunk-HHPJXK4Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/form/Calendar/CalendarMonth.tsx"],"sourcesContent":["import ChevronLeft from '@mui/icons-material/ChevronLeft';\nimport ChevronRight from '@mui/icons-material/ChevronRight';\nimport Box from '@mui/material/Box/index.js';\nimport IconButton from '@mui/material/IconButton/index.js';\nimport Typography from '@mui/material/Typography/index.js';\nimport type { FC } from 'react';\nimport React from 'react';\n\nimport { sxRem } from '../../../tokens/relative';\n\nimport { getMonthName } from './Calendar.dates';\nimport type { CalendarProps, MonthMatrix } from './Calendar.types';\nimport type { DayCellContext } from './CalendarDayCell';\nimport { CalendarDayCell } from './CalendarDayCell';\n\n/** The nav spacer's width and the weekday row's height, 32 design px through the type scale. */\nconst SPACER_WIDTH = sxRem(32);\n\n// `minmax(0, 1fr)`, not `1fr`: a bare `1fr` keeps each column at least its\n// content's width, which is what held the grid at 304px (FUT-3861).\nconst GRID_SX = { display: 'grid', gridTemplateColumns: 'repeat(7, minmax(0, 1fr))', gap: 0.5 } as const;\n\n/**\n * A month takes the room it is given, from nothing up to seven full cells and\n * their gaps (7 × 40 + 6 × 4 design px). Months side by side keep a 280 basis,\n * so a multi-month calendar still wraps rather than squeezing every month.\n */\nconst MONTH_SX = { flex: `1 1 ${sxRem(280)}`, minWidth: 0, maxWidth: sxRem(304) } as const;\n\n// Only the outermost months carry arrows; the ones between get a spacer so their\n// titles stay centred.\nconst MonthNavHeader: FC<{\n title: React.ReactNode;\n showPrevious: boolean;\n showNext: boolean;\n onPreviousMonth: () => void;\n onNextMonth: () => void;\n}> = ({ title, showPrevious, showNext, onPreviousMonth, onNextMonth }) => (\n <Box\n sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 2 }}\n data-testid=\"calendar-header\"\n >\n {showPrevious && (\n <IconButton onClick={onPreviousMonth} size=\"small\" data-testid=\"calendar-prev-month\">\n <ChevronLeft />\n </IconButton>\n )}\n\n <Typography\n variant=\"h6\"\n component=\"h2\"\n sx={{ fontWeight: 'bold', flex: 1, textAlign: 'center' }}\n >\n {title}\n </Typography>\n\n {showNext && (\n <IconButton onClick={onNextMonth} size=\"small\" data-testid=\"calendar-next-month\">\n <ChevronRight />\n </IconButton>\n )}\n\n {!showPrevious && !showNext && <Box sx={{ width: SPACER_WIDTH }} />}\n </Box>\n);\n\nconst WeekdayHeader: FC<{ weekdayNames: string[] }> = ({ weekdayNames }) => (\n <Box sx={{ ...GRID_SX, mb: 1 }}>\n {weekdayNames.map((weekday, index) => (\n <Box\n // Narrow weekday names repeat within a week ('S', 'T'), so position is\n // the only stable key here.\n key={`weekday-${index}`}\n role=\"columnheader\"\n data-testid={`calendar-weekday-${index}`}\n sx={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n height: SPACER_WIDTH,\n fontSize: sxRem(14),\n fontWeight: 'bold',\n color: 'text.secondary',\n }}\n >\n {weekday}\n </Box>\n ))}\n </Box>\n);\n\nexport interface CalendarMonthProps {\n matrix: MonthMatrix;\n monthIndex: number;\n monthsToShow: number;\n locale: string;\n weekdayNames: string[];\n renderHeader?: CalendarProps['renderHeader'];\n onPreviousMonth: () => void;\n onNextMonth: () => void;\n dayContext: DayCellContext;\n}\n\nexport const CalendarMonth: FC<CalendarMonthProps> = ({\n matrix,\n monthIndex,\n monthsToShow,\n locale,\n weekdayNames,\n renderHeader,\n onPreviousMonth,\n onNextMonth,\n dayContext,\n}) => {\n const monthName = getMonthName(matrix.month, matrix.year, locale);\n const title = renderHeader ? renderHeader({ month: matrix.month, year: matrix.year }) : monthName;\n\n return (\n /* The month is addressable by its position, because in a multi-month\n calendar every day number appears once PER MONTH — `calendar-date-5` is\n January's 5th and February's. Without a per-month hook a test can only\n reach a day positionally, which is exactly what the flakiness gate\n refuses. Additive: `calendar-grid` below is unchanged. */\n <Box sx={MONTH_SX} data-testid={`calendar-month-${monthIndex}`}>\n <MonthNavHeader\n title={title}\n showPrevious={monthIndex === 0}\n showNext={monthIndex === monthsToShow - 1}\n onPreviousMonth={onPreviousMonth}\n onNextMonth={onNextMonth}\n />\n\n <WeekdayHeader weekdayNames={weekdayNames} />\n\n <Box\n role=\"grid\"\n aria-labelledby={`month-${monthIndex}`}\n data-testid=\"calendar-grid\"\n sx={GRID_SX}\n >\n {matrix.weeks.flat().map((day) => (\n <CalendarDayCell key={day.key} day={day} {...dayContext} />\n ))}\n </Box>\n </Box>\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA,OAAO,iBAAiB;AACxB,OAAO,kBAAkB;AACzB,OAAO,SAAS;AAChB,OAAO,gBAAgB;AACvB,OAAO,gBAAgB;AAkCrB,SAMM,KANN;AAtBF,IAAM,eAAe,MAAM,EAAE;AAI7B,IAAM,UAAU,EAAE,SAAS,QAAQ,qBAAqB,6BAA6B,KAAK,IAAI;AAO9F,IAAM,WAAW,EAAE,MAAM,OAAO,MAAM,GAAG,CAAC,IAAI,UAAU,GAAG,UAAU,MAAM,GAAG,EAAE;AAIhF,IAAM,iBAMD,CAAC,EAAE,OAAO,cAAc,UAAU,iBAAiB,YAAY,MAClE;AAAA,EAAC;AAAA;AAAA,IACC,IAAI,EAAE,SAAS,QAAQ,YAAY,UAAU,gBAAgB,iBAAiB,IAAI,EAAE;AAAA,IACpF,eAAY;AAAA,IAEX;AAAA,sBACC,oBAAC,cAAW,SAAS,iBAAiB,MAAK,SAAQ,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AAe;AAAA,UAC7B,UAAU,eAAe,eAAe;AAAA,UACxC;AAAA,UACA;AAAA;AAAA,MACF;AAAA,MAEA,oBAAC,iBAAc,cAA4B;AAAA,MAE3C;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,mBAAiB,SAAS,UAAU;AAAA,UACpC,eAAY;AAAA,UACZ,IAAI;AAAA,UAEH,iBAAO,MAAM,KAAK,EAAE,IAAI,CAAC,QACxB,oBAAC,mBAA8B,KAAW,GAAG,cAAvB,IAAI,GAA+B,CAC1D;AAAA;AAAA,MACH;AAAA,OACF;AAAA;AAEJ;","names":[]}
|
|
@@ -43,8 +43,15 @@ var dayCellSx = (day, visible) => ({
|
|
|
43
43
|
display: "flex",
|
|
44
44
|
alignItems: "center",
|
|
45
45
|
justifyContent: "center",
|
|
46
|
+
// 40 is the size it ASKS for, so the month's intrinsic width stays 304 and a
|
|
47
|
+
// shrink-wrapping parent (the picker is inline-flex) still sizes to it; the
|
|
48
|
+
// column's `minmax(0, 1fr)` and this `maxWidth` let it give way below that.
|
|
46
49
|
width: CELL_SIZE,
|
|
47
|
-
|
|
50
|
+
maxWidth: "100%",
|
|
51
|
+
aspectRatio: "1 / 1",
|
|
52
|
+
justifySelf: "center",
|
|
53
|
+
boxSizing: "border-box",
|
|
54
|
+
padding: 0,
|
|
48
55
|
border: "none",
|
|
49
56
|
borderRadius: 1,
|
|
50
57
|
cursor: day.disabled ? "not-allowed" : "pointer",
|
|
@@ -99,4 +106,4 @@ var CalendarDay = ({
|
|
|
99
106
|
export {
|
|
100
107
|
CalendarDay
|
|
101
108
|
};
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
109
|
+
//# sourceMappingURL=chunk-HKGKQKQT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/form/Calendar/CalendarDay.tsx"],"sourcesContent":["import type { SxProps, Theme } from '@mui/material/styles/index.js';\nimport Box from '@mui/material/Box/index.js';\nimport type { FC } from 'react';\nimport React from 'react';\n\nimport { rem, sxRem } from '../../../tokens/relative';\n\nimport type { DayRenderArgs } from './Calendar.types';\n\n/**\n * A day cell's LARGEST edge, 40 design px through the theme's type scale. The\n * cell is a square that fills its grid column up to this size, so the month\n * shrinks with its container instead of holding a fixed 304px floor (FUT-3861).\n */\nconst CELL_SIZE = sxRem(40);\n\ninterface DayState extends DayRenderArgs {\n outside: boolean;\n focused: boolean;\n}\n\n// Order matters: these land on the element in the order listed.\nconst CLASS_FLAGS: Array<[keyof DayState, string]> = [\n ['selected', 'selected'],\n ['inRange', 'in-range'],\n ['rangeStart', 'range-start'],\n ['rangeEnd', 'range-end'],\n ['disabled', 'disabled'],\n ['today', 'today'],\n ['outside', 'outside'],\n ['hovered', 'hovered'],\n ['focused', 'focused'],\n];\n\nconst dayClassNames = (state: DayState, custom?: string): string =>\n [\n 'calendar-day',\n ...CLASS_FLAGS.filter(([flag]) => state[flag]).map(([, name]) => name),\n ...(custom ? [custom] : []),\n ].join(' ');\n\nconst isEndpoint = (day: DayRenderArgs): boolean =>\n day.selected || day.rangeStart || day.rangeEnd;\n\nconst backgroundFor = (day: DayRenderArgs): string => {\n if (isEndpoint(day)) return 'primary.main';\n if (day.inRange || day.hovered) return 'primary.light';\n return 'transparent';\n};\n\nconst colorFor = (day: DayRenderArgs, visible: boolean): string => {\n if (isEndpoint(day)) return 'primary.contrastText';\n if (day.disabled) return 'text.disabled';\n // Outside days that are switched off still occupy the grid, they just have\n // nothing to show.\n if (!visible) return 'transparent';\n return 'text.primary';\n};\n\nconst hoverBackgroundFor = (day: DayRenderArgs): string | undefined => {\n if (day.disabled) return undefined;\n return day.selected ? 'primary.dark' : 'action.hover';\n};\n\nconst dayCellSx = (day: DayRenderArgs, visible: boolean): SxProps<Theme> => ({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n // 40 is the size it ASKS for, so the month's intrinsic width stays 304 and a\n // shrink-wrapping parent (the picker is inline-flex) still sizes to it; the\n // column's `minmax(0, 1fr)` and this `maxWidth` let it give way below that.\n width: CELL_SIZE,\n maxWidth: '100%',\n aspectRatio: '1 / 1',\n justifySelf: 'center',\n boxSizing: 'border-box',\n padding: 0,\n border: 'none',\n borderRadius: 1,\n cursor: day.disabled ? 'not-allowed' : 'pointer',\n backgroundColor: backgroundFor(day),\n color: colorFor(day, visible),\n opacity: !day.inCurrentMonth && visible ? 0.5 : 1,\n fontWeight: day.today ? 'bold' : 'normal',\n '&:hover': {\n backgroundColor: hoverBackgroundFor(day),\n },\n '&:focus': {\n outline: (theme: Theme) => `${rem(theme, 2)} solid`,\n outlineColor: 'primary.main',\n outlineOffset: sxRem(1),\n },\n});\n\nexport interface CalendarDayProps {\n day: DayRenderArgs;\n focused: boolean;\n showOutsideDays: boolean;\n dayClassName?: (args: DayRenderArgs) => string;\n onSelect: (date: Date) => void;\n onHover: (date: Date) => void;\n onHoverEnd: () => void;\n}\n\nexport const CalendarDay: FC<CalendarDayProps> = ({\n day,\n focused,\n showOutsideDays,\n dayClassName,\n onSelect,\n onHover,\n onHoverEnd,\n}) => {\n const visible = day.inCurrentMonth || showOutsideDays;\n const state: DayState = { ...day, outside: !day.inCurrentMonth, focused };\n\n return (\n <Box\n component=\"button\"\n role=\"gridcell\"\n tabIndex={focused ? 0 : -1}\n aria-selected={day.selected}\n aria-disabled={day.disabled}\n aria-current={day.today ? 'date' : undefined}\n className={dayClassNames(state, dayClassName?.(day))}\n data-testid={`calendar-date-${day.date.getDate()}`}\n onClick={() => onSelect(day.date)}\n onMouseEnter={() => onHover(day.date)}\n onMouseLeave={onHoverEnd}\n sx={dayCellSx(day, visible)}\n >\n {day.selected && (\n <Box component=\"span\" data-testid=\"calendar-selected-date\" sx={{ display: 'none' }} />\n )}\n {day.today && (\n <Box component=\"span\" data-testid=\"calendar-today\" sx={{ display: 'none' }} />\n )}\n {visible ? day.date.getDate() : ''}\n </Box>\n );\n};\n"],"mappings":";;;;;;AACA,OAAO,SAAS;AAoHZ,SAeI,KAfJ;AAvG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AiB,IAAI,EAAE,SAAS,OAAO,GAAG;AAAA,QAE7E,UAAU,IAAI,KAAK,QAAQ,IAAI;AAAA;AAAA;AAAA,EAClC;AAEJ;","names":[]}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-FRAVVI4A.js";
|
|
16
16
|
import {
|
|
17
17
|
Calendar
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-NDGA7ZE6.js";
|
|
19
19
|
|
|
20
20
|
// src/components/form/DateRangePicker/DateRangePicker.tsx
|
|
21
21
|
import Box from "@mui/material/Box/index.js";
|
|
@@ -181,4 +181,4 @@ export {
|
|
|
181
181
|
DateRangePicker,
|
|
182
182
|
DateRangePicker_default
|
|
183
183
|
};
|
|
184
|
-
//# sourceMappingURL=chunk-
|
|
184
|
+
//# sourceMappingURL=chunk-MNZ6MCOK.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-SUALMVL7.js";
|
|
7
7
|
import {
|
|
8
8
|
CalendarMonth
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HHPJXK4Z.js";
|
|
10
10
|
import {
|
|
11
11
|
rem,
|
|
12
12
|
sxRem
|
|
@@ -87,4 +87,4 @@ export {
|
|
|
87
87
|
Calendar,
|
|
88
88
|
Calendar_default
|
|
89
89
|
};
|
|
90
|
-
//# sourceMappingURL=chunk-
|
|
90
|
+
//# sourceMappingURL=chunk-NDGA7ZE6.js.map
|
package/dist/form/Calendar.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "../chunk-BO6S47KI.js";
|
|
2
2
|
import {
|
|
3
3
|
Calendar
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-NDGA7ZE6.js";
|
|
5
5
|
import "../chunk-2ZRZTGWP.js";
|
|
6
6
|
import "../chunk-SUALMVL7.js";
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-HHPJXK4Z.js";
|
|
8
|
+
import "../chunk-6DAIC2MG.js";
|
|
9
|
+
import "../chunk-HKGKQKQT.js";
|
|
10
10
|
import "../chunk-E2Y7G4MP.js";
|
|
11
11
|
import "../chunk-FFQ4NOJT.js";
|
|
12
12
|
import "../chunk-TERT6TIS.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../chunk-BN6POCYF.js";
|
|
2
2
|
import {
|
|
3
3
|
DateRangePicker
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-MNZ6MCOK.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_QUICK_RANGES,
|
|
7
7
|
DEFAULT_QUICK_RANGE_LABELS,
|
|
@@ -16,12 +16,12 @@ import {
|
|
|
16
16
|
} from "../chunk-NTO5DALI.js";
|
|
17
17
|
import "../chunk-FRAVVI4A.js";
|
|
18
18
|
import "../chunk-BO6S47KI.js";
|
|
19
|
-
import "../chunk-
|
|
19
|
+
import "../chunk-NDGA7ZE6.js";
|
|
20
20
|
import "../chunk-2ZRZTGWP.js";
|
|
21
21
|
import "../chunk-SUALMVL7.js";
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
22
|
+
import "../chunk-HHPJXK4Z.js";
|
|
23
|
+
import "../chunk-6DAIC2MG.js";
|
|
24
|
+
import "../chunk-HKGKQKQT.js";
|
|
25
25
|
import "../chunk-E2Y7G4MP.js";
|
|
26
26
|
import "../chunk-FFQ4NOJT.js";
|
|
27
27
|
import "../chunk-TERT6TIS.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarDay.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/Calendar/CalendarDay.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"CalendarDay.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/Calendar/CalendarDay.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAuFtD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,aAAa,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,MAAM,CAAC;IAC/C,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAoC5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarMonth.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/Calendar/CalendarMonth.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAMhC,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"CalendarMonth.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/Calendar/CalendarMonth.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAMhC,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA+ExD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC7C,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA2ChD,CAAC"}
|
package/package.json
CHANGED
|
@@ -116,6 +116,13 @@ export interface CalendarProps {
|
|
|
116
116
|
- Enforce `minRangeLength`/`maxRangeLength`. If invalid, ignore or snap (configurable via your handler).
|
|
117
117
|
- Fire `onIntermediateRangeChange` as user hovers. Fire `onRangeChange` once both ends are chosen.
|
|
118
118
|
|
|
119
|
+
### Width
|
|
120
|
+
|
|
121
|
+
- The day grid is fluid: seven `minmax(0, 1fr)` columns, each day a square that fills its column up to 40 design px.
|
|
122
|
+
- A month takes the room it is given, up to 304 design px (7 × 40 + 6 × 4). Side by side, months wrap rather than squeeze, at the same width as before.
|
|
123
|
+
- A custom `renderDay` element is the grid item, so it is held to its column: keep it within 40 design px or it overlaps the next day.
|
|
124
|
+
- So a one-month calendar fits a 320 bottom sheet and a 390 `Dialog` with no consumer CSS (FUT-3861). Pinned by the `FitsA320Sheet` and `FitsA390Dialog` stories in `DateRangePicker.test.stories.tsx`.
|
|
125
|
+
|
|
119
126
|
### Navigation
|
|
120
127
|
|
|
121
128
|
- Header buttons move month (or year with modifier keys if desired).
|
|
@@ -7,7 +7,11 @@ import { rem, sxRem } from '../../../tokens/relative';
|
|
|
7
7
|
|
|
8
8
|
import type { DayRenderArgs } from './Calendar.types';
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* A day cell's LARGEST edge, 40 design px through the theme's type scale. The
|
|
12
|
+
* cell is a square that fills its grid column up to this size, so the month
|
|
13
|
+
* shrinks with its container instead of holding a fixed 304px floor (FUT-3861).
|
|
14
|
+
*/
|
|
11
15
|
const CELL_SIZE = sxRem(40);
|
|
12
16
|
|
|
13
17
|
interface DayState extends DayRenderArgs {
|
|
@@ -62,8 +66,15 @@ const dayCellSx = (day: DayRenderArgs, visible: boolean): SxProps<Theme> => ({
|
|
|
62
66
|
display: 'flex',
|
|
63
67
|
alignItems: 'center',
|
|
64
68
|
justifyContent: 'center',
|
|
69
|
+
// 40 is the size it ASKS for, so the month's intrinsic width stays 304 and a
|
|
70
|
+
// shrink-wrapping parent (the picker is inline-flex) still sizes to it; the
|
|
71
|
+
// column's `minmax(0, 1fr)` and this `maxWidth` let it give way below that.
|
|
65
72
|
width: CELL_SIZE,
|
|
66
|
-
|
|
73
|
+
maxWidth: '100%',
|
|
74
|
+
aspectRatio: '1 / 1',
|
|
75
|
+
justifySelf: 'center',
|
|
76
|
+
boxSizing: 'border-box',
|
|
77
|
+
padding: 0,
|
|
67
78
|
border: 'none',
|
|
68
79
|
borderRadius: 1,
|
|
69
80
|
cursor: day.disabled ? 'not-allowed' : 'pointer',
|
|
@@ -16,7 +16,16 @@ import { CalendarDayCell } from './CalendarDayCell';
|
|
|
16
16
|
/** The nav spacer's width and the weekday row's height, 32 design px through the type scale. */
|
|
17
17
|
const SPACER_WIDTH = sxRem(32);
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// `minmax(0, 1fr)`, not `1fr`: a bare `1fr` keeps each column at least its
|
|
20
|
+
// content's width, which is what held the grid at 304px (FUT-3861).
|
|
21
|
+
const GRID_SX = { display: 'grid', gridTemplateColumns: 'repeat(7, minmax(0, 1fr))', gap: 0.5 } as const;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A month takes the room it is given, from nothing up to seven full cells and
|
|
25
|
+
* their gaps (7 × 40 + 6 × 4 design px). Months side by side keep a 280 basis,
|
|
26
|
+
* so a multi-month calendar still wraps rather than squeezing every month.
|
|
27
|
+
*/
|
|
28
|
+
const MONTH_SX = { flex: `1 1 ${sxRem(280)}`, minWidth: 0, maxWidth: sxRem(304) } as const;
|
|
20
29
|
|
|
21
30
|
// Only the outermost months carry arrows; the ones between get a spacer so their
|
|
22
31
|
// titles stay centred.
|
|
@@ -112,7 +121,7 @@ export const CalendarMonth: FC<CalendarMonthProps> = ({
|
|
|
112
121
|
January's 5th and February's. Without a per-month hook a test can only
|
|
113
122
|
reach a day positionally, which is exactly what the flakiness gate
|
|
114
123
|
refuses. Additive: `calendar-grid` below is unchanged. */
|
|
115
|
-
<Box sx={
|
|
124
|
+
<Box sx={MONTH_SX} data-testid={`calendar-month-${monthIndex}`}>
|
|
116
125
|
<MonthNavHeader
|
|
117
126
|
title={title}
|
|
118
127
|
showPrevious={monthIndex === 0}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/form/Calendar/CalendarMonth.tsx"],"sourcesContent":["import ChevronLeft from '@mui/icons-material/ChevronLeft';\nimport ChevronRight from '@mui/icons-material/ChevronRight';\nimport Box from '@mui/material/Box/index.js';\nimport IconButton from '@mui/material/IconButton/index.js';\nimport Typography from '@mui/material/Typography/index.js';\nimport type { FC } from 'react';\nimport React from 'react';\n\nimport { sxRem } from '../../../tokens/relative';\n\nimport { getMonthName } from './Calendar.dates';\nimport type { CalendarProps, MonthMatrix } from './Calendar.types';\nimport type { DayCellContext } from './CalendarDayCell';\nimport { CalendarDayCell } from './CalendarDayCell';\n\n/** The nav spacer's width and the weekday row's height, 32 design px through the type scale. */\nconst SPACER_WIDTH = sxRem(32);\n\nconst GRID_SX = { display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: 0.5 } as const;\n\n// Only the outermost months carry arrows; the ones between get a spacer so their\n// titles stay centred.\nconst MonthNavHeader: FC<{\n title: React.ReactNode;\n showPrevious: boolean;\n showNext: boolean;\n onPreviousMonth: () => void;\n onNextMonth: () => void;\n}> = ({ title, showPrevious, showNext, onPreviousMonth, onNextMonth }) => (\n <Box\n sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 2 }}\n data-testid=\"calendar-header\"\n >\n {showPrevious && (\n <IconButton onClick={onPreviousMonth} size=\"small\" data-testid=\"calendar-prev-month\">\n <ChevronLeft />\n </IconButton>\n )}\n\n <Typography\n variant=\"h6\"\n component=\"h2\"\n sx={{ fontWeight: 'bold', flex: 1, textAlign: 'center' }}\n >\n {title}\n </Typography>\n\n {showNext && (\n <IconButton onClick={onNextMonth} size=\"small\" data-testid=\"calendar-next-month\">\n <ChevronRight />\n </IconButton>\n )}\n\n {!showPrevious && !showNext && <Box sx={{ width: SPACER_WIDTH }} />}\n </Box>\n);\n\nconst WeekdayHeader: FC<{ weekdayNames: string[] }> = ({ weekdayNames }) => (\n <Box sx={{ ...GRID_SX, mb: 1 }}>\n {weekdayNames.map((weekday, index) => (\n <Box\n // Narrow weekday names repeat within a week ('S', 'T'), so position is\n // the only stable key here.\n key={`weekday-${index}`}\n role=\"columnheader\"\n data-testid={`calendar-weekday-${index}`}\n sx={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n height: SPACER_WIDTH,\n fontSize: sxRem(14),\n fontWeight: 'bold',\n color: 'text.secondary',\n }}\n >\n {weekday}\n </Box>\n ))}\n </Box>\n);\n\nexport interface CalendarMonthProps {\n matrix: MonthMatrix;\n monthIndex: number;\n monthsToShow: number;\n locale: string;\n weekdayNames: string[];\n renderHeader?: CalendarProps['renderHeader'];\n onPreviousMonth: () => void;\n onNextMonth: () => void;\n dayContext: DayCellContext;\n}\n\nexport const CalendarMonth: FC<CalendarMonthProps> = ({\n matrix,\n monthIndex,\n monthsToShow,\n locale,\n weekdayNames,\n renderHeader,\n onPreviousMonth,\n onNextMonth,\n dayContext,\n}) => {\n const monthName = getMonthName(matrix.month, matrix.year, locale);\n const title = renderHeader ? renderHeader({ month: matrix.month, year: matrix.year }) : monthName;\n\n return (\n /* The month is addressable by its position, because in a multi-month\n calendar every day number appears once PER MONTH — `calendar-date-5` is\n January's 5th and February's. Without a per-month hook a test can only\n reach a day positionally, which is exactly what the flakiness gate\n refuses. Additive: `calendar-grid` below is unchanged. */\n <Box sx={{ minWidth: sxRem(280) }} data-testid={`calendar-month-${monthIndex}`}>\n <MonthNavHeader\n title={title}\n showPrevious={monthIndex === 0}\n showNext={monthIndex === monthsToShow - 1}\n onPreviousMonth={onPreviousMonth}\n onNextMonth={onNextMonth}\n />\n\n <WeekdayHeader weekdayNames={weekdayNames} />\n\n <Box\n role=\"grid\"\n aria-labelledby={`month-${monthIndex}`}\n data-testid=\"calendar-grid\"\n sx={GRID_SX}\n >\n {matrix.weeks.flat().map((day) => (\n <CalendarDayCell key={day.key} day={day} {...dayContext} />\n ))}\n </Box>\n </Box>\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA,OAAO,iBAAiB;AACxB,OAAO,kBAAkB;AACzB,OAAO,SAAS;AAChB,OAAO,gBAAgB;AACvB,OAAO,gBAAgB;AAyBrB,SAMM,KANN;AAbF,IAAM,eAAe,MAAM,EAAE;AAE7B,IAAM,UAAU,EAAE,SAAS,QAAQ,qBAAqB,kBAAkB,KAAK,IAAI;AAInF,IAAM,iBAMD,CAAC,EAAE,OAAO,cAAc,UAAU,iBAAiB,YAAY,MAClE;AAAA,EAAC;AAAA;AAAA,IACC,IAAI,EAAE,SAAS,QAAQ,YAAY,UAAU,gBAAgB,iBAAiB,IAAI,EAAE;AAAA,IACpF,eAAY;AAAA,IAEX;AAAA,sBACC,oBAAC,cAAW,SAAS,iBAAiB,MAAK,SAAQ,eAAY,uBAC7D,8BAAC,eAAY,GACf;AAAA,MAGF;AAAA,QAAC;AAAA;AAAA,UACC,SAAQ;AAAA,UACR,WAAU;AAAA,UACV,IAAI,EAAE,YAAY,QAAQ,MAAM,GAAG,WAAW,SAAS;AAAA,UAEtD;AAAA;AAAA,MACH;AAAA,MAEC,YACC,oBAAC,cA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AAU;AAAA,UACpC,eAAY;AAAA,UACZ,IAAI;AAAA,UAEH,iBAAO,MAAM,KAAK,EAAE,IAAI,CAAC,QACxB,oBAAC,mBAA8B,KAAW,GAAG,cAAvB,IAAI,GAA+B,CAC1D;AAAA;AAAA,MACH;AAAA,OACF;AAAA;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/form/Calendar/CalendarDay.tsx"],"sourcesContent":["import type { SxProps, Theme } from '@mui/material/styles/index.js';\nimport Box from '@mui/material/Box/index.js';\nimport type { FC } from 'react';\nimport React from 'react';\n\nimport { rem, sxRem } from '../../../tokens/relative';\n\nimport type { DayRenderArgs } from './Calendar.types';\n\n/** A day cell's edge, 40 design px through the theme's type scale. */\nconst CELL_SIZE = sxRem(40);\n\ninterface DayState extends DayRenderArgs {\n outside: boolean;\n focused: boolean;\n}\n\n// Order matters: these land on the element in the order listed.\nconst CLASS_FLAGS: Array<[keyof DayState, string]> = [\n ['selected', 'selected'],\n ['inRange', 'in-range'],\n ['rangeStart', 'range-start'],\n ['rangeEnd', 'range-end'],\n ['disabled', 'disabled'],\n ['today', 'today'],\n ['outside', 'outside'],\n ['hovered', 'hovered'],\n ['focused', 'focused'],\n];\n\nconst dayClassNames = (state: DayState, custom?: string): string =>\n [\n 'calendar-day',\n ...CLASS_FLAGS.filter(([flag]) => state[flag]).map(([, name]) => name),\n ...(custom ? [custom] : []),\n ].join(' ');\n\nconst isEndpoint = (day: DayRenderArgs): boolean =>\n day.selected || day.rangeStart || day.rangeEnd;\n\nconst backgroundFor = (day: DayRenderArgs): string => {\n if (isEndpoint(day)) return 'primary.main';\n if (day.inRange || day.hovered) return 'primary.light';\n return 'transparent';\n};\n\nconst colorFor = (day: DayRenderArgs, visible: boolean): string => {\n if (isEndpoint(day)) return 'primary.contrastText';\n if (day.disabled) return 'text.disabled';\n // Outside days that are switched off still occupy the grid, they just have\n // nothing to show.\n if (!visible) return 'transparent';\n return 'text.primary';\n};\n\nconst hoverBackgroundFor = (day: DayRenderArgs): string | undefined => {\n if (day.disabled) return undefined;\n return day.selected ? 'primary.dark' : 'action.hover';\n};\n\nconst dayCellSx = (day: DayRenderArgs, visible: boolean): SxProps<Theme> => ({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: CELL_SIZE,\n height: CELL_SIZE,\n border: 'none',\n borderRadius: 1,\n cursor: day.disabled ? 'not-allowed' : 'pointer',\n backgroundColor: backgroundFor(day),\n color: colorFor(day, visible),\n opacity: !day.inCurrentMonth && visible ? 0.5 : 1,\n fontWeight: day.today ? 'bold' : 'normal',\n '&:hover': {\n backgroundColor: hoverBackgroundFor(day),\n },\n '&:focus': {\n outline: (theme: Theme) => `${rem(theme, 2)} solid`,\n outlineColor: 'primary.main',\n outlineOffset: sxRem(1),\n },\n});\n\nexport interface CalendarDayProps {\n day: DayRenderArgs;\n focused: boolean;\n showOutsideDays: boolean;\n dayClassName?: (args: DayRenderArgs) => string;\n onSelect: (date: Date) => void;\n onHover: (date: Date) => void;\n onHoverEnd: () => void;\n}\n\nexport const CalendarDay: FC<CalendarDayProps> = ({\n day,\n focused,\n showOutsideDays,\n dayClassName,\n onSelect,\n onHover,\n onHoverEnd,\n}) => {\n const visible = day.inCurrentMonth || showOutsideDays;\n const state: DayState = { ...day, outside: !day.inCurrentMonth, focused };\n\n return (\n <Box\n component=\"button\"\n role=\"gridcell\"\n tabIndex={focused ? 0 : -1}\n aria-selected={day.selected}\n aria-disabled={day.disabled}\n aria-current={day.today ? 'date' : undefined}\n className={dayClassNames(state, dayClassName?.(day))}\n data-testid={`calendar-date-${day.date.getDate()}`}\n onClick={() => onSelect(day.date)}\n onMouseEnter={() => onHover(day.date)}\n onMouseLeave={onHoverEnd}\n sx={dayCellSx(day, visible)}\n >\n {day.selected && (\n <Box component=\"span\" data-testid=\"calendar-selected-date\" sx={{ display: 'none' }} />\n )}\n {day.today && (\n <Box component=\"span\" data-testid=\"calendar-today\" sx={{ display: 'none' }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