akar 2.0.15 → 2.0.18
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/Autocomplete/AutocompleteRoot.cjs +3 -0
- package/dist/Autocomplete/AutocompleteRoot.cjs.map +1 -1
- package/dist/Autocomplete/AutocompleteRoot.js +3 -0
- package/dist/Autocomplete/AutocompleteRoot.js.map +1 -1
- package/dist/Calendar/CalendarCell.cjs +1 -1
- package/dist/Calendar/CalendarCell.js +1 -1
- package/dist/Calendar/CalendarCellTrigger.cjs +2 -2
- package/dist/Calendar/CalendarCellTrigger.js +2 -2
- package/dist/Calendar/CalendarRoot.cjs +10 -6
- package/dist/Calendar/CalendarRoot.cjs.map +1 -1
- package/dist/Calendar/CalendarRoot.js +10 -6
- package/dist/Calendar/CalendarRoot.js.map +1 -1
- package/dist/Collection/Collection.cjs +6 -0
- package/dist/Collection/Collection.cjs.map +1 -1
- package/dist/Collection/Collection.js +6 -0
- package/dist/Collection/Collection.js.map +1 -1
- package/dist/Combobox/ComboboxContentImpl.cjs +5 -1
- package/dist/Combobox/ComboboxContentImpl.cjs.map +1 -1
- package/dist/Combobox/ComboboxContentImpl.js +6 -2
- package/dist/Combobox/ComboboxContentImpl.js.map +1 -1
- package/dist/Combobox/ComboboxRoot.cjs +9 -2
- package/dist/Combobox/ComboboxRoot.cjs.map +1 -1
- package/dist/Combobox/ComboboxRoot.js +9 -2
- package/dist/Combobox/ComboboxRoot.js.map +1 -1
- package/dist/Combobox/useComboboxContentPositioning.cjs +54 -0
- package/dist/Combobox/useComboboxContentPositioning.cjs.map +1 -0
- package/dist/Combobox/useComboboxContentPositioning.js +48 -0
- package/dist/Combobox/useComboboxContentPositioning.js.map +1 -0
- package/dist/DateField/DateFieldRoot.cjs +6 -6
- package/dist/DateField/DateFieldRoot.js +6 -6
- package/dist/DatePicker/DatePickerCell.cjs +1 -1
- package/dist/DatePicker/DatePickerCell.js +1 -1
- package/dist/DatePicker/DatePickerCellTrigger.cjs +2 -2
- package/dist/DatePicker/DatePickerCellTrigger.js +2 -2
- package/dist/DatePicker/DatePickerRoot.cjs +6 -6
- package/dist/DatePicker/DatePickerRoot.js +6 -6
- package/dist/DateRangeField/DateRangeFieldRoot.cjs +4 -4
- package/dist/DateRangeField/DateRangeFieldRoot.js +4 -4
- package/dist/DateRangePicker/DateRangePickerCell.cjs +1 -1
- package/dist/DateRangePicker/DateRangePickerCell.js +1 -1
- package/dist/DateRangePicker/DateRangePickerCellTrigger.cjs +2 -2
- package/dist/DateRangePicker/DateRangePickerCellTrigger.js +2 -2
- package/dist/DateRangePicker/DateRangePickerRoot.cjs +4 -4
- package/dist/DateRangePicker/DateRangePickerRoot.js +4 -4
- package/dist/Dialog/DialogContent.cjs +7 -6
- package/dist/Dialog/DialogContent.cjs.map +1 -1
- package/dist/Dialog/DialogContent.js +8 -7
- package/dist/Dialog/DialogContent.js.map +1 -1
- package/dist/Dialog/DialogOverlay.cjs +6 -4
- package/dist/Dialog/DialogOverlay.cjs.map +1 -1
- package/dist/Dialog/DialogOverlay.js +7 -5
- package/dist/Dialog/DialogOverlay.js.map +1 -1
- package/dist/DismissableLayer/DismissableLayer.cjs +1 -1
- package/dist/DismissableLayer/DismissableLayer.cjs.map +1 -1
- package/dist/DismissableLayer/DismissableLayer.js +1 -1
- package/dist/DismissableLayer/DismissableLayer.js.map +1 -1
- package/dist/DismissableLayer/DismissableLayerBranch.cjs +7 -2
- package/dist/DismissableLayer/DismissableLayerBranch.cjs.map +1 -1
- package/dist/DismissableLayer/DismissableLayerBranch.js +7 -2
- package/dist/DismissableLayer/DismissableLayerBranch.js.map +1 -1
- package/dist/DismissableLayer/utils.cjs +2 -0
- package/dist/DismissableLayer/utils.cjs.map +1 -1
- package/dist/DismissableLayer/utils.js +2 -0
- package/dist/DismissableLayer/utils.js.map +1 -1
- package/dist/Drawer/DrawerContent.cjs +11 -4
- package/dist/Drawer/DrawerContent.cjs.map +1 -1
- package/dist/Drawer/DrawerContent.js +11 -4
- package/dist/Drawer/DrawerContent.js.map +1 -1
- package/dist/Drawer/DrawerContentImpl.cjs +16 -4
- package/dist/Drawer/DrawerContentImpl.cjs.map +1 -1
- package/dist/Drawer/DrawerContentImpl.js +16 -4
- package/dist/Drawer/DrawerContentImpl.js.map +1 -1
- package/dist/Drawer/DrawerRoot.cjs +12 -9
- package/dist/Drawer/DrawerRoot.cjs.map +1 -1
- package/dist/Drawer/DrawerRoot.js +12 -9
- package/dist/Drawer/DrawerRoot.js.map +1 -1
- package/dist/Drawer/DrawerTrigger.cjs +3 -2
- package/dist/Drawer/DrawerTrigger.cjs.map +1 -1
- package/dist/Drawer/DrawerTrigger.js +3 -2
- package/dist/Drawer/DrawerTrigger.js.map +1 -1
- package/dist/FocusScope/FocusScope.cjs +2 -0
- package/dist/FocusScope/FocusScope.cjs.map +1 -1
- package/dist/FocusScope/FocusScope.js +2 -0
- package/dist/FocusScope/FocusScope.js.map +1 -1
- package/dist/Listbox/ListboxItem.cjs +2 -1
- package/dist/Listbox/ListboxItem.cjs.map +1 -1
- package/dist/Listbox/ListboxItem.js +2 -1
- package/dist/Listbox/ListboxItem.js.map +1 -1
- package/dist/Listbox/ListboxRoot.cjs +22 -4
- package/dist/Listbox/ListboxRoot.cjs.map +1 -1
- package/dist/Listbox/ListboxRoot.js +17 -5
- package/dist/Listbox/ListboxRoot.js.map +1 -1
- package/dist/Listbox/ListboxVirtualizer.cjs +2 -2
- package/dist/Listbox/ListboxVirtualizer.cjs.map +1 -1
- package/dist/Listbox/ListboxVirtualizer.js +2 -2
- package/dist/Listbox/ListboxVirtualizer.js.map +1 -1
- package/dist/Menu/MenuItemImpl.cjs +2 -1
- package/dist/Menu/MenuItemImpl.cjs.map +1 -1
- package/dist/Menu/MenuItemImpl.js +2 -1
- package/dist/Menu/MenuItemImpl.js.map +1 -1
- package/dist/MonthPicker/MonthPickerCell.cjs +1 -1
- package/dist/MonthPicker/MonthPickerCell.js +1 -1
- package/dist/MonthPicker/MonthPickerCellTrigger.cjs +1 -1
- package/dist/MonthPicker/MonthPickerCellTrigger.js +1 -1
- package/dist/MonthPicker/MonthPickerRoot.cjs +10 -6
- package/dist/MonthPicker/MonthPickerRoot.cjs.map +1 -1
- package/dist/MonthPicker/MonthPickerRoot.js +10 -6
- package/dist/MonthPicker/MonthPickerRoot.js.map +1 -1
- package/dist/MonthRangePicker/MonthRangePickerCell.cjs +1 -1
- package/dist/MonthRangePicker/MonthRangePickerCell.js +1 -1
- package/dist/MonthRangePicker/MonthRangePickerCellTrigger.cjs +1 -1
- package/dist/MonthRangePicker/MonthRangePickerCellTrigger.js +1 -1
- package/dist/MonthRangePicker/MonthRangePickerRoot.cjs +4 -4
- package/dist/MonthRangePicker/MonthRangePickerRoot.js +4 -4
- package/dist/NumberField/utils.cjs +62 -18
- package/dist/NumberField/utils.cjs.map +1 -1
- package/dist/NumberField/utils.js +63 -19
- package/dist/NumberField/utils.js.map +1 -1
- package/dist/PinInput/PinInputInput.cjs +29 -6
- package/dist/PinInput/PinInputInput.cjs.map +1 -1
- package/dist/PinInput/PinInputInput.js +29 -6
- package/dist/PinInput/PinInputInput.js.map +1 -1
- package/dist/Popover/PopoverTrigger.cjs +2 -1
- package/dist/Popover/PopoverTrigger.cjs.map +1 -1
- package/dist/Popover/PopoverTrigger.js +2 -1
- package/dist/Popover/PopoverTrigger.js.map +1 -1
- package/dist/RadioGroup/Radio.cjs +1 -1
- package/dist/RadioGroup/Radio.cjs.map +1 -1
- package/dist/RadioGroup/Radio.js +1 -1
- package/dist/RadioGroup/Radio.js.map +1 -1
- package/dist/RangeCalendar/RangeCalendarCell.cjs +1 -1
- package/dist/RangeCalendar/RangeCalendarCell.js +1 -1
- package/dist/RangeCalendar/RangeCalendarCellTrigger.cjs +2 -2
- package/dist/RangeCalendar/RangeCalendarCellTrigger.js +2 -2
- package/dist/RangeCalendar/RangeCalendarRoot.cjs +4 -4
- package/dist/RangeCalendar/RangeCalendarRoot.js +4 -4
- package/dist/Rating/RatingItemIndicator.cjs +2 -1
- package/dist/Rating/RatingItemIndicator.cjs.map +1 -1
- package/dist/Rating/RatingItemIndicator.js +2 -1
- package/dist/Rating/RatingItemIndicator.js.map +1 -1
- package/dist/Select/SelectContentImpl.cjs +4 -0
- package/dist/Select/SelectContentImpl.cjs.map +1 -1
- package/dist/Select/SelectContentImpl.js +4 -0
- package/dist/Select/SelectContentImpl.js.map +1 -1
- package/dist/Select/SelectTrigger.cjs +1 -1
- package/dist/Select/SelectTrigger.cjs.map +1 -1
- package/dist/Select/SelectTrigger.js +1 -1
- package/dist/Select/SelectTrigger.js.map +1 -1
- package/dist/Tooltip/TooltipContentHoverable.cjs +11 -0
- package/dist/Tooltip/TooltipContentHoverable.cjs.map +1 -1
- package/dist/Tooltip/TooltipContentHoverable.js +11 -0
- package/dist/Tooltip/TooltipContentHoverable.js.map +1 -1
- package/dist/Tooltip/TooltipContentImpl.cjs +1 -1
- package/dist/Tooltip/TooltipContentImpl.cjs.map +1 -1
- package/dist/Tooltip/TooltipContentImpl.js +1 -1
- package/dist/Tooltip/TooltipContentImpl.js.map +1 -1
- package/dist/Tooltip/TooltipTrigger.cjs +4 -4
- package/dist/Tooltip/TooltipTrigger.cjs.map +1 -1
- package/dist/Tooltip/TooltipTrigger.js +5 -5
- package/dist/Tooltip/TooltipTrigger.js.map +1 -1
- package/dist/Tree/TreeItem.cjs +2 -2
- package/dist/Tree/TreeItem.cjs.map +1 -1
- package/dist/Tree/TreeItem.js +2 -2
- package/dist/Tree/TreeItem.js.map +1 -1
- package/dist/Tree/TreeRoot.cjs +21 -1
- package/dist/Tree/TreeRoot.cjs.map +1 -1
- package/dist/Tree/TreeRoot.js +21 -1
- package/dist/Tree/TreeRoot.js.map +1 -1
- package/dist/YearPicker/YearPickerCell.cjs +1 -1
- package/dist/YearPicker/YearPickerCell.js +1 -1
- package/dist/YearPicker/YearPickerCellTrigger.cjs +1 -1
- package/dist/YearPicker/YearPickerCellTrigger.js +1 -1
- package/dist/YearPicker/YearPickerRoot.cjs +10 -6
- package/dist/YearPicker/YearPickerRoot.cjs.map +1 -1
- package/dist/YearPicker/YearPickerRoot.js +10 -6
- package/dist/YearPicker/YearPickerRoot.js.map +1 -1
- package/dist/YearRangePicker/YearRangePickerCell.cjs +1 -1
- package/dist/YearRangePicker/YearRangePickerCell.js +1 -1
- package/dist/YearRangePicker/YearRangePickerCellTrigger.cjs +1 -1
- package/dist/YearRangePicker/YearRangePickerCellTrigger.js +1 -1
- package/dist/YearRangePicker/YearRangePickerRoot.cjs +4 -4
- package/dist/YearRangePicker/YearRangePickerRoot.js +4 -4
- package/dist/composables/useSwipeDismiss.cjs +47 -0
- package/dist/composables/useSwipeDismiss.cjs.map +1 -1
- package/dist/composables/useSwipeDismiss.js +47 -0
- package/dist/composables/useSwipeDismiss.js.map +1 -1
- package/dist/date/comparators.cjs.map +1 -1
- package/dist/date/comparators.js.map +1 -1
- package/dist/date/parser.cjs +4 -1
- package/dist/date/parser.cjs.map +1 -1
- package/dist/date/parser.js +4 -1
- package/dist/date/parser.js.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.js +1 -0
- package/dist/index2.d.cts.map +1 -1
- package/dist/index2.d.ts.map +1 -1
- package/dist/index3.d.cts +27 -2
- package/dist/index3.d.cts.map +1 -1
- package/dist/index3.d.ts +27 -2
- package/dist/index3.d.ts.map +1 -1
- package/dist/index4.d.cts +662 -656
- package/dist/index4.d.cts.map +1 -1
- package/dist/index4.d.ts +662 -656
- package/dist/index4.d.ts.map +1 -1
- package/dist/internal.d.cts +2 -2
- package/dist/internal.d.cts.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/shared/useDateFormatter.cjs +25 -5
- package/dist/shared/useDateFormatter.cjs.map +1 -1
- package/dist/shared/useDateFormatter.js +25 -5
- package/dist/shared/useDateFormatter.js.map +1 -1
- package/dist/shared/useEmitAsProps.cjs +1 -0
- package/dist/shared/useEmitAsProps.cjs.map +1 -1
- package/dist/shared/useEmitAsProps.js +1 -0
- package/dist/shared/useEmitAsProps.js.map +1 -1
- package/dist/shared/useFilter.cjs +4 -5
- package/dist/shared/useFilter.cjs.map +1 -1
- package/dist/shared/useFilter.js +4 -5
- package/dist/shared/useFilter.js.map +1 -1
- package/dist/shared/useGraceArea.cjs +11 -8
- package/dist/shared/useGraceArea.cjs.map +1 -1
- package/dist/shared/useGraceArea.js +11 -8
- package/dist/shared/useGraceArea.js.map +1 -1
- package/dist/utils/registry.cjs +11 -0
- package/dist/utils/registry.cjs.map +1 -1
- package/dist/utils/registry.js +11 -0
- package/dist/utils/registry.js.map +1 -1
- package/package.json +11 -13
- package/src/Autocomplete/AutocompleteRoot.vue +3 -0
- package/src/Collection/Collection.ts +10 -1
- package/src/Combobox/ComboboxContentImpl.vue +11 -1
- package/src/Combobox/ComboboxRoot.vue +12 -2
- package/src/Combobox/useComboboxContentPositioning.ts +59 -0
- package/src/Dialog/DialogContent.vue +17 -6
- package/src/Dialog/DialogOverlay.vue +13 -5
- package/src/DismissableLayer/DismissableLayer.vue +6 -1
- package/src/DismissableLayer/DismissableLayerBranch.vue +11 -2
- package/src/DismissableLayer/utils.ts +16 -0
- package/src/Drawer/DrawerContent.vue +19 -3
- package/src/Drawer/DrawerContentImpl.vue +22 -2
- package/src/Drawer/DrawerRoot.vue +15 -11
- package/src/Drawer/DrawerTrigger.vue +1 -1
- package/src/Drawer/composables/useSwipeDismiss.ts +88 -0
- package/src/DropdownMenu/DropdownMenuFilter.vue +1 -1
- package/src/FocusScope/FocusScope.vue +11 -0
- package/src/Listbox/ListboxItem.vue +1 -1
- package/src/Listbox/ListboxRoot.vue +36 -4
- package/src/Listbox/ListboxVirtualizer.vue +3 -4
- package/src/Menu/MenuItemImpl.vue +2 -1
- package/src/NumberField/utils.ts +90 -22
- package/src/PinInput/PinInputInput.vue +54 -16
- package/src/PinInput/PinInputRoot.vue +5 -5
- package/src/Popover/PopoverTrigger.vue +2 -1
- package/src/RadioGroup/Radio.vue +1 -1
- package/src/Rating/RatingItemIndicator.vue +11 -1
- package/src/Select/SelectContentImpl.vue +9 -0
- package/src/Select/SelectTrigger.vue +1 -1
- package/src/Splitter/utils/registry.ts +22 -0
- package/src/Tooltip/TooltipContentHoverable.vue +26 -0
- package/src/Tooltip/TooltipContentImpl.vue +1 -1
- package/src/Tooltip/TooltipTrigger.vue +9 -5
- package/src/Tree/TreeItem.vue +2 -2
- package/src/Tree/TreeRoot.vue +24 -1
- package/src/shared/date/comparators.ts +2 -2
- package/src/shared/date/parser.ts +2 -1
- package/src/shared/useDateFormatter.ts +26 -9
- package/src/shared/useEmitAsProps.test-d.ts +34 -1
- package/src/shared/useEmitAsProps.ts +52 -8
- package/src/shared/useFilter.ts +14 -4
- package/src/shared/useGraceArea.ts +11 -8
|
@@ -31,7 +31,7 @@ export const [injectComboboxContentContext, provideComboboxContentContext]
|
|
|
31
31
|
</script>
|
|
32
32
|
|
|
33
33
|
<script setup lang="ts">
|
|
34
|
-
import { computed, onMounted, onUnmounted, ref, toRefs } from 'vue';
|
|
34
|
+
import { computed, onMounted, onUnmounted, ref, toRefs, watch } from 'vue';
|
|
35
35
|
import { DismissableLayer } from '@/DismissableLayer';
|
|
36
36
|
import { FocusScope } from '@/FocusScope';
|
|
37
37
|
import { ListboxContent } from '@/Listbox';
|
|
@@ -47,6 +47,10 @@ const emits = defineEmits<ComboboxContentImplEmits>();
|
|
|
47
47
|
const { position } = toRefs(props);
|
|
48
48
|
const rootContext = injectComboboxRootContext();
|
|
49
49
|
|
|
50
|
+
const contentId = Symbol('ComboboxContent');
|
|
51
|
+
|
|
52
|
+
watch(position, (value) => rootContext.onContentPositionChange(contentId, value), { immediate: true });
|
|
53
|
+
|
|
50
54
|
const isEmpty = computed(() => rootContext.ignoreFilter.value
|
|
51
55
|
? rootContext.allItems.value.size === 0
|
|
52
56
|
: rootContext.filterState.value.count === 0,
|
|
@@ -94,6 +98,7 @@ onMounted(() => {
|
|
|
94
98
|
});
|
|
95
99
|
|
|
96
100
|
onUnmounted(() => {
|
|
101
|
+
rootContext.onContentUnmount(contentId);
|
|
97
102
|
const activeElement = getActiveElement();
|
|
98
103
|
if (isInputWithinContent.value && (!activeElement || activeElement === document.body)) {
|
|
99
104
|
rootContext.triggerElement.value?.focus();
|
|
@@ -113,6 +118,10 @@ function isEventTargetWithinCombobox(target: EventTarget | null) {
|
|
|
113
118
|
const control = label?.control;
|
|
114
119
|
return !!control && !!rootContext.parentElement.value?.contains(control);
|
|
115
120
|
}
|
|
121
|
+
|
|
122
|
+
const popperContentEvents = {
|
|
123
|
+
placed: () => rootContext.onContentPlaced(contentId),
|
|
124
|
+
};
|
|
116
125
|
</script>
|
|
117
126
|
|
|
118
127
|
<template>
|
|
@@ -158,6 +167,7 @@ function isEventTargetWithinCombobox(target: EventTarget | null) {
|
|
|
158
167
|
outline: 'none',
|
|
159
168
|
...(position === 'popper' ? popperStyle : {}),
|
|
160
169
|
}"
|
|
170
|
+
v-on="position === 'popper' ? popperContentEvents : {}"
|
|
161
171
|
>
|
|
162
172
|
<slot />
|
|
163
173
|
</component>
|
|
@@ -11,6 +11,9 @@ type ComboboxRootContext<T> = {
|
|
|
11
11
|
disabled: Ref<boolean>;
|
|
12
12
|
open: Ref<boolean>;
|
|
13
13
|
onOpenChange: (value: boolean) => void;
|
|
14
|
+
onContentPositionChange: (content: symbol, position: 'inline' | 'popper') => void;
|
|
15
|
+
onContentPlaced: (content: symbol) => void;
|
|
16
|
+
onContentUnmount: (content: symbol) => void;
|
|
14
17
|
isUserInputted: Ref<boolean>;
|
|
15
18
|
isVirtual: Ref<boolean>;
|
|
16
19
|
contentId: string;
|
|
@@ -86,6 +89,7 @@ import { createEventHook, useVModel } from '@vueuse/core';
|
|
|
86
89
|
import { computed, getCurrentInstance, nextTick, onMounted, ref, toRefs } from 'vue';
|
|
87
90
|
import { ListboxRoot } from '@/Listbox';
|
|
88
91
|
import { PopperRoot } from '@/Popper';
|
|
92
|
+
import { useComboboxContentPositioning } from './useComboboxContentPositioning';
|
|
89
93
|
|
|
90
94
|
const props = withDefaults(defineProps<ComboboxRootProps<T>>(), {
|
|
91
95
|
open: undefined,
|
|
@@ -150,6 +154,7 @@ const inputElement = ref<HTMLInputElement>();
|
|
|
150
154
|
const triggerElement = ref<HTMLElement>();
|
|
151
155
|
|
|
152
156
|
const highlightedElement = computed(() => primitiveElement.value?.highlightedElement ?? undefined);
|
|
157
|
+
const contentPositioning = useComboboxContentPositioning(open);
|
|
153
158
|
|
|
154
159
|
const allItems = ref<Map<string, string>>(new Map());
|
|
155
160
|
const allGroups = ref<Map<string, Set<string>>>(new Map());
|
|
@@ -225,14 +230,19 @@ provideComboboxRootContext({
|
|
|
225
230
|
disabled,
|
|
226
231
|
open,
|
|
227
232
|
onOpenChange,
|
|
233
|
+
...contentPositioning,
|
|
228
234
|
contentId: '',
|
|
229
235
|
isUserInputted,
|
|
230
236
|
isVirtual,
|
|
231
237
|
inputElement,
|
|
232
238
|
highlightedElement,
|
|
233
|
-
onInputElementChange: (val) =>
|
|
239
|
+
onInputElementChange: (val) => {
|
|
240
|
+
inputElement.value = val;
|
|
241
|
+
},
|
|
234
242
|
triggerElement,
|
|
235
|
-
onTriggerElementChange: (val) =>
|
|
243
|
+
onTriggerElementChange: (val) => {
|
|
244
|
+
triggerElement.value = val;
|
|
245
|
+
},
|
|
236
246
|
parentElement,
|
|
237
247
|
resetSearchTermOnSelect,
|
|
238
248
|
onResetSearchTerm: resetSearchTerm.on,
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
3
|
+
import { provideListboxHighlightScrollContext } from '@/Listbox/ListboxRoot.vue';
|
|
4
|
+
|
|
5
|
+
export function useComboboxContentPositioning(
|
|
6
|
+
open: Readonly<Ref<boolean>>,
|
|
7
|
+
) {
|
|
8
|
+
const contentPosition = ref<'inline' | 'popper'>('inline');
|
|
9
|
+
const contentPlaced = ref(false);
|
|
10
|
+
const currentContent = ref<symbol>();
|
|
11
|
+
const suppressHighlightScroll = computed(() => contentPosition.value === 'popper' && !contentPlaced.value);
|
|
12
|
+
let pendingHighlightScroll: (() => void) | undefined;
|
|
13
|
+
|
|
14
|
+
provideListboxHighlightScrollContext({
|
|
15
|
+
suppressHighlightScroll,
|
|
16
|
+
onHighlightScrollRequest(scroll) {
|
|
17
|
+
pendingHighlightScroll = scroll;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
function onContentPositionChange(content: symbol, position: 'inline' | 'popper') {
|
|
22
|
+
if (currentContent.value !== content || contentPosition.value !== position) {
|
|
23
|
+
contentPlaced.value = false;
|
|
24
|
+
pendingHighlightScroll = undefined;
|
|
25
|
+
}
|
|
26
|
+
currentContent.value = content;
|
|
27
|
+
contentPosition.value = position;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function onContentPlaced(content: symbol) {
|
|
31
|
+
if (currentContent.value !== content || contentPosition.value !== 'popper' || contentPlaced.value) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
contentPlaced.value = true;
|
|
36
|
+
const scroll = pendingHighlightScroll;
|
|
37
|
+
pendingHighlightScroll = undefined;
|
|
38
|
+
if (open.value) {
|
|
39
|
+
scroll?.();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function onContentUnmount(content: symbol) {
|
|
44
|
+
if (currentContent.value !== content) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
currentContent.value = undefined;
|
|
49
|
+
contentPosition.value = 'inline';
|
|
50
|
+
contentPlaced.value = false;
|
|
51
|
+
pendingHighlightScroll = undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
onContentPositionChange,
|
|
56
|
+
onContentPlaced,
|
|
57
|
+
onContentUnmount,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -16,6 +16,7 @@ export interface DialogContentProps extends Omit<DialogContentImplProps, 'trapFo
|
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<script setup lang="ts">
|
|
19
|
+
import { computed } from 'vue';
|
|
19
20
|
import { Presence } from '@/Presence';
|
|
20
21
|
import { useEmitAsProps, useForwardExpose } from '@/shared';
|
|
21
22
|
import DialogContentModal from './DialogContentModal.vue';
|
|
@@ -38,28 +39,38 @@ const rootContext = injectDialogRootContext();
|
|
|
38
39
|
|
|
39
40
|
const emitsAsProps = useEmitAsProps(emits);
|
|
40
41
|
const { forwardRef } = useForwardExpose();
|
|
42
|
+
|
|
43
|
+
// The node stays in the DOM across open/close when force-mounted, or when the
|
|
44
|
+
// root opts out of unmounting. Only then does the child need the real presence
|
|
45
|
+
// state: mount-keyed behaviour (`FocusScope`'s auto-focus, layer stacks) has to
|
|
46
|
+
// be re-keyed on `present` because no physical unmount happens. When the node
|
|
47
|
+
// does unmount on close, keep passing a constant `true` so the child is never
|
|
48
|
+
// briefly told it is absent while `usePresence` settles on `MOUNT`.
|
|
49
|
+
const staysMounted = computed(
|
|
50
|
+
() => props.forceMount || !rootContext.unmountOnHide.value,
|
|
51
|
+
);
|
|
41
52
|
</script>
|
|
42
53
|
|
|
43
54
|
<template>
|
|
44
55
|
<Presence
|
|
45
56
|
v-slot="{ present }"
|
|
46
|
-
:present="
|
|
47
|
-
:force-mount="
|
|
57
|
+
:present="rootContext.open.value"
|
|
58
|
+
:force-mount="staysMounted"
|
|
48
59
|
>
|
|
49
60
|
<DialogContentModal
|
|
50
61
|
v-if="rootContext.modal.value"
|
|
51
|
-
v-show="rootContext.unmountOnHide.value || present"
|
|
62
|
+
v-show="forceMount || rootContext.unmountOnHide.value || present"
|
|
52
63
|
:ref="forwardRef"
|
|
53
|
-
:present="
|
|
64
|
+
:present="staysMounted ? present : true"
|
|
54
65
|
v-bind="{ ...props, ...emitsAsProps, ...$attrs }"
|
|
55
66
|
>
|
|
56
67
|
<slot />
|
|
57
68
|
</DialogContentModal>
|
|
58
69
|
<DialogContentNonModal
|
|
59
70
|
v-else
|
|
60
|
-
v-show="rootContext.unmountOnHide.value || present"
|
|
71
|
+
v-show="forceMount || rootContext.unmountOnHide.value || present"
|
|
61
72
|
:ref="forwardRef"
|
|
62
|
-
:present="
|
|
73
|
+
:present="staysMounted ? present : true"
|
|
63
74
|
v-bind="{ ...props, ...emitsAsProps, ...$attrs }"
|
|
64
75
|
>
|
|
65
76
|
<slot />
|
|
@@ -13,29 +13,37 @@ export interface DialogOverlayProps extends DialogOverlayImplProps {
|
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<script setup lang="ts">
|
|
16
|
+
import { computed } from 'vue';
|
|
16
17
|
import { Presence } from '@/Presence';
|
|
17
18
|
import { injectDialogRootContext } from './DialogRoot.vue';
|
|
18
19
|
|
|
19
|
-
defineProps<DialogOverlayProps>();
|
|
20
|
+
const props = defineProps<DialogOverlayProps>();
|
|
20
21
|
const rootContext = injectDialogRootContext();
|
|
21
22
|
|
|
22
23
|
const { forwardRef } = useForwardExpose();
|
|
24
|
+
|
|
25
|
+
// See `DialogContent.vue`: when the overlay is kept mounted across open/close it
|
|
26
|
+
// must report the real presence state, otherwise `DialogOverlayImpl` keeps the
|
|
27
|
+
// body scroll locked after the dialog is dismissed.
|
|
28
|
+
const staysMounted = computed(
|
|
29
|
+
() => props.forceMount || !rootContext.unmountOnHide.value,
|
|
30
|
+
);
|
|
23
31
|
</script>
|
|
24
32
|
|
|
25
33
|
<template>
|
|
26
34
|
<Presence
|
|
27
35
|
v-if="rootContext?.modal.value"
|
|
28
36
|
v-slot="{ present }"
|
|
29
|
-
:present="
|
|
30
|
-
:force-mount="
|
|
37
|
+
:present="rootContext.open.value"
|
|
38
|
+
:force-mount="staysMounted"
|
|
31
39
|
>
|
|
32
40
|
<DialogOverlayImpl
|
|
33
|
-
v-show="rootContext.unmountOnHide.value || present"
|
|
41
|
+
v-show="forceMount || rootContext.unmountOnHide.value || present"
|
|
34
42
|
v-bind="$attrs"
|
|
35
43
|
:ref="forwardRef"
|
|
36
44
|
:as="as"
|
|
37
45
|
:as-child="asChild"
|
|
38
|
-
:present="
|
|
46
|
+
:present="staysMounted ? present : true"
|
|
39
47
|
>
|
|
40
48
|
<slot />
|
|
41
49
|
</DialogOverlayImpl>
|
|
@@ -109,6 +109,11 @@ const isPointerEventsEnabled = computed(() => {
|
|
|
109
109
|
return index.value >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
+
// A layer that stays mounted while hidden (e.g. a Dialog with `unmountOnHide: false`)
|
|
113
|
+
// must not listen while it is not present, hence the `present` guard passed as `enabled`.
|
|
114
|
+
// On touch the dispatch is deferred to the `click` event, so a `pointerdown` captured
|
|
115
|
+
// while hidden would be delivered right after the layer opened and dismiss it on the
|
|
116
|
+
// very interaction that opened it.
|
|
112
117
|
const pointerDownOutside = usePointerDownOutside(async (event) => {
|
|
113
118
|
const isPointerDownOnBranch = [...context.branches].some((branch) =>
|
|
114
119
|
branch?.contains(event.target as HTMLElement),
|
|
@@ -123,7 +128,7 @@ const pointerDownOutside = usePointerDownOutside(async (event) => {
|
|
|
123
128
|
if (!event.defaultPrevented) {
|
|
124
129
|
emits('dismiss');
|
|
125
130
|
}
|
|
126
|
-
}, layerElement);
|
|
131
|
+
}, layerElement, () => props.present);
|
|
127
132
|
|
|
128
133
|
const focusOutside = useFocusOutside((event) => {
|
|
129
134
|
const isFocusInBranch = [...context.branches].some((branch) =>
|
|
@@ -13,11 +13,20 @@ import { context } from './context';
|
|
|
13
13
|
const props = defineProps<DismissableLayerBranchProps>();
|
|
14
14
|
|
|
15
15
|
const { forwardRef, currentElement } = useForwardExpose();
|
|
16
|
+
|
|
17
|
+
let registeredElement: HTMLElement | null = null;
|
|
18
|
+
|
|
16
19
|
onMounted(() => {
|
|
17
|
-
|
|
20
|
+
registeredElement = currentElement.value;
|
|
21
|
+
if (registeredElement) {
|
|
22
|
+
context.branches.add(registeredElement);
|
|
23
|
+
}
|
|
18
24
|
});
|
|
19
25
|
onUnmounted(() => {
|
|
20
|
-
|
|
26
|
+
if (registeredElement) {
|
|
27
|
+
context.branches.delete(registeredElement);
|
|
28
|
+
registeredElement = null;
|
|
29
|
+
}
|
|
21
30
|
});
|
|
22
31
|
</script>
|
|
23
32
|
|
|
@@ -18,6 +18,17 @@ export function isLayerExist(layerElement: HTMLElement, targetElement: HTMLEleme
|
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// Anything inside the layer's own root element is inside the layer. The root
|
|
22
|
+
// can differ from the `[data-dismissable-layer]` element when the layer is
|
|
23
|
+
// rendered `asChild` into a component whose root is not the element that
|
|
24
|
+
// receives its attrs (e.g. `PopperContent`'s wrapper `div`). `FocusScope`
|
|
25
|
+
// resolves the same root as its container and may focus it as a fallback
|
|
26
|
+
// when the content has no tabbable children; that focus must not read as
|
|
27
|
+
// focus-outside and dismiss the layer it belongs to.
|
|
28
|
+
if (layerElement.contains(targetElement)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
const targetLayer = targetElement.closest(
|
|
22
33
|
'[data-dismissable-layer]',
|
|
23
34
|
);
|
|
@@ -67,6 +78,11 @@ export function usePointerDownOutside(
|
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
if (isLayerExist(element.value, target)) {
|
|
81
|
+
// A touch `pointerdown` outside arms a one-shot `click` listener that
|
|
82
|
+
// never fires when the tap becomes a scroll/drag. Drop it here so the
|
|
83
|
+
// next tap inside a layer cannot trigger the stale dismissal (mirrors
|
|
84
|
+
// Radix's inside-tree branch, radix-ui/primitives#2171).
|
|
85
|
+
ownerDocument.removeEventListener('click', handleClickRef.value);
|
|
70
86
|
isPointerInsideDOMTree.value = false;
|
|
71
87
|
return;
|
|
72
88
|
}
|
|
@@ -14,7 +14,13 @@ import { useEmitAsProps, useForwardExpose, useHideOthers } from '@/shared';
|
|
|
14
14
|
import DrawerContentImpl from './DrawerContentImpl.vue';
|
|
15
15
|
import { injectDrawerRootContext } from './DrawerRoot.vue';
|
|
16
16
|
|
|
17
|
-
const props =
|
|
17
|
+
const props = withDefaults(
|
|
18
|
+
defineProps<DrawerContentProps>(),
|
|
19
|
+
{
|
|
20
|
+
initialFocus: true,
|
|
21
|
+
finalFocus: true,
|
|
22
|
+
},
|
|
23
|
+
);
|
|
18
24
|
const emits = defineEmits<DrawerContentEmits>();
|
|
19
25
|
|
|
20
26
|
const rootContext = injectDrawerRootContext();
|
|
@@ -33,12 +39,22 @@ const shouldTrapFocus = computed(() => (isFullModal.value || isTrapFocusOnly.val
|
|
|
33
39
|
const shouldHideOthers = computed(() => isFullModal.value ? currentElement.value : undefined);
|
|
34
40
|
useHideOthers(shouldHideOthers);
|
|
35
41
|
|
|
42
|
+
function finalFocusElement() {
|
|
43
|
+
if (props.finalFocus === false) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
if (props.finalFocus instanceof HTMLElement) {
|
|
47
|
+
return props.finalFocus;
|
|
48
|
+
}
|
|
49
|
+
return rootContext.triggerElement.value;
|
|
50
|
+
}
|
|
51
|
+
|
|
36
52
|
// Non-modal handlers defined as named functions so the refs are accessed via
|
|
37
53
|
// `.value` explicitly and the reads/writes are unambiguous.
|
|
38
54
|
function onCloseAutoFocusNonModal(e: Event) {
|
|
39
55
|
if (!e.defaultPrevented) {
|
|
40
56
|
if (!hasInteractedOutside.value) {
|
|
41
|
-
|
|
57
|
+
finalFocusElement()?.focus();
|
|
42
58
|
}
|
|
43
59
|
e.preventDefault();
|
|
44
60
|
}
|
|
@@ -74,7 +90,7 @@ function onInteractOutsideNonModal(e: any) {
|
|
|
74
90
|
@close-auto-focus="(e: Event) => {
|
|
75
91
|
if (!e.defaultPrevented) {
|
|
76
92
|
e.preventDefault()
|
|
77
|
-
|
|
93
|
+
finalFocusElement()?.focus()
|
|
78
94
|
}
|
|
79
95
|
}"
|
|
80
96
|
@pointer-down-outside="(e: any) => {
|
|
@@ -34,13 +34,20 @@ import { useResizeObserver } from '@vueuse/core';
|
|
|
34
34
|
import { computed, onMounted, onUnmounted, watch } from 'vue';
|
|
35
35
|
import { DismissableLayer } from '@/DismissableLayer';
|
|
36
36
|
import { FocusScope } from '@/FocusScope';
|
|
37
|
+
import { focus } from '@/FocusScope/utils';
|
|
37
38
|
import { useForwardExpose } from '@/shared';
|
|
38
39
|
import { useDrawerSnapPoints } from './composables/useDrawerSnapPoints';
|
|
39
40
|
import { useSwipeDismiss } from './composables/useSwipeDismiss';
|
|
40
41
|
import { injectDrawerRootContext } from './DrawerRoot.vue';
|
|
41
42
|
import { computeSwipeReleaseScalar, DRAWER_CSS_VARS, getDisplacement, registerDrawerCssProperties } from './utils';
|
|
42
43
|
|
|
43
|
-
const props =
|
|
44
|
+
const props = withDefaults(
|
|
45
|
+
defineProps<DrawerContentImplProps>(),
|
|
46
|
+
{
|
|
47
|
+
initialFocus: true,
|
|
48
|
+
finalFocus: true,
|
|
49
|
+
},
|
|
50
|
+
);
|
|
44
51
|
const emits = defineEmits<DrawerContentImplEmits>();
|
|
45
52
|
|
|
46
53
|
const rootContext = injectDrawerRootContext();
|
|
@@ -261,6 +268,19 @@ function onInteractOutside(event: any) {
|
|
|
261
268
|
emits('interactOutside', event);
|
|
262
269
|
}
|
|
263
270
|
|
|
271
|
+
function onMountAutoFocus(event: Event) {
|
|
272
|
+
emits('openAutoFocus', event);
|
|
273
|
+
if (event.defaultPrevented) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (props.initialFocus === false) {
|
|
277
|
+
event.preventDefault();
|
|
278
|
+
} else if (props.initialFocus instanceof HTMLElement) {
|
|
279
|
+
event.preventDefault();
|
|
280
|
+
focus(props.initialFocus, { select: true });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
264
284
|
// --- update:openComplete wiring ---
|
|
265
285
|
// Fire `update:openComplete` on the popup's own transitionend/animationend,
|
|
266
286
|
// not on a microtask — consumers rely on this marker to know the enter/exit
|
|
@@ -370,7 +390,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
370
390
|
as-child
|
|
371
391
|
loop
|
|
372
392
|
:trapped="props.trapFocus"
|
|
373
|
-
@mount-auto-focus="
|
|
393
|
+
@mount-auto-focus="onMountAutoFocus"
|
|
374
394
|
@unmount-auto-focus="emits('closeAutoFocus', $event)"
|
|
375
395
|
>
|
|
376
396
|
<DismissableLayer
|
|
@@ -69,6 +69,7 @@ export interface DrawerRootContext {
|
|
|
69
69
|
isSwiping: Ref<boolean>;
|
|
70
70
|
nestedSwipeProgressStore: NestedSwipeProgressStore;
|
|
71
71
|
onOpenChange: (value: boolean, reason?: DrawerOpenChangeReason) => void;
|
|
72
|
+
onOpenToggle: () => void;
|
|
72
73
|
notifyOpenComplete: (value: boolean) => void;
|
|
73
74
|
setActiveSnapPoint: (point: DrawerSnapPoint | null) => void;
|
|
74
75
|
onPopupHeightChange: (height: number) => void;
|
|
@@ -165,14 +166,8 @@ provideDrawerRootContext({
|
|
|
165
166
|
nestedSwiping,
|
|
166
167
|
isSwiping,
|
|
167
168
|
nestedSwipeProgressStore,
|
|
168
|
-
onOpenChange
|
|
169
|
-
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
const details: DrawerOpenChangeDetails | undefined = reason ? { reason } : undefined;
|
|
173
|
-
uncontrolledOpen.value = value;
|
|
174
|
-
emit('update:open', value, details);
|
|
175
|
-
},
|
|
169
|
+
onOpenChange: handleOpenChange,
|
|
170
|
+
onOpenToggle: handleOpenToggle,
|
|
176
171
|
notifyOpenComplete(value) {
|
|
177
172
|
emit('update:openComplete', value);
|
|
178
173
|
},
|
|
@@ -219,11 +214,20 @@ provideDrawerRootContext({
|
|
|
219
214
|
});
|
|
220
215
|
|
|
221
216
|
function handleClose() {
|
|
222
|
-
|
|
217
|
+
handleOpenChange(false, 'close-press');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function handleOpenChange(value: boolean, reason?: DrawerOpenChangeReason) {
|
|
221
|
+
if (open.value === value) {
|
|
223
222
|
return;
|
|
224
223
|
}
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
const details: DrawerOpenChangeDetails | undefined = reason ? { reason } : undefined;
|
|
225
|
+
uncontrolledOpen.value = value;
|
|
226
|
+
emit('update:open', value, details);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function handleOpenToggle() {
|
|
230
|
+
handleOpenChange(!open.value, 'trigger-press');
|
|
227
231
|
}
|
|
228
232
|
|
|
229
233
|
// Sync open state with DrawerProvider
|
|
@@ -38,7 +38,7 @@ onUnmounted(() => {
|
|
|
38
38
|
:aria-expanded="rootContext.open.value"
|
|
39
39
|
:aria-controls="rootContext.open.value ? rootContext.contentId : undefined"
|
|
40
40
|
:data-state="rootContext.open.value ? 'open' : 'closed'"
|
|
41
|
-
@click="rootContext.
|
|
41
|
+
@click="rootContext.onOpenToggle"
|
|
42
42
|
>
|
|
43
43
|
<slot />
|
|
44
44
|
</Primitive>
|
|
@@ -35,6 +35,10 @@ export interface UseSwipeDismissOptions {
|
|
|
35
35
|
const DEFAULT_SWIPE_THRESHOLD = 40;
|
|
36
36
|
const REVERSE_CANCEL_THRESHOLD = 10;
|
|
37
37
|
const MIN_DRAG_THRESHOLD = 1;
|
|
38
|
+
// Travel an axis must cover from the touch origin to claim the gesture, and the
|
|
39
|
+
// margin the cross axis must beat the drawer axis by to win it.
|
|
40
|
+
const AXIS_LOCK_SLOP = 6;
|
|
41
|
+
const AXIS_LOCK_BIAS = 2;
|
|
38
42
|
const MIN_RELEASE_VELOCITY_DURATION_MS = 16;
|
|
39
43
|
const MAX_RELEASE_VELOCITY_AGE_MS = 80;
|
|
40
44
|
const DEFAULT_IGNORE_SELECTOR = 'button,a,input,select,textarea,label,[role="button"]';
|
|
@@ -132,6 +136,15 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
132
136
|
const allowLeft = computed(() => toValue(directions).includes('left'));
|
|
133
137
|
const allowRight = computed(() => toValue(directions).includes('right'));
|
|
134
138
|
|
|
139
|
+
// The axis the drawer dismisses along, or `null` when both axes are
|
|
140
|
+
// dismissable and there is no cross axis to yield native scrolling to.
|
|
141
|
+
const drawerAxis = computed<'vertical' | 'horizontal' | null>(() => {
|
|
142
|
+
if (hasVertical.value === hasHorizontal.value) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
return hasVertical.value ? 'vertical' : 'horizontal';
|
|
146
|
+
});
|
|
147
|
+
|
|
135
148
|
const isSwiping = ref(false);
|
|
136
149
|
const swipeDirection = ref<SwipeDirection | undefined>(undefined);
|
|
137
150
|
const dragOffset = ref({ x: 0, y: 0 });
|
|
@@ -146,6 +159,10 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
146
159
|
let pendingSwipeStartPos: { x: number; y: number } | null = null;
|
|
147
160
|
let swipeFromScrollable = false;
|
|
148
161
|
let scrollableAncestor: HTMLElement | null = null;
|
|
162
|
+
// Cross-axis arbitration state (touch only), reset per gesture.
|
|
163
|
+
let crossAxisScrollable: HTMLElement | null = null;
|
|
164
|
+
let drawerAxisAttributed = false;
|
|
165
|
+
let preserveNativeCrossAxisScroll = false;
|
|
149
166
|
let elementSize = { width: 0, height: 0 };
|
|
150
167
|
let swipeProgress = 0;
|
|
151
168
|
let lastDragSample: { x: number; y: number; time: number } | null = null;
|
|
@@ -217,6 +234,9 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
217
234
|
resetGestureState();
|
|
218
235
|
swipeFromScrollable = false;
|
|
219
236
|
scrollableAncestor = null;
|
|
237
|
+
crossAxisScrollable = null;
|
|
238
|
+
drawerAxisAttributed = false;
|
|
239
|
+
preserveNativeCrossAxisScroll = false;
|
|
220
240
|
activePointerId = null;
|
|
221
241
|
pointerStarted = false;
|
|
222
242
|
}
|
|
@@ -261,6 +281,54 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
261
281
|
return { x: newDx, y: newDy };
|
|
262
282
|
}
|
|
263
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Arbitrates a touchmove between the drawer swipe and a native scroll on the
|
|
286
|
+
* cross axis. Returns `true` when the move must be left alone — the cross axis
|
|
287
|
+
* already won the gesture, or neither axis has passed the slop yet.
|
|
288
|
+
*/
|
|
289
|
+
function shouldYieldTouchMove(e: TouchEvent, pos: { x: number; y: number }): boolean {
|
|
290
|
+
if (preserveNativeCrossAxisScroll) {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Attribution happens once per gesture: the slop is measured from the touch
|
|
295
|
+
// origin, which is never re-baselined, so re-arbitrating mid-drag would
|
|
296
|
+
// freeze the drawer and drop `preventDefault()`.
|
|
297
|
+
if (drawerAxisAttributed || !crossAxisScrollable || !drawerAxis.value) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// The browser has already committed the gesture to a native scroll.
|
|
302
|
+
if (!e.cancelable) {
|
|
303
|
+
preserveNativeCrossAxisScroll = true;
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const isVerticalDrawerAxis = drawerAxis.value === 'vertical';
|
|
308
|
+
const drawerAxisDelta = isVerticalDrawerAxis ? pos.y - dragStartPos.y : pos.x - dragStartPos.x;
|
|
309
|
+
const crossAxisDelta = isVerticalDrawerAxis ? pos.x - dragStartPos.x : pos.y - dragStartPos.y;
|
|
310
|
+
const absDrawerAxisDelta = Math.abs(drawerAxisDelta);
|
|
311
|
+
const absCrossAxisDelta = Math.abs(crossAxisDelta);
|
|
312
|
+
|
|
313
|
+
if (
|
|
314
|
+
absCrossAxisDelta >= AXIS_LOCK_SLOP
|
|
315
|
+
&& absCrossAxisDelta > absDrawerAxisDelta + AXIS_LOCK_BIAS
|
|
316
|
+
) {
|
|
317
|
+
preserveNativeCrossAxisScroll = true;
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (absDrawerAxisDelta >= AXIS_LOCK_SLOP) {
|
|
322
|
+
drawerAxisAttributed = true;
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Unattributed. Leave the event alone: on iOS, `preventDefault()` on the
|
|
327
|
+
// first cancelable touchmove cancels native scrolling for the whole gesture,
|
|
328
|
+
// locking out a cross-axis scroll that only passes the slop on a later move.
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
|
|
264
332
|
function processMove(el: HTMLElement, pos: { x: number; y: number }, time: number) {
|
|
265
333
|
const rawDx = pos.x - dragStartPos.x;
|
|
266
334
|
const rawDy = pos.y - dragStartPos.y;
|
|
@@ -513,6 +581,12 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
513
581
|
return;
|
|
514
582
|
}
|
|
515
583
|
|
|
584
|
+
// A gesture whose end we never saw would otherwise leak its verdict into
|
|
585
|
+
// this one, permanently muting the swipe.
|
|
586
|
+
crossAxisScrollable = null;
|
|
587
|
+
drawerAxisAttributed = false;
|
|
588
|
+
preserveNativeCrossAxisScroll = false;
|
|
589
|
+
|
|
516
590
|
if (!options.ignoreScrollableAncestors) {
|
|
517
591
|
const axis = hasVertical.value ? 'vertical' : 'horizontal';
|
|
518
592
|
const scrollable = findScrollableAncestor(target, axis);
|
|
@@ -522,6 +596,15 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
522
596
|
}
|
|
523
597
|
}
|
|
524
598
|
|
|
599
|
+
// The scroller on the axis the drawer does NOT dismiss along, so
|
|
600
|
+
// `shouldYieldTouchMove` can hand the gesture to it. Deliberately not gated
|
|
601
|
+
// on `ignoreScrollableAncestors`: that option is about starting a swipe from
|
|
602
|
+
// inside a scroller on the dismiss axis.
|
|
603
|
+
if (drawerAxis.value) {
|
|
604
|
+
const crossAxis = drawerAxis.value === 'vertical' ? 'horizontal' : 'vertical';
|
|
605
|
+
crossAxisScrollable = findScrollableAncestor(target, crossAxis);
|
|
606
|
+
}
|
|
607
|
+
|
|
525
608
|
const t = e.touches[0];
|
|
526
609
|
if (!t) {
|
|
527
610
|
return;
|
|
@@ -542,6 +625,11 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
542
625
|
|
|
543
626
|
const pos = { x: t.clientX, y: t.clientY };
|
|
544
627
|
|
|
628
|
+
// Bailing here leaves the move untouched, so the browser can scroll natively.
|
|
629
|
+
if (shouldYieldTouchMove(e, pos)) {
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
|
|
545
633
|
if (swipeFromScrollable && pendingSwipe && scrollableAncestor) {
|
|
546
634
|
const dx = pos.x - dragStartPos.x;
|
|
547
635
|
const dy = pos.y - dragStartPos.y;
|
|
@@ -6,7 +6,7 @@ export interface DropdownMenuFilterProps extends PrimitiveProps {
|
|
|
6
6
|
modelValue?: string;
|
|
7
7
|
/** Focus on element when mounted. */
|
|
8
8
|
autoFocus?: boolean;
|
|
9
|
-
/** When `true`, prevents the user from interacting with
|
|
9
|
+
/** When `true`, prevents the user from interacting with the filter input */
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -157,6 +157,17 @@ watchEffect((cleanupFn) => {
|
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
// Confirm focus was actually orphaned before pulling it back. `lastFocusedElement`
|
|
161
|
+
// is only tracked while the scope is not paused, so an open popper (which pauses
|
|
162
|
+
// this trap and only resumes it in a `setTimeout`) leaves it pointing at a stale
|
|
163
|
+
// element. Without this check, an element focused inside the container during that
|
|
164
|
+
// window — e.g. a view swapped in by the popper's `select` handler focusing its own
|
|
165
|
+
// input on mount — would be robbed of focus.
|
|
166
|
+
const activeElement = getActiveElement();
|
|
167
|
+
if (activeElement && container.contains(activeElement)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
160
171
|
const isLastFocusedElementExist = container.contains(lastFocusedElement);
|
|
161
172
|
if (!isLastFocusedElementExist) {
|
|
162
173
|
focus(container);
|
|
@@ -77,7 +77,7 @@ provideListboxItemContext({
|
|
|
77
77
|
:id="id"
|
|
78
78
|
v-bind="$attrs"
|
|
79
79
|
:ref="forwardRef"
|
|
80
|
-
v-memo="[isHighlighted, isSelected, disabled, rootContext.focusable.value]"
|
|
80
|
+
v-memo="[isHighlighted, isSelected, disabled, rootContext.focusable.value, ...Object.entries($attrs).flat()]"
|
|
81
81
|
role="option"
|
|
82
82
|
:tabindex="rootContext.focusable.value ? isHighlighted ? '0' : '-1' : -1"
|
|
83
83
|
:aria-selected="isSelected"
|