@lifesg/react-design-system 4.0.0-alpha.5 → 4.0.0-alpha.6

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 (445) hide show
  1. package/accordion/types.d.ts +1 -1
  2. package/breadcrumb/breadcrumb.d.ts +7 -0
  3. package/breadcrumb/breadcrumb.js.map +1 -1
  4. package/breadcrumb/types.d.ts +31 -0
  5. package/button/button.d.ts +1 -0
  6. package/button/button.js.map +1 -1
  7. package/button/types.d.ts +42 -9
  8. package/calendar/calendar.d.ts +3 -0
  9. package/calendar/calendar.js.map +1 -1
  10. package/calendar/types.d.ts +43 -7
  11. package/card/card.d.ts +1 -0
  12. package/card/card.js.map +1 -1
  13. package/card/types.d.ts +1 -0
  14. package/checkbox/checkbox.d.ts +3 -0
  15. package/checkbox/checkbox.js.map +1 -1
  16. package/checkbox/types.d.ts +19 -3
  17. package/cjs/breadcrumb/breadcrumb.js.map +1 -1
  18. package/cjs/button/button.js.map +1 -1
  19. package/cjs/calendar/calendar.js.map +1 -1
  20. package/cjs/card/card.js.map +1 -1
  21. package/cjs/checkbox/checkbox.js.map +1 -1
  22. package/cjs/data-table/data-table.js +1 -1
  23. package/cjs/data-table/data-table.js.map +1 -1
  24. package/cjs/data-table/data-table.styles.js +1 -1
  25. package/cjs/data-table/data-table.styles.js.map +1 -1
  26. package/cjs/data-table/data-table.styles_rxganh.css +27 -0
  27. package/cjs/external/dompurify/dist/purify.es.js +2 -2
  28. package/cjs/external/dompurify/dist/purify.es.js.map +1 -1
  29. package/cjs/external/lodash/_setCacheHas.js.map +1 -1
  30. package/cjs/external/lodash/lodash.js +1 -1
  31. package/cjs/external/lodash/lodash.js.map +1 -1
  32. package/cjs/form/form-label-addon.js +1 -1
  33. package/cjs/form/form-label-addon.js.map +1 -1
  34. package/cjs/form/index.js +1 -1
  35. package/cjs/form/index.js.map +1 -1
  36. package/cjs/fullscreen-image-carousel/fullscreen-image-carousel.js +1 -1
  37. package/cjs/fullscreen-image-carousel/fullscreen-image-carousel.js.map +1 -1
  38. package/cjs/histogram-slider/histogram-slider.js.map +1 -1
  39. package/cjs/image-button/image-button.js.map +1 -1
  40. package/cjs/index.js +1 -1
  41. package/cjs/input/input.js.map +1 -1
  42. package/cjs/input-group/input-group.js.map +1 -1
  43. package/cjs/input-multi-select/input-multi-select.js.map +1 -1
  44. package/cjs/input-nested-multi-select/input-nested-multi-select.js.map +1 -1
  45. package/cjs/input-nested-select/input-nested-select.js.map +1 -1
  46. package/cjs/input-range-select/input-range-select.js.map +1 -1
  47. package/cjs/input-range-slider/input-range-slider.js.map +1 -1
  48. package/cjs/input-select/input-select.js.map +1 -1
  49. package/cjs/input-slider/input-slider.js.map +1 -1
  50. package/cjs/input-textarea/textarea.js.map +1 -1
  51. package/cjs/language-switcher/language-switcher.js.map +1 -1
  52. package/cjs/layout/index.js +1 -1
  53. package/cjs/layout/index.js.map +1 -1
  54. package/cjs/link-list/link-list.js.map +1 -1
  55. package/cjs/local-nav/local-nav-dropdown/local-nav-dropdown.js.map +1 -1
  56. package/cjs/local-nav/local-nav-menu/local-nav-menu.js.map +1 -1
  57. package/cjs/markup/markup.js.map +1 -1
  58. package/cjs/masked-input/masked-input.js.map +1 -1
  59. package/cjs/masthead/masthead.js.map +1 -1
  60. package/cjs/menu/menu.js +1 -1
  61. package/cjs/menu/menu.js.map +1 -1
  62. package/cjs/modal/index.js.map +1 -1
  63. package/cjs/modal/modal-box.js +1 -1
  64. package/cjs/modal/modal-box.js.map +1 -1
  65. package/cjs/modal-v2/index.js +1 -1
  66. package/cjs/modal-v2/index.js.map +1 -1
  67. package/cjs/modal-v2/modal-v2.js +1 -1
  68. package/cjs/modal-v2/modal-v2.js.map +1 -1
  69. package/cjs/modal-v2/slots/card.js +1 -1
  70. package/cjs/modal-v2/slots/card.js.map +1 -1
  71. package/cjs/navbar/navbar.js.map +1 -1
  72. package/cjs/notification-banner/notification-banner-hoc.js.map +1 -1
  73. package/cjs/notification-banner/notification-banner.js.map +1 -1
  74. package/cjs/otp-input/otp-input.js.map +1 -1
  75. package/cjs/otp-verification/otp-verification.js.map +1 -1
  76. package/cjs/overlay/overlay.js.map +1 -1
  77. package/cjs/pagination/pagination.js.map +1 -1
  78. package/cjs/phone-number-input/phone-number-input.js.map +1 -1
  79. package/cjs/pill/pill.js.map +1 -1
  80. package/cjs/popover/popover-inline/popover-inline.js.map +1 -1
  81. package/cjs/popover/popover-trigger.js.map +1 -1
  82. package/cjs/popover/popover.js +1 -1
  83. package/cjs/popover/popover.js.map +1 -1
  84. package/cjs/predictive-text-input/predictive-text-input.js.map +1 -1
  85. package/cjs/progress-indicator/progress-indicator.js.map +1 -1
  86. package/cjs/radio-button/radio-button.js.map +1 -1
  87. package/cjs/schedule/schedule.js.map +1 -1
  88. package/cjs/schedule/shared/with-optional-popover.js +1 -1
  89. package/cjs/schedule/shared/with-optional-popover.js.map +1 -1
  90. package/cjs/select-histogram/select-histogram.js.map +1 -1
  91. package/cjs/sidenav/sidenav.js.map +1 -1
  92. package/cjs/singpass-button/singpass-button.js.map +1 -1
  93. package/cjs/smart-app-banner/smart-app-banner.js.map +1 -1
  94. package/cjs/tab/tab.js.map +1 -1
  95. package/cjs/table/table.js.map +1 -1
  96. package/cjs/table/table.styles.js +1 -1
  97. package/cjs/table/table.styles.js.map +1 -1
  98. package/{table/table.styles_1af5ipv.css → cjs/table/table.styles_1vjx31g.css} +1 -1
  99. package/cjs/tag/tag.js.map +1 -1
  100. package/cjs/text-list/index.js.map +1 -1
  101. package/cjs/theme/theme-provider/breakpoint.js +1 -1
  102. package/cjs/theme/theme-provider/breakpoint.js.map +1 -1
  103. package/cjs/theme/theme-provider/hooks.js.map +1 -1
  104. package/cjs/theme/theme-provider/index.js.map +1 -1
  105. package/cjs/theme/tokens/border.js.map +1 -1
  106. package/cjs/theme/tokens/breakpoint.js.map +1 -1
  107. package/cjs/theme/tokens/colour.js.map +1 -1
  108. package/cjs/theme/tokens/component.js.map +1 -1
  109. package/cjs/theme/tokens/font.js.map +1 -1
  110. package/cjs/theme/tokens/media-query.js.map +1 -1
  111. package/cjs/theme/tokens/motion.js.map +1 -1
  112. package/cjs/theme/tokens/radius.js.map +1 -1
  113. package/cjs/theme/tokens/shadow.js.map +1 -1
  114. package/cjs/theme/tokens/spacing.js.map +1 -1
  115. package/cjs/theme/types.js.map +1 -1
  116. package/cjs/theme/utils/css-variable.js.map +1 -1
  117. package/cjs/theme/utils/font.js.map +1 -1
  118. package/cjs/theme/utils/use-apply-styles.js +1 -1
  119. package/cjs/theme/utils/use-apply-styles.js.map +1 -1
  120. package/cjs/theme/utils/use-design-token-override.js.map +1 -1
  121. package/cjs/theme/utils/use-design-token.js.map +1 -1
  122. package/cjs/theme/utils/use-media-query.js.map +1 -1
  123. package/cjs/time-range-picker/combobox-picker/combobox-picker.js +1 -1
  124. package/cjs/time-range-picker/combobox-picker/combobox-picker.js.map +1 -1
  125. package/cjs/time-range-picker/common.styles.js +1 -1
  126. package/cjs/time-range-picker/common.styles.js.map +1 -1
  127. package/{time-range-picker/common.styles_1qwp4xa.css → cjs/time-range-picker/common.styles_cnkkax.css} +2 -1
  128. package/cjs/time-range-picker/dial-picker/dial-picker.js +1 -1
  129. package/cjs/time-range-picker/dial-picker/dial-picker.js.map +1 -1
  130. package/cjs/time-range-picker/time-range-picker.js.map +1 -1
  131. package/cjs/time-slot-bar/time-slot-bar.js.map +1 -1
  132. package/cjs/time-slot-bar-week/time-slot-bar-week.js.map +1 -1
  133. package/cjs/time-slot-week-view/time-slot-week-view.js.map +1 -1
  134. package/cjs/timeline/timeline.js.map +1 -1
  135. package/cjs/timepicker/timepicker.js +1 -1
  136. package/cjs/timepicker/timepicker.js.map +1 -1
  137. package/cjs/timepicker/timepicker.styles.js +1 -1
  138. package/cjs/timepicker/timepicker.styles.js.map +1 -1
  139. package/cjs/timepicker/timepicker.styles_lyizvq.css +2 -0
  140. package/cjs/timetable/timetable-row/with-optional-popover.js +1 -1
  141. package/cjs/timetable/timetable-row/with-optional-popover.js.map +1 -1
  142. package/cjs/timetable/timetable.js +1 -1
  143. package/cjs/timetable/timetable.js.map +1 -1
  144. package/cjs/toast/toast.js.map +1 -1
  145. package/cjs/toggle/toggle.js.map +1 -1
  146. package/cjs/typography/index.js.map +1 -1
  147. package/cjs/uneditable-section/index.js.map +1 -1
  148. package/cjs/unit-number/unit-number-input.js.map +1 -1
  149. package/cjs/util/merge-refs.js.map +1 -1
  150. package/cjs/util/use-throttle.js +2 -0
  151. package/cjs/util/use-throttle.js.map +1 -0
  152. package/countdown-timer/types.d.ts +3 -3
  153. package/data-table/data-table.js +1 -1
  154. package/data-table/data-table.js.map +1 -1
  155. package/data-table/data-table.styles.d.ts +2 -1
  156. package/data-table/data-table.styles.js +1 -1
  157. package/data-table/data-table.styles.js.map +1 -1
  158. package/data-table/data-table.styles_rxganh.css +27 -0
  159. package/date-range-input/types.d.ts +1 -1
  160. package/drawer/types.d.ts +1 -1
  161. package/e-signature/types.d.ts +1 -1
  162. package/external/dompurify/dist/purify.es.js +2 -2
  163. package/external/dompurify/dist/purify.es.js.map +1 -1
  164. package/external/lodash/_setCacheHas.js.map +1 -1
  165. package/external/lodash/lodash.js +1 -1
  166. package/external/lodash/lodash.js.map +1 -1
  167. package/file-upload/types.d.ts +0 -1
  168. package/filter/types.d.ts +6 -10
  169. package/form/form-label-addon.js +1 -1
  170. package/form/form-label-addon.js.map +1 -1
  171. package/form/index.d.ts +65 -8
  172. package/form/index.js +1 -1
  173. package/form/index.js.map +1 -1
  174. package/form/types.d.ts +155 -6
  175. package/fullscreen-image-carousel/fullscreen-image-carousel.d.ts +7 -0
  176. package/fullscreen-image-carousel/fullscreen-image-carousel.js +1 -1
  177. package/fullscreen-image-carousel/fullscreen-image-carousel.js.map +1 -1
  178. package/fullscreen-image-carousel/types.d.ts +91 -3
  179. package/histogram-slider/histogram-slider.d.ts +6 -0
  180. package/histogram-slider/histogram-slider.js.map +1 -1
  181. package/histogram-slider/types.d.ts +63 -3
  182. package/image-button/image-button.d.ts +6 -0
  183. package/image-button/image-button.js.map +1 -1
  184. package/image-button/types.d.ts +11 -1
  185. package/index.js +1 -1
  186. package/input/input.d.ts +6 -0
  187. package/input/input.js.map +1 -1
  188. package/input/types.d.ts +38 -2
  189. package/input-group/input-group.d.ts +7 -0
  190. package/input-group/input-group.js.map +1 -1
  191. package/input-group/types.d.ts +84 -8
  192. package/input-multi-select/input-multi-select.d.ts +6 -0
  193. package/input-multi-select/input-multi-select.js.map +1 -1
  194. package/input-multi-select/types.d.ts +46 -5
  195. package/input-nested-multi-select/input-nested-multi-select.d.ts +8 -0
  196. package/input-nested-multi-select/input-nested-multi-select.js.map +1 -1
  197. package/input-nested-multi-select/types.d.ts +35 -5
  198. package/input-nested-select/input-nested-select.d.ts +9 -2
  199. package/input-nested-select/input-nested-select.js.map +1 -1
  200. package/input-nested-select/types.d.ts +77 -8
  201. package/input-range-select/input-range-select.d.ts +6 -0
  202. package/input-range-select/input-range-select.js.map +1 -1
  203. package/input-range-select/types.d.ts +68 -1
  204. package/input-range-slider/input-range-slider.d.ts +7 -0
  205. package/input-range-slider/input-range-slider.js.map +1 -1
  206. package/input-range-slider/types.d.ts +91 -6
  207. package/input-select/input-select.d.ts +5 -0
  208. package/input-select/input-select.js.map +1 -1
  209. package/input-select/types.d.ts +70 -14
  210. package/input-slider/input-slider.d.ts +6 -0
  211. package/input-slider/input-slider.js.map +1 -1
  212. package/input-slider/types.d.ts +21 -2
  213. package/input-textarea/textarea.d.ts +3 -0
  214. package/input-textarea/textarea.js.map +1 -1
  215. package/input-textarea/types.d.ts +24 -1
  216. package/language-switcher/language-switcher.d.ts +6 -0
  217. package/language-switcher/language-switcher.js.map +1 -1
  218. package/language-switcher/types.d.ts +23 -0
  219. package/layout/index.d.ts +16 -2
  220. package/layout/index.js +1 -1
  221. package/layout/index.js.map +1 -1
  222. package/layout/types.d.ts +61 -3
  223. package/link-list/internal-types.d.ts +57 -3
  224. package/link-list/link-list.d.ts +6 -0
  225. package/link-list/link-list.js.map +1 -1
  226. package/link-list/types.d.ts +3 -0
  227. package/local-nav/local-nav-dropdown/local-nav-dropdown.d.ts +11 -0
  228. package/local-nav/local-nav-dropdown/local-nav-dropdown.js.map +1 -1
  229. package/local-nav/local-nav-menu/local-nav-menu.d.ts +6 -0
  230. package/local-nav/local-nav-menu/local-nav-menu.js.map +1 -1
  231. package/local-nav/types.d.ts +51 -0
  232. package/markup/markup.d.ts +6 -0
  233. package/markup/markup.js.map +1 -1
  234. package/markup/types.d.ts +6 -2
  235. package/masked-input/masked-input.d.ts +6 -0
  236. package/masked-input/masked-input.js.map +1 -1
  237. package/masked-input/types.d.ts +83 -8
  238. package/masthead/masthead.d.ts +6 -0
  239. package/masthead/masthead.js.map +1 -1
  240. package/masthead/types.d.ts +9 -0
  241. package/menu/menu.d.ts +27 -4
  242. package/menu/menu.js +1 -1
  243. package/menu/menu.js.map +1 -1
  244. package/menu/types.d.ts +32 -0
  245. package/modal/index.d.ts +13 -0
  246. package/modal/index.js.map +1 -1
  247. package/modal/modal-box.js +1 -1
  248. package/modal/modal-box.js.map +1 -1
  249. package/modal/types.d.ts +54 -7
  250. package/modal-v2/index.d.ts +1 -15
  251. package/modal-v2/index.js +1 -1
  252. package/modal-v2/index.js.map +1 -1
  253. package/modal-v2/modal-v2.d.ts +32 -1
  254. package/modal-v2/modal-v2.js +1 -1
  255. package/modal-v2/modal-v2.js.map +1 -1
  256. package/modal-v2/slots/card.js +1 -1
  257. package/modal-v2/slots/card.js.map +1 -1
  258. package/modal-v2/types.d.ts +75 -8
  259. package/navbar/navbar.d.ts +7 -0
  260. package/navbar/navbar.js.map +1 -1
  261. package/navbar/types.d.ts +200 -13
  262. package/notification-banner/notification-banner-hoc.d.ts +6 -0
  263. package/notification-banner/notification-banner-hoc.js.map +1 -1
  264. package/notification-banner/notification-banner.d.ts +7 -0
  265. package/notification-banner/notification-banner.js.map +1 -1
  266. package/notification-banner/types.d.ts +57 -2
  267. package/otp-input/otp-input.d.ts +7 -0
  268. package/otp-input/otp-input.js.map +1 -1
  269. package/otp-input/types.d.ts +54 -11
  270. package/otp-verification/internal-types.d.ts +22 -5
  271. package/otp-verification/otp-verification.d.ts +6 -0
  272. package/otp-verification/otp-verification.js.map +1 -1
  273. package/otp-verification/types.d.ts +125 -6
  274. package/overlay/overlay.d.ts +7 -0
  275. package/overlay/overlay.js.map +1 -1
  276. package/overlay/types.d.ts +57 -2
  277. package/package.json +1 -1
  278. package/pagination/pagination.d.ts +5 -0
  279. package/pagination/pagination.js.map +1 -1
  280. package/pagination/types.d.ts +48 -0
  281. package/phone-number-input/phone-number-input.d.ts +7 -0
  282. package/phone-number-input/phone-number-input.js.map +1 -1
  283. package/phone-number-input/types.d.ts +78 -13
  284. package/pill/pill.d.ts +6 -0
  285. package/pill/pill.js.map +1 -1
  286. package/pill/types.d.ts +19 -0
  287. package/popover/popover-inline/popover-inline.d.ts +5 -0
  288. package/popover/popover-inline/popover-inline.js.map +1 -1
  289. package/popover/popover-trigger.d.ts +6 -0
  290. package/popover/popover-trigger.js.map +1 -1
  291. package/popover/popover.d.ts +6 -0
  292. package/popover/popover.js +1 -1
  293. package/popover/popover.js.map +1 -1
  294. package/popover/types.d.ts +150 -3
  295. package/predictive-text-input/predictive-text-input.d.ts +6 -0
  296. package/predictive-text-input/predictive-text-input.js.map +1 -1
  297. package/predictive-text-input/types.d.ts +65 -11
  298. package/progress-indicator/progress-indicator.d.ts +7 -0
  299. package/progress-indicator/progress-indicator.js.map +1 -1
  300. package/progress-indicator/types.d.ts +18 -0
  301. package/radio-button/radio-button.d.ts +5 -0
  302. package/radio-button/radio-button.js.map +1 -1
  303. package/radio-button/types.d.ts +11 -0
  304. package/schedule/internal-types.d.ts +18 -0
  305. package/schedule/schedule-day-view/types.d.ts +2 -1
  306. package/schedule/schedule-week-view/types.d.ts +2 -1
  307. package/schedule/schedule.d.ts +3 -0
  308. package/schedule/schedule.js.map +1 -1
  309. package/schedule/shared/with-optional-popover.js +1 -1
  310. package/schedule/shared/with-optional-popover.js.map +1 -1
  311. package/schedule/types.d.ts +129 -10
  312. package/select-histogram/select-histogram.d.ts +5 -0
  313. package/select-histogram/select-histogram.js.map +1 -1
  314. package/select-histogram/types.d.ts +57 -4
  315. package/shared/dropdown-list/types.d.ts +52 -19
  316. package/shared/dropdown-wrapper/types.d.ts +6 -0
  317. package/sidenav/sidenav.d.ts +10 -0
  318. package/sidenav/sidenav.js.map +1 -1
  319. package/sidenav/types.d.ts +70 -21
  320. package/singpass-button/singpass-button.d.ts +6 -0
  321. package/singpass-button/singpass-button.js.map +1 -1
  322. package/singpass-button/types.d.ts +29 -2
  323. package/smart-app-banner/smart-app-banner.d.ts +5 -0
  324. package/smart-app-banner/smart-app-banner.js.map +1 -1
  325. package/smart-app-banner/types.d.ts +54 -0
  326. package/tab/tab.d.ts +7 -0
  327. package/tab/tab.js.map +1 -1
  328. package/tab/types.d.ts +55 -6
  329. package/table/table.d.ts +21 -0
  330. package/table/table.js.map +1 -1
  331. package/table/table.styles.js +1 -1
  332. package/table/table.styles.js.map +1 -1
  333. package/{cjs/table/table.styles_1af5ipv.css → table/table.styles_1vjx31g.css} +1 -1
  334. package/tag/tag.d.ts +5 -0
  335. package/tag/tag.js.map +1 -1
  336. package/tag/types.d.ts +24 -0
  337. package/text-list/index.d.ts +17 -0
  338. package/text-list/index.js.map +1 -1
  339. package/text-list/types.d.ts +33 -4
  340. package/theme/theme-provider/breakpoint.d.ts +0 -1
  341. package/theme/theme-provider/breakpoint.js +1 -1
  342. package/theme/theme-provider/breakpoint.js.map +1 -1
  343. package/theme/theme-provider/hooks.d.ts +16 -0
  344. package/theme/theme-provider/hooks.js.map +1 -1
  345. package/theme/theme-provider/index.d.ts +7 -0
  346. package/theme/theme-provider/index.js.map +1 -1
  347. package/theme/theme-provider/types.d.ts +14 -0
  348. package/theme/tokens/border.d.ts +3 -0
  349. package/theme/tokens/border.js.map +1 -1
  350. package/theme/tokens/breakpoint.d.ts +3 -0
  351. package/theme/tokens/breakpoint.js.map +1 -1
  352. package/theme/tokens/colour.d.ts +3 -0
  353. package/theme/tokens/colour.js.map +1 -1
  354. package/theme/tokens/component.d.ts +1 -0
  355. package/theme/tokens/component.js.map +1 -1
  356. package/theme/tokens/font.d.ts +2 -0
  357. package/theme/tokens/font.js.map +1 -1
  358. package/theme/tokens/media-query.d.ts +1 -0
  359. package/theme/tokens/media-query.js.map +1 -1
  360. package/theme/tokens/motion.d.ts +1 -0
  361. package/theme/tokens/motion.js.map +1 -1
  362. package/theme/tokens/radius.d.ts +1 -0
  363. package/theme/tokens/radius.js.map +1 -1
  364. package/theme/tokens/shadow.d.ts +1 -0
  365. package/theme/tokens/shadow.js.map +1 -1
  366. package/theme/tokens/spacing.d.ts +1 -0
  367. package/theme/tokens/spacing.js.map +1 -1
  368. package/theme/types.d.ts +23 -3
  369. package/theme/types.js.map +1 -1
  370. package/theme/utils/css-variable.d.ts +10 -2
  371. package/theme/utils/css-variable.js.map +1 -1
  372. package/theme/utils/font.d.ts +2 -1
  373. package/theme/utils/font.js.map +1 -1
  374. package/theme/utils/use-apply-styles.d.ts +8 -2
  375. package/theme/utils/use-apply-styles.js +1 -1
  376. package/theme/utils/use-apply-styles.js.map +1 -1
  377. package/theme/utils/use-design-token-override.d.ts +9 -1
  378. package/theme/utils/use-design-token-override.js.map +1 -1
  379. package/theme/utils/use-design-token.d.ts +9 -0
  380. package/theme/utils/use-design-token.js.map +1 -1
  381. package/theme/utils/use-media-query.d.ts +41 -3
  382. package/theme/utils/use-media-query.js.map +1 -1
  383. package/time-range-picker/combobox-picker/combobox-picker.js +1 -1
  384. package/time-range-picker/combobox-picker/combobox-picker.js.map +1 -1
  385. package/time-range-picker/common.styles.d.ts +1 -0
  386. package/time-range-picker/common.styles.js +1 -1
  387. package/time-range-picker/common.styles.js.map +1 -1
  388. package/{cjs/time-range-picker/common.styles_1qwp4xa.css → time-range-picker/common.styles_cnkkax.css} +2 -1
  389. package/time-range-picker/dial-picker/dial-picker.js +1 -1
  390. package/time-range-picker/dial-picker/dial-picker.js.map +1 -1
  391. package/time-range-picker/time-range-picker.d.ts +5 -0
  392. package/time-range-picker/time-range-picker.js.map +1 -1
  393. package/time-range-picker/types.d.ts +85 -25
  394. package/time-slot-bar/internal-types.d.ts +1 -0
  395. package/time-slot-bar/time-slot-bar.d.ts +7 -0
  396. package/time-slot-bar/time-slot-bar.js.map +1 -1
  397. package/time-slot-bar/types.d.ts +112 -20
  398. package/time-slot-bar-week/time-slot-bar-week.d.ts +8 -0
  399. package/time-slot-bar-week/time-slot-bar-week.js.map +1 -1
  400. package/time-slot-bar-week/types.d.ts +74 -13
  401. package/time-slot-week-view/time-slot-week-view.d.ts +7 -0
  402. package/time-slot-week-view/time-slot-week-view.js.map +1 -1
  403. package/time-slot-week-view/types.d.ts +53 -10
  404. package/timeline/timeline.d.ts +6 -0
  405. package/timeline/timeline.js.map +1 -1
  406. package/timeline/types.d.ts +58 -4
  407. package/timepicker/timepicker.d.ts +5 -0
  408. package/timepicker/timepicker.js +1 -1
  409. package/timepicker/timepicker.js.map +1 -1
  410. package/timepicker/timepicker.styles.d.ts +1 -0
  411. package/timepicker/timepicker.styles.js +1 -1
  412. package/timepicker/timepicker.styles.js.map +1 -1
  413. package/timepicker/timepicker.styles_lyizvq.css +2 -0
  414. package/timepicker/types.d.ts +49 -14
  415. package/timetable/timetable-row/with-optional-popover.js +1 -1
  416. package/timetable/timetable-row/with-optional-popover.js.map +1 -1
  417. package/timetable/timetable.d.ts +6 -0
  418. package/timetable/timetable.js +1 -1
  419. package/timetable/timetable.js.map +1 -1
  420. package/timetable/types.d.ts +175 -50
  421. package/toast/toast.d.ts +6 -0
  422. package/toast/toast.js.map +1 -1
  423. package/toast/types.d.ts +42 -8
  424. package/toggle/toggle.d.ts +6 -0
  425. package/toggle/toggle.js.map +1 -1
  426. package/toggle/types.d.ts +95 -17
  427. package/typography/index.d.ts +29 -0
  428. package/typography/index.js.map +1 -1
  429. package/typography/types.d.ts +51 -8
  430. package/uneditable-section/index.d.ts +15 -0
  431. package/uneditable-section/index.js.map +1 -1
  432. package/uneditable-section/types.d.ts +66 -23
  433. package/unit-number/types.d.ts +30 -4
  434. package/unit-number/unit-number-input.d.ts +6 -0
  435. package/unit-number/unit-number-input.js.map +1 -1
  436. package/util/index.d.ts +1 -0
  437. package/util/merge-refs.d.ts +1 -1
  438. package/util/merge-refs.js.map +1 -1
  439. package/util/use-throttle.d.ts +1 -0
  440. package/util/use-throttle.js +2 -0
  441. package/util/use-throttle.js.map +1 -0
  442. package/cjs/data-table/data-table.styles_1iqq1g7.css +0 -26
  443. package/cjs/timepicker/timepicker.styles_1jm33yw.css +0 -1
  444. package/data-table/data-table.styles_1iqq1g7.css +0 -26
  445. package/timepicker/timepicker.styles_1jm33yw.css +0 -1
