@asup/tree-of-nodes 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/{cjs/src/__mocks__ → __mocks__}/mockNodes.d.ts +0 -0
- package/dist/{cjs/src/__mocks__ → __mocks__}/styleMock.d.ts +0 -0
- package/dist/{cjs/src/__tests__/TreeNode.test.d.ts → __tests__/ContextMenu.d.ts} +0 -0
- package/dist/{cjs/src/__tests__/TreeOfNodes.test.d.ts → __tests__/ContextMenu.test.d.ts} +0 -0
- package/dist/{src/__tests__ → __tests__}/TreeNode.test.d.ts +0 -0
- package/dist/{src/__tests__ → __tests__}/TreeOfNodes.test.d.ts +0 -0
- package/dist/{cjs/src/__tests__ → __tests__}/WordEntry.test.d.ts +0 -0
- package/dist/{src → cjs}/__mocks__/mockNodes.d.ts +0 -0
- package/dist/{src → cjs}/__mocks__/styleMock.d.ts +0 -0
- package/dist/{src/__tests__/WordEntry.test.d.ts → cjs/__tests__/ContextMenu.d.ts} +0 -0
- package/dist/cjs/__tests__/ContextMenu.test.d.ts +1 -0
- package/dist/cjs/__tests__/TreeNode.test.d.ts +1 -0
- package/dist/cjs/__tests__/TreeOfNodes.test.d.ts +1 -0
- package/dist/cjs/__tests__/WordEntry.test.d.ts +1 -0
- package/dist/cjs/{src/components → components}/ContextMenu.d.ts +0 -0
- package/dist/cjs/{src/components → components}/ContextMenuProvider.d.ts +0 -0
- package/dist/cjs/{src/components → components}/TreeNode.d.ts +0 -0
- package/dist/cjs/{src/components → components}/TreeOfNodes.d.ts +0 -0
- package/dist/{src → cjs}/components/TreeOfNodesContext.d.ts +6 -6
- package/dist/cjs/{src/components → components}/WordEntry.d.ts +0 -0
- package/dist/cjs/{src/components → components}/index.d.ts +2 -2
- package/dist/cjs/{src/main.d.ts → main.d.ts} +0 -0
- package/dist/cjs/main.js +13 -13
- package/dist/{src/components → components}/ContextMenu.d.ts +0 -0
- package/dist/{src/components → components}/ContextMenuProvider.d.ts +0 -0
- package/dist/{src/components → components}/TreeNode.d.ts +0 -0
- package/dist/{src/components → components}/TreeOfNodes.d.ts +0 -0
- package/dist/{cjs/src/components → components}/TreeOfNodesContext.d.ts +6 -6
- package/dist/{src/components → components}/WordEntry.d.ts +0 -0
- package/dist/{src/components → components}/index.d.ts +2 -2
- package/dist/{src/main.d.ts → main.d.ts} +0 -0
- package/dist/tree-of-nodes.d.ts +87 -30
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
[![npm][npm]][npm-url]
|
|
7
7
|
[![size][size]][size-url]
|
|
8
|
-

