agentation-vue 0.2.2 → 0.2.3

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.
@@ -1,34 +1,19 @@
1
- <script setup lang="ts">
2
- import type { InteractionMode, ToolbarAnchor } from '../types'
3
- import { computed, onBeforeUnmount, ref, toRef, watch } from 'vue-demi'
4
- import { useToolbarAutoHide } from '../composables/useToolbarAutoHide'
5
- import { useToolbarDragSnap } from '../composables/useToolbarDragSnap'
6
- import VaIcon from './VaIcon.vue'
7
- import VaIconButton from './VaIconButton.vue'
8
-
9
- const props = defineProps<{
10
- mode: InteractionMode
11
- annotationCount: number
12
- isPaused: boolean
13
- isAreaMode: boolean
14
- autoHideEnabled: boolean
15
- placement: ToolbarAnchor
16
- }>()
17
-
18
- const emit = defineEmits<{
19
- 'activate': []
20
- 'deactivate': []
21
- 'copy': []
22
- 'clear': []
23
- 'toggle-pause': []
24
- 'toggle-area': [value: boolean]
25
- 'update:placement': [value: ToolbarAnchor]
26
- 'open-settings': [anchorEl: HTMLElement | null]
27
- 'drag-start': []
28
- 'drag-end': []
29
- }>()
30
-
31
- const expanded = ref(false)
1
+ <script setup>
2
+ import { computed, onBeforeUnmount, ref, toRef, watch } from "vue-demi";
3
+ import { useToolbarAutoHide } from "../composables/useToolbarAutoHide";
4
+ import { useToolbarDragSnap } from "../composables/useToolbarDragSnap";
5
+ import VaIcon from "./VaIcon.vue";
6
+ import VaIconButton from "./VaIconButton.vue";
7
+ const props = defineProps({
8
+ mode: { type: String, required: true },
9
+ annotationCount: { type: Number, required: true },
10
+ isPaused: { type: Boolean, required: true },
11
+ isAreaMode: { type: Boolean, required: true },
12
+ autoHideEnabled: { type: Boolean, required: true },
13
+ placement: { type: String, required: true }
14
+ });
15
+ const emit = defineEmits(["activate", "deactivate", "copy", "clear", "toggle-pause", "toggle-area", "update:placement", "open-settings", "drag-start", "drag-end"]);
16
+ const expanded = ref(false);
32
17
  const {
33
18
  placement,
34
19
  isDragging,
@@ -44,15 +29,14 @@ const {
44
29
  onPointerUp,
45
30
  onPointerCancel,
46
31
  consumeToggleClickSuppression,
47
- cleanup,
32
+ cleanup
48
33
  } = useToolbarDragSnap({
49
34
  expanded,
50
35
  initialPlacement: props.placement,
51
- onDragStart: () => emit('drag-start'),
52
- onDragEnd: () => emit('drag-end'),
53
- })
54
-
55
- const autoHideEnabled = toRef(props, 'autoHideEnabled')
36
+ onDragStart: () => emit("drag-start"),
37
+ onDragEnd: () => emit("drag-end")
38
+ });
39
+ const autoHideEnabled = toRef(props, "autoHideEnabled");
56
40
  const {
57
41
  isAutoHideActive,
58
42
  isAutoHideRevealed,
@@ -60,69 +44,58 @@ const {
60
44
  onToolbarPointerLeave,
61
45
  onToolbarPointerDown,
62
46
  onToolbarFocusIn,
63
- onToolbarFocusOut,
47
+ onToolbarFocusOut
64
48
  } = useToolbarAutoHide({
65
49
  enabled: autoHideEnabled,
66
50
  expanded,
67
51
  isDragging,
68
52
  placement,
69
- toolbarEl,
70
- })
71
-
53
+ toolbarEl
54
+ });
72
55
  const toolbarClass = computed(() => [
73
56
  `__va-toolbar--place-${placement.value}`,
74
57
  {
75
- '__va-toolbar--collapsed': !expanded.value,
76
- '__va-toolbar--expanded': expanded.value,
77
- '__va-toolbar--dragging': isDragging.value,
78
- '__va-toolbar--auto-hide': isAutoHideActive.value,
79
- '__va-toolbar--auto-hide-revealed': isAutoHideRevealed.value,
80
- },
81
- ])
82
-
58
+ "__va-toolbar--collapsed": !expanded.value,
59
+ "__va-toolbar--expanded": expanded.value,
60
+ "__va-toolbar--dragging": isDragging.value,
61
+ "__va-toolbar--auto-hide": isAutoHideActive.value,
62
+ "__va-toolbar--auto-hide-revealed": isAutoHideRevealed.value
63
+ }
64
+ ]);
83
65
  function onToggleClick() {
84
66
  if (consumeToggleClickSuppression()) {
85
- return
67
+ return;
86
68
  }
87
- onActivate()
69
+ onActivate();
88
70
  }
