@lifesg/react-design-system 4.0.0-alpha.11 → 4.0.0-alpha.13

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 (288) hide show
  1. package/breadcrumb/breadcrumb.js +1 -1
  2. package/breadcrumb/breadcrumb.js.map +1 -1
  3. package/breadcrumb/breadcrumb.styles.d.ts +0 -8
  4. package/breadcrumb/breadcrumb.styles.js +1 -1
  5. package/breadcrumb/breadcrumb.styles.js.map +1 -1
  6. package/breadcrumb/breadcrumb.styles_1blzn8n.css +7 -0
  7. package/breadcrumb/types.d.ts +2 -13
  8. package/cjs/breadcrumb/breadcrumb.js +1 -1
  9. package/cjs/breadcrumb/breadcrumb.js.map +1 -1
  10. package/cjs/breadcrumb/breadcrumb.styles.js +1 -1
  11. package/cjs/breadcrumb/breadcrumb.styles.js.map +1 -1
  12. package/cjs/breadcrumb/breadcrumb.styles_1blzn8n.css +7 -0
  13. package/cjs/drawer/drawer.js +1 -1
  14. package/cjs/drawer/drawer.js.map +1 -1
  15. package/cjs/drawer/drawer.styles.js +1 -1
  16. package/cjs/drawer/drawer.styles.js.map +1 -1
  17. package/{drawer/drawer.styles_94hx3y.css → cjs/drawer/drawer.styles_a4bwe0.css} +6 -3
  18. package/cjs/file-download/file-download.js +1 -1
  19. package/cjs/file-download/file-download.js.map +1 -1
  20. package/cjs/file-download/file-list-card/file-list-card.js +1 -1
  21. package/cjs/file-download/file-list-card/file-list-card.js.map +1 -1
  22. package/cjs/file-download/file-list-card/file-list-card.styles.js +1 -1
  23. package/cjs/file-download/file-list-card/file-list-card.styles.js.map +1 -1
  24. package/cjs/file-download/file-list-card/file-list-card.styles_lzbqkk.css +18 -0
  25. package/cjs/file-upload/file-list/file-list.js +1 -1
  26. package/cjs/file-upload/file-list/file-list.js.map +1 -1
  27. package/cjs/file-upload/file-list/file-list.styles.js +1 -1
  28. package/cjs/file-upload/file-list/file-list.styles.js.map +1 -1
  29. package/cjs/file-upload/file-list/file-list.styles_1xbypnh.css +2 -0
  30. package/cjs/file-upload/file-list-item/file-item-actions.js +2 -0
  31. package/cjs/file-upload/file-list-item/file-item-actions.js.map +1 -0
  32. package/cjs/file-upload/file-list-item/file-item-actions.styles.js +2 -0
  33. package/cjs/file-upload/file-list-item/file-item-actions.styles.js.map +1 -0
  34. package/cjs/file-upload/file-list-item/file-item-actions.styles_1quulgy.css +8 -0
  35. package/cjs/file-upload/file-list-item/file-item-details.js +2 -0
  36. package/cjs/file-upload/file-list-item/file-item-details.js.map +1 -0
  37. package/cjs/file-upload/file-list-item/file-item-details.styles.js +2 -0
  38. package/cjs/file-upload/file-list-item/file-item-details.styles.js.map +1 -0
  39. package/cjs/file-upload/file-list-item/file-item-details.styles_1ce9akx.css +7 -0
  40. package/cjs/file-upload/file-list-item/file-list-item.js +1 -1
  41. package/cjs/file-upload/file-list-item/file-list-item.js.map +1 -1
  42. package/cjs/file-upload/file-list-item/file-list-item.styles.js +1 -1
  43. package/cjs/file-upload/file-list-item/file-list-item.styles.js.map +1 -1
  44. package/cjs/file-upload/file-list-item/file-list-item.styles_x3a500.css +10 -0
  45. package/cjs/file-upload/file-list-item/use-truncated-name.js +2 -0
  46. package/cjs/file-upload/file-list-item/use-truncated-name.js.map +1 -0
  47. package/cjs/file-upload/helper.js +1 -1
  48. package/cjs/file-upload/helper.js.map +1 -1
  49. package/cjs/footer/footer-disclaimer-links-data.js +1 -1
  50. package/cjs/footer/footer-disclaimer-links-data.js.map +1 -1
  51. package/cjs/footer/footer.styles.js +1 -1
  52. package/cjs/footer/footer.styles.js.map +1 -1
  53. package/{footer/footer.styles_1msorhc.css → cjs/footer/footer.styles_14hnlcq.css} +4 -4
  54. package/cjs/fullscreen-image-carousel/fullscreen-image-carousel.js +1 -1
  55. package/cjs/fullscreen-image-carousel/fullscreen-image-carousel.js.map +1 -1
  56. package/cjs/index.js +1 -1
  57. package/cjs/local-nav/local-nav-dropdown/local-nav-dropdown.js +1 -1
  58. package/cjs/local-nav/local-nav-dropdown/local-nav-dropdown.js.map +1 -1
  59. package/cjs/local-nav/local-nav-dropdown/local-nav-dropdown.styles.js +1 -1
  60. package/cjs/local-nav/local-nav-dropdown/local-nav-dropdown.styles.js.map +1 -1
  61. package/cjs/local-nav/local-nav-dropdown/{local-nav-dropdown.styles_uhd4xl.css → local-nav-dropdown.styles_kpel1m.css} +9 -6
  62. package/cjs/local-nav/local-nav-menu/local-nav-menu.js +1 -1
  63. package/cjs/local-nav/local-nav-menu/local-nav-menu.js.map +1 -1
  64. package/cjs/local-nav/local-nav-menu/local-nav-menu.styles.js +1 -1
  65. package/cjs/local-nav/local-nav-menu/local-nav-menu.styles.js.map +1 -1
  66. package/cjs/local-nav/local-nav-menu/local-nav-menu.styles_67fcyc.css +8 -0
  67. package/cjs/masthead/sgds-day.css +0 -1
  68. package/cjs/masthead/sgds-night.css +0 -1
  69. package/cjs/menu/menu-content.js +1 -1
  70. package/cjs/menu/menu-content.js.map +1 -1
  71. package/cjs/menu/menu-content.styles.js +1 -1
  72. package/cjs/menu/menu-content.styles.js.map +1 -1
  73. package/cjs/menu/menu-content.styles_1r8oxtk.css +5 -0
  74. package/cjs/menu/menu-item.styles.js +1 -1
  75. package/cjs/menu/menu-item.styles.js.map +1 -1
  76. package/cjs/menu/{menu-item.styles_liyed8.css → menu-item.styles_eut2j9.css} +1 -1
  77. package/cjs/menu/menu-link.styles.js +1 -1
  78. package/cjs/menu/menu-link.styles.js.map +1 -1
  79. package/cjs/menu/menu-link.styles_rng7n7.css +2 -0
  80. package/cjs/menu/menu-section.js +1 -1
  81. package/cjs/menu/menu-section.js.map +1 -1
  82. package/cjs/menu/menu-section.styles.js +1 -1
  83. package/cjs/menu/menu-section.styles.js.map +1 -1
  84. package/cjs/menu/menu-section.styles_1n0ppxl.css +5 -0
  85. package/cjs/navbar/navbar-items.js +1 -1
  86. package/cjs/navbar/navbar-items.js.map +1 -1
  87. package/cjs/navbar/navbar-logo-data.js +1 -1
  88. package/cjs/navbar/navbar-logo-data.js.map +1 -1
  89. package/cjs/notification-banner/notification-banner-hoc.js +1 -1
  90. package/cjs/notification-banner/notification-banner-hoc.js.map +1 -1
  91. package/cjs/pagination/pagination.js +1 -1
  92. package/cjs/pagination/pagination.js.map +1 -1
  93. package/cjs/shared/dropdown-list/dropdown-label.js +1 -1
  94. package/cjs/shared/dropdown-list/dropdown-label.js.map +1 -1
  95. package/cjs/shared/fade-wrapper/fade-wrapper.js +1 -1
  96. package/cjs/shared/fade-wrapper/fade-wrapper.js.map +1 -1
  97. package/cjs/theme/index.js +1 -1
  98. package/cjs/theme/tokens/colour.js +1 -1
  99. package/cjs/theme/tokens/colour.js.map +1 -1
  100. package/cjs/theme/tokens/radius.js +1 -1
  101. package/cjs/theme/tokens/radius.js.map +1 -1
  102. package/cjs/theme/types.js +1 -1
  103. package/cjs/theme/types.js.map +1 -1
  104. package/codemods/run-codemod.js +8 -2
  105. package/codemods/run-codemod.js.map +1 -1
  106. package/codemods/run-codemod.ts +13 -4
  107. package/drawer/drawer.d.ts +1 -1
  108. package/drawer/drawer.js +1 -1
  109. package/drawer/drawer.js.map +1 -1
  110. package/drawer/drawer.styles.d.ts +3 -0
  111. package/drawer/drawer.styles.js +1 -1
  112. package/drawer/drawer.styles.js.map +1 -1
  113. package/{cjs/drawer/drawer.styles_94hx3y.css → drawer/drawer.styles_a4bwe0.css} +6 -3
  114. package/drawer/types.d.ts +7 -0
  115. package/file-download/file-download.d.ts +1 -1
  116. package/file-download/file-download.js +1 -1
  117. package/file-download/file-download.js.map +1 -1
  118. package/file-download/file-list-card/file-list-card.d.ts +1 -1
  119. package/file-download/file-list-card/file-list-card.js +1 -1
  120. package/file-download/file-list-card/file-list-card.js.map +1 -1
  121. package/file-download/file-list-card/file-list-card.styles.d.ts +2 -0
  122. package/file-download/file-list-card/file-list-card.styles.js +1 -1
  123. package/file-download/file-list-card/file-list-card.styles.js.map +1 -1
  124. package/file-download/file-list-card/file-list-card.styles_lzbqkk.css +18 -0
  125. package/file-download/file-list-card/types.d.ts +1 -0
  126. package/file-download/types.d.ts +13 -0
  127. package/file-upload/file-list/file-list.js +1 -1
  128. package/file-upload/file-list/file-list.js.map +1 -1
  129. package/file-upload/file-list/file-list.styles.d.ts +0 -1
  130. package/file-upload/file-list/file-list.styles.js +1 -1
  131. package/file-upload/file-list/file-list.styles.js.map +1 -1
  132. package/file-upload/file-list/file-list.styles_1xbypnh.css +2 -0
  133. package/file-upload/file-list-item/file-item-actions.d.ts +30 -0
  134. package/file-upload/file-list-item/file-item-actions.js +2 -0
  135. package/file-upload/file-list-item/file-item-actions.js.map +1 -0
  136. package/file-upload/file-list-item/file-item-actions.styles.d.ts +6 -0
  137. package/file-upload/file-list-item/file-item-actions.styles.js +2 -0
  138. package/file-upload/file-list-item/file-item-actions.styles.js.map +1 -0
  139. package/file-upload/file-list-item/file-item-actions.styles_1quulgy.css +8 -0
  140. package/file-upload/file-list-item/file-item-details.d.ts +15 -0
  141. package/file-upload/file-list-item/file-item-details.js +2 -0
  142. package/file-upload/file-list-item/file-item-details.js.map +1 -0
  143. package/file-upload/file-list-item/file-item-details.styles.d.ts +7 -0
  144. package/file-upload/file-list-item/file-item-details.styles.js +2 -0
  145. package/file-upload/file-list-item/file-item-details.styles.js.map +1 -0
  146. package/file-upload/file-list-item/file-item-details.styles_1ce9akx.css +7 -0
  147. package/file-upload/file-list-item/file-list-item.d.ts +1 -7
  148. package/file-upload/file-list-item/file-list-item.js +1 -1
  149. package/file-upload/file-list-item/file-list-item.js.map +1 -1
  150. package/file-upload/file-list-item/file-list-item.styles.d.ts +6 -13
  151. package/file-upload/file-list-item/file-list-item.styles.js +1 -1
  152. package/file-upload/file-list-item/file-list-item.styles.js.map +1 -1
  153. package/file-upload/file-list-item/file-list-item.styles_x3a500.css +10 -0
  154. package/file-upload/file-list-item/types.d.ts +10 -3
  155. package/file-upload/file-list-item/use-truncated-name.d.ts +1 -0
  156. package/file-upload/file-list-item/use-truncated-name.js +2 -0
  157. package/file-upload/file-list-item/use-truncated-name.js.map +1 -0
  158. package/file-upload/helper.d.ts +30 -0
  159. package/file-upload/helper.js +1 -1
  160. package/file-upload/helper.js.map +1 -1
  161. package/footer/footer-disclaimer-links-data.js +1 -1
  162. package/footer/footer-disclaimer-links-data.js.map +1 -1
  163. package/footer/footer.styles.js +1 -1
  164. package/footer/footer.styles.js.map +1 -1
  165. package/{cjs/footer/footer.styles_1msorhc.css → footer/footer.styles_14hnlcq.css} +4 -4
  166. package/fullscreen-image-carousel/fullscreen-image-carousel.d.ts +1 -1
  167. package/fullscreen-image-carousel/fullscreen-image-carousel.js +1 -1
  168. package/fullscreen-image-carousel/fullscreen-image-carousel.js.map +1 -1
  169. package/fullscreen-image-carousel/types.d.ts +37 -0
  170. package/index.js +1 -1
  171. package/input-group/types.d.ts +4 -1
  172. package/input-select/types.d.ts +1 -0
  173. package/local-nav/local-nav-dropdown/local-nav-dropdown.js +1 -1
  174. package/local-nav/local-nav-dropdown/local-nav-dropdown.js.map +1 -1
  175. package/local-nav/local-nav-dropdown/local-nav-dropdown.styles.d.ts +3 -0
  176. package/local-nav/local-nav-dropdown/local-nav-dropdown.styles.js +1 -1
  177. package/local-nav/local-nav-dropdown/local-nav-dropdown.styles.js.map +1 -1
  178. package/local-nav/local-nav-dropdown/{local-nav-dropdown.styles_uhd4xl.css → local-nav-dropdown.styles_kpel1m.css} +9 -6
  179. package/local-nav/local-nav-menu/local-nav-menu.js +1 -1
  180. package/local-nav/local-nav-menu/local-nav-menu.js.map +1 -1
  181. package/local-nav/local-nav-menu/local-nav-menu.styles.d.ts +3 -0
  182. package/local-nav/local-nav-menu/local-nav-menu.styles.js +1 -1
  183. package/local-nav/local-nav-menu/local-nav-menu.styles.js.map +1 -1
  184. package/local-nav/local-nav-menu/local-nav-menu.styles_67fcyc.css +8 -0
  185. package/local-nav/types.d.ts +17 -0
  186. package/masked-input/types.d.ts +1 -2
  187. package/masthead/sgds-day.css +0 -1
  188. package/masthead/sgds-night.css +0 -1
  189. package/menu/menu-content.js +1 -1
  190. package/menu/menu-content.js.map +1 -1
  191. package/menu/menu-content.styles.d.ts +1 -0
  192. package/menu/menu-content.styles.js +1 -1
  193. package/menu/menu-content.styles.js.map +1 -1
  194. package/menu/menu-content.styles_1r8oxtk.css +5 -0
  195. package/menu/menu-item.styles.js +1 -1
  196. package/menu/menu-item.styles.js.map +1 -1
  197. package/menu/{menu-item.styles_liyed8.css → menu-item.styles_eut2j9.css} +1 -1
  198. package/menu/menu-link.styles.js +1 -1
  199. package/menu/menu-link.styles.js.map +1 -1
  200. package/menu/menu-link.styles_rng7n7.css +2 -0
  201. package/menu/menu-section.d.ts +1 -1
  202. package/menu/menu-section.js +1 -1
  203. package/menu/menu-section.js.map +1 -1
  204. package/menu/menu-section.styles.d.ts +7 -0
  205. package/menu/menu-section.styles.js +1 -1
  206. package/menu/menu-section.styles.js.map +1 -1
  207. package/menu/menu-section.styles_1n0ppxl.css +5 -0
  208. package/menu/menu.d.ts +1 -1
  209. package/menu/types.d.ts +10 -2
  210. package/navbar/navbar-items.js +1 -1
  211. package/navbar/navbar-items.js.map +1 -1
  212. package/navbar/navbar-logo-data.js +1 -1
  213. package/navbar/navbar-logo-data.js.map +1 -1
  214. package/navbar/types.d.ts +9 -0
  215. package/notification-banner/notification-banner-hoc.js +1 -1
  216. package/notification-banner/notification-banner-hoc.js.map +1 -1
  217. package/package.json +2 -3
  218. package/pagination/pagination.js +1 -1
  219. package/pagination/pagination.js.map +1 -1
  220. package/pagination/types.d.ts +8 -1
  221. package/select-histogram/types.d.ts +1 -0
  222. package/shared/dropdown-list/dropdown-label.d.ts +2 -2
  223. package/shared/dropdown-list/dropdown-label.js +1 -1
  224. package/shared/dropdown-list/dropdown-label.js.map +1 -1
  225. package/shared/dropdown-list/types.d.ts +6 -2
  226. package/shared/fade-wrapper/fade-wrapper.js +1 -1
  227. package/shared/fade-wrapper/fade-wrapper.js.map +1 -1
  228. package/shared/fade-wrapper/types.d.ts +1 -0
  229. package/shared/styles/index.d.ts +5 -0
  230. package/theme/index.js +1 -1
  231. package/theme/styles/a11y-playground.css +52 -40
  232. package/theme/styles/bookingsg.css +52 -40
  233. package/theme/styles/careercompass.css +52 -40
  234. package/theme/styles/ccube.css +52 -40
  235. package/theme/styles/imda.css +52 -40
  236. package/theme/styles/lifesg.css +52 -40
  237. package/theme/styles/mylegacy.css +52 -40
  238. package/theme/styles/oneservice.css +52 -40
  239. package/theme/styles/pa.css +28 -22
  240. package/theme/styles/rbs.css +52 -40
  241. package/theme/styles/sgw-digital-lobby.css +52 -40
  242. package/theme/styles/smgs.css +52 -40
  243. package/theme/styles/spf.css +28 -27
  244. package/theme/styles/sportsg-orange.css +791 -0
  245. package/theme/styles/supportgowhere.css +52 -40
  246. package/theme/styles/tote-board.css +52 -40
  247. package/theme/styles/vica.css +52 -40
  248. package/theme/styles/websg.css +52 -40
  249. package/theme/styles/wise.css +52 -40
  250. package/theme/styles/wogaa.css +52 -40
  251. package/theme/theme-provider/preset.d.ts +2 -0
  252. package/theme/tokens/colour.d.ts +6 -0
  253. package/theme/tokens/colour.js +1 -1
  254. package/theme/tokens/colour.js.map +1 -1
  255. package/theme/tokens/radius.d.ts +3 -0
  256. package/theme/tokens/radius.js +1 -1
  257. package/theme/tokens/radius.js.map +1 -1
  258. package/theme/types.d.ts +9 -3
  259. package/theme/types.js +1 -1
  260. package/theme/types.js.map +1 -1
  261. package/breadcrumb/breadcrumb.styles_1nl4aua.css +0 -18
  262. package/cjs/breadcrumb/breadcrumb.styles_1nl4aua.css +0 -18
  263. package/cjs/file-download/file-list-card/file-list-card.styles_18j2gut.css +0 -16
  264. package/cjs/file-upload/file-item-edit.js +0 -2
  265. package/cjs/file-upload/file-item-edit.js.map +0 -1
  266. package/cjs/file-upload/file-item-edit.styles.js +0 -2
  267. package/cjs/file-upload/file-item-edit.styles.js.map +0 -1
  268. package/cjs/file-upload/file-item-edit.styles_19bvztn.css +0 -11
  269. package/cjs/file-upload/file-list/file-list.styles_1w7so98.css +0 -3
  270. package/cjs/file-upload/file-list-item/file-list-item.styles_kgtfke.css +0 -17
  271. package/cjs/local-nav/local-nav-menu/local-nav-menu.styles_pq19dh.css +0 -5
  272. package/cjs/menu/menu-content.styles_p7ijll.css +0 -2
  273. package/cjs/menu/menu-link.styles_hfxoez.css +0 -2
  274. package/cjs/menu/menu-section.styles_g7my4d.css +0 -3
  275. package/file-download/file-list-card/file-list-card.styles_18j2gut.css +0 -16
  276. package/file-upload/file-item-edit.d.ts +0 -14
  277. package/file-upload/file-item-edit.js +0 -2
  278. package/file-upload/file-item-edit.js.map +0 -1
  279. package/file-upload/file-item-edit.styles.d.ts +0 -9
  280. package/file-upload/file-item-edit.styles.js +0 -2
  281. package/file-upload/file-item-edit.styles.js.map +0 -1
  282. package/file-upload/file-item-edit.styles_19bvztn.css +0 -11
  283. package/file-upload/file-list/file-list.styles_1w7so98.css +0 -3
  284. package/file-upload/file-list-item/file-list-item.styles_kgtfke.css +0 -17
  285. package/local-nav/local-nav-menu/local-nav-menu.styles_pq19dh.css +0 -5
  286. package/menu/menu-content.styles_p7ijll.css +0 -2
  287. package/menu/menu-link.styles_hfxoez.css +0 -2
  288. package/menu/menu-section.styles_g7my4d.css +0 -3
