agentation-vue 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +27 -0
- package/dist/AgentationVue.d.vue.ts +27 -0
- package/dist/AgentationVue.vue +839 -0
- package/dist/AgentationVue.vue.d.ts +27 -0
- package/dist/components/AgentationToolbar.d.vue.ts +36 -0
- package/dist/components/AgentationToolbar.vue +233 -0
- package/dist/components/AgentationToolbar.vue.d.ts +36 -0
- package/dist/components/AnnotationInput.d.vue.ts +21 -0
- package/dist/components/AnnotationInput.vue +105 -0
- package/dist/components/AnnotationInput.vue.d.ts +21 -0
- package/dist/components/AnnotationMarker.d.vue.ts +15 -0
- package/dist/components/AnnotationMarker.vue +46 -0
- package/dist/components/AnnotationMarker.vue.d.ts +15 -0
- package/dist/components/ComponentChain.d.vue.ts +10 -0
- package/dist/components/ComponentChain.vue +91 -0
- package/dist/components/ComponentChain.vue.d.ts +10 -0
- package/dist/components/ElementHighlight.d.vue.ts +9 -0
- package/dist/components/ElementHighlight.vue +33 -0
- package/dist/components/ElementHighlight.vue.d.ts +9 -0
- package/dist/components/SettingsPanel.d.vue.ts +10 -0
- package/dist/components/SettingsPanel.vue +143 -0
- package/dist/components/SettingsPanel.vue.d.ts +10 -0
- package/dist/components/SettingsPopover.d.vue.ts +14 -0
- package/dist/components/SettingsPopover.vue +235 -0
- package/dist/components/SettingsPopover.vue.d.ts +14 -0
- package/dist/components/VaButton.d.vue.ts +23 -0
- package/dist/components/VaButton.vue +19 -0
- package/dist/components/VaButton.vue.d.ts +23 -0
- package/dist/components/VaIcon.d.vue.ts +6 -0
- package/dist/components/VaIcon.vue +18 -0
- package/dist/components/VaIcon.vue.d.ts +6 -0
- package/dist/components/VaIconButton.d.vue.ts +25 -0
- package/dist/components/VaIconButton.vue +43 -0
- package/dist/components/VaIconButton.vue.d.ts +25 -0
- package/dist/components/VaToggle.d.vue.ts +10 -0
- package/dist/components/VaToggle.vue +23 -0
- package/dist/components/VaToggle.vue.d.ts +10 -0
- package/dist/composables/useAnimationPause.d.ts +7 -0
- package/dist/composables/useAnimationPause.js +52 -0
- package/dist/composables/useAnimationPause.mjs +43 -0
- package/dist/composables/useAnnotations.d.ts +105 -0
- package/dist/composables/useAnnotations.js +106 -0
- package/dist/composables/useAnnotations.mjs +108 -0
- package/dist/composables/useAreaSelect.d.ts +21 -0
- package/dist/composables/useAreaSelect.js +62 -0
- package/dist/composables/useAreaSelect.mjs +41 -0
- package/dist/composables/useElementDetection.d.ts +22 -0
- package/dist/composables/useElementDetection.js +85 -0
- package/dist/composables/useElementDetection.mjs +82 -0
- package/dist/composables/useInteractionMode.d.ts +5 -0
- package/dist/composables/useInteractionMode.js +29 -0
- package/dist/composables/useInteractionMode.mjs +20 -0
- package/dist/composables/useKeyboardShortcuts.d.ts +43 -0
- package/dist/composables/useKeyboardShortcuts.js +202 -0
- package/dist/composables/useKeyboardShortcuts.mjs +223 -0
- package/dist/composables/useMarkerPositions.d.ts +5 -0
- package/dist/composables/useMarkerPositions.js +45 -0
- package/dist/composables/useMarkerPositions.mjs +36 -0
- package/dist/composables/useMultiSelect.d.ts +20 -0
- package/dist/composables/useMultiSelect.js +108 -0
- package/dist/composables/useMultiSelect.mjs +85 -0
- package/dist/composables/useOutputFormatter.d.ts +5 -0
- package/dist/composables/useOutputFormatter.js +100 -0
- package/dist/composables/useOutputFormatter.mjs +91 -0
- package/dist/composables/useSettings.d.ts +14 -0
- package/dist/composables/useSettings.js +48 -0
- package/dist/composables/useSettings.mjs +38 -0
- package/dist/composables/useTextSelection.d.ts +11 -0
- package/dist/composables/useTextSelection.js +33 -0
- package/dist/composables/useTextSelection.mjs +22 -0
- package/dist/composables/useToolbarAutoHide.d.ts +19 -0
- package/dist/composables/useToolbarAutoHide.js +270 -0
- package/dist/composables/useToolbarAutoHide.mjs +208 -0
- package/dist/composables/useToolbarDragSnap.d.ts +30 -0
- package/dist/composables/useToolbarDragSnap.js +296 -0
- package/dist/composables/useToolbarDragSnap.mjs +245 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +8 -0
- package/dist/constants.mjs +2 -0
- package/dist/directives/vaTooltip.d.ts +22 -0
- package/dist/directives/vaTooltip.js +241 -0
- package/dist/directives/vaTooltip.mjs +257 -0
- package/dist/icons.d.ts +16 -0
- package/dist/icons.js +21 -0
- package/dist/icons.mjs +15 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +168 -0
- package/dist/index.mjs +30 -0
- package/dist/styles/agentation.css +1 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +1 -0
- package/dist/types.mjs +0 -0
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.js +22 -0
- package/dist/utils/clipboard.mjs +16 -0
- package/dist/utils/dom-inspector.d.ts +7 -0
- package/dist/utils/dom-inspector.js +168 -0
- package/dist/utils/dom-inspector.mjs +242 -0
- package/dist/utils/math.d.ts +1 -0
- package/dist/utils/math.js +9 -0
- package/dist/utils/math.mjs +3 -0
- package/dist/utils/portal.d.ts +2 -0
- package/dist/utils/portal.js +18 -0
- package/dist/utils/portal.mjs +11 -0
- package/dist/utils/selectors.d.ts +3 -0
- package/dist/utils/selectors.js +103 -0
- package/dist/utils/selectors.mjs +105 -0
- package/dist/utils/style.d.ts +2 -0
- package/dist/utils/style.js +14 -0
- package/dist/utils/style.mjs +8 -0
- package/package.json +49 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.vaTooltipDirective = exports.default = void 0;
|
|
7
|
+
const TOOLTIP_STATE_KEY = "__vaTooltipState";
|
|
8
|
+
const TOOLTIP_MARGIN = 8;
|
|
9
|
+
const DEFAULT_OFFSET = 12;
|
|
10
|
+
const DEFAULT_SHOW_DELAY = 300;
|
|
11
|
+
function normalizeTooltipValue(value) {
|
|
12
|
+
if (!value) return null;
|
|
13
|
+
if (typeof value === "string") {
|
|
14
|
+
const text2 = value.trim();
|
|
15
|
+
if (!text2) return null;
|
|
16
|
+
return {
|
|
17
|
+
text: text2,
|
|
18
|
+
placement: "top",
|
|
19
|
+
offset: DEFAULT_OFFSET,
|
|
20
|
+
showDelay: DEFAULT_SHOW_DELAY
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (typeof value !== "object") return null;
|
|
24
|
+
if (value.disabled) return null;
|
|
25
|
+
const text = typeof value.text === "string" ? value.text.trim() : "";
|
|
26
|
+
if (!text) return null;
|
|
27
|
+
const shortcut = typeof value.shortcut === "string" ? value.shortcut.trim() : void 0;
|
|
28
|
+
const placement = value.placement === "bottom" ? "bottom" : "top";
|
|
29
|
+
const offset = Number.isFinite(value.offset) ? Math.max(4, Number(value.offset)) : DEFAULT_OFFSET;
|
|
30
|
+
const showDelay = Number.isFinite(value.showDelay) ? Math.max(0, Number(value.showDelay)) : DEFAULT_SHOW_DELAY;
|
|
31
|
+
return {
|
|
32
|
+
text,
|
|
33
|
+
shortcut: shortcut || void 0,
|
|
34
|
+
placement,
|
|
35
|
+
offset,
|
|
36
|
+
showDelay
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function getState(el) {
|
|
40
|
+
return el[TOOLTIP_STATE_KEY];
|
|
41
|
+
}
|
|
42
|
+
function isHostDisabled(el) {
|
|
43
|
+
if ("disabled" in el) return Boolean(el.disabled);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
function createTooltipElement(value) {
|
|
47
|
+
const tooltipEl = document.createElement("div");
|
|
48
|
+
tooltipEl.className = "__va-tooltip";
|
|
49
|
+
tooltipEl.setAttribute("role", "tooltip");
|
|
50
|
+
updateTooltipContent(tooltipEl, value);
|
|
51
|
+
return tooltipEl;
|
|
52
|
+
}
|
|
53
|
+
function updateTooltipContent(tooltipEl, value) {
|
|
54
|
+
tooltipEl.innerHTML = "";
|
|
55
|
+
tooltipEl.setAttribute("data-placement", value.placement);
|
|
56
|
+
const labelEl = document.createElement("span");
|
|
57
|
+
labelEl.className = "__va-tooltip-label";
|
|
58
|
+
labelEl.textContent = value.text;
|
|
59
|
+
tooltipEl.appendChild(labelEl);
|
|
60
|
+
if (value.shortcut) {
|
|
61
|
+
const shortcutEl = document.createElement("kbd");
|
|
62
|
+
shortcutEl.className = "__va-tooltip-shortcut";
|
|
63
|
+
shortcutEl.textContent = value.shortcut;
|
|
64
|
+
tooltipEl.appendChild(shortcutEl);
|
|
65
|
+
}
|
|
66
|
+
const arrowEl = document.createElement("span");
|
|
67
|
+
arrowEl.className = "__va-tooltip-arrow";
|
|
68
|
+
arrowEl.setAttribute("aria-hidden", "true");
|
|
69
|
+
tooltipEl.appendChild(arrowEl);
|
|
70
|
+
}
|
|
71
|
+
function positionTooltip(el) {
|
|
72
|
+
const state = getState(el);
|
|
73
|
+
if (!state?.value || !state.tooltipEl) return;
|
|
74
|
+
const tooltipEl = state.tooltipEl;
|
|
75
|
+
const hostRect = el.getBoundingClientRect();
|
|
76
|
+
const viewportWidth = window.innerWidth;
|
|
77
|
+
const viewportHeight = window.innerHeight;
|
|
78
|
+
tooltipEl.style.left = "0px";
|
|
79
|
+
tooltipEl.style.top = "0px";
|
|
80
|
+
const tooltipRect = tooltipEl.getBoundingClientRect();
|
|
81
|
+
let placement = state.value.placement;
|
|
82
|
+
let top = placement === "top" ? hostRect.top - tooltipRect.height - state.value.offset : hostRect.bottom + state.value.offset;
|
|
83
|
+
if (placement === "top" && top < TOOLTIP_MARGIN) {
|
|
84
|
+
placement = "bottom";
|
|
85
|
+
top = hostRect.bottom + state.value.offset;
|
|
86
|
+
} else if (placement === "bottom" && top + tooltipRect.height > viewportHeight - TOOLTIP_MARGIN) {
|
|
87
|
+
placement = "top";
|
|
88
|
+
top = hostRect.top - tooltipRect.height - state.value.offset;
|
|
89
|
+
}
|
|
90
|
+
const centeredLeft = hostRect.left + hostRect.width / 2 - tooltipRect.width / 2;
|
|
91
|
+
const maxLeft = Math.max(TOOLTIP_MARGIN, viewportWidth - tooltipRect.width - TOOLTIP_MARGIN);
|
|
92
|
+
const left = Math.min(Math.max(centeredLeft, TOOLTIP_MARGIN), maxLeft);
|
|
93
|
+
const maxTop = Math.max(TOOLTIP_MARGIN, viewportHeight - tooltipRect.height - TOOLTIP_MARGIN);
|
|
94
|
+
tooltipEl.setAttribute("data-placement", placement);
|
|
95
|
+
tooltipEl.style.left = `${Math.round(left)}px`;
|
|
96
|
+
tooltipEl.style.top = `${Math.round(Math.min(Math.max(top, TOOLTIP_MARGIN), maxTop))}px`;
|
|
97
|
+
}
|
|
98
|
+
function attachWindowListeners(el) {
|
|
99
|
+
const state = getState(el);
|
|
100
|
+
if (!state) return;
|
|
101
|
+
window.addEventListener("scroll", state.onWindowReposition, true);
|
|
102
|
+
window.addEventListener("resize", state.onWindowReposition, {
|
|
103
|
+
passive: true
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function detachWindowListeners(el) {
|
|
107
|
+
const state = getState(el);
|
|
108
|
+
if (!state) return;
|
|
109
|
+
window.removeEventListener("scroll", state.onWindowReposition, true);
|
|
110
|
+
window.removeEventListener("resize", state.onWindowReposition);
|
|
111
|
+
}
|
|
112
|
+
function clearShowTimer(el) {
|
|
113
|
+
const state = getState(el);
|
|
114
|
+
if (!state?.showTimer) return;
|
|
115
|
+
clearTimeout(state.showTimer);
|
|
116
|
+
state.showTimer = null;
|
|
117
|
+
}
|
|
118
|
+
function showTooltipNow(el) {
|
|
119
|
+
const state = getState(el);
|
|
120
|
+
if (!state?.value || isHostDisabled(el)) return;
|
|
121
|
+
if (!state.tooltipEl) state.tooltipEl = createTooltipElement(state.value);else updateTooltipContent(state.tooltipEl, state.value);
|
|
122
|
+
if (!document.body.contains(state.tooltipEl)) document.body.appendChild(state.tooltipEl);
|
|
123
|
+
positionTooltip(el);
|
|
124
|
+
state.tooltipEl.classList.add("__va-tooltip--visible");
|
|
125
|
+
attachWindowListeners(el);
|
|
126
|
+
}
|
|
127
|
+
function scheduleShowTooltip(el) {
|
|
128
|
+
const state = getState(el);
|
|
129
|
+
if (!state?.value || isHostDisabled(el)) return;
|
|
130
|
+
clearShowTimer(el);
|
|
131
|
+
if (state.value.showDelay <= 0) {
|
|
132
|
+
showTooltipNow(el);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
state.showTimer = setTimeout(() => {
|
|
136
|
+
state.showTimer = null;
|
|
137
|
+
showTooltipNow(el);
|
|
138
|
+
}, state.value.showDelay);
|
|
139
|
+
}
|
|
140
|
+
function hideTooltip(el) {
|
|
141
|
+
const state = getState(el);
|
|
142
|
+
if (!state) return;
|
|
143
|
+
clearShowTimer(el);
|
|
144
|
+
if (!state.tooltipEl) return;
|
|
145
|
+
detachWindowListeners(el);
|
|
146
|
+
state.tooltipEl.classList.remove("__va-tooltip--visible");
|
|
147
|
+
state.tooltipEl.remove();
|
|
148
|
+
}
|
|
149
|
+
function syncAriaLabel(el) {
|
|
150
|
+
const state = getState(el);
|
|
151
|
+
if (!state) return;
|
|
152
|
+
if (!state.value && state.ownsAriaLabel) {
|
|
153
|
+
el.removeAttribute("aria-label");
|
|
154
|
+
state.ownsAriaLabel = false;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!state.value) return;
|
|
158
|
+
if (!el.hasAttribute("aria-label")) {
|
|
159
|
+
el.setAttribute("aria-label", state.value.text);
|
|
160
|
+
state.ownsAriaLabel = true;
|
|
161
|
+
} else if (state.ownsAriaLabel) {
|
|
162
|
+
el.setAttribute("aria-label", state.value.text);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function updateTooltipValue(el, value) {
|
|
166
|
+
const state = getState(el);
|
|
167
|
+
if (!state) return;
|
|
168
|
+
state.value = normalizeTooltipValue(value);
|
|
169
|
+
syncAriaLabel(el);
|
|
170
|
+
if (!state.value) {
|
|
171
|
+
hideTooltip(el);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (state.tooltipEl) {
|
|
175
|
+
updateTooltipContent(state.tooltipEl, state.value);
|
|
176
|
+
positionTooltip(el);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function bindTooltip(el, binding) {
|
|
180
|
+
if (getState(el)) {
|
|
181
|
+
updateTooltipValue(el, binding.value);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const state = {
|
|
185
|
+
value: null,
|
|
186
|
+
tooltipEl: null,
|
|
187
|
+
ownsAriaLabel: false,
|
|
188
|
+
showTimer: null,
|
|
189
|
+
onMouseEnter: () => scheduleShowTooltip(el),
|
|
190
|
+
onMouseLeave: () => hideTooltip(el),
|
|
191
|
+
onFocus: () => scheduleShowTooltip(el),
|
|
192
|
+
onBlur: () => hideTooltip(el),
|
|
193
|
+
onPointerDown: () => hideTooltip(el),
|
|
194
|
+
onKeyDown: event => {
|
|
195
|
+
if (event.key === "Escape") hideTooltip(el);
|
|
196
|
+
},
|
|
197
|
+
onWindowReposition: () => positionTooltip(el)
|
|
198
|
+
};
|
|
199
|
+
el[TOOLTIP_STATE_KEY] = state;
|
|
200
|
+
el.addEventListener("mouseenter", state.onMouseEnter);
|
|
201
|
+
el.addEventListener("mouseleave", state.onMouseLeave);
|
|
202
|
+
el.addEventListener("focus", state.onFocus, true);
|
|
203
|
+
el.addEventListener("blur", state.onBlur, true);
|
|
204
|
+
el.addEventListener("pointerdown", state.onPointerDown);
|
|
205
|
+
el.addEventListener("keydown", state.onKeyDown);
|
|
206
|
+
updateTooltipValue(el, binding.value);
|
|
207
|
+
}
|
|
208
|
+
function unbindTooltip(el) {
|
|
209
|
+
const state = getState(el);
|
|
210
|
+
if (!state) return;
|
|
211
|
+
hideTooltip(el);
|
|
212
|
+
el.removeEventListener("mouseenter", state.onMouseEnter);
|
|
213
|
+
el.removeEventListener("mouseleave", state.onMouseLeave);
|
|
214
|
+
el.removeEventListener("focus", state.onFocus, true);
|
|
215
|
+
el.removeEventListener("blur", state.onBlur, true);
|
|
216
|
+
el.removeEventListener("pointerdown", state.onPointerDown);
|
|
217
|
+
el.removeEventListener("keydown", state.onKeyDown);
|
|
218
|
+
if (state.ownsAriaLabel) el.removeAttribute("aria-label");
|
|
219
|
+
delete el[TOOLTIP_STATE_KEY];
|
|
220
|
+
}
|
|
221
|
+
const vaTooltipDirective = exports.vaTooltipDirective = {
|
|
222
|
+
beforeMount(el, binding) {
|
|
223
|
+
bindTooltip(el, binding);
|
|
224
|
+
},
|
|
225
|
+
updated(el, binding) {
|
|
226
|
+
updateTooltipValue(el, binding.value);
|
|
227
|
+
},
|
|
228
|
+
unmounted(el) {
|
|
229
|
+
unbindTooltip(el);
|
|
230
|
+
},
|
|
231
|
+
bind(el, binding) {
|
|
232
|
+
bindTooltip(el, binding);
|
|
233
|
+
},
|
|
234
|
+
componentUpdated(el, binding) {
|
|
235
|
+
updateTooltipValue(el, binding.value);
|
|
236
|
+
},
|
|
237
|
+
unbind(el) {
|
|
238
|
+
unbindTooltip(el);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
module.exports = vaTooltipDirective;
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
const TOOLTIP_STATE_KEY = "__vaTooltipState";
|
|
2
|
+
const TOOLTIP_MARGIN = 8;
|
|
3
|
+
const DEFAULT_OFFSET = 12;
|
|
4
|
+
const DEFAULT_SHOW_DELAY = 300;
|
|
5
|
+
function normalizeTooltipValue(value) {
|
|
6
|
+
if (!value)
|
|
7
|
+
return null;
|
|
8
|
+
if (typeof value === "string") {
|
|
9
|
+
const text2 = value.trim();
|
|
10
|
+
if (!text2)
|
|
11
|
+
return null;
|
|
12
|
+
return {
|
|
13
|
+
text: text2,
|
|
14
|
+
placement: "top",
|
|
15
|
+
offset: DEFAULT_OFFSET,
|
|
16
|
+
showDelay: DEFAULT_SHOW_DELAY
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (typeof value !== "object")
|
|
20
|
+
return null;
|
|
21
|
+
if (value.disabled)
|
|
22
|
+
return null;
|
|
23
|
+
const text = typeof value.text === "string" ? value.text.trim() : "";
|
|
24
|
+
if (!text)
|
|
25
|
+
return null;
|
|
26
|
+
const shortcut = typeof value.shortcut === "string" ? value.shortcut.trim() : void 0;
|
|
27
|
+
const placement = value.placement === "bottom" ? "bottom" : "top";
|
|
28
|
+
const offset = Number.isFinite(value.offset) ? Math.max(4, Number(value.offset)) : DEFAULT_OFFSET;
|
|
29
|
+
const showDelay = Number.isFinite(value.showDelay) ? Math.max(0, Number(value.showDelay)) : DEFAULT_SHOW_DELAY;
|
|
30
|
+
return {
|
|
31
|
+
text,
|
|
32
|
+
shortcut: shortcut || void 0,
|
|
33
|
+
placement,
|
|
34
|
+
offset,
|
|
35
|
+
showDelay
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function getState(el) {
|
|
39
|
+
return el[TOOLTIP_STATE_KEY];
|
|
40
|
+
}
|
|
41
|
+
function isHostDisabled(el) {
|
|
42
|
+
if ("disabled" in el)
|
|
43
|
+
return Boolean(el.disabled);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
function createTooltipElement(value) {
|
|
47
|
+
const tooltipEl = document.createElement("div");
|
|
48
|
+
tooltipEl.className = "__va-tooltip";
|
|
49
|
+
tooltipEl.setAttribute("role", "tooltip");
|
|
50
|
+
updateTooltipContent(tooltipEl, value);
|
|
51
|
+
return tooltipEl;
|
|
52
|
+
}
|
|
53
|
+
function updateTooltipContent(tooltipEl, value) {
|
|
54
|
+
tooltipEl.innerHTML = "";
|
|
55
|
+
tooltipEl.setAttribute("data-placement", value.placement);
|
|
56
|
+
const labelEl = document.createElement("span");
|
|
57
|
+
labelEl.className = "__va-tooltip-label";
|
|
58
|
+
labelEl.textContent = value.text;
|
|
59
|
+
tooltipEl.appendChild(labelEl);
|
|
60
|
+
if (value.shortcut) {
|
|
61
|
+
const shortcutEl = document.createElement("kbd");
|
|
62
|
+
shortcutEl.className = "__va-tooltip-shortcut";
|
|
63
|
+
shortcutEl.textContent = value.shortcut;
|
|
64
|
+
tooltipEl.appendChild(shortcutEl);
|
|
65
|
+
}
|
|
66
|
+
const arrowEl = document.createElement("span");
|
|
67
|
+
arrowEl.className = "__va-tooltip-arrow";
|
|
68
|
+
arrowEl.setAttribute("aria-hidden", "true");
|
|
69
|
+
tooltipEl.appendChild(arrowEl);
|
|
70
|
+
}
|
|
71
|
+
function positionTooltip(el) {
|
|
72
|
+
const state = getState(el);
|
|
73
|
+
if (!state?.value || !state.tooltipEl)
|
|
74
|
+
return;
|
|
75
|
+
const tooltipEl = state.tooltipEl;
|
|
76
|
+
const hostRect = el.getBoundingClientRect();
|
|
77
|
+
const viewportWidth = window.innerWidth;
|
|
78
|
+
const viewportHeight = window.innerHeight;
|
|
79
|
+
tooltipEl.style.left = "0px";
|
|
80
|
+
tooltipEl.style.top = "0px";
|
|
81
|
+
const tooltipRect = tooltipEl.getBoundingClientRect();
|
|
82
|
+
let placement = state.value.placement;
|
|
83
|
+
let top = placement === "top" ? hostRect.top - tooltipRect.height - state.value.offset : hostRect.bottom + state.value.offset;
|
|
84
|
+
if (placement === "top" && top < TOOLTIP_MARGIN) {
|
|
85
|
+
placement = "bottom";
|
|
86
|
+
top = hostRect.bottom + state.value.offset;
|
|
87
|
+
} else if (placement === "bottom" && top + tooltipRect.height > viewportHeight - TOOLTIP_MARGIN) {
|
|
88
|
+
placement = "top";
|
|
89
|
+
top = hostRect.top - tooltipRect.height - state.value.offset;
|
|
90
|
+
}
|
|
91
|
+
const centeredLeft = hostRect.left + hostRect.width / 2 - tooltipRect.width / 2;
|
|
92
|
+
const maxLeft = Math.max(TOOLTIP_MARGIN, viewportWidth - tooltipRect.width - TOOLTIP_MARGIN);
|
|
93
|
+
const left = Math.min(Math.max(centeredLeft, TOOLTIP_MARGIN), maxLeft);
|
|
94
|
+
const maxTop = Math.max(TOOLTIP_MARGIN, viewportHeight - tooltipRect.height - TOOLTIP_MARGIN);
|
|
95
|
+
tooltipEl.setAttribute("data-placement", placement);
|
|
96
|
+
tooltipEl.style.left = `${Math.round(left)}px`;
|
|
97
|
+
tooltipEl.style.top = `${Math.round(Math.min(Math.max(top, TOOLTIP_MARGIN), maxTop))}px`;
|
|
98
|
+
}
|
|
99
|
+
function attachWindowListeners(el) {
|
|
100
|
+
const state = getState(el);
|
|
101
|
+
if (!state)
|
|
102
|
+
return;
|
|
103
|
+
window.addEventListener("scroll", state.onWindowReposition, true);
|
|
104
|
+
window.addEventListener("resize", state.onWindowReposition, { passive: true });
|
|
105
|
+
}
|
|
106
|
+
function detachWindowListeners(el) {
|
|
107
|
+
const state = getState(el);
|
|
108
|
+
if (!state)
|
|
109
|
+
return;
|
|
110
|
+
window.removeEventListener("scroll", state.onWindowReposition, true);
|
|
111
|
+
window.removeEventListener("resize", state.onWindowReposition);
|
|
112
|
+
}
|
|
113
|
+
function clearShowTimer(el) {
|
|
114
|
+
const state = getState(el);
|
|
115
|
+
if (!state?.showTimer)
|
|
116
|
+
return;
|
|
117
|
+
clearTimeout(state.showTimer);
|
|
118
|
+
state.showTimer = null;
|
|
119
|
+
}
|
|
120
|
+
function showTooltipNow(el) {
|
|
121
|
+
const state = getState(el);
|
|
122
|
+
if (!state?.value || isHostDisabled(el))
|
|
123
|
+
return;
|
|
124
|
+
if (!state.tooltipEl)
|
|
125
|
+
state.tooltipEl = createTooltipElement(state.value);
|
|
126
|
+
else
|
|
127
|
+
updateTooltipContent(state.tooltipEl, state.value);
|
|
128
|
+
if (!document.body.contains(state.tooltipEl))
|
|
129
|
+
document.body.appendChild(state.tooltipEl);
|
|
130
|
+
positionTooltip(el);
|
|
131
|
+
state.tooltipEl.classList.add("__va-tooltip--visible");
|
|
132
|
+
attachWindowListeners(el);
|
|
133
|
+
}
|
|
134
|
+
function scheduleShowTooltip(el) {
|
|
135
|
+
const state = getState(el);
|
|
136
|
+
if (!state?.value || isHostDisabled(el))
|
|
137
|
+
return;
|
|
138
|
+
clearShowTimer(el);
|
|
139
|
+
if (state.value.showDelay <= 0) {
|
|
140
|
+
showTooltipNow(el);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
state.showTimer = setTimeout(() => {
|
|
144
|
+
state.showTimer = null;
|
|
145
|
+
showTooltipNow(el);
|
|
146
|
+
}, state.value.showDelay);
|
|
147
|
+
}
|
|
148
|
+
function hideTooltip(el) {
|
|
149
|
+
const state = getState(el);
|
|
150
|
+
if (!state)
|
|
151
|
+
return;
|
|
152
|
+
clearShowTimer(el);
|
|
153
|
+
if (!state.tooltipEl)
|
|
154
|
+
return;
|
|
155
|
+
detachWindowListeners(el);
|
|
156
|
+
state.tooltipEl.classList.remove("__va-tooltip--visible");
|
|
157
|
+
state.tooltipEl.remove();
|
|
158
|
+
}
|
|
159
|
+
function syncAriaLabel(el) {
|
|
160
|
+
const state = getState(el);
|
|
161
|
+
if (!state)
|
|
162
|
+
return;
|
|
163
|
+
if (!state.value && state.ownsAriaLabel) {
|
|
164
|
+
el.removeAttribute("aria-label");
|
|
165
|
+
state.ownsAriaLabel = false;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!state.value)
|
|
169
|
+
return;
|
|
170
|
+
if (!el.hasAttribute("aria-label")) {
|
|
171
|
+
el.setAttribute("aria-label", state.value.text);
|
|
172
|
+
state.ownsAriaLabel = true;
|
|
173
|
+
} else if (state.ownsAriaLabel) {
|
|
174
|
+
el.setAttribute("aria-label", state.value.text);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function updateTooltipValue(el, value) {
|
|
178
|
+
const state = getState(el);
|
|
179
|
+
if (!state)
|
|
180
|
+
return;
|
|
181
|
+
state.value = normalizeTooltipValue(value);
|
|
182
|
+
syncAriaLabel(el);
|
|
183
|
+
if (!state.value) {
|
|
184
|
+
hideTooltip(el);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (state.tooltipEl) {
|
|
188
|
+
updateTooltipContent(state.tooltipEl, state.value);
|
|
189
|
+
positionTooltip(el);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function bindTooltip(el, binding) {
|
|
193
|
+
if (getState(el)) {
|
|
194
|
+
updateTooltipValue(el, binding.value);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const state = {
|
|
198
|
+
value: null,
|
|
199
|
+
tooltipEl: null,
|
|
200
|
+
ownsAriaLabel: false,
|
|
201
|
+
showTimer: null,
|
|
202
|
+
onMouseEnter: () => scheduleShowTooltip(el),
|
|
203
|
+
onMouseLeave: () => hideTooltip(el),
|
|
204
|
+
onFocus: () => scheduleShowTooltip(el),
|
|
205
|
+
onBlur: () => hideTooltip(el),
|
|
206
|
+
onPointerDown: () => hideTooltip(el),
|
|
207
|
+
onKeyDown: (event) => {
|
|
208
|
+
if (event.key === "Escape")
|
|
209
|
+
hideTooltip(el);
|
|
210
|
+
},
|
|
211
|
+
onWindowReposition: () => positionTooltip(el)
|
|
212
|
+
};
|
|
213
|
+
el[TOOLTIP_STATE_KEY] = state;
|
|
214
|
+
el.addEventListener("mouseenter", state.onMouseEnter);
|
|
215
|
+
el.addEventListener("mouseleave", state.onMouseLeave);
|
|
216
|
+
el.addEventListener("focus", state.onFocus, true);
|
|
217
|
+
el.addEventListener("blur", state.onBlur, true);
|
|
218
|
+
el.addEventListener("pointerdown", state.onPointerDown);
|
|
219
|
+
el.addEventListener("keydown", state.onKeyDown);
|
|
220
|
+
updateTooltipValue(el, binding.value);
|
|
221
|
+
}
|
|
222
|
+
function unbindTooltip(el) {
|
|
223
|
+
const state = getState(el);
|
|
224
|
+
if (!state)
|
|
225
|
+
return;
|
|
226
|
+
hideTooltip(el);
|
|
227
|
+
el.removeEventListener("mouseenter", state.onMouseEnter);
|
|
228
|
+
el.removeEventListener("mouseleave", state.onMouseLeave);
|
|
229
|
+
el.removeEventListener("focus", state.onFocus, true);
|
|
230
|
+
el.removeEventListener("blur", state.onBlur, true);
|
|
231
|
+
el.removeEventListener("pointerdown", state.onPointerDown);
|
|
232
|
+
el.removeEventListener("keydown", state.onKeyDown);
|
|
233
|
+
if (state.ownsAriaLabel)
|
|
234
|
+
el.removeAttribute("aria-label");
|
|
235
|
+
delete el[TOOLTIP_STATE_KEY];
|
|
236
|
+
}
|
|
237
|
+
export const vaTooltipDirective = {
|
|
238
|
+
beforeMount(el, binding) {
|
|
239
|
+
bindTooltip(el, binding);
|
|
240
|
+
},
|
|
241
|
+
updated(el, binding) {
|
|
242
|
+
updateTooltipValue(el, binding.value);
|
|
243
|
+
},
|
|
244
|
+
unmounted(el) {
|
|
245
|
+
unbindTooltip(el);
|
|
246
|
+
},
|
|
247
|
+
bind(el, binding) {
|
|
248
|
+
bindTooltip(el, binding);
|
|
249
|
+
},
|
|
250
|
+
componentUpdated(el, binding) {
|
|
251
|
+
updateTooltipValue(el, binding.value);
|
|
252
|
+
},
|
|
253
|
+
unbind(el) {
|
|
254
|
+
unbindTooltip(el);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
export default vaTooltipDirective;
|
package/dist/icons.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const icons: {
|
|
2
|
+
readonly cursor: "<path d=\"m4 4 7 17 2.5-7.5L21 11Z\"/>";
|
|
3
|
+
readonly 'area-select': "<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><path d=\"M3 9h18M9 3v18\" opacity=\"0.3\"/>";
|
|
4
|
+
readonly pause: "<rect x=\"6\" y=\"4\" width=\"4\" height=\"16\"/><rect x=\"14\" y=\"4\" width=\"4\" height=\"16\"/>";
|
|
5
|
+
readonly play: "<polygon points=\"5,3 19,12 5,21\"/>";
|
|
6
|
+
readonly copy: "<rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\"/><path d=\"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1\"/>";
|
|
7
|
+
readonly trash: "<path d=\"M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2\"/><path d=\"M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6\"/>";
|
|
8
|
+
readonly settings: "<path d=\"M14.4 2h-4.8l-.6 3a7.8 7.8 0 0 0-1.9 1.1L4.3 5 2 9.1l2.2 2a7.7 7.7 0 0 0 0 1.8L2 14.9 4.3 19l2.8-1.1A7.8 7.8 0 0 0 9 19l.6 3h4.8l.6-3a7.8 7.8 0 0 0 1.9-1.1l2.8 1.1 2.3-4.1-2.2-2a7.7 7.7 0 0 0 0-1.8l2.2-2L19.7 5l-2.8 1.1A7.8 7.8 0 0 0 15 5z\"/><circle cx=\"12\" cy=\"12\" r=\"3\"/>";
|
|
9
|
+
readonly minimize: "<polyline points=\"4 14 10 14 10 20\"/><polyline points=\"20 10 14 10 14 4\"/><line x1=\"14\" y1=\"10\" x2=\"21\" y2=\"3\"/><line x1=\"3\" y1=\"21\" x2=\"10\" y2=\"14\"/>";
|
|
10
|
+
readonly sun: "<circle cx=\"12\" cy=\"12\" r=\"4\"/><path d=\"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41\"/>";
|
|
11
|
+
readonly moon: "<path d=\"M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8z\"/>";
|
|
12
|
+
readonly pencil: "<path d=\"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z\"/><path d=\"m15 5 4 4\"/>";
|
|
13
|
+
readonly plus: "<line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/>";
|
|
14
|
+
readonly close: "<line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"/><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"/>";
|
|
15
|
+
};
|
|
16
|
+
export type IconName = keyof typeof icons;
|
package/dist/icons.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.icons = void 0;
|
|
7
|
+
const icons = exports.icons = {
|
|
8
|
+
"cursor": '<path d="m4 4 7 17 2.5-7.5L21 11Z"/>',
|
|
9
|
+
"area-select": '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 3v18" opacity="0.3"/>',
|
|
10
|
+
"pause": '<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>',
|
|
11
|
+
"play": '<polygon points="5,3 19,12 5,21"/>',
|
|
12
|
+
"copy": '<rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/>',
|
|
13
|
+
"trash": '<path d="M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2"/><path d="M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"/>',
|
|
14
|
+
"settings": '<path d="M14.4 2h-4.8l-.6 3a7.8 7.8 0 0 0-1.9 1.1L4.3 5 2 9.1l2.2 2a7.7 7.7 0 0 0 0 1.8L2 14.9 4.3 19l2.8-1.1A7.8 7.8 0 0 0 9 19l.6 3h4.8l.6-3a7.8 7.8 0 0 0 1.9-1.1l2.8 1.1 2.3-4.1-2.2-2a7.7 7.7 0 0 0 0-1.8l2.2-2L19.7 5l-2.8 1.1A7.8 7.8 0 0 0 15 5z"/><circle cx="12" cy="12" r="3"/>',
|
|
15
|
+
"minimize": '<polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="14" y1="10" x2="21" y2="3"/><line x1="3" y1="21" x2="10" y2="14"/>',
|
|
16
|
+
"sun": '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"/>',
|
|
17
|
+
"moon": '<path d="M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8z"/>',
|
|
18
|
+
"pencil": '<path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/>',
|
|
19
|
+
"plus": '<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',
|
|
20
|
+
"close": '<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>'
|
|
21
|
+
};
|
package/dist/icons.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const icons = {
|
|
2
|
+
"cursor": '<path d="m4 4 7 17 2.5-7.5L21 11Z"/>',
|
|
3
|
+
"area-select": '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 3v18" opacity="0.3"/>',
|
|
4
|
+
"pause": '<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>',
|
|
5
|
+
"play": '<polygon points="5,3 19,12 5,21"/>',
|
|
6
|
+
"copy": '<rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/>',
|
|
7
|
+
"trash": '<path d="M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2"/><path d="M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"/>',
|
|
8
|
+
"settings": '<path d="M14.4 2h-4.8l-.6 3a7.8 7.8 0 0 0-1.9 1.1L4.3 5 2 9.1l2.2 2a7.7 7.7 0 0 0 0 1.8L2 14.9 4.3 19l2.8-1.1A7.8 7.8 0 0 0 9 19l.6 3h4.8l.6-3a7.8 7.8 0 0 0 1.9-1.1l2.8 1.1 2.3-4.1-2.2-2a7.7 7.7 0 0 0 0-1.8l2.2-2L19.7 5l-2.8 1.1A7.8 7.8 0 0 0 15 5z"/><circle cx="12" cy="12" r="3"/>',
|
|
9
|
+
"minimize": '<polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="14" y1="10" x2="21" y2="3"/><line x1="3" y1="21" x2="10" y2="14"/>',
|
|
10
|
+
"sun": '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"/>',
|
|
11
|
+
"moon": '<path d="M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8z"/>',
|
|
12
|
+
"pencil": '<path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/>',
|
|
13
|
+
"plus": '<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',
|
|
14
|
+
"close": '<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>'
|
|
15
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { App } from 'vue-demi';
|
|
2
|
+
import AgentationVue from './AgentationVue.vue';
|
|
3
|
+
import { vaTooltipDirective } from './directives/vaTooltip';
|
|
4
|
+
export { AgentationVue };
|
|
5
|
+
export default AgentationVue;
|
|
6
|
+
export declare const AgentationVuePlugin: {
|
|
7
|
+
install(app: App): void;
|
|
8
|
+
};
|
|
9
|
+
export { default as ComponentChain } from './components/ComponentChain.vue';
|
|
10
|
+
export { default as VaButton } from './components/VaButton.vue';
|
|
11
|
+
export { default as VaIcon } from './components/VaIcon.vue';
|
|
12
|
+
export { default as VaIconButton } from './components/VaIconButton.vue';
|
|
13
|
+
export { default as VaToggle } from './components/VaToggle.vue';
|
|
14
|
+
export { vaTooltipDirective };
|
|
15
|
+
export { useAnimationPause } from './composables/useAnimationPause';
|
|
16
|
+
export { useAnnotations } from './composables/useAnnotations';
|
|
17
|
+
export { useAreaSelect } from './composables/useAreaSelect';
|
|
18
|
+
export { useElementDetection } from './composables/useElementDetection';
|
|
19
|
+
export { useInteractionMode } from './composables/useInteractionMode';
|
|
20
|
+
export { DEFAULT_SHORTCUT_CONFIG, useKeyboardShortcuts } from './composables/useKeyboardShortcuts';
|
|
21
|
+
export type { DoubleTapConfig, KeyboardShortcutConfig, KeyboardShortcutState, ShortcutAction, } from './composables/useKeyboardShortcuts';
|
|
22
|
+
export { useMarkerPositions } from './composables/useMarkerPositions';
|
|
23
|
+
export { useMultiSelect } from './composables/useMultiSelect';
|
|
24
|
+
export { formatAnnotations, useOutputFormatter } from './composables/useOutputFormatter';
|
|
25
|
+
export { useSettings } from './composables/useSettings';
|
|
26
|
+
export { useTextSelection } from './composables/useTextSelection';
|
|
27
|
+
export { useToolbarAutoHide } from './composables/useToolbarAutoHide';
|
|
28
|
+
export type { VaTooltipOptions, VaTooltipPlacement, VaTooltipValue } from './directives/vaTooltip';
|
|
29
|
+
export { icons } from './icons';
|
|
30
|
+
export type { IconName } from './icons';
|
|
31
|
+
export type { AgentationEmits, AgentationProps, Annotation, BoundingBox, ElementRef, InteractionMode, OutputDetail, Settings, } from './types';
|