89
-
90
71
  function onActivate() {
91
- expanded.value = true
92
- emit('activate')
72
+ expanded.value = true;
73
+ emit("activate");
93
74
  }
94
-
95
75
  function onDeactivate() {
96
- expanded.value = false
97
- emit('deactivate')
76
+ expanded.value = false;
77
+ emit("deactivate");
98
78
  }
99
-
100
79
  function onClear() {
101
- // eslint-disable-next-line no-alert
102
- if (confirm('Clear all annotations?'))
103
- emit('clear')
80
+ if (confirm("Clear all annotations?"))
81
+ emit("clear");
104
82
  }
105
-
106
- function onOpenSettings(e: MouseEvent) {
107
- const anchorEl = e.currentTarget instanceof HTMLElement ? e.currentTarget : null
108
- emit('open-settings', anchorEl)
83
+ function onOpenSettings(e) {
84
+ const anchorEl = e.currentTarget instanceof HTMLElement ? e.currentTarget : null;
85
+ emit("open-settings", anchorEl);
109
86
  }
110
-
111
87
  onBeforeUnmount(() => {
112
- cleanup()
113
- })
114
-
88
+ cleanup();
89
+ });
115
90
  watch(
116
91
  () => props.placement,
117
92
  (value) => {
118
93
  if (placement.value !== value)
119
- placement.value = value
120
- },
121
- )
122
-
123
- watch(placement, value => emit('update:placement', value))
124
-
125
- defineExpose({ expanded, placement })
94
+ placement.value = value;
95
+ }
96
+ );
97
+ watch(placement, (value) => emit("update:placement", value));
98
+ defineExpose({ expanded, placement });
126
99
  </script>
127
100
 
128
101
  <template>
