@viamrobotics/test-widgets 0.1.1 → 0.1.2
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/components/index.d.ts +0 -2
- package/dist/components/index.js +0 -2
- package/dist/components/widgets/do-command/do-command.svelte +14 -4
- package/dist/components/widgets/switch/position-view.svelte +6 -6
- package/dist/components/widgets/vision-service/context.svelte.js +6 -6
- package/package.json +1 -1
- package/dist/components/image-annotations/annotation-edit-utils.d.ts +0 -21
- package/dist/components/image-annotations/annotation-edit-utils.js +0 -183
- package/dist/components/image-annotations/bounding-box-labeler.svelte +0 -521
- package/dist/components/image-annotations/bounding-box-labeler.svelte.d.ts +0 -51
- package/dist/components/image-annotations/bounding-box-types.d.ts +0 -29
- package/dist/components/image-annotations/bounding-box-types.js +0 -17
- package/dist/components/image-annotations/bounding-box.svelte +0 -230
- package/dist/components/image-annotations/bounding-box.svelte.d.ts +0 -44
- package/dist/components/image-annotations/get-image-size.d.ts +0 -7
- package/dist/components/image-annotations/get-image-size.js +0 -29
- package/dist/components/image-annotations/labeler-constants.d.ts +0 -4
- package/dist/components/image-annotations/labeler-constants.js +0 -4
- package/dist/components/image-annotations/resize-corner.svelte +0 -47
- package/dist/components/image-annotations/resize-corner.svelte.d.ts +0 -9
- package/dist/components/image-annotations/resize-edge.svelte +0 -51
- package/dist/components/image-annotations/resize-edge.svelte.d.ts +0 -9
- package/dist/components/image-annotations/resize-handle-props.d.ts +0 -60
- package/dist/components/image-annotations/resize-handle-props.js +0 -66
- package/dist/components/image-annotations/resize-handles.svelte +0 -53
- package/dist/components/image-annotations/resize-handles.svelte.d.ts +0 -8
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { labelToColor } from '../widgets/vision-service/color'
|
|
3
|
-
|
|
4
|
-
import type { BoundingBox, Coordinates, ResizeHandleLocation } from './bounding-box-types'
|
|
5
|
-
|
|
6
|
-
import { getBoundingRect, getModifyKeyForOS } from './annotation-edit-utils'
|
|
7
|
-
import ResizeHandles from './resize-handles.svelte'
|
|
8
|
-
|
|
9
|
-
// opacity represented as hexadecimal
|
|
10
|
-
const ACTIVE_BG_OPACITY = '70'
|
|
11
|
-
const INACTIVE_BG_OPACITY = '30'
|
|
12
|
-
const ACTIVE_BORDER_OPACITY = 'FF'
|
|
13
|
-
const INACTIVE_BORDER_OPACITY = 'AA'
|
|
14
|
-
|
|
15
|
-
const MODIFY_KEY = getModifyKeyForOS()
|
|
16
|
-
|
|
17
|
-
interface Props {
|
|
18
|
-
/** whether to display the active (hovered) state */
|
|
19
|
-
active: boolean
|
|
20
|
-
/** which corner is currently being manipulated */
|
|
21
|
-
activeResizeHandle?: ResizeHandleLocation | undefined
|
|
22
|
-
/** whether to allow click or hovering behaviors to function */
|
|
23
|
-
allowInteractivity: boolean
|
|
24
|
-
/** bounding box size and label information */
|
|
25
|
-
annotation: BoundingBox
|
|
26
|
-
/** width of drawing container */
|
|
27
|
-
containerHeight: number
|
|
28
|
-
/** height of drawing container */
|
|
29
|
-
containerWidth: number
|
|
30
|
-
/** distance box has been dragged in pixels */
|
|
31
|
-
dragDistance?: Coordinates
|
|
32
|
-
/** whether box should be displayed with dashed borders to indicate pending status */
|
|
33
|
-
isPending: boolean
|
|
34
|
-
/** whether box should box should be editable (can still be hovered) */
|
|
35
|
-
readonly?: boolean
|
|
36
|
-
/** whether box has been selected (clicked on) */
|
|
37
|
-
selected?: boolean
|
|
38
|
-
/** tab index used for tabbing behaviors */
|
|
39
|
-
tabIndex?: number
|
|
40
|
-
/** current zoom scale being applied to labeller */
|
|
41
|
-
zoom: number
|
|
42
|
-
/** add current box to list of hovered boxes */
|
|
43
|
-
addToHovered?: (id: string) => void
|
|
44
|
-
/** called when backspace keyboard key is pressed */
|
|
45
|
-
onBackspacePress?: (id: string, label: string) => void
|
|
46
|
-
/** called when hitting copy command */
|
|
47
|
-
onCopyPress?: () => void
|
|
48
|
-
/** called when enter keyboard key is pressed */
|
|
49
|
-
onEnterPress?: (id: string) => void
|
|
50
|
-
/** called when escape keyboard key is pressed */
|
|
51
|
-
onEscapePress?: VoidFunction
|
|
52
|
-
/** called on mouse down on the box */
|
|
53
|
-
onMouseDown?: (event: MouseEvent, id: string, corner?: ResizeHandleLocation) => void
|
|
54
|
-
/** remove current box to list of hovered boxes */
|
|
55
|
-
removeFromHovered?: (id: string) => void
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const {
|
|
59
|
-
active,
|
|
60
|
-
activeResizeHandle,
|
|
61
|
-
allowInteractivity,
|
|
62
|
-
annotation,
|
|
63
|
-
containerHeight,
|
|
64
|
-
containerWidth,
|
|
65
|
-
dragDistance,
|
|
66
|
-
isPending,
|
|
67
|
-
readonly = false,
|
|
68
|
-
selected = false,
|
|
69
|
-
tabIndex = -1,
|
|
70
|
-
zoom,
|
|
71
|
-
addToHovered,
|
|
72
|
-
onBackspacePress,
|
|
73
|
-
onCopyPress,
|
|
74
|
-
onEnterPress,
|
|
75
|
-
onEscapePress,
|
|
76
|
-
onMouseDown,
|
|
77
|
-
removeFromHovered,
|
|
78
|
-
}: Props = $props()
|
|
79
|
-
|
|
80
|
-
const color = $derived(labelToColor(annotation.label))
|
|
81
|
-
|
|
82
|
-
let factoredXMin = $state(0)
|
|
83
|
-
let factoredXMax = $state(0)
|
|
84
|
-
let factoredYMin = $state(0)
|
|
85
|
-
let factoredYMax = $state(0)
|
|
86
|
-
let box: HTMLDivElement | undefined = $state()
|
|
87
|
-
let labelText: HTMLDivElement | undefined = $state()
|
|
88
|
-
|
|
89
|
-
const drag = $derived(selected ? dragDistance : undefined)
|
|
90
|
-
|
|
91
|
-
$effect.pre(() => {
|
|
92
|
-
const boundingRect = getBoundingRect(
|
|
93
|
-
annotation,
|
|
94
|
-
drag,
|
|
95
|
-
containerWidth,
|
|
96
|
-
containerHeight,
|
|
97
|
-
activeResizeHandle
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
factoredXMin = boundingRect.xMinNormalized
|
|
101
|
-
factoredXMax = boundingRect.xMaxNormalized
|
|
102
|
-
factoredYMin = boundingRect.yMinNormalized
|
|
103
|
-
factoredYMax = boundingRect.yMaxNormalized
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
const showHighlight = $derived(active || selected)
|
|
107
|
-
|
|
108
|
-
const handleMove = () => {
|
|
109
|
-
if (allowInteractivity) {
|
|
110
|
-
addToHovered?.(annotation.id)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const handleLeave = () => {
|
|
115
|
-
removeFromHovered?.(annotation.id)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
119
|
-
if (selected && event[MODIFY_KEY]) {
|
|
120
|
-
// prevents UX from going into crosshair drawing mode when first pressing CMD/CTRL key
|
|
121
|
-
event.stopPropagation()
|
|
122
|
-
|
|
123
|
-
if (event.code === 'KeyC') {
|
|
124
|
-
onCopyPress?.()
|
|
125
|
-
box?.blur()
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
switch (event.code) {
|
|
130
|
-
case 'Escape': {
|
|
131
|
-
event.stopPropagation()
|
|
132
|
-
onEscapePress?.()
|
|
133
|
-
break
|
|
134
|
-
}
|
|
135
|
-
case 'Enter': {
|
|
136
|
-
event.stopPropagation()
|
|
137
|
-
onEnterPress?.(annotation.id)
|
|
138
|
-
break
|
|
139
|
-
}
|
|
140
|
-
case 'Backspace': {
|
|
141
|
-
event.stopPropagation()
|
|
142
|
-
onBackspacePress?.(annotation.id, annotation.label)
|
|
143
|
-
break
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
$effect(() => {
|
|
149
|
-
if (selected) {
|
|
150
|
-
box?.focus()
|
|
151
|
-
} else {
|
|
152
|
-
box?.blur()
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
const handleMouseDown = (event: MouseEvent) => {
|
|
157
|
-
if (!readonly && allowInteractivity) {
|
|
158
|
-
event.stopPropagation()
|
|
159
|
-
onMouseDown?.(event, annotation.id)
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const handleCornerPointerDown = (event: MouseEvent, corner: ResizeHandleLocation) => {
|
|
164
|
-
event.stopPropagation()
|
|
165
|
-
onMouseDown?.(event, annotation.id, corner)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const zIndex = $derived.by(() => {
|
|
169
|
-
if (selected) return 30
|
|
170
|
-
if (showHighlight) return 20
|
|
171
|
-
return 10
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
const labelTextWidth = $derived(labelText?.getBoundingClientRect().width ?? 0)
|
|
175
|
-
const rightAlignText = $derived.by(() => {
|
|
176
|
-
// check if text needs right align when text is bigger than box
|
|
177
|
-
if (labelTextWidth < (factoredXMax - factoredXMin) * zoom) {
|
|
178
|
-
return false
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// only right align when the distance between the box left edge plus text width exceeds container boundary
|
|
182
|
-
return labelTextWidth / zoom + factoredXMin > containerWidth
|
|
183
|
-
})
|
|
184
|
-
</script>
|
|
185
|
-
|
|
186
|
-
<div
|
|
187
|
-
role="button"
|
|
188
|
-
tabindex={tabIndex}
|
|
189
|
-
bind:this={box}
|
|
190
|
-
class={['absolute outline-none', { 'border-dashed': isPending }]}
|
|
191
|
-
style:border-width={`${2 / zoom}px`}
|
|
192
|
-
style:border-color={showHighlight
|
|
193
|
-
? `${color}${ACTIVE_BORDER_OPACITY.toString()}`
|
|
194
|
-
: `${color}${INACTIVE_BORDER_OPACITY.toString()}`}
|
|
195
|
-
style:background-color={showHighlight
|
|
196
|
-
? `${color}${ACTIVE_BG_OPACITY.toString()}`
|
|
197
|
-
: `${color}${INACTIVE_BG_OPACITY.toString()}`}
|
|
198
|
-
style:top={`${factoredYMin}px`}
|
|
199
|
-
style:left={`${factoredXMin}px`}
|
|
200
|
-
style:height={`${factoredYMax - factoredYMin}px`}
|
|
201
|
-
style:width={`${factoredXMax - factoredXMin}px`}
|
|
202
|
-
style:z-index={zIndex}
|
|
203
|
-
onmousedown={handleMouseDown}
|
|
204
|
-
onmouseleave={handleLeave}
|
|
205
|
-
onmousemove={handleMove}
|
|
206
|
-
onkeydown={handleKeyDown}
|
|
207
|
-
>
|
|
208
|
-
{#if showHighlight}
|
|
209
|
-
<div
|
|
210
|
-
bind:this={labelText}
|
|
211
|
-
class="absolute w-fit select-none"
|
|
212
|
-
style:background-color={color}
|
|
213
|
-
style:transform-origin={`top ${rightAlignText ? 'right' : 'left'}`}
|
|
214
|
-
style:scale={1 / zoom}
|
|
215
|
-
style:right={rightAlignText ? `-${2 / zoom}px` : undefined}
|
|
216
|
-
style:left={rightAlignText ? undefined : `-${2 / zoom}px`}
|
|
217
|
-
style:top={factoredYMin > 24 / zoom ? `-${24 / zoom}px` : `-${2 / zoom}px`}
|
|
218
|
-
>
|
|
219
|
-
<span class="font-roboto-mono px-2 py-0.5 text-xs font-medium whitespace-nowrap"
|
|
220
|
-
>{annotation.label}</span
|
|
221
|
-
>
|
|
222
|
-
</div>
|
|
223
|
-
{/if}
|
|
224
|
-
{#if selected && !readonly}
|
|
225
|
-
<ResizeHandles
|
|
226
|
-
{zoom}
|
|
227
|
-
onMouseDown={handleCornerPointerDown}
|
|
228
|
-
/>
|
|
229
|
-
{/if}
|
|
230
|
-
</div>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { BoundingBox, Coordinates, ResizeHandleLocation } from './bounding-box-types';
|
|
2
|
-
interface Props {
|
|
3
|
-
/** whether to display the active (hovered) state */
|
|
4
|
-
active: boolean;
|
|
5
|
-
/** which corner is currently being manipulated */
|
|
6
|
-
activeResizeHandle?: ResizeHandleLocation | undefined;
|
|
7
|
-
/** whether to allow click or hovering behaviors to function */
|
|
8
|
-
allowInteractivity: boolean;
|
|
9
|
-
/** bounding box size and label information */
|
|
10
|
-
annotation: BoundingBox;
|
|
11
|
-
/** width of drawing container */
|
|
12
|
-
containerHeight: number;
|
|
13
|
-
/** height of drawing container */
|
|
14
|
-
containerWidth: number;
|
|
15
|
-
/** distance box has been dragged in pixels */
|
|
16
|
-
dragDistance?: Coordinates;
|
|
17
|
-
/** whether box should be displayed with dashed borders to indicate pending status */
|
|
18
|
-
isPending: boolean;
|
|
19
|
-
/** whether box should box should be editable (can still be hovered) */
|
|
20
|
-
readonly?: boolean;
|
|
21
|
-
/** whether box has been selected (clicked on) */
|
|
22
|
-
selected?: boolean;
|
|
23
|
-
/** tab index used for tabbing behaviors */
|
|
24
|
-
tabIndex?: number;
|
|
25
|
-
/** current zoom scale being applied to labeller */
|
|
26
|
-
zoom: number;
|
|
27
|
-
/** add current box to list of hovered boxes */
|
|
28
|
-
addToHovered?: (id: string) => void;
|
|
29
|
-
/** called when backspace keyboard key is pressed */
|
|
30
|
-
onBackspacePress?: (id: string, label: string) => void;
|
|
31
|
-
/** called when hitting copy command */
|
|
32
|
-
onCopyPress?: () => void;
|
|
33
|
-
/** called when enter keyboard key is pressed */
|
|
34
|
-
onEnterPress?: (id: string) => void;
|
|
35
|
-
/** called when escape keyboard key is pressed */
|
|
36
|
-
onEscapePress?: VoidFunction;
|
|
37
|
-
/** called on mouse down on the box */
|
|
38
|
-
onMouseDown?: (event: MouseEvent, id: string, corner?: ResizeHandleLocation) => void;
|
|
39
|
-
/** remove current box to list of hovered boxes */
|
|
40
|
-
removeFromHovered?: (id: string) => void;
|
|
41
|
-
}
|
|
42
|
-
declare const BoundingBox: import("svelte").Component<Props, {}, "">;
|
|
43
|
-
type BoundingBox = ReturnType<typeof BoundingBox>;
|
|
44
|
-
export default BoundingBox;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export interface Size {
|
|
2
|
-
/** The image height, with a max height determined by its container */
|
|
3
|
-
height: number;
|
|
4
|
-
/** The image width, resized to match aspect ratio determined by height */
|
|
5
|
-
width: number;
|
|
6
|
-
}
|
|
7
|
-
export declare const getImageSize: (img: HTMLImageElement, container: HTMLElement) => Size;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const getImageSize = (img, container) => {
|
|
2
|
-
const aspectRatio = img.naturalWidth / img.naturalHeight;
|
|
3
|
-
if (img.naturalHeight > img.naturalWidth) {
|
|
4
|
-
let heightNumber = Math.min(container.clientHeight, img.naturalHeight);
|
|
5
|
-
let widthNumber = heightNumber * aspectRatio;
|
|
6
|
-
// if scaled width is still too large for container, scale down again
|
|
7
|
-
if (widthNumber > container.clientWidth) {
|
|
8
|
-
const downScale = container.clientWidth / widthNumber;
|
|
9
|
-
widthNumber = container.clientWidth;
|
|
10
|
-
heightNumber *= downScale;
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
width: widthNumber,
|
|
14
|
-
height: heightNumber,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
let widthNumber = Math.min(container.clientWidth, img.naturalWidth);
|
|
18
|
-
let heightNumber = widthNumber * (1 / aspectRatio);
|
|
19
|
-
// if scaled height is still too large for container, scale down again
|
|
20
|
-
if (heightNumber > container.clientHeight) {
|
|
21
|
-
const downScale = container.clientHeight / heightNumber;
|
|
22
|
-
heightNumber = container.clientHeight;
|
|
23
|
-
widthNumber *= downScale;
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
width: widthNumber,
|
|
27
|
-
height: heightNumber,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { ResizeHandleLocation } from './bounding-box-types'
|
|
3
|
-
import {
|
|
4
|
-
BOX_SIZE,
|
|
5
|
-
INVISIBLE_BUFFER,
|
|
6
|
-
ResizeHandleClassMap,
|
|
7
|
-
WRAPPER_SIZE,
|
|
8
|
-
} from './resize-handle-props'
|
|
9
|
-
|
|
10
|
-
interface Props {
|
|
11
|
-
cornerDesignation: ResizeHandleLocation
|
|
12
|
-
zoom?: number
|
|
13
|
-
onMouseDown: (event: MouseEvent, corner: ResizeHandleLocation) => void
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const { cornerDesignation, zoom = 1, onMouseDown }: Props = $props()
|
|
17
|
-
|
|
18
|
-
const wrapperStyle = $derived(ResizeHandleClassMap[cornerDesignation])
|
|
19
|
-
|
|
20
|
-
const handleMouseDown = (event: MouseEvent) => {
|
|
21
|
-
;(event as PointerEvent).stopPropagation()
|
|
22
|
-
onMouseDown(event, cornerDesignation)
|
|
23
|
-
}
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
<button
|
|
27
|
-
tabindex="-1"
|
|
28
|
-
class="absolute"
|
|
29
|
-
aria-label={`${cornerDesignation}-resize`}
|
|
30
|
-
style:height={`${WRAPPER_SIZE}px`}
|
|
31
|
-
style:width={`${WRAPPER_SIZE}px`}
|
|
32
|
-
style:left={`${wrapperStyle.positionLeft ?? ''}px`}
|
|
33
|
-
style:top={`${wrapperStyle.positionTop ?? ''}px`}
|
|
34
|
-
style:right={`${wrapperStyle.positionRight ?? ''}px`}
|
|
35
|
-
style:bottom={`${wrapperStyle.positionBottom ?? ''}px`}
|
|
36
|
-
style:cursor={wrapperStyle.cursor}
|
|
37
|
-
style:scale={1 / zoom}
|
|
38
|
-
onmousedown={handleMouseDown}
|
|
39
|
-
>
|
|
40
|
-
<div
|
|
41
|
-
style:height={`${BOX_SIZE}px`}
|
|
42
|
-
style:width={`${BOX_SIZE}px`}
|
|
43
|
-
style:left={`${INVISIBLE_BUFFER / 2}px`}
|
|
44
|
-
style:top={`${INVISIBLE_BUFFER / 2}px`}
|
|
45
|
-
class="absolute border border-black bg-white"
|
|
46
|
-
></div>
|
|
47
|
-
</button>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ResizeHandleLocation } from './bounding-box-types';
|
|
2
|
-
interface Props {
|
|
3
|
-
cornerDesignation: ResizeHandleLocation;
|
|
4
|
-
zoom?: number;
|
|
5
|
-
onMouseDown: (event: MouseEvent, corner: ResizeHandleLocation) => void;
|
|
6
|
-
}
|
|
7
|
-
declare const ResizeCorner: import("svelte").Component<Props, {}, "">;
|
|
8
|
-
type ResizeCorner = ReturnType<typeof ResizeCorner>;
|
|
9
|
-
export default ResizeCorner;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { ResizeHandleLocation } from './bounding-box-types'
|
|
3
|
-
import { ResizeHandleClassMap } from './resize-handle-props'
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
edgeDesignation: ResizeHandleLocation
|
|
7
|
-
zoom?: number
|
|
8
|
-
onMouseDown: (event: MouseEvent, edge: ResizeHandleLocation) => void
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const { edgeDesignation, zoom = 1, onMouseDown }: Props = $props()
|
|
12
|
-
|
|
13
|
-
const wrapperStyle = $derived(ResizeHandleClassMap[edgeDesignation])
|
|
14
|
-
|
|
15
|
-
const handleMouseDown = (event: MouseEvent) => {
|
|
16
|
-
;(event as PointerEvent).stopPropagation()
|
|
17
|
-
onMouseDown(event, edgeDesignation)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const scale = $derived.by(() => {
|
|
21
|
-
switch (edgeDesignation) {
|
|
22
|
-
case ResizeHandleLocation.L:
|
|
23
|
-
case ResizeHandleLocation.R: {
|
|
24
|
-
return `${1 / zoom} 1`
|
|
25
|
-
}
|
|
26
|
-
case ResizeHandleLocation.T:
|
|
27
|
-
case ResizeHandleLocation.B: {
|
|
28
|
-
return `1 ${1 / zoom}`
|
|
29
|
-
}
|
|
30
|
-
default: {
|
|
31
|
-
return ''
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<button
|
|
38
|
-
tabindex="-1"
|
|
39
|
-
class="absolute"
|
|
40
|
-
aria-label={`${edgeDesignation}-resize`}
|
|
41
|
-
style:height={wrapperStyle.height}
|
|
42
|
-
style:width={wrapperStyle.width}
|
|
43
|
-
style:left={`${wrapperStyle.positionLeft ?? ''}px`}
|
|
44
|
-
style:top={`${wrapperStyle.positionTop ?? ''}px`}
|
|
45
|
-
style:right={`${wrapperStyle.positionRight ?? ''}px`}
|
|
46
|
-
style:bottom={`${wrapperStyle.positionBottom ?? ''}px`}
|
|
47
|
-
style:cursor={wrapperStyle.cursor}
|
|
48
|
-
style:scale
|
|
49
|
-
onmousedown={handleMouseDown}
|
|
50
|
-
>
|
|
51
|
-
</button>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ResizeHandleLocation } from './bounding-box-types';
|
|
2
|
-
interface Props {
|
|
3
|
-
edgeDesignation: ResizeHandleLocation;
|
|
4
|
-
zoom?: number;
|
|
5
|
-
onMouseDown: (event: MouseEvent, edge: ResizeHandleLocation) => void;
|
|
6
|
-
}
|
|
7
|
-
declare const ResizeEdge: import("svelte").Component<Props, {}, "">;
|
|
8
|
-
type ResizeEdge = ReturnType<typeof ResizeEdge>;
|
|
9
|
-
export default ResizeEdge;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { ResizeHandleLocation } from './bounding-box-types';
|
|
2
|
-
export declare const BOX_SIZE = 10;
|
|
3
|
-
export declare const INVISIBLE_BUFFER = 6;
|
|
4
|
-
export declare const WRAPPER_SIZE: number;
|
|
5
|
-
export declare const OFFSET: number;
|
|
6
|
-
export declare const EDGE_WIDTH = 6;
|
|
7
|
-
export declare const EDGE_OFFSET: number;
|
|
8
|
-
export declare const topLeft: {
|
|
9
|
-
positionLeft: number;
|
|
10
|
-
positionTop: number;
|
|
11
|
-
cursor: string;
|
|
12
|
-
height: number;
|
|
13
|
-
width: number;
|
|
14
|
-
};
|
|
15
|
-
export declare const topRight: {
|
|
16
|
-
positionRight: number;
|
|
17
|
-
positionTop: number;
|
|
18
|
-
cursor: string;
|
|
19
|
-
height: number;
|
|
20
|
-
width: number;
|
|
21
|
-
};
|
|
22
|
-
export declare const bottomLeft: {
|
|
23
|
-
positionLeft: number;
|
|
24
|
-
positionBottom: number;
|
|
25
|
-
cursor: string;
|
|
26
|
-
height: number;
|
|
27
|
-
width: number;
|
|
28
|
-
};
|
|
29
|
-
export declare const bottomRight: {
|
|
30
|
-
positionRight: number;
|
|
31
|
-
positionBottom: number;
|
|
32
|
-
cursor: string;
|
|
33
|
-
height: number;
|
|
34
|
-
width: number;
|
|
35
|
-
};
|
|
36
|
-
export declare const top: {
|
|
37
|
-
height: string;
|
|
38
|
-
width: string;
|
|
39
|
-
positionTop: number;
|
|
40
|
-
cursor: string;
|
|
41
|
-
};
|
|
42
|
-
export declare const right: {
|
|
43
|
-
height: string;
|
|
44
|
-
width: string;
|
|
45
|
-
positionRight: number;
|
|
46
|
-
cursor: string;
|
|
47
|
-
};
|
|
48
|
-
export declare const bottom: {
|
|
49
|
-
height: string;
|
|
50
|
-
width: string;
|
|
51
|
-
positionBottom: number;
|
|
52
|
-
cursor: string;
|
|
53
|
-
};
|
|
54
|
-
export declare const left: {
|
|
55
|
-
height: string;
|
|
56
|
-
width: string;
|
|
57
|
-
positionLeft: number;
|
|
58
|
-
cursor: string;
|
|
59
|
-
};
|
|
60
|
-
export declare const ResizeHandleClassMap: Record<ResizeHandleLocation, Record<string, number | string>>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ResizeHandleLocation } from './bounding-box-types';
|
|
2
|
-
export const BOX_SIZE = 10;
|
|
3
|
-
export const INVISIBLE_BUFFER = 6;
|
|
4
|
-
export const WRAPPER_SIZE = BOX_SIZE + INVISIBLE_BUFFER;
|
|
5
|
-
export const OFFSET = -0.5 * WRAPPER_SIZE;
|
|
6
|
-
export const EDGE_WIDTH = 6;
|
|
7
|
-
export const EDGE_OFFSET = EDGE_WIDTH / -2;
|
|
8
|
-
const wrapperBaseProps = { height: WRAPPER_SIZE, width: WRAPPER_SIZE };
|
|
9
|
-
export const topLeft = {
|
|
10
|
-
...wrapperBaseProps,
|
|
11
|
-
positionLeft: OFFSET,
|
|
12
|
-
positionTop: OFFSET,
|
|
13
|
-
cursor: 'nwse-resize',
|
|
14
|
-
};
|
|
15
|
-
export const topRight = {
|
|
16
|
-
...wrapperBaseProps,
|
|
17
|
-
positionRight: OFFSET,
|
|
18
|
-
positionTop: OFFSET,
|
|
19
|
-
cursor: 'nesw-resize',
|
|
20
|
-
};
|
|
21
|
-
export const bottomLeft = {
|
|
22
|
-
...wrapperBaseProps,
|
|
23
|
-
positionLeft: OFFSET,
|
|
24
|
-
positionBottom: OFFSET,
|
|
25
|
-
cursor: 'nesw-resize',
|
|
26
|
-
};
|
|
27
|
-
export const bottomRight = {
|
|
28
|
-
...wrapperBaseProps,
|
|
29
|
-
positionRight: OFFSET,
|
|
30
|
-
positionBottom: OFFSET,
|
|
31
|
-
cursor: 'nwse-resize',
|
|
32
|
-
};
|
|
33
|
-
export const top = {
|
|
34
|
-
height: `${EDGE_WIDTH}px`,
|
|
35
|
-
width: '100%',
|
|
36
|
-
positionTop: EDGE_OFFSET,
|
|
37
|
-
cursor: 'ns-resize',
|
|
38
|
-
};
|
|
39
|
-
export const right = {
|
|
40
|
-
height: '100%',
|
|
41
|
-
width: `${EDGE_WIDTH}px`,
|
|
42
|
-
positionRight: EDGE_OFFSET,
|
|
43
|
-
cursor: 'ew-resize',
|
|
44
|
-
};
|
|
45
|
-
export const bottom = {
|
|
46
|
-
height: `${EDGE_WIDTH}px`,
|
|
47
|
-
width: '100%',
|
|
48
|
-
positionBottom: EDGE_OFFSET,
|
|
49
|
-
cursor: 'ns-resize',
|
|
50
|
-
};
|
|
51
|
-
export const left = {
|
|
52
|
-
height: '100%',
|
|
53
|
-
width: `${EDGE_WIDTH}px`,
|
|
54
|
-
positionLeft: EDGE_OFFSET,
|
|
55
|
-
cursor: 'ew-resize',
|
|
56
|
-
};
|
|
57
|
-
export const ResizeHandleClassMap = {
|
|
58
|
-
[ResizeHandleLocation.T]: top,
|
|
59
|
-
[ResizeHandleLocation.R]: right,
|
|
60
|
-
[ResizeHandleLocation.B]: bottom,
|
|
61
|
-
[ResizeHandleLocation.L]: left,
|
|
62
|
-
[ResizeHandleLocation.TL]: topLeft,
|
|
63
|
-
[ResizeHandleLocation.TR]: topRight,
|
|
64
|
-
[ResizeHandleLocation.BL]: bottomLeft,
|
|
65
|
-
[ResizeHandleLocation.BR]: bottomRight,
|
|
66
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { ResizeHandleLocation } from './bounding-box-types'
|
|
3
|
-
import ResizeCorner from './resize-corner.svelte'
|
|
4
|
-
import ResizeEdge from './resize-edge.svelte'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
zoom: number
|
|
8
|
-
onMouseDown: (event: MouseEvent, edge: ResizeHandleLocation) => void
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const { zoom, onMouseDown }: Props = $props()
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<ResizeEdge
|
|
15
|
-
{zoom}
|
|
16
|
-
edgeDesignation={ResizeHandleLocation.T}
|
|
17
|
-
{onMouseDown}
|
|
18
|
-
/>
|
|
19
|
-
<ResizeEdge
|
|
20
|
-
{zoom}
|
|
21
|
-
edgeDesignation={ResizeHandleLocation.R}
|
|
22
|
-
{onMouseDown}
|
|
23
|
-
/>
|
|
24
|
-
<ResizeEdge
|
|
25
|
-
{zoom}
|
|
26
|
-
edgeDesignation={ResizeHandleLocation.B}
|
|
27
|
-
{onMouseDown}
|
|
28
|
-
/>
|
|
29
|
-
<ResizeEdge
|
|
30
|
-
{zoom}
|
|
31
|
-
edgeDesignation={ResizeHandleLocation.L}
|
|
32
|
-
{onMouseDown}
|
|
33
|
-
/>
|
|
34
|
-
<ResizeCorner
|
|
35
|
-
{zoom}
|
|
36
|
-
cornerDesignation={ResizeHandleLocation.TL}
|
|
37
|
-
{onMouseDown}
|
|
38
|
-
/>
|
|
39
|
-
<ResizeCorner
|
|
40
|
-
{zoom}
|
|
41
|
-
cornerDesignation={ResizeHandleLocation.TR}
|
|
42
|
-
{onMouseDown}
|
|
43
|
-
/>
|
|
44
|
-
<ResizeCorner
|
|
45
|
-
{zoom}
|
|
46
|
-
cornerDesignation={ResizeHandleLocation.BL}
|
|
47
|
-
{onMouseDown}
|
|
48
|
-
/>
|
|
49
|
-
<ResizeCorner
|
|
50
|
-
{zoom}
|
|
51
|
-
cornerDesignation={ResizeHandleLocation.BR}
|
|
52
|
-
{onMouseDown}
|
|
53
|
-
/>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ResizeHandleLocation } from './bounding-box-types';
|
|
2
|
-
interface Props {
|
|
3
|
-
zoom: number;
|
|
4
|
-
onMouseDown: (event: MouseEvent, edge: ResizeHandleLocation) => void;
|
|
5
|
-
}
|
|
6
|
-
declare const ResizeHandles: import("svelte").Component<Props, {}, "">;
|
|
7
|
-
type ResizeHandles = ReturnType<typeof ResizeHandles>;
|
|
8
|
-
export default ResizeHandles;
|