@teambit/workspace 0.0.621 → 0.0.629

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,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/workspace",
3
- "version": "0.0.621",
3
+ "version": "0.0.629",
4
4
  "homepage": "https://bit.dev/teambit/workspace/workspace",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.workspace",
8
8
  "name": "workspace",
9
- "version": "0.0.621"
9
+ "version": "0.0.629"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -37,43 +37,42 @@
37
37
  "core-js": "^3.0.0",
38
38
  "@teambit/base-ui.surfaces.split-pane.hover-splitter": "1.0.0",
39
39
  "@teambit/base-ui.surfaces.split-pane.split-pane": "1.0.0",
40
- "@teambit/base-ui.graph.tree.recursive-tree": "1.0.0",
41
- "@teambit/component-id": "0.0.398",
40
+ "@teambit/component-id": "0.0.400",
42
41
  "@teambit/bit-error": "0.0.394",
43
42
  "@teambit/legacy-bit-id": "0.0.397",
44
- "@teambit/logger": "0.0.516",
45
- "@teambit/scope": "0.0.621",
46
- "@teambit/cli": "0.0.427",
47
- "@teambit/isolator": "0.0.621",
48
- "@teambit/component-tree": "0.0.411",
43
+ "@teambit/logger": "0.0.522",
44
+ "@teambit/scope": "0.0.629",
45
+ "@teambit/cli": "0.0.433",
46
+ "@teambit/isolator": "0.0.629",
47
+ "@teambit/component-tree": "0.0.417",
49
48
  "@teambit/component.ui.component-status-resolver": "0.0.490",
50
49
  "@teambit/harmony.modules.resolved-component": "0.0.483",
51
- "@teambit/dependency-resolver": "0.0.621",
52
- "@teambit/compiler": "0.0.621",
53
- "@teambit/component": "0.0.621",
54
- "@teambit/graphql": "0.0.621",
55
- "@teambit/aspect-loader": "0.0.621",
56
- "@teambit/bundler": "0.0.621",
57
- "@teambit/envs": "0.0.621",
58
- "@teambit/pubsub": "0.0.621",
59
- "@teambit/ui": "0.0.621",
60
- "@teambit/variants": "0.0.518",
50
+ "@teambit/dependency-resolver": "0.0.629",
51
+ "@teambit/compiler": "0.0.629",
52
+ "@teambit/component": "0.0.629",
53
+ "@teambit/graphql": "0.0.629",
54
+ "@teambit/aspect-loader": "0.0.629",
55
+ "@teambit/bundler": "0.0.629",
56
+ "@teambit/envs": "0.0.629",
57
+ "@teambit/pubsub": "0.0.629",
58
+ "@teambit/ui": "0.0.629",
59
+ "@teambit/variants": "0.0.524",
61
60
  "@teambit/component-issues": "0.0.45",
62
- "@teambit/config": "0.0.439",
61
+ "@teambit/config": "0.0.445",
63
62
  "@teambit/harmony.modules.requireable-component": "0.0.483",
64
- "@teambit/importer": "0.0.52",
63
+ "@teambit/importer": "0.0.58",
65
64
  "@teambit/workspace.modules.match-pattern": "0.0.487",
66
- "@teambit/command-bar": "0.0.621",
65
+ "@teambit/command-bar": "0.0.629",
67
66
  "@teambit/design.ui.surfaces.menu.link-item": "0.0.377",
68
- "@teambit/graph": "0.0.621",
69
- "@teambit/react-router": "0.0.621",
70
- "@teambit/sidebar": "0.0.621",
67
+ "@teambit/graph": "0.0.629",
68
+ "@teambit/react-router": "0.0.629",
69
+ "@teambit/sidebar": "0.0.629",
71
70
  "@teambit/ui-foundation.ui.main-dropdown": "0.0.485",
72
71
  "@teambit/ui-foundation.ui.menu": "0.0.485",
73
72
  "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.487",
74
73
  "@teambit/toolbox.time.time-format": "0.0.482",
75
74
  "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.486",
76
- "@teambit/deprecation": "0.0.621",
75
+ "@teambit/deprecation": "0.0.629",
77
76
  "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.486",
78
77
  "@teambit/ui-foundation.ui.buttons.collapser": "0.0.192",
79
78
  "@teambit/ui-foundation.ui.corner": "0.0.493",
@@ -81,12 +80,13 @@
81
80
  "@teambit/ui-foundation.ui.top-bar": "0.0.488",
82
81
  "@teambit/design.ui.styles.ellipsis": "0.0.347",
83
82
  "@teambit/design.ui.styles.muted-italic": "0.0.35",
83
+ "@teambit/design.ui.tree": "0.0.2",
84
84
  "@teambit/ui-foundation.ui.full-loader": "0.0.485",
85
- "@teambit/ui-foundation.ui.side-bar": "0.0.492",
86
- "@teambit/ui-foundation.ui.tree.drawer": "0.0.486",
85
+ "@teambit/ui-foundation.ui.side-bar": "0.0.494",
86
+ "@teambit/ui-foundation.ui.tree.drawer": "0.0.488",
87
87
  "@teambit/explorer.ui.gallery.component-grid": "0.0.485",
