@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
@@ -1,11 +1,16 @@
1
1
  import * as React from "react";
2
2
 
3
3
  import { Text, UnstyledButton } from "@knitui/components";
4
- import { createStyledContext, type GetProps, styled, withStaticProperties } from "@knitui/core";
5
-
6
- import { type CalendarSize, CELL_FONT, CELL_WIDTH } from "../cell-metrics";
4
+ import {
5
+ createStyledContext,
6
+ type GetProps,
7
+ styleable,
8
+ styled,
9
+ withStaticProperties,
10
+ } from "@knitui/core";
11
+
12
+ import { type CalendarSize, cellFontVariant, pickerCellVariant } from "../cell-metrics";
7
13
  import { controlA11yProps } from "../internal/a11y";
8
- import { webCursor } from "../internal/web-cursor";
9
14
 
10
15
  /** PickerControl size — the kit's shared control size scale. */
11
16
  type PickerControlSize = CalendarSize;
@@ -20,84 +25,33 @@ type PickerControlSize = CalendarSize;
20
25
  // `height` to `"100%"` to fill a constrained calendar height — an unconstrained
21
26
  // parent resolves that percentage to "auto" and the cell would otherwise
22
27
  // collapse to its label's line-height (the same floor `Day` carries).
23
- const pickerCellVariant = {
24
- xxs: {
25
- height: CELL_WIDTH.xxs,
26
- minHeight: CELL_WIDTH.xxs,
27
- width: Math.round((CELL_WIDTH.xxs * 7) / 3),
28
- },
29
- xs: {
30
- height: CELL_WIDTH.xs,
31
- minHeight: CELL_WIDTH.xs,
32
- width: Math.round((CELL_WIDTH.xs * 7) / 3),
33
- },
34
- sm: {
35
- height: CELL_WIDTH.sm,
36
- minHeight: CELL_WIDTH.sm,
37
- width: Math.round((CELL_WIDTH.sm * 7) / 3),
38
- },
39
- md: {
40
- height: CELL_WIDTH.md,
41
- minHeight: CELL_WIDTH.md,
42
- width: Math.round((CELL_WIDTH.md * 7) / 3),
43
- },
44
- lg: {
45
- height: CELL_WIDTH.lg,
46
- minHeight: CELL_WIDTH.lg,
47
- width: Math.round((CELL_WIDTH.lg * 7) / 3),
48
- },
49
- xl: {
50
- height: CELL_WIDTH.xl,
51
- minHeight: CELL_WIDTH.xl,
52
- width: Math.round((CELL_WIDTH.xl * 7) / 3),
53
- },
54
- xxl: {
55
- height: CELL_WIDTH.xxl,
56
- minHeight: CELL_WIDTH.xxl,
57
- width: Math.round((CELL_WIDTH.xxl * 7) / 3),
58
- },
59
- } as const;
60
-
61
- const pickerFontVariant = {
62
- xxs: { fontSize: CELL_FONT.xxs },
63
- xs: { fontSize: CELL_FONT.xs },
64
- sm: { fontSize: CELL_FONT.sm },
65
- md: { fontSize: CELL_FONT.md },
66
- lg: { fontSize: CELL_FONT.lg },
67
- xl: { fontSize: CELL_FONT.xl },
68
- xxl: { fontSize: CELL_FONT.xxl },
69
- } as const;
70
-
71
28
  const PickerControlContext = createStyledContext<{ size: PickerControlSize }>({ size: "md" });
72
29
 
