@knitui/dates 0.14.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.
Files changed (225) hide show
  1. package/lib/commonjs/Calendar/Calendar.js +4 -4
  2. package/lib/commonjs/Calendar/Calendar.js.map +1 -1
  3. package/lib/commonjs/CalendarHeader/CalendarHeader.js +24 -152
  4. package/lib/commonjs/CalendarHeader/CalendarHeader.js.map +1 -1
  5. package/lib/commonjs/DatePicker/DatePicker.js +1 -1
  6. package/lib/commonjs/DatePickerInput/DatePickerInput.js +1 -1
  7. package/lib/commonjs/DateTimePicker/DateTimePicker.js +1 -1
  8. package/lib/commonjs/DatesProvider/DatesProvider.js +1 -1
  9. package/lib/commonjs/Day/Day.js +74 -142
  10. package/lib/commonjs/Day/Day.js.map +1 -1
  11. package/lib/commonjs/DecadeLevel/DecadeLevel.js +5 -5
  12. package/lib/commonjs/DecadeLevel/DecadeLevel.js.map +1 -1
  13. package/lib/commonjs/InlineDateTimePicker/InlineDateTimePicker.js +16 -7
  14. package/lib/commonjs/InlineDateTimePicker/InlineDateTimePicker.js.map +1 -1
  15. package/lib/commonjs/LevelsGroup/LevelsGroup.js +3 -3
  16. package/lib/commonjs/LevelsGroup/LevelsGroup.js.map +1 -1
  17. package/lib/commonjs/MiniCalendar/MiniCalendar.js +37 -173
  18. package/lib/commonjs/MiniCalendar/MiniCalendar.js.map +1 -1
  19. package/lib/commonjs/Month/Month.js +15 -62
  20. package/lib/commonjs/Month/Month.js.map +1 -1
  21. package/lib/commonjs/MonthLevel/MonthLevel.js +5 -5
  22. package/lib/commonjs/MonthLevel/MonthLevel.js.map +1 -1
  23. package/lib/commonjs/MonthPicker/MonthPicker.js +1 -1
  24. package/lib/commonjs/MonthPickerInput/MonthPickerInput.js +1 -1
  25. package/lib/commonjs/MonthsList/MonthsList.js +8 -9
  26. package/lib/commonjs/MonthsList/MonthsList.js.map +1 -1
  27. package/lib/commonjs/PickerControl/PickerControl.js +41 -121
  28. package/lib/commonjs/PickerControl/PickerControl.js.map +1 -1
  29. package/lib/commonjs/PickerInputBase/PickerInputBase.js +1 -1
  30. package/lib/commonjs/TimeControlsList/TimeControl.js +19 -48
  31. package/lib/commonjs/TimeControlsList/TimeControl.js.map +1 -1
  32. package/lib/commonjs/TimeControlsList/TimeControlsList.js +1 -1
  33. package/lib/commonjs/TimeControlsList/TimeControlsList.js.map +1 -1
  34. package/lib/commonjs/TimeGrid/TimeGrid.js +50 -97
  35. package/lib/commonjs/TimeGrid/TimeGrid.js.map +1 -1
  36. package/lib/commonjs/TimeInput/TimeInput.js +1 -1
  37. package/lib/commonjs/TimePicker/TimePicker.js +20 -20
  38. package/lib/commonjs/TimePicker/TimePicker.js.map +1 -1
  39. package/lib/commonjs/TimePresets/TimePresetControl.js +32 -62
  40. package/lib/commonjs/TimePresets/TimePresetControl.js.map +1 -1
  41. package/lib/commonjs/TimePresets/TimePresetGroup.js +5 -5
  42. package/lib/commonjs/TimePresets/TimePresetGroup.js.map +1 -1
  43. package/lib/commonjs/TimePresets/TimePresets.js +4 -4
  44. package/lib/commonjs/TimePresets/TimePresets.js.map +1 -1
  45. package/lib/commonjs/TimeValue/TimeValue.js +2 -2
  46. package/lib/commonjs/WeekdaysRow/WeekdaysRow.js +7 -38
  47. package/lib/commonjs/WeekdaysRow/WeekdaysRow.js.map +1 -1
  48. package/lib/commonjs/YearLevel/YearLevel.js +5 -5
  49. package/lib/commonjs/YearLevel/YearLevel.js.map +1 -1
  50. package/lib/commonjs/YearPicker/YearPicker.js +1 -1
  51. package/lib/commonjs/YearPickerInput/YearPickerInput.js +1 -1
  52. package/lib/commonjs/YearsList/YearsList.js +8 -9
  53. package/lib/commonjs/YearsList/YearsList.js.map +1 -1
  54. package/lib/commonjs/_reference/ExampleControl.js +26 -91
  55. package/lib/commonjs/_reference/ExampleControl.js.map +1 -1
  56. package/lib/commonjs/_reference/README.md +3 -3
  57. package/lib/commonjs/cell-metrics.js +167 -37
  58. package/lib/commonjs/cell-metrics.js.map +1 -1
  59. package/lib/commonjs/internal/a11y.js +5 -3
  60. package/lib/commonjs/internal/a11y.js.map +1 -1
  61. package/lib/commonjs/internal/get-input-default-date.js +1 -1
  62. package/lib/commonjs/internal/select-on-focus.js +1 -1
  63. package/lib/module/Calendar/Calendar.js +5 -5
  64. package/lib/module/Calendar/Calendar.js.map +1 -1
  65. package/lib/module/CalendarHeader/CalendarHeader.js +26 -155
  66. package/lib/module/CalendarHeader/CalendarHeader.js.map +1 -1
  67. package/lib/module/DatePicker/DatePicker.js +1 -1
  68. package/lib/module/DatePickerInput/DatePickerInput.js +1 -1
  69. package/lib/module/DateTimePicker/DateTimePicker.js +1 -1
  70. package/lib/module/DatesProvider/DatesProvider.js +1 -1
  71. package/lib/module/Day/Day.js +76 -144
  72. package/lib/module/Day/Day.js.map +1 -1
  73. package/lib/module/DecadeLevel/DecadeLevel.js +6 -6
  74. package/lib/module/DecadeLevel/DecadeLevel.js.map +1 -1
  75. package/lib/module/InlineDateTimePicker/InlineDateTimePicker.js +16 -7
  76. package/lib/module/InlineDateTimePicker/InlineDateTimePicker.js.map +1 -1
  77. package/lib/module/LevelsGroup/LevelsGroup.js +4 -4
  78. package/lib/module/LevelsGroup/LevelsGroup.js.map +1 -1
  79. package/lib/module/MiniCalendar/MiniCalendar.js +39 -175
  80. package/lib/module/MiniCalendar/MiniCalendar.js.map +1 -1
  81. package/lib/module/Month/Month.js +17 -64
  82. package/lib/module/Month/Month.js.map +1 -1
  83. package/lib/module/MonthLevel/MonthLevel.js +6 -6
  84. package/lib/module/MonthLevel/MonthLevel.js.map +1 -1
  85. package/lib/module/MonthPicker/MonthPicker.js +1 -1
  86. package/lib/module/MonthPickerInput/MonthPickerInput.js +1 -1
  87. package/lib/module/MonthsList/MonthsList.js +9 -10
  88. package/lib/module/MonthsList/MonthsList.js.map +1 -1
  89. package/lib/module/PickerControl/PickerControl.js +42 -122
  90. package/lib/module/PickerControl/PickerControl.js.map +1 -1
  91. package/lib/module/PickerInputBase/PickerInputBase.js +1 -1
  92. package/lib/module/TimeControlsList/TimeControl.js +20 -49
  93. package/lib/module/TimeControlsList/TimeControl.js.map +1 -1
  94. package/lib/module/TimeControlsList/TimeControlsList.js +1 -1
  95. package/lib/module/TimeControlsList/TimeControlsList.js.map +1 -1
  96. package/lib/module/TimeGrid/TimeGrid.js +53 -100
  97. package/lib/module/TimeGrid/TimeGrid.js.map +1 -1
  98. package/lib/module/TimeInput/TimeInput.js +1 -1
  99. package/lib/module/TimePicker/TimePicker.js +20 -20
  100. package/lib/module/TimePicker/TimePicker.js.map +1 -1
  101. package/lib/module/TimePresets/TimePresetControl.js +36 -65
  102. package/lib/module/TimePresets/TimePresetControl.js.map +1 -1
  103. package/lib/module/TimePresets/TimePresetGroup.js +6 -6
  104. package/lib/module/TimePresets/TimePresetGroup.js.map +1 -1
  105. package/lib/module/TimePresets/TimePresets.js +4 -4
  106. package/lib/module/TimePresets/TimePresets.js.map +1 -1
  107. package/lib/module/TimeValue/TimeValue.js +2 -2
  108. package/lib/module/WeekdaysRow/WeekdaysRow.js +8 -39
  109. package/lib/module/WeekdaysRow/WeekdaysRow.js.map +1 -1
  110. package/lib/module/YearLevel/YearLevel.js +6 -6
  111. package/lib/module/YearLevel/YearLevel.js.map +1 -1
  112. package/lib/module/YearPicker/YearPicker.js +1 -1
  113. package/lib/module/YearPickerInput/YearPickerInput.js +1 -1
  114. package/lib/module/YearsList/YearsList.js +9 -10
  115. package/lib/module/YearsList/YearsList.js.map +1 -1
  116. package/lib/module/_reference/ExampleControl.js +28 -93
  117. package/lib/module/_reference/ExampleControl.js.map +1 -1
  118. package/lib/module/_reference/README.md +3 -3
  119. package/lib/module/cell-metrics.js +166 -36
  120. package/lib/module/cell-metrics.js.map +1 -1
  121. package/lib/module/internal/a11y.js +5 -3
  122. package/lib/module/internal/a11y.js.map +1 -1
  123. package/lib/module/internal/get-input-default-date.js +1 -1
  124. package/lib/module/internal/select-on-focus.js +1 -1
  125. package/lib/typescript/Calendar/Calendar.d.ts +28 -21
  126. package/lib/typescript/Calendar/Calendar.d.ts.map +1 -1
  127. package/lib/typescript/Calendar/pick-calendar-props/pick-calendar-props.d.ts +1 -1
  128. package/lib/typescript/CalendarHeader/CalendarHeader.d.ts +190 -53
  129. package/lib/typescript/CalendarHeader/CalendarHeader.d.ts.map +1 -1
  130. package/lib/typescript/Day/Day.d.ts +103 -84
  131. package/lib/typescript/Day/Day.d.ts.map +1 -1
  132. package/lib/typescript/DecadeLevel/DecadeLevel.d.ts +172 -71
  133. package/lib/typescript/DecadeLevel/DecadeLevel.d.ts.map +1 -1
  134. package/lib/typescript/DecadeLevelGroup/DecadeLevelGroup.d.ts +171 -86
  135. package/lib/typescript/DecadeLevelGroup/DecadeLevelGroup.d.ts.map +1 -1
  136. package/lib/typescript/InlineDateTimePicker/InlineDateTimePicker.d.ts +64 -12
  137. package/lib/typescript/InlineDateTimePicker/InlineDateTimePicker.d.ts.map +1 -1
  138. package/lib/typescript/LevelsGroup/LevelsGroup.d.ts +27 -20
  139. package/lib/typescript/LevelsGroup/LevelsGroup.d.ts.map +1 -1
  140. package/lib/typescript/MiniCalendar/MiniCalendar.d.ts +247 -61
  141. package/lib/typescript/MiniCalendar/MiniCalendar.d.ts.map +1 -1
  142. package/lib/typescript/Month/Month.d.ts +164 -43
  143. package/lib/typescript/Month/Month.d.ts.map +1 -1
  144. package/lib/typescript/MonthLevel/MonthLevel.d.ts +208 -79
  145. package/lib/typescript/MonthLevel/MonthLevel.d.ts.map +1 -1
  146. package/lib/typescript/MonthLevelGroup/MonthLevelGroup.d.ts +207 -94
  147. package/lib/typescript/MonthLevelGroup/MonthLevelGroup.d.ts.map +1 -1
  148. package/lib/typescript/MonthsList/MonthsList.d.ts +91 -26
  149. package/lib/typescript/MonthsList/MonthsList.d.ts.map +1 -1
  150. package/lib/typescript/PickerControl/PickerControl.d.ts +79 -59
  151. package/lib/typescript/PickerControl/PickerControl.d.ts.map +1 -1
  152. package/lib/typescript/TimeControlsList/TimeControl.d.ts +19 -4
  153. package/lib/typescript/TimeControlsList/TimeControl.d.ts.map +1 -1
  154. package/lib/typescript/TimeControlsList/TimeControlsList.d.ts +66 -12
  155. package/lib/typescript/TimeControlsList/TimeControlsList.d.ts.map +1 -1
  156. package/lib/typescript/TimeGrid/TimeGrid.d.ts +98 -34
  157. package/lib/typescript/TimeGrid/TimeGrid.d.ts.map +1 -1
  158. package/lib/typescript/TimePicker/TimePicker.d.ts +43 -7
  159. package/lib/typescript/TimePicker/TimePicker.d.ts.map +1 -1
  160. package/lib/typescript/TimePresets/TimePresetControl.d.ts +65 -10
  161. package/lib/typescript/TimePresets/TimePresetControl.d.ts.map +1 -1
  162. package/lib/typescript/TimePresets/TimePresetGroup.d.ts +132 -44
  163. package/lib/typescript/TimePresets/TimePresetGroup.d.ts.map +1 -1
  164. package/lib/typescript/TimePresets/TimePresets.d.ts +237 -64
  165. package/lib/typescript/TimePresets/TimePresets.d.ts.map +1 -1
  166. package/lib/typescript/WeekdaysRow/WeekdaysRow.d.ts +81 -27
  167. package/lib/typescript/WeekdaysRow/WeekdaysRow.d.ts.map +1 -1
  168. package/lib/typescript/YearLevel/YearLevel.d.ts +172 -71
  169. package/lib/typescript/YearLevel/YearLevel.d.ts.map +1 -1
  170. package/lib/typescript/YearLevelGroup/YearLevelGroup.d.ts +171 -86
  171. package/lib/typescript/YearLevelGroup/YearLevelGroup.d.ts.map +1 -1
  172. package/lib/typescript/YearsList/YearsList.d.ts +91 -26
  173. package/lib/typescript/YearsList/YearsList.d.ts.map +1 -1
  174. package/lib/typescript/_reference/ExampleControl.d.ts +163 -43
  175. package/lib/typescript/_reference/ExampleControl.d.ts.map +1 -1
  176. package/lib/typescript/cell-metrics.d.ts +120 -0
  177. package/lib/typescript/cell-metrics.d.ts.map +1 -1
  178. package/lib/typescript/internal/a11y.d.ts +0 -14
  179. package/lib/typescript/internal/a11y.d.ts.map +1 -1
  180. package/package.json +11 -11
  181. package/src/Calendar/Calendar.tsx +6 -5
  182. package/src/CalendarHeader/CalendarHeader.tsx +32 -74
  183. package/src/DatePicker/DatePicker.tsx +1 -1
  184. package/src/DatePickerInput/DatePickerInput.tsx +1 -1
  185. package/src/DateTimePicker/DateTimePicker.tsx +1 -1
  186. package/src/DatesProvider/DatesProvider.tsx +1 -1
  187. package/src/Day/Day.tsx +85 -82
  188. package/src/DecadeLevel/DecadeLevel.tsx +7 -5
  189. package/src/InlineDateTimePicker/InlineDateTimePicker.tsx +14 -7
  190. package/src/LevelsGroup/LevelsGroup.tsx +13 -13
  191. package/src/MiniCalendar/MiniCalendar.tsx +47 -91
  192. package/src/Month/Month.tsx +21 -37
  193. package/src/MonthLevel/MonthLevel.tsx +7 -5
  194. package/src/MonthPicker/MonthPicker.tsx +1 -1
  195. package/src/MonthPickerInput/MonthPickerInput.tsx +1 -1
  196. package/src/MonthsList/MonthsList.tsx +9 -10
  197. package/src/PickerControl/PickerControl.tsx +44 -89
  198. package/src/PickerInputBase/PickerInputBase.tsx +1 -1
  199. package/src/TimeControlsList/TimeControl.tsx +17 -28
  200. package/src/TimeControlsList/TimeControlsList.tsx +1 -1
  201. package/src/TimeGrid/TimeGrid.tsx +71 -61
  202. package/src/TimeInput/TimeInput.tsx +1 -1
  203. package/src/TimePicker/TimePicker.tsx +15 -15
  204. package/src/TimePresets/TimePresetControl.tsx +30 -45
  205. package/src/TimePresets/TimePresetGroup.tsx +7 -5
  206. package/src/TimePresets/TimePresets.tsx +4 -4
  207. package/src/TimeValue/TimeValue.tsx +2 -2
  208. package/src/WeekdaysRow/WeekdaysRow.tsx +9 -17
  209. package/src/YearLevel/YearLevel.tsx +121 -117
  210. package/src/YearPicker/YearPicker.tsx +1 -1
  211. package/src/YearPickerInput/YearPickerInput.tsx +1 -1
  212. package/src/YearsList/YearsList.tsx +142 -141
  213. package/src/_reference/ExampleControl.tsx +29 -53
  214. package/src/_reference/README.md +3 -3
  215. package/src/cell-metrics.ts +110 -36
  216. package/src/internal/a11y.ts +6 -3
  217. package/src/internal/get-input-default-date.ts +1 -1
  218. package/src/internal/select-on-focus.ts +1 -1
  219. package/lib/commonjs/internal/web-cursor.js +0 -24
  220. package/lib/commonjs/internal/web-cursor.js.map +0 -1
  221. package/lib/module/internal/web-cursor.js +0 -20
  222. package/lib/module/internal/web-cursor.js.map +0 -1
  223. package/lib/typescript/internal/web-cursor.d.ts +0 -10
  224. package/lib/typescript/internal/web-cursor.d.ts.map +0 -1
  225. package/src/internal/web-cursor.ts +0 -15
