Coder Social home page Coder Social logo

ealexandros / editable-antd-tree Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 0.0 706 KB

This is an editable tree component based on antd.

License: MIT License

Shell 0.31% JavaScript 11.39% TypeScript 87.58% CSS 0.72%
editable editable-tree-table editable-tree antd tree next react

editable-antd-tree's Introduction

editable-antd-tree-logo-light

This is an editable tree based on antd components.


node version pnpm version react version antd version


๐Ÿ“– Preview

preview

๐Ÿ“ฆ Install

$ npm editable-antd-tree

The package can be found here.

๐Ÿ”จ Usage

Below there is a demonstration of the input data.

const tree = [
  {
    key: "1",
    title: "Technology",
    isLeaf: false,
    children: [
      {
        key: "2",
        parent: "1",
        title: "Phones",
        isLeaf: false,
        children: [
          // ...
        ],
      },
      {
        key: "3",
        parent: "1",
        title: "Laptops",
        isLeaf: true,
      },
    ],
    // ...
  },
  // ...
];

A simple example of this package can be seen below.

import { EditableAntdTree } from "editable-antd-tree";

import "editable-antd-tree/dist/esm/output.css"; // load style

const initTree = []; // ๐Ÿ‘€ example above

const App = () => (
  <>
    <EditableAntdTree treeData={initTree} />
  </>
);

Typescipt

By downloading this package, there is a direct compatability with typescript.

๐Ÿ”€๏ธ Properties

Tree

Property Description Type Required
treeData Initial tree data. See section below for all fields of TreeData. EditableTreeNode[] Yes
onTreeChange Executes uppon any tree data change. Function No
switcherIcon Controls the switcher icon, used to expand or collapse parent nodes. React.ReactNode No
size Controls the size of the tree. xs, sm, md, lg, xl No
loadData Function triggered when a non-leaf TreeNode lacks children. Loads data asynchronously and replaces TreeNode's children. Function No
createRootLeaf Contains properties explained in the sections below. Object No
createRootParent Contains properties explained in the sections below. Object No
deleteNode Contains properties explained in the sections below. Object No
updateNode Contains properties explained in the sections below. Object No
createLeaf Contains properties explained in the sections below. Object No
createParent Contains properties explained in the sections below. Object No

Create Root Leaf

Property Description Type Required
caption This property shows what should be displayed when a user hovers over the action. string No
disable This property indicates if the action should be disabled. boolean No
event This property is a Function that runs after the action has been pressed. Function No

Create Root Parent

Property Description Type Required
caption This property shows what should be displayed when a user hovers over the action. string No
disable This property indicates if the action should be disabled. boolean No
event This property is a Function that runs after the action has been pressed. Function No

Delete Node

Property Description Type Required
caption This property shows what should be displayed when a user hovers over the action. string No
disable This property indicates if the action should be disabled. boolean | Function No
event This property is a Function that runs after the action has been pressed. Function No

Update Node

Property Description Type Required
caption This property shows what should be displayed when a user hovers over the action. string No
disable This property indicates if the action should be disabled. boolean | Function No
event This property is a Function that runs after the action has been pressed. Function No

Create Leaf Node

Property Description Type Required
caption This property shows what should be displayed when a user hovers over the action. string No
disable This property indicates if the action should be disabled. boolean | Function No
event This property is a Function that runs after the action has been pressed. Function No

Create Parent Node

Property Description Type Required
caption This property shows what should be displayed when a user hovers over the action. string No
disable This property indicates if the action should be disabled. boolean | Function No
event This property is a Function that runs after the action has been pressed. Function No

+ All Tree properties of antd tree component.

Tree Data

Property Description Type Required
key This field is used as a unique identifier. string Yes
title This field is displayed in the tree. string No
parent This field points to the parent key. string No
children This field contains more nested tree nodes. EditableTreeNode[] No

+ All TreeNode properties of antd tree component.

โœจ Acknowledgements

Special acknowledgements to the following packages:

๐ŸŽ™ Conclusion

After experimenting with various npm packages, none of them quite met my specific requirements. However, drawing inspiration from the packages mentioned earlier, I took it upon myself to develop a solution tailored to my needs, resulting in the creation of the editable-antd-tree package.

editable-antd-tree's People

Contributors

ealexandros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

editable-antd-tree's Issues

Warning: findDOMNode is deprecated in StrictMode

Hello! I am testing this incredible package, using next 13 when rendering the component I see the following in the console
Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of DomWrapper which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node

get treeData after changed

Hi,
I just want to ask if there is any way to get the data change value. I'm currently trying out this package since it can be helpful for my project.
Appreciate if anyone can help me!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.