UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

32 lines 971 B
import React from 'react'; import createClass from 'create-react-class'; import { DraggableList } from '../../../index'; export default createClass({ getInitialState: function getInitialState() { return { items: ['Item One', 'Item Two', 'Item Three', 'Item Four', 'Item Five'] }; }, handleDrop: function handleDrop(_ref) { var oldIndex = _ref.oldIndex, newIndex = _ref.newIndex; var items = this.state.items; var updatedItems = items.filter(function (column, index) { return index !== oldIndex; }); updatedItems.splice(newIndex, 0, items[oldIndex]); this.setState({ items: updatedItems }); }, render: function render() { var items = this.state.items; return /*#__PURE__*/React.createElement(DraggableList, { onDrop: this.handleDrop }, items.map(function (text) { return /*#__PURE__*/React.createElement(DraggableList.Item, { key: text }, text); })); } });