@@ -1,27 +1,82 @@
1
1
  import type { TypographyLinkProps, TypographyProps } from "../typography";
2
+ /**
3
+ * Props for the `NotificationBanner` component.
4
+ *
5
+ * When `onClick` is provided, the entire banner becomes interactive and a
6
+ * visually hidden accessible button is rendered for keyboard and screen-reader
7
+ * users.
8
+ */
2
9
  export interface NotificationBannerProps extends React.HTMLAttributes<HTMLDivElement> {
3
10
  children?: React.ReactNode | undefined;
11
+ /**
12
+ * Whether the dismiss button is rendered. The caller is responsible
13
+ * for dismissing the banner in the callback.
14
+ *
15
+ * @default true
16
+ */
4
17
  dismissible?: boolean | undefined;
18
+ /**
19
+ * Controls the visibility of the banner.
20
+ *
21
+ * @default true
22
+ */
5
23
  visible?: boolean | undefined;
24
+ /**
25
+ * Whether the banner sticks to the top of the viewport while the page
26
+ * scrolls.
27
+ *
28
+ * @default true
29
+ */
6
30
  sticky?: boolean | undefined;
31
+ /**
32
+ * An optional icon element rendered at the leading edge of the banner.
33
+ */
7
34
  icon?: JSX.Element | undefined;
35
+ /**
36
+ * Called when the user activates the dismiss button and `dismissible` is `true`.
37
+ */
8
38
  onDismiss?: (() => void) | undefined;
9
39
  "data-testid"?: string | undefined;
10
- /** Specifies the maximum height of content, after which it is collapsed */
40
+ /**
41
+ * Maximum height in pixels for the content area. When the rendered content
42
+ * exceeds this value, the overflow is clipped.
43
+ */
11
44
  maxCollapsedHeight?: number | undefined;
12
- /** Action button that will be displayed */
45
+ /**
46
+ * An action button rendered inside the content area. When
47
+ * `actionButton.onClick` is provided it stops propagation to the banner's
48
+ * own `onClick` handler.
49
+ */
13
50
  actionButton?: React.ButtonHTMLAttributes<HTMLButtonElement> | undefined;
14
51
  }
