Détail du package

@scalar/draggable

scalar184.2kMIT0.2.0

A simple vue wrapper around html drag and drop

vue drag and drop draggable html

readme

Scalar Draggable component

Version Downloads License Discord

Installation

npm install @scalar/draggable

Usage

A complete example can be found the playground, but basically you need a data structure like:

const sidebar = ref({
  // Master list of all items
  items: {
    '1': {
      id: '1',
      name: 'Rangers',
      children: ['2', '4', '5', '6', '7'],
    },
    '2': {
      id: '2',
      name: 'Stars',
      children: ['3'],
    },
    '3': { id: '3', name: 'Bruins', children: [] },
    '4': { id: '4', name: 'Canucks', children: [] },
    '5': { id: '5', name: 'Panthers', children: [] },
    '6': { id: '6', name: 'Avalanche', children: [] },
    '7': { id: '7', name: 'Hurricanes', children: [] },
    '8': { id: '8', name: 'Jets', children: [] },
    '9': { id: '9', name: 'Oilers', children: [] },
    '10': { id: '10', name: 'Predators', children: [] },
    '11': { id: '11', name: 'Maple Leafs', children: [] },
    '12': { id: '12', name: 'Kings', children: [] },
  } satisfies Items,
  // Root level children (the top level of the sidebar)
  children: ['1', '8', '9', '10', '11', '12'],
})

Then you will need a recursive component that wraps Draggable like:

<template>
  <Draggable
    :id="id"
    :ceiling="0.8"
    :floor="0.2"
    :height="30"
    :parentIds="[...parentIds, id]">
    <div
      class="sidebar-item"
      :class="{ 'sidebar-folder': items[id].children.length }">
      {{ items[id].name }}
      <SidebarItem
        v-for="childId in items[id].children"
        :id="childId"
        :key="childId"
        :items="items"
        :parentIds="[...parentIds, id]" />
    </div>
  </Draggable>
</template>

Then manage the data manipluation on drop using the emitted events!

Example

You can find an example in this repo under the playground

changelog

@scalar/draggable

0.2.0

Minor Changes

  • 483ca93: chore: require Node 20 (or above)

0.1.11

Patch Changes

  • c10bbf5: chore: code style

0.1.10

Patch Changes

  • fa6afe8: chore: code formatting

0.1.9

Patch Changes

  • f500435: chore: stricter TypeScript configuration
  • 34e6f52: feat: upgrade to stricter tsconfig

0.1.8

Patch Changes

  • 90529fc: chore: upgrade to react 19

0.1.7

Patch Changes

  • a40999d: chore: added type safety rule noUncheckedIndexedAccess

0.1.6

Patch Changes

  • 0c34a18: chore: updated vue package to 3.5

0.1.5

Patch Changes

  • e9253af: fix(api-client): scope api client draggable styles

0.1.4

Patch Changes

  • dfa7434: feat(api-client): added drag and drop to the api client

0.1.3

Patch Changes

  • 94e68ab: chore: upgrade typescript to 5.5

0.1.2

Patch Changes

  • a2cb3c3: Migrate away from unintended peer dependencies

0.1.1

Patch Changes

  • e0fc110: chore: patch bump all package

0.1.0

Minor Changes

  • 7f8ef74: chore: remove aliasing

Patch Changes

  • 6fbb57e: feat: release all the packages

0.0.7

Patch Changes

  • 453b297: fix: drag and dropping of draggable

0.0.6

Patch Changes

  • b5a3f7e: feat: added a few props to draggable and exported prop types

0.0.5

Patch Changes

  • 45dc04b: fix: can’t release packages

0.0.4

Patch Changes

  • f0cc812: chore: update exports for draggable and add jsdoc types
  • 05e2e27: chore: add provenance statement
  • bf430f6: fix: export draggable types

0.0.3

Patch Changes

  • 07211ad: chore: added new lint rule for type importing for better perf

0.0.2

Patch Changes

  • fbaaf20: feat: added draggable package