@@ -17,7 +17,7 @@
17
17
  // rules in `_reference/README.md` that apply here: #1 (this header), #2 (shared
18
18
  // size context), #7 (`styles` sugar + `getMonthControlProps` passthrough — owned
19
19
  // by `MonthsList`), #9 (locale), #10 (min/max bounds), #11 (delegated a11y),
20
- // #13 (`.styleable` + typed ref), #14 (`withStaticProperties`), #15 (no dynamic
20
+ // #13 (`styleable()` + typed ref), #14 (`withStaticProperties`), #15 (no dynamic
21
21
  // hide styles — none used here). Unlike `DecadeLevel`, a year is NOT the top
22
22
  // level: it zooms out to a decade, so the level control stays interactive
23
23
  // (`onLevelClick`/`hasNextLevel`).
@@ -32,6 +32,7 @@ import {
32
32
  type GetProps,
33
33
  slotStyles,
34
34
  type SlotStyles,
35
+ styleable,
35
36
  styled,
36
37
  withStaticProperties,
37
38
  } from "@knitui/core";
@@ -60,10 +61,10 @@ const YearLevelContext = createStyledContext<{ size: CalendarSize }>({ size: "md
60
61
 
61
62
  // ── 5/13. Styled root ─────────────────────────────────────────────────────────
62
63
  // The level root is a styled `Box` column (the dates norm: a real styled part so
63
- // `.styleable` can forward a ref + style props onto it). It establishes the
64
+ // `styleable()` can forward a ref + style props onto it). It establishes the
64
65
  // shared `size` context; the header and grid own the `size` variant themselves.
65
66
  const YearLevelFrame = styled(Box, {
66
- name: "YearLevel",
67
+ displayName: "YearLevel",
67
68
  context: YearLevelContext,
68
69
  flexDirection: "column",
69
70
 
@@ -149,7 +150,7 @@ export interface YearLevelProps extends YearLevelFrameProps, YearLevelSettings {
149
150
  * locale. All `__onControl*` / `__getControlRef` / `__preventFocus` /
150
151
  * `__stopPropagation` plumbing is forwarded straight to the `MonthsList`.
151
152
  *
152
- * Per-slot style sugar: `styles={{ headerControl: { borderRadius: "$lg" } }}` routes
153
+ * Per-slot style sugar: `styles={{ headerControl: { borderRadius: "lg" } }}` routes
153
154
  * onto the matching part; per-cell tuning stays on `getMonthControlProps(date)`. The
154
155
  * month grid's a11y/interaction/sizing are delegated to `MonthsList`/`PickerControl`
155
156
  * and the header to `CalendarHeader`. Forwards its ref + style props to the root.
@@ -157,129 +158,132 @@ export interface YearLevelProps extends YearLevelFrameProps, YearLevelSettings {
157
158
  * @example
158
159
  * <YearLevel year="2024-01-01" onNext={nextYear} onPrevious={prevYear} onLevelClick={zoomOut} />
159
160
  */
160
- const YearLevelComponent = YearLevelFrame.styleable<YearLevelProps>(function YearLevel(props, ref) {
161
- const {
162
- // MonthsList settings
163
- year,
164
- locale,
165
- minDate,
166
- maxDate,
167
- monthsListFormat,
168
- getMonthControlProps,
169
- __getControlRef,
170
- __onControlKeyDown,
171
- __onControlClick,
172
- __onControlMouseEnter,
173
- withCellSpacing,
161
+ const YearLevelComponent = styleable<YearLevelProps>(
162
+ YearLevelFrame,
163
+ function YearLevel(props, ref) {
164
+ const {
165
+ // MonthsList settings
166
+ year,
167
+ locale,
168
+ minDate,
169
+ maxDate,
170
+ monthsListFormat,
171
+ getMonthControlProps,
172
+ __getControlRef,
173
+ __onControlKeyDown,
174
+ __onControlClick,
175
+ __onControlMouseEnter,
176
+ withCellSpacing,
174
177
 
175
- // CalendarHeader settings
176
- __preventFocus,
177
- __stopPropagation,
178
- nextIcon,
179
- previousIcon,
180
- nextLabel,
181
- previousLabel,
182
- onNext,
183
- onPrevious,
184
- onLevelClick,
185
- nextDisabled,
186
- previousDisabled,
187
- hasNextLevel,
188
- levelControlAriaLabel,
189
- withNext,
190
- withPrevious,
191
- headerControlsOrder,
178
+ // CalendarHeader settings
179
+ __preventFocus,
180
+ __stopPropagation,
181
+ nextIcon,
182
+ previousIcon,
183
+ nextLabel,
184
+ previousLabel,
185
+ onNext,
186
+ onPrevious,
187
+ onLevelClick,
188
+ nextDisabled,
189
+ previousDisabled,
190
+ hasNextLevel,
191
+ levelControlAriaLabel,
192
+ withNext,
193
+ withPrevious,
194
+ headerControlsOrder,
192
195
 
193
- // Level-specific
194
- yearLabelFormat = "YYYY",
195
- size = "md",
196
- fullWidth,
197
- styles,
198
- ...rest
199
- } = props;
196
+ // Level-specific
197
+ yearLabelFormat = "YYYY",
198
+ size = "md",
199
+ fullWidth,
200
+ styles,
201
+ ...rest
202
+ } = props;
200
203
 
201
- // 7. Typed per-slot accessor (dev-warns unknown keys against the known set).
202
- const s = slotStyles<YearLevelStyles>(styles, YEAR_LEVEL_SLOT_KEYS, "YearLevel");
204
+ // 7. Typed per-slot accessor (dev-warns unknown keys against the known set).
205
+ const s = slotStyles<YearLevelStyles>(styles, YEAR_LEVEL_SLOT_KEYS, "YearLevel");
203
206
 
204
- // 9. Locale comes from `DatesProvider` (consumer `locale` prop wins).
205
- const ctx = useDatesContext();
207
+ // 9. Locale comes from `DatesProvider` (consumer `locale` prop wins).
208
+ const ctx = useDatesContext();
206
209
 
207
- // 10. Auto-disable the controls at the `minDate`/`maxDate` bounds (an explicit
208
- // boolean override always wins).
209
- const _nextDisabled =
210
- typeof nextDisabled === "boolean"
211
- ? nextDisabled
212
- : maxDate
213
- ? !dayjs(year).endOf("year").isBefore(maxDate)
214
- : false;
210
+ // 10. Auto-disable the controls at the `minDate`/`maxDate` bounds (an explicit
211
+ // boolean override always wins).
212
+ const _nextDisabled =
213
+ typeof nextDisabled === "boolean"
214
+ ? nextDisabled
215
+ : maxDate
216
+ ? !dayjs(year).endOf("year").isBefore(maxDate)
217
+ : false;
215
218
 
216
- const _previousDisabled =
217
- typeof previousDisabled === "boolean"
218
- ? previousDisabled
219
- : minDate
220
- ? !dayjs(year).startOf("year").isAfter(minDate)
221
- : false;
219
+ const _previousDisabled =
220
+ typeof previousDisabled === "boolean"
221
+ ? previousDisabled
222
+ : minDate
223
+ ? !dayjs(year).startOf("year").isAfter(minDate)
224
+ : false;
222
225
 
223
- const label =
224
- typeof yearLabelFormat === "function"
225
- ? yearLabelFormat(year)
226
- : dayjs(year).locale(ctx.getLocale(locale)).format(yearLabelFormat);
226
+ const label =
227
+ typeof yearLabelFormat === "function"
228
+ ? yearLabelFormat(year)
229
+ : dayjs(year).locale(ctx.getLocale(locale)).format(yearLabelFormat);
227
230
 
228
- // 7. Route the header-named slots into `CalendarHeader`'s own `styles` map.
229
- const headerStyles: SlotStyles<CalendarHeaderStyles> = {
230
- root: s.get("header"),
231
- control: s.get("headerControl"),
232
- level: s.get("headerLevel"),
233
- levelLabel: s.get("headerLevelLabel"),
234
- icon: s.get("headerIcon"),
235
- };
231
+ // 7. Route the header-named slots into `CalendarHeader`'s own `styles` map.
232
+ const headerStyles: SlotStyles<CalendarHeaderStyles> = {
233
+ root: s.get("header"),
234
+ control: s.get("headerControl"),
235
+ level: s.get("headerLevel"),
236
+ levelLabel: s.get("headerLevelLabel"),
237
+ icon: s.get("headerIcon"),
238
+ };
236
239
 
237
- return (
238
- <YearLevelFrame ref={ref} fullWidth={fullWidth} {...s.merge("root", rest)}>
239
- <CalendarHeader
240
- label={label}
241
- __preventFocus={__preventFocus}
242
- __stopPropagation={__stopPropagation}
243
- nextIcon={nextIcon}
244
- previousIcon={previousIcon}
245
- nextLabel={nextLabel}
246
- previousLabel={previousLabel}
247
- onNext={onNext}
248
- onPrevious={onPrevious}
249
- onLevelClick={onLevelClick}
250
- nextDisabled={_nextDisabled}
251
- previousDisabled={_previousDisabled}
252
- hasNextLevel={hasNextLevel}
253
- levelControlAriaLabel={levelControlAriaLabel}
254
- withNext={withNext}
255
- withPrevious={withPrevious}
256
- headerControlsOrder={headerControlsOrder}
257
- size={size}
258
- fullWidth={fullWidth}
259
- styles={headerStyles}
260
- />
240
+ return (
241
+ <YearLevelFrame ref={ref} fullWidth={fullWidth} {...s.merge("root", rest)}>
242
+ <CalendarHeader
243
+ label={label}
244
+ __preventFocus={__preventFocus}
245
+ __stopPropagation={__stopPropagation}
246
+ nextIcon={nextIcon}
247
+ previousIcon={previousIcon}
248
+ nextLabel={nextLabel}
249
+ previousLabel={previousLabel}
250
+ onNext={onNext}
251
+ onPrevious={onPrevious}
252
+ onLevelClick={onLevelClick}
253
+ nextDisabled={_nextDisabled}
254
+ previousDisabled={_previousDisabled}
255
+ hasNextLevel={hasNextLevel}
256
+ levelControlAriaLabel={levelControlAriaLabel}
257
+ withNext={withNext}
258
+ withPrevious={withPrevious}
259
+ headerControlsOrder={headerControlsOrder}
260
+ size={size}
261
+ fullWidth={fullWidth}
262
+ styles={headerStyles}
263
+ />
261
264
 
262
- <MonthsList
263
- year={year}
264
- locale={locale}
265
- minDate={minDate}
266
- maxDate={maxDate}
267
- monthsListFormat={monthsListFormat}
268
- getMonthControlProps={getMonthControlProps}
269
- __getControlRef={__getControlRef}
270
- __onControlKeyDown={__onControlKeyDown}
271
- __onControlClick={__onControlClick}
272
- __onControlMouseEnter={__onControlMouseEnter}
273
- __preventFocus={__preventFocus}
274
- __stopPropagation={__stopPropagation}
275
- withCellSpacing={withCellSpacing}
276
- size={size}
277
- fullWidth={fullWidth}
278
- {...s.get("months")}
279
- />
280
- </YearLevelFrame>
281
- );
282
- });
265
+ <MonthsList
266
+ year={year}
267
+ locale={locale}
268
+ minDate={minDate}
269
+ maxDate={maxDate}
270
+ monthsListFormat={monthsListFormat}
271
+ getMonthControlProps={getMonthControlProps}
272
+ __getControlRef={__getControlRef}
273
+ __onControlKeyDown={__onControlKeyDown}
274
+ __onControlClick={__onControlClick}
275
+ __onControlMouseEnter={__onControlMouseEnter}
276
+ __preventFocus={__preventFocus}
277
+ __stopPropagation={__stopPropagation}
278
+ withCellSpacing={withCellSpacing}
279
+ size={size}
280
+ fullWidth={fullWidth}
281
+ {...s.get("months")}
282
+ />
283
+ </YearLevelFrame>
284
+ );
285
+ },
286
+ );
283
287
 
284
288
  // ── 14. Public surface ────────────────────────────────────────────────────────
285
289
  // `withStaticProperties` exposes the styled root + the composed parts so consumers
@@ -25,7 +25,7 @@
25
25
  // subtree — never a dynamic `opacity`/`display` style prop (15). The `<Type>`
26
26
  // generic is preserved through `forwardRef` (which would otherwise pin it at
27
27
  // `"default"`), so the ref is forwarded via a typed `forwardRef` rather than
28
- // `.styleable` (13) — the documented sibling-picker pattern.
28
+ // `styleable()` (13) — the documented sibling-picker pattern.
29
29
  // ───────────────────────────────────────────────────────────────────────────
30
30
  import * as React from "react";
31
31
  import { useRef } from "react";
@@ -37,7 +37,7 @@
37
37
  // dropdown subtree `PickerInputBase` owns — never a dynamic `opacity`/`display`
38
38
  // style prop (15). The `<Type>` generic is preserved through `forwardRef` (which
39
39
  // would otherwise pin it at `"default"`), so the ref is forwarded via a typed
40
- // `forwardRef` rather than `.styleable` (13) — the documented sibling-picker
40
+ // `forwardRef` rather than `styleable()` (13) — the documented sibling-picker
41
41
  // pattern (`YearPicker` / `MonthPickerInput` / `DatePickerInput`).
42
42
  // ───────────────────────────────────────────────────────────────────────────
43
43
  import * as React from "react";
@@ -24,11 +24,13 @@ import { useMemo } from "react";
24
24
  import dayjs from "dayjs";
25
25
 
26
26
  import { Box } from "@knitui/components";
27
+ import { hoverProps } from "@knitui/components/control-system";
27
28
  import {
28
29
  createStyledContext,
29
30
  type GetProps,
30
31
  slotStyles,
31
32
  type SlotStyles,
33
+ styleable,
32
34
  styled,
33
35
  withStaticProperties,
34
36
  } from "@knitui/core";
@@ -70,7 +72,7 @@ const YearsListContext = createStyledContext<{ size: CalendarSize }>({ size: "md
70
72
 
71
73
  /** The grid container — a column of year rows (web `role="grid"`). */
72
74
  const YearsListFrame = styled(Box, {
73
- name: "YearsList",
75
+ displayName: "YearsList",
74
76
  context: YearsListContext,
75
77
  flexDirection: "column",
76
78
 
@@ -89,7 +91,7 @@ const YearsListFrame = styled(Box, {
89
91
 
90
92
  /** A single year row (web `role="row"`). */
91
93
  const YearsListRow = styled(Box, {
92
- name: "YearsListRow",
94
+ displayName: "YearsListRow",
93
95
  context: YearsListContext,
94
96
  flexDirection: "row",
95
97
 
@@ -114,7 +116,7 @@ const YearsListRow = styled(Box, {
114
116
  * per-render `flexGrow` spread — so the optimiser has nothing dynamic to fold).
115
117
  */
116
118
  const YearsListCell = styled(Box, {
117
- name: "YearsListCell",
119
+ displayName: "YearsListCell",
118
120
  context: YearsListContext,
119
121
  alignItems: "center",
120
122
  justifyContent: "center",
@@ -205,12 +207,8 @@ const YearsListControlCell = React.memo(function YearsListControlCell({
205
207
  onControlKeyDown,
206
208
  getControlRef,
207
209
  }: YearsListControlCellProps) {
208
- // Tamagui hover handlers are not part of `PickerControl`'s public prop type;
209
- // attach them via a precisely-typed object spread, the kit's pattern for web-only
210
- // affordances (see `Month`). Native never fires it.
211
- const hoverHandlers: { onHoverIn?: (event: unknown) => void } = {
212
- onHoverIn: (event) => onControlMouseEnter(event, year),
213
- };
210
+ // Range hover preview (see `Month`): `onMouseEnter` on web, `onHoverIn` on native.
211
+ const hoverHandlers = hoverProps({ onHoverIn: (event) => onControlMouseEnter(event, year) });
214
212
 
215
213
  return (
216
214
  <YearsListCell role="cell" fullWidth={fullWidth} {...cellProps}>
@@ -339,148 +337,151 @@ export interface YearsListProps extends YearsListFrameProps, YearsListSettings {
339
337
  * wrapping a `role="button"` control. (ARIA's `gridcell` would be the ideal child
340
338
  * of `role="grid"`, but the cross-platform `Role` type has no `gridcell` member.)
341
339
  */
342
- const YearsListComponent = YearsListFrame.styleable<YearsListProps>(function YearsList(props, ref) {
343
- const {
344
- decade,
345
- yearsListFormat = "YYYY",
346
- locale,
347
- minDate,
348
- maxDate,
349
- getYearControlProps,
350
- __getControlRef,
351
- __onControlKeyDown,
352
- __onControlClick,
353
- __onControlMouseEnter,
354
- __preventFocus,
355
- __stopPropagation,
356
- withCellSpacing = true,
357
- fullWidth = false,
358
- size = "md",
359
- styles,
360
- ...rest
361
- } = props;
362
-
363
- // `__stopPropagation` is accepted for Mantine API parity; the cross-platform
364
- // Escape handling lives at the picker/popover layer, so it is a no-op here
365
- // (the same reservation `CalendarHeader`/`Month` make for it).
366
- void __stopPropagation;
367
-
368
- const ctx = useDatesContext();
369
-
370
- const minDateString = minDate == null ? undefined : toDateString(minDate);
371
- const maxDateString = maxDate == null ? undefined : toDateString(maxDate);
372
-
373
- // 7. Typed per-slot accessor (dev-warns unknown keys against the known set).
374
- const s = slotStyles<YearsListStyles>(styles, YEARS_LIST_SLOT_KEYS, "YearsList");
375
-
376
- const resolvedLocale = ctx.getLocale(locale);
377
-
378
- // The 10 cells' grid, bounds and LABELS depend only on the decade, the locale,
379
- // the format and the min/max bounds — never on the selection — yet they were
380
- // rebuilt every render, each cell paying a `dayjs(year).locale(…).format(…)`
381
- // (parse + locale clone + locale-table format) for a label fixed for the decade.
382
- const yearsInfo = useMemo(() => {
383
- const grid = getYearsData(decade);
384
- return {
385
- grid,
386
- cells: grid.map((row) =>
387
- row.map((year) => ({
388
- year,
389
- disabled: isYearDisabled({ year, minDate: minDateString, maxDate: maxDateString }),
390
- label: dayjs(year).locale(resolvedLocale).format(yearsListFormat),
391
- })),
392
- ),
393
- };
394
- }, [decade, minDateString, maxDateString, resolvedLocale, yearsListFormat]);
395
-
396
- // ONE per-render cache shared by `getYearInTabOrder` (which consults the getter
397
- // twice per year) and the cell loop below (a third time). Not memoized across
398
- // renders — the getter closes over live selection state.
399
- const resolveControlProps = memoizeByDate(getYearControlProps);
400
-
401
- const yearInTabOrder = getYearInTabOrder({
402
- years: yearsInfo.grid,
403
- minDate: minDateString,
404
- maxDate: maxDateString,
405
- getYearControlProps: resolveControlProps,
406
- });
407
-
408
- const cellGap = withCellSpacing ? CELL_SPACING : 0;
409
-
410
- // The cell memo can only bail out if every function prop it receives keeps a
411
- // stable identity. All four of these arrive freshly built each render (the level
412
- // group builds them per decade, `YearPicker` per render), so they are wrapped once
413
- // here rather than being stabilised at each of their many call sites.
414
- const onControlMouseEnter = useCallbackRef(__onControlMouseEnter);
415
- const onControlClick = useCallbackRef(__onControlClick);
416
- const onControlKeyDown = useCallbackRef(__onControlKeyDown);
417
- const getControlRef = useCallbackRef(__getControlRef);
418
-
419
- const cellSlotProps = s.get("cell");
420
-
421
- const rows = yearsInfo.cells.map((yearsRow, rowIndex) => {
422
- const cells = yearsRow.map(({ year, disabled: outOfBounds, label }, cellIndex) => {
423
- const controlProps = resolveControlProps?.(year);
424
- // Both sides come from `getYearsData`'s canonical `YYYY-MM-DD`, so the `YYYY`
425
- // prefix compare is exactly the year-granularity `isSame` it replaces.
426
- const isYearInTabOrder =
427
- yearInTabOrder !== undefined && year.slice(0, 4) === yearInTabOrder.slice(0, 4);
428
- const disabled = outOfBounds || controlProps?.disabled;
340
+ const YearsListComponent = styleable<YearsListProps>(
341
+ YearsListFrame,
342
+ function YearsList(props, ref) {
343
+ const {
344
+ decade,
345
+ yearsListFormat = "YYYY",
346
+ locale,
347
+ minDate,
348
+ maxDate,
349
+ getYearControlProps,
350
+ __getControlRef,
351
+ __onControlKeyDown,
352
+ __onControlClick,
353
+ __onControlMouseEnter,
354
+ __preventFocus,
355
+ __stopPropagation,
356
+ withCellSpacing = true,
357
+ fullWidth = false,
358
+ size = "md",
359
+ styles,
360
+ ...rest
361
+ } = props;
362
+
363
+ // `__stopPropagation` is accepted for Mantine API parity; the cross-platform
364
+ // Escape handling lives at the picker/popover layer, so it is a no-op here
365
+ // (the same reservation `CalendarHeader`/`Month` make for it).
366
+ void __stopPropagation;
367
+
368
+ const ctx = useDatesContext();
369
+
370
+ const minDateString = minDate == null ? undefined : toDateString(minDate);
371
+ const maxDateString = maxDate == null ? undefined : toDateString(maxDate);
372
+
373
+ // 7. Typed per-slot accessor (dev-warns unknown keys against the known set).
374
+ const s = slotStyles<YearsListStyles>(styles, YEARS_LIST_SLOT_KEYS, "YearsList");
375
+
376
+ const resolvedLocale = ctx.getLocale(locale);
377
+
378
+ // The 10 cells' grid, bounds and LABELS depend only on the decade, the locale,
379
+ // the format and the min/max bounds — never on the selection — yet they were
380
+ // rebuilt every render, each cell paying a `dayjs(year).locale(…).format(…)`
381
+ // (parse + locale clone + locale-table format) for a label fixed for the decade.
382
+ const yearsInfo = useMemo(() => {
383
+ const grid = getYearsData(decade);
384
+ return {
385
+ grid,
386
+ cells: grid.map((row) =>
387
+ row.map((year) => ({
388
+ year,
389
+ disabled: isYearDisabled({ year, minDate: minDateString, maxDate: maxDateString }),
390
+ label: dayjs(year).locale(resolvedLocale).format(yearsListFormat),
391
+ })),
392
+ ),
393
+ };
394
+ }, [decade, minDateString, maxDateString, resolvedLocale, yearsListFormat]);
395
+
396
+ // ONE per-render cache shared by `getYearInTabOrder` (which consults the getter
397
+ // twice per year) and the cell loop below (a third time). Not memoized across
398
+ // renders — the getter closes over live selection state.
399
+ const resolveControlProps = memoizeByDate(getYearControlProps);
400
+
401
+ const yearInTabOrder = getYearInTabOrder({
402
+ years: yearsInfo.grid,
403
+ minDate: minDateString,
404
+ maxDate: maxDateString,
405
+ getYearControlProps: resolveControlProps,
406
+ });
407
+
408
+ const cellGap = withCellSpacing ? CELL_SPACING : 0;
409
+
410
+ // The cell memo can only bail out if every function prop it receives keeps a
411
+ // stable identity. All four of these arrive freshly built each render (the level
412
+ // group builds them per decade, `YearPicker` per render), so they are wrapped once
413
+ // here rather than being stabilised at each of their many call sites.
414
+ const onControlMouseEnter = useCallbackRef(__onControlMouseEnter);
415
+ const onControlClick = useCallbackRef(__onControlClick);
416
+ const onControlKeyDown = useCallbackRef(__onControlKeyDown);
417
+ const getControlRef = useCallbackRef(__getControlRef);
418
+
419
+ const cellSlotProps = s.get("cell");
420
+
421
+ const rows = yearsInfo.cells.map((yearsRow, rowIndex) => {
422
+ const cells = yearsRow.map(({ year, disabled: outOfBounds, label }, cellIndex) => {
423
+ const controlProps = resolveControlProps?.(year);
424
+ // Both sides come from `getYearsData`'s canonical `YYYY-MM-DD`, so the `YYYY`
425
+ // prefix compare is exactly the year-granularity `isSame` it replaces.
426
+ const isYearInTabOrder =
427
+ yearInTabOrder !== undefined && year.slice(0, 4) === yearInTabOrder.slice(0, 4);
428
+ const disabled = outOfBounds || controlProps?.disabled;
429
+
430
+ return (
431
+ <YearsListControlCell
432
+ key={year}
433
+ year={year}
434
+ label={label}
435
+ disabled={disabled}
436
+ rowIndex={rowIndex}
437
+ cellIndex={cellIndex}
438
+ tabIndex={__preventFocus || !isYearInTabOrder ? -1 : 0}
439
+ size={size}
440
+ fullWidth={fullWidth}
441
+ preventFocus={__preventFocus}
442
+ cellProps={cellSlotProps}
443
+ controlProps={controlProps}
444
+ mergedControlProps={s.merge("control", controlProps)}
445
+ onControlMouseEnter={onControlMouseEnter}
446
+ onControlClick={onControlClick}
447
+ onControlKeyDown={onControlKeyDown}
448
+ getControlRef={getControlRef}
449
+ />
450
+ );
451
+ });
429
452
 
430
453
  return (
431
- <YearsListControlCell
432
- key={year}
433
- year={year}
434
- label={label}
435
- disabled={disabled}
436
- rowIndex={rowIndex}
437
- cellIndex={cellIndex}
438
- tabIndex={__preventFocus || !isYearInTabOrder ? -1 : 0}
439
- size={size}
454
+ <YearsListRow
455
+ key={rowIndex}
456
+ role="row"
457
+ columnGap={cellGap}
440
458
  fullWidth={fullWidth}
441
- preventFocus={__preventFocus}
442
- cellProps={cellSlotProps}
443
- controlProps={controlProps}
444
- mergedControlProps={s.merge("control", controlProps)}
445
- onControlMouseEnter={onControlMouseEnter}
446
- onControlClick={onControlClick}
447
- onControlKeyDown={onControlKeyDown}
448
- getControlRef={getControlRef}
449
- />
459
+ {...s.get("row")}
460
+ >
461
+ {cells}
462
+ </YearsListRow>
450
463
  );
451
464
  });
452
465
 
453
466
  return (
454
- <YearsListRow
455
- key={rowIndex}
456
- role="row"
457
- columnGap={cellGap}
467
+ // The grid CONTAINER roles (`grid`/`row`/`cell`) are WEB-ONLY: React-Native's
468
+ // `accessibilityRole` has no `grid`/`row`/`gridcell` member (same root cause
469
+ // as the closed `role="cell"`→`gridcell` question), so there is no native
470
+ // counterpart to add here. Per-cell native announcement is instead carried
471
+ // by each `PickerControl`'s own `accessibilityRole`/`accessibilityState`.
472
+ <YearsListFrame
473
+ ref={ref}
474
+ role="grid"
475
+ rowGap={cellGap}
458
476
  fullWidth={fullWidth}
459
- {...s.get("row")}
477
+ {...s.get("root")}
478
+ {...rest}
460
479
  >
461
- {cells}
462
- </YearsListRow>
480
+ {rows}
481
+ </YearsListFrame>
463
482
  );
464
- });
465
-
466
- return (
467
- // The grid CONTAINER roles (`grid`/`row`/`cell`) are WEB-ONLY: React-Native's
468
- // `accessibilityRole` has no `grid`/`row`/`gridcell` member (same root cause
469
- // as the closed `role="cell"`→`gridcell` question), so there is no native
470
- // counterpart to add here. Per-cell native announcement is instead carried
471
- // by each `PickerControl`'s own `accessibilityRole`/`accessibilityState`.
472
- <YearsListFrame
473
- ref={ref}
474
- role="grid"
475
- rowGap={cellGap}
476
- fullWidth={fullWidth}
477
- {...s.get("root")}
478
- {...rest}
479
- >
480
- {rows}
481
- </YearsListFrame>
482
- );
483
- });
483
+ },
484
+ );
484
485
 
485
486
  YearsListComponent.displayName = "@knitui/dates/YearsList";
486
487