@@ -1,47 +1,37 @@
1
- <script setup lang="ts">
2
- import { computed, onMounted, ref } from 'vue-demi'
3
- import ComponentChain from './ComponentChain.vue'
4
- import VaButton from './VaButton.vue'
5
- import VaIcon from './VaIcon.vue'
6
-
7
- const props = defineProps<{
8
- position: { x: number, y: number }
9
- elementName?: string
10
- componentChain?: string
11
- computedStyles?: Record<string, string>
12
- initialComment?: string
13
- isEditing?: boolean
14
- }>()
15
-
16
- const emit = defineEmits<{
17
- add: [comment: string]
18
- cancel: []
19
- delete: []
20
- }>()
21
-
22
- const comment = ref(props.initialComment || '')
23
- const inputEl = ref<HTMLInputElement | null>(null)
24
- const computedStyleEntries = computed(() => Object.entries(props.computedStyles || {}))
25
-
1
+ <script setup>
2
+ import { computed, onMounted, ref } from "vue-demi";
3
+ import ComponentChain from "./ComponentChain.vue";
4
+ import VaButton from "./VaButton.vue";
5
+ import VaIcon from "./VaIcon.vue";
6
+ const props = defineProps({
7
+ position: { type: Object, required: true },
8
+ elementName: { type: String, required: false },
9
+ componentChain: { type: String, required: false },
10
+ computedStyles: { type: Object, required: false },
11
+ initialComment: { type: String, required: false },
12
+ isEditing: { type: Boolean, required: false }
13
+ });
14
+ const emit = defineEmits(["add", "cancel", "delete"]);
15
+ const comment = ref(props.initialComment || "");
16
+ const inputEl = ref(null);
17
+ const computedStyleEntries = computed(() => Object.entries(props.computedStyles || {}));
26
18
  const inputStyle = computed(() => {
27
- const x = Math.min(props.position.x, window.innerWidth - 380)
28
- const y = Math.min(props.position.y + 20, window.innerHeight - 150)
19
+ const x = Math.min(props.position.x, window.innerWidth - 380);
20
+ const y = Math.min(props.position.y + 20, window.innerHeight - 150);
29
21
  return {
30
22
  left: `${Math.max(10, x)}px`,
31
- top: `${Math.max(10, y)}px`,
32
- }
33
- })
34
-
23
+ top: `${Math.max(10, y)}px`
24
+ };
25
+ });
35
26
  function onAdd() {
36
- const text = comment.value.trim()
27
+ const text = comment.value.trim();
37
28
  if (!text)
38
- return
39
- emit('add', text)
29
+ return;
30
+ emit("add", text);
40
31
  }
41
-
42
32
  onMounted(() => {
43
- inputEl.value?.focus()
44
- })
33
+ inputEl.value?.focus();
34
+ });
45
35
  </script>
46
36
 
47
37
  <template>
@@ -97,7 +87,7 @@ onMounted(() => {
97
87
  Cancel
98
88
  </VaButton>
99
89
  <VaButton :disabled="!comment.trim()" @click="onAdd">
100
- {{ isEditing ? 'Save' : 'Add' }}
90
+ {{ isEditing ? "Save" : "Add" }}
101
91
  </VaButton>
102
92
  </div>
103
93
  </div>
@@ -1,25 +1,20 @@
1
- <script setup lang="ts">
2
- import { computed } from 'vue-demi'
3
- import VaIcon from './VaIcon.vue'
4
-
5
- const props = defineProps<{
6
- number: number
7
- x: number
8
- y: number
9
- isFixed?: boolean
10
- isStale?: boolean
11
- isPending?: boolean
12
- isSelection?: boolean
13
- }>()
14
-
15
- defineEmits<{
16
- click: []
17
- }>()
18
-
1
+ <script setup>
2
+ import { computed } from "vue-demi";
3
+ import VaIcon from "./VaIcon.vue";
4
+ const props = defineProps({
5
+ number: { type: Number, required: true },
6
+ x: { type: Number, required: true },
7
+ y: { type: Number, required: true },
8
+ isFixed: { type: Boolean, required: false },
9
+ isStale: { type: Boolean, required: false },
10
+ isPending: { type: Boolean, required: false },
11
+ isSelection: { type: Boolean, required: false }
12
+ });
13
+ defineEmits(["click"]);
19
14
  const markerStyle = computed(() => ({
20
15
  left: `${props.x}%`,
21
- top: `${props.y}px`,
22
- }))
16
+ top: `${props.y}px`
17
+ }));
23
18
  </script>
24
19
 
25
20
  <template>
