react-tree-visualizer
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -7,1 +7,2 @@ declare const _default: { | ||
export declare const Tree: () => JSX.Element; | ||
export declare const AsyncTree: () => JSX.Element; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -17,4 +36,4 @@ var t = {}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Tree = void 0; | ||
const react_1 = __importDefault(require("react")); | ||
exports.AsyncTree = exports.Tree = void 0; | ||
const react_1 = __importStar(require("react")); | ||
const styled_components_1 = __importDefault(require("styled-components")); | ||
@@ -67,2 +86,15 @@ const use_window_size_1 = __importDefault(require("../hooks/use-window-size")); | ||
exports.Tree = Tree; | ||
const AsyncTree = () => { | ||
const [tree, setTree] = react_1.useState({ | ||
data: { id: 0, ref: { current: null }, type: 0 }, | ||
children: [], | ||
}); | ||
react_1.useEffect(() => { | ||
setTimeout(() => { | ||
setTree(simple_tree_1.simpleTree); | ||
}, 300); | ||
}, []); | ||
return react_1.default.createElement(Template, { tree: tree, itemComponent: MockItemComponent }); | ||
}; | ||
exports.AsyncTree = AsyncTree; | ||
//# sourceMappingURL=general-tree.stories.js.map |
@@ -12,3 +12,3 @@ import React, { Dispatch } from 'react'; | ||
}>; | ||
export declare const useItemContext: <T>(tree: Tree<T>) => [any, React.Dispatch<any>]; | ||
export declare const useItemContext: <T>(tree: Tree<T>) => any[]; | ||
export declare const useItemHighlightContext: <T>({ currentItem, }: { | ||
@@ -15,0 +15,0 @@ currentItem: RenderItem<T>; |
@@ -24,3 +24,3 @@ "use strict"; | ||
const [, ...renderMatrix] = renderDataRaw; | ||
return react_1.useReducer((previousState, action) => { | ||
const [state, dispatch] = react_1.useReducer((previousState, action) => { | ||
var _a, _b; | ||
@@ -49,6 +49,15 @@ switch (action.type) { | ||
} | ||
case 'UPDATE_TREE': { | ||
const { newResult: renderDataRawUpdated } = treeToRenderAdapter_1.generateRenderTree(tree); | ||
const [, ...renderMatrixUpdated] = renderDataRawUpdated; | ||
return Object.assign(Object.assign({}, initialState), { renderData: renderMatrixUpdated }); | ||
} | ||
default: | ||
throw new Error(); | ||
return Object.assign(Object.assign({}, previousState), { renderData: renderMatrix }); | ||
} | ||
}, Object.assign(Object.assign({}, initialState), { renderData: renderMatrix })); | ||
react_1.useEffect(() => { | ||
dispatch({ type: 'UPDATE_TREE', payload: tree }); | ||
}, [tree]); | ||
return [state, dispatch]; | ||
}; | ||
@@ -55,0 +64,0 @@ exports.useItemContext = useItemContext; |
{ | ||
"name": "react-tree-visualizer", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "A react component library for visualizing tree data structures", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
127154
1523