sample-ui-component-library 0.0.11-dev → 0.0.13-dev

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sample-ui-component-library",
3
- "version": "0.0.11-dev",
3
+ "version": "0.0.13-dev",
4
4
  "description": "A library which contains sample UI elements that can be used for populating layouts.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -34,7 +34,7 @@ export const Tabs = () => {
34
34
  const list = [];
35
35
  tabs.forEach((tab, index) => {
36
36
  list.push(<Gutter key={tab.uid + "-gutter"} id={tabGroupId + "-" + index} index={index} parentId={tabGroupId} />);
37
- list.push(<Tab key={tab.uid} id={tab.uid} parentId={tabGroupId} node={tab} />);
37
+ list.push(<Tab key={tab.uid} id={"tab-" + tabGroupId + "-" + tab.uid} parentId={tabGroupId} node={tab} />);
38
38
  });
39
39
  list.push(<Gutter key="last-gutter" id={tabGroupId + "-" + tabs.length} index={tabs.length} parentId={tabGroupId} />);
40
40
  setTabsList(list);
@@ -10,7 +10,6 @@ import {
10
10
  import "./FileBrowser.scss";
11
11
 
12
12
  import { Tree } from "./Tree/Tree";
13
- import { TreeNodePreview } from "./TreeNode/TreeNode";
14
13
 
15
14
  import { FileBrowserContext } from "./FileBrowserContext";
16
15
 
@@ -37,25 +36,14 @@ export const FileBrowser = forwardRef(({onSelectFile}, ref) => {
37
36
  const selectNode = useCallback((node) => {
38
37
  dispatch({ type: "SELECT_NODE", payload: node });
39
38
  }, []);
40
-
41
- const getPreviewElement = useCallback((tabId) => {
42
- // Get the preview element for a tab by its id for use in drag-and-drop operations.
43
- const tab = state.flattenedTree.find(t => t.uid === tabId);
44
- if (!tab) {
45
- console.error(`getPreviewElement: tab with id ${tabId} not found.`);
46
- return null;
47
- }
48
- return <TreeNodePreview node={tab} />;
49
- }, [state]);
50
39
 
51
40
  const api = useMemo(() => {
52
41
  return {
53
42
  state,
54
43
  addFileTree,
55
- selectNode,
56
- getPreviewElement
44
+ selectNode
57
45
  };
58
- }, [state, addFileTree, selectNode, getPreviewElement]);
46
+ }, [state, addFileTree, selectNode]);
59
47
 
60
48
  useImperativeHandle(ref, () => api, [api]);
61
49
 
@@ -4,6 +4,9 @@ import {
4
4
  flattenTree,
5
5
  } from "./helper";
6
6
 
7
+ //TODO: I should set a unique id for each reducer state and use it
8
+ // for all the ids of the components to make them unique. I could
9
+ // also manually set the ID like I do in the editor reducer.
7
10
  export const initialState = {
8
11
  tree: {},
9
12
  flattenedTree: {},
@@ -1,20 +1,12 @@
1
1
  import {
2
2
  useEffect,
3
- useState,
4
- useRef
3
+ useState
5
4
  } from "react";
6
5
 
7
6
  import { TreeNode } from "../TreeNode/TreeNode";
8
7
 
9
8
  import { useFileBrowser } from "../FileBrowser";
10
9
 
11
- import {
12
- setDefaultCollapsed,
13
- collapseTree,
14
- selectNode,
15
- flattenTree,
16
- } from "../helper";
17
-
18
10
  import "./Tree.scss";
19
11
 
20
12
  /**
@@ -40,7 +32,7 @@ export const Tree = ({}) => {
40
32
  <TreeNode
41
33
  key={node.uid}
42
34
  node={node}
43
- id={node.name}
35
+ id={"tree-node-" + node.uid}
44
36
  />,
45
37
  );
46
38
  });
@@ -1,10 +1,7 @@
1
1
  import { FileCode, ChevronRight, ChevronDown, Braces, FiletypeScss, FiletypeJs, FiletypePy } from "react-bootstrap-icons";
2
2
  import PropTypes from 'prop-types';
3
3
  import {
4
- DndContext,
5
- DragOverlay,
6
- useDraggable,
7
- useDroppable,
4
+ useDraggable
8
5
  } from "@dnd-kit/core";
9
6
 
10
7
  import { useFileBrowser } from "../FileBrowser";
@@ -24,7 +21,7 @@ export const TreeNode = ({ id, node }) => {
24
21
  data: {
25
22
  type: "FileTreeNode",
26
23
  node: node,
27
- preview: <TreeNodePreview node={node}/ >
24
+ preview: <TreeNodePreview node={node} />
28
25
  }
29
26
  }
30
27
  );