|
|
9
9
|
[](https://raw.githubusercontent.com/PaulDThomas/tree-of-nodes/master/LICENCE)
|
|
10
10
|
|
|
11
11
|
# @asup/tree-of-notes
|
|
@@ -98,7 +98,7 @@ export interface iNodeUpdate {
|
|
|
98
98
|
Inbuilt context menu provider, takes a list of available actions and renders a context menu on appropriate click.
|
|
99
99
|
|
|
100
100
|
```
|
|
101
|
-
import { ContextMenuProvider, iMenuItem } from '@asup/tree-of-nodes';
|
|
101
|
+
import { ContextMenuProvider, iMenuItem, MenuContext } from '@asup/tree-of-nodes';
|
|
102
102
|
import '@asup/tree-of-nodes/dist/style.css';
|
|
103
103
|
|
|
104
104
|
... inside REACT component
|
|
@@ -107,8 +107,7 @@ import '@asup/tree-of-nodes/dist/style.css';
|
|
|
107
107
|
|
|
108
108
|
<SomeChild
|
|
109
109
|
|
|
110
|
-
const showMenu ()
|
|
111
|
-
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
110
|
+
const showMenu = useCallback((e) => {
|
|
112
111
|
e.preventDefault();
|
|
113
112
|
e.stopPropagation();
|
|
114
113
|
const menuItems: iMenuItem[] = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,18 +3,18 @@ export interface iNodeUpdate {
|
|
|
3
3
|
success: boolean;
|
|
4
4
|
ErrorText?: string;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export interface TreeNodeBase {
|
|
7
7
|
id: Key;
|
|
8
8
|
label: string;
|
|
9
9
|
parentId?: Key;
|
|
10
|
-
}
|
|
11
|
-
export
|
|
10
|
+
}
|
|
11
|
+
export interface TreeNodeData<T> {
|
|
12
12
|
id: Key;
|
|
13
13
|
label: string;
|
|
14
14
|
parentId?: Key;
|
|
15
15
|
data: T;
|
|
16
|
-
}
|
|
17
|
-
export
|
|
16
|
+
}
|
|
17
|
+
export interface TreeOfNodesContextData<T> {
|
|
18
18
|
id: string;
|
|
19
19
|
nodeList: TreeNodeData<T>[];
|
|
20
20
|
selectedId?: Key;
|
|
@@ -24,5 +24,5 @@ export type TreeOfNodesContextData<T> = {
|
|
|
24
24
|
onAddChild?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;
|
|
25
25
|
onRename?: (id: Key, newName: string) => Promise<iNodeUpdate>;
|
|
26
26
|
onRemove?: (id: Key) => Promise<iNodeUpdate>;
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
export declare const TreeOfNodesContext: import("react").Context<TreeOfNodesContextData<unknown>>;
|
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ContextMenu } from './ContextMenu';
|
|
2
|
-
import { ContextMenuProvider } from './ContextMenuProvider';
|
|
2
|
+
import { ContextMenuProvider, iMenuItem, MenuContext } from './ContextMenuProvider';
|
|
3
3
|
import { TreeNode } from './TreeNode';
|
|
4
4
|
import { TreeOfNodes } from './TreeOfNodes';
|
|
5
5
|
import { iNodeUpdate, TreeNodeBase, TreeNodeData } from './TreeOfNodesContext';
|
|
6
6
|
import { WordEntry } from './WordEntry';
|
|
7
7
|
export { ContextMenu, ContextMenuProvider, TreeNode, TreeOfNodes, WordEntry };
|
|
8
|
-
export type { TreeNodeBase, TreeNodeData, iNodeUpdate };
|
|
8
|
+
export type { TreeNodeBase, TreeNodeData, iNodeUpdate, iMenuItem, MenuContext };
|
|
File without changes
|
package/dist/cjs/main.js
CHANGED
|
@@ -4,20 +4,20 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
|
|
6
6
|
function _interopNamespaceDefault(e) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
15
17
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
n.default = e;
|
|
20
|
-
return Object.freeze(n);
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,18 +3,18 @@ export interface iNodeUpdate {
|
|
|
3
3
|
success: boolean;
|
|
4
4
|
ErrorText?: string;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export interface TreeNodeBase {
|
|
7
7
|
id: Key;
|
|
8
8
|
label: string;
|
|
9
9
|
parentId?: Key;
|
|
10
|
-
}
|
|
11
|
-
export
|
|
10
|
+
}
|
|
11
|
+
export interface TreeNodeData<T> {
|
|
12
12
|
id: Key;
|
|
13
13
|
label: string;
|
|
14
14
|
parentId?: Key;
|
|
15
15
|
data: T;
|
|
16
|
-
}
|
|
17
|
-
export
|
|
16
|
+
}
|
|
17
|
+
export interface TreeOfNodesContextData<T> {
|
|
18
18
|
id: string;
|
|
19
19
|
nodeList: TreeNodeData<T>[];
|
|
20
20
|
selectedId?: Key;
|
|
@@ -24,5 +24,5 @@ export type TreeOfNodesContextData<T> = {
|
|
|
24
24
|
onAddChild?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;
|
|
25
25
|
onRename?: (id: Key, newName: string) => Promise<iNodeUpdate>;
|
|
26
26
|
onRemove?: (id: Key) => Promise<iNodeUpdate>;
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
export declare const TreeOfNodesContext: import("react").Context<TreeOfNodesContextData<unknown>>;
|
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ContextMenu } from './ContextMenu';
|
|
2
|
-
import { ContextMenuProvider } from './ContextMenuProvider';
|
|
2
|
+
import { ContextMenuProvider, iMenuItem, MenuContext } from './ContextMenuProvider';
|
|
3
3
|
import { TreeNode } from './TreeNode';
|
|
4
4
|
import { TreeOfNodes } from './TreeOfNodes';
|
|
5
5
|
import { iNodeUpdate, TreeNodeBase, TreeNodeData } from './TreeOfNodesContext';
|
|
6
6
|
import { WordEntry } from './WordEntry';
|
|
7
7
|
export { ContextMenu, ContextMenuProvider, TreeNode, TreeOfNodes, WordEntry };
|
|
8
|
-
export type { TreeNodeBase, TreeNodeData, iNodeUpdate };
|
|
8
|
+
export type { TreeNodeBase, TreeNodeData, iNodeUpdate, iMenuItem, MenuContext };
|
|
File without changes
|
package/dist/tree-of-nodes.d.ts
CHANGED
|
@@ -1,32 +1,89 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { Key } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}): any;
|
|
30
|
-
declare const WordEntry: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
3
|
+
interface iContextMenuSettings {
|
|
4
|
+
visible?: boolean;
|
|
5
|
+
x?: number;
|
|
6
|
+
y?: number;
|
|
7
|
+
set?: (ret: {
|
|
8
|
+
visible?: boolean;
|
|
9
|
+
x?: number;
|
|
10
|
+
y?: number;
|
|
11
|
+
menuItems?: iMenuItem[];
|
|
12
|
+
}) => void;
|
|
13
|
+
}
|
|
14
|
+
interface contextMenuProps {
|
|
15
|
+
entries: iMenuItem[];
|
|
16
|
+
visible: boolean;
|
|
17
|
+
xPos: number;
|
|
18
|
+
yPos: number;
|
|
19
|
+
}
|
|
20
|
+
interface iMenuItem {
|
|
21
|
+
label?: string;
|
|
22
|
+
action?: () => void;
|
|
23
|
+
}
|
|
24
|
+
declare const MenuContext: React.Context<iContextMenuSettings>;
|
|
25
|
+
interface iContextMenuProvider {
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
declare const ContextMenuProvider: ({ children }: iContextMenuProvider) => JSX.Element;
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
declare const ContextMenu: React.ForwardRefExoticComponent<contextMenuProps & React.RefAttributes<HTMLDivElement>>;
|
|
31
|
+
|
|
32
|
+
interface TreeNodeProps {
|
|
33
|
+
id: Key;
|
|
34
|
+
indentLevel?: number;
|
|
35
|
+
canRemove?: boolean;
|
|
36
|
+
canRename?: boolean;
|
|
37
|
+
canAddChildren?: boolean;
|
|
38
|
+
canRemoveChildren?: boolean;
|
|
39
|
+
canRenameChildren?: boolean;
|
|
40
|
+
refresh?: () => void;
|
|
41
|
+
}
|
|
42
|
+
declare const TreeNode: ({ id, canRemove, canRename, canAddChildren, canRemoveChildren, canRenameChildren, }: TreeNodeProps) => JSX.Element;
|
|
43
|
+
|
|
44
|
+
interface iNodeUpdate {
|
|
45
|
+
success: boolean;
|
|
46
|
+
ErrorText?: string;
|
|
47
|
+
}
|
|
48
|
+
interface TreeNodeBase {
|
|
49
|
+
id: Key;
|
|
50
|
+
label: string;
|
|
51
|
+
parentId?: Key;
|
|
52
|
+
}
|
|
53
|
+
interface TreeNodeData<T> {
|
|
54
|
+
id: Key;
|
|
55
|
+
label: string;
|
|
56
|
+
parentId?: Key;
|
|
57
|
+
data: T;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface iTreeOfNodes<T> {
|
|
61
|
+
id: string;
|
|
62
|
+
nodeList: TreeNodeData<T>[];
|
|
63
|
+
roots: Key[];
|
|
64
|
+
selectedId?: Key;
|
|
65
|
+
handleSelect?: (ret: Key) => void;
|
|
66
|
+
onAdd?: (parentId: Key, newName: string) => Promise<iNodeUpdate>;
|
|
67
|
+
onRename?: (childId: Key, newName: string) => Promise<iNodeUpdate>;
|
|
68
|
+
onRemove?: (childId: Key) => Promise<iNodeUpdate>;
|
|
69
|
+
canAddRoot?: boolean;
|
|
70
|
+
canRemoveRoot?: boolean;
|
|
71
|
+
canRenameRoot?: boolean;
|
|
72
|
+
canAddChildren?: boolean;
|
|
73
|
+
canRemoveChildren?: boolean;
|
|
74
|
+
canRenameChildren?: boolean;
|
|
75
|
+
}
|
|
76
|
+
declare const TreeOfNodes: <T extends unknown>({ id, nodeList, roots, canRemoveRoot, canRenameRoot, canAddChildren, canRemoveChildren, canRenameChildren, selectedId, handleSelect, onAdd, onRename, onRemove, }: iTreeOfNodes<T>) => JSX.Element;
|
|
77
|
+
|
|
78
|
+
interface WordEntryProps {
|
|
79
|
+
id: Key;
|
|
80
|
+
value?: string;
|
|
81
|
+
editing?: boolean;
|
|
82
|
+
saving?: boolean;
|
|
83
|
+
setValue?: (ret: string) => void;
|
|
84
|
+
sendEscape?: () => void;
|
|
85
|
+
style?: React.CSSProperties;
|
|
86
|
+
}
|
|
87
|
+
declare const WordEntry: React.ForwardRefExoticComponent<WordEntryProps & React.RefAttributes<HTMLInputElement>>;
|
|
88
|
+
|
|
89
|
+
export { ContextMenu, ContextMenuProvider, MenuContext, TreeNode, TreeNodeBase, TreeNodeData, TreeOfNodes, WordEntry, iMenuItem, iNodeUpdate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asup/tree-of-nodes",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "REACT Typescript Treeview component",
|
|
5
5
|
"author": "Paul Thomas <@PaulDThomas>",
|
|
6
6
|
"private": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
52
52
|
"husky": "^8.0.1",
|
|
53
53
|
"jest": "^29.2.2",
|
|
54
|
-
"jest-environment-jsdom": "^29.3.
|
|
54
|
+
"jest-environment-jsdom": "^29.3.1",
|
|
55
55
|
"lint-staged": "^13.0.3",
|
|
56
56
|
"parcel": "^2.7.0",
|
|
57
57
|
"postcss": "^8.4.18",
|
|
@@ -62,10 +62,8 @@
|
|
|
62
62
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
63
63
|
"rollup-plugin-postcss": "^4.0.2",
|
|
64
64
|
"rollup-plugin-terser": "^7.0.2",
|
|
65
|
-
"rollup-plugin-typescript2": "^0.34.1",
|
|
66
65
|
"ts-jest": "^29.0.3",
|
|
67
66
|
"ts-node": "^10.9.1",
|
|
68
|
-
"tslib": "^2.4.1",
|
|
69
67
|
"typescript": "^4.9.3"
|
|
70
68
|
},
|
|
71
69
|
"lint-staged": {
|