@lifesg/react-design-system 4.0.0-alpha.5 → 4.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/types.d.ts +1 -1
- package/breadcrumb/breadcrumb.d.ts +7 -0
- package/breadcrumb/breadcrumb.js.map +1 -1
- package/breadcrumb/types.d.ts +31 -0
- package/button/button.d.ts +1 -0
- package/button/button.js.map +1 -1
- package/button/types.d.ts +42 -9
- package/calendar/calendar.d.ts +3 -0
- package/calendar/calendar.js.map +1 -1
- package/calendar/types.d.ts +43 -7
- package/card/card.d.ts +1 -0
- package/card/card.js.map +1 -1
- package/card/types.d.ts +1 -0
- package/checkbox/checkbox.d.ts +3 -0
- package/checkbox/checkbox.js.map +1 -1
- package/checkbox/types.d.ts +19 -3
- package/cjs/breadcrumb/breadcrumb.js.map +1 -1
- package/cjs/button/button.js.map +1 -1
- package/cjs/calendar/calendar.js.map +1 -1
- package/cjs/card/card.js.map +1 -1
- package/cjs/checkbox/checkbox.js.map +1 -1
- package/cjs/data-table/data-table.js +1 -1
- package/cjs/data-table/data-table.js.map +1 -1
- package/cjs/data-table/data-table.styles.js +1 -1
- package/cjs/data-table/data-table.styles.js.map +1 -1
- package/cjs/data-table/data-table.styles_rxganh.css +27 -0
- package/cjs/external/dompurify/dist/purify.es.js +2 -2
- package/cjs/external/dompurify/dist/purify.es.js.map +1 -1
- package/cjs/external/lodash/_setCacheHas.js.map +1 -1
- package/cjs/external/lodash/lodash.js +1 -1
- package/cjs/external/lodash/lodash.js.map +1 -1
- package/cjs/form/form-label-addon.js +1 -1
- package/cjs/form/form-label-addon.js.map +1 -1
- package/cjs/form/index.js +1 -1
- package/cjs/form/index.js.map +1 -1
- package/cjs/fullscreen-image-carousel/fullscreen-image-carousel.js +1 -1
- package/cjs/fullscreen-image-carousel/fullscreen-image-carousel.js.map +1 -1
- package/cjs/histogram-slider/histogram-slider.js.map +1 -1
- package/cjs/image-button/image-button.js.map +1 -1
- package/cjs/index.js +1 -1
- package/cjs/input/input.js.map +1 -1
- package/cjs/input-group/input-group.js.map +1 -1
- package/cjs/input-multi-select/input-multi-select.js.map +1 -1
- package/cjs/input-nested-multi-select/input-nested-multi-select.js.map +1 -1
- package/cjs/input-nested-select/input-nested-select.js.map +1 -1
- package/cjs/input-range-select/input-range-select.js.map +1 -1
- package/cjs/input-range-slider/input-range-slider.js.map +1 -1
- package/cjs/input-select/input-select.js.map +1 -1
- package/cjs/input-slider/input-slider.js.map +1 -1
- package/cjs/input-textarea/textarea.js.map +1 -1
- package/cjs/language-switcher/language-switcher.js.map +1 -1
- package/cjs/layout/index.js +1 -1
- package/cjs/layout/index.js.map +1 -1
- package/cjs/link-list/link-list.js.map +1 -1
- package/cjs/local-nav/local-nav-dropdown/local-nav-dropdown.js.map +1 -1
- package/cjs/local-nav/local-nav-menu/local-nav-menu.js.map +1 -1
- package/cjs/markup/markup.js.map +1 -1
- package/cjs/masked-input/masked-input.js.map +1 -1
- package/cjs/masthead/masthead.js.map +1 -1
- package/cjs/menu/menu.js +1 -1
- package/cjs/menu/menu.js.map +1 -1
- package/cjs/modal/index.js.map +1 -1
- package/cjs/modal/modal-box.js +1 -1
- package/cjs/modal/modal-box.js.map +1 -1
- package/cjs/modal-v2/index.js +1 -1
- package/cjs/modal-v2/index.js.map +1 -1
- package/cjs/modal-v2/modal-v2.js +1 -1
- package/cjs/modal-v2/modal-v2.js.map +1 -1
- package/cjs/modal-v2/slots/card.js +1 -1
- package/cjs/modal-v2/slots/card.js.map +1 -1
- package/cjs/navbar/navbar.js.map +1 -1
- package/cjs/notification-banner/notification-banner-hoc.js.map +1 -1
- package/cjs/notification-banner/notification-banner.js.map +1 -1
- package/cjs/otp-input/otp-input.js.map +1 -1
- package/cjs/otp-verification/otp-verification.js.map +1 -1
- package/cjs/overlay/overlay.js.map +1 -1
- package/cjs/pagination/pagination.js.map +1 -1
- package/cjs/phone-number-input/phone-number-input.js.map +1 -1
- package/cjs/pill/pill.js.map +1 -1
- package/cjs/popover/popover-inline/popover-inline.js.map +1 -1
- package/cjs/popover/popover-trigger.js.map +1 -1
- package/cjs/popover/popover.js +1 -1
- package/cjs/popover/popover.js.map +1 -1
- package/cjs/predictive-text-input/predictive-text-input.js.map +1 -1
- package/cjs/progress-indicator/progress-indicator.js.map +1 -1
- package/cjs/radio-button/radio-button.js.map +1 -1
- package/cjs/schedule/schedule.js.map +1 -1
- package/cjs/schedule/shared/with-optional-popover.js +1 -1
- package/cjs/schedule/shared/with-optional-popover.js.map +1 -1
- package/cjs/select-histogram/select-histogram.js.map +1 -1
- package/cjs/sidenav/sidenav.js.map +1 -1
- package/cjs/singpass-button/singpass-button.js.map +1 -1
- package/cjs/smart-app-banner/smart-app-banner.js.map +1 -1
- package/cjs/tab/tab.js.map +1 -1
- package/cjs/table/table.js.map +1 -1
- package/cjs/table/table.styles.js +1 -1
- package/cjs/table/table.styles.js.map +1 -1
- package/{table/table.styles_1af5ipv.css → cjs/table/table.styles_1vjx31g.css} +1 -1
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/text-list/index.js.map +1 -1
- package/cjs/theme/theme-provider/breakpoint.js +1 -1
- package/cjs/theme/theme-provider/breakpoint.js.map +1 -1
- package/cjs/theme/theme-provider/hooks.js.map +1 -1
- package/cjs/theme/theme-provider/index.js.map +1 -1
- package/cjs/theme/tokens/border.js.map +1 -1
- package/cjs/theme/tokens/breakpoint.js.map +1 -1
- package/cjs/theme/tokens/colour.js.map +1 -1
- package/cjs/theme/tokens/component.js.map +1 -1
- package/cjs/theme/tokens/font.js.map +1 -1
- package/cjs/theme/tokens/media-query.js.map +1 -1
- package/cjs/theme/tokens/motion.js.map +1 -1
- package/cjs/theme/tokens/radius.js.map +1 -1
- package/cjs/theme/tokens/shadow.js.map +1 -1
- package/cjs/theme/tokens/spacing.js.map +1 -1
- package/cjs/theme/types.js.map +1 -1
- package/cjs/theme/utils/css-variable.js.map +1 -1
- package/cjs/theme/utils/font.js.map +1 -1
- package/cjs/theme/utils/use-apply-styles.js +1 -1
- package/cjs/theme/utils/use-apply-styles.js.map +1 -1
- package/cjs/theme/utils/use-design-token-override.js.map +1 -1
- package/cjs/theme/utils/use-design-token.js.map +1 -1
- package/cjs/theme/utils/use-media-query.js.map +1 -1
- package/cjs/time-range-picker/combobox-picker/combobox-picker.js +1 -1
- package/cjs/time-range-picker/combobox-picker/combobox-picker.js.map +1 -1
- package/cjs/time-range-picker/common.styles.js +1 -1
- package/cjs/time-range-picker/common.styles.js.map +1 -1
- package/{time-range-picker/common.styles_1qwp4xa.css → cjs/time-range-picker/common.styles_cnkkax.css} +2 -1
- package/cjs/time-range-picker/dial-picker/dial-picker.js +1 -1
- package/cjs/time-range-picker/dial-picker/dial-picker.js.map +1 -1
- package/cjs/time-range-picker/time-range-picker.js.map +1 -1
- package/cjs/time-slot-bar/time-slot-bar.js.map +1 -1
- package/cjs/time-slot-bar-week/time-slot-bar-week.js.map +1 -1
- package/cjs/time-slot-week-view/time-slot-week-view.js.map +1 -1
- package/cjs/timeline/timeline.js.map +1 -1
- package/cjs/timepicker/timepicker.js +1 -1
- package/cjs/timepicker/timepicker.js.map +1 -1
- package/cjs/timepicker/timepicker.styles.js +1 -1
- package/cjs/timepicker/timepicker.styles.js.map +1 -1
- package/cjs/timepicker/timepicker.styles_lyizvq.css +2 -0
- package/cjs/timetable/timetable-row/with-optional-popover.js +1 -1
- package/cjs/timetable/timetable-row/with-optional-popover.js.map +1 -1
- package/cjs/timetable/timetable.js +1 -1
- package/cjs/timetable/timetable.js.map +1 -1
- package/cjs/toast/toast.js.map +1 -1
- package/cjs/toggle/toggle.js.map +1 -1
- package/cjs/typography/index.js.map +1 -1
- package/cjs/uneditable-section/index.js.map +1 -1
- package/cjs/unit-number/unit-number-input.js.map +1 -1
- package/cjs/util/merge-refs.js.map +1 -1
- package/cjs/util/use-throttle.js +2 -0
- package/cjs/util/use-throttle.js.map +1 -0
- package/countdown-timer/types.d.ts +3 -3
- package/data-table/data-table.js +1 -1
- package/data-table/data-table.js.map +1 -1
- package/data-table/data-table.styles.d.ts +2 -1
- package/data-table/data-table.styles.js +1 -1
- package/data-table/data-table.styles.js.map +1 -1
- package/data-table/data-table.styles_rxganh.css +27 -0
- package/date-range-input/types.d.ts +1 -1
- package/drawer/types.d.ts +1 -1
- package/e-signature/types.d.ts +1 -1
- package/external/dompurify/dist/purify.es.js +2 -2
- package/external/dompurify/dist/purify.es.js.map +1 -1
- package/external/lodash/_setCacheHas.js.map +1 -1
- package/external/lodash/lodash.js +1 -1
- package/external/lodash/lodash.js.map +1 -1
- package/file-upload/types.d.ts +0 -1
- package/filter/types.d.ts +6 -10
- package/form/form-label-addon.js +1 -1
- package/form/form-label-addon.js.map +1 -1
- package/form/index.d.ts +65 -8
- package/form/index.js +1 -1
- package/form/index.js.map +1 -1
- package/form/types.d.ts +155 -6
- package/fullscreen-image-carousel/fullscreen-image-carousel.d.ts +7 -0
- package/fullscreen-image-carousel/fullscreen-image-carousel.js +1 -1
- package/fullscreen-image-carousel/fullscreen-image-carousel.js.map +1 -1
- package/fullscreen-image-carousel/types.d.ts +91 -3
- package/histogram-slider/histogram-slider.d.ts +6 -0
- package/histogram-slider/histogram-slider.js.map +1 -1
- package/histogram-slider/types.d.ts +63 -3
- package/image-button/image-button.d.ts +6 -0
- package/image-button/image-button.js.map +1 -1
- package/image-button/types.d.ts +11 -1
- package/index.js +1 -1
- package/input/input.d.ts +6 -0
- package/input/input.js.map +1 -1
- package/input/types.d.ts +38 -2
- package/input-group/input-group.d.ts +7 -0
- package/input-group/input-group.js.map +1 -1
- package/input-group/types.d.ts +84 -8
- package/input-multi-select/input-multi-select.d.ts +6 -0
- package/input-multi-select/input-multi-select.js.map +1 -1
- package/input-multi-select/types.d.ts +46 -5
- package/input-nested-multi-select/input-nested-multi-select.d.ts +8 -0
- package/input-nested-multi-select/input-nested-multi-select.js.map +1 -1
- package/input-nested-multi-select/types.d.ts +35 -5
- package/input-nested-select/input-nested-select.d.ts +9 -2
- package/input-nested-select/input-nested-select.js.map +1 -1
- package/input-nested-select/types.d.ts +77 -8
- package/input-range-select/input-range-select.d.ts +6 -0
- package/input-range-select/input-range-select.js.map +1 -1
- package/input-range-select/types.d.ts +68 -1
- package/input-range-slider/input-range-slider.d.ts +7 -0
- package/input-range-slider/input-range-slider.js.map +1 -1
- package/input-range-slider/types.d.ts +91 -6
- package/input-select/input-select.d.ts +5 -0
- package/input-select/input-select.js.map +1 -1
- package/input-select/types.d.ts +70 -14
- package/input-slider/input-slider.d.ts +6 -0
- package/input-slider/input-slider.js.map +1 -1
- package/input-slider/types.d.ts +21 -2
- package/input-textarea/textarea.d.ts +3 -0
- package/input-textarea/textarea.js.map +1 -1
- package/input-textarea/types.d.ts +24 -1
- package/language-switcher/language-switcher.d.ts +6 -0
- package/language-switcher/language-switcher.js.map +1 -1
- package/language-switcher/types.d.ts +23 -0
- package/layout/index.d.ts +16 -2
- package/layout/index.js +1 -1
- package/layout/index.js.map +1 -1
- package/layout/types.d.ts +61 -3
- package/link-list/internal-types.d.ts +57 -3
- package/link-list/link-list.d.ts +6 -0
- package/link-list/link-list.js.map +1 -1
- package/link-list/types.d.ts +3 -0
- package/local-nav/local-nav-dropdown/local-nav-dropdown.d.ts +11 -0
- package/local-nav/local-nav-dropdown/local-nav-dropdown.js.map +1 -1
- package/local-nav/local-nav-menu/local-nav-menu.d.ts +6 -0
- package/local-nav/local-nav-menu/local-nav-menu.js.map +1 -1
- package/local-nav/types.d.ts +51 -0
- package/markup/markup.d.ts +6 -0
- package/markup/markup.js.map +1 -1
- package/markup/types.d.ts +6 -2
- package/masked-input/masked-input.d.ts +6 -0
- package/masked-input/masked-input.js.map +1 -1
- package/masked-input/types.d.ts +83 -8
- package/masthead/masthead.d.ts +6 -0
- package/masthead/masthead.js.map +1 -1
- package/masthead/types.d.ts +9 -0
- package/menu/menu.d.ts +27 -4
- package/menu/menu.js +1 -1
- package/menu/menu.js.map +1 -1
- package/menu/types.d.ts +32 -0
- package/modal/index.d.ts +13 -0
- package/modal/index.js.map +1 -1
- package/modal/modal-box.js +1 -1
- package/modal/modal-box.js.map +1 -1
- package/modal/types.d.ts +54 -7
- package/modal-v2/index.d.ts +1 -15
- package/modal-v2/index.js +1 -1
- package/modal-v2/index.js.map +1 -1
- package/modal-v2/modal-v2.d.ts +32 -1
- package/modal-v2/modal-v2.js +1 -1
- package/modal-v2/modal-v2.js.map +1 -1
- package/modal-v2/slots/card.js +1 -1
- package/modal-v2/slots/card.js.map +1 -1
- package/modal-v2/types.d.ts +75 -8
- package/navbar/navbar.d.ts +7 -0
- package/navbar/navbar.js.map +1 -1
- package/navbar/types.d.ts +200 -13
- package/notification-banner/notification-banner-hoc.d.ts +6 -0
- package/notification-banner/notification-banner-hoc.js.map +1 -1
- package/notification-banner/notification-banner.d.ts +7 -0
- package/notification-banner/notification-banner.js.map +1 -1
- package/notification-banner/types.d.ts +57 -2
- package/otp-input/otp-input.d.ts +7 -0
- package/otp-input/otp-input.js.map +1 -1
- package/otp-input/types.d.ts +54 -11
- package/otp-verification/internal-types.d.ts +22 -5
- package/otp-verification/otp-verification.d.ts +6 -0
- package/otp-verification/otp-verification.js.map +1 -1
- package/otp-verification/types.d.ts +125 -6
- package/overlay/overlay.d.ts +7 -0
- package/overlay/overlay.js.map +1 -1
- package/overlay/types.d.ts +57 -2
- package/package.json +1 -1
- package/pagination/pagination.d.ts +5 -0
- package/pagination/pagination.js.map +1 -1
- package/pagination/types.d.ts +48 -0
- package/phone-number-input/phone-number-input.d.ts +7 -0
- package/phone-number-input/phone-number-input.js.map +1 -1
- package/phone-number-input/types.d.ts +78 -13
- package/pill/pill.d.ts +6 -0
- package/pill/pill.js.map +1 -1
- package/pill/types.d.ts +19 -0
- package/popover/popover-inline/popover-inline.d.ts +5 -0
- package/popover/popover-inline/popover-inline.js.map +1 -1
- package/popover/popover-trigger.d.ts +6 -0
- package/popover/popover-trigger.js.map +1 -1
- package/popover/popover.d.ts +6 -0
- package/popover/popover.js +1 -1
- package/popover/popover.js.map +1 -1
- package/popover/types.d.ts +150 -3
- package/predictive-text-input/predictive-text-input.d.ts +6 -0
- package/predictive-text-input/predictive-text-input.js.map +1 -1
- package/predictive-text-input/types.d.ts +65 -11
- package/progress-indicator/progress-indicator.d.ts +7 -0
- package/progress-indicator/progress-indicator.js.map +1 -1
- package/progress-indicator/types.d.ts +18 -0
- package/radio-button/radio-button.d.ts +5 -0
- package/radio-button/radio-button.js.map +1 -1
- package/radio-button/types.d.ts +11 -0
- package/schedule/internal-types.d.ts +18 -0
- package/schedule/schedule-day-view/types.d.ts +2 -1
- package/schedule/schedule-week-view/types.d.ts +2 -1
- package/schedule/schedule.d.ts +3 -0
- package/schedule/schedule.js.map +1 -1
- package/schedule/shared/with-optional-popover.js +1 -1
- package/schedule/shared/with-optional-popover.js.map +1 -1
- package/schedule/types.d.ts +129 -10
- package/select-histogram/select-histogram.d.ts +5 -0
- package/select-histogram/select-histogram.js.map +1 -1
- package/select-histogram/types.d.ts +57 -4
- package/shared/dropdown-list/types.d.ts +52 -19
- package/shared/dropdown-wrapper/types.d.ts +6 -0
- package/sidenav/sidenav.d.ts +10 -0
- package/sidenav/sidenav.js.map +1 -1
- package/sidenav/types.d.ts +70 -21
- package/singpass-button/singpass-button.d.ts +6 -0
- package/singpass-button/singpass-button.js.map +1 -1
- package/singpass-button/types.d.ts +29 -2
- package/smart-app-banner/smart-app-banner.d.ts +5 -0
- package/smart-app-banner/smart-app-banner.js.map +1 -1
- package/smart-app-banner/types.d.ts +54 -0
- package/tab/tab.d.ts +7 -0
- package/tab/tab.js.map +1 -1
- package/tab/types.d.ts +55 -6
- package/table/table.d.ts +21 -0
- package/table/table.js.map +1 -1
- package/table/table.styles.js +1 -1
- package/table/table.styles.js.map +1 -1
- package/{cjs/table/table.styles_1af5ipv.css → table/table.styles_1vjx31g.css} +1 -1
- package/tag/tag.d.ts +5 -0
- package/tag/tag.js.map +1 -1
- package/tag/types.d.ts +24 -0
- package/text-list/index.d.ts +17 -0
- package/text-list/index.js.map +1 -1
- package/text-list/types.d.ts +33 -4
- package/theme/theme-provider/breakpoint.d.ts +0 -1
- package/theme/theme-provider/breakpoint.js +1 -1
- package/theme/theme-provider/breakpoint.js.map +1 -1
- package/theme/theme-provider/hooks.d.ts +16 -0
- package/theme/theme-provider/hooks.js.map +1 -1
- package/theme/theme-provider/index.d.ts +7 -0
- package/theme/theme-provider/index.js.map +1 -1
- package/theme/theme-provider/types.d.ts +14 -0
- package/theme/tokens/border.d.ts +3 -0
- package/theme/tokens/border.js.map +1 -1
- package/theme/tokens/breakpoint.d.ts +3 -0
- package/theme/tokens/breakpoint.js.map +1 -1
- package/theme/tokens/colour.d.ts +3 -0
- package/theme/tokens/colour.js.map +1 -1
- package/theme/tokens/component.d.ts +1 -0
- package/theme/tokens/component.js.map +1 -1
- package/theme/tokens/font.d.ts +2 -0
- package/theme/tokens/font.js.map +1 -1
- package/theme/tokens/media-query.d.ts +1 -0
- package/theme/tokens/media-query.js.map +1 -1
- package/theme/tokens/motion.d.ts +1 -0
- package/theme/tokens/motion.js.map +1 -1
- package/theme/tokens/radius.d.ts +1 -0
- package/theme/tokens/radius.js.map +1 -1
- package/theme/tokens/shadow.d.ts +1 -0
- package/theme/tokens/shadow.js.map +1 -1
- package/theme/tokens/spacing.d.ts +1 -0
- package/theme/tokens/spacing.js.map +1 -1
- package/theme/types.d.ts +23 -3
- package/theme/types.js.map +1 -1
- package/theme/utils/css-variable.d.ts +10 -2
- package/theme/utils/css-variable.js.map +1 -1
- package/theme/utils/font.d.ts +2 -1
- package/theme/utils/font.js.map +1 -1
- package/theme/utils/use-apply-styles.d.ts +8 -2
- package/theme/utils/use-apply-styles.js +1 -1
- package/theme/utils/use-apply-styles.js.map +1 -1
- package/theme/utils/use-design-token-override.d.ts +9 -1
- package/theme/utils/use-design-token-override.js.map +1 -1
- package/theme/utils/use-design-token.d.ts +9 -0
- package/theme/utils/use-design-token.js.map +1 -1
- package/theme/utils/use-media-query.d.ts +41 -3
- package/theme/utils/use-media-query.js.map +1 -1
- package/time-range-picker/combobox-picker/combobox-picker.js +1 -1
- package/time-range-picker/combobox-picker/combobox-picker.js.map +1 -1
- package/time-range-picker/common.styles.d.ts +1 -0
- package/time-range-picker/common.styles.js +1 -1
- package/time-range-picker/common.styles.js.map +1 -1
- package/{cjs/time-range-picker/common.styles_1qwp4xa.css → time-range-picker/common.styles_cnkkax.css} +2 -1
- package/time-range-picker/dial-picker/dial-picker.js +1 -1
- package/time-range-picker/dial-picker/dial-picker.js.map +1 -1
- package/time-range-picker/time-range-picker.d.ts +5 -0
- package/time-range-picker/time-range-picker.js.map +1 -1
- package/time-range-picker/types.d.ts +85 -25
- package/time-slot-bar/internal-types.d.ts +1 -0
- package/time-slot-bar/time-slot-bar.d.ts +7 -0
- package/time-slot-bar/time-slot-bar.js.map +1 -1
- package/time-slot-bar/types.d.ts +112 -20
- package/time-slot-bar-week/time-slot-bar-week.d.ts +8 -0
- package/time-slot-bar-week/time-slot-bar-week.js.map +1 -1
- package/time-slot-bar-week/types.d.ts +74 -13
- package/time-slot-week-view/time-slot-week-view.d.ts +7 -0
- package/time-slot-week-view/time-slot-week-view.js.map +1 -1
- package/time-slot-week-view/types.d.ts +53 -10
- package/timeline/timeline.d.ts +6 -0
- package/timeline/timeline.js.map +1 -1
- package/timeline/types.d.ts +58 -4
- package/timepicker/timepicker.d.ts +5 -0
- package/timepicker/timepicker.js +1 -1
- package/timepicker/timepicker.js.map +1 -1
- package/timepicker/timepicker.styles.d.ts +1 -0
- package/timepicker/timepicker.styles.js +1 -1
- package/timepicker/timepicker.styles.js.map +1 -1
- package/timepicker/timepicker.styles_lyizvq.css +2 -0
- package/timepicker/types.d.ts +49 -14
- package/timetable/timetable-row/with-optional-popover.js +1 -1
- package/timetable/timetable-row/with-optional-popover.js.map +1 -1
- package/timetable/timetable.d.ts +6 -0
- package/timetable/timetable.js +1 -1
- package/timetable/timetable.js.map +1 -1
- package/timetable/types.d.ts +175 -50
- package/toast/toast.d.ts +6 -0
- package/toast/toast.js.map +1 -1
- package/toast/types.d.ts +42 -8
- package/toggle/toggle.d.ts +6 -0
- package/toggle/toggle.js.map +1 -1
- package/toggle/types.d.ts +95 -17
- package/typography/index.d.ts +29 -0
- package/typography/index.js.map +1 -1
- package/typography/types.d.ts +51 -8
- package/uneditable-section/index.d.ts +15 -0
- package/uneditable-section/index.js.map +1 -1
- package/uneditable-section/types.d.ts +66 -23
- package/unit-number/types.d.ts +30 -4
- package/unit-number/unit-number-input.d.ts +6 -0
- package/unit-number/unit-number-input.js.map +1 -1
- package/util/index.d.ts +1 -0
- package/util/merge-refs.d.ts +1 -1
- package/util/merge-refs.js.map +1 -1
- package/util/use-throttle.d.ts +1 -0
- package/util/use-throttle.js +2 -0
- package/util/use-throttle.js.map +1 -0
- package/cjs/data-table/data-table.styles_1iqq1g7.css +0 -26
- package/cjs/timepicker/timepicker.styles_1jm33yw.css +0 -1
- package/data-table/data-table.styles_1iqq1g7.css +0 -26
- package/timepicker/timepicker.styles_1jm33yw.css +0 -1
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { PopoverInlineProps } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* An inline text or icon element that opens a popover on interaction.
|
|
4
|
+
*
|
|
5
|
+
* Use `PopoverInline` to embed a labelled trigger directly within a body of content.
|
|
6
|
+
*/
|
|
2
7
|
export declare const PopoverInline: ({ ariaLabel, content, icon, underlineStyle, underlineHoverStyle, ...otherProps }: PopoverInlineProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-inline.js","sources":["../../../src/popover/popover-inline/popover-inline.tsx"],"sourcesContent":["import clsx from \"clsx\";\n\nimport { PopoverTrigger } from \"../popover-trigger\";\nimport type { PopoverInlineProps } from \"../types\";\nimport * as styles from \"./popover-inline.styles\";\n\nexport const PopoverInline = ({\n ariaLabel,\n content,\n icon,\n underlineStyle = \"default\",\n underlineHoverStyle = \"default\",\n ...otherProps\n}: PopoverInlineProps) => {\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n const hasContent = !!content;\n\n return (\n <PopoverTrigger {...otherProps}>\n <span\n aria-label={ariaLabel ?? (hasContent ? undefined : \"More info\")}\n role=\"button\"\n aria-haspopup=\"dialog\"\n tabIndex={0}\n className={styles.popoverInlineText}\n data-underline-style={underlineStyle}\n data-underline-hover-style={underlineHoverStyle}\n >\n {content}\n {icon && (\n <span\n className={clsx(\n hasContent && styles.popoverInlineIconWithContent\n )}\n >\n {icon}\n </span>\n )}\n </span>\n </PopoverTrigger>\n );\n};\n"],"names":["PopoverInline","_a","ariaLabel","content","icon","underlineStyle","underlineHoverStyle","otherProps","__rest","hasContent","_jsx","PopoverTrigger","Object","assign","children","_jsxs","undefined","role","tabIndex","className","styles.popoverInlineText","clsx","styles.popoverInlineIconWithContent"],"mappings":"
|
|
1
|
+
{"version":3,"file":"popover-inline.js","sources":["../../../src/popover/popover-inline/popover-inline.tsx"],"sourcesContent":["import clsx from \"clsx\";\n\nimport { PopoverTrigger } from \"../popover-trigger\";\nimport type { PopoverInlineProps } from \"../types\";\nimport * as styles from \"./popover-inline.styles\";\n\n/**\n * An inline text or icon element that opens a popover on interaction.\n *\n * Use `PopoverInline` to embed a labelled trigger directly within a body of content.\n */\nexport const PopoverInline = ({\n ariaLabel,\n content,\n icon,\n underlineStyle = \"default\",\n underlineHoverStyle = \"default\",\n ...otherProps\n}: PopoverInlineProps) => {\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n const hasContent = !!content;\n\n return (\n <PopoverTrigger {...otherProps}>\n <span\n aria-label={ariaLabel ?? (hasContent ? undefined : \"More info\")}\n role=\"button\"\n aria-haspopup=\"dialog\"\n tabIndex={0}\n className={styles.popoverInlineText}\n data-underline-style={underlineStyle}\n data-underline-hover-style={underlineHoverStyle}\n >\n {content}\n {icon && (\n <span\n className={clsx(\n hasContent && styles.popoverInlineIconWithContent\n )}\n >\n {icon}\n </span>\n )}\n </span>\n </PopoverTrigger>\n );\n};\n"],"names":["PopoverInline","_a","ariaLabel","content","icon","underlineStyle","underlineHoverStyle","otherProps","__rest","hasContent","_jsx","PopoverTrigger","Object","assign","children","_jsxs","undefined","role","tabIndex","className","styles.popoverInlineText","clsx","styles.popoverInlineIconWithContent"],"mappings":"gRAWO,MAAMA,EAAiBC,IAAA,IAAAC,UAC1BA,EAASC,QACTA,EAAOC,KACPA,EAAIC,eACJA,EAAiB,UAASC,oBAC1BA,EAAsB,WAASL,EAC5BM,EAAUC,EAAAP,EANa,uEAW1B,MAAMQ,IAAeN,EAErB,OACIO,EAACC,EAAcC,OAAAC,OAAA,CAAA,EAAKN,EAAU,CAAAO,SAC1BC,EAAA,OAAA,CAAA,aACgBb,QAAAA,EAAcO,OAAaO,EAAY,YACnDC,KAAK,SAAQ,gBACC,SACdC,SAAU,EACVC,UAAWC,yBACWf,EAAc,6BACRC,EAAmBQ,SAAA,CAE9CX,EACAC,GACGM,EAAA,OAAA,CACIS,UAAWE,EACPZ,GAAca,GACjBR,SAEAV,SAIA"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { PopoverTriggerProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps an element to make it a popover trigger.
|
|
4
|
+
*
|
|
5
|
+
* Use `PopoverTrigger` when you need to attach a popover to any arbitrary
|
|
6
|
+
* child element.
|
|
7
|
+
*/
|
|
2
8
|
export declare const PopoverTrigger: ({ children, popoverContent, trigger: _trigger, position, zIndex, rootNode, customOffset, delay, onPopoverAppear, onPopoverDismiss, popoverAriaLabel, enableFlip, enableResize, overflow, triggerOnFocus, isModal, className, ...otherProps }: PopoverTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-trigger.js","sources":["../../src/popover/popover-trigger.tsx"],"sourcesContent":["import {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingPortal,\n limitShift,\n offset,\n shift,\n size,\n useClick,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n} from \"@floating-ui/react\";\nimport clsx from \"clsx\";\nimport type React from \"react\";\nimport { useRef, useState } from \"react\";\n\nimport { useFloatingChild } from \"../overlay/use-floating-context\";\nimport { useInheritedThemeScope, useMaxWidthMediaQuery } from \"../theme\";\nimport { useId } from \"../util\";\nimport { Popover } from \"./popover\";\nimport * as styles from \"./popover-trigger.styles\";\nimport type { PopoverTriggerProps, PopoverTriggerType } from \"./types\";\n\nexport const PopoverTrigger = ({\n children,\n popoverContent,\n trigger: _trigger = \"click\",\n position = \"top\",\n zIndex,\n rootNode,\n customOffset,\n delay,\n onPopoverAppear,\n onPopoverDismiss,\n popoverAriaLabel,\n enableFlip = true,\n enableResize = false,\n overflow = \"auto\",\n triggerOnFocus = false,\n isModal = true,\n className,\n ...otherProps\n}: PopoverTriggerProps) => {\n // =========================================================================\n // CONST, STATE, REF\n // =========================================================================\n const [visible, setVisible] = useState<boolean>(false);\n const nodeRef = useRef<HTMLElement | null>(null);\n const popoverRef = useRef<HTMLElement | null>(null);\n const isMobile = useMaxWidthMediaQuery(\"sm\");\n const [availableHeight, setAvailableHeight] = useState(0);\n const internalId = useId();\n const popoverContainerId = `${internalId}-popover`;\n\n const { refs, floatingStyles, context } = useFloating({\n open: visible,\n placement: position,\n whileElementsMounted: autoUpdate,\n middleware: [\n offset(customOffset ?? 16),\n enableFlip && flip(),\n shift({\n limiter: limitShift(),\n }),\n enableResize &&\n size({\n apply({ availableHeight }) {\n setAvailableHeight(availableHeight);\n },\n }),\n ],\n onOpenChange: (isOpen) => {\n setVisible(isOpen);\n\n // this callback is triggering twice on hover, the check here prevents extra calls\n if (visible !== isOpen) {\n handleVisibilityChange(isOpen);\n }\n },\n });\n const parentZIndex = useFloatingChild();\n const { themeProps, themeStyle } = useInheritedThemeScope(visible);\n\n const trigger: PopoverTriggerType = isMobile ? \"click\" : _trigger;\n const isTooltip = trigger === \"hover\";\n\n const click = useClick(context, {\n // allow trigger by Space/Enter, but disable mouse click in hover mode\n ignoreMouse: isTooltip,\n });\n\n const dismiss = useDismiss(context);\n\n const hover = useHover(context, {\n enabled: isTooltip,\n // short window to enter the floating element without it closing\n delay: {\n open: delay?.open ?? 0,\n close: delay?.close ?? 500,\n },\n });\n\n const focus = useFocus(context, {\n enabled: triggerOnFocus,\n });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([\n click,\n dismiss,\n hover,\n focus,\n ]);\n\n // =========================================================================\n // HELPER FUNCTIONS\n // =========================================================================\n const isFocusInside = (node: Node | null) => {\n if (!node) return false;\n\n if (\n node instanceof HTMLElement &&\n node.hasAttribute(\"data-floating-ui-focus-guard\")\n ) {\n return true;\n }\n\n const refEl = nodeRef.current;\n const floatingEl = popoverRef.current?.parentElement;\n\n return (\n (!!refEl && refEl.contains(node)) ||\n (!!floatingEl && floatingEl.contains(node))\n );\n };\n\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handlePopoverMobileClose = () => {\n setVisible(false);\n handleVisibilityChange(false);\n };\n\n const handleVisibilityChange = (nextVisible: boolean) => {\n if (nextVisible && onPopoverAppear) onPopoverAppear();\n if (!nextVisible && onPopoverDismiss) onPopoverDismiss();\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLElement>) => {\n // On mobile, ModalV2 handles its own dismiss via onMobileClose\n if (isModal || (isMobile && typeof popoverContent !== \"function\"))\n return;\n\n const next =\n (e.relatedTarget as Node | null) ??\n (document.activeElement as Node | null);\n\n if (next && isFocusInside(next)) return;\n\n setVisible(false);\n handleVisibilityChange(false);\n };\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n const renderPopover = () => {\n if (typeof popoverContent === \"function\") {\n return popoverContent(\n enableResize ? { maxHeight: availableHeight, overflow } : {}\n );\n }\n\n return (\n <Popover\n visible\n onMobileClose={handlePopoverMobileClose}\n maxHeight={enableResize ? availableHeight : undefined}\n overflow={enableResize ? overflow : undefined}\n ariaLabel={popoverAriaLabel}\n id={popoverContainerId}\n >\n {popoverContent}\n </Popover>\n );\n };\n\n return (\n <>\n <div\n ref={(node) => {\n nodeRef.current = node;\n refs.setReference(node);\n }}\n {...getReferenceProps({\n onClick: (event) => {\n // prevent popover interaction from triggering click events on parents\n event.stopPropagation();\n event.preventDefault();\n },\n })}\n {...otherProps}\n className={clsx(styles.triggerContainer, className)}\n >\n {children}\n </div>\n {visible && (\n <FloatingPortal root={rootNode}>\n <FloatingFocusManager\n context={context}\n {...(!isModal && {\n initialFocus: -1,\n returnFocus: false,\n modal: false,\n })}\n >\n <div\n ref={(node) => {\n popoverRef.current = node;\n refs.setFloating(node);\n }}\n {...themeProps}\n onBlur={handleBlur}\n style={{\n ...themeStyle,\n ...floatingStyles,\n outline: \"none\",\n zIndex: zIndex ?? parentZIndex,\n }}\n {...getFloatingProps()}\n >\n {renderPopover()}\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n )}\n </>\n );\n};\n"],"names":["PopoverTrigger","_a","children","popoverContent","trigger","_trigger","position","zIndex","rootNode","customOffset","delay","onPopoverAppear","onPopoverDismiss","popoverAriaLabel","enableFlip","enableResize","overflow","triggerOnFocus","isModal","className","otherProps","__rest","visible","setVisible","useState","nodeRef","useRef","popoverRef","isMobile","useMaxWidthMediaQuery","availableHeight","setAvailableHeight","popoverContainerId","useId","refs","floatingStyles","context","useFloating","open","placement","whileElementsMounted","autoUpdate","middleware","offset","flip","shift","limiter","limitShift","size","apply","onOpenChange","isOpen","handleVisibilityChange","parentZIndex","useFloatingChild","themeProps","themeStyle","useInheritedThemeScope","isTooltip","click","useClick","ignoreMouse","dismiss","useDismiss","hover","useHover","enabled","_b","close","_c","focus","useFocus","getReferenceProps","getFloatingProps","useInteractions","handlePopoverMobileClose","nextVisible","_jsxs","_jsx","Object","assign","ref","node","current","setReference","onClick","event","stopPropagation","preventDefault","clsx","styles.triggerContainer","FloatingPortal","root","FloatingFocusManager","initialFocus","returnFocus","modal","setFloating","onBlur","e","next","relatedTarget","document","activeElement","HTMLElement","hasAttribute","refEl","floatingEl","parentElement","contains","isFocusInside","style","outline","maxHeight","Popover","onMobileClose","undefined","ariaLabel","id"],"mappings":"kmCA2BO,MAAMA,EAAkBC,aAAAC,SAC3BA,EAAQC,eACRA,EACAC,QAASC,EAAW,QAAOC,SAC3BA,EAAW,MAAKC,OAChBA,EAAMC,SACNA,EAAQC,aACRA,EAAYC,MACZA,EAAKC,gBACLA,EAAeC,iBACfA,EAAgBC,iBAChBA,EAAgBC,WAChBA,GAAa,EAAIC,aACjBA,GAAe,EAAKC,SACpBA,EAAW,OAAMC,eACjBA,GAAiB,EAAKC,QACtBA,GAAU,EAAIC,UACdA,GAASlB,EACNmB,EAAUC,EAAApB,EAlBc,CAAA,WAAA,iBAAA,UAAA,WAAA,SAAA,WAAA,eAAA,QAAA,kBAAA,mBAAA,mBAAA,aAAA,eAAA,WAAA,iBAAA,UAAA,cAuB3B,MAAOqB,EAASC,GAAcC,GAAkB,GAC1CC,EAAUC,EAA2B,MACrCC,EAAaD,EAA2B,MACxCE,EAAWC,EAAsB,OAChCC,EAAiBC,IAAsBP,EAAS,GAEjDQ,GAAqB,GADRC,eAGbC,KAAEA,GAAIC,eAAEA,GAAcC,QAAEA,IAAYC,EAAY,CAClDC,KAAMhB,EACNiB,UAAWjC,EACXkC,qBAAsBC,EACtBC,WAAY,CACRC,EAAOlC,QAAAA,EAAgB,IACvBK,GAAc8B,IACdC,EAAM,CACFC,QAASC,MAEbhC,GACIiC,EAAK,CACD,KAAAC,EAAMnB,gBAAEA,IACJC,GAAmBD,EACvB,KAGZoB,aAAeC,IACX5B,EAAW4B,GAGP7B,IAAY6B,GACZC,GAAuBD,EAC3B,IAGFE,GAAeC,KACfC,WAAEA,GAAUC,WAAEA,IAAeC,EAAuBnC,GAGpDoC,GAAwB,WADM9B,EAAW,QAAUvB,GAGnDsD,GAAQC,EAASxB,GAAS,CAE5ByB,YAAaH,KAGXI,GAAUC,EAAW3B,IAErB4B,GAAQC,EA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ChBwB,EAA+B,QAAlB1G,EAAA0B,EAAWwD,eAAO,IAAAlF,OAAA,EAAAA,EAAE2G,cAEvC,QACOF,GAASA,EAAMG,SAAS3B,MACxByB,GAAcA,EAAWE,SAAS3B,EAAM,EA0BnC4B,CAAcV,KAE1B7E,GAAW,GACX6B,IAAuB,GAAM,EA+DT2D,MAAKhC,OAAAC,OAAAD,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EACExB,IACArB,IAAc,CACjB6E,QAAS,OACTzG,OAAQA,QAAAA,EAAU8C,MAElBoB,KAAkB,CAAAvE,SA9DZ,mBAAnBC,EACAA,EACHY,EAAe,CAAEkG,UAAWnF,EAAiBd,YAAa,IAK9D8D,EAACoC,EAAO,CACJ5F,SAAO,EACP6F,cAAexC,GACfsC,UAAWlG,EAAee,OAAkBsF,EAC5CpG,SAAUD,EAAeC,OAAWoG,EACpCC,UAAWxG,EACXyG,GAAItF,GAAkB9B,SAErBC,cAsDN"}
|
|
1
|
+
{"version":3,"file":"popover-trigger.js","sources":["../../src/popover/popover-trigger.tsx"],"sourcesContent":["import {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingPortal,\n limitShift,\n offset,\n shift,\n size,\n useClick,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n} from \"@floating-ui/react\";\nimport clsx from \"clsx\";\nimport type React from \"react\";\nimport { useRef, useState } from \"react\";\n\nimport { useFloatingChild } from \"../overlay/use-floating-context\";\nimport { useInheritedThemeScope, useMaxWidthMediaQuery } from \"../theme\";\nimport { useId } from \"../util\";\nimport { Popover } from \"./popover\";\nimport * as styles from \"./popover-trigger.styles\";\nimport type { PopoverTriggerProps, PopoverTriggerType } from \"./types\";\n\n/**\n * Wraps an element to make it a popover trigger.\n *\n * Use `PopoverTrigger` when you need to attach a popover to any arbitrary\n * child element.\n */\nexport const PopoverTrigger = ({\n children,\n popoverContent,\n trigger: _trigger = \"click\",\n position = \"top\",\n zIndex,\n rootNode,\n customOffset,\n delay,\n onPopoverAppear,\n onPopoverDismiss,\n popoverAriaLabel,\n enableFlip = true,\n enableResize = false,\n overflow = \"auto\",\n triggerOnFocus = false,\n isModal = true,\n className,\n ...otherProps\n}: PopoverTriggerProps) => {\n // =========================================================================\n // CONST, STATE, REF\n // =========================================================================\n const [visible, setVisible] = useState<boolean>(false);\n const nodeRef = useRef<HTMLElement | null>(null);\n const popoverRef = useRef<HTMLElement | null>(null);\n const isMobile = useMaxWidthMediaQuery(\"sm\");\n const [availableHeight, setAvailableHeight] = useState(0);\n const internalId = useId();\n const popoverContainerId = `${internalId}-popover`;\n\n const { refs, floatingStyles, context } = useFloating({\n open: visible,\n placement: position,\n whileElementsMounted: autoUpdate,\n middleware: [\n offset(customOffset ?? 16),\n enableFlip && flip(),\n shift({\n limiter: limitShift(),\n }),\n enableResize &&\n size({\n apply({ availableHeight }) {\n setAvailableHeight(availableHeight);\n },\n }),\n ],\n onOpenChange: (isOpen) => {\n setVisible(isOpen);\n\n // this callback is triggering twice on hover, the check here prevents extra calls\n if (visible !== isOpen) {\n handleVisibilityChange(isOpen);\n }\n },\n });\n const parentZIndex = useFloatingChild();\n const { themeProps, themeStyle } = useInheritedThemeScope(visible);\n\n const trigger: PopoverTriggerType = isMobile ? \"click\" : _trigger;\n const isTooltip = trigger === \"hover\";\n\n const click = useClick(context, {\n // allow trigger by Space/Enter, but disable mouse click in hover mode\n ignoreMouse: isTooltip,\n });\n\n const dismiss = useDismiss(context);\n\n const hover = useHover(context, {\n enabled: isTooltip,\n // short window to enter the floating element without it closing\n delay: {\n open: delay?.open ?? 0,\n close: delay?.close ?? 500,\n },\n });\n\n const focus = useFocus(context, {\n enabled: triggerOnFocus,\n });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([\n click,\n dismiss,\n hover,\n focus,\n ]);\n\n // =========================================================================\n // HELPER FUNCTIONS\n // =========================================================================\n const isFocusInside = (node: Node | null) => {\n if (!node) return false;\n\n if (\n node instanceof HTMLElement &&\n node.hasAttribute(\"data-floating-ui-focus-guard\")\n ) {\n return true;\n }\n\n const refEl = nodeRef.current;\n const floatingEl = popoverRef.current?.parentElement;\n\n return (\n (!!refEl && refEl.contains(node)) ||\n (!!floatingEl && floatingEl.contains(node))\n );\n };\n\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handlePopoverMobileClose = () => {\n setVisible(false);\n handleVisibilityChange(false);\n };\n\n const handleVisibilityChange = (nextVisible: boolean) => {\n if (nextVisible && onPopoverAppear) onPopoverAppear();\n if (!nextVisible && onPopoverDismiss) onPopoverDismiss();\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLElement>) => {\n // On mobile, ModalV2 handles its own dismiss via onMobileClose\n if (isModal || (isMobile && typeof popoverContent !== \"function\"))\n return;\n\n const next =\n (e.relatedTarget as Node | null) ??\n (document.activeElement as Node | null);\n\n if (next && isFocusInside(next)) return;\n\n setVisible(false);\n handleVisibilityChange(false);\n };\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n const renderPopover = () => {\n if (typeof popoverContent === \"function\") {\n return popoverContent(\n enableResize ? { maxHeight: availableHeight, overflow } : {}\n );\n }\n\n return (\n <Popover\n visible\n onMobileClose={handlePopoverMobileClose}\n maxHeight={enableResize ? availableHeight : undefined}\n overflow={enableResize ? overflow : undefined}\n ariaLabel={popoverAriaLabel}\n id={popoverContainerId}\n >\n {popoverContent}\n </Popover>\n );\n };\n\n return (\n <>\n <div\n ref={(node) => {\n nodeRef.current = node;\n refs.setReference(node);\n }}\n {...getReferenceProps({\n onClick: (event) => {\n // prevent popover interaction from triggering click events on parents\n event.stopPropagation();\n event.preventDefault();\n },\n })}\n {...otherProps}\n className={clsx(styles.triggerContainer, className)}\n >\n {children}\n </div>\n {visible && (\n <FloatingPortal root={rootNode}>\n <FloatingFocusManager\n context={context}\n {...(!isModal && {\n initialFocus: -1,\n returnFocus: false,\n modal: false,\n })}\n >\n <div\n ref={(node) => {\n popoverRef.current = node;\n refs.setFloating(node);\n }}\n {...themeProps}\n onBlur={handleBlur}\n style={{\n ...themeStyle,\n ...floatingStyles,\n outline: \"none\",\n zIndex: zIndex ?? parentZIndex,\n }}\n {...getFloatingProps()}\n >\n {renderPopover()}\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n )}\n </>\n );\n};\n"],"names":["PopoverTrigger","_a","children","popoverContent","trigger","_trigger","position","zIndex","rootNode","customOffset","delay","onPopoverAppear","onPopoverDismiss","popoverAriaLabel","enableFlip","enableResize","overflow","triggerOnFocus","isModal","className","otherProps","__rest","visible","setVisible","useState","nodeRef","useRef","popoverRef","isMobile","useMaxWidthMediaQuery","availableHeight","setAvailableHeight","popoverContainerId","useId","refs","floatingStyles","context","useFloating","open","placement","whileElementsMounted","autoUpdate","middleware","offset","flip","shift","limiter","limitShift","size","apply","onOpenChange","isOpen","handleVisibilityChange","parentZIndex","useFloatingChild","themeProps","themeStyle","useInheritedThemeScope","isTooltip","click","useClick","ignoreMouse","dismiss","useDismiss","hover","useHover","enabled","_b","close","_c","focus","useFocus","getReferenceProps","getFloatingProps","useInteractions","handlePopoverMobileClose","nextVisible","_jsxs","_jsx","Object","assign","ref","node","current","setReference","onClick","event","stopPropagation","preventDefault","clsx","styles.triggerContainer","FloatingPortal","root","FloatingFocusManager","initialFocus","returnFocus","modal","setFloating","onBlur","e","next","relatedTarget","document","activeElement","HTMLElement","hasAttribute","refEl","floatingEl","parentElement","contains","isFocusInside","style","outline","maxHeight","Popover","onMobileClose","undefined","ariaLabel","id"],"mappings":"kmCAiCO,MAAMA,EAAkBC,aAAAC,SAC3BA,EAAQC,eACRA,EACAC,QAASC,EAAW,QAAOC,SAC3BA,EAAW,MAAKC,OAChBA,EAAMC,SACNA,EAAQC,aACRA,EAAYC,MACZA,EAAKC,gBACLA,EAAeC,iBACfA,EAAgBC,iBAChBA,EAAgBC,WAChBA,GAAa,EAAIC,aACjBA,GAAe,EAAKC,SACpBA,EAAW,OAAMC,eACjBA,GAAiB,EAAKC,QACtBA,GAAU,EAAIC,UACdA,G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,IAK9D8D,EAACoC,EAAO,CACJ5F,SAAO,EACP6F,cAAexC,GACfsC,UAAWlG,EAAee,OAAkBsF,EAC5CpG,SAAUD,EAAeC,OAAWoG,EACpCC,UAAWxG,EACXyG,GAAItF,GAAkB9B,SAErBC,cAsDN"}
|
package/popover/popover.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { PopoverProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* The presentational overlay for a popover panel. Renders as a floating card
|
|
4
|
+
* on desktop and modal on mobile.
|
|
5
|
+
*
|
|
6
|
+
* Use with `PopoverTrigger`, which manages visibility state and positioning.
|
|
7
|
+
*/
|
|
2
8
|
export declare const Popover: ({ children, visible, onMobileClose, maxHeight, overflow, ariaLabel, id, className, "data-testid": testId, ...otherProps }: PopoverProps) => JSX.Element;
|
package/popover/popover.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__rest as e}from"../_virtual/_tslib.js";import{jsxs as o,Fragment as r,jsx as
|
|
1
|
+
import{__rest as e}from"../_virtual/_tslib.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";import i from"clsx";import{useRef as l,useMemo as m}from"react";import{Card as s}from"../card/card.js";import{Markup as a}from"../markup/markup.js";import{ModalV2 as d}from"../modal-v2/modal-v2.js";import"../theme/theme-provider/index.js";import"../theme/theme-provider/context.js";import"../theme/tokens/border.js";import"../theme/tokens/colour.js";import"../theme/tokens/font.js";import"../theme/tokens/media-query.js";import{useApplyStyle as n}from"../theme/utils/use-apply-styles.js";import{useMaxWidthMediaQuery as p}from"../theme/utils/use-media-query.js";import{Typography as c}from"../typography/index.js";import{tokens as h,popoverCard as v,popoverCardWithMaxHeight as f,popoverCardWithOverflow as u,popoverContainer as j}from"./popover.styles.js";const b=b=>{var{children:x,visible:y=!1,onMobileClose:C,maxHeight:g,overflow:k,ariaLabel:w="More information",id:M,className:N,"data-testid":H="popover"}=b,q=e(b,["children","visible","onMobileClose","maxHeight","overflow","ariaLabel","id","className","data-testid"]);const B=p("sm"),L=l(null),O=m((()=>({[h.popoverCard.maxHeight]:void 0===g?null:`${g}px`,[h.popoverCard.overflowY]:null!=k?k:null})),[g,k]);n(L,O);const _=()=>{C&&C()},z=()=>"string"==typeof x?t(c.BodyMD,{children:x}):x;return o(r,{children:[y&&!B&&t("div",Object.assign({ref:L,tabIndex:0,"data-testid":H},q,{className:i(j,N),id:M,role:"dialog","aria-label":w,children:t(s,{className:i(v,void 0!==g&&f,k&&u),children:t(a,{baseTextSize:"body-md",children:z()})})})),B&&t(d,{show:y,onOverlayClick:_,onClose:_,id:M,role:"dialog","aria-label":w,children:o(d.Card,{children:[t(d.Content,{children:t(a,{children:z()})}),t(d.CloseButton,{})]})})]})};export{b as Popover};
|
|
2
2
|
//# sourceMappingURL=popover.js.map
|
package/popover/popover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sources":["../../src/popover/popover.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { useMemo, useRef } from \"react\";\n\nimport { Card } from \"../card\";\nimport { Markup } from \"../markup\";\nimport { ModalV2 } from \"../modal-v2\";\nimport { useApplyStyle, useMaxWidthMediaQuery } from \"../theme\";\nimport { Typography } from \"../typography\";\nimport * as styles from \"./popover.styles\";\nimport type { PopoverProps } from \"./types\";\n\nexport const Popover = ({\n children,\n visible = false,\n onMobileClose,\n maxHeight,\n overflow,\n ariaLabel = \"More information\",\n id,\n className,\n \"data-testid\": testId = \"popover\",\n ...otherProps\n}: PopoverProps): JSX.Element => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const isMobile = useMaxWidthMediaQuery(\"sm\");\n const popoverContainerRef = useRef<HTMLDivElement>(null);\n const popoverCardStyle = useMemo(\n () => ({\n [styles.tokens.popoverCard.maxHeight]:\n maxHeight === undefined ? null : `${maxHeight}px`,\n [styles.tokens.popoverCard.overflowY]: overflow ?? null,\n }),\n [maxHeight, overflow]\n );\n useApplyStyle(popoverContainerRef, popoverCardStyle);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleMobileClose = () => {\n if (onMobileClose) {\n onMobileClose();\n }\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderContent = () =>\n typeof children === \"string\" ? (\n <Typography.BodyMD>{children}</Typography.BodyMD>\n ) : (\n children\n );\n\n return (\n <>\n {visible && !isMobile && (\n <div\n ref={popoverContainerRef}\n tabIndex={0}\n data-testid={testId}\n {...otherProps}\n className={clsx(styles.popoverContainer, className)}\n id={id}\n role=\"dialog\"\n aria-label={ariaLabel}\n >\n <Card\n className={clsx(\n styles.popoverCard,\n maxHeight !== undefined &&\n styles.popoverCardWithMaxHeight,\n overflow && styles.popoverCardWithOverflow\n )}\n >\n <Markup baseTextSize=\"body-md\">\n {renderContent()}\n </Markup>\n </Card>\n </div>\n )}\n {isMobile && (\n <ModalV2\n show={visible}\n onOverlayClick={handleMobileClose}\n onClose={handleMobileClose}\n id={id}\n role=\"dialog\"\n aria-label={ariaLabel}\n >\n <ModalV2.Card>\n <ModalV2.Content>\n <Markup>{renderContent()}</Markup>\n </ModalV2.Content>\n <ModalV2.CloseButton />\n </ModalV2.Card>\n </ModalV2>\n )}\n </>\n );\n};\n"],"names":["Popover","_a","children","visible","onMobileClose","maxHeight","overflow","ariaLabel","id","className","testId","otherProps","__rest","isMobile","useMaxWidthMediaQuery","popoverContainerRef","useRef","popoverCardStyle","useMemo","styles.tokens","popoverCard","undefined","overflowY","useApplyStyle","handleMobileClose","renderContent","_jsx","Typography","BodyMD","_jsxs","_Fragment","Object","assign","ref","tabIndex","clsx","styles.popoverContainer","role","Card","styles.popoverCard","styles.popoverCardWithMaxHeight","styles.popoverCardWithOverflow","Markup","baseTextSize","ModalV2","show","onOverlayClick","onClose","Content","CloseButton"],"mappings":"
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../src/popover/popover.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { useMemo, useRef } from \"react\";\n\nimport { Card } from \"../card\";\nimport { Markup } from \"../markup\";\nimport { ModalV2 } from \"../modal-v2\";\nimport { useApplyStyle, useMaxWidthMediaQuery } from \"../theme\";\nimport { Typography } from \"../typography\";\nimport * as styles from \"./popover.styles\";\nimport type { PopoverProps } from \"./types\";\n\n/**\n * The presentational overlay for a popover panel. Renders as a floating card\n * on desktop and modal on mobile.\n *\n * Use with `PopoverTrigger`, which manages visibility state and positioning.\n */\nexport const Popover = ({\n children,\n visible = false,\n onMobileClose,\n maxHeight,\n overflow,\n ariaLabel = \"More information\",\n id,\n className,\n \"data-testid\": testId = \"popover\",\n ...otherProps\n}: PopoverProps): JSX.Element => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const isMobile = useMaxWidthMediaQuery(\"sm\");\n const popoverContainerRef = useRef<HTMLDivElement>(null);\n const popoverCardStyle = useMemo(\n () => ({\n [styles.tokens.popoverCard.maxHeight]:\n maxHeight === undefined ? null : `${maxHeight}px`,\n [styles.tokens.popoverCard.overflowY]: overflow ?? null,\n }),\n [maxHeight, overflow]\n );\n useApplyStyle(popoverContainerRef, popoverCardStyle);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleMobileClose = () => {\n if (onMobileClose) {\n onMobileClose();\n }\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderContent = () =>\n typeof children === \"string\" ? (\n <Typography.BodyMD>{children}</Typography.BodyMD>\n ) : (\n children\n );\n\n return (\n <>\n {visible && !isMobile && (\n <div\n ref={popoverContainerRef}\n tabIndex={0}\n data-testid={testId}\n {...otherProps}\n className={clsx(styles.popoverContainer, className)}\n id={id}\n role=\"dialog\"\n aria-label={ariaLabel}\n >\n <Card\n className={clsx(\n styles.popoverCard,\n maxHeight !== undefined &&\n styles.popoverCardWithMaxHeight,\n overflow && styles.popoverCardWithOverflow\n )}\n >\n <Markup baseTextSize=\"body-md\">\n {renderContent()}\n </Markup>\n </Card>\n </div>\n )}\n {isMobile && (\n <ModalV2\n show={visible}\n onOverlayClick={handleMobileClose}\n onClose={handleMobileClose}\n id={id}\n role=\"dialog\"\n aria-label={ariaLabel}\n >\n <ModalV2.Card>\n <ModalV2.Content>\n <Markup>{renderContent()}</Markup>\n </ModalV2.Content>\n <ModalV2.CloseButton />\n </ModalV2.Card>\n </ModalV2>\n )}\n </>\n );\n};\n"],"names":["Popover","_a","children","visible","onMobileClose","maxHeight","overflow","ariaLabel","id","className","testId","otherProps","__rest","isMobile","useMaxWidthMediaQuery","popoverContainerRef","useRef","popoverCardStyle","useMemo","styles.tokens","popoverCard","undefined","overflowY","useApplyStyle","handleMobileClose","renderContent","_jsx","Typography","BodyMD","_jsxs","_Fragment","Object","assign","ref","tabIndex","clsx","styles.popoverContainer","role","Card","styles.popoverCard","styles.popoverCardWithMaxHeight","styles.popoverCardWithOverflow","Markup","baseTextSize","ModalV2","show","onOverlayClick","onClose","Content","CloseButton"],"mappings":"o2BAiBO,MAAMA,EAAWC,IAAA,IAAAC,SACpBA,EAAQC,QACRA,GAAU,EAAKC,cACfA,EAAaC,UACbA,EAASC,SACTA,EAAQC,UACRA,EAAY,mBAAkBC,GAC9BA,EAAEC,UACFA,EACA,cAAeC,EAAS,WAAST,EAC9BU,EAAUC,EAAAX,EAVO,0GAepB,MAAMY,EAAWC,EAAsB,MACjCC,EAAsBC,EAAuB,MAC7CC,EAAmBC,GACrB,KAAA,CACI,CAACC,EAAcC,YAAYf,gBACTgB,IAAdhB,EAA0B,KAAO,GAAGA,MACxC,CAACc,EAAcC,YAAYE,WAAYhB,QAAAA,EAAY,QAEvD,CAACD,EAAWC,IAEhBiB,EAAcR,EAAqBE,GAKnC,MAAMO,EAAoB,KAClBpB,GACAA,GACJ,EAMEqB,EAAgB,IACE,iBAAbvB,EACHwB,EAACC,EAAWC,OAAM,CAAA1B,SAAEA,IAA6B,EAKzD,OACI2B,EAAAC,EAAA,CAAA5B,SAAA,CACKC,IAAYU,GACTa,EAAA,MAAAK,OAAAC,OAAA,CACIC,IAAKlB,EACLmB,SAAU,EAAC,cACExB,GACTC,EAAU,CACdF,UAAW0B,EAAKC,EAAyB3B,GACzCD,GAAIA,EACJ6B,KAAK,SAAQ,aACD9B,EAASL,SAErBwB,EAACY,EAAI,CACD7B,UAAW0B,EACPI,OACclB,IAAdhB,GACImC,EACJlC,GAAYmC,GACfvC,SAEDwB,EAACgB,EAAM,CAACC,aAAa,mBAChBlB,WAKhBZ,GACGa,EAACkB,EAAO,CACJC,KAAM1C,EACN2C,eAAgBtB,EAChBuB,QAASvB,EACThB,GAAIA,EACJ6B,KAAK,SAAQ,aACD9B,EAASL,SAErB2B,EAACe,EAAQN,KAAI,CAAApC,SAAA,CACTwB,EAACkB,EAAQI,QAAO,CAAA9C,SACZwB,EAACgB,EAAM,CAAAxC,SAAEuB,QAEbC,EAACkB,EAAQK,YAAW,CAAA,UAIjC"}
|
package/popover/types.d.ts
CHANGED
|
@@ -1,59 +1,206 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `Popover` component.
|
|
4
|
+
*/
|
|
2
5
|
export interface PopoverProps extends PopoverRenderProps {
|
|
6
|
+
/**
|
|
7
|
+
* Content displayed inside the popover. A plain string is automatically
|
|
8
|
+
* wrapped in a `Typography.BodyMD` element.
|
|
9
|
+
*/
|
|
3
10
|
children: string | JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* Controls whether the popover is visible.
|
|
13
|
+
*
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
4
16
|
visible?: boolean | undefined;
|
|
5
17
|
id?: string | undefined;
|
|
6
18
|
className?: string | undefined;
|
|
7
19
|
"data-testid"?: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Called when the user dismisses the popover on a mobile viewport, either
|
|
22
|
+
* by tapping the overlay or the close button.
|
|
23
|
+
*/
|
|
8
24
|
onMobileClose?: (() => void) | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Accessible label for the `role="dialog"` element.
|
|
27
|
+
*
|
|
28
|
+
* @default "More information"
|
|
29
|
+
*/
|
|
9
30
|
ariaLabel?: string | undefined;
|
|
10
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Style constraints that control the popover card's height and overflow.
|
|
34
|
+
*/
|
|
11
35
|
export interface PopoverRenderProps {
|
|
36
|
+
/**
|
|
37
|
+
* CSS `overflow` value applied to the popover card body.
|
|
38
|
+
*/
|
|
12
39
|
overflow?: PopoverOverflowType | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum height of the popover card in pixels.
|
|
42
|
+
*/
|
|
13
43
|
maxHeight?: number | undefined;
|
|
14
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Interaction that opens the popover.
|
|
47
|
+
*
|
|
48
|
+
* @remarks On mobile viewports `"hover"` is automatically promoted to `"click"`.
|
|
49
|
+
*/
|
|
15
50
|
export type PopoverTriggerType = "click" | "hover";
|
|
16
51
|
type Position = "top" | "right" | "bottom" | "left";
|
|
17
52
|
type Alignment = "start" | "end";
|
|
18
53
|
type AlignedPosition = `${Position}-${Alignment}`;
|
|
54
|
+
/**
|
|
55
|
+
* CSS `overflow` value applied to the popover card body.
|
|
56
|
+
*/
|
|
19
57
|
export type PopoverOverflowType = "visible" | "hidden" | "clip" | "scroll" | "auto";
|
|
58
|
+
/**
|
|
59
|
+
* Preferred placement of the popover relative to its trigger element.
|
|
60
|
+
*/
|
|
20
61
|
export type PopoverPosition = Position | AlignedPosition;
|
|
62
|
+
/**
|
|
63
|
+
* Props for the `PopoverTrigger` component.
|
|
64
|
+
*/
|
|
21
65
|
export interface PopoverTriggerProps {
|
|
66
|
+
/**
|
|
67
|
+
* The trigger element rendered inside a focusable wrapper div.
|
|
68
|
+
*/
|
|
22
69
|
children: React.ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* Content shown inside the popover panel. A string or JSX element is
|
|
72
|
+
* rendered inside the default `Popover`; a render function bypasses it
|
|
73
|
+
* for completely custom rendering.
|
|
74
|
+
*/
|
|
23
75
|
popoverContent: string | JSX.Element | ((renderProps: PopoverRenderProps) => React.ReactNode);
|
|
76
|
+
/**
|
|
77
|
+
* Interaction that opens the popover.
|
|
78
|
+
*
|
|
79
|
+
* @remarks On mobile, always `"click"`.
|
|
80
|
+
*
|
|
81
|
+
* @default "click"
|
|
82
|
+
*/
|
|
24
83
|
trigger?: PopoverTriggerType | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Preferred placement of the popover relative to the trigger.
|
|
86
|
+
*
|
|
87
|
+
* @default "top"
|
|
88
|
+
*/
|
|
25
89
|
position?: PopoverPosition | undefined;
|
|
26
90
|
id?: string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Overrides the stacking context z-index for the floating popover layer.
|
|
93
|
+
* Falls back to the inherited floating context z-index when omitted.
|
|
94
|
+
*/
|
|
27
95
|
zIndex?: number | undefined;
|
|
28
96
|
className?: string | undefined;
|
|
29
97
|
"data-testid"?: string | undefined;
|
|
30
98
|
/**
|
|
31
|
-
* The root element that contains the popover element.
|
|
99
|
+
* The root element that contains the popover element.
|
|
100
|
+
*
|
|
101
|
+
* @remarks Specify this if you need to change the parent of the
|
|
102
|
+
* popover in the HTML DOM.
|
|
103
|
+
* Possible use case: sharing a stacking context.
|
|
32
104
|
*
|
|
33
|
-
*
|
|
34
|
-
* the popover may
|
|
105
|
+
* Note: if a parent of the trigger has a higher `z-index` than the popover,
|
|
106
|
+
* the popover may be obscured.
|
|
107
|
+
*
|
|
108
|
+
* @default document.body
|
|
35
109
|
*/
|
|
36
110
|
rootNode?: RefObject<HTMLElement> | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Distance in pixels between the trigger element and the popover panel.
|
|
113
|
+
*
|
|
114
|
+
* @default 16
|
|
115
|
+
*/
|
|
37
116
|
customOffset?: number | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Open and close delays in milliseconds. Only applies when `trigger` is `"hover"`.
|
|
119
|
+
*/
|
|
38
120
|
delay?: {
|
|
39
121
|
open?: number | undefined;
|
|
40
122
|
close?: number | undefined;
|
|
41
123
|
} | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Allows the popover to flip to the opposite side when the preferred
|
|
126
|
+
* position has insufficient viewport space.
|
|
127
|
+
*
|
|
128
|
+
* @default true
|
|
129
|
+
*/
|
|
42
130
|
enableFlip?: boolean | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Resizes the popover to fit the remaining vertical space in the viewport.
|
|
133
|
+
*
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
43
136
|
enableResize?: boolean | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* CSS `overflow` value forwarded to the popover card when `enableResize`
|
|
139
|
+
* is active.
|
|
140
|
+
*
|
|
141
|
+
* @default "auto"
|
|
142
|
+
*/
|
|
44
143
|
overflow?: PopoverOverflowType | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Accessible label for the popover dialog element.
|
|
146
|
+
*/
|
|
45
147
|
popoverAriaLabel?: string | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* Also opens the popover when the trigger element receives focus.
|
|
150
|
+
*
|
|
151
|
+
* @default false
|
|
152
|
+
*/
|
|
46
153
|
triggerOnFocus?: boolean | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* When `true`, focus is trapped inside the popover until dismissed.
|
|
156
|
+
* When `false`, the popover closes automatically once the user tabs
|
|
157
|
+
* away from both the trigger and the popover.
|
|
158
|
+
*
|
|
159
|
+
* @default true
|
|
160
|
+
*/
|
|
47
161
|
isModal?: boolean | undefined;
|
|
162
|
+
/**
|
|
163
|
+
* Called when the popover becomes visible.
|
|
164
|
+
*/
|
|
48
165
|
onPopoverAppear?: (() => void) | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* Called when the popover is dismissed.
|
|
168
|
+
*/
|
|
49
169
|
onPopoverDismiss?: (() => void) | undefined;
|
|
50
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Underline decoration applied to the `PopoverInline` trigger span.
|
|
173
|
+
*/
|
|
51
174
|
export type PopoverInlineStyle = "default" | "underline" | "underline-dashed";
|
|
175
|
+
/**
|
|
176
|
+
* Props for the `PopoverInline` component.
|
|
177
|
+
*/
|
|
52
178
|
export interface PopoverInlineProps extends Omit<PopoverTriggerProps, "children"> {
|
|
179
|
+
/**
|
|
180
|
+
* Accessible label for the trigger button.
|
|
181
|
+
*
|
|
182
|
+
* @default "More info" when `content` is not provided
|
|
183
|
+
*/
|
|
53
184
|
ariaLabel?: string | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Label text or element displayed inside the trigger span.
|
|
187
|
+
*/
|
|
54
188
|
content?: React.ReactNode | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Icon element rendered after `content` inside the trigger span.
|
|
191
|
+
*/
|
|
55
192
|
icon?: JSX.Element | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Underline style applied to the trigger span in its default state.
|
|
195
|
+
*
|
|
196
|
+
* @default "default"
|
|
197
|
+
*/
|
|
56
198
|
underlineStyle?: PopoverInlineStyle | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Underline style applied to the trigger span on hover.
|
|
201
|
+
*
|
|
202
|
+
* @default "default"
|
|
203
|
+
*/
|
|
57
204
|
underlineHoverStyle?: PopoverInlineStyle | undefined;
|
|
58
205
|
}
|
|
59
206
|
export {};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { PredictiveTextInputProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* A text input that fetches and displays matching suggestions as the user types.
|
|
4
|
+
*
|
|
5
|
+
* Use `PredictiveTextInput` for search-as-you-type or autocomplete scenarios
|
|
6
|
+
* where options are loaded asynchronously based on the current input.
|
|
7
|
+
*/
|
|
2
8
|
export declare const PredictiveTextInput: <T, V>({ className, "data-testid": testId, selectedOption, minimumCharacters, fetchOptions, placeholder, readOnly, disabled, error, valueExtractor, listExtractor, displayValueExtractor, onSelectOption, alignment, dropdownZIndex, dropdownRootNode, dropdownWidth, "aria-describedby": ariaDescribedBy, ...otherProps }: PredictiveTextInputProps<T, V>) => JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predictive-text-input.js","sources":["../../src/predictive-text-input/predictive-text-input.tsx"],"sourcesContent":["import debounce from \"lodash/debounce\";\nimport type React from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { Input } from \"../input\";\nimport { concatIds, VisuallyHidden } from \"../shared/accessibility\";\nimport { DropdownList, DropdownListState } from \"../shared/dropdown-list\";\nimport type { ItemsLoadStateType } from \"../shared/dropdown-list/types\";\nimport { ElementWithDropdown } from \"../shared/dropdown-wrapper\";\nimport { InputWrapper } from \"../shared/input-wrapper\";\nimport { useId } from \"../util\";\nimport type { PredictiveTextInputProps } from \"./types\";\n\nexport const PredictiveTextInput = <T, V>({\n className,\n \"data-testid\": testId,\n selectedOption,\n minimumCharacters = 3,\n fetchOptions,\n placeholder = \"Enter here...\",\n readOnly = false,\n disabled = false,\n error,\n valueExtractor,\n listExtractor,\n displayValueExtractor,\n onSelectOption,\n alignment,\n dropdownZIndex,\n dropdownRootNode,\n dropdownWidth,\n \"aria-describedby\": ariaDescribedBy,\n ...otherProps\n}: PredictiveTextInputProps<T, V>): JSX.Element => {\n const getDisplayValue = (item: T | undefined): string => {\n if (!item) return \"\";\n return displayValueExtractor\n ? displayValueExtractor(item)\n : item.toString();\n };\n\n // =============================================================================\n // CONST, STATE\n // =============================================================================\n const [input, setInput] = useState<string>(() =>\n selectedOption ? getDisplayValue(selectedOption) : \"\"\n );\n const [searchedInput, setSearchedInput] = useState<string>(() =>\n selectedOption ? getDisplayValue(selectedOption) : \"\"\n );\n const [options, setOptions] = useState<T[]>([]);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [isError, setIsError] = useState<boolean>(false);\n const [isOptionSelected, setIsOptionSelected] = useState<boolean>(\n !!selectedOption\n );\n const [prevOptionSelected, setPrevOptionSelected] = useState<T | undefined>(\n selectedOption\n );\n const [isOpen, setIsOpen] = useState(false);\n const [isFocused, setIsFocused] = useState(false);\n\n const internalId = useId();\n const [resultAnnouncement, setResultAnnouncement] = useState<string | null>(\n null\n );\n const instructionId = `${internalId}-instruction`;\n\n const nodeRef = useRef<HTMLDivElement | null>(null);\n const selectorRef = useRef<HTMLInputElement | null>(null);\n\n const fetchOptionsRef = useRef(fetchOptions);\n\n // =============================================================================\n // DEBOUNCE FUNCTIONS\n // =============================================================================\n const handleFetchOptions = useCallback(async (input: string) => {\n if (!fetchOptionsRef.current) return;\n setIsError(false);\n setIsLoading(true);\n try {\n const fetchedOptions = await fetchOptionsRef.current(input);\n setSearchedInput(input);\n setOptions(fetchedOptions ?? []);\n setIsLoading(false);\n } catch {\n setIsError(true);\n setIsLoading(false);\n }\n }, []);\n\n const fetchOptionsDebounced = useCallback(\n debounce((input: string) => {\n handleFetchOptions(input);\n }, 500),\n [handleFetchOptions]\n );\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n\n useEffect(() => {\n fetchOptionsRef.current = fetchOptions;\n }, [fetchOptions]);\n\n useEffect(() => {\n /***\n * Should not fetch options for the following the scenario :\n * 1. When input < minimumCharacters\n * 2. When user selected option from dropdown becomes input\n * 3. Initial selectedOption passed in as input\n */\n if (input && input.length >= minimumCharacters) {\n if (!isOptionSelected) {\n setIsOpen(true);\n fetchOptionsDebounced(input);\n } else if (input !== searchedInput) {\n fetchOptionsDebounced(input);\n }\n } else {\n fetchOptionsDebounced.cancel();\n }\n\n if (input === \"\" && prevOptionSelected) {\n onSelectOption?.(undefined, undefined);\n handleDropdownDismiss();\n setPrevOptionSelected(undefined);\n }\n\n if (selectedOption && input !== getDisplayValue(selectedOption)) {\n setIsOptionSelected(false);\n }\n }, [input, selectedOption]);\n\n useEffect(() => {\n setInput(selectedOption ? getDisplayValue(selectedOption) : \"\");\n setSearchedInput(selectedOption ? getDisplayValue(selectedOption) : \"\");\n setPrevOptionSelected(selectedOption);\n setOptions([]);\n setIsOptionSelected(!!selectedOption);\n }, [selectedOption]);\n\n useEffect(() => {\n const state = getItemsLoadState();\n const count = options?.length ?? 0;\n\n if (state === \"loading\" && input.length >= minimumCharacters) {\n setResultAnnouncement(\"Loading suggested results\");\n return;\n }\n\n if (state === \"fail\") {\n setResultAnnouncement(\"Suggestions failed to load. Try again.\");\n return;\n }\n\n if (isOpen && !isLoading && !isError) {\n if (count === 0) {\n setResultAnnouncement(input ? \"No results found.\" : null);\n } else {\n setResultAnnouncement(\n `${count} result${\n count > 1 ? \"s\" : \"\"\n } found. Press down arrow to scroll through the list.`\n );\n }\n }\n }, [options, input, isError, isLoading]);\n\n // =============================================================================\n // Cleanup: cancel debounce on unmount\n // =============================================================================\n useEffect(() => {\n return () => {\n fetchOptionsDebounced.cancel();\n };\n }, [fetchOptionsDebounced]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleListItemClick = (item: T, extractedValue: V) => {\n selectorRef.current?.focus();\n setInput(getDisplayValue(item));\n setSearchedInput(item ? getDisplayValue(item) : \"\");\n setIsOptionSelected(true);\n setPrevOptionSelected(item);\n setIsOpen(false);\n onSelectOption?.(item, extractedValue);\n };\n\n const handleOpen = () => {\n if (!isOptionSelected && input.length >= minimumCharacters) {\n setIsFocused(true);\n }\n };\n\n const handleClose = () => {\n setIsOpen(false);\n setIsFocused(false);\n handleOnBlur();\n };\n\n const handleNodeFocus = () => {\n setIsFocused(true);\n };\n\n const handleNodeBlur = (e: React.FocusEvent) => {\n if (\n !isOpen &&\n nodeRef.current &&\n !nodeRef.current.contains(e.relatedTarget as Node)\n ) {\n setIsFocused(false);\n handleOnBlur();\n }\n };\n\n const handleListDismiss = () => {\n setIsOpen(false);\n setIsFocused(false);\n };\n\n const handleDismiss = () => {\n setIsOpen(false);\n setIsFocused(false);\n handleOnBlur();\n selectorRef.current?.focus();\n };\n\n const handleOnClear = () => {\n setInput(\"\");\n setOptions([]);\n setIsOptionSelected(false);\n setIsOpen(false);\n onSelectOption?.(undefined, undefined);\n };\n\n const handleOnBlur = () => {\n if (!isOptionSelected) {\n if (prevOptionSelected) {\n const prevValue = getDisplayValue(prevOptionSelected);\n setInput(prevValue);\n setIsOpen(false);\n } else {\n handleOnClear();\n }\n }\n };\n\n const handleTyping = (e: React.ChangeEvent<HTMLInputElement>) => {\n setInput(e.target.value);\n setIsOptionSelected(false);\n };\n\n const handleDropdownDismiss = (item?: T) => {\n setSearchedInput(item ? getDisplayValue(item) : \"\");\n setIsOptionSelected(!!item);\n setOptions([]);\n setIsLoading(true);\n };\n\n // =============================================================================\n // HELPER FUNCTION\n // =============================================================================\n const getItemsLoadState = (): ItemsLoadStateType => {\n if (isError) return \"fail\";\n return isLoading ? \"loading\" : \"success\";\n };\n\n // =============================================================================\n // RENDER FUNCTION\n // =============================================================================\n const renderInputElement = () => {\n return (\n <InputWrapper\n className={className}\n data-testid={testId}\n ref={nodeRef}\n tabIndex={-1}\n onFocus={handleNodeFocus}\n onBlur={handleNodeBlur}\n focused={isFocused}\n disabled={disabled}\n readOnly={readOnly}\n error={error}\n >\n <VisuallyHidden id={instructionId} aria-hidden>\n Type in {minimumCharacters} or more characters for suggested\n results.\n </VisuallyHidden>\n {resultAnnouncement && (\n <VisuallyHidden aria-live=\"polite\">\n {resultAnnouncement}\n </VisuallyHidden>\n )}\n <Input\n role=\"combobox\"\n ref={selectorRef}\n id={internalId}\n type=\"text\"\n value={input}\n onChange={handleTyping}\n placeholder={placeholder}\n readOnly={readOnly}\n disabled={disabled}\n allowClear\n onClear={handleOnClear}\n aria-expanded={isOpen}\n aria-controls={internalId}\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n onBlur={\n input.length < minimumCharacters\n ? handleOnBlur\n : undefined\n }\n styleType=\"no-border\"\n aria-describedby={concatIds(ariaDescribedBy, instructionId)}\n {...otherProps}\n />\n </InputWrapper>\n );\n };\n\n const renderDropdown = () => {\n return (\n <>\n <DropdownList\n listboxId={internalId}\n listItems={options}\n onSelectItem={handleListItemClick}\n onDismiss={handleListDismiss}\n valueExtractor={valueExtractor}\n listExtractor={listExtractor}\n itemsLoadState={getItemsLoadState()}\n itemTruncationType={\"end\"}\n itemMaxLines={1}\n labelDisplayType={\"next-line\"}\n disableItemFocus\n onRetry={() => handleFetchOptions(input)}\n width={dropdownWidth}\n matchElementWidth\n />\n </>\n );\n };\n\n return (\n <DropdownListState>\n <ElementWithDropdown\n enabled={!readOnly && !disabled}\n isOpen={isOpen}\n renderElement={renderInputElement}\n renderDropdown={renderDropdown}\n onOpen={handleOpen}\n onClose={handleClose}\n onDismiss={handleDismiss}\n clickToToggle={false}\n offset={8}\n alignment={alignment}\n fitAvailableHeight\n customZIndex={dropdownZIndex}\n rootNode={dropdownRootNode}\n />\n </DropdownListState>\n );\n};\n"],"names":["PredictiveTextInput","_a","className","testId","selectedOption","minimumCharacters","fetchOptions","placeholder","readOnly","disabled","error","valueExtractor","listExtractor","displayValueExtractor","onSelectOption","alignment","dropdownZIndex","dropdownRootNode","dropdownWidth","ariaDescribedBy","otherProps","__rest","getDisplayValue","item","toString","input","setInput","useState","searchedInput","setSearchedInput","options","setOptions","isLoading","setIsLoading","isError","setIsError","isOptionSelected","setIsOptionSelected","prevOptionSelected","setPrevOptionSelected","isOpen","setIsOpen","isFocused","setIsFocused","internalId","useId","resultAnnouncement","setResultAnnouncement","instructionId","nodeRef","useRef","selectorRef","fetchOptionsRef","handleFetchOptions","useCallback","__awaiter","current","fetchedOptions","fetchOptionsDebounced","debounce","useEffect","length","cancel","undefined","handleDropdownDismiss","state","getItemsLoadState","count","handleListItemClick","extractedValue","focus","handleNodeFocus","handleNodeBlur","e","contains","relatedTarget","handleOnBlur","handleListDismiss","handleOnClear","prevValue","handleTyping","target","value","_jsx","DropdownListState","children","ElementWithDropdown","enabled","renderElement","_jsxs","InputWrapper","ref","tabIndex","onFocus","onBlur","focused","VisuallyHidden","id","Input","Object","assign","role","type","onChange","allowClear","onClear","styleType","concatIds","renderDropdown","_Fragment","DropdownList","listboxId","listItems","onSelectItem","onDismiss","itemsLoadState","itemTruncationType","itemMaxLines","labelDisplayType","disableItemFocus","onRetry","width","matchElementWidth","onOpen","onClose","clickToToggle","offset","fitAvailableHeight","customZIndex","rootNode"],"mappings":"mwEAaO,MAAMA,EAA6BC,QAAAC,UACtCA,EACA,cAAeC,EAAMC,eACrBA,EAAcC,kBACdA,EAAoB,EAACC,aACrBA,EAAYC,YACZA,EAAc,gBAAeC,SAC7BA,GAAW,EAAKC,SAChBA,GAAW,EAAKC,MAChBA,EAAKC,eACLA,EAAcC,cACdA,EAAaC,sBACbA,EAAqBC,eACrBA,EAAcC,UACdA,EAASC,eACTA,EAAcC,iBACdA,EAAgBC,cAChBA,EACA,mBAAoBC,KACjBC,EAAUC,EAAApB,EAnByB,CAAA,YAAA,cAAA,iBAAA,oBAAA,eAAA,cAAA,WAAA,WAAA,QAAA,iBAAA,gBAAA,wBAAA,iBAAA,YAAA,iBAAA,mBAAA,gBAAA,qBAqBtC,MAAMqB,EAAmBC,GAChBA,EACEV,EACDA,EAAsBU,GACtBA,EAAKC,WAHO,IASfC,EAAOC,GAAYC,GAAiB,IACvCvB,EAAiBkB,EAAgBlB,GAAkB,MAEhDwB,EAAeC,GAAoBF,GAAiB,IACvDvB,EAAiBkB,EAAgBlB,GAAkB,MAEhD0B,EAASC,GAAcJ,EAAc,KACrCK,EAAWC,GAAgBN,GAAkB,IAC7CO,EAASC,GAAcR,GAAkB,IACzCS,EAAkBC,GAAuBV,IAC1CvB,IAECkC,EAAoBC,GAAyBZ,EAChDvB,IAEGoC,EAAQC,IAAad,GAAS,IAC9Be,GAAWC,IAAgBhB,GAAS,GAErCiB,GAAaC,KACZC,GAAoBC,IAAyBpB,EAChD,MAEEqB,GAAgB,GAAGJ,iBAEnBK,GAAUC,EAA8B,MACxCC,GAAcD,EAAgC,MAE9CE,GAAkBF,EAAO5C,GAKzB+C,GAAqBC,GAAmB7B,GAAiB8B,OAAA,OAAA,OAAA,GAAA,YAC3D,GAAKH,GAAgBI,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AACa,EAAc,CAAA,YAAW,SAAQX,SAC7BvC,KAGTqC,EAACe,EAAKC,OAAAC,OAAA,CACFC,KAAK,WACLV,IAAKxC,GACL8C,GAAIrD,GACJ0D,KAAK,OACLpB,MAAOzD,EACP8E,SAAUvB,GACVzE,YAAaA,EACbC,SAAUA,EACVC,SAAUA,EACV+F,YAAU,EACVC,QAAS3B,GAAa,gBACPtC,EAAM,gBACNI,GAAU,oBACP,OAAM,gBACV,UACdkD,OACIrE,EAAMoC,OAASxD,EACTuE,QACAb,EAEV2C,UAAU,+BACQC,EAAUxF,EAAiB6B,KACzC5B,OAmCRwF,eA7BW,IAEfzB,EAAA0B,EAAA,CAAAxB,SACIF,EAAC2B,EAAY,CACTC,UAAWnE,GACXoE,UAAWlF,EACXmF,aAAc7C,GACd8C,UAAWrC,GACXlE,eAAgBA,EAChBC,cAAeA,EACfuG,eAAgBjD,KAChBkD,mBAAoB,MACpBC,aAAc,EACdC,iBAAkB,YAClBC,oBACAC,QAAS,IAAMnE,GAAmB5B,GAClCgG,MAAOvG,EACPwG,mBAAiB,MAarBC,OApKO,MACVvF,GAAoBX,EAAMoC,QAAUxD,GACrCsC,IAAa,EACjB,EAkKQiF,QA/JQ,KAChBnF,IAAU,GACVE,IAAa,GACbiC,IAAc,EA6JNsC,UAtIU,WAClBzE,IAAU,GACVE,IAAa,GACbiC,KACmB,QAAnB3E,EAAAkD,GAAYK,eAAO,IAAAvD,GAAAA,EAAEqE,OAAO,EAmIpBuD,eAAe,EACfC,OAAQ,EACR/G,UAAWA,EACXgH,oBAAkB,EAClBC,aAAchH,EACdiH,SAAUhH,KAEE"}
|
|
1
|
+
{"version":3,"file":"predictive-text-input.js","sources":["../../src/predictive-text-input/predictive-text-input.tsx"],"sourcesContent":["import debounce from \"lodash/debounce\";\nimport type React from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { Input } from \"../input\";\nimport { concatIds, VisuallyHidden } from \"../shared/accessibility\";\nimport { DropdownList, DropdownListState } from \"../shared/dropdown-list\";\nimport type { ItemsLoadStateType } from \"../shared/dropdown-list/types\";\nimport { ElementWithDropdown } from \"../shared/dropdown-wrapper\";\nimport { InputWrapper } from \"../shared/input-wrapper\";\nimport { useId } from \"../util\";\nimport type { PredictiveTextInputProps } from \"./types\";\n\n/**\n * A text input that fetches and displays matching suggestions as the user types.\n *\n * Use `PredictiveTextInput` for search-as-you-type or autocomplete scenarios\n * where options are loaded asynchronously based on the current input.\n */\nexport const PredictiveTextInput = <T, V>({\n className,\n \"data-testid\": testId,\n selectedOption,\n minimumCharacters = 3,\n fetchOptions,\n placeholder = \"Enter here...\",\n readOnly = false,\n disabled = false,\n error,\n valueExtractor,\n listExtractor,\n displayValueExtractor,\n onSelectOption,\n alignment,\n dropdownZIndex,\n dropdownRootNode,\n dropdownWidth,\n \"aria-describedby\": ariaDescribedBy,\n ...otherProps\n}: PredictiveTextInputProps<T, V>): JSX.Element => {\n const getDisplayValue = (item: T | undefined): string => {\n if (!item) return \"\";\n return displayValueExtractor\n ? displayValueExtractor(item)\n : item.toString();\n };\n\n // =============================================================================\n // CONST, STATE\n // =============================================================================\n const [input, setInput] = useState<string>(() =>\n selectedOption ? getDisplayValue(selectedOption) : \"\"\n );\n const [searchedInput, setSearchedInput] = useState<string>(() =>\n selectedOption ? getDisplayValue(selectedOption) : \"\"\n );\n const [options, setOptions] = useState<T[]>([]);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [isError, setIsError] = useState<boolean>(false);\n const [isOptionSelected, setIsOptionSelected] = useState<boolean>(\n !!selectedOption\n );\n const [prevOptionSelected, setPrevOptionSelected] = useState<T | undefined>(\n selectedOption\n );\n const [isOpen, setIsOpen] = useState(false);\n const [isFocused, setIsFocused] = useState(false);\n\n const internalId = useId();\n const [resultAnnouncement, setResultAnnouncement] = useState<string | null>(\n null\n );\n const instructionId = `${internalId}-instruction`;\n\n const nodeRef = useRef<HTMLDivElement | null>(null);\n const selectorRef = useRef<HTMLInputElement | null>(null);\n\n const fetchOptionsRef = useRef(fetchOptions);\n\n // =============================================================================\n // DEBOUNCE FUNCTIONS\n // =============================================================================\n const handleFetchOptions = useCallback(async (input: string) => {\n if (!fetchOptionsRef.current) return;\n setIsError(false);\n setIsLoading(true);\n try {\n const fetchedOptions = await fetchOptionsRef.current(input);\n setSearchedInput(input);\n setOptions(fetchedOptions ?? []);\n setIsLoading(false);\n } catch {\n setIsError(true);\n setIsLoading(false);\n }\n }, []);\n\n const fetchOptionsDebounced = useCallback(\n debounce((input: string) => {\n handleFetchOptions(input);\n }, 500),\n [handleFetchOptions]\n );\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n\n useEffect(() => {\n fetchOptionsRef.current = fetchOptions;\n }, [fetchOptions]);\n\n useEffect(() => {\n /***\n * Should not fetch options for the following the scenario :\n * 1. When input < minimumCharacters\n * 2. When user selected option from dropdown becomes input\n * 3. Initial selectedOption passed in as input\n */\n if (input && input.length >= minimumCharacters) {\n if (!isOptionSelected) {\n setIsOpen(true);\n fetchOptionsDebounced(input);\n } else if (input !== searchedInput) {\n fetchOptionsDebounced(input);\n }\n } else {\n fetchOptionsDebounced.cancel();\n }\n\n if (input === \"\" && prevOptionSelected) {\n onSelectOption?.(undefined, undefined);\n handleDropdownDismiss();\n setPrevOptionSelected(undefined);\n }\n\n if (selectedOption && input !== getDisplayValue(selectedOption)) {\n setIsOptionSelected(false);\n }\n }, [input, selectedOption]);\n\n useEffect(() => {\n setInput(selectedOption ? getDisplayValue(selectedOption) : \"\");\n setSearchedInput(selectedOption ? getDisplayValue(selectedOption) : \"\");\n setPrevOptionSelected(selectedOption);\n setOptions([]);\n setIsOptionSelected(!!selectedOption);\n }, [selectedOption]);\n\n useEffect(() => {\n const state = getItemsLoadState();\n const count = options?.length ?? 0;\n\n if (state === \"loading\" && input.length >= minimumCharacters) {\n setResultAnnouncement(\"Loading suggested results\");\n return;\n }\n\n if (state === \"fail\") {\n setResultAnnouncement(\"Suggestions failed to load. Try again.\");\n return;\n }\n\n if (isOpen && !isLoading && !isError) {\n if (count === 0) {\n setResultAnnouncement(input ? \"No results found.\" : null);\n } else {\n setResultAnnouncement(\n `${count} result${\n count > 1 ? \"s\" : \"\"\n } found. Press down arrow to scroll through the list.`\n );\n }\n }\n }, [options, input, isError, isLoading]);\n\n // =============================================================================\n // Cleanup: cancel debounce on unmount\n // =============================================================================\n useEffect(() => {\n return () => {\n fetchOptionsDebounced.cancel();\n };\n }, [fetchOptionsDebounced]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleListItemClick = (item: T, extractedValue: V) => {\n selectorRef.current?.focus();\n setInput(getDisplayValue(item));\n setSearchedInput(item ? getDisplayValue(item) : \"\");\n setIsOptionSelected(true);\n setPrevOptionSelected(item);\n setIsOpen(false);\n onSelectOption?.(item, extractedValue);\n };\n\n const handleOpen = () => {\n if (!isOptionSelected && input.length >= minimumCharacters) {\n setIsFocused(true);\n }\n };\n\n const handleClose = () => {\n setIsOpen(false);\n setIsFocused(false);\n handleOnBlur();\n };\n\n const handleNodeFocus = () => {\n setIsFocused(true);\n };\n\n const handleNodeBlur = (e: React.FocusEvent) => {\n if (\n !isOpen &&\n nodeRef.current &&\n !nodeRef.current.contains(e.relatedTarget as Node)\n ) {\n setIsFocused(false);\n handleOnBlur();\n }\n };\n\n const handleListDismiss = () => {\n setIsOpen(false);\n setIsFocused(false);\n };\n\n const handleDismiss = () => {\n setIsOpen(false);\n setIsFocused(false);\n handleOnBlur();\n selectorRef.current?.focus();\n };\n\n const handleOnClear = () => {\n setInput(\"\");\n setOptions([]);\n setIsOptionSelected(false);\n setIsOpen(false);\n onSelectOption?.(undefined, undefined);\n };\n\n const handleOnBlur = () => {\n if (!isOptionSelected) {\n if (prevOptionSelected) {\n const prevValue = getDisplayValue(prevOptionSelected);\n setInput(prevValue);\n setIsOpen(false);\n } else {\n handleOnClear();\n }\n }\n };\n\n const handleTyping = (e: React.ChangeEvent<HTMLInputElement>) => {\n setInput(e.target.value);\n setIsOptionSelected(false);\n };\n\n const handleDropdownDismiss = (item?: T) => {\n setSearchedInput(item ? getDisplayValue(item) : \"\");\n setIsOptionSelected(!!item);\n setOptions([]);\n setIsLoading(true);\n };\n\n // =============================================================================\n // HELPER FUNCTION\n // =============================================================================\n const getItemsLoadState = (): ItemsLoadStateType => {\n if (isError) return \"fail\";\n return isLoading ? \"loading\" : \"success\";\n };\n\n // =============================================================================\n // RENDER FUNCTION\n // =============================================================================\n const renderInputElement = () => {\n return (\n <InputWrapper\n className={className}\n data-testid={testId}\n ref={nodeRef}\n tabIndex={-1}\n onFocus={handleNodeFocus}\n onBlur={handleNodeBlur}\n focused={isFocused}\n disabled={disabled}\n readOnly={readOnly}\n error={error}\n >\n <VisuallyHidden id={instructionId} aria-hidden>\n Type in {minimumCharacters} or more characters for suggested\n results.\n </VisuallyHidden>\n {resultAnnouncement && (\n <VisuallyHidden aria-live=\"polite\">\n {resultAnnouncement}\n </VisuallyHidden>\n )}\n <Input\n role=\"combobox\"\n ref={selectorRef}\n id={internalId}\n type=\"text\"\n value={input}\n onChange={handleTyping}\n placeholder={placeholder}\n readOnly={readOnly}\n disabled={disabled}\n allowClear\n onClear={handleOnClear}\n aria-expanded={isOpen}\n aria-controls={internalId}\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n onBlur={\n input.length < minimumCharacters\n ? handleOnBlur\n : undefined\n }\n styleType=\"no-border\"\n aria-describedby={concatIds(ariaDescribedBy, instructionId)}\n {...otherProps}\n />\n </InputWrapper>\n );\n };\n\n const renderDropdown = () => {\n return (\n <>\n <DropdownList\n listboxId={internalId}\n listItems={options}\n onSelectItem={handleListItemClick}\n onDismiss={handleListDismiss}\n valueExtractor={valueExtractor}\n listExtractor={listExtractor}\n itemsLoadState={getItemsLoadState()}\n itemTruncationType={\"end\"}\n itemMaxLines={1}\n labelDisplayType={\"next-line\"}\n disableItemFocus\n onRetry={() => handleFetchOptions(input)}\n width={dropdownWidth}\n matchElementWidth\n />\n </>\n );\n };\n\n return (\n <DropdownListState>\n <ElementWithDropdown\n enabled={!readOnly && !disabled}\n isOpen={isOpen}\n renderElement={renderInputElement}\n renderDropdown={renderDropdown}\n onOpen={handleOpen}\n onClose={handleClose}\n onDismiss={handleDismiss}\n clickToToggle={false}\n offset={8}\n alignment={alignment}\n fitAvailableHeight\n customZIndex={dropdownZIndex}\n rootNode={dropdownRootNode}\n />\n </DropdownListState>\n );\n};\n"],"names":["PredictiveTextInput","_a","className","testId","selectedOption","minimumCharacters","fetchOptions","placeholder","readOnly","disabled","error","valueExtractor","listExtractor","displayValueExtractor","onSelectOption","alignment","dropdownZIndex","dropdownRootNode","dropdownWidth","ariaDescribedBy","otherProps","__rest","getDisplayValue","item","toString","input","setInput","useState","searchedInput","setSearchedInput","options","setOptions","isLoading","setIsLoading","isError","setIsError","isOptionSelected","setIsOptionSelected","prevOptionSelected","setPrevOptionSelected","isOpen","setIsOpen","isFocused","setIsFocused","internalId","useId","resultAnnouncement","setResultAnnouncement","instructionId","nodeRef","useRef","selectorRef","fetchOptionsRef","handleFetchOptions","useCallback","__awaiter","current","fetchedOptions","fetchOptionsDebounced","debounce","useEffect","length","cancel","undefined","handleDropdownDismiss","state","getItemsLoadState","count","handleListItemClick","extractedValue","focus","handleNodeFocus","handleNodeBlur","e","contains","relatedTarget","handleOnBlur","handleListDismiss","handleOnClear","prevValue","handleTyping","target","value","_jsx","DropdownListState","children","ElementWithDropdown","enabled","renderElement","_jsxs","InputWrapper","ref","tabIndex","onFocus","onBlur","focused","VisuallyHidden","id","Input","Object","assign","role","type","onChange","allowClear","onClear","styleType","concatIds","renderDropdown","_Fragment","DropdownList","listboxId","listItems","onSelectItem","onDismiss","itemsLoadState","itemTruncationType","itemMaxLines","labelDisplayType","disableItemFocus","onRetry","width","matchElementWidth","onOpen","onClose","clickToToggle","offset","fitAvailableHeight","customZIndex","rootNode"],"mappings":"mwEAmBO,MAAMA,EAA6BC,QAAAC,UACtCA,EACA,cAAeC,EAAMC,eACrBA,EAAcC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+F,YAAU,EACVC,QAAS3B,GAAa,gBACPtC,EAAM,gBACNI,GAAU,oBACP,OAAM,gBACV,UACdkD,OACIrE,EAAMoC,OAASxD,EACTuE,QACAb,EAEV2C,UAAU,+BACQC,EAAUxF,EAAiB6B,KACzC5B,OAmCRwF,eA7BW,IAEfzB,EAAA0B,EAAA,CAAAxB,SACIF,EAAC2B,EAAY,CACTC,UAAWnE,GACXoE,UAAWlF,EACXmF,aAAc7C,GACd8C,UAAWrC,GACXlE,eAAgBA,EAChBC,cAAeA,EACfuG,eAAgBjD,KAChBkD,mBAAoB,MACpBC,aAAc,EACdC,iBAAkB,YAClBC,oBACAC,QAAS,IAAMnE,GAAmB5B,GAClCgG,MAAOvG,EACPwG,mBAAiB,MAarBC,OApKO,MACVvF,GAAoBX,EAAMoC,QAAUxD,GACrCsC,IAAa,EACjB,EAkKQiF,QA/JQ,KAChBnF,IAAU,GACVE,IAAa,GACbiC,IAAc,EA6JNsC,UAtIU,WAClBzE,IAAU,GACVE,IAAa,GACbiC,KACmB,QAAnB3E,EAAAkD,GAAYK,eAAO,IAAAvD,GAAAA,EAAEqE,OAAO,EAmIpBuD,eAAe,EACfC,OAAQ,EACR/G,UAAWA,EACXgH,oBAAkB,EAClBC,aAAchH,EACdiH,SAAUhH,KAEE"}
|
|
@@ -1,39 +1,93 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
2
|
import type { ListItemDisplayProps } from "../shared/dropdown-list/types";
|
|
3
3
|
import type { DropdownAlignmentType } from "../shared/dropdown-wrapper";
|
|
4
|
+
/**
|
|
5
|
+
* Props for the `PredictiveTextInput` component.
|
|
6
|
+
*
|
|
7
|
+
* `T` is the shape of each option item returned by `fetchOptions`.
|
|
8
|
+
* `V` is the extracted value type produced by `valueExtractor`.
|
|
9
|
+
*/
|
|
4
10
|
export interface PredictiveTextInputProps<T, V> extends React.AriaAttributes {
|
|
5
11
|
id?: string | undefined;
|
|
6
12
|
className?: string | undefined;
|
|
7
13
|
"data-testid"?: string | undefined;
|
|
8
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Minimum number of characters the user must type before `fetchOptions` is
|
|
16
|
+
* called and the dropdown opens.
|
|
17
|
+
*
|
|
18
|
+
* @default 3
|
|
19
|
+
*/
|
|
9
20
|
minimumCharacters?: number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Placeholder text shown inside the input when it is empty.
|
|
23
|
+
*
|
|
24
|
+
* @default "Enter here..."
|
|
25
|
+
*/
|
|
10
26
|
placeholder?: string | undefined;
|
|
11
27
|
readOnly?: boolean | undefined;
|
|
12
28
|
disabled?: boolean | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Applies error styling to the input wrapper.
|
|
31
|
+
*/
|
|
13
32
|
error?: boolean | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* The currently confirmed option. Updating this prop resets the displayed
|
|
35
|
+
* text and clears the dropdown options list. Pass `undefined` to clear the
|
|
36
|
+
* selection.
|
|
37
|
+
*/
|
|
14
38
|
selectedOption?: T | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Horizontal alignment of the dropdown relative to the input element.
|
|
41
|
+
*/
|
|
15
42
|
alignment?: DropdownAlignmentType | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* CSS `z-index` applied to the dropdown overlay.
|
|
45
|
+
*/
|
|
16
46
|
dropdownZIndex?: number | undefined;
|
|
17
47
|
/**
|
|
18
|
-
* The root element that contains the dropdown element.
|
|
48
|
+
* The root element that contains the dropdown element.
|
|
19
49
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
50
|
+
* @remarks Specify this if you need to change the parent of the
|
|
51
|
+
* dropdown in the HTML DOM.
|
|
52
|
+
* Possible use case: sharing a stacking context.
|
|
53
|
+
*
|
|
54
|
+
* Note: if a parent of the trigger has a higher `z-index` than the dropdown,
|
|
55
|
+
* the dropdown may be obscured.
|
|
56
|
+
*
|
|
57
|
+
* @default `document.body`
|
|
22
58
|
*/
|
|
23
59
|
dropdownRootNode?: RefObject<HTMLElement> | undefined;
|
|
24
60
|
/**
|
|
25
|
-
* Custom width for the dropdown. When specified, the dropdown
|
|
26
|
-
* width instead of matching the
|
|
61
|
+
* Custom width for the dropdown. When specified, the dropdown uses this
|
|
62
|
+
* width instead of matching the trigger element width.
|
|
27
63
|
*/
|
|
28
64
|
dropdownWidth?: string | undefined;
|
|
29
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Async function called with the current input string to retrieve matching
|
|
67
|
+
* options. A rejected promise triggers the error state in the
|
|
68
|
+
* dropdown.
|
|
69
|
+
*
|
|
70
|
+
* @param input The current text in the input field.
|
|
71
|
+
*/
|
|
30
72
|
fetchOptions: (input: string) => Promise<T[]>;
|
|
31
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Derives the submitted value `V` from a selected item `T`.
|
|
75
|
+
*/
|
|
32
76
|
valueExtractor?: ((item: T) => V) | undefined;
|
|
33
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Derives the display label for each option in the dropdown list.
|
|
79
|
+
*/
|
|
34
80
|
listExtractor?: ((item: T) => string | ListItemDisplayProps) | undefined;
|
|
35
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Derives the text shown in the input field after an option is selected.
|
|
83
|
+
*/
|
|
36
84
|
displayValueExtractor?: ((option: T) => string) | undefined;
|
|
37
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Called when the user selects an option from the dropdown or clears the
|
|
87
|
+
* field.
|
|
88
|
+
*
|
|
89
|
+
* @param option The selected item, or `undefined` when cleared.
|
|
90
|
+
* @param extractedValue The value produced by `valueExtractor`, or `undefined` when cleared.
|
|
91
|
+
*/
|
|
38
92
|
onSelectOption?: ((option: T | undefined, extractedValue: V | undefined) => void) | undefined;
|
|
39
93
|
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { ProgressIndicatorProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* A horizontal step-progress bar that tracks a user's position through a
|
|
4
|
+
* multi-step flow.
|
|
5
|
+
*
|
|
6
|
+
* Use `ProgressIndicator` when you need to communicate progress through an
|
|
7
|
+
* ordered sequence of steps.
|
|
8
|
+
*/
|
|
2
9
|
export declare const ProgressIndicator: <T>({ steps, currentIndex, displayExtractor, className, ...otherProps }: ProgressIndicatorProps<T>) => import("react/jsx-runtime").JSX.Element | null;
|