Changelog
Every release of @lukez/svelte-dnd, generated from the package CHANGELOG.md.
Subscribe via Atom1.0.0
Major Changes
First stable release of the Svelte 5 rewrite of
svelte-dnd-action. Zones and drag handles are attachments (dndzone,dragHandleZone,dragHandle), updates arrive through theonconsiderandonfinalizeoptions, and global settings go throughconfigure.Read the documentation to get started, or the migration guide to move from
svelte-dnd-action. See1.0.0-next.0below for the full list of changes since the fork.
Patch Changes
useComputedStyleForRectsnow also applies when a pointer drag starts: the dragged clone takes the item's computed width, height and box-sizing instead of its bounding rect. Before, the clone was sized from the rect at drag start, and the option only took effect on the first morph.A click on another item during a keyboard drag now ends the drag with an
onconsiderwhose trigger isDRAG_STOPPEDbefore it starts a drag of the clicked item. Before, the first drag ended without one, so code that saves onDRAG_STOPPEDmissed its moves. No new drag starts if that handler disables dragging in the clicked item's zone or removes the item.A pointer drag now scrolls a page that only overflows horizontally when the page's scroll width is not more than the window's height, as in a portrait window. Before, the check compared the scroll width with the client height.
1.0.0-next.0
Major Changes
Fork
svelte-dnd-action0.9.80 as@lukez/svelte-dnd. The package now ships ESM and CommonJS builds fromdistonly (thesveltefield and rawsrcentry are gone) and is moving to a breaking Svelte 5 rewrite. Expect API changes betweennextprereleases.Rewrite the public API for Svelte 5. See MIGRATING.md for the steps.
- The action became an attachment factory that takes an options getter:
use:dndzone={options}is now{@attach dndzone(() => options)}. The same applies todragHandleZone. - The
considerandfinalizeDOM events became theonconsiderandonfinalizeoptions. They receive the event directly, soe.detail.itemsis nowe.items. - The global setters
setAriaStrings,setKeyboardDragTrigger,setDebugModeandoverrideItemIdKeyNameBeforeInitialisingDndZonesbecameconfigure({ ariaStrings, keyboardDragTrigger, debug, idKey }). setFeatureFlagandFEATURE_FLAG_NAMESbecame the per-zoneuseComputedStyleForRectsoption.- Drag handles are attachments:
{@attach dragHandle}inside adragHandleZone.dragDisabledapplies to that zone's handles only. - Types: the public generics take
T extends object, so interfaces work as item types, andtransformDraggedElementreceives the zone's item type.DndEventInfotakes the item type, andinfo.idis inferred from the item'sidfield (unknownfor items without one, as with a customidKey) instead of typedstring.ItemisRecord<string, unknown>instead ofRecord<string, any>, so code that leaves the item type out, such as(e: DndEvent) => e.items[0].name, no longer compiles: pass the item type.DndZoneAttributesis removed. - Requires
svelte^5.32.
- The action became an attachment factory that takes an options getter:
Patch Changes
configurenow checks every key and value before applying any, so a call that throws no longer leaves some settings changed.A zone created on an element during the drop animation of a drag from the previous zone on it no longer receives that drag's finalize event or loses its registration when the drop ends.
A handle zone created again on the same element now takes over the handles of the zone it replaces.
info.idis inferred from an optionalidfield too.A zone nested in an element marked with the shadow item hint is now set up once the hint is removed. Before, the dropped item's nested zone stayed dead after the drop (#7).
A zone created with a different
typeon an element during the drop animation of a drag from the previous zone on it no longer leaves the old type registered, which keptconfigure({ idKey })throwing and broke the next drag of that type.