Socket
Socket
Sign inDemoInstall

dndlist

Package Overview
Dependencies
263
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dndlist

drag and drop list


Version published
Maintainers
1
Created

Readme

Source

Drag and Drop in list component

How to use

/// main.ts
import { createApp } from 'vue'
import App from './App.vue'
import dndlist from 'dndlist'
import 'dndlist/lib/style.css'

const app = createApp(App)
app.use(dndlist)
...
/// foo.vue
<template>
  <DNDList :list="testList" item-id="id" v-slot="{item}" @change="change" ref="listRef">
    <div>
      <div>{{ item.name }}</div>
      <div>{{ item.age + ' ' +item.id }}</div>
    </div>
  </DNDList>
</template>

<script lang='ts' setup>
  const testList = ref([
    {id:...,
    name,
    age},
    ...
  ])

  const listRef = ref(null)

  function change(list) {
    console.log(list)
  }

  function cancelChange() {
    listRef.restore()
  }
</script>

Props and others in DNDList component

  • list: The target list you want to render in row flex display
  • item-id: The unique id key of the list item obj, if the list is just a string[], you can keep item-id=''
  • wrap-class: The css class you want use on the flex wrap
  • direction: the flex-direction. can be 'row' or 'column'
  • @change: The drop event will emit with param of the updated list
  • method restore: The component expose a method restore to cancel the update about the list
  • You need render the item in your own way by the default slot. please refer the example in How to use

Notice

  • Recommand to render the slot item with fixed width & height, or the position maybe change not by your expectation.

Keywords

FAQs

Last updated on 24 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc