0.1.64 • Published 10 months ago

@baronote/listcomponents v0.1.64

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

@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

KeyRequiredTypeDescDefault
columnsVArrayDefine Columns
recordsVArrayDefine Records
rowHeightNumberResize Row Height50
avatarPropsObjectCustom Avatar type Propssize : 30, round : 50%
rowIconPropsObjectCustom Icon type Propssize : 30, icons : react-icons/fa
linkPropsObjectCustom Link type Propstarget : _blank, text : value
imagePropsObjectCustom Thumbnail type Propstarget : _blank, size : 30
timeFormatStringCustom Time type PropsYYYY-MM-DD HH:mm:ss
useBackwardBooleanDisplay Backwardfalse
onBackwardFunctionCallback when backward clicked
onMoveRecordFunctionCallback when record moved
onClickRecordFunctionCallback when record clicked
onContextMenuFunctionCallback when mouse right clicked
onFileDropFunctionCallback when local file dropped

Column - Props

KeyRequiredTypeDescVaild Values
accessorVStringAccess to Record Key
classNameStringDefine className for style
typeStringResizing border widthtext, time, icon, avatar, link, checkbox, image
widthNumberDefine Column Width50, 120, 300 etc ...
useDescBooleanDisplay Desc Under name when type is texttrue, false

Record - Value by Type

Header TypeValueExample
textString'Hong Gil Dong', 'Hi, Hello', etc ...
timeDatenew Date(), moment()
iconString'folder', 'file', 'pdf', 'image', 'audio', 'loading'
avatarObject{ src : imageUrl, name : String }
linkString'http://www.google.com', etc...
checkboxBooleantrue, false
imageString'https://cdn3.iconfinder.com/data/icons/feather-5/24/download-512.png', etc...

Record - Other Props

KeyRequiredTypeDescDefault
checkedVBooleanIsCheck Rowfalse
readOnlyBooleanCss - Opacity 0.5false

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,
    },
  ],
  []
);

Sample Image

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