react-accessible-treeview
Advanced tools
Comparing version 2.9.1 to 2.10.0
import React from "react"; | ||
import { ITreeViewState, TreeViewAction } from "./reducer"; | ||
import { ClickActions, INode, INodeRendererProps, NodeAction, NodeId } from "./types"; | ||
import { IFlatMetadata } from "./utils"; | ||
export interface ITreeViewOnSelectProps { | ||
@@ -35,5 +36,5 @@ element: INode; | ||
} | ||
export interface ITreeViewProps { | ||
export interface ITreeViewProps<M extends IFlatMetadata = IFlatMetadata> { | ||
/** Tree data*/ | ||
data: INode[]; | ||
data: INode<M>[]; | ||
/** Function called when a node changes its selected state */ | ||
@@ -50,3 +51,3 @@ onSelect?: (props: ITreeViewOnSelectProps) => void; | ||
/** Render prop for the node */ | ||
nodeRenderer: (props: INodeRendererProps) => React.ReactNode; | ||
nodeRenderer: (props: INodeRendererProps<M>) => React.ReactNode; | ||
/** Indicates what action will be performed on a node which informs the correct aria-* properties to use on the node (aria-checked if using checkboxes, aria-selected if not). */ | ||
@@ -86,3 +87,3 @@ nodeAction?: NodeAction; | ||
} | ||
declare const TreeView: React.ForwardRefExoticComponent<ITreeViewProps & React.RefAttributes<HTMLUListElement>>; | ||
declare const TreeView: React.ForwardRefExoticComponent<ITreeViewProps<IFlatMetadata> & React.RefAttributes<HTMLUListElement>>; | ||
export default TreeView; |
import React from "react"; | ||
import { ITreeViewState, TreeViewAction } from "./reducer"; | ||
import { ClickActions, INode, INodeRefs, INodeRendererProps, NodeAction, NodeId } from "./types"; | ||
import { IFlatMetadata } from "./utils"; | ||
import { baseClassNames } from "./constants"; | ||
export interface INodeProps { | ||
element: INode; | ||
export interface INodeProps<M extends IFlatMetadata = IFlatMetadata> { | ||
element: INode<M>; | ||
dispatch: React.Dispatch<TreeViewAction>; | ||
data: INode[]; | ||
data: INode<M>[]; | ||
nodeAction: NodeAction; | ||
@@ -20,3 +21,3 @@ selectedIds: Set<NodeId>; | ||
baseClassNames: typeof baseClassNames; | ||
nodeRenderer: (props: INodeRendererProps) => React.ReactNode; | ||
nodeRenderer: (props: INodeRendererProps<M>) => React.ReactNode; | ||
setsize: number; | ||
@@ -33,3 +34,3 @@ posinset: number; | ||
} | ||
export interface INodeGroupProps extends Omit<INodeProps, "setsize" | "posinset"> { | ||
export interface INodeGroupProps<M extends IFlatMetadata = IFlatMetadata> extends Omit<INodeProps<M>, "setsize" | "posinset"> { | ||
getClasses: (className: string) => string; | ||
@@ -41,3 +42,3 @@ /** don't send this. The NodeGroup render function, determines it for you */ | ||
} | ||
export declare const Node: (props: INodeProps) => JSX.Element; | ||
export declare const NodeGroup: ({ data, element, expandedIds, getClasses, baseClassNames, level, ...rest }: INodeGroupProps) => JSX.Element; | ||
export declare const Node: <M extends IFlatMetadata = IFlatMetadata>(props: INodeProps<M>) => JSX.Element; | ||
export declare const NodeGroup: <M extends IFlatMetadata = IFlatMetadata>({ data, element, expandedIds, getClasses, baseClassNames, level, ...rest }: INodeGroupProps<M>) => JSX.Element; |
@@ -28,5 +28,5 @@ /// <reference types="react" /> | ||
} | ||
export interface INodeRendererProps { | ||
export interface INodeRendererProps<M extends IFlatMetadata = IFlatMetadata> { | ||
/** The object that represents the rendered node */ | ||
element: INode; | ||
element: INode<M>; | ||
/** A function which gives back the props to pass to the node */ | ||
@@ -33,0 +33,0 @@ getNodeProps: (args?: { |
@@ -35,3 +35,3 @@ import { EventCallback, INode, INodeRef, NodeId } from "./types"; | ||
export type IFlatMetadata = Record<string, string | number | boolean | undefined | null>; | ||
interface ITreeNode<M extends IFlatMetadata> { | ||
interface ITreeNode<M extends IFlatMetadata = IFlatMetadata> { | ||
id?: NodeId; | ||
@@ -43,3 +43,3 @@ name: string; | ||
} | ||
export declare const flattenTree: <M extends IFlatMetadata>(tree: ITreeNode<M>) => INode<M>[]; | ||
export declare const flattenTree: <M extends IFlatMetadata = IFlatMetadata>(tree: ITreeNode<M>) => INode<M>[]; | ||
export declare const getAriaSelected: ({ isSelected, isDisabled, multiSelect, }: { | ||
@@ -63,4 +63,4 @@ isSelected: boolean; | ||
export declare const getOnSelectTreeAction: (data: INode[], elementId: NodeId, selectedIds: Set<NodeId>, disabledIds: Set<NodeId>) => "HALF_SELECT" | "TOGGLE_SELECT"; | ||
export declare const getTreeParent: (data: INode[]) => INode; | ||
export declare const getTreeNode: (data: INode[], id: NodeId) => INode; | ||
export declare const getTreeParent: <M extends IFlatMetadata = IFlatMetadata>(data: INode<M>[]) => INode<M>; | ||
export declare const getTreeNode: <M extends IFlatMetadata = IFlatMetadata>(data: INode<M>[], id: NodeId) => INode<M>; | ||
/** | ||
@@ -67,0 +67,0 @@ * We need to validate a tree data for |
{ | ||
"name": "react-accessible-treeview", | ||
"description": "A react component that implements the treeview pattern as described by the WAI-ARIA Authoring Practices.", | ||
"version": "2.9.1", | ||
"version": "2.10.0", | ||
"author": "lissitz (https://github.com/lissitz)", | ||
@@ -6,0 +6,0 @@ "main": "dist/react-accessible-treeview.cjs.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
726
101908