@@ -1,2 +1,2 @@
1
- import{__rest as e}from"../_virtual/_tslib.js";import{jsxs as r,jsx as t,Fragment as i}from"react/jsx-runtime";import{ChevronRightIcon as o}from"@lifesg/react-icons/chevron-right";import s from"clsx";import{useState as l,useRef as n}from"react";import{useResizeDetector as a}from"../external/react-resize-detector/build/index.esm.js";import"../theme/theme-provider/index.js";import{parsePxOrRemValue as m}from"../theme/utils/css-variable.js";import"../theme/theme-provider/context.js";import"../theme/tokens/border.js";import{Breakpoint as d}from"../theme/tokens/breakpoint.js";import"../theme/tokens/colour.js";import"../theme/tokens/font.js";import"../theme/tokens/media-query.js";import{useApplyStyle as c}from"../theme/utils/use-apply-styles.js";import{useResolvedBreakpointToken as h}from"../theme/utils/use-media-query.js";import{Typography as u}from"../typography/index.js";import"../util/calendar-helper.js";import"../external/dayjs/dayjs.min.js";import"../util/simple-id-generator.js";import"../util/string-helper.js";import"@react-aria/live-announcer";import{useEvent as f}from"../util/use-event.js";import{useEventListener as p}from"../util/use-event-listener.js";import{useIsomorphicLayoutEffect as j}from"../util/use-isomorphic-layout-effect.js";import{tokens as g,wrapper as v,content as b,currentLabel as y,previousLink as k,item as N,caret as x,slash as W,fade as w,fadeLeft as M,fadeRight as C}from"./breadcrumb.styles.js";const L=L=>{var O,z,{links:B,fadeColor:D,fadePosition:R="both",id:S,separatorStyle:q="chevron",className:A}=L,P=e(L,["links","fadeColor","fadePosition","id","separatorStyle","className"]);const[_,E]=l(!1),[F,G]=l(!1),[H,I]=l(!1),J="left"===R||"both"===R,K="right"===R||"both"===R,Q=n(null),T=n(null),U=n(null),V=n(null),X=m(h(d["lg-max"]));let Y;Y=Array.isArray(D)&&D.length>0?{left:D,right:D}:D||{left:void 0,right:void 0},c(U,{[g.fade.backgroundColor]:null===(O=null==Y?void 0:Y.left)||void 0===O?void 0:O.join(", ")}),c(V,{[g.fade.backgroundColor]:null===(z=null==Y?void 0:Y.right)||void 0===z?void 0:z.join(", ")});const Z=f((()=>{const e=T.current,r=Q.current;e&&r&&B&&B.length>1&&window.innerWidth<=X&&(e.scrollLeft=e.scrollWidth-r.offsetWidth)})),$=f((()=>{const e=window.innerWidth<=X;E(e);const r=T.current,t=Q.current;if(r&&t&&e&&r.scrollWidth>t.offsetWidth)return G(r.scrollLeft>=1),void I(r.scrollWidth-r.scrollLeft-1>t.offsetWidth);G(!1),I(!1)}));if(p("resize",$),p("scroll",$,T.current),j((()=>{Z(),$()}),[Z,$,X]),a({onResize:Z,targetRef:Q,refreshMode:"debounce",refreshRate:50,skipOnMount:!0}),!B)return null;return r("div",Object.assign({ref:Q,id:S||"breadcrumb",className:s(v,A)},P,{children:[t("nav",{"aria-label":"Breadcrumb",children:t("ul",{ref:T,className:b,children:B.map(((e,i)=>{let s;return e.children?(s=i!==B.length-1&&e.href?t(u.LinkMD,Object.assign({},e,{weight:"semibold",underlineStyle:"none",className:k})):t(u.BodyMD,{weight:"semibold",as:"span",className:y,children:e.children}),r("li",Object.assign({className:N},i===B.length-1&&{"aria-current":"page"},{children:[s,i<B.length-1&&("chevron"===q?t(o,{"aria-hidden":!0,className:x}):t(u.BodyMD,{inline:!0,"aria-hidden":!0,className:W,children:"/"}))]}),i)):null}))})}),_&&r(i,{children:[F&&J&&t("div",{ref:U,className:s(w,M)}),H&&K&&t("div",{ref:V,className:s(w,C)})]})]}))};export{L as Breadcrumb};
1
+ import{__rest as e}from"../_virtual/_tslib.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";import{ChevronRightIcon as t}from"@lifesg/react-icons/chevron-right";import o from"clsx";import{useRef as s}from"react";import{FadeWrapper as a}from"../shared/fade-wrapper/fade-wrapper.js";import"../theme/theme-provider/index.js";import{parsePxOrRemValue as n}from"../theme/utils/css-variable.js";import"../theme/theme-provider/context.js";import"../theme/tokens/border.js";import{Breakpoint as l}from"../theme/tokens/breakpoint.js";import"../theme/tokens/colour.js";import"../theme/tokens/font.js";import"../theme/tokens/media-query.js";import"../util/calendar-helper.js";import"../external/dayjs/dayjs.min.js";import"../util/simple-id-generator.js";import"../util/string-helper.js";import"@react-aria/live-announcer";import{useEvent as m}from"../util/use-event.js";import{useIsomorphicLayoutEffect as d}from"../util/use-isomorphic-layout-effect.js";import{useResolvedBreakpointToken as c}from"../theme/utils/use-media-query.js";import{Typography as p}from"../typography/index.js";import{wrapper as h,content as u,currentLabel as f,previousLink as j,item as b,caret as g,slash as v}from"./breadcrumb.styles.js";const y=y=>{var{links:k,fadeColor:N,fadePosition:x="both",id:w,separatorStyle:B="chevron",className:C}=y,D=e(y,["links","fadeColor","fadePosition","id","separatorStyle","className"]);const M=s(null),O=n(c(l["lg-max"])),P=m((()=>{var e;k&&k.length>1&&window.innerWidth<=O&&(null===(e=M.current)||void 0===e||e.scrollToEnd())}));if(d((()=>{P()}),[P,O]),!k)return null;return r(a,Object.assign({ref:M,id:w||"breadcrumb",className:o(h,C),fadeColor:N,fadePosition:x,onResize:P},D,{children:r("nav",{"aria-label":"Breadcrumb",children:r("ul",{className:u,children:k.map(((e,o)=>{let s;return e.children?(s=o!==k.length-1&&e.href?r(p.LinkMD,Object.assign({},e,{weight:"semibold",underlineStyle:"none",className:j})):r(p.BodyMD,{weight:"semibold",as:"span",className:f,children:e.children}),i("li",Object.assign({className:b},o===k.length-1&&{"aria-current":"page"},{children:[s,o<k.length-1&&("chevron"===B?r(t,{"aria-hidden":!0,className:g}):r(p.BodyMD,{inline:!0,"aria-hidden":!0,className:v,children:"/"}))]}),o)):null}))})})}))};export{y as Breadcrumb};
2
2
  //# sourceMappingURL=breadcrumb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumb.js","sources":["../../src/breadcrumb/breadcrumb.tsx"],"sourcesContent":["import { ChevronRightIcon } from \"@lifesg/react-icons/chevron-right\";\nimport clsx from \"clsx\";\nimport { useRef, useState } from \"react\";\nimport { useResizeDetector } from \"react-resize-detector\";\n\nimport {\n parsePxOrRemValue,\n useApplyStyle,\n useResolvedBreakpointToken,\n} from \"../theme\";\nimport { Breakpoint } from \"../theme/tokens\";\nimport { Typography } from \"../typography\";\nimport { useEvent, useEventListener, useIsomorphicLayoutEffect } from \"../util\";\nimport * as styles from \"./breadcrumb.styles\";\nimport type { BreadcrumbProps, FadeColorSet } from \"./types\";\n\n// @catalog\n/**\n * Horizontal breadcrumb navigation trail.\n *\n * Use `Breadcrumb` to show the user's position within a page hierarchy and\n * allow navigation to parent pages. On tablet and below, the trail scrolls\n * horizontally with optional edge fade overlays to indicate clipped content.\n * @keywords hierarchy, navigation, path, trail, wayfinding\n */\nexport const Breadcrumb = ({\n links,\n fadeColor,\n fadePosition = \"both\",\n id,\n separatorStyle = \"chevron\",\n className,\n ...otherProps\n}: BreadcrumbProps) => {\n // =========================================================================\n // CONST, STATE, REFS\n // =========================================================================\n const [showFade, setShowFade] = useState<boolean>(false);\n const [showFadeLeft, setShowFadeLeft] = useState<boolean>(false);\n const [showFadeRight, setShowFadeRight] = useState<boolean>(false);\n const shouldShowFadeLeft =\n fadePosition === \"left\" || fadePosition === \"both\";\n const shouldShowFadeRight =\n fadePosition === \"right\" || fadePosition === \"both\";\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLUListElement>(null);\n const fadeLeftRef = useRef<HTMLDivElement>(null);\n const fadeRightRef = useRef<HTMLDivElement>(null);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n\n const tabletBreakpoint = parsePxOrRemValue(\n useResolvedBreakpointToken(Breakpoint[\"lg-max\"])\n );\n\n // =============================================================================\n // FADE COLOR CALCULATION\n // =============================================================================\n let fadeColorSet: FadeColorSet;\n\n if (Array.isArray(fadeColor) && fadeColor.length > 0) {\n fadeColorSet = {\n left: fadeColor,\n right: fadeColor,\n };\n } else if (fadeColor) {\n fadeColorSet = fadeColor as FadeColorSet;\n } else {\n fadeColorSet = {\n left: undefined,\n right: undefined,\n };\n }\n\n // =============================================================================\n // CSS VARIABLES\n // =============================================================================\n useApplyStyle(fadeLeftRef, {\n [styles.tokens.fade.backgroundColor]: fadeColorSet?.left?.join(\", \"),\n });\n\n useApplyStyle(fadeRightRef, {\n [styles.tokens.fade.backgroundColor]: fadeColorSet?.right?.join(\", \"),\n });\n\n const onResize = useEvent(() => {\n const content = contentRef.current;\n const wrapper = wrapperRef.current;\n\n if (\n content &&\n wrapper &&\n links &&\n links.length > 1 &&\n window.innerWidth <= tabletBreakpoint\n ) {\n content.scrollLeft = content.scrollWidth - wrapper.offsetWidth;\n }\n });\n\n const handleShowFadeToggle = useEvent(() => {\n const nextShowFade = window.innerWidth <= tabletBreakpoint;\n setShowFade(nextShowFade);\n\n const content = contentRef.current;\n const wrapper = wrapperRef.current;\n if (content && wrapper && nextShowFade) {\n if (content.scrollWidth > wrapper.offsetWidth) {\n // set 1px margin of error to handle sub-pixel differences\n setShowFadeLeft(content.scrollLeft >= 1);\n setShowFadeRight(\n content.scrollWidth - content.scrollLeft - 1 >\n wrapper.offsetWidth\n );\n return;\n }\n }\n\n setShowFadeLeft(false);\n setShowFadeRight(false);\n });\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEventListener(\"resize\", handleShowFadeToggle);\n useEventListener(\"scroll\", handleShowFadeToggle, contentRef.current);\n\n useIsomorphicLayoutEffect(() => {\n onResize();\n handleShowFadeToggle();\n }, [onResize, handleShowFadeToggle, tabletBreakpoint]);\n\n // To scroll left when wrapper resizes\n useResizeDetector({\n onResize,\n targetRef: wrapperRef,\n refreshMode: \"debounce\",\n refreshRate: 50,\n skipOnMount: true,\n });\n\n // =========================================================================\n // RENDER\n // =========================================================================\n if (!links) return null;\n\n const renderLinks = () => {\n return links.map((link, index) => {\n let element: JSX.Element;\n if (!link.children) {\n return null;\n }\n\n if (index === links.length - 1 || !link.href) {\n element = (\n <Typography.BodyMD\n weight=\"semibold\"\n as=\"span\"\n className={styles.currentLabel}\n >\n {link.children}\n </Typography.BodyMD>\n );\n } else {\n element = (\n <Typography.LinkMD\n {...link}\n weight=\"semibold\"\n underlineStyle=\"none\"\n className={styles.previousLink}\n />\n );\n }\n\n return (\n <li\n key={index}\n className={styles.item}\n {...(index === links.length - 1 && {\n \"aria-current\": \"page\",\n })}\n >\n {element}\n {index < links.length - 1 &&\n (separatorStyle === \"chevron\" ? (\n <ChevronRightIcon\n aria-hidden\n className={styles.caret}\n />\n ) : (\n <Typography.BodyMD\n inline\n aria-hidden\n className={styles.slash}\n >\n /\n </Typography.BodyMD>\n ))}\n </li>\n );\n });\n };\n\n const renderFade = () => {\n return (\n <>\n {showFadeLeft && shouldShowFadeLeft && (\n <div\n ref={fadeLeftRef}\n className={clsx(styles.fade, styles.fadeLeft)}\n />\n )}\n {showFadeRight && shouldShowFadeRight && (\n <div\n ref={fadeRightRef}\n className={clsx(styles.fade, styles.fadeRight)}\n />\n )}\n </>\n );\n };\n\n return (\n <div\n ref={wrapperRef}\n id={id || \"breadcrumb\"}\n className={clsx(styles.wrapper, className)}\n {...otherProps}\n >\n <nav aria-label=\"Breadcrumb\">\n <ul ref={contentRef} className={styles.content}>\n {renderLinks()}\n </ul>\n </nav>\n {showFade && renderFade()}\n </div>\n );\n};\n"],"names":["Breadcrumb","_a","links","fadeColor","fadePosition","id","separatorStyle","className","otherProps","__rest","showFade","setShowFade","useState","showFadeLeft","setShowFadeLeft","showFadeRight","setShowFadeRight","shouldShowFadeLeft","shouldShowFadeRight","wrapperRef","useRef","contentRef","fadeLeftRef","fadeRightRef","tabletBreakpoint","parsePxOrRemValue","useResolvedBreakpointToken","Breakpoint","fadeColorSet","Array","isArray","length","left","right","undefined","useApplyStyle","styles.tokens","fade","backgroundColor","_b","join","_c","onResize","useEvent","content","current","wrapper","window","innerWidth","scrollLeft","scrollWidth","offsetWidth","handleShowFadeToggle","nextShowFade","useEventListener","useIsomorphicLayoutEffect","useResizeDetector","targetRef","refreshMode","refreshRate","skipOnMount","_jsxs","ref","clsx","styles.wrapper","children","_jsx","styles.content","map","link","index","element","href","Typography","LinkMD","Object","assign","weight","underlineStyle","styles.previousLink","BodyMD","as","styles.currentLabel","styles.item","ChevronRightIcon","styles.caret","inline","styles.slash","_Fragment","styles.fade","styles.fadeLeft","styles.fadeRight"],"mappings":"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"}
1
+ {"version":3,"file":"breadcrumb.js","sources":["../../src/breadcrumb/breadcrumb.tsx"],"sourcesContent":["import { ChevronRightIcon } from \"@lifesg/react-icons/chevron-right\";\nimport clsx from \"clsx\";\nimport { useRef } from \"react\";\n\nimport { FadeWrapper, type FadeWrapperRef } from \"../shared/fade-wrapper\";\nimport { parsePxOrRemValue, useResolvedBreakpointToken } from \"../theme\";\nimport { Breakpoint } from \"../theme/tokens\";\nimport { Typography } from \"../typography\";\nimport { useEvent, useIsomorphicLayoutEffect } from \"../util\";\nimport * as styles from \"./breadcrumb.styles\";\nimport type { BreadcrumbProps } from \"./types\";\n\n// @catalog\n/**\n * Horizontal breadcrumb navigation trail.\n *\n * Use `Breadcrumb` to show the user's position within a page hierarchy and\n * allow navigation to parent pages. On tablet and below, the trail scrolls\n * horizontally with optional edge fade overlays to indicate clipped content.\n * @keywords hierarchy, navigation, path, trail, wayfinding\n */\nexport const Breadcrumb = ({\n links,\n fadeColor,\n fadePosition = \"both\",\n id,\n separatorStyle = \"chevron\",\n className,\n ...otherProps\n}: BreadcrumbProps) => {\n // =========================================================================\n // CONST, STATE, REFS\n // =========================================================================\n const fadeWrapperRef = useRef<FadeWrapperRef>(null);\n\n const tabletBreakpoint = parsePxOrRemValue(\n useResolvedBreakpointToken(Breakpoint[\"lg-max\"])\n );\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleResize = useEvent(() => {\n if (\n links &&\n links.length > 1 &&\n window.innerWidth <= tabletBreakpoint\n ) {\n fadeWrapperRef.current?.scrollToEnd();\n }\n });\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useIsomorphicLayoutEffect(() => {\n handleResize();\n }, [handleResize, tabletBreakpoint]);\n\n // =========================================================================\n // RENDER\n // =========================================================================\n if (!links) return null;\n\n const renderLinks = () => {\n return links.map((link, index) => {\n let element: JSX.Element;\n if (!link.children) {\n return null;\n }\n\n if (index === links.length - 1 || !link.href) {\n element = (\n <Typography.BodyMD\n weight=\"semibold\"\n as=\"span\"\n className={styles.currentLabel}\n >\n {link.children}\n </Typography.BodyMD>\n );\n } else {\n element = (\n <Typography.LinkMD\n {...link}\n weight=\"semibold\"\n underlineStyle=\"none\"\n className={styles.previousLink}\n />\n );\n }\n\n return (\n <li\n key={index}\n className={styles.item}\n {...(index === links.length - 1 && {\n \"aria-current\": \"page\",\n })}\n >\n {element}\n {index < links.length - 1 &&\n (separatorStyle === \"chevron\" ? (\n <ChevronRightIcon\n aria-hidden\n className={styles.caret}\n />\n ) : (\n <Typography.BodyMD\n inline\n aria-hidden\n className={styles.slash}\n >\n /\n </Typography.BodyMD>\n ))}\n </li>\n );\n });\n };\n\n return (\n <FadeWrapper\n ref={fadeWrapperRef}\n id={id || \"breadcrumb\"}\n className={clsx(styles.wrapper, className)}\n fadeColor={fadeColor}\n fadePosition={fadePosition}\n onResize={handleResize}\n {...otherProps}\n >\n <nav aria-label=\"Breadcrumb\">\n <ul className={styles.content}>{renderLinks()}</ul>\n </nav>\n </FadeWrapper>\n );\n};\n"],"names":["Breadcrumb","_a","links","fadeColor","fadePosition","id","separatorStyle","className","otherProps","__rest","fadeWrapperRef","useRef","tabletBreakpoint","parsePxOrRemValue","useResolvedBreakpointToken","Breakpoint","handleResize","useEvent","length","window","innerWidth","current","scrollToEnd","useIsomorphicLayoutEffect","_jsx","FadeWrapper","Object","assign","ref","clsx","styles.wrapper","onResize","children","styles.content","map","link","index","element","href","Typography","LinkMD","weight","underlineStyle","styles.previousLink","BodyMD","as","styles.currentLabel","_jsxs","styles.item","ChevronRightIcon","styles.caret","inline","styles.slash"],"mappings":"yrCAqBO,MAAMA,EAAcC,QAAAC,MACvBA,EAAKC,UACLA,EAASC,aACTA,EAAe,OAAMC,GACrBA,EAAEC,eACFA,EAAiB,UAASC,UAC1BA,GAASN,EACNO,EAAUC,EAAAR,EAPU,wEAYvB,MAAMS,EAAiBC,EAAuB,MAExCC,EAAmBC,EACrBC,EAA2BC,EAAW,YAMpCC,EAAeC,GAAS,WAEtBf,GACAA,EAAMgB,OAAS,GACfC,OAAOC,YAAcR,IAEC,QAAtBX,EAAAS,EAAeW,eAAO,IAAApB,GAAAA,EAAEqB,cAC5B,IAaJ,GAPAC,GAA0B,KACtBP,GAAc,GACf,CAACA,EAAcJ,KAKbV,EAAO,OAAO,KA2DnB,OACIsB,EAACC,EAAWC,OAAAC,OAAA,CACRC,IAAKlB,EACLL,GAAIA,GAAM,aACVE,UAAWsB,EAAKC,EAAgBvB,GAChCJ,UAAWA,EACXC,aAAcA,EACd2B,SAAUf,GACNR,EAAU,CAAAwB,SAEdR,EAAA,MAAA,CAAA,aAAgB,aAAYQ,SACxBR,QAAIjB,UAAW0B,EAAcD,SAnE9B9B,EAAMgC,KAAI,CAACC,EAAMC,KACpB,IAAIC,EACJ,OAAKF,EAAKH,UAeNK,EAXAD,IAAUlC,EAAMgB,OAAS,GAAMiB,EAAKG,KAYhCd,EAACe,EAAWC,OAAMd,OAAAC,OAAA,GACVQ,EAAI,CACRM,OAAO,WACPC,eAAe,OACfnC,UAAWoC,KAdfnB,EAACe,EAAWK,OAAM,CACdH,OAAO,WACPI,GAAG,OACHtC,UAAWuC,EAAmBd,SAE7BG,EAAKH,WAede,EAAA,KAAArB,OAAAC,OAAA,CAEIpB,UAAWyC,GACNZ,IAAUlC,EAAMgB,OAAS,GAAK,CAC/B,eAAgB,QAClB,CAAAc,SAAA,CAEDK,EACAD,EAAQlC,EAAMgB,OAAS,IACA,YAAnBZ,EACGkB,EAACyB,EAAgB,CAAA,eAAA,EAEb1C,UAAW2C,IAGf1B,EAACe,EAAWK,QACRO,QAAM,EAAA,eAAA,EAEN5C,UAAW6C,qBAjBlBhB,IA1BF,IAgDF,UAkBC"}
@@ -1,13 +1,5 @@
1
- export declare const tokens: {
2
- fade: {
3
- backgroundColor: string;
4
- };
5
- };
6
1
  export declare const wrapper: import("@linaria/core").LinariaClassName;
