caplink-saas-ui-shared-component-library 0.5.4 → 0.5.5

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,78 +1,78 @@
1
- # caplink-saas-ui-shared-component-library
2
-
3
- This project is a shared component library for the Caplink SaaS UI. It is built using React and Storybook.
4
-
5
- ## Installation
6
-
7
- 1. Clone the repository
8
- 2. Run `npm install` to install the dependencies
9
- 3. Run `npm run storybook` to start the Storybook server
10
-
11
- ## Usage
12
-
13
- To use the components in your project, you can install the package from npm:
14
-
15
- ```bash
16
- npm install @caplink/saas-ui-shared-component-library
17
- ```
18
-
19
- Then import the components you need:
20
-
21
- ```javascript
22
- import { Button } from '@caplink/saas-ui-shared-component-library';
23
- ```
24
-
25
- ## Development
26
-
27
- ### Components
28
-
29
- All the components are located in the 'component-library' folder. Each component should be in its own folder, with the component file and any other files it needs (like styles, tests, etc).
30
-
31
- An expected component development workflow would be:
32
-
33
- 1. Create a new folder for the component
34
- 2. Create the component file (e.g. MyComponent.js)
35
- 3. Create a story file (e.g. MyComponent.stories.js)
36
- 4. Create a test file (e.g. MyComponent.spec.js)
37
- 5. Create a style file (e.g. MyComponent.css) (if needed, we use tailwindcss for styles)
38
- 6. If it's a complex component, create a Cypress test file (e.g. MyComponent.spec.js in the 'cypress' folder)
39
-
40
- ### Folder structure
41
-
42
- - All the components are located in the '/component-library' folder.
43
- - Each component should be in its own folder, with the component file and any other files it needs (like styles, tests, etc).
44
- - Cypress tests are located in the 'cypress' folder and should follow the same folder structure as the components.
45
-
46
- ### Storybook
47
-
48
- We use Storybook to develop and test the components. To start the Storybook server, run:
49
-
50
- ```bash
51
- npm run sb:dev
52
- ```
53
-
54
- ```bash
55
- npm run sb:build
56
- ```
57
-
58
- This will start the Storybook server and open a browser window with the Storybook UI. You can use this to develop and test the components.
59
-
60
- This is the gallery of components that we use to develop and test the components. It's also used to generate the documentation for the components, so it's important to keep it up to date and encompassing relevant states and use cases within the stories.
61
-
62
- ## Testing
63
-
64
- We use multiple testing libraries to test our components. We use Jest for unit tests and Cypress for more complex integration tests that require a browser.
65
-
66
- - All unit tests are located in the same folder as the component they are testing. The file name should be the same as the component file name, but with a '.spec.xxx' suffix.
67
- - All Cypress tests are located in the 'cypress' folder.
68
-
69
- ## Contributing
70
-
71
- This is a project for the Caplink SaaS UI team. If you are a member of the team, you can contribute to this project by following the standard Git workflow:
72
-
73
- 1. Create a new branch for your feature or bug fix
74
- 2. Make your changes
75
- 3. Push your branch to the remote repository
76
- 4. Create a pull request
77
-
78
- Developing components with tests is a requirement for contributing to this project.
1
+ # caplink-saas-ui-shared-component-library
2
+
3
+ This project is a shared component library for the Caplink SaaS UI. It is built using React and Storybook.
4
+
5
+ ## Installation
6
+
7
+ 1. Clone the repository
8
+ 2. Run `npm install` to install the dependencies
9
+ 3. Run `npm run storybook` to start the Storybook server
10
+
11
+ ## Usage
12
+
13
+ To use the components in your project, you can install the package from npm:
14
+
15
+ ```bash
16
+ npm install @caplink/saas-ui-shared-component-library
17
+ ```
18
+
19
+ Then import the components you need:
20
+
21
+ ```javascript
22
+ import { Button } from '@caplink/saas-ui-shared-component-library';
23
+ ```
24
+
25
+ ## Development
26
+
27
+ ### Components
28
+
29
+ All the components are located in the 'component-library' folder. Each component should be in its own folder, with the component file and any other files it needs (like styles, tests, etc).
30
+
31
+ An expected component development workflow would be:
32
+
33
+ 1. Create a new folder for the component
34
+ 2. Create the component file (e.g. MyComponent.js)
35
+ 3. Create a story file (e.g. MyComponent.stories.js)
36
+ 4. Create a test file (e.g. MyComponent.spec.js)
37
+ 5. Create a style file (e.g. MyComponent.css) (if needed, we use tailwindcss for styles)
38
+ 6. If it's a complex component, create a Cypress test file (e.g. MyComponent.spec.js in the 'cypress' folder)
39
+
40
+ ### Folder structure
41
+
42
+ - All the components are located in the '/component-library' folder.
43
+ - Each component should be in its own folder, with the component file and any other files it needs (like styles, tests, etc).
44
+ - Cypress tests are located in the 'cypress' folder and should follow the same folder structure as the components.
45
+
46
+ ### Storybook
47
+
48
+ We use Storybook to develop and test the components. To start the Storybook server, run:
49
+
50
+ ```bash
51
+ npm run sb:dev
52
+ ```
53
+
54
+ ```bash
55
+ npm run sb:build
56
+ ```
57
+
58
+ This will start the Storybook server and open a browser window with the Storybook UI. You can use this to develop and test the components.
59
+
60
+ This is the gallery of components that we use to develop and test the components. It's also used to generate the documentation for the components, so it's important to keep it up to date and encompassing relevant states and use cases within the stories.
61
+
62
+ ## Testing
63
+
64
+ We use multiple testing libraries to test our components. We use Jest for unit tests and Cypress for more complex integration tests that require a browser.
65
+
66
+ - All unit tests are located in the same folder as the component they are testing. The file name should be the same as the component file name, but with a '.spec.xxx' suffix.
67
+ - All Cypress tests are located in the 'cypress' folder.
68
+
69
+ ## Contributing
70
+
71
+ This is a project for the Caplink SaaS UI team. If you are a member of the team, you can contribute to this project by following the standard Git workflow:
72
+
73
+ 1. Create a new branch for your feature or bug fix
74
+ 2. Make your changes
75
+ 3. Push your branch to the remote repository
76
+ 4. Create a pull request
77
+
78
+ Developing components with tests is a requirement for contributing to this project.
@@ -24,6 +24,7 @@ export type NodeProps<T extends Node = Node> = Pick<T, 'id' | 'data' | 'sourcePo
24
24
  export type DefaultNodeDataProps = {
25
25
  content: React.ReactNode;
26
26
  className?: string;
27
+ hideHandles?: boolean;
27
28
  targetHandleClassName?: string;
28
29
  sourceHandleClassName?: string;
29
30
  } & Record<string, unknown>;
