@knitui/dates 0.5.0 → 0.6.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.
Files changed (161) hide show
  1. package/lib/commonjs/DatesProvider/DatesProvider.js +33 -4
  2. package/lib/commonjs/DatesProvider/DatesProvider.js.map +1 -1
  3. package/lib/commonjs/Day/Day.js +45 -7
  4. package/lib/commonjs/Day/Day.js.map +1 -1
  5. package/lib/commonjs/Month/Month.js +266 -80
  6. package/lib/commonjs/Month/Month.js.map +1 -1
  7. package/lib/commonjs/MonthLevel/MonthLevel.js +19 -3
  8. package/lib/commonjs/MonthLevel/MonthLevel.js.map +1 -1
  9. package/lib/commonjs/MonthsList/MonthsList.js +160 -60
  10. package/lib/commonjs/MonthsList/MonthsList.js.map +1 -1
  11. package/lib/commonjs/MonthsList/get-month-in-tab-order/get-month-in-tab-order.js +7 -1
  12. package/lib/commonjs/MonthsList/get-month-in-tab-order/get-month-in-tab-order.js.map +1 -1
  13. package/lib/commonjs/TimeControlsList/TimeControl.js +15 -1
  14. package/lib/commonjs/TimeControlsList/TimeControl.js.map +1 -1
  15. package/lib/commonjs/TimeControlsList/TimeControlsList.js +16 -3
  16. package/lib/commonjs/TimeControlsList/TimeControlsList.js.map +1 -1
  17. package/lib/commonjs/WeekdaysRow/WeekdaysRow.js +23 -4
  18. package/lib/commonjs/WeekdaysRow/WeekdaysRow.js.map +1 -1
  19. package/lib/commonjs/YearsList/YearsList.js +155 -60
  20. package/lib/commonjs/YearsList/YearsList.js.map +1 -1
  21. package/lib/commonjs/YearsList/get-year-in-tab-order/get-year-in-tab-order.js +7 -1
  22. package/lib/commonjs/YearsList/get-year-in-tab-order/get-year-in-tab-order.js.map +1 -1
  23. package/lib/commonjs/hooks/use-dates-state/is-in-range/is-in-range.js +20 -0
  24. package/lib/commonjs/hooks/use-dates-state/is-in-range/is-in-range.js.map +1 -1
  25. package/lib/commonjs/hooks/use-dates-state/use-dates-state.js +25 -7
  26. package/lib/commonjs/hooks/use-dates-state/use-dates-state.js.map +1 -1
  27. package/lib/commonjs/internal/are-cell-props-equal.js +64 -0
  28. package/lib/commonjs/internal/are-cell-props-equal.js.map +1 -0
  29. package/lib/commonjs/internal/date-string-fast-path.js +98 -0
  30. package/lib/commonjs/internal/date-string-fast-path.js.map +1 -0
  31. package/lib/commonjs/internal/memoize-control-props.js +54 -0
  32. package/lib/commonjs/internal/memoize-control-props.js.map +1 -0
  33. package/lib/commonjs/internal/month-days-cache.js +71 -0
  34. package/lib/commonjs/internal/month-days-cache.js.map +1 -0
  35. package/lib/commonjs/utils/get-date-in-tab-order/get-date-in-tab-order.js +9 -1
  36. package/lib/commonjs/utils/get-date-in-tab-order/get-date-in-tab-order.js.map +1 -1
  37. package/lib/commonjs/utils/is-after-min-date/is-after-min-date.js +14 -1
  38. package/lib/commonjs/utils/is-after-min-date/is-after-min-date.js.map +1 -1
  39. package/lib/commonjs/utils/is-before-max-date/is-before-max-date.js +14 -1
  40. package/lib/commonjs/utils/is-before-max-date/is-before-max-date.js.map +1 -1
  41. package/lib/commonjs/utils/is-same-month/is-same-month.js +17 -1
  42. package/lib/commonjs/utils/is-same-month/is-same-month.js.map +1 -1
  43. package/lib/module/DatesProvider/DatesProvider.js +34 -5
  44. package/lib/module/DatesProvider/DatesProvider.js.map +1 -1
  45. package/lib/module/Day/Day.js +46 -8
  46. package/lib/module/Day/Day.js.map +1 -1
  47. package/lib/module/Month/Month.js +267 -82
  48. package/lib/module/Month/Month.js.map +1 -1
  49. package/lib/module/MonthLevel/MonthLevel.js +19 -3
  50. package/lib/module/MonthLevel/MonthLevel.js.map +1 -1
  51. package/lib/module/MonthsList/MonthsList.js +159 -60
  52. package/lib/module/MonthsList/MonthsList.js.map +1 -1
  53. package/lib/module/MonthsList/get-month-in-tab-order/get-month-in-tab-order.js +7 -1
  54. package/lib/module/MonthsList/get-month-in-tab-order/get-month-in-tab-order.js.map +1 -1
  55. package/lib/module/TimeControlsList/TimeControl.js +15 -1
  56. package/lib/module/TimeControlsList/TimeControl.js.map +1 -1
  57. package/lib/module/TimeControlsList/TimeControlsList.js +16 -3
  58. package/lib/module/TimeControlsList/TimeControlsList.js.map +1 -1
  59. package/lib/module/WeekdaysRow/WeekdaysRow.js +23 -4
  60. package/lib/module/WeekdaysRow/WeekdaysRow.js.map +1 -1
  61. package/lib/module/YearsList/YearsList.js +154 -60
  62. package/lib/module/YearsList/YearsList.js.map +1 -1
  63. package/lib/module/YearsList/get-year-in-tab-order/get-year-in-tab-order.js +7 -1
  64. package/lib/module/YearsList/get-year-in-tab-order/get-year-in-tab-order.js.map +1 -1
  65. package/lib/module/hooks/use-dates-state/is-in-range/is-in-range.js +20 -0
  66. package/lib/module/hooks/use-dates-state/is-in-range/is-in-range.js.map +1 -1
  67. package/lib/module/hooks/use-dates-state/use-dates-state.js +25 -7
  68. package/lib/module/hooks/use-dates-state/use-dates-state.js.map +1 -1
  69. package/lib/module/internal/are-cell-props-equal.js +60 -0
  70. package/lib/module/internal/are-cell-props-equal.js.map +1 -0
  71. package/lib/module/internal/date-string-fast-path.js +91 -0
  72. package/lib/module/internal/date-string-fast-path.js.map +1 -0
  73. package/lib/module/internal/memoize-control-props.js +50 -0
  74. package/lib/module/internal/memoize-control-props.js.map +1 -0
  75. package/lib/module/internal/month-days-cache.js +68 -0
  76. package/lib/module/internal/month-days-cache.js.map +1 -0
  77. package/lib/module/utils/get-date-in-tab-order/get-date-in-tab-order.js +9 -1
  78. package/lib/module/utils/get-date-in-tab-order/get-date-in-tab-order.js.map +1 -1
  79. package/lib/module/utils/is-after-min-date/is-after-min-date.js +14 -1
  80. package/lib/module/utils/is-after-min-date/is-after-min-date.js.map +1 -1
  81. package/lib/module/utils/is-before-max-date/is-before-max-date.js +14 -1
  82. package/lib/module/utils/is-before-max-date/is-before-max-date.js.map +1 -1
  83. package/lib/module/utils/is-same-month/is-same-month.js +17 -1
  84. package/lib/module/utils/is-same-month/is-same-month.js.map +1 -1
  85. package/lib/typescript/Calendar/pick-calendar-props/pick-calendar-props.d.ts +1 -1
  86. package/lib/typescript/CalendarHeader/CalendarHeader.d.ts +14 -14
  87. package/lib/typescript/DatesProvider/DatesProvider.d.ts.map +1 -1
  88. package/lib/typescript/Day/Day.d.ts +31 -31
  89. package/lib/typescript/Day/Day.d.ts.map +1 -1
  90. package/lib/typescript/DecadeLevel/DecadeLevel.d.ts +7 -7
  91. package/lib/typescript/DecadeLevelGroup/DecadeLevelGroup.d.ts +7 -7
  92. package/lib/typescript/InlineDateTimePicker/InlineDateTimePicker.d.ts +4 -4
  93. package/lib/typescript/MiniCalendar/MiniCalendar.d.ts +18 -18
  94. package/lib/typescript/Month/Month.d.ts +9 -8
  95. package/lib/typescript/Month/Month.d.ts.map +1 -1
  96. package/lib/typescript/MonthLevel/MonthLevel.d.ts +10 -10
  97. package/lib/typescript/MonthLevel/MonthLevel.d.ts.map +1 -1
  98. package/lib/typescript/MonthLevelGroup/MonthLevelGroup.d.ts +10 -10
  99. package/lib/typescript/MonthsList/MonthsList.d.ts +3 -2
  100. package/lib/typescript/MonthsList/MonthsList.d.ts.map +1 -1
  101. package/lib/typescript/MonthsList/get-month-in-tab-order/get-month-in-tab-order.d.ts +6 -0
  102. package/lib/typescript/MonthsList/get-month-in-tab-order/get-month-in-tab-order.d.ts.map +1 -1
  103. package/lib/typescript/PickerControl/PickerControl.d.ts +10 -10
  104. package/lib/typescript/TimeControlsList/TimeControl.d.ts +13 -0
  105. package/lib/typescript/TimeControlsList/TimeControl.d.ts.map +1 -1
  106. package/lib/typescript/TimeControlsList/TimeControlsList.d.ts.map +1 -1
  107. package/lib/typescript/TimeGrid/TimeGrid.d.ts +7 -7
  108. package/lib/typescript/TimePicker/TimePicker.d.ts +4 -4
  109. package/lib/typescript/TimePresets/TimePresetGroup.d.ts +4 -4
  110. package/lib/typescript/TimePresets/TimePresets.d.ts +6 -4
  111. package/lib/typescript/TimePresets/TimePresets.d.ts.map +1 -1
  112. package/lib/typescript/WeekdaysRow/WeekdaysRow.d.ts +6 -6
  113. package/lib/typescript/WeekdaysRow/WeekdaysRow.d.ts.map +1 -1
  114. package/lib/typescript/YearLevel/YearLevel.d.ts +7 -7
  115. package/lib/typescript/YearLevelGroup/YearLevelGroup.d.ts +7 -7
  116. package/lib/typescript/YearsList/YearsList.d.ts +3 -2
  117. package/lib/typescript/YearsList/YearsList.d.ts.map +1 -1
  118. package/lib/typescript/YearsList/get-year-in-tab-order/get-year-in-tab-order.d.ts +6 -0
  119. package/lib/typescript/YearsList/get-year-in-tab-order/get-year-in-tab-order.d.ts.map +1 -1
  120. package/lib/typescript/_reference/ExampleControl.d.ts +8 -8
  121. package/lib/typescript/hooks/use-dates-state/is-in-range/is-in-range.d.ts +12 -0
  122. package/lib/typescript/hooks/use-dates-state/is-in-range/is-in-range.d.ts.map +1 -1
  123. package/lib/typescript/hooks/use-dates-state/use-dates-state.d.ts.map +1 -1
  124. package/lib/typescript/internal/are-cell-props-equal.d.ts +21 -0
  125. package/lib/typescript/internal/are-cell-props-equal.d.ts.map +1 -0
  126. package/lib/typescript/internal/date-string-fast-path.d.ts +35 -0
  127. package/lib/typescript/internal/date-string-fast-path.d.ts.map +1 -0
  128. package/lib/typescript/internal/memoize-control-props.d.ts +12 -0
  129. package/lib/typescript/internal/memoize-control-props.d.ts.map +1 -0
  130. package/lib/typescript/internal/month-days-cache.d.ts +19 -0
  131. package/lib/typescript/internal/month-days-cache.d.ts.map +1 -0
  132. package/lib/typescript/utils/get-date-in-tab-order/get-date-in-tab-order.d.ts +9 -1
  133. package/lib/typescript/utils/get-date-in-tab-order/get-date-in-tab-order.d.ts.map +1 -1
  134. package/lib/typescript/utils/is-after-min-date/is-after-min-date.d.ts +6 -0
  135. package/lib/typescript/utils/is-after-min-date/is-after-min-date.d.ts.map +1 -1
  136. package/lib/typescript/utils/is-before-max-date/is-before-max-date.d.ts +6 -0
  137. package/lib/typescript/utils/is-before-max-date/is-before-max-date.d.ts.map +1 -1
  138. package/lib/typescript/utils/is-same-month/is-same-month.d.ts +13 -1
  139. package/lib/typescript/utils/is-same-month/is-same-month.d.ts.map +1 -1
  140. package/package.json +6 -6
  141. package/src/DatesProvider/DatesProvider.tsx +27 -5
  142. package/src/Day/Day.tsx +51 -10
  143. package/src/Month/Month.tsx +357 -80
  144. package/src/MonthLevel/MonthLevel.tsx +35 -16
  145. package/src/MonthsList/MonthsList.tsx +201 -55
  146. package/src/MonthsList/get-month-in-tab-order/get-month-in-tab-order.ts +12 -1
  147. package/src/TimeControlsList/TimeControl.tsx +16 -1
  148. package/src/TimeControlsList/TimeControlsList.tsx +15 -3
  149. package/src/WeekdaysRow/WeekdaysRow.tsx +29 -5
  150. package/src/YearsList/YearsList.tsx +196 -55
  151. package/src/YearsList/get-year-in-tab-order/get-year-in-tab-order.ts +12 -1
  152. package/src/hooks/use-dates-state/is-in-range/is-in-range.ts +22 -0
  153. package/src/hooks/use-dates-state/use-dates-state.ts +27 -11
  154. package/src/internal/are-cell-props-equal.ts +63 -0
  155. package/src/internal/date-string-fast-path.ts +94 -0
  156. package/src/internal/memoize-control-props.ts +54 -0
  157. package/src/internal/month-days-cache.ts +77 -0
  158. package/src/utils/get-date-in-tab-order/get-date-in-tab-order.ts +17 -2
  159. package/src/utils/is-after-min-date/is-after-min-date.ts +16 -1
  160. package/src/utils/is-before-max-date/is-before-max-date.ts +16 -1
  161. package/src/utils/is-same-month/is-same-month.ts +18 -1
