@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.
Files changed (34) hide show
  1. package/README.md +3 -4
  2. package/dist/{cjs/src/__mocks__ → __mocks__}/mockNodes.d.ts +0 -0
  3. package/dist/{cjs/src/__mocks__ → __mocks__}/styleMock.d.ts +0 -0
  4. package/dist/{cjs/src/__tests__/TreeNode.test.d.ts → __tests__/ContextMenu.d.ts} +0 -0
  5. package/dist/{cjs/src/__tests__/TreeOfNodes.test.d.ts → __tests__/ContextMenu.test.d.ts} +0 -0
  6. package/dist/{src/__tests__ → __tests__}/TreeNode.test.d.ts +0 -0
  7. package/dist/{src/__tests__ → __tests__}/TreeOfNodes.test.d.ts +0 -0
  8. package/dist/{cjs/src/__tests__ → __tests__}/WordEntry.test.d.ts +0 -0
  9. package/dist/{src → cjs}/__mocks__/mockNodes.d.ts +0 -0
  10. package/dist/{src → cjs}/__mocks__/styleMock.d.ts +0 -0
  11. package/dist/{src/__tests__/WordEntry.test.d.ts → cjs/__tests__/ContextMenu.d.ts} +0 -0
  12. package/dist/cjs/__tests__/ContextMenu.test.d.ts +1 -0
  13. package/dist/cjs/__tests__/TreeNode.test.d.ts +1 -0
  14. package/dist/cjs/__tests__/TreeOfNodes.test.d.ts +1 -0
  15. package/dist/cjs/__tests__/WordEntry.test.d.ts +1 -0
  16. package/dist/cjs/{src/components → components}/ContextMenu.d.ts +0 -0
  17. package/dist/cjs/{src/components → components}/ContextMenuProvider.d.ts +0 -0
  18. package/dist/cjs/{src/components → components}/TreeNode.d.ts +0 -0
  19. package/dist/cjs/{src/components → components}/TreeOfNodes.d.ts +0 -0
  20. package/dist/{src → cjs}/components/TreeOfNodesContext.d.ts +6 -6
  21. package/dist/cjs/{src/components → components}/WordEntry.d.ts +0 -0
  22. package/dist/cjs/{src/components → components}/index.d.ts +2 -2
  23. package/dist/cjs/{src/main.d.ts → main.d.ts} +0 -0
  24. package/dist/cjs/main.js +13 -13
  25. package/dist/{src/components → components}/ContextMenu.d.ts +0 -0
  26. package/dist/{src/components → components}/ContextMenuProvider.d.ts +0 -0
  27. package/dist/{src/components → components}/TreeNode.d.ts +0 -0
  28. package/dist/{src/components → components}/TreeOfNodes.d.ts +0 -0
  29. package/dist/{cjs/src/components → components}/TreeOfNodesContext.d.ts +6 -6
  30. package/dist/{src/components → components}/WordEntry.d.ts +0 -0
  31. package/dist/{src/components → components}/index.d.ts +2 -2
  32. package/dist/{src/main.d.ts → main.d.ts} +0 -0
  33. package/dist/tree-of-nodes.d.ts +87 -30
  34. 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
- ![npm bundle size](https://img.shields.io/bundlephobia/min/@asup/simple-table)
8
+ ![npm bundle size](https://img.shields.io/bundlephobia/min/@asup/tree-of-nodes)
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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 () = useCallback(
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
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -3,18 +3,18 @@ export interface iNodeUpdate {
3
3
  success: boolean;
4
4
  ErrorText?: string;
5
5
  }
6
- export type TreeNodeBase = {
6
+ export interface TreeNodeBase {
7
7
  id: Key;
8
8
  label: string;
9
9
  parentId?: Key;
10
- };
11
- export type TreeNodeData<T> = {
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 type TreeOfNodesContextData<T> = {
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>>;
@@ -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
- 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]; }
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);
@@ -3,18 +3,18 @@ export interface iNodeUpdate {
3
3
  success: boolean;
4
4
  ErrorText?: string;
5
5
  }
6
- export type TreeNodeBase = {
6
+ export interface TreeNodeBase {
7
7
  id: Key;
8
8
  label: string;
9
9
  parentId?: Key;
10
- };
11
- export type TreeNodeData<T> = {
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 type TreeOfNodesContextData<T> = {
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>>;
@@ -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
@@ -1,32 +1,89 @@
1
- import * as React from 'react';
1
+ import React, { Key } from 'react';
2
2
 
3
- declare const ContextMenu: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
4
- declare function ContextMenuProvider({ children }: {
5
- children: any;
6
- }): any;
7
- declare function TreeNode({ id, canRemove, canRename, canAddChildren, canRemoveChildren, canRenameChildren, }: {
8
- id: any;
9
- canRemove: any;
10
- canRename: any;
11
- canAddChildren: any;
12
- canRemoveChildren: any;
13
- canRenameChildren: any;
14
- }): any;
15
- declare function TreeOfNodes({ id, nodeList, roots, canRemoveRoot, canRenameRoot, canAddChildren, canRemoveChildren, canRenameChildren, selectedId, handleSelect, onAdd, onRename, onRemove, }: {
16
- id: any;
17
- nodeList: any;
18
- roots: any;
19
- canRemoveRoot?: boolean | undefined;
20
- canRenameRoot?: boolean | undefined;
21
- canAddChildren?: boolean | undefined;
22
- canRemoveChildren?: boolean | undefined;
23
- canRenameChildren?: boolean | undefined;
24
- selectedId: any;
25
- handleSelect?: (() => void) | undefined;
26
- onAdd: any;
27
- onRename: any;
28
- onRemove: any;
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
- export { ContextMenu, ContextMenuProvider, TreeNode, TreeOfNodes, WordEntry };
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.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.0",
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": {