@@ -50,6 +51,9 @@ export type EdgePosition = {
50
51
  export type EdgeProps<T extends Edge = Edge> = Pick<T, 'id' | 'animated' | 'data' | 'style' | 'selected' | 'source' | 'target' | 'selectable' | 'deletable'> & EdgePosition & {
51
52
  markerEnd?: string;
52
53
  };
54
+ export type DefaultEdgeProps = {
55
+ edgePath?: 'simpleBezier' | 'smoothStep';
56
+ } & Record<string, unknown>;
53
57
  export declare enum Position {
54
58
  Left = "left",
55
59
  Top = "top",
@@ -100,7 +104,11 @@ export type UseDagProps = {
100
104
  deleteNodes: (node: Node | Node[]) => void;
101
105
  deleteEdges: (edge: Edge | Edge[]) => void;
102
106
  getNodeEdges: (nodeId: string) => Edge[];
103
- changeOrientation: (direction: 'vertical' | 'horizontal') => {
107
+ changeOrientation: (props: {
108
+ direction: 'vertical' | 'horizontal';
109
+ nodeHeight?: number;
110
+ nodeWidth?: number;
111
+ }) => {
104
112
  nodes: Node[];
105
113
  edges: Edge[];
106
114
  };
@@ -1,3 +1,3 @@
1
- import { EdgeProps } from '../../model';
1
+ import { DefaultEdgeProps, Edge, EdgeProps } from '../../model/dag-types';
2
2
 
3
- export declare function DefaultEdge({ sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, style, markerEnd, source, target, }: EdgeProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function DefaultEdge({ sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, style, markerEnd, source, target, data, }: EdgeProps<Edge<DefaultEdgeProps>>): import("react/jsx-runtime").JSX.Element;
@@ -7,5 +7,7 @@ export type ButtonChangeOrientationProps = {
7
7
  edges: Edge[];
8
8
  }) => void;
9
9
  shouldFitView?: boolean;
10
+ nodeHeight?: number;
11
+ nodeWidth?: number;
10
12
  };
11
- export declare const ButtonChangeOrientation: ({ onClick, orientation, shouldFitView, }: ButtonChangeOrientationProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const ButtonChangeOrientation: ({ onClick, orientation, shouldFitView, nodeHeight, nodeWidth, }: ButtonChangeOrientationProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,11 @@
1
1
  import { Edge, Node, Position } from '@xyflow/react';
2
2
 
3
- interface GetLayoutedElementsProps {
3
+ export interface GetLayoutedElementsProps {
4
4
  nodes: Node[];
5
5
  edges: Edge[];
6
6
  direction?: 'vertical' | 'horizontal';
7
+ nodeWidth?: number;
8
+ nodeHeight?: number;
7
9
  }
8
10
  export declare const getLayoutedElements: (props: GetLayoutedElementsProps) => {
9
11
  nodes: {
@@ -46,4 +48,3 @@ export declare const getLayoutedElements: (props: GetLayoutedElementsProps) => {
46
48
  }[];
47
49
  edges: Edge[];
48
50
  };
49
- export {};
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ import { FloatButton, FloatButtonProps } from './shared/ui/float-button';
14
14
  import { IconButtonProps } from './shared/ui/icon-button';
15
15
  import { MatrixTypes, SpreadsheetTypes } from './types';
16
16
  import { Position, Connection, DagProps, DefaultNodeDataProps, Edge, EdgePosition, EdgeProps, Node, NodeProps, UseDagProps } from './components/dag/model';
17
+ import { GetLayoutedElementsProps } from './components/dag/utils/get-layout-elements';
17
18
 
18
19
  export declare const CapLink: {
19
20
  Spreadsheet: typeof Spreadsheet;
@@ -40,7 +41,7 @@ export declare const CapLink: {
40
41
  useDag: () => UseDagProps;
41
42
  useGetAdjacentNodes: ({ nodeId, type }: useGetAdjacentNodesProps) => import('@xyflow/react').Node[];
42
43
  AdjacentNodes: typeof AdjacentNodes;
43
- ButtonChangeOrientation: ({ onClick, orientation, shouldFitView, }: ButtonChangeOrientationProps) => import("react/jsx-runtime").JSX.Element;
44
+ ButtonChangeOrientation: ({ onClick, orientation, shouldFitView, nodeHeight, nodeWidth, }: ButtonChangeOrientationProps) => import("react/jsx-runtime").JSX.Element;
44
45
  ButtonZoomIn: () => import("react/jsx-runtime").JSX.Element;
45
46
  ButtonZoomOut: () => import("react/jsx-runtime").JSX.Element;
46
47
  FloatMenu: typeof FloatMenu;
@@ -100,5 +101,46 @@ export declare const CapLink: {
100
101
  }[];
101
102
  }>;
102
103
  };
104
+ getLayoutedElements: (props: GetLayoutedElementsProps) => {
105
+ nodes: {
106
+ targetPosition: import('@xyflow/system').Position;
107
+ sourcePosition: import('@xyflow/system').Position;
108
+ position: {
109
+ x: number;
110
+ y: number;
111
+ };
112
+ id: string;
113
+ data: Record<string, unknown>;
114
+ type?: string | undefined;
115
+ hidden?: boolean | undefined;
116
+ selected?: boolean | undefined;
117
+ dragging?: boolean | undefined;
118
+ draggable?: boolean | undefined;
119
+ selectable?: boolean | undefined;
120
+ connectable?: boolean | undefined;
121
+ deletable?: boolean | undefined;
122
+ dragHandle?: string | undefined;
123
+ width?: number | undefined;
124
+ height?: number | undefined;
125
+ initialWidth?: number | undefined;
126
+ initialHeight?: number | undefined;
127
+ parentId?: string | undefined;
128
+ zIndex?: number | undefined;
129
+ extent?: "parent" | import('@xyflow/system').CoordinateExtent | undefined;
130
+ expandParent?: boolean | undefined;
131
+ ariaLabel?: string | undefined;
132
+ origin?: import('@xyflow/system').NodeOrigin | undefined;
133
+ handles?: import('@xyflow/system').NodeHandle[] | undefined;
134
+ measured?: {
135
+ width?: number | undefined;
136
+ height?: number | undefined;
137
+ } | undefined;
138
+ style?: import('react').CSSProperties | undefined;
139
+ className?: string | undefined;
140
+ resizing?: boolean | undefined;
141
+ focusable?: boolean | undefined;
142
+ }[];
143
+ edges: import('@xyflow/react').Edge[];
144
+ };
103
145
  };
104
- export type { FileUploaderProps, ImageUploaderProps, MatrixTypes, SpreadsheetTypes, SearchNodeProps, IconButtonProps, FloatButtonProps, ContentSplitProps, SidebarProps, useGetAdjacentNodesProps, AdjacentNodesProps, ButtonChangeOrientationProps, FloatMenuProps, Connection, DagProps, DefaultNodeDataProps, Edge, EdgePosition, EdgeProps, Node, NodeProps, UseDagProps, Position, };
146
+ export type { FileUploaderProps, ImageUploaderProps, MatrixTypes, SpreadsheetTypes, SearchNodeProps, IconButtonProps, FloatButtonProps, ContentSplitProps, SidebarProps, useGetAdjacentNodesProps, AdjacentNodesProps, ButtonChangeOrientationProps, FloatMenuProps, Connection, DagProps, DefaultNodeDataProps, Edge, EdgePosition, EdgeProps, Node, NodeProps, UseDagProps, Position, GetLayoutedElementsProps };