@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 +1 @@
1
- {"version":3,"file":"overlay.js","sources":["../../src/overlay/overlay.tsx"],"sourcesContent":["import {\n FloatingNode,\n FloatingTree,\n useFloatingNodeId,\n} from \"@floating-ui/react\";\nimport clsx from \"clsx\";\nimport type React from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport ReactDOM from \"react-dom\";\n\nimport { useApplyStyle, useInheritedThemeScope } from \"../theme\";\nimport { useId } from \"../util\";\nimport * as styles from \"./overlay.styles\";\nimport type { OverlayProps } from \"./types\";\nimport { useFloatingParent } from \"./use-floating-context\";\n\nconst OverlayComponent = ({\n show = false,\n rootId,\n onOverlayClick,\n children,\n backgroundBlur = true,\n disableTransition = false,\n enableOverlayClick = false,\n zIndex: customZIndex,\n id,\n containerRef,\n}: OverlayProps): JSX.Element | null => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const [rootElement, setRootElement] = useState<HTMLElement | null>(null);\n const [isStacked, _setIsStacked] = useState<boolean>();\n const uid = useId();\n const nodeId = useFloatingNodeId();\n\n const stacked = useRef<boolean>();\n // Track where mousedown started to prevent closing drawer during text selection drag\n const mouseDownInsideModalRef = useRef(false);\n const rootRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n const overlayRootId = id\n ? `lifesg-ds-overlay-root-${id}`\n : \"lifesg-ds-overlay-root\";\n const zIndex = customZIndex ?? (isStacked ? 99999 : 99998);\n const { themeProps, themeStyle } = useInheritedThemeScope(show);\n\n useFloatingParent(zIndex);\n\n useApplyStyle(rootRef, { [styles.tokens.root.zIndex]: zIndex });\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n initialiseStylesForDocumentBody();\n setRootElement(getRootElement());\n\n return () => {\n removeOverlay();\n\n if (getOverlayOrder().length < 1) {\n if (isIOS()) {\n applyScrollLockClassForIOS(\"remove\");\n scrollToLastScrollPositionForIOS();\n }\n\n applyBodyStyleClass(\"remove\");\n }\n };\n }, []);\n\n useEffect(() => {\n if (show) {\n const isStacked = checkIfStacked();\n setStacked(isStacked);\n\n addOverlay();\n\n if (isIOS() && getOverlayOrder().length === 1) {\n saveScrollPosition();\n applyScrollLockClassForIOS(\"add\");\n }\n\n const timerId = setTimeout(() => {\n applyBodyStyleClass(\"add\");\n }, 200); // Allow overlay animations to complete\n\n return () => clearTimeout(timerId);\n } else {\n removeOverlay();\n\n if (isIOS() && getOverlayOrder().length < 1) {\n applyScrollLockClassForIOS(\"remove\");\n scrollToLastScrollPositionForIOS();\n }\n\n const timerId = setTimeout(() => {\n if (getOverlayOrder().length < 1) {\n applyBodyStyleClass(\"remove\");\n }\n }, 200); // Allow overlay animations to complete\n\n return () => clearTimeout(timerId);\n }\n }, [show]);\n\n // Track mousedown origin to distinguish clicks from text selection drags\n useEffect(() => {\n if (!show) return;\n\n document.addEventListener(\"mousedown\", handleDocumentMouseDown, true);\n return () => {\n document.removeEventListener(\n \"mousedown\",\n handleDocumentMouseDown,\n true\n );\n };\n }, [show]);\n\n // =============================================================================\n // REF FUNCTIONS\n // =============================================================================\n const setStacked = (data: boolean) => {\n stacked.current = data;\n _setIsStacked(data);\n };\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n const isIOS = () => /(iPad|iPhone|iPod)/g.test(navigator.userAgent);\n\n const getRootElement = (): HTMLElement | null => {\n if (document && rootId) {\n return document.getElementById(rootId);\n } else if (document) {\n // If rootId not specified, we'll use body\n return document.body;\n } else {\n return null;\n }\n };\n\n const checkIfStacked = () => {\n return getOverlayOrder().length > 0;\n };\n\n const initialiseStylesForDocumentBody = () => {\n const documentWidth = document.documentElement.clientWidth;\n const windowWidth = window.innerWidth;\n const scrollBarWidth = windowWidth - documentWidth;\n\n document.documentElement.style.setProperty(\n styles.tokens.global.scrollbarWidth,\n `${scrollBarWidth}px`\n );\n };\n\n /**\n * This sets the style of <body> to hide the scrollbar\n */\n const applyBodyStyleClass = (action: \"add\" | \"remove\") => {\n const isOverlayStyleClassApplied = document.body.classList.contains(\n styles.tokens.global.overlayOpenClass\n );\n\n if (action === \"add\" && !isOverlayStyleClassApplied) {\n document.body.classList.add(styles.tokens.global.overlayOpenClass);\n } else if (action === \"remove\" && isOverlayStyleClassApplied) {\n document.body.classList.remove(\n styles.tokens.global.overlayOpenClass\n );\n }\n };\n\n const getOverlayOrder = () => {\n const attr = document.body.dataset.lifesgDsOverlayOrder;\n return attr ? attr.split(\",\") : [];\n };\n\n const addOverlay = () => {\n const order = getOverlayOrder();\n document.body.dataset.lifesgDsOverlayOrder = [...order, uid].join(\",\");\n };\n\n const removeOverlay = () => {\n const order = getOverlayOrder();\n document.body.dataset.lifesgDsOverlayOrder = order\n .filter((o) => o !== uid)\n .join(\",\");\n };\n\n /**\n * This sets the style of <body> to further prevent scrolling on iOS\n *\n * ref: https://stackoverflow.com/a/57455820/3932279\n * `overflow: hidden` and `overscroll-behavior` is ignored by iOS, this is\n * an alternative solution\n *\n * as a side effect this causes the scroll position to reset, so additional\n * logic to restore the scroll on close is required\n */\n const applyScrollLockClassForIOS = (action: \"add\" | \"remove\") => {\n if (!isIOS()) {\n return;\n }\n\n const isClassApplied = document.body.classList.contains(\n styles.tokens.global.overlayScrollLockClass\n );\n\n if (action === \"add\" && !isClassApplied) {\n document.body.classList.add(\n styles.tokens.global.overlayScrollLockClass\n );\n } else if (action === \"remove\" && isClassApplied) {\n document.body.classList.remove(\n styles.tokens.global.overlayScrollLockClass\n );\n }\n };\n\n const saveScrollPosition = () => {\n const bodyStyle = document.body.style;\n const scrollY = bodyStyle.top ? bodyStyle.top : window.scrollY + \"px\";\n\n document.body.style.setProperty(styles.tokens.global.scrollY, scrollY);\n };\n\n const scrollToLastScrollPositionForIOS = () => {\n if (!isIOS()) {\n return;\n }\n\n const scrollY = document.body.style.getPropertyValue(\n styles.tokens.global.scrollY\n );\n requestAnimationFrame(() => {\n window.scrollTo({\n top: parseFloat(scrollY),\n });\n });\n };\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleDocumentMouseDown = (e: MouseEvent) => {\n const container = containerRef?.current ?? wrapperRef.current;\n const wrapper = wrapperRef.current;\n if (!container) {\n mouseDownInsideModalRef.current = false;\n return;\n }\n\n const target = e.target as Node;\n const clickedOnWrapper = wrapper === target;\n const clickedOnContainer = container === target;\n const clickedInsideContainer = container.contains(target);\n\n // Track if mousedown started inside modal content\n mouseDownInsideModalRef.current =\n !clickedOnWrapper && (clickedOnContainer || clickedInsideContainer);\n };\n\n const handleWrapperClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const container = containerRef?.current ?? wrapperRef.current;\n const wrapper = wrapperRef.current;\n if (!container) {\n mouseDownInsideModalRef.current = false;\n return;\n }\n\n const target = event.target as Node;\n const clickedOnWrapper = wrapper === target;\n const clickedOnContainer = container === target;\n const clickedInsideContainer = container.contains(target);\n const clickedInsideModal = clickedOnContainer || clickedInsideContainer;\n\n // Only close if both mousedown AND click happened outside modal\n if (\n (clickedOnWrapper || !clickedInsideModal) &&\n !mouseDownInsideModalRef.current &&\n onOverlayClick &&\n enableOverlayClick\n ) {\n event.preventDefault();\n onOverlayClick();\n }\n\n mouseDownInsideModalRef.current = false;\n };\n\n // =============================================================================\n // RENDER\n // =============================================================================\n const renderWrapper = () => (\n <FloatingNode id={nodeId}>\n <div\n ref={wrapperRef}\n data-testid=\"overlay-wrapper\"\n className={clsx(\n styles.wrapper,\n show ? styles.wrapperShow : styles.wrapperHide,\n isStacked && styles.wrapperStacked,\n backgroundBlur && styles.wrapperBackgroundBlur,\n disableTransition && styles.wrapperDisableTransition\n )}\n onClick={handleWrapperClick}\n >\n {children}\n </div>\n </FloatingNode>\n );\n\n const renderComponent = () => (\n <div\n ref={rootRef}\n id={overlayRootId}\n data-testid={overlayRootId}\n className={clsx(styles.root, show && styles.rootShow)}\n {...themeProps}\n style={themeStyle}\n >\n {children && renderWrapper()}\n </div>\n );\n\n return rootElement\n ? ReactDOM.createPortal(renderComponent(), rootElement)\n : null;\n};\n\nexport const Overlay = (props: OverlayProps) => {\n return (\n <FloatingTree>\n <OverlayComponent {...props} />\n </FloatingTree>\n );\n};\n"],"names":["OverlayComponent","show","rootId","onOverlayClick","children","backgroundBlur","disableTransition","enableOverlayClick","zIndex","customZIndex","id","containerRef","rootElement","setRootElement","useState","isStacked","_setIsStacked","uid","useId","nodeId","useFloatingNodeId","stacked","useRef","mouseDownInsideModalRef","rootRef","wrapperRef","overlayRootId","themeProps","themeStyle","useInheritedThemeScope","useFloatingParent","useApplyStyle","styles.tokens","root","useEffect","initialiseStylesForDocumentBody","getRootElement","removeOverlay","getOverlayOrder","length","isIOS","applyScrollLockClassForIOS","scrollToLastScrollPositionForIOS","applyBodyStyleClass","checkIfStacked","setStacked","addOverlay","saveScrollPosition","timerId","setTimeout","clearTimeout","document","addEventListener","handleDocumentMouseDown","removeEventListener","data","current","test","navigator","userAgent","getElementById","body","documentWidth","documentElement","clientWidth","scrollBarWidth","window","innerWidth","style","setProperty","global","scrollbarWidth","action","isOverlayStyleClassApplied","classList","contains","overlayOpenClass","remove","add","attr","dataset","lifesgDsOverlayOrder","split","order","join","filter","o","isClassApplied","overlayScrollLockClass","bodyStyle","scrollY","top","getPropertyValue","requestAnimationFrame","scrollTo","parseFloat","e","container","_a","wrapper","target","clickedOnWrapper","clickedOnContainer","clickedInsideContainer","handleWrapperClick","event","preventDefault","ReactDOM","createPortal","_jsx","Object","assign","ref","className","clsx","styles.root","styles.rootShow","FloatingNode","styles.wrapper","styles.wrapperShow","styles.wrapperHide","styles.wrapperStacked","styles.wrapperBackgroundBlur","styles.wrapperDisableTransition","onClick","Overlay","props","FloatingTree"],"mappings":"2hCAgBA,MAAMA,EAAmB,EACrBC,QAAO,EACPC,SACAC,iBACAC,WACAC,kBAAiB,EACjBC,qBAAoB,EACpBC,sBAAqB,EACrBC,OAAQC,EACRC,KACAC,mBAKA,MAAOC,EAAaC,GAAkBC,EAA6B,OAC5DC,EAAWC,GAAiBF,IAC7BG,EAAMC,IACNC,EAASC,IAETC,EAAUC,IAEVC,EAA0BD,GAAO,GACjCE,EAAUF,EAAuB,MACjCG,EAAaH,EAAuB,MAEpCI,EAAgBhB,EAChB,0BAA0BA,IAC1B,yBACAF,EAASC,QAAAA,EAAiBM,EAAY,MAAQ,OAC9CY,WAAEA,EAAUC,WAAEA,GAAeC,EAAuB5B,GAE1D6B,EAAkBtB,GAElBuB,EAAcP,EAAS,CAAE,CAACQ,EAAcC,KAAKzB,QAASA,IAKtD0B,GAAU,KACNC,IACAtB,EAAeuB,KAER,KACHC,IAEIC,IAAkBC,OAAS,IACvBC,MACAC,GAA2B,UAC3BC,MAGJC,EAAoB,UACxB,IAEL,IAEHT,GAAU,KACN,GAAIjC,EAAM,CACN,MAAMc,EAAY6B,IAClBC,EAAW9B,GAEX+B,IAEIN,KAAwC,IAA7BF,IAAkBC,SAC7BQ,KACAN,GAA2B,QAG/B,MAAMO,EAAUC,YAAW,KACvBN,EAAoB,MAAM,GAC3B,KAEH,MAAO,IAAMO,aAAaF,EAC9B,CAAO,CACHX,IAEIG,KAAWF,IAAkBC,OAAS,IACtCE,GAA2B,UAC3BC,MAGJ,MAAMM,EAAUC,YAAW,KACnBX,IAAkBC,OAAS,GAC3B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AK5ChF,EAAwBiC,UACzBrD,IACAI,IAEAkG,EAAMC,iBACNvG,KAGJoB,EAAwBiC,SAAU,CAAK,EAsC3C,OAAO5C,EACD+F,EAASC,aAbXC,EAAA,MAAAC,OAAAC,OAAA,CACIC,IAAKxF,EACLd,GAAIgB,EAAa,cACJA,EACbuF,UAAWC,EAAKC,EAAalH,GAAQmH,IACjCzF,EAAU,CACdyC,MAAOxC,WAENxB,GA3BLyG,EAACQ,EAAY,CAAC3G,GAAIS,EAAMf,SACpByG,SACIG,IAAKvF,EAAU,cACH,kBACZwF,UAAWC,EACPI,EACArH,EAAOsH,EAAqBC,EAC5BzG,GAAa0G,EACbpH,GAAkBqH,EAClBpH,GAAqBqH,GAEzBC,QAASpB,GAAkBpG,SAE1BA,SAmBkCQ,GACzC,IAAI,EAGDiH,EAAWC,GAEhBjB,EAACkB,EAAY,CAAA3H,SACTyG,EAAC7G,EAAgB8G,OAAAC,OAAA,CAAA,EAAKe"}
1
+ {"version":3,"file":"overlay.js","sources":["../../src/overlay/overlay.tsx"],"sourcesContent":["import {\n FloatingNode,\n FloatingTree,\n useFloatingNodeId,\n} from \"@floating-ui/react\";\nimport clsx from \"clsx\";\nimport type React from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport ReactDOM from \"react-dom\";\n\nimport { useApplyStyle, useInheritedThemeScope } from \"../theme\";\nimport { useId } from \"../util\";\nimport * as styles from \"./overlay.styles\";\nimport type { OverlayProps } from \"./types\";\nimport { useFloatingParent } from \"./use-floating-context\";\n\nconst OverlayComponent = ({\n show = false,\n rootId,\n onOverlayClick,\n children,\n backgroundBlur = true,\n disableTransition = false,\n enableOverlayClick = false,\n zIndex: customZIndex,\n id,\n containerRef,\n}: OverlayProps): JSX.Element | null => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const [rootElement, setRootElement] = useState<HTMLElement | null>(null);\n const [isStacked, _setIsStacked] = useState<boolean>();\n const uid = useId();\n const nodeId = useFloatingNodeId();\n\n const stacked = useRef<boolean>();\n // Track where mousedown started to prevent closing drawer during text selection drag\n const mouseDownInsideModalRef = useRef(false);\n const rootRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n const overlayRootId = id\n ? `lifesg-ds-overlay-root-${id}`\n : \"lifesg-ds-overlay-root\";\n const zIndex = customZIndex ?? (isStacked ? 99999 : 99998);\n const { themeProps, themeStyle } = useInheritedThemeScope(show);\n\n useFloatingParent(zIndex);\n\n useApplyStyle(rootRef, { [styles.tokens.root.zIndex]: zIndex });\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n initialiseStylesForDocumentBody();\n setRootElement(getRootElement());\n\n return () => {\n removeOverlay();\n\n if (getOverlayOrder().length < 1) {\n if (isIOS()) {\n applyScrollLockClassForIOS(\"remove\");\n scrollToLastScrollPositionForIOS();\n }\n\n applyBodyStyleClass(\"remove\");\n }\n };\n }, []);\n\n useEffect(() => {\n if (show) {\n const isStacked = checkIfStacked();\n setStacked(isStacked);\n\n addOverlay();\n\n if (isIOS() && getOverlayOrder().length === 1) {\n saveScrollPosition();\n applyScrollLockClassForIOS(\"add\");\n }\n\n const timerId = setTimeout(() => {\n applyBodyStyleClass(\"add\");\n }, 200); // Allow overlay animations to complete\n\n return () => clearTimeout(timerId);\n } else {\n removeOverlay();\n\n if (isIOS() && getOverlayOrder().length < 1) {\n applyScrollLockClassForIOS(\"remove\");\n scrollToLastScrollPositionForIOS();\n }\n\n const timerId = setTimeout(() => {\n if (getOverlayOrder().length < 1) {\n applyBodyStyleClass(\"remove\");\n }\n }, 200); // Allow overlay animations to complete\n\n return () => clearTimeout(timerId);\n }\n }, [show]);\n\n // Track mousedown origin to distinguish clicks from text selection drags\n useEffect(() => {\n if (!show) return;\n\n document.addEventListener(\"mousedown\", handleDocumentMouseDown, true);\n return () => {\n document.removeEventListener(\n \"mousedown\",\n handleDocumentMouseDown,\n true\n );\n };\n }, [show]);\n\n // =============================================================================\n // REF FUNCTIONS\n // =============================================================================\n const setStacked = (data: boolean) => {\n stacked.current = data;\n _setIsStacked(data);\n };\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n const isIOS = () => /(iPad|iPhone|iPod)/g.test(navigator.userAgent);\n\n const getRootElement = (): HTMLElement | null => {\n if (document && rootId) {\n return document.getElementById(rootId);\n } else if (document) {\n // If rootId not specified, we'll use body\n return document.body;\n } else {\n return null;\n }\n };\n\n const checkIfStacked = () => {\n return getOverlayOrder().length > 0;\n };\n\n const initialiseStylesForDocumentBody = () => {\n const documentWidth = document.documentElement.clientWidth;\n const windowWidth = window.innerWidth;\n const scrollBarWidth = windowWidth - documentWidth;\n\n document.documentElement.style.setProperty(\n styles.tokens.global.scrollbarWidth,\n `${scrollBarWidth}px`\n );\n };\n\n /**\n * This sets the style of <body> to hide the scrollbar\n */\n const applyBodyStyleClass = (action: \"add\" | \"remove\") => {\n const isOverlayStyleClassApplied = document.body.classList.contains(\n styles.tokens.global.overlayOpenClass\n );\n\n if (action === \"add\" && !isOverlayStyleClassApplied) {\n document.body.classList.add(styles.tokens.global.overlayOpenClass);\n } else if (action === \"remove\" && isOverlayStyleClassApplied) {\n document.body.classList.remove(\n styles.tokens.global.overlayOpenClass\n );\n }\n };\n\n const getOverlayOrder = () => {\n const attr = document.body.dataset.lifesgDsOverlayOrder;\n return attr ? attr.split(\",\") : [];\n };\n\n const addOverlay = () => {\n const order = getOverlayOrder();\n document.body.dataset.lifesgDsOverlayOrder = [...order, uid].join(\",\");\n };\n\n const removeOverlay = () => {\n const order = getOverlayOrder();\n document.body.dataset.lifesgDsOverlayOrder = order\n .filter((o) => o !== uid)\n .join(\",\");\n };\n\n /**\n * This sets the style of <body> to further prevent scrolling on iOS\n *\n * ref: https://stackoverflow.com/a/57455820/3932279\n * `overflow: hidden` and `overscroll-behavior` is ignored by iOS, this is\n * an alternative solution\n *\n * as a side effect this causes the scroll position to reset, so additional\n * logic to restore the scroll on close is required\n */\n const applyScrollLockClassForIOS = (action: \"add\" | \"remove\") => {\n if (!isIOS()) {\n return;\n }\n\n const isClassApplied = document.body.classList.contains(\n styles.tokens.global.overlayScrollLockClass\n );\n\n if (action === \"add\" && !isClassApplied) {\n document.body.classList.add(\n styles.tokens.global.overlayScrollLockClass\n );\n } else if (action === \"remove\" && isClassApplied) {\n document.body.classList.remove(\n styles.tokens.global.overlayScrollLockClass\n );\n }\n };\n\n const saveScrollPosition = () => {\n const bodyStyle = document.body.style;\n const scrollY = bodyStyle.top ? bodyStyle.top : window.scrollY + \"px\";\n\n document.body.style.setProperty(styles.tokens.global.scrollY, scrollY);\n };\n\n const scrollToLastScrollPositionForIOS = () => {\n if (!isIOS()) {\n return;\n }\n\n const scrollY = document.body.style.getPropertyValue(\n styles.tokens.global.scrollY\n );\n requestAnimationFrame(() => {\n window.scrollTo({\n top: parseFloat(scrollY),\n });\n });\n };\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleDocumentMouseDown = (e: MouseEvent) => {\n const container = containerRef?.current ?? wrapperRef.current;\n const wrapper = wrapperRef.current;\n if (!container) {\n mouseDownInsideModalRef.current = false;\n return;\n }\n\n const target = e.target as Node;\n const clickedOnWrapper = wrapper === target;\n const clickedOnContainer = container === target;\n const clickedInsideContainer = container.contains(target);\n\n // Track if mousedown started inside modal content\n mouseDownInsideModalRef.current =\n !clickedOnWrapper && (clickedOnContainer || clickedInsideContainer);\n };\n\n const handleWrapperClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const container = containerRef?.current ?? wrapperRef.current;\n const wrapper = wrapperRef.current;\n if (!container) {\n mouseDownInsideModalRef.current = false;\n return;\n }\n\n const target = event.target as Node;\n const clickedOnWrapper = wrapper === target;\n const clickedOnContainer = container === target;\n const clickedInsideContainer = container.contains(target);\n const clickedInsideModal = clickedOnContainer || clickedInsideContainer;\n\n // Only close if both mousedown AND click happened outside modal\n if (\n (clickedOnWrapper || !clickedInsideModal) &&\n !mouseDownInsideModalRef.current &&\n onOverlayClick &&\n enableOverlayClick\n ) {\n event.preventDefault();\n onOverlayClick();\n }\n\n mouseDownInsideModalRef.current = false;\n };\n\n // =============================================================================\n // RENDER\n // =============================================================================\n const renderWrapper = () => (\n <FloatingNode id={nodeId}>\n <div\n ref={wrapperRef}\n data-testid=\"overlay-wrapper\"\n className={clsx(\n styles.wrapper,\n show ? styles.wrapperShow : styles.wrapperHide,\n isStacked && styles.wrapperStacked,\n backgroundBlur && styles.wrapperBackgroundBlur,\n disableTransition && styles.wrapperDisableTransition\n )}\n onClick={handleWrapperClick}\n >\n {children}\n </div>\n </FloatingNode>\n );\n\n const renderComponent = () => (\n <div\n ref={rootRef}\n id={overlayRootId}\n data-testid={overlayRootId}\n className={clsx(styles.root, show && styles.rootShow)}\n {...themeProps}\n style={themeStyle}\n >\n {children && renderWrapper()}\n </div>\n );\n\n return rootElement\n ? ReactDOM.createPortal(renderComponent(), rootElement)\n : null;\n};\n\n/**\n * A full-screen dimmed overlay backdrop.\n *\n * Use `Overlay` as the backdrop for modal dialogs, drawers, and similar\n * blocking UI patterns. It manages body scroll-lock automatically and stacks\n * correctly when multiple overlays are open at once.\n */\nexport const Overlay = (props: OverlayProps) => {\n return (\n <FloatingTree>\n <OverlayComponent {...props} />\n </FloatingTree>\n );\n};\n"],"names":["OverlayComponent","show","rootId","onOverlayClick","children","backgroundBlur","disableTransition","enableOverlayClick","zIndex","customZIndex","id","containerRef","rootElement","setRootElement","useState","isStacked","_setIsStacked","uid","useId","nodeId","useFloatingNodeId","stacked","useRef","mouseDownInsideModalRef","rootRef","wrapperRef","overlayRootId","themeProps","themeStyle","useInheritedThemeScope","useFloatingParent","useApplyStyle","styles.tokens","root","useEffect","initialiseStylesForDocumentBody","getRootElement","removeOverlay","getOverlayOrder","length","isIOS","applyScrollLockClassForIOS","scrollToLastScrollPositionForIOS","applyBodyStyleClass","checkIfStacked","setStacked","addOverlay","saveScrollPosition","timerId","setTimeout","clearTimeout","document","addEventListener","handleDocumentMouseDown","removeEventListener","data","current","test","navigator","userAgent","getElementById","body","documentWidth","documentElement","clientWidth","scrollBarWidth","window","innerWidth","style","setProperty","global","scrollbarWidth","action","isOverlayStyleClassApplied","classList","contains","overlayOpenClass","remove","add","attr","dataset","lifesgDsOverlayOrder","split","order","join","filter","o","isClassApplied","overlayScrollLockClass","bodyStyle","scrollY","top","getPropertyValue","requestAnimationFrame","scrollTo","parseFloat","e","container","_a","wrapper","target","clickedOnWrapper","clickedOnContainer","clickedInsideContainer","handleWrapperClick","event","preventDefault","ReactDOM","createPortal","_jsx","Object","assign","ref","className","clsx","styles.root","styles.rootShow","FloatingNode","styles.wrapper","styles.wrapperShow","styles.wrapperHide","styles.wrapperStacked","styles.wrapperBackgroundBlur","styles.wrapperDisableTransition","onClick","Overlay","props","FloatingTree"],"mappings":"2hCAgBA,MAAMA,EAAmB,EACrBC,QAAO,EACPC,SACAC,iBACAC,WACAC,kBAAiB,EACjBC,qBAAoB,EACpBC,sBAAqB,EACrBC,OAAQC,EACRC,KACAC,mBAKA,MAAOC,EAAaC,GAAkBC,EAA6B,OAC5DC,EAAWC,GAAiBF,IAC7BG,EAAMC,IACNC,EAASC,IAETC,EAAUC,IAEVC,EAA0BD,GAAO,GACjCE,EAAUF,EAAuB,MACjCG,EAAaH,EAAuB,MAEpCI,EAAgBhB,EAChB,0BAA0BA,IAC1B,yBACAF,EAASC,QAAAA,EAAiBM,EAAY,MAAQ,OAC9CY,WAAEA,EAAUC,WAAEA,GAAeC,EAAuB5B,GAE1D6B,EAAkBtB,GAElBuB,EAAcP,EAAS,CAAE,CAACQ,EAAcC,KAAKzB,QAASA,IAKtD0B,GAAU,KACNC,IACAtB,EAAeuB,KAER,KACHC,IAEIC,IAAkBC,OAAS,IACvBC,MACAC,GAA2B,UAC3BC,MAGJC,EAAoB,UACxB,IAEL,IAEHT,GAAU,KACN,GAAIjC,EAAM,CACN,MAAMc,EAAY6B,IAClBC,EAAW9B,GAEX+B,IAEIN,KAAwC,IAA7BF,IAAkBC,SAC7BQ,KACAN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,EAAIzE,EAAW+B,QAChD2C,EAAU1E,EAAW+B,QAC3B,IAAKyC,EAED,YADA1E,EAAwBiC,SAAU,GAItC,MAAM4C,EAASK,EAAML,OACfC,EAAmBF,IAAYC,EAC/BE,EAAqBL,IAAcG,EACnCG,EAAyBN,EAAUtB,SAASyB,IAK7CC,IAJsBC,GAAsBC,IAK5ChF,EAAwBiC,UACzBrD,IACAI,IAEAkG,EAAMC,iBACNvG,KAGJoB,EAAwBiC,SAAU,CAAK,EAsC3C,OAAO5C,EACD+F,EAASC,aAbXC,EAAA,MAAAC,OAAAC,OAAA,CACIC,IAAKxF,EACLd,GAAIgB,EAAa,cACJA,EACbuF,UAAWC,EAAKC,EAAalH,GAAQmH,IACjCzF,EAAU,CACdyC,MAAOxC,WAENxB,GA3BLyG,EAACQ,EAAY,CAAC3G,GAAIS,EAAMf,SACpByG,SACIG,IAAKvF,EAAU,cACH,kBACZwF,UAAWC,EACPI,EACArH,EAAOsH,EAAqBC,EAC5BzG,GAAa0G,EACbpH,GAAkBqH,EAClBpH,GAAqBqH,GAEzBC,QAASpB,GAAkBpG,SAE1BA,SAmBkCQ,GACzC,IAAI,EAUDiH,EAAWC,GAEhBjB,EAACkB,EAAY,CAAA3H,SACTyG,EAAC7G,EAAgB8G,OAAAC,OAAA,CAAA,EAAKe"}
@@ -1,14 +1,69 @@
1
+ /**
2
+ * Props for the `Overlay` component.
3
+ */
1
4
  export interface OverlayProps {
2
5
  children?: JSX.Element | undefined;
6
+ /**
7
+ * Controls the visible state of the overlay.
8
+ *
9
+ * @default false
10
+ */
3
11
  show?: boolean | undefined;
4
- /** The id of the root element to attach the overlay to */
12
+ /**
13
+ * The root element that contains the overlay element, specified by its `id`.
14
+ *
15
+ * @remarks
16
+ * - If `rootId` is provided but no matching element exists, the overlay is not rendered.
17
+ * - If a parent has a higher `z-index` than the overlay, the overlay may be
18
+ * obscured.
19
+ *
20
+ * @default document.body
21
+ */
5
22
  rootId?: string | undefined;
23
+ /**
24
+ * Applies a blur effect to the background behind the overlay.
25
+ *
26
+ * @default true
27
+ */
6
28
  backgroundBlur?: boolean | undefined;
29
+ /**
30
+ * Disables the enter and exit transition animations.
31
+ *
32
+ * @default false
33
+ */
7
34
  disableTransition?: boolean | undefined;
35
+ /**
36
+ * Enables `onOverlayClick` to fire when the user clicks outside the
37
+ * modal content.
38
+ *
39
+ * @default false
40
+ */
8
41
  enableOverlayClick?: boolean | undefined;
42
+ /**
43
+ * Overrides the CSS `z-index` of the overlay root element.
44
+ *
45
+ * @remarks
46
+ * When omitted, the z-index is auto-assigned: `99999` for stacked overlays (opened on
47
+ * top of another) and `99998` for the base overlay.
48
+ */
9
49
  zIndex?: number | undefined;
50
+ /**
51
+ * Called when the user clicks outside the modal content area. Only fires
52
+ * when `enableOverlayClick` is `true`.
53
+ */
10
54
  onOverlayClick?: (() => void) | undefined;
55
+ /**
56
+ * Sets the `id` attribute of the overlay root element as
57
+ * `lifesg-ds-overlay-root-${id}`.
58
+ *
59
+ * @default "lifesg-ds-overlay-root"
60
+ */
11
61
  id?: string | undefined;
12
- /** The container that defines the boundaries for overlay click detection */
62
+ /**
63
+ * A ref to an element that defines the boundary for outside-click
64
+ * detection.
65
+ *
66
+ * @remarks Falls back to the internal wrapper element when omitted.
67
+ */
13
68
  containerRef?: React.RefObject<HTMLElement> | undefined;
14
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifesg/react-design-system",
3
- "version": "4.0.0-alpha.5",
3
+ "version": "4.0.0-alpha.6",
4
4
  "description": "A component design system for LifeSG web apps",
5
5
  "keywords": [
6
6
  "design-system"
@@ -1,3 +1,8 @@
1
1
  import React from "react";
2
2
  import type { PaginationProps } from "./types";
3
+ /**
4
+ * A navigation control for moving through paged content.
5
+ *
6
+ * Use `Pagination` to let users navigate between pages of a data set.
7
+ */
3
8
  export declare const Pagination: (props: PaginationProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.js","sources":["../../src/pagination/pagination.tsx"],"sourcesContent":["import { Chevron2LeftIcon } from \"@lifesg/react-icons/chevron-2-left\";\nimport { Chevron2RightIcon } from \"@lifesg/react-icons/chevron-2-right\";\nimport { ChevronLeftIcon } from \"@lifesg/react-icons/chevron-left\";\nimport { ChevronLineLeftIcon } from \"@lifesg/react-icons/chevron-line-left\";\nimport { ChevronLineRightIcon } from \"@lifesg/react-icons/chevron-line-right\";\nimport { ChevronRightIcon } from \"@lifesg/react-icons/chevron-right\";\nimport { EllipsisHorizontalIcon } from \"@lifesg/react-icons/ellipsis-horizontal\";\nimport clsx from \"clsx\";\nimport React, { useEffect, useState } from \"react\";\n\nimport { Input } from \"../input\";\nimport { InputSelect } from \"../input-select\";\nimport { VisuallyHidden } from \"../shared/accessibility\";\nimport { ClickableIcon } from \"../shared/clickable-icon\";\nimport { useMaxWidthMediaQuery } from \"../theme\";\nimport { Typography } from \"../typography\";\nimport { useId, useIsMounted } from \"../util\";\nimport * as styles from \"./pagination.styles\";\nimport type { PageSizeItemProps, PaginationProps } from \"./types\";\n\nconst Component = (\n {\n id,\n \"data-testid\": dataTestId,\n className,\n pageSize = 10,\n totalItems,\n activePage,\n pageSizeOptions = DEFAULT_OPTIONS,\n showFirstAndLastNav,\n showPageSizeChanger = false,\n onPageChange,\n onPageSizeChange,\n }: PaginationProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n\n const isMounted = useIsMounted();\n const isMobile = useMaxWidthMediaQuery(\"sm\");\n const [hoverRightButton, setHoverRightButton] = useState(false);\n const [hoverLeftButton, setHoverLeftButton] = useState(false);\n const [inputText, setInputText] = useState<string>(\"\");\n\n const [selectedOption, setSelectedOption] = useState<\n PageSizeItemProps | undefined\n >(pageSizeOptions[0]);\n const [pageSizeLocal, setPageSize] = useState<number>(\n !isMobile && showPageSizeChanger\n ? selectedOption\n ? selectedOption.value\n : pageSize\n : pageSize\n );\n\n const boundaryRange = 1;\n const siblingRange = 1;\n\n const internalId = useId();\n const paginationId = `${internalId}-pagination`;\n\n const totalPages = Math.ceil(totalItems / pageSizeLocal);\n const isFirstPage = activePage === 1;\n const isLastPage = activePage === totalPages;\n\n const firstPaginationItem =\n activePage > 1 ? () => handlePaginationItemClick(1) : undefined;\n const lastPaginationItem =\n activePage < totalPages\n ? () => handlePaginationItemClick(totalPages)\n : undefined;\n const prevPaginationItem =\n activePage > 1\n ? () => handlePaginationItemClick(activePage - 1)\n : undefined;\n const nextPaginationItem =\n activePage < totalPages\n ? () =>\n handlePaginationItemClick(parseInt(activePage.toString()) + 1)\n : undefined;\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n if (activePage) {\n setInputValue(activePage);\n }\n }, [activePage]);\n\n useEffect(() => {\n setPageSize(pageSize);\n setSelectedOption(\n pageSizeOptions.find((option) => option.value === pageSize)\n );\n }, [pageSize]);\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n const setInputValue = (value: number) => {\n setInputText(value.toString());\n };\n\n const closeAllTooltips = () => {\n setHoverRightButton(false);\n setHoverLeftButton(false);\n };\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handlePaginationItemClick = (pageIndex: number) => {\n if (onPageChange) {\n onPageChange(pageIndex);\n setInputValue(pageIndex);\n }\n };\n\n const handleFastForwardClick = () => {\n const currentIndex = Math.min(totalPages, activePage + 5);\n handlePaginationItemClick(currentIndex);\n setInputValue(currentIndex);\n setHoverRightButton(true);\n setHoverLeftButton(false);\n };\n\n const handleFastBackwardClick = () => {\n const currentIndex = Math.max(1, activePage - 5);\n handlePaginationItemClick(currentIndex);\n setInputValue(currentIndex);\n setHoverRightButton(false);\n setHoverLeftButton(true);\n };\n\n const handleInput = (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n const numericRegex = /^[0-9]+$/;\n if (value === undefined || value.length === 0) {\n setInputText(\"\");\n } else if (!numericRegex.test(value)) {\n setInputText(value.replace(/[^0-9]/g, \"\"));\n } else {\n const newPage = parseInt(value.replace(/[^0-9]/g, \"\"));\n setInputValue(Math.max(1, Math.min(totalPages, newPage)));\n }\n };\n\n const handleInputSubmit = (event: React.FormEvent) => {\n event.preventDefault();\n if (inputText) {\n onPageChange?.(parseInt(inputText));\n }\n };\n\n const onHoverRightButton = () => {\n setHoverRightButton(true);\n };\n\n const onBlurRightButton = () => {\n setHoverRightButton(false);\n };\n\n const onHoverLeftButton = () => {\n setHoverLeftButton(true);\n };\n\n const onBlurLeftButton = () => {\n setHoverLeftButton(false);\n };\n\n const handleListItemClick = (item: PageSizeItemProps) => {\n setSelectedOption(item);\n const pagesize = item.value;\n const totalPage = Math.ceil(totalItems / pagesize);\n\n setPageSize(pagesize);\n\n const page = activePage >= totalPage ? totalPage : activePage;\n\n if (onPageSizeChange) {\n onPageSizeChange(page, pagesize);\n }\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderPaginationItems = () => {\n return [...Array(totalPages)].map((e, i) => {\n const pageIndex = i + 1;\n const startRange = boundaryRange + 2 + siblingRange * 2;\n const endRange = totalPages - startRange;\n const totalRange = (boundaryRange + siblingRange) * 2 + 3;\n const active = activePage === pageIndex;\n if (totalPages <= totalRange) {\n return (\n <button\n key={pageIndex}\n onClick={() => handlePaginationItemClick(pageIndex)}\n className={clsx(\n styles.pageItem,\n active && styles.pageItemSelected\n )}\n aria-label={`page ${pageIndex} of ${totalPages}`}\n aria-current={active ? \"page\" : false}\n onMouseOver={closeAllTooltips}\n onFocus={closeAllTooltips}\n >\n {pageIndex}\n </button>\n );\n }\n\n const ellipsisStart =\n activePage + siblingRange > startRange &&\n pageIndex === boundaryRange + 1;\n if (ellipsisStart) {\n return renderStartEllipsis(pageIndex);\n }\n\n const ellipsisEnd =\n activePage - siblingRange <= endRange &&\n pageIndex === totalPages - boundaryRange - 1;\n if (ellipsisEnd) {\n return renderEndEllipsis(pageIndex);\n }\n\n const paginationStart =\n (pageIndex <= startRange &&\n activePage + siblingRange <= startRange) ||\n pageIndex <= boundaryRange;\n const paginationMiddle =\n pageIndex === activePage ||\n (pageIndex <= activePage + siblingRange &&\n pageIndex >= activePage - siblingRange - 1);\n const paginationEnd =\n (pageIndex > endRange &&\n activePage - siblingRange > endRange) ||\n pageIndex > totalPages - boundaryRange;\n if (paginationStart || paginationMiddle || paginationEnd) {\n return (\n <button\n key={pageIndex}\n onClick={() => handlePaginationItemClick(pageIndex)}\n className={clsx(\n styles.pageItem,\n active && styles.pageItemSelected\n )}\n aria-label={`page ${pageIndex} of ${totalPages}`}\n aria-current={active ? \"page\" : false}\n onMouseOver={closeAllTooltips}\n onFocus={closeAllTooltips}\n >\n {pageIndex}\n </button>\n );\n }\n\n return null;\n });\n };\n\n const renderStartEllipsis = (pageIndex: number) => (\n <div key={pageIndex} className={styles.ellipsisContainer}>\n <ClickableIcon\n className={styles.iconButton}\n focusHighlight={false}\n focusOutline=\"browser\"\n aria-label={\"Previous 5 pages\"}\n onMouseEnter={onHoverLeftButton}\n onMouseLeave={onBlurLeftButton}\n onFocus={onHoverLeftButton}\n onBlur={onBlurLeftButton}\n onClick={handleFastBackwardClick}\n >\n {hoverLeftButton ? (\n <Chevron2LeftIcon aria-hidden />\n ) : (\n <EllipsisHorizontalIcon aria-hidden />\n )}\n </ClickableIcon>\n {hoverLeftButton && (\n <div className={styles.hover}>Previous 5 pages</div>\n )}\n </div>\n );\n\n const renderEndEllipsis = (pageIndex: number) => (\n <div key={pageIndex} className={styles.ellipsisContainer}>\n <ClickableIcon\n className={styles.iconButton}\n focusHighlight={false}\n focusOutline=\"browser\"\n aria-label={\"Next 5 pages\"}\n onMouseEnter={onHoverRightButton}\n onMouseLeave={onBlurRightButton}\n onFocus={onHoverRightButton}\n onBlur={onBlurRightButton}\n onClick={handleFastForwardClick}\n >\n {hoverRightButton ? (\n <Chevron2RightIcon aria-hidden />\n ) : (\n <EllipsisHorizontalIcon aria-hidden />\n )}\n </ClickableIcon>\n {hoverRightButton && (\n <div className={styles.hover}>Next 5 pages</div>\n )}\n </div>\n );\n\n const renderMobile = () => (\n <div className={styles.paginationMobileInput}>\n <form onSubmit={handleInputSubmit}>\n <Input\n className={styles.inputView}\n value={inputText}\n onChange={handleInput}\n autoComplete=\"off\"\n type=\"numeric\"\n id={(id || \"pagination\") + \"-input\"}\n data-testid={(dataTestId || \"pagination\") + \"-input\"}\n aria-label={`Page ${activePage} of ${totalPages}`}\n />\n </form>\n <Typography.BodyBL className={styles.labelDivider}>\n /\n </Typography.BodyBL>\n <Typography.BodyBL className={styles.label}>\n {totalPages}\n </Typography.BodyBL>\n </div>\n );\n\n return (\n <nav\n className={clsx(styles.paginationWrapper, className)}\n ref={ref}\n id={id || \"pagination-wrapper\"}\n data-testid={dataTestId || \"pagination\"}\n aria-labelledby={paginationId}\n >\n <VisuallyHidden id={paginationId} aria-hidden>\n pagination\n </VisuallyHidden>\n <div className={styles.paginationList}>\n <div className={styles.paginationMenu}>\n {showFirstAndLastNav && (\n <ClickableIcon\n className={clsx(\n styles.iconButton,\n styles.iconButtonNavigation\n )}\n onClick={firstPaginationItem}\n disabled={isFirstPage}\n focusHighlight={false}\n aria-label=\"First page\"\n focusOutline=\"browser\"\n >\n <ChevronLineLeftIcon aria-hidden />\n </ClickableIcon>\n )}\n <ClickableIcon\n className={clsx(\n styles.iconButton,\n styles.iconButtonNavigation\n )}\n onClick={prevPaginationItem}\n disabled={isFirstPage}\n focusHighlight={false}\n aria-label=\"Previous page\"\n focusOutline=\"browser\"\n >\n <ChevronLeftIcon aria-hidden />\n </ClickableIcon>\n {isMounted && isMobile\n ? renderMobile()\n : renderPaginationItems()}\n <ClickableIcon\n className={clsx(\n styles.iconButton,\n styles.iconButtonNavigation\n )}\n onClick={nextPaginationItem}\n disabled={isLastPage}\n focusHighlight={false}\n aria-label=\"Next page\"\n focusOutline=\"browser\"\n >\n <ChevronRightIcon aria-hidden />\n </ClickableIcon>\n {showFirstAndLastNav && (\n <ClickableIcon\n className={clsx(\n styles.iconButton,\n styles.iconButtonNavigation\n )}\n onClick={lastPaginationItem}\n disabled={isLastPage}\n focusHighlight={false}\n aria-label=\"Last page\"\n focusOutline=\"browser\"\n >\n <ChevronLineRightIcon aria-hidden />\n </ClickableIcon>\n )}\n </div>\n </div>\n {showPageSizeChanger && !isMobile && (\n <div className={styles.inputSelectWrapper}>\n <VisuallyHidden id={`${paginationId}-page-size`}>\n Items per page\n </VisuallyHidden>\n <InputSelect\n aria-labelledby={`${paginationId}-page-size`}\n options={pageSizeOptions}\n valueExtractor={(item) => item.value}\n listExtractor={(item) => item.label}\n displayValueExtractor={(item) => item.label}\n selectedOption={selectedOption}\n onSelectOption={handleListItemClick}\n />\n </div>\n )}\n </nav>\n );\n};\nexport const Pagination = React.forwardRef(Component);\n\nconst DEFAULT_OPTIONS: PageSizeItemProps[] = [\n { value: 10, label: \"10 per page\" },\n { value: 20, label: \"20 per page\" },\n { value: 30, label: \"30 per page\" },\n];\n"],"names":["Pagination","React","forwardRef","id","dataTestId","className","pageSize","totalItems","activePage","pageSizeOptions","DEFAULT_OPTIONS","showFirstAndLastNav","showPageSizeChanger","onPageChange","onPageSizeChange","ref","isMounted","useIsMounted","isMobile","useMaxWidthMediaQuery","hoverRightButton","setHoverRightButton","useState","hoverLeftButton","setHoverLeftButton","inputText","setInputText","selectedOption","setSelectedOption","pageSizeLocal","setPageSize","value","paginationId","useId","totalPages","Math","ceil","isFirstPage","isLastPage","firstPaginationItem","handlePaginationItemClick","undefined","lastPaginationItem","prevPaginationItem","nextPaginationItem","parseInt","toString","useEffect","setInputValue","find","option","closeAllTooltips","pageIndex","handleFastForwardClick","currentIndex","min","handleFastBackwardClick","max","handleInput","event","target","length","test","newPage","replace","handleInputSubmit","preventDefault","onHoverRightButton","onBlurRightButton","onHoverLeftButton","onBlurLeftButton","renderStartEllipsis","_jsxs","styles.ellipsisContainer","children","_jsx","ClickableIcon","styles.iconButton","focusHighlight","focusOutline","onMouseEnter","onMouseLeave","onFocus","onBlur","onClick","Chevron2LeftIcon","EllipsisHorizontalIcon","styles.hover","renderEndEllipsis","Chevron2RightIcon","clsx","styles.paginationWrapper","VisuallyHidden","styles.paginationList","styles.paginationMenu","styles.iconButtonNavigation","disabled","ChevronLineLeftIcon","ChevronLeftIcon","styles.paginationMobileInput","onSubmit","Input","styles.inputView","onChange","autoComplete","type","Typography","BodyBL","styles.labelDivider","styles.label","Array","map","e","i","endRange","boundaryRange","active","styles.pageItem","styles.pageItemSelected","onMouseOver","ChevronRightIcon","ChevronLineRightIcon","styles.inputSelectWrapper","InputSelect","options","valueExtractor","item","listExtractor","label","displayValueExtractor","onSelectOption","pagesize","totalPage"],"mappings":"uvDAoBA,MA2ZaA,EAAaC,EAAMC,YA3Zd,EAEVC,KACA,cAAeC,EACfC,YACAC,WAAW,GACXC,aACAC,aACAC,kBAAkBC,EAClBC,sBACAC,uBAAsB,EACtBC,eACAC,oBAEJC,KAMA,MAAMC,EAAYC,IACZC,EAAWC,EAAsB,OAChCC,EAAkBC,GAAuBC,GAAS,IAClDC,EAAiBC,GAAsBF,GAAS,IAChDG,EAAWC,IAAgBJ,EAAiB,KAE5CK,GAAgBC,IAAqBN,EAE1Cb,EAAgB,KACXoB,GAAeC,IAAeR,GAChCJ,GAAYN,GACPe,GACIA,GAAeI,MAEnBzB,GAOJ0B,GAAe,GADFC,iBAGbC,GAAaC,KAAKC,KAAK7B,EAAasB,IACpCQ,GAA6B,IAAf7B,EACd8B,GAAa9B,IAAe0B,GAE5BK,GACF/B,EAAa,EAAI,IAAMgC,GAA0B,QAAKC,EACpDC,GACFlC,EAAa0B,GACP,IAAMM,GAA0BN,SAChCO,EACJE,GACFnC,EAAa,EACP,IAAMgC,GAA0BhC,EAAa,QAC7CiC,EACJG,GACFpC,EAAa0B,GACP,IACIM,GAA0BK,SAASrC,EAAWsC,YAAc,QAChEL,EAKVM,GAAU,KACFvC,GACAwC,GAAcxC,EAClB,GACD,CAACA,IAEJuC,GAAU,KACNj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aAAa,mBAEbJ,EAAC6C,EAAgB,CAAA,eAAA,MAEpB7G,GACGgE,EAACC,EAAa,CACVvE,UAAWqF,EACPb,EACAkB,GAEJX,QAAS1C,GACTsD,SAAU1D,GACVwC,gBAAgB,EAAK,aACV,YACXC,aAAa,UAASL,SAEtBC,EAAC8C,EAAoB,CAAA,eAAA,WAKpC7G,IAAwBM,GACrBsD,EAAA,MAAA,CAAKnE,UAAWqH,EAAyBhD,SAAA,CACrCC,EAACiB,EAAc,CAACzF,GAAI,GAAG6B,2CAGvB2C,EAACgD,EAAW,CAAA,kBACS,GAAG3F,eACpB4F,QAASnH,EACToH,eAAiBC,GAASA,EAAK/F,MAC/BgG,cAAgBD,GAASA,EAAKE,MAC9BC,sBAAwBH,GAASA,EAAKE,MACtCrG,eAAgBA,GAChBuG,eA3PSJ,IACzBlG,GAAkBkG,GAClB,MAAMK,EAAWL,EAAK/F,MAChBqG,EAAYjG,KAAKC,KAAK7B,EAAa4H,GAEzCrG,GAAYqG,GAIRrH,GACAA,EAHSN,GAAc4H,EAAYA,EAAY5H,EAGxB2H,EAC3B,SAoPM,IAKRzH,EAAuC,CACzC,CAAEqB,MAAO,GAAIiG,MAAO,eACpB,CAAEjG,MAAO,GAAIiG,MAAO,eACpB,CAAEjG,MAAO,GAAIiG,MAAO"}
1
+ {"version":3,"file":"pagination.js","sources":["../../src/pagination/pagination.tsx"],"sourcesContent":["import { Chevron2LeftIcon } from \"@lifesg/react-icons/chevron-2-left\";\nimport { Chevron2RightIcon } from \"@lifesg/react-icons/chevron-2-right\";\nimport { ChevronLeftIcon } from \"@lifesg/react-icons/chevron-left\";\nimport { ChevronLineLeftIcon } from \"@lifesg/react-icons/chevron-line-left\";\nimport { ChevronLineRightIcon } from \"@lifesg/react-icons/chevron-line-right\";\nimport { ChevronRightIcon } from \"@lifesg/react-icons/chevron-right\";\nimport { EllipsisHorizontalIcon } from \"@lifesg/react-icons/ellipsis-horizontal\";\nimport clsx from \"clsx\";\nimport React, { useEffect, useState } from \"react\";\n\nimport { Input } from \"../input\";\nimport { InputSelect } from \"../input-select\";\nimport { VisuallyHidden } from \"../shared/accessibility\";\nimport { ClickableIcon } from \"../shared/clickable-icon\";\nimport { useMaxWidthMediaQuery } from \"../theme\";\nimport { Typography } from \"../typography\";\nimport { useId, useIsMounted } from \"../util\";\nimport * as styles from \"./pagination.styles\";\nimport type { PageSizeItemProps, PaginationProps } from \"./types\";\n\nconst Component = (\n {\n id,\n \"data-testid\": dataTestId,\n className,\n pageSize = 10,\n totalItems,\n activePage,\n pageSizeOptions = DEFAULT_OPTIONS,\n showFirstAndLastNav,\n showPageSizeChanger = false,\n onPageChange,\n onPageSizeChange,\n }: PaginationProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n\n const isMounted = useIsMounted();\n const isMobile = useMaxWidthMediaQuery(\"sm\");\n const [hoverRightButton, setHoverRightButton] = useState(false);\n const [hoverLeftButton, setHoverLeftButton] = useState(false);\n const [inputText, setInputText] = useState<string>(\"\");\n\n const [selectedOption, setSelectedOption] = useState<\n PageSizeItemProps | undefined\n >(pageSizeOptions[0]);\n const [pageSizeLocal, setPageSize] = useState<number>(\n !isMobile && showPageSizeChanger\n ? selectedOption\n ? selectedOption.value\n : pageSize\n : pageSize\n );\n\n const boundaryRange = 1;\n const siblingRange = 1;\n\n const internalId = useId();\n const paginationId = `${internalId}-pagination`;\n\n const totalPages = Math.ceil(totalItems / pageSizeLocal);\n const isFirstPage = activePage === 1;\n const isLastPage = activePage === totalPages;\n\n const firstPaginationItem =\n activePage > 1 ? () => handlePaginationItemClick(1) : undefined;\n const lastPaginationItem =\n activePage < totalPages\n ? () => handlePaginationItemClick(totalPages)\n : undefined;\n const prevPaginationItem =\n activePage > 1\n ? () => handlePaginationItemClick(activePage - 1)\n : undefined;\n const nextPaginationItem =\n activePage < totalPages\n ? () =>\n handlePaginationItemClick(parseInt(activePage.toString()) + 1)\n : undefined;\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n if (activePage) {\n setInputValue(activePage);\n }\n }, [activePage]);\n\n useEffect(() => {\n setPageSize(pageSize);\n setSelectedOption(\n pageSizeOptions.find((option) => option.value === pageSize)\n );\n }, [pageSize]);\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n const setInputValue = (value: number) => {\n setInputText(value.toString());\n };\n\n const closeAllTooltips = () => {\n setHoverRightButton(false);\n setHoverLeftButton(false);\n };\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handlePaginationItemClick = (pageIndex: number) => {\n if (onPageChange) {\n onPageChange(pageIndex);\n setInputValue(pageIndex);\n }\n };\n\n const handleFastForwardClick = () => {\n const currentIndex = Math.min(totalPages, activePage + 5);\n handlePaginationItemClick(currentIndex);\n setInputValue(currentIndex);\n setHoverRightButton(true);\n setHoverLeftButton(false);\n };\n\n const handleFastBackwardClick = () => {\n const currentIndex = Math.max(1, activePage - 5);\n handlePaginationItemClick(currentIndex);\n setInputValue(currentIndex);\n setHoverRightButton(false);\n setHoverLeftButton(true);\n };\n\n const handleInput = (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n const numericRegex = /^[0-9]+$/;\n if (value === undefined || value.length === 0) {\n setInputText(\"\");\n } else if (!numericRegex.test(value)) {\n setInputText(value.replace(/[^0-9]/g, \"\"));\n } else {\n const newPage = parseInt(value.replace(/[^0-9]/g, \"\"));\n setInputValue(Math.max(1, Math.min(totalPages, newPage)));\n }\n };\n\n const handleInputSubmit = (event: React.FormEvent) => {\n event.preventDefault();\n if (inputText) {\n onPageChange?.(parseInt(inputText));\n }\n };\n\n const onHoverRightButton = () => {\n setHoverRightButton(true);\n };\n\n const onBlurRightButton = () => {\n setHoverRightButton(false);\n };\n\n const onHoverLeftButton = () => {\n setHoverLeftButton(true);\n };\n\n const onBlurLeftButton = () => {\n setHoverLeftButton(false);\n };\n\n const handleListItemClick = (item: PageSizeItemProps) => {\n setSelectedOption(item);\n const pagesize = item.value;\n const totalPage = Math.ceil(totalItems / pagesize);\n\n setPageSize(pagesize);\n\n const page = activePage >= totalPage ? totalPage : activePage;\n\n if (onPageSizeChange) {\n onPageSizeChange(page, pagesize);\n }\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderPaginationItems = () => {\n return [...Array(totalPages)].map((e, i) => {\n const pageIndex = i + 1;\n const startRange = boundaryRange + 2 + siblingRange * 2;\n const endRange = totalPages - startRange;\n const totalRange = (boundaryRange + siblingRange) * 2 + 3;\n const active = activePage === pageIndex;\n if (totalPages <= totalRange) {\n return (\n <button\n key={pageIndex}\n onClick={() => handlePaginationItemClick(pageIndex)}\n className={clsx(\n styles.pageItem,\n active && styles.pageItemSelected\n )}\n aria-label={`page ${pageIndex} of ${totalPages}`}\n aria-current={active ? \"page\" : false}\n onMouseOver={closeAllTooltips}\n onFocus={closeAllTooltips}\n >\n {pageIndex}\n </button>\n );\n }\n\n const ellipsisStart =\n activePage + siblingRange > startRange &&\n pageIndex === boundaryRange + 1;\n if (ellipsisStart) {\n return renderStartEllipsis(pageIndex);\n }\n\n const ellipsisEnd =\n activePage - siblingRange <= endRange &&\n pageIndex === totalPages - boundaryRange - 1;\n if (ellipsisEnd) {\n return renderEndEllipsis(pageIndex);\n }\n\n const paginationStart =\n (pageIndex <= startRange &&\n activePage + siblingRange <= startRange) ||\n pageIndex <= boundaryRange;\n const paginationMiddle =\n pageIndex === activePage ||\n (pageIndex <= activePage + siblingRange &&\n pageIndex >= activePage - siblingRange - 1);\n const paginationEnd =\n (pageIndex > endRange &&\n activePage - siblingRange > endRange) ||\n pageIndex > totalPages - boundaryRange;\n if (paginationStart || paginationMiddle || paginationEnd) {\n return (\n <button\n key={pageIndex}\n onClick={() => handlePaginationItemClick(pageIndex)}\n className={clsx(\n styles.pageItem,\n active && styles.pageItemSelected\n )}\n aria-label={`page ${pageIndex} of ${totalPages}`}\n aria-current={active ? \"page\" : false}\n onMouseOver={closeAllTooltips}\n onFocus={closeAllTooltips}\n >\n {pageIndex}\n </button>\n );\n }\n\n return null;\n });\n };\n\n const renderStartEllipsis = (pageIndex: number) => (\n <div key={pageIndex} className={styles.ellipsisContainer}>\n <ClickableIcon\n className={styles.iconButton}\n focusHighlight={false}\n focusOutline=\"browser\"\n aria-label={\"Previous 5 pages\"}\n onMouseEnter={onHoverLeftButton}\n onMouseLeave={onBlurLeftButton}\n onFocus={onHoverLeftButton}\n onBlur={onBlurLeftButton}\n onClick={handleFastBackwardClick}\n >\n {hoverLeftButton ? (\n <Chevron2LeftIcon aria-hidden />\n ) : (\n <EllipsisHorizontalIcon aria-hidden />\n )}\n </ClickableIcon>\n {hoverLeftButton && (\n <div className={styles.hover}>Previous 5 pages</div>\n )}\n </div>\n );\n\n const renderEndEllipsis = (pageIndex: number) => (\n <div key={pageIndex} className={styles.ellipsisContainer}>\n <ClickableIcon\n className={styles.iconButton}\n focusHighlight={false}\n focusOutline=\"browser\"\n aria-label={\"Next 5 pages\"}\n onMouseEnter={onHoverRightButton}\n onMouseLeave={onBlurRightButton}\n onFocus={onHoverRightButton}\n onBlur={onBlurRightButton}\n onClick={handleFastForwardClick}\n >\n {hoverRightButton ? (\n <Chevron2RightIcon aria-hidden />\n ) : (\n <EllipsisHorizontalIcon aria-hidden />\n )}\n </ClickableIcon>\n {hoverRightButton && (\n <div className={styles.hover}>Next 5 pages</div>\n )}\n </div>\n );\n\n const renderMobile = () => (\n <div className={styles.paginationMobileInput}>\n <form onSubmit={handleInputSubmit}>\n <Input\n className={styles.inputView}\n value={inputText}\n onChange={handleInput}\n autoComplete=\"off\"\n type=\"numeric\"\n id={(id || \"pagination\") + \"-input\"}\n data-testid={(dataTestId || \"pagination\") + \"-input\"}\n aria-label={`Page ${activePage} of ${totalPages}`}\n />\n </form>\n <Typography.BodyBL className={styles.labelDivider}>\n /\n </Typography.BodyBL>\n <Typography.BodyBL className={styles.label}>\n {totalPages}\n </Typography.BodyBL>\n </div>\n );\n\n return (\n <nav\n className={clsx(styles.paginationWrapper, className)}\n ref={ref}\n id={id || \"pagination-wrapper\"}\n data-testid={dataTestId || \"pagination\"}\n aria-labelledby={paginationId}\n >\n <VisuallyHidden id={paginationId} aria-hidden>\n pagination\n </VisuallyHidden>\n <div className={styles.paginationList}>\n <div className={styles.paginationMenu}>\n {showFirstAndLastNav && (\n <ClickableIcon\n className={clsx(\n styles.iconButton,\n styles.iconButtonNavigation\n )}\n onClick={firstPaginationItem}\n disabled={isFirstPage}\n focusHighlight={false}\n aria-label=\"First page\"\n focusOutline=\"browser\"\n >\n <ChevronLineLeftIcon aria-hidden />\n </ClickableIcon>\n )}\n <ClickableIcon\n className={clsx(\n styles.iconButton,\n styles.iconButtonNavigation\n )}\n onClick={prevPaginationItem}\n disabled={isFirstPage}\n focusHighlight={false}\n aria-label=\"Previous page\"\n focusOutline=\"browser\"\n >\n <ChevronLeftIcon aria-hidden />\n </ClickableIcon>\n {isMounted && isMobile\n ? renderMobile()\n : renderPaginationItems()}\n <ClickableIcon\n className={clsx(\n styles.iconButton,\n styles.iconButtonNavigation\n )}\n onClick={nextPaginationItem}\n disabled={isLastPage}\n focusHighlight={false}\n aria-label=\"Next page\"\n focusOutline=\"browser\"\n >\n <ChevronRightIcon aria-hidden />\n </ClickableIcon>\n {showFirstAndLastNav && (\n <ClickableIcon\n className={clsx(\n styles.iconButton,\n styles.iconButtonNavigation\n )}\n onClick={lastPaginationItem}\n disabled={isLastPage}\n focusHighlight={false}\n aria-label=\"Last page\"\n focusOutline=\"browser\"\n >\n <ChevronLineRightIcon aria-hidden />\n </ClickableIcon>\n )}\n </div>\n </div>\n {showPageSizeChanger && !isMobile && (\n <div className={styles.inputSelectWrapper}>\n <VisuallyHidden id={`${paginationId}-page-size`}>\n Items per page\n </VisuallyHidden>\n <InputSelect\n aria-labelledby={`${paginationId}-page-size`}\n options={pageSizeOptions}\n valueExtractor={(item) => item.value}\n listExtractor={(item) => item.label}\n displayValueExtractor={(item) => item.label}\n selectedOption={selectedOption}\n onSelectOption={handleListItemClick}\n />\n </div>\n )}\n </nav>\n );\n};\n/**\n * A navigation control for moving through paged content.\n *\n * Use `Pagination` to let users navigate between pages of a data set.\n */\nexport const Pagination = React.forwardRef(Component);\n\nconst DEFAULT_OPTIONS: PageSizeItemProps[] = [\n { value: 10, label: \"10 per page\" },\n { value: 20, label: \"20 per page\" },\n { value: 30, label: \"30 per page\" },\n];\n"],"names":["Pagination","React","forwardRef","id","dataTestId","className","pageSize","totalItems","activePage","pageSizeOptions","DEFAULT_OPTIONS","showFirstAndLastNav","showPageSizeChanger","onPageChange","onPageSizeChange","ref","isMounted","useIsMounted","isMobile","useMaxWidthMediaQuery","hoverRightButton","setHoverRightButton","useState","hoverLeftButton","setHoverLeftButton","inputText","setInputText","selectedOption","setSelectedOption","pageSizeLocal","setPageSize","value","paginationId","useId","totalPages","Math","ceil","isFirstPage","isLastPage","firstPaginationItem","handlePaginationItemClick","undefined","lastPaginationItem","prevPaginationItem","nextPaginationItem","parseInt","toString","useEffect","setInputValue","find","option","closeAllTooltips","pageIndex","handleFastForwardClick","currentIndex","min","handleFastBackwardClick","max","handleInput","event","target","length","test","newPage","replace","handleInputSubmit","preventDefault","onHoverRightButton","onBlurRightButton","onHoverLeftButton","onBlurLeftButton","renderStartEllipsis","_jsxs","styles.ellipsisContainer","children","_jsx","ClickableIcon","styles.iconButton","focusHighlight","focusOutline","onMouseEnter","onMouseLeave","onFocus","onBlur","onClick","Chevron2LeftIcon","EllipsisHorizontalIcon","styles.hover","renderEndEllipsis","Chevron2RightIcon","clsx","styles.paginationWrapper","VisuallyHidden","styles.paginationList","styles.paginationMenu","styles.iconButtonNavigation","disabled","ChevronLineLeftIcon","ChevronLeftIcon","styles.paginationMobileInput","onSubmit","Input","styles.inputView","onChange","autoComplete","type","Typography","BodyBL","styles.labelDivider","styles.label","Array","map","e","i","endRange","boundaryRange","active","styles.pageItem","styles.pageItemSelected","onMouseOver","ChevronRightIcon","ChevronLineRightIcon","styles.inputSelectWrapper","InputSelect","options","valueExtractor","item","listExtractor","label","displayValueExtractor","onSelectOption","pagesize","totalPage"],"mappings":"uvDAoBA,MAgaaA,EAAaC,EAAMC,YAhad,EAEVC,KACA,cAAeC,EACfC,YACAC,WAAW,GACXC,aACAC,aACAC,kBAAkBC,EAClBC,sBACAC,uBAAsB,EACtBC,eACAC,oBAEJC,KAMA,MAAMC,EAAYC,IACZC,EAAWC,EAAsB,OAChCC,EAAkBC,GAAuBC,GAAS,IAClDC,EAAiBC,GAAsBF,GAAS,IAChDG,EAAWC,IAAgBJ,EAAiB,KAE5CK,GAAgBC,IAAqBN,EAE1Cb,EAAgB,KACXoB,GAAeC,IAAeR,GAChCJ,GAAYN,GACPe,GACIA,GAAeI,MAEnBzB,GAOJ0B,GAAe,GADFC,iBAGbC,GAAaC,KAAKC,KAAK7B,EAAasB,IACpCQ,GAA6B,IAAf7B,EACd8B,GAAa9B,IAAe0B,GAE5BK,GACF/B,EAAa,EAAI,IAAMgC,GAA0B,QAAKC,EACpDC,GACFlC,EAAa0B,GACP,IAAMM,GAA0BN,SAChCO,EACJE,GACFnC,EAAa,EACP,IAAMgC,GAA0BhC,EAAa,QAC7CiC,EACJG,GACFpC,EAAa0B,GACP,IACIM,GAA0BK,SAASrC,EAAWsC,YAAc,QAChEL,EAKVM,GAAU,KACFvC,GACAwC,GAAcxC,EAClB,GACD,CAACA,IAEJuC,GAAU,KACNjB,GAAYxB,GACZsB,GACInB,EAAgBwC,MAAMC,GAAWA,EAAOnB,QAAUzB,IACrD,GACF,CAACA,IAKJ,MAAM0C,GAAiBjB,IACnBL,GAAaK,EAAMe,WAAW,EAG5BK,GAAmB,KACrB9B,GAAoB,GACpBG,GAAmB,EAAM,EAMvBgB,GAA6BY,IAC3BvC,IACAA,EAAauC,GACbJ,GAAcI,GAClB,EAGEC,GAAyB,KAC3B,MAAMC,EAAenB,KAAKoB,IAAIrB,GAAY1B,EAAa,GACvDgC,GAA0Bc,GAC1BN,GAAcM,GACdjC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,kBACS,GAAG3F,eACpB4F,QAASnH,EACToH,eAAiBC,GAASA,EAAK/F,MAC/BgG,cAAgBD,GAASA,EAAKE,MAC9BC,sBAAwBH,GAASA,EAAKE,MACtCrG,eAAgBA,GAChBuG,eA3PSJ,IACzBlG,GAAkBkG,GAClB,MAAMK,EAAWL,EAAK/F,MAChBqG,EAAYjG,KAAKC,KAAK7B,EAAa4H,GAEzCrG,GAAYqG,GAIRrH,GACAA,EAHSN,GAAc4H,EAAYA,EAAY5H,EAGxB2H,EAC3B,SAoPM,IAURzH,EAAuC,CACzC,CAAEqB,MAAO,GAAIiG,MAAO,eACpB,CAAEjG,MAAO,GAAIiG,MAAO,eACpB,CAAEjG,MAAO,GAAIiG,MAAO"}
@@ -1,16 +1,64 @@
1
+ /**
2
+ * Props for the `Pagination` component.
3
+ */
1
4
  export interface PaginationProps {
2
5
  id?: string | undefined;
3
6
  "data-testid"?: string | undefined;
4
7
  className?: string | undefined;
8
+ /**
9
+ * Number of items displayed per page.
10
+ *
11
+ * @default 10
12
+ */
5
13
  pageSize?: number | undefined;
14
+ /**
15
+ * Total number of items across all pages. Used to compute the total page count.
16
+ */
6
17
  totalItems: number;
18
+ /**
19
+ * The currently active 1-based page number. This is a controlled prop;
20
+ * update it in response to `onPageChange`.
21
+ */
7
22
  activePage: number;
23
+ /**
24
+ * Options listed in the page-size changer dropdown.
25
+ *
26
+ * Only relevant when `showPageSizeChanger` is `true`.
27
+ *
28
+ * @default 10, 20, 30 per page
29
+ */
8
30
  pageSizeOptions?: PageSizeItemProps[] | undefined;
31
+ /**
32
+ * When `true`, renders first-page and last-page navigation buttons
33
+ * alongside the previous/next buttons.
34
+ */
9
35
  showFirstAndLastNav?: boolean | undefined;
36
+ /**
37
+ * When `true`, renders a dropdown on desktop viewports to change the `pageSize`.
38
+ *
39
+ * @default false
40
+ */
10
41
  showPageSizeChanger?: boolean | undefined;
42
+ /**
43
+ * Called when the user navigates to a different page.
44
+ *
45
+ * @param page The 1-based index of the newly selected page.
46
+ */
11
47
  onPageChange?: ((page: number) => void) | undefined;
48
+ /**
49
+ * Called when the user selects a different page size from
50
+ * the dropdown and `showPageSizeChanger` is `true`.
51
+ *
52
+ * @param page The adjusted active page after the size change. If the current
53
+ * `activePage` exceeds the new total page count, this value is capped to the
54
+ * new last page.
55
+ * @param pageSize The newly selected number of items per page.
56
+ */
12
57
  onPageSizeChange?: ((page: number, pageSize: number) => void) | undefined;
13
58
  }
59
+ /**
60
+ * A single option in the page-size changer dropdown.
61
+ */
14
62
  export interface PageSizeItemProps {
15
63
  value: number;
16
64
  label: string;
@@ -1,2 +1,9 @@
1
1
  import type { PhoneNumberInputProps } from "./types";
2
+ /**
3
+ * A phone number field composed of a country code selector and a number input.
4
+ *
5
+ * Use `PhoneNumberInput` when collecting an internationalised phone number.
6
+ * The country code can be selected from a searchable dropdown or locked to a
7
+ * fixed value via `fixedCountry`.
8
+ */
2
9
  export declare const PhoneNumberInput: ({ id, onChange, value, allowClear, onClear, onBlur, error, fixedCountry, optionPlaceholder, optionSearchPlaceholder, enableSearch, onHideOptions, onShowOptions, placeholder, autoComplete, noBorder, getAriaLabel, ...otherProps }: PhoneNumberInputProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"phone-number-input.js","sources":["../../src/phone-number-input/phone-number-input.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\n\nimport { InputGroup } from \"../input-group/input-group\";\nimport type { AddonProps, LabelAddon, ListAddon } from \"../input-group/types\";\nimport { useNextInputState } from \"../util\";\nimport { PhoneNumberInputHelper } from \"./phone-number-input-helper\";\nimport type { CountryValue, PhoneNumberInputProps } from \"./types\";\n\nexport const PhoneNumberInput = ({\n id,\n onChange,\n value,\n allowClear,\n onClear,\n onBlur,\n error,\n fixedCountry = false,\n optionPlaceholder = \"Select\",\n optionSearchPlaceholder,\n enableSearch,\n onHideOptions,\n onShowOptions,\n placeholder,\n autoComplete,\n noBorder = false,\n getAriaLabel,\n ...otherProps\n}: PhoneNumberInputProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const [options] = useState<CountryValue[]>(\n PhoneNumberInputHelper.getCountries()\n );\n\n const [selectedCountry, setSelectedCountry] = useState<\n CountryValue | undefined\n >(undefined);\n const [inputValue, setInputValue] = useState<string>(\"\");\n\n const nodeRef = useRef<HTMLInputElement>(null);\n\n const getNextInputState = useNextInputState({\n ref: nodeRef,\n formatter: (value) =>\n PhoneNumberInputHelper.formatNumber(\n value.replace(/[^0-9]/g, \"\"),\n selectedCountry\n ),\n });\n\n const resolvedAriaLabel =\n getAriaLabel?.(selectedCountry) ?? \"Enter phone number\";\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n const selectedOption = options.filter(\n (country) =>\n country.countryCode === normaliseCountryCode(value?.countryCode)\n )[0];\n\n setSelectedCountry(selectedOption);\n setInputValue(\n PhoneNumberInputHelper.formatNumber(value?.number, selectedOption)\n );\n }, [value]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleClear = () => {\n if (onClear) {\n onClear();\n } else {\n setInputValue(\"\");\n }\n };\n\n const handleInputChange = () => {\n const nextState = getNextInputState();\n if (!nextState) return;\n\n const { nextValue, updateCaretPosition } = nextState;\n\n updateCaretPosition();\n performLocalChangeHandler(nextValue, selectedCountry);\n if (onChange) {\n performOnChangeHandler(nextValue, selectedCountry);\n }\n };\n\n const handleSelectOption = (country: CountryValue) => {\n performLocalChangeHandler(inputValue, country);\n if (onChange) {\n performOnChangeHandler(inputValue, country);\n }\n };\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n const performOnChangeHandler = (\n inputValue: string,\n selectedCountry: CountryValue | undefined\n ) => {\n const formatedInputValue = PhoneNumberInputHelper.formatNumber(\n inputValue,\n selectedCountry\n );\n onChange?.({\n number: formatedInputValue.replace(/[\\s()]+/g, \"\"), // strip formatted spaces\n countryCode:\n selectedCountry && addPlusPrefix(selectedCountry.countryCode),\n });\n };\n\n const performLocalChangeHandler = (\n inputValue: string,\n selectedCountry: CountryValue | undefined\n ) => {\n setInputValue(\n PhoneNumberInputHelper.formatNumber(inputValue, selectedCountry)\n );\n\n setSelectedCountry(selectedCountry);\n };\n\n const getAddonProps = (): AddonProps<CountryValue, string> => {\n if (fixedCountry) {\n return {\n type: \"label\",\n attributes: {\n value: addPlusPrefix(selectedCountry?.countryCode),\n } as LabelAddon,\n };\n } else {\n return {\n type: \"list\",\n attributes: {\n \"aria-label\": \"Country code\",\n placeholder: optionPlaceholder,\n options,\n selectedOption: selectedCountry,\n enableSearch: enableSearch,\n searchPlaceholder: optionSearchPlaceholder,\n valueExtractor: (option) => `+${option.countryCode}`,\n listExtractor: (option) => ({\n title: option.name,\n secondaryLabel: addPlusPrefix(option.countryCode),\n }),\n onSelectOption: handleSelectOption,\n onHideOptions: onHideOptions,\n onShowOptions: onShowOptions,\n } as ListAddon<CountryValue, string>,\n };\n }\n };\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n return (\n <InputGroup\n id={id}\n ref={nodeRef}\n value={inputValue}\n onChange={handleInputChange}\n allowClear={allowClear && !!inputValue}\n onClear={handleClear}\n onBlur={onBlur}\n error={error}\n placeholder={placeholder}\n addon={getAddonProps()}\n inputMode=\"numeric\"\n autoComplete={autoComplete}\n noBorder={noBorder}\n aria-label={resolvedAriaLabel}\n {...otherProps}\n />\n );\n};\n\n// =============================================================================\n// HELPER FUNCTIONS\n// =============================================================================\n/**\n * This strips the + off the specified country code if it\n * is present.\n */\nconst normaliseCountryCode = (countryCode: string | undefined): string => {\n return countryCode ? countryCode.replace(\"+\", \"\") : \"\";\n};\n\nconst addPlusPrefix = (countryCode?: string): string => {\n if (!countryCode) return \"\";\n return countryCode.includes(\"+\") ? countryCode : `+${countryCode}`;\n};\n"],"names":["PhoneNumberInput","_a","id","onChange","value","allowClear","onClear","onBlur","error","fixedCountry","optionPlaceholder","optionSearchPlaceholder","enableSearch","onHideOptions","onShowOptions","placeholder","autoComplete","noBorder","getAriaLabel","otherProps","__rest","options","useState","PhoneNumberInputHelper","getCountries","selectedCountry","setSelectedCountry","undefined","inputValue","setInputValue","nodeRef","useRef","getNextInputState","useNextInputState","ref","formatter","formatNumber","replace","resolvedAriaLabel","_b","useEffect","selectedOption","filter","country","countryCode","normaliseCountryCode","number","handleSelectOption","performLocalChangeHandler","performOnChangeHandler","formatedInputValue","addPlusPrefix","_jsx","InputGroup","Object","assign","nextState","nextValue","updateCaretPosition","addon","type","attributes","searchPlaceholder","valueExtractor","option","listExtractor","title","name","secondaryLabel","onSelectOption","inputMode","includes"],"mappings":"+gBAQO,MAAMA,EAAoBC,WAAAC,GAC7BA,EAAEC,SACFA,EAAQC,MACRA,EAAKC,WACLA,EAAUC,QACVA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,aACLA,GAAe,EAAKC,kBACpBA,EAAoB,SAAQC,wBAC5BA,EAAuBC,aACvBA,EAAYC,cACZA,EAAaC,cACbA,EAAaC,YACbA,EAAWC,aACXA,EAAYC,SACZA,GAAW,EAAKC,aAChBA,GAAYjB,EACTkB,EAAUC,EAAAnB,EAlBgB,sOAuB7B,MAAOoB,GAAWC,EACdC,EAAuBC,iBAGpBC,EAAiBC,GAAsBJ,OAE5CK,IACKC,EAAYC,GAAiBP,EAAiB,IAE/CQ,EAAUC,EAAyB,MAEnCC,EAAoBC,EAAkB,CACxCC,IAAKJ,EACLK,UAAY/B,GACRmB,EAAuBa,aACnBhC,EAAMiC,QAAQ,UAAW,IACzBZ,KAINa,EAC6B,QAA/BC,EAAArB,aAAY,EAAZA,EAAeO,UAAgB,IAAAc,EAAAA,EAAI,qBAKvCC,GAAU,KACN,MAAMC,EAAiBpB,EAAQqB,QAC1BC,GACGA,EAAQC,cAAgBC,EAAqBzC,aAAK,EAALA,EAAOwC,eAC1D,GAEFlB,EAAmBe,GACnBZ,EACIN,EAAuBa,aAAahC,aAAK,EAALA,EAAO0C,OAAQL,GACtD,GACF,CAACrC,IAKJ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M,GAGlDc,EAAiBP,GACdA,EACEA,EAAY2B,SAAS,KAAO3B,EAAc,IAAIA,IAD5B"}
1
+ {"version":3,"file":"phone-number-input.js","sources":["../../src/phone-number-input/phone-number-input.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\n\nimport { InputGroup } from \"../input-group/input-group\";\nimport type { AddonProps, LabelAddon, ListAddon } from \"../input-group/types\";\nimport { useNextInputState } from \"../util\";\nimport { PhoneNumberInputHelper } from \"./phone-number-input-helper\";\nimport type { CountryValue, PhoneNumberInputProps } from \"./types\";\n\n/**\n * A phone number field composed of a country code selector and a number input.\n *\n * Use `PhoneNumberInput` when collecting an internationalised phone number.\n * The country code can be selected from a searchable dropdown or locked to a\n * fixed value via `fixedCountry`.\n */\nexport const PhoneNumberInput = ({\n id,\n onChange,\n value,\n allowClear,\n onClear,\n onBlur,\n error,\n fixedCountry = false,\n optionPlaceholder = \"Select\",\n optionSearchPlaceholder,\n enableSearch,\n onHideOptions,\n onShowOptions,\n placeholder,\n autoComplete,\n noBorder = false,\n getAriaLabel,\n ...otherProps\n}: PhoneNumberInputProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const [options] = useState<CountryValue[]>(\n PhoneNumberInputHelper.getCountries()\n );\n\n const [selectedCountry, setSelectedCountry] = useState<\n CountryValue | undefined\n >(undefined);\n const [inputValue, setInputValue] = useState<string>(\"\");\n\n const nodeRef = useRef<HTMLInputElement>(null);\n\n const getNextInputState = useNextInputState({\n ref: nodeRef,\n formatter: (value) =>\n PhoneNumberInputHelper.formatNumber(\n value.replace(/[^0-9]/g, \"\"),\n selectedCountry\n ),\n });\n\n const resolvedAriaLabel =\n getAriaLabel?.(selectedCountry) ?? \"Enter phone number\";\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n const selectedOption = options.filter(\n (country) =>\n country.countryCode === normaliseCountryCode(value?.countryCode)\n )[0];\n\n setSelectedCountry(selectedOption);\n setInputValue(\n PhoneNumberInputHelper.formatNumber(value?.number, selectedOption)\n );\n }, [value]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleClear = () => {\n if (onClear) {\n onClear();\n } else {\n setInputValue(\"\");\n }\n };\n\n const handleInputChange = () => {\n const nextState = getNextInputState();\n if (!nextState) return;\n\n const { nextValue, updateCaretPosition } = nextState;\n\n updateCaretPosition();\n performLocalChangeHandler(nextValue, selectedCountry);\n if (onChange) {\n performOnChangeHandler(nextValue, selectedCountry);\n }\n };\n\n const handleSelectOption = (country: CountryValue) => {\n performLocalChangeHandler(inputValue, country);\n if (onChange) {\n performOnChangeHandler(inputValue, country);\n }\n };\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n const performOnChangeHandler = (\n inputValue: string,\n selectedCountry: CountryValue | undefined\n ) => {\n const formatedInputValue = PhoneNumberInputHelper.formatNumber(\n inputValue,\n selectedCountry\n );\n onChange?.({\n number: formatedInputValue.replace(/[\\s()]+/g, \"\"), // strip formatted spaces\n countryCode:\n selectedCountry && addPlusPrefix(selectedCountry.countryCode),\n });\n };\n\n const performLocalChangeHandler = (\n inputValue: string,\n selectedCountry: CountryValue | undefined\n ) => {\n setInputValue(\n PhoneNumberInputHelper.formatNumber(inputValue, selectedCountry)\n );\n\n setSelectedCountry(selectedCountry);\n };\n\n const getAddonProps = (): AddonProps<CountryValue, string> => {\n if (fixedCountry) {\n return {\n type: \"label\",\n attributes: {\n value: addPlusPrefix(selectedCountry?.countryCode),\n } as LabelAddon,\n };\n } else {\n return {\n type: \"list\",\n attributes: {\n \"aria-label\": \"Country code\",\n placeholder: optionPlaceholder,\n options,\n selectedOption: selectedCountry,\n enableSearch: enableSearch,\n searchPlaceholder: optionSearchPlaceholder,\n valueExtractor: (option) => `+${option.countryCode}`,\n listExtractor: (option) => ({\n title: option.name,\n secondaryLabel: addPlusPrefix(option.countryCode),\n }),\n onSelectOption: handleSelectOption,\n onHideOptions: onHideOptions,\n onShowOptions: onShowOptions,\n } as ListAddon<CountryValue, string>,\n };\n }\n };\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n return (\n <InputGroup\n id={id}\n ref={nodeRef}\n value={inputValue}\n onChange={handleInputChange}\n allowClear={allowClear && !!inputValue}\n onClear={handleClear}\n onBlur={onBlur}\n error={error}\n placeholder={placeholder}\n addon={getAddonProps()}\n inputMode=\"numeric\"\n autoComplete={autoComplete}\n noBorder={noBorder}\n aria-label={resolvedAriaLabel}\n {...otherProps}\n />\n );\n};\n\n// =============================================================================\n// HELPER FUNCTIONS\n// =============================================================================\n/**\n * This strips the + off the specified country code if it\n * is present.\n */\nconst normaliseCountryCode = (countryCode: string | undefined): string => {\n return countryCode ? countryCode.replace(\"+\", \"\") : \"\";\n};\n\nconst addPlusPrefix = (countryCode?: string): string => {\n if (!countryCode) return \"\";\n return countryCode.includes(\"+\") ? countryCode : `+${countryCode}`;\n};\n"],"names":["PhoneNumberInput","_a","id","onChange","value","allowClear","onClear","onBlur","error","fixedCountry","optionPlaceholder","optionSearchPlaceholder","enableSearch","onHideOptions","onShowOptions","placeholder","autoComplete","noBorder","getAriaLabel","otherProps","__rest","options","useState","PhoneNumberInputHelper","getCountries","selectedCountry","setSelectedCountry","undefined","inputValue","setInputValue","nodeRef","useRef","getNextInputState","useNextInputState","ref","formatter","formatNumber","replace","resolvedAriaLabel","_b","useEffect","selectedOption","filter","country","countryCode","normaliseCountryCode","number","handleSelectOption","performLocalChangeHandler","performOnChangeHandler","formatedInputValue","addPlusPrefix","_jsx","InputGroup","Object","assign","nextState","nextValue","updateCaretPosition","addon","type","attributes","searchPlaceholder","valueExtractor","option","listExtractor","title","name","secondaryLabel","onSelectOption","inputMode","includes"],"mappings":"+gBAeO,MAAMA,EAAoBC,WAAAC,GAC7BA,EAAEC,SACFA,EAAQC,MACRA,EAAKC,WACLA,EAAUC,QACVA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,aACLA,GAAe,EAAKC,kBACpBA,EAAoB,SAAQC,wBAC5BA,EAAu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,EAAWhC,GACjCtB,GACA8C,EAAuBQ,EAAWhC,EACtC,EA+EIpB,WAAYA,KAAgBuB,EAC5BtB,QAlGY,KACZA,EACAA,IAEAuB,EAAc,GAClB,EA8FItB,OAAQA,EACRC,MAAOA,EACPO,YAAaA,EACb4C,MA5CAlD,EACO,CACHmD,KAAM,QACNC,WAAY,CACRzD,MAAO+C,EAAc1B,aAAe,EAAfA,EAAiBmB,eAIvC,CACHgB,KAAM,OACNC,WAAY,CACR,aAAc,eACd9C,YAAaL,EACbW,UACAoB,eAAgBhB,EAChBb,aAAcA,EACdkD,kBAAmBnD,EACnBoD,eAAiBC,GAAW,IAAIA,EAAOpB,cACvCqB,cAAgBD,IAAM,CAClBE,MAAOF,EAAOG,KACdC,eAAgBjB,EAAca,EAAOpB,eAEzCyB,eAAgBtB,EAChBlC,cAAeA,EACfC,cAAeA,IAqBvBwD,UAAU,UACVtD,aAAcA,EACdC,SAAUA,EAAQ,aACNqB,GACRnB,GACN,EAWJ0B,EAAwBD,GACnBA,EAAcA,EAAYP,QAAQ,IAAK,IAAM,GAGlDc,EAAiBP,GACdA,EACEA,EAAY2B,SAAS,KAAO3B,EAAc,IAAIA,IAD5B"}
@@ -1,47 +1,107 @@
1
1
  import type React from "react";
2
+ /**
3
+ * Represents a selectable country entry in the phone number country code dropdown.
4
+ */
2
5
  export interface CountryValue {
6
+ /** The country name. */
3
7
  name: string;
8
+ /** The country region. */
4
9
  regions: string[];
10
+ /**
11
+ * ISO 3166-1 alpha-2 country code.
12
+ */
5
13
  iso2: string;
14
+ /**
15
+ * Calling code for the country, without the leading `+`.
16
+ */
6
17
  countryCode: string;
18
+ /**
19
+ * Phone number format mask applied to the phone number field.
20
+ */
7
21
  format: string;
8
22
  }
23
+ /**
24
+ * Value shape for `PhoneNumberInput`, representing the selected country code
25
+ * and the phone number separately.
26
+ */
9
27
  export interface PhoneNumberInputValue {
10
28
  /**
11
- * You may choose to specify with or without the +. The return value
12
- * will always contain the +
29
+ * Country calling code. May be supplied with or without a leading `+`;
13
30
  */
14
31
  countryCode?: string | undefined;
32
+ /**
33
+ * The phone number number, without the country code prefix.
34
+ */
15
35
  number?: string | undefined;
16
36
  }
37
+ /**
38
+ * Props for the `PhoneNumberInput` component.
39
+ */
17
40
  export interface PhoneNumberInputProps extends React.AriaAttributes {
18
- /** The value of the input */
41
+ /**
42
+ * Controlled value containing the selected country code and phone number.
43
+ */
19
44
  value?: PhoneNumberInputValue | undefined;
45
+ /**
46
+ * Renders the input in an error state when `true`.
47
+ */
20
48
  error?: boolean | undefined;
21
- /** Specifies if the clear button should be present in the input */
49
+ /**
50
+ * Shows a clear button inside the input when `true` and the field has a value.
51
+ */
22
52
  allowClear?: boolean | undefined;
23
53
  "data-testid"?: string | undefined;
24
54
  className?: string | undefined;
55
+ /**
56
+ * Removes the visible border from the input group when `true`.
57
+ *
58
+ * @default false
59
+ */
25
60
  noBorder?: boolean | undefined;
26
61
  /**
27
- * Specifies if the country code is a fixed value and the user
28
- * cannot select another option
62
+ * When `true`, the country code is displayed as a static label and the
63
+ * user cannot change it. When `false`, a searchable dropdown is rendered.
64
+ *
65
+ * @default false
29
66
  */
30
67
  fixedCountry?: boolean | undefined;
68
+ /**
69
+ * Called whenever the country or phone number changes.
70
+ *
71
+ * @param value Updated phone number value including the leading `+`.
72
+ */
31
73
  onChange?: ((value: PhoneNumberInputValue) => void) | undefined;
32
- /** Called when the clear button in the input field is clicked */
74
+ /**
75
+ * Called when the clear button is activated.
76
+ */
33
77
  onClear?: () => void | undefined;
34
- /** Called when a defocus happens */
78
+ /**
79
+ * Called when the input loses focus.
80
+ */
35
81
  onBlur?: (() => void) | undefined;
36
- /** The placeholder value for the dropdown selector */
82
+ /**
83
+ * Placeholder text shown in the country code dropdown when no country is
84
+ * selected.
85
+ *
86
+ * @default "Select"
87
+ */
37
88
  optionPlaceholder?: string | undefined;
38
- /** The placeholder value for the dropdown search */
89
+ /**
90
+ * Placeholder text shown inside the search field of the country code
91
+ * dropdown. Only relevant when `enableSearch` is `true`.
92
+ */
39
93
  optionSearchPlaceholder?: string | undefined;
40
- /** Specifies if search is enabled in the dropdown */
94
+ /**
95
+ * Enables a search field inside the country code dropdown.
96
+ */
41
97
  enableSearch?: boolean | undefined;
42
- /** Called when the dropdown is dismissed */
98
+ /**
99
+ * Called when the country code dropdown closes.
100
+ */
43
101
  onHideOptions?: (() => void) | undefined;
44
- /** Called when the dropdown is visible */
102
+ /**
103
+ * Called when the country code dropdown opens.
104
+ */
45
105
  onShowOptions?: (() => void) | undefined;
46
106
  disabled?: boolean | undefined;
47
107
  name?: string | undefined;
@@ -50,5 +110,10 @@ export interface PhoneNumberInputProps extends React.AriaAttributes {
50
110
  readOnly?: boolean | undefined;
51
111
  id?: string | undefined;
52
112
  autoComplete?: string | undefined;
113
+ /**
114
+ * Returns the accessible label for the phone number input.
115
+ *
116
+ * @param country Currently selected country, or `undefined`.
117
+ */
53
118
  getAriaLabel?: ((country?: CountryValue) => string) | undefined;
54
119
  }
package/pill/pill.d.ts CHANGED
@@ -1,2 +1,8 @@
1
1
  import type { PillProps } from "./types";
2
+ /**
3
+ * A compact label used to display status, category, or metadata.
4
+ *
5
+ * Use `Pill` to surface short, read-only information — such as a tag or status
6
+ * badge — inline with other content.
7
+ */
2
8
  export declare const Pill: ({ type, colorType, children, icon, className, ...otherProps }: PillProps) => JSX.Element;
package/pill/pill.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pill.js","sources":["../../src/pill/pill.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\n\nimport * as styles from \"./pill.styles\";\nimport type { PillColorType, PillProps, PillType } from \"./types\";\n\nconst WRAPPER_CLASS: Record<PillType, Record<PillColorType, string>> = {\n solid: {\n black: styles.wrapperSolidBlack,\n grey: styles.wrapperSolidGrey,\n green: styles.wrapperSolidGreen,\n yellow: styles.wrapperSolidYellow,\n red: styles.wrapperSolidRed,\n blue: styles.wrapperSolidBlue,\n primary: styles.wrapperSolidPrimary,\n },\n outline: {\n black: styles.wrapperOutlineBlack,\n grey: styles.wrapperOutlineGrey,\n green: styles.wrapperOutlineGreen,\n yellow: styles.wrapperOutlineYellow,\n red: styles.wrapperOutlineRed,\n blue: styles.wrapperOutlineBlue,\n primary: styles.wrapperOutlinePrimary,\n },\n};\n\nexport const Pill = ({\n type,\n colorType = \"black\",\n children,\n icon,\n className,\n ...otherProps\n}: PillProps): JSX.Element => {\n return (\n <div\n {...otherProps}\n className={clsx(\n styles.wrapperBase,\n type === \"solid\" && styles.wrapperSolid,\n WRAPPER_CLASS[type][colorType],\n className\n )}\n >\n {icon && React.cloneElement(icon, { \"aria-hidden\": true })}\n <div className={styles.label}>{children}</div>\n </div>\n );\n};\n"],"names":["WRAPPER_CLASS","solid","black","styles.wrapperSolidBlack","grey","styles.wrapperSolidGrey","green","styles.wrapperSolidGreen","yellow","styles.wrapperSolidYellow","red","styles.wrapperSolidRed","blue","styles.wrapperSolidBlue","primary","styles.wrapperSolidPrimary","outline","styles.wrapperOutlineBlack","styles.wrapperOutlineGrey","styles.wrapperOutlineGreen","styles.wrapperOutlineYellow","styles.wrapperOutlineRed","styles.wrapperOutlineBlue","styles.wrapperOutlinePrimary","Pill","_a","type","colorType","children","icon","className","otherProps","__rest","_jsxs","Object","assign","clsx","styles.wrapperBase","styles.wrapperSolid","React","cloneElement","_jsx","styles.label"],"mappings":"oiBAMA,MAAMA,EAAiE,CACnEC,MAAO,CACHC,MAAOC,EACPC,KAAMC,EACNC,MAAOC,EACPC,OAAQC,EACRC,IAAKC,EACLC,KAAMC,EACNC,QAASC,GAEbC,QAAS,CACLd,MAAOe,EACPb,KAAMc,EACNZ,MAAOa,EACPX,OAAQY,EACRV,IAAKW,EACLT,KAAMU,EACNR,QAASS,IAIJC,EAAQC,IAAA,IAAAC,KACjBA,EAAIC,UACJA,EAAY,QAAOC,SACnBA,EAAQC,KACRA,EAAIC,UACJA,GAASL,EACNM,EAAUC,EAAAP,EANI,oDAQjB,OACIQ,EAAA,MAAAC,OAAAC,OAAA,GACQJ,EAAU,CACdD,UAAWM,EACPC,EACS,UAATX,GAAoBY,EACpBtC,EAAc0B,GAAMC,GACpBG,GACHF,SAAA,CAEAC,GAAQU,EAAMC,aAAaX,EAAM,CAAE,eAAe,IACnDY,EAAA,MAAA,CAAKX,UAAWY,EAAYd,SAAGA,OAC7B"}
1
+ {"version":3,"file":"pill.js","sources":["../../src/pill/pill.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\n\nimport * as styles from \"./pill.styles\";\nimport type { PillColorType, PillProps, PillType } from \"./types\";\n\nconst WRAPPER_CLASS: Record<PillType, Record<PillColorType, string>> = {\n solid: {\n black: styles.wrapperSolidBlack,\n grey: styles.wrapperSolidGrey,\n green: styles.wrapperSolidGreen,\n yellow: styles.wrapperSolidYellow,\n red: styles.wrapperSolidRed,\n blue: styles.wrapperSolidBlue,\n primary: styles.wrapperSolidPrimary,\n },\n outline: {\n black: styles.wrapperOutlineBlack,\n grey: styles.wrapperOutlineGrey,\n green: styles.wrapperOutlineGreen,\n yellow: styles.wrapperOutlineYellow,\n red: styles.wrapperOutlineRed,\n blue: styles.wrapperOutlineBlue,\n primary: styles.wrapperOutlinePrimary,\n },\n};\n\n/**\n * A compact label used to display status, category, or metadata.\n *\n * Use `Pill` to surface short, read-only information — such as a tag or status\n * badge — inline with other content.\n */\nexport const Pill = ({\n type,\n colorType = \"black\",\n children,\n icon,\n className,\n ...otherProps\n}: PillProps): JSX.Element => {\n return (\n <div\n {...otherProps}\n className={clsx(\n styles.wrapperBase,\n type === \"solid\" && styles.wrapperSolid,\n WRAPPER_CLASS[type][colorType],\n className\n )}\n >\n {icon && React.cloneElement(icon, { \"aria-hidden\": true })}\n <div className={styles.label}>{children}</div>\n </div>\n );\n};\n"],"names":["WRAPPER_CLASS","solid","black","styles.wrapperSolidBlack","grey","styles.wrapperSolidGrey","green","styles.wrapperSolidGreen","yellow","styles.wrapperSolidYellow","red","styles.wrapperSolidRed","blue","styles.wrapperSolidBlue","primary","styles.wrapperSolidPrimary","outline","styles.wrapperOutlineBlack","styles.wrapperOutlineGrey","styles.wrapperOutlineGreen","styles.wrapperOutlineYellow","styles.wrapperOutlineRed","styles.wrapperOutlineBlue","styles.wrapperOutlinePrimary","Pill","_a","type","colorType","children","icon","className","otherProps","__rest","_jsxs","Object","assign","clsx","styles.wrapperBase","styles.wrapperSolid","React","cloneElement","_jsx","styles.label"],"mappings":"oiBAMA,MAAMA,EAAiE,CACnEC,MAAO,CACHC,MAAOC,EACPC,KAAMC,EACNC,MAAOC,EACPC,OAAQC,EACRC,IAAKC,EACLC,KAAMC,EACNC,QAASC,GAEbC,QAAS,CACLd,MAAOe,EACPb,KAAMc,EACNZ,MAAOa,EACPX,OAAQY,EACRV,IAAKW,EACLT,KAAMU,EACNR,QAASS,IAUJC,EAAQC,IAAA,IAAAC,KACjBA,EAAIC,UACJA,EAAY,QAAOC,SACnBA,EAAQC,KACRA,EAAIC,UACJA,GAASL,EACNM,EAAUC,EAAAP,EANI,oDAQjB,OACIQ,EAAA,MAAAC,OAAAC,OAAA,GACQJ,EAAU,CACdD,UAAWM,EACPC,EACS,UAATX,GAAoBY,EACpBtC,EAAc0B,GAAMC,GACpBG,GACHF,SAAA,CAEAC,GAAQU,EAAMC,aAAaX,EAAM,CAAE,eAAe,IACnDY,EAAA,MAAA,CAAKX,UAAWY,EAAYd,SAAGA,OAC7B"}
package/pill/types.d.ts CHANGED
@@ -1,8 +1,27 @@
1
1
  import type React from "react";
2
+ /**
3
+ * Visual style variant for `Pill`.
4
+ *
5
+ * - `"solid"` renders a filled background.
6
+ * - `"outline"` renders a border-only style.
7
+ */
2
8
  export type PillType = "outline" | "solid";
9
+ /** Color theme for `Pill`. */
3
10
  export type PillColorType = "black" | "grey" | "green" | "yellow" | "red" | "blue" | "primary";
11
+ /**
12
+ * Props for the `Pill` component.
13
+ */
4
14
  export interface PillProps extends React.HTMLAttributes<HTMLDivElement> {
15
+ /** Visual style variant for the pill. */
5
16
  type: PillType;
17
+ /**
18
+ * Color theme applied to the pill.
19
+ *
20
+ * @default "black"
21
+ */
6
22
  colorType?: PillColorType | undefined;
23
+ /**
24
+ * Icon rendered before the label text.
25
+ */
7
26
  icon?: JSX.Element | undefined;
8
27
  }