@dfosco/storyboard-react 3.8.2 → 3.9.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/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfosco/storyboard-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@dfosco/storyboard-core": "3.
|
|
6
|
+
"@dfosco/storyboard-core": "3.9.0",
|
|
7
7
|
"@dfosco/tiny-canvas": "^1.1.0",
|
|
8
8
|
"@neodrag/react": "^2.3.1",
|
|
9
9
|
"glob": "^11.0.0",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/dfosco/storyboard
|
|
15
|
+
"url": "https://github.com/dfosco/storyboard.git",
|
|
16
16
|
"directory": "packages/react"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
@@ -13,6 +13,12 @@ vi.mock('@dfosco/tiny-canvas', () => ({
|
|
|
13
13
|
>
|
|
14
14
|
drag widget
|
|
15
15
|
</button>
|
|
16
|
+
<button
|
|
17
|
+
data-testid="drag-widget-negative"
|
|
18
|
+
onClick={() => onDragEnd?.('widget-1', { x: -50, y: -30 })}
|
|
19
|
+
>
|
|
20
|
+
drag widget negative
|
|
21
|
+
</button>
|
|
16
22
|
<button
|
|
17
23
|
data-testid="drag-source"
|
|
18
24
|
onClick={() => onDragEnd?.('jsx-PrimaryButtons', { x: 333.2, y: 444.8 })}
|
|
@@ -144,6 +150,25 @@ describe('CanvasPage canvas bridge', () => {
|
|
|
144
150
|
)
|
|
145
151
|
})
|
|
146
152
|
})
|
|
153
|
+
|
|
154
|
+
it('clamps negative drag positions to zero', async () => {
|
|
155
|
+
render(<CanvasPage name="design-overview" />)
|
|
156
|
+
|
|
157
|
+
fireEvent.click(screen.getByTestId('drag-widget-negative'))
|
|
158
|
+
await waitFor(() => {
|
|
159
|
+
expect(updateCanvas).toHaveBeenCalledWith(
|
|
160
|
+
'design-overview',
|
|
161
|
+
expect.objectContaining({
|
|
162
|
+
widgets: expect.arrayContaining([
|
|
163
|
+
expect.objectContaining({
|
|
164
|
+
id: 'widget-1',
|
|
165
|
+
position: { x: 0, y: 0 },
|
|
166
|
+
}),
|
|
167
|
+
]),
|
|
168
|
+
})
|
|
169
|
+
)
|
|
170
|
+
})
|
|
171
|
+
})
|
|
147
172
|
})
|
|
148
173
|
|
|
149
174
|
describe('getCanvasThemeVars', () => {
|
|
@@ -156,7 +156,7 @@ export default function CanvasPage({ name }) {
|
|
|
156
156
|
|
|
157
157
|
const handleItemDragEnd = useCallback((dragId, position) => {
|
|
158
158
|
if (!dragId || !position) return
|
|
159
|
-
const rounded = { x: roundPosition(position.x), y: roundPosition(position.y) }
|
|
159
|
+
const rounded = { x: Math.max(0, roundPosition(position.x)), y: Math.max(0, roundPosition(position.y)) }
|
|
160
160
|
|
|
161
161
|
if (dragId.startsWith('jsx-')) {
|
|
162
162
|
const sourceExport = dragId.replace(/^jsx-/, '')
|
|
@@ -541,6 +541,7 @@ export default function CanvasPage({ name }) {
|
|
|
541
541
|
transformOrigin: '0 0',
|
|
542
542
|
width: `${Math.max(10000, 100 / scale)}vw`,
|
|
543
543
|
height: `${Math.max(10000, 100 / scale)}vh`,
|
|
544
|
+
...(spaceHeld ? { pointerEvents: 'none' } : {}),
|
|
544
545
|
}}
|
|
545
546
|
>
|
|
546
547
|
<Canvas {...canvasProps} onDragEnd={handleItemDragEnd}>
|