@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 +0,0 @@
|
|
|
1
|
-
export { default as BTextViewer } from "./TextViewer.vue";
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { Placement } from "@floating-ui/dom";
|
|
3
|
-
import type { TIcon } from "../types";
|
|
4
|
-
import { computed, ref } from "vue";
|
|
5
|
-
import { BIcon, BTooltip } from "../";
|
|
6
|
-
|
|
7
|
-
const props = withDefaults(
|
|
8
|
-
defineProps<{
|
|
9
|
-
active: boolean;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
icon?: TIcon;
|
|
12
|
-
label?: string;
|
|
13
|
-
focus?: boolean;
|
|
14
|
-
stopPropagation?: boolean;
|
|
15
|
-
tooltip?: string;
|
|
16
|
-
tooltipDelay?: number;
|
|
17
|
-
tooltipPlacement?: Placement;
|
|
18
|
-
}>(),
|
|
19
|
-
{
|
|
20
|
-
disabled: false,
|
|
21
|
-
focus: false,
|
|
22
|
-
loading: false,
|
|
23
|
-
notification: false,
|
|
24
|
-
stopPropagation: false,
|
|
25
|
-
tooltipDelay: 500,
|
|
26
|
-
tooltipPlacement: "top",
|
|
27
|
-
},
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const emit = defineEmits(["click", "blur"]);
|
|
31
|
-
|
|
32
|
-
const buttonRef = ref<HTMLButtonElement>();
|
|
33
|
-
|
|
34
|
-
const buttonClasses = computed(() => {
|
|
35
|
-
const result = [];
|
|
36
|
-
|
|
37
|
-
if (props.icon && !props.label) {
|
|
38
|
-
result.push("w-6");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
props.disabled ? result.push("opacity-75 cursor-not-allowed") : result.push("cursor-pointer");
|
|
42
|
-
result.push("rounded-md");
|
|
43
|
-
|
|
44
|
-
result.push(
|
|
45
|
-
...(props.active
|
|
46
|
-
? [
|
|
47
|
-
"bg-blue-100 hover:bg-blue-200 focus-visible:bg-blue-200 active:bg-blue-300",
|
|
48
|
-
"border border-action hover:border-action-hover focus-visible:border-action-hover active:border-action-active",
|
|
49
|
-
"text-action hover:text-action-hover focus-visible:text-action-hover active:text-action-active",
|
|
50
|
-
"dark:bg-blue-800/25 dark:hover:bg-blue-800/50 dark:focus-visible:bg-blue-800/50 dark:active:bg-blue-800/75",
|
|
51
|
-
"dark:border-action dark:hover:border-action-hover dark:focus-visible:border-action-hover dark:active:border-action-active",
|
|
52
|
-
"dark:text-action dark:hover:text-action-hover dark:focus-visible:text-action-hover dark:active:text-action-active",
|
|
53
|
-
]
|
|
54
|
-
: [
|
|
55
|
-
"hover:bg-slate-100 focus-visible:bg-slate-100 active:bg-slate-200",
|
|
56
|
-
"border border-stone-300 hover:border-stone-400 focus-visible:border-stone-400 active:border-stone-500",
|
|
57
|
-
"text-slate-700 hover:text-slate-800 focus-visible:text-slate-800 active:text-slate-900",
|
|
58
|
-
"dark:hover:bg-neutral-700 dark:focus-visible:bg-neutral-700 dark:active:bg-neutral-600",
|
|
59
|
-
"dark:border-stone-700 dark:hover:border-stone-600 dark:focus-visible:border-stone-600 dark:active:border-stone-500",
|
|
60
|
-
"dark:text-slate-200 dark:hover:text-slate-100 dark:focus-visible:text-slate-100 dark:active:text-white",
|
|
61
|
-
]
|
|
62
|
-
),
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return result.filter(i => i).join(" ");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const disabledStyle = computed(() => {
|
|
69
|
-
if (props.disabled) {
|
|
70
|
-
return { background: "hsl(0 0% 90%)" };
|
|
71
|
-
}
|
|
72
|
-
return {};
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const onClick = (event: MouseEvent) => {
|
|
76
|
-
props.stopPropagation && event.stopPropagation();
|
|
77
|
-
|
|
78
|
-
if (!props.disabled) {
|
|
79
|
-
emit("click");
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const focus = () => buttonRef.value!.focus();
|
|
84
|
-
|
|
85
|
-
defineExpose({ focus });
|
|
86
|
-
</script>
|
|
87
|
-
|
|
88
|
-
<template>
|
|
89
|
-
<BTooltip v-if="tooltip" hover :text="tooltip" :delay="tooltipDelay" :placement="tooltipPlacement">
|
|
90
|
-
<button
|
|
91
|
-
ref="buttonRef"
|
|
92
|
-
class="z-0 relative inline-flex items-center justify-center gap-1 h-6 leading-none text-sm border focus:z-10 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-black dark:focus-visible:outline-white"
|
|
93
|
-
:class="buttonClasses"
|
|
94
|
-
:disabled="disabled"
|
|
95
|
-
:style="disabledStyle"
|
|
96
|
-
@click="onClick"
|
|
97
|
-
@blur="emit('blur')"
|
|
98
|
-
>
|
|
99
|
-
<BIcon v-if="icon" :name="icon" />
|
|
100
|
-
<div v-if="label">
|
|
101
|
-
{{ label }}
|
|
102
|
-
</div>
|
|
103
|
-
</button>
|
|
104
|
-
</BTooltip>
|
|
105
|
-
</template>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as BToggleButton } from "./ToggleButton.vue";
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { Placement } from "@floating-ui/dom";
|
|
3
|
-
import type { TPopperTrigger } from "../types";
|
|
4
|
-
import { BPopper } from "../popper";
|
|
5
|
-
|
|
6
|
-
withDefaults(
|
|
7
|
-
defineProps<{
|
|
8
|
-
bgColorClass?: string;
|
|
9
|
-
delay?: number;
|
|
10
|
-
forceShow?: boolean;
|
|
11
|
-
offsetMain?: number;
|
|
12
|
-
offsetCross?: number;
|
|
13
|
-
placement?: Placement;
|
|
14
|
-
text?: string;
|
|
15
|
-
textColorClass?: string;
|
|
16
|
-
trigger?: TPopperTrigger;
|
|
17
|
-
triggerFullWidth?: boolean;
|
|
18
|
-
}>(),
|
|
19
|
-
{
|
|
20
|
-
bgColorClass: "bg-black",
|
|
21
|
-
delay: 10,
|
|
22
|
-
forceShow: false,
|
|
23
|
-
offsetMain: 2,
|
|
24
|
-
offsetCross: 0,
|
|
25
|
-
placement: "top",
|
|
26
|
-
textColorClass: "text-white",
|
|
27
|
-
trigger: "hover",
|
|
28
|
-
triggerFullWidth: false,
|
|
29
|
-
},
|
|
30
|
-
);
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
<template>
|
|
34
|
-
<BPopper
|
|
35
|
-
:trigger="trigger"
|
|
36
|
-
:open-delay="delay"
|
|
37
|
-
disable-click-outside
|
|
38
|
-
:offset-main="offsetMain"
|
|
39
|
-
:offset-cross="offsetCross"
|
|
40
|
-
:root-class="triggerFullWidth ? 'w-full flex' : 'inline-flex'"
|
|
41
|
-
:trigger-class="triggerFullWidth ? 'w-full flex' : 'inline-flex'"
|
|
42
|
-
:placement="placement"
|
|
43
|
-
>
|
|
44
|
-
<slot />
|
|
45
|
-
<template #content>
|
|
46
|
-
<div class="z-50 min-w-0 px-2 py-1 rounded-md text-sm shadow-sm-md" :class="[bgColorClass, textColorClass]">
|
|
47
|
-
<span v-if="text">
|
|
48
|
-
{{ text }}
|
|
49
|
-
</span>
|
|
50
|
-
<slot name="content" />
|
|
51
|
-
</div>
|
|
52
|
-
</template>
|
|
53
|
-
</BPopper>
|
|
54
|
-
</template>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as BTooltip } from "./Tooltip.vue";
|
package/src/components/types.ts
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
export const buttonVariants = ["fill", "outline", "outlineSubtle", "text", "textSubtle", "destructive"] as const;
|
|
2
|
-
export type ButtonVariant = (typeof buttonVariants)[number];
|
|
3
|
-
|
|
4
|
-
export const ButtonType = ["default", "primary", "error"] as const;
|
|
5
|
-
export type TButtonType = (typeof ButtonType)[number];
|
|
6
|
-
|
|
7
|
-
export const checkboxTypes = ["default", "circle"] as const;
|
|
8
|
-
export type TCheckboxType = (typeof checkboxTypes)[number];
|
|
9
|
-
|
|
10
|
-
export const Orientation = ["horizontal", "vertical"] as const;
|
|
11
|
-
export type TButtonGroupOrientation = (typeof Orientation)[number];
|
|
12
|
-
|
|
13
|
-
export const Alignments = ["start", "center", "end", "stretch"] as const;
|
|
14
|
-
export type TAlignment = (typeof Alignments)[number];
|
|
15
|
-
|
|
16
|
-
export const Justifications = [...Alignments, "between", "around", "evenly"] as const;
|
|
17
|
-
export type TJustification = (typeof Justifications)[number];
|
|
18
|
-
|
|
19
|
-
export type TColumnNavigationOptionBase = {
|
|
20
|
-
id?: string;
|
|
21
|
-
label: string;
|
|
22
|
-
value: string;
|
|
23
|
-
icon?: string;
|
|
24
|
-
textClass?: string;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type TColumnNavigationOptionWithChildren = TColumnNavigationOptionBase & {
|
|
29
|
-
type?: "withChildren";
|
|
30
|
-
children?: TColumnNavigationOption[];
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type TColumnNavigationOptionWithDescription = TColumnNavigationOptionBase & {
|
|
34
|
-
type?: "withDescription";
|
|
35
|
-
description?: string;
|
|
36
|
-
component?: string;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type TColumnNavigationOption = TColumnNavigationOptionWithChildren | TColumnNavigationOptionWithDescription;
|
|
40
|
-
|
|
41
|
-
export type TColumnNavigationSelection = {
|
|
42
|
-
path: TColumnNavigationOption[];
|
|
43
|
-
isLeaf: boolean;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const OverlayType = ["default", "blurred"] as const;
|
|
47
|
-
export type TOverlayType = (typeof OverlayType)[number];
|
|
48
|
-
|
|
49
|
-
export const PopperTrigger = ["click", "hover", "focus", "manual"] as const;
|
|
50
|
-
export type TPopperTrigger = (typeof PopperTrigger)[number];
|
|
51
|
-
|
|
52
|
-
export type TPopSelectOption = {
|
|
53
|
-
id?: string | number;
|
|
54
|
-
icon?: TIcon;
|
|
55
|
-
label: string;
|
|
56
|
-
disabled?: boolean;
|
|
57
|
-
meta?: unknown;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export type TPopSelectResultFilter<T> = {
|
|
61
|
-
name: string;
|
|
62
|
-
disabled: boolean;
|
|
63
|
-
execute: (record: T) => boolean;
|
|
64
|
-
count?: number;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const statuses = ["Ok", "Not Ok", "Not Applicable"] as const;
|
|
68
|
-
export type TStatusSelectStatus = (typeof statuses)[number];
|
|
69
|
-
|
|
70
|
-
export type TTreeListNode = {
|
|
71
|
-
key: string;
|
|
72
|
-
value: unknown;
|
|
73
|
-
open: boolean;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const icons = [
|
|
77
|
-
"admin",
|
|
78
|
-
"arrow-deviate",
|
|
79
|
-
"arrow-down-plus",
|
|
80
|
-
"arrow-down",
|
|
81
|
-
"arrow-from",
|
|
82
|
-
"arrow-left",
|
|
83
|
-
"arrow-move",
|
|
84
|
-
"arrow-right",
|
|
85
|
-
"arrow-sub",
|
|
86
|
-
"arrow-trend",
|
|
87
|
-
"arrow-up-plus",
|
|
88
|
-
"arrow-up",
|
|
89
|
-
"authority",
|
|
90
|
-
"beams",
|
|
91
|
-
"bell",
|
|
92
|
-
"bold",
|
|
93
|
-
"box",
|
|
94
|
-
"building",
|
|
95
|
-
"bullet-list",
|
|
96
|
-
"calendar",
|
|
97
|
-
"camera",
|
|
98
|
-
"categories",
|
|
99
|
-
"check-circled",
|
|
100
|
-
"check-outline",
|
|
101
|
-
"check",
|
|
102
|
-
"chevron-down",
|
|
103
|
-
"chevron-down-small",
|
|
104
|
-
"chevron-left-double",
|
|
105
|
-
"chevron-left",
|
|
106
|
-
"chevron-left-small",
|
|
107
|
-
"chevron-right-double",
|
|
108
|
-
"chevron-right",
|
|
109
|
-
"chevron-right-small",
|
|
110
|
-
"chevron-up",
|
|
111
|
-
"chevron-up-small",
|
|
112
|
-
"clock",
|
|
113
|
-
"close-outline",
|
|
114
|
-
"close",
|
|
115
|
-
"columns",
|
|
116
|
-
"conclusion",
|
|
117
|
-
"copy",
|
|
118
|
-
"crosshair",
|
|
119
|
-
"dash",
|
|
120
|
-
"dashboard",
|
|
121
|
-
"delete",
|
|
122
|
-
"delta",
|
|
123
|
-
"download",
|
|
124
|
-
"drag",
|
|
125
|
-
"drilldown",
|
|
126
|
-
"edit",
|
|
127
|
-
"envelope",
|
|
128
|
-
"error",
|
|
129
|
-
"export-document",
|
|
130
|
-
"filter",
|
|
131
|
-
"filters",
|
|
132
|
-
"flag",
|
|
133
|
-
"folder",
|
|
134
|
-
"frequency",
|
|
135
|
-
"fullscreen-off",
|
|
136
|
-
"fullscreen-on",
|
|
137
|
-
"graduate",
|
|
138
|
-
"hamburger",
|
|
139
|
-
"handshake",
|
|
140
|
-
"heading-1",
|
|
141
|
-
"heading-2",
|
|
142
|
-
"heading",
|
|
143
|
-
"home",
|
|
144
|
-
"id-card",
|
|
145
|
-
"id",
|
|
146
|
-
"indent-left",
|
|
147
|
-
"indent-right",
|
|
148
|
-
"information",
|
|
149
|
-
"italics",
|
|
150
|
-
"itenary",
|
|
151
|
-
"keyboard",
|
|
152
|
-
"lightning",
|
|
153
|
-
"link",
|
|
154
|
-
"list-collapse",
|
|
155
|
-
"list-expand",
|
|
156
|
-
"location",
|
|
157
|
-
"lock-locked",
|
|
158
|
-
"lock-unlocked",
|
|
159
|
-
"magnifying-glass",
|
|
160
|
-
"map",
|
|
161
|
-
"match-case",
|
|
162
|
-
"match-diacritics",
|
|
163
|
-
"match-full-word",
|
|
164
|
-
"megaphone",
|
|
165
|
-
"message",
|
|
166
|
-
"message-question",
|
|
167
|
-
"microscope",
|
|
168
|
-
"moon",
|
|
169
|
-
"new-document",
|
|
170
|
-
"news",
|
|
171
|
-
"numbered-list",
|
|
172
|
-
"open-link",
|
|
173
|
-
"options",
|
|
174
|
-
"page",
|
|
175
|
-
"panel-left-show",
|
|
176
|
-
"panel-left-hide",
|
|
177
|
-
"panel-right-show",
|
|
178
|
-
"panel-right-hide",
|
|
179
|
-
"paper-plane",
|
|
180
|
-
"paper",
|
|
181
|
-
"pdf",
|
|
182
|
-
"pen-and-paper",
|
|
183
|
-
"phase",
|
|
184
|
-
"photo",
|
|
185
|
-
"pie-chart",
|
|
186
|
-
"plus",
|
|
187
|
-
"point-left",
|
|
188
|
-
"point-up",
|
|
189
|
-
"popup",
|
|
190
|
-
"question",
|
|
191
|
-
"radio-tower",
|
|
192
|
-
"recycle",
|
|
193
|
-
"redo",
|
|
194
|
-
"refresh",
|
|
195
|
-
"route",
|
|
196
|
-
"rows",
|
|
197
|
-
"scope",
|
|
198
|
-
"settings",
|
|
199
|
-
"share",
|
|
200
|
-
"sign-in",
|
|
201
|
-
"sign-up",
|
|
202
|
-
"slideshow",
|
|
203
|
-
"sort-down",
|
|
204
|
-
"sort-up",
|
|
205
|
-
"sort",
|
|
206
|
-
"square-solid",
|
|
207
|
-
"star-solid",
|
|
208
|
-
"star",
|
|
209
|
-
"stop-watch",
|
|
210
|
-
"structure",
|
|
211
|
-
"sun",
|
|
212
|
-
"table",
|
|
213
|
-
"tag",
|
|
214
|
-
"team",
|
|
215
|
-
"telescope",
|
|
216
|
-
"text-select",
|
|
217
|
-
"trash",
|
|
218
|
-
"triangle-angle",
|
|
219
|
-
"triangle-side",
|
|
220
|
-
"underline",
|
|
221
|
-
"undo",
|
|
222
|
-
"user",
|
|
223
|
-
"venn",
|
|
224
|
-
"video",
|
|
225
|
-
"visibility-off-alt",
|
|
226
|
-
"visibility-off",
|
|
227
|
-
"visibility-on",
|
|
228
|
-
"warning",
|
|
229
|
-
"zoom",
|
|
230
|
-
] as const;
|
|
231
|
-
|
|
232
|
-
export type TIcon = (typeof icons)[number];
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { TSectionType } from "./types";
|
|
3
|
-
import { computed, ref } from "vue";
|
|
4
|
-
|
|
5
|
-
const props = withDefaults(
|
|
6
|
-
defineProps<{
|
|
7
|
-
border?: boolean;
|
|
8
|
-
heightClass?: string;
|
|
9
|
-
type?: TSectionType;
|
|
10
|
-
}>(),
|
|
11
|
-
{
|
|
12
|
-
border: false,
|
|
13
|
-
heightClass: "h-12",
|
|
14
|
-
type: "header",
|
|
15
|
-
},
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const containerRef = ref<HTMLElement>();
|
|
19
|
-
const borderPosition = props.type === "header" ? "border-b" : "border-t";
|
|
20
|
-
|
|
21
|
-
const classes = computed(() => {
|
|
22
|
-
return [props.heightClass, props.border ? "border-default" : "border-transparent", props.border ? borderPosition : ""];
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const heightStyle = computed(() => {
|
|
26
|
-
let height;
|
|
27
|
-
|
|
28
|
-
// if height is auto we have to use js to calculate and actual height in pixels
|
|
29
|
-
// otherwise the height can't be animated
|
|
30
|
-
if (props.heightClass === "h-auto") {
|
|
31
|
-
if (containerRef.value) {
|
|
32
|
-
height = 0;
|
|
33
|
-
for (const child of containerRef.value.children) {
|
|
34
|
-
height += (child as HTMLElement).offsetHeight;
|
|
35
|
-
}
|
|
36
|
-
height = `${height}px`;
|
|
37
|
-
}
|
|
38
|
-
return { height };
|
|
39
|
-
}
|
|
40
|
-
return {};
|
|
41
|
-
});
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<template>
|
|
45
|
-
<component
|
|
46
|
-
:is="type"
|
|
47
|
-
ref="containerRef"
|
|
48
|
-
class="flex-none w-full overflow-hidden transition-height duration-500 ease-in-out"
|
|
49
|
-
:class="classes"
|
|
50
|
-
:style="heightStyle"
|
|
51
|
-
>
|
|
52
|
-
<slot />
|
|
53
|
-
</component>
|
|
54
|
-
</template>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { BFlexbox, BScrollbar } from "../";
|
|
3
|
-
import RunningSection from "./RunningSection.vue";
|
|
4
|
-
|
|
5
|
-
const props = withDefaults(
|
|
6
|
-
defineProps<{
|
|
7
|
-
borders?: boolean;
|
|
8
|
-
footerHeightClass?: string;
|
|
9
|
-
headerHeightClass?: string;
|
|
10
|
-
widthClass?: string;
|
|
11
|
-
windowFrame?: boolean;
|
|
12
|
-
}>(),
|
|
13
|
-
{
|
|
14
|
-
borders: false,
|
|
15
|
-
footerHeightClass: "h-content",
|
|
16
|
-
headerHeightClass: "h-content",
|
|
17
|
-
widthClass: "w-full",
|
|
18
|
-
windowFrame: false,
|
|
19
|
-
},
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const classes = [props.widthClass, props.windowFrame ? "px-8 py-6 bg-light shadow-sm-xl rounded-lg" : ""];
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<template>
|
|
26
|
-
<BFlexbox col align="stretch" justify="start" class="relative h-full overflow-x-hidden" :class="classes">
|
|
27
|
-
<RunningSection v-if="$slots.header" type="header" :border="borders" :height-class="headerHeightClass">
|
|
28
|
-
<slot name="header" />
|
|
29
|
-
</RunningSection>
|
|
30
|
-
<BScrollbar window-resize wrap-class="h-full">
|
|
31
|
-
<slot name="main" />
|
|
32
|
-
</BScrollbar>
|
|
33
|
-
<RunningSection v-if="$slots.footer" type="footer" :border="borders" :height-class="footerHeightClass">
|
|
34
|
-
<slot name="footer" />
|
|
35
|
-
</RunningSection>
|
|
36
|
-
</BFlexbox>
|
|
37
|
-
</template>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ref } from "vue";
|
|
3
|
-
// import { useTrapFocus } from "@/bui/composables";
|
|
4
|
-
|
|
5
|
-
const windowRef = ref<HTMLDivElement>();
|
|
6
|
-
// const { trapFocus } = useTrapFocus(windowRef);
|
|
7
|
-
|
|
8
|
-
// defineExpose({
|
|
9
|
-
// trapFocus: () => {
|
|
10
|
-
// Boolean(windowRef.value) && windowRef.value!.focus();
|
|
11
|
-
// trapFocus();
|
|
12
|
-
// }
|
|
13
|
-
// });
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<template>
|
|
17
|
-
<div ref="windowRef" tabindex="0" class="w-full flex flex-col bg-primary shadow-xl rounded-xl focus:outline-hidden">
|
|
18
|
-
<slot />
|
|
19
|
-
</div>
|
|
20
|
-
</template>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as BWindowFrame } from "./WindowFrame.vue";
|
package/src/composables/index.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { onBeforeUnmount, unref } from "vue";
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line ts/no-unsafe-function-type
|
|
4
|
-
export function useClickOutside(handler: Function) {
|
|
5
|
-
const event = "pointerdown";
|
|
6
|
-
let listener: EventListenerOrEventListenerObject;
|
|
7
|
-
|
|
8
|
-
const enableClickOutside = (targets: HTMLElement[]): void => {
|
|
9
|
-
listener = (event: Event) => {
|
|
10
|
-
let elements: HTMLElement | HTMLElement[] = unref(targets);
|
|
11
|
-
if (!elements)
|
|
12
|
-
return;
|
|
13
|
-
|
|
14
|
-
if (!("length" in elements))
|
|
15
|
-
elements = [elements];
|
|
16
|
-
|
|
17
|
-
const hit = elements.some((el: HTMLElement) => {
|
|
18
|
-
return el === (event.target as HTMLElement) || event.composedPath().includes(el);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
if (hit)
|
|
22
|
-
return;
|
|
23
|
-
|
|
24
|
-
handler(event);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
window.addEventListener(event, listener);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const disableClickOutside = (): void => {
|
|
31
|
-
if (!listener)
|
|
32
|
-
return;
|
|
33
|
-
window.removeEventListener(event, listener);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const updateClickOutside = (targets: HTMLElement[]): void => {
|
|
37
|
-
disableClickOutside();
|
|
38
|
-
enableClickOutside(targets);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
onBeforeUnmount(() => disableClickOutside());
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
enableClickOutside,
|
|
45
|
-
disableClickOutside,
|
|
46
|
-
updateClickOutside,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { onMounted, onUnmounted } from "vue";
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line ts/no-unsafe-function-type
|
|
4
|
-
export function useEscapeKey(callback: Function) {
|
|
5
|
-
const onKeydown = (e: KeyboardEvent) => {
|
|
6
|
-
if (e.key === "Escape")
|
|
7
|
-
callback();
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
onMounted(() => window.addEventListener("keydown", onKeydown));
|
|
11
|
-
onUnmounted(() => window.removeEventListener("keydown", onKeydown));
|
|
12
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { onUnmounted } from "vue";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* TrapFocus keeps (loops) the focus inside an element (fx Modal or Dialog), so the user cannot focus on elements outside of it - using the tab key
|
|
5
|
-
*
|
|
6
|
-
* 'trapElement' is the vue ref to the HTML element that we want to trap focus (tabindex) inside
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export const useTrapFocus = (trapElement: any, focusFirstElement: boolean = false) => {
|
|
10
|
-
// add all the elements inside modal which you want to make focusable
|
|
11
|
-
const focusableElements = "button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])";
|
|
12
|
-
|
|
13
|
-
let firstFocusableElement: HTMLElement;
|
|
14
|
-
let focusableContent: Element[];
|
|
15
|
-
let lastFocusableElement: HTMLElement;
|
|
16
|
-
|
|
17
|
-
const handleKeyDown = (e: KeyboardEvent) => {
|
|
18
|
-
const isTabPressed = e.key === "Tab";
|
|
19
|
-
|
|
20
|
-
if (!isTabPressed)
|
|
21
|
-
return;
|
|
22
|
-
|
|
23
|
-
if (e.shiftKey) {
|
|
24
|
-
if (firstFocusableElement && lastFocusableElement) {
|
|
25
|
-
if (document.activeElement === firstFocusableElement) {
|
|
26
|
-
lastFocusableElement!.focus();
|
|
27
|
-
e.preventDefault();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
if (firstFocusableElement && lastFocusableElement) {
|
|
33
|
-
if (document.activeElement === lastFocusableElement) {
|
|
34
|
-
firstFocusableElement!.focus();
|
|
35
|
-
e.preventDefault();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const trapFocus = () => {
|
|
42
|
-
if (!trapElement.value) {
|
|
43
|
-
console.warn("[useTrapFocus] trapElement is not present");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
firstFocusableElement = trapElement.value.querySelectorAll(focusableElements)[0] as HTMLElement;
|
|
48
|
-
focusableContent = Array.from(trapElement.value.querySelectorAll(focusableElements));
|
|
49
|
-
lastFocusableElement = focusableContent[focusableElements.length - 1] as HTMLElement;
|
|
50
|
-
|
|
51
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
52
|
-
|
|
53
|
-
if (firstFocusableElement && focusFirstElement) {
|
|
54
|
-
firstFocusableElement.focus();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
onUnmounted(() => document.removeEventListener("keydown", handleKeyDown));
|
|
59
|
-
|
|
60
|
-
return { trapFocus };
|
|
61
|
-
};
|