Adds the ability to swap nodes by dragging to the center of a tile.
Also fixes a bug where moving a node to a new lesser index under the
same parent would produce a no-op.
This adds support for windows builds. With it, the app can successfully
run on windows and unix systems. Note that the terminal still only works
on unix systems at this time.
This was a weird one, apparently Storybook still uses CJS but Vite has fully deprecated CJS support. So we need to dynamically import the electron.vite.config.ts file for Storybook, but this breaks because Typescript doesn't resolve and properly compile the dynamic import. To get around this, I am using the `tsx` package, which can dynamically compile typescript imports.
This sets us back up to use Vite via the electron-vite package. This
will let us continue to build our testing suite on Vitest and take
advantage of Vite features like Hot Module Reloading, etc.
---------
Co-authored-by: sawka <mike.sawka@gmail.com>
I found that the drag preview images would get unset when the app went idle. I am now caching the preview image and resetting it every time a user hovers over a TileNode. I am also updating the logic for the placeholder slightly to reduce the number of variables floating around.
It turns out that WebKit uses its own prefix for user-select so I'm adding this everywhere we currently define user-select, as well as a few new places
Insert the node at the new location before removing it from its old location. With the old order, removing a node from its parent could change the indexing of the parent node, if moving a node to a new location under the same parent.
This PR adds support for Outer variants of each DropDirection.
When calculating the drop direction, the cursor position is calculated
relevant to the box over which it is hovering. The following diagram
shows how drop directions are calculated. The colored in center is
currently not supported, it is assigned to the top, bottom, left, right
direction for now, though it will ultimately be its own distinct
direction.
![IMG_3505](https://github.com/wavetermdev/thenextwave/assets/16651283/a7ea7387-b95d-4831-9e29-d3225b824c97)
When an outer drop direction is provided for a move operation, if the
reference node flexes in the same axis as the drop direction, the new
node will be inserted at the same level as the parent of the reference
node. If the reference node flexes in a different direction or the
reference node does not have a grandparent, the operation will fall back
to its non-Outer variant.
This also removes some chatty debug statements, adds a blur to the
currently-dragging node to indicate that it cannot be dropped onto, and
simplifies the deriving of the layout state atom from the tab atom so
there's no longer another intermediate derived atom for the layout node.
This also adds rudimentary support for rendering custom preview images
for any tile being dragged. Right now, this is a simple block containing
the block ID, but this can be anything. This resolves an issue where
letting React-DnD generate its own previews could take up to a half
second, and would block dragging until complete. For Monaco, this was
outright failing.
It also fixes an issue where the tile layout could animate on first
paint. Now, I use React Suspense to prevent the layout from displaying
until all the children have loaded.