Sha256: 454091dd8077ae746601ae0ac87778cd187fbec54bda869c9a4ad98e5bd71c1f

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

import React, { useState } from "react";
import { SelectableList, Draggable, DraggableProvider } from "../../";

// Initial items to be dragged
const data = [
  {
    id: "1",
    text: "Task 1",
  },
  {
    id: "2",
    text: "Task 2",
  },
  {
    id: "3",
    text: "Task 3",
  },
  {
    id: "4",
    text: "Task 4",
  },
];

const DraggableDefault = (props) => {
  const [initialState, setInitialState] = useState(data);

  return (
    <>
    <DraggableProvider initialItems={data}
        onChange={(items) => setInitialState(items)}
    >
        <Draggable.Container {...props}>
          <SelectableList variant="checkbox">
            {initialState.map(({ id, text }) => (
              <Draggable.Item id={id} 
                  key={id}
              >
                <SelectableList.Item
                    label={text} 
                    name={id} 
                    value={id} 
                />
              </Draggable.Item>
            ))}
          </SelectableList>
        </Draggable.Container>
    </DraggableProvider>
    </>

  );
};

export default DraggableDefault;

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
playbook_ui_docs-13.29.0.pre.alpha.removeduplicatekitexampleclass3063 app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx
playbook_ui-13.29.0.pre.alpha.removeduplicatekitexampleclass3063 app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx
playbook_ui_docs-13.29.0.pre.alpha.testingcollapsibleissue3052 app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx
playbook_ui-13.29.0.pre.alpha.testingcollapsibleissue3052 app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx
playbook_ui-13.29.0 app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx