akar 2.0.14 → 2.0.17
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/AutocompleteInput.cjs +4 -2
- package/dist/Autocomplete/AutocompleteInput.cjs.map +1 -1
- package/dist/Autocomplete/AutocompleteInput.js +4 -2
- package/dist/Autocomplete/AutocompleteInput.js.map +1 -1
- 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/ComboboxInput.cjs +4 -2
- package/dist/Combobox/ComboboxInput.cjs.map +1 -1
- package/dist/Combobox/ComboboxInput.js +4 -2
- package/dist/Combobox/ComboboxInput.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 +7 -7
- package/dist/DateField/DateFieldRoot.cjs.map +1 -1
- package/dist/DateField/DateFieldRoot.js +7 -7
- package/dist/DateField/DateFieldRoot.js.map +1 -1
- 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 +5 -5
- package/dist/DateRangeField/DateRangeFieldRoot.cjs.map +1 -1
- package/dist/DateRangeField/DateRangeFieldRoot.js +5 -5
- package/dist/DateRangeField/DateRangeFieldRoot.js.map +1 -1
- 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 +13 -24
- package/dist/DismissableLayer/DismissableLayer.cjs.map +1 -1
- package/dist/DismissableLayer/DismissableLayer.js +4 -9
- package/dist/DismissableLayer/DismissableLayer.js.map +1 -1
- package/dist/DismissableLayer/DismissableLayerBranch.cjs +8 -3
- package/dist/DismissableLayer/DismissableLayerBranch.cjs.map +1 -1
- package/dist/DismissableLayer/DismissableLayerBranch.js +8 -3
- package/dist/DismissableLayer/DismissableLayerBranch.js.map +1 -1
- package/dist/DismissableLayer/context.cjs +19 -0
- package/dist/DismissableLayer/context.cjs.map +1 -0
- package/dist/DismissableLayer/context.js +13 -0
- package/dist/DismissableLayer/context.js.map +1 -0
- 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/DropdownMenu/DropdownMenuFilter.cjs +4 -2
- package/dist/DropdownMenu/DropdownMenuFilter.cjs.map +1 -1
- package/dist/DropdownMenu/DropdownMenuFilter.js +4 -2
- package/dist/DropdownMenu/DropdownMenuFilter.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/ListboxFilter.cjs +4 -2
- package/dist/Listbox/ListboxFilter.cjs.map +1 -1
- package/dist/Listbox/ListboxFilter.js +4 -2
- package/dist/Listbox/ListboxFilter.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/NumberFieldInput.cjs +1 -0
- package/dist/NumberField/NumberFieldInput.cjs.map +1 -1
- package/dist/NumberField/NumberFieldInput.js +1 -0
- package/dist/NumberField/NumberFieldInput.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/Presence/usePresence.cjs +3 -2
- package/dist/Presence/usePresence.cjs.map +1 -1
- package/dist/Presence/usePresence.js +3 -2
- package/dist/Presence/usePresence.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/Rating/RatingRoot.cjs +7 -1
- package/dist/Rating/RatingRoot.cjs.map +1 -1
- package/dist/Rating/RatingRoot.js +7 -1
- package/dist/Rating/RatingRoot.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/Stepper/StepperIndicator.cjs +2 -1
- package/dist/Stepper/StepperIndicator.cjs.map +1 -1
- package/dist/Stepper/StepperIndicator.js +2 -1
- package/dist/Stepper/StepperIndicator.js.map +1 -1
- package/dist/Stepper/StepperTrigger.cjs +7 -2
- package/dist/Stepper/StepperTrigger.cjs.map +1 -1
- package/dist/Stepper/StepperTrigger.js +7 -2
- package/dist/Stepper/StepperTrigger.js.map +1 -1
- package/dist/TagsInput/TagsInputRoot.cjs +5 -3
- package/dist/TagsInput/TagsInputRoot.cjs.map +1 -1
- package/dist/TagsInput/TagsInputRoot.js +6 -4
- package/dist/TagsInput/TagsInputRoot.js.map +1 -1
- package/dist/TimeField/TimeFieldRoot.cjs +1 -1
- package/dist/TimeField/TimeFieldRoot.cjs.map +1 -1
- package/dist/TimeField/TimeFieldRoot.js +1 -1
- package/dist/TimeField/TimeFieldRoot.js.map +1 -1
- package/dist/TimeRangeField/TimeRangeFieldRoot.cjs +1 -1
- package/dist/TimeRangeField/TimeRangeFieldRoot.cjs.map +1 -1
- package/dist/TimeRangeField/TimeRangeFieldRoot.js +1 -1
- package/dist/TimeRangeField/TimeRangeFieldRoot.js.map +1 -1
- package/dist/Toast/ToastRootImpl.cjs +2 -2
- package/dist/Toast/ToastRootImpl.cjs.map +1 -1
- package/dist/Toast/ToastRootImpl.js +2 -2
- package/dist/Toast/ToastRootImpl.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 +101 -18
- package/dist/composables/useSwipeDismiss.cjs.map +1 -1
- package/dist/composables/useSwipeDismiss.js +101 -18
- 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/index.cjs +2 -0
- package/dist/index.js +2 -0
- package/dist/index2.d.ts.map +1 -1
- package/dist/index3.d.cts +43 -16
- package/dist/index3.d.cts.map +1 -1
- package/dist/index3.d.ts +43 -16
- package/dist/index3.d.ts.map +1 -1
- package/dist/index4.d.cts +664 -658
- package/dist/index4.d.cts.map +1 -1
- package/dist/index4.d.ts +682 -676
- package/dist/index4.d.ts.map +1 -1
- package/dist/internal.cjs +1 -0
- package/dist/internal.d.cts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +1 -0
- package/dist/shared/useBodyScrollLock.cjs +6 -5
- package/dist/shared/useBodyScrollLock.cjs.map +1 -1
- package/dist/shared/useBodyScrollLock.js +6 -5
- package/dist/shared/useBodyScrollLock.js.map +1 -1
- package/dist/shared/useComposing.cjs +19 -0
- package/dist/shared/useComposing.cjs.map +1 -1
- package/dist/shared/useComposing.js +20 -1
- package/dist/shared/useComposing.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/shared.cjs +1 -0
- package/dist/shared.js +1 -0
- 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/dist/utils/validation.cjs +1 -0
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.js +1 -0
- package/dist/utils/validation.js.map +1 -1
- package/package.json +12 -14
- package/src/Autocomplete/AutocompleteInput.vue +3 -2
- package/src/Autocomplete/AutocompleteRoot.vue +3 -0
- package/src/Collection/Collection.ts +10 -1
- package/src/Combobox/ComboboxContentImpl.vue +11 -1
- package/src/Combobox/ComboboxInput.vue +3 -2
- package/src/Combobox/ComboboxRoot.vue +12 -2
- package/src/Combobox/useComboboxContentPositioning.ts +59 -0
- package/src/DateField/DateFieldRoot.vue +4 -1
- package/src/DateRangeField/DateRangeFieldRoot.vue +4 -1
- package/src/Dialog/DialogContent.vue +17 -6
- package/src/Dialog/DialogOverlay.vue +13 -5
- package/src/DismissableLayer/DismissableLayer.vue +8 -8
- package/src/DismissableLayer/DismissableLayerBranch.vue +12 -3
- package/src/DismissableLayer/context.ts +8 -0
- 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 +182 -26
- package/src/DropdownMenu/DropdownMenuFilter.vue +4 -3
- package/src/FocusScope/FocusScope.vue +11 -0
- package/src/Listbox/ListboxFilter.vue +3 -2
- 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/NumberFieldInput.vue +3 -0
- package/src/PinInput/PinInputInput.vue +54 -16
- package/src/PinInput/PinInputRoot.vue +5 -5
- package/src/Popover/PopoverTrigger.vue +2 -1
- package/src/Presence/usePresence.ts +6 -2
- package/src/RadioGroup/Radio.vue +1 -1
- package/src/Rating/RatingItemIndicator.vue +11 -1
- package/src/Rating/RatingRoot.vue +7 -0
- package/src/Select/SelectTrigger.vue +1 -1
- package/src/Splitter/utils/registry.ts +22 -0
- package/src/Splitter/utils/validation.ts +11 -7
- package/src/Stepper/StepperIndicator.vue +6 -1
- package/src/Stepper/StepperTrigger.vue +11 -2
- package/src/TagsInput/TagsInputRoot.vue +6 -4
- package/src/TimeField/TimeFieldRoot.vue +4 -1
- package/src/TimeRangeField/TimeRangeFieldRoot.vue +4 -1
- package/src/Toast/ToastRootImpl.vue +5 -2
- 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/useBodyScrollLock.ts +9 -1
- package/src/shared/useComposing.ts +53 -2
- 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
|
@@ -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;
|
|
@@ -190,7 +207,12 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
190
207
|
el.style.setProperty(movementCssVars.y, '0px');
|
|
191
208
|
}
|
|
192
209
|
|
|
193
|
-
|
|
210
|
+
/**
|
|
211
|
+
* Clears the per-gesture tracking state. Deliberately leaves the pointer
|
|
212
|
+
* identity and the touch scroll-guard flags alone, so it is safe to call at
|
|
213
|
+
* the start of a gesture as well as at the end of one.
|
|
214
|
+
*/
|
|
215
|
+
function resetGestureState() {
|
|
194
216
|
setSwiping(false);
|
|
195
217
|
swipeDirection.value = undefined;
|
|
196
218
|
dragOffset.value = { x: 0, y: 0 };
|
|
@@ -201,18 +223,30 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
201
223
|
isFirstMove = false;
|
|
202
224
|
pendingSwipe = false;
|
|
203
225
|
pendingSwipeStartPos = null;
|
|
204
|
-
swipeFromScrollable = false;
|
|
205
|
-
scrollableAncestor = null;
|
|
206
226
|
elementSize = { width: 0, height: 0 };
|
|
207
227
|
swipeProgress = 0;
|
|
208
228
|
lastDragSample = null;
|
|
209
229
|
lastVelocity = { x: 0, y: 0 };
|
|
210
230
|
lockedAxis = null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function reset() {
|
|
234
|
+
resetGestureState();
|
|
235
|
+
swipeFromScrollable = false;
|
|
236
|
+
scrollableAncestor = null;
|
|
237
|
+
crossAxisScrollable = null;
|
|
238
|
+
drawerAxisAttributed = false;
|
|
239
|
+
preserveNativeCrossAxisScroll = false;
|
|
211
240
|
activePointerId = null;
|
|
212
241
|
pointerStarted = false;
|
|
213
242
|
}
|
|
214
243
|
|
|
215
244
|
function startSwipe(el: HTMLElement, pos: { x: number; y: number }) {
|
|
245
|
+
// Start from a clean slate (BaseUI parity: `startSwipeAtPosition` resets the
|
|
246
|
+
// gesture refs on every press). A previous gesture whose end we never saw
|
|
247
|
+
// would otherwise leak `isSwiping`, the intended direction and the velocity
|
|
248
|
+
// samples into this one.
|
|
249
|
+
resetGestureState();
|
|
216
250
|
// Capture the element's current transform so we can account for it
|
|
217
251
|
getElementTransform(el);
|
|
218
252
|
dragStartPos = pos;
|
|
@@ -247,6 +281,54 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
247
281
|
return { x: newDx, y: newDy };
|
|
248
282
|
}
|
|
249
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
|
+
|
|
250
332
|
function processMove(el: HTMLElement, pos: { x: number; y: number }, time: number) {
|
|
251
333
|
const rawDx = pos.x - dragStartPos.x;
|
|
252
334
|
const rawDy = pos.y - dragStartPos.y;
|
|
@@ -272,24 +354,19 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
272
354
|
const dir: SwipeDirection | undefined = toValue(directions).find((d) => getDisplacement(d, dx, dy) > 0);
|
|
273
355
|
|
|
274
356
|
if (pendingSwipe && pendingSwipeStartPos) {
|
|
275
|
-
//
|
|
276
|
-
//
|
|
277
|
-
//
|
|
278
|
-
//
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
pos.y - pendingSwipeStartPos.y,
|
|
286
|
-
);
|
|
287
|
-
if (Math.abs(pending) < MIN_DRAG_THRESHOLD) {
|
|
357
|
+
// BaseUI parity (`useSwipeDismiss.ts:startSwipeAtPosition`): the drag is
|
|
358
|
+
// tracked from the first movement whatever its direction — the gesture
|
|
359
|
+
// does NOT need to point at a dismissable direction to begin. Movement
|
|
360
|
+
// along a non-dismissable direction still reaches
|
|
361
|
+
// `applyDirectionalDamping` below, which sqrt-damps it; that damped
|
|
362
|
+
// offset is the elastic "pull" feedback you get when dragging a bottom
|
|
363
|
+
// drawer upward. Bailing out on `!dir` instead would leave the drawer
|
|
364
|
+
// completely frozen until the user drags the dismissable way.
|
|
365
|
+
const pending = Math.max(Math.abs(dx), Math.abs(dy));
|
|
366
|
+
if (pending < MIN_DRAG_THRESHOLD) {
|
|
288
367
|
return;
|
|
289
368
|
}
|
|
290
369
|
pendingSwipe = false;
|
|
291
|
-
intendedDirection = dir;
|
|
292
|
-
swipeDirection.value = dir;
|
|
293
370
|
setSwiping(true);
|
|
294
371
|
onSwipeStart?.();
|
|
295
372
|
}
|
|
@@ -298,11 +375,21 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
298
375
|
return;
|
|
299
376
|
}
|
|
300
377
|
|
|
301
|
-
|
|
302
|
-
|
|
378
|
+
// The intended (dismissable) direction is adopted the first time the drag
|
|
379
|
+
// moves in one, which may be many moves after the swipe started — e.g. pull
|
|
380
|
+
// up, then push back down on a `down` drawer. Until then the gesture has no
|
|
381
|
+
// dismiss candidate and only rubber-bands.
|
|
382
|
+
if (!intendedDirection && dir) {
|
|
383
|
+
intendedDirection = dir;
|
|
384
|
+
swipeDirection.value = dir;
|
|
385
|
+
maxDisplacement = getDisplacement(dir, dx, dy);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const currentDir = intendedDirection;
|
|
303
389
|
|
|
304
390
|
// Detect reversal (cancel swipe)
|
|
305
|
-
if (!cancelledSwipe) {
|
|
391
|
+
if (currentDir && !cancelledSwipe) {
|
|
392
|
+
const displacement = getDisplacement(currentDir, dx, dy);
|
|
306
393
|
maxDisplacement = Math.max(maxDisplacement, displacement);
|
|
307
394
|
if (
|
|
308
395
|
maxDisplacement > DEFAULT_SWIPE_THRESHOLD / 2
|
|
@@ -321,14 +408,18 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
321
408
|
setCssVars(el, damped.x, damped.y);
|
|
322
409
|
recordSample({ x: damped.x, y: damped.y }, time);
|
|
323
410
|
|
|
324
|
-
// Progress: 0 = closed/start, 1 = fully dismissed
|
|
411
|
+
// Progress: 0 = closed/start, 1 = fully dismissed. Before a dismissable
|
|
412
|
+
// direction is adopted, measure against the primary one — a pull away from
|
|
413
|
+
// it yields a negative displacement, which clamps to 0 (BaseUI parity:
|
|
414
|
+
// `progressDirection = primaryDirection ?? intendedSwipeDirection`).
|
|
325
415
|
const currentEl = elementRef.value;
|
|
326
|
-
|
|
327
|
-
|
|
416
|
+
const progressDir = currentDir ?? toValue(directions)[0];
|
|
417
|
+
if (currentEl && progressDir) {
|
|
418
|
+
const dim = (progressDir === 'up' || progressDir === 'down')
|
|
328
419
|
? elementSize.height || currentEl.offsetHeight
|
|
329
420
|
: elementSize.width || currentEl.offsetWidth;
|
|
330
|
-
const threshold = getThreshold(currentEl,
|
|
331
|
-
const p = Math.min(1, Math.max(0,
|
|
421
|
+
const threshold = getThreshold(currentEl, progressDir);
|
|
422
|
+
const p = Math.min(1, Math.max(0, getDisplacement(progressDir, dx, dy) / (dim + threshold)));
|
|
332
423
|
if (p !== swipeProgress) {
|
|
333
424
|
swipeProgress = p;
|
|
334
425
|
onProgress?.(p, { deltaX: damped.x, deltaY: damped.y, direction: currentDir });
|
|
@@ -428,6 +519,13 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
428
519
|
return;
|
|
429
520
|
}
|
|
430
521
|
if ((e.buttons & 1) === 0) {
|
|
522
|
+
// The primary button is no longer held, but we never saw the release —
|
|
523
|
+
// it happened outside the window, over another application, or after the
|
|
524
|
+
// browser dropped pointer capture. Treat this move as the missing
|
|
525
|
+
// `pointerup`: without it the gesture stays wedged with `data-swiping`
|
|
526
|
+
// set (which pins the transition to 0ms), leaving the drawer frozen
|
|
527
|
+
// mid-pull and ignoring every subsequent drag.
|
|
528
|
+
finishSwipe(el);
|
|
431
529
|
return;
|
|
432
530
|
}
|
|
433
531
|
processMove(el, { x: e.clientX, y: e.clientY }, e.timeStamp);
|
|
@@ -439,6 +537,25 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
439
537
|
}
|
|
440
538
|
const el = elementRef.value;
|
|
441
539
|
if (!el) {
|
|
540
|
+
reset();
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
finishSwipe(el);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Ends an in-flight pointer drag that can no longer be tracked — pointer
|
|
548
|
+
* capture was lost, or the window lost focus mid-drag (which is what happens
|
|
549
|
+
* when the release lands over another application). The drawer settles from
|
|
550
|
+
* wherever it was last dragged to.
|
|
551
|
+
*/
|
|
552
|
+
function onPointerInterrupted() {
|
|
553
|
+
if (!pointerStarted) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const el = elementRef.value;
|
|
557
|
+
if (!el) {
|
|
558
|
+
reset();
|
|
442
559
|
return;
|
|
443
560
|
}
|
|
444
561
|
finishSwipe(el);
|
|
@@ -464,6 +581,12 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
464
581
|
return;
|
|
465
582
|
}
|
|
466
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
|
+
|
|
467
590
|
if (!options.ignoreScrollableAncestors) {
|
|
468
591
|
const axis = hasVertical.value ? 'vertical' : 'horizontal';
|
|
469
592
|
const scrollable = findScrollableAncestor(target, axis);
|
|
@@ -473,6 +596,15 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
473
596
|
}
|
|
474
597
|
}
|
|
475
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
|
+
|
|
476
608
|
const t = e.touches[0];
|
|
477
609
|
if (!t) {
|
|
478
610
|
return;
|
|
@@ -493,6 +625,11 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
493
625
|
|
|
494
626
|
const pos = { x: t.clientX, y: t.clientY };
|
|
495
627
|
|
|
628
|
+
// Bailing here leaves the move untouched, so the browser can scroll natively.
|
|
629
|
+
if (shouldYieldTouchMove(e, pos)) {
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
|
|
496
633
|
if (swipeFromScrollable && pendingSwipe && scrollableAncestor) {
|
|
497
634
|
const dx = pos.x - dragStartPos.x;
|
|
498
635
|
const dy = pos.y - dragStartPos.y;
|
|
@@ -556,16 +693,35 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions) {
|
|
|
556
693
|
return;
|
|
557
694
|
}
|
|
558
695
|
|
|
696
|
+
// BaseUI hangs the gesture off `Drawer.Viewport`, a `position: fixed;
|
|
697
|
+
// inset: 0` element, so the pointer can never leave the element that is
|
|
698
|
+
// listening. Here the listeners live on the popup itself, which the
|
|
699
|
+
// pointer leaves as soon as the drag goes past the drawer's bounds.
|
|
700
|
+
// `setPointerCapture` covers that for an ordinary in-window drag, but a
|
|
701
|
+
// release the popup never sees — outside the window, over another app, or
|
|
702
|
+
// after capture is dropped — would otherwise leave the gesture wedged.
|
|
703
|
+
// Mirror the pointer end events on the document and window so the drag
|
|
704
|
+
// can always be finished.
|
|
705
|
+
const doc = el.ownerDocument;
|
|
706
|
+
const win = doc.defaultView;
|
|
707
|
+
|
|
559
708
|
cleanups.push(
|
|
560
709
|
useEventListener(el, 'pointerdown', onPointerDown as EventListener),
|
|
561
710
|
useEventListener(el, 'pointermove', onPointerMove as EventListener),
|
|
562
711
|
useEventListener(el, 'pointerup', onPointerUp as EventListener),
|
|
563
712
|
useEventListener(el, 'pointercancel', onPointerUp as EventListener),
|
|
713
|
+
useEventListener(el, 'lostpointercapture', onPointerInterrupted as EventListener),
|
|
714
|
+
useEventListener(doc, 'pointerup', onPointerUp as EventListener),
|
|
715
|
+
useEventListener(doc, 'pointercancel', onPointerUp as EventListener),
|
|
564
716
|
useEventListener(el, 'touchstart', onTouchStart as EventListener, { passive: true }),
|
|
565
717
|
useEventListener(el, 'touchmove', onTouchMove as EventListener, { passive: false }),
|
|
566
718
|
useEventListener(el, 'touchend', onTouchEnd as EventListener),
|
|
567
719
|
useEventListener(el, 'touchcancel', onTouchEnd as EventListener),
|
|
568
720
|
);
|
|
721
|
+
|
|
722
|
+
if (win) {
|
|
723
|
+
cleanups.push(useEventListener(win, 'blur', onPointerInterrupted));
|
|
724
|
+
}
|
|
569
725
|
},
|
|
570
726
|
{ immediate: true },
|
|
571
727
|
);
|
|
@@ -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
|
|
|
@@ -77,7 +77,7 @@ onUnmounted(() => {
|
|
|
77
77
|
contentContext.searchRef.value = '';
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
const { isComposing, handleCompositionStart, handleCompositionEnd } = useComposing((event) => {
|
|
80
|
+
const { isComposing, shouldDeferInput, handleCompositionStart, handleCompositionUpdate, handleCompositionEnd } = useComposing((event) => {
|
|
81
81
|
const el = event.target as HTMLInputElement;
|
|
82
82
|
if (el) {
|
|
83
83
|
modelValue.value = el.value;
|
|
@@ -90,7 +90,7 @@ function handleInput(event: InputEvent) {
|
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
if (
|
|
93
|
+
if (shouldDeferInput.value) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -142,6 +142,7 @@ function handleKeyDown(event: KeyboardEvent) {
|
|
|
142
142
|
@input="handleInput"
|
|
143
143
|
@keydown="handleKeyDown"
|
|
144
144
|
@compositionstart="handleCompositionStart"
|
|
145
|
+
@compositionupdate="handleCompositionUpdate"
|
|
145
146
|
@compositionend="handleCompositionEnd"
|
|
146
147
|
>
|
|
147
148
|
<slot :model-value="modelValue" />
|
|
@@ -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);
|
|
@@ -65,7 +65,7 @@ onUnmounted(() => {
|
|
|
65
65
|
rootContext.focusable.value = true;
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
const { isComposing, handleCompositionStart, handleCompositionEnd } = useComposing((event) => {
|
|
68
|
+
const { isComposing, shouldDeferInput, handleCompositionStart, handleCompositionUpdate, handleCompositionEnd } = useComposing((event) => {
|
|
69
69
|
modelValue.value = (event.target as HTMLInputElement).value;
|
|
70
70
|
rootContext.onCompositionEnd();
|
|
71
71
|
rootContext.highlightFirstItem();
|
|
@@ -77,7 +77,7 @@ function onCompositionStart() {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
function handleInput(event: InputEvent) {
|
|
80
|
-
if (
|
|
80
|
+
if (shouldDeferInput.value) {
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
modelValue.value = (event.target as HTMLInputElement).value;
|
|
@@ -117,6 +117,7 @@ function handleKeydownEnter(event: KeyboardEvent) {
|
|
|
117
117
|
@keydown.enter="handleKeydownEnter"
|
|
118
118
|
@input="handleInput"
|
|
119
119
|
@compositionstart="onCompositionStart"
|
|
120
|
+
@compositionupdate="handleCompositionUpdate"
|
|
120
121
|
@compositionend="handleCompositionEnd"
|
|
121
122
|
>
|
|
122
123
|
<slot :model-value="modelValue" />
|
|
@@ -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"
|
|
@@ -40,6 +40,15 @@ type ListboxRootContext<T> = {
|
|
|
40
40
|
export const [injectListboxRootContext, provideListboxRootContext]
|
|
41
41
|
= createContext<ListboxRootContext<AcceptableValue>>('ListboxRoot');
|
|
42
42
|
|
|
43
|
+
/** Controls highlight scrolling while a parent composite is being positioned. */
|
|
44
|
+
type ListboxHighlightScrollContext = {
|
|
45
|
+
suppressHighlightScroll: Readonly<Ref<boolean>>;
|
|
46
|
+
onHighlightScrollRequest: (scroll: (() => void) | undefined) => void;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const [injectListboxHighlightScrollContext, provideListboxHighlightScrollContext]
|
|
50
|
+
= createContext<ListboxHighlightScrollContext>('ListboxHighlightScroll');
|
|
51
|
+
|
|
43
52
|
export interface ListboxRootProps<T = AcceptableValue> extends PrimitiveProps, FormFieldProps {
|
|
44
53
|
/** The controlled value of the listbox. Can be binded with `v-model`. */
|
|
45
54
|
modelValue?: T | Array<T>;
|
|
@@ -100,11 +109,19 @@ defineSlots<{
|
|
|
100
109
|
}>();
|
|
101
110
|
|
|
102
111
|
const { multiple, highlightOnHover, orientation, disabled, selectionBehavior, dir: propDir } = toRefs(props);
|
|
103
|
-
const { getItems } = useCollection<{ value: T }>({ isProvider: true });
|
|
112
|
+
const { getItems, getItem } = useCollection<{ value: T }>({ isProvider: true });
|
|
104
113
|
const { handleTypeaheadSearch } = useTypeahead();
|
|
105
114
|
const { primitiveElement, currentElement } = usePrimitiveElement();
|
|
106
115
|
const dir = useDirection(propDir);
|
|
107
116
|
|
|
117
|
+
const highlightScrollContext = injectListboxHighlightScrollContext(null);
|
|
118
|
+
|
|
119
|
+
// Prevent nested Listbox roots from inheriting this root's scroll coordination.
|
|
120
|
+
provideListboxHighlightScrollContext({
|
|
121
|
+
suppressHighlightScroll: ref(false),
|
|
122
|
+
onHighlightScrollRequest: () => {},
|
|
123
|
+
});
|
|
124
|
+
|
|
108
125
|
const isFormControl = useFormControl(currentElement);
|
|
109
126
|
|
|
110
127
|
const firstValue = ref<T>();
|
|
@@ -162,14 +179,29 @@ function changeHighlight(el: HTMLElement, scrollIntoView = true, focus?: boolean
|
|
|
162
179
|
}
|
|
163
180
|
|
|
164
181
|
highlightedElement.value = el;
|
|
182
|
+
const suppressHighlightScroll = highlightScrollContext?.suppressHighlightScroll.value ?? false;
|
|
165
183
|
if (focus ?? focusable.value) {
|
|
166
|
-
|
|
184
|
+
if (suppressHighlightScroll) {
|
|
185
|
+
highlightedElement.value.focus({ preventScroll: true });
|
|
186
|
+
} else {
|
|
187
|
+
highlightedElement.value.focus();
|
|
188
|
+
}
|
|
167
189
|
}
|
|
168
|
-
|
|
190
|
+
|
|
191
|
+
if (suppressHighlightScroll) {
|
|
192
|
+
highlightScrollContext?.onHighlightScrollRequest(scrollIntoView
|
|
193
|
+
? () => {
|
|
194
|
+
const element = highlightedElement.value;
|
|
195
|
+
if (element?.isConnected) {
|
|
196
|
+
element.scrollIntoView({ block: 'nearest' });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
: undefined);
|
|
200
|
+
} else if (scrollIntoView) {
|
|
169
201
|
highlightedElement.value.scrollIntoView({ block: 'nearest' });
|
|
170
202
|
}
|
|
171
203
|
|
|
172
|
-
const highlightedItem =
|
|
204
|
+
const highlightedItem = getItem(el);
|
|
173
205
|
emits('highlight', highlightedItem);
|
|
174
206
|
}
|
|
175
207
|
|
|
@@ -136,10 +136,9 @@ rootContext.virtualFocusHook.on(({ event, scroll }) => {
|
|
|
136
136
|
requestAnimationFrame(() => {
|
|
137
137
|
const item = queryCheckedElement(parentEl.value);
|
|
138
138
|
if (item) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
139
|
+
// eslint-disable-next-line no-nested-ternary
|
|
140
|
+
const focus = event ? true : scroll ? undefined : false;
|
|
141
|
+
rootContext.changeHighlight(item, scroll, focus);
|
|
143
142
|
}
|
|
144
143
|
});
|
|
145
144
|
} else if (scroll) {
|
|
@@ -93,10 +93,11 @@ async function handlePointerLeave(event: PointerEvent) {
|
|
|
93
93
|
@pointerleave="handlePointerLeave"
|
|
94
94
|
@focus="
|
|
95
95
|
async (event: FocusEvent) => {
|
|
96
|
+
const item = event.currentTarget as HTMLElement;
|
|
96
97
|
await nextTick();
|
|
97
98
|
if (event.defaultPrevented || disabled) return;
|
|
98
99
|
isFocused = true;
|
|
99
|
-
contentContext.highlightedElement.value =
|
|
100
|
+
contentContext.highlightedElement.value = item;
|
|
100
101
|
}
|
|
101
102
|
"
|
|
102
103
|
@blur="
|
|
@@ -126,6 +126,9 @@ function handleChange() {
|
|
|
126
126
|
@wheel="handleWheelEvent"
|
|
127
127
|
@beforeinput="(event: InputEvent) => {
|
|
128
128
|
if (event.isComposing) return
|
|
129
|
+
// A collapsed deletion carries no data, so nextValue would repeat the current value; undo and redo read the same
|
|
130
|
+
// Every deletion is skipped so they stay consistent, and applyInputValue reformats on blur
|
|
131
|
+
if (event.inputType.startsWith('delete') || event.inputType.startsWith('history')) return
|
|
129
132
|
const target = event.target as HTMLInputElement
|
|
130
133
|
let nextValue
|
|
131
134
|
= target.value.slice(0, target.selectionStart ?? undefined)
|