@firstnoodle-ui/bui 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/bui.css +1 -0
- package/dist/components/application-wrapper/ApplicationWrapper.vue.d.ts +17 -0
- package/dist/components/application-wrapper/index.d.ts +1 -0
- package/dist/components/aside-section-label/AsideSectionLabel.vue.d.ts +5 -0
- package/dist/components/aside-section-label/index.d.ts +1 -0
- package/dist/components/button/Button.vue.d.ts +52 -0
- package/dist/components/button/NotificationBadge.vue.d.ts +5 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/button-group/ButtonGroup.vue.d.ts +29 -0
- package/dist/components/button-group/index.d.ts +1 -0
- package/dist/components/checkbox/Checkbox.vue.d.ts +18 -0
- package/dist/components/checkbox/CircleIndicator.vue.d.ts +6 -0
- package/dist/components/checkbox/DefaultIndicator.vue.d.ts +6 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/collapse/Collapse.vue.d.ts +50 -0
- package/dist/components/collapse/index.d.ts +1 -0
- package/dist/components/confirm-cancel/ConfirmCancel.vue.d.ts +36 -0
- package/dist/components/confirm-cancel/index.d.ts +1 -0
- package/dist/components/data-point/DataPoint.vue.d.ts +2 -0
- package/dist/components/data-point/index.d.ts +1 -0
- package/dist/components/dialog/Dialog.vue.d.ts +128 -0
- package/dist/components/dialog/index.d.ts +1 -0
- package/dist/components/fade-in-up/FadeInUp.vue.d.ts +21 -0
- package/dist/components/fade-in-up/index.d.ts +1 -0
- package/dist/components/first-paint/FirstPaint.vue.d.ts +20 -0
- package/dist/components/first-paint/index.d.ts +1 -0
- package/dist/components/flexbox/Flexbox.vue.d.ts +31 -0
- package/dist/components/flexbox/index.d.ts +1 -0
- package/dist/components/horizontal-layout/Aside.vue.d.ts +48 -0
- package/dist/components/horizontal-layout/HorizontalLayout.vue.d.ts +48 -0
- package/dist/components/horizontal-layout/index.d.ts +2 -0
- package/dist/components/icon/Icon.vue.d.ts +6 -0
- package/dist/components/icon/index.d.ts +1 -0
- package/dist/components/index.d.ts +38 -0
- package/dist/components/input/Input.vue.d.ts +26 -0
- package/dist/components/input/index.d.ts +1 -0
- package/dist/components/load-spinner/LoadSpinner.vue.d.ts +2 -0
- package/dist/components/load-spinner/index.d.ts +1 -0
- package/dist/components/modal/Modal.vue.d.ts +135 -0
- package/dist/components/modal/index.d.ts +1 -0
- package/dist/components/nav-item/NavItem.vue.d.ts +43 -0
- package/dist/components/nav-item/index.d.ts +1 -0
- package/dist/components/notification/Notification.vue.d.ts +14 -0
- package/dist/components/notification/index.d.ts +1 -0
- package/dist/components/pagination/Pagination.vue.d.ts +13 -0
- package/dist/components/pagination/index.d.ts +1 -0
- package/dist/components/pill/Pill.vue.d.ts +32 -0
- package/dist/components/pill/index.d.ts +2 -0
- package/dist/components/pill/pill-types.d.ts +2 -0
- package/dist/components/pop-confirm/PopConfirm.vue.d.ts +357 -0
- package/dist/components/pop-confirm/index.d.ts +1 -0
- package/dist/components/pop-select/FooterButton.vue.d.ts +2 -0
- package/dist/components/pop-select/PopSelect.vue.d.ts +51 -0
- package/dist/components/pop-select/ResultFilters.vue.d.ts +20 -0
- package/dist/components/pop-select/enums.d.ts +7 -0
- package/dist/components/pop-select/index.d.ts +2 -0
- package/dist/components/pop-select/option.vue.d.ts +39 -0
- package/dist/components/popper/Popper.vue.d.ts +79 -0
- package/dist/components/popper/PopperContent.vue.d.ts +17 -0
- package/dist/components/popper/index.d.ts +2 -0
- package/dist/components/popper/middleware.d.ts +10 -0
- package/dist/components/screen-overlay/ScreenOverlay.vue.d.ts +31 -0
- package/dist/components/screen-overlay/index.d.ts +1 -0
- package/dist/components/scrollbar/Bar.vue.d.ts +19 -0
- package/dist/components/scrollbar/ScrollBottomLoader.vue.d.ts +25 -0
- package/dist/components/scrollbar/Scrollbar.vue.d.ts +62 -0
- package/dist/components/scrollbar/enums.d.ts +3 -0
- package/dist/components/scrollbar/index.d.ts +2 -0
- package/dist/components/scrollbar/scrollbarWidth.d.ts +1 -0
- package/dist/components/scrollbar/types.d.ts +27 -0
- package/dist/components/side-over/SideOver.vue.d.ts +43 -0
- package/dist/components/side-over/index.d.ts +1 -0
- package/dist/components/status-select/StatusSelect.vue.d.ts +2 -0
- package/dist/components/status-select/index.d.ts +1 -0
- package/dist/components/switch/Switch.vue.d.ts +17 -0
- package/dist/components/switch/index.d.ts +1 -0
- package/dist/components/tab/Tab.vue.d.ts +22 -0
- package/dist/components/tab/index.d.ts +1 -0
- package/dist/components/tag/Tag.vue.d.ts +29 -0
- package/dist/components/tag/index.d.ts +1 -0
- package/dist/components/text-editor/TextEditor.vue.d.ts +79 -0
- package/dist/components/text-editor/components/Dialog.vue.d.ts +17 -0
- package/dist/components/text-editor/components/FormattingButton.vue.d.ts +19 -0
- package/dist/components/text-editor/components/InsertLinkDialog.vue.d.ts +57 -0
- package/dist/components/text-editor/components/InsertTextDialog.vue.d.ts +54 -0
- package/dist/components/text-editor/components/index.d.ts +3 -0
- package/dist/components/text-editor/index.d.ts +1 -0
- package/dist/components/text-highlight/TextHighlight.vue.d.ts +16 -0
- package/dist/components/text-highlight/index.d.ts +1 -0
- package/dist/components/text-viewer/TextViewer.vue.d.ts +17 -0
- package/dist/components/text-viewer/index.d.ts +1 -0
- package/dist/components/tooltip/Tooltip.vue.d.ts +42 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/types.d.ts +64 -0
- package/dist/components/vertical-layout/RunningSection.vue.d.ts +31 -0
- package/dist/components/vertical-layout/VerticalLayout.vue.d.ts +32 -0
- package/dist/components/vertical-layout/index.d.ts +3 -0
- package/dist/components/vertical-layout/types.d.ts +2 -0
- package/dist/components/window-frame/WindowFrame.vue.d.ts +21 -0
- package/dist/components/window-frame/index.d.ts +1 -0
- package/dist/composables/index.d.ts +5 -0
- package/dist/composables/useClickOutside.d.ts +5 -0
- package/dist/composables/useEscapeKey.d.ts +1 -0
- package/dist/composables/useMounted.d.ts +3 -0
- package/dist/composables/useNextFrame.d.ts +3 -0
- package/dist/composables/useTrapFocus.d.ts +8 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +20754 -0
- package/dist/utils/array.d.ts +5 -0
- package/dist/utils/clamp.d.ts +1 -0
- package/dist/utils/debounce.d.ts +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/scrollIntoView.d.ts +1 -0
- package/dist/utils/scrollbarWidth.d.ts +1 -0
- package/package.json +65 -0
- package/src/components/application-wrapper/ApplicationWrapper.vue +8 -0
- package/src/components/application-wrapper/index.ts +1 -0
- package/src/components/aside-section-label/AsideSectionLabel.vue +16 -0
- package/src/components/aside-section-label/index.ts +1 -0
- package/src/components/button/Button.vue +245 -0
- package/src/components/button/NotificationBadge.vue +15 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button-group/ButtonGroup.vue +97 -0
- package/src/components/button-group/index.ts +1 -0
- package/src/components/checkbox/Checkbox.vue +52 -0
- package/src/components/checkbox/CircleIndicator.vue +27 -0
- package/src/components/checkbox/DefaultIndicator.vue +22 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/collapse/Collapse.vue +120 -0
- package/src/components/collapse/index.ts +1 -0
- package/src/components/confirm-cancel/ConfirmCancel.vue +79 -0
- package/src/components/confirm-cancel/index.ts +1 -0
- package/src/components/data-point/DataPoint.vue +5 -0
- package/src/components/data-point/index.ts +1 -0
- package/src/components/dialog/Dialog.vue +70 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/fade-in-up/FadeInUp.vue +17 -0
- package/src/components/fade-in-up/index.ts +1 -0
- package/src/components/first-paint/FirstPaint.vue +21 -0
- package/src/components/first-paint/index.ts +1 -0
- package/src/components/first-paint/style.scss +23 -0
- package/src/components/flexbox/Flexbox.vue +50 -0
- package/src/components/flexbox/index.ts +1 -0
- package/src/components/horizontal-layout/Aside.vue +113 -0
- package/src/components/horizontal-layout/HorizontalLayout.vue +118 -0
- package/src/components/horizontal-layout/index.ts +2 -0
- package/src/components/icon/Icon.vue +1159 -0
- package/src/components/icon/index.ts +1 -0
- package/src/components/icon/utils/combine-svgs.cjs +55 -0
- package/src/components/icon/utils/combined-svgs.txt +1150 -0
- package/src/components/icon/utils/svgs/admin.svg +16 -0
- package/src/components/icon/utils/svgs/arrow-deviate.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-down-plus.svg +4 -0
- package/src/components/icon/utils/svgs/arrow-down.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-from.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-left.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-move.svg +15 -0
- package/src/components/icon/utils/svgs/arrow-right.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-sub.svg +3 -0
- package/src/components/icon/utils/svgs/arrow-trend.svg +15 -0
- package/src/components/icon/utils/svgs/arrow-up-plus.svg +4 -0
- package/src/components/icon/utils/svgs/arrow-up.svg +3 -0
- package/src/components/icon/utils/svgs/authority.svg +5 -0
- package/src/components/icon/utils/svgs/beams.svg +5 -0
- package/src/components/icon/utils/svgs/bell.svg +15 -0
- package/src/components/icon/utils/svgs/bold.svg +3 -0
- package/src/components/icon/utils/svgs/box.svg +5 -0
- package/src/components/icon/utils/svgs/building.svg +15 -0
- package/src/components/icon/utils/svgs/bullet-list.svg +8 -0
- package/src/components/icon/utils/svgs/calendar.svg +21 -0
- package/src/components/icon/utils/svgs/camera.svg +5 -0
- package/src/components/icon/utils/svgs/categories.svg +3 -0
- package/src/components/icon/utils/svgs/check-circled.svg +16 -0
- package/src/components/icon/utils/svgs/check-outline.svg +15 -0
- package/src/components/icon/utils/svgs/check.svg +3 -0
- package/src/components/icon/utils/svgs/chevron-down.svg +3 -0
- package/src/components/icon/utils/svgs/chevron-left-double.svg +4 -0
- package/src/components/icon/utils/svgs/chevron-left.svg +3 -0
- package/src/components/icon/utils/svgs/chevron-right-double.svg +4 -0
- package/src/components/icon/utils/svgs/chevron-right.svg +3 -0
- package/src/components/icon/utils/svgs/chevron-up.svg +3 -0
- package/src/components/icon/utils/svgs/clock.svg +4 -0
- package/src/components/icon/utils/svgs/close-outline.svg +3 -0
- package/src/components/icon/utils/svgs/close.svg +3 -0
- package/src/components/icon/utils/svgs/columns.svg +3 -0
- package/src/components/icon/utils/svgs/conclusion.svg +17 -0
- package/src/components/icon/utils/svgs/copy.svg +16 -0
- package/src/components/icon/utils/svgs/crosshair.svg +15 -0
- package/src/components/icon/utils/svgs/dash.svg +3 -0
- package/src/components/icon/utils/svgs/dashboard.svg +3 -0
- package/src/components/icon/utils/svgs/delete.svg +4 -0
- package/src/components/icon/utils/svgs/delta.svg +3 -0
- package/src/components/icon/utils/svgs/download.svg +3 -0
- package/src/components/icon/utils/svgs/drag.svg +8 -0
- package/src/components/icon/utils/svgs/drilldown.svg +8 -0
- package/src/components/icon/utils/svgs/edit.svg +16 -0
- package/src/components/icon/utils/svgs/envelope.svg +3 -0
- package/src/components/icon/utils/svgs/error.svg +3 -0
- package/src/components/icon/utils/svgs/export-document.svg +16 -0
- package/src/components/icon/utils/svgs/filter.svg +6 -0
- package/src/components/icon/utils/svgs/filters.svg +4 -0
- package/src/components/icon/utils/svgs/flag.svg +3 -0
- package/src/components/icon/utils/svgs/folder.svg +15 -0
- package/src/components/icon/utils/svgs/frequency.svg +3 -0
- package/src/components/icon/utils/svgs/fullscreen-off.svg +3 -0
- package/src/components/icon/utils/svgs/fullscreen-on.svg +3 -0
- package/src/components/icon/utils/svgs/graduate.svg +3 -0
- package/src/components/icon/utils/svgs/hamburger.svg +5 -0
- package/src/components/icon/utils/svgs/handshake.svg +15 -0
- package/src/components/icon/utils/svgs/heading-1.svg +4 -0
- package/src/components/icon/utils/svgs/heading-2.svg +4 -0
- package/src/components/icon/utils/svgs/heading.svg +3 -0
- package/src/components/icon/utils/svgs/home.svg +3 -0
- package/src/components/icon/utils/svgs/id-card.svg +6 -0
- package/src/components/icon/utils/svgs/id.svg +4 -0
- package/src/components/icon/utils/svgs/indent-left.svg +7 -0
- package/src/components/icon/utils/svgs/indent-right.svg +7 -0
- package/src/components/icon/utils/svgs/information.svg +17 -0
- package/src/components/icon/utils/svgs/italics.svg +3 -0
- package/src/components/icon/utils/svgs/itenary.svg +11 -0
- package/src/components/icon/utils/svgs/keyboard.svg +11 -0
- package/src/components/icon/utils/svgs/lightning.svg +15 -0
- package/src/components/icon/utils/svgs/link.svg +4 -0
- package/src/components/icon/utils/svgs/list-collapse.svg +6 -0
- package/src/components/icon/utils/svgs/list-expand.svg +6 -0
- package/src/components/icon/utils/svgs/location.svg +4 -0
- package/src/components/icon/utils/svgs/lock-locked.svg +4 -0
- package/src/components/icon/utils/svgs/lock-unlocked.svg +4 -0
- package/src/components/icon/utils/svgs/magnifying-glass.svg +15 -0
- package/src/components/icon/utils/svgs/map.svg +3 -0
- package/src/components/icon/utils/svgs/megaphone.svg +3 -0
- package/src/components/icon/utils/svgs/message.svg +15 -0
- package/src/components/icon/utils/svgs/microscope.svg +3 -0
- package/src/components/icon/utils/svgs/moon.svg +3 -0
- package/src/components/icon/utils/svgs/new-document.svg +4 -0
- package/src/components/icon/utils/svgs/news.svg +15 -0
- package/src/components/icon/utils/svgs/numbered-list.svg +7 -0
- package/src/components/icon/utils/svgs/open-link.svg +16 -0
- package/src/components/icon/utils/svgs/options.svg +5 -0
- package/src/components/icon/utils/svgs/page.svg +7 -0
- package/src/components/icon/utils/svgs/paper-plane.svg +15 -0
- package/src/components/icon/utils/svgs/paper.svg +3 -0
- package/src/components/icon/utils/svgs/pen-and-paper.svg +4 -0
- package/src/components/icon/utils/svgs/phase.svg +15 -0
- package/src/components/icon/utils/svgs/photo.svg +4 -0
- package/src/components/icon/utils/svgs/pie-chart.svg +3 -0
- package/src/components/icon/utils/svgs/plus.svg +3 -0
- package/src/components/icon/utils/svgs/point-left.svg +3 -0
- package/src/components/icon/utils/svgs/point-up.svg +3 -0
- package/src/components/icon/utils/svgs/popup.svg +16 -0
- package/src/components/icon/utils/svgs/question.svg +17 -0
- package/src/components/icon/utils/svgs/radio-tower.svg +3 -0
- package/src/components/icon/utils/svgs/recycle.svg +3 -0
- package/src/components/icon/utils/svgs/redo.svg +3 -0
- package/src/components/icon/utils/svgs/refresh.svg +3 -0
- package/src/components/icon/utils/svgs/route.svg +3 -0
- package/src/components/icon/utils/svgs/rows.svg +3 -0
- package/src/components/icon/utils/svgs/scope.svg +7 -0
- package/src/components/icon/utils/svgs/settings.svg +16 -0
- package/src/components/icon/utils/svgs/share.svg +11 -0
- package/src/components/icon/utils/svgs/sign-in.svg +4 -0
- package/src/components/icon/utils/svgs/sign-up.svg +3 -0
- package/src/components/icon/utils/svgs/sort-down.svg +20 -0
- package/src/components/icon/utils/svgs/sort-up.svg +20 -0
- package/src/components/icon/utils/svgs/sort.svg +7 -0
- package/src/components/icon/utils/svgs/square-solid.svg +3 -0
- package/src/components/icon/utils/svgs/star-solid.svg +15 -0
- package/src/components/icon/utils/svgs/star.svg +15 -0
- package/src/components/icon/utils/svgs/stop-watch.svg +5 -0
- package/src/components/icon/utils/svgs/structure.svg +3 -0
- package/src/components/icon/utils/svgs/sun.svg +23 -0
- package/src/components/icon/utils/svgs/table.svg +3 -0
- package/src/components/icon/utils/svgs/tag.svg +15 -0
- package/src/components/icon/utils/svgs/team.svg +15 -0
- package/src/components/icon/utils/svgs/telescope.svg +15 -0
- package/src/components/icon/utils/svgs/trash.svg +6 -0
- package/src/components/icon/utils/svgs/triangle-angle.svg +3 -0
- package/src/components/icon/utils/svgs/triangle-side.svg +3 -0
- package/src/components/icon/utils/svgs/underline.svg +4 -0
- package/src/components/icon/utils/svgs/undo.svg +3 -0
- package/src/components/icon/utils/svgs/user.svg +16 -0
- package/src/components/icon/utils/svgs/venn.svg +3 -0
- package/src/components/icon/utils/svgs/video.svg +3 -0
- package/src/components/icon/utils/svgs/visibility-off-alt.svg +19 -0
- package/src/components/icon/utils/svgs/visibility-off.svg +3 -0
- package/src/components/icon/utils/svgs/visibility-on.svg +16 -0
- package/src/components/icon/utils/svgs/warning.svg +5 -0
- package/src/components/index.ts +38 -0
- package/src/components/input/Input.vue +87 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/load-spinner/LoadSpinner.vue +13 -0
- package/src/components/load-spinner/index.ts +1 -0
- package/src/components/modal/Modal.vue +111 -0
- package/src/components/modal/index.ts +1 -0
- package/src/components/nav-item/NavItem.vue +62 -0
- package/src/components/nav-item/index.ts +1 -0
- package/src/components/notification/Notification.vue +34 -0
- package/src/components/notification/index.ts +1 -0
- package/src/components/pagination/Pagination.vue +72 -0
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pill/Pill.vue +52 -0
- package/src/components/pill/index.ts +2 -0
- package/src/components/pill/pill-types.ts +2 -0
- package/src/components/pop-confirm/PopConfirm.vue +69 -0
- package/src/components/pop-confirm/index.ts +1 -0
- package/src/components/pop-select/FooterButton.vue +5 -0
- package/src/components/pop-select/PopSelect.vue +346 -0
- package/src/components/pop-select/ResultFilters.vue +31 -0
- package/src/components/pop-select/enums.ts +7 -0
- package/src/components/pop-select/index.ts +2 -0
- package/src/components/pop-select/option.vue +51 -0
- package/src/components/popper/Popper.vue +239 -0
- package/src/components/popper/PopperContent.vue +5 -0
- package/src/components/popper/index.ts +2 -0
- package/src/components/popper/middleware.ts +19 -0
- package/src/components/screen-overlay/ScreenOverlay.vue +53 -0
- package/src/components/screen-overlay/index.ts +1 -0
- package/src/components/scrollbar/Bar.vue +106 -0
- package/src/components/scrollbar/ScrollBottomLoader.vue +25 -0
- package/src/components/scrollbar/Scrollbar.vue +220 -0
- package/src/components/scrollbar/enums.ts +23 -0
- package/src/components/scrollbar/index.ts +2 -0
- package/src/components/scrollbar/scrollbarWidth.ts +26 -0
- package/src/components/scrollbar/style.scss +75 -0
- package/src/components/scrollbar/types.ts +32 -0
- package/src/components/side-over/SideOver.vue +87 -0
- package/src/components/side-over/index.ts +1 -0
- package/src/components/status-select/StatusIndicator.vue +78 -0
- package/src/components/status-select/StatusSelect.vue +62 -0
- package/src/components/status-select/index.ts +1 -0
- package/src/components/switch/Switch.vue +52 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/tab/Tab.vue +59 -0
- package/src/components/tab/index.ts +1 -0
- package/src/components/tag/Tag.vue +34 -0
- package/src/components/tag/index.ts +1 -0
- package/src/components/text-editor/TextEditor.vue +399 -0
- package/src/components/text-editor/components/Dialog.vue +11 -0
- package/src/components/text-editor/components/FormattingButton.vue +46 -0
- package/src/components/text-editor/components/InsertLinkDialog.vue +81 -0
- package/src/components/text-editor/components/InsertTextDialog.vue +36 -0
- package/src/components/text-editor/components/index.ts +3 -0
- package/src/components/text-editor/index.ts +1 -0
- package/src/components/text-highlight/TextHighlight.vue +113 -0
- package/src/components/text-highlight/index.ts +1 -0
- package/src/components/text-viewer/TextViewer.vue +5 -0
- package/src/components/text-viewer/index.ts +1 -0
- package/src/components/tooltip/Tooltip.vue +54 -0
- package/src/components/tooltip/index.ts +1 -0
- package/src/components/types.ts +221 -0
- package/src/components/vertical-layout/RunningSection.vue +54 -0
- package/src/components/vertical-layout/VerticalLayout.vue +37 -0
- package/src/components/vertical-layout/index.ts +3 -0
- package/src/components/vertical-layout/types.ts +2 -0
- package/src/components/window-frame/WindowFrame.vue +20 -0
- package/src/components/window-frame/index.ts +1 -0
- package/src/composables/index.ts +5 -0
- package/src/composables/useClickOutside.ts +48 -0
- package/src/composables/useEscapeKey.ts +12 -0
- package/src/composables/useMounted.ts +7 -0
- package/src/composables/useNextFrame.ts +10 -0
- package/src/composables/useTrapFocus.ts +61 -0
- package/src/index.ts +5 -0
- package/src/main.css +116 -0
- package/src/utils/array.ts +11 -0
- package/src/utils/clamp.ts +1 -0
- package/src/utils/debounce.ts +8 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/scrollIntoView.ts +25 -0
- package/src/utils/scrollbarWidth.ts +27 -0
- package/tsconfig.app.json +4 -0
- package/tsconfig.json +11 -0
- package/tsconfig.node.json +21 -0
- package/vite.config.ts +27 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Placement } from "@floating-ui/dom";
|
|
3
|
+
import type { TPopperTrigger } from "../types";
|
|
4
|
+
import { autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
5
|
+
import debounce from "debounce";
|
|
6
|
+
import { nextTick, onMounted, onUnmounted, ref, useSlots, watch } from "vue";
|
|
7
|
+
import { useClickOutside, useMounted } from "../../composables";
|
|
8
|
+
import { sameWidthAsElementMiddleware, sameWidthAsTriggerMiddleware } from "./middleware";
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(
|
|
11
|
+
defineProps<{
|
|
12
|
+
closeDelay?: number;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
offsetMain?: number;
|
|
15
|
+
offsetCross?: number;
|
|
16
|
+
openDelay?: number;
|
|
17
|
+
placement?: Placement;
|
|
18
|
+
popperWidthClass?: string;
|
|
19
|
+
rootClass?: string | string[];
|
|
20
|
+
sameWidthAsElement?: HTMLElement;
|
|
21
|
+
sameWidthAsTrigger?: boolean;
|
|
22
|
+
show?: boolean;
|
|
23
|
+
trigger?: TPopperTrigger;
|
|
24
|
+
triggerClass?: string | string[];
|
|
25
|
+
useOverlay?: boolean;
|
|
26
|
+
}>(),
|
|
27
|
+
{
|
|
28
|
+
closeDelay: 20,
|
|
29
|
+
disabled: false,
|
|
30
|
+
offsetMain: 0,
|
|
31
|
+
offsetCross: 0,
|
|
32
|
+
openDelay: 0,
|
|
33
|
+
placement: "bottom-start",
|
|
34
|
+
rootClass: "inline-flex",
|
|
35
|
+
sameWidthAsTrigger: false,
|
|
36
|
+
show: false,
|
|
37
|
+
trigger: "hover",
|
|
38
|
+
triggerClass: "flex",
|
|
39
|
+
useOverlay: false,
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const emit = defineEmits(["open", "close", "updateClickOutside"]);
|
|
44
|
+
const slots = useSlots();
|
|
45
|
+
|
|
46
|
+
// eslint-disable-next-line ts/no-unsafe-function-type
|
|
47
|
+
let cleanup: Function | null;
|
|
48
|
+
|
|
49
|
+
const containerRef = ref<HTMLDivElement>();
|
|
50
|
+
const popperRef = ref<HTMLDivElement>();
|
|
51
|
+
const triggerRef = ref<HTMLDivElement>();
|
|
52
|
+
const isOpen = ref(false);
|
|
53
|
+
|
|
54
|
+
const { mounted } = useMounted();
|
|
55
|
+
// eslint-disable-next-line ts/no-use-before-define
|
|
56
|
+
const { disableClickOutside, enableClickOutside, updateClickOutside } = useClickOutside(() => closePopper());
|
|
57
|
+
|
|
58
|
+
const update = async () => {
|
|
59
|
+
if (triggerRef.value && popperRef.value) {
|
|
60
|
+
const middleware = [
|
|
61
|
+
offset({
|
|
62
|
+
mainAxis: props.offsetMain,
|
|
63
|
+
crossAxis: props.offsetCross,
|
|
64
|
+
}),
|
|
65
|
+
flip(),
|
|
66
|
+
shift(),
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
if (!props.popperWidthClass) {
|
|
70
|
+
if (props.sameWidthAsTrigger) {
|
|
71
|
+
middleware.push(sameWidthAsTriggerMiddleware);
|
|
72
|
+
}
|
|
73
|
+
else if (props.sameWidthAsElement) {
|
|
74
|
+
middleware.push(sameWidthAsElementMiddleware(props.sameWidthAsElement));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const position = await computePosition(triggerRef.value, popperRef.value, {
|
|
79
|
+
placement: props.placement as Placement,
|
|
80
|
+
middleware,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
popperRef.value.style.left = `${position.x}px`;
|
|
84
|
+
popperRef.value.style.top = `${position.y}px`;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
onMounted(() => {
|
|
89
|
+
const children = slots.default && slots.default({ visible: isOpen.value });
|
|
90
|
+
|
|
91
|
+
if (children && children.length > 1) {
|
|
92
|
+
return console.error(`[Popper]: The <Popper> component expects only one child element at its root. You passed ${children.length} child nodes.`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!props.popperWidthClass) {
|
|
96
|
+
if (props.sameWidthAsElement && props.sameWidthAsTrigger) {
|
|
97
|
+
console.warn(`[Popper]: The 'sameWidthAsElement' prop will be ignored because 'sameWidthAsTrigger' is set to true`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (props.sameWidthAsElement || props.sameWidthAsTrigger) {
|
|
101
|
+
console.warn(`[Popper]: The props 'sameWidthAsElement' or 'sameWidthAsTrigger' will be ignored because the 'popperWidthClass' is set`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (props.trigger === "manual" && props.show) {
|
|
105
|
+
// eslint-disable-next-line ts/no-use-before-define
|
|
106
|
+
openPopperDebounce();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
onUnmounted(() => {
|
|
111
|
+
// the openDelay might be triggered after the component is onUnmounted
|
|
112
|
+
// eslint-disable-next-line ts/no-use-before-define
|
|
113
|
+
openPopperDebounce.clear();
|
|
114
|
+
|
|
115
|
+
if (cleanup) {
|
|
116
|
+
cleanup();
|
|
117
|
+
cleanup = null;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const close = () => {
|
|
122
|
+
if (!isOpen.value) return;
|
|
123
|
+
isOpen.value = false;
|
|
124
|
+
emit("close");
|
|
125
|
+
|
|
126
|
+
!props.useOverlay && disableClickOutside();
|
|
127
|
+
|
|
128
|
+
if (cleanup) {
|
|
129
|
+
cleanup();
|
|
130
|
+
cleanup = null;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const open = async () => {
|
|
135
|
+
if (isOpen.value) return;
|
|
136
|
+
isOpen.value = true;
|
|
137
|
+
|
|
138
|
+
await nextTick();
|
|
139
|
+
emit("open", [triggerRef.value, popperRef.value]);
|
|
140
|
+
cleanup = autoUpdate(triggerRef.value as HTMLElement, popperRef.value as HTMLElement, update);
|
|
141
|
+
|
|
142
|
+
!props.useOverlay && popperRef.value && triggerRef.value && enableClickOutside([popperRef.value, triggerRef.value]);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const openPopperDebounce = debounce(open, props.openDelay);
|
|
146
|
+
const closePopperDebounce = debounce(close, props.closeDelay);
|
|
147
|
+
|
|
148
|
+
const openPopper = async () => {
|
|
149
|
+
if (props.disabled) return;
|
|
150
|
+
closePopperDebounce.clear();
|
|
151
|
+
openPopperDebounce();
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const closePopper = async () => {
|
|
155
|
+
openPopperDebounce.clear();
|
|
156
|
+
closePopperDebounce();
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const onClick = (e: MouseEvent) => {
|
|
160
|
+
if (props.trigger === "click") {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
e.stopPropagation();
|
|
163
|
+
// eslint-disable-next-line ts/no-use-before-define
|
|
164
|
+
togglePopper();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const updateClickOutsideTargets = (targets: HTMLElement[]) => {
|
|
169
|
+
if (popperRef.value && triggerRef.value) {
|
|
170
|
+
updateClickOutside([popperRef.value, triggerRef.value, ...targets]);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const togglePopper = () => (isOpen.value ? closePopper() : openPopper());
|
|
175
|
+
|
|
176
|
+
/** If Popper is open, we automatically close it if if becomes disabled */
|
|
177
|
+
watch(
|
|
178
|
+
() => props.disabled,
|
|
179
|
+
(newValue: boolean) => isOpen.value && newValue && close(),
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
/** If trigger is manual, we open/close popper when prop.show changes */
|
|
183
|
+
watch(
|
|
184
|
+
() => props.show,
|
|
185
|
+
(newValue: boolean) => {
|
|
186
|
+
if (props.trigger === "manual") {
|
|
187
|
+
newValue ? openPopperDebounce() : closePopperDebounce();
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
console.warn(`[Popper]: The 'show' prop is only available when the 'trigger' prop is set to 'manual'`);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
defineExpose({
|
|
196
|
+
close,
|
|
197
|
+
containerRef,
|
|
198
|
+
open,
|
|
199
|
+
updateClickOutsideTargets,
|
|
200
|
+
});
|
|
201
|
+
</script>
|
|
202
|
+
|
|
203
|
+
<template>
|
|
204
|
+
<div ref="containerRef" :class="rootClass" @mouseleave="trigger === 'hover' && closePopper()">
|
|
205
|
+
<div
|
|
206
|
+
ref="triggerRef"
|
|
207
|
+
:class="triggerClass"
|
|
208
|
+
@mouseover="trigger === 'hover' && openPopper()"
|
|
209
|
+
@click="onClick"
|
|
210
|
+
@focus="trigger === 'focus' && openPopper()"
|
|
211
|
+
@keyup.esc="closePopper()"
|
|
212
|
+
>
|
|
213
|
+
<slot :visible="isOpen" />
|
|
214
|
+
</div>
|
|
215
|
+
<Teleport v-if="mounted" to="#poppers">
|
|
216
|
+
<template v-if="!disabled && isOpen">
|
|
217
|
+
<div
|
|
218
|
+
v-if="useOverlay && trigger !== 'hover' && trigger !== 'manual'"
|
|
219
|
+
class="pointer-events-auto absolute w-screen h-screen top-0 left-0 bg-transparent"
|
|
220
|
+
@click="closePopper()"
|
|
221
|
+
>
|
|
222
|
+
<div v-show="!disabled && isOpen" ref="popperRef" class="absolute" :class="popperWidthClass">
|
|
223
|
+
<slot name="content" :close="close" :is-open="isOpen" />
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
<div
|
|
227
|
+
v-else
|
|
228
|
+
ref="popperRef"
|
|
229
|
+
class="absolute"
|
|
230
|
+
:class="popperWidthClass"
|
|
231
|
+
@mouseover="trigger === 'hover' && openPopper()"
|
|
232
|
+
@mouseleave="trigger === 'hover' && closePopper()"
|
|
233
|
+
>
|
|
234
|
+
<slot name="content" :close="close" :is-open="isOpen" />
|
|
235
|
+
</div>
|
|
236
|
+
</template>
|
|
237
|
+
</Teleport>
|
|
238
|
+
</div>
|
|
239
|
+
</template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { size } from "@floating-ui/dom";
|
|
2
|
+
|
|
3
|
+
export const sameWidthAsTriggerMiddleware = size({
|
|
4
|
+
apply({ rects, elements }) {
|
|
5
|
+
Object.assign(elements.floating.style, {
|
|
6
|
+
width: `${rects.reference.width}px`,
|
|
7
|
+
});
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const sameWidthAsElementMiddleware = (element: HTMLElement) => {
|
|
12
|
+
return size({
|
|
13
|
+
apply({ elements }) {
|
|
14
|
+
Object.assign(elements.floating.style, {
|
|
15
|
+
width: `${element.offsetWidth}px`,
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { TOverlayType } from "../types";
|
|
3
|
+
import { onBeforeMount, reactive, ref } from "vue";
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(
|
|
6
|
+
defineProps<{
|
|
7
|
+
show?: boolean;
|
|
8
|
+
type?: TOverlayType;
|
|
9
|
+
}>(),
|
|
10
|
+
{
|
|
11
|
+
show: false,
|
|
12
|
+
type: "default",
|
|
13
|
+
},
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const emit = defineEmits(["click", "close"]);
|
|
17
|
+
|
|
18
|
+
const classes = ref("");
|
|
19
|
+
const styles = reactive({ backdropFilter: "" });
|
|
20
|
+
|
|
21
|
+
onBeforeMount(() => {
|
|
22
|
+
if (props.type === "default") {
|
|
23
|
+
classes.value = "bg-black/25 dark:bg-black/50";
|
|
24
|
+
styles.backdropFilter = "";
|
|
25
|
+
}
|
|
26
|
+
else if (props.type === "blurred") {
|
|
27
|
+
classes.value = "bg-black/25";
|
|
28
|
+
styles.backdropFilter = "blur(3px)";
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<transition
|
|
35
|
+
enter-active-class="transform transition ease-in-out duration-200"
|
|
36
|
+
enter-from-class="opacity-0"
|
|
37
|
+
enter-to-class=""
|
|
38
|
+
leave-active-class="transform transition ease-in-out duration-500"
|
|
39
|
+
leave-class="translate-y-0 opacity-100"
|
|
40
|
+
leave-to-class="opacity-0"
|
|
41
|
+
@after-leave="emit('close')"
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
v-show="show"
|
|
45
|
+
class="z-40 fixed w-screen h-screen top-0 left-0 flex items-start justify-center pointer-events-auto"
|
|
46
|
+
:class="classes"
|
|
47
|
+
:style="styles"
|
|
48
|
+
@mousedown.self="emit('click')"
|
|
49
|
+
>
|
|
50
|
+
<slot />
|
|
51
|
+
</div>
|
|
52
|
+
</transition>
|
|
53
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BScreenOverlay } from "./ScreenOverlay.vue";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ThumbDragEvent } from "./types";
|
|
3
|
+
import { ref } from "vue";
|
|
4
|
+
import { horizontalProperties, verticalProperties } from "./enums";
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
vertical: Boolean,
|
|
8
|
+
size: String,
|
|
9
|
+
move: Number,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const emit = defineEmits(["update"]);
|
|
13
|
+
|
|
14
|
+
const scrollbarRef = ref<HTMLDivElement>();
|
|
15
|
+
const thumbRef = ref<HTMLDivElement>();
|
|
16
|
+
const dragging = ref(false);
|
|
17
|
+
const bar = props.vertical ? verticalProperties : horizontalProperties;
|
|
18
|
+
const position = ref(0);
|
|
19
|
+
|
|
20
|
+
const onDocumentMouseMove = (event: MouseEvent) => {
|
|
21
|
+
if (!dragging.value) return;
|
|
22
|
+
|
|
23
|
+
const prevPage = position.value;
|
|
24
|
+
if (!prevPage) return;
|
|
25
|
+
|
|
26
|
+
const rect = scrollbarRef.value!.getBoundingClientRect();
|
|
27
|
+
if (rect) {
|
|
28
|
+
const offset = ((rect[bar.direction as keyof DOMRect] as number || 0) - (event[bar.client as keyof MouseEvent] as number || 0)) * -1;
|
|
29
|
+
const thumbClickPosition = thumbRef.value && typeof thumbRef.value[bar.offset as keyof HTMLDivElement] === "number"
|
|
30
|
+
? (thumbRef.value[bar.offset as keyof HTMLDivElement] as number) - prevPage
|
|
31
|
+
: 0;
|
|
32
|
+
const scrollbarOffset = scrollbarRef.value ? Number(scrollbarRef.value[bar.offset as keyof HTMLDivElement]) : 0;
|
|
33
|
+
const thumbPositionPercentage = scrollbarOffset ? ((offset - thumbClickPosition) * 100) / scrollbarOffset : 0;
|
|
34
|
+
|
|
35
|
+
emit("update", {
|
|
36
|
+
scrollReference: bar.scroll,
|
|
37
|
+
positionPercentage: thumbPositionPercentage,
|
|
38
|
+
scrollSize: bar.scrollSize,
|
|
39
|
+
} as unknown as ThumbDragEvent);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const onDocumentMouseUp = () => {
|
|
44
|
+
dragging.value = false;
|
|
45
|
+
position.value = 0;
|
|
46
|
+
document.removeEventListener("mousemove", onDocumentMouseMove);
|
|
47
|
+
document.onselectstart = null;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const startDrag = (event: MouseEvent) => {
|
|
51
|
+
event.stopImmediatePropagation();
|
|
52
|
+
dragging.value = true;
|
|
53
|
+
document.addEventListener("mousemove", onDocumentMouseMove);
|
|
54
|
+
document.addEventListener("mouseup", onDocumentMouseUp);
|
|
55
|
+
document.onselectstart = () => false;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const onThumbClick = (event: MouseEvent) => {
|
|
59
|
+
// prevent click event of right button
|
|
60
|
+
if (event.ctrlKey || event.button === 2) return;
|
|
61
|
+
startDrag(event);
|
|
62
|
+
|
|
63
|
+
if (event.currentTarget) {
|
|
64
|
+
|
|
65
|
+
const offset: number = (event.currentTarget as HTMLDivElement)[bar.offset as keyof HTMLDivElement] as number;
|
|
66
|
+
const axis: number = event[bar.client as keyof MouseEvent] as number;
|
|
67
|
+
const rect: DOMRect = (event.currentTarget as HTMLDivElement).getBoundingClientRect();
|
|
68
|
+
const side = rect[bar.direction as keyof DOMRect] as unknown as number;
|
|
69
|
+
position.value = offset - (axis - side);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const onTrackClick = (event: MouseEvent) => {
|
|
74
|
+
const rect = (event.target as HTMLDivElement).getBoundingClientRect();
|
|
75
|
+
if (rect) {
|
|
76
|
+
const rectDirection = rect[bar.direction as keyof DOMRect];
|
|
77
|
+
const eventClient = event[bar.client as keyof MouseEvent];
|
|
78
|
+
const offset = Math.abs((rectDirection ? Number(rectDirection) : 0) - (eventClient ? Number(eventClient) : 0));
|
|
79
|
+
const thumbHalf = thumbRef.value![bar.offset as keyof HTMLDivElement] as number / 2;
|
|
80
|
+
const scrollbarOffset = scrollbarRef.value ? Number(scrollbarRef.value[bar.offset as keyof HTMLDivElement]) : 0;
|
|
81
|
+
const thumbPositionPercentage = scrollbarOffset ? ((offset - thumbHalf) * 100) / scrollbarOffset : 0;
|
|
82
|
+
|
|
83
|
+
emit("update", {
|
|
84
|
+
scrollReference: bar.scroll,
|
|
85
|
+
positionPercentage: thumbPositionPercentage,
|
|
86
|
+
scrollSize: bar.scrollSize,
|
|
87
|
+
} as unknown as ThumbDragEvent);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const renderThumbStyle = () => {
|
|
92
|
+
const translate = `translate${bar.axis}(${props.move}%)`;
|
|
93
|
+
return {
|
|
94
|
+
[bar.size]: props.size,
|
|
95
|
+
transform: translate,
|
|
96
|
+
msTransform: translate,
|
|
97
|
+
webkitTransform: translate,
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<template>
|
|
103
|
+
<div ref="scrollbarRef" :class="`scrollbar__bar is-${bar.key}`" @click.stop.prevent @mousedown.stop.prevent="onTrackClick">
|
|
104
|
+
<div ref="thumbRef" :style="renderThumbStyle()" class="scrollbar__thumb" @click.stop.prevent @mousedown.stop.prevent="onThumbClick" />
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onMounted, onUnmounted, ref } from "vue";
|
|
3
|
+
import { BLoadSpinner } from "../";
|
|
4
|
+
|
|
5
|
+
const emit = defineEmits(["intersect"]);
|
|
6
|
+
const triggerRef = ref<HTMLDivElement>();
|
|
7
|
+
const observer = ref<IntersectionObserver | null>(null);
|
|
8
|
+
|
|
9
|
+
onMounted(() => {
|
|
10
|
+
observer.value = new IntersectionObserver(
|
|
11
|
+
([e]) => e.isIntersecting && emit("intersect"),
|
|
12
|
+
{ threshold: 0.01 },
|
|
13
|
+
);
|
|
14
|
+
observer.value.observe(triggerRef.value!);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
onUnmounted(() => observer.value && observer.value.disconnect());
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div ref="triggerRef" class="w-full h-16 flex items-center justify-center bg-white">
|
|
22
|
+
<slot v-if="$slots.default" />
|
|
23
|
+
<BLoadSpinner v-else class="w-6 h-6 text-granite-grey" />
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ScrollIntersectionEvent, ScrollTrigger, ThumbDragEvent } from "./types";
|
|
3
|
+
import { nextTick, onBeforeUnmount, onMounted, reactive, ref } from "vue";
|
|
4
|
+
import Bar from "./Bar.vue";
|
|
5
|
+
import { scrollbarWidth } from "./scrollbarWidth.ts";
|
|
6
|
+
import "./style.scss";
|
|
7
|
+
|
|
8
|
+
const props = withDefaults(
|
|
9
|
+
defineProps<{
|
|
10
|
+
disableX?: boolean;
|
|
11
|
+
disableY?: boolean;
|
|
12
|
+
wrapClass?: string;
|
|
13
|
+
viewClass?: string;
|
|
14
|
+
viewHeightClass?: string;
|
|
15
|
+
noresize?: boolean;
|
|
16
|
+
show?: boolean;
|
|
17
|
+
tag?: string;
|
|
18
|
+
triggers?: ScrollTrigger[];
|
|
19
|
+
windowResize?: boolean;
|
|
20
|
+
}>(),
|
|
21
|
+
{
|
|
22
|
+
disableX: false,
|
|
23
|
+
disableY: false,
|
|
24
|
+
wrapClass: "",
|
|
25
|
+
viewClass: "h-full",
|
|
26
|
+
viewHeightClass: "h-full",
|
|
27
|
+
noresize: false,
|
|
28
|
+
show: false,
|
|
29
|
+
tag: "div",
|
|
30
|
+
windowResize: false,
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits<{
|
|
35
|
+
intersect: [ScrollIntersectionEvent];
|
|
36
|
+
scroll: [value: number];
|
|
37
|
+
scrollXActive: [value: boolean];
|
|
38
|
+
scrollYActive: [value: boolean];
|
|
39
|
+
}>();
|
|
40
|
+
|
|
41
|
+
let mutationObserver: MutationObserver;
|
|
42
|
+
|
|
43
|
+
const gutterWidth = ref(scrollbarWidth());
|
|
44
|
+
const moveX = ref(0);
|
|
45
|
+
const moveY = ref(0);
|
|
46
|
+
const previousY = ref(0);
|
|
47
|
+
const sizeHeight = ref("0");
|
|
48
|
+
const sizeWidth = ref("0");
|
|
49
|
+
const wrapStyle = reactive({
|
|
50
|
+
marginRight: "",
|
|
51
|
+
marginBottom: "",
|
|
52
|
+
});
|
|
53
|
+
const cachedSizePercentages = { height: 100, width: 100 };
|
|
54
|
+
|
|
55
|
+
const wrapClasses = ["scrollbar__wrap"];
|
|
56
|
+
!gutterWidth.value && wrapClasses.push("scrollbar__wrap--hidden-default");
|
|
57
|
+
props.wrapClass && wrapClasses.push(props.wrapClass);
|
|
58
|
+
|
|
59
|
+
const wrapRef = ref();
|
|
60
|
+
const contentRef = ref();
|
|
61
|
+
|
|
62
|
+
const onScroll = () => {
|
|
63
|
+
moveY.value = (wrapRef.value.scrollTop * 100) / wrapRef.value.clientHeight;
|
|
64
|
+
moveX.value = (wrapRef.value.scrollLeft * 100) / wrapRef.value.clientWidth;
|
|
65
|
+
emit("scroll", wrapRef.value.scrollTop);
|
|
66
|
+
|
|
67
|
+
const thumbBottomY = wrapRef.value.scrollTop + wrapRef.value.clientHeight;
|
|
68
|
+
const scrollBottom = wrapRef.value.scrollHeight;
|
|
69
|
+
|
|
70
|
+
if (previousY.value > 0 && wrapRef.value.scrollTop === 0) {
|
|
71
|
+
emit("intersect", { edge: "top", hit: true });
|
|
72
|
+
}
|
|
73
|
+
else if (previousY.value === 0 && wrapRef.value.scrollTop > 0) {
|
|
74
|
+
emit("intersect", { edge: "top", hit: false });
|
|
75
|
+
}
|
|
76
|
+
else if (previousY.value + wrapRef.value.clientHeight < scrollBottom && thumbBottomY === scrollBottom) {
|
|
77
|
+
emit("intersect", { edge: "bottom", hit: true });
|
|
78
|
+
}
|
|
79
|
+
else if (previousY.value + wrapRef.value.clientHeight === scrollBottom && thumbBottomY < scrollBottom) {
|
|
80
|
+
emit("intersect", { edge: "bottom", hit: false });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (props.triggers) {
|
|
84
|
+
for (const trigger of props.triggers) {
|
|
85
|
+
if (previousY.value < trigger.px && wrapRef.value.scrollTop >= trigger.px) {
|
|
86
|
+
trigger.callback(trigger, "down");
|
|
87
|
+
}
|
|
88
|
+
else if (previousY.value > trigger.px && wrapRef.value.scrollTop <= trigger.px) {
|
|
89
|
+
trigger.callback(trigger, "up");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
previousY.value = wrapRef.value.scrollTop;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const updateSizePercentages = () => {
|
|
98
|
+
return {
|
|
99
|
+
heightPercentage: (wrapRef.value.clientHeight * 100) / wrapRef.value.scrollHeight,
|
|
100
|
+
widthPercentage: (wrapRef.value.clientWidth * 100) / wrapRef.value.scrollWidth,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const update = async () => {
|
|
105
|
+
if (!wrapRef.value) return;
|
|
106
|
+
|
|
107
|
+
await nextTick();
|
|
108
|
+
|
|
109
|
+
const { heightPercentage, widthPercentage } = updateSizePercentages();
|
|
110
|
+
|
|
111
|
+
if (!heightPercentage && !widthPercentage) return;
|
|
112
|
+
|
|
113
|
+
if (!props.disableX) {
|
|
114
|
+
if (cachedSizePercentages.width === 100 && widthPercentage < 100) {
|
|
115
|
+
emit("scrollXActive", true);
|
|
116
|
+
}
|
|
117
|
+
else if (widthPercentage === 100 && cachedSizePercentages.width < 100) {
|
|
118
|
+
emit("scrollXActive", false);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (widthPercentage === 100) {
|
|
122
|
+
wrapStyle.marginBottom = `0px`;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
if (gutterWidth.value) {
|
|
126
|
+
wrapStyle.marginBottom = `-${gutterWidth.value}px`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
cachedSizePercentages.width = widthPercentage;
|
|
130
|
+
sizeWidth.value = widthPercentage < 100 ? `${widthPercentage}%` : "";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (!props.disableY) {
|
|
134
|
+
if (cachedSizePercentages.height === 100 && heightPercentage < 100) {
|
|
135
|
+
emit("scrollYActive", true);
|
|
136
|
+
}
|
|
137
|
+
else if (heightPercentage === 100 && cachedSizePercentages.height < 100) {
|
|
138
|
+
emit("scrollYActive", false);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (heightPercentage === 100) {
|
|
142
|
+
wrapStyle.marginRight = `0px`;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
if (gutterWidth.value) {
|
|
146
|
+
wrapStyle.marginRight = `-${gutterWidth.value}px`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
cachedSizePercentages.height = heightPercentage;
|
|
150
|
+
sizeHeight.value = heightPercentage < 100 ? `${heightPercentage}%` : "";
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
onScroll();
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
onMounted(async () => {
|
|
157
|
+
await nextTick(update);
|
|
158
|
+
|
|
159
|
+
if (cachedSizePercentages.height === 100) {
|
|
160
|
+
emit("intersect", { edge: "top", hit: true });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
props.windowResize && window.addEventListener("resize", update);
|
|
164
|
+
if (!props.noresize) {
|
|
165
|
+
mutationObserver = new MutationObserver(update);
|
|
166
|
+
mutationObserver.observe(contentRef.value, {
|
|
167
|
+
childList: true,
|
|
168
|
+
subtree: true,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
onBeforeUnmount(() => {
|
|
174
|
+
!props.noresize && mutationObserver.disconnect();
|
|
175
|
+
props.windowResize && window.removeEventListener("resize", update);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const onBarUpdate = (event: ThumbDragEvent) => {
|
|
179
|
+
wrapRef.value[event.scrollReference] = (event.positionPercentage * wrapRef.value[event.scrollSize]) / 100;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const scrollToPercentage = (axis: "x" | "y", percentage: number) => {
|
|
183
|
+
if (axis === "x") {
|
|
184
|
+
wrapRef.value.scrollTo({ left: (wrapRef.value.scrollWidth * percentage) / 100, behavior: "smooth" });
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
wrapRef.value.scrollTo({ top: (wrapRef.value.scrollHeight * percentage) / 100, behavior: "smooth" });
|
|
188
|
+
}
|
|
189
|
+
onScroll();
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const jumpToPercentage = (axis: "x" | "y", percentage: number) => {
|
|
193
|
+
if (axis === "x") {
|
|
194
|
+
wrapRef.value.scrollLeft = (wrapRef.value.scrollWidth * percentage) / 100;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
wrapRef.value.scrollTop = (wrapRef.value.scrollHeight * percentage) / 100;
|
|
198
|
+
}
|
|
199
|
+
onScroll();
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const reset = () => {
|
|
203
|
+
wrapRef.value.scrollTop = 0;
|
|
204
|
+
onScroll();
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
defineExpose({ handleScroll: onScroll, reset, jumpToPercentage, scrollToPercentage, update });
|
|
208
|
+
</script>
|
|
209
|
+
|
|
210
|
+
<template>
|
|
211
|
+
<main class="scrollbar" :class="[viewHeightClass, { show }]">
|
|
212
|
+
<div id="wrapRef" ref="wrapRef" :class="[wrapClasses]" :style="wrapStyle" @scroll="onScroll">
|
|
213
|
+
<component :is="props.tag" ref="contentRef" class="scrollbar__view" :class="[viewClass]">
|
|
214
|
+
<slot />
|
|
215
|
+
</component>
|
|
216
|
+
</div>
|
|
217
|
+
<Bar v-if="!disableX" :move="moveX" :size="sizeWidth" @update="onBarUpdate" />
|
|
218
|
+
<Bar v-if="!disableY" :move="moveY" :size="sizeHeight" vertical @update="onBarUpdate" />
|
|
219
|
+
</main>
|
|
220
|
+
</template>
|