@firstnoodle-ui/bui 0.0.28 → 0.0.32
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/dist/bui.css +1 -1
- package/dist/components/horizontal-layout/Aside.vue.d.ts +2 -6
- package/dist/components/index.d.ts +1 -0
- package/dist/components/modal/Modal.vue.d.ts +9 -3
- package/dist/components/tree-list/InputNode.vue.d.ts +90 -0
- package/dist/components/tree-list/TreeList.vue.d.ts +27 -0
- package/dist/components/tree-list/index.d.ts +2 -0
- package/dist/components/tree-list/types.d.ts +14 -0
- package/dist/index.mjs +6598 -6369
- package/package.json +22 -11
- package/src/components/application-wrapper/ApplicationWrapper.vue +0 -8
- package/src/components/application-wrapper/index.ts +0 -1
- package/src/components/aside-section-label/AsideSectionLabel.vue +0 -16
- package/src/components/aside-section-label/index.ts +0 -1
- package/src/components/button/Button.vue +0 -246
- package/src/components/button/NotificationBadge.vue +0 -15
- package/src/components/button/components/button-label/ButtonLabel.vue +0 -9
- package/src/components/button/components/button-label/index.ts +0 -1
- package/src/components/button/components/index.ts +0 -3
- package/src/components/button/components/left-group/LeftGroup.vue +0 -5
- package/src/components/button/components/left-group/index.ts +0 -1
- package/src/components/button/components/notification-badge/NotificationBadge.vue +0 -17
- package/src/components/button/components/notification-badge/index.ts +0 -1
- package/src/components/button/index.ts +0 -1
- package/src/components/button-group/ButtonGroup.vue +0 -97
- package/src/components/button-group/index.ts +0 -1
- package/src/components/calendar-view/CalendarView.vue +0 -106
- package/src/components/calendar-view/components/DateButton.vue +0 -23
- package/src/components/calendar-view/components/DecadeView.vue +0 -50
- package/src/components/calendar-view/components/MonthView.vue +0 -72
- package/src/components/calendar-view/components/NavButton.vue +0 -16
- package/src/components/calendar-view/components/YearView.vue +0 -52
- package/src/components/calendar-view/composables/useCalendar.ts +0 -138
- package/src/components/calendar-view/index.ts +0 -1
- package/src/components/calendar-view/utils/enums.ts +0 -31
- package/src/components/calendar-view/utils/index.ts +0 -240
- package/src/components/calendar-view/utils/types.ts +0 -13
- package/src/components/calendar-view/utils/utils/calendar.ts +0 -70
- package/src/components/calendar-view/utils/utils/date.ts +0 -130
- package/src/components/calendar-view/utils/utils/format.ts +0 -61
- package/src/components/calendar-view/utils/utils/time.ts +0 -70
- package/src/components/checkbox/Checkbox.vue +0 -51
- package/src/components/checkbox/CircleIndicator.vue +0 -26
- package/src/components/checkbox/DefaultIndicator.vue +0 -19
- package/src/components/checkbox/index.ts +0 -1
- package/src/components/collapse/Collapse.vue +0 -114
- package/src/components/collapse/index.ts +0 -1
- package/src/components/confirm-cancel/ConfirmCancel.vue +0 -66
- package/src/components/confirm-cancel/index.ts +0 -1
- package/src/components/confirm-cancel/types.ts +0 -18
- package/src/components/content-slider/ContentSlider.vue +0 -79
- package/src/components/content-slider/index.ts +0 -1
- package/src/components/data-point/DataPoint.vue +0 -5
- package/src/components/data-point/index.ts +0 -1
- package/src/components/delete-button/DeleteButton.vue +0 -19
- package/src/components/delete-button/index.ts +0 -1
- package/src/components/dialog/Dialog.vue +0 -70
- package/src/components/dialog/index.ts +0 -1
- package/src/components/fade-in-up/FadeInUp.vue +0 -17
- package/src/components/fade-in-up/index.ts +0 -1
- package/src/components/filter-chip/FilterChip.vue +0 -28
- package/src/components/filter-chip/index.ts +0 -1
- package/src/components/first-paint/FirstPaint.vue +0 -21
- package/src/components/first-paint/index.ts +0 -1
- package/src/components/first-paint/style.scss +0 -23
- package/src/components/flexbox/Flexbox.vue +0 -51
- package/src/components/flexbox/index.ts +0 -1
- package/src/components/horizontal-layout/Aside.vue +0 -114
- package/src/components/horizontal-layout/HorizontalLayout.vue +0 -118
- package/src/components/horizontal-layout/index.ts +0 -2
- package/src/components/icon/Icon.vue +0 -1263
- package/src/components/icon/index.ts +0 -1
- package/src/components/icon/utils/combine-svgs.cjs +0 -55
- package/src/components/icon/utils/combined-svgs.txt +0 -1150
- package/src/components/icon/utils/svgs/admin.svg +0 -16
- package/src/components/icon/utils/svgs/arrow-deviate.svg +0 -3
- package/src/components/icon/utils/svgs/arrow-down-plus.svg +0 -4
- package/src/components/icon/utils/svgs/arrow-down.svg +0 -3
- package/src/components/icon/utils/svgs/arrow-from.svg +0 -3
- package/src/components/icon/utils/svgs/arrow-left.svg +0 -3
- package/src/components/icon/utils/svgs/arrow-move.svg +0 -15
- package/src/components/icon/utils/svgs/arrow-right.svg +0 -3
- package/src/components/icon/utils/svgs/arrow-sub.svg +0 -3
- package/src/components/icon/utils/svgs/arrow-trend.svg +0 -15
- package/src/components/icon/utils/svgs/arrow-up-plus.svg +0 -4
- package/src/components/icon/utils/svgs/arrow-up.svg +0 -3
- package/src/components/icon/utils/svgs/authority.svg +0 -5
- package/src/components/icon/utils/svgs/beams.svg +0 -5
- package/src/components/icon/utils/svgs/bell.svg +0 -15
- package/src/components/icon/utils/svgs/bold.svg +0 -3
- package/src/components/icon/utils/svgs/box.svg +0 -5
- package/src/components/icon/utils/svgs/building.svg +0 -15
- package/src/components/icon/utils/svgs/bullet-list.svg +0 -8
- package/src/components/icon/utils/svgs/calendar.svg +0 -21
- package/src/components/icon/utils/svgs/camera.svg +0 -5
- package/src/components/icon/utils/svgs/categories.svg +0 -3
- package/src/components/icon/utils/svgs/check-circled.svg +0 -16
- package/src/components/icon/utils/svgs/check-outline.svg +0 -15
- package/src/components/icon/utils/svgs/check.svg +0 -3
- package/src/components/icon/utils/svgs/chevron-down.svg +0 -3
- package/src/components/icon/utils/svgs/chevron-left-double.svg +0 -4
- package/src/components/icon/utils/svgs/chevron-left.svg +0 -3
- package/src/components/icon/utils/svgs/chevron-right-double.svg +0 -4
- package/src/components/icon/utils/svgs/chevron-right.svg +0 -3
- package/src/components/icon/utils/svgs/chevron-up.svg +0 -3
- package/src/components/icon/utils/svgs/clock.svg +0 -4
- package/src/components/icon/utils/svgs/close-outline.svg +0 -3
- package/src/components/icon/utils/svgs/close.svg +0 -3
- package/src/components/icon/utils/svgs/columns.svg +0 -3
- package/src/components/icon/utils/svgs/conclusion.svg +0 -17
- package/src/components/icon/utils/svgs/copy.svg +0 -16
- package/src/components/icon/utils/svgs/crosshair.svg +0 -15
- package/src/components/icon/utils/svgs/dash.svg +0 -3
- package/src/components/icon/utils/svgs/dashboard.svg +0 -3
- package/src/components/icon/utils/svgs/delete.svg +0 -4
- package/src/components/icon/utils/svgs/delta.svg +0 -3
- package/src/components/icon/utils/svgs/download.svg +0 -3
- package/src/components/icon/utils/svgs/drag.svg +0 -8
- package/src/components/icon/utils/svgs/drilldown.svg +0 -8
- package/src/components/icon/utils/svgs/edit.svg +0 -16
- package/src/components/icon/utils/svgs/envelope.svg +0 -3
- package/src/components/icon/utils/svgs/error.svg +0 -3
- package/src/components/icon/utils/svgs/export-document.svg +0 -16
- package/src/components/icon/utils/svgs/filter.svg +0 -6
- package/src/components/icon/utils/svgs/filters.svg +0 -4
- package/src/components/icon/utils/svgs/flag.svg +0 -3
- package/src/components/icon/utils/svgs/folder.svg +0 -15
- package/src/components/icon/utils/svgs/frequency.svg +0 -3
- package/src/components/icon/utils/svgs/fullscreen-off.svg +0 -3
- package/src/components/icon/utils/svgs/fullscreen-on.svg +0 -3
- package/src/components/icon/utils/svgs/graduate.svg +0 -3
- package/src/components/icon/utils/svgs/hamburger.svg +0 -5
- package/src/components/icon/utils/svgs/handshake.svg +0 -15
- package/src/components/icon/utils/svgs/heading-1.svg +0 -4
- package/src/components/icon/utils/svgs/heading-2.svg +0 -4
- package/src/components/icon/utils/svgs/heading.svg +0 -3
- package/src/components/icon/utils/svgs/home.svg +0 -3
- package/src/components/icon/utils/svgs/id-card.svg +0 -6
- package/src/components/icon/utils/svgs/id.svg +0 -4
- package/src/components/icon/utils/svgs/indent-left.svg +0 -7
- package/src/components/icon/utils/svgs/indent-right.svg +0 -7
- package/src/components/icon/utils/svgs/information.svg +0 -17
- package/src/components/icon/utils/svgs/italics.svg +0 -3
- package/src/components/icon/utils/svgs/itenary.svg +0 -11
- package/src/components/icon/utils/svgs/keyboard.svg +0 -11
- package/src/components/icon/utils/svgs/lightning.svg +0 -15
- package/src/components/icon/utils/svgs/link.svg +0 -4
- package/src/components/icon/utils/svgs/list-collapse.svg +0 -6
- package/src/components/icon/utils/svgs/list-expand.svg +0 -6
- package/src/components/icon/utils/svgs/location.svg +0 -4
- package/src/components/icon/utils/svgs/lock-locked.svg +0 -4
- package/src/components/icon/utils/svgs/lock-unlocked.svg +0 -4
- package/src/components/icon/utils/svgs/magnifying-glass.svg +0 -15
- package/src/components/icon/utils/svgs/map.svg +0 -3
- package/src/components/icon/utils/svgs/megaphone.svg +0 -3
- package/src/components/icon/utils/svgs/message.svg +0 -15
- package/src/components/icon/utils/svgs/microscope.svg +0 -3
- package/src/components/icon/utils/svgs/moon.svg +0 -3
- package/src/components/icon/utils/svgs/new-document.svg +0 -4
- package/src/components/icon/utils/svgs/news.svg +0 -15
- package/src/components/icon/utils/svgs/numbered-list.svg +0 -7
- package/src/components/icon/utils/svgs/open-link.svg +0 -16
- package/src/components/icon/utils/svgs/options.svg +0 -5
- package/src/components/icon/utils/svgs/page.svg +0 -7
- package/src/components/icon/utils/svgs/paper-plane.svg +0 -15
- package/src/components/icon/utils/svgs/paper.svg +0 -3
- package/src/components/icon/utils/svgs/pen-and-paper.svg +0 -4
- package/src/components/icon/utils/svgs/phase.svg +0 -15
- package/src/components/icon/utils/svgs/photo.svg +0 -4
- package/src/components/icon/utils/svgs/pie-chart.svg +0 -3
- package/src/components/icon/utils/svgs/plus.svg +0 -3
- package/src/components/icon/utils/svgs/point-left.svg +0 -3
- package/src/components/icon/utils/svgs/point-up.svg +0 -3
- package/src/components/icon/utils/svgs/popup.svg +0 -16
- package/src/components/icon/utils/svgs/question.svg +0 -17
- package/src/components/icon/utils/svgs/radio-tower.svg +0 -3
- package/src/components/icon/utils/svgs/recycle.svg +0 -3
- package/src/components/icon/utils/svgs/redo.svg +0 -3
- package/src/components/icon/utils/svgs/refresh.svg +0 -3
- package/src/components/icon/utils/svgs/route.svg +0 -3
- package/src/components/icon/utils/svgs/rows.svg +0 -3
- package/src/components/icon/utils/svgs/scope.svg +0 -7
- package/src/components/icon/utils/svgs/settings.svg +0 -16
- package/src/components/icon/utils/svgs/share.svg +0 -11
- package/src/components/icon/utils/svgs/sign-in.svg +0 -4
- package/src/components/icon/utils/svgs/sign-up.svg +0 -3
- package/src/components/icon/utils/svgs/sort-down.svg +0 -20
- package/src/components/icon/utils/svgs/sort-up.svg +0 -20
- package/src/components/icon/utils/svgs/sort.svg +0 -7
- package/src/components/icon/utils/svgs/square-solid.svg +0 -3
- package/src/components/icon/utils/svgs/star-solid.svg +0 -15
- package/src/components/icon/utils/svgs/star.svg +0 -15
- package/src/components/icon/utils/svgs/stop-watch.svg +0 -5
- package/src/components/icon/utils/svgs/structure.svg +0 -3
- package/src/components/icon/utils/svgs/sun.svg +0 -23
- package/src/components/icon/utils/svgs/table.svg +0 -3
- package/src/components/icon/utils/svgs/tag.svg +0 -15
- package/src/components/icon/utils/svgs/team.svg +0 -15
- package/src/components/icon/utils/svgs/telescope.svg +0 -15
- package/src/components/icon/utils/svgs/trash.svg +0 -6
- package/src/components/icon/utils/svgs/triangle-angle.svg +0 -3
- package/src/components/icon/utils/svgs/triangle-side.svg +0 -3
- package/src/components/icon/utils/svgs/underline.svg +0 -4
- package/src/components/icon/utils/svgs/undo.svg +0 -3
- package/src/components/icon/utils/svgs/user.svg +0 -16
- package/src/components/icon/utils/svgs/venn.svg +0 -3
- package/src/components/icon/utils/svgs/video.svg +0 -3
- package/src/components/icon/utils/svgs/visibility-off-alt.svg +0 -19
- package/src/components/icon/utils/svgs/visibility-off.svg +0 -3
- package/src/components/icon/utils/svgs/visibility-on.svg +0 -16
- package/src/components/icon/utils/svgs/warning.svg +0 -5
- package/src/components/index.ts +0 -45
- package/src/components/input/Input.vue +0 -118
- package/src/components/input/index.ts +0 -1
- package/src/components/input-number/InputNumber.vue +0 -112
- package/src/components/input-number/StepButton.vue +0 -23
- package/src/components/input-number/index.ts +0 -1
- package/src/components/load-spinner/LoadSpinner.vue +0 -13
- package/src/components/load-spinner/index.ts +0 -1
- package/src/components/modal/Modal.vue +0 -111
- package/src/components/modal/index.ts +0 -1
- package/src/components/nav-item/NavItem.vue +0 -62
- package/src/components/nav-item/index.ts +0 -1
- package/src/components/notification/Notification.vue +0 -53
- package/src/components/notification/index.ts +0 -1
- package/src/components/notification-badge/NotificationBadge.vue +0 -7
- package/src/components/notification-badge/index.ts +0 -1
- package/src/components/pagination/Pagination.vue +0 -65
- package/src/components/pagination/index.ts +0 -1
- package/src/components/pop-confirm/PopConfirm.vue +0 -90
- package/src/components/pop-confirm/index.ts +0 -1
- package/src/components/pop-select/FooterButton.vue +0 -5
- package/src/components/pop-select/PopSelect.vue +0 -346
- package/src/components/pop-select/ResultFilters.vue +0 -28
- package/src/components/pop-select/enums.ts +0 -7
- package/src/components/pop-select/index.ts +0 -2
- package/src/components/pop-select/option.vue +0 -51
- package/src/components/popper/Popper.vue +0 -239
- package/src/components/popper/PopperContent.vue +0 -5
- package/src/components/popper/index.ts +0 -2
- package/src/components/popper/middleware.ts +0 -19
- package/src/components/screen-overlay/ScreenOverlay.vue +0 -53
- package/src/components/screen-overlay/index.ts +0 -1
- package/src/components/scrollbar/Bar.vue +0 -106
- package/src/components/scrollbar/ScrollBottomLoader.vue +0 -25
- package/src/components/scrollbar/Scrollbar.vue +0 -219
- package/src/components/scrollbar/enums.ts +0 -23
- package/src/components/scrollbar/index.ts +0 -3
- package/src/components/scrollbar/style.scss +0 -77
- package/src/components/scrollbar/types.ts +0 -32
- package/src/components/select-list/SelectList.vue +0 -476
- package/src/components/select-list/components/SelectListFilterChip.vue +0 -34
- package/src/components/select-list/components/index.ts +0 -3
- package/src/components/select-list/components/option-group/OptionGroup.vue +0 -20
- package/src/components/select-list/components/option-group/index.ts +0 -1
- package/src/components/select-list/components/select-list-option/SelectListOption.vue +0 -83
- package/src/components/select-list/components/select-list-option/index.ts +0 -1
- package/src/components/select-list/components/status-cards/error-card/ErrorCard.vue +0 -17
- package/src/components/select-list/components/status-cards/error-card/index.ts +0 -1
- package/src/components/select-list/components/status-cards/idle-card/IdleCard.vue +0 -11
- package/src/components/select-list/components/status-cards/idle-card/index.ts +0 -1
- package/src/components/select-list/components/status-cards/index.ts +0 -4
- package/src/components/select-list/components/status-cards/loading-card/LoadingCard.vue +0 -10
- package/src/components/select-list/components/status-cards/loading-card/index.ts +0 -1
- package/src/components/select-list/components/status-cards/no-match-card/NoMatchCard.vue +0 -15
- package/src/components/select-list/components/status-cards/no-match-card/index.ts +0 -1
- package/src/components/select-list/components/status-cards/status-card/StatusCard.vue +0 -25
- package/src/components/select-list/components/status-cards/status-card/index.ts +0 -1
- package/src/components/select-list/index.ts +0 -5
- package/src/components/select-list/types.ts +0 -49
- package/src/components/side-over/SideOver.vue +0 -87
- package/src/components/side-over/index.ts +0 -1
- package/src/components/status-select/StatusIndicator.vue +0 -78
- package/src/components/status-select/StatusSelect.vue +0 -62
- package/src/components/status-select/index.ts +0 -1
- package/src/components/switch/Switch.vue +0 -52
- package/src/components/switch/index.ts +0 -1
- package/src/components/tab/Tab.vue +0 -65
- package/src/components/tab/index.ts +0 -1
- package/src/components/tag/Tag.vue +0 -34
- package/src/components/tag/index.ts +0 -1
- package/src/components/text-editor/TextEditor.vue +0 -399
- package/src/components/text-editor/components/Dialog.vue +0 -11
- package/src/components/text-editor/components/FormattingButton.vue +0 -46
- package/src/components/text-editor/components/InsertLinkDialog.vue +0 -81
- package/src/components/text-editor/components/InsertTextDialog.vue +0 -36
- package/src/components/text-editor/components/index.ts +0 -3
- package/src/components/text-editor/index.ts +0 -1
- package/src/components/text-highlight/TextHighlight.vue +0 -113
- package/src/components/text-highlight/index.ts +0 -1
- package/src/components/text-viewer/TextViewer.vue +0 -5
- package/src/components/text-viewer/index.ts +0 -1
- package/src/components/toggle-button/ToggleButton.vue +0 -105
- package/src/components/toggle-button/index.ts +0 -1
- package/src/components/tooltip/Tooltip.vue +0 -54
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/types.ts +0 -232
- package/src/components/vertical-layout/RunningSection.vue +0 -54
- package/src/components/vertical-layout/VerticalLayout.vue +0 -37
- package/src/components/vertical-layout/index.ts +0 -3
- package/src/components/vertical-layout/types.ts +0 -2
- package/src/components/window-frame/WindowFrame.vue +0 -20
- package/src/components/window-frame/index.ts +0 -1
- package/src/composables/index.ts +0 -5
- package/src/composables/useClickOutside.ts +0 -48
- package/src/composables/useEscapeKey.ts +0 -12
- package/src/composables/useMounted.ts +0 -7
- package/src/composables/useNextFrame.ts +0 -10
- package/src/composables/useTrapFocus.ts +0 -61
- package/src/index.ts +0 -5
- package/src/main.css +0 -140
- package/src/utils/array.ts +0 -11
- package/src/utils/capitalizeFirstLetter.ts +0 -4
- package/src/utils/clamp.ts +0 -9
- package/src/utils/debounce.ts +0 -8
- package/src/utils/index.ts +0 -5
- package/src/utils/scrollIntoView.ts +0 -25
- package/src/utils/scrollbarWidth.ts +0 -27
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts" generic="T extends TPopSelectOption">
|
|
2
|
-
import type { Placement } from "@floating-ui/dom";
|
|
3
|
-
import type { TIcon, TPopSelectOption, TPopSelectResultFilter } from "../types";
|
|
4
|
-
import { computed, nextTick, onBeforeMount, ref, useSlots, watch } from "vue";
|
|
5
|
-
import { BIcon, BLoadSpinner, BPopper, BPopperContent, BScrollbar, BTextHighlight } from "../";
|
|
6
|
-
import { useNextFrame } from "../../composables";
|
|
7
|
-
import { debounce, scrollIntoView } from "../../utils";
|
|
8
|
-
import { State } from "./enums.ts";
|
|
9
|
-
import PopSelectOption from "./option.vue";
|
|
10
|
-
import ResultFilters from "./ResultFilters.vue";
|
|
11
|
-
|
|
12
|
-
const props = withDefaults(
|
|
13
|
-
defineProps<{
|
|
14
|
-
resetOnClose?: boolean;
|
|
15
|
-
debounceMs?: number;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
emptyStateIcon?: TIcon;
|
|
18
|
-
emptyStateText?: string;
|
|
19
|
-
filterable?: boolean;
|
|
20
|
-
fixedHeight?: boolean;
|
|
21
|
-
keepOpen?: boolean;
|
|
22
|
-
loading?: boolean;
|
|
23
|
-
loadingText?: string;
|
|
24
|
-
options: T[];
|
|
25
|
-
placeholder?: string;
|
|
26
|
-
placement?: Placement;
|
|
27
|
-
popperWidthClass?: string;
|
|
28
|
-
// eslint-disable-next-line ts/no-unsafe-function-type
|
|
29
|
-
remoteMethod?: Function | null;
|
|
30
|
-
resultFilters?: TPopSelectResultFilter<T>[];
|
|
31
|
-
rootClass?: string;
|
|
32
|
-
sameWidthAsElement?: HTMLElement;
|
|
33
|
-
sameWidthAsTrigger?: boolean;
|
|
34
|
-
selected?: TPopSelectOption | TPopSelectOption[];
|
|
35
|
-
triggerClass?: string;
|
|
36
|
-
}>(),
|
|
37
|
-
{
|
|
38
|
-
resetOnClose: false,
|
|
39
|
-
debounceMs: 300,
|
|
40
|
-
disabled: false,
|
|
41
|
-
emptyStateIcon: "keyboard",
|
|
42
|
-
emptyStateText: "Type to search",
|
|
43
|
-
filterable: false,
|
|
44
|
-
fixedHeight: false,
|
|
45
|
-
keepOpen: false,
|
|
46
|
-
loading: false,
|
|
47
|
-
loadingText: "Loading...",
|
|
48
|
-
placeholder: "Search",
|
|
49
|
-
placement: "bottom-start",
|
|
50
|
-
remoteMethod: null,
|
|
51
|
-
sameWidthAsTrigger: false,
|
|
52
|
-
},
|
|
53
|
-
);
|
|
54
|
-
const emit = defineEmits(["close", "save-custom", "select"]);
|
|
55
|
-
const slots = useSlots() as ReturnType<typeof useSlots>;
|
|
56
|
-
|
|
57
|
-
const hoveredOption = ref<TPopSelectOption | null>(null);
|
|
58
|
-
const localOptions = ref<TPopSelectOption[]>([]);
|
|
59
|
-
const currentQuery = ref("");
|
|
60
|
-
|
|
61
|
-
const contentRef = ref<typeof BPopperContent>();
|
|
62
|
-
const errorRef = ref<HTMLElement>();
|
|
63
|
-
const inputRef = ref<HTMLInputElement>();
|
|
64
|
-
const optionsRef = ref();
|
|
65
|
-
const popperRef = ref<typeof BPopper>();
|
|
66
|
-
const scrollbarRef = ref<typeof BScrollbar>();
|
|
67
|
-
|
|
68
|
-
const localResultFilters = ref<TPopSelectResultFilter<T>[]>(props.resultFilters || []);
|
|
69
|
-
const selectedResultFilter = ref<TPopSelectResultFilter<T> | null>(props.resultFilters ? props.resultFilters[0] : null);
|
|
70
|
-
|
|
71
|
-
const { nextFrame } = useNextFrame();
|
|
72
|
-
|
|
73
|
-
const selectedOptions = computed(() => {
|
|
74
|
-
if (!props.selected) return [];
|
|
75
|
-
return Array.isArray(props.selected) ? props.selected : [props.selected];
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const allOptionsDisabled = computed(() => {
|
|
79
|
-
return localOptions.value.every((option: TPopSelectOption) => option.disabled as boolean);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const emptyState = computed(() => {
|
|
83
|
-
return !currentQuery.value.length && !localOptions.value.length;
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const noSearchResults = computed(() => {
|
|
87
|
-
return currentQuery.value.length && !localOptions.value.length;
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const state = computed(() => {
|
|
91
|
-
if (errorRef.value) return State.ERROR;
|
|
92
|
-
if (props.loading) return State.LOADING;
|
|
93
|
-
if (noSearchResults.value && !props.loading) return State.NO_MATCH;
|
|
94
|
-
if (emptyState.value && !props.loading) return State.IDLE;
|
|
95
|
-
if (localOptions.value.length && !props.loading) return State.MATCH;
|
|
96
|
-
return undefined;
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const updateLocalOptions = (options: T[]) => {
|
|
100
|
-
localOptions.value = selectedResultFilter.value ? options.filter(selectedResultFilter.value.execute) : options;
|
|
101
|
-
|
|
102
|
-
// update counts
|
|
103
|
-
if (props.resultFilters) {
|
|
104
|
-
localResultFilters.value.forEach((filter) => {
|
|
105
|
-
filter.count = options.filter(filter.execute).length;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
watch(
|
|
111
|
-
() => props.options,
|
|
112
|
-
(newValue: T[]) => {
|
|
113
|
-
updateLocalOptions(newValue);
|
|
114
|
-
hoveredOption.value = null;
|
|
115
|
-
},
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
onBeforeMount(() => {
|
|
119
|
-
if (props.filterable && props.remoteMethod) {
|
|
120
|
-
console.warn("[PopSelect] should not have both \"filterable\" and \"remoteMethod\" props at the same time");
|
|
121
|
-
}
|
|
122
|
-
updateLocalOptions(props.options);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// triggers onClose event when popper is closed
|
|
126
|
-
const close = () => popperRef.value!.close();
|
|
127
|
-
const focus = () => popperRef.value!.open();
|
|
128
|
-
|
|
129
|
-
const onOpen = async () => {
|
|
130
|
-
nextFrame(() => {
|
|
131
|
-
if (scrollbarRef.value) {
|
|
132
|
-
nextFrame(() => scrollbarRef.value!.update());
|
|
133
|
-
}
|
|
134
|
-
if (inputRef.value) {
|
|
135
|
-
nextFrame(() => inputRef.value!.focus());
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const onClose = () => {
|
|
141
|
-
if (props.keepOpen) return;
|
|
142
|
-
|
|
143
|
-
hoveredOption.value = null;
|
|
144
|
-
|
|
145
|
-
if (props.resetOnClose) {
|
|
146
|
-
currentQuery.value = "";
|
|
147
|
-
props.remoteMethod ? props.remoteMethod("") : updateLocalOptions([]);
|
|
148
|
-
selectedResultFilter.value = props.resultFilters ? props.resultFilters[0] : null;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
emit("close");
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const onSelect = (option: TPopSelectOption) => {
|
|
155
|
-
emit("select", option);
|
|
156
|
-
if (!props.keepOpen) close();
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const filterOptions = (query: string) => (localOptions.value = props.options.filter(o => o.label.toLowerCase().includes(query.toLowerCase())));
|
|
160
|
-
|
|
161
|
-
const onQuery = async (event: Event) => {
|
|
162
|
-
const query = (event.target as HTMLInputElement).value;
|
|
163
|
-
|
|
164
|
-
hoveredOption.value = null;
|
|
165
|
-
|
|
166
|
-
if (props.filterable) {
|
|
167
|
-
filterOptions(query);
|
|
168
|
-
}
|
|
169
|
-
else if (props.remoteMethod) {
|
|
170
|
-
await props.remoteMethod(query);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const debounceOnQuery = debounce(onQuery, props.debounceMs);
|
|
175
|
-
|
|
176
|
-
const onOptionHover = (label: string) => {
|
|
177
|
-
hoveredOption.value = localOptions.value.find(o => o.label === label) || null;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const scrollToOption = (option: TPopSelectOption) => {
|
|
181
|
-
if (!optionsRef.value.length) return;
|
|
182
|
-
|
|
183
|
-
const target = optionsRef.value[localOptions.value.findIndex(o => o.label === option.label)].$el;
|
|
184
|
-
|
|
185
|
-
if (scrollbarRef.value && target) {
|
|
186
|
-
const menu: HTMLElement | null = scrollbarRef.value.$el.querySelector(".scrollbar__wrap");
|
|
187
|
-
if (menu) {
|
|
188
|
-
scrollIntoView(menu, target);
|
|
189
|
-
scrollbarRef.value.handleScroll();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
const navigateOptions = async (direction: "next" | "prev") => {
|
|
195
|
-
if (localOptions.value.length === 0) return;
|
|
196
|
-
|
|
197
|
-
let hoverIndex = localOptions.value.findIndex(o => o.label === hoveredOption.value?.label);
|
|
198
|
-
|
|
199
|
-
if (!allOptionsDisabled.value) {
|
|
200
|
-
if (direction === "next") {
|
|
201
|
-
hoverIndex++;
|
|
202
|
-
if (hoverIndex === localOptions.value.length) {
|
|
203
|
-
hoverIndex = 0;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
else if (direction === "prev") {
|
|
207
|
-
hoverIndex--;
|
|
208
|
-
if (hoverIndex < 0) {
|
|
209
|
-
hoverIndex = localOptions.value.length - 1;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
hoveredOption.value = localOptions.value[hoverIndex];
|
|
213
|
-
|
|
214
|
-
if (hoveredOption.value.disabled === true) {
|
|
215
|
-
navigateOptions(direction);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
await nextTick();
|
|
219
|
-
|
|
220
|
-
if (hoveredOption.value) {
|
|
221
|
-
scrollToOption(hoveredOption.value);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
const selectOption = () => {
|
|
227
|
-
if (hoveredOption.value) {
|
|
228
|
-
onSelect(hoveredOption.value);
|
|
229
|
-
}
|
|
230
|
-
else if (currentQuery.value.length) {
|
|
231
|
-
emit("save-custom", currentQuery.value);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
const onResultFilterChange = (filter: TPopSelectResultFilter<T>) => {
|
|
236
|
-
selectedResultFilter.value = filter;
|
|
237
|
-
updateLocalOptions(props.options);
|
|
238
|
-
inputRef.value!.focus();
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
defineExpose({ close, focus });
|
|
242
|
-
</script>
|
|
243
|
-
|
|
244
|
-
<template>
|
|
245
|
-
<BPopper
|
|
246
|
-
ref="popperRef"
|
|
247
|
-
trigger="click"
|
|
248
|
-
:placement="placement"
|
|
249
|
-
:disabled="disabled"
|
|
250
|
-
:popper-width-class="popperWidthClass"
|
|
251
|
-
:same-width-as-element="sameWidthAsElement"
|
|
252
|
-
:same-width-as-trigger="sameWidthAsTrigger"
|
|
253
|
-
:root-class="rootClass"
|
|
254
|
-
:trigger-class="triggerClass"
|
|
255
|
-
@close="onClose"
|
|
256
|
-
@open="onOpen"
|
|
257
|
-
>
|
|
258
|
-
<template #default="slotProps">
|
|
259
|
-
<slot name="trigger" :disabled="disabled" :visible="slotProps && slotProps.visible" />
|
|
260
|
-
</template>
|
|
261
|
-
|
|
262
|
-
<template #content>
|
|
263
|
-
<BPopperContent ref="contentRef" class="flex flex-col" :class="{ 'h-72': fixedHeight }">
|
|
264
|
-
<header v-if="filterable || remoteMethod || resultFilters" class="border-b border-default">
|
|
265
|
-
<header v-if="filterable || remoteMethod" class="flex items-center w-full px-3 space-x-2 bg-primary overflow-hidden">
|
|
266
|
-
<BIcon name="magnifying-glass" class="text-light-blue" />
|
|
267
|
-
<input
|
|
268
|
-
ref="inputRef"
|
|
269
|
-
v-model="currentQuery"
|
|
270
|
-
type="text"
|
|
271
|
-
class="w-full h-8 text-sm leading-none bg-primary rounded-tr-lg focus:outline-hidden"
|
|
272
|
-
:placeholder="placeholder"
|
|
273
|
-
@click.stop.prevent
|
|
274
|
-
@input="debounceOnQuery"
|
|
275
|
-
@keydown.down.prevent="navigateOptions('next')"
|
|
276
|
-
@keydown.up.prevent="navigateOptions('prev')"
|
|
277
|
-
@keydown.enter.prevent="selectOption"
|
|
278
|
-
@keydown.esc.stop.prevent="onClose"
|
|
279
|
-
>
|
|
280
|
-
</header>
|
|
281
|
-
<ResultFilters
|
|
282
|
-
v-if="resultFilters"
|
|
283
|
-
show-counts
|
|
284
|
-
:filters="localResultFilters"
|
|
285
|
-
:selected="selectedResultFilter"
|
|
286
|
-
@change="onResultFilterChange"
|
|
287
|
-
/>
|
|
288
|
-
</header>
|
|
289
|
-
|
|
290
|
-
<div v-if="$slots.error" ref="errorRef" class="flex-1 bg-primary h-full">
|
|
291
|
-
<slot name="error" />
|
|
292
|
-
</div>
|
|
293
|
-
<div v-else-if="state === State.LOADING" class="flex-1">
|
|
294
|
-
<div class="flex items-center space-x-2 bg-primary text-tertiary py-3 px-3">
|
|
295
|
-
<BLoadSpinner class="w-4 h-4 text-granite-grey" />
|
|
296
|
-
<span class="italic leading-none text-sm">{{ loadingText }}</span>
|
|
297
|
-
</div>
|
|
298
|
-
</div>
|
|
299
|
-
<div v-else-if="state === State.NO_MATCH" class="flex-1">
|
|
300
|
-
<div class="flex space-x-2 bg-primary text-tertiary py-3 px-3">
|
|
301
|
-
<div class="w-4 h-4 text-center leading-none">
|
|
302
|
-
...
|
|
303
|
-
</div>
|
|
304
|
-
<span class="italic leading-none text-sm">Nothing matches your input</span>
|
|
305
|
-
</div>
|
|
306
|
-
</div>
|
|
307
|
-
<div v-else-if="state === State.IDLE" class="flex-1">
|
|
308
|
-
<div class="flex items-center space-x-2 bg-primary text-tertiary py-3 px-3">
|
|
309
|
-
<BIcon :name="emptyStateIcon" />
|
|
310
|
-
<span class="italic leading-none text-sm">{{ emptyStateText }}</span>
|
|
311
|
-
</div>
|
|
312
|
-
<div class="h-8 w-full bg-primary" />
|
|
313
|
-
</div>
|
|
314
|
-
|
|
315
|
-
<BScrollbar v-else-if="state === State.MATCH" ref="scrollbarRef">
|
|
316
|
-
<div class="max-h-60 bg-primary">
|
|
317
|
-
<PopSelectOption
|
|
318
|
-
v-for="option in localOptions"
|
|
319
|
-
ref="optionsRef"
|
|
320
|
-
:key="option.id || option.label"
|
|
321
|
-
:disabled="option.disabled"
|
|
322
|
-
:label="option.label"
|
|
323
|
-
:hovered-option="hoveredOption"
|
|
324
|
-
:selected="selectedOptions.includes(option)"
|
|
325
|
-
@focus="onOptionHover"
|
|
326
|
-
@hover="onOptionHover"
|
|
327
|
-
@click="onSelect(option)"
|
|
328
|
-
>
|
|
329
|
-
<div class="flex items-center space-x-2">
|
|
330
|
-
<BIcon v-if="option.icon" :name="option.icon" />
|
|
331
|
-
<BTextHighlight bold underline :value="option.label" :highlight="currentQuery" />
|
|
332
|
-
</div>
|
|
333
|
-
<div v-if="option.meta" class="text-secondary">
|
|
334
|
-
{{ option.meta }}
|
|
335
|
-
</div>
|
|
336
|
-
</PopSelectOption>
|
|
337
|
-
</div>
|
|
338
|
-
</BScrollbar>
|
|
339
|
-
|
|
340
|
-
<footer v-if="slots.footer" class="flex-none border-t border-default bg-primary">
|
|
341
|
-
<slot name="footer" />
|
|
342
|
-
</footer>
|
|
343
|
-
</BPopperContent>
|
|
344
|
-
</template>
|
|
345
|
-
</BPopper>
|
|
346
|
-
</template>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts" generic="T extends TPopSelectOption">
|
|
2
|
-
import type { TPopSelectOption, TPopSelectResultFilter } from "../types";
|
|
3
|
-
import { BFilterChip } from "../";
|
|
4
|
-
|
|
5
|
-
withDefaults(defineProps<{
|
|
6
|
-
selected: TPopSelectResultFilter<T> | null;
|
|
7
|
-
showCounts?: boolean;
|
|
8
|
-
filters: TPopSelectResultFilter<T>[];
|
|
9
|
-
}>(), {
|
|
10
|
-
showCounts: false,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const emit = defineEmits(["change"]);
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<template>
|
|
17
|
-
<section class="flex items-center px-2 pb-2 space-x-2">
|
|
18
|
-
<BFilterChip
|
|
19
|
-
v-for="filter in filters"
|
|
20
|
-
:key="filter.name"
|
|
21
|
-
:active="Boolean(selected && selected.name === filter.name)"
|
|
22
|
-
:count="filter.count"
|
|
23
|
-
:label="filter.name"
|
|
24
|
-
stop-propagation
|
|
25
|
-
@click="emit('change', filter)"
|
|
26
|
-
/>
|
|
27
|
-
</section>
|
|
28
|
-
</template>
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { TPopSelectOption } from "../types";
|
|
3
|
-
import { computed, ref } from "vue";
|
|
4
|
-
|
|
5
|
-
const props = withDefaults(
|
|
6
|
-
defineProps<{
|
|
7
|
-
label: string;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
hoveredOption: TPopSelectOption | null;
|
|
10
|
-
selected?: boolean;
|
|
11
|
-
}>(),
|
|
12
|
-
{
|
|
13
|
-
disabled: false,
|
|
14
|
-
selected: false,
|
|
15
|
-
},
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const emit = defineEmits(["click", "focus", "hover"]);
|
|
19
|
-
|
|
20
|
-
const root = ref();
|
|
21
|
-
|
|
22
|
-
const highlighted = computed(() => {
|
|
23
|
-
return props.hoveredOption && props.hoveredOption.label === props.label;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const onOptionClick = () => {
|
|
27
|
-
if (props.disabled) return;
|
|
28
|
-
emit("click");
|
|
29
|
-
};
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
<template>
|
|
33
|
-
<div
|
|
34
|
-
ref="root"
|
|
35
|
-
tabindex="0"
|
|
36
|
-
class="flex items-center justify-between w-full h-8 px-3 space-x-2 text-sm focus:outline-hidden"
|
|
37
|
-
:class="{
|
|
38
|
-
'cursor-not-allowed text-muted ': disabled,
|
|
39
|
-
'cursor-pointer text-primary hover:bg-secondary focus:bg-secondary active:bg-tertiary': !disabled && !selected,
|
|
40
|
-
'cursor-pointer text-light-blue font-medium hover:bg-secondary focus:bg-secondary active:bg-tertiary': selected,
|
|
41
|
-
'bg-secondary': highlighted,
|
|
42
|
-
'bg-primary': !highlighted,
|
|
43
|
-
}"
|
|
44
|
-
@click="onOptionClick"
|
|
45
|
-
@keydown.enter.prevent="onOptionClick"
|
|
46
|
-
@mouseover="emit('hover', label)"
|
|
47
|
-
@focus="emit('focus', label)"
|
|
48
|
-
>
|
|
49
|
-
<slot />
|
|
50
|
-
</div>
|
|
51
|
-
</template>
|
|
@@ -1,239 +0,0 @@
|
|
|
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>
|