JSPM

  • Created
  • Published
  • Downloads 65504
  • Score
    100M100P100Q150558F
  • License MIT

Package Exports

  • treemate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (treemate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

treemate · Coverage Status

Help people who want to write a tree component.

TODO

  • checked keys & indeterminate keys
  • basic test
  • lint
  • check action & uncheck action
    • full test
    • batch check & batch uncheck
      • feature
      • API cleaning
      • test
    • functional disabled prop
  • async patches support non-complete-data
    • support check & uncheck action on partial complete tree
      • implemented
      • well tested
    • throw error on non-complete tree
  • getIsGroup

API

function createTreeMate(nodes: RawNode[], options: TreeMateOptions): TreeMate

export interface TreeMateOptions {
  getDisabled?: (node: RawNode) => boolean
  getKey?: (node: RawNode) => Key
}

export interface TreeMateInstance {
  treeNodes: TreeNode[]
  treeNodeMap: TreeNodeMap
  levelTreeNodeMap: LevelTreeNodeMap
  flattenedNodes: TreeNode[]
  getNode: KeyToNode
  getCheckedKeys: (
    checkedKeys: Key[] | InputMergedKeys | null | undefined,
    options?: CheckOptions
  ) => MergedKeys
  check: (
    keysToCheck: Key | Key[] | null | undefined,
    checkedKeys: Key[] | InputMergedKeys,
    options?: CheckOptions
  ) => MergedKeys
  uncheck: (
    keysToUncheck: Key | Key[] | null | undefined,
    checkedKeys: Key[] | InputMergedKeys,
    options?: CheckOptions
  ) => MergedKeys
  getPath: (key: Key, options?: GetPathOptions) => MergedPath
  getFirstAvailableNode: () => TreeNode | null
  getPrev: KeyToNode
  getNext: KeyToNode
  getParent: KeyToNode
  getChild: KeyToNode
}

interface CheckOptions {
  cascade: boolean
  leafOnly: boolean
}

interface MergedKeys {
  checkedKeys: Key[],
  indeterminateKeys: Key[]
}

interface TreeNode {
  key: Key
  rawNode: RawNode
  level: number
  index: number
  fIndex: number
  isFirstChild: boolean
  isLastChild: boolean
  parent: TreeNode | null
  isLeaf: boolean
  isGroup: boolean
  isShallowLoaded: boolean
  disabled: boolean
  siblings: TreeNode[]
  children?: TreeNode[]
  getPrev: (options?: GetPrevNextOptions) => TreeNode | null
  getNext: (options?: GetPrevNextOptions) => TreeNode | null
  getParent: () => TreeNode | null
  getChild: () => TreeNode | null
}