@knitui/dates 0.13.0 → 1.0.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 +5 -5
  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
@@ -13,7 +13,7 @@
13
13
  // 1. File header documenting provenance + cross-platform stance.
14
14
  // 2. `createStyledContext` to share `size` across every styled part.
15
15
  // 3. Sizing DERIVED from the shared `cell-metrics` ladders (no magic numbers).
16
- // 4. Theme-ramp colors only ($colorN) — `theme="red"` recolors, zero per-comp logic.
16
+ // 4. Theme-ramp colors only (colorN) — `theme="red"` recolors, zero per-comp logic.
17
17
  // 5. A styled Frame + leaf parts, each carrying the context.
18
18
  // 6. Marker-slot composition (`createSlot`/`defineSlots` from `@knitui/core`).
19
19
  // 7. Per-slot `styles={{…}}` sugar (`SlotStyles` + `slotStyles().merge`) PLUS the
@@ -22,8 +22,8 @@
22
22
  // 9. Locale + date formatting via `useDatesContext` + dayjs.
23
23
  // 10. min/max bounds via the shared date utils.
24
24
  // 11. Native + web a11y set side-by-side (`controlA11yProps` + `aria-*`).
25
- // 12. `webCursor`, real `hoverStyle`/`pressStyle`, a `disabled` variant.
26
- // 13. `.styleable` wrapper forwarding a ref + style props (the dates norm).
25
+ // 12. `web:` cursor clauses, real `hover:`/`press:` clauses, a `disabled` variant.
26
+ // 13. `styleable()` wrapper forwarding a ref + style props (the dates norm).
27
27
  // 14. `withStaticProperties` exposing parts + slot markers.
28
28
  // 15. A documented "compiler-safe styling" pitfall (the `_o-0` trap).
29
29
  //
@@ -42,15 +42,15 @@ import {
42
42
  type GetProps,
43
43
  slotStyles,
44
44
  type SlotStyles,
45
+ styleable,
45
46
  styled,
46
47
  withStaticProperties,
47
48
  } from "@knitui/core";
48
49
  import { useUncontrolled } from "@knitui/hooks";
49
50
 
50
- import { type CalendarSize, CELL_FONT, CELL_WIDTH } from "../cell-metrics";
51
+ import { type CalendarSize, cellFontVariant, cellMinWidthVariant } from "../cell-metrics";
51
52
  import { useDatesContext } from "../DatesProvider";
52
53
  import { controlA11yProps } from "../internal/a11y";
53
- import { webCursor } from "../internal/web-cursor";
54
54
  import type { DateStringValue } from "../types";
55
55
  import { isAfterMinDate, isBeforeMaxDate, toDateString } from "../utils";
56
56
 
@@ -67,77 +67,53 @@ const ExampleControlContext = createStyledContext<{ size: CalendarSize }>({ size
67
67
  // Each variant maps the `xxs…xxl` keys onto a metric so retuning the ladder moves
68
68
  // every component together. Express these with raw values from the ladder (they
69
69
  // resolve at module-load) — NOT `getTokenValue`, which needs the live config.
70
- const optionMinWidthVariant = {
71
- xxs: { minWidth: CELL_WIDTH.xxs },
72
- xs: { minWidth: CELL_WIDTH.xs },
73
- sm: { minWidth: CELL_WIDTH.sm },
74
- md: { minWidth: CELL_WIDTH.md },
75
- lg: { minWidth: CELL_WIDTH.lg },
76
- xl: { minWidth: CELL_WIDTH.xl },
77
- xxl: { minWidth: CELL_WIDTH.xxl },
78
- } as const;
79
-
80
- const optionFontVariant = {
81
- xxs: { fontSize: CELL_FONT.xxs },
82
- xs: { fontSize: CELL_FONT.xs },
83
- sm: { fontSize: CELL_FONT.sm },
84
- md: { fontSize: CELL_FONT.md },
85
- lg: { fontSize: CELL_FONT.lg },
86
- xl: { fontSize: CELL_FONT.xl },
87
- xxl: { fontSize: CELL_FONT.xxl },
88
- } as const;
89
-
90
70
  // ── 5. Styled parts ───────────────────────────────────────────────────────────
91
71
 
92
72
  /** The root row: optional lead · option strip · optional trail. */
93
73
  const ExampleControlFrame = styled(Box, {
94
- name: "ExampleControl",
74
+ displayName: "ExampleControl",
95
75
  context: ExampleControlContext,
96
76
  flexDirection: "row",
97
77
  alignItems: "center",
98
- gap: "$xs",
78
+ gap: "xs",
99
79
  });
100
80
 
101
81
  /** The strip wrapping the option buttons. */
102
82
  const ExampleControlOptions = styled(Box, {
103
- name: "ExampleControlOptions",
83
+ displayName: "ExampleControlOptions",
104
84
  flexDirection: "row",
105
85
  alignItems: "stretch",
106
- gap: "$xxs",
86
+ gap: "xxs",
107
87
  });
108
88
 
109
89
  /**
110
90
  * A single selectable option button.
111
91
  *
112
- * 4. Colors are theme-ramp tokens ONLY: idle text is the neutral `$color`, the
113
- * selected fill is the accent `$color9` with `$color1` contrast text. No hex,
92
+ * 4. Colors are theme-ramp tokens ONLY: idle text is the neutral `color`, the
93
+ * selected fill is the accent `color9` with `color1` contrast text. No hex,
114
94
  * no `color` prop — `theme="red"` on (or above) the control recolors it.
115
- * 12. Interaction lives in real Tamagui pseudo-state (`hoverStyle`/`pressStyle`)
95
+ * 12. Interaction lives in real Tamagui pseudo-state (`hover:`/`press:` clauses)
116
96
  * and a `disabled` variant (Mantine parity: 0.3 + non-interactive), never a
117
97
  * runtime `onHoverIn` state machine.
118
98
  */
119
99
  const ExampleControlOption = styled(UnstyledButton.Frame, {
120
- name: "ExampleControlOption",
100
+ displayName: "ExampleControlOption",
121
101
  context: ExampleControlContext,
122
102
  alignItems: "center",
123
103
  justifyContent: "center",
124
- paddingVertical: "$xs",
125
- paddingHorizontal: "$xs",
126
- borderRadius: "$sm",
127
- backgroundColor: "transparent",
128
- ...webCursor("pointer"),
129
- hoverStyle: { backgroundColor: "$color2" },
130
- pressStyle: { backgroundColor: "$color3" },
104
+ paddingVertical: "xs",
105
+ paddingHorizontal: "xs",
106
+ borderRadius: "sm",
107
+ backgroundColor: "transparent hover:color2 press:color3",
108
+ cursor: "web:pointer",
131
109
 
132
110
  variants: {
133
- size: optionMinWidthVariant,
111
+ size: cellMinWidthVariant,
134
112
 
135
113
  /** Selected option — solid accent fill. */
136
114
  selected: {
137
115
  true: {
138
- backgroundColor: "$color9",
139
- hoverStyle: { backgroundColor: "$color10" },
140
- pressStyle: { backgroundColor: "$color8" },
116
+ backgroundColor: "color9 hover:color10 press:color8",
141
117
  },
142
118
  },
143
119
 
@@ -146,9 +122,8 @@ const ExampleControlOption = styled(UnstyledButton.Frame, {
146
122
  true: {
147
123
  opacity: 0.3,
148
124
  pointerEvents: "none",
149
- ...webCursor("not-allowed"),
150
- hoverStyle: { backgroundColor: "transparent" },
151
- pressStyle: { backgroundColor: "transparent" },
125
+ cursor: "web:not-allowed",
126
+ backgroundColor: "hover:transparent press:transparent",
152
127
  },
153
128
  },
154
129
  } as const,
@@ -170,22 +145,22 @@ const ExampleControlOption = styled(UnstyledButton.Frame, {
170
145
  * a per-render dynamic `opacity`/`display` style prop.
171
146
  */
172
147
  const ExampleControlLabel = styled(Text, {
173
- name: "ExampleControlLabel",
148
+ displayName: "ExampleControlLabel",
174
149
  context: ExampleControlContext,
175
150
  userSelect: "none",
176
- color: "$color",
151
+ color: "color",
177
152
  variants: {
178
- size: optionFontVariant,
153
+ size: cellFontVariant,
179
154
 
180
155
  /** On the selected accent fill, the label flips to the contrast color. */
181
- selected: { true: { color: "$color1" } },
156
+ selected: { true: { color: "color1" } },
182
157
  } as const,
183
158
  defaultVariants: { size: "md" },
184
159
  });
185
160
 
186
161
  /** Lead/trail section wrapper — a real styled part for the section props to land on. */
187
162
  const ExampleControlSection = styled(Box, {
188
- name: "ExampleControlSection",
163
+ displayName: "ExampleControlSection",
189
164
  context: ExampleControlContext,
190
165
  flexDirection: "row",
191
166
  alignItems: "center",
@@ -304,7 +279,8 @@ export interface ExampleControlProps extends ExampleControlFrameProps {
304
279
  * onChange={setValue}
305
280
  * />
306
281
  */
307
- const ExampleControlComponent = ExampleControlFrame.styleable<ExampleControlProps>(
282
+ const ExampleControlComponent = styleable<ExampleControlProps>(
283
+ ExampleControlFrame,
308
284
  function ExampleControl(props, ref) {
309
285
  const {
310
286
  data,
@@ -19,7 +19,7 @@ The numbered rules below map 1:1 onto the numbered comments in
19
19
  (`CELL_WIDTH`/`CELL_FONT`) — the calendar twin of components' `controlMetrics`.
20
20
  No magic pixels. Express variants with raw ladder values at module-load (never
21
21
  `getTokenValue`, which needs the live config).
22
- 4. **Theme-ramp colors only.** `$color1…$color12` / semantic neutrals — never hex,
22
+ 4. **Theme-ramp colors only.** `color1…color12` / semantic neutrals — never hex,
23
23
  never a Mantine-style `color` prop. Accent is the Tamagui `theme=` prop, so
24
24
  `theme="red"` recolors with zero per-component logic.
25
25
  5. **Styled Frame + leaf parts**, each opting into the context.
@@ -38,10 +38,10 @@ props on a composed part` — **explicit beats sugar**.
38
38
  normalized through `toDateString` once.
39
39
  11. **A11y on both axes.** Web (`role`/`aria-*`) and native (`accessibility*` via
40
40
  `internal/a11y` `controlA11yProps`) set side-by-side — neither replaces the other.
41
- 12. **Interaction in style, not state.** `webCursor`, real `hoverStyle`/`pressStyle`,
41
+ 12. **Interaction in style, not state.** `web:` cursor clauses, real `hover:`/`press:` clauses,
42
42
  a `disabled` variant (Mantine parity: 0.3 + `pointerEvents: "none"`). No runtime
43
43
  hover state machines.
44
- 13. **`.styleable` wrapper** forwarding a ref + the frame's style props (the dates norm).
44
+ 13. **`styleable()` wrapper** forwarding a ref + the frame's style props (the dates norm).
45
45
  14. **`withStaticProperties`** exposing the slot markers (single source of truth) and
46
46
  the styled parts, so consumers can compose and `styled(X.Part, …)`.
47
47
  15. **Compiler-safe styling.** The `apps/web` build runs the Tamagui optimizing
@@ -1,52 +1,126 @@
1
1
  // Shared cell-size ladders for every calendar grid component (Day, WeekdaysRow,
2
- // Month, PickerControl). ONE source of truth for the `xxs…xxl → width/font`
3
- // ladders that were previously duplicated per component. INTERNAL — deliberately
4
- // NOT re-exported from the public `src/index.ts` barrel.
2
+ // Month, PickerControl, CalendarHeader, MiniCalendar, TimeGrid, TimeControlsList,
3
+ // TimePresets). ONE source of truth: `CELL_METRICS` below — the calendar twin of
4
+ // components' `controlMetrics` — and every per-part variant map is DERIVED from it
5
+ // at module load into a plain, exact-key, literal-shaped object (Tamagui v3's
6
+ // fastest variant shape: static bodies, per-clause friendly, compiler-evaluable).
7
+ // INTERNAL — deliberately NOT re-exported from the public `src/index.ts` barrel.
5
8
  //
6
- // Mirrors @mantine/dates' control sizing: a square cell width per size and a
7
- // proportional label font (≈ size / 2.8). PickerControl derives its wider
8
- // month/year cell from `CELL_WIDTH` too (Mantine: width = height * 7/3).
9
+ // Why raw pixels, not control-height tokens: a calendar cell is not a control.
10
+ // It mirrors @mantine/dates' grid sizing (square cell per size, label ≈ size / 2.8),
11
+ // so a 7-column month at `md` is 7 × 42 = 294px. `controlMetrics`' heights
12
+ // (18…96) would make an `xxl` month 672px wide. The KEY scale (`xxs…xxl`,
13
+ // default `md`) is the kit's; only the numbers are calendar-specific.
9
14
  //
10
15
  // ─── THEMING: the accent palette-ramp convention (read before styling a cell) ───
11
16
  // Accent colour is ALWAYS the Tamagui `theme=` prop (e.g. `<DatePicker theme="blue" />`)
12
17
  // — there is NO Mantine-style `color` prop, and palette hex is NEVER hard-coded.
13
- // Every cell (Day, PickerControl, MiniCalendar days, TimeGrid/TimeControlsList
14
- // controls) reads the ACTIVE theme's ramp with this fixed mapping so they don't
15
- // drift:
16
- // $color9 solid accent — selected cell background
17
- // $color1 contrast text ON the solid accent (selected label)
18
- // $color4 / $color5 subtle accent tint — in-range background
19
- // $color2 / $color3 hover / press background (hoverStyle / pressStyle)
20
- // $color7 accent borders (e.g. the "today" outline)
21
- // $color11 accent text (unselected-but-accented label)
22
- // $background / $color / $borderColor semantic neutrals (idle cell)
23
- // States use `hoverStyle`/`pressStyle`/`focusVisibleStyle` + a `disabled` variant —
24
- // never runtime hover state, never a Pressable wrapper.
18
+ // Every cell reads the ACTIVE theme's ramp with this fixed mapping so they don't
19
+ // drift (v3 flat values — conditions live inside the property they change):
20
+ // color9 hover:color10 press:color8 solid accent — selected cell background
21
+ // color1 contrast text ON the solid accent
22
+ // color4 hover:color5 press:color5 subtle accent tint — in-range background
23
+ // transparent hover:color2 press:color3 idle cell background
24
+ // color7 accent borders (the "today" outline)
25
+ // color11 muted / accented label text
26
+ // background / color / borderColor semantic neutrals
27
+ // States are `hover:` / `press:` clauses + a `disabled` variant — never runtime
28
+ // hover state, never a Pressable wrapper. `cursor` is a `web:` clause (dropped on
29
+ // native by the style engine, no `isWeb` branching at module load).
25
30
 
26
31
  /** Calendar grid size — the kit's shared control size scale. */
27
32
  export type CalendarSize = "xxs" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
28
33
 
34
+ /** The size keys in ascending order. */
35
+ export const CALENDAR_SIZES = ["xxs", "xs", "sm", "md", "lg", "xl", "xxl"] as const;
36
+
37
+ /**
38
+ * THE canonical calendar-cell table. Every column is a raw px number.
39
+ *
40
+ * key cell font picker(7/3) header icon
41
+ * xxs 24 11 56 9 13
42
+ * xs 30 13 70 12 17
43
+ * sm 36 14 84 14 20
44
+ * md 42 15 98 16 23
45
+ * lg 48 17 112 18 26
46
+ * xl 54 19 126 21 30
47
+ * xxl 60 21 140 23 33
48
+ *
49
+ * `cell` is the square day cell (and the header control / column width), `font`
50
+ * the cell label (≈ cell / 2.8), `picker` the wide month/year cell
51
+ * (Mantine: width = height × 7/3, so a 3-column grid spans a 7-column month),
52
+ * `header` the level label (≈ cell / 2.6) and `icon` the chevron glyph (≈ 55%).
53
+ */
54
+ export const CELL_METRICS = {
55
+ xxs: { cell: 24, font: 11, picker: 56, header: 9, icon: 13 },
56
+ xs: { cell: 30, font: 13, picker: 70, header: 12, icon: 17 },
57
+ sm: { cell: 36, font: 14, picker: 84, header: 14, icon: 20 },
58
+ md: { cell: 42, font: 15, picker: 98, header: 16, icon: 23 },
59
+ lg: { cell: 48, font: 17, picker: 112, header: 18, icon: 26 },
60
+ xl: { cell: 54, font: 19, picker: 126, header: 21, icon: 30 },
61
+ xxl: { cell: 60, font: 21, picker: 140, header: 23, icon: 33 },
62
+ } as const satisfies Record<CalendarSize, Record<string, number>>;
63
+
29
64
  /** Square column/cell width per `size`, shared so every grid's columns align. */
30
- export const CELL_WIDTH: Record<CalendarSize, number> = {
31
- xxs: 24,
32
- xs: 30,
33
- sm: 36,
34
- md: 42,
35
- lg: 48,
36
- xl: 54,
37
- xxl: 60,
38
- };
65
+ export const CELL_WIDTH: Record<CalendarSize, number> = ladder((k) => CELL_METRICS[k].cell);
39
66
 
40
67
  /** Cell label font per `size` (≈ size / 2.8, matching the day label). */
41
- export const CELL_FONT: Record<CalendarSize, number> = {
42
- xxs: 11,
43
- xs: 13,
44
- sm: 14,
45
- md: 15,
46
- lg: 17,
47
- xl: 19,
48
- xxl: 21,
49
- };
68
+ export const CELL_FONT: Record<CalendarSize, number> = ladder((k) => CELL_METRICS[k].font);
50
69
 
51
70
  /** Gap inserted between cells/rows when `withCellSpacing` is on. */
52
71
  export const CELL_SPACING = 2;
72
+
73
+ /** Build one exact-key `xxs…xxl` table at module scope. */
74
+ function ladder<T>(body: (key: CalendarSize) => T): Record<CalendarSize, T> {
75
+ const out = {} as Record<CalendarSize, T>;
76
+ for (const key of CALENDAR_SIZES) out[key] = body(key);
77
+ return out;
78
+ }
79
+
80
+ // ── Derived variant maps (static exact-key bodies; spread only at module scope) ──
81
+
82
+ /**
83
+ * Square cell. `minHeight` mirrors `height` so it acts as a FLOOR: when
84
+ * `fullWidth` swaps `height` to `"100%"` to fill a constrained calendar height,
85
+ * an UNCONSTRAINED parent resolves that percentage to "auto" and the cell would
86
+ * otherwise collapse to its label's line-height.
87
+ */
88
+ export const cellSquareVariant = ladder((k) => ({
89
+ width: CELL_METRICS[k].cell,
90
+ height: CELL_METRICS[k].cell,
91
+ minHeight: CELL_METRICS[k].cell,
92
+ }));
93
+
94
+ /** The wide month/year cell (`PickerControl`), with the same `minHeight` floor. */
95
+ export const pickerCellVariant = ladder((k) => ({
96
+ width: CELL_METRICS[k].picker,
97
+ height: CELL_METRICS[k].cell,
98
+ minHeight: CELL_METRICS[k].cell,
99
+ }));
100
+
101
+ /** Cell height only (header level control). */
102
+ export const cellHeightVariant = ladder((k) => ({ height: CELL_METRICS[k].cell }));
103
+
104
+ /** Cell min-height only (time-grid controls grow with their label). */
105
+ export const cellMinHeightVariant = ladder((k) => ({ minHeight: CELL_METRICS[k].cell }));
106
+
107
+ /** Column width only (week-number column). */
108
+ export const cellWidthVariant = ladder((k) => ({ width: CELL_METRICS[k].cell }));
109
+
110
+ /** Column min-width only (mini-calendar days, example options). */
111
+ export const cellMinWidthVariant = ladder((k) => ({ minWidth: CELL_METRICS[k].cell }));
112
+
113
+ /** Cell label font. */
114
+ export const cellFontVariant = ladder((k) => ({ fontSize: CELL_METRICS[k].font }));
115
+
116
+ /** Weekday header column: cell width + label font, so it lines up with the days. */
117
+ export const weekdayCellVariant = ladder((k) => ({
118
+ width: CELL_METRICS[k].cell,
119
+ fontSize: CELL_METRICS[k].font,
120
+ }));
121
+
122
+ /** Header level label font. */
123
+ export const headerFontVariant = ladder((k) => ({ fontSize: CELL_METRICS[k].header }));
124
+
125
+ /** Chevron glyph font. */
126
+ export const iconFontVariant = ladder((k) => ({ fontSize: CELL_METRICS[k].icon }));
@@ -2,7 +2,7 @@
2
2
  // barrel. Shared by every interactive leaf (`Day`, `PickerControl`, `TimeGrid`'s
3
3
  // control, `CalendarHeader`, `MiniCalendar`) so the React-Native `accessibility*`
4
4
  // shape lives in ONE place and can't drift across call sites — the same
5
- // extraction discipline as `web-cursor` and `has-prevent-default`.
5
+ // extraction discipline as `has-prevent-default`.
6
6
  //
7
7
  // Web screen readers are driven by the existing `role`/`aria-*` attributes; these
8
8
  // `accessibility*` props are their NATIVE counterparts (VoiceOver/TalkBack). Both
@@ -54,13 +54,16 @@ export interface ControlA11yProps {
54
54
  * On WEB this returns nothing: every call site already sets the equivalent
55
55
  * `role`/`aria-*` attributes (the kit's cross-platform web a11y axis), and
56
56
  * react-native-web does not translate these RN `accessibility*` props on the
57
- * `styled(...).styleable` hosts these controls use — so emitting them would only
57
+ * `styleable()` hosts these controls use — so emitting them would only
58
58
  * leak unrecognised `accessibility*` attributes onto the DOM. They are the
59
59
  * VoiceOver/TalkBack counterparts, needed on native only.
60
60
  */
61
+ /** The web result: one frozen empty object, so 42 cells per grid allocate nothing. */
62
+ const NO_NATIVE_A11Y: Partial<ControlA11yProps> = Object.freeze({});
63
+
61
64
  export function controlA11yProps(options: ControlA11yOptions = {}): Partial<ControlA11yProps> {
62
65
  if (isWeb) {
63
- return {};
66
+ return NO_NATIVE_A11Y;
64
67
  }
65
68
 
66
69
  const { label, selected, disabled, role = "button" } = options;
@@ -1,5 +1,5 @@
1
1
  // Internal cross-platform helper — NOT exported from the public `src/index.ts`
2
- // barrel (same discipline as `web-cursor`/`focus-element`/`picker-presets`).
2
+ // barrel (same discipline as `focus-element`/`picker-presets`).
3
3
  // Shared by the `*PickerInput` wrappers so the inline picker's `defaultDate`
4
4
  // computation lives in one place instead of being copied per wrapper.
5
5
 
@@ -1,7 +1,7 @@
1
1
  // Internal cross-platform helper — NOT exported from the public `src/index.ts`
2
2
  // barrel. Shared by the time-segment leaves (`SpinInput`, `AmPmInput`) so the
3
3
  // web `.select()`-on-focus narrowing lives in one place (the same extraction
4
- // pattern as `web-cursor`, `focus-element` and `has-prevent-default`).
4
+ // pattern as `focus-element` and `has-prevent-default`).
5
5
 
6
6
  import { isWeb } from "@knitui/core";
7
7
 
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.webCursor = void 0;
7
- var _core = require("@knitui/core");
8
- // Internal cross-platform helper — NOT exported from the public `src/index.ts`
9
- // barrel. Shared by `Day`, `PickerControl` and `CalendarHeader` (and any future
10
- // grid control) so the web-only cursor narrowing lives in one place instead of
11
- // being copied per component (the same extraction pattern as `cell-metrics` and
12
- // `has-prevent-default`).
13
-
14
- /**
15
- * Cursor is a web-only affordance — passing it on native leaks to the RN host
16
- * node. `isWeb` is a module-load constant, so this is safe to call inside a
17
- * static styled-variant definition. Mirrors the kit's internal `webCursor`,
18
- * which is not exported from `@knitui/components`.
19
- */
20
- const webCursor = cursor => _core.isWeb ? {
21
- cursor
22
- } : {};
23
- exports.webCursor = webCursor;
24
- //# sourceMappingURL=web-cursor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_core","require","webCursor","cursor","isWeb","exports"],"sourceRoot":"../../../src","sources":["internal/web-cursor.ts"],"mappings":";;;;;;AAMA,IAAAA,KAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,SAAS,GAAsBC,MAAS,IAAsBC,WAAK,GAAG;EAAED;AAAO,CAAC,GAAG,CAAC,CAAE;AAACE,OAAA,CAAAH,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- // Internal cross-platform helper — NOT exported from the public `src/index.ts`
4
- // barrel. Shared by `Day`, `PickerControl` and `CalendarHeader` (and any future
5
- // grid control) so the web-only cursor narrowing lives in one place instead of
6
- // being copied per component (the same extraction pattern as `cell-metrics` and
7
- // `has-prevent-default`).
8
-
9
- import { isWeb } from "@knitui/core";
10
-
11
- /**
12
- * Cursor is a web-only affordance — passing it on native leaks to the RN host
13
- * node. `isWeb` is a module-load constant, so this is safe to call inside a
14
- * static styled-variant definition. Mirrors the kit's internal `webCursor`,
15
- * which is not exported from `@knitui/components`.
16
- */
17
- export const webCursor = cursor => isWeb ? {
18
- cursor
19
- } : {};
20
- //# sourceMappingURL=web-cursor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["isWeb","webCursor","cursor"],"sourceRoot":"../../../src","sources":["internal/web-cursor.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,cAAc;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAsBC,MAAS,IAAsBF,KAAK,GAAG;EAAEE;AAAO,CAAC,GAAG,CAAC,CAAE","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- /**
2
- * Cursor is a web-only affordance — passing it on native leaks to the RN host
3
- * node. `isWeb` is a module-load constant, so this is safe to call inside a
4
- * static styled-variant definition. Mirrors the kit's internal `webCursor`,
5
- * which is not exported from `@knitui/components`.
6
- */
7
- export declare const webCursor: <T extends string>(cursor: T) => {
8
- cursor?: T;
9
- };
10
- //# sourceMappingURL=web-cursor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-cursor.d.ts","sourceRoot":"","sources":["../../../src/internal/web-cursor.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,EAAE,QAAQ,CAAC,KAAG;IAAE,MAAM,CAAC,EAAE,CAAC,CAAA;CAA+B,CAAC"}
@@ -1,15 +0,0 @@
1
- // Internal cross-platform helper — NOT exported from the public `src/index.ts`
2
- // barrel. Shared by `Day`, `PickerControl` and `CalendarHeader` (and any future
3
- // grid control) so the web-only cursor narrowing lives in one place instead of
4
- // being copied per component (the same extraction pattern as `cell-metrics` and
5
- // `has-prevent-default`).
6
-
7
- import { isWeb } from "@knitui/core";
8
-
9
- /**
10
- * Cursor is a web-only affordance — passing it on native leaks to the RN host
11
- * node. `isWeb` is a module-load constant, so this is safe to call inside a
12
- * static styled-variant definition. Mirrors the kit's internal `webCursor`,
13
- * which is not exported from `@knitui/components`.
14
- */
15
- export const webCursor = <T extends string>(cursor: T): { cursor?: T } => (isWeb ? { cursor } : {});