0.2.0 • Published 3 years ago

svelte-pick-list v0.2.0

Weekly downloads
5
License
MIT
Repository
-
Last release
3 years ago

svelte-pick-list

Svelte component to reorder items between different lists.

API

PickList (Default)

Svelte component comprised of two lists arranged using CSS List Layout with button controls.

Props

NameTypeRequiredDefaultDescription
dataArray<Array.<{key: String, label: String, disabled: Boolean}>>false[[], []]Nested arrays of data. Each nested array should include key, label and disabled properties.
selectedKeysArray<Array>false[[], []]Nested array of selected list keys
renderFormatFunction: Stringfalse(item) => item.label || item.keyFunction for rendering item label
sortFnFunction: Arrayfalse(a, b) => a.key.localeCompare(b.key)Function for sorting items in each list
titlesArrayfalse"Available", "Selected"Array of titles/headings to render

Events

NameDescription
selectAllFired when select all is checked.
moveFired when items are move to another list.
moveAllFired when all items are move to another list.

Installation

npm install svelte-pick-list

Usage

<script>
  import PickList from "svelte-pick-list";

  let data = [
    [
      { key: "1", label: "Content 1", disabled: false },
      { key: "2", label: "Content 2", disabled: true },
      { key: "3", label: "Content 3", disabled: false },
      { key: "4", label: "Content 4", disabled: false },
    ],
    [
      { key: "5", label: "Content 5", disabled: false },
      { key: "6", label: "Content 6", disabled: true },
    ],
  ];
</script>

<PickList bind:data />

Todo

  • Allow custom components for list items
  • Allow custom components for controls
  • Allow custom styles
  • Allow custom list object data structure
  • Allow custom animation
  • Dispatch events
  • Add search functionality
  • Add re-order functionality
0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.1

3 years ago