73
30
  /**
74
31
  * The month/year cell — the `Day` analogue for the year & decade levels — an
75
32
  * `UnstyledButton`-based control composed via `styled`. Accent comes from the
76
33
  * active theme's palette ramp via the `theme` prop (no Mantine `color` prop): a
77
- * selected control fills with `$color9`/`$color1` text; in-range controls take a
78
- * `$color4` tint with the range edges rounded by the `firstInRange`/`lastInRange`
34
+ * selected control fills with `color9`/`color1` text; in-range controls take a
35
+ * `color4` tint with the range edges rounded by the `firstInRange`/`lastInRange`
79
36
  * corner variants (the `inRange` base squares all four corners, the edge variants
80
37
  * round their own two — so a single control range gets all four back). States use
81
- * `hoverStyle`/`pressStyle` + a `disabled` variant, never a runtime hover flag.
38
+ * `hover:`/`press:` clauses + a `disabled` variant, never a runtime hover flag.
82
39
  *
83
- * Variant precedence relies on Tamagui applying active variants in declaration
84
- * order (later wins): `inRange` is declared before `firstInRange`/`lastInRange`
85
- * so the edges win on radius, and before `selected` so a selected endpoint wins
86
- * on background. Mantine precedence (selected over in-range, all suppressed when
40
+ * Variant precedence: Tamagui v3 applies active variants in PROP order (later
41
+ * wins), not declaration order: the wrapper passes `inRange` before
42
+ * `firstInRange`/`lastInRange` (the edges win on radius) and `selected` last. Mantine precedence (selected over in-range, all suppressed when
87
43
  * disabled) is applied in the component by gating the boolean flags.
88
44
  */
89
45
  const PickerControlFrame = styled(UnstyledButton.Frame, {
90
- name: "PickerControl",
46
+ displayName: "PickerControl",
91
47
  context: PickerControlContext,
92
48
  alignItems: "center",
93
49
  justifyContent: "center",
94
50
  borderWidth: 0,
95
51
  borderColor: "transparent",
96
- borderRadius: "$sm",
97
- backgroundColor: "transparent",
98
- ...webCursor("pointer"),
99
- hoverStyle: { backgroundColor: "$color2" },
100
- pressStyle: { backgroundColor: "$color3" },
52
+ borderRadius: "sm",
53
+ backgroundColor: "transparent hover:color2 press:color3",
54
+ cursor: "web:pointer",
101
55
 
102
56
  variants: {
103
57
  size: pickerCellVariant,
@@ -115,29 +69,25 @@ const PickerControlFrame = styled(UnstyledButton.Frame, {
115
69
  /** Control within a selected range — tinted background, squared corners. */
116
70
  inRange: {
117
71
  true: {
118
- backgroundColor: "$color4",
72
+ backgroundColor: "color4 hover:color5 press:color5",
119
73
  borderRadius: 0,
120
- hoverStyle: { backgroundColor: "$color5" },
121
- pressStyle: { backgroundColor: "$color5" },
122
74
  },
123
75
  },
124
76
 
125
77
  /** First control of a range — round the inline-start corners. */
126
78
  firstInRange: {
127
- true: { borderTopLeftRadius: "$sm", borderBottomLeftRadius: "$sm" },
79
+ true: { borderTopLeftRadius: "sm", borderBottomLeftRadius: "sm" },
128
80
  },
129
81
 
130
82
  /** Last control of a range — round the inline-end corners. */
131
83
  lastInRange: {
132
- true: { borderTopRightRadius: "$sm", borderBottomRightRadius: "$sm" },
84
+ true: { borderTopRightRadius: "sm", borderBottomRightRadius: "sm" },
133
85
  },
134
86
 
135
87
  /** Selected control — solid accent fill. */
136
88
  selected: {
137
89
  true: {
138
- backgroundColor: "$color9",
139
- hoverStyle: { backgroundColor: "$color10" },
140
- pressStyle: { backgroundColor: "$color8" },
90
+ backgroundColor: "color9 hover:color10 press:color8",
141
91
  },
142
92
  },
143
93
 
@@ -146,9 +96,8 @@ const PickerControlFrame = styled(UnstyledButton.Frame, {
146
96
  true: {
147
97
  opacity: 0.5,
148
98
  pointerEvents: "none",
149
- ...webCursor("not-allowed"),
150
- hoverStyle: { backgroundColor: "transparent" },
151
- pressStyle: { backgroundColor: "transparent" },
99
+ cursor: "web:not-allowed",
100
+ backgroundColor: "hover:transparent press:transparent",
152
101
  },
153
102
  },
154
103
  } as const,
@@ -160,22 +109,22 @@ const PickerControlFrame = styled(UnstyledButton.Frame, {
160
109
  * The control label — shares `size` via context, colour set per state.
161
110
  *
162
111
  * Colour is expressed as boolean VARIANTS, never a per-render dynamic `color`
163
- * style prop: the idle label is the neutral `$color`, and on the solid accent
164
- * fill a `selected` label flips to the contrast `$color1`. Keeping colour in
112
+ * style prop: the idle label is the neutral `color`, and on the solid accent
113
+ * fill a `selected` label flips to the contrast `color1`. Keeping colour in
165
114
  * variants — not a runtime ternary — keeps the cell compiler-safe (no dynamic
166
115
  * style prop for the optimiser to fold into the whole cell; mirrors `DayLabel`).
167
116
  */
168
117
  const PickerControlLabel = styled(Text, {
169
- name: "PickerControlLabel",
118
+ displayName: "PickerControlLabel",
170
119
  context: PickerControlContext,
171
120
  userSelect: "none",
172
- color: "$color",
121
+ color: "color",
173
122
  variants: {
174
- size: pickerFontVariant,
123
+ size: cellFontVariant,
175
124
 
176
125
  /** Selected control — contrast text on the solid accent fill. */
177
126
  selected: {
178
- true: { color: "$color1" },
127
+ true: { color: "color1" },
179
128
  },
180
129
  } as const,
181
130
 
@@ -184,6 +133,13 @@ const PickerControlLabel = styled(Text, {
184
133
 
185
134
  type PickerControlFrameProps = GetProps<typeof PickerControlFrame>;
186
135
 
136
+ /**
137
+ * `type="button"` — a runtime-only `<button>` attribute outside Tamagui's style
138
+ * types, spread from one frozen module constant (no excess-prop check, no
139
+ * per-render object).
140
+ */
141
+ const BUTTON_TYPE: { type: string } = Object.freeze({ type: "button" });
142
+
187
143
  export interface PickerControlProps extends Omit<
188
144
  PickerControlFrameProps,
189
145
  "size" | "selected" | "inRange" | "firstInRange" | "lastInRange" | "disabled" | "children"
@@ -221,7 +177,8 @@ export interface PickerControlProps extends Omit<
221
177
  * a11y: it is a button (`role="button"`); `aria-label` (via `...rest`),
222
178
  * `aria-selected` and `aria-disabled` are exposed for screen readers.
223
179
  */
224
- const PickerControlComponent = PickerControlFrame.styleable<PickerControlProps>(
180
+ const PickerControlComponent = styleable<PickerControlProps>(
181
+ PickerControlFrame,
225
182
  function PickerControl(props, ref) {
226
183
  const {
227
184
  children,
@@ -247,18 +204,16 @@ const PickerControlComponent = PickerControlFrame.styleable<PickerControlProps>(
247
204
  const content = children;
248
205
  const isTextContent = typeof content === "string" || typeof content === "number";
249
206
 
250
- // `type` is a runtime-only `<button>` attribute outside Tamagui's style types;
251
- // narrow via a precise local object (spread → no excess-prop check).
252
- const elementProps: { type: string } = { type: "button" };
253
-
254
207
  return (
255
208
  <PickerControlFrame
256
209
  ref={ref}
257
210
  size={size}
258
- selected={isSelected}
211
+ // v3 applies variants in PROP ORDER (later wins): inRange squares the
212
+ // corners, the edges round theirs after it, `selected` wins last.
259
213
  inRange={isInRange}
260
214
  firstInRange={isFirstInRange}
261
215
  lastInRange={isLastInRange}
216
+ selected={isSelected}
262
217
  disabled={disabled}
263
218
  fullWidth={fullWidth}
264
219
  role="button"
@@ -274,7 +229,7 @@ const PickerControlComponent = PickerControlFrame.styleable<PickerControlProps>(
274
229
  disabled,
275
230
  })}
276
231
  render="button"
277
- {...elementProps}
232
+ {...BUTTON_TYPE}
278
233
  {...rest}
279
234
  >
280
235
  {isTextContent ? (
@@ -25,7 +25,7 @@
25
25
  // 12 interaction styling (`pointer` cursor, disabled state) is the `InputBase`
26
26
  // trigger's; `readOnly`/`disabled` keep the dropdown from opening.
27
27
  // 13 a typed `forwardRef` forwards the ref to the trigger element (the
28
- // sibling-picker norm; `.styleable` is reserved for components that own a
28
+ // sibling-picker norm; `styleable()` is reserved for components that own a
29
29
  // styled Frame, which this shell does not).
30
30
  // 15 COMPILER-SAFE show/hide: the dropdown body is mounted via a CONDITIONAL
31
31
  // SUBTREE (`!isModal ? <Popover.Dropdown>…`) and the picker children are
@@ -3,62 +3,51 @@ import * as React from "react";
3
3
  import { Text, UnstyledButton } from "@knitui/components";
4
4
  import { createStyledContext, type GetProps, styled, type TamaguiElement } from "@knitui/core";
5
5
 
6
- import { type CalendarSize, CELL_FONT } from "../cell-metrics";
6
+ import { type CalendarSize, cellFontVariant } from "../cell-metrics";
7
7
  import { controlA11yProps } from "../internal/a11y";
8
8
  import { hasPreventDefault } from "../internal/has-prevent-default";
9
- import { webCursor } from "../internal/web-cursor";
10
9
  import { padTime } from "../utils";
11
10
 
12
- const controlFontVariant = {
13
- xxs: { fontSize: CELL_FONT.xxs },
14
- xs: { fontSize: CELL_FONT.xs },
15
- sm: { fontSize: CELL_FONT.sm },
16
- md: { fontSize: CELL_FONT.md },
17
- lg: { fontSize: CELL_FONT.lg },
18
- xl: { fontSize: CELL_FONT.xl },
19
- xxl: { fontSize: CELL_FONT.xxl },
20
- } as const;
21
-
22
11
  const TimeControlContext = createStyledContext<{ size: CalendarSize }>({ size: "sm" });
23
12
 
24
13
  /**
25
14
  * A single selectable time-cell in a `TimeControlsList` dropdown column. Accent
26
15
  * comes from the active theme's palette ramp via the `theme` prop (no Mantine
27
- * `color` prop): the active control fills with `$color9`/`$color1` text — the
16
+ * `color` prop): the active control fills with `color9`/`color1` text — the
28
17
  * same convention as `PickerControl`/`TimeGridControl`. States use
29
- * `hoverStyle`/`pressStyle`, never a runtime hover flag.
18
+ * `hover:`/`press:` clauses, never a runtime hover flag.
30
19
  */
31
20
  const TimeControlFrame = styled(UnstyledButton.Frame, {
32
- name: "TimeControl",
21
+ displayName: "TimeControl",
33
22
  context: TimeControlContext,
34
23
  alignItems: "center",
35
24
  justifyContent: "center",
36
- borderRadius: "$sm",
37
- paddingVertical: "$xs",
38
- paddingHorizontal: "$sm",
39
- backgroundColor: "transparent",
40
- ...webCursor("pointer"),
41
- hoverStyle: { backgroundColor: "$color2" },
42
- pressStyle: { backgroundColor: "$color3" },
25
+ borderRadius: "sm",
26
+ paddingVertical: "xs",
27
+ paddingHorizontal: "sm",
28
+ backgroundColor: "transparent hover:color2 press:color3",
29
+ cursor: "web:pointer",
43
30
 
44
31
  variants: {
45
32
  /** Active option — solid accent fill. */
46
33
  active: {
47
34
  true: {
48
- backgroundColor: "$color9",
49
- hoverStyle: { backgroundColor: "$color10" },
50
- pressStyle: { backgroundColor: "$color8" },
35
+ backgroundColor: "color9 hover:color10 press:color8",
51
36
  },
52
37
  },
53
38
  } as const,
54
39
  });
55
40
 
56
41
  const TimeControlLabel = styled(Text, {
57
- name: "TimeControlLabel",
42
+ displayName: "TimeControlLabel",
58
43
  context: TimeControlContext,
59
44
  userSelect: "none",
45
+ color: "color",
60
46
  variants: {
61
- size: controlFontVariant,
47
+ size: cellFontVariant,
48
+
49
+ /** On the active accent fill, the label flips to the contrast colour. */
50
+ active: { true: { color: "color1" } },
62
51
  } as const,
63
52
 
64
53
  defaultVariants: { size: "sm" },
@@ -114,7 +103,7 @@ function TimeControlImpl<Value extends number | string>(
114
103
  render="button"
115
104
  {...others}
116
105
  >
117
- <TimeControlLabel size={size} color={active ? "$color1" : "$color"}>
106
+ <TimeControlLabel size={size} active={active}>
118
107
  {label}
119
108
  </TimeControlLabel>
120
109
  </TimeControlFrame>
@@ -94,7 +94,7 @@ const TimeControlsListContext = createStyledContext<{ size: CalendarSize }>({ si
94
94
 
95
95
  /** The inner column of controls (web `role="list"`). */
96
96
  const TimeControlsListColumn = styled(Box, {
97
- name: "TimeControlsListColumn",
97
+ displayName: "TimeControlsListColumn",
98
98
  context: TimeControlsListContext,
99
99
  gap: CELL_SPACING,
100
100
  paddingHorizontal: CELL_SPACING,
@@ -26,14 +26,15 @@ import {
26
26
  type GetProps,
27
27
  slotStyles,
28
28
  type SlotStyles,
29
+ styleable,
29
30
  styled,
30
31
  withStaticProperties,
31
32
  } from "@knitui/core";
32
- import { useUncontrolled } from "@knitui/hooks";
33
+ import { useCallbackRef, useUncontrolled } from "@knitui/hooks";
33
34
 
34
- import { type CalendarSize, CELL_FONT, CELL_WIDTH } from "../cell-metrics";
35
+ import { type CalendarSize, cellFontVariant, cellMinHeightVariant } from "../cell-metrics";
35
36
  import { controlA11yProps } from "../internal/a11y";
36
- import { webCursor } from "../internal/web-cursor";
37
+ import { areCellPropsEqual } from "../internal/are-cell-props-equal";
37
38
  import type { TimePickerAmPmLabels, TimePickerFormat } from "../types";
38
39
  import { getFormattedTime, isSameTime } from "../utils";
39
40
  import { isTimeAfter, isTimeBefore } from "./compare-time/compare-time";
@@ -54,70 +55,46 @@ const TimeGridContext = createStyledContext<{ size: CalendarSize }>({ size: "sm"
54
55
  // (`CELL_WIDTH`/`CELL_FONT`) — the calendar twin of components' `controlMetrics`
55
56
  // — expressed with raw ladder values at module-load (NOT `getTokenValue`, which
56
57
  // needs the live config).
57
- const controlSizeVariant = {
58
- xxs: { minHeight: CELL_WIDTH.xxs },
59
- xs: { minHeight: CELL_WIDTH.xs },
60
- sm: { minHeight: CELL_WIDTH.sm },
61
- md: { minHeight: CELL_WIDTH.md },
62
- lg: { minHeight: CELL_WIDTH.lg },
63
- xl: { minHeight: CELL_WIDTH.xl },
64
- xxl: { minHeight: CELL_WIDTH.xxl },
65
- } as const;
66
-
67
- const controlFontVariant = {
68
- xxs: { fontSize: CELL_FONT.xxs },
69
- xs: { fontSize: CELL_FONT.xs },
70
- sm: { fontSize: CELL_FONT.sm },
71
- md: { fontSize: CELL_FONT.md },
72
- lg: { fontSize: CELL_FONT.lg },
73
- xl: { fontSize: CELL_FONT.xl },
74
- xxl: { fontSize: CELL_FONT.xxl },
75
- } as const;
76
-
77
58
  /* -------------------------------------------------------------------------- */
78
59
  /* Styled parts (#5) */
79
60
  /* -------------------------------------------------------------------------- */
80
61
 
81
62
  /** The host frame establishing the shared `size` context (web `role="group"`). */
82
63
  const TimeGridFrame = styled(Box, {
83
- name: "TimeGrid",
64
+ displayName: "TimeGrid",
84
65
  context: TimeGridContext,
85
66
  });
86
67
 
87
68
  /**
88
69
  * A single time-option button. Accent comes from the active theme's palette ramp
89
70
  * via the `theme` prop (no Mantine `color` prop): a selected control fills with
90
- * `$color9` and prints `$color1` text (checklist #4). States use
91
- * `hoverStyle`/`pressStyle` + a `disabled` variant, never a runtime hover flag
71
+ * `color9` and prints `color1` text (checklist #4). States use
72
+ * `hover:`/`press:` clauses + a `disabled` variant, never a runtime hover flag
92
73
  * (#12) — mirroring `PickerControl`.
93
74
  */
94
75
  const TimeGridControlFrame = styled(UnstyledButton.Frame, {
95
- name: "TimeGridControl",
76
+ displayName: "TimeGridControl",
96
77
  context: TimeGridContext,
97
78
  alignItems: "center",
98
79
  justifyContent: "center",
99
80
  flexGrow: 1,
100
81
  flexBasis: 0,
101
82
  borderWidth: 1,
102
- borderColor: "$borderColor",
103
- borderRadius: "$sm",
104
- backgroundColor: "transparent",
105
- paddingVertical: "$xs",
106
- paddingHorizontal: "$sm",
107
- ...webCursor("pointer"),
108
- hoverStyle: { backgroundColor: "$color2" },
109
- pressStyle: { backgroundColor: "$color3" },
83
+ borderColor: "borderColor",
84
+ borderRadius: "sm",
85
+ backgroundColor: "transparent hover:color2 press:color3",
86
+ paddingVertical: "xs",
87
+ paddingHorizontal: "sm",
88
+ cursor: "web:pointer",
110
89
 
111
90
  variants: {
112
- size: controlSizeVariant,
91
+ size: cellMinHeightVariant,
113
92
 
114
93
  /** Selected option — solid accent fill. */
115
94
  selected: {
116
95
  true: {
117
- backgroundColor: "$color9",
118
- borderColor: "$color9",
119
- hoverStyle: { backgroundColor: "$color10" },
120
- pressStyle: { backgroundColor: "$color8" },
96
+ backgroundColor: "color9 hover:color10 press:color8",
97
+ borderColor: "color9",
121
98
  },
122
99
  },
123
100
 
@@ -126,9 +103,8 @@ const TimeGridControlFrame = styled(UnstyledButton.Frame, {
126
103
  true: {
127
104
  opacity: 0.5,
128
105
  pointerEvents: "none",
129
- ...webCursor("not-allowed"),
130
- hoverStyle: { backgroundColor: "transparent" },
131
- pressStyle: { backgroundColor: "transparent" },
106
+ cursor: "web:not-allowed",
107
+ backgroundColor: "hover:transparent press:transparent",
132
108
  },
133
109
  },
134
110
  } as const,
@@ -142,15 +118,15 @@ const TimeGridControlFrame = styled(UnstyledButton.Frame, {
142
118
  * web optimiser can never fold a hide-value class onto the whole cell.
143
119
  */
144
120
  const TimeGridControlLabel = styled(Text, {
145
- name: "TimeGridControlLabel",
121
+ displayName: "TimeGridControlLabel",
146
122
  context: TimeGridContext,
147
123
  userSelect: "none",
148
- color: "$color",
124
+ color: "color",
149
125
  variants: {
150
- size: controlFontVariant,
126
+ size: cellFontVariant,
151
127
 
152
128
  /** On the selected accent fill, the label flips to the contrast colour. */
153
- selected: { true: { color: "$color1" } },
129
+ selected: { true: { color: "color1" } },
154
130
  } as const,
155
131
 
156
132
  defaultVariants: { size: "sm" },
@@ -163,13 +139,24 @@ const TimeGridControlLabel = styled(Text, {
163
139
  /** Props passed to a single control via `getControlProps` / `styles.control`. */
164
140
  type TimeGridControlPassthrough = Partial<GetProps<typeof UnstyledButton>>;
165
141
 
166
- interface TimeGridControlProps extends Omit<GetProps<typeof TimeGridControlFrame>, "children"> {
142
+ type TimeGridPressEvent = Parameters<NonNullable<TimeGridControlPassthrough["onPress"]>>[0];
143
+
144
+ interface TimeGridControlProps extends Omit<
145
+ GetProps<typeof TimeGridControlFrame>,
146
+ "children" | "selected" | "disabled" | "size" | "onPress"
147
+ > {
167
148
  /** Time value in 24h format (`"HH:mm[:ss]"`). */
168
149
  time: string;
169
150
 
170
151
  /** Whether this option is the active value. */
171
152
  active: boolean;
172
153
 
154
+ /** Whether this option is disabled (bounds / `disableTime` / `disabled`). */
155
+ disabled: boolean;
156
+
157
+ /** Control size. */
158
+ size: CalendarSize;
159
+
173
160
  /** Clock display mode. */
174
161
  format: TimePickerFormat;
175
162
 
@@ -181,17 +168,31 @@ interface TimeGridControlProps extends Omit<GetProps<typeof TimeGridControlFrame
181
168
 
182
169
  /** Props spread onto the inner label (carries `styles.label`). */
183
170
  labelProps?: GetProps<typeof TimeGridControlLabel>;
171
+
172
+ /** The consumer's own `getControlProps(time).onPress`, called before ours. */
173
+ consumerOnPress?: TimeGridControlPassthrough["onPress"];
174
+
175
+ /** Stable (grid-level) press handler — keeps the memo boundary intact. */
176
+ onSelect: (time: string, active: boolean) => void;
184
177
  }
185
178
 
186
- function TimeGridControl({
179
+ /**
180
+ * One time option, memoized. A selection change re-renders the grid, but only
181
+ * the two cells whose `active` flag moved need to re-render: the press handler
182
+ * is a stable grid-level callback (`onSelect`), and `areCellPropsEqual` looks one
183
+ * level into the freshly built `labelProps` / slot objects.
184
+ */
185
+ const TimeGridControl = React.memo(function TimeGridControl({
187
186
  time,
188
187
  active,
189
188
  format,
190
189
  amPmLabels,
191
190
  withSeconds,
192
191
  disabled,
193
- size = "sm",
192
+ size,
194
193
  labelProps,
194
+ consumerOnPress,
195
+ onSelect,
195
196
  ...others
196
197
  }: TimeGridControlProps) {
197
198
  const label = getFormattedTime({ value: time, format, amPmLabels, withSeconds });
@@ -214,13 +215,17 @@ function TimeGridControl({
214
215
  size={size}
215
216
  render="button"
216
217
  {...others}
218
+ onPress={(event: TimeGridPressEvent) => {
219
+ consumerOnPress?.(event);
220
+ onSelect(time, active);
221
+ }}
217
222
  >
218
223
  <TimeGridControlLabel size={size} selected={active} {...labelProps}>
219
224
  {label}
220
225
  </TimeGridControlLabel>
221
226
  </TimeGridControlFrame>
222
227
  );
223
- }
228
+ }, areCellPropsEqual);
224
229
 
225
230
  /* -------------------------------------------------------------------------- */
226
231
  /* TimeGrid */
@@ -318,7 +323,7 @@ const DEFAULT_AM_PM_LABELS: TimePickerAmPmLabels = { am: "AM", pm: "PM" };
318
323
  * `useUncontrolled`; each option is labelled through the shared `getFormattedTime`
319
324
  * (so `12h` shows AM/PM and `withSeconds` adds `:ss`); `minTime`/`maxTime`/
320
325
  * `disableTime`/`disabled` gate the controls; selection is styled from the active
321
- * Tamagui theme ramp (`$color9`/`$color1`).
326
+ * Tamagui theme ramp (`color9`/`color1`).
322
327
  *
323
328
  * Per-control sizing/colour/interaction live in the folder-local `TimeGridControl`
324
329
  * leaf (delegated); this lays out the grid, shares `size` via context, and offers
@@ -329,7 +334,7 @@ const DEFAULT_AM_PM_LABELS: TimePickerAmPmLabels = { am: "AM", pm: "PM" };
329
334
  * @example
330
335
  * <TimeGrid data={["10:00", "12:30", "18:00"]} defaultValue="10:00" onChange={setValue} />
331
336
  */
332
- const TimeGridComponent = TimeGridFrame.styleable<TimeGridProps>(function TimeGrid(props, ref) {
337
+ const TimeGridComponent = styleable<TimeGridProps>(TimeGridFrame, function TimeGrid(props, ref) {
333
338
  const {
334
339
  data,
335
340
  value,
@@ -362,6 +367,15 @@ const TimeGridComponent = TimeGridFrame.styleable<TimeGridProps>(function TimeGr
362
367
  const s = slotStyles<TimeGridStyles>(styles, TIME_GRID_SLOT_KEYS, "TimeGrid");
363
368
  const labelStyles = s.get("label");
364
369
 
370
+ // One stable press handler for every control (reads the live value through
371
+ // the ref), so a selection change only re-renders the cells whose state moved.
372
+ const onSelect = useCallbackRef((time: string, active: boolean) => {
373
+ const nextValue = allowDeselect && active ? null : time;
374
+ if (nextValue !== _value) {
375
+ setValue(nextValue);
376
+ }
377
+ });
378
+
365
379
  const controls = data.map((time) => {
366
380
  // 10. Bounds + per-time disabling gate each control.
367
381
  const isDisabled =
@@ -387,15 +401,11 @@ const TimeGridComponent = TimeGridFrame.styleable<TimeGridProps>(function TimeGr
387
401
  size={size}
388
402
  labelProps={labelStyles}
389
403
  // explicit beats sugar: the `control` slot sits UNDER per-item
390
- // `getControlProps`, and the consumer's own `onPress` is preserved.
404
+ // `getControlProps`, and the consumer's own `onPress` is preserved
405
+ // (called before ours, inside the leaf).
391
406
  {...s.merge("control", controlProps)}
392
- onPress={(event: Parameters<NonNullable<TimeGridControlPassthrough["onPress"]>>[0]) => {
393
- controlProps?.onPress?.(event);
394
- const nextValue = allowDeselect && active ? null : time;
395
- if (nextValue !== _value) {
396
- setValue(nextValue);
397
- }
398
- }}
407
+ consumerOnPress={controlProps?.onPress}
408
+ onSelect={onSelect}
399
409
  />
400
410
  );
401
411
  });
@@ -33,7 +33,7 @@
33
33
  // label→input association are wired by `InputBase` on both platforms;
34
34
  // no extra `accessibility*` axis is needed (unlike the interactive
35
35
  // `Day`/segment leaves).
36
- // 12/13/14/15 — interaction styling, `.styleable`, slot markers and the
36
+ // 12/13/14/15 — interaction styling, `styleable()`, slot markers and the
37
37
  // compiler-safe show/hide trap all belong to styled parts; this leaf
38
38
  // owns none. Ref forwards to the `InputBase` host via `forwardRef`.
39
39
  // ───────────────────────────────────────────────────────────────────────────