88
88
  "@teambit/workspace.ui.empty-workspace": "0.0.488",
89
- "@teambit/workspace.ui.workspace-component-card": "0.0.490"
89
+ "@teambit/workspace.ui.workspace-component-card": "0.0.492"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/lodash": "4.14.165",
@@ -106,7 +106,7 @@
106
106
  },
107
107
  "peerDependencies": {
108
108
  "@apollo/client": "^3.0.0",
109
- "@teambit/legacy": "1.0.206",
109
+ "@teambit/legacy": "1.0.209",
110
110
  "react-dom": "^16.8.0 || ^17.0.0",
111
111
  "react": "^16.8.0 || ^17.0.0"
112
112
  },
@@ -134,7 +134,7 @@
134
134
  "react": "-"
135
135
  },
136
136
  "peerDependencies": {
137
- "@teambit/legacy": "1.0.206",
137
+ "@teambit/legacy": "1.0.209",
138
138
  "react-dom": "^16.8.0 || ^17.0.0",
139
139
  "react": "^16.8.0 || ^17.0.0"
140
140
  }
@@ -2,3 +2,7 @@
2
2
  padding: 8px 8px 0 28px;
3
3
  display: block;
4
4
  }
5
+
6
+ .collapseIcon {
7
+ width: 16px;
8
+ }
@@ -8,10 +8,8 @@ import {
8
8
  NamespaceTreeNode,
9
9
  ScopePayload,
10
10
  } from '@teambit/ui-foundation.ui.side-bar';
11
-
12
- import type { TreeNodeProps } from '@teambit/base-ui.graph.tree.recursive-tree';
13
-
14
- import React, { useCallback, useContext } from 'react';
11
+ import { TreeNodeProps } from '@teambit/design.ui.tree';
12
+ import React, { useCallback, useContext, useState, createContext } from 'react';
15
13
  import classNames from 'classnames';
16
14
  import { ComponentTreeSlot } from '@teambit/component-tree';
17
15
  import { mutedItalic } from '@teambit/design.ui.styles.muted-italic';
@@ -19,20 +17,35 @@ import { ellipsis } from '@teambit/design.ui.styles.ellipsis';
19
17
  import { WorkspaceContext } from '../workspace/workspace-context';
20
18
  import styles from './workspace-components-drawer.module.scss';
21
19
 
20
+ const WorkspaceTreeContext = createContext<{ collapsed: boolean; setCollapsed: (x: boolean) => void }>({
21
+ collapsed: true,
22
+ setCollapsed: () => {},
23
+ });
24
+
22
25
  export class WorkspaceComponentsDrawer implements DrawerType {
23
26
  constructor(private treeNodeSlot: ComponentTreeSlot) {}
24
27
 
25
28
  name = 'COMPONENTS';
26
29
 
30
+ widget = (<Widget />);
31
+
32
+ Context = ({ children }) => {
33
+ const [collapsed, setCollapsed] = useState(true);
34
+ return (
35
+ <WorkspaceTreeContext.Provider value={{ collapsed, setCollapsed }}>{children}</WorkspaceTreeContext.Provider>
36
+ );
37
+ };
38
+
27
39
  render = () => {
28
40
  const workspace = useContext(WorkspaceContext);
41
+ const { collapsed } = useContext(WorkspaceTreeContext);
29
42
  const { treeNodeSlot } = this;
30
43
 
31
44
  const TreeNodeRenderer = useCallback(
32
45
  function TreeNode(props: TreeNodeProps<PayloadType>) {
33
46
  const children = props.node.children;
34
47
 
35
- if (!children) return <ComponentView {...props} treeNodeSlot={treeNodeSlot} />;
48
+ if (!children) return <ComponentView {...props} treeNodeSlot={treeNodeSlot} />; // non collapse
36
49
 
37
50
  if (props.node.payload instanceof ScopePayload) return <ScopeTreeNode {...props} />;
38
51
 
@@ -42,8 +55,18 @@ export class WorkspaceComponentsDrawer implements DrawerType {
42
55
  );
43
56
 
44
57
  if (!workspace) return <FullLoader />;
45
- if (workspace.components.length === 0)
58
+ if (workspace.components.length === 0) {
46
59
  return <span className={classNames(mutedItalic, ellipsis, styles.emptyWorkspace)}>Workspace is empty</span>;
47
- return <ComponentTree components={workspace.components} TreeNode={TreeNodeRenderer} />;
60
+ }
61
+
62
+ return <ComponentTree components={workspace.components} isCollapsed={collapsed} TreeNode={TreeNodeRenderer} />;
48
63
  };
49
64
  }
65
+
66
+ function Widget() {
67
+ const { collapsed, setCollapsed } = useContext(WorkspaceTreeContext);
68
+ const icon = collapsed
69
+ ? 'https://static.bit.dev/bit-icons/expand.svg'
70
+ : 'https://static.bit.dev/bit-icons/collapse.svg';
71
+ return <img src={icon} className={styles.collapseIcon} onClick={() => setCollapsed(!collapsed)} />;
72
+ }