52
+ /**
53
+ * Props for the `withNotificationBanner` HOC wrapper,
54
+ * extending `NotificationBannerProps` with a forwarded ref.
55
+ */
15
56
  export interface NotificationBannerWithForwardedRefProps extends NotificationBannerProps {
16
57
  forwardedRef?: React.Ref<HTMLDivElement> | undefined;
17
58
  }
59
+ /**
60
+ * Discriminant for `NotificationContentAttributes` content items.
61
+ *
62
+ * - `"text"` items are sanitized and injected as HTML paragraphs.
63
+ * - `"link"` items are rendered as `NotificationBanner.Link` elements.
64
+ */
18
65
  export type ContentType = "text" | "link";
66
+ /** Props for a `"link"` content item inside a notification banner. */
19
67
  export interface ContentLinkAttributes extends TypographyLinkProps {
20
68
  }
69
+ /** Props for a `"text"` content item inside a notification banner. */
21
70
  export interface ContentTextAttributes extends TypographyProps {
22
71
  }
72
+ /**
73
+ * A single content item for use with `withNotificationBanner`.
74
+ */
23
75
  export interface NotificationContentAttributes {
76
+ /** Determines how `content` is rendered inside the banner. */
24
77
  type: ContentType;
78
+ /** The text string or link label to display. */
25
79
  content: string;
80
+ /** Additional props forwarded to the rendered text or link element. */
26
81
  otherAttributes?: TypographyLinkProps | TypographyProps | undefined;
27
82
  }
@@ -1,3 +1,10 @@
1
1
  import type React from "react";
2
2
  import type { OtpInputProps, OtpInputRef } from "./types";
3
+ /**
4
+ * A field composed of individual inputs for a numeric one-time password
5
+ * with an in-built countdown mechanism.
6
+ *
7
+ * Use `OtpInput` when users must enter the one-time password (OTP)
8
+ * for multi-factored authentication methods.
9
+ */
3
10
  export declare const OtpInput: (props: OtpInputProps & React.RefAttributes<OtpInputRef>) => React.ReactElement | null;
@@ -1 +1 @@
1
- {"version":3,"file":"otp-input.js","sources":["../../src/otp-input/otp-input.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport type React from \"react\";\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\n\nimport { Button } from \"../button\";\nimport { FormErrorMessage } from \"../form/form-label\";\nimport { Input } from \"../input\";\nimport { VisuallyHidden } from \"../shared/accessibility\";\nimport { Typography } from \"../typography\";\nimport { StringHelper, useId } from \"../util\";\nimport * as styles from \"./otp-input.styles\";\nimport type { OtpInputProps, OtpInputRef } from \"./types\";\nimport { stripOtpFromAutofill, validateUserInput } from \"./utils\";\n\nconst Component = (\n {\n id,\n value = [],\n \"data-testid\": dataTestId,\n className,\n cooldownDuration,\n actionButtonProps,\n errorMessage,\n numOfInput,\n prefix,\n onChange,\n onCooldownStart,\n onCooldownEnd,\n otpOnly,\n onCountdownChange,\n ...otherProps\n }: OtpInputProps,\n ref: React.Ref<OtpInputRef>\n) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const {\n disabled,\n onClick,\n styleType = \"secondary\",\n ...otherCtaProps\n } = actionButtonProps ?? {};\n\n const inputRefs = useRef<(HTMLInputElement | null)[]>([]);\n const onChangeRef = useRef(onChange);\n\n const [otpValues, setOtpValues] = useState<string[]>(\n new Array(numOfInput).fill(\"\")\n );\n const [countDown, setCountDown] = useState<number>(cooldownDuration);\n const [lastCtaTimestamp, setLastCtaTimestamp] = useState<Date>(new Date());\n const internalId = useId();\n\n const hasError = !!errorMessage;\n const errorId = `${internalId}-error`;\n const timerId = `${internalId}-timer`;\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n inputRefs?.current[0]?.focus();\n document.addEventListener(\"paste\", handlePaste);\n return () => document.removeEventListener(\"paste\", handlePaste);\n }, []);\n\n useEffect(() => {\n if (cooldownDuration !== 0) {\n if (onCooldownStart) onCooldownStart();\n const cleanup = beginCountdown();\n\n return () => cleanup();\n }\n }, [lastCtaTimestamp]);\n\n useImperativeHandle(ref, () => ({\n startCooldown: () => {\n setLastCtaTimestamp(new Date());\n setCountDown(cooldownDuration);\n },\n }));\n\n useEffect(() => {\n onChangeRef.current = onChange;\n }, [onChange]);\n\n useEffect(() => {\n if (value.length === numOfInput) {\n setOtpValues(value);\n }\n }, [value]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleInputFullValue = (incomingValue: string) => {\n if (incomingValue && validateUserInput(incomingValue, numOfInput)) {\n const incomingValueArr = incomingValue.split(\"\");\n setOtpValues(incomingValueArr);\n if (onChangeRef.current) {\n onChangeRef.current(incomingValueArr);\n }\n\n return true;\n }\n\n return false;\n };\n\n const handleChange =\n (index: number) => (event: React.ChangeEvent<HTMLInputElement>) => {\n const eventValue = event.target.value;\n\n /* handle autofill */\n const fieldIsEmpty = otpValues.every((num) => num === \"\");\n const autofillOtp = stripOtpFromAutofill(\n eventValue,\n numOfInput,\n prefix\n );\n if (fieldIsEmpty && handleInputFullValue(autofillOtp)) {\n return;\n }\n\n /* handle normal input */\n const value = eventValue.replace(/[^0-9]/g, \"\");\n if (validateUserInput(value)) {\n const newOtpValues = [...otpValues];\n\n newOtpValues[index] = value.substring(value.length - 1);\n inputRefs.current[index + 1]?.focus();\n\n setOtpValues(newOtpValues);\n\n if (onChange) {\n onChange(newOtpValues);\n }\n }\n };\n\n const handleKeyDown =\n (index: number) => (event: React.KeyboardEvent<HTMLInputElement>) => {\n const { key, code } = event;\n\n if (key === \"Backspace\" || code === \"Backspace\") {\n const newOtpValues = [...otpValues];\n if (newOtpValues[index] !== \"\") {\n newOtpValues[index] = \"\";\n } else if (index !== 0) {\n newOtpValues[index - 1] = \"\";\n inputRefs.current[index - 1]?.focus();\n }\n\n setOtpValues(newOtpValues);\n\n if (onChange) {\n onChange(newOtpValues);\n }\n } else if (event.code === \"ArrowRight\") {\n inputRefs.current[index + 1]?.focus();\n } else if (event.code === \"ArrowLeft\") {\n inputRefs.current[index - 1]?.focus();\n }\n };\n\n const handlePaste = (event: ClipboardEvent): void => {\n if (!event.clipboardData) return;\n\n const pastedValue = event.clipboardData.getData(\"text\");\n const autofillOtp = stripOtpFromAutofill(\n pastedValue,\n numOfInput,\n prefix\n );\n if (!handleInputFullValue(autofillOtp)) {\n event.preventDefault();\n }\n };\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n setOtpValues(new Array(numOfInput).fill(\"\"));\n\n if (!isWithinCooldown()) {\n setLastCtaTimestamp(new Date());\n setCountDown(cooldownDuration);\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n // =========================================================================\n // HELPER FUNCTIONS\n // =========================================================================\n const isWithinCooldown = (): boolean => {\n const currentTime = Date.now();\n const coolDownInMilliseconds = cooldownDuration * 1000;\n\n return (\n currentTime < lastCtaTimestamp.valueOf() + coolDownInMilliseconds\n );\n };\n\n const beginCountdown = () => {\n const interval = setInterval(() => {\n const currentTime = Date.now();\n const coolDownInMilliseconds = cooldownDuration * 1000;\n\n const timer = Math.ceil(\n (lastCtaTimestamp.valueOf() +\n coolDownInMilliseconds -\n currentTime) /\n 1000\n );\n setCountDown(timer);\n if (timer <= 0) {\n if (onCooldownEnd) onCooldownEnd();\n clearInterval(interval);\n } else if (onCountdownChange) {\n onCountdownChange(timer);\n }\n }, 1000);\n\n return () => {\n clearInterval(interval);\n };\n };\n\n const generateId = (index: number, name: string, prefix?: string) => {\n return prefix\n ? `${prefix}-${name}-${index + 1}`\n : `${name}-${index + 1}`;\n };\n\n const displaySeconds = (time: number) => {\n return `${time} second${time === 1 ? \"\" : \"s\"}`;\n };\n\n const getCTALabelProps = (): Partial<\n React.HTMLAttributes<HTMLButtonElement>\n > => {\n return otherCtaProps.children\n ? { children: otherCtaProps.children }\n : {\n children:\n countDown > 0\n ? `Resend OTP in ${displaySeconds(countDown)}`\n : \"Resend OTP\",\n // use a fixed label to avoid repeated screen reader updates when the button is focused\n \"aria-label\":\n countDown > 0\n ? `Resend OTP in ${displaySeconds(cooldownDuration)}`\n : \"Resend OTP\",\n // use a secondary element to reflect the latest countdown\n \"aria-describedby\": timerId,\n };\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n return (\n <div\n id={id}\n data-testid={dataTestId}\n className={clsx(styles.wrapper, className)}\n >\n <div\n className={styles.inputContainer}\n role=\"group\"\n aria-label={`${numOfInput}-digit OTP input field`}\n >\n {prefix && (\n <Typography.BodyBL\n as=\"span\"\n className={styles.prefix}\n data-testid=\"otp-prefix\"\n weight=\"semibold\"\n >\n <VisuallyHidden>O T P prefix</VisuallyHidden>\n {`${prefix.value} ${prefix.separator}`}\n </Typography.BodyBL>\n )}\n {otpValues.map((data, index) => {\n return (\n <Input\n className={styles.inputField}\n id={generateId(index, \"otp-input\", id)}\n data-testid={generateId(\n index,\n \"otp-input\",\n dataTestId\n )}\n aria-label={`${StringHelper.formatOrdinal(\n index + 1\n )} digit`}\n aria-invalid={hasError}\n aria-describedby={hasError ? errorId : undefined}\n key={index}\n ref={(el) => (inputRefs.current[index] = el)}\n type=\"text\"\n inputMode=\"numeric\"\n value={data}\n error={hasError}\n onChange={handleChange(index)}\n onKeyDown={handleKeyDown(index)}\n autoComplete=\"off\"\n {...otherProps}\n />\n );\n })}\n </div>\n {errorMessage && (\n <FormErrorMessage id={errorId} data-testid=\"otp-error-message\">\n {errorMessage}\n </FormErrorMessage>\n )}\n {/* visually hidden elements need to be rendered before the button so that Voiceover/Chrome doesn't skip the button */}\n <VisuallyHidden role=\"timer\" id={timerId}>\n {displaySeconds(countDown)} remaining\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"polite\">\n {countDown > 0 ? \"\" : \"Ready to resend OTP\"}\n </VisuallyHidden>\n {!otpOnly && (\n <Button\n className={styles.ctaButton}\n styleType={styleType}\n type=\"button\"\n sizeType=\"small\"\n {...otherCtaProps}\n onClick={handleClick}\n disabled={disabled || isWithinCooldown()}\n {...getCTALabelProps()}\n />\n )}\n </div>\n );\n};\n\nexport const OtpInput = forwardRef(Component);\n"],"names":["OtpInput","forwardRef","_a","ref","id","value","dataTestId","className","cooldownDuration","actionButtonProps","errorMessage","numOfInput","prefix","onChange","onCooldownStart","onCooldownEnd","otpOnly","onCountdownChange","otherProps","__rest","_b","disabled","onClick","styleType","otherCtaProps","inputRefs","useRef","onChangeRef","otpValues","setOtpValues","useState","Array","fill","countDown","setCountDown","lastCtaTimestamp","setLastCtaTimestamp","Date","internalId","useId","hasError","errorId","timerId","useEffect","current","focus","document","addEventListener","handlePaste","removeEventListener","cleanup","beginCountdown","useImperativeHandle","startCooldown","length","handleInputFullValue","incomingValue","validateUserInput","incomingValueArr","split","handleChange","index","event","eventValue","target","fieldIsEmpty","every","num","autofillOtp","stripOtpFromAutofill","replace","newOtpValues","substring","handleKeyDown","key","code","_c","clipboardData","pastedValue","getData","preventDefault","isWithinCooldown","currentTime","now","coolDownInMilliseconds","valueOf","interval","setInterval","timer","Math","ceil","clearInterval","generateId","name","displaySeconds","time","_jsxs","clsx","styles.wrapper","children","styles.inputContainer","role","Typography","BodyBL","as","styles.prefix","weight","_jsx","VisuallyHidden","separator","map","data","Input","Object","assign","styles.inputField","StringHelper","formatOrdinal","undefined","el","type","inputMode","error","onKeyDown","autoComplete","FormErrorMessage","Button","styles.ctaButton","sizeType"],"mappings":"o3BAoBA,MAwUaA,EAAWC,GAxUN,CACdC,EAiBAC,KAjBA,IAAAC,GACIA,EAAEC,MACFA,EAAQ,GACR,cAAeC,EAAUC,UACzBA,EAASC,iBACTA,EAAgBC,kBAChBA,EAAiBC,aACjBA,EAAYC,WACZA,EAAUC,OACVA,EAAMC,SACNA,EAAQC,gBACRA,EAAeC,cACfA,EAAaC,QACbA,EAAOC,kBACPA,GAAiBf,EACdgB,EAAUC,EAAAjB,EAfjB,iMAsBA,MAAMkB,EAKFX,QAAAA,EAAqB,CAAA,GALnBY,SACFA,EAAQC,QACRA,EAAOC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Y,EAAI,GAAK,yBAExBjB,GACE2F,EAACmB,EAAMb,OAAAC,OAAA,CACH3G,UAAWwH,EACXxG,UAAWA,EACXiG,KAAK,SACLQ,SAAS,SACLxG,GACJF,QAzJKwC,IACjBjC,EAAa,IAAIE,MAAMpB,GAAYqB,KAAK,KAEnCiD,OACD7C,EAAoB,IAAIC,MACxBH,EAAa1B,IAGbc,GACAA,EAAQwC,EACZ,EAgJYzC,SAAUA,GAAY4D,MA3F3BzD,EAAc2E,SACf,CAAEA,SAAU3E,EAAc2E,UAC1B,CACIA,SACIlE,EAAY,EACN,iBAAiB6D,GAAe7D,KAChC,aAEV,aACIA,EAAY,EACN,iBAAiB6D,GAAetF,KAChC,aAEV,mBAAoBkC,QAkFxB"}
1
+ {"version":3,"file":"otp-input.js","sources":["../../src/otp-input/otp-input.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport type React from \"react\";\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\n\nimport { Button } from \"../button\";\nimport { FormErrorMessage } from \"../form/form-label\";\nimport { Input } from \"../input\";\nimport { VisuallyHidden } from \"../shared/accessibility\";\nimport { Typography } from \"../typography\";\nimport { StringHelper, useId } from \"../util\";\nimport * as styles from \"./otp-input.styles\";\nimport type { OtpInputProps, OtpInputRef } from \"./types\";\nimport { stripOtpFromAutofill, validateUserInput } from \"./utils\";\n\nconst Component = (\n {\n id,\n value = [],\n \"data-testid\": dataTestId,\n className,\n cooldownDuration,\n actionButtonProps,\n errorMessage,\n numOfInput,\n prefix,\n onChange,\n onCooldownStart,\n onCooldownEnd,\n otpOnly,\n onCountdownChange,\n ...otherProps\n }: OtpInputProps,\n ref: React.Ref<OtpInputRef>\n) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const {\n disabled,\n onClick,\n styleType = \"secondary\",\n ...otherCtaProps\n } = actionButtonProps ?? {};\n\n const inputRefs = useRef<(HTMLInputElement | null)[]>([]);\n const onChangeRef = useRef(onChange);\n\n const [otpValues, setOtpValues] = useState<string[]>(\n new Array(numOfInput).fill(\"\")\n );\n const [countDown, setCountDown] = useState<number>(cooldownDuration);\n const [lastCtaTimestamp, setLastCtaTimestamp] = useState<Date>(new Date());\n const internalId = useId();\n\n const hasError = !!errorMessage;\n const errorId = `${internalId}-error`;\n const timerId = `${internalId}-timer`;\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n inputRefs?.current[0]?.focus();\n document.addEventListener(\"paste\", handlePaste);\n return () => document.removeEventListener(\"paste\", handlePaste);\n }, []);\n\n useEffect(() => {\n if (cooldownDuration !== 0) {\n if (onCooldownStart) onCooldownStart();\n const cleanup = beginCountdown();\n\n return () => cleanup();\n }\n }, [lastCtaTimestamp]);\n\n useImperativeHandle(ref, () => ({\n startCooldown: () => {\n setLastCtaTimestamp(new Date());\n setCountDown(cooldownDuration);\n },\n }));\n\n useEffect(() => {\n onChangeRef.current = onChange;\n }, [onChange]);\n\n useEffect(() => {\n if (value.length === numOfInput) {\n setOtpValues(value);\n }\n }, [value]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleInputFullValue = (incomingValue: string) => {\n if (incomingValue && validateUserInput(incomingValue, numOfInput)) {\n const incomingValueArr = incomingValue.split(\"\");\n setOtpValues(incomingValueArr);\n if (onChangeRef.current) {\n onChangeRef.current(incomingValueArr);\n }\n\n return true;\n }\n\n return false;\n };\n\n const handleChange =\n (index: number) => (event: React.ChangeEvent<HTMLInputElement>) => {\n const eventValue = event.target.value;\n\n /* handle autofill */\n const fieldIsEmpty = otpValues.every((num) => num === \"\");\n const autofillOtp = stripOtpFromAutofill(\n eventValue,\n numOfInput,\n prefix\n );\n if (fieldIsEmpty && handleInputFullValue(autofillOtp)) {\n return;\n }\n\n /* handle normal input */\n const value = eventValue.replace(/[^0-9]/g, \"\");\n if (validateUserInput(value)) {\n const newOtpValues = [...otpValues];\n\n newOtpValues[index] = value.substring(value.length - 1);\n inputRefs.current[index + 1]?.focus();\n\n setOtpValues(newOtpValues);\n\n if (onChange) {\n onChange(newOtpValues);\n }\n }\n };\n\n const handleKeyDown =\n (index: number) => (event: React.KeyboardEvent<HTMLInputElement>) => {\n const { key, code } = event;\n\n if (key === \"Backspace\" || code === \"Backspace\") {\n const newOtpValues = [...otpValues];\n if (newOtpValues[index] !== \"\") {\n newOtpValues[index] = \"\";\n } else if (index !== 0) {\n newOtpValues[index - 1] = \"\";\n inputRefs.current[index - 1]?.focus();\n }\n\n setOtpValues(newOtpValues);\n\n if (onChange) {\n onChange(newOtpValues);\n }\n } else if (event.code === \"ArrowRight\") {\n inputRefs.current[index + 1]?.focus();\n } else if (event.code === \"ArrowLeft\") {\n inputRefs.current[index - 1]?.focus();\n }\n };\n\n const handlePaste = (event: ClipboardEvent): void => {\n if (!event.clipboardData) return;\n\n const pastedValue = event.clipboardData.getData(\"text\");\n const autofillOtp = stripOtpFromAutofill(\n pastedValue,\n numOfInput,\n prefix\n );\n if (!handleInputFullValue(autofillOtp)) {\n event.preventDefault();\n }\n };\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n setOtpValues(new Array(numOfInput).fill(\"\"));\n\n if (!isWithinCooldown()) {\n setLastCtaTimestamp(new Date());\n setCountDown(cooldownDuration);\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n // =========================================================================\n // HELPER FUNCTIONS\n // =========================================================================\n const isWithinCooldown = (): boolean => {\n const currentTime = Date.now();\n const coolDownInMilliseconds = cooldownDuration * 1000;\n\n return (\n currentTime < lastCtaTimestamp.valueOf() + coolDownInMilliseconds\n );\n };\n\n const beginCountdown = () => {\n const interval = setInterval(() => {\n const currentTime = Date.now();\n const coolDownInMilliseconds = cooldownDuration * 1000;\n\n const timer = Math.ceil(\n (lastCtaTimestamp.valueOf() +\n coolDownInMilliseconds -\n currentTime) /\n 1000\n );\n setCountDown(timer);\n if (timer <= 0) {\n if (onCooldownEnd) onCooldownEnd();\n clearInterval(interval);\n } else if (onCountdownChange) {\n onCountdownChange(timer);\n }\n }, 1000);\n\n return () => {\n clearInterval(interval);\n };\n };\n\n const generateId = (index: number, name: string, prefix?: string) => {\n return prefix\n ? `${prefix}-${name}-${index + 1}`\n : `${name}-${index + 1}`;\n };\n\n const displaySeconds = (time: number) => {\n return `${time} second${time === 1 ? \"\" : \"s\"}`;\n };\n\n const getCTALabelProps = (): Partial<\n React.HTMLAttributes<HTMLButtonElement>\n > => {\n return otherCtaProps.children\n ? { children: otherCtaProps.children }\n : {\n children:\n countDown > 0\n ? `Resend OTP in ${displaySeconds(countDown)}`\n : \"Resend OTP\",\n // use a fixed label to avoid repeated screen reader updates when the button is focused\n \"aria-label\":\n countDown > 0\n ? `Resend OTP in ${displaySeconds(cooldownDuration)}`\n : \"Resend OTP\",\n // use a secondary element to reflect the latest countdown\n \"aria-describedby\": timerId,\n };\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n return (\n <div\n id={id}\n data-testid={dataTestId}\n className={clsx(styles.wrapper, className)}\n >\n <div\n className={styles.inputContainer}\n role=\"group\"\n aria-label={`${numOfInput}-digit OTP input field`}\n >\n {prefix && (\n <Typography.BodyBL\n as=\"span\"\n className={styles.prefix}\n data-testid=\"otp-prefix\"\n weight=\"semibold\"\n >\n <VisuallyHidden>O T P prefix</VisuallyHidden>\n {`${prefix.value} ${prefix.separator}`}\n </Typography.BodyBL>\n )}\n {otpValues.map((data, index) => {\n return (\n <Input\n className={styles.inputField}\n id={generateId(index, \"otp-input\", id)}\n data-testid={generateId(\n index,\n \"otp-input\",\n dataTestId\n )}\n aria-label={`${StringHelper.formatOrdinal(\n index + 1\n )} digit`}\n aria-invalid={hasError}\n aria-describedby={hasError ? errorId : undefined}\n key={index}\n ref={(el) => (inputRefs.current[index] = el)}\n type=\"text\"\n inputMode=\"numeric\"\n value={data}\n error={hasError}\n onChange={handleChange(index)}\n onKeyDown={handleKeyDown(index)}\n autoComplete=\"off\"\n {...otherProps}\n />\n );\n })}\n </div>\n {errorMessage && (\n <FormErrorMessage id={errorId} data-testid=\"otp-error-message\">\n {errorMessage}\n </FormErrorMessage>\n )}\n {/* visually hidden elements need to be rendered before the button so that Voiceover/Chrome doesn't skip the button */}\n <VisuallyHidden role=\"timer\" id={timerId}>\n {displaySeconds(countDown)} remaining\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"polite\">\n {countDown > 0 ? \"\" : \"Ready to resend OTP\"}\n </VisuallyHidden>\n {!otpOnly && (\n <Button\n className={styles.ctaButton}\n styleType={styleType}\n type=\"button\"\n sizeType=\"small\"\n {...otherCtaProps}\n onClick={handleClick}\n disabled={disabled || isWithinCooldown()}\n {...getCTALabelProps()}\n />\n )}\n </div>\n );\n};\n\n/**\n * A field composed of individual inputs for a numeric one-time password\n * with an in-built countdown mechanism.\n *\n * Use `OtpInput` when users must enter the one-time password (OTP)\n * for multi-factored authentication methods.\n */\nexport const OtpInput = forwardRef(Component);\n"],"names":["OtpInput","forwardRef","_a","ref","id","value","dataTestId","className","cooldownDuration","actionButtonProps","errorMessage","numOfInput","prefix","onChange","onCooldownStart","onCooldownEnd","otpOnly","onCountdownChange","otherProps","__rest","_b","disabled","onClick","styleType","otherCtaProps","inputRefs","useRef","onChangeRef","otpValues","setOtpValues","useState","Array","fill","countDown","setCountDown","lastCtaTimestamp","setLastCtaTimestamp","Date","internalId","useId","hasError","errorId","timerId","useEffect","current","focus","document","addEventListener","handlePaste","removeEventListener","cleanup","beginCountdown","useImperativeHandle","startCooldown","length","handleInputFullValue","incomingValue","validateUserInput","incomingValueArr","split","handleChange","index","event","eventValue","target","fieldIsEmpty","every","num","autofillOtp","stripOtpFromAutofill","replace","newOtpValues","substring","handleKeyDown","key","code","_c","clipboardData","pastedValue","getData","preventDefault","isWithinCooldown","currentTime","now","coolDownInMilliseconds","valueOf","interval","setInterval","timer","Math","ceil","clearInterval","generateId","name","displaySeconds","time","_jsxs","clsx","styles.wrapper","children","styles.inputContainer","role","Typography","BodyBL","as","styles.prefix","weight","_jsx","VisuallyHidden","separator","map","data","Input","Object","assign","styles.inputField","StringHelper","formatOrdinal","undefined","el","type","inputMode","error","onKeyDown","autoComplete","FormErrorMessage","Button","styles.ctaButton","sizeType"],"mappings":"o3BAoBA,MA+UaA,EAAWC,GA/UN,CACdC,EAiBAC,KAjBA,IAAAC,GACIA,EAAEC,MACFA,EAAQ,GACR,cAAeC,EAAUC,UACzBA,EAASC,iBACTA,EAAgBC,kBAChBA,EAAiBC,aACjBA,EAAYC,WACZA,EAAUC,OACVA,EAAMC,SACNA,EAAQC,gBACRA,EAAeC,cACfA,EAAaC,QACbA,EAAOC,kBACPA,GAAiBf,EACdgB,EAAUC,EAAAjB,EAfjB,iMAsBA,MAAMkB,EAKFX,QAAAA,EAAqB,CAAA,GALnBY,SACFA,EAAQC,QACRA,EAAOC,UACPA,EAAY,aAAWH,EACpBI,EAAaL,EAAAC,EAJd,CAAA,WAAA,UAAA,cAOAK,EAAYC,EAAoC,IAChDC,EAAcD,EAAOb,IAEpBe,EAAWC,GAAgBC,EAC9B,IAAIC,MAAMpB,GAAYqB,KAAK,MAExBC,EAAWC,GAAgBJ,EAAiBtB,IAC5C2B,EAAkBC,GAAuBN,EAAe,IAAIO,MAC7DC,EAAaC,IAEbC,IAAa9B,EACb+B,GAAU,GAAGH,UACbI,GAAU,GAAGJ,UAKnBK,GAAU,WAGN,OAFqB,QAArBzC,EAAAuB,aAAS,EAATA,EAAWmB,QAAQ,UAAE,IAAA1C,GAAAA,EAAE2C,QACvBC,SAASC,iBAAiB,QAASC,IAC5B,IAAMF,SAASG,oBAAoB,QAASD,GAAY,GAChE,IAEHL,GAAU,KACN,GAAyB,IAArBnC,EAAwB,CACpBM,GAAiBA,IACrB,MAAMoC,EAAUC,KAEhB,MAAO,IAAMD,GACjB,IACD,CAACf,IAEJiB,EAAoBjD,GAAK,KAAA,CACrBkD,cAAe,KACXjB,EAAoB,IAAIC,MACxBH,EAAa1B,EAAiB,MAItCmC,GAAU,KACNhB,EAAYiB,QAAU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,cACzBwF,GACT/B,EACA,YACAvD,GACH,aACW,GAAG8G,EAAaC,cACxBxD,EAAQ,0BAEErB,EAAQ,mBACJA,EAAWC,QAAU6E,EAEvCnH,IAAMoH,GAAQ9F,EAAUmB,QAAQiB,GAAS0D,EACzCC,KAAK,OACLC,UAAU,UACVpH,MAAO0G,EACPW,MAAOlF,EACP3B,SAAU+C,GAAaC,GACvB8D,UAAWlD,GAAcZ,GACzB+D,aAAa,OACT1G,GATC2C,QAcpBnD,GACGiG,EAACkB,EAAgB,CAACzH,GAAIqC,GAAO,cAAc,oBAAmB0D,SACzDzF,IAITsF,EAACY,EAAc,CAACP,KAAK,QAAQjG,GAAIsC,aAC5BoD,GAAe7D,GAAU,gBAE9B0E,EAACC,EAAc,CAAA,YAAW,SAAQT,SAC7BlE,EAAY,EAAI,GAAK,yBAExBjB,GACE2F,EAACmB,EAAMb,OAAAC,OAAA,CACH3G,UAAWwH,EACXxG,UAAWA,EACXiG,KAAK,SACLQ,SAAS,SACLxG,GACJF,QAzJKwC,IACjBjC,EAAa,IAAIE,MAAMpB,GAAYqB,KAAK,KAEnCiD,OACD7C,EAAoB,IAAIC,MACxBH,EAAa1B,IAGbc,GACAA,EAAQwC,EACZ,EAgJYzC,SAAUA,GAAY4D,MA3F3BzD,EAAc2E,SACf,CAAEA,SAAU3E,EAAc2E,UAC1B,CACIA,SACIlE,EAAY,EACN,iBAAiB6D,GAAe7D,KAChC,aAEV,aACIA,EAAY,EACN,iBAAiB6D,GAAetF,KAChC,aAEV,mBAAoBkC,QAkFxB"}
@@ -1,34 +1,77 @@
1
1
  import type { ButtonProps } from "../button";