7
2
  export declare const content: import("@linaria/core").LinariaClassName;
8
- export declare const fade: import("@linaria/core").LinariaClassName;
9
- export declare const fadeLeft: import("@linaria/core").LinariaClassName;
10
- export declare const fadeRight: import("@linaria/core").LinariaClassName;
11
3
  export declare const item: import("@linaria/core").LinariaClassName;
12
4
  export declare const caret: import("@linaria/core").LinariaClassName;
13
5
  export declare const slash: import("@linaria/core").LinariaClassName;
@@ -1,2 +1,2 @@
1
- import"./breadcrumb.styles_1nl4aua.css";const r={fade:{backgroundColor:"--fds-internal-breadcrumb-fade-backgroundColor"}},a="wcpniaz",o="c10gatr7",c="fbyhxo7",d="f1xa0lk7",b="f1oxmxuo",e="ikhkv84",m="co9wmrd",n="spyv6ve",f="c1mfqdvn",s="pm022dc";export{m as caret,o as content,f as currentLabel,c as fade,d as fadeLeft,b as fadeRight,e as item,s as previousLink,n as slash,r as tokens,a as wrapper};
1
+ import"./breadcrumb.styles_1blzn8n.css";const c="wcpniaz",r="c10gatr7",o="ibyhxo7",b="c1xa0lk7",s="s1oxmxuo",a="ckhkv84",m="po9wmrd";export{b as caret,r as content,a as currentLabel,o as item,m as previousLink,s as slash,c as wrapper};
2
2
  //# sourceMappingURL=breadcrumb.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumb.styles.js","sources":["../../src/breadcrumb/breadcrumb.styles.ts"],"sourcesContent":["import { css } from \"@linaria/core\";\n\nimport { Colour, Font, MediaQuery, Spacing } from \"../theme\";\n\nexport const tokens = {\n fade: {\n backgroundColor: \"--fds-internal-breadcrumb-fade-backgroundColor\",\n },\n};\n\n// =============================================================================\n// STYLE CLASSES\n// =============================================================================\nexport const wrapper = css`\n position: relative;\n width: 100%;\n z-index: 1;\n margin: ${Spacing[\"spacing-32\"]} 0;\n\n ${MediaQuery.MaxWidth.xl} {\n margin: ${Spacing[\"spacing-24\"]} 0;\n }\n\n ${MediaQuery.MaxWidth.lg} {\n margin: ${Spacing[\"spacing-16\"]} 0;\n }\n`;\n\nexport const content = css`\n display: inline-flex;\n width: 100%;\n flex-wrap: wrap;\n white-space: nowrap;\n margin-left: calc(${Spacing[\"spacing-8\"]} * -1);\n font-size: ${Font.Spec[\"body-size-md\"]};\n overflow-x: scroll;\n overflow-y: hidden;\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE 10+ */\n &::-webkit-scrollbar {\n display: none; /* Chrome/Safari/Webkit */\n }\n\n ${MediaQuery.MaxWidth.lg} {\n flex-wrap: nowrap;\n }\n`;\n\nexport const fade = css`\n ${tokens.fade.backgroundColor}: initial;\n width: ${Spacing[\"spacing-64\"]};\n height: calc(1lh + ${Spacing[\"spacing-4\"]});\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n pointer-events: none;\n`;\n\nexport const fadeLeft = css`\n ${MediaQuery.MaxWidth.lg} {\n left: calc(${Spacing[\"spacing-8\"]} * -1);\n background-image: linear-gradient(\n to right,\n var(${tokens.fade.backgroundColor}, ${Colour.bg}),\n rgba(255, 255, 255, 0.001)\n );\n }\n`;\n\nexport const fadeRight = css`\n ${MediaQuery.MaxWidth.lg} {\n right: ${Spacing[\"spacing-8\"]};\n background-image: linear-gradient(\n to left,\n var(${tokens.fade.backgroundColor}, ${Colour.bg}),\n rgba(255, 255, 255, 0.001)\n );\n }\n`;\n\nexport const item = css`\n display: flex;\n flex-direction: row;\n align-items: center;\n line-height: inherit;\n font-size: inherit;\n`;\n\nexport const caret = css`\n height: 1em;\n width: 1em;\n color: ${Colour[\"icon-subtle\"]};\n`;\n\nexport const slash = css`\n display: inline-block;\n color: ${Colour[\"text-subtlest\"]};\n`;\n\nexport const currentLabel = css`\n margin: ${Spacing[\"spacing-8\"]} !important;\n`;\n\nexport const previousLink = css`\n margin: ${Spacing[\"spacing-8\"]} !important;\n`;\n"],"names":["tokens","fade","backgroundColor","wrapper","content","fadeLeft","fadeRight","item","caret","slash","currentLabel","previousLink"],"mappings":"kEAIO,MAAMA,EAAS,CAClBC,KAAM,CACFC,gBAAiB,mDAOZC,EAAO,UAePC,EAAO,WAoBPH,EAAI,UAUJI,EAAQ,WAWRC,EAAS,WAWTC,EAAI,UAQJC,EAAK,UAMLC,EAAK,UAKLC,EAAY,WAIZC,EAAY"}
1
+ {"version":3,"file":"breadcrumb.styles.js","sources":["../../src/breadcrumb/breadcrumb.styles.ts"],"sourcesContent":["import { css } from \"@linaria/core\";\n\nimport { Colour, Font, MediaQuery, Spacing } from \"../theme\";\n\n// =============================================================================\n// STYLE CLASSES\n// =============================================================================\nexport const wrapper = css`\n z-index: 1;\n margin: ${Spacing[\"spacing-32\"]} 0;\n\n ${MediaQuery.MaxWidth.xl} {\n margin: ${Spacing[\"spacing-24\"]} 0;\n }\n\n ${MediaQuery.MaxWidth.lg} {\n margin: ${Spacing[\"spacing-16\"]} 0;\n }\n\n [data-id=\"left-fade\"],\n [data-id=\"right-fade\"] {\n height: calc(1lh + ${Spacing[\"spacing-4\"]});\n top: 50%;\n transform: translateY(-50%);\n }\n`;\n\nexport const content = css`\n display: inline-flex;\n width: 100%;\n flex-wrap: wrap;\n white-space: nowrap;\n margin-left: calc(${Spacing[\"spacing-8\"]} * -1);\n font-size: ${Font.Spec[\"body-size-md\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n flex-wrap: nowrap;\n }\n`;\n\nexport const item = css`\n display: flex;\n flex-direction: row;\n align-items: center;\n line-height: inherit;\n font-size: inherit;\n`;\n\nexport const caret = css`\n height: 1em;\n width: 1em;\n color: ${Colour[\"icon-subtle\"]};\n`;\n\nexport const slash = css`\n display: inline-block;\n color: ${Colour[\"text-subtlest\"]};\n`;\n\nexport const currentLabel = css`\n margin: ${Spacing[\"spacing-8\"]} !important;\n`;\n\nexport const previousLink = css`\n margin: ${Spacing[\"spacing-8\"]} !important;\n`;\n"],"names":["wrapper","content","item","caret","slash","currentLabel","previousLink"],"mappings":"kEAOO,MAAMA,EAAO,UAoBPC,EAAO,WAaPC,EAAI,UAQJC,EAAK,WAMLC,EAAK,WAKLC,EAAY,UAIZC,EAAY"}
@@ -0,0 +1,7 @@
1
+ @layer fds{.wcpniaz{z-index:1;margin:var(--fds-spacing-32) 0;}:where(body.fds-breakpoint-xl-max) .wcpniaz{margin:var(--fds-spacing-24) 0;}:where(body.fds-breakpoint-lg-max) .wcpniaz{margin:var(--fds-spacing-16) 0;}.wcpniaz [data-id="left-fade"],.wcpniaz [data-id="right-fade"]{height:calc(1lh + var(--fds-spacing-4));top:50%;-webkit-transform:translateY(-50%);-moz-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);}
2
+ .c10gatr7{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;width:100%;-webkit-box-flex-wrap:wrap;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;white-space:nowrap;margin-left:calc(var(--fds-spacing-8) * -1);font-size:var(--fds-font-body-size-md);}:where(body.fds-breakpoint-lg-max) .c10gatr7{-webkit-box-flex-wrap:nowrap;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;}
3
+ .ibyhxo7{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;line-height:inherit;font-size:inherit;}
4
+ .c1xa0lk7{height:1em;width:1em;color:var(--fds-colour-icon-subtle);}
5
+ .s1oxmxuo{display:inline-block;color:var(--fds-colour-text-subtlest);}
6
+ .ckhkv84{margin:var(--fds-spacing-8)!important;}
7
+ .po9wmrd{margin:var(--fds-spacing-8)!important;}}
@@ -1,18 +1,7 @@
1
+ import type { FadeColorSet } from "../shared/fade-wrapper";
2
+ export type { FadeColorSet };
1
3
  export type FadePosition = "left" | "right" | "both";
2
4
  export type SeparatorStyle = "chevron" | "slash";
3
- /**
4
- * Gradient color values for the fade overlays in the breadcrumb scroll container.
5
- */
6
- export interface FadeColorSet {
7
- /**
8
- * Gradient color stops for the left fade overlay.
9
- */
10
- left?: string[] | undefined;
11
- /**
12
- * Gradient color stops for the right fade overlay.
13
- */
14
- right?: string[] | undefined;
15
- }
16
5
  /** Props for the `Breadcrumb` component */
