react-miui 0.33.0 → 0.35.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 (343) hide show
  1. package/.claude/settings.json +12 -0
  2. package/.claude/settings.local.json +5 -1
  3. package/.storybook/preview.tsx +10 -4
  4. package/CHANGELOG.md +22 -0
  5. package/dist/components/form/index.d.ts +1 -0
  6. package/dist/components/form/index.d.ts.map +1 -1
  7. package/dist/components/form/index.js +1 -0
  8. package/dist/components/form/index.js.map +1 -1
  9. package/dist/components/form/input/Input.d.ts.map +1 -1
  10. package/dist/components/form/input/Input.js +9 -5
  11. package/dist/components/form/input/Input.js.map +1 -1
  12. package/dist/components/form/timepicker/TimePicker.css.d.ts +99 -0
  13. package/dist/components/form/timepicker/TimePicker.css.d.ts.map +1 -0
  14. package/dist/components/form/timepicker/TimePicker.css.js +116 -0
  15. package/dist/components/form/timepicker/TimePicker.css.js.map +1 -0
  16. package/dist/components/form/timepicker/TimePicker.d.ts +22 -0
  17. package/dist/components/form/timepicker/TimePicker.d.ts.map +1 -0
  18. package/dist/components/form/timepicker/TimePicker.js +141 -0
  19. package/dist/components/form/timepicker/TimePicker.js.map +1 -0
  20. package/dist/components/form/timepicker/TimePicker.styled.d.ts +936 -0
  21. package/dist/components/form/timepicker/TimePicker.styled.d.ts.map +1 -0
  22. package/dist/components/form/timepicker/TimePicker.styled.js +29 -0
  23. package/dist/components/form/timepicker/TimePicker.styled.js.map +1 -0
  24. package/dist/components/form/timepicker/TimePickerModal.d.ts +17 -0
  25. package/dist/components/form/timepicker/TimePickerModal.d.ts.map +1 -0
  26. package/dist/components/form/timepicker/TimePickerModal.js +92 -0
  27. package/dist/components/form/timepicker/TimePickerModal.js.map +1 -0
  28. package/dist/components/form/timepicker/Wheel.d.ts +12 -0
  29. package/dist/components/form/timepicker/Wheel.d.ts.map +1 -0
  30. package/dist/components/form/timepicker/Wheel.js +187 -0
  31. package/dist/components/form/timepicker/Wheel.js.map +1 -0
  32. package/dist/components/form/timepicker/utils.d.ts +4 -0
  33. package/dist/components/form/timepicker/utils.d.ts.map +1 -0
  34. package/dist/components/form/timepicker/utils.js +62 -0
  35. package/dist/components/form/timepicker/utils.js.map +1 -0
  36. package/dist/components/icons/Clock.d.ts +7 -0
  37. package/dist/components/icons/Clock.d.ts.map +1 -0
  38. package/dist/components/icons/Clock.js +45 -0
  39. package/dist/components/icons/Clock.js.map +1 -0
  40. package/dist/components/icons/Icon.d.ts +2 -1
  41. package/dist/components/icons/Icon.d.ts.map +1 -1
  42. package/dist/components/icons/Icon.js +3 -0
  43. package/dist/components/icons/Icon.js.map +1 -1
  44. package/dist/components/ui/drawer/Drawer.d.ts +10 -1
  45. package/dist/components/ui/drawer/Drawer.d.ts.map +1 -1
  46. package/dist/components/ui/drawer/Drawer.js +135 -15
  47. package/dist/components/ui/drawer/Drawer.js.map +1 -1
  48. package/dist/components/ui/drawer/Drawer.styled.d.ts +86 -1
  49. package/dist/components/ui/drawer/Drawer.styled.d.ts.map +1 -1
  50. package/dist/components/ui/drawer/Drawer.styled.js +13 -1
  51. package/dist/components/ui/drawer/Drawer.styled.js.map +1 -1
  52. package/dist/components/ui/modal/Modal.d.ts +1 -2
  53. package/dist/components/ui/modal/Modal.d.ts.map +1 -1
  54. package/dist/components/ui/modal/Modal.js +114 -42
  55. package/dist/components/ui/modal/Modal.js.map +1 -1
  56. package/dist/components/ui/modal/Modal.styled.d.ts +1 -1
  57. package/dist/components/ui/modal/Modal.styled.d.ts.map +1 -1
  58. package/dist/components/ui/modal/Modal.styled.js +40 -25
  59. package/dist/components/ui/modal/Modal.styled.js.map +1 -1
  60. package/dist/components/ui/toaster/Toaster.d.ts.map +1 -1
  61. package/dist/components/ui/toaster/Toaster.js +7 -1
  62. package/dist/components/ui/toaster/Toaster.js.map +1 -1
  63. package/dist/components/ui/tooltip/Tooltip.d.ts +30 -0
  64. package/dist/components/ui/tooltip/Tooltip.d.ts.map +1 -0
  65. package/dist/components/ui/tooltip/Tooltip.js +81 -0
  66. package/dist/components/ui/tooltip/Tooltip.js.map +1 -0
  67. package/dist/components/ui/tooltip/Tooltip.styled.d.ts +173 -0
  68. package/dist/components/ui/tooltip/Tooltip.styled.d.ts.map +1 -0
  69. package/dist/components/ui/tooltip/Tooltip.styled.js +65 -0
  70. package/dist/components/ui/tooltip/Tooltip.styled.js.map +1 -0
  71. package/dist/index.d.ts +1 -0
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +1 -0
  74. package/dist/index.js.map +1 -1
  75. package/dist/theme.css-global.d.ts.map +1 -1
  76. package/dist/theme.css-global.js +0 -1
  77. package/dist/theme.css-global.js.map +1 -1
  78. package/dist/utils/index.d.ts +1 -0
  79. package/dist/utils/index.d.ts.map +1 -1
  80. package/dist/utils/index.js +1 -0
  81. package/dist/utils/index.js.map +1 -1
  82. package/dist/utils/useNativeValidity.d.ts +11 -0
  83. package/dist/utils/useNativeValidity.d.ts.map +1 -0
  84. package/dist/utils/useNativeValidity.js +32 -0
  85. package/dist/utils/useNativeValidity.js.map +1 -0
  86. package/docs/assets/highlight.css +7 -0
  87. package/docs/assets/navigation.js +1 -1
  88. package/docs/assets/search.js +1 -1
  89. package/docs/classes/index.Pop.html +7 -7
  90. package/docs/documents/Test.html +2 -2
  91. package/docs/enums/index.ICON.html +3 -2
  92. package/docs/functions/index.Action.html +3 -3
  93. package/docs/functions/index.Button.html +4 -4
  94. package/docs/functions/index.Card.html +3 -3
  95. package/docs/functions/index.Checkbox.html +3 -3
  96. package/docs/functions/index.Choice.html +2 -2
  97. package/docs/functions/index.ColorPicker.html +3 -3
  98. package/docs/functions/index.CoveringLoader.html +3 -3
  99. package/docs/functions/index.DirectionPad.html +2 -2
  100. package/docs/functions/index.Drawer.html +2 -2
  101. package/docs/functions/index.EqualActions.html +2 -2
  102. package/docs/functions/index.FullLoader.html +3 -3
  103. package/docs/functions/index.Gap.html +3 -3
  104. package/docs/functions/index.HandleEsc.html +3 -3
  105. package/docs/functions/index.Header.html +3 -3
  106. package/docs/functions/index.HeaderIconAction.html +3 -3
  107. package/docs/functions/index.Icon-1.html +2 -2
  108. package/docs/functions/index.If.html +3 -3
  109. package/docs/functions/index.Input.html +1 -1
  110. package/docs/functions/index.KeyValue.html +2 -2
  111. package/docs/functions/index.Label.html +2 -2
  112. package/docs/functions/index.Line.html +4 -4
  113. package/docs/functions/index.List.html +2 -2
  114. package/docs/functions/index.Loader.html +3 -3
  115. package/docs/functions/index.Loading.html +3 -3
  116. package/docs/functions/index.Message.html +4 -4
  117. package/docs/functions/index.Modal.html +2 -2
  118. package/docs/functions/index.ModalButtons.html +3 -3
  119. package/docs/functions/index.PopLoader.html +3 -3
  120. package/docs/functions/index.PopOption.html +2 -2
  121. package/docs/functions/index.Progress.html +2 -2
  122. package/docs/functions/index.SearchContainer.html +3 -3
  123. package/docs/functions/index.Section.html +4 -4
  124. package/docs/functions/index.Select.html +3 -3
  125. package/docs/functions/index.Selector.html +2 -2
  126. package/docs/functions/index.Spacer.html +3 -3
  127. package/docs/functions/index.Stats.html +2 -2
  128. package/docs/functions/index.StickyHeader.html +4 -4
  129. package/docs/functions/index.Table.html +3 -3
  130. package/docs/functions/index.TextArea.html +2 -2
  131. package/docs/functions/index.TimePicker.html +10 -0
  132. package/docs/functions/index.ToasterProvider.html +3 -3
  133. package/docs/functions/index.Toggle.html +3 -3
  134. package/docs/functions/index.ToolButton.html +4 -4
  135. package/docs/functions/index.Tooltip.html +18 -0
  136. package/docs/functions/index.TooltipProvider.html +6 -0
  137. package/docs/functions/index.borderPxToRem.html +1 -1
  138. package/docs/functions/index.createTheme.html +1 -1
  139. package/docs/functions/index.css.html +1 -1
  140. package/docs/functions/index.dimensionsPxToRem.html +1 -1
  141. package/docs/functions/index.fontPxToRem.html +1 -1
  142. package/docs/functions/index.getCssText.html +1 -1
  143. package/docs/functions/index.globalCss.html +2 -2
  144. package/docs/functions/index.injectGlobalStyles.html +1 -1
  145. package/docs/functions/index.keyframes.html +1 -1
  146. package/docs/functions/index.pxToRem.html +1 -1
  147. package/docs/functions/index.styled.html +1 -1
  148. package/docs/functions/index.toast.html +2 -2
  149. package/docs/functions/index.useToaster.html +1 -1
  150. package/docs/index.html +2 -2
  151. package/docs/interfaces/index.IconProps.html +2 -2
  152. package/docs/interfaces/index.InputCustomProps.html +3 -3
  153. package/docs/interfaces/index.LoaderProps.html +6 -6
  154. package/docs/interfaces/index.StickyHeaderProps.html +4 -4
  155. package/docs/interfaces/index.ToasterProviderProps.html +3 -3
  156. package/docs/interfaces/index.TooltipProps.html +36 -0
  157. package/docs/interfaces/index.TooltipProviderProps.html +13 -0
  158. package/docs/modules/index.html +1 -1
  159. package/docs/modules.html +1 -1
  160. package/docs/types/index.ActionProps.html +1 -1
  161. package/docs/types/index.CardProps.html +1 -1
  162. package/docs/types/index.CheckboxProps.html +2 -2
  163. package/docs/types/index.ChoiceProps.html +1 -1
  164. package/docs/types/index.ColorPickerProps.html +1 -1
  165. package/docs/types/index.DirectionPadProps.html +1 -1
  166. package/docs/types/index.DrawerFrom.html +1 -0
  167. package/docs/types/index.DrawerProps.html +28 -1
  168. package/docs/types/index.EqualActionsProps.html +1 -1
  169. package/docs/types/index.HeaderProps.html +1 -1
  170. package/docs/types/index.InputProps.html +1 -1
  171. package/docs/types/index.KeyValueProps.html +1 -1
  172. package/docs/types/index.LabelProps.html +1 -1
  173. package/docs/types/index.OverwriteProps.html +1 -1
  174. package/docs/types/index.ProgressProps.html +2 -2
  175. package/docs/types/index.SelectProps.html +1 -1
  176. package/docs/types/index.SelectorProps.html +1 -1
  177. package/docs/types/index.Stat.html +1 -1
  178. package/docs/types/index.StatsProps.html +1 -1
  179. package/docs/types/index.TextAreaProps.html +1 -1
  180. package/docs/types/index.ThemeCSS.html +1 -1
  181. package/docs/types/index.TimePickerProps.html +1 -0
  182. package/docs/types/index.ToggleProps.html +2 -2
  183. package/docs/variables/index.ActionBadgeSelector.html +1 -1
  184. package/docs/variables/index.ActionCircleSelector.html +1 -1
  185. package/docs/variables/index.CheckboxCheckmarkWrapperSelector.html +1 -1
  186. package/docs/variables/index.CheckboxTextLabelSelector.html +1 -1
  187. package/docs/variables/index.ChoiceItemSelector.html +1 -1
  188. package/docs/variables/index.ColorPickerColorDisplaySelector.html +1 -1
  189. package/docs/variables/index.DirectionPadButtonDotSelector.html +1 -1
  190. package/docs/variables/index.DirectionPadButtonSelector.html +1 -1
  191. package/docs/variables/index.DirectionPadLineSelector.html +1 -1
  192. package/docs/variables/index.DirectionPadMiddleSelector.html +1 -1
  193. package/docs/variables/index.DrawerContentSelector.html +1 -1
  194. package/docs/variables/index.HeaderAfterSelector.html +1 -1
  195. package/docs/variables/index.HeaderBeforeSelector.html +1 -1
  196. package/docs/variables/index.HeaderContentsSelector.html +1 -1
  197. package/docs/variables/index.HeaderIconActionIconSelector.html +1 -1
  198. package/docs/variables/index.InputContainerSelector.html +1 -1
  199. package/docs/variables/index.InputInputSelector.html +1 -1
  200. package/docs/variables/index.InputLabelSelector.html +1 -1
  201. package/docs/variables/index.InputPrefixSelector.html +1 -1
  202. package/docs/variables/index.InputSuffixSelector.html +1 -1
  203. package/docs/variables/index.KeyValueIconSelector.html +1 -1
  204. package/docs/variables/index.KeyValueItemSelector.html +1 -1
  205. package/docs/variables/index.KeyValueKeySelector.html +1 -1
  206. package/docs/variables/index.KeyValuePairSelector.html +1 -1
  207. package/docs/variables/index.KeyValueValueSelector.html +1 -1
  208. package/docs/variables/index.LabelTextSelector.html +1 -1
  209. package/docs/variables/index.ListItemInnerContainerClassNameSelector.html +1 -1
  210. package/docs/variables/index.ModalContainerSelector.html +1 -1
  211. package/docs/variables/index.ModalRemovePaddingSelector.html +1 -1
  212. package/docs/variables/index.ModalTitleSelector.html +1 -1
  213. package/docs/variables/index.PopListSelector.html +1 -1
  214. package/docs/variables/index.PopOptionButtonSelector.html +1 -1
  215. package/docs/variables/index.PopOptionIconSelector.html +1 -1
  216. package/docs/variables/index.PopOverlaySelector.html +1 -1
  217. package/docs/variables/index.ProgressBackgroundSelector.html +1 -1
  218. package/docs/variables/index.ProgressValueSelector.html +1 -1
  219. package/docs/variables/index.SelectorItemSelector.html +1 -1
  220. package/docs/variables/index.StatsItemSelector.html +1 -1
  221. package/docs/variables/index.StatsLabelSelector.html +1 -1
  222. package/docs/variables/index.StatsSeparatorSelector.html +1 -1
  223. package/docs/variables/index.StatsValueSelector.html +1 -1
  224. package/docs/variables/index.TextAreaLabelSelector.html +1 -1
  225. package/docs/variables/index.TextAreaTextAreaSelector.html +1 -1
  226. package/docs/variables/index.TextAreaWrapperSelector.html +1 -1
  227. package/docs/variables/index.ToggleStyledToggleSelector.html +1 -1
  228. package/docs/variables/index.TooltipContentSelector.html +1 -0
  229. package/docs/variables/index.config.html +1 -1
  230. package/docs/variables/index.cssReset.html +2 -2
  231. package/docs/variables/index.darkTheme.html +1 -1
  232. package/docs/variables/index.miuiScrollbars.html +1 -1
  233. package/docs/variables/index.theme.html +1 -1
  234. package/esm/components/form/index.d.ts +1 -0
  235. package/esm/components/form/index.d.ts.map +1 -1
  236. package/esm/components/form/index.js +1 -0
  237. package/esm/components/form/index.js.map +1 -1
  238. package/esm/components/form/input/Input.d.ts.map +1 -1
  239. package/esm/components/form/input/Input.js +9 -5
  240. package/esm/components/form/input/Input.js.map +1 -1
  241. package/esm/components/form/timepicker/TimePicker.css.d.ts +99 -0
  242. package/esm/components/form/timepicker/TimePicker.css.d.ts.map +1 -0
  243. package/esm/components/form/timepicker/TimePicker.css.js +102 -0
  244. package/esm/components/form/timepicker/TimePicker.css.js.map +1 -0
  245. package/esm/components/form/timepicker/TimePicker.d.ts +22 -0
  246. package/esm/components/form/timepicker/TimePicker.d.ts.map +1 -0
  247. package/esm/components/form/timepicker/TimePicker.js +93 -0
  248. package/esm/components/form/timepicker/TimePicker.js.map +1 -0
  249. package/esm/components/form/timepicker/TimePicker.styled.d.ts +936 -0
  250. package/esm/components/form/timepicker/TimePicker.styled.d.ts.map +1 -0
  251. package/esm/components/form/timepicker/TimePicker.styled.js +20 -0
  252. package/esm/components/form/timepicker/TimePicker.styled.js.map +1 -0
  253. package/esm/components/form/timepicker/TimePickerModal.d.ts +17 -0
  254. package/esm/components/form/timepicker/TimePickerModal.d.ts.map +1 -0
  255. package/esm/components/form/timepicker/TimePickerModal.js +56 -0
  256. package/esm/components/form/timepicker/TimePickerModal.js.map +1 -0
  257. package/esm/components/form/timepicker/Wheel.d.ts +12 -0
  258. package/esm/components/form/timepicker/Wheel.d.ts.map +1 -0
  259. package/esm/components/form/timepicker/Wheel.js +151 -0
  260. package/esm/components/form/timepicker/Wheel.js.map +1 -0
  261. package/esm/components/form/timepicker/utils.d.ts +4 -0
  262. package/esm/components/form/timepicker/utils.d.ts.map +1 -0
  263. package/esm/components/form/timepicker/utils.js +58 -0
  264. package/esm/components/form/timepicker/utils.js.map +1 -0
  265. package/esm/components/icons/Clock.d.ts +7 -0
  266. package/esm/components/icons/Clock.d.ts.map +1 -0
  267. package/esm/components/icons/Clock.js +9 -0
  268. package/esm/components/icons/Clock.js.map +1 -0
  269. package/esm/components/icons/Icon.d.ts +2 -1
  270. package/esm/components/icons/Icon.d.ts.map +1 -1
  271. package/esm/components/icons/Icon.js +3 -0
  272. package/esm/components/icons/Icon.js.map +1 -1
  273. package/esm/components/ui/drawer/Drawer.d.ts +10 -1
  274. package/esm/components/ui/drawer/Drawer.d.ts.map +1 -1
  275. package/esm/components/ui/drawer/Drawer.js +139 -15
  276. package/esm/components/ui/drawer/Drawer.js.map +1 -1
  277. package/esm/components/ui/drawer/Drawer.styled.d.ts +86 -1
  278. package/esm/components/ui/drawer/Drawer.styled.d.ts.map +1 -1
  279. package/esm/components/ui/drawer/Drawer.styled.js +12 -1
  280. package/esm/components/ui/drawer/Drawer.styled.js.map +1 -1
  281. package/esm/components/ui/modal/Modal.d.ts +1 -2
  282. package/esm/components/ui/modal/Modal.d.ts.map +1 -1
  283. package/esm/components/ui/modal/Modal.js +103 -43
  284. package/esm/components/ui/modal/Modal.js.map +1 -1
  285. package/esm/components/ui/modal/Modal.styled.d.ts +1 -1
  286. package/esm/components/ui/modal/Modal.styled.d.ts.map +1 -1
  287. package/esm/components/ui/modal/Modal.styled.js +40 -25
  288. package/esm/components/ui/modal/Modal.styled.js.map +1 -1
  289. package/esm/components/ui/toaster/Toaster.d.ts.map +1 -1
  290. package/esm/components/ui/toaster/Toaster.js +8 -2
  291. package/esm/components/ui/toaster/Toaster.js.map +1 -1
  292. package/esm/components/ui/tooltip/Tooltip.d.ts +30 -0
  293. package/esm/components/ui/tooltip/Tooltip.d.ts.map +1 -0
  294. package/esm/components/ui/tooltip/Tooltip.js +43 -0
  295. package/esm/components/ui/tooltip/Tooltip.js.map +1 -0
  296. package/esm/components/ui/tooltip/Tooltip.styled.d.ts +173 -0
  297. package/esm/components/ui/tooltip/Tooltip.styled.d.ts.map +1 -0
  298. package/esm/components/ui/tooltip/Tooltip.styled.js +28 -0
  299. package/esm/components/ui/tooltip/Tooltip.styled.js.map +1 -0
  300. package/esm/index.d.ts +1 -0
  301. package/esm/index.d.ts.map +1 -1
  302. package/esm/index.js +1 -0
  303. package/esm/index.js.map +1 -1
  304. package/esm/theme.css-global.d.ts.map +1 -1
  305. package/esm/theme.css-global.js +0 -1
  306. package/esm/theme.css-global.js.map +1 -1
  307. package/esm/utils/index.d.ts +1 -0
  308. package/esm/utils/index.d.ts.map +1 -1
  309. package/esm/utils/index.js +1 -0
  310. package/esm/utils/index.js.map +1 -1
  311. package/esm/utils/useNativeValidity.d.ts +11 -0
  312. package/esm/utils/useNativeValidity.d.ts.map +1 -0
  313. package/esm/utils/useNativeValidity.js +29 -0
  314. package/esm/utils/useNativeValidity.js.map +1 -0
  315. package/package.json +2 -1
  316. package/pnpm-workspace.yaml +3 -0
  317. package/src/bugfixes/ToastsFromModal.stories.tsx +59 -0
  318. package/src/components/form/index.ts +1 -0
  319. package/src/components/form/input/Input.stories.tsx +47 -1
  320. package/src/components/form/input/Input.tsx +11 -5
  321. package/src/components/form/timepicker/TimePicker.css.ts +132 -0
  322. package/src/components/form/timepicker/TimePicker.stories.tsx +107 -0
  323. package/src/components/form/timepicker/TimePicker.styled.ts +52 -0
  324. package/src/components/form/timepicker/TimePicker.tsx +229 -0
  325. package/src/components/form/timepicker/TimePickerModal.tsx +131 -0
  326. package/src/components/form/timepicker/Wheel.tsx +201 -0
  327. package/src/components/form/timepicker/utils.ts +66 -0
  328. package/src/components/icons/Clock.tsx +38 -0
  329. package/src/components/icons/Icon.tsx +3 -0
  330. package/src/components/ui/drawer/Drawer.stories.tsx +143 -59
  331. package/src/components/ui/drawer/Drawer.styled.ts +13 -0
  332. package/src/components/ui/drawer/Drawer.tsx +214 -20
  333. package/src/components/ui/modal/Modal.stories.tsx +43 -7
  334. package/src/components/ui/modal/Modal.styled.ts +46 -25
  335. package/src/components/ui/modal/Modal.tsx +135 -52
  336. package/src/components/ui/toaster/Toaster.tsx +12 -2
  337. package/src/components/ui/tooltip/Tooltip.stories.tsx +285 -0
  338. package/src/components/ui/tooltip/Tooltip.styled.ts +36 -0
  339. package/src/components/ui/tooltip/Tooltip.tsx +195 -0
  340. package/src/index.ts +1 -0
  341. package/src/theme.css-global.ts +0 -1
  342. package/src/utils/index.ts +1 -0
  343. package/src/utils/useNativeValidity.ts +57 -0
@@ -0,0 +1,229 @@
1
+ import React, {
2
+ forwardRef,
3
+ useCallback,
4
+ useEffect,
5
+ useId,
6
+ useState,
7
+ } from "react";
8
+
9
+ import { useForwardedRef } from "@bedrock-layout/use-forwarded-ref";
10
+
11
+ import { useNativeValidity } from "../../../utils/useNativeValidity";
12
+ import { Clock } from "../../icons/Clock";
13
+ import {
14
+ StyledInputContainer,
15
+ StyledLabel,
16
+ StyledSuffix,
17
+ StyledWrapper,
18
+ } from "../input/Input.styled";
19
+ import {
20
+ StyledSuffixButton,
21
+ StyledTimeInput,
22
+ } from "./TimePicker.styled";
23
+ import { TimePickerModal } from "./TimePickerModal";
24
+
25
+ const PATTERN_HHMM = "(?:[01]\\d|2[0-3]):[0-5]\\d";
26
+ const PATTERN_HHMMSS = "(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
27
+ const MAX_LEN_HHMM = 5;
28
+ const MAX_LEN_HHMMSS = 8;
29
+
30
+ const assertStep = (name: string, step: number): void => {
31
+ if (!Number.isInteger(step) || step < 1 || step > 60) {
32
+ throw new Error(
33
+ `TimePicker: \`${name}\` must be an integer between 1 and 60, got ${String(step)}`,
34
+ );
35
+ }
36
+ };
37
+
38
+ interface CustomProps {
39
+ children?: never;
40
+ label?: string;
41
+ pinnedLabel?: boolean;
42
+ error?: boolean;
43
+ withSeconds?: boolean;
44
+ minuteStep?: number;
45
+ secondStep?: number;
46
+ value?: string;
47
+ defaultValue?: string;
48
+ onChange?: (value: string) => void;
49
+ modalTitle?: React.ReactNode;
50
+ okLabel?: React.ReactNode;
51
+ cancelLabel?: React.ReactNode;
52
+ }
53
+
54
+ type InputAttrs = Omit<
55
+ React.InputHTMLAttributes<HTMLInputElement>,
56
+ "value" | "defaultValue" | "onChange" | "type" | "prefix" | "pattern" | "placeholder" | "maxLength"
57
+ >;
58
+
59
+ type Props = InputAttrs & CustomProps;
60
+
61
+ // eslint-disable-next-line max-lines-per-function,max-statements
62
+ const TimePickerInner = ({
63
+ className,
64
+ label,
65
+ pinnedLabel = false,
66
+ error,
67
+ withSeconds = false,
68
+ minuteStep = 1,
69
+ secondStep = 1,
70
+ value,
71
+ defaultValue,
72
+ onChange,
73
+ onFocus,
74
+ onBlur,
75
+ disabled,
76
+ readOnly,
77
+ id,
78
+ modalTitle,
79
+ okLabel = "OK",
80
+ cancelLabel = "Cancel",
81
+ ...rest
82
+ }: Props, ref: React.Ref<HTMLInputElement>) => {
83
+ assertStep("minuteStep", minuteStep);
84
+ if (withSeconds) {
85
+ assertStep("secondStep", secondStep);
86
+ }
87
+
88
+ const isControlled = value !== undefined;
89
+ const [internalValue, setInternalValue] = useState(defaultValue ?? "");
90
+ const currentValue = isControlled ? (value ?? "") : internalValue;
91
+
92
+ const [focused, setFocused] = useState(false);
93
+ const validity = useNativeValidity(error);
94
+ const { revalidate } = validity;
95
+ const inputRef = useForwardedRef(ref);
96
+ const generatedId = useId();
97
+ const inputId = id ?? (label ? generatedId : undefined);
98
+
99
+ const [modalOpen, setModalOpen] = useState(false);
100
+
101
+ const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
102
+ const next = e.target.value;
103
+ if (!isControlled) {
104
+ setInternalValue(next);
105
+ }
106
+ validity.onChange(e);
107
+ onChange?.(next);
108
+ }, [isControlled, onChange, validity]);
109
+
110
+ const handleFocus = useCallback((e: React.FocusEvent<HTMLInputElement>) => {
111
+ setFocused(true);
112
+ onFocus?.(e);
113
+ }, [onFocus]);
114
+
115
+ const handleBlur = useCallback((e: React.FocusEvent<HTMLInputElement>) => {
116
+ setFocused(false);
117
+ validity.onBlur(e);
118
+ onBlur?.(e);
119
+ }, [onBlur, validity]);
120
+
121
+ useEffect(() => {
122
+ revalidate(inputRef.current);
123
+ }, [currentValue, revalidate, inputRef]);
124
+
125
+ const openModal = useCallback(() => {
126
+ setModalOpen(true);
127
+ }, []);
128
+
129
+ const closeModal = useCallback(() => {
130
+ setModalOpen(false);
131
+ inputRef.current?.focus();
132
+ }, [inputRef]);
133
+
134
+ const confirmModal = useCallback((next: string) => {
135
+ if (!isControlled) {
136
+ setInternalValue(next);
137
+ }
138
+ onChange?.(next);
139
+ setModalOpen(false);
140
+ inputRef.current?.focus();
141
+ }, [isControlled, onChange, inputRef]);
142
+
143
+ const hasValue = currentValue.length > 0;
144
+ const floating = Boolean(label) && (pinnedLabel || focused || hasValue);
145
+ const placeholder = withSeconds ? "--:--:--" : "--:--";
146
+ const pattern = withSeconds ? PATTERN_HHMMSS : PATTERN_HHMM;
147
+ const maxLength = withSeconds ? MAX_LEN_HHMMSS : MAX_LEN_HHMM;
148
+ const finalError = validity.finalError;
149
+
150
+ const labelElem = label
151
+ ? (
152
+ <StyledLabel
153
+ htmlFor={inputId}
154
+ floating={floating}
155
+ error={finalError}
156
+ >
157
+ {label}
158
+ </StyledLabel>
159
+ )
160
+ : null;
161
+
162
+ return (
163
+ <>
164
+ <StyledWrapper
165
+ className={className}
166
+ focused={focused}
167
+ disabled={Boolean(disabled)}
168
+ readOnly={Boolean(readOnly)}
169
+ error={finalError}
170
+ >
171
+ <StyledInputContainer>
172
+ {labelElem}
173
+ <StyledTimeInput
174
+ ref={inputRef}
175
+ {...rest}
176
+ id={inputId}
177
+ type={"text"}
178
+ inputMode={"numeric"}
179
+ autoComplete={"off"}
180
+ value={currentValue}
181
+ placeholder={placeholder}
182
+ pattern={pattern}
183
+ maxLength={maxLength}
184
+ disabled={disabled}
185
+ readOnly={readOnly}
186
+ onChange={handleChange}
187
+ onFocus={handleFocus}
188
+ onBlur={handleBlur}
189
+ onInvalid={validity.onInvalid}
190
+ data-error={finalError}
191
+ />
192
+ </StyledInputContainer>
193
+ <StyledSuffix>
194
+ <StyledSuffixButton
195
+ type={"button"}
196
+ onClick={openModal}
197
+ disabled={disabled}
198
+ aria-label={"Open time picker"}
199
+ >
200
+ <Clock />
201
+ </StyledSuffixButton>
202
+ </StyledSuffix>
203
+ </StyledWrapper>
204
+ <TimePickerModal
205
+ isOpen={modalOpen}
206
+ initialValue={currentValue}
207
+ withSeconds={withSeconds}
208
+ minuteStep={minuteStep}
209
+ secondStep={secondStep}
210
+ readOnly={Boolean(readOnly)}
211
+ title={modalTitle}
212
+ okLabel={okLabel}
213
+ cancelLabel={cancelLabel}
214
+ onClose={closeModal}
215
+ onConfirm={confirmModal}
216
+ />
217
+ </>
218
+ );
219
+ };
220
+
221
+ const TimePickerRef = forwardRef(TimePickerInner);
222
+ TimePickerRef.displayName = "TimePicker";
223
+ TimePickerRef.toString = () => StyledWrapper.toString();
224
+
225
+ const TimePicker = TimePickerRef;
226
+
227
+ export { TimePicker };
228
+
229
+ export type { Props as TimePickerProps };
@@ -0,0 +1,131 @@
1
+ import React, { useCallback, useEffect, useState } from "react";
2
+
3
+ import { Modal } from "../../ui/modal/Modal";
4
+ import { ModalButtons } from "../../ui/modal/ModalButtons";
5
+ import {
6
+ StyledWheelHighlight,
7
+ StyledWheelsContainer,
8
+ StyledWheelSeparator,
9
+ } from "./TimePicker.styled";
10
+ import { padTwo, parseTimeText } from "./utils";
11
+ import { Wheel } from "./Wheel";
12
+
13
+ interface Props {
14
+ isOpen: boolean;
15
+ /** Current input value, parsed to seed the wheels when the modal opens. */
16
+ initialValue: string;
17
+ withSeconds: boolean;
18
+ minuteStep: number;
19
+ secondStep: number;
20
+ readOnly: boolean;
21
+ title?: React.ReactNode;
22
+ okLabel: React.ReactNode;
23
+ cancelLabel: React.ReactNode;
24
+ onClose: () => void;
25
+ onConfirm: (value: string) => void;
26
+ }
27
+
28
+ const snapToStep = (v: number, step: number, max: number): number => {
29
+ const snapped = Math.round(v / step) * step;
30
+ return Math.min(snapped, max - (max % step === 0 ? step : max % step));
31
+ };
32
+
33
+ const TimePickerModal = ({
34
+ isOpen,
35
+ initialValue,
36
+ withSeconds,
37
+ minuteStep,
38
+ secondStep,
39
+ readOnly,
40
+ title,
41
+ okLabel,
42
+ cancelLabel,
43
+ onClose,
44
+ onConfirm,
45
+ }: Props) => {
46
+ const [draftHours, setDraftHours] = useState(0);
47
+ const [draftMinutes, setDraftMinutes] = useState(0);
48
+ const [draftSeconds, setDraftSeconds] = useState(0);
49
+
50
+ useEffect(() => {
51
+ if (!isOpen) {
52
+ return;
53
+ }
54
+ const digits = parseTimeText(initialValue, withSeconds);
55
+ const hh = digits.length >= 2 ? parseInt(digits.slice(0, 2), 10) : 0;
56
+ const mmRaw = digits.length >= 4 ? parseInt(digits.slice(2, 4), 10) : 0;
57
+ const ssRaw = digits.length >= 6 ? parseInt(digits.slice(4, 6), 10) : 0;
58
+ setDraftHours(hh);
59
+ setDraftMinutes(snapToStep(mmRaw, minuteStep, 60));
60
+ setDraftSeconds(snapToStep(ssRaw, secondStep, 60));
61
+ }, [isOpen, initialValue, withSeconds, minuteStep, secondStep]);
62
+
63
+ const handleConfirm = useCallback(() => {
64
+ const next = padTwo(draftHours) + ":" + padTwo(draftMinutes)
65
+ + (withSeconds ? ":" + padTwo(draftSeconds) : "");
66
+ onConfirm(next);
67
+ }, [draftHours, draftMinutes, draftSeconds, withSeconds, onConfirm]);
68
+
69
+ const handleWheelsKeyDown = useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
70
+ if (e.key === "Enter" && !readOnly) {
71
+ e.preventDefault();
72
+ handleConfirm();
73
+ }
74
+ }, [readOnly, handleConfirm]);
75
+
76
+ return (
77
+ <Modal
78
+ isOpen={isOpen}
79
+ onClose={onClose}
80
+ title={title}
81
+ >
82
+ <StyledWheelsContainer onKeyDown={handleWheelsKeyDown}>
83
+ <Wheel
84
+ count={24}
85
+ step={1}
86
+ value={draftHours}
87
+ onChange={setDraftHours}
88
+ ariaLabel={"Hours"}
89
+ autoFocus={true}
90
+ />
91
+ <StyledWheelSeparator>{":"}</StyledWheelSeparator>
92
+ <Wheel
93
+ count={60}
94
+ step={minuteStep}
95
+ value={draftMinutes}
96
+ onChange={setDraftMinutes}
97
+ ariaLabel={"Minutes"}
98
+ />
99
+ {withSeconds
100
+ ? (
101
+ <>
102
+ <StyledWheelSeparator>{":"}</StyledWheelSeparator>
103
+ <Wheel
104
+ count={60}
105
+ step={secondStep}
106
+ value={draftSeconds}
107
+ onChange={setDraftSeconds}
108
+ ariaLabel={"Seconds"}
109
+ />
110
+ </>
111
+ )
112
+ : null}
113
+ <StyledWheelHighlight aria-hidden={true} />
114
+ </StyledWheelsContainer>
115
+ <ModalButtons>
116
+ <ModalButtons.Button onClick={onClose}>
117
+ {cancelLabel}
118
+ </ModalButtons.Button>
119
+ {readOnly
120
+ ? null
121
+ : (
122
+ <ModalButtons.Button variant={"main"} onClick={handleConfirm}>
123
+ {okLabel}
124
+ </ModalButtons.Button>
125
+ )}
126
+ </ModalButtons>
127
+ </Modal>
128
+ );
129
+ };
130
+
131
+ export { TimePickerModal };
@@ -0,0 +1,201 @@
1
+ import React, { useCallback, useEffect, useLayoutEffect, useRef } from "react";
2
+
3
+ import {
4
+ StyledWheelFocusRing,
5
+ StyledWheelItem,
6
+ StyledWheelPadder,
7
+ StyledWheelViewport,
8
+ StyledWheelWrapper,
9
+ } from "./TimePicker.styled";
10
+ import { padTwo } from "./utils";
11
+
12
+ interface Props {
13
+ count: number;
14
+ step: number;
15
+ value: number;
16
+ onChange: (v: number) => void;
17
+ ariaLabel: string;
18
+ autoFocus?: boolean;
19
+ }
20
+
21
+ const PAGE_JUMP = 3;
22
+
23
+ const Wheel = ({ count, step, value, onChange, ariaLabel, autoFocus = false }: Props) => {
24
+ const viewportRef = useRef<HTMLDivElement>(null);
25
+ const itemRef = useRef<HTMLDivElement>(null);
26
+ const itemHeightRef = useRef<number>(0);
27
+ const scrollRafRef = useRef<number | null>(null);
28
+ const valueRef = useRef(value);
29
+ valueRef.current = value;
30
+
31
+ const items = Math.ceil(count / step);
32
+ const lastValue = (items - 1) * step;
33
+
34
+ const valueToIndex = useCallback((v: number) => {
35
+ const idx = Math.round(v / step);
36
+ if (idx < 0) {
37
+ return 0;
38
+ }
39
+ if (idx >= items) {
40
+ return items - 1;
41
+ }
42
+ return idx;
43
+ }, [items, step]);
44
+
45
+ const scrollToValue = useCallback((v: number, behavior: ScrollBehavior) => {
46
+ const vp = viewportRef.current;
47
+ const h = itemHeightRef.current;
48
+ if (!vp || h === 0) {
49
+ return;
50
+ }
51
+ const idx = valueToIndex(v);
52
+ vp.scrollTo({ top: idx * h, behavior });
53
+ }, [valueToIndex]);
54
+
55
+ useLayoutEffect(() => {
56
+ const item = itemRef.current;
57
+ if (!item) {
58
+ return;
59
+ }
60
+ itemHeightRef.current = item.getBoundingClientRect().height;
61
+ scrollToValue(valueRef.current, "auto");
62
+ // eslint-disable-next-line react-hooks/exhaustive-deps
63
+ }, []);
64
+
65
+ useEffect(() => {
66
+ const item = itemRef.current;
67
+ if (!item || typeof ResizeObserver === "undefined") {
68
+ return;
69
+ }
70
+ const ro = new ResizeObserver((entries) => {
71
+ const entry = entries[0];
72
+ if (!entry) {
73
+ return;
74
+ }
75
+ const h = entry.contentRect.height;
76
+ if (h > 0 && h !== itemHeightRef.current) {
77
+ itemHeightRef.current = h;
78
+ scrollToValue(valueRef.current, "auto");
79
+ }
80
+ });
81
+ ro.observe(item);
82
+ return () => {
83
+ ro.disconnect();
84
+ };
85
+ }, [scrollToValue]);
86
+
87
+ useEffect(() => {
88
+ const vp = viewportRef.current;
89
+ const h = itemHeightRef.current;
90
+ if (!vp || h === 0) {
91
+ return;
92
+ }
93
+ const currentIdx = Math.round(vp.scrollTop / h);
94
+ const desiredIdx = valueToIndex(value);
95
+ if (currentIdx !== desiredIdx) {
96
+ scrollToValue(value, "smooth");
97
+ }
98
+ }, [value, valueToIndex, scrollToValue]);
99
+
100
+ const handleScroll = useCallback(() => {
101
+ const vp = viewportRef.current;
102
+ if (!vp) {
103
+ return;
104
+ }
105
+ if (scrollRafRef.current != null) {
106
+ cancelAnimationFrame(scrollRafRef.current);
107
+ }
108
+ scrollRafRef.current = requestAnimationFrame(() => {
109
+ scrollRafRef.current = null;
110
+ const vpInner = viewportRef.current;
111
+ const h = itemHeightRef.current;
112
+ if (!vpInner || h === 0) {
113
+ return;
114
+ }
115
+ const rawIdx = Math.round(vpInner.scrollTop / h);
116
+ const clamped = Math.max(0, Math.min(items - 1, rawIdx));
117
+ const newValue = clamped * step;
118
+ if (newValue !== valueRef.current) {
119
+ onChange(newValue);
120
+ }
121
+ });
122
+ }, [items, step, onChange]);
123
+
124
+ const handleKeyDown = useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
125
+ let next: number;
126
+ switch (e.key) {
127
+ case "ArrowDown":
128
+ next = valueRef.current + step;
129
+ break;
130
+ case "ArrowUp":
131
+ next = valueRef.current - step;
132
+ break;
133
+ case "PageDown":
134
+ next = valueRef.current + (step * PAGE_JUMP);
135
+ break;
136
+ case "PageUp":
137
+ next = valueRef.current - (step * PAGE_JUMP);
138
+ break;
139
+ case "Home":
140
+ next = 0;
141
+ break;
142
+ case "End":
143
+ next = lastValue;
144
+ break;
145
+ default:
146
+ return;
147
+ }
148
+ e.preventDefault();
149
+ const clamped = Math.max(0, Math.min(lastValue, next));
150
+ if (clamped !== valueRef.current) {
151
+ onChange(clamped);
152
+ }
153
+ }, [step, lastValue, onChange]);
154
+
155
+ useEffect(() => () => {
156
+ if (scrollRafRef.current != null) {
157
+ cancelAnimationFrame(scrollRafRef.current);
158
+ }
159
+ }, []);
160
+
161
+ useEffect(() => {
162
+ if (autoFocus) {
163
+ viewportRef.current?.focus({ preventScroll: true });
164
+ }
165
+ // eslint-disable-next-line react-hooks/exhaustive-deps
166
+ }, []);
167
+
168
+ const itemElems: React.ReactElement[] = [];
169
+ for (let i = 0; i < items; i++) {
170
+ const v = i * step;
171
+ itemElems.push(
172
+ <StyledWheelItem key={i} ref={i === 0 ? itemRef : undefined}>
173
+ {padTwo(v)}
174
+ </StyledWheelItem>,
175
+ );
176
+ }
177
+
178
+ return (
179
+ <StyledWheelWrapper>
180
+ <StyledWheelViewport
181
+ ref={viewportRef}
182
+ onScroll={handleScroll}
183
+ onKeyDown={handleKeyDown}
184
+ role={"spinbutton"}
185
+ aria-label={ariaLabel}
186
+ aria-valuemin={0}
187
+ aria-valuemax={lastValue}
188
+ aria-valuenow={value}
189
+ aria-valuetext={padTwo(value)}
190
+ tabIndex={0}
191
+ >
192
+ <StyledWheelPadder />
193
+ {itemElems}
194
+ <StyledWheelPadder />
195
+ </StyledWheelViewport>
196
+ <StyledWheelFocusRing aria-hidden={true} />
197
+ </StyledWheelWrapper>
198
+ );
199
+ };
200
+
201
+ export { Wheel };
@@ -0,0 +1,66 @@
1
+ /** Pads a number to a 2-digit string with a leading zero (e.g. `7` → `"07"`). */
2
+ const padTwo = (n: number): string => n.toString().padStart(2, "0");
3
+
4
+ /** Clamps each completed pair in the digit buffer to a valid range: HH≤23, MM≤59, SS≤59. */
5
+ const clampDigits = (digits: string, withSeconds: boolean): string => {
6
+ if (digits.length < 2) {
7
+ return digits;
8
+ }
9
+ let hh = parseInt(digits.slice(0, 2), 10);
10
+ if (hh > 23) {
11
+ hh = 23;
12
+ }
13
+ let out = padTwo(hh);
14
+ if (digits.length < 4) {
15
+ return out + digits.slice(2);
16
+ }
17
+ let mm = parseInt(digits.slice(2, 4), 10);
18
+ if (mm > 59) {
19
+ mm = 59;
20
+ }
21
+ out += padTwo(mm);
22
+ if (!withSeconds || digits.length < 6) {
23
+ return out + digits.slice(4);
24
+ }
25
+ let ss = parseInt(digits.slice(4, 6), 10);
26
+ if (ss > 59) {
27
+ ss = 59;
28
+ }
29
+ out += padTwo(ss);
30
+ return out;
31
+ };
32
+
33
+ /**
34
+ * Parses a free-form time string into a clamped 2/4/6-digit buffer.
35
+ * Colon-aware: each colon-separated segment is padded to 2 digits, so `"3:40"` → `"0340"`.
36
+ * Used by the modal to extract HH/MM/SS from whatever the user typed.
37
+ */
38
+ const parseTimeText = (text: string, withSeconds: boolean): string => {
39
+ if (!text) {
40
+ return "";
41
+ }
42
+ const max = withSeconds ? 6 : 4;
43
+ const segments = text.split(":");
44
+ let raw: string;
45
+ if (segments.length === 1) {
46
+ raw = (segments[0] ?? "").replace(/\D/gu, "");
47
+ if (raw.length === 1) {
48
+ raw = "0" + raw;
49
+ }
50
+ }
51
+ else {
52
+ raw = segments.map((s) => {
53
+ const d = s.replace(/\D/gu, "");
54
+ if (d.length === 0) {
55
+ return "";
56
+ }
57
+ if (d.length === 1) {
58
+ return "0" + d;
59
+ }
60
+ return d.slice(0, 2);
61
+ }).join("");
62
+ }
63
+ return clampDigits(raw.slice(0, max), withSeconds);
64
+ };
65
+
66
+ export { padTwo, parseTimeText };
@@ -0,0 +1,38 @@
1
+ import React, { forwardRef } from "react";
2
+
3
+ interface Props {
4
+ className?: string;
5
+ }
6
+
7
+ const Clock = forwardRef<SVGSVGElement, Props>((props, ref) => {
8
+ return (
9
+ <svg
10
+ ref={ref}
11
+ width={"16"}
12
+ height={"16"}
13
+ viewBox={"0 0 16 16"}
14
+ xmlns={"http://www.w3.org/2000/svg"}
15
+ className={props.className}
16
+ >
17
+ <circle
18
+ cx={"8"}
19
+ cy={"8"}
20
+ r={"6.5"}
21
+ fill={"none"}
22
+ stroke={"currentColor"}
23
+ strokeWidth={"1.5"}
24
+ />
25
+ <path
26
+ fill={"none"}
27
+ stroke={"currentColor"}
28
+ strokeWidth={"1.5"}
29
+ strokeLinecap={"round"}
30
+ d={"M8 4.5V8l2.5 1.75"}
31
+ />
32
+ </svg>
33
+ );
34
+ });
35
+
36
+ Clock.displayName = "Clock";
37
+
38
+ export { Clock };
@@ -3,6 +3,7 @@ import React, { forwardRef } from "react";
3
3
  import { Back } from "./Back";
4
4
  import { Battery } from "./Battery";
5
5
  import { Checkmark } from "./Checkmark";
6
+ import { Clock } from "./Clock";
6
7
  import { Config } from "./Config";
7
8
  import { Dots } from "./Dots";
8
9
  import { Forward } from "./Forward";
@@ -20,6 +21,7 @@ enum ICON {
20
21
  trash = "trash",
21
22
  config = "config",
22
23
  dots = "dots",
24
+ clock = "clock",
23
25
  }
24
26
 
25
27
  interface Props {
@@ -39,6 +41,7 @@ const iconsMap = new Map<ICON, IconComponent>([
39
41
  [ICON.trash, Trash],
40
42
  [ICON.config, Config],
41
43
  [ICON.dots, Dots],
44
+ [ICON.clock, Clock],
42
45
  ]);
43
46
 
44
47
  const Icon = forwardRef<SVGSVGElement, Props>(({ name: iconName, ...props }, ref) => {