0.1.64 • Published 10 months ago
@baronote/listcomponents v0.1.64
@baronote/ListComponents
How To Install
# NPM
npm i @baronote/listcomponents
# Yarn
yarn add @baronote/listcomponents
Usage
import ListComponent from "@baronote/listcomponents";
...
const columns = React.useMemo(
() => [
{
accessor: "col1", // accessor is the "key" in the data
type: "checkbox", // if not define, Default text
width: 50, // if not define, Default 150
},
{
accessor: "col2", // accessor is the "key" in the data
type: "text", // if not define, Default text
},
{
accessor: "col3",
},
],
[]
);
const records = React.useMemo(
() => [
{
col1: true,
col2: "Hello",
col3: "World",
},
{
col1: false,
col2: "안녕",
col3: "하세요",
readOnly : true // Default is False
},
],
[]
);
return (
<ListComponent columns={columns} records={records} />
);
ListComponent - Props
Key | Required | Type | Desc | Default |
---|---|---|---|---|
columns | V | Array | Define Columns | |
records | V | Array | Define Records | |
rowHeight | Number | Resize Row Height | 50 | |
avatarProps | Object | Custom Avatar type Props | size : 30, round : 50% | |
rowIconProps | Object | Custom Icon type Props | size : 30, icons : react-icons/fa | |
linkProps | Object | Custom Link type Props | target : _blank, text : value | |
imageProps | Object | Custom Thumbnail type Props | target : _blank, size : 30 | |
timeFormat | String | Custom Time type Props | YYYY-MM-DD HH:mm:ss | |
useBackward | Boolean | Display Backward | false | |
onBackward | Function | Callback when backward clicked | ||
onMoveRecord | Function | Callback when record moved | ||
onClickRecord | Function | Callback when record clicked | ||
onContextMenu | Function | Callback when mouse right clicked | ||
onFileDrop | Function | Callback when local file dropped |
Column - Props
Key | Required | Type | Desc | Vaild Values |
---|---|---|---|---|
accessor | V | String | Access to Record Key | |
className | String | Define className for style | ||
type | String | Resizing border width | text, time, icon, avatar, link, checkbox, image | |
width | Number | Define Column Width | 50, 120, 300 etc ... | |
useDesc | Boolean | Display Desc Under name when type is text | true, false |
Record - Value by Type
Header Type | Value | Example |
---|---|---|
text | String | 'Hong Gil Dong', 'Hi, Hello', etc ... |
time | Date | new Date(), moment() |
icon | String | 'folder', 'file', 'pdf', 'image', 'audio', 'loading' |
avatar | Object | { src : imageUrl, name : String } |
link | String | 'http://www.google.com', etc... |
checkbox | Boolean | true, false |
image | String | 'https://cdn3.iconfinder.com/data/icons/feather-5/24/download-512.png', etc... |
Record - Other Props
Key | Required | Type | Desc | Default |
---|---|---|---|---|
checked | V | Boolean | IsCheck Row | false |
readOnly | Boolean | Css - Opacity 0.5 | false |
Example
const columns = React.useMemo(
() => [
{
accessor: "checkbox",
type: "checkbox",
width: 50,
},
{
accessor: "title",
type: "text",
},
{
accessor: "modified",
type: "time",
},
{
accessor: "extension",
type: "icon",
width: 50,
},
{
accessor: "profile",
type: "avatar",
},
{
accessor: "link",
type: "link",
},
{
accessor: "thumbnail",
type: "image",
},
],
[]
);
const records = React.useMemo(
() => [
{
title: "Sample_1",
modified: new Date(),
extension: "folder",
profile: "Sample",
link: "https://www.google.com",
thumbnail:
"https://cdn3.iconfinder.com/data/icons/feather-5/24/download-512.png",
checked: false,
},
{
title: "Test_File",
extension: "file",
profile: "Test",
link: "https://www.naver.com",
thumbnail:
"https://cdn4.iconfinder.com/data/icons/pop-scenes/1000/navigation___explore_space_exploration_astronaut_planets_planet-512.png",
checked: false,
},
{
title: "Test_Pdf",
modified: moment(),
extension: "loading",
readOnly: true,
checked: false,
},
],
[]
);
User Custom
want to resize Row height ?
<ListComponent columns={columns} records={records} rowHeight={90} />
want to custom Icons ?
<ListComponent
columns={columns}
records={records}
iconProps={{
size: 25,
icons: {
folder:
"https://cdn3.iconfinder.com/data/icons/feather-5/24/folder-512.png",
file: <FaRegFile />,
},
}}
/>
※ You can use react-icons and image url And also can add icon key
want to custom Avatar size or round ?
<ListComponent
columns={columns}
records={records}
avatarProps={{
size: 25,
round: "20%",
}}
/>
want to custom Link property ?
<ListComponent
columns={columns}
records={records}
linkProps={{
target: "_self",
text: "Go to Link",
}}
/>
want to custom Thumbnail size ?
<ListComponent
columns={columns}
records={records}
imageProps={{
target: "_self",
size: 40,
}}
/>
want to custom Timeformat ?
<ListComponent columns={columns} records={records} timeFormat={"YY/MM/DD"} />
0.1.63
10 months ago
0.1.64
10 months ago
0.1.57
12 months ago
0.1.58
12 months ago
0.1.59
12 months ago
0.1.60
12 months ago
0.1.61
12 months ago
0.1.62
12 months ago
0.1.55
1 year ago
0.1.56
1 year ago
0.1.52
1 year ago
0.1.53
1 year ago
0.1.54
1 year ago
0.1.50
1 year ago
0.1.51
1 year ago
0.1.49
1 year ago
0.1.47
1 year ago
0.1.48
1 year ago
0.1.46
1 year ago
0.1.45
1 year ago
0.1.44
1 year ago
0.1.43
1 year ago
0.1.42
1 year ago
0.1.41
1 year ago
0.1.40
1 year ago
0.1.39
1 year ago
0.1.38
1 year ago
0.1.37
1 year ago
0.1.36
1 year ago
0.1.35
1 year ago
0.1.34
1 year ago
0.1.33
1 year ago
0.1.32
1 year ago
0.1.31
1 year ago
0.1.30
1 year ago
0.1.29
1 year ago
0.1.28
1 year ago
0.1.27
1 year ago
0.1.26
1 year ago
0.1.25
1 year ago
0.1.24
1 year ago
0.1.23
1 year ago
0.1.22
1 year ago
0.1.21
1 year ago
0.1.20
1 year ago
0.1.19
1 year ago
0.1.18
1 year ago
0.1.17
1 year ago
0.1.15
1 year ago
0.1.14
1 year ago
0.1.13
1 year ago
0.1.12
1 year ago
0.1.11
1 year ago
0.1.10
1 year ago
0.1.9
1 year ago
0.1.8
1 year ago
0.1.7
1 year ago
0.1.6
1 year ago
0.1.4
1 year ago
0.1.3
1 year ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago