@aleph-alpha/ui-library 6.3.3 → 6.4.0
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/config.js +2 -1
- package/dist/system/components/UiDropdownMenu/UiDropdownMenuSubContent.vue.d.ts +102 -2
- package/dist/system/components/UiDropdownMenu/UiDropdownMenuViewport.vue.d.ts +23 -0
- package/dist/system/components/UiDropdownMenu/menu-metrics.d.ts +4 -0
- package/dist/system/components/UiDropdownMenu/placeMobileSubmenu.d.ts +55 -0
- package/dist/system/components/UiDropdownMenu/types.d.ts +3 -0
- package/dist/system/components/UiDropdownMenu/useMobileSubmenuPlacement.d.ts +18 -0
- package/dist/system/components/UiFileUploadBox/UiFileUploadBox.vue.d.ts +2 -2
- package/dist/system/components/UiFileUploadBox/types.d.ts +8 -5
- package/dist/system/components/UiResizable/UiResizablePanel.vue.d.ts +2 -2
- package/dist/system/components/UiStepper/context.d.ts +8 -0
- package/dist/system/components/UiToggle/UiToggle.vue.d.ts +2 -1
- package/dist/system/components/UiToggle/types.d.ts +10 -2
- package/dist/system/components/UiToggleGroup/UiToggleGroupItem.vue.d.ts +5 -1
- package/dist/system/components/UiToggleGroup/types.d.ts +12 -2
- package/dist/system/components/core/dropdown-menu/DropdownMenuSubContent.vue.d.ts +2 -6
- package/dist/system/components/core/range-calendar/RangeCalendar.vue.d.ts +24 -24
- package/dist/system/components/core/resizable/ResizablePanel.vue.d.ts +2 -2
- package/dist/system/components/core/toggle/Toggle.vue.d.ts +3 -1
- package/dist/system/components/core/toggle/index.d.ts +47 -2
- package/dist/system/components/core/toggle-group/ToggleGroup.vue.d.ts +3 -1
- package/dist/system/components/core/toggle-group/ToggleGroupItem.vue.d.ts +11 -1
- package/dist/system/components/core/toggle-group/context.d.ts +1 -0
- package/dist/system/components/core/toggle-group/index.d.ts +10 -2
- package/dist/system/icons/story-sidebar-icons.json +7 -0
- package/dist/system/lib.js +14114 -13755
- package/dist/system/patterns/UiFileUpload/UiFileUpload.vue.d.ts +2 -2
- package/dist/system/patterns/UiLayout/layout-shell.d.ts +379 -8
- package/dist/system/patterns/UiProfileCard/profile-card.d.ts +51 -1
- package/dist/system/patterns/UiTopBar/accessory-dropdown.d.ts +232 -0
- package/dist/system/story-sidebar-icons.json +7 -0
- package/package.json +2 -2
- package/src/components/UiAccordion/UiAccordion.stories.ts +1079 -0
- package/src/components/UiCalendar/UiCalendar.stories.ts +734 -0
- package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +8 -5
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +819 -31
- package/src/components/UiDropdownMenu/UiDropdownMenuContent.vue +4 -1
- package/src/components/UiDropdownMenu/UiDropdownMenuSubContent.vue +142 -1
- package/src/components/UiDropdownMenu/UiDropdownMenuSubTrigger.vue +28 -0
- package/src/components/UiDropdownMenu/UiDropdownMenuTrigger.vue +3 -1
- package/src/components/UiDropdownMenu/UiDropdownMenuViewport.vue +171 -0
- package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +326 -0
- package/src/components/UiDropdownMenu/__tests__/placeMobileSubmenu.test.ts +128 -0
- package/src/components/UiDropdownMenu/menu-metrics.ts +5 -0
- package/src/components/UiDropdownMenu/placeMobileSubmenu.ts +96 -0
- package/src/components/UiDropdownMenu/types.ts +3 -0
- package/src/components/UiDropdownMenu/useMobileSubmenuPlacement.ts +163 -0
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +389 -3
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +55 -75
- package/src/components/UiFileUploadBox/__tests__/UiFileUploadBox.test.ts +44 -0
- package/src/components/UiFileUploadBox/types.ts +8 -5
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +723 -0
- package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +819 -7
- package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +8 -3
- package/src/components/UiResizable/UiResizable.stories.ts +1215 -5
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +1089 -4
- package/src/components/UiSnackbar/UiSnackbar.vue +3 -2
- package/src/components/UiSnackbar/UiSnackbarContent.vue +1 -1
- package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +3 -1
- package/src/components/UiStepper/UiStepper.stories.ts +566 -2
- package/src/components/UiStepper/UiStepper.vue +14 -1
- package/src/components/UiStepper/UiStepperItem.vue +22 -4
- package/src/components/UiStepper/__tests__/UiStepper.test.ts +66 -0
- package/src/components/UiStepper/context.ts +10 -0
- package/src/components/UiToggle/UiToggle.stories.ts +386 -261
- package/src/components/UiToggle/UiToggle.vue +2 -0
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +63 -10
- package/src/components/UiToggle/types.ts +10 -2
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +765 -30
- package/src/components/UiToggleGroup/UiToggleGroup.vue +2 -0
- package/src/components/UiToggleGroup/UiToggleGroupItem.vue +10 -1
- package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +83 -4
- package/src/components/UiToggleGroup/types.ts +12 -2
- package/src/components/core/calendar/Calendar.vue +234 -2
- package/src/components/core/calendar/CalendarCellTrigger.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuContent.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuSubContent.vue +31 -20
- package/src/components/core/navigation-menu/NavigationMenuList.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendar.vue +254 -6
- package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +1 -1
- package/src/components/core/toggle/Toggle.vue +12 -5
- package/src/components/core/toggle/index.ts +47 -19
- package/src/components/core/toggle-group/ToggleGroup.vue +20 -4
- package/src/components/core/toggle-group/ToggleGroupItem.vue +36 -8
- package/src/components/core/toggle-group/context.ts +1 -0
- package/src/components/core/toggle-group/index.ts +10 -24
- package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +1 -1
- package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +1 -1
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +846 -17
- package/src/patterns/UiDatePicker/UiDatePicker.vue +9 -0
- package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +13 -8
- package/src/patterns/UiFileUpload/UiFileItem.stories.ts +23 -17
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +138 -113
- package/src/patterns/UiFileUpload/UiFileUpload.vue +1 -1
- package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +2 -2
- package/src/patterns/UiLayout/UiLayout.stories.ts +25 -0
- package/src/patterns/UiLayout/UiLayoutContent.stories.ts +359 -0
- package/src/patterns/UiLayout/UiLayoutContent.vue +45 -23
- package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +13 -0
- package/src/patterns/UiLayout/layout-shell.ts +159 -13
- package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +13 -6
- package/src/patterns/UiTopBar/UiTopBar.stories.ts +245 -36
- package/src/patterns/UiTopBar/UiTopBar.vue +4 -2
- package/src/patterns/UiTopBar/accessory-dropdown.ts +99 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { DropdownMenuContent as ShadcnDropdownMenuContent } from '@/components/core/dropdown-menu';
|
|
3
|
+
import UiDropdownMenuViewport from './UiDropdownMenuViewport.vue';
|
|
3
4
|
import type {
|
|
4
5
|
UiDropdownMenuContentProps,
|
|
5
6
|
UiDropdownMenuContentEmits,
|
|
@@ -25,6 +26,8 @@ const emit = defineEmits<UiDropdownMenuContentEmits>();
|
|
|
25
26
|
:align="props.align"
|
|
26
27
|
@escape-key-down="emit('escapeKeyDown', $event)"
|
|
27
28
|
>
|
|
28
|
-
<
|
|
29
|
+
<UiDropdownMenuViewport>
|
|
30
|
+
<slot />
|
|
31
|
+
</UiDropdownMenuViewport>
|
|
29
32
|
</ShadcnDropdownMenuContent>
|
|
30
33
|
</template>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { ref, watch } from 'vue';
|
|
2
3
|
import { DropdownMenuSubContent as ShadcnDropdownMenuSubContent } from '@/components/core/dropdown-menu';
|
|
4
|
+
import UiDropdownMenuViewport from './UiDropdownMenuViewport.vue';
|
|
5
|
+
import { DROPDOWN_MENU_MOBILE_MEDIA } from './menu-metrics';
|
|
6
|
+
import { useMobileSubmenuPlacement } from './useMobileSubmenuPlacement';
|
|
3
7
|
import type {
|
|
4
8
|
UiDropdownMenuSubContentProps,
|
|
5
9
|
UiDropdownMenuSubContentEmits,
|
|
@@ -14,13 +18,150 @@ const props = withDefaults(defineProps<UiDropdownMenuSubContentProps>(), {
|
|
|
14
18
|
});
|
|
15
19
|
|
|
16
20
|
const emit = defineEmits<UiDropdownMenuSubContentEmits>();
|
|
21
|
+
|
|
22
|
+
interface DropdownMenuViewportExpose {
|
|
23
|
+
/** The element that scrolls the menu rows. */
|
|
24
|
+
scrollEl: HTMLElement | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const viewportRef = ref<DropdownMenuViewportExpose | null>(null);
|
|
28
|
+
|
|
29
|
+
function content() {
|
|
30
|
+
const scroll = viewportRef.value?.scrollEl ?? null;
|
|
31
|
+
return (
|
|
32
|
+
scroll?.closest<HTMLElement>('[data-slot="dropdown-menu-sub-content"]') ??
|
|
33
|
+
null
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const { apply, clear } = useMobileSubmenuPlacement(content);
|
|
38
|
+
|
|
39
|
+
// The submenu panel is only mounted once it opens, after this component.
|
|
40
|
+
// Placing it in the same post-render flush means it is never painted at the
|
|
41
|
+
// side position reka-ui computed.
|
|
42
|
+
watch(
|
|
43
|
+
() => viewportRef.value?.scrollEl ?? null,
|
|
44
|
+
(scroll) => {
|
|
45
|
+
if (scroll) {
|
|
46
|
+
apply();
|
|
47
|
+
} else {
|
|
48
|
+
clear();
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{ flush: 'post' },
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Keeps the submenu open while the pointer travels from its row to the panel.
|
|
56
|
+
*
|
|
57
|
+
* When the pointer leaves a row without heading sideways, reka-ui hands focus
|
|
58
|
+
* back to the parent panel, and the submenu reads that as focus leaving and
|
|
59
|
+
* closes. Stacked above or below the row, the pointer never heads sideways,
|
|
60
|
+
* so focus returning to the parent panel itself is not a reason to close.
|
|
61
|
+
* Focus landing on another row still closes it.
|
|
62
|
+
* @param event The focus-outside event, targeted at the newly focused element.
|
|
63
|
+
*/
|
|
64
|
+
function keepOpenWhileCrossing(event: Event) {
|
|
65
|
+
if (!window.matchMedia?.(DROPDOWN_MENU_MOBILE_MEDIA).matches) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const panel = content();
|
|
69
|
+
const labelId = panel?.getAttribute('aria-labelledby');
|
|
70
|
+
const trigger = labelId ? document.getElementById(labelId) : null;
|
|
71
|
+
const parent = trigger?.closest('[role="menu"]');
|
|
72
|
+
if (parent && event.target === parent) {
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
17
76
|
</script>
|
|
18
77
|
|
|
19
78
|
<template>
|
|
20
79
|
<ShadcnDropdownMenuSubContent
|
|
21
80
|
:side-offset="props.sideOffset"
|
|
22
81
|
@escape-key-down="emit('escapeKeyDown', $event)"
|
|
82
|
+
@focus-outside="keepOpenWhileCrossing"
|
|
23
83
|
>
|
|
24
|
-
<
|
|
84
|
+
<UiDropdownMenuViewport ref="viewportRef">
|
|
85
|
+
<slot />
|
|
86
|
+
</UiDropdownMenuViewport>
|
|
25
87
|
</ShadcnDropdownMenuSubContent>
|
|
26
88
|
</template>
|
|
89
|
+
|
|
90
|
+
<style scoped>
|
|
91
|
+
/* On a narrow screen the submenu stacks above or below the row that opened
|
|
92
|
+
it, at the parent's width, instead of sitting beside it. reka-ui positions
|
|
93
|
+
its wrapper with inline styles; the stylesheet wins over those with
|
|
94
|
+
`!important` and collapses the wrapper to the viewport origin, so the panel
|
|
95
|
+
inside can be fixed in viewport coordinates from the measured variables. */
|
|
96
|
+
@media (max-width: 639px) {
|
|
97
|
+
:global(
|
|
98
|
+
[data-reka-popper-content-wrapper]:has(
|
|
99
|
+
> [data-slot='dropdown-menu-sub-content']
|
|
100
|
+
)
|
|
101
|
+
) {
|
|
102
|
+
position: fixed !important;
|
|
103
|
+
top: 0 !important;
|
|
104
|
+
left: 0 !important;
|
|
105
|
+
width: 0;
|
|
106
|
+
height: 0;
|
|
107
|
+
min-width: 0 !important;
|
|
108
|
+
transform: none !important;
|
|
109
|
+
will-change: auto !important;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
:global(
|
|
113
|
+
[data-reka-popper-content-wrapper] > [data-slot='dropdown-menu-sub-content']
|
|
114
|
+
) {
|
|
115
|
+
position: fixed;
|
|
116
|
+
top: var(--ui-dropdown-submenu-top);
|
|
117
|
+
left: var(--ui-dropdown-submenu-left);
|
|
118
|
+
width: var(--ui-dropdown-submenu-width);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* When the chosen side cannot hold the whole panel, the scroll area gives
|
|
122
|
+
up the difference so the panel ends at the viewport edge and every row
|
|
123
|
+
can still be scrolled to. The cap is always under the five-row limit. */
|
|
124
|
+
:global(
|
|
125
|
+
[data-slot='dropdown-menu-sub-content'][data-mobile-clamped]
|
|
126
|
+
[data-slot='dropdown-menu-scroll']
|
|
127
|
+
) {
|
|
128
|
+
max-height: var(--ui-dropdown-submenu-scroll-max-height);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* Not measured yet: keep it out of sight rather than flash at the origin. */
|
|
132
|
+
:global([data-slot='dropdown-menu-sub-content']:not([data-mobile-side])) {
|
|
133
|
+
visibility: hidden;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* The gap between the row and the panel belongs to the open row for hit
|
|
137
|
+
testing, so the pointer crossing it never leaves the row and lands on a
|
|
138
|
+
neighbour, which would close the submenu. The row rises above its
|
|
139
|
+
neighbours so the extension is not covered by the next row. */
|
|
140
|
+
:global([data-slot='dropdown-menu-sub-trigger'][data-mobile-submenu-side]) {
|
|
141
|
+
position: relative;
|
|
142
|
+
z-index: 1;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:global(
|
|
146
|
+
[data-slot='dropdown-menu-sub-trigger'][data-mobile-submenu-side]::after
|
|
147
|
+
) {
|
|
148
|
+
content: '';
|
|
149
|
+
position: absolute;
|
|
150
|
+
right: 0;
|
|
151
|
+
left: 0;
|
|
152
|
+
height: var(--ui-dropdown-submenu-gap);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:global(
|
|
156
|
+
[data-slot='dropdown-menu-sub-trigger'][data-mobile-submenu-side='bottom']::after
|
|
157
|
+
) {
|
|
158
|
+
top: 100%;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
:global(
|
|
162
|
+
[data-slot='dropdown-menu-sub-trigger'][data-mobile-submenu-side='top']::after
|
|
163
|
+
) {
|
|
164
|
+
bottom: 100%;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
</style>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { DropdownMenuSubTrigger as ShadcnDropdownMenuSubTrigger } from '@/components/core/dropdown-menu';
|
|
3
|
+
import { DROPDOWN_MENU_MOBILE_MEDIA } from './menu-metrics';
|
|
3
4
|
import type { UiDropdownMenuSubTriggerProps } from './types';
|
|
4
5
|
|
|
5
6
|
defineOptions({
|
|
@@ -11,6 +12,32 @@ const props = withDefaults(defineProps<UiDropdownMenuSubTriggerProps>(), {
|
|
|
11
12
|
inset: false,
|
|
12
13
|
textValue: undefined,
|
|
13
14
|
});
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Keeps the submenu open while the pointer moves over the row that opened it.
|
|
18
|
+
*
|
|
19
|
+
* reka-ui closes the active submenu whenever the parent's highlighted row
|
|
20
|
+
* changes, and re-highlights a row on every pointer move over it. Once the row
|
|
21
|
+
* has lost its highlight — focus landing on it clears the highlight a tick
|
|
22
|
+
* later — the next move over the same row counts as a change and closes the
|
|
23
|
+
* submenu it just opened. Stacked above or below the row, the pointer crosses
|
|
24
|
+
* the row again on its way to the panel, so on a narrow screen the move is
|
|
25
|
+
* cancelled before reka-ui sees it; the row is already open and highlighted,
|
|
26
|
+
* and there is nothing left for the move to do.
|
|
27
|
+
* @param event The pointer move, caught before reka-ui's own handler.
|
|
28
|
+
*/
|
|
29
|
+
function keepOpenOnOwnRow(event: PointerEvent) {
|
|
30
|
+
if (event.pointerType !== 'mouse') {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!window.matchMedia?.(DROPDOWN_MENU_MOBILE_MEDIA).matches) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const row = event.currentTarget as HTMLElement | null;
|
|
37
|
+
if (row?.dataset.state === 'open') {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
14
41
|
</script>
|
|
15
42
|
|
|
16
43
|
<template>
|
|
@@ -18,6 +45,7 @@ const props = withDefaults(defineProps<UiDropdownMenuSubTriggerProps>(), {
|
|
|
18
45
|
:disabled="props.disabled"
|
|
19
46
|
:text-value="props.textValue"
|
|
20
47
|
:inset="props.inset"
|
|
48
|
+
@pointermove.capture="keepOpenOnOwnRow"
|
|
21
49
|
>
|
|
22
50
|
<slot />
|
|
23
51
|
</ShadcnDropdownMenuSubTrigger>
|
|
@@ -19,7 +19,9 @@ const props = withDefaults(defineProps<UiDropdownMenuTriggerProps>(), {
|
|
|
19
19
|
:disabled="props.disabled"
|
|
20
20
|
:as-child="props.asChild"
|
|
21
21
|
:aria-label="props.ariaLabel"
|
|
22
|
-
:class="
|
|
22
|
+
:class="
|
|
23
|
+
cn('ui-focus-ring', !props.asChild && 'rounded-sm', $attrs?.class ?? '')
|
|
24
|
+
"
|
|
23
25
|
>
|
|
24
26
|
<slot />
|
|
25
27
|
</ShadcnDropdownMenuTrigger>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
|
3
|
+
import { useEventListener } from '@vueuse/core';
|
|
4
|
+
import UiFadeMask from '@/components/UiFadeMask/UiFadeMask.vue';
|
|
5
|
+
import type { UiFadeMaskPosition } from '@/components/UiFadeMask';
|
|
6
|
+
|
|
7
|
+
defineOptions({
|
|
8
|
+
name: 'UiDropdownMenuViewport',
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const scrollEl = ref<HTMLElement | null>(null);
|
|
12
|
+
const fadePosition = ref<UiFadeMaskPosition | null>(null);
|
|
13
|
+
|
|
14
|
+
let resizeObserver: ResizeObserver | undefined;
|
|
15
|
+
let mutationObserver: MutationObserver | undefined;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Pins a fade to each edge that still has rows beyond it.
|
|
19
|
+
*
|
|
20
|
+
* At the start the first row is clear, and at the end the last row is clear.
|
|
21
|
+
*/
|
|
22
|
+
function measureFade() {
|
|
23
|
+
const element = scrollEl.value;
|
|
24
|
+
if (!element) {
|
|
25
|
+
fadePosition.value = null;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const hidden = element.scrollHeight - element.clientHeight;
|
|
30
|
+
if (hidden <= 1) {
|
|
31
|
+
fadePosition.value = null;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const atStart = element.scrollTop <= 1;
|
|
36
|
+
const atEnd = element.scrollTop >= hidden - 1;
|
|
37
|
+
if (atStart) {
|
|
38
|
+
fadePosition.value = 'bottom';
|
|
39
|
+
} else if (atEnd) {
|
|
40
|
+
fadePosition.value = 'top';
|
|
41
|
+
} else {
|
|
42
|
+
fadePosition.value = 'both';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
useEventListener(scrollEl, 'scroll', measureFade);
|
|
47
|
+
|
|
48
|
+
onMounted(() => {
|
|
49
|
+
measureFade();
|
|
50
|
+
const element = scrollEl.value;
|
|
51
|
+
if (!element) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
56
|
+
resizeObserver = new ResizeObserver(measureFade);
|
|
57
|
+
resizeObserver.observe(element);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
mutationObserver = new MutationObserver(measureFade);
|
|
61
|
+
mutationObserver.observe(element, { childList: true, subtree: true });
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
onBeforeUnmount(() => {
|
|
65
|
+
resizeObserver?.disconnect();
|
|
66
|
+
mutationObserver?.disconnect();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
defineExpose({ scrollEl });
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<!--
|
|
74
|
+
The fade mask wraps only the scroll box, so its bands sit inside the
|
|
75
|
+
panel's padding, over the rows. Five rows stay in view on a narrow screen.
|
|
76
|
+
From `sm` up the scroll box drops out of layout and the menu panel scrolls
|
|
77
|
+
the way it always has.
|
|
78
|
+
-->
|
|
79
|
+
<UiFadeMask
|
|
80
|
+
:position="fadePosition ?? 'top'"
|
|
81
|
+
data-slot="dropdown-menu-viewport"
|
|
82
|
+
class="ui-dropdown-menu-viewport"
|
|
83
|
+
:data-fade="fadePosition ?? 'none'"
|
|
84
|
+
>
|
|
85
|
+
<div
|
|
86
|
+
ref="scrollEl"
|
|
87
|
+
data-slot="dropdown-menu-scroll"
|
|
88
|
+
class="ui-dropdown-menu-scroll"
|
|
89
|
+
>
|
|
90
|
+
<slot />
|
|
91
|
+
</div>
|
|
92
|
+
</UiFadeMask>
|
|
93
|
+
</template>
|
|
94
|
+
|
|
95
|
+
<style scoped>
|
|
96
|
+
/* One row is `h-9` (2.25rem). The scroll box holds five of them, or fewer
|
|
97
|
+
when the panel itself is held to the height reka-ui found free beside the
|
|
98
|
+
trigger: the panel is a flex column, so the scroll box gives up height
|
|
99
|
+
instead of being clipped by the panel's hidden overflow. `min-height: 0`
|
|
100
|
+
lets a flex item shrink below its content. */
|
|
101
|
+
@media (max-width: 639px) {
|
|
102
|
+
.ui-dropdown-menu-viewport {
|
|
103
|
+
display: flex;
|
|
104
|
+
flex-direction: column;
|
|
105
|
+
min-height: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.ui-dropdown-menu-scroll {
|
|
109
|
+
max-height: calc(2.25rem * 5);
|
|
110
|
+
min-height: 0;
|
|
111
|
+
overflow-x: hidden;
|
|
112
|
+
overflow-y: auto;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* The band is only for the edges that still have rows past them. */
|
|
117
|
+
.ui-dropdown-menu-viewport[data-fade='none'] :deep(.ui-fade-mask__band) {
|
|
118
|
+
display: none;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* The band is one row tall and fades into the floating surface the menu is
|
|
122
|
+
drawn on. The ramp is clear at the row's inner edge and solid before the
|
|
123
|
+
outer edge, so the first or last row is washed heavily while the next row
|
|
124
|
+
stays untouched, and a light blur softens what shows through. */
|
|
125
|
+
.ui-dropdown-menu-viewport
|
|
126
|
+
:deep(.ui-fade-mask__band[data-background][data-position]) {
|
|
127
|
+
--ui-fade-mask-height: 2.25rem;
|
|
128
|
+
--ui-fade-mask-surface: var(--background-surface-floating);
|
|
129
|
+
--ui-fade-mask-stop: 85%;
|
|
130
|
+
|
|
131
|
+
backdrop-filter: blur(1px);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@media (min-width: 640px) {
|
|
135
|
+
.ui-dropdown-menu-viewport {
|
|
136
|
+
display: contents;
|
|
137
|
+
position: static;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.ui-dropdown-menu-viewport :deep(.ui-fade-mask__band) {
|
|
141
|
+
display: none;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.ui-dropdown-menu-scroll {
|
|
145
|
+
display: contents;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* The parent panel takes overlay/hover/default while a submenu is open.
|
|
150
|
+
The open submenu is a separate layer and does not match this. */
|
|
151
|
+
@media (max-width: 639px) {
|
|
152
|
+
:global(
|
|
153
|
+
[data-slot='dropdown-menu-content']:has(
|
|
154
|
+
[data-slot='dropdown-menu-sub-trigger'][data-state='open']
|
|
155
|
+
)::before
|
|
156
|
+
),
|
|
157
|
+
:global(
|
|
158
|
+
[data-slot='dropdown-menu-sub-content']:has(
|
|
159
|
+
[data-slot='dropdown-menu-sub-trigger'][data-state='open']
|
|
160
|
+
)::before
|
|
161
|
+
) {
|
|
162
|
+
content: '';
|
|
163
|
+
position: absolute;
|
|
164
|
+
inset: 0;
|
|
165
|
+
z-index: 20;
|
|
166
|
+
border-radius: inherit;
|
|
167
|
+
pointer-events: none;
|
|
168
|
+
background-color: oklch(var(--overlay-hover-default));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
</style>
|