@dfosco/storyboard-react 3.8.1 → 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}>
|
package/src/canvas/useCanvas.js
CHANGED
|
@@ -59,14 +59,20 @@ export function useCanvas(name) {
|
|
|
59
59
|
})
|
|
60
60
|
}, [name, buildTimeCanvas])
|
|
61
61
|
|
|
62
|
+
const jsxModule = canvas?._jsxModule
|
|
63
|
+
const jsxImport = canvas?._jsxImport
|
|
64
|
+
|
|
62
65
|
useEffect(() => {
|
|
63
|
-
if (!
|
|
66
|
+
if (!jsxModule) {
|
|
64
67
|
setJsxExports(null)
|
|
65
68
|
return
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
const
|
|
69
|
-
|
|
71
|
+
const loadPromise = jsxImport
|
|
72
|
+
? jsxImport()
|
|
73
|
+
: import(/* @vite-ignore */ resolveCanvasModuleImport(jsxModule))
|
|
74
|
+
|
|
75
|
+
loadPromise
|
|
70
76
|
.then((mod) => {
|
|
71
77
|
const exports = {}
|
|
72
78
|
for (const [key, value] of Object.entries(mod)) {
|
|
@@ -77,10 +83,10 @@ export function useCanvas(name) {
|
|
|
77
83
|
setJsxExports(exports)
|
|
78
84
|
})
|
|
79
85
|
.catch((err) => {
|
|
80
|
-
console.error(`[storyboard] Failed to load canvas JSX module: ${
|
|
86
|
+
console.error(`[storyboard] Failed to load canvas JSX module: ${jsxModule}`, err)
|
|
81
87
|
setJsxExports(null)
|
|
82
88
|
})
|
|
83
|
-
}, [
|
|
89
|
+
}, [jsxModule, jsxImport])
|
|
84
90
|
|
|
85
91
|
// In dev, react to file mutations from the data plugin without reloading
|
|
86
92
|
// the current page. This keeps canvas editing state and route stable.
|
|
@@ -73,7 +73,9 @@ export function useFlowData(path) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if (sceneValue === undefined) {
|
|
76
|
-
|
|
76
|
+
if (data != null && Object.keys(data).length > 0) {
|
|
77
|
+
console.warn(`[useFlowData] Path "${path}" not found in flow data.`)
|
|
78
|
+
}
|
|
77
79
|
return {}
|
|
78
80
|
}
|
|
79
81
|
|
package/src/vite/data-plugin.js
CHANGED
|
@@ -444,7 +444,11 @@ function generateModule({ index, protoFolders, flowRoutes, canvasRoutes }, root)
|
|
|
444
444
|
}
|
|
445
445
|
parsed = resolveTemplateVars(parsed, templateVars)
|
|
446
446
|
|
|
447
|
-
|
|
447
|
+
if (suffix === 'canvas' && parsed._jsxModule) {
|
|
448
|
+
declarations.push(`const ${varName} = Object.assign(${JSON.stringify(parsed)}, { _jsxImport: () => import(${JSON.stringify(parsed._jsxModule)}) })`)
|
|
449
|
+
} else {
|
|
450
|
+
declarations.push(`const ${varName} = ${JSON.stringify(parsed)}`)
|
|
451
|
+
}
|
|
448
452
|
entries[suffix].push(` ${JSON.stringify(name)}: ${varName}`)
|
|
449
453
|
}
|
|
450
454
|
}
|