17
6
  export interface BreadcrumbProps {
18
7
  /**
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../_virtual/_tslib.js"),r=require("react/jsx-runtime"),t=require("@lifesg/react-icons/chevron-right"),s=require("clsx"),i=require("react"),l=require("../external/react-resize-detector/build/index.esm.js");require("../theme/theme-provider/index.js");var n=require("../theme/utils/css-variable.js");require("../theme/theme-provider/context.js"),require("../theme/tokens/border.js");var a=require("../theme/tokens/breakpoint.js");require("../theme/tokens/colour.js"),require("../theme/tokens/font.js"),require("../theme/tokens/media-query.js");var u=require("../theme/utils/use-apply-styles.js"),o=require("../theme/utils/use-media-query.js"),d=require("../typography/index.js");require("../util/calendar-helper.js"),require("../external/dayjs/dayjs.min.js"),require("../util/simple-id-generator.js"),require("../util/string-helper.js"),require("@react-aria/live-announcer");var c=require("../util/use-event.js"),h=require("../util/use-event-listener.js"),f=require("../util/use-isomorphic-layout-effect.js"),m=require("./breadcrumb.styles.js");function j(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v=j(s);exports.Breadcrumb=s=>{var j,p,{links:g,fadeColor:y,fadePosition:q="both",id:b,separatorStyle:x="chevron",className:k}=s,R=e.__rest(s,["links","fadeColor","fadePosition","id","separatorStyle","className"]);const[N,L]=i.useState(!1),[S,W]=i.useState(!1),[w,B]=i.useState(!1),C="left"===q||"both"===q,E="right"===q||"both"===q,M=i.useRef(null),O=i.useRef(null),z=i.useRef(null),A=i.useRef(null),D=n.parsePxOrRemValue(o.useResolvedBreakpointToken(a.Breakpoint["lg-max"]));let T;T=Array.isArray(y)&&y.length>0?{left:y,right:y}:y||{left:void 0,right:void 0},u.useApplyStyle(z,{[m.tokens.fade.backgroundColor]:null===(j=null==T?void 0:T.left)||void 0===j?void 0:j.join(", ")}),u.useApplyStyle(A,{[m.tokens.fade.backgroundColor]:null===(p=null==T?void 0:T.right)||void 0===p?void 0:p.join(", ")});const _=c.useEvent((()=>{const e=O.current,r=M.current;e&&r&&g&&g.length>1&&window.innerWidth<=D&&(e.scrollLeft=e.scrollWidth-r.offsetWidth)})),P=c.useEvent((()=>{const e=window.innerWidth<=D;L(e);const r=O.current,t=M.current;if(r&&t&&e&&r.scrollWidth>t.offsetWidth)return W(r.scrollLeft>=1),void B(r.scrollWidth-r.scrollLeft-1>t.offsetWidth);W(!1),B(!1)}));if(h.useEventListener("resize",P),h.useEventListener("scroll",P,O.current),f.useIsomorphicLayoutEffect((()=>{_(),P()}),[_,P,D]),l.useResizeDetector({onResize:_,targetRef:M,refreshMode:"debounce",refreshRate:50,skipOnMount:!0}),!g)return null;return r.jsxs("div",Object.assign({ref:M,id:b||"breadcrumb",className:v.default(m.wrapper,k)},R,{children:[r.jsx("nav",{"aria-label":"Breadcrumb",children:r.jsx("ul",{ref:O,className:m.content,children:g.map(((e,s)=>{let i;return e.children?(i=s!==g.length-1&&e.href?r.jsx(d.Typography.LinkMD,Object.assign({},e,{weight:"semibold",underlineStyle:"none",className:m.previousLink})):r.jsx(d.Typography.BodyMD,{weight:"semibold",as:"span",className:m.currentLabel,children:e.children}),r.jsxs("li",Object.assign({className:m.item},s===g.length-1&&{"aria-current":"page"},{children:[i,s<g.length-1&&("chevron"===x?r.jsx(t.ChevronRightIcon,{"aria-hidden":!0,className:m.caret}):r.jsx(d.Typography.BodyMD,{inline:!0,"aria-hidden":!0,className:m.slash,children:"/"}))]}),s)):null}))})}),N&&r.jsxs(r.Fragment,{children:[S&&C&&r.jsx("div",{ref:z,className:v.default(m.fade,m.fadeLeft)}),w&&E&&r.jsx("div",{ref:A,className:v.default(m.fade,m.fadeRight)})]})]}))};
1
+ "use strict";var e=require("../_virtual/_tslib.js"),r=require("react/jsx-runtime"),i=require("@lifesg/react-icons/chevron-right"),s=require("clsx"),a=require("react"),t=require("../shared/fade-wrapper/fade-wrapper.js");require("../theme/theme-provider/index.js");var n=require("../theme/utils/css-variable.js");require("../theme/theme-provider/context.js"),require("../theme/tokens/border.js");var l=require("../theme/tokens/breakpoint.js");require("../theme/tokens/colour.js"),require("../theme/tokens/font.js"),require("../theme/tokens/media-query.js"),require("../util/calendar-helper.js"),require("../external/dayjs/dayjs.min.js"),require("../util/simple-id-generator.js"),require("../util/string-helper.js"),require("@react-aria/live-announcer");var u=require("../util/use-event.js"),o=require("../util/use-isomorphic-layout-effect.js"),c=require("../theme/utils/use-media-query.js"),d=require("../typography/index.js"),h=require("./breadcrumb.styles.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=m(s);exports.Breadcrumb=s=>{var{links:m,fadeColor:j,fadePosition:q="both",id:f,separatorStyle:v="chevron",className:y}=s,g=e.__rest(s,["links","fadeColor","fadePosition","id","separatorStyle","className"]);const b=a.useRef(null),x=n.parsePxOrRemValue(c.useResolvedBreakpointToken(l.Breakpoint["lg-max"])),k=u.useEvent((()=>{var e;m&&m.length>1&&window.innerWidth<=x&&(null===(e=b.current)||void 0===e||e.scrollToEnd())}));if(o.useIsomorphicLayoutEffect((()=>{k()}),[k,x]),!m)return null;return r.jsx(t.FadeWrapper,Object.assign({ref:b,id:f||"breadcrumb",className:p.default(h.wrapper,y),fadeColor:j,fadePosition:q,onResize:k},g,{children:r.jsx("nav",{"aria-label":"Breadcrumb",children:r.jsx("ul",{className:h.content,children:m.map(((e,s)=>{let a;return e.children?(a=s!==m.length-1&&e.href?r.jsx(d.Typography.LinkMD,Object.assign({},e,{weight:"semibold",underlineStyle:"none",className:h.previousLink})):r.jsx(d.Typography.BodyMD,{weight:"semibold",as:"span",className:h.currentLabel,children:e.children}),r.jsxs("li",Object.assign({className:h.item},s===m.length-1&&{"aria-current":"page"},{children:[a,s<m.length-1&&("chevron"===v?r.jsx(i.ChevronRightIcon,{"aria-hidden":!0,className:h.caret}):r.jsx(d.Typography.BodyMD,{inline:!0,"aria-hidden":!0,className:h.slash,children:"/"}))]}),s)):null}))})})}))};
2
2
  //# sourceMappingURL=breadcrumb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumb.js","sources":["../../../src/breadcrumb/breadcrumb.tsx"],"sourcesContent":["import { ChevronRightIcon } from \"@lifesg/react-icons/chevron-right\";\nimport clsx from \"clsx\";\nimport { useRef, useState } from \"react\";\nimport { useResizeDetector } from \"react-resize-detector\";\n\nimport {\n parsePxOrRemValue,\n useApplyStyle,\n useResolvedBreakpointToken,\n} from \"../theme\";\nimport { Breakpoint } from \"../theme/tokens\";\nimport { Typography } from \"../typography\";\nimport { useEvent, useEventListener, useIsomorphicLayoutEffect } from \"../util\";\nimport * as styles from \"./breadcrumb.styles\";\nimport type { BreadcrumbProps, FadeColorSet } from \"./types\";\n\n// @catalog\n/**\n * Horizontal breadcrumb navigation trail.\n *\n * Use `Breadcrumb` to show the user's position within a page hierarchy and\n * allow navigation to parent pages. On tablet and below, the trail scrolls\n * horizontally with optional edge fade overlays to indicate clipped content.\n * @keywords hierarchy, navigation, path, trail, wayfinding\n */\nexport const Breadcrumb = ({\n links,\n fadeColor,\n fadePosition = \"both\",\n id,\n separatorStyle = \"chevron\",\n className,\n ...otherProps\n}: BreadcrumbProps) => {\n // =========================================================================\n // CONST, STATE, REFS\n // =========================================================================\n const [showFade, setShowFade] = useState<boolean>(false);\n const [showFadeLeft, setShowFadeLeft] = useState<boolean>(false);\n const [showFadeRight, setShowFadeRight] = useState<boolean>(false);\n const shouldShowFadeLeft =\n fadePosition === \"left\" || fadePosition === \"both\";\n const shouldShowFadeRight =\n fadePosition === \"right\" || fadePosition === \"both\";\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLUListElement>(null);\n const fadeLeftRef = useRef<HTMLDivElement>(null);\n const fadeRightRef = useRef<HTMLDivElement>(null);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n\n const tabletBreakpoint = parsePxOrRemValue(\n useResolvedBreakpointToken(Breakpoint[\"lg-max\"])\n );\n\n // =============================================================================\n // FADE COLOR CALCULATION\n // =============================================================================\n let fadeColorSet: FadeColorSet;\n\n if (Array.isArray(fadeColor) && fadeColor.length > 0) {\n fadeColorSet = {\n left: fadeColor,\n right: fadeColor,\n };\n } else if (fadeColor) {\n fadeColorSet = fadeColor as FadeColorSet;\n } else {\n fadeColorSet = {\n left: undefined,\n right: undefined,\n };\n }\n\n // =============================================================================\n // CSS VARIABLES\n // =============================================================================\n useApplyStyle(fadeLeftRef, {\n [styles.tokens.fade.backgroundColor]: fadeColorSet?.left?.join(\", \"),\n });\n\n useApplyStyle(fadeRightRef, {\n [styles.tokens.fade.backgroundColor]: fadeColorSet?.right?.join(\", \"),\n });\n\n const onResize = useEvent(() => {\n const content = contentRef.current;\n const wrapper = wrapperRef.current;\n\n if (\n content &&\n wrapper &&\n links &&\n links.length > 1 &&\n window.innerWidth <= tabletBreakpoint\n ) {\n content.scrollLeft = content.scrollWidth - wrapper.offsetWidth;\n }\n });\n\n const handleShowFadeToggle = useEvent(() => {\n const nextShowFade = window.innerWidth <= tabletBreakpoint;\n setShowFade(nextShowFade);\n\n const content = contentRef.current;\n const wrapper = wrapperRef.current;\n if (content && wrapper && nextShowFade) {\n if (content.scrollWidth > wrapper.offsetWidth) {\n // set 1px margin of error to handle sub-pixel differences\n setShowFadeLeft(content.scrollLeft >= 1);\n setShowFadeRight(\n content.scrollWidth - content.scrollLeft - 1 >\n wrapper.offsetWidth\n );\n return;\n }\n }\n\n setShowFadeLeft(false);\n setShowFadeRight(false);\n });\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEventListener(\"resize\", handleShowFadeToggle);\n useEventListener(\"scroll\", handleShowFadeToggle, contentRef.current);\n\n useIsomorphicLayoutEffect(() => {\n onResize();\n handleShowFadeToggle();\n }, [onResize, handleShowFadeToggle, tabletBreakpoint]);\n\n // To scroll left when wrapper resizes\n useResizeDetector({\n onResize,\n targetRef: wrapperRef,\n refreshMode: \"debounce\",\n refreshRate: 50,\n skipOnMount: true,\n });\n\n // =========================================================================\n // RENDER\n // =========================================================================\n if (!links) return null;\n\n const renderLinks = () => {\n return links.map((link, index) => {\n let element: JSX.Element;\n if (!link.children) {\n return null;\n }\n\n if (index === links.length - 1 || !link.href) {\n element = (\n <Typography.BodyMD\n weight=\"semibold\"\n as=\"span\"\n className={styles.currentLabel}\n >\n {link.children}\n </Typography.BodyMD>\n );\n } else {\n element = (\n <Typography.LinkMD\n {...link}\n weight=\"semibold\"\n underlineStyle=\"none\"\n className={styles.previousLink}\n />\n );\n }\n\n return (\n <li\n key={index}\n className={styles.item}\n {...(index === links.length - 1 && {\n \"aria-current\": \"page\",\n })}\n >\n {element}\n {index < links.length - 1 &&\n (separatorStyle === \"chevron\" ? (\n <ChevronRightIcon\n aria-hidden\n className={styles.caret}\n />\n ) : (\n <Typography.BodyMD\n inline\n aria-hidden\n className={styles.slash}\n >\n /\n </Typography.BodyMD>\n ))}\n </li>\n );\n });\n };\n\n const renderFade = () => {\n return (\n <>\n {showFadeLeft && shouldShowFadeLeft && (\n <div\n ref={fadeLeftRef}\n className={clsx(styles.fade, styles.fadeLeft)}\n />\n )}\n {showFadeRight && shouldShowFadeRight && (\n <div\n ref={fadeRightRef}\n className={clsx(styles.fade, styles.fadeRight)}\n />\n )}\n </>\n );\n };\n\n return (\n <div\n ref={wrapperRef}\n id={id || \"breadcrumb\"}\n className={clsx(styles.wrapper, className)}\n {...otherProps}\n >\n <nav aria-label=\"Breadcrumb\">\n <ul ref={contentRef} className={styles.content}>\n {renderLinks()}\n </ul>\n </nav>\n {showFade && renderFade()}\n </div>\n );\n};\n"],"names":["_a","links","fadeColor","fadePosition","id","separatorStyle","className","otherProps","__rest","showFade","setShowFade","useState","showFadeLeft","setShowFadeLeft","showFadeRight","setShowFadeRight","shouldShowFadeLeft","shouldShowFadeRight","wrapperRef","useRef","contentRef","fadeLeftRef","fadeRightRef","tabletBreakpoint","parsePxOrRemValue","useResolvedBreakpointToken","Breakpoint","fadeColorSet","Array","isArray","length","left","right","undefined","useApplyStyle","styles.tokens","fade","backgroundColor","_b","join","_c","onResize","useEvent","content","current","wrapper","window","innerWidth","scrollLeft","scrollWidth","offsetWidth","handleShowFadeToggle","nextShowFade","useEventListener","useIsomorphicLayoutEffect","useResizeDetector","targetRef","refreshMode","refreshRate","skipOnMount","_jsxs","ref","clsx","styles.wrapper","children","_jsx","styles.content","map","link","index","element","href","Typography","LinkMD","Object","assign","weight","underlineStyle","styles.previousLink","BodyMD","as","styles.currentLabel","styles.item","ChevronRightIcon","styles.caret","inline","styles.slash","_Fragment","styles.fade","styles.fadeLeft","styles.fadeRight"],"mappings":"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"}
1
+ {"version":3,"file":"breadcrumb.js","sources":["../../../src/breadcrumb/breadcrumb.tsx"],"sourcesContent":["import { ChevronRightIcon } from \"@lifesg/react-icons/chevron-right\";\nimport clsx from \"clsx\";\nimport { useRef } from \"react\";\n\nimport { FadeWrapper, type FadeWrapperRef } from \"../shared/fade-wrapper\";\nimport { parsePxOrRemValue, useResolvedBreakpointToken } from \"../theme\";\nimport { Breakpoint } from \"../theme/tokens\";\nimport { Typography } from \"../typography\";\nimport { useEvent, useIsomorphicLayoutEffect } from \"../util\";\nimport * as styles from \"./breadcrumb.styles\";\nimport type { BreadcrumbProps } from \"./types\";\n\n// @catalog\n/**\n * Horizontal breadcrumb navigation trail.\n *\n * Use `Breadcrumb` to show the user's position within a page hierarchy and\n * allow navigation to parent pages. On tablet and below, the trail scrolls\n * horizontally with optional edge fade overlays to indicate clipped content.\n * @keywords hierarchy, navigation, path, trail, wayfinding\n */\nexport const Breadcrumb = ({\n links,\n fadeColor,\n fadePosition = \"both\",\n id,\n separatorStyle = \"chevron\",\n className,\n ...otherProps\n}: BreadcrumbProps) => {\n // =========================================================================\n // CONST, STATE, REFS\n // =========================================================================\n const fadeWrapperRef = useRef<FadeWrapperRef>(null);\n\n const tabletBreakpoint = parsePxOrRemValue(\n useResolvedBreakpointToken(Breakpoint[\"lg-max\"])\n );\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleResize = useEvent(() => {\n if (\n links &&\n links.length > 1 &&\n window.innerWidth <= tabletBreakpoint\n ) {\n fadeWrapperRef.current?.scrollToEnd();\n }\n });\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useIsomorphicLayoutEffect(() => {\n handleResize();\n }, [handleResize, tabletBreakpoint]);\n\n // =========================================================================\n // RENDER\n // =========================================================================\n if (!links) return null;\n\n const renderLinks = () => {\n return links.map((link, index) => {\n let element: JSX.Element;\n if (!link.children) {\n return null;\n }\n\n if (index === links.length - 1 || !link.href) {\n element = (\n <Typography.BodyMD\n weight=\"semibold\"\n as=\"span\"\n className={styles.currentLabel}\n >\n {link.children}\n </Typography.BodyMD>\n );\n } else {\n element = (\n <Typography.LinkMD\n {...link}\n weight=\"semibold\"\n underlineStyle=\"none\"\n className={styles.previousLink}\n />\n );\n }\n\n return (\n <li\n key={index}\n className={styles.item}\n {...(index === links.length - 1 && {\n \"aria-current\": \"page\",\n })}\n >\n {element}\n {index < links.length - 1 &&\n (separatorStyle === \"chevron\" ? (\n <ChevronRightIcon\n aria-hidden\n className={styles.caret}\n />\n ) : (\n <Typography.BodyMD\n inline\n aria-hidden\n className={styles.slash}\n >\n /\n </Typography.BodyMD>\n ))}\n </li>\n );\n });\n };\n\n return (\n <FadeWrapper\n ref={fadeWrapperRef}\n id={id || \"breadcrumb\"}\n className={clsx(styles.wrapper, className)}\n fadeColor={fadeColor}\n fadePosition={fadePosition}\n onResize={handleResize}\n {...otherProps}\n >\n <nav aria-label=\"Breadcrumb\">\n <ul className={styles.content}>{renderLinks()}</ul>\n </nav>\n </FadeWrapper>\n );\n};\n"],"names":["_a","links","fadeColor","fadePosition","id","separatorStyle","className","otherProps","__rest","fadeWrapperRef","useRef","tabletBreakpoint","parsePxOrRemValue","useResolvedBreakpointToken","Breakpoint","handleResize","useEvent","length","window","innerWidth","current","scrollToEnd","useIsomorphicLayoutEffect","_jsx","FadeWrapper","Object","assign","ref","clsx","styles.wrapper","onResize","children","styles.content","map","link","index","element","href","Typography","LinkMD","weight","underlineStyle","styles.previousLink","BodyMD","as","styles.currentLabel","_jsxs","styles.item","ChevronRightIcon","styles.caret","inline","styles.slash"],"mappings":"uiCAqB2BA,QAAAC,MACvBA,EAAKC,UACLA,EAASC,aACTA,EAAe,OAAMC,GACrBA,EAAEC,eACFA,EAAiB,UAASC,UAC1BA,GAASN,EACNO,EAAUC,EAAAA,OAAAR,EAPU,wEAYvB,MAAMS,EAAiBC,EAAAA,OAAuB,MAExCC,EAAmBC,EAAAA,kBACrBC,EAAAA,2BAA2BC,EAAAA,WAAW,YAMpCC,EAAeC,EAAAA,UAAS,WAEtBf,GACAA,EAAMgB,OAAS,GACfC,OAAOC,YAAcR,IAEC,QAAtBX,EAAAS,EAAeW,eAAO,IAAApB,GAAAA,EAAEqB,cAC5B,IAaJ,GAPAC,EAAAA,2BAA0B,KACtBP,GAAc,GACf,CAACA,EAAcJ,KAKbV,EAAO,OAAO,KA2DnB,OACIsB,EAAAA,IAACC,EAAAA,YAAWC,OAAAC,OAAA,CACRC,IAAKlB,EACLL,GAAIA,GAAM,aACVE,UAAWsB,EAAAA,QAAKC,EAAAA,QAAgBvB,GAChCJ,UAAWA,EACXC,aAAcA,EACd2B,SAAUf,GACNR,EAAU,CAAAwB,SAEdR,EAAAA,IAAA,MAAA,CAAA,aAAgB,aAAYQ,SACxBR,EAAAA,UAAIjB,UAAW0B,UAAcD,SAnE9B9B,EAAMgC,KAAI,CAACC,EAAMC,KACpB,IAAIC,EACJ,OAAKF,EAAKH,UAeNK,EAXAD,IAAUlC,EAAMgB,OAAS,GAAMiB,EAAKG,KAYhCd,EAAAA,IAACe,EAAAA,WAAWC,OAAMd,OAAAC,OAAA,GACVQ,EAAI,CACRM,OAAO,WACPC,eAAe,OACfnC,UAAWoC,EAAAA,gBAdfnB,EAAAA,IAACe,EAAAA,WAAWK,OAAM,CACdH,OAAO,WACPI,GAAG,OACHtC,UAAWuC,EAAAA,aAAmBd,SAE7BG,EAAKH,WAede,OAAA,KAAArB,OAAAC,OAAA,CAEIpB,UAAWyC,EAAAA,MACNZ,IAAUlC,EAAMgB,OAAS,GAAK,CAC/B,eAAgB,QAClB,CAAAc,SAAA,CAEDK,EACAD,EAAQlC,EAAMgB,OAAS,IACA,YAAnBZ,EACGkB,MAACyB,EAAAA,iBAAgB,CAAA,eAAA,EAEb1C,UAAW2C,EAAAA,QAGf1B,EAAAA,IAACe,EAAAA,WAAWK,QACRO,QAAM,EAAA,eAAA,EAEN5C,UAAW6C,EAAAA,yBAjBlBhB,IA1BF,IAgDF,UAkBC"}
@@ -1,2 +1,2 @@
1
- "use strict";require("./breadcrumb.styles_1nl4aua.css");exports.caret="co9wmrd",exports.content="c10gatr7",exports.currentLabel="c1mfqdvn",exports.fade="fbyhxo7",exports.fadeLeft="f1xa0lk7",exports.fadeRight="f1oxmxuo",exports.item="ikhkv84",exports.previousLink="pm022dc",exports.slash="spyv6ve",exports.tokens={fade:{backgroundColor:"--fds-internal-breadcrumb-fade-backgroundColor"}},exports.wrapper="wcpniaz";
1
+ "use strict";require("./breadcrumb.styles_1blzn8n.css");exports.caret="c1xa0lk7",exports.content="c10gatr7",exports.currentLabel="ckhkv84",exports.item="ibyhxo7",exports.previousLink="po9wmrd",exports.slash="s1oxmxuo",exports.wrapper="wcpniaz";
2
2
  //# sourceMappingURL=breadcrumb.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumb.styles.js","sources":["../../../src/breadcrumb/breadcrumb.styles.ts"],"sourcesContent":["import { css } from \"@linaria/core\";\n\nimport { Colour, Font, MediaQuery, Spacing } from \"../theme\";\n\nexport const tokens = {\n fade: {\n backgroundColor: \"--fds-internal-breadcrumb-fade-backgroundColor\",\n },\n};\n\n// =============================================================================\n// STYLE CLASSES\n// =============================================================================\nexport const wrapper = css`\n position: relative;\n width: 100%;\n z-index: 1;\n margin: ${Spacing[\"spacing-32\"]} 0;\n\n ${MediaQuery.MaxWidth.xl} {\n margin: ${Spacing[\"spacing-24\"]} 0;\n }\n\n ${MediaQuery.MaxWidth.lg} {\n margin: ${Spacing[\"spacing-16\"]} 0;\n }\n`;\n\nexport const content = css`\n display: inline-flex;\n width: 100%;\n flex-wrap: wrap;\n white-space: nowrap;\n margin-left: calc(${Spacing[\"spacing-8\"]} * -1);\n font-size: ${Font.Spec[\"body-size-md\"]};\n overflow-x: scroll;\n overflow-y: hidden;\n scrollbar-width: none; /* Firefox */\n -ms-overflow-style: none; /* IE 10+ */\n &::-webkit-scrollbar {\n display: none; /* Chrome/Safari/Webkit */\n }\n\n ${MediaQuery.MaxWidth.lg} {\n flex-wrap: nowrap;\n }\n`;\n\nexport const fade = css`\n ${tokens.fade.backgroundColor}: initial;\n width: ${Spacing[\"spacing-64\"]};\n height: calc(1lh + ${Spacing[\"spacing-4\"]});\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n pointer-events: none;\n`;\n\nexport const fadeLeft = css`\n ${MediaQuery.MaxWidth.lg} {\n left: calc(${Spacing[\"spacing-8\"]} * -1);\n background-image: linear-gradient(\n to right,\n var(${tokens.fade.backgroundColor}, ${Colour.bg}),\n rgba(255, 255, 255, 0.001)\n );\n }\n`;\n\nexport const fadeRight = css`\n ${MediaQuery.MaxWidth.lg} {\n right: ${Spacing[\"spacing-8\"]};\n background-image: linear-gradient(\n to left,\n var(${tokens.fade.backgroundColor}, ${Colour.bg}),\n rgba(255, 255, 255, 0.001)\n );\n }\n`;\n\nexport const item = css`\n display: flex;\n flex-direction: row;\n align-items: center;\n line-height: inherit;\n font-size: inherit;\n`;\n\nexport const caret = css`\n height: 1em;\n width: 1em;\n color: ${Colour[\"icon-subtle\"]};\n`;\n\nexport const slash = css`\n display: inline-block;\n color: ${Colour[\"text-subtlest\"]};\n`;\n\nexport const currentLabel = css`\n margin: ${Spacing[\"spacing-8\"]} !important;\n`;\n\nexport const previousLink = css`\n margin: ${Spacing[\"spacing-8\"]} !important;\n`;\n"],"names":["fade","backgroundColor"],"mappings":"gGAwFkB,0BA5DE,gCAuEK,wBAnDR,2BAUI,6BAWC,wBAWL,+BAuBQ,wBATP,yBA1FI,CAClBA,KAAM,CACFC,gBAAiB,mEAOL"}
1
+ {"version":3,"file":"breadcrumb.styles.js","sources":["../../../src/breadcrumb/breadcrumb.styles.ts"],"sourcesContent":["import { css } from \"@linaria/core\";\n\nimport { Colour, Font, MediaQuery, Spacing } from \"../theme\";\n\n// =============================================================================\n// STYLE CLASSES\n// =============================================================================\nexport const wrapper = css`\n z-index: 1;\n margin: ${Spacing[\"spacing-32\"]} 0;\n\n ${MediaQuery.MaxWidth.xl} {\n margin: ${Spacing[\"spacing-24\"]} 0;\n }\n\n ${MediaQuery.MaxWidth.lg} {\n margin: ${Spacing[\"spacing-16\"]} 0;\n }\n\n [data-id=\"left-fade\"],\n [data-id=\"right-fade\"] {\n height: calc(1lh + ${Spacing[\"spacing-4\"]});\n top: 50%;\n transform: translateY(-50%);\n }\n`;\n\nexport const content = css`\n display: inline-flex;\n width: 100%;\n flex-wrap: wrap;\n white-space: nowrap;\n margin-left: calc(${Spacing[\"spacing-8\"]} * -1);\n font-size: ${Font.Spec[\"body-size-md\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n flex-wrap: nowrap;\n }\n`;\n\nexport const item = css`\n display: flex;\n flex-direction: row;\n align-items: center;\n line-height: inherit;\n font-size: inherit;\n`;\n\nexport const caret = css`\n height: 1em;\n width: 1em;\n color: ${Colour[\"icon-subtle\"]};\n`;\n\nexport const slash = css`\n display: inline-block;\n color: ${Colour[\"text-subtlest\"]};\n`;\n\nexport const currentLabel = css`\n margin: ${Spacing[\"spacing-8\"]} !important;\n`;\n\nexport const previousLink = css`\n margin: ${Spacing[\"spacing-8\"]} !important;\n`;\n"],"names":[],"mappings":"gGAgDkB,2BArBE,gCAgCK,uBAnBR,+BAuBQ,wBATP,2BA/CE"}
@@ -0,0 +1,7 @@
1
+ @layer fds{.wcpniaz{z-index:1;margin:var(--fds-spacing-32) 0;}:where(body.fds-breakpoint-xl-max) .wcpniaz{margin:var(--fds-spacing-24) 0;}:where(body.fds-breakpoint-lg-max) .wcpniaz{margin:var(--fds-spacing-16) 0;}.wcpniaz [data-id="left-fade"],.wcpniaz [data-id="right-fade"]{height:calc(1lh + var(--fds-spacing-4));top:50%;-webkit-transform:translateY(-50%);-moz-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);}
2
+ .c10gatr7{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;width:100%;-webkit-box-flex-wrap:wrap;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;white-space:nowrap;margin-left:calc(var(--fds-spacing-8) * -1);font-size:var(--fds-font-body-size-md);}:where(body.fds-breakpoint-lg-max) .c10gatr7{-webkit-box-flex-wrap:nowrap;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;}
3
+ .ibyhxo7{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;line-height:inherit;font-size:inherit;}
4
+ .c1xa0lk7{height:1em;width:1em;color:var(--fds-colour-icon-subtle);}
5
+ .s1oxmxuo{display:inline-block;color:var(--fds-colour-text-subtlest);}
6
+ .ckhkv84{margin:var(--fds-spacing-8)!important;}
7
+ .po9wmrd{margin:var(--fds-spacing-8)!important;}}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../_virtual/_tslib.js"),r=require("react/jsx-runtime"),a=require("@floating-ui/react"),i=require("@lifesg/react-icons/cross"),s=require("clsx"),t=require("react"),l=require("../overlay/overlay.js"),n=require("../shared/clickable-icon/clickable-icon.js"),o=require("../typography/index.js");require("../util/calendar-helper.js"),require("../external/dayjs/dayjs.min.js");var c=require("../util/simple-id-generator.js");require("../util/string-helper.js"),require("@react-aria/live-announcer");var u=require("./drawer.styles.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=d(s);exports.Drawer=s=>{var{children:d,heading:g,show:j,onClose:v,onOverlayClick:y,className:f}=s,x=e.__rest(s,["children","heading","show","onClose","onOverlayClick","className"]);const[m,p]=t.useState(j),q=c.useId(),b=t.useRef(null),{context:C,refs:k}=a.useFloating({open:j,onOpenChange:e=>{!e&&v&&v()}}),w=a.useDismiss(C,{escapeKey:!0,outsidePress:!1}),{getFloatingProps:N}=a.useInteractions([w]),{isMounted:F,status:O}=a.useTransitionStatus(C,{duration:800});t.useEffect((()=>{if(!j){const e=setTimeout((()=>p(!1)),800);return()=>clearTimeout(e)}p(!0)}),[j]);return r.jsx(l.Overlay,{show:m,enableOverlayClick:!0,onOverlayClick:y,children:F?r.jsx(a.FloatingFocusManager,{context:C,initialFocus:-1,returnFocus:!0,children:r.jsxs("div",Object.assign({ref:k.setFloating,"data-status":O,"data-testid":"drawer","aria-modal":!0,role:"dialog","aria-labelledby":q,onTransitionEnd:e=>{var r;"visibility"===e.propertyName&&j&&(null===(r=b.current)||void 0===r||r.focus())},className:h.default(u.container,f)},N(),x,{children:[r.jsx("div",{className:u.header,children:r.jsx(o.Typography.HeadingMD,{as:"h2",className:u.heading,id:q,ref:b,tabIndex:-1,weight:"bold",children:g})}),r.jsx("div",{className:u.content,children:d}),r.jsx(n.ClickableIcon,{"aria-label":"Close drawer",onClick:v,focusHighlight:!1,className:u.closeButton,children:r.jsx(i.CrossIcon,{"aria-hidden":!0})})]}))}):void 0})};
1
+ "use strict";var e=require("../_virtual/_tslib.js"),r=require("react/jsx-runtime"),s=require("@floating-ui/react"),i=require("@lifesg/react-icons/cross"),t=require("clsx"),a=require("react"),o=require("../external/react-resize-detector/build/index.esm.js"),l=require("../overlay/overlay.js"),n=require("../shared/clickable-icon/clickable-icon.js");require("../theme/theme-provider/index.js");var u=require("../theme/utils/css-variable.js");require("../theme/theme-provider/context.js"),require("../theme/tokens/border.js");var c=require("../theme/tokens/breakpoint.js");require("../theme/tokens/colour.js"),require("../theme/tokens/font.js"),require("../theme/tokens/media-query.js"),require("../util/calendar-helper.js"),require("../external/dayjs/dayjs.min.js");var d=require("../util/simple-id-generator.js");require("../util/string-helper.js"),require("@react-aria/live-announcer");var h=require("../theme/utils/use-media-query.js"),m=require("../typography/index.js"),j=require("./drawer.styles.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=v(t);exports.Drawer=t=>{var{children:v,heading:q,show:g,onClose:p,onOverlayClick:x,customCallToAction:y,className:k}=t,b=e.__rest(t,["children","heading","show","onClose","onOverlayClick","customCallToAction","className"]);const[C,T]=a.useState(g),[w,N]=a.useState(),O=d.useId(),F=a.useRef(null),{width:R,ref:I}=o.useResizeDetector({refreshMode:"throttle",refreshRate:300,onResize:()=>{const e=F.current;e&&N(e.offsetTop+e.offsetHeight/2)}}),S=u.parsePxOrRemValue(h.useResolvedBreakpointToken(c.Breakpoint["sm-max"])),A=void 0!==R&&R<=S,{context:D,refs:M}=s.useFloating({open:g,onOpenChange:e=>{!e&&p&&p()}}),_=s.useDismiss(D,{escapeKey:!0,outsidePress:!1}),{getFloatingProps:z}=s.useInteractions([_]),{isMounted:B,status:H}=s.useTransitionStatus(D,{duration:800});a.useEffect((()=>{if(!g){const e=setTimeout((()=>T(!1)),800);return()=>clearTimeout(e)}T(!0)}),[g]);return r.jsx(l.Overlay,{show:C,enableOverlayClick:!0,onOverlayClick:x,children:B?r.jsx(s.FloatingFocusManager,{context:D,initialFocus:-1,returnFocus:!0,children:r.jsxs("div",Object.assign({ref:M.setFloating,"data-status":H,"data-testid":"drawer","aria-modal":!0,role:"dialog","aria-labelledby":O,onTransitionEnd:e=>{var r;"visibility"===e.propertyName&&g&&(null===(r=F.current)||void 0===r||r.focus())},className:f.default(j.container,k)},z(),b,{children:[r.jsxs("div",{ref:I,className:f.default(j.header,A&&j.headerStacked),children:[r.jsx(m.Typography.HeadingMD,{as:"h2",className:j.heading,id:O,ref:F,tabIndex:-1,weight:"bold",children:q}),y?r.jsx("div",{className:f.default(j.callToAction,A&&j.callToActionStacked),children:y}):null]}),r.jsx("div",{className:j.content,children:v}),r.jsx(n.ClickableIcon,{"aria-label":"Close drawer",onClick:p,focusHighlight:!1,className:j.closeButton,style:void 0!==w?{top:w,transform:"translateY(-50%)"}:void 0,children:r.jsx(i.CrossIcon,{"aria-hidden":!0})})]}))}):void 0})};
2
2
  //# sourceMappingURL=drawer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.js","sources":["../../../src/drawer/drawer.tsx"],"sourcesContent":["import {\n FloatingFocusManager,\n useDismiss,\n useFloating,\n useInteractions,\n useTransitionStatus,\n} from \"@floating-ui/react\";\nimport { CrossIcon } from \"@lifesg/react-icons/cross\";\nimport clsx from \"clsx\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport { Overlay } from \"../overlay\";\nimport { ClickableIcon } from \"../shared/clickable-icon\";\nimport { Typography } from \"../typography\";\nimport { useId } from \"../util\";\nimport * as styles from \"./drawer.styles\";\nimport type { DrawerProps } from \"./types\";\n\n// @catalog\n/**\n * A slide-in panel that overlays the page content.\n *\n * Use `Drawer` to surface supplementary content or navigation options without\n * navigating away from the current page. Focus is trapped inside the dialog\n * while it is open and returns to the triggering element on close.\n * @keywords overlay, panel, side panel, tray\n */\nexport const Drawer = ({\n children,\n heading,\n show,\n onClose,\n onOverlayClick,\n className,\n ...otherProps\n}: DrawerProps) => {\n // =========================================================================\n // CONST, STATE, REFS\n // =========================================================================\n const [showOverlay, setShowOverlay] = useState(show);\n const id = useId();\n const initialFocusRef = useRef<HTMLHeadingElement>(null);\n\n // =========================================================================\n // FLOATING UI CONFIG\n // =========================================================================\n const { context, refs } = useFloating({\n open: show,\n onOpenChange: (open) => {\n if (!open && onClose) {\n onClose();\n }\n },\n });\n\n const dismiss = useDismiss(context, {\n escapeKey: true,\n outsidePress: false, // defer to Overlay click\n });\n\n const { getFloatingProps } = useInteractions([dismiss]);\n\n const { isMounted, status } = useTransitionStatus(context, {\n duration: 800,\n });\n\n // =========================================================================\n // EFFECTS\n // =========================================================================\n useEffect(() => {\n if (!show) {\n const timer = setTimeout(() => setShowOverlay(false), 800);\n return () => clearTimeout(timer);\n } else {\n setShowOverlay(true);\n }\n }, [show]);\n\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handleDialogVisibility = (e: React.TransitionEvent) => {\n if (e.propertyName === \"visibility\" && show) {\n // focus the first element so that the screenreader enters the dialog\n initialFocusRef.current?.focus();\n }\n };\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n return (\n <Overlay\n show={showOverlay}\n enableOverlayClick\n onOverlayClick={onOverlayClick}\n >\n {isMounted ? (\n <FloatingFocusManager\n context={context}\n initialFocus={-1}\n returnFocus={true}\n >\n <div\n ref={refs.setFloating}\n data-status={status}\n data-testid=\"drawer\"\n aria-modal\n role=\"dialog\"\n aria-labelledby={id}\n onTransitionEnd={handleDialogVisibility}\n className={clsx(styles.container, className)}\n {...getFloatingProps()}\n {...otherProps}\n >\n <div className={styles.header}>\n <Typography.HeadingMD\n as=\"h2\"\n className={styles.heading}\n id={id}\n ref={initialFocusRef}\n tabIndex={-1}\n weight=\"bold\"\n >\n {heading}\n </Typography.HeadingMD>\n </div>\n <div className={styles.content}>{children}</div>\n <ClickableIcon\n aria-label=\"Close drawer\"\n onClick={onClose}\n focusHighlight={false}\n className={styles.closeButton}\n >\n <CrossIcon aria-hidden />\n </ClickableIcon>\n </div>\n </FloatingFocusManager>\n ) : undefined}\n </Overlay>\n );\n};\n"],"names":["_a","children","heading","show","onClose","onOverlayClick","className","otherProps","__rest","showOverlay","setShowOverlay","useState","id","useId","initialFocusRef","useRef","context","refs","useFloating","open","onOpenChange","dismiss","useDismiss","escapeKey","outsidePress","getFloatingProps","useInteractions","isMounted","status","useTransitionStatus","duration","useEffect","timer","setTimeout","clearTimeout","_jsx","Overlay","enableOverlayClick","FloatingFocusManager","initialFocus","returnFocus","_jsxs","ref","setFloating","role","onTransitionEnd","e","propertyName","current","focus","clsx","styles.container","styles.header","Typography","HeadingMD","as","styles.heading","tabIndex","weight","styles.content","ClickableIcon","onClick","focusHighlight","styles.closeButton","CrossIcon","undefined"],"mappings":"8oBA2BuBA,IAAA,IAAAC,SACnBA,EAAQC,QACRA,EAAOC,KACPA,EAAIC,QACJA,EAAOC,eACPA,EAAcC,UACdA,GAASN,EACNO,EAAUC,EAAAA,OAAAR,EAPM,sEAYnB,MAAOS,EAAaC,GAAkBC,EAAAA,SAASR,GACzCS,EAAKC,EAAAA,QACLC,EAAkBC,EAAAA,OAA2B,OAK7CC,QAAEA,EAAOC,KAAEA,GAASC,cAAY,CAClCC,KAAMhB,EACNiB,aAAeD,KACNA,GAAQf,GACTA,GACJ,IAIFiB,EAAUC,EAAAA,WAAWN,EAAS,CAChCO,WAAW,EACXC,cAAc,KAGZC,iBAAEA,GAAqBC,kBAAgB,CAACL,KAExCM,UAAEA,EAASC,OAAEA,GAAWC,EAAAA,oBAAoBb,EAAS,CACvDc,SAAU,MAMdC,EAAAA,WAAU,KACN,IAAK5B,EAAM,CACP,MAAM6B,EAAQC,YAAW,IAAMvB,GAAe,IAAQ,KACtD,MAAO,IAAMwB,aAAaF,EAC9B,CACItB,GAAe,EACnB,GACD,CAACP,IAeJ,OACIgC,MAACC,EAAAA,QAAO,CACJjC,KAAMM,EACN4B,oBAAkB,EAClBhC,eAAgBA,EAAcJ,SAE7B0B,EACGQ,EAAAA,IAACG,uBAAoB,CACjBtB,QAASA,EACTuB,cAAc,EACdC,aAAa,EAAIvC,SAEjBwC,EAAAA,0BACIC,IAAKzB,EAAK0B,YAAW,cACRf,EAAM,cACP,yBAEZgB,KAAK,SAAQ,kBACIhC,EACjBiC,gBA7BYC,UACL,eAAnBA,EAAEC,cAAiC5C,IAEZ,QAAvBH,EAAAc,EAAgBkC,eAAO,IAAAhD,GAAAA,EAAEiD,QAC7B,EA0BgB3C,UAAW4C,EAAAA,QAAKC,EAAAA,UAAkB7C,IAC9BmB,IACAlB,EAAU,CAAAN,SAAA,CAEdkC,EAAAA,IAAA,MAAA,CAAK7B,UAAW8C,EAAAA,OAAanD,SACzBkC,MAACkB,EAAAA,WAAWC,UAAS,CACjBC,GAAG,KACHjD,UAAWkD,UACX5C,GAAIA,EACJ8B,IAAK5B,EACL2C,UAAU,EACVC,OAAO,gBAENxD,MAGTiC,EAAAA,WAAK7B,UAAWqD,EAAAA,QAAc1D,SAAGA,IACjCkC,EAAAA,IAACyB,EAAAA,cAAa,CAAA,aACC,eACXC,QAASzD,EACT0D,gBAAgB,EAChBxD,UAAWyD,cAAkB9D,SAE7BkC,EAAAA,IAAC6B,YAAS,CAAA,eAAA,iBAItBC,GACE"}
1
+ {"version":3,"file":"drawer.js","sources":["../../../src/drawer/drawer.tsx"],"sourcesContent":["import {\n FloatingFocusManager,\n useDismiss,\n useFloating,\n useInteractions,\n useTransitionStatus,\n} from \"@floating-ui/react\";\nimport { CrossIcon } from \"@lifesg/react-icons/cross\";\nimport clsx from \"clsx\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useResizeDetector } from \"react-resize-detector\";\n\nimport { Overlay } from \"../overlay\";\nimport { ClickableIcon } from \"../shared/clickable-icon\";\nimport {\n Breakpoint,\n parsePxOrRemValue,\n useResolvedBreakpointToken,\n} from \"../theme\";\nimport { Typography } from \"../typography\";\nimport { useId } from \"../util\";\nimport * as styles from \"./drawer.styles\";\nimport type { DrawerProps } from \"./types\";\n\n// @catalog\n/**\n * A slide-in panel that overlays the page content.\n *\n * Use `Drawer` to surface supplementary content or navigation options without\n * navigating away from the current page. Focus is trapped inside the dialog\n * while it is open and returns to the triggering element on close.\n * @keywords overlay, panel, side panel, tray\n */\nexport const Drawer = ({\n children,\n heading,\n show,\n onClose,\n onOverlayClick,\n customCallToAction,\n className,\n ...otherProps\n}: DrawerProps) => {\n // =========================================================================\n // CONST, STATE, REFS\n // =========================================================================\n const [showOverlay, setShowOverlay] = useState(show);\n // vertical centre of the heading, used to align the (last-in-DOM,\n // absolutely positioned) close button with it\n const [closeButtonTop, setCloseButtonTop] = useState<number>();\n const id = useId();\n const initialFocusRef = useRef<HTMLHeadingElement>(null);\n // Observe the header (whose size tracks the drawer's actual width, which\n // consumers may override) to drive layout in one pass: the width decides\n // call-to-action stacking, and each resize re-centres the close button on\n // the heading. offsetTop/offsetHeight are relative to the drawer (the\n // positioned ancestor), so they share the close button's coordinate space.\n const { width: headerWidth, ref: headerRef } =\n useResizeDetector<HTMLDivElement>({\n refreshMode: \"throttle\",\n refreshRate: 300,\n onResize: () => {\n const headingEl = initialFocusRef.current;\n if (headingEl) {\n setCloseButtonTop(\n headingEl.offsetTop + headingEl.offsetHeight / 2\n );\n }\n },\n });\n // stack the call-to-action below the heading once the drawer is too narrow\n // to fit both on one line\n const stackWidth = parsePxOrRemValue(\n useResolvedBreakpointToken(Breakpoint[\"sm-max\"])\n );\n const stackCallToAction =\n headerWidth !== undefined && headerWidth <= stackWidth;\n\n // =========================================================================\n // FLOATING UI CONFIG\n // =========================================================================\n const { context, refs } = useFloating({\n open: show,\n onOpenChange: (open) => {\n if (!open && onClose) {\n onClose();\n }\n },\n });\n\n const dismiss = useDismiss(context, {\n escapeKey: true,\n outsidePress: false, // defer to Overlay click\n });\n\n const { getFloatingProps } = useInteractions([dismiss]);\n\n const { isMounted, status } = useTransitionStatus(context, {\n duration: 800,\n });\n\n // =========================================================================\n // EFFECTS\n // =========================================================================\n useEffect(() => {\n if (!show) {\n const timer = setTimeout(() => setShowOverlay(false), 800);\n return () => clearTimeout(timer);\n } else {\n setShowOverlay(true);\n }\n }, [show]);\n\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handleDialogVisibility = (e: React.TransitionEvent) => {\n if (e.propertyName === \"visibility\" && show) {\n // focus the first element so that the screenreader enters the dialog\n initialFocusRef.current?.focus();\n }\n };\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n return (\n <Overlay\n show={showOverlay}\n enableOverlayClick\n onOverlayClick={onOverlayClick}\n >\n {isMounted ? (\n <FloatingFocusManager\n context={context}\n initialFocus={-1}\n returnFocus={true}\n >\n <div\n ref={refs.setFloating}\n data-status={status}\n data-testid=\"drawer\"\n aria-modal\n role=\"dialog\"\n aria-labelledby={id}\n onTransitionEnd={handleDialogVisibility}\n className={clsx(styles.container, className)}\n {...getFloatingProps()}\n {...otherProps}\n >\n <div\n ref={headerRef}\n className={clsx(\n styles.header,\n stackCallToAction && styles.headerStacked\n )}\n >\n <Typography.HeadingMD\n as=\"h2\"\n className={styles.heading}\n id={id}\n ref={initialFocusRef}\n tabIndex={-1}\n weight=\"bold\"\n >\n {heading}\n </Typography.HeadingMD>\n {customCallToAction ? (\n <div\n className={clsx(\n styles.callToAction,\n stackCallToAction &&\n styles.callToActionStacked\n )}\n >\n {customCallToAction}\n </div>\n ) : null}\n </div>\n <div className={styles.content}>{children}</div>\n {/* Rendered last so assistive tech reaches the heading\n and content before the close button; centred against\n the header via its measured height. */}\n <ClickableIcon\n aria-label=\"Close drawer\"\n onClick={onClose}\n focusHighlight={false}\n className={styles.closeButton}\n style={\n closeButtonTop !== undefined\n ? {\n top: closeButtonTop,\n transform: \"translateY(-50%)\",\n }\n : undefined\n }\n >\n <CrossIcon aria-hidden />\n </ClickableIcon>\n </div>\n </FloatingFocusManager>\n ) : undefined}\n </Overlay>\n );\n};\n"],"names":["_a","children","heading","show","onClose","onOverlayClick","customCallToAction","className","otherProps","__rest","showOverlay","setShowOverlay","useState","closeButtonTop","setCloseButtonTop","id","useId","initialFocusRef","useRef","width","headerWidth","ref","headerRef","useResizeDetector","refreshMode","refreshRate","onResize","headingEl","current","offsetTop","offsetHeight","stackWidth","parsePxOrRemValue","useResolvedBreakpointToken","Breakpoint","stackCallToAction","undefined","context","refs","useFloating","open","onOpenChange","dismiss","useDismiss","escapeKey","outsidePress","getFloatingProps","useInteractions","isMounted","status","useTransitionStatus","duration","useEffect","timer","setTimeout","clearTimeout","_jsx","Overlay","enableOverlayClick","FloatingFocusManager","initialFocus","returnFocus","_jsxs","Object","assign","setFloating","role","onTransitionEnd","e","propertyName","focus","clsx","styles.container","styles.header","styles.headerStacked","Typography","HeadingMD","as","styles.heading","tabIndex","weight","styles.callToAction","styles.callToActionStacked","styles.content","ClickableIcon","onClick","focusHighlight","styles.closeButton","style","top","transform","CrossIcon"],"mappings":"+kCAiCuBA,IAAA,IAAAC,SACnBA,EAAQC,QACRA,EAAOC,KACPA,EAAIC,QACJA,EAAOC,eACPA,EAAcC,mBACdA,EAAkBC,UAClBA,GAASP,EACNQ,EAAUC,EAAAA,OAAAT,EARM,2FAanB,MAAOU,EAAaC,GAAkBC,EAAAA,SAAST,IAGxCU,EAAgBC,GAAqBF,aACtCG,EAAKC,EAAAA,QACLC,EAAkBC,EAAAA,OAA2B,OAM3CC,MAAOC,EAAaC,IAAKC,GAC7BC,EAAAA,kBAAkC,CAC9BC,YAAa,WACbC,YAAa,IACbC,SAAU,KACN,MAAMC,EAAYV,EAAgBW,QAC9BD,GACAb,EACIa,EAAUE,UAAYF,EAAUG,aAAe,EAEvD,IAKNC,EAAaC,EAAAA,kBACfC,EAAAA,2BAA2BC,EAAAA,WAAW,YAEpCC,OACcC,IAAhBhB,GAA6BA,GAAeW,GAK1CM,QAAEA,EAAOC,KAAEA,GAASC,cAAY,CAClCC,KAAMrC,EACNsC,aAAeD,KACNA,GAAQpC,GACTA,GACJ,IAIFsC,EAAUC,EAAAA,WAAWN,EAAS,CAChCO,WAAW,EACXC,cAAc,KAGZC,iBAAEA,GAAqBC,kBAAgB,CAACL,KAExCM,UAAEA,EAASC,OAAEA,GAAWC,EAAAA,oBAAoBb,EAAS,CACvDc,SAAU,MAMdC,EAAAA,WAAU,KACN,IAAKjD,EAAM,CACP,MAAMkD,EAAQC,YAAW,IAAM3C,GAAe,IAAQ,KACtD,MAAO,IAAM4C,aAAaF,EAC9B,CACI1C,GAAe,EACnB,GACD,CAACR,IAeJ,OACIqD,EAAAA,IAACC,UAAO,CACJtD,KAAMO,EACNgD,oBAAkB,EAClBrD,eAAgBA,WAEf2C,EACGQ,MAACG,EAAAA,qBAAoB,CACjBtB,QAASA,EACTuB,gBACAC,aAAa,EAAI5D,SAEjB6D,EAAAA,KAAA,MAAAC,OAAAC,OAAA,CACI3C,IAAKiB,EAAK2B,YAAW,cACRhB,EAAM,cACP,SAAQ,cAAA,EAEpBiB,KAAK,2BACYnD,EACjBoD,gBA7BYC,UACL,eAAnBA,EAAEC,cAAiClE,IAEZ,QAAvBH,EAAAiB,EAAgBW,eAAO,IAAA5B,GAAAA,EAAEsE,QAC7B,EA0BgB/D,UAAWgE,EAAAA,QAAKC,EAAAA,UAAkBjE,IAC9BuC,IACAtC,EAAU,CAAAP,SAAA,CAEd6D,OAAA,MAAA,CACIzC,IAAKC,EACLf,UAAWgE,UACPE,EAAAA,OACAtC,GAAqBuC,iBACxBzE,SAAA,CAEDuD,EAAAA,IAACmB,aAAWC,UAAS,CACjBC,GAAG,KACHtE,UAAWuE,UACX/D,GAAIA,EACJM,IAAKJ,EACL8D,UAAU,EACVC,OAAO,OAAM/E,SAEZC,IAEJI,EACGkD,EAAAA,IAAA,MAAA,CACIjD,UAAWgE,UACPU,EAAAA,aACA9C,GACI+C,EAAAA,qBACPjF,SAEAK,IAEL,QAERkD,EAAAA,WAAKjD,UAAW4E,EAAAA,QAAclF,SAAGA,IAIjCuD,EAAAA,IAAC4B,EAAAA,cAAa,CAAA,aACC,eACXC,QAASjF,EACTkF,gBAAgB,EAChB/E,UAAWgF,EAAAA,YACXC,WACuBpD,IAAnBvB,EACM,CACI4E,IAAK5E,EACL6E,UAAW,yBAEftD,EAASnC,SAGnBuD,EAAAA,IAACmC,EAAAA,2CAIbvD,GACE"}
@@ -1,2 +1,2 @@
1
- "use strict";require("./drawer.styles_94hx3y.css");exports.closeButton="c1njxz6r",exports.container="c1agands",exports.content="c2k10hw",exports.header="h1kc1wos",exports.heading="hcrz6mg";
1
+ "use strict";require("./drawer.styles_a4bwe0.css");exports.callToAction="ccrz6mg",exports.callToActionStacked="c2k10hw",exports.closeButton="cu0iil5",exports.container="c1agands",exports.content="csm06gm",exports.header="h1kc1wos",exports.headerStacked="h1njxz6r",exports.heading="hdpobta";
2
2
  //# sourceMappingURL=drawer.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.styles.js","sources":["../../../src/drawer/drawer.styles.ts"],"sourcesContent":["import { css } from \"@linaria/core\";\n\nimport {\n Border,\n Colour,\n Font,\n MediaQuery,\n Motion,\n Radius,\n Shadow,\n Spacing,\n} from \"../theme\";\n\nexport const container = css`\n position: fixed;\n top: 0;\n\n display: flex;\n flex-direction: column;\n\n height: 100%;\n width: 40%;\n overflow: hidden;\n\n background-color: ${Colour[\"bg\"]};\n box-shadow: ${Shadow[\"lg-subtle\"]};\n border-top-left-radius: ${Radius[\"md\"]};\n border-bottom-left-radius: ${Radius[\"md\"]};\n\n transition-property: right, visibility;\n\n &[data-status=\"initial\"] {\n right: -100%;\n visibility: hidden;\n }\n\n &[data-status=\"open\"] {\n transition-duration: ${Motion[\"duration-800\"]};\n transition-timing-function: ${Motion[\"ease-entrance\"]};\n right: 0;\n visibility: visible;\n }\n\n &[data-status=\"close\"] {\n transition-duration: ${Motion[\"duration-800\"]};\n transition-timing-function: ${Motion[\"ease-exit\"]};\n right: -100%;\n visibility: hidden;\n }\n\n ${MediaQuery.MaxWidth.xl} {\n width: 50%;\n min-width: 700px;\n }\n\n ${MediaQuery.MaxWidth.lg} {\n width: 100%;\n min-width: unset;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n`;\n\nexport const header = css`\n top: 0;\n display: flex;\n align-items: center;\n gap: ${Spacing[\"spacing-16\"]};\n padding: ${Spacing[\"spacing-32\"]} ${Spacing[\"spacing-16\"]}\n ${Spacing[\"spacing-16\"]}\n calc(${Font.Spec[\"heading-lh-md\"]} + ${Spacing[\"spacing-32\"]});\n background-color: ${Colour[\"bg\"]};\n border-bottom: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n gap: ${Spacing[\"spacing-8\"]};\n padding: ${Spacing[\"spacing-32\"]} ${Spacing[\"spacing-20\"]}\n ${Spacing[\"spacing-16\"]}\n calc(${Font.Spec[\"heading-lh-md\"]} + ${Spacing[\"spacing-24\"]});\n }\n`;\n\nexport const closeButton = css`\n color: ${Colour[\"icon\"]};\n padding: 0;\n position: absolute;\n top: ${Spacing[\"spacing-32\"]};\n left: ${Spacing[\"spacing-16\"]};\n &:active,\n &:focus {\n color: ${Colour[\"icon-hover\"]};\n }\n\n svg {\n height: ${Font.Spec[\"heading-lh-md\"]};\n width: ${Font.Spec[\"heading-lh-md\"]};\n }\n`;\n\nexport const heading = css`\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n`;\n\nexport const content = css`\n flex: 1;\n overflow-y: auto;\n`;\n"],"names":[],"mappings":"6FAkFwB,6BArEF,2BA4FF,yBA1CD,2BAoCC"}
1
+ {"version":3,"file":"drawer.styles.js","sources":["../../../src/drawer/drawer.styles.ts"],"sourcesContent":["import { css } from \"@linaria/core\";\n\nimport {\n Border,\n Colour,\n Font,\n MediaQuery,\n Motion,\n Radius,\n Shadow,\n Spacing,\n} from \"../theme\";\n\nexport const container = css`\n position: fixed;\n top: 0;\n\n display: flex;\n flex-direction: column;\n\n height: 100%;\n width: 40%;\n overflow: hidden;\n\n background-color: ${Colour[\"bg\"]};\n box-shadow: ${Shadow[\"lg-subtle\"]};\n border-top-left-radius: ${Radius[\"md\"]};\n border-bottom-left-radius: ${Radius[\"md\"]};\n\n transition-property: right, visibility;\n\n &[data-status=\"initial\"] {\n right: -100%;\n visibility: hidden;\n }\n\n &[data-status=\"open\"] {\n transition-duration: ${Motion[\"duration-800\"]};\n transition-timing-function: ${Motion[\"ease-entrance\"]};\n right: 0;\n visibility: visible;\n }\n\n &[data-status=\"close\"] {\n transition-duration: ${Motion[\"duration-800\"]};\n transition-timing-function: ${Motion[\"ease-exit\"]};\n right: -100%;\n visibility: hidden;\n }\n\n ${MediaQuery.MaxWidth.xl} {\n width: 50%;\n min-width: 700px;\n }\n\n ${MediaQuery.MaxWidth.lg} {\n width: 100%;\n min-width: unset;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n`;\n\nexport const header = css`\n top: 0;\n display: flex;\n align-items: center;\n gap: ${Spacing[\"spacing-16\"]};\n padding: ${Spacing[\"spacing-32\"]} ${Spacing[\"spacing-16\"]}\n ${Spacing[\"spacing-16\"]}\n calc(${Font.Spec[\"heading-lh-md\"]} + ${Spacing[\"spacing-32\"]});\n background-color: ${Colour[\"bg\"]};\n border-bottom: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n gap: ${Spacing[\"spacing-8\"]};\n padding: ${Spacing[\"spacing-32\"]} ${Spacing[\"spacing-20\"]}\n ${Spacing[\"spacing-16\"]}\n calc(${Font.Spec[\"heading-lh-md\"]} + ${Spacing[\"spacing-24\"]});\n }\n`;\n\n// Stack the call-to-action below the heading when the drawer is too narrow\n// to fit both on one line.\nexport const headerStacked = css`\n flex-direction: column;\n align-items: stretch;\n gap: ${Spacing[\"spacing-16\"]};\n`;\n\nexport const callToAction = css`\n display: flex;\n margin-left: auto;\n`;\n\n// When stacked, flush left so the buttons line up with the heading (the\n// header's left padding already clears the close icon).\nexport const callToActionStacked = css`\n margin-left: 0;\n`;\n\nexport const closeButton = css`\n color: ${Colour[\"icon\"]};\n padding: 0;\n position: absolute;\n top: ${Spacing[\"spacing-32\"]};\n left: ${Spacing[\"spacing-16\"]};\n &:active,\n &:focus {\n color: ${Colour[\"icon-hover\"]};\n }\n\n svg {\n height: ${Font.Spec[\"heading-lh-md\"]};\n width: ${Font.Spec[\"heading-lh-md\"]};\n }\n`;\n\nexport const heading = css`\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n`;\n\nexport const content = css`\n flex: 1;\n overflow-y: auto;\n`;\n"],"names":[],"mappings":"8FA0FyB,sCAOO,8BAIR,4BAxFF,2BA+GF,yBA7DD,iCAqBO,2BAkCN"}
@@ -1,5 +1,8 @@
1
1
  @layer fds{.c1agands{position:fixed;top:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;height:100%;width:40%;overflow:hidden;background-color:var(--fds-colour-bg);box-shadow:var(--fds-shadow-lg-subtle);border-top-left-radius:var(--fds-radius-md);border-bottom-left-radius:var(--fds-radius-md);transition-property:right,visibility;}.c1agands[data-status="initial"]{right:-100%;visibility:hidden;}.c1agands[data-status="open"]{transition-duration:var(--fds-motion-duration-800);transition-timing-function:var(--fds-motion-timing-ease-entrance);right:0;visibility:visible;}.c1agands[data-status="close"]{transition-duration:var(--fds-motion-duration-800);transition-timing-function:var(--fds-motion-timing-ease-exit);right:-100%;visibility:hidden;}:where(body.fds-breakpoint-xl-max) .c1agands{width:50%;min-width:700px;}:where(body.fds-breakpoint-lg-max) .c1agands{width:100%;min-width:unset;border-top-left-radius:0;border-bottom-left-radius:0;}
2
2
  .h1kc1wos{top:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:var(--fds-spacing-16);padding:var(--fds-spacing-32) var(--fds-spacing-16) var(--fds-spacing-16) calc(var(--fds-font-heading-lh-md) + var(--fds-spacing-32));background-color:var(--fds-colour-bg);border-bottom:var(--fds-border-width-010) var(--fds-border-style-solid) var(--fds-colour-border);}:where(body.fds-breakpoint-lg-max) .h1kc1wos{gap:var(--fds-spacing-8);padding:var(--fds-spacing-32) var(--fds-spacing-20) var(--fds-spacing-16) calc(var(--fds-font-heading-lh-md) + var(--fds-spacing-24));}
3
- .c1njxz6r{color:var(--fds-colour-icon);padding:0;position:absolute;top:var(--fds-spacing-32);left:var(--fds-spacing-16);}.c1njxz6r:active,.c1njxz6r:focus{color:var(--fds-colour-icon-hover);}.c1njxz6r svg{height:var(--fds-font-heading-lh-md);width:var(--fds-font-heading-lh-md);}
4
- .hcrz6mg{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
5
- .c2k10hw{-webkit-flex:1;-ms-flex:1;flex:1;overflow-y:auto;}}
3
+ .h1njxz6r{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;gap:var(--fds-spacing-16);}
4
+ .ccrz6mg{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin-left:auto;}
5
+ .c2k10hw{margin-left:0;}
6
+ .cu0iil5{color:var(--fds-colour-icon);padding:0;position:absolute;top:var(--fds-spacing-32);left:var(--fds-spacing-16);}.cu0iil5:active,.cu0iil5:focus{color:var(--fds-colour-icon-hover);}.cu0iil5 svg{height:var(--fds-font-heading-lh-md);width:var(--fds-font-heading-lh-md);}
7
+ .hdpobta{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
8
+ .csm06gm{-webkit-flex:1;-ms-flex:1;flex:1;overflow-y:auto;}}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../_virtual/_tslib.js"),r=require("react/jsx-runtime"),i=require("clsx"),s=require("../dashed-border/dashed-border.js"),t=require("../markup/markup.js");require("../theme/theme-provider/index.js"),require("react"),require("../theme/theme-provider/context.js");var a=require("../theme/tokens/border.js"),d=require("../theme/tokens/colour.js");require("../theme/tokens/font.js"),require("../theme/tokens/media-query.js");var l=require("../theme/tokens/radius.js");require("../util/calendar-helper.js"),require("../external/dayjs/dayjs.min.js"),require("../util/simple-id-generator.js"),require("../util/string-helper.js"),require("@react-aria/live-announcer"),require("../theme/utils/use-media-query.js");var n=require("./file-download.styles.js"),o=require("./file-list-card/file-list-card.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(i);exports.FileDownload=({id:i,fileItems:u,title:m,description:j,onDownload:h,"data-testid":q,className:p,styleType:x="bordered"})=>{const f=r=>e.__awaiter(void 0,void 0,void 0,(function*(){h&&(yield h(r))})),v="bordered"===x;return r.jsxs(s.DashedBorder,{id:i?`${i}-file-download`:"file-download",className:c.default(n.container,v&&n.containerBordered,p),"data-testid":q,enabled:v,thickness:a.Border["width-040"],radius:l.Radius.sm,colour:d.Colour.border,children:[(m||j)&&r.jsxs("div",{className:n.textContainer,children:[m?"string"==typeof m?r.jsx("p",{className:n.title,children:m}):r.jsx(t.Markup,{className:n.titleContainer,baseTextSize:"heading-xs",children:m}):null,j?"string"==typeof j?r.jsx("p",{className:n.description,children:j}):r.jsx(t.Markup,{className:n.descriptionContainer,baseTextSize:"body-md",children:j}):null]}),r.jsx("ul",{className:n.listWrapper,children:u&&u.length>0&&u.map((e=>r.jsx(o.FileListCard,{fileItem:e,onDownload:f},e.id)))})]})};
1
+ "use strict";var e=require("../_virtual/_tslib.js"),r=require("react/jsx-runtime"),i=require("clsx"),s=require("../dashed-border/dashed-border.js"),t=require("../markup/markup.js");require("../theme/theme-provider/index.js"),require("react"),require("../theme/theme-provider/context.js");var a=require("../theme/tokens/border.js"),d=require("../theme/tokens/colour.js");require("../theme/tokens/font.js"),require("../theme/tokens/media-query.js");var l=require("../theme/tokens/radius.js");require("../util/calendar-helper.js"),require("../external/dayjs/dayjs.min.js"),require("../util/simple-id-generator.js"),require("../util/string-helper.js"),require("@react-aria/live-announcer"),require("../theme/utils/use-media-query.js");var n=require("./file-download.styles.js"),o=require("./file-list-card/file-list-card.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(i);exports.FileDownload=({id:i,fileItems:u,title:m,description:j,onDownload:h,onClick:q,"data-testid":p,className:x,styleType:f="bordered"})=>{const v=r=>e.__awaiter(void 0,void 0,void 0,(function*(){h&&(yield h(r))})),b="bordered"===f;return r.jsxs(s.DashedBorder,{id:i?`${i}-file-download`:"file-download",className:c.default(n.container,b&&n.containerBordered,x),"data-testid":p,enabled:b,thickness:a.Border["width-040"],radius:l.Radius.sm,colour:d.Colour.border,children:[(m||j)&&r.jsxs("div",{className:n.textContainer,children:[m?"string"==typeof m?r.jsx("p",{className:n.title,children:m}):r.jsx(t.Markup,{className:n.titleContainer,baseTextSize:"heading-xs",children:m}):null,j?"string"==typeof j?r.jsx("p",{className:n.description,children:j}):r.jsx(t.Markup,{className:n.descriptionContainer,baseTextSize:"body-md",children:j}):null]}),r.jsx("ul",{className:n.listWrapper,children:u&&u.length>0&&u.map((e=>r.jsx(o.FileListCard,{fileItem:e,onDownload:v,onClick:q},e.id)))})]})};
2
2
  //# sourceMappingURL=file-download.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-download.js","sources":["../../../src/file-download/file-download.tsx"],"sourcesContent":["import clsx from \"clsx\";\n\nimport { DashedBorder } from \"../dashed-border\";\nimport { Markup } from \"../markup\";\nimport { Border, Colour, Radius } from \"../theme\";\nimport * as styles from \"./file-download.styles\";\nimport { FileListCard } from \"./file-list-card\";\nimport type { FileDownloadProps, FileItemDownloadProps } from \"./types\";\n\n// @catalog\n/**\n * Displays a list of downloadable files, optionally grouped under a title and description.\n *\n * Use `FileDownload` to present one or more files that users can download individually.\n * Each file item renders as a card with file metadata and a download trigger.\n * @keywords attachment, document, download, file\n */\nexport const FileDownload = ({\n id,\n fileItems,\n title,\n description,\n onDownload,\n \"data-testid\": testId,\n className,\n styleType = \"bordered\",\n}: FileDownloadProps) => {\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handleDownloadItem = async (item: FileItemDownloadProps) => {\n if (onDownload) {\n await onDownload(item);\n }\n };\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n const renderTitle = () => {\n if (!title) {\n return null;\n }\n\n if (typeof title === \"string\") {\n return <p className={styles.title}>{title}</p>;\n }\n\n return (\n <Markup className={styles.titleContainer} baseTextSize=\"heading-xs\">\n {title}\n </Markup>\n );\n };\n\n const renderDescription = () => {\n if (!description) {\n return null;\n }\n\n if (typeof description === \"string\") {\n return <p className={styles.description}>{description}</p>;\n }\n\n return (\n <Markup\n className={styles.descriptionContainer}\n baseTextSize=\"body-md\"\n >\n {description}\n </Markup>\n );\n };\n\n const isBordered = styleType === \"bordered\";\n\n return (\n <DashedBorder\n id={id ? `${id}-file-download` : \"file-download\"}\n className={clsx(\n styles.container,\n isBordered && styles.containerBordered,\n className\n )}\n data-testid={testId}\n enabled={isBordered}\n thickness={Border[\"width-040\"]}\n radius={Radius[\"sm\"]}\n colour={Colour[\"border\"]}\n >\n {(title || description) && (\n <div className={styles.textContainer}>\n {renderTitle()}\n {renderDescription()}\n </div>\n )}\n <ul className={styles.listWrapper}>\n {fileItems &&\n fileItems.length > 0 &&\n fileItems.map((item) => (\n <FileListCard\n key={item.id}\n fileItem={item}\n onDownload={handleDownloadItem}\n />\n ))}\n </ul>\n </DashedBorder>\n );\n};\n"],"names":["id","fileItems","title","description","onDownload","testId","className","styleType","handleDownloadItem","item","__awaiter","isBordered","_jsxs","DashedBorder","clsx","styles.container","styles.containerBordered","enabled","thickness","Border","radius","Radius","colour","Colour","children","styles.textContainer","_jsx","styles.title","Markup","styles.titleContainer","baseTextSize","styles.description","styles.descriptionContainer","styles.listWrapper","length","map","FileListCard","fileItem"],"mappings":"85BAiB4B,EACxBA,KACAC,YACAC,QACAC,cACAC,aACA,cAAeC,EACfC,YACAC,YAAY,eAKZ,MAAMC,EAA4BC,GAA+BC,EAAAA,eAAA,OAAA,OAAA,GAAA,YACzDN,UACMA,EAAWK,GAEzB,IAwCME,EAA2B,aAAdJ,EAEnB,OACIK,OAACC,EAAAA,cACGb,GAAIA,EAAK,GAAGA,kBAAqB,gBACjCM,UAAWQ,EAAAA,QACPC,EAAAA,UACAJ,GAAcK,oBACdV,GACH,cACYD,EACbY,QAASN,EACTO,UAAWC,EAAAA,OAAO,aAClBC,OAAQC,EAAAA,OAAW,GACnBC,OAAQC,EAAAA,OAAe,OAACC,SAAA,EAEtBtB,GAASC,IACPS,EAAAA,YAAKN,UAAWmB,EAAAA,wBAnDnBvB,EAIgB,iBAAVA,EACAwB,EAAAA,IAAA,IAAA,CAAGpB,UAAWqB,EAAAA,MAAYH,SAAGtB,IAIpCwB,EAAAA,IAACE,SAAM,CAACtB,UAAWuB,EAAAA,eAAuBC,aAAa,sBAClD5B,IATE,KAeNC,EAIsB,iBAAhBA,EACAuB,EAAAA,IAAA,IAAA,CAAGpB,UAAWyB,EAAAA,YAAkBP,SAAGrB,IAI1CuB,EAAAA,IAACE,SAAM,CACHtB,UAAW0B,EAAAA,qBACXF,aAAa,mBAEZ3B,IAZE,QAuCPuB,EAAAA,UAAIpB,UAAW2B,EAAAA,qBACVhC,GACGA,EAAUiC,OAAS,GACnBjC,EAAUkC,KAAK1B,GACXiB,EAAAA,IAACU,EAAAA,aAAY,CAETC,SAAU5B,EACVL,WAAYI,GAFPC,EAAKT,UAMf"}
1
+ {"version":3,"file":"file-download.js","sources":["../../../src/file-download/file-download.tsx"],"sourcesContent":["import clsx from \"clsx\";\n\nimport { DashedBorder } from \"../dashed-border\";\nimport { Markup } from \"../markup\";\nimport { Border, Colour, Radius } from \"../theme\";\nimport * as styles from \"./file-download.styles\";\nimport { FileListCard } from \"./file-list-card\";\nimport type { FileDownloadProps, FileItemDownloadProps } from \"./types\";\n\n// @catalog\n/**\n * Displays a list of downloadable files, optionally grouped under a title and description.\n *\n * Use `FileDownload` to present one or more files that users can download individually.\n * Each file item renders as a card with file metadata and a download trigger.\n * @keywords attachment, document, download, file\n */\nexport const FileDownload = ({\n id,\n fileItems,\n title,\n description,\n onDownload,\n onClick,\n \"data-testid\": testId,\n className,\n styleType = \"bordered\",\n}: FileDownloadProps) => {\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handleDownloadItem = async (item: FileItemDownloadProps) => {\n if (onDownload) {\n await onDownload(item);\n }\n };\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n const renderTitle = () => {\n if (!title) {\n return null;\n }\n\n if (typeof title === \"string\") {\n return <p className={styles.title}>{title}</p>;\n }\n\n return (\n <Markup className={styles.titleContainer} baseTextSize=\"heading-xs\">\n {title}\n </Markup>\n );\n };\n\n const renderDescription = () => {\n if (!description) {\n return null;\n }\n\n if (typeof description === \"string\") {\n return <p className={styles.description}>{description}</p>;\n }\n\n return (\n <Markup\n className={styles.descriptionContainer}\n baseTextSize=\"body-md\"\n >\n {description}\n </Markup>\n );\n };\n\n const isBordered = styleType === \"bordered\";\n\n return (\n <DashedBorder\n id={id ? `${id}-file-download` : \"file-download\"}\n className={clsx(\n styles.container,\n isBordered && styles.containerBordered,\n className\n )}\n data-testid={testId}\n enabled={isBordered}\n thickness={Border[\"width-040\"]}\n radius={Radius[\"sm\"]}\n colour={Colour[\"border\"]}\n >\n {(title || description) && (\n <div className={styles.textContainer}>\n {renderTitle()}\n {renderDescription()}\n </div>\n )}\n <ul className={styles.listWrapper}>\n {fileItems &&\n fileItems.length > 0 &&\n fileItems.map((item) => (\n <FileListCard\n key={item.id}\n fileItem={item}\n onDownload={handleDownloadItem}\n onClick={onClick}\n />\n ))}\n </ul>\n </DashedBorder>\n );\n};\n"],"names":["id","fileItems","title","description","onDownload","onClick","testId","className","styleType","handleDownloadItem","item","__awaiter","isBordered","_jsxs","DashedBorder","clsx","styles.container","styles.containerBordered","enabled","thickness","Border","radius","Radius","colour","Colour","children","styles.textContainer","_jsx","styles.title","Markup","styles.titleContainer","baseTextSize","styles.description","styles.descriptionContainer","styles.listWrapper","length","map","FileListCard","fileItem"],"mappings":"85BAiB4B,EACxBA,KACAC,YACAC,QACAC,cACAC,aACAC,UACA,cAAeC,EACfC,YACAC,YAAY,eAKZ,MAAMC,EAA4BC,GAA+BC,EAAAA,eAAA,OAAA,OAAA,GAAA,YACzDP,UACMA,EAAWM,GAEzB,IAwCME,EAA2B,aAAdJ,EAEnB,OACIK,OAACC,EAAAA,cACGd,GAAIA,EAAK,GAAGA,kBAAqB,gBACjCO,UAAWQ,EAAAA,QACPC,EAAAA,UACAJ,GAAcK,oBACdV,GACH,cACYD,EACbY,QAASN,EACTO,UAAWC,EAAAA,OAAO,aAClBC,OAAQC,EAAAA,OAAW,GACnBC,OAAQC,EAAAA,OAAe,OAACC,SAAA,EAEtBvB,GAASC,IACPU,EAAAA,YAAKN,UAAWmB,EAAAA,wBAnDnBxB,EAIgB,iBAAVA,EACAyB,EAAAA,IAAA,IAAA,CAAGpB,UAAWqB,EAAAA,MAAYH,SAAGvB,IAIpCyB,EAAAA,IAACE,SAAM,CAACtB,UAAWuB,EAAAA,eAAuBC,aAAa,sBAClD7B,IATE,KAeNC,EAIsB,iBAAhBA,EACAwB,EAAAA,IAAA,IAAA,CAAGpB,UAAWyB,EAAAA,YAAkBP,SAAGtB,IAI1CwB,EAAAA,IAACE,SAAM,CACHtB,UAAW0B,EAAAA,qBACXF,aAAa,mBAEZ5B,IAZE,QAuCPwB,EAAAA,UAAIpB,UAAW2B,EAAAA,qBACVjC,GACGA,EAAUkC,OAAS,GACnBlC,EAAUmC,KAAK1B,GACXiB,EAAAA,IAACU,eAAY,CAETC,SAAU5B,EACVN,WAAYK,EACZJ,QAASA,GAHJK,EAAKV,UAOf"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),i=require("@lifesg/react-icons"),t=require("@lifesg/react-icons/exclamation-circle-fill"),a=require("clsx"),s=require("react"),n=require("../../button/button.js"),l=require("../../file-upload/helper.js"),c=require("../../shared/image-with-fallback/image-with-fallback.js");require("../../theme/theme-provider/index.js"),require("../../theme/theme-provider/context.js"),require("../../theme/tokens/border.js"),require("../../theme/tokens/colour.js"),require("../../theme/tokens/font.js"),require("../../theme/tokens/media-query.js"),require("../../util/calendar-helper.js"),require("../../external/dayjs/dayjs.min.js"),require("../../util/simple-id-generator.js");var o=require("../../util/string-helper.js");require("@react-aria/live-announcer");var d=require("../../theme/utils/use-media-query.js"),u=require("./file-list-card.styles.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=m(a);const j=s.memo((({fileItem:a,onDownload:m})=>{const{id:j,name:x,size:g,errorMessage:f,thumbnailImageDataUrl:v,truncateText:q=!0,ready:b=!0}=a,[N,p]=s.useState(!1),[S,y]=s.useState(!1),w=l.FileUploadHelper.formatFileSizeDisplay(g),F=d.useMaxWidthMediaQuery("sm"),[I,k]=s.useState(),C=s.useRef(null);s.useEffect((()=>{C.current&&k(F?E(x):x)}),[x,F]);const E=e=>{if(!q)return e;const r=C&&C.current?C.current.getBoundingClientRect().width:0;return o.StringHelper.truncateTwoLines(e,r,16,1.5)},M=()=>r.jsxs(r.Fragment,{children:[r.jsx("div",{className:u.itemNameText,ref:C,children:I}),S&&r.jsxs("div",{className:u.desktopErrorMessage,children:[r.jsx(t.ExclamationCircleFillIcon,{className:u.errorIcon}),f||"Something went wrong"]})]});return r.jsx("li",{className:u.item,"data-testid":j,children:r.jsxs("div",{className:h.default(u.box,S&&u.boxError),onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(b&&!N){p(!0);try{y(!1),yield m(a)}catch(e){y(!0)}finally{p(!1)}}})),children:[(()=>{let e;var i;return v?(i=v,e=r.jsxs(r.Fragment,{children:[r.jsx("div",{className:u.thumbnailContainer,"data-testid":`${j}-thumbnail`,children:r.jsx(c.ImageWithFallback,{className:u.thumbnail,"data-testid":`${j}-thumbnail-image`,src:i})}),r.jsxs("div",{className:u.extendedNameSection,children:[r.jsx("div",{className:u.nameSection,children:M()}),r.jsx("div",{className:u.fileSizeSection,children:w||"-"}),S&&r.jsxs("div",{className:u.mobileErrorMessage,children:[r.jsx(t.ExclamationCircleFillIcon,{className:u.errorIcon}),f||"Something went wrong"]})]})]})):e=r.jsxs(r.Fragment,{children:[r.jsx("div",{className:u.nameSection,children:M()}),r.jsx("div",{className:u.fileSizeSection,children:w||"-"}),S&&r.jsxs("div",{className:u.mobileErrorMessage,children:[r.jsx(t.ExclamationCircleFillIcon,{className:u.errorIcon}),f||"Something went wrong"]})]}),r.jsx("div",{className:h.default(u.contentSection,!!v&&u.contentSectionHasThumbnail),children:e})})(),r.jsx("div",{className:u.actionContainer,children:r.jsx(n.Button,{className:u.iconButton,"data-testid":`${j}-download-button`,type:"button",styleType:"light",sizeType:"small","aria-label":`download ${x}`,loading:N||!b,icon:r.jsx(i.DownloadIcon,{})})})]})})}));exports.FileListCard=j;
1
+ "use strict";var e=require("../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("@lifesg/react-icons"),r=require("@lifesg/react-icons/exclamation-circle-fill"),a=require("clsx"),s=require("react"),l=require("../../button/button.js"),n=require("../../file-upload/helper.js"),o=require("../../shared/accessibility/index.js"),c=require("../../shared/image-with-fallback/image-with-fallback.js");require("../../theme/theme-provider/index.js"),require("../../theme/theme-provider/context.js"),require("../../theme/tokens/border.js"),require("../../theme/tokens/colour.js"),require("../../theme/tokens/font.js"),require("../../theme/tokens/media-query.js"),require("../../util/calendar-helper.js"),require("../../external/dayjs/dayjs.min.js"),require("../../util/simple-id-generator.js");var d=require("../../util/string-helper.js");require("@react-aria/live-announcer");var u=require("../../theme/utils/use-media-query.js"),m=require("./file-list-card.styles.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var j=h(a);const x=s.memo((({fileItem:a,onDownload:h,onClick:x})=>{const{id:p,name:b,mimeType:f,size:g,errorMessage:q,thumbnailImageDataUrl:y,truncateText:v=!0,ready:N=!0,clickLabel:k}=a,[w,S]=s.useState(!1),[C,F]=s.useState(!1),I=n.FileUploadHelper.formatFileSizeDisplay(g),T=n.FileUploadHelper.resolveThumbnailDisplay(f,y),D="none"!==T.type,E=u.useMaxWidthMediaQuery("sm"),[H,_]=s.useState(),M=s.useRef(null);s.useEffect((()=>{M.current&&_(E?L(b):b)}),[b,E]);const U=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(N&&!w){S(!0);try{F(!1),yield h(a)}catch(e){F(!0)}finally{S(!1)}}})),$=()=>{N&&(x?x(a):U())},z=e=>{e.stopPropagation(),$()},B=e=>{e.stopPropagation(),U()},L=e=>{if(!v)return e;const i=M&&M.current?M.current.getBoundingClientRect().width:0;return d.StringHelper.truncateTwoLines(e,i,16,1.5)},P=()=>{if("none"===T.type)return null;const e="pdf-icon"===T.type;return i.jsx("div",{className:m.thumbnailContainer,"data-testid":`${p}-thumbnail`,children:i.jsx(c.ImageWithFallback,{className:j.default(m.thumbnail,e&&m.thumbnailPdf),"data-testid":`${p}-thumbnail-image`,src:e?n.FileUploadHelper.PDF_ICON_URL:T.src})})},R=()=>i.jsxs(i.Fragment,{children:[i.jsx("div",{className:m.nameSection,children:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:m.itemNameText,ref:M,children:H}),C&&i.jsxs("div",{className:m.desktopErrorMessage,children:[i.jsx(r.ExclamationCircleFillIcon,{className:m.errorIcon}),q||"Something went wrong"]})]})}),i.jsx("div",{className:m.fileSizeSection,children:I||"-"}),C&&i.jsxs("div",{className:m.mobileErrorMessage,children:[i.jsx(r.ExclamationCircleFillIcon,{className:m.errorIcon}),q||"Something went wrong"]})]});return i.jsx("li",{className:m.item,"data-testid":p,children:i.jsxs("div",{className:j.default(m.box,C&&m.boxError),onClick:$,children:[i.jsxs("div",{className:j.default(m.contentSection,D&&m.contentSectionHasThumbnail),children:[P(),D?i.jsx("div",{className:m.extendedNameSection,children:R()}):R()]}),x?i.jsx(o.VisuallyHidden,{children:i.jsx("button",{type:"button",className:m.cardButton,"data-testid":`${p}-card-button`,"aria-label":null!=k?k:b,disabled:!N,onClick:z})}):null,i.jsx("div",{className:m.actionContainer,children:i.jsx(l.Button,{className:m.iconButton,"data-testid":`${p}-download-button`,type:"button",styleType:"light",sizeType:"small","aria-label":`download ${b}`,loading:w||!N,icon:i.jsx(t.DownloadIcon,{}),onClick:B})})]})})}));exports.FileListCard=x;
2
2
  //# sourceMappingURL=file-list-card.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-list-card.js","sources":["../../../../src/file-download/file-list-card/file-list-card.tsx"],"sourcesContent":["import { DownloadIcon } from \"@lifesg/react-icons\";\nimport { ExclamationCircleFillIcon } from \"@lifesg/react-icons/exclamation-circle-fill\";\nimport clsx from \"clsx\";\nimport { memo, useEffect, useRef, useState } from \"react\";\n\nimport { Button } from \"../../button\";\nimport { FileUploadHelper } from \"../../file-upload/helper\";\nimport { ImageWithFallback } from \"../../shared/image-with-fallback/image-with-fallback\";\nimport { useMaxWidthMediaQuery } from \"../../theme\";\nimport { StringHelper } from \"../../util\";\nimport * as styles from \"./file-list-card.styles\";\nimport type { FileListItemProps } from \"./types\";\n\nconst Component = ({ fileItem, onDownload }: FileListItemProps) => {\n // =========================================================================\n // CONST, STATE, REFS\n // =========================================================================\n const {\n id,\n name,\n size,\n errorMessage,\n thumbnailImageDataUrl,\n truncateText = true,\n ready = true,\n } = fileItem;\n\n // Local variables\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [isError, setIsError] = useState<boolean>(false);\n const fileSize = FileUploadHelper.formatFileSizeDisplay(size);\n const isMobile = useMaxWidthMediaQuery(\"sm\");\n const [displayText, setDisplayText] = useState<string>();\n const containerRef = useRef<HTMLDivElement>(null);\n\n // =========================================================================\n // EFFECTS\n // =========================================================================\n useEffect(() => {\n if (!containerRef.current) return;\n if (isMobile) {\n setDisplayText(getTruncatedText(name));\n } else {\n setDisplayText(name);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [name, isMobile]);\n\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handleDownload = async () => {\n if (!ready || isLoading) {\n return;\n }\n\n setIsLoading(true);\n try {\n setIsError(false);\n await onDownload(fileItem);\n } catch {\n setIsError(true);\n } finally {\n setIsLoading(false);\n }\n };\n\n // =========================================================================\n // HELPER FUNCTIONS\n // =========================================================================\n const getTruncatedText = (value: string) => {\n if (!truncateText) return value;\n\n const widthOfElement =\n containerRef && containerRef.current\n ? containerRef.current.getBoundingClientRect().width\n : 0;\n\n return StringHelper.truncateTwoLines(value, widthOfElement, 16, 1.5);\n };\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n const renderNameDescription = () => (\n <>\n <div className={styles.itemNameText} ref={containerRef}>\n {displayText}\n </div>\n {isError && (\n <div className={styles.desktopErrorMessage}>\n <ExclamationCircleFillIcon className={styles.errorIcon} />\n {errorMessage ? errorMessage : \"Something went wrong\"}\n </div>\n )}\n </>\n );\n\n const renderWithThumbnail = (thumbnailSrc: string) => (\n <>\n <div\n className={styles.thumbnailContainer}\n data-testid={`${id}-thumbnail`}\n >\n <ImageWithFallback\n className={styles.thumbnail}\n data-testid={`${id}-thumbnail-image`}\n src={thumbnailSrc}\n />\n </div>\n <div className={styles.extendedNameSection}>\n <div className={styles.nameSection}>\n {renderNameDescription()}\n </div>\n <div className={styles.fileSizeSection}>\n {fileSize ? fileSize : \"-\"}\n </div>\n {isError && (\n <div className={styles.mobileErrorMessage}>\n <ExclamationCircleFillIcon\n className={styles.errorIcon}\n />\n {errorMessage ? errorMessage : \"Something went wrong\"}\n </div>\n )}\n </div>\n </>\n );\n\n const renderDefault = () => (\n <>\n <div className={styles.nameSection}>{renderNameDescription()}</div>\n <div className={styles.fileSizeSection}>\n {fileSize ? fileSize : \"-\"}\n </div>\n {isError && (\n <div className={styles.mobileErrorMessage}>\n <ExclamationCircleFillIcon className={styles.errorIcon} />\n {errorMessage ? errorMessage : \"Something went wrong\"}\n </div>\n )}\n </>\n );\n\n const renderContents = () => {\n let content: JSX.Element;\n\n if (thumbnailImageDataUrl) {\n content = renderWithThumbnail(thumbnailImageDataUrl);\n } else {\n content = renderDefault();\n }\n\n return (\n <div\n className={clsx(\n styles.contentSection,\n !!thumbnailImageDataUrl && styles.contentSectionHasThumbnail\n )}\n >\n {content}\n </div>\n );\n };\n\n const renderActions = () => {\n return (\n <div className={styles.actionContainer}>\n <Button\n className={styles.iconButton}\n data-testid={`${id}-download-button`}\n type=\"button\"\n styleType=\"light\"\n sizeType=\"small\"\n aria-label={`download ${name}`}\n loading={isLoading || !ready}\n icon={<DownloadIcon />}\n />\n </div>\n );\n };\n\n return (\n <li className={styles.item} data-testid={id}>\n <div\n className={clsx(styles.box, isError && styles.boxError)}\n onClick={handleDownload}\n >\n {renderContents()}\n {renderActions()}\n </div>\n </li>\n );\n};\n\nexport const FileListCard = memo(Component);\n"],"names":["FileListCard","memo","fileItem","onDownload","id","name","size","errorMessage","thumbnailImageDataUrl","truncateText","ready","isLoading","setIsLoading","useState","isError","setIsError","fileSize","FileUploadHelper","formatFileSizeDisplay","isMobile","useMaxWidthMediaQuery","displayText","setDisplayText","containerRef","useRef","useEffect","current","getTruncatedText","value","widthOfElement","getBoundingClientRect","width","StringHelper","truncateTwoLines","renderNameDescription","_jsxs","_Fragment","children","_jsx","className","styles.itemNameText","ref","styles.desktopErrorMessage","ExclamationCircleFillIcon","styles.errorIcon","styles.item","clsx","styles.box","styles.boxError","onClick","__awaiter","_a","content","thumbnailSrc","styles.thumbnailContainer","ImageWithFallback","styles.thumbnail","src","styles.extendedNameSection","styles.nameSection","styles.fileSizeSection","styles.mobileErrorMessage","styles.contentSection","styles.contentSectionHasThumbnail","renderContents","styles.actionContainer","Button","styles.iconButton","type","styleType","sizeType","loading","icon","DownloadIcon"],"mappings":"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"}