2
+ /**
3
+ * Props for the `OtpInput` component.
4
+ */
2
5
  export interface OtpInputProps extends React.AriaAttributes {
3
6
  id?: string | undefined;
4
7
  "data-testid"?: string | undefined;
5
8
  className?: string | undefined;
6
- /** The array of input values */
9
+ /**
10
+ * Controlled array of digit strings, one entry per input cell.
11
+ * Only applied when the array length equals `numOfInput`.
12
+ */
7
13
  value?: string[] | undefined;
14
+ /**
15
+ * Error text displayed below the input cells.
16
+ */
8
17
  errorMessage?: string | React.ReactNode | undefined;
9
- /** The duration (in seconds) to disable the submit button after a click is made */
18
+ /**
19
+ * Duration in seconds to disable the action button after it is clicked.
20
+ * Pass `0` to skip the cooldown entirely.
21
+ */
10
22
  cooldownDuration: number;
11
- /** The props for the submit button */
23
+ /**
24
+ * Props forwarded to the action button. When `children` is not provided,
25
+ * the button label defaults to `"Resend OTP"`, or `"Resend OTP in X seconds"`
26
+ * while a cooldown is active.
27
+ *
28
+ * @default styleType: "secondary"
29
+ */
12
30
  actionButtonProps?: ButtonProps | undefined;
13
- /** Flag to indicate if only OTP inputs should be rendered without the action button */
31
+ /**
32
+ * When `true`, renders only the OTP input cells without the action button.
33
+ */
14
34
  otpOnly?: boolean | undefined;
15
- /** The number of characters for the Otp */
35
+ /**
36
+ * Number of single-digit input cells to render.
37
+ */
16
38
  numOfInput: number;
39
+ /**
40
+ * Optional prefix label rendered before the input cells.
41
+ */
17
42
  prefix?: {
18
- /** Optional OTP prefix, usually consisting of a few alphabetic characters */
43
+ /** Prefix text, usually a few alphabetic characters. */
19
44
  value: string;
20
- /** separator between prefix and otp digits. Only "-" supported for now */
45
+ /**
46
+ * Separator between the prefix and the OTP input.
47
+ * Only `"-"` is supported.
48
+ */
21
49
  separator: "-";
22
50
  } | undefined;
23
- /** Called when one of the input is changed. Returns an array of all the input values */
51
+ /**
52
+ * Called when any input cell changes.
53
+ *
54
+ * @param value Array of all input cell values, one string per cell.
55
+ */
24
56
  onChange?: ((value: string[]) => void) | undefined;
25
- /** Called when the countdown changes. Returns the remaining time in seconds */
57
+ /**
58
+ * Called each second while a cooldown countdown is active.
59
+ *
60
+ * @param remaining Seconds remaining in the current cooldown.
61
+ */
26
62
  onCountdownChange?: ((remaining: number) => void) | undefined;
27
- /** Called when the cooldown begins */
63
+ /** Called when a cooldown period begins. */
28
64
  onCooldownStart?: (() => void) | undefined;
29
- /** Called when the cooldown ends */
65
+ /** Called when a cooldown period ends. */
30
66
  onCooldownEnd?: (() => void) | undefined;
31
67
  }
