ropav 0.1.7 → 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 +1 -1
- package/dist/ancestry.js +136 -0
- package/dist/calendar.css +173 -0
- package/dist/calendar.js +714 -0
- package/dist/calendar2.js +37 -0
- package/dist/chevron-left.js +12 -0
- package/dist/color-picker.js +38 -88
- package/dist/combobox.css +251 -0
- package/dist/combobox.js +410 -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/color-picker/useColorPickerDrag.d.ts +1 -1
- package/dist/components/color-picker/useColorPickerSaturation.d.ts +1 -1
- package/dist/components/color-picker/useColorPickerSlider.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/dropdown-menu/dropdown-menu-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdownMenuContext.d.ts +7 -18
- package/dist/components/dropdown-menu/dropdownMenuInteraction.d.ts +3 -3
- package/dist/components/dropdown-menu/dropdownMenuInteractionTypes.d.ts +58 -29
- package/dist/components/dropdown-menu/useDropdownMenuDataController.d.ts +4 -3
- package/dist/components/dropdown-menu/useDropdownMenuDataRegistration.d.ts +6 -4
- package/dist/components/dropdown-menu/useDropdownMenuPresentation.d.ts +3 -4
- package/dist/components/dropdown-menu/useDropdownMenuTargetBindings.d.ts +5 -5
- 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 +1 -1
- package/dist/components/floating/useFloatingPosition.d.ts +1 -13
- 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/useNumberInput.d.ts +1 -3
- package/dist/components/popover/usePopoverBindings.d.ts +3 -6
- package/dist/components/scroll-area/useScrollArea.d.ts +4 -4
- package/dist/components/scroll-area/useScrollAreaAttributes.d.ts +3 -3
- package/dist/components/scroll-area/useScrollAreaPointer.d.ts +1 -1
- 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/useRangeSlider.d.ts +1 -1
- package/dist/components/slider/useRangeSliderPointer.d.ts +1 -1
- 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/tooltip/useTooltipTargetBindings.d.ts +12 -0
- package/dist/date-picker.css +49 -0
- package/dist/date-picker.js +809 -0
- package/dist/dialog.js +9 -20
- package/dist/direction.js +6 -0
- package/dist/dropdown-menu.css +21 -3
- package/dist/dropdown-menu.js +341 -261
- package/dist/dropzone.css +135 -0
- package/dist/dropzone.js +431 -0
- package/dist/file-input.css +135 -0
- package/dist/file-input.js +198 -0
- package/dist/hover-card.css +80 -0
- package/dist/hover-card.js +402 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +14 -3
- package/dist/internal/composables/useOverlayLayer.d.ts +12 -0
- package/dist/modal.js +1 -1
- 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 +36 -38
- package/dist/pagination.js +1 -10
- package/dist/pointerSession.js +130 -0
- package/dist/popover.css +21 -3
- package/dist/popover.js +37 -62
- package/dist/scroll-area.js +52 -62
- package/dist/segmented-control.css +176 -0
- package/dist/segmented-control.js +382 -0
- package/dist/select.css +50 -48
- package/dist/select.js +121 -271
- package/dist/slider.js +70 -129
- package/dist/tags-input.css +197 -0
- package/dist/tags-input.js +380 -0
- package/dist/tooltip.js +35 -30
- package/dist/useEditableOptionList.js +216 -0
- package/dist/useFlatOptionCollection.js +134 -0
- package/dist/useFloatingPosition.js +4 -160
- package/dist/useFloatingTargetLifecycle.js +127 -0
- package/dist/useFormControl.js +1 -0
- package/dist/{floating.js → useHoverDisclosure.js} +338 -421
- package/dist/useNativeChoiceTransaction.js +46 -0
- package/dist/useNativeFileSelection.js +86 -0
- package/dist/useOverlayZIndex.js +246 -15
- package/dist/utils/date.d.ts +13 -0
- package/dist/utils/dateAvailability.d.ts +7 -0
- package/dist/utils/dom/ancestry.d.ts +1 -0
- package/dist/utils/dom/direction.d.ts +2 -0
- package/dist/utils/dom/files.d.ts +3 -0
- package/dist/utils/dom/nativeChoice.d.ts +17 -0
- package/dist/utils/dom/pointerSession.d.ts +20 -0
- package/dist/utils/dom/scroll.d.ts +2 -1
- package/dist/utils/optionFilter.d.ts +5 -0
- package/docs/public-floating-api.md +7 -4
- package/docs/public-styles-api.md +25 -12
- package/package.json +39 -3
- package/src/styles/_mixins.scss +26 -0
- package/src/styles/styles-manifest.json +1 -2
- package/dist/components/floating/hoverDisclosureInteractionModel.d.ts +0 -42
- package/dist/components/floating/useHoverDisclosureInteractions.d.ts +0 -32
- package/dist/components/floating/useHoverDisclosureOpenState.d.ts +0 -25
- package/dist/components/floating/useHoverDisclosureTargetBinding.d.ts +0 -27
- package/dist/components/select/useSelectNativeControl.d.ts +0 -9
- package/dist/components/select/useSelectNativeValue.d.ts +0 -9
- package/dist/pointer.js +0 -9
- package/dist/utils/dom/pointer.d.ts +0 -2
|
@@ -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 };
|
|
@@ -1,132 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as isElement } from "./query.js";
|
|
2
|
+
import { n as observeComposedAncestry } from "./ancestry.js";
|
|
3
|
+
import { nextTick, onBeforeUnmount, readonly, ref, toValue, watch } from "vue";
|
|
4
4
|
import { arrow, autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
5
|
-
//#region src/utils/dom/ancestry.ts
|
|
6
|
-
function getFrameElement(documentNode) {
|
|
7
|
-
try {
|
|
8
|
-
const frameElement = documentNode.defaultView?.frameElement;
|
|
9
|
-
return isElement(frameElement) ? frameElement : null;
|
|
10
|
-
} catch {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function getComposedParent(node) {
|
|
15
|
-
if (isElement(node) && node.assignedSlot) return node.assignedSlot;
|
|
16
|
-
if (node.parentNode) return node.parentNode;
|
|
17
|
-
if (node.nodeType === 9) return getFrameElement(node);
|
|
18
|
-
const host = "host" in node ? node.host : null;
|
|
19
|
-
return isElement(host) ? host : null;
|
|
20
|
-
}
|
|
21
|
-
function getComposedAncestry(node) {
|
|
22
|
-
const ancestry = [];
|
|
23
|
-
let current = node ?? null;
|
|
24
|
-
while (current) {
|
|
25
|
-
current = getComposedParent(current);
|
|
26
|
-
if (current) ancestry.push(current);
|
|
27
|
-
}
|
|
28
|
-
return ancestry;
|
|
29
|
-
}
|
|
30
|
-
function areNodeListsIdentical(left, right) {
|
|
31
|
-
return left.length === right.length && left.every((node, index) => node === right[index]);
|
|
32
|
-
}
|
|
33
|
-
function readComposedAncestryPaths(nodes) {
|
|
34
|
-
return nodes.map((node) => node ? [node, ...getComposedAncestry(node)] : []);
|
|
35
|
-
}
|
|
36
|
-
function areAncestryPathsIdentical(left, right) {
|
|
37
|
-
return left.length === right.length && left.every((path, index) => areNodeListsIdentical(path, right[index] ?? []));
|
|
38
|
-
}
|
|
39
|
-
function getNodeDocument(node) {
|
|
40
|
-
return node.nodeType === 9 ? node : node.ownerDocument;
|
|
41
|
-
}
|
|
42
|
-
function getMutationObserverConstructor(node) {
|
|
43
|
-
return getNodeDocument(node)?.defaultView?.MutationObserver ?? globalThis.MutationObserver;
|
|
44
|
-
}
|
|
45
|
-
function isShadowRootNode(node) {
|
|
46
|
-
return node.nodeType === 11 && "host" in node && isElement(node.host);
|
|
47
|
-
}
|
|
48
|
-
function hasDisconnectedAncestry(nodes) {
|
|
49
|
-
return nodes.some((node) => node != null && [node, ...getComposedAncestry(node)].some((ancestor) => !ancestor.isConnected));
|
|
50
|
-
}
|
|
51
|
-
function observeComposedAncestry(getNodes, onChange, options = {}) {
|
|
52
|
-
let paths = readComposedAncestryPaths(getNodes());
|
|
53
|
-
let mutationObservers = [];
|
|
54
|
-
let slotRoots = [];
|
|
55
|
-
let disposed = false;
|
|
56
|
-
const reconnectScheduler = createRafScheduler(check, getView);
|
|
57
|
-
function getView() {
|
|
58
|
-
for (const node of getNodes()) {
|
|
59
|
-
const view = node ? getNodeDocument(node)?.defaultView : null;
|
|
60
|
-
if (view) return view;
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
function scheduleReconnectCheck(nodes) {
|
|
65
|
-
if (!hasDisconnectedAncestry(nodes)) return;
|
|
66
|
-
if (!getView()?.requestAnimationFrame) return;
|
|
67
|
-
reconnectScheduler.schedule();
|
|
68
|
-
}
|
|
69
|
-
function disconnectTargets() {
|
|
70
|
-
for (const observer of mutationObservers) observer.disconnect();
|
|
71
|
-
mutationObservers = [];
|
|
72
|
-
for (const root of slotRoots) root.removeEventListener("slotchange", check);
|
|
73
|
-
slotRoots = [];
|
|
74
|
-
}
|
|
75
|
-
function observeTargets(nodes, nextPaths) {
|
|
76
|
-
const observedNodes = new Set(nextPaths.flat());
|
|
77
|
-
const nextSlotRoots = /* @__PURE__ */ new Set();
|
|
78
|
-
const observersByConstructor = /* @__PURE__ */ new Map();
|
|
79
|
-
for (const node of observedNodes) {
|
|
80
|
-
if (isElement(node) && node.shadowRoot) nextSlotRoots.add(node.shadowRoot);
|
|
81
|
-
if (isShadowRootNode(node)) nextSlotRoots.add(node);
|
|
82
|
-
const MutationObserverConstructor = getMutationObserverConstructor(node);
|
|
83
|
-
if (!MutationObserverConstructor) continue;
|
|
84
|
-
let observer = observersByConstructor.get(MutationObserverConstructor);
|
|
85
|
-
if (!observer) {
|
|
86
|
-
observer = new MutationObserverConstructor(check);
|
|
87
|
-
observersByConstructor.set(MutationObserverConstructor, observer);
|
|
88
|
-
}
|
|
89
|
-
if (isElement(node)) observer.observe(node, {
|
|
90
|
-
childList: true,
|
|
91
|
-
attributes: true,
|
|
92
|
-
attributeFilter: ["slot", "name"]
|
|
93
|
-
});
|
|
94
|
-
else observer.observe(node, { childList: true });
|
|
95
|
-
}
|
|
96
|
-
mutationObservers = [...observersByConstructor.values()];
|
|
97
|
-
slotRoots = [...nextSlotRoots];
|
|
98
|
-
for (const root of slotRoots) root.addEventListener("slotchange", check);
|
|
99
|
-
scheduleReconnectCheck(nodes);
|
|
100
|
-
}
|
|
101
|
-
function rebind(nodes, nextPaths) {
|
|
102
|
-
disconnectTargets();
|
|
103
|
-
paths = nextPaths;
|
|
104
|
-
observeTargets(nodes, paths);
|
|
105
|
-
}
|
|
106
|
-
function check() {
|
|
107
|
-
if (disposed) return;
|
|
108
|
-
const nodes = getNodes();
|
|
109
|
-
if (options.deferWhileDisconnected && hasDisconnectedAncestry(nodes)) {
|
|
110
|
-
scheduleReconnectCheck(nodes);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
reconnectScheduler.cancel();
|
|
114
|
-
const nextPaths = readComposedAncestryPaths(nodes);
|
|
115
|
-
if (areAncestryPathsIdentical(paths, nextPaths)) return;
|
|
116
|
-
rebind(nodes, nextPaths);
|
|
117
|
-
onChange();
|
|
118
|
-
}
|
|
119
|
-
const initialNodes = getNodes();
|
|
120
|
-
paths = readComposedAncestryPaths(initialNodes);
|
|
121
|
-
observeTargets(initialNodes, paths);
|
|
122
|
-
return () => {
|
|
123
|
-
if (disposed) return;
|
|
124
|
-
disposed = true;
|
|
125
|
-
reconnectScheduler.cancel();
|
|
126
|
-
disconnectTargets();
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
5
|
//#region src/components/floating/useFloatingPosition.ts
|
|
131
6
|
var DEFAULT_ARROW_PADDING = 4;
|
|
132
7
|
var DEFAULT_COLLISION_PADDING = 8;
|
|
@@ -137,37 +12,6 @@ function getReferenceElement(reference) {
|
|
|
137
12
|
if (isElement(reference)) return reference;
|
|
138
13
|
return reference && isElement(reference.contextElement) ? reference.contextElement : null;
|
|
139
14
|
}
|
|
140
|
-
function readFloatingTarget(target) {
|
|
141
|
-
return isRef(target) ? target.value : target;
|
|
142
|
-
}
|
|
143
|
-
function isVirtualReference(value) {
|
|
144
|
-
if (value == null || typeof value !== "object") return false;
|
|
145
|
-
return "getBoundingClientRect" in value && typeof value.getBoundingClientRect === "function";
|
|
146
|
-
}
|
|
147
|
-
function resolveFloatingTarget(target) {
|
|
148
|
-
if (!target) return null;
|
|
149
|
-
if (typeof target !== "string") return isVirtualReference(target) ? target : null;
|
|
150
|
-
return querySelectorSafe(target);
|
|
151
|
-
}
|
|
152
|
-
function useFloatingTarget(getTarget, fallback) {
|
|
153
|
-
const resolvedTarget = shallowRef(null);
|
|
154
|
-
const isExplicitTarget = computed(() => {
|
|
155
|
-
const target = readFloatingTarget(getTarget());
|
|
156
|
-
return target != null && target !== "";
|
|
157
|
-
});
|
|
158
|
-
const reference = computed(() => isExplicitTarget.value ? resolvedTarget.value : fallback.value);
|
|
159
|
-
function syncTarget() {
|
|
160
|
-
resolvedTarget.value = isExplicitTarget.value ? resolveFloatingTarget(readFloatingTarget(getTarget())) : null;
|
|
161
|
-
}
|
|
162
|
-
watch(() => readFloatingTarget(getTarget()), syncTarget, { flush: "post" });
|
|
163
|
-
onMounted(syncTarget);
|
|
164
|
-
return {
|
|
165
|
-
isExplicitTarget,
|
|
166
|
-
reference,
|
|
167
|
-
resolvedTarget,
|
|
168
|
-
syncTarget
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
15
|
function useFloatingPosition(options) {
|
|
172
16
|
const actualPlacement = ref(getPlacement());
|
|
173
17
|
const isPositioned = ref(false);
|
|
@@ -322,4 +166,4 @@ function useFloatingPosition(options) {
|
|
|
322
166
|
};
|
|
323
167
|
}
|
|
324
168
|
//#endregion
|
|
325
|
-
export {
|
|
169
|
+
export { useFloatingPosition as t };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { i as querySelectorSafe, t as isElement } from "./query.js";
|
|
2
|
+
import { a as snapshotAttributes, i as restoreAttributes } from "./attributes2.js";
|
|
3
|
+
import { computed, isRef, onBeforeUnmount, onMounted, shallowRef, watch, watchEffect } from "vue";
|
|
4
|
+
//#region src/components/floating/useFloatingTargetLifecycle.ts
|
|
5
|
+
var SELECTOR_OBSERVER_OPTIONS = {
|
|
6
|
+
attributes: true,
|
|
7
|
+
childList: true,
|
|
8
|
+
subtree: true
|
|
9
|
+
};
|
|
10
|
+
function readTarget(target) {
|
|
11
|
+
return isRef(target) ? target.value : target;
|
|
12
|
+
}
|
|
13
|
+
function isVirtualReference(value) {
|
|
14
|
+
if (value == null || typeof value !== "object") return false;
|
|
15
|
+
return "getBoundingClientRect" in value && typeof value.getBoundingClientRect === "function";
|
|
16
|
+
}
|
|
17
|
+
function resolveTarget(target) {
|
|
18
|
+
if (!target) return null;
|
|
19
|
+
if (typeof target !== "string") return isVirtualReference(target) ? target : null;
|
|
20
|
+
return querySelectorSafe(target);
|
|
21
|
+
}
|
|
22
|
+
function getMutationObserverConstructor() {
|
|
23
|
+
if (typeof document === "undefined") return void 0;
|
|
24
|
+
return document.defaultView?.MutationObserver ?? globalThis.MutationObserver;
|
|
25
|
+
}
|
|
26
|
+
function useFloatingTargetLifecycle({ target, fallback, getTargetElement }) {
|
|
27
|
+
const resolvedTarget = shallowRef(null);
|
|
28
|
+
const isExplicitTarget = computed(() => {
|
|
29
|
+
const currentTarget = readTarget(target());
|
|
30
|
+
return currentTarget != null && currentTarget !== "";
|
|
31
|
+
});
|
|
32
|
+
const reference = computed(() => isExplicitTarget.value ? resolvedTarget.value : fallback.value);
|
|
33
|
+
const targetElement = computed(() => {
|
|
34
|
+
const currentTarget = resolvedTarget.value;
|
|
35
|
+
if (!currentTarget) return null;
|
|
36
|
+
if (getTargetElement) return getTargetElement(currentTarget);
|
|
37
|
+
return isElement(currentTarget) ? currentTarget : null;
|
|
38
|
+
});
|
|
39
|
+
let selectorObserver;
|
|
40
|
+
let selectorObserverActive = false;
|
|
41
|
+
let ownedAttributeMutationDepth = 0;
|
|
42
|
+
let selectorSyncScheduled = false;
|
|
43
|
+
function syncTarget() {
|
|
44
|
+
resolvedTarget.value = isExplicitTarget.value ? resolveTarget(readTarget(target())) : null;
|
|
45
|
+
}
|
|
46
|
+
function stopObservingSelector() {
|
|
47
|
+
selectorObserverActive = false;
|
|
48
|
+
selectorObserver?.disconnect();
|
|
49
|
+
selectorObserver = void 0;
|
|
50
|
+
}
|
|
51
|
+
function scheduleSelectorSync() {
|
|
52
|
+
if (selectorSyncScheduled) return;
|
|
53
|
+
selectorSyncScheduled = true;
|
|
54
|
+
queueMicrotask(() => {
|
|
55
|
+
selectorSyncScheduled = false;
|
|
56
|
+
if (selectorObserverActive) syncTarget();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function mutateWithoutSelectorObservation(mutate) {
|
|
60
|
+
const observer = selectorObserver;
|
|
61
|
+
const shouldPause = observer !== void 0 && selectorObserverActive && ownedAttributeMutationDepth === 0;
|
|
62
|
+
ownedAttributeMutationDepth += 1;
|
|
63
|
+
if (shouldPause) {
|
|
64
|
+
if (observer.takeRecords().length > 0) scheduleSelectorSync();
|
|
65
|
+
observer.disconnect();
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
mutate();
|
|
69
|
+
} finally {
|
|
70
|
+
ownedAttributeMutationDepth -= 1;
|
|
71
|
+
if (shouldPause && selectorObserverActive && selectorObserver === observer && typeof document !== "undefined") observer.observe(document, SELECTOR_OBSERVER_OPTIONS);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function observeSelector() {
|
|
75
|
+
stopObservingSelector();
|
|
76
|
+
const currentTarget = readTarget(target());
|
|
77
|
+
const MutationObserverConstructor = getMutationObserverConstructor();
|
|
78
|
+
if (typeof currentTarget !== "string" || !MutationObserverConstructor || typeof document === "undefined") return;
|
|
79
|
+
const observer = new MutationObserverConstructor(syncTarget);
|
|
80
|
+
selectorObserver = observer;
|
|
81
|
+
selectorObserverActive = true;
|
|
82
|
+
observer.observe(document, SELECTOR_OBSERVER_OPTIONS);
|
|
83
|
+
}
|
|
84
|
+
function syncLifecycle() {
|
|
85
|
+
syncTarget();
|
|
86
|
+
observeSelector();
|
|
87
|
+
}
|
|
88
|
+
function bindTarget(adapter) {
|
|
89
|
+
watchEffect((onCleanup) => {
|
|
90
|
+
const currentTarget = targetElement.value;
|
|
91
|
+
if (!currentTarget) return;
|
|
92
|
+
const disconnect = adapter.connect?.(currentTarget);
|
|
93
|
+
const listeners = adapter.listeners ?? [];
|
|
94
|
+
for (const [type, listener, options] of listeners) currentTarget.addEventListener(type, listener, options);
|
|
95
|
+
onCleanup(() => {
|
|
96
|
+
for (const [type, listener, options] of listeners) currentTarget.removeEventListener(type, listener, options);
|
|
97
|
+
disconnect?.();
|
|
98
|
+
});
|
|
99
|
+
}, { flush: "sync" });
|
|
100
|
+
const attributeAdapter = adapter.attributes;
|
|
101
|
+
if (!attributeAdapter) return;
|
|
102
|
+
watchEffect((onCleanup) => {
|
|
103
|
+
const currentTarget = targetElement.value;
|
|
104
|
+
if (!currentTarget || attributeAdapter.isActive?.() === false) return;
|
|
105
|
+
const snapshot = snapshotAttributes(currentTarget, attributeAdapter.names);
|
|
106
|
+
mutateWithoutSelectorObservation(() => {
|
|
107
|
+
attributeAdapter.apply(currentTarget, snapshot);
|
|
108
|
+
});
|
|
109
|
+
onCleanup(() => {
|
|
110
|
+
mutateWithoutSelectorObservation(() => {
|
|
111
|
+
restoreAttributes(currentTarget, snapshot);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}, { flush: "sync" });
|
|
115
|
+
}
|
|
116
|
+
watch(() => readTarget(target()), syncLifecycle, { flush: "post" });
|
|
117
|
+
onMounted(syncLifecycle);
|
|
118
|
+
onBeforeUnmount(stopObservingSelector);
|
|
119
|
+
return {
|
|
120
|
+
bindTarget,
|
|
121
|
+
isExplicitTarget,
|
|
122
|
+
reference,
|
|
123
|
+
targetElement
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { useFloatingTargetLifecycle as t };
|
package/dist/useFormControl.js
CHANGED
|
@@ -37,6 +37,7 @@ function useFormControl(options) {
|
|
|
37
37
|
const elements = getElements(options).filter((element) => element.form === form);
|
|
38
38
|
if (elements.length === 0) return;
|
|
39
39
|
queueMicrotask(() => {
|
|
40
|
+
if (event.defaultPrevented) return;
|
|
40
41
|
if (options.isControlled()) options.syncControlledValue(elements);
|
|
41
42
|
else options.readResetValue(elements);
|
|
42
43
|
});
|