@lifesg/react-design-system 4.0.0-alpha.4 → 4.0.0-alpha.5
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.
- package/accordion/accordion-item.styles_1j4eb32.css +2 -2
- package/accordion/accordion.d.ts +19 -0
- package/accordion/accordion.js.map +1 -1
- package/accordion/accordion.styles_bzrfrs.css +2 -2
- package/accordion/types.d.ts +42 -2
- package/alert/alert.d.ts +8 -0
- package/alert/alert.js.map +1 -1
- package/alert/alert.styles_patwo2.css +2 -2
- package/alert/types.d.ts +26 -2
- package/animations/loading-dots/loading-dots.styles_1rgrrmw.css +2 -2
- package/animations/loading-dots/lottie-animation.styles_1m15v69.css +1 -1
- package/animations/loading-dots-spinner/loading-dots-spinner.styles_1hcqkhs.css +2 -2
- package/animations/loading-dots-spinner/lottie-animation.styles_13d1unb.css +1 -1
- package/animations/loading-spinner/loading-spinner.styles_n6xoft.css +2 -2
- package/animations/loading-spinner/lottie-animation.styles_bnn4qt.css +1 -1
- package/avatar/avatar.d.ts +7 -0
- package/avatar/avatar.js.map +1 -1
- package/avatar/avatar.styles_16efw4.css +2 -2
- package/avatar/types.d.ts +11 -0
- package/badge/badge.d.ts +7 -0
- package/badge/badge.js.map +1 -1
- package/badge/badge.styles_1c3c6wj.css +2 -2
- package/badge/types.d.ts +20 -0
- package/box-container/box-container.d.ts +8 -0
- package/box-container/box-container.js.map +1 -1
- package/box-container/box-container.styles_5t2j9k.css +2 -2
- package/box-container/types.d.ts +24 -0
- package/breadcrumb/breadcrumb.styles_1nl4aua.css +2 -2
- package/button/button.styles_1pxy0co.css +2 -2
- package/calendar/calendar.styles_11ho5x8.css +2 -2
- package/card/card.styles_1gh9gs3.css +2 -2
- package/checkbox/checkbox.styles_gm5bu1.css +2 -2
- package/cjs/accordion/accordion-item.styles_1j4eb32.css +2 -2
- package/cjs/accordion/accordion.js.map +1 -1
- package/cjs/accordion/accordion.styles_bzrfrs.css +2 -2
- package/cjs/alert/alert.js.map +1 -1
- package/cjs/alert/alert.styles_patwo2.css +2 -2
- package/cjs/animations/loading-dots/loading-dots.styles_1rgrrmw.css +2 -2
- package/cjs/animations/loading-dots/lottie-animation.styles_1m15v69.css +1 -1
- package/cjs/animations/loading-dots-spinner/loading-dots-spinner.styles_1hcqkhs.css +2 -2
- package/cjs/animations/loading-dots-spinner/lottie-animation.styles_13d1unb.css +1 -1
- package/cjs/animations/loading-spinner/loading-spinner.styles_n6xoft.css +2 -2
- package/cjs/animations/loading-spinner/lottie-animation.styles_bnn4qt.css +1 -1
- package/cjs/avatar/avatar.js.map +1 -1
- package/cjs/avatar/avatar.styles_16efw4.css +2 -2
- package/cjs/badge/badge.js.map +1 -1
- package/cjs/badge/badge.styles_1c3c6wj.css +2 -2
- package/cjs/box-container/box-container.js.map +1 -1
- package/cjs/box-container/box-container.styles_5t2j9k.css +2 -2
- package/cjs/breadcrumb/breadcrumb.styles_1nl4aua.css +2 -2
- package/cjs/button/button.styles_1pxy0co.css +2 -2
- package/cjs/calendar/calendar.styles_11ho5x8.css +2 -2
- package/cjs/card/card.styles_1gh9gs3.css +2 -2
- package/cjs/checkbox/checkbox.styles_gm5bu1.css +2 -2
- package/cjs/countdown-timer/countdown-timer.js.map +1 -1
- package/cjs/countdown-timer/countdown-timer.styles_ipn1b0.css +2 -2
- package/cjs/dashed-border/dashed-border.js.map +1 -1
- package/cjs/dashed-border/dashed-border.styles_zszoox.css +2 -2
- package/cjs/data-table/data-table.js.map +1 -1
- package/cjs/data-table/data-table.styles_1iqq1g7.css +2 -2
- package/cjs/date-input/date-input.js.map +1 -1
- package/cjs/date-input/date-input.styles_1r5kcc7.css +1 -1
- package/cjs/date-navigator/date-navigator.js.map +1 -1
- package/cjs/date-navigator/date-navigator.styles_wokh56.css +2 -2
- package/cjs/date-range-input/date-range-input.js.map +1 -1
- package/cjs/date-range-input/date-range-input.styles_1s7ojnj.css +2 -2
- package/cjs/divider/divider.js.map +1 -1
- package/cjs/divider/divider.styles_1xpzh8p.css +2 -2
- package/cjs/drawer/drawer.js.map +1 -1
- package/cjs/drawer/drawer.styles_94hx3y.css +2 -2
- package/cjs/e-signature/e-signature-canvas.js +1 -1
- package/cjs/e-signature/e-signature-canvas.js.map +1 -1
- package/cjs/e-signature/e-signature.js.map +1 -1
- package/cjs/e-signature/e-signature.styles_lukd9f.css +2 -2
- package/cjs/error-display/error-display.js.map +1 -1
- package/cjs/error-display/error-display.styles_d3tql1.css +2 -2
- package/cjs/external/dompurify/dist/purify.es.js +3 -3
- package/cjs/external/dompurify/dist/purify.es.js.map +1 -1
- package/cjs/feedback-rating/feedback-rating-stars-container.styles_dmi8z9.css +2 -2
- package/cjs/feedback-rating/feedback-rating.js.map +1 -1
- package/cjs/feedback-rating/feedback-rating.styles_1kdklb6.css +2 -2
- package/cjs/file-download/file-download.js.map +1 -1
- package/cjs/file-download/file-download.styles_iggk8q.css +2 -2
- package/cjs/file-download/file-list-card/file-list-card.styles.js +1 -1
- package/cjs/file-download/file-list-card/file-list-card.styles.js.map +1 -1
- package/cjs/file-download/file-list-card/{file-list-card.styles_oom8ii.css → file-list-card.styles_18j2gut.css} +3 -3
- package/cjs/file-upload/dropzone.styles_1pllsau.css +2 -2
- package/cjs/file-upload/file-item-edit.js +1 -1
- package/cjs/file-upload/file-item-edit.js.map +1 -1
- package/cjs/file-upload/file-item-edit.styles.js +1 -1
- package/cjs/file-upload/file-item-edit.styles.js.map +1 -1
- package/cjs/file-upload/{file-item-edit.styles_1qbpbxj.css → file-item-edit.styles_19bvztn.css} +6 -5
- package/cjs/file-upload/file-list/file-list.js +1 -1
- package/cjs/file-upload/file-list/file-list.js.map +1 -1
- package/cjs/file-upload/file-list/file-list.styles.js +1 -1
- package/cjs/file-upload/file-list/file-list.styles.js.map +1 -1
- package/cjs/file-upload/file-list/file-list.styles_1w7so98.css +3 -0
- package/cjs/file-upload/file-list-item/file-list-item-thumbnail.styles_1y4si19.css +2 -2
- package/cjs/file-upload/file-list-item/file-list-item.js +1 -1
- package/cjs/file-upload/file-list-item/file-list-item.js.map +1 -1
- package/cjs/file-upload/file-list-item/file-list-item.styles.js +1 -1
- package/cjs/file-upload/file-list-item/file-list-item.styles.js.map +1 -1
- package/cjs/file-upload/file-list-item/file-list-item.styles_o8000f.css +17 -0
- package/cjs/file-upload/file-upload.js +1 -1
- package/cjs/file-upload/file-upload.js.map +1 -1
- package/cjs/file-upload/file-upload.styles_9ffwcd.css +2 -2
- package/cjs/filter/addons/filter-item-checkbox.styles_7degw7.css +2 -2
- package/cjs/filter/filter-item-page.styles_17ewfrz.css +1 -1
- package/cjs/filter/filter-item.js.map +1 -1
- package/cjs/filter/filter-item.styles_cphjnj.css +2 -2
- package/cjs/filter/filter-modal.styles_qw3xlg.css +2 -2
- package/cjs/filter/filter-sidebar.styles_1otwpjl.css +2 -2
- package/cjs/filter/filter.js.map +1 -1
- package/cjs/filter/filter.styles_1ykijwm.css +2 -2
- package/cjs/footer/footer-download-app.styles_1v1j2us.css +2 -2
- package/cjs/footer/footer-resource-addon.styles_1jepb1d.css +2 -2
- package/cjs/footer/footer.js +1 -1
- package/cjs/footer/footer.js.map +1 -1
- package/cjs/footer/footer.styles_1msorhc.css +2 -2
- package/cjs/form/form-label-addon.styles_b00z8p.css +1 -1
- package/cjs/form/form-label.styles.js +1 -1
- package/cjs/form/form-label.styles.js.map +1 -1
- package/cjs/form/{form-label.styles_11r0652.css → form-label.styles_1nbe0bm.css} +2 -2
- package/cjs/form/form-textarea.styles_3p9qoy.css +2 -2
- package/cjs/form/form-wrapper.styles_199rslu.css +1 -1
- package/cjs/fullscreen-image-carousel/fullscreen-image-carousel.styles_vc6y5c.css +2 -2
- package/cjs/fullscreen-image-carousel/stateful-image.styles_1xe8ypm.css +2 -2
- package/cjs/histogram-slider/histogram-slider.styles_wvd4w.css +2 -2
- package/cjs/image-button/image-button.styles_6n1qsr.css +2 -2
- package/cjs/index.js +1 -1
- package/cjs/input/input.styles_1cblor0.css +2 -2
- package/cjs/input-group/input-group-list-addon.styles_17iuqtw.css +2 -2
- package/cjs/input-group/input-group.styles_bqye6f.css +2 -2
- package/cjs/input-range-select/input-range-select.styles_adbrbm.css +2 -2
- package/cjs/input-range-slider/input-range-slider.styles_aljl2v.css +2 -2
- package/cjs/input-textarea/textarea-counter.styles_1n3wsnv.css +1 -1
- package/cjs/input-textarea/textarea.styles_22z4n3.css +2 -2
- package/cjs/language-switcher/dropdown-panel.styles_1qsjf8d.css +2 -2
- package/cjs/language-switcher/dropdown-variant.styles_1vrdfky.css +2 -2
- package/cjs/language-switcher/link-container-variant.styles_1iw6zux.css +2 -2
- package/cjs/layout/col-div.styles_16o6mwx.css +1 -1
- package/cjs/layout/container.styles_v70ec6.css +2 -2
- package/cjs/layout/section.styles_hstcaf.css +1 -1
- package/cjs/link-list/link-list.styles_m57vks.css +2 -2
- package/cjs/local-nav/local-nav-dropdown/local-nav-dropdown.styles_uhd4xl.css +2 -2
- package/cjs/local-nav/local-nav-menu/local-nav-menu.styles_pq19dh.css +2 -2
- package/cjs/markup/markup.style_1iu40x9.css +2 -2
- package/cjs/masked-input/masked-input.styles_1cm388a.css +2 -2
- package/cjs/masthead/masthead.styles_1huzon9.css +2 -2
- package/cjs/menu/menu-content.styles_p7ijll.css +2 -2
- package/cjs/menu/menu-item.styles_liyed8.css +2 -2
- package/cjs/menu/menu-link.styles_hfxoez.css +2 -2
- package/cjs/menu/menu-section.styles_g7my4d.css +2 -2
- package/cjs/modal/modal-box.styles_y52cts.css +2 -2
- package/cjs/modal/modal.styles_1lbblx6.css +2 -2
- package/cjs/modal-v2/modal-v2.styles_a8gv5i.css +2 -2
- package/cjs/modal-v2/slots/slot-styles_13sd376.css +2 -2
- package/cjs/navbar/brand.styles_zcgddp.css +1 -1
- package/cjs/navbar/drawer.js +1 -1
- package/cjs/navbar/drawer.js.map +1 -1
- package/cjs/navbar/drawer.styles_7hnxp5.css +2 -2
- package/cjs/navbar/menu.styles_gdpqc.css +2 -2
- package/cjs/navbar/navbar-action-buttons.styles_1vpm0nk.css +2 -2
- package/cjs/navbar/navbar-items.styles_1i3ltot.css +2 -2
- package/cjs/navbar/navbar.js +1 -1
- package/cjs/navbar/navbar.js.map +1 -1
- package/cjs/navbar/navbar.styles_koy0c7.css +2 -2
- package/cjs/notification-banner/notification-banner.styles_uxlysy.css +2 -2
- package/cjs/otp-input/otp-input.styles_5sbutl.css +2 -2
- package/cjs/otp-verification/contact-input-section.styles_odrjvt.css +2 -2
- package/cjs/otp-verification/otp-verification.styles_dg9bm8.css +1 -1
- package/cjs/otp-verification/thumbnail/thumbnail.styles_shqylh.css +2 -2
- package/cjs/otp-verification/verification-section.styles_x8jj.css +2 -2
- package/cjs/overlay/overlay.js +1 -1
- package/cjs/overlay/overlay.js.map +1 -1
- package/cjs/overlay/overlay.styles_12wym18.css +2 -2
- package/cjs/pagination/pagination.styles_6bcgva.css +2 -2
- package/cjs/pill/pill.styles_xwrniu.css +2 -2
- package/cjs/popover/popover-inline/popover-inline.styles_bkopnt.css +2 -2
- package/cjs/popover/popover-trigger.styles_8zokig.css +1 -1
- package/cjs/popover/popover.styles_ujnf0h.css +2 -2
- package/cjs/progress-indicator/progress-indicator.styles_1c038s4.css +2 -2
- package/cjs/radio-button/radio-button.styles_1c4v6v.css +2 -2
- package/cjs/schedule/schedule-day-view/schedule-day-view.styles_8ti149.css +2 -2
- package/cjs/schedule/schedule-header/schedule-header.js +1 -1
- package/cjs/schedule/schedule-header/schedule-header.js.map +1 -1
- package/cjs/schedule/schedule-header/schedule-header.styles_1n2u5vj.css +2 -2
- package/cjs/schedule/schedule-week-view/schedule-week-view.styles_x7x50m.css +2 -2
- package/cjs/schedule/schedule-week-view/time-cell.styles_1sorjz8.css +2 -2
- package/cjs/schedule/schedule.styles_fdy5a1.css +2 -2
- package/cjs/schedule/shared/with-optional-popover.styles_7mv3p2.css +1 -1
- package/cjs/schedule/time-indicator/time-indicator.styles_1eaxyes.css +2 -2
- package/cjs/select-histogram/select-histogram.styles_n260dy.css +2 -2
- package/cjs/shared/accessibility/index_13g9vp.css +1 -1
- package/cjs/shared/clickable-icon/clickable-icon.styles_1v2imml.css +2 -2
- package/cjs/shared/component-loading-spinner/component-loading-spinner.styles_15eq02i.css +2 -2
- package/cjs/shared/dropdown-list/dropdown-label.styles_mloii0.css +2 -2
- package/cjs/shared/dropdown-list/dropdown-list.styles_konwm.css +2 -2
- package/cjs/shared/dropdown-list/dropdown-search.styles_1hc1gkh.css +2 -2
- package/cjs/shared/dropdown-list/expandable-element.styles_rkkvqr.css +2 -2
- package/cjs/shared/dropdown-list/nested-dropdown-list.styles_wdhxoe.css +2 -2
- package/cjs/shared/dropdown-wrapper/dropdown-wrapper.styles_15hwwoj.css +2 -2
- package/cjs/shared/fade-wrapper/fade-wrapper.styles_16iug7l.css +2 -2
- package/cjs/shared/image-placeholder/image-placeholder.styles_44nwil.css +1 -1
- package/cjs/shared/input-wrapper/input-wrapper.styles_je6maw.css +2 -2
- package/cjs/shared/internal-calendar/calendar-dropdown.styles_wybjai.css +1 -1
- package/cjs/shared/internal-calendar/calendar-manager.js +1 -1
- package/cjs/shared/internal-calendar/calendar-manager.js.map +1 -1
- package/cjs/shared/internal-calendar/calendar-manager.styles.js +1 -1
- package/cjs/shared/internal-calendar/calendar-manager.styles.js.map +1 -1
- package/cjs/shared/internal-calendar/{calendar-manager.styles_1iuq5zw.css → calendar-manager.styles_1njwkj2.css} +3 -3
- package/cjs/shared/internal-calendar/day-cell/day-cell.styles_1t5oqc1.css +2 -2
- package/cjs/shared/internal-calendar/internal-calendar-month.styles_14oh57f.css +2 -2
- package/cjs/shared/internal-calendar/internal-calendar-year.styles_therlc.css +2 -2
- package/cjs/shared/internal-calendar/internal-calendar.styles_gnc3eq.css +1 -1
- package/cjs/shared/internal-calendar/standard/standard-calendar-day-view.styles_1bw26au.css +2 -2
- package/cjs/shared/progress-bar/progress-bar.styles_125ri7a.css +1 -1
- package/cjs/shared/range-input-inner-container/range-input-inner-container.styles_1v61utg.css +2 -2
- package/cjs/shared/standalone-date-input/standalone-date-input.styles_157qo89.css +2 -2
- package/cjs/shared/time-slot/time-slot.styles_18s0to7.css +2 -2
- package/cjs/shared/timepicker-dropdown/timepicker-dropdown.styles_119l6k6.css +2 -2
- package/cjs/sidenav/sidenav-drawer-item.styles_1ljnyx2.css +2 -2
- package/cjs/sidenav/sidenav-drawer-subitem.styles_2y58kf.css +1 -1
- package/cjs/sidenav/sidenav-group.styles_1x604sw.css +2 -2
- package/cjs/sidenav/sidenav-item.styles_lqw3kh.css +2 -2
- package/cjs/sidenav/sidenav.styles_1vxezie.css +2 -2
- package/cjs/singpass-button/singpass-button.styles_1miyex3.css +2 -2
- package/cjs/smart-app-banner/smart-app-banner.styles_15u6yv4.css +2 -2
- package/cjs/tab/tab-link-chain.styles_49got4.css +2 -2
- package/cjs/tab/tab.styles_1najffw.css +1 -1
- package/cjs/table/table.styles_1af5ipv.css +2 -2
- package/cjs/tag/tag.style_d98c53.css +2 -2
- package/cjs/text-list/text-list.styles_w3fvyt.css +2 -2
- package/cjs/theme/types.js +1 -1
- package/cjs/theme/types.js.map +1 -1
- package/cjs/theme/utils/use-design-token-override.js +2 -0
- package/cjs/theme/utils/use-design-token-override.js.map +1 -0
- package/cjs/time-range-picker/combobox-picker/combobox-picker.styles_7i9vso.css +1 -1
- package/cjs/time-range-picker/common.styles_1qwp4xa.css +2 -2
- package/cjs/time-slot-bar/time-slot-bar.styles_wigbyd.css +2 -2
- package/cjs/time-slot-bar-week/time-slot-bar-week-days.styles_evdvs9.css +2 -2
- package/cjs/time-slot-bar-week/time-slot-bar-week.styles_11ybf42.css +1 -1
- package/cjs/time-slot-week-view/time-slot-week-days.styles_1h21vyw.css +2 -2
- package/cjs/time-slot-week-view/time-slot-week-view.styles_gqgsw2.css +1 -1
- package/cjs/timeline/timeline.styles_1jxzik4.css +2 -2
- package/cjs/timepicker/timepicker.styles_1jm33yw.css +1 -1
- package/cjs/timetable/timetable-header/timetable-header.styles_11gl1h4.css +2 -2
- package/cjs/timetable/timetable-row/row-bar.styles_1x0vrsz.css +1 -1
- package/cjs/timetable/timetable-row/row-cell.styles_y1dl5j.css +2 -2
- package/cjs/timetable/timetable.styles_7rp8kz.css +2 -2
- package/cjs/toast/toast.styles_1e0l60w.css +2 -2
- package/cjs/toggle/toggle-icon.styles_ba71y.css +2 -2
- package/cjs/toggle/toggle.styles_1t5qrye.css +2 -2
- package/cjs/typography/typography-text.styles_1734x2k.css +2 -2
- package/cjs/typography/typography.styles.js +1 -1
- package/cjs/typography/typography.styles.js.map +1 -1
- package/cjs/typography/{typography.styles_1155j4c.css → typography.styles_1wd82dn.css} +2 -2
- package/cjs/uneditable-section/section-item.styles_mwx8ht.css +2 -2
- package/cjs/uneditable-section/uneditable-section.js +1 -1
- package/cjs/uneditable-section/uneditable-section.js.map +1 -1
- package/cjs/uneditable-section/uneditable-section.styles_aj9zun.css +2 -2
- package/cjs/unit-number/unit-number-input.styles_8yizj.css +2 -2
- package/countdown-timer/countdown-timer.d.ts +6 -0
- package/countdown-timer/countdown-timer.js.map +1 -1
- package/countdown-timer/countdown-timer.styles_ipn1b0.css +2 -2
- package/countdown-timer/types.d.ts +55 -11
- package/dashed-border/dashed-border.d.ts +6 -0
- package/dashed-border/dashed-border.js.map +1 -1
- package/dashed-border/dashed-border.styles_zszoox.css +2 -2
- package/dashed-border/types.d.ts +27 -5
- package/data-table/data-table.d.ts +8 -0
- package/data-table/data-table.js.map +1 -1
- package/data-table/data-table.styles_1iqq1g7.css +2 -2
- package/data-table/types.d.ts +58 -12
- package/date-input/date-input.d.ts +5 -0
- package/date-input/date-input.js.map +1 -1
- package/date-input/date-input.styles_1r5kcc7.css +1 -1
- package/date-input/types.d.ts +32 -16
- package/date-navigator/date-navigator.d.ts +6 -0
- package/date-navigator/date-navigator.js.map +1 -1
- package/date-navigator/date-navigator.styles_wokh56.css +2 -2
- package/date-navigator/types.d.ts +44 -7
- package/date-range-input/date-range-input.d.ts +4 -0
- package/date-range-input/date-range-input.js.map +1 -1
- package/date-range-input/date-range-input.styles_1s7ojnj.css +2 -2
- package/date-range-input/types.d.ts +50 -14
- package/divider/divider.d.ts +6 -0
- package/divider/divider.js.map +1 -1
- package/divider/divider.styles_1xpzh8p.css +2 -2
- package/divider/types.d.ts +27 -4
- package/drawer/drawer.d.ts +7 -0
- package/drawer/drawer.js.map +1 -1
- package/drawer/drawer.styles_94hx3y.css +2 -2
- package/drawer/types.d.ts +16 -4
- package/e-signature/e-signature-canvas.js +1 -1
- package/e-signature/e-signature-canvas.js.map +1 -1
- package/e-signature/e-signature.d.ts +5 -0
- package/e-signature/e-signature.js.map +1 -1
- package/e-signature/e-signature.styles_lukd9f.css +2 -2
- package/e-signature/types.d.ts +23 -1
- package/error-display/error-display.d.ts +7 -0
- package/error-display/error-display.js.map +1 -1
- package/error-display/error-display.styles_d3tql1.css +2 -2
- package/error-display/types.d.ts +36 -6
- package/external/dompurify/dist/purify.es.js +2 -2
- package/external/dompurify/dist/purify.es.js.map +1 -1
- package/feedback-rating/feedback-rating-stars-container.styles_dmi8z9.css +2 -2
- package/feedback-rating/feedback-rating.d.ts +6 -0
- package/feedback-rating/feedback-rating.js.map +1 -1
- package/feedback-rating/feedback-rating.styles_1kdklb6.css +2 -2
- package/feedback-rating/types.d.ts +29 -0
- package/file-download/file-download.d.ts +6 -0
- package/file-download/file-download.js.map +1 -1
- package/file-download/file-download.styles_iggk8q.css +2 -2
- package/file-download/file-list-card/file-list-card.styles.js +1 -1
- package/file-download/file-list-card/file-list-card.styles.js.map +1 -1
- package/file-download/file-list-card/{file-list-card.styles_oom8ii.css → file-list-card.styles_18j2gut.css} +3 -3
- package/file-download/types.d.ts +44 -11
- package/file-upload/dropzone.styles_1pllsau.css +2 -2
- package/file-upload/file-item-edit.d.ts +4 -1
- package/file-upload/file-item-edit.js +1 -1
- package/file-upload/file-item-edit.js.map +1 -1
- package/file-upload/file-item-edit.styles.d.ts +1 -0
- package/file-upload/file-item-edit.styles.js +1 -1
- package/file-upload/file-item-edit.styles.js.map +1 -1
- package/file-upload/{file-item-edit.styles_1qbpbxj.css → file-item-edit.styles_19bvztn.css} +6 -5
- package/file-upload/file-list/file-list.d.ts +3 -0
- package/file-upload/file-list/file-list.js +1 -1
- package/file-upload/file-list/file-list.js.map +1 -1
- package/file-upload/file-list/file-list.styles.js +1 -1
- package/file-upload/file-list/file-list.styles.js.map +1 -1
- package/file-upload/file-list/file-list.styles_1w7so98.css +3 -0
- package/file-upload/file-list-item/file-list-item-thumbnail.styles_1y4si19.css +2 -2
- package/file-upload/file-list-item/file-list-item.d.ts +3 -1
- package/file-upload/file-list-item/file-list-item.js +1 -1
- package/file-upload/file-list-item/file-list-item.js.map +1 -1
- package/file-upload/file-list-item/file-list-item.styles.d.ts +3 -0
- package/file-upload/file-list-item/file-list-item.styles.js +1 -1
- package/file-upload/file-list-item/file-list-item.styles.js.map +1 -1
- package/file-upload/file-list-item/file-list-item.styles_o8000f.css +17 -0
- package/file-upload/file-upload.d.ts +2 -1
- package/file-upload/file-upload.js +1 -1
- package/file-upload/file-upload.js.map +1 -1
- package/file-upload/file-upload.styles_9ffwcd.css +2 -2
- package/file-upload/types.d.ts +125 -20
- package/filter/addons/filter-item-checkbox.styles_7degw7.css +2 -2
- package/filter/filter-item-page.styles_17ewfrz.css +1 -1
- package/filter/filter-item.js.map +1 -1
- package/filter/filter-item.styles_cphjnj.css +2 -2
- package/filter/filter-modal.styles_qw3xlg.css +2 -2
- package/filter/filter-sidebar.styles_1otwpjl.css +2 -2
- package/filter/filter.d.ts +21 -0
- package/filter/filter.js.map +1 -1
- package/filter/filter.styles_1ykijwm.css +2 -2
- package/filter/types.d.ts +161 -21
- package/footer/footer-download-app.styles_1v1j2us.css +2 -2
- package/footer/footer-resource-addon.styles_1jepb1d.css +2 -2
- package/footer/footer.d.ts +8 -1
- package/footer/footer.js +1 -1
- package/footer/footer.js.map +1 -1
- package/footer/footer.styles_1msorhc.css +2 -2
- package/footer/types.d.ts +55 -4
- package/form/form-label-addon.styles_b00z8p.css +1 -1
- package/form/form-label.styles.js +1 -1
- package/form/form-label.styles.js.map +1 -1
- package/form/{form-label.styles_11r0652.css → form-label.styles_1nbe0bm.css} +2 -2
- package/form/form-textarea.styles_3p9qoy.css +2 -2
- package/form/form-wrapper.styles_199rslu.css +1 -1
- package/fullscreen-image-carousel/fullscreen-image-carousel.styles_vc6y5c.css +2 -2
- package/fullscreen-image-carousel/stateful-image.styles_1xe8ypm.css +2 -2
- package/histogram-slider/histogram-slider.styles_wvd4w.css +2 -2
- package/image-button/image-button.styles_6n1qsr.css +2 -2
- package/index.d.ts +0 -1
- package/index.js +1 -1
- package/input/input.styles_1cblor0.css +2 -2
- package/input-group/input-group-list-addon.styles_17iuqtw.css +2 -2
- package/input-group/input-group.styles_bqye6f.css +2 -2
- package/input-range-select/input-range-select.styles_adbrbm.css +2 -2
- package/input-range-slider/input-range-slider.styles_aljl2v.css +2 -2
- package/input-textarea/textarea-counter.styles_1n3wsnv.css +1 -1
- package/input-textarea/textarea.styles_22z4n3.css +2 -2
- package/language-switcher/dropdown-panel.styles_1qsjf8d.css +2 -2
- package/language-switcher/dropdown-variant.styles_1vrdfky.css +2 -2
- package/language-switcher/link-container-variant.styles_1iw6zux.css +2 -2
- package/layout/col-div.styles_16o6mwx.css +1 -1
- package/layout/container.styles_v70ec6.css +2 -2
- package/layout/section.styles_hstcaf.css +1 -1
- package/link-list/link-list.styles_m57vks.css +2 -2
- package/local-nav/local-nav-dropdown/local-nav-dropdown.styles_uhd4xl.css +2 -2
- package/local-nav/local-nav-menu/local-nav-menu.styles_pq19dh.css +2 -2
- package/markup/markup.style_1iu40x9.css +2 -2
- package/masked-input/masked-input.styles_1cm388a.css +2 -2
- package/masthead/masthead.styles_1huzon9.css +2 -2
- package/menu/menu-content.styles_p7ijll.css +2 -2
- package/menu/menu-item.styles_liyed8.css +2 -2
- package/menu/menu-link.styles_hfxoez.css +2 -2
- package/menu/menu-section.styles_g7my4d.css +2 -2
- package/modal/modal-box.styles_y52cts.css +2 -2
- package/modal/modal.styles_1lbblx6.css +2 -2
- package/modal-v2/modal-v2.styles_a8gv5i.css +2 -2
- package/modal-v2/slots/slot-styles_13sd376.css +2 -2
- package/navbar/brand.styles_zcgddp.css +1 -1
- package/navbar/drawer.js +1 -1
- package/navbar/drawer.js.map +1 -1
- package/navbar/drawer.styles_7hnxp5.css +2 -2
- package/navbar/menu.styles_gdpqc.css +2 -2
- package/navbar/navbar-action-buttons.styles_1vpm0nk.css +2 -2
- package/navbar/navbar-items.styles_1i3ltot.css +2 -2
- package/navbar/navbar.js +1 -1
- package/navbar/navbar.js.map +1 -1
- package/navbar/navbar.styles_koy0c7.css +2 -2
- package/notification-banner/notification-banner.styles_uxlysy.css +2 -2
- package/otp-input/otp-input.styles_5sbutl.css +2 -2
- package/otp-verification/contact-input-section.styles_odrjvt.css +2 -2
- package/otp-verification/otp-verification.styles_dg9bm8.css +1 -1
- package/otp-verification/thumbnail/thumbnail.styles_shqylh.css +2 -2
- package/otp-verification/verification-section.styles_x8jj.css +2 -2
- package/overlay/overlay.js +1 -1
- package/overlay/overlay.js.map +1 -1
- package/overlay/overlay.styles_12wym18.css +2 -2
- package/overlay/types.d.ts +0 -13
- package/package.json +1 -7
- package/pagination/pagination.styles_6bcgva.css +2 -2
- package/pill/pill.styles_xwrniu.css +2 -2
- package/popover/popover-inline/popover-inline.styles_bkopnt.css +2 -2
- package/popover/popover-trigger.styles_8zokig.css +1 -1
- package/popover/popover.styles_ujnf0h.css +2 -2
- package/progress-indicator/progress-indicator.styles_1c038s4.css +2 -2
- package/radio-button/radio-button.styles_1c4v6v.css +2 -2
- package/schedule/schedule-day-view/schedule-day-view.styles_8ti149.css +2 -2
- package/schedule/schedule-header/schedule-header.js +1 -1
- package/schedule/schedule-header/schedule-header.js.map +1 -1
- package/schedule/schedule-header/schedule-header.styles_1n2u5vj.css +2 -2
- package/schedule/schedule-week-view/schedule-week-view.styles_x7x50m.css +2 -2
- package/schedule/schedule-week-view/time-cell.styles_1sorjz8.css +2 -2
- package/schedule/schedule.styles_fdy5a1.css +2 -2
- package/schedule/shared/with-optional-popover.styles_7mv3p2.css +1 -1
- package/schedule/time-indicator/time-indicator.styles_1eaxyes.css +2 -2
- package/select-histogram/select-histogram.styles_n260dy.css +2 -2
- package/shared/accessibility/index_13g9vp.css +1 -1
- package/shared/clickable-icon/clickable-icon.styles_1v2imml.css +2 -2
- package/shared/component-loading-spinner/component-loading-spinner.styles_15eq02i.css +2 -2
- package/shared/dropdown-list/dropdown-label.styles_mloii0.css +2 -2
- package/shared/dropdown-list/dropdown-list.styles_konwm.css +2 -2
- package/shared/dropdown-list/dropdown-search.styles_1hc1gkh.css +2 -2
- package/shared/dropdown-list/expandable-element.styles_rkkvqr.css +2 -2
- package/shared/dropdown-list/nested-dropdown-list.styles_wdhxoe.css +2 -2
- package/shared/dropdown-wrapper/dropdown-wrapper.styles_15hwwoj.css +2 -2
- package/shared/fade-wrapper/fade-wrapper.styles_16iug7l.css +2 -2
- package/shared/image-placeholder/image-placeholder.styles_44nwil.css +1 -1
- package/shared/input-wrapper/input-wrapper.styles_je6maw.css +2 -2
- package/shared/internal-calendar/calendar-dropdown.styles_wybjai.css +1 -1
- package/shared/internal-calendar/calendar-manager.js +1 -1
- package/shared/internal-calendar/calendar-manager.js.map +1 -1
- package/shared/internal-calendar/calendar-manager.styles.js +1 -1
- package/shared/internal-calendar/calendar-manager.styles.js.map +1 -1
- package/shared/internal-calendar/{calendar-manager.styles_1iuq5zw.css → calendar-manager.styles_1njwkj2.css} +3 -3
- package/shared/internal-calendar/day-cell/day-cell.styles_1t5oqc1.css +2 -2
- package/shared/internal-calendar/internal-calendar-month.styles_14oh57f.css +2 -2
- package/shared/internal-calendar/internal-calendar-year.styles_therlc.css +2 -2
- package/shared/internal-calendar/internal-calendar.styles_gnc3eq.css +1 -1
- package/shared/internal-calendar/standard/standard-calendar-day-view.styles_1bw26au.css +2 -2
- package/shared/progress-bar/progress-bar.styles_125ri7a.css +1 -1
- package/shared/range-input-inner-container/range-input-inner-container.styles_1v61utg.css +2 -2
- package/shared/standalone-date-input/standalone-date-input.styles_157qo89.css +2 -2
- package/shared/time-slot/time-slot.styles_18s0to7.css +2 -2
- package/shared/timepicker-dropdown/timepicker-dropdown.styles_119l6k6.css +2 -2
- package/sidenav/sidenav-drawer-item.styles_1ljnyx2.css +2 -2
- package/sidenav/sidenav-drawer-subitem.styles_2y58kf.css +1 -1
- package/sidenav/sidenav-group.styles_1x604sw.css +2 -2
- package/sidenav/sidenav-item.styles_lqw3kh.css +2 -2
- package/sidenav/sidenav.styles_1vxezie.css +2 -2
- package/singpass-button/singpass-button.styles_1miyex3.css +2 -2
- package/smart-app-banner/smart-app-banner.styles_15u6yv4.css +2 -2
- package/tab/tab-link-chain.styles_49got4.css +2 -2
- package/tab/tab.styles_1najffw.css +1 -1
- package/table/table.styles_1af5ipv.css +2 -2
- package/tag/tag.style_d98c53.css +2 -2
- package/text-list/text-list.styles_w3fvyt.css +2 -2
- package/theme/styles/a11y-playground.css +3 -0
- package/theme/styles/bookingsg.css +7 -4
- package/theme/styles/careercompass.css +4 -1
- package/theme/styles/ccube.css +3 -0
- package/theme/styles/default.css +9 -5
- package/theme/styles/imda.css +3 -0
- package/theme/styles/lifesg.css +3 -0
- package/theme/styles/mylegacy.css +7 -4
- package/theme/styles/oneservice.css +52 -0
- package/theme/styles/pa.css +3 -0
- package/theme/styles/rbs.css +3 -0
- package/theme/styles/sgw-digital-lobby.css +5 -2
- package/theme/styles/smgs.css +3 -0
- package/theme/styles/spf.css +3 -0
- package/theme/styles/supportgowhere.css +3 -0
- package/theme/types.d.ts +1 -1
- package/theme/types.js +1 -1
- package/theme/types.js.map +1 -1
- package/theme/utils/index.d.ts +1 -0
- package/theme/utils/use-design-token-override.d.ts +11 -0
- package/theme/utils/use-design-token-override.js +2 -0
- package/theme/utils/use-design-token-override.js.map +1 -0
- package/time-range-picker/combobox-picker/combobox-picker.styles_7i9vso.css +1 -1
- package/time-range-picker/common.styles_1qwp4xa.css +2 -2
- package/time-slot-bar/time-slot-bar.styles_wigbyd.css +2 -2
- package/time-slot-bar-week/time-slot-bar-week-days.styles_evdvs9.css +2 -2
- package/time-slot-bar-week/time-slot-bar-week.styles_11ybf42.css +1 -1
- package/time-slot-week-view/time-slot-week-days.styles_1h21vyw.css +2 -2
- package/time-slot-week-view/time-slot-week-view.styles_gqgsw2.css +1 -1
- package/timeline/timeline.styles_1jxzik4.css +2 -2
- package/timepicker/timepicker.styles_1jm33yw.css +1 -1
- package/timetable/timetable-header/timetable-header.styles_11gl1h4.css +2 -2
- package/timetable/timetable-row/row-bar.styles_1x0vrsz.css +1 -1
- package/timetable/timetable-row/row-cell.styles_y1dl5j.css +2 -2
- package/timetable/timetable.styles_7rp8kz.css +2 -2
- package/toast/toast.styles_1e0l60w.css +2 -2
- package/toggle/toggle-icon.styles_ba71y.css +2 -2
- package/toggle/toggle.styles_1t5qrye.css +2 -2
- package/typography/typography-text.styles_1734x2k.css +2 -2
- package/typography/typography.styles.js +1 -1
- package/typography/typography.styles.js.map +1 -1
- package/typography/{typography.styles_1155j4c.css → typography.styles_1wd82dn.css} +2 -2
- package/uneditable-section/index.d.ts +1 -1
- package/uneditable-section/section-item.styles_mwx8ht.css +2 -2
- package/uneditable-section/uneditable-section.d.ts +2 -1
- package/uneditable-section/uneditable-section.js +1 -1
- package/uneditable-section/uneditable-section.js.map +1 -1
- package/uneditable-section/uneditable-section.styles_aj9zun.css +2 -2
- package/unit-number/unit-number-input.styles_8yizj.css +2 -2
- package/cjs/example/example.js +0 -2
- package/cjs/example/example.js.map +0 -1
- package/cjs/example/example_r47nvz.css +0 -1
- package/cjs/example/index.js +0 -2
- package/cjs/example/index.js.map +0 -1
- package/cjs/file-upload/file-list/file-list.styles_1ea12kj.css +0 -3
- package/cjs/file-upload/file-list-item/file-list-item.styles_y7my2m.css +0 -14
- package/example/example.d.ts +0 -2
- package/example/example.js +0 -2
- package/example/example.js.map +0 -1
- package/example/example_r47nvz.css +0 -1
- package/example/index.d.ts +0 -1
- package/example/index.js +0 -2
- package/example/index.js.map +0 -1
- package/example/types.d.ts +0 -3
- package/file-upload/file-list/file-list.styles_1ea12kj.css +0 -3
- package/file-upload/file-list-item/file-list-item.styles_y7my2m.css +0 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countdown-timer.js","sources":["../../src/countdown-timer/countdown-timer.tsx"],"sourcesContent":["import { ClockIcon } from \"@lifesg/react-icons\";\nimport clsx from \"clsx\";\nimport throttle from \"lodash/throttle\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport { inertValue, VisuallyHidden } from \"../shared/accessibility\";\nimport {\n formatUnitValue,\n useApplyStyle,\n useMaxWidthMediaQuery,\n} from \"../theme\";\nimport { useIsMounted } from \"../util\";\nimport { TimeHelper } from \"../util/time-helper\";\nimport * as styles from \"./countdown-timer.styles\";\nimport type { CountdownTimerProps } from \"./types\";\nimport { useTimer } from \"./use-timer\";\n\nexport const CountdownTimer = ({\n className,\n align = \"right\",\n timer,\n timestamp,\n notifyTimer,\n offset,\n mobileOffset,\n show,\n fixed = true,\n reminderInterval = 120,\n \"data-testid\": testId,\n onFinish,\n onNotify,\n onTick,\n ...otherProps\n}: CountdownTimerProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n const fixedCountdownRef = useRef<HTMLDivElement>(null);\n\n const isNotified = useRef<boolean>(false);\n const [offsetY, setOffsetY] = useState<number>(0);\n const [clientRectRight, setClientRectRight] = useState<number>(0);\n const [clientRectX, setClientRectX] = useState<number>(0);\n const [isPlaying, setIsPlaying] = useState(false);\n const [announcement, setAnnouncement] = useState<string>(\"\");\n\n const isMounted = useIsMounted();\n const [remainingSeconds, initialSeconds] = useTimer(\n timer,\n timestamp,\n isPlaying\n );\n const { ref: stickyRef, inView } = useInView({\n threshold: 1,\n rootMargin: `${offsetY * -1}px 0px 0px 0px`,\n initialInView: true,\n });\n const isVisible = !fixed || inView;\n const warn =\n typeof notifyTimer === \"number\" && remainingSeconds <= notifyTimer;\n\n const isMobile = useMaxWidthMediaQuery(\"sm\");\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n\n useApplyStyle(fixedCountdownRef, {\n [styles.tokens.fixedCountdown.top]: formatUnitValue(offsetY, \"px\"),\n [styles.tokens.fixedCountdown.left]: formatUnitValue(\n getOffsetLeft(),\n \"px\"\n ),\n [styles.tokens.fixedCountdown.right]: formatUnitValue(\n getOffsetRight(),\n \"px\"\n ),\n });\n\n useEffect(() => {\n setIsPlaying(show);\n }, [show]);\n\n useEffect(() => {\n if (remainingSeconds === 0) {\n performOnFinishHandler();\n } else if (\n typeof notifyTimer === \"number\" &&\n remainingSeconds <= notifyTimer\n ) {\n performOnTickHandler();\n performOnNotifyHandler();\n }\n }, [remainingSeconds]);\n\n useEffect(() => {\n const y = getOffsetY();\n setOffsetY(y);\n }, [isMobile, offset?.top, mobileOffset?.top]);\n\n useEffect(() => {\n if (wrapperRef.current) {\n const handleResize = throttle(handleWindowResize, 300);\n handleWindowResize();\n\n window.addEventListener(\"resize\", handleResize);\n\n return () => {\n window.removeEventListener(\"resize\", handleResize);\n };\n }\n }, [wrapperRef.current]);\n\n // Announcements\n useEffect(() => {\n const timeElapsed = initialSeconds - remainingSeconds;\n if (timeElapsed === 0) return;\n // Polite notification\n if (timeElapsed % reminderInterval === 0) {\n if (\n typeof notifyTimer !== \"number\" ||\n remainingSeconds > notifyTimer\n ) {\n setAnnouncement(getAccessibleTimeText(remainingSeconds));\n }\n }\n\n // Assertive notification\n if (\n typeof notifyTimer === \"number\" &&\n remainingSeconds === notifyTimer\n ) {\n setAnnouncement(getAccessibleTimeText(remainingSeconds));\n }\n }, [remainingSeconds, initialSeconds, reminderInterval, notifyTimer]);\n\n useEffect(() => {\n // reset\n isNotified.current = false;\n }, [initialSeconds, show]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleWindowResize = () => {\n if (!wrapperRef.current) return;\n\n const clientRect = wrapperRef.current.getBoundingClientRect();\n\n setClientRectX(clientRect.x);\n setClientRectRight(clientRect.right);\n };\n\n const handleOnFocus = () => {\n const focusMessage = getAccessibleTimeText(remainingSeconds);\n setAnnouncement(focusMessage);\n };\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n\n const performOnTickHandler = () => {\n if (onTick) {\n onTick(remainingSeconds);\n }\n };\n\n const performOnNotifyHandler = () => {\n if (onNotify && !isNotified.current) {\n isNotified.current = true;\n onNotify();\n }\n };\n\n const performOnFinishHandler = () => {\n setIsPlaying(false);\n\n if (onFinish) onFinish();\n };\n\n function getOffsetY() {\n const desktopTop = offset?.top ?? 168;\n const mobileTop = mobileOffset?.top ?? 80;\n const offsetY = isMobile ? mobileTop : desktopTop;\n\n return offsetY;\n }\n\n function getOffsetLeft() {\n if (!isMounted || align !== \"left\") return undefined;\n return offset?.left ?? clientRectX;\n }\n\n function getOffsetRight() {\n if (!isMounted || align !== \"right\") return undefined;\n return (\n offset?.right ??\n Math.floor(document.body.clientWidth - clientRectRight)\n );\n }\n\n const getAccessibleTimeText = (seconds: number): string => {\n const { minutes, seconds: secs } = TimeHelper.toMinutesSeconds(seconds);\n\n const minuteText = minutes === 1 ? \"minute\" : \"minutes\";\n const secondText = secs === 1 ? \"second\" : \"seconds\";\n\n if (minutes > 0 && secs > 0) {\n return `Time left: ${minutes} ${minuteText} and ${secs} ${secondText}`;\n } else if (minutes > 0) {\n return `Time left: ${minutes} ${minuteText}`;\n } else {\n return `Time left: ${secs} ${secondText}`;\n }\n };\n // =============================================================================\n // RENDER FUNCTION\n // =============================================================================\n\n const renderPeriodicAndWarningAnnouncement = () => (\n <VisuallyHidden\n aria-live={\n typeof notifyTimer === \"number\" &&\n remainingSeconds <= notifyTimer\n ? \"assertive\"\n : \"polite\"\n }\n aria-atomic=\"true\"\n >\n {announcement}\n </VisuallyHidden>\n );\n\n const renderTimer = () => {\n const { minutes, seconds } =\n TimeHelper.toMinutesSeconds(remainingSeconds);\n const m = minutes !== 1 ? \"mins\" : \"min\";\n const s = seconds !== 1 ? \"secs\" : \"sec\";\n return (\n <>\n <ClockIcon className={styles.timerIcon} data-warn={!!warn} />\n <div className={styles.timeLeft}>Time left:</div>\n <div\n className={styles.timer}\n aria-label={getAccessibleTimeText(remainingSeconds)}\n >\n {minutes} {m} {String(seconds).padStart(2, \"0\")} {s}\n </div>\n {renderPeriodicAndWarningAnnouncement()}\n </>\n );\n };\n\n const renderInlineCountdown = () => {\n return (\n <div\n data-testid={testId}\n data-id=\"countdown-wrapper\"\n data-warn={!!warn}\n ref={wrapperRef}\n inert={inertValue(!isVisible)}\n className={clsx(\n styles.countdown,\n styles.countdownInline,\n !isVisible && styles.countdownHidden\n )}\n tabIndex={0}\n role=\"timer\"\n aria-label=\"Countdown timer\"\n onFocus={handleOnFocus}\n >\n {renderTimer()}\n </div>\n );\n };\n\n const renderFixedCountdown = () => {\n return (\n <div\n ref={fixedCountdownRef}\n data-testid={testId}\n data-id=\"fixed-countdown-wrapper\"\n data-warn={!!warn}\n className={clsx(styles.countdown, styles.countdownFixed)}\n tabIndex={0}\n role=\"timer\"\n aria-label=\"Countdown timer\"\n onFocus={handleOnFocus}\n >\n {renderTimer()}\n </div>\n );\n };\n\n if (!isPlaying && remainingSeconds !== 0) return <></>;\n\n return (\n <div className={clsx(styles.wrapper, className)} {...otherProps}>\n <div ref={stickyRef}></div>\n {renderInlineCountdown()}\n {wrapperRef.current && !isVisible && renderFixedCountdown()}\n </div>\n );\n};\n"],"names":["CountdownTimer","_a","className","align","timer","timestamp","notifyTimer","offset","mobileOffset","show","fixed","reminderInterval","testId","onFinish","onNotify","onTick","otherProps","__rest","wrapperRef","useRef","fixedCountdownRef","isNotified","offsetY","setOffsetY","useState","clientRectRight","setClientRectRight","clientRectX","setClientRectX","isPlaying","setIsPlaying","announcement","setAnnouncement","isMounted","useIsMounted","remainingSeconds","initialSeconds","useTimer","ref","stickyRef","inView","useInView","threshold","rootMargin","initialInView","isVisible","warn","isMobile","useMaxWidthMediaQuery","useApplyStyle","styles.tokens","fixedCountdown","top","formatUnitValue","left","getOffsetLeft","right","Math","floor","document","body","clientWidth","getOffsetRight","useEffect","performOnFinishHandler","performOnTickHandler","performOnNotifyHandler","y","desktopTop","mobileTop","_b","getOffsetY","current","handleResize","throttle","handleWindowResize","window","addEventListener","removeEventListener","timeElapsed","getAccessibleTimeText","clientRect","getBoundingClientRect","x","handleOnFocus","focusMessage","seconds","minutes","secs","TimeHelper","toMinutesSeconds","minuteText","secondText","renderTimer","m","s","_jsxs","_Fragment","children","_jsx","ClockIcon","styles.timerIcon","styles.timeLeft","styles.timer","String","padStart","VisuallyHidden","Object","assign","clsx","styles.wrapper","inert","inertValue","styles.countdown","styles.countdownInline","styles.countdownHidden","tabIndex","role","onFocus","styles.countdownFixed"],"mappings":"u2CAkBO,MAAMA,EAAkBC,IAAA,IAAAC,UAC3BA,EAASC,MACTA,EAAQ,QAAOC,MACfA,EAAKC,UACLA,EAASC,YACTA,EAAWC,OACXA,EAAMC,aACNA,EAAYC,KACZA,EAAIC,MACJA,GAAQ,EAAIC,iBACZA,EAAmB,IACnB,cAAeC,EAAMC,SACrBA,EAAQC,SACRA,EAAQC,OACRA,GAAMd,EACHe,EAAUC,EAAAhB,EAfc,gKAqB3B,MAAMiB,EAAaC,EAAuB,MACpCC,EAAoBD,EAAuB,MAE3CE,EAAaF,GAAgB,IAC5BG,EAASC,GAAcC,EAAiB,IACxCC,EAAiBC,GAAsBF,EAAiB,IACxDG,EAAaC,GAAkBJ,EAAiB,IAChDK,EAAWC,IAAgBN,GAAS,IACpCO,GAAcC,IAAmBR,EAAiB,IAEnDS,GAAYC,KACXC,GAAkBC,IAAkBC,EACvCjC,EACAC,EACAwB,IAEIS,IAAKC,GAASC,OAAEA,IAAWC,EAAU,CACzCC,UAAW,EACXC,YAAyB,EAAVrB,EAAH,iBACZsB,eAAe,IAE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EAAA,MAAA,CAAKjG,UAAWoG,EAAeJ,SAAA,eAC/BF,EAAA,MAAA,CACI9F,UAAWqG,EAAY,aACXvB,GAAsB7C,IAAiB+D,SAAA,CAElDX,EAAO,IAAGO,EAAC,IAAGU,OAAOlB,GAASmB,SAAS,EAAG,KAAI,IAAGV,KA1B9DI,EAACO,EAAc,CAAA,YAEgB,iBAAhBpG,GACP6B,IAAoB7B,EACd,YACA,SAAQ,cAEN,gBAEXyB,OAoBE,EA6CX,OAAKF,GAAkC,IAArBM,GAGd6D,EAAA,MAAAW,OAAAC,OAAA,CAAK1G,UAAW2G,EAAKC,EAAgB5G,IAAgBc,aACjDmF,EAAA,MAAA,CAAK7D,IAAKC,KA3CV4D,EAAA,MAAA,CAAA,cACiBvF,EAAM,UACX,oBAAmB,cACdkC,GACbR,IAAKpB,EACL6F,MAAOC,GAAYnE,IACnB3C,UAAW2G,EACPI,EACAC,GACCrE,IAAasE,GAElBC,SAAU,EACVC,KAAK,QAAO,aACD,kBACXC,QAASlC,GAAac,SAErBL,OA6BJ3E,EAAWsD,UAAY3B,IAtBxBsD,SACI7D,IAAKlB,EAAiB,cACTR,YACL,0BAAyB,cACpBkC,GACb5C,UAAW2G,EAAKI,EAAkBM,GAClCH,SAAU,EACVC,KAAK,qBACM,kBACXC,QAASlC,YAERS,WAKoCM,OAOvC"}
|
|
1
|
+
{"version":3,"file":"countdown-timer.js","sources":["../../src/countdown-timer/countdown-timer.tsx"],"sourcesContent":["import { ClockIcon } from \"@lifesg/react-icons\";\nimport clsx from \"clsx\";\nimport throttle from \"lodash/throttle\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport { inertValue, VisuallyHidden } from \"../shared/accessibility\";\nimport {\n formatUnitValue,\n useApplyStyle,\n useMaxWidthMediaQuery,\n} from \"../theme\";\nimport { useIsMounted } from \"../util\";\nimport { TimeHelper } from \"../util/time-helper\";\nimport * as styles from \"./countdown-timer.styles\";\nimport type { CountdownTimerProps } from \"./types\";\nimport { useTimer } from \"./use-timer\";\n\n/**\n * Displays a live countdown of time remaining until a deadline.\n *\n * Use when a time-limited interaction — such as a session timeout or a timed\n * form — needs a persistent visual reminder.\n */\nexport const CountdownTimer = ({\n className,\n align = \"right\",\n timer,\n timestamp,\n notifyTimer,\n offset,\n mobileOffset,\n show,\n fixed = true,\n reminderInterval = 120,\n \"data-testid\": testId,\n onFinish,\n onNotify,\n onTick,\n ...otherProps\n}: CountdownTimerProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n const fixedCountdownRef = useRef<HTMLDivElement>(null);\n\n const isNotified = useRef<boolean>(false);\n const [offsetY, setOffsetY] = useState<number>(0);\n const [clientRectRight, setClientRectRight] = useState<number>(0);\n const [clientRectX, setClientRectX] = useState<number>(0);\n const [isPlaying, setIsPlaying] = useState(false);\n const [announcement, setAnnouncement] = useState<string>(\"\");\n\n const isMounted = useIsMounted();\n const [remainingSeconds, initialSeconds] = useTimer(\n timer,\n timestamp,\n isPlaying\n );\n const { ref: stickyRef, inView } = useInView({\n threshold: 1,\n rootMargin: `${offsetY * -1}px 0px 0px 0px`,\n initialInView: true,\n });\n const isVisible = !fixed || inView;\n const warn =\n typeof notifyTimer === \"number\" && remainingSeconds <= notifyTimer;\n\n const isMobile = useMaxWidthMediaQuery(\"sm\");\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n\n useApplyStyle(fixedCountdownRef, {\n [styles.tokens.fixedCountdown.top]: formatUnitValue(offsetY, \"px\"),\n [styles.tokens.fixedCountdown.left]: formatUnitValue(\n getOffsetLeft(),\n \"px\"\n ),\n [styles.tokens.fixedCountdown.right]: formatUnitValue(\n getOffsetRight(),\n \"px\"\n ),\n });\n\n useEffect(() => {\n setIsPlaying(show);\n }, [show]);\n\n useEffect(() => {\n if (remainingSeconds === 0) {\n performOnFinishHandler();\n } else if (\n typeof notifyTimer === \"number\" &&\n remainingSeconds <= notifyTimer\n ) {\n performOnTickHandler();\n performOnNotifyHandler();\n }\n }, [remainingSeconds]);\n\n useEffect(() => {\n const y = getOffsetY();\n setOffsetY(y);\n }, [isMobile, offset?.top, mobileOffset?.top]);\n\n useEffect(() => {\n if (wrapperRef.current) {\n const handleResize = throttle(handleWindowResize, 300);\n handleWindowResize();\n\n window.addEventListener(\"resize\", handleResize);\n\n return () => {\n window.removeEventListener(\"resize\", handleResize);\n };\n }\n }, [wrapperRef.current]);\n\n // Announcements\n useEffect(() => {\n const timeElapsed = initialSeconds - remainingSeconds;\n if (timeElapsed === 0) return;\n // Polite notification\n if (timeElapsed % reminderInterval === 0) {\n if (\n typeof notifyTimer !== \"number\" ||\n remainingSeconds > notifyTimer\n ) {\n setAnnouncement(getAccessibleTimeText(remainingSeconds));\n }\n }\n\n // Assertive notification\n if (\n typeof notifyTimer === \"number\" &&\n remainingSeconds === notifyTimer\n ) {\n setAnnouncement(getAccessibleTimeText(remainingSeconds));\n }\n }, [remainingSeconds, initialSeconds, reminderInterval, notifyTimer]);\n\n useEffect(() => {\n // reset\n isNotified.current = false;\n }, [initialSeconds, show]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleWindowResize = () => {\n if (!wrapperRef.current) return;\n\n const clientRect = wrapperRef.current.getBoundingClientRect();\n\n setClientRectX(clientRect.x);\n setClientRectRight(clientRect.right);\n };\n\n const handleOnFocus = () => {\n const focusMessage = getAccessibleTimeText(remainingSeconds);\n setAnnouncement(focusMessage);\n };\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n\n const performOnTickHandler = () => {\n if (onTick) {\n onTick(remainingSeconds);\n }\n };\n\n const performOnNotifyHandler = () => {\n if (onNotify && !isNotified.current) {\n isNotified.current = true;\n onNotify();\n }\n };\n\n const performOnFinishHandler = () => {\n setIsPlaying(false);\n\n if (onFinish) onFinish();\n };\n\n function getOffsetY() {\n const desktopTop = offset?.top ?? 168;\n const mobileTop = mobileOffset?.top ?? 80;\n const offsetY = isMobile ? mobileTop : desktopTop;\n\n return offsetY;\n }\n\n function getOffsetLeft() {\n if (!isMounted || align !== \"left\") return undefined;\n return offset?.left ?? clientRectX;\n }\n\n function getOffsetRight() {\n if (!isMounted || align !== \"right\") return undefined;\n return (\n offset?.right ??\n Math.floor(document.body.clientWidth - clientRectRight)\n );\n }\n\n const getAccessibleTimeText = (seconds: number): string => {\n const { minutes, seconds: secs } = TimeHelper.toMinutesSeconds(seconds);\n\n const minuteText = minutes === 1 ? \"minute\" : \"minutes\";\n const secondText = secs === 1 ? \"second\" : \"seconds\";\n\n if (minutes > 0 && secs > 0) {\n return `Time left: ${minutes} ${minuteText} and ${secs} ${secondText}`;\n } else if (minutes > 0) {\n return `Time left: ${minutes} ${minuteText}`;\n } else {\n return `Time left: ${secs} ${secondText}`;\n }\n };\n // =============================================================================\n // RENDER FUNCTION\n // =============================================================================\n\n const renderPeriodicAndWarningAnnouncement = () => (\n <VisuallyHidden\n aria-live={\n typeof notifyTimer === \"number\" &&\n remainingSeconds <= notifyTimer\n ? \"assertive\"\n : \"polite\"\n }\n aria-atomic=\"true\"\n >\n {announcement}\n </VisuallyHidden>\n );\n\n const renderTimer = () => {\n const { minutes, seconds } =\n TimeHelper.toMinutesSeconds(remainingSeconds);\n const m = minutes !== 1 ? \"mins\" : \"min\";\n const s = seconds !== 1 ? \"secs\" : \"sec\";\n return (\n <>\n <ClockIcon className={styles.timerIcon} data-warn={!!warn} />\n <div className={styles.timeLeft}>Time left:</div>\n <div\n className={styles.timer}\n aria-label={getAccessibleTimeText(remainingSeconds)}\n >\n {minutes} {m} {String(seconds).padStart(2, \"0\")} {s}\n </div>\n {renderPeriodicAndWarningAnnouncement()}\n </>\n );\n };\n\n const renderInlineCountdown = () => {\n return (\n <div\n data-testid={testId}\n data-id=\"countdown-wrapper\"\n data-warn={!!warn}\n ref={wrapperRef}\n inert={inertValue(!isVisible)}\n className={clsx(\n styles.countdown,\n styles.countdownInline,\n !isVisible && styles.countdownHidden\n )}\n tabIndex={0}\n role=\"timer\"\n aria-label=\"Countdown timer\"\n onFocus={handleOnFocus}\n >\n {renderTimer()}\n </div>\n );\n };\n\n const renderFixedCountdown = () => {\n return (\n <div\n ref={fixedCountdownRef}\n data-testid={testId}\n data-id=\"fixed-countdown-wrapper\"\n data-warn={!!warn}\n className={clsx(styles.countdown, styles.countdownFixed)}\n tabIndex={0}\n role=\"timer\"\n aria-label=\"Countdown timer\"\n onFocus={handleOnFocus}\n >\n {renderTimer()}\n </div>\n );\n };\n\n if (!isPlaying && remainingSeconds !== 0) return <></>;\n\n return (\n <div className={clsx(styles.wrapper, className)} {...otherProps}>\n <div ref={stickyRef}></div>\n {renderInlineCountdown()}\n {wrapperRef.current && !isVisible && renderFixedCountdown()}\n </div>\n );\n};\n"],"names":["CountdownTimer","_a","className","align","timer","timestamp","notifyTimer","offset","mobileOffset","show","fixed","reminderInterval","testId","onFinish","onNotify","onTick","otherProps","__rest","wrapperRef","useRef","fixedCountdownRef","isNotified","offsetY","setOffsetY","useState","clientRectRight","setClientRectRight","clientRectX","setClientRectX","isPlaying","setIsPlaying","announcement","setAnnouncement","isMounted","useIsMounted","remainingSeconds","initialSeconds","useTimer","ref","stickyRef","inView","useInView","threshold","rootMargin","initialInView","isVisible","warn","isMobile","useMaxWidthMediaQuery","useApplyStyle","styles.tokens","fixedCountdown","top","formatUnitValue","left","getOffsetLeft","right","Math","floor","document","body","clientWidth","getOffsetRight","useEffect","performOnFinishHandler","performOnTickHandler","performOnNotifyHandler","y","desktopTop","mobileTop","_b","getOffsetY","current","handleResize","throttle","handleWindowResize","window","addEventListener","removeEventListener","timeElapsed","getAccessibleTimeText","clientRect","getBoundingClientRect","x","handleOnFocus","focusMessage","seconds","minutes","secs","TimeHelper","toMinutesSeconds","minuteText","secondText","renderTimer","m","s","_jsxs","_Fragment","children","_jsx","ClockIcon","styles.timerIcon","styles.timeLeft","styles.timer","String","padStart","VisuallyHidden","Object","assign","clsx","styles.wrapper","inert","inertValue","styles.countdown","styles.countdownInline","styles.countdownHidden","tabIndex","role","onFocus","styles.countdownFixed"],"mappings":"u2CAwBO,MAAMA,EAAkBC,IAAA,IAAAC,UAC3BA,EAASC,MACTA,EAAQ,QAAOC,MACfA,EAAKC,UACLA,EAASC,YACTA,EAAWC,OACXA,EAAMC,aACNA,EAAYC,KACZA,EAAIC,MACJA,GAAQ,EAAIC,iBACZA,EAAmB,IACnB,cAAeC,EAAMC,SACrBA,EAAQC,SACRA,EAAQC,OACRA,GAAMd,EACHe,EAAUC,EAAAhB,EAfc,gKAqB3B,MAAMiB,EAAaC,EAAuB,MACpCC,EAAoBD,EAAuB,MAE3CE,EAAaF,GAAgB,IAC5BG,EAASC,GAAcC,EAAiB,IACxCC,EAAiBC,GAAsBF,EAAiB,IACxDG,EAAaC,GAAkBJ,EAAiB,IAChDK,EAAWC,IAAgBN,GAAS,IACpCO,GAAcC,IAAmBR,EAAiB,IAEnDS,GAAYC,KACXC,GAAkBC,IAAkBC,EACvCjC,EACAC,EACAwB,IAEIS,IAAKC,GAASC,OAAEA,IAAWC,EAAU,CACzCC,UAAW,EACXC,YAAyB,EAAVrB,EAAH,iBACZsB,eAAe,IAEbC,IAAanC,GAAS8B,GACtBM,GACqB,iBAAhBxC,GAA4B6B,IAAoB7B,EAErDyC,GAAWC,EAAsB,MAMvCC,EAAc7B,EAAmB,CAC7B,CAAC8B,EAAcC,eAAeC,KAAMC,EAAgB/B,EAAS,MAC7D,CAAC4B,EAAcC,eAAeG,MAAOD,EAwHzC,iBACI,OAAKpB,IAAuB,SAAV9B,EACC,QAAZF,EAAAM,aAAM,EAANA,EAAQ+C,YAAI,IAAArD,EAAAA,EAAI0B,OADa,CAExC,CA1HQ4B,GACA,MAEJ,CAACL,EAAcC,eAAeK,OAAQH,EAyH1C,iBACI,OAAKpB,IAAuB,UAAV9B,EAED,UAAbI,aAAM,EAANA,EAAQiD,aAAK,IAAAvD,EAAAA,EACbwD,KAAKC,MAAMC,SAASC,KAAKC,YAAcpC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,IAAKpB,EACL6F,MAAOC,GAAYnE,IACnB3C,UAAW2G,EACPI,EACAC,GACCrE,IAAasE,GAElBC,SAAU,EACVC,KAAK,QAAO,aACD,kBACXC,QAASlC,GAAac,SAErBL,OA6BJ3E,EAAWsD,UAAY3B,IAtBxBsD,SACI7D,IAAKlB,EAAiB,cACTR,YACL,0BAAyB,cACpBkC,GACb5C,UAAW2G,EAAKI,EAAkBM,GAClCH,SAAU,EACVC,KAAK,qBACM,kBACXC,QAASlC,YAERS,WAKoCM,OAOvC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
.wav7a6b{width:100%;}
|
|
1
|
+
@layer fds{.wav7a6b{width:100%;}
|
|
2
2
|
.c1ji5mw9{font-family:var(--fds-font-family-body);font-variant:var(--fds-font-variant);font-size:var(--fds-font-body-size-baseline);font-weight:var(--fds-font-weight-regular);line-height:var(--fds-font-body-lh-baseline);letter-spacing:var(--fds-font-body-ls-baseline);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;padding:var(--fds-spacing-8) var(--fds-spacing-16);border-radius:var(--fds-radius-sm);color:var(--fds-colour-text-primary);border:var(--fds-border-width-010) var(--fds-border-style-solid);border-color:var(--fds-colour-border-primary);background-color:var(--fds-colour-bg);}:where(body.fds-breakpoint-sm-max) .c1ji5mw9{padding:var(--fds-spacing-16);}.c1ji5mw9[data-warn="true"]{color:var(--fds-colour-text-error);border-color:var(--fds-colour-border-error);}
|
|
3
3
|
.csdqyky{opacity:0;}
|
|
4
4
|
.cibq1kp{position:relative;}
|
|
5
5
|
.c1ehax2j{position:fixed;z-index:10;--fds-internal-countdownTimer-fixedCountdown-top:initial;--fds-internal-countdownTimer-fixedCountdown-left:initial;--fds-internal-countdownTimer-fixedCountdown-right:initial;top:var(--fds-internal-countdownTimer-fixedCountdown-top);left:var(--fds-internal-countdownTimer-fixedCountdown-left);right:var(--fds-internal-countdownTimer-fixedCountdown-right);box-shadow:var(--fds-shadow-xs-focus-strong);}:where(body.fds-breakpoint-sm-max) .c1ehax2j{left:0;right:0;border-radius:0;border-left:none;border-right:none;box-shadow:none;}.c1ehax2j[data-warn="true"]{box-shadow:var(--fds-shadow-xs-error-strong);}
|
|
6
6
|
.t6f42l5{font-weight:var(--fds-font-weight-bold);margin-left:var(--fds-spacing-8);margin-right:var(--fds-spacing-24);}:where(body.fds-breakpoint-sm-max) .t6f42l5{margin-right:var(--fds-spacing-48);}
|
|
7
7
|
.t19x1azi{font-weight:var(--fds-font-weight-semibold);margin-left:auto;}
|
|
8
|
-
.t1pvvziw{color:var(--fds-colour-icon-primary);}.t1pvvziw[data-warn="true"]{color:var(--fds-colour-icon-error);}
|
|
8
|
+
.t1pvvziw{color:var(--fds-colour-icon-primary);}.t1pvvziw[data-warn="true"]{color:var(--fds-colour-icon-error);}}
|
|
@@ -8,37 +8,81 @@ interface Offset {
|
|
|
8
8
|
interface MobileOffset {
|
|
9
9
|
top?: number | undefined;
|
|
10
10
|
}
|
|
11
|
+
/** Base props shared by both the `timer`-based and `timestamp`-based variants. */
|
|
11
12
|
interface CountdownTimerBaseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
12
13
|
"data-testid"?: string | undefined;
|
|
13
|
-
/**
|
|
14
|
+
/** Controls whether the timer is visible and actively counting down. */
|
|
14
15
|
show: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* When `true`, the timer switches to a fixed viewport overlay once its
|
|
18
|
+
* inline position scrolls out of view, keeping the countdown visible at
|
|
19
|
+
* all times.
|
|
20
|
+
*
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
15
23
|
fixed?: boolean | undefined;
|
|
16
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Remaining-seconds threshold at which the warning state activates.
|
|
26
|
+
* Once the countdown reaches this value, `onNotify` fires once and
|
|
27
|
+
* `onTick` fires every second until the timer finishes.
|
|
28
|
+
*/
|
|
17
29
|
notifyTimer?: number | undefined;
|
|
18
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Fine-tunes the fixed overlay position on tablet and desktop viewports.
|
|
32
|
+
*
|
|
33
|
+
* @remarks `top` defaults to 168 when not provided; `left`/`right`
|
|
34
|
+
* fall back to the bounding-rect of the inline wrapper.
|
|
35
|
+
*/
|
|
19
36
|
offset?: Offset | undefined;
|
|
20
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Fine-tunes the fixed overlay position on mobile viewports.
|
|
39
|
+
*
|
|
40
|
+
* @default { top: 80 }
|
|
41
|
+
*/
|
|
21
42
|
mobileOffset?: MobileOffset | undefined;
|
|
22
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Side of the inline wrapper the fixed overlay is pinned to when
|
|
45
|
+
* scrolled into sticky mode.
|
|
46
|
+
*
|
|
47
|
+
* @default "right"
|
|
48
|
+
*/
|
|
23
49
|
align?: AlignPosition | undefined;
|
|
24
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Called every second with the remaining seconds once the countdown falls
|
|
52
|
+
* at or below `notifyTimer`.
|
|
53
|
+
*/
|
|
25
54
|
onTick?: ((seconds: number) => void) | undefined;
|
|
26
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Called once when the remaining seconds first reach the `notifyTimer`
|
|
57
|
+
* threshold.
|
|
58
|
+
*
|
|
59
|
+
* @remarks Fires at most once per timer session; resets when `show` or
|
|
60
|
+
* `timer`/`timestamp` changes.
|
|
61
|
+
*/
|
|
27
62
|
onNotify?: (() => void) | undefined;
|
|
28
|
-
/** Called when countdown reaches
|
|
63
|
+
/** Called when the countdown reaches zero. */
|
|
29
64
|
onFinish?: (() => void) | undefined;
|
|
30
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Interval in seconds between polite screen-reader announcement of the
|
|
67
|
+
* remaining time while the timer is above the `notifyTimer`
|
|
68
|
+
* threshold.
|
|
69
|
+
*
|
|
70
|
+
* @default 120
|
|
71
|
+
*/
|
|
31
72
|
reminderInterval?: number | undefined;
|
|
32
73
|
}
|
|
74
|
+
/** Props for the duration-based variant. Supply `timer` to count down from a fixed number of seconds. */
|
|
33
75
|
interface TimerProps extends CountdownTimerBaseProps {
|
|
34
|
-
/**
|
|
76
|
+
/** Duration of the countdown in seconds. */
|
|
35
77
|
timer: number;
|
|
36
78
|
timestamp?: number | undefined;
|
|
37
79
|
}
|
|
80
|
+
/** Props for the deadline-based variant. Supply `timestamp` to count down to an absolute point in time. */
|
|
38
81
|
interface TimestampProps extends CountdownTimerBaseProps {
|
|
39
|
-
/**
|
|
82
|
+
/** Unix timestamp (milliseconds since Jan 1, 1970) at which the countdown ends. */
|
|
40
83
|
timestamp: number;
|
|
41
84
|
timer?: number | undefined;
|
|
42
85
|
}
|
|
86
|
+
/** Props for `CountdownTimer`. Provide either `timer` (duration in seconds) or `timestamp` (Unix ms deadline). */
|
|
43
87
|
export type CountdownTimerProps = TimerProps | TimestampProps;
|
|
44
88
|
export {};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { DashedBorderProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* A container that renders a dashed border using an SVG overlay.
|
|
4
|
+
*
|
|
5
|
+
* Use when you need a dashed visual boundary around content — for example, drop zones,
|
|
6
|
+
* placeholder regions, or empty-state containers.
|
|
7
|
+
*/
|
|
2
8
|
export declare const DashedBorder: (props: DashedBorderProps & import("react").RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashed-border.js","sources":["../../src/dashed-border/dashed-border.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, useRef } from \"react\";\n\nimport { BorderThickness, Colour, Radius, useApplyStyle } from \"../theme\";\nimport { toCssValue, useResolvedTokenValue } from \"../theme/utils\";\nimport { mergeRefs } from \"../util\";\nimport {\n isColourToken,\n isRadiusToken,\n isThicknessToken,\n} from \"../util/styling-helper\";\nimport * as styles from \"./dashed-border.styles\";\nimport { createSvgBackgroundImage } from \"./dashed-border.utils\";\nimport type { DashedBorderProps } from \"./types\";\n\nconst Component = (\n props: DashedBorderProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n const {\n enabled = true,\n thickness = BorderThickness[\"width-010\"],\n radius = Radius[\"none\"],\n colour = Colour[\"border\"],\n backgroundColor,\n className,\n children,\n ...otherProps\n } = props;\n\n const effectiveThickness = useResolvedTokenValue({\n value: thickness,\n fallback: BorderThickness[\"width-010\"],\n isToken: isThicknessToken,\n normalizeCustom: toCssValue,\n });\n\n const effectiveRadius = useResolvedTokenValue({\n value: radius,\n fallback: Radius[\"none\"],\n isToken: isRadiusToken,\n normalizeCustom: toCssValue,\n });\n\n const effectiveColour = useResolvedTokenValue({\n value: colour,\n fallback: Colour[\"border\"],\n isToken: isColourToken,\n normalizeCustom: String,\n });\n\n const effectiveBackgroundColor = useResolvedTokenValue({\n value: backgroundColor,\n fallback: \"none\",\n isToken: isColourToken,\n normalizeCustom: String,\n });\n\n const showSvg = enabled || !!backgroundColor;\n const overlayBackgroundImage = createSvgBackgroundImage({\n radius: effectiveRadius,\n colour: effectiveColour,\n thickness: effectiveThickness,\n enabled,\n });\n const rootRef = useRef<HTMLDivElement>(null);\n const overlayRef = useRef<HTMLDivElement>(null);\n const mergedRootRef = ref ? mergeRefs(rootRef, ref) : rootRef;\n\n useApplyStyle(rootRef, {\n [styles.tokens.rootRadius]: effectiveRadius,\n [styles.tokens.rootBackgroundColor]: backgroundColor\n ? effectiveBackgroundColor\n : null,\n });\n\n useApplyStyle(overlayRef, {\n [styles.tokens.overlayBackgroundImage]: showSvg\n ? overlayBackgroundImage\n : null,\n });\n\n return (\n <div\n ref={mergedRootRef}\n className={clsx(styles.root, className)}\n {...otherProps}\n >\n {showSvg && (\n <div\n aria-hidden=\"true\"\n className={styles.overlay}\n ref={overlayRef}\n />\n )}\n {children}\n </div>\n );\n};\n\nexport const DashedBorder = forwardRef(Component);\n"],"names":["DashedBorder","forwardRef","props","ref","enabled","thickness","BorderThickness","radius","Radius","colour","Colour","backgroundColor","className","children","otherProps","__rest","effectiveThickness","useResolvedTokenValue","value","fallback","isToken","isThicknessToken","normalizeCustom","toCssValue","effectiveRadius","isRadiusToken","effectiveColour","isColourToken","String","effectiveBackgroundColor","showSvg","overlayBackgroundImage","createSvgBackgroundImage","rootRef","useRef","overlayRef","mergedRootRef","mergeRefs","useApplyStyle","styles.tokens","rootRadius","rootBackgroundColor","_jsxs","Object","assign","clsx","styles.root","_jsx","styles.overlay"],"mappings":"+qCAeA,
|
|
1
|
+
{"version":3,"file":"dashed-border.js","sources":["../../src/dashed-border/dashed-border.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, useRef } from \"react\";\n\nimport { BorderThickness, Colour, Radius, useApplyStyle } from \"../theme\";\nimport { toCssValue, useResolvedTokenValue } from \"../theme/utils\";\nimport { mergeRefs } from \"../util\";\nimport {\n isColourToken,\n isRadiusToken,\n isThicknessToken,\n} from \"../util/styling-helper\";\nimport * as styles from \"./dashed-border.styles\";\nimport { createSvgBackgroundImage } from \"./dashed-border.utils\";\nimport type { DashedBorderProps } from \"./types\";\n\nconst Component = (\n props: DashedBorderProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n const {\n enabled = true,\n thickness = BorderThickness[\"width-010\"],\n radius = Radius[\"none\"],\n colour = Colour[\"border\"],\n backgroundColor,\n className,\n children,\n ...otherProps\n } = props;\n\n const effectiveThickness = useResolvedTokenValue({\n value: thickness,\n fallback: BorderThickness[\"width-010\"],\n isToken: isThicknessToken,\n normalizeCustom: toCssValue,\n });\n\n const effectiveRadius = useResolvedTokenValue({\n value: radius,\n fallback: Radius[\"none\"],\n isToken: isRadiusToken,\n normalizeCustom: toCssValue,\n });\n\n const effectiveColour = useResolvedTokenValue({\n value: colour,\n fallback: Colour[\"border\"],\n isToken: isColourToken,\n normalizeCustom: String,\n });\n\n const effectiveBackgroundColor = useResolvedTokenValue({\n value: backgroundColor,\n fallback: \"none\",\n isToken: isColourToken,\n normalizeCustom: String,\n });\n\n const showSvg = enabled || !!backgroundColor;\n const overlayBackgroundImage = createSvgBackgroundImage({\n radius: effectiveRadius,\n colour: effectiveColour,\n thickness: effectiveThickness,\n enabled,\n });\n const rootRef = useRef<HTMLDivElement>(null);\n const overlayRef = useRef<HTMLDivElement>(null);\n const mergedRootRef = ref ? mergeRefs(rootRef, ref) : rootRef;\n\n useApplyStyle(rootRef, {\n [styles.tokens.rootRadius]: effectiveRadius,\n [styles.tokens.rootBackgroundColor]: backgroundColor\n ? effectiveBackgroundColor\n : null,\n });\n\n useApplyStyle(overlayRef, {\n [styles.tokens.overlayBackgroundImage]: showSvg\n ? overlayBackgroundImage\n : null,\n });\n\n return (\n <div\n ref={mergedRootRef}\n className={clsx(styles.root, className)}\n {...otherProps}\n >\n {showSvg && (\n <div\n aria-hidden=\"true\"\n className={styles.overlay}\n ref={overlayRef}\n />\n )}\n {children}\n </div>\n );\n};\n\n/**\n * A container that renders a dashed border using an SVG overlay.\n *\n * Use when you need a dashed visual boundary around content — for example, drop zones,\n * placeholder regions, or empty-state containers.\n */\nexport const DashedBorder = forwardRef(Component);\n"],"names":["DashedBorder","forwardRef","props","ref","enabled","thickness","BorderThickness","radius","Radius","colour","Colour","backgroundColor","className","children","otherProps","__rest","effectiveThickness","useResolvedTokenValue","value","fallback","isToken","isThicknessToken","normalizeCustom","toCssValue","effectiveRadius","isRadiusToken","effectiveColour","isColourToken","String","effectiveBackgroundColor","showSvg","overlayBackgroundImage","createSvgBackgroundImage","rootRef","useRef","overlayRef","mergedRootRef","mergeRefs","useApplyStyle","styles.tokens","rootRadius","rootBackgroundColor","_jsxs","Object","assign","clsx","styles.root","_jsx","styles.overlay"],"mappings":"+qCAeA,MA2FaA,EAAeC,GA3FV,CACdC,EACAC,KAEA,MAAMC,QACFA,GAAU,EAAIC,UACdA,EAAYC,EAAgB,aAAYC,OACxCA,EAASC,EAAa,KAACC,OACvBA,EAASC,EAAe,OAACC,gBACzBA,EAAeC,UACfA,EAASC,SACTA,GAEAX,EADGY,EAAUC,EACbb,EATE,CAAA,UAAA,YAAA,SAAA,SAAA,kBAAA,YAAA,aAWAc,EAAqBC,EAAsB,CAC7CC,MAAOb,EACPc,SAAUb,EAAgB,aAC1Bc,QAASC,EACTC,gBAAiBC,IAGfC,EAAkBP,EAAsB,CAC1CC,MAAOX,EACPY,SAAUX,EAAa,KACvBY,QAASK,EACTH,gBAAiBC,IAGfG,EAAkBT,EAAsB,CAC1CC,MAAOT,EACPU,SAAUT,EAAe,OACzBU,QAASO,EACTL,gBAAiBM,SAGfC,EAA2BZ,EAAsB,CACnDC,MAAOP,EACPQ,SAAU,OACVC,QAASO,EACTL,gBAAiBM,SAGfE,EAAU1B,KAAaO,EACvBoB,EAAyBC,EAAyB,CACpDzB,OAAQiB,EACRf,OAAQiB,EACRrB,UAAWW,EACXZ,YAEE6B,EAAUC,EAAuB,MACjCC,EAAaD,EAAuB,MACpCE,EAAgBjC,EAAMkC,EAAUJ,EAAS9B,GAAO8B,EAetD,OAbAK,EAAcL,EAAS,CACnB,CAACM,EAAcC,YAAahB,EAC5B,CAACe,EAAcE,qBAAsB9B,EAC/BkB,EACA,OAGVS,EAAcH,EAAY,CACtB,CAACI,EAAcR,wBAAyBD,EAClCC,EACA,OAINW,EAAA,MAAAC,OAAAC,OAAA,CACIzC,IAAKiC,EACLxB,UAAWiC,EAAKC,EAAalC,IACzBE,EAAU,CAAAD,SAAA,CAEbiB,GACGiB,uBACgB,OACZnC,UAAWoC,EACX7C,IAAKgC,IAGZtB,KACC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.r1c3yh16{position:relative;overflow:hidden;border-radius:var(--fds-internal-dashedBorder-root-radius, 0);background-color:var(--fds-internal-dashedBorder-root-backgroundColor, transparent);}
|
|
2
|
-
.okel4vg{position:absolute;inset:0;width:100%;height:100%;background-image:var(--fds-internal-dashedBorder-overlay-backgroundImage, none);background-repeat:no-repeat;-webkit-background-position:center;background-position:center;-webkit-background-size:100% 100%;background-size:100% 100%;pointer-events:none;}
|
|
1
|
+
@layer fds{.r1c3yh16{position:relative;overflow:hidden;border-radius:var(--fds-internal-dashedBorder-root-radius, 0);background-color:var(--fds-internal-dashedBorder-root-backgroundColor, transparent);}
|
|
2
|
+
.okel4vg{position:absolute;inset:0;width:100%;height:100%;background-image:var(--fds-internal-dashedBorder-overlay-backgroundImage, none);background-repeat:no-repeat;-webkit-background-position:center;background-position:center;-webkit-background-size:100% 100%;background-size:100% 100%;pointer-events:none;}}
|
package/dashed-border/types.d.ts
CHANGED
|
@@ -2,16 +2,38 @@ import type { BorderThickness, ColourCSSVariableString, RadiusCSSVariableString
|
|
|
2
2
|
import type { ValueOf } from "../util/utility-types";
|
|
3
3
|
type CustomCssValue = number | (string & {});
|
|
4
4
|
type CustomCssString = string & {};
|
|
5
|
+
/** Props for the `DashedBorder` component. */
|
|
5
6
|
export interface DashedBorderProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color" | "style"> {
|
|
6
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Optional background fill applied inside the container, behind the dashed overlay.
|
|
9
|
+
*
|
|
10
|
+
* @remarks If this prop is provided, the background colour remains
|
|
11
|
+
* visible even when `enabled` is `false`
|
|
12
|
+
*/
|
|
7
13
|
backgroundColor?: ColourCSSVariableString | CustomCssString | undefined;
|
|
8
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Stroke colour for the dashed border.
|
|
16
|
+
*
|
|
17
|
+
* @default Colour["border"]
|
|
18
|
+
*/
|
|
9
19
|
colour?: ColourCSSVariableString | CustomCssString | undefined;
|
|
10
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Whether the dashed stroke is rendered.
|
|
22
|
+
*
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
11
25
|
enabled?: boolean | undefined;
|
|
12
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Corner radius of the container and the dashed stroke.
|
|
28
|
+
*
|
|
29
|
+
* @default Radius["none"]
|
|
30
|
+
*/
|
|
13
31
|
radius?: RadiusCSSVariableString | CustomCssValue | undefined;
|
|
14
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Width of the dashed stroke.
|
|
34
|
+
*
|
|
35
|
+
* @default BorderThickness["width-010"]
|
|
36
|
+
*/
|
|
15
37
|
thickness?: ValueOf<typeof BorderThickness> | CustomCssValue | undefined;
|
|
16
38
|
}
|
|
17
39
|
export {};
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { DataTableProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Renders a sortable, selectable data table with scroll-aware action bar and loading state support.
|
|
4
|
+
*
|
|
5
|
+
* Use `DataTable` when presenting structured multi-column data that users may need to sort by
|
|
6
|
+
* column or select rows for bulk actions. Row selection, sort indicators, and the action bar
|
|
7
|
+
* content are all externally controlled; the component manages scroll detection, sticky-header
|
|
8
|
+
* positioning, and floating action bar behaviour internally.
|
|
9
|
+
*/
|
|
2
10
|
export declare const DataTable: ({ id, headers, rows, className, sortIndicators, alternatingRows, loadState, enableMultiSelect, selectedIds, disabledIds, enableActionBar, enableSelectAll, enableStickyHeader, emptyView, actionBarContent, renderCustomEmptyView, onHeaderClick, onSelect, onSelectAll, onClearSelectionClick, ...otherProps }: DataTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.js","sources":["../../src/data-table/data-table.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowUpIcon } from \"@lifesg/react-icons\";\nimport clsx from \"clsx\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useInView } from \"react-intersection-observer\";\nimport { useResizeDetector } from \"react-resize-detector\";\n\nimport { LoadingDotsSpinner } from \"../animations\";\nimport { Checkbox } from \"../checkbox\";\nimport { ErrorDisplay } from \"../error-display\";\nimport { concatIds, VisuallyHidden } from \"../shared/accessibility\";\nimport { BasicButton } from \"../shared/input-wrapper\";\nimport { useApplyStyle } from \"../theme\";\nimport { Typography } from \"../typography\";\nimport { useId } from \"../util\";\nimport { useEventListener } from \"../util/use-event-listener\";\nimport * as styles from \"./data-table.styles\";\nimport type { DataTableProps, HeaderProps, RowProps } from \"./types\";\n\nexport const DataTable = ({\n id,\n headers,\n rows,\n className,\n sortIndicators,\n alternatingRows,\n loadState = \"success\",\n enableMultiSelect,\n selectedIds,\n disabledIds,\n enableActionBar,\n enableSelectAll,\n enableStickyHeader,\n emptyView,\n actionBarContent,\n renderCustomEmptyView,\n onHeaderClick,\n onSelect,\n onSelectAll,\n onClearSelectionClick,\n ...otherProps\n}: DataTableProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const tableRef = useRef<HTMLTableElement>(null);\n const tableEndRef = useRef<HTMLDivElement | null>(null);\n const headerRef = useRef<HTMLTableSectionElement>(null);\n const actionBarRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const internalId = useId();\n const keyColumns = headers.filter(\n (header): header is Exclude<HeaderProps, string> => {\n return typeof header !== \"string\" && !!header.keyColumn;\n }\n );\n\n const [scrollable, setScrollable] = useState(false);\n const [scrollEnd, setScrollEnd] = useState(false);\n const [isFloatingActionBar, setIsFloatingActionBar] = useState(false);\n const [showLastBorder, setShowLastBorder] = useState(false);\n\n const { ref: endRef, inView: end } = useInView();\n\n useApplyStyle(actionBarRef, {\n [styles.tokens.actionBarWrapperLeft]:\n isFloatingActionBar && tableRef.current\n ? `${tableRef.current.getBoundingClientRect().left}px`\n : undefined,\n [styles.tokens.actionBarWrapperWidth]:\n isFloatingActionBar && tableRef.current\n ? `${tableRef.current.clientWidth}px`\n : undefined,\n });\n\n // =============================================================================\n // EFFECTS, EVENT LISTENERS\n // ============================================================================\n const onResize = useCallback(() => {\n if (!wrapperRef.current || !actionBarRef.current) {\n return;\n }\n const scrollable =\n wrapperRef.current.scrollHeight > wrapperRef.current.clientHeight;\n setScrollable(scrollable);\n\n if (scrollable) {\n actionBarRef.current.style.transform = `translateY(0)`;\n } else {\n calculateStickyInViewport();\n }\n }, []);\n\n useEffect(() => {\n onResize();\n }, []);\n\n useResizeDetector({ onResize });\n\n const scrollHandler = () => {\n requestAnimationFrame(() => {\n if (scrollable) {\n calculateFixedInViewport();\n } else {\n calculateStickyInViewport();\n }\n });\n };\n\n useEventListener(\"scroll\", scrollHandler, \"window\");\n\n useEffect(() => {\n checkLastBorder();\n }, [rows]);\n\n // ===========================================================================\n // HELPER FUNCTIONS\n // ===========================================================================\n const isAllCheckboxSelected = (): boolean => {\n if (!rows || !rows.length || !selectedIds) {\n return false;\n }\n return selectedIds.length === rows.length;\n };\n\n const isIndeterminateCheckbox = (): boolean => {\n return (\n !!selectedIds &&\n selectedIds.length !== 0 &&\n !isAllCheckboxSelected()\n );\n };\n\n const isHeaderCheckboxDisabled = (): boolean => {\n return !rows || !rows.length || !selectedIds;\n };\n\n const isRowSelected = (rowId: string): boolean => {\n return !!selectedIds?.includes(rowId);\n };\n\n const isAlternatingRow = (index: number): boolean => {\n return !!alternatingRows && index % 2 === 1;\n };\n\n const isDisabledRow = (rowId: string): boolean => {\n return !!disabledIds?.includes(rowId);\n };\n\n const getDataTestId = (subStr: string) => {\n if (!otherProps[\"data-testid\"]) return undefined;\n return `${otherProps[\"data-testid\"]}-${subStr}`;\n };\n\n const getTotalColumns = (): number => {\n return headers.length + (enableMultiSelect ? 1 : 0);\n };\n\n const getSortDirection = (fieldKey: string) => {\n return sortIndicators?.[fieldKey];\n };\n\n const getHeaderAriaSort = (fieldKey: string) => {\n const sortDirection = getSortDirection(fieldKey);\n\n if (!sortDirection) {\n return undefined;\n }\n\n return sortDirection === \"asc\" ? \"ascending\" : \"descending\";\n };\n\n const getSortButtonAriaLabel = (fieldKey: string) => {\n const nextSortDirection =\n getSortDirection(fieldKey) === \"asc\" ? \"descending\" : \"ascending\";\n\n return ` by ${nextSortDirection} order`;\n };\n\n const getHeaderCellId = (fieldKey: string) => {\n return `${internalId}-header-${fieldKey}`;\n };\n const getCellId = (rowId: string, fieldKey: string) => {\n return `${internalId}-row-${rowId}-${fieldKey}-key-column`;\n };\n\n const getRowCheckboxAriaLabelledBy = (rowId: string) => {\n const keyColumnIds = keyColumns.map((header) =>\n getCellId(rowId, header.fieldKey)\n );\n\n return concatIds(...keyColumnIds);\n };\n\n const calculateFixedInViewport = () => {\n if (!wrapperRef.current) {\n return;\n }\n const wrapperBounds = wrapperRef.current.getBoundingClientRect();\n setIsFloatingActionBar(\n wrapperBounds.bottom > window.innerHeight + 30 &&\n wrapperBounds.top < window.innerHeight - 200\n );\n };\n\n const calculateStickyInViewport = () => {\n if (\n !tableRef.current ||\n !tableEndRef.current ||\n !wrapperRef.current ||\n !actionBarRef.current ||\n !headerRef.current\n ) {\n return;\n }\n\n const endBounds = tableEndRef.current.getBoundingClientRect();\n\n if (endBounds.top > window.innerHeight) {\n const bottomOffset = endBounds.bottom - window.innerHeight;\n const bottomToHeaderOffset =\n tableRef.current.getBoundingClientRect().height -\n headerRef.current.clientHeight -\n 32;\n const maxBottomOffset = Math.min(\n bottomOffset,\n bottomToHeaderOffset\n );\n\n actionBarRef.current.style.transform = `translateY(-${maxBottomOffset}px)`;\n } else {\n actionBarRef.current.style.transform = `translateY(0)`;\n }\n };\n\n const checkLastBorder = () => {\n if (!tableRef.current || !wrapperRef.current) {\n return;\n }\n // 56 pixels added due to the behavior of action bar\n setShowLastBorder(\n tableRef.current.clientHeight + (enableActionBar ? 56 : 0) <\n wrapperRef.current.clientHeight\n );\n };\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleHeaderClick = (fieldKey: string) => {\n onHeaderClick?.(fieldKey);\n };\n\n const handleHeaderButtonClick = (\n event: React.MouseEvent<HTMLButtonElement>,\n fieldKey: string\n ) => {\n event.stopPropagation();\n onHeaderClick?.(fieldKey);\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderHeaders = () => (\n <thead\n ref={headerRef}\n className={enableStickyHeader ? styles.stickyHeader : undefined}\n >\n <tr className={styles.headerRow}>\n {enableMultiSelect && renderHeaderCheckBox()}\n {headers.map(renderHeaderCell)}\n </tr>\n </thead>\n );\n\n const renderHeaderCell = (header: HeaderProps) => {\n const {\n fieldKey,\n label,\n clickable = false,\n style,\n } = typeof header === \"string\"\n ? {\n fieldKey: header,\n label: header,\n style: undefined,\n }\n : header;\n\n const isSortable = !!getSortDirection(fieldKey);\n const headerCellId = getHeaderCellId(fieldKey);\n return (\n <th\n data-testid={getDataTestId(`header-${fieldKey}`)}\n key={fieldKey}\n className={clsx(\n styles.headerCell,\n clickable && styles.headerCellClickable\n )}\n scope=\"col\"\n aria-sort={getHeaderAriaSort(fieldKey)}\n style={style}\n onClick={() => handleHeaderClick(fieldKey)}\n >\n <div className={styles.headerCellContent} id={headerCellId}>\n {typeof label === \"string\" ? (\n <Typography.BodyBL weight=\"bold\">\n {label}\n </Typography.BodyBL>\n ) : (\n label\n )}\n {renderSortedArrow(fieldKey)}\n </div>\n {(clickable || isSortable) && (\n <VisuallyHidden>\n <button\n onClick={(event) =>\n handleHeaderButtonClick(event, fieldKey)\n }\n >\n {isSortable && \"Sort \"}\n <span aria-labelledby={headerCellId} />\n {isSortable && getSortButtonAriaLabel(fieldKey)}\n </button>\n </VisuallyHidden>\n )}\n </th>\n );\n };\n\n const renderSortedArrow = (fieldKey: string) => {\n const isSorted = sortIndicators?.[fieldKey];\n\n if (!isSorted) {\n return <></>;\n }\n if (isSorted === \"asc\") {\n return (\n <ArrowUpIcon\n aria-hidden\n data-testid={getDataTestId(`header-${fieldKey}-arrowup`)}\n />\n );\n }\n return (\n <ArrowDownIcon\n aria-hidden\n data-testid={getDataTestId(`header-${fieldKey}-arrowdown`)}\n />\n );\n };\n\n const renderHeaderCheckBox = () => {\n return (\n <th\n data-testid={getDataTestId(\"header-selection\")}\n className={clsx(styles.headerCell, styles.headerCellCheckbox)}\n scope=\"col\"\n >\n <div className={styles.selectionCheckboxWrapper}>\n <VisuallyHidden>Row selection</VisuallyHidden>\n {enableSelectAll && (\n <Checkbox\n checked={isAllCheckboxSelected()}\n indeterminate={isIndeterminateCheckbox()}\n disabled={isHeaderCheckboxDisabled()}\n aria-label=\"Select all rows\"\n onClick={() => {\n if (onSelectAll) {\n onSelectAll(isAllCheckboxSelected());\n }\n }}\n />\n )}\n </div>\n </th>\n );\n };\n\n const renderRows = () => {\n return !rows || rows.length < 1 ? (\n <tr className={styles.bodyRow}>\n <td\n className={styles.emptyStateCell}\n colSpan={getTotalColumns()}\n >\n {renderCustomEmptyView\n ? renderCustomEmptyView()\n : renderBasicEmptyView()}\n </td>\n </tr>\n ) : (\n <>\n {rows?.map((row: RowProps, index: number) => (\n <tr\n data-testid={getDataTestId(`row-${row.id.toString()}`)}\n key={row.id.toString()}\n className={clsx(\n styles.bodyRow,\n showLastBorder && styles.bodyRowWithBottomBorder,\n isAlternatingRow(index) &&\n styles.bodyRowAlternating,\n enableMultiSelect && styles.bodyRowSelectable,\n isRowSelected(row.id.toString()) &&\n styles.bodyRowSelected\n )}\n >\n {enableMultiSelect && renderRowCheckBox(row)}\n\n {headers.map((header) => renderRowCell(header, row))}\n </tr>\n ))}\n </>\n );\n };\n\n const renderRowCell = (header: HeaderProps, row: RowProps) => {\n const style = typeof header === \"string\" ? undefined : header.style;\n const fieldKey = typeof header === \"string\" ? header : header.fieldKey;\n const rowId = row.id.toString();\n const cellData = row[fieldKey];\n const cellId = `${rowId}-${fieldKey}`;\n\n let cellContent: React.ReactNode;\n if (typeof cellData === \"string\" || typeof cellData === \"number\") {\n cellContent = (\n <Typography.BodyBL className={styles.bodyCellText}>\n {cellData}\n </Typography.BodyBL>\n );\n } else if (typeof cellData === \"function\") {\n cellContent = cellData(row, { isSelected: isRowSelected(rowId) });\n } else {\n cellContent = cellData;\n }\n\n return (\n <td\n data-testid={getDataTestId(`row-${cellId}`)}\n key={cellId}\n id={getCellId(rowId, fieldKey)}\n className={styles.bodyCell}\n style={style}\n >\n {cellContent}\n </td>\n );\n };\n\n const renderRowCheckBox = (row: RowProps) => {\n const rowId = row.id.toString();\n\n return (\n <td\n data-testid={getDataTestId(`row-${rowId}-selection`)}\n className={clsx(styles.bodyCell, styles.bodyCellCheckbox)}\n >\n <div className={styles.selectionCheckboxWrapper}>\n <Checkbox\n checked={isRowSelected(rowId)}\n aria-labelledby={getRowCheckboxAriaLabelledBy(rowId)}\n onClick={() => {\n if (onSelect) {\n onSelect(rowId, !isRowSelected(rowId));\n }\n }}\n disabled={isDisabledRow(rowId)}\n focusableWhenDisabled={isDisabledRow(rowId)}\n />\n </div>\n </td>\n );\n };\n\n const renderBasicEmptyView = () => {\n let emptyTitle: JSX.Element;\n if (!emptyView?.title) {\n emptyTitle = (\n <Typography.HeadingSM\n className={styles.emptyStateTitle}\n weight=\"bold\"\n >\n {\"No <items> found\"}\n </Typography.HeadingSM>\n );\n } else if (typeof emptyView.title === \"string\") {\n emptyTitle = (\n <Typography.HeadingSM\n className={styles.emptyStateTitle}\n weight=\"bold\"\n >\n {emptyView.title}\n </Typography.HeadingSM>\n );\n } else {\n emptyTitle = emptyView.title;\n }\n\n return (\n <ErrorDisplay\n type={\"no-item-found\"}\n {...emptyView}\n title={emptyTitle}\n description={\n emptyView?.description\n ? emptyView.description\n : \"No matching rows\"\n }\n />\n );\n };\n\n const renderLoader = () => {\n return (\n <tr className={styles.bodyRow}>\n <td colSpan={getTotalColumns()}>\n <div\n className={styles.loadingStateWrapper}\n role=\"status\"\n aria-live=\"polite\"\n aria-label=\"Loading table\"\n >\n {loadState === \"loading\" && <LoadingDotsSpinner />}\n </div>\n </td>\n </tr>\n );\n };\n\n const renderSelectionBar = () => {\n const count = selectedIds?.length ?? 0;\n const hasNotReachedScrollableEnd = scrollable && !scrollEnd;\n const hasNotReachedTableEnd = !scrollable && !end;\n const shouldUseFloatingActionBar =\n hasNotReachedScrollableEnd ||\n hasNotReachedTableEnd ||\n isFloatingActionBar;\n\n return (\n <div\n ref={actionBarRef}\n className={clsx(\n styles.actionBarWrapper,\n isFloatingActionBar && styles.actionBarWrapperFloating\n )}\n >\n <div\n className={clsx(\n styles.actionBar,\n shouldUseFloatingActionBar && styles.actionBarFloating\n )}\n >\n <Typography.BodyMD weight=\"semibold\">{`${count} item${\n count > 1 ? \"s\" : \"\"\n } selected`}</Typography.BodyMD>\n <BasicButton\n className={styles.actionBarButton}\n type=\"button\"\n aria-label={`Clear selection of ${count} item${\n count === 1 ? \"\" : \"s\"\n }`}\n onClick={onClearSelectionClick}\n >\n Clear selection\n </BasicButton>\n {actionBarContent}\n </div>\n </div>\n );\n };\n\n return (\n <div\n id={id || \"table-wrapper\"}\n data-testid={otherProps[\"data-testid\"] || \"table\"}\n className={clsx(styles.tableWrapper, className)}\n ref={wrapperRef}\n onScroll={() => {\n if (scrollable && wrapperRef.current) {\n setScrollEnd(\n wrapperRef.current.scrollTop +\n wrapperRef.current.clientHeight >=\n wrapperRef.current.scrollHeight\n );\n }\n }}\n tabIndex={0} // scrollable container must be focusable to support keyboard users\n >\n <div className={styles.tableContainer}>\n <table ref={tableRef} className={clsx(styles.table)}>\n {renderHeaders()}\n <tbody>\n {loadState === \"success\"\n ? renderRows()\n : renderLoader()}\n </tbody>\n </table>\n </div>\n {enableActionBar &&\n selectedIds &&\n selectedIds.length > 0 &&\n renderSelectionBar()}\n <div\n ref={(r) => {\n tableEndRef.current = r;\n endRef(r);\n }}\n />\n </div>\n );\n};\n"],"names":["DataTable","_a","id","headers","rows","className","sortIndicators","alternatingRows","loadState","enableMultiSelect","selectedIds","disabledIds","enableActionBar","enableSelectAll","enableStickyHeader","emptyView","actionBarContent","renderCustomEmptyView","onHeaderClick","onSelect","onSelectAll","onClearSelectionClick","otherProps","__rest","tableRef","useRef","tableEndRef","headerRef","actionBarRef","wrapperRef","internalId","useId","keyColumns","filter","header","keyColumn","scrollable","setScrollable","useState","scrollEnd","setScrollEnd","isFloatingActionBar","setIsFloatingActionBar","showLastBorder","setShowLastBorder","ref","endRef","inView","end","useInView","useApplyStyle","styles.tokens","actionBarWrapperLeft","current","getBoundingClientRect","left","undefined","actionBarWrapperWidth","clientWidth","onResize","useCallback","scrollHeight","clientHeight","style","transform","calculateStickyInViewport","useEffect","useResizeDetector","useEventListener","requestAnimationFrame","calculateFixedInViewport","checkLastBorder","isAllCheckboxSelected","length","isRowSelected","rowId","includes","isAlternatingRow","index","isDisabledRow","getDataTestId","subStr","getTotalColumns","getSortDirection","fieldKey","getHeaderAriaSort","sortDirection","getSortButtonAriaLabel","getCellId","getRowCheckboxAriaLabelledBy","keyColumnIds","map","concatIds","wrapperBounds","bottom","window","innerHeight","top","endBounds","bottomOffset","bottomToHeaderOffset","height","maxBottomOffset","Math","min","renderHeaderCell","label","clickable","isSortable","headerCellId","getHeaderCellId","_jsxs","clsx","styles.headerCell","styles.headerCellClickable","scope","onClick","handleHeaderClick","children","styles.headerCellContent","_jsx","Typography","BodyBL","weight","renderSortedArrow","VisuallyHidden","event","stopPropagation","handleHeaderButtonClick","isSorted","ArrowUpIcon","ArrowDownIcon","renderHeaderCheckBox","styles.headerCellCheckbox","styles.selectionCheckboxWrapper","Checkbox","checked","indeterminate","disabled","renderRowCell","row","toString","cellData","cellId","cellContent","styles.bodyCellText","isSelected","styles.bodyCell","renderRowCheckBox","styles.bodyCellCheckbox","focusableWhenDisabled","renderBasicEmptyView","emptyTitle","title","HeadingSM","styles.emptyStateTitle","ErrorDisplay","Object","assign","type","description","styles.tableWrapper","onScroll","scrollTop","tabIndex","styles.tableContainer","styles.table","styles.stickyHeader","styles.headerRow","styles.bodyRow","styles.emptyStateCell","colSpan","_Fragment","styles.bodyRowWithBottomBorder","styles.bodyRowAlternating","styles.bodyRowSelectable","styles.bodyRowSelected","styles.loadingStateWrapper","role","LoadingDotsSpinner","count","shouldUseFloatingActionBar","styles.actionBarWrapper","styles.actionBarWrapperFloating","styles.actionBar","styles.actionBarFloating","BodyMD","BasicButton","styles.actionBarButton","renderSelectionBar","r"],"mappings":"smEAkBO,MAAMA,EAAaC,QAAAC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,WAAUL,SAAE,GAAG8D,SACrCA,EAAQ,EAAI,IAAM,gBAEtB5D,EAACmE,EAAW,CACRtL,UAAWuL,EACX7B,KAAK,SAAQ,aACD,sBAAsBqB,SACpB,IAAVA,EAAc,GAAK,MAEvBhE,QAAS/F,GAAqBiG,SAAA,oBAIjCtG,OAEH,EAkCF6K,GACJrE,EAAA,MAAA,CACI3E,IAAMiJ,IACFpK,GAAY2B,QAAUyI,EACtBhJ,GAAOgJ,EAAE,MAGf"}
|
|
1
|
+
{"version":3,"file":"data-table.js","sources":["../../src/data-table/data-table.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowUpIcon } from \"@lifesg/react-icons\";\nimport clsx from \"clsx\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useInView } from \"react-intersection-observer\";\nimport { useResizeDetector } from \"react-resize-detector\";\n\nimport { LoadingDotsSpinner } from \"../animations\";\nimport { Checkbox } from \"../checkbox\";\nimport { ErrorDisplay } from \"../error-display\";\nimport { concatIds, VisuallyHidden } from \"../shared/accessibility\";\nimport { BasicButton } from \"../shared/input-wrapper\";\nimport { useApplyStyle } from \"../theme\";\nimport { Typography } from \"../typography\";\nimport { useId } from \"../util\";\nimport { useEventListener } from \"../util/use-event-listener\";\nimport * as styles from \"./data-table.styles\";\nimport type { DataTableProps, HeaderProps, RowProps } from \"./types\";\n\n/**\n * Renders a sortable, selectable data table with scroll-aware action bar and loading state support.\n *\n * Use `DataTable` when presenting structured multi-column data that users may need to sort by\n * column or select rows for bulk actions. Row selection, sort indicators, and the action bar\n * content are all externally controlled; the component manages scroll detection, sticky-header\n * positioning, and floating action bar behaviour internally.\n */\nexport const DataTable = ({\n id,\n headers,\n rows,\n className,\n sortIndicators,\n alternatingRows,\n loadState = \"success\",\n enableMultiSelect,\n selectedIds,\n disabledIds,\n enableActionBar,\n enableSelectAll,\n enableStickyHeader,\n emptyView,\n actionBarContent,\n renderCustomEmptyView,\n onHeaderClick,\n onSelect,\n onSelectAll,\n onClearSelectionClick,\n ...otherProps\n}: DataTableProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const tableRef = useRef<HTMLTableElement>(null);\n const tableEndRef = useRef<HTMLDivElement | null>(null);\n const headerRef = useRef<HTMLTableSectionElement>(null);\n const actionBarRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const internalId = useId();\n const keyColumns = headers.filter(\n (header): header is Exclude<HeaderProps, string> => {\n return typeof header !== \"string\" && !!header.keyColumn;\n }\n );\n\n const [scrollable, setScrollable] = useState(false);\n const [scrollEnd, setScrollEnd] = useState(false);\n const [isFloatingActionBar, setIsFloatingActionBar] = useState(false);\n const [showLastBorder, setShowLastBorder] = useState(false);\n\n const { ref: endRef, inView: end } = useInView();\n\n useApplyStyle(actionBarRef, {\n [styles.tokens.actionBarWrapperLeft]:\n isFloatingActionBar && tableRef.current\n ? `${tableRef.current.getBoundingClientRect().left}px`\n : undefined,\n [styles.tokens.actionBarWrapperWidth]:\n isFloatingActionBar && tableRef.current\n ? `${tableRef.current.clientWidth}px`\n : undefined,\n });\n\n // =============================================================================\n // EFFECTS, EVENT LISTENERS\n // ============================================================================\n const onResize = useCallback(() => {\n if (!wrapperRef.current || !actionBarRef.current) {\n return;\n }\n const scrollable =\n wrapperRef.current.scrollHeight > wrapperRef.current.clientHeight;\n setScrollable(scrollable);\n\n if (scrollable) {\n actionBarRef.current.style.transform = `translateY(0)`;\n } else {\n calculateStickyInViewport();\n }\n }, []);\n\n useEffect(() => {\n onResize();\n }, []);\n\n useResizeDetector({ onResize });\n\n const scrollHandler = () => {\n requestAnimationFrame(() => {\n if (scrollable) {\n calculateFixedInViewport();\n } else {\n calculateStickyInViewport();\n }\n });\n };\n\n useEventListener(\"scroll\", scrollHandler, \"window\");\n\n useEffect(() => {\n checkLastBorder();\n }, [rows]);\n\n // ===========================================================================\n // HELPER FUNCTIONS\n // ===========================================================================\n const isAllCheckboxSelected = (): boolean => {\n if (!rows || !rows.length || !selectedIds) {\n return false;\n }\n return selectedIds.length === rows.length;\n };\n\n const isIndeterminateCheckbox = (): boolean => {\n return (\n !!selectedIds &&\n selectedIds.length !== 0 &&\n !isAllCheckboxSelected()\n );\n };\n\n const isHeaderCheckboxDisabled = (): boolean => {\n return !rows || !rows.length || !selectedIds;\n };\n\n const isRowSelected = (rowId: string): boolean => {\n return !!selectedIds?.includes(rowId);\n };\n\n const isAlternatingRow = (index: number): boolean => {\n return !!alternatingRows && index % 2 === 1;\n };\n\n const isDisabledRow = (rowId: string): boolean => {\n return !!disabledIds?.includes(rowId);\n };\n\n const getDataTestId = (subStr: string) => {\n if (!otherProps[\"data-testid\"]) return undefined;\n return `${otherProps[\"data-testid\"]}-${subStr}`;\n };\n\n const getTotalColumns = (): number => {\n return headers.length + (enableMultiSelect ? 1 : 0);\n };\n\n const getSortDirection = (fieldKey: string) => {\n return sortIndicators?.[fieldKey];\n };\n\n const getHeaderAriaSort = (fieldKey: string) => {\n const sortDirection = getSortDirection(fieldKey);\n\n if (!sortDirection) {\n return undefined;\n }\n\n return sortDirection === \"asc\" ? \"ascending\" : \"descending\";\n };\n\n const getSortButtonAriaLabel = (fieldKey: string) => {\n const nextSortDirection =\n getSortDirection(fieldKey) === \"asc\" ? \"descending\" : \"ascending\";\n\n return ` by ${nextSortDirection} order`;\n };\n\n const getHeaderCellId = (fieldKey: string) => {\n return `${internalId}-header-${fieldKey}`;\n };\n const getCellId = (rowId: string, fieldKey: string) => {\n return `${internalId}-row-${rowId}-${fieldKey}-key-column`;\n };\n\n const getRowCheckboxAriaLabelledBy = (rowId: string) => {\n const keyColumnIds = keyColumns.map((header) =>\n getCellId(rowId, header.fieldKey)\n );\n\n return concatIds(...keyColumnIds);\n };\n\n const calculateFixedInViewport = () => {\n if (!wrapperRef.current) {\n return;\n }\n const wrapperBounds = wrapperRef.current.getBoundingClientRect();\n setIsFloatingActionBar(\n wrapperBounds.bottom > window.innerHeight + 30 &&\n wrapperBounds.top < window.innerHeight - 200\n );\n };\n\n const calculateStickyInViewport = () => {\n if (\n !tableRef.current ||\n !tableEndRef.current ||\n !wrapperRef.current ||\n !actionBarRef.current ||\n !headerRef.current\n ) {\n return;\n }\n\n const endBounds = tableEndRef.current.getBoundingClientRect();\n\n if (endBounds.top > window.innerHeight) {\n const bottomOffset = endBounds.bottom - window.innerHeight;\n const bottomToHeaderOffset =\n tableRef.current.getBoundingClientRect().height -\n headerRef.current.clientHeight -\n 32;\n const maxBottomOffset = Math.min(\n bottomOffset,\n bottomToHeaderOffset\n );\n\n actionBarRef.current.style.transform = `translateY(-${maxBottomOffset}px)`;\n } else {\n actionBarRef.current.style.transform = `translateY(0)`;\n }\n };\n\n const checkLastBorder = () => {\n if (!tableRef.current || !wrapperRef.current) {\n return;\n }\n // 56 pixels added due to the behavior of action bar\n setShowLastBorder(\n tableRef.current.clientHeight + (enableActionBar ? 56 : 0) <\n wrapperRef.current.clientHeight\n );\n };\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleHeaderClick = (fieldKey: string) => {\n onHeaderClick?.(fieldKey);\n };\n\n const handleHeaderButtonClick = (\n event: React.MouseEvent<HTMLButtonElement>,\n fieldKey: string\n ) => {\n event.stopPropagation();\n onHeaderClick?.(fieldKey);\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderHeaders = () => (\n <thead\n ref={headerRef}\n className={enableStickyHeader ? styles.stickyHeader : undefined}\n >\n <tr className={styles.headerRow}>\n {enableMultiSelect && renderHeaderCheckBox()}\n {headers.map(renderHeaderCell)}\n </tr>\n </thead>\n );\n\n const renderHeaderCell = (header: HeaderProps) => {\n const {\n fieldKey,\n label,\n clickable = false,\n style,\n } = typeof header === \"string\"\n ? {\n fieldKey: header,\n label: header,\n style: undefined,\n }\n : header;\n\n const isSortable = !!getSortDirection(fieldKey);\n const headerCellId = getHeaderCellId(fieldKey);\n return (\n <th\n data-testid={getDataTestId(`header-${fieldKey}`)}\n key={fieldKey}\n className={clsx(\n styles.headerCell,\n clickable && styles.headerCellClickable\n )}\n scope=\"col\"\n aria-sort={getHeaderAriaSort(fieldKey)}\n style={style}\n onClick={() => handleHeaderClick(fieldKey)}\n >\n <div className={styles.headerCellContent} id={headerCellId}>\n {typeof label === \"string\" ? (\n <Typography.BodyBL weight=\"bold\">\n {label}\n </Typography.BodyBL>\n ) : (\n label\n )}\n {renderSortedArrow(fieldKey)}\n </div>\n {(clickable || isSortable) && (\n <VisuallyHidden>\n <button\n onClick={(event) =>\n handleHeaderButtonClick(event, fieldKey)\n }\n >\n {isSortable && \"Sort \"}\n <span aria-labelledby={headerCellId} />\n {isSortable && getSortButtonAriaLabel(fieldKey)}\n </button>\n </VisuallyHidden>\n )}\n </th>\n );\n };\n\n const renderSortedArrow = (fieldKey: string) => {\n const isSorted = sortIndicators?.[fieldKey];\n\n if (!isSorted) {\n return <></>;\n }\n if (isSorted === \"asc\") {\n return (\n <ArrowUpIcon\n aria-hidden\n data-testid={getDataTestId(`header-${fieldKey}-arrowup`)}\n />\n );\n }\n return (\n <ArrowDownIcon\n aria-hidden\n data-testid={getDataTestId(`header-${fieldKey}-arrowdown`)}\n />\n );\n };\n\n const renderHeaderCheckBox = () => {\n return (\n <th\n data-testid={getDataTestId(\"header-selection\")}\n className={clsx(styles.headerCell, styles.headerCellCheckbox)}\n scope=\"col\"\n >\n <div className={styles.selectionCheckboxWrapper}>\n <VisuallyHidden>Row selection</VisuallyHidden>\n {enableSelectAll && (\n <Checkbox\n checked={isAllCheckboxSelected()}\n indeterminate={isIndeterminateCheckbox()}\n disabled={isHeaderCheckboxDisabled()}\n aria-label=\"Select all rows\"\n onClick={() => {\n if (onSelectAll) {\n onSelectAll(isAllCheckboxSelected());\n }\n }}\n />\n )}\n </div>\n </th>\n );\n };\n\n const renderRows = () => {\n return !rows || rows.length < 1 ? (\n <tr className={styles.bodyRow}>\n <td\n className={styles.emptyStateCell}\n colSpan={getTotalColumns()}\n >\n {renderCustomEmptyView\n ? renderCustomEmptyView()\n : renderBasicEmptyView()}\n </td>\n </tr>\n ) : (\n <>\n {rows?.map((row: RowProps, index: number) => (\n <tr\n data-testid={getDataTestId(`row-${row.id.toString()}`)}\n key={row.id.toString()}\n className={clsx(\n styles.bodyRow,\n showLastBorder && styles.bodyRowWithBottomBorder,\n isAlternatingRow(index) &&\n styles.bodyRowAlternating,\n enableMultiSelect && styles.bodyRowSelectable,\n isRowSelected(row.id.toString()) &&\n styles.bodyRowSelected\n )}\n >\n {enableMultiSelect && renderRowCheckBox(row)}\n\n {headers.map((header) => renderRowCell(header, row))}\n </tr>\n ))}\n </>\n );\n };\n\n const renderRowCell = (header: HeaderProps, row: RowProps) => {\n const style = typeof header === \"string\" ? undefined : header.style;\n const fieldKey = typeof header === \"string\" ? header : header.fieldKey;\n const rowId = row.id.toString();\n const cellData = row[fieldKey];\n const cellId = `${rowId}-${fieldKey}`;\n\n let cellContent: React.ReactNode;\n if (typeof cellData === \"string\" || typeof cellData === \"number\") {\n cellContent = (\n <Typography.BodyBL className={styles.bodyCellText}>\n {cellData}\n </Typography.BodyBL>\n );\n } else if (typeof cellData === \"function\") {\n cellContent = cellData(row, { isSelected: isRowSelected(rowId) });\n } else {\n cellContent = cellData;\n }\n\n return (\n <td\n data-testid={getDataTestId(`row-${cellId}`)}\n key={cellId}\n id={getCellId(rowId, fieldKey)}\n className={styles.bodyCell}\n style={style}\n >\n {cellContent}\n </td>\n );\n };\n\n const renderRowCheckBox = (row: RowProps) => {\n const rowId = row.id.toString();\n\n return (\n <td\n data-testid={getDataTestId(`row-${rowId}-selection`)}\n className={clsx(styles.bodyCell, styles.bodyCellCheckbox)}\n >\n <div className={styles.selectionCheckboxWrapper}>\n <Checkbox\n checked={isRowSelected(rowId)}\n aria-labelledby={getRowCheckboxAriaLabelledBy(rowId)}\n onClick={() => {\n if (onSelect) {\n onSelect(rowId, !isRowSelected(rowId));\n }\n }}\n disabled={isDisabledRow(rowId)}\n focusableWhenDisabled={isDisabledRow(rowId)}\n />\n </div>\n </td>\n );\n };\n\n const renderBasicEmptyView = () => {\n let emptyTitle: JSX.Element;\n if (!emptyView?.title) {\n emptyTitle = (\n <Typography.HeadingSM\n className={styles.emptyStateTitle}\n weight=\"bold\"\n >\n {\"No <items> found\"}\n </Typography.HeadingSM>\n );\n } else if (typeof emptyView.title === \"string\") {\n emptyTitle = (\n <Typography.HeadingSM\n className={styles.emptyStateTitle}\n weight=\"bold\"\n >\n {emptyView.title}\n </Typography.HeadingSM>\n );\n } else {\n emptyTitle = emptyView.title;\n }\n\n return (\n <ErrorDisplay\n type={\"no-item-found\"}\n {...emptyView}\n title={emptyTitle}\n description={\n emptyView?.description\n ? emptyView.description\n : \"No matching rows\"\n }\n />\n );\n };\n\n const renderLoader = () => {\n return (\n <tr className={styles.bodyRow}>\n <td colSpan={getTotalColumns()}>\n <div\n className={styles.loadingStateWrapper}\n role=\"status\"\n aria-live=\"polite\"\n aria-label=\"Loading table\"\n >\n {loadState === \"loading\" && <LoadingDotsSpinner />}\n </div>\n </td>\n </tr>\n );\n };\n\n const renderSelectionBar = () => {\n const count = selectedIds?.length ?? 0;\n const hasNotReachedScrollableEnd = scrollable && !scrollEnd;\n const hasNotReachedTableEnd = !scrollable && !end;\n const shouldUseFloatingActionBar =\n hasNotReachedScrollableEnd ||\n hasNotReachedTableEnd ||\n isFloatingActionBar;\n\n return (\n <div\n ref={actionBarRef}\n className={clsx(\n styles.actionBarWrapper,\n isFloatingActionBar && styles.actionBarWrapperFloating\n )}\n >\n <div\n className={clsx(\n styles.actionBar,\n shouldUseFloatingActionBar && styles.actionBarFloating\n )}\n >\n <Typography.BodyMD weight=\"semibold\">{`${count} item${\n count > 1 ? \"s\" : \"\"\n } selected`}</Typography.BodyMD>\n <BasicButton\n className={styles.actionBarButton}\n type=\"button\"\n aria-label={`Clear selection of ${count} item${\n count === 1 ? \"\" : \"s\"\n }`}\n onClick={onClearSelectionClick}\n >\n Clear selection\n </BasicButton>\n {actionBarContent}\n </div>\n </div>\n );\n };\n\n return (\n <div\n id={id || \"table-wrapper\"}\n data-testid={otherProps[\"data-testid\"] || \"table\"}\n className={clsx(styles.tableWrapper, className)}\n ref={wrapperRef}\n onScroll={() => {\n if (scrollable && wrapperRef.current) {\n setScrollEnd(\n wrapperRef.current.scrollTop +\n wrapperRef.current.clientHeight >=\n wrapperRef.current.scrollHeight\n );\n }\n }}\n tabIndex={0} // scrollable container must be focusable to support keyboard users\n >\n <div className={styles.tableContainer}>\n <table ref={tableRef} className={clsx(styles.table)}>\n {renderHeaders()}\n <tbody>\n {loadState === \"success\"\n ? renderRows()\n : renderLoader()}\n </tbody>\n </table>\n </div>\n {enableActionBar &&\n selectedIds &&\n selectedIds.length > 0 &&\n renderSelectionBar()}\n <div\n ref={(r) => {\n tableEndRef.current = r;\n endRef(r);\n }}\n />\n </div>\n );\n};\n"],"names":["DataTable","_a","id","headers","rows","className","sortIndicators","alternatingRows","loadState","enableMultiSelect","selectedIds","disabledIds","enableActionBar","enableSelectAll","enableStickyHeader","emptyView","actionBarContent","renderCustomEmptyView","onHeaderClick","onSelect","onSelectAll","onClearSelectionClick","otherProps","__rest","tableRef","useRef","tableEndRef","headerRef","actionBarRef","wrapperRef","internalId","useId","keyColumns","filter","header","keyColumn","scrollable","setScrollable","useState","scrollEnd","setScrollEnd","isFloatingActionBar","setIsFloatingActionBar","showLastBorder","setShowLastBorder","ref","endRef","inView","end","useInView","useApplyStyle","styles.tokens","actionBarWrapperLeft","current","getBoundingClientRect","left","undefined","actionBarWrapperWidth","clientWidth","onResize","useCallback","scrollHeight","clientHeight","style","transform","calculateStickyInViewport","useEffect","useResizeDetector","useEventListener","requestAnimationFrame","calculateFixedInViewport","checkLastBorder","isAllCheckboxSelected","length","isRowSelected","rowId","includes","isAlternatingRow","index","isDisabledRow","getDataTestId","subStr","getTotalColumns","getSortDirection","fieldKey","getHeaderAriaSort","sortDirection","getSortButtonAriaLabel","getCellId","getRowCheckboxAriaLabelledBy","keyColumnIds","map","concatIds","wrapperBounds","bottom","window","innerHeight","top","endBounds","bottomOffset","bottomToHeaderOffset","height","maxBottomOffset","Math","min","renderHeaderCell","label","clickable","isSortable","headerCellId","getHeaderCellId","_jsxs","clsx","styles.headerCell","styles.headerCellClickable","scope","onClick","handleHeaderClick","children","styles.headerCellContent","_jsx","Typography","BodyBL","weight","renderSortedArrow","VisuallyHidden","event","stopPropagation","handleHeaderButtonClick","isSorted","ArrowUpIcon","ArrowDownIcon","renderHeaderCheckBox","styles.headerCellCheckbox","styles.selectionCheckboxWrapper","Checkbox","checked","indeterminate","disabled","renderRowCell","row","toString","cellData","cellId","cellContent","styles.bodyCellText","isSelected","styles.bodyCell","renderRowCheckBox","styles.bodyCellCheckbox","focusableWhenDisabled","renderBasicEmptyView","emptyTitle","title","HeadingSM","styles.emptyStateTitle","ErrorDisplay","Object","assign","type","description","styles.tableWrapper","onScroll","scrollTop","tabIndex","styles.tableContainer","styles.table","styles.stickyHeader","styles.headerRow","styles.bodyRow","styles.emptyStateCell","colSpan","_Fragment","styles.bodyRowWithBottomBorder","styles.bodyRowAlternating","styles.bodyRowSelectable","styles.bodyRowSelected","styles.loadingStateWrapper","role","LoadingDotsSpinner","count","shouldUseFloatingActionBar","styles.actionBarWrapper","styles.actionBarWrapperFloating","styles.actionBar","styles.actionBarFloating","BodyMD","BasicButton","styles.actionBarButton","renderSelectionBar","r"],"mappings":"smEA0BO,MAAMA,EAAaC,QAAAC,GACtBA,EAAEC,QACFA,EAAOC,KACPA,EAAIC,UACJA,GAASC,eACTA,GAAcC,gBACdA,GAAeC,UACfA,GAAY,UAASC,kBACrBA,GAAiBC,YACjBA,GAAWC,YACXA,GAAWC,gBACXA,GAAeC,gBACfA,GAAeC,mBACfA,GAAkBC,UAClBA,GAASC,iBACTA,GAAgBC,sBAChBA,GAAqBC,cACrBA,GAAaC,SACbA,GAAQC,YACRA,GAAWC,sBACXA,MACGC,GAAUC,EAAAtB,EArBS,CAAA,KAAA,UAAA,OAAA,YAAA,iBAAA,kBAAA,YAAA,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display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;border:var(--fds-border-width-010) var(--fds-border-style-solid) var(--fds-colour-border);border-radius:var(--fds-radius-md);}.t188sfx3::-webkit-scrollbar{display:none;}.t188sfx3 *{-ms-overflow-style:none;scrollbar-width:none;}
|
|
1
|
+
@layer fds{.t188sfx3{overflow:auto;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;border:var(--fds-border-width-010) var(--fds-border-style-solid) var(--fds-colour-border);border-radius:var(--fds-radius-md);}.t188sfx3::-webkit-scrollbar{display:none;}.t188sfx3 *{-ms-overflow-style:none;scrollbar-width:none;}
|
|
2
2
|
.t1j0mhj{-webkit-flex:1;-ms-flex:1;flex:1;}
|
|
3
3
|
.t4ucy2z{text-align:left;border-collapse:separate;border-spacing:0;width:100%;}
|
|
4
4
|
.s7u4vf5{position:-webkit-sticky;position:sticky;top:0;z-index:20;}
|
|
@@ -23,4 +23,4 @@
|
|
|
23
23
|
.aag0lf9{bottom:0;position:-webkit-sticky;position:sticky;left:0;}
|
|
24
24
|
.a1euqarq{--fds-internal-dataTable-actionBarWrapper-left:initial;--fds-internal-dataTable-actionBarWrapper-width:initial;position:fixed;left:var(--fds-internal-dataTable-actionBarWrapper-left, 0px);width:var(--fds-internal-dataTable-actionBarWrapper-width, 100%);}
|
|
25
25
|
.ldhafdm{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:4rem 0;}
|
|
26
|
-
.e1pcc0nq{margin-top:2rem;margin-bottom:1rem;}
|
|
26
|
+
.e1pcc0nq{margin-top:2rem;margin-bottom:1rem;}}
|
package/data-table/types.d.ts
CHANGED
|
@@ -1,40 +1,70 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
2
|
import type { ErrorDisplayAttributes } from "../error-display/types";
|
|
3
|
+
/** Props for the `DataTable` component. */
|
|
3
4
|
export interface DataTableProps {
|
|
4
5
|
id?: string | undefined;
|
|
5
6
|
"data-testid"?: string | undefined;
|
|
6
|
-
/**
|
|
7
|
+
/** Column definitions that determine the rendered headers and the `fieldKey` used to read values from each `RowProps` entry. */
|
|
7
8
|
headers: HeaderProps[];
|
|
9
|
+
/** Row data to render. When omitted or empty the empty state is shown. */
|
|
8
10
|
rows?: RowProps[] | undefined;
|
|
9
11
|
className?: string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Controlled set of row IDs that are currently selected.
|
|
14
|
+
*
|
|
15
|
+
* @remarks Must be provided alongside `enableMultiSelect` for selection to work. Pass an
|
|
16
|
+
* empty array (not `undefined`) to enable the select-all checkbox while having no rows
|
|
17
|
+
* selected.
|
|
18
|
+
*/
|
|
10
19
|
selectedIds?: string[] | undefined;
|
|
20
|
+
/** Row IDs whose checkboxes are rendered in a disabled state; the rows remain visible. */
|
|
11
21
|
disabledIds?: string[] | undefined;
|
|
12
|
-
/**
|
|
22
|
+
/** Renders a checkbox column as the first column of each row to support row selection. */
|
|
13
23
|
enableMultiSelect?: boolean | undefined;
|
|
14
|
-
/**
|
|
24
|
+
/** Renders a select-all checkbox in the header checkbox column. Requires `enableMultiSelect`. */
|
|
15
25
|
enableSelectAll?: boolean | undefined;
|
|
16
|
-
/**
|
|
26
|
+
/** Shows the action bar whenever one or more rows are selected. */
|
|
17
27
|
enableActionBar?: boolean | undefined;
|
|
18
|
-
/**
|
|
28
|
+
/** Keeps the header row visible as the user scrolls down through the table. */
|
|
19
29
|
enableStickyHeader?: boolean | undefined;
|
|
20
|
-
/**
|
|
30
|
+
/** Additional content rendered inside the action bar. */
|
|
21
31
|
actionBarContent?: ReactNode | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Controls whether the table body renders data rows or a loading indicator.
|
|
34
|
+
* @default "success"
|
|
35
|
+
*/
|
|
22
36
|
loadState?: LoadStateType | undefined;
|
|
37
|
+
/** Called when a row's checkbox is toggled; receives the row ID and the new selected state. */
|
|
23
38
|
onSelect?: ((rowId: string, isSelected: boolean) => void) | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Called when the select-all checkbox is toggled.
|
|
41
|
+
*/
|
|
24
42
|
onSelectAll?: ((isAllSelected: boolean) => void) | undefined;
|
|
43
|
+
/** Called when a header cell is clicked; receives the `fieldKey` of the clicked column. */
|
|
25
44
|
onHeaderClick?: ((fieldKey: string) => void) | undefined;
|
|
45
|
+
/** Called when the "Clear selection" button inside the action bar is clicked. */
|
|
26
46
|
onClearSelectionClick?: (() => void) | undefined;
|
|
27
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Maps each `fieldKey` to its current sort direction. A key present in this map causes the
|
|
49
|
+
* corresponding header to render a directional arrow and expose sort controls to assistive
|
|
50
|
+
* technology.
|
|
51
|
+
*/
|
|
28
52
|
sortIndicators?: SortIndicatorsProps | undefined;
|
|
29
|
-
/**
|
|
53
|
+
/** Applies an alternate background colour to every odd-indexed row. */
|
|
30
54
|
alternatingRows?: boolean | undefined;
|
|
31
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Overrides the title and description shown in the built-in empty state. Ignored when
|
|
57
|
+
* `renderCustomEmptyView` is provided.
|
|
58
|
+
*/
|
|
32
59
|
emptyView?: ErrorDisplayAttributes | undefined;
|
|
33
|
-
/**
|
|
60
|
+
/** Renders a fully custom empty state in place of the default `ErrorDisplay`. */
|
|
34
61
|
renderCustomEmptyView?: (() => ReactNode) | undefined;
|
|
35
62
|
}
|
|
63
|
+
/** Whether the table body is in a loading or data-ready state. */
|
|
36
64
|
export type LoadStateType = "loading" | "success";
|
|
65
|
+
/** Direction of a column sort indicator. */
|
|
37
66
|
export type SortIndicatorType = "asc" | "desc";
|
|
67
|
+
/** Maps column `fieldKey` values to their current sort direction. */
|
|
38
68
|
export interface SortIndicatorsProps {
|
|
39
69
|
[fieldKey: string]: SortIndicatorType;
|
|
40
70
|
}
|
|
@@ -45,23 +75,39 @@ export interface SortIndicatorsProps {
|
|
|
45
75
|
* For additional customisation, pass a `HeaderItemProps` object
|
|
46
76
|
*/
|
|
47
77
|
export type HeaderProps = string | HeaderItemProps;
|
|
78
|
+
/**
|
|
79
|
+
* Full object form of a column header definition;
|
|
80
|
+
* use instead of a plain string when custom labels, click handling,
|
|
81
|
+
* or accessibility metadata is needed. */
|
|
48
82
|
interface HeaderItemProps {
|
|
83
|
+
/** Key used to read the corresponding cell value from each `RowProps` entry. */
|
|
49
84
|
fieldKey: string;
|
|
85
|
+
/** Column heading content. Pass a string for plain text or a `ReactNode` for custom markup. */
|
|
50
86
|
label: string | ReactNode;
|
|
87
|
+
/** Makes the header cell interactive, firing `onHeaderClick` when clicked. */
|
|
51
88
|
clickable?: boolean | undefined;
|
|
52
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Used with `enableMultiSelect`. Marks this column as descriptive of the row
|
|
53
91
|
* (e.g. a name or unique ID). Its value is used to label the row's checkbox
|
|
54
92
|
* for screen readers.
|
|
55
93
|
*/
|
|
56
94
|
keyColumn?: boolean | undefined;
|
|
57
95
|
style?: CSSProperties | undefined;
|
|
58
96
|
}
|
|
97
|
+
/** Props for each row of data in the table. */
|
|
59
98
|
export interface RowProps {
|
|
99
|
+
/** Unique identifier for the row; used as the key and referenced by `selectedIds`/`disabledIds`. */
|
|
60
100
|
id: string | number;
|
|
61
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Cell values keyed by the `fieldKey` of the matching `HeaderProps`. Values can be a
|
|
103
|
+
* primitive (rendered inside a `Typography.BodyBL`), a `ReactNode`, or a render function
|
|
104
|
+
* that receives the full row and `RowRenderProps`.
|
|
105
|
+
*/
|
|
62
106
|
[fieldKey: string]: string | number | ReactNode | ((row: RowProps, renderProps: RowRenderProps) => ReactNode) | undefined;
|
|
63
107
|
}
|
|
108
|
+
/** Runtime context passed to a cell's render function when the value is a function. */
|
|
64
109
|
interface RowRenderProps {
|
|
110
|
+
/** Whether the row is currently in the `selectedIds` set. */
|
|
65
111
|
isSelected: boolean;
|
|
66
112
|
}
|
|
67
113
|
export {};
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { DateInputProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* A single-date input field with an attached calendar dropdown.
|
|
4
|
+
*
|
|
5
|
+
* Use this to enter or pick a single date.
|
|
6
|
+
*/
|
|
2
7
|
export declare const DateInput: ({ minDate, maxDate, disabled, disabledDates, error, hideInputKeyboard, value, onChange, onFocus, onBlur, onYearMonthDisplayChange, withButton, readOnly, id, allowDisabledSelection, zIndex, dropdownRootNode, className, ...otherProps }: DateInputProps) => import("react/jsx-runtime").JSX.Element;
|