How to use the react-sortable-tree.addNodeUnderParent function in react-sortable-tree

To help you get started, we’ve selected a few react-sortable-tree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nubuck / z1-app-starter / web / src / features / screen-cmd / views / view-editor / main.js View on Github external
onClick={() =>
                          mutations.dataChange({
                            data: addNodeUnderParent({
                              treeData: state.data,
                              parentKey: path[path.length - 1],
                              expandParent: true,
                              getNodeKey,
                              newNode: {
                                title: '',
                              },
                              // addAsFirstChild: state.addAsFirstChild,
                            }).treeData,
                          })
                        }
github virena-app / virena / src / reducer / compReducer.js View on Github external
return {
        ...state,
        components: removeNodeAtPath({
          treeData: state.components,
          path,
          getNodeKey: key
        })
    }

    case types.ADD_CHILD:
    const copy = Object.assign({}, state)
      const key1 = action.payload.key;
      const path1 = action.payload.path;
      return {
        ...state,
        components: addNodeUnderParent({
          treeData: copy.components,
          parentKey: path1[path1.length - 1],
          expandParent: true,
          getNodeKey: key1,
          newNode: action.payload,
          addAsFirstChild: copy.addAsFirstChild,
        }).treeData,
    }
    case types.SELECT_COMPONENT:
      const key2 = action.payload.key;
      const path2 = action.payload.path;
      const title2 = action.payload.title;
      state.selectedComponent = [];
      state.selectedComponent.push({ title: title2, path: path2, key: key2 });
      const selectedComponent = state.selectedComponent;
      return {
github CLOSER-Cohorts / archivist / react / src / pages / InstrumentConstructBuild.js View on Github external
onClick={(event) => {
                  setTreeData(addNodeUnderParent({
                    treeData: treeData,
                    parentKey: path[path.length - 1],
                    expandParent: true,
                    getNodeKey,
                    newNode: {
                      title: `Click to select construct type`,
                      children: []
                    }
                  }).treeData)
                  event.stopPropagation()
                  setSelectedNode({node: { type: undefined }})
              }}
            >
github virena-app / virena / src / reducers / componentReducer.js View on Github external
headerStatus: false
      }
      copy.treeData.push(parent)
      const copyid = copy.id + 1;
    return {
      ...state,
      treeData: copy.treeData,
      input: '',
      id: copyid,
      selectedComponent: parent,
      headerStatus: false
    }
    case types.ADD_CHILD:
      const key1 = action.payload.key;
      const path1 = action.payload.path;
      const newTreeData = addNodeUnderParent({
        treeData: copy.treeData,
        parentKey: path1[path1.length - 1],
        expandParent: true,
        getNodeKey: key1,
        newNode: action.payload,
        addAsFirstChild: copy.addAsFirstChild,
      }).treeData;
      const newNode = findNewNode(copy.treeData, newTreeData);
      const isInvalidAdd = maxDepth(newTreeData) > 5
      || childrenLimitExceeded(newTreeData, "BottomTab", 5) 
      || childrenLimitExceeded(newTreeData, "Drawer", 10)

      return {
        ...state,
        treeData: isInvalidAdd ? copy.treeData : newTreeData,
        id: isInvalidAdd ? copy.id : copy.id + 1,
github CLOSER-Cohorts / archivist / react / src / components / MoveConstructSelect.js View on Github external
const moveNode = () => {
    var node = nodeToMove.node

    onChange(addNodeUnderParent({
      treeData: removeNodeAtPath({
        treeData: treeData,
        path: nodeToMove.path,
        getNodeKey
      }),
      parentKey: parentNode.path[parentNode.path.length - 1],
      expandParent: true,
      getNodeKey,
      newNode: node
    }).treeData)

    setNodeToMove(undefined)
    setParentNode(undefined)
  }
github jddunn / frame / frame / src / components / MainMenu / MainMenu.jsx View on Github external
this.setState(state => ({
        treeData: addNodeUnderParent({
          treeData: state.treeData,
          parentKey: rowInfo.path[rowInfo.path.length - 1],
          expandParent: true,
          getNodeKey: getNodeKey,
          newNode: {
            title: newChildEntryTitle,
            subtitle: newChildSubtitlePlaceholderText,
            id: uuid,
            timestampCreated: timestampNow,
            timestampLastModified: timestampNow,
            editorType: "flow",
            tags: [],
            data: {},
            dragDisabled: false
          },
          addAsFirstChild: state.addAsFirstChild,
github apjs / ReactVelocity / src / components / react-tree.js View on Github external
this.setState(state => ({
                    treeData: addNodeUnderParent({
                      treeData: state.treeData,
                      parentKey: path[path.length - 1],
                      expandParent: true,
                      getNodeKey,
                      newNode: {
                        name: '',
                      },
                    }).treeData,
                }))
              }
github dotgreg / XinDaw / imports / client / components / explorer / Explorer2.jsx View on Github external
return this.setState(state => ({
      treeData: addNodeUnderParent({
        treeData: state.treeData,
        parentKey: path[path.length - 1],
        expandParent: true,
        getNodeKey: this.getNodeKey,
        newNode: this.createNode(node),
      }).treeData,
    }))
  }