Gathering detailed insights and metrics for react-sortable-pane
Gathering detailed insights and metrics for react-sortable-pane
Gathering detailed insights and metrics for react-sortable-pane
Gathering detailed insights and metrics for react-sortable-pane
@jonnyopenear/react-sortable-pane
<p align="center"><img src ="https://github.com/bokuweb/react-sortable-pane/blob/master/logo.png?raw=true" /></p>
@types/react-sortable-pane
Stub TypeScript definitions entry for react-sortable-pane, which provides its own types definitions
@joshcaplin/wasp
Wicked Awesome Sortable Panel - React component for drag & drop functionality
npm install react-sortable-pane
Typescript
Module System
Min. Node Version
Node Version
NPM Version
Total Downloads
342,574
Last Day
3
Last Week
314
Last Month
1,917
Last Year
27,820
Minified
Minified + Gzipped
Latest Version
1.1.0
Package Id
react-sortable-pane@1.1.0
Unpacked Size
83.19 kB
Size
12.70 kB
File Count
11
NPM Version
6.4.1
Node Version
10.14.2
Cumulative downloads
Total Downloads
Last Day
200%
3
Compared to previous day
Last Week
-21.9%
314
Compared to previous week
Last Month
-12.3%
1,917
Compared to previous month
Last Year
-8.1%
27,820
Compared to previous year
33
Sortable and resizable pane component for react.
1npm i react-sortable-pane
or
1yarn add react-sortable-pane
If you need not to control SortablePane
state, please use defaultSize
and defaultOrder
.
1import * as React from 'react'; 2import { SortablePane, Pane } from 'react-sortable-pane'; 3 4export default function SimpleUncontrolledExample() { 5 const panes = [0, 1, 2].map(key => ( 6 <Pane key={key} defaultSize={{ width: '100%', height: 120 }}> 7 00{key} 8 </Pane> 9 )); 10 return ( 11 <div> 12 <SortablePane direction="vertical" margin={20} defaultOrder={['0', '1', '2']}> 13 {panes} 14 </SortablePane> 15 </div> 16 ); 17}
If you need to control SortablePane
state by yourself, please use size
and order
.
1import * as React from 'react'; 2import { SortablePane, Pane } from 'react-sortable-pane'; 3 4type State = { 5 order: string[]; 6 panes: { [key: string]: { height: number } }; 7}; 8 9export default class SimpleControlledFullExample extends React.Component<{}, State> { 10 state = { 11 order: ['2', '1', '0'], 12 panes: { '0': { height: 100 }, '1': { height: 200 }, '2': { height: 300 } }, 13 }; 14 15 render() { 16 const panes = [0, 1, 2].map(key => ( 17 <Pane key={key} size={{ width: '100%', height: this.state.panes[key].height }}> 18 00{key} 19 </Pane> 20 )); 21 return ( 22 <div> 23 <SortablePane 24 direction="vertical" 25 margin={20} 26 order={this.state.order} 27 onOrderChange={order => { 28 this.setState({ order }); 29 }} 30 onResizeStop={(e, key, dir, ref, d) => { 31 this.setState({ 32 panes: { ...this.state.panes, [key]: { height: this.state.panes[key].height + d.height } }, 33 }); 34 }} 35 > 36 {panes} 37 </SortablePane> 38 </div> 39 ); 40 } 41}
Props | Required | Type | Default | Description |
---|---|---|---|---|
className | string | undefined | Specify className of component. | |
style | React.CssProperties | {} | Original style of component. | |
direction | 'horizontal' | 'vertical' | horizontal | The direction is used to set the direction of a component. | |
order | string[] | undefined | The order is used to control Pane order. If you need not to control Pane state, you can omit this property. (See also, controlled) | |
defaultOrder | string[] | undefined | The defaultOrder is used to set default Pane order. If you need to control Pane state, please use order property. (See also, uncontrolled) | |
margin | number | 0 | The margin is used to set the margin between Pane component. | |
isSortable | boolean | true | The isSortable is used to control whether panes can be dragged or not. | |
disableEffect | boolean | false | The disableEffect is used to disable floating effect. | |
dragHandleClassName | string | undefined | The dragHandleClassName is a class name of an element which should handle drag events for panes. | |
onOrderChange | (order: string[]) => void | undefined | It is called when Pane component order changed. The argument order is array of react element's key . | |
onResizeStart | (e: React.MouseEvent | React.TouchEvent, key: string, dir: PaneResizeDirection) => void | undefined | It is called when Pane component resize start. | |
onResize | (e: MouseEvent | TouchEvent, key: string, dir: PaneResizeDirection, elementRef: HTMLElement, delta: PaneSize) => void | undefined | It is called when Pane component resize. | |
onResizeStop | (e: MouseEvent | TouchEvent, key: string, dir: PaneResizeDirection, elementRef: HTMLElement, delta: PaneSize) => void | undefined | It is called when Pane component resize stop. | |
onDragStart | (e: React.MouseEvent | undefined | It is called when Pane component dragging starts. | |
onDragStop | (e: MouseEvent | TouchEvent, key: PaneKey, elementRef: HTMLElement, order: string[]) => void | undefined | It is called when Pane component dragging stop. |
Props | Required | Type | Default | Description |
---|---|---|---|---|
className | string | undefined | Specify className of component. | |
style | React.CssProperties | {} | Original style of component. | |
defaultSize | { width?: (number | string), height?: (number | string) } | auto | Specifies the width and height that the dragged item should start at. For example, you can set 300, '300px', 50%. | |
size | { width?: (number | string), height?: (number | string) } | auto | The size property is used to set the size of the component. For example, you can set 300, '300px', '50%'. | |
minWidth | number | string | 10px | The minWidth is used to set the minimum width of a Pane component. | |
minHeight | number | string | 10px | The minHeight is used to set the minimum height of a Pane component. | |
maxWidth | number | string | undefined | The maxWidth is used to set the maximum width of a Pane component. | |
maxHeight | number | string | undefined | The maxHeight is used to set the maximum height of a Pane component. | |
grid | [number, number] | [1, 1] | The maxHeight is used to set the maximum height of a Pane component. | |
resizable | { x: boolean, y: boolean, xy: boolean } | { x: true, y: true, xy: true } | The resizable is used to set the resizable permission of a component. |
flowtype
definition.TypeScript
instead of flowtype
.defaultSize
, defaultOrder
, order
, size
props to control(or uncontrol) SortablePane
state.order
property.re-resizable
instead of react-resizable-box
)grid
props.grid
props. (#93)onResizeStart
and onResizeStop
not fired.prop-types
package.user-select: none
when resizeing or moving.isSortable
props. (#34 thanks @lanVS)publised.
The MIT License (MIT)
Copyright (c) 2018 @bokuweb
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
No security vulnerabilities found.