1
+ {"version":3,"file":"file-list-card.js","sources":["../../../../src/file-download/file-list-card/file-list-card.tsx"],"sourcesContent":["import { DownloadIcon } from \"@lifesg/react-icons\";\nimport { ExclamationCircleFillIcon } from \"@lifesg/react-icons/exclamation-circle-fill\";\nimport clsx from \"clsx\";\nimport { memo, useEffect, useRef, useState } from \"react\";\n\nimport { Button } from \"../../button\";\nimport { FileUploadHelper } from \"../../file-upload/helper\";\nimport { VisuallyHidden } from \"../../shared/accessibility\";\nimport { ImageWithFallback } from \"../../shared/image-with-fallback/image-with-fallback\";\nimport { useMaxWidthMediaQuery } from \"../../theme\";\nimport { StringHelper } from \"../../util\";\nimport * as styles from \"./file-list-card.styles\";\nimport type { FileListItemProps } from \"./types\";\n\nconst Component = ({ fileItem, onDownload, onClick }: FileListItemProps) => {\n // =========================================================================\n // CONST, STATE, REFS\n // =========================================================================\n const {\n id,\n name,\n mimeType,\n size,\n errorMessage,\n thumbnailImageDataUrl,\n truncateText = true,\n ready = true,\n clickLabel,\n } = fileItem;\n\n // Local variables\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [isError, setIsError] = useState<boolean>(false);\n const fileSize = FileUploadHelper.formatFileSizeDisplay(size);\n const thumbnailDisplay = FileUploadHelper.resolveThumbnailDisplay(\n mimeType,\n thumbnailImageDataUrl\n );\n const hasThumbnail = thumbnailDisplay.type !== \"none\";\n const isMobile = useMaxWidthMediaQuery(\"sm\");\n const [displayText, setDisplayText] = useState<string>();\n const containerRef = useRef<HTMLDivElement>(null);\n\n // =========================================================================\n // EFFECTS\n // =========================================================================\n useEffect(() => {\n if (!containerRef.current) return;\n if (isMobile) {\n setDisplayText(getTruncatedText(name));\n } else {\n setDisplayText(name);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [name, isMobile]);\n\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handleDownload = async () => {\n if (!ready || isLoading) {\n return;\n }\n\n setIsLoading(true);\n try {\n setIsError(false);\n await onDownload(fileItem);\n } catch {\n setIsError(true);\n } finally {\n setIsLoading(false);\n }\n };\n\n const handleCardClick = () => {\n if (!ready) {\n return;\n }\n\n if (onClick) {\n onClick(fileItem);\n return;\n }\n\n handleDownload();\n };\n\n const handleCardButtonClick = (\n event: React.MouseEvent<HTMLButtonElement>\n ) => {\n /*\n * The button sits inside the container, which handles clicks too.\n * Without this both handlers fire and the action runs twice.\n */\n event.stopPropagation();\n handleCardClick();\n };\n\n const handleDownloadButtonClick = (\n event: React.MouseEvent<HTMLButtonElement>\n ) => {\n // Same reason: the container's handler must not also run.\n event.stopPropagation();\n handleDownload();\n };\n\n // =========================================================================\n // HELPER FUNCTIONS\n // =========================================================================\n const getTruncatedText = (value: string) => {\n if (!truncateText) return value;\n\n const widthOfElement =\n containerRef && containerRef.current\n ? containerRef.current.getBoundingClientRect().width\n : 0;\n\n return StringHelper.truncateTwoLines(value, widthOfElement, 16, 1.5);\n };\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n const renderNameDescription = () => (\n <>\n <div className={styles.itemNameText} ref={containerRef}>\n {displayText}\n </div>\n {isError && (\n <div className={styles.desktopErrorMessage}>\n <ExclamationCircleFillIcon className={styles.errorIcon} />\n {errorMessage ? errorMessage : \"Something went wrong\"}\n </div>\n )}\n </>\n );\n\n const renderThumbnail = () => {\n if (thumbnailDisplay.type === \"none\") {\n return null;\n }\n\n const isPdfBadge = thumbnailDisplay.type === \"pdf-icon\";\n\n return (\n <div\n className={styles.thumbnailContainer}\n data-testid={`${id}-thumbnail`}\n >\n <ImageWithFallback\n className={clsx(\n styles.thumbnail,\n isPdfBadge && styles.thumbnailPdf\n )}\n data-testid={`${id}-thumbnail-image`}\n src={\n isPdfBadge\n ? FileUploadHelper.PDF_ICON_URL\n : thumbnailDisplay.src\n }\n />\n </div>\n );\n };\n\n const renderNameSizeError = () => (\n <>\n <div className={styles.nameSection}>{renderNameDescription()}</div>\n <div className={styles.fileSizeSection}>\n {fileSize ? fileSize : \"-\"}\n </div>\n {isError && (\n <div className={styles.mobileErrorMessage}>\n <ExclamationCircleFillIcon className={styles.errorIcon} />\n {errorMessage ? errorMessage : \"Something went wrong\"}\n </div>\n )}\n </>\n );\n\n const renderContents = () => (\n <div\n className={clsx(\n styles.contentSection,\n hasThumbnail && styles.contentSectionHasThumbnail\n )}\n >\n {renderThumbnail()}\n {hasThumbnail ? (\n <div className={styles.extendedNameSection}>\n {renderNameSizeError()}\n </div>\n ) : (\n renderNameSizeError()\n )}\n </div>\n );\n\n const renderCardButton = () => {\n if (!onClick) {\n return null;\n }\n\n return (\n <VisuallyHidden>\n <button\n type=\"button\"\n className={styles.cardButton}\n data-testid={`${id}-card-button`}\n aria-label={clickLabel ?? name}\n disabled={!ready}\n onClick={handleCardButtonClick}\n />\n </VisuallyHidden>\n );\n };\n\n const renderActions = () => {\n return (\n <div className={styles.actionContainer}>\n <Button\n className={styles.iconButton}\n data-testid={`${id}-download-button`}\n type=\"button\"\n styleType=\"light\"\n sizeType=\"small\"\n aria-label={`download ${name}`}\n loading={isLoading || !ready}\n icon={<DownloadIcon />}\n onClick={handleDownloadButtonClick}\n />\n </div>\n );\n };\n\n return (\n <li className={styles.item} data-testid={id}>\n <div\n className={clsx(styles.box, isError && styles.boxError)}\n onClick={handleCardClick}\n >\n {renderContents()}\n {renderCardButton()}\n {renderActions()}\n </div>\n </li>\n );\n};\n\nexport const FileListCard = memo(Component);\n"],"names":["FileListCard","memo","fileItem","onDownload","onClick","id","name","mimeType","size","errorMessage","thumbnailImageDataUrl","truncateText","ready","clickLabel","isLoading","setIsLoading","useState","isError","setIsError","fileSize","FileUploadHelper","formatFileSizeDisplay","thumbnailDisplay","resolveThumbnailDisplay","hasThumbnail","type","isMobile","useMaxWidthMediaQuery","displayText","setDisplayText","containerRef","useRef","useEffect","current","getTruncatedText","handleDownload","__awaiter","_a","handleCardClick","handleCardButtonClick","event","stopPropagation","handleDownloadButtonClick","value","widthOfElement","getBoundingClientRect","width","StringHelper","truncateTwoLines","renderThumbnail","isPdfBadge","_jsx","className","styles.thumbnailContainer","children","ImageWithFallback","clsx","styles.thumbnail","styles.thumbnailPdf","src","PDF_ICON_URL","renderNameSizeError","_jsxs","_Fragment","styles.nameSection","styles.itemNameText","ref","styles.desktopErrorMessage","ExclamationCircleFillIcon","styles.errorIcon","styles.fileSizeSection","styles.mobileErrorMessage","styles.item","styles.box","styles.boxError","styles.contentSection","styles.contentSectionHasThumbnail","styles.extendedNameSection","VisuallyHidden","styles.cardButton","disabled","styles.actionContainer","Button","styles.iconButton","styleType","sizeType","loading","icon","DownloadIcon"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- "use strict";require("./file-list-card.styles_18j2gut.css");exports.actionContainer="a1xq0zd",exports.box="b7grm6i",exports.boxError="b1ryf4f4",exports.contentSection="casceiz",exports.contentSectionHasThumbnail="c83cih3",exports.desktopErrorMessage="dga23xt",exports.errorIcon="e4y82lx",exports.extendedNameSection="ethi1vt",exports.fileSizeSection="ff8ofzq",exports.iconButton="i18nltf5",exports.item="ifkrwze",exports.itemNameText="iytzo9z",exports.mobileErrorMessage="m1qdniby",exports.nameSection="n13wqyhg",exports.thumbnail="t4orgj8",exports.thumbnailContainer="tmpqdeo";
1
+ "use strict";require("./file-list-card.styles_lzbqkk.css");exports.actionContainer="a18nltf5",exports.box="b1ryf4f4",exports.boxError="basceiz",exports.cardButton="c7grm6i",exports.contentSection="c83cih3",exports.contentSectionHasThumbnail="c13wqyhg",exports.desktopErrorMessage="d1qdniby",exports.errorIcon="ega23xt",exports.extendedNameSection="ef8ofzq",exports.fileSizeSection="fytzo9z",exports.iconButton="impqdeo",exports.item="ifkrwze",exports.itemNameText="i4y82lx",exports.mobileErrorMessage="m1xq0zd",exports.nameSection="nthi1vt",exports.thumbnail="t96jkl",exports.thumbnailContainer="t4orgj8",exports.thumbnailPdf="t1l7ztkl";
2
2
  //# sourceMappingURL=file-list-card.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-list-card.styles.js","sources":["../../../../src/file-download/file-list-card/file-list-card.styles.ts"],"sourcesContent":["import { css } from \"@linaria/core\";\n\nimport { lineClampCss } from \"../../shared/styles\";\nimport { Border, Colour, Font, MediaQuery, Radius, Spacing } from \"../../theme\";\n\n// =============================================================================\n// STYLING\n// =============================================================================\nexport const item = css`\n display: flex;\n align-items: center;\n\n width: 100%;\n border: none;\n\n &:not(:last-child) {\n margin-bottom: ${Spacing[\"spacing-16\"]};\n }\n`;\n\nexport const box = css`\n display: flex;\n align-items: center;\n\n width: 100%;\n padding: ${Spacing[\"spacing-16\"]} ${Spacing[\"spacing-32\"]};\n cursor: pointer;\n\n background: ${Colour[\"bg-primary-subtlest\"]};\n border: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n border-radius: ${Radius[\"sm\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n padding: ${Spacing[\"spacing-16\"]};\n }\n\n &:hover {\n background: ${Colour[\"bg-hover\"]};\n }\n`;\n\nexport const boxError = css`\n background: ${Colour[\"bg-error\"]};\n border-color: ${Colour[\"border-error\"]};\n\n &:hover {\n background: ${Colour[\"bg-error\"]};\n }\n`;\n\nexport const contentSection = css`\n display: flex;\n flex: 1;\n align-items: center;\n\n ${MediaQuery.MaxWidth.lg} {\n flex-direction: column;\n align-items: flex-start;\n width: 100%;\n }\n`;\n\nexport const contentSectionHasThumbnail = css`\n ${MediaQuery.MaxWidth.lg} {\n flex-direction: row;\n align-items: center;\n }\n`;\n\nexport const nameSection = css`\n display: flex;\n flex: 1;\n flex-direction: column;\n\n width: 100%;\n\n overflow-wrap: break-word;\n word-break: break-all;\n white-space: normal;\n`;\n\nexport const extendedNameSection = css`\n display: flex;\n flex: 1;\n align-items: center;\n\n ${MediaQuery.MaxWidth.lg} {\n flex-direction: column;\n align-items: flex-start;\n width: 100%;\n }\n`;\n\nexport const fileSizeSection = css`\n display: flex;\n justify-content: flex-end;\n\n width: 5rem;\n margin-left: ${Spacing[\"spacing-8\"]};\n\n ${Font[\"body-md-regular\"]}\n color: ${Colour[\"text\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n justify-content: flex-start;\n\n width: 100%;\n margin-left: 0;\n margin-top: ${Spacing[\"spacing-8\"]};\n\n ${lineClampCss(2)}\n }\n`;\n\nexport const itemNameText = css`\n ${Font[\"body-md-regular\"]}\n color: ${Colour[\"text\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n ${lineClampCss(2)}\n }\n`;\n\nexport const errorIcon = css`\n height: 1lh;\n width: 1em;\n flex-shrink: 0;\n color: ${Colour[\"icon-error-strong\"]};\n`;\n\nconst baseErrorMessage = `\n ${Font[\"body-sm-semibold\"]}\n color: ${Colour[\"text-error\"]};\n`;\n\nexport const desktopErrorMessage = css`\n ${baseErrorMessage}\n margin-top: ${Spacing[\"spacing-8\"]};\n display: flex;\n gap: ${Spacing[\"spacing-4\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n display: none;\n visibility: hidden;\n }\n`;\n\nexport const mobileErrorMessage = css`\n ${baseErrorMessage}\n display: none;\n visibility: hidden;\n\n ${MediaQuery.MaxWidth.lg} {\n display: flex;\n gap: ${Spacing[\"spacing-4\"]};\n visibility: visible;\n margin-top: ${Spacing[\"spacing-8\"]};\n }\n`;\n\nexport const actionContainer = css`\n display: flex;\n justify-content: flex-end;\n align-items: center;\n\n margin-left: ${Spacing[\"spacing-32\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n margin-left: ${Spacing[\"spacing-16\"]};\n }\n`;\n\nexport const iconButton = css`\n min-width: unset;\n\n &:not(:last-child) {\n margin-right: ${Spacing[\"spacing-16\"]};\n }\n`;\n\nexport const thumbnailContainer = css`\n width: auto;\n margin-right: ${Spacing[\"spacing-32\"]};\n\n display: flex;\n flex-shrink: 0;\n flex-direction: column;\n justify-content: center;\n\n ${MediaQuery.MaxWidth.lg} {\n margin-right: ${Spacing[\"spacing-16\"]};\n }\n`;\n\nexport const thumbnail = css`\n border-radius: ${Radius[\"sm\"]};\n border: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n\n width: 96px;\n height: 96px;\n aspect-ratio: 1;\n object-fit: cover;\n\n ${MediaQuery.MaxWidth.lg} {\n width: 64px;\n height: 64px;\n }\n`;\n"],"names":[],"mappings":"gIAgK4B,sBA5IZ,2BAqBK,kCASM,6CAYY,sCAyEP,4BAZV,sCA1CU,kCAYJ,6BA+EL,wBApKN,+BA0GQ,qCAiCM,+BA9EP,6BA6HF,qCAdS"}
1
+ {"version":3,"file":"file-list-card.styles.js","sources":["../../../../src/file-download/file-list-card/file-list-card.styles.ts"],"sourcesContent":["import { css } from \"@linaria/core\";\n\nimport { lineClampCss } from \"../../shared/styles\";\nimport { Border, Colour, Font, MediaQuery, Radius, Spacing } from \"../../theme\";\n\n// =============================================================================\n// STYLING\n// =============================================================================\nexport const item = css`\n display: flex;\n align-items: center;\n\n width: 100%;\n border: none;\n\n &:not(:last-child) {\n margin-bottom: ${Spacing[\"spacing-16\"]};\n }\n`;\n\nexport const cardButton = css`\n appearance: none;\n padding: 0;\n background: none;\n border: none;\n`;\n\nexport const box = css`\n position: relative;\n display: flex;\n align-items: center;\n\n width: 100%;\n padding: ${Spacing[\"spacing-16\"]} ${Spacing[\"spacing-32\"]};\n cursor: pointer;\n\n background: ${Colour[\"bg-primary-subtlest\"]};\n border: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n border-radius: ${Radius[\"sm\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n padding: ${Spacing[\"spacing-16\"]};\n }\n\n &:hover {\n background: ${Colour[\"bg-hover\"]};\n }\n\n @supports selector(:has(*)) {\n &:has(.${cardButton}:focus-visible) {\n outline: 2px solid ${Colour[\"focus-ring\"]};\n outline-offset: -2px;\n }\n }\n`;\n\nexport const boxError = css`\n background: ${Colour[\"bg-error\"]};\n border-color: ${Colour[\"border-error\"]};\n\n &:hover {\n background: ${Colour[\"bg-error\"]};\n }\n\n @supports selector(:has(*)) {\n &:has(.${cardButton}:focus-visible) {\n outline-color: ${Colour[\"border-error-focus\"]};\n }\n }\n`;\n\nexport const contentSection = css`\n display: flex;\n flex: 1;\n align-items: center;\n\n ${MediaQuery.MaxWidth.lg} {\n flex-direction: column;\n align-items: flex-start;\n width: 100%;\n }\n`;\n\nexport const contentSectionHasThumbnail = css`\n ${MediaQuery.MaxWidth.lg} {\n flex-direction: row;\n align-items: center;\n }\n`;\n\nexport const nameSection = css`\n display: flex;\n flex: 1;\n flex-direction: column;\n\n width: 100%;\n\n overflow-wrap: break-word;\n word-break: break-all;\n white-space: normal;\n`;\n\nexport const extendedNameSection = css`\n display: flex;\n flex: 1;\n align-items: center;\n\n ${MediaQuery.MaxWidth.lg} {\n flex-direction: column;\n align-items: flex-start;\n width: 100%;\n }\n`;\n\nexport const fileSizeSection = css`\n display: flex;\n justify-content: flex-end;\n\n width: 5rem;\n margin-left: ${Spacing[\"spacing-8\"]};\n\n ${Font[\"body-md-regular\"]}\n color: ${Colour[\"text\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n justify-content: flex-start;\n\n width: 100%;\n margin-left: 0;\n margin-top: ${Spacing[\"spacing-8\"]};\n\n ${lineClampCss(2)}\n }\n`;\n\nexport const itemNameText = css`\n ${Font[\"body-md-regular\"]}\n color: ${Colour[\"text\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n ${lineClampCss(2)}\n }\n`;\n\nexport const errorIcon = css`\n height: 1lh;\n width: 1em;\n flex-shrink: 0;\n color: ${Colour[\"icon-error-strong\"]};\n`;\n\nconst baseErrorMessage = `\n ${Font[\"body-sm-semibold\"]}\n color: ${Colour[\"text-error\"]};\n`;\n\nexport const desktopErrorMessage = css`\n ${baseErrorMessage}\n margin-top: ${Spacing[\"spacing-8\"]};\n display: flex;\n gap: ${Spacing[\"spacing-4\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n display: none;\n visibility: hidden;\n }\n`;\n\nexport const mobileErrorMessage = css`\n ${baseErrorMessage}\n display: none;\n visibility: hidden;\n\n ${MediaQuery.MaxWidth.lg} {\n display: flex;\n gap: ${Spacing[\"spacing-4\"]};\n visibility: visible;\n margin-top: ${Spacing[\"spacing-8\"]};\n }\n`;\n\nexport const actionContainer = css`\n display: flex;\n justify-content: flex-end;\n align-items: center;\n\n margin-left: ${Spacing[\"spacing-32\"]};\n\n ${MediaQuery.MaxWidth.lg} {\n margin-left: ${Spacing[\"spacing-16\"]};\n }\n`;\n\nexport const iconButton = css`\n min-width: unset;\n\n &:not(:last-child) {\n margin-right: ${Spacing[\"spacing-16\"]};\n }\n`;\n\nexport const thumbnailContainer = css`\n width: auto;\n margin-right: ${Spacing[\"spacing-32\"]};\n\n display: flex;\n flex-shrink: 0;\n flex-direction: column;\n justify-content: center;\n\n ${MediaQuery.MaxWidth.lg} {\n margin-right: ${Spacing[\"spacing-16\"]};\n }\n`;\n\nexport const thumbnail = css`\n border-radius: ${Radius[\"sm\"]};\n border: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n\n width: 96px;\n height: 96px;\n aspect-ratio: 1;\n object-fit: cover;\n\n ${MediaQuery.MaxWidth.lg} {\n width: 64px;\n height: 64px;\n }\n`;\n\nexport const thumbnailPdf = css`\n border: none;\n`;\n"],"names":[],"mappings":"+HAqL4B,uBA1JZ,4BA6BK,6BApCE,iCAmDI,6CAYY,uCAyEP,6BAZV,sCA1CU,kCAYJ,6BA+EL,uBAzLN,+BA+HQ,qCAiCM,8BA9EP,4BA6HF,oCAdS,+BA6BN"}