agentation-vue 0.2.2 → 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.
Files changed (37) hide show
  1. package/dist/AgentationVue.vue +411 -528
  2. package/dist/components/AgentationToolbar.vue +49 -76
  3. package/dist/components/AnnotationInput.vue +30 -40
  4. package/dist/components/AnnotationMarker.vue +20 -25
  5. package/dist/components/ComponentChain.vue +19 -29
  6. package/dist/components/ElementHighlight.vue +13 -16
  7. package/dist/components/SettingsPanel.vue +29 -41
  8. package/dist/components/SettingsPopover.vue +128 -159
  9. package/dist/components/VaButton.vue +6 -12
  10. package/dist/components/VaIcon.vue +5 -5
  11. package/dist/components/VaIconButton.vue +15 -23
  12. package/dist/components/VaToggle.vue +7 -8
  13. package/package.json +7 -12
  14. package/dist/composables/useAnimationPause.js +0 -52
  15. package/dist/composables/useAnnotations.js +0 -106
  16. package/dist/composables/useAreaSelect.js +0 -62
  17. package/dist/composables/useElementDetection.js +0 -85
  18. package/dist/composables/useInteractionMode.js +0 -29
  19. package/dist/composables/useKeyboardShortcuts.js +0 -202
  20. package/dist/composables/useMarkerPositions.js +0 -45
  21. package/dist/composables/useMultiSelect.js +0 -108
  22. package/dist/composables/useOutputFormatter.js +0 -100
  23. package/dist/composables/useSettings.js +0 -48
  24. package/dist/composables/useTextSelection.js +0 -33
  25. package/dist/composables/useToolbarAutoHide.js +0 -270
  26. package/dist/composables/useToolbarDragSnap.js +0 -296
  27. package/dist/constants.js +0 -8
  28. package/dist/directives/vaTooltip.js +0 -241
  29. package/dist/icons.js +0 -21
  30. package/dist/index.js +0 -168
  31. package/dist/types.js +0 -1
  32. package/dist/utils/clipboard.js +0 -22
  33. package/dist/utils/dom-inspector.js +0 -168
  34. package/dist/utils/math.js +0 -9
  35. package/dist/utils/portal.js +0 -18
  36. package/dist/utils/selectors.js +0 -103
  37. package/dist/utils/style.js +0 -14
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useTextSelection = useTextSelection;
7
- function useTextSelection(mode) {
8
- function checkTextSelection(e) {
9
- if (mode.value !== "inspect") return null;
10
- if (e.shiftKey || e.altKey) return null;
11
- const selection = window.getSelection();
12
- const selectedText = selection?.toString().trim() ?? "";
13
- if (selectedText.length >= 2 && selection?.rangeCount) {
14
- const range = selection.getRangeAt(0);
15
- const rect = range.getBoundingClientRect();
16
- if (rect.width > 5) {
17
- const anchorElement = range.commonAncestorContainer instanceof Element ? range.commonAncestorContainer : range.commonAncestorContainer.parentElement;
18
- if (anchorElement) {
19
- return {
20
- selectedText,
21
- range,
22
- rect,
23
- anchorElement
24
- };
25
- }
26
- }
27
- }
28
- return null;
29
- }
30
- return {
31
- checkTextSelection
32
- };
33
- }
@@ -1,270 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useToolbarAutoHide = useToolbarAutoHide;
7
- var _vueDemi = require("vue-demi");
8
- const EDGE_OFFSET = 20;
9
- const DEFAULT_TOOLBAR_SIZE = 42;
10
- const ACTIVATION_EDGE_DEPTH = 16;
11
- const ACTIVATION_INLINE_PAD = 30;
12
- const ACTIVATION_CORNER_SIZE = 32;
13
- const KEEP_ALIVE_PADDING = 56;
14
- const HIDE_DELAY_MS = 140;
15
- const ENTER_LOCK_MS = 220;
16
- const CLICK_LOCK_MS = 320;
17
- function useToolbarAutoHide(options) {
18
- const {
19
- enabled,
20
- expanded,
21
- isDragging,
22
- placement,
23
- toolbarEl
24
- } = options;
25
- const isAutoHideRevealed = (0, _vueDemi.ref)(false);
26
- const isAutoHideActive = (0, _vueDemi.computed)(() => enabled.value && !expanded.value && !isDragging.value);
27
- let hideTimer = null;
28
- let revealLockUntil = 0;
29
- let listenersAttached = false;
30
- function clearHideTimer() {
31
- if (!hideTimer) {
32
- return;
33
- }
34
- clearTimeout(hideTimer);
35
- hideTimer = null;
36
- }
37
- function reveal() {
38
- isAutoHideRevealed.value = true;
39
- clearHideTimer();
40
- }
41
- function lockReveal(durationMs) {
42
- revealLockUntil = Math.max(revealLockUntil, Date.now() + durationMs);
43
- reveal();
44
- }
45
- function hideNow() {
46
- clearHideTimer();
47
- revealLockUntil = 0;
48
- isAutoHideRevealed.value = false;
49
- }
50
- function scheduleHide() {
51
- clearHideTimer();
52
- hideTimer = setTimeout(() => {
53
- if (Date.now() < revealLockUntil) {
54
- scheduleHide();
55
- return;
56
- }
57
- isAutoHideRevealed.value = false;
58
- hideTimer = null;
59
- }, HIDE_DELAY_MS);
60
- }
61
- function getToolbarSize() {
62
- const el = toolbarEl.value;
63
- return {
64
- width: el?.offsetWidth ?? DEFAULT_TOOLBAR_SIZE,
65
- height: el?.offsetHeight ?? DEFAULT_TOOLBAR_SIZE
66
- };
67
- }
68
- function getCollapsedRect(anchor, size) {
69
- const left = EDGE_OFFSET;
70
- const top = EDGE_OFFSET;
71
- const right = window.innerWidth - EDGE_OFFSET - size.width;
72
- const bottom = window.innerHeight - EDGE_OFFSET - size.height;
73
- const centerX = (window.innerWidth - size.width) / 2;
74
- switch (anchor) {
75
- case "top-left":
76
- return {
77
- left,
78
- top,
79
- right: left + size.width,
80
- bottom: top + size.height
81
- };
82
- case "top-center":
83
- return {
84
- left: centerX,
85
- top,
86
- right: centerX + size.width,
87
- bottom: top + size.height
88
- };
89
- case "top-right":
90
- return {
91
- left: right,
92
- top,
93
- right: right + size.width,
94
- bottom: top + size.height
95
- };
96
- case "bottom-left":
97
- return {
98
- left,
99
- top: bottom,
100
- right: left + size.width,
101
- bottom: bottom + size.height
102
- };
103
- case "bottom-center":
104
- return {
105
- left: centerX,
106
- top: bottom,
107
- right: centerX + size.width,
108
- bottom: bottom + size.height
109
- };
110
- case "bottom-right":
111
- default:
112
- return {
113
- left: right,
114
- top: bottom,
115
- right: right + size.width,
116
- bottom: bottom + size.height
117
- };
118
- }
119
- }
120
- function getActivationRect(anchor, size) {
121
- const W = window.innerWidth;
122
- const H = window.innerHeight;
123
- const centerX = W / 2;
124
- switch (anchor) {
125
- case "top-left":
126
- return {
127
- left: 0,
128
- top: 0,
129
- right: ACTIVATION_CORNER_SIZE,
130
- bottom: ACTIVATION_CORNER_SIZE
131
- };
132
- case "top-center":
133
- return {
134
- left: centerX - size.width / 2 - ACTIVATION_INLINE_PAD,
135
- top: 0,
136
- right: centerX + size.width / 2 + ACTIVATION_INLINE_PAD,
137
- bottom: ACTIVATION_EDGE_DEPTH
138
- };
139
- case "top-right":
140
- return {
141
- left: W - ACTIVATION_CORNER_SIZE,
142
- top: 0,
143
- right: W,
144
- bottom: ACTIVATION_CORNER_SIZE
145
- };
146
- case "bottom-left":
147
- return {
148
- left: 0,
149
- top: H - ACTIVATION_CORNER_SIZE,
150
- right: ACTIVATION_CORNER_SIZE,
151
- bottom: H
152
- };
153
- case "bottom-center":
154
- return {
155
- left: centerX - size.width / 2 - ACTIVATION_INLINE_PAD,
156
- top: H - ACTIVATION_EDGE_DEPTH,
157
- right: centerX + size.width / 2 + ACTIVATION_INLINE_PAD,
158
- bottom: H
159
- };
160
- case "bottom-right":
161
- default:
162
- return {
163
- left: W - ACTIVATION_CORNER_SIZE,
164
- top: H - ACTIVATION_CORNER_SIZE,
165
- right: W,
166
- bottom: H
167
- };
168
- }
169
- }
170
- function inflateRect(rect, padding) {
171
- return {
172
- left: rect.left - padding,
173
- top: rect.top - padding,
174
- right: rect.right + padding,
175
- bottom: rect.bottom + padding
176
- };
177
- }
178
- function isInside(point, rect) {
179
- return point.x >= rect.left && point.x <= rect.right && point.y >= rect.top && point.y <= rect.bottom;
180
- }
181
- function isInActivationZone(point, anchor, size) {
182
- return isInside(point, getActivationRect(anchor, size));
183
- }
184
- function onGlobalPointerMove(e) {
185
- if (!isAutoHideActive.value) {
186
- return;
187
- }
188
- const size = getToolbarSize();
189
- const point = {
190
- x: e.clientX,
191
- y: e.clientY
192
- };
193
- const keepAliveRect = inflateRect(getCollapsedRect(placement.value, size), KEEP_ALIVE_PADDING);
194
- if (isInActivationZone(point, placement.value, size) || isAutoHideRevealed.value && isInside(point, keepAliveRect)) {
195
- reveal();
196
- return;
197
- }
198
- scheduleHide();
199
- }
200
- function onWindowBlur() {
201
- if (isAutoHideActive.value) {
202
- hideNow();
203
- }
204
- }
205
- function addGlobalListeners() {
206
- if (listenersAttached || typeof window === "undefined") {
207
- return;
208
- }
209
- listenersAttached = true;
210
- window.addEventListener("pointermove", onGlobalPointerMove, true);
211
- window.addEventListener("blur", onWindowBlur);
212
- }
213
- function removeGlobalListeners() {
214
- if (!listenersAttached || typeof window === "undefined") {
215
- return;
216
- }
217
- listenersAttached = false;
218
- window.removeEventListener("pointermove", onGlobalPointerMove, true);
219
- window.removeEventListener("blur", onWindowBlur);
220
- }
221
- function onToolbarPointerEnter() {
222
- if (!isAutoHideActive.value) {
223
- return;
224
- }
225
- lockReveal(ENTER_LOCK_MS);
226
- }
227
- function onToolbarPointerLeave() {}
228
- function onToolbarPointerDown() {
229
- if (!isAutoHideActive.value) {
230
- return;
231
- }
232
- lockReveal(CLICK_LOCK_MS);
233
- }
234
- function onToolbarFocusIn() {
235
- if (!isAutoHideActive.value) {
236
- return;
237
- }
238
- lockReveal(CLICK_LOCK_MS);
239
- }
240
- function onToolbarFocusOut() {
241
- if (!isAutoHideActive.value) {
242
- return;
243
- }
244
- scheduleHide();
245
- }
246
- (0, _vueDemi.watch)(isAutoHideActive, active => {
247
- if (!active) {
248
- removeGlobalListeners();
249
- hideNow();
250
- return;
251
- }
252
- addGlobalListeners();
253
- isAutoHideRevealed.value = false;
254
- }, {
255
- immediate: true
256
- });
257
- (0, _vueDemi.onBeforeUnmount)(() => {
258
- removeGlobalListeners();
259
- clearHideTimer();
260
- });
261
- return {
262
- isAutoHideActive,
263
- isAutoHideRevealed,
264
- onToolbarPointerEnter,
265
- onToolbarPointerLeave,
266
- onToolbarPointerDown,
267
- onToolbarFocusIn,
268
- onToolbarFocusOut
269
- };
270
- }
@@ -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]";