@asup/tree-of-nodes 0.9.0 → 0.9.1

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 CHANGED
@@ -1,4 +1,5 @@
1
1
  # Tree of nodes for REACT
2
2
 
3
- REACT treeview, because I couldn't quite find what I wanted
4
- Works with bootstrap
3
+ REACT treeview, because I couldn't quite find what I wanted.
4
+
5
+ Works with/needs bootstrap, react-bootstrap, react-bootstrap-icons.
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
2
  import { contextMenuProps } from './ContextMenuProvider';
3
+ import './ContextMenu.css';
3
4
  export declare const ContextMenu: React.ForwardRefExoticComponent<contextMenuProps & React.RefAttributes<HTMLDivElement>>;
@@ -39,6 +39,6 @@ declare type TreeOfNodesContextData<T> = {
39
39
  onRename?: (id: Key, newName: string) => Promise<iNodeUpdate>;
40
40
  onRemove?: (id: Key) => Promise<iNodeUpdate>;
41
41
  };
42
- export declare const TreeOfNodesContext: import("react").Context<TreeOfNodesContextData<object>>;
43
- export declare const TreeOfNodes: <T extends object>({ nodeList, roots, canRemoveRoot, canRenameRoot, canAddChildren, canRemoveChildren, canRenameChildren, selectedId, handleSelect, onAdd, onRename, onRemove, }: iTreeOfNodes<T>) => JSX.Element;
42
+ export declare const TreeOfNodesContext: import("react").Context<TreeOfNodesContextData<unknown>>;
43
+ export declare const TreeOfNodes: <T extends unknown>({ nodeList, roots, canRemoveRoot, canRenameRoot, canAddChildren, canRemoveChildren, canRenameChildren, selectedId, handleSelect, onAdd, onRename, onRemove, }: iTreeOfNodes<T>) => JSX.Element;
44
44
  export {};
@@ -1,7 +1,7 @@
1
1
  import { ContextMenu } from './ContextMenu';
2
2
  import { ContextMenuProvider } from './ContextMenuProvider';
3
3
  import { TreeNode } from './TreeNode';
4
- import { iNodeUpdate, TreeNodeData, TreeOfNodes } from './TreeOfNodes';
4
+ import { iNodeUpdate, TreeNodeBase, TreeNodeData, TreeOfNodes } from './TreeOfNodes';
5
5
  import { WordEntry } from './WordEntry';
6
6
  export { ContextMenu, ContextMenuProvider, TreeNode, TreeOfNodes, WordEntry };
7
- export type { TreeNodeData, iNodeUpdate };
7
+ export type { TreeNodeBase, TreeNodeData, iNodeUpdate };
package/dist/cjs/main.js CHANGED
@@ -1566,8 +1566,8 @@ const WordEntry = React.forwardRef(({ id, value, editing, saving, setValue, send
1566
1566
  paddingRight: '3px',
1567
1567
  border: '1px',
1568
1568
  borderRadius: '3px',
1569
- ...style,
1570
1569
  display: 'inline-block',
1570
+ ...style,
1571
1571
  });
1572
1572
  }, [style]);
1573
1573
  // Simple if not editing
