agentation-vue 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentationVue.vue +2 -6
- package/dist/components/AnnotationInput.vue +2 -2
- package/dist/components/AnnotationMarker.vue +5 -5
- package/dist/components/ComponentChain.vue +4 -1
- package/dist/components/SettingsPanel.vue +2 -6
- package/package.json +4 -10
- package/dist/composables/useAnimationPause.js +0 -52
- package/dist/composables/useAnnotations.js +0 -106
- package/dist/composables/useAreaSelect.js +0 -62
- package/dist/composables/useElementDetection.js +0 -85
- package/dist/composables/useInteractionMode.js +0 -29
- package/dist/composables/useKeyboardShortcuts.js +0 -202
- package/dist/composables/useMarkerPositions.js +0 -45
- package/dist/composables/useMultiSelect.js +0 -108
- package/dist/composables/useOutputFormatter.js +0 -100
- package/dist/composables/useSettings.js +0 -48
- package/dist/composables/useTextSelection.js +0 -33
- package/dist/composables/useToolbarAutoHide.js +0 -270
- package/dist/composables/useToolbarDragSnap.js +0 -296
- package/dist/constants.js +0 -8
- package/dist/directives/vaTooltip.js +0 -241
- package/dist/icons.js +0 -21
- package/dist/index.js +0 -168
- package/dist/types.js +0 -1
- package/dist/utils/clipboard.js +0 -22
- package/dist/utils/dom-inspector.js +0 -168
- package/dist/utils/math.js +0 -9
- package/dist/utils/portal.js +0 -18
- package/dist/utils/selectors.js +0 -103
- package/dist/utils/style.js +0 -14
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useToolbarDragSnap = useToolbarDragSnap;
|
|
7
|
-
var _vueDemi = require("vue-demi");
|
|
8
|
-
var _math = require("../utils/math");
|
|
9
|
-
const TOOLBAR_SIZE = 42;
|
|
10
|
-
const EDGE_OFFSET = 20;
|
|
11
|
-
const LONG_PRESS_MS = 350;
|
|
12
|
-
const HALF_TOOLBAR_SIZE = TOOLBAR_SIZE / 2;
|
|
13
|
-
const TOOLBAR_ANCHORS = ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
|
|
14
|
-
function isToolbarAnchor(value) {
|
|
15
|
-
return typeof value === "string" && TOOLBAR_ANCHORS.includes(value);
|
|
16
|
-
}
|
|
17
|
-
function useToolbarDragSnap(options) {
|
|
18
|
-
const {
|
|
19
|
-
expanded,
|
|
20
|
-
initialPlacement,
|
|
21
|
-
onDragStart,
|
|
22
|
-
onDragEnd
|
|
23
|
-
} = options;
|
|
24
|
-
const placement = (0, _vueDemi.ref)(isToolbarAnchor(initialPlacement) ? initialPlacement : "bottom-right");
|
|
25
|
-
const isDragging = (0, _vueDemi.ref)(false);
|
|
26
|
-
const dragPosition = (0, _vueDemi.ref)(null);
|
|
27
|
-
const suppressNextClick = (0, _vueDemi.ref)(false);
|
|
28
|
-
const activePointerId = (0, _vueDemi.ref)(null);
|
|
29
|
-
const toolbarEl = (0, _vueDemi.ref)(null);
|
|
30
|
-
const dragOffset = (0, _vueDemi.ref)({
|
|
31
|
-
x: HALF_TOOLBAR_SIZE,
|
|
32
|
-
y: HALF_TOOLBAR_SIZE
|
|
33
|
-
});
|
|
34
|
-
const dragSize = (0, _vueDemi.ref)({
|
|
35
|
-
width: TOOLBAR_SIZE,
|
|
36
|
-
height: TOOLBAR_SIZE
|
|
37
|
-
});
|
|
38
|
-
const dragSource = (0, _vueDemi.ref)(null);
|
|
39
|
-
const dragRotation = (0, _vueDemi.ref)(0);
|
|
40
|
-
let longPressTimer = null;
|
|
41
|
-
const snapAnchors = TOOLBAR_ANCHORS;
|
|
42
|
-
const isExpandedDrag = (0, _vueDemi.computed)(() => isDragging.value && dragSource.value === "handle");
|
|
43
|
-
const toolbarStyle = (0, _vueDemi.computed)(() => {
|
|
44
|
-
if (!isDragging.value || !dragPosition.value) {
|
|
45
|
-
return void 0;
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
left: `${dragPosition.value.x}px`,
|
|
49
|
-
top: `${dragPosition.value.y}px`,
|
|
50
|
-
transform: `rotate(${dragRotation.value}deg)`
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
const activeSnapAnchor = (0, _vueDemi.computed)(() => {
|
|
54
|
-
const current = dragPosition.value;
|
|
55
|
-
if (!current) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
return findClosestAnchor(current.x + dragSize.value.width / 2, current.y + dragSize.value.height / 2);
|
|
59
|
-
});
|
|
60
|
-
function getAnchorRects(size) {
|
|
61
|
-
const top = EDGE_OFFSET;
|
|
62
|
-
const bottom = window.innerHeight - EDGE_OFFSET - size.height;
|
|
63
|
-
const left = EDGE_OFFSET;
|
|
64
|
-
const right = window.innerWidth - EDGE_OFFSET - size.width;
|
|
65
|
-
const centerX = (window.innerWidth - size.width) / 2;
|
|
66
|
-
return {
|
|
67
|
-
"top-left": {
|
|
68
|
-
x: left,
|
|
69
|
-
y: top,
|
|
70
|
-
width: size.width,
|
|
71
|
-
height: size.height
|
|
72
|
-
},
|
|
73
|
-
"top-center": {
|
|
74
|
-
x: centerX,
|
|
75
|
-
y: top,
|
|
76
|
-
width: size.width,
|
|
77
|
-
height: size.height
|
|
78
|
-
},
|
|
79
|
-
"top-right": {
|
|
80
|
-
x: right,
|
|
81
|
-
y: top,
|
|
82
|
-
width: size.width,
|
|
83
|
-
height: size.height
|
|
84
|
-
},
|
|
85
|
-
"bottom-left": {
|
|
86
|
-
x: left,
|
|
87
|
-
y: bottom,
|
|
88
|
-
width: size.width,
|
|
89
|
-
height: size.height
|
|
90
|
-
},
|
|
91
|
-
"bottom-center": {
|
|
92
|
-
x: centerX,
|
|
93
|
-
y: bottom,
|
|
94
|
-
width: size.width,
|
|
95
|
-
height: size.height
|
|
96
|
-
},
|
|
97
|
-
"bottom-right": {
|
|
98
|
-
x: right,
|
|
99
|
-
y: bottom,
|
|
100
|
-
width: size.width,
|
|
101
|
-
height: size.height
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
function getSnapPoints(size) {
|
|
106
|
-
const rects = getAnchorRects(size);
|
|
107
|
-
const result = {};
|
|
108
|
-
for (const anchor of snapAnchors) {
|
|
109
|
-
const r = rects[anchor];
|
|
110
|
-
result[anchor] = {
|
|
111
|
-
x: r.x + r.width / 2,
|
|
112
|
-
y: r.y + r.height / 2
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
function findClosestAnchor(x, y) {
|
|
118
|
-
const points = getSnapPoints(dragSize.value);
|
|
119
|
-
let closest = "bottom-right";
|
|
120
|
-
let bestDistance = Number.POSITIVE_INFINITY;
|
|
121
|
-
for (const [anchor, point] of Object.entries(points)) {
|
|
122
|
-
const dx = point.x - x;
|
|
123
|
-
const dy = point.y - y;
|
|
124
|
-
const distance = dx * dx + dy * dy;
|
|
125
|
-
if (distance < bestDistance) {
|
|
126
|
-
bestDistance = distance;
|
|
127
|
-
closest = anchor;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return closest;
|
|
131
|
-
}
|
|
132
|
-
function captureDragMetrics(clientX, clientY) {
|
|
133
|
-
const rect = toolbarEl.value?.getBoundingClientRect();
|
|
134
|
-
if (!rect) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
dragOffset.value = {
|
|
138
|
-
x: clientX - rect.left,
|
|
139
|
-
y: clientY - rect.top
|
|
140
|
-
};
|
|
141
|
-
dragSize.value = {
|
|
142
|
-
width: rect.width,
|
|
143
|
-
height: rect.height
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function updateDragPosition(clientX, clientY) {
|
|
147
|
-
const {
|
|
148
|
-
width,
|
|
149
|
-
height
|
|
150
|
-
} = dragSize.value;
|
|
151
|
-
dragPosition.value = {
|
|
152
|
-
x: (0, _math.clamp)(clientX - dragOffset.value.x, 0, window.innerWidth - width),
|
|
153
|
-
y: (0, _math.clamp)(clientY - dragOffset.value.y, 0, window.innerHeight - height)
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
function clearLongPressTimer() {
|
|
157
|
-
if (longPressTimer) {
|
|
158
|
-
clearTimeout(longPressTimer);
|
|
159
|
-
longPressTimer = null;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function finishDrag(clientX, clientY) {
|
|
163
|
-
updateDragPosition(clientX, clientY);
|
|
164
|
-
const current = dragPosition.value;
|
|
165
|
-
if (current) {
|
|
166
|
-
placement.value = findClosestAnchor(current.x + dragSize.value.width / 2, current.y + dragSize.value.height / 2);
|
|
167
|
-
}
|
|
168
|
-
isDragging.value = false;
|
|
169
|
-
dragPosition.value = null;
|
|
170
|
-
onDragEnd?.();
|
|
171
|
-
}
|
|
172
|
-
function getSnapStyle(anchor) {
|
|
173
|
-
const rect = getAnchorRects(dragSize.value)[anchor];
|
|
174
|
-
if (isExpandedDrag.value) {
|
|
175
|
-
return {
|
|
176
|
-
left: `${rect.x}px`,
|
|
177
|
-
top: `${rect.y}px`,
|
|
178
|
-
width: `${rect.width}px`,
|
|
179
|
-
height: `${rect.height}px`
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
left: `${rect.x + rect.width / 2}px`,
|
|
184
|
-
top: `${rect.y + rect.height / 2}px`
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
function startDragPointer(e, source, options2) {
|
|
188
|
-
if (e.button !== 0) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
activePointerId.value = e.pointerId;
|
|
192
|
-
dragSource.value = source;
|
|
193
|
-
captureDragMetrics(e.clientX, e.clientY);
|
|
194
|
-
const target = e.currentTarget;
|
|
195
|
-
target?.setPointerCapture?.(e.pointerId);
|
|
196
|
-
clearLongPressTimer();
|
|
197
|
-
dragRotation.value = (2 + Math.random() * 3) * (Math.random() < 0.5 ? -1 : 1);
|
|
198
|
-
if (options2.immediate) {
|
|
199
|
-
dragRotation.value = (Math.random() * 4 + 1) * (Math.random() < 0.5 ? -1 : 1);
|
|
200
|
-
isDragging.value = true;
|
|
201
|
-
onDragStart?.();
|
|
202
|
-
updateDragPosition(e.clientX, e.clientY);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
longPressTimer = setTimeout(() => {
|
|
206
|
-
if (activePointerId.value !== e.pointerId || expanded.value) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
dragRotation.value = (Math.random() * 4 + 1) * (Math.random() < 0.5 ? -1 : 1);
|
|
210
|
-
isDragging.value = true;
|
|
211
|
-
onDragStart?.();
|
|
212
|
-
updateDragPosition(e.clientX, e.clientY);
|
|
213
|
-
}, LONG_PRESS_MS);
|
|
214
|
-
}
|
|
215
|
-
function onTogglePointerDown(e) {
|
|
216
|
-
if (expanded.value) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
startDragPointer(e, "toggle", {
|
|
220
|
-
immediate: false
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
function onHandlePointerDown(e) {
|
|
224
|
-
if (!expanded.value) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
startDragPointer(e, "handle", {
|
|
228
|
-
immediate: true
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
function onPointerMove(e) {
|
|
232
|
-
if (!isDragging.value || activePointerId.value !== e.pointerId) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
updateDragPosition(e.clientX, e.clientY);
|
|
236
|
-
}
|
|
237
|
-
function onPointerUp(e) {
|
|
238
|
-
if (activePointerId.value !== e.pointerId) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
clearLongPressTimer();
|
|
242
|
-
if (isDragging.value) {
|
|
243
|
-
finishDrag(e.clientX, e.clientY);
|
|
244
|
-
if (dragSource.value === "toggle") {
|
|
245
|
-
suppressNextClick.value = true;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
activePointerId.value = null;
|
|
249
|
-
dragSource.value = null;
|
|
250
|
-
const target = e.currentTarget;
|
|
251
|
-
target?.releasePointerCapture?.(e.pointerId);
|
|
252
|
-
}
|
|
253
|
-
function onPointerCancel() {
|
|
254
|
-
if (isDragging.value) {
|
|
255
|
-
onDragEnd?.();
|
|
256
|
-
}
|
|
257
|
-
clearLongPressTimer();
|
|
258
|
-
isDragging.value = false;
|
|
259
|
-
dragPosition.value = null;
|
|
260
|
-
activePointerId.value = null;
|
|
261
|
-
dragSource.value = null;
|
|
262
|
-
}
|
|
263
|
-
function consumeToggleClickSuppression() {
|
|
264
|
-
if (!suppressNextClick.value) {
|
|
265
|
-
return false;
|
|
266
|
-
}
|
|
267
|
-
suppressNextClick.value = false;
|
|
268
|
-
return true;
|
|
269
|
-
}
|
|
270
|
-
function cleanup() {
|
|
271
|
-
clearLongPressTimer();
|
|
272
|
-
if (isDragging.value) {
|
|
273
|
-
isDragging.value = false;
|
|
274
|
-
onDragEnd?.();
|
|
275
|
-
}
|
|
276
|
-
activePointerId.value = null;
|
|
277
|
-
dragSource.value = null;
|
|
278
|
-
}
|
|
279
|
-
return {
|
|
280
|
-
placement,
|
|
281
|
-
isDragging,
|
|
282
|
-
toolbarStyle,
|
|
283
|
-
toolbarEl,
|
|
284
|
-
snapAnchors,
|
|
285
|
-
activeSnapAnchor,
|
|
286
|
-
isExpandedDrag,
|
|
287
|
-
getSnapStyle,
|
|
288
|
-
onTogglePointerDown,
|
|
289
|
-
onHandlePointerDown,
|
|
290
|
-
onPointerMove,
|
|
291
|
-
onPointerUp,
|
|
292
|
-
onPointerCancel,
|
|
293
|
-
consumeToggleClickSuppression,
|
|
294
|
-
cleanup
|
|
295
|
-
};
|
|
296
|
-
}
|
package/dist/constants.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.VA_DATA_ATTR_SELECTOR = exports.VA_DATA_ATTR = void 0;
|
|
7
|
-
const VA_DATA_ATTR = exports.VA_DATA_ATTR = "data-agentation-vue";
|
|
8
|
-
const VA_DATA_ATTR_SELECTOR = exports.VA_DATA_ATTR_SELECTOR = "[data-agentation-vue]";
|
|
@@ -1,241 +0,0 @@
|
|
|
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;
|
package/dist/icons.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
};
|