@@ -1,30 +1,20 @@
1
- <script setup lang="ts">
2
- import { computed, ref } from 'vue-demi'
3
-
4
- const props = withDefaults(defineProps<{
5
- chain: string
6
- variant?: 'dark' | 'light'
7
- truncate?: 'none' | 'auto' | 'leaf'
8
- }>(), {
9
- variant: 'light',
10
- truncate: 'none',
11
- })
12
-
13
- const TRUNCATE_THRESHOLD = 4
14
-
15
- const components = computed(() => props.chain.split(' > '))
16
- const shouldTruncate = computed(() => components.value.length >= TRUNCATE_THRESHOLD)
17
-
18
- // For 'auto' mode: first + ellipsis + last 2
1
+ <script setup>
2
+ import { computed, ref } from "vue-demi";
3
+ const props = defineProps({
4
+ chain: { type: String, required: true },
5
+ variant: { type: String, required: false, default: "light" },
6
+ truncate: { type: String, required: false, default: "none" }
7
+ });
8
+ const TRUNCATE_THRESHOLD = 4;
9
+ const components = computed(() => props.chain.split(" > "));
10
+ const shouldTruncate = computed(() => components.value.length >= TRUNCATE_THRESHOLD);
19
11
  const autoTruncated = computed(() => {
20
12
  if (!shouldTruncate.value)
21
- return components.value
22
- const all = components.value
23
- return [all[0], null, all[all.length - 2], all[all.length - 1]] as (string | null)[]
24
- })
25
-
26
- // For 'leaf' mode
27
- const leafExpanded = ref(false)
13
+ return components.value;
14
+ const all = components.value;
15
+ return [all[0], null, all[all.length - 2], all[all.length - 1]];
16
+ });
17
+ const leafExpanded = ref(false);
28
18
  </script>
29
19
 
30
20
  <template>
@@ -55,11 +45,8 @@ const leafExpanded = ref(false)
55
45
  <span
56
46
  v-else-if="truncate === 'leaf'"
57
47
  class="__va-comp-chain"
58
- :class="[
59
- `__va-comp-chain--${variant}`,
60
- shouldTruncate ? '__va-comp-chain--collapsible' : '',
61
- ]"
62
- @click.stop="shouldTruncate ? (leafExpanded = !leafExpanded) : undefined"
48
+ :class="[`__va-comp-chain--${variant}`, shouldTruncate ? '__va-comp-chain--collapsible' : '']"
49
+ @click.stop="shouldTruncate ? leafExpanded = !leafExpanded : void 0"
63
50
  >
64
51
  <template v-if="!shouldTruncate || leafExpanded">
65
52
  <span v-for="comp in components" :key="comp" class="__va-comp">
@@ -1,21 +1,18 @@
1
- <script setup lang="ts">
2
- import type { BoundingBox } from '../types'
3
- import { computed } from 'vue-demi'
4
- import { boundingBoxToStyle } from '../utils/style'
5
- import ComponentChain from './ComponentChain.vue'
6
-
7
- const props = defineProps<{
8
- rect: BoundingBox | null
9
- elementName: string
10
- visible: boolean
11
- componentChain?: string
12
- }>()
13
-
1
+ <script setup>
2
+ import { computed } from "vue-demi";
3
+ import { boundingBoxToStyle } from "../utils/style";
4
+ import ComponentChain from "./ComponentChain.vue";
5
+ const props = defineProps({
6
+ rect: { type: [Object, null], required: true },
7
+ elementName: { type: String, required: true },
8
+ visible: { type: Boolean, required: true },
9
+ componentChain: { type: String, required: false }
10
+ });
14
11
  const highlightStyle = computed(() => {
15
12
  if (!props.rect)
16
- return {}
17
- return boundingBoxToStyle(props.rect)
18
- })
13
+ return {};
14
+ return boundingBoxToStyle(props.rect);
15
+ });
19
16
  </script>
20
17
 
21
18
  <template>