@@ -1679,7 +1679,7 @@ const TreeNode = ({ id, canRemove, canRename, canAddChildren, canRemoveChildren,
1679
1679
  e.stopPropagation();
1680
1680
  const menuItems = [];
1681
1681
  if (canAddChildren)
1682
- menuItems.push({ label: 'Add directory', action: addChild });
1682
+ menuItems.push({ label: 'Add', action: addChild });
1683
1683
  if (canRename)
1684
1684
  menuItems.push({ label: 'Rename', action: renameThis });
1685
1685
  if (canRemove && (childNodes === undefined || childNodes.length === 0))
@@ -1716,7 +1716,7 @@ const TreeNode = ({ id, canRemove, canRename, canAddChildren, canRemoveChildren,
1716
1716
  visibility: expanded ? 'inherit' : 'hidden',
1717
1717
  opacity: expanded ? 1 : 0,
1718
1718
  transition: 'visibility .3s, opacity .3s ease-in-out, max-height 0.3s ease-in-out',
1719
- }, children: jsxRuntime.jsx(TreeNode, { id: h.id, canRemove: canRemoveChildren, canRename: canRenameChildren, canAddChildren: canAddChildren, canRemoveChildren: canRemoveChildren, canRenameChildren: canRenameChildren }) }, h.id))) })), showNewNode && (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(WordEntry, { id: id ? `hierarchynode-new-${id}` : undefined, ref: newNameRef, editing: true, setValue: (ret) => {
1719
+ }, children: jsxRuntime.jsx(TreeNode, { id: h.id, canRemove: canRemoveChildren, canRename: canRenameChildren, canAddChildren: canAddChildren, canRemoveChildren: canRemoveChildren, canRenameChildren: canRenameChildren }) }, h.id))) })), showNewNode && (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(WordEntry, { style: { marginLeft: '14px' }, id: id ? `hierarchynode-new-${id}` : undefined, ref: newNameRef, editing: true, setValue: (ret) => {
1720
1720
  confirmNewNode(ret);
1721
1721
  }, saving: savingNewNode, sendEscape: () => {
1722
1722
  setShowNewNode(false);
@@ -0,0 +1 @@
1
+ .context-menu{background-color:#fbfdf6;border:1px solid #111418;border-radius:8px;opacity:1;position:absolute;visibility:hidden}.context-menu.visible{visibility:"inherit"}.context-menu-item{color:#111418;cursor:pointer;min-width:80px;padding:0 4px}.context-menu-item:first-child{padding-top:2px}.context-menu-item:last-child{padding-bottom:2px}.context-menu-item:hover{background-color:#fbe9e6}.context-menu-item:hover:first-child{border-radius:6px 6px 0 0}.context-menu-item:hover:last-child{border-radius:0 0 6px 6px}
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
2
  import { contextMenuProps } from './ContextMenuProvider';
3
+ import './ContextMenu.css';
3
4
  export declare const ContextMenu: React.ForwardRefExoticComponent<contextMenuProps & React.RefAttributes<HTMLDivElement>>;
@@ -39,6 +39,6 @@ declare type TreeOfNodesContextData<T> = {
39
39
  onRename?: (id: Key, newName: string) => Promise<iNodeUpdate>;
40
40
  onRemove?: (id: Key) => Promise<iNodeUpdate>;
41
41
  };
42
- export declare const TreeOfNodesContext: import("react").Context<TreeOfNodesContextData<object>>;
43
- export declare const TreeOfNodes: <T extends object>({ nodeList, roots, canRemoveRoot, canRenameRoot, canAddChildren, canRemoveChildren, canRenameChildren, selectedId, handleSelect, onAdd, onRename, onRemove, }: iTreeOfNodes<T>) => JSX.Element;
42
+ export declare const TreeOfNodesContext: import("react").Context<TreeOfNodesContextData<unknown>>;
43
+ export declare const TreeOfNodes: <T extends unknown>({ nodeList, roots, canRemoveRoot, canRenameRoot, canAddChildren, canRemoveChildren, canRenameChildren, selectedId, handleSelect, onAdd, onRename, onRemove, }: iTreeOfNodes<T>) => JSX.Element;
44
44
  export {};
@@ -1,7 +1,7 @@
1
1
  import { ContextMenu } from './ContextMenu';
2
2
  import { ContextMenuProvider } from './ContextMenuProvider';
3
3
  import { TreeNode } from './TreeNode';
4
- import { iNodeUpdate, TreeNodeData, TreeOfNodes } from './TreeOfNodes';
4
+ import { iNodeUpdate, TreeNodeBase, TreeNodeData, TreeOfNodes } from './TreeOfNodes';
5
5
  import { WordEntry } from './WordEntry';
6
6
  export { ContextMenu, ContextMenuProvider, TreeNode, TreeOfNodes, WordEntry };
7
- export type { TreeNodeData, iNodeUpdate };
7
+ export type { TreeNodeBase, TreeNodeData, iNodeUpdate };
File without changes
@@ -1546,8 +1546,8 @@ const WordEntry = React__default.forwardRef(({ id, value, editing, saving, setVa
1546
1546
  paddingRight: '3px',
1547
1547
  border: '1px',
1548
1548
  borderRadius: '3px',
1549
- ...style,
1550
1549
  display: 'inline-block',
1550
+ ...style,
1551
1551
  });
1552
1552
  }, [style]);
1553
1553
  // Simple if not editing
@@ -1659,7 +1659,7 @@ const TreeNode = ({ id, canRemove, canRename, canAddChildren, canRemoveChildren,
1659
1659
  e.stopPropagation();
1660
1660
  const menuItems = [];
1661
1661
  if (canAddChildren)
1662
- menuItems.push({ label: 'Add directory', action: addChild });
1662
+ menuItems.push({ label: 'Add', action: addChild });
1663
1663
  if (canRename)
1664
1664
  menuItems.push({ label: 'Rename', action: renameThis });
1665
1665
  if (canRemove && (childNodes === undefined || childNodes.length === 0))
@@ -1696,7 +1696,7 @@ const TreeNode = ({ id, canRemove, canRename, canAddChildren, canRemoveChildren,
1696
1696
  visibility: expanded ? 'inherit' : 'hidden',
1697
1697
  opacity: expanded ? 1 : 0,
1698
1698
  transition: 'visibility .3s, opacity .3s ease-in-out, max-height 0.3s ease-in-out',
1699
- }, children: jsx(TreeNode, { id: h.id, canRemove: canRemoveChildren, canRename: canRenameChildren, canAddChildren: canAddChildren, canRemoveChildren: canRemoveChildren, canRenameChildren: canRenameChildren }) }, h.id))) })), showNewNode && (jsx("div", { children: jsx(WordEntry, { id: id ? `hierarchynode-new-${id}` : undefined, ref: newNameRef, editing: true, setValue: (ret) => {
1699
+ }, children: jsx(TreeNode, { id: h.id, canRemove: canRemoveChildren, canRename: canRenameChildren, canAddChildren: canAddChildren, canRemoveChildren: canRemoveChildren, canRenameChildren: canRenameChildren }) }, h.id))) })), showNewNode && (jsx("div", { children: jsx(WordEntry, { style: { marginLeft: '14px' }, id: id ? `hierarchynode-new-${id}` : undefined, ref: newNameRef, editing: true, setValue: (ret) => {
1700
1700
  confirmNewNode(ret);
1701
1701
  }, saving: savingNewNode, sendEscape: () => {
1702
1702
  setShowNewNode(false);
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .context-menu{background-color:#fbfdf6;border:1px solid #111418;border-radius:8px;opacity:1;position:absolute;visibility:hidden}.context-menu.visible{visibility:"inherit"}.context-menu-item{color:#111418;cursor:pointer;min-width:80px;padding:0 4px}.context-menu-item:first-child{padding-top:2px}.context-menu-item:last-child{padding-bottom:2px}.context-menu-item:hover{background-color:#fbe9e6}.context-menu-item:hover:first-child{border-radius:6px 6px 0 0}.context-menu-item:hover:last-child{border-radius:0 0 6px 6px}
@@ -29,6 +29,11 @@ interface TreeNodeProps {
29
29
  }
30
30
  declare const TreeNode: ({ id, canRemove, canRename, canAddChildren, canRemoveChildren, canRenameChildren, }: TreeNodeProps) => JSX.Element;
31
31
 
32
+ declare type TreeNodeBase = {
33
+ id: Key;
34
+ label: string;
35
+ parentId?: Key;
36
+ };
32
37
  declare type TreeNodeData<T> = {
33
38
  id: Key;
34
39
  label: string;
@@ -54,7 +59,7 @@ interface iTreeOfNodes<T> {
54
59
  canRemoveChildren?: boolean;
55
60
  canRenameChildren?: boolean;
56
61
  }
57
- declare const TreeOfNodes: <T extends object>({ nodeList, roots, canRemoveRoot, canRenameRoot, canAddChildren, canRemoveChildren, canRenameChildren, selectedId, handleSelect, onAdd, onRename, onRemove, }: iTreeOfNodes<T>) => JSX.Element;
62
+ declare const TreeOfNodes: <T extends unknown>({ nodeList, roots, canRemoveRoot, canRenameRoot, canAddChildren, canRemoveChildren, canRenameChildren, selectedId, handleSelect, onAdd, onRename, onRemove, }: iTreeOfNodes<T>) => JSX.Element;
58
63
 
59
64
  interface WordEntryProps {
60
65
  id?: string;
@@ -67,4 +72,4 @@ interface WordEntryProps {
67
72
  }
68
73
  declare const WordEntry: React.ForwardRefExoticComponent<WordEntryProps & React.RefAttributes<HTMLInputElement>>;
69
74
 
70
- export { ContextMenu, ContextMenuProvider, TreeNode, TreeNodeData, TreeOfNodes, WordEntry, iNodeUpdate };
75
+ export { ContextMenu, ContextMenuProvider, TreeNode, TreeNodeBase, TreeNodeData, TreeOfNodes, WordEntry, iNodeUpdate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asup/tree-of-nodes",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "REACT Typescript Treeview component",
5
5
  "author": "Paul Thomas <@PaulDThomas>",
6
6
  "private": false,
@@ -69,7 +69,7 @@
69
69
  "**/*": "prettier --write --ignore-unknown"
70
70
  },
71
71
  "main": "dist/cjs/main.js",
72
- "module": "dist/esm/main.js",
72
+ "module": "dist/main.js",
73
73
  "types": "dist/tree-of-nodes.d.ts",
74
74
  "files": [
75
75
  "dist"
@@ -93,8 +93,8 @@
93
93
  ]
94
94
  },
95
95
  "scripts": {
96
- "build": "rollup -c --configPlugin typescript && parcel build demo/index.html -d demo/public --public-url ./",
97
- "start": "parcel demo/index.html",
96
+ "build": "rollup -c --configPlugin typescript",
97
+ "start": "parcel demo/index.html --dist-dir demo/dist",
98
98
  "test": "jest"
99
99
  }
100
100
  }
Binary file