@@ -1 +1 @@
1
- {"version":3,"file":"is-before-max-date.d.ts","sourceRoot":"","sources":["../../../../src/utils/is-before-max-date/is-before-max-date.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,eAAe,GAAG,SAAS,GACnC,OAAO,CAET"}
1
+ {"version":3,"file":"is-before-max-date.d.ts","sourceRoot":"","sources":["../../../../src/utils/is-before-max-date/is-before-max-date.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,eAAe,GAAG,SAAS,GACnC,OAAO,CAUT"}
@@ -1,4 +1,16 @@
1
1
  import type { DateStringValue } from "../../types";
2
- /** Whether two dates fall in the same calendar month. Mirrors @mantine/dates `isSameMonth`. */
2
+ /**
3
+ * Whether two dates fall in the same calendar month. Mirrors @mantine/dates
4
+ * `isSameMonth`.
5
+ *
6
+ * This is one of the hottest comparisons in the package — `Month` calls it once
7
+ * per cell (42×) to decide `outside`, and `getDateInTabOrder` calls it again per
8
+ * cell whenever `hideOutsideDates` is on (which `DatePicker` enables
9
+ * automatically for multiple columns). The dayjs spelling cost 2 instances plus
10
+ * 2 `format("YYYY-MM")` calls (locale lookup + regex replace) EACH TIME; for the
11
+ * canonical `YYYY-MM-DD` strings that are the actual inputs, comparing the
12
+ * `YYYY-MM` prefix is exact and allocates nothing. `Date` inputs (and any
13
+ * non-canonical string) keep the original dayjs path.
14
+ */
3
15
  export declare function isSameMonth(date: DateStringValue | Date, comparison: DateStringValue | Date): boolean;
4
16
  //# sourceMappingURL=is-same-month.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-same-month.d.ts","sourceRoot":"","sources":["../../../../src/utils/is-same-month/is-same-month.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,+FAA+F;AAC/F,wBAAgB,WAAW,CACzB,IAAI,EAAE,eAAe,GAAG,IAAI,EAC5B,UAAU,EAAE,eAAe,GAAG,IAAI,GACjC,OAAO,CAET"}
1
+ {"version":3,"file":"is-same-month.d.ts","sourceRoot":"","sources":["../../../../src/utils/is-same-month/is-same-month.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,eAAe,GAAG,IAAI,EAC5B,UAAU,EAAE,eAAe,GAAG,IAAI,GACjC,OAAO,CAMT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knitui/dates",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Date and time components for Knit UI.",
5
5
  "license": "MIT",
6
6
  "author": "The Haus <joost@the.haus>",
@@ -27,13 +27,13 @@
27
27
  "source": "./src/index.ts",
28
28
  "main": "./src/index.ts",
29
29
  "module": "./src/index.ts",
30
- "types": "./src/index.ts",
30
+ "types": "./lib/typescript/index.d.ts",
31
31
  "react-native": "./src/index.ts",
32
32
  "exports": {
33
33
  ".": {
34
34
  "source": "./src/index.ts",
35
35
  "react-native": "./src/index.ts",
36
- "types": "./src/index.ts",
36
+ "types": "./lib/typescript/index.d.ts",
37
37
  "default": "./src/index.ts"
38
38
  },
39
39
  "./src/*.stories": {
@@ -55,9 +55,9 @@
55
55
  "sideEffects": false,
56
56
  "dependencies": {
57
57
  "dayjs": "^1.11.13",
58
- "@knitui/components": "0.5.0",
59
- "@knitui/core": "0.5.0",
60
- "@knitui/hooks": "0.5.0"
58
+ "@knitui/components": "0.6.1",
59
+ "@knitui/core": "0.6.1",
60
+ "@knitui/hooks": "0.6.1"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": "*",
@@ -18,7 +18,7 @@
18
18
  // the ported `@mantine/dates` build (the upstream `tz`/dayjs-timezone layer is
19
19
  // not part of this port).
20
20
  // ───────────────────────────────────────────────────────────────────────────
21
- import { createContext, type ReactNode } from "react";
21
+ import { createContext, type ReactNode, useMemo } from "react";
22
22
 
23
23
  import type { DayOfWeek } from "../types";
24
24
 
@@ -70,11 +70,33 @@ export interface DatesProviderProps {
70
70
  * Components read it through `useDatesContext`.
71
71
  */
72
72
  export function DatesProvider({ settings, children }: DatesProviderProps) {
73
- return (
74
- <DatesProviderContext.Provider value={{ ...DATES_PROVIDER_DEFAULT_SETTINGS, ...settings }}>
75
- {children}
76
- </DatesProviderContext.Provider>
73
+ // The context value MUST keep a stable identity across renders. A context change
74
+ // propagates past every `React.memo` boundary below it, so an inline
75
+ // `value={{ ...defaults, ...settings }}` — a fresh object each render — defeats
76
+ // the memoized day cell (`Month`'s `MonthDayCell`) for all 42 cells of every
77
+ // month grid, which is exactly the boundary that keeps a web hover from
78
+ // re-rendering the whole calendar.
79
+ //
80
+ // `settings` itself is documented (and used throughout the stories/tests) as an
81
+ // INLINE literal, so memoizing on its identity would never hit. We therefore
82
+ // depend on the individual fields: the four primitives by value, and
83
+ // `weekendDays` by its joined value rather than its identity so an inlined
84
+ // `weekendDays={[0, 6]}` does not invalidate on every render either.
85
+ const { locale, firstDayOfWeek, weekendDays, labelSeparator, consistentWeeks } = settings;
86
+ const weekendDaysKey = weekendDays?.join(",");
87
+
88
+ const value = useMemo<DatesProviderValue>(
89
+ // The merge is kept verbatim (rather than rebuilt from the destructured
90
+ // locals) so the exact spread semantics are preserved — including a key that
91
+ // is present with an explicit `undefined`, which overrides its default.
92
+ () => ({ ...DATES_PROVIDER_DEFAULT_SETTINGS, ...settings }),
93
+ // `settings` is read inside but deliberately NOT a dependency — that is the
94
+ // whole point (see above); `weekendDays` is depended on via `weekendDaysKey`.
95
+ // eslint-disable-next-line react-hooks/exhaustive-deps
96
+ [locale, firstDayOfWeek, weekendDaysKey, labelSeparator, consistentWeeks],
77
97
  );
98
+
99
+ return <DatesProviderContext.Provider value={value}>{children}</DatesProviderContext.Provider>;
78
100
  }
79
101
 
80
102
  DatesProvider.displayName = "@knitui/dates/DatesProvider";
package/src/Day/Day.tsx CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as React from "react";
2
2
 
3
- import dayjs from "dayjs";
3
+ import dayjs, { type Dayjs } from "dayjs";
4
4
 
5
5
  import { Text, UnstyledButton } from "@knitui/components";
6
6
  import { createStyledContext, type GetProps, styled, withStaticProperties } from "@knitui/core";
7
7
 
8
8
  import { type CalendarSize, CELL_FONT, CELL_WIDTH } from "../cell-metrics";
9
- import { useDatesContext } from "../DatesProvider";
9
+ import { DatesProviderContext } from "../DatesProvider";
10
10
  import { controlA11yProps } from "../internal/a11y";
11
11
  import { webCursor } from "../internal/web-cursor";
12
12
  import type { DateStringValue } from "../types";
@@ -51,6 +51,26 @@ const dayFontVariant = {
51
51
 
52
52
  const DayContext = createStyledContext<{ size: DaySize }>({ size: "md" });
53
53
 
54
+ /**
55
+ * Whether `day` falls on today's LOCAL calendar date, compared without
56
+ * allocating a single extra dayjs instance.
57
+ *
58
+ * `day.isSame(new Date(), "day")` — the obvious spelling — costs a `Date`, a
59
+ * dayjs instance wrapping it, and two more clones for dayjs' internal
60
+ * `startOf`/`endOf` bracket, i.e. ~4 allocations PER CELL (×42 cells, every
61
+ * render). Reading the three calendar fields off the instance we already have
62
+ * is exact (`year`/`month`/`date` are plain field reads, no clone) and costs
63
+ * only the one `Date` for "now".
64
+ */
65
+ function isSameDayAsToday(day: Dayjs): boolean {
66
+ const now = new Date();
67
+ return (
68
+ day.date() === now.getDate() &&
69
+ day.month() === now.getMonth() &&
70
+ day.year() === now.getFullYear()
71
+ );
72
+ }
73
+
54
74
  /**
55
75
  * The atomic calendar cell — an `UnstyledButton`-based control composed via
56
76
  * `styled`. Accent comes from the active theme's palette ramp via the `theme`
@@ -281,16 +301,37 @@ const DayComponent = DayFrame.styleable<DayProps>(function Day(props, ref) {
281
301
  ...rest
282
302
  } = props;
283
303
 
284
- const ctx = useDatesContext();
304
+ // The RAW context, not `useDatesContext()`. The hook's four `useCallback` getter
305
+ // helpers are convenience for components that resolve several settings; `Day`
306
+ // needs exactly one value — the locale for its fallback label — and it is the
307
+ // grid's hottest leaf (42 instances per month × `numberOfColumns`, all
308
+ // re-rendering on a hover frame). Going through the hook there cost 42 extra
309
+ // hook subscriptions and ~168 freshly allocated closures per grid render for a
310
+ // single string read. `locale || ctx.locale` below is the getter's body verbatim
311
+ // (`getLocale = (input) => input || ctx.locale`), so a standalone `<Day>`
312
+ // resolves its locale exactly as before.
313
+ const ctx = React.useContext(DatesProviderContext);
285
314
  const day = dayjs(date);
286
- const isToday = day.isSame(new Date(), "day");
315
+
316
+ // Only the `highlightToday` border consults "is this today", so the comparison
317
+ // is skipped entirely when the border is off (the default).
318
+ const isToday = highlightToday && isSameDayAsToday(day);
287
319
 
288
320
  // Locale-aware default label, read from `DatesProvider`. A static (display-only)
289
- // day announces nothing — it is not an interactive date. An explicit
290
- // `aria-label` in `...rest` still wins (it is spread last).
291
- const defaultAriaLabel = isStatic
321
+ // day announces nothing — it is not an interactive date.
322
+ //
323
+ // An explicit `aria-label` WINS, so it is read up-front and the fallback is
324
+ // only built when there is none: `Month` always passes its own `aria-label`
325
+ // through `...rest` (spread last), which means computing the fallback there
326
+ // was pure waste — a locale clone plus `format("D MMMM YYYY")`, the most
327
+ // expensive token set in the file, for a string that was always discarded,
328
+ // ×42 cells every render. Reading the explicit label here also means NATIVE
329
+ // (`accessibilityLabel` below) now announces the same custom label web does,
330
+ // instead of the generic date it used to fall back to.
331
+ const explicitAriaLabel = props["aria-label"];
332
+ const ariaLabel = isStatic
292
333
  ? undefined
293
- : day.locale(ctx.getLocale(locale)).format("D MMMM YYYY");
334
+ : (explicitAriaLabel ?? day.locale(locale || ctx.locale).format("D MMMM YYYY"));
294
335
 
295
336
  // Mirror Mantine's data-attribute gating: a disabled day shows none of the
296
337
  // selection/range/weekend/outside styling, and today's border is suppressed
@@ -327,7 +368,7 @@ const DayComponent = DayFrame.styleable<DayProps>(function Day(props, ref) {
327
368
  fullWidth={fullWidth}
328
369
  disabled={disabled}
329
370
  role={isStatic ? "presentation" : "button"}
330
- aria-label={defaultAriaLabel}
371
+ aria-label={ariaLabel}
331
372
  aria-selected={isSelected || undefined}
332
373
  aria-disabled={disabled || undefined}
333
374
  aria-hidden={hidden || undefined}
@@ -335,7 +376,7 @@ const DayComponent = DayFrame.styleable<DayProps>(function Day(props, ref) {
335
376
  // a static display cell announces nothing interactive (`role="none"`).
336
377
  {...controlA11yProps({
337
378
  role: isStatic ? "none" : "button",
338
- label: defaultAriaLabel,
379
+ label: ariaLabel,
339
380
  selected: isSelected,
340
381
  disabled,
341
382
  })}