@@ -1,47 +1,35 @@
1
- <script setup lang="ts">
2
- import type { Settings } from '../types'
3
- import { computed, toRef } from 'vue-demi'
4
- import { vaTooltipDirective } from '../directives/vaTooltip'
5
- import VaIcon from './VaIcon.vue'
6
- import VaToggle from './VaToggle.vue'
7
-
8
- const props = defineProps<{
9
- settings: Settings
10
- }>()
11
- const emit = defineEmits<{
12
- update: [settings: Partial<Settings>]
13
- }>()
14
- const settings = toRef(props, 'settings')
15
-
16
- const presetColors = ['#8B5CF6', '#3B82F6', '#06B6D4', '#10B981', '#EAB308', '#FF5C00', '#EF4444']
17
- const isMac = typeof navigator !== 'undefined' && /Mac|iPhone|iPad|iPod/.test(navigator.userAgent)
18
-
19
- function update(key: keyof Settings, value: any) {
20
- emit('update', { [key]: value })
1
+ <script setup>
2
+ import { computed, toRef } from "vue-demi";
3
+ import { vaTooltipDirective } from "../directives/vaTooltip";
4
+ import VaIcon from "./VaIcon.vue";
5
+ import VaToggle from "./VaToggle.vue";
6
+ const props = defineProps({
7
+ settings: { type: Object, required: true }
8
+ });
9
+ const emit = defineEmits(["update"]);
10
+ const settings = toRef(props, "settings");
11
+ const presetColors = ["#8B5CF6", "#3B82F6", "#06B6D4", "#10B981", "#EAB308", "#FF5C00", "#EF4444"];
12
+ const isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);
13
+ function update(key, value) {
14
+ emit("update", { [key]: value });
21
15
  }
22
-
23
- function onSelectChange(key: keyof Settings, event: Event) {
24
- const target = event.currentTarget as HTMLSelectElement | null
16
+ function onSelectChange(key, event) {
17
+ const target = event.currentTarget;
25
18
  if (!target)
26
- return
27
- update(key, target.value)
19
+ return;
20
+ update(key, target.value);
28
21
  }
29
-
30
22
  const isDarkTheme = computed(() => {
31
- if (settings.value.theme === 'dark')
32
- return true
33
- if (settings.value.theme === 'light')
34
- return false
35
- return typeof window !== 'undefined'
36
- && typeof window.matchMedia === 'function'
37
- && window.matchMedia('(prefers-color-scheme: dark)').matches
38
- })
39
-
40
- const themeIcon = computed(() => (isDarkTheme.value ? 'sun' : 'moon'))
41
- const vVaTooltip = vaTooltipDirective
42
-
23
+ if (settings.value.theme === "dark")
24
+ return true;
25
+ if (settings.value.theme === "light")
26
+ return false;
27
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches;
28
+ });
29
+ const themeIcon = computed(() => isDarkTheme.value ? "sun" : "moon");
30
+ const vVaTooltip = vaTooltipDirective;
43
31
  function toggleTheme() {
44
- update('theme', isDarkTheme.value ? 'light' : 'dark')
32
+ update("theme", isDarkTheme.value ? "light" : "dark");
45
33
  }
46
34
  </script>
47
35
 
@@ -84,8 +72,12 @@ function toggleTheme() {
84
72
  :key="color"
85
73
  type="button"
86
74
  class="__va-color-swatch"
87
- :class="{ '__va-color-swatch--active': settings.markerColor === color }"
88
- :style="{ background: color }"
75
+ :class="{
76
+ '__va-color-swatch--active': settings.markerColor === color
77
+ }"
78
+ :style="{
79
+ background: color
80
+ }"
89
81
  @click="update('markerColor', color)"
90
82
  />
91
83
  </div>
@@ -129,10 +121,10 @@ function toggleTheme() {
129
121
  Off
130
122
  </option>
131
123
  <option value="Meta">
132
- {{ isMac ? '&#8984; Cmd' : 'Ctrl' }}
124
+ {{ isMac ? "\u2318 Cmd" : "Ctrl" }}
133
125
  </option>
134
126
  <option value="Alt">
135
- {{ isMac ? '&#8997; Option' : 'Alt' }}
127
+ {{ isMac ? "\u2325 Option" : "Alt" }}
136
128
  </option>
137
129
  <option value="Shift">
138
130
  Shift