ropav 0.1.6 → 0.1.8
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/README.md +7 -1
- package/dist/accordion.css +17 -17
- package/dist/accordion.js +123 -155
- package/dist/alert.css +18 -18
- package/dist/alert.js +10 -11
- package/dist/ancestry.js +136 -0
- package/dist/aria.js +14 -0
- package/dist/aspect-ratio.js +1 -1
- package/dist/attributes.js +9 -0
- package/dist/attributes2.js +29 -0
- package/dist/avatar.css +19 -19
- package/dist/avatar.js +9 -17
- package/dist/badge.css +16 -16
- package/dist/badge.js +5 -5
- package/dist/button-group.js +1 -1
- package/dist/button-link.js +4 -3
- package/dist/button.js +4 -3
- package/dist/button.scss_vue_type_style_index_0_src_true_lang.js +1 -1
- package/dist/calendar.css +173 -0
- package/dist/calendar.js +714 -0
- package/dist/calendar2.js +37 -0
- package/dist/card.js +1 -1
- package/dist/checkbox.css +32 -32
- package/dist/checkbox.js +22 -28
- package/dist/chevron-left.js +12 -0
- package/dist/collapse.css +6 -6
- package/dist/collapse.js +7 -6
- package/dist/collectionNavigation.js +2 -99
- package/dist/color-input.css +19 -19
- package/dist/color-input.js +14 -13
- package/dist/color-picker.css +40 -40
- package/dist/color-picker.js +247 -276
- package/dist/color-picker2.js +1 -9
- package/dist/color-swatch.css +4 -4
- package/dist/color-swatch.js +6 -8
- package/dist/color.js +5 -10
- package/dist/combobox.css +251 -0
- package/dist/combobox.js +410 -0
- package/dist/componentColors.js +125 -84
- package/dist/componentRef.js +26 -0
- package/dist/components/accordion/accordionContext.d.ts +3 -0
- package/dist/components/accordion/accordionModel.d.ts +14 -0
- package/dist/components/accordion/index.d.ts +2 -1
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/accordion/types.d.ts +1 -2
- package/dist/components/accordion/useAccordion.d.ts +2 -2
- package/dist/components/accordion/useAccordionItem.d.ts +2 -0
- package/dist/components/calendar/calendar.d.ts +30 -0
- package/dist/components/calendar/calendarBehavior.d.ts +49 -0
- package/dist/components/calendar/index.d.ts +3 -0
- package/dist/components/calendar/index.js +3 -0
- package/dist/components/calendar/types.d.ts +53 -0
- package/dist/components/calendar/useCalendar.d.ts +24 -0
- package/dist/components/checkbox/useCheckbox.d.ts +1 -2
- package/dist/components/color-picker/index.js +2 -2
- package/dist/components/color-picker/types.d.ts +2 -2
- package/dist/components/color-picker/useColorPickerDrag.d.ts +1 -1
- package/dist/components/color-picker/useColorPickerSaturation.d.ts +22 -0
- package/dist/components/color-picker/useColorPickerSlider.d.ts +20 -0
- package/dist/components/color-picker/useColorPickerValue.d.ts +1 -1
- package/dist/components/combobox/combobox.d.ts +29 -0
- package/dist/components/combobox/comboboxModel.d.ts +4 -0
- package/dist/components/combobox/index.d.ts +3 -0
- package/dist/components/combobox/index.js +2 -0
- package/dist/components/combobox/types.d.ts +43 -0
- package/dist/components/combobox/useCombobox.d.ts +45 -0
- package/dist/components/date-picker/date-picker.d.ts +33 -0
- package/dist/components/date-picker/datePickerModel.d.ts +10 -0
- package/dist/components/date-picker/index.d.ts +4 -0
- package/dist/components/date-picker/index.js +2 -0
- package/dist/components/date-picker/types.d.ts +57 -0
- package/dist/components/date-picker/useDatePicker.d.ts +29 -0
- package/dist/components/date-picker/useDatePickerValueState.d.ts +21 -0
- package/dist/components/dialog/{dialog-core.d.ts → dialogContext.d.ts} +1 -5
- package/dist/components/dialog/useDialogContentInteractions.d.ts +18 -0
- package/dist/components/dialog/useDialogRootState.d.ts +19 -0
- package/dist/components/dropdown-menu/dropdown-menu-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-item-row.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-model.d.ts +8 -0
- package/dist/components/dropdown-menu/dropdown-menu-root.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-trigger.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/components/dropdown-menu/{dropdown-menu-primitive-core.d.ts → dropdownMenuContext.d.ts} +17 -30
- package/dist/components/dropdown-menu/dropdownMenuDataModel.d.ts +20 -0
- package/dist/components/dropdown-menu/dropdownMenuInteraction.d.ts +3 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionNavigation.d.ts +24 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionRegistry.d.ts +42 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionTypes.d.ts +114 -0
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts +11 -11
- package/dist/components/dropdown-menu/useDropdownMenuContextTrigger.d.ts +9 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataController.d.ts +35 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataRegistration.d.ts +24 -0
- package/dist/components/dropdown-menu/useDropdownMenuHoverIntent.d.ts +6 -5
- package/dist/components/dropdown-menu/useDropdownMenuInteractionDismissal.d.ts +17 -0
- package/dist/components/dropdown-menu/useDropdownMenuInteractionKeyboard.d.ts +19 -0
- package/dist/components/dropdown-menu/useDropdownMenuPortalPosition.d.ts +0 -1
- package/dist/components/dropdown-menu/useDropdownMenuPresentation.d.ts +28 -0
- package/dist/components/dropdown-menu/useDropdownMenuPrimitiveContent.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +1 -1
- package/dist/components/dropdown-menu/useDropdownMenuTargetBindings.d.ts +19 -0
- package/dist/components/dropzone/dropzone.d.ts +31 -0
- package/dist/components/dropzone/dropzoneModel.d.ts +16 -0
- package/dist/components/dropzone/index.d.ts +3 -0
- package/dist/components/dropzone/index.js +2 -0
- package/dist/components/dropzone/types.d.ts +56 -0
- package/dist/components/dropzone/useDropzone.d.ts +25 -0
- package/dist/components/file-input/file-input.d.ts +29 -0
- package/dist/components/file-input/index.d.ts +3 -0
- package/dist/components/file-input/index.js +2 -0
- package/dist/components/file-input/types.d.ts +37 -0
- package/dist/components/file-input/useFileInput.d.ts +15 -0
- package/dist/components/floating/index.js +2 -2
- package/dist/components/floating/useFloatingPosition.d.ts +1 -14
- package/dist/components/floating/useFloatingTargetLifecycle.d.ts +32 -0
- package/dist/components/floating/useHoverDisclosure.d.ts +10 -0
- package/dist/components/hover-card/hover-card.d.ts +25 -0
- package/dist/components/hover-card/index.d.ts +3 -0
- package/dist/components/hover-card/index.js +2 -0
- package/dist/components/hover-card/types.d.ts +45 -0
- package/dist/components/hover-card/useHoverCard.d.ts +22 -0
- package/dist/components/hover-card/useHoverCardDisclosure.d.ts +19 -0
- package/dist/components/multi-select/index.d.ts +3 -0
- package/dist/components/multi-select/index.js +2 -0
- package/dist/components/multi-select/multi-select.d.ts +30 -0
- package/dist/components/multi-select/multiSelectModel.d.ts +3 -0
- package/dist/components/multi-select/types.d.ts +49 -0
- package/dist/components/multi-select/useMultiSelect.d.ts +46 -0
- package/dist/components/number-input/numberInputModel.d.ts +15 -0
- package/dist/components/number-input/useNumberInput.d.ts +3 -19
- package/dist/components/pagination/index.d.ts +1 -1
- package/dist/components/pagination/index.js +1 -1
- package/dist/components/pagination/paginationModel.d.ts +4 -0
- package/dist/components/pagination/types.d.ts +15 -0
- package/dist/components/pagination/usePagination.d.ts +3 -19
- package/dist/components/popover/usePopoverBindings.d.ts +13 -0
- package/dist/components/progress/progressModel.d.ts +8 -0
- package/dist/components/progress/useProgress.d.ts +0 -6
- package/dist/components/radio/useRadio.d.ts +1 -2
- package/dist/components/scroll-area/scroll-area.d.ts +1 -1
- package/dist/components/scroll-area/scrollAreaModel.d.ts +64 -0
- package/dist/components/scroll-area/useScrollArea.d.ts +70 -53
- package/dist/components/scroll-area/{useScrollAreaPresentation.d.ts → useScrollAreaAttributes.d.ts} +37 -17
- package/dist/components/scroll-area/useScrollAreaDerivedState.d.ts +8 -0
- package/dist/components/scroll-area/useScrollAreaMeasurement.d.ts +35 -0
- package/dist/components/scroll-area/useScrollAreaPointer.d.ts +11 -9
- package/dist/components/scroll-area/useScrollAreaVisibility.d.ts +15 -20
- package/dist/components/segmented-control/index.d.ts +3 -0
- package/dist/components/segmented-control/index.js +2 -0
- package/dist/components/segmented-control/segmented-control.d.ts +26 -0
- package/dist/components/segmented-control/types.d.ts +47 -0
- package/dist/components/segmented-control/useSegmentedControl.d.ts +15 -0
- package/dist/components/select/useSelect.d.ts +31 -19
- package/dist/components/slider/rangeSliderModel.d.ts +41 -0
- package/dist/components/slider/{sliderCore.d.ts → sliderModel.d.ts} +0 -1
- package/dist/components/slider/useRangeSlider.d.ts +9 -17
- package/dist/components/slider/useRangeSliderPointer.d.ts +1 -1
- package/dist/components/slider/useRangeSliderValueState.d.ts +40 -0
- package/dist/components/slider/useSlider.d.ts +7 -13
- package/dist/components/slider/useSliderPointerPreview.d.ts +22 -0
- package/dist/components/slider/useSliderTooltipState.d.ts +40 -0
- package/dist/components/slider/useSliderValueState.d.ts +33 -0
- package/dist/components/tags-input/index.d.ts +3 -0
- package/dist/components/tags-input/index.js +2 -0
- package/dist/components/tags-input/tags-input.d.ts +27 -0
- package/dist/components/tags-input/tagsInputModel.d.ts +12 -0
- package/dist/components/tags-input/types.d.ts +37 -0
- package/dist/components/tags-input/useTagsInput.d.ts +23 -0
- package/dist/components/teleport-provider/index.js +1 -1
- package/dist/components/teleport-provider/useTeleportTarget.d.ts +1 -2
- package/dist/components/toast/useToastLifecycle.d.ts +19 -0
- package/dist/components/tooltip/useTooltip.d.ts +1 -2
- package/dist/components/tooltip/useTooltipTargetBindings.d.ts +12 -0
- package/dist/css.js +12 -0
- package/dist/date-picker.css +49 -0
- package/dist/date-picker.js +809 -0
- package/dist/dialog.js +215 -218
- package/dist/direction.js +6 -0
- package/dist/dropdown-menu.css +21 -3
- package/dist/dropdown-menu.js +1626 -1185
- package/dist/dropzone.css +135 -0
- package/dist/dropzone.js +431 -0
- package/dist/events.js +59 -0
- package/dist/field.css +8 -8
- package/dist/field.js +13 -25
- package/dist/file-input.css +135 -0
- package/dist/file-input.js +198 -0
- package/dist/floatingOffset.js +11 -0
- package/dist/focus-trap.js +7 -5
- package/dist/focusNavigation.js +37 -0
- package/dist/hover-card.css +80 -0
- package/dist/hover-card.js +402 -0
- package/dist/icon-button.css +8 -8
- package/dist/icon-button.js +7 -6
- package/dist/index.d.ts +9 -0
- package/dist/index.js +20 -9
- package/dist/input.css +24 -24
- package/dist/input.js +19 -31
- package/dist/interactive.js +18 -0
- package/dist/internal/composables/useOverlayLayer.d.ts +12 -0
- package/dist/modal.js +2 -2
- package/dist/multi-select.css +316 -0
- package/dist/multi-select.js +481 -0
- package/dist/nativeChoice.js +169 -0
- package/dist/number-input.css +18 -18
- package/dist/number-input.js +44 -44
- package/dist/number.js +22 -0
- package/dist/overlay.js +3 -2
- package/dist/pagination.css +28 -28
- package/dist/pagination.js +66 -73
- package/dist/pointerSession.js +130 -0
- package/dist/popover.css +55 -37
- package/dist/popover.js +75 -101
- package/dist/progress.js +10 -13
- package/dist/query.js +40 -0
- package/dist/radio.css +18 -18
- package/dist/radio.js +30 -36
- package/dist/rafScheduler.js +34 -0
- package/dist/scroll-area.css +28 -28
- package/dist/scroll-area.js +540 -554
- package/dist/segmented-control.css +176 -0
- package/dist/segmented-control.js +382 -0
- package/dist/select.css +50 -48
- package/dist/select.js +131 -289
- package/dist/slider.css +191 -191
- package/dist/slider.js +720 -706
- package/dist/styles-api.d.ts +0 -1
- package/dist/styles-api.js +1 -4
- package/dist/switch.css +17 -17
- package/dist/switch.js +14 -15
- package/dist/tabs.css +43 -43
- package/dist/tabs.js +29 -56
- package/dist/tags-input.css +197 -0
- package/dist/tags-input.js +380 -0
- package/dist/text.js +17 -0
- package/dist/textarea.css +26 -26
- package/dist/textarea.js +21 -32
- package/dist/toast.css +26 -26
- package/dist/toast.js +141 -118
- package/dist/tooltip.css +12 -12
- package/dist/tooltip.js +64 -63
- package/dist/useCollapse.js +8 -11
- package/dist/useControlState.js +3 -6
- package/dist/useEditableOptionList.js +216 -0
- package/dist/useFlatOptionCollection.js +134 -0
- package/dist/useFloatingPosition.js +14 -40
- package/dist/useFloatingTargetLifecycle.js +127 -0
- package/dist/useFormControl.js +1 -0
- package/dist/useHoverDisclosure.js +561 -0
- package/dist/useNativeChoiceTransaction.js +46 -0
- package/dist/useNativeFileSelection.js +86 -0
- package/dist/useOverlayZIndex.js +246 -19
- package/dist/useTeleportTarget.js +3 -14
- package/dist/useTypeahead.js +94 -0
- package/dist/utils/aria.d.ts +3 -0
- package/dist/utils/attributes.d.ts +2 -0
- package/dist/utils/bem.d.ts +3 -0
- package/dist/utils/collectionNavigation.d.ts +2 -0
- package/dist/utils/color.d.ts +7 -0
- package/dist/{components/color-picker/color-picker-utils.d.ts → utils/colorPicker.d.ts} +5 -4
- package/dist/utils/componentColors.d.ts +7 -0
- package/dist/utils/css.d.ts +3 -0
- package/dist/utils/date.d.ts +13 -0
- package/dist/utils/dateAvailability.d.ts +7 -0
- package/dist/utils/dom/ancestry.d.ts +8 -0
- package/dist/utils/dom/attributes.d.ts +16 -0
- package/dist/utils/dom/componentRef.d.ts +4 -0
- package/dist/utils/dom/direction.d.ts +2 -0
- package/dist/utils/dom/events.d.ts +5 -0
- package/dist/utils/dom/files.d.ts +3 -0
- package/dist/utils/dom/focusNavigation.d.ts +7 -0
- package/dist/utils/dom/interactive.d.ts +2 -0
- package/dist/utils/dom/nativeChoice.d.ts +17 -0
- package/dist/utils/dom/pointerSession.d.ts +20 -0
- package/dist/utils/dom/query.d.ts +4 -0
- package/dist/utils/dom/scroll.d.ts +24 -0
- package/dist/utils/floatingOffset.d.ts +10 -0
- package/dist/utils/geometry.d.ts +14 -0
- package/dist/utils/indexPath.d.ts +6 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/optionFilter.d.ts +5 -0
- package/dist/utils/rafScheduler.d.ts +4 -0
- package/dist/utils/text.d.ts +2 -0
- package/docs/code-architecture.md +118 -0
- package/docs/public-floating-api.md +13 -9
- package/docs/public-styles-api.md +25 -12
- package/package.json +51 -14
- package/src/styles/_mixins.scss +26 -0
- package/src/styles/styles-manifest.json +1 -2
- package/dist/components/dropdown-menu/dropdown-menu-outside.d.ts +0 -3
- package/dist/components/dropdown-menu/dropdown-menu-utils.d.ts +0 -21
- package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +0 -36
- package/dist/components/dropdown-menu/useDropdownMenuDom.d.ts +0 -29
- package/dist/components/dropdown-menu/useDropdownMenuInteractions.d.ts +0 -52
- package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +0 -17
- package/dist/components/dropdown-menu/useDropdownSubmenus.d.ts +0 -18
- package/dist/components/scroll-area/scrollAreaCore.d.ts +0 -30
- package/dist/components/scroll-area/useScrollAreaControls.d.ts +0 -25
- package/dist/components/scroll-area/useScrollAreaMetrics.d.ts +0 -38
- package/dist/components/select/useSelectNativeControl.d.ts +0 -9
- package/dist/components/select/useSelectNativeValue.d.ts +0 -9
- package/dist/floating.js +0 -415
- /package/dist/components/alert/{useAlertColor.d.ts → alertColor.d.ts} +0 -0
- /package/dist/components/avatar/{useAvatarColor.d.ts → avatarColor.d.ts} +0 -0
- /package/dist/components/badge/{useBadgeColor.d.ts → badgeColor.d.ts} +0 -0
- /package/dist/components/button/{useButtonColor.d.ts → buttonColor.d.ts} +0 -0
- /package/dist/components/color-swatch/{useColorSwatchColor.d.ts → colorSwatchColor.d.ts} +0 -0
- /package/dist/components/toast/{useToastColor.d.ts → toastColor.d.ts} +0 -0
package/dist/tooltip.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import './tooltip.css';
|
|
2
2
|
import { t as useControllableValue } from "./useControllableValue.js";
|
|
3
|
-
import {
|
|
3
|
+
import { t as useStylesApi } from "./styles-api.js";
|
|
4
|
+
import { n as toPresenceAttribute } from "./attributes.js";
|
|
4
5
|
import { t as bem } from "./bem.js";
|
|
5
6
|
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
7
|
+
import { r as normalizeDelay } from "./number.js";
|
|
6
8
|
import { a as getComponentVariantColorRoles } from "./componentColors.js";
|
|
9
|
+
import { n as mergeAriaIdRefs } from "./aria.js";
|
|
7
10
|
import { n as useOverlayZIndex } from "./useOverlayZIndex.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
+
import { t as getFloatingOffsetStyle } from "./floatingOffset.js";
|
|
12
|
+
import { t as useFloatingPosition } from "./useFloatingPosition.js";
|
|
13
|
+
import { t as useFloatingTargetLifecycle } from "./useFloatingTargetLifecycle.js";
|
|
14
|
+
import { n as useTeleportTarget } from "./useTeleportTarget.js";
|
|
15
|
+
import { VaporTeleport, VaporTransition, applyVShow, computed, createComponent, createIf, createSlot, createTemplateRefSetter, defineVaporComponent, extend, onBeforeUnmount, ref, renderEffect, setAttr, setDynamicProps, setInsertionState, setStyle, setTemplateRefBinding, setText, template, toDisplayString, unref, useId, useSlots, watch } from "vue";
|
|
11
16
|
//#region src/internal/composables/useDelayedOpen.ts
|
|
12
17
|
function readOption(value, fallback) {
|
|
13
18
|
return typeof value === "function" ? value() ?? fallback : value ?? fallback;
|
|
@@ -37,7 +42,7 @@ function useDelayedOpen(options = {}) {
|
|
|
37
42
|
}
|
|
38
43
|
function open() {
|
|
39
44
|
if (isDisabled()) return;
|
|
40
|
-
const delay = readOption(options.openDelay, 0);
|
|
45
|
+
const delay = normalizeDelay(readOption(options.openDelay, 0));
|
|
41
46
|
if (delay <= 0) {
|
|
42
47
|
setOpen(true);
|
|
43
48
|
return;
|
|
@@ -60,15 +65,32 @@ function useDelayedOpen(options = {}) {
|
|
|
60
65
|
};
|
|
61
66
|
}
|
|
62
67
|
//#endregion
|
|
63
|
-
//#region src/components/tooltip/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
//#region src/components/tooltip/useTooltipTargetBindings.ts
|
|
69
|
+
var TARGET_ATTRIBUTES = ["aria-describedby"];
|
|
70
|
+
function useTooltipTargetBindings({ targetLifecycle, shouldDescribeContent, tooltipId, openTooltip, closeTooltip, onKeydown }) {
|
|
71
|
+
targetLifecycle.bindTarget({
|
|
72
|
+
listeners: [
|
|
73
|
+
["mouseenter", openTooltip],
|
|
74
|
+
["mouseleave", closeTooltip],
|
|
75
|
+
["focusin", openTooltip],
|
|
76
|
+
["focusout", closeTooltip],
|
|
77
|
+
["keydown", onKeydown]
|
|
78
|
+
],
|
|
79
|
+
attributes: {
|
|
80
|
+
names: TARGET_ATTRIBUTES,
|
|
81
|
+
isActive: () => shouldDescribeContent.value,
|
|
82
|
+
apply: (target, snapshot) => {
|
|
83
|
+
target.setAttribute("aria-describedby", mergeAriaIdRefs(snapshot.get("aria-describedby"), tooltipId.value) ?? "");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
71
87
|
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/components/tooltip/useTooltip.ts
|
|
90
|
+
var TOOLTIP_OFFSET_PROPERTIES = {
|
|
91
|
+
mainAxis: "--_rp-tooltip-main-axis-offset",
|
|
92
|
+
crossAxis: "--_rp-tooltip-cross-axis-offset"
|
|
93
|
+
};
|
|
72
94
|
function resolveTooltipColorStyleWithContrast(color, autoContrast, contrastColor) {
|
|
73
95
|
if (!color) return void 0;
|
|
74
96
|
const roles = getComponentVariantColorRoles({
|
|
@@ -97,9 +119,11 @@ function useTooltip(props, emitOpenChange) {
|
|
|
97
119
|
const shouldRenderContent = computed(() => !isDisabled.value);
|
|
98
120
|
const shouldDescribeContent = computed(() => shouldRenderContent.value && !isDecorative.value);
|
|
99
121
|
const teleportTo = useTeleportTarget(() => props.teleportTo);
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
122
|
+
const targetLifecycle = useFloatingTargetLifecycle({
|
|
123
|
+
target: () => props.target,
|
|
124
|
+
fallback: rootRef
|
|
125
|
+
});
|
|
126
|
+
const { isExplicitTarget, reference } = targetLifecycle;
|
|
103
127
|
const zIndex = useOverlayZIndex({
|
|
104
128
|
baseZIndex: () => props.baseZIndex,
|
|
105
129
|
defaultBaseZIndex: 1e3
|
|
@@ -123,12 +147,7 @@ function useTooltip(props, emitOpenChange) {
|
|
|
123
147
|
flipOptions: () => props.flipOptions,
|
|
124
148
|
shift: () => props.shift !== false,
|
|
125
149
|
collisionPadding: () => props.collisionPadding ?? 8,
|
|
126
|
-
autoUpdateOptions: () => props.autoUpdateOptions
|
|
127
|
-
restartKey: () => [
|
|
128
|
-
Boolean(props.teleport),
|
|
129
|
-
teleportTo.value,
|
|
130
|
-
teleportPositioningKey.value
|
|
131
|
-
]
|
|
150
|
+
autoUpdateOptions: () => props.autoUpdateOptions
|
|
132
151
|
});
|
|
133
152
|
const placementSide = computed(() => floating.actualPlacement.value.split("-")[0]);
|
|
134
153
|
const rootClass = computed(() => bem("rp-tooltip", {
|
|
@@ -143,7 +162,7 @@ function useTooltip(props, emitOpenChange) {
|
|
|
143
162
|
const contentAriaHidden = computed(() => isDecorative.value ? "true" : void 0);
|
|
144
163
|
const contentStyle = computed(() => ({
|
|
145
164
|
...floating.floatingStyle.value,
|
|
146
|
-
...
|
|
165
|
+
...getFloatingOffsetStyle(props.offset, TOOLTIP_OFFSET_PROPERTIES),
|
|
147
166
|
...resolveTooltipColorStyleWithContrast(props.color, props.autoContrast, props.contrastColor),
|
|
148
167
|
zIndex: zIndex.value
|
|
149
168
|
}));
|
|
@@ -159,37 +178,14 @@ function useTooltip(props, emitOpenChange) {
|
|
|
159
178
|
watch(isDisabled, (disabled) => {
|
|
160
179
|
if (disabled) closeTooltip();
|
|
161
180
|
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
target.addEventListener("mouseenter", openTooltip);
|
|
165
|
-
target.addEventListener("mouseleave", closeTooltip);
|
|
166
|
-
target.addEventListener("focusin", openTooltip);
|
|
167
|
-
target.addEventListener("focusout", closeTooltip);
|
|
168
|
-
target.addEventListener("keydown", onKeydown);
|
|
169
|
-
onCleanup(() => {
|
|
170
|
-
target.removeEventListener("mouseenter", openTooltip);
|
|
171
|
-
target.removeEventListener("mouseleave", closeTooltip);
|
|
172
|
-
target.removeEventListener("focusin", openTooltip);
|
|
173
|
-
target.removeEventListener("focusout", closeTooltip);
|
|
174
|
-
target.removeEventListener("keydown", onKeydown);
|
|
175
|
-
});
|
|
176
|
-
}, { flush: "sync" });
|
|
177
|
-
watch([
|
|
178
|
-
isExplicitTarget,
|
|
179
|
-
targetElement,
|
|
181
|
+
useTooltipTargetBindings({
|
|
182
|
+
targetLifecycle,
|
|
180
183
|
shouldDescribeContent,
|
|
181
|
-
tooltipId
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (!ids.includes(id)) ids.push(id);
|
|
187
|
-
target.setAttribute("aria-describedby", ids.join(" "));
|
|
188
|
-
onCleanup(() => {
|
|
189
|
-
if (previous == null) target.removeAttribute("aria-describedby");
|
|
190
|
-
else target.setAttribute("aria-describedby", previous);
|
|
191
|
-
});
|
|
192
|
-
}, { flush: "sync" });
|
|
184
|
+
tooltipId,
|
|
185
|
+
openTooltip,
|
|
186
|
+
closeTooltip,
|
|
187
|
+
onKeydown
|
|
188
|
+
});
|
|
193
189
|
return {
|
|
194
190
|
rootRef,
|
|
195
191
|
contentRef,
|
|
@@ -216,10 +212,10 @@ function useTooltip(props, emitOpenChange) {
|
|
|
216
212
|
}
|
|
217
213
|
//#endregion
|
|
218
214
|
//#region src/components/tooltip/tooltip.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
219
|
-
var t0 = template("<span data-v-
|
|
215
|
+
var t0 = template("<span data-v-19aad69c class=rp-tooltip__arrow aria-hidden=true>");
|
|
220
216
|
var t1 = template(" ");
|
|
221
|
-
var t2 = template("<span data-v-
|
|
222
|
-
var t3 = template("<span data-v-
|
|
217
|
+
var t2 = template("<span data-v-19aad69c>");
|
|
218
|
+
var t3 = template("<span data-v-19aad69c>", 1);
|
|
223
219
|
//#endregion
|
|
224
220
|
//#region src/components/tooltip/tooltip.vue
|
|
225
221
|
var tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -283,12 +279,17 @@ var tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE
|
|
|
283
279
|
const { rootRef, contentRef, arrowRef, tooltipId, isDisabled, isVisible, isTargetMode, shouldRenderContent, rootClass, triggerProps, contentRole, contentAriaHidden, contentStyle, actualPlacement, placementSide, arrowStyle, teleportTo, openTooltip, closeTooltip, onKeydown } = useTooltip(props, (open) => {
|
|
284
280
|
emit("update:open", open);
|
|
285
281
|
});
|
|
282
|
+
const templateRefs = {
|
|
283
|
+
root: rootRef,
|
|
284
|
+
content: contentRef,
|
|
285
|
+
arrow: arrowRef
|
|
286
|
+
};
|
|
286
287
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
287
288
|
const state = computed(() => isVisible.value ? "open" : "closed");
|
|
288
289
|
const rootAttrs = computed(() => getRootAttrs({
|
|
289
290
|
class: rootClass.value,
|
|
290
291
|
"data-state": state.value,
|
|
291
|
-
"data-disabled":
|
|
292
|
+
"data-disabled": toPresenceAttribute(isDisabled.value),
|
|
292
293
|
onMouseenter: openTooltip,
|
|
293
294
|
onMouseleave: closeTooltip,
|
|
294
295
|
onFocusin: openTooltip,
|
|
@@ -302,7 +303,7 @@ var tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE
|
|
|
302
303
|
...props.classNames?.trigger !== void 0 ? { class: partAttrs.class } : {},
|
|
303
304
|
...props.styles?.trigger !== void 0 ? { style: partAttrs.style } : {},
|
|
304
305
|
"data-state": state.value,
|
|
305
|
-
"data-disabled":
|
|
306
|
+
"data-disabled": toPresenceAttribute(isDisabled.value)
|
|
306
307
|
};
|
|
307
308
|
});
|
|
308
309
|
const contentAttrs = computed(() => ({
|
|
@@ -340,10 +341,10 @@ var tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE
|
|
|
340
341
|
setInsertionState(n11, null, 0);
|
|
341
342
|
createIf(() => __props.arrow, () => {
|
|
342
343
|
const n7 = t0();
|
|
343
|
-
_setTemplateRef(n7, arrowRef, null, "arrowRef");
|
|
344
344
|
renderEffect(() => {
|
|
345
345
|
setAttr(n7, "data-side", unref(placementSide));
|
|
346
346
|
setStyle(n7, unref(arrowStyle));
|
|
347
|
+
_setTemplateRef(n7, templateRefs.arrow);
|
|
347
348
|
});
|
|
348
349
|
return n7;
|
|
349
350
|
});
|
|
@@ -354,14 +355,14 @@ var tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE
|
|
|
354
355
|
return n10;
|
|
355
356
|
}, 1);
|
|
356
357
|
applyVShow(n11, () => unref(isVisible));
|
|
357
|
-
|
|
358
|
+
setTemplateRefBinding(n11, () => templateRefs.content, _setTemplateRef);
|
|
358
359
|
return n11;
|
|
359
360
|
}, null, 129);
|
|
360
361
|
}, { _: 8 }));
|
|
361
362
|
});
|
|
362
|
-
|
|
363
|
+
setTemplateRefBinding(n14, () => templateRefs.root);
|
|
363
364
|
return n14;
|
|
364
365
|
}
|
|
365
|
-
}), [["__scopeId", "data-v-
|
|
366
|
+
}), [["__scopeId", "data-v-19aad69c"]]);
|
|
366
367
|
//#endregion
|
|
367
|
-
export {
|
|
368
|
+
export { resolveTooltipColorStyleWithContrast as n, useDelayedOpen as r, tooltip_default as t };
|
package/dist/useCollapse.js
CHANGED
|
@@ -3,15 +3,12 @@ import { t as bem } from "./bem.js";
|
|
|
3
3
|
import { computed, toValue, useId } from "vue";
|
|
4
4
|
//#region src/components/collapse/useCollapse.ts
|
|
5
5
|
var DEFAULT_ROLE = "region";
|
|
6
|
-
function optionValue(value) {
|
|
7
|
-
return toValue(value);
|
|
8
|
-
}
|
|
9
6
|
function useCollapse(options = {}, emitOpenChange) {
|
|
10
7
|
const generatedId = useId();
|
|
11
|
-
const id = computed(() =>
|
|
12
|
-
const isDisabled = computed(() => Boolean(
|
|
8
|
+
const id = computed(() => toValue(options.id) ?? `${generatedId}-collapse`);
|
|
9
|
+
const isDisabled = computed(() => Boolean(toValue(options.disabled)));
|
|
13
10
|
const controllableOpen = useControllableValue({
|
|
14
|
-
modelValue: () =>
|
|
11
|
+
modelValue: () => toValue(options.open),
|
|
15
12
|
defaultValue: () => false,
|
|
16
13
|
onChange: (nextOpen) => {
|
|
17
14
|
options.onOpenChange?.(nextOpen);
|
|
@@ -20,7 +17,7 @@ function useCollapse(options = {}, emitOpenChange) {
|
|
|
20
17
|
});
|
|
21
18
|
const isOpen = controllableOpen.value;
|
|
22
19
|
const state = computed(() => isOpen.value ? "open" : "closed");
|
|
23
|
-
const shouldRenderContent = computed(() => !
|
|
20
|
+
const shouldRenderContent = computed(() => !toValue(options.unmountOnExit) || isOpen.value);
|
|
24
21
|
const rootClass = computed(() => bem("rp-collapse", {
|
|
25
22
|
open: isOpen.value,
|
|
26
23
|
closed: !isOpen.value,
|
|
@@ -48,12 +45,12 @@ function useCollapse(options = {}, emitOpenChange) {
|
|
|
48
45
|
const contentProps = computed(() => ({
|
|
49
46
|
class: "rp-collapse__content",
|
|
50
47
|
id: id.value,
|
|
51
|
-
role:
|
|
48
|
+
role: toValue(options.role) ?? DEFAULT_ROLE,
|
|
52
49
|
"data-state": state.value,
|
|
53
50
|
"aria-hidden": isOpen.value ? void 0 : "true",
|
|
54
|
-
"aria-label":
|
|
55
|
-
"aria-labelledby":
|
|
56
|
-
"aria-describedby":
|
|
51
|
+
"aria-label": toValue(options.ariaLabel) || void 0,
|
|
52
|
+
"aria-labelledby": toValue(options.ariaLabelledby) || void 0,
|
|
53
|
+
"aria-describedby": toValue(options.ariaDescribedby) || void 0
|
|
57
54
|
}));
|
|
58
55
|
const triggerSlotProps = computed(() => ({
|
|
59
56
|
triggerProps: triggerProps.value,
|
package/dist/useControlState.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { n as mergeAriaIdRefs } from "./aria.js";
|
|
1
2
|
import { computed } from "vue";
|
|
2
3
|
//#region src/internal/composables/useControlState.ts
|
|
3
|
-
function mergeIds(...values) {
|
|
4
|
-
const ids = values.flatMap((value) => value?.split(/\s+/) ?? []).filter(Boolean);
|
|
5
|
-
return ids.length > 0 ? Array.from(new Set(ids)).join(" ") : void 0;
|
|
6
|
-
}
|
|
7
4
|
function useControlState(options = {}) {
|
|
8
5
|
const id = computed(() => options.id);
|
|
9
6
|
const form = computed(() => options.form);
|
|
@@ -11,8 +8,8 @@ function useControlState(options = {}) {
|
|
|
11
8
|
const required = computed(() => options.required ?? false);
|
|
12
9
|
const invalid = computed(() => options.invalid ?? false);
|
|
13
10
|
const valid = computed(() => options.valid ?? false);
|
|
14
|
-
const ariaDescribedby = computed(() =>
|
|
15
|
-
const ariaLabelledby = computed(() =>
|
|
11
|
+
const ariaDescribedby = computed(() => mergeAriaIdRefs(options.describedby));
|
|
12
|
+
const ariaLabelledby = computed(() => mergeAriaIdRefs(options.labelledby));
|
|
16
13
|
return {
|
|
17
14
|
get id() {
|
|
18
15
|
return id.value;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { i as isNodeWithinElement } from "./events.js";
|
|
2
|
+
import { t as isInteractiveElement } from "./interactive.js";
|
|
3
|
+
import { n as useClickOutside, t as useFlatOptionCollection } from "./useFlatOptionCollection.js";
|
|
4
|
+
import { computed, nextTick, ref, watch } from "vue";
|
|
5
|
+
//#region src/utils/optionFilter.ts
|
|
6
|
+
function defaultOptionFilter(option, searchValue) {
|
|
7
|
+
return option.label.toLocaleLowerCase().includes(searchValue.trim().toLocaleLowerCase());
|
|
8
|
+
}
|
|
9
|
+
function filterOptions(options, searchValue, filter) {
|
|
10
|
+
const availableOptions = options ?? [];
|
|
11
|
+
if (filter === false || searchValue.trim() === "") return [...availableOptions];
|
|
12
|
+
const predicate = filter ?? defaultOptionFilter;
|
|
13
|
+
return availableOptions.filter((option) => predicate(option, searchValue));
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/internal/composables/useEditableOptionList.ts
|
|
17
|
+
function useEditableOptionList(options) {
|
|
18
|
+
const selection = options.selection;
|
|
19
|
+
const isSingle = selection.kind === "single";
|
|
20
|
+
const isOpen = ref(false);
|
|
21
|
+
const isSearching = ref(false);
|
|
22
|
+
const popupId = `${options.baseId}-popup`;
|
|
23
|
+
const searchValue = ref(isSingle ? selection.displayValue() : "");
|
|
24
|
+
const filterValue = computed(() => isSingle && !isSearching.value ? "" : searchValue.value);
|
|
25
|
+
const visibleOptions = computed(() => filterOptions(options.items(), filterValue.value, options.filter()));
|
|
26
|
+
const optionCollection = useFlatOptionCollection({
|
|
27
|
+
items: () => visibleOptions.value,
|
|
28
|
+
baseId: options.baseId,
|
|
29
|
+
isOpen: () => isOpen.value,
|
|
30
|
+
collectionRef: options.rootRef,
|
|
31
|
+
getKey: options.getKey,
|
|
32
|
+
isDisabled: options.isDisabled,
|
|
33
|
+
isSelected: selection.isSelected
|
|
34
|
+
});
|
|
35
|
+
const itemsSnapshot = computed(() => visibleOptions.value.map((option) => [options.getKey(option), options.isDisabled(option)]));
|
|
36
|
+
const canClear = computed(() => options.clearable() && !options.disabled() && (selection.hasSelection() || isSingle && searchValue.value !== ""));
|
|
37
|
+
function setInputValue(value) {
|
|
38
|
+
searchValue.value = value;
|
|
39
|
+
if (options.inputRef.value && options.inputRef.value.value !== value) options.inputRef.value.value = value;
|
|
40
|
+
}
|
|
41
|
+
function syncInputToSelection() {
|
|
42
|
+
if (selection.kind !== "single") return;
|
|
43
|
+
isSearching.value = false;
|
|
44
|
+
setInputValue(selection.displayValue());
|
|
45
|
+
}
|
|
46
|
+
function resetQuery() {
|
|
47
|
+
if (searchValue.value === "") return;
|
|
48
|
+
setInputValue("");
|
|
49
|
+
options.onSearch("");
|
|
50
|
+
}
|
|
51
|
+
function focusInput() {
|
|
52
|
+
nextTick(() => options.inputRef.value?.focus());
|
|
53
|
+
}
|
|
54
|
+
function open() {
|
|
55
|
+
if (options.disabled() || isOpen.value) return;
|
|
56
|
+
isOpen.value = true;
|
|
57
|
+
syncInputToSelection();
|
|
58
|
+
optionCollection.activate("selected");
|
|
59
|
+
}
|
|
60
|
+
function close(restoreInput = true) {
|
|
61
|
+
isOpen.value = false;
|
|
62
|
+
optionCollection.reset();
|
|
63
|
+
if (restoreInput) syncInputToSelection();
|
|
64
|
+
}
|
|
65
|
+
function toggle() {
|
|
66
|
+
if (options.disabled()) return;
|
|
67
|
+
const wasOpen = isOpen.value;
|
|
68
|
+
if (wasOpen) close();
|
|
69
|
+
else open();
|
|
70
|
+
if (!wasOpen || selection.kind === "multiple") focusInput();
|
|
71
|
+
}
|
|
72
|
+
function restoreRejectedSingleSelection(option) {
|
|
73
|
+
if (selection.kind !== "single") return;
|
|
74
|
+
queueMicrotask(() => {
|
|
75
|
+
if (!(option ? selection.isSelected(option) : !selection.hasSelection()) && !isOpen.value) syncInputToSelection();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function selectOption(option) {
|
|
79
|
+
if (options.isDisabled(option)) return;
|
|
80
|
+
selection.select(option);
|
|
81
|
+
if (selection.kind === "single") {
|
|
82
|
+
isSearching.value = false;
|
|
83
|
+
setInputValue(option.label);
|
|
84
|
+
close(false);
|
|
85
|
+
restoreRejectedSingleSelection(option);
|
|
86
|
+
} else {
|
|
87
|
+
resetQuery();
|
|
88
|
+
optionCollection.activate(option);
|
|
89
|
+
}
|
|
90
|
+
focusInput();
|
|
91
|
+
}
|
|
92
|
+
function clearSelection() {
|
|
93
|
+
if (!canClear.value) return;
|
|
94
|
+
if (selection.kind === "single") {
|
|
95
|
+
isSearching.value = false;
|
|
96
|
+
setInputValue("");
|
|
97
|
+
options.onSearch("");
|
|
98
|
+
selection.clear();
|
|
99
|
+
close(false);
|
|
100
|
+
restoreRejectedSingleSelection();
|
|
101
|
+
} else {
|
|
102
|
+
selection.clear();
|
|
103
|
+
resetQuery();
|
|
104
|
+
}
|
|
105
|
+
focusInput();
|
|
106
|
+
}
|
|
107
|
+
function resetAfterFormReset() {
|
|
108
|
+
close();
|
|
109
|
+
if (selection.kind === "multiple") resetQuery();
|
|
110
|
+
}
|
|
111
|
+
function onOptionMouseenter(option) {
|
|
112
|
+
optionCollection.activate(option);
|
|
113
|
+
}
|
|
114
|
+
function onRootMousedown(event) {
|
|
115
|
+
if (selection.kind !== "multiple" || options.disabled()) return;
|
|
116
|
+
if (!isNodeWithinElement(event.target, options.inputRef.value) && isInteractiveElement(event.target)) return;
|
|
117
|
+
open();
|
|
118
|
+
options.inputRef.value?.focus();
|
|
119
|
+
}
|
|
120
|
+
function onFocusout(event) {
|
|
121
|
+
if (isNodeWithinElement(event.relatedTarget, options.rootRef.value)) return;
|
|
122
|
+
close();
|
|
123
|
+
}
|
|
124
|
+
function onInput(event) {
|
|
125
|
+
if (options.disabled()) return;
|
|
126
|
+
const value = event.currentTarget.value;
|
|
127
|
+
searchValue.value = value;
|
|
128
|
+
isSearching.value = true;
|
|
129
|
+
options.onSearch(value);
|
|
130
|
+
if (!isOpen.value) isOpen.value = true;
|
|
131
|
+
optionCollection.activate("first");
|
|
132
|
+
}
|
|
133
|
+
function onInputFocus() {
|
|
134
|
+
open();
|
|
135
|
+
}
|
|
136
|
+
function onInputClick() {
|
|
137
|
+
open();
|
|
138
|
+
}
|
|
139
|
+
function selectHighlightedOption() {
|
|
140
|
+
const option = visibleOptions.value[optionCollection.activeIndex.value];
|
|
141
|
+
if (option) selectOption(option);
|
|
142
|
+
}
|
|
143
|
+
function onInputKeydown(event) {
|
|
144
|
+
if (options.disabled() || event.isComposing) return;
|
|
145
|
+
switch (event.key) {
|
|
146
|
+
case "Enter":
|
|
147
|
+
if (!isOpen.value || selection.kind === "multiple" && optionCollection.activeIndex.value < 0) return;
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
selectHighlightedOption();
|
|
150
|
+
break;
|
|
151
|
+
case "ArrowDown":
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
if (!isOpen.value) open();
|
|
154
|
+
else optionCollection.move(1);
|
|
155
|
+
break;
|
|
156
|
+
case "ArrowUp":
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
if (!isOpen.value) {
|
|
159
|
+
open();
|
|
160
|
+
optionCollection.activate("last");
|
|
161
|
+
} else optionCollection.move(-1);
|
|
162
|
+
break;
|
|
163
|
+
case "Backspace":
|
|
164
|
+
if (selection.kind === "multiple" && searchValue.value === "") selection.removeLast();
|
|
165
|
+
break;
|
|
166
|
+
case "Escape":
|
|
167
|
+
if (!isOpen.value) return;
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
close();
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
watch(itemsSnapshot, () => {
|
|
174
|
+
if (!isOpen.value || optionCollection.activeIndex.value >= 0) return;
|
|
175
|
+
if (selection.kind === "multiple" || isSearching.value) optionCollection.activate("first");
|
|
176
|
+
});
|
|
177
|
+
if (selection.kind === "single") watch(selection.displayValue, (value) => {
|
|
178
|
+
if (!isSearching.value) setInputValue(value);
|
|
179
|
+
});
|
|
180
|
+
watch(options.disabled, (disabled) => {
|
|
181
|
+
if (disabled) close();
|
|
182
|
+
});
|
|
183
|
+
useClickOutside(options.rootRef, isOpen, () => close());
|
|
184
|
+
return {
|
|
185
|
+
actions: {
|
|
186
|
+
clearSelection,
|
|
187
|
+
focusInput,
|
|
188
|
+
resetAfterFormReset,
|
|
189
|
+
selectOption,
|
|
190
|
+
toggle
|
|
191
|
+
},
|
|
192
|
+
handlers: {
|
|
193
|
+
onFocusout,
|
|
194
|
+
onInput,
|
|
195
|
+
onInputClick,
|
|
196
|
+
onInputFocus,
|
|
197
|
+
onInputKeydown,
|
|
198
|
+
onOptionMouseenter,
|
|
199
|
+
onRootMousedown
|
|
200
|
+
},
|
|
201
|
+
ids: {
|
|
202
|
+
listbox: `${popupId}-viewport`,
|
|
203
|
+
popup: popupId
|
|
204
|
+
},
|
|
205
|
+
state: {
|
|
206
|
+
activeDescendantId: optionCollection.activeDescendantId,
|
|
207
|
+
canClear,
|
|
208
|
+
isOpen,
|
|
209
|
+
renderedOptions: optionCollection.options,
|
|
210
|
+
searchValue,
|
|
211
|
+
visibleOptions
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
//#endregion
|
|
216
|
+
export { useEditableOptionList as t };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { n as getNextEnabledIndex, t as getEnabledIndexes } from "./collectionNavigation.js";
|
|
2
|
+
import { n as isEventWithinElement } from "./events.js";
|
|
3
|
+
import { computed, defineVaporComponent, markRaw, onBeforeUnmount, onMounted, shallowRef, template, watch } from "vue";
|
|
4
|
+
//#region ~icons/lucide/chevrons-up-down
|
|
5
|
+
var t0 = template("<svg viewBox=\"0 0 24 24\"width=1.2em height=1.2em><path fill=none stroke=currentColor stroke-linecap=round stroke-linejoin=round stroke-width=2 d=\"m7 15l5 5l5-5M7 9l5-5l5 5\">", 3, 1);
|
|
6
|
+
function render(_ctx) {
|
|
7
|
+
return t0();
|
|
8
|
+
}
|
|
9
|
+
var chevrons_up_down_default = markRaw(defineVaporComponent({
|
|
10
|
+
name: "lucide-chevrons-up-down",
|
|
11
|
+
render
|
|
12
|
+
}));
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/internal/composables/useClickOutside.ts
|
|
15
|
+
function useClickOutside(target, active, callback) {
|
|
16
|
+
const targets = Array.isArray(target) ? target : [target];
|
|
17
|
+
const listeningDocuments = /* @__PURE__ */ new Set();
|
|
18
|
+
let stopWatch;
|
|
19
|
+
function handler(event) {
|
|
20
|
+
if (!targets.some((current) => {
|
|
21
|
+
const element = current.value;
|
|
22
|
+
return element ? isEventWithinElement(event, element) : false;
|
|
23
|
+
})) callback(event);
|
|
24
|
+
}
|
|
25
|
+
function detachListeners() {
|
|
26
|
+
for (const document of listeningDocuments) document.removeEventListener("click", handler, true);
|
|
27
|
+
listeningDocuments.clear();
|
|
28
|
+
}
|
|
29
|
+
function syncListeners() {
|
|
30
|
+
detachListeners();
|
|
31
|
+
if (!active.value) return;
|
|
32
|
+
for (const current of targets) {
|
|
33
|
+
const document = current.value?.ownerDocument;
|
|
34
|
+
if (!document || listeningDocuments.has(document)) continue;
|
|
35
|
+
document.addEventListener("click", handler, true);
|
|
36
|
+
listeningDocuments.add(document);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
onMounted(() => {
|
|
40
|
+
stopWatch = watch([active, ...targets], syncListeners, { immediate: true });
|
|
41
|
+
});
|
|
42
|
+
onBeforeUnmount(() => {
|
|
43
|
+
stopWatch?.();
|
|
44
|
+
detachListeners();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/internal/composables/useFlatOptionCollection.ts
|
|
49
|
+
function findActiveDescendant(collection, id) {
|
|
50
|
+
const documentMatch = collection.ownerDocument.getElementById(id);
|
|
51
|
+
if (documentMatch && collection.contains(documentMatch)) return documentMatch;
|
|
52
|
+
return [...collection.querySelectorAll("[id]")].find((element) => element.id === id);
|
|
53
|
+
}
|
|
54
|
+
function useFlatOptionCollection(options) {
|
|
55
|
+
const activeKey = shallowRef(null);
|
|
56
|
+
const isDisabled = options.isDisabled ?? (() => false);
|
|
57
|
+
const isSelected = options.isSelected ?? (() => false);
|
|
58
|
+
const loop = options.loop ?? true;
|
|
59
|
+
const activeIndex = computed(() => {
|
|
60
|
+
if (activeKey.value == null) return -1;
|
|
61
|
+
return options.items().findIndex((item) => options.getKey(item) === activeKey.value && !isDisabled(item));
|
|
62
|
+
});
|
|
63
|
+
const enabledIndexes = computed(() => getEnabledIndexes(options.items(), isDisabled));
|
|
64
|
+
const optionStates = computed(() => options.items().map((option, index) => ({
|
|
65
|
+
option,
|
|
66
|
+
id: `${options.baseId}-option-${index}`,
|
|
67
|
+
active: index === activeIndex.value,
|
|
68
|
+
disabled: isDisabled(option),
|
|
69
|
+
selected: isSelected(option)
|
|
70
|
+
})));
|
|
71
|
+
const activeDescendantId = computed(() => {
|
|
72
|
+
if (!options.isOpen()) return void 0;
|
|
73
|
+
return optionStates.value[activeIndex.value]?.id;
|
|
74
|
+
});
|
|
75
|
+
function reset() {
|
|
76
|
+
activeKey.value = null;
|
|
77
|
+
}
|
|
78
|
+
function activateIndex(index) {
|
|
79
|
+
const item = options.items()[index];
|
|
80
|
+
if (!item || isDisabled(item)) return;
|
|
81
|
+
activeKey.value = options.getKey(item);
|
|
82
|
+
}
|
|
83
|
+
function activate(target) {
|
|
84
|
+
if (target === "first") {
|
|
85
|
+
const first = enabledIndexes.value[0];
|
|
86
|
+
if (first === void 0) reset();
|
|
87
|
+
else activateIndex(first);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (target === "last") {
|
|
91
|
+
const indexes = enabledIndexes.value;
|
|
92
|
+
const last = indexes[indexes.length - 1];
|
|
93
|
+
if (last === void 0) reset();
|
|
94
|
+
else activateIndex(last);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (target === "selected") {
|
|
98
|
+
const selectedIndex = options.items().findIndex((item) => isSelected(item) && !isDisabled(item));
|
|
99
|
+
if (selectedIndex >= 0) activateIndex(selectedIndex);
|
|
100
|
+
else activate("first");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (!isDisabled(target)) activeKey.value = options.getKey(target);
|
|
104
|
+
}
|
|
105
|
+
function move(direction) {
|
|
106
|
+
if (activeIndex.value < 0) {
|
|
107
|
+
activate(direction === 1 ? "first" : "last");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const nextIndex = getNextEnabledIndex(options.items(), activeIndex.value, direction, isDisabled, loop);
|
|
111
|
+
if (nextIndex === void 0) reset();
|
|
112
|
+
else activateIndex(nextIndex);
|
|
113
|
+
}
|
|
114
|
+
watch(activeIndex, (index) => {
|
|
115
|
+
if (activeKey.value != null && index < 0) reset();
|
|
116
|
+
}, { flush: "sync" });
|
|
117
|
+
watch([activeDescendantId, options.collectionRef], ([id, collection]) => {
|
|
118
|
+
if (!id || !collection) return;
|
|
119
|
+
findActiveDescendant(collection, id)?.scrollIntoView?.({ block: "nearest" });
|
|
120
|
+
}, {
|
|
121
|
+
flush: "post",
|
|
122
|
+
immediate: true
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
options: optionStates,
|
|
126
|
+
activeIndex,
|
|
127
|
+
activeDescendantId,
|
|
128
|
+
activate,
|
|
129
|
+
move,
|
|
130
|
+
reset
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { useClickOutside as n, chevrons_up_down_default as r, useFlatOptionCollection as t };
|