npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

meinkush-react-table-hoc-draggable-columns

v1.4.2

Published

ReactTable HOC for draggable columns

Downloads

3

Readme

react-table-hoc-draggable-columns

ReactTable HOC for draggable columns

NPM JavaScript Style Guide

Higher Order Component for ReactTable to enable Draggable columns for reordering or swapping positions.

*Note: This version supports V6 of React Table.

Documentation

Install

npm install --save react-table-hoc-draggable-columns

Usage

import ReactTable from 'react-table';
import "react-table/react-table.css";
import withDraggableColumns from 'react-table-hoc-draggable-columns';
import 'react-table-hoc-draggable-columns/dist/styles.css';

const ReactTableDraggableColumns = withDraggableColumns(ReactTable);
...
render () {
  return (
    <ReactTableDraggableColumns
      draggableColumns= {{
        mode: 'reorder',
        draggable: ['firstName', 'age']
      }}
      data={data}
      columns={[
        {
          Header: 'First Name',
          accessor: 'firstName',
        },
        {
          Header: 'Last Name',
          accessor: 'lastName',
        },
        ...
        {
          Header: 'age',
          accessor: 'age',
        }
      ]}
    />
  )
}

Special Considerations

If any of your React Table columns are hidden (show: false), this HOC will automatically move those columns to the end of the list. This is to prevent hidden columns from throwing off calculating the updated column order.

ReactTable Columns Props [https://github.com/tannerlinsley/react-table/tree/v6.10.0#columns]

draggableColumns Prop

| Property | Description | Default value | Type | Required | | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ---------------- | -------- | | mode | mode to either 'reorder' the column or 'swap' column position on drop | 'reorder' | string | yes | | draggable | array of string-based column accessors or column ids (when using a custom accessor) to allow drag and drop | | array of strings | | | enableColumnWideDrag | when {true} entire column is draggable. when {false} only header text is draggable | true | bool | | | disableTableScroll | disable ReactTable horizontal/vertical scrolling when dragging a column | false | bool | | | overflow | used with disableTableScroll={true} to reset ReactTable overflow style onDragEnd event | auto | string | | | useDragImage | clone dragged column element? useful for applying a different css class. | true | bool | | | dragImageClassName | dragImageClassName only applies when useDragImage={true} | rt-dragged-item | string | | | onDragEnterClassName | when mode={'swap'} - css class applied on dragged over column | rt-drag-enter-item | string | | | onDraggedColumnChange | callback method to be notified when column order changes - signature: function(columns) | | function | | | onDropSuccess | callback method to be notified when on column drop success - signature: function(draggedColumn, targetColumn, oldIndex, newIndex, oldOffset, newOffset) | | function | | | reorderIndicatorUpClassName | additional className for reorder indicator Up | | string | | | reorderIndicatorDownClassName | additional className for reorder indicator Down | | string | |

License

MIT © patricktran