68
+ /**
69
+ * Imperative handle returned by `OtpInput` via `ref`.
70
+ */
32
71
  export type OtpInputRef = {
72
+ /**
73
+ * Starts a new cooldown countdown without clearing the input cells.
74
+ * Fires `onCooldownStart` and begins the countdown timer.
75
+ */
33
76
  startCooldown: () => void;
34
77
  };
@@ -25,16 +25,33 @@ export interface ContactInputSectionProps {
25
25
  export interface VerificationSectionProps {
26
26
  id?: string | undefined;
27
27
  "data-testid"?: string | undefined;
28
+ countdown: ReturnType<typeof useCountdown>;
29
+ isVerifyLoading: boolean;
30
+ otpCode?: string | undefined;
31
+ otpPrefix?: string | undefined;
32
+ otpSeparator?: string | undefined;
28
33
  type: "email" | "phone-number";
34
+ /**
35
+ * Whether to display the thumbnail image in the OTP verification section,
36
+ * visible in the `"sent"` state.
37
+ */
29
38
  showVerifyOtpThumbnail?: boolean | undefined;
39
+ /**
40
+ * Custom icon in the OTP verification section, visible in the `"sent"` state.
41
+ */
42
+ verifyOtpIcon?: React.ReactNode | undefined;
43
+ /**
44
+ * Custom heading in the OTP verification section, visible in the `"sent"` state.
45
+ */
30
46
  verifyOtpTitle?: string | undefined;
47
+ /**
48
+ * Custom body text in the OTP verification section, visible in the `"sent"` state.
49
+ */
31
50
  verifyOtpMessage?: string | undefined;
51
+ /**
52
+ * Error message displayed below the OTP input after a failed verification attempt.
53
+ */
32
54
  verifyOtpError?: string | undefined;
33
- otpCode?: string | undefined;
34
55
  setOtpCode?: (value: string) => void;
35
- isVerifyLoading: boolean;
36
- countdown: ReturnType<typeof useCountdown>;
37
56
  onVerifyOtp: () => void;
38
- otpPrefix?: string | undefined;
39
- otpSeparator?: string | undefined;
40
57
  }
@@ -1,2 +1,8 @@
1
1
  import type { OtpVerificationProps } from "./types";
2
+ /**
3
+ * A multi-step form component that guides users through OTP-based verification.
4
+ *
5
+ * Use `OtpVerification` when you need to verify a user's identity through
6
+ * email address or phone number.
7
+ */
2
8
  export declare const OtpVerification: (props: OtpVerificationProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"otp-verification.js","sources":["../../src/otp-verification/otp-verification.tsx"],"sourcesContent":["import { announce, clearAnnouncer } from \"@react-aria/live-announcer\";\nimport clsx from \"clsx\";\nimport { useState } from \"react\";\n\nimport { useCountdown } from \"../util\";\nimport { ContactInputSection } from \"./contact-input-section\";\nimport * as styles from \"./otp-verification.styles\";\nimport type { OtpVerificationProps } from \"./types\";\nimport { VerificationSection } from \"./verification-section\";\n\nexport const OtpVerification = (props: OtpVerificationProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const {\n id,\n \"data-testid\": dataTestId,\n className,\n inputId,\n onSendOtp,\n onVerifyOtp,\n verifyOtpCountdownTimer = 60,\n sendOtpError,\n verifyOtpError,\n otpValue,\n onOtpChange,\n otpState,\n onOtpStateChange,\n otpReminderInterval = 120,\n } = props;\n\n const [isLoading, setIsLoading] = useState(false);\n const [isVerifyLoading, setIsVerifyLoading] = useState(false);\n\n const countdown = useCountdown({\n duration: verifyOtpCountdownTimer,\n reminderInterval: otpReminderInterval,\n getStartMessage: (duration) =>\n `You can resend the OTP in ${duration} seconds`,\n getIntervalMessage: (remaining) => `${remaining} seconds remaining`,\n getCompletionMessage: () => \"You can now resend the OTP\",\n });\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n // Send OTP\n const handleSendOtp = async () => {\n if (!onSendOtp || isLoading) return;\n\n try {\n setIsLoading(true);\n await onSendOtp();\n onOtpStateChange(\"sent\");\n countdown.reset();\n countdown.start();\n } catch {\n // do nothing\n } finally {\n setIsLoading(false);\n }\n };\n\n // Verify OTP\n const handleVerifyOtp = async () => {\n if (!onVerifyOtp || isVerifyLoading || !otpValue?.value) return;\n\n try {\n setIsVerifyLoading(true);\n await onVerifyOtp(otpValue.value);\n\n onOtpStateChange(\"verified\");\n\n clearAnnouncer(\"polite\");\n announce(\n \"Success. Your email or mobile number has been verified.\",\n \"polite\"\n );\n\n // Reset the countdown and clear the OTP code in case user enter new OTP later\n countdown.reset();\n onOtpChange?.(\"\");\n } catch {\n // do nothing\n } finally {\n setIsVerifyLoading(false);\n }\n };\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n const resetToDefault = () => {\n if (otpState === \"verified\") {\n onOtpStateChange(\"default\");\n }\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n return (\n <div\n id={id}\n data-testid={dataTestId}\n className={clsx(styles.otpInputWrapper, className)}\n >\n <ContactInputSection\n {...props}\n inputId={inputId}\n data-testid={dataTestId ? `${dataTestId}-contact` : undefined}\n isLoading={isLoading}\n isVerified={otpState === \"verified\"}\n countdown={countdown}\n onSendOtp={handleSendOtp}\n onStateReset={resetToDefault}\n sendOtpError={sendOtpError}\n fixedCountry={\n props.type === \"phone-number\" ? props.fixedCountry : true\n }\n />\n\n {otpState === \"sent\" && (\n <VerificationSection\n {...props}\n data-testid={\n dataTestId ? `${dataTestId}-verification` : undefined\n }\n otpCode={otpValue?.value}\n otpPrefix={otpValue?.prefix}\n otpSeparator={otpValue?.separator}\n setOtpCode={onOtpChange}\n isVerifyLoading={isVerifyLoading}\n countdown={countdown}\n onVerifyOtp={handleVerifyOtp}\n verifyOtpError={verifyOtpError}\n />\n )}\n </div>\n );\n};\n"],"names":["OtpVerification","props","id","dataTestId","className","inputId","onSendOtp","onVerifyOtp","verifyOtpCountdownTimer","sendOtpError","verifyOtpError","otpValue","onOtpChange","otpState","onOtpStateChange","otpReminderInterval","isLoading","setIsLoading","useState","isVerifyLoading","setIsVerifyLoading","countdown","useCountdown","duration","reminderInterval","getStartMessage","getIntervalMessage","remaining","getCompletionMessage","_jsxs","clsx","styles.otpInputWrapper","children","_jsx","ContactInputSection","Object","assign","undefined","isVerified","__awaiter","reset","start","_a","onStateReset","fixedCountry","type","VerificationSection","otpCode","value","otpPrefix","prefix","otpSeparator","separator","setOtpCode","clearA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ACjBE,UAAWA,EACXd,YAtEQ,IAAWgC,OAAA,OAAA,OAAA,GAAA,YAC/B,GAAKhC,IAAeY,IAAoBR,aAAQ,EAARA,EAAUqC,OAElD,IACI5B,GAAmB,SACbb,EAAYI,EAASqC,OAE3BlC,EAAiB,YAEjBwC,EAAe,UACfC,EACI,0DACA,UAIJlC,EAAUmB,QACV5B,SAAAA,EAAc,GAClB,CAAE,MAAA8B,GAEF,SACItB,GAAmB,EACvB,CACJ,IAgDgBV,eAAgBA,OAGtB"}
1
+ {"version":3,"file":"otp-verification.js","sources":["../../src/otp-verification/otp-verification.tsx"],"sourcesContent":["import { announce, clearAnnouncer } from \"@react-aria/live-announcer\";\nimport clsx from \"clsx\";\nimport { useState } from \"react\";\n\nimport { useCountdown } from \"../util\";\nimport { ContactInputSection } from \"./contact-input-section\";\nimport * as styles from \"./otp-verification.styles\";\nimport type { OtpVerificationProps } from \"./types\";\nimport { VerificationSection } from \"./verification-section\";\n\n/**\n * A multi-step form component that guides users through OTP-based verification.\n *\n * Use `OtpVerification` when you need to verify a user's identity through\n * email address or phone number.\n */\nexport const OtpVerification = (props: OtpVerificationProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const {\n id,\n \"data-testid\": dataTestId,\n className,\n inputId,\n onSendOtp,\n onVerifyOtp,\n verifyOtpCountdownTimer = 60,\n sendOtpError,\n verifyOtpError,\n otpValue,\n onOtpChange,\n otpState,\n onOtpStateChange,\n otpReminderInterval = 120,\n } = props;\n\n const [isLoading, setIsLoading] = useState(false);\n const [isVerifyLoading, setIsVerifyLoading] = useState(false);\n\n const countdown = useCountdown({\n duration: verifyOtpCountdownTimer,\n reminderInterval: otpReminderInterval,\n getStartMessage: (duration) =>\n `You can resend the OTP in ${duration} seconds`,\n getIntervalMessage: (remaining) => `${remaining} seconds remaining`,\n getCompletionMessage: () => \"You can now resend the OTP\",\n });\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n // Send OTP\n const handleSendOtp = async () => {\n if (!onSendOtp || isLoading) return;\n\n try {\n setIsLoading(true);\n await onSendOtp();\n onOtpStateChange(\"sent\");\n countdown.reset();\n countdown.start();\n } catch {\n // do nothing\n } finally {\n setIsLoading(false);\n }\n };\n\n // Verify OTP\n const handleVerifyOtp = async () => {\n if (!onVerifyOtp || isVerifyLoading || !otpValue?.value) return;\n\n try {\n setIsVerifyLoading(true);\n await onVerifyOtp(otpValue.value);\n\n onOtpStateChange(\"verified\");\n\n clearAnnouncer(\"polite\");\n announce(\n \"Success. Your email or mobile number has been verified.\",\n \"polite\"\n );\n\n // Reset the countdown and clear the OTP code in case user enter new OTP later\n countdown.reset();\n onOtpChange?.(\"\");\n } catch {\n // do nothing\n } finally {\n setIsVerifyLoading(false);\n }\n };\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n const resetToDefault = () => {\n if (otpState === \"verified\") {\n onOtpStateChange(\"default\");\n }\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n return (\n <div\n id={id}\n data-testid={dataTestId}\n className={clsx(styles.otpInputWrapper, className)}\n >\n <ContactInputSection\n {...props}\n inputId={inputId}\n data-testid={dataTestId ? `${dataTestId}-contact` : undefined}\n isLoading={isLoading}\n isVerified={otpState === \"verified\"}\n countdown={countdown}\n onSendOtp={handleSendOtp}\n onStateReset={resetToDefault}\n sendOtpError={sendOtpError}\n fixedCountry={\n props.type === \"phone-number\" ? props.fixedCountry : true\n }\n />\n\n {otpState === \"sent\" && (\n <VerificationSection\n {...props}\n data-testid={\n dataTestId ? `${dataTestId}-verification` : undefined\n }\n otpCode={otpValue?.value}\n otpPrefix={otpValue?.prefix}\n otpSeparator={otpValue?.separator}\n setOtpCode={onOtpChange}\n isVerifyLoading={isVerifyLoading}\n countdown={countdown}\n onVerifyOtp={handleVerifyOtp}\n verifyOtpError={verifyOtpError}\n />\n )}\n </div>\n );\n};\n"],"names":["OtpVerification","props","id","dataTestId","className","inputId","onSendOtp","onVerifyOtp","verifyOtpCountdownTimer","sendOtpError","verifyOtpError","otpValue","onOtpChange","otpState","onOtpStateChange","otpReminderInterval","isLoading","setIsLoading","useState","isVerifyLoading","setIsVerifyLoading","countdown","useCountdown","duration","reminderInterval","getStartMessage","getIntervalMessage","remaining","getCompletionMessage","_jsxs","clsx","styles.otpInputWrapper","children","_jsx","ContactInputSection","Object","assign","undefined","isVerified","__awaiter","reset","start","_a","onStateReset","fixedCountry","type","VerificationSection","otpCode","value","otpPrefix","prefix","otpSeparator","separator","setOtpCode","clearAnnouncer","announce"],"mappings":"6mBAgBO,MAAMA,EAAmBC,IAI5B,MAAMC,GACFA,EACA,cAAeC,EAAUC,UACzBA,EAASC,QACTA,EAAOC,UACPA,EAASC,YACTA,EAAWC,wBACXA,EAA0B,GAAEC,aAC5BA,EAAYC,eACZA,EAAcC,SACdA,EAAQC,YACRA,EAAWC,SACXA,EAAQC,iBACRA,EAAgBC,oBAChBA,EAAsB,KACtBd,GAEGe,EAAWC,GAAgBC,GAAS,IACpCC,EAAiBC,GAAsBF,GAAS,GAEjDG,EAAYC,EAAa,CAC3BC,SAAUf,EACVgB,iBAAkBT,EAClBU,gBAAkBF,GACd,6BAA6BA,YACjCG,mBAAqBC,GAAc,GAAGA,sBACtCC,qBAAsB,IAAM,+BA6DhC,OACIC,EAAA,MAAA,CACI3B,GAAIA,gBACSC,EACbC,UAAW0B,EAAKC,EAAwB3B,GAAU4B,SAAA,CAElDC,EAACC,EAAmBC,OAAAC,OAAA,CAAA,EACZnC,EAAK,CACTI,QAASA,EAAO,cACHF,EAAa,GAAGA,iBAAuBkC,EACpDrB,UAAWA,EACXsB,WAAyB,aAAbzB,EACZQ,UAAWA,EACXf,UAnEU,IAAWiC,OAAA,OAAA,OAAA,GAAA,YAC7B,GAAKjC,IAAaU,EAElB,IACIC,GAAa,SACPX,IACNQ,EAAiB,QACjBO,EAAUmB,QACVnB,EAAUoB,OACd,CAAE,MAAAC,GAEF,SACIzB,GAAa,EACjB,CACJ,IAsDY0B,aAvBW,KACF,aAAb9B,GACAC,EAAiB,UACrB,EAqBQL,aAAcA,EACdmC,aACmB,iBAAf3C,EAAM4C,MAA0B5C,EAAM2C,gBAIhC,SAAb/B,GACGoB,EAACa,mBACO7C,EAAK,CAAA,cAELE,EAAa,GAAGA,sBAA4BkC,EAEhDU,QAASpC,eAAAA,EAAUqC,MACnBC,UAAWtC,aAAQ,EAARA,EAAUuC,OACrBC,aAAcxC,aAAQ,EAARA,EAAUyC,UACxBC,WAAYzC,EACZO,gBAAiBA,EACjBE,UAAWA,EACXd,YAtEQ,IAAWgC,OAAA,OAAA,OAAA,GAAA,YAC/B,GAAKhC,IAAeY,IAAoBR,aAAQ,EAARA,EAAUqC,OAElD,IACI5B,GAAmB,SACbb,EAAYI,EAASqC,OAE3BlC,EAAiB,YAEjBwC,EAAe,UACfC,EACI,0DACA,UAIJlC,EAAUmB,QACV5B,SAAAA,EAAc,GAClB,CAAE,MAAA8B,GAEF,SACItB,GAAmB,EACvB,CACJ,IAgDgBV,eAAgBA,OAGtB"}
@@ -1,52 +1,171 @@
1
1
  import type { BaseFormElementProps } from "../form/types";
2
2
  import type { PhoneNumberInputValue } from "../phone-number-input";
3
+ import type { VerificationSectionProps } from "./internal-types";
4
+ /**
5
+ * Lifecycle state of the OTP verification flow.
6
+ *
7
+ * - `"default"` — initial state; the contact input is displayed.
8
+ * - `"sent"` — OTP has been dispatched; the OTP entry and verification section appears.
9
+ * - `"verified"` — OTP was successfully verified; the success confirmation is displayed.
10
+ */
3
11
  export type OtpVerificationState = "default" | "sent" | "verified";
12
+ /**
13
+ * Base props shared by all variants of the `OtpVerification` component.
14
+ */
4
15
  export interface BaseOtpVerificationProps {
5
16
  id?: string | undefined;
6
17
  "data-testid"?: string | undefined;
7
18
  disabled?: boolean | undefined;
8
19
  readOnly?: boolean | undefined;
9
20
  className?: string | undefined;
21
+ /**
22
+ * The `id` attribute applied to the contact input field.
23
+ */
10
24
  inputId?: string | undefined;
25
+ /**
26
+ * The current step in the OTP verification flow.
27
+ * Controls which sections are rendered.
28
+ */
11
29
  otpState: OtpVerificationState;
30
+ /**
31
+ * Called when the component transition to a new `otpState`.
32
+ */
12
33
  onOtpStateChange: (state: OtpVerificationState) => void;
34
+ /**
35
+ * Called when the user initiates sending the OTP.
36
+ * On resolution, the component transitions to `"sent"`.
37
+ *
38
+ * @remarks a rejection is silently swallowed. The consumer must use `sendOtpError` to show feedback
39
+ */
13
40
  onSendOtp?: (() => Promise<void>) | undefined;
41
+ /**
42
+ * Error message displayed below the contact input after a failed attempt.
43
+ */
14
44
  sendOtpError?: string | undefined;
45
+ /**
46
+ * Placeholder text for the contact input field.
47
+ */
15
48
  sendOtpPlaceholder?: string | undefined;
49
+ /**
50
+ * Interval in seconds at which an accessibility announcement is made,
51
+ * reminding the user how many seconds remain before they can resend the OTP.
52
+ *
53
+ * @default 120
54
+ */
16
55
  otpReminderInterval?: number | undefined;
17
56
  }
57
+ /**
58
+ * Email-specific props for `OtpVerification`.
59
+ */
18
60
  export interface OtpVerificationEmailInputProps {
61
+ /**
62
+ * Discriminant that sets the contact input to email mode.
63
+ */
19
64
  type: "email";
65
+ /**
66
+ * Controlled value of the email input.
67
+ */
20
68
  emailValue?: string | undefined;
69
+ /**
70
+ * Called when the email input value changes.
71
+ */
21
72
  onEmailChange?: ((input: string) => void) | undefined;
22
73
  }
74
+ /**
75
+ * Phone-number-specific props for `OtpVerification`.
76
+ */
23
77
  export interface OtpVerificationPhoneNumberInputProps {
78
+ /**
79
+ * Discriminant that sets the contact input to phone number mode.
80
+ */
24
81
  type: "phone-number";
82
+ /**
83
+ * Controlled value of the phone number input.
84
+ */
25
85
  phoneNumberValue?: PhoneNumberInputValue | undefined;
86
+ /**
87
+ * Called when the phone number input value changes.
88
+ */
26
89
  onPhoneNumberChange?: ((value: PhoneNumberInputValue) => void) | undefined;
90
+ /**
91
+ * Always `true`; the country selector is locked and cannot be changed by the user.
92
+ */
27
93
  fixedCountry: true;
28
94
  }
29
- export interface OtpVerificationInputProps {
95
+ /**
96
+ * Props for controlling the OTP input field and verification step.
97
+ */
98
+ export interface OtpVerificationInputProps extends Pick<VerificationSectionProps, "showVerifyOtpThumbnail" | "verifyOtpIcon" | "verifyOtpTitle" | "verifyOtpMessage" | "verifyOtpError"> {
99
+ /**
100
+ * Controlled state of the OTP input field.
101
+ */
30
102
  otpValue?: {
103
+ /**
104
+ * Static text displayed before the OTP input.
105
+ */
31
106
  prefix?: string | undefined;
107
+ /**
108
+ * Character displayed between the `prefix` and OTP input..
109
+ */
32
110
  separator?: string | undefined;
111
+ /**
112
+ * The current OTP string entered by the user.
113
+ */
33
114
  value?: string | undefined;
34
115
  } | undefined;
116
+ /**
117
+ * Called when the OTP input value changes.
118
+ *
119
+ * @param value The full OTP string without prefix or separators.
120
+ */
35
121
  onOtpChange?: ((value: string) => void) | undefined;
122
+ /**
123
+ * Called when the user submits the OTP for verification.
124
+ * On resolution the component transitions to `"verified"`.
125
+ *
126
+ * @param input The current OTP string.
127
+ *
128
+ * @remarks a rejection is silently swallowed. The consumer must use `verifyOtpError` to show feedback
129
+ */
36
130
  onVerifyOtp?: ((input: string) => Promise<void>) | undefined;
131
+ /**
132
+ * Duration in seconds of the resend cooldown after an OTP is sent.
133
+ *
134
+ * @default 60
135
+ */
37
136
  verifyOtpCountdownTimer?: number | undefined;
137
+ /**
138
+ * Called when the user requests to resend the OTP from the verification step.
139
+ */
38
140
  onResendOtp?: (() => Promise<void>) | undefined;
39
- verifyOtpError?: string | undefined;
40
- showVerifyOtpThumbnail?: boolean | undefined;
41
- verifyOtpIcon?: React.ReactNode | undefined;
42
- verifyOtpTitle?: string | undefined;
43
- verifyOtpMessage?: string | undefined;
44
141
  }
142
+ /**
143
+ * Combined props for email-based OTP verification.
144
+ */
45
145
  export type EmailOtpVerificationProps = BaseOtpVerificationProps & OtpVerificationEmailInputProps & OtpVerificationInputProps;
146
+ /**
147
+ * Combined props for phone-number-based OTP verification.
148
+ */
46
149
  export type PhoneOtpVerificationProps = BaseOtpVerificationProps & OtpVerificationPhoneNumberInputProps & OtpVerificationInputProps;
150
+ /**
151
+ * Props for the `OtpVerification` component.
152
+ */
47
153
  export type OtpVerificationProps = EmailOtpVerificationProps | PhoneOtpVerificationProps;
154
+ /**
155
+ * Props for the `Form.OtpVerification` email variant, extending
156
+ * `EmailOtpVerificationProps` with form field layout metadata such as label
157
+ * and hint text.
158
+ */
48
159
  export interface FormEmailOtpVerificationProps extends EmailOtpVerificationProps, Omit<BaseFormElementProps, "errorMessage"> {
49
160
  }
161
+ /**
162
+ * Props for the `Form.OtpVerification` phone-number variant, extending
163
+ * `PhoneOtpVerificationProps` with form field layout metadata such as label
164
+ * and hint text.
165
+ */
50
166
  export interface FormPhoneOtpVerificationProps extends PhoneOtpVerificationProps, Omit<BaseFormElementProps, "errorMessage"> {
51
167
  }
168
+ /**
169
+ * Props for the `Form.OtpVerification` component.
170
+ */
52
171
  export type FormOtpVerificationProps = FormEmailOtpVerificationProps | FormPhoneOtpVerificationProps;
@@ -1,2 +1,9 @@
1
1
  import type { OverlayProps } from "./types";
2
+ /**
3
+ * A full-screen dimmed overlay backdrop.
4
+ *
5
+ * Use `Overlay` as the backdrop for modal dialogs, drawers, and similar
6
+ * blocking UI patterns. It manages body scroll-lock automatically and stacks
7
+ * correctly when multiple overlays are open at once.
8
+ */
2
9
  export declare const Overlay: (props: OverlayProps) => import("react